DETERMINE_PERIOD FM to Retrieve fiscal year and period

The below ABAP code shows how to use function modules BAPI_COMPANYCODE_GET_PERIOD and DETERMINE_PERIOD to retrieve fiscal year and fiscal period for a specific date.


*..........................................................
*: Report:  ZFISCALYR                                     :
*:                                                        :
*: Author:  www.SAPdev.co.uk                              :
*:                                                        :
*: Date  :  2004                                          :
*:                                                        :
*: Demonstrates how to return the corresponding fiscal    :
*: year and posting period for a company code and posting :
*: date or posting date and fiscal year variant.          :
*:........................................................:
REPORT  zfiscalyr NO STANDARD PAGE HEADING.
TABLES: ekko.
PARAMETERS:     p_bukrs TYPE ekko-bukrs,
                p_bedat TYPE ekko-bedat.
DATA: gd_fiscalyr  TYPE bapi0002_4-fiscal_year,
      gd_fiscalp   TYPE bapi0002_4-fiscal_period.
DATA: gd_fiscalyr2 TYPE T009B-BDATJ,
      gd_fiscalp2  TYPE bapi0002_4-fiscal_period.
DATA: gd_periv     TYPE t009-periv.
************************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
* get fiscal year and period - (requires date and company code)
  CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'
    EXPORTING
      companycodeid = p_bukrs
      posting_date  = p_bedat
    IMPORTING
      fiscal_year   = gd_fiscalyr
      fiscal_period = gd_fiscalp.
* Alternative fiscal year function module
* - (requires date and fiscal year variant code from T009 table)
*--------------------------------------------------------------------
* gets first entry in fiscal year variant table (will need to choose
* correct one from table rather than just using first entry)
  SELECT SINGLE periv
    FROM t009
    INTO gd_periv.
* get fiscal year and period
  CALL FUNCTION 'DETERMINE_PERIOD'
    EXPORTING
      date                      = p_bedat
*    PERIOD_IN                 = '000'
      version                   = gd_periv
   IMPORTING
      period                    = gd_fiscalp2
      year                      = gd_fiscalyr2
   EXCEPTIONS
      period_in_not_valid       = 1
      period_not_assigned       = 2
      version_undefined         = 3
      OTHERS                    = 4.
************************************************************************
*END-OF-SELECTION.
END-OF-SELECTION.
  WRITE:/ 'From function module: BAPI_COMPANYCODE_GET_PERIOD',
        / 'Fiscal year is:', gd_fiscalyr,
        / 'Fiscal period is:', gd_fiscalp.
  SKIP.
  WRITE:/ 'From function module: DETERMINE_PERIOD',
        / 'Fiscal year is:', gd_fiscalyr2,
        / 'Fiscal period is:', gd_fiscalp2.

Related Articles

ABAP4_CALL_TRANSACTION sap function module
BAPI_ALM_ORDER_MAINTAIN sap BAPI / Function Module to create a work order
Function module BAPI_EMPLCOMM_CREATE to maintain the SAP HR communication infotype 0105
CLPB_EXPORT sap function module
CLPB_IMPORT sap function module
CONVERT_DATE_TO_EXTERNAL sap function module
CREATE_TEXT sap function module
CURRENCY_AMOUNT_DISPLAY_TO_SAP sap function module to Convert currency value from display to SAP
CURRENCY_AMOUNT_SAP_TO_DISPLAY FM to Convert currency value from SAP to display
DATE_COMPUTE_DAY sap function module
DATE_TO_DAY sap function module
DOCU_READ sap function module
ENQUEUE_READ sap function module
F4IF_INT_TABLE_VALUE_REQUEST sap function module
FILE_GET_NAME sap function module
SAP Application specific function modules
SAP Custom function modules
SAP field conversion function modules
SAP HR specific function modules
SAP development function modules
Retrieve employees address details (own data)
Function Module DYNP_VALUES_UPDATE to Change screen field contents
sxpg_command_execute FM to Execute external commands (FTP Scripts)
Function module HR_INFOTYPE_OPERATION to maintain SAP HR infotypes
RH_PM_GET_STRUCTURE FM to retrieve HR Organisation Structure
Validate WBS (code used in ME21)
HR_READ_INFOTYPE SAP FM to Read infotype data
READ_TEXT FM to Read SAP texts
ADDR_PERS_COMP_COMM_MAINTAIN to Update sap users email address plus other details (own data)
HR_PERSONAL_WORK_SCHEDULE to Retrieve employees work schedule
NUMBER_GET_NEXT to get next number in number range sap function module
Generate random number using QF05_RANDOM_INTEGER SAP function module within your ABAP code
RSEC_GENERATE_PASSWORD SAP FM to generate user password
The SAP internet user functionality and Password BAPIs
SAPGUI_SET_FUNCTIONCODE sap function module to execute function code
SX_INTERNET_ADDRESS_TO_NORMAL SAP function module to check email format is correct