Search code examples
httpodatasapui5hana

Understanding of OData services


This is a question to improve my understanding about OData and the process of OData services. I'm not sure about the process when an OData request is sent to the server from my Fiori app. The app is added to our Fiori Launchpad. When the user wants to create a new target group in the UI, a create request is sent. What happens then in detail? What I thought so far:

  • OData service checks the data
  • If the data is valid, a new entry in the database is created (HTTP POST)
  • If the data is not valid, the OData service sends an error

I'm not sure about what information is delivered by the OData service and what information is delivered directly from the database? Does the OData service work like a adjustor which transfers the messages sent from the database to the application?

I hope you can understand what I'm trying to figure out. Thank you for your time.


Solution

  • it depends how your backend-methods are implemented. Every Entityset usually has one of these Methods:

    • Get Entity
    • Get EntitySet
    • Create
    • Update
    • Delete

    There are some more I guess, but these are mostly used by developers. You can redefine every single method and implement your own Business Logic in there.

    So, let's assume you want to send data from the Frontend to your service and insert the data into a table inside your database. You have to redefine the create method of your entity and implement own logic. This could contain an insert into a database-table. You have to consider, that your oData Service will throw an Error if the types which are sent from the frontend do not match the Entity-Types (i.e. a String into an edm.Time type).

    Here you can find all EDM.Types oData could consume and the correct mapping of the types: https://help.sap.com/saphelp_gateway20sp12/helpdata/en/76/4a837928fa4751ab6e0a50a2a4a56b/frameset.htm

    Hope this helps :)