SAPHub

ALV Object Model : ALV Toolbar Functions

Use class CL_SALV_FUNCTIONS_LIST to add ALV toolbar functions. Call SET_SORT_ASC method to set the Sort Ascending function in the ALV toolbar.

*&---------------------------------------------------------------------*
*& 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.
*&---------------------------------------------------------------------*
*& 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 ALV toolbar functions
  gr_functions = gr_table->get_functions( ).

**Set the sort ascending function
  gr_functions->set_sort_asc( abap_true ).

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

Output

Call SET_GROUP_SORT method to set all the Sort functions in the ALV toolbar.

**Set all the sort functions
  gr_functions->set_group_sort( abap_true ).

Call SET_DEFAULT method to set all the default functions in the ALV toolbar.

**Set all default functions
  gr_functions->set_default( abap_true ).

Call SET_ALL method to set all the functions in the ALV toolbar.

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

Check the list of methods in class CL_SALV_FUNCTIONS_LIST for the entire list of options available to manage the ALV toolbar functions.