ARTICLE
rel_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, it is
converted to this type.
Comparisons with Numeric Data Types
- xstring , x
decfloat34 decfloat34
decfloat16 decfloat34
f f
p p
int8 int8
i , s , b i
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
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.
cl_demo_output=>write_text( |{ hex } <(><<)>> { text } | ).
ENDIF.
hex_helper = text.
IF hex = hex_helper.
cl_demo_output=>write_text( |{ hex } = { hex_helper } | ).
ENDIF.
cl_demo_output=>display( ).
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved