In this exercise we will learn how to combine HANA native artifacts, like calculation views, with SAP Cloud Application Programming Model (CAP).
Perform all the steps in 👉 tutorial: Create Calculation View and Expose via CAP (SAP HANA Cloud)
You've now experienced Calculation View development in the Business Application Studio. For some of you this might have been a big change from HANA Studio. For others coming from SAP Web IDE, the difference isn't really all that much.
But perhaps more importantly you now know how to create a CAP proxy
entity to import an existing database artifact into CAP (and therefore also use it in the service layer). This can be done for database tables that weren't modeled in CAP or that come from another schema/container as well as SQL Views.
-
This was a very basic Calculation View and perhaps everyone in the room is already familiar with Calculation Views; but if new to the topic -- what is a Calculation View and how is it different from a SQL View?
Answer
A Calculation View is a powerful feature in SAP HANA that allows for complex data transformations and aggregations. It is different from a SQL View in that it can include multiple data sources, advanced calculations, and graphical modeling, whereas a SQL View is a simpler, predefined query on a single table or a set of joined tables. -
Why did we change from a namespace to a context in steps three?
Answer
We changed from a namespace to a context to better organize and encapsulate the entities and services within the CAP model. Contexts provide a way to group related entities and services, making the model more modular and easier to manage. But most important in this case is the need for the proxy entity name to match the underlying database object (in this case the Calculation View) EXACTLY. The namespace is applied to everything in the file, but the context allows us to have the same functionality but only applied to a section of the objects in the cds file. This allows us to have the benefits above for all the native CDS objects but also keep the specific, simple name to match the Calculation View. -
What is
@cds.persistence.exists
doing?Answer
The@cds.persistence.exists
annotation indicates that the entity already exists in the database and should not be created or altered by the CAP framework. It is used to integrate existing database artifacts into the CAP model without modifying them. This is particularly useful when you want to use existing tables, views, or other database objects that were not created by CAP but need to be part of your CAP service. By using this annotation, you ensure that CAP does not attempt to recreate or modify these objects during deployment, thus preserving their original structure and data. -
What is
@cds.persistence.calcview
doing?Answer
The@cds.persistence.calcview
annotation is used to indicate that the entity represents a calculation view in SAP HANA. This allows CAP to recognize and interact with the calculation view as part of the service layer.
- CAP - Using Native SAP HANA Artifacts
- SAP HANA Cloud, SAP HANA Database Modeling Guide for SAP Business Application Studio
- hana-cli inspectView
The
hana-cli inspectView
command is used to inspect the details of a calculation view in SAP HANA. It provides metadata about the view, including its structure, columns, and dependencies. This command is useful for understanding the composition and properties of a calculation view, which can aid in debugging and development.
Continue to 👉 Exercise 7 - Create HANA Stored Procedure and Expose as CAP Service Function (SAP HANA Cloud)