Application Development and Automation 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: 
Read only

Simple date question

Former Member
0 Likes
644

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
Read only

Former Member
0 Likes
618

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
Read only

Former Member
0 Likes
619

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.

Read only

0 Likes
618

Thanks. How should I declare gs_fiscal_year?

Read only

0 Likes
618

Like this...


data: gs_fiscal_year type sy-datum.

Greetings,

Blag.

Read only

0 Likes
618

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

Read only

Former Member
0 Likes
618

CAll FM DATE_TO_PERIOD_CONVERT. That's the easiest way.

Rob