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 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 ViewCDS ViewsDescription
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 ViewCDS ViewDescription

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 ViewAnnotationDescription
Session ClientCLIENT DEPENDENTClient Specific
Cross ClientCLIENT INDEPENDENTCross Client
Not ApplicableINHERITED

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

AnnotationCan be GroupedCannot be Grouped
AUTOMATEDINHERITED, CLIENT DEPENDENTCLIENT INDEPENDENT
SESSION_VARIABLEINHERITED, CLIENT DEPENDENTCLIENT INDEPENDENT
NONECLIENT INDEPENDENTINHERITED, CLIENT DEPENDENT

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.guide-convert-hana-calculation-views-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.
guide-convert-hana-calculation-views-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
guide-convert-hana-calculation-views-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

Ex:
guide-convert-hana-calculation-views-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.guide-convert-hana-calculation-views-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.
guide-convert-hana-calculation-views-cds-views

Possible types inside the variable are as follows

TYPESVALUES
SelectionTypeHIERARCHY_NODE, INTERVAL, RANGE, SINGLE
DefaultValueAny Constant Value
MandatoryBoolean
MultipleSelectionsBoolean

 

 

REFERENCES

https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/7.5.9/en-US/efe9c80fc6ba4db692e08340c9151a17.html

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.

Subscribe to our Newsletter

5920 Windhaven Pkwy
Plano TX 75093.

+1 888-227-2794

+1 972-232-2233

+1 888-227-7192

solutions@visualbi.com