Blogs / SAP / SAP BW/HANA / SAP BW / A Guide To Convert HANA Calculation Views to CDS Views

A Guide To Convert HANA Calculation Views to CDS Views

Aug 2, 2019


The recent studies on data modeling guides users, to implement or model as much as you can at the database level. In SAP, we have the calculation views and CDS views that use the pushdown mechanism to consume the data at the database level rather than at application.

Use Case for Migrating HANA Calculation Views to CDS

To consume HANA Calculation views in the reporting tools like Analysis for Office or SAP Analytics Cloud, the users should be defined at the database level. From a security standpoint, many customers do not prefer creating users at the database level. Customers using S/4 HANA for reporting can migrate from calculation views to ABAP CDS, implying the maintenance of authorizations at SAP NetWeaver Gateway which eliminates the authorizations at the DB level.

With the introduction of S/4 HANA and reporting capabilities from the ERP system, SAP created standard content on the database tables with CDS views which are readily available for the end-users for reporting purposes. With the reporting enabled on the ERP system, the users will be able to analyze the live data as soon as the data is posted in the ERP systems.

Checklist for the Conversion

Following are the basic parameters to consider for the basic conversion

  1. Naming Standards
  2. Types of calculation view (Master or Transaction)
  3. View types (Private, Reuse and Reporting (Queries))
  4. Client Handling
  5. Variables and parameters
  6. Aggregation types & Assigning UOM/Currency Code

Naming Standards

1) File suffix
The file suffix differs according to SAP HANA XS version:

  • XS classic: hdbdd, for example, MyModel.hdbdd.
  • XS advanced: hdbcds, for example, MyModel.hdbcds.

2) Permitted characters

  • CDS object and package names can include the following characters:
  • Lower or Upper-Case letters (aA-zZ) and the underscore character (_)
  • Digits (0-9)

3) Forbidden characters
The following restrictions apply to the characters you can use (and their position) in the name of a CDS document or a package:

  • You cannot use either the hyphen (-) or the dot (.) in the name of a CDS document.
  • You cannot use a digit (0-9) as the first character of the name of either a CDS document or a package, for example, 2CDSobjectname.hdbdd (XS classic) or (XS advanced).
  • The CDS parser does not recognize either CDS document names or package names that consist exclusively of digits, for example, 1234.hdbdd (XS classic) or 999.hdbcds (XS advanced).

VDM/Analytic models Types

In the conversion of HANA Calculation views to CDS Views choosing the right Virtual/Analytic data model plays an important role in how the data needs to be accessed.

Business data of an SAP system is exposed as an understandable, relatable, reusable, executable, stable and compatible platform for Consumers using VDM and hence the data model of a view can be defined as,

HANA Calculation ViewCDS ViewsDescription
Private Views@VDM.viewtype: #BASICCreated on top of DDIC Tables/ Views with no redundancies
Reuse Views@VDM.viewtype: #COMPOSITEDerived or composed of BASIC Views that includes Joins/Association, calculated field, etc 
Query Views@VDM.viewtype: #CONSUMPTIONExpose data to different analytical tools hence can be built on top of BASIC or COMPOSITE views

Data Aggregation, slicing, and dicing of data, data consumption at a multi-dimensional level are done by enabling Analytical Manager. The Type of a view can be defined as follows and hence the Analytic Manager knows how to interpret the data.

HANA Calculation ViewCDS ViewDescription
Dimension based Calculation View / Attribute View@Analytics.dataCategory: #DIMENSIONRepresents the Master Data and can be used for Replication
Star Join based Calculation View / Analytic View@Analytics.dataCategory: #FACTCentre of Star Schema, it contains only measures and needed for Replication hence not joined with Master Data
Cube based Calculation View@Analytics.dataCategory: #CUBEFactual data with redundancies as It includes Master data join, data is replicated from facts and query can be built on top of it
Not Applicable@Analytics.dataCategory: #AGGREGATIONLEVELWrite Back Functionality consuming a CUBE view

Client Handling

Client Dependency in the view can be determined by using the @ClientHandling.type annotation. The default value for the view is @ClientHandling.type:  # INHERITED

HANA Calculation ViewAnnotationDescription
Session ClientCLIENT DEPENDENTClient Specific
Cross ClientCLIENT INDEPENDENTCross Client
Not ApplicableINHERITEDIt depends on the Data sources used. The view is client-specific if at least one of the data sources is client-specific. The view is cross-client if none of the data sources is client-specific.

Client Handling algorithm can be specified to understand the Implicit Performance. It expands the Join Condition between the data sources in the view and behaves accordingly. The Default Value for the view is @ClientHandling.Algorithm: #AUTOMATED

AnnotationCan be GroupedCannot be Grouped

Aggregation Types & UOM

The aggregation in calculation views can be defined in 2 types

  1. Native SQL
  2. CDS Incorporated

SQL approach supports most of the aggregation types defined in SQL standards. Supported functions are Sum, Min, Max, Avg, Count, Var, Stddev.

A Guide To Convert HANA Calculation Views to CDS Views

In a CDS specific approach, the semantics are defined to specify what type of aggregation needs to happen. The supported aggregation types as shown in the below image.

A Guide To Convert HANA Calculation Views to CDS Views

The aggregations are defined with annotation @DefaultAggregation: #(Aggregations type as mentioned n the above image).

We can also declare a characteristic as a Unit of Measure/Currency Code with @Semantics.unitOfMeasure:true @Semantics.currencyCode: true.

A UOM/Currency can be applied to a measure to show meaningful data at the reporting layer using

@Semantics.quantity.unitOfMeasure: ‘Quantity Field Name’

@Semantics.amount.currencyCode: ‘Currency Field Name

A Guide To Convert HANA Calculation Views to CDS Views

Parameters and Variables

The parameters in CDS Views helps you to filter the data at the base node and once the parameter is declared, it is mandatory in nature. The CDS view with parameters are declared after defining the view Name with syntax as follows.

Define View /*ViewName*/ with parameters

Parameter1 : abap.char( 10 )

Parameter2: Dats


A Guide To Convert HANA Calculation Views to CDS Views

Like the ‘Manage Mappings’ option in HANA calculation views which push down the Input Parameters from the top-level calculation view to the base level, CDS views also allow the push down of the filters using the below syntax.

A Guide To Convert HANA Calculation Views to CDS Views

Like the ‘Variables’ in HANA Calculation Views, CDS views allows the creation of variables at the Query model. They use the annotation ‘viewType’ with value ‘Consumption’ as below.

A Guide To Convert HANA Calculation Views to CDS Views

Possible types inside the variable are as follows

DefaultValueAny Constant Value

Know more about our Visual BI offerings and to read more related content click here.

Corporate HQ:
5920 Windhaven Pkwy, Plano, TX 75093

+1 888-227-2794

+1 972-232-2233

+1 888-227-7192

Copyright © Visual BI Solutions Inc.

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!

Share This!

Share this with your friends and colleagues!