SAP BAPI_DOCUMENT_CREATE Function Module for Create Document
BAPI_DOCUMENT_CREATE is a standard bapi document create SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Create 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 create FM, simply by entering the name BAPI_DOCUMENT_CREATE into the relevant SAP transaction such as SE37 or SE38.
Function Group: CVBAPI
Program Name: SAPLCVBAPI
Main Program: SAPLCVBAPI
Appliation area: C
Release date: 03-Jul-1998
Mode(Normal, Remote etc): Remote-Enabled
Update:

Function BAPI_DOCUMENT_CREATE 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_CREATE'"Create Document.
EXPORTING
DOCUMENTDATA = "Document Data
* HOSTNAME = ' ' "Name of Frontend
IMPORTING
DOCTYPE = "Document Type
DOCNUMBER = "Document Number
DOCPART = "Document Part
DOCVERSION = "Document Version
RETURN = "BAPI Return
TABLES
* CHARACTERISTICVALUES = "Assigned Characteristic Values
* CLASSALLOCATIONS = "Classifications
* DOCUMENTDESCRIPTIONS = "Short texts
* OBJECTLINKS = "Object Links
* DOCUMENTSTRUCTURE = "Document-Based Structure
* DOCUMENTFILES = "Originals to Check In
* LONGTEXTS = "Long Texts
IMPORTING Parameters details for BAPI_DOCUMENT_CREATE
DOCUMENTDATA - Document Data
Data type: BAPI_DOC_DRAWOptional: No
Call by Reference: No ( called with pass by value option)
HOSTNAME - Name of Frontend
Data type: BAPI_DOC_AUX-HOSTNAMEDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for BAPI_DOCUMENT_CREATE
DOCTYPE - Document Type
Data type: BAPI_DOC_AUX-DOCTYPEOptional: No
Call by Reference: No ( called with pass by value option)
DOCNUMBER - Document Number
Data type: BAPI_DOC_AUX-DOCNUMBEROptional: No
Call by Reference: No ( called with pass by value option)
DOCPART - Document Part
Data type: BAPI_DOC_AUX-DOCPARTOptional: No
Call by Reference: No ( called with pass by value option)
DOCVERSION - Document Version
Data type: BAPI_DOC_AUX-DOCVERSIONOptional: No
Call by Reference: No ( called with pass by value option)
RETURN - BAPI Return
Data type: BAPIRET2Optional: No
Call by Reference: No ( called with pass by value option)
TABLES Parameters details for BAPI_DOCUMENT_CREATE
CHARACTERISTICVALUES - Assigned Characteristic Values
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-Based Structure
Data type: BAPI_DOC_STRUCTUREOptional: Yes
Call by Reference: No ( called with pass by value option)
DOCUMENTFILES - Originals to Check In
Data type: BAPI_DOC_FILESOptional: 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)
Copy and paste ABAP code example for BAPI_DOCUMENT_CREATE 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_doctype | TYPE BAPI_DOC_AUX-DOCTYPE, " | |||
| lv_documentdata | TYPE BAPI_DOC_DRAW, " | |||
| lt_characteristicvalues | TYPE STANDARD TABLE OF BAPI_CHARACTERISTIC_VALUES, " | |||
| lv_hostname | TYPE BAPI_DOC_AUX-HOSTNAME, " SPACE | |||
| lv_docnumber | TYPE BAPI_DOC_AUX-DOCNUMBER, " | |||
| lt_classallocations | TYPE STANDARD TABLE OF BAPI_CLASS_ALLOCATION, " | |||
| lv_docpart | TYPE BAPI_DOC_AUX-DOCPART, " | |||
| lt_documentdescriptions | TYPE STANDARD TABLE OF BAPI_DOC_DRAT, " | |||
| lv_docversion | TYPE BAPI_DOC_AUX-DOCVERSION, " | |||
| lt_objectlinks | TYPE STANDARD TABLE OF BAPI_DOC_DRAD, " | |||
| lv_return | TYPE BAPIRET2, " | |||
| lt_documentstructure | TYPE STANDARD TABLE OF BAPI_DOC_STRUCTURE, " | |||
| lt_documentfiles | TYPE STANDARD TABLE OF BAPI_DOC_FILES, " | |||
| lt_longtexts | TYPE STANDARD TABLE OF BAPI_DOC_TEXT. " |
|   CALL FUNCTION 'BAPI_DOCUMENT_CREATE' "Create Document |
| EXPORTING | ||
| DOCUMENTDATA | = lv_documentdata | |
| HOSTNAME | = lv_hostname | |
| IMPORTING | ||
| DOCTYPE | = lv_doctype | |
| DOCNUMBER | = lv_docnumber | |
| DOCPART | = lv_docpart | |
| DOCVERSION | = lv_docversion | |
| 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 | |
| . " BAPI_DOCUMENT_CREATE | ||
ABAP code using 7.40 inline data declarations to call FM BAPI_DOCUMENT_CREATE
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_doctype). | ||||
| "SELECT single HOSTNAME FROM BAPI_DOC_AUX INTO @DATA(ld_hostname). | ||||
| DATA(ld_hostname) | = ' '. | |||
| "SELECT single DOCNUMBER FROM BAPI_DOC_AUX INTO @DATA(ld_docnumber). | ||||
| "SELECT single DOCPART FROM BAPI_DOC_AUX INTO @DATA(ld_docpart). | ||||
| "SELECT single DOCVERSION FROM BAPI_DOC_AUX INTO @DATA(ld_docversion). | ||||
Search for further information about these or an SAP related objects