Tuesday, May 12, 2015

API to End Date User

DECLARE
   CURSOR c1
   IS
      SELECT fu.user_name, per.employee_number, per.attribute29
        FROM per_all_people_f per,
             per_all_assignments_f paaf,
             fnd_user fu,
             hr_all_organization_units haou,
             pay_cost_allocation_keyflex pcak
       WHERE     per.person_id = paaf.person_id
             AND paaf.assignment_type = 'E'
             AND paaf.primary_flag = 'Y'
             AND paaf.assignment_status_type_id = 1
             AND TRUNC (SYSDATE) BETWEEN per.effective_start_date
                                     AND per.effective_end_date
             AND TRUNC (SYSDATE) BETWEEN paaf.effective_start_date
                                     AND paaf.effective_end_date
             AND fu.employee_id = per.person_id
             AND paaf.organization_id = haou.organization_id
             AND haou.cost_allocation_keyflex_id =
                    pcak.cost_allocation_keyflex_id
             AND pcak.segment3 <> 509;

BEGIN
   FOR i IN c1
   LOOP
      BEGIN
         fnd_user_pkg.
          updateuser (x_user_name   => i.user_name,
                      x_owner       => NULL,
                      x_end_date    => SYSDATE - 1);

         COMMIT;

         DBMS_OUTPUT.put_line ('User has been End dated --> ' || i.user_name);
      EXCEPTION
         WHEN OTHERS
         THEN
            DBMS_OUTPUT.
             put_line (
               'Inner Exception --> ' || i.user_name || '--> ' || SQLERRM);
      END;
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Main Exception --> ' || SQLERRM);

END;

No comments:

Post a Comment