SAPHub

CL_SALV_TABLE : ALV Object Model – Display ALV Table

Use the below steps to display simple table using ALV Object Model (Class CL_SALV_TABLE).

*&---------------------------------------------------------------------*
*& Data Declaration
*&---------------------------------------------------------------------*
DATA: gt_spfli TYPE TABLE OF spfli.
DATA: gr_table TYPE REF TO   cl_salv_table.

*&---------------------------------------------------------------------*
*& Start-of-Selection
*&---------------------------------------------------------------------*
START-OF-SELECTION.
  SELECT * UP TO 10 ROWS FROM spfli INTO TABLE gt_spfli.

*Generate an instance of the ALV table object
  CALL METHOD cl_salv_table=>factory
    IMPORTING
      r_salv_table = gr_table
    CHANGING
      t_table      = gt_spfli.

*Display the ALV table.
  gr_table->display( ).

Output

You can display the simple ALV table in the following ways:

Below code displays simple table as classic ABAP list.

*&---------------------------------------------------------------------*
*& Data Declaration
*&---------------------------------------------------------------------*
DATA: gt_spfli  TYPE TABLE OF spfli.
DATA: gr_table  TYPE REF TO   cl_salv_table.

*&---------------------------------------------------------------------*
*& Start-of-Selection
*&---------------------------------------------------------------------*
START-OF-SELECTION.
  SELECT * UP TO 10 ROWS FROM spfli INTO TABLE gt_spfli.

*Generate an instance of the ALV table object
  CALL METHOD cl_salv_table=>factory
    EXPORTING
      list_display = if_salv_c_bool_sap=>true
    IMPORTING
      r_salv_table = gr_table
    CHANGING
      t_table      = gt_spfli.

*Display the ALV table.
  gr_table->display( ).

Output

Following are the restrictions with CL_SALV_TABLE (ALV Object Model)