Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Analytic (Query) Annotations

In this page we want to provide simple examples for the most important annotations used by the Analytic Engine. S ee also Embedded Reporting on ABAP CDS views for more information to the CDS Views used in BW. Please note that also some non-analytics annotations are used by the OLAP Engine as you can see below.

Two important analytic annotations:

  • CDS views with the annotation @Analytics.query: true are transient queries which can be interpreted by the Analytic Engine.
  • CDS views with the analytic annotation @Analytics.dataCategory:#CUBE are transient BW providers.

BW InfoProvider: @Analytic.dataCatgegory: #CUBE

The analytic annotation Analytics.dataCategory can be used to create an BW provider by using the value #CUBE, see Simple BW Provider based on CDS View.

Data Extraction

@Analytics.dataExtraction.enabled: If set to true, the view(CUBE) suitable for data replication. This is the default setting. See also Delta enabled extraction from CDS views .

(Component for @Analytics.dataExtraction:  BC-BW-ODP)


@Aggregation.default or @DefaultAggregation: When the DefaultAggregation annotation has been specified for an element, the corresponding elements are used as so called measures (elements that can be aggregated) in analytical scenarios. See Simple BW Provider based on CDS View.


Currency Key Figures
  • @Semantics.currencyCode This annotation tags a field containing a currency code
  • @Semantics.amount.currencyCode The annotated field contains a monetary amount, and the corresponding currency code is contained in the referenced field.

See Simple BW Provider based on CDS View. key figure FlightPrice(text:Airfare).

Quantity Key Figures
  • @Semantics.unitOfMeasure This annotation tags a field containing a unit of measure
  • @Semantics.quantity.unitOfMeasure The annotated field contains a quantity, and the corresponding unit of measure is contained in the referenced field
Association to DIMENSION(BW Infoobject)

@ObjectModel.foreignKey.association: see CUBE with association to DIMENSION.

Access Control/Authorization Check

It is possible to restrict the access to certain values of fields/Infoobjects by using CDS access controls  which are based on CDS roles. The annotation @AccessControl.authorizationCheck: #CHECK  can be used for data category CUBE and DIMENSION( a query ignores such a annotation). See CDS Access Controls for further details.

BW InfoObject: @Analytic.dataCatgegory: #DIMENSION

Corresponds to a BW InfoObject: see CUBE with association to DIMENSION.

More info: IOBJ in CDS

BW Hierarchy: @ObjectModel.dataCategory: #HIERARCHY

Corresponds to a BW Presentation Hierarchy

Hierarchy is defined on infoprovider CDS, however they are only interpreted by the Analytic Engine when it is used in a CDS query with @AnalyticsDetails.query.

See: Using Hierarchies in CDS

BW Query: @Analytics.query: true

In order to specify which views will be exposed to the analytic engine, the following annotation is used:

@Analytics.query: true.

The query views are built on top of views classified as #CUBE or #DIMENSION (master data reporting). They inherit the dimensions, measures and the hierarchies from the reuse view.


Filter variables of the BW query can be expressed with @Consumption.filter annotations in CDS. As an alternative to the filter annotation, you can introduce a parameter and use it in the where clause. See below.

Variables and Filters are always so called hard filters  (characteristic restrictions, see OLAP Filter Handling).


  • Text variables are not supported yet. @EndUserText.label only uses static text.
  • With @Consumption.filter:{selectionType: #RANGE or #INTERVAL, multipleSelections:true}, a selection option variable is generated. With this, exclude or contain patterns are possible. (see Example)
  • Variable derivation troubleshooting, see KBA 2588590 Error 'Variable xxx could not be replaced' in a CDS Query (BRAIN 641)
Filters/Variables by using Parameters

As an alternative to the filter annotation, you can introduce a parameter and use it in the where clause. In that case only single values are supported. The variable is mandatory.


Note: In case a @Filter annotation is used for an element that is filtered in the WHERE condition as well, the filter annotation will be ignored! See Example (at the very bottum)

Sort by Characteristic

If no additional annotation is used, the characteristic values are sorted as defined in filters.

Use annotation: @AnalyticsDetails.query.sortDirection  with #ASC, #DESC


Calculated Elements

the annotation @AnalyticsDetails.query.formula  will only be interpreted by the BW query BADI. It contains an expression representing a numerical value. This expression can contain the following

  • cube measures and/or other numeric elements of the select list
  • arithmetic expressions using operators + - * /
  • functions NDIV0, NODIM, SQRT, SUMGT, SUMCT and SUMRT, which represent the corresponding BW formula functions
  • CASE expressions with at most a single THEN clause (will be translated into BW IF operator)
  • WHEN clause can contain conditional or boolean expressions of measures and/or other numeric elements of the select list
  • ELSE clause is optional (defaulted to ELSE 0 )


Simple CDS View Query with formulas and restrictions  

Restricted Measures

The filters for restricted measures will be modeled via the standard SQL case statement.


Hidden Key Figures

In order to hide measures initially but allow a user to unhide it - annotation @AnalyticsDetails.query.hidden can be used. In order to hide e.g. intermediate calculated fields permanently, the domain specific annotation @Consumption.hidden can be used.

Currency Conversion

Curreny conversion can be defined by using a CDS currency_conversion function expression in a select list entry. See the following examples and SAP Online Help: ABAP CDS - Conversion Functions for Units and Currencies

CUBE: Example

Query: Example

Multidimensional Layout

Attributes and measures can be put on several axes. For this the following annotation can be used: 

  • @AnalyticsDetails.query.axis: #ROWS
  • @AnalyticsDetails.query.axis: #COLUMNS
  • @AnalyticsDetails.query.axis: #FREE (default)

The default value is the free axis. Measures all need to be on the same axis. The default for the measures is to place them on the columns. If the measures should be put on the rows they all need to be annotated to be placed on the rows:


Formula variables

Numeric view parameters can be used as BW formula variables, see Example.

Value Help for Variables

Filter variables inherit their value help from the corresponding Dimension / InfoObject.


F4 D mode is not possible. Only M mode.

Display attributes and texts

Display Attributes and texts can be added by using associations of the cube in the projection list. Elements (keys) and their label elements (texts) are combined by the engine into one field. Whether the analytic engine shows key/text or text/key depends on the order in the projection list

Display Attributes: see CUBE with association to DIMENSION.

Texts: see Cube with association to DIMENSION and TEXT

Exception Aggregation

For calculated elements (not for Restricted Measures) exception aggregation can be defined for CDS queries using the annotaions

  • @AnalyticsDetails: {
  • exceptionAggregationSteps.exceptionAggregationBehavior: #Aggregation,
  • exceptionAggregationSteps.exceptionAggregationElements: ['FieldName']
  • }

The default aggregation behavior cannot be defined in the query. It needs to be defined on the cube layer. Therefore, usage of @DefaultAggregation is restricted to the values #FORMULA for formulas and #NONE for other select list entries.



With the annotation @AnalyticsDetails.query.displayHierarchy you can specify a display hierarchy for an element. This annotation is an enumeration with the following values:

  • #OFF: No display hierarchy
  • #ON: With display hierarchy

Which hierarchy is taken is defined by @AnalyticsDetails.query.hierarchyBinding. If only one hierarchy exists, the hierarchy binding can be omitted.

A CDS hierarchy can be defined using the annotaion @ObjectModel.dataCategory: #HIERARCHY

See Using Hierarchy in CDS for details.

Structures with Hierarchical Display

With the annotation @AnalyticsDetails.query.elementHierarchy you can maintain hierarchical relationships for structural components in a structure

OData Service / ODataQuery

Using the annotation "@OData.publish: true" generates a OData Service when activating the CDS view. See BW OData Queries . 

Run CDS Query in AO

With the annotation @AnalyticsDetails.query:true,  the CDS query 2C<sqlview name> can directly be executed in transaction RSRT (after CDS view activation). However, to run it in frontends like AO (what aklso means that it is available in AO query value help / search for a query),  it needs to be C1-released. In order to check this, you need to open the CDS view with the Hana  Studion(ABAP Development Tool) and check the Properties of the view:

You can use ther Change button to set the state to Released:

If 'API State' is not available in MT, please apply latest MT patch. See also note 2733553.

So far, there is no tool to massive release API State to C1 released yet.

SAP Online Documentation




  • No labels