SAP READ TABLE ABAP Statements



Get Example source ABAP code based on a different SAP table
  


ID READ-ITAB
• READ TABLE itab ABAP Statement

READ TABLE itab
Short Reference

ABAP_SYNTAX
READ TABLE itab ${ table_key
$| free_key
$| index $} result.

What does it do?
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-subrcMeaning 0Line 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. 2Like sy-subrc equals 0. Distinguishes cases that use the addition COMPARING in result. 4Line was not found. If the entry was found 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 ... • ..., to preserve the sort order. A binary search takes place when a sorted key is used by specifying it with additions table_key or free_key or if the addition BINARY SEARCH is used. Otherwise, sy-tabix is undefined (-1). 8Line was not found. The entry was searched using a binary search and the end of the table was reached. sy-tabix is set to the number of table lines + 1.
The system fields sy-tfill and sy-tleng are also filled.



Latest notes: