Universal approach to debug any fast formula
In this article we will learn a universal way to debug any fast formula, we have already seen in this article How to Debug Oracle Absence Management Fast Formulas using ESS_LOG_WRITE method. However, problem with that approach is that it doesn’t work for all fast formula types, for example Performance Rating Calculation. There is no way to check log generated by function ESS_LOG_WRITE which you might have written inside formula type Performance Rating Calculation.
We have talked about the problem, but now lets also discuss about the solution. Thankfully, we have another function called ADD_RLOG(), which can be used to debug any fast formula types. Similar to ESS_LOG_WRITE, ADD_RLOGS also prints debug message but stores them in a table HWM_RULE_FF_WORK_LOG therefore we never have any challenge in accessing logs generated by formula that we are trying to debug.
How to use ADD_RLOG function to debug any fast formula
Approach to use add_rlog function to print log message inside our fast formula is slightly different than function ess_log_write. Let’s assume that you want to print person number of an employee, which is stored in the variable l_person_number, you will use below code inside your formula to print the variable.
l_msg = add_rlog(-999, 10, ‘Person Number is ‘|| l_person_number)
There are three parameters inside add_rlog function, lets understand them one by one.
- First Parameter : first parameter (-999) in the function is the Fast Formula Session id, you will have to pass a unique value so that you can easily identify your log messages from the table HWM_RULE_FF_WORK_LOG. This value will be stored in the column FFS_ID.
- Second Parameter : Second parameter (10) is the Rule id, this need not to be unique. But you can smartly use it to assign different rule id to each log message so that you can print/view your log messages sequentially from the table. This is important because as you will test/debug your same fast formula multiple times, all your messages will get added to table HWM_RULE_FF_WORK_LOG one after another and then it will become difficult for you to identify which log message belongs to which test you performed. This value is stored in the column RULE_ID.
- Third Parameter : Third parameter is the log message that you would like to display. This will be stored in the column LOG_TEXT.
How to retrieve message generated by ADD_RLOG function
Once you have added all your log messages inside the formula, next step is to retrieve them. However, before you can retrieve the message you must perform some step that will call the fast formula, which will internally generate log message. Steps you need to perform to call the formula, depends on the type of fast formula you are working on. For example, if you are working on formula type Performance Rating Calculation, you will have to attach the formula with correct performance template section and then perform steps like Worker Self Evolutions or Manager Evaluation of Workers to revoke the formula.
Once you perform necessary steps to generate the log message, you can use below query to get your messages from the table
SELECT LOG_TEXT, RULE_ID FROM HWM_RULE_FF_WORK_LOG WHERE FFS_ID = -999 order by LOG_ID, RULE_ID
You will see output like this
How to smartly use ADD_RLOG function inside fast formula
Once you start using add_log function to debug the formula you will notice that biggest problem with this approach is that it keeps on adding log message to the table without deleting previous messages and due to that it becomes difficult to identify which log message was generated by which run. To overcome this problem, you can define below two variables at the beginning of the formula.
l_ff_id = -99999 l_test_seq = 1
and then use your log message statement like this
l_msg = add_rlog(l_ff_id, l_test_seq, 'Person Number is '|| l_person_number)
and run below query to get message generated from your first run
SELECT LOG_TEXT, RULE_ID FROM HWM_RULE_FF_WORK_LOG WHERE FFS_ID = -999 AND RULE_ID = 1 order by LOG_ID, RULE_ID
Now if any further changes is required in your formula after going through the log messages, you can change the variable in the fast formula as follows and compile again. Perform steps that will generate log message.
l_ff_id = -99999 l_test_seq = 2 /* here value is incremented by one */
then to get new set of log messages use below query, which will only retrieve log messages from the latest test.
SELECT LOG_TEXT, RULE_ID
FROM HWM_RULE_FF_WORK_LOG
WHERE FFS_ID = -999
AND RULE_ID = 2
order by LOG_ID, RULE_ID
How did you find this approach?
The approach discussed in this article for debugging any fast formula is extensively used in Oracle Time and Labor (OTL). We hope this approach has proven helpful, and you can utilize it the next time you encounter any issues with your formula. However, remember that you’re not alone when seeking assistance with your formula. There is a supportive community of technical HCM professionals who are ready to lend a helping hand. Simply post your question on the hcmfolks.com forum to receive assistance from experts like yourself.