Sunteți pe pagina 1din 11

Array Processing Formulas for Time and Labor

Oracle Fusion Time and Labor


ORACLE WHITE PAPER | MARCH 2018
Table of Contents

Introducing Fast Formula Use in Oracle Cloud Time and Labor 1

Time and Labor Array Processing Formulas Compared with Normal Formulas 2

Main Difference 2

Output 2

Why Use Normal Formula? 2

Difference in Rule Template 2

Samples 2

Delivered AP and Normal WFM_THRESHOLD_TIME_CALCULATION_RULE

Formulas 3

Formula: WFM_THRESHOLD_TIME_CALCULATION_RULE_AP 3

Formula: WFM_THRESHOLD_TIME_CALCULATION_RULE 6

0 | DAVE Functions for Workforce Management Fast Formulas Reference Guide


Introducing Fast Formula Use in Oracle Cloud Time and Labor
Oracle Cloud Fast Formula is an easy way to customize the existing functionality in Oracle Cloud Time
and Labor. Formulas are pieces of code that can receive information from calling program (packages),
access database information, and return values to the calling program. The calling program can use
this information to modify the process functionality. The fast formula language hides the complexity of
accessing the tables and column.

A formula can return more than one value to the calling program. Different programs that call the
formula expect outputs to return differently. Based on the formula type, the number and data type of
values to return are already defined.

» Some programs expect the defined names for outputs: the location of an output in the return
statement does not matter. If defined names are expected and the formula does not use the
expected names, the process errors out at run time.
» Some programs expect the output to return by location; in this case the name of the output does not
matter.

1 | DAVE FUNCTIONS FOR WORKFORCE MANAGEMENT FAST FORMULAS REFERENCE GUIDE


Time and Labor Array Processing Formulas Compared with Normal Formulas
Time and Labor introduced array processing (AP) formulas in release 10. Array processing functionality provides
added flexibility and better performance when defining and using formulas and rules.

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 only passes information about 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 developers to loop through time card data in various ways,
with more control over the process.

All formulas ending in _AP are array processing formulas. All formulas without this suffix are normal formulas.

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 final results are exactly 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 for developers just learning how to code formula. All formulas delivered since Release 10 are
AP formulas.

Difference in Rule Template


There are no differences between how AP and normal formulas are defined or how they are used in rule templates.
The rule template handles all necessary changes in the background. Time and labor administrators and managers
creating rule templates won't notice any differences when using a normal or AP formulas.

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 exact 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

2 | DAVE FUNCTIONS FOR WORKFORCE MANAGEMENT FAST FORMULAS REFERENCE GUIDE


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
* --------------
* Default input values are set as
* Who Ver Date Description 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

INPUTS ARE
HWM_CTXARY_RECORD_POSITIONS,
HWM_CTXARY_HWM_MEASURE_DAY, Required inputs for all AP formulas are
measure HWM_CTXARY_RECORD_POSITIONS and
HWM_CTXARY_HWM_MEASURE_DAY.

/* 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)

3 | DAVE FUNCTIONS FOR WORKFORCE MANAGEMENT FAST FORMULAS REFERENCE GUIDE


/* 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)

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
if (MEASURE.exists(nidx) ) then ( Loop through time card and process
aiMeasure = MEASURE[nidx] records by selecting 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'
, measure_period > 'measurePeriod'
, aiMeasureDay > 'measureDay'
, aiRecPosition > 'recPosition'
, wkTotalHrsDay > 'wkTotalHrsDay'

4 | DAVE FUNCTIONS FOR WORKFORCE MANAGEMENT FAST FORMULAS REFERENCE GUIDE


, 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

5 | DAVE FUNCTIONS FOR WORKFORCE MANAGEMENT FAST FORMULAS REFERENCE GUIDE


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 for measure(number) is 0
Default input and input 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 */
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 ) ||

6 | DAVE FUNCTIONS FOR WORKFORCE MANAGEMENT FAST FORMULAS REFERENCE GUIDE


' , 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
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
)

wk_hrs_total_day = tot_day
wk_hrs_total_tc = tot_tc

if (rec_position = 'END_DAY') then (

7 | DAVE FUNCTIONS FOR WORKFORCE MANAGEMENT FAST FORMULAS REFERENCE GUIDE


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

8 | DAVE FUNCTIONS FOR WORKFORCE MANAGEMENT FAST FORMULAS REFERENCE GUIDE


Oracle Corporation, World Headquarters Worldwide Inquiries
500 Oracle Parkway Phone: +1.650.506.7000
Redwood Shores, CA 94065, USA Fax: +1.650.506.7200

CONNECT W ITH US

blogs.oracle.com/oracle
Copyright © 2018, 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
facebook.com/oracle 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,
twitter.com/oracle electronic or mechanical, for any purpose, without our prior written permission.

oracle.com 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. 0318

Array Processing Formulas for Time and Labor


March 2018
Authors: David Cohanoff, John Finnegan, and Lynn Raiser
Contributing Authors: [OPTIONAL]

S-ar putea să vă placă și