Friday, June 19, 2015

How can I get Payroll results when I run the Payroll in Simulation mode

SAP - How can I get Payroll results when I run the Payroll in Simulation mode

Follow this link ->  http://scn.sap.com/thread/1830478 but it's for Canada Payroll

i'v modified for indonesia payroll below.

1. Include in main program





*&---------------------------------------------------------------------*
*& Report HIDCHCR0
*&
*&---------------------------------------------------------------------*
*& Indonesia BPJS Health Care Report
*&---------------------------------------------------------------------*

REPORT ZHIDCHCR0 MESSAGE-ID 3D.

INCLUDE zhidchcr0_top. "Data Declaration
* dicky 20150225
INCLUDE zpy_simulation.      "Payroll Simulation
INCLUDE zhr_gen_excel_ver1.  "Excel function
INCLUDE zhidcbmr0_alv.       "Popup ALV
* dicky 20150225
INCLUDE zhidchcr0_sel. "Selection Screen
INCLUDE zhidchcr0_f01. "Main Functions
INCLUDE zhidchcr0_f02. "Other Functions
INCLUDE zhidchcr0_mai. "Main Include


2. Module for Read Simulation Payroll

*----------------------------------------------------------------------*
*   INCLUDE ZPY_SIMULATION                                             *
*----------------------------------------------------------------------*
*---------------------------------------------------------------------*
*       FORM zpy_payroll_simulation                                   *
*---------------------------------------------------------------------*
  TYPE-POOLS: hrpay.
  TABLES: pcl1,  "IMPORT/EXPORT
          pcl2.  "IMPORT/EXPORT

  INCLUDE hidpaymacro.
  INCLUDE rpc2cd09.
  INCLUDE rpppxd10.
  INCLUDE rpc2rx29.
  INCLUDE rpc2ps00.
  INCLUDE rpc2pt00.
  INCLUDE pc2rxid0.
  INCLUDE rpc2rx02.
  INCLUDE rpc2rx39.
  INCLUDE rpppxd00.
  INCLUDE rpppxm00.

*---------------------------------------------------------------------*
*       FORM zpy_payroll_simulation                                   *
*---------------------------------------------------------------------*
  FORM zpy_payroll_simulation
       TABLES p_rgdir STRUCTURE rgdir
*              p_rt STRUCTURE rt
        USING p_abkrs zperiod zyear p_pernr.


    DATA: molga(2)              TYPE c.
    DATA: buffer                TYPE hrpay_buffer.
*    DATA: rgdir_line            LIKE pc261.
    DATA: trgdir LIKE rgdir OCCURS 0 WITH HEADER LINE.
    DATA: p_var(14)             TYPE c VALUE ''.
    DATA: p_prog TYPE trdir-name VALUE 'ZHIDCALC0'.
    DATA: sim_pernr LIKE pay_sim_pernr OCCURS 0 WITH HEADER LINE.
    DATA: p_period  TYPE t549q-pabrp, p_year    TYPE t549q-pabrj.
    DATA: p_fpper TYPE faper.

    p_period = zperiod.
    p_year = zyear.
    CONCATENATE p_year p_period INTO p_fpper.
    sim_pernr-pernr       = p_pernr.
    APPEND sim_pernr.

    CALL FUNCTION 'HR_PAYROLL'
      EXPORTING
       payroll_area               = p_abkrs
       payroll_period             = p_period
       payroll_year               = p_year
       selection_variant          = p_var
       program_name               = p_prog
*     TST_ON                     = 'X'
      TABLES
        employee_numbers          = sim_pernr
       buffer                     = tbuff
       buffer_directory           = buffer_dir
       delete_pclx                = del_pclx_tab
     EXCEPTIONS
       program_not_exist          = 1
       variant_not_exist          = 2
       missing_parameter          = 3
       wrong_parameter            = 4
       wrong_country_group        = 5
       OTHERS                     = 6
              .
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

    buffer-tbuff[]        = tbuff[].
    buffer-buffer_dir[]   = buffer_dir[].
    buffer-del_pclx_tab[] = del_pclx_tab[].

    CALL FUNCTION 'CU_READ_RGDIR'
         EXPORTING
              persnr          = sim_pernr-pernr
              buffer          = buffer
         IMPORTING
              molga           = molga
         TABLES
              in_rgdir        = trgdir
         EXCEPTIONS
              no_record_found = 1
              OTHERS          = 2.

*    CALL FUNCTION 'CD_READ_LAST_RESULT_IN_RGDIR'
*         IMPORTING
*              ptx_rgdir_nv = rgdir_line
*         TABLES
*              pt_rgdir     = rgdir.
    CALL FUNCTION 'CD_EVALUATION_PERIODS'
         EXPORTING
              inper_modif     = '01'
              inper           = p_fpper
         TABLES
              rgdir           = trgdir
              evpdir          = rgdir
         EXCEPTIONS
              no_record_found = 1
              OTHERS          = 2.

*    rx-key-pernr = sim_pernr-pernr.
*    read table rgdir index 1.
*    rx-key-seqno = rgdir-seqnr.
*    rp-imp-c2-is.

*    IF rp-imp-is-subrc = 0.
      p_rgdir[] = rgdir[].
*      p_rt[] = rt[].
*    READ TABLE rgdir INDEX 1.
*    WRITE: / 'fpper:', rgdir-fpper, 'inper:', rgdir-inper, 'srtza:',
*rgdir-srtza.
*    WRITE: /.
*    LOOP AT rt.
*      WRITE: / rt-lgart, rt-betpe, rt-anzhl, rt-betrg.
*    ENDLOOP.
*    ENDIF.
  ENDFORM.


3. How to use it.

   PERFORM zpy_payroll_simulation
         TABLES zrgdir
         USING gv_abkrs gv_fpper+4(2) gv_fpper(4) p_pernr.
  ENDIF.

* ambil yang current period saja
* tidak perlu di loop ( kasus late hiring )
  CALL FUNCTION 'CD_READ_LAST_RESULT_IN_RGDIR'
       IMPORTING
            ptx_rgdir_nv = rgdir_line
       TABLES
            pt_rgdir     = zrgdir.
*  LOOP AT zrgdir.
  REFRESH rt.
  rx-key-pernr = p_pernr.
*  rx-key-seqno = zrgdir-seqnr.
  rx-key-seqno = rgdir_line-seqnr.
  rp-imp-c2-is.

  loop at rt.
       write rt.
  endloop.

No comments:

Post a Comment