My solution as below:
1. Create 6 wage type ( index from 00, 01, 02, 03, 04, 05) to store basic salary.
2. Keep in mind these logic
- wt 00 only contains current basic salary
- wt 01 only contains Last value of wt 00 (if it's NULL, ONLY in golive period or 1st period running payroll, using current basic salary or Avg 6mon Basic Golive inputted manually)
- the same logic will be applied for others from wt 03, wt 04 and wt 05.
3. After having value in these wage types, you just simply total and divide 6. It's very easy so I don't care about it. I will focus only the step 2.
1. Configuration Wage type: Create 6 wage types (sharing same configurations in V_512W_D) and please note processing class 6:
There are some PCR will re-produce solution steps mentioned in step 2:
There are total 5 PCR (from ZV20 to ZV24). Basic Salary is wt 1000 and Avg 6mon Basic Golive is wt 5901.
In the first PCR, there are some steps I would like to explain in order to be easier to understand
- Output wt 1000 from internal table IT to output table OT to process. Insert current AMT into wt 00 (wt 8000). (100% fits with 1st step above Keep in mind these logic)
- Get last value of wt 00 (wt 8000), if it's > 0, assign to wt 01 (wt 8001).
Otherwise (Only in golive period or 1st period running payroll), check Avg 6mon Basic Golive.
If Avg 6mon Basic Golive = 0, get Basic Salary and assign to wt 01 (wt 8001). Else wt 01 (wt 8001) equals Avg 6mon Basic Golive.
Should include your PCR before processing class 10 in sub-schema XAL9 Factoring and storage. With my case I insert it into sub-schema XAP9 Import additional payments/deductions. I captured payroll schema when running display mode, as it's very important way to deeply and fast control and understand Payroll Schema
And Avg 6mon Basic Golive (if you don't input the wt, system will get from current basic salary in 1st period running payroll )
In JANUARY: (6 wt (00 -> 05) contain correctly values: wt 00 (wt 8000) - current basic 300, other Avg 6mon Basic Golive 150.
In JUNE: (6 wt (00 -> 05) are exactly: wt 00 (wt 8000) - current basic Jun 400, wt 01 (wt 8001) - basic in May: 400, wt 02 (wt 8002) - basic in Apr: 350, wt 03 (wt 8003) - basic in Mar: 400, wt 04 and wt 05 (wt 8004 & wt 8005) both base in Jan and Feb - 300).