1: PACKAGE BODY INV_RCV_RESERVATION_UTIL AS
2: /* $Header: INVRUTLB.pls 120.20 2007/12/19 22:15:13 musinha ship $*/
3:
4: g_source_type_oe NUMBER := inv_reservation_global.g_source_type_oe;
5: g_source_type_po NUMBER := inv_reservation_global.g_source_type_po;
6: g_source_type_asn NUMBER := inv_reservation_global.g_source_type_asn;
7: g_source_type_internal_req NUMBER := inv_reservation_global.g_source_type_internal_req;
8: g_source_type_internal_ord NUMBER := inv_reservation_global.g_source_type_internal_ord;
1: PACKAGE BODY INV_RCV_RESERVATION_UTIL AS
2: /* $Header: INVRUTLB.pls 120.20 2007/12/19 22:15:13 musinha ship $*/
3:
4: g_source_type_oe NUMBER := inv_reservation_global.g_source_type_oe;
5: g_source_type_po NUMBER := inv_reservation_global.g_source_type_po;
6: g_source_type_asn NUMBER := inv_reservation_global.g_source_type_asn;
7: g_source_type_internal_req NUMBER := inv_reservation_global.g_source_type_internal_req;
8: g_source_type_internal_ord NUMBER := inv_reservation_global.g_source_type_internal_ord;
9: g_source_type_in_transit NUMBER := inv_reservation_global.g_source_type_intransit;
2: /* $Header: INVRUTLB.pls 120.20 2007/12/19 22:15:13 musinha ship $*/
3:
4: g_source_type_oe NUMBER := inv_reservation_global.g_source_type_oe;
5: g_source_type_po NUMBER := inv_reservation_global.g_source_type_po;
6: g_source_type_asn NUMBER := inv_reservation_global.g_source_type_asn;
7: g_source_type_internal_req NUMBER := inv_reservation_global.g_source_type_internal_req;
8: g_source_type_internal_ord NUMBER := inv_reservation_global.g_source_type_internal_ord;
9: g_source_type_in_transit NUMBER := inv_reservation_global.g_source_type_intransit;
10: g_source_type_inv NUMBER := inv_reservation_global.g_source_type_inv;
3:
4: g_source_type_oe NUMBER := inv_reservation_global.g_source_type_oe;
5: g_source_type_po NUMBER := inv_reservation_global.g_source_type_po;
6: g_source_type_asn NUMBER := inv_reservation_global.g_source_type_asn;
7: g_source_type_internal_req NUMBER := inv_reservation_global.g_source_type_internal_req;
8: g_source_type_internal_ord NUMBER := inv_reservation_global.g_source_type_internal_ord;
9: g_source_type_in_transit NUMBER := inv_reservation_global.g_source_type_intransit;
10: g_source_type_inv NUMBER := inv_reservation_global.g_source_type_inv;
11: g_source_type_rcv NUMBER := inv_reservation_global.g_source_type_rcv;
4: g_source_type_oe NUMBER := inv_reservation_global.g_source_type_oe;
5: g_source_type_po NUMBER := inv_reservation_global.g_source_type_po;
6: g_source_type_asn NUMBER := inv_reservation_global.g_source_type_asn;
7: g_source_type_internal_req NUMBER := inv_reservation_global.g_source_type_internal_req;
8: g_source_type_internal_ord NUMBER := inv_reservation_global.g_source_type_internal_ord;
9: g_source_type_in_transit NUMBER := inv_reservation_global.g_source_type_intransit;
10: g_source_type_inv NUMBER := inv_reservation_global.g_source_type_inv;
11: g_source_type_rcv NUMBER := inv_reservation_global.g_source_type_rcv;
12: g_source_type_wip NUMBER := inv_reservation_global.g_source_type_wip;
5: g_source_type_po NUMBER := inv_reservation_global.g_source_type_po;
6: g_source_type_asn NUMBER := inv_reservation_global.g_source_type_asn;
7: g_source_type_internal_req NUMBER := inv_reservation_global.g_source_type_internal_req;
8: g_source_type_internal_ord NUMBER := inv_reservation_global.g_source_type_internal_ord;
9: g_source_type_in_transit NUMBER := inv_reservation_global.g_source_type_intransit;
10: g_source_type_inv NUMBER := inv_reservation_global.g_source_type_inv;
11: g_source_type_rcv NUMBER := inv_reservation_global.g_source_type_rcv;
12: g_source_type_wip NUMBER := inv_reservation_global.g_source_type_wip;
13:
6: g_source_type_asn NUMBER := inv_reservation_global.g_source_type_asn;
7: g_source_type_internal_req NUMBER := inv_reservation_global.g_source_type_internal_req;
8: g_source_type_internal_ord NUMBER := inv_reservation_global.g_source_type_internal_ord;
9: g_source_type_in_transit NUMBER := inv_reservation_global.g_source_type_intransit;
10: g_source_type_inv NUMBER := inv_reservation_global.g_source_type_inv;
11: g_source_type_rcv NUMBER := inv_reservation_global.g_source_type_rcv;
12: g_source_type_wip NUMBER := inv_reservation_global.g_source_type_wip;
13:
14: g_query_demand_ship_date_desc NUMBER := inv_reservation_global.g_query_demand_ship_date_desc;
7: g_source_type_internal_req NUMBER := inv_reservation_global.g_source_type_internal_req;
8: g_source_type_internal_ord NUMBER := inv_reservation_global.g_source_type_internal_ord;
9: g_source_type_in_transit NUMBER := inv_reservation_global.g_source_type_intransit;
10: g_source_type_inv NUMBER := inv_reservation_global.g_source_type_inv;
11: g_source_type_rcv NUMBER := inv_reservation_global.g_source_type_rcv;
12: g_source_type_wip NUMBER := inv_reservation_global.g_source_type_wip;
13:
14: g_query_demand_ship_date_desc NUMBER := inv_reservation_global.g_query_demand_ship_date_desc;
15: g_query_demand_ship_date_asc NUMBER := inv_reservation_global.g_query_demand_ship_date_asc ;
8: g_source_type_internal_ord NUMBER := inv_reservation_global.g_source_type_internal_ord;
9: g_source_type_in_transit NUMBER := inv_reservation_global.g_source_type_intransit;
10: g_source_type_inv NUMBER := inv_reservation_global.g_source_type_inv;
11: g_source_type_rcv NUMBER := inv_reservation_global.g_source_type_rcv;
12: g_source_type_wip NUMBER := inv_reservation_global.g_source_type_wip;
13:
14: g_query_demand_ship_date_desc NUMBER := inv_reservation_global.g_query_demand_ship_date_desc;
15: g_query_demand_ship_date_asc NUMBER := inv_reservation_global.g_query_demand_ship_date_asc ;
16:
10: g_source_type_inv NUMBER := inv_reservation_global.g_source_type_inv;
11: g_source_type_rcv NUMBER := inv_reservation_global.g_source_type_rcv;
12: g_source_type_wip NUMBER := inv_reservation_global.g_source_type_wip;
13:
14: g_query_demand_ship_date_desc NUMBER := inv_reservation_global.g_query_demand_ship_date_desc;
15: g_query_demand_ship_date_asc NUMBER := inv_reservation_global.g_query_demand_ship_date_asc ;
16:
17: PROCEDURE print_debug(p_err_msg VARCHAR2
18: ,p_module IN VARCHAR2
11: g_source_type_rcv NUMBER := inv_reservation_global.g_source_type_rcv;
12: g_source_type_wip NUMBER := inv_reservation_global.g_source_type_wip;
13:
14: g_query_demand_ship_date_desc NUMBER := inv_reservation_global.g_query_demand_ship_date_desc;
15: g_query_demand_ship_date_asc NUMBER := inv_reservation_global.g_query_demand_ship_date_asc ;
16:
17: PROCEDURE print_debug(p_err_msg VARCHAR2
18: ,p_module IN VARCHAR2
19: ,p_level NUMBER DEFAULT 4)
291: x_return_status := fnd_api.g_ret_sts_error;
292: END split_wdd;
293:
294: PROCEDURE query_reservation
295: (p_query_input IN inv_reservation_global.mtl_reservation_rec_type
296: ,p_sort_by_req_date IN NUMBER
297: ,x_rsv_results OUT nocopy inv_reservation_global.mtl_reservation_tbl_type
298: ,x_return_status OUT nocopy VARCHAR2
299: ) IS
293:
294: PROCEDURE query_reservation
295: (p_query_input IN inv_reservation_global.mtl_reservation_rec_type
296: ,p_sort_by_req_date IN NUMBER
297: ,x_rsv_results OUT nocopy inv_reservation_global.mtl_reservation_tbl_type
298: ,x_return_status OUT nocopy VARCHAR2
299: ) IS
300:
301: l_rsv_results_count NUMBER;
376: x_return_status := fnd_api.g_ret_sts_error;
377: END query_reservation;
378:
379: PROCEDURE transfer_reservation
380: (p_original_rsv_rec IN inv_reservation_global.mtl_reservation_rec_type
381: ,p_to_rsv_rec IN inv_reservation_global.mtl_reservation_rec_type
382: ,x_new_rsv_id OUT nocopy NUMBER
383: ,x_return_status OUT nocopy VARCHAR2)
384: IS
377: END query_reservation;
378:
379: PROCEDURE transfer_reservation
380: (p_original_rsv_rec IN inv_reservation_global.mtl_reservation_rec_type
381: ,p_to_rsv_rec IN inv_reservation_global.mtl_reservation_rec_type
382: ,x_new_rsv_id OUT nocopy NUMBER
383: ,x_return_status OUT nocopy VARCHAR2)
384: IS
385: l_dummy_serial inv_reservation_global.serial_number_tbl_type;
381: ,p_to_rsv_rec IN inv_reservation_global.mtl_reservation_rec_type
382: ,x_new_rsv_id OUT nocopy NUMBER
383: ,x_return_status OUT nocopy VARCHAR2)
384: IS
385: l_dummy_serial inv_reservation_global.serial_number_tbl_type;
386: l_return_status VARCHAR2(1);
387: l_msg_count NUMBER;
388: l_msg_data VARCHAR2(2000);
389:
454: x_return_status := fnd_api.g_ret_sts_error;
455: END transfer_reservation;
456:
457: PROCEDURE relieve_reservation
458: (p_rsv_rec IN inv_reservation_global.mtl_reservation_rec_type
459: ,p_prim_qty_to_relieve IN NUMBER
460: ,x_return_status OUT nocopy VARCHAR2
461: )
462: IS
459: ,p_prim_qty_to_relieve IN NUMBER
460: ,x_return_status OUT nocopy VARCHAR2
461: )
462: IS
463: l_dummy_serial inv_reservation_global.serial_number_tbl_type;
464: l_tmp_prim_relieved_qty NUMBER;
465: l_tmp_prim_remain_qty NUMBER;
466:
467: l_return_status VARCHAR2(1);
543: x_return_status := fnd_api.g_ret_sts_error;
544: END relieve_reservation;
545:
546: PROCEDURE delete_reservation
547: (p_rsv_rec IN inv_reservation_global.mtl_reservation_rec_type
548: ,x_return_status OUT nocopy VARCHAR2)
549: IS
550: l_dummy_serial inv_reservation_global.serial_number_tbl_type;
551: l_return_status VARCHAR2(1);
546: PROCEDURE delete_reservation
547: (p_rsv_rec IN inv_reservation_global.mtl_reservation_rec_type
548: ,x_return_status OUT nocopy VARCHAR2)
549: IS
550: l_dummy_serial inv_reservation_global.serial_number_tbl_type;
551: l_return_status VARCHAR2(1);
552: l_msg_count NUMBER;
553: l_msg_data VARCHAR2(2000);
554:
616: x_return_status := fnd_api.g_ret_sts_error;
617: END delete_reservation;
618:
619: PROCEDURE reduce_reservation
620: (p_mtl_rsv_rec IN inv_reservation_global.mtl_maintain_rsv_rec_type
621: ,x_return_status OUT nocopy VARCHAR2
622: )
623: IS
624: l_qty_modified NUMBER;
762: ,x_msg_count OUT NOCOPY NUMBER
763: ,x_msg_data OUT NOCOPY VARCHAR2
764: ,p_cas_mol_rec_tb IN inv_rcv_integration_pvt.cas_mol_rec_tb_tp
765: ) IS
766: l_rsv_query_rec inv_reservation_global.mtl_reservation_rec_type;
767: l_rsv_results_tbl inv_reservation_global.mtl_reservation_tbl_type;
768: l_rsv_update_rec inv_reservation_global.mtl_reservation_rec_type;
769: l_rsv_results_count NUMBER;
770: l_remaining_prim_qty NUMBER;
763: ,x_msg_data OUT NOCOPY VARCHAR2
764: ,p_cas_mol_rec_tb IN inv_rcv_integration_pvt.cas_mol_rec_tb_tp
765: ) IS
766: l_rsv_query_rec inv_reservation_global.mtl_reservation_rec_type;
767: l_rsv_results_tbl inv_reservation_global.mtl_reservation_tbl_type;
768: l_rsv_update_rec inv_reservation_global.mtl_reservation_rec_type;
769: l_rsv_results_count NUMBER;
770: l_remaining_prim_qty NUMBER;
771: l_reservation_id NUMBER;
764: ,p_cas_mol_rec_tb IN inv_rcv_integration_pvt.cas_mol_rec_tb_tp
765: ) IS
766: l_rsv_query_rec inv_reservation_global.mtl_reservation_rec_type;
767: l_rsv_results_tbl inv_reservation_global.mtl_reservation_tbl_type;
768: l_rsv_update_rec inv_reservation_global.mtl_reservation_rec_type;
769: l_rsv_results_count NUMBER;
770: l_remaining_prim_qty NUMBER;
771: l_reservation_id NUMBER;
772: l_new_wdd_id NUMBER;
998: ,x_msg_count OUT NOCOPY NUMBER
999: ,x_msg_data OUT NOCOPY VARCHAR2
1000: ,p_cas_mol_rec_tb IN inv_rcv_integration_pvt.cas_mol_rec_tb_tp
1001: ) IS
1002: l_rsv_query_rec inv_reservation_global.mtl_reservation_rec_type;
1003: l_rsv_results_tbl inv_reservation_global.mtl_reservation_tbl_type;
1004: l_rsv_update_rec inv_reservation_global.mtl_reservation_rec_type;
1005: l_reservation_id NUMBER;
1006: l_dummy NUMBER;
999: ,x_msg_data OUT NOCOPY VARCHAR2
1000: ,p_cas_mol_rec_tb IN inv_rcv_integration_pvt.cas_mol_rec_tb_tp
1001: ) IS
1002: l_rsv_query_rec inv_reservation_global.mtl_reservation_rec_type;
1003: l_rsv_results_tbl inv_reservation_global.mtl_reservation_tbl_type;
1004: l_rsv_update_rec inv_reservation_global.mtl_reservation_rec_type;
1005: l_reservation_id NUMBER;
1006: l_dummy NUMBER;
1007:
1000: ,p_cas_mol_rec_tb IN inv_rcv_integration_pvt.cas_mol_rec_tb_tp
1001: ) IS
1002: l_rsv_query_rec inv_reservation_global.mtl_reservation_rec_type;
1003: l_rsv_results_tbl inv_reservation_global.mtl_reservation_tbl_type;
1004: l_rsv_update_rec inv_reservation_global.mtl_reservation_rec_type;
1005: l_reservation_id NUMBER;
1006: l_dummy NUMBER;
1007:
1008: l_return_status VARCHAR2(1);
1192: ,x_msg_data OUT NOCOPY VARCHAR2
1193: ,p_cas_mol_rec_tb IN inv_rcv_integration_pvt.cas_mol_rec_tb_tp
1194: ,x_cas_mol_rec_tb OUT nocopy inv_rcv_integration_pvt.cas_mol_rec_tb_tp
1195: ) IS
1196: l_rsv_query_rec inv_reservation_global.mtl_reservation_rec_type;
1197: l_rsv_results_tbl inv_reservation_global.mtl_reservation_tbl_type;
1198: l_rsv_update_rec inv_reservation_global.mtl_reservation_rec_type;
1199: l_shipment_header_id NUMBER;
1200: l_requisition_header_id NUMBER;
1193: ,p_cas_mol_rec_tb IN inv_rcv_integration_pvt.cas_mol_rec_tb_tp
1194: ,x_cas_mol_rec_tb OUT nocopy inv_rcv_integration_pvt.cas_mol_rec_tb_tp
1195: ) IS
1196: l_rsv_query_rec inv_reservation_global.mtl_reservation_rec_type;
1197: l_rsv_results_tbl inv_reservation_global.mtl_reservation_tbl_type;
1198: l_rsv_update_rec inv_reservation_global.mtl_reservation_rec_type;
1199: l_shipment_header_id NUMBER;
1200: l_requisition_header_id NUMBER;
1201: l_rsv_results_count NUMBER;
1194: ,x_cas_mol_rec_tb OUT nocopy inv_rcv_integration_pvt.cas_mol_rec_tb_tp
1195: ) IS
1196: l_rsv_query_rec inv_reservation_global.mtl_reservation_rec_type;
1197: l_rsv_results_tbl inv_reservation_global.mtl_reservation_tbl_type;
1198: l_rsv_update_rec inv_reservation_global.mtl_reservation_rec_type;
1199: l_shipment_header_id NUMBER;
1200: l_requisition_header_id NUMBER;
1201: l_rsv_results_count NUMBER;
1202: l_remaining_prim_qty NUMBER;
1682: ,x_msg_count OUT NOCOPY NUMBER
1683: ,x_msg_data OUT NOCOPY VARCHAR2
1684: ,p_cas_mol_rec_tb IN inv_rcv_integration_pvt.cas_mol_rec_tb_tp
1685: ) IS
1686: l_rsv_reduce_rec inv_reservation_global.mtl_maintain_rsv_rec_type;
1687: l_rsv_query_rec inv_reservation_global.mtl_reservation_rec_type;
1688: l_rsv_results_tbl inv_reservation_global.mtl_reservation_tbl_type;
1689: l_rsv_update_rec inv_reservation_global.mtl_reservation_rec_type;
1690: l_remaining_prim_qty NUMBER;
1683: ,x_msg_data OUT NOCOPY VARCHAR2
1684: ,p_cas_mol_rec_tb IN inv_rcv_integration_pvt.cas_mol_rec_tb_tp
1685: ) IS
1686: l_rsv_reduce_rec inv_reservation_global.mtl_maintain_rsv_rec_type;
1687: l_rsv_query_rec inv_reservation_global.mtl_reservation_rec_type;
1688: l_rsv_results_tbl inv_reservation_global.mtl_reservation_tbl_type;
1689: l_rsv_update_rec inv_reservation_global.mtl_reservation_rec_type;
1690: l_remaining_prim_qty NUMBER;
1691: l_new_rsv_id NUMBER;
1684: ,p_cas_mol_rec_tb IN inv_rcv_integration_pvt.cas_mol_rec_tb_tp
1685: ) IS
1686: l_rsv_reduce_rec inv_reservation_global.mtl_maintain_rsv_rec_type;
1687: l_rsv_query_rec inv_reservation_global.mtl_reservation_rec_type;
1688: l_rsv_results_tbl inv_reservation_global.mtl_reservation_tbl_type;
1689: l_rsv_update_rec inv_reservation_global.mtl_reservation_rec_type;
1690: l_remaining_prim_qty NUMBER;
1691: l_new_rsv_id NUMBER;
1692: l_new_wdd_id NUMBER;
1685: ) IS
1686: l_rsv_reduce_rec inv_reservation_global.mtl_maintain_rsv_rec_type;
1687: l_rsv_query_rec inv_reservation_global.mtl_reservation_rec_type;
1688: l_rsv_results_tbl inv_reservation_global.mtl_reservation_tbl_type;
1689: l_rsv_update_rec inv_reservation_global.mtl_reservation_rec_type;
1690: l_remaining_prim_qty NUMBER;
1691: l_new_rsv_id NUMBER;
1692: l_new_wdd_id NUMBER;
1693: l_dummy NUMBER;
2042: ,x_msg_count OUT NOCOPY NUMBER
2043: ,x_msg_data OUT NOCOPY VARCHAR2
2044: ,p_cas_mol_rec_tb IN inv_rcv_integration_pvt.cas_mol_rec_tb_tp
2045: ) IS
2046: l_rsv_query_rec inv_reservation_global.mtl_reservation_rec_type;
2047: l_rsv_update_rec inv_reservation_global.mtl_reservation_rec_type;
2048: l_remaining_prim_qty NUMBER;
2049: l_shipment_header_id NUMBER;
2050: l_requisition_header_id NUMBER;
2043: ,x_msg_data OUT NOCOPY VARCHAR2
2044: ,p_cas_mol_rec_tb IN inv_rcv_integration_pvt.cas_mol_rec_tb_tp
2045: ) IS
2046: l_rsv_query_rec inv_reservation_global.mtl_reservation_rec_type;
2047: l_rsv_update_rec inv_reservation_global.mtl_reservation_rec_type;
2048: l_remaining_prim_qty NUMBER;
2049: l_shipment_header_id NUMBER;
2050: l_requisition_header_id NUMBER;
2051: l_supply_source_type_id NUMBER;
2221: , primary_reservation_quantity
2222: , reservation_uom_code
2223: , demand_source_line_detail
2224: FROM mtl_reservations mr
2225: WHERE mr.supply_source_type_id = inv_reservation_global.g_source_type_rcv
2226: AND mr.organization_id = p_cas_mol_rec_tb(1).organization_id
2227: AND mr.inventory_item_id = p_cas_mol_rec_tb(1).inventory_item_id
2228: AND ((mr.demand_source_line_detail IS NOT NULL
2229: AND mr.demand_source_line_detail
2542: l_rsv_update_rec.supply_source_header_id := p_cas_mol_rec_tb(1).po_header_id;
2543: l_rsv_update_rec.supply_source_line_id := p_cas_mol_rec_tb(1).po_line_location_id;
2544: l_rsv_update_rec.supply_source_line_detail := p_cas_mol_rec_tb(1).shipment_line_id;
2545: ELSIF (l_receipt_source_code = 'VENDOR' AND p_cas_mol_rec_tb(1).asn_line_flag = 'N') THEN
2546: l_rsv_update_rec.supply_source_type_id := inv_reservation_global.g_source_type_po;
2547: l_rsv_update_rec.supply_source_header_id := p_cas_mol_rec_tb(1).po_header_id;
2548: l_rsv_update_rec.supply_source_line_id := p_cas_mol_rec_tb(1).po_line_location_id;
2549: l_rsv_update_rec.supply_source_line_detail := NULL;
2550: ELSIF (l_receipt_source_code = 'INTERNAL ORDER') THEN
2548: l_rsv_update_rec.supply_source_line_id := p_cas_mol_rec_tb(1).po_line_location_id;
2549: l_rsv_update_rec.supply_source_line_detail := NULL;
2550: ELSIF (l_receipt_source_code = 'INTERNAL ORDER') THEN
2551: l_rsv_update_rec.supply_source_type_id :=
2552: inv_reservation_global.g_source_type_internal_req;
2553: l_rsv_update_rec.supply_source_header_id := l_requisition_header_id;
2554: l_rsv_update_rec.supply_source_line_id := p_cas_mol_rec_tb(1).requisition_line_id;
2555: l_rsv_update_rec.supply_source_line_detail := NULL;
2556: ELSIF (l_receipt_source_code = 'INVENTORY') THEN