Human Capital Management Blogs by Members
Gain valuable knowledge and tips on SAP SuccessFactors HCM suite and human capital management market from member blog posts. Share your insights with a post of your own.
Showing results for 
Search instead for 
Did you mean: 
Business Scenario:  Recently I was implementing time off solution for my client.  While implementing Annual Leave Entitlement for my clients, I have encountered a little complex scenario that I would like to share with you today. Also, discuss on some specific business rule functionality.

Annual Leave entitlement Accrual rule is pretty much straight forward to configure and well-articulated in the implementation guide. My focus today is to explain a typical Proration logic for Termination or Hire Annual Leave Proration Rule.

Annual Leave Entitlement to be retrieved (from a lookup table) based on years with company and Position. Proration logic is to round up the prorated leave balance to multiple of 0.5 for Hire and Termination Case.

Example Scenario:

For Hire Scenario, if Yearly Entitlement is 18 days leave, below proration logic to be implemented:

A calculated prorated leave entitlement of 12.75 to 13.24 to be rounded to 13

A calculated prorated leave entitlement of 13.25 to 13.74 to be rounded to 13.5

A calculated prorated leave entitlement of 13.75 to 14.24 to be rounded to 14


Here is the rule with simple rounding logic and optimized database hitting:

Variable Deceleration

Rule Body



Trick I did is to perform the proration entitlement calculation before actual rule execution, assigning  the value into a variableCalculatedamount ). Then apply the round rule in the actual rule body processing.

Note 1: A variable declared in any business rule, can’t be deleted to modified, if that is referenced in the rule body. So, to update a variable, one needs to remove it from the rule body part first.

Note 2: If any variable just declared in any business rule, but not referred in the rule body, the variable will not get called during the run time

So, further drilling down on the variable ( var_calculatedamount ) assignment:

  1. Calculate the number of days a terminated employee will be eligible for leave calculation on the last day of work

Get Number Of Calendar Days()

                           Start Date: Accrual Rule Parameters.Accruable Start Date

                           End Date:  Accrual Rule Parameters.Accruable End Date

  1. Get the number of days in the year calculation is happening. This function is used to take into account the extra day on Leap year

Get Number Of Days For Year Of Date()

                            Date: Accrual Rule Parameters.Accruable End Date


  1. Divide Days obtained from point 1 with Days obtained from point 2, to get the fraction

  2. Fetch the yearly leave day’s entitlement from “Your Lookup Table”, based on employee’s years of experience and Position Title (Consultant, Lead Consultant, Principal Consultant etc.)

  3. Multiply Yearly entitlement obtained from Point 4 with Fraction from Point 3 to get prorated entitlement for the year

  4. Round off the prorated data obtained from point 5 to 2 decimal places (Precision 2) and with threshold (0.5)

Now, we get the prorated value till 2 decimal. Example if the yearly entitlement is of 18 days for the whole year, prorated entitlement may be like 12.25, 13.01 or 12.06.

Now we shall use simple Modulo function to achieve desired rounded value. That is prorated leave balance in the range 12.75 to 13.24 to be rounded to 13 and so on.

Modulo function on a decimal number returns only the decimal part of it with divisor is 1.

For example MODULO ( Number = 12.35 Divisor = 1 ), will return value 0.35.

Then simply compare the decimal part against the rage and post the desired leave like below:

If Modulo ( Number =  12.35 Division = 1 ) less than 0.25

Then Post Leave  ( Number = 12.35 – Module ( Number  = 12.35 ) ) = 12.35 - 0.35 = 12

Else if  Modulo ( Number =  12.35 Division = 1 ) Greater  than 0.24 and Less Than 0.75

Then Post Leave  ( Number = 12.35 – Module ( Number  = 12.35 )  + .5  ) = 12.35 - 0.35 + .5 = 12.5

Else Post Leave  ( Number = 12.35 – Module ( Number  = 12.35 )  + 1  ) = 12.35 - 0.35 + .5 = 13

In the above example final prorated rounded value will be 12.5

Thank You!

Thank you for reading this blog. Hope you find this interesting.  Request you to please share your comment and / or queries.

You can ask your query in community forum mentioned in the link below as well.

Labels in this area