Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

avl scrolling

Former Member
0 Likes
822

Hi all

I am using the abap class implementation of an alv. I have a problem that occurs when I enter a cell value and hit return the focus goes back to the first row.

e.g. i enter a value on row 50 and the focus jumps back to row 1.

Any help would be greatly appreciated

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
697

Dareen

Write the below code in the program (In the handle_data_changed event). It will keep the scroll bar in the same place.

Concept behind this code is, after the data is changed we will call refresh_table_display. If u call like that the ALV will get refreshed so the cursor goes to the first cell. But before refreshing the ALV get the current cell using <b>get_current_cell</b> and get the scroll information using <b>get_scroll_info_via_id</b>. Then refresh the ALV and again set the current cell using <b>set_current_cell_via_id</b>.

DATA: li_rows TYPE lvc_s_roid,

li_col TYPE lvc_s_col,

lws_row_id TYPE lvc_s_roid,

lws_col_id TYPE lvc_s_col,

ls_col TYPE lvc_s_col,

ls_num TYPE lvc_s_roid.

CALL METHOD o_alvgrid->get_current_cell

IMPORTING

es_col_id = li_col

es_row_no = li_rows.

CALL METHOD o_alvgrid->get_scroll_info_via_id

IMPORTING

es_col_info = ls_col

es_row_no = ls_num.

CALL METHOD o_alvgrid->refresh_table_display.

CALL METHOD o_alvgrid->set_scroll_info_via_id

EXPORTING

is_col_info = ls_col

is_row_no = ls_num.

lws_row_id-row_id = li_rows-row_id.

lws_col_id-fieldname = li_col-fieldname.

CALL METHOD o_alvgrid->set_current_cell_via_id

EXPORTING

is_column_id = lws_col_id

is_row_no = lws_row_id.

Regards,

Prakash.

Dareen

Write the below code in the program (In the handle_data_changed event). It will keep the scroll bar in the same place.

Concept behind this code is, after the data is changed we will call refresh_table_display. If u call like that the ALV will get refreshed so the cursor goes to the first cell. But before refreshing the ALV get the current cell using <b>get_current_cell</b> and get the scroll information using <b>get_scroll_info_via_id</b>. Then refresh the ALV and again set the current cell using <b>set_current_cell_via_id</b>.

DATA: li_rows TYPE lvc_s_roid,

li_col TYPE lvc_s_col,

lws_row_id TYPE lvc_s_roid,

lws_col_id TYPE lvc_s_col,

ls_col TYPE lvc_s_col,

ls_num TYPE lvc_s_roid.

CALL METHOD o_alvgrid->get_current_cell

IMPORTING

es_col_id = li_col

es_row_no = li_rows.

CALL METHOD o_alvgrid->get_scroll_info_via_id

IMPORTING

es_col_info = ls_col

es_row_no = ls_num.

CALL METHOD o_alvgrid->refresh_table_display.

CALL METHOD o_alvgrid->set_scroll_info_via_id

EXPORTING

is_col_info = ls_col

is_row_no = ls_num.

lws_row_id-row_id = li_rows-row_id.

lws_col_id-fieldname = li_col-fieldname.

CALL METHOD o_alvgrid->set_current_cell_via_id

EXPORTING

is_column_id = lws_col_id

is_row_no = lws_row_id.

Regards,

Prakash.

3 REPLIES 3
Read only

Former Member
0 Likes
698

Dareen

Write the below code in the program (In the handle_data_changed event). It will keep the scroll bar in the same place.

Concept behind this code is, after the data is changed we will call refresh_table_display. If u call like that the ALV will get refreshed so the cursor goes to the first cell. But before refreshing the ALV get the current cell using <b>get_current_cell</b> and get the scroll information using <b>get_scroll_info_via_id</b>. Then refresh the ALV and again set the current cell using <b>set_current_cell_via_id</b>.

DATA: li_rows TYPE lvc_s_roid,

li_col TYPE lvc_s_col,

lws_row_id TYPE lvc_s_roid,

lws_col_id TYPE lvc_s_col,

ls_col TYPE lvc_s_col,

ls_num TYPE lvc_s_roid.

CALL METHOD o_alvgrid->get_current_cell

IMPORTING

es_col_id = li_col

es_row_no = li_rows.

CALL METHOD o_alvgrid->get_scroll_info_via_id

IMPORTING

es_col_info = ls_col

es_row_no = ls_num.

CALL METHOD o_alvgrid->refresh_table_display.

CALL METHOD o_alvgrid->set_scroll_info_via_id

EXPORTING

is_col_info = ls_col

is_row_no = ls_num.

lws_row_id-row_id = li_rows-row_id.

lws_col_id-fieldname = li_col-fieldname.

CALL METHOD o_alvgrid->set_current_cell_via_id

EXPORTING

is_column_id = lws_col_id

is_row_no = lws_row_id.

Regards,

Prakash.

Read only

Former Member
0 Likes
697

check out if u r refreshing the ALV in the PAI

Read only

uwe_schieferstein
Active Contributor
0 Likes
697

Hello Darren

When you refresh your ALV grid (method REFRESH_TABLE_DISPLAY) set parameter IS_STABLE:

IS_STABLE-ROW = 'X'

IS_STABLE-COL = 'X'

Regards

Uwe