Skip to Content
author's profile photo Former Member
Former Member

BAPI_DOCUMENT_CREATE2 - File not attached to SAP document

Hi all,

I use the fm BAPI_DOCUMENT_CREATE2 to create a SAP document.

The BAPI creates the SAP document but doesn't attach the given files.

Here is my coding:

ls_doc-documenttype = doctyp.

ls_doc-documentnumber = ''.

ls_doc-documentversion = docvs.

ls_doc-documentpart = docprt.

ls_doc-description = it_fdata-bez.

ls_doc-username = sy-uname.

  • Files

REFRESH lt_files.

CLEAR lt_files.

lt_files-documenttype = doctyp.

lt_files-documentversion = docvs.

lt_files-documentpart = docprt.

lt_files-sourcedatacarrier = 'DEFAULT'.

lt_files-storagecategory = 'DMS_C1_ST'.

lt_files-docfile = it_fdata-path.

lt_files-wsapplication = 'PDF'.

lt_files-description = it_fdata-bez.

lt_files-originaltype = 1.

lt_files-checkedin = 'X'.

APPEND lt_files.

  • Object link to material master

CLEAR lt_drad.

REFRESH lt_drad.

lt_drad-objecttype = 'MARA'.

lt_drad-objectkey = it_fdata-matnr.

APPEND lt_drad.

  • Create document



documentdata = ls_doc


return = ls_return

documentnumber = doknr


objectlinks = lt_drad

documentfiles = lt_files.

commit work.

What is missing that the files were attached to the SAP document?

I have also tried to add the following fm:



documenttype = 'DMO'

documentnumber = doknr

documentpart = '000'

documentversion = '00'

hostname = ''

statusintern = ''

statusextern = ''

statuslog = ''


return = ls_return


documentfiles = lt_files.

But the files are also missing.

Any ideas?


Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Mar 22, 2010 at 01:18 PM

    Hi Wolfgang,

    based on the data for the BAPI I would recommend you to leave the paramter 'lt_files-checkedin' blank. Because in case that a storage category is entered the file will be checked in automatically.

    Further please check if the value at 'it_fdata-path' is correct and here the whole path plus filename is handed over. I also saw that you hand over the value 'DEFAULT' for the data carrier. Do you have maintained path prefix in the data carrier DEFAULT in transaction DC20? Because if the whole path is handed over in the 'it_fdata-path' parameter the data carrier field should

    remain empty too.

    As you enter the data in table DOCUMENTFILES I think you want to store the original files in the KPRO. Please check in transaction DC10 if the flag 'Use KPRO' is set for the used document type.

    After the BAPI_DOCUMENT_CREATE2 is executed successfully please execute the BAPI_TRANSACTION_COMMIT as this module is required to write the new entries on the database tables.

    For further help, please check the SAP note 766277 or transaction BAPI where you can find a complete documentation about all DMS related BAPIs and also sample coding to see how these BAPIs needs to be filled.

    Best regards,


    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 03, 2011 at 11:01 PM

    Did you find the solution for above issue?


    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 18, 2016 at 02:21 PM

    The Same, I tried if we are maintaining the USE KPRO check box tick it is uploading the document.

    DC10 Settings.JPG (45.0 kB)
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.