2013 Sep 13 12:00 PM
Hi,
I registered two event handler for two alv object, which are displayed in same screen. But sometimes one can be triggered and sometimes the other especially for event DATA_CHANGED and SUBTOTAL_TEXT. For example, DATA_CHANGED under event handler A is triggered and that under event handler B is not.
Best regards,
ts
2013 Sep 15 5:58 AM
Hi T.S,
You can handle the events for all instances by defining just a single event handler.
DATA : alv01 TYPE REF TO cl_gui_alv_grid ,
alv02 TYPE REF TO cl_gui_alv_grid .
SET HANDLER g_event_receiver->handle_data_changed FOR FOR ALL INSTANCES.
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING
er_data_changed
e_onf4
e_onf4_before
e_onf4_after
e_ucomm
sender.
*----------------------------------------------------------------------*
* CLASS lcl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
CASE sender.
WHEN alv01.
" alv01 has fired the event
WHEN alv02.
" alv02 has fired the event
In this way, you will get events for all instances handled correctly with a single handler.
You can refer these links for sample codes on multiple instance handling and data changed event handling
http://abap-development-consultant.blogspot.ae/2011/05/using-alv-event-handler-for-all.html
http://wiki.scn.sap.com/wiki/display/ABAP/Get+Changed+Value+In+ALV+Grid+Dynamically.
2013 Sep 13 12:15 PM
Don't need one handler for each ALV GRID
Can use
SET HANDLER ... FOR ALL INSTANCES OF ...
2013 Sep 15 3:34 AM
I use different event handlers because the user commands are different. Can SET HANDLER ... FOR ALL INSTANCES OF ... handle this?
2013 Sep 15 6:29 AM
2013 Sep 13 12:47 PM
Hi TS,
Hi refer below code.
for different alv objects you can pass registered events like this.
data:grid1 type ref to cl_gui_alv_grid,
grid2 type ref to cl_gui_alv_grid,
call method grid1->check_changed_data.
call method grid1->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_modified
exceptions
error = 1
others = 2.
call method grid2->check_changed_data.
call method grid2->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_modified
exceptions
error = 1
others = 2.
Thanks & Reagards
Hiriyappa
2013 Sep 15 5:58 AM
Hi T.S,
You can handle the events for all instances by defining just a single event handler.
DATA : alv01 TYPE REF TO cl_gui_alv_grid ,
alv02 TYPE REF TO cl_gui_alv_grid .
SET HANDLER g_event_receiver->handle_data_changed FOR FOR ALL INSTANCES.
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING
er_data_changed
e_onf4
e_onf4_before
e_onf4_after
e_ucomm
sender.
*----------------------------------------------------------------------*
* CLASS lcl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
CASE sender.
WHEN alv01.
" alv01 has fired the event
WHEN alv02.
" alv02 has fired the event
In this way, you will get events for all instances handled correctly with a single handler.
You can refer these links for sample codes on multiple instance handling and data changed event handling
http://abap-development-consultant.blogspot.ae/2011/05/using-alv-event-handler-for-all.html
http://wiki.scn.sap.com/wiki/display/ABAP/Get+Changed+Value+In+ALV+Grid+Dynamically.