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

sy-index sy-tabix

Former Member
34,274

can any body tell me diff bw sy-tabex and sy-index. pls

1 ACCEPTED SOLUTION
Read only

Former Member
12,671

SY-TABIX : gives the Current line of an internal table

example

SEARCH T FOR 're'.

READ TABLE T INDEX SY-TABIX.

SY-INDEX : gives the Number of loop passes.

example

DO 5 TIMES.

WRITE: SY-INDEX.

<REMOVED BY MODERATOR>

ENDDO.

Edited by: Alvaro Tejada Galindo on Feb 21, 2008 5:44 PM

SY-TABIX : gives the Current line of an internal table

example

SEARCH T FOR 're'.

READ TABLE T INDEX SY-TABIX.

SY-INDEX : gives the Number of loop passes.

example

DO 5 TIMES.

WRITE: SY-INDEX.

<REMOVED BY MODERATOR>

ENDDO.

Edited by: Alvaro Tejada Galindo on Feb 21, 2008 5:44 PM

10 REPLIES 10
Read only

Former Member
0 Likes
12,671

Hi,

SY-INDEX is used to describe the number of iteration with in the DO..ENDDO, WHILE ...ENDWHILE....

SY-TABIX is used to define the iteration with in the internal table like between LOOP AT & ENDLOOP.

Rgds,

Bujji

Read only

Former Member
12,672

SY-TABIX : gives the Current line of an internal table

example

SEARCH T FOR 're'.

READ TABLE T INDEX SY-TABIX.

SY-INDEX : gives the Number of loop passes.

example

DO 5 TIMES.

WRITE: SY-INDEX.

<REMOVED BY MODERATOR>

ENDDO.

Edited by: Alvaro Tejada Galindo on Feb 21, 2008 5:44 PM

Read only

Former Member
0 Likes
12,671

Hi Sudheer,

sy-tabix :

Sy-tabix is used to find the current line in the internal table; it’s a current line index, 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 :

SY-INDEX is the number of Iterations for a loop.

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

Regards,

Sai

Read only

Former Member
0 Likes
12,671

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.

SY-INDEX

the loop is at which index will be given by sy-index.

Read only

Former Member
0 Likes
12,671

hi,

Sy-tabix is used to find the current line in the internal table; it’s a current line index, 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 is the number of Iterations for a loop. bascially DO - ENDO .

SY-INDEX is not equal to SY-TABIX.

some more info.............

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.

Read only

Former Member
0 Likes
12,671

hi,

SY-TABIX is used as the index of an internal table, which means that each time thru the LOOP it is incremented by 1. Simularly,

SY-INDEX is incremented each time thru the loop of a DO loop. If you want to count the number of internal table records, you can use the DESCRIBE TABLE statement.

Read only

Former Member
12,671

SY-INDEX

In a loop, a statement block is executed several times in succession. There are four kinds of loops in ABAP:

Unconditional loops using the DO statement.

Conditional loops using the WHILE statement.

Loops through internal tables and extract datasets using the LOOP statement.

Loops through datasets from database tables using the SELECT statement.

This section deals with DO and WHILE loops. SELECT is an Open SQL statement, and is described in the Open SQL section. The LOOP statement is described in the sections on internal tables and extract datasets.

Unconditional Loops

To process a statement block several times unconditionally, use the following control structure:

DO [<n> TIMES] [VARYING <f> FROM <f1> NEXT <f 2>].

<Statement block>

ENDDO.

If you do not specify any additions, the statement block is repeated until it reaches a termination statement such as EXIT or STOP (see below). The system field SY-INDEX contains the number of loop passes, including the current loop pass.

SY-TABIX

You can use the LOOP statement to process special loops for any internal table.

LOOP AT <itab> <result> <condition>.

<statement block>

ENDLOOP.

This reads the lines of the table one by one as specified in the <result> part of the LOOP statement. You can then process them in the statements within the LOOP... ENDLOOP control structure. You can either run the loop for all entries in the internal table, or restrict the number of lines read by specifying a <condition>. Control level processing is allowed within the loop.

The sequence in which the lines are processed depends on the table type:

Standard tables and sorted tables

The lines are processed according to the linear index. Within the processing block, the system field SY-TABIX contains the index of the current line.

Hashed tables

As long as the table has not been sorted, the lines are processed in the order in which you added them to the table. Within the processing block, the system field SY-TABIX is always 0.

Read only

Former Member
0 Likes
12,671

Sy-tabix: NO of record in the internal table

Sy-index: index number of record which is currently executed

eg: itab contains values 1 to 10.

loop at itab into wa_itab.

write: wa_itab-field1.

endloop.

suppose if the loop is getting executed for the 3rd time, then the sy-index will store the value as 3.

read table itab into wa_itab where field1 = 3.

after execution of this statement, the value of sy-index will be 3.

Read only

Former Member
0 Likes
12,671

This message was moderated.

Read only

0 Likes
12,671

This message was moderated.