Payroll Analysis For a Given Personnel Number

Program to read and display payroll analysis for a given Personnel Number and for a specified period. 

* =======================================================
* Stefanos Moschidis - SAP Certified Technical Consultant 
* =======================================================

*======================================================
* PROGRAM TO READ PAYROLL ANALYSIS FOR A PERSON, IN A 
* PAYROLL PERIOD
* =====================================================
REPORT Z_READ_CLUSTER_RT_PAYROLL .

* ======================================================
* Payroll directory
* ======================================================
DATA: BEGIN OF RGDIR OCCURS 100.
        INCLUDE STRUCTURE PC261.
DATA: END OF RGDIR.

* ======================================================
* PAYROLL RESULT
* ======================================================
DATA : ref_payresult TYPE pay99_result .
DATA : ls_rt TYPE pc207 .
DATA : ls_wpbp LIKE PC205 .

* ======================================================
* WORDINGS OF PAYROLL ELEMENTS
* ======================================================
DATA : BEGIN OF I_T512T OCCURS 1000 .
        INCLUDE STRUCTURE T512T .
DATA : END OF I_T512T .

* ======================================================
* SELECTION SCREEN ( DEFAULT )
* ======================================================
PARAMETERS : P_PERNR LIKE PA0002-PERNR DEFAULT '10000004' obligatory .
PARAMETERS : P_BEGDA LIKE PA0002-BEGDA DEFAULT '20030101' obligatory .
PARAMETERS : P_ENDDA LIKE PA0002-ENDDA DEFAULT '20030131' obligatory .

* ======================================================
* INITIALIZATION
* ======================================================
INITIALIZATION . 
SELECT * FROM T512T INTO TABLE I_T512T
         WHERE SPRSL = SY-LANGU
         AND   MOLGA = '99' .

* =====================================================
* START OF SELECTION
* =====================================================
START-OF-SELECTION . 

CALL FUNCTION 'CU_READ_RGDIR'
  EXPORTING
    PERSNR                   = P_PERNR
*   BUFFER                   =
*   NO_AUTHORITY_CHECK       = ' '
* IMPORTING
*   MOLGA                    =
  TABLES
    IN_RGDIR                 = RGDIR
 EXCEPTIONS
   NO_RECORD_FOUND          = 1
   OTHERS                   = 2 .

IF SY-SUBRC <> 0.
  MESSAGE I398(00) WITH 'ERROR READING PAYROLL DATA' .
  EXIT  .
ENDIF.


LOOP AT RGDIR .

  CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
    EXPORTING
      CLUSTERID                          = 'RX'
      EMPLOYEENUMBER                     = P_PERNR
      SEQUENCENUMBER                     = RGDIR-SEQNR
*   READ_ONLY_BUFFER                   = ' '
*   READ_ONLY_INTERNATIONAL            = ' '
*   CHECK_READ_AUTHORITY               = 'X'
*   FILTER_CUMULATIONS                 = 'X'
*   CLIENT                             =
* IMPORTING
*   VERSION_NUMBER_PAYVN               =
*   VERSION_NUMBER_PCL2                =
    CHANGING
      PAYROLL_RESULT                     = ref_payresult
   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
     OTHERS                             = 8 .

  IF SY-SUBRC =  0.

    READ TABLE ref_payresult-inter-wpbp INTO  ls_wpbp
                                    INDEX 1.
    CHECK ls_wpbp-begda EQ P_BEGDA .
    CHECK ls_wpbp-ENDda EQ P_ENDDA .

    WRITE :  / 'Personnel Number :' COLOR COL_HEADING ,
             P_Pernr COLOR COL_HEADING ,
            'Start of Payroll Period' COLOR COL_HEADING ,
             ls_wpbp-begda  COLOR COL_HEADING ,
            'End of Payroll Period' COLOR COL_HEADING ,
             ls_wpbp-endda  COLOR COL_HEADING .

    LOOP AT ref_payresult-inter-rt INTO  ls_rt .
      CLEAR I_T512T .
      READ TABLE I_T512T WITH KEY LGART = ls_rt-lgart .
      WRITE : / ls_rt-lgart ,
                I_T512T-LGTXT ,
                ls_rt-betrg ,
                ls_rt-amt_curr .
    ENDLOOP.

  ENDIF.

ENDLOOP .

Related:

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

Smart Forms
SAP Smartforms

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.