SAP K_HIERARCHY_TABLES_READ Function Module for
K_HIERARCHY_TABLES_READ is a standard k hierarchy tables read 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 k hierarchy tables read FM, simply by entering the name K_HIERARCHY_TABLES_READ into the relevant SAP transaction such as SE37 or SE38.
Function Group: KKHI
Program Name: SAPLKKHI
Main Program: SAPLKKHI
Appliation area: K
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function K_HIERARCHY_TABLES_READ 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 'K_HIERARCHY_TABLES_READ'".
EXPORTING
E_CLASS = "Set Class
* E_REPLACE_FIELD = ' ' "
* E_SUFFIX = "
* E_OLD_LINE_LEVEL = 0 "
* E_CO_REN_FLG = "
E_SETID = "
E_KOKRS = "Controlling Area
* E_MANDT = "Client
* E_MASTER_DATA = "
* E_STRUCTURE = "
* E_REPLACE_CLASS = "
* E_REPLACE_UNIT = "
* E_REPLACE_TABLE = ' ' "
IMPORTING
I_DOUBLE_CHECK = "
I_MASTER_DATA = "
CHANGING
C_INFO = "
C_OVERWRITE = "
TABLES
T_NODES = "Hierarchy Node
T_VALUES = "
* T_MASTER_DATA = "
* T_FORMULA = "Formulas
* T_FIELD_INFO = "
* T_NODE_LIST_OVERWRITE = "
EXCEPTIONS
NO_CONTROLLING_AREA = 1 NO_OVERWRITE_STANDARD_HIER = 10 NO_BUKRS_FOR_KOKRS = 11 NO_CHART_OF_ACCOUNT = 2 DIFFERENT_CONTROLLING_AREAS = 3 DIFFERENT_CHART_OF_ACCOUNTS = 4 SET_NOT_FOUND = 5 ILLEGAL_FIELD_REPLACEMENT = 6 ILLEGAL_TABLE_REPLACEMENT = 7 FM_RAISE = 8 CONVERT_ERROR = 9
IMPORTING Parameters details for K_HIERARCHY_TABLES_READ
E_CLASS - Set Class
Data type: SETHIER-SETCLASSOptional: No
Call by Reference: No ( called with pass by value option)
E_REPLACE_FIELD -
Data type: SETHIER-TABNAMEDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
E_SUFFIX -
Data type: GRPDYNP-SUFFIXOptional: Yes
Call by Reference: No ( called with pass by value option)
E_OLD_LINE_LEVEL -
Data type: SETHIER-LEVELOptional: Yes
Call by Reference: No ( called with pass by value option)
E_CO_REN_FLG -
Data type: BOOLE_DOptional: Yes
Call by Reference: No ( called with pass by value option)
E_SETID -
Data type: SETHIER-SETIDOptional: No
Call by Reference: No ( called with pass by value option)
E_KOKRS - Controlling Area
Data type: SETHIER-KOKRSOptional: No
Call by Reference: No ( called with pass by value option)
E_MANDT - Client
Data type: SY-MANDTOptional: Yes
Call by Reference: No ( called with pass by value option)
E_MASTER_DATA -
Data type: GRPHP1Optional: Yes
Call by Reference: No ( called with pass by value option)
E_STRUCTURE -
Data type: GRPHP2Optional: Yes
Call by Reference: No ( called with pass by value option)
E_REPLACE_CLASS -
Data type: SETHIER-SETCLASSOptional: Yes
Call by Reference: No ( called with pass by value option)
E_REPLACE_UNIT -
Data type: SETHIER-KOKRSOptional: Yes
Call by Reference: No ( called with pass by value option)
E_REPLACE_TABLE -
Data type: SETHIER-FIELDNAMEDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for K_HIERARCHY_TABLES_READ
I_DOUBLE_CHECK -
Data type: FLAGOptional: No
Call by Reference: Yes
I_MASTER_DATA -
Data type: GRPHP1Optional: No
Call by Reference: Yes
CHANGING Parameters details for K_HIERARCHY_TABLES_READ
C_INFO -
Data type: GRPHINFOOptional: No
Call by Reference: Yes
C_OVERWRITE -
Data type: SY-DATAROptional: No
Call by Reference: Yes
TABLES Parameters details for K_HIERARCHY_TABLES_READ
T_NODES - Hierarchy Node
Data type: GSETH_NODE_TABOptional: No
Call by Reference: No ( called with pass by value option)
T_VALUES -
Data type: GSETH_VAL_TABOptional: No
Call by Reference: No ( called with pass by value option)
T_MASTER_DATA -
Data type: GSETH_MD_TABOptional: Yes
Call by Reference: No ( called with pass by value option)
T_FORMULA - Formulas
Data type: GSETH_FORM_TABOptional: Yes
Call by Reference: No ( called with pass by value option)
T_FIELD_INFO -
Data type: GSETH_INFO_TABOptional: Yes
Call by Reference: No ( called with pass by value option)
T_NODE_LIST_OVERWRITE -
Data type: GSETH_NODE_LISTOptional: Yes
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
NO_CONTROLLING_AREA - Controlling area does not exist
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
NO_OVERWRITE_STANDARD_HIER -
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
NO_BUKRS_FOR_KOKRS -
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
NO_CHART_OF_ACCOUNT -
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
DIFFERENT_CONTROLLING_AREAS -
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
DIFFERENT_CHART_OF_ACCOUNTS -
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
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)
FM_RAISE -
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
CONVERT_ERROR -
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for K_HIERARCHY_TABLES_READ 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_c_info | TYPE GRPHINFO, " | |||
| lv_e_class | TYPE SETHIER-SETCLASS, " | |||
| lt_t_nodes | TYPE STANDARD TABLE OF GSETH_NODE_TAB, " | |||
| lv_i_double_check | TYPE FLAG, " | |||
| lv_no_controlling_area | TYPE FLAG, " | |||
| lv_e_replace_field | TYPE SETHIER-TABNAME, " SPACE | |||
| lv_no_overwrite_standard_hier | TYPE SETHIER, " | |||
| lv_e_suffix | TYPE GRPDYNP-SUFFIX, " | |||
| lv_no_bukrs_for_kokrs | TYPE GRPDYNP, " | |||
| lv_e_old_line_level | TYPE SETHIER-LEVEL, " 0 | |||
| lv_e_co_ren_flg | TYPE BOOLE_D, " | |||
| lv_e_setid | TYPE SETHIER-SETID, " | |||
| lt_t_values | TYPE STANDARD TABLE OF GSETH_VAL_TAB, " | |||
| lv_c_overwrite | TYPE SY-DATAR, " | |||
| lv_i_master_data | TYPE GRPHP1, " | |||
| lv_no_chart_of_account | TYPE GRPHP1, " | |||
| lv_e_kokrs | TYPE SETHIER-KOKRS, " | |||
| lt_t_master_data | TYPE STANDARD TABLE OF GSETH_MD_TAB, " | |||
| lv_different_controlling_areas | TYPE GSETH_MD_TAB, " | |||
| lv_e_mandt | TYPE SY-MANDT, " | |||
| lt_t_formula | TYPE STANDARD TABLE OF GSETH_FORM_TAB, " | |||
| lv_different_chart_of_accounts | TYPE GSETH_FORM_TAB, " | |||
| lt_t_field_info | TYPE STANDARD TABLE OF GSETH_INFO_TAB, " | |||
| lv_e_master_data | TYPE GRPHP1, " | |||
| lv_set_not_found | TYPE GRPHP1, " | |||
| lv_e_structure | TYPE GRPHP2, " | |||
| lt_t_node_list_overwrite | TYPE STANDARD TABLE OF GSETH_NODE_LIST, " | |||
| lv_illegal_field_replacement | TYPE GSETH_NODE_LIST, " | |||
| lv_e_replace_class | TYPE SETHIER-SETCLASS, " | |||
| lv_illegal_table_replacement | TYPE SETHIER, " | |||
| lv_fm_raise | TYPE SETHIER, " | |||
| lv_e_replace_unit | TYPE SETHIER-KOKRS, " | |||
| lv_convert_error | TYPE SETHIER, " | |||
| lv_e_replace_table | TYPE SETHIER-FIELDNAME. " SPACE |
|   CALL FUNCTION 'K_HIERARCHY_TABLES_READ' " |
| EXPORTING | ||
| E_CLASS | = lv_e_class | |
| E_REPLACE_FIELD | = lv_e_replace_field | |
| E_SUFFIX | = lv_e_suffix | |
| E_OLD_LINE_LEVEL | = lv_e_old_line_level | |
| E_CO_REN_FLG | = lv_e_co_ren_flg | |
| E_SETID | = lv_e_setid | |
| E_KOKRS | = lv_e_kokrs | |
| E_MANDT | = lv_e_mandt | |
| E_MASTER_DATA | = lv_e_master_data | |
| E_STRUCTURE | = lv_e_structure | |
| E_REPLACE_CLASS | = lv_e_replace_class | |
| E_REPLACE_UNIT | = lv_e_replace_unit | |
| E_REPLACE_TABLE | = lv_e_replace_table | |
| IMPORTING | ||
| I_DOUBLE_CHECK | = lv_i_double_check | |
| I_MASTER_DATA | = lv_i_master_data | |
| CHANGING | ||
| C_INFO | = lv_c_info | |
| C_OVERWRITE | = lv_c_overwrite | |
| TABLES | ||
| T_NODES | = lt_t_nodes | |
| T_VALUES | = lt_t_values | |
| T_MASTER_DATA | = lt_t_master_data | |
| T_FORMULA | = lt_t_formula | |
| T_FIELD_INFO | = lt_t_field_info | |
| T_NODE_LIST_OVERWRITE | = lt_t_node_list_overwrite | |
| EXCEPTIONS | ||
| NO_CONTROLLING_AREA = 1 | ||
| NO_OVERWRITE_STANDARD_HIER = 10 | ||
| NO_BUKRS_FOR_KOKRS = 11 | ||
| NO_CHART_OF_ACCOUNT = 2 | ||
| DIFFERENT_CONTROLLING_AREAS = 3 | ||
| DIFFERENT_CHART_OF_ACCOUNTS = 4 | ||
| SET_NOT_FOUND = 5 | ||
| ILLEGAL_FIELD_REPLACEMENT = 6 | ||
| ILLEGAL_TABLE_REPLACEMENT = 7 | ||
| FM_RAISE = 8 | ||
| CONVERT_ERROR = 9 | ||
| . " K_HIERARCHY_TABLES_READ | ||
ABAP code using 7.40 inline data declarations to call FM K_HIERARCHY_TABLES_READ
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 SETCLASS FROM SETHIER INTO @DATA(ld_e_class). | ||||
| "SELECT single TABNAME FROM SETHIER INTO @DATA(ld_e_replace_field). | ||||
| DATA(ld_e_replace_field) | = ' '. | |||
| "SELECT single SUFFIX FROM GRPDYNP INTO @DATA(ld_e_suffix). | ||||
| "SELECT single LEVEL FROM SETHIER INTO @DATA(ld_e_old_line_level). | ||||
| "SELECT single SETID FROM SETHIER INTO @DATA(ld_e_setid). | ||||
| "SELECT single DATAR FROM SY INTO @DATA(ld_c_overwrite). | ||||
| "SELECT single KOKRS FROM SETHIER INTO @DATA(ld_e_kokrs). | ||||
| "SELECT single MANDT FROM SY INTO @DATA(ld_e_mandt). | ||||
| "SELECT single SETCLASS FROM SETHIER INTO @DATA(ld_e_replace_class). | ||||
| "SELECT single KOKRS FROM SETHIER INTO @DATA(ld_e_replace_unit). | ||||
| "SELECT single FIELDNAME FROM SETHIER INTO @DATA(ld_e_replace_table). | ||||
| DATA(ld_e_replace_table) | = ' '. | |||
Search for further information about these or an SAP related objects