Google Search - Blog...........

HR ABAP - Get The Manager Of The Employee

*&---------------------------------------------------------------------*
*& Report ZSUP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZSUP.
TABLES:PA0001,
HRP1001,
PA0002.

DATA: T1001 LIKE P1001 OCCURS 0 WITH HEADER LINE.
DATA: T1002 LIKE P1001 OCCURS 0 WITH HEADER LINE.
DATA: T1003 LIKE P1001 OCCURS 0 WITH HEADER LINE.
DATA: T1004 LIKE P1001 OCCURS 0 WITH HEADER LINE.
DATA: T0001 LIKE P0001 OCCURS 0 WITH HEADER LINE.
DATA: IT_PA0002 TYPE PA0002 OCCURS 0 WITH HEADER LINE.

DATA: V_SOBID1 LIKE P1001-OBJID.
DATA: V_SOBID2 LIKE P1001-OBJID.
DATA: V_SOBID3 LIKE P1001-OBJID.

DATA:V_PERNR LIKE PA0002-PERNR.

PARAMETERS:P_PERNR LIKE PA0001-PERNR.

START-OF-SELECTION.

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.

SORT T1001 BY BEGDA DESCENDING .

READ TABLE T1001 WITH KEY OBJID = P_PERNR
OTYPE = 'P'
RSIGN = 'B'
RELAT = '008'
SCLAS = 'S'.

IF SY-SUBRC = 0.

V_SOBID1 = T1001-SOBID.

CALL FUNCTION 'RH_READ_INFTY'
EXPORTING
PLVAR = '01'
OTYPE = 'S'
OBJID = V_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 = V_SOBID1
OTYPE = 'S'
RSIGN = 'A'
RELAT = '003'
SCLAS = 'O'.

IF SY-SUBRC = 0.

V_SOBID2 = T1002-SOBID.

CALL FUNCTION 'RH_READ_INFTY'
EXPORTING
PLVAR = '01'
OTYPE = 'O'
OBJID = V_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 = V_SOBID2
OTYPE = 'O'
RSIGN = 'B'
RELAT = '012'
SCLAS = 'S'.

IF SY-SUBRC = 0.

V_SOBID3 = T1003-SOBID.

CALL FUNCTION 'RH_READ_INFTY'
EXPORTING
PLVAR = '01'
OTYPE = 'S'
OBJID = V_SOBID3
INFTY = '1001'
SUBTY = 'A008'
BEGDA = SY-DATUM
ENDDA = SY-DATUM
TABLES
INNNN = T1004.

ENDIF.

READ TABLE T1004 WITH KEY OBJID = V_SOBID3
OTYPE = 'S'
RSIGN = 'A'
RELAT = '008'
SCLAS = 'P'.
IF SY-SUBRC = 0.

V_PERNR = T1004-SOBID+0(8).

SELECT PERNR
VORNA
NACHN
CNAME
FROM PA0002
INTO CORRESPONDING FIELDS OF TABLE IT_PA0002
WHERE PERNR = V_PERNR.

SORT IT_PA0002 BY PERNR BEGDA.

READ TABLE IT_PA0002 INDEX 1.

IF SY-SUBRC EQ 0.
WRITE:/ IT_PA0002-PERNR,
IT_PA0002-VORNA,
IT_PA0002-NACHN,
IT_PA0002-CNAME.
ENDIF.
ENDIF.


ALSO READ:

- Creating An HR Infotype Step By Step.

- Creating HR Report Category In PNP Logical Database.

- Fetching The Entry Or Joining Date For Employees.

- Fetching HR Data In Different Ways.

- Get Managers List For All The Organization Units.

.....Back To Sub-Index On HR ABAP.

.....Back To MAIN INDEX.


No comments:

Post a Comment