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

Internal tables

Former Member
0 Likes
670

what is the difference between sy-index and sy-tabix?can any one provide me with some points on this ?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
649

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.

Reward all helpful answers,

Regards,

Omakr.

6 REPLIES 6
Read only

Former Member
0 Likes
650

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.

Reward all helpful answers,

Regards,

Omakr.

Read only

Former Member
0 Likes
649

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.

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.

Message was edited by:

Roja Velagapudi

Read only

Former Member
0 Likes
649

Hi,

if you are using a internal table within loop, then sy-tabix wil return the current record number of the internal table.

sy-index wil return the current loop index.

Regards,

Niyaz

Read only

Former Member
0 Likes
649

Hi,

SY-TABIX - Current line of an internal table. SY-TABIX is set by the statements below, but only for index tables. The field is either not set or is set to 0 for hashed tables.

APPEND sets SY-TABIX to the index of the last line of the table, that is, it contains the overall number of entries in the table.

COLLECT sets SY-TABIX to the index of the existing or inserted line in the table. If the table has the type HASHED TABLE, SY-TABIX is set to 0.

LOOP AT sets SY-TABIX to the index of the current line at the beginning of each loop lass. At the end of the loop, SY-TABIX is reset to the value that it had before entering the loop. It is set to 0 if the table has the type HASHED TABLE.

READ TABLE sets SY-TABIX to the index of the table line read. If you use a binary search, and the system does not find a line, SY-TABIX contains the total number of lines, or one more than the total number of lines. SY-INDEX is undefined if a linear search fails to return an entry.

SEARCH <itab> FOR sets SY-TABIX to the index of the table line in which the search string is found.

SY_INDEX - In a DO or WHILE loop, SY-INDEX contains the number of loop passes including the current pass.

Hope it was useful.

Thanks,

Sandeep.

Read only

Former Member
0 Likes
649

Hi,

SY-INDEX

In a DO or WHILE loop, SY-INDEX contains the number of loop passes including the current pass.

SY-TABIX

Current line of an internal table. SY-TABIX is set by the statements below, but only for index tables. The field is either not set or is set to 0 for hashed tables.

-APPEND sets SY-TABIX to the index of the last line of the table, that is, it contains the overall number of entries in the table.

-COLLECT sets SY-TABIX to the index of the existing or inserted line in the table. If the table has the type HASHED TABLE, SY-TABIX is set to 0.

-LOOP AT sets SY-TABIX to the index of the current line at the beginning of each loop lass. At the end of the loop, SY-TABIX is reset to the value that it had before entering the loop. It is set to 0 if the table has the type HASHED TABLE.

-READ TABLE sets SY-TABIX to the index of the table line read. If you use a binary search, and the system does not find a line, SY-TABIX contains the total number of lines, or one more than the total number of lines. SY-INDEX is undefined if a linear search fails to return an entry.

-SEARCH <itab> FOR sets SY-TABIX to the index of the table line in which the search string is found.

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

Reward if useful

Thanks

Read only

Former Member
0 Likes
649

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.