Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
rajnish_tiwari2
Advisor
Advisor

  1. Introduction


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

Employee Table



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:

.package.hdbcds

A CDS document containing the definition of the CDS extension package employeeExt/

EmployeeExtension.hdbcds

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.

3. Conclusion:

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:-

 
5 Comments