2008 Mar 20 3:55 PM
Hello,
Are you aware of any function module or method which takes input as a file of type doc, pdf or text files and convert it to binary format? Kindly let me know.
This is what i tried and was unsuccessful.
i tried using gui_upload method and pass " asc" as file type while importing file of type .doc but it returns me string filled with strange characters.
I did try converting this string to xstring using cl_proxy_service=>cstring2xstring but i realized my 1st step of uploading file itself was wrong.
Please let me know what can be done if you are aware of how to convert file of various types to binary.
thanks
Pooja
2008 Mar 20 4:24 PM
Try this FM,
C13Z_FILE_UPLOAD_BINARY Uploads a file in binary format
C13Z_FILE_DOWNLOAD_BINARY Downloads a file in binary format
and i think you should use 'BIN' in the gui_upload .
Hello,
Are you aware of any function module or method which takes input as a file of type doc, pdf or text files and convert it to binary format? Kindly let me know.
This is what i tried and was unsuccessful.
i tried using gui_upload method and pass " asc" as file type while importing file of type .doc but it returns me string filled with strange characters.
I did try converting this string to xstring using cl_proxy_service=>cstring2xstring but i realized my 1st step of uploading file itself was wrong.
Please let me know what can be done if you are aware of how to convert file of various types to binary.
thanks
Pooja
2008 Mar 20 4:18 PM
Hello,
If you want to read a Word file as a Word file directly - i.e. not converted to text - then you have to work out/find out the internal format, and write a program to handle it. Effectively an ABAP version of a Word Document viewer. Applications such as Open Office have managed to do this, but I think even with their source code, you'd have a very difficult task on your hands.
If you are using the latest version of Word (2007), then you can comparitively easily write an XML parser for Microsoft Open Office XML (OOXML)
It may be possible to write a Word VBA macro that extracts the information from the Word Document, which you could call from ABAP using OLE. But again, a lot depends on your SAP version and your version of Word.
Of course, you can simplify the problem dramatically by converting the word document to a text format, then reading the text file by GUI_UPLOAD.
2008 Mar 20 4:24 PM
Try this FM,
C13Z_FILE_UPLOAD_BINARY Uploads a file in binary format
C13Z_FILE_DOWNLOAD_BINARY Downloads a file in binary format
and i think you should use 'BIN' in the gui_upload .
2008 Mar 31 5:30 PM
hi All,
thanks alot for the information and help provided by all of you.
I did figure out a way where the word document or pdf can be pretty much loaded with gui_upload. the file type used in the method would be "BIN" the following thing has to be done. declare data type as given below and file would be the complete path along with document name which has to be uploaded
DATA: BEGIN OF res_line,
raw(255) TYPE x,
END OF res_line.
DATA: res_tab LIKE res_line OCCURS 0 WITH HEADER LINE.
data : wf_var_stringx TYPE xstring .
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file
filetype = 'BIN'
read_by_line = 'X'
has_field_separator = ' '
header_length = 0
header_line = 'X'
IMPORTING
filelength = l_filelength
TABLES
data_tab = res_tab
EXCEPTIONS
OTHERS = 1.
*
LOOP AT res_tab .
CONCATENATE wf_var_stringx res_tab-raw INTO wf_var_stringx IN BYTE MODE.
ENDLOOP.
*
this will upload the file and will file the string x with its content.
hope this helps to some of you.
Thanks
Pooja
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |