06-11-2009 4:51 AM
Hi Guys,
I am trying to get the manager of an employee.
I can't get it from HRP1001 as advised by functional consultant, I am trying to get it using FM.
Here is my code
DATA: l_actor_tab TYPE swhactor OCCURS 0 WITH HEADER LINE,
result_tab TYPE swhactor OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'RH_STRUC_GET'
EXPORTING
act_otype = 'O'
act_objid = p0001-orgeh
act_wegid = 'B012'
TABLES
result_tab = l_actor_tab
EXCEPTIONS
no_plvar_found = 1
no_entry_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'RH_STRUC_GET'
EXPORTING
act_otype = 'S'
act_objid = l_actor_tab-objid
act_wegid = 'A008'
TABLES
result_tab = result_tab
EXCEPTIONS
no_plvar_found = 1
no_entry_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
This code works fine, when the employee himseld not a manager.
If the employee is a manager, it brings his own PERNR.
Thanks for your time.
Cheers
06-11-2009 5:37 AM
hi
try using these FM's:
SWX_GET_MANAGER
RH_GET_STRUCT
RH_GET_LEADING_POSITION
RH_GET_LEADER
hope this helps
regards
Aakash Banga
06-11-2009 5:37 AM
hi
try using these FM's:
SWX_GET_MANAGER
RH_GET_STRUCT
RH_GET_LEADING_POSITION
RH_GET_LEADER
hope this helps
regards
Aakash Banga
06-11-2009 5:39 AM
06-11-2009 7:25 AM
06-11-2009 7:29 AM
To my knowledge what ever FM or Bapi u use...u will get the same pernr if he himself is a manager...
Put a condition that, if pernr = manager, go to higher org and get manager of higher org
Regards,
Veeranji Reddy P
06-11-2009 7:30 AM
hi
the table HRP1001 - holds all the relationships.
I think if you are giving the pernr and relationship A002 (reports to) you will easily get the reporting manager of the pernr ...
regards ,
amit
06-11-2009 7:41 AM
if the employee himself is the manager then take the orgunit of the employee and use the FM
CALL FUNCTION 'RH_STRUC_GET'
EXPORTING
act_otype = 'O'
act_objid = p0001-orgeh
act_wegid = 'A002' --> Reports to
TABLES
result_tab = l_actor_tab --> Reporting org unit
EXCEPTIONS
no_plvar_found = 1
no_entry_found = 2
OTHERS = 3.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'RH_STRUC_GET'
EXPORTING
act_otype = 'O'
act_objid = Reporting org unit --> get it from the above FM
act_wegid = 'B012'
TABLES
result_tab = l_actor_tab
EXCEPTIONS
no_plvar_found = 1
no_entry_found = 2
OTHERS = 3.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'RH_STRUC_GET'
EXPORTING
act_otype = 'S'
act_objid = l_actor_tab-objid
act_wegid = 'A008'
TABLES
result_tab = result_tab
EXCEPTIONS
no_plvar_found = 1
no_entry_found = 2
OTHERS = 3.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
Kumar Bandanadham
06-12-2009 8:21 AM
Hi,
The first call with act_wegid = A002 brings more than one result record.
I am not sure which one to use for the next call.
Thanks
06-23-2009 8:08 PM
I had the same issue...Try this
IF <fs_emp_info>-orgeh NE '00000000'.
SELECT SINGLE * INTO gw_hrp1000
FROM hrp1000
WHERE plvar EQ '01'
AND otype EQ 'O'
AND objid EQ <fs_emp_info>-orgeh
AND istat EQ '1'.
CALL FUNCTION 'HRCM_ORGUNIT_MANAGER_GET'
EXPORTING
plvar = '01'
otype = 'O'
objid = <fs_emp_info>-orgeh
begda = gw_hrp1000-begda
endda = gw_hrp1000-endda
TABLES
manager_info_table = gt_mgr_info
EXCEPTIONS
path_error = 1
root_error = 2
nothing_found = 3
OTHERS = 4.
LOOP AT gt_mgr_info INTO gw_mgr_info.
MOVE:gw_mgr_info-objid TO <fs_emp_info>-m_pernr.
MOVE: gw_mgr_info-stext TO <fs_emp_info>-m_vorna.
READ TABLE gt_file_info WITH KEY pernr = <fs_emp_info>-m_pernr.
IF sy-subrc = 0.
<fs_emp_info>-m_usrid = gt_file_info-usrid.
ENDIF.
ENDLOOP.
ENDIF.
09-12-2009 3:43 AM