cancel
Showing results for 
Search instead for 
Did you mean: 

Help with "attach_file_to_response"

Former Member
0 Kudos

Hi,

can any one tell me how I supply a file from the application server to the parameter "I_CONTENT" of method "attach_file_to_response" as type xstring.

Thanks in advance

C

Accepted Solutions (0)

Answers (1)

Answers (1)

shwetars
Advisor
Advisor
0 Kudos

Hi,

you can use the fm SCMS_BINARY_TO_XSTRING to convert your file content on AS from binary to xstring and pass the output of the above fm to the parameter i_content of the method attach_file_to_response.

Regards,

Shweta

Former Member
0 Kudos

Thanks Shweta,

this is my code and although the functionality of opening the file in Excel or saving the file as Excel works, when I open the file there is an initial column at the start that I can't get rid of.

In your example, are you reading the data in line by line, i.e. read dataset? If you are, surley the output of the file would be the same as my example with an initial column. Produced I think by the Concatenation.

CURRENT CODE

open dataset lv_dataset for input in text mode

encoding default.

do.

read dataset lv_dataset into wa.

if sy-subrc ne 0.

exit.

endif.

concatenate: lv_string_s

wa

cl_abap_char_utilities=>cr_lf into lv_string_s

separated by cl_abap_char_utilities=>horizontal_tab.

enddo.

close dataset lv_dataset.

cl_abap_conv_out_ce=>create( receiving conv = lr_conv ).

lr_conv->convert( exporting data = lv_string_s

importing buffer = lv_xfile ).

cl_wd_runtime_services=>attach_file_to_response(

exporting i_filename = i_filename

i_content = lv_xfile "<hex_container>

i_mime_type = 'application/vnd.ms-excel' ).