当前位置:网站首页>ABAP CDS VIEW WITH ASSOCIATION示例
ABAP CDS VIEW WITH ASSOCIATION示例
2022-04-23 06:25:00 【rogerix4】
1. ASSOCIATION的应用场景
- ASSOCIATION是一种通过Join条件从多个表中获取数据的连接,但这些是“按需连接”,也就是说,它们只会在用户访问需要关联表的所需数据时被触发
- 由于ASSOCIATION是按需触发,当Join较多实际访问时用户只访问单个或者少数Join时,相比较传统可以高效率地完成SQL
- ASSOCIATION的关联基数
- [ 0 … 1 ] = 最多关联一个(at most one)
- [ 1 … 1 ] = 只能一一对应关联(exactly one)
- [ 0 … n ] = 关联任意数量(any number)
- [ 1 … n ] = 至少关联一个(at least one)
- [ 1 … 1 ] [ 1 … n ]保证了关联的主表始终至少有一条记录
2. 实现CDS VIEW WITH ASSOCIATION
-
创建一个CDS VIEW WITH ASSOCIATION
-
实现CDS VIEW WITH ASSOCIATION代码
@AbapCatalog.sqlViewName: 'ZCDS_ASSO_01' @AbapCatalog.compiler.compareFilter: true @AbapCatalog.preserveKey: true @AccessControl.authorizationCheck: #CHECK @EndUserText.label: 'cds view with association' define view ZCDS_ASSOCIATIONS as select from spfli as t1 association [1] to sflight as _sflight on $projection.carrid = _sflight.carrid { key t1.carrid, t1.connid, t1.countryfr, t1.cityfrom, t1.airpfrom, t1.countryto, t1.cityto, t1.airpto, t1.fltime, t1.deptime, t1.arrtime, t1.distance, t1.distid, _sflight }
3. 数据预览
-
任意位置单击鼠标右键,点击Follow Association 可查看ASSOCIATION
-
双击Associations查看,由此可见默认Association方式为**[ 0 … 1 ]**
-
Association _sflight
4. 在ABAP中调用
- 常用的Select * 写法无法获取到Association _sflight中的数据内容,这也印证了开头所讲(Association 只会在用户访问需要关联表的所需数据时被触发)
- 正确的读取方法
- 激活报错:The association “_SFLIGHT” could not be resolved.修正
- 使用不正确的调用View Name激活时会报错
- 解决方法:使用View Name即可
- 使用不正确的调用View Name激活时会报错
版权声明
本文为[rogerix4]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_30797051/article/details/123889093
边栏推荐
猜你喜欢
随机推荐
嵌入式相关面经(一)
SAP pi / PO rfc2restful publishing RFC interface is a restful example (proxy indirect method)
The difference and application of VR, AR and MR, as well as some implementation principles of AR technology
Reflect on the limitations of event bus and the design and implementation of communication mechanism in component development process
8.分页查询
NPM installation stepping pit
【TED系列】如何与内心深处的批评家相处?
Dirichlet 前缀和(数论优化式子复杂度利器)
SAP Excel 已完成文件级验证和修复。此工作簿的某些部分可能已被修复或丢弃。
ogldev-读书笔记
What is a closure?
对STL容器的理解
On BFC (block formatting context)
How to judge whether a point is within a polygon (including complex polygons or a large number of polygons)
菜菜的刷题日记 | 蓝桥杯 — 十六进制转八进制(纯手撕版)附进制转换笔记
Nacos / sentinel gateway current limiting and grouping (code)
SAP RFC_CVI_EI_INBOUND_MAIN BP主数据创建示例(仅演示客户)
P2257 YY的GCD(莫比乌斯反演)
简易随机点名抽奖(js下编写)
h5本地存储数据sessionStorage、localStorage