on 06-17-2016 8:09 AM
Hi Experts,
I'm getting error in CRUD operations while using sap.ui.model.odata.v2.ODataModel.Before that let me explain what i did in sap.ui.model.odata.ODataModel.
This is my url = "/sap/opu/odata/xxxxx/xxx_OBJLIST_LIST_SRV/ObjListSet?$filter=Aufnr eq '7007204' and Screenid eq ''&$format=json";
var ServiceUrl = "/sap/opu/odata/xxxxx/xxx_OBJLIST_LIST_SRV/";
var sPath = "ObjListSet?$filter=Aufnr eq '" + selectedOrderListRow.Aufnr + "' and Screenid eq ''&$format=json";
var oDataModel = new sap.ui.model.odata.ODataModel(ServiceUrl,true);
oDataModel.read(sPath, null,null,true,
function onSuccess(oData, oResponse)
{
successFunc(oData);
},
function onError(oData, oResponse)
{
});
it's working fine..but if i changed to sap.ui.model.odata.v2.ODataModel getting error.
So can you please explain how to integrate the services in sap.ui.model.odata.v2.ODataModel.
Thanks,
Palsaran
Hi Dudes,
Thanks to all..!! Finally i found the issue..The problem is the way we defined the filter is wrong.
It should be
var serviceUrl = "/sap/opu/odata/xxxxx/xxx_OBJLIST_LIST_SRV/";
var oDataModel = new sap.ui.model.odata.v2.ODataModel(serviceUrl);
oModel.read("/ObjListSet", {
filters:[
new sap.ui.model.Filter({
path: "Aufnr",
operator: sap.ui.model.FilterOperator.EQ,
value1: selectedOrderListRow.Aufnr ,
})
],
success: function(oData, oResponse){
},
error: function(oError){
}
});
Thanks,
Palsaran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hope this thread helps you find a solution
How to apply a filter to the oDataModel read fu... | SCN
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Pal
var oDataModel = new sap.ui.model.odata.ODataModel(ServiceUrl,true);
oDataModel.read(sPath, null,null,true,
function onSuccess(oData, oResponse)
{
successFunc(oData);
},
function onError(oData, oResponse)
{
});
mParameters.async parameter is not there in sap.ui.model.odata.v2.ODataModel
read function.
Compare Parameters:
For V2
For V1
Regards,
Rajesh Kherwa
var serviceUrl = "/sap/opu/odata/xxxxx/xxx_OBJLIST_LIST_SRV/";
var oDataModel = new sap.ui.model.odata.v2.ODataModel(serviceUrl);
var parameters = "$filter=Aufnr eq '" + selectedOrderListRow.Aufnr + "' and Screenid eq ' '&$format=json";
oModel.read("/ObjListSet", {
urlParameters: parameters ,
success: function(oData, oResponse){
},
error: function(oError){
}
});
regards,
Kherwa
Hi,
Try setting the parameters explicitly. For example:
oDataModel.read(sPath, {
success: function(){
alert("success");
},
error: function(){
alert("error");
}
});
I think the problem is that the order of the parameters are incorrect. So if you explicitly set the parameters, then the order won't break the parameters. Take a look at the documentation to see which parameters you can set: JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.odata.v2.ODataMod..., I think they are different then the v1 parameters
See this link, to see how this solved a similar problem:
Regards
Albert Volschenk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Albert,
Thanks for your reply..!!
I've tried but i couldn't get the result..still i'm getting the same error..My doubt is, the same code is working fine in sap.ui.model.odata.ODataModel but it's not working in sap.ui.model.odata.v2.ODataModel. So anything needs to be done in sap.ui.model.odata.v2.ODataModel ?. I mean, is there any separate format for v2 model ?.
Thanks,
Palsaran
Hi,
Can you post the example that you tried with the explicit parameters? It would also be good to see how you create your version 2 model, maybe there's a broken parameter when you create the model.
I can't remember that I had to do anything specific for the model when I switched from v1 to v2, other than changing to explicit properties instead of relying on the order of the constructor's variables.
Regards
Albert Volschenk
Hi,
Yes..This is my sample code.I'm not sure whether it's right way to define explicit parameters but I'm not getting any code error
var parameters = '$filter=Aufnr eq '" + selectedOrderListRow.Aufnr + "' and Screenid eq ''&$format=json';
oModel.read("/ObjListSet", {
"method": "GET",
urlParameters: parameters ,
success: function(oData, oResponse){
},
error: function(oError){
}
});
but no luck..still i'm getting the same result
Thanks,
Palsaran
Hi,
I don't know if your parameters variable is correct. Maybe try it without the parameters and see if it is working then.
for example:
oModel.read("/ObjListSet", {
method: "GET",
success: function(oData, oResponse){
},
error: function(oError){
}
});
Unfortunately my knowledge runs out at this point so I can't help much further. But I hope you get it to work.
Regards
Albert
Hi,
Unfortunately I don't know much about the gateway server. There is however one more thing that I might be able to help with. Which version of the UI5 Library are you using? We ran into problems with our update request on v1.32 (using oData v2, we didn't test v1), so we reverted back to v1.28. Maybe you can try using a different version of the UI5 library to fix the problem? I know we've experienced some problems between versions in the past, so maybe this is a similar case?
Regards
Albert Volschenk
Please can you post the error?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.