2016 Aug 26 1:17 PM
Hi
I need to make a CDS view for consumption via Analysis for Office
However there are certain parameters which user will enter as mandatory(easily solved by parameters) but certain are optional (parameters )
How to solve this optional parameters in CDS, because while comparing in where condition it can be that for some parameters users might not enter anything and we have to get all the data corresponding to that value.
HOW TO USE OPTIONAL PARAMETERS IN CDS, OR A WORKAROUND if optional parameters aren't possible
Please suggest
Hi
I need to make a CDS view for consumption via Analysis for Office
However there are certain parameters which user will enter as mandatory(easily solved by parameters) but certain are optional (parameters )
How to solve this optional parameters in CDS, because while comparing in where condition it can be that for some parameters users might not enter anything and we have to get all the data corresponding to that value.
HOW TO USE OPTIONAL PARAMETERS IN CDS, OR A WORKAROUND if optional parameters aren't possible
Please suggest
2016 Aug 29 2:14 PM
Hi Indresh,
I see two potential solutions:
1. Create multiple CDS views(with different number of parameters & different code) and call/consume them individually from ABAP based on parameters entered by user. Case or if/else construct can be used in ABAP to check parameter availability & consume right CDS
2. Create one CDS and use UNION to add result of different queries. e.g.
DEFINE VIEW XYZ as
select from Table1
{
...
}
WHERE field_a = mandatory_param1
UNION
select from Table1
{
...
}
WHERE field_a = mandatory_param1
AND field_b = optional_param2
UNION
select from Table1
{
...
}
WHERE field_a = mandatory_param1
AND field_c = optional_param3
Thanks,
Sumit
2016 Aug 29 3:48 PM
Hi Sumit,
But I am not able to find right annotataions for making a parameter optional.
I have period (MONAT) as optional parameter. how to make that
2016 Aug 29 6:13 PM
There is no annotation which makes CDS parameter optional(as of now). You need to think other way.
2023 Aug 17 6:51 AM
2023 Aug 17 6:53 AM
I have added consumption.filter.mandatory to parameter but it is not working
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'CDS Program1'
define view ZCD_training
with parameters doc_no : char10
as select from ekko
{
@Consumption.filter.mandatory:false
@Consumption.filter.selectionType: #SINGLE
key ebeln,
bukrs,
ernam
} where ebeln = $parameters.doc_no;
Can anyone tell how to make doc_no as optional parameter?
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |