‎2007 Jun 22 8:07 AM
What is the Diffrence between these two?
SORT it_itab.
DELETE adjacent duplicates FROM it_itab COMPARING ALL FIELDS.
SORT it_itab.
DELETE adjacent duplicates FROM it_itab.
Regards,
Ram.
‎2007 Jun 22 8:10 AM
Hi
No difference both are same
Reward points for useful Answers
Regards
Anji
‎2007 Jun 22 8:10 AM
Hi Ramganesan
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.
Reward all helpfull answers
Regards
Pavan
‎2007 Jun 22 8:11 AM
‎2007 Jun 22 8:13 AM
they are the same...
u need to specify key fields to delete duplicate records...
then there will be a difference
‎2007 Jun 22 8:14 AM
Hi,
I dont think they are same.
I think here is the difference
SORT it_itab.
DELETE adjacent duplicates FROM it_itab COMPARING ALL FIELDS.
If you give COMPARING ALL FIELDS, all the fields of the internal table is compared and upon finding identical entries, they are deleted.
SORT it_itab.
DELETE adjacent duplicates FROM it_itab.
By omitting it, only the key fields of the internal table are compared and upon finding identical entries, they are deleted.
Reward if useful.
Suruchi
‎2007 Jun 22 8:19 AM
Hi Ramganesan ,
My understanding is that DELETE adjacent duplicates deletes records which have the same key feild , it is not necessary that the other feilds also need to be the same.
Where as DELETE adjacent duplicates FROM it_itab COMPARING ALL FIELDS will delete records only if all the feilds are the same.
This diffrence comes into picture when you specify the key feilds of the internal table.
Here is a sample code as an eg.
Types : Begin of it_1 ,
test1(2) ,
test2(2) ,
End of it_1.
Data : it_2 type table of it_1 with key test1 ,
IT_3 type table of it_1 with key test1.
data : wa_1 type it_1.
wa_1-test1 = 'A'.
wa_1-test2 = 'B'.
APPEND WA_1 TO IT_2.
wa_1-test1 = 'A'.
wa_1-test2 = 'C'.
APPEND WA_1 TO IT_2.
wa_1-test1 = 'A'.
wa_1-test2 = 'D'.
APPEND WA_1 TO IT_2.
IT_3 = IT_2.
DELETE adjacent duplicates FROM it_2.
DELETE adjacent duplicates FROM it_3 COMPARING ALL FIELDS.
BREAK-POINT
Hope this clears your doubt.
Regards
Arun
‎2007 Jun 22 8:31 AM
Thank You,
I Wish to delete the replicated entries from the table . Which one of the way is
suitable ?
‎2007 Jun 22 9:04 AM
Hi ,
If you have not specified any key when you declared you internal table then you can use any one it will give the same result.
Where as if you have mentioned a key for the internal table when use COMPARING ALL FIELDS.
Regards
Arun
‎2007 Jun 22 8:35 AM
Hi Ramaganesan
I prefer u
DELETE adjacent duplicates FROM it_itab.Reward all helpfull answers
Regards
Pavan
‎2007 Jun 22 8:47 AM
Hi.
If you want delete only Duplicate Entries use
DELETE adjacent duplicates FROM it_itab.
Reward all helpfull answers.
Regards.
Jay