简体   繁体   中英

Error in calling Filter URL odata service sapui5

I have to pass two filter parameters to ODATA service. I am trying it as follows:

new ODataModel("proxy/http/FIORI-DEV.abc.com:8000/sap/opu/odata/sap/Z_FI_PAY_D_SRV/PdetailSet?$filter=Laufi eq '"+spayid+"' and Laufd eq '"+spaydt+"'?$sap-client=100",

It is giving following error. GET http://localhost:63655/Payment1/proxy/http/FIORI-DEV.abc.com:8000/sap/opu/odata/sap/Z_FI_PAY_D_SRV/PdetailSet/$metadata?$filter=Laufi%20eq%20%27U2-28%27 400 (Bad Request) Log-dbg.js:456 2020-07-21 16:40:39.956774 [ODataMetadata] initial loading of metadata failed -

Can anyone suggest correct way to add filter parameters on ODATA service. Thanks.

When you create a new OData model, then you can not provide any filters. You have to provide the base URI of the service.

Filtering by value happens automatically by the UI5 framework based on a context binding .

  1. You create an OData model with new ODataModel("proxy/http/FIORI-DEV.abc.com:8000/sap/opu/odata/sap/Z_FI_PAY_D_SRV/") (or even better: you define your model using your manifest.json).
  2. You assign your model to your view with view.setModel
  3. Then you create property bindings on controls of your view (which you would usually do in the XML definition, but you can also do it in code)
  4. You bind an element on your view. This is where the filtering happens. The UI5 framework looks at the binding path you provided to controlWhichShowsTheThing.bindObject and will perform an HTTP request to the OData model to retrieve that object when required.

Now you might ask "OK, so how does that binding path look"? This actually depends on the oData model itself and how it addresses individual objects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM