894: FETCH purge_mtl_so_rma_interface into v_rma_interface_id;
895: EXIT WHEN purge_mtl_so_rma_interface%NOTFOUND -- end of fetch
896: OR purge_mtl_so_rma_interface%NOTFOUND IS NULL; -- empty cursor
897:
898: return_status := so_purge_mtl_so_rma_receipts( v_rma_interface_id,
899: p_request_id );
900: IF return_status > -1 THEN
901: DELETE FROM mtl_so_rma_interface
902: WHERE rma_interface_id = v_rma_interface_id;
922:
923: END so_purge_mtl_so_rma_interface;
924:
925: /*************************************************************
926: * The mtl_so_rma_receipts needs to be cleaned when the *
927: * corresponding rma_interface line is purged for the *
928: * following reasons: *
929: * 1. the reference to rma_interface_id becomes dangling *
930: * 2. when a return line is purged, corresponding interfaced *
933: * RMA's exist for this item in the interface table *
934: * (MTL_SO_RMA_INTERFACE) *
935: *************************************************************/
936:
937: FUNCTION so_purge_mtl_so_rma_receipts
938: ( p_rma_interface_id NUMBER,
939: p_request_id NUMBER ) RETURN NUMBER IS
940:
941: return_status NUMBER := 0;
940:
941: return_status NUMBER := 0;
942: v_rma_receipt_id NUMBER := 0;
943:
944: CURSOR purge_mtl_so_rma_receipts IS
945: SELECT rma_receipt_id -- Lock rows to be purged
946: FROM mtl_so_rma_receipts
947: WHERE rma_interface_id = p_rma_interface_id;
948: BEGIN
942: v_rma_receipt_id NUMBER := 0;
943:
944: CURSOR purge_mtl_so_rma_receipts IS
945: SELECT rma_receipt_id -- Lock rows to be purged
946: FROM mtl_so_rma_receipts
947: WHERE rma_interface_id = p_rma_interface_id;
948: BEGIN
949: OPEN purge_mtl_so_rma_receipts;
950: LOOP
945: SELECT rma_receipt_id -- Lock rows to be purged
946: FROM mtl_so_rma_receipts
947: WHERE rma_interface_id = p_rma_interface_id;
948: BEGIN
949: OPEN purge_mtl_so_rma_receipts;
950: LOOP
951: FETCH purge_mtl_so_rma_receipts into v_rma_receipt_id;
952: EXIT WHEN purge_mtl_so_rma_receipts%NOTFOUND -- end of fetch
953: OR purge_mtl_so_rma_receipts%NOTFOUND IS NULL; -- empty cursor
947: WHERE rma_interface_id = p_rma_interface_id;
948: BEGIN
949: OPEN purge_mtl_so_rma_receipts;
950: LOOP
951: FETCH purge_mtl_so_rma_receipts into v_rma_receipt_id;
952: EXIT WHEN purge_mtl_so_rma_receipts%NOTFOUND -- end of fetch
953: OR purge_mtl_so_rma_receipts%NOTFOUND IS NULL; -- empty cursor
954:
955: DELETE FROM mtl_so_rma_receipts
948: BEGIN
949: OPEN purge_mtl_so_rma_receipts;
950: LOOP
951: FETCH purge_mtl_so_rma_receipts into v_rma_receipt_id;
952: EXIT WHEN purge_mtl_so_rma_receipts%NOTFOUND -- end of fetch
953: OR purge_mtl_so_rma_receipts%NOTFOUND IS NULL; -- empty cursor
954:
955: DELETE FROM mtl_so_rma_receipts
956: WHERE rma_receipt_id = v_rma_receipt_id;
949: OPEN purge_mtl_so_rma_receipts;
950: LOOP
951: FETCH purge_mtl_so_rma_receipts into v_rma_receipt_id;
952: EXIT WHEN purge_mtl_so_rma_receipts%NOTFOUND -- end of fetch
953: OR purge_mtl_so_rma_receipts%NOTFOUND IS NULL; -- empty cursor
954:
955: DELETE FROM mtl_so_rma_receipts
956: WHERE rma_receipt_id = v_rma_receipt_id;
957:
951: FETCH purge_mtl_so_rma_receipts into v_rma_receipt_id;
952: EXIT WHEN purge_mtl_so_rma_receipts%NOTFOUND -- end of fetch
953: OR purge_mtl_so_rma_receipts%NOTFOUND IS NULL; -- empty cursor
954:
955: DELETE FROM mtl_so_rma_receipts
956: WHERE rma_receipt_id = v_rma_receipt_id;
957:
958: END LOOP;
959: CLOSE purge_mtl_so_rma_receipts;
955: DELETE FROM mtl_so_rma_receipts
956: WHERE rma_receipt_id = v_rma_receipt_id;
957:
958: END LOOP;
959: CLOSE purge_mtl_so_rma_receipts;
960: RETURN SQLCODE;
961:
962: EXCEPTION -- Exception handler to record error
963: WHEN OTHERS THEN
965: ROLLBACK;
966: so_record_errors( return_status,
967: p_request_id,
968: p_rma_interface_id,
969: 'OEPUR: MTL_SO_RMA_RECEIPTS',
970: NULL );
971: CLOSE purge_mtl_so_rma_receipts;
972: RETURN return_status;
973:
967: p_request_id,
968: p_rma_interface_id,
969: 'OEPUR: MTL_SO_RMA_RECEIPTS',
970: NULL );
971: CLOSE purge_mtl_so_rma_receipts;
972: RETURN return_status;
973:
974: END so_purge_mtl_so_rma_receipts;
975:
970: NULL );
971: CLOSE purge_mtl_so_rma_receipts;
972: RETURN return_status;
973:
974: END so_purge_mtl_so_rma_receipts;
975:
976: FUNCTION so_purge_order_cancellations
977: ( p_header_id NUMBER,
978: p_request_id NUMBER ) RETURN NUMBER IS