Timecard Entry Rules – OTL
In this article, we will talk about how to create Oracle timecard(OTL) entry rules and impose on timecard entry.
To validate a timecard when it is saved or submitted and display a business message, error or warning
Let’s assume the user enters more than 24 hours per day while timecard creation then we have to raise an error and stop user being save/submit the timecard.
This we can achieve by using Oracle seeded formula and by creating custom rules.
Oracle Seeded Formula:
- Create recurring periods
- Create a time entry rule
- Creare rule group
- Assign rule group to OTL preferences
- Enter a timecard and verify
Create Recurring Period:
OTL Super Administrator -> Recurring Periods
Provide recurring period name and don’t provide period type(in general it calculates for the whole week), so just provide duration in days value as 1(this is for the day)
start date is nothing but rule start date and the rule will be raised only when on/after the start date. If user creating time card before 01-JAN-2017 then this rule will not fire/execute.
Create a time entry rule:
OTL Super Administrator -> Time Entry Rules -> Define Time Entry Rules
Name: XXCUS_MAX_24HRS_SAVE(any suitable name)
Description: You’re not allowed enter more than 24hrs a day
Usage: Save or Submission/Resubmission(if we select to save this rule will be fired only during saving timecard and rule will not fire when we submit the timecard)
One rule for Save and another rule for Submission/Re-Submission
Formula: Seeded formula for Period Maximum
From Date: Rule to be applied from which date, we can provide a current date, future date or past date
Create a Rule Group:
OTL Super Administrator -> Time Entry Rules -> Define Time Entry Rule Groups
We can list out all the rules which we would like fire while creating/entering timecard and create under one group.
Name: XXCUS Timecard Entry Rules(Rule group name)
Rule Name: XXCUS_MAX_24HRS_SAVE
XXCUS_MAX_24HRS_SUBMIT
Time entry rule names, we have to select from LOV what is available in time entry rules screen. We selected what we created in the above step.
Outcome: Error(Rule outcome Error or Waring)
Assign Rule Group to OTL Preference:
We have to assign our rule group to OTL preference.
OTLSuper Administrator -> Preferences -> Preference Tree -> Select your own preference
Select your preference name, select Time Store and click on New
Give any name of the Tree
Preference should be Time Store Time Entry Rules
Preference Values XXCUS Timecard Entry Rules which we created in the above step.
Verify this OTL preference tree is assigned to particular employees/group in the organization.
Name of the rule: Provide any suitable name(XXCUS OTL)
Name of Branch: Preference Tree Name(You have created)
Link by: Organization (Select group or some criteria type to apply all these setups)
-
- Organization – US or AUS(All these setups/changes will be applied only employees under this Org)
- Person – Millar, Jhon (All these setups/changes will be applied only for one person)
- Person Type – Employee/Contingent
- All People – All Employees
Linked to: US/AUS(Select the value based on the link by selection)
Precedence: 20
- Let’s assume you have created 2 preference tree and you would like to assign it to a specific group/person then precedence need to be provided correct like 10 or 20
Precedence 10 will execute first and followed by 20
Timecard Entry:
Error: You’re not allowed to enter more than 24 hours a day
This is how we create an Oracle seeded rules for timecard entry in OTL
Rule 2: Users are not allowed to enter more than 40 hours per week
We have to approach the same steps as above the only formula definition/creation will change. We will see below how to which Oracle seeded formula to use.
Create a time entry rule
OTL Super Administrator -> Time Entry Rules -> Define Time Entry Rules
Name: XXCUS_MAX_40HRS_SAVE, XXCUS_MAX_40hrs_SUBMIT
Description: You’re not allowed to enter more than 40 hours per week.
Usage: Save and Submission/Resubmission
Formula: Seeded formula for Period Maimun
Inputs: Select the weekly period(Weekly – Starts Monday) and enter maximum hours per week(40 hours).
Create a Rule Group:
OTL Super Administrator -> Time Entry Rules -> Define Time Entry Rule Groups
Name: XXCUS Timecard Entry Rules(Rule group name)
Rule Name: XXCUS_MAX_40HRS_SAVE, XXCUS_MAX_40HRS_SUBMIT
Outcome: Error(Rule outcome Error or Waring)
Assign Rule Group to OTL Preference:
We have to assign our rule group to OTL preference.
OTLSuper Administrator -> Preferences -> Preference Tree -> Select your own preference
Select your preference name, select Time Store and click on New
Give any name of the Tree
Preference should be Time Store Time Entry Rules
Preference Values XXCUS Timecard Entry Rules which we created in the above step.
Timecard Entry:
Enter timecard with more than 40 hours per week and click on save/continue, then you’ll receive an error.
Now enter timecard with exact 40 hours per week and click on continue, then you won’t receive an error and you’ll go through the next page to submit the timecard as shown below.
nextpage(after clicking continue button)
Custom Rule Creation:
In the above scenarios, we have noticed rules for maximum hours for timecard entry
Rule1: Users are not allowed to enter more than 24 hours per day
Rule2: Users are not allowed to enter more than 40 hours per week
Now we will discuss how to implement the custom rules and impose those rules on Oracle Timecard entry page.
Rule 3: Preventing users to enter less than 40 hours per week
- Create a Database Function
- Create Fast Formula Function
- Create Fast Formula
- Create Custom FND Message
- Create a Time Entry Rule
- Create Time Rule Group
- Assign Rule Group to OTL Preference
- Timecard Entry and Verify
Create a Database Function:
We have to create custom logic to prevent the users do not enter less than 40 hours per week.
We do not have any Oracle Seeded formula available to use, so we are going with the custom logic.
CREATE OR REPLACE FUNCTION APPS.XXCUS_40HRS_FNC(P_RESOURCE_ID NUMBER) RETURN number IS v_hours NUMBER := 0; v_tbb_array HXC_BLOCK_TABLE_TYPE; v_time_info hxc_self_service_time_deposit.timecard_info; v_return_status number := 0; BEGIN -- To get timecard information v_time_info := hxc_self_service_time_deposit.get_building_blocks; -- Store current timecard info to the table type v_tbb_array := hxc_deposit_wrapper_utilities.blocks_to_array(p_blocks => v_time_info); IF v_tbb_array.FIRST IS NOT NULL THEN -- Here we loop the data, this is nothing but each day what we enter in the timecard entry page -- like Monday to Sunday FOR i IN v_tbb_array.FIRST .. v_tbb_array.LAST LOOP IF v_tbb_array(i).SCOPE = 'DETAIL' THEN v_hours := v_hours + v_tbb_array(i).MEASURE; -- l_tbb_array(i).MEASURE means hours what you enter END IF; END LOOP; IF v_hours < 40 THEN v_return_status := 1; return v_return_status; END IF; END IF; RETURN v_return_status; END XXCUS_40HRS_FNC;
Create Fast Formula Function:
Navigation: HRMS Manager -> Other Functions -> Formula Functions
Name: XXCUS_40HRS(Provide any suitable name)
Class: External Function
Definition: XXCUS_40HRS_FNC (This is the database function name and it should be same as DB object name)
Create Fast Formula:
Navigation: HRMS Manager -> Total Compensation -> Basic -> Wirte Formula
Save the changes
Name: XCUS_40HRS_F(Any suitable name)
Type: OTL Time Entry Rules
Click on Edit button and paste the below code
The IF condition is true we will raise an error through error message(fnd message) and should return the logic with rule return status and error message.
We should return rule_status with S(success)/E(error)
/* Initialise Variables which can be null ***************************************************************** */ default for db_pre_period_start is ' ' default for db_pre_period_end is ' ' default for db_post_period_start is ' ' default for db_post_period_end is ' ' default for db_ref_period_start is ' ' default for db_ref_period_end is ' ' default for timecard_hrs is 0 /* ****************************************************************** READ IN INPUT VARIABLES ****************************************************************** */ INPUTS ARE resource_id (number) , submission_date (text) , db_pre_period_start (text) , db_pre_period_end (text) , db_post_period_start (text) , db_post_period_end (text) , db_ref_period_start (text) , db_ref_period_end (text) , timecard_hrs (number) IF ( XXCUS_40HRS_FNC(resource_id) = 1 ) THEN (rule_status = 'E' message1 = 'XXCUS_40HRS_MSG' return rule_status,message1) ELSE (rule_status = 'S' return rule_status)
Verify the code without any error and formula should be verified as shown below
Create Custom FND Message:
Navigation: Application Developer -> Application -> Messages
Create a Time Entry Rule:
Navigation: OTL Super Administrator -> Time Entry Rules -> Define Time Entry Rules
Name: XXCUS_40HRS_SAVE
Usage: Save & Submission/Resubmission
Formula: Preventing users not to enter less than 40 hours per week(Custom Fast formula description)
Note: From the date of OTL time entry rule must be greater than Fast formula creation date, otherwise will receive a couple of errors.
Create a Rule Group:
Navigation: OTL Super Administrator -> Time Entry Rules -> Define Time Entry Rule Groups
Assign these rules(XXCUS_40HRS_SAVE, XXCUS_40HRS_SUBMIT) to rule group(XXCUS Timecard Entry Rules)
Assign Rule Group to OTL Preference:
Assign OTL rule group(XXCUS Timecard Entry Rules) to preferences the same as above.
Navigation: OTLSuper Administrator -> Preferences -> Preference Tree -> Select your own preference
Select your preference name, select Time Store and click on New
Preference should be Time Store Time Entry Rules
Preference Values XXCUS Timecard Entry Rules which we created in the above step.
Timecard Entry:
Enter timecard with less than 40 hours per week and click on save/continue, then you’ll receive an error.