cancel
Showing results for 
Search instead for 
Did you mean: 

Getting error in CRUD operations while using sap.ui.model.odata.v2.ODataModel

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi All,


Please anyone address the above issue.

Thanks,

Palsaran

Former Member
0 Kudos

Hope this thread helps you find a solution

How to apply a filter to the oDataModel read fu... | SCN

Regards

Former Member
0 Kudos

Hi Rajeesh,

I've checked the thread which you gave me..but they didn't mention which odata model they are used because its working fine in v1 odata model..i'm facing the issue in v2 odata model only.

Thanks,

Palsaran

Khairwa
Explorer
0 Kudos

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

SAPUI5 SDK - Demo Kit

For V1

SAPUI5 SDK - Demo Kit

Regards,

Rajesh Kherwa

Former Member
0 Kudos

Hi Rajesh,

I've removed the mParameters.async parameter..Now i'm getting the new error

Thanks,

Palsaran

Khairwa
Explorer
0 Kudos

Hi Pal,

As error is saying order no is initial,

try to pass hardcoded sPath instead of deriving values from  'selectedOrderListRow'.

or check value of selectedOrderListRow.Aufnr at runtime.

regards,

Kherwa

Former Member
0 Kudos

Hi Rajesh,

Yes..I've checked..getting the value at runtime but i don't know why this kinda error coming. I think the way defined the path is wrong..But i tried many ways nothing work

Thanks,

Palsaran

Khairwa
Explorer
0 Kudos


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

Former Member
0 Kudos

Thanks Rajesh..already i tried this way..no change..same result.

Thanks,

Palsaran

Khairwa
Explorer
0 Kudos

Try without URL parameters.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Thanks Albert..! Still I'm trying.. let's see..can you say supported sapui5 version for V2 oData model. i mean anything need to update in gateway server.

Thanks,

Palsaran

Former Member
0 Kudos

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

Former Member
0 Kudos

Ok..I'm using version 1.28.5..I'll try to use different version of the UI5.

Thanks,

Palsaran

Chantele
Active Participant
0 Kudos

Please can you post the error?

Former Member
0 Kudos

Yes..