Skip to content

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

String expressions can be used as operands in comparison expressions with

It is possible to compare a string expression with a single operand with any elementary data type or with another string expression.

If one of the operands of a comparison is a string expression, the comparison type whose comparison rules are used to perform the comparison is always string. If necessary, single operands are converted to the type string before the comparison.

Other versions: 7.31 | 7.40 | 7.54


Note

A string expression cannot be specified as the operand of a predicate expression.


Example

This example demonstrates the effect of different comparison types. The first comparison is true, since the character-like operand is converted to the type of the numeric operand (in accordance with the rule for comparing character-like data types) and the numeric value is compared. The second comparison is false, since the numeric operand is converted to the type string of the string expression and the internal representation of the code page used is compared.

IF `02` > 1.
  WRITE / 'yes'.
ELSE.
  WRITE / 'no'.
ENDIF.

IF |02| > 1.
  WRITE / 'yes'.
ELSE.
  WRITE / 'no'.
ENDIF.