SAP STREE_HIERARCHY_COPY Function Module for Copy a Structure
STREE_HIERARCHY_COPY is a standard stree hierarchy copy SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Copy a Structure 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 stree hierarchy copy FM, simply by entering the name STREE_HIERARCHY_COPY into the relevant SAP transaction such as SE37 or SE38.
Function Group: SHI6
Program Name: SAPLSHI6
Main Program: SAPLSHI6
Appliation area: S
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function STREE_HIERARCHY_COPY 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 'STREE_HIERARCHY_COPY'"Copy a Structure.
EXPORTING
COPY_FROM_STRUCTURE_ID = "
* NO_TRANSPORT_CHECK = "Single-Character Flag
* UPDATE_TTREE_APPL = ' ' "
* COPY_DEPENDENT_FILTERS = ' ' "
* NEW_STRUCTURE_ID = ' ' "
* NEW_STRUCTURE_TOP_NODE = ' ' "
NEW_STRUCTURE_DESCRIPTION = "
* NEW_EXTERNAL_KEY = ' ' "
* NEW_MASTERLANGUAGE = SY-LANGU "SAP R/3 System, Current Language
* NEW_TRANSPORT_ORDER = ' ' "
* NEW_DEVELOPMENT_CLASS = ' ' "
IMPORTING
COPIED_STRUCTURE_ID = "
MESSAGE = "
TABLES
* NEW_DEPENDENT_FILTERS = "Definition Table for Structures
* USER_PARAMETERS = "
IMPORTING Parameters details for STREE_HIERARCHY_COPY
COPY_FROM_STRUCTURE_ID -
Data type: TTREE-IDOptional: No
Call by Reference: No ( called with pass by value option)
NO_TRANSPORT_CHECK - Single-Character Flag
Data type: CHAR1Optional: Yes
Call by Reference: No ( called with pass by value option)
UPDATE_TTREE_APPL -
Data type: HIER_YESNODefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
COPY_DEPENDENT_FILTERS -
Data type: HIER_YESNODefault: SPACE
Optional: Yes
Call by Reference: Yes
NEW_STRUCTURE_ID -
Data type: TTREE-IDDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
NEW_STRUCTURE_TOP_NODE -
Data type: TTREE-NODE_IDDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
NEW_STRUCTURE_DESCRIPTION -
Data type: TTREET-TEXTOptional: No
Call by Reference: No ( called with pass by value option)
NEW_EXTERNAL_KEY -
Data type: TTREE-EXT_KEYDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
NEW_MASTERLANGUAGE - SAP R/3 System, Current Language
Data type: SY-LANGUDefault: SY-LANGU
Optional: Yes
Call by Reference: No ( called with pass by value option)
NEW_TRANSPORT_ORDER -
Data type: KO200-TRKORRDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
NEW_DEVELOPMENT_CLASS -
Data type: KO200-DEVCLASSDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for STREE_HIERARCHY_COPY
COPIED_STRUCTURE_ID -
Data type: TTREE-IDOptional: No
Call by Reference: No ( called with pass by value option)
MESSAGE -
Data type: HIER_MESSOptional: No
Call by Reference: No ( called with pass by value option)
TABLES Parameters details for STREE_HIERARCHY_COPY
NEW_DEPENDENT_FILTERS - Definition Table for Structures
Data type: TTREEOptional: Yes
Call by Reference: Yes
USER_PARAMETERS -
Data type: STREEPROPOptional: Yes
Call by Reference: Yes
Copy and paste ABAP code example for STREE_HIERARCHY_COPY 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_copied_structure_id | TYPE TTREE-ID, " | |||
| lt_new_dependent_filters | TYPE STANDARD TABLE OF TTREE, " | |||
| lv_copy_from_structure_id | TYPE TTREE-ID, " | |||
| lv_no_transport_check | TYPE CHAR1, " | |||
| lv_update_ttree_appl | TYPE HIER_YESNO, " SPACE | |||
| lv_message | TYPE HIER_MESS, " | |||
| lt_user_parameters | TYPE STANDARD TABLE OF STREEPROP, " | |||
| lv_copy_dependent_filters | TYPE HIER_YESNO, " SPACE | |||
| lv_new_structure_id | TYPE TTREE-ID, " SPACE | |||
| lv_new_structure_top_node | TYPE TTREE-NODE_ID, " SPACE | |||
| lv_new_structure_description | TYPE TTREET-TEXT, " | |||
| lv_new_external_key | TYPE TTREE-EXT_KEY, " SPACE | |||
| lv_new_masterlanguage | TYPE SY-LANGU, " SY-LANGU | |||
| lv_new_transport_order | TYPE KO200-TRKORR, " SPACE | |||
| lv_new_development_class | TYPE KO200-DEVCLASS. " SPACE |
|   CALL FUNCTION 'STREE_HIERARCHY_COPY' "Copy a Structure |
| EXPORTING | ||
| COPY_FROM_STRUCTURE_ID | = lv_copy_from_structure_id | |
| NO_TRANSPORT_CHECK | = lv_no_transport_check | |
| UPDATE_TTREE_APPL | = lv_update_ttree_appl | |
| COPY_DEPENDENT_FILTERS | = lv_copy_dependent_filters | |
| NEW_STRUCTURE_ID | = lv_new_structure_id | |
| NEW_STRUCTURE_TOP_NODE | = lv_new_structure_top_node | |
| NEW_STRUCTURE_DESCRIPTION | = lv_new_structure_description | |
| NEW_EXTERNAL_KEY | = lv_new_external_key | |
| NEW_MASTERLANGUAGE | = lv_new_masterlanguage | |
| NEW_TRANSPORT_ORDER | = lv_new_transport_order | |
| NEW_DEVELOPMENT_CLASS | = lv_new_development_class | |
| IMPORTING | ||
| COPIED_STRUCTURE_ID | = lv_copied_structure_id | |
| MESSAGE | = lv_message | |
| TABLES | ||
| NEW_DEPENDENT_FILTERS | = lt_new_dependent_filters | |
| USER_PARAMETERS | = lt_user_parameters | |
| . " STREE_HIERARCHY_COPY | ||
ABAP code using 7.40 inline data declarations to call FM STREE_HIERARCHY_COPY
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 ID FROM TTREE INTO @DATA(ld_copied_structure_id). | ||||
| "SELECT single ID FROM TTREE INTO @DATA(ld_copy_from_structure_id). | ||||
| DATA(ld_update_ttree_appl) | = ' '. | |||
| DATA(ld_copy_dependent_filters) | = ' '. | |||
| "SELECT single ID FROM TTREE INTO @DATA(ld_new_structure_id). | ||||
| DATA(ld_new_structure_id) | = ' '. | |||
| "SELECT single NODE_ID FROM TTREE INTO @DATA(ld_new_structure_top_node). | ||||
| DATA(ld_new_structure_top_node) | = ' '. | |||
| "SELECT single TEXT FROM TTREET INTO @DATA(ld_new_structure_description). | ||||
| "SELECT single EXT_KEY FROM TTREE INTO @DATA(ld_new_external_key). | ||||
| DATA(ld_new_external_key) | = ' '. | |||
| "SELECT single LANGU FROM SY INTO @DATA(ld_new_masterlanguage). | ||||
| DATA(ld_new_masterlanguage) | = SY-LANGU. | |||
| "SELECT single TRKORR FROM KO200 INTO @DATA(ld_new_transport_order). | ||||
| DATA(ld_new_transport_order) | = ' '. | |||
| "SELECT single DEVCLASS FROM KO200 INTO @DATA(ld_new_development_class). | ||||
| DATA(ld_new_development_class) | = ' '. | |||
Search for further information about these or an SAP related objects