SAP K_GROUP_REMOTE_DIRECTORY Function Module for Directory of CO hierarchies
K_GROUP_REMOTE_DIRECTORY is a standard k group remote directory SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Directory of CO hierarchies 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 k group remote directory FM, simply by entering the name K_GROUP_REMOTE_DIRECTORY into the relevant SAP transaction such as SE37 or SE38.
Function Group: KGR2
Program Name: SAPLKGR2
Main Program: SAPLKGR2
Appliation area: K
Release date: 30-Mar-1999
Mode(Normal, Remote etc): Remote-Enabled
Update:

Function K_GROUP_REMOTE_DIRECTORY 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_GROUP_REMOTE_DIRECTORY'"Directory of CO hierarchies.
EXPORTING
SETCLASS = "Set class
* CO_AREA = "Controlling area
* CHRT_ACCTS = "Chart of accounts (for cost elements/account groups)
* GROUPNAME = '*' "Entry screen for group name
* LANGUAGE = "Language of text
* TOP_NODES_ONLY = ' ' "Search for top node only
IMPORTING
RETURN = "Error
TABLES
ET_SETLIST = "List of hierarchies found
IMPORTING Parameters details for K_GROUP_REMOTE_DIRECTORY
SETCLASS - Set class
Data type: SETHIER_CO-SETCLASSOptional: No
Call by Reference: No ( called with pass by value option)
CO_AREA - Controlling area
Data type: SETHIER_CO-CO_AREAOptional: Yes
Call by Reference: No ( called with pass by value option)
CHRT_ACCTS - Chart of accounts (for cost elements/account groups)
Data type: SETHIER_CO-CHRT_ACCTSOptional: Yes
Call by Reference: No ( called with pass by value option)
GROUPNAME - Entry screen for group name
Data type: SETHIER_CO-GROUPNAMEDefault: '*'
Optional: Yes
Call by Reference: No ( called with pass by value option)
LANGUAGE - Language of text
Data type: SY-LANGUOptional: Yes
Call by Reference: No ( called with pass by value option)
TOP_NODES_ONLY - Search for top node only
Data type: SY-DATARDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for K_GROUP_REMOTE_DIRECTORY
RETURN - Error
Data type: BAPIRET2Optional: No
Call by Reference: No ( called with pass by value option)
TABLES Parameters details for K_GROUP_REMOTE_DIRECTORY
ET_SETLIST - List of hierarchies found
Data type: SETHIER_COOptional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for K_GROUP_REMOTE_DIRECTORY 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_return | TYPE BAPIRET2, " | |||
| lv_setclass | TYPE SETHIER_CO-SETCLASS, " | |||
| lt_et_setlist | TYPE STANDARD TABLE OF SETHIER_CO, " | |||
| lv_co_area | TYPE SETHIER_CO-CO_AREA, " | |||
| lv_chrt_accts | TYPE SETHIER_CO-CHRT_ACCTS, " | |||
| lv_groupname | TYPE SETHIER_CO-GROUPNAME, " '*' | |||
| lv_language | TYPE SY-LANGU, " | |||
| lv_top_nodes_only | TYPE SY-DATAR. " SPACE |
|   CALL FUNCTION 'K_GROUP_REMOTE_DIRECTORY' "Directory of CO hierarchies |
| EXPORTING | ||
| SETCLASS | = lv_setclass | |
| CO_AREA | = lv_co_area | |
| CHRT_ACCTS | = lv_chrt_accts | |
| GROUPNAME | = lv_groupname | |
| LANGUAGE | = lv_language | |
| TOP_NODES_ONLY | = lv_top_nodes_only | |
| IMPORTING | ||
| RETURN | = lv_return | |
| TABLES | ||
| ET_SETLIST | = lt_et_setlist | |
| . " K_GROUP_REMOTE_DIRECTORY | ||
ABAP code using 7.40 inline data declarations to call FM K_GROUP_REMOTE_DIRECTORY
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_CO INTO @DATA(ld_setclass). | ||||
| "SELECT single CO_AREA FROM SETHIER_CO INTO @DATA(ld_co_area). | ||||
| "SELECT single CHRT_ACCTS FROM SETHIER_CO INTO @DATA(ld_chrt_accts). | ||||
| "SELECT single GROUPNAME FROM SETHIER_CO INTO @DATA(ld_groupname). | ||||
| DATA(ld_groupname) | = '*'. | |||
| "SELECT single LANGU FROM SY INTO @DATA(ld_language). | ||||
| "SELECT single DATAR FROM SY INTO @DATA(ld_top_nodes_only). | ||||
| DATA(ld_top_nodes_only) | = ' '. | |||
Search for further information about these or an SAP related objects