SAP K_GET_HIERARCHY Function Module for









K_GET_HIERARCHY is a standard k get hierarchy 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 get hierarchy FM, simply by entering the name K_GET_HIERARCHY into the relevant SAP transaction such as SE37 or SE38.

Function Group: KKPH
Program Name: SAPLKKPH
Main Program:
Appliation area: K
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:



Function K_GET_HIERARCHY 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_GET_HIERARCHY'"
EXPORTING
* HIART = '1' "
* LOEKZ = ' ' "
* OBART = '1' "
* TOTAL = "
* WITH_POSNR = "
* WITH_ORDERS = 'X' "
* READMODE = ' ' "
* KTRTP = '01' "
OBJECT_NR = "
* DATBI = '99991231' "
* WERKS = ' ' "
* VERID = ' ' "
* PROCNR = "
* PLNNR = "
* PLNAL = "

IMPORTING
KOKRS = "

TABLES
KKHIE_I = "
* CKPH_I = "
* CKPE_I = "
* VKKP0_OR_I = "

EXCEPTIONS
NOT_FOUND = 1 NOT_ATTACHED = 2 SYSTEM_FAILURE = 3 WRONG_COSTOBJECT_TYPE = 4 NO_ROOT = 5
.



IMPORTING Parameters details for K_GET_HIERARCHY

HIART -

Data type: KKHIE-HIART
Default: '1'
Optional: Yes
Call by Reference: No ( called with pass by value option)

LOEKZ -

Data type: CKPH-LOEKZ
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

OBART -

Data type: KKHIE-OBART
Default: '1'
Optional: Yes
Call by Reference: No ( called with pass by value option)

TOTAL -

Data type: SY-INPUT
Optional: Yes
Call by Reference: No ( called with pass by value option)

WITH_POSNR -

Data type: SY-INPUT
Optional: Yes
Call by Reference: No ( called with pass by value option)

WITH_ORDERS -

Data type: SY-INPUT
Default: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)

READMODE -

Data type: SY-INPUT
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

KTRTP -

Data type: CKPHS-KTRTP
Default: '01'
Optional: Yes
Call by Reference: No ( called with pass by value option)

OBJECT_NR -

Data type: CKPH-OBJNR
Optional: No
Call by Reference: No ( called with pass by value option)

DATBI -

Data type: CKPH-DATBI
Default: '99991231'
Optional: Yes
Call by Reference: No ( called with pass by value option)

WERKS -

Data type: KKHIE-WERKS
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

VERID -

Data type: KKHIE-VERID
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

PROCNR -

Data type: KKHIE-PROCNR
Optional: Yes
Call by Reference: No ( called with pass by value option)

PLNNR -

Data type: KKHIE-PLNNR
Optional: Yes
Call by Reference: No ( called with pass by value option)

PLNAL -

Data type: KKHIE-PLNAL
Optional: Yes
Call by Reference: No ( called with pass by value option)

EXPORTING Parameters details for K_GET_HIERARCHY

KOKRS -

Data type: CKPH-KOKRS
Optional: No
Call by Reference: No ( called with pass by value option)

TABLES Parameters details for K_GET_HIERARCHY

KKHIE_I -

Data type: KKHIE
Optional: No
Call by Reference: No ( called with pass by value option)

CKPH_I -

Data type: CKPH
Optional: Yes
Call by Reference: No ( called with pass by value option)

CKPE_I -

Data type: CKPE
Optional: Yes
Call by Reference: No ( called with pass by value option)

VKKP0_OR_I -

Data type: VKKP0_OR
Optional: Yes
Call by Reference: No ( called with pass by value option)

EXCEPTIONS details

NOT_FOUND - Hierarchy node does not exist

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

NOT_ATTACHED -

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

SYSTEM_FAILURE -

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

WRONG_COSTOBJECT_TYPE -

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

NO_ROOT -

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

Copy and paste ABAP code example for K_GET_HIERARCHY 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_hiart  TYPE KKHIE-HIART, "   '1'
lv_kokrs  TYPE CKPH-KOKRS, "   
lt_kkhie_i  TYPE STANDARD TABLE OF KKHIE, "   
lv_not_found  TYPE KKHIE, "   
lv_loekz  TYPE CKPH-LOEKZ, "   SPACE
lv_obart  TYPE KKHIE-OBART, "   '1'
lv_total  TYPE SY-INPUT, "   
lv_with_posnr  TYPE SY-INPUT, "   
lv_with_orders  TYPE SY-INPUT, "   'X'
lv_readmode  TYPE SY-INPUT, "   SPACE
lv_ktrtp  TYPE CKPHS-KTRTP, "   '01'
lt_ckph_i  TYPE STANDARD TABLE OF CKPH, "   
lv_not_attached  TYPE CKPH, "   
lt_ckpe_i  TYPE STANDARD TABLE OF CKPE, "   
lv_object_nr  TYPE CKPH-OBJNR, "   
lv_system_failure  TYPE CKPH, "   
lv_datbi  TYPE CKPH-DATBI, "   '99991231'
lt_vkkp0_or_i  TYPE STANDARD TABLE OF VKKP0_OR, "   
lv_wrong_costobject_type  TYPE VKKP0_OR, "   
lv_werks  TYPE KKHIE-WERKS, "   SPACE
lv_no_root  TYPE KKHIE, "   
lv_verid  TYPE KKHIE-VERID, "   SPACE
lv_procnr  TYPE KKHIE-PROCNR, "   
lv_plnnr  TYPE KKHIE-PLNNR, "   
lv_plnal  TYPE KKHIE-PLNAL. "   

  CALL FUNCTION 'K_GET_HIERARCHY'  "
    EXPORTING
         HIART = lv_hiart
         LOEKZ = lv_loekz
         OBART = lv_obart
         TOTAL = lv_total
         WITH_POSNR = lv_with_posnr
         WITH_ORDERS = lv_with_orders
         READMODE = lv_readmode
         KTRTP = lv_ktrtp
         OBJECT_NR = lv_object_nr
         DATBI = lv_datbi
         WERKS = lv_werks
         VERID = lv_verid
         PROCNR = lv_procnr
         PLNNR = lv_plnnr
         PLNAL = lv_plnal
    IMPORTING
         KOKRS = lv_kokrs
    TABLES
         KKHIE_I = lt_kkhie_i
         CKPH_I = lt_ckph_i
         CKPE_I = lt_ckpe_i
         VKKP0_OR_I = lt_vkkp0_or_i
    EXCEPTIONS
        NOT_FOUND = 1
        NOT_ATTACHED = 2
        SYSTEM_FAILURE = 3
        WRONG_COSTOBJECT_TYPE = 4
        NO_ROOT = 5
. " K_GET_HIERARCHY




ABAP code using 7.40 inline data declarations to call FM K_GET_HIERARCHY

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 HIART FROM KKHIE INTO @DATA(ld_hiart).
DATA(ld_hiart) = '1'.
 
"SELECT single KOKRS FROM CKPH INTO @DATA(ld_kokrs).
 
 
 
"SELECT single LOEKZ FROM CKPH INTO @DATA(ld_loekz).
DATA(ld_loekz) = ' '.
 
"SELECT single OBART FROM KKHIE INTO @DATA(ld_obart).
DATA(ld_obart) = '1'.
 
"SELECT single INPUT FROM SY INTO @DATA(ld_total).
 
"SELECT single INPUT FROM SY INTO @DATA(ld_with_posnr).
 
"SELECT single INPUT FROM SY INTO @DATA(ld_with_orders).
DATA(ld_with_orders) = 'X'.
 
"SELECT single INPUT FROM SY INTO @DATA(ld_readmode).
DATA(ld_readmode) = ' '.
 
"SELECT single KTRTP FROM CKPHS INTO @DATA(ld_ktrtp).
DATA(ld_ktrtp) = '01'.
 
 
 
 
"SELECT single OBJNR FROM CKPH INTO @DATA(ld_object_nr).
 
 
"SELECT single DATBI FROM CKPH INTO @DATA(ld_datbi).
DATA(ld_datbi) = '99991231'.
 
 
 
"SELECT single WERKS FROM KKHIE INTO @DATA(ld_werks).
DATA(ld_werks) = ' '.
 
 
"SELECT single VERID FROM KKHIE INTO @DATA(ld_verid).
DATA(ld_verid) = ' '.
 
"SELECT single PROCNR FROM KKHIE INTO @DATA(ld_procnr).
 
"SELECT single PLNNR FROM KKHIE INTO @DATA(ld_plnnr).
 
"SELECT single PLNAL FROM KKHIE INTO @DATA(ld_plnal).
 


Search for further information about these or an SAP related objects



Comments on this SAP object

What made you want to lookup this SAP object? Please tell us what you were looking for and anything you would like to be included on this page!