Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Write payroll Program in HR

Former Member
0 Likes
2,044

Hi

I have assigned to write a program, which reads the payroll data on the basis of screen input date. I know we have to incorporate HR cluster PCL1 and PCL2 but I remember there’re some macros as well as we have to includes some of SAP standard includes which store the information about cluster and also have the result table information ( RU ) with different wage types. Can some body mail me the code or step how to start program?

Thanks

Bye

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,187

Look at the sample program: The logical database used for this is PNPCE.

REPORT z_payroll_results MESSAGE-ID hrpbsus NO STANDARD PAGE HEADING

LINE-SIZE 130

LINE-COUNT 65(3) .

TABLES: pernr,pcl1, " HR Cluster

pcl2 . " HR Cluster.

NODES : person, peras.

INFOTYPES: 0006, 0000, 0001, 0002.

***********************************************************************

  • Clusters, Buffers

***********************************************************************

INCLUDE rpc2cd09. " cluster CD DATA-Defenition

INCLUDE rpc2ca00. " cluster CA DATA-Defenition

INCLUDE rpc2ruu0. " cluster RU DATA-Defenition

INCLUDE rpc2rx09. " cluster RU DATA-Defenition internat.part

INCLUDE rpppxd00. " DATA definition buffer PCL1/PCL2

INCLUDE rpppxd10. " common part buffer PCL1/PCL2

INCLUDE rpppxm00. " buffer handling routine

DATA: BEGIN OF i_datatab OCCURS 0,

name(32) TYPE c, " Employee Name

pernr LIKE pernr-pernr, " Employee Number

pay_period(7) TYPE c, " Pay Period

pay_srt_date(10) TYPE c, " PayPeriod Start Date

pay_end_date(10) TYPE c, " PayPeriod End Date

cent_value(2) TYPE p, " Actual Cent value

hours_period(3) TYPE p DECIMALS 2, " Hours Per Period

amount(4) TYPE p DECIMALS 2, " Calculated Amount

END OF i_datatab.

START-OF-SELECTION.

GET person.

GET peras.

  • rp_provide_from_last p0006 '1' pn-begda pn-endda.

rp_provide_from_last p0000 space pn-begda pn-endda.

rp_provide_from_last p0001 space pn-begda pn-endda.

rp_provide_from_last p0002 space pn-begda pn-endda.

CHECK pernr-pernr IN pnppernr. " Checking Employee Number

MOVE p0002-vorna TO i_datatab-name.

MOVE pernr-pernr TO i_datatab-pernr.

PERFORM pay_results.

APPEND i_datatab.

CLEAR i_datatab.

&----


*& Form pay_results

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM pay_results .

DATA: l_tabix TYPE sy-tabix.

  • Reading Payroll Cluster and getting the Payroll results

cd-key-pernr = pernr-pernr.

rp-imp-c2-cu.

IF rp-imp-cd-subrc EQ 0.

  • LOOP AT rgdir where srtza = 'A' and fpend between

  • pn-begda and pn-endda.

SORT rgdir BY srtza seqnr DESCENDING.

LOOP AT rgdir WHERE srtza = 'A'.

l_tabix = l_tabix + 1.

IF l_tabix > 2.

EXIT.

ENDIF.

rx-key-pernr = pernr-pernr.

UNPACK rgdir-seqnr TO rx-key-seqno.

rp-imp-c2-ru.

IF sy-subrc EQ 0.

LOOP AT rt.

ENDLOOP.

ENDIF.

CONCATENATE rgdir-fpper4(2) rgdir-fpper0(4)

INTO i_datatab-pay_period SEPARATED BY space.

MOVE rgdir-fpbeg TO i_datatab-pay_srt_date.

MOVE rgdir-fpend TO i_datatab-pay_end_date.

i_datatab-amount =

( i_datatab-cent_value * i_datatab-hours_period ) / 100.

ENDLOOP.

ENDIF.

ENDFORM. " pay_results

END-OF-SELECTION.

LOOP AT i_datatab.

WRITE:/ i_datatab-name,

i_datatab-pernr,

i_datatab-pay_period,

i_datatab-pay_srt_date,

i_datatab-pay_end_date.

ENDLOOP.

Good luck.

Please close the issue with appropriate points if helpful.

Venu

5 REPLIES 5
Read only

Former Member
0 Likes
1,188

Look at the sample program: The logical database used for this is PNPCE.

REPORT z_payroll_results MESSAGE-ID hrpbsus NO STANDARD PAGE HEADING

LINE-SIZE 130

LINE-COUNT 65(3) .

TABLES: pernr,pcl1, " HR Cluster

pcl2 . " HR Cluster.

NODES : person, peras.

INFOTYPES: 0006, 0000, 0001, 0002.

***********************************************************************

  • Clusters, Buffers

***********************************************************************

INCLUDE rpc2cd09. " cluster CD DATA-Defenition

INCLUDE rpc2ca00. " cluster CA DATA-Defenition

INCLUDE rpc2ruu0. " cluster RU DATA-Defenition

INCLUDE rpc2rx09. " cluster RU DATA-Defenition internat.part

INCLUDE rpppxd00. " DATA definition buffer PCL1/PCL2

INCLUDE rpppxd10. " common part buffer PCL1/PCL2

INCLUDE rpppxm00. " buffer handling routine

DATA: BEGIN OF i_datatab OCCURS 0,

name(32) TYPE c, " Employee Name

pernr LIKE pernr-pernr, " Employee Number

pay_period(7) TYPE c, " Pay Period

pay_srt_date(10) TYPE c, " PayPeriod Start Date

pay_end_date(10) TYPE c, " PayPeriod End Date

cent_value(2) TYPE p, " Actual Cent value

hours_period(3) TYPE p DECIMALS 2, " Hours Per Period

amount(4) TYPE p DECIMALS 2, " Calculated Amount

END OF i_datatab.

START-OF-SELECTION.

GET person.

GET peras.

  • rp_provide_from_last p0006 '1' pn-begda pn-endda.

rp_provide_from_last p0000 space pn-begda pn-endda.

rp_provide_from_last p0001 space pn-begda pn-endda.

rp_provide_from_last p0002 space pn-begda pn-endda.

CHECK pernr-pernr IN pnppernr. " Checking Employee Number

MOVE p0002-vorna TO i_datatab-name.

MOVE pernr-pernr TO i_datatab-pernr.

PERFORM pay_results.

APPEND i_datatab.

CLEAR i_datatab.

&----


*& Form pay_results

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM pay_results .

DATA: l_tabix TYPE sy-tabix.

  • Reading Payroll Cluster and getting the Payroll results

cd-key-pernr = pernr-pernr.

rp-imp-c2-cu.

IF rp-imp-cd-subrc EQ 0.

  • LOOP AT rgdir where srtza = 'A' and fpend between

  • pn-begda and pn-endda.

SORT rgdir BY srtza seqnr DESCENDING.

LOOP AT rgdir WHERE srtza = 'A'.

l_tabix = l_tabix + 1.

IF l_tabix > 2.

EXIT.

ENDIF.

rx-key-pernr = pernr-pernr.

UNPACK rgdir-seqnr TO rx-key-seqno.

rp-imp-c2-ru.

IF sy-subrc EQ 0.

LOOP AT rt.

ENDLOOP.

ENDIF.

CONCATENATE rgdir-fpper4(2) rgdir-fpper0(4)

INTO i_datatab-pay_period SEPARATED BY space.

MOVE rgdir-fpbeg TO i_datatab-pay_srt_date.

MOVE rgdir-fpend TO i_datatab-pay_end_date.

i_datatab-amount =

( i_datatab-cent_value * i_datatab-hours_period ) / 100.

ENDLOOP.

ENDIF.

ENDFORM. " pay_results

END-OF-SELECTION.

LOOP AT i_datatab.

WRITE:/ i_datatab-name,

i_datatab-pernr,

i_datatab-pay_period,

i_datatab-pay_srt_date,

i_datatab-pay_end_date.

ENDLOOP.

Good luck.

Please close the issue with appropriate points if helpful.

Venu

Read only

suresh_datti
Active Contributor
0 Likes
1,187

Hi Suleman,

here is a sample.. this one reads the Co code from WPBP.. but in the RGDIR loop all the internal tables liek RT<CRT<BT<TCRT etc are available for evaluation...


report  zppayresult.
.
data:  t_rgdir          like pc261 occurs 0 with header line.
include: rpcccd09,                      "constants for cluster CD/CU
         rpc2rx00,                      "Definition cluster RX (I)
         rpppxd00,                      "Buffer definition (I)
         rpc2ruu0.                      "US cluster

data: begin of common part buffer.
include: rpppxd10.                      "Buffer definition (II)
data: end  of common part buffer.
tables: pcl1, pcl2.
include rpppxm00.

start-of-selection.
  call function 'CU_READ_RGDIR'
    exporting
      persnr   = '00007519'
    tables
      in_rgdir = t_rgdir.
  if sy-subrc eq 0.
    loop at t_rgdir where seqnr = '00057'.
      rx-key-pernr = '00007519'.
      unpack t_rgdir-seqnr to rx-key-seqno.
*Import data from PCL2
      rp-imp-c2-ru.
      read table wpbp index 1.
      if sy-subrc eq 0.
        write:/ wpbp-bukrs.
      endif.
    endloop.
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

There are other ways too like using the GET PAYROLL event in PNP or standard function calls like HR_GET_PAYROLL_RESULTS etc..

Regards,

Suresh Datti

Read only

0 Likes
1,187

Thanks Guys....!!!!

Bye

Read only

0 Likes
1,187

No problm you're welcome

Read only

Former Member
0 Likes
1,187

Hi,

You have to check program RPCLSTRU and RPCLSTB2 and include the same include as there is in these progs.

to import payroll Macro to use is:

*Standard Payroll Routines and Data Definitions

INCLUDE RPC2CD09.

INCLUDE RPC2RUU0.

INCLUDE RPC2RX09.

INCLUDE RPPPXD00.

INCLUDE RPPPXD10.

INCLUDE RPPPXM00.

Then...

FORM IMPORT_PAYROLL_RESULT.

DATA: MED_AMT LIKE RT-BETRG.

DATA: DAY_AMT LIKE RT-BETRG.

*TRMAC macro to import US Payroll results from PCL2(RU)

RP-IMP-C2-RU.

*check RC

IF RP-IMP-RU-SUBRC = 0.

IF RU-VERSION-NUMBER NE ORU-VERSION-NUMBER.

STOP.

SY-SUBRC = 4.

ELSE.

SY-SUBRC = 0.

ENDIF.

ELSE.

SY-SUBRC = 8.

ENDIF.

CHECK SY-SUBRC = 0.

*get $amount from required wagetype in required result table

DATA: CONT_AMNT(15).

LOOP AT RT.

CASE RT-LGART.

WHEN 'XXXX'.

CONT_AMNT = RT-BETRG.

C_OUTFL-1ST_CONT_AMNT = CONT_AMNT+8(7) + C_OUTFL-1ST_CONT_AMNT.

ENDCASE.

ENDLOOP.

ENDFORM. " IMPORT_PAYROLL_RESULT

This form is used here in the form that reads the different payrolls:

FORM GET_RGDIR_CD.

CD-KEY-PERNR = PERNR-PERNR.

SY-SUBRC = 0.

*call TRMAC macro to retrieve cluster directory

RP-IMP-C2-CU.

*look for actual result

LOOP AT RGDIR WHERE FPBEG LE PN-ENDDA

AND FPEND GE PN-BEGDA

AND SRTZA = 'A'

AND VOID = SPACE.

MOVE PERNR-PERNR TO RX-KEY-PERNR.

UNPACK RGDIR-SEQNR TO RX-KEY-SEQNO.

PERFORM IMPORT_PAYROLL_RESULT.

CLEAR: RX-KEY-PERNR,

RX-KEY-SEQNO.

ENDLOOP.

ENDFORM. " GET_RGDIR_CD

RP-IMP-C2-RU to import the payroll of the cluster RU BUT Pay attention !!! RGDIR contains