cancel
Showing results for 
Search instead for 
Did you mean: 

Implementing Odata service in SAPUI5

Former Member
0 Kudos

Hi,

   I am new to sapui5 ,trying out some stuffs.

Could you please let me know how to implement this service url

"/sap/opu/odata/sap/ZNWG_ADD_CON/znwg_add_data_modelCollection?$filter=a_imp1 eq 15 and b_imp2 eq 12" in sapui5 .

I have used this method

  var oModel=new sap.ui.model.odata.ODataModel("proxy/sap/opu/odata/sap/ZNWG_ADD_CON/znwg_add_data_modelCollection?$filter=a_imp1 eq 15 and b_imp2 eq 12",false,"username","password");

but system appends $metadata after znwg_add_data_modelCollection

i.e., http://localhost:8006/MyFirstMobile/proxy/sap/opu/odata/sap/ZNWG_ADD_CON/znwg_add_data_modelCollecti...

and error related to this is "The request URI is not valid. The segment 'znwg_add_data_modelCollection' refers to an entity set and not to a single entity".

Thanks,

Vijay.

Accepted Solutions (0)

Answers (1)

Answers (1)

ChandraMahajan
Active Contributor
0 Kudos
Former Member
0 Kudos

Hi Chandra,

    

    Thanks for the links,I have gone through them. Could you please give me some example related to my situation .

Thanks,

Vijay.

Former Member
0 Kudos

,

Were you able to figure this error out?  I was following this tutorial and found that I am in the same boat as you...

allthatjs.com/2012/02/23/getting-started-with-sapui5/

Former Member
0 Kudos

Hi Tapia,

  I did figure out where i was going wrong ,filter's should be assigned to controls rather than using it with  a service url i.e., in my case model should be like :

var oModel=new sap.ui.model.odata.ODataModel("proxy/sap/opu/odata/sap/ZNWG_ADD_CON",false,"username","password");

   and now let us assume the control is oTable,in this case

oTable.bindRows("/CollectionName");            

var oFilter=new sap.ui.model.Filter("a_imp1",sap.ui.model.FilterOperator.EQ,15);

var oFilter1=new sap.ui.model.Filter("b_imp2",sap.ui.model.FilterOperator.EQ,12);

oTable.getBinding("rows").filter(oFilter,oFilter1);

Regards,

Vijay.