0% found this document useful (0 votes)
74 views5 pages

Fast Formulas: Using Arrays in Fusion

The document explains the use of Arrays in Fast Formulas, detailing their types, attributes, and various applications such as Input Values, DBI, Variables, and Return Values. It outlines the syntax for declaring Arrays and provides examples of functions to manipulate them, along with a sample Fast Formula demonstrating these concepts. Additionally, it emphasizes the importance of proper validation and handling of Array DBIs to avoid performance issues.

Uploaded by

balasuk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views5 pages

Fast Formulas: Using Arrays in Fusion

The document explains the use of Arrays in Fast Formulas, detailing their types, attributes, and various applications such as Input Values, DBI, Variables, and Return Values. It outlines the syntax for declaring Arrays and provides examples of functions to manipulate them, along with a sample Fast Formula demonstrating these concepts. Additionally, it emphasizes the importance of proper validation and handling of Array DBIs to avoid performance issues.

Uploaded by

balasuk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Fast Formulas and Arrays

 Fast Formula uses Arrays, the return values are passed as name and value pair of Arrays.
 Arrays can be used in
1. Input Values
2. DBI
3. Variables
4. Return values.
Different types of Arrays.
 Arrays are defined with two attributes:
1. Type of Value - indicates the value type (Number, Date or Char) stored in the Array.
2. Type of Index - indicates how the Array is indexed.
 The following options are available for defining an Array in Fusion Fast Formula.
Array Type Meaning
DATE_NUMBER Date value and number index Array
DATE_TEXT Date value and text index Array
NUMBER_NUMBE Number value and number index Array
R
NUMBER_TEXT Number value and text index Array
TEXT_NUMBER Text value and number index Array
TEXT_TEXT Text value and text Index Array
Usage of Arrays:
Input Values:
 There are many products in Fusion that pass the Input Values as Array.
 For example, Total Compensation Statement (TCS) process the data at a person level. Therefore, when the
Fast Formula is executed for a person, it sets the primary Assignment Id as Context, HR_ASSIGNMENT_ID.
 In case if the person has more than one assignment, it passes all the assignments as Array to the Fast
Formula so that the formula can use the Assignments to process the data.
 The syntax for declaring the Array Input Value is:
INPUTS ARE CMP_IVR_ASSIGNMENT_ID (NUMBER_NUMBER)
 You can also default the Array with an empty Array as follows.
DEFAULT for CMP_IVR_PAY_ASSIGNMENT_ID is EMPTY_NUMBER_NUMBER
 To find the Array input values, you need to check the documentation of each of the products.
Array DBI/ range DBI
DBI:
 The Array DBI is also called range DBI.
 Every product in HCM has seeded these Array DBIs.
 It looks like the Array DBIs are more popular than the conventional ones in Fusion.
The Array DBIs are declared and defaulted as follows
DEFAULT_DATA_VALUE FOR PER_HIST_ASG_EFFECTIVE_START_DATE IS '1900/01/01 [Link]' (date)
 If the Array DBI is not handled in a proper manner, it may lead to a performance issue.
 Since the Array DBI holds a range of data, you will need to implement the proper validation to get the
desired results.
Variables:
 The variables are like any other Array, the only difference is how you declare them.
 You can declare the variable Array as follows.
DEFAULT FOR COMPENSATION_DATES is EMPTY_TEXT_NUMBER
Return values:
Fast Formula engine allows returning Array variables provided the Formula Type supports it.
The Product that executes the Formula determines whether the Array variables that are returned from Fast
Formula are supported. As far as I know, in Compensation product, TCS supports Arrays for their Formula
Type, “Total Compensation Item” in their latest release. (please check the documentation for the availability).
Fast Formula has provided the following functions to handle the Arrays.
Function Syntax Meaning
Return the count of an Array elements
COUNT <Array> .COUNT
Example: l_count = l_array.count
Delete a element from the Array
<Array>. DELETE( <index
DELETE Example: l_array.delete(2) or l_array.delete(‘TWO’) depending on
value> )
the index type of the Array.
Delete all the elements.
DELETE <Array>. DELETE()
Example: l_array.delete()
<Array>. EXISTS ( <index If a value exists at an index of an Array. It returns a Boolean.
EXISTS
value> ) Example: if l_array.exists(1) then
Returns first index of an Array. If there are no elements, then
<Array>.FIRST( <default value>
FIRST return the default value.
)
Example: l_index = l_array.first(-1)
< Array>.LAST (<default Returns last index of an Array. If there is no elements then returns
LAST value>) the default value.
Example: l_index = l_array.last(-1)
< Array>.NEXT (<index>, Returns the next index of the index parameter. If there is no next
NEXT <default value>) element, returns default value.
Example: : l_index =l_array.next(l_index, -1)
< Array>.PRIOR (<index>, Returns the previous index of the index parameter. If there is no
PRIOR <default value>) previous element, returns default value.
Example: l_index =l_array.prior(l_index, -1)
To get/set a value from/to an Array element.
Array[<index>] Example: L_number = l_array[100]
l_array[100] = L_number
Sample Fast Formula to handle Arrays:
/*
Author : Tilak-Lakshmi
Name : TCS_ITEM_ARRAY_TEST
Type : Total Compensation Item
Purpose : Example of using Array DBI, input values and return variables. This formula returns changed salary
of every assignment.
*/
/*Defaulting DBI */
DEFAULT_DATA_VALUE FOR CMP_ASSIGNMENT_RGE_SALARY_CHANGE_AMOUNT IS 0

/* Defaulting Input Values and variables*/


DEFAULT for CMP_IVR_ASSIGNMENT_ID is EMPTY_NUMBER_NUMBER
DEFAULT FOR COMPENSATION_DATES is EMPTY_TEXT_NUMBER
DEFAULT FOR VALUES is EMPTY_TEXT_NUMBER
DEFAULT FOR ASSIGNMENTS is EMPTY_TEXT_NUMBER
/* Declaring Input Values */
INPUTS ARE CMP_IV_PERSON_ID , CMP_IV_PERIOD_START_DATE(DATE), CMP_IV_PERIOD_END_DATE (DATE),
CMP_IVR_ASSIGNMENT_ID(NUMBER_NUMBER) , CMP_IVR_TERM_ID(NUMBER_NUMBER),
CMP_IVR_PAY_ASSIGNMENT_ID (NUMBER_NUMBER), CMP_IVR_PAY_TERM_ID(NUMBER_NUMBER),
CMP_IVR_PAY_RELATION_ID(NUMBER_NUMBER)

l_data= ESS_LOG_WRITE( 'ENTERING TCS_ITEM_ARRAY_TEST ' )

/* Get the first index of assignment */


index = CMP_IVR_ASSIGNMENT_ID.FIRST(-1)
l_data= ESS_LOG_WRITE( ' first index ' + TO_CHAR(index ))
l_counter = 1

/* Loop through the assignments */


WHILE (CMP_IVR_ASSIGNMENT_ID.EXISTS(index))
LOOP (
l_data= ESS_LOG_WRITE( ' asg ' + TO_CHAR( CMP_IVR_ASSIGNMENT_ID[index]) )

/*Set the context to assignment id */


CHANGE_CONTEXTS(HR_ASSIGNMENT_ID= CMP_IVR_ASSIGNMENT_ID[index] )
(
l_asg = CMP_IVR_ASSIGNMENT_ID[index]
l_data= ESS_LOG_WRITE( ' ASG CONTTEXT IS SET ' + TO_CHAR(l_asg))

/* get salary index and loop through the Array */


l_sal_indx = CMP_ASSIGNMENT_RGE_SALARY_CHANGE_AMOUNT.FIRST(-1)
WHILE (CMP_ASSIGNMENT_RGE_SALARY_CHANGE_AMOUNT.EXISTS(l_sal_indx ) )
LOOP (
if (CMP_ASSIGNMENT_RGE_SALARY_CHANGE_AMOUNT[l_sal_indx] <> 0 ) THEN
(
COMPENSATION_DATES[l_counter]= TO_CHAR(CMP_IV_PERIOD_START_DATE,'YYYY/MM/DD')

ASSIGNMENTS[l_counter] = TO_CHAR(l_asg)
VALUES[l_counter] = TO_CHAR( CMP_ASSIGNMENT_RGE_SALARY_CHANGE_AMOUNT[l_sal_indx])
l_counter = l_counter + 1
)
l_sal_indx = CMP_ASSIGNMENT_RGE_SALARY_CHANGE_AMOUNT.NEXT(l_sal_indx , -1)
)
)
index = CMP_IVR_ASSIGNMENT_ID.NEXT(index ,-1)
)
l_data= ESS_LOG_WRITE( ' LEAVING TCS_ITEM_ARRAY_TEST ' )
RETURN COMPENSATION_DATES, VALUES, ASSIGNMENTS
Explanation of the Formula:
When declaring an Array DBI, please note the syntax. It is a little different than the normal DBI declaration.
DEFAULT_DATA_VALUE FOR CMP_ASSIGNMENT_RGE_SALARY_CHANGE_AMOUNT IS 0

We use the same syntax to default the Input Values and for declaring/defaulting variables.
DEFAULT FOR CMP_IVR_ASSIGNMENT_ID is EMPTY_NUMBER_NUMBER
DEFAULT FOR COMPENSATION_DATES is EMPTY_TEXT_NUMBER
DEFAULT FOR VALUES is EMPTY_TEXT_NUMBER
DEFAULT FOR ASSIGNMENTS is EMPTY_TEXT_NUMBER

The Input Values are declared as below.


INPUTS ARE CMP_IV_PERSON_ID, CMP_IV_PERIOD_START_DATE(DATE),
CMP_IV_PERIOD_END_DATE (DATE),
CMP_IVR_ASSIGNMENT_ID(NUMBER_NUMBER) , CMP_IVR_TERM_ID(NUMBER_NUMBER),
CMP_IVR_PAY_ASSIGNMENT_ID (NUMBER_NUMBER), CMP_IVR_PAY_TERM_ID(NUMBER_NUMBER),
CMP_IVR_PAY_RELATION_ID(NUMBER_NUMBER)

To loop through the Array, whether it is DBI or Input Values; we need to identify the index type.
In our example, all the Arrays are indexed by number.
We can identify the index type from the document or the DBI list from the Fast Formula UI.

Once we know the index type, we need to identify the first index.
Many developers use 1 as starting index but I prefer to get the first index from the Array itself.
In the .FIRST method, we use -1 as default value. In case there is no element in the Array, the method will
return the default value, -1.

index = CMP_IVR_ASSIGNMENT_ID.FIRST(-1)
l_data= ESS_LOG_WRITE( ' first index ' + TO_CHAR(index ) )
l_counter = 1
In the loop, we iterate as long as an element exists.
We use the .EXISTS method to find the existence of the element for an index.

/* Loop through the assignments */


WHILE (CMP_IVR_ASSIGNMENT_ID.EXISTS(index))
LOOP (

We get the assignment id and set the Context, HR_ASSIGNMENT_ID with the assignment id, so that the DBI for
the Assignment Id can be used.
/*Set the Context to the Assignment Id */
CHANGE_CONTEXTS(HR_ASSIGNMENT_ID= CMP_IVR_ASSIGNMENT_ID[index] )
(
l_asg = CMP_IVR_ASSIGNMENT_ID[index]
l_data= ESS_LOG_WRITE( ' ASG CONTTEXT IS SET ' + TO_CHAR(l_ASG) )

In the following code, we get the salary changes for the assignment and then assign the value in the Array
variables.
l_sal_indx = CMP_ASSIGNMENT_RGE_SALARY_CHANGE_AMOUNT.FIRST(-1)
WHILE (CMP_ASSIGNMENT_RGE_SALARY_CHANGE_AMOUNT.EXISTS(l_sal_indx ) )
LOOP (
if ( CMP_ASSIGNMENT_RGE_SALARY_CHANGE_AMOUNT[l_sal_indx] <> 0 ) THEN
(
COMPENSATION_DATES[l_counter]= TO_CHAR(CMP_IV_PERIOD_START_DATE,'YYYY/MM/DD')
ASSIGNMENTS[l_counter] = TO_CHAR(l_asg)
VALUES[l_counter] = TO_CHAR( CMP_ASSIGNMENT_RGE_SALARY_CHANGE_AMOUNT[l_sal_indx] )
l_counter = l_counter + 1
)

Get the next index for the DBI and Input values to move to the next element.
l_sal_indx = CMP_ASSIGNMENT_RGE_SALARY_CHANGE_AMOUNT.NEXT(l_sal_indx, -1)
)
index = CMP_IVR_ASSIGNMENT_ID.NEXT(index ,-1)
)
l_data= ESS_LOG_WRITE( ' LEAVING TCS_ITEM_ARRAY_TEST ' )
RETURN COMPENSATION_DATES , VALUES,ASSIGNMENTS

Common questions

Powered by AI

Fast Formula provides several functions for managing arrays, such as COUNT to retrieve the count of elements, DELETE to remove specific elements or all, EXISTS to check if an index exists, FIRST and LAST to find the first and last indices, and NEXT and PRIOR to move between indices. These functions facilitate comprehensive array management by enabling manipulation of array data, handling of dynamic indexing, and efficient loop constructions within fast formulas .

The "Total Compensation Item" type in Fusion's Fast Formula supports arrays, allowing complex data processing within compensation-related calculations. By supporting arrays, this formula type can handle multiple values simultaneously such as different compensation components for assignments. This ability enhances the customization and depth of compensation calculations, as arrays can store and retrieve multiple data entries efficiently, leading to sophisticated and nuanced compensation management .

The CHANGE_CONTEXTS function within the Fast Formula loop is crucial for setting the operational context of the formula to the current assignment id. By associating HR_ASSIGNMENT_ID with CMP_IVR_ASSIGNMENT_ID[index], the function ensures that any operations, such as data retrieval and processing within the loop, are relevant to the current assignment data. This context-switching capability allows precise control over which assignment data the formula processes during each iteration, facilitating accurate and contextually-appropriate data manipulation .

Developers can determine the first index of an array by using the .FIRST method, which returns the first index of an array, taking a default value if the array is empty. This is done by employing syntax such as 'index = CMP_IVR_ASSIGNMENT_ID.FIRST(-1)'. Knowing the first index is crucial for effectively looping through arrays, particularly in cases where the array indexing may not start at 1, helping avoid errors and ensure robust data handling .

In Fusion Fast Formula, array variables are declared by specifying the type of value and index. For example, a variable array can be declared using syntax like 'DEFAULT FOR COMPENSATION_DATES is EMPTY_TEXT_NUMBER', indicating that it stores text values indexed by numbers. Defaulting these arrays involves setting an initial state or value which might be empty, as demonstrated by the use of 'EMPTY' in the declaration .

When utilizing Array DBIs in Fusion applications, it is essential to implement proper validation to ensure data integrity and avoid performance issues. Array DBIs, which store a range of data, may result in inefficiencies or slowdowns if not managed correctly. Ensuring that the array's contents are validated and optimized for retrieval can significantly impact performance. Using appropriate default values and ensuring relevant data indexing also play vital roles in maintaining efficient processing .

Arrays in Fusion Fast Formula significantly enhance the processing of input values by allowing the formula to handle multiple data points simultaneously. For instance, in Total Compensation Statements, an individual's assignments are processed at a person level. If an individual has multiple assignments, these are passed to the formula as an array, enabling processing across all assignments collectively. This not only optimizes data handling but also ensures comprehensive and efficient data processing in scenarios such as multi-assignment contexts .

A Fast Formula can loop through assignment arrays by first determining the starting index using the .FIRST method. For example, 'index = CMP_IVR_ASSIGNMENT_ID.FIRST(-1)' sets the initial index. The loop then proceeds by checking the existence of each index element using .EXISTS. Within the loop, context for each assignment is set, 'CHANGE_CONTEXTS(HR_ASSIGNMENT_ID = CMP_IVR_ASSIGNMENT_ID[index])', enabling the formula to process each assignment's data, such as salary changes. The subsequent salary change values are evaluated and stored in array variables, moving to the next element with .NEXT method, effectively iterating through the assignments .

The NEXT function in an array aids in iterating through indexes by returning the subsequent index of a given index. If there is no next element, it returns a specified default value, ensuring the loop can terminate gracefully at the end of an array. A typical default value used is '-1', as demonstrated in 'l_index = l_array.next(l_index, -1)'. This usage allows seamless iteration over arrays without out-of-bound errors when the array is exhausted .

Fusion Fast Formula supports various types of arrays based on combinations of value and index types. These include DATE_NUMBER (Date value and number index), DATE_TEXT (Date value and text index), NUMBER_NUMBER (Number value and number index), NUMBER_TEXT (Number value and text index), TEXT_NUMBER (Text value and number index), and TEXT_TEXT (Text value and text index). Each array type serves a specific purpose depending on the type of value it stores and how the array is indexed .

You might also like