How to consume an Odata service from
sapui5 mobile application is explained here.
Here we will use OData Model of SAPUI5 framework.The OData model is a server-side model, meaning that the data set is only available on the server and the client only knows the currently visible (requested) data. Operations, such as sorting and filtering, are done on the server. The client sends a request to the server and shows the returned data.
The OData model currently supports OData version 2.0.SAP reccommend using v2 model.
Steps
Pre-requisites
1.odata
service
2.sapui5
library files loadedHere we will use OData Model of SAPUI5 framework.The OData model is a server-side model, meaning that the data set is only available on the server and the client only knows the currently visible (requested) data. Operations, such as sorting and filtering, are done on the server. The client sends a request to the server and shows the returned data.
The OData model currently supports OData version 2.0.SAP reccommend using v2 model.
Steps
- Create model instance.One OData model instance can cover only one OData service.
- Read entity.This triggers a get request to the specified path.
- See Sample provided.Here on clicking the button OData read operation is performed.
var oModel = new sap.ui.model.odata.v2.ODataModel({ serviceUrl: "https://cors-anywhere.herokuapp.com/services.odata.org/V2/Northwind/Northwind.svc/", /*headers: { "myHeader1" : "value1", "myHeader2" : "value2" }*/ });
oModel.read("/Categories", { method: "GET", success: function(data) { alert(JSON.stringify(data)); }, error: function() { } });
OData Read Operation
If you enjoyed this post, Please Share!!
You are lifesaver ;) thanks a lot.
ReplyDeleteThanks for your valuable feedback
DeleteHi Rajeesh,
ReplyDeleteCan you provide something similar for triggering an update function from SAPUI5 to SAP?
Sure...
DeleteHi REALITYKILLS,
Deletesee my new post
odata-update-operation-sapui5-application