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

LOOP AT AN INTERNAL TABLE

xt_inergo
Participant
0 Likes
2,657

Hi,

I have created an abap program that has an internal table. In that table I want to compare the values of one field with the values of the same field but from other records except the current one. What do I have to do?

Thanks in advanced.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,151

data: index type sy-tabix,

flag(1) type c.

itab1 = itab

loop at itab.

index = sy-tabix.

loop at itab1 where field = itab-field

if sy-tabix ne index.

flag = 'X'.

exit.

endif.

endloop.

if flag = 'X'.

*....Do your coding here.

endif.

endloop.

5 REPLIES 5
Read only

Former Member
0 Likes
1,151

1) Use meaningful subject line

2) Dont use ALL CAPS in subject line

3) Please read the forum rules before posting

4) Your question is not clear. Elaborate more

Read only

Former Member
0 Likes
1,151

Hi,

You can use the CONTROL BREAK statements and check whats happening in Debug.

ON CHANGE OF

AT NEW

Etc.

first time you hold this value in a temp variable and then you can compare

ON CHANGE OF you can clear the Temp Variable.

AT NEW just store this new value in Temp variable .

and for other loop passes you can compare the Value in Work Area with Temp Variable

Cheers

Ram

Read only

Former Member
0 Likes
1,151

Hello ,

I understand ur requirement in this way:-

U have records in one internal table,u want to loop through the table and process some changes to the fields of the record and then compare the same record in another place within the loop .

see once u modify the fields of the table then append the data or modify table command would help you to change the data in the record of internal table.

Now once you have the new record you can use read table command and read the same record with some key values present in the internal table which u r looping , example:it may be even the index also in some cases or it may be some key field.

then u have the read table workarea with modified record and loop table's work area with previous data.

thus u can now perform ur comparision easily.

thanks,

M.Naveen Kumar

Read only

Former Member
0 Likes
1,152

data: index type sy-tabix,

flag(1) type c.

itab1 = itab

loop at itab.

index = sy-tabix.

loop at itab1 where field = itab-field

if sy-tabix ne index.

flag = 'X'.

exit.

endif.

endloop.

if flag = 'X'.

*....Do your coding here.

endif.

endloop.

Read only

Former Member