SAP READ TABLE ABEXA

Get Example source ABAP code based on a different SAP table
  

Warning: Undefined variable $prev in /customers/b/9/9/trailsap.com/httpd.www/sap-help/index.php on line 54
ARTIClE

Internal Tables, Output Area
This example demonstrates how, and where to, the row contents of internal tables are read.

ABAP_SOURCE_CODE
ABAP_EXEC

ABAP_DESCRIPTION
Four alternatives for output behaviour during the reading of internal tables are shown. First a sorted table is filled with a list of square numbers.
In the first alternative, the work area line, which is compatible with the row type, is filled with the numbers 2 and 3. Using the READ statement the rows of the table are found, in which the keyfield col1 has the same contents as the work area, and these are then copied. sy-subrc is two because different numbers were found during the comparison of field col2.
In the second alternative, the READ statement is used to read those rows in which the keyfield col1 has the value 3. Only the content of col2 is copied to the work area line. sy-subrc has the value zero and sy-tabix is three because itab is an index table.
In the third alternative, the READ statement is used to find the rows of the table in which col2 is 16. The primary table key is not used. No fields are copied to the work area and no rows are assigned a field symbol. Only system fields are set. sy-subrc is zero because a row has been found and sy-tabix is four.
In the READ statement of the final alternative, the rows of the table are read in which the keyfield col1 has the value 2 and are then assigned to the field symbol <(><)>. The component col2 of <(><)> is assigned the value 100. This also changes the corresponding field of the table.