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: 

How can i get the month and year of the current open Periode?

Ralf_Kaufmann
Newcomer
0 Kudos
1,438

At the beginning of each month the booking period for the new month was not open,but i need to book material automatically with the last day of the old month. The booking period will change at the first working day between 13 and 17 a clock. when the booking period was changed i have to book with the current date.

How can i do this ??

Regards

Ralf

1 ACCEPTED SOLUTION

Former Member
325

Dear Ralf,

the FMs mentioned above are the most reliable way to determine whether posting is possible in a period. To determine, if the period has been changed it might be quicker to read table marv (for MM periods) and/or T001B (for FI periods).

But for a check if posting is possible, the FMs are definitely safer.

Hope this helps, kind regards, Kathrin!

5 REPLIES 5

Former Member
0 Kudos
325

hi,

try with this

CALL FUNCTION 'MONTH_PLUS_DETERMINE'

EXPORTING

MONTHS = -1

OLDDATE = sy-datum

IMPORTING

NEWDATE = date1

CALL FUNCTION 'LAST_DAY_OF_MONTHS'

EXPORTING

DAY_IN = date1

IMPORTING

LAST_DAY_OF_MONTH = date2

cheers,

sasi

0 Kudos
325

Hi Ralf,

here's a complete example:

DATA: last LIKE sy-datum, "ultimo of last month
      gjahr LIKE t001b-frye1,
      buper LIKE t001b-frpe1.
last = sy-datum - sy-datum+6(2) .
PERFORM check_period.
IF sy-subrc <> 0.
  ADD 1 TO last . "-> next month
  PERFORM check_period.
  IF sy-subrc <> 0.
    MESSAGE a001(00) WITH 'no open fi period'.
  ENDIF.
ENDIF.
*formatting for germany
CONCATENATE last+6(2) last+4(2) last(4) INTO bbkpf-budat.
WRITE: / bbkpf-budat.
*&---------------------------------------------------------------------*
FORM check_period.

  MOVE last(4) TO gjahr.
  MOVE last+4(2) TO buper.


  CALL FUNCTION 'FI_PERIOD_CHECK'
       EXPORTING
            i_bukrs          = bbkpf-bukrs
            i_gjahr          = gjahr
            i_koart          = '+'
            i_monat          = buper
       EXCEPTIONS
            error_period     = 1
            error_period_acc = 2
            OTHERS           = 3.

ENDFORM.                    " check_period

regards <a href="https://www.sdn.sap.com:443/irj/servlet/prt/porta

l/prtroot/com.sap.sdn.businesscard.SDNBusinessCard?u=i

Wo3ssHlIihvCrADIEGqaw%3D%3D">Andreas</a>

Message was edited by: Andreas Mann

andreas_mann3
Active Contributor
0 Kudos
325

hi and welcome to SDN,

1st) bkpf-budat = last day of old month

check with fm FI_PERIOD_CHECK

i_monat = old month

if sy subrc <> 0.

*period is closed

endif.

2nd) add 1 to old month

and check with fm again

regards Andreas

ramki_maley
Active Contributor
0 Kudos
325

Ralph,

Welcome to the forum!

BAPI_COMPANYCODE_GET_PERIOD will give you the current open period. Then use BAPI_CCODE_GET_FIRSTDAY_PERIOD and get the month & year from the date returned.

You can also try BAPI_CONTROLLINGAREA_GETPERIOD for the open period and then BAPI_COAREA_GETPERIODLIMITS which will return both the begining and end dates of the open period.

This will work whether your fiscal year is same as calendar year or not (for instance in US federal govt, fiscal year 2006 starts first of October 2005 - with October being period 1).

Cheers,

Ramki Maley.

Please reward points if the answer is helpful.

For info on awarding points click on this link: https://www.sdn.sap.com/sdn/index.sdn?page=crp_help.htm

Former Member
326

Dear Ralf,

the FMs mentioned above are the most reliable way to determine whether posting is possible in a period. To determine, if the period has been changed it might be quicker to read table marv (for MM periods) and/or T001B (for FI periods).

But for a check if posting is possible, the FMs are definitely safer.

Hope this helps, kind regards, Kathrin!