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. ESP8266MOD、刷可以使用AT指令的固件、作为客户端向贝壳云端发送固定数据

    硬件部分 1. ESP8266MOD 2. Micro USB数据线一根 实物图:(小灯不必) 硬件准备好之后,直接用数据线连接到电脑即可,然后找到所对应的COM口,记下来备用! 为ESP8266刷A ...

  2. ESP8266 LUA脚本语言开发: 准备工作-官网获取LUA固件

    前言 这节咱去官网上获取lua开发的固件. 官网下载 下面是我以前写的,咱不使用官网下载的固件,咱使用自己编译的固件.. 填写好自己的的邮箱地址,然后选择好自己需要的功能,一会编译好的固件就会发到您的 ...

  3. 箭头函数可不用return直接将表达式作为函数返回值

    箭头函数如果函数体只有一个表达式,那么表达式将作为函数的返回值,这种写法无须加上return关键字, 看下面两个函数定义 var testAf = () => '111'; var testAf ...

  4. SqlServer事务语法及使用方法(转)

    原博:http://blog.csdn.net/xiaouncle/article/details/52891563 事务是关于原子性的.原子性的概念是指可以把一些事情当做一个不可分割的单元来看待.从 ...

  5. SpringBoot与MyBatis整合案例

    1.导入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId> ...

  6. vue 2.0 及 vue 3.0 rem配置

    vue 2.0 配置 rem 首先先安装postcss-px2rem   (百度可以) https://www.jianshu.com/p/e6476bbc2131 npm install postc ...

  7. [原创]Emmagee V2.4工具使用介绍

    [原创]Emmagee V2.4工具使用介绍 1 Emmagee 介绍 Emmagee 是网易杭州研究院 QA团队开发的一款简单易上手的Android性能监控App,主要用于监控单个App的CPU.内 ...

  8. 2018-2019-2 网络对抗技术 20165318 Exp 8 Web基础

    2018-2019-2 网络对抗技术 20165318 Exp 8 Web基础 原理与实践说明 实践内容概述 基础问题回答 实践过程记录 1.Web前端:HTML 2.Web前端:javascipt ...

  9. “/usr/local/lib/libosipparser2.so.7: could not read symbols: Invalid operation” 异常解决

    编译c代码报错如下 /usr/bin/ld: /tmp/ccl8nBND.o: undefined reference to symbol 'osip_message_get_body' /usr/b ...

  10. Java选择结构和循环结构

    1.选择结构 ①.ifif(){ } if(){}else{} if(){}else if(){}else if(){}else{} ②.switch switch (表达式) { case 常量 1 ...