SAP BAPI_DOCUMENT_CHANGE2 Function Module for Change Document
BAPI_DOCUMENT_CHANGE2 is a standard bapi document change2 SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Change Document processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.
See here to view full function module documentation and code listing for bapi document change2 FM, simply by entering the name BAPI_DOCUMENT_CHANGE2 into the relevant SAP transaction such as SE37 or SE38.
Function Group: CVBAPI
Program Name: SAPLCVBAPI
Main Program: SAPLCVBAPI
Appliation area: C
Release date: 25-Mar-1999
Mode(Normal, Remote etc): Remote-Enabled
Update:

Function BAPI_DOCUMENT_CHANGE2 pattern details
In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'"Change Document.
EXPORTING
DOCUMENTTYPE = "Document Type
* DOCBOMREVISIONLEVEL = "Revision Level
* SENDCOMPLETEBOM = ' ' "Indicator whether BOM (or only delta) is sent. Only for Engineering Change Mgmt
* PF_FTP_DEST = ' ' "Logical Destination (Specified in Function Call)
* PF_HTTP_DEST = ' ' "Logical Destination (Specified in Function Call)
* CAD_MODE = ' ' "CAD FLag for Document Structure
* ACCEPT_EMPTY_BOM = ' ' "Update Document Structure Without Items if SENDCOMPLETEBOM Is Active
DOCUMENTNUMBER = "Document Number
DOCUMENTPART = "Document Part
DOCUMENTVERSION = "Document Version
DOCUMENTDATA = "Document Data
DOCUMENTDATAX = "Indicator for Relevancy to Change
* HOSTNAME = "Name of Frontend
* DOCBOMCHANGENUMBER = "Change Number
* DOCBOMVALIDFROM = "Valid-From Date
IMPORTING
RETURN = "Return Structure
TABLES
* CHARACTERISTICVALUES = "Characteristic Value Assignments
* CLASSALLOCATIONS = "Classifications
* DOCUMENTDESCRIPTIONS = "Short texts
* OBJECTLINKS = "Object Links
* DOCUMENTSTRUCTURE = "Document Structure
* DOCUMENTFILES = "Originals
* LONGTEXTS = "Long Texts
* COMPONENTS = "Additional Files for Originals (in future development)
IMPORTING Parameters details for BAPI_DOCUMENT_CHANGE2
DOCUMENTTYPE - Document Type
Data type: BAPI_DOC_AUX-DOCTYPEOptional: No
Call by Reference: No ( called with pass by value option)
DOCBOMREVISIONLEVEL - Revision Level
Data type: BAPI_DOC_DRAW2-REVLEVELOptional: Yes
Call by Reference: No ( called with pass by value option)
SENDCOMPLETEBOM - Indicator whether BOM (or only delta) is sent. Only for Engineering Change Mgmt
Data type: BAPI_DOC_AUX-FLAGDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
PF_FTP_DEST - Logical Destination (Specified in Function Call)
Data type: RFCDES-RFCDESTDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
PF_HTTP_DEST - Logical Destination (Specified in Function Call)
Data type: RFCDES-RFCDESTDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
CAD_MODE - CAD FLag for Document Structure
Data type: CSDATA-XFELDDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
ACCEPT_EMPTY_BOM - Update Document Structure Without Items if SENDCOMPLETEBOM Is Active
Data type: BAPI_DOC_AUX-FLAGDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
DOCUMENTNUMBER - Document Number
Data type: BAPI_DOC_AUX-DOCNUMBEROptional: No
Call by Reference: No ( called with pass by value option)
DOCUMENTPART - Document Part
Data type: BAPI_DOC_AUX-DOCPARTOptional: No
Call by Reference: No ( called with pass by value option)
DOCUMENTVERSION - Document Version
Data type: BAPI_DOC_AUX-DOCVERSIONOptional: No
Call by Reference: No ( called with pass by value option)
DOCUMENTDATA - Document Data
Data type: BAPI_DOC_DRAW2Optional: No
Call by Reference: No ( called with pass by value option)
DOCUMENTDATAX - Indicator for Relevancy to Change
Data type: BAPI_DOC_DRAWX2Optional: No
Call by Reference: No ( called with pass by value option)
HOSTNAME - Name of Frontend
Data type: BAPI_DOC_AUX-HOSTNAMEOptional: Yes
Call by Reference: No ( called with pass by value option)
DOCBOMCHANGENUMBER - Change Number
Data type: BAPI_DOC_DRAW2-ECNUMBEROptional: Yes
Call by Reference: No ( called with pass by value option)
DOCBOMVALIDFROM - Valid-From Date
Data type: BAPI_DOC_DRAW2-VALIDFROMDATEOptional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for BAPI_DOCUMENT_CHANGE2
RETURN - Return Structure
Data type: BAPIRET2Optional: No
Call by Reference: No ( called with pass by value option)
TABLES Parameters details for BAPI_DOCUMENT_CHANGE2
CHARACTERISTICVALUES - Characteristic Value Assignments
Data type: BAPI_CHARACTERISTIC_VALUESOptional: Yes
Call by Reference: No ( called with pass by value option)
CLASSALLOCATIONS - Classifications
Data type: BAPI_CLASS_ALLOCATIONOptional: Yes
Call by Reference: No ( called with pass by value option)
DOCUMENTDESCRIPTIONS - Short texts
Data type: BAPI_DOC_DRATOptional: Yes
Call by Reference: No ( called with pass by value option)
OBJECTLINKS - Object Links
Data type: BAPI_DOC_DRADOptional: Yes
Call by Reference: No ( called with pass by value option)
DOCUMENTSTRUCTURE - Document Structure
Data type: BAPI_DOC_STRUCTUREOptional: Yes
Call by Reference: No ( called with pass by value option)
DOCUMENTFILES - Originals
Data type: BAPI_DOC_FILES2Optional: Yes
Call by Reference: No ( called with pass by value option)
LONGTEXTS - Long Texts
Data type: BAPI_DOC_TEXTOptional: Yes
Call by Reference: No ( called with pass by value option)
COMPONENTS - Additional Files for Originals (in future development)
Data type: BAPI_DOC_COMPOptional: Yes
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for BAPI_DOCUMENT_CHANGE2 Function Module
The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.| DATA: | ||||
| lv_return | TYPE BAPIRET2, " | |||
| lv_documenttype | TYPE BAPI_DOC_AUX-DOCTYPE, " | |||
| lt_characteristicvalues | TYPE STANDARD TABLE OF BAPI_CHARACTERISTIC_VALUES, " | |||
| lv_docbomrevisionlevel | TYPE BAPI_DOC_DRAW2-REVLEVEL, " | |||
| lv_sendcompletebom | TYPE BAPI_DOC_AUX-FLAG, " SPACE | |||
| lv_pf_ftp_dest | TYPE RFCDES-RFCDEST, " SPACE | |||
| lv_pf_http_dest | TYPE RFCDES-RFCDEST, " SPACE | |||
| lv_cad_mode | TYPE CSDATA-XFELD, " SPACE | |||
| lv_accept_empty_bom | TYPE BAPI_DOC_AUX-FLAG, " SPACE | |||
| lv_documentnumber | TYPE BAPI_DOC_AUX-DOCNUMBER, " | |||
| lt_classallocations | TYPE STANDARD TABLE OF BAPI_CLASS_ALLOCATION, " | |||
| lv_documentpart | TYPE BAPI_DOC_AUX-DOCPART, " | |||
| lt_documentdescriptions | TYPE STANDARD TABLE OF BAPI_DOC_DRAT, " | |||
| lt_objectlinks | TYPE STANDARD TABLE OF BAPI_DOC_DRAD, " | |||
| lv_documentversion | TYPE BAPI_DOC_AUX-DOCVERSION, " | |||
| lv_documentdata | TYPE BAPI_DOC_DRAW2, " | |||
| lt_documentstructure | TYPE STANDARD TABLE OF BAPI_DOC_STRUCTURE, " | |||
| lv_documentdatax | TYPE BAPI_DOC_DRAWX2, " | |||
| lt_documentfiles | TYPE STANDARD TABLE OF BAPI_DOC_FILES2, " | |||
| lv_hostname | TYPE BAPI_DOC_AUX-HOSTNAME, " | |||
| lt_longtexts | TYPE STANDARD TABLE OF BAPI_DOC_TEXT, " | |||
| lt_components | TYPE STANDARD TABLE OF BAPI_DOC_COMP, " | |||
| lv_docbomchangenumber | TYPE BAPI_DOC_DRAW2-ECNUMBER, " | |||
| lv_docbomvalidfrom | TYPE BAPI_DOC_DRAW2-VALIDFROMDATE. " |
|   CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2' "Change Document |
| EXPORTING | ||
| DOCUMENTTYPE | = lv_documenttype | |
| DOCBOMREVISIONLEVEL | = lv_docbomrevisionlevel | |
| SENDCOMPLETEBOM | = lv_sendcompletebom | |
| PF_FTP_DEST | = lv_pf_ftp_dest | |
| PF_HTTP_DEST | = lv_pf_http_dest | |
| CAD_MODE | = lv_cad_mode | |
| ACCEPT_EMPTY_BOM | = lv_accept_empty_bom | |
| DOCUMENTNUMBER | = lv_documentnumber | |
| DOCUMENTPART | = lv_documentpart | |
| DOCUMENTVERSION | = lv_documentversion | |
| DOCUMENTDATA | = lv_documentdata | |
| DOCUMENTDATAX | = lv_documentdatax | |
| HOSTNAME | = lv_hostname | |
| DOCBOMCHANGENUMBER | = lv_docbomchangenumber | |
| DOCBOMVALIDFROM | = lv_docbomvalidfrom | |
| IMPORTING | ||
| RETURN | = lv_return | |
| TABLES | ||
| CHARACTERISTICVALUES | = lt_characteristicvalues | |
| CLASSALLOCATIONS | = lt_classallocations | |
| DOCUMENTDESCRIPTIONS | = lt_documentdescriptions | |
| OBJECTLINKS | = lt_objectlinks | |
| DOCUMENTSTRUCTURE | = lt_documentstructure | |
| DOCUMENTFILES | = lt_documentfiles | |
| LONGTEXTS | = lt_longtexts | |
| COMPONENTS | = lt_components | |
| . " BAPI_DOCUMENT_CHANGE2 | ||
ABAP code using 7.40 inline data declarations to call FM BAPI_DOCUMENT_CHANGE2
The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.| "SELECT single DOCTYPE FROM BAPI_DOC_AUX INTO @DATA(ld_documenttype). | ||||
| "SELECT single REVLEVEL FROM BAPI_DOC_DRAW2 INTO @DATA(ld_docbomrevisionlevel). | ||||
| "SELECT single FLAG FROM BAPI_DOC_AUX INTO @DATA(ld_sendcompletebom). | ||||
| DATA(ld_sendcompletebom) | = ' '. | |||
| "SELECT single RFCDEST FROM RFCDES INTO @DATA(ld_pf_ftp_dest). | ||||
| DATA(ld_pf_ftp_dest) | = ' '. | |||
| "SELECT single RFCDEST FROM RFCDES INTO @DATA(ld_pf_http_dest). | ||||
| DATA(ld_pf_http_dest) | = ' '. | |||
| "SELECT single XFELD FROM CSDATA INTO @DATA(ld_cad_mode). | ||||
| DATA(ld_cad_mode) | = ' '. | |||
| "SELECT single FLAG FROM BAPI_DOC_AUX INTO @DATA(ld_accept_empty_bom). | ||||
| DATA(ld_accept_empty_bom) | = ' '. | |||
| "SELECT single DOCNUMBER FROM BAPI_DOC_AUX INTO @DATA(ld_documentnumber). | ||||
| "SELECT single DOCPART FROM BAPI_DOC_AUX INTO @DATA(ld_documentpart). | ||||
| "SELECT single DOCVERSION FROM BAPI_DOC_AUX INTO @DATA(ld_documentversion). | ||||
| "SELECT single HOSTNAME FROM BAPI_DOC_AUX INTO @DATA(ld_hostname). | ||||
| "SELECT single ECNUMBER FROM BAPI_DOC_DRAW2 INTO @DATA(ld_docbomchangenumber). | ||||
| "SELECT single VALIDFROMDATE FROM BAPI_DOC_DRAW2 INTO @DATA(ld_docbomvalidfrom). | ||||
Search for further information about these or an SAP related objects