With continuation to previous article, let see how to get Default values in Parameters.
If we use @Environment.systemField : #SYSTEM_TIME annotation then system date will be assigned to prompts.
What if we need previous day or first day of current month or first day of previous month in parameter as default value? Then same can be achieved by creating separate date bucket CDS view where we can calculate required dates.
Develop Date Bucket CDS View
In below example, we have generated different dates which can be used to filter data dynamically.
Output of CDS View
Date Bucket CDS view will be used in consumption view with help of Consumption.derivation annotations. This annotation enables derivation of the value for a parameter or a filter automatically at runtime by selecting a row from a given entity.
Example -
Now let’s execute our CDS view in RSRT to verify if we can get FirstDayOfPreviousMonth as default value in prompt.
@AbapCatalog.sqlViewName: 'ZVM_C_CDSP'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@VDM.viewType: #CONSUMPTION
@Analytics.query: true
@Analytics.dataExtraction.enabled: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'CDS View With Parameter'
define view ZCDS_C_WITH_PARAMETER
with parameters
@Environment.systemField: #SYSTEM_DATE
@EndUserText.label: 'Todays Date'
@AnalyticsDetails.query.variableSequence: 1
@Consumption.hidden: true
p_keydate : abap.dats,
@AnalyticsDetails.query.variableSequence: 2
@Consumption.derivation: { lookupEntity: 'ZCDS_I_DATE_BUCKET',
resultElement: 'FirstDayOfPreviousMonth',
binding: [{ targetElement: 'CalendarDate',
type:#PARAMETER ,
value: 'p_keydate' }]
}
P_ValidFrom : abap.dats
as select from ZCDS_WITH_PARAMETER
{
@AnalyticsDetails.query.axis: #ROWS
anlage as Installation,
@AnalyticsDetails.query.axis: #ROWS
bis as ValidTo,
@AnalyticsDetails.query.axis: #ROWS
ab as ValidFrom
} where ab >= $parameters.P_ValidFrom
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 |