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: 

Trigger Custom Button in ALV report using SALV

spartans007
Participant
0 Kudos

Hello,

I am writing a report and displaying it with the CL_SALV_Table objects. I have created a custom GUI status with two buttons on it and I need to know how to handle those actions when they are pressed.

Below is my code.

  lo_gr_alv->set_screen_status( pfstatus      = 'ZCUSTOM'
                                report        = sy-repid
                                set_functions = lo_gr_alv->c_functions_all
                                  ).
								  
								  
data: 
          l_text       type string,
          l_icon       type string.

  lo_gr_functions = lo_gr_alv->get_functions( ).
  lo_gr_functions->set_all( abap_true ).

    l_text = 'Generate'.
    l_icon = icon_complete.
    try.
      lo_gr_functions->add_function(
        name     = 'TEST'
        icon     = l_icon
        text     = l_text
        tooltip  = l_text
        position = if_salv_c_function_position=>right_of_salv_functions ).
      catch cx_salv_existing cx_salv_wrong_call.
    endtry.
*****

  CASE sy-ucomm.
    WHEN 'TEST'.
      gt_rows = lr_selections->get_selected_rows( ).
      LOOP AT gt_rows INTO DATA(gs_rows).
        READ TABLE gt_data INTO DATA(gs_index) INDEX gs_rows.
      ENDLOOP.
    WHEN 'BACK'.
      LEAVE TO SCREEN 0.
    WHEN OTHERS.
  ENDCASE.

Can someone please help me out with this?

How to handel the custom buttons

5 REPLIES 5

raymond_giuseppi
Active Contributor
0 Kudos

Can you post the code of your local method to handle events such as if_salv_events_functions~before_salv_function

Sandra_Rossi
Active Contributor
0 Kudos

Did you search?

Custom Button "set_screen_status" CL_SALV_TABLE site:sap.com

spartans007
Participant
0 Kudos

Yes sandra.rossi i check all these sites too. Did not found how to trigger event for the button.

I was able to add the custom button, but when i click on the button it does not get trigged.

Sandra_Rossi
Active Contributor
0 Kudos

Try this search to include the events (any user action) of CL_SALV_TABLE (method GET_EVENT):

Custom Button "set_screen_status" "get_event" CL_SALV_TABLE site:sap.com

wilbur_peng
Explorer
0 Kudos

you need a local event listener class to handle SALV event, please check demo program SALV_DEMO_TABLE_EVENTS in SE38