Thursday, May 18, 2017

Script to End Data all Application Users in Oracle EBS

take backup of fnd _user table
conn apps/***
create table fnd_user_bkp as select * from fnd_user;

the below script will end date all application users except some system accounts and few application users who needs to be active in the cloned environment or test instance

DECLARE
   CURSOR usercur  
   IS
    SELECT fu.user_name
      FROM apps.fnd_user fu
     WHERE NVL(fu.end_date, SYSDATE + 1) >= SYSDATE
       AND fu.user_name NOT IN -- EXCLUDE SYSTEM ACCOUNTS ** THIS IS NOT A COMPREHENSIVE LIST **
        (
            'AME_INVALID_APPROVER',
            'APPSMGR',
            'ASGADM',
            'ASGUEST',
            'AUTOINSTALL',
            'GUEST',
            'IBE_ADMIN',
            'IBE_GUEST',
            'IBEGUEST',
            'IEXADMIN',
            'IRC_EMP_GUEST',
            'IRC_EXT_GUEST',
            'MOBADM',
            'MOBDEV',
            'MOBILEADM',
            'OP_CUST_CARE_ADMIN',
            'OP_SYSADMIN',
            'PORTAL_PROD',
            'PRODAPOID',
            'PRODOIDAP',
            'SYSADMIN',
            'WIZARD'
        ) -- you can use this list to exclude staff in central support team if required:
       AND fu.user_name NOT IN('TEST1',
                               'TEST2',
                               'TEST3',
                               'TEST4',
      'TEST5',
      'TEST6',
      'TEST7');

BEGIN
   FOR myuser IN usercur
   LOOP
      fnd_user_pkg.updateuser(
         x_user_name                 => myuser.user_name,
         x_owner                     => 'CUST',
         x_end_date                  => TRUNC(SYSDATE-1)
      );
   END LOOP;
END;
/
COMMIT;
EXIT