ABAPDELETE_DUPLICATES - DELETE DUPLICATES

RFUMSV00 - Advance Return for Tax on Sales/Purchases   RFUMSV00 - Advance Return for Tax on Sales/Purchases  
This documentation is copyright by SAP AG.

DELETE itab - duplicates

Short Reference



Syntax

... ADJACENT DUPLICATES FROM itab [USING KEY keyname]
             [COMPARING {comp1comp2 ...}|{ALL FIELDS}]... .

Additions

1. ... USING KEY keyname

2. ... COMPARING {comp1 comp2 ...}|{ALL FIELDS}

Effect

With these additions, the DELETE statement deletes consecutive lines in groups (except for thefirst line of the group) that have the same content in specific components. If the COMPARINGaddition is not specified, the groups are determined by the content of the key fields of the table key used. If an explicit table key is not specified, theprimary table key is used implicitly.

The order of the table rows that are used to form the groups is determined by the table key used. If a key(keyname) is not specified after USING KEY, the order is the same as when processing aLOOP statement without the explicit specification of a key.

Lines are considered to be duplicated if the content of adjacent lines is the same in the components examined. If several duplicated lines follow one another, all of the lines (except for the first one) are deleted.

If a standard table is accessed using theprimary table key and this isempty, no lines are deleted.

Note

When using the primary table key, note that this may also be thestandard key, whereby unexpected effects may occur:

  • For structured line types, the standard key encompasses all character and byte-like components.
  • The standard key of a standard table can be empty.


Addition 1

... USING KEY keyname

Effect

Using the USING KEY addition, a table key can be specified in keynamewith which processing is carried out. The specified table key influences the sequence in which the table rows are accessed, and the evaluation of the remaining conditions.

If the primary table key is specified, processing behaves in the same way as when no key is explicitly specified. If asecondary table key is specified, the sequence in which the rows are accessed is as follows:

  • Specification of a sorted key
    The rows are processed by ascending row number in the secondary table index

  • Specification of a hash key
    The rows are processed in the sequence in which they were inserted into the table.

Note

In contrast to processing a hash table when a primary key is used, a preceding sort using the SORT statement has no influence on the processing sequence when a secondary hash key is specified.

Addition 2

... COMPARING {comp1 comp2 ...}|{ALL FIELDS}

Effect

If the COMPARING addition is specified, the groups are determined either using the content of the components specified(comp1 comp2 ...) or the content of all components (ALL FIELDS). Individual components (comp) are specified as described inSpecification of Components. Class attributes, in particular, can be accessed using the object component selector.

Example

Deleting all lines that occur more than once and refer to the primary key in internal table connection_tab.The result of this example corresponds to that 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.


ROGBILLS - Synchronize billing plans   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.


Length: 7260 Date: 20120522 Time: 045617     triton ( 245 ms )