Search code examples
toolbarabapalv

How to exclude unnecessary buttons in ALV toolbar?


So, inside the TOOLBAR event of the CL_GUI_ALV_GRID the parameter E_OBJECT has the table MT_TOOLBAR that I can access to change all the buttons manually.

Is there a better way to include/exclude standard buttons in the toolbar than simply creating them like custom-buttons in the toolbar event?


Solution

  • Similar to REUSE_ALV_GRID_DISPLAY in class CL_GUI_ALV_GRID there is also a way.

    Define a table of type UI_FUNCTIONS and a work area of type UI_FUNC :

    data: lt_exclude type ui_functions,
          ls_exclude type ui_func.
    

    Append the attributes of the functions you want to hide to the table:

    ls_exclude = cl_gui_alv_grid=>mc_fc_sum.
    append ls_exclude to lt_exclude.
    

    The attributes of the standard functions all begin with the prefix MC_FC_, in addition, there is the prefix MC_MB_ for an entire menu in the toolbar.

    Pass the table using method set_table_for_first_display with parameter it_toolbar_excluding