0% found this document useful (0 votes)
17 views

HRMS API User Hook

Uploaded by

abdulrahim
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

HRMS API User Hook

Uploaded by

abdulrahim
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

11/13/24, 6:32 PM HRMS API User Hook

ORACLE APPS ESSENTIALS SEARCH

Home Useful Queries

HRMS API
User Hook

January 10, 2018

W hat is API? SHARE

Labels
API, an abbreviation
HRMS
of Application
User Hooks

Program Interface, is
a set of routines,

protocols, and tools

for building software

applications. The API


https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 1/43
11/13/24, 6:32 PM HRMS API User Hook

specifies how

software

components should

interact and APIs are

used when
programming

graphical user

interface (GUI)

components.

What is User Hook?

User Hook, is a pl/sql

code used to execute

from the standard

API.

Oracle has

supplemented the

core product API

functionality by the

addition of API user

hooks.

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 2/43
11/13/24, 6:32 PM HRMS API User Hook

When the API

processing reaches a

user hook, core

product processing

stops and any

customer specific

logic for that event is


executed. Then, if no

errors occur, the

main API processing

resumes.

You can use such

extra logic to add

functionality not

supplied directly by

Oracle Applications.

NOTE: You should


not manually edit the

API source code files


supplied by Oracle If

you do modify these

codes, Oracle

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 3/43
11/13/24, 6:32 PM HRMS API User Hook

Applications will be

unable to support

the product, and

upgrades may not be

possible. Oracle

Applications only

supports direct calls

to the published

APIs. Direct calls to

any other server-side

package procedures

or functions that are

written as part of the

Oracle HRMS

Applications suite are

not supported.

Hence, the

conclusion is User

hook is used to add

extra logic to the

Business APIs using

User Hooks

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 4/43
11/13/24, 6:32 PM HRMS API User Hook

Below diagram shows

the overview of how

the custom logic

executes in the

Oracle standard API:

User Hook Tables:

HR_API_HOOKS -
Contains all the API

hooks

HR_API_MODULES

– Module list in

which hooks

available

Steps to

Implementing User

Hooks:

There are basically 4

steps to

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 5/43
11/13/24, 6:32 PM HRMS API User Hook

implementing API

User Hooks.

1. Choose the API

you wish to hook

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 pre-


processor program
which builds the

logic to execute your


PL/SQL

procedure from the


hook specified in 3.

Note: Oracle has not


given the user hook

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 6/43
11/13/24, 6:32 PM HRMS API User Hook

option to all the

forms OR APIs.
HR_API_HOOKS

table gives the hook


details

Use
HR_API_MODULES

table to get the API


names (Module

Package) and the


procedure name
(Module Name) with

respective Module
Type.

A list of each API, it's

hooks, and the


parameters available

to a procedure called
by that hook, can be

obtained by running
the script

$PER_TOP/admin/s
ql/hrahkpar.sql.

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 7/43
11/13/24, 6:32 PM HRMS API User Hook

TYPES of User Hook:

There are 5 different


types of User Hooks
(Module Type in the

HR_API_MODULES):
> Business Process

APIs:
1. AD – After

Delete
2. AI – After

Insert
> Row Handler APIs:

1. AP – After
Process

2. AU – After
Update

3. BP – Before
Process

Example:

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 8/43
11/13/24, 6:32 PM HRMS API User Hook

Business Process
User Hooks:

The Business Process

hooks should be used


if extra logic is

required on top of
the standard

business process
logic. For instance,

CREATE_EMPLOYEE
,

UPDATE_ELEMENT
_ENTRY,etc.

A full list can be

obtained by running
the following script:
SELECT

module_name
FROM

hr_api_modules

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 9/43
11/13/24, 6:32 PM HRMS API User Hook

WHERE
api_module_type='B

P'

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

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 10/43
11/13/24, 6:32 PM HRMS API User Hook

validation failed then


the user hook will

not be called.

The following sql


retrieves the hook

details of the After


Process hook for the

CREATE_EMPLOYEE
business process.

SELECTahk.api_hook
_id,

ahk.api_module_id,

ahk.hook_package,

ahk.hook_procedure

FROM
hr_api_hooks ahk,

hr_api_modules

ahm

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 11/43
11/13/24, 6:32 PM HRMS API User Hook

WHERE
ahm.module_name='

CREATE_EMPLOYEE
'
and
ahm.api_module_ty

pe = 'BP'
and
ahk.api_hook_type =
'AP'

and
ahk.api_module_id=
ahm.api_module_id;

Row Handler User


Hooks:

The Row Handler

hooks should be used

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 12/43
11/13/24, 6:32 PM HRMS API User Hook

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='R

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 13/43
11/13/24, 6:32 PM HRMS API User Hook

H';

The following sql


retrieves hook details
for the After Insert
hook for the

PER_ALL_PEOPLE_
F table:

SELECT

ahk.api_hook_id,

ahk.hook_package,

ahk.hook_procedure

FROM
hr_api_hooks ahk,

hr_api_modules

ahm
WHERE
(ahm.module_name='
PER_ALL_PEOPLE_

F'

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 14/43
11/13/24, 6:32 PM HRMS API User Hook

OR
ahm.module_name='
PER_PEOPLE_F')
AND

ahm.api_module_ty
pe = 'RH'
AND
ahk.api_hook_type =
'AI'

AND
ahk.api_module_id=
ahm.api_module_id;

Core Product Logic

Core Product Logic

is split into a number


of components. For
tables that can be
altered

by an API there is an
internal row handler

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 15/43
11/13/24, 6:32 PM HRMS API User Hook

code module. These


rows handlers are

implemented for
nearly all the tables
in the system where
APIs are available.
They

control all the insert,


update, delete and
lock processing
required by the main

APIs. For
example, if a main
API needs to insert a
new row into the

PER_ALL_PEOPLE_
F table it
will not perform the
DML itself. Instead it

will execute the


PER_ALL_PEOPLE_
F row handler

Using User Hooks

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 16/43
11/13/24, 6:32 PM HRMS API User Hook

After choosing the

type of hook required


and the location for
it, the hook code
has to be written. It

then needs to be
registered, and
finally the hook
package

has to be modified to
call it. The example
used in this section
describes the

implementation of an
After Process hook in
the
CREATE_EMPLOYEE
Business Process API.

Writing the custom


PL/SQL procedure
The hook code must

be written in a
PL/SQL server-side

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 17/43
11/13/24, 6:32 PM HRMS API User Hook

package procedure.
The
procedure is always

called if registered
(unless the main
validation logic
errors first), and, any

conditional logic
must be
implemented in the
code
and an application

error raised if
required.

NOTE: No commits
or rollbacks are
allowed in the hook
procedure. These are
always

performed after the


API has been called
whether it be in a
PL/SQL wrapper or

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 18/43
11/13/24, 6:32 PM HRMS API User Hook

form.

When the PL/SQL


package has been
created, it must be

compiled
successfully
on the database.

Example:
CREATE OR
REPLACE PACKAGE
scoop_nationality_c
heck AS

PROCEDURE
polish_name_check

(p_last_name in

VARCHAR2

,p_nationality in
VARCHAR2);

END
scoop_nationality_c

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 19/43
11/13/24, 6:32 PM HRMS API User Hook

heck;
/

CREATE OR

REPLACE PACKAGE
BODY
scoop_nationality_c
heck AS

PROCEDURE
polish_name_check

(p_last_name in

VARCHAR2

,p_nationality in
VARCHAR2)

IS
BEGIN
-- When the first
name entered is a
polish name then

check that the


-- nationality
entered is Polish

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 20/43
11/13/24, 6:32 PM HRMS API User Hook

IF p_last_name =
'Chrosicka' THEN

IF p_nationality !=
'POL' THEN

dbms_standard.rais

e_application_error
(num => -20999

,msg

=> 'Nationality must


be Polish');
END IF;
END IF;

END
polish_name_check;
END
scoop_nationality_c
heck;

Registering the User


Hook

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 21/43
11/13/24, 6:32 PM HRMS API User Hook

The next step is to


link the custom
package procedure
created above

DECLARE
l_api_hook_call_id
NUMBER;

l_object_version_nu
mber NUMBER;

BEGIN

hr_api_hook_call_a
pi.create_api_hook_
call
(p_validate

=> FALSE,
p_effective_date
=>
TO_DATE('01-JUL-

1999','DD-MON-
YYYY'),

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 22/43
11/13/24, 6:32 PM HRMS API User Hook

p_api_hook_id
=> 63,

p_api_hook_call_ty
pe => 'PP',
p_sequence
=> 3000,

p_enabled_flag
=> 'Y',

p_call_package

=>
'SCOOP_NATIONALI

TY_CHECK',

p_call_procedure
=>

'POLISH_NAME_CH
ECK',

p_api_hook_call_id
=>

l_api_hook_call_id,

p_object_version_n

umber =>

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 23/43
11/13/24, 6:32 PM HRMS API User Hook

l_object_version_nu
mber);

EXCEPTION WHEN

OTHERS
DBMS_OUTPUT.PU

T_LINE(SUBSTR(SQL
ERRM,1,300)); --

Handle exception

END;

Points to be noted:

a. See section
‘Business Process

User Hooks’ to get

api_hook_id. (Refer
above queries)

b. The hook

mechanism only

supports calls to
package procedures

currently

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 24/43
11/13/24, 6:32 PM HRMS API User Hook

so

api_hook_call_type
must be PP.

c. Sequence

numbers > 2000 are

recommended, as
sequences < than

2000 are

reserved for
Oracle seeded logic

which needs to be
processed first.

Please note that

you can add any


number of hooks to

the same API, and


order them using

the sequence.

To Delete the user

hook:

DECLARE

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 25/43
11/13/24, 6:32 PM HRMS API User Hook

l_api_hook_call_id

NUMBER := 2;
l_object_version_nu

mber NUMBER := 3;

BEGIN

hr_api_hook_call_a
pi.delete_api_hook_

call
(p_validate

=> FALSE,

p_api_hook_call_id

=>
l_api_hook_call_id,

p_object_version_n
umber =>

l_object_version_nu

mber);

EXCEPTION WHEN
OTHERS

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 26/43
11/13/24, 6:32 PM HRMS API User Hook

DBMS_OUTPUT.PU

T_LINE(SUBSTR(SQL

ERRM,1,300)); --
Handle exception

END;

The above call is

deleting a specific
user hook. Please

note any changes

made to the
HR_API_HOOK_CA

LLS table, be they via


the supplied

procedures or not,

will only be effective


once the pre-

processor has been

run.

Running the Pre-

Processor

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 27/43
11/13/24, 6:32 PM HRMS API User Hook

Adding rows to the


HR_API_HOOK_CA

LLS table by itself is


not sufficient to

enable this extra

logic to be called.
The pre-processor

program must be

called
first. This will look at

the definitions in the


table and build

another package

body in the database


which is known as

the hook package

body.

If successful, the
pre-processor will

hard code the calls to

the custom package


procedures into the

hook package body. If

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 28/43
11/13/24, 6:32 PM HRMS API User Hook

no extra logic is
implemented the

hook package body

is
still created but

without any calls to

custom procedures.

During upgrades the


pre-processor

program will be

automatically called
to create

the hook package


bodies.

To run the pre-


processor run one of

the following

commands:

cd
$PER_TOP/admin/s

ql

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 29/43
11/13/24, 6:32 PM HRMS API User Hook

Log into SQLPLUS as

the APPS user


SQL> @hrahkall.sql

OR

SQL> @hrahkone.sql

NOTE: The first


script will create all
hook package bodies,

whilst the second


will create hook

package bodies for

one API module only,


and prompt for that

api_module_id.

Refer to the results


of the query

executed in
above(first query) to

obtain the

api_module_id.

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 30/43
11/13/24, 6:32 PM HRMS API User Hook

Tips on resolving

Invalid Hook
Packages

Occasionally when
applying patches

Hook Packages may

fail to compile. This


could

be for a variety of
reasons. Running the

report

$PER_TOP/patch/11
5/sql/hrahkall.sql

will provide a

comprehensive list of
the invalid hook

packages.

Sometimes the

problem may simply


be resolved by

reapplying the hook


package

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 31/43
11/13/24, 6:32 PM HRMS API User Hook

Refer HRMS

Implementation
guide for examples

To find the code used


by a User Hook

You can use the hook

name and type from

the error message:

SELECT

api_hook_id,
hook_procedure

FROM
hr_api_hooks

WHERE

api_hook_type = 'AP'
AND

hook_procedure
LIKE

'UPDATE_ORG_INF

ORMATION%';

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 32/43
11/13/24, 6:32 PM HRMS API User Hook

SELECT

call_package,

call_procedure,
legislation_code

FROM
hr_api_hook_calls

WHERE

api_hook_id =
5012; -- Got this

value from the above


query

The following query

will provide you the

additional
information:

SELECT *

FROM

hr_api_hook_calls
WHERE api_hook_id

IN (SELECT

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 33/43
11/13/24, 6:32 PM HRMS API User Hook

api_hook_id

FROM

hr_api_hooks

WHERE

api_module_id =
(SELECT

api_module_id

FROM
hr_api_modules

WHERE

module_name LIKE
'UPDATE_ORG_INF

ORMATION%'));

*******************

*******************
*******************

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 34/43
11/13/24, 6:32 PM HRMS API User Hook

*******************

*******************
**

Please refer the


below unpublished

metalink note OR
HRMS

implementation

guide for more info


on User hooks:

> Understanding and

Using Application
Program Interface

(API) User Hooks in


Oracle HRMS [ID

73170.1]

> Refer ‘API User

Hooks’ section in
Oracle HRMS

Implementation

Guide

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 35/43
11/13/24, 6:32 PM HRMS API User Hook

List of APIs

The following APIs


support all the API

event points (Before


process; After

process) :

applicant assignment

offer_apl_asg

update_apl_asg
contact relationship

create_contact_rela
tionship

delete_contact_relat

ionship
employee

actual_termination_
emp

final_process_emp

create_employee
employee assignment

activate_emp_asg

suspend_emp_asg

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 36/43
11/13/24, 6:32 PM HRMS API User Hook

final_process_emp_
asg

update_emp_asg
actual_termination_

emp_asg

employee assignment
criteria

update_emp_asg_cr

iteria
grade rate value

create_grade_rate_
value

update_grade_rate_

value
delete_grade_rate_

value
job requirement

create_job_require

ment
mass moves

mass_moves

pay scale value


create_pay_scale_v

alue

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 37/43
11/13/24, 6:32 PM HRMS API User Hook

update_pay_scale_v
alue

delete_pay_scale_va

lue
person address

create_person_addr
ess

update_person_add

ress
personal payment

method

create_personal_pay
ment_method

update_personal_pa
yment_method

position

create_position
update_position

position requirement

create_position_req
uirement

secondary applicant
assignment

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 38/43
11/13/24, 6:32 PM HRMS API User Hook

create_secondary_a

pl_asg
secondary employee

assignment
create_secondary_e

mp_asg

Row Handlers

The Row Handlers on


the following tables

support all the Row


Handler event points

(After insert; After

update; After delete) :

PER_ADDRESSES

PER_ALL_PEOPLE_
F

PER_ALL_ASSIGNM
ENTS_F

PAY_PERSONAL_PA

YMENT_METHODS
_F

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 39/43
11/13/24, 6:32 PM HRMS API User Hook

PER_POSITIONS

PER_APPLICATIONS
PER_CONTACT_REL

ATIONSHIPS

LABELS: HRMS,

USER HOOKS

SHARE
Comments

Enter comment

Popular posts from this blog

How to
setup
and use
AME -
Approv
al
https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 40/43
11/13/24, 6:32 PM HRMS API User Hook

Manage
ment
Engine
September 15,
2017

Approval
Management

Engine - AME

For Purchase…

SHARE
POST A
COMMENT
READ MORE

How to
compile
all
INVALI
D
objects
in
Oracle
https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 41/43
11/13/24, 6:32 PM HRMS API User Hook

September 05,
2017

There are five

ways to

recompile
invalid objects

SHARE
POST A
COMMENT
READ MORE

Workfl
ow
Importa
nt
Debug
Queries
August 30, 2017

deq_time is

not always

populated in
WF_DEFERR…

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 42/43
11/13/24, 6:32 PM HRMS API User Hook

SHARE
POST A
COMMENT
READ MORE

About Me

Aniket
VISIT PROFILE

Powered by Blogger

Archive

Powered by Blogger

https://oracleappsessentials.blogspot.com/2018/01/hrms-api-user-hook.html 43/43

You might also like