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

Cumulative Amount Report in HR ABAP

REPORT ZHR_CUM_REPORT NO STANDARD PAGE HEADING
LINE-SIZE 255
LINE-COUNT 65
MESSAGE-ID ZZ.

************************************************************************
* T A B L E S D E C L A R A T I O N *
************************************************************************
TABLES: PERNR, " STUCTURE PERNR DECLARATION
PCL1, " CLUSTER DECLARATION
PCL2. " CLUSTER DECLARATION

************************************************************************
* I N F O T Y P E S D E C L A R A T I O N *
************************************************************************
INFOTYPES: 0001, "INFOTYPE 0001 DECLARATION
0002. "INFOTYPE 0002 DECLARATION

***********************************************************************
* I N C L U D E S T R U C T U R E S *
***********************************************************************
INCLUDE RPC2CD09. "Cluster CD Data-Definition
INCLUDE RPC2CA00. "Cluster CA Data-Definition "XUJP30K079863
INCLUDE RPC2RUU0. "Cluster RU Data-Definition
INCLUDE RPC2RX09. "Cluster RU Data-Definition internat. part
INCLUDE RPPPXD00. "Data Definition buffer PCL1/PCL2
INCLUDE RPPPXD10. "Common part buffer PCL1/PCL2
INCLUDE RPPPXM00. "Buffer handling routine


************************************************************************
* I N T E R N A L T A B L E S D E C L A R A T I O N *
************************************************************************
*....internal table to store final data
DATA: BEGIN OF IT_FINAL OCCURS 0,
PERNR LIKE PA0001-PERNR, "PERSONNEL NUMBER
GBDAT LIKE PA0002-GBDAT, "DATE OF BIRTH
VORNA LIKE PA0002-VORNA, "FIRST NAME
NACHN LIKE PA0002-NACHN, "LAST NAME
BETRG LIKE RT-BETRG, "BASIC PAY
BETRG1 LIKE TCRT-BETRG, "TOTAL GROSS CUMMULATIVE TAX
END OF IT_FINAL.
*....internal table used to get sequence number
DATA: IT_RGDIR LIKE PC261 OCCURS 0 WITH HEADER LINE.

************************************************************************
* D A T A D E C L A R A T I O N *
************************************************************************
DATA: V_PERMO LIKE T549A-PERMO, "VARIABLE TO GET PERIOD PARAMETERS
V_PABRJ LIKE T569V-PABRJ, "VARIABLE TO GET YEAR
V_PABRP LIKE T569V-PABRP, "VARIABLE TO GET PERIOD
V_ENDDA LIKE T549Q-ENDDA, "VARIABLE TO GET END DATE
V_BEGDA LIKE T549Q-BEGDA, "VARIABLE TO GET BEGIN DATE
V_SEQNR LIKE RGDIR-SEQNR, "VARIABLE TO GET SEQUENCE NUMBER
V_ABKRS LIKE PA0001-ABKRS, "PAY ROLL AREA
V_ATEXT LIKE T549T-ATEXT, "PAY ROLL AREA TEXT
V_NAME(35). "VARAIABLE TO STORE EMPLOYEE NAME


************************************************************************
* S T A R T O F S E L E C T I O N *
************************************************************************
START-OF-SELECTION.
*....form to get payroll area text
PERFORM GET_PAYROLLAREATEXT.
*....form to get Period parameter into v_permo from table t549a
PERFORM GETPERMO.
*....from to get begda and endda
PERFORM GETDATES.


***********************************************************************
* G E T P E R N R E V E N T *
***********************************************************************
GET PERNR.
*.....form for getting latest org. info and personal info.
PERFORM GET-DATA.

************************************************************************
* E N D O F S E L E C T I O N *
************************************************************************
END-OF-SELECTION.
*.....form to display data as report
PERFORM DISPLAY-PARA.

************************************************************************
* Form GET_PAYROLLAREATEXT *
************************************************************************
FORM GET_PAYROLLAREATEXT.
V_ABKRS = PNPXABKR.
SELECT SINGLE
ATEXT
INTO V_ATEXT
FROM T549T WHERE ABKRS = V_ABKRS
AND SPRSL = SY-LANGU.
ENDFORM. " GET_PAYROLLAREATEXT

************************************************************************
* Form GETPERMO *
************************************************************************
FORM GETPERMO.
*.....get Period parameter into v_permo from table t549a
SELECT SINGLE PERMO
FROM T549A
INTO V_PERMO
WHERE ABKRS = V_ABKRS.
ENDFORM. " GETPERMO


************************************************************************
* Form GETDATES *
************************************************************************
FORM GETDATES.
*.....Time period indicator: Current period is initial
IF PNPTIMR9 = 'X'.
PERFORM GETDATES1.
*.....Time period indicator: Other period is initial
ELSEIF PNPTIMRA = 'X'.
PERFORM GETDATES2.
ENDIF.
ENDFORM. " GETDATES


************************************************************************
* Form GETDATES1 *
************************************************************************
FORM GETDATES1.
*.....get Payroll year and period from table t569v
SELECT SINGLE PABRJ
PABRP
FROM T569V
INTO (V_PABRJ , V_PABRP)
WHERE ABKRS = V_ABKRS.
*.....get Start Date and End Date from table t549q
SELECT SINGLE ENDDA
BEGDA
FROM T549Q
INTO (V_ENDDA , V_BEGDA)
WHERE PABRJ = V_PABRJ
AND PABRP = V_PABRP
AND PERMO = V_PERMO.
ENDFORM. " GETDATES1

************************************************************************
* Form GETDATES2 *
************************************************************************
FORM GETDATES2.
*.....get Start Date and End Date from table t549q
SELECT SINGLE ENDDA
BEGDA
FROM T549Q
INTO (V_ENDDA , V_BEGDA)
WHERE PABRJ = PNPPABRJ
AND PABRP = PNPPABRP
AND PERMO = V_PERMO.
ENDFORM. " GETDATES2


************************************************************************
* Form GET-DATA *
************************************************************************
FORM GET-DATA.

*.....HR macro to get Latest Personnel Org. Info by Start and End dates
RP-PROVIDE-FROM-LAST P0001 SPACE V_BEGDA
V_ENDDA.
*.....if infotype p0001 succussfully read
IF PNP-SW-FOUND = '1'.
IT_FINAL-PERNR = P0001-PERNR.
*.....HR macro to get Latest personal Info by Start and End dates
RP-PROVIDE-FROM-LAST P0002 SPACE V_BEGDA
V_ENDDA.
*.....if infotype p0002 succussfully read
IF PNP-SW-FOUND = '1'.
IT_FINAL-VORNA = P0002-VORNA.
IT_FINAL-NACHN = P0002-NACHN.
IT_FINAL-GBDAT = P0002-GBDAT.
*.....get data into Resultant table using function module CU_READ_RGDIR
PERFORM READ-RGDIR.
ENDIF.
ENDIF.
ENDFORM. " GET-DATA

************************************************************************
* Form READ-RGDIR *
************************************************************************
FORM READ-RGDIR.
*.....fill it_rgdir Personnel Number
CALL FUNCTION 'CU_READ_RGDIR'
EXPORTING
PERSNR = P0001-PERNR
* BUFFER =
* NO_AUTHORITY_CHECK = ' '
* IMPORTING
* MOLGA =
TABLES
IN_RGDIR = IT_RGDIR
EXCEPTIONS
NO_RECORD_FOUND = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

*.....check whether "Pay date for payroll result" with in Start Date and
* End date, and "Reason for Off-Cycle Payroll" is initial

LOOP AT IT_RGDIR WHERE PAYDT >= V_BEGDA
AND PAYDT <= V_ENDDA and VOID IS INITIAL AND OCRSN IS INITIAL AND SRTZA = 'A'. V_SEQNR = IT_RGDIR-SEQNR.

*.....Move pernr and seqnr to cluster

RX UNPACK P0001-PERNR TO RX-KEY-PERNR.
UNPACK V_SEQNR TO RX-KEY-SEQNO.

*.....Macro for getting US pernrs Info. in cluster

PCL2 RP-IMP-C2-RU.

*.....populate internal table RT where Wage Type is '1000'

LOOP AT RT WHERE LGART = '1000'.
IT_FINAL-BETRG = RT-BETRG.

*.......populate internal table TCRT where Wage Type is '/100'

LOOP AT TCRT WHERE LGART = '/101' AND CTYPE = 'Y'.
IT_FINAL-BETRG1 = TCRT-BETRG.
APPEND IT_FINAL.
ENDLOOP.

ENDLOOP.
CLEAR IT_FINAL.
ENDLOOP.
REFRESH IT_RGDIR.

ENDFORM. " READ-RGDIR

************************************************************************ *
Form DISPLAY-PARA * ************************************************************************
FORM DISPLAY-PARA.

IF IT_FINAL[] IS INITIAL.
MESSAGE I013 WITH 'No data matched selection criteria'.

ELSE.
WRITE:/ SY-ULINE(125).
WRITE:/5 'PAYROLL AREA ' , 30 'PAYROLL TEXT'.
WRITE:/ SY-ULINE(125).
WRITE:/10 V_ABKRS, 35 V_ATEXT.
WRITE:/ SY-ULINE(125).
WRITE:/2 'EMP ID', 10 'FULL NAME', 46 'DATE OF BIRTH', 70 'BASIC PAY', 90'TOTAL GROSS CUMULATED TAX AMOUNT'.

WRITE:/ SY-ULINE(125).

LOOP AT IT_FINAL.
CONCATENATE IT_FINAL-VORNA IT_FINAL-NACHN INTO V_NAME SEPARATED BY ' '.

WRITE: / IT_FINAL-PERNR, V_NAME, IT_FINAL-GBDAT, IT_FINAL-BETRG, IT_FINAL-BETRG1.
CLEAR V_NAME.
CLEAR IT_FINAL.

ENDLOOP.
WRITE:/ SY-ULINE(125).
ENDIF.
ENDFORM. " DISPLAY-PARA


ALSO READ:

No comments:

Post a Comment