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

Table control

Former Member
0 Likes
1,420

Quick question..

While looping through the records in table control, Would the TC-Current_line be same as sy-tabix of the Internal table?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,392

hi,

<b>They are not the same</b>

Reason,

Suppose say that the table control can accomodate 5 rows on screen,and internal table containes 100 records,each time the table control scrolls down TC_current_line will reset to 1 and the sy-tabix keeps on increasing

TC_CURRENT_LINE sy-tabix

1 1

2 2

3 3

4 4

5 5

1 6

2 7

3 8

4 9

and so on

19 REPLIES 19
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,392

Yes, they are.

Regards,

Rich Heilman

Read only

0 Likes
1,392

Why aren't they?

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,392

They are not same..

Read only

Former Member
0 Likes
1,392

yes it is same, provided there is no where condition

Read only

0 Likes
1,392

No where conditions..

Read only

0 Likes
1,392

If no where conditions, then I say that they would be the same.

Regards,

Rich Heilman

Read only

0 Likes
1,392

Hi

Yes they are the same, if you load whole internal table in the table control.

But the sy-tabix index is active while looping internal table, the <TABLE_CONTROL>-CURRENT_LINE while looping table control.

So in the PBO and PAI you should use <TABLE_CONTROL>-CURRENT_LINE, no SY-TABIX.

Max

Message was edited by: max bianchi

Read only

0 Likes
1,392

Think of it this way, if you were to take current_line and read the internal table you will get the row same row that would match sy-tabix if you were LOOPing at the table.

Say, that current_line is now "4" and you do a READ, you get the 4th row of the internal table.

Read table itab index tc-current_line.

Now say, that you loop at the interal table and check when sy-tabix = 4. This is the same exact row.

Loop at itab.
if sy-tabix = 4.
* do something
Endif.
Endloop.

REgards,

Rich Heilman

Read only

Former Member
0 Likes
1,392

Using sy-tabix will have problems in comparision to current_line. If we take the case of PAI, the data flows from screen table to the internal table so the current_line points to the screen table rather than the internal table.In such a case it will be more appropriate to use current_line of table control than the sy-tabix.

Read only

Former Member
0 Likes
1,393

hi,

<b>They are not the same</b>

Reason,

Suppose say that the table control can accomodate 5 rows on screen,and internal table containes 100 records,each time the table control scrolls down TC_current_line will reset to 1 and the sy-tabix keeps on increasing

TC_CURRENT_LINE sy-tabix

1 1

2 2

3 3

4 4

5 5

1 6

2 7

3 8

4 9

and so on

Read only

0 Likes
1,392

I didn't think that current_line got reset when scrolling?

Regards,

Rich Heilman

Read only

0 Likes
1,392

I am also of the opinion that current_line does not get reset while scrolling.. I know that 'Get Cursor' resets the position while scrolling..

Read only

0 Likes
1,392

Hi SSG,

Both are same.

if tc-current_line = 14 and with in the loop if you

try to acceess the record sy-tabix = 14 then you both

the records are same.

If you scroll alos it can not reset.

Thanks&Regards,

Siri.

Read only

0 Likes
1,392

Even I feel CURRENTLINE will be reset when you scroll..

vijay

Read only

0 Likes
1,392

Has anyone actually tested it? We need to make a final decision here so that we can close the post.

Regards,

Rich Heilman

Read only

0 Likes
1,392

I've just tested it, in my program, current_line is following sy-tabix, it is not getting reset to 1 when scrolling, if I page down the entire table control, current_line has the same value that sy-tabix would if I loop at the interal table.

Regards,

Rich Heilman

Read only

0 Likes
1,392

Hi

I feel While looping both works same , but if you do some change or some double click on table control

it will not refer current_line.

it will be reset to 1 after scrolling...

vijay

Read only

0 Likes
1,392

Hi Rich,

Just now I have checked in my table control.

If it is with in the loop current_line and sy-tabix

are same.

If it is outside the loop then current_line will

always refers the tc-top_line. so we can not read the

itab using tc-currnt_line. it doesnt pick up cursor

line.

Thnaks&Regards,

Siri.

Read only

0 Likes
1,392

Hi Rich

You're right, the index current_line is always link with the index (sy-tabix) of table, it won't be reset.

While looping a table control there are three index:

- SY-STEPL,

- TOP_LINE,

- CURRENT_LINE

where:

CURRENT_LINE = TOP_LINE + SY-STEPL - 1.

The values of SY-STEPL can be from 1 to N, where N is the number of rows can be displayed in TC,

TOP_LINE is the index (sy-tabix) of the record of internal table placed in the first row of tc.

So SY-STEPL'll be reset to 1 for every new scrolling, not CURRENT_LINE.

When user does a doubleclick on a record of tc, the system returns the number of record of tc, not index of internal table: i.e. the system returns SY-STEPL.

The SY-STEPL'll be reset out of LOOP/ENDLOOP of tc.

So if user does a doubleclick, the SY-TABIX has to be found out by rule above:

GET CURSOR LINE VN_LINE.

SY-TABIX = TOP_LINE + VN_LINE - 1.

READ TABLE ITAB INDEX SY-TABIX.

Max

Message was edited by: max bianchi

Message was edited by: max bianchi

Message was edited by: max bianchi