2009 Dec 23 7:53 AM
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
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 .
2009 Dec 23 7:58 AM
Try something like this.
If not xkomv-kschl is initial.
Delete ADJACENT DUPLICATES FROM xkomv COMPARING KSCHL.
endif.
2009 Dec 23 7:58 AM
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.
2009 Dec 23 8:02 AM
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 ..
2009 Dec 23 8:01 AM
hi,
DELETE ADJACENT DUPLICATES FROM it_t001_kkber COMPARING kkber.
DELETE it_t001_kkber WHERE kkber = space.
thanks
2009 Dec 23 8:03 AM
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.
a®
2009 Dec 23 8:05 AM
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
2009 Dec 23 8:07 AM
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
2009 Dec 23 10:02 AM
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.
2009 Dec 23 10:18 AM
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.
2009 Dec 23 10:20 AM
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 .
2009 Dec 24 5:11 AM
Hi Nilkhilarya,
What error you are getting when you tried that code?
Regards,
Swarna Munukoti.
2009 Dec 24 5:18 AM
Hi Nilkhilarya,
Please sort internal table before delete adjacent duplicates syntax.
Hope it will help you.
Regards,
Praveen
2009 Dec 23 11:15 AM
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.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |