Tuesday, 24 September 2019

PO Delete

**************** PO Delete ***********************

DECLARE
   lb_result        BOOLEAN;
   l_po_number      VARCHAR2 (100) :='5952001681';-- &po_number;
 
   CURSOR po_csr IS
      SELECT poh.po_header_id
           , poh.type_lookup_code
           , poh.segment1 po_number
        FROM po_headers_all poh 
       WHERE NVL (poh.closed_code, 'OPEN') = 'OPEN'
         AND poh.segment1 = l_po_number;
BEGIN
   FOR po_rec IN po_csr LOOP
       lb_result :=  po_headers_sv1.delete_po
                             ( x_po_header_id     => po_rec.po_header_id
                             , x_type_lookup_code => po_rec.type_lookup_code
                             , p_skip_validation  => 'Y' );

       IF lb_result = TRUE THEN
        --  DBMS_OUTPUT.PUT_LINE('PO Number Deleted '|| l_po_number);
        DBMS_OUTPUT.put_line ( 'Successfully Deleted the PO');
          COMMIT;
       ELSE
         -- DBMS_OUTPUT.PUT_LINE ('API Failed to delete the Purchase Order ' || l_po_number);
         DBMS_OUTPUT.put_line ( 'Failed to Delete the PO');
          ROLLBACK;
       END IF;
   END LOOP;
EXCEPTION
   WHEN OTHERS THEN
      DBMS_OUTPUT.PUT_LINE ('Unexpected Exception while deleting PO~' || l_po_number || '~' || SQLERRM);
      ROLLBACK;
END;

No comments:

Post a Comment

AIM Document List

AIM Document List Business Process Architecture (BP) BP.010 Define Business and Process Strategy BP.020 Catalog and Analyze P...