SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

Create Calculation View and Expose via CAP (SAP HANA Cloud)

Learn how to combine HANA native artifacts, like calculation views, with SAP Cloud Application Programming Model (CAP)

Overview

🎓 beginner 20 min. SAP HANA CloudBeginnerSAP HANASAP Business Application StudioSAP Cloud Application Programming Model

You will learn

  • โœ”The basics of creating HANA Native Artifacts within a Cloud Application Programming Model project
  • โœ”How to create SAP HANA calculation views
  • โœ”How to integrate SAP HANA native artifacts, like calculation views, within the SAP Cloud Application Programming Model
Thomas Jung T Thomas Jung January 15, 2025
Created by March 1, 2021
Contributors

Prerequisites

Prerequisites

  • This tutorial is designed for SAP HANA Cloud. It is not designed for SAP HANA on premise or SAP HANA, express edition.
  • You have created database artifacts and loaded data as explained in the previous tutorial.

Steps

Video Version

Video tutorial version:

Step 1 Create calculation view
โ€”

With the SAP Cloud Application Programming Model and its implementation of Core Data Services (CDS), we don’t directly import a Calculation View or other native DB artifact. This import, however, is important if you want to expose these artifacts via OData V4 services, since that requires a CDS entity or view.

But CDS does have an annotation called @cds.persistence.exists. This annotation allows you to re-define an existing DB object and CDS won’t attempt to create or alter it. It will just assume it already exists in the matching state.

This feature does require you to completely redefine the DB artifact with exactly the same name, columns and column names.

In this exercise, lets see how we can create a calculation view and other artifacts and expose them to CDS.

For more details on this topic, including advanced features such as parameters and quoted names, please refer to the online documentation here: https://cap.cloud.sap/docs/advanced/hana#create-sap-hana-native-object

Calculation Views and other HANA native artifacts allow you to leverage HANA specific features and optimizations that might not otherwise be available at the abstraction layers within the SAP Cloud Application Programming Model. Calculation Views are especially good at aggregation and filtering of large datasets. In this exercise will create a simple join Calculation View based upon or small data set and data model. This is done so we focus on the mechanics of combining HANA native with CAP without needing the typical large data set where the technical advantages of Calculation Views become more apparent.

  1. Create a new Calculation View via View > Command Pallette and then SAP HANA: Create SAP HANA Database Artifact command pallet entry.

    New calculation view
    New calculation view

  2. Create a calculation view called V_INTERACTION of Data Category DIMENSION and Dimension Type of STANDARD. Press Create

    Create calculation view
    Create calculation view

  3. The new artifact is created in the /db/src folder. This way you can have a single HANA database model that contains both HANA native content and CAP generated content.

    View created in the /db/src folder
    View created in the /db/src folder

  4. Click on the V_INTERACTION.hdbcalculationview to load the graphical calculation view editor.

    Calculation View editor
    Calculation View editor

Step 2 Model the join relationship
+
Step 3 Create calculation view proxy entity
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 3
1. Create calculation view 2. Model the join relationship 3. Create calculation view proxy entity

Learn more →