10-19-2005 4:46 PM
hi,
Please tell me how to delete the duplicate values/records from the internal table.
Code will be very helpfull.
Thanks,
Sriram.
10-19-2005 5:02 PM
SORT ITAB.
DELETE ADJACENT DUPLICATES FROM ITAB.
( Above will take the key of table as all the character fields in it and delete the rows which have duplicates comparing all the character fields ) .
Cheers.
10-19-2005 4:55 PM
Hi Sriram!
First sort your table by the relevant key:
e.g.
SORT itab_marc by matnr werks.
Then use
delete adjacent duplicates from itab_marc comparing matnr werks.
If you don't sort your table in beforehand, deleting won't work correct. First entry of a sequence will be left in the table.
Regards,
Christian
10-19-2005 5:02 PM
SORT ITAB.
DELETE ADJACENT DUPLICATES FROM ITAB.
( Above will take the key of table as all the character fields in it and delete the rows which have duplicates comparing all the character fields ) .
Cheers.
10-19-2005 5:07 PM
If want to delete duplicate rows based on duplicate values in only certain fields, then sort itab by those fields and then use COMPARING field1 field2 etc.
SORT itab BY field1 fiel2.
DELETE ADJACENT DUPLICATES FROM itab COMPARING field1 field2.
Srinivas
10-19-2005 5:34 PM
10-19-2005 5:37 PM
Hi sriram,
check this link for further details....
http://help.sap.com/saphelp_erp2004/helpdata/en/06/aafd54fc4011d195280000e8353423/frameset.htm
regards,
venu.
11-03-2005 9:56 AM
I need to delete duplicate entries, but not, if the compared field is initial.
Any ideas?
Best regards
Norbert
11-03-2005 10:08 AM
Hi,
change your field , which is initial.
loop at itab where f1 = space.
add 1 to counter.
*enumerate
move counter to itab-f1.
modify ...
after delete:
loop at itab where f1 between 1 and counter.
clear itab-f1.
...
Andreas
11-03-2005 10:30 AM
Thanks Andreas!
In the meantime I got the idea to split the table into two, delete the duplicates in the table without initials and merge them after the deletion.
I'm not sure what has better performance.
Any other ideas or knowledge about performance in this case?
Best regards
Norbert
11-03-2005 1:07 PM
... regarding performance, the use of field-symbols is a must!
You may use <fs> type any. <fs> type (your table structure) is even faster:
field-symbols:
<fs> type line of itab.
loop at itab assigning <fs>.
where xfield is initial. "if desired
<fs>-xfield = count.
add 1 to count.
endloop." at itab assigning <fs>.
...
something like this...
C.