‎2006 Aug 24 5:58 AM
Hi all,
I have an internal table filled with data. I need to take up a single record at a time and compare with all the other records of the internal table. This I need to do for all the records of the internal table.
Please tell me the best way of doing this.
Thx..
Paul
‎2006 Aug 24 6:02 AM
‎2006 Aug 24 6:03 AM
use
FOR All entries in ITAB1 into ITAB2.
Do not put a select query in a loop.
‎2006 Aug 24 6:03 AM
HI,
use
LOOP AT itab1.
READ table itab2 with key field1 = itab1-field1
field2 = itab1-field2.
ENDLOOP.<b>OR</b>
LOOP AT itab1.
LOOP AT itab2.
if itab1-field1 = itab2-field1 AND
itab1-field2 = itab2-field2.
endif.
ENDLOOP.
ENDLOOP.Regards,
HRA
‎2006 Aug 24 6:04 AM
Hi
i will give some sample code.
Loop at abc.
read table xys key xys-fieldname = abc-firlsname.
if sy-sybrc = 0.
do the comparision or any opration as requried.
endif.
read table lmn key lmn-fieldname = abc-firlsname.
if sy-sybrc = 0.
do the comparision or any opration as requried.
endif.
endloop
This will help
If it help you please don't forget to give ratting
with regards
Dhananjay
‎2006 Aug 24 6:05 AM
hi pradipta..
u can use READ statement.
Read table itab with key <>.
it will bring the record one by one to the work area.
Then u can process the record in this work area.
Naveen
‎2006 Aug 24 6:05 AM
Eg:
SELECT * FROM ebkn
INTO TABLE ITAB2
FOR ALL ENTRIES IN
ITAB2
WHERE (your condition).
Please reward if useful.
cheers,
‎2006 Aug 24 6:06 AM
‎2006 Aug 24 6:06 AM
Hi,
LOOP AT ITAB.
LOOP AT ITAB.
Do the comparison...
ENDLOOP.
ENDLOOP.
‎2006 Aug 24 6:09 AM
Hello,
You can either loop on internal table and do comparision. To simplify the code you can create a copy of your internal table
ITAB_COPY[] = ITAB_ORIGINAL[].
LOOP AT ITAB_ORIGINAL.
LOOP AT ITAB_COPY.
If you want to compare the whole row(all columns)
IF ITAB_COPY = ITAB_ORIGINAL.
Do what you want
ENDIF.
ENDLOOP.
ENDLOOP.
If required you can use the
READ TABLE ITAB_ORIGINAL INDIX SY-TABIX.
TO remove duplicate rows:
SORT ITAB_ORIGIBAL.
Use...DELETE ADJACENT DUPLICATE ..COMPARING <FIELDS><fields>.
Hope it helps !!
Regards,
Vishal
Rewardif helpful
‎2006 Aug 24 6:10 AM
hi,
try doing this...
sort itab1.
loop at itab2.
read table itab1 with key field1 = itab2-field1 binary search.
itab2-fld1 = itab1-fdl1.
...
...
append itab2.
endloop.
‎2006 Aug 24 8:13 AM
LOOP AT ITAB1.
v_tabix = sy-tabix.
LOOP AT ITAB1.
*--For each ITAB1 record you will be looping with all other records.
if sy-tabix = v_tabix.
continue.
*--this is the same record.no need to check this.
endif.
write your code to compare & place to any other itab
ENDLOOP.
ENDLOOP.
‎2006 Aug 24 9:00 AM
Hello
The best possible soln would depend on your detail requirement but as per the given details below can be one of the solutions.
--itab and itab1 have the same structure.
--your data is in itab.
itab1[] = itab[].
loop at itab.
clear itab1.
loop at itab1. {where condition}
--comparing the fields of itab with itab1.
endloop.
endloop.
regards
Anurag