Thanks to Kat for this one... I've got to get the UserID of the Users Manager... trouble is, sometimes the OrgStructure positions aren't filled - so I have to see who's sitting in the position. If there's no-one in it, then I loop back round and get the OrgStructure's superior position (since there's no Personnel person to check on!). I repeat this until I find someone, and stop at 20 goes... If this has happened, it's either
the guy at the top of the tree (we try 20 times to work out if the guy has a useful boss, but fail because it's Paul Solomon :)
OR
there's such a massive Org Structure that's not populated with stuff, that you should probably question what the point of the structure is!!
do 20 times. "Don't want to infinite loop...
refresh t_leadpos.
CALL FUNCTION 'RH_GET_LEADING_POSITION'
EXPORTING
plvar = w_plvar
otype = l_otype "can be US (user), P (Person), S (position) or O (Org unit)
sobid = l_sobid
date = sy-datum
auth = ' '
TABLES
leading_pos = t_leadpos
EXCEPTIONS
no_lead_pos_found = 1
OTHERS = 2.
check t_leadpos[] is not initial.
read table t_leadpos into w_leadpos index 1.
REFRESH t_holders.
CALL FUNCTION 'HRWPC_RFC_PP_HOLDERS'
EXPORTING
plvar = w_plvar "usually 01
otype = 'S'
objid = w_leadpos-objid "from above table read
TABLES
holder = t_holders
EXCEPTIONS
no_active_plvar = 1
infty_not_found = 2
nothing_found = 3
OTHERS = 4.
IF sy-subrc = 0 AND t_holders IS NOT INITIAL.
READ TABLE t_holders INTO w_holders INDEX 1.
read table t_pa0105 into w_pa0105 with key pernr = w_holders-pernr
subty = '0001'.
if sy-subrc = 0.
p_output-manager = w_pa0105-usrid.
exit.
endif.
else. "Didn't find holders for the position... Go and find the Super-Position.
l_otype = w_leadpos-otype. "Probably 'S' but hey, let's make it dynamic.
l_sobid = w_leadpos-objid.
endif. "Found holders for the position.
enddo. "Iterate up the structure.
No comments:
Post a Comment