cancel
Showing results for 
Search instead for 
Did you mean: 

'BAPI_DOCUMENT_CREATE2': file attachment

Former Member
0 Kudos

Hi experts !!

I have a problem with this Bapi "BAPI_DOCUMENT_CREATE2". I can attach a file manually in CV01N.But when i try to attach a file using this BAPI - file not getting store.Following is my code,

ls_doc-documenttype = 'DRW'.

ls_doc-documentversion = '00'.

ls_doc-documentpart = '000'.

ls_doc-statusextern = 'WR'.

ls_doc-laboratory = '001'.

REFRESH lt_files.

CLEAR lt_files.

lt_files-storagecategory = 'KPRO'.

lt_files-docfile = 'C:\temp\Documents and Settings\anuvidhya.t\anu.doc'."'c:\temp\drawing.txt'.

lt_files-wsapplication = 'WRD'."'TXT'.

APPEND lt_files.

CLEAR lt_drat.

REFRESH lt_drat.

lt_drat-language = 'EN'.

lt_drat-description = 'Testing document from bapi'.

APPEND lt_drat.

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'

EXPORTING documentdata = ls_doc

IMPORTING documenttype = lf_doctype

documentnumber = lf_docnumber

documentpart = lf_docpart

documentversion = lf_docversion

return = ls_return

TABLES documentdescriptions = lt_drat

documentfiles = lt_files.

Thanks in advance,

Regards,

Anu.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Anu/Surjit Bawa

Have you been successful in uploading a document using JAVA.

I am trying to send document from external DMS system into SAP DMS using SAP JCo

I can create DIR in SAP but not sure which  JAVA API to use to insert doc.

JCoStructure  importStructure =function.getImportParameterList().getStructure("DOCUMENTDATA")

importStructure.setValue("DOCFILE","file location")

If I am following example in ABAP.

However in ABAP,it_files, takes the path of the file location and adds the file into SAP system

Whereas JAVA it is only sets the value.

However in JAVA we can pass byte array of the document.Will that work if I pass byte array of the document?.

Venkat

christoph_hopf
Advisor
Advisor
0 Kudos

Dear Anu,

based on the provided sample data for the BAPI I would kindly ask you to try with the following values:

ls_doc-documenttype = 'DRW'.

ls_doc-documentversion = '00'.

ls_doc-documentpart = '000'.

ls_doc-statusextern = 'WR'.

ls_doc-laboratory = '001'.

REFRESH lt_files.

CLEAR lt_files.

lt_files-storagecategory = 'DMS_C1_ST'.

lt_files-docfile = 'C:\temp\Documents and Settings\anuvidhya.t\anu.doc'.

lt_files-wsapplication = 'WRD'.

APPEND lt_files.

CLEAR lt_drat.

REFRESH lt_drat.

lt_drat-language = 'EN'.

lt_drat-description = 'Testing document from bapi'.

APPEND lt_drat.

Regarding the lt_files table you have to made sure that for each original you want to add a separate line has to be appended.

For further information on the BAPI behavior please see SAP note 766277 where you will find a detailed documentation on all DMS BAPIs in the attachment list.

Best regards,

Christoph

Former Member
0 Kudos

Hi Christoph,

Thanks for ur reply.I had solved this issue by below changes,

ls_doc-originaltype = '001'.

lt_files-storagecategory = 'SAP-SYSTEM'.

Now everything is working fine is SAP server,but when i call it from JAVA server values are comming

but document has not created.Is any value need to pass in BAPI(specialy for calling from JAVA)??

Regards,

Anu.

Former Member
0 Kudos

did u use BAPI_TRANSACTION_COMMIT

Former Member
0 Kudos

Yes, I am calling this BAPI after BAPI_DOCUMENT_CREATE2.I have called this both BAPI's in a Remote enabled function module. It generating document number when i execute in SAP server.

But when i call it from java server it's not generating document number.

Regards,

Anu.

Former Member
0 Kudos

check

use parameters

PF_FTP_DEST

PF_HTTP_DEST