SAP CDS view自学教程之六:如何在CDS view里消费table function

简介: SAP CDS view自学教程之六:如何在CDS view里消费table function

Let’s try to resolve one real issue now. What we want to achieve is: in CRM we need a CDS view which returns the service order guid together with its Sold-to Party information, “Title” ( Mr. ) and “Name” ( blGMOUTH ).


image.png


The title and Name information are stored on table BUT000, while Service order transactional information is maintained in tableCRMD_PARTNER, which has a field PARTNER_NO ( CHAR32 ) linking to table BUT000’s PARTNER_GUID ( RAW16 ).


image.png



It is not allowed to do join on these two fields since their data type are not equal. This question is asked via this SCN thread: ABAP CDS View: join tables on columns of different type.


As suggested in the Correction Answer, this issue could be resolved by using CDS Table Function. Here below are the detail steps.

image.png

(1) Create a new table function

image.png

With keyword “with parameters”, the client parameters is defined which works as the importing parameters for the ABAP class method zcl_amdp_bp_detail=>crmd_partner_but000. The keywords “returns” defines available fields which could be consumed by other CDS entities.


For further information about AMDP ( ABAP Managed Database Procedure ), please refer to this document Implement and consume your first ABAP Managed Database Procedure on HANA or this blog An example of AMDP( ABAP Managed Database Procedure ) in 740.


(2) Create a new AMDP implementation


Create a new ABAP class zcl_amdp_bp_detail by copying the following source code:


image.png

Here in line 30 the two columns of CRMD_PARTNER and BUT000 are joined. The importing parameter is used in SQLScript source code by adding a “:” before the variable name. The hard code “00000001” means the constant value for partner function “Sold-to Party”.image.png

(3) Consume the created table function in CDS view

image.png

Please note that the created table function in step1 could be directly consumed just as a normal CDS view, see example in line 8.

Since the table function declares client as parameter, so when consumed, I put the current client id 001 into it. The fields defined as the returning parameters in table function could be used in consuming view.image.png

(4) Test the whole solution

Click F8 on the view z_c_partner, check whether data previews as expected.


image.png


or you can also check against single data record, by clicking “SQL Console”, maintain the SQL and click Run:


image.png


The same test could also easily be done on ABAP side:


image.png


image.png

相关文章
|
1月前
|
SQL Android开发
创建 SAP ABAP CDS View 保存失败 - Dependencies DDL source - View Entity not written
创建 SAP ABAP CDS View 保存失败 - Dependencies DDL source - View Entity not written
9 0
创建 SAP ABAP CDS View 保存失败 - Dependencies DDL source - View Entity not written
|
2月前
|
搜索推荐
如何让 SAP UI5 Smart Table 支持多项选择(Multiple-Selection)试读版
如何让 SAP UI5 Smart Table 支持多项选择(Multiple-Selection)试读版
19 0
|
1月前
|
Web App开发 开发者 存储
介绍一个 webp 格式转 png 格式的软件:XNConvert
介绍一个 webp 格式转 png 格式的软件:XNConvert
30 6
介绍一个 webp 格式转 png 格式的软件:XNConvert
|
1月前
|
数据库 存储 BI
SAP ABAP CDS View 源代码存储的数据库表揭秘和其他相关数据库表介绍试读版
SAP ABAP CDS View 源代码存储的数据库表揭秘和其他相关数据库表介绍试读版
12 0
SAP ABAP CDS View 源代码存储的数据库表揭秘和其他相关数据库表介绍试读版
|
1月前
|
数据库
SAP S/4HANA 系统的底层基石 - 通过实际的例子,介绍 CDS View 入门级的概念试读版
SAP S/4HANA 系统的底层基石 - 通过实际的例子,介绍 CDS View 入门级的概念试读版
8 0
SAP S/4HANA 系统的底层基石 - 通过实际的例子,介绍 CDS View 入门级的概念试读版
|
1月前
|
数据库
迈入 SAP CDS View 世界的前置知识 - SAP ABAP 数据库视图介绍试读版
迈入 SAP CDS View 世界的前置知识 - SAP ABAP 数据库视图介绍试读版
11 0
迈入 SAP CDS View 世界的前置知识 - SAP ABAP 数据库视图介绍试读版
|
1月前
|
数据库 SQL 应用服务中间件
SAP ABAP CDS View 和 HANA CDS View 相同点和不同点辨析
SAP ABAP CDS View 和 HANA CDS View 相同点和不同点辨析
24 0
SAP ABAP CDS View 和 HANA CDS View 相同点和不同点辨析
|
4月前
|
数据库
SAP ABAP 更新函数(Update Function Module)执行出错的原因分析试读版
SAP ABAP 更新函数(Update Function Module)执行出错的原因分析试读版
35 0
|
4月前
|
数据库
130. SAP ABAP 更新函数(Update Function Module)执行出错的原因分析
130. SAP ABAP 更新函数(Update Function Module)执行出错的原因分析
26 0
|
7月前
|
设计模式 SQL 数据建模
SAP Virtual Data Model 和 CDS View 的关联关系
SAP Virtual Data Model 和 CDS View 的关联关系
31 0