Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Program Flow Logic →  Expressions and Functions for Conditions →  log_exp - Logical Expressions →  rel_exp - Comparison Expressions →  rel_exp - Comparison Rules 

rel_exp - Comparing Internal Tables

It is possible to compare internal tables with other internal tables if their row types can be compared. Internal tables are compared based on the following hierarchy:

  • The internal table that has more rows than the other internal table is the larger table.
  • Internal tables with the same number of rows are compared row by row. If an internal table contains nested internal tables, these are compared recursively. Two internal tables are identical if the content of each corresponding row matches. If two internal tables are not identical, the first non-matching pair of rows determines the result of the comparison.
  • Other versions: 7.31 | 7.40 | 7.54


    Note

    If an internal table with a header line is specified as an operand of an assignment, the header line is addressed in nearly all operand positions and not the table body. To address the table body of a table with a header, [] must be appended to the name.


    Example

    itab2 is larger than itab1, despite having the same number of rows, because the content of its second row is larger than that of itab1.

    DATA: 
      itab1 TYPE TABLE OF i WITH EMPTY KEY, 
      itab2 TYPE TABLE OF i WITH EMPTY KEY. 
    
    itab1 = VALUE #( ( 1 ) ( 2 ) ( 3 ) ). 
    itab2 = VALUE #( ( 1 ) ( 3 ) ( 3 ) ). 
    
    ASSERT itab2 > itab1.
    

    Executable Example

    Comparing Internal Tables.

    Continue

    Comparing Internal Tables