The Cloud Application Programming model utilizes core data services to define artifacts in the database module. Because this model is meant to be database-agnostic – i.e., work with any database – it does not allow you to leverage features that are specific to SAP HANA. For this reason, you will create two tables that do not require any advanced data types.
Step 1Create database entities
โ
In the db module, you will find a file called data-model.cds. Right-click on it and choose Rename.
Create Database entities
Use the following name:
Name
interactions.cds
Double-click on the file to open it.
Create Database entities
Replace the default contents with the following:
CDS
namespace app.interactions;using { Country } from '@sap/cds/common';type BusinessKey : String(10);type SDate : DateTime;type LText : String(1024);entity Interactions_Header { key ID : Integer; ITEMS : association to many Interactions_Items on ITEMS.INTHeader = $self; PARTNER : BusinessKey; LOG_DATE : SDate; BPCOUNTRY : Country;};entity Interactions_Items { key INTHeader : association to Interactions_Header; key TEXT_ID : BusinessKey; LANGU : String(2); LOGTEXT : LText;};
What is going on?
You are declaring two entities with an association to each other. The design-time artifacts declared in this file will be converted to run-time, physical artifacts in the database. In this example, the entities will become tables.
Step 2Adapt service call
+
Locate the other cds file (this file may be called cat-service.cds or my-service.cds, depending on the IDE) in the srv folder and rename it.
Rename service
Use the following name:
Name
interaction_srv.cds
Double-click to open it and replace the existing content with the following:
CDS
using app.interactions from '../db/interactions';service CatalogService { entity Interactions_Header @readonly as projection on interactions.Interactions_Header; entity Interactions_Items @readonly as projection on interactions.Interactions_Items;}
Click Save all.
Build database module
What is going on?
You are declaring services to expose the database entities you declared in the previous step.
Open the package.json file in the root of your project. Add a section to the cds configuration to include the following
JSON
"hana":{"deploy-format":"hdbtable"}
Edit package.json
Right-click on the CDS declaration of the services and choose Build > Build CDS.
Build database module
Look into the console to see the progress. You can scroll up and see what has been built
Build database module
Step 3Explore the generated design-time artifacts
+
If you pay attention to the build log in the console, you will see the CDS artifacts were converted to hdbtable and hdbview artifacts. You will find those artifacts in a new folder under src called gen.
Build database module
You will now convert those CDS files specific to SAP HANA into runtime objects (tables). Right-click on the database module and choose Build.
Build database module
Note: If you get an error during the build process, this could be caused by an older version of the XSA Runtime in HANA, express edition. If your XSA version still contains Node.js version 8.x; this can lead to errors when building because this version of Node.js is no longer supported at the OS level. Newer versions of the XSA runtime only contain Node.js version 10.x and 12.x. If you do receive an error at this point, we would suggest editing the /db/package.json like the following to force the usage of the newer version of the Node.js runtime.
Scroll up to in the console to see what the build process has done.
What is going on?
CDS stands for Core Data Services. This is an infrastructure that allows you to create persistency and services using a declarative language. Notice how you are using the same syntax to define both the persistency and the services.
ย
You can find more information on CDS in the help
You defined a CDS artifact, this is an abstraction, a design-time declaration of the entities to be represented in a database and the services to expose them.
ย Build database module
The original .cds file was translated into hdbtable, which is the SQLDDL syntax specific to SAP HANA when you saved all of the files.
ย Build database module
These hdbtable files were then translated into runtime objects such as tables in the HANA database.
Build database module
If you checked the services in your space, you would see the service for your HDI container.
Build database module
or for the HANA Cloud trial:
Build database module
You can also check the resources in your space using the resource manager in SAP Web IDE:
Build database module
You can find a similar example and further context on Core Data and Services in this explanatory video
Step 4Check the Database Explorer
+
You can now check the generated tables and views in the database explorer. Right-click on the database module and select Open HDI Container.
Build database module
Once open, navigate to the Tables section and double-click on the Header table.
Build database module
Note the name of the table matches the generated hdbtable artifacts. You will also see the physical schema managed by the HDI container.
Unless a name is specified during deployment, HDI containers are automatically created with names relative to the project and user generating them. This allows developers to work on different versions of the same HDI container at the same time.Build database module
Share feedback on this tutorial or join the conversation in SAP Community.
Submit detailed feedbackDiscuss in Community
Steps
Step 1 of 6
1. Create database entities2. Adapt service call3. Explore the generated design-time artifacts4. Check the Database Explorer5. Load data into your tables6. Check data loaded into the tables
Joule
AI Notice
Joule is an AI assistant. Generative AI may produce inaccurate, incomplete, or biased information. Always verify important details before acting on them.
Conversations are sent to SAP-hosted large language models for processing. Do not include personal data, credentials, or confidential information in your messages.
Joule's responses are based on the SAP tutorial catalog and may not reflect the latest product changes. For authoritative guidance, consult the linked tutorials and official SAP documentation.