What is OData – Part 3 – Why we need it

SOOOOO THE BIG QUESTION — IF REST Works — WHY TO SHAKE THE BOAT ?? 

In this blog we will explore this question


 

This blog is part 3 in out series on understanding OData. These are the basics which will help you move ahead with your understanding of SAP Netweaver Gateway.

You can access earlier parts here

Part 1 : What is OData

Part 2 : REST Approach to HTTP – Precursor to OData


WHY ODATA ?

Long story short – REST Protocol is good because you can access Web data in a systematic way. You know that if you make an application and make GET, POST and other calls to a web service which understands HTTP then you will get an answer/data which you can then work on.

But its beautiful if you know the system. You know the system if you have been dealing with it for a long time. Like if you have to fetch data from a google map then the service is quite freely known. What if you are not aware of what is going to be given back to you.

Let me explain further.

Lets say you have a non-trivial ERP application and lets say you create a web service API to lets say expose Customer data. So you could have a web service like getCustomers to get a list of all customers —- and these customers list can be huge with various different kinds of customers ( Yes slowly I am going to introduce you to SAP’s adoption of OData – but if you are into SAP, you know what I mean by non-trivial application – Like for instance if you talk about a company which has global operations and has customers all around the globe with different categories and different product lines )

— Ok So your getCustomers service works fine – but then people using your service to build applications on will ask you — getCustomers is working fine — but I want another service to getCustomers order by country – and another getCustomers by id, by customer number, by first name, by last name — and so you will end up building hundreds of web services.  — And this is only about customers– but you could go on with Orders and Vendors and so on…So in the end you’r solution will become complex and with a lot of web services. And this is only for Querying — You will have to do the same for inserts, for updates ..

So in the end we ask is there was a simpler way to use REST but still be able to directly run queries on the underlying data over the internet — So here is where we introduce OData — which is also mentioned as SQL for the Web.

OData (Open Data Protocol) is an OASIS standard that defines the best practice for building and consuming RESTful APIs.

Ok — so if you are with me so far -then I want you to try this out yourself.

Visit this following link and see for yourself what I mean

http://services.odata.org/northwind/northwind.svc/

As you can see this is a web service in the internet and simply by accessing this hyperlink — you have made your first OData query call. This call gave you a list of all the basic data in the northward database to test on.

But thats not all. In this call you also got the meta-data of the actual data. Meta-Data simply means the way the data is organized. So you know what tables exist in this database and what are the actual data values. So ideally you can now without even actually knowing this database structure can program a generic front-end to accept this data and display this data to the user.

With traditional REST approach this generic programming would be difficult. You would have to read the documentation and know which queries are possible, then may be hard-code the url’s etc.

But that’s not all. Meta-Data in OData call goes much beyond, because with the $metadata appended to this URL you can get not only the name of the table-Entity-type, but you will get a list of Properties which are basically Fields – Its data type, Other data attributes, wether it is a primary key and also additional annotations which you want your client to understand and use.

Plus You can control how you want this data to be sent back whether in XML of JSON format for example by adding the command ACCEPT: application/json  which can be used by javascript based clients. off course the size of the data returned in json is considerably less than XML.

So to Query this data with a filter I could simply use the $ sign and say $filter=CustomerID eq ‘ALFKI’ and this query will fetch me customer with id = ‘ALFKI’ – And this query is actually executed at the database layer. Off course there are a lots and lots of things you can do here just like SQL on Database.

So OData like SQL is not tied to any database, it can fetch values from any database.

 

— In the future blogs I am going to explore more on SAP Netweaver Gateway —–

How the Gateway can be used to develop Data services to expose SAP Data.

How to consume such data and how to do code based development of SAP Netweaver Gateway Services.

etc.. If you are interested in these topics and would like to keep up with my blogs on this topic provide your email blog to keep in touch with these posts.

52 Comments

  1. Anand R

    I liked the way you explained quite complex concets like OData .I need more details about Netweaver Gateway and Fiori in similar way. Please send me details or let me know links if they are already available

  2. Navina govinda

    It is very nice explanation with wonder full examples, so i want to go deep in ODATA with your explanation, could you send topics related to odata and netwawer gateway.

  3. Suresh Kolisetty

    Very elaborated and clear explanation of protocols and oData introduction. Please share any links related to SAP Netweaver Gateway.

  4. Lorrie

    I read all 3 parts in 1 sitting and it’s very easy to understand. Please continue with this blog series. It’s really very helpful. Thank you so much!!

  5. Tripurari Rai

    Nice blog Linkin. Really clear most of my queries related web development world. Please continue writing the way you have done it here in all 3 blogs. Well done mate. Looking forward for new blogs soon from you. Keep us posted.

  6. Krish

    Am looking for ODATA and SAP UI5. Thank you for these blogs . They are too good and very easy to understand. The way you breakdown things is simply superb.

  7. Muthukumar

    Am looking for ODATA and SAP UI5. Thank you for these blogs . They are too good and very easy to understand.

  8. Venkat

    Hi,

    It’s very nice blog about OData. Understood the basics.
    If you have some time can you please give one small example (Hello world kind of example) how can we create OData and how this can be used in Fiori application. Thanks.

    Regards,
    Venkat

  9. Abrar

    since long time, i wanted to check for ODATA and when i actually started looking, i came accross your blog, its very well explained.

    Thanks.

  10. Shailendra Jain

    Very beautifully and logically explained. Foremost its very easy to understand. Thanks Linkin!

  11. Dan

    I want to learn Fiori (both as a developer and as an admin). i.e Integrating Fiori to other systems. Please let me know about your courses and blogs

  12. Deepak

    Just love the way you explain the topic. i would like to go through all your blogs, Could you please help me on this.

  13. Amit Khedekar

    Hi Linkin,

    You are really doing a great job.
    Thanks for knowledge sharing.
    I would like to be updated with your next part on OData and SAPUI5.

  14. Srishti

    Hi Linkin,

    Your all three blogs are really very helpful for a beginner like me.

    Please update all your further blogs related to OData and SAP netweaver gateway.

    I’m really grateful to you.
    Kepp blogging.
    All the best.

    Thanks a lot.

  15. Hari Prasad

    Hi Linkin,

    Thanks for knowledge sharing. Your explanation is simply superb, to say in another words ‘Lay man also can understand and would be able to teach what is OData after going through your explanation. Most of the knowledge experts poor at explanation/presenting (which is playing key role in machine learning also 🙂 ) but you are not. Keep up the good quality.

  16. AVINASH

    The Blogs are quite informative and easy to understand.
    But, you must add link for the next blog on each and every blog you posted.

  17. Mangesh Pandure

    Short & Sweet…Very good explanation along with real time examples.
    Thanks a lot.

    Looking for Part 4.

  18. Mohan

    Your explanation is awesome.. really very interesting to read and connect with real world senario…

    Same way fiori , SAP UI and gateway also can u please share/

    Mohan.P

  19. Keerthana

    I am finding this very useful. Your explanations are really good and easy to understand.But I’m finding difficulty in moving to the next part .It’ll be helpful if you provide the link for next blog in the current one

  20. Shreejeet vinayraj Alkari

    your bolg is really you have really created milestone without this milestone no once can proceed for o data please share all the blog

  21. Raghavendra Pawar

    Hi, after a long time i came across this amazing blog which is so simple & superb (it was like drinking water).
    Please keep posted about SAP Netweaver Gateway Services, OData, UI5, Fiori and all your future blogs as well.
    Thanks in advance.

  22. Diane

    Thanks – these are very helpful for understanding principles of oData.
    Please send me the further topics links.

  23. Himanshu

    The concepts are easily defined and so beautifully explained with the examples that we can’t satisfy with only one page and want to learn more from you.

  24. krushna Narote

    Quite Helpful content …! thank you ……. Have You made part 4 Or ui5 course that you were talking about …?

  25. Babu

    Hey,
    Very nice detailed blog. Me being non-technical now able to undertstand what oData is. Thanks for that.

    You have mentioned: “In the future blogs I am going to explore more on SAP Netweaver Gateway”.

    I couldn’t find that blog. Can you provide the link or create a blog on that please :).

    Thanks,

Leave a Reply

Your email address will not be published. Required fields are marked *