ALV using OOPS, How to handle events


I need to handle EVENTS (user_command) using OOPS in ALV. Please let me know in general - how do we define event handlers for the events declared in a CLASS.

In This case, I need to handle EVENT user_command of cl_gui_alv_grid CLASS.

I am aware of the syntax:

SET HANDLER o_eventreceiver->handle_user_command FOR o_Alvgrid.

Is it necessary to have a self defined class (like one above quoted - o_eventreceiver) to set the handler? Cant I use something like -

SET HANDLER handle_user_command FOR EVENT user_command of o_Alvgrid.

Thanks & Regards,


  • SAP Employee

Yes, it is a very common practice to define a local class as the event handler class for all events.

You should follow the example in program BCALV_GRID_02.


Rich Heilman

0 View this answer in context