SAP G_VARIABLE_GENERATE Function Module for Generating a Variable









G_VARIABLE_GENERATE is a standard g variable generate SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Generating a 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 generate FM, simply by entering the name G_VARIABLE_GENERATE 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_GENERATE 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_GENERATE'"Generating a Variable
EXPORTING
* NO_TITLE = ' ' "Title is not filled; no MODIFY on T802T
VARSTRUCTURE = "Variable Information
* CLIENT = "Client of Variable
* FLAG_USE_RGSGV_USER = ' ' "

IMPORTING
INT_VAR = "Indicator 'Internal Variable' is set

EXCEPTIONS
ILLEGAL_CHANGE_OF_FIELD = 1 ILLEGAL_CHANGE_OF_TABLE = 2 ILLEGAL_CHANGE_OF_TYPE = 3 VARIABLE_NOT_FOUND = 4 FIELD_NOT_FOUND = 5 TEMPORARY_SET_IN_VARIABLE = 6
.



IMPORTING Parameters details for G_VARIABLE_GENERATE

NO_TITLE - Title is not filled; no MODIFY on T802T

Data type: FLAG
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

VARSTRUCTURE - Variable Information

Data type: RGSGV
Optional: No
Call by Reference: No ( called with pass by value option)

CLIENT - Client of Variable

Data type: SY-MANDT
Optional: Yes
Call by Reference: No ( called with pass by value option)

FLAG_USE_RGSGV_USER -

Data type: SY-DATAR
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

EXPORTING Parameters details for G_VARIABLE_GENERATE

INT_VAR - Indicator 'Internal Variable' is set

Data type: T802G-INT_VAR
Optional: No
Call by Reference: No ( called with pass by value option)

EXCEPTIONS details

ILLEGAL_CHANGE_OF_FIELD - Incompatible Field Change

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

ILLEGAL_CHANGE_OF_TABLE - Incompatible Table Change

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

ILLEGAL_CHANGE_OF_TYPE - Incompatible Type Change

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

VARIABLE_NOT_FOUND - Variable used does not exist

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

FIELD_NOT_FOUND - The Table Field does not exist

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

TEMPORARY_SET_IN_VARIABLE - Permanent Set Variables Include Temporary Set

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

Copy and paste ABAP code example for G_VARIABLE_GENERATE 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_int_var  TYPE T802G-INT_VAR, "   
lv_no_title  TYPE FLAG, "   SPACE
lv_illegal_change_of_field  TYPE FLAG, "   
lv_varstructure  TYPE RGSGV, "   
lv_illegal_change_of_table  TYPE RGSGV, "   
lv_client  TYPE SY-MANDT, "   
lv_illegal_change_of_type  TYPE SY, "   
lv_variable_not_found  TYPE SY, "   
lv_flag_use_rgsgv_user  TYPE SY-DATAR, "   SPACE
lv_field_not_found  TYPE SY, "   
lv_temporary_set_in_variable  TYPE SY. "   

  CALL FUNCTION 'G_VARIABLE_GENERATE'  "Generating a Variable
    EXPORTING
         NO_TITLE = lv_no_title
         VARSTRUCTURE = lv_varstructure
         CLIENT = lv_client
         FLAG_USE_RGSGV_USER = lv_flag_use_rgsgv_user
    IMPORTING
         INT_VAR = lv_int_var
    EXCEPTIONS
        ILLEGAL_CHANGE_OF_FIELD = 1
        ILLEGAL_CHANGE_OF_TABLE = 2
        ILLEGAL_CHANGE_OF_TYPE = 3
        VARIABLE_NOT_FOUND = 4
        FIELD_NOT_FOUND = 5
        TEMPORARY_SET_IN_VARIABLE = 6
. " G_VARIABLE_GENERATE




ABAP code using 7.40 inline data declarations to call FM G_VARIABLE_GENERATE

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 INT_VAR FROM T802G INTO @DATA(ld_int_var).
 
DATA(ld_no_title) = ' '.
 
 
 
 
"SELECT single MANDT FROM SY INTO @DATA(ld_client).
 
 
 
"SELECT single DATAR FROM SY INTO @DATA(ld_flag_use_rgsgv_user).
DATA(ld_flag_use_rgsgv_user) = ' '.
 
 
 


Search for further information about these or an SAP related objects



Comments on this SAP object

What made you want to lookup this SAP object? Please tell us what you were looking for and anything you would like to be included on this page!