Recently, have come across a requirement to send output of report developed based on SALV as an excel attachment. To achieve the same we can use the method TO_XML of class CL_SALV_TABLE. This method will have the formatted output content as XSTRING value.
Here are the steps.
a. Variable Declaration.
b.Data Selection/ALV Customizing calls.
c.Call to Convert ALV Output as internal XML Format.
d.E-Mail Data Declaration.
e.EMail – Content Conversion/Body/Attachment Creation
we can also use TO_XML method to download the content as an XLS or XML documents in Abap Web dynpro based applications .
Here is the sample source code for this approach.