SAP NetWeaver AS ABAP Release 750, ©Copyright 2016 SAP AG. All rights reserved.
ABAP - Keyword Documentation → ABAP - Dictionary → ABAP CDS in ABAP Dictionary → ABAP CDS - Data Definitions → ABAP CDS - DDL Statements → ABAP CDS - DEFINE VIEW → ABAP CDS - SELECT → ABAP CDS - SELECT, Operands and Expressions → ABAP CDS - case_expr →ABAP CDS - searched_case_expr
Syntax
... CASE WHEN cond_expr1 THEN result1
[WHEN cond_expr2 THENresult2]
[WHEN cond_expr3 THENresult3]
...
[ELSE resultn]
END ...
Effect
Complex case distinction (searched case) in a SELECT statement of a CDS view in ABAP CDS. Case distinction evaluates the sequence of conditions cond_expr1, cond_expr2, ... and returns the operand result as the result after THEN, for which the condition is true for the first time. If none of the conditions are true, the result specified after ELSE is selected. If ELSE is not specified, the result is the zero value. Special rules apply when specifying the conditions.
Example
The following CDS view has a complex case distinction in the SELECT list.
Das Programm DEMO_CDS_SEARCHED_CASE greift mit SELECT auf die View zu und stellt das Ergebnis dar.