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: 

difference between sy-index & sy-tabix

Former Member
0 Kudos
2,174

Dear friends,

Please tell me the difference between sy-index & sy-tabix

Actually my problem is i don't know how to compare for example between first record'field n and second record'field n when u r in loop so i can take particular action based on result

on current recor

if possible send me sample code.

Regards;

Parag Gavkar.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
258

Hi,

sy-index will give u the number of iteration in the loop.

sy-tabix will give u the number rows filled in an internal table at the moment.

rgds,

bharat.

14 REPLIES 14

Former Member
0 Kudos
259

Hi,

sy-index will give u the number of iteration in the loop.

sy-tabix will give u the number rows filled in an internal table at the moment.

rgds,

bharat.

Former Member
0 Kudos
258

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 - ENDDO .

SY-INDEX is not equal to SY-TABIX.

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

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.

~~Guduri

Former Member
0 Kudos
258

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.

****DO REWARDS IF USEFULL

REGARDS,

VIJAY

Former Member
0 Kudos
258

Hi,

SY-INDEX will work for DO..ENDDO..It holds the current row number within the loop..

DO 10 TIMES.

WRITE: / SY-INDEX.

ENDDO.

SY-TABIX will work for LOOP..ENDLOOP...It holds the current row within the loop..

Thanks,

Naren

Former Member
0 Kudos
258

Hi

sy-index = gives the number of iterations in the loop.

sy-tabix = will give the Table Index of an internal table at that moment.

Reward points if useful

Regards

Anji

Former Member
258

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,

Santosh

Former Member
0 Kudos
258

Hi,

Sy-index - > give the index of the record in the loop.,

sy-tabix - > give the number of iterations in a loop.

Reward points if it is helpful.

Regards,

Sangeetha.a

Former Member
0 Kudos
258

Hi Parag,

Check this Link,

https://forums.sdn.sap.com/click.jspa?searchID=2863826&messageID=2868547

Thanks,

Reward If Helpful.

Former Member
0 Kudos
258
sy-index is used in do..enddo ,  and other loops

sy-tabix is used when looping at internal tables

loop at itab.
 v_tabix = sy-tabix.
 v_tabix = v_tabix + 1.
 read table itab index v_tabix.   " to read the next record
 *do the calculations herw
 endloop.

Former Member
0 Kudos
258

Hi,

Sy-index is related to the loop,It's represents the Current loop pass.(Do ,While)

Sy-tabix is related to the internal table.it represents current line index.(Looping thru itab affects sy-tabix)

sreeramkumar_madisetty
Active Contributor
0 Kudos
258

Hi Parag

SY-INDEX will work for DO..ENDDO..It holds the current row number within the loop..

DO 10 TIMES.

WRITE: / SY-INDEX.

ENDDO.

SY-TABIX will work for LOOP..ENDLOOP...It holds the current row within the loop

Regards,

Sree

Former Member
0 Kudos
258

hi,

sy-index is used in do..enddo , and other loops and also used as current index of the list.

sy-tabix is used when looping at internal tables for getting index of the internal table.

if helpfulreward some points.

with regards,

suresh babu aluri.

Former Member
0 Kudos
258

hi parag,

if it's sy-index that we can use in read statement,

or if it's sy-tabix that we can use in loop statement, this can help u to know which record(no) is processing in the loop.

regards,

seshu.

Former Member
0 Kudos
258

Hi

SY-INDEX - > It is ABAP System field, Initial value will be zero, but when u place in do loop and while loop it is incremented by 1.

example

do 5 times.

write : sy-index.

enddo.

o/p will be 1 2 3 4 5

SY-TABIX - > Current Line of Internal Table

Regards

Vijaya