Technical Articles
Accrual Calculation based on age limit for each child or dependent
Hello Everyone
This is regarding calculating accruals based on dependent age. I have seen many such questions floating around the customer and partner community. Hence wanted to share a possible solution for now.
Let’s look at a sample requirement “A customer’s requirement is, that Vacation days are added for each child under 12 years of age”. For example, if there are 3 children and only 2 are below 12 years, the accrual should be 20 (2 * 10 days per child). “
We have two ways of handling this. You can follow the approach you like
Option 1: Using Custom field and Integration Center
Coming to this solution, you can follow the below steps and check the results yourself. Further, you can adapt
Procedure
1. Create a custom field in Dependents “IsEligibleForAccrual” using BCUI.
2. Create a new on Save rule on the same dependent portlet to set this custom field based on your requirement of 12 years (144 months)
3. In the accrual rule use the cardinality rule function to check the number of dependents matching this field as “YES”
Testing
The current employee has two eligible dependent Childs
In my sample rule, I am providing 10 days per dependent matching the criteria
The accrual granted is 20 days which is correct in this case
Integration Center to update dependents in subsequent years
The eligibility of existing dependents which were added after the employee is hired can change in subsequent years. For example, If there is a child born in 2008 would become 13 years in 2021. As a result, at beginning of 2021, we need to update this eligibility field to “NO” so that the accruals for 2021 can consider this
To achieve this consider the below design
Create a outbound integration to output the current dependents in system into a csv file in SFTP folder
Example:
Add a calculated field named “Years” and add the following calculation
This gives the difference between the date of birth of dependent and today (Jan 1st of every year)
Sample file extracted
Create an inbound integration to read the csv file (exported in above step) from SFTP folder
Map the fields Person ID External , Related Person ID External
Make Start date as calculated field which is resolved to today or NOW
Also make the isEligibleForAccrual as calculated field with below calculation by using “Choose” Operator
It is a switch case where if the Years field from CSV is between 1 to 12 , it will be set to YES
Otherwise NO
Small Test
After I run the integration centre report, the dependent who is now 13 years in 2021 is updated
You can schedule these integrations every year (Beginning of Jan) if your accrual calendar year is Jan – Dec. This would ensure that the dependent’s eligibility is set as per their age at that moment.
Post this, you can run the accrual calendars for this time account type
Other considerations
- Instead of years if you want months, you need to add numbers from 1 to 144 in your switch case, as in IC the if else condition does not provide filters less than currently
- You can add additional time based filters to prevent reading all dependents. This can depend on your use case
Option 2:
You can use the below rule and rule function to check if a child is less than 15 years or 180 months as of accrual date
What this rule does? It basically sorts the employee’s dependents with relationship child (external code =2) as per their DOB. And it checks the position/rank of the first child meeting the criteria of less than <= 180 months. . For example say there are 5 children and the first child meeting the criteria of<=180 months is at rank 3, this means the first 2 children are above>= 180 months and all children below 3rd position i.e child 4 and 5 are <=180 months. So in total, we have 5-2 = 3 children meeting these criteria. Hence you can then use this number 3 to further calculate the accruals
This is a simpler way instead of option 1. Further, the rule is limited to only 3 children in the picture but you can extend it to any number of children. Just continue the pattern and logic
Disclaimer:
The current solution does not cover accrual recalculation for ex: when a new eligible child is added. But such challenges can be overcome by scheduling periodically the time off calendars.
If I get a way to automate this step as well, Will enhance this blog or create a new one.
Also please evaluate this with your customer, before adopting the solution.
Thanks
Neelesh
Nice blog Neelesh Kamath and I have a small query on Treat Null As() function you used TREAT NULL AS() function because to avoid inconsistency if there are no YES records in the system, correct me if I’m wrong.
Considering your example there are 2 YES records, so first system checks whether there are none of YES records maintained and if none YES records exist then rule will update the VALUE with 0; when multiply any number with 0 will be 0 so no output and if YES records are maintained then the VALUE will be 2( based on example) and Factor is 10 so output will be 2*10=20.
My Query is what happens if we directly use Cardinality function in VALUE field, will system throw error or Accruals will generate with different value?
Thanks,
Parthu.
HI Parthu
Thanks for the feedback. I generally use Treat Null As with all these functions as some return NULL and some a numeric value. Hence Do not want the rule to fail because of an unhandled null case.. But I guess for Cardinality you can make use of the function directly on the value as it is numeric.
Please give it a try
Thanks
Neelesh
Hi Neelesh,
thanks for the information you shared, I am just facing this situation. About that, I have a couple of questions about the process you follow.
If the rule is an onSave trigger scenario, then this information is going to be useful just one time. I mean:
Additionally, I do not get the point of calculating eligibility based on dependent's date of birth and event date, I would calculate eligibility based on date of birth and today, to determine age and this would let me calculate eligibility.
Thanks for your time and effort to share knowledge.
Best regards,
Isra
Hi Isra
Regarding your comments
Additionally, I do not get the point of calculating eligibility based on dependent’s date of birth and event date, I would calculate eligibility based on date of birth and today, to determine age and this would let me calculate eligibility. – yes you are right. I just created a POC and tested with event date = today. Practically Today makes sense.
Thanks & BR
Neelesh
Hi Neelesh,
On the second option did you use new custom object Sub Quota for Vacation per Employee SVN?
Regards,
Fuad
Hi Fuad,
Yes I used a custom MDF in my implementation for different reasons but you can use this rule function directly in accrual rule as well and use else if to create different accrual values based on conditions
Regards
Neelesh
Dear Neelesh,
Coming back to this question one more time. Option 2 for me still it is unclear to which object/portlet you have assigned the mentioned Rule ? Is it assigned on Dependent portlet onSave ?
Could you pls elaborate a little bit more your option 2 ?
Regards,
Fuad
Hi Fuad,
In My case, I am storing the dependent eligibility in a custom MDF as my requirement was something else where I had to calculate the quota based on different parameters for an employee
However, you can use this directly in the accrual rule itself as this is a rule function-based logic. You can use these rule functions in different if-else conditions of the accrual rule and then set the accrual value of time account details
I have also used this logic directly in accrual rules for some other requirement
Regards
Neelesh
Hi Neelesh,
Lemme explain what we are trying to do:
Requirement:
If employee has 2 or less dependent under 12 years then 1 day, else if more than 2 the 2 days on monthly based is granted on monthly based. We have a custom field in dependent portlet which stores is Yes and No and everything is updated regarding to your Option 1.
Solution:
From Time Management point of view balance is granted separately on monthly based and that's why we have to use Ad-hoc type. If we use Ad-hoc type time account type then object Time account and time account details has to be created manually:
Time account:
Via the Integration center we are able to export csv with required columns and then import back and it successfully creates ad-hoc time account to all active employees with 0 balance.
Time Account Details:
Here we plan the same approach but main source of data should be custom object where we store the eligibility result and balance number (1 or 2). Via the business rule create record in custom object after that via this custom object and Integration center update Time account details for everyone who should be granted 1 or 2 days.
Question
Problem here from dependent portlet we have some troubles to create record in our custom object via rule. But from your screens for Option 2 you managed to set a value to the field of your custom object. I'm just curious to see you rule scenario, parameters and the place where you put your rule in manage business configuration.
And additionally maybe you can also share your knowledge and experience in this overall approach.
Regards,
Fuad
Hi Fuad
I have attached the config of custom MDF and rule below
The custom MDF is created using IC where starting entity is user and the target is the custom MDF
It is similar to the blog I wrote in below. The IC is run periodically based on a schedule and the custom MDF is updated using on Save rules
https://blogs.sap.com/2021/10/22/timely-time-sheet-alerts-for-no-records-on-previous-working-day/
Hi Neelesh,
This is a great blog and was looking exactly looking for this solution for one of our requirement.
Below is code snippet which we have configured following your option 2 but not working as expected.
Employee has one dependent effective 4 Jul 2022 with DOB as 4 Jul 2022
Dependent information:
when we run simulator for the employee, expected result was 5 days but we are getting 0 days and below is the rule log
Not sure how the system calculates 41.21 when the DOB of dependent is 04 Jul 2022.
Can you please help us here.
Thanks,
Sriram
Hi Sriram
Couple of issues I anticipate here
Try with accruable end date and also different rank conditions to see from which rank you get the child which is less than 36 months
This logic has been implemented by a couple of partners and it is working for them successfully.
Hi Neelesh Kamath,
Thank you so much for taking time in replying to my query. Changed As on Date from Context.Effective Date to Accrual Rule Parameters.Accruable Start Date and it is now working as expected. Have couple of questions:
Thanks,
Sriram
Hi Sriram,
To answer your questions
Hi Neelesh Kamath ,
Can you explain me how I can schedule the job to run every day or week?
I have setup an annual time account type for "Sick Child", it's using the dependents portal to accrue the number of days you will get. If you have 1 child under 12 you will get 10 days. Everything is working on hire, or when we create the accruals for the "next" year. The Time Account Type is Annual.
But after reading your blog post, and this sentence " But such challenges can be overcome by scheduling periodically the time off calendars." I started to wonder what is wrong with my setup?
Maybe my issue is that the Time Account Type has frequency "Annual"? and therefore not possible to schedule it more often in the Manage Time Off Calendar?
During a year a new child can be added in the Dependents portlet and thus I would like the quota balance to automatically be updated. It does not need to be immediately, but the day or week after is fine.
I hope you can help me and direct me in the correct way.
Thanks for a good post!
Hi @Jesper Marrup ,
You can periodically schedule your calendars from manage time off calendars...I am assuming you have the accrual logic to find number of children below a certain age in the accrual rule itself (like option 2 in my case)..If a new child is born mid of a year, ideally the acrrual calendar should be invoked again and your accual rule should be written in such a way that it recalculates the actual value
When to recalculate
If 2 > 1, it is clear that there is a new child added in the middle of year (because in such a case the child is valid also as of end of the year but its not valid at beginning of the year)..Then in such a case give an additional accrual on top of whatever you have calculated with existing logic.
if 2 == 1 , the accrual rule will give the same value, hence no change is required
In order to run recalculation, you would need to schedule the accrual calendars with recal flag ON every week in advance
Hi,
This is what I see in Manage Time Off Calendars:
I don't see any possibility to make it run every week?
you will have to create multiple calendar run for each week and schedule them..Please look at time management implementation guide for further details on time calendar
Thanks, I got it. I hoped there was a schedule feature or something I have missed.
will see if i can find a smart way. I was thinking about using IC to create new time account calendars every week.
Hi Neelash,
Thank you for your detailed explanation.
I have followed the steps that you described for option 1 however, I am getting an error in the inbound integration. Please see below:
Do you know what could be the root cause of this?
Thank you,
Maria