SAP HCM ABAP DRIVER SIMULATION

From SapWiki
Revision as of 19:26, 28 June 2026 by WikiSysop (talk | contribs)

FM Hr_Payroll_Simulation

  1. The HR_PAYROLL_SIMULATION function module is used to simulate payroll processing without actually running the payroll.
  2. It is particularly useful for testing and debugging payroll scenarios.
  3. To use this function module, follow these steps:
   ## Define the necessary input parameters, such as payroll area, payroll period, and payroll year.
   ## Call the HR_PAYROLL_SIMULATION function module with the defined parameters.
   ## The function module will return the simulation results, which can be analyzed for any discrepancies or errors.
  1. Ensure that the personnel calculation rules are set up correctly to work irrespective of the payroll sequence.

Ejemplo 1 (ojo con la clase cl_hrpay99_fill_infotypes)

Simular existencia de Infotipos en driver nomina RPCALCX0

*Tables for intermediate memory mngmt.
types: begin of hroct_iprel,
  pernr like p0001-pernr,
  infty like p0001-infty,
  idata like prelp occurs 0,
end of hroct iprel.

data: begin of mem id_iprel,
  pernr like p0001-pernr,
  value (5) value 'IPREL',
end of mem_id_iprel.

"Memory ID for infotypes

data: obj_iprel type ref to cl_hrpay99_fill_infotypes.

*objects for infotype simulation

data: send_it type ref to cl_hrpay99_send_infotypes,
      iprel type hrpay99_iprel_table.

IF obj_iprel IS INITIAL.
  CREATE OBJECT obj_iprel.
ENDIF.

if p_flag ='X'.
*read & send infotype 0014 to memory for the process of simulation
*of the payroll driver RPCALCX0
  perform fill_iperl_i0014.
else.
  clear retro date.
endif.

if not obj_iprel is initial.
* create object for infotype simulation
  create object send_it.
* fill iprel from importing parameter
  iprel = obj_iprel->get_iprel( ).
* fill send_it from table iprel
  call method send_it->set_iprel( iprel ).
* send infotype object to memory
  call method send_it->send_all.
endif.

submit rpcalcx0
using selection-set variant_calc
**** using selection-sets of program 'HARCALC0'
 using selection-sets of program 'RPCALCX0'
with pnppernr eq fired_employees_line-pernr
with pnpxabkr eq fired_employees_line-abkrs
with pnpabkrs eq fired_employees_line-abkrs
with pnptimr9 eq space
with pnptimra eq 'X'
* WITH pnppabrp EQ fired_employees_line-pabrp "M29
* WITH pnppabrj EQ fired_employees_line-pabrj "M29
with pnppabrp eq gd_pabrp "M29
with pnppabrj eq gd_pabrj "M29
with payty eq fired_employees_line-payty
* WITH bondt EQ fired_employees_line-bondt "M29
* WITH ocrsn EQ fired_employees_line-ocrsn "M29
with bondt eq gd_bondt "M29
with ocrsn eq gd_ocrsn "M29
* with test_on eq ' '
with tst_on eq 'X'
with prt_prot eq 'X'
with sw_spool eq space " Print to spool
* with edt_vari eq variant_cedt " Show payslip
with edt_vari eq variant_cedt " Show payslip
with ecalled eq 'X'
with set_nib eq 'X'
with set_odc eq 'X'
with upd_ps eq space
with exp_buff eq 'X'
with imp_buff eq space
* with brk_on eq ' '
* with brk_sc eq ' '
* with brk_off eq 'X'
with plgmemky eq memo_key
with rueck-ab = retro_date "M19
exporting list to memory
and return.

form fill_iperl_10014.

data: begin of help i0014 occurs 5.
  include structure p0014.
data: end of help i0014.

*fill iprel with all infotypes

clear iprel.
*refresh iprel.

if p9902-zzbasetri > 0.

****************************************
* RP-READ-INFOTYPE *
****************************************
* PARAMETERS: *
* PERNR REQUESTED PERSONALNUMBER*
* INFTY REQUESTED INFOTYPNUMBER *
* INFTY-TABLE OUTPUT-TABLE LIKE PNNNN*
* BEGDA REQUESTED INTERVAL-BEGIN*
* ENDDA REQUESTED INTERVAL-END *
****************************************


*read all the 0014 records for put in memory
perform read-infotype(sapdbpnp)
                       tables help_10014
                        using p9902-pernr '0014' '18000101' '99991231'.

*distribution of the p9902-zzbasetri ammount in IT0014 records
perform create_10014 tables help_10014
                     using p9902
                           p9902-zzbasetri
                           p9902-waers.

*Put the IT0014 records in internal object for send it
*to memory
  call method obj_iprel->insert(help_10014[] ).

endif.

endform. "fill_iperl_10014 

Ojo en driver RPCALCX0 los infotipos simulados se procesan en include RPCHRT09

get pernr.
  if ecalled = 'X'. "XAIAHRK001447
* read infotypes from memory (for infotype simulation)
    perform get_iprel using pernr-pernr. "XAIAHRK001447