Showing posts with label Fast Formula. Show all posts
Showing posts with label Fast Formula. Show all posts

Wednesday, April 28, 2010

Practice Notes: Payroll Fast Formula

Fast formulas exist not only for payroll calculation but also for many other purposes. One of them being input value validation i.e. using these type of formulas we will be able to validate the screen entry values of element's input values.

We can add these validations against particular elements in

Form Functions(ctrl + L) -> element entries

Here search for the person and select the element's entry value button and in the popup form, horizontal scroll to formula text box and from the LOV select the formula which validates the screen entries against this input value.

Such custom formula can be created in

Form Functions(ctrl + L) -> write formula

Create the formula with formula type as Element Input Validation. A very useful article on element input validation formulas can be found in oracle manual here.

Two basic rules for writing an input value validation formula are
  1. There should be only one INPUT for the formula named ENTRY_VALUE of text data type i.e. INPUTS are entry_value(text)
  2. entry_value input can be converted to number types using to_num conversion functions for any validation
  3. There should be a mandatory return parameter called formula_result that can take either ‘S’ (success) or ‘E’ (error)
Let us consider an example of validating an entry value which must be atleast 10 i.e. consider an HRA element where we will be using this validation to enforce a rule that the employee gets a minimum of 10% HRA. A simple formula validation may be as follows

INPUTS are Entry_Value(text)
FORMULA_RESULT = ‘S’
IF TO_NUM(Entry_Value) < 10 THEN
(
FORMULA_RESULT = ‘E’
FORMULA_MESSAGE = ‘Entry Value must be minimum 10 and above’
)
RETURN FORMULA_RESULT, FORMULA_MESSAGE

After attaching this above formula against hra_pct of test_hra and when used for an employee, the above validation is fired whenever we enter some screen entry value for the hra_pct. Notice that when hra_pct value entered is less than 10, application throws error from the formula_message but eventually saves the transaction.

The formula validation we try to do will merely give warning to the user and no way prevent one from overriding the formula validation.

Friday, April 23, 2010

Short Writeup: Fast Formula - Overview

Oracle Fast Formula can be written using formula form found in

Navigation -> Total Compensation -> Basic -> Fast Formula -> Write Formula

Once written, usually Fast formulas are attached to elements of Payroll for any computation. But FF can be of any type including payroll, accruals etc.

Different Components of Fast Formulas:
  1. Input Statement
  2. Assignment Statements
  3. Return Statements
Data Types:
There are three types of data available in fast formula. They are text, numeric and date types. By default a variable is of numeric type. If the data type is not numeric then it must be specified like

INPUTS are x,y (date),z (text)

Fast Formula Variables:
Fast formula variables are of three types. Local, Global and database variables.

Variables usually get their values when values are input to them during a formula call or through database objects.

Formula Structure:
A simple formula may look like this with input, assignment and return statements.

INPUTS are x,y

x = y + 1

RETURN x

Note:
  • RETURN statement is used to return the specific value to outside usually a payroll run
  • There can be many RETURN statement in a formula but only one INPUTS statement is allowed in a formula
  • Values of input variables can not be changed
  • When the element input value is passed to the formula, the input name must be same as that of the input values of the element and the multiple words must be joined by an underscore.
Contexts:
Contexts are similar to environment variables. Since fast formulas are attached to elements, the contexts change for each assignment. Typical context info include
  • Business group
  • Element and element links
  • Employee and his assignments
Order of processing:
Calculation begins from inner most braces starting left to right.

Conditional Statements:
We can use If-else statement like we use it in any other languages.

IF THEN
(
statements
)
ELSE
(
statements
)

Here we can use the normal conditional operators and logical operators(AND,OR,NOT). There is one more clause called 'WAS DEFAULTED' which when used in if condition, results in true condition if the particular value passed is null.
For eg.

DEFAULT for x is 10

IF x WAS DEFAULTED THEN
(
statements
)
ELSE
(
statements
)

When no value/null value is passed to x then the condition evaluates to TRUE oterwise FALSE.

Comments:
The commenting is similar to that of pl/sql and C++
/* Comments */

Aliases:
The database items are often longer and referencing them in formulas becomes tedious without aliases.
ALIAS database_name AS alias_name

Fast Formula Functions:
FF Functions can be of following types.
  • Text Functions
  • Numeric Functions
  • Date Functions
  • Data conversion Functions
  • NULL Functions
Database items:
Database items are the procedures that exist in database. These items can be referenced in fast formula to arrive at the result values. There are two types of database items.

  1. Static DB Items: are predefined and include standard type of information. For example, date of birth of an employee.
  2. Dynamic DB Items: are generated by the definitions of elements, balances, absence types, flex field segments etc. For example, for each of the input value entry of an element one DB Item is created with preceding element name.