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. 数据库: 安装配置数据库,使用Navicat for MySQL和手机APP 连接测试(如果上一节碰到问题可参考这一节)

       咱就安装上       还有这个                    最终测试请参考上一节 启动MySQL服务主要有以下两种方法: 第一种: 在搜索框中输入“services,msc” ,en ...

  2. 请用js语言实现sort排序函数,要求:sort([4,5,2,-1,0])返回[-1,0,2,4,5]

    Array.prototype.sort1=function(fn){ var len=this.length; while(len>0){ for(var i=0;i<len;i++){ ...

  3. IO多路复用——poll

    1.基本知识 poll是Linux中的字符设备驱动中的一个函数.Linux 2.5.44版本后,poll被epoll取代.和select实现的功能差不多,poll的作用是把当前的文件指针挂到等待队列. ...

  4. 【可持久化0/1Trie】【P4735】最大异或和

    Description 给定一个长度为 \(n\) 的序列 \(A\),有 \(m\) 次操作,每次要么在序列尾部再添加一个数,将序列长度 \(n\) 加一,要么给进行一次查询,给定查询参数 \(l, ...

  5. java web开发入门四(spring)基于intellig idea

    spring 1.spring简介 Spring框架,可以解决对象创建以及对象之间依赖关系的一种框架. 且可以和其他框架一起使用:Spring与Struts,  Spring与hibernate (起 ...

  6. 安装goimports

    当我们执行 go get golang.org/x/tools/cmd/goimports 会报错package golang.org/x/tools/cmd/goimports: unrecogni ...

  7. quantmod

    -quantmod(数据和图形) -TTR(技术分析) -blooter(账户管理) -FinancialInstrument(金融产品) -quantstrast(策略模型) -Performanc ...

  8. Solr7.x学习(3)-创建core并使用分词器

    1.创建core文件夹 ck /usr/local/solr-7.7.2/server/solr mkdir first_core cp -r configsets/_default/* first_ ...

  9. Linux 下配置 iSCSI 客户端

    安装客户端软件 Redhat/Centos: yum install -y iscsi-initiator-utils Debian/Ubuntu: apt-get install open-iscs ...

  10. SpringCloud组件学习-图

    图很清晰,直接放大浏览器,或者下载下来放大看