Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Difference

Former Member
0 Likes
1,046

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.

10 REPLIES 10
Read only

Former Member
0 Likes
1,028

Hi

No difference both are same

Reward points for useful Answers

Regards

Anji

Read only

Former Member
0 Likes
1,028

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

Read only

Former Member
0 Likes
1,028

Hi,

two are similar.

Thanks,

Anitha

Read only

Former Member
0 Likes
1,028

they are the same...

u need to specify key fields to delete duplicate records...

then there will be a difference

Read only

Former Member
0 Likes
1,028

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

Read only

Former Member
0 Likes
1,028

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

Read only

0 Likes
1,028

Thank You,

I Wish to delete the replicated entries from the table . Which one of the way is

suitable ?

Read only

0 Likes
1,028

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

Read only

Former Member
0 Likes
1,028

Hi Ramaganesan

I prefer u

DELETE adjacent duplicates FROM it_itab.

Reward all helpfull answers

Regards

Pavan

Read only

Former Member
0 Likes
1,028

Hi.

If you want delete only Duplicate Entries use

DELETE adjacent duplicates FROM it_itab.

Reward all helpfull answers.

Regards.

Jay