SAP G_PERIOD_GET Function Module for Determine period from date
G_PERIOD_GET is a standard g period 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 Determine period from date 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 g period get FM, simply by entering the name G_PERIOD_GET into the relevant SAP transaction such as SE37 or SE38.
Function Group: GUPD
Program Name: SAPLGUPD
Main Program: SAPLGUPD
Appliation area:
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function G_PERIOD_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 'G_PERIOD_GET'"Determine period from date.
EXPORTING
* COMPANY = ' ' "Company code
* DATE = SY-DATLO "Posting date
* GLOBAL_COMPANY = ' ' "Global company
* LEDGER = ' ' "Ledger
* VARIANT = ' ' "Fiscal year variant
IMPORTING
ANZBP = "
ANZSP = "
PERIOD = "Posting period
YEAR = "Fiscal year
VARIANT = "Fiscal year variant
EXCEPTIONS
LEDGER_NOT_ASSIGNED_TO_COMPANY = 1 PERIOD_NOT_DEFINED = 2 VARIANT_NOT_DEFINED = 3 PARAMETER_ERROR = 4
IMPORTING Parameters details for G_PERIOD_GET
COMPANY - Company code
Data type: T001-BUKRSDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
DATE - Posting date
Data type: SY-DATUMDefault: SY-DATLO
Optional: Yes
Call by Reference: No ( called with pass by value option)
GLOBAL_COMPANY - Global company
Data type: T880-RCOMPDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
LEDGER - Ledger
Data type: T881-RLDNRDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
VARIANT - Fiscal year variant
Data type: T882-PERIVDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for G_PERIOD_GET
ANZBP -
Data type: T009-ANZBPOptional: No
Call by Reference: No ( called with pass by value option)
ANZSP -
Data type: T009-ANZSPOptional: No
Call by Reference: No ( called with pass by value option)
PERIOD - Posting period
Data type: T009B-POPEROptional: No
Call by Reference: No ( called with pass by value option)
YEAR - Fiscal year
Data type: T009B-BDATJOptional: No
Call by Reference: No ( called with pass by value option)
VARIANT - Fiscal year variant
Data type: T882-PERIVOptional: No
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
LEDGER_NOT_ASSIGNED_TO_COMPANY -
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
PERIOD_NOT_DEFINED - No period defined for the posting date
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
VARIANT_NOT_DEFINED - Fiscal year variant not defined
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
PARAMETER_ERROR -
Data type:Optional: No
Call by Reference: Yes
Copy and paste ABAP code example for G_PERIOD_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_anzbp | TYPE T009-ANZBP, " | |||
| lv_company | TYPE T001-BUKRS, " SPACE | |||
| lv_ledger_not_assigned_to_company | TYPE T001, " | |||
| lv_date | TYPE SY-DATUM, " SY-DATLO | |||
| lv_anzsp | TYPE T009-ANZSP, " | |||
| lv_period_not_defined | TYPE T009, " | |||
| lv_period | TYPE T009B-POPER, " | |||
| lv_global_company | TYPE T880-RCOMP, " SPACE | |||
| lv_variant_not_defined | TYPE T880, " | |||
| lv_year | TYPE T009B-BDATJ, " | |||
| lv_ledger | TYPE T881-RLDNR, " SPACE | |||
| lv_parameter_error | TYPE T881, " | |||
| lv_variant | TYPE T882-PERIV, " | |||
| lv_variant | TYPE T882-PERIV. " SPACE |
|   CALL FUNCTION 'G_PERIOD_GET' "Determine period from date |
| EXPORTING | ||
| COMPANY | = lv_company | |
| DATE | = lv_date | |
| GLOBAL_COMPANY | = lv_global_company | |
| LEDGER | = lv_ledger | |
| VARIANT | = lv_variant | |
| IMPORTING | ||
| ANZBP | = lv_anzbp | |
| ANZSP | = lv_anzsp | |
| PERIOD | = lv_period | |
| YEAR | = lv_year | |
| VARIANT | = lv_variant | |
| EXCEPTIONS | ||
| LEDGER_NOT_ASSIGNED_TO_COMPANY = 1 | ||
| PERIOD_NOT_DEFINED = 2 | ||
| VARIANT_NOT_DEFINED = 3 | ||
| PARAMETER_ERROR = 4 | ||
| . " G_PERIOD_GET | ||
ABAP code using 7.40 inline data declarations to call FM G_PERIOD_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 ANZBP FROM T009 INTO @DATA(ld_anzbp). | ||||
| "SELECT single BUKRS FROM T001 INTO @DATA(ld_company). | ||||
| DATA(ld_company) | = ' '. | |||
| "SELECT single DATUM FROM SY INTO @DATA(ld_date). | ||||
| DATA(ld_date) | = SY-DATLO. | |||
| "SELECT single ANZSP FROM T009 INTO @DATA(ld_anzsp). | ||||
| "SELECT single POPER FROM T009B INTO @DATA(ld_period). | ||||
| "SELECT single RCOMP FROM T880 INTO @DATA(ld_global_company). | ||||
| DATA(ld_global_company) | = ' '. | |||
| "SELECT single BDATJ FROM T009B INTO @DATA(ld_year). | ||||
| "SELECT single RLDNR FROM T881 INTO @DATA(ld_ledger). | ||||
| DATA(ld_ledger) | = ' '. | |||
| "SELECT single PERIV FROM T882 INTO @DATA(ld_variant). | ||||
| "SELECT single PERIV FROM T882 INTO @DATA(ld_variant). | ||||
| DATA(ld_variant) | = ' '. | |||
Search for further information about these or an SAP related objects