简体   繁体   English

调用过滤器 URL odata 服务 sapui5 时出错

[英]Error in calling Filter URL odata service sapui5

I have to pass two filter parameters to ODATA service.我必须将两个过滤器参数传递给 ODATA 服务。 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 - 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(错误请求)Log-dbg.js:456 2020-07-21 16:40:39.956774 [ODataMetadata] 元数据初始加载失败 -

Can anyone suggest correct way to add filter parameters on ODATA service.谁能建议在 ODATA 服务上添加过滤器参数的正确方法。 Thanks.谢谢。

When you create a new OData model, then you can not provide any filters.当您创建新的 OData model 时,您不能提供任何过滤器。 You have to provide the base URI of the service.您必须提供服务的基本 URI。

Filtering by value happens automatically by the UI5 framework based on a context binding . UI5 框架基于上下文绑定自动按值过滤。

  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). 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您使用view.setModel将 model 分配给您的视图
  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)然后在视图的控件上创建属性绑定(您通常会在 XML 定义中执行此操作,但您也可以在代码中执行此操作)
  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. UI5 框架查看您提供给controlWhichShowsTheThing.bindObject的绑定路径,并将向 OData model 执行 HTTP 请求,以便在需要时检索该 ZA8CFDE6331BD59EB2AC96F8911C4B666。

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.这实际上取决于 oData model 本身以及它如何处理单个对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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