FUNCTION grid_refresh_and_keep_position.
*"----------------------------------------------------------------------
"“本地接口:
*” IMPORTING
*" REFERENCE(I_SOFT) TYPE CHAR01 DEFAULT ‘X’
*" REFERENCE(I_SET_CURRENT) TYPE CHAR01 DEFAULT SPACE
*" REFERENCE(I_SET_SELECTED) TYPE CHAR01 DEFAULT SPACE
*" CHANGING
*" REFERENCE(GRID) TYPE REF TO CL_GUI_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.
grid->refresh_table_display( i_soft_refresh = i_soft ).
IF i_set_selected EQ ‘X’.
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.
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
).
IF i_set_current EQ ‘X’.
grid->set_current_cell_via_id( is_row_id = fes_row_id
is_column_id = fes_col_id
is_row_no = fes_row_no ).
ENDIF.
REFRESH: mt_rows[], mt_cells[].
ENDFUNCTION.