Some important Function Modules for Date Conversion in SAP ABAP
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_DATE in this field you can pass todays date or sy-datum. 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
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.
Always use Pretty Printer and Extended Program Check before releasing the code.
Do not leave unused code in the program. Comment the code thoroughly. Align the comments and the Code. Follow the SAP Standards and SAP Best Practices guidelines. It’s a good practice to take a dump of the code on your local drive.