720: return_status := so_purge_order_cancel_lines( v_line_id,
721: p_request_id );
722: END IF;
723:
724: /* bug 683844 -- clean mtl_so_rma_interface table */
725: IF return_status > -1 THEN
726: return_status := so_purge_mtl_so_rma_interface( v_line_id,
727: p_request_id );
728: END IF;
722: END IF;
723:
724: /* bug 683844 -- clean mtl_so_rma_interface table */
725: IF return_status > -1 THEN
726: return_status := so_purge_mtl_so_rma_interface( v_line_id,
727: p_request_id );
728: END IF;
729:
730: IF return_status > -1 THEN
867:
868: END so_purge_order_cancel_lines;
869:
870: /*************************************************************
871: * The mtl_so_rma_interface needs to be cleaned when the *
872: * corresponding returns lines are purged for the following *
873: * reasons: *
874: * 1. the reference to line_id becomes dangling pointer *
875: * 2. Inventory can't delete the item with error message: *
873: * reasons: *
874: * 1. the reference to line_id becomes dangling pointer *
875: * 2. Inventory can't delete the item with error message: *
876: * RMA's exist for this item in the interface table *
877: * (MTL_SO_RMA_INTERFACE) *
878: *************************************************************/
879:
880: FUNCTION so_purge_mtl_so_rma_interface
881: ( p_line_id NUMBER,
876: * RMA's exist for this item in the interface table *
877: * (MTL_SO_RMA_INTERFACE) *
878: *************************************************************/
879:
880: FUNCTION so_purge_mtl_so_rma_interface
881: ( p_line_id NUMBER,
882: p_request_id NUMBER ) RETURN NUMBER IS
883:
884: return_status NUMBER := 0;
883:
884: return_status NUMBER := 0;
885: v_rma_interface_id NUMBER := 0;
886:
887: CURSOR purge_mtl_so_rma_interface IS
888: SELECT rma_interface_id -- Lock rows to be purged
889: FROM mtl_so_rma_interface
890: WHERE rma_line_id = p_line_id;
891: BEGIN
885: v_rma_interface_id NUMBER := 0;
886:
887: CURSOR purge_mtl_so_rma_interface IS
888: SELECT rma_interface_id -- Lock rows to be purged
889: FROM mtl_so_rma_interface
890: WHERE rma_line_id = p_line_id;
891: BEGIN
892: OPEN purge_mtl_so_rma_interface;
893: LOOP
888: SELECT rma_interface_id -- Lock rows to be purged
889: FROM mtl_so_rma_interface
890: WHERE rma_line_id = p_line_id;
891: BEGIN
892: OPEN purge_mtl_so_rma_interface;
893: LOOP
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
890: WHERE rma_line_id = p_line_id;
891: BEGIN
892: OPEN purge_mtl_so_rma_interface;
893: LOOP
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,
891: BEGIN
892: OPEN purge_mtl_so_rma_interface;
893: LOOP
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 );
892: OPEN purge_mtl_so_rma_interface;
893: LOOP
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
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;
903: ELSE
904: EXIT;
905: END IF;
904: EXIT;
905: END IF;
906:
907: END LOOP;
908: CLOSE purge_mtl_so_rma_interface;
909: RETURN SQLCODE;
910:
911: EXCEPTION -- Exception handler to record error
912: WHEN OTHERS THEN
914: ROLLBACK;
915: so_record_errors( return_status,
916: p_request_id,
917: p_line_id,
918: 'OEPUR: MTL_SO_RMA_INTERFACE',
919: NULL );
920: CLOSE purge_mtl_so_rma_interface;
921: RETURN return_status;
922:
916: p_request_id,
917: p_line_id,
918: 'OEPUR: MTL_SO_RMA_INTERFACE',
919: NULL );
920: CLOSE purge_mtl_so_rma_interface;
921: RETURN return_status;
922:
923: END so_purge_mtl_so_rma_interface;
924:
919: NULL );
920: CLOSE purge_mtl_so_rma_interface;
921: RETURN return_status;
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 *
930: * 2. when a return line is purged, corresponding interfaced *
931: * line needs to be purged because: *
932: * Inventory can't delete the item with error message: *
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,