Skip to Content
-1

Convert/Calculate Date to Fiscal year in CDS View

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

Add comment
10|10000 characters needed characters exceeded

  • 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

  • Get RSS Feed

1 Answer

  • May 09 at 09: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

    Add comment
    10|10000 characters needed characters exceeded