Deleting Data Clusters from Cluster Databases
To delete data objects from a cluster database, use the following statement:
Syntax
DELETE FROM DATABASE <dbtab>(<ar>) [CLIENT <cli>] ID <key>.
This statement deletes the entire cluster in area <ar> with the name <key> from the database table <dbtab>. You must declare <dbtab> using a TABLES statement.
The CLIENT <cli> option allows you to disable the automatic client handling of a client-specific cluster database, and specify the client yourself. The addition must always come directly after the name of the database.
To save a data cluster in a database, use the EXPORT TO DATABASE statement (refer to
Saving Data Objects in a Cluster Database). For information about the structure of the database table <dbtab>, refer to the section Structure of Cluster Databases.The DELETE statement deletes all of the lines in the cluster database over which the data cluster extends.
If the system is able to delete a data cluster with the specified key, SY-SUBRC is set to 0, otherwise to 4.
PROGRAM SAPMZTS4.
TABLES INDX.
DATA DIRTAB LIKE CDIR OCCURS 10.
IMPORT DIRECTORY INTO DIRTAB FROM DATABASE
INDX(HK) ID 'Table'.
WRITE: / 'SY-SUBRC, IMPORT:', SY-SUBRC.
DELETE FROM DATABASE INDX(HK) ID 'Table'.
WRITE: / 'SY-SUBRC, DELETE:', SY-SUBRC.
IMPORT DIRECTORY INTO DIRTAB FROM DATABASE
INDX(HK) ID 'Table'.
WRITE: / 'SY-SUBRC, IMPORT:', SY-SUBRC.
This example deletes the data cluster stored in the cluster database in the example from the section
SY-SUBRC, IMPORT: 0
SY-SUBRC, DELETE: 0
SY-SUBRC, IMPORT: 4
In the first IMPORT statement, the data cluster still exists. The DELETE statement is successful. In the second IMPORT statement, the data cluster no longer exists.