Here is a piece of code to write ABAP reports and format them easily and quickly. The following code can be created as an include and used whenever required. This code uses the ABAP objects and created as local class.
This include can be used for printing Internal tables, either by passing the whole table or by passing individual lines. Using the following steps the report output can be easily formatted.
- Create object with referance to lcl_report.
- Create column formats for individual columns by building the t_format structure and calling the method add_column as follows call method x->add_column exporting l_format = comp_print = 'K' (to print the column with key color) comp_print = 'H' (to print the column as hotspot)
- Call method write_table for listing the whole internal table. call method x->write_table exporting p_table =
- Call method write_line for listing one line at a time. May be used in cases where loop control is with the main program. call method x->write_line exporting p_line =
- Call method write_header to print the page header. Will be used in the top-of-page event. The report title is picked up as follows. for basic list - from the report title in the attributes for drilldown lists - from text symbol TTN where N is the drill down level. For example drill down level 2 will look for TT2.
- call method X->format_line exporting p_line = importing out_line =
Comments
We have tried your code and it's working perfectly. Thanks for the great information and for sharing it with others.
Amani