Hi Experts,
I have requirement where I need to upload the Original file from application server to the DMS document that I create. The below code works perfectly fine in the IDES server. However it does not work when I execute it in the client system
DATA: ls_doc type bapi_doc_draw2,
ls_return type bapiret2.
** key fields for BAPI return
DATA: lf_doctype type bapi_doc_draw2-documenttype,
lf_docnumber type bapi_doc_draw2-documentnumber,
lf_docpart type bapi_doc_draw2-documentpart,
lf_docversion type bapi_doc_draw2-documentversion.
DATA: lt_files type table of bapi_doc_files2 ,
ls_files like line of lt_files,
** short text
lt_drat type table of bapi_doc_drat,
ls_drat like line of lt_drat,
** object links
lt_drad type table of bapi_doc_drad,
ls_drad like line of lt_drad.
**----------------------------------------------------
*allocate document data which will be assigned to the new document
**----------------------------------------------------
ls_doc-documenttype = 'ZPD'.
ls_doc-documentversion = '00'.
ls_doc-documentpart = '000'.
ls_doc-statusextern = 'IW'.
**-----------------------------------------------------------
*upload the file from the presentation server to the application server
*------------------------------------------------------------
data : lv_length type i.
types : begin of st_ts_raw_line,
line type sdokcntbin ,
end of st_ts_raw_line.
data : itab type table of st_ts_raw_line.
data : wa like line of itab.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\Desktop\50492.pdf'
FILETYPE = 'BIN'
TABLES
DATA_TAB = itab .
* .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*------------------------------------------------------
*Open a file on the application server for the uploaded file
*-------------------------------------------------------
DATA: e_file like rlgrap-filename value '/usr/sap/tmp/50492.pdf'.
open dataset e_file for output in binary mode.
lOOP AT itab into wa.
transfer wa to e_file.
ENDLOOP.
close dataset e_file.
*------------------------------------------------------
*Hand over the original files to be attached
*------------------------------------------------------
REFRESH lt_files.
CLEAR lt_files.
ls_files-storagecategory = 'DMS_C1_ST'.
ls_files-DOCPATH = '/usr/sap/tmp/'.
ls_files-docfile = '50492.pdf'.
ls_files-wsapplication = 'PDF'.
ls_files-originaltype = '1'. " or '2' have to be done
APPEND ls_files to lt_files.
*--------------------------------------------------
*allocate the short texts
*---------------------------------------------------
CLEAR ls_drat.
REFRESH lt_drat.
ls_drat-language = 'EN'.
ls_drat-description = 'gear'.
APPEND ls_drat to lt_drat.
ls_drat-language = 'DE'.
ls_drat-description = 'Getriebe'.
APPEND ls_drat to lt_drat.
*----------------------------------------------
*call the function module to create the document
*-----------------------------------------------
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING: documentdata = ls_doc
PF_HTTP_DEST = 'SAPHTTPA'
PF_FTP_DEST = 'SAPFTPA'
IMPORTING: documenttype = lf_doctype
documentnumber = lf_docnumber
documentpart = lf_docpart
documentversion = lf_docversion
return = ls_return
TABLES: documentdescriptions = lt_drat
documentfiles = lt_files.
** error occured ??
IF ls_return-type CA 'EA'.
ROLLBACK WORK.
MESSAGE ID '26' TYPE 'I' NUMBER '000'
WITH ls_return-message.
ELSE.
COMMIT WORK.
ENDIF.
The reason why I am first transferring the file to the application server is because the file comes from EP ABAP server where the webdynpro application is running.When executing in client system, I have changed the parameters like document type, storage category ( I have given SAP-SYSTEM ) accordingly.
I am able to manually upload the original files to this storage category using CV01N. I have also confirmed that the file is created in the application server by checking the AL11 T code. The error message that I get is ID : 26 Number : 128 Message 'Error uploading /usr/sap/tmp/50492.pdf'
I have also confirmed that 'SAPHTTPA' and 'SAPFTPA' exists in the TCode SM59 and connection test is passed. What else could I check in order to resolve this issue?
Thanks,
Ajith C