How to insert functions to the Functions toolbar of new SAP ALV Display CL_SALV_TABLE

The new ALV Display based on the class CL_SALV_TABLE offers you the possibility to add a new function. It is completely based on the Display mode. In the container mode, the function is added through the functions object. In the complete mode, it is added through the GUI status for the Dynpro.

Adding functions in Container mode:

The Add_function( ) method of the functions object is used to insert functions to the functions toolbar.

DATA lr_functions_list TYPE REF TO cl_salv_functions_list.

lr_functions_list = lr_alv_object->get_functions( ).

lr_functions_list->set_all( ).

lr_functions_list->add_function( name = ‘SUM’  text = ‘SUM’  tooltip = ‘SUM’

position = if_salv_c_function_position=>right_of_salv_function ).

Adding functions in complete mode:

In order to insert a new function in complete mode, copy the GUI status SALV_TABLE_STANDARD in your report.

  1. Open the function group SALV_METADATA_STATUS through the transaction SE80. Right click on the GUI status SALV_TABLE_STANDARD.
  2. Select the copy from the options in order to copy the GUI status.
  3. Give the program name and a name for the copied GUI status in the popup window and finally confirm the entries.
  4. The ALV object must be able to recognize the newly added GUI-status. It is recognized through the set_screen_status method of the ALV object.

Lr_alv_object->set_screen_status( report = ‘ZALV_NEW_FUNCTION’ pfstatus = ‘SALV_TABLE_STANDARD’ set_functions = lr_alv_object->c_functions_all ).

The GUI status can be further adjusted to insert the new function code.