Overview of Writing Formulas

Writing fast formulas enables you to perform a wide variety of tasks using English words and basic mathematical functions. There are several techniques that you can use to ensure your formulas are easy to read, use, and understand.

You write fast formulas to validate or calculate data for payroll and other Oracle Fusion applications.

This table lists the key aspects of writing fast formulas.

Key Aspects

Description

Using the expression editor

Use the expression editor with these formula types:

  • Deduction component groups

  • Deduction component detail groups

  • Payroll relationship groups

  • Work relationship groups

Use these formula types when creating dynamic object groups. Object groups define subsets of deduction components or people for processing or reporting.

Using formula text

Most formula types use the text editor to define formulas. The text editor is more flexible than the expression editor. Here's what you can do with the text editor:

  • Add database items applicable to the formula type

  • Use functions to manipulate data

  • Use user-defined global values

Database items are read-only variables that you can use to get application data without having knowledge of the underlying data model, and writing queries to get the data.

The input values that you have passed and the output values returned depend upon the context in which you're using the formula. The names and types of these values are defined in many scenarios, so refer the appropriate product documentation.

Improving performance

Here's what you can do to improve performance:

  • Shorten your formulas.

  • Don't refer to database items until needed.

  • Use an ALIAS instead of assigning a database item to a local variable.

  • Use input statements instead of database items.

  • Leave a WHILE loop as early as possible.

  • Limit use of CHANGE_CONTEXT blocks.

  • Change as many contexts as possible in one CHANGE_CONTEXTS block instead of having CHANGE_CONTEXTS blocks inside other CHANGE_CONTEXTS blocks.

  • Don't use CHANGE_CONTEXTS to set contexts that you would reasonably expect to be set already, and aren't going to change.

  • Use the database item that would retrieve the required data. Some database items are used in reporting, and are unsuitable for use in formulas because they return a lot of inefficient data. Avoid these database items in formulas because they require more complex formulas to get the required data, and they make performance worse.

Avoiding compilation errors

Compile a modified formula before using it. Here's what you can do to avoid common compilation errors:

  • Look for syntax errors, such as using IF1 instead of IF.

  • Ensure that the statement order is correct. For example ALIAS, DEFAULT, or INPUT statements come after other statements.

  • Don't misuse assignment statements by assigning a value to a database item.

  • Don't misuse the ALIAS statement. It can only be used for database items.

  • Don't misuse DEFAULT statements. You must specify a DEFAULT statement for a variable other than an input or database item.

  • Look out for missing DEFAULT statements. Database items that have a default value specified must contain a DEFAULT statement.

Avoiding execution errors

Here's what you can do to avoid common execution errors:

  • Ensure that variables are initialized. For example, a variable initialized inside an IF block might be initialized when it's used.

  • Verify that your formula calculations won't end up dividing a number by zero.

  • Ensure that the formula compiler can find the data.

  • Ensure that the value that your formula generates doesn't exceed the permissible range.