08-13-2007 10:26 AM
Hello,
I am using GUI_UPLOAD function module to upload a word document.
I am setting the file type as ASC ( is this correct) ??
When I test the function module with the word file that I upload it shows junk characters.
Any ideas??
Regards,
Narayani
08-13-2007 10:51 AM
If you are uploading a ".doc" file, then it is quite likely to look like jibberish as M/S Word saves documents in its own special way (open one on your desktop using Notepad to see this!). Perhaps try saving the document as an RTF and doing the upload - that should look a lot more reasonable (i.e. it should have no special low-hex characters etc).
But (a) why are you uploading a word document and (b) if you have to attach it to something and extract it again later, I think "BIN" would be a better options so you don't introduce unwanted characters when you download it again later.
08-13-2007 10:32 AM
There shouldn't be any problem in that case..... Please check the file type...
Here is a sample code........
<b>Textual upload</b>
begin of itab,
text(255) type c,
end of itab occurs 0.
CALL FUNCTION 'GUI_UPLOAD'
exporting
filetype = 'ASC'
filename = 'C:\DOWNLOAD.TXT'
tables
data_tab = itab.
Regards,
Pavan
08-13-2007 10:51 AM
If you are uploading a ".doc" file, then it is quite likely to look like jibberish as M/S Word saves documents in its own special way (open one on your desktop using Notepad to see this!). Perhaps try saving the document as an RTF and doing the upload - that should look a lot more reasonable (i.e. it should have no special low-hex characters etc).
But (a) why are you uploading a word document and (b) if you have to attach it to something and extract it again later, I think "BIN" would be a better options so you don't introduce unwanted characters when you download it again later.
08-13-2007 11:28 AM
Hi,
I tried but doesnot work.
I am basically using this to upload document and then convert to a binary data.
Regards,
Narayani
08-13-2007 11:41 AM
Hi Narayani,
to upload a word-document in the native word format it is the best to do this directly in binary format (BIN). Important here is to take the binary_filesize back from the gui_upload (either function module or cl_gui_frontend_services). Uploading it directly in binary format avoids later conversion.
For conversion to xstring and back from xstring to binary table you can use function modules SCMS_BINARY_TO_XSTRING and SCMS_XSTRING_TO_BINARY.
Hope that helps.
Best Regards
Michael
08-13-2007 12:01 PM
Hi,
I did the same thing. But when I download this binary file back to word I see junk characters.
Did a gui_upload,
took the binary file size,
used SCMS_BINARY_TO_XSTRING
Regards,
Narayani
08-13-2007 1:42 PM
Hi Narayani,
in case you are working with up- and download in binary mode you always need to read/supply the filesize, otherwise the trailing zeros in the last table line may damage the original file. This file length you also need to supply for the conversion from binary table to xstring (so that the conversion eliminates the trailing zeros of the last line). Before converting back the xstring back to a binary table for download you can use xstrlen to determine the length of the xstring and supply this length for the download.
Of course you can keep the file in the binary table and remember the file length you've got from the upload. The conversion might just be of interest in case you store it in the database and maybe want to put the file into a http-response or you need the file in an xstring for some other reason.
Hope that helps.
Best Regards
Michael