Registration

Dear SCN Member,
In order to fully benefit from what SCN has to offer, please register at:
http://scn.sap.com/login.jspa
Thank you,
The SCN team
We are improving!
The SCN wiki will not be available for new content submission starting September 11th 6PM CET until September 14th 6PM CET. Please plan your SCN wiki tasks accordingly.
Skip to end of metadata
Go to start of metadata

Extracting HCM Payroll area information using class - CL_HR_PAYROLL_AREA.

Link to Content's target Space :

http://wiki.sdn.sap.com/wiki/display/ABAP/ABAP+Development+and+Programming.

Applies to:

Developed in ECC 6.0 Ehp4, NW 7.01.

Summary

How to use the global class CL_HR_PAYROLL_AREA to extract payroll area and related information.

Author(s):  Vinod Kumar T

   
Company:     NIIT Technologies Limited
Created on:    04.07.2011
Author(s) Bio
Vinod Kumar is an ABAP consultant working with NIIT Technologies Limited.

Table of Contents

Class and Methods Used

Class

Method

Description

CL_HR_PAYROLL_AREA

GET_INSTANCE

Delivers the Instance for a Payroll Area

CL_HR_PAYROLL_AREA

DETERMINE_EARLIEST_BEGDA_ENDDA

Determines strt/ end date of 1st retr.accnting period

CL_HR_PAYROLL_AREA

DETERMINE_EARLIEST_RETRO_DATE

Earliest retroactive accounting date of payroll control rec.

CL_HR_PAYROLL_AREA

GET_EARLIEST_RETRO_PERIOD

Determines Earliest PY Per. for Which RA Can Be Run

CL_HR_PAYROLL_AREA

DETERMINE_LAST_DAY_OF_CALC

Determines the last day of the payroll run of the pyrll area

CL_HR_PAYROLL_AREA

DETERMINE_PERIODE_BEGDA_ENDDA

Determines strt/end date for period of payroll area keydate

CL_HR_PAYROLL_AREA

GET_PERIODE_WITH_DATE

Determine period for a key date

CL_HR_PAYROLL_AREA

GET_INFO_OF_ACTUAL_PERIODE

Information on a Payroll period based on default attribute value

CL_HR_PAYROLL_AREA

GET_PERIOD_INFO

Information on a Period

CL_HR_PAYROLL_AREA

GET_NEXT_PERIOD

Next payroll period information

CX_HRPY_PAYROLL_AREA

GET_TEXT

Exception short text

Input Screen

Sample Code

 *&---------------------------------------------------------------------*
 *& Report  ZVK_HR_AREA
 *&---------------------------------------------------------------------*
 *& Use of class CL_HR_PAYROLL_AREA to extract payroll area related info
 *&---------------------------------------------------------------------*

 * Text Elements
 * 1) p_area - Payroll Area

 REPORT  zvk_hr_area.
 TABLES : t549a.

 DATA : zcl_hr_payroll_area   TYPE REF TO cl_hr_payroll_area,
        zcx_hrpy_payroll_area TYPE REF TO cx_hrpy_payroll_area.

 DATA : ls_t549n              TYPE t549n,
        ls_ret_period         TYPE pc2paper.

 DATA : lv_result             TYPE string,
        lv_begda              TYPE begda,
        lv_endda              TYPE endda,
        lv_retro_dt           TYPE datum,
        lv_vabrj              TYPE vabrj,
        lv_vabrp              TYPE vabrp.

 SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
 PARAMETERS : p_area TYPE t549a-abkrs.
 PARAMETERS : p_date TYPE sy-datum.
 SELECTION-SCREEN END OF BLOCK b1.

 START-OF-SELECTION.
 ********************************************************************
 ** Get instance of class CL_HR_PAYROLL_AREA **
 ********************************************************************
   TRY.
       zcl_hr_payroll_area = cl_hr_payroll_area=>get_instance( imp_area = p_area ).

       WRITE :/ 'Current Payroll Year      : ' , zcl_hr_payroll_area->pabrj.
       WRITE :/ 'Current Payroll Month     : ' , zcl_hr_payroll_area->pabrp.

 ** Display Payroll Period type **

       CLEAR : ls_t549n.
       SELECT SINGLE * FROM t549n INTO ls_t549n
         WHERE spras = sy-langu
         AND   permo = zcl_hr_payroll_area->permo.
       IF sy-subrc EQ 0.
         WRITE:/ 'Payroll Period Type       : ', ls_t549n-atext.
       ENDIF.
       WRITE :/.
 ********************************************************************
 ** Determine First Payroll period for Area **
 ********************************************************************
       CLEAR : lv_begda, lv_endda.

       zcl_hr_payroll_area->determine_earliest_begda_endda(
         IMPORTING
           exp_begda = lv_begda
           exp_endda = lv_endda ).

       WRITE :/ 'Start/End date of First Payroll Period' COLOR 1.
       WRITE :/ 'Start Date                : ' , lv_begda.
       WRITE :/ 'End   Date                : ' , lv_endda.
       WRITE :/.
 ********************************************************************
 ** Determine Earliest Retro-active accounting date of payroll run **
 ********************************************************************
       CLEAR : lv_retro_dt.

       lv_retro_dt = zcl_hr_payroll_area->determine_earliest_retro_date( ).

       WRITE :/ 'Earliest Retro A/C Date   : ' COLOR 1.
       WRITE :  lv_retro_dt.
 ********************************************************************
 ** Determine Earliest Retro-active Payroll Period **
 ********************************************************************
       CLEAR : ls_ret_period.
       ls_ret_period = zcl_hr_payroll_area->get_earliest_retro_period( ).

       WRITE :/ 'Earliest Retro Period     : ' COLOR 1 , ls_ret_period-pabrj,
                                                 ls_ret_period-pabrp.
       WRITE :/.
 ********************************************************************
 ** Determine Last day of Payroll run **
 ********************************************************************
       CLEAR : lv_endda.

       lv_endda = zcl_hr_payroll_area->determine_last_day_of_calc( ).

       WRITE :/ 'Last day of Payroll Run   : ' COLOR 1.
       WRITE :  lv_endda.
       WRITE :/.
 ********************************************************************
 ** Determine Payroll Period range based on Key Date **
 ********************************************************************
       CLEAR : lv_begda, lv_endda.
       zcl_hr_payroll_area->determine_periode_begda_endda(
         EXPORTING
           imp_date  = p_date
         IMPORTING
           exp_begda = lv_begda
           exp_endda = lv_endda ).

       WRITE :/ 'Payroll Period Date Based for Key Date - ' COLOR 1, p_date COLOR 1.
       WRITE :/ 'Start Date                : ' , lv_begda.
       WRITE :/ 'End   Date                : ' , lv_endda.
       WRITE :/.

 ********************************************************************
 ** Determine Information about payroll period for key date**
 ********************************************************************
       CLEAR : ls_ret_period.

       ls_ret_period = zcl_hr_payroll_area->get_periode_with_date(
                                              imp_date   = p_date ).

       WRITE :/ 'Payroll Period Based for Key Date - ' COLOR 1, p_date COLOR 1.
       WRITE :/ 'Payroll Period            : ' , ls_ret_period-pabrj,
                                                 ls_ret_period-pabrp.
       WRITE :/ .
 ********************************************************************
 ** Determine Information about current payroll period **
 ** Current Period has been used for example **
 ** To extract for another period change the values of instance attributes
 ** 1) zcl_hr_payroll_area->pabrj  - Payroll year
 ** 2) zcl_hr_payroll_area->pabrp  - Payroll period(month)
 **    OR
 ** Method zcl_hr_payroll_area->get_period_info can be used.
 ********************************************************************
       CLEAR : lv_begda, lv_endda, lv_vabrj, lv_vabrp.

       CALL METHOD zcl_hr_payroll_area->get_info_of_actual_periode(
         IMPORTING
           exp_vabrj = lv_vabrj
           exp_vabrp = lv_vabrp
           exp_begda = lv_begda
           exp_endda = lv_endda ).

       WRITE :/ 'Payroll Period Info for ' COLOR 1,
                zcl_hr_payroll_area->pabrj COLOR 1,
                zcl_hr_payroll_area->pabrp COLOR 1.

       WRITE :/ 'Start of Period           : ' , lv_begda.
       WRITE :/ 'End of Period             : ' , lv_endda.
       WRITE :/ 'Previous Payroll period   : ' , lv_vabrj, lv_vabrp.
       WRITE :/.
 ********************************************************************
 ** Determine Information about Next payroll period **
 ** Current Period has been used for example **
 ********************************************************************
       CLEAR : lv_begda, lv_endda, lv_vabrj, lv_vabrp.

       zcl_hr_payroll_area->get_next_period(
         EXPORTING
           imp_pabrj = zcl_hr_payroll_area->pabrj
           imp_pabrp = zcl_hr_payroll_area->pabrp
         IMPORTING
           exp_pabrj = lv_vabrj
           exp_pabrp = lv_vabrp
           exp_begda = lv_begda
           exp_endda = lv_endda ).

       WRITE :/ 'Next Payroll Period Info for ' COLOR 1,
                zcl_hr_payroll_area->pabrj COLOR 1,
                zcl_hr_payroll_area->pabrp COLOR 1.

       WRITE :/ 'Next Payroll period       : ' , lv_vabrj, lv_vabrp.
       WRITE :/ 'Start of Period           : ' , lv_begda.
       WRITE :/ 'End of Period             : ' , lv_endda.
       WRITE :/.


     CATCH cx_hrpy_payroll_area INTO zcx_hrpy_payroll_area.
       lv_result = zcx_hrpy_payroll_area->get_text( ).
       WRITE :/ lv_result.
   ENDTRY.


Output Screen

Useful Information

CL_HR_PAYROLL_AREA for Payroll area & period information