CL_SALV_TABLE : ALV Object Model – Display Settings

To change the display settings of ALV object model (Class CL_SALV_TABLE) use class CL_SALV_DISPLAY_SETTINGS.

With the class CL_SALV_DISPLAY_SETTINGS, you can make settings that affect the appearance of the entire table.

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

*&---------------------------------------------------------------------*
*& 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.

*Get the reference to the settings of the table
  gr_display = gr_table->get_display_settings( ).
*Set the striped pattern (ZEBRA pattern)
  gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
*Set the heading
  gr_display->set_list_header( 'ALV Demo Program' ).
*Remove horizontal lines of the grid
  gr_display->set_horizontal_lines( if_salv_c_bool_sap=>false ).
*Remove vertical lines of the grid
  gr_display->set_vertical_lines( if_salv_c_bool_sap=>false ).

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

Output

 sap-alv-object-model-displayt-settings

Class CL_SALV_DISPLAY_SETTINGS contains the following methods:

Method Description
SET_STRIPED_PATTERN Sets striped pattern
IS_STRIPED_PATTERN Checks whether the striped pattern is active
SET_LIST_HEADER_SIZE Sets header sizes
GET_LIST_HEADER_SIZE Returns header sizes
SET_HORIZONTAL_LINES Sets horizontal lines
IS_HORIZONTAL_LINES Checks whether horizontal lines are active
IS_VERTICAL_LINES Checks whether vertical lines are active
SET_VERTICAL_LINES Sets vertical lines
SET_LIST_HEADER Sets headers
GET_LIST_HEADER Returns header
GET_SUPPRESS_EMPTY_DATA Checks how an empty data table is displayed
SET_SUPPRESS_EMPTY_DATA Determines how an empty data table is to be displayed