CAFE

ABAP

중복데이터 삭제(DELETE ADJACENT DUPLICATES FROM itab.)

작성자우승권|작성시간08.10.27|조회수2,764 목록 댓글 0

DELETE ADJACENT DUPLICATES FROM itab.


Extras:

1. ... COMPARING f1 f2 ...

2. ... COMPARING ALL FIELDS

Effect

Deletes adjacent duplicate entries from the internal table itab. If there are n duplicate entries in succession, the first entry is retained, and the following n-1 entries are deleted.

Two lines are regarded as duplicates if their keys are identical.

The Return Code is set as follows:

SY-SUBRC = 0:
At least one duplicate was found, and at least one entry was deleted.
SY-SUBRC = 4:
No duplicates found, no entries deleted.

Addition 1

... COMPARING f1 f2 ...

Effect

Two lines of the internal table itab are regarded as duplicates if they have identical contents in the fields f1, f2, ...

Addition 2

... COMPARING ALL FIELDS

Effect

Two lines of the internal table are regarded as duplicates if all of their field contents are identical.

Notes

  1. The DELETE ADJACENT DUPLICATES statement works particularly well if you have sorted the internal table itab according to the fields that you want to compare when looking for duplicates. In this case, deleting adjacent duplicates is the same as deleting all duplicates. The direction of the sort is irrelevant.


  2. If you do not know a comparison expression‎ until runtime, you can specify it dynamically as the contents of the field name in the expression‎ COMPARING ... (name) .... If name is empty at runtime, the comparison expression‎ is ignored. If name contains an invalid component name, a runtime error occurs.


  3. You can further restrict comparison expressions - both static and dynamic - by specifying offset and length.


Note

Performance:

  1. When you delete a line of an internal table, index maintenance costs are incurred. These depend on the index of the table. The runtime is independent of the width of the table line.

    Deleting a line from the middle of an internal table with 200 entries usually requires around 10 msn (standardized microseconds).

    When you delete a set of entries using "DELETE itab FROM idx1 TO idx2." or "DELETE itab WHERE ...", index maintenance costs are only incurred once. This means that it is considerably more efficient than deleting entries in a LOOP.

  2. If you want to delete adjacent duplicate entries from an internal table, use the variant " DELETE ADJACENT DUPLICATES FROM itab." instead of a LOOP construction.

다음검색
현재 게시글 추가 기능 열기

댓글

댓글 리스트
맨위로

카페 검색

카페 검색어 입력폼