The idea of this blog is simple. This blog is an effort to simplify OData and help beginners understand and start adopting the standard for their development needs.

When I started off with trying to break down and understand OData, I found the internet a big world to get lost in. If you are one of those, patient enough to read through precise technical details, then will be the best place to learn OData.

In this blog, I will try to summarize OData into a crash course version for those who like me come with a lazy attitude towards reading online documentation. To keep this a blog easily readable by beginners, I will try to keep the discussion of OData to 10 short sections that I personally believe is what we need to know as to get our basics clear.

Note: I will use the various references inline with the site so that it might be easier for readers to refer back to the website for further details and keep the context alive.

Lets start with

1. What is OData?

The simplest definition of OData would be that it is a standardized protocol built over existing HTTP and REST protocols supporting CRUD (Create, Read, Update, Delete) operations for creating and consuming data APIs.

Nickname: ODBC for the Web

2. Entity Data Model and an OData metadata

The metadata of an OData message can be summarized as below;


An OData metadata will contain the definition of Entity Sets and the associations. An entity set is nothing but a collection of Entity Type. An entity type can be considered as a data type that contains details of a specific type of data ex. Customer, Supplier, Sales Order, Employee etc.

You would have already figured out that an entity key is used to uniquely identify an entity type. Ex. Employee number, Sales Order number, Product ID etc

Now an association is simply the relationship between two or more entity types. A good example for association would be Products to its Manufacturer. An entity set Product can be associated with an entity set Manufacturer in an OData metadata.

A navigation property then is nothing but a property set on an entity type to understand the associations of the entity type.

3. Access an OData service

We access and OData service via an URI


4. How do I understand/access the metadata model of the above service?

Add the suffix to the service URI- $metadata


5. Lets talk details please!

If we deep dive into the OData service referred earlier, we find that there are four Entity sets i.e Four different types of data returned by the service.


Now to understand more about this, we will have to look into the metadata and see what information it reveals.

Below we see how the metadata revels the Entity type to Entity set relationship;


To understand the relation between each of the Entity sets and Entities, refer the below;


The above means that for particular item in the Products Entity set, we can refer its Category or its Supplier. Similarly for a particular Supplier in the Supplier entity set (Suppliers), we can get a Product set (Products) and for a particular Product from that set, can further extract it’s category.

In the case of Categories, for a Particular Category, we can extract a Product set (Products) related to it and further also extract the supplier for a specific product.

6. OK, enough with the pictures. Show me the real stuff now!

6.A. How do I access an Entity set?

If you want to access say the Categories entity set, use the URI –

This will return the entire Categories available with the service. You will find three Categories returned, Food, Beverages and Electronics.

6.B. How do I access a particular entity in an entity set?

You can refer the entity key in the URI to access the particular record. Ex. in the above service for a specific category, we can refer it with its ID. From the above URI, lets access only the beverages category. The id for Beverages is 1. So we can use the following URI to access that specific record;

Note: How do I know what’s the entity key?

In the metadata, for the Entity type definition, you can find the Key referenced. In the case of Category, it is the field ‘ID’.


6.C. Show me an example of the associations and navigation between Categories, Products and Suppliers.

The above link can be interpreted as finding the Supplier of Product with ID = 2 within the Categories entity set with the Category ID as 1.

7. So what are the queries I can use to manipulate the data?

The below table will document the most used and helpful queries when dealing with an OData service;

$formatBy default you would have noticed that the data returned is in an XML feed. This query allows us to change the format of data. The example here shows how you can return all the suppliers returned by the service in JSON format instead of XML.$format=json
$topThis query option helps to limit the data returned by the service. The example here shows how you can return only the 1st Category instead of all the Categories.$top=1
$skipThis can be treated as the opposite of $top. The skip queries can be used to skip records. The example here shows how you can skip the first 2 records in the Products set and return the rest of products. Hence on the execution of the given query, Products with ID as 0 and 1 gets skipped.$skip=2
$inlinecountThis will return the total number of records as part of the response payload. We can extract the number from the field <count></count>. If you execute the given example, in the payload you will find that in the field <count>, the value is returned as 2, meaning there are total 2 Suppliers as part of the service.$inlinecount=allpages
$orderbyUse this to sort the records returned by the service. The given example shows how to sort the Product entity set by the price of each product. Here Price is a field returned as part of the Product set. On use of the query, the record set is returned with the ascending order of Price. You can use a suffix desc to return the records in the descending order.$orderby=Price$orderby=Price desc

$expandThis I found to be a very helpful query to reduce the number of calls we need to make to access a particular set of data. Say, in case you want to return all the products along with their Category, use the URL provided in the example.$expand=Category
$filterThis can be compared to the ‘where’ query in SQL. Lets say we want to get all the products with rating greater than 3, then use the example as defined here. Note that we can use both Logical and Arithmetic operators. There are also various functions like substring etc that is supported. Please refer this link for the extensive list that you can use.$filter=Rating gt 3


As in any SQL query, this query option can be used to Select specific or all fields of an Entity set or entity. A simple example, lets say the requirement for which is for us to return the fields rating and Price of a Product with ID = 3

Note: I found that it is not possible to use $select on Complex types. For example, the Address is a complex type in the Entity Supplier. So if we want to say, select the City and State which are the fields part of the Address structure, the $select is not supported. (Or am I struggling to use it correctly?)$select=Rating,Price

More examples,

a. Get me the three of the best rated products$top=3&$orderby=Rating desc

b. Ok! Now get me the next three best rated products.$top=3&$skip=3&$orderby=Rating desc

c. Get me the count of Products with the Price greater than or equal to 20?$inlinecount=allpages&$filter=Price ge 20

8. Instead of a browser, are there any tools I can use to play around with OData?

Yes. One simple tool is the Advanced REST Client for Chrome. There are also many other clients available online for free which help you.

9. What was all the CRUD thing about?

In case of OData, CRUD operations are defined as POST (Create), GET (Read), PUT (Update) and Delete (Delete) HTTP methods.

You can do a GET and POST request on an Entity Set while GET, PUT and DELETE can be done on an Entity.


10. This is all good but why OData instead of normal REST?

Well, you have seen how OData provides you with a consistent uniform standard way of describing the data and the data model. That precisely gives it an edge over REST. Moreover, hey SAP seems to be investing heavily on the standard. Which might mean, like it or not, you will eventually end up using OData 😉

Hope this was an enjoyable read. Please do leave a feedback or comment on anything you wish to see changed or added additionally.

To report this post you need to login first.


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

  1. Luke Marson

    Great blog Shabarish and although this is in Mobile it has value for other areas since OData is being used to help other Cloud technologies consume data.


    Best regards,



    1. Shabarish Vijayakumar Post author

      Thanks Luke. Absolutely agree that this is a topic much wider, that it does no justice for this to be restricted to the mobile space. But I had to decide a topic area and finally posted it here. (On second thoughts, perhaps Gateway space might have been a better fit)


      I hope this blog does serve its purpose by simplifying the understanding of OData for folks new to it.

  2. Custodio de Oliveira

    hey SAP seems to be investing heavily on the standard. Which might mean, like it or not, you will eventually end up using OData

    To me it sounds like: “Why Web Dynpro instead of ‘normal’ Java? – Beacuse SAP is investing heavily on it, so like it or not you will end up developing Web Dynpro”

    1. Chris Paine

      RESTafarian hat on… REST is not a protocol, OData is not RESTful.


      Yes it is a powerful and open standard for doing “SQL for the web”, but it isn’t REST.


      Hat off.


      Nice blog that points out in very simple terms the power of OData. We will all have to learn to use it even if we dislike it, much in the same way as SAPUI5 because it is going to be used in the SAP products that we work with and support.


      Just like web dynpro. 😉

      1. Custodio de Oliveira

        The only thing in advantage of OData x WebDynpro in this situation is that OData, unlike WD, is open. Thank God SAP didn’t choose to use their own version of OData!


        BTW, I usually see “ODBC for the web”, not “SQL for the web”.

  3. Benedict Venmani Felix

    Thanks Shabarish,

    Now I am a lillte closer to my target than I was before. My target being “get a better understanding of OData”

    But problem is I do not understand REST as well to tell th difference between th two. I hope you would be able to elaborate some more on the question number 10.


    Person with a lazy attitude towards reading online documentation,


  4. suresh babu

    Hi Shabarish Vijayakumar



    Nice blog..


    I have small doubt …..

    We have configured netweaver gateway SERVER and created OData.

    We created a project based on java script ad html5.

    When we do web security disable for chrome it is working fine.


    Now we have smp 2.3 and afaria , web server ( reverse proxy/web dispacher)

    architecture is

    internet–> webserver(webdispacher/reverse proxy)–>netweaver gatewat

    still we are facing cross origin null not allowed error


    Can u give us any way, how to make out java script application work on mobile. without cross origin error?




    1. Shabarish Vijayakumar Post author

      Suresh – I woudnt claim to be a mobility expert. This seems too technical a question I can help answer.


      Please raise it in the SMP forums and I am sure there are experts who can help answer this.




    2. Njål Stabell

      Hi Suresh,

      Using Phonegap/Cordova will enable you to run an js/html5 hybrid App that can use the REST API of SMP.


      For iOS you need to whitelist the SMP server url.


      Here is a blog I wrote on onboarding and authenticating a Hybrid App (based on SAPUI5) there is a link to the logon js file on Github in the blog.




  5. Nick Thienpondt

    Hi Suresh,


    When you are developping on your local machine you can redirect it via proxy match in that case you do not need to disabled it anymore.


    The reason why you have this problem is because of the different domains. If you should deploy your HTML/5 – JavaScript code on your ERP Backend like in a BSP then you will not have this problem anymore because they are on the same origin.


    Also another solution is using the full links in you code like HTTP:// etc


    The thing Njål says is also true and possible. I already did this for several projects.


    So normally with one of these you should be able to solve the problem.




    1. suresh babu

      Hi Nick,

      Thanks for input…..


      We are using sap wed dispatcher as reverse proxy. Could you please update us how to make it work in web dispatcher.


      Now We will try by deploying HTML5 and Java script in ERP. Is there any document how to do it. ?


      We are using full url to call Netweaver gatway in Odata.Read function

      It didn’t help us?


      Thanks in advance


  6. Nick Thienpondt

    Hi Suresh,


    How to upload the code is very easy in fact you just go to SE80 you choose BSP-app.

    There you create a new one and upload al the files to the BSP.

    To do it all in once it is possible via the program BSP_UPDATE_MIMEREPOS.

    Once you done this you can test the website(html/5-JavaScript) via the normal test way in a BSP.


    If you want to make an application (standalone) on your phone or tablet please follow the explanation of Njål because that is a correct explenation.


    If the gateway and the location where your website is are on the same location and then you dispatch you website url to the outside world then normally this should work…


    In fact the same explanation as here

    I also only did it like this… I’m not sure if it possible like you want it.





    If we were to use ODATA Services on HANA to connect Microsoft clients like excel and analysis services do you know if there will be a performance difference in using ODBC connectivity vs. ODATA?

  8. cind q

    Great Bolg that we’ve ever seen before. ( Fresh & clear). BTW, we’ve well konw about CRUD. Here, is there any ex. to share about Create, update, delete a record?


    Thanks a lot.

  9. vijay m

    Very Nice Blog. Explained with simple words and with sample ODATA and diagrams to understand the beginners very easily with out any difficult.

  10. N Meenakshi


    we are  using SAP Net weavers  in desktop,i need know how connect the server using Android Application or  .Net Application how and where i can get the answer for this..reply me any guys…

    1. Michael Appleby

      Unless you are asking for clarification/correction of some part of the Document, please create a new Discussion marked as a Question.  The Comments section of a Blog (or Document) is not the right vehicle for asking questions as the results are not easily searchable.  Once your issue is solved, a Discussion with the solution (and marked with Correct Answer) makes the results visible to others experiencing a similar problem.  If a blog or document is related, put in a link.  Read the Getting Started documents (link at the top right) including the Rules of Engagement. 



      NOTE: Getting the link is easy enough for both the author and Blog.  Simply MouseOver the item, Right Click, and select Copy Shortcut.  Paste it into your Discussion.  You can also click on the url after pasting.  Click on the A to expand the options and select T (on the right) to Auto-Title the url.



      Thanks, Mike (Moderator)

      SAP Technology RIG


Leave a Reply