04-10-2010 11:59 PM
I would like to select all rows before sending ALV Grid Display. User then can unselect couple of rows for further processing. How do I do that ?. Im using Method grid1->SET_TABLE_FOR_FIRST_DISPLAY for ALV Report Display. Any help appreciated.
04-11-2010 1:12 AM
Ok,
I've started the editor and check my code. I made few small mistakes (like with this exporting/importing), here's the sample - correctly working - code:
DATA: it_selected TYPE lvc_t_row,
wa_selected TYPE lvc_s_row,
wa_sflight TYPE sflight,
ltp_layout TYPE lvc_s_layo.
SELECT *
FROM sflight
INTO TABLE gi_sflight.
ltp_layout-stylefname = 'CELLTAB'.
ltp_layout-sel_mode = 'A'.
LOOP AT gi_sflight INTO wa_sflight.
wa_selected-index = sy-tabix.
APPEND wa_selected TO it_selected.
ENDLOOP.
* * Load data into the grid and display them
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
is_layout = ltp_layout
i_save = 'A'
CHANGING it_outtab = gi_sflight.
CALL METHOD go_grid->set_selected_rows
EXPORTING
it_index_rows = it_selected.
This time it is 100% correct.
Edited by: Marcin Cudo on Apr 11, 2010 2:13 AM
04-11-2010 12:30 AM
Hi,
you can use method set_selected_rows of class cl_gui_alv_grid. Just loop through the the table you are going to display and add corresponding index to the work area, then append it to it_index_rows table.
DATA: it_selected TYPE lvc_t_row,
wa_selected TYPE lvc_s_row.
LOOP AT it_your_table TRANSPORTING NO FIELDS.
wa_index-index = sy-tabix.
APPEND wa_selected TO it_selected.
ENDLOOP.
CALL METHOD grid1->set_selected_rows
IMPORTING
it_index_rows = it_selected.
I didn't test it right now, but i suppose it should work fine.
04-11-2010 12:41 AM
Thanks a lot for the reply. When should I call this method ?. before calling grid1->SET_TABLE_FOR_FIRST_DISPLAY or after ?
04-11-2010 12:53 AM
Sreenivas, I really think it wouldn't take much time to just copy and paste this code before and after method set_table_for_first_display, activate it and check which one is giving the correct result
04-11-2010 1:06 AM
I tried both before and after still no luck. But Im sure set_selected_rows might do the trick. I think we need to export params rathan import. What do you think ?
04-11-2010 1:12 AM
Ok,
I've started the editor and check my code. I made few small mistakes (like with this exporting/importing), here's the sample - correctly working - code:
DATA: it_selected TYPE lvc_t_row,
wa_selected TYPE lvc_s_row,
wa_sflight TYPE sflight,
ltp_layout TYPE lvc_s_layo.
SELECT *
FROM sflight
INTO TABLE gi_sflight.
ltp_layout-stylefname = 'CELLTAB'.
ltp_layout-sel_mode = 'A'.
LOOP AT gi_sflight INTO wa_sflight.
wa_selected-index = sy-tabix.
APPEND wa_selected TO it_selected.
ENDLOOP.
* * Load data into the grid and display them
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
is_layout = ltp_layout
i_save = 'A'
CHANGING it_outtab = gi_sflight.
CALL METHOD go_grid->set_selected_rows
EXPORTING
it_index_rows = it_selected.
This time it is 100% correct.
Edited by: Marcin Cudo on Apr 11, 2010 2:13 AM
04-11-2010 1:24 AM