SAP G_SUBSTITUTION_ENVIRONMENT Function Module for Maintain Substitution: Create. Change, Delete....
G_SUBSTITUTION_ENVIRONMENT is a standard g substitution environment SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Maintain Substitution: Create. Change, Delete.... 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 substitution environment FM, simply by entering the name G_SUBSTITUTION_ENVIRONMENT into the relevant SAP transaction such as SE37 or SE38.
Function Group: GBLO
Program Name: SAPLGBLO
Main Program: SAPLGBLO
Appliation area:
Release date: 20-Jul-1999
Mode(Normal, Remote etc): Normal Function Module
Update:

Function G_SUBSTITUTION_ENVIRONMENT 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_SUBSTITUTION_ENVIRONMENT'"Maintain Substitution: Create. Change, Delete.....
EXPORTING
* SUBST_TEMPLATE = ' ' "Substitution Model
* ONE_S = ' ' "X' = only 1 Sub. (not in Create, with B_Subevent!)
* STEP = "Selected Step in Open Tree (Not in Create)
* BSUBEVENT = ' ' "Flag = 'X' to Prevent User Changing Subevent
* BSUBUSER = 'X' "Flag = 'X' to Prevent User Changing Subuser
* SUBEVENT = "Substitution Event
SUBSTID = "
* SUBUSER = "
* VIEW_ONLY = ' ' "'X' = Changes not Possible
* ACTION_MODE = 'C' "Calling Mode: 'C' = Change, 'N' = Create
* SKIP_FIRST_SCREEN = ' ' "'X' = Skip the First Screen of Maintenance
IMPORTING
HEADER_INFO = "Header Information about the Substitution
SUBST_MODIFIED = "'X' - Substitution has been Changed
EXCEPTIONS
NOT_FOUND = 1
IMPORTING Parameters details for G_SUBSTITUTION_ENVIRONMENT
SUBST_TEMPLATE - Substitution Model
Data type: RGBLO-SUBSTPROTODefault: ' '
Optional: Yes
Call by Reference: No ( called with pass by value option)
ONE_S - X' = only 1 Sub. (not in Create, with B_Subevent!)
Data type: GB01-BEXCLUDEDefault: ' '
Optional: Yes
Call by Reference: No ( called with pass by value option)
STEP - Selected Step in Open Tree (Not in Create)
Data type: GB921-SUBSEQNROptional: Yes
Call by Reference: No ( called with pass by value option)
BSUBEVENT - Flag = 'X' to Prevent User Changing Subevent
Data type: GB01-BEXCLUDEDefault: ' '
Optional: Yes
Call by Reference: No ( called with pass by value option)
BSUBUSER - Flag = 'X' to Prevent User Changing Subuser
Data type: GB01-BEXCLUDEDefault: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)
SUBEVENT - Substitution Event
Data type: GB31-VALEVENTOptional: Yes
Call by Reference: No ( called with pass by value option)
SUBSTID -
Data type: GB92-SUBSTIDOptional: No
Call by Reference: No ( called with pass by value option)
SUBUSER -
Data type: GB03-VALUSEROptional: Yes
Call by Reference: No ( called with pass by value option)
VIEW_ONLY - 'X' = Changes not Possible
Data type: GB01-BEXCLUDEDefault: ' '
Optional: Yes
Call by Reference: No ( called with pass by value option)
ACTION_MODE - Calling Mode: 'C' = Change, 'N' = Create
Data type: GB01-BEXCLUDEDefault: 'C'
Optional: Yes
Call by Reference: No ( called with pass by value option)
SKIP_FIRST_SCREEN - 'X' = Skip the First Screen of Maintenance
Data type: GB01-BEXCLUDEDefault: ' '
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for G_SUBSTITUTION_ENVIRONMENT
HEADER_INFO - Header Information about the Substitution
Data type: GB92Optional: No
Call by Reference: No ( called with pass by value option)
SUBST_MODIFIED - 'X' - Substitution has been Changed
Data type: GB01-BEXCLUDEOptional: No
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
NOT_FOUND - Boolean Class Or Subclass does not Exist.
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for G_SUBSTITUTION_ENVIRONMENT 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_not_found | TYPE STRING, " | |||
| lv_header_info | TYPE GB92, " | |||
| lv_subst_template | TYPE RGBLO-SUBSTPROTO, " ' ' | |||
| lv_one_s | TYPE GB01-BEXCLUDE, " ' ' | |||
| lv_step | TYPE GB921-SUBSEQNR, " | |||
| lv_bsubevent | TYPE GB01-BEXCLUDE, " ' ' | |||
| lv_subst_modified | TYPE GB01-BEXCLUDE, " | |||
| lv_bsubuser | TYPE GB01-BEXCLUDE, " 'X' | |||
| lv_subevent | TYPE GB31-VALEVENT, " | |||
| lv_substid | TYPE GB92-SUBSTID, " | |||
| lv_subuser | TYPE GB03-VALUSER, " | |||
| lv_view_only | TYPE GB01-BEXCLUDE, " ' ' | |||
| lv_action_mode | TYPE GB01-BEXCLUDE, " 'C' | |||
| lv_skip_first_screen | TYPE GB01-BEXCLUDE. " ' ' |
|   CALL FUNCTION 'G_SUBSTITUTION_ENVIRONMENT' "Maintain Substitution: Create. Change, Delete.... |
| EXPORTING | ||
| SUBST_TEMPLATE | = lv_subst_template | |
| ONE_S | = lv_one_s | |
| STEP | = lv_step | |
| BSUBEVENT | = lv_bsubevent | |
| BSUBUSER | = lv_bsubuser | |
| SUBEVENT | = lv_subevent | |
| SUBSTID | = lv_substid | |
| SUBUSER | = lv_subuser | |
| VIEW_ONLY | = lv_view_only | |
| ACTION_MODE | = lv_action_mode | |
| SKIP_FIRST_SCREEN | = lv_skip_first_screen | |
| IMPORTING | ||
| HEADER_INFO | = lv_header_info | |
| SUBST_MODIFIED | = lv_subst_modified | |
| EXCEPTIONS | ||
| NOT_FOUND = 1 | ||
| . " G_SUBSTITUTION_ENVIRONMENT | ||
ABAP code using 7.40 inline data declarations to call FM G_SUBSTITUTION_ENVIRONMENT
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 SUBSTPROTO FROM RGBLO INTO @DATA(ld_subst_template). | ||||
| DATA(ld_subst_template) | = ' '. | |||
| "SELECT single BEXCLUDE FROM GB01 INTO @DATA(ld_one_s). | ||||
| DATA(ld_one_s) | = ' '. | |||
| "SELECT single SUBSEQNR FROM GB921 INTO @DATA(ld_step). | ||||
| "SELECT single BEXCLUDE FROM GB01 INTO @DATA(ld_bsubevent). | ||||
| DATA(ld_bsubevent) | = ' '. | |||
| "SELECT single BEXCLUDE FROM GB01 INTO @DATA(ld_subst_modified). | ||||
| "SELECT single BEXCLUDE FROM GB01 INTO @DATA(ld_bsubuser). | ||||
| DATA(ld_bsubuser) | = 'X'. | |||
| "SELECT single VALEVENT FROM GB31 INTO @DATA(ld_subevent). | ||||
| "SELECT single SUBSTID FROM GB92 INTO @DATA(ld_substid). | ||||
| "SELECT single VALUSER FROM GB03 INTO @DATA(ld_subuser). | ||||
| "SELECT single BEXCLUDE FROM GB01 INTO @DATA(ld_view_only). | ||||
| DATA(ld_view_only) | = ' '. | |||
| "SELECT single BEXCLUDE FROM GB01 INTO @DATA(ld_action_mode). | ||||
| DATA(ld_action_mode) | = 'C'. | |||
| "SELECT single BEXCLUDE FROM GB01 INTO @DATA(ld_skip_first_screen). | ||||
| DATA(ld_skip_first_screen) | = ' '. | |||
Search for further information about these or an SAP related objects