Get Example source ABAP code based on a different SAP table
• CASE ABAP_CDS_ANALYTICAL • WHEN ABAP_CDS_ANALYTICAL • THEN ABAP_CDS_ANALYTICAL • ELSE ABAP_CDS_ANALYTICAL • ELSE NULL ABAP_CDS_ANALYTICAL • END ABAP_CDS_ANALYTICAL
ABAP_CDS_DDL - case_expr>, Analytical Query
ABAP_SYNTAX_FORMS
Selection-Related Case Expression (Restricted Measure) 1 ... CASE WHEN cds_cond> THEN result $[ELSE NULL$] END ...>
Formula-Related Case Expression 2 @Aggregation.default: #FORMULA CASE WHEN cds_cond> THEN result1 ELSE ${result2 $| NULL$} END ...> ITOC
What does it do? Case distinction> in the element list> of an analytical query. Either a selection-related case expression (restricted measure) or a formula-related case expression.
ABAP_EXAMPLE_VX5 The following CDS analytical projection view DEMO_CDS_ANALYTIC_CASE>> defines an analytical query. It is based on the cube view DEMO_CDS_CUBE_VIEW>>. The projection view defines one selection-related case expression and one formula-related case expression. DDLS DEMO_CDS_ANALYTIC_CASE ABAP_EXAMPLE_END
Selection-Related Case Expression (Restricted Measure)
ABAP_SYNTAX ... CASE WHEN cds_cond> THEN result $[ELSE NULL$] END ...>
What does it do? Case expression in a CDS analytical projection view that defines a selection. There must be exactly one WHEN> branch. A regular ELSE> branch is not allowed. ELSE NULL> is available (optionally) to explicitly define the null value as result if no matches are found. The following is allowed as result> specified after THEN>:
A field of a data source specified as analytical measure>.
The built-in functions CURR_TO_DECFLOAT_AMOUNT>>, CURRENCY_COVERSION>>, and UNIT_CONVERSION>>.
A numeric typed literal> of a measure-like data type or the untyped literal> 1. A literal is only allowed if the element is annotated with AnalyticsDetails.query.onCharacteristicStructure: true> and when this annotation is used, a literal is mandatory. The following rules apply to the condition cds_cond>> specified after WHEN>:
All comparison operators> are supported.
$[NOT$] BETWEEN >>, LIKE>>, and IS $[NOT$] INITIAL>> are supported. ABAP_NOTE NOT LIKE> is not supported.
The Boolean operators> AND>, OR>, and NOT> are allowed. Identical fields must be combined with OR> and different fields must be combined with AND>. ABAP_NOTE A filter condition does not support nested negations. The following is not supported: AND NOT field_a <> 'B>. The reason is that NOT > and <> are both negations.
lhs> expects a field of the projected entity>. The field must be classified as analytical dimension field>.
rhs> can be a parameter>, a session variable, or a typed literal>.
Path expressions> are not supported as operands.
Formula-Related Case Expression
ABAP_SYNTAX ... @Aggregation.default: #FORMULA CASE WHEN cds_cond THEN result1 ELSE ${result2 $| NULL$} END ...>
What does it do? Formula-related case expression in the element list of an CDS analytical projection view. The case distinction evaluates the condition cds_cond>> and returns either the operand result1> specified after THEN>, or the operand result2> specified after ELSE>. result2> can also be the null value. ELSE NULL> is available to explicitly define the null value as result if no matches are found. There must be exactly one WHEN> branch, one THEN> branch, and one ELSE> branch. The annotation @Aggregation.default: #FORMULA> is mandatory for formula-related case expressions. result1> and result2> must be specified as a field of a data source with a data type valid for analytical measures >, numeric typed literals> (except for data type NUMC>), or numeric parameters > (except for data type NUMC>). The following rules apply to the condition specified after WHEN>:
All comparison operators> except for <> are supported.
IS INITIAL> > is supported. BETWEEN >>, LIKE >>, and IS NULL>> are not allowed.
The Boolean operators> AND> and OR> are allowed.
lhs> expects either a field of the projected entity> that has a data type valid for analytical measures, a built-in function>, or an input parameter.
rhs> can be a field of a data source specified as analytical measure>, a built-in function, a parameter>, a session variable, or a typed literal> of one of the following data types: DEC>, DECFLOAT16>, DECFLOAT34>, FLTP >, DF16_DEC>, DF34_DEC>, DF16_RAW>, DF34_RAW>, INT1>, INT2>, INT4>, INT8>, DATS>, DATN>, TIMN>, TIMS>.