cancel
Showing results for 
Search instead for 
Did you mean: 

Download multiple internal table into excel in WDA

0 Kudos

Hi Experts,

Here is my requirement, I have a initial ALV display using Webdynpro, upon clicking on ALV output another two different dynamic alv's will be displayed below the initial ALV. Now i have button to download the three different ALV's data into an Excel .

I cannot use standard download ALV functionality of webdynpro, since i want to download all the three alvs data into single EXCEL file, I have tried to convert the internal table data into string and then to Xstring using FM SCMS_STRING_TO_XSTRING

When i use the method: attach_file_to_response=>ATTACH_FILE_TO_RESPONSE and try to download it is giving me an error "Service cannot be reached" , URL call was terminated because the service corresponding is not available, I have done some research on this error and found note : 1568932 WDA: Problems when downloading files, but it is not suggestable.

Please help me if any alternative way to download the above requirement, Thanks for your help!.

Thanks,

Sailaja

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Yes Matthew, please find my below code.

data: text type string,

xtext type xstring.

loop at lt_summ_disp INTO ls_summ_disp.
CONCATENATE ls_summ_disp-KOSTL ls_summ_disp-WBS ls_summ_disp-PROJECT
CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO text SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
ENDLOOP.

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = text
* MIMETYPE = ' '
* ENCODING =
IMPORTING
BUFFER = xtext
* EXCEPTIONS
* FAILED = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
wdr_task=>client_window->client->attach_file_to_response=>ATTACH_FILE_TO_RESPONSE(
i_filename = 'WDP.xls'
i_content = xtext
i_mime_type = 'EXCEL'
i_in_new_window = abap_true ).

Thanks

Sailaja

matt
Active Contributor
0 Kudos

Don't post as an answer. Post as a comment.

While Excel can open a tab delimited file, a tab delimited file cannot really be described as an Excel file. Any more than a .txt file is a Word file. Even if you name the file .doc.

What is the complete error message? Does it tell you the URL that's failing? You probably need to activate a service in SICF. It's unlikely you need to use an alternate method for downloading you file.

matt
Active Contributor
0 Kudos

You can't just download an xstring and expect that somehow to magically become a fully functional xlsx file.

Use abap2xlsx to generate the excel file (as xstring), and then use attach_file_to_response.