12-10-2010 8:30 AM
Hi experts,
I'm using the method get_selected_rows for my OO ALV.
It's under the user command module.
I don't know why but sometimes it populates the return table but sometimes it doesn't.
Any ideas what could be causing this?
Really appreciate your inputs.
Thanks
Chris
12-10-2010 9:24 AM
12-10-2010 8:44 AM
This happens because you are not clearing the custom container.
Do you have this check??
if g_custom_container is initial.
----------
endif.
Check the same, if the check is not there, then set it up, then the method will always return values.
BR
Mishra..
12-10-2010 9:25 AM
Hi Mishra,
Yes i already have that custom container check where you create the container and the grid all over again.
thanks for the input though.
Chris
12-10-2010 8:48 AM
Try to use method refresh_table_display after your get_selected_rows..
a®
12-10-2010 9:24 AM
12-10-2010 9:36 AM
Hi Sumodh,
Sorry for this. I'm still learning OO coding. Hope you can help.
-
module status_0100 output.
perform f_show_grid.
endmodule.
-
form f_show_grid.
data: wa_rows like line of t_rows.
if custom_container is initial.
create a custom container control for our ALV Control
create object custom_container
exporting
container_name = container
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
create an instance of alv control
create object grid
exporting
i_parent = custom_container.
wa_layout-sel_mode = 'A'.
call method grid->set_table_for_first_display
exporting
is_layout = wa_layout
changing
it_fieldcatalog = t_field
it_sort = t_sort
it_outtab = t_main.
perform create_grid.
Create Object to receive events and link them to handler methods.
When the ALV Control raises the event for the specified instance
the corresponding method is automatically called.
create object event_receiver.
set handler event_receiver->handle_toolbar for grid.
set handler event_receiver->handle_user_command for grid.
Call method 'set_toolbar_interactive' to raise event TOOLBAR.
call method grid->set_toolbar_interactive.
else.
perform refresh_grid.
endif.
call method cl_gui_control=>set_focus
exporting
control = grid.
endform. "f_show_grid
-
form create_grid.
Create an instance of alv control
create object grid
exporting
i_parent = custom_container.
wa_layout-sel_mode = 'A'.
call method grid->set_table_for_first_display
exporting
is_layout = wa_layout
changing
it_fieldcatalog = t_field
it_outtab = t_main.
Create Object to receive events and link them to handler methods.
When the ALV Control raises the event for the specified instance
the corresponding method is automatically called.
create object event_receiver.
set handler event_receiver->handle_toolbar for grid.
set handler event_receiver->handle_hotspot_click for grid.
set handler event_receiver->handle_user_command for grid.
Call method 'set_toolbar_interactive' to raise event TOOLBAR.
call method grid->set_toolbar_interactive.
endform. " create_grid1
-
form refresh_grid.
call method grid->free.
perform create_grid.
call method grid->refresh_table_display.
endform. " refresh_grid1
-
module user_command_0100 input.
case ok_code.
perform f_selected_rows.
...
endmodule.
-
form f_selected_rows.
call method grid->get_selected_rows
importing
et_index_rows = t_rows.
--> after this t_rows gets values, sometimes it doesn't
...
endform.
-
Chris
12-10-2010 9:45 AM
Chris,
Try to call check_changed_data before the get_selected_row
form f_selected_rows.
CALL METHOD grid->check_changed_data( ). " Add this line
call method grid->get_selected_rows
importing
et_index_rows = t_rows.
endform.
a®
12-13-2010 8:50 AM
Hi a®s,
Still. I figured that on first execution it works fine. Then sometimes by going back to the selection-screen and executing again, the problem persists.
Any ideas? Sorry for the trouble but this is really starting to frustrate me.
Chris
12-13-2010 4:03 PM
Hi Chris,
when you return to selection screen, the object custom_container is initialized in your program, but it still lives at your front end - gui controls are applications run by your PC.
When executing 'BACK' or other command to return to selection screen, you should call custom_container->free( ) and grid->free( ).
Otherwise the data you see are not the data you are processing.
Regards,
Clemens
12-14-2010 3:49 AM
12-08-2011 10:55 AM
Hi all,
I call back this old thread, because I tried every suggestion in this, but nothing helps.
I created 2 Dynpros. The first gives an overview, the second shows the details. If I select one or more rows after first display of the overview everything is fine. But if I go back from the detail screen to the overview screen and select any other row, method doesn`t recognize it.
r_cont type ref to cl_gui_custom_container,
r_alv type ref to cl_salv_table,
.....
r_select TYPE REF TO cl_salv_selections,
....
it_getsel TYPE salv_t_row
WHEN 'GET_DETAIL'.
LEAVE TO LIST-PROCESSING.
r_alv->get_metadata( ).
it_getsel = r_select->get_selected_rows( ).
CLEAR: r_alv, r_cont.
CALL SCREEN 0101.
Anyone - who knows a solution?
Cheers
DieterA