CL_SALV_TABLE example



Using CL_SALV_TABLE class to create a very simple ABAP ALV report that selects data from database table SFLIGHT and displays it to the user as an ALV grid via the cl_salv_table=>factory method. This is just a very basic output but demonstrates how you can display a grid report with s little as 12 lines of code, you could actually get it lower than this.

*& TITLE: Simple ALV report using CL_SALV_TABLE class
*&-------------------------------*
*& Report  ZALV_SIMPLE
*&-------------------------------*
*& Output very simple ALV report using CL_SALV_TABLE class
*&-------------------------------*
REPORT ZALV_SIMPLE.

DATA: it_report TYPE TABLE OF sflight.
DATA: salv_table TYPE REF TO   cl_salv_table.

*------------------
START-OF-SELECTION.

* Select data from database table SFLIGHT
  SELECT *
   UP TO 20 ROWS
    from SFLIGHT
    INTO TABLE it_report.

* Create an instance of the SALV table object
  CALL METHOD cl_salv_table=>factory
    EXPORTING
      list_display = if_salv_c_bool_sap=>false
    IMPORTING
      r_salv_table = salv_table
    CHANGING
      t_table      = it_report.


*----------------
END-OF-SELECTION.

* Output ALV report to user
  salv_table->display( ).

CL_SALV_TABLE example

About the Author se80