ABAP Keyword Documentation →  ABAP − Reference →  Program Flow Logic →  Expressions and Functions for Conditions →  log_exp - Logical Expressions →  rel_exp - Relational Expressions →  rel_exp - Comparison Rules →  rel_exp - Comparing Elementary Data Types →  rel_exp - Comparisons of Elementary Data Objects → 

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
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

Comparisons with Byte-Like Data Types

- xstring x
xstring xstring xstring
x xstring x

Length Adjustments

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( ).