[ABAP] ALV-Grid: Toolbar-Buttons entfernen

Variante 1 (Event on_toolbar)

* Die Button-Bezeichner sind Konstanten der Klasse cl_gui_alv_grid
METHOD on_toolbar.
* alle Toolbar-Buttons entfernen, außer
  DELETE e_object->mt_toolbar WHERE
        function NE cl_gui_alv_grid=>mc_fc_refresh          " Refresh
    AND function NE cl_gui_alv_grid=>mc_fc_loc_append_row   " Append
    AND function NE cl_gui_alv_grid=>mc_fc_loc_insert_row   " Insert
    AND function NE cl_gui_alv_grid=>mc_fc_loc_delete_row   " Delete
    AND function NE cl_gui_alv_grid=>mc_mb_export           " Excel
    AND function NE cl_gui_alv_grid=>mc_fc_current_variant. " Layout
ENDMETHOD.

Variante 2 (it_toolbar_excluding)

DATA: o_alv TYPE REF TO cl_gui_alv_grid.
DATA: it_tab TYPE STANDARD TABLE OF ...
DATA: it_fcat TYPE lvc_t_fcat.

...

* Liste mit auszuschließenden Toolbuttons erstellen
DATA(it_excl_toolbuttons) = VALUE ui_functions( ( cl_gui_alv_grid=>mc_fc_maximum )
                                                ( cl_gui_alv_grid=>mc_fc_minimum ) ).

* Layout anpassen
DATA(lv_layout) = VALUE lvc_s_layo( grid_title = 'ALV-Grid'
                                    zebra      = abap_true ).
                                    
* ALV-Grid anzeigen
o_alv->set_table_for_first_display( EXPORTING
                                      it_toolbar_excluding = it_excl_toolbuttons
                                      is_layout            = lv_layout
                                    CHANGING
                                      it_fieldcatalog      = it_fcat
                                      it_outtab            = it_tab ).