05-09-2018 6:08 AM
Hi,
I am trying to convert date to fiscal year in CDS view but not working.
Is there any way to achieve this?
Kindly help.
Thanks & Regards,
Yogesh
05-09-2018 6:47 AM
Hi Floarian,
I am working on ABAP CDS View.
I have to convert date to fiscal year(April to March).
e.g. 20180201 to 2017, 20180301 to 2017, 20180401 to 2018, 20180501 to 2018...like that
I tried this -
case
when a.vmonth = '01' then (a.calyear - 1)
when a.vmonth = '02' then (a.calyear - 1)
when a.vmonth = '03' then (a.calyear - 1)
when a.vmonth = '04' then a.calyear
when a.vmonth = '05' then a.calyear
when a.vmonth = '06' then a.calyear
when a.vmonth = '07' then a.calyear
when a.vmonth = '08' then a.calyear
when a.vmonth = '09' then a.calyear
when a.vmonth = '10' then a.calyear
when a.vmonth = '11' then a.calyear
when a.vmonth = '12' then a.calyear
end as vfiscalyear,
but (a.calyear - 1) this is not working...Error: Data type NUMC is currently not supported in an arithmetic expression
Kindly help with this or please provide any other way to achieve the requirement.
Thanks & Regards,
Yogesh
05-09-2018 10:35 AM
According to the message "...Error: Data type NUMC is currently not supported in an arithmetic expression" it should be clear what the error is and how it can be solved?
One option is to case the NUMC value to an integer. E.g.
...
case
when a.vmonth = '01' then ( cast( a.calyear as abap.int2 ) - 1)
...
Details can be found here
Regards,
Florian
04-01-2020 3:21 PM
Please use standard SAP provided CDS view like I_FiscalYearPeriod, which could be used to convert the date to fiscal year and period.
Regards,
Eswara.
01-31-2022 9:55 AM
Best choice eswaramaharaja_n !
This one my integration if someone else need it :
association [0..1] to I_FiscalYearPeriod as _FiscalYearPeriod on
$projection.budat >= _FiscalYearPeriod.FiscalPeriodStartDate // Sebastiano Marchesini 28/10/2022 TKT 5000033224
and $projection.budat <= _FiscalYearPeriod.FiscalPeriodEndDate
and _FiscalYearPeriod.IsSpecialPeriod <> 'X'