‎2009 Feb 17 5:18 PM
Hi, Gurus:
I followed the example ALV program BCALV_GRID_03, created my own program.
I have my own data show on the first grid. Double click event implemented, so I can go to second grid via double click.
Now I need to implement another double click event for grid 2, the code inside CLASS lcl_event_receiver IMPLEMENTATION is just for grid 1. How could I do it ?
I have read the Easy Reference for ALV Grid Control, it seems that I could not get answer from it.
Thanks in advance.
Liang
‎2009 Feb 17 5:28 PM
Try this way
data: event_receiver_grid type ref to lcl_event_receiver_grid,
event_receiver_grid2 type ref to lcl_event_receiver_grid2.
....
....
....
class lcl_event_receiver_grid2 definition.
public section.
methods:
double_click_200
for event double_click
of cl_gui_alv_grid
importing e_row e_column es_row_no,
....
....
class lcl_event_receiver_grid2 implementation.
method double_click_200.
v_dclick = c_y.
move e_row to wa_dblclk_rows.
append wa_dblclk_rows to i_dblclk_rows.
v_row = wa_dblclk_rows-index.
if e_column-fieldname ne 'EQUNR'.
* perform f_equipment_detail.
endif.
clear : v_dclick.
endmethod.
....
....
....
then use the lcl_event_receiver_grid2 in the set handler for grid2
set handler event_receiver_grid->double_click_200 for grid2.
a®
‎2009 Feb 17 5:28 PM
Try this way
data: event_receiver_grid type ref to lcl_event_receiver_grid,
event_receiver_grid2 type ref to lcl_event_receiver_grid2.
....
....
....
class lcl_event_receiver_grid2 definition.
public section.
methods:
double_click_200
for event double_click
of cl_gui_alv_grid
importing e_row e_column es_row_no,
....
....
class lcl_event_receiver_grid2 implementation.
method double_click_200.
v_dclick = c_y.
move e_row to wa_dblclk_rows.
append wa_dblclk_rows to i_dblclk_rows.
v_row = wa_dblclk_rows-index.
if e_column-fieldname ne 'EQUNR'.
* perform f_equipment_detail.
endif.
clear : v_dclick.
endmethod.
....
....
....
then use the lcl_event_receiver_grid2 in the set handler for grid2
set handler event_receiver_grid->double_click_200 for grid2.
a®
‎2009 Feb 17 5:37 PM
a®s:
Your proposal does not work since lcl_event_receiver_grid2 is not defined in SAP.
If I use: event_receiver_grid2 type ref to lcl_event_receiver_grid
It does not make sense since "lcl_event_receiver_grid" is still same class.
Thanks
Liang
‎2009 Feb 17 5:41 PM
>
> data: event_receiver_grid type ref to lcl_event_receiver_grid, > event_receiver_grid2 type ref to lcl_event_receiver_grid2. >>
If you see my code above i am referencing to lcl_event_receiver_grid2 and NOT lcl_event_receiver_grid.
and also you need to define and implement lcl_event_receiver_grid2 in your code
a®
‎2009 Feb 17 6:08 PM
‎2009 Feb 17 7:30 PM
Hello Liang
There is absolutely no need to define a second event handler. You may have a look at my sample report ZUS_SDN_THREE_ALV_GRIDS in thread .
The crucial points are shown below:
*---------------------------------------------------------------------*
* CLASS lcl_eventhandler DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
sender. " <<< optional parameter: instance that raised the event
ENDCLASS. "lcl_eventhandler DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_eventhandler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
ls_knb1 TYPE knb1,
ls_vbak TYPE vbak,
ls_vbap TYPE vbap.
CASE sender. " discriminate according to sending instance...
WHEN go_grid1.
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
* IS_ROW_ID =
* IS_COLUMN_ID =
is_row_no = es_row_no.
* Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'ORDERS' ).
WHEN go_grid2.
READ TABLE gt_vbak INTO ls_vbak INDEX e_row-index.
CHECK ( ls_vbak-vbeln IS NOT INITIAL ).
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
* IS_ROW_ID =
* IS_COLUMN_ID =
is_row_no = es_row_no.
* Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'ORDER_DETAILS' ).
WHEN go_grid3.
READ TABLE gt_vbap INTO ls_vbap INDEX e_row-index.
CHECK ( ls_vbap-matnr IS NOT INITIAL ).
SET PARAMETER ID 'MAT' FIELD ls_vbap-matnr.
CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
WHEN OTHERS.
RETURN.
ENDCASE.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
Regards
Uwe
‎2009 Feb 17 7:37 PM
Thanks Uwe,
I never used "SENDER" parameter. Its new info to me.
This info i came to know few months earlier i can avoid bunch of unwanted codes which i have written
Thanks anyway
a®
‎2009 Feb 17 8:33 PM
Great! Uwe. It help me to solve my problem.
Your solution is what I prefered, and I have tried it works.
Thanks a lot.
Liang
Edited by: Liang Ji on Feb 17, 2009 9:40 PM
‎2009 Feb 17 5:29 PM
<< cut and paste without attribution from https://www.sdn.sap.com/irj/scn/wiki?path=/pages/viewpage.action%3fpageid=53583 removed >>
Edited by: GP on Feb 17, 2009 6:32 PM
Edited by: Rob Burbank on Feb 17, 2009 1:24 PM