ABAPDELETE_ITAB_KEY - DELETE ITAB KEY

General Material Data   BAL Application Log Documentation  
This documentation is copyright by SAP AG.

DELETE itab - table_key

Short Reference



Syntax

... { FROM wa [USING KEY keyname] }
  | { WITH TABLE KEY [keyname COMPONENTS]
                     {comp_name1|(name1)} = dobj1
                     {comp_name2|(name2)} = dobj2
                    ...                           } ... .

Alternatives:

1. ... FROM wa [USING KEY keyname]

2. ... WITH TABLE KEY [keyname COMPONENTS] ...

Effect

Enter table key as a search key. The values of the search key can be declared either implicitly in awork area wa behind FROM or by listing the components of the table key explicitly behind TABLE KEY.

When the primary table key is used, the table categories are accessed as follows:

When the secondary table key is used, a binary scan is used in thesorted key case and ahash algorithm is used in thehash key case.

Notes

When deleting a row from a standard table using a secondary key, the entire runtime depends linearlyon the number of table rows. Although the lines to be deleted are found quickly, a linear search must be carried out for the entry to be deleted when the primary index is updated.

Alternative 1

... FROM wa [USING KEY keyname]


Effect

For wa, a work area compatible to the row type of the internal table must be specified. This concernsfunctionaloperand positions. The first row of the internal table found, whose values in the columns of thetable key used match those of the corresponding components of wa, is processed. If the key fields in wa are empty, no entries are processed.

If the USING KEY addition is not specified, theprimarytable key is used. If the USING KEY addition is specified, the table key specified in keyname is used.

If a standard table is accessed using theprimary table key and this isempty, the first row of the internal table is deleted.

Notes

  • When using the primary table key, note that this may also by thestandard key, whereby unexpected effects may occur:
  • For structured row types, the standard key encompasses all character and byte-like components.

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

  • Outside of classes, an obsoleteshort form still exists for which you can omit the FROM wa specification if the internal table has an identically namedheader line(itab). The statement then uses the header line as the work area implicitly. Without FROM wa, USING KEY cannot be specified.


Example

A work area (scarr_wa) is used to delete the table row that has the same value as p_carrid in the carrid key field of the primary key.

PARAMETERS p_carrid TYPE scarr-carrid.

DATA: scarr_tab TYPE SORTED TABLE OF scarr
               WITH UNIQUE KEY carrid,
      scarr_wa  LIKE LINE OF scarr_tab.

SELECT *
       FROM scarr
       INTO TABLE scarr_tab.

IF sy-subrc = 0.
  scarr_wa-carrid = p_carrid.
  DELETE TABLE scarr_tab FROM scarr_wa.
ENDIF.

Alternative 2

... WITH TABLE KEY [keyname COMPONENTS] ...


Effect

Every component of the table key used must be executed, either directly as comp_name1 comp_name2..., or as a bracketed character-type data object name1 name2 ..., which contains the name of the component during the execution of the statement. comp_name1 comp_name2 ... arefunctional operand positions. name is not case-sensitive. If name only contains blank spaces, this component specification is ignored in the execution of the statement. A data object dobj1 dobj2 ..., that iscompatiblewith the data type of the component or that can be converted to it, must be assigned to every component.The first row of the internal table found, whose values in the column of the table key used correspondwith the values in the data object dobj1 dobj2 ... assigned, is processed. If it is necessary, the content of dobj1 dobj2 ... is converted to the data type of the component before the comparison.

If the addition COMPONENTS is not specified, theprimarytable key is used. If the addition COMPONENTS is specified, the table key specified in keyname is used.

Notes

  • The pseudocomponent table_line can be specified as a component for tables with an unstructured row type, if their whole table entry is defined as a table key.

  • To avoid unexpected results after a conversion, dobj1 dobj2 ... must be compatible with the data type of the component.

No Customizing include may be specified as a component if it is empty.

Example

When the primary table key is specified explicitly, the table row is deleted that has the same value as p_carrid in the carrid key field.

PARAMETERS p_carrid TYPE scarr-carrid.

DATA scarr_tab TYPE SORTED TABLE OF scarr
              WITH UNIQUE KEY carrid.

SELECT *
       FROM scarr
       INTO TABLE scarr_tab.

DELETE TABLE scarr_tab WITH TABLE KEY carrid = p_carrid.


SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.


Length: 10111 Date: 20120522 Time: 045903     triton ( 377 ms )