Application Development and Automation 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: 
Read only

Replicating MENU_BUTTON, TOOLBAR events

Former Member
0 Likes
649

Hi All,

I wanted to know if the events in CL_GUI_ALV_GRID - MENU_BUTTON and TOOLBAR - are available in the new ALV Object Model. If not, is there a way to replicate them.

I couldn't find anything matching these events in the various CL_SALV* classes.

Thanks and Regards,

Vidya.

1 REPLY 1
Read only

naimesh_patel
Active Contributor
0 Likes
348

SALV Model has Functions object which does the job similar to TOOLBAR Event.

In SALV, Add the function in the ALV grid, get the function object and call the method ADD_FUNCTION.


*... §3.1 activate ALV generic Functions
    data: lr_functions type ref to cl_salv_functions,
          l_text       type string,
          l_icon       type string.

    lr_functions = gr_table->get_functions( ).
    lr_functions->set_all( gc_true ).

*... §3.2 include own functions
    l_text = 'My Button'.
    l_icon = icon_complete.
    try.
      lr_functions->add_function(
        name     = 'MYFUNCTION'
        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.

To handle the added function, register the event USER_COMMAND.


    data: lr_events type ref to cl_salv_events_table.

    lr_events = gr_table->get_event( ).

    create object gr_events.
    set handler gr_events->on_user_command for lr_events.

Event handler class


class lcl_handle_events definition.
  public section.
    methods:
      on_user_command for event added_function of cl_salv_events
        importing e_salv_function.
endclass.                    "lcl_handle_events DEFINITION

class lcl_handle_events implementation.
  method on_user_command.
    perform show_function_info using e_salv_function text-i08.
  endmethod.                    "on_user_command
endclass.                    "lcl_handle_events IMPLEMENTATION

Check program SALV_DEMO_TABLE_FUNCTIONS for more information.

Regards,

Naimesh Patel