Professional Documents
Culture Documents
User Hook Implemantation Sample Example
User Hook Implemantation Sample Example
com
Business Requirement:
Business wants to ensure that whenever an employee tries to overbook leaves the system should not allow him to do so. In case of exceptional situations the user will contact the Local HR who will then enter his/her leaves in the system. In 11i Oracle Absence Management user/employee only gets a warning message stating that after you apply this leave your balance will be negative , but allows the user to ignore and proceed. The approver too does not gets any such message so the approver is completely in dark and so he unknowingly approves it. In order to achieve this there are two options : a) Upgrade your Application to R12 b) Write custom logic within user hook. Now, it is not always possible to move to a higher version just for achieving some functionality although that would be best considering the added features you get with next upgrade, but as a stop gap solution we would try to see how we can get this done via user hook.
On investigation it was found that there is a particular out parameter p_exceeds_pto_entit_warning which gives the message on self-service screen. Since it is a out parameter we have to choose the API Hook of process type 'BP' and after insert.
Now I have written a package which takes p_exceeds_pto_entit_warning as input and displays the error message. I have also used a custom profile option XXC_LOA_RESTRICT_OVERBOOKING to ensure I have the option of switching on/off the functionality.
User Hook Implementation A Sample Example http://oracleapps-atechniciansview.blogspot.co.uk/ Author : Ashish Harbhajanka Email : [email protected]
Name : XXC_LOA_RESTRICT_OVERBOOKING User Profile Name : XXC: LOA Restrict Overbooking Hierarchy Type Access Level : Responsibility and user ( visible and updatable) User Access : Visible SQL Validation: SQL="select meaning \"Yes or No\", lookup_code into :visible_option_value, :profile_option_value from fnd_lookups where lookup_type = 'YES_NO'" COLUMN="\"Yes or No\"(*)" N.B: We have define this profile option value to ensure that the error will be thrown only when employees try to overbook using Self Service Responsibility but when the changes are to be incorporated from Absence Details screen it would allow HR to add details ( with seeded warning message). In case you want to switch on this functionality just set the value of profile at Responsibility level to Yes to switch off set the same to No.
This gives the flexibility that from Employee Self Service error will be displayed but not from core Absence Details form
User Hook Implementation A Sample Example http://oracleapps-atechniciansview.blogspot.co.uk/ Author : Ashish Harbhajanka Email : [email protected] Message : You have exceeded the maximum limit for this absence type. Please resubmit based on the local policy for this leave type.
select hah.api_hook_id,ham.api_module_id from apps.hr_api_hooks hah, apps.hr_api_modules ham where hah.api_module_id = ham.api_module_id
User Hook Implementation A Sample Example http://oracleapps-atechniciansview.blogspot.co.uk/ Author : Ashish Harbhajanka Email : [email protected] and hah.hook_package = 'HR_PERSON_ABSENCE_BK1' and hah.hook_procedure = 'CREATE_PERSON_ABSENCE_A'
DECLARE P_VALIDATE BOOLEAN; P_EFFECTIVE_DATE DATE; P_API_HOOK_ID NUMBER; P_API_HOOK_CALL_TYPE VARCHAR2(200); P_SEQUENCE NUMBER; P_ENABLED_FLAG VARCHAR2(200); P_CALL_PACKAGE VARCHAR2(200); P_CALL_PROCEDURE VARCHAR2(200); P_API_HOOK_CALL_ID NUMBER; P_OBJECT_VERSION_NUMBER NUMBER;
BEGIN P_VALIDATE := TRUE; P_EFFECTIVE_DATE := 01-JAN-1951; P_API_HOOK_ID := 3840;-- derived from SQL1 P_API_HOOK_CALL_TYPE := 'PP'; P_SEQUENCE := 3000; -- any value greater than 2000, 1-2000 reserved for Oracle Use P_ENABLED_FLAG := 'Y'; P_CALL_PACKAGE := 'XXC_HR_USER_HOOK_PKG'; -- custom package
User Hook Implementation A Sample Example http://oracleapps-atechniciansview.blogspot.co.uk/ Author : Ashish Harbhajanka Email : [email protected] P_CALL_PROCEDURE := 'XXC_LOA_RESTRICT_OVERBOOKING'; -- custom procedure P_API_HOOK_CALL_ID := NULL; P_OBJECT_VERSION_NUMBER := NULL;
APPS.HR_API_HOOK_CALL_API.CREATE_API_HOOK_CALL ( P_VALIDATE, P_EFFECTIVE_DATE, P_API_HOOK_ID, P_API_HOOK_CALL_TYPE, P_SEQUENCE, P_ENABLED_FLAG, P_CALL_PACKAGE, P_CALL_PROCEDURE, P_API_HOOK_CALL_ID, P_OBJECT_VERSION_NUMBER ); COMMIT; dbms_output.put_line('API Hook ID: '|| P_API_HOOK_ID); dbms_output.put_line('API OVN: '|| P_OBJECT_VERSION_NUMBER); EXCEPTION WHEN OTHERS THEN dbms_output.put_line('Error: '|| SQLCODE||SQLERRM); END;
-- Output of above query -- API Hook Call ID: 864 -- API OVN: 1
------Query to execute Pre-processor--------------------------------Login to your unix enviornment and connect sqlplus go to $PER_TOP/admin/sql execute hrahkone.sql it will ask for module id derived from sql1
After completing the desired steps and setting the profile value of your Responsibility to Yes / No the application will work as per business requirement.