SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Obsolete Language Elements → Obsolete Processing of External Data → Obsolete Database Access → Obsolete Access Statements →Obsolete Syntax
READ TABLE { dbtab | *dbtab }
[WITH KEY key]
[SEARCH {FKEQ|FKGE|GKEQ|GKGE}]
[VERSION vers].
Extras:
1. ... WITH KEY key
2. ... SEARCH {FKEQ|FKGE|GKEQ|GKGE}
3. ... VERSION vers
Effect
This variant of the statement READ (not allowed in classes) reads a row from the database table dbtab and assigns the content to a work area.
A table work area dbtab or *dbtab is used implicitly as the work area. The table work area must be declared using the statement TABLES. If, instead of the name of the database table dbtab, the description *dbtab is used, dbtab is actually accessed but an additional table work area is used. All components of the table work area that match the primary key fields of the database table dbtab must be character-type.
For dbtab, you must specify a database table that begins with "T" and has a maximum length of five characters. If a database table is specified that does not begin with "T", then the first letter is implicitly replaced by "T".
Without the addition WITH KEY, the row to be read is determined by the content
of the components of the table work area that correspond to the primary key fields of database table dbtab.
System Fields
sy-subrc | Meaning |
0 | A table entry was read. |
4 | No table entry was found under the specified search key. |
8 | The table work area is too short. |
12 | The database table was not found. |
Note
This form of READ statement is not allowed in classes. It must be replaced by the statement SELECT.
... WITH KEY key
Effect
The addition WITH KEY determines the key by using the content of data object key, which expects a flat character-like data type.
The content of the table work area or the data object key is taken from the
database table as a search key (left-aligned with the length of the key components); then a matching entry is searched in the database.
... SEARCH {FKEQ|FKGE|GKEQ|GKGE}
Effect
The addition SEARCH determines how the row is searched:
... VERSION vers
Effect
If the addition VERSION is specified, then the database table dbtab is not read, and the table whose name is composed of "T" and the content of vers is read instead. vers expects a data object with a maximum of four characters, of type c. If the database table is not available, sy-subrc is set to 12.
The content of the row is still assigned to the table work area of dbtab
or *dbtab and its type is cast. If table work area is too short, then sy-subrc is set to 8.
Example
Reading of a row from the database table T100 or another database table that starts with "T".
The Open SQL-syntax to be used instead reads as follows. It uses a dynamic FROM clause and also uses CREATE DATA to create a suitable work area for the INTO clause.
PARAMETERS p TYPE c LENGTH 5 DEFAULT 'T100T'.
DATA dref TYPE REF TO data.
FIELD-SYMBOLS <fs> TYPE ANY.
CREATE DATA dref TYPE (p).
ASSIGN dref->* TO <fs>.
SELECT SINGLE *
FROM (p)
INTO <fs>
WHERE sprsl = 'E' AND
arbgb = 'BC' AND
msgnr = '010'.
IF sy-subrc = 0.
...
ENDIF.