on 06-14-2007 10:00 AM
Hi all,
I want to create an abap program where i have the personal number of a person. Now i want to find the org unit of that person, which I will find from PA0001. Now i want to get the position of the manager or the head of that org unit and from that position I want to get the holder of that position ( pernr) and ultimately the name of that person.
Can anyone help me with the CODING of the above problem?
Can anyone provide me a sample code for it.
Thanks
Ribhu
Refer this Function Module, it wil give u the immediate manager name of a employee number, u can call this in a ABAPProgram after creating it or u can copy this code and paste it in a ABAP program.
FUNCTION ZGILL_APPROVER.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(PERNR) TYPE PERSNO
*" EXPORTING
*" REFERENCE(NAME) TYPE PAD_CNAME
*" EXCEPTIONS
*" NO_DATA
*"----------------------------------------------------------------------
DATA: ls_sobid1 TYPE sobid,
ls_sobid2 TYPE sobid,
ls_sobid3 TYPE sobid,
vorna type PAD_VORNA,
nachn type PAD_NACHN.
SELECT SINGLE sobid FROM hrp1001 INTO ls_sobid1
WHERE otype = 'P'
and plvar = '01'
AND objid = pernr
AND endda >= sy-datum
AND begda <= sy-datum
AND rsign = 'B'
AND relat = '008'.
IF sy-subrc EQ 0.
SELECT SINGLE sobid FROM hrp1001 INTO ls_sobid2
WHERE otype = 'S'
and plvar = '01'
AND objid = ls_sobid1
AND endda >= sy-datum
AND begda <= sy-datum
AND rsign = 'A'
AND relat = '002'.
IF sy-subrc EQ 0.
SELECT SINGLE sobid FROM hrp1001 INTO ls_sobid3
WHERE otype = 'S'
and plvar = '01'
AND objid = ls_sobid2
AND endda >= sy-datum
AND begda <= sy-datum
AND rsign = 'A'
AND relat = '008'.
IF sy-subrc EQ 0.
SELECT SINGLE vorna nachn from pa0002 INTO (vorna , nachn)
WHERE pernr = ls_sobid3
AND endda >= sy-datum
AND begda <= sy-datum.
IF sy-subrc EQ 0.
Concatenate vorna nachn into name separated by SPACE.
condense name.
else.
Raise NO_DATA.
endif.
else.
Raise NO_DATA.
endif.
else.
Raise NO_DATA.
endif.
else.
RAISE no_data.
endif.
ENDFUNCTION.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
102 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.