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

ALV OO - single handler for several grids

Former Member
0 Likes
1,170

Hi people!

First of all, I apologize if this thread is not in the correct section.

I have a screen which displays three ALV OO, and each one of these ALV have to respond to double click event.

The functionality for the double click event is the same for all the ALVs, this is, to show another screen with detailed data based on each ALV.

As far as I know about OO programming( which is not too much btw...) in order to do this, I have to create a handler class for each one of these ALV (feel free to correct me if I'm wrong about this):

class handler_1 to manage grid_1

class handler_2 to manage grid_2

class handler_3 to manage grid_3

I think this is not efficient at all, because the functionality of each handler is the same for all of the ALV's.

That's why I wanted to know if there's a way to get which of the ALV's is triggering the handle_double_click event.

I've been searching, and I found this, but it's used for handle_data_changed event

http://www.erpgenie.com/sap-technical/abap/handling-changes-to-multiple-alv-grids

any ideas?

Thanks!

1 ACCEPTED SOLUTION
Read only

huseyindereli
Active Contributor
0 Likes
852

Hi Fabian,

Check this code snippet. It may help you to handle events with one handler for different instances.

[my blog.|http://abap-development-consultant.blogspot.com/2011/05/using-alv-event-handler-for-all.html]

*** INSTANCES

DATA : go_alv01 TYPE REF TO cl_gui_alv_grid ,

go_alv02 TYPE REF TO cl_gui_alv_grid ,

go_alv03 TYPE REF TO cl_gui_alv_grid .

      • LINK EVENTS TO INSTANCE

SET HANDLER go_event_handler->handle_double_click FOR ALL INSTANCES.

      • DEFINITION OF EVENT

----


  • CLASS lcl_event_handler DEFINITION

----


class lcl_event_handler definition .

public section .

class-methods:

handle_double_click

for event double_click of cl_gui_alv_grid

importing e_row e_column sender.

private section.

endclass. "lcl_event_handler DEFINITION

      • IMPLEMENTATION OF EVENTS

----


  • CLASS lcl_event_handler IMPLEMENTATION

----


class lcl_event_handler implementation .

method handle_hotspot_click.

CASE sender.

WHEN go_alv01.

" go_alv01 has fired the event

WHEN go_alv02.

" go_alv02 has fired the event

WHEN go_alv03.

" go_alv03 has fired the event

ENDCASE.

endmethod.

2 REPLIES 2
Read only

huseyindereli
Active Contributor
0 Likes
853

Hi Fabian,

Check this code snippet. It may help you to handle events with one handler for different instances.

[my blog.|http://abap-development-consultant.blogspot.com/2011/05/using-alv-event-handler-for-all.html]

*** INSTANCES

DATA : go_alv01 TYPE REF TO cl_gui_alv_grid ,

go_alv02 TYPE REF TO cl_gui_alv_grid ,

go_alv03 TYPE REF TO cl_gui_alv_grid .

      • LINK EVENTS TO INSTANCE

SET HANDLER go_event_handler->handle_double_click FOR ALL INSTANCES.

      • DEFINITION OF EVENT

----


  • CLASS lcl_event_handler DEFINITION

----


class lcl_event_handler definition .

public section .

class-methods:

handle_double_click

for event double_click of cl_gui_alv_grid

importing e_row e_column sender.

private section.

endclass. "lcl_event_handler DEFINITION

      • IMPLEMENTATION OF EVENTS

----


  • CLASS lcl_event_handler IMPLEMENTATION

----


class lcl_event_handler implementation .

method handle_hotspot_click.

CASE sender.

WHEN go_alv01.

" go_alv01 has fired the event

WHEN go_alv02.

" go_alv02 has fired the event

WHEN go_alv03.

" go_alv03 has fired the event

ENDCASE.

endmethod.

Read only

0 Likes
852

You're a genius Hüseyin Dereli!!

I've implemented the solution you gave me, and it's working!

Thank you very much for your reply

Regards!