2008 Aug 21 9:26 AM
Hi all,
My problem is:
I have 2 screens say 101, 102
In 101 screen, i am displaying alv grid, when i select a row and click on the button 'Display' on app toolbar, using get_selected_rows method i am capturing index of the row and displaying corresponding details in the second alv (will be displayed in screen 102) .
when i go back from 102 using 'BACK' to the screen 101 and selects the other row in alv and againing clicking on 'Dislay' , my get_selected_rows is not capturing the index of the row i selected.(Second time)
lt_index[] is empty for the second time.
Code in PAI event of 101 screen.
case sy-ucomm.
WHEN 'DISPLAY'
refresh lt_index[].
clear wa_index.
call method grid1->get_selected_rows
importing
et_index_rows = lt_index.
et_row_no = lt_row_no[].
READ TABLE LT_INDEX INTO WA_INDEX INDEX 1.
READ TABLE itab_zqmseq INDEX wa_index INTO z_alv.
call screen 102.
call method grid1->refresh_table_display.
endcase.
PAI Event of 102 screen.
WHEN 'BACK'.
leave to screen 101.
Please help me in solving this.
Thanks in advance,
Swathi
hi,
try with
clear row no in display method or
clear the row no you are capturing from the method get_selected_rows
once you are coming back from screen 102 to 101.
2008 Aug 21 10:19 AM
hi,
try with
clear row no in display method or
clear the row no you are capturing from the method get_selected_rows
once you are coming back from screen 102 to 101.
2008 Aug 21 11:55 AM
It is working for me check it once, what you are doing with the sample code..
I have two screens 100,200.
for 100 screen CONT and 200 screen CONT1.
it working fine for me.
CREATE OBJECT grid
EXPORTING
i_parent = cont
i_appl_events = 'X' "<----Check this
REPORT ztest_selected.
DATA: it_flight TYPE sflight_tab1,
it_scarr TYPE STANDARD TABLE OF scarr.
DATA: grid TYPE REF TO cl_gui_alv_grid,
cont TYPE REF TO cl_gui_custom_container.
DATA: grid2 TYPE REF TO cl_gui_alv_grid,
cont2 TYPE REF TO cl_gui_custom_container.
SELECT * FROM scarr
INTO TABLE it_scarr
UP TO 10 ROWS.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS'.
IF cont IS INITIAL.
CREATE OBJECT cont
EXPORTING
container_name = 'CONT'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6
.
IF sy-subrc EQ 0.
CREATE OBJECT grid
EXPORTING
i_parent = cont
i_appl_events = 'X'
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5
.
IF sy-subrc NE 0.
ENDIF.
CALL METHOD grid->set_table_for_first_display(
EXPORTING
i_structure_name = 'SCARR'
CHANGING
it_outtab = it_scarr
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
).
IF sy-subrc NE 0.
ENDIF.
ENDIF.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
DATA: et_row_no TYPE lvc_t_roid,
LS_ROW LIKE LINE OF ET_ROW_NO,
WA_SCARR TYPE SCARR.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'DISPLAY'.
CALL METHOD grid->get_selected_rows(
IMPORTING
et_row_no = et_row_no
).
if et_row_no is not INITIAL.
READ TABLE ET_ROW_NO INTO LS_ROW INDEX 1.
READ TABLE IT_SCARR INTO WA_SCARR INDEX LS_ROW-ROW_ID.
PERFORM FLIGHT_DISPLAY using WA_SCARR-carrid.
ENDIF.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form FLIGHT_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form FLIGHT_DISPLAY using carrid type sflight-carrid.
clear it_flight.
select * from sflight
into table it_flight
where carrid eq wa_scarr-carrid.
CALL SCREEN 200.
endform. " FLIGHT_DISPLAY
*&---------------------------------------------------------------------*
*& Module STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module STATUS_0200 output.
SET PF-STATUS 'STATUS2'.
clear: cont2,grid2.
IF cont2 IS INITIAL.
CREATE OBJECT cont2
EXPORTING
container_name = 'CONT2'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6
.
IF sy-subrc EQ 0.
CREATE OBJECT grid2
EXPORTING
i_parent = cont2
i_appl_events = 'X'
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5
.
IF sy-subrc NE 0.
ENDIF.
CALL METHOD grid2->set_table_for_first_display(
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
it_outtab = it_flight
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
).
IF sy-subrc NE 0.
ENDIF.
ENDIF.
ENDIF.
endmodule. " STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0200 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module USER_COMMAND_0200 input.
case sy-ucomm.
when 'BACK'.
leave to screen 0.
endcase.
endmodule. " USER_COMMAND_0200 INPUT
2008 Aug 27 5:26 AM
Hello Swathi
The sample report ZUS_SDN_TWO_ALV_GRIDS_2SCR does exactly what you would like to do.
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_TWO_ALV_GRIDS_2SCR
*&
*&---------------------------------------------------------------------*
*& Thread: get_selected_rows when called second time
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1013798"></a>
*&
*& Thread: clear GRID
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1017969"></a>
*&
*& Thread: ALV Grid OO u2013 Get_selected_rows u2013 I can I re-display ALV Grid with selected
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="924061"></a>
*&
*& Thread: CL_GUI_ALV_GRID-GET_SELECTED_ROWS Parameter ET_INDEX_ROWS not filled.
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="826287"></a>
*&
*& Thread: ALV double-click
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="900214"></a>
*&---------------------------------------------------------------------*
*& Screen '0100' contains no elements.
*& ok_code -> assigned to GD_OKCODE
*&
*& Flow logic:
* PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
**
* PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
*&
*& Screen '0200': copy of screen '0100' (for the sake of simplicity)
*&
*& GUI Status: contains function button 'DETAIL' to display details
*& of customer on 2nd screen
*&---------------------------------------------------------------------*
REPORT zus_sdn_two_alv_grids_2scr.
DATA:
gd_okcode TYPE ui_func,
gd_repid TYPE syrepid,
*
go_docking1 TYPE REF TO cl_gui_docking_container,
go_docking2 TYPE REF TO cl_gui_docking_container,
go_grid1 TYPE REF TO cl_gui_alv_grid,
go_grid2 TYPE REF TO cl_gui_alv_grid,
gs_layout TYPE lvc_s_layo.
DATA:
gt_outtab1 TYPE STANDARD TABLE OF knb1,
gt_outtab2 TYPE STANDARD TABLE OF knvv.
*---------------------------------------------------------------------*
* 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.
ENDCLASS. "lcl_eventhandler DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_eventhandler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
lt_rows type lvc_t_row.
CHECK ( sender = go_grid1 ).
append e_row to lt_rows.
CALL METHOD go_grid1->set_selected_rows
EXPORTING
it_index_rows = lt_rows
* it_row_no =
* is_keep_other_selections =
.
* Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DETAIL' ).
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_outtab1
WHERE bukrs = '1000'.
PERFORM init_controls.
* Display data
gs_layout-grid_title = 'Customers'.
gs_layout-sel_mode = 'D'. " multiple row selection
gs_layout-sel_mode = ' '. " single row selection
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'KNB1'
is_layout = gs_layout
CHANGING
it_outtab = gt_outtab1
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
gs_layout-grid_title = 'Customers Details (Sales Areas)'.
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'KNVV'
is_layout = gs_layout
CHANGING
it_outtab = gt_outtab2 " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
gd_repid = syst-repid.
* Link the docking container to the target dynpro
CALL METHOD go_docking1->link
EXPORTING
repid = gd_repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Link the docking container to the target dynpro
CALL METHOD go_docking2->link
EXPORTING
repid = gd_repid
dynnr = '0200'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* NOTE: dynpro does not contain any elements
CALL SCREEN '0100'.
* Flow logic of dynpro '0100' (does not contain any dynpro elements):
*
*PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
**
*PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form INIT_CONTROLS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM init_controls .
* Create docking container
CREATE OBJECT go_docking1
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create ALV grids
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_docking1
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Set event handler
SET HANDLER:
lcl_eventhandler=>handle_double_click FOR go_grid1.
* Create docking container
CREATE OBJECT go_docking2
EXPORTING
parent = go_docking2
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create ALV grids
CREATE OBJECT go_grid2
EXPORTING
i_parent = go_docking2
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " INIT_CONTROLS
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'. " contains push button "DETAIL"
* SET TITLEBAR 'xxx'.
* Refresh display of detail ALV list
CALL METHOD go_grid2->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
TRANSLATE gd_okcode TO UPPER CASE.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
CASE syst-dynnr.
WHEN '0100'.
SET SCREEN 0. LEAVE SCREEN.
WHEN '0200'.
SET SCREEN '0100'.
LEAVE SCREEN.
ENDCASE.
* User has pushed button "Display Details"
WHEN 'DETAIL'.
PERFORM entry_show_details.
CALL SCREEN '0200'.
WHEN 'DELETE'.
perform DELETE_ENTRIES.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form ENTRY_SHOW_DETAILS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM entry_show_details .
* define local data
DATA:
ls_row TYPE lvc_s_row,
lt_rows type lvc_t_row,
ls_knb1 TYPE knb1,
lt_knb1 TYPE STANDARD TABLE OF knb1.
CALL METHOD go_grid1->get_selected_rows
IMPORTING
et_index_rows = lt_rows
* et_row_no =
.
LOOP AT lt_rows INTO ls_row.
READ TABLE gt_outtab1 INTO ls_knb1 INDEX ls_row-index.
APPEND ls_knb1 TO lt_knb1.
ENDLOOP.
IF ( lt_rows IS INITIAL ).
REFRESH: gt_outtab2.
ELSE.
SELECT * FROM knvv INTO TABLE gt_outtab2
FOR ALL ENTRIES IN lt_knb1
WHERE kunnr = lt_knb1-kunnr.
ENDIF.
ENDFORM. " ENTRY_SHOW_DETAILS
*&---------------------------------------------------------------------*
*& Form DELETE_ENTRIES
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form DELETE_ENTRIES .
* define local data
DATA:
ls_row TYPE lvc_s_row,
lt_rows type lvc_t_row.
CALL METHOD go_grid1->get_selected_rows
IMPORTING
et_index_rows = lt_rows
* et_row_no =
.
LOOP AT lt_rows INTO ls_row.
delete gt_outtab1 INDEX ls_row-index.
ENDLOOP.
go_grid1->refresh_table_display( ). " Mandatory !!!
endform. " DELETE_ENTRIES
Regards
Uwe
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |