Documentation View

We are hiring and constantly growing! Have a look through our vacancies to find the right role for you!

ABAPREAD_TABLE_DBTAB - READ TABLE DBTAB

ABAPREAD_TABLE_DBTAB - READ TABLE DBTAB

Fill RESBD Structure from EBP Component Structure   PERFORM Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

READ TABLE dbtab

Short Reference



READ TABLE ${ dbtab $| *dbtab $}
           $[WITH KEY key$]
           $[SEARCH ${FKEQ$|FKGE$|GKEQ$|GKGE$}$]
           $[VERSION vers$].

Additions

1. ... WITH KEY key

2. ... SEARCH ${FKEQ$|FKGE$|GKEQ$|GKGE$}

3. ... VERSION vers

Effect

This variant of the statement READ, which is forbidden in classes, reads a row from the database table dbtab or from a DDIC table view and assigns the content to a work area.

A table work area dbtab or *dbtab is used implicitly as the work area. This table work area must be declared using the statement TABLES. If the name *dbtab is used instead of the name of the database table or view dbtab, dbtab is accessed, but the additional table work area is used. All components of the table work area that match the primary key fields of the database table or view dbtab must be character-like.

dbtab expects a database table or DDIC table view that starts with "T" and has a maximum length of five characters. If a database table or view is specified that does not begin with "T", 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 match the primary key fields of database table or view dbtab.

System Fields

sy-subrc Meaning
0 A table entry was read.
4 No table entry was found for the specified search key.
8 The table work area is too short.
12 The database table or view was not found.

Notes

  • This form of READ statement is not allowed in classes. It must be replaced by the SELECT statement.

  • The obsolete access statements do not support automatic client handling. The client identifier of a database table must be specified explicitly. The application programs are only to work with data for the current client. In systems with multitenancy, this is checked by the ABAP runtime environment.


Addition 1

... 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 or view as a search key (left-aligned with the length of the key components). A search for a matching entry is then made in the database table.

Addition 2

... SEARCH ${FKEQ$|FKGE$|GKEQ$|GKGE$}

Effect

The addition SEARCH determines how the row is searched for:

  • Without the addition SEARCH and with SEARCH FKEQ, the first row in the database table or view that matches the search key is searched for.
  • SEARCH GKEQ is used to search generically for the first row of the database table or view that matches the search key. The search key handles blanks as if they match all values.
  • SEARCH FKGE searches the first row of the database table or view that is greater than or equal to the search key.
  • SEARCH GKGE generically searches the first row of the database table or view that is greater than or equal to the search key. The search key handles blanks as if they match all values.

Addition 3

... VERSION vers

Effect

If the addition VERSION is specified, the database table or view 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 or view 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, where its type is cast. If the table work area is too short, sy-subrc is set to 8.

Example

Reading of a row from the database table T100 or another database table that starts with "T".

TABLES t100.

PARAMETERS p TYPE c LENGTH 4 DEFAULT '100T'.

t100-sprsl = 'E'.
t100-arbgb = 'BC'.

READ TABLE t100 SEARCH FKEQ VERSION p.
IF sy-subrc = 0.
  ...
ENDIF.

The syntax to be used instead reads as follows. It uses a dynamic FROM clause and CREATE DATA to create a suitable work area for the INTO clause.






PERFORM Short Reference   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.

Length: 7587 Date: 20230207 Time: 094321     sap01-206 ( 106 ms )