The previous blog of this series was an introduction of the CDS graphical editor as a new tool to model CDS artifacts. This article is to help you get started in creating CDS models (.hdbcds files) using the CDS graphical editorUsing the CDS graphic in SAP Web IDE for SAP HANA.

First, create a project in SAP Web IDE for SAP HANA, and, and only then open the .hdbcds file using the graphical editor. then create an ‘.hdb’ module under this project. This is because, in SAP Web IDE for SAP HANA, all database related artifacts or models are created inside an ‘HANA Database Module’ (hdb) module.

Inside the ‘.hdb’ module, you can create various types of files, for example, .hdbflowgraph, .hdbcalculationview, .hdbanalyticprivilege, .hdbcds, etc. The following sections explain how to create CDS Data Models (.hdbcds files) using the CDS graphical editor.

Create a new .hdbcds file:

  1. To create a new CDS model, in a .hdb module, right click on the ‘src’ folder and select ‘CDS Artifact’:

  1. The CDS file creation wizard opens, where you can specify the name of your CDS model. Additionally, you can also choose to open the file with the Graphical Editor or with the Text Editor.

  1. When you select the option, Open With ‘Graphical Editor’ and click on ‘Create’, a new CDS file opens up with a blank canvas to design your data model. The toolbar on the top of the file is the starting point for creating the CDS model for your database design.

 

  1. At Step 2, if you choose to open this CDS file with the option ‘Text Editor’, a blank text editor opens with a predefined namespace and context declaration for your file. You can continue to type-in and create a CDS artifact in this file (as was done before the CDS Graphical Editor came in)

Using the CDS graphical editor to open existing .hdbcds files:

You can use the CDS graphical editor to open .hdbcds files that were created using the text editor, and conversely, you can also open .hdbcds files that were created using the graphical editor, with the text editor.

Right click on the existing .hdbcds file, navigate to the option ‘Open With’ and click on ‘Graphical Editor’:

The .hdbcds file will open on the CDS graphical editor and all the artifacts contained in the file will be displayed on the canvas. Users can then create new CDS artifacts like CDS entity, contexts, data types, CDS views, etc, or they can modify the existing CDS artifact, without having to type-in all the code using the CDS syntax!

Open .hdbcds file containing unsupported features for CDS graphical editor

CDS graphical editor is a new tool and is continuously evolving. It is very likely that the .hdbcds file that you are trying to open with the graphical editor, contains CDS artifacts, which are not supported in the current version of the CDS graphical editor that you are using. In such cases, a warning message is shown to the user before the graphical editor loads. The warning message states that the file being opened contains features that the graphical editor does not know how to open and display the unsupported features.

For instance, the file shown above called ‘UnsupportedFeaturesOnGraphicalEditor.hdbcds’ contains constants declarations, CDS entities and one CDS view declaration (cds source ode below):

context UnsupportedFeatures{
  const MyIntConst      : Integer      = -7;
  const MyStringConst   : String(10)   = 'bright';
  const MyDecConst      : Decimal(4,2) = 3.14;
  const MyDateTimeConst : UTCDateTime  = '2015-09-30 14:33';
 
  entity MyEntity {
    key id : Integer;
    a : Integer;
    b : String(100);
    c : Decimal(20,10);
    d : UTCDateTime;
  };
   
  entity YourEntity {
    key id : Integer;
    a : Integer;   
  };
      
  entity HerEntity {
    key id : Integer;
    t : String(20);
  };
   
  view MyView as select from MyEntity{
     id, a as age, c as grades
   };

The CDS graphical editor in SAP Web IDE for SAP HANA 2.0 SPS 00 does not support declaring constants. Hence, these constants will not be displayed on the graphical editor. Rest of the artifacts, like the CDS entities and the CDS views, are understood by the graphical editor and the file is loaded as shown below:

The user can make modifications to existing CDS artifacts in this model, or create new artifacts once the model is opened on the graphical editor.

Open .hdbcds files containing errors

It is possible that the .hdbcds file created using the CDS text editor was saved with syntactical errors. When you try to open an .hdbcds file that contains errors using the CDS graphical editor, a message is displayed on screen stating that the CDS graphical editor cannot open .hdbcds files with errors. To open such files, the user is required to fix all errors using the text editor, and only then open the .hdbcds file using the graphical editor.

The above file, ‘FileWithErrors.hdbcds’,  contains typo error where the element ‘orderId’ is declared:

context FileWithErrors{
  entity SALESORDER{
    orderId : Integer 3422;
    salesId : Integer;
    dateOfPurchase : UTCDateTime;
    division : String(10);
  };
};

Once the error is fixed using text editor, the file can then be opened with the CDS graphical editor like so:

Closing Points

This article explained how to use CDS graphical editor to:

  1. Create new .hdbcds files
  2. Open existing .hdbcds files that contains syntactical errors
  3. Open existing .hdbcds files that contains features that are not supported in the CDS graphical editor (as of the version of SAP Web IDE for SAP HANA being used)

The next blog in the series will explore in depth on how to create a ‘CDS Entity’ and how to configure various technical configurations for it like Indexes, Partitions, Storage Type, Table Grouping etc.

 

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

    1. Rutika Bodas Post author

      Hey Shiny,

      As you would notice, I have used the term SAP Web IDE for SAP HANA in the blog post. This is because the SAP Web IDE is a different web application from SAP Web IDE for SAP HANA. The former one has fiori dev tools and the latter one has all tools and plug-ins for HANA database modelling.

      HANA CDS Graphical editor is available on the SAP Web IDE for SAP HANA. This can be installed on your XSA as an MTAR. Please seek help from your HANA system admins for deployment related queries.

      Once you have the  SAP Web IDE for SAP HANA running on your XSA, you can access the CDS graphical editor there on.

      Regards,

      Rutika

      (0) 

Leave a Reply