CDS

Use of Parameter in CDS View

One question, I often get asked is – how to choose between “Where Clause” and “Parameter”. And I answer that I only use parameters in a CDS view – if I absolutely have to. The next question is obviously what are those cases. Let’s have some examples here.

If we need to filter data, there are better options than parameters. But parameters can do more than just filter data – they can influence the logic.

Case 1: A sales forecasting app, needs input from the user to dynamically calculate the sales volume in the next quarter using a factor.

Case 2: A global company wants the flexibility to see the total expenses in different units – the unit to be entered by the user.

Case 3: Flexibility to show values from different columns, for example, net weight or gross weight, depending on user input.

Probably, you got the idea – parameters can influence data selection or data manipulation. Let’s see an example of a parameter used in a where clause.

@AbapCatalog.sqlViewName: 'Z000T023T'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Material Group Description'

define view Z000_T023T 
with parameters p_lang  :spras
as select from t023t {
    key t023t.matkl,
        t023t.wgbez60,
        case :p_lang when 'E' then 'English'
        else 'Other' 
        end as language,
        t023t.spras
}

I hope this makes sense. If it does, it makes sense to follow our LinkedIn page. LinkedIn page is the best place to get the latest updates on training sessions and blogs or to share feedback.

error

Enjoy this blog? Please spread the word :)

Follow by Email
Twitter
LinkedIn
LinkedIn
Share