You are on page 1of 13

Array Processing Formulas

Oracle Fusion Time and Labor

February 07, 2020 | Version 1.00


Copyright © 2021, Oracle and/or its affiliates
Confidential: Public
PURPOSE STATEMENT
This document provides an overview of features and enhancements included in release 13.20.04.01 It is intended solely to
help you assess the business benefits of upgrading to 13.20.04.01 and to plan your I.T. projects.

DISCLAIMER
This document in any form, software or printed matter, contains proprietary information that is the exclusive property of
Oracle. Your access to and use of this confidential material is subject to the terms and conditions of your Oracle software
license and service agreement, which has been executed and with which you agree to comply. This document and
information contained herein may not be disclosed, copied, reproduced or distributed to anyone outside Oracle without
prior written consent of Oracle. This document is not part of your license agreement nor can it be incorporated into any
contractual agreement with Oracle or its subsidiaries or affiliates.
This document is for informational purposes only and is intended solely to assist you in planning for the implementation
and upgrade of the product features described. It is not a commitment to deliver any material, code, or functionality, and
should not be relied upon in making purchasing decisions. The development, release, and timing of any features or
functionality described in this document remains at the sole discretion of Oracle.
Due to the nature of the product architecture, it may not be possible to safely include all features described in this document
without risking significant destabilization of the code.

1 Technical Brief | Array Processing Formulas | Version 1.00


Copyright © 2021, Oracle and/or its affiliates | Confidential: Public
TABLE OF CONTENTS
Purpose Statement 1
Disclaimer 1
Time and Labor Array Processing Formulas Compared with Normal Formulas 3
Main Difference 3
Output 3
Why Use Normal Formula? 3
Difference in Rule Template 3
Samples 3

Delivered AP and Normal WFM_THRESHOLD_TIME_CALCULATION_RULE


FORMULAS 4
Formula: WFM_THRESHOLD_TIME_CALCULATION_RULE_AP 4
Formula: WFM_THRESHOLD_TIME_CALCULATION_RULE 8

2 Technical Brief | Array Processing Formulas | Version 1.00


Copyright © 2021, Oracle and/or its affiliates | Confidential: Public
TIME AND LABOR ARRAY PROCESSING FORMULAS COMPARED WITH NORMAL
FORMULAS
Time and Labor introduced array processing (AP) formulas in Release 10. Array processing functionality gives you more
flexibility and better performance when defining and using formulas and rules. All formulas ending in _AP are array
processing formulas. All formulas without this suffix are normal formulas.

Main Difference
With normal fast formulas, the rule-processing engine calls the formula for each day and detail time entry on the time card.
Each call passes information about only a single entry to the formula. With AP fast formulas, the rule-processing engine calls
the formula only once. The single call passes all relevant time attributes for the entire time card. This behavior significantly
reduces the number of calls to the middle tier and improves processing performance. Also, AP formulas are flexible and
enable you to loop through time card data in various ways, with more control over the process.

Output
AP formula output returns values in an array format for the entire time card. Normal formula output returns values one
record at time. The results are the same for the AP and normal formulas.

Why Use Normal Formula?


Normal formulas are supported for backward compatibility. In some cases, normal formulas are easier to write and
understand, especially if you're just learning how to code formula. All formulas delivered since Release 10 are AP formulas.

Difference in Rule Template


You define AP and normal formulas and use them in rule templates the same. The rule template handles all necessary
changes in the background.

Samples
These delivered formulas and rule templates, composed of these formulas, are perfect examples of AP and normal formulas
and templates. They both generate the same result:

OBJECT DELIVERED ARRAY PROCESSING VERSION DELIVERED NORMAL VERSION

Formula WFM_THRESHOLD_TIME_CALCULATION_RULE_AP WFM_THRESHOLD_TIME_CALCULATION_RULE

Rule template Daily Threshold AP Template Daily Threshold Template


Weekly Threshold AP Template Weekly Threshold Template

3 Technical Brief | Array Processing Formulas | Version 1.00


Copyright © 2021, Oracle and/or its affiliates | Confidential: Public
DELIVERED AP AND NORMAL WFM_THRESHOLD_TIME_CALCULATION_RULE
FORMULAS

Formula: WFM_THRESHOLD_TIME_CALCULATION_RULE_AP

/* +======================================================================+
| Copyright (c) 2009 Oracle Corporation |
| Redwood Shores, California, USA |
| All rights reserved. |
+======================================================================+
*
* Formula Name : WFM_THRESHOLD_TIME_CALCULATION_RULE_AP
*
* Formula Type: Time Calculation rule
*
*
* Description: Divides reported daily or period time into calculated
* time attributes for hours above and below defined
* threshold hours. Reported time and specific time attribute
* results are inputs to the delivered formula. This formula
* uses an array to process time card data.
*
* Detail: Compares the total time category hours for the day or
* period to the threshold value. Hours above the threshold
* are converted to a single pay time type. Hours under the
* threshold either remain the same pay time type value or
* are converted into a new pay time type attribute.
*
*
*
* Change History
* --------------
*
* Who Ver Date Description Default input values are set
as Array Data type
*----------------- ------ ------------ -----------------------------------------
EMPTY_TEXT_NUMBER,
* David Cohanoff 206.12 2013-FEB-10 Created.
EMPTY_DATE_NUMBER, and
* EMPTY_NUMBER_NUMBER
***************************************************************************/
DEFAULT FOR HWM_CTXARY_RECORD_POSITIONS is EMPTY_TEXT_NUMBER
DEFAULT FOR HWM_CTXARY_HWM_MEASURE_DAY is EMPTY_NUMBER_NUMBER
DEFAULT FOR measure is EMPTY_NUMBER_NUMBER

4 Technical Brief | Array Processing Formulas | Version 1.00


Copyright © 2021, Oracle and/or its affiliates | Confidential: Public
INPUTS ARE Required inputs for all AP formulas are
HWM_CTXARY_RECORD_POSITIONS, HWM_CTXARY_RECORD_POSITIONS and
HWM_CTXARY_HWM_MEASURE_DAY.
HWM_CTXARY_HWM_MEASURE_DAY,
measure

/* Following 2 lines are required right after inputs for all OTL and HWM formulas */
ffs_id = GET_CONTEXT(HWM_FFS_ID, 0)
rule_id = GET_CONTEXT(HWM_RULE_ID, 0)
ffName = 'WFM_THRESHOLD_TIME_CALCULATION_RULE_AP' || ' - v115.1106 '
rLog = add_rlog (ffs_id, rule_id, '>>> Enter - ' || ffName )

NullDate = '01-JAN-1900'(DATE)
NullText = '--NULL--'

measure_period = GET_CONTEXT(HWM_MEASURE_PERIOD, 0)

/* Fixed Values from Rule header */


hSumLvl= Get_Hdr_Text(rule_id, 'RUN_SUMMATION_LEVEL', 'TIMECARD')
hExecType = Get_Hdr_Text(rule_id,'RULE_EXEC_TYPE', 'CREATE')

hCreateYn = 'N'
if (upper(hExecType) = 'CREATE' ) then (
hCreateYn = 'Y'
)

l_status = add_rlog (ffs_id , rule_id ,'Rule Header and Context:' ||


' , ffs_id =' || TO_CHAR( ffs_id ) ||
' , rule_id =' || TO_CHAR( rule_id ) ||
' , measure_period=' || TO_CHAR( measure_period ) ||
' , hSumLvl=' || hSumLvl ||
' , hExecType=' || hExecType ||
' , hCreateYn=' || hCreateYn )

/* Fixed Values from Rule Input parameters */


pCategoryId = get_rvalue_number (rule_id ,'WORKED_TIME_CONDITION', 0)
pMaxHrs = get_rvalue_number (rule_id ,'DEFINED_LIMIT', 0)

5 Technical Brief | Array Processing Formulas | Version 1.00


Copyright © 2021, Oracle and/or its affiliates | Confidential: Public
l_status = add_rlog (ffs_id , rule_id , 'Rule Parameters: ' ||
' , pMaxHrs=' || TO_CHAR( pMaxHrs ) ||
' , pCategoryId =' || TO_CHAR( pCategoryId ) )

wMaAry = HWM_CTXARY_RECORD_POSITIONS.count
rLog = add_rlog (ffs_id, rule_id, 'Start bulk process - wMaAry=' || TO_CHAR( wMaAry ) )

out_measure_ary_under = EMPTY_NUMBER_NUMBER
out_measure_ary_over = EMPTY_NUMBER_NUMBER

Output data types set as


Array Data type:
wkTotalHrsDay = 0
EMPTY_TEXT_NUMBER,
wkTotalHrsTc = 0
EMPTY_DATE_NUMBER, and
nidx = 0 EMPTY_NUMBER_NUMBER
WHILE (nidx < wMaAry ) LOOP
(
aiMeasure = 0
aiRecPosition = NullText

nidx = nidx + 1
Loop through time card and
if (MEASURE.exists(nidx) ) then ( process records by selecting
aiMeasure = MEASURE[nidx] individual input attributes
defined in the input section,
) such as Measure

aiMeasureDay = 0
if (HWM_CTXARY_HWM_MEASURE_DAY.exists(nidx) ) then (
aiMeasureDay = HWM_CTXARY_HWM_MEASURE_DAY[nidx]
)

aiRecPosition = HWM_CTXARY_RECORD_POSITIONS[nidx]

ocMeasure_under = -9999
ocMeasure_over = -9999

CALL_FORMULA ('WFM_THRESHOLD_TIME_CALCULATION_RULE_SUB'
, ffs_id > 'ffs_id'
, rule_id > 'rule_id'
, hSumLvl > 'hSumLvl'
, hCreateYn > 'hCreateYn'

6 Technical Brief | Array Processing Formulas | Version 1.00


Copyright © 2021, Oracle and/or its affiliates | Confidential: Public
, measure_period > 'measurePeriod'
, aiMeasureDay > 'measureDay'
, aiRecPosition > 'recPosition'
, wkTotalHrsDay > 'wkTotalHrsDay'
, wkTotalHrsTc > 'wkTotalHrsTc'
, aiMeasure > 'measure'
, pMaxHrs > 'pMaxHrs'
, ocMeasure_under < 'out_measure_under' DEFAULT -9999
, ocMeasure_over < 'out_measure_over' DEFAULT -9999
, wkTotalHrsDay < 'oTotalHrsDay' DEFAULT 0
, wkTotalHrsTc < 'oTotalHrsTc' DEFAULT 0 )

rLog = add_rlog (ffs_id, rule_id, '>>> CALL_FORMULA Result: ' ||


' , aiMeasureDay =' || TO_CHAR( aiMeasureDay ) ||
' , ocMeasure_under =' || TO_CHAR( ocMeasure_under ) ||
' , ocMeasure_over =' || TO_CHAR( ocMeasure_over ) ||
' , wkTotalHrsDay =' || TO_CHAR( wkTotalHrsDay ) ||
' , wkTotalHrsTc =' || TO_CHAR( wkTotalHrsTc ) )

if (ocMeasure_under <> -9999 ) Then (


out_measure_ary_under[nidx] = ocMeasure_under
)
if (ocMeasure_over <> -9999 ) Then (
out_measure_ary_over[nidx] = ocMeasure_over
)

if (nidx > 1000 ) Then (


if (nidx > 1000 ) Then (
/* endless loop? Stop process if more than max_loop records found */
ex = raise_error (ffs_id, rule_id, 'Formula ' || ffName || ' terminated
due to possible end-less loop.' )
)

)
)

rLog = add_rlog (ffs_id, rule_id, '<< Exit - ' || ffName )

RETURN out_measure_ary_under, out_measure_ary_over

7 Technical Brief | Array Processing Formulas | Version 1.00


Copyright © 2021, Oracle and/or its affiliates | Confidential: Public
Formula: WFM_THRESHOLD_TIME_CALCULATION_RULE

/* +======================================================================+
| Copyright (c) 2009 Oracle Corporation |
| Redwood Shores, California, USA |
| All rights reserved. |
+======================================================================+
*
* Formula Name : WFM_THRESHOLD_TIME_CALCULATION_RULE
*
* Formula Type: WFM TCR Threshold Rule - FF Seed Data
*
* Description: Divides reported daily or period time into calculated
* time attributes for hours above and below defined threshold
* hours. Reported time and specific time attribute results
* are inputs to the delivered formula.
*
* Detail: Compares the total time category hours for the day or
* period to the threshold value. Hours above the threshold
* are converted to a single pay time type. Hours under
* the threshold either remain the same pay time type value
* or are converted into a new pay time type attribute.
*
*
* Change History
* --------------
*
* Who Ver Date Description
*----------------- ------ ------------ -----------------------------------------
* David Cohanoff 206.12 2013-FEB-10 Created.
*
*
**************************************************************************/
Default input and input
default for measure(number) is 0 variable value data type is
single Number, Date, or Text

INPUTS ARE
measure(number)

/* Following 2 lines are required right after inputs for all OTL and HWM formulas */

8 Technical Brief | Array Processing Formulas | Version 1.00


Copyright © 2021, Oracle and/or its affiliates | Confidential: Public
ffs_id = GET_CONTEXT(HWM_FFS_ID, 0)
rule_id = GET_CONTEXT(HWM_RULE_ID, 0)
l_status = add_rlog (ffs_id , rule_id , 'WFM_THRESHOLD_TIME_CALCULATION_RULE v104.0525 ' )

/* sum_lvl = GET_CONTEXT(HWM_SUMMATION_LEVEL, 'TIMECARD') */


rec_position = GET_CONTEXT(HWM_RECORD_POSITION, 'DETAIL')

/* Fixed Values from Rule header */


sum_lvl= Get_Hdr_Text(rule_id, 'RUN_SUMMATION_LEVEL', 'TIMECARD')
exec_type = Get_Hdr_Text(rule_id,'RULE_EXEC_TYPE', 'CREATE')

create_yn = 'N'
if (upper(exec_type) = 'CREATE' ) then (
create_yn = 'Y'
)

l_status = add_rlog (ffs_id , rule_id ,'(v3.08a- ' ||


' , sum_lvl=' || sum_lvl ||
' , rec_position =' || rec_position ||
' , ffs_id =' || TO_CHAR( ffs_id ) ||
' , measure =' || TO_CHAR( measure ) )

/* Fixed Values from Rule Input parameters */


max_hr = get_rvalue_number (rule_id ,'DEFINED_LIMIT', 0)
categoryId = get_rvalue_number (rule_id ,'WORKED_TIME_CONDITION', 0)

wk_hrs_total_day = get_wrk_num (ffs_id , 'wk_hrs_total_day' , 0, 0 )


wk_hrs_total_tc = get_wrk_num (ffs_id , 'wk_hrs_total_tc' , 0, 0 )

l_status = add_rlog (ffs_id , rule_id , '( total_day=' || TO_CHAR( wk_hrs_total_day ) ||


' , total_tc =' || TO_CHAR( wk_hrs_total_tc ) ||
' ) ' )

tot_day = wk_hrs_total_day + measure


tot_tc = wk_hrs_total_tc + measure

tot_ck = 0
hr_ot =0

9 Technical Brief | Array Processing Formulas | Version 1.00


Copyright © 2021, Oracle and/or its affiliates | Confidential: Public
hr_reg =0

if (sum_lvl = 'TIMECARD' AND tot_tc > max_hr and max_hr > 0 ) then (
tot_ck = tot_tc
) ELSE IF (sum_lvl = 'DAY' AND tot_day > max_hr and max_hr > 0) then (
tot_ck = tot_day
) ELSE IF ( sum_lvl = 'DETAIL' AND measure > max_hr and max_hr > 0 ) then (
tot_ck = measure
)

if ( tot_ck > 0 ) then (

hr_ot = tot_ck - max_hr


if (hr_ot > measure ) then (
hr_ot = measure
hr_reg = 0
) else (
hr_reg = measure - hr_ot
)

if ( create_yn = 'Y') then (


hr_reg = measure
)

) else (
if ( measure > 0 ) then (
hr_reg = measure
)

if ( hr_reg > 0 ) then (


out_measure_under = hr_reg
) Output data type is also
Text, Number, or Date.

if ( hr_ot > 0 ) then (


out_measure_over = hr_ot
)

10 Technical Brief | Array Processing Formulas | Version 1.00


Copyright © 2021, Oracle and/or its affiliates | Confidential: Public
wk_hrs_total_day = tot_day
wk_hrs_total_tc = tot_tc

if (rec_position = 'END_DAY') then (


wk_hrs_total_day = 0
) ELSE IF (rec_position = 'END_PERIOD') then (
wk_hrs_total_day = 0
wk_hrs_total_tc = 0
)

l_status = set_wrk_num (ffs_id , 'wk_hrs_total_day' , 0, wk_hrs_total_day)


l_status = set_wrk_num (ffs_id , 'wk_hrs_total_tc' , 0, wk_hrs_total_tc )

RETURN out_measure_under,
out_measure_over

11 Technical Brief | Array Processing Formulas | Version 1.00


Copyright © 2021, Oracle and/or its affiliates | Confidential: Public
CONNECT WITH US
Call +1.800.ORACLE1 or visit oracle.com.
Outside North America, find your local office at oracle.com/contact.

blogs.oracle.com facebook.com/oracle twitter.com/oracle

Copyright © 2021, Oracle and/or its affiliates. All rights reserved. This document is provided for information purposes only, and the contents hereof are subject to change without
notice. This document is not warranted to be error-free, nor subject to any other warranties or conditions, whether expressed orally or implied in law, including implied warranties
and conditions of merchantability or fitness for a particular purpose. We specifically disclaim any liability with respect to this document, and no contractual obligations are formed
either directly or indirectly by this document. This document may not be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without
our prior written permission.

Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.

Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of
SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered
trademark of The Open Group. 0120

Array Processing Formulas


June, 2021

You might also like