2011 Jan 03 9:49 PM
Hello,
I am trying to create document "CV01N" with PDF attachment.
I am using BAPI 'BAPI_DOCUMENT_CREATE2' to create document. It is creating document but is not attaching the PDF document. I am running in foreground mode. Tried to seach forum but did not find solution.
Following is the code i am using:
DATA:
lv_docnum TYPE bapi_doc_aux-docnumber,
lw_docdata TYPE bapi_doc_draw2,
lw_return TYPE bapiret2,
lw_dsp TYPE bapi_doc_drat,
lw_objlink TYPE bapi_doc_drad,
lw_docfile TYPE bapi_doc_files2,
lt_dsp TYPE STANDARD TABLE OF bapi_doc_drat,
lt_objlink TYPE STANDARD TABLE OF bapi_doc_drad,
lt_docfile TYPE STANDARD TABLE OF bapi_doc_files2.
START-OF-SELECTION.
CLEAR lw_docdata.
lw_docdata-documenttype = 'ZAC'.
lw_docdata-documentversion = 'A0'.
lw_docdata-documentpart = '000'.
lw_docdata-laboratory = '001'.
CLEAR lw_dsp.
lw_dsp-description = 'Test '.
lw_dsp-language = 'E'.
APPEND lw_dsp TO lt_dsp.
lw_docfile-docfile = 'C:\test.pdf'.
LW_DOCFILE-ORIGINALTYPE = '1'.
lw_docfile-storagecategory = 'SAP-SYSTEM'.
lw_docfile-wsapplication = 'PDF'.
lw_docfile-language = 'E'.
lw_docfile-checkedin = 'X'.
lw_docfile-active_version = 'X'.
APPEND lw_docfile TO lt_docfile.
CLEAR lw_objlink.
lw_objlink-objecttype = 'VBAP'.
lw_objlink-objectkey = '0040081239000010'.
lw_objlink-documentdirection = 'X'.
APPEND lw_objlink TO lt_objlink.
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
documentdata = lw_docdata
IMPORTING
documentnumber = lv_docnum
return = lw_return
TABLES
documentdescriptions = lt_dsp
objectlinks = lt_objlink
documentfiles = lt_docfile.
IF lw_return-type CA 'EA'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
MESSAGE ID lw_return-id
TYPE lw_return-type
NUMBER lw_return-number.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
CLEAR lw_return.
CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN2'
EXPORTING
documenttype = 'ZTR'
documentnumber = lv_docnum
documentpart = '000'
documentversion = 'A0'
IMPORTING
return = lw_return
TABLES
documentfiles = lt_docfile.
IF lw_return-type CA 'EA'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
MESSAGE ID lw_return-id
TYPE lw_return-type
NUMBER lw_return-number.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
WRITE: / 'document number = ', lv_docnum.
ENDIF.
ENDIF.
Hello,
I am trying to create document "CV01N" with PDF attachment.
I am using BAPI 'BAPI_DOCUMENT_CREATE2' to create document. It is creating document but is not attaching the PDF document. I am running in foreground mode. Tried to seach forum but did not find solution.
Following is the code i am using:
DATA:
lv_docnum TYPE bapi_doc_aux-docnumber,
lw_docdata TYPE bapi_doc_draw2,
lw_return TYPE bapiret2,
lw_dsp TYPE bapi_doc_drat,
lw_objlink TYPE bapi_doc_drad,
lw_docfile TYPE bapi_doc_files2,
lt_dsp TYPE STANDARD TABLE OF bapi_doc_drat,
lt_objlink TYPE STANDARD TABLE OF bapi_doc_drad,
lt_docfile TYPE STANDARD TABLE OF bapi_doc_files2.
START-OF-SELECTION.
CLEAR lw_docdata.
lw_docdata-documenttype = 'ZAC'.
lw_docdata-documentversion = 'A0'.
lw_docdata-documentpart = '000'.
lw_docdata-laboratory = '001'.
CLEAR lw_dsp.
lw_dsp-description = 'Test '.
lw_dsp-language = 'E'.
APPEND lw_dsp TO lt_dsp.
lw_docfile-docfile = 'C:\test.pdf'.
LW_DOCFILE-ORIGINALTYPE = '1'.
lw_docfile-storagecategory = 'SAP-SYSTEM'.
lw_docfile-wsapplication = 'PDF'.
lw_docfile-language = 'E'.
lw_docfile-checkedin = 'X'.
lw_docfile-active_version = 'X'.
APPEND lw_docfile TO lt_docfile.
CLEAR lw_objlink.
lw_objlink-objecttype = 'VBAP'.
lw_objlink-objectkey = '0040081239000010'.
lw_objlink-documentdirection = 'X'.
APPEND lw_objlink TO lt_objlink.
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
documentdata = lw_docdata
IMPORTING
documentnumber = lv_docnum
return = lw_return
TABLES
documentdescriptions = lt_dsp
objectlinks = lt_objlink
documentfiles = lt_docfile.
IF lw_return-type CA 'EA'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
MESSAGE ID lw_return-id
TYPE lw_return-type
NUMBER lw_return-number.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
CLEAR lw_return.
CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN2'
EXPORTING
documenttype = 'ZTR'
documentnumber = lv_docnum
documentpart = '000'
documentversion = 'A0'
IMPORTING
return = lw_return
TABLES
documentfiles = lt_docfile.
IF lw_return-type CA 'EA'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
MESSAGE ID lw_return-id
TYPE lw_return-type
NUMBER lw_return-number.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
WRITE: / 'document number = ', lv_docnum.
ENDIF.
ENDIF.
2011 Jan 04 1:11 PM
Hello,
the document must be exist for checkin a file.
In you code, you create a documenttype = 'ZAC' and you want to checkin on a documenttype = 'ZTR'
For checkin a document, Y use BAPI_DOCUMENT_CHANGE2
CLEAR lt_documentfiles_new. REFRESH lt_documentfiles_new.
lt_documentfiles_new-sourcedatacarrier = carrier.
lt_documentfiles_new-storagecategory = storage.
lt_documentfiles_new-wsapplication = dappl.
lt_documentfiles_new-docfile = filep.
APPEND lt_documentfiles_new.
CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'
EXPORTING
documenttype = dokar
documentnumber = doknr
documentpart = doktl
documentversion = dokvr
documentdata = ls_doc
documentdatax = ls_docx
pf_ftp_dest = 'SAPFTP'
pf_http_dest = 'SAPHTTP'
IMPORTING
return = ls_return
TABLES
documentfiles = lt_documentfiles_new.
Hope this can help you
Thierry
2011 Jan 04 2:11 PM
I made both the document types ZTR but still it does not work.
THanks
2011 Jan 05 8:51 PM
I am able to create document and load attachments after applying oss note 0001173675. But some how it is uploading duplicate attachment instead of only one. Any suggestion?
THanks.
2011 Jan 07 10:05 PM
I am able to attach only 2 files as attachment. How do you increase number in configuration.\
Also when i do file checkin the file name in disappearing. How can I keep the file name.
Thanks.
2011 Jan 10 2:38 PM
I am using FM 'BAPI_DOCUMENT_CREATE2' and FM ''CVAPI_DOC_CHECKIN'' to create document and attachment and then checkin the document.
I am able to accomplish all the step. when i do file checkin the file name in disappearing. How can I keep the file name? When i attach the file I can see the name but when I checkin the file name disappers but the files are there.
I am able to attach only 2 files as attachment. How do you increase number in configuration.
Thanks,
2011 Jan 10 3:15 PM
Hello,
>>the file name disappers but the files are there.
Perhaps you must filled the PT_FILES_X-FILENAME
Thierry
2011 Jan 10 5:11 PM
Hello Thierry,
In FM ''CVAPI_DOC_CHECKIN'' I am passing the file to be updated in parameter PT_FILES_X-FILENAME. Still it is not working. If i do manual check in. It shows the file name.
Thanks.
2011 Jan 11 7:22 AM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |