Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
kevin_wilson2
Contributor
0 Kudos

I searched high and low for this and found 2 useful solutions.

1 is purely a functional one.

You can Enable Fiscal year Default & Value Date via the IMG.
Path: Financial Accounting (New)-Financial Accounting Global Settings (New)-Document-Default Values-Enable Fiscal Year Default & Default Value Date.

The second is the one that worked for me. The code below calls the function DATE_TO_PERIOD_CONVERT to return the current period from table T009B.

The function module needs value PERIV (Fiscal Year Variant) which is set in your customizing for your company code (table T001). 

Table T009C is a good table as well showing the periods and their language relevant names should you need to show that as well.

  data: lv_poper_l  type poper,
        lv_pgjahr_l type bdatj,
        lv_date     type sydatum,
        lv_periv    type periv.

* Set Posting date
    lv_date = sy-datum.

* Determine Financial Period Variant
  select single periv into lv_periv
    from t001
    where bukrs = pv_bukrs.  "PV_BUKRS is the company code

  if sy-subrc = 0.

*  determine posting period
    call function 'DATE_TO_PERIOD_CONVERT'
      exporting
        i_date         = lv_date
        i_periv        = lv_periv
      importing
        e_buper        = lv_poper_l     "Contains period
        e_gjahr        = lv_pgjahr_l    "Contains year
      exceptions
        input_false    = 1
        t009_notfound  = 2
        t009b_notfound = 3
        others         = 4.

  endif.

6 Comments