on 2012 Mar 15 2:38 PM
Hello experts,
I'm having a problem with downloading .docx and .xlsx files from Webdynpro.
Situation: User uploads a document and it is saved to the network drive. Later on a user must be able to open this file/download this file in Webdynpro ABAP. To read the file into an XSTRING I use the statement:
OPEN DATASET x FOR INPUT IN BINARY MODE
This is succesfull, later on I retrieve the correct MIME type and size
FYI: With note 1237688 you can retrieve the latest Word 2007 mime types in your system
CALL FUNCTION 'SDOK_MIMETYPE_GET'
EXPORTING
extension = lv_extension
IMPORTING
mimetype = lv_mime_type.
XSTRLEN( ls_attachment-file_contents ).
For example .docx is mime type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Afterwards I pass these on to the FileDownload UI element or the following method
CL_WD_RUNTIME_SERVICES=>attach_file_to_response
Result: .docx or .xlsx download files are always corrupt - with Office 2010 you do have the option to try and recover the file -> and this works!
But our customer is using Office 2007 and this is not supported there so he only gets the message that the file is corrupt.
Can anyone else confirm this problem or help me with a solution? Thx!
Greetings,
Wouter
DATA: lt_access_info TYPE TABLE OF sdokfilaci,
lt_ascii_content TYPE TABLE OF sdokcntasc,
lt_binary_content TYPE TABLE OF sdokcntbin.
DATA: lv_doc_lenght TYPE i,
lv_qty_lines TYPE i,
lv_xstring TYPE xstring.
CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
EXPORTING
object_id = w_object_id
raw_mode = 'X'
TABLES
file_access_info = lt_access_info
file_content_ascii = lt_ascii_content
file_content_binary = lt_binary_content
EXCEPTIONS
not_existing = 1
not_authorized = 2
no_content = 3
bad_storage_type = 4
OTHERS = 5.
IF sy-subrc <> 0.
RETURN.
ENDIF.
FIELD-SYMBOLS: <lt_access_info> LIKE LINE OF lt_access_info.
READ TABLE lt_access_info ASSIGNING <lt_access_info> INDEX 1.
IF sy-subrc IS INITIAL AND <lt_access_info>-file_size IS NOT INITIAL.
lv_doc_lenght = <lt_access_info>-file_size.
ELSE.
lv_qty_lines = lines( lt_binary_content ).
lv_doc_lenght = lv_qty_lines * 1022.
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
11 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.