on 2021 Nov 09 11:11 AM
Dears
I created a filter field and I want it to display the system date by default,
I tried to use @Consumption.defaultValue but it does not seem to support system variables
eg. @Consumption.defaultValue#SYSTEM_DATE
I tried to define the parameter and use @Environment.systemField: #SYSTEM_DATE, but the system date is still not displayed in the filter field
What should I do to solve this problem
Request clarification before answering.
Hi
It is two years later, but maybe it helps someone else. Today I was looking for a solution to a similar problem and couldn't find it. By the end of the day I was able to write my own solution. I was looking how can i use dynamic interval of 2 dates as default filter value. This is my solution.
@analytics.query:true
define view ZI_TESTDATE_02
as select from ZI_TESTDATE_01
{
key SalesOrder,
@Consumption.filter: {selectionType: #INTERVAL, multipleSelections: false, mandatory: true}
@Consumption.derivation.lookupEntity: 'scal_tt_date'
@Consumption.derivation.resultElement: 'firstdayofmonthdate
@Consumption.derivation.resultElementHigh: 'lastdayofmonthdate'
@Consumption.derivation.binding: [{targetElement: 'calendardate', type: #SYSTEM_FIELD, value: '#SYSTEM_DATE'}]
TestDate
}
Or for single date this one.
@Consumption.filter: {selectionType: #INTERVAL, multipleSelections: false, mandatory: true}
@Consumption.derivation.lookupEntity: 'scal_tt_date'
@Consumption.derivation.resultElement: 'calendardate'
@Consumption.derivation.binding: [{targetElement: 'calendardate', type: #SYSTEM_FIELD, value: '#SYSTEM_DATE'}]
TestDate
I hope it helps someone. Cheers,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Parameter hidden with deriviation
with parameters
@Consumption:{
hidden: true,
derivation:{
lookupEntity: 'ZI_DATE_BUCKET',
resultElement: 'TodayDate'
}
}
@EndUserText.label: 'Start Date'
p_start_date : abap.dats,
End in zi_date_bucket.
key CalendarDate,
$session.system_date as TodayDate,
dats_add_days(CalendarDate, -1, 'UNCHANGED') as PreviousDay,
Like this is start date hidden and equals today
And example of Filter with derivation
@Consumption: {
filter: {
selectionType: #INTERVAL,
multipleSelections: false,
mandatory: false
},
derivation: {
lookupEntity: 'ZI_DATE_BUCKET',
resultElement: 'DateMinus14Days',
resultElementHigh: 'PreviousDay',
binding: [{targetElement: 'CalendarDate', type: #SYSTEM_FIELD, value: '#SYSTEM_DATE'}]
}
}
DeliveryDate,
And in zi_date_bucket
key CalendarDate,
$session.system_date as TodayDate,
dats_add_days(CalendarDate, -1, 'UNCHANGED') as PreviousDay,
dats_add_days(CalendarDate, 21, 'UNCHANGED') as DatePlus21Days,
dats_add_days(CalendarDate, -7, 'UNCHANGED') as DateMinus7Days ,
dats_add_days(CalendarDate, -14, 'UNCHANGED') as DateMinus14Days,
And then
| User | Count |
|---|---|
| 17 | |
| 8 | |
| 8 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.