I am working on a program in Business Warehouse that allows you to map out all of your process chains by following the hierarchy of parent to sub-chains by using the rspcchain table. As of right now I have it printing the output to the screen, but would like to export this output to excel instead. I have been unable to find a function module that serves this purpose, so any help would be greatly appreciated
note - after learning about the SALV classes available I changed the code to display the table differently.
*Declaring types and variables
TYPES: BEGIN OF t_chains,
chain_id LIKE rspcchain-chain_id,
variant LIKE rspcchain-variante,
END OF t_chains.
DATA: lt_rspcchain TYPE STANDARD TABLE OF t_chains,
lwa_rspcchain TYPE t_chains,
o_alv TYPE REF TO cl_salv_table,
lx_msg TYPE REF TO cx_salv_msg.
*selection screen setup
SELECT-OPTIONS chain_id FOR rspcchain-chain_id.
SELECT-OPTIONS type FOR rspcchain-type.
*filling local table
SELECT chain_id variante
FROM rspcchain INTO TABLE lt_rspcchain
WHERE chain_id IN chain_id AND
type IN type AND
objvers = 'A'.
*original code to test printing output on screen
*LOOP AT lt_rspcchain INTO lwa_rspcchain.
* WRITE lwa_rspcchain-chain_id.
* WRITE lwa_rspcchain-variant.
IF sy-subrc NE 0. "sy-subrc = return code
WRITE 'Data not found'.
*loading data from local table into alv object table
r_salv_table = o_alv
t_table = lt_rspcchain ).
CATCH cx_salv_msg INTO lx_msg.
*calling display method to display table
You can use the SALV framework for this, it comes with a class to export whatever would be displayed to various formats, including .MHTML and .XML formats that are understood by Excel. The class
CL_SALV_TABLE has a method
TO_XML to support this; additionally, you might need the
CL_SALV_BS_XML_UTILS to handle the transformations. See the report
SALV_TEST_TABLE_DISPLAY_OR_XML for example coding.