‎2007 Apr 04 9:37 AM
hi
i need tohave full detail and use of delted adjacent duplicate statement,
where touse it and where not to use it as some confusion is there realted to it.
i need to have all pros and cons of it and also the use and varous options available in it?
pls eloborate more clearly and menwhile ia m also serching for more info on it.
regards
Nishant
‎2007 Apr 04 9:41 AM
Deletes neighboring, duplicate entries from the internal table itab . If there are n duplicate entries, the first entry is retained and the other n - 1 entries are deleted.
Two lines are considered to be duplicated if their default keys match.
The return code value is set as follows:
SY-SUBRC = 0 At least one duplicate exists, at least one entry deleted.
SY_SUBRC = 4 No duplicates exist, no entry deleted.
Refer
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/delete_i.htm
Regards,
Santosh
Message was edited by:
Santosh Kumar Patha
‎2007 Apr 04 9:41 AM
Deletes neighboring, duplicate entries from the internal table itab . If there are n duplicate entries, the first entry is retained and the other n - 1 entries are deleted.
Two lines are considered to be duplicated if their default keys match.
The return code value is set as follows:
SY-SUBRC = 0 At least one duplicate exists, at least one entry deleted.
SY_SUBRC = 4 No duplicates exist, no entry deleted.
Refer
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/delete_i.htm
Regards,
Santosh
Message was edited by:
Santosh Kumar Patha
‎2007 Apr 04 9:44 AM
hi,
Example..
For DELETE ADJACENT DUPLICATES you have to sort first..
SORT ITAB BY MATNR.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING MATNR.
Just use that statement, omitting the COMPARING extension will simply mean that it will look at the entire line.
sort it_bsid ascending.
DELETE ADJACENT DUPLICATES FROM it_bsid.
Rgds
Anversha
‎2007 Apr 04 9:45 AM
Hi,
DELETE - duplicates
Syntax
... ADJACENT DUPLICATES FROM itab
[COMPARING { comp1 comp2 ...}|{ALL FIELDS}]... .
Addition:
... COMPARING {comp1 comp2 ...}|{ALL FIELDS}
Effect
With these additions, the statement DELETE deletes all lines in certain groups of lines, except for the first line of the group. These are groups of lines that follow one another and have the same content in certain components. If the addition COMPARING is not specified, the groups are determined by the content of the key fields.
Lines are considered to be doubled if the content of neighboring lines is the same in the components examined. In the case of several double lines following one another, all the lines - except for the first - are deleted.
Addition
... COMPARING {comp1 comp2 ...}|{ALL FIELDS}
Effect
If the addition COMPARING is specified, the groups are determined either by the content of the specified components comp1 comp2 ... or the content of all components ALL FIELDS. The specification of individual components comp is made as described in the section Specification of Components. Access to class attributes is possible through the object component selector only as of Release 6.10.
Example
Deleting all multiple-occurring lines in the internal table connection_tab. The result of this exanple corresponds to the one in the example for the position specification for INSERT.
DATA: BEGIN OF connection,
cityfrom TYPE spfli-cityfrom,
cityto TYPE spfli-cityto,
distid TYPE spfli-distid,
distance TYPE spfli-distance,
END OF connection.
DATA connection_tab LIKE SORTED TABLE OF connection
WITH NON-UNIQUE KEY cityfrom cityto
distid distance.
SELECT cityfrom cityto distid distance
FROM spfli
INTO TABLE connection_tab.
DELETE ADJACENT DUPLICATES FROM connection_tab.
Cheers,
Simha.
‎2007 Apr 04 9:47 AM
hi,
As the name says, it deletes the adjacent duplicates of data in the internal table.
Note : Before deleting adjacent duplicates, you have to ensure that the internal table is sorted based on the fields which are used in delete adjacent duplicates statement.
ex:
sort itab by f1 f2 f3.
delete adjacent duplicates from itab comparing f1 f2.
We have list of Sales orders and sold-toparty corresponding to these sales orders.
Now, you require the details of sold-to-party, say name of sold-to-party.
There might be a case, where we have same sold-to-party for different sales orders.
select kunnr
name1
from kna1
into table it_kna1
where kunnr eq it_vbak-kunnr.Instead of fetching name1 for every record of vbak, we can minimise our data retrieval by
deleting the duplicates..it_vbak is having 100 records with 10 sol-to-party. in previous select, we have to pass 100 records to fetch kunnr details.
Instead, we can do teh way specified below so that we get data for only 10 kunnrs.
if not it_vbak[] is initial.
it_vbak_temp[] = it_vbak[].
sort it_vbak_temp by kunnr.
delete adjacent duplicates from it_vbak_temp comparing kunnr.
select kunnr
name1
from kna1
into table it_kna1
for all entries in it_vbak_temp
where kunnr eq it_vbak_temp-kunnr.
endif.Hope it is clear...
Regards,
sailaja.
‎2007 Apr 04 9:47 AM
‎2007 Jun 08 4:50 AM
got helpful anseres rest will explore
if anyone has still more link can mail
‎2007 Jun 08 5:07 AM
sometimes we get duplicates to internal table from table,and when you see the repeat same record is repeqting mutiple times,
then we adjacent duplicate condition.
if you use this condition it will delete duplicates value from internal table and also you can keep condition based field you can delete
‎2007 Jun 08 5:08 AM
hi,
Variant 5
DELETE ADJACENT DUPLICATES FROM itab.
Additions
1. ... COMPARING f1 f2 ...
2. ... COMPARING ALL FIELDS
Effect
Deletes neighboring, duplicate entries from the internal table itab . If there are n duplicate entries, the first entry is retained and the other n - 1 entries are deleted.
Two lines are considered to be duplicated if their default keys match.
The return code value is set as follows:
SY-SUBRC = 0 At least one duplicate exists, at least one entry deleted.
SY_SUBRC = 4 No duplicates exist, no entry deleted.
Addition 1
... COMPARING f1 f2 ...
Effect
Two lines of the internal table itab are considered to be duplicates if the specified fields f1 , f2 , .... match.
Addition 2
... COMPARING ALL FIELDS
Effect
Two lines are considered to be duplicates if all fields of the table entries match.
Notes
<b>The DELETE ADJACENT DUPLICATES statement is especially useful if the internal table itab is sorted by fields (whether in ascending or descending order) which were compared during duplicate determination. In this case, the deletion of neighbouring duplicates is the same as the deletion of all duplicates.</b>
<b>
If a comparison criterion is only known at runtime, it can be specified dynamically as the content of a field name by using COMPARING ... (name) ... . If name is blank at runtime, the comparison criterion is ignored. If name contains an invalid component name, a runtime error occurs.
Comparison criteria - statistically or dynamically specified - can be further restriced by specifying the offset and/or length.</b>