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 - Comparisons of Elementary Data Objects
log_exp - Comparing Byte-Like Data Types
The following tables show the comparison types for comparisons between byte-like data types and other data types. If the type of an operand is not the same as the comparison type, then it is converted to this type.
Other versions: 7.31 | 7.40 | 7.54
Comparisons with Numeric Data Types
- | xstring, x |
---|---|
decfloat34 | decfloat34 |
decfloat16 | decfloat34 |
f | f |
p | p |
i, s, b | i |
Length Adjustments
The comparison type p
has 31 decimal places and the number of places in the decimal portion in the operand of type p
.
Note
When converting byte-like data types to numeric types, note that all bytes are ignored except for the final four.
Comparisons with Character-Like Data Types
- | xstring | x |
---|---|---|
string | string |
string |
c | string |
c |
n | p |
p |
d,t | i |
i |
Length Adjustments
- When data type
c
is compared withx
or xstring, the shorter field is adjusted to the length of the longer field after conversions fromx
toc
orxstring
tostring
. Blanks are used as filler on the right.
- Lengths are not adjusted for comparisons between the data type
string
andx
orxstring
.
Comparisons with Byte-Like Data Types
- | xstring | x |
---|---|---|
xstring | xstring |
xstring |
x | xstring |
x |
Length Adjustments
- Operands of data type
xstring
with different lengths never match. If the contents of the operands match for the length of the shorter operand, the shorter operand is smaller than the longer one. Otherwise the surplus bytes in the longer field are truncated on the right, and then the content is compared.
- For comparisons between two operands of data type
c
, the shorter field is converted to the longer field, with hexadecimal 0 used as filler on the right.
Example
The first comparison uses the appropriate conversion
rules to convert the hexadecimal content "FF00" of hex
to the string "FF00"; this string is then compared with "FFxx". Before the second comparison, the appropriate
conversion rules are used to convert the content
of text
to the hexadecimal value "FF00" in the helper variable hex_helper
and this value is compared with the content of hex
.
DATA hex TYPE x LENGTH 2.
DATA text TYPE c LENGTH 4.
DATA hex_helper TYPE x LENGTH 2.
hex = 'FF00'.
text = 'FFxx'.
IF hex <> text.
WRITE: / hex, '<>', text.
ENDIF.
hex_helper = text.
IF hex = hex_helper.
WRITE: / hex, '=', hex_helper.
ENDIF.