‎2009 Oct 20 10:51 AM
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.
‎2009 Oct 20 10:58 AM
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.
‎2009 Oct 20 10:54 AM
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
‎2009 Oct 20 10:54 AM
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
‎2009 Oct 20 10:57 AM
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
‎2009 Oct 20 10:58 AM
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.
‎2009 Oct 24 4:25 PM
Take a look of this code example: http://mysapsource.com/abap-tables/how-to-retreive-data-from-to-sap-tables-into-an-internal-table