Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Simple date question

Former Member
0 Kudos

Hi Experts,

I do not know ABAP which explains my straight forward question.

I am coding in BI.

Based on an invoice date, I need to work-out the fiscal year.

If the month of the invoice date is >= 4, then the fiscal year, is the current year.

If the month of the invoice date is jan-march, then the fiscal year, it the current year-1.

Thank you.

PY

1 ACCEPTED SOLUTION

former_member583013
Active Contributor
0 Kudos

data: gs_month(2) type c.

gs_month = gs_invoice_date+4(2).

if gs_month GE 4.
gs_fiscal_year = sy-datum+0(4).
elseif gs_month between '01' and '03'.
gs_fiscal_year = sy-datum+0(4) - 1. 
endif.

Greetings,

Blag.

5 REPLIES 5

former_member583013
Active Contributor
0 Kudos

data: gs_month(2) type c.

gs_month = gs_invoice_date+4(2).

if gs_month GE 4.
gs_fiscal_year = sy-datum+0(4).
elseif gs_month between '01' and '03'.
gs_fiscal_year = sy-datum+0(4) - 1. 
endif.

Greetings,

Blag.

0 Kudos

Thanks. How should I declare gs_fiscal_year?

0 Kudos

Like this...


data: gs_fiscal_year type sy-datum.

Greetings,

Blag.

0 Kudos

Blag - wouldn't you rather have a four character fiscal year?

If you do subsequent work on the field as you have declared it (say add a year), you will get unexpected results.

Rob

Message was edited by:

Rob Burbank

Former Member
0 Kudos

CAll FM DATE_TO_PERIOD_CONVERT. That's the easiest way.

Rob