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: 

DELETE ADJACENT DUPLICATES

Former Member
0 Kudos

hallow

i wont to delete appearance in table of mine when data appear more then one time

example

itab before

<b>field num</b>

100 aa

100 bb

200 cc

200 dd

itab after

<b>field num</b>

100 aa

200 cc

<b>i reward</b>

regars

i try with

DELETE ADJACENT DUPLICATES FROM itab

but its not working

Regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Check the below program :

data : begin of itab occurs 0,

num(3) type n,

fld(4) type c,

end of itab.

start-of-selection.

itab-num = '100'.

itab-fld = 'aa'.

append itab.

itab-num = '100'.

itab-fld = 'bb'.

append itab.

itab-num = '200'.

itab-fld = 'cc'.

append itab.

itab-num = '200'.

itab-fld = 'dd'.

append itab.

DELETE ADJACENT DUPLICATES FROM itab comparing num.

loop at itab.

write:/ itab-num,itab-fld.

endloop.

Thanks

Seshu

3 REPLIES 3

athavanraja
Active Contributor
0 Kudos

sort itab by field num .

delete adjacent duplicates from itab comparing field.

Former Member
0 Kudos

Check the below program :

data : begin of itab occurs 0,

num(3) type n,

fld(4) type c,

end of itab.

start-of-selection.

itab-num = '100'.

itab-fld = 'aa'.

append itab.

itab-num = '100'.

itab-fld = 'bb'.

append itab.

itab-num = '200'.

itab-fld = 'cc'.

append itab.

itab-num = '200'.

itab-fld = 'dd'.

append itab.

DELETE ADJACENT DUPLICATES FROM itab comparing num.

loop at itab.

write:/ itab-num,itab-fld.

endloop.

Thanks

Seshu

Former Member
0 Kudos

Small modification in code and i forgot to keep sort command.

Check the below program :

data : begin of itab occurs 0,

num(3) type n,

fld(4) type c,

end of itab.

start-of-selection.

itab-num = '100'.

itab-fld = 'aa'.

append itab.

itab-num = '100'.

itab-fld = 'bb'.

append itab.

itab-num = '200'.

itab-fld = 'cc'.

append itab.

itab-num = '200'.

itab-fld = 'dd'.

append itab.

<b>sort itab by num fld.</b>

DELETE ADJACENT DUPLICATES FROM itab comparing num.

loop at itab.

write:/ itab-num,itab-fld.

endloop.

Thanks

Seshu