on 09-19-2016 4:24 AM
Hi Experts,
I am new in SAP UI5, I referred the example about OData & UI5 for CRUD operations.
When I code the update function in the view controller, it showed error "OData" is not defined. However I searched on the internet, there are many cases about CRUD operation used OData.request, I don't know why there is error in my case.
BTW, I used the SAP Web IDE local version.
As below is my coding with error in SAP Web IDE. As attached is my source code of view controller.
Thank you in advance and looking forward to your reply.
Hi,
either define odata model
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/model/odata/ODataModel "
], function(Controller,OData)
or before u do service call get instance
var OData = new sap.ui.mode.odata.ODataModel();
OData.request(........)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
sorry i have not seen in API
if you are using
var OData = new sap.ui.mode.odata.ODataModel();
then there is no method called "request"
OData.request(........) // will give error
so u have to use only update/read/create i.e
OData.read(....)
OData.update(....)
OData.create (....)
for API reference : JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.odata.ODataModel
i think in older version of odata may have request(i.e OData.request ) method (i am not sure about this)
Hi Mahesh,
Thank you so much for your explanation.
The issue is solved by using the solution you mentioned.
I also found SAP help about this topic.
OData Write Support - UI Development Toolkit for HTML5 (SAPUI5) - SAP Library
Really appreciate your kindly support.
Thanks and wish you have a good day.
Hi Scott,
I don't know why are you using the oData.request() ..even if there is no variable name oData.
To simply call the Get service .. why can't you use read() method of oData Model ...
var oModel = new sap.ui.model.odata.ODataModel(url,true);
oModel.read();
reference : JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.odata.ODataModel
thanks
Viplove
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Viplove,
Thank you so much for your feedback.
To be honest, I even don't know why OData.request() is needed.
What I want to do is to implement update function by using UI5 and OData. So I refer to the below example. However for some UI5 code, I don't quite understand it.
Since I am just new in SAP UI5, I believe I must have asked so many silly questions, sorry about that.
Anyway, thank for your suggestion. I will check it later.
Cheers.
Hi Scott Zheng ,
Just download data.js file from datajs - JavaScript Library for data-centric web applications - Home and include it in index.html.
or
jQuery.sap.require("sap.ui.thirdparty.datajs"); in sap.ui.getCore().attachInit
U got error oData is not defined because u didn't included datajs library
Thanks
Suresh
HI Scott
You are referring to a old exercise.
here is the oData API
JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.odata.ODataModel
Hi Suresh,
Thank you so much for your comments.
I already solved the issue. The reason is OData.request() is the old way to operate OData for CRUD. The new way is mentioned at below link.
OData Write Support - UI Development Toolkit for HTML5 (SAPUI5) - SAP Library
Anyway, I really appreciate your help.
Cheers.
Hi Scott,
You need define the odata model to use the respective functionality like
var oModel = new sap.ui.model.odata.ODataModel(url,true);
then only you can use
oData.request();
Hope this will works.
Thanks,
Deepak.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.