‎2005 May 17 7:59 PM
Hi,
i have an internal table with several fields. those have name, number and code along with others.
The value in number field may or may not exist and if exists i have to check whether there are any duplicates with the same 'number and code' and i have to delete those.
could some one give me an efficient approach to do this. your help would be appreciated
Thanks
kranthi.
‎2005 May 17 8:44 PM
What Serder suggested and what Rich would have suggested will work for you, but it will also delete the ones that don't have a number. I think your requirement is to delete duplicates only if the number field is filled in.
You need to prepare two internal tables of the same structure. In one you will have records that have the number field filled in and the other will have records that don't have the number field filled in.
NO_NUMBER_ITAB[] = SOURCE_ITAB[].
DELETE NO_NUMBER_ITAB WHERE NOT NUMBER IS INITIAL.
NUMBER_FILLED_ITAB[] = SOURCE_ITAB[].
DELETE NUMBER_FILLED_ITAB WHERE IS INITIAL.
SORT NUMBER_FILLED_ITAB BY NUMBER CODE.
DELETE ADJACENT DUPLICATES FROM NUMBER_FILLED_ITAB COMPARING NUMBER CODE.
REFRESH SOURCE_ITAB.
APPEND LINES OF NUMBER_FILLED_ITAB TO SOURCE_ITAB.
APPEND LINES OF NO_NUMBER_ITAB TO SOURCE_ITAB.
Hope this works,
Srinivas
‎2005 May 17 8:04 PM
Hi Kranthi
Do not know whether Rich is at the moment writing for the answer but you can use
SORT itab BY number code .
DELETE ADJACENT DUPLICATES FROM itab COMPARING number code .Regards
*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>
‎2005 May 17 8:18 PM
‎2005 May 17 8:44 PM
What Serder suggested and what Rich would have suggested will work for you, but it will also delete the ones that don't have a number. I think your requirement is to delete duplicates only if the number field is filled in.
You need to prepare two internal tables of the same structure. In one you will have records that have the number field filled in and the other will have records that don't have the number field filled in.
NO_NUMBER_ITAB[] = SOURCE_ITAB[].
DELETE NO_NUMBER_ITAB WHERE NOT NUMBER IS INITIAL.
NUMBER_FILLED_ITAB[] = SOURCE_ITAB[].
DELETE NUMBER_FILLED_ITAB WHERE IS INITIAL.
SORT NUMBER_FILLED_ITAB BY NUMBER CODE.
DELETE ADJACENT DUPLICATES FROM NUMBER_FILLED_ITAB COMPARING NUMBER CODE.
REFRESH SOURCE_ITAB.
APPEND LINES OF NUMBER_FILLED_ITAB TO SOURCE_ITAB.
APPEND LINES OF NO_NUMBER_ITAB TO SOURCE_ITAB.
Hope this works,
Srinivas