In the previous lessons, you saw how powerful CDS views are when it comes to doing calculations on the database. Maybe you already asked yourself in how far the consumer of the CDS view can influence the way the calculations are done. Of course the consumer can provide a WHERE clause to perform a selection on the result. But how does that help when you want to choose the target currency for a currency conversion?
CDS views with input parameters close this gap. They allow the consumer of a view to provide additional information when retrieving data from this view. The CDS view in turn evaluates this information and takes it into account when calculating the results. Some possible use cases for parameters are as follows:
The consumer specifies the target currency of a currency conversion.
The consumer specifies whether prices are calculated with or without tax.
The consumer provides a separator that is used when concatenating fields.
the consumer specifies the language in which translatable text is returned.
Another important motivation for input views are CDS views with aggregations where you want to filter the data that enter the aggregation. If for example you calculate the total revenue and you want to specify a date up to which revenue should be taken into account.
Finally, SQL does not know about mandatory selection criteria. A consumer may provide a WHERE clause or might not. With a mandatory input parameter, the view can force the consumer to provide a necessary selection criterion - for example, a language key, a date or a username.