Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Finding Supervisor of an employee

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

9 REPLIES 9

Former Member
0 Kudos

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

0 Kudos

Hi, I tried all this FM.

Cheers

0 Kudos

Hi,

Have you checked:

BAPI_EMPLOYEE_GETDATA

Thanks,

Krishna

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

solved