SAP G_SET_TREE_IMPORT Function Module for Importing a Set Hierarchy
G_SET_TREE_IMPORT is a standard g set tree import 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 Hierarchy 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 set tree import FM, simply by entering the name G_SET_TREE_IMPORT into the relevant SAP transaction such as SE37 or SE38.
Function Group: GSAC
Program Name: SAPLGSAC
Main Program: SAPLGSAC
Appliation area: G
Release date: 16-Aug-1999
Mode(Normal, Remote etc): Normal Function Module
Update:

Function G_SET_TREE_IMPORT 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_IMPORT'"Importing a Set Hierarchy.
EXPORTING
* CLIENT = SY-MANDT "Client
* NO_TABLE_BUFFERING = ' ' "'X' --> Table T800S Is Read Without Buffer
* MAX_HIER_LEVEL = 99 "Maximum Hierarchy Level (0 = Top Node)
* DATE_FROM = "Selection Date for Dynamic Sets (From Value)
* DATE_TO = "Selection Date for Dynamic Sets (To Value)
* FIELDNAME = ' ' "Different Reference Field, if Required
* LANGU = SY-LANGU "Short Descriptions Language
* NO_DESCRIPTIONS = ' ' "'X' --> No Short Descriptions
* NO_RW_INFO = ' ' "'X' --> No Report Info (Formulas, etc.)
SETID = "Set Identification
* TABNAME = ' ' "Different Reference Table, if Required
* NO_VARIABLE_REPLACEMENT = ' ' "'X' --> Set Variables Are Not Replaced
* ROOT_HEADER_ONLY = ' ' "'X' --> Read Header Information Only (for Root)
IMPORTING
SET_NOT_TRANSPARENT = "Set Is Not Yet Stored Transparently
TABLES
* SET_HIERARCHY = "Set Hierarchy
* SET_VALUES = "Value Intervals for Set Hierarchy
EXCEPTIONS
SET_NOT_FOUND = 1 ILLEGAL_FIELD_REPLACEMENT = 2 ILLEGAL_TABLE_REPLACEMENT = 3 SET_IS_DAMAGED = 4
IMPORTING Parameters details for G_SET_TREE_IMPORT
CLIENT - Client
Data type: SY-MANDTDefault: SY-MANDT
Optional: Yes
Call by Reference: No ( called with pass by value option)
NO_TABLE_BUFFERING - 'X' --> Table T800S Is Read Without Buffer
Data type: SY-DATARDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
MAX_HIER_LEVEL - Maximum Hierarchy Level (0 = Top Node)
Data type: IDefault: 99
Optional: Yes
Call by Reference: No ( called with pass by value option)
DATE_FROM - Selection Date for Dynamic Sets (From Value)
Data type: DATABOptional: Yes
Call by Reference: Yes
DATE_TO - Selection Date for Dynamic Sets (To Value)
Data type: DATBIOptional: Yes
Call by Reference: Yes
FIELDNAME - Different Reference Field, if Required
Data type: RGSMH-FIELDDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
LANGU - Short Descriptions Language
Data type: SY-LANGUDefault: SY-LANGU
Optional: Yes
Call by Reference: No ( called with pass by value option)
NO_DESCRIPTIONS - 'X' --> No Short Descriptions
Data type: SY-DATARDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
NO_RW_INFO - 'X' --> No Report Info (Formulas, etc.)
Data type: SY-DATARDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
SETID - Set Identification
Data type: SETHIER-SETIDOptional: No
Call by Reference: No ( called with pass by value option)
TABNAME - Different Reference Table, if Required
Data type: RGSMH-TABLEDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
NO_VARIABLE_REPLACEMENT - 'X' --> Set Variables Are Not Replaced
Data type: SY-DATARDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
ROOT_HEADER_ONLY - 'X' --> Read Header Information Only (for Root)
Data type: SY-DATARDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for G_SET_TREE_IMPORT
SET_NOT_TRANSPARENT - Set Is Not Yet Stored Transparently
Data type: SY-DATAROptional: No
Call by Reference: No ( called with pass by value option)
TABLES Parameters details for G_SET_TREE_IMPORT
SET_HIERARCHY - Set Hierarchy
Data type: SETHIEROptional: Yes
Call by Reference: No ( called with pass by value option)
SET_VALUES - Value Intervals for Set Hierarchy
Data type: SETVALUESOptional: Yes
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
SET_NOT_FOUND - Set Not Found
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
ILLEGAL_FIELD_REPLACEMENT - Invalid Change of Reference Field
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
ILLEGAL_TABLE_REPLACEMENT - Invalid Change of Reference Table
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
SET_IS_DAMAGED - The Set Hierarchy on the Database Is Faulty
Data type:Optional: No
Call by Reference: Yes
Copy and paste ABAP code example for G_SET_TREE_IMPORT 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, " SY-MANDT | |||
| lt_set_hierarchy | TYPE STANDARD TABLE OF SETHIER, " | |||
| lv_set_not_found | TYPE SETHIER, " | |||
| lv_set_not_transparent | TYPE SY-DATAR, " | |||
| lv_no_table_buffering | TYPE SY-DATAR, " SPACE | |||
| lv_max_hier_level | TYPE I, " 99 | |||
| lv_date_from | TYPE DATAB, " | |||
| lv_date_to | TYPE DATBI, " | |||
| lv_fieldname | TYPE RGSMH-FIELD, " SPACE | |||
| lt_set_values | TYPE STANDARD TABLE OF SETVALUES, " | |||
| lv_illegal_field_replacement | TYPE SETVALUES, " | |||
| lv_langu | TYPE SY-LANGU, " SY-LANGU | |||
| lv_illegal_table_replacement | TYPE SY, " | |||
| lv_set_is_damaged | TYPE SY, " | |||
| lv_no_descriptions | TYPE SY-DATAR, " SPACE | |||
| lv_no_rw_info | TYPE SY-DATAR, " SPACE | |||
| lv_setid | TYPE SETHIER-SETID, " | |||
| lv_tabname | TYPE RGSMH-TABLE, " SPACE | |||
| lv_no_variable_replacement | TYPE SY-DATAR, " SPACE | |||
| lv_root_header_only | TYPE SY-DATAR. " SPACE |
|   CALL FUNCTION 'G_SET_TREE_IMPORT' "Importing a Set Hierarchy |
| EXPORTING | ||
| CLIENT | = lv_client | |
| NO_TABLE_BUFFERING | = lv_no_table_buffering | |
| MAX_HIER_LEVEL | = lv_max_hier_level | |
| DATE_FROM | = lv_date_from | |
| DATE_TO | = lv_date_to | |
| FIELDNAME | = lv_fieldname | |
| LANGU | = lv_langu | |
| NO_DESCRIPTIONS | = lv_no_descriptions | |
| NO_RW_INFO | = lv_no_rw_info | |
| SETID | = lv_setid | |
| TABNAME | = lv_tabname | |
| NO_VARIABLE_REPLACEMENT | = lv_no_variable_replacement | |
| ROOT_HEADER_ONLY | = lv_root_header_only | |
| IMPORTING | ||
| SET_NOT_TRANSPARENT | = lv_set_not_transparent | |
| TABLES | ||
| SET_HIERARCHY | = lt_set_hierarchy | |
| SET_VALUES | = lt_set_values | |
| EXCEPTIONS | ||
| SET_NOT_FOUND = 1 | ||
| ILLEGAL_FIELD_REPLACEMENT = 2 | ||
| ILLEGAL_TABLE_REPLACEMENT = 3 | ||
| SET_IS_DAMAGED = 4 | ||
| . " G_SET_TREE_IMPORT | ||
ABAP code using 7.40 inline data declarations to call FM G_SET_TREE_IMPORT
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) | = SY-MANDT. | |||
| "SELECT single DATAR FROM SY INTO @DATA(ld_set_not_transparent). | ||||
| "SELECT single DATAR FROM SY INTO @DATA(ld_no_table_buffering). | ||||
| DATA(ld_no_table_buffering) | = ' '. | |||
| DATA(ld_max_hier_level) | = 99. | |||
| "SELECT single FIELD FROM RGSMH 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_descriptions). | ||||
| DATA(ld_no_descriptions) | = ' '. | |||
| "SELECT single DATAR FROM SY INTO @DATA(ld_no_rw_info). | ||||
| DATA(ld_no_rw_info) | = ' '. | |||
| "SELECT single SETID FROM SETHIER INTO @DATA(ld_setid). | ||||
| "SELECT single TABLE FROM RGSMH INTO @DATA(ld_tabname). | ||||
| DATA(ld_tabname) | = ' '. | |||
| "SELECT single DATAR FROM SY INTO @DATA(ld_no_variable_replacement). | ||||
| DATA(ld_no_variable_replacement) | = ' '. | |||
| "SELECT single DATAR FROM SY INTO @DATA(ld_root_header_only). | ||||
| DATA(ld_root_header_only) | = ' '. | |||
Search for further information about these or an SAP related objects