Skip to Content
Technical Articles

How to Build your Mobile OData Service From Scratch


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,



You must be Logged on to comment or reply to a post.
  • Hi Martin,

    Is this feature available in productive environments? We do have an account with the Mobile Services service and the MDK feature enabled but I can’t see the Mobile OData Service Project template. I can see it in my trial account.



  • Hi Martin,

    Thank you for your blog.

    I followed your webinar ‘Create Full-Fledged OData Service for Mobile Apps’ on december 2018 and I have a question. You had initialized you Odata service with some data.

    For that you had modified the ‘’ could you explain me how to do because I want to do the same thing with my hown Odata.

    Thank you for your help.

    Best regards,


    • Hi Mikael,

      today, there is no need to load the data via coding anymore. You can provide a JSON file in your project to load the data for test and/or for initial data. That makes using this much easier. Here’s the link to the docs

      Hope that helps.



  • Hello,


    Great tutorial, first of all. But when I try to right click and generate mobile data service on CSDL file, I am getting error “(CSDL) No destination defined for OData service generator”. What could be the reason?


    Thank you in advance for explaining.


    Seyed Ismail.

      • yes but how to connect postgresel actual database with sap ??? means i cound find the way that how to integreate postgreSQl with sap. @Martin Grasshoff guide me to connect postgresql database

  • Hi Martin,

    Thanks for this excellent tutorial, i have followed each step mentioned but when i deploy the project(.war)  on Neo Trial environment , i get HTTP 403 error.

    can you please help me resolve this issue.


  • Hi,

    Are there any tutorials on how to make the mobile OData server a pass through server, just getting the data and authorizations from another backend which has its own web apis? I saw there was an option for the server to not connect to any database so I assume that this option is for using at as a pass through server?

  • Hi Martin Grasshoff,

    Thank you for the blog,

    I did exactly same steps but when generating mobile odata service its getting failed. Please find screenshot and please do let me know what went wrong.