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
- Naming Standards
- Types of calculation view (Master or Transaction)
- View types (Private, Reuse and Reporting (Queries))
- Client Handling
- Variables and parameters
- 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 acme.com.1package.hdbcds (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 View | CDS Views | Description |
Private Views | @VDM.viewtype: #BASIC | Created on top of DDIC Tables/ Views with no redundancies |
Reuse Views | @VDM.viewtype: #COMPOSITE | Derived or composed of BASIC Views that includes Joins/Association, calculated field, etc |
Query Views | @VDM.viewtype: #CONSUMPTION | Expose 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 View | CDS View | Description |
Dimension based Calculation View / Attribute View | @Analytics.dataCategory: #DIMENSION | Represents the Master Data and can be used for Replication |
Star Join based Calculation View / Analytic View | @Analytics.dataCategory: #FACT | Centre of Star Schema, it contains only measures and needed for Replication hence not joined with Master Data |
Cube based Calculation View | @Analytics.dataCategory: #CUBE | Factual 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: #AGGREGATIONLEVEL | Write 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 View | Annotation | Description |
Session Client | CLIENT DEPENDENT | Client Specific |
Cross Client | CLIENT INDEPENDENT | Cross Client |
Not Applicable | INHERITED | It 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
Annotation | Can be Grouped | Cannot be Grouped |
AUTOMATED | INHERITED, CLIENT DEPENDENT | CLIENT INDEPENDENT |
SESSION_VARIABLE | INHERITED, CLIENT DEPENDENT | CLIENT INDEPENDENT |
NONE | CLIENT INDEPENDENT | INHERITED, CLIENT DEPENDENT |
Aggregation Types & UOM
The aggregation in calculation views can be defined in 2 types
- Native SQL
- CDS Incorporated
SQL approach supports most of the aggregation types defined in SQL standards. Supported functions are Sum, Min, Max, Avg, Count, Var, Stddev.

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.

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

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
Ex:

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.

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.

Possible types inside the variable are as follows
TYPES | VALUES |
SelectionType | HIERARCHY_NODE, INTERVAL, RANGE, SINGLE |
DefaultValue | Any Constant Value |
Mandatory | Boolean |
MultipleSelections | Boolean |
REFERENCES
https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abencds_client_handling.htm
Know more about our Visual BI offerings and to read more related content click here.