Skip to Content

About the Graphical Modeling Tool

The Graphical Modeling Tool is a new tool that’s available from within the Mobile Backend Generator. It lets you edit or create a CSDL file. The extension of the file is XML. CSDL stands for Common Schema Definition Language(CSDL) and Extensible Markup Language (XML).

About the Mobile Backend Generator

The Mobile Backend Generator is a mechanism used to create and deploy an OData service. The Mobile Backend Generator is a set of tools that’s included with SAP Web IDE and interacts with SAP Cloud Platform Mobile Services. These tools are now available to customers with the latest release of the Mobile Services App Development Tools on SAP Web IDE for trial or preview landscapes.  You’ll need to create a trial account to use this new feature, if you don’t have one already.

About the Mobile Services App Development Tools

Mobile Services App Development Tools is a feature of SAP Cloud Platform Mobile Services. If you’re new to developing mobile apps and want to learn more about developing apps without having to do much coding, you might want to begin by going through this Learning Journey and these helpful videos.

In my last blog, I walked you through how to create and deploy an OData Service using the Mobile Backend Generator. Before you start to edit or create a CSDL file, ensure that SAP Web IDE Full-Stack service is enabled in the SAP Cloud Platform Cockpit.  Once you’re in the SAP Cloud Platform Cockpit, select “Services” (1) and type web into the category search field (2). Enable the service (3). Select the box (4).

This blog shows you how to use the Graphical Modeling Tool.

Under Take Action, select “Go to Service” (1).

Select the gear icon in the left menu (1) and select “Features” (2). Make sure “Mobile Services App Development Tools V Master” is “ON” (3).

Editing an Existing CSDL File

Select the “</>” symbol (1) to enter your workspace in an existing project where you created your own OData service. Right-click the CSDL file (2) and select “Open Code Editor (3).

The code editor displays the CSDL file, which made up of the metadata that defines the objects in the database.

Although this is helpful, wouldn’t it be much easier if you could see the relationships graphically? Look no further! Well, look below 🙂

In your existing project, right-click the CSDL file (1) and select “Open CSDL Editor (2).

The graphical editor opens and shows the CSDL file in a graphical format.

There are three entity types in this simple CSDL file.  The file contains no complex types, enum types, or data methods. If enum types were defined in your CSDL file, you’d see them as a menu item between “Complex Types” and “Data Methods”.

If you select the whitespace (1) in the graphical editor, you see the attributes of the CSDL schema. You see the OData Version, Namespace, Alias, and you can check whether you wish to “Track Changes(2).

If you select an Entity Type (1), its attributes show in the right column.

You can delete properties from your entity by selecting the property (1), then selecting the trash icon (2).

Add a property to your entity by selecting the + sign (1) and filling out the name (2), type (3), maximum length (4) and selecting “Create (5). The UI (user interface) changes dynamically when the type changes.

Select a single entity property to see its the attributes in the right column (1).

You can define a function, which has a return type, or an action; which may or may not have a return type. Select the “+sign (1) and fill in the name of the method (2), whether it is an action or function (3) and select “Create” (4).

Add parameters to your function or action by selecting the “+” sign (1), entering a name (2), and selecting the type (3). Select “Create” (4).

There are Annotations within the CSDL file that are not shown visually; don’t remove them from the file.

Let’s define a new navigation property between Contacts and Opportunities to show a relationship.  Look here for more information about navigation properties.

Select the  entity type you’re navigating from (1), then select the “+ sign next to Properties (2).  Check Navigation (3) and provide the name and type of the entity to which you want to navigate (4,5). The partner will default as the first entity type (6).  Select “Create.” (7)

Ideally, the navigation properties should be bidirectional.

Creating a New CSDL File

Create a new project that will use your CSDL file.  Select the “</>” symbol (1) to enter your workspace. Right-click the workspace folder, select “New” (2), then “Project from Template” (3).

Change the Category to “Mobile Services” (1) and select “Mobile OData Service Project” (2). Select “Next” (3).

Provide a project name (1), then select “Next” (2).

Provide a service app name (1) and the version (2). For simplicity, I’m using an in-memory database (3), a deployment target of Cloud Foundry (4) and “None” (5) as the authentication mode. Select “Finish” (6) when done. See Generating an OData Service for alternatives to using an in-memory database.

Create a model for your project by creating a new CSDL file. Right-click your project folder (1), select “New” (2), then “OData CSDL Document” (3).

Choose the OData Version (1), provide a schema namespace (2), a namespace alias, and select “Create” (4).

Double-click (1) the CSDL file to open the graphic editor (2).

Add an entity type (1) called “Accounts” (2) and select “Create” (3). Accounts have the following properties: address1, address2, city, country, email, and name. Create another entity type called “Contacts” with the following properties: account, dept, email, and name.

Select the “+” sign (1), provide the name (2), type (3), maximum length (4) and select “Create” (5).

When you finish adding properties to your entity type, don’t forget to save (1)!!

These are the two entity types, but we need to show how they relate to each other. We’ll do this by adding navigation properties.

Let’s add a bidirectional relationship between “Accounts” and “Contacts”. Select the “+” sign (1) in the Properties section,then check Navigation. (2) Enter the name of the entity (3), in this case,  “Contacts”, then select its type, “(Entity Type) Contacts” (4). The partner field defaults to entity type to which you are adding a property. Select “Create” (5).

You can now see the relationship between the two entity types.

Right-click the CSDL file (1) and select “Open Code Editor” (2).

The code editor now shows the CSDL that you generated in the graphical editor!

With your new or updated CSDL, you can now generate an OData service using the Mobile Backend Generator with your updated metadata definitions.

I hope you’ve enjoyed this blog!

To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply