Before you write your user hook, you must review your user population and create a standard user name format, responsibility, and security profile for your enterprise. When you have defined a standard and created any security profiles or security groups you need, you can begin to write your user hook.
You can create a template responsibility for the batch process. If you create a template responsibility or use the predefined Manager Self-Service responsibility, you can code a new responsibility created by the user hook to inherit the template responsibilities attributes. You can then overwrite the template responsibility's attributes by setting values in the communication area of the API, hr_user_acct_utility.
You can find sample user hook code in the following package:
$PER_TOP/patch/115/sql/hrhksmpl.pkb
Create a security profile in Oracle HRMS and, using your naming standard, associate the security profile and responsibility to a new user in your user hook code.
Implement security groups to manage security profiles with the Enable Security Groups profile option. By implementing security groups, you can associate more than one security profile to a single responsibility.
Note: Before you write user hooks, run the Security List Maintenance concurrent process. This ensures that the security profiles work.
Note: If you plan to use security groups in a responsibility defined for use in Oracle Self-Service Web Applications, or plan to create a new responsibility for use in Oracle Self-Service Web Applications, set the Enable Security Groups profile option at the application level: Oracle Self Service Web Applications.
Set up a guest user account in Oracle Applications by setting the GUEST USER PASSWORD profile option. This must be in the format <username/password>. You can obtain and verify the guest user account with your Database Administrator.
Use the Define System Profile Option Value in System Administrator responsibility to set a security profile at Site or Application level. This is necessary because security profile option values can be set at Responsibility or User level with the batch process.
Note: The sample user hook is called hrhksmpl.pkb and each code block is documented. You can also find a copy of the sample in the following directory $PER_TOP/patch/115/sql.
See: API User Hooks
See: Sample Code
The batch process inserts records into the following FND tables:
FND_USER
FND_USER_RESP_GROUPS
to enable a new user to use a designated responsibility
FND_RESPONSIBILITY
if new responsibilities are created in the custom user hook module for the new user
FND_RESPONSIBILITY_TL
stores the translated value of responsibility name
FND_RESP_FUNCTIONS
if the new responsibility has function exclusion rules
FND_PROFILE_OPTION_VALUES
to set profile option values for any newly created responsibility for the user.
PER_SEC_PROFILE_ASSIGNMENTS
if security groups are enabled.
The batch process automates the functionality of the Define User Form and inserts records into the following FND tables:
FND_USER
FND_RESP_GROUPS
Note: Security attributes for a user cannot be created in the batch process
The batch process automates the functionality of the Define Responsibility Form and inserts records into the following FND tables:
FND_USER_RESP_GROUPS
FND_RESPONSIBILITY_TL
Note: Security attributes for a responsibility cannot be created in the batch process
The batch process automates the functionality of the Profile Option Value Form and inserts records into the following FND table:
FND_PROFILE_OPTION_VALUES
To create batches of users you need to write PL/SQL programs in the user hooks of the following API:
hr_user_acct_api
This API contains two procedures:
hr_user_acct_api.create_user_acct
used to create a new user
hr_user_acct_api.update_user_acct
used to inactivate user accounts, for example on termination of an employee or worker
Write a PL/SQL program to communicate to the API the user name, password, responsibility, and profile to use when it creates a new user account for the employee or worker in the process.
There are two user hook points in the create user procedure:
hr_user_acct_bk1.create_user_acct_b
before-process hook point
hr_user_acct_bk1.create_user_acct_a
after-process hook point
Use the before-process hook for the PL/SQL program. The program enters these values into the global variables or record structures in hr_user_acct_utility.
Note: You can supply passwords for the new user account or leave the API to generate a random string. The string will be in an 8 character alphanumeric format.
Write a PL/SQL program for the after-process hook if you leave the API to generate a password. The program must save the password of the new user account to a file that can be accessed by a system administrator. This is necessary because the password created by the API is encrypted when it is saved to the FND_USER table in the database. You must capture the password before it is encrypted so that you can notify employees of their initial password.
Note: If you supply a password, you may not need to write a user hook for this after-process hook point.
The update user API procedure is used to inactivate employees. The API end dates the employees record in the FND_USER and FND_USER_RESP_GROUPS tables and is not meant for general purpose update.
There are two user hook points in the update user procedure:
hr_user_acct_bk2.update_user_acct_b
before process hook point
hr_user_acct_bk2.update_user_acct_a
after process hook point
The before process user hook point is used for your extra validation. The API will not pick up any values from your user hook.
The after process user hook point executes any extra logic after the main API validation and processing logic has successfully completed and the update process is finished.
Compile the custom package you have created after you have written your user hooks.
Register and link your custom package procedures to the appropriate API user hooks when you have compiled the package.
See: API User Hooks
A sample script to register and link your custom package and procedures is provided below.
Sample code
DECLARE
ln_api_hook_call_id NUMBER;
ln_object_version_number NUMBER;
ln_api_hook_id NUMBER;
BEGIN
-- get api_hook_id for the seeded before process user hook package procedure
SELECT ahk.api_hook_id
INTO ln_api_hook_id
FROM hr_api_hooks ahk
,hr_api_modules ahm
WHERE ahm.module_name = 'CREATE_USER_ACCT'
AND ahm.api_module_type = 'BP'
AND ahk.hook_package = 'HR_USER_ACCT_BK1'
AND ahk.hook_procedure = 'CREATE_USER_ACCT_B'
AND ahk.api_hook_type = 'BP'
AND ahk.api_module_id = ahm.api_module_id;
-- insert a row into HR_API_HOOK_CALLS for before process user hook custom package procedure
hr_api_hook_call_api.create_api_hook_call(
p_effective_date => to_date('02/02/2000', 'DD/MM/YYYY'),
p_api_hook_id => ln_api_hook_id,
p_api_hook_call_type => 'PP',
p_sequence => 1,
p_enabled_flag => 'Y',
p_call_package => 'MY_USER_ACCT', -- your custom package name
p_call_procedure => 'CREATE_USER_ACCT_B', -- your custom package procedure name
p_api_hook_call_id => ln_api_hook_call_id,
p_object_version_number => ln_object_version_number
);
-- get api_hook_id for the seeded after process user hook package procedure
SELECT ahk.api_hook_id
INTO ln_api_hook_id
FROM hr_api_hooks ahk
,hr_api_modules ahm
WHERE ahm.module_name = 'CREATE_USER_ACCT'
AND ahm.api_module_type = 'BP'
AND ahk.hook_package = 'HR_USER_ACCT_BK1'
AND ahk.hook_procedure = 'CREATE_USER_ACCT_A'
AND ahk.api_hook_type = 'AP'
AND ahk.api_module_id = ahm.api_module_id;
-- insert a row in HR_API_HOOK_CALLS for after process user hook custom package procedure
hr_api_hook_call_api.create_api_hook_call(
p_effective_date => to_date('02/02/2000', 'DD/MM/YYYY'),
p_api_hook_id => ln_api_hook_id,
p_api_hook_call_type => 'PP',
p_sequence => 1,
p_enabled_flag => 'Y',
p_call_package => 'MY_USER_ACCT',
p_call_procedure => 'CREATE_USER_ACCT_A',
p_api_hook_call_id => ln_api_hook_call_id,
p_object_version_number => ln_object_version_number
);
EXCEPTION
when others then
dbms_output.put_line('Error in seeding user hook procedures: ' || sqlerrm);
END;
/
commit;
exit;
Execute User Hook Pre-Processor
When you have registered and linked your custom package procedure to the API you should execute the user hook pre-processor program. Run the hrahkone.sql found in $PER_TOP/patch/115/sql directory to do this. However, you'll need to know the internal api_module_id for the HR_USER_ACCT_API before running the script. To find the internal api_module_id you should run the script below:
SELECT api_module_id ,api_module_type ,module_name FROM hr_api_modules WHERE module_package = 'HR_USER_ACCT_API';
You should see results similar to those below:
API_MODULE_ID API_MODULE_TYPE MODULE_NAME
--------------------------------------------------------
383 BP CREATE_USER_ACCT
384 BP UPDATE_USER_ACCT
Note: Your api_module_id will be different from the one above.
Use your own API module id when executing hrahkone.sql. If you have a customer package for UPDATE_USER_ACCT hook point, you will need to run hrahkone.sql twice. Once for the api_module_id for CREATE_USER_ACCT hook call and second for the UPDATE_USER_ACCT hook call.
Enter any new message text for the messages that you issue in your custom package when you have run the pre-processor program. Use an Application Developer responsibility in Oracle Applications to create your message text.
Ensure you have set the application level correctly if you use security groups to manage security profiles. For example, in SSHR you must set the application level to Oracle Self Service Web Applications. Set the security profile option to the application level if you need to associate the responsibility with another HRMS application.
This updates the following tables: per_sec_ profile_ assignments, and fnd_user_resp_groups
Make sure that the Enable Security Groups profile option is Yes.
Set the Data Pump error parameters. These parameter control aspects of the Data Pump Engine process.
See: Oracle HRMS Data Pump.
Note: You must set the MAX_ERRORS_ALLOWED parameter to see all the errors logged during the run. This parameter controls how many errors are issued before the engine stops processing. The default value for the parameter is 20 or the chunk size. If you do not set this parameter value, the engine will stop processing after 20 errors.
Test the custom packages by running the following programs:. To test, run the User Account Employee Extract concurrent program to create batches of extracted employees. Run the Data Pump Engine concurrent program to process your batch, and run the Data Pump Batch Exceptions
User Account Employee Extract concurrent program - to create batches of extracted employees
Data Pump Engine concurrent program - to process your batch
Data Pump Batch Exceptions concurrent program - to report any errors.
If necessary, you can rerun the batch after fixing any errors.
Note: You can use the Pipemon utility to help you debug your code.