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.
Showing results for 
Search instead for 
Did you mean: 

In my last blog (here) I introduced the Mobile OData Service Generator, a feature in the Mobile Development Kit plugin for SAP Web IDE that generates a full fledged OData service for you based on a CSDL.

Well, I hope you are eager to hear how it works so we will jump directly into the action:

You need a place to store the data of your solution and to make it more easily to understand let's assume you want to build a mobile canteen menu application for your peers.

In order to use the new Mobile OData Service Generator you need to active your Mobile Development Kit feature (which has recently been renamed to Mobile Services Development Tools) in the SAP WebIDE full-stack edition. (this video explains how it works)

Now you  can create a new project by choosing File > Project from Template. In the list of project templates, select Category "All categories" as a filter and select the "Mobile OData Service Project".

For demonstration purposes we go the easiest way possible - choosing inMemory, so you can just type in a project name like "MyBackEnd" in the first step of the wizard dialog popping up.

You need to provide some more information about your service. Do you want to generate a service for CF or for NEO? Do you want to generate the persistence for SAP HANA, SAP ASE or Postgress? For our little getting started guide, we use InMemory with BasicAuth on NEO like below:


After finishing the project wizard, you'll see a new project in your workspace like this:

This is the empty project structure of your service. Next step is to right click the project folder and create New > OData CSDL Document and fill out the form as follows:

These information are being used to generate the Java classes that will make your service.

In addition an file will be created that represents your OData Service:

If you don't know what CSDL is all about, you should NOT read this. Keep focused on the task before you and save that link for later.

Just double click on the csdl.xml file to open a graphical editor that let's you design your service.

I created a service like this:

This created a CSDL as follows:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="4.0" xmlns:edmx="">
<Schema Namespace="" Alias="canteen" xmlns="">

<EntityType Name="Canteen">
<PropertyRef Name="CanteenID"/>
<Property Name="CanteenID" Type="Edm.Int64" Nullable="false"/>
<Property Name="Location" Type="Edm.String" Nullable="false" MaxLength="50"/>
<Property Name="Name" Type="Edm.String" Nullable="false"/>
<NavigationProperty Name="LunchMenu" Type="canteen.Menu" Nullable="false"/>

<EntityType Name="Menu">
<PropertyRef Name="MenuID"/>
<Property Name="DateOfLunch" Type="Edm.Date" Nullable="false"/>
<Property Name="Description" Type="Edm.String" Nullable="false" MaxLength="250"/>
<Property Name="MenuID" Type="Edm.Int64" Nullable="false"/>
<Property Name="Name" Type="Edm.String" Nullable="false" MaxLength="50"/>
<Property Name="kcal" Type="Edm.Int32" Nullable="true"/>
<Property Name="veggie" Type="Edm.Binary" Nullable="true"/>

<EntityContainer Name="CanteenService">
<EntitySet Name="CanteenSet" EntityType="canteen.Canteen">
<NavigationPropertyBinding Path="LunchMenu" Target="MenuSet"/>

<EntitySet Name="MenuSet" EntityType="canteen.Menu"/>


Right-click on the csdl.xml file and click "Generate Mobile OData Server" to start generation of an Java project that represents the service. After a while the "srv" folder should look like this:

The next step would be to compile the Java project, but before you can do that you need an SAP Cloud Foundry trial, then go back to SAP WebIDE preferences and add your CF account details as seen below.

Please click the "Install Builder" button.

Don't forget to "Save" the changes in this dialog at the bottom of the screen!

Now we can compile the Java Project and we will get a odata-service-0.1.0.war file like this:

This concludes the service generation and the scope of the tool. Everything that follows is standard SAP Cloud Platform behavior.

Now we will export the war and bring it into our SAP Cloud Platform Cockpit and run it as a Java Application in our trial landscape.

So in your Cockpit, choose Java Applications, then "Deploy Application" button to upload our .war file.

I used these parameters:


After deploying the war, start the app.

Once the service started, you can assign the "ServiceUser" role to yourself and open the service in your browser under, where XXXXXX is your trial account name.

What you see is your freshly created service, which fully supports all OData operations (CRUD) as well as OData features like, filter, select. It even serves the data as OData v2 and v4 simultaneously, just like the client demands it!





If you send along a header like this DataServiceVersion:2.0 you'll get a result like this
"d": {
"results": []

I admit that it looks quite complicated, but if you look at the steps I performed for achieving this, there was not a single line of code involved and I used a graphical modelling approach to create an OData service.

Next step would be to create either an mobile app with SAP Mobile Cards, SAP Cloud Platform SDK for iOS or SAP Cloud Platform SDK for Android on top of this OData service.

And the OData service generator can even do more, which I did not have covered so far:

  • Generate an delta token enabled OData Service

  • Provides hooks to inject your own logic into the service to make it even more versatile

But these topics will be covered by other blogs in the future. More information can be found in our docs.

I hope you enjoyed our newest addition to the SAP Cloud Platform Mobile Service feature set.

Have Fun,