Hi,
I am trying to upload original files from the application server to the dms. It is giving me an error message with id 26 and number 128 stating that error uploading file. I have selected 'SAP-SYSTEM' as the storage category. However, I am able to upload original files from the front end to the DMS without any issue. In order to upload file from application server, I have written the code as below.
* declare the binary data file and the work area
data : it_binary type solix_tab,
wa_binary type solix.
data : lv_length type i.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\Desktop\50492.pdf'
FILETYPE = 'BIN'
IMPORTING
FILELENGTH = lv_length
TABLES
DATA_TAB = it_binary
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
.
IF SY-SUBRC <> 0.
ENDIF.
* create a file on the application server to store this binary file.
data : lv_app type rlgrap-filename value '/usr/sap/tmp/test2aj50492.pdf'.
open dataset lv_app for output in binary mode.
loop at it_binary into wa_binary.
transfer wa_binary to lv_app.
endloop.
close dataset lv_app.
clear wa_binary.
refresh it_binary.
* download the same file to desktop.
* read the file from application server to internal table.
**----------------------------------------------------------------
*The logic for uploading the files onto the dms server
**-----------------------------------------------------------------
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 = 'ZD1'.
ls_doc-documentversion = '00'.
ls_doc-documentpart = '000'.
ls_doc-statusextern = 'CR'.
*------------------------------------------------------
*Hand over the original files to be attached
*------------------------------------------------------
REFRESH lt_files.
CLEAR lt_files.
ls_files-storagecategory = 'SAP-SYSTEM'.
ls_files-DOCPATH = '/usr/sap/tmp/'.
ls_files-DOCFILE = 'test2aj50492.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 = 'Test whether we can upload originals from app server'.
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 same code works when I execute in the ides server. Please guide me as to what changes or settings I need to make to get this done.
Thanks,
Ajith C