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

SAP HANA Native, Create Database Artifacts Using Core Data Services (CDS)

Use core data services to generate SAP HANA basic database artifacts.

Overview

🎓 beginner 15 min. SAP HANABeginnerExpress Edition

You will learn

  • โœ”How to use core data services to create simple database entities
  • โœ”How to define database-agnostic artifacts in the persistence module
Thomas Jung T Thomas Jung November 1, 2022
Created by July 25, 2019
Contributors

Prerequisites

Prerequisites

  • This tutorial is designed for SAP HANA on premise and SAP HANA, express edition. It is not designed for SAP HANA Cloud.
  • You have created an application using the Business Application wizard.

Steps

Intro

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 1 Create 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
Create Database entities

Use the following name:

Name
interactions.cds

Double-click on the file to open it.

Create Database entities
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 2 Adapt service call
+
Step 3 Explore the generated design-time artifacts
+
Step 4 Check the Database Explorer
+
Step 5 Load data into your tables
+
Step 6 Check data loaded into the tables
+

Resources

Discussion

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

Submit detailed feedback Discuss in Community
Steps
Step 1 of 6
1. Create database entities 2. Adapt service call 3. Explore the generated design-time artifacts 4. Check the Database Explorer 5. Load data into your tables 6. Check data loaded into the tables

Learn more →