Friday, September 12, 2014

Useful script to assign all Super User responsibilities to your user

Dear Reader

Sometimes we may have come across on some instances where we do not have access to all the super user responsibilities when our user is created especially in DEV/TEST instances

So with below script you can simply assign all of them to your user at one shot and then you have all the responsibilities you may need

DECLARE
   lv_count NUMBER;
BEGIN
   FOR i IN
   (
      SELECT   fu.user_name,
               fa.application_short_name,
               fr.responsibility_key,
               fr.responsibility_id,
               fu.user_id
      FROM     fnd_user fu,
               fnd_responsibility_vl fr,
               fnd_application_vl fa
      WHERE    fu.user_name = 'ASHANKAR'
      AND
      (
               fr.responsibility_name like '%Super%User%'
               or
               fr.responsibility_name in ('System Administrator', 'Application Developer', 'XML Publisher Administrator', 'Desktop Integration')
      )
      AND      fr.application_id = fa.application_id
   ) LOOP
      SELECT   COUNT(1)
      INTO     lv_count
      FROM     fnd_user_resp_groups
      WHERE    user_id = i.user_id
      AND      responsibility_id = i.responsibility_id;

      IF lv_count <> 0 THEN
         UPDATE   fnd_user_resp_groups
         SET      end_date = NULL
         WHERE    user_id = i.user_id
         AND      responsibility_id = i.responsibility_id;
      ELSE
         fnd_user_pkg.AddResp
         (
            username          => i.user_name,
            resp_app          => i.application_short_name,
            resp_key          => i.responsibility_key,
            security_group    => 'STANDARD',
            description       => NULL,
            start_date        => '01-JAN-2013',
            end_date          => NULL
         );
      END IF;
   END LOOP;
END;

Cheers
A

1 comment: