Fonction SAP BAPI_RECORD_ADDELEMENTS - Insert Multiple Elements in Record

Paramètre Reférence Type Long. Valeur par déf. Facultatif Description
DOCUMENTCLASS BAPISRMREC-DOCCLASS C 10 Record Location
DOC_CONTEXT BAPIDOCCONTEXT u 64 X SRM Context for Document Access
OBJECTID BAPISRMREC-GUID C 32 Internal ID of Record
OMIT_AUTHORITY_CHECK BAPISRMREC-BOOLEAN C 1 ' ' X Perform Authority Check Yes/No
SET_ELEM_DESCR_HARD BAPISRMREC-BOOLEAN C 1 ' ' X Specifies whether the DESCRIPTION can be overwritten by the SP's description
SKIP_ELEMS_WITH_ERROR BAPISRMREC-BOOLEAN C 1 'X' X Indicator: Ignore Elements with Errors
STACKED BAPISRMREC-BOOLEAN C 1 'X' X Insert Front or Back (Within model_id)
STORE_AS_NEW_VERSION BAPISRMREC-BOOLEAN C 1 ' ' X Indicator: Create New Logical Version of Record?

Paramètre Reférence Long. Facultatif Description
ELEMENT_IDENTIFICATION BAPIPROPME 324 Identification of Elements to be Inserted
ELEMENT_INSERTION BAPIINSERT 324 X Information for Inserting Elements into the Record
ELEMENT_INSERTION_BY_ANCHOR BAPISRMREC_ANCHORINS_MULTIP 656 X Insert Using Anchor (New)
ELEMENT_INSERTION_BY_MODELID BAPISRMREC_MODELIDINS_MULTIP 600 X Insert Using Model Node
ELEMENT_INSERTION_BY_REF_NODE BAPISRMREC_REFINS_MULTIP 272 X Insert Using Reference Node
ELEMENT_PROPERTIES BAPIPROPME 324 X Attributes for Elements to be Inserted
ELEMENT_VISIBILITY BAPIPROPME 324 X Roles, for Which Elements to be Inserted Are to be Visible
RETURN BAPIRET2 548 Return Code

Functionality
Inserts multiple elements in a record.

Example
* Fill SP POID table
CLEAR element_identification.
  
* SP POID 1. element (Service Provider for Documents)
wa_element_identification-ELEM_NO = 1.
* "%" is used to distinguish the SPS_ID from other POID parameters.
wa_element_identification-NAME = '%SPS_ID%'.
wa_element_identification-VALUE = 'SRM_SPS_DOCUMENT'.
APPEND wa_element_identification TO element_identification.
  
wa_element_identification-NAME = 'DOC_ID'.
wa_element_identification-VALUE = C_DOC_ID.
APPEND wa_element_identification TO element_identification.
  
wa_element_identification-NAME = 'VARIANT'.
wa_element_identification-VALUE = '0'.
APPEND wa_elem_identification TO element_identification.
  
wa_element_identification-NAME = 'VERSION'.
wa_element_identification-VALUE = '0'.
APPEND wa_element_identification TO element_identification.
  
* SP POID 2. element (Service Provider for Transactions)
wa_element_identification-ELEM_NO = 2.
  
wa_element_identification-NAME = '%SPS_ID%'.
wa_element_identification-VALUE = 'SRM_SPS_GENERAL_TRANSACTION
'.
APPEND wa_element_identification TO element_identification.
  
wa_element_identification-NAME = 'TCODE'.
wa_element_identification-VALUE = ''.
APPEND wa_element_identification TO element_identification.
  
*** Fill element insertion table
*Insertion by Anchor
CLEAR element_insertion.
wa_element_insertion-ELEM_NO = 1.
wa_element_insertion-ANCHOR = 'MY_DOC_ANCHOR'.
wa_element_insertion-DESCR = 'My document description'.
APPEND wa_element_insertion TO element_insertion.
  
*Insertion by ModelId
wa_element_insertion_modelid-ELEM_NO = 2.
wa_element_insertion_modelid-MODEL_ID = '10'. "an existing node inthe record model
wa_element_insertion_modelid-DESCR = 'My transaction description'.

APPEND wa_element_insertion_modelid TO element_insertion_modelid.
  
* Fill element properties table
CLEAR element_properties.
wa_element_properties-ELEM_NO = 1.
wa_element_properties-NAME = 'MY_DOC_PROPERTY_NAME'.
wa_element_properties-VALUE = 'MY_DOC_PROPERTY_VALUE'.
APPEND wa_ element_properties TO element_properties.
  
* Call the BAPI
CALL FUNCTION 'BAPI_RECORD_ADDELEMENTS'
  EXPORTING
    OBJECT_ID,,,,,,,,,,= 'FE55793BA8182177E10000000A1148F5'
    DOCUMENTCLASS ,,          ,,= 'SRM_REC00'
    SKIP_ELEMS_WITH_ERROR    ,,= 'X'
  TABLES
    ELEMENT_IDENTIFICATION,,,,= element_identification
    ELEMENT_INSERTION        ,,= element_insertion
    ELEMENT_PROPERTIES       ,,= element_properties
    RETURN                   ,,= bapi_return_tab
ELEMENT_INSERTION_BY_MODELID,,= element_insertion_modelid.

Notes
The following requirements must be met:

  • A record has been created. OBJECTID and DOCUMENTCLASS are known.

  • The insertion position in the record is defined for each element by one
  • of the table parameters listed below. You must ensure that each elementis listed in only one of these tables:
    ELEMENT_INSERTION (to insert the element using an anchor)
    ELEMENT_INSERTION_BY_ANCHOR (to insert the element using an anchor, new,with added options)
    ELEMENT_INSERTION_BY_MODELID (to insert the element using a model ID)
    ELEMENT_INSERTION_BY_REF_NODE (to insert the element using an existingreference node in the record)
    • The record model has the status 'Released' or 'Final'

    • Insertion of elements that are stored in the WebDAV repository, and
    • whose underlying URL (-> documentation on Records Management) exceeds128 Bytes, is not supported.
      The following authorizations are required:
      • Authorization for displaying record content (authorization object
      • S_SRMGS_CT)
        • Authorization for displaying record properties (authorization object
        • S_SRMGS_PR)
          • Authorization for displaying record models (authorization object
          • S_SRMGS_CT)
            • Authorization for displaying properties of the record model
            • (authorization object S_SRMGS_PR)
              • Authorization for creating versions/variants of records (authorization
              • object S_SRMGS_VV)
                • Authorization for changing record properties (authorization object
                • S_SRMGS_PR)
                  • Authorization for adding record content (authorization object
                  • S_SRMGS_CT)

                    Further information
                    Documentation for the business object type "Record"

                    Description
                    Location of the record (content model) in which you want to insert theelements. If the record is in the WebDAV, give this parameter an initialvalue.

                    Description
                    If the record is stored in the WebDAV, you must specify the RMS and SPS(corresponding element type of the record) here. Otherwise, you do notneed to set this parameter.

                    Description
                    Internal ID of the record in which the elements are to be inserted

                    Description
                    This parameter determines whether the authority check will be performed.

                    Default
                    The authority check will be performed.

                    Description
                    This parameter determines whether the DESCRIPTION can be overwritten bythe corresponding service provider's description.

                    Description
                    If this indicator is selected, elements with errors are ignored.
                    Otherwise, processing is terminated at the first error.

                    Description
                    This parameter specifies whether the element is inserted at the start("X") or at the end (" ") of the model ID.

                    Default
                    By default, the element is inserted at the start of the model ID.

                    Description
                    If the indicator is set, a new logical version is created for a record.
                    If it is not, no new logical record version is created.
                    If you want to create a new logical version without inserting elementsinto the record, enter 'X' in the parameter STORE_AS_NEW_VERSION, andtransfer an empty table for the parameter ELEMENT_IDENTIFICATION.

                    Description
                    This table is used to transfer all information for the uniqueidentification of the elements to be inserted in a record.
                    The table has three columns:

                    • Sequence number of the element to insert.

                    • All elements to be inserted are assigned consecutive element numbers.These are used when determining which table entries are associated withwhich elements.
                      • Parameter Name

                      • Parameter Value

                      • The columns parameter name and parameter value transfername-value pairs for parameters that uniquely identify the element to beinserted.
                        In one row, first enter the element type of the element beinginserted (for instance elements) or a constant (for structure nodes). Ifthe element is an instance element, you need to add further rows todescribe the SP POID of the element (see b) ):

                        a) Element is a structure node
                        ELEM_NO,,NAME,,VALUE
                        Seq. no. of element ,,%FOLDER% ,,

                        b) Element is an instance element
                        ELEM_NO,,NAME,,VALUE
                        Seq. no. of the element to be inserted ,,%SPS_ID% ,,

                        Then enter the SP POID. This is the information that allows the"responsible" service provider to uniquely identify an element.
                        Which information a service provider needs to identify elements isdetailed in the SAP Records Registry (transaction SRMREGEDIT). If youdouble-click a service provider, its "SP POID Parameters" are displayedon a tab page with the same name.
                        Enter the parameters specified here and the corresponding values for theelement, along with the sequence number, in the tableELEMENT_IDENTIFICATION.
                        Example for the service provider for documents (SRM_SP_DOCUMENT):
                        ELEM_NO,,NAME,,VALUE
                        Seq. no. of the element to be inserted ,,%SPS_ID% ,,,,,,for example, SRM_SPS_DOCUMENT_DEMO>
                        Seq. no. of the element to be inserted ,,DOC_ID,,

                        Seq. no. of the element to be inserted,,VARIANT,,
                        Seq. no. of the element to be inserted,,VERSION,,
                        Example for the service provider for transactions(SRM_SP_GENERAL_TRANSACTION):
                        ELEM_NO,,NAME,,VALUE
                        Seq. no. of the element to be inserted ,,%SPS_ID% ,,,,,,for example, SRM_SPS_GENERAL_URL_DEMO>
                        Seq. no. of the element to be inserted ,,TCODE,,

                        Important:
                        Currently, only a restricted check is performed on the SP POID. It istherefore possible that errors and inconsistencies in elementidentification are sometimes not recognized, and do not result in anerror message.
                        Insertion of elements that are stored in the WebDAV repository, aswell as their basic URL (-> documentation on Records Management) > 128Bytes, is not supported.

                        Description
                        This table is used to transfer information about how the elements areto be inserted in the record.
                        The table has three columns:

                        • Sequence number of the element to insert.

                        • All elements to be inserted are assigned consecutive element numbers.These are used when determining which table entries are associatedwith which elements.
                          • Anchor

                          • Enter the value of the anchor defined for the element in the recordmodel (attribute ANCHOR). The anchor determines the position in therecord at which the element is to be inserted. The model node must bein the record model on which the particular model is based. Enter thevalue of the attribute ANCHOR for the model node that represents theelement type of the element.
                            If the value '*' is transferred, the element is entered in the Historyof the record. If the name of the anchor is not unique, the firstanchor with this name is used.
                            • Description

                            • Here you can enter a descriptive text, which is displayed in the recordwhen the element is displayed.

                              Description
                              This table is used to transfer information about how the elements are tobe inserted in the record using the anchor. In contrast to theELEMENT_INSERTION table, you have the added option of specifying anexisting record element in the record. If you do this, the element beinginserted will be a child of this record element.
                              The table contains the following columns:

                              • ELEM_NO: Sequence number of the element to insert. All elements to be
                              • inserted are assigned consecutive element numbers. These are used whendetermining which table entries are associated with which elements.
                                • ANCHOR: Enter the value of the anchor defined for the element in the
                                • record model (attribute ANCHOR). The anchor determines the position(model node) in the record at which the element is to be inserted. Themodel node must be in the record model on which the particular model isbased. Enter the value of the attribute ANCHOR for the model node thatrepresents the element type (or structure node) of the element beinginserted.
                                  • PARENT_NODE_ID: You can use this optional parameter to define a parent
                                  • node (ELEMENT_ID) beneath which the element is inserted as a childelement.
                                    • PARENT_NODE_ATTR_NAME & PARENT_NODE_ATTR_VALUE: This optional parameter
                                    • allows you to insert an element under an existing node in the record inthe same way as the parameter "PARENT_NODE_ID". Here though, the parentnode is identified using the name and value of a freely definedattribute (such as a serial number). The user must ensure that thisattribute is unique within the record.
                                      Note: The parent element can be determined using either its ID or anattribute. Both alternatives can be used simultaneously.
                                      • DESCR: Here, you can enter a descriptive text. This text appears in the
                                      • record whenever the element is displayed.

                                        Description
                                        This table is used to transfer information about how the elements are tobe inserted in the record using a model node.
                                        The table contains the following columns:

                                        • ELEM_NO: Sequence number of the element to insert. All elements to be
                                        • inserted are assigned consecutive element numbers. These are used whendetermining which table entries are associated with which elements.
                                          • MODEL_ID: ID of the model node that must exist in the underlying record
                                          • model for the record. The model node must support the element type orstructure node to be inserted.
                                            • PARENT_NODE_ID: You can use this optional parameter to define a parent
                                            • node (ELEMENT_ID) beneath which the element is inserted as a childelement.
                                              • PARENT_NODE_ATTR_NAME & PARENT_NODE_ATTR_VALUE: This optional parameter
                                              • allows you to insert an element under an existing node in the record inthe same way as the parameter "PARENT_NODE_ID". Here though, the parentnode is identified using the name and value of a freely definedattribute (such as a serial number). The user must ensure that thisattribute is unique within the record.
                                                Note: The parent element can be determined using either its ID or anattribute. Both alternatives can be used simultaneously.
                                                • DESCR: Here, you can enter a descriptive text. This text appears in the
                                                • record whenever the element is displayed.

                                                  Description
                                                  This table is used to transfer information about how elements are to beinserted in the record using an existing reference node in the record.
                                                  The table contains the following columns:

                                                  • ELEM_NO: Sequence number of the element to insert. All elements to be
                                                  • inserted are assigned consecutive element numbers. These are used whendetermining which table entries are associated with which elements.
                                                    • REF_NODE_ID: ID of the existing node in the record (of type "instance"
                                                    • or "structure node"). The element is then inserted either before orafter this reference node (depending on the parameter STACKED); themodel node of the reference node is used for the new element. However,this is on condition that the underlying record model for the record inquestion actually allows this (cardinality, for example).
                                                      • ADD_AS_CHILD: if this optional parameter is set to 'X', the element will
                                                      • be inserted as a child in the node referenced by REF_NODE_ID in therecord. However, this is on condition that the underlying record modelfor the record in question actually allows this.
                                                        • DESCR: Here you can enter a descriptive text, which is displayed in the
                                                        • record when the element is displayed.

                                                          Description
                                                          This table is used for transferring free attributes for the elements tobe inserted.
                                                          The table has 3 columns:

                                                          • Sequential number of the element to be inserted.

                                                          • All elements to be added are assigned consecutive element numbers.These are used when determining which table entries are associated withwhich elements.
                                                            • Parameter name

                                                            • Parameter value

                                                            • The columns parameter name and parameter value are used fortransferring name-value-pairs for the free attributes saved for theelement in the record. These can then be displayed and changed in theRecords Browser.
                                                              The names of the free attributes must not contain any emptyspaces.

                                                              Description
                                                              This table is used for transferring the roles for which the elements tobe inserted are to be visible.
                                                              The table has three columns:

                                                              • Sequence number of the element to insert.

                                                              • All elements to be inserted are assigned consecutive element numbers.These are used when determining which table entries are associated withwhich elements.
                                                                • Parameter name

                                                                • Enter the name of a role for which the elements are to be visible. Ifthe element is to be visible in all roles, enter *.
                                                                  • Parameter value

                                                                  • Do not enter anything in this column, it will be ignored.
                                                                    If no roles are specified for an element, the role assignment from thecorresponding node of the record model is used.
                                                                    Example
                                                                    Element 1 is to be visible for the roles Z_RM_REGISTRATOR andZ_RM_ADMINISTRATOR.
                                                                    Element 2 is to be visible for the roles Z_RM_USER andZ_RM_ADMINISTRATOR.
                                                                    Element 3 is to be visible for all roles.
                                                                    For element 4, you want to use the role assignment from the recordmodel. Element 4 is therefore not entered in the table.
                                                                    ELEM_NO,,NAME,,VALUE
                                                                    1,,Z_RM_REGISTRATOR
                                                                    1,,Z_RM_ADMINISTRATOR
                                                                    2,,Z_RM_USER
                                                                    2,,Z_RM_ADMINISTRATOR
                                                                    3,,*

                                                                    Description
                                                                    Result of the BAPI call
                                                                    In contrast to the standard, the entry in the field ROW does notidentify the row number of the data record containing the value witherrors.
                                                                    Rather, ROW identifies the sequence number of the element tobe inserted for which the error occurred, which is transferred in thefield ELEM_NO of the table parameters ELEMENT_IDENTIFICATION,ELEMENT_INSERTION or ELEMENT_PROPERTIES.