SAP 基于 ABAP 实现的 gateway 框架里,为什么默认返回100条数据?
答案就在这个参数里:
skip=0&top=100

ODataListBinding.js里,this.loadData的输入参数为100:


this.oModel.iSizeLimit 为100:

在 sap-ui-core-dbg.js里,同样能看到下面高亮出来的硬编码代码:
this.iSizeLimit = 100;

我基于 SAP Spartacus library创建了一个自定义的Storefront实现。在其app.module.ts里,我采用自定义的MyCurrentProductService,去替换 SAP Spartacus 标准的CurrentProductService 实现:

通过AppComponent的构造函数引入OccCartAdapter的依赖:

启动应用,在解析并加载AppComponent时,检测到输入参数的CurrentProductService是通过 Angular 依赖注入提供的,因此执行getOrCreateInjectable 方法:


注意这里的token 指向class CurrentProductService:

而 CurrentProductService的实例化,发生在下图的代码位置。
其中1和2两处的token指向不一样:

第二处的token,已经指向自定义的product service了:

OccCartAdapter也可以通过同样的方式注入:

我在做SAP Cloud Application Programming 练习时,执行下列两条命令后:
- cds init bookshop
- cds watch bookshop


遇到这一条错误消息:
cannot find package module @sap/cds/common

npm install之后,问题解决,现在错误消失了:

@sap/cds/common 位于node_modules文件夹下,例子程序中的Currency,Country等类型和entity等等,就出自这个资源文件。

通过package.json里的dependencies: @sap/cds 引入:

- 点赞
- 收藏
- 关注作者

评论(0)