Application Development 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: 

Sort before delete adjacent

Former Member
0 Kudos
1,087

Hi,

I have a requirement for delete adjacent records,

DELETE ADJACENT DUPLICATES FROM IT_OPSALES COMPARING BUKRS ENAME NAME1 BSTKD VBELN AUDAT POSNR MATNR .

Is it mandatory to sort internal table before delete adjacent ??

regards

Mark

1 ACCEPTED SOLUTION

Former Member
0 Kudos
356

Hi,

Yes Mark, It is mandatory to sort before deleting adjacent records, or else the system compares only with adjacent records. If the adjacent is not found as same ,it wont be deleted. At the end of all, the duplicate will still exists after deletion.

regards

Jijo

11 REPLIES 11

Former Member
0 Kudos
356

Hi Mark,

It is very compulsory to sort the table when you use the statement DELETE ADJACENT DUPLICATES. Because it checks if the adjacent record is similar . If it is similar it will delete else it will not delete. So it is compulsory to sort in order to get the appropriate output.

Regards,

Swapna.

Former Member
0 Kudos
356

hi,

Yes sort it on BUKRS ENAME NAME1 BSTKD VBELN AUDAT POSNR MATNR fields ...

i.e,


sort IT_OPSALES  by BUKRS ENAME NAME1 BSTKD VBELN AUDAT POSNR MATNR.

bpawanchand
Active Contributor
0 Kudos
356

Hi

Yes it is Mandatory to sort the internal table because as soon as you sort the Table all the SAME entries come Adjacent to each other so there after your statement works properly

Regards

Pavan

Former Member
0 Kudos
356

Hi,

Yes , It is mandetory.

For detail please check

http://help.sap.com/saphelp_nw04/Helpdata/EN/06/aafd54fc4011d195280000e8353423/content.htm

Regards,

Anirban

Former Member
0 Kudos
356

Hi Mark,

Yes Mark, it always better to SORT the internal table before you use DELETE ADJECENT DUPLICATES..

Best regards,

raam

Former Member
0 Kudos
356

Hi,

yes sorting is mandatory.

after sorting only u can do the delete adjacent duplicates.

when we sort all the data which are same come one after one so u can delete the adjacent duplicate data.

Former Member
0 Kudos
356

Hi,

After selecting the data into internal table. first we have to sort that internal table and use delete adjacent.

example:

select * from zse_role into itab_role.

sort itab_role by i_rolecd.

delete adjacent duplicates from itab_role.

Cheers,

vasavi.v

Former Member
0 Kudos
357

Hi,

Yes Mark, It is mandatory to sort before deleting adjacent records, or else the system compares only with adjacent records. If the adjacent is not found as same ,it wont be deleted. At the end of all, the duplicate will still exists after deletion.

regards

Jijo

Former Member
0 Kudos
356

Hi Mark,

You need to definitely SORT before using DELETE ADJACENT DUPLICATES

As you are using COMPARING in delete with some fields you need to SORT the table with those fields.

Regards,

Chandra Sekhar

Former Member
0 Kudos
356

hi

let us we have an table with following record in itab1

F1 F2 F3 F4

a b c d

c x y z

a b d e

c x y h

now here if i apply

DELETE ADJACENT DUPLICATES FROM ITAB1 COMPARING F1 F2 .

here no record wil be deleteted

but if u sort the itab1

and then apply

DELETE ADJACENT DUPLICATES FROM ITAB1 COMPARING F1 F2 .

u have only two record

spo it is always recomended to apply sort defore delete adjacent

Cheers

Snehi

Former Member
0 Kudos
356

as all have said you should always sort the internal table before using DELETE ADJACENT DUPLICATES, as otherwise you may not get the appropriate result you want, if the table is not sorted then after using DELETE ADJACENT DUPLICATES also there might be duplicate records left, so to be sure that all the duplicate records have been deleted you should use sort.

With regards,

Pritam