SAP READ TABLE ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_ITAB - Output Area
This example demonstrates how and where the line content of internal tables is read to.

ABAP_SOURCE_CODE
DEMO CL_DEMO_READ_TABLE_RESULT

ABAP_DESCRIPTION
Four alternatives for output behavior when reading internal tables are shown. First a sorted table is filled with a list of square numbers.
In the first alternative, the work area line that is compatible with the line type is filled with the numbers 2 and 3. The READ statement finds the line of the table in which the key field col1 has the same content as the work area and is copied to the work area. sy-subrc is two, since different numbers are found when the field col2 is compared.
In the second alternative, the READ statement reads the line of the table in which the key field col1 has the value 3. Only the content of col2 is copied to the work area line. sy-subrc is zero and sy-tabix is three, since itab is an index table.
In the third alternative, the READ statement is used to search for the lines of the table in which the field col2 has the value 16. The primary table key is not used. No fields are copied to the work area and no lines are assigned a field symbol. Only system fields are set. sy-subrc is zero, since a line was found and sy-tabix is four.
In the READ statement of the final alternative, the lines of the table are read in which the key field col1 has the value 2 and are assigned to the field symbol <(><)>. The component col2 of <(><)> is assigned the value 100. This also changes the corresponding table field.