Data base Tables in SAP ABAP
Database Tables
Database Tables
A table is two dimensional data matrix i.e. it’s the combination of rows and columns. The rows contain the data record and columns contain the field.Tables can be containing zero or multiple records or rows.
Ex: Employee Table.
Types of Tables
1. Client Dependent
2. Client Independent
Client Dependent:- If the first field of a table is MANDT and data type is CLNT then it is called client dependent table. The length will be always 3.
Client Independent: - If the first field contains other than the MANDT then it is called client independent table .
The client dependent tables are again of three types.
1. Transparent tables.
2. Pooled Tables.
3. Clustered Table.
1.Transparent Tables
A transparent table in the dictionary has one to one relationship with a table in the database. Its structure in R/3 Data dictionary corresponding to a single database table. The database table has the same name, the same number of fields and the fields have the same names as the R/3 table definition. It contains application data. In below fig first part will shows tranasparent table.
Table Pools and Pooled Tables
A pooled table in R/3 has a many-to-one relationship with a table in the database. For one table in the database, there are many tables in the R/3 Data Dictionary. The table in the database has a different name than the tables in the DDIC, it has a different number of fields, and the fields have different names as well. Pooled tables are an SAP proprietary construct.
In the database pooled tables are stored in a single table called a table pool table.R/3 uses table pools to hold a large number (tens to thousands) of very small tables (about 10 to 100 rows each). Table pools reduce the amount of database resources needed when many small tables have to be open at the same time. Pooled tables are primarily used by SAP to hold customizing data. In the above fig second part is an example for pooled tables
Table Clusters and Cluster Tables
A cluster table is similar to a pooled table. It has a many to one relationship with a table in the database. Many cluster tables are stored in a single table in the database called a table cluster.
Table clusters are used to hold data from a few (approximately 2 to 10) very large tables. They would be used when these tables have a part of their primary keys in common, and if the data in these tables are all accessed simultaneously. Table clusters contain fewer tables than table pools and, unlike table pools, the primary key of each table within the table cluster begins with the same field or fields. In the above fig third part is an example for cluster tables.
Restrictions on Pooled and Cluster Tables
Pooled and cluster tables are usually used only by SAP and not used by customers, probably because of the proprietary format of these tables within the database and because of technical restrictions placed upon their use within ABAP/4 programs. On a pooled or cluster table:
Secondary indexes cannot be created.
1. You cannot use the ABAP/4 constructs select distinct or group by.
2. You cannot use native SQL.
3. You cannot specify field names after the order by clause. order by primary key is the only permitted variation.
Because of these restrictions on pooled and cluster tables and because of their limited usefulness. Normally in real time system we will not create much pooled and cluster tables. Only transparent tables are used or created maximum. So we will discuss only about transparent tables
Other Components of the Table
Fields: - Fields are nothing but columns.
Domain: - Domain consists of the technical characteristics of a field such as field length and data type.
Data Element: - A table is composed of fields to create a field you need a data element. The data element contains the field labels and documentation (F1 help) for the field. It contains the semantic characteristics for the field and it works like a interface between Field and Domain.
Domain and data elements are reusable. A domain can be used in more than one data element and data elements can be used in more than one field and in more than one table.
Delivery Class:- Delivery class comes under attributes. The value in the delivery class field identifies the “OWNER” of the data in this table. The owner is responsible for maintaining the table contents. In customer tables we always enter ‘A’ Here which indicates that the table contains application data owned by the customer only.
Ex: A – Application table (Master and transaction data).
Data Class: It comes under technical settings. It defines the physical address of the database in which the table uses creates and logically stored or it’s a physical place where the actual data is to be stored
Categories of Data Class: APPLO- Master Data, transparent tables.
Size Category: It also comes under technical settings. It defines the probable space requirement for a table in the database.
Categories:
0:- 0 to 30,000.
1:- 30,000 to 1, 20,000.
2:- 1, 20,000 to 4, 90,000.
3:- 4, 90,000 to 1,9,00,000
Table Maintenance allowed: Its also comes under attributes. By enabling table maintenance allowed user can be able to enter the data, change and display manually.
Approaches for creating tables.
There are two approaches you can use when creating tables.
Top-down-approach: In top down approach first we create the field then data element then domain.
Bottom-up-approach: In the bottom-up-approach first we create the domain, then data element and then field.
Direct Method: Do not have data element or domain.
Primary key: Primary key is a field or combination of fields that uniquely identify a row in the database table.
Foreign Key: Foreign Key is a key which is a primary key of another table.
Naming convention for database tables:
1. The tables we are creating are generally called as Z-tables or customizing tables.
2. The name of a table should be started with Y or Z that a user creates.
3. SAP has used A to X for its own use, Z or Y in the beginning means that the program or table is user defined.
So it avoids the redundancy between predefined and customizing tables.
Step1:Using Select * in SAP ABAP Important Top^
Select * is a statement which is used to read whole data from a database table.The below is the example code for reading data from MARA table.
**Declare internal table
DATA : IT_MARA TYPE TABLE OF MARA.
*use select * to read data
SELECT * FROM MARA INTO TABLE IT_MARA .
The below example code is used to get data based on a condition with all fields(columns) from MARA table.
**Declare internal table
DATA : IT_MARA TYPE TABLE OF MARA.
* read data
SELECT * FROM MARA INTO TABLE IT_MARA WHERE MTART = 'FERT' .
Step2:Using Select Single in SAP ABAP Normal Top^
Select Single is a statement which is used to read single data from a database table.The below is the example code for reading single record from MARA table.
Note: When ever we use select single, we must pass key field in where condition.
**Declare internal table
DATA : WA_MARA TYPE TABLE OF MARA.
*use select * to read data
SELECT SINGLE * FROM MARA INTO WA_MARA WHERE MATNR = '000001'. .
Step3:Using Select Max in SAP ABAP Important Top^
By using this query we can get highest numeric value of a column in SAP Database tables.
Syntax: SELECT MAX( <COLUMNNAME> ) INTO (<VARIABLE>) FROM <TABLE> .
Get Maximum value of a column using Select Max
The below statement will get the maximum value of column LIFNR from LFA1 table.
DATA LV_MAX TYPE LIFNR.
SELECT MAX( LIFNR )
INTO (LV_MAX)
FROM LIFNR .
WRITE:/ LV_MAX.
Step4:Using Select Min in SAP ABAP Important Top^
By using this query we can get minimum value of a column in SAP database table.
Syntax: SELECT MIN( <column> )
INTO (<variable>)
FROM <table>.
Get Minimum Value of a column in SAP ABAP
The below query will get the minimum value of LIFNR (Vendor Account No) from LFA1 table.
DATA LV_MIN TYPE LIFNR.
SELECT MIN( LIFNR )
INTO (LV_MIN)
FROM LFA1 .
WRITE:/ LV_MIN.
Step5:Using Select UP TO in SAP ABAP Normal Top^
BY using Select Up To query we will get the specific no of records from a data base table, it will get records from starting(begining).
Syntax:select * FROM <TABLE> INTO TABLE <ITAB> UP TO <NUMBEROFROWS> rows.
Get specific number of rows (records) from a database table in SAP ABAP.
data : it_mara type TABLE OF mara.
**Get 50 rows form starting
select * FROM mara INTO TABLE it_mara UP TO 50 rows.
Step6:Using Select Distinct in SAP ABAP Normal Top^
Select Distinct is used to get distinct (unique) values of a particular column in SAP ABAP.
Syntax: SELECT DISTINCT <COULMN> FROM <TABLE> INTO TABLE <ITAB>.
The below example is used to get distinct material type values from MARA table.
REPORT ZSAPN_SELECT_DISTINCT .
TYPES: BEGIN OF TY_MARA,
MTART TYPE MARA-MTART,
END OF TY_MARA.
DATA : IT_MARA TYPE TABLE OF TY_MARA.
DATA : WA_MARA TYPE TY_MARA.
SELECT DISTINCT MTART FROM MARA INTO TABLE IT_MARA.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MTART.
ENDLOOP.
Step7:Using Select Order by in SAP ABAP Important Top^
SELECT ORDERBY is used to fetch data from database table with sorted result set, by default the result will be sorted in ascending order, to sort in descending order you have to specify
Syntax: SELECT * FROM <TABLE> INTO TABLE <ITAB> ORDER BY <COLUMN> ASCENDING/DESCENDING.
The below is the example program of using orderby with select in SAP ABAP.
*example1 Sort in ASCENDING ORDER
REPORT ZSAPN_SORT_ASCENDING .
DATA : IT_MARA TYPE TABLE OF MARA.
DATA : WA_MARA TYPE MARA.
SELECT * FROM MARA INTO TABLE IT_MARA ORDER BY MATNR ASCENDING.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MATNR.ENDLOOP.
*example2 Sort in DESCENDING ORDER
REPORT ZSAPN_SORT_ASCENDING .
DATA : IT_MARA TYPE TABLE OF MARA.
DATA : WA_MARA TYPE MARA.
SELECT * FROM MARA INTO TABLE IT_MARA ORDER BY MATNR DESCENDING.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MATNR.
ENDLOOP.
The above statement is educational purpose only, in your real-time projects don`t use SELECT ORDERBY, it decreases performance of a program, instead use SORT after fetching data.SORT <ITAB> ASCENDING/DESCENDING.
Step8:Using Wildcards in Selects Normal Top^
SQL Wildcards are used to search for data in a database table, below are the examples of using wildcards in SAP ABAP.
The below example will get all records from MARA where MATNR contains 11.
REPORT ZSAPN_WILDCARDS.
DATA : IT_MARA TYPE TABLE OF MARA.
DATA : WA_MARA TYPE MARA.
SELECT * FROM MARA INTO TABLE IT_MARA WHERE matnr LIKE '%11%'.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MATNR.
ENDLOOP.
The below example will get all records from MARA where MATNR ends with 11.
REPORT ZSAPN_WILDCARDS.
DATA : IT_MARA TYPE TABLE OF MARA.
DATA : WA_MARA TYPE MARA.
SELECT * FROM MARA INTO TABLE IT_MARA WHERE matnr LIKE '%11'.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MATNR.
ENDLOOP.
The below example will get all records from MARA where MATNR starts 11.
REPORT ZSAPN_WILDCARDS.
DATA : IT_MARA TYPE TABLE OF MARA.
DATA : WA_MARA TYPE MARA.
SELECT * FROM MARA INTO TABLE IT_MARA WHERE matnr LIKE '11%'.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MATNR.
ENDLOOP.
MODIFY - Changing a Database Table
Variants:
1. MODIFY dbtab FROM wa. or
MODIFY (dbtabname) FROM wa.
2. MODIFY dbtab FROM TABLE itab. or
MODIFY (dbtabname) FROM TABLE itab.
3. MODIFY dbtab. or
MODIFY *dbtab.
4. MODIFY dbtab VERSION vers. or
MODIFY *dbtab VERSION vers.
Effect
Inserts new lines or updates existing lines in a database table (s. relational database). If a line with the specified primary key already exists, an UPDATE is executed. Otherwise, an INSERT is performed. You can specify the name of the database table either in the program itself in the form MODIFY dbtab ... or at runtime as the contents of the variable dbtabname in the form MODIFY (dbtabname) .... In both cases, the database table must be defined in the ABAP Dictionary. If the program contains the name of the database table, it must also have a corresponding TABLES statement. Normally, records are inserted or updated only in the current client. Data can only be inserted or updated using a view, if the view refers to a single table and was created in the ABAP Dictionary with the maintenance status "No restriction".
MODIFY belongs to the Open SQL command set.
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Open SQL and Unicode.
The system field SY-DBCNT contains the number of lines processed after the call of the statement.
The Return Code is set as follows:
SY-SUBRC = 0:
All lines were successfully inserted or updated.
SY-SUBRC = 4:
One or more lines could not be inserted or updated.
Notes
You cannot modify a line if there is already a line in the table with identical key field values in a UNIQUE index.
Automatic definition of INSERT and UPDATE is expensive. You should therefore use MODIFY only if you cannot define the INSERT and UPDATE cases yourself in the program.
Since the MODIFY statement does not perform authority checks, you have to program them yourself.
Adding or changing lines with the MODIFY command is only completed after a database commit (see LUW) has been performed. Before the database commit has been performed, any database changes can be reversed with a database rollback (see Programming transactions).
Synchronization of simultanous accesses by several users to the same set of data cannot be exclusively achieved with the lock mechanism of the database system. In several cases, you are recommended to use the SAP lock mechanism.
Variant 1
MODIFY dbtab FROM wa. or
MODIFY (dbtabname) FROM wa.
Extras:
1. ... CLIENT SPECIFIED
2. ... CONNECTION con
Effect
Inserts a new line or updates an existing line in a database table. The primary key for identifying the line to be inserted or updated and the relevant values are taken from the work area wa. When doing this, the data is read from wa from left to right according to the line structure of the database table dbtab. Since the structure of wa is not taken into account, the work area wa must be at least as wide (see DATA) as the line structure of dbtab, and the alignment of the work area wa must correspond to that of the line structure. Otherwise, a runtime error occurs.
If the database table dbtab or the work area wa contains strings, then wa must be compatible with the line structure of dbtab.
Example
Insert or change data of the customer Robinson in the current client:
DATA: wa TYPE scustom.
wa-id = '12400177'.
wa-name = 'Robinson'.
wa-postcode = '69542'.
wa-city = 'Heidelberg'.
wa-custtype = 'P'.
wa-discount = '003'.
wa-telephone = '06201/44889'.
MODIFY scustom FROM wa.
Addition 1
... CLIENT SPECIFIED
Effect
Switches off automatic client handling. This allows you
to edit data across all clients even when dealing with client-specific tables. The client field is treated like a normal table field that must be programmed to accept values in the work area wa.
The addition CLIENT SPECIFIED must be specified immediately after the name of the database table.
Addition 2
... CONNECTION con
Effect
The Open SQL command is not executed on the
standard database, but on the secondary database connection specified with con. con is the name of the databse connection as it was specified in the table DBCON in the column CON_NAME. The database connection con can also be specified dynamically in the form (source_text), where the field source_text contains the name of the database connection and must be type C or STRING. The CONNECTION con addition must be specified directly after the name of the database table or after the CLIENT SPECIFIED addition.
Variant 2
MODIFY dbtab FROM TABLE itab.or
MODIFY (dbtabname) FROM TABLE itab.
Extras:
1. ... CLIENT SPECIFIED
2. ... CONNECTION con
Effect
Mass modify: Inserts new lines or updates existing lines of a database table. The primary keys for identifying the lines to be inserted or updated and the relevant values are taken from the internal table itab. The lines of the internal table itab must satisfy the same conditions as the work area wa in addition 1 to variant 1.
Note
If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0.
Addition 1
... CLIENT SPECIFIED
Effect
As with variant 1.
Addition 2
... CONNECTION con
Effect
As with variant 1.
Variant 3
MODIFY dbtab. or
MODIFY *dbtab.
Extras:
1. ... CLIENT SPECIFIED
2. ... CONNECTION con
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Short Forms and Cannot Use *-Work Areas.
Note
This variant is obsolete.
Effect
These are the SAP-specific short forms of variant 1. They have the same effect as variant 1, but you do not specify the work area explicitly. Instead, the system implicitly uses the table work area dbtab or *dbtab declared using the TABLES statement.
MODIFY dbtab. or
MODIFY *dbtab.
is therefore equivalent to
MODIFY dbtab FROM dbtab. or
MODIFY dbtab FROM *dbtab.
Inserting Lines into Tables
The Open SQL statement for inserting data into a database table is:
INSERT INTO target lines.
It allows you to insert one or more lines into the database table target. You may specify the database table targeteither statically or dynamically.
Specifying a Database Table
To specify the database table statically, enter the following for target:
INSERT INTO dbtab [CLIENT SPECIFIED] lines.
where dbtab is the name of a database table defined in the ABAP Dictionary.
To specify the database table dynamically, enter the following for target:
INSERT INTO (name) [CLIENT SPECIFIED] lines.
where the field name contains the name of a database table defined in the ABAP Dictionary.
You can use the CLIENT SPECIFIED addition to disable automatic client handling.
Inserting a Single Line
To insert a single line into a database table, use the following:
INSERT INTO target VALUES wa.
The contents of the work area wa are written to the database table dbtab. It is a good idea to define the work area with reference to the structure of the database table.
You can also insert single lines using the following shortened form of the INSERT statement:
INSERT target FROM wa.
Using FROM instead of VALUE allows you to omit the INTOclause. Shorter still is:
INSERT dbtab.
In this case, the contents of the table work area dbtab are inserted into the database table with the same name. You must declare this table work area using the TABLES statement. In this case, it is not possible to specify the name of the database table dynamically. Table work areas with the same name as the database table (necessary before Release 4.0) should no longer be used for the sake of clarity.
Inserting Several Lines
To insert several lines into a database table, use the following:
INSERT target FROM TABLE itab [ACCEPTING DUPLICATE KEYS].
This writes all lines of the internal table itabto the database table in one single operation. If one or more lines cannot be inserted because the database already contains a line with the same primary key, a runtime error occurs. You can prevent the runtime error occurring by using the addition ACCEPTING DUPLICATE KEYS.
Whenever you want to insert more than one line into a database table, it is more efficient to work with an internal table than to insert the lines one by one.
Examples
Example
Adding single lines
TABLES spfli.
DATA wa TYPE spfli.
wa-carrid = 'LH'.
wa-cityfrom = 'WASHINGTON'.
...
INSERT INTO spfli VALUES wa.
wa-carrid = 'UA'.
wa-cityfrom = 'LONDON'.
...
INSERT spfli FROM wa.
spfli-carrid = 'LH'.
spfli-cityfrom = 'BERLIN'.
...
INSERT spfli.
This program inserts a single line into the database table SPFLI using each of the three possible variants of the INSERTstatement.
Instead of
INSERT spfli.
in the last line, you could also use the longer forms
INSERT spfli FROM spfli
or
INSERT INTO spfli VALUES spfli
here. The name SPFLI is therefore not unique.
These variations of the INSERT addition only work with table work areas that have been declared using TABLESand should therefore no longer be used.
Example
DATA: itab TYPE HASHED TABLE OF spfli
WITH UNIQUE KEY carrid connid,
wa LIKE LINE OF itab.
wa-carrid = 'UA'. wa-connid = '0011'. wa-cityfrom = ...
INSERT wa INTO TABLE itab.
wa-carrid = 'LH'. wa-connid = '1245'. wa-cityfrom = ...
INSERT wa INTO TABLE itab.
wa-carrid = 'AA'. wa-connid = '4574'. wa-cityfrom = ...
INSERT wa INTO TABLE itab.
...
INSERT spfli FROM TABLE itab ACCEPTING DUPLICATE KEYS.
IF sy-subrc = 0.
...
ELSEIF sy-subrc = 4.
...
ENDIF.
This example fills a hashed table itaband inserts its contents into the database table SPFLI. The program examines the contents of sy-subrc to see if the operation was successful.
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.
Database Tables
A table is two dimensional data matrix i.e. it’s the combination of rows and columns. The rows contain the data record and columns contain the field.Tables can be containing zero or multiple records or rows.
Ex: Employee Table.
Types of Tables
1. Client Dependent
2. Client Independent
Client Dependent:- If the first field of a table is MANDT and data type is CLNT then it is called client dependent table. The length will be always 3.
Client Independent: - If the first field contains other than the MANDT then it is called client independent table .
The client dependent tables are again of three types.
1. Transparent tables.
2. Pooled Tables.
3. Clustered Table.
1.Transparent Tables
A transparent table in the dictionary has one to one relationship with a table in the database. Its structure in R/3 Data dictionary corresponding to a single database table. The database table has the same name, the same number of fields and the fields have the same names as the R/3 table definition. It contains application data. In below fig first part will shows tranasparent table.
Table Pools and Pooled Tables
A pooled table in R/3 has a many-to-one relationship with a table in the database. For one table in the database, there are many tables in the R/3 Data Dictionary. The table in the database has a different name than the tables in the DDIC, it has a different number of fields, and the fields have different names as well. Pooled tables are an SAP proprietary construct.
In the database pooled tables are stored in a single table called a table pool table.R/3 uses table pools to hold a large number (tens to thousands) of very small tables (about 10 to 100 rows each). Table pools reduce the amount of database resources needed when many small tables have to be open at the same time. Pooled tables are primarily used by SAP to hold customizing data. In the above fig second part is an example for pooled tables
Table Clusters and Cluster Tables
A cluster table is similar to a pooled table. It has a many to one relationship with a table in the database. Many cluster tables are stored in a single table in the database called a table cluster.
Table clusters are used to hold data from a few (approximately 2 to 10) very large tables. They would be used when these tables have a part of their primary keys in common, and if the data in these tables are all accessed simultaneously. Table clusters contain fewer tables than table pools and, unlike table pools, the primary key of each table within the table cluster begins with the same field or fields. In the above fig third part is an example for cluster tables.
Restrictions on Pooled and Cluster Tables
Pooled and cluster tables are usually used only by SAP and not used by customers, probably because of the proprietary format of these tables within the database and because of technical restrictions placed upon their use within ABAP/4 programs. On a pooled or cluster table:
Secondary indexes cannot be created.
1. You cannot use the ABAP/4 constructs select distinct or group by.
2. You cannot use native SQL.
3. You cannot specify field names after the order by clause. order by primary key is the only permitted variation.
Because of these restrictions on pooled and cluster tables and because of their limited usefulness. Normally in real time system we will not create much pooled and cluster tables. Only transparent tables are used or created maximum. So we will discuss only about transparent tables
Other Components of the Table
Fields: - Fields are nothing but columns.
Domain: - Domain consists of the technical characteristics of a field such as field length and data type.
Data Element: - A table is composed of fields to create a field you need a data element. The data element contains the field labels and documentation (F1 help) for the field. It contains the semantic characteristics for the field and it works like a interface between Field and Domain.
Domain and data elements are reusable. A domain can be used in more than one data element and data elements can be used in more than one field and in more than one table.
Delivery Class:- Delivery class comes under attributes. The value in the delivery class field identifies the “OWNER” of the data in this table. The owner is responsible for maintaining the table contents. In customer tables we always enter ‘A’ Here which indicates that the table contains application data owned by the customer only.
Ex: A – Application table (Master and transaction data).
Data Class: It comes under technical settings. It defines the physical address of the database in which the table uses creates and logically stored or it’s a physical place where the actual data is to be stored
Categories of Data Class: APPLO- Master Data, transparent tables.
Size Category: It also comes under technical settings. It defines the probable space requirement for a table in the database.
Categories:
0:- 0 to 30,000.
1:- 30,000 to 1, 20,000.
2:- 1, 20,000 to 4, 90,000.
3:- 4, 90,000 to 1,9,00,000
Table Maintenance allowed: Its also comes under attributes. By enabling table maintenance allowed user can be able to enter the data, change and display manually.
Approaches for creating tables.
There are two approaches you can use when creating tables.
Top-down-approach: In top down approach first we create the field then data element then domain.
Bottom-up-approach: In the bottom-up-approach first we create the domain, then data element and then field.
Direct Method: Do not have data element or domain.
Primary key: Primary key is a field or combination of fields that uniquely identify a row in the database table.
Foreign Key: Foreign Key is a key which is a primary key of another table.
Naming convention for database tables:
1. The tables we are creating are generally called as Z-tables or customizing tables.
2. The name of a table should be started with Y or Z that a user creates.
3. SAP has used A to X for its own use, Z or Y in the beginning means that the program or table is user defined.
So it avoids the redundancy between predefined and customizing tables.
Step1:Using Select * in SAP ABAP Important Top^
Select * is a statement which is used to read whole data from a database table.The below is the example code for reading data from MARA table.
**Declare internal table
DATA : IT_MARA TYPE TABLE OF MARA.
*use select * to read data
SELECT * FROM MARA INTO TABLE IT_MARA .
The below example code is used to get data based on a condition with all fields(columns) from MARA table.
**Declare internal table
DATA : IT_MARA TYPE TABLE OF MARA.
* read data
SELECT * FROM MARA INTO TABLE IT_MARA WHERE MTART = 'FERT' .
Step2:Using Select Single in SAP ABAP Normal Top^
Select Single is a statement which is used to read single data from a database table.The below is the example code for reading single record from MARA table.
Note: When ever we use select single, we must pass key field in where condition.
**Declare internal table
DATA : WA_MARA TYPE TABLE OF MARA.
*use select * to read data
SELECT SINGLE * FROM MARA INTO WA_MARA WHERE MATNR = '000001'. .
Step3:Using Select Max in SAP ABAP Important Top^
By using this query we can get highest numeric value of a column in SAP Database tables.
Syntax: SELECT MAX( <COLUMNNAME> ) INTO (<VARIABLE>) FROM <TABLE> .
Get Maximum value of a column using Select Max
The below statement will get the maximum value of column LIFNR from LFA1 table.
DATA LV_MAX TYPE LIFNR.
SELECT MAX( LIFNR )
INTO (LV_MAX)
FROM LIFNR .
WRITE:/ LV_MAX.
Step4:Using Select Min in SAP ABAP Important Top^
By using this query we can get minimum value of a column in SAP database table.
Syntax: SELECT MIN( <column> )
INTO (<variable>)
FROM <table>.
Get Minimum Value of a column in SAP ABAP
The below query will get the minimum value of LIFNR (Vendor Account No) from LFA1 table.
DATA LV_MIN TYPE LIFNR.
SELECT MIN( LIFNR )
INTO (LV_MIN)
FROM LFA1 .
WRITE:/ LV_MIN.
Step5:Using Select UP TO in SAP ABAP Normal Top^
BY using Select Up To query we will get the specific no of records from a data base table, it will get records from starting(begining).
Syntax:select * FROM <TABLE> INTO TABLE <ITAB> UP TO <NUMBEROFROWS> rows.
Get specific number of rows (records) from a database table in SAP ABAP.
data : it_mara type TABLE OF mara.
**Get 50 rows form starting
select * FROM mara INTO TABLE it_mara UP TO 50 rows.
Step6:Using Select Distinct in SAP ABAP Normal Top^
Select Distinct is used to get distinct (unique) values of a particular column in SAP ABAP.
Syntax: SELECT DISTINCT <COULMN> FROM <TABLE> INTO TABLE <ITAB>.
The below example is used to get distinct material type values from MARA table.
REPORT ZSAPN_SELECT_DISTINCT .
TYPES: BEGIN OF TY_MARA,
MTART TYPE MARA-MTART,
END OF TY_MARA.
DATA : IT_MARA TYPE TABLE OF TY_MARA.
DATA : WA_MARA TYPE TY_MARA.
SELECT DISTINCT MTART FROM MARA INTO TABLE IT_MARA.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MTART.
ENDLOOP.
Step7:Using Select Order by in SAP ABAP Important Top^
SELECT ORDERBY is used to fetch data from database table with sorted result set, by default the result will be sorted in ascending order, to sort in descending order you have to specify
Syntax: SELECT * FROM <TABLE> INTO TABLE <ITAB> ORDER BY <COLUMN> ASCENDING/DESCENDING.
The below is the example program of using orderby with select in SAP ABAP.
*example1 Sort in ASCENDING ORDER
REPORT ZSAPN_SORT_ASCENDING .
DATA : IT_MARA TYPE TABLE OF MARA.
DATA : WA_MARA TYPE MARA.
SELECT * FROM MARA INTO TABLE IT_MARA ORDER BY MATNR ASCENDING.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MATNR.ENDLOOP.
*example2 Sort in DESCENDING ORDER
REPORT ZSAPN_SORT_ASCENDING .
DATA : IT_MARA TYPE TABLE OF MARA.
DATA : WA_MARA TYPE MARA.
SELECT * FROM MARA INTO TABLE IT_MARA ORDER BY MATNR DESCENDING.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MATNR.
ENDLOOP.
The above statement is educational purpose only, in your real-time projects don`t use SELECT ORDERBY, it decreases performance of a program, instead use SORT after fetching data.SORT <ITAB> ASCENDING/DESCENDING.
Step8:Using Wildcards in Selects Normal Top^
SQL Wildcards are used to search for data in a database table, below are the examples of using wildcards in SAP ABAP.
The below example will get all records from MARA where MATNR contains 11.
REPORT ZSAPN_WILDCARDS.
DATA : IT_MARA TYPE TABLE OF MARA.
DATA : WA_MARA TYPE MARA.
SELECT * FROM MARA INTO TABLE IT_MARA WHERE matnr LIKE '%11%'.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MATNR.
ENDLOOP.
The below example will get all records from MARA where MATNR ends with 11.
REPORT ZSAPN_WILDCARDS.
DATA : IT_MARA TYPE TABLE OF MARA.
DATA : WA_MARA TYPE MARA.
SELECT * FROM MARA INTO TABLE IT_MARA WHERE matnr LIKE '%11'.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MATNR.
ENDLOOP.
The below example will get all records from MARA where MATNR starts 11.
REPORT ZSAPN_WILDCARDS.
DATA : IT_MARA TYPE TABLE OF MARA.
DATA : WA_MARA TYPE MARA.
SELECT * FROM MARA INTO TABLE IT_MARA WHERE matnr LIKE '11%'.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MATNR.
ENDLOOP.
MODIFY - Changing a Database Table
Variants:
1. MODIFY dbtab FROM wa. or
MODIFY (dbtabname) FROM wa.
2. MODIFY dbtab FROM TABLE itab. or
MODIFY (dbtabname) FROM TABLE itab.
3. MODIFY dbtab. or
MODIFY *dbtab.
4. MODIFY dbtab VERSION vers. or
MODIFY *dbtab VERSION vers.
Effect
Inserts new lines or updates existing lines in a database table (s. relational database). If a line with the specified primary key already exists, an UPDATE is executed. Otherwise, an INSERT is performed. You can specify the name of the database table either in the program itself in the form MODIFY dbtab ... or at runtime as the contents of the variable dbtabname in the form MODIFY (dbtabname) .... In both cases, the database table must be defined in the ABAP Dictionary. If the program contains the name of the database table, it must also have a corresponding TABLES statement. Normally, records are inserted or updated only in the current client. Data can only be inserted or updated using a view, if the view refers to a single table and was created in the ABAP Dictionary with the maintenance status "No restriction".
MODIFY belongs to the Open SQL command set.
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Open SQL and Unicode.
The system field SY-DBCNT contains the number of lines processed after the call of the statement.
The Return Code is set as follows:
SY-SUBRC = 0:
All lines were successfully inserted or updated.
SY-SUBRC = 4:
One or more lines could not be inserted or updated.
Notes
You cannot modify a line if there is already a line in the table with identical key field values in a UNIQUE index.
Automatic definition of INSERT and UPDATE is expensive. You should therefore use MODIFY only if you cannot define the INSERT and UPDATE cases yourself in the program.
Since the MODIFY statement does not perform authority checks, you have to program them yourself.
Adding or changing lines with the MODIFY command is only completed after a database commit (see LUW) has been performed. Before the database commit has been performed, any database changes can be reversed with a database rollback (see Programming transactions).
Synchronization of simultanous accesses by several users to the same set of data cannot be exclusively achieved with the lock mechanism of the database system. In several cases, you are recommended to use the SAP lock mechanism.
Variant 1
MODIFY dbtab FROM wa. or
MODIFY (dbtabname) FROM wa.
Extras:
1. ... CLIENT SPECIFIED
2. ... CONNECTION con
Effect
Inserts a new line or updates an existing line in a database table. The primary key for identifying the line to be inserted or updated and the relevant values are taken from the work area wa. When doing this, the data is read from wa from left to right according to the line structure of the database table dbtab. Since the structure of wa is not taken into account, the work area wa must be at least as wide (see DATA) as the line structure of dbtab, and the alignment of the work area wa must correspond to that of the line structure. Otherwise, a runtime error occurs.
If the database table dbtab or the work area wa contains strings, then wa must be compatible with the line structure of dbtab.
Example
Insert or change data of the customer Robinson in the current client:
DATA: wa TYPE scustom.
wa-id = '12400177'.
wa-name = 'Robinson'.
wa-postcode = '69542'.
wa-city = 'Heidelberg'.
wa-custtype = 'P'.
wa-discount = '003'.
wa-telephone = '06201/44889'.
MODIFY scustom FROM wa.
Addition 1
... CLIENT SPECIFIED
Effect
Switches off automatic client handling. This allows you
to edit data across all clients even when dealing with client-specific tables. The client field is treated like a normal table field that must be programmed to accept values in the work area wa.
The addition CLIENT SPECIFIED must be specified immediately after the name of the database table.
Addition 2
... CONNECTION con
Effect
The Open SQL command is not executed on the
standard database, but on the secondary database connection specified with con. con is the name of the databse connection as it was specified in the table DBCON in the column CON_NAME. The database connection con can also be specified dynamically in the form (source_text), where the field source_text contains the name of the database connection and must be type C or STRING. The CONNECTION con addition must be specified directly after the name of the database table or after the CLIENT SPECIFIED addition.
Variant 2
MODIFY dbtab FROM TABLE itab.or
MODIFY (dbtabname) FROM TABLE itab.
Extras:
1. ... CLIENT SPECIFIED
2. ... CONNECTION con
Effect
Mass modify: Inserts new lines or updates existing lines of a database table. The primary keys for identifying the lines to be inserted or updated and the relevant values are taken from the internal table itab. The lines of the internal table itab must satisfy the same conditions as the work area wa in addition 1 to variant 1.
Note
If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0.
Addition 1
... CLIENT SPECIFIED
Effect
As with variant 1.
Addition 2
... CONNECTION con
Effect
As with variant 1.
Variant 3
MODIFY dbtab. or
MODIFY *dbtab.
Extras:
1. ... CLIENT SPECIFIED
2. ... CONNECTION con
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Short Forms and Cannot Use *-Work Areas.
Note
This variant is obsolete.
Effect
These are the SAP-specific short forms of variant 1. They have the same effect as variant 1, but you do not specify the work area explicitly. Instead, the system implicitly uses the table work area dbtab or *dbtab declared using the TABLES statement.
MODIFY dbtab. or
MODIFY *dbtab.
is therefore equivalent to
MODIFY dbtab FROM dbtab. or
MODIFY dbtab FROM *dbtab.
Inserting Lines into Tables
The Open SQL statement for inserting data into a database table is:
INSERT INTO target lines.
It allows you to insert one or more lines into the database table target. You may specify the database table targeteither statically or dynamically.
Specifying a Database Table
To specify the database table statically, enter the following for target:
INSERT INTO dbtab [CLIENT SPECIFIED] lines.
where dbtab is the name of a database table defined in the ABAP Dictionary.
To specify the database table dynamically, enter the following for target:
INSERT INTO (name) [CLIENT SPECIFIED] lines.
where the field name contains the name of a database table defined in the ABAP Dictionary.
You can use the CLIENT SPECIFIED addition to disable automatic client handling.
Inserting a Single Line
To insert a single line into a database table, use the following:
INSERT INTO target VALUES wa.
The contents of the work area wa are written to the database table dbtab. It is a good idea to define the work area with reference to the structure of the database table.
You can also insert single lines using the following shortened form of the INSERT statement:
INSERT target FROM wa.
Using FROM instead of VALUE allows you to omit the INTOclause. Shorter still is:
INSERT dbtab.
In this case, the contents of the table work area dbtab are inserted into the database table with the same name. You must declare this table work area using the TABLES statement. In this case, it is not possible to specify the name of the database table dynamically. Table work areas with the same name as the database table (necessary before Release 4.0) should no longer be used for the sake of clarity.
Inserting Several Lines
To insert several lines into a database table, use the following:
INSERT target FROM TABLE itab [ACCEPTING DUPLICATE KEYS].
This writes all lines of the internal table itabto the database table in one single operation. If one or more lines cannot be inserted because the database already contains a line with the same primary key, a runtime error occurs. You can prevent the runtime error occurring by using the addition ACCEPTING DUPLICATE KEYS.
Whenever you want to insert more than one line into a database table, it is more efficient to work with an internal table than to insert the lines one by one.
Examples
Example
Adding single lines
TABLES spfli.
DATA wa TYPE spfli.
wa-carrid = 'LH'.
wa-cityfrom = 'WASHINGTON'.
...
INSERT INTO spfli VALUES wa.
wa-carrid = 'UA'.
wa-cityfrom = 'LONDON'.
...
INSERT spfli FROM wa.
spfli-carrid = 'LH'.
spfli-cityfrom = 'BERLIN'.
...
INSERT spfli.
This program inserts a single line into the database table SPFLI using each of the three possible variants of the INSERTstatement.
Instead of
INSERT spfli.
in the last line, you could also use the longer forms
INSERT spfli FROM spfli
or
INSERT INTO spfli VALUES spfli
here. The name SPFLI is therefore not unique.
These variations of the INSERT addition only work with table work areas that have been declared using TABLESand should therefore no longer be used.
Example
DATA: itab TYPE HASHED TABLE OF spfli
WITH UNIQUE KEY carrid connid,
wa LIKE LINE OF itab.
wa-carrid = 'UA'. wa-connid = '0011'. wa-cityfrom = ...
INSERT wa INTO TABLE itab.
wa-carrid = 'LH'. wa-connid = '1245'. wa-cityfrom = ...
INSERT wa INTO TABLE itab.
wa-carrid = 'AA'. wa-connid = '4574'. wa-cityfrom = ...
INSERT wa INTO TABLE itab.
...
INSERT spfli FROM TABLE itab ACCEPTING DUPLICATE KEYS.
IF sy-subrc = 0.
...
ELSEIF sy-subrc = 4.
...
ENDIF.
This example fills a hashed table itaband inserts its contents into the database table SPFLI. The program examines the contents of sy-subrc to see if the operation was successful.
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.