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

logic

Former Member
0 Likes
890

pls give the result...

I created a internal table .. as t1 in that i appended a,b,c,d

loop at t1.

write sy-index.

write sy-tabix.

endloop.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
867

HI,

sy-tabix will give u the table index.so in ur case it is 1,2,3,4

sy-index will give u the current loop index(do,while,...).

so it will give u 0 for each time.

so ur output is:01020304

rgds,

bharat.

7 REPLIES 7
Read only

Former Member
0 Likes
868

HI,

sy-tabix will give u the table index.so in ur case it is 1,2,3,4

sy-index will give u the current loop index(do,while,...).

so it will give u 0 for each time.

so ur output is:01020304

rgds,

bharat.

Read only

Former Member
0 Likes
867

sy-index

1

2

3

4

sy-tabix

4

4

4

4

reward points if it is usefull....

Girish

Read only

Former Member
0 Likes
867

sy-tabix is 0

sy-index is no of records in the internal table (suppose if u have 5 records in the internal table then the sy-index is 5 (1 2 3 4 5)).

REMINDER: If you posted the question, please reward points for good answers*. Thanks.

Read only

Former Member
0 Likes
867

in loop at itab only sy-tabix getting incremented but in other loop like do enddo or while loop sy-index is getting incremented.

since you are using loop at itab.. so sy-tabix will get incremented from 1 to 4 because you have only 4 rows.... and sy-index is initial.

so output 01020304.

regards

shiba dutta

Read only

Former Member
0 Likes
867

HI,

Here there is differnece between sy-tabix and sy-index.

sy-tabix and sy-index will give the current loop pass value in the loop.

But here the differnece is sy-tabix must be used in the loop at - endloop only.

Sy-index must be used in the other loop like Do-Enddo.

So in your scenario you have used both sy-tabix and sy-index in loop at -endloop.

Here sy-tabix will give the current loop pass value i.e. during first loop pass it gives sy-tabix as 1 and during second loop pass it gives as 2 so on.

But here sy-index value does not change i.e.whatever the sy-index value before the loop at that will mainitan.Here let assume before loop at sy-index is 0 then after every loop pass also sy-index is 0.

So simply in your logic sy-tabix will give current loop pass value but sy-index has no effect and it does not change.

Thanks and regards,

shyla

Read only

Former Member
0 Likes
867

Hi,

output will be 0 1 0 2 0 3 0 4

bcoz sy-index is 0 and sy-tabix will change from 1-4.

also, this is my codes where i hv tried.

DATA: BEGIN OF itab occurs 0,
index type int4,
END OF itab,
wa like line of itab.

do 4 times.

wa-index = sy-index.
append wa to itab.
enddo.

loop at itab.
write: sy-index.
write: sy-tabix.

endloop.

Jogdand M B

Read only

Former Member
0 Likes
867

Hi,

loop at t1.

write sy-index.

write sy-tabix.

endloop.

Output for your program is:4, because you didn't use '/' in each write statement, so you change your program by given below

loop at t1.

write / 'index:',sy-index.

write / 'tabix:',sy-tabix.

endloop.

OUTPUT:

***********

index:0

tabix:1

index:1

tabix:2

index:2

tabix:3

index:3

tabix:4

index will start from 0 and tabix will start from 1.

IF USEFULL REWARD