cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

@Consumption.filter.defaultValue using system date

panda_tom
Explorer
0 Kudos
7,291

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

Accepted Solutions (0)

Answers (1)

Answers (1)

hajduk
Explorer

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,

 

SuryaRamesh
Explorer
0 Kudos
This is also not working
hajduk
Explorer
0 Kudos

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

hajduk_0-1751004876664.png

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

hajduk_1-1751005048587.png