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 Elementary Data Types 

rel_exp - Comparison Rules for Comparison Types

When operands with elementary data types are compared, the comparison uses a comparison type defined by the operands in question, as for elementary data objects and calculation expressions. The comparison type be one of the predefined ABAP types. When incompatible operands are compared, the operands that do not have the comparison type are converted to this type.

Other versions: 7.31 | 7.40 | 7.54

Numeric Comparison Type

If the comparison type is one of the numeric data types, the numeric values are compared.


Notes

  • Platform-dependent rounding errors may occur with data type f, which means it often does not make sense to compare floating point numbers to see if they match.

  • Scale and precision are not relevant in comparisons between decimal floating point numbers.

Character-Like Comparison Type

If the comparison type is one of the character-like data types, the content is compared from left to right. Based on the internal binary representation in the code page used, the first differing character from the left determines which operand is greater.


Notes

  • For operands of types c and string, the contents are not compared on the basis of the locale of the current text environment. To specify the order with reference to the locale, the statement CONVERT TEXT can be used.

  • If operands of type n contain a valid string of digits, the proportions of the numbers represented are determined correctly.

  • For operands of types d and t containing a valid date or a valid time, the later date or time is always greater than the earlier one.

Byte-Like Comparison Type

If the comparison type is one of the byte-like data types, the content is compared from left to right. Based on the byte values, the first differing byte from the left determines which operand is greater.