[SAP HCM PY] Any way to loop over the previous results?
BREAK dungbv7.
1. Understanding business requirements
One of my previous clients has a seniority allowance that will be calculated every month inside the Payroll driver. But these allowance amounts are only paid to the employee once a quarter.
So during the Payroll run of March, July, September and December, the system needs to call back the payroll results of 2 preceding months.
Most SAP PY consultants know how to import the last payroll result by using the function IMPORT L. However, in this situation, we need a function that only imports regular monthly results and skips special runs such as Off-cycle Bonus or Adjustment-check.
In this post, I will show you how to use the operation PLOOP to perform this task.
2. Understanding system configuration
Ok, let's jump straight into schema config.
First of all, I will use an IF function and a PCR to make sure my calculation will only occur in the payroll run of March, July, September or December.
When I run payroll in period 05/2021:
When I run payroll in period 06/2021:
Next, inside PCR YY97 I put operation PLOOP to retrieve RTs from preceding months:
In case you don't familiar with these operations please check the table below for further understanding:
Let's take a look at Payroll logs to view what was happen:
This employee has many payroll runs in PC_PAYRESULT, with sequence numbers from 01 to 11. In the payroll run of 06/2021, I need to import results of 04/2021 and 05/2021, which have the sequence of 10 and 09.
Double click into processing folder of PCR YY97
We can see the operation IMPRE - import 2 times, the first time is the Payroll result with sequence number 10 (Regular run 05/2021) and the second is 09 (Regular run 04/2021):
The sum of the preceding months' allowance is stored in a separate line with EEsubgrouping *:
Finally, function PIT is called to summarize allowance from preceding months with current months:
3. Expanding the configuration
With a similar calculation process, we can generate multiple salary amounts using historical payroll runs. For example, the average salary of the last 6 months or the total income YTD. I will continue writing on this topic if I have free time.
Ok, that's all for today. Thanks for reading 😀
May the best solution be with you
Subscribe to my newsletter
Read articles from Việt Dũng directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Việt Dũng
Việt Dũng
I am a SAP HCM consultant from Vietnam.