## Saturday, 14 October 2017

### FUSION HCM : FAST FORMULAS

#### Fast Formulas:

Oracle FastFormula is a simple way to write formulas using English words and basic mathematical functions
You can write generic expressions for any calculation or comparison you may want to repeat with different input values
The Fast Formula uses its own language similar to C and PL/SQL. If you are familiar with either one of these languages, you will not find it difficult to understand the syntax of the fast formula.
Fast formula is an Oracle HCM payroll engine and other products like
• Payroll
• Benefits
• Human Resources HCM Extracts
• Compensation Management
• Absence Management
• Time and Labor use the engine.

These products have provided places to attach formula, whenever there is a need of a Complex/custom logic.
The consultants add their own logic via a set of statements and subprograms which is the Fast Formula.
Uses of Fast Formula :
Fast Formulas can be used across various Fusion HCM products to:
–Perform Payroll Calculations
–Define rules for paid time off (PTO) accruals
–Calculate absence duration
–Define custom calculations for benefits administration
–Edit rules for object group population for elements or people
–Validate Element Input Values or User-Defined Tables
–Validation and HCM Extracts
Basic Components of Fast Formula
Before start writing any fast formula, you need to understand the following.
1)      Formula types
2)      Context
3)      Database items (DBI)
4)      Input values
5)      Return Variables/Values.

Formula types:
The Formula types are created by products like Benefit (BEN), Compensation (COMP), and Payroll (PAY). This is giving a name to a group of formulas. The name will help in identifying which product the formula is being used and where it is used.
Some examples are given below:
Extract record ,Extract rule ,Legislative check ,Net to gross
Compensation Person Selection:  This formula type is from Compensation (COMP) and is used to validate the person selection in Compensation and Total Compensation (TCS) process.
Participation and Rate Eligibility:  This formula type is from Benefit (BEN) and is used in COMP, BEN, TCS and ABS to determine the eligibility of a person.
Total Compensation Item: This formula type is from Total Compensation (TCS) and is used to create or calculate a value for total compensation items.

#### Context:

Context is a very important part of Fast Formula. This is defined for a Formula Type. Different Formula Types support different set of Context.  You can find the contexts that are supported by a formula type from the documentation of individual products like COMP, BEN etc.

The value to the context is set by the application when the fast formula is executed.
For example, the Compensation (COMP) sets the value to context like PERSON_ID, ASSIGNMENT_ID etc while executing the Fast Formula.

The context behaves like a value to the bind variable of a SQL.
For example, let us take the SQL statement,
“Select Full_name from PERSON_TABLE where person_id =  :P_ID”

In this SQL, P_ID is a bind variable and the value for the bind variable is provided by the Context, PERSON_ID.  The value to the context PERSON_ID is set by the application while executing the Fast Formula. In Fusion, Fast Formula developer can also set the value using method SET_CONTEXTS provided the Fast Formula type supports the Context.
Related methods for the context are:
GET_CONTEXT : To find the value from the context
CONTEXT_IS_SET: To find whether a context is set
SET_CONTEXTS: to set one or more contexts

#### Database Items (DBI):

DBI is similar to a single data or a value from a column or a set of values (Array).  In Fusion, you cannot write a meaningful fast formula without using DBI. DBI provides values from the database tables. The source of the DBI is called Route.  Route is similar to a “from and where” clause of a SQL statement.

For example of Route: “FROM  PERSON_TABLE WHERE  PERSON_ID =  :PID”.
For this Route, there could be many DBIs like Full_Name, First_Name, Last_Name, Date_of_Birth etc…

DBI          = Select clause                                  =   Select person_id, full_name, date_of_birth
Route       = From clause and Where clause      =   FROM Person_TABLE where person_id = :P_ID
Context    = Value for binding variables           =   PERSON_ID     = 000001

The number of DBI (Database items) supported by a Formula type depends on the context provided by the Formula type.

For example, if a Formula type supports context PERSON_ID and EFFECTIVE_DATE, the formula type can use all the DBI from person level. If it also supports ASSIGNMENT_ID and EFFECTIVE_DATE, it can use the DBI from Employment (Assignment) too.

#### Input Values:

Input values are additional values/information that are passed by the individual applications to the Fast Formula to assist the Formula developers while executing the Fast Formula. This information can be collected from individual application’s documentation.
For example,
Plan Start Date and Plan End Date are input values of Compensation Plan Setup.
Period Start Date and End Date are input values of Total Compensation Statement.

#### Return Variables/Values:

Most of the Formula types do not care about the return variables. There are some exceptions where some Fast Formulas expect to return more than one value.  Therefore, the variable has to be set as per the documentation. In these cases, the formula will not work as expected if the return variables are not correct. In some other cases, even if there is one return value, it needs to be a specific return variable.
For example,
Total Compensation Item Fast Formula expects the return variable, “COMPENSATION_DATES,VALUES, ASSIGNMENTS,LEGALEMPLOYERS.”
Benefit Eligible fast formula expects the return variable, ELIGIBLE.
In some cases, the formula type expects certain values. For example, Benefit Eligible and Compensation Person Selection Fast Formula types expect either a ‘Y’ or ‘N’.

Mostly, the dates are returned in “YYYY/MM/DD” format.