/***Step 1 run the following query to find if there any user Hook available for the object that you need ***/
select *
from HR_API_HOOKS
where hook_procedure LIKE 'CREATE_SIT%';
API_HOOK_ID = 2758
API_MODULE_ID = 1226
/***Step 2 Run the following Procedure ***/
declare
l_api_hook_call_id number;
l_object_version_number number;
begin
hr_api_hook_call_api.create_api_hook_call
(p_validate => false,
p_effective_date => to_date('01-JUL-1999','DD-MON-YYYY'),
p_api_hook_id => 2758,
p_api_hook_call_type => 'PP',
p_sequence => 2000,
p_enabled_flag => 'Y',
p_call_package => 'XXPBAD_USER_HOOK',
p_call_procedure => 'CHECK_DUPLICATE_PASSPORT',
p_api_hook_call_id => l_api_hook_call_id,
p_object_version_number => l_object_version_number);
COMMIT;
end;
/***Step 3 Run the following Procedure ***/
SELECT ENABLED_FLAG
FROM HR_API_HOOK_CALLS
WHERE API_HOOK_ID = 2758 ;
/* ENABLED_FLAG should be YES */
/***Step 4 Run the hrahkone.sql ***/ $PER_TOP/admin/sql/hrahkpar.sql.
declare
l_api_module_id number;
begin
l_api_module_id := &API_MODULE_ID;
--
-- Create all hook package body source code for one API module
--
hr_api_user_hooks_utility.create_hooks_one_module(l_api_module_id);
--
-- Build the report text
--
END;
/
/***Step 5 Run the following query ***/
SELECT STATUS
FROM HR_API_HOOK_CALLS
WHERE API_HOOK_ID = 2879 ;
Example requirement to Validate fields in Absence Screen in SSHR:
Requirment:
1. If leave type is 'Annual Leave' and reason is null, then error msg should be shown.
2. If leave type is 'Maternity leave' and days less than 45 then error msg should be shown.
Step 1 – Identifying the correct User Hook API
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 like '%_PERSON_ABSENCE%'
AND ahm.api_module_type = 'BP'
AND ahk.api_hook_type = 'AP'
AND ahk.api_module_id = ahm.api_module_id
It will show all Person Absence relevant APIs.We need to select the correct API that matched with our requirement. For Example for above mentioned requirement, we shall select CREATE_PERSON_ABSENCE_A API. We shall note its API_HOOK_ID (3840) and API_MODULE_ID (1731) as API_HOOK_ID will be used at the time of registration of user hook mentioned in Step 3 ahead and API_MODULE_ID will be needed in running the processor in Step 4.
Step 2. Create PL/SQL procedure to execute your logic.
CREATE OR REPLACE PACKAGE APPS.XX_LSG_USERHOOK_PKG IS
PROCEDURE XXALB_CREATE_ABS_VAL_P
(P_EFFECTIVE_DATE IN DATE
,P_PERSON_ID IN NUMBER
,P_BUSINESS_GROUP_ID IN NUMBER
,P_ABSENCE_ATTENDANCE_TYPE_ID IN NUMBER
,P_ABS_ATTENDANCE_REASON_ID IN NUMBER
,P_COMMENTS IN LONG
,P_DATE_NOTIFICATION IN DATE
,P_DATE_PROJECTED_START IN DATE
,P_TIME_PROJECTED_START IN VARCHAR2
,P_DATE_PROJECTED_END IN DATE
,P_TIME_PROJECTED_END IN VARCHAR2
,P_DATE_START IN DATE
,P_TIME_START IN VARCHAR2
,P_DATE_END IN DATE
,P_TIME_END IN VARCHAR2
,P_ABSENCE_DAYS IN NUMBER
,P_ABSENCE_HOURS IN NUMBER
,P_AUTHORISING_PERSON_ID IN NUMBER
,P_REPLACEMENT_PERSON_ID IN NUMBER
,P_ATTRIBUTE_CATEGORY IN VARCHAR2
,P_ATTRIBUTE1 IN VARCHAR2
,P_ATTRIBUTE2 IN VARCHAR2
,P_ATTRIBUTE3 IN VARCHAR2
,P_ATTRIBUTE4 IN VARCHAR2
,P_ATTRIBUTE5 IN VARCHAR2
,P_ATTRIBUTE6 IN VARCHAR2
,P_ATTRIBUTE7 IN VARCHAR2
,P_ATTRIBUTE8 IN VARCHAR2
,P_ATTRIBUTE9 IN VARCHAR2
,P_ATTRIBUTE10 IN VARCHAR2
,P_ATTRIBUTE11 IN VARCHAR2
,P_ATTRIBUTE12 IN VARCHAR2
,P_ATTRIBUTE13 IN VARCHAR2
,P_ATTRIBUTE14 IN VARCHAR2
,P_ATTRIBUTE15 IN VARCHAR2
,P_ATTRIBUTE16 IN VARCHAR2
,P_ATTRIBUTE17 IN VARCHAR2
,P_ATTRIBUTE18 IN VARCHAR2
,P_ATTRIBUTE19 IN VARCHAR2
,P_ATTRIBUTE20 IN VARCHAR2
,P_PERIOD_OF_INCAPACITY_ID IN NUMBER
,P_SSP1_ISSUED IN VARCHAR2
,P_MATERNITY_ID IN NUMBER
,P_SICKNESS_START_DATE IN DATE
,P_SICKNESS_END_DATE IN DATE
,P_PREGNANCY_RELATED_ILLNESS IN VARCHAR2
,P_REASON_FOR_NOTIFICATION_DELA IN VARCHAR2
,P_ACCEPT_LATE_NOTIFICATION_FLA IN VARCHAR2
,P_LINKED_ABSENCE_ID IN NUMBER
,P_BATCH_ID IN NUMBER
,P_CREATE_ELEMENT_ENTRY IN BOOLEAN
,P_ABS_INFORMATION_CATEGORY IN VARCHAR2,
P_ABS_INFORMATION1 IN VARCHAR2,
--P_ABS_INFORMATION1 IN VARCHAR2,
P_ABS_INFORMATION2 IN VARCHAR2,
P_ABS_INFORMATION3 IN VARCHAR2,
P_ABS_INFORMATION4 IN VARCHAR2,
P_ABS_INFORMATION5 IN VARCHAR2,
P_ABS_INFORMATION6 IN VARCHAR2,
P_ABS_INFORMATION7 IN VARCHAR2,
P_ABS_INFORMATION8 IN VARCHAR2,
P_ABS_INFORMATION9 IN VARCHAR2,
P_ABS_INFORMATION10 IN VARCHAR2,
P_ABS_INFORMATION11 IN VARCHAR2,
P_ABS_INFORMATION12 IN VARCHAR2,
P_ABS_INFORMATION13 IN VARCHAR2,
P_ABS_INFORMATION14 IN VARCHAR2,
P_ABS_INFORMATION15 IN VARCHAR2,
P_ABS_INFORMATION16 IN VARCHAR2,
P_ABS_INFORMATION17 IN VARCHAR2,
P_ABS_INFORMATION18 IN VARCHAR2,
P_ABS_INFORMATION19 IN VARCHAR2,
P_ABS_INFORMATION20 IN VARCHAR2,
P_ABS_INFORMATION21 IN VARCHAR2,
P_ABS_INFORMATION22 IN VARCHAR2,
P_ABS_INFORMATION23 IN VARCHAR2,
P_ABS_INFORMATION24 IN VARCHAR2,
P_ABS_INFORMATION25 IN VARCHAR2,
P_ABS_INFORMATION26 IN VARCHAR2,
P_ABS_INFORMATION27 IN VARCHAR2,
P_ABS_INFORMATION28 IN VARCHAR2,
P_ABS_INFORMATION29 IN VARCHAR2,
P_ABS_INFORMATION30 IN VARCHAR2,
P_ABSENCE_CASE_ID IN NUMBER
);
END ;
/
--XX_LSG_USERHOOK_PKG.XXALB_CREATE_ABS_VAL_P
CREATE OR REPLACE PACKAGE BODY XX_LSG_USERHOOK_PKG IS
PROCEDURE XXALB_CREATE_ABS_VAL_P
(P_EFFECTIVE_DATE IN DATE
,P_PERSON_ID IN NUMBER
,P_BUSINESS_GROUP_ID IN NUMBER
,P_ABSENCE_ATTENDANCE_TYPE_ID IN NUMBER
,P_ABS_ATTENDANCE_REASON_ID IN NUMBER
,P_COMMENTS IN LONG
,P_DATE_NOTIFICATION IN DATE
,P_DATE_PROJECTED_START IN DATE
,P_TIME_PROJECTED_START IN VARCHAR2
,P_DATE_PROJECTED_END IN DATE
,P_TIME_PROJECTED_END IN VARCHAR2
,P_DATE_START IN DATE
,P_TIME_START IN VARCHAR2
,P_DATE_END IN DATE
,P_TIME_END IN VARCHAR2
,P_ABSENCE_DAYS IN NUMBER
,P_ABSENCE_HOURS IN NUMBER
,P_AUTHORISING_PERSON_ID IN NUMBER
,P_REPLACEMENT_PERSON_ID IN NUMBER
,P_ATTRIBUTE_CATEGORY IN VARCHAR2
,P_ATTRIBUTE1 IN VARCHAR2
,P_ATTRIBUTE2 IN VARCHAR2
,P_ATTRIBUTE3 IN VARCHAR2
,P_ATTRIBUTE4 IN VARCHAR2
,P_ATTRIBUTE5 IN VARCHAR2
,P_ATTRIBUTE6 IN VARCHAR2
,P_ATTRIBUTE7 IN VARCHAR2
,P_ATTRIBUTE8 IN VARCHAR2
,P_ATTRIBUTE9 IN VARCHAR2
,P_ATTRIBUTE10 IN VARCHAR2
,P_ATTRIBUTE11 IN VARCHAR2
,P_ATTRIBUTE12 IN VARCHAR2
,P_ATTRIBUTE13 IN VARCHAR2
,P_ATTRIBUTE14 IN VARCHAR2
,P_ATTRIBUTE15 IN VARCHAR2
,P_ATTRIBUTE16 IN VARCHAR2
,P_ATTRIBUTE17 IN VARCHAR2
,P_ATTRIBUTE18 IN VARCHAR2
,P_ATTRIBUTE19 IN VARCHAR2
,P_ATTRIBUTE20 IN VARCHAR2
,P_PERIOD_OF_INCAPACITY_ID IN NUMBER
,P_SSP1_ISSUED IN VARCHAR2
,P_MATERNITY_ID IN NUMBER
,P_SICKNESS_START_DATE IN DATE
,P_SICKNESS_END_DATE IN DATE
,P_PREGNANCY_RELATED_ILLNESS IN VARCHAR2
,P_REASON_FOR_NOTIFICATION_DELA IN VARCHAR2
,P_ACCEPT_LATE_NOTIFICATION_FLA IN VARCHAR2
,P_LINKED_ABSENCE_ID IN NUMBER
,P_BATCH_ID IN NUMBER
,P_CREATE_ELEMENT_ENTRY IN BOOLEAN
,P_ABS_INFORMATION_CATEGORY IN VARCHAR2,
P_ABS_INFORMATION1 IN VARCHAR2,
--P_ABS_INFORMATION1 IN VARCHAR2,
P_ABS_INFORMATION2 IN VARCHAR2,
P_ABS_INFORMATION3 IN VARCHAR2,
P_ABS_INFORMATION4 IN VARCHAR2,
P_ABS_INFORMATION5 IN VARCHAR2,
P_ABS_INFORMATION6 IN VARCHAR2,
P_ABS_INFORMATION7 IN VARCHAR2,
P_ABS_INFORMATION8 IN VARCHAR2,
P_ABS_INFORMATION9 IN VARCHAR2,
P_ABS_INFORMATION10 IN VARCHAR2,
P_ABS_INFORMATION11 IN VARCHAR2,
P_ABS_INFORMATION12 IN VARCHAR2,
P_ABS_INFORMATION13 IN VARCHAR2,
P_ABS_INFORMATION14 IN VARCHAR2,
P_ABS_INFORMATION15 IN VARCHAR2,
P_ABS_INFORMATION16 IN VARCHAR2,
P_ABS_INFORMATION17 IN VARCHAR2,
P_ABS_INFORMATION18 IN VARCHAR2,
P_ABS_INFORMATION19 IN VARCHAR2,
P_ABS_INFORMATION20 IN VARCHAR2,
P_ABS_INFORMATION21 IN VARCHAR2,
P_ABS_INFORMATION22 IN VARCHAR2,
P_ABS_INFORMATION23 IN VARCHAR2,
P_ABS_INFORMATION24 IN VARCHAR2,
P_ABS_INFORMATION25 IN VARCHAR2,
P_ABS_INFORMATION26 IN VARCHAR2,
P_ABS_INFORMATION27 IN VARCHAR2,
P_ABS_INFORMATION28 IN VARCHAR2,
P_ABS_INFORMATION29 IN VARCHAR2,
P_ABS_INFORMATION30 IN VARCHAR2,
P_ABSENCE_CASE_ID IN NUMBER
)
IS
L_ABSENCE_TYPE VARCHAR2 (500) := NULL;
L_ASSIGNMENT_ID NUMBER;
L_ABSENCE_START_DATE DATE := NVL (P_DATE_START, P_DATE_PROJECTED_START);
L_ABSENCE_END_DATE DATE := NVL (P_DATE_END, P_DATE_PROJECTED_END);
L_ABSENCE_FUTURE_ST_DATE DATE;
L_ABSENCE_FUTURE_END_DATE DATE;
BEGIN
SELECT NAME
INTO L_ABSENCE_TYPE
FROM PER_ABSENCE_ATTENDANCE_TYPES
WHERE ABSENCE_ATTENDANCE_TYPE_ID = P_ABSENCE_ATTENDANCE_TYPE_ID
AND BUSINESS_GROUP_ID = P_BUSINESS_GROUP_ID;
--Annual Leave
IF P_ABSENCE_ATTENDANCE_TYPE_ID = 62 AND P_ABS_ATTENDANCE_REASON_ID IS NULL THEN
HR_UTILITY.SET_MESSAGE (800, 'LSG_ANN_LEAVE_REAS');
HR_UTILITY.RAISE_ERROR;
ELSIF P_ABSENCE_ATTENDANCE_TYPE_ID = 63 AND P_ABS_ATTENDANCE_REASON_ID IS NULL THEN
HR_UTILITY.SET_MESSAGE (800, 'LSG_MAT_LEV_REAS');
HR_UTILITY.RAISE_ERROR;
--Maternity Leave
ELSIF (P_ABSENCE_ATTENDANCE_TYPE_ID = 63 and P_ABS_ATTENDANCE_REASON_ID = 61) and (P_ABSENCE_DAYS <> 60) THEN
HR_UTILITY.SET_MESSAGE (800, 'LSG_MAT_60DAYS');
HR_UTILITY.RAISE_ERROR;
ELSIF (P_ABSENCE_ATTENDANCE_TYPE_ID = 63 and P_ABS_ATTENDANCE_REASON_ID = 62) and (P_ABSENCE_DAYS <> 45) THEN
HR_UTILITY.SET_MESSAGE (800, 'LSG_MAT_45DAYS');
HR_UTILITY.RAISE_ERROR;
END IF;
END;
END ;
3. Register your procedure with one or more specific user hooks.
We shall use the API_HOOK_ID identified in Step 1 in the parameter p_api_hook_id. Through this API, custom logic will be registered against user hook.
DECLARE
L_API_HOOK_ID NUMBER := 3840 ;
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 =>L_API_HOOK_ID,
P_API_HOOK_CALL_TYPE => 'PP',
P_SEQUENCE => L_SEQUENCE,
P_ENABLED_FLAG => 'Y',
P_CALL_PACKAGE => 'XX_LSG_USERHOOK_PKG', -- CUSTOM PACKAGE
P_CALL_PROCEDURE => 'XXALB_CREATE_ABS_VAL_P', -- 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 ;
After this step, you shall be able to see the reference of your custom package/ procedure in table HR_API_HOOK_CALLS. You can check it by using following query
SELECT *
FROM HR_API_HOOK_CALLS
WHERE api_hook_id = 3840;
4. Run the pre-processor program
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.
or
declare
l_api_module_id number := 1731; --Value 1731 is derived from Step 1 above using following query
begin
hr_api_user_hooks_utility.create_hooks_one_module (l_api_module_id);
dbms_output.put_line('Success');
exception when others then
dbms_output.put_line('Exception : '||SQLERRM);
end;
select *
from HR_API_HOOKS
where hook_procedure LIKE 'CREATE_SIT%';
API_HOOK_ID = 2758
API_MODULE_ID = 1226
/***Step 2 Run the following Procedure ***/
declare
l_api_hook_call_id number;
l_object_version_number number;
begin
hr_api_hook_call_api.create_api_hook_call
(p_validate => false,
p_effective_date => to_date('01-JUL-1999','DD-MON-YYYY'),
p_api_hook_id => 2758,
p_api_hook_call_type => 'PP',
p_sequence => 2000,
p_enabled_flag => 'Y',
p_call_package => 'XXPBAD_USER_HOOK',
p_call_procedure => 'CHECK_DUPLICATE_PASSPORT',
p_api_hook_call_id => l_api_hook_call_id,
p_object_version_number => l_object_version_number);
COMMIT;
end;
/***Step 3 Run the following Procedure ***/
SELECT ENABLED_FLAG
FROM HR_API_HOOK_CALLS
WHERE API_HOOK_ID = 2758 ;
/* ENABLED_FLAG should be YES */
/***Step 4 Run the hrahkone.sql ***/ $PER_TOP/admin/sql/hrahkpar.sql.
declare
l_api_module_id number;
begin
l_api_module_id := &API_MODULE_ID;
--
-- Create all hook package body source code for one API module
--
hr_api_user_hooks_utility.create_hooks_one_module(l_api_module_id);
--
-- Build the report text
--
END;
/
/***Step 5 Run the following query ***/
SELECT STATUS
FROM HR_API_HOOK_CALLS
WHERE API_HOOK_ID = 2879 ;
Example requirement to Validate fields in Absence Screen in SSHR:
Requirment:
1. If leave type is 'Annual Leave' and reason is null, then error msg should be shown.
2. If leave type is 'Maternity leave' and days less than 45 then error msg should be shown.
Step 1 – Identifying the correct User Hook API
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 like '%_PERSON_ABSENCE%'
AND ahm.api_module_type = 'BP'
AND ahk.api_hook_type = 'AP'
AND ahk.api_module_id = ahm.api_module_id
It will show all Person Absence relevant APIs.We need to select the correct API that matched with our requirement. For Example for above mentioned requirement, we shall select CREATE_PERSON_ABSENCE_A API. We shall note its API_HOOK_ID (3840) and API_MODULE_ID (1731) as API_HOOK_ID will be used at the time of registration of user hook mentioned in Step 3 ahead and API_MODULE_ID will be needed in running the processor in Step 4.
Step 2. Create PL/SQL procedure to execute your logic.
CREATE OR REPLACE PACKAGE APPS.XX_LSG_USERHOOK_PKG IS
PROCEDURE XXALB_CREATE_ABS_VAL_P
(P_EFFECTIVE_DATE IN DATE
,P_PERSON_ID IN NUMBER
,P_BUSINESS_GROUP_ID IN NUMBER
,P_ABSENCE_ATTENDANCE_TYPE_ID IN NUMBER
,P_ABS_ATTENDANCE_REASON_ID IN NUMBER
,P_COMMENTS IN LONG
,P_DATE_NOTIFICATION IN DATE
,P_DATE_PROJECTED_START IN DATE
,P_TIME_PROJECTED_START IN VARCHAR2
,P_DATE_PROJECTED_END IN DATE
,P_TIME_PROJECTED_END IN VARCHAR2
,P_DATE_START IN DATE
,P_TIME_START IN VARCHAR2
,P_DATE_END IN DATE
,P_TIME_END IN VARCHAR2
,P_ABSENCE_DAYS IN NUMBER
,P_ABSENCE_HOURS IN NUMBER
,P_AUTHORISING_PERSON_ID IN NUMBER
,P_REPLACEMENT_PERSON_ID IN NUMBER
,P_ATTRIBUTE_CATEGORY IN VARCHAR2
,P_ATTRIBUTE1 IN VARCHAR2
,P_ATTRIBUTE2 IN VARCHAR2
,P_ATTRIBUTE3 IN VARCHAR2
,P_ATTRIBUTE4 IN VARCHAR2
,P_ATTRIBUTE5 IN VARCHAR2
,P_ATTRIBUTE6 IN VARCHAR2
,P_ATTRIBUTE7 IN VARCHAR2
,P_ATTRIBUTE8 IN VARCHAR2
,P_ATTRIBUTE9 IN VARCHAR2
,P_ATTRIBUTE10 IN VARCHAR2
,P_ATTRIBUTE11 IN VARCHAR2
,P_ATTRIBUTE12 IN VARCHAR2
,P_ATTRIBUTE13 IN VARCHAR2
,P_ATTRIBUTE14 IN VARCHAR2
,P_ATTRIBUTE15 IN VARCHAR2
,P_ATTRIBUTE16 IN VARCHAR2
,P_ATTRIBUTE17 IN VARCHAR2
,P_ATTRIBUTE18 IN VARCHAR2
,P_ATTRIBUTE19 IN VARCHAR2
,P_ATTRIBUTE20 IN VARCHAR2
,P_PERIOD_OF_INCAPACITY_ID IN NUMBER
,P_SSP1_ISSUED IN VARCHAR2
,P_MATERNITY_ID IN NUMBER
,P_SICKNESS_START_DATE IN DATE
,P_SICKNESS_END_DATE IN DATE
,P_PREGNANCY_RELATED_ILLNESS IN VARCHAR2
,P_REASON_FOR_NOTIFICATION_DELA IN VARCHAR2
,P_ACCEPT_LATE_NOTIFICATION_FLA IN VARCHAR2
,P_LINKED_ABSENCE_ID IN NUMBER
,P_BATCH_ID IN NUMBER
,P_CREATE_ELEMENT_ENTRY IN BOOLEAN
,P_ABS_INFORMATION_CATEGORY IN VARCHAR2,
P_ABS_INFORMATION1 IN VARCHAR2,
--P_ABS_INFORMATION1 IN VARCHAR2,
P_ABS_INFORMATION2 IN VARCHAR2,
P_ABS_INFORMATION3 IN VARCHAR2,
P_ABS_INFORMATION4 IN VARCHAR2,
P_ABS_INFORMATION5 IN VARCHAR2,
P_ABS_INFORMATION6 IN VARCHAR2,
P_ABS_INFORMATION7 IN VARCHAR2,
P_ABS_INFORMATION8 IN VARCHAR2,
P_ABS_INFORMATION9 IN VARCHAR2,
P_ABS_INFORMATION10 IN VARCHAR2,
P_ABS_INFORMATION11 IN VARCHAR2,
P_ABS_INFORMATION12 IN VARCHAR2,
P_ABS_INFORMATION13 IN VARCHAR2,
P_ABS_INFORMATION14 IN VARCHAR2,
P_ABS_INFORMATION15 IN VARCHAR2,
P_ABS_INFORMATION16 IN VARCHAR2,
P_ABS_INFORMATION17 IN VARCHAR2,
P_ABS_INFORMATION18 IN VARCHAR2,
P_ABS_INFORMATION19 IN VARCHAR2,
P_ABS_INFORMATION20 IN VARCHAR2,
P_ABS_INFORMATION21 IN VARCHAR2,
P_ABS_INFORMATION22 IN VARCHAR2,
P_ABS_INFORMATION23 IN VARCHAR2,
P_ABS_INFORMATION24 IN VARCHAR2,
P_ABS_INFORMATION25 IN VARCHAR2,
P_ABS_INFORMATION26 IN VARCHAR2,
P_ABS_INFORMATION27 IN VARCHAR2,
P_ABS_INFORMATION28 IN VARCHAR2,
P_ABS_INFORMATION29 IN VARCHAR2,
P_ABS_INFORMATION30 IN VARCHAR2,
P_ABSENCE_CASE_ID IN NUMBER
);
END ;
/
--XX_LSG_USERHOOK_PKG.XXALB_CREATE_ABS_VAL_P
CREATE OR REPLACE PACKAGE BODY XX_LSG_USERHOOK_PKG IS
PROCEDURE XXALB_CREATE_ABS_VAL_P
(P_EFFECTIVE_DATE IN DATE
,P_PERSON_ID IN NUMBER
,P_BUSINESS_GROUP_ID IN NUMBER
,P_ABSENCE_ATTENDANCE_TYPE_ID IN NUMBER
,P_ABS_ATTENDANCE_REASON_ID IN NUMBER
,P_COMMENTS IN LONG
,P_DATE_NOTIFICATION IN DATE
,P_DATE_PROJECTED_START IN DATE
,P_TIME_PROJECTED_START IN VARCHAR2
,P_DATE_PROJECTED_END IN DATE
,P_TIME_PROJECTED_END IN VARCHAR2
,P_DATE_START IN DATE
,P_TIME_START IN VARCHAR2
,P_DATE_END IN DATE
,P_TIME_END IN VARCHAR2
,P_ABSENCE_DAYS IN NUMBER
,P_ABSENCE_HOURS IN NUMBER
,P_AUTHORISING_PERSON_ID IN NUMBER
,P_REPLACEMENT_PERSON_ID IN NUMBER
,P_ATTRIBUTE_CATEGORY IN VARCHAR2
,P_ATTRIBUTE1 IN VARCHAR2
,P_ATTRIBUTE2 IN VARCHAR2
,P_ATTRIBUTE3 IN VARCHAR2
,P_ATTRIBUTE4 IN VARCHAR2
,P_ATTRIBUTE5 IN VARCHAR2
,P_ATTRIBUTE6 IN VARCHAR2
,P_ATTRIBUTE7 IN VARCHAR2
,P_ATTRIBUTE8 IN VARCHAR2
,P_ATTRIBUTE9 IN VARCHAR2
,P_ATTRIBUTE10 IN VARCHAR2
,P_ATTRIBUTE11 IN VARCHAR2
,P_ATTRIBUTE12 IN VARCHAR2
,P_ATTRIBUTE13 IN VARCHAR2
,P_ATTRIBUTE14 IN VARCHAR2
,P_ATTRIBUTE15 IN VARCHAR2
,P_ATTRIBUTE16 IN VARCHAR2
,P_ATTRIBUTE17 IN VARCHAR2
,P_ATTRIBUTE18 IN VARCHAR2
,P_ATTRIBUTE19 IN VARCHAR2
,P_ATTRIBUTE20 IN VARCHAR2
,P_PERIOD_OF_INCAPACITY_ID IN NUMBER
,P_SSP1_ISSUED IN VARCHAR2
,P_MATERNITY_ID IN NUMBER
,P_SICKNESS_START_DATE IN DATE
,P_SICKNESS_END_DATE IN DATE
,P_PREGNANCY_RELATED_ILLNESS IN VARCHAR2
,P_REASON_FOR_NOTIFICATION_DELA IN VARCHAR2
,P_ACCEPT_LATE_NOTIFICATION_FLA IN VARCHAR2
,P_LINKED_ABSENCE_ID IN NUMBER
,P_BATCH_ID IN NUMBER
,P_CREATE_ELEMENT_ENTRY IN BOOLEAN
,P_ABS_INFORMATION_CATEGORY IN VARCHAR2,
P_ABS_INFORMATION1 IN VARCHAR2,
--P_ABS_INFORMATION1 IN VARCHAR2,
P_ABS_INFORMATION2 IN VARCHAR2,
P_ABS_INFORMATION3 IN VARCHAR2,
P_ABS_INFORMATION4 IN VARCHAR2,
P_ABS_INFORMATION5 IN VARCHAR2,
P_ABS_INFORMATION6 IN VARCHAR2,
P_ABS_INFORMATION7 IN VARCHAR2,
P_ABS_INFORMATION8 IN VARCHAR2,
P_ABS_INFORMATION9 IN VARCHAR2,
P_ABS_INFORMATION10 IN VARCHAR2,
P_ABS_INFORMATION11 IN VARCHAR2,
P_ABS_INFORMATION12 IN VARCHAR2,
P_ABS_INFORMATION13 IN VARCHAR2,
P_ABS_INFORMATION14 IN VARCHAR2,
P_ABS_INFORMATION15 IN VARCHAR2,
P_ABS_INFORMATION16 IN VARCHAR2,
P_ABS_INFORMATION17 IN VARCHAR2,
P_ABS_INFORMATION18 IN VARCHAR2,
P_ABS_INFORMATION19 IN VARCHAR2,
P_ABS_INFORMATION20 IN VARCHAR2,
P_ABS_INFORMATION21 IN VARCHAR2,
P_ABS_INFORMATION22 IN VARCHAR2,
P_ABS_INFORMATION23 IN VARCHAR2,
P_ABS_INFORMATION24 IN VARCHAR2,
P_ABS_INFORMATION25 IN VARCHAR2,
P_ABS_INFORMATION26 IN VARCHAR2,
P_ABS_INFORMATION27 IN VARCHAR2,
P_ABS_INFORMATION28 IN VARCHAR2,
P_ABS_INFORMATION29 IN VARCHAR2,
P_ABS_INFORMATION30 IN VARCHAR2,
P_ABSENCE_CASE_ID IN NUMBER
)
IS
L_ABSENCE_TYPE VARCHAR2 (500) := NULL;
L_ASSIGNMENT_ID NUMBER;
L_ABSENCE_START_DATE DATE := NVL (P_DATE_START, P_DATE_PROJECTED_START);
L_ABSENCE_END_DATE DATE := NVL (P_DATE_END, P_DATE_PROJECTED_END);
L_ABSENCE_FUTURE_ST_DATE DATE;
L_ABSENCE_FUTURE_END_DATE DATE;
BEGIN
SELECT NAME
INTO L_ABSENCE_TYPE
FROM PER_ABSENCE_ATTENDANCE_TYPES
WHERE ABSENCE_ATTENDANCE_TYPE_ID = P_ABSENCE_ATTENDANCE_TYPE_ID
AND BUSINESS_GROUP_ID = P_BUSINESS_GROUP_ID;
--Annual Leave
IF P_ABSENCE_ATTENDANCE_TYPE_ID = 62 AND P_ABS_ATTENDANCE_REASON_ID IS NULL THEN
HR_UTILITY.SET_MESSAGE (800, 'LSG_ANN_LEAVE_REAS');
HR_UTILITY.RAISE_ERROR;
ELSIF P_ABSENCE_ATTENDANCE_TYPE_ID = 63 AND P_ABS_ATTENDANCE_REASON_ID IS NULL THEN
HR_UTILITY.SET_MESSAGE (800, 'LSG_MAT_LEV_REAS');
HR_UTILITY.RAISE_ERROR;
--Maternity Leave
ELSIF (P_ABSENCE_ATTENDANCE_TYPE_ID = 63 and P_ABS_ATTENDANCE_REASON_ID = 61) and (P_ABSENCE_DAYS <> 60) THEN
HR_UTILITY.SET_MESSAGE (800, 'LSG_MAT_60DAYS');
HR_UTILITY.RAISE_ERROR;
ELSIF (P_ABSENCE_ATTENDANCE_TYPE_ID = 63 and P_ABS_ATTENDANCE_REASON_ID = 62) and (P_ABSENCE_DAYS <> 45) THEN
HR_UTILITY.SET_MESSAGE (800, 'LSG_MAT_45DAYS');
HR_UTILITY.RAISE_ERROR;
END IF;
END;
END ;
3. Register your procedure with one or more specific user hooks.
We shall use the API_HOOK_ID identified in Step 1 in the parameter p_api_hook_id. Through this API, custom logic will be registered against user hook.
DECLARE
L_API_HOOK_ID NUMBER := 3840 ;
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 =>L_API_HOOK_ID,
P_API_HOOK_CALL_TYPE => 'PP',
P_SEQUENCE => L_SEQUENCE,
P_ENABLED_FLAG => 'Y',
P_CALL_PACKAGE => 'XX_LSG_USERHOOK_PKG', -- CUSTOM PACKAGE
P_CALL_PROCEDURE => 'XXALB_CREATE_ABS_VAL_P', -- 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 ;
After this step, you shall be able to see the reference of your custom package/ procedure in table HR_API_HOOK_CALLS. You can check it by using following query
SELECT *
FROM HR_API_HOOK_CALLS
WHERE api_hook_id = 3840;
4. Run the pre-processor program
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.
or
declare
l_api_module_id number := 1731; --Value 1731 is derived from Step 1 above using following query
begin
hr_api_user_hooks_utility.create_hooks_one_module (l_api_module_id);
dbms_output.put_line('Success');
exception when others then
dbms_output.put_line('Exception : '||SQLERRM);
end;
good
ReplyDelete