We are hiring and constantly growing! Have a look through our vacancies to find the right role for you!
READ TABLE itab ${ table_key
$| free_key
$|
index $} result.
This statement reads a line from the internal table itab. itab is a functional operand position.
The line must be specified by specifying values for either table_key for a table key, using a free condition free_key, or by specifying an index index. The latter is possible only for index tables and when using a sorted secondary key. The output response result determines how and to where the line content is read.
If the line to be read is not specified uniquely, the first suitable line is read. In index tables, this line has the lowest line number of all suitable lines with respect to the table index used.
If the internal table is specified as the return value or result of a
functional method, a
constructor expression, or a
table expression,
the value only exists when the statement is executed. Afterwards, it is no longer possible to access the internal table.
System Fields
The statement READ TABLE sets the values for the system fields sy-subrc and sy-tabix.
sy-subrc | Meaning |
0 | Line is found. sy-tabix is set to the line number of the entry in the primary or secondary table index used. If a hash key is used, it is set to 0. |
2 | Like sy-subrc equals 0. Distinguishes cases that use the addition COMPARING in result. |
4 | Line was not found. If the entry was determined using a binary search, sy-tabix is set to the line number of the entry in the primary or secondary table index in front of which it would be inserted using INSERT ... INDEX ..., to preserve the sort order. This is the case if, when sorted keys are used, the addition table_key or free_key was specified in addition to the complete table key or if the addition BINARY SEARCH was specified explicitly. Otherwise, sy-tabix is undefined (-1). |
8 | Line was not found. The entry was found using a binary search and the end of the table was reached. sy-tabix is set to the number of lines + 1. |
The system fields sy-tfill and sy-tleng are also filled.
Reading of individual table lines from a standard table in a WHILE loop. The table lines are read in reverse order with respect to the sorted secondary key sort_key. A CHECK statement exits the loop if the specified condition is not met. This construct demonstrates how an internal table could be processed in reverse order, before the addition STEP was introduced for the LOOP statement.
Reading of individual table lines from a standard table in a WHILE loop. The table lines are
read in reverse order with respect to the sorted secondary key sort_key. A CHECK statement
exits the loop if the specified condition is not met. This construct replaces the missing option of performing LOOP statements in reverse order. See also the corresponding
executable example with a FOR expression.
Non-Catchable Exceptions
Leave us your contact details and we will call you back. Fields marked with * are mandatory.
We offer holistic SAP solutions from a single source to shape digital change and develop new business areas.
Switzerland
Schaffhausen
Germany
Mannheim, Düsseldorf, Munich
USA
Haverhill
Greece
Thessaloniki