cancel
Showing results for 
Search instead for 
Did you mean: 

How to download alv data in webdynpro to external file

Former Member
0 Kudos

Hi,

Can anyone guide me how to download alv data from webdynpro to an external file. i followed the standard component WDR_TEST_EVENTS . FILE DOWNLOAD.

method supply_file .

data conv_out type ref to cl_abap_conv_out_ce.

data struct type if_filedownload=>element_filecontent_node.

  • fill the file content

conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).

conv_out->convert(

exporting

data = 'Der Inhalt einer Textdatei'

importing

buffer = struct-filecontent ).

node->bind_structure( struct ).

endmethod.

But how to pass our alv table data here instead of the text (Der Inhalt einer Textdatei) .

Thanking you

Archana.

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You are going to have to retrieve the data from the context into an internal table. You can use the node object method get_static_attributes_table.

Then you need to transform the internal table into something that Excel understands. In the ALV we use an XSLT to transform the data into the MHTML Excel format. However this relies on internal structures of the ALV component and isn't easily resuable from outside the ALV. Consider transforming the data into XML with your own XSLT or iXML parser or going with a simplier text-tab delimited format. Search the forums as the logic to conver the data (basically looping and concatenating in CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB and CR_LF) has been discussed just the other day.