80: debug_print('Exception Occurred while checking reservable type for subinventory : '
81: || l_rsv_rec.subinventory_code || ' Organization Id :'
82: || l_rsv_rec.organization_id );
83: END IF;
84: RAISE fnd_api.g_exc_unexpected_error;
85: END;
86: END IF;
87:
88: -- Checking whether the locator is reservable or not
100: debug_print('Exception Occurred while checking reservable type for locator : '
101: || l_rsv_rec.locator_id || ' Organization Id :'
102: || l_rsv_rec.organization_id );
103: END IF;
104: RAISE fnd_api.g_exc_unexpected_error;
105: END;
106: END IF;
107:
108: -- Checking whether the lot is reservable or not
125: || l_rsv_rec.lot_number || ' Organization Id :'
126: || l_rsv_rec.organization_id || ' Invenotry Item Id :'
127: || l_rsv_rec.inventory_item_id);
128: END IF;
129: RAISE fnd_api.g_exc_unexpected_error;
130: END;
131: END IF;
132:
133: IF (l_debug = 1) THEN
231: IS
232: l_mtl_reservation inv_reservation_global.mtl_reservation_tbl_type;
233: x_mtl_reservation inv_reservation_global.mtl_reservation_tbl_type;
234: l_rsv_index NUMBER := 0;
235: l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
236: l_debug NUMBER;
237:
238: BEGIN
239:
369:
370: x_return_status := l_return_status;
371: --
372: EXCEPTION
373: WHEN fnd_api.g_exc_error THEN
374: x_return_status := fnd_api.g_ret_sts_error;
375: IF (l_debug = 1) THEN
376: debug_print('Error occurred in Sort Reservation : ' || x_return_status);
377: END IF;
370: x_return_status := l_return_status;
371: --
372: EXCEPTION
373: WHEN fnd_api.g_exc_error THEN
374: x_return_status := fnd_api.g_ret_sts_error;
375: IF (l_debug = 1) THEN
376: debug_print('Error occurred in Sort Reservation : ' || x_return_status);
377: END IF;
378: --
375: IF (l_debug = 1) THEN
376: debug_print('Error occurred in Sort Reservation : ' || x_return_status);
377: END IF;
378: --
379: WHEN fnd_api.g_exc_unexpected_error THEN
380: x_return_status := fnd_api.g_ret_sts_unexp_error;
381: IF (l_debug = 1) THEN
382: debug_print('Exception occurred in Sort Reservation : ' || x_return_status);
383: END IF;
376: debug_print('Error occurred in Sort Reservation : ' || x_return_status);
377: END IF;
378: --
379: WHEN fnd_api.g_exc_unexpected_error THEN
380: x_return_status := fnd_api.g_ret_sts_unexp_error;
381: IF (l_debug = 1) THEN
382: debug_print('Exception occurred in Sort Reservation : ' || x_return_status);
383: END IF;
384:
382: debug_print('Exception occurred in Sort Reservation : ' || x_return_status);
383: END IF;
384:
385: WHEN OTHERS THEN
386: x_return_status := fnd_api.g_ret_sts_unexp_error;
387: IF (l_debug = 1) THEN
388: debug_print('Exception occurred in Sort Reservation : ' || x_return_status);
389: END IF;
390:
406: IS
407: l_mtl_reservation inv_reservation_global.mtl_reservation_tbl_type;
408: x_mtl_reservation inv_reservation_global.mtl_reservation_tbl_type;
409: l_rsv_index NUMBER := 0;
410: l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
411: l_debug NUMBER;
412: l_rev_control BOOLEAN;
413: l_lot_control BOOLEAN;
414: l_ser_control BOOLEAN;
458: END IF;
459:
460: inv_quantity_tree_pvt.create_tree (
461: p_api_version_number => 1.0
462: , p_init_msg_lst => fnd_api.g_true
463: , x_return_status => l_return_status
464: , x_msg_count => x_msg_count
465: , x_msg_data => x_msg_data
466: , p_organization_id => p_rsv_rec.organization_id
483: IF (l_debug = 1) THEN
484: debug_print('After create tree in process reservations ' || l_return_status || ' Tree Id: ' || l_tree_id);
485: END IF;
486:
487: IF l_return_status = fnd_api.g_ret_sts_error THEN
488: RAISE fnd_api.g_exc_error;
489: END IF;
490:
491: IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
484: debug_print('After create tree in process reservations ' || l_return_status || ' Tree Id: ' || l_tree_id);
485: END IF;
486:
487: IF l_return_status = fnd_api.g_ret_sts_error THEN
488: RAISE fnd_api.g_exc_error;
489: END IF;
490:
491: IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
492: RAISE fnd_api.g_exc_unexpected_error;
487: IF l_return_status = fnd_api.g_ret_sts_error THEN
488: RAISE fnd_api.g_exc_error;
489: END IF;
490:
491: IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
492: RAISE fnd_api.g_exc_unexpected_error;
493: END IF;
494:
495: inv_quantity_tree_pvt.query_tree(
488: RAISE fnd_api.g_exc_error;
489: END IF;
490:
491: IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
492: RAISE fnd_api.g_exc_unexpected_error;
493: END IF;
494:
495: inv_quantity_tree_pvt.query_tree(
496: p_api_version_number => 1.0
493: END IF;
494:
495: inv_quantity_tree_pvt.query_tree(
496: p_api_version_number => 1.0
497: , p_init_msg_lst => fnd_api.g_true
498: , x_return_status => l_return_status
499: , x_msg_count => l_msg_count
500: , x_msg_data => l_msg_data
501: , p_tree_id => l_tree_id
522: debug_print('After query tree in process reservations ' || l_return_status);
523: END IF;
524:
525:
526: IF l_return_status = fnd_api.g_ret_sts_error THEN
527: RAISE fnd_api.g_exc_error;
528: END IF;
529:
530: IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
523: END IF;
524:
525:
526: IF l_return_status = fnd_api.g_ret_sts_error THEN
527: RAISE fnd_api.g_exc_error;
528: END IF;
529:
530: IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
531: RAISE fnd_api.g_exc_unexpected_error;
526: IF l_return_status = fnd_api.g_ret_sts_error THEN
527: RAISE fnd_api.g_exc_error;
528: END IF;
529:
530: IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
531: RAISE fnd_api.g_exc_unexpected_error;
532: END IF;
533:
534: IF (l_debug = 1) THEN
527: RAISE fnd_api.g_exc_error;
528: END IF;
529:
530: IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
531: RAISE fnd_api.g_exc_unexpected_error;
532: END IF;
533:
534: IF (l_debug = 1) THEN
535: debug_print('l_atr ' || l_atr);
548:
549: x_atr := l_atr;
550:
551: EXCEPTION
552: WHEN fnd_api.g_exc_error THEN
553: x_return_status := fnd_api.g_ret_sts_error;
554: IF (l_debug = 1) THEN
555: debug_print('Error occurred in Get atr : ' || x_return_status);
556: END IF;
549: x_atr := l_atr;
550:
551: EXCEPTION
552: WHEN fnd_api.g_exc_error THEN
553: x_return_status := fnd_api.g_ret_sts_error;
554: IF (l_debug = 1) THEN
555: debug_print('Error occurred in Get atr : ' || x_return_status);
556: END IF;
557: --
554: IF (l_debug = 1) THEN
555: debug_print('Error occurred in Get atr : ' || x_return_status);
556: END IF;
557: --
558: WHEN fnd_api.g_exc_unexpected_error THEN
559: x_return_status := fnd_api.g_ret_sts_unexp_error;
560: IF (l_debug = 1) THEN
561: debug_print('Exception occurred in Get atr : ' || x_return_status);
562: END IF;
555: debug_print('Error occurred in Get atr : ' || x_return_status);
556: END IF;
557: --
558: WHEN fnd_api.g_exc_unexpected_error THEN
559: x_return_status := fnd_api.g_ret_sts_unexp_error;
560: IF (l_debug = 1) THEN
561: debug_print('Exception occurred in Get atr : ' || x_return_status);
562: END IF;
563:
561: debug_print('Exception occurred in Get atr : ' || x_return_status);
562: END IF;
563:
564: WHEN OTHERS THEN
565: x_return_status := fnd_api.g_ret_sts_unexp_error;
566: IF (l_debug = 1) THEN
567: debug_print('Exception occurred in Get atr : ' || x_return_status);
568: END IF;
569: END Get_atr;
579: -- p_api_version_number API version number (current version is 1.0)
580: --
581: -- p_init_msg_lst Whether initialize the error message list or
582: -- not.
583: -- Should be fnd_api.g_false or fnd_api.g_true
584: --
585: -- p_rsv_rec Contains info to be used to process the
586: -- reservation
587: --
593: -- IF STAGE then the reservation would be
594: -- detailed and then staged
595: --
596: -- Output Parameters
597: -- x_return_status = fnd_api.g_ret_sts_success, if succeeded
598: -- = fnd_api.g_ret_sts_exc_error, if an expected
599: -- error occurred
600: -- = fnd_api.g_ret_sts_unexp_error, if
601: -- an unexpected error occurred
594: -- detailed and then staged
595: --
596: -- Output Parameters
597: -- x_return_status = fnd_api.g_ret_sts_success, if succeeded
598: -- = fnd_api.g_ret_sts_exc_error, if an expected
599: -- error occurred
600: -- = fnd_api.g_ret_sts_unexp_error, if
601: -- an unexpected error occurred
602: --
596: -- Output Parameters
597: -- x_return_status = fnd_api.g_ret_sts_success, if succeeded
598: -- = fnd_api.g_ret_sts_exc_error, if an expected
599: -- error occurred
600: -- = fnd_api.g_ret_sts_unexp_error, if
601: -- an unexpected error occurred
602: --
603: -- x_msg_count Number of error message in the error message
604: -- list
609: --
610:
611: PROCEDURE Process_Reservation
612: ( p_api_version_number IN NUMBER ,
613: p_init_msg_lst IN VARCHAR2 DEFAULT fnd_api.g_false ,
614: p_rsv_rec IN inv_reservation_global.mtl_reservation_rec_type ,
615: p_serial_number IN inv_reservation_global.serial_number_tbl_type ,
616: p_rsv_status IN VARCHAR2,
617: x_return_status OUT NOCOPY VARCHAR2 ,
619: x_msg_data OUT NOCOPY VARCHAR2
620: )
621: IS
622:
623: l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
624: l_msg_count NUMBER;
625: l_msg_data VARCHAR2(2000);
626: l_query_input inv_reservation_global.mtl_reservation_rec_type;
627: l_query_det_rsv inv_reservation_global.mtl_reservation_rec_type;
696: debug_print('Converting all the missing fields in the input reservation record to NULL');
697: END IF;
698: --Convert all the missing fileds in the input rsv record to NULL
699: inv_reservation_pvt.convert_missing_to_null ( p_rsv_rec => l_rsv_rec1, x_rsv_rec => l_rsv_rec);
700: IF l_return_status <> fnd_api.g_ret_sts_success THEN
701: IF (l_debug = 1) THEN
702: debug_print(' return error from inv_reservation_pvt.convert_missing_to_null '||l_return_status);
703: END IF;
704: RAISE fnd_api.g_exc_unexpected_error;
700: IF l_return_status <> fnd_api.g_ret_sts_success THEN
701: IF (l_debug = 1) THEN
702: debug_print(' return error from inv_reservation_pvt.convert_missing_to_null '||l_return_status);
703: END IF;
704: RAISE fnd_api.g_exc_unexpected_error;
705: END IF;
706:
707: --Print the input reservation record passed
708: inv_reservation_pvt.print_rsv_rec( p_rsv_rec => l_rsv_rec);
711: debug_print('Handling prim, sec, rsv uom and qty');
712: END IF;
713: --Handle uom conversion
714: inv_reservation_pvt.convert_quantity( x_return_status => l_return_status, px_rsv_rec => l_rsv_rec);
715: IF l_return_status <> fnd_api.g_ret_sts_success THEN
716: IF (l_debug = 1) THEN
717: debug_print(' return error from inv_reservation_pvt.convert_quantity '||l_return_status);
718: END IF;
719: RAISE fnd_api.g_exc_unexpected_error;
715: IF l_return_status <> fnd_api.g_ret_sts_success THEN
716: IF (l_debug = 1) THEN
717: debug_print(' return error from inv_reservation_pvt.convert_quantity '||l_return_status);
718: END IF;
719: RAISE fnd_api.g_exc_unexpected_error;
720: END IF;
721:
722: --Query reservations only on the basis of demand source line id from the input.
723: --This will fetch all reservation records for the respective demand source line
739: --l_query_input.staged_flag := NULL;
740:
741: inv_reservation_pub.query_reservation(
742: p_api_version_number => 1.0
743: , p_init_msg_lst => fnd_api.g_true
744: , x_return_status => l_return_status
745: , x_msg_count => l_msg_count
746: , x_msg_data => l_msg_data
747: , p_query_input => l_query_input
750: , x_error_code => l_error_code
751: );
752:
753: -- Return an error if the query reservations call failed
754: IF l_return_status <> fnd_api.g_ret_sts_success THEN
755: IF (l_debug = 1) THEN
756: debug_print(' return error from query reservation: '||l_return_status);
757: END IF;
758: fnd_message.set_name('INV', 'INV_QRY_RSV_FAILED');
756: debug_print(' return error from query reservation: '||l_return_status);
757: END IF;
758: fnd_message.set_name('INV', 'INV_QRY_RSV_FAILED');
759: fnd_msg_pub.ADD;
760: RAISE fnd_api.g_exc_unexpected_error;
761: END IF;
762:
763: IF l_mtl_reservation_count > 0 THEN
764: --Calculate the total primary reservation qty by summing up all the
787: IF (l_debug = 1) THEN
788: debug_print('No reservations exists for the demand source line : '|| l_rsv_rec.demand_source_line_id);
789: debug_print('Return without processing any reservations');
790: END IF;
791: x_return_status := fnd_api.g_ret_sts_success;
792: RETURN;
793: END IF;
794:
795: IF l_mtl_rsv_non_staged_count <= 0 THEN
796: IF (l_debug = 1) THEN
797: debug_print('No Unstaged reservations exists for the demand source line : '|| l_rsv_rec.demand_source_line_id);
798: debug_print('Return without processing any reservations');
799: END IF;
800: x_return_status := fnd_api.g_ret_sts_success;
801: RETURN;
802: END IF;
803:
804: -- set the item cache
806: If NOT l_return_value THEN
807: IF (l_debug = 1) THEN
808: debug_print('Exception occurred while setting the item cache');
809: END IF;
810: RAISE fnd_api.g_exc_unexpected_error;
811: End If;
812:
813: l_primary_uom := INV_CACHE.item_rec.primary_uom_code;
814: l_secondary_uom := INV_CACHE.item_rec.secondary_uom_code;
853: x_msg_count => l_msg_count,
854: x_msg_data => l_msg_data
855: );
856:
857: IF l_return_status <> fnd_api.g_ret_sts_success THEN
858: IF (l_debug = 1) THEN
859: debug_print(' return error from sort reservation: '||l_return_status);
860: END IF;
861: RAISE fnd_api.g_exc_unexpected_error;
857: IF l_return_status <> fnd_api.g_ret_sts_success THEN
858: IF (l_debug = 1) THEN
859: debug_print(' return error from sort reservation: '||l_return_status);
860: END IF;
861: RAISE fnd_api.g_exc_unexpected_error;
862: END IF;
863:
864: END IF;
865:
905: END IF;
906:
907: inv_reservation_pub.delete_reservation
908: ( p_api_version_number => 1.0
909: , p_init_msg_lst => fnd_api.g_false
910: , x_return_status => l_return_status
911: , x_msg_count => l_msg_count
912: , x_msg_data => l_msg_data
913: , p_rsv_rec => l_mtl_reservation_non_staged(i)
914: , p_serial_number => l_dummy_sn
915: );
916:
917: -- Return an error if the delete reservations call failed
918: IF l_return_status <> fnd_api.g_ret_sts_success THEN
919: IF (l_debug = 1) THEN
920: debug_print(' return error from delete reservation: '||l_return_status);
921: END IF;
922: RAISE fnd_api.g_exc_unexpected_error;
918: IF l_return_status <> fnd_api.g_ret_sts_success THEN
919: IF (l_debug = 1) THEN
920: debug_print(' return error from delete reservation: '||l_return_status);
921: END IF;
922: RAISE fnd_api.g_exc_unexpected_error;
923: END IF;
924: END LOOP;
925:
926: ELSE -- l_rsv_rec.reservation_quantity < l_primary_reservation_qty
947: END IF;
948:
949: inv_reservation_pub.delete_reservation
950: ( p_api_version_number => 1.0
951: , p_init_msg_lst => fnd_api.g_false
952: , x_return_status => l_return_status
953: , x_msg_count => l_msg_count
954: , x_msg_data => l_msg_data
955: , p_rsv_rec => l_mtl_reservation_non_staged(i)
956: , p_serial_number => l_dummy_sn
957: );
958:
959: -- Return an error if the delete reservations call failed
960: IF l_return_status <> fnd_api.g_ret_sts_success THEN
961: IF (l_debug = 1) THEN
962: debug_print(' return error from delete reservation: '||l_return_status);
963: END IF;
964: RAISE fnd_api.g_exc_unexpected_error;
960: IF l_return_status <> fnd_api.g_ret_sts_success THEN
961: IF (l_debug = 1) THEN
962: debug_print(' return error from delete reservation: '||l_return_status);
963: END IF;
964: RAISE fnd_api.g_exc_unexpected_error;
965: END IF;
966:
967:
968: ELSE --IF l_remaining_reservation_qty < l_mtl_reservation(i).reservation_quantity
984: debug_print('Handling rsv qty and sec rsv qty for the reservation record which is to be updated');
985: END IF;
986:
987: inv_reservation_pvt.convert_quantity( x_return_status => l_return_status, px_rsv_rec => l_to_rsv_record);
988: IF l_return_status <> fnd_api.g_ret_sts_success THEN
989: IF (l_debug = 1) THEN
990: debug_print(' return error from inv_reservation_pvt.convert_quantity '||l_return_status);
991: END IF;
992: RAISE fnd_api.g_exc_unexpected_error;
988: IF l_return_status <> fnd_api.g_ret_sts_success THEN
989: IF (l_debug = 1) THEN
990: debug_print(' return error from inv_reservation_pvt.convert_quantity '||l_return_status);
991: END IF;
992: RAISE fnd_api.g_exc_unexpected_error;
993: END IF;
994:
995:
996: IF (l_debug = 1) THEN
1003: -- This update will always reduce the primary qty.
1004: -- Unmarking of the serial in case of serial controlled items is handled by the api
1005: inv_reservation_pub.update_reservation(
1006: p_api_version_number => 1.0
1007: , p_init_msg_lst => fnd_api.g_false
1008: , x_return_status => l_return_status
1009: , x_msg_count => l_msg_count
1010: , x_msg_data => l_msg_data
1011: , p_original_rsv_rec => l_original_rsv_record
1011: , p_original_rsv_rec => l_original_rsv_record
1012: , p_to_rsv_rec => l_to_rsv_record
1013: , p_original_serial_number => l_dummy_sn
1014: , p_to_serial_number => l_dummy_sn
1015: , p_validation_flag => fnd_api.g_true
1016: , p_over_reservation_flag => 2
1017: );
1018:
1019: IF l_return_status <> fnd_api.g_ret_sts_success THEN
1015: , p_validation_flag => fnd_api.g_true
1016: , p_over_reservation_flag => 2
1017: );
1018:
1019: IF l_return_status <> fnd_api.g_ret_sts_success THEN
1020: IF (l_debug = 1) THEN
1021: debug_print('return error from update reservation: '||l_return_status);
1022: END IF;
1023: fnd_message.set_name('INV', 'INV_UPD_RSV_FAILED');
1021: debug_print('return error from update reservation: '||l_return_status);
1022: END IF;
1023: fnd_message.set_name('INV', 'INV_UPD_RSV_FAILED');
1024: fnd_msg_pub.ADD;
1025: RAISE fnd_api.g_exc_unexpected_error;
1026: END IF;
1027: END IF; --IF l_remaining_reservation_qty >= l_mtl_reservation_non_staged(i).reservation_quantity
1028:
1029: l_remaining_reservation_qty := l_remaining_reservation_qty - l_mtl_reservation_non_staged(i).primary_reservation_quantity;
1045: , x_msg_count => l_msg_count
1046: , x_msg_data => l_msg_data
1047: );
1048:
1049: IF l_return_status <> fnd_api.g_ret_sts_success THEN
1050: IF (l_debug = 1) THEN
1051: debug_print(' return error from inv_rsv_detail_stage_pvt.Get_atr '||l_return_status);
1052: END IF;
1053: RAISE fnd_api.g_exc_unexpected_error;
1049: IF l_return_status <> fnd_api.g_ret_sts_success THEN
1050: IF (l_debug = 1) THEN
1051: debug_print(' return error from inv_rsv_detail_stage_pvt.Get_atr '||l_return_status);
1052: END IF;
1053: RAISE fnd_api.g_exc_unexpected_error;
1054: ELSE
1055: IF (l_debug = 1) THEN
1056: debug_print(' Atr for the given sku is : '||l_atr);
1057: END IF;
1123: END IF;
1124:
1125: inv_reservation_pub.create_reservation(
1126: p_api_version_number => 1.0
1127: , p_init_msg_lst => fnd_api.g_false
1128: , x_return_status => l_return_status
1129: , x_msg_count => l_msg_count
1130: , x_msg_data => l_msg_data
1131: , p_rsv_rec => l_create_rsv_rec
1130: , x_msg_data => l_msg_data
1131: , p_rsv_rec => l_create_rsv_rec
1132: , p_serial_number => l_serial_number
1133: , x_serial_number => l_serial_number1
1134: , p_partial_reservation_flag => fnd_api.g_true
1135: , p_force_reservation_flag => fnd_api.g_false
1136: , p_validation_flag => fnd_api.g_true
1137: , x_quantity_reserved => l_det_res_qty
1138: , x_reservation_id => l_det_res_id
1131: , p_rsv_rec => l_create_rsv_rec
1132: , p_serial_number => l_serial_number
1133: , x_serial_number => l_serial_number1
1134: , p_partial_reservation_flag => fnd_api.g_true
1135: , p_force_reservation_flag => fnd_api.g_false
1136: , p_validation_flag => fnd_api.g_true
1137: , x_quantity_reserved => l_det_res_qty
1138: , x_reservation_id => l_det_res_id
1139: , p_over_reservation_flag => 2
1132: , p_serial_number => l_serial_number
1133: , x_serial_number => l_serial_number1
1134: , p_partial_reservation_flag => fnd_api.g_true
1135: , p_force_reservation_flag => fnd_api.g_false
1136: , p_validation_flag => fnd_api.g_true
1137: , x_quantity_reserved => l_det_res_qty
1138: , x_reservation_id => l_det_res_id
1139: , p_over_reservation_flag => 2
1140: );
1139: , p_over_reservation_flag => 2
1140: );
1141:
1142: -- Return an error if the query reservation call failed
1143: IF l_return_status <> fnd_api.g_ret_sts_success THEN
1144: IF (l_debug = 1) THEN
1145: debug_print('return error from query reservation: '||l_return_status);
1146: END IF;
1147: fnd_message.set_name('INV', 'INV_QRY_RSV_FAILED');
1145: debug_print('return error from query reservation: '||l_return_status);
1146: END IF;
1147: fnd_message.set_name('INV', 'INV_QRY_RSV_FAILED');
1148: fnd_msg_pub.ADD;
1149: RAISE fnd_api.g_exc_unexpected_error;
1150: END IF;
1151:
1152: IF (l_debug = 1) THEN
1153: debug_print('Detailed reservation created. Reservation Id : ' || l_det_res_id || ' and qty :' || l_det_res_qty);
1160: END IF;
1161: -- Query for the one reservation created for updating the det qty
1162: inv_reservation_pub.query_reservation(
1163: p_api_version_number => 1.0
1164: , p_init_msg_lst => fnd_api.g_true
1165: , x_return_status => l_return_status
1166: , x_msg_count => l_msg_count
1167: , x_msg_data => l_msg_data
1168: , p_query_input => l_query_det_rsv
1171: , x_error_code => l_error_code
1172: );
1173:
1174: -- Return an error if the query reservations call failed
1175: IF l_return_status <> fnd_api.g_ret_sts_success THEN
1176: IF (l_debug = 1) THEN
1177: debug_print(' return error from query reservation: '||l_return_status);
1178: END IF;
1179: fnd_message.set_name('INV', 'INV_QRY_RSV_FAILED');
1177: debug_print(' return error from query reservation: '||l_return_status);
1178: END IF;
1179: fnd_message.set_name('INV', 'INV_QRY_RSV_FAILED');
1180: fnd_msg_pub.ADD;
1181: RAISE fnd_api.g_exc_unexpected_error;
1182: END IF;
1183:
1184: l_mtl_reservation_det_qty := l_mtl_reservation_detailed(1) ;
1185: l_mtl_reservation_det_qty.detailed_quantity := l_det_res_qty; --l_rsv_rec.primary_reservation_quantity;
1191:
1192: --This update is meant only to update the det qty and sec det qty
1193: inv_reservation_pub.update_reservation(
1194: p_api_version_number => 1.0
1195: , p_init_msg_lst => fnd_api.g_false
1196: , x_return_status => l_return_status
1197: , x_msg_count => l_msg_count
1198: , x_msg_data => l_msg_data
1199: , p_original_rsv_rec => l_mtl_reservation_detailed(1)
1199: , p_original_rsv_rec => l_mtl_reservation_detailed(1)
1200: , p_to_rsv_rec => l_mtl_reservation_det_qty
1201: , p_original_serial_number => l_dummy_sn
1202: , p_to_serial_number => l_dummy_sn
1203: , p_validation_flag => fnd_api.g_true
1204: , p_over_reservation_flag => 2
1205: );
1206:
1207: IF l_return_status <> fnd_api.g_ret_sts_success THEN
1203: , p_validation_flag => fnd_api.g_true
1204: , p_over_reservation_flag => 2
1205: );
1206:
1207: IF l_return_status <> fnd_api.g_ret_sts_success THEN
1208: IF (l_debug = 1) THEN
1209: debug_print('return error from update reservation: '||l_return_status);
1210: END IF;
1211: fnd_message.set_name('INV', 'INV_UPD_RSV_FAILED');
1209: debug_print('return error from update reservation: '||l_return_status);
1210: END IF;
1211: fnd_message.set_name('INV', 'INV_UPD_RSV_FAILED');
1212: fnd_msg_pub.ADD;
1213: RAISE fnd_api.g_exc_unexpected_error;
1214: END IF;
1215:
1216: IF (l_debug = 1) THEN
1217: debug_print('Reservation successfully detailed ');
1238: END IF;
1239: -- Query for the one detailed reservation created
1240: inv_reservation_pub.query_reservation(
1241: p_api_version_number => 1.0
1242: , p_init_msg_lst => fnd_api.g_true
1243: , x_return_status => l_return_status
1244: , x_msg_count => l_msg_count
1245: , x_msg_data => l_msg_data
1246: , p_query_input => l_query_det_rsv
1249: , x_error_code => l_error_code
1250: );
1251:
1252: -- Return an error if the query reservations call failed
1253: IF l_return_status <> fnd_api.g_ret_sts_success THEN
1254: IF (l_debug = 1) THEN
1255: debug_print(' return error from query reservation: '||l_return_status);
1256: END IF;
1257: fnd_message.set_name('INV', 'INV_QRY_RSV_FAILED');
1255: debug_print(' return error from query reservation: '||l_return_status);
1256: END IF;
1257: fnd_message.set_name('INV', 'INV_QRY_RSV_FAILED');
1258: fnd_msg_pub.ADD;
1259: RAISE fnd_api.g_exc_unexpected_error;
1260: END IF;
1261:
1262: l_mtl_reservation_staged := l_mtl_reservation_detailed(1) ;
1263: l_mtl_reservation_staged.staged_flag := 'Y';
1270: END IF;
1271:
1272: inv_reservation_pub.update_reservation(
1273: p_api_version_number => 1.0
1274: , p_init_msg_lst => fnd_api.g_false
1275: , x_return_status => l_return_status
1276: , x_msg_count => l_msg_count
1277: , x_msg_data => l_msg_data
1278: , p_original_rsv_rec => l_mtl_reservation_detailed(1)
1278: , p_original_rsv_rec => l_mtl_reservation_detailed(1)
1279: , p_to_rsv_rec => l_mtl_reservation_staged
1280: , p_original_serial_number => l_dummy_sn
1281: , p_to_serial_number => l_dummy_sn
1282: , p_validation_flag => fnd_api.g_true
1283: , p_over_reservation_flag => 2
1284: );
1285:
1286: IF l_return_status <> fnd_api.g_ret_sts_success THEN
1282: , p_validation_flag => fnd_api.g_true
1283: , p_over_reservation_flag => 2
1284: );
1285:
1286: IF l_return_status <> fnd_api.g_ret_sts_success THEN
1287: IF (l_debug = 1) THEN
1288: debug_print('return error from update reservation: '||l_return_status);
1289: END IF;
1290: fnd_message.set_name('INV', 'INV_UPD_RSV_FAILED');
1288: debug_print('return error from update reservation: '||l_return_status);
1289: END IF;
1290: fnd_message.set_name('INV', 'INV_UPD_RSV_FAILED');
1291: fnd_msg_pub.ADD;
1292: RAISE fnd_api.g_exc_unexpected_error;
1293: END IF;
1294:
1295: END IF; --IF l_det_res_id IS NOT NULL THEN
1296:
1299: x_return_status := l_return_status;
1300:
1301: EXCEPTION
1302:
1303: WHEN fnd_api.g_exc_error THEN
1304: ROLLBACK TO process_reservation_ds;
1305: x_return_status := fnd_api.g_ret_sts_error;
1306: IF (l_debug = 1) THEN
1307: debug_print('Error occurred in Process Reservation : '||l_return_status);
1301: EXCEPTION
1302:
1303: WHEN fnd_api.g_exc_error THEN
1304: ROLLBACK TO process_reservation_ds;
1305: x_return_status := fnd_api.g_ret_sts_error;
1306: IF (l_debug = 1) THEN
1307: debug_print('Error occurred in Process Reservation : '||l_return_status);
1308: END IF;
1309: fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
1308: END IF;
1309: fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
1310:
1311:
1312: WHEN fnd_api.g_exc_unexpected_error THEN
1313: ROLLBACK TO process_reservation_ds;
1314: x_return_status := fnd_api.g_ret_sts_unexp_error;
1315: IF (l_debug = 1) THEN
1316: debug_print('Unexpected error occurred in Process Reservation : '||l_return_status);
1310:
1311:
1312: WHEN fnd_api.g_exc_unexpected_error THEN
1313: ROLLBACK TO process_reservation_ds;
1314: x_return_status := fnd_api.g_ret_sts_unexp_error;
1315: IF (l_debug = 1) THEN
1316: debug_print('Unexpected error occurred in Process Reservation : '||l_return_status);
1317: END IF;
1318: fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
1318: fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
1319:
1320: WHEN OTHERS THEN
1321: ROLLBACK TO process_reservation_ds;
1322: x_return_status := fnd_api.g_ret_sts_unexp_error;
1323: IF (l_debug = 1) THEN
1324: debug_print('Unexpected error occurred in Process Reservation : '||l_return_status);
1325: END IF;
1326: fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);