Starting the release of CDS Graphical Modeler 2105, you can not only create entities and projections but also the CDS Graphical Modeler would allow you to create structured types, enums and named aspects as well. In this blog post, we’ll demonstrate how to create structured types, enums and aspects using the CDS Graphical Modeler.

Creating Structured Types

Open the CDS file using the CDS Graphical Modeler:

Click “+” and choose “Create structured type” menu item:

In the new structure type dialog, enter “BookInfo” as the structured type name:

Click “Create” to dismiss the dialog, and you will see the newly created structured type:

Please note the CDS Graphical Modeler automatically switches to the “type” view from the “entity” view so that you can see the newly created structured type:

Now you can add a few properties to this structured type. You can do that by clicking the structured type and select the “Add Property” menu item:

then add a few properties for example the ISBN for the BookInfo structure type:

continue to add properties until you close the add property dialog, and you will have below structured type:

Creating Enums

Now let’s create a new enum using the CDS Graphical Modeler. Click “+” in the toolbar and click “Add enum” menu item:

and you will see the new enum dialog:

CDS Graphical Modeler supports 2 types of enums, the integer enum and string enum. Let’s create an integer enum first:

Click “Create” to dismiss the dialog and you will see the newly created enum in the “Enum” view:

Now let’s create a new string enum:

Click “Create” button to dismiss the dialog and you will see the newly created string enum too:

Creating Named Aspects

We can also create aspects using the CDS Graphical Modeler. Click “+” button on the toolbar and choose “Add aspect” menu item:

In the new named aspect dialog, enter “BookBase” as the aspect name:

Click “Create” to close the dialog and you will be able to see the named aspect in the “Entity” view. You can add required properties to the aspect by clicking the entity and choose the “Add Property” menu item:

Please note like the normal entity, you can create key properties to the aspect. Create a key property called “id” to this aspect:

Continue to add properties until you close the dialog, and you will be able to see the named aspect like below:

We can now take a look at the CDS file and check its content:

namespace my.bookshop;

entity Books
{
    key ID : Integer;
    title : String;
    stock : Integer;
}

type BookInfo
{
    ISBN : String;
    totalPages : Integer;
    publishingYear : Integer;
    publishingDate : Date;
    title : String;
    subTitle : String;
    languages : array of String;
}

type ColorEnum1 : Integer enum
{
    red = 1;
    blue = 2;
    yellow = 3;
    orange = 4;
}

type ColorEnum2 : String enum
{
    red;
    blue;
    yello = 'yellow';
    orange;
}

aspect BookBase
{
    key id : String;
    ISBN : String;
    publishingYear : Integer;
    publishingDate : Date;
    weight : Integer;
    country : String(100);
}

Conclusion

With the new release of the CDS Graphical Modeler, we’re able to create structured types, enums and named aspects. In this blog, we demonstrate how to create structured types, enums as well as aspects using the CDS Graphical Modeler.

Randa Khaled

Randa Khaled

Author Since: November 19, 2020

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x