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

Function G_VARIABLE_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_VARIABLE_GET'"Importing a Set Variable.
EXPORTING
* CLIENT = "Client
VARIABLE = "Variable
* TABNAME = ' ' "Alternative table (optional) -->
* FIELDNAME = ' ' "Alternative field name (optional) -->
* LANGU = SY-LANGU "Language (for short description)
* NO_DESCRIPTION = 'X' "'X' --> Do not return a short description
* NO_TABLE_BUFFERING = ' ' "
IMPORTING
VARSTRUCTURE = "Variable information
EXCEPTIONS
NOT_FOUND = 1 NO_FIELDNAME_FOUND = 2 DIFFERENT_ROLLNAMES = 3
IMPORTING Parameters details for G_VARIABLE_GET
CLIENT - Client
Data type: SY-MANDTOptional: Yes
Call by Reference: No ( called with pass by value option)
VARIABLE - Variable
Data type: T802G-GLOBALOptional: No
Call by Reference: No ( called with pass by value option)
TABNAME - Alternative table (optional) -->
Data type: DFIES-TABNAMEDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
FIELDNAME - Alternative field name (optional) -->
Data type: DFIES-FIELDNAMEDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
LANGU - Language (for short description)
Data type: SY-LANGUDefault: SY-LANGU
Optional: Yes
Call by Reference: No ( called with pass by value option)
NO_DESCRIPTION - 'X' --> Do not return a short description
Data type: SY-DATARDefault: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)
NO_TABLE_BUFFERING -
Data type: SY-DATARDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for G_VARIABLE_GET
VARSTRUCTURE - Variable information
Data type: RGSGVOptional: No
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
NOT_FOUND - Variable does not exist
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
NO_FIELDNAME_FOUND - Corresponding table field not found
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
DIFFERENT_ROLLNAMES -
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for G_VARIABLE_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_client | TYPE SY-MANDT, " | |||
| lv_not_found | TYPE SY, " | |||
| lv_varstructure | TYPE RGSGV, " | |||
| lv_variable | TYPE T802G-GLOBAL, " | |||
| lv_no_fieldname_found | TYPE T802G, " | |||
| lv_tabname | TYPE DFIES-TABNAME, " SPACE | |||
| lv_different_rollnames | TYPE DFIES, " | |||
| lv_fieldname | TYPE DFIES-FIELDNAME, " SPACE | |||
| lv_langu | TYPE SY-LANGU, " SY-LANGU | |||
| lv_no_description | TYPE SY-DATAR, " 'X' | |||
| lv_no_table_buffering | TYPE SY-DATAR. " SPACE |
|   CALL FUNCTION 'G_VARIABLE_GET' "Importing a Set Variable |
| EXPORTING | ||
| CLIENT | = lv_client | |
| VARIABLE | = lv_variable | |
| TABNAME | = lv_tabname | |
| FIELDNAME | = lv_fieldname | |
| LANGU | = lv_langu | |
| NO_DESCRIPTION | = lv_no_description | |
| NO_TABLE_BUFFERING | = lv_no_table_buffering | |
| IMPORTING | ||
| VARSTRUCTURE | = lv_varstructure | |
| EXCEPTIONS | ||
| NOT_FOUND = 1 | ||
| NO_FIELDNAME_FOUND = 2 | ||
| DIFFERENT_ROLLNAMES = 3 | ||
| . " G_VARIABLE_GET | ||
ABAP code using 7.40 inline data declarations to call FM G_VARIABLE_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 MANDT FROM SY INTO @DATA(ld_client). | ||||
| "SELECT single GLOBAL FROM T802G INTO @DATA(ld_variable). | ||||
| "SELECT single TABNAME FROM DFIES INTO @DATA(ld_tabname). | ||||
| DATA(ld_tabname) | = ' '. | |||
| "SELECT single FIELDNAME FROM DFIES INTO @DATA(ld_fieldname). | ||||
| DATA(ld_fieldname) | = ' '. | |||
| "SELECT single LANGU FROM SY INTO @DATA(ld_langu). | ||||
| DATA(ld_langu) | = SY-LANGU. | |||
| "SELECT single DATAR FROM SY INTO @DATA(ld_no_description). | ||||
| DATA(ld_no_description) | = 'X'. | |||
| "SELECT single DATAR FROM SY INTO @DATA(ld_no_table_buffering). | ||||
| DATA(ld_no_table_buffering) | = ' '. | |||
Search for further information about these or an SAP related objects