cancel
Showing results for 
Search instead for 
Did you mean: 

BSP - download xlsx(excel 2007) document - error

Former Member
0 Kudos

Hi all,

i have a requirement to download different types of documents saved in server. All MS office documents are downloading correctly. it is supporting .xls files but .xlsx files are beiong saved and opened but with empty data, when opened in text document, it shows unrecognized characters(corrupted data)

i am using the below code.

1. FM to get the data in bianry format, file name and mome type.

2. then....

concatenate 'attachment;filename=' <filename> into lv_content_disposition_value .

loop at <binary data> into LT_CONTENT_BIN. " LT_CONTENT_BIN is of RAW(1022) type

CONCATENATE xstr LT_CONTENT_BIN-line INTO xstr IN BYTE MODE.

endloop.

me->response->set_data( data = xstr ).

me->response->set_header_field( name = 'Content-Type' value = lv_mimetype ).

me->response->set_header_field(

NAME = 'content-disposition'

VALUE = lv_content_disposition_value ).

navigation->response_complete( ).

the above code is written in Controller - do_request. no view is being called at the end. only the controller is available.

this is of high priority.. so please respond quickly.

thanks in advance.

Ajay.

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

Hi Guys,

How did you solve the problem, as I am facing
the same issue with
'SCMS_STRING_TO_XSTRING'
in an existing custom BSP application while converting the string to a XLSX file.

FM 'SCMS_STRING_TO_XSTRING'
was working fine with XLS format but for XLSX format(Microsoft excel 2007) I am
not able to open the file.

I have tried with the MIMETYPE “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”
but was not successful.

Can you guys
toss some light on this please!!!

Former Member
0 Kudos

Hi Guys,

how did you solve the problem? I am facing the same.

Please share.

Thanks

Former Member
0 Kudos

HI..

in addidtion the mime type are as below:

XLSX - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

XLS - application/vnd.ms-excel

Hendrik
Active Participant
0 Kudos

hi,

I faced the same problem with Office 2010 documents (docx, pptx and xlsx) stored in the system. Download with a custom BSP application did not work, the documents were corrupted during the process. Export in SAP GUI did work, hence we figured it must have something to do with the download.

Our solution was the use of:


    CALL FUNCTION 'CRM_KW_DOC_GET_DOCUMENT'
          EXPORTING
            io          = ls_phio
          IMPORTING
            content_bin = xstr.

In the FM the xstring is generated via the FM SCMS_BINARY_TO_XSTRING. It seams that the concatenation in the loop we used before (and did work for Office 2003 files) somehow messes up the binary stream for the Office 2010 documents.

Regards,

Hendrik