Skip to content

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 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.

    In non-Unicode programs, the system converts the structures involved to elementary fields of type c before starting the comparison. The comparison is then carried out in the same way as for elementary fields.

    In Unicode programs, comparing two flat incompatible structures requires that the 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-type 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.

    Comparing a flat structure to an elementary field in a Unicode program is subject to the following rules:
  • If a flat structure is character-type, it is handled like an elementary field of type c during comparison.
  • If a flat structure is not purely character-type, the elementry field must be of type c and the first Unicode fragment of the structure must be character-type 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-type 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