Monday, 26 March 2012

Reading Arrears using Retroactive Payroll Processing in HR ABAP

REPORT  ZHR_D207_AS10_ARREARS11.

TABLES PERNR.

DATA  MOLGA TYPE MOLGA.
DATA IT_RGDIR TYPE PC261 OCCURS 0 WITH HEADER LINE.

DATA  SEQNR TYPE PC261-SEQNR.

DATA  IT_PAYRESULT TYPE PAYIN_RESULT OCCURS 0 WITH HEADER LINE.
DATA  WA_CRT TYPE PC208.
DATA WA_RT TYPE PC207.

DATA: BEGIN OF ITAB OCCURS 0,
      PERNR TYPE PERNR-PERNR,
      GROSS TYPE PC208-BETRG,
      NETPAY TYPE PC207-BETRG,
      TAX TYPE PC207-BETRG,
      END OF ITAB.

DATA IT_RT TYPE PC207 OCCURS 0 WITH HEADER LINE.

DATA:  BETRG(15) TYPE P DECIMALS 2,
       X(15) TYPE P DECIMALS 2,
       Y(15) TYPE P DECIMALS 2.

GET PERNR.

  CALL FUNCTION 'HR_COUNTRYGROUPING_GET'
   EXPORTING
     PERNR           = PERNR-PERNR
*   TCLAS           = 'A'
     BEGDA           = PN-BEGDA
     ENDDA           = PN-ENDDA
*   WERKS           =
   IMPORTING
     MOLGA           = MOLGA.


  CALL FUNCTION 'CU_READ_RGDIR'
    EXPORTING
      PERSNR                   = PERNR-PERNR
*   BUFFER                   =
*   NO_AUTHORITY_CHECK       = ' '
   IMPORTING
     MOLGA                    = MOLGA
    TABLES
      IN_RGDIR                 = IT_RGDIR.


  LOOP AT IT_RGDIR WHERE FPPER = PN-PAPER.

    IF IT_RGDIR-SRTZA EQ 'P' OR IT_RGDIR-SRTZA EQ 'A'.

      CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
        EXPORTING
      *   CLUSTERID                          =
          EMPLOYEENUMBER                     = PERNR-PERNR
          SEQUENCENUMBER                     = IT_RGDIR-SEQNR

        CHANGING
          PAYROLL_RESULT                     = IT_PAYRESULT


      LOOP AT IT_PAYRESULT-INTER-RT INTO WA_RT.

********IF WA_RT-LGART = 'MB10' OR WA_RT-LGART = 'M200'.*********

          IF IT_RGDIR-SRTZA EQ 'P'.
            WA_RT-BETRG = 0 - WA_RT-BETRG.
          ENDIF.

          COLLECT WA_RT INTO IT_RT.

          CLEAR WA_RT.
************ENDIF.*******************
      ENDLOOP.

    ENDIF.

  ENDLOOP.

  LOOP AT IT_RT INTO WA_RT.

    WRITE:/ PERNR-PERNR,WA_RT-LGART,WA_RT-BETRG.

  ENDLOOP.