DECLARE
p_user_name VARCHAR2 (50) := <Username>;
p_resp_name VARCHAR2 (50) := <Responsibility Name>;
v_user_id NUMBER (10) := 0;
v_responsibility_id NUMBER (10) := 0;
v_application_id NUMBER (10) := 0;
BEGIN
BEGIN
SELECT user_id
INTO v_user_id
FROM fnd_user
WHERE UPPER (user_name) = UPPER (p_user_name);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
DBMS_OUTPUT.put_line ('User not found');
RAISE;
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error finding User.');
RAISE;
END;
BEGIN
SELECT application_id, responsibility_id
INTO v_application_id, v_responsibility_id
FROM fnd_responsibility_vl
WHERE UPPER (responsibility_name) = UPPER (p_resp_name);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
DBMS_OUTPUT.put_line ('Responsibility not found.');
RAISE;
WHEN TOO_MANY_ROWS
THEN
DBMS_OUTPUT.put_line
('More than one responsibility found with this name.');
RAISE;
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error finding responsibility.');
RAISE;
END;
BEGIN
DBMS_OUTPUT.put_line ('Initializing The Application');
fnd_global.apps_initialize (user_id => v_user_id,
resp_id => v_responsibility_id,
resp_appl_id => v_application_id
);
DBMS_OUTPUT.put_line
('Calling FND_USER_RESP_GROUPS_API API To Insert/Update Resp');
fnd_user_resp_groups_api.update_assignment
(user_id => v_user_id,
responsibility_id => v_responsibility_id,
responsibility_application_id => v_application_id,
security_group_id => 0,
start_date => SYSDATE,
end_date => NULL,
description => NULL
);
DBMS_OUTPUT.put_line
('The End Date has been removed from responsibility');
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error calling the API');
RAISE;
END;
END;
/
SET SERVEROUTPUT ON
set veri off
set echo off
set head off
set feed off
declare
v_user_name varchar2(30):=upper('SYSADMIN');
v_resp varchar2(30):='Direct US Service Contracts Manager';
v_resp_key varchar2(30);
v_app_short_name varchar2(50);
begin
select
r.responsibility_key ,
a.application_short_name
into v_resp_key,v_app_short_name
from fnd_responsibility_vl r,
fnd_application_vl a
where
r.application_id =a.application_id
and upper(r.responsibility_name) = upper(v_resp);
fnd_user_pkg.AddResp (
username => v_user_name,
resp_app => v_app_short_name,
resp_key => v_resp_key,
security_group => 'STANDARD',
description => null,
start_date => sysdate,
end_date => null
);
commit;
DBMS_OUTPUT.put_line ('Responsibility:'||v_resp||' '||'is added to the User:'||v_user_name);
EXCEPTION
when others then
DBMS_OUTPUT.put_line ('Unable to add the responsibility due to'||SQLCODE||' '||SUBSTR(SQLERRM, 1, 100));
rollback;
end;
/
p_user_name VARCHAR2 (50) := <Username>;
p_resp_name VARCHAR2 (50) := <Responsibility Name>;
v_user_id NUMBER (10) := 0;
v_responsibility_id NUMBER (10) := 0;
v_application_id NUMBER (10) := 0;
BEGIN
BEGIN
SELECT user_id
INTO v_user_id
FROM fnd_user
WHERE UPPER (user_name) = UPPER (p_user_name);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
DBMS_OUTPUT.put_line ('User not found');
RAISE;
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error finding User.');
RAISE;
END;
BEGIN
SELECT application_id, responsibility_id
INTO v_application_id, v_responsibility_id
FROM fnd_responsibility_vl
WHERE UPPER (responsibility_name) = UPPER (p_resp_name);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
DBMS_OUTPUT.put_line ('Responsibility not found.');
RAISE;
WHEN TOO_MANY_ROWS
THEN
DBMS_OUTPUT.put_line
('More than one responsibility found with this name.');
RAISE;
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error finding responsibility.');
RAISE;
END;
BEGIN
DBMS_OUTPUT.put_line ('Initializing The Application');
fnd_global.apps_initialize (user_id => v_user_id,
resp_id => v_responsibility_id,
resp_appl_id => v_application_id
);
DBMS_OUTPUT.put_line
('Calling FND_USER_RESP_GROUPS_API API To Insert/Update Resp');
fnd_user_resp_groups_api.update_assignment
(user_id => v_user_id,
responsibility_id => v_responsibility_id,
responsibility_application_id => v_application_id,
security_group_id => 0,
start_date => SYSDATE,
end_date => NULL,
description => NULL
);
DBMS_OUTPUT.put_line
('The End Date has been removed from responsibility');
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error calling the API');
RAISE;
END;
END;
/
SET SERVEROUTPUT ON
set veri off
set echo off
set head off
set feed off
declare
v_user_name varchar2(30):=upper('SYSADMIN');
v_resp varchar2(30):='Direct US Service Contracts Manager';
v_resp_key varchar2(30);
v_app_short_name varchar2(50);
begin
select
r.responsibility_key ,
a.application_short_name
into v_resp_key,v_app_short_name
from fnd_responsibility_vl r,
fnd_application_vl a
where
r.application_id =a.application_id
and upper(r.responsibility_name) = upper(v_resp);
fnd_user_pkg.AddResp (
username => v_user_name,
resp_app => v_app_short_name,
resp_key => v_resp_key,
security_group => 'STANDARD',
description => null,
start_date => sysdate,
end_date => null
);
commit;
DBMS_OUTPUT.put_line ('Responsibility:'||v_resp||' '||'is added to the User:'||v_user_name);
EXCEPTION
when others then
DBMS_OUTPUT.put_line ('Unable to add the responsibility due to'||SQLCODE||' '||SUBSTR(SQLERRM, 1, 100));
rollback;
end;
/