User Hooks in Oracle HRMS
API User Hooks refers to points in the API execution to which
customers can
attach or extend business logic. User-defined code can be
“hooked” into these
predefined locations, and executed in conjunction with the API
call.
User code can: extend validation on Oracle HRMS tables,
maintain data in
external customer-specific tables (not part of Oracle
Applications)
simultaneously with the Oracle HRMS updates through the API, or
send alerts at
particular Oracle HRMS events.
The explicit limitation for customer extensions remains—any and
all HRMS
data manipulation must be performed by HRMS APIs.
User Hooks offer similar functionality to the Custom Library,
but at the database
rather than in the Forms front end.
User Hooks allow logic extensions without changing delivered API
code. Hooks
are regenerated at upgrade. However, since schema changes may
occur at any
time, all custom procedures should be tested after upgrade.
Additionally, API
Hooks are available to any interface that calls the API, such
as: Forms, Self-
Service, and Data Pump.
Not all HRMS Forms use APIs; a trace can identify whether a Form
uses APIs.
Only Forms that call APIs will execute a User Hooked code. If
the Form does
not use APIs, the same code extension can be implemented in
Custom Library.
The HR_API_HOOKS table holds all available API hooks for APIs in
HR_API_MODULES table.
Implementing User Hooks
Four steps are required to implement API User
Hooks:
1. Determine the API to which you need to hook
extra logic
2. Write the PL/SQL procedure that executes
your logic.
3. Register your procedure with one or more
specific user hooks.
4. Run the pre-processor program that hooks your PL/SQL
procedure to the
hook(s).
Oracle HRMS has
several types of hooks. Only Business Process Hooks
correspond to Business
Process APIs. They are used when logic must extend
beyond the standard
business process. Only Business Process Hooks are
Supported for Customer
use. A list can be obtained by running the following
query:
select module_name
from hr_api_modules
where api_module_type='BP';
The
$PER_TOP/admin/sql/hrahkpar.sql script provides listing of each API, its
hooks, and
corresponding procedure parameters.Sample Hook Implementation
Get
Hook Information
SELECT ahk.api_hook_id,
ahk.api_module_id,
ahk.hook_package,
ahk.hook_procedure
FROM hr_api_hooks ahk, hr_api_modules ahm
WHERE ahm.module_name = 'CREATE_PERSON_ABSENCE' -- Module Name
AND ahm.api_module_type = 'BP'
AND ahk.api_hook_type = 'AP'
AND ahk.api_module_id = ahm.api_module_id
Hook
Registration
DECLARE
l_api_hook_call_id NUMBER;
l_object_version_number NUMBER;
l_sequence NUMBER;
BEGIN
SELECT
HR_API_HOOKS_S.NEXTVAL
INTO l_sequence
FROM dual;
Hr_Api_Hook_Call_Api.create_api_hook_call
(p_validate => FALSE,
p_effective_date => TO_DATE('01-JAN-1952','DD-MON-YYYY'),
p_api_hook_id =>
p_api_hook_call_type => 'PP',
p_sequence => l_sequence,
p_enabled_flag => 'Y',
p_call_package =>
'LMHR_HOOK_VALIDATIONS_PKG', -- Custom Package
p_call_procedure =>
UPPER('Validate_Objectives_Weight'), -- Custom procedure
p_api_hook_call_id => l_api_hook_call_id,
p_object_version_number => l_object_version_number);
DBMS_OUTPUT.PUT_LINE('l_api_hook_call_id '||
l_api_hook_call_id);
END ;
Run
the pre-processor script
Run pre-processor
script hrahkone.sql with module name as parameter
(PER_TOP/admin/sql/hrahkone.sql).It compile API hook. After running this your APIhook Package
should have custom procedure call.
Delete custom code from APIuser Hook
Get Hook Call ID and Object Version_number
Delete custom code from APIuser Hook
Get Hook Call ID and Object Version_number
Select api_hook_call_id,object_version_number from
HR_API_HOOK_CALLS where call_package like ‘LMHR%’ and call_procedure =
UPPER('Validate_Objectives_Weight')
Hook Deletion
BEGIN
Hr_Api_Hook_Call_Api.delete_api_hook_call ( p_validate => FALSE,
p_api_hook_call_id => ,
p_object_version_number
=>2
);
DBMS_OUTPUT.PUT_LINE('deleted Successfully');
END;
No comments:
Post a Comment