Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Hide Default Toolbar buttons in cl_salv_table ALV

8,903

Hi,

I wanted to remove the standard buttons coming in ALV GRID

2018-01-04-20-38-05.png

the table is displayed with following code,

    TRY.
        cl_salv_table=>factory(
          IMPORTING
            r_salv_table = go_alv
          CHANGING
            t_table      = gt_tab ).
      CATCH cx_salv_msg .

I tried the method from post

https://archive.sap.com/discussions/thread/1549378 but it is not working.

Requirement is to remove all standard buttons.

4 REPLIES 4

0 Kudos
3,029

Take a look at this link please.

https://archive.sap.com/discussions/thread/1377425

raymond_giuseppi
Active Contributor
3,029

Can you post the code you already wrote, using class cl_salv_functions or a similar one?

3,029

Dear All,

To Hide the default tool bar icon in FACTORY method, use below code.

***Below Code is used to set the standard tool bar

* §3.1 activate ALV generic Functions
data: lr_functions type ref to cl_salv_functions_list,
l_text type string,
l_icon type string.
constants gc_true type char1 value 'X'.
lr_functions = go_salv->get_functions( ).

lr_functions->set_all( gc_true ).

***Below Code is used to hide the standard tool bar icons.

try.
lr_functions->remove_function( name = '&GRAPH' ).
" ALV: General Error Class (Checked During Syntax Check)
catch cx_salv_not_found.
"ALV: General Error Class (Checked During Syntax Check)

catch cx_salv_wrong_call

endtry.

Sandra_Rossi
Active Contributor
0 Kudos
3,029

I was looking for a solution to remove the line of the toolbar control with CL_SALV_TABLE, when it's displayed in a container (the same as with LVC_S_LAYO-NO_TOOLBAR = 'X' when using CL_GUI_ALV_GRID), but it seems impossible .

At least, you can remove easily all standard buttons, except the information icon (tested with ABAP 7.57):

Minimal code to reproduce:

REPORT.
PARAMETERS dummy.
AT SELECTION-SCREEN OUTPUT.
  IF dummy = ''.
    dummy = 'X'.
    DATA(modules) = VALUE soli_tab(
        ( line = |Accounting| )
        ( line = |Procurement| ) ).
    cl_salv_table=>factory( EXPORTING r_container  = cl_gui_container=>screen0
                            IMPORTING r_salv_table = DATA(go_alv)
                            CHANGING  t_table      = modules ).
    go_alv->get_functions( )->set_all( abap_false ). " <======== SET_ALL( abap_false )
    go_alv->display( ).
  ENDIF.

NB: for information, what I wanted to achieve is this (if I force the hiding of the toolbar, by debug of CL_SALV_GUI_GRID_FACADE, method if_salv_gui_grid_ui_functions~is_toolbar_visible) or if I use the below code:

REPORT.
PARAMETERS dummy.
AT SELECTION-SCREEN OUTPUT.
  IF dummy = ''.
    dummy = 'X'.
    DATA(modules) = VALUE soli_tab(
        ( line = |Accounting| )
        ( line = |Procurement| ) ).
    DATA(alv_grid) = NEW cl_gui_alv_grid( i_parent = cl_gui_container=>screen0 ).
    alv_grid->set_table_for_first_display(
          EXPORTING  i_structure_name = 'SOLI'
                     is_layout        = VALUE #( no_toolbar = abap_true )
          CHANGING   it_outtab        = modules
          EXCEPTIONS OTHERS           = 4 ).
  ENDIF.