Total Pageviews

March 8, 2016

3/08/2016 10:09:00 PM
Oracle APPS user hooks
What is User Hooks?

By Using  ‘Api Hooks’ we can extend the business logic of the standard business rules  that are executed by APIs.ie., if we want to add the extra validation which is not done by  the API. For Example,
We can create the employee through the CREATE_EMPLOYEE API, Even though we
won’t give the Nationality.

But we can add the functionality to the API in such a way that  if Nationality is not passed then API has to throw the error.
We can achieve this by using  API HOOKS.  

There are 5 different types of User Hook.

Two for Business Process APIs (Before Process  and After Process),
and 3 more for Row Handler APIs (After Insert,After Update and  After Delete).  
The two types of Business Process hook available are:  

Before Process ‐ These hooks execute logic before the main API logic. The  majority of  validation will not have taken place.
No database changes will have been made.
After Process  ‐ These hooks will execute after the main API validation has  completed  and database changes made. If the main validation failed then the user hook will not be  called.  

Row Handler Hooks     
The Row Handler hooks should be used if extra logic is required prior to  performing an Insert, Update or Delete on a specific table.

As all the main APIs  call the row handlers, these hooks would be executed by any API that updates  the specific table.    A full list of the Row Handler APIs can be obtained by running the
 following sql:

select module_name from hr_api_modules  where api_module_type='RH'  
The 3 types of Row Handler hook available are:  

  • After Insert  
  • After Update   
  • After Delete 

 
Steps to Implementing Hooks
There are basically 4 steps to implementing API User Hooks.      
1. Choose the API you wish to add some extra logic to.    
2. Write the PL/SQL procedure that you wish to be called by the hook.    
3. Register or associate the procedure you have written with one or more specific user  hooks.    4.Run the Run the processor program which builds logic to execute your pl/sql procedure from the hookup specified in 3

Choose the API you wish to add some extra logic to.        If we want to create the employee we need to call the API ‘CREATE_EMPLOYEE’.  (ahm.module_name='CREATE_EMPLOYEE').Following query will give the procedure  (CREATE_EMPLOYEE_A ) (API) to add the extra logic.    
select ahk.api_hook_idahk.api_module_id,ahk.hook_package,ahk.hook_procedure  
from       hr_api_hooks ahk,hr_api_modules ahm  
where     ahm.module_name='CREATE_EMPLOYEE' and ahm.api_module_type = 'BP'