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

POsitioning Cursor in Table Control

lijisusan_mathews
Active Contributor
0 Likes
1,606

Hi all,

i have a screen with a text field in the first line, then followed by a table control..I can add new values into the table control when i click the '+' button at the bottom( it is created using wizard). my requirement is that, whenever i add a new line,the cursor shud be automatically positioned in the first field of that row. I tried with set cursor field line.... but it is not working , probably because the difference in tablecontrol-current_line and actual index when scrolling happens..So the cursor is set to the text field at the top... How can i make this happen??

Suzie

1 ACCEPTED SOLUTION
Read only

christine_evans
Active Contributor
0 Likes
1,256

Should work. If you've got one existing line on screen, you click on the + button to create a new line (which will be line 2), and you then use SET CURSOR FIELD...LINE... to set FIELD to the field name and LINE to 2, the cursor should go there. In fact, I've just tried it on one of my screens and that's what it did. I'm not sure what you mean when you mention scrolling since this should only happen if you've filled up your table control and so clicking on + means that it has to display a new scren.

4 REPLIES 4
Read only

christine_evans
Active Contributor
0 Likes
1,257

Should work. If you've got one existing line on screen, you click on the + button to create a new line (which will be line 2), and you then use SET CURSOR FIELD...LINE... to set FIELD to the field name and LINE to 2, the cursor should go there. In fact, I've just tried it on one of my screens and that's what it did. I'm not sure what you mean when you mention scrolling since this should only happen if you've filled up your table control and so clicking on + means that it has to display a new scren.

Read only

0 Likes
1,256

Sorry for confusing.. ACtually i got the cursor position correctly as long as no scrollong takes place in the table, but wen the entries in the current screen are full, it will have to scroll down and then this will not work.. Please help me correct it..

Suzie

Read only

Former Member
0 Likes
1,256

hi,

try this

READ TABLE ITAB INDEX TAB_SCHEDULE-CURRENT_LINE. " ITAB is internal table in table control

DESCRIBE TABLE ITAB LINES LIN1.

IF SY-UCOMM = 'ADD' AND LIN1 = 20 "no of lines.

APPEND INITIAL LINE TO ITAB.

ENDIF.

thanks

Read only

Former Member
0 Likes
1,256

Hello Suzie,

At your SY-UCOMM value of that button ,after whose click you want you cursor to be placed on the next rows 1st field you can use:

For Eg:

To Place the cursor at the beginning of a field when selecting a line in list processing.

MOVE 'MODUS' TO F.

MOVE '1234567890' TO MODUS.

DO 10 TIMES.

NEW-LINE. POSITION SY-INDEX WRITE MODUS.

ENDDO.

AT LINE-SELECTION.

SET CURSOR FIELD F LINE SY-LILLI.

or

SET CURSOR FIELD 'MODUS' LINE SY-LILLI.

Both statements place the cursor at the beginning of the field MODUS on this line when the user double-clicks.

Like this you can do for your user command actions.

Hope it helps you.

Tnaks Mansi