DELETE - Delete from an internal table
Variants
1. DELETE itab.
2. DELETE itab INDEX idx.
3. DELETE itab FROM idx1 TO idx2.
4. DELETE itab WHERE condition.
5. DELETE ADJACENT DUPLICATES FROM itab.
Effect
Deletes one or more lines from an internal table.
Note
The deletion of lines within a LOOP ... ENDLOOP loop is performed in a sequence of loop passes.
Variant 1
DELETE itab.
Effect
The current entry of the internal table itab is
deleted in a LOOP loop.
Return code value
The is set to 0.
Note
After deleting the current entry in an internal table in a LOOP loop, the effect of further update operations on the current entry without an INDEX specification is not guaranteed and may changed in later Releases.
Variant 2
DELETE itab INDEX idx.
Effect
Deletes the idx entry from the internal table itab .
The return code value is set as follows:
SY-SUBRC = 0 The entry was deleted.
SY_SUBRC = 4 The entry does not exist.
Variant 3
DELETE itab FROM idx1 TO idx2.
Effect
Deletes the line area from index idx1 to idx2 from internal table itab . At least one of the two parameters FROM idx1 or TO idx2 should be specified. If parameter FROM is missing, the area from the start of the table to line idx2 is deleted. If parameter TO is missing, the area from line idx1 to the end of the table is deleted. Start index idx1 must be greater than 0.
The return code value is set as follows:
SY-SUBRC = 0 At least one entry was deleted.
SY_SUBRC = 4 None of the entries were deleted.
Variant 4
DELETE itab WHERE condition.
Additions
1. ... FROM idx1
2. ... TO idx2
Effect
Deletes all entries from internal table itab , which satisfies the condition condition .
The return code value is set as follows:
SY-SUBRC = 0 At least one entry was deleted.
SY_SUBRC = 4 None of the entries were deleted.
Addition 1
... FROM idx1
Effect
The line area to be investigated is restricted to the lines up to index idx1 . If the addition FROM idx1 is missing, a search is carried out from the beginning of the table.
The addition FROM must come before the WHERE condition.
Addition 2
... TO idx2
Effect
Restricts the line area to be investigated to the lines up to index idx2 . If the addition TO idx2 is missing, a search is carried out until the end of the table.
The addition TO must come before the WHERE condition.
Example
Delete all lines in a name table between lines 5 and 36, if the entry begins with one of the letters 'A' to 'C' :
DATA: BEGIN OF NAMETAB OCCURS 100,
NAME(30) TYPE C, END OF NAMETAB.
...
DELETE NAMETAB FROM 5 TO 36 WHERE NAME CA 'ABC'.
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
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.
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.
Note
Performance
Deleting a line from an internal table incurs index maintenance costs which depend on the index of the line to be deleted. The runtime depends on the line width of the table.
For example, deleting a line in the middle of an internal table with 200 entries requires about 10 msn (standardized microseconds).
Deleting a range of entries with " DELETE itab FROM idx1 TO idx2. " deleting a set of entries with " DELETE itab WHERE ... " only incur index maintenance costs once. Compared with a LOOP , which deletes line-by-line, this is much faster.
To delete neighboring, duplicate entries from an internal table, use the variant " DELETE ADJACENT DUPLICATES FROM itab. " instead of LOOP constructions.
Related INSERT itab , MODIFY itab
Index
?SAP AG 1996
Variants
1. DELETE itab.
2. DELETE itab INDEX idx.
3. DELETE itab FROM idx1 TO idx2.
4. DELETE itab WHERE condition.
5. DELETE ADJACENT DUPLICATES FROM itab.
Effect
Deletes one or more lines from an internal table.
Note
The deletion of lines within a LOOP ... ENDLOOP loop is performed in a sequence of loop passes.
Variant 1
DELETE itab.
Effect
The current entry of the internal table itab is
deleted in a LOOP loop.
Return code value
The is set to 0.
Note
After deleting the current entry in an internal table in a LOOP loop, the effect of further update operations on the current entry without an INDEX specification is not guaranteed and may changed in later Releases.
Variant 2
DELETE itab INDEX idx.
Effect
Deletes the idx entry from the internal table itab .
The return code value is set as follows:
SY-SUBRC = 0 The entry was deleted.
SY_SUBRC = 4 The entry does not exist.
Variant 3
DELETE itab FROM idx1 TO idx2.
Effect
Deletes the line area from index idx1 to idx2 from internal table itab . At least one of the two parameters FROM idx1 or TO idx2 should be specified. If parameter FROM is missing, the area from the start of the table to line idx2 is deleted. If parameter TO is missing, the area from line idx1 to the end of the table is deleted. Start index idx1 must be greater than 0.
The return code value is set as follows:
SY-SUBRC = 0 At least one entry was deleted.
SY_SUBRC = 4 None of the entries were deleted.
Variant 4
DELETE itab WHERE condition.
Additions
1. ... FROM idx1
2. ... TO idx2
Effect
Deletes all entries from internal table itab , which satisfies the condition condition .
The return code value is set as follows:
SY-SUBRC = 0 At least one entry was deleted.
SY_SUBRC = 4 None of the entries were deleted.
Addition 1
... FROM idx1
Effect
The line area to be investigated is restricted to the lines up to index idx1 . If the addition FROM idx1 is missing, a search is carried out from the beginning of the table.
The addition FROM must come before the WHERE condition.
Addition 2
... TO idx2
Effect
Restricts the line area to be investigated to the lines up to index idx2 . If the addition TO idx2 is missing, a search is carried out until the end of the table.
The addition TO must come before the WHERE condition.
Example
Delete all lines in a name table between lines 5 and 36, if the entry begins with one of the letters 'A' to 'C' :
DATA: BEGIN OF NAMETAB OCCURS 100,
NAME(30) TYPE C, END OF NAMETAB.
...
DELETE NAMETAB FROM 5 TO 36 WHERE NAME CA 'ABC'.
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
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.
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.
Note
Performance
Deleting a line from an internal table incurs index maintenance costs which depend on the index of the line to be deleted. The runtime depends on the line width of the table.
For example, deleting a line in the middle of an internal table with 200 entries requires about 10 msn (standardized microseconds).
Deleting a range of entries with " DELETE itab FROM idx1 TO idx2. " deleting a set of entries with " DELETE itab WHERE ... " only incur index maintenance costs once. Compared with a LOOP , which deletes line-by-line, this is much faster.
To delete neighboring, duplicate entries from an internal table, use the variant " DELETE ADJACENT DUPLICATES FROM itab. " instead of LOOP constructions.
Related INSERT itab , MODIFY itab
Index
?SAP AG 1996
댓글 7
-
체인지
2007.11.20 20:26
헐 아직 초보라 좀 이해가 많이 안되네요 그래도 좋은 자료 감사합니다 -
ABAP짱!
2007.12.06 19:13
저도잘.. ^^;; -
달식이
2008.02.27 02:15
좋은 자료 감사합니다. -
천군
2008.07.11 23:17
감사합니다... -
자드러브
2008.08.06 23:43
감사합니다. 모르던것들 참고하는데 도움이 됬습니다.
-
재리
2013.01.30 23:43
좋은정보 감사합니다.^^
-
neoclassic
2013.11.13 00:35
감사합니다~
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
8 | ftp://ftp.sap.com [3] | sapjoy | 2006.12.02 | 4624 |
» | delete 인터널 테이블 [7] | ecbase | 2006.12.02 | 11820 |
6 | TRANSPORTING [9] | ecbase | 2006.12.02 | 6398 |
5 | LIKE (% _)의 사용법 [8] | ecbase | 2006.12.02 | 6972 |
4 | AT 의 사용법(LOOP) [19] | ecbase | 2006.12.02 | 6875 |
3 | 프로그램간 테이블 넘김 [6] | ecbase | 2006.12.02 | 6830 |
2 | 특수 문자 표현 [8] | ecbase | 2006.12.02 | 6714 |
1 | 모듈 풀 스크린에서 마이너스(-)값 표시하기 [12] | ecbase | 2006.12.02 | 8687 |