SAP技术 - How to create a CDS redirect view for a given database table
Scenario
Suppose we have a database table A, and then we create a CDS redirect view B for it, then every time the READ OPEN SQL is done on table A, ABAP kernel will direct this request to view B, and serve the request with content from B.
Prerequisite
In order to make view B qualified as redirect view for table A, both A and B must have the same fields with exactly the same order and tehcnical name.
How to
- In order to demonstrate the logic, I create a Z table in ER9/001 with four fields as below.
Write a simple report to test:
DATA: lt_table TYPE STANDARD TABLE OF zcomm_product.
SELECT * INTO TABLE lt_table FROM zcomm_product.
WRITE: / sy-dbcnt.
Since this table is just created, so there is no content inside it, 0 is expected for output.
- Create a new CDS view with following source code:
@AbapCatalog.sqlViewName: 'zmara_cds'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Redirect ZCOMM_PRODUCT to MARA'
define view Zp_Mara_Redirect as select from mara {
mara.matnr as PRODUCT_ID,
case
when (mara.mtart = 'HAWA' or mara.mtart = 'INTR')
then '01'
when (mara.mtart = 'DIEN' or mara.mtart = 'COUP')
then '02'
else ''
end as product_Type,
mara.mtart as object_family
}
Note: since this is just a example, the mapping between ZCOMM_PRODUCT.PRODUCT_TYPE to MARA.MTART does not make sense from business point of view, I just use it to illustrate how a field from database table could be mapped to a CDS view ( field name and technical type must be equal ).
Once CDS view is done, activate it and assign the view to database table via menu in SE11:
Once done, execute the report once again. This time, you could see the SELECT OPEN SQL on empty table ZCOMM_PRODUCT is actually redirected to MARA table - lots of entries returned.
Redirect is also automatically done when you browse the content of ZCOMM_PRODUCT from tcode SE16:
How does redirect work under the hood
If you perform a ST05 trace, you can observe the redirect is automatically done by ABAP runtime, no action from application side is needed.
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
SAP技术 - How to create a CDS redirect view for a given database table的更多相关文章
- SAP CDS redirect view支持写操作吗,一个实验来验证
According to this wiki, write back on CDS view is not supported: And also it is defined in ABAP help ...
- Jerry Wang诚邀广大SAP同仁免费加入我的知识星球,共同探讨SAP技术问题
大家知道Jerry Wang有一个微信公众号"汪子熙",2017年12月27日,Jerry的这个公众号发布了第一篇文章.到今天2018年10月底为止,正好十个月. 在这10个月的时 ...
- 「SAP技术」如何看Z移动类型是复制哪个标准移动类型而创建的?
[SAP技术]SAP MM 如何看一个自定义移动类型是复制哪个标准移动类型而创建的? 比如项目上有一个自定义移动类型Z59,是复制551移动类型而定义的. OMJJ配置界面里,是有一个Ref字段.如下 ...
- 「SAP技术」A项目关联公司间退货STO流程
[SAP技术]A项目关联公司间退货STO流程 1)创建公司间退货STO单据. 如下图示的公司间退货STO 4500000572, 2),VL10B, 创建交货单. 如下图交货单号:80044918, ...
- 「SAP技术」已启用质检物料创建PO时候'STOCK TYPE'没有默认为X?
「SAP技术」 SAP MM 已启用质检物料创建PO时候'STOCK TYPE'没有默认为X? Part I:SAP 标准行为 1, 物料11002335, QM视图里 01 inspection t ...
- 「SAP技术」SAP 如何看序列号被包在哪些HU里?
「SAP技术」SAP 如何看序列号被包在哪些HU里? 事务代码SE16 ,表名OBJK, 输入物料号,序列号,HeadTable 输入值SER06, 查询结果如下, 根据objlist, 去表ser0 ...
- 「SAP技术」 SAP MM MPN物料的采购初探
「SAP技术」 SAP MM MPN物料的采购初探 1, MPN物料号与我方正常使用料号物料主数据之间的LINK关系维护 MPN料号 14000005 , 我方料号11000250 , 2,采购信息记 ...
- ABAP CDS - DEFINE VIEW, name_list
Syntax ... ( name1, name2, ... ) ... Effect Defines the element names of a CDS view in ABAP CDS in a ...
- SAP技术相关Tcode
ABAP的常用tcode 开发----------------------------------------------- SE51 屏幕制作 SE91 MESSAGE OBJECT SE80 ...
随机推荐
- Nothing to say
1. This moment will nap, you will have a dream; but this moment study, you will interpret a dream.此刻 ...
- Tarjan 算法求 LCA / Tarjan 算法求强连通分量
[时光蒸汽喵带你做专题]最近公共祖先 LCA (Lowest Common Ancestors)_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili tarjan LCA - YouTube Tarj ...
- GitLab修改root用户密码
GitLab是一个私有的Git仓库,具有较好的项目管理和用户管理能力.对于普通用户而言,通过系统的重置密码,接受邮件即可解决,可是GitLab的管理员账号,缺省的邮箱是一个不存在的邮箱地址,所以没有办 ...
- JavaScript 一些实用技巧
快速创建从0到n的数字 let arr1 = [...(new Array(n)).keys()]; let arr2 = Array.from({length:n},(v, k) => k); ...
- java 获取类路径
package com.jason.test; import java.io.File; import java.io.IOException; import java.net.URL; public ...
- OpenSTF 平台搭建
什么是OpenSTF? OpenSTF(Smartphone Test Farm)是一个web端移动设备管理平台,可以从浏览器端远程调试.远程管理设备.其实有点类似于我们现在很火热的云测平台,如:te ...
- Ognl 使用实例手册
上一篇博文介绍了ongl的基础语法,接下来进入实际的使用篇,我们将结合一些实际的case,来演示ognl究竟可以支撑到什么地步 在看本文之前,强烈建议先熟悉一下什么是ognl,以及其语法特点,减少阅读 ...
- HTML5微信jssdk录音播放语音的方法
HTML5微信jssdk录音播放语音的方法需要注意的2个问题1 就是一定要判断1秒内 录音都不算 ps:太短不能录音 2 录音超过1分钟 会发现正在录音突然消失 所以要写wx.onVoiceRecor ...
- 爬虫框架 ---- scrapy 框架的介绍与安装
----- 爬虫 基于B/S 模式的数据采集技术,按照一定的规则,自动的抓取万维网信息程序 以一个或多个页面为爬取起点,从页面中提取链接实现深度爬取 使用爬虫的列子 第三方抢票软件(360/猎豹/ ...
- Oracle查询所有字段另加两个拼接字段的操作
Oracle查询所有字段,再加两个字段拼接, select a.*,(SNO||SNAME) from TEST_STUDENT a; 同理,查询所有字段,其中两个字段求和:(SNO和SAGE都是NU ...