‎2006 Dec 18 4:23 PM
Hello all,
Just a basic one, but I need to confirm from you guys. I believe whenever we use the statement 'DELETE ADJACENT DUPLICATES FROM ITAB......' we should sort itab before that on the field we are comparing. If not the delete adjacent duplicates statement will not work correctly. Am I right?
Thanks,
‎2006 Dec 18 4:25 PM
Yes you are right.
The logic is simple, the statement DELETE ADJACENT DUPLICATES. So unless the data next to each other it cannot delete the duplicates.
Regards,
Ravi
Note - Please mark all the helpful answers
‎2006 Dec 18 4:25 PM
Yes you are right.
The logic is simple, the statement DELETE ADJACENT DUPLICATES. So unless the data next to each other it cannot delete the duplicates.
Regards,
Ravi
Note - Please mark all the helpful answers
‎2006 Dec 18 4:25 PM
‎2006 Dec 18 4:25 PM
Yes Buddy.
Always do a SORT on Itab before applying DELETE ADJASCENT DUPLICATE.
Regards,
Surya
‎2006 Dec 18 4:26 PM
Hi Somen,
You are right...
Keep cursor on Key DELETE in Se38.
Do F1 on.. Read details from SAP documentation.
Will learn more about the Options and limitations.
DELETE ADJACENT DUPLICATES FROM itab.
Extras:
1. ... COMPARING f1 f2 ...
2. ... COMPARING ALL FIELDS
Effect
Deletes adjacent duplicate entries from the internal table itab. If there are n duplicate entries in succession, the first entry is retained, and the following n-1 entries are deleted.
Two lines are regarded as duplicates if their keys are identical.
The Return Code is set as follows:
SY-SUBRC = 0:
At least one duplicate was found, and at least one entry was deleted.
SY-SUBRC = 4:
No duplicates found, no entries deleted.
Addition 1
... COMPARING f1 f2 ...
Effect
Two lines of the internal table itab are regarded as duplicates if they have identical contents in the fields f1, f2, ...
Addition 2
... COMPARING ALL FIELDS
Effect
Two lines of the internal table are regarded as duplicates if all of their field contents are identical.
Notes
The DELETE ADJACENT DUPLICATES statement works particularly well if you have sorted the internal table itab according to the fields that you want to compare when looking for duplicates. In this case, deleting adjacent duplicates is the same as deleting all duplicates. The direction of the sort is irrelevant.
If you do not know a comparison expression until runtime, you can specify it dynamically as the contents of the field name in the expression COMPARING ... (name) .... If name is empty at runtime, the comparison expression is ignored. If name contains an invalid component name, a runtime error occurs.
You can further restrict comparison expressions - both static and dynamic - by specifying offset and length.
Note
Performance:
When you delete a line of an internal table, index maintenance costs are incurred. These depend on the index of the table. The runtime is independent of the width of the table line.
Deleting a line from the middle of an internal table with 200 entries usually requires around 10 msn (standardized microseconds).
When you delete a set of entries using "DELETE itab FROM idx1 TO idx2." or "DELETE itab WHERE ...", index maintenance costs are only incurred once. This means that it is considerably more efficient than deleting entries in a LOOP.
If you want to delete adjacent duplicate entries from an internal table, use the variant " DELETE ADJACENT DUPLICATES FROM itab." instead of a LOOP construction.
Hope This helps in future.
Manish
Message was edited by:
Manish Kumar
‎2006 Dec 18 4:27 PM
From F1:
Notes
The DELETE ADJACENT DUPLICATES statement works particularly well if you
have sorted the internal table itab according to the fields that you want to compare
when looking for duplicates. In this case, deleting adjacent duplicates is the same
as deleting all duplicates. The direction of the sort is irrelevant.
Rob
‎2006 Dec 18 4:36 PM
Yes you need to Sort the itab before you use delete adjacent duplicates.
Madhu.
‎2006 Dec 18 4:39 PM