Fetching N Level Managers
Function module ZHR0275_DYN_MGR_FETCH is created the logic for the same is
Function Group – ZHR0275_MANAGER_FETCH
Import: OBJID, OTYPE, LEVEL
Tables: Output TYPE ZH0275_T_DYN_MGR
1. A standard FM RH_GET_LEADING_POSITION is called in a loop whose number of iterations is based on input parameter LEVEL.
2. This Function module returns the top up position as output in the form of a table called leading_position of type hrobject
3. Outputted position is checked for the assigned holder (Employee), if found then same is sent to the output of the FM
4. If not found then position is sent to the output of the FM.
5. A logic is written with the FM to get the description for the outputted OBJID, If it has otype ‘P’ then data is fetched from PA0002 else from HRP1000 table.
Following table structure was created.
It is table type of ZH0275_DYN_MGR hence has same structure.
Program code is attached in the document.
This is OM Structure of the company, Employee 6204 to a position which is not held by anyone presently, Blank position Reports to 6228 and 6228 to 50050.
Output of the function module is as follows:
OBJID Field can have value for Employee Number or Position.
OTYPE field can have value as ‘S’ for Position and ‘P’ for Employee.
LEVEL field can have any numeral value up to 99, it determines the top up movement in the organization hierarchical structure.
Column wise description
LEVEL This column provides the Manager’s Level above requested employee / position. Immediate manager will have Level as ‘1’ like wise.
OTYPE This field can have two values either P or S, If returned value is P that means top up manager exist, if S is returned that means a top up position do exists over the employee but currently it is unassigned or vacant.
OBJID This field will contain Employee number or Position number for the top up position
Description This field will either display Employee name or vacant position description for the top up manager.
If no top up position exists over a particular position then program will return blank lines. In illustrated example Level 4 is top of the OM structure for the inputted employee, If function is executed for 10 levels then output will be like,