Fonction SAP BAPI_RECORD_ADDELEMENT - Insert Element in Record

Paramètre Reférence Type Long. Valeur par déf. Facultatif Description
ALL_SAME_NAME_ANCHOR BAPISRMREC-BOOLEAN C 1 ' ' X Insert in all anchors with the same name (using parameter ANCHOR)
ANCHOR BAPISRMREC-ANCHOR C 64 X Position for Insertion into the Record (Name of Anchor or *)
DESCRIPTION BAPISRMREC-EL_DESCR C 128 X Description for Display in Records Browser
DOCUMENTCLASS BAPISRMREC-DOCCLASS C 10 Storage Location of Record (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 Insert Using the Anchor (New)
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 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
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 Indicator: Create New Logical Version of Record?

Paramètre Reférence Type Long. Description
RETURN BAPIRET2 u 548 Return Code

Paramètre Reférence Long. Facultatif Description
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


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
                      The element will be inserted wherever the specified anchor is found.

                      Value range
                      This parameter is only evaluated if the insertion is made for eachindividual anchor.

                      Default
                      The element will only be inserted at the first anchor found.

                      Description
                      Position at which the element is to be added to the record (anchor).
                      Enter the name of an anchor defined for the element in the recordmodel, which determines the position at which the element is to beinserted. This is the value of the attribute ANCHOR for the model nodethat represents the element. The model node must be in the record modelon which the particular record is based.
                      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
                      Descriptive text that is displayed in the Records Browser for the forthe element to be inserted.

                      Description
                      Location of the record (content model) in which you want to insert theelement. If the record is in the WebDAV, give this parameter aninitial value.

                      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
                      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 defaul 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). Die Eindeutigkeit dieses Attributsinnerhalb der Akte hat der Verwender sicherzustellen!
                            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 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.

                                      Description
                                      Internal ID of the record in which the element is 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
                                      Element type of the element to be inserted, if it is an instanceelement.

                                      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 this indicator is set, a new logical version of the record iscreated.
                                      Otherwise, no new logical record version is created.
                                      If you want to create a new logical record version without inserting anelement in the record, enter 'X' in the parameter STORE_AS_NEW_VERSION,and transfer an empty table for the parameter ELEMENT_SP_POID.

                                      Description
                                      The free attributes for the element to be inserted can be transferredas name-value pairs in this table.
                                      These attributes are saved in the record for the element and can bedisplayed or changed in the Records Browser.
                                      The names of the free attributes must not contain any emptyspaces.

                                      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 the informationthat allows the service provider responsible to uniquely identify anelement.
                                      Which information a service provider needs to identify elements isavailable in the SAP Records Registry (transaction SRMREGEDIT. If youdouble-click on a service provider, its "SP POID Parameters" aredisplayed on 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 ,,
                                      Caution
                                      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 is used for transferring the roles for which the element tobe 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 is to be visible for the rolesZ_RM_REGISTRATOR and Z_RM_ADMINISTRATOR.
                                      NAME,,VALUE
                                      Z_RM_REGISTRATOR
                                      Z_RM_ADMINISTRATOR