Friday, 23 March 2012

Retro Active Payroll Processing

REPORT  ZCLASS_H16.

TABLES PERNR.

DATA ITAB LIKE PC261 OCCURS 0 WITH HEADER LINE.

DATA IT_RESULT TYPE PAYIN_RESULT.

DATA WA_RT TYPE PC207.

START-OF-SELECTION.

GET PERNR.
  CALL FUNCTION 'CU_READ_RGDIR'
    EXPORTING
      PERSNR                   = PERNR-PERNR
*   BUFFER                   =
*   NO_AUTHORITY_CHECK       = ' '
* IMPORTING
*   MOLGA                    =
    TABLES
      IN_RGDIR                 = ITAB
* 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.

LOOP AT ITAB WHERE FPPER = PN-PAPER.

    CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
      EXPORTING
*     CLUSTERID                          =
        EMPLOYEENUMBER                     = PERNR-PERNR
        SEQUENCENUMBER                     = ITAB-SEQNR
*     READ_ONLY_BUFFER                   = ' '
*     READ_ONLY_INTERNATIONAL            = ' '
*     ARC_GROUP                          = ' '
*     CHECK_READ_AUTHORITY               = 'X'
*     FILTER_CUMULATIONS                 = 'X'
*     CLIENT                             =
*   IMPORTING
*     VERSION_NUMBER_PAYVN               =
*     VERSION_NUMBER_PCL2                =
      CHANGING
        PAYROLL_RESULT                     = IT_RESULT
*   EXCEPTIONS
*     ILLEGAL_ISOCODE_OR_CLUSTERID       = 1
*     ERROR_GENERATING_IMPORT            = 2
*     IMPORT_MISMATCH_ERROR              = 3
*     SUBPOOL_DIR_FULL                   = 4
*     NO_READ_AUTHORITY                  = 5
*     NO_RECORD_FOUND                    = 6
*     VERSIONS_DO_NOT_MATCH              = 7
*     ERROR_READING_ARCHIVE              = 8
*     ERROR_READING_RELID                = 9
*     OTHERS                             = 10
              .
    IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    LOOP AT IT_RESULT-INTER-RT INTO WA_RT WHERE  LGART = '/ZBS'.
      WRITE:/ PERNR-PERNR, PERNR-ENAME, WA_RT-LGART, WA_RT-BETRG, ITAB-SRTZA.

    ENDLOOP.

  ENDLOOP.