Fast Formula – WSA
In this session, we will explain how to talk to another Fast Formula that is executed in the same session.
In many processes, we define more than one Fast Formula and sometimes these Fast Formulas execute the same routine again and again. This can be avoided if we could talk to each other or if we can pass a value between Fast Formulas.
We will explain this concept with a hypothetical use case.
Assume Total Compensation Statement needs to calculate the Annual FTE (Full Time Equivalent) Salary and Bonus for every person. The Bonus is 20% of the Annual FTE Salary.
In the above example, the Annual FTE needs to be calculated in the Salary Fast Formula and the Bonus Fast Formula. Instead of doing the calculation in every Fast Formula, we want to calculate the Annual FTE salary in the Fast Formula that is executed first and pass the value to the Fast Formula that is executed later.
As per the setup, we assume, the Annual FTE Salary Fast Formula is executed first and the Bonus Fast Formula is executed later. To find out which process is executed first, you can run the process for a person and the Fast Formula ESS Logs can help you.
How we achieved this requirement:
- Steps for FTE Salary Fast Formula:
- We get the Annual salary from the Annual Salary DBI.
- Get the FTE value from the FTE DBI.
- If the DBI is not null or 1, then divide the Annual salary with FTE
- If the Salary is defined for Hourly, then multiply the salary with FTE.
- Set the value in Working Storage Area using the function WSA_SET(<item>, <value>).
- Check the salary WSA Item exists by using WSA_EXISTS(<item>).
- If the WSA exists, get the value from WSA by using WSA_GET(<item>, <default-value>).
- Otherwise, calculate the value from the DBI.
- If the WSA exists, delete the WSA by using WSA_DELETE(<item>) so that we make sure the WSA value is not used for the next person.
What is WSA:
As per the Fast Formula documentation,
“The working storage area is a mechanism for storing global values across
formulas. The values are accessed by name. The names are case-independent”.
There are four working storage area methods:
WSA_EXISTS
WSA_DELETE
WSA_SET
WSA_GET
FTE Salary Fast Formula:
/*
Author : Ti(lak)shmi
Type : Total Compensation Item
NAME : TCS_FTE_SAL_TEST_FF
Remarks: This formula is for demonstrating the communication between Fast Formulas.
This formula calculates the Full time FTE salary and assigns it to a WSA Variable.
*/
DEFAULT FOR CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT IS -1
DEFAULT FOR PER_ASG_FTE_VALUE IS 1
INPUTS ARE CMP_IV_PERIOD_START_DATE (DATE) ,CMP_IV_PERIOD_END_DATE (DATE)
L_DATA = ESS_LOG_WRITE( 'BEGIN CS_FTE_SAL_TEST_FF' )
COMPENSATION_DATES = TO_CHAR(CMP_IV_PERIOD_END_DATE, 'YYYY/MM/DD')
VALUES = 0
IF (CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT WAS NOT DEFAULTED ) THEN
(
VALUES = CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT
IF (PER_ASG_FTE_VALUE WAS NOT DEFAULTED) THEN
(
VALUES = VALUES * PER_ASG_FTE_VALUE
)
L_DATA = ESS_LOG_WRITE( 'Salary Amount is ' + TO_CHAR(VALUES) )
WSA_SET('TCS_WSA_TEST_FTE_SALARY', VALUES)
) ELSE (
L_DATA = ESS_LOG_WRITE( 'Salary Amount is 0 to test WSA ' )
WSA_SET('TCS_WSA_TEST_FTE_SALARY', VALUES)
)
L_DATA = ESS_LOG_WRITE( 'END CS_FTE_SAL_TEST_FF' )
RETURN COMPENSATION_DATES ,VALUE
Bonus Fast Formula:
/*
Author : Ti(lak)shmi
Type : Total Compensation Item
NAME : TCS_BONUS_TEST_FF
Remarks: This formula is for demonstrating the communication between Fast Formulas.
This formula gets the salary value that is calculated at TCS_FTE_SAL_TEST_FF by using WSA.
*/
INPUTS ARE CMP_IV_PERIOD_START_DATE (DATE) ,CMP_IV_PERIOD_END_DATE (DATE)
L_DATA = ESS_LOG_WRITE( 'BEGIN TCS_BONUS_TEST_FF' )
COMPENSATION_DATES = CMP_IV_PERIOD_END_DATE
VALUES = 0
IF WSA_EXISTS('TCS_WSA_TEST_FTE_SALARY' ) THEN
(
L_DATA = ESS_LOG_WRITE( 'WSA FOUND' )
VALUES = WSA_GET('TCS_WSA_TEST_FTE_SALARY', 0 )
L_DATA = ESS_LOG_WRITE( 'WSA VALUE ' + TO_CHAR(VALUES))
IF (VALUES != 0 ) THEN
(
VALUES = VALUES * .20
L_DATA = ESS_LOG_WRITE( 'Bonus Amount ' + TO_CHAR(VALUES))
)
WSA_DELETE('TCS_WSA_TEST_FTE_SALARY' )
)
L_DATA = ESS_LOG_WRITE( 'END TCS_BONUS_TEST_FF' )
RETURN COMPENSATION_DATES ,VALUE
TCS Setups:
Item:
Category Setup
Statement Setup
Sample Log for the Formula Execution
BEGIN CS_FTE_SAL_TEST_FF
Salary Amount is 54963
END CS_FTE_SAL_TEST_FF
BEGIN TCS_BONUS_TEST_FF
WSA FOUND
WSA VALUE 54963
Bonus Amount 10992.6
END TCS_BONUS_TEST_FF
As per the log, Salary Fast Formula calculated the Salary and assigned the Salary value to a WSA Variable and the Bonus Fast Formula was able to get the value from the WSA Variable.
Hope this has helped you with an understanding of WSA and how communicating between Fast Formulas is possible. As always, if you have any questions or suggestions, please feel free to comment.
/*
Author : Tilak
Type : Compensation Person Selection
NAME : CMP_PERSON_SELECTION
Remarks: Eligible if the person annual salary is < 200000
and set the salary to WSA with person id
*/
DEFAULT FOR CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT IS -1
DEFAULT FOR PER_ASG_FTE_VALUE IS 1
INPUTS ARE CMP_IV_PERIOD_START_DATE (DATE) ,CMP_IV_PERIOD_END_DATE (DATE)
L_DATA = ESS_LOG_WRITE( 'Entering CMP_PERSON_SELECTION' )
VALUES = 0
retValue = 'Y'
personid = get_context(PERSON_ID, -1)
L_DATA = ESS_LOG_WRITE( 'person id ' + to_char( personid ) )
IF (CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT WAS NOT DEFAULTED ) THEN
(
VALUES = CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT
IF (PER_ASG_FTE_VALUE WAS NOT DEFAULTED) THEN
(
VALUES = VALUES * PER_ASG_FTE_VALUE
)
)
L_DATA = ESS_LOG_WRITE( 'Salary Amount is ' + TO_CHAR(VALUES) )
WSA_SET('TCS_WSA_TEST_FTE_SALARY', VALUES)
WSA_SET('TCS_WSA_TEST_PERSON', personid)
if VALUES > 200000 OR VALUES <= 0 then (
retValue = 'N'
)
L_DATA = ESS_LOG_WRITE( 'Leaving CMP_PERSON_SELECTION ' + retValue )
RETURN retValue
//*
Author : Tilak
Type : Participation and Rate Eligibility
NAME : CMP_ELiGiBLE
Remarks: Eligible if the person annual salary is > 100000
get the salary from WSA and delete the WSA
*/
L_DATA = ESS_LOG_WRITE( 'Entering CMP_ELiGiBLE ' )
VALUES = 0
ELIGIBLE = 'Y'
personid = get_context(PERSON_ID, -1)
L_DATA = ESS_LOG_WRITE( 'person ' + TO_CHAR(personid) )
if WSA_EXISTS('TCS_WSA_TEST_FTE_SALARY') then (
L_DATA = ESS_LOG_WRITE( ' WSA Exists' )
lperson = WSA_GET('TCS_WSA_TEST_PERSON', -1)
L_DATA = ESS_LOG_WRITE( 'WSA person ' + TO_CHAR(lperson) )
if lperson = personid then (
VALUES = WSA_GET('TCS_WSA_TEST_FTE_SALARY', -1)
L_DATA = ESS_LOG_WRITE( 'WSA salary ' + TO_CHAR(VALUES) )
if VALUES > 100000 then (
ELIGIBLE = 'N'
)
WSA_DELETE('TCS_WSA_TEST_FTE_SALARY')
WSA_DELETE('TCS_WSA_TEST_PERSON')
)
)
ELSE (
L_DATA = ESS_LOG_WRITE( 'WSA NOT EXIST CMP_ELiGiBLE ' )
ELIGIBLE = 'N'
)
L_DATA = ESS_LOG_WRITE( 'Leaving CMP_ELiGiBLE ' + ELIGIBLE )
RETURN ELIGIBLE