Fonction SAP BAPI_RECORD_DELETEELEMENTS - Delete Multiple Elements From Record

Paramètre Reférence Type Long. Valeur par déf. Facultatif Description
DEL_ALL_NOT_UNIQUE_ELEMS BAPISRMREC-BOOLEAN C 1 ' ' X Indicator: Delete all elements that occur more than once in the record
DOCUMENTCLASS BAPISRMREC-DOCCLASS C 10 Record Location
DOC_CONTEXT BAPIDOCCONTEXT u 64 X SRM Context for Document Access
IGNORE_CONNECTION_FAILED BAPISRMREC-BOOLEAN C 1 ' ' X Ignores the exception if the element no longer exists
OBJECTID BAPISRMREC-GUID C 32 Internal ID of Record
SKIP_ELEMS_WITH_ERROR BAPISRMREC-BOOLEAN C 1 'X' X Indicator: Ignore Elements with Errors
STORE_AS_NEW_VERSION BAPISRMREC-BOOLEAN C 1 ' ' X Indicator: Create New Logical Version of Record?

Paramètre Reférence Long. Facultatif Description
ELEM_IDENT_RECPOS BAPIRECPOS 4 X Identification of Elements to be Deleted Using Record Position
ELEM_IDENT_SP_POID BAPIPROPME 324 X Service Provider-Specific Identification of Elements to be Deleted
RETURN BAPIRET2 548 Return Code

Functionality
Deletes multiple elements from a record.

Example
* Remove 2 elements via SP-POID
CLEAR elem_ident_sp_poid.

* SP POID 1. element (Service Provider for Documents)
wa_elem_ident_sp_poid-ELEM_NO = 1
* "%" is used to mark the SPS_ID of other POID parameters.

wa_elem_ident_sp_poid-NAME = '%SPS_ID%'.
wa_elem_ident_sp_poid-VALUE = 'SRM_SP_DOCUMENT'.
APPEND wa_elem_ident_sp_poid TO elem_ident_sp_poid.

wa_elem_ident_sp_poid-NAME = 'DOC_ID'.
wa_elem_ident_sp_poid-VALUE = C_DOC_ID.
APPEND wa_elem_ident_sp_poid TO elem_ident_sp_poid.

wa_elem_ident_sp_poid-NAME = 'VARIANT'.
wa_elem_ident_sp_poid-VALUE = '0'.
APPEND wa_elem_ident_sp_poid TO elem_ident_sp_poid.

wa_elem_ident_sp_poid-NAME = 'VERSION'.
wa_elem_ident_sp_poid-VALUE = '0'.
APPEND wa_elem_ident_sp_poid TO elem_ident_sp_poid.
  
* SP POID 2. element (Service Provider for Transactions)
wa_elem_ident_sp_poid-ELEM_NO = 2

wa_elem_ident_sp_poid-NAME = '%SPS_ID%'.
wa_elem_ident_sp_poid-VALUE = 'SRM_SP_GENERAL_TRANSACTION'.

APPEND wa_elem_ident_sp_poid TO elem_ident_sp_poid.

wa_elem_ident_sp_poid-NAME = 'TCODE'.
wa_elem_ident_sp_poid-VALUE = ''.
APPEND wa_elem_ident_sp_poid TO elem_ident_sp_poid.

* Remove 2 elements via record position
CLEAR elem_ident_recpos.
wa_elem_ident_recpos-REC_NODEID = 23.
APPEND wa_elem_ident_recpos TO elem_ident_recpos.
wa_elem_ident_recpos-REC_NODEID = 37.
APPEND wa_elem_ident_recpos TO elem_ident_recpos.
    
* Call the BAPI
CALL FUNCTION 'BAPI_RECORD_DELETEELEMENTS'
EXPORTING
    OBJECT_ID                = 'FE55793BA8182177E10000000A1148F5'
DOCUMENTCLASS = 'SRM_REC00'
SKIP_ELEMS_WITH_ERROR = 'X'
TABLES
ELEM_IDENT_SP_POID = elem_ident_sp_poid
ELEM_IDENT_RECPOS = elem_ident_recpos
RETURN = bapi_return_tab

  • You cannot address or
  • insert elements that are stored in the WebDAV Repository.
    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)
                  The tables ELEM_IDENT_RECORDS and ELEM_IDENT_SP_POID are processed oneafter the other in this order. Any overlaps can therefore lead to errormessages.

                  Further information
                  Documentation for the business object type "Record":

                  Description
                  Elements can be entered more than once in the same record.
                  If an element that occurs more than once in a record is not identifiedby its position in the record, you can use the parameterDEL_ALL_NOT_UNIQUE_ELEMS to control whether the element is deleted fromall positions in the record (enter 'X'), or only from the firstposition in which it is found (enter ' ').

                  Description
                  Location of the record (content model) from whichyou want to delete 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
                  If this parameter is set, references to elements that no longer existare deleted without raising an exception.

                  Description
                  Internal ID of record from which element is to be deleted

                  Description
                  If the indicator is set, all elements with errors are ignored.
                  Otherwise, processing terminates at the first error.

                  Description
                  If the indicator is selected, a new logical version of the record iscreated for the record.
                  If it is not selected, no new logical record version is created.
                  If you want to create a new logical record version without deletingelements from the record, enter 'X' in the parameterSTORE_AS_NEW_VERSION, and transfer empty tables for the parametersELEM_IDENT_RECPOS and ELEM_IDENT_SP_POID.

                  Description
                  In this table, the elements to be deleted are uniquely identified withinthe record using their node ID. The node ID of an element is displayedin the Records Browser in the column Node ID (record). If the node ID ofa structure node is specified, the whole subtree beneath this node isdeleted.
                  Important Note:
                  Identifying an element by the node ID in the record is an alternativemethod of identification to using the SP POID (tableELEM_IDENT_SP_POID). The entries in the table ELEM_IDENT_RECPOS areprocessed with higher priority than those in the tableELEM_IDENT_SP_POID. There is no logical "AND" link between the tables,instead there is an "OR" link. Therefore, only one of these two tablesshould be used to identify an element.

                  Description
                  This table uses SP POIDs to identify all elements that need to bedeleted. If an element defined by its SP POID appears more than once inrecord, then the value of the parameter DEL_ALL_NOT_UNIQUE_ELEMSdecides whether all instances of this element are removed from therecord (= 'X') or just the first instance (= ' ').
                  Important note:
                  Identifying an element by its SP POID is an alternative to identifyingit by the node ID in the record (table ELEM_IDENT_RECPOS). The entriesin the table ELEM_IDENT_RECPOS take priority over the entries in thetable ELEM_IDENT_SP_POID. There is an OR relationship between thetables, not a logical AND relationship. Therefore, only use one of thesetwo tables to identify an element.
                  The table ELEM_IDENT_SP_POID has three columns:

                  • Sequence number of the element to be removed

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

                    • Parameter value

                    • The columns parameter name and parameter value transfer name-valuepairs for parameters that uniquely identify the element to be deleted.
                      First enter the element type of the element in the table as follows:
                      ELEM_NO,,NAME,,VALUE
                      Sequence no. of element ,,%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 requires for identifying elementsis detailed in the SAP Records Registry (transaction SRMREGEDIT).Double-click on a service provider to display its "SP POID Parameters#on a similar tab page.
                      Enter the parameters specified here and the corresponding values forthe element, 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 element . ,,%SPS_ID% ,,,,,,for example, SRM_SPS_DOCUMENT_DEMO>
                      Seq.No. of element .,,DOC_ID,,
                      Seq.No. of element .,,VARIANT,,
                      Seq.No. of element .,,VERSION,,
                      Example for the service provider for transactions(SRM_SP_GENERAL_TRANSACTION):
                      ELEM_NO,,NAME,,VALUE
                      Seq.No. of element . ,,%SPS_ID% ,,,,,,for example, SRM_SPS_GENERAL_URL_DEMO>
                      Seq.No. of element .,,TCODE,, ,,,,Transaction>
                      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.
                      Elements in the record that are stored in the WebDAV Repositorycan only be addressed or deleted using the parameter ELEM_IDENT_RECPOS.You cannot address these elements with the parameterELEM_IDENT_SP_POID.

                      Description
                      Return value that is empty when no error occurs, or that containsinformation on the errors that have occurred.
                      If an error refers to an entry in the table ELEM_IDENT_RECPOS ,ROW identifies the row number in this table.
                      If an error refers to an entry in the table ELEM_IDENT_SPPOID, ROW
                      identifies the sequential number of the element to be inserted
                      , which is transferred in the table field ELEM_NO.