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

Generating Core Data Services files with Sybase PowerDesigner

Contents


Generating Core Data Services files with Sybase PowerDesigner. 1

What is Core Data Services?. 1

The basics: Creating a project, a physical data model and the data model 1

Installing the HDBCDS Extension File (HDBCDS.xem). 6

The funny part: Generating the CDS definition file. 8

Using Domains in the Data Model (CDS Basic Types). 11

Working with multiple Contexts. 13

Conclusion. 16


What is Core Data Services?

As described in the SAP HANA CDS Reference guide, Core Data Services (CDS) is an infrastructure that can be used by database developers to create the underlying (persistent) data model which the application services expose to UI clients.

In that sense, CDS looks to be similar to SQL DDL but the key advantage is that CDS definition files are created as design-time objects that means that can be transported together with HANA Models.

Design-time objects for Data Model definition + logic + UI layer is indispensable for Native HANA Apps.

With this SPD Extension you can create CDS (.hdbdd) files from Physical Data Models.

So, let’s take the following example from the SAP HANA CDS Reference Guide

This code creates two tables after activation in the schema MYSCHEMA.

The CDS Guide explains in details all the elements that composes a CDS file (.hdbdd).


The basics: Creating a project, a physical data model and the data model


Go to File -> New Project and give a name to the project


1)      Go to File -> New Model and select Physical Model under the Information category.


2)      Create the Book and Author tables



3)      Create the SCHEMA

Go to Model -> User and Roles -> Schemas




4)    Set the Table’s owner


Go to Model -> Tables


And set the Owner column to MYSCHEMA


5)      Preview the Data Model (press Ctrl+G or Right click on the Model -> Properties )




Installing the HDBCDS Extension File (HDBCDS.xem)


Before proceeding we must create a folder to store the .XEM extension file.


Go to Model -> Extensions -> Attach an Extension



Click on Path and select the folder that contains the .XEM file

After the Path is added, select the HDBCDS extension


Once the HDBCDS extension is added, a new object is added to the toolbox for creating contexts


The funny part: Generating the CDS definition file

Before generating the .hdbdd file from the PDM we must create a Package and a Context.

Using the package tool in the toolbox under SAP HANA Database 1.0 category, create a package named com.acme.myapp1


Use the context tool to create a context named Books.


Set the context Books as main context for the data model.


Go to Model Properties (right click on DemoCDS Model -> Properties)
In the CDS Tab set the Books context for the Context property


Finally, generate the CDS Definition files. Go to Tools -> Extended Generation



In the Targets tabs select HDBCDS, let the Selection by default selecting all objects and in Generated Files select the .hdbdd and .hdbschema files.
Set an output directory and click Ok to generate the two files


Using Domains in the Data Model (CDS Basic Types)

CDS supports the definition of shared types so that your columns definition can reference the types instead of declaring explicit the data type.

f.e.


To use this feature, go to Model -> Domains and define a Domain, for example “TextoLargo” defined as VARCHAR(100)


Set the Domain in the columns definition, instead of setting the Data Type.

Go to Model -> Columns


And set de Domain value to “TextoLargo” for those fields of Varchar(100) type

Tip: If the Domain column is not present in the Columns properties, press Ctrl+U and select “Domain”.

Go to Tools -> Extended Generation and generate the model.hdbddfile once again.



Working with multiple Contexts

As described in the CDS Guide, we can define multiple contexts for grouping tables that belongs to the same functional group.

For instance, let’s rename the Book context to Main context, and create 2 more contexts named “Datamodel” and “Application”

Go to the Book table’s properties, and select the CDS tab, then set the Context to “Datamodel


Create a 3rdtable named UILogic and set the “Application” context in the CDS Tab



Finally, generate the hdbdd file to see the context definition.



Conclusion


It is possible to use Sybase PowerDesigner to generate SAP HANA CDS files. Using an enterprise modeling tool such as PowerDesigner gives more transparency in the model definition and simplifies the data model maintenance. There is no big effort to generate the CDS file once the PDM is defined.


There are some limitations in this extension, for example structured typed cannot be created.


If you want to enhance this extension, feel free to modify the code.


Go to Extensions -> HDBCDS -> Properties to see all the code behind this extension


10 Comments
juan_escalante
Explorer
0 Kudos

Hi Martin! Very useful guide. I don't know if im the only one who cannot see first picture after "What is Core Data Services".

Cheers,

Juan

0 Kudos

Thanks Martin! CDS generation from PD was something I was in dire need of and wondering if that was possible. Thanks again for sharing!

Cheers,

Glenn

Former Member
0 Kudos

Hello Martin

Excellent post and very useful extension.

Some nice features can still be added, like including associations generation for foreign keys. As far as I've tested, this feature it's not included yet.

Maybe if you could share some links on how to work with PowerDesigner extensions, more people interested in the subject could help to enhance this nice extension.

Regards

Luis Becker

martin_donadio
Employee
Employee
0 Kudos

Hi Luis,

Thanks for your feedback. Yes, there are more features that can still be added like associations and I would be happy to see this extension grow..

I used mainly the Customizing and Extending PowerDesginer Guide:

(http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc38628.1650/doc/pdf/customizing_power...)

Thanks,

BR, Martin

martin_donadio
Employee
Employee
0 Kudos

Thanks! Corrected

Former Member

Hi Martin

I'm sure will be glad to help you in extending the extensions, but up till now I hadn't time to dig deeper in the subject and work in more complex features like associations.

One very small change that I've done is to add support for NVARCHAR, which wasn't supported, just adding two lines on  "tipoDato" template:

.elsif(%.2:ConceptualDataType% == "VM")

String(%Length%)

But sure I'll let you know and share if I'm able to do further improvements.

UPDATE: finally I've made it to modify the file to allow it to create unmanaged associations. It works with 0..* and 1..* associations and do the backlink also. Let me know how can we share and even improve it more.

Best regards (o saludos desde el país vecino)

Luis Becker

Where could I download the HDBCDS extension?
Former Member
0 Kudos
Where could I download the HDBCDS extension?
0 Kudos
Hi, I have download the extension but now system shows dll file error. So what can i do for that?
martin_donadio
Employee
Employee
0 Kudos
Hi Sachin,

Please, note that this post was created in 2015 and at that time, CDS feature was not built-in the product.

Latests versions of SAP Power Designer might have this feature built-in, please get the latest version in order to generate CDS from SPD

 

Best regards,

Martin