SAP札记SAP 实用篇

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

2020-01-31  本文已影响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
}
上一篇下一篇

猜你喜欢

热点阅读