Skip to Content
1
Feb 03, 2022 at 04:43 PM

CDS view: derivation of posting date from period filter

658 Views

Hello, all.

I would like to create a CDS view query that derives the posting date from the periods selected by the user in the consumption view.

My initial attempt was to define these conditions in the where clause

where PostingDate between i_fiscalyearperiodforvariant.FiscalPeriodStartDate
                  and     i_fiscalyearperiodforvariant.FiscalPeriodEndDate

But this is giving me the following error "Lower and upper value of between expression must be literal values".

Is there a way that I could do this and avoid asking the user for PostingDate?

See below the full CDS view code:

@AbapCatalog.sqlViewName: 'ZGCIPLA_7_1'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@VDM.viewType: #CONSUMPTION
@Analytics.query: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Query 7 (No posting date)'
define view ZG_C_IPLA_7_1 as select from ZG_I_IPLA_7 


    association to I_FiscalYearPeriodForVariant as I_FISCALYEARPERIODFORVARIANT

    on I_FiscalYearPeriodForVariant.FiscalYearVariant = ZG_I_IPLA_7.Fiscvarnt
    and I_FiscalYearPeriodForVariant.FiscalYear = ZG_I_IPLA_7.Fiscyear
    and I_FiscalYearPeriodForVariant.FiscalPeriod = ZG_I_IPLA_7.Fiscper3

{
    
    @Consumption.filter : { mandatory: true, selectionType: #SINGLE, multipleSelections : true, defaultValue: '0L'}
    @AnalyticsDetails.query.variableSequence: 10
    @AnalyticsDetails.query.axis: #ROWS
    /bic/gfiledger,
    
    @Consumption.filter : { mandatory: false, selectionType: #SINGLE, multipleSelections : true}
    @AnalyticsDetails.query.variableSequence: 20
    @AnalyticsDetails.query.axis: #ROWS
    /bic/gficocode,
    Fiscyear,
    Fiscper3,
    Fiscvarnt,
    
    @Consumption.filter : { mandatory: false, selectionType: #RANGE, multipleSelections : false}
    @AnalyticsDetails.query.variableSequence: 30
    @AnalyticsDetails.query.axis: #ROWS
    Fiscper,

    PostingDate,
    /bic/gfiadhoc1,
    C_IPLA_Rate
}

where PostingDate between i_fiscalyearperiodforvariant.FiscalPeriodStartDate
                  and     i_fiscalyearperiodforvariant.FiscalPeriodEndDate