使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

新建一个Destination,类型为HTTP,再添加三个额外的Properties,其中WebIDEUsage设置为odata_gen:

使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

其中WebIDEUsage属性的值,除了odata_gen之外,还有odata_abap,ui5_execute_abap等选择。

关于这些值的区别,参考SAP帮助文档:

Values for the WebIDEUsage property determine how the SAP Web IDE interprets the destination definition & presents it to you for connection and consumption. The value odata_gen signifies that the destination represents generic OData services (as opposed to OData services that are hosted on an SAP Gateway system, for example) and that the full, specific OData service URL specification is to be provided in the SAP Web IDE New Project wizard, specifically via the Service URL data connection source, as shown in this example scenario:

https://help.sap.com/viewer/825270ffffe74d9f988a0f0066ad59f0/CF/en-US/5c3debce758a470e8342161457fd6f70.html

使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

WebIDE里新建一个UI5应用,基于模板SAP Fiori Worklist Application创建。

使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

维护项目明细:

使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

选择这个Fiori应用基于的OData服务,从Service Url的下拉菜单里,选中之前创建的Destination:

使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

这里我们需要手动补全OData服务的url:
/V2/Northwind/Northwind.svc

使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

点击Test按钮,获得这个OData服务里包含的data collection:

使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

点击Diagram按钮可以看到这个OData服务所有的entity和其之间的相互关系:

使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务
使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

选定OData服务后,点击下一步,应用类型选择为Standalone App:

使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

Object Collection选择Products:

使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

依次维护剩下的属性,点击Finish:

使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

打开生成的项目文件,用Layout Editor打开Worklist.view.xml:

使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

找到显示产品价格单位的空间,将值硬编码成USD:

使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

在manifest.json里维护useBatch为false,这样可以让该Fiori应用采用非batch模式消费OData服务。

使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

直接运行,看到该应用能够正常工作了:

使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

并且在Chrome开发者工具network标签页里,看到该OData服务确实是以非batch模式的方式调用:

使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务

要获取更多Jerry的原创文章,请关注公众号"汪子熙":
使用SAP WebIDE开发SAP Fiori Worklist应用消费OData服务