Wednesday, July 23, 2014

API to Update Start or End Date of User Responsibility

DECLARE
   CURSOR c1
   IS
      SELECT fu.user_name,
             per.employee_number,
             fa.application_short_name,
             frt.responsibility_name,
             fr.responsibility_key,
             fsg.security_group_key,
             frt.description
        FROM fnd_user_resp_groups_all ful,
             fnd_user fu,
             fnd_responsibility_tl frt,
             fnd_responsibility fr,
             fnd_security_groups fsg,
             fnd_application fa,
             per_people_x per
       WHERE     fu.user_id = ful.user_id
             AND frt.responsibility_id = ful.responsibility_id
             AND fr.responsibility_id = frt.responsibility_id
             AND fsg.security_group_id = ful.security_group_id
             AND fa.application_id = ful.responsibility_application_id
             AND frt.language = 'US'
             AND fu.employee_id = per.person_id
             AND per.business_group_id = 2734
             AND frt.responsibility_name = 'XXX HR Employee Self Service';


   l_effective_date   DATE := TO_DATE ('09-AUG-2014');
BEGIN
   FOR i IN c1
   LOOP
      BEGIN
         fnd_user_pkg.AddResp (username         => i.user_name,
                               resp_app         => i.application_short_name,
                               resp_key         => i.responsibility_key,
                               security_group   => i.security_group_key,
                               description      => i.description,
                               start_date       => l_effective_date,
                               end_date         => NULL);

         COMMIT;
         DBMS_OUTPUT.
          put_line (
            i.responsibility_name || ' has been Enabled for ' || i.user_name);
      EXCEPTION
         WHEN OTHERS
         THEN
            DBMS_OUTPUT.
             put_line (
                  'Inner Exception: '
               || ' - '
               || i.responsibility_key
               || ' - '
               || SQLERRM);
      END;
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Main Exception: ' || SQLERRM);

END;

No comments:

Post a Comment