I wanted to loop through a table and write each row of data from the table into an excel document.
LOOP AT IT_Table INTO ST_Table.
IF IT_Table[] IS NOT INITIAL.
DELETE FROM ZLN.
MOVE-CORRESPONDING IT_Table[] TO IT_ZLN[].
MODIFY ZLN FROM TABLE IT_ZLN.
"Code here to write to excel
ENDIF.
ENDLOOP.
FM GUI_DOWNLOAD - first header, then append line.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = "C:\myexcel.xls"
TABLES
data_tab = lt_hdr.
LOOP AT it_table INTO st_table.
... "here your code
APPEND st_table to it_output.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = "C:\myexcel.xls"
append = 'X' "this will append line to your file
TABLES
data_tab = it_output. "table with one record wich you should collect
CLEAR it_output.
ENDLOOP.
SAP_CONVERT_TO_XLS_FORMAT can read about this FM
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.