美文网首页SAP札记SAP 实用篇
CDS view里case - when - else关键字的用

CDS view里case - when - else关键字的用

作者: 华山令狐冲 | 来源:发表于2020-01-31 12:52 被阅读0次

Requirement

The following mapping logic needs to be implemented in CDS view layer:
if MARA-MTART = "SERV", then PRODUCT_TYPE = "02"
if MARA-MTART <> "SERV" and PROD_TYPE_CODE = '2', then PRODUCT_TYPE = "02"
otherwise PRODUCT_TYPE = ''01".
View source code:

@AbapCatalog.sqlViewName: 'ZMATTYPE'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'material type'
define view Zmaterial_Type as select from mara inner join t134 on mara.mtart 
= t134.mtart {
  key mara.scm_matid_guid16 as product_guid,
   case 
    when ( mara.mtart = 'SERV') or t134.prod_type_code = '2'
     then '02'
    else '01'
  end as product_type
}

相关文章

网友评论

    本文标题:CDS view里case - when - else关键字的用

    本文链接:https://www.haomeiwen.com/subject/oxjgthtx.html