The function module DATE_TO_PERIOD_CONVERT can be used to get the current period by passing the current date. This function module need the following import parameters
I_DATE Current Date
I_MONMIT First day of the second half of the month
PERIV Fiscal year variant
I_MONMIT First day of the second half of the month
PERIV Fiscal year variant
I_MONMIT in this field you can pass '00'
PERIV in this filed you can pass the FISCAL YEAR for a list of Fiscal years run transaction OB37
DATA: D_PERIOD T009B-POPER, determined posting period
D_Year T009B-BDATJ. determined fiscal year
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
I_DATE = SY-DATUM
I_MONMIT = 00
I_PERIV = 'K4'
IMPORTING
E_BUPER = D_PERIOD
E_GJAHR = D_YEAR
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 3
OTHERS = 4.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
I_DATE = SY-DATUM
I_MONMIT = 00
I_PERIV = 'K4'
IMPORTING
E_BUPER = D_PERIOD
E_GJAHR = D_YEAR
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 3
OTHERS = 4.
PERIOD_DAY_DETERMINE
The above mentioned function module will determine the first of the the Fiscal Year. If you want to know the first day of the Fiscal year for a Company, then you can use this function module. While trying this function module for company codes of different countries.
REPORT ZEX_PERIODDAYDETERMINE .
Data: d_gjahr like BKPF-GJAHR, "Fiscal year
d_monat like BKPF-MONAT, "Posting period
d_periv like T001-PERIV, "Period version
d_fday like BKPF-BUDAT, "First period day
d_lday like BKPF-BUDAT, "Last period day
d_SPERIOD like BKPF-BSTAT. "Special period indicator
Move: '2008' to d_gjahr,
'01' to d_monat,
'K4' to d_periv.
CALL FUNCTION 'PERIOD_DAY_DETERMINE'
EXPORTING
I_GJAHR = d_gjahr
I_MONAT = d_monat
I_PERIV = d_periv
IMPORTING
E_FDAY = d_fday
E_LDAY = d_lday
E_SPERIOD = d_SPERIOD
EXCEPTIONS
ERROR_PERIOD = 1
ERROR_PERIOD_VERSION = 2
FIRSTDAY_NOT_DEFINED = 3
PERIOD_NOT_DEFINED = 4
YEAR_INVALID = 5
OTHERS = 6
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Write:/ 'First Day Of the Fiscal Year =',d_fday.
Data: d_gjahr like BKPF-GJAHR, "Fiscal year
d_monat like BKPF-MONAT, "Posting period
d_periv like T001-PERIV, "Period version
d_fday like BKPF-BUDAT, "First period day
d_lday like BKPF-BUDAT, "Last period day
d_SPERIOD like BKPF-BSTAT. "Special period indicator
Move: '2008' to d_gjahr,
'01' to d_monat,
'K4' to d_periv.
CALL FUNCTION 'PERIOD_DAY_DETERMINE'
EXPORTING
I_GJAHR = d_gjahr
I_MONAT = d_monat
I_PERIV = d_periv
IMPORTING
E_FDAY = d_fday
E_LDAY = d_lday
E_SPERIOD = d_SPERIOD
EXCEPTIONS
ERROR_PERIOD = 1
ERROR_PERIOD_VERSION = 2
FIRSTDAY_NOT_DEFINED = 3
PERIOD_NOT_DEFINED = 4
YEAR_INVALID = 5
OTHERS = 6
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Write:/ 'First Day Of the Fiscal Year =',d_fday.
Period Day Determine
First Day Of the Fiscal Year = 01/01/2008
Last Day Of the first period Fiscal Year = 01/31/2008
Change the Fiscal Year Variant to some other country and see the result. In my system I got the following result.First Day Of the Fiscal Year = 01/01/2008
Last Day Of the first period Fiscal Year = 01/31/2008
Period Day Determine
First Day Of the Fiscal Year = 04/01/2008
Last Day Of the first period Fiscal Year = 04/30/2008
First Day Of the Fiscal Year = 04/01/2008
Last Day Of the first period Fiscal Year = 04/30/2008