Ansicht
Dokumentation

ABAPDELETE_DUPLICATES - DELETE DUPLICATES

ABAPDELETE_DUPLICATES - DELETE DUPLICATES

Fill RESBD Structure from EBP Component Structure   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.
SAP E-Book

DELETE itab, duplicates

Short Reference



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

Additions

1. ... USING KEY keyname

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

Effect

Using these additions, the statement DELETE deletes all lines except for the first line of the group in groups of consecutive lines that 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 of the table key used. If no explicit table key is specified, the primary table key is used implicitly.

The order of the table lines that are used to form the groups is determined by the table key used. If no key keyname is specified after USING KEY, the order is the same as when processing a statement LOOP without an explicit key specification.

Lines are considered to be duplicate if the content of neighboring line matches in the components examined. In the case of multiple duplicate lines following one another, all but the first line are deleted.

If the primary table key is used to access a standard table and the key is empty, no lines are deleted. If this is known statically, the syntax check produces a warning.

Notes

  • The use of ADJACENT DUPLICATES usually requires a suitable sorting by the components compared in the statement.
  • When using the primary table key, it should be noted that this key can be the standard key, which can also have unexpected consequences:
  • For structured line types, the standard key covers all character-like and byte-like components.

  • The standard key of a standard table can be empty.

Example

Deletion of all multiple lines with respect to the primary key in the internal table city_connections.

Addition 1

... USING KEY keyname

Effect

Using the USING KEY addition, a table key can be specified in keyname with 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 a secondary 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.

Note

Unlike the processing of a hashed table when a primary key is used, a preceding sort using the statement SORT does not affect the processing order when a secondary hash key is specified.

Example

The statement DELETE deletes all multiple numbers from the internal table itab. The table then contains a maximum of ten lines.

Addition 2

... 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 using the object component selector.

Example

Reading of specific data from two tables in the ITF framework, where DOKIL is the index table for DOKHL. After the multiple numbers are deleted, it is expected that both tables contain the same number of lines. The table declared inline, >dokhl_tab, has an empty primary key, which means that the component object is specified explicitly using COMPARING.






rdisp/max_wprun_time - Maximum work process run time   General Data in Customer Master  
This documentation is copyright by SAP AG.

Length: 6893 Date: 20240614 Time: 044459     sap01-206 ( 96 ms )