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

DELETE ADJACENT DUPLICATES

Former Member
0 Likes
540

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
Read only

Former Member
0 Likes
501

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
Read only

athavanraja
Active Contributor
0 Likes
501

sort itab by field num .

delete adjacent duplicates from itab comparing field.

Read only

Former Member
0 Likes
502

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

Read only

Former Member
0 Likes
501

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