ABAP CDS on HANA-6

cds

Case Expression in CDS View

 

 

Create a CDS view and use below case expression.

1


@AbapCatalog.sqlViewName: ‘ZFLIGHT_VW’
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: ‘Use of Case Expression in CDS view’
define view Zflight_Case_Exp

as select from spfli {
key spfli.carrid,
key spfli.connid,
       spfli.countryfr,
       spfli.countryto,
case
when distance >= 10000 then ‘Long Way Journey’
when distance >= 5000 and distance < 10000 then ‘Medium Way Journey’
else ‘Short Way journey’
end as journey_type
}


Output- Data Preview

2

SPFLI Table Entries

3


 

2 comments

    1. Hi , The computed field that has to be displayed on UI to be treated differently. The computed field here is simply a text but it could be an interger or something which helps in intermediate calculation. Thanks.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s