DELETE dbtab - source

Syntax

... FROM wa|{TABLE itab}.

Alternatives:

1. ... FROM wa

2. ... FROM TABLE itab

Effect

After FROM, you can specifiy a data object wa that is not table-type or an internal table itab. The content of the data objects determines the row(s) to be deleted.

Alternative 1

... FROM wa


Effect

If you specify a work area wa that is not table-type, a row is searched for in the database table whose primary key content is the same as that of the corresponding initial part of the work area. The content of the work area is not converted and is interpreted according to the structure of the database table or view. This row is deleted. The work area must meet the prerequisites for use in Open SQL statements.

If there is no row in the database with the same content as the primary key, no row is deleted and sy-subrc is set to 4.

Notes

Alternative 2

... FROM TABLE itab


Effect

If an internal table itab is specified, the system processed all rows of the internal table according to the rules for the work area wa. The row type of the internal table must meet the prerequisites for use in Open SQLstatements.

If, for a row of the internal table, there is no row in the database with the same content as the primary key, the corresponding row is ignored and sy-subrc is set to 4. If the internal table is empty, sy-subrc is set to 0. The system field sy-dbcnt is always set to the number of rows actually deleted.

Example

In the following example, all today's flights of an airline in which no seats are occupied are deleted from the database table SFLIGHT. The client field must be in the row structure of the internal table sflight_key_tab. Otherwise it does not cover the primary key of the database table and incorrect key values will be accepted as a result. This example has the same function as that for dtab-cond, but it requires two database accesses. The deleted rows are recorded in the internal table.

PARAMETERS p_carrid TYPE sflight-carrid.

TYPES: BEGIN OF sflight_key,
         mandt  TYPE sflight-mandt,
         carrid TYPE sflight-carrid,
         connid TYPE sflight-connid,
         fldate TYPE sflight-fldate,
      END OF sflight_key.

DATA sflight_key_tab TYPE TABLE OF sflight_key.

SELECT carrid connid fldate
       FROM sflight
       INTO CORRESPONDING FIELDS OF TABLE sflight_key_tab
       WHERE carrid = p_carrid AND
             fldate = sy-datum AND
             seatsocc = 0.

DELETE sflight FROM TABLE sflight_key_tab.