Site icon Learn SAP HANA through easy tutorials

Creating HDBDD Table

Creating HDBDD Table using CDS method in SAP HANA

Hi All. Welcome to a new tutorial on creating a CDS based HDBDD Table in SAP HANA. In this one, we learn to create a table using the SAP HANA CDS (Core Data Service) method. The two recommended methods today to create a custom table in SAP HANA are using the HDBDD file or to use the HDBCDS file (when you have an XS Advanced or XSA installation).

The method to create a table elaborated on this website are:

  1. Using the graphical method  discussed in a separate tutorial.
  2. Using the SQL Script method discussed in a separate tutorial.
  3. Using the HDB tables method discussed in a separate tutorial.
  4. Using the HDBDD method discussed here(Recommended method in non XSA projects).
  5. Using the HDBCDS method which would be discussed in a future tutorial(Recommended method in XSA projects).

For anyone in a hurry, here’s the video version of this tutorial on YouTube. If you prefer a written one, please read on. Also, please subscribe to our YouTube channel to get video tutorials weeks before the written ones.

CDS HDBDD table : Using Web Development Workbench

We are using the web development workbench to create this HDBDD file. You can also do this in the SAP HANA studio under the repository tab.

Once you open the SAP HANA web development workbench, click on the Catalog to open the Catalog section.

The catalog link opens up showing the packages you are authorized to view.

Right click on the package where you wish to develop this code.

From the context menu, choose New-> File

A window opens up asking for the file name

We provide a file name TABLES with the extension hdbdd.

The editor opens up.

Now, we paste the below code into this editor to create our table.

namespace TEACHMEHANA;

@Schema: 'SHYAM'

context TABLES {

Entity CUST_REV_CDS {

CUST_ID : String (10);

FIRST_NAME : String (20);

LAST_NAME : String(20);

REVENUE_USD : Integer;

};

};

The namespace needs to define the package under which this file is created.

@Schema defines the schema under which the created table(s) would reside under.

The main context defines the file name that was given at the time of HDBDD creation.

A table is a persistent entity in SAP HANA CDS and hence the below statement declares a table (entity) CUST_REV_CDS.

Entity CUST_REV_CDS : The next part declares the columns in this table. Notice that the data types are different than in regular SQL. There is no NVARCHAR. Instead the declaration uses a String datatype. This is because CDS has slightly different datatypes.

{

CUST_ID : String (10);

FIRST_NAME : String (20);

LAST_NAME : String(20);

REVENUE_USD : Integer;

};

SAP has an online page dedicated to the datatype mappings which you can refer to in this regard. Click here to reach that page. A screenshot of that page currently is as below.

Once done, right click on the file and click “Activate”.

The cross symbol disappears from the file confirming that it is now active. The table CUST_REV_CDS should also now be created in the SHYAM schema as defined.

Now come back to the Web based development workbench. Click on the Editor.

Now, expand the Catalog, the schema, and the tables folder.

We see that the table has been created successfully.

This table can also be loaded using the hdbti method in the same way as the hdb tables.

I hope that the SAP HANA CDS HDBDD table concept is now clear to you. Please share this tutorial on social media to help support the site. Also, comments with your thoughts and questions.

Until next time…

<<Previous Tutorial                                                                                                                 Next Tutorial>>

Exit mobile version