2012 Sep 24 6:29 PM
Hi Experts,
I have data in my internal table like shown below:
WBS OBJNR STATUS
1234 123 E009
1234 123 E0011
I am using delete adjacent duplicated from ITAB comparing WBS OBJNR which delete entry with status E0011.
But want to delete duplicates comparing WBS OBJNR and status = E009 or E008 or E013
So that the entry E0011 is not deleted.
I dont want to loop my table and i wanted to know if how i can achieve this.
2012 Sep 24 6:33 PM
hello,
not sure why you need E0011, but the above requirement cannot be done using delete adjacent duplicates. You will need some custom code. You need to explain more to understand what your need is. Thanks.
best regards,
swanand
2012 Sep 24 6:37 PM
We need records in internal table with status other than E009 or E008 or E013 i.e only if there are duplicate records comparing (wbs) we dont want records with status mentioned above.
2012 Sep 24 7:24 PM
you could delete these ( E009 or E008 or E013 ) from the internal table in that case.
2012 Sep 24 7:42 PM
I want to delete duplicates only and not the single entry with above status.
Anyways i am moving only the duplicates in another internal table and checking the status this was the only way i could figure out to do this.
2012 Sep 25 4:57 AM
Copy the original values to a temp table and do the processing.
it_data_ttemp[] = it_data[].
DELETE it_data_temp WHERE status EQ 'E009' OR status EQ 'E008'.
SORT it_data_temp BY wbs objnr.
DELETE ADJACENT DUPLICATES FROM it_data_temp COMPARING wbs objnr.
it_data_temp will have the unique entries and you can append them to it_data to continue processing.
Thanks,
Shambu
2012 Sep 25 6:10 AM
Hi Shambu,
Thanks for the reply
DELETE it_data_temp WHERE status EQ 'E009' OR status EQ 'E008'. this statement will also delete
single record but i want to delete only duplicated where status is E009 or E008
2012 Sep 25 6:24 AM
Are you telling that you want to keep entries for E011 even if they have duplicate entries but delete other like E008, E009 and so on?
Thanks,
Shambu
2012 Sep 25 6:29 AM
Hi Shambu,
Here is the scenario:
I want to delete only those duplicates where status is E009 or E008.
For below scenario after the logic i should get 2 records in my final o/p table
WBS OBJNR STATUS
1234 123 E009
1234 123 E0011
678 234 E009
Final o/p
1234 123 E0011
678 234 E009 ->even if this entry is with status E009 it is not duplicate
2012 Sep 25 6:48 AM
SORT it_data BY wms objnr status DESCENDING.
LOOP AT it_data INTO ls_data.
is_data = ls_data.
AT NEW objnr.
lv_first = 'X'.
ENDAT.
IF lv_first NE 'X'.
IF ( is_data-status EQ 'E008' OR is_data-status EQ 'E009' ) AND is_data-status NE 'E0011'.
DELETE it_data INDEX sy-tabix.
ENDIF.
ENDIF.
CLEAR lv_first.
ENDLOOP.
Check this and make sure E0011 comes on top of the internal table.
2012 Sep 25 10:46 AM
Hi,
I think loop is very much required for this task. please check the attahed text file however it is not that much good for performance criterria but it is working as you required.
Amit