How to exclude unnecessary buttons in ALV toolbar?
Question
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
OTHER TIPS
If you use REUSE_ALV_GRID_DISPLAY
in your code, this might be helpful for you:
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = 'ZPROGRAM'
i_callback_pf_status_set = 'SET_PF_STATUS'
it_fieldcat = it_fieldcat
tables
t_outtab = gt_itab.
Your SET_PF_STATUS
should be like this in order to eliminate some of the buttons you want. In this example I'm eliminating the "SORT_UP" button.
form set_pf_status using rt_extab type slis_t_extab.
data: lv_flag VALUE 'X'.
if lv_flag is not INITIAL.
append '&OUP' to rt_extab.
endif.
set pf-status 'STANDARD' excluding rt_extab.
endform. "set_pf_status
Hope it was helpful.
Talha