Application Development 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: 

set cursor alv grid (not using objects)

Former Member
0 Kudos

I got a question on ALV GRID (not using objects), please let me know if you have pointers. Thanks.

Output has 2 screens both has different contents. The output is generated using internal table1 and 2 and using FM 'REUSE_ALV_GRID_DISPLAY_LVC' (both screen use same FM).

First screen has multiple pages of output (say 10 pages). User scrolled page 5 and line 10 of first screen and then double clicked it takes to screen #2. After completion of screen #2, the back arrow should get back to page 5 and line 10 of screen #1. Currently the back arrow gets to screen#1 page 1 and line 1. How to remember the cursor position in alv grid and instruct the cursor to go there?

Appreciate the input.

Note: I tried "set cursor line n" with "Scroll" command but no luck. http://help.sap.com/saphelp_nw70/helpdata/EN/9f/dba47e35c111d1829f0000e829fbfe/content.htm

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Ravi,

by using below syntax you can catch the line selected..


* getting the cursor line in Alv Grid
  GET CURSOR FIELD selfield LINE selline.
  selindex = t_output-top_line + selline - 1.

Regards,

Prabhudas

2 REPLIES 2

Former Member
0 Kudos

Hi Ravi,

by using below syntax you can catch the line selected..


* getting the cursor line in Alv Grid
  GET CURSOR FIELD selfield LINE selline.
  selindex = t_output-top_line + selline - 1.

Regards,

Prabhudas

0 Kudos

Thanks for the inputs.

FYI, I got it implemented using method CALL METHOD <ref.var. to CL_GUI_ALV_GRID > ->set_current_cell_via_id

The method is called by 'REUSE_ALV_GRID_DISPLAY_LVC' form 'PF_STATUS_SET' when the ALV grid output is presented each time.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

EXPORTING

i_bypassing_buffer = 'X'

i_callback_program = gc_repid

i_callback_pf_status_set = 'PF_STATUS_SET'

i_callback_user_command = 'USER_COMMAND'

is_layout_lvc = lwa_layout

it_fieldcat_lvc = git_fc_lvc

i_default = ' '

TABLES

t_outtab = git_data

EXCEPTIONS

program_error = 1

OTHERS = 2.

.....

FORM alv_event_pf_status_set USING rt_extab

TYPE slis_t_extab.

DATA lo_ref1 TYPE REF TO cl_gui_alv_grid.

*Get the reference to class "lo_ref1" for the ALV report

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = lo_ref1.

*set the focus of cursor in ALV

CALL METHOD lo_ref1->set_current_cell_via_id

EXPORTING

is_row_no = gv_row. "row number where you want to focus the cursor

....

ENDFORM.