Question:
Hi,
I'm trying to get all the duplicate rows from an internal table. Any help would be greatly appreciated.
Example:
Pernr rsign relat
00001 A 008
00002 A 008
00004 B 003
00005 A 002
I'm trying to get the fallowing rows. Is there anyway to get this result without going into loop.
00001 A 008
00002 A 008
Thanks,
Gandhi
Answer:
I mean duplicates means not exactly duplicates but the repeated A 0008.
00001 A 008
00002 A 008
00004 B 003
00005 A 002
00006 B 002
00007 A 003
I'm trying to get the fallowing rows. Is there anyway to get this result without going into loop.
00001 A 008
00002 A 008
Thanks,
Srini
Answer:
you could sort the table by rsign and relat... than compare a record with the previous...
Another solution that could work, using hashed tables:
You could change the structure of your table to have default keys. After that you can use
DELETE ADJACENT DUPLICATES FROM itab
Or you could DELETE ADJACENT DUPLICATES FROM itab COMPARING field1 field2 ...
Answer:
The easiest way to find out if you have duplicate entries (particularly if you want to keep them - as the OP did not mention deleting their duplicates) is to sort your table, then loop and compare. I personally do not know of a way to access a table body without looping to compare specific row values.
_________________
Kind Regards
Rosie Brent
Please remember to search the forum and check the FAQ before posting questions, thank you.
Tuly Idiot most of the time, part-time Guru
Answer:
I want to keep the duplicate rows in a table and delete the rest of the table. How Can I do that. Delete adjucent rows delete the duplicate rows but I wan to keep the duplicates. Please help..
Answer:
table1[] = table2[]
delete adjacent duplicates from table1
loop at table2
read table1 with key .... binary search
if sy-subrc = 0
clear table2-key
modify table2
endif
endloop
delete table2 where key is initial
table1[] = table2[]
_________________
Need a new tagline...