191: /*Int variables
192: =========================================*/
193: x_return_status := FND_API.G_RET_STS_SUCCESS;
194:
195: IF (g_debug <= gme_debug.g_log_statement) THEN
196: gme_debug.log_initialize ('OPM_MaketoOrder');
197: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' ENTER API ');
198: -- gme_debug.log_initialize ('OPM_MaketoOrder');
199: END IF;
192: =========================================*/
193: x_return_status := FND_API.G_RET_STS_SUCCESS;
194:
195: IF (g_debug <= gme_debug.g_log_statement) THEN
196: gme_debug.log_initialize ('OPM_MaketoOrder');
197: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' ENTER API ');
198: -- gme_debug.log_initialize ('OPM_MaketoOrder');
199: END IF;
200:
193: x_return_status := FND_API.G_RET_STS_SUCCESS;
194:
195: IF (g_debug <= gme_debug.g_log_statement) THEN
196: gme_debug.log_initialize ('OPM_MaketoOrder');
197: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' ENTER API ');
198: -- gme_debug.log_initialize ('OPM_MaketoOrder');
199: END IF;
200:
201: /* Standard begin of API savepoint
194:
195: IF (g_debug <= gme_debug.g_log_statement) THEN
196: gme_debug.log_initialize ('OPM_MaketoOrder');
197: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' ENTER API ');
198: -- gme_debug.log_initialize ('OPM_MaketoOrder');
199: END IF;
200:
201: /* Standard begin of API savepoint
202: ===========================================*/
210: p_api_version,
211: l_api_name,
212: g_pkg_name)
213: THEN
214: IF (g_debug <= gme_debug.g_log_statement) THEN
215: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' compatability call failure ');
216: END IF;
217: RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
218: END IF;
211: l_api_name,
212: g_pkg_name)
213: THEN
214: IF (g_debug <= gme_debug.g_log_statement) THEN
215: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' compatability call failure ');
216: END IF;
217: RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
218: END IF;
219:
225: FND_MSG_PUB.initialize;
226: END IF;
227:
228: FND_FILE.Put_Line(FND_FILE.LOG, 'After Initialize ');
229: IF (g_debug <= gme_debug.g_log_statement) THEN
230: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' begin processing ');
231: END IF;
232:
233: IF( NVL(p_so_line_id,0) = 0 ) THEN
226: END IF;
227:
228: FND_FILE.Put_Line(FND_FILE.LOG, 'After Initialize ');
229: IF (g_debug <= gme_debug.g_log_statement) THEN
230: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' begin processing ');
231: END IF;
232:
233: IF( NVL(p_so_line_id,0) = 0 ) THEN
234: IF (g_debug <= gme_debug.g_log_statement) THEN
230: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' begin processing ');
231: END IF;
232:
233: IF( NVL(p_so_line_id,0) = 0 ) THEN
234: IF (g_debug <= gme_debug.g_log_statement) THEN
235: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' sales order line id parameter is missing ');
236: END IF;
237: FND_MESSAGE.Set_Name('GMI','Missing');
238: FND_MESSAGE.Set_Token('MISSING', 'so_line_id');
231: END IF;
232:
233: IF( NVL(p_so_line_id,0) = 0 ) THEN
234: IF (g_debug <= gme_debug.g_log_statement) THEN
235: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' sales order line id parameter is missing ');
236: END IF;
237: FND_MESSAGE.Set_Name('GMI','Missing');
238: FND_MESSAGE.Set_Token('MISSING', 'so_line_id');
239: FND_MSG_PUB.Add;
245: OPEN Get_order_info(p_so_line_id);
246: FETCH Get_order_info INTO l_so_line_no,l_item_no,
247: l_order_no;
248: IF(Get_order_info%NOTFOUND) THEN
249: IF g_debug <= gme_debug.g_log_procedure THEN
250: gme_debug.put_line(g_pkg_name||'.'||l_api_name ||'Get_order_info%NOTFOUND');
251: END IF;
252: END IF;
253: CLOSE Get_order_info;
246: FETCH Get_order_info INTO l_so_line_no,l_item_no,
247: l_order_no;
248: IF(Get_order_info%NOTFOUND) THEN
249: IF g_debug <= gme_debug.g_log_procedure THEN
250: gme_debug.put_line(g_pkg_name||'.'||l_api_name ||'Get_order_info%NOTFOUND');
251: END IF;
252: END IF;
253: CLOSE Get_order_info;
254:
252: END IF;
253: CLOSE Get_order_info;
254:
255: /* ============ IF this line is already reserved to production supply do not process further =========== */
256: IF (g_debug <= gme_debug.g_log_statement) THEN
257: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Check for existing reservations against GME PROD supply ');
258: END IF;
259: OPEN cur_prod_reservations(p_so_line_id);
260: FETCH cur_prod_reservations INTO l_count;
253: CLOSE Get_order_info;
254:
255: /* ============ IF this line is already reserved to production supply do not process further =========== */
256: IF (g_debug <= gme_debug.g_log_statement) THEN
257: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Check for existing reservations against GME PROD supply ');
258: END IF;
259: OPEN cur_prod_reservations(p_so_line_id);
260: FETCH cur_prod_reservations INTO l_count;
261: IF (cur_prod_reservations%NOTFOUND) or (l_count=0) THEN
260: FETCH cur_prod_reservations INTO l_count;
261: IF (cur_prod_reservations%NOTFOUND) or (l_count=0) THEN
262: FND_FILE.Put_Line(FND_FILE.LOG,' No existing reservations against PRODUCTION supply'); -- Bug 13359707
263:
264: IF g_debug <= gme_debug.g_log_procedure THEN
265: gme_debug.put_line(g_pkg_name||'.'||l_api_name || ' No existing reservations against PRODUCTION supply');
266: END IF;
267: CLOSE cur_prod_reservations;
268: ELSE
261: IF (cur_prod_reservations%NOTFOUND) or (l_count=0) THEN
262: FND_FILE.Put_Line(FND_FILE.LOG,' No existing reservations against PRODUCTION supply'); -- Bug 13359707
263:
264: IF g_debug <= gme_debug.g_log_procedure THEN
265: gme_debug.put_line(g_pkg_name||'.'||l_api_name || ' No existing reservations against PRODUCTION supply');
266: END IF;
267: CLOSE cur_prod_reservations;
268: ELSE
269:
267: CLOSE cur_prod_reservations;
268: ELSE
269:
270: FND_FILE.Put_Line(FND_FILE.LOG,'Reservations already against PRODUCTION supply so terminate here'); -- Bug 13359707
271: IF g_debug <= gme_debug.g_log_procedure THEN
272: gme_debug.put_line(g_pkg_name||'.'||l_api_name || 'Reservations already against PRODUCTION supply so terminate here');
273: END IF;
274: CLOSE cur_prod_reservations;
275: RETURN;
268: ELSE
269:
270: FND_FILE.Put_Line(FND_FILE.LOG,'Reservations already against PRODUCTION supply so terminate here'); -- Bug 13359707
271: IF g_debug <= gme_debug.g_log_procedure THEN
272: gme_debug.put_line(g_pkg_name||'.'||l_api_name || 'Reservations already against PRODUCTION supply so terminate here');
273: END IF;
274: CLOSE cur_prod_reservations;
275: RETURN;
276: END IF;
275: RETURN;
276: END IF;
277:
278: /* ============== Start of Order Line Processing ====================*/
279: IF (g_debug <= gme_debug.g_log_statement) THEN
280: gme_debug.put_line(g_pkg_name||'.'||l_api_name||'Retrieve the sales order line for line_id '||p_so_line_id);
281: END IF;
282:
283: OPEN get_so_line_rec(p_so_line_id);
276: END IF;
277:
278: /* ============== Start of Order Line Processing ====================*/
279: IF (g_debug <= gme_debug.g_log_statement) THEN
280: gme_debug.put_line(g_pkg_name||'.'||l_api_name||'Retrieve the sales order line for line_id '||p_so_line_id);
281: END IF;
282:
283: OPEN get_so_line_rec(p_so_line_id);
284: FETCH get_so_line_rec INTO l_so_line_rec;
284: FETCH get_so_line_rec INTO l_so_line_rec;
285:
286: IF(get_so_line_rec%NOTFOUND) THEN
287: CLOSE get_so_line_rec;
288: IF (g_debug <= gme_debug.g_log_statement) THEN
289: gme_debug.put_line(g_pkg_name||'.'||l_api_name||'RETURNING - sales order not found for for line_id '||p_so_line_id);
290: END IF;
291: RAISE FND_API.G_EXC_ERROR;
292: END IF;
285:
286: IF(get_so_line_rec%NOTFOUND) THEN
287: CLOSE get_so_line_rec;
288: IF (g_debug <= gme_debug.g_log_statement) THEN
289: gme_debug.put_line(g_pkg_name||'.'||l_api_name||'RETURNING - sales order not found for for line_id '||p_so_line_id);
290: END IF;
291: RAISE FND_API.G_EXC_ERROR;
292: END IF;
293: CLOSE get_so_line_rec;
292: END IF;
293: CLOSE get_so_line_rec;
294:
295: /* ============== Establish Item Characteristics ====================*/
296: IF (g_debug <= gme_debug.g_log_statement) THEN
297: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve Item for organization_id '||l_so_line_rec.ship_from_org_id);
298: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve Item for inventory_item_id '||l_so_line_rec.inventory_item_id);
299: END IF;
300: OPEN cur_item (l_so_line_rec.ship_from_org_id, l_so_line_rec.inventory_item_id);
293: CLOSE get_so_line_rec;
294:
295: /* ============== Establish Item Characteristics ====================*/
296: IF (g_debug <= gme_debug.g_log_statement) THEN
297: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve Item for organization_id '||l_so_line_rec.ship_from_org_id);
298: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve Item for inventory_item_id '||l_so_line_rec.inventory_item_id);
299: END IF;
300: OPEN cur_item (l_so_line_rec.ship_from_org_id, l_so_line_rec.inventory_item_id);
301: FETCH cur_item INTO l_item_rec;
294:
295: /* ============== Establish Item Characteristics ====================*/
296: IF (g_debug <= gme_debug.g_log_statement) THEN
297: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve Item for organization_id '||l_so_line_rec.ship_from_org_id);
298: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve Item for inventory_item_id '||l_so_line_rec.inventory_item_id);
299: END IF;
300: OPEN cur_item (l_so_line_rec.ship_from_org_id, l_so_line_rec.inventory_item_id);
301: FETCH cur_item INTO l_item_rec;
302: IF(cur_item%NOTFOUND) THEN
301: FETCH cur_item INTO l_item_rec;
302: IF(cur_item%NOTFOUND) THEN
303: CLOSE cur_item;
304: FND_FILE.Put_Line(FND_FILE.LOG,'Failure to retrieve inventory item'); -- Bug 13359707
305: IF (g_debug <= gme_debug.g_log_statement) THEN
306: gme_debug.put_line(g_pkg_name||'.'||l_api_name||'Failure to retrieve inventory item ');
307: END IF;
308: RAISE FND_API.G_EXC_ERROR;
309: END IF;
302: IF(cur_item%NOTFOUND) THEN
303: CLOSE cur_item;
304: FND_FILE.Put_Line(FND_FILE.LOG,'Failure to retrieve inventory item'); -- Bug 13359707
305: IF (g_debug <= gme_debug.g_log_statement) THEN
306: gme_debug.put_line(g_pkg_name||'.'||l_api_name||'Failure to retrieve inventory item ');
307: END IF;
308: RAISE FND_API.G_EXC_ERROR;
309: END IF;
310: CLOSE cur_item;
309: END IF;
310: CLOSE cur_item;
311:
312: /* ============== Determine whether Make to Order Rule exists ===============*/
313: IF (g_debug <= gme_debug.g_log_statement) THEN
314: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Determine whether make to order rule exists ');
315: END IF;
316:
317: l_in_assignments_rec.organization_id := l_so_line_rec.ship_from_org_id;
310: CLOSE cur_item;
311:
312: /* ============== Determine whether Make to Order Rule exists ===============*/
313: IF (g_debug <= gme_debug.g_log_statement) THEN
314: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Determine whether make to order rule exists ');
315: END IF;
316:
317: l_in_assignments_rec.organization_id := l_so_line_rec.ship_from_org_id;
318: l_in_assignments_rec.inventory_item_id := l_so_line_rec.inventory_item_id;
327: ,x_return_status => l_return_status
328: ,x_msg_data => l_msg_data
329: ,x_msg_count => l_msg_count);
330:
331: IF (g_debug <= gme_debug.g_log_statement) THEN
332: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Return status from Retrieve_Rule is '||l_return_status);
333: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Rule ID to work with is '||l_mto_assignments_rec.rule_id);
334: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Rule being honored is '||l_mto_rules_rec.rule_name);
335: END IF;
328: ,x_msg_data => l_msg_data
329: ,x_msg_count => l_msg_count);
330:
331: IF (g_debug <= gme_debug.g_log_statement) THEN
332: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Return status from Retrieve_Rule is '||l_return_status);
333: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Rule ID to work with is '||l_mto_assignments_rec.rule_id);
334: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Rule being honored is '||l_mto_rules_rec.rule_name);
335: END IF;
336:
329: ,x_msg_count => l_msg_count);
330:
331: IF (g_debug <= gme_debug.g_log_statement) THEN
332: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Return status from Retrieve_Rule is '||l_return_status);
333: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Rule ID to work with is '||l_mto_assignments_rec.rule_id);
334: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Rule being honored is '||l_mto_rules_rec.rule_name);
335: END IF;
336:
337: IF( l_return_status <> FND_API.G_RET_STS_SUCCESS ) THEN
330:
331: IF (g_debug <= gme_debug.g_log_statement) THEN
332: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Return status from Retrieve_Rule is '||l_return_status);
333: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Rule ID to work with is '||l_mto_assignments_rec.rule_id);
334: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Rule being honored is '||l_mto_rules_rec.rule_name);
335: END IF;
336:
337: IF( l_return_status <> FND_API.G_RET_STS_SUCCESS ) THEN
338: FND_FILE.Put_Line(FND_FILE.LOG,' Failure to Get_Rule so terminate processing for order '||l_order_no); -- Bug 13359707
336:
337: IF( l_return_status <> FND_API.G_RET_STS_SUCCESS ) THEN
338: FND_FILE.Put_Line(FND_FILE.LOG,' Failure to Get_Rule so terminate processing for order '||l_order_no); -- Bug 13359707
339: FND_FILE.Put_Line(FND_FILE.LOG,' Failure to Get_Rule so terminate processing for line '||l_so_line_no); -- Bug 13359707
340: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Failure to Get_Rule so terminate processing for line '||p_so_line_id);
341: FND_MESSAGE.Set_Name('GMI','Missing');
342: FND_MESSAGE.Set_Token('MISSING', 'rule_id');
343: FND_MSG_PUB.Add;
344: RAISE FND_API.G_EXC_ERROR;
346:
347: IF (NVL(l_mto_rules_rec.rule_id,0) = 0) THEN
348: FND_FILE.Put_Line(FND_FILE.LOG,' No MAKE to ORDER rule exists to cover order '||l_order_no); -- Bug 13359707
349: FND_FILE.Put_Line(FND_FILE.LOG,' No MAKE to ORDER rule exists to cover order line '||l_so_line_no); -- Bug 13359707
350: gme_debug.put_line(g_pkg_name||'.'||l_api_name||'No MAKE to ORDER rule exists to cover order line '||p_so_line_id);
351: gme_debug.put_line(g_pkg_name||'.'||l_api_name||'No Further Processing Required for order line '||p_so_line_id);
352: RETURN;
353: END IF;
354:
347: IF (NVL(l_mto_rules_rec.rule_id,0) = 0) THEN
348: FND_FILE.Put_Line(FND_FILE.LOG,' No MAKE to ORDER rule exists to cover order '||l_order_no); -- Bug 13359707
349: FND_FILE.Put_Line(FND_FILE.LOG,' No MAKE to ORDER rule exists to cover order line '||l_so_line_no); -- Bug 13359707
350: gme_debug.put_line(g_pkg_name||'.'||l_api_name||'No MAKE to ORDER rule exists to cover order line '||p_so_line_id);
351: gme_debug.put_line(g_pkg_name||'.'||l_api_name||'No Further Processing Required for order line '||p_so_line_id);
352: RETURN;
353: END IF;
354:
355: /* ============== Start Processing Make to Order Rule ===============*/
352: RETURN;
353: END IF;
354:
355: /* ============== Start Processing Make to Order Rule ===============*/
356: IF (g_debug <= gme_debug.g_log_statement) THEN
357: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Start processing rule definition for '||l_mto_rules_rec.rule_name);
358: END IF;
359:
360: /* ================== Assess the rule for checking available inventory =================*/
353: END IF;
354:
355: /* ============== Start Processing Make to Order Rule ===============*/
356: IF (g_debug <= gme_debug.g_log_statement) THEN
357: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Start processing rule definition for '||l_mto_rules_rec.rule_name);
358: END IF;
359:
360: /* ================== Assess the rule for checking available inventory =================*/
361: IF (g_debug <= gme_debug.g_log_statement) THEN
357: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Start processing rule definition for '||l_mto_rules_rec.rule_name);
358: END IF;
359:
360: /* ================== Assess the rule for checking available inventory =================*/
361: IF (g_debug <= gme_debug.g_log_statement) THEN
362: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Check Availability set to '||l_mto_rules_rec.check_availability);
363: END IF;
364: IF NVL(l_mto_rules_rec.check_availability,'N') = 'N' THEN
365: IF (g_debug <= gme_debug.g_log_statement) THEN
358: END IF;
359:
360: /* ================== Assess the rule for checking available inventory =================*/
361: IF (g_debug <= gme_debug.g_log_statement) THEN
362: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Check Availability set to '||l_mto_rules_rec.check_availability);
363: END IF;
364: IF NVL(l_mto_rules_rec.check_availability,'N') = 'N' THEN
365: IF (g_debug <= gme_debug.g_log_statement) THEN
366: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' No need for Availabilty check create for full order qty');
361: IF (g_debug <= gme_debug.g_log_statement) THEN
362: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Check Availability set to '||l_mto_rules_rec.check_availability);
363: END IF;
364: IF NVL(l_mto_rules_rec.check_availability,'N') = 'N' THEN
365: IF (g_debug <= gme_debug.g_log_statement) THEN
366: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' No need for Availabilty check create for full order qty');
367: END IF;
368: /* Create a batch for the full order line quantity regardless of onhand availability
369: - Relieve any reservations against inventory; must not duplicate demand
362: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Check Availability set to '||l_mto_rules_rec.check_availability);
363: END IF;
364: IF NVL(l_mto_rules_rec.check_availability,'N') = 'N' THEN
365: IF (g_debug <= gme_debug.g_log_statement) THEN
366: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' No need for Availabilty check create for full order qty');
367: END IF;
368: /* Create a batch for the full order line quantity regardless of onhand availability
369: - Relieve any reservations against inventory; must not duplicate demand
370: ==================================================================================*/
369: - Relieve any reservations against inventory; must not duplicate demand
370: ==================================================================================*/
371: l_batch_qty := l_so_line_rec.ordered_quantity;
372: l_batch_qty2 := l_so_line_rec.ordered_quantity2;
373: IF (g_debug <= gme_debug.g_log_statement) THEN
374: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Batch quantity needed is '||l_batch_qty);
375: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Secondary qty needed is '||l_batch_qty2);
376: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve any existing inv reservations ');
377: END IF;
370: ==================================================================================*/
371: l_batch_qty := l_so_line_rec.ordered_quantity;
372: l_batch_qty2 := l_so_line_rec.ordered_quantity2;
373: IF (g_debug <= gme_debug.g_log_statement) THEN
374: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Batch quantity needed is '||l_batch_qty);
375: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Secondary qty needed is '||l_batch_qty2);
376: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve any existing inv reservations ');
377: END IF;
378: OPEN cur_inv_reservations (l_so_line_id);
371: l_batch_qty := l_so_line_rec.ordered_quantity;
372: l_batch_qty2 := l_so_line_rec.ordered_quantity2;
373: IF (g_debug <= gme_debug.g_log_statement) THEN
374: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Batch quantity needed is '||l_batch_qty);
375: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Secondary qty needed is '||l_batch_qty2);
376: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve any existing inv reservations ');
377: END IF;
378: OPEN cur_inv_reservations (l_so_line_id);
379:
372: l_batch_qty2 := l_so_line_rec.ordered_quantity2;
373: IF (g_debug <= gme_debug.g_log_statement) THEN
374: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Batch quantity needed is '||l_batch_qty);
375: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Secondary qty needed is '||l_batch_qty2);
376: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve any existing inv reservations ');
377: END IF;
378: OPEN cur_inv_reservations (l_so_line_id);
379:
380: FETCH cur_inv_reservations
381: BULK COLLECT INTO l_rsv_tbl;
382: CLOSE cur_inv_reservations;
383:
384: l_count := 1;
385: IF (g_debug <= gme_debug.g_log_statement) THEN
386: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Loop thru existing reservations for'||l_rsv_tbl.COUNT);
387: END IF;
388: WHILE l_count <= l_rsv_tbl.COUNT LOOP
389: l_rsv_row_rec := l_rsv_tbl(l_count);
382: CLOSE cur_inv_reservations;
383:
384: l_count := 1;
385: IF (g_debug <= gme_debug.g_log_statement) THEN
386: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Loop thru existing reservations for'||l_rsv_tbl.COUNT);
387: END IF;
388: WHILE l_count <= l_rsv_tbl.COUNT LOOP
389: l_rsv_row_rec := l_rsv_tbl(l_count);
390: /* Relieve any reservations against INV */
387: END IF;
388: WHILE l_count <= l_rsv_tbl.COUNT LOOP
389: l_rsv_row_rec := l_rsv_tbl(l_count);
390: /* Relieve any reservations against INV */
391: IF (g_debug <= gme_debug.g_log_statement) THEN
392: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Relieve Reservation here for ID '||l_rsv_row_rec.reservation_id);
393: END IF;
394: gme_reservations_pvt.relieve_reservation
395: (p_reservation_id => l_rsv_row_rec.reservation_id
388: WHILE l_count <= l_rsv_tbl.COUNT LOOP
389: l_rsv_row_rec := l_rsv_tbl(l_count);
390: /* Relieve any reservations against INV */
391: IF (g_debug <= gme_debug.g_log_statement) THEN
392: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Relieve Reservation here for ID '||l_rsv_row_rec.reservation_id);
393: END IF;
394: gme_reservations_pvt.relieve_reservation
395: (p_reservation_id => l_rsv_row_rec.reservation_id
396: ,p_prim_relieve_qty => l_rsv_row_rec.primary_reservation_quantity
395: (p_reservation_id => l_rsv_row_rec.reservation_id
396: ,p_prim_relieve_qty => l_rsv_row_rec.primary_reservation_quantity
397: ,x_return_status => x_return_status);
398:
399: IF g_debug <= gme_debug.g_log_statement THEN
400: gme_debug.put_line
401: ( g_pkg_name
402: || '.'
403: || l_api_name
396: ,p_prim_relieve_qty => l_rsv_row_rec.primary_reservation_quantity
397: ,x_return_status => x_return_status);
398:
399: IF g_debug <= gme_debug.g_log_statement THEN
400: gme_debug.put_line
401: ( g_pkg_name
402: || '.'
403: || l_api_name
404: || ' Return status from relieve_reservation is '
414:
415: /* Deal with cases where check on availability is required
416: ========================================================= */
417: IF NVL(l_mto_rules_rec.check_availability,'N') = 'Y' THEN
418: IF (g_debug <= gme_debug.g_log_statement) THEN
419: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' NEED to check Inventory Availabilty ahead of creating batch');
420: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' start point is the order qty ' ||l_so_line_rec.ordered_quantity);
421: END IF;
422: /* Find out how much quantity needs to be manufactured to meet inventory shortfall */
415: /* Deal with cases where check on availability is required
416: ========================================================= */
417: IF NVL(l_mto_rules_rec.check_availability,'N') = 'Y' THEN
418: IF (g_debug <= gme_debug.g_log_statement) THEN
419: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' NEED to check Inventory Availabilty ahead of creating batch');
420: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' start point is the order qty ' ||l_so_line_rec.ordered_quantity);
421: END IF;
422: /* Find out how much quantity needs to be manufactured to meet inventory shortfall */
423: /* step 1 - what is the current unreserved quantity
416: ========================================================= */
417: IF NVL(l_mto_rules_rec.check_availability,'N') = 'Y' THEN
418: IF (g_debug <= gme_debug.g_log_statement) THEN
419: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' NEED to check Inventory Availabilty ahead of creating batch');
420: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' start point is the order qty ' ||l_so_line_rec.ordered_quantity);
421: END IF;
422: /* Find out how much quantity needs to be manufactured to meet inventory shortfall */
423: /* step 1 - what is the current unreserved quantity
424: =======================================================*/
454: exception when no_data_found then
455: null;
456: end;
457:
458: IF (g_debug <= gme_debug.g_log_statement) THEN
459: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Deduct qty already reserved, this is '||l_total_primary_rsv_qty);
460: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Now batch qty required stands at '||l_batch_qty);
461: END IF;
462: IF (l_batch_qty <= 0) THEN
455: null;
456: end;
457:
458: IF (g_debug <= gme_debug.g_log_statement) THEN
459: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Deduct qty already reserved, this is '||l_total_primary_rsv_qty);
460: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Now batch qty required stands at '||l_batch_qty);
461: END IF;
462: IF (l_batch_qty <= 0) THEN
463: IF (g_debug <= gme_debug.g_log_statement) THEN
456: end;
457:
458: IF (g_debug <= gme_debug.g_log_statement) THEN
459: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Deduct qty already reserved, this is '||l_total_primary_rsv_qty);
460: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Now batch qty required stands at '||l_batch_qty);
461: END IF;
462: IF (l_batch_qty <= 0) THEN
463: IF (g_debug <= gme_debug.g_log_statement) THEN
464: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Full Order Qty already reserved to INV');
459: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Deduct qty already reserved, this is '||l_total_primary_rsv_qty);
460: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Now batch qty required stands at '||l_batch_qty);
461: END IF;
462: IF (l_batch_qty <= 0) THEN
463: IF (g_debug <= gme_debug.g_log_statement) THEN
464: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Full Order Qty already reserved to INV');
465: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' No need for batch creation Return here');
466: END IF;
467: RETURN;
460: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Now batch qty required stands at '||l_batch_qty);
461: END IF;
462: IF (l_batch_qty <= 0) THEN
463: IF (g_debug <= gme_debug.g_log_statement) THEN
464: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Full Order Qty already reserved to INV');
465: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' No need for batch creation Return here');
466: END IF;
467: RETURN;
468: END IF;
461: END IF;
462: IF (l_batch_qty <= 0) THEN
463: IF (g_debug <= gme_debug.g_log_statement) THEN
464: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Full Order Qty already reserved to INV');
465: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' No need for batch creation Return here');
466: END IF;
467: RETURN;
468: END IF;
469:
474: l_is_lot_control := TRUE;
475: END IF;
476:
477: -- set controls for locator and serial
478: IF (g_debug <= gme_debug.g_log_statement) THEN
479: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Need to assess ATR level so invoke create tree');
480: END IF;
481:
482: inv_quantity_tree_pvt.create_tree
475: END IF;
476:
477: -- set controls for locator and serial
478: IF (g_debug <= gme_debug.g_log_statement) THEN
479: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Need to assess ATR level so invoke create tree');
480: END IF;
481:
482: inv_quantity_tree_pvt.create_tree
483: (
502: , p_lot_expiration_date => SYSDATE
503: , x_tree_id => l_tree_id
504: );
505:
506: IF (g_debug <= gme_debug.g_log_statement) THEN
507: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' After create tree status returned is '||l_return_status);
508: END IF;
509:
510: IF l_return_status = fnd_api.g_ret_sts_error THEN
503: , x_tree_id => l_tree_id
504: );
505:
506: IF (g_debug <= gme_debug.g_log_statement) THEN
507: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' After create tree status returned is '||l_return_status);
508: END IF;
509:
510: IF l_return_status = fnd_api.g_ret_sts_error THEN
511: RAISE fnd_api.g_exc_error;
514: IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
515: RAISE fnd_api.g_exc_unexpected_error;
516: END IF;
517:
518: IF (g_debug <= gme_debug.g_log_statement) THEN
519: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Query tree for ATR next ');
520: END IF;
521: inv_quantity_tree_pvt.query_tree(
522: p_api_version_number => 1.0
515: RAISE fnd_api.g_exc_unexpected_error;
516: END IF;
517:
518: IF (g_debug <= gme_debug.g_log_statement) THEN
519: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Query tree for ATR next ');
520: END IF;
521: inv_quantity_tree_pvt.query_tree(
522: p_api_version_number => 1.0
523: , p_init_msg_lst => fnd_api.g_true
543: , x_satr => l_satr
544: , p_lpn_id => l_lpn_id
545: );
546:
547: IF (g_debug <= gme_debug.g_log_statement) THEN
548: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' After Query tree return status is '||l_return_status);
549: END IF;
550: IF l_return_status = fnd_api.g_ret_sts_error THEN
551: RAISE fnd_api.g_exc_error;
544: , p_lpn_id => l_lpn_id
545: );
546:
547: IF (g_debug <= gme_debug.g_log_statement) THEN
548: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' After Query tree return status is '||l_return_status);
549: END IF;
550: IF l_return_status = fnd_api.g_ret_sts_error THEN
551: RAISE fnd_api.g_exc_error;
552: END IF;
554: IF l_return_status = fnd_api.g_ret_sts_unexp_error THEN
555: RAISE fnd_api.g_exc_unexpected_error;
556: END IF;
557:
558: IF (g_debug <= gme_debug.g_log_statement) THEN
559: gme_debug.put_line('l_atr ' || l_atr);
560: gme_debug.put_line('l_att ' || l_att);
561: gme_debug.put_line('l_qoh ' || l_qoh);
562: gme_debug.put_line('l_rqoh ' || l_rqoh);
555: RAISE fnd_api.g_exc_unexpected_error;
556: END IF;
557:
558: IF (g_debug <= gme_debug.g_log_statement) THEN
559: gme_debug.put_line('l_atr ' || l_atr);
560: gme_debug.put_line('l_att ' || l_att);
561: gme_debug.put_line('l_qoh ' || l_qoh);
562: gme_debug.put_line('l_rqoh ' || l_rqoh);
563: gme_debug.put_line('l_qr ' || l_qr);
556: END IF;
557:
558: IF (g_debug <= gme_debug.g_log_statement) THEN
559: gme_debug.put_line('l_atr ' || l_atr);
560: gme_debug.put_line('l_att ' || l_att);
561: gme_debug.put_line('l_qoh ' || l_qoh);
562: gme_debug.put_line('l_rqoh ' || l_rqoh);
563: gme_debug.put_line('l_qr ' || l_qr);
564: gme_debug.put_line('l_qs ' || l_qs);
557:
558: IF (g_debug <= gme_debug.g_log_statement) THEN
559: gme_debug.put_line('l_atr ' || l_atr);
560: gme_debug.put_line('l_att ' || l_att);
561: gme_debug.put_line('l_qoh ' || l_qoh);
562: gme_debug.put_line('l_rqoh ' || l_rqoh);
563: gme_debug.put_line('l_qr ' || l_qr);
564: gme_debug.put_line('l_qs ' || l_qs);
565: gme_debug.put_line('l_satr ' || l_satr);
558: IF (g_debug <= gme_debug.g_log_statement) THEN
559: gme_debug.put_line('l_atr ' || l_atr);
560: gme_debug.put_line('l_att ' || l_att);
561: gme_debug.put_line('l_qoh ' || l_qoh);
562: gme_debug.put_line('l_rqoh ' || l_rqoh);
563: gme_debug.put_line('l_qr ' || l_qr);
564: gme_debug.put_line('l_qs ' || l_qs);
565: gme_debug.put_line('l_satr ' || l_satr);
566: gme_debug.put_line('l_satt ' || l_satt);
559: gme_debug.put_line('l_atr ' || l_atr);
560: gme_debug.put_line('l_att ' || l_att);
561: gme_debug.put_line('l_qoh ' || l_qoh);
562: gme_debug.put_line('l_rqoh ' || l_rqoh);
563: gme_debug.put_line('l_qr ' || l_qr);
564: gme_debug.put_line('l_qs ' || l_qs);
565: gme_debug.put_line('l_satr ' || l_satr);
566: gme_debug.put_line('l_satt ' || l_satt);
567: gme_debug.put_line('l_sqoh ' || l_sqoh);
560: gme_debug.put_line('l_att ' || l_att);
561: gme_debug.put_line('l_qoh ' || l_qoh);
562: gme_debug.put_line('l_rqoh ' || l_rqoh);
563: gme_debug.put_line('l_qr ' || l_qr);
564: gme_debug.put_line('l_qs ' || l_qs);
565: gme_debug.put_line('l_satr ' || l_satr);
566: gme_debug.put_line('l_satt ' || l_satt);
567: gme_debug.put_line('l_sqoh ' || l_sqoh);
568: gme_debug.put_line('l_srqoh ' || l_srqoh);
561: gme_debug.put_line('l_qoh ' || l_qoh);
562: gme_debug.put_line('l_rqoh ' || l_rqoh);
563: gme_debug.put_line('l_qr ' || l_qr);
564: gme_debug.put_line('l_qs ' || l_qs);
565: gme_debug.put_line('l_satr ' || l_satr);
566: gme_debug.put_line('l_satt ' || l_satt);
567: gme_debug.put_line('l_sqoh ' || l_sqoh);
568: gme_debug.put_line('l_srqoh ' || l_srqoh);
569: gme_debug.put_line('l_sqr ' || l_sqr);
562: gme_debug.put_line('l_rqoh ' || l_rqoh);
563: gme_debug.put_line('l_qr ' || l_qr);
564: gme_debug.put_line('l_qs ' || l_qs);
565: gme_debug.put_line('l_satr ' || l_satr);
566: gme_debug.put_line('l_satt ' || l_satt);
567: gme_debug.put_line('l_sqoh ' || l_sqoh);
568: gme_debug.put_line('l_srqoh ' || l_srqoh);
569: gme_debug.put_line('l_sqr ' || l_sqr);
570: gme_debug.put_line('l_sqs ' || l_sqs);
563: gme_debug.put_line('l_qr ' || l_qr);
564: gme_debug.put_line('l_qs ' || l_qs);
565: gme_debug.put_line('l_satr ' || l_satr);
566: gme_debug.put_line('l_satt ' || l_satt);
567: gme_debug.put_line('l_sqoh ' || l_sqoh);
568: gme_debug.put_line('l_srqoh ' || l_srqoh);
569: gme_debug.put_line('l_sqr ' || l_sqr);
570: gme_debug.put_line('l_sqs ' || l_sqs);
571: END IF;
564: gme_debug.put_line('l_qs ' || l_qs);
565: gme_debug.put_line('l_satr ' || l_satr);
566: gme_debug.put_line('l_satt ' || l_satt);
567: gme_debug.put_line('l_sqoh ' || l_sqoh);
568: gme_debug.put_line('l_srqoh ' || l_srqoh);
569: gme_debug.put_line('l_sqr ' || l_sqr);
570: gme_debug.put_line('l_sqs ' || l_sqs);
571: END IF;
572: /* Deduct any ATR from the manufacture qty */
565: gme_debug.put_line('l_satr ' || l_satr);
566: gme_debug.put_line('l_satt ' || l_satt);
567: gme_debug.put_line('l_sqoh ' || l_sqoh);
568: gme_debug.put_line('l_srqoh ' || l_srqoh);
569: gme_debug.put_line('l_sqr ' || l_sqr);
570: gme_debug.put_line('l_sqs ' || l_sqs);
571: END IF;
572: /* Deduct any ATR from the manufacture qty */
573: /* Convert atr quantity into Orderline UOM */
566: gme_debug.put_line('l_satt ' || l_satt);
567: gme_debug.put_line('l_sqoh ' || l_sqoh);
568: gme_debug.put_line('l_srqoh ' || l_srqoh);
569: gme_debug.put_line('l_sqr ' || l_sqr);
570: gme_debug.put_line('l_sqs ' || l_sqs);
571: END IF;
572: /* Deduct any ATR from the manufacture qty */
573: /* Convert atr quantity into Orderline UOM */
574: IF l_so_line_rec.order_quantity_uom <> l_primary_uom_code THEN
588: * action required */
589: FND_FILE.Put_Line(FND_FILE.LOG,' Stock is available to meet the demand so batch creation not necessary for order '||l_order_no); -- Bug 13359707
590: FND_FILE.Put_Line(FND_FILE.LOG,' Stock is available to meet the demand so batch creation not necessary for order line ' ||l_so_line_no); -- Bug 13359707
591:
592: gme_debug.put_line('Stock is available to meet the demand so batch creation not necessary ');
593: END IF;
594: l_batch_qty := l_batch_qty - l_atr;
595: END IF; -- End of check availability
596:
595: END IF; -- End of check availability
596:
597: FND_FILE.Put_Line(FND_FILE.LOG, 'END of section for MUST check availability ');
598: FND_FILE.Put_Line(FND_FILE.LOG, ' batch qty now stands at '||l_batch_qty );
599: IF (g_debug <= gme_debug.g_log_statement) THEN
600: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' End of availability checking and batch qty now '||l_batch_qty);
601: END IF;
602: /* Now set up data and invoke create_batch
603: ==========================================*/
596:
597: FND_FILE.Put_Line(FND_FILE.LOG, 'END of section for MUST check availability ');
598: FND_FILE.Put_Line(FND_FILE.LOG, ' batch qty now stands at '||l_batch_qty );
599: IF (g_debug <= gme_debug.g_log_statement) THEN
600: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' End of availability checking and batch qty now '||l_batch_qty);
601: END IF;
602: /* Now set up data and invoke create_batch
603: ==========================================*/
604: IF (l_batch_qty <= 0) THEN
601: END IF;
602: /* Now set up data and invoke create_batch
603: ==========================================*/
604: IF (l_batch_qty <= 0) THEN
605: IF (g_debug <= gme_debug.g_log_statement) THEN
606: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Entire requested qty aviaable in inventory so Return now');
607: END IF;
608: RETURN;
609: END IF;
602: /* Now set up data and invoke create_batch
603: ==========================================*/
604: IF (l_batch_qty <= 0) THEN
605: IF (g_debug <= gme_debug.g_log_statement) THEN
606: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Entire requested qty aviaable in inventory so Return now');
607: END IF;
608: RETURN;
609: END IF;
610:
615: END IF;
616:
617: /* Now populate the batch record so you can call Create Batch API */
618:
619: gme_debug.put_line('populate the batch record in readiness for create_batch API');
620: l_batch_header_rec.batch_type := l_mto_rules_rec.batch_type_to_create;
621: l_batch_header_rec.organization_id := l_so_line_rec.ship_from_org_id;
622:
623: -- Bug 12664771 - Do not initialize plan start date.
632: -- Bug 9355688 - Initialize with proper values not hard coded -1.
633: -- l_user_id := FND_GLOBAL.user_id;
634: -- FND_GLOBAL.apps_initialize(l_user_id,-1,-1);
635:
636: IF (g_debug <= gme_debug.g_log_statement) THEN
637: gme_debug.put_line ('before apps init FND_GLOBAL.USER_ID '||FND_GLOBAL.USER_ID);
638: gme_debug.put_line ('before apps init FND_GLOBAL.RESP_ID '||FND_GLOBAL.RESP_ID);
639: gme_debug.put_line ('before apps init FND_GLOBAL.RESP_APPL_ID '||FND_GLOBAL.RESP_APPL_ID);
640: END IF;
633: -- l_user_id := FND_GLOBAL.user_id;
634: -- FND_GLOBAL.apps_initialize(l_user_id,-1,-1);
635:
636: IF (g_debug <= gme_debug.g_log_statement) THEN
637: gme_debug.put_line ('before apps init FND_GLOBAL.USER_ID '||FND_GLOBAL.USER_ID);
638: gme_debug.put_line ('before apps init FND_GLOBAL.RESP_ID '||FND_GLOBAL.RESP_ID);
639: gme_debug.put_line ('before apps init FND_GLOBAL.RESP_APPL_ID '||FND_GLOBAL.RESP_APPL_ID);
640: END IF;
641:
634: -- FND_GLOBAL.apps_initialize(l_user_id,-1,-1);
635:
636: IF (g_debug <= gme_debug.g_log_statement) THEN
637: gme_debug.put_line ('before apps init FND_GLOBAL.USER_ID '||FND_GLOBAL.USER_ID);
638: gme_debug.put_line ('before apps init FND_GLOBAL.RESP_ID '||FND_GLOBAL.RESP_ID);
639: gme_debug.put_line ('before apps init FND_GLOBAL.RESP_APPL_ID '||FND_GLOBAL.RESP_APPL_ID);
640: END IF;
641:
642: l_user_id := FND_GLOBAL.USER_ID;
635:
636: IF (g_debug <= gme_debug.g_log_statement) THEN
637: gme_debug.put_line ('before apps init FND_GLOBAL.USER_ID '||FND_GLOBAL.USER_ID);
638: gme_debug.put_line ('before apps init FND_GLOBAL.RESP_ID '||FND_GLOBAL.RESP_ID);
639: gme_debug.put_line ('before apps init FND_GLOBAL.RESP_APPL_ID '||FND_GLOBAL.RESP_APPL_ID);
640: END IF;
641:
642: l_user_id := FND_GLOBAL.USER_ID;
643: l_resp_id := FND_GLOBAL.RESP_ID;
646: FND_GLOBAL.apps_initialize(user_id => l_user_id,
647: resp_id => l_resp_id,
648: resp_appl_id => l_resp_appl_id);
649:
650: IF (g_debug <= gme_debug.g_log_statement) THEN
651: gme_debug.put_line ('after apps init FND_GLOBAL.USER_ID '||FND_GLOBAL.USER_ID);
652: gme_debug.put_line ('after apps init FND_GLOBAL.RESP_ID '||FND_GLOBAL.RESP_ID);
653: gme_debug.put_line ('after apps init FND_GLOBAL.RESP_APPL_ID '||FND_GLOBAL.RESP_APPL_ID);
654: END IF;
647: resp_id => l_resp_id,
648: resp_appl_id => l_resp_appl_id);
649:
650: IF (g_debug <= gme_debug.g_log_statement) THEN
651: gme_debug.put_line ('after apps init FND_GLOBAL.USER_ID '||FND_GLOBAL.USER_ID);
652: gme_debug.put_line ('after apps init FND_GLOBAL.RESP_ID '||FND_GLOBAL.RESP_ID);
653: gme_debug.put_line ('after apps init FND_GLOBAL.RESP_APPL_ID '||FND_GLOBAL.RESP_APPL_ID);
654: END IF;
655:
648: resp_appl_id => l_resp_appl_id);
649:
650: IF (g_debug <= gme_debug.g_log_statement) THEN
651: gme_debug.put_line ('after apps init FND_GLOBAL.USER_ID '||FND_GLOBAL.USER_ID);
652: gme_debug.put_line ('after apps init FND_GLOBAL.RESP_ID '||FND_GLOBAL.RESP_ID);
653: gme_debug.put_line ('after apps init FND_GLOBAL.RESP_APPL_ID '||FND_GLOBAL.RESP_APPL_ID);
654: END IF;
655:
656: IF l_mto_rules_rec.batch_creation_user is not NULL THEN
649:
650: IF (g_debug <= gme_debug.g_log_statement) THEN
651: gme_debug.put_line ('after apps init FND_GLOBAL.USER_ID '||FND_GLOBAL.USER_ID);
652: gme_debug.put_line ('after apps init FND_GLOBAL.RESP_ID '||FND_GLOBAL.RESP_ID);
653: gme_debug.put_line ('after apps init FND_GLOBAL.RESP_APPL_ID '||FND_GLOBAL.RESP_APPL_ID);
654: END IF;
655:
656: IF l_mto_rules_rec.batch_creation_user is not NULL THEN
657: IF (l_mto_rules_rec.batch_creation_user <> l_user_id) THEN
654: END IF;
655:
656: IF l_mto_rules_rec.batch_creation_user is not NULL THEN
657: IF (l_mto_rules_rec.batch_creation_user <> l_user_id) THEN
658: IF (g_debug <= gme_debug.g_log_statement) THEN
659: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Batch creation user is '||l_mto_rules_rec.batch_creation_user);
660: END IF;
661: -- Bug 9355688 - Initialize with proper values not hard coded -1.
662: -- FND_GLOBAL.apps_initialize(l_mto_rules_rec.batch_creation_user,-1,-1);
655:
656: IF l_mto_rules_rec.batch_creation_user is not NULL THEN
657: IF (l_mto_rules_rec.batch_creation_user <> l_user_id) THEN
658: IF (g_debug <= gme_debug.g_log_statement) THEN
659: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Batch creation user is '||l_mto_rules_rec.batch_creation_user);
660: END IF;
661: -- Bug 9355688 - Initialize with proper values not hard coded -1.
662: -- FND_GLOBAL.apps_initialize(l_mto_rules_rec.batch_creation_user,-1,-1);
663: FND_GLOBAL.apps_initialize(user_id => l_mto_rules_rec.batch_creation_user,
665: resp_appl_id => l_resp_appl_id);
666: END IF;
667: END IF;
668:
669: gme_debug.put_line('Calling Create Batch API');
670: FND_FILE.Put_Line(FND_FILE.LOG, 'call Create Batch/FPO API ');
671: FND_FILE.Put_Line(FND_FILE.LOG, 'Batch/FPO qty needed is '||l_batch_qty);
672: IF (g_debug <= gme_debug.g_log_statement) THEN
673: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Invoke Create_Batch API here');
668:
669: gme_debug.put_line('Calling Create Batch API');
670: FND_FILE.Put_Line(FND_FILE.LOG, 'call Create Batch/FPO API ');
671: FND_FILE.Put_Line(FND_FILE.LOG, 'Batch/FPO qty needed is '||l_batch_qty);
672: IF (g_debug <= gme_debug.g_log_statement) THEN
673: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Invoke Create_Batch API here');
674: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Batch qty required is '||l_batch_qty);
675: gme_debug.put_line ('before create batch FND_GLOBAL.USER_ID '||FND_GLOBAL.USER_ID);
676: gme_debug.put_line ('before create batch FND_GLOBAL.RESP_ID '||FND_GLOBAL.RESP_ID);
669: gme_debug.put_line('Calling Create Batch API');
670: FND_FILE.Put_Line(FND_FILE.LOG, 'call Create Batch/FPO API ');
671: FND_FILE.Put_Line(FND_FILE.LOG, 'Batch/FPO qty needed is '||l_batch_qty);
672: IF (g_debug <= gme_debug.g_log_statement) THEN
673: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Invoke Create_Batch API here');
674: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Batch qty required is '||l_batch_qty);
675: gme_debug.put_line ('before create batch FND_GLOBAL.USER_ID '||FND_GLOBAL.USER_ID);
676: gme_debug.put_line ('before create batch FND_GLOBAL.RESP_ID '||FND_GLOBAL.RESP_ID);
677: gme_debug.put_line ('before create batch FND_GLOBAL.RESP_APPL_ID '||FND_GLOBAL.RESP_APPL_ID);
670: FND_FILE.Put_Line(FND_FILE.LOG, 'call Create Batch/FPO API ');
671: FND_FILE.Put_Line(FND_FILE.LOG, 'Batch/FPO qty needed is '||l_batch_qty);
672: IF (g_debug <= gme_debug.g_log_statement) THEN
673: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Invoke Create_Batch API here');
674: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Batch qty required is '||l_batch_qty);
675: gme_debug.put_line ('before create batch FND_GLOBAL.USER_ID '||FND_GLOBAL.USER_ID);
676: gme_debug.put_line ('before create batch FND_GLOBAL.RESP_ID '||FND_GLOBAL.RESP_ID);
677: gme_debug.put_line ('before create batch FND_GLOBAL.RESP_APPL_ID '||FND_GLOBAL.RESP_APPL_ID);
678: END IF;
671: FND_FILE.Put_Line(FND_FILE.LOG, 'Batch/FPO qty needed is '||l_batch_qty);
672: IF (g_debug <= gme_debug.g_log_statement) THEN
673: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Invoke Create_Batch API here');
674: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Batch qty required is '||l_batch_qty);
675: gme_debug.put_line ('before create batch FND_GLOBAL.USER_ID '||FND_GLOBAL.USER_ID);
676: gme_debug.put_line ('before create batch FND_GLOBAL.RESP_ID '||FND_GLOBAL.RESP_ID);
677: gme_debug.put_line ('before create batch FND_GLOBAL.RESP_APPL_ID '||FND_GLOBAL.RESP_APPL_ID);
678: END IF;
679: GME_API_PUB.create_batch(
672: IF (g_debug <= gme_debug.g_log_statement) THEN
673: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Invoke Create_Batch API here');
674: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Batch qty required is '||l_batch_qty);
675: gme_debug.put_line ('before create batch FND_GLOBAL.USER_ID '||FND_GLOBAL.USER_ID);
676: gme_debug.put_line ('before create batch FND_GLOBAL.RESP_ID '||FND_GLOBAL.RESP_ID);
677: gme_debug.put_line ('before create batch FND_GLOBAL.RESP_APPL_ID '||FND_GLOBAL.RESP_APPL_ID);
678: END IF;
679: GME_API_PUB.create_batch(
680: p_api_version => 2.0,
673: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Invoke Create_Batch API here');
674: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Batch qty required is '||l_batch_qty);
675: gme_debug.put_line ('before create batch FND_GLOBAL.USER_ID '||FND_GLOBAL.USER_ID);
676: gme_debug.put_line ('before create batch FND_GLOBAL.RESP_ID '||FND_GLOBAL.RESP_ID);
677: gme_debug.put_line ('before create batch FND_GLOBAL.RESP_APPL_ID '||FND_GLOBAL.RESP_APPL_ID);
678: END IF;
679: GME_API_PUB.create_batch(
680: p_api_version => 2.0,
681: p_validation_level => 100,
707: FND_FILE.Put_Line(FND_FILE.LOG,' Return Status from Create_Batch API is '||l_return_status); -- Bug 13359707
708: FND_FILE.Put_Line(FND_FILE.LOG,' Message from Create_Batch API is '||l_msg_data); -- Bug 13359707
709:
710:
711: IF (g_debug <= gme_debug.g_log_statement) THEN
712: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Return Status from Create_Batch API is '||l_return_status);
713: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Message from Create_Batch API is '||l_msg_data );
714: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Batch No from Create_Batch API is '||
715: l_out_batch_header_rec.batch_no);
708: FND_FILE.Put_Line(FND_FILE.LOG,' Message from Create_Batch API is '||l_msg_data); -- Bug 13359707
709:
710:
711: IF (g_debug <= gme_debug.g_log_statement) THEN
712: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Return Status from Create_Batch API is '||l_return_status);
713: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Message from Create_Batch API is '||l_msg_data );
714: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Batch No from Create_Batch API is '||
715: l_out_batch_header_rec.batch_no);
716: END IF;
709:
710:
711: IF (g_debug <= gme_debug.g_log_statement) THEN
712: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Return Status from Create_Batch API is '||l_return_status);
713: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Message from Create_Batch API is '||l_msg_data );
714: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Batch No from Create_Batch API is '||
715: l_out_batch_header_rec.batch_no);
716: END IF;
717: /*Bug#8367071 Added the inventory shortage condition here so that the
710:
711: IF (g_debug <= gme_debug.g_log_statement) THEN
712: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Return Status from Create_Batch API is '||l_return_status);
713: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Message from Create_Batch API is '||l_msg_data );
714: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Batch No from Create_Batch API is '||
715: l_out_batch_header_rec.batch_no);
716: END IF;
717: /*Bug#8367071 Added the inventory shortage condition here so that the
718: * code proceeds thorugh the resevation etc even when there is material shortage
723: LOOP
724:
725: l_message := fnd_msg_pub.get(p_encoded => FND_API.G_FALSE);
726: l_message := replace(l_message, chr(0), ' ');
727: gme_debug.put_line(l_message);
728: END LOOP;
729: RAISE fnd_api.g_exc_error;
730: END IF;
731:
730: END IF;
731:
732: /* Now retrieve the batch product line - sales order line must reserve to this supply
733: ===================================================================================*/
734: IF (g_debug <= gme_debug.g_log_statement) THEN
735: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve product line - must reserve to this supply');
736: END IF;
737: OPEN get_batch_line(l_out_batch_header_rec.batch_id,l_so_line_rec.inventory_item_id);
738: FETCH get_batch_line INTO l_material_detail_rec;
731:
732: /* Now retrieve the batch product line - sales order line must reserve to this supply
733: ===================================================================================*/
734: IF (g_debug <= gme_debug.g_log_statement) THEN
735: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve product line - must reserve to this supply');
736: END IF;
737: OPEN get_batch_line(l_out_batch_header_rec.batch_id,l_so_line_rec.inventory_item_id);
738: FETCH get_batch_line INTO l_material_detail_rec;
739:
738: FETCH get_batch_line INTO l_material_detail_rec;
739:
740: IF(get_batch_line%NOTFOUND) THEN
741: CLOSE get_batch_line;
742: IF (g_debug <= gme_debug.g_log_statement) THEN
743: gme_debug.put_line('get_batch_line%NOTFOUND, returning from create_batch_for_order_line');
744: END IF;
745: RAISE fnd_api.g_exc_error;
746: END IF;
739:
740: IF(get_batch_line%NOTFOUND) THEN
741: CLOSE get_batch_line;
742: IF (g_debug <= gme_debug.g_log_statement) THEN
743: gme_debug.put_line('get_batch_line%NOTFOUND, returning from create_batch_for_order_line');
744: END IF;
745: RAISE fnd_api.g_exc_error;
746: END IF;
747: CLOSE get_batch_line;
747: CLOSE get_batch_line;
748:
749: /* Copy Attachments if the rule says so
750: ===================================== */
751: IF (g_debug <= gme_debug.g_log_statement) THEN
752: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' analyse copy attachments '||l_mto_rules_rec.copy_attachments);
753: END IF;
754: IF (NVL(l_mto_rules_rec.copy_attachments,'N') = 'Y') THEN
755: IF (g_debug <= gme_debug.g_log_statement) THEN
748:
749: /* Copy Attachments if the rule says so
750: ===================================== */
751: IF (g_debug <= gme_debug.g_log_statement) THEN
752: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' analyse copy attachments '||l_mto_rules_rec.copy_attachments);
753: END IF;
754: IF (NVL(l_mto_rules_rec.copy_attachments,'N') = 'Y') THEN
755: IF (g_debug <= gme_debug.g_log_statement) THEN
756: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Invoke copy attachments ');
751: IF (g_debug <= gme_debug.g_log_statement) THEN
752: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' analyse copy attachments '||l_mto_rules_rec.copy_attachments);
753: END IF;
754: IF (NVL(l_mto_rules_rec.copy_attachments,'N') = 'Y') THEN
755: IF (g_debug <= gme_debug.g_log_statement) THEN
756: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Invoke copy attachments ');
757: END IF;
758: copy_attachments( p_so_line_id => l_so_line_id
759: , p_so_category_id => l_mto_rules_rec.sales_order_attachment
752: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' analyse copy attachments '||l_mto_rules_rec.copy_attachments);
753: END IF;
754: IF (NVL(l_mto_rules_rec.copy_attachments,'N') = 'Y') THEN
755: IF (g_debug <= gme_debug.g_log_statement) THEN
756: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Invoke copy attachments ');
757: END IF;
758: copy_attachments( p_so_line_id => l_so_line_id
759: , p_so_category_id => l_mto_rules_rec.sales_order_attachment
760: , p_batch_id => l_out_batch_header_rec.batch_id
760: , p_batch_id => l_out_batch_header_rec.batch_id
761: , p_batch_category_id => l_mto_rules_rec.batch_attachment
762: , x_return_status => l_return_status);
763:
764: IF (g_debug <= gme_debug.g_log_statement) THEN
765: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Return Status from copy attachments '||l_return_status);
766: END IF;
767: END IF;
768:
761: , p_batch_category_id => l_mto_rules_rec.batch_attachment
762: , x_return_status => l_return_status);
763:
764: IF (g_debug <= gme_debug.g_log_statement) THEN
765: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Return Status from copy attachments '||l_return_status);
766: END IF;
767: END IF;
768:
769: /* Need to set up pending lots if the product is lot controlled and the rule requires lot generation
767: END IF;
768:
769: /* Need to set up pending lots if the product is lot controlled and the rule requires lot generation
770: =======================================================================================================*/
771: IF (g_debug <= gme_debug.g_log_statement) THEN
772: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' analyse auto lot generation'||l_mto_rules_rec.auto_lot_generation);
773: END IF;
774: IF l_item_rec.SECONDARY_UOM_CODE is not null then
775: l_batch_qty2 := inv_convert.inv_um_convert(l_so_line_rec.inventory_item_id,
768:
769: /* Need to set up pending lots if the product is lot controlled and the rule requires lot generation
770: =======================================================================================================*/
771: IF (g_debug <= gme_debug.g_log_statement) THEN
772: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' analyse auto lot generation'||l_mto_rules_rec.auto_lot_generation);
773: END IF;
774: IF l_item_rec.SECONDARY_UOM_CODE is not null then
775: l_batch_qty2 := inv_convert.inv_um_convert(l_so_line_rec.inventory_item_id,
776: null,
790: l_pending_product_lots_rec.lot_number := null;
791: l_pending_product_lots_rec.quantity := l_batch_qty;
792: l_pending_product_lots_rec.secondary_quantity := l_batch_qty2;
793:
794: IF (g_debug <= gme_debug.g_log_statement) THEN
795: gme_debug.put_line(g_pkg_name||'.'||l_api_name||
796: ' Invoke create_pending_product_lot for line_id '||l_material_detail_rec.material_detail_id);
797: END IF;
798:
791: l_pending_product_lots_rec.quantity := l_batch_qty;
792: l_pending_product_lots_rec.secondary_quantity := l_batch_qty2;
793:
794: IF (g_debug <= gme_debug.g_log_statement) THEN
795: gme_debug.put_line(g_pkg_name||'.'||l_api_name||
796: ' Invoke create_pending_product_lot for line_id '||l_material_detail_rec.material_detail_id);
797: END IF;
798:
799: GME_API_PUB.create_pending_product_lot
817: FND_FILE.Put_Line(FND_FILE.LOG,' After calling GME_API_PUB.create_pending_product_lot for '||l_order_no || 'and line_no ' || l_so_line_no); -- Bug 13359707
818: FND_FILE.Put_Line(FND_FILE.LOG,' Return Status from create_pending_product_lot is '||l_return_status); -- Bug 13359707
819: FND_FILE.Put_Line(FND_FILE.LOG,' FAILURE to generate pending lot'); -- Bug 13359707
820:
821: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' FAILURE to generate pending lot ');
822: END IF;
823: END IF; -- End of pending lot generation
824:
825: gme_debug.put_line('Reserve the batch Quantity to this order line');
821: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' FAILURE to generate pending lot ');
822: END IF;
823: END IF; -- End of pending lot generation
824:
825: gme_debug.put_line('Reserve the batch Quantity to this order line');
826: /* Establish a reservation between the order line (demand) and batch product (supply)
827: ====================================================================================*/
828: FND_FILE.Put_Line(FND_FILE.LOG, ' start of Reservation Processing ');
829: l_rsv_rec:= NULL;
854: l_rsv_rec.supply_source_type_id := inv_reservation_global.g_source_type_wip;
855: l_rsv_rec.supply_source_header_id := l_out_batch_header_rec.batch_id;
856: l_rsv_rec.supply_source_line_id := l_material_detail_rec.material_detail_id;
857:
858: IF (g_debug <= gme_debug.g_log_statement) THEN
859: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Invoke INV_RESERVATION_PUB.Create_Reservation ');
860: END IF;
861:
862: inv_reservation_pub.create_reservation
855: l_rsv_rec.supply_source_header_id := l_out_batch_header_rec.batch_id;
856: l_rsv_rec.supply_source_line_id := l_material_detail_rec.material_detail_id;
857:
858: IF (g_debug <= gme_debug.g_log_statement) THEN
859: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Invoke INV_RESERVATION_PUB.Create_Reservation ');
860: END IF;
861:
862: inv_reservation_pub.create_reservation
863: (p_api_version_number => 1.0
876:
877: FND_FILE.Put_Line(FND_FILE.LOG,' inv_reservation_pub.create_reservation for '||l_order_no || 'and line_no ' || l_so_line_no); -- Bug 13359707
878: FND_FILE.Put_Line(FND_FILE.LOG,' Return Status from inv_reservation_pub.create_reservation is '||l_return_status); -- Bug 13359707
879:
880: IF (g_debug <= gme_debug.g_log_statement) THEN
881: gme_debug.put_line ( g_pkg_name
882: || '.'
883: || l_api_name
884: || ' inv_reservation_pub.create_reservation returns status of '
877: FND_FILE.Put_Line(FND_FILE.LOG,' inv_reservation_pub.create_reservation for '||l_order_no || 'and line_no ' || l_so_line_no); -- Bug 13359707
878: FND_FILE.Put_Line(FND_FILE.LOG,' Return Status from inv_reservation_pub.create_reservation is '||l_return_status); -- Bug 13359707
879:
880: IF (g_debug <= gme_debug.g_log_statement) THEN
881: gme_debug.put_line ( g_pkg_name
882: || '.'
883: || l_api_name
884: || ' inv_reservation_pub.create_reservation returns status of '
885: || l_return_status
897: /* Notify the customer sales representative of the batch creation
898: ===============================================================*/
899: FND_FILE.Put_Line(FND_FILE.LOG,' Calling Notify_CSR for batch_id'||l_rsv_rec.supply_source_header_id); -- Bug 13359707
900:
901: IF (g_debug <= gme_debug.g_log_statement) THEN
902: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Notify_CSR for batch_id'||l_rsv_rec.supply_source_header_id);
903: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Notify_CSR for batch_line_id'||l_rsv_rec.supply_source_line_id);
904: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Notify_CSR for sales_line_id'||l_rsv_rec.demand_source_line_id);
905: END IF;
898: ===============================================================*/
899: FND_FILE.Put_Line(FND_FILE.LOG,' Calling Notify_CSR for batch_id'||l_rsv_rec.supply_source_header_id); -- Bug 13359707
900:
901: IF (g_debug <= gme_debug.g_log_statement) THEN
902: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Notify_CSR for batch_id'||l_rsv_rec.supply_source_header_id);
903: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Notify_CSR for batch_line_id'||l_rsv_rec.supply_source_line_id);
904: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Notify_CSR for sales_line_id'||l_rsv_rec.demand_source_line_id);
905: END IF;
906: --FND_GLOBAL.apps_initialize(l_user_id,-1,-1);
899: FND_FILE.Put_Line(FND_FILE.LOG,' Calling Notify_CSR for batch_id'||l_rsv_rec.supply_source_header_id); -- Bug 13359707
900:
901: IF (g_debug <= gme_debug.g_log_statement) THEN
902: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Notify_CSR for batch_id'||l_rsv_rec.supply_source_header_id);
903: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Notify_CSR for batch_line_id'||l_rsv_rec.supply_source_line_id);
904: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Notify_CSR for sales_line_id'||l_rsv_rec.demand_source_line_id);
905: END IF;
906: --FND_GLOBAL.apps_initialize(l_user_id,-1,-1);
907: GME_SUPPLY_RES_PVT.notify_CSR
900:
901: IF (g_debug <= gme_debug.g_log_statement) THEN
902: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Notify_CSR for batch_id'||l_rsv_rec.supply_source_header_id);
903: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Notify_CSR for batch_line_id'||l_rsv_rec.supply_source_line_id);
904: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Notify_CSR for sales_line_id'||l_rsv_rec.demand_source_line_id);
905: END IF;
906: --FND_GLOBAL.apps_initialize(l_user_id,-1,-1);
907: GME_SUPPLY_RES_PVT.notify_CSR
908: ( P_Batch_id => l_rsv_rec.supply_source_header_id
916: , X_msg_data => l_msg_data );
917:
918: FND_FILE.Put_Line(FND_FILE.LOG,' Return status from GME_SUPPLY_RES_PVT.notify_CSR is '||l_return_status); -- Bug 13359707
919:
920: IF g_debug <= gme_debug.g_log_procedure THEN
921: gme_debug.put_line ( g_pkg_name || '.'
922: || l_api_name
923: || ' after calling notify_CSR for create reservation status is '
924: || l_return_status );
917:
918: FND_FILE.Put_Line(FND_FILE.LOG,' Return status from GME_SUPPLY_RES_PVT.notify_CSR is '||l_return_status); -- Bug 13359707
919:
920: IF g_debug <= gme_debug.g_log_procedure THEN
921: gme_debug.put_line ( g_pkg_name || '.'
922: || l_api_name
923: || ' after calling notify_CSR for create reservation status is '
924: || l_return_status );
925: END IF;
924: || l_return_status );
925: END IF;
926:
927: IF l_return_status IN (fnd_api.g_ret_sts_error, fnd_api.g_ret_sts_unexp_error) THEN
928: IF g_debug <= gme_debug.g_log_procedure THEN
929: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Exit after Notifications Failure ');
930: END IF;
931: RAISE FND_API.G_EXC_ERROR;
932: END IF;
925: END IF;
926:
927: IF l_return_status IN (fnd_api.g_ret_sts_error, fnd_api.g_ret_sts_unexp_error) THEN
928: IF g_debug <= gme_debug.g_log_procedure THEN
929: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Exit after Notifications Failure ');
930: END IF;
931: RAISE FND_API.G_EXC_ERROR;
932: END IF;
933:
945: OPEN Get_order_info(p_so_line_id);
946: FETCH Get_order_info INTO l_so_line_no,l_item_no,
947: l_order_no;
948: IF(Get_order_info%NOTFOUND) THEN
949: IF g_debug <= gme_debug.g_log_procedure THEN
950: gme_debug.put_line(g_pkg_name||'.'||l_api_name ||'Get_order_info%NOTFOUND');
951: END IF;
952: END IF;
953: CLOSE Get_order_info; */
946: FETCH Get_order_info INTO l_so_line_no,l_item_no,
947: l_order_no;
948: IF(Get_order_info%NOTFOUND) THEN
949: IF g_debug <= gme_debug.g_log_procedure THEN
950: gme_debug.put_line(g_pkg_name||'.'||l_api_name ||'Get_order_info%NOTFOUND');
951: END IF;
952: END IF;
953: CLOSE Get_order_info; */
954: FND_FILE.Put_Line(FND_FILE.LOG, '***************************************************************************************** ');
969: ====================*/
970: EXCEPTION
971: WHEN FND_API.G_EXC_ERROR THEN
972: -- ROLLBACK TO SAVEPOINT create_batch_for_so_line_SP;
973: gme_debug.put_line('sqlcode : ' ||to_char(sqlcode));
974: gme_debug.put_line('sqlerr : '|| SUBSTRB(SQLERRM, 1, 150));
975: x_return_status := FND_API.G_RET_STS_ERROR;
976: -- errbuf := SUBSTRB(SQLERRM, 1, 150);
977: -- retcode := x_return_status;
970: EXCEPTION
971: WHEN FND_API.G_EXC_ERROR THEN
972: -- ROLLBACK TO SAVEPOINT create_batch_for_so_line_SP;
973: gme_debug.put_line('sqlcode : ' ||to_char(sqlcode));
974: gme_debug.put_line('sqlerr : '|| SUBSTRB(SQLERRM, 1, 150));
975: x_return_status := FND_API.G_RET_STS_ERROR;
976: -- errbuf := SUBSTRB(SQLERRM, 1, 150);
977: -- retcode := x_return_status;
978:
985: );
986:
987: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
988: -- ROLLBACK TO SAVEPOINT create_batch_for_so_line_SP;
989: gme_debug.put_line('sqlcode : ' ||to_char(sqlcode));
990: gme_debug.put_line('sqlerr : '|| SUBSTRB(SQLERRM, 1, 150));
991:
992: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
993: -- errbuf := SUBSTRB(SQLERRM, 1, 150);
986:
987: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
988: -- ROLLBACK TO SAVEPOINT create_batch_for_so_line_SP;
989: gme_debug.put_line('sqlcode : ' ||to_char(sqlcode));
990: gme_debug.put_line('sqlerr : '|| SUBSTRB(SQLERRM, 1, 150));
991:
992: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
993: -- errbuf := SUBSTRB(SQLERRM, 1, 150);
994: -- retcode := x_return_status;
1002: , p_data => x_msg_data
1003: );
1004: WHEN OTHERS THEN
1005: --ROLLBACK TO SAVEPOINT create_batch_for_so_line_SP;
1006: gme_debug.put_line('sqlcode : ' ||to_char(sqlcode));
1007: gme_debug.put_line('sqlerr : '|| SUBSTRB(SQLERRM, 1, 150));
1008:
1009: FND_MSG_PUB.Add_Exc_Msg ( g_pkg_name
1010: , l_api_name
1003: );
1004: WHEN OTHERS THEN
1005: --ROLLBACK TO SAVEPOINT create_batch_for_so_line_SP;
1006: gme_debug.put_line('sqlcode : ' ||to_char(sqlcode));
1007: gme_debug.put_line('sqlerr : '|| SUBSTRB(SQLERRM, 1, 150));
1008:
1009: FND_MSG_PUB.Add_Exc_Msg ( g_pkg_name
1010: , l_api_name
1011: );
1040: AND ((entity_name = 'OE_ORDER_LINES') AND (pk1_value = p_so_line_id ));
1041:
1042:
1043: BEGIN
1044: gme_debug.put_line('Entering copy_attachemnts routine..');
1045: FOR so_attchments_row IN get_attachments(p_so_category_id,p_so_line_id) LOOP
1046:
1047: so_attchments_row.row_id := NULL;
1048: so_attchments_row.document_id := NULL;
1117: );
1118: x_return_status := FND_API.G_RET_STS_SUCCESS;
1119: END LOOP;
1120:
1121: gme_debug.put_line('Exiting copy_attachments procedure without any errors');
1122: EXCEPTION
1123: WHEN OTHERS THEN
1124: GMI_RESERVATION_UTIL.Println('In others exception in copy_attachments');
1125: x_return_status := FND_API.G_RET_STS_ERROR;
1151: FROM mtl_system_items_b m
1152: WHERE m.inventory_item_id = p_inventory_item_id
1153: AND m.organization_id = p_organization_id;
1154: BEGIN
1155: IF (g_debug <= gme_debug.g_log_statement) THEN
1156: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' ENTER FUNCTION '||l_api_name||' for line '||p_line_id);
1157: gme_debug.put_line ( '*** function call to check if order line qualifies for OPM make to order ***' );
1158: END IF;
1159:
1152: WHERE m.inventory_item_id = p_inventory_item_id
1153: AND m.organization_id = p_organization_id;
1154: BEGIN
1155: IF (g_debug <= gme_debug.g_log_statement) THEN
1156: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' ENTER FUNCTION '||l_api_name||' for line '||p_line_id);
1157: gme_debug.put_line ( '*** function call to check if order line qualifies for OPM make to order ***' );
1158: END IF;
1159:
1160: /* ============== Retrieve Order line data ====================*/
1153: AND m.organization_id = p_organization_id;
1154: BEGIN
1155: IF (g_debug <= gme_debug.g_log_statement) THEN
1156: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' ENTER FUNCTION '||l_api_name||' for line '||p_line_id);
1157: gme_debug.put_line ( '*** function call to check if order line qualifies for OPM make to order ***' );
1158: END IF;
1159:
1160: /* ============== Retrieve Order line data ====================*/
1161: OPEN get_order_line_rec(p_line_id);
1163:
1164:
1165: IF(get_order_line_rec%NOTFOUND) THEN
1166: CLOSE get_order_line_rec;
1167: IF (g_debug <= gme_debug.g_log_statement) THEN
1168: gme_debug.put_line('get_order_line_rec%NOTFOUND, RETURN now');
1169: END IF;
1170: Return FALSE;
1171: END IF;
1164:
1165: IF(get_order_line_rec%NOTFOUND) THEN
1166: CLOSE get_order_line_rec;
1167: IF (g_debug <= gme_debug.g_log_statement) THEN
1168: gme_debug.put_line('get_order_line_rec%NOTFOUND, RETURN now');
1169: END IF;
1170: Return FALSE;
1171: END IF;
1172: CLOSE get_order_line_rec;
1171: END IF;
1172: CLOSE get_order_line_rec;
1173:
1174: /* ============== Establish Item Characteristics ====================*/
1175: IF (g_debug <= gme_debug.g_log_statement) THEN
1176: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve Item for organization_id '||l_order_line_rec.ship_from_org_id);
1177: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve Item for inventory_item_id '||l_order_line_rec.inventory_item_id);
1178: END IF;
1179: OPEN cur_item (l_order_line_rec.ship_from_org_id, l_order_line_rec.inventory_item_id);
1172: CLOSE get_order_line_rec;
1173:
1174: /* ============== Establish Item Characteristics ====================*/
1175: IF (g_debug <= gme_debug.g_log_statement) THEN
1176: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve Item for organization_id '||l_order_line_rec.ship_from_org_id);
1177: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve Item for inventory_item_id '||l_order_line_rec.inventory_item_id);
1178: END IF;
1179: OPEN cur_item (l_order_line_rec.ship_from_org_id, l_order_line_rec.inventory_item_id);
1180: FETCH cur_item INTO l_item_type;
1173:
1174: /* ============== Establish Item Characteristics ====================*/
1175: IF (g_debug <= gme_debug.g_log_statement) THEN
1176: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve Item for organization_id '||l_order_line_rec.ship_from_org_id);
1177: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Retrieve Item for inventory_item_id '||l_order_line_rec.inventory_item_id);
1178: END IF;
1179: OPEN cur_item (l_order_line_rec.ship_from_org_id, l_order_line_rec.inventory_item_id);
1180: FETCH cur_item INTO l_item_type;
1181: IF(cur_item%NOTFOUND) THEN
1179: OPEN cur_item (l_order_line_rec.ship_from_org_id, l_order_line_rec.inventory_item_id);
1180: FETCH cur_item INTO l_item_type;
1181: IF(cur_item%NOTFOUND) THEN
1182: CLOSE cur_item;
1183: IF (g_debug <= gme_debug.g_log_statement) THEN
1184: gme_debug.put_line('Failure to retrieve item; terminate processing');
1185: END IF;
1186: Return FALSE;
1187: END IF;
1180: FETCH cur_item INTO l_item_type;
1181: IF(cur_item%NOTFOUND) THEN
1182: CLOSE cur_item;
1183: IF (g_debug <= gme_debug.g_log_statement) THEN
1184: gme_debug.put_line('Failure to retrieve item; terminate processing');
1185: END IF;
1186: Return FALSE;
1187: END IF;
1188: CLOSE cur_item;
1200: ,x_return_status => l_return_status
1201: ,x_msg_data => l_msg_data
1202: ,x_msg_count => l_msg_count);
1203:
1204: IF (g_debug <= gme_debug.g_log_statement) THEN
1205: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Return status from Retrieve_Rule is '||l_return_status);
1206: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Rule ID to work with is '||l_mto_assignments_rec.rule_id);
1207: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Rule being honored is '||l_mto_rules_rec.rule_name);
1208: END IF;
1201: ,x_msg_data => l_msg_data
1202: ,x_msg_count => l_msg_count);
1203:
1204: IF (g_debug <= gme_debug.g_log_statement) THEN
1205: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Return status from Retrieve_Rule is '||l_return_status);
1206: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Rule ID to work with is '||l_mto_assignments_rec.rule_id);
1207: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Rule being honored is '||l_mto_rules_rec.rule_name);
1208: END IF;
1209:
1202: ,x_msg_count => l_msg_count);
1203:
1204: IF (g_debug <= gme_debug.g_log_statement) THEN
1205: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Return status from Retrieve_Rule is '||l_return_status);
1206: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Rule ID to work with is '||l_mto_assignments_rec.rule_id);
1207: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Rule being honored is '||l_mto_rules_rec.rule_name);
1208: END IF;
1209:
1210: IF( l_return_status <> FND_API.G_RET_STS_SUCCESS ) or (NVL(l_mto_assignments_rec.rule_id,0) = 0) THEN
1203:
1204: IF (g_debug <= gme_debug.g_log_statement) THEN
1205: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Return status from Retrieve_Rule is '||l_return_status);
1206: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Rule ID to work with is '||l_mto_assignments_rec.rule_id);
1207: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' Rule being honored is '||l_mto_rules_rec.rule_name);
1208: END IF;
1209:
1210: IF( l_return_status <> FND_API.G_RET_STS_SUCCESS ) or (NVL(l_mto_assignments_rec.rule_id,0) = 0) THEN
1211: Return FALSE;
1258: From gme_mto_rules
1259: Where rule_id = l_mto_assignments_rec.rule_id;
1260:
1261: BEGIN
1262: IF (g_debug <= gme_debug.g_log_statement) THEN
1263: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' ENTER API ');
1264: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' organization_id '||p_mto_assignments_rec.organization_id);
1265: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' inventory_item_id '||p_mto_assignments_rec.inventory_item_id);
1266: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' item_type '||p_mto_assignments_rec.item_type);
1259: Where rule_id = l_mto_assignments_rec.rule_id;
1260:
1261: BEGIN
1262: IF (g_debug <= gme_debug.g_log_statement) THEN
1263: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' ENTER API ');
1264: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' organization_id '||p_mto_assignments_rec.organization_id);
1265: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' inventory_item_id '||p_mto_assignments_rec.inventory_item_id);
1266: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' item_type '||p_mto_assignments_rec.item_type);
1267: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' customer_id '||p_mto_assignments_rec.customer_id);
1260:
1261: BEGIN
1262: IF (g_debug <= gme_debug.g_log_statement) THEN
1263: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' ENTER API ');
1264: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' organization_id '||p_mto_assignments_rec.organization_id);
1265: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' inventory_item_id '||p_mto_assignments_rec.inventory_item_id);
1266: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' item_type '||p_mto_assignments_rec.item_type);
1267: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' customer_id '||p_mto_assignments_rec.customer_id);
1268: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' site_use_id '||p_mto_assignments_rec.site_use_id);
1261: BEGIN
1262: IF (g_debug <= gme_debug.g_log_statement) THEN
1263: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' ENTER API ');
1264: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' organization_id '||p_mto_assignments_rec.organization_id);
1265: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' inventory_item_id '||p_mto_assignments_rec.inventory_item_id);
1266: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' item_type '||p_mto_assignments_rec.item_type);
1267: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' customer_id '||p_mto_assignments_rec.customer_id);
1268: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' site_use_id '||p_mto_assignments_rec.site_use_id);
1269: END IF;
1262: IF (g_debug <= gme_debug.g_log_statement) THEN
1263: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' ENTER API ');
1264: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' organization_id '||p_mto_assignments_rec.organization_id);
1265: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' inventory_item_id '||p_mto_assignments_rec.inventory_item_id);
1266: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' item_type '||p_mto_assignments_rec.item_type);
1267: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' customer_id '||p_mto_assignments_rec.customer_id);
1268: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' site_use_id '||p_mto_assignments_rec.site_use_id);
1269: END IF;
1270: x_return_status := FND_API.G_RET_STS_SUCCESS;
1263: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' ENTER API ');
1264: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' organization_id '||p_mto_assignments_rec.organization_id);
1265: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' inventory_item_id '||p_mto_assignments_rec.inventory_item_id);
1266: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' item_type '||p_mto_assignments_rec.item_type);
1267: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' customer_id '||p_mto_assignments_rec.customer_id);
1268: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' site_use_id '||p_mto_assignments_rec.site_use_id);
1269: END IF;
1270: x_return_status := FND_API.G_RET_STS_SUCCESS;
1271: /* get the most suitable rule first */
1264: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' organization_id '||p_mto_assignments_rec.organization_id);
1265: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' inventory_item_id '||p_mto_assignments_rec.inventory_item_id);
1266: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' item_type '||p_mto_assignments_rec.item_type);
1267: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' customer_id '||p_mto_assignments_rec.customer_id);
1268: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' site_use_id '||p_mto_assignments_rec.site_use_id);
1269: END IF;
1270: x_return_status := FND_API.G_RET_STS_SUCCESS;
1271: /* get the most suitable rule first */
1272: GMI_reservation_Util.PrintLn('IN check Rule');
1280: , l_mto_assignments_rec.rule_id
1281: , l_mto_assignments_rec.organization_id;
1282: IF(get_assignment%NOTFOUND) THEN
1283: CLOSE get_assignment;
1284: gme_debug.put_line('No rule assigment to match input criteria; returning from Retrieve Rule');
1285: RETURN;
1286: END IF;
1287: Close get_assignment;
1288:
1291: Open get_rule;
1292: Fetch get_rule into l_mto_rules_rec;
1293: IF(get_rule%NOTFOUND) THEN
1294: CLOSE get_rule;
1295: gme_debug.put_line('Error encountered on rule retrieval for Rule ID '||l_mto_assignments_rec.rule_id);
1296: RAISE FND_API.G_EXC_ERROR;
1297: END IF;
1298: Close get_rule;
1299: