Thursday, October 16, 2014

API to Cancel Workflow

DECLARE
   CURSOR c1
   IS
      SELECT item_type, item_key, process_name
        FROM hr_api_transactions hat
       WHERE     status = 'Y'
             AND process_name = 'HR_GENERIC_APPROVAL_PRC'
             AND item_key = '254954';
BEGIN
   FOR i IN c1
   LOOP
      BEGIN
         wf_engine.
          abortprocess (itemtype   => i.item_type,
                        itemkey    => i.item_key,
                        process    => i.process_name);


         COMMIT;
         DBMS_OUTPUT.put_line ('Item Key has been Aborted/Cancelled: ' || i.item_key);
      EXCEPTION
         WHEN OTHERS
         THEN
            DBMS_OUTPUT.
             put_line ('Inner Exception: ' || SQLERRM || ' - ' || i.item_key);
      END;
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Main Exception: ' || SQLERRM);

END;

1 comment: