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: 

sy-tabix,sy-index

Former Member
0 Kudos

what is the sy-tabix and sy-index?

7 REPLIES 7

LucianoBentiveg
Active Contributor

sy-tabix inside loop-endloop, and sy-index inside do-enddo.

Regards.

Former Member

Hi,

SY-TABIX means Table Index. This signifies the number of table index. Each row of a table has certain index or counter. The value of sy-tabix for the last entry would be equivalent to number of table entries.

SY-INDEX means the number of Iterations for a loop. bascially DO - ENDO .

SY-INDEX is not equal to SY-TABIX.

Check the belwo program

report tabix_index.

DO 100 times.

wa_tab-index = sy-index.

append wa_tab to itab.

clear wa_tab.

enddo.

loop at itab into wa_tab.

write:/1 sy-tabix.

endloop.

I hope this answers your question.

Regards,

Vara

ferry_lianto
Active Contributor

Hi,

SY-TABIX:

Current line in an internal table. With the following statements SY-TABIX is set for index tables. With hashed tables, SY-TABIX is not filled or it is set to 0.

- APPEND sets SY-TABIX to the index of the last table row, that is the total number of entries in the target table.

- COLLECT sets SY-TABIX to the index of the existing or appended table row. With hashed tables, SY-TABIX is set to 0.

- LOOP AT sets SY-TABIX to the index of the current table row at the beginning of every loop pass. After leaving a loop, SY-TABIX is set to the value it had before entering the loop. With hashed tables, SY-TABIX is set to 0.

- READ TABLE sets SY-TABIX to the index of the table row read. If no row is found with binary search while reading, SY-TABIX contains the index of the next-highest row or the total number of rows +1. If no row is found with linear search while reading, SY-TABIX is undefined.

- SEARCH itab FOR sets SY-TABIX to the index of the table row, in which the search string was found.

SY-INDEX:

SY-INDEX contains the number of loop passes in DO and WHILE loops, including the current loop pass.

Regards,

Ferry Lianto

Former Member
0 Kudos

Sy-tabix is related to internal table which provides index number of current line in loop enloop.

Sy-index is related to loops (while/endwhile, do/enddo). It provides number of current pass.

Thanks,

Santosh

Former Member
0 Kudos

What about this situation?

The LOOP statement with a WHERE condition?

Is the sy-tabix assigned the current line that match the where condition or it is only added 1 by each line which meet the condition?

0 Kudos

In case of loop at with where condition sy-tabix willl return the matching record row number in the internal table. and will not increase by 1. It will always give the matching row number of internal table.

anusurbab
Explorer
0 Kudos

Hi,

It is not added by 1 which meet the condition.

The sy-tabix will be always be assigned with the index of the table row.