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: 

System field in internal table

former_member233090
Active Contributor
0 Kudos

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

former_member555112
Active Contributor
0 Kudos

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

4 REPLIES 4

former_member555112
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

jaideepsharma
Active Contributor
0 Kudos

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,

viquar_iqbal
Active Contributor
0 Kudos

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