Skip to Content
avatar image
Former Member

How to identify which button user clicked on ALV

Hi,

I have created 2 custom buttons on ALV grid.For select-all/De-select-all chekbox column.

In wdoinit I have folowing code.

CREATE OBJECT lr_buttonui.
  lr_buttonui->set_text( 'Select all ' ).

  DATA button1 TYPE REF TO cl_salv_wd_function.

  button1 = lo_value->if_salv_wd_function_settings~create_function( id = 'LBUTTON' ).
  button1->set_editor( lr_buttonui ).

  CREATE OBJECT lr_buttonud.
  lr_buttonud->set_text( 'De-Select all ' ).

  DATA button2 TYPE REF TO cl_salv_wd_function.

  button2 = lo_value->if_salv_wd_function_settings~create_function( id = 'LBUTTOND' ).
  button2->set_editor( lr_buttonud ).

In eventhandler ONFUNCTIONCLICK - type - ON_FUNCTION I am writing my code to do the changes for checkboxes.

My issue is now how do i identify which button has user-clicked?

Rgds

vara

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Jul 02, 2009 at 02:28 AM

    Hi Vara,

    button1 = lo_value->if_salv_wd_function_settings~create_function( id = 'LBUTTON' ).

    Here the id mentioned within the brackets will help you identify which button is click. So using LBUTTON and LBUTTOND u can identify which button was clicked.

    Place the following code in your on_function method

    DATA: temp TYPE string. 
    temp = r_param->id. 
    CASE temp.
      WHEN 'LBUTTON'.
          "carry out the required fucntionality  
      WHEN 'LBUTTOND'.
          ..........
    ENDCASE.

    Check this article [Self Defined Functions for ALV|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/101df93f-4b5c-2910-14aa-9eb0338c2110?overridelayout=true], it will be helpful.

    Regards,

    Radhika.

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 02, 2009 at 05:31 AM
    • My apologies I see that Radhika has posted the same exact answer & article as mine. Sorry for the redundant reply*

    Hi Vara,

    You need to create an event handler method for the event ON_FUNCTION of the ALV. Then within this method you can write a case structure to find out which particular button triggered the event. Something similar to what is shown below:

    method ON_SEARCH . 
         DATA: temp TYPE string. 
          temp = r_param->id.
    
          IF temp = 'LBUTTON'. 
                wd_comp_controller->fill_sflights( ).
         ENDIF. 
    endmethod.

    Try go through this [article |https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/101df93f-4b5c-2910-14aa-9eb0338c2110]by Rakesh in which he is creating 2 input fields & button inside the ALV toolbar. He then tries to detect from which button the action was triggered.

    Regards,

    Uday

    Edited by: Uday Gubbala on Jul 2, 2009 11:02 AM

    Add comment
    10|10000 characters needed characters exceeded