Payroll results (ABAP)

ABAP code to demonstrate how to retrieve payroll results which are usually accessed via SAP transaction PC_PAYRESULT.

You will also need to assign a logical database to your program which is done via the menu option Goto->Attributes

*......................................................
*: Report:  ZPAYROLL_RESULTS                          :
*:                                                    :
*: Author:  www.SAPdev.co.uk                          :
*:                                                    :
*: Demonstrate retrieving payroll results data, please:
*: note program does not produce any meaningful output:
*  is simply a demonstration of how to access the data:
*:....................................................:
REPORT  ZPAYROLL_RESULTS.
NODES: pernr.
INFOTYPES: 0000, 0001, 2001.
TABLES: t554s, pcl1, pcl2.
INCLUDE rpclst00.
INCLUDE rpc2rx09.                      "Payroll results datadefns-Intl.
INCLUDE rpc2rxx0.                      "Payroll results datadefns-Intl.
INCLUDE rpc2rgg0.                      "Payroll results datadefns-GB
INCLUDE rpcfdcg0.                      "Payroll results datadefns-GB
INCLUDE rpcdatg0.
INCLUDE rpc2cd00.                      "Cluster Directory defns.
INCLUDE rpc2ps00.                      "Cluster: Generierte Schematas
INCLUDE rpc2pt00.
INCLUDE rpcfdc10.
INCLUDE rpcfdc00.
INCLUDE rpppxd00.
INCLUDE rpppxd10.
INCLUDE rpcfvp09.
INCLUDE rpcfvpg0.
INCLUDE rpppxm00.
TYPES: BEGIN OF t_salrate,
    seqnr    TYPE pc261-seqnr,
    begda    TYPE p2001-begda,
    endda    TYPE p2001-endda,
    split(2) TYPE c,
    val      TYPE p DECIMALS 2,
   END OF t_salrate.
DATA: it_salrate TYPE STANDARD TABLE OF t_salrate INITIAL SIZE 0,
      wa_salrate TYPE t_salrate.
*Selection screen
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: so_awart FOR p2001-awart.
SELECTION-SCREEN END OF BLOCK block1.
************************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
GET pernr.
* get payroll results data
  rp-init-buffer.
  CLEAR rgdir. REFRESH rgdir.
  CLEAR rt. REFRESH rt.
  CLEAR: rx-key.
* set key to current pernr
  MOVE pernr-pernr(8) TO cd-key-pernr.
* retrieves payroll results for specific pernr(personnel number)
  rp-imp-c2-cd.
  IF rp-imp-cd-subrc = 0.                                "rgdir success
    rx-key-pernr = pernr-pernr.
    SORT rgdir BY seqnr ASCENDING.
    CLEAR rgdir.
  ENDIF.
  SORT rgdir BY fpbeg fpend ASCENDING seqnr DESCENDING.
* RGDIR the table where all payroll results periods are stored
  LOOP AT rgdir WHERE  abkrs IN pnpabkrs        "pay area
                  AND  srtza EQ 'A'
                  AND  void  NE 'V'.
    IF sy-subrc NE 0.
*     set key to specific payroll results period(current RGDIR loop pass)
      UNPACK rgdir-seqnr   TO   rx-key-seqno.
*     Retrieves data for specific payroll results period (current RGDIR
*     loop pass)
      rp-imp-c2-rg.
*     Loop at wpbp data for specific payroll results period
      LOOP AT wpbp.
        wa_salrate-seqnr = rgdir-seqnr.
        wa_salrate-begda = wpbp-begda.
        wa_salrate-endda = wpbp-endda.
        wa_salrate-split = wpbp-apznr.
*       loop at rt data for specific payroll results period
        LOOP AT rt WHERE lgart EQ '/010' AND             "wage type
                         apznr EQ wpbp-apznr.            "payroll split
          wa_salrate-val = ( rt-betpe * ( wpbp-adivi / wpbp-kdivi ) ).
          APPEND wa_salrate TO it_salrate.
        ENDLOOP.
      ENDLOOP.
*     Process BT table
      LOOP AT BT.
      ENDLOOP.
*     Process NIPAY table
      LOOP AT NIPAY.
      ENDLOOP.
*     etc................
    ENDIF.
  ENDLOOP.
************************************************************************
*END-OF-SELECTION.
END-OF-SELECTION.

Related Articles

Payroll results (ABAP)
Display organisational structure
SAP HR infotypes
GET PERNR LAST and GET PAYROL
Retrieve multiple contracts for HR personnel and include in locical database selection/report
SAP HR Development help - ABAP code and information on various areas of HR development in SAP
ABAP code to retrieve Absence type text(AWART) from SAP table
ABAP to retrieve country grouping for personnel with SAP
Deleting an SAP HR Infotype
SAP HR Infotype selection
Creating a New SAP Infotype using transaction PM01 and PPCI
Retrieve comment texts from cluster table for SAP infotype 19
SAP Function module to call ABAP report from managers desktop(MDT)
SAP User Exits to Add functionality to the PBO and PAI of HR infotypes
Create SAP HR report category for logical database selection within ABAP report
SAP HR Selection Screen example
Retrieve SAP personal work schedule
SAP HR Infotype Development Information, ABP and step by step instructions
Enhancing an Infotype - Add, change or modify fields of and SAP infotype
SAP Personal absence calander for SSP/SMP
ABAP Program to retrieve and display sickpay(SSP, SMP etc) with SAP
SAP Personal absence calendar (NCALE) using transaction PC00_M08_CLPC
Accessing NCALE data via the Results Log when running a payroll
Program to retrieve sickpay values
Processing the SAP HR Organisation unit
SAP HR Payroll results ( transaction code: PC_PAYRESULT)
Display Payroll results using SAP transaction PC_PAYRESULT