ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Internal Tables → Processing Statements for Internal Tables → READ TABLE itab → READ TABLE - result
READ TABLE - transport_options
Other versions: 7.31 | 7.40 | 7.54
Syntax
... [COMPARING { {comp1 comp2 ...}|{ALL FIELDS}|{NO FIELDS} }]
[TRANSPORTING { {comp1 comp2 ...}|{ALL FIELDS} }] ... .
Effect
The addition COMPARING
compares the specified components comp1
comp2 ... (or the subareas or attributes) in a found row before they are transported with the
corresponding components of the work area. If ALL FIELDS
is specified, all
components are compared. If no NO FIELDS
is specified, no components are
compared. If the content of the compared components is identical, sy-subrc
is set to 0. Otherwise it is set to 2. The found row is assigned to the work area independently of the result of the comparison.
If the addition TRANSPORTING
is specified, only the specified components
comp1 comp2 ...
(and their subareas) in the found row are assigned to the
corresponding components of the work area (or their subareas). If ALL FIELDS
is specified, all the components are assigned.
COMPARING
must be specified before TRANSPORTING
. The components comp1 comp2 ...
are specified according to the rules in the section
Specifying Components. This is subject to the restriction
that after TRANSPORTING
, attributes of classes cannot be addressed using the object component selector.
Example
The READ
statement uses a WHILE
loop to read all rows of the table sflight_tab
one after the other using
the primary table index in the work area sflight_wa
. Only fields that are
also in the output are transported. The COMPARING
addition is used to select all flights in which no seats have yet been booked.
DATA: sflight_tab TYPE SORTED TABLE OF sflight
WITH UNIQUE KEY carrid connid fldate,
sflight_wa LIKE LINE OF sflight_tab.
DATA subrc TYPE sy-subrc.
SELECT *
FROM sflight
INTO TABLE sflight_tab
WHERE carrid = 'LH'.
subrc = sy-subrc.
WHILE subrc = 0.
sflight_wa-seatsocc = 0.
READ TABLE sflight_tab
INDEX sy-index
INTO sflight_wa COMPARING seatsocc
TRANSPORTING carrid
connid
fldate
seatsocc.
CASE sy-subrc.
WHEN 0.
WRITE: / sflight_wa-carrid, sflight_wa-connid,
sflight_wa-fldate, sflight_wa-seatsocc COLOR = 6.
subrc = sy-subrc.
WHEN 2.
WRITE: / sflight_wa-carrid, sflight_wa-connid,
sflight_wa-fldate, sflight_wa-seatsocc COLOR = 5.
subrc = 0.
WHEN 4 OR 8.
EXIT.
ENDCASE.
ENDWHILE.