Skip to Content
Technical Articles
Author's profile photo Yogen Patil

ABAP CDS Views: Optional parameters in CDS View

Version: SAP S/4 HANA 1909


In SAP Embedded Analytics world ABAP Core Data Service Views also known as ABAP CDS Views. ABAP CDS Views are defined on top of existing database tables. Which can be further used in UI5 application for reporting purpose. When we deal with reports, then we need some selection parameters to restrict data in to get expected output. Which works as selection screen in UI5 application. Such functionality can be achieved with help ABAP CDS view.

Based on my experience & learning; I am drafting information in below article.

With continuation to previous article, lets see how to develop a report based on CDS view having Optional Input Parameter.

CDS views can be created with parameters & without parameters. If we create view with parameters, then it will become mandatory to provide input while executing a report.

Example –

Executing CDS via RSRT Tcode –


Question: Is it possible to develop a report based on CDS view having facility of optional input parameters?

Answer is yes, let see how we can achieve this by doing minor changes in CDS view.

CDS View –

We will add 2 annotations in CDS view to generate prompts while executing of report based on CDS view.

@Consumption.filter.mandatory: false
@Consumption.filter.selectionType: #SINGLE

Executing CDS View via RSRT Tcode –

Here, in above image we can see input parameter is optional here.

Sample Code –

//with parameters P_ANLAGE : abap.char( 10 )
as select from ZCDS_WITH_PARAMETER
@AnalyticsDetails.query.axis: #ROWS
@Consumption.filter.selectionType: #SINGLE
anlage as Installation,
@AnalyticsDetails.query.axis: #ROWS
bis as ValidTo,
@AnalyticsDetails.query.axis: #ROWS
ab as ValidFrom
} //where anlage = $parameters.P_ANLAGE


If we use annotation @Consumption.filter.mandatory: True then its mandatory to provide input in prompt.

More details related consumption annotation are available here.

Conclusion –

  • We can develop a report based on CDS view with optional input parameters.



Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo B. Struijk
      B. Struijk

      Thank you very much Yogen, for your clear explanation with code example!
      This was exactly what I was looking for.

      Author's profile photo Yogen Patil
      Yogen Patil
      Blog Post Author

      Welcome 🙂

      Author's profile photo Anthony Capone
      Anthony Capone

      These seem to be optional "filters" not optional "parameters".  Is there a way to pass these consumption.filter values down to a lower view?


      I need to create a cds view with optional parameters that, when selected, will be passed down to other views.  Is this possible?

      Author's profile photo Luis Andres Lara Graffe
      Luis Andres Lara Graffe

      Great Post Yogen.


      I have a CDS that is exposed as Odata Service. I have a few parameters in that CDS that I want to make optional and range type. My client system is S/4 1909, but I can't get these new annotations to work. Do you have any example for a CDS exposed as Odata Service?

      I will appreciate your help.


      Best Regards:


      Luis Lara.

      Author's profile photo Hamama Zouhair
      Hamama Zouhair

      Hi patil,

      I have a question please, I need to develop a CDS Views Consumption that has filled Parameters and Select option and checkbox just like in the picture below, is it possible please.
      This CDS view musst be  consumed in a FIORI

      Best Regards.

      Author's profile photo Yogen Patil
      Yogen Patil
      Blog Post Author



      You can pass default values to variables. You can refer -


      Author's profile photo Swati More
      Swati More

      @Yogen Patil

      Still it is not working after adding Consumption.filter for parameter doc_no


      Can you please suggest any additional changes ?


      Author's profile photo Shijo Joy
      Shijo Joy

      @Swati, Comment out the parameter declaration and the where clause.

      Author's profile photo Yogen Patil
      Yogen Patil
      Blog Post Author

      Hi Swati,


      You are using parameter and consumption filter both. Please use any one of them.

      Author's profile photo Purnachander Nagula
      Purnachander Nagula

      Hi Yogesh,

      this is not working for me. I am looking a CDS view where input parameters are optional. I tried using but not working. can you give more details?

      @AnalyticsDetails.query.axis: #ROWS
      @Consumption.filter.selectionType: #SINGLE