Search This Blog

Search This Blog

Regular Payroll Processing In ABAP HR


* Example Program On Payroll in HR-ABAP *
REPORT  ZR_H113_PAYROLL LINE-SIZE 200.

TABLES PERNR.

INFOTYPES: 0000,0008.

DATA ITAB TYPE PC261 OCCURS 0 WITH HEADER LINE.
DATA G_SEQNR LIKE  PC261-SEQNR.

DATA IT_RESULTS TYPE PAYIN_RESULT.
DATA WA_RT TYPE PC207.
DATA WA_BT TYPE PC209.

DATA: VAR1 TYPE T512T-LGTXT.

DATA: BEGIN OF IT_T549T OCCURS 0,
       ABKRS TYPE T549T-ABKRS,
       ATEXT TYPE T549T-ATEXT,
      END OF IT_T549T.

DATA: BEGIN OF IT_T512T OCCURS 0,
       LGART TYPE T512T-LGART,
       LGTXT TYPE T512T-LGTXT,
      END OF IT_T512T.

DATA: BEGIN OF ITAB1 OCCURS 0,
       LGTXT TYPE T512T-LGTXT,
      END OF ITAB1.

START-OF-SELECTION.

SELECT ABKRS
       ATEXT FROM T549T INTO TABLE IT_T549T
               WHERE SPRSL = SY-LANGU.

SELECT LGART
       LGTXT FROM T512T INTO TABLE IT_T512T
               WHERE SPRSL = SY-LANGU.

 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.

  CALL FUNCTION 'CD_READ_LAST'
    EXPORTING
      BEGIN_DATE            = PN-BEGDA
      END_DATE              = PN-ENDDA
   IMPORTING
     OUT_SEQNR             = G_SEQNR
    TABLES
      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.

  CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
    EXPORTING
*     CLUSTERID                          =
      EMPLOYEENUMBER                     = PERNR-PERNR
      SEQUENCENUMBER                     = G_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_RESULTS
*   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 P0000.
   READ TABLE IT_T549T WITH KEY ABKRS = PERNR-ABKRS.
    WRITE:/ PERNR-PERNR, PERNR-ENAME,P0000-BEGDA,IT_T549T-ABKRS,IT_T549T-ATEXT.
  ENDLOOP.

LOOP AT IT_T512T WHERE LGART ='/460'.
 MOVE IT_T512T-LGTXT TO ITAB1-LGTXT.
 APPEND ITAB1.
ENDLOOP.

READ TABLE ITAB1 INDEX 11.
MOVE ITAB1-LGTXT TO VAR1.

LOOP AT IT_RESULTS-INTER-RT INTO WA_RT.
 READ TABLE IT_T512T WITH KEY LGART = WA_RT-LGART.
  IF WA_RT-LGART = '/101'.
   WRITE:/ WA_RT-LGART,IT_T512T-LGTXT,WA_RT-BETRG.
 ELSEIF WA_RT-LGART = '/460'.
   WRITE:/ WA_RT-LGART,VAR1,WA_RT-BETRG.
 ENDIF.
ENDLOOP.

LOOP AT IT_RESULTS-INTER-BT INTO WA_BT.
  READ TABLE IT_T512T WITH KEY LGART = '/559'.
   WRITE:/ WA_BT-BANKL,WA_BT-BANKN,WA_BT-LGART,IT_T512T-LGTXT,WA_BT-BETRG.
ENDLOOP.