Skip to Content
avatar image
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

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'

EXPORTING

documentdata = ls_doc

IMPORTING

return = ls_return

documentnumber = doknr

TABLES

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:

CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN2'

EXPORTING

documenttype = 'DMO'

documentnumber = doknr

documentpart = '000'

documentversion = '00'

hostname = ''

statusintern = ''

statusextern = ''

statuslog = ''

IMPORTING

return = ls_return

TABLES

documentfiles = lt_files.

But the files are also missing.

Any ideas?

regards

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    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,

    Christoph

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 03, 2011 at 11:01 PM

    Did you find the solution for above issue?

    THanks.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    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 comment
    10|10000 characters needed characters exceeded