| Home • Tips • Tutorials • Forums • Certification Q's • Interview Q's • Jobs • Testimonials • Contact Us | ||
Tips Categories:
Contribute?What's New?
What's Hot? |
Program to get the manager details for a given personnel numberBy Venkateswara Rao Appikonda, Intelligroup Inc *&------------------------------------------------------------------* * Report : YGETSUPERVISOR * * Created By : Venkateswararao Appikonda * * Created On : 07/02/2008 * * Description : This report is to get the supervisor* * (in some cases manager) of employee * * entered on selection screen * *&------------------------------------------------------------------* REPORT ygetsupervisor MESSAGE-ID zmsg. *&---------------------------------------------------------------------*
* database tables used
*&---------------------------------------------------------------------*
TABLES:pa0001, "Infotype 0001 (Org. Assignment)
hrp1001, "Infotype 1001
pa0002. "Infotype 0002 (Personal Data)
*&---------------------------------------------------------------------*
* internal tables declaration
*&---------------------------------------------------------------------*
*----internal tables for holding
DATA: t1001 LIKE p1001 OCCURS 0 WITH HEADER LINE,
t1002 LIKE p1001 OCCURS 0 WITH HEADER LINE,
t1003 LIKE p1001 OCCURS 0 WITH HEADER LINE,
t1004 LIKE p1001 OCCURS 0 WITH HEADER LINE,
t0001 LIKE p0001 OCCURS 0 WITH HEADER LINE,
t0002 TYPE p0002 OCCURS 0 WITH HEADER LINE.
*&---------------------------------------------------------------------*
* variable declaration
*&---------------------------------------------------------------------*
*---0 to capture the id of the object "may be orgunit, position, persion
.
DATA: g_sobid1 LIKE p1001-objid,
g_sobid2 LIKE p1001-objid,
g_sobid3 LIKE p1001-objid,
*--to capture the personnel number
g_pernr LIKE pa0002-pernr.
*&---------------------------------------------------------------------* * selection screen paramters *&---------------------------------------------------------------------* *----enter a valid personnel number PARAMETERS:p_pernr LIKE pa0002-pernr. *&---------------------------------------------------------------------* * start of selection *&---------------------------------------------------------------------* START-OF-SELECTION. *-- Get the Position for entered Personnel number
*----RH_READ_INFTY function module is used for the OM infotypes ..
*starting with HRP
CALL FUNCTION 'RH_READ_INFTY'
EXPORTING
plvar = '01'
otype = 'P'
objid = p_pernr
infty = '1001'
subty = 'B008'
begda = sy-datum
endda = sy-datum
TABLES
innnn = t1001
EXCEPTIONS
all_infty_with_subty = 1
nothing_found = 2
no_objects = 3
wrong_condition = 4
wrong_parameters = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE i000 WITH 'this number is not maintained in hrp1001'.
ENDIF.
*-- Get the latest record reading T1001 with following values SORT t1001 BY begda DESCENDING . READ TABLE t1001 WITH KEY objid = p_pernr "personnel number
otype = 'P' "Person
rsign = 'B' "hirarchy top down
relat = '008' "Holder
sclas = 'S'. "Position
IF NOT t1001[] IS INITIAL. g_sobid1 = t1001-sobid. "ID of Related Object *-- Get Org unit for the position obtained from above
CALL FUNCTION 'RH_READ_INFTY'
EXPORTING
plvar = '01'
otype = 'S'
objid = g_sobid1
infty = '1001'
subty = 'A003'
begda = sy-datum
endda = sy-datum
TABLES
innnn = t1002.
ENDIF.
SORT t1002 BY begda DESCENDING .
READ TABLE t1002 WITH KEY objid = g_sobid1
otype = 'S' "Position
rsign = 'A' "bottom up
relat = '003' "Belongs to
sclas = 'O'. "org unit
IF NOT t1002[] IS INITIAL. g_sobid2 = t1002-sobid.
*-- Get position for the Org unit (Manager)
CALL FUNCTION 'RH_READ_INFTY'
EXPORTING
plvar = '01'
otype = 'O'
objid = g_sobid2
infty = '1001'
subty = 'B012'
begda = sy-datum
endda = sy-datum
TABLES
innnn = t1003.
ENDIF. SORT t1003 BY objid. READ TABLE t1003 WITH KEY objid = g_sobid2
otype = 'O' "org unit
rsign = 'B' "hirarchy top down
relat = '012' "Manages
sclas = 'S'. "Position
IF NOT t1003[] IS INITIAL. g_sobid3 = t1003-sobid.
*-- Get Personnel number for the Manager
CALL FUNCTION 'RH_READ_INFTY'
EXPORTING
plvar = '01'
otype = 'S'
objid = g_sobid3
infty = '1001'
subty = 'A008'
begda = sy-datum
endda = sy-datum
TABLES
innnn = t1004.
ENDIF.
READ TABLE t1004 WITH KEY objid = g_sobid3
otype = 'S' "Position
rsign = 'A' "bottom up
relat = '008' "Holder
sclas = 'P'. "Person
IF NOT t1004[] IS INITIAL.
g_pernr = t1004-sobid+0(8). *--Get name of Manager(Supervisor) CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
pernr = g_pernr
infty = '0002'
TABLES
infty_tab = t0002.
SORT t0002 BY pernr begda. READ TABLE t0002 INDEX 1. IF NOT t0002[] IS INITIAL.
FORMAT COLOR 7 .
SKIP 3.
WRITE:/1(101) sy-uline .
WRITE:/1 sy-vline,
2 'manager personnel number',
30 sy-vline,
31 'manager first name' ,
60 sy-vline,
61 'manager lastname',
101 sy-vline.
FORMAT COLOR OFF.
WRITE:/1(101) sy-uline .
WRITE:/1 sy-vline,
2 t0002-pernr COLOR 4,
30 sy-vline,
31 t0002-vorna COLOR 4,
60 sy-vline,
61 t0002-nachn COLOR 4,
101 sy-vline.
WRITE:/1(101) sy-uline . ENDIF. ENDIF. Output: Test Run 1:
Manager for the personnel number: 1034:
Test Run 2:
Manager for the personnel number: 1265:
|
|
|
Please send us your feedback/suggestions at webmaster@SAPTechnical.COM Home • Contribute • About Us • Privacy • Terms Of Use • Disclaimer • Safe • Companies: Advertise on SAPTechnical.COM | Post Job • Contact Us ©2006-2007 SAPTechnical.COM. All rights reserved. All
product names are trademarks of their respective companies. SAPTechnical.COM
is in no way affiliated with SAP AG. Graphic Design by Round the Bend Wizards |
||