Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Optional parameters on CDS Views?

former_member186444
Participant
4,438

As far as I can tell (as I cannot find reference to it anywhere), it's not possible to define an optional parameter for a CDS view.

Is that correct? Thanks.

1 ACCEPTED SOLUTION
Read only

pfefferf
Active Contributor
0 Likes
1,674

Hello Malcolm,

no, optional parameters are not possible (at the moment). To each input parameter an actual parameter must be assigned. Please take a look to paragraph "Notes" in online help ABAP Keyword Documentation.

Best Regards,

Florian

As far as I can tell (as I cannot find reference to it anywhere), it's not possible to define an optional parameter for a CDS view.

Is that correct? Thanks.

5 REPLIES 5
Read only

pfefferf
Active Contributor
0 Likes
1,675

Hello Malcolm,

no, optional parameters are not possible (at the moment). To each input parameter an actual parameter must be assigned. Please take a look to paragraph "Notes" in online help ABAP Keyword Documentation.

Best Regards,

Florian

Read only

0 Likes
1,674

I just spotted that in the help at the same time as your reply came in! Thanks Florian.

I'm just wondering what the alternative is now. Would it be to put it in the projection list instead and then add it to the WHERE clause of the caller if it's filled and not add it to the WHERE clause when it isn't filled?

Read only

jasmin_gruschke
Product and Topic Expert
Product and Topic Expert
0 Likes
1,674

Hi Malcolm,

I'd say, that depends... e.g. if you are using aggregations in the view.

But I'd say it's a good workaround if applicable, so I understand instead of passing a filter value to the view in form of an input parameter, you're adding the (to be filtered) field to the projection list and leave the filtering to the consumer, right?

Question is, how will you consume the view? If it's Open SQL you can of course use a default value (in the Open SQL) or the given filter value in case it's given... same holds for IDA ALV, you can pass the default in the ABAP coding.

Cheers,
  Jasmin

Read only

Former Member
0 Likes
1,674

Hi

Is there any way to make parameters optional in abap cds views, say via annotations...?

Any possibility now?

Read only

vincenzocappelluti
Participant
1,674

any update in 2021?