Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Removing Standard Toolbar Buttons in OO ALV Grid

Tech Oct 21 2

Customizing the toolbar is a common requirement when developing OO ALV reports in SAP to align with specific business styles. To hide the standard buttons and replace them with custom ones, you need to populate an exclusion table and pass it to the display method.

First, define an internal table to store the function codes of the buttons you wish to suppress:

DATA: lt_hidden_funcs TYPE ui_functions.

Next, create a routine that fills this table with the specific constants representing the standard ALV functions. In this example, we identify buttons by their class cnostants and append them to the exclusion list:

FORM remove_standard_buttons TABLES pt_func_list TYPE ui_functions.
  DATA: ls_func_code TYPE ui_func.

  ls_func_code = cl_gui_alv_grid=>mc_fc_maximum.
  APPEND ls_func_code TO pt_func_list.
  ls_func_code = cl_gui_alv_grid=>mc_fc_minimum.
  APPEND ls_func_code TO pt_func_list.
  
  ls_func_code = cl_gui_alv_grid=>mc_fc_subtot.
  APPEND ls_func_code TO pt_func_list.
  ls_func_code = cl_gui_alv_grid=>mc_fc_sum.
  APPEND ls_func_code TO pt_func_list.
  ls_func_code = cl_gui_alv_grid=>mc_fc_average.
  APPEND ls_func_code TO pt_func_list.
  
  ls_func_code = cl_gui_alv_grid=>mc_mb_sum.
  APPEND ls_func_code TO pt_func_list.
  ls_func_code = cl_gui_alv_grid=>mc_mb_subtot.
  APPEND ls_func_code TO pt_func_list.
  
  ls_func_code = cl_gui_alv_grid=>mc_fc_sort_asc.
  APPEND ls_func_code TO pt_func_list.
  ls_func_code = cl_gui_alv_grid=>mc_fc_sort_dsc.
  APPEND ls_func_code TO pt_func_list.
  
  ls_func_code = cl_gui_alv_grid=>mc_fc_find.
  APPEND ls_func_code TO pt_func_list.
  ls_func_code = cl_gui_alv_grid=>mc_fc_filter.
  APPEND ls_func_code TO pt_func_list.
  
  ls_func_code = cl_gui_alv_grid=>mc_fc_print.
  APPEND ls_func_code TO pt_func_list.
  ls_func_code = cl_gui_alv_grid=>mc_fc_print_prev.
  APPEND ls_func_code TO pt_func_list.
  
  ls_func_code = cl_gui_alv_grid=>mc_mb_export.
  APPEND ls_func_code TO pt_func_list.
  ls_func_code = cl_gui_alv_grid=>mc_fc_graph.
  APPEND ls_func_code TO pt_func_list.
  
  ls_func_code = cl_gui_alv_grid=>mc_mb_view.
  APPEND ls_func_code TO pt_func_list.
  ls_func_code = cl_gui_alv_grid=>mc_fc_detail.
  APPEND ls_func_code TO pt_func_list.
  
  ls_func_code = cl_gui_alv_grid=>mc_fc_help.
  APPEND ls_func_code TO pt_func_list.
  ls_func_code = cl_gui_alv_grid=>mc_fc_info.
  APPEND ls_func_code TO pt_func_list.
  
  ls_func_code = cl_gui_alv_grid=>mc_mb_variant.
  APPEND ls_func_code TO pt_func_list.
ENDFORM.

Finally, invoke the routine to populate the exclusion table and pass it to the set_table_for_first_display method using the it_toolbar_excluding parameter:

PERFORM remove_standard_buttons TABLES lt_hidden_funcs.

CALL METHOD grf_alv_grid->set_table_for_first_display
  EXPORTING
    is_variant           = gs_variant_config
    i_save               = 'A'
    is_layout            = gs_layout_config
    it_toolbar_excluding = lt_hidden_funcs
  CHANGING
    it_outtab            = gt_output_data
    it_fieldcatalog      = gt_field_catalog.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.