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 - Comparison of Structures

It is possible to compare structures to structures and to elementary fields.

  • The system compares compatible structures on a component-by-component basis, resolving nested structures recursively. Two structures are equal if the contents of their components are equal. If two structures are not equal, the first unequal component pair determines the result of the comparison.
  • It is possible to compare incompatible structures and structures with elementary fields provided that the structures concerned are flat.
  • Comparisons between two flat structures require that their Unicode fragment views match for the length of the shorter structure. Before starting the comparison, the system fills the shorter structure up to the length of the longer structure. In this process, the system fills all character-like components with spaces and all other components with a type-related initial value. The comparison is then performed on a section-by-section basis according to the Unicode fragment view.
  • Comparisons between a flat structure and an elementary field are subject to the following rules:

    If the flat structure is character-like, it is handled like an elementary field with the type c in the comparison.

    If the flat structure is not just character-like, the elementary field must have the type c and the first Unicode fragment of the structure must be character-like and at least as long as the elementary field. If the elementary field is shorter than the structure, the system extends it to the length of the structure before starting the comparison and then handles it implicitly like a structure. The character-like parts of the extension are filled with spaces and all other components are filled with the type-related initial value.

Other versions: 7.31 | 7.40 | 7.54


Note

The Unicode fragment view is ignored in obsolete non-Unicode programs. Instead, each structure is converted to an elementary field with the type c before the comparison and the comparison is then performed in the same way as for elementary fields.