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

problem in delete adjecent duplicates

Former Member
0 Likes
3,015

Hi All,

i have a problem in delete adjacent duplicate in an internal table .

when i use it i want that the records which are getting doubled to be removed

but i also want that if the value in that field is empty for which i am comparing , to be ignored means i dont want the records

to be deleted in which the field value is empty for which i am comparing.

snippet of my code

delete ADJACENT DUPLICATES FROM xkomv COMPARING KSCHL.

so if theere is no value in KSCHL THAT RECORD NOT TO BE DELETED .

waiting for your reply..

Thanks in advance

Hi All,

i have a problem in delete adjacent duplicate in an internal table .

when i use it i want that the records which are getting doubled to be removed

but i also want that if the value in that field is empty for which i am comparing , to be ignored means i dont want the records

to be deleted in which the field value is empty for which i am comparing.

snippet of my code

delete ADJACENT DUPLICATES FROM xkomv COMPARING KSCHL.

so if theere is no value in KSCHL THAT RECORD NOT TO BE DELETED .

waiting for your reply..

Thanks in advance

13 REPLIES 13
Read only

GauthamV
Active Contributor
0 Likes
2,097

Try something like this.


If not xkomv-kschl is initial.
Delete ADJACENT DUPLICATES FROM xkomv COMPARING KSCHL.
endif.

Read only

Former Member
0 Likes
2,097

pass the empty values to another (new) iternal table.

loop at it_1 where my_field = ''.
move-corresponding it_1 to it_2.
append it_2.
endloop.

now delete adjecent duplicates in it_1.

then append it_1 to it_2.

Read only

0 Likes
2,097

thanks for the reply i could have applied the loop but i am writing this code in a routine ..

so i m not sure how to use this here ..

Read only

Former Member
0 Likes
2,097

hi,

DELETE ADJACENT DUPLICATES FROM it_t001_kkber COMPARING kkber.

DELETE it_t001_kkber WHERE kkber = space.

thanks

Read only

former_member194669
Active Contributor
0 Likes
2,097

Then you need to use


itab_1[] = itab[].
delete itab_1 where kschl ne space.
delete itab where kschl eq space.
sort itab by kschl
delete adjacent duplicates from itab comparing kschl.
append lines of itab_1 into itab.

Read only

Former Member
0 Likes
2,097

Hi,

You need to take your records in another internal table. Now from this table delete the records for which KSCHL NE Space. ( Say ITAB1). And from the other table delete the records where KSCHL eq SPACE. ( Say ITAB2). Now on ITAB2 use Delete Adjacant Duplicates statement. Now appendrecords of one table to the other.

This should meet your requirement.

Regards,

Lalit

Read only

Former Member
0 Likes
2,097

Try the following,

"delete ADJACENT DUPLICATES FROM xkomv COMPARING KSCHL.

Before using the above statement do the following,

u201C decalare a temporary table for u2018xkomvu2019 say u2018t_xkomvu2019, and copy the data.

Refresh t_xkomv[].

t_xkomv[] = xkomv[].

Delete t_xkomv where KSCHL <> u2018 u2018.

Delete xkomv where KSCHL = u2018 u2018.

u201C Sort xkomv and then use delete adjacent duplicates.

And after this append data from t_xkomv to xkomv.

Hope it helps you,

Regards,

Abhijit G. Borkar

Read only

0 Likes
2,097

Is there any addition in delete duplicate statement where we use where addition as well with that .. so that we can specify

if KSCHL IS empty ignore it ..

I read it somewhere

delete adjacent duplicate from itab comparing field1 <value1>.

this was the statement and it was written there if the value of field is empty that is ignored and it will consider only where the value exist.

Read only

0 Likes
2,097

Hi Nilkhilarya,

I dont think the syntax for delete adjacent duplicates contains comparing values also along with fields.

But the code provided by a®s works very well as per your requirement.

Regards,

Swarna Munukoti.

Read only

0 Likes
2,097

ya it will work but it is not accepting i mean there is a syntax error and there was no example on that site where i saw this code

and when i tried it is giving me error .

Read only

0 Likes
2,097

Hi Nilkhilarya,

What error you are getting when you tried that code?

Regards,

Swarna Munukoti.

Read only

0 Likes
2,097

Hi Nilkhilarya,

Please sort internal table before delete adjacent duplicates syntax.

Hope it will help you.

Regards,

Praveen

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
2,097

append lines of xtkomv to tkomv.
delete tkomv[] where KSCHL ne space.
delete ADJACENT DUPLICATES FROM xkomv COMPARING KSCHL.
append lines of  tkomv to xkomv.