Fonction SAP BAPI_DOCUMENT_DELETE - Delete document or set deletion indicator

Paramètre Reférence Type Long. Valeur par déf. Facultatif Description
DOCUMENTNUMBER BAPI_DOC_AUX-DOCNUMBER C 25 Document Number
DOCUMENTPART BAPI_DOC_AUX-DOCPART C 3 Document Part
DOCUMENTTYPE BAPI_DOC_AUX-DOCTYPE C 3 Document Type
DOCUMENTVERSION BAPI_DOC_AUX-DOCVERSION C 2 Document Version

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

Functionality
You can use this method to set a deletion indicator for a document inforecord (DIR).

Notes
The system does not delete any data from the database.
You have two options for deleting a DIR with a deletion indicator fromthe database:

  • By using BAPI Bapi_Document_Delete_Direct

  • By using program MCDOKDEL (report for deleting documents with a
  • deletion indicator)
    Enter the document type for which you want to delete all documents witha deletion indicator. Since there may be several documents with the samedocument type (and a deletion indicator), first run the program in testmode. Then you can run the report live.

    Example
    Example program
    *************
    **Define variables required
    ************
    DATA: ls_doc LIKE bapi_doc_draw2,
    * BAPI return structure
    ls_return LIKE bapiret2.
    *******************************************
    ** Assign document data (which document is to be deleted or
    ** where is the deletion indicator to be set)
    ******************************************
    ls_doc-documenttype = 'DRW'.
    ls_doc-documentnumber = 'DOKUMENTNUMMER'.
    ls_doc-documentversion = '00'.
    ls_doc-documentpart = '000'.
    ********************************************************************

    ** Call the BAPI that deletes the document or sets the deletionindicator
    ********************************************************************

    CALL FUNCTION 'BAPI_DOCUMENT_DELETE'
    EXPORTING: documenttype = ls_doc-documenttype
    documentnumber = ls_doc-documentnumber
    documentpart = ls_doc-documentpart
    documentversion = ls_doc-documentversion
    IMPORTING: return = ls_return.
    ** Any errors?
    IF ls_return-type CA 'EA'.
    ROLLBACK WORK.
    MESSAGE ID '26' TYPE 'I' NUMBER '000'
    WITH ls_return-message.
    ELSE.
    COMMIT WORK.
    ENDIF.