82: BEGIN
83: l_count := 0;
84: SELECT count(*)
85: INTO l_count
86: FROM gmf_batch_requirements
87: WHERE batch_id = p_batch_id AND
88: delete_mark = 0;
89:
90: IF l_count > 0 THEN
119: IF g_debug <= gme_debug.g_log_statement THEN
120: gme_debug.put_line ('inserting into req table from gtmp table');
121: END IF;
122:
123: INSERT INTO gmf_batch_requirements(
124: vib_id,
125: batch_id,
126: product_item_id,
127: prod_material_detail_id,
159: last_update_login,
160: requirement_id,
161: organization_id,
162: vib_profile_value
163: FROM gmf_batch_requirements_gtmp
164: WHERE batch_id = p_batch_id;
165:
166: IF g_debug <= gme_debug.g_log_statement THEN
167: gme_debug.put_line (sql%ROWCOUNT || ' rows inserted');
239: END IF;
240:
241: IF (x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
242:
243: UPDATE gmf_batch_requirements
244: SET delete_mark = 1
245: WHERE
246: batch_id = p_batch_id;
247:
249: IF g_debug <= gme_debug.g_log_statement THEN
250: gme_debug.put_line ('inserting into req table from gtmp');
251: END IF;
252:
253: INSERT INTO gmf_batch_requirements(
254: vib_id,
255: batch_id,
256: product_item_id,
257: prod_material_detail_id,
289: last_update_login,
290: requirement_id,
291: organization_id,
292: vib_profile_value
293: FROM gmf_batch_requirements_gtmp;
294:
295: IF g_debug <= gme_debug.g_log_statement THEN
296: gme_debug.put_line (sql%ROWCOUNT || ' rows inserted');
297: END IF;
375: IF g_debug <= gme_debug.g_log_statement THEN
376: gme_debug.put_line ('deleting batch reqs');
377: END IF;
378:
379: UPDATE gmf_batch_requirements
380: SET delete_mark = 1
381: WHERE
382: batch_id = p_batch_id AND
383: delete_mark = 0;
469:
470: CURSOR c_total_prod_alloc (c_batch_id NUMBER) IS
471: SELECT ing_material_detail_id, batchstep_resource_id,
472: SUM(derived_cost_alloc) total_prod_alloc
473: FROM gmf_batch_requirements_gtmp
474: WHERE batch_id = c_batch_id
475: GROUP BY ing_material_detail_id, batchstep_resource_id;
476:
477:
544:
545: gme_debug.put_line ('profiles. step_dep: ' || l_use_item_step_dep || ' vib: ' || l_vib_profile_value);
546:
547: -- Delete the temp table first
548: DELETE from gmf_batch_requirements_gtmp;
549:
550: -- Get all products and step association
551: IF g_debug <= gme_debug.g_log_statement THEN
552: gme_debug.put_line ('Get all products and step association');
565: -- Get all dependant steps for the product step
566: FOR ds IN c_step_dependencies (p_batch_id, p.batchstep_id)
567: LOOP
568: -- insert records into the batch requirements table
569: INSERT INTO gmf_batch_requirements_gtmp(
570: vib_id,
571: batch_id,
572: product_item_id,
573: prod_material_detail_id,
612: WHERE batchstep_id = ds.dep_step_id AND
613: s.material_detail_id = m.material_detail_id AND
614: m.line_type <> 1;
615:
616: INSERT INTO gmf_batch_requirements_gtmp(
617: vib_id,
618: batch_id,
619: product_item_id,
620: prod_material_detail_id,
664: IF g_debug <= gme_debug.g_log_statement THEN
665: gme_debug.put_line ('Now insert any remaining ingredients which was not used for any product...');
666: END IF;
667:
668: INSERT INTO gmf_batch_requirements_gtmp(
669: vib_id,
670: batch_id,
671: product_item_id,
672: prod_material_detail_id,
715: nvl(p.cost_alloc,0) <> 0 AND
716: i.line_type <> 1 AND
717: i.material_detail_id NOT IN (
718: SELECT nvl(ing_material_detail_id, -99)
719: FROM gmf_batch_requirements_gtmp f
720: WHERE
721: batch_id = p_batch_id );
722:
723: IF g_debug <= gme_debug.g_log_statement THEN
726: END IF;
727:
728: /* Bug 13442362 13367279 Added gme_batch_steps and joins so that index on gme_batch_step_resources is used */
729:
730: INSERT INTO gmf_batch_requirements_gtmp(
731: vib_id,
732: batch_id,
733: product_item_id,
734: prod_material_detail_id,
777: decode(p.plan_qty, 0, p.wip_plan_qty, p.plan_qty) <> 0 AND
778: nvl(p.cost_alloc,0) <> 0 AND
779: r.batchstep_resource_id NOT IN (
780: SELECT nvl(batchstep_resource_id, -99)
781: FROM gmf_batch_requirements_gtmp f
782: WHERE
783: batch_id = p_batch_id );
784:
785: IF g_debug <= gme_debug.g_log_statement THEN
790: IF g_debug <= gme_debug.g_log_statement THEN
791: gme_debug.put_line ('Now insert any product that may have been missed out...');
792: END IF;
793:
794: INSERT INTO gmf_batch_requirements_gtmp(
795: vib_id,
796: batch_id,
797: product_item_id,
798: prod_material_detail_id,
841: nvl(p.cost_alloc,0) <> 0 AND
842: i.line_type <> 1 AND
843: p.material_detail_id NOT IN (
844: SELECT prod_material_detail_id
845: FROM gmf_batch_requirements_gtmp f
846: WHERE
847: batch_id = p_batch_id );
848: IF g_debug <= gme_debug.g_log_statement THEN
849: gme_debug.put_line (sql%ROWCOUNT || ' rows inserted');
854: END IF;
855:
856: /* Bug 13442362 13367279 Added gme_batch_steps and joins so that index on gme_batch_step_resources is used */
857:
858: INSERT INTO gmf_batch_requirements_gtmp(
859: vib_id,
860: batch_id,
861: product_item_id,
862: prod_material_detail_id,
905: decode(p.plan_qty, 0, p.wip_plan_qty, p.plan_qty) <> 0 AND
906: nvl(p.cost_alloc,0) <> 0 AND
907: p.material_detail_id NOT IN (
908: SELECT prod_material_detail_id
909: FROM gmf_batch_requirements_gtmp f
910: WHERE
911: batch_id = p_batch_id );
912:
913: IF g_debug <= gme_debug.g_log_statement THEN
921: END IF;
922:
923: FOR i IN c_total_prod_alloc(p_batch_id) LOOP
924: BEGIN
925: UPDATE gmf_batch_requirements_gtmp
926: SET derived_cost_alloc = derived_cost_alloc/i.total_prod_alloc,
927: required_doc_qty = required_doc_qty/i.total_prod_alloc
928: WHERE
929: batch_id = p_batch_id AND
1008: ) IS
1009:
1010: CURSOR c_batch_req IS
1011: SELECT *
1012: FROM gmf_batch_requirements
1013: WHERE
1014: batch_id = p_tran_rec.transaction_source_id AND
1015: prod_material_detail_id = p_tran_rec.trx_source_line_id AND
1016: delete_mark = 0;
1211:
1212: SELECT count (1)
1213: INTO l_count
1214: FROM gmf_batch_vib_details vib,
1215: gmf_batch_requirements r
1216: WHERE
1217: r.batch_id = p_tran_rec.transaction_source_id AND
1218: r.prod_material_detail_id = p_tran_rec.trx_source_line_id AND
1219: vib.requirement_id = r.requirement_id AND
1288:
1289: SELECT count (1)
1290: INTO l_count
1291: FROM gmf_batch_vib_details vib,
1292: gmf_batch_requirements r
1293: WHERE
1294: r.batch_id = p_tran_rec.transaction_source_id AND
1295: r.prod_material_detail_id = p_tran_rec.trx_source_line_id AND
1296: vib.requirement_id = r.requirement_id AND
1436: IF ing.layer_doc_qty <> ing.remaining_ib_doc_qty THEN
1437: SELECT nvl(sum (consume_ib_doc_qty), 0)
1438: INTO l_prev_consume_ib_doc_qty
1439: FROM gmf_batch_vib_details v,
1440: gmf_batch_requirements r
1441: WHERE
1442: r.batch_id = p_tran_rec.transaction_source_id AND
1443: r.prod_material_detail_id = p_tran_rec.trx_source_line_id AND
1444: v.requirement_id = r.requirement_id AND
1455: SELECT nvl(sum (consume_ib_doc_qty), 0)
1456: INTO l_orig_layer_consumption_qty
1457: FROM gmf_outgoing_material_layers ol,
1458: gmf_batch_vib_details v,
1459: gmf_batch_requirements r
1460: WHERE
1461: ol.mmt_transaction_id = ing.reverse_id AND
1462: v.consume_layer_id = ol.layer_id AND
1463: r.batch_id = p_tran_rec.transaction_source_id AND
1587: IF rsrc.layer_doc_qty <> rsrc.remaining_ib_doc_qty THEN
1588: SELECT nvl(sum (consume_ib_doc_qty), 0)
1589: INTO l_prev_consume_ib_doc_qty
1590: FROM gmf_batch_vib_details v,
1591: gmf_batch_requirements r
1592: WHERE
1593: r.batch_id = p_tran_rec.transaction_source_id AND
1594: r.prod_material_detail_id = p_tran_rec.trx_source_line_id AND
1595: v.requirement_id = r.requirement_id AND
1606: SELECT nvl(sum (consume_ib_doc_qty), 0)
1607: INTO l_orig_layer_consumption_qty
1608: FROM gmf_resource_layers rl,
1609: gmf_batch_vib_details v,
1610: gmf_batch_requirements r
1611: WHERE
1612: rl.poc_trans_id = rsrc.reverse_id AND
1613: v.consume_layer_id = rl.layer_id AND
1614: r.batch_id = p_tran_rec.transaction_source_id AND
1862: x_msg_data OUT NOCOPY VARCHAR2) IS
1863:
1864: CURSOR c_batch_req IS
1865: SELECT *
1866: FROM gmf_batch_requirements
1867: WHERE
1868: batch_id = p_batch_id AND
1869: delete_mark = 0
1870: ORDER BY prod_material_detail_id;
1871:
1872: CURSOR c_null_consume_layers IS
1873: SELECT v.*, l.layer_doc_qty, l.layer_doc_um, l.mmt_transaction_id, l.lot_number, l.mmt_organization_id
1874: FROM gmf_batch_vib_details v,
1875: gmf_batch_requirements r,
1876: gmf_incoming_material_layers l
1877: WHERE
1878: r.batch_id = p_batch_id AND
1879: v.requirement_id = r.requirement_id AND
1940: CURSOR c_finalize_layer_consumption IS
1941: SELECT v.consume_layer_id, v.line_type, sum(v.consume_ib_doc_qty) consume_ib_doc_qty
1942: FROM
1943: gmf_batch_vib_details v,
1944: gmf_batch_requirements r
1945: WHERE
1946: r.batch_id = p_batch_id AND
1947: v.requirement_id = r.requirement_id AND
1948: v.finalize_ind = 1 AND
2004: BEGIN
2005: SELECT count(*)
2006: INTO l_count
2007: FROM gmf_batch_vib_details v,
2008: gmf_batch_requirements r
2009: WHERE
2010: r.batch_id = p_batch_id AND
2011: r.requirement_id = v.requirement_id and
2012: v.finalize_ind = 1;
2603: x_msg_data OUT NOCOPY VARCHAR2) IS
2604:
2605: CURSOR c_finalize_rows IS
2606: SELECT v.ROWID, v.consume_ib_doc_qty, v.consume_layer_id, v.line_type
2607: FROM gmf_batch_vib_details v, gmf_batch_requirements r
2608: WHERE
2609: r.batch_id = p_batch_id and
2610: r.requirement_id = v.requirement_id and
2611: v.finalize_ind = 1 and
2762: pseudo_layer_id IS NOT NULL AND
2763: layer_id in (
2764: SELECT prod_layer_id
2765: FROM gmf_batch_vib_details v,
2766: gmf_batch_requirements r
2767: WHERE
2768: r.batch_id = p_batch_id AND
2769: r.requirement_id = v.requirement_id AND
2770: v.finalize_ind = 1);
2785: finalize_ind = 1 and
2786: consume_layer_id IS NULL and
2787: requirement_id in (
2788: SELECT requirement_id
2789: FROM gmf_batch_requirements
2790: WHERE
2791: Batch_id = p_batch_id);
2792:
2793: IF g_debug <= gme_debug.g_log_statement THEN