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 Elementary Data Types → log_exp - Comparing Calculation Expressions
log_exp - Comparison of Bit Expressions
A bit expression can be compared with a single operand of a byte-like data type or with another bit expression.
Bit expressions are possible for
and conditions mapped to comparisons for all data types, that is
Each bit expression of a logical expression is calculated based on the length of its longest operand, with shorter operands filled on the right with hexadecimal 0. All operands of the entire logical expression are respected. The result of the bit expressions involved is contained within this length and, if necessary, a single operand is converted to this length before the comparison, again by filling with hexadecimal 0 on the right. The comparison is then performed using the rule for a byte-like comparison type.
Other versions: 7.31 | 7.40 | 7.54
Example
This example demonstrates the different ways lengths are handled in comparisons between byte fields
and bit expressions. The bit expression in the first comparison is evaluated with length 4 and produces
the value hexadecimal 1100. The single operand on the right is converted to the value hexadecimal 1100
by filling with hexadecimal 00 and the equality comparison is true. In the second comparison, on the
other hand, the operand on the left is converted to the type xstring
and the operand on the right is not made longer. Here, the inequality comparison is true.
IF x`FFFF` BIT-AND x`11` = xstring`11`.
WRITE / 'yes'.
ENDIF.
IF x`1100` <> xstring`11`.
WRITE / 'no'.
ENDIF.