‎2009 Apr 15 5:22 PM
Hi,
Suppose my internal table ITAB has 4 fields F1 F2 F3 F4 with the following data:
F1 F2 F3 F4
1 1 1 2
2 1 1 3
3 1 1 2
1 1 1 2
then how many records are left after DELETE ADJACENT DUPLICATES FROM ITAB.
how many records are left after DELETE ADJACENT DUPLICATES FROM ITAB COMPARING F4.
is is mandatory to sort before using above statements...
Thanks
Tarun Brijwani.
‎2009 Apr 15 5:27 PM
Hi,
To delete all duplicate entries from a sorted internal table (e.g. just after SORT), you can use the
DELETE ADJACENT DUPLICATES FROM itab
statement.
You can use the COMPARING adition to limit the fields that are used to test for duplicate entries e.g.
SORT i_tab by matnr werks logort.
DELETE ADJACENT DUPLICATES FROM itab COMPARING matnr werks.
All duplicates withe same combination of matnr and werks will be deleted.
Regards
Krishna
‎2009 Apr 15 5:32 PM
‎2009 Apr 15 5:34 PM
‎2009 Apr 15 5:43 PM
>
> Sort is must before you use the Delete Adjacent Duplicate statement. With out sort you will not get the appropriate results.
Incorrect - it depends on the requirements whether and how you sort.
Rob
‎2009 Apr 15 5:53 PM
Hi YOu have to sort it first based on F4 and then apply delete adjacent duplicates. It will delete two records with the value f4 = 2 and 2 records will remain. Delete adjacenet duplicates will not work properly if you do not sort it first.
‎2009 Apr 15 6:01 PM
F1 F2 F3 F4
1 1 1 2
2 1 1 3
3 1 1 2
1 1 1 2
when you do
delete adjacent duplicates comparing F4.
this will delete the last entry.
output:
F1 F2 F3 F4
1 1 1 2
2 1 1 3
3 1 1 2
how delete adjacent duplicate works is:
it checks the entry and compares with the next entry comparing the field mentioned,
when it finds the field as same it deletes the next entry.
when it finds the entry same and deletes , it again checks the same with the next line and then continues.
If you sort your table before delete adjacent duplicates all the entries with the field mentioned as same will be deleted.
When you do sort on F4 and then delete adjacenct duplicates.
output would be as follows:
F1 F2 F3 F4
1 1 1 2
2 1 1 3
Regards,
Lalit Mohan Gupta.