Skip to Content
0
Jan 11, 2018 at 01:41 PM

Could not get data from OData with CDS

186 Views

Hi all

I created a CDS query:

@AbapCatalog.sqlViewName: 'ZAMSALESSTAT'
@AbapCatalog.compiler.compareFilter: true
@OData: {
    publish: true
}
@AccessControl.authorizationCheck: #NOT_REQUIRED 
@EndUserText.label: 'Sales statistics from payer'
define view ZAM_sales_statistics
  with parameters
    p_payer_l: kunnr,
    p_payer_u: kunnr,
    p_date_l: datum,
    p_date_u: datum
as select from vbrk {
    key kunrg as Payer,
    @Semantics.currencyCode: true
    waerk as Currency,
    @Semantics: {
        amount: {
            currencyCode: 'Currency'
        }
    }
    sum(netwr) as NetValue
}
where kunrg between :p_payer_l and :p_payer_u
and   fkdat between :p_date_l and :p_date_u
group by kunrg,
         waerk

and provide it as OData interface as you can see on the annotation.

I tried to query via SAP Gateway Client as following:

/sap/opu/odata/sap/ZAM_SALES_STATISTICS_CDS/ZAM_sales_statisticsSet?$filter=p_payer_l eq '0022100000' and p_payer_u eq '0022100005' and p_date_l eq datetime'2017-11-01T00%3A00%3A00' and p_date_u eq datetime'2017-12-31T00%3A00%3A00'

and got the exception:

I did test the CDS query and got expected result:

Payer,Currency,NetValue
0022100003,CHF,1175.80
0022100001,CHF,1000.00
0022100005,CHF,46362.00

Why do I get an exception on OData service? What am I doing wrong?

Thanks

Attachments

capture.png (81.9 kB)