Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Access →  ABAP SQL →  ABAP SQL - Operands and Expressions →  ABAP SQL - SQL Expressions sql_exp 

sql_exp - sql_case

Other versions: 7.31 | 7.40 | 7.54

Syntax Forms


Simple case distinction

1. ... CASE sql_exp
           WHEN sql_exp1 THEN result1
          [WHEN sql_exp2 THEN result2]
           ...
          [ELSE resultn]
      END ...


Complex case distinction

2. ... CASE WHEN sql_cond1 THEN result1
          [WHEN sql_cond2 THEN result2]
          [WHEN sql_cond3 THEN result3]
            ...
          [ELSE resultn]
      END ...

Effect

Case distinction in ABAP SQL. Either a simple case distinction (simple case) or a complex case distinction (searched case).


Notes

  • Specifying a case distinction always means specifying an SQL expression. Case distinctions can only be specified for operand positions for which SQL expressions are possible.

  • A conflict between SQL language element CASE and a column named CASE cannot occur because ABAP Dictionary does not permit a column with this name to be created. However, if a column with this name does exist, it must be prefixed with the escape character ! when it is specified in an ABAP SQL statements.

  • A maximum of 10 case distinctions can be nested with CASE.

Continue

sql_exp - sql_simple_case

sql_exp - sql_searched_case