Since I’ve been rebuilding my Renovation product into the old school Dynpro, it’s meant relearning a few tricks. Today, my trick was to keep the position, selections and current cell after refreshing the data with new data or updated date. First off, I need to thank this post for the great info.
Here’s the basics. Before you refresh the table, you will need to perform the following on your ALV grid.
data: es_row_no type lvc_s_roid.
data: es_row_info type lvc_s_row.
data: es_col_info type lvc_s_col.
data: fes_row_no type lvc_s_roid.
data: fes_row_id type lvc_s_row.
data: fes_col_id type lvc_s_col.
data: mt_cells type lvc_t_ceno.
data: mt_rows type lvc_t_row.
grid->get_scroll_info_via_id(
importing
es_row_no = es_row_no
es_row_info = es_row_info
es_col_info = es_col_info
).
grid->get_current_cell(
importing
* e_row = e_row
* e_value = e_value
* e_col = e_col
es_row_id = fes_row_id
es_col_id = fes_col_id
es_row_no = fes_row_no
).
grid->get_selected_rows(
importing
et_index_rows = mt_rows
* et_row_no = et_row_no
).
if mt_rows[] is initial.
grid->get_selected_cells_id(
importing et_cells = mt_cells ).
endif.
Now, there are multiple ways to refresh the table, I use set_table_for_first_display, but the post example uses refresh_table_display. Either way, after you do your refresh, then run the following to set the position and selections.
if mt_cells[] is not initial.
grid->set_selected_cells_id( it_cells = mt_cells ).
else.
grid->set_selected_rows(
it_index_rows = mt_rows
* it_row_no = it_row_no
* is_keep_other_selections = is_keep_other_selections
).
endif.
grid->set_scroll_info_via_id(
is_row_info = es_row_info
is_col_info = es_col_info
is_row_no = es_row_no
).
grid->set_current_cell_via_id( is_row_id = fes_row_id
is_column_id = fes_col_id
is_row_no = fes_row_no ).
refresh: mt_rows[], mt_cells[].
Thanks for reading,
As always, thanks for reading and don't forget to check out our SAP Service Management Products at my other company JaveLLin Solutions,Mike