Skip to content

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

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

String expressions are possible when using

and conditions mapped to comparisons for all data types, that is

If one of the operands in a comparison is a string expression, then the comparison type is always string. If necessary, single operands are converted to the type string before the comparison.

Other versions: 7.31 | 7.40 | 7.54


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.