ABAP Keyword Documentation → ABAP - Reference → Program Flow → Expressions and Functions for Logical Expressions → log_exp - Logical Expressions → log_exp - Comparisons → log_exp Comparison Rules → log_exp - Comparing Internal Tables
Comparing Internal Tables
This example demonstrates how internal tables are compared.
Other versions: 7.31 | 7.40 | 7.54
Source Code
DATA: BEGIN OF line,
col1 TYPE i,
col2 TYPE i,
END OF line.
DATA: itab LIKE TABLE OF line,
jtab LIKE TABLE OF line.
DO 3 TIMES.
line-col1 = sy-index.
line-col2 = sy-index ** 2.
APPEND line TO itab.
ENDDO.
MOVE itab TO jtab.
line-col1 = 10. line-col2 = 20.
APPEND line TO itab.
IF itab > jtab.
WRITE / 'ITAB > JTAB'.
ENDIF.
APPEND line TO jtab.
IF itab = jtab.
WRITE / 'ITAB = JTAB'.
ENDIF.
line-col1 = 30. line-col2 = 80.
APPEND line TO itab.
IF jtab <= itab.
WRITE / 'JTAB <= ITAB'.
ENDIF.
line-col1 = 50. line-col2 = 60.
APPEND line TO jtab.
IF itab <> jtab.
WRITE / 'ITAB <> JTAB'.
ENDIF.
IF itab < jtab.
WRITE / 'ITAB < JTAB'.
ENDIF.
Description
Two standard tables itab and jtab are created.
itab is filled with three rows and assigned to jtab.
A further row is added to itab and the first logical expression returns that
itab is bigger than jtab. After the same row has
been added to jtab, the second logical expression returns that both tables
are the same. Another row is added to itab and the third logical expression
returns that jtab is smaller than itab. Next,
a further row is added to jtab, the content of which is different from the
final row of itab. The next logical expression returns that itab
is not identical to jtab. The first table field where the contents of itab and jtab differ is
col1 in the last row of the table - that is to say, 30 for itab
and 50 for jtab. In the last logical expression, itab is therefore smaller than jtab.