cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to download .docx file in abap

Former Member
0 Kudos

Hi Guys,

While downloading the .docx file in code the file gets downloaded properly. But when opening it locally it a message is shown that the file is corrupted and can be repared. When I clickon ok. It gets repaired. I didnt have the problem with .doc file. Internally, the MIME type of the .docx file is saved as 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'. The .docx file is read from a content server as a binary file and also written on the application server as a binary file (line lenght 1022)

Can anyone tell why the contents of the file could not be viewed while opening in the application the file but can be viewed when saved as local file( the pop up information with a message that the file was corrupted and could be repaired appeared first. I choose the ok button for the file to be repaired and the content was then showed)?

Thanks in advance

Accepted Solutions (0)

Answers (4)

Answers (4)

alisonv
Explorer
0 Kudos
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.


Former Member
0 Kudos

Hi Maria,

I had exactly the same problem, and the error was the length of the binary. When you convert the file from binary to xstring, the parameter "input_length" should be exactly the length of the binary.

If the length doesn't fit, the file is downloaded ok, but the "corrupted file error" appears...

I hope it helps!   

Former Member
0 Kudos

Dear

I guess it has problem with .doc extension but

  .txt you can read

and also .docx and .xlsx will provide the content

it is only this .doc and .xls which will create problem.

e.g. .docx after downloading will give one .zip file.

change its extension to .doc or .docx. the content will be there.

thanks

Former Member
0 Kudos

Dear

Check which msoffice installed on your system install msoffice 2010 then it will read docx properly

Regards

Former Member
0 Kudos

Hi,

on my System i have msoffice 2010. I need to make some adjustments when downloading the binary file from the content server to application server. With msoffice 2007 I didnt have any problem with the code. The Binary file is retrieved from the content server using the FM SCMS_DOC_READ and is written on the application server using OPEN DATASET xxxx FOR OUTPUT IN BINARY MODE. I need to keep it in binary mode. As I said it works fine with .doc files.

Thanks.

christoph_hopf
Advisor
Advisor
0 Kudos

Hi Maria,

do you have to kind of issue also within the DMS transactions CV02N when displaying such a file or when downloading the file with report DMS_KPRO_READ?

Best regards,
Christoph

Former Member
0 Kudos

Hi,

both the CV02N and the report DMS_KPRO_READ are not working for me because we have our own implementation.

Is there any alternative FM to SCMS_DOC_READ to  read the office 2010 file (in binary) from the content server?

Should they be some additional steps to do with the binary file before writting it on the application server for office 2010 documents?

Thanks

christoph_hopf
Advisor
Advisor
0 Kudos

Hi Maria,

thanks for the information. But is it generally possible for you to download the files with report DMS_KPRO_READ or do you also get an error message with this report?

Best regards,
Christoph

Former Member
0 Kudos

How can I call this report in my own implementation?

Thanks

Former Member
0 Kudos

Hi,

DMS_KPRO_READ is not working for me. I dont have the expected parameters.  Is there any other solution? is there any customizing setting I should have think of compare to office 2003?

Thanks