10-15-2008 9:49 AM
I have a requirement wherein there are two ALV grids and the user needs to select a row from the grid and click a button on the application toolbar to display a detailed report for the selected row.
I am using get_selected_rows method for each instance of the Grid to get the selected row id.
Now the problem is, suppose if I select a row from Grid 1 and then later a row from Grid 2, the GET_SELECTED_ROWS method for GRID1 and GRID2 both provide data which makes it confusing as I need to display the report for the latest(recently) selected row.
Can anybody suggest me a method which tells me that the recently selected row was from Grid1 or Grid2.
or any event wherein I can fill the flag to indicate that the grid1 was most recently used or vice versa.
10-15-2008 10:53 PM
Hello Vin
Why do you not replace the button click by the double-click event? Then you have the selected row (via the row index) and you can easily distinguish between the different grid instance (see sample report ZUS_SDN_THREE_ALV_GRIDS in thread 😞
*---------------------------------------------------------------------*
* 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. " sending control, i.e. ALV grid that raised event
ENDCLASS. "lcl_eventhandler DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_eventhandler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
ls_kna1 TYPE kna1,
ls_vbak TYPE vbak,
ls_vbap TYPE vbap.
* Distinguish according to sending grid instance
CASE sender.
WHEN go_grid1.
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_grid2.
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
10-15-2008 10:53 PM
Hello Vin
Why do you not replace the button click by the double-click event? Then you have the selected row (via the row index) and you can easily distinguish between the different grid instance (see sample report ZUS_SDN_THREE_ALV_GRIDS in thread 😞
*---------------------------------------------------------------------*
* 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. " sending control, i.e. ALV grid that raised event
ENDCLASS. "lcl_eventhandler DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_eventhandler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
ls_kna1 TYPE kna1,
ls_vbak TYPE vbak,
ls_vbap TYPE vbap.
* Distinguish according to sending grid instance
CASE sender.
WHEN go_grid1.
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_grid2.
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
10-15-2008 11:04 PM
When you create the event receiver, can you create one for each grid so they are using their own event handlers? As long as both grids have their own handlers the corresponding get_selected_rows should only be being called for the respective grid. Also make sure you are refreshing and clearing the data structures/tables when done with them before the next double click. Hopefully this helps some.
Lamont
10-16-2008 6:18 AM