This example portrays the most simple ALV creation using the cl_salv_table
class and no additional formatting options. Additional formatting options would be included after the TRY
ENDTRY
block and before the alv->display( )
method call.
All subsequent examples using the ABAP Objects approach to ALV creation will use this example as a starting point.
DATA: t_spfli TYPE STANDARD TABLE OF spfli,
alv TYPE REF TO cl_salv_table,
error_message TYPE REF TO cx_salv_msg.
" Fill the internal table with example data
SELECT * FROM spfli INTO TABLE t_spfli.
" Fill ALV object with data from the internal table
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = alv
CHANGING
t_table = t_spfli ).
CATCH cx_salv_msg INTO error_message.
" error handling
ENDTRY.
" Use the ALV object's display method to show the ALV on the screen
alv->display( ).