Tuesday, March 15, 2016

Parent and Child Formula

Fast Formula – Parent and Child Formula (Formula Calling Formula)

In the previous section, we went over on how to create a sample Fast Formula that can be used in a real life scenario.
In this session, we will create a Fast Formula (Child) that can be called from another Fast Formula (Parent).  In other words, we will explain the Parent-Child concept of a Fast Formula.
Why do we need to call another Fast Formula?

The Fast Formula documentation reads the functionality of the Formula calling Formula as

Instead of writing large formulas, common calculations can be put into their own smaller formulas. These calculation formulas can then be called from other formulas that need the calculation.”

Yes, it can be used for separating the common routine in different Fast Formulas but this is more of a convenience than necessity. I have different reasons on why we need this feature more than just separating the common routines.  Below are two examples.


  • If an organization has employees from different legislation, we need to have different Fast Formulas to support data from different Legislation.
  • If we need to get data from different applications, we need to work with different DBI and Context. Since our Formula Type does not support the entire Context, we need to use different Formula Types.  

1) Legislative Data Group (LDG):  There are many DBIs that can be used only in a Legislative Data Group specific formula. For example, in Payroll Element Entry values DBI, I believe that the entire Payroll related DBIs can be used only in LDG specific Fast Formula (needs to be verified though).  
In case your organization has employees from more than one LDG (assume US, UK) and you want to use the element entry values in your Fast Formula (assume Salary Element Entry value), you cannot achieve your requirement in one Fast Formula.  If you create a Fast Formula in US LDG, then this Fast Formula will error for UK employees.
In this case, you can follow these steps:
  • You can create a Fast Formula (Parent) that is non LDG specific. This can be used by both UK and US employees.  
  • Create a Fast Formula (Child) in US LDG. Let us assume this child Fast Formula is named as TILAKSHMI_FF_CHILD_US.  We will use the Salary Element Entry from US LDG.
  • Create a Fast Formula in UK LDG with the same name, TILAKSHMI_FF_CHILD_US. We use the Salary Element Entry for UK in this Fast Formula. If you remember, since we provided a LDG, the uniqueness is validated within the LDG while saving the Fast Formula. Please check the second section where we explained the uniqueness of Fast Formula name.  
  • Now, you can call the child Fast Formula, TILAKSHMI_FF_CHILD_US from your parent Fast Formula either by “CALL_FORMULA()” or “EXECUTE()”.  
  • You will attach the Parent Formula in your UI or process.
  • In case you do not have same name for Child Fast Formula in UK and US LDG, you need to use IF condition in parent Fast Formula to call the right Fast Formula for the LDG.
For the above scenario, when the parent Fast Formula is executed:
  • It will call the child Fast Formula as per the employee’s LDG.
    • If the employee belongs to US, then the parent will call the child, TILAKSHMI_FF_CHILD_US that is created in US LDG.
    • If the employee belongs to UK, then the parent will call the TILAKSHMI_FF_CHILD_US that is created in UK LDG.


Create a Child Formula in US LDG.


Create a Child Formula of same type in UK LDG using the same Formula Name.

Formula Text:
/*
 Author  : Tilak
 Type    : Compensation Default and Override
 NAME    :  TILAKSHMI_FF_CHILD_US
 Remarks:  This is a Child formula in US LDG
*/


/*
DEFAULT FOR MONTHLY_SALARYBASIS_ELEMENT_AMOUNT_ENTRY_VALUE IS -1


l_hr_assign_id = get_context(HR_ASSIGNMENT_ID, -1)
l_eff_date = get_context(DATE_EARNED, '1900/01/01 00:00:00' (date))
l_pay_assign_id = get_context(PAYROLL_ASSIGNMENT_ID, -1)


L_DATA = ESS_LOG_WRITE( 'BEGIN TILAKSHMI_FF_CHILD_US' )
L_DATA = ESS_LOG_WRITE( 'ASG ID  :' + TO_CHAR(l_hr_assign_id ))
L_DATA = ESS_LOG_WRITE( 'PAY ASG ID  :' + TO_CHAR(l_pay_assign_id ))
L_DATA = ESS_LOG_WRITE( 'Date   :' +   TO_CHAR(l_eff_date , 'YYYY/MM/DD') )


L_VALUE =  MONTHLY_SALARYBASIS_ELEMENT_AMOUNT_ENTRY_VALUE


L_DATA = ESS_LOG_WRITE( 'EXIT TILAKSHMI_FF_CHILD_US ' + TO_CHAR(L_VALUE) )
RETURN  L_VALUE
Explanation of Fast Formula:  
  • This is a simple Fast Formula which just returns a value from a DBI, MONTHLY_SALARYBASIS_ELEMENT_AMOUNT_ENTRY_VALUE.


Parent Formula is created without LDG.



Formula Text:
/*
 Author  : Tilak
 Type    : Compensation Default and Override
 NAME    :  TILAKSHMI_FF_PARENT_US
 Remarks:  This is a Parent formula without any LDG
*/


l_hr_assign_id = get_context(HR_ASSIGNMENT_ID, -1)
l_eff_date = get_context(DATE_EARNED, '1900/01/01 00:00:00' (date))
l_pay_assign_id = get_context(PAYROLL_ASSIGNMENT_ID, -1)


L_DATA = ESS_LOG_WRITE( 'BEGIN TILAKSHMI_FF_PARENT_US' )
L_DATA = ESS_LOG_WRITE( 'ASG ID  :' + TO_CHAR(l_hr_assign_id ))
L_DATA = ESS_LOG_WRITE( 'PAY ASG ID  :' + TO_CHAR(l_pay_assign_id ))
L_DATA = ESS_LOG_WRITE( 'Date   :' +   TO_CHAR(l_eff_date , 'YYYY/MM/DD') )


L_VALUE = 0
/* check if the child formula is available*/
IF (IS_EXECUTABLE('TILAKSHMI_FF_CHILD_US')) THEN
(
   /* call the child formula */
   EXECUTE('TILAKSHMI_FF_CHILD_US')
   L_VALUE = GET_OUTPUT('L_VALUE', 0)
)


L_DATA = ESS_LOG_WRITE( 'EXIT TILAKSHMI_FF_PARENT_US ' + TO_CHAR(L_VALUE) )
RETURN  L_VALUE
Explanation of Fast Formula
This is again a simple Fast Formula. There are three points you need to understand here.
  1. In one of our previous sessions, we explained that the Formula engine only passes the Contexts that are used in the Formula. Therefore, it is the developer’s responsibility to make sure the value for Context that is used in the Child formula is also passed to the Parent Formula. For this, you need to get all the Contexts in Parent formula though it is not used in the Parent Fast Formula. You can use GET_CONTEXT, NEED_CONTEXT etc to make sure that the value of the context are passed to the Parent Formula.
l_hr_assign_id = get_context(HR_ASSIGNMENT_ID, -1)
l_eff_date = get_context(DATE_EARNED, '1900/01/01 00:00:00' (date))
l_pay_assign_id = get_context(PAYROLL_ASSIGNMENT_ID, -1)


  1. Before we call the child formula we make sure it is available.


IF (IS_EXECUTABLE('TILAKSHMI_FF_CHILD_US')) THEN
(


  1. Call the child formula and get the output from the Child Formula.


/* call the child formula */
   EXECUTE('TILAKSHMI_FF_CHILD_US')
   L_VALUE = GET_OUTPUT('L_VALUE', 0)
2) Context:  As we discussed in our previous sessions, different Formula Types support different context sets. Therefore, different Formula Types support different sets of DBI. If you need to understand the relation between Formula Types, Context and DBIs, please read our first session.


Since some DBIs can be used only in some Formula Types, we need to use different Formula Types to achieve our requirements.  But our UI Field supports only one Formula Type, therefore, you need to use the child Fast Formula of different Formula Type to get the information from the DBI.
Let us go through an example to understand this part.
  • For example, Compensation Default and Override (for CWB) needs to find the DBA Certification of a person to determine the Bonus.
  • Let us assume the bonus is calculated as: 20% of Salary + $1000, if the DBA Certification is obtained in the plan period.
  • The DBA Certification information is available in the Talent Management. And we will use the DBI; ‘HRT_PERSON_GENERIC_CONTENT_TYPE_CONTENT_ITEM_NAME’ to find the certification.
  • For using the DBI, ‘HRT_PERSON_GENERIC_CONTENT_TYPE_CONTENT_ITEM_NAME’, we need to use the context, 'TALENT_PROFILE_CONTENT_TYPE' and set the context value as 'CERTIFICATION'.
  • This Context is supported only by Talent Formula Types. For example, “Generic Formula type for Profile Content” supports the Context, 'TALENT_PROFILE_CONTENT_TYPE'.
To achieve the above requirement:
  • We will create a Parent Formula of Formula Type, “Compensation Default and Override”
  • The Parent Formula will call a Child Formula Type, “Generic Formula type for Profile Content” after setting the context, 'TALENT_PROFILE_CONTENT_TYPE'.


Create a Child Formula in Talent Type and use the Talent DBI.



Formula Text:


/*
 TYPE       : Generic Formula type for Profile Content
 Name      : TILAKSHMI_TALENT_DBI_CERT
 Author   : Tilak
*/


/*DEFAULT_DATA_VALUE FOR HRT_PERSON_GENERIC_CONTENT_TYPE_CONTEXT_NAME IS 'XXX'*/
DEFAULT_DATA_VALUE FOR HRT_PERSON_GENERIC_CONTENT_TYPE_CONTENT_ITEM_NAME IS 'XXX'
DEFAULT_DATA_VALUE FOR HRT_PERSON_GENERIC_CONTENT_TYPE_DATE_FROM IS '1900/01/01 00:00:00' (date)


INPUTS ARE IV_PLAN_START_DATE (text) ,IV_PLAN_END_DATE (text)
/*Default for Input values */


DEFAULT FOR IV_PLAN_START_DATE   IS  '2001/01/01'
DEFAULT FOR IV_PLAN_END_DATE     IS  '2001/01/01'


L_RETURN_VALUE  = 'N'
L_DATA = ESS_LOG_WRITE( 'BEGIN TILAKSHMI_TALENT_DBI_CERT' )


l_person_id = get_context(PERSON_ID,-1)
l_eff_date =  get_context(EFFECTIVE_DATE,'1900/01/01 00:00:00' (date))
l_type     =  get_context(TALENT_PROFILE_CONTENT_TYPE , 'NONE')


L_DATA = ESS_LOG_WRITE( 'Person ID Context ' || TO_CHAR(l_person_id ) )
L_DATA = ESS_LOG_WRITE( 'EFFECTIVE_DATE  Context ' || TO_CHAR(l_eff_date ) )
L_DATA = ESS_LOG_WRITE( 'TALENT_PROFILE_CONTENT_TYPE Context ' || l_type)
L_DATA = ESS_LOG_WRITE( 'CMP_IV_PLAN_START_DATE    ' || IV_PLAN_START_DATE   )
L_DATA = ESS_LOG_WRITE( 'CMP_IV_PLAN_END_DATE     ' || IV_PLAN_END_DATE     )


/* convert plan dates into date value */
l_start_date = TO_DATE(IV_PLAN_START_DATE, 'YYYY/MM/DD')
l_end_date = TO_DATE(IV_PLAN_END_DATE, 'YYYY/MM/DD')


L_DATA = ESS_LOG_WRITE( 'Start of the Loop in DBI ' )
l_index =  HRT_PERSON_GENERIC_CONTENT_TYPE_CONTENT_ITEM_NAME.FIRST(-1)
l_counter = 1
/* loop the all the item value */
WHILE  HRT_PERSON_GENERIC_CONTENT_TYPE_CONTENT_ITEM_NAME.EXISTS(l_index)
LOOP(
       L_DATA = ESS_LOG_WRITE( 'IN Index  ' || TO_CHAR(l_index ) )
       L_VALUE= HRT_PERSON_GENERIC_CONTENT_TYPE_CONTENT_ITEM_NAME[l_index]
       L_DATA = ESS_LOG_WRITE( 'ITEM VALUE  ' || L_VALUE )
       /* Check the item value us DBA Certification */
       IF  (L_VALUE = 'ORACLE DBA CERTIFIED' ) THEN (
           L_DATA = ESS_LOG_WRITE( 'DBA ' )
           l_DATE = HRT_PERSON_GENERIC_CONTENT_TYPE_DATE_FROM[l_index]
           /* if the certification received within the plan period */
           if (l_DATE >= l_start_date AND l_DATE <= l_end_date) THEN (  
                  L_DATA = ESS_LOG_WRITE( 'DBS IN CURRENT PLAN YEAR ' )
                  L_RETURN_VALUE = 'Y'
                  EXIT
               
           )
        )  
       l_index = HRT_PERSON_GENERIC_CONTENT_TYPE_CONTENT_ITEM_NAME.NEXT(l_index,-1)  
)


L_DATA = ESS_LOG_WRITE( 'End of the Loop' )


L_DATA = ESS_LOG_WRITE( 'END TILAKSHMI_TALENT_DBI_CERT: ' || L_RETURN_VALUE   )
RETURN  L_RETURN_VALUE  


Explanation of Fast Formula:


This Child Formula uses array DBI. Since the objective of this session is not to go over Arrays, we will cover this part in the next session.


 INPUTS ARE IV_PLAN_START_DATE (text) , IV_PLAN_END_DATE (text)
/*Default for Input values */


DEFAULT FOR IV_PLAN_START_DATE   IS  '2001/01/01'
DEFAULT FOR IV_PLAN_END_DATE     IS  '2001/01/01'


In the Business logic, the Fast Formula loops the through the DBI values and validates the value of the DBI. If the value is ‘DBA Certification’, and if the ‘DBA Certification’ has been received within the plan period, then we return ‘Y’.


/* loop the all the item values */
WHILE  HRT_PERSON_GENERIC_CONTENT_TYPE_CONTENT_ITEM_NAME.EXISTS(l_index)
LOOP(
       L_DATA = ESS_LOG_WRITE( 'IN Index  ' || TO_CHAR(l_index ) )
       L_VALUE= HRT_PERSON_GENERIC_CONTENT_TYPE_CONTENT_ITEM_NAME[l_index]
       L_DATA = ESS_LOG_WRITE( 'ITEM VALUE  ' || L_VALUE )
       /* Check the item value us DBA Certification */
       IF  (L_VALUE = 'ORACLE DBA CERTIFIED' ) THEN (
           L_DATA = ESS_LOG_WRITE( 'DBA ' )
           l_DATE = HRT_PERSON_GENERIC_CONTENT_TYPE_DATE_FROM[l_index]
           /* if the certification received within the plan period */
           if (l_DATE >= l_start_date AND l_DATE <= l_end_date) THEN (  
                  L_DATA = ESS_LOG_WRITE( 'DBS IN CURRENT PLAN YEAR ' )
                  L_RETURN_VALUE = 'Y'
                  EXIT
           )
        )  
       l_index = HRT_PERSON_GENERIC_CONTENT_TYPE_CONTENT_ITEM_NAME.NEXT(l_index,-1)  
)


Create Parent Formula in Compensation Type to use it in Compensation.



Formula Text:
   /*
 TYPE       : Compensation Default and Override
 Name       : TILAKSHMI_CWB_PARENT_DBA_CERT
 Author  : Tilak
                       
 */
DEFAULT FOR  CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT IS 0


INPUTS ARE CMP_IV_PLAN_START_DATE (text) ,CMP_IV_PLAN_END_DATE (text)
DEFAULT FOR CMP_IV_PLAN_START_DATE   IS  '2001/01/01'
DEFAULT FOR CMP_IV_PLAN_END_DATE     IS  '4012/01/01'


L_DATA = ESS_LOG_WRITE( 'BEGIN TILAKSHMI_CWB_PARENT_DBA_CERT' )


l_person_id = get_context(PERSON_ID,-1)
l_eff_date = get_context(EFFECTIVE_DATE,'1900/01/01 00:00:00' (date))
L_RETURN_VALUE = 'N'
l_end_date = TO_DATE(CMP_IV_PLAN_END_DATE, 'YYYY/MM/DD')


L_DATA = ESS_LOG_WRITE( 'Person ID COntext : ' || TO_CHAR(l_person_id) )
L_DATA = ESS_LOG_WRITE( 'EFFECTIVE_DATE context : ' || TO_CHAR(l_eff_date) )
L_DATA = ESS_LOG_WRITE( 'START DATE  : ' || CMP_IV_PLAN_START_DATE    )
L_DATA = ESS_LOG_WRITE( 'END DATE  : ' || CMP_IV_PLAN_END_DATE    )


L_VALUE = -1
/* When the salary is defined
*/
IF CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT WAS NOT DEFAULTED  THEN
(
  L_VALUE  = CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT
  L_VALUE  = (L_VALUE/100)*20
  L_DATA = ESS_LOG_WRITE( '20 % of Sal ' + TO_CHAR(L_VALUE ) )


 IF (IS_EXECUTABLE('TILAKSHMI_TALENT_DBI_CERT')) THEN
 (
  SET_INPUT('TALENT_PROFILE_CONTENT_TYPE','CERTIFICATION')
  SET_INPUT('EFFECTIVE_DATE',l_end_date)
  SET_INPUT('IV_PLAN_START_DATE', CMP_IV_PLAN_START_DATE )
  SET_INPUT('IV_PLAN_END_DATE',CMP_IV_PLAN_END_DATE )
  EXECUTE('TILAKSHMI_TALENT_DBI_CERT')
  L_CERT_VALUE = GET_OUTPUT('L_RETURN_VALUE','N')
  L_DATA = ESS_LOG_WRITE( ' RETURN VALUE OF CERT  '|| L_CERT_VALUE  )
  /*  add 1000 if cert is Y
 */
  IF (L_CERT_VALUE = 'Y') THEN
  (
    L_VALUE  =  L_VALUE  + 1000
    L_DATA = ESS_LOG_WRITE( ' Bonus after certification : '|| TO_CHAR(L_VALUE))
  
   )
 )  
)


L_DATA = ESS_LOG_WRITE( 'END TEST_CMP_CPR_ENROLLED_FF : '|| TO_CHAR(L_VALUE))
RETURN L_VALUE
Explanation of Fast Formula
Define the DBI and Input values that are used in parent and child Fast Formula.


DEFAULT FOR  CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT IS  0


INPUTS ARE CMP_IV_PLAN_START_DATE (text) , CMP_IV_PLAN_END_DATE (text)
DEFAULT FOR CMP_IV_PLAN_START_DATE   IS  '2001/01/01'
DEFAULT FOR CMP_IV_PLAN_END_DATE     IS  '4012/01/01'


L_DATA = ESS_LOG_WRITE( 'BEGIN TILAKSHMI_CWB_PARENT_DBA_CERT' )


l_person_id = get_context(PERSON_ID,-1)
l_eff_date = get_context(EFFECTIVE_DATE,'1900/01/01 00:00:00' (date))
L_RETURN_VALUE = 'N'
l_end_date = TO_DATE(CMP_IV_PLAN_END_DATE, 'YYYY/MM/DD')


As per the business logic, validate the salary. If the salary is not defined, do not proceed. If the salary is defined, calculate 20% for salary for Bonus.


L_VALUE = -1
/* When the salary is defined
*/
IF CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT WAS NOT DEFAULTED  THEN
(
  L_VALUE  = CMP_ASSIGNMENT_SALARY_ANNUAL_AMOUNT
  L_VALUE  = (L_VALUE/100)*20
  L_DATA = ESS_LOG_WRITE( '20 % of Sal ' + TO_CHAR(L_VALUE ) )


Check if the Child Fast Formula is available. If so, set the required context and input values.
 IF (IS_EXECUTABLE('TILAKSHMI_TALENT_DBI_CERT')) THEN
 (
  SET_INPUT('TALENT_PROFILE_CONTENT_TYPE','CERTIFICATION')
  SET_INPUT('EFFECTIVE_DATE',l_end_date)
  SET_INPUT('IV_PLAN_START_DATE', CMP_IV_PLAN_START_DATE )
  SET_INPUT('IV_PLAN_END_DATE',CMP_IV_PLAN_END_DATE )


Just for this example, we use different input values. You do not need to do so in a real Fast Formula.
  SET_INPUT('IV_PLAN_START_DATE', CMP_IV_PLAN_START_DATE )
  SET_INPUT('IV_PLAN_END_DATE',CMP_IV_PLAN_END_DATE )


If you notice, the Context is also set like the input values.


  SET_INPUT('EFFECTIVE_DATE',l_end_date)


Execute the Child Fast Formula and get the return value. You need to use the return variables from Child Fast Formula ('L_RETURN_VALUE’) to get the value. The second parameter (‘N’) is the default value.  If the child formula returns ‘Y’ then we add $1000 to the Bonus.


  SET_INPUT('IV_PLAN_END_DATE',CMP_IV_PLAN_END_DATE )
  EXECUTE('TILAKSHMI_TALENT_DBI_CERT')
  L_CERT_VALUE = GET_OUTPUT('L_RETURN_VALUE','N')
  L_DATA = ESS_LOG_WRITE( ' RETURN VALUE OF CERT  '|| L_CERT_VALUE  )
  /*  
    add 1000 if cert is Y
 */
  IF (L_CERT_VALUE = 'Y') THEN
  (
    L_VALUE  =  L_VALUE  + 1000
    L_DATA = ESS_LOG_WRITE( ' Bonus after certification : '|| TO_CHAR(L_VALUE))
   )

Please look at our previous section to see how the Fast Formula is added in the UI. In the same manner, please add the parent Fast Formula to the UI.



YouTube Tutorial 14

/*************************

Name: TCS_CHILD_FF

Type: Compensation Person Selection

Simple Child Formula


**************************/


l_temp = ESS_LOG_WRITE('Entering TCS_CHILD_FF' )

VALUE = 'Y' 


l_person = get_context(PERSON_ID, -1)

l_asg  =  get_context(HR_ASSIGNMENT_ID, -1)


l_temp = ESS_LOG_WRITE('Person ' +  to_char(l_person) )

l_temp = ESS_LOG_WRITE('Asg ' +  to_char(l_asg) )


if l_person = -1 OR  l_asg = -1 THEN 

(

   VALUE = 'Y' 

)




l_temp = ESS_LOG_WRITE('Leaving TCS_CHILD_FF ' + value )

Return VALUE 




/*******************

Name: TCS_PARENT_FF

Type: Compensation Person Selection

Simple Parent Formula that calls Child Formula


******************/


l_temp = ESS_LOG_WRITE('Entering TCS_PARENT_FF' )

RETVALUE = 'N' 

person =  get_context(PERSON_ID, -1)

asg    =  get_context(HR_ASSIGNMENT_ID, -1)


l_temp = ESS_LOG_WRITE('Person ID ' + TO_CHAR(person) )

IF IS_EXECUTABLE('TCS_CHILD_FF') THEN 

(

   set_input('MYTEST' , 'XXXXXX')

   set_input('PERSON_ID' 20000 )

 

   l_temp = ESS_LOG_WRITE('Entering TCS_PARENT_FF' ) 

   EXECUTE('TCS_CHILD_FF')

   l_var = GET_OUTPUT('VALUE', 'x')

   l_temp = ESS_LOG_WRITE('Child Return ' +  l_var) 

   if l_var = 'Y' then 

   (

     RETVALUE = 'Y' 

   )

 


)





YouTube Tutorial 16

/*************************

Name: TCS_CHILD_FF

Type: Age Calculation

Simple Child Formula


**************************/


DEFAULT FOR BEN_PGM_NAME is ' '

l_temp = ESS_LOG_WRITE('Entering TCS_CHILD_FF' )

VALUE  = 'N' 

ldate = get_Context(EFFECTIVE_DATE, '1900/01/01' (date) ) 

lbg   = get_context(BUSINESS_GROUP_ID, -1) 

lpgm  = get_context(PGM_ID , -1) 

lpgmname = BEN_PGM_NAME


l_temp = ESS_LOG_WRITE('Date ' + to_char(ldate) )

l_temp = ESS_LOG_WRITE('Bg ' + to_char(lbg) )

l_temp = ESS_LOG_WRITE('pgm ' + to_char(lpgm) )

l_temp = ESS_LOG_WRITE('pgm NAME ' + lpgmname)


l_temp = ESS_LOG_WRITE('Entering TCS_CHILD_FF ' + VALUE)

Return VALUE

        


/*******************

Name: TCS_PARENT_FF

Type: Compensation Person Selection

Simple Parent Formula that calls Child Formula


******************/


l_temp = ESS_LOG_WRITE('Entering TCS_PARENT_FF' )

RETVALUE = 'N' 

person =  get_context(PERSON_ID, -1)

asg    =  get_context(HR_ASSIGNMENT_ID, -1)


l_temp = ESS_LOG_WRITE('Person ID ' + TO_CHAR(person) )

IF IS_EXECUTABLE('TCS_CHILD_FF') THEN 

(


   l_var = 'N'

   CALL_FORMULA('TCS_CHILD_FF' ,

                100010025071996 > 'BUSINESS_GROUP_ID' , 

                100100081493359 > 'PGM_ID'  ,      

                l_var <  'VALUE' default 'X' 

               )



   l_temp = ESS_LOG_WRITE('Child Return ' +  l_var) 

   if l_var = 'Y' then 

   (

     RETVALUE = 'Y' 

   )

 


)


l_temp = ESS_LOG_WRITE('Leaving TCS_PARENT_FF ' + RETVALUE )

RETURN RETVALUE







18 comments:

  1. Hi Tilak and Lakshmi,

    Thanks a lot for sharing the knowledge.

    I am going through the fast formula user guide along with this article, and found that there are 2 ways to call the child formula.
    1) Using Separate Calls
    2) Using a Single Self-Contained Call.

    Either ways result and execution is same but below points makes the difference in case of Using a Single Self-Contained Call.

    • Input values are cleared at the start so that prior SET_INPUT call values are not used.
    • Outputs are discarded at the end so that subsequent GET_OUTPUT calls just return the default values.


    Can you please explain about 2 differences with examples?

    ReplyDelete
  2. Hi Tilak & Lakshmi,

    I'm using below logic to get a value from another which function which retruns date

    IF (IS_EXECUTABLE('XXXX')) THEN
    (
    EXECUTE('XXXX')
    L_NEW_ENROLL_DATE = GET_OUTPUT('l_date','2051-01-01T00:00:00.000Z')
    L_DATA = ESS_LOG_WRITE( 'log13_Formula: ' || L_NEW_ENROLL_DATE)
    )

    It compiles without no error but when it executes it's giving me below error

    Formula XXXX, line 62, output item has different data types in calling and called formulas. Output item L_DATE has data type TEXT in the calling formula, but data type DATE in the called formula. GET_OUTPUT calls set an output items calling formula data type. Ensure that output item data types are the same in the calling and called formulas.

    I checked the other formula return value and it returns date value like 2017-11-01T00:00:00.000Z.

    I dont have any variable in the calling formula called L_DATE.

    What default value should I be using got GET_OUPTUT and what should be the L_NEW_ENROLL_DATE data type?

    Thanks,
    Kal

    ReplyDelete
    Replies
    1. Your question has the answer "Output item L_DATE has data type TEXT in the calling formula, but data type DATE in the called formula"
      Why cant you convert the return date as char in child formula.

      you have tow possibilities here

      1) return the date as char using to_char function from the child
      2) accept the variable as date in parent
      L_NEW_ENROLL_DATE = GET_OUTPUT('l_date','2051-01-01T00:00:00.000Z' (DATE) )
      I suggest return char.

      In the log the date or char look the same .
      Still If you have issues, pls provide me the child formula for further assistance.

      Delete
    2. The Child formula is used for determining the employee enrollment date and is used at a different place. I'm using that date to compare it against my date in parent fast formula.

      I tried the 2nd option and it worked now. I did not add the DATE after the default value which caused the issue.

      Thanks for the quick response and identifying the issue :)

      Delete
    3. Glad to know it worked for you.
      Without knowing the type of formula I can not comment on the return type.
      Well, Just for your information. In Benefit and Compensation, most of the formulas expect the date returned in YYYY/MM/DD formats.
      In my understanding, only in absence the dates are returned as dates.

      Delete
  3. Where to view ESS_LOG_WRITE logs?

    ReplyDelete
  4. this is already explained in my blog, How to debug a Fast Formula on March, 2017. (
    http://tilak-lakshmi.blogspot.com/2017/03/how-to-debug-fast-formula.html
    )

    ReplyDelete
  5. Hi Tilak & Lakshmi
    Thanks for the information
    We have requirement to pull content item in to performance document
    we have created a fastformula to pull content item nut unfortunately PERSON_ID context is missing in performance rating calculation type .
    so we created a child fast formula to get person_id context and we have mapped it to Parent fastformula but still we aren't getting the desired output...
    Hope you can help us with the solution....
    Child FF
    Type Extract Rule
    RULE_VALUE = 0
    l_person_id = (get_context(PERSON_ID, -1))
    L_DATA = ESS_LOG_WRITE( 'Person ID Context ' || TO_CHAR(l_person_id ) )
    RULE_VALUE = (l_person_id)
    RETURN RULE_VALUE

    Parent FF
    Type Performance Rating Calculation
    DEFAULT_DATA_VALUE FOR HRT_PERSON_CUSTCTYPE1_ITEM_DECIMAL_1 IS 'ABC'
    DEFAULT_DATA_VALUE FOR HRT_PERSON_CUSTCTYPE1_CONTENT_TYPE_ID IS 'ABC'
    DEFAULT_DATA_VALUE FOR HRT_PERSON_CUSTCTYPE1_PERSON_ID IS 'ABC'

    L_RETURN_VALUE = 0
    L_Team_Score = 0
    L_Proj_Score = 0
    l_person_id = 0
    i=1
    j=1
    IF (IS_EXECUTABLE('TEST CHILD FF')) THEN
    (
    L_DATA = ESS_LOG_WRITE( 'TEST CHILD FF FOUND' )
    /* call the child formula
    SET_INPUT('PERSON_ID','RULE_VALUE')
    L_DATA = ESS_LOG_WRITE( 'Person ID Context ' || TO_CHAR(RULE_VALUE) )*/
    EXECUTE('TEST CHILD FF')
    l_person_id = (GET_OUTPUT('RULE_VALUE', 10))
    L_DATA = ESS_LOG_WRITE( 'l_person_id ' || TO_CHAR(l_person_id ) )
    )
    WHILE (HRT_PERSON_CUSTCTYPE1_ITEM_DECIMAL_1.EXISTS(j)) LOOP
    (
    L_DIGITAL = HRT_PERSON_CUSTCTYPE1_ITEM_DECIMAL_1[j]
    IF HRT_PERSON_CUSTCTYPE1_CONTENT_TYPE_ID[j] = '300000205825141' AND HRT_PERSON_CUSTCTYPE1_PERSON_ID[i] = TO_CHAR(l_person_id) THEN

    (
    L_Proj_Score = TO_NUMBER(HRT_PERSON_CUSTCTYPE1_ITEM_DECIMAL_1[j])
    EXIT
    )
    j = j + 1
    )

    L_RETURN_VALUE = (L_Proj_Score)
    L_DATA = ESS_LOG_WRITE( 'l_RULE_VALUE' || TO_CHAR(L_RETURN_VALUE) )

    RETURN L_RETURN_VALUE

    Im not able to bring PERSON_ID Context used in child formula to parent FF kindly correct me if there are any corrections

    ReplyDelete
    Replies
    1. I can see that you are logging person id in child formula, please let me know the value.

      context PERSON_ID is a number ,can you set to some number and try the same.

      Delete
    2. after a second look at your formula. did you compile the formula ?
      you are printing a variable, RULE_VALUE without declaring.

      Delete
    3. Hi Tilak & Lakshmi
      Yes I have compiled the formula but still PERSON_ID context from child FF is not passed to the parent formula.
      Rule_value is the output from child formula do i still need to declare them as local variable?
      For Performance Rating calculation Formula Type how do i generate log Files?

      Delete
    4. my bad, i missed the comments on the code.
      Try for testing
      SET_INPUT('PERSON_ID', 500), this will pass the 500 to person_id.
      For your real formula, how are you planning to get the person id ?
      I never used the above said formula type, so i can not comment on this.
      I already have a blog on how to debug,http://tilak-lakshmi.blogspot.com/2017/03/how-to-debug-fast-formula.html. please go through that.

      Delete
    5. Hi Tilak & Lakshmi
      For obtaining the desired output i wanted to fetch PERSON_ID context, but unfortunately PERSON_ID Context is not available in formula type Performance Rating calculation. so i have created a child formula under Extract Rule formula Type where i assign person_id context to a local variable and iam trying to pass the context to parent formula whose type Performance Rating calculation.
      I have three questions here
      1) how does the context used in child formula pass on to the parent formula ?
      2) does SET_INPUT act as a context or a input variable.
      3) Do i need to pass the Person_id context used in child FF to any DBI ?
      Is there any other means to contact you

      Delete
    6. These are already explained in my blogs.
      1) If the person_id passed as context to parent that will be automatically passed to the child. In your case the parent does not support the context person_DI , so it is your responsibility to pass the value to the context person_id for the4 child.

      2) yes, set_input set the context for child.

      3) Yes you need to pass the context that are used by the dBI and supported by the formula type.

      Delete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Hi Tilak & Lakshmi,

    We are trying to get the content of talent profile which is in 'Skills & Qualifications' page under 'Me' Section to Compensation worksheet display. We are using same like parent and child formulas. We are not able to get the result. We are using almost same DBIs. Does TALENT_PROFILE_CONTENT_TYPE work for that? The talent profile has 4-5 columns in it. Is there any approach for multiple columns?

    Kindly help us in this.

    Thanks,
    Umesh.

    ReplyDelete
  8. Hi Tilak & Lakshmi, great post (and still useful after all these years). Just wondering -as I can't seem to find any like references- if I would want to retrieve all Amount input values of a certain element (non-recurring) between a certain start and end date, how can this be achieved? I hope this doesn't mean looping through the array and setting the date_earned context as date+1 from start_date until end_date within a loop?

    ReplyDelete
    Replies
    1. Most of the Element Entry DBI are extracted for a date (Context:Earned Date ) and non recurring entry are created for a date i guess therefore you need set the context with right date to get the value.

      Delete