其他分享
首页 > 其他分享> > 记录ABAP开发的日常——使用eclipse创建简单CDS Views案例

记录ABAP开发的日常——使用eclipse创建简单CDS Views案例

作者:互联网

前言: 在日常的ABAP开发中,有时候开发的报表设计的表或者字段比较多,而且经常用到,所以可以将这些表字段定义为CDS视图,可以大大提高我们的开发效率,当然CDS的应用远不止如此,本次只是简单介绍如何创建CDS View,步骤如下:

1.创建CDS View

1.1 新建Other ABAP Repository Object

1.1新建Other ABAP Repository Object

1.2 选择Data Definition

1.2选择Data Definition

1.3 完善信息

1.3完善信息

1.4 编写代码

// 可以使用 Alt + / 快速调用模板
@AbapCatalog.sqlViewName: 'ZS_SD_TEST_01'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'CDS测试案例'
define view Zcds_Sd_Test_01 as select from vbak as A
    inner join vbap as B on A.vbeln = B.vbeln
    inner join vbfa as C on B.vbeln = C.vbelv and B.posnr = C.posnv
    left outer join t023t as D on B.matkl = D.matkl
    and D.spras = $session.system_language
 {
    A.erdat as erdat,
    A.erzet as erzet,
    A.ernam as ernam,
    A.audat as audat,
    A.vbtyp as vbtyp,
    A.auart as auart,
    A.lifsk as lifsk,
    A.vkorg as vkorg,
    A.vtweg as vtweg,
    A.spart as spart,
    A.vkgrp as vkgrp,
    A.fksak as fksak,
    A.gbstk as gbstk,
    A.vbeln as vbeln,
    B.posnr as posnr,
    B.matnr as matnr,
    B.matwa as matwa,
    B.pmatn as pmatn,
    B.charg as charg,
    B.matkl as matkl,
    C.wbsta as wbsta,
    C.fktyp as fktyp,
    D.wgbez as wgbez
}

2.使用CDS View

2.1 创建测试程序

创建ABAP Program
对象定义

2.2 编写测试代码

2.2编写测试代码

2.3 测试结果

2.3测试结果

3.CDS注解

关于CDS的相关@注解信息,这里有一个博主进行了详细的解释说明,不懂的可以去阅读了解下:

标签:vbeln,Views,eclipse,matkl,AbapCatalog,ABAP,CDS,posnr
来源: https://www.cnblogs.com/zyhcs/p/16189039.html