03-19-2007 10:21 AM
Dear All,
I have an ALV in a first screen, we selected a row and call a second screen with a new ALV.
If in the first one i have two lines, i select the first one and i display the second ALV with the data concerning the first row selected. I go back and i select the second line and i try to display the data concerning this one but the old data of the first line of the ALV displayed.
I made some FREE of all objects GRID, CONTAINER.*
Someone could help me on this issue ???
Regards
Sebastien
03-19-2007 10:25 AM
Also try to refresh the fieldcatalog for the second ALV and also the internal tables used in second ALV
03-19-2007 10:46 AM
I checked in debug mode and my internal table is Ok when i call the method SET_TABLE_FOR_FIRST_DISPLAY for the second time
03-19-2007 10:53 AM
03-19-2007 11:04 AM
The data just before the method in OK in t_outtab2 for the second display
but it displayed the data of the first display.
Sort internal table
SORT t_outtab2.
Refresh data
REFRESH t_outtab2_bck.
Move data to variable
MOVE t_outtab2[] TO t_outtab2_bck[].
Call method
CALL METHOD wo_grid2->set_table_for_first_display
EXPORTING
i_save = 'A'
i_default = c_x
is_layout = wa_layout2
CHANGING
it_outtab = t_outtab2[]
it_fieldcatalog = t_fieldcat2[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc EQ 0.
Dummy
ENDIF. " IF sy-subrc eq 0
Create event handler object
CREATE OBJECT wo_event_handler.
Register handler methods to handle ALV grid events
SET HANDLER wo_event_handler->handle_data_changed FOR wo_grid2.
Call method
CALL METHOD wo_grid2->set_toolbar_interactive.
Check IF condition
IF sy-subrc EQ 0.
Dummy
ENDIF. " IF sy-subrc EQ 0
Call method
CALL METHOD wo_grid2->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
Check IF condition
IF sy-subrc EQ 0.
Dummy
ENDIF. " IF sy-subrc EQ 0
Call method
CALL METHOD wo_grid2->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
Check IF condition
IF sy-subrc EQ 0.
Dummy
ENDIF. " IF sy-subrc EQ 0
03-19-2007 11:08 AM
But where are you populating the t_outtab2 table??
Before populating that REFRESH t_outtab2.
03-19-2007 11:14 AM
I checked the internal table populating, it was not in this part of code.
Consider that the internal tbale is right populated before the call method.
Thanks
Sebastien
03-19-2007 11:22 AM
03-19-2007 11:34 AM
Hello Sebastien
I guess the following sample report may be helpful:
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_TWO_ALV_GRIDS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zus_sdn_two_alv_grids.
DATA:
gd_okcode TYPE ui_func,
*
go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
go_cell_top TYPE REF TO cl_gui_container,
go_cell_bottom TYPE REF TO cl_gui_container,
go_grid1 TYPE REF TO cl_gui_alv_grid,
go_grid2 TYPE REF TO cl_gui_alv_grid.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1,
gt_knvv 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:
ls_knb1 TYPE knb1.
CHECK ( sender = 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( 'DETAIL' ).
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = '1000'.
* Create docking container
CREATE OBJECT go_docking
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 splitter container
CREATE OBJECT go_splitter
EXPORTING
parent = go_docking
rows = 2
columns = 1
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Get cell container
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_top.
CALL METHOD go_splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = go_cell_bottom.
* Create ALV grids
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_cell_top
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 OBJECT go_grid2
EXPORTING
i_parent = go_cell_bottom
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.
* Display data
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'KNB1'
CHANGING
it_outtab = gt_knb1
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.
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'KNVV'
CHANGING
it_outtab = gt_knvv " 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.
* Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-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.
* NOTE: dynpro does not contain any elements
CALL SCREEN '0100'.
* Flow logic of dynpro:
*
*PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
**
*PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& 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.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
* User has pushed button "Display Details"
WHEN 'DETAIL'.
PERFORM entry_show_details.
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:
ld_row TYPE i,
ls_knb1 TYPE knb1.
CALL METHOD go_grid1->get_current_cell
IMPORTING
e_row = ld_row.
READ TABLE gt_knb1 INTO ls_knb1 INDEX ld_row.
CHECK ( syst-subrc = 0 ).
SELECT * FROM knvv INTO TABLE gt_knvv
WHERE kunnr = ls_knb1-kunnr.
ENDFORM. " ENTRY_SHOW_DETAILS
Regards
Uwe
03-19-2007 11:41 AM
03-19-2007 1:41 PM
Hello Uwe,
I try to summarise.
1 ALV OO in a screen 100 (main data) with 2 rows
1 ALV OO in screen 200 (detail screen)
When i select the first row in the first ALV and i display detailled data in the second -> OK
I go back and i select the second one and i display the data linked with this one.
The data of the first line selected is displayed. If i click on refresh button, data of the second row selected are displayed.
Could you tell me if it's possible to refresh all the data of my second ALV before the second display.
Thanks and regards
Sebastien
03-19-2007 2:38 PM
Hello Sebastien
In my second sample report I used - for the sake of simplicity - the same USER_COMMAND PAI module. In your case you probable prefer to have a <b>separate</b> USER_COMMAND_0200 PAI module for the <b>second</b> dynpro.
When you leave the second dynpro and return to the first dynpro you could put the following coding into the PAI module.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0200 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0200 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
* Refresh 2nd itab
REFRESH: gt_knvv.
* 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.
" Perhaps flushing is necessary, i.e.
CALL METHOD cl_gui_cfw=>flush.
SET SCREEN 0. LEAVE SCREEN. " return to screen '0100'
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0200 INPUT
Regards
Uwe
03-19-2007 3:07 PM
hi,
need to do flushing in program.
the best example of this is in SAP program name BCALV_GRID_07 where they have button on tool and change the values on selction from primary list to secondary list..
I hope just run this program ..and see this would really help you building the program.
cheers
03-19-2007 3:44 PM
Ok this issue comes from the fact that we passed all the time in the CREATE object statement.
When i trigger it only one time, it works fine.
What i don't understand it's why when you FREE all the object, the result is not the same.
Thanks for All