1) API to create FND User
BEGIN
fnd_user_pkg.CreateUser ( x_user_name =>'Operations',
x_owner => NULL,
x_unencrypted_password =>'welcome1',
x_start_date =>TO_DATE('01-JAN-2000'),
x_end_date => NULL, x_last_logon_date => NULL,
x_description => 'Operations User',
x_password_date => NULL,
x_password_accesses_left => NULL,
x_employee_id => NULL,
x_email_address => NULL,
x_fax => NULL,
x_customer_id => NULL,
x_supplier_id => NULL);
COMMIT;
END;
API to add responsibilities to a user
BEGIN
fnd_user_pkg.addresp(username =>'XXTEST',
resp_app =>'SYSADMIN',
resp_key =>'SYSTEM_ADMINISTRATOR',
security_group =>'STANDARD',
description => NULL,
start_date =>TO_DATE('01-JAN-2000'),
end_date =>NULL );
COMMIT;
END;
--(or)
declare
l_user_name varchar2(100) := UPPER('XXTEST');
l_resp_key varchar2(100) := '&resp_key';
l_app_short_name varchar2(100);
begin
select application_short_name
into l_app_short_name
from fnd_application fa, fnd_responsibility fr
where fa.application_id = fr.application_id
and trunc(sysdate) between start_date and nvl(end_date, '31-dec-4712')
and fr.responsibility_key = l_resp_key;
fnd_user_resp_groups_api.load_row
(x_user_name => l_user_name,
x_resp_key => l_resp_key,
x_app_short_name => l_app_short_name ,
x_security_group => 'STANDARD',
x_owner => 'CUST',
x_start_date => TO_CHAR ( SYSDATE, 'YYYY/MM/DD'),
x_end_date => NULL,
x_description => NULL
);
commit;
end;
/
--API to remove responsibilities from a user
BEGIN
fnd_user_pkg.delresp(username =>'XXTEST',
resp_app =>'SYSADMIN',
resp_key =>'SYSTEM_ADMINISTRATOR',
security_group =>'STANDARD' );
COMMIT;
END;
--To get Assigned responsibilities to a user
SELECT frt.responsibility_name r_name, fr.application_id, fr.responsibility_id
FROM fnd_user fu, fnd_responsibility fr, fnd_responsibility_tl frt, fnd_user_resp_groups furg
WHERE fu.user_id = furg.user_id
AND fr.responsibility_id = frt.responsibility_id
and frt.language = userenv('LANG')
AND furg.responsibility_id = fr.responsibility_id
AND fu.user_name = &1
AND SYSDATE BETWEEN fr.START_DATE AND nvl(fr.end_date, SYSDATE)
AND SYSDATE BETWEEN furg.START_DATE AND nvl(furg.end_date, SYSDATE);
BEGIN
fnd_user_pkg.CreateUser ( x_user_name =>'Operations',
x_owner => NULL,
x_unencrypted_password =>'welcome1',
x_start_date =>TO_DATE('01-JAN-2000'),
x_end_date => NULL, x_last_logon_date => NULL,
x_description => 'Operations User',
x_password_date => NULL,
x_password_accesses_left => NULL,
x_employee_id => NULL,
x_email_address => NULL,
x_fax => NULL,
x_customer_id => NULL,
x_supplier_id => NULL);
COMMIT;
END;
API to add responsibilities to a user
BEGIN
fnd_user_pkg.addresp(username =>'XXTEST',
resp_app =>'SYSADMIN',
resp_key =>'SYSTEM_ADMINISTRATOR',
security_group =>'STANDARD',
description => NULL,
start_date =>TO_DATE('01-JAN-2000'),
end_date =>NULL );
COMMIT;
END;
--(or)
declare
l_user_name varchar2(100) := UPPER('XXTEST');
l_resp_key varchar2(100) := '&resp_key';
l_app_short_name varchar2(100);
begin
select application_short_name
into l_app_short_name
from fnd_application fa, fnd_responsibility fr
where fa.application_id = fr.application_id
and trunc(sysdate) between start_date and nvl(end_date, '31-dec-4712')
and fr.responsibility_key = l_resp_key;
fnd_user_resp_groups_api.load_row
(x_user_name => l_user_name,
x_resp_key => l_resp_key,
x_app_short_name => l_app_short_name ,
x_security_group => 'STANDARD',
x_owner => 'CUST',
x_start_date => TO_CHAR ( SYSDATE, 'YYYY/MM/DD'),
x_end_date => NULL,
x_description => NULL
);
commit;
end;
/
--API to remove responsibilities from a user
BEGIN
fnd_user_pkg.delresp(username =>'XXTEST',
resp_app =>'SYSADMIN',
resp_key =>'SYSTEM_ADMINISTRATOR',
security_group =>'STANDARD' );
COMMIT;
END;
--To get Assigned responsibilities to a user
SELECT frt.responsibility_name r_name, fr.application_id, fr.responsibility_id
FROM fnd_user fu, fnd_responsibility fr, fnd_responsibility_tl frt, fnd_user_resp_groups furg
WHERE fu.user_id = furg.user_id
AND fr.responsibility_id = frt.responsibility_id
and frt.language = userenv('LANG')
AND furg.responsibility_id = fr.responsibility_id
AND fu.user_name = &1
AND SYSDATE BETWEEN fr.START_DATE AND nvl(fr.end_date, SYSDATE)
AND SYSDATE BETWEEN furg.START_DATE AND nvl(furg.end_date, SYSDATE);
No comments:
Post a Comment