Introduction:
A responsibility is a level of authority in Oracle Applications that lets users access only those Oracle Applications functions and data appropriate to their roles in an organization.
Oracle
for more information click here
Goal:
Add a List of Responsibilities to a user using “fnd_user_pkg.AddResp” API
Forms Or Pages:
Example:
Add responsibility to user in oracle apps from backend Using API
For how to create user using API click here
API IN/OUT Parameters :
- IN username VARCHAR2.
- IN resp_app VARCHAR2.
- IN resp_key VARCHAR2.
- IN security_group VARCHAR2.
- IN description VARCHAR2.
- IN start_date DATE.
- IN end_date DATE.
API Parameters clarifications:
- @param username User Name from table “fnd_user” .
- @param resp_app Application Short Name from table “fnd_application”.
- @param resp_key Responsibility Key from table “fnd_responsibility”.
- @param security_group Security Group Key from table “fnd_security_groups”.
API Calling example:
— Create Custom table to hold our responsibilities informations
CREATE TABLE xx_responsibility_info
(
seq NUMBER (5)
,user_name VARCHAR2 (200)
,app_short_name VARCHAR2 (200)
,responsibility_key VARCHAR2 (200)
,security_group_key VARCHAR2 (200)
,description VARCHAR2 (200)
,start_date DATE
,end_date DATE
,status VARCHAR2 (10)
,error_msg VARCHAR2 (600)
);
INSERT INTO xx_responsibility_info (seq
,user_name
,app_short_name
,responsibility_key
,security_group_key
,start_date)
VALUES (1
,'AHMED_SHMES'
,'FND'
,'APPLICATION_DEVELOPER'
,'STANDARD'
,sysdate);
INSERT INTO xx_responsibility_info (seq
,user_name
,app_short_name
,responsibility_key
,security_group_key
,start_date)
VALUES (2
,'AHMED_SHMES'
,'SYSADMIN'
,'SYSTEM_ADMINISTRATOR'
,'STANDARD'
,sysdate);
— API Script
DECLARE
v_error_msg VARCHAR2 (500) := NULL;
CURSOR xx_resp_info
IS
SELECT * FROM xx_responsibility_info;
BEGIN
FOR resp_data IN xx_resp_info
LOOP
BEGIN
fnd_user_pkg.addresp (username => resp_data.user_name
,resp_app => resp_data.app_short_name
,resp_key => resp_data.responsibility_key
,security_group => resp_data.security_group_key
,description => resp_data.description
,start_date => resp_data.start_date
,end_date => resp_data.end_date);
dbms_output.put_line ('***************************');
dbms_output.put_line ('Output information ....');
dbms_output.put_line ('Responsibility has been added to user Successfully....');
dbms_output.put_line ('user_name: ' || resp_data.user_name);
dbms_output.put_line ('responsibility_key: ' || resp_data.responsibility_key);
dbms_output.put_line ('update custom table with Done status');
COMMIT;
--To ensure that the data inserted successfully
BEGIN
UPDATE xx_responsibility_info
SET status = 'Done', error_msg = NULL
WHERE seq = resp_data.seq;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
dbms_output.put_line ('***************************');
-- To handle unexpected errors and unsuccessful data insertion
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line ('***************************');
dbms_output.put_line ('Error informations ....');
v_error_msg := sqlerrm;
dbms_output.put_line ('The Error Returned from API is : ' || v_error_msg);
dbms_output.put_line ('Update custom table with error for current row ');
UPDATE xx_responsibility_info
SET error_msg = v_error_msg, status = 'Error'
WHERE seq = resp_data.seq;
COMMIT;
--
dbms_output.put_line ('***************************');
END;
END LOOP;
END;
Final Result:
[convertkit form=1415728]Hope this helpful.
If you found it simple and easy to understand, we would love to provide you and your friends a simple solution for your problems.
Thanks.