Skip to Content

Disabling / Enabling a cutom button on the toolbar

Hi,

I'm using the new way to do ALV grids - I have a customised button called 'DIRECT' on the toolbar but dont know how to disable it have tried to use the CL_SALV_FUNCTIONS->remove_function method but it keeps on coming back with an exception stating that I am using a wrong call

data: gt_table   type ref to cl_salv_table.
  data: l_t100     type t100,
        l_save(10).
  data: gr_layout  type ref to cl_salv_layout.
  data: key        type salv_s_layout_key.
 
  try.
      cl_salv_table=>factory(
        importing
          r_salv_table = gt_table
        changing
          t_table      = it_boc_document ).
    catch cx_salv_msg.                                
  endtry.
 
  gr_layout = gt_table->get_layout( ).
  key-report = sy-repid.
  gr_layout->set_key( key ).
 
  gr_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
 
  "Set the pf-status
  try.
      gt_table->set_screen_status(
        pfstatus      =  'ALV_STATUS'
        report        =  sy-repid
        set_functions = gt_table->c_functions_all ).
    catch cx_salv_msg.                          
  endtry.
 
  gt_table->display( ).

Any help would be appreciated.

Many thanks in advance

Raj

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Dec 04, 2009 at 03:56 PM

    You need to set the Visibility of the required function to hide it.

    Like:

      gr_table->set_screen_status(
        pfstatus      =  'SALV_STANDARD'
        report        =  gs_test-repid
        set_functions = gr_table->c_functions_all ).
    
      DATA: lo_functions TYPE REF TO cl_salv_functions,
            lt_func_list TYPE salv_t_ui_func,
            la_func_list LIKE LINE OF lt_func_list.
    
    * Get all functions
      lo_functions =   gr_table->get_functions( ).
      lt_func_list = lo_functions->get_functions( ).
    
    * Now hide the MYFUNCTION
      LOOP AT lt_func_list INTO la_func_list.
        IF la_func_list-r_function->get_name( ) = 'MYFUNCTION'.
          la_func_list-r_function->set_visible( ' ' ).
        ENDIF.
      ENDLOOP.
    

    Regards,

    Naimesh Patel

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Experts,

      I have a requirement to disable (not hide) the button in application toolbar. I have also tried the method SET_ENABLE, but it hides the button.

      Regards,

      Ashok

  • avatar image
    Former Member
    Dec 04, 2009 at 12:33 PM

    Hi Raj,

    ALV Grid control allows you to add your own functions triggered by a button press on the ALV toolbar. For this, we mainly utilize two of ALV Grid events. We use the event TOOLBAR to add the button and the event USER_COMMAND to implement the new function.

    In the method handling the TOOLBAR event, we define a new button by filling a structure and appending it to the table attribute MT_TOOLBAR of the object to whose reference we can reach via the parameter E_OBJECT of the event.

    The field of the structure for your requirement will be DISABLED.

    Refer below code :-

    CLEAR ls_toolbar.
    MOVE 'EXCH' TO ls_toolbar-function. 
    MOVE 2 TO ls_toolbar-butn_type.
    MOVE icon_calculation TO ls_toolbar-icon.
    MOVE 'Payment in Other Currencies'(202) TO ls_toolbar-quickinfo.
    MOVE ' ' TO ls_toolbar-text.
    MOVE ' ' TO ls_toolbar-disabled.
    APPEND ls_toolbar TO i_object->mt_toolbar.

    Regards

    Abhii

    Add comment
    10|10000 characters needed characters exceeded