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

  1. 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.

  1. 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的更多相关文章

  1. SAP CDS redirect view支持写操作吗,一个实验来验证

    According to this wiki, write back on CDS view is not supported: And also it is defined in ABAP help ...

  2. Jerry Wang诚邀广大SAP同仁免费加入我的知识星球,共同探讨SAP技术问题

    大家知道Jerry Wang有一个微信公众号"汪子熙",2017年12月27日,Jerry的这个公众号发布了第一篇文章.到今天2018年10月底为止,正好十个月. 在这10个月的时 ...

  3. 「SAP技术」如何看Z移动类型是复制哪个标准移动类型而创建的?

    [SAP技术]SAP MM 如何看一个自定义移动类型是复制哪个标准移动类型而创建的? 比如项目上有一个自定义移动类型Z59,是复制551移动类型而定义的. OMJJ配置界面里,是有一个Ref字段.如下 ...

  4. 「SAP技术」A项目关联公司间退货STO流程

    [SAP技术]A项目关联公司间退货STO流程 1)创建公司间退货STO单据. 如下图示的公司间退货STO 4500000572, 2),VL10B, 创建交货单. 如下图交货单号:80044918, ...

  5. 「SAP技术」已启用质检物料创建PO时候'STOCK TYPE'没有默认为X?

    「SAP技术」 SAP MM 已启用质检物料创建PO时候'STOCK TYPE'没有默认为X? Part I:SAP 标准行为 1, 物料11002335, QM视图里 01 inspection t ...

  6. 「SAP技术」SAP 如何看序列号被包在哪些HU里?

    「SAP技术」SAP 如何看序列号被包在哪些HU里? 事务代码SE16 ,表名OBJK, 输入物料号,序列号,HeadTable 输入值SER06, 查询结果如下, 根据objlist, 去表ser0 ...

  7. 「SAP技术」 SAP MM MPN物料的采购初探

    「SAP技术」 SAP MM MPN物料的采购初探 1, MPN物料号与我方正常使用料号物料主数据之间的LINK关系维护 MPN料号 14000005 , 我方料号11000250 , 2,采购信息记 ...

  8. ABAP CDS - DEFINE VIEW, name_list

    Syntax ... ( name1, name2, ... ) ... Effect Defines the element names of a CDS view in ABAP CDS in a ...

  9. SAP技术相关Tcode

    ABAP的常用tcode 开发----------------------------------------------- SE51  屏幕制作 SE91  MESSAGE OBJECT SE80  ...

随机推荐

  1. TypeScript 解构和展开

    解构数组 解构数组元素 let input = [1, 2]; let [first, second] = input; console.log(first,second); 交换值 [first, ...

  2. HTML JAVASCRIPT CSS 大小写敏感问题

    html: 大小写不敏感 css: 大小写不敏感 javascript: 大小写敏感 但是 但是 但是 这三者是相互联系的, 所以合在一起使用的时候就产生了变化 ----  TagName, Clas ...

  3. plv8 中使用 eval 函数执行表达式计算

    在js 开发中我们都说eval 函数是邪恶的,但是此函数也有好多妙用,以下是几个简单的案例 eval 执行基于js 的表达式计算 比如我们有以下表 CREATE TABLE rules (    id ...

  4. 基于AOP的插件化(扩展)方案

    在项目迭代开发中经常会遇到对已有功能的改造需求,尽管我们可能已经预留了扩展点,并且尝试通过接口或扩展类完成此类任务.可是,仍然有很多难以预料的场景无法通过上述方式解决.修改原有代码当然能够做到,但是这 ...

  5. Perl 使用perl命令批量替换文件内容

    对linux系统下面多个文本文件内容做处理,是SA经常需要完成的工作.如何高效的完成这个工作,perl应该是一个不错的语言工具.你甚至不需要编写perl脚本,用命令就可以完成上面的工作. perl 命 ...

  6. Scala词法文法解析器 (一)解析SparkSQL的BNF文法

    平台公式及翻译后的SparkSQL 平台公式的样子如下所示: if (XX1_m001[D003]="邢おb7肮α䵵薇" || XX1_m001[H003]<"2& ...

  7. 【Gamma】“北航社团帮”测试报告——小程序v3.0

    目录 测试计划.过程和结果 后端测试--单元测试与覆盖率 后端测试--压力测试 展示部分数据 平均数据 前端测试--小程序v3.0 新功能 各页面均可正常打开,跳转,回退 授权登录与权限检查 页面数据 ...

  8. Docker 部署web项目

    1.查找Docker Hub上的tomcat镜像 # docker search tomcat   2.拉取官方的镜像 # docker pull tomcat   提示:Using default ...

  9. 《Linux就该这么学》培训笔记_ch11_使用Vsftpd服务传输文件

    <Linux就该这么学>培训笔记_ch11_使用Vsftpd服务传输文件 文章最后会post上书本的笔记照片. 文章主要内容: 文件传输协议 Vsftpd服务程序 匿名访问模式 本地用户模 ...

  10. docker 学习操作记录 5-2

    记录5-2 root@53d0a643a2c7:/# quit bash: quit: command not found root@53d0a643a2c7:/# exit exit -->@ ...