ERPWebTutor confidential
Oracle Fast Formula
Training – Part 3
An ERPWebTutor Presentation
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Section 3 – Writing Fast Formulas
• Formula Structure • Comparators
• Calculation Section • Checking for Defaults
• Assignment Statement • Nested If Statements
• Return Statement • Functions
• Other Statements • User Tables
• Adding Comments • Lookup Values
• Fast Formula Compiler • User Defined Formulas
• IF Statement
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Formula Structure
Formulas are linear and do not loop
They are run from the top,
in sequence, until Fast Formula
reaches a Return statement
RETURN ...
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Formula Structure
alias grade_hourly_rate_value 1. Alias statement
as hourly_rate
default for hours_worked is 0
2. Default
default for statement
grade_hourly_rate_value is 25
inputs are hours_worked 3. Inputs
wage = hours_worked * 4. Calculation
hourly_rate section
return wage 5. Return
Statement
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Calculation Section
The core of the formula, where values are calculated or
validated
Includes assignment statements, such as:
time_available = accrued_PTO - amount_over_ceiling
May include IF statements for conditional processing, such as:
IF amount_over_ceiling > accrued_PTO THEN
time_available = 0
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Assignment Statement
The left hand side of an assignment statement is a local
variable
The right hand side can contain constants or variable of the
same data type
Examples:
salary = annual_salary/12
message = ‘This value exceeds the
maximum‘
Note: Always assign a value to a local variable before you use it
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Return Statement
Calculation results can be passed back to the application
using the RETURN statement
Many values can be returned from a formula with a single
Return statement:
RETURN value1, value2, … and so on
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Formula Statements
Alias <x> as <y>
Default for <a> is <b>
Inputs are <1>, <2>, ….
Assignment
If …. Then(…) Else(…)
Return <R1>, <R2>, ….
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Comments
Use comments to explain what your formula does
You can put comments anywhere in your formula
Start the comment with /* and end with */
Use white space and indentation, as well as comments, to
make your formulas easier to read and understand
Do not put a comment within a comment
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
FastFormula Compiler
When you have written a formula, you compile it by choosing
the Verify button on the Formula window
The compiler:
Checks syntax
Interprets database items
Interprets functions
Produces executable PL/SQL
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
If Statement
IF clause
THEN clause
ELSE clause
For example:
IF age < 20
THEN training_allowance = 30
ELSE training_allowance = 0
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Conditions
Simple conditions compare a variable with a constant
IF salary > 20000
You can also combine variables using arithmetical operators
and compare them to constants or other variables
IF (total_accrued_time + time_carried_forward + time_bought
> ceiling)
You can combine conditions using the logical operators AND,
OR, NOT
IF (years_service > 15) AND (long_service_accrual = 0)
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Multiple Actions Example - No Brackets
INPUTS ARE acct_balance, account (text),
debit_amt
IF acct_balance >= debit_amt
THEN
new_balance = acct_balance - debit_amt
message = ‘Full amount deducted.’
RETURN new_balance
Executed
unconditionally
ELSE Never gets here!
message = ‘Account number ‘ + account +
‘ has insufficient funds.’
RETURN message
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Comparators
Use comparators to compare variables with constants or
other variables
Examples:
Equals--Text expressions must be in the same case, so
‘Smith’ does not equal ‘SMITH’
Greater than--The first expression must be
alphabetically after, or numerically greater, or a later
date than the second expression
= > <
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Checking for Defaults
If <variable> Was Defaulted then ….
Use the Was Defaulted test to check whether a database
item or input is null
For example, you might want to check whether there is a
termination date or continuous service date on record for an
employee
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Nested IF Statements
You can nest an IF statement within a THEN or ELSE clause
IF NOT termination_date WAS DEFAULTED
THEN
(
early_end_date = termination_date
IF (early_end_date < first_period_end_date)
THEN
accrued_pto = 0
)
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Functions
Oracle Fast Formula comes supplied with a number of
functions that make it easier to perform common
calculations or transformations of data
Examples:
Rounding numbers to two decimal places
Converting dates to the text data type so they can be
used in messages
Functions are also supplied for accessing data from user
tables and translating lookup codes into meanings
You can create your own functions using PL/SQL then
register them with Oracle FastFormula
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Example Functions
greatest add_years
least days_between
floor months_between
round to_text
trunc num_to_char
add_days to_date
add_months to_number
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Example Functions
greatest add_years
least days_between
floor months_between
round to_text
trunc num_to_char
add_days to_date
add_months to_number
annual_leave = 20 + FLOOR(years_service/2)
bonus = (monthly_salary * (bonus_percentage/100))
* MONTHS_BETWEEN(calculation_date, start_date)
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
User Tables
User tables are matrixes of information that can be
accessed using Oracle Fast Formula
Some user tables are predefined for each legislation
You can define as many additional user tables as you
require
Examples
Location allowance against locations
PTO accrual entitlement by grade or job
Shift differentials (normal shift against shift worked)
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
GET_TABLE_VALUE Function
Use the GET_TABLE_VALUE function in a formula to access
user table values
GET_TABLE_VALUE
The required format is:
GET_TABLE_VALUE(table_name, column_name,
row_value [,effective date])
The effective date parameter is optional
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
User Table Example
Yearly PTO Accrual
Years Service Grade A Grade B
0-5 20 22
6 - 10 22 24
10 - 50 25 26
yearly_accrual =
GET_TABLE_VALUE(‘yearly_pto_accrual’, ‘Grade A’, 6)
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
GET_LOOKUP_MEANING Function
Use this function when you want Oracle FastFormula to
translate a lookup code into a meaning
The required format is:
GET_LOOKUP_MEANING(lookup_type, lookup_code)
GET_LOOKUP_MEANING(‘eth_type’, ‘people_gb_ethnic_origin’)
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
User-Defined Functions
Create your own PL/SQL functions and register them with
Oracle Fast Formula using the Define Function window
When you register the function, specify the contexts
and parameters it requires
Functions used in Oracle Fast Formula must not have any
commit, rollback, or savepoint statements
Fast Formula is a read-only tool
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Compiling Formulas
Normally you compile a formula by choosing the Verify
button on the Formulas window
You can recompile all formulas (for example, after an
upgrade) by running the Bulk Compile Formulas process (
FFXBCP )
If you edit a user-defined function, you must recompile all
formulas that use the function
[Link]
ERPWebTutor confidential
Introduction to Fast Formula
Summary
Section 3 - Writing Fast Formulas
• Fast Formulas are linear and do not Loop. They Run upto
Return Statement.
• Basic statements like Inputs, Defaults, Aliases, IF and Return
Statements can be used.
• Local Inputs, Database Items and Global Values can be used in
Fast Formulas.
• Pre-defined Functions, Values from User Tables and Meanings
from Lookup Codes can also be accessed in Fast Formula.
[Link]
ERPWebTutor confidential
The New Beginning….
Fast Formula will never be scary any
more!!!!!!
Visit us at [Link]
[Link]