OTF File attachment to SAP DMS/Content Server

In DMS you can upload or attach the PDF of various transactions without downloading them to the Desktop or Mobile devices.

You need to convert the PDF into Binary format data and then you need to try uploading it into the SAP DMS system or content server.

Example will make it more clear say you are printing the Invoice and you wish that the invoice should be uploaded to the content server or SAP DMS. Just need to convert the Smartforms or Adobe form to binary format.

  1. You create a DMS document using the BAPI  BAPI_DOCUMENT_CREATE2.
  2. Then you need to call the another BAPI which will help you upload or attach the form CVAPI_DOC_CHECKIN.

Below Code will guide you :-

TYPES: BEGIN OF zst_ts_raw_line,
line(2550) type x,
END OF zst_ts_raw_line.

*now after successful document creation we have to attach document to this dms document
DATA : ls_file TYPE cvapi_doc_file,
ls_api_cntl TYPE cvapi_api_control,
ls_bintab type zst_ts_raw_line, “needed for HTTP response
ls_drao TYPE drao,
ls_msg TYPE messages,
binlen TYPE i,
l_filename TYPE char50,
lt_files TYPE TABLE OF cvapi_doc_file,
lt_bintab TYPE TABLE OF zst_ts_raw_line,
lt_drao TYPE TABLE OF drao.

**—here we will get lv_pdfsource as zstrong data now Convert XSTRING TO BInary DAta.
*DATA: lt_bintab TYPE TABLE OF ls_bintab.

  • wa_bintab TYPE ls_bintab.

CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
EXPORTING
buffer = l_out
IMPORTING
output_length = binlen
TABLES
binary_tab = lt_bintab.

**FIELD-SYMBOLS: TYPE ls_bintab.
LOOP AT lt_bintab INTO ls_bintab.
CLEAR ls_drao.
ls_drao-orblk = ls_bintab-line.
ls_drao-orln = binlen.
APPEND ls_drao TO lt_drao.
ENDLOOP.

CONCATENATE ‘TEST’ ‘pdf’
INTO l_filename SEPARATED BY ‘.’.

ls_file-updateflag = ‘I’.
ls_file-dappl = ‘PDF’.
ls_file-storage_cat = ‘DMS_C1_ST’.
ls_file-filename = l_filename.
ls_file-description = ‘AcrobatReader’. “l_docname.”file_st-cvtext.”‘AcrobatReader’.
ls_file-checked_in = ‘X’.
APPEND ls_file TO lt_files.

ls_api_cntl-no_update_task = ‘X’.

BREAK-POINT.

CALL FUNCTION ‘CVAPI_DOC_CHECKIN’
EXPORTING
pf_dokar = ‘ZIN'”gs_draw-dokar
pf_doknr = ‘INV0000000002’ “attr_draw-doknr
pf_dokvr = ’01’ “attr_draw-dokvr
pf_doktl = ‘000’ “attr_draw-doktl
pf_hostname = ‘DEFAULT’
ps_api_control = ls_api_cntl
pf_replace = ‘X’
pf_content_provide = ‘TBL’
pf_ftp_dest = ‘SAPFTPA’
pf_http_dest = ‘SAPHTTPA’
IMPORTING
psx_message = ls_msg
TABLES
pt_files_x = lt_files
pt_content = lt_drao.

BREAK-POINT.

CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
EXPORTING
wait = ‘X’.

Leave a Reply

Your email address will not be published. Required fields are marked *