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 ...
随机推荐
- (HK1-0)激活与配置摄像机
HK使用手册 网络连接 激活与配置摄像机 网络摄像机可通过 SADP 软件.客户端软件和浏览器三种方式激活, 具体激活操作方式可参见<网络摄像机操作手册>. 1. 安装随机光盘或从官网下载 ...
- LeetCode 987. Vertical Order Traversal of a Binary Tree
原题链接在这里:https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/ 题目: Given a binary ...
- ASP.NET中IOC容器Autofac(依赖注入DI 控制反转IOC)
IOC的一个重点是在程序运行中,动态的向某个对象提供它所需要的其他对象.这一点是通过DI来实现的.Autofac则是比较流行的一款IOC容器. IoC和DI有什么关系呢?其实它们是同一个概念的不同角度 ...
- Python——IO多路复用之select模块poll方法
Python——IO多路复用之select模块poll方法 使用poll方法实现IO多路复用 .├── poll_client.py├── poll_server.py└── settings.py ...
- [RN] Android 设备adb连接后unauthorized解决方法
Android 设备adb连接后unauthorized解决方法 安卓设备usb或者adbwireless连接后输入adb device后都是未授权状态 相信很多同学都会遇到这种情况,除了一直重复开关 ...
- windows下如何制作和应用数字签名证书 全流程
目前我们在发布应用程序时,有时用户下载后会被360杀毒当做木马直接隔离.为应用程序可执行文件打上数字签名可以让360杀毒放宽检测规则.下文是讲述如何制作数字签名证书的过程. 需要准备的工具:makec ...
- 【字符串】【P5830】 【模板】失配树
[字符串][P5830] [模板]失配树 Description 给定一个长度为 \(n\) 的字符串 \(S\),有 \(m\) 次询问,每次询问给定 \(S\) 的两个前缀,求它们的最长公共 bo ...
- Ajax 与 Django
目录 Django与AJAX orm优化查询: MTV 与 MVC模型 choices 参数 update 与 save的区别 AJAX导入: Jquery 实现AJAX ajax基本语法结构 原生J ...
- bind 安装 和配置(master/slave)
一,软件安装 #sudo yum -y install bind 二,配置 # vi /etc/named.conf // // named.conf // // Provided by Red H ...
- pip: failed to create process.解决方法
昨天在使用pip过程,pip提示:failed to create process. 解决方法:python -m pip install xxx 就可以了 如以matplotlib为例即:pytho ...