SAP Function SRM_RECORD_ADDELEMENT - Insert Element in Container

Parameter Reference Type Length Default Optional Text
ANCHOR BAPISRMREC-ANCHOR C 64 X Insert-Position in the Container (Name of an Anchor or *)
DESCRIPTION BAPISRMREC-EL_DESCR C 128 X Description for the Browser Display
DOCUMENTCLASS BAPISRMREC-DOCCLASS C 10 Storage Location for the Container (Content Model)
DOC_CONTEXT BAPIDOCCONTEXT u 64 X SRM Context for Document Access
ELEMENT_TYPE BAPISRMREC_ELEMENT-TYPE C 1 'I' X Type of Record Element
INSERTION_BY_ANCHOR BAPISRMREC_ANCHORINS u 394 X Parent Node When Inserting with Anchor
INSERTION_BY_MODELID BAPISRMREC_MODELIDINS u 341 X Insert Using Model Node
INSERTION_BY_REFERENCE_NODE BAPISRMREC_REFINS u 12 X Insert Using Reference Node
OBJECTID BAPISRMREC-GUID C 32 Internal ID of the Container
SPS_ID BAPISRMREC-SPSID C 32 X Element Type of Element to Insert
STACKED BAPISRMREC-BOOLEAN C 1 'X' X Insert Front or Back (Within model_id)
STORE_AS_NEW_VERSION BAPISRMREC-BOOLEAN C 1 ' ' X Flag: Do you want a new logical version of the container to be created?

Parameter Reference Type Length Text
RETURN BAPIRET2 u 548 Return Code

Parameter Reference Length Optional Text
ELEMENT_PROPERTIES BAPIPROPTB 319 X Attributes for Element to be Inserted
ELEMENT_SP_POID BAPIPROPTB 319 X SP POID: Service Provider-Specific ID of Element to be Inserted
ELEMENT_VISIBILITY BAPIPROPTB 319 X Roles for Which Element to be Inserted Should Be Visible

Exception Text
ANCHOR_NOT_FOUND Anchor Not Found
CONTAINER_IS_LOCKED Container is Locked
CONTAINER_NOT_FOUND Container Not Found
INTERNAL_ERROR Internal Error
MAX_NUMBER_OF_ELEMENTS Maximum Number of Elements Reached
NOT_AUTHORIZED User Not Authorized
PARAMETER_ERROR Parameter Error
POID_IS_WRONG POID Contains Errors
RECORD_IS_FROZEN Record closed


Inserts an element in a record.

Example
Insertion using an anchor
* Fill SP POID table
CLEAR element_sp_poid.
wa_element_sp_poid-NAME = 'DOC_ID'.
wa_element_sp_poid-VALUE = C_DOC_ID.
APPEND wa_element_sp_poid TO element_sp_poid.
  
wa_element_sp_poid-NAME = 'VARIANT'.
wa_element_sp_poid-VALUE = '0'.
APPEND wa_element_sp_poid TO element_sp_poid.
  
wa_element_sp_poid-NAME = 'VERSION'.
wa_element_sp_poid-VALUE = '0'.
APPEND wa_element_sp_poid TO element_sp_poid.
  
* Fill element properties table
CLEAR element_properties.
wa_element_properties-NAME = 'MY_PROPERTY_NAME'.
wa_element_properties-VALUE = 'MY_PROPERTY_VALUE'.
APPEND wa_ element_properties TO element_properties.
  
* Call the BAPI
CALL FUNCTION 'BAPI_RECORD_ADDELEMENT'
  EXPORTING
    OBJECT_ID                = 'FE55793BA8182177E10000000A1148F5'
    DOCUMENTCLASS            = 'SRM_REC00'
    SPS_ID                   = 'SRM_SPS_DOCUMENT'
    ANCHOR                   = 'MY_ANCHOR'
    DESCRIPTION              = 'My element description'
  IMPORTING
    RETURN                   = bapi_return
  TABLES
    ELEMENT_SP_POID          = element_sp_poid
    ELEMENT_PROPERTIES       = element_properties.
Insertion in a specified folder using a model node
* Fill SP POID table
CLEAR element_sp_poid.
wa_element_sp_poid-NAME = 'DOC_ID'.
wa_element_sp_poid-VALUE = C_DOC_ID.
APPEND wa_element_sp_poid TO element_sp_poid.
  
wa_element_sp_poid-NAME = 'VARIANT'.
wa_element_sp_poid-VALUE = '0'.
APPEND wa_element_sp_poid TO element_sp_poid.
  
wa_element_sp_poid-NAME = 'VERSION'.
wa_element_sp_poid-VALUE = '0'.
APPEND wa_element_sp_poid TO element_sp_poid.
  
* Insert by ModelId --> fill corresponding structure ofparameter INSERTION_BY_MODELID
wa_insertion_by_modelid-MODEL_ID = '10'. ,,,,"Model ID has to exist inthe corresponding record model
wa_insertion_by_modelid-PARENT_NODE_ID ='33'.,,"An existing node in therecord for example a folder
  
* Call the BAPI
CALL FUNCTION 'BAPI_RECORD_ADDELEMENT'
  EXPORTING
    OBJECT_ID                = 'FE55793BA8182177E10000000A1148F5'
    DOCUMENTCLASS            = 'SRM_REC00'
    SPS_ID                   = 'SRM_SPS_DOCUMENT'
    DESCRIPTION              = 'My element description'
INSERTION_BY_MODELID = wa_insertion_by_modelid

  IMPORTING
    RETURN                   = bapi_return
  TABLES
    ELEMENT_SP_POID          = element_sp_poid
    ELEMENT_PROPERTIES       = element_properties.

Notes
The following requirements must be met:

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

  • The record model has the status 'Released' or 'Final'

  • The insertion item in the record is determined by one of the following
  • four parameters:
    ANCHOR (Insertion using an anchor)
    INSERTION_BY_ANCHOR (Insertion using an anchor, new, with extendedoptions)
    INSERTION_BY_MODELID (Insertion using a Model ID)
    INSERTION_BY_REFERENCE_NODE (Insertion using an existing reference nodein the record)
    • 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 displaying 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
                      Result of the BAPI call

                      Description
                      Position in which the element is to be inserted in the container(anchor).
                      Enter the name of an anchor defined in the model here. This determinesthe position at which the element is to be inserted in the container.This is the value of the attribute ANCHOR for a model node of theunderlying container. The model node must have the same element type asthe element to be inserted.
                      If the value '*' is transferred, the element is entered in the worklistof the container. If the name of the anchor is not unique, the firstanchor with this name is used.

                      Description
                      Descriptive text to be displayed in the Records Browser for the elementto be inserted.

                      Description
                      Storage location of the container (content model) in which the elementis to be inserted. If the record is stored in WebDAV, this parametershould have an initial value.

                      Description
                      If the record is stored in WebDAV, the RMS and SPS (correspondingelement type of the record) need to be entered here. If not, no entry isrequired in this parameter.

                      Description
                      This parameter specifies whether an instance element ("I") or astructure node ("F") is to be inserted in the record. Note that theelement type must match the anchor or model node used.

                      Default
                      The default setting for this parameter is 'I' (instance element).

                      Description
                      This optional parameter allows you to insert an element using an anchor.In contrast to the parameter "anchor", you have the option here ofdefining a parent element (instance or structure node) under which theelement is then inserted as a child element.
                      The structure of the parameter is as follows:

                      • ANCHOR: Here, you enter the name of the anchor defined in the record
                      • model. The anchor determines the position at which the element is to beinserted in the record. This is the value of the attribute ANCHOR for amodel node of the underlying record model. The model node must have thesame element type as the element 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, though not by both simultaneously.

                            Description
                            This optional parameter allows you to insert an element using a modelnode.
                            The structure of the parameter is as follows:

                            • MODEL_ID: ID of the model node that must exist in the underlying record
                            • model for the record.
                              • 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, though not by both simultaneously.

                                  Description
                                  This optional parameter allows you to insert an element using anexisting reference node in the record.
                                  The structure of the parameter is as follows:

                                  • REF_NODE_ID: ID of the existing node in the record (of type "instance"
                                  • or "structure node"). The element is inserted before or after thisreference node (depending on the parameter STACKED) or as a child of thereference node (see Parameter ADD_AS_CHILD). However, this is oncondition that the underlying record model for the record in questionactually allows this.
                                    • 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.

                                      Description
                                      Internal ID of the container in which the element is to be inserted.

                                      Description
                                      Element type of the element to be inserted

                                      Description
                                      This parameter is used to specify whether the element is inserted at thevery beginning ("X") or at the very end (" " ) of the model ID.

                                      Value range
                                      The standard setting is to insert the element at the beginning of themodel ID.

                                      Description
                                      If this indicator is set, a new logical version is created for thecontainer.
                                      To create a new logical version without inserting an element, enter 'X'in the parameter STORE_AS_NEW_VERSION, and transfer an empty table forthe parameter ELEMENT_SP_POID.

                                      Description
                                      The free attributes for the element to be inserted can be transferred asname-value-pairs in this table.
                                      These attributes are saved for the element in the record, and can bedisplayed and changed in the Records Browser.
                                      The names of the free attributes must not contain anyempty spaces.

                                      Description
                                      Entries are required in this parameter if the element to be inserted isan instance element. If the element to be inserted is a structure node,no entries are required.
                                      This table is used for transferring the 'SP POID'. This is theinformation that allows the service provider responsible to uniquelyidentify 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 of the same name.
                                      Enter the parameters specified on this tab page and the correspondingvalues for the element to be inserted in the table ELEMENT_SP_POID.
                                      Example for the service provider for documents (SRM_SP_DOCUMENT):
                                      NAME,,VALUE
                                      DOC_ID,,
                                      VARIANT,,
                                      VERSION,,
                                      Example for the service provider for transactions(SRM_SP_GENERAL_TRANSACTION)
                                      NAME,,VALUE
                                      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, andwhose underlying URL (-> documention on Records Management) exceeds 128Bytes, is not supported.

                                      Description
                                      This table can be used for transferring the roles for which the elementto be inserted is to be visible.
                                      Enter the role name in the NAME column. If the element is to be visiblefor all roles, enter *. Entries in the VALUE column are ignored.
                                      If the parameter is not transferred, or the table is empty, the roleassignment from the corresponding node of the record model is used.
                                      Example
                                      The element being inserted in the record is to be visible for the rolesZ_RM_REGISTRATOR and Z_RM_ADMINISTRATOR.
                                      NAME,,VALUE
                                      Z_RM_REGISTRATOR
                                      Z_RM_ADMINISTRATOR