SAP CDS ELEMENT APV Get Example source ABAP code based on a different SAP table
SAP Help
• LOCALIZED ABAP_CDS_ANALYTICAL
• VIRTUAL ABAP_CDS_ANALYTICAL
ABAP_CDS_DDL - element>, Analytical Query ABAP_SYNTAX ... $[@element_annot1>$] $[@element_annot2>$] ... ${ field $[AS alias$] $} $| ${ path_expr >.element $[AS alias$]$[: LOCALIZED$]$} $| ${ arith_expr> AS alias $} $| ${ builtin_func> AS alias $} $| ${ Analytical Scalar Functions> AS alias $} $| ${ case_expr> AS alias $} $| ${ VIRTUAL calculated unit> AS alias $} $| ${ parameter> AS alias $} $| ${ session_variable> AS alias $} $| ${ typed_literal> AS alias $} $| ${ cast_expr> AS alias $} $| ${ $projection.reuse_exp> AS alias $}> ABAP Addition 1 ... AS alias> 2 ... LOCALIZED> 3 ... VIRTUAL> What does it do? Defines an element in the element list of a CDS analytical projection view>. Elements in the element list of an analytical projection view can be analytical formulas>, selections>, dimension fields, text fields or attributes, or CDS amount and quantity fields. See the topic about the conceptual background of analytical queries> for further details. The rules for propagation of element annotations in CDS projection views> apply. field> exposes an element from the projected entity>. AS > can be used to define an alternative element name alias>. In analytical projection views, measure> fields can be exposed multiple times with different alias names. Dimension fields> can be exposed only once. Analytical measure fields and analytical dimension fields from the projected entity remain analytical measures and dimensions and their type must not be changed in the projection layer. path_expr>.element> exposes an element of an association target of the projected entity>. If no alternative element name alias> is defined, the original element name of the element picked by the path expression is reused. For details, see the topic about path expressions in analytical queries>. arith_expr>> can be used to specify an arithmetic expression>. The annotation Aggregation.default: #FORMULA > is mandatory when an arithmetic expression is included as a field in the element list. Arithmetic expressions are evaluated by the analytical engine when the analytical query is accessed. An alternative element name alias > must be defined with the keyword AS>. ABAP_NOTE Arithmetic expressions must not have any path fields specified using path_expr.element> as operands. The following built-in functions builtin_func>> are supported: CURR_TO_DECFLOAT_AMOUNT>> GET_NUMERIC_VALUE>> DATS_DAYS_BETWEEN>> DATS_ADD_DAYS>> CURRENCY_CONVERSION>>: The following special rules apply: amount> can be either a field of the CDS projected entity>, or the function CURR_TO_DECFLOAT_AMOUNT> with a field of the projected entity> as argument arg>. No other expression or operand is allowed as operand for amount>. source_currency> must be a field of the projected entity>. target_currency> must not be a reuse expression specified using $projection>>. The following optional parameters are not supported: client>, round>, decimal_shift>, decimal_shift_back>, and error_handling>. UNIT_CONVERSION>>: The following special rules apply: quantity> and source_unit> must be defined as a field of the projected entity>. target_unit> must not be a reuse expression specified using $projection >>. The following optional parameters are not supported: client>, error_handling>. The annotation Aggregation.default: #FORMULA> is mandatory for built-in functions. Analytical scalar functions> can be specified as elements. An alias name is mandatory. case_exp>> can be used to specify case distinctions>. In an analytical query, case distinctions define analytical formulas> or restricted measures>. See topic TITLE > for further details. Calculated units> can be defined using the keyword VIRTUAL> in CDS analytical projection views. By that, the analytical runtime automatically fills in the required value for the unit. parameter> can be used to specify a parameter from the parameter list>. An alternative element name using the keyword AS> must be defined and it cannot be the name of the parameter. In analytical queries, parameters must have either a numeric data type (except for NUMC>), or a unit or currency key. The annotation Aggregation.default: #FORMULA> is mandatory when a parameter of a numeric data type is included as a field in the element list. No annotation is required when a parameter is used as an operand in a formula >. session_variable>> can be used to specify a session variable>. AS > must be used to define an alternative element name alias>. The following session variables are supported in the element list of analytical queries: system_date> and user_date>. The annotation Aggregation.default: #FORMULA> is mandatory when a session variable is included as a field in the element list. No annotation is required when a session variable is used as an operand in a formula> or selection>. typed_literal>> can be used to declare a typed literal>. AS > must be used to define an alternative element name alias >. In analytical queries, typed literals must have either a numeric data type (except for NUMC>), or a unit or currency key. The annotation Aggregation.default: #FORMULA> is mandatory when a numeric typed literal is included as a field in the element list. No annotation is required when a typed literal is used as an operand in a formula> or selection>. ABAP_NOTE untyped literals> are not supported in the element list of analytical projection views. cast_expr>> can be used to specify cast expressions>. For a cast expression, an alias name must be specified with the keyword AS>. $projection.reuse_exp>> reuses an expression defined in the SELECT> list in another operand position of the same analytical projection view. An alternative element name specified using AS> is required. ABAP_RESTRICTIONS Exposing associations from the projected entity is not allowed. The definition of key fields using KEY> is not allowed. ABAP_RESTR_END ABAP_EXAMPLE_VX5 The following CDS analytical projection view DEMO_ANALYTICAL_QUERY_ELEM>> defines an analytical query. It is based on the cube view DEMO_CDS_CUBE_VIEW>>. DDLS DEMO_ANALYTICAL_QUERY_ELEM ABAP_EXAMPLE_END ABAP Addition What does it do? Defines an alternative element name for the projected element. The alternative element name replaces the actual name of the element from the projected entity>. The view field is created under the alternative element name in the CDS projection view. Accordingly, the alternative element name must comply with the general syntax rules for names>. ABAP Addition What does it do? The keyword LOCALIZED> must be used to display text elements in the current system language. See ABAP Addition View, proj_element>>. ABAP Addition What does it do? The keyword VIRTUAL> defines a CDS virtual element> in a CDS projection view. In general, CDS virtual elements calculate field values during runtime, see topic TITLE >. In analytical queries, a virtual element is mostly used to define a calculated unit> for a calculated quantity>. By using VIRTUAL>, the analytical runtime automatically fills in the required value for the unit by interpreting the referred calculated quantity. ABAP_NOTE In an analytical query, the annotation @ObjectModel.virtualElementCalculatedBy>>, which connects the virtual element to an ABAP class that calculates a value at runtime, is not supported.