# BAPI_DOCUMENT_CREATE2 — Create Document Info Record

> Creates a document info record in Document Management (DMS) with descriptions, object links, classification and original files, like transaction CV01N. It is used to upload drawings, certificates or scanned files from external systems and link them to materials, equipment or other objects. Fill DOCUMENTDATA (type, number, part, version), add files in DOCUMENTFILES and links in OBJECTLINKS, check RETURN and call BAPI_TRANSACTION_COMMIT.

- Modules: CA
- Type: BAPI
- Function group: CVBAPI
- Remote-enabled (RFC): Yes
- S/4HANA status: Used the same way in S/4HANA
- URL: https://nekuhub.com/en/functions/bapi-document-create2/

## Importing parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| DOCUMENTDATA | BAPI_DOC_DRAW2 | Document data | Yes |
| HOSTNAME | BAPI_DOC_AUX-HOSTNAME | Front-end host name | - |
| DOCBOMCHANGENUMBER | BAPI_DOC_DRAW2-ECNUMBER | Change number for document structure | - |
| DOCBOMVALIDFROM | BAPI_DOC_DRAW2-VALIDFROMDATE | Valid-from date of document structure | - |
| DOCBOMREVISIONLEVEL | BAPI_DOC_DRAW2-REVLEVEL | Revision level | - |
| CAD_MODE | CSDATA-XFELD | CAD indicator for document structure | - |
| PF_FTP_DEST | RFCDES-RFCDEST | FTP destination for file transfer | - |
| PF_HTTP_DEST | RFCDES-RFCDEST | HTTP destination for file transfer | - |
| DEFAULTCLASS | BAPI_DOC_AUX-FLAG | Use class from Customizing | - |

## Exporting parameters

| Parameter | Type | Description |
|---|---|---|
| DOCUMENTTYPE | BAPI_DOC_AUX-DOCTYPE | Document type |
| DOCUMENTNUMBER | BAPI_DOC_AUX-DOCNUMBER | Document number |
| DOCUMENTPART | BAPI_DOC_AUX-DOCPART | Document part |
| DOCUMENTVERSION | BAPI_DOC_AUX-DOCVERSION | Document version |
| RETURN | BAPIRET2 | Return message |

## Tables parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| CHARACTERISTICVALUES | BAPI_CHARACTERISTIC_VALUES | Characteristic values | - |
| CLASSALLOCATIONS | BAPI_CLASS_ALLOCATION | Class assignments | - |
| DOCUMENTDESCRIPTIONS | BAPI_DOC_DRAT | Descriptions | - |
| OBJECTLINKS | BAPI_DOC_DRAD | Object links | - |
| DOCUMENTSTRUCTURE | BAPI_DOC_STRUCTURE | Document structure | - |
| DOCUMENTFILES | BAPI_DOC_FILES2 | Original files | - |
| LONGTEXTS | BAPI_DOC_TEXT | Long texts | - |
| COMPONENTS | BAPI_DOC_COMP | Additional files for originals | - |

## Call template (ABAP)

```abap
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
  EXPORTING
    documentdata = lv_documentdata
  IMPORTING
    documenttype = lv_documenttype
    documentnumber = lv_documentnumber
    documentpart = lv_documentpart
    documentversion = lv_documentversion
    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.
```

## Related tables

DRAD, DRAT, DRAW

