SAP ABAP SYNTAX FOR delete from data base 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.

RELATED POST

No comments :

Post a Comment