当前位置:网站首页>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
边栏推荐
猜你喜欢
[Educational Codeforces Round 80] 解题报告
菜菜的并发编程笔记 |(五)线程安全问题以及Lock解决方案
Nacos/sentinel网关限流和分组 (代码)
AuthorizationServer(授权服务器的简单搭建)
菜菜的并发编程笔记 |(九)异步IO实现并发爬虫加速
反思|开启B站少女心模式,探究APP换肤机制的设计与实现
Educational Codeforces Round 81 (Rated for Div. 2)
菜菜的刷题日记 | 238.除自身以外数组的乘积
学习笔记6-几种深度学习卷积神经网络的总结
Solutions to common problems in visualization (VII) solutions to drawing scale setting
随机推荐
嵌入式相关面经(一)
NPM installation stepping pit
菜菜的刷题日记 | 蓝桥杯 — 十六进制转八进制(纯手撕版)附进制转换笔记
What is a closure?
如何SQL 语句UNION实现当一个表中的一列内容为空时则取另一个表的另一列
How to judge whether a point is within a polygon (including complex polygons or a large number of polygons)
Reflect on the limitations of event bus and the design and implementation of communication mechanism in component development process
手游性能优化
SAP PI/PO Soap2Proxy 消费外部ws示例
[CF 1425D]Danger of Mad Snakes(组合计数+容斥)
P2257 YY的GCD(莫比乌斯反演)
Mysql的存储引擎
2.限定查询
[COCI] Vještica (子集dp)
图论入门——建图
[CodeForces - 208E] Blood Cousins(k代兄弟问题)
SAP PI/PO rfc2RESTful 發布rfc接口為RESTful示例(Proxy間接法)
常用的DOS命令
11.表和库的管理
SAP PI/PO登录使用及基本功能简介