Here in this example, We are going to create CDS view with Case statement, here new field “DocText” will be added and value will be calculated based on below.
case vbtyp
when 'A' then 'Inquiry'
when 'B' then 'Quotation'
when 'C' then
case netwr
when 0 then 'Not Paid Order'
else 'Paid Order'
end
else 'Unknown'
end as DocText,
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'CDS - Session Variables'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
}
define view entity ZCDS_CASE
as select from vbak
{
key vbeln as SaleDoc,
vbtyp as DocCatCode,
vkorg as SalesOrg,
vtweg as DistChannel,
spart as Div,
kunnr as CustNo,
case vbtyp
when 'A' then 'Inquiry'
when 'B' then 'Quotation'
when 'C' then
case netwr
when 0 then 'Not Paid Order'
else 'Paid Order'
end
else 'Unknown'
end as DocText,
}