RH_PM_GET_STRUCTURE FM to retrieve HR Organisation Structure

The below ABAP code shows how RH_PM_GET_STRUCTURE is used. You pass it an Organisation Unit(OBJID) and it will retrieve all the units below it in the org. tree (including idividual personnel). Also 'RH_DIR_ORG_STRUC_GET' is an alternative but seems to be much slower.

The OBJECT_TAB table stores all the objects within the org structure zorg_unit (including all sub levels). The key for these objects is stored within the 'OTYPE' field. Therefor if you loop through the table you can retrive the objects you require.
   i.e. The following code will loop around all the personnel numbers:

* Loops around personnel numbers within Org. Unit.
LOOP AT objec_tab where otype = 'P'.
* Processing....
ENDLOOP.

See PPOM_OLD transaction code to view personnel numbers within an organisation unit!

data: objec_tab like objec occurs 0 with header line.
data: zorg_unit   type p0001-orgeh.
data: t_org_tab like rhldapp occurs 0 with header line.
  call function 'RH_PM_GET_STRUCTURE'
       exporting
            plvar           = '01'   "p0000-plvar
            otype           = 'O'  "0001-otype
            objid           = zorg_unit
            begda           = pn-begda
            endda           = pn-endda
            status          = '1'
            wegid           = 'SBESX'   "ORGEH
            77aw_int        = ' '
       tables
            objec_tab       = objec_tab
       exceptions
            not_found       = 1
            ppway_not_found = 2
            others          = 3.

The wegid passed to function module RH_PM_GET_STRUCTURE defines what the Evaluation Path is and controls what gets returned:

SBESX - All Staff assignments along organizational structure
ORGEH - Returns only org units within passed org unit
SBESC - Staff assignments of organizational structure with describing job
..See T778A for possible values that can be passed to this parameter


data: objec_tab like objec occurs 0 with header line.
***************************
Alternative, but very slow*
***************************
*    call function 'RH_DIR_ORG_STRUC_GET'
*        exporting
*              act_orgunit     = zorg_unit
*              act_plvar       = '01'
*              act_date        = pn-begda
*         tables
*              org_units       = t_org_tab
*         exceptions
*              no_active_plvar = 1
*              others          = 2.

If you want to create your own version of this see here for details on Org unit relationship


Related Articles

ABAP4_CALL_TRANSACTION sap function module
BAPI_ALM_ORDER_MAINTAIN sap BAPI / Function Module to create a work order
Function module BAPI_EMPLCOMM_CREATE to maintain the SAP HR communication infotype 0105
CLPB_EXPORT sap function module
CLPB_IMPORT sap function module
CONVERT_DATE_TO_EXTERNAL sap function module
CREATE_TEXT sap function module
CURRENCY_AMOUNT_DISPLAY_TO_SAP sap function module to Convert currency value from display to SAP
CURRENCY_AMOUNT_SAP_TO_DISPLAY FM to Convert currency value from SAP to display
DATE_COMPUTE_DAY sap function module
DATE_TO_DAY sap function module
DOCU_READ sap function module
ENQUEUE_READ sap function module
F4IF_INT_TABLE_VALUE_REQUEST sap function module
FILE_GET_NAME sap function module
SAP Application specific function modules
SAP Custom function modules
SAP field conversion function modules
SAP HR specific function modules
SAP development function modules
Retrieve employees address details (own data)
Function Module DYNP_VALUES_UPDATE to Change screen field contents
sxpg_command_execute FM to Execute external commands (FTP Scripts)
DETERMINE_PERIOD FM to Retrieve fiscal year and period
Function module HR_INFOTYPE_OPERATION to maintain SAP HR infotypes
Validate WBS (code used in ME21)
HR_READ_INFOTYPE SAP FM to Read infotype data
READ_TEXT FM to Read SAP texts
ADDR_PERS_COMP_COMM_MAINTAIN to Update sap users email address plus other details (own data)
HR_PERSONAL_WORK_SCHEDULE to Retrieve employees work schedule
NUMBER_GET_NEXT to get next number in number range sap function module
Generate random number using QF05_RANDOM_INTEGER SAP function module within your ABAP code
RSEC_GENERATE_PASSWORD SAP FM to generate user password
The SAP internet user functionality and Password BAPIs
SAPGUI_SET_FUNCTIONCODE sap function module to execute function code
SX_INTERNET_ADDRESS_TO_NORMAL SAP function module to check email format is correct