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 Type of Calculation Expressions
rel_exp - Comparison Type of Arithmetic Expressions
Arithmetic expressions can be used as operands of comparison expressions using relational operators for all data types. It is possible to compare an arithmetic expression with a single operand of a numeric data type or with another arithmetic expression.
The calculation type
of all arithmetic expressions in a comparison expression is determined by all single operands of the entire comparison expression as well as by any operators **
, using the
usual rules. The result of the arithmetic expressions involved exists in the calculation type. This calculation type is also the
comparison type whose
comparison rules are used to make the comparison. If necessary, single operands are
converted to the comparison type before the comparison starts.
If multiple relational expressions are joined as a logical expression using Boolean operators, the calculation type or relational type are determined separately for each relational expression.
Other versions: 7.31 | 7.40 | 7.54
Notes
- If a conversion error occurs in an arithmetic expression in a relational expression, the corresponding exception can be handled (unlike in direct comparisons of data objects).
- To compare an arithmetic expression with a single non-numeric operand, the operand can be prefixed with the "
+
" sign to turn it into an arithmetic expression.
- An arithmetic expression cannot be specified as the operand of a predicate expression.
Example
The following comparisons are both true. In the first, the calculation type is i
and the result of the calculation is rounded to 1. In the second, the calculation type is decfloat34
and there is no rounding.
IF 4 / 3 = 1.
cl_demo_output=>write( '4 / 3 = 1' ).
ENDIF.
IF 4 / 3 > CONV decfloat34( 1 ).
cl_demo_output=>write( '4 / 3 > CONV decfloat34( 1 )' ).
ENDIF.
cl_demo_output=>display( ).