sapdev logo background
sapdev logo sapdev logo
Comments

ABAP DELETE ITAB LINES Statement syntax, information and example SAP source code



Return to Statement index



DELETE itab - itab_lines

Short Reference

ABAP Syntax ... itab [USING KEY keyname ] [FROM idx1] [TO idx2]
[WHERE log_exp
|(cond_syntax)] ... .

ABAP_ADDITIONS:
1 ... USING KEY keyname
2 ... [FROM idx1] [TO idx2]
3 ... WHERE log_exp
4 ... WHERE (cond_syntax)

What does it do? To delete several lines at once, you have to specify at least one of the additions FROM , TO , or WHERE .
USING KEY keyname is used to determine the the table key to which the additions refer.
If you specify more than one of the additions, those rows are deleted that result from the intersection of the individual additions.

ABAP_ADDITION_1 ... USING KEY keyname

Latest notes: Unlike the processing of 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.
If a secondary table key is specified, any WHERE condition also specified must be optimizable . Otherwise a syntax error occurs or an exception is raised.

Example ABAP Coding See Deleting Rows Using a Key

ABAP_ADDITION_2 ... [FROM idx1] [TO idx2]


ABAP_ADDITION_3 ... WHERE log_exp


ABAP_ADDITION_4 ... WHERE (cond_syntax)


Example ABAP Coding Deletes all rows in an internal table from row 4. The result is the same as in the example for APPEND ... SORTED BY . The column seatsfree is not required by the
SELECT statement but is filled by the program. For this reason, the associated syntax check warning is hidden by the appropriate pragma .
PARAMETERS: p_carrid TYPE sflight-carrid,
p_connid TYPE sflight-connid.

DATA: BEGIN OF seats,
fldate TYPE sflight-fldate,
seatsocc TYPE sflight-seatsocc,
seatsmax TYPE sflight-seatsmax,
seatsfree TYPE sflight-seatsocc,
END OF seats.

DATA seats_tab LIKE STANDARD TABLE OF seats.

SELECT fldate seatsocc seatsmax
FROM sflight
INTO TABLE seats_tab
WHERE carrid = p_carrid AND
connid = p_connid ##too_many_itab_fields.

LOOP AT seats_tab INTO seats.
seats-seatsfree = seats-seatsmax - seats-seatsocc.
MODIFY seats_tab INDEX sy-tabix FROM seats.
ENDLOOP.

SORT seats_tab BY seatsfree DESCENDING.

DELETE seats_tab FROM 4.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




DELETE_ITAB_LINE
DELETE_OBSOLETE




comments powered by Disqus