CDS extension feature in HANA
This blog is about CDS extension in HANA database features, which was added in the HANA 1.0 SPS11. This is a short blog about the CDS table creation and its extension. Just assume that we delivered the data models to customers and if any delta changes in existing table has to be added in DB artifacts without modifying the customer’s existing DB artifacts, Then we will have to create new CDS extension files and add it to database artifacts as part of patch releases. This feature will help the customer or the client to maintain the db artifacts in better way in the production system, Since it will not touch the existing DB artifacts file which is already deployed in the production system of customer. Here we will create a new core data service(HDBCDS) file as a cds extension and deploy it as a patch or service pack release to the customer or the end users. Though the feature supports in SPS11 but the documentation about this feature in detail is mentioned in the HANA 2.0 SPS00 XSA development documents.
2. Core Data Service file(CDS) creation
2.1 Prerequisite: Defining the CDS artifacts, like here I have taken an example of Employee and Order table, along with not to forget that .hdbconfig and .hdbnamespace has to be included in src folder.
Now the catalogue view after successful deployment. In the above cds file, created two table Employee and Order table
2.2 CDS extension and its prerequisite: CDS extension has to have its different set of folder structure that needs to be followed. Each CDS extension package must have the following elements:
- The package descriptor (.package.hdbcds).
- The package descriptor for a CDS extension has no name, only the suffix. Its contents must conform to the required syntax.
- The CDS extension descriptor (myCDSExtension.hdbcds)
- The extension descriptor’s contents must confirm to the required syntax.
Each of the folder must have to have the above necessary extensions files
In the simple scenarios of Employee table, we add a new element (i.e. columns in table) and for that we need to create a new context and new entity class as shown below
The CDS extension employee must contain the following artifacts:
A CDS document containing the definition of the CDS extension package employeeExt/
A CDS document containing the definition of the CDS extension EmployeeExtension
Create a new folder for the CDS extension employeeExt/.
Navigate to the src/ folder in your application’s database module db/, in folder db/src/ and create New Folder in the context menu. Name the new folder “employeeExt”.
Create the CDS extension package descriptor .package.hdbcds.
The .package.hdbcds files and its folder structure screenshots
As mentioned above, I wanted to add new column name “empDeptId” So I have created a Context name EmployeeExtenstion.hdbcds as shown below and in that cds file, I have imported the existing cds file package
using testProj.DBExt :: MySample.Employee;
And to define the EmployeeExtension.hdbcds I have included the following statements, employeeExt the denotes that it is in which folder.
in package testProj.DBExt.employeeExt;
The newly included columns in EmployeeExtension Context file.
2.3 CDS extension columns in existing table
As mentioned above that I added the “empDeptId” columns, Now that will be reflected in the existing employee table as shown below.
So in this way we can add as many as possible columns as well as table (i.e. Entity ) in the existing table without modifying the already deployed content in system. This is indeed a great feature which available as part of HANA SPS11(Since I have deployed and tested to this version also) but it is not part of the documentation and it has been added properly to the documentation of HANA 2.0 SPS 01.
The feature is well documented in HANA 2.0 SPS00 XSA development. The main reason for writing this blog is to give a better idea and to demonstrate one of the new feature of HANA CDS which makes the life of the end users easier as it helps to create completely new set of columns and add the same to existing table without editing or modifying the existing content (i.e. context). Even though we are modifying the package but the file in which table is created has not been touched (editing) which helps the developer and end users easier to add the columns as much as possible without making any changes to existing content.
Do share your feedback about the blog post.
Few of my other blog posts:-
- Blog Series:ODATA Protocol implementation for IOT Applications on SAP HCP
- Binary content upload & download from HANA DB via Apache Olingo OData in SCP
- Database migration in SAP Cloud platform using Liquibase
- Image persistence through Spring RESTful web services in CF
- logging in SCP with Java and Tomee using slf4j, logback, Jolokia
- Json to parquet, orc file format using Apache spark library
- Introduction to Annotations & Vocabularies
- Annotation’s usage in SAP S/4HANA Intelligent product design
Hello dear, Firstly thanks for share this wonderful and deep information. I am searching for that kind of information. I want cds file extension with crdownload file and how to use. I learn a lot of things from your blog.
Rajnish Tiwari , Is it possible to track and manage DB changes done via HDBCDS artefacts using Liquibase (Database migration in SAP Cloud platform using Liquibase) ?
I am not sure about this kind of db changes of HDBCDS can be tracked via liquibase.
However you can give it a try, If you get any approach to do that. Please update it here.
I am SAP working professional. Your article really help me to understand mange of DB changes via HDBCDS. I was looking for same information from last 15 days. I am also looking for installation of SAP application as mine one is showing some kind of Open dll file error while I am trying to open file.
Can you post the exact error here ? as well as the steps