Here in this section we will understand another method to display the internal table data. Check the code below.
Line 6 : Report program name.
Line 8 : Declaring internal table to store records.
Line 10 – 11 : Declare internal table and work area for field catalogue. This field catalogue will be used to display the output.
Line 13 : Event start-of-selection.
Line 16 – 18 : Select query on DB table to fill the internal table. The data in this internal table will be displayed as Grid output.
Line 21 – 47 : Creating field catalogue for all the fields of the internal table which will be displayed.
FIELDNAME – this will carry the field name of the internal table
SELTEXT_L = This will carry the Long text which will be displayed as Column header in the output.
TABNAME = Internal table name whose data will be displayed as output.
COL_POS = Position at which the field will be displayed.
Line 49 : FM REUSE_ALV_GRID_DISPLAY is called to display the internal table records as a Grid.
Line 50 – 52 (Exporting parameters) :
i_callback_program = program name which calls this FM.
it_fieldcat = Field catalogue name.
Line 53 – 54 (Tables Parameters) :
t_outtab = name of the internal table whose records will be displayed.
Line 55 – 57 (Exceptions) : FM will return exceptions if any error occurs while execution.
Line 58 – 61 : Handle exceptions with a proper error message.
To understand Exporting and Tables Parameters please check post – Function Modules.
Program Output below :