SAP PERIODS_TEXT_GET Function Module for Converts a date into a text according to the selected period type
PERIODS_TEXT_GET is a standard periods text get SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Converts a date into a text according to the selected period type processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.
See here to view full function module documentation and code listing for periods text get FM, simply by entering the name PERIODS_TEXT_GET into the relevant SAP transaction such as SE37 or SE38.
Function Group: CR02
Program Name: SAPLCR02
Main Program:
Appliation area: M
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function PERIODS_TEXT_GET pattern details
In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.CALL FUNCTION 'PERIODS_TEXT_GET'"Converts a date into a text according to the selected period type.
EXPORTING
* CALENDAR_ID = ' ' "Calendar ID
DATE = "Date to be converted
* FISCAL_YEAR_VARIANT = ' ' "Fiscal year variant
PERIOD_TYPE = "Period type to which date is to be converted
* NO_CENTURY = ' ' "If set to 'X', no century in day format
* NO_NR_OF_PERIODS = ' ' "
IMPORTING
PERIOD_TEXT = "Converted date
EXCEPTIONS
DATE_AFTER_RANGE = 1 DATE_BEFORE_RANGE = 2 DATE_INVALID = 3 FACTORY_CALENDAR_NOT_FOUND = 4 T009B_NOTFOUND = 5 T009_NOTFOUND = 6 UNKNOWN_PERIOD_TYPE = 7 WRONG_INPUT = 8
IMPORTING Parameters details for PERIODS_TEXT_GET
CALENDAR_ID - Calendar ID
Data type: RC65A-KALIDDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
DATE - Date to be converted
Data type: SY-DATUMOptional: No
Call by Reference: No ( called with pass by value option)
FISCAL_YEAR_VARIANT - Fiscal year variant
Data type: RC65A-PERIVDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
PERIOD_TYPE - Period type to which date is to be converted
Data type: RC65A-DATE_TYPEOptional: No
Call by Reference: No ( called with pass by value option)
NO_CENTURY - If set to 'X', no century in day format
Data type: CYREFS-FLAGDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
NO_NR_OF_PERIODS -
Data type: CYREFS-FLAGDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for PERIODS_TEXT_GET
PERIOD_TEXT - Converted date
Data type: RC65A-DATEFROMOptional: No
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
DATE_AFTER_RANGE - Date after defined range of factory calendar
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
DATE_BEFORE_RANGE - Date before defined range of factory calendar
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
DATE_INVALID - Date not correct
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
FACTORY_CALENDAR_NOT_FOUND - Factory calendar not found
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
T009B_NOTFOUND - Fiscal year variant not found in table T009B
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
T009_NOTFOUND - Fiscal year variant not found in table T009
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
UNKNOWN_PERIOD_TYPE - Period type not correct
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
WRONG_INPUT - Incorrect entry for conversion
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for PERIODS_TEXT_GET Function Module
The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.| DATA: | ||||
| lv_calendar_id | TYPE RC65A-KALID, " SPACE | |||
| lv_period_text | TYPE RC65A-DATEFROM, " | |||
| lv_date_after_range | TYPE RC65A, " | |||
| lv_date | TYPE SY-DATUM, " | |||
| lv_date_before_range | TYPE SY, " | |||
| lv_date_invalid | TYPE SY, " | |||
| lv_fiscal_year_variant | TYPE RC65A-PERIV, " SPACE | |||
| lv_period_type | TYPE RC65A-DATE_TYPE, " | |||
| lv_factory_calendar_not_found | TYPE RC65A, " | |||
| lv_no_century | TYPE CYREFS-FLAG, " SPACE | |||
| lv_t009b_notfound | TYPE CYREFS, " | |||
| lv_t009_notfound | TYPE CYREFS, " | |||
| lv_no_nr_of_periods | TYPE CYREFS-FLAG, " SPACE | |||
| lv_unknown_period_type | TYPE CYREFS, " | |||
| lv_wrong_input | TYPE CYREFS. " |
|   CALL FUNCTION 'PERIODS_TEXT_GET' "Converts a date into a text according to the selected period type |
| EXPORTING | ||
| CALENDAR_ID | = lv_calendar_id | |
| DATE | = lv_date | |
| FISCAL_YEAR_VARIANT | = lv_fiscal_year_variant | |
| PERIOD_TYPE | = lv_period_type | |
| NO_CENTURY | = lv_no_century | |
| NO_NR_OF_PERIODS | = lv_no_nr_of_periods | |
| IMPORTING | ||
| PERIOD_TEXT | = lv_period_text | |
| EXCEPTIONS | ||
| DATE_AFTER_RANGE = 1 | ||
| DATE_BEFORE_RANGE = 2 | ||
| DATE_INVALID = 3 | ||
| FACTORY_CALENDAR_NOT_FOUND = 4 | ||
| T009B_NOTFOUND = 5 | ||
| T009_NOTFOUND = 6 | ||
| UNKNOWN_PERIOD_TYPE = 7 | ||
| WRONG_INPUT = 8 | ||
| . " PERIODS_TEXT_GET | ||
ABAP code using 7.40 inline data declarations to call FM PERIODS_TEXT_GET
The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.| "SELECT single KALID FROM RC65A INTO @DATA(ld_calendar_id). | ||||
| DATA(ld_calendar_id) | = ' '. | |||
| "SELECT single DATEFROM FROM RC65A INTO @DATA(ld_period_text). | ||||
| "SELECT single DATUM FROM SY INTO @DATA(ld_date). | ||||
| "SELECT single PERIV FROM RC65A INTO @DATA(ld_fiscal_year_variant). | ||||
| DATA(ld_fiscal_year_variant) | = ' '. | |||
| "SELECT single DATE_TYPE FROM RC65A INTO @DATA(ld_period_type). | ||||
| "SELECT single FLAG FROM CYREFS INTO @DATA(ld_no_century). | ||||
| DATA(ld_no_century) | = ' '. | |||
| "SELECT single FLAG FROM CYREFS INTO @DATA(ld_no_nr_of_periods). | ||||
| DATA(ld_no_nr_of_periods) | = ' '. | |||
Search for further information about these or an SAP related objects