It mainly involves the use of a function:Call function 'ws _ Excel'
However, the problem is not solved yet. That is, an Excel file is generated after this function is called, but if you do not close this Excel file and run your program again, when you call this function again, the system will report an error. I do not know how to solve this problem yet. That is, after a call, you must close the opened Excel file before calling it again. Otherwise, an error occurs. Or it cannot be called twice in a row.
Example:
Form output_excel.
* "For testing
If chk_dtl EQ 'x '.
Clear out_excel [].
Out_excel-field01 = 'Company Code '.
Out_excel-field02 = 'employee no '.
Out_excel-field03 = 'elastic' (y/n )'.
Out_excel-field04 = 'rating '.
Out_excel-field05 = 'salary increase % '.
Append out_excel.
Loop at it_detail.
Out_excel-field01 = it_detail-bukrs.
Out_excel-field02 = it_detail-pernr.
Out_excel-field03 = it_detail-eligible.
Out_excel-field04 = it_detail-rating.
Out_excel-field05 = it_detail-percentage.
Append out_excel.
Clear out_excel.
Endloop.
Call function 'ws _ Excel'
Exporting
Filename = 'd:/emprating.xls'
Tables
Data = out_excel.
Endif.
Endform. "output_excel