Skip to Content
avatar image
Former Member

How to set cursor at the first line in a table control?

Hi,

I have a customized infotype screen where a table control is being used to input new values.The tab control has 30 lines.Now, the problem is that when the screen is displayed, the cursor always starts at 8th or 4th line.The behaviour is not very consistent.I tried the following statement in the PBO, but no effect.

SET CURSOR FIELD P9417-ZCOUNTRY LINE 1. ( P9417-ZCOUNTRY is the name of the tab control field where i want to set the cursor ).This is the last statement in the PBO.

Can someone please tell me why still I am not able to set the cursor at the first line? I have infact noticed that , in the debugging mode , sometimes the cursor starts at the first line.Please help. Thanks

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Oct 06, 2007 at 10:37 AM

    hi.

    in SE51-> click on attributes and in <b>cursor position</b> give the field name.

    SET CURSOR FIELD P9417-ZCOUNTRY LINE 1. write this code in your report.

    ex:-

    MODULE INPUT_GET_LINES OUTPUT.

    G_INPUT_LINES = SY-LOOPC.

    set cursor FIELD 'INDT-RDSCODE' LINE SY-STEPL.

    ENDMODULE. "INPUT_get_lines OUTPUT

    regards

    prajwal.k

    Message was edited by:

    prajwal k

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 08, 2007 at 02:15 PM

    Hi Prajwal,

    Thanks a lot man...It really worked.. I just had to enter the cursor position in the attributes..in fact, no abap code is required..

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      I have got a new requirement on this now. If the table control does not have any records , then the cursor position should be on the first row.Otherwise, if it already has some records, then the cursor should be at the first empty row.I wrote the code like below.

      if sy-ucomm = 'INSERT'.

      set cursor 'P9714-ZCOUNTRY' line 1.

      else if sy-ucomm eq 'CHANGE'.

      describe table itab lines fill.

      fill = fill + 1.

      set cursor 'P9714-ZCOUNTRY' line fill.

      endif.

      I am facing a strange problem now.The table control has some 10 rows when you see the screen for the first time.If the number of records already present is less than 10, I am able to position the cursor on the first empty row.But if the number is say 15, then the cursor position goes to eighth or fourth line or sometimes the first line.

      Is there any way to display the last few records , ie, if there are 15 records , is there any way to display the last five rows when I see the screen for the first time, rather than showing the first 10 records?How can I position the cursor at the first empty row, when there are more records?

      Thanks in advance..good answers will be rewarded.

      Mahesh