Followers

Monday, February 15, 2016

User Creation from backend For Oracle Apps

DECLARE
   l_user_id   NUMBER;
   l_resp_id   NUMBER;
   l_app_id    NUMBER;
BEGIN
   FND_USER_PKG.CreateUser
                          (x_user_name                       => 'TEST',---Use your user name
                            x_owner                              => NULL,
                            x_unencrypted_password   => 'welcome123',--default passsword
                            x_email_address                 => null);

   SELECT user_id
     INTO l_user_id
     FROM fnd_user
    WHERE user_name = 'TEST'; --Change as per the user name

   SELECT responsibility_id, application_id
     INTO l_resp_id, l_app_id
     FROM fnd_responsibility
    WHERE responsibility_key = 'SYSTEM ADMIN - USER CREATION';

   FND_USER_RESP_GROUPS_API.insert_assignment
                      (user_id                                      => l_user_id,
                       responsibility_id                       => l_resp_id,
                       responsibility_application_id   => l_app_id,
                       security_group_id                     => NULL,
                       start_date                                  => SYSDATE,
                       end_date                                   => NULL,
                       description                                => NULL);

   COMMIT;
EXCEPTION
   WHEN OTHERS THEN
      raise_application_error ( -20001, 'An error was encountered - ' || SQLCODE || ' -ERROR- ' || SQLERRM);

END;

No comments:

Post a Comment