ALV Object Model : Manage ALV Layouts

Users are able to save the following settings for their output table as layouts:

  • Which columns from the column set they wish to display and in what position
  • Which of the columns that can be aggregated they wish to total
  • Which columns in the output table are used to sort
  • Which filter should be used

Use class CL_SALV_LAYOUT to allow the user to manage ALV layouts. Call SET_KEY and SET_SAVE_RESTRICTION methods with proper parameters.

*& Data Declaration
DATA: gt_spfli     TYPE TABLE OF spfli.
DATA: gr_table     TYPE REF TO   cl_salv_table.
DATA: gr_functions TYPE REF TO   cl_salv_functions_list.
DATA: gr_layout    TYPE REF TO   cl_salv_layout.
DATA: g_key        TYPE salv_s_layout_key.
*& 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
      r_salv_table = gr_table
      t_table      = gt_spfli.

**Get the reference to the ALV toolbar functions
  gr_functions = gr_table->get_functions( ).

**Set all toolbar functions
  gr_functions->set_all( abap_true ).

**Manage ALV layouts
  gr_layout = gr_table->get_layout( ).
  g_key-report = sy-repid.
  gr_layout->set_key( g_key ).
*Set proper restriction for saving the layouts
  gr_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).

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



You are able to define various restrictions here that affect the user’s options for saving a layout. You are able to determine whether

  • Users can save layouts for themselves (user specific)
  • Users can save layout for all users (non user-specific)
  • Users can save layouts for themselves or for all users

Options available for set save restriction method that affect the user’s options for saving a layout.

Option Description
RESTRICT_NONE Save Layout Without Restriction
RESTRICT_USER_DEPENDANT Save Layout Only User-Specific

Three different types of layouts are as follows.

  1. Standard layout provided by SAP start with a number (0-9).
  2. Non user-specific layout start with ‘/’.
  3. User-specific layout start with a letter (A-Z).

Be the first to comment

Leave a Reply

Your email address will not be published.