07-09-2007 9:12 PM
Hi all,
I have a problem while I attach a file (.doc, .pdf, .jpeg) automatically to a custom's declaration document.
I wrote a program and file attachment is working fine, but when I tried opening the document in the customs declartion screen, the file is corrupted...
For foreground, I am using function module gui_upload, but after upload, .doc file, .pdf file are corrupted...
Please help me regarding this.... following is the code...
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file
TABLES
data_tab = lt_doc_content.
Thanks in advace.
Jaffer Ali.S
07-10-2007 4:22 AM
Hi,
The GUI_UPLOAD Function module is used to upload BIN and ASC Files. The files that can be uploaded are text files. Convert the word documents into a normal text file. It will be uploaded without any problem with in the internal tables.
" The module loads a file from the PC to the server. Data can be transferred binarily or as text. Numbers and date fields can be interpreted according to the user settings." - Function Module Documentation
For the other format you need some other function modules.
Thanks.
Samantak.
Please rewards points if found useful.
07-10-2007 4:39 AM
For uploading pdf, doc files (binary) use filetype = 'BIN' as..
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = iv_filename
filetype = 'BIN'
has_field_separator = space
header_length = 0
read_by_line = ''
dat_mode = space
codepage = space
ignore_cerr = abap_true
replacement = '#'
virus_scan_profile =
IMPORTING
filelength = lv_filelength
header = lv_fileheader
CHANGING
data_tab = lt_filedata
.
Regards,
Abhijit
Reward points for helpful answers..
Message was edited by:
Abhijit V Patil
07-10-2007 7:53 AM
Hi,
You have to use the Function Module GUI_UPLOAD to upload .doc and .pdf files. But take care of the format as SAP follows UNICODE and the same needs to be there in the files that you are uploading. The uploaded files must be UNICODE enabled. As for the function module there is an option where you can decide the file type. If the format is not compatible then the internal table will be filled with junk details.
You can also use this Function Module: WS_UPLOAD.
Thanks
Samantak
Rewards points if useful.