Thursday, August 15, 2019

Delete Responsibility from User, Disable user, Enable user and Change UserName using API


Overview:

    This document helps you for below points:
           1) Delete Responsibility from USER using API
           2) Disable User using API
           3) Enable User using API
           4) Change User name using API    

1) Delete Responsibility from USER using API

     Detach a responsibility which is already assigned to User
     If any of the username or application short name or responsibility key or
     security group is not valid, exception raised with error message.
  
    Input (Mandatory)
       username:        User Name
       resp_app:         Application Short Name
       resp_key:          Responsibility Key
       security_group: Security Group Key

          For example: Below example assign responsibility to FND USER
 
        DECLARE
             lc_user_name        VARCHAR2(90) := 'XX007MN';
             lc_resp_app           VARCHAR2(40) := 'SYSADMIN';
             lc_resp_key            VARCHAR2(40) := 'SYSTEM_ADMINISTRATOR';
             lc_security_group   VARCHAR2(40) := 'STANDARD';
        BEGIN
          FND_USER_PKG.DelResp(username         => lc_user_name,
                                                 resp_app           => lc_resp_app,
                                                 resp_key           => lc_resp_key,
                                                 security_group  => lc_security_group
                              );
            COMMIT;
                dbms_output.put_line('Successfully Responsibility: ' || lc_resp_key || ' delete from User: '||lc_user_name);
        EXCEPTION
               WHEN OTHERS THEN
                    dbms_output.put_line('Unable to delete responsibility from User due to' || SQLCODE || ' ' || SUBSTR(SQLERRM, 1, 100));
            ROLLBACK;
        END;
        /

Note: Replace variable values with your values.
-----------------------------------------------------------------

2) Disable User using API

   This document helps you to Disable particular User.
   --
   For Example:
  
      DECLARE
        lc_user_name VARCHAR2(50) := 'XX007MN';
      BEGIN
          FND_USER_PKG.DisableUser(username => lc_user_name);
          COMMIT;
           dbms_output.put_line('Successfully Disable User: '||lc_user_name);
      EXCEPTION
        WHEN OTHERS THEN
        dbms_output.put_line('Unable to disable User due to' || SQLCODE || ' ' || SUBSTR(SQLERRM, 1, 100));
      END;
      /

Note: Replace variable values with your values.
-----------------------------------------------------------------

3) Enable User using API

   This document helps you to Enable particular User.
  
   For Example:
      DECLARE
        lc_user_name  VARCHAR2(50) := 'XX007MN';
        ld_start_date DATE         := to_Date('01-JAN-2018');
        ld_end_date   DATE         := to_Date('20-DEC-2045');
       
      BEGIN
        FND_USER_PKG.EnableUser(username   => lc_user_name,
                                                   start_date   => ld_start_date,
                                                    end_date    => ld_end_date);
        COMMIT;
           dbms_output.put_line('Successfully Enable User: '||lc_user_name);
      EXCEPTION
        WHEN OTHERS THEN
        dbms_output.put_line('Unable to Enable User due to' || SQLCODE || ' ' || SUBSTR(SQLERRM, 1, 100));
      END;
      /
     
Note: Replace variable values with your values.
-----------------------------------------------------------------

4) Change User name using API:

   Using below API you will changer User Name.

       Input (Mandantory)
         x_old_user_name:     Old User Name
         x_new_user_name:     New User Name
                      
    For Example:

        DECLARE
             lc_old_user_name   VARCHAR2(50)    := 'XX007MN';
             lc_new_user_name   VARCHAR2(50)   := 'XX10LMN';
        BEGIN
              FND_USER_PKG.change_user_name(x_old_user_name => lc_old_user_name,
                                         x_new_user_name => lc_new_user_name
                                        );
          COMMIT;
           dbms_output.put_line('Successfully changed UserName from: '||lc_old_user_name|| ' to: '||lc_new_user_name);
        EXCEPTION
          WHEN OTHERS THEN
            dbms_output.put_line('Unable to change User name due to' || SQLCODE || ' ' || SUBSTR(SQLERRM, 1, 100));
        END;
        /

Note: Replace variable values with your values.

After completed script check in Base table:

SELECT * FROM fnd_user WHERE user_name = 'XX10LMN';

No comments:

Post a Comment

Steps to get ZPL code output using Zebra viewer - Online

Introduction ZPL is a print language used by many label printers. A print language is a set of commands that can be used to draw elements li...