SAP G_SET_TREE_GENERATE Function Module for
G_SET_TREE_GENERATE is a standard g set tree generate SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used to perform a specific ABAP function and below is the pattern details, 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 set tree generate FM, simply by entering the name G_SET_TREE_GENERATE into the relevant SAP transaction such as SE37 or SE38.
Function Group: GSGF
Program Name: SAPLGSGF
Main Program:
Appliation area: G
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function G_SET_TREE_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_SET_TREE_GENERATE'".
EXPORTING
* CLIENT = ' ' "Client
* LANGU = ' ' "Language of Hierarchy
* TOLERATE_AMBIGUITY = ' ' "Suppress Uniqueness Check
* CREATE_TOP_NODE_ONLY = ' ' "Test Temp. Sets !!! Do Not Use !!!
TABLES
SET_HIERARCHY = "Table of Sets
SET_VALUES = "Table of Set Values
EXCEPTIONS
BAD_FORMULA = 1 SUBSET_HAS_WRONG_CLASS = 10 SUBSET_HAS_WRONG_DATA_ELEMENT = 11 SUBSET_HAS_WRONG_TYPE = 12 TEMPORARY_IN_PERMANENT_SET = 13 VARIABLE_DOES_NOT_EXIST = 14 VARIABLE_HAS_WRONG_DATA_ELEM = 15 VARIABLE_HAS_WRONG_TABLE = 16 VARIABLE_HAS_WRONG_TYPE = 17 WRONG_INTERVAL = 18 WRONG_SETCLASS = 19 DOUBLE_FIELD = 2 ENTRY_NOT_FOUND = 3 HIERARCHY_NOT_CORRECT = 4 NOT_UNIQUE = 5 OLD_SET_HAS_WRONG_DATA_ELEMENT = 6 OLD_SET_HAS_WRONG_TYPE = 7 SET_IS_RECURSIVE = 8 SETNAME_TOO_LONG = 9
IMPORTING Parameters details for G_SET_TREE_GENERATE
CLIENT - Client
Data type: SY-MANDTDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
LANGU - Language of Hierarchy
Data type: SY-LANGUDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
TOLERATE_AMBIGUITY - Suppress Uniqueness Check
Data type: SY-DATARDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
CREATE_TOP_NODE_ONLY - Test Temp. Sets !!! Do Not Use !!!
Data type: SY-DATARDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
TABLES Parameters details for G_SET_TREE_GENERATE
SET_HIERARCHY - Table of Sets
Data type: SETHIEROptional: No
Call by Reference: No ( called with pass by value option)
SET_VALUES - Table of Set Values
Data type: SETVALUESOptional: No
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
BAD_FORMULA - Error in a Formula
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
SUBSET_HAS_WRONG_CLASS - Subset used has a Different Class
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
SUBSET_HAS_WRONG_DATA_ELEMENT - Subset used has a Different Set Data Element
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
SUBSET_HAS_WRONG_TYPE - Subset used has Incorrect Type
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
TEMPORARY_IN_PERMANENT_SET - Set contains temporary set
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
VARIABLE_DOES_NOT_EXIST - Variable used does not exist
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
VARIABLE_HAS_WRONG_DATA_ELEM - Variable used has a different set data element
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
VARIABLE_HAS_WRONG_TABLE - Set variable belongs to wrong table
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
VARIABLE_HAS_WRONG_TYPE - Variable used has incorrect type
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
WRONG_INTERVAL - Interval with From value > To Value
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
WRONG_SETCLASS - Incorrect set class (for M/D general sets only)
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
DOUBLE_FIELD - Field used Repeatedly in the Set
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
ENTRY_NOT_FOUND - Unknown entry
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
HIERARCHY_NOT_CORRECT - Incorrect Hierarchy Table
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
NOT_UNIQUE - Set is not unique, although required
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
OLD_SET_HAS_WRONG_DATA_ELEMENT - Set with same name but different set data element
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
OLD_SET_HAS_WRONG_TYPE - Set with same name but different type
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
SET_IS_RECURSIVE - Subset used contains the highest set
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
SETNAME_TOO_LONG - Set name is too long for a temporary set
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for G_SET_TREE_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_client | TYPE SY-MANDT, " SPACE | |||
| lv_bad_formula | TYPE SY, " | |||
| lt_set_hierarchy | TYPE STANDARD TABLE OF SETHIER, " | |||
| lv_subset_has_wrong_class | TYPE SETHIER, " | |||
| lv_subset_has_wrong_data_element | TYPE SETHIER, " | |||
| lv_subset_has_wrong_type | TYPE SETHIER, " | |||
| lv_temporary_in_permanent_set | TYPE SETHIER, " | |||
| lv_variable_does_not_exist | TYPE SETHIER, " | |||
| lv_variable_has_wrong_data_elem | TYPE SETHIER, " | |||
| lv_variable_has_wrong_table | TYPE SETHIER, " | |||
| lv_variable_has_wrong_type | TYPE SETHIER, " | |||
| lv_wrong_interval | TYPE SETHIER, " | |||
| lv_wrong_setclass | TYPE SETHIER, " | |||
| lv_langu | TYPE SY-LANGU, " SPACE | |||
| lt_set_values | TYPE STANDARD TABLE OF SETVALUES, " | |||
| lv_double_field | TYPE SETVALUES, " | |||
| lv_entry_not_found | TYPE SETVALUES, " | |||
| lv_tolerate_ambiguity | TYPE SY-DATAR, " SPACE | |||
| lv_create_top_node_only | TYPE SY-DATAR, " SPACE | |||
| lv_hierarchy_not_correct | TYPE SY, " | |||
| lv_not_unique | TYPE SY, " | |||
| lv_old_set_has_wrong_data_element | TYPE SY, " | |||
| lv_old_set_has_wrong_type | TYPE SY, " | |||
| lv_set_is_recursive | TYPE SY, " | |||
| lv_setname_too_long | TYPE SY. " |
|   CALL FUNCTION 'G_SET_TREE_GENERATE' " |
| EXPORTING | ||
| CLIENT | = lv_client | |
| LANGU | = lv_langu | |
| TOLERATE_AMBIGUITY | = lv_tolerate_ambiguity | |
| CREATE_TOP_NODE_ONLY | = lv_create_top_node_only | |
| TABLES | ||
| SET_HIERARCHY | = lt_set_hierarchy | |
| SET_VALUES | = lt_set_values | |
| EXCEPTIONS | ||
| BAD_FORMULA = 1 | ||
| SUBSET_HAS_WRONG_CLASS = 10 | ||
| SUBSET_HAS_WRONG_DATA_ELEMENT = 11 | ||
| SUBSET_HAS_WRONG_TYPE = 12 | ||
| TEMPORARY_IN_PERMANENT_SET = 13 | ||
| VARIABLE_DOES_NOT_EXIST = 14 | ||
| VARIABLE_HAS_WRONG_DATA_ELEM = 15 | ||
| VARIABLE_HAS_WRONG_TABLE = 16 | ||
| VARIABLE_HAS_WRONG_TYPE = 17 | ||
| WRONG_INTERVAL = 18 | ||
| WRONG_SETCLASS = 19 | ||
| DOUBLE_FIELD = 2 | ||
| ENTRY_NOT_FOUND = 3 | ||
| HIERARCHY_NOT_CORRECT = 4 | ||
| NOT_UNIQUE = 5 | ||
| OLD_SET_HAS_WRONG_DATA_ELEMENT = 6 | ||
| OLD_SET_HAS_WRONG_TYPE = 7 | ||
| SET_IS_RECURSIVE = 8 | ||
| SETNAME_TOO_LONG = 9 | ||
| . " G_SET_TREE_GENERATE | ||
ABAP code using 7.40 inline data declarations to call FM G_SET_TREE_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 MANDT FROM SY INTO @DATA(ld_client). | ||||
| DATA(ld_client) | = ' '. | |||
| "SELECT single LANGU FROM SY INTO @DATA(ld_langu). | ||||
| DATA(ld_langu) | = ' '. | |||
| "SELECT single DATAR FROM SY INTO @DATA(ld_tolerate_ambiguity). | ||||
| DATA(ld_tolerate_ambiguity) | = ' '. | |||
| "SELECT single DATAR FROM SY INTO @DATA(ld_create_top_node_only). | ||||
| DATA(ld_create_top_node_only) | = ' '. | |||
Search for further information about these or an SAP related objects