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: 

Help with DATE_TO_PERIOD_CONVERT

Former Member
0 Kudos

Hi,

I would like to know if there is any function module to convert calendar month and year to Fiscal Period.

Example: 07 month and 2005 year of calender would be Fiscal period 001 / FY05 (actually July)

Here is my below code & problem:-

Please let me know how do I do it for any date that a user enters & convert that to respective Fiscal Period.

Points will be rewarded.

CODE: There is some issue with this one.

w_date='20060202' (I need to convert whatever user enters & not hard code it this way)

CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'

EXPORTING

I_DATE = w_date

I_MONMIT = 00

I_PERIV = 'S1' (Fiscal period Variant)

IMPORTING

E_BUPER = w_period

E_GJAHR = w_year

EXCEPTIONS

INPUT_FALSE = 1

T009_NOTFOUND = 2

T009B_NOTFOUND = 3

OTHERS = 4

Thanks.

5 REPLIES 5

Former Member
0 Kudos

What about your solution doesn't work?

Former Member
0 Kudos

Make sure w_date is declared like sy-datum:

PARAMETERS: w_date LIKE sy-datum.

DATA: w_period LIKE  t009b-poper,
      w_year   LIKE  t009b-bdatj.

CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
  EXPORTING
    i_date         = w_date
    i_monmit       = 00
    i_periv        = 'S1'
  IMPORTING
    e_buper        = w_period
    e_gjahr        = w_year
  EXCEPTIONS
    input_false    = 1
    t009_notfound  = 2
    t009b_notfound = 3
    OTHERS         = 4.

Rob

0 Kudos

Rob,

If I give w_date LIKE sy-datum, wudn't it take the system date & convert that to the reaspective period. Correct me if I'm wrong. This is what I need to do: No matter what date the user enters in the report, it needs to return the fiscal period for that date.

Also, will my code return the value or not?

Thanks in advance.

0 Kudos

It just creates a parameter with the same attributes as SY-DATUM. The user is forced to enter it in the correct format. I tested the code I posted and it returns the result I expect. Why don't you just try it out?

Rob

0 Kudos

Rob,

I'll surely try. Thanks a bunch. Shall assign points:)

M.