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: 

Problem with set cursor in table control

Former Member
0 Kudos
1,052

Hi,

Iam getting problem with set cursor in table control.

initially iam displaying 6 lines in table control. in PAI i wrote set cursor field lines ..

For first 6 lines it is setting thr cursor correctly.

After filling the 6 lines it is setting the cursor to other fields(In Header Field).

How to set the cursor .

i have to code any page down are something.. give any idea about this problem..

Thanks,

Venkat.

20 REPLIES 20

brad_bohn
Active Contributor
0 Kudos
254

As a general rule of thumb, set your cursor and any other output related information in PBO. Where is the cursor supposed to go if all 6 lines are filled? Did you want to set it to an empty line? Have you set the TOP_LINE property of your table control properly? How about some code?

Former Member
0 Kudos
254

Hi Brad,

After completing the 6 lines my table control has to go down and the cuesor should be on 7th line.

How to code this scwnario.

Thanks,

Venkat.

0 Kudos
254

Hi,

After the no of visible lines are done, the table control generally behaves like this.

To get your desired output, you will have to Manually trigger the

Page down function and then set the cursor to the desired line.

Are you using the table control to add data to some table?

Suzie

Former Member
0 Kudos
254

Hi,

Iam using the table control to add some line items to a table.

How to Trigger Page down Manually.

Thanks,

Venkat.

0 Kudos
254

Hi Venkatesh,

In PAI you will use following to get the Position of Cursor

GET CURSOR FIELD field LINE line OFFSET offset.

Now when you will add some new line in table control add 1 to Line, in PBO like below.

ADD 1 TO line.
SET CURSOR FIELD field LINE line OFFSET offset.

Hope you got it, Please Reply if any confusion.

Thanks and Regards,

Faisal

Former Member
0 Kudos
254

Hi Faisal,

Already iam adding 1 to lines . it is working properly for the first 6 lines.

After completing the six rows it has to pagedoen and then cursor should be in 7th line.But after completing 6lines cursor is in first row itself.

I hope you understand clearly.

Thanks,

Venkat.

0 Kudos
254

Hi Venkat,

If you created your table control using wizard and you also selected scrolling buttons than you can test below code.

ADD 1 TO line.
PERFORM compute_scrolling_in_tc USING 'TC_TEST' 'P+'.
SET CURSOR FIELD field LINE line OFFSET offset.

In above code replace TC_TEST with your Table Control Name.

Thanks and Regards,

Faisal

0 Kudos
254

Are you using Table control wizard ?

Former Member
0 Kudos
254

Hi,

yes iam using table control wizard.

Thanks,

Venkat.

Former Member
0 Kudos
254

Hi Faisal,

I used your code. it is scrolling down correctly.But cursor is not setting correctly in the next line.

Thanks,

Venkat.

0 Kudos
254

if yes, trigger the P+ function as mentioned above.

And then, set the cursor to the first line as you would have done now.

Otherwise,

try the following:

get the line no you are currently on. And when the Add button is pressed, check if the current line no is 6( max tabcontrol lines). If it is 6, add a blank row into your table. Now you will be able to set the cursor to this row, in the PBO if you display the last 6 lines.

Hope i dint confuse you..

Suzie

0 Kudos
254

Hi Venkat,

Follow the steps below.

1.

DATA: next_page  TYPE c LENGTH 1.

2. In PAI just before getting courser position write following code

IF sy-ucomm = 'TC_TEST_INSR'. " This can be change in your case have to replace TC_TEST with your Table Control Name
    next_page = 'X'.
ENDIF.

3. In PBO Just before setting courser position write below code

IF next_page = 'X'.
    ADD 1 TO line.
    PERFORM compute_scrolling_in_tc USING 'TC_TEST' 'P+'. " Replace TC_TEST with your Table Control Name
    CLEAR next_page.
ENDIF.

4. Copy STD PERFORM (fcode_insert_row) Change name to zfcode_insert_row and change below line.

*&SPWIZARD: get current line                                           *
  GET CURSOR LINE l_selline.
  IF sy-subrc NE 0.                   " append line to table " Change this NE sign with EQ = sign

I am doing same and it is working fine for me, Please reply in case of any confusion.

Thanks and Best Regards,

Faisal

Former Member
0 Kudos
254

HI Faisal,

Thanks for your quick reply. All are working correctly. But the cursor is not going to the next line when iam doing page down.

Thanks,

Venkat.

0 Kudos
254

Hi Venkat,

As I think your module where you are using SET COURSOR is before the modules of table control. This module must be at the end in the flow logice of your screen in PBO and the very first in PAI where you are using GET COURSOR , hope youu understand, please reply if you still have issue.

Thanks and Best Regards,

Faisal

Edited by: Faisal Altaf on Mar 22, 2011 1:51 PM

Former Member
0 Kudos
254

Hi

You should write code for it.

See my previous answer. it will work

With regards,

aahbha

Former Member
0 Kudos
254

Hi,

See my code if any wrong is there suggest me.

*PBO

After Table control loop.

MODULE set_cursor.

MODULE set_cursor OUTPUT.

DESCRIBE TABLE it_item LINES tctrl-lines.

l_lin = tctrl-lines + 1.

SET CURSOR FIELD 'WA_ITEM-ITEM_CODE' LINE l_lin.

endmodule.

Thanks,

Venkat.

Edited by: Venkatesh Kolluru on Mar 22, 2011 10:01 AM

Former Member
0 Kudos
254

Hi venkat,

Please do the following,

PROCESS BEFORE OUTPUT.

MODULE STATUS_9400.

MODULE SETTABLECONTROLS.

loop at t_bank into zbanksel WITH CONTROL tbl1.

endloop.

loop at t_card into ZCARDSEL WITH CONTROL tbl2.

endloop.

Module SETCURSOR.

&----


*& Module SETTABLECONTROLS OUTPUT

&----


  • text

----


MODULE settablecontrols OUTPUT.

IF v_code = 'INSERT'.

DESCRIBE TABLE t_bank LINES tbl1-top_line.

ENDIF.

tbl1-lines = tbl1-top_line + 3.

ENDMODULE. " SETTABLECONTROLS OUTPUT

&----


*& Module SETCURSOR OUTPUT

&----


  • text

----


MODULE setcursor OUTPUT.

IF v_code = 'INSERT'.

SET CURSOR FIELD 'ZBANKSEL-BCOUNTRY' LINE 2.

CLEAR v_code.

ENDIF.

ENDMODULE. " SETCURSOR OUTPUT

do this and reply me

0 Kudos
254

Hey.. Wen u reach the PBO, your internal table must be having a new blank line right? In that case, U dont need to use l_lins + 1.

And if its still not working,

There should be a module woth a line ( for wizard code) which sets the top-line set teh top_line number to current internal tbale line index and see.

Suzie

Former Member
0 Kudos
254

Hi Venkatesh,

DESCRIBE TABLE <internal table name> lines tc_scarr-top_line. " tc_scarr name of table control

This will place the cursor always pointing towards the first line of the table control by default. Please check with this..

thanks.

Sri Hari Anand Kumar

Former Member
0 Kudos
254

Try this,

@ PBO.

IF v_code = 'INSERT'.

DESCRIBE TABLE t_bank LINES tbl1-top_line.

ENDIF.

tbl1-lines = tbl1-top_line + 6.

IF v_code = 'INSERT'.

SET CURSOR FIELD 'ZBANKSEL-BCOUNTRY' LINE 2.

CLEAR v_code.

Try this logic.

initially through the module pool screen, make your table control to display as you like ie., How much row to be displayed.

Enjoy!!

with regards,

aahbha.