ABAP/4   ОКМ   ДМ   экономическая информатика   4GL   Теория и практика обработки информации

Компьютерный язык ABAP/4 - ключевые слова

DELETE - Delete from a database table

Variants

1. DELETE FROM dbtab WHERE condition.
DELETE FROM (dbtabname) WHERE condition.
2. DELETE dbtab.
DELETE *dbtab.
DELETE (dbtabname) ...
3. DELETE dbtab FROM TABLE itab.
DELETE (dbtabname) FROM TABLE itab.
4. DELETE dbtab VERSION vers.
DELETE *dbtab VERSION vers.

Effect

Deletes lines in a database table . You can specify the name of the database table either in the program itself with DELETE FROM dbtab ... or at runtime as the contents of the field dbtabname with DELETE FROM (dbtabname) ... . In both cases, the database table must be known in the ABAP/4 Dictionary. If you specify the name in the program, there must also be an appropriate TABLES statement. Only data from the current client is usually deleted. You can delete data using a view only if the view refers to a single table and was created in the ABAP/4 Dictionary with the maintenance status "No restriction".

DELETE belongs to the Open SQL command set.

Note

The DELETE statement does not perform authorization checks : You must program these yourself.

Variant 1

DELETE FROM dbtab WHERE condition.
DELETE FROM (dbtabname) WHERE condition.

Addition




... CLIENT SPECIFIED

Effect

Deletes lines in a database table that satisfy the WHERE clause condition . With this variant, specification of a WHERE condition is obligatory .

When the statement has been executed, the system field SY-DBCNT contains the number of deleted lines.

The return code value is set as follows:


SY-SUBRC = 0 At least one line was deleted.
SY_SUBRC = 4 No lines were deleted, since no line was selected.

Example

Delete all bookings for the Lufthansa flight 0400 on 28.02.1995 (in the current client):
TABLES SBOOK. DELETE FROM SBOOK WHERE CARRID = 'LH' AND CONNID = '0400' AND FLDATE = '19950228'.

Note

To delete all the lines in a table, you must specify a WHERE condition that is true for all lines. You can achieve this with
... WHERE f IN itab
If the internal table itab is empty, such a condition would select all lines.

Addition

... CLIENT SPECIFIED

Effect

Switches off automatic client handling. This allows you to delete data across all clients in the case of client-specific tables. The client field is then treated like a normal table field, for which you can formulate suitable conditions in the WHERE clause.

You must specify the addition CLIENT SPECIFIED immediately after the name of the database table.

Variant 2

DELETE dbtab.
DELETE *dbtab.
DELETE (dbtabname) ...

Additions




1. ... FROM wa
2. ... CLIENT SPECIFIED

Effect

These are SAP-specific short forms used to delete a single line of a database table. If the name of the database table is specified in the program, the primary key of the line to be deleted is taken from the specified work area - dbtab or *dbtab . If the name of the database table is not determined until runtime ( DELETE (dbtabname) ... ), the addition ... FROM wa is obligatory .

When the statement has been executed, the system field SY-DBCNT contains the number of deleted lines (0 or 1).

The return code value is set as follows:


SY-SUBRC = 0 The line was deleted.
SY_SUBRC = 4 No lines could be deleted, since no line exists with the primary key specified.

Example

Delete the booking with the booking number 3 for the Lufthansa flight 0400 on 28.02.1995 (in the current client):
TABLES SBOOK. SBOOK-CARRID = 'LH'. SBOOK-CONNID = '0400'. SBOOK-FLDATE = '19950228'. SBOOK-BOOKID = '00000003'. DELETE SBOOK.

Addition 1

... FROM wa

Effect

Takes the primary key for the line to be deleted not from the table work area dbtab , but from the explicitly specified work area wa . Here, the key values from left to right are taken from wa according to the structure of the primary key in the table work area dbtab (see TABLES ). The structure of wa is not taken into account. Therefore, the work area wa must be at least as wide (see DATA ) as the primary key in the table work area dbtab and the alignment of the work area wa must correspond to the alignment of the primary key in the table work area. Otherwise, you get a runtime error.

Note

If a work area is not explicitly specified, the values for the line to be deleted are taken from the table work area dbtab , even if the statement appears in a subroutine (see FORM ) or Funktionsbaustein (see FUNCTION ) where the table work area is stored in a formal parameter or a local variable of the same name.

Addition 2

... CLIENT SPECIFIED

Effect

As with variant 1.

Variant 3

DELETE dbtab FROM TABLE itab.
DELETE (dbtabname) FROM TABLE itab.

Addition




... CLIENT SPECIFIED

Effect

Mass deletion: Deletes all database table lines for which the internal table itab contains values for the primary key fields. The lines of the internal table itab must satisfy the same condition as the work area wa in addition 1 to variant.

The system field SY-DBCNT contains the number of deleted lines, i.e. the number of lines of the internal table itab for whose key values there were lines in the database table dbtab .

The return code value is set as follows:


SY-SUBRC = 0 All lines from itab could be used to delete lines from dbtab .
SY_SUBRC = 4 For at least one line of the internal table in the database table, there was no line with the same primary key. All found lines are deleted..

Note

If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0.

Addition

... CLIENT SPECIFIED

Effect

As with variant 1.

Variant 4

DELETE dbtab VERSION vers.
DELETE *dbtab VERSION vers.

Note

This variant is obsolete, since variants 1 - 3 allow you to specify the database table name dynamically.

Effect

Deletes a line in a database table, the name of which is taken from the field vers at runtime. The database table must be known to the ABAP/4 Dictionary and its name must conform to the following naming convention: It must begin with 'T' and can consist of four additional characters. The field vers must contain the table name without a leading 'T'. Only lines in the current client are deleted. The line to be deleted is taken from the statically specified table work area dbtab or *dbtab .

The return code value is set as follows:


SY-SUBRC = 0 The line was deleted.
SY_SUBRC = 4 No lines could be deleted because no line existed with the specified primary key.

Index
© SAP AG 1996
ABAP/4   ОКМ   ДМ   экономическая информатика   4GL   Теория и практика обработки информации

НОВОСТИ ФОРУМА

Форум Рыцари теории эфира


Рыцари теории эфира
 10.11.2021 - 12:37: ПЕРСОНАЛИИ - Personalias -> WHO IS WHO - КТО ЕСТЬ КТО - Карим_Хайдаров.
10.11.2021 - 12:36: СОВЕСТЬ - Conscience -> РАСЧЕЛОВЕЧИВАНИЕ ЧЕЛОВЕКА. КОМУ ЭТО НАДО? - Карим_Хайдаров.
10.11.2021 - 12:36: ВОСПИТАНИЕ, ПРОСВЕЩЕНИЕ, ОБРАЗОВАНИЕ - Upbringing, Inlightening, Education -> Просвещение от д.м.н. Александра Алексеевича Редько - Карим_Хайдаров.
10.11.2021 - 12:35: ЭКОЛОГИЯ - Ecology -> Биологическая безопасность населения - Карим_Хайдаров.
10.11.2021 - 12:34: ВОЙНА, ПОЛИТИКА И НАУКА - War, Politics and Science -> Проблема государственного терроризма - Карим_Хайдаров.
10.11.2021 - 12:34: ВОЙНА, ПОЛИТИКА И НАУКА - War, Politics and Science -> ПРАВОСУДИЯ.НЕТ - Карим_Хайдаров.
10.11.2021 - 12:34: ВОСПИТАНИЕ, ПРОСВЕЩЕНИЕ, ОБРАЗОВАНИЕ - Upbringing, Inlightening, Education -> Просвещение от Вадима Глогера, США - Карим_Хайдаров.
10.11.2021 - 09:18: НОВЫЕ ТЕХНОЛОГИИ - New Technologies -> Волновая генетика Петра Гаряева, 5G-контроль и управление - Карим_Хайдаров.
10.11.2021 - 09:18: ЭКОЛОГИЯ - Ecology -> ЭКОЛОГИЯ ДЛЯ ВСЕХ - Карим_Хайдаров.
10.11.2021 - 09:16: ЭКОЛОГИЯ - Ecology -> ПРОБЛЕМЫ МЕДИЦИНЫ - Карим_Хайдаров.
10.11.2021 - 09:15: ВОСПИТАНИЕ, ПРОСВЕЩЕНИЕ, ОБРАЗОВАНИЕ - Upbringing, Inlightening, Education -> Просвещение от Екатерины Коваленко - Карим_Хайдаров.
10.11.2021 - 09:13: ВОСПИТАНИЕ, ПРОСВЕЩЕНИЕ, ОБРАЗОВАНИЕ - Upbringing, Inlightening, Education -> Просвещение от Вильгельма Варкентина - Карим_Хайдаров.
Bourabai Research - Технологии XXI века Bourabai Research Institution