06-17-2010 11:17 AM
Dear experts,
I have a requirement wherein I have to get all the personnel numbers inside a specific org unit.
For that I have to get all the positions in that org unit. But the issue is, due hierarchical structure of org units, I cannot get
the positions inside the nested org units.
O------ O1-------------- O4 ----------- S4
|___ O2 |____ O5 |____S5
|___ O3 |_____ S3
|___ S1
|___ S2
Here I get only the positions S1 and S2 for org unit "O" , whereas I also want positions S3,S4,S5...
Regards,
Sumit.
06-17-2010 2:54 PM
Hi Sumit ,
you can use the FM 'RH_STRUC_GET' for this purpose. It will retrieve all the levels of data.Given below is the Example of Source. ITAB it_result will have all the active positions and persons.
You can delete the data other than person in the ITAB by the delete statement.
Delete it_result where otype <> 'P'.
Finally your objID will be active persons available under the org unit.
CALL FUNCTION 'RH_STRUC_GET'
EXPORTING
act_otype = 'O'
act_objid = " Pass Org_unit ID here
act_wegid = 'O-S-P'
* ACT_INT_FLAG =
* ACT_PLVAR = ' '
ACT_BEGDA = SY-DATUM
ACT_ENDDA = SY-DATUM
ACT_TDEPTH = 20
* ACT_TFLAG = 'X'
* ACT_VFLAG = 'X'
* AUTHORITY_CHECK = 'X'
* TEXT_BUFFER_FILL =
* BUFFER_MODE =
* IMPORTING
* ACT_PLVAR =
TABLES
RESULT_TAB = it_result
* RESULT_OBJEC =
* RESULT_STRUC =
* 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.
06-17-2010 1:33 PM
Hi...
If your requirement is just to find active persons in org unit ,dont use get pernr insted directly use select statement as,
select pernr form pa0001 into itab where
orgeh in s_orgeh(its ur select option on screen)
abd begda eq p_begda and endda eq p_endda.
this will give you all the pernrs in the orgunit
then ,
select pernr from pa0000 into itab1 for all entries in itab
where pernr = itab-pernr
and stat3 eq 0
and begda eq p_begda and endda eq p_endda.
this will give all the active pernrs in the orgunit.
stat3 value eq 0 gives the active pernr.
How ever if you want to use get pernr ,
then
infotypes : 0000,0001
get pernr
loop at p0001 into wa_pa0001
if wa_p0001-orgeh in s_orgeh.
loop at p0000 into wa_p0000
if wa_p0000-stat3 eq 0.
then do the processing
else
exit.
endif
endif
06-17-2010 2:54 PM
Hi Sumit ,
you can use the FM 'RH_STRUC_GET' for this purpose. It will retrieve all the levels of data.Given below is the Example of Source. ITAB it_result will have all the active positions and persons.
You can delete the data other than person in the ITAB by the delete statement.
Delete it_result where otype <> 'P'.
Finally your objID will be active persons available under the org unit.
CALL FUNCTION 'RH_STRUC_GET'
EXPORTING
act_otype = 'O'
act_objid = " Pass Org_unit ID here
act_wegid = 'O-S-P'
* ACT_INT_FLAG =
* ACT_PLVAR = ' '
ACT_BEGDA = SY-DATUM
ACT_ENDDA = SY-DATUM
ACT_TDEPTH = 20
* ACT_TFLAG = 'X'
* ACT_VFLAG = 'X'
* AUTHORITY_CHECK = 'X'
* TEXT_BUFFER_FILL =
* BUFFER_MODE =
* IMPORTING
* ACT_PLVAR =
TABLES
RESULT_TAB = it_result
* RESULT_OBJEC =
* RESULT_STRUC =
* 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.
06-18-2010 3:51 AM
Solved.
Thanks a lot Prasath!
I was using this FM but was not aware how
"act_wegid = 'O-S-P'" works..
Just another doubt. If I am working at employee level, how can I find out that a specific pernr is (at any level) under a specif org unit?
In my case, how can I find if S4 position is under org unit O or not?
Regards,
Sumit Nene
06-18-2010 4:17 AM
Hi Sumit ,
You can use the same RH_STRUC_GET for this. Pass the input as below. FM's Output table IT_RESULT will have all the Org ID above the pernr to till the root ( Bottom to Top ). Just use read table statement to check whether the particular Org ID is there or now.
READ TABLE IT_RESULT with key otype = 'O' and OBJID = ORG_UNIT_ID
if Sy-subrc is iniial.
" Employee is present under the particular Org unit
Endif.
CALL FUNCTION 'RH_STRUC_GET'
EXPORTING
act_otype = 'P'
act_objid = " Pass the Emp Pernr here
act_wegid = 'P-S-O-O'
* ACT_INT_FLAG =
* ACT_PLVAR = ' '
ACT_BEGDA = SY-DATUM
ACT_ENDDA = SY-DATUM
ACT_TDEPTH = 20
* ACT_TFLAG = 'X'
* ACT_VFLAG = 'X'
* AUTHORITY_CHECK = 'X'
* TEXT_BUFFER_FILL =
* BUFFER_MODE =
* IMPORTING
* ACT_PLVAR =
TABLES
RESULT_TAB = it_result
* RESULT_OBJEC =
* RESULT_STRUC =
* 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.
06-18-2010 6:04 AM
Thanks again Prasath,
But it gives this error to me..
Structure 01 P 00000006 P-S-O-O: No agent found.
Message no. 5W170
Regards,
Sumit Nene.
06-18-2010 6:29 AM
HI Sumit,
It means that Employee number you passed 000006 not available / Active in the system.
PLease pass the Employee No ( Pernr ) which is active and available in the system. it will work.