13:
14: PROCEDURE available_supply_to_reserve
15: (
16: p_api_version_number IN NUMBER DEFAULT 1.0
17: , p_init_msg_lst IN VARCHAR2 DEFAULT fnd_api.g_false
18: , x_return_status OUT NOCOPY VARCHAR2
19: , x_msg_count OUT NOCOPY NUMBER
20: , x_msg_data OUT NOCOPY VARCHAR2
21: , p_organization_id IN NUMBER DEFAULT NULL
23: , p_revision IN VARCHAR2 DEFAULT NULL
24: , p_lot_number IN VARCHAR2 DEFAULT NULL
25: , p_subinventory_code IN VARCHAR2 DEFAULT NULL
26: , p_locator_id IN NUMBER DEFAULT NULL
27: , p_lpn_id IN NUMBER DEFAULT fnd_api.g_miss_num
28: , p_fm_supply_source_type_id IN NUMBER DEFAULT 0
29: , p_supply_source_type_id IN NUMBER
30: , p_supply_source_header_id IN NUMBER
31: , p_supply_source_line_id IN NUMBER
28: , p_fm_supply_source_type_id IN NUMBER DEFAULT 0
29: , p_supply_source_type_id IN NUMBER
30: , p_supply_source_header_id IN NUMBER
31: , p_supply_source_line_id IN NUMBER
32: , p_supply_source_line_detail IN NUMBER DEFAULT fnd_api.g_miss_num
33: , p_project_id IN NUMBER DEFAULT NULL
34: , p_task_id IN NUMBER DEFAULT NULL
35: , x_qty_available_to_reserve OUT NOCOPY NUMBER
36: , x_qty_available OUT NOCOPY NUMBER
36: , x_qty_available OUT NOCOPY NUMBER
37: ) IS
38: l_api_version_number CONSTANT NUMBER := 1.0;
39: l_api_name CONSTANT VARCHAR2(30) := 'avilable_supply_to_reserve';
40: l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
41: l_msg_count NUMBER;
42: l_msg_data VARCHAR2(2000);
43: l_debug NUMBER;
44: l_wip_entity_type NUMBER;
78: -- error out if supply source type id is null
79: IF (p_supply_source_type_id is null) THEN
80: fnd_message.set_name('INV', 'INV_NO_SUPPLY_TYPE');
81: fnd_msg_pub.add;
82: RAISE fnd_api.g_exc_error;
83: END IF;
84:
85: -- for WIP supply source
86: IF (p_supply_source_type_id = inv_reservation_global.g_source_type_wip) THEN
88: -- error out if supply source header id is null
89: IF (p_supply_source_header_id is null) THEN
90: fnd_message.set_name('INV','INV_NO_SUPPLY_INFO');
91: fnd_msg_pub.add;
92: RAISE fnd_api.g_exc_error;
93: END IF;
94:
95: -- get wip entity type from wip_record_cache
96: inv_reservation_util_pvt.get_wip_cache
98: x_return_status => l_return_status
99: , p_wip_entity_id => p_supply_source_header_id
100: );
101:
102: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
103: RAISE fnd_api.g_exc_error;
104: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
105: RAISE fnd_api.g_exc_unexpected_error;
106: ELSE
99: , p_wip_entity_id => p_supply_source_header_id
100: );
101:
102: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
103: RAISE fnd_api.g_exc_error;
104: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
105: RAISE fnd_api.g_exc_unexpected_error;
106: ELSE
107: l_wip_entity_type := inv_reservation_global.g_wip_record_cache(p_supply_source_header_id).wip_entity_type;
100: );
101:
102: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
103: RAISE fnd_api.g_exc_error;
104: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
105: RAISE fnd_api.g_exc_unexpected_error;
106: ELSE
107: l_wip_entity_type := inv_reservation_global.g_wip_record_cache(p_supply_source_header_id).wip_entity_type;
108: l_wip_job_type := inv_reservation_global.g_wip_record_cache(p_supply_source_header_id).wip_entity_job;
101:
102: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
103: RAISE fnd_api.g_exc_error;
104: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
105: RAISE fnd_api.g_exc_unexpected_error;
106: ELSE
107: l_wip_entity_type := inv_reservation_global.g_wip_record_cache(p_supply_source_header_id).wip_entity_type;
108: l_wip_job_type := inv_reservation_global.g_wip_record_cache(p_supply_source_header_id).wip_entity_job;
109: END IF;
156: , p_lpn_id => p_lpn_id
157: , p_project_id => null -- p_project_id
158: , p_task_id => null -- p_task_id
159: , p_api_version_number => 1.0
160: , p_init_msg_lst => fnd_api.g_false
161: , p_return_txn => l_return_txn
162: );
163:
164: IF (l_debug = 1) THEN
167: debug_print('source uom code = ' || l_source_uom_code);
168: debug_print('source primary uom code = ' || l_source_primary_uom_code);
169: END IF;
170:
171: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
172: raise fnd_api.g_exc_error;
173: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
174: raise fnd_api.g_exc_unexpected_error;
175: END IF;
168: debug_print('source primary uom code = ' || l_source_primary_uom_code);
169: END IF;
170:
171: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
172: raise fnd_api.g_exc_error;
173: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
174: raise fnd_api.g_exc_unexpected_error;
175: END IF;
176: ELSIF (l_wip_entity_type = inv_reservation_global.g_wip_source_type_osfm) THEN
169: END IF;
170:
171: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
172: raise fnd_api.g_exc_error;
173: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
174: raise fnd_api.g_exc_unexpected_error;
175: END IF;
176: ELSIF (l_wip_entity_type = inv_reservation_global.g_wip_source_type_osfm) THEN
177: -- remove comment later
170:
171: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
172: raise fnd_api.g_exc_error;
173: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
174: raise fnd_api.g_exc_unexpected_error;
175: END IF;
176: ELSIF (l_wip_entity_type = inv_reservation_global.g_wip_source_type_osfm) THEN
177: -- remove comment later
178: IF (l_debug = 1) THEN
201: , p_lpn_id => p_lpn_id
202: , p_project_id => null -- p_project_id
203: , p_task_id => null -- p_task_id
204: , p_api_version_number => 1.0
205: , p_init_msg_lst => fnd_api.g_false
206: );
207:
208: IF (l_debug = 1) THEN
209: debug_print('return status from get_available_supply_demand = ' || l_return_status);
211: debug_print('source uom code = ' || l_source_uom_code);
212: debug_print('source primary uom code = ' || l_source_primary_uom_code);
213: END IF;
214:
215: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
216: raise fnd_api.g_exc_error;
217: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
218: raise fnd_api.g_exc_unexpected_error;
219: END IF;
212: debug_print('source primary uom code = ' || l_source_primary_uom_code);
213: END IF;
214:
215: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
216: raise fnd_api.g_exc_error;
217: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
218: raise fnd_api.g_exc_unexpected_error;
219: END IF;
220: ELSIF (l_wip_entity_type = inv_reservation_global.g_wip_source_type_fpo OR
213: END IF;
214:
215: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
216: raise fnd_api.g_exc_error;
217: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
218: raise fnd_api.g_exc_unexpected_error;
219: END IF;
220: ELSIF (l_wip_entity_type = inv_reservation_global.g_wip_source_type_fpo OR
221: l_wip_entity_type = inv_reservation_global.g_wip_source_type_batch) THEN
214:
215: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
216: raise fnd_api.g_exc_error;
217: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
218: raise fnd_api.g_exc_unexpected_error;
219: END IF;
220: ELSIF (l_wip_entity_type = inv_reservation_global.g_wip_source_type_fpo OR
221: l_wip_entity_type = inv_reservation_global.g_wip_source_type_batch) THEN
222: -- remove comment later
245: , p_lpn_id => p_lpn_id
246: , p_project_id => null -- p_project_id
247: , p_task_id => null -- p_task_id
248: , p_api_version_number => 1.0
249: , p_init_msg_lst => fnd_api.g_false
250: );
251: /* Added following elsif for bug 13524480 */
252: ELSIF (l_wip_entity_type = inv_reservation_global.g_wip_source_type_cmro) THEN
253: IF (l_debug = 1) THEN
255: END IF;
256:
257: AHL_INV_RESERVATIONS_GRP.get_available_supply_demand (
258: p_api_version_number => 1.0
259: , p_init_msg_lst => fnd_api.g_false
260: , x_return_status => l_return_status
261: , x_msg_count => l_msg_count
262: , x_msg_data => l_msg_data
263: , p_organization_id => p_organization_id
287: debug_print('source uom code = ' || l_source_uom_code);
288: debug_print('source primary uom code = ' || l_source_primary_uom_code);
289: END IF;
290:
291: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
292: raise fnd_api.g_exc_error;
293: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
294: raise fnd_api.g_exc_unexpected_error;
295: END IF;
288: debug_print('source primary uom code = ' || l_source_primary_uom_code);
289: END IF;
290:
291: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
292: raise fnd_api.g_exc_error;
293: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
294: raise fnd_api.g_exc_unexpected_error;
295: END IF;
296:
289: END IF;
290:
291: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
292: raise fnd_api.g_exc_error;
293: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
294: raise fnd_api.g_exc_unexpected_error;
295: END IF;
296:
297: -- need uom conversion if source uom is different from primary uom
290:
291: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
292: raise fnd_api.g_exc_error;
293: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
294: raise fnd_api.g_exc_unexpected_error;
295: END IF;
296:
297: -- need uom conversion if source uom is different from primary uom
298: IF (l_available_quantity > 0 AND l_source_uom_code is not NULL AND l_source_uom_code <> l_source_primary_uom_code) THEN
364: -- error out if supply source header or line id is null
365: IF (p_supply_source_header_id is null or p_supply_source_line_id is null) THEN
366: fnd_message.set_name('INV','INV_NO_SUPPLY_INFO');
367: fnd_msg_pub.add;
368: RAISE fnd_api.g_exc_error;
369: END IF;
370:
371: -- for ASN supply, error if if supply source line detail is null
372: IF (p_supply_source_type_id = inv_reservation_global.g_source_type_asn
372: IF (p_supply_source_type_id = inv_reservation_global.g_source_type_asn
373: and p_supply_source_line_detail is null) THEN
374: fnd_message.set_name('INV','INV_NO_SUPPLY_INFO');
375: fnd_msg_pub.add;
376: RAISE fnd_api.g_exc_error;
377: END IF;
378:
379: -- call availability API for PO, ASN, Intransit shipment or Internal Req
380: -- For PO, the available quantity is the quantity ordered
415: , p_lpn_id => p_lpn_id
416: , p_project_id => p_project_id
417: , p_task_id => p_task_id
418: , p_api_version_number => 1.0
419: , p_init_msg_lst => fnd_api.g_false
420: );
421:
422: IF (l_debug = 1) THEN
423: debug_print('return status from RCV_availability.get_available_supply_demand = ' || l_return_status);
425: debug_print('source uom code = ' || l_source_uom_code);
426: debug_print('source primary uom code = ' || l_source_primary_uom_code);
427: END IF;
428:
429: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
430: raise fnd_api.g_exc_error;
431: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
432: raise fnd_api.g_exc_unexpected_error;
433: END IF;
426: debug_print('source primary uom code = ' || l_source_primary_uom_code);
427: END IF;
428:
429: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
430: raise fnd_api.g_exc_error;
431: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
432: raise fnd_api.g_exc_unexpected_error;
433: END IF;
434:
427: END IF;
428:
429: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
430: raise fnd_api.g_exc_error;
431: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
432: raise fnd_api.g_exc_unexpected_error;
433: END IF;
434:
435: -- need uom conversion if source uom is different from primary uom
428:
429: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
430: raise fnd_api.g_exc_error;
431: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
432: raise fnd_api.g_exc_unexpected_error;
433: END IF;
434:
435: -- need uom conversion if source uom is different from primary uom
436: IF (l_available_quantity > 0 AND l_source_uom_code is not NULL AND l_source_uom_code <> l_source_primary_uom_code) THEN
516: -- error out if organization_id or item id is null
517: IF (p_organization_id is null or p_item_id is null) THEN
518: fnd_message.set_name('INV', 'INV_NO_ORG_ITEM');
519: fnd_msg_pub.add;
520: RAISE fnd_api.g_exc_error;
521: END IF;
522:
523: -- call availability API for available quantity in receiving
524: IF (l_debug = 1) THEN
547: , p_lpn_id => p_lpn_id
548: , p_project_id => null -- p_project_id
549: , p_task_id => null -- p_task_id
550: , p_api_version_number => 1.0
551: , p_init_msg_lst => fnd_api.g_false
552: );
553:
554: IF (l_debug = 1) THEN
555: debug_print('return status from get_available_supply_demand = ' || l_return_status);
557: debug_print('source uom code = ' || l_source_uom_code);
558: debug_print('source primary uom code = ' || l_source_primary_uom_code);
559: END IF;
560:
561: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
562: raise fnd_api.g_exc_error;
563: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
564: raise fnd_api.g_exc_unexpected_error;
565: END IF;
558: debug_print('source primary uom code = ' || l_source_primary_uom_code);
559: END IF;
560:
561: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
562: raise fnd_api.g_exc_error;
563: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
564: raise fnd_api.g_exc_unexpected_error;
565: END IF;
566:
559: END IF;
560:
561: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
562: raise fnd_api.g_exc_error;
563: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
564: raise fnd_api.g_exc_unexpected_error;
565: END IF;
566:
567: -- need uom conversion if source uom is different from primary uom
560:
561: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
562: raise fnd_api.g_exc_error;
563: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
564: raise fnd_api.g_exc_unexpected_error;
565: END IF;
566:
567: -- need uom conversion if source uom is different from primary uom
568: IF (l_available_quantity > 0 AND l_source_uom_code is not NULL AND l_source_uom_code <> l_source_primary_uom_code) THEN
669: x_qty_available := nvl(l_primary_available_qty, 0);
670:
671: x_return_status := l_return_status;
672: EXCEPTION
673: WHEN fnd_api.g_exc_error THEN
674: x_return_status := fnd_api.g_ret_sts_error;
675: IF (l_debug = 1) THEN
676: debug_print('expected error in available_supply_to_reserve');
677: END IF;
670:
671: x_return_status := l_return_status;
672: EXCEPTION
673: WHEN fnd_api.g_exc_error THEN
674: x_return_status := fnd_api.g_ret_sts_error;
675: IF (l_debug = 1) THEN
676: debug_print('expected error in available_supply_to_reserve');
677: END IF;
678: --
675: IF (l_debug = 1) THEN
676: debug_print('expected error in available_supply_to_reserve');
677: END IF;
678: --
679: WHEN fnd_api.g_exc_unexpected_error THEN
680: x_return_status := fnd_api.g_ret_sts_unexp_error ;
681: IF (l_debug = 1) THEN
682: debug_print('unexpected error in available_supply_to_reserve');
683: debug_print('SQLCODE:'||SQLCODE||' SQLERRM:'||SQLERRM);
676: debug_print('expected error in available_supply_to_reserve');
677: END IF;
678: --
679: WHEN fnd_api.g_exc_unexpected_error THEN
680: x_return_status := fnd_api.g_ret_sts_unexp_error ;
681: IF (l_debug = 1) THEN
682: debug_print('unexpected error in available_supply_to_reserve');
683: debug_print('SQLCODE:'||SQLCODE||' SQLERRM:'||SQLERRM);
684: END IF;
683: debug_print('SQLCODE:'||SQLCODE||' SQLERRM:'||SQLERRM);
684: END IF;
685: --
686: WHEN OTHERS THEN
687: x_return_status := fnd_api.g_ret_sts_unexp_error ;
688: IF (l_debug = 1) THEN
689: debug_print('others error in available_supply_to_reserve');
690: debug_print('SQLCODE:'||SQLCODE||' SQLERRM:'||SQLERRM);
691: END IF;
702:
703:
704: PROCEDURE available_demand_to_reserve
705: ( p_api_version_number IN NUMBER DEFAULT 1.0
706: , p_init_msg_lst IN VARCHAR2 DEFAULT fnd_api.g_false
707: , x_return_status OUT NOCOPY VARCHAR2
708: , x_msg_count OUT NOCOPY NUMBER
709: , x_msg_data OUT NOCOPY VARCHAR2
710: , p_organization_id IN NUMBER DEFAULT NULL
712: , p_primary_uom_code IN VARCHAR2 DEFAULT NULL
713: , p_demand_source_type_id IN NUMBER
714: , p_demand_source_header_id IN NUMBER
715: , p_demand_source_line_id IN NUMBER
716: , p_demand_source_line_detail IN NUMBER DEFAULT fnd_api.g_miss_num
717: , p_project_id IN NUMBER DEFAULT NULL
718: , p_task_id IN NUMBER DEFAULT NULL
719: , x_qty_available_to_reserve OUT NOCOPY NUMBER
720: , x_qty_available OUT NOCOPY NUMBER
750:
751: PROCEDURE available_demand_to_reserve
752: (
753: p_api_version_number IN NUMBER DEFAULT 1.0
754: , p_init_msg_lst IN VARCHAR2 DEFAULT fnd_api.g_false
755: , x_return_status OUT NOCOPY VARCHAR2
756: , x_msg_count OUT NOCOPY NUMBER
757: , x_msg_data OUT NOCOPY VARCHAR2
758: , p_organization_id IN NUMBER DEFAULT NULL
760: , p_primary_uom_code IN VARCHAR2 DEFAULT NULL
761: , p_demand_source_type_id IN NUMBER
762: , p_demand_source_header_id IN NUMBER
763: , p_demand_source_line_id IN NUMBER
764: , p_demand_source_line_detail IN NUMBER DEFAULT fnd_api.g_miss_num
765: , p_project_id IN NUMBER DEFAULT NULL
766: , p_task_id IN NUMBER DEFAULT NULL
767: , x_qty_available_to_reserve OUT NOCOPY NUMBER
768: , x_qty_available OUT NOCOPY NUMBER
770: , x_qty_available2 OUT NOCOPY NUMBER
771: ) IS
772: l_api_version_number CONSTANT NUMBER := 1.0;
773: l_api_name CONSTANT VARCHAR2(30) := 'avilable_demand_to_reserve';
774: l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
775: l_msg_count NUMBER;
776: l_msg_data VARCHAR2(2000);
777: l_debug NUMBER;
778: l_wip_entity_type NUMBER;
859: -- error out if demand source type id is null
860: IF (p_demand_source_type_id is null) THEN
861: fnd_message.set_name('INV', 'INV_NO_DEMAND_TYPE');
862: fnd_msg_pub.add;
863: RAISE fnd_api.g_exc_error;
864: END IF;
865:
866: -- for WIP demand source
867: IF (p_demand_source_type_id = inv_reservation_global.g_source_type_wip) THEN
869: -- error out if demand source header id is null
870: IF (p_demand_source_header_id is null) THEN
871: fnd_message.set_name('INV','INV_NO_DEMAND_INFO');
872: fnd_msg_pub.add;
873: RAISE fnd_api.g_exc_error;
874: END IF;
875:
876: -- get wip entitty type from wip_record_cache
877: inv_reservation_util_pvt.get_wip_cache
879: x_return_status => l_return_status
880: , p_wip_entity_id => p_demand_source_header_id
881: );
882:
883: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
884: RAISE fnd_api.g_exc_error;
885: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
886: RAISE fnd_api.g_exc_unexpected_error;
887: ELSE
880: , p_wip_entity_id => p_demand_source_header_id
881: );
882:
883: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
884: RAISE fnd_api.g_exc_error;
885: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
886: RAISE fnd_api.g_exc_unexpected_error;
887: ELSE
888: l_wip_entity_type := inv_reservation_global.g_wip_record_cache(p_demand_source_header_id).wip_entity_type;
881: );
882:
883: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
884: RAISE fnd_api.g_exc_error;
885: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
886: RAISE fnd_api.g_exc_unexpected_error;
887: ELSE
888: l_wip_entity_type := inv_reservation_global.g_wip_record_cache(p_demand_source_header_id).wip_entity_type;
889: l_wip_job_type := inv_reservation_global.g_wip_record_cache(p_demand_source_header_id).wip_entity_job;
882:
883: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
884: RAISE fnd_api.g_exc_error;
885: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
886: RAISE fnd_api.g_exc_unexpected_error;
887: ELSE
888: l_wip_entity_type := inv_reservation_global.g_wip_record_cache(p_demand_source_header_id).wip_entity_type;
889: l_wip_job_type := inv_reservation_global.g_wip_record_cache(p_demand_source_header_id).wip_entity_job;
890: END IF;
925: , p_lpn_id => null
926: , p_project_id => null -- p_project_id
927: , p_task_id => null -- p_task_id
928: , p_api_version_number => 1.0
929: , p_init_msg_lst => fnd_api.g_false
930: );
931:
932: IF (l_debug = 1) THEN
933: debug_print('return status from cmro get_available_supply_demand = ' || l_return_status);
935: debug_print('source uom code = ' || l_source_uom_code);
936: debug_print('source primary uom code = ' || l_source_primary_uom_code);
937: END IF;
938:
939: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
940: raise fnd_api.g_exc_error;
941: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
942: raise fnd_api.g_exc_unexpected_error;
943: END IF;
936: debug_print('source primary uom code = ' || l_source_primary_uom_code);
937: END IF;
938:
939: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
940: raise fnd_api.g_exc_error;
941: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
942: raise fnd_api.g_exc_unexpected_error;
943: END IF;
944:
937: END IF;
938:
939: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
940: raise fnd_api.g_exc_error;
941: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
942: raise fnd_api.g_exc_unexpected_error;
943: END IF;
944:
945: -- get the sum of quantity that is already reserved on the document.
938:
939: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
940: raise fnd_api.g_exc_error;
941: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
942: raise fnd_api.g_exc_unexpected_error;
943: END IF;
944:
945: -- get the sum of quantity that is already reserved on the document.
946: -- bug #5458083 added demand_source_line_detail in the where clause
990: , p_lpn_id => null
991: , p_project_id => null -- p_project_id
992: , p_task_id => null -- p_task_id
993: , p_api_version_number => 1.0
994: , p_init_msg_lst => fnd_api.g_false
995: );
996:
997: IF (l_debug = 1) THEN
998: debug_print('return status from batch/fpo get_available_supply_demand = ' || l_return_status);
1000: debug_print('source uom code = ' || l_source_uom_code);
1001: debug_print('source primary uom code = ' || l_source_primary_uom_code);
1002: END IF;
1003:
1004: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
1005: raise fnd_api.g_exc_error;
1006: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
1007: raise fnd_api.g_exc_unexpected_error;
1008: END IF;
1001: debug_print('source primary uom code = ' || l_source_primary_uom_code);
1002: END IF;
1003:
1004: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
1005: raise fnd_api.g_exc_error;
1006: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
1007: raise fnd_api.g_exc_unexpected_error;
1008: END IF;
1009:
1002: END IF;
1003:
1004: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
1005: raise fnd_api.g_exc_error;
1006: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
1007: raise fnd_api.g_exc_unexpected_error;
1008: END IF;
1009:
1010: -- get the sum of quantity that is already reserved on the document.
1003:
1004: IF (l_return_status = fnd_api.g_ret_sts_error) THEN
1005: raise fnd_api.g_exc_error;
1006: ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
1007: raise fnd_api.g_exc_unexpected_error;
1008: END IF;
1009:
1010: -- get the sum of quantity that is already reserved on the document.
1011: BEGIN
1057: (inv_reservation_global.g_source_type_oe,
1058: inv_reservation_global.g_source_type_internal_ord,
1059: inv_reservation_global.g_source_type_rma)) THEN
1060:
1061: IF (p_demand_source_line_detail is not NULL AND p_demand_source_line_detail <> fnd_api.g_miss_num) THEN
1062:
1063: IF (l_debug = 1) THEN
1064: debug_print('p_demand_source_line_detail is not NULL and p_demand_source_line_detail <> fnd_api.g_miss_num');
1065: END IF;
1060:
1061: IF (p_demand_source_line_detail is not NULL AND p_demand_source_line_detail <> fnd_api.g_miss_num) THEN
1062:
1063: IF (l_debug = 1) THEN
1064: debug_print('p_demand_source_line_detail is not NULL and p_demand_source_line_detail <> fnd_api.g_miss_num');
1065: END IF;
1066:
1067: -- get wdd requested quantity with line detail level
1068: BEGIN
1082: END IF;
1083:
1084: FND_MESSAGE.SET_NAME('INV', 'INV_WDD_NOT_FOUND');
1085: FND_MSG_PUB.ADD;
1086: RAISE fnd_api.g_exc_error;
1087: END;
1088:
1089: IF (l_debug = 1) THEN
1090: debug_print('l_wdd_primary_quantity = ' || l_wdd_primary_quantity);
1148: debug_print('l_primary_reserved_quantity = ' || l_primary_reserved_quantity);
1149: debug_print('l_secondary_reserved_quantity = ' || l_secondary_reserved_quantity);
1150: END IF;
1151:
1152: ELSIF (p_demand_source_line_detail = fnd_api.g_miss_num) THEN
1153:
1154: IF (l_debug = 1) THEN
1155: debug_print('p_demand_source_line_detail = fnd_api.g_miss_num');
1156: END IF;
1151:
1152: ELSIF (p_demand_source_line_detail = fnd_api.g_miss_num) THEN
1153:
1154: IF (l_debug = 1) THEN
1155: debug_print('p_demand_source_line_detail = fnd_api.g_miss_num');
1156: END IF;
1157:
1158: -- get all reservation quantity at the order line level
1159: BEGIN
1515: IF (NOT INV_CACHE.set_org_rec(p_organization_id)) THEN
1516: IF (l_debug = 1) THEN
1517: debug_print('EXCEPTION while trying to set org parameters');
1518: END IF;
1519: RAISE fnd_api.g_exc_error;
1520: END IF;
1521: END IF;
1522: IF (l_debug = 1) THEN
1523: debug_print('wms enabled ? : '||NVL(INV_CACHE.org_rec.wms_enabled_flag,'N') );
1562: debug_print('Cannot find the primary unit of measure');
1563: END IF;
1564: FND_MESSAGE.SET_NAME('INV', 'INV_UOM_NOTFOUND');
1565: FND_MSG_PUB.ADD;
1566: RAISE fnd_api.g_exc_error;
1567: END;
1568: END IF;
1569:
1570: END IF;
1658:
1659: /* End bug# 8807194 */
1660:
1661:
1662: IF (p_demand_source_line_detail is not NULL AND p_demand_source_line_detail <> fnd_api.g_miss_num) THEN
1663:
1664: IF (l_debug = 1) THEN
1665: debug_print('p_demand_source_line_detail is not NULL AND p_demand_source_line_detail <> fnd_api.g_miss_num');
1666: END IF;
1661:
1662: IF (p_demand_source_line_detail is not NULL AND p_demand_source_line_detail <> fnd_api.g_miss_num) THEN
1663:
1664: IF (l_debug = 1) THEN
1665: debug_print('p_demand_source_line_detail is not NULL AND p_demand_source_line_detail <> fnd_api.g_miss_num');
1666: END IF;
1667:
1668: l_wdd_available_qty := nvl(l_wdd_primary_quantity,0) - nvl(l_wdd_primary_reserved_qty,0);
1669: l_order_available_qty := nvl(l_primary_available_qty,0) - nvl(l_primary_reserved_quantity,0);
1719: x_qty_available2 := nvl(l_available_quantity2, 0);
1720:
1721: x_return_status := l_return_status;
1722: EXCEPTION
1723: WHEN fnd_api.g_exc_error THEN
1724: x_return_status := fnd_api.g_ret_sts_error;
1725: --
1726: WHEN fnd_api.g_exc_unexpected_error THEN
1727: x_return_status := fnd_api.g_ret_sts_unexp_error ;
1720:
1721: x_return_status := l_return_status;
1722: EXCEPTION
1723: WHEN fnd_api.g_exc_error THEN
1724: x_return_status := fnd_api.g_ret_sts_error;
1725: --
1726: WHEN fnd_api.g_exc_unexpected_error THEN
1727: x_return_status := fnd_api.g_ret_sts_unexp_error ;
1728: --
1722: EXCEPTION
1723: WHEN fnd_api.g_exc_error THEN
1724: x_return_status := fnd_api.g_ret_sts_error;
1725: --
1726: WHEN fnd_api.g_exc_unexpected_error THEN
1727: x_return_status := fnd_api.g_ret_sts_unexp_error ;
1728: --
1729: WHEN OTHERS THEN
1730: x_return_status := fnd_api.g_ret_sts_unexp_error ;
1723: WHEN fnd_api.g_exc_error THEN
1724: x_return_status := fnd_api.g_ret_sts_error;
1725: --
1726: WHEN fnd_api.g_exc_unexpected_error THEN
1727: x_return_status := fnd_api.g_ret_sts_unexp_error ;
1728: --
1729: WHEN OTHERS THEN
1730: x_return_status := fnd_api.g_ret_sts_unexp_error ;
1731: --
1726: WHEN fnd_api.g_exc_unexpected_error THEN
1727: x_return_status := fnd_api.g_ret_sts_unexp_error ;
1728: --
1729: WHEN OTHERS THEN
1730: x_return_status := fnd_api.g_ret_sts_unexp_error ;
1731: --
1732: IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
1733: THEN
1734: fnd_msg_pub.add_exc_msg