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

System field in internal table

Former Member
0 Likes
1,210

Hi,

I have a program where iam appending data in to the internal table .

DATA : BEGIN OF ITAB OCCURS 10,

A TYPE I,

B TYPE I,

END OF ITAB.

DO 5 TIMES.

ITAB-A = SY-INDEX.

ITAB-B = SY-INDEX * 10.

APPEND ITAB. * COMMENTS FROM HEADER LINE ARE APPENDED TO THE BODY

ENDDO.

WRITE : / ITAB-A,ITAB-B. OUTPUT TILL HERE IS 5 50 ( WHERE SY-INDEX = 5)

SKIP.

LOOP AT ITAB[] INTO ITAB.

WRITE : / ITAB-A,ITAB-B.

ENDLOOP.

My question is what happen to the values of , and how?

SY-INDEX

SY-TABIX

SY-FILL.

With regards

Bhavana

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
968

HI,

SY-INDEX will be incremented within a DO-END or WHILE-ENDWHILE.

SY-TABIX will be incremented whenever an internal table is looped upon using LOOP statement.

Also when any particular row of an internal table is read successfully using READ statement; then SY-TABIX will hold the row number.

Regards,

Ankur Parab

Hi,

I have a program where iam appending data in to the internal table .

DATA : BEGIN OF ITAB OCCURS 10,

A TYPE I,

B TYPE I,

END OF ITAB.

DO 5 TIMES.

ITAB-A = SY-INDEX.

ITAB-B = SY-INDEX * 10.

APPEND ITAB. * COMMENTS FROM HEADER LINE ARE APPENDED TO THE BODY

ENDDO.

WRITE : / ITAB-A,ITAB-B. OUTPUT TILL HERE IS 5 50 ( WHERE SY-INDEX = 5)

SKIP.

LOOP AT ITAB[] INTO ITAB.

WRITE : / ITAB-A,ITAB-B.

ENDLOOP.

My question is what happen to the values of , and how?

SY-INDEX

SY-TABIX

SY-FILL.

With regards

Bhavana

4 REPLIES 4
Read only

Former Member
0 Likes
969

HI,

SY-INDEX will be incremented within a DO-END or WHILE-ENDWHILE.

SY-TABIX will be incremented whenever an internal table is looped upon using LOOP statement.

Also when any particular row of an internal table is read successfully using READ statement; then SY-TABIX will hold the row number.

Regards,

Ankur Parab

Read only

Former Member
0 Likes
968

When you use SY-INDEX in DO loop it increses as follows

Do Loop - Sy-index will increse by 1 in each loop.

LOOP AT ITAB. - SY_TABIX will increase by 1 in each loop.

So use SY-INDEX in DO LOOP and SY-TABIX IN looping internal table.

Read only

jaideepsharma
Active Contributor
0 Likes
968

Hi,

After the execution of loop used for printing the lines of internal table values of SY-TABIX will change while that of SY-TFILL and SY-INDEX will remain same as before.

KR Jaideep,

Read only

viquar_iqbal
Active Contributor
0 Likes
968

Hi

it would display the values from 1-10 ,2-20,........

SY-TABIX : used for record count of internal tables.

SY-INDEX : used for loop counter.

SY-TFILL contains the number of lines in the relevant internal table.

You can get more information at

[SYSTEMFIELDS|http://help.sap.com/saphelp_nw70/helpdata/en/7b/fb96c8882811d295a90000e8353423/content.htm]

Thanks

Viquar Iqbal