147:
148: CURSOR c_boms IS
149: select distinct
150: bcolu.ato_line_id ato_line_id
151: from bom_cto_order_lines_upg bcolu
152: where bcolu.sequence = p_seq
153: and bcolu.status = 'BOM_PROC'
154: and bcolu.ato_line_id = bcolu.line_id;
155:
153: and bcolu.status = 'BOM_PROC'
154: and bcolu.ato_line_id = bcolu.line_id;
155:
156: CURSOR c_all_configs(p_ato_line_id number) IS
157: select /*+ INDEX (BCOLU BOM_CTO_ORDER_LINES_UPG_N4) */
158: bcolu.line_id,
159: bcolu.inventory_item_id,
160: bcolu.config_item_id
161: from bom_cto_order_lines_upg bcolu
157: select /*+ INDEX (BCOLU BOM_CTO_ORDER_LINES_UPG_N4) */
158: bcolu.line_id,
159: bcolu.inventory_item_id,
160: bcolu.config_item_id
161: from bom_cto_order_lines_upg bcolu
162: where bcolu.ato_line_id = p_ato_line_id
163: and bcolu.bom_item_type = 1
164: and nvl(bcolu.wip_supply_type,0) <> 6
165: and bcolu.config_item_id is not null
192: --
193: -- select next N ato_line_ids and update status to BOM_PROC
194: --
195: l_stmt_num := 20;
196: update bom_cto_order_lines_upg bcolu
197: set status = 'BOM_PROC'
198: where bcolu.ato_line_id in (select ato_line_id
199: from bom_cto_order_lines_upg bcolu2
200: where bcolu2.ato_line_id = bcolu2.line_id
195: l_stmt_num := 20;
196: update bom_cto_order_lines_upg bcolu
197: set status = 'BOM_PROC'
198: where bcolu.ato_line_id in (select ato_line_id
199: from bom_cto_order_lines_upg bcolu2
200: where bcolu2.ato_line_id = bcolu2.line_id
201: and bcolu2.sequence = p_seq
202: and bcolu2.status = 'CTO_SRC'
203: and rownum < G_SUB_BATCH_SIZE + 1);
218: -- being found for the same config item on a different order line
219: -- Process only if line is not on hold
220: --
221: l_stmt_num := 35;
222: select /*+ INDEX (BOM_CTO_ORDER_LINES_UPG BOM_CTO_ORDER_LINES_UPG_U1) */
223: status
224: into l_bcolu_status
225: from bom_cto_order_lines_upg
226: where ato_line_id = v_boms.ato_line_id
221: l_stmt_num := 35;
222: select /*+ INDEX (BOM_CTO_ORDER_LINES_UPG BOM_CTO_ORDER_LINES_UPG_U1) */
223: status
224: into l_bcolu_status
225: from bom_cto_order_lines_upg
226: where ato_line_id = v_boms.ato_line_id
227: and rownum = 1;
228:
229: WriteToLog('Line is in status :: '||l_bcolu_status, 2);
236: WriteToLog('In v_boms loop, ato_line_id:: '||v_boms.ato_line_id, 4);
237:
238:
239:
240: select /*+ INDEX (BOM_CTO_ORDER_LINES_UPG BOM_CTO_ORDER_LINES_UPG_N4) */
241: status
242: into l_bcolu_status
243: from bom_cto_order_lines_upg
244: where line_id = v_all_configs.line_id ;
239:
240: select /*+ INDEX (BOM_CTO_ORDER_LINES_UPG BOM_CTO_ORDER_LINES_UPG_N4) */
241: status
242: into l_bcolu_status
243: from bom_cto_order_lines_upg
244: where line_id = v_all_configs.line_id ;
245:
246: WriteToLog('Line is in status :: '||l_bcolu_status, 2);
247:
264: -- Here, we want to skip processing for
265: -- the rest of this ato_line_id, but continue
266: -- processing the remaining ato_line_ids.
267: --
268: update /*+ INDEX (BCOLU1 BOM_CTO_ORDER_LINES_UPG_N4) */
269: bom_cto_order_lines_upg bcolu1
270: set bcolu1.status = 'ERROR'
271: where bcolu1.ato_line_id =
272: (select bcolu2.ato_line_id
265: -- the rest of this ato_line_id, but continue
266: -- processing the remaining ato_line_ids.
267: --
268: update /*+ INDEX (BCOLU1 BOM_CTO_ORDER_LINES_UPG_N4) */
269: bom_cto_order_lines_upg bcolu1
270: set bcolu1.status = 'ERROR'
271: where bcolu1.ato_line_id =
272: (select bcolu2.ato_line_id
273: from bom_cto_order_lines_upg bcolu2
269: bom_cto_order_lines_upg bcolu1
270: set bcolu1.status = 'ERROR'
271: where bcolu1.ato_line_id =
272: (select bcolu2.ato_line_id
273: from bom_cto_order_lines_upg bcolu2
274: where bcolu2.line_id = v_all_configs.line_id);
275:
276: WriteToLog('Rows updated to status ERROR::'||sql%rowcount, 1);
277: l_error_flag := 'Y';
305: END IF; /* line on hold */
306: END LOOP;
307:
308: l_stmt_num := 60;
309: update bom_cto_order_lines_upg bcolu
310: set status = 'BOM_LOOP'
311: where sequence = p_seq
312: and status = 'BOM_PROC';
313:
333:
334: --
335: -- Update rows processed to BOM_BULK
336: --
337: update bom_cto_order_lines_upg bcolu
338: set status = 'BOM_BULK'
339: where bcolu.ato_line_id in (select ato_line_id
340: from bom_cto_order_lines_upg bcolu2
341: where bcolu2.sequence = p_seq
336: --
337: update bom_cto_order_lines_upg bcolu
338: set status = 'BOM_BULK'
339: where bcolu.ato_line_id in (select ato_line_id
340: from bom_cto_order_lines_upg bcolu2
341: where bcolu2.sequence = p_seq
342: and bcolu2.status = 'BOM_LOOP');
343:
344: WriteToLog('Rows updated to status BOM_BULK::' ||sql%rowcount, 2);
366: delete from mrp_sr_assignments
367: where assignment_set_id = l_mrp_aset_id
368: and inventory_item_id in
369: (select config_item_id
370: from bom_cto_order_lines_upg
371: where sequence = p_seq
372: and status = 'BOM_BULK'
373: and (p_changed_src = 'Y'
374: or (p_changed_src = 'N' and nvl(config_creation,'1') = '3')));
454: from mrp_sr_assignments ma
455: where ma.assignment_set_id = l_cto_aset_id
456: and ma.inventory_item_id in (
457: select distinct bcolu.config_item_id
458: from bom_cto_order_lines_upg bcolu
459: where bcolu.sequence = p_seq
460: and bcolu.status = 'BOM_BULK');
461:
462: WriteToLog('Rows inserted into MRP Default Assignment Set::' ||sql%rowcount, 2);
463:
464: --
465: -- update status to 'MRP_SRC'
466: --
467: update bom_cto_order_lines_upg
468: set status = 'MRP_SRC'
469: where sequence = p_seq
470: and status = 'BOM_BULK';
471:
560: bcso.create_bom bom_create,
561: bcso.model_item_id,
562: bcso.config_item_id
563: from bom_cto_src_orgs bcso,
564: bom_cto_order_lines_upg bcolu
565: where bcso.line_id = pLineId
566: and bcso.model_item_id = pModelId
567: and bcso.config_item_id is not null
568: and bcso.line_id = bcolu.line_id ;
581: -- Get total lead time for this config based on OE validation org
582: --
583: select nvl(schedule_ship_date,sysdate), nvl(program_id, 0)
584: into g_SchShpDate, l_program_id
585: from bom_cto_order_lines_upg
586: where line_id = pLineId ;
587:
588: g_SchShpDate := greatest(g_SchShpDate, sysdate);
589: WriteToLog('Schedule Ship Date is '||g_SchShpDate, 4);
611: exception
612: when no_data_found then
613: SELECT master_organization_id
614: INTO lOEValidationOrg
615: FROM mtl_parameters mp, bom_cto_order_lines_upg bcol
616: WHERE bcol.ship_from_org_id = mp.organization_id
617: and bcol.line_id = pLineid;
618: end; --Bugfix 6376208: The main query will run into no data found if SO having line_id has been purged.
619:
632: bcolu.inventory_item_id,
633: bcolu.parent_ato_line_id,
634: bcolu.ordered_quantity
635: into lLineId, lModelId, lParentAtoLineId, lOrderedQty
636: from bom_cto_order_lines_upg bcolu
637: where bcolu.line_id = lParentAtoLineId;
638:
639: WriteToLog('lLineId: ' || to_char(lLineId), 5);
640: WriteToLog('lModelId: ' || to_char(lModelId), 5);
851: cursor missed_lines ( xlineid number,
852: xconfigbillid number,
853: xEstRelDate date ) is /* Effectivity_date changes */
854: select line_id
855: from bom_cto_order_lines_upg
856: where parent_ato_line_id=xlineid
857: and parent_ato_line_id <> line_id /* to avoid selecting top model */
858: minus
859: select revised_item_sequence_id /* new column used to store line_id */
956: --where last_update_login=pRtgId;
957: where config_routing_id=pRtgId;
958:
959:
960: v_program_id bom_cto_order_lines_upg.program_id%type;
961:
962: TYPE mod_opclass_rtg_tab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
963:
964:
982: select oel.line_id,
983: oel.header_id header_id,
984: oeh.order_number order_num,
985: to_char(oel.line_number)||'.'||to_char(oel.shipment_number) ||decode(oel.option_number,NULL,NULL,'.'||to_char(oel.option_number)) line_num
986: from bom_cto_order_lines_upg bcolu,
987: oe_order_lines_all oel,
988: oe_order_headers_all oeh
989: where bcolu.config_item_id = pConfigId
990: and nvl(bcolu.program_id, -99) <> 99
1148: select CAL.CALENDAR_DATE
1149: into lEstRelDate
1150: from bom_calendar_dates cal,
1151: mtl_system_items msi,
1152: bom_cto_order_lines_upg bcolu,
1153: mtl_parameters mp
1154: where msi.organization_id = pOrgId
1155: and msi.inventory_item_id = pModelId
1156: and bcolu.line_id = pLineId
1362: , nvl(ic1.basis_type,1), /* LBM project */
1363: cto_msutil_pub.bom_batch_id
1364: from
1365: bom_inventory_components ic1,
1366: bom_cto_order_lines_upg bcol1, -- Option
1367: bom_cto_order_lines_upg bcol2, -- Parent-Model
1368: bom_cto_order_lines_upg bcol3, -- Parent-component
1369: mtl_system_items msi_child , /* 02-14-2005 Sushant */ -- begin bugfix 1653881
1370: mtl_system_items msi_parent /* 02-14-2005 Sushant */ -- begin bugfix 1653881
1363: cto_msutil_pub.bom_batch_id
1364: from
1365: bom_inventory_components ic1,
1366: bom_cto_order_lines_upg bcol1, -- Option
1367: bom_cto_order_lines_upg bcol2, -- Parent-Model
1368: bom_cto_order_lines_upg bcol3, -- Parent-component
1369: mtl_system_items msi_child , /* 02-14-2005 Sushant */ -- begin bugfix 1653881
1370: mtl_system_items msi_parent /* 02-14-2005 Sushant */ -- begin bugfix 1653881
1371: where ic1.bill_sequence_id = (
1364: from
1365: bom_inventory_components ic1,
1366: bom_cto_order_lines_upg bcol1, -- Option
1367: bom_cto_order_lines_upg bcol2, -- Parent-Model
1368: bom_cto_order_lines_upg bcol3, -- Parent-component
1369: mtl_system_items msi_child , /* 02-14-2005 Sushant */ -- begin bugfix 1653881
1370: mtl_system_items msi_parent /* 02-14-2005 Sushant */ -- begin bugfix 1653881
1371: where ic1.bill_sequence_id = (
1372: select common_bill_sequence_id
1604: bcol1.plan_level+1-bcol2.plan_level --plan_level
1605: , nvl(ic1.basis_type,1), /* LBM project */
1606: cto_msutil_pub.bom_batch_id
1607: from
1608: bom_cto_order_lines_upg bcol1, -- component
1609: bom_cto_order_lines_upg bcol2, -- Model
1610: mtl_system_items si1,
1611: mtl_system_items si2,
1612: bom_bill_of_materials b,
1605: , nvl(ic1.basis_type,1), /* LBM project */
1606: cto_msutil_pub.bom_batch_id
1607: from
1608: bom_cto_order_lines_upg bcol1, -- component
1609: bom_cto_order_lines_upg bcol2, -- Model
1610: mtl_system_items si1,
1611: mtl_system_items si2,
1612: bom_bill_of_materials b,
1613: bom_inventory_components ic1
1808: select substrb(msi.concatenated_segments,1,50),
1809: 'Not Available' ,
1810: -1
1811: into v_missed_item,v_missed_line_number,v_order_number
1812: from mtl_system_items_kfv msi, bom_cto_order_lines_upg bcolu
1813: where msi.organization_id = bcolu.ship_from_org_id
1814: and msi.inventory_item_id = bcolu.inventory_item_id
1815: and bcolu.line_id = v_missed_line_id;
1816:
1885: -- Put all open order lines having this config item on hold
1886: --
1887: select nvl(config_creation, '1')
1888: into l_config_creation
1889: from bom_cto_order_lines_upg
1890: where line_id = pLineId;
1891:
1892: WriteToLog('l_config_creation:: '||l_config_creation, 3);
1893:
1980: into l_hold_source_rec.line_id,
1981: l_hold_source_rec.header_id,
1982: l_order_num,
1983: l_line_number
1984: from bom_cto_order_lines_upg bcolu,
1985: oe_order_lines_all oel,
1986: oe_order_headers_all oeh
1987: where bcolu.line_id = pLineId
1988: and bcolu.ato_line_id = oel.ato_line_id /* BUG 3396081 dropped component in lower config */
2086: -- Update status to 'ERROR'
2087: -- Update for all lines having this config if config creation = 3
2088: --
2089: IF l_config_creation = 3 THEN
2090: update bom_cto_order_lines_upg bcolu1
2091: set bcolu1.status = 'ERROR'
2092: where bcolu1.ato_line_id in
2093: (select bcolu2.ato_line_id
2094: from bom_cto_order_lines_upg bcolu2
2090: update bom_cto_order_lines_upg bcolu1
2091: set bcolu1.status = 'ERROR'
2092: where bcolu1.ato_line_id in
2093: (select bcolu2.ato_line_id
2094: from bom_cto_order_lines_upg bcolu2
2095: where config_item_id = pConfigId);
2096:
2097: WriteToLog('Rows updated to status ERROR::'||sql%rowcount, 1);
2098: ELSE
2095: where config_item_id = pConfigId);
2096:
2097: WriteToLog('Rows updated to status ERROR::'||sql%rowcount, 1);
2098: ELSE
2099: update bom_cto_order_lines_upg bcolu1
2100: set bcolu1.status = 'ERROR'
2101: where bcolu1.ato_line_id =
2102: (select bcolu2.ato_line_id
2103: from bom_cto_order_lines_upg bcolu2
2099: update bom_cto_order_lines_upg bcolu1
2100: set bcolu1.status = 'ERROR'
2101: where bcolu1.ato_line_id =
2102: (select bcolu2.ato_line_id
2103: from bom_cto_order_lines_upg bcolu2
2104: where bcolu2.line_id = pLineId);
2105:
2106: WriteToLog('Rows updated to status ERROR::'||sql%rowcount, 1);
2107: END IF;
2249: 0 --plan_level
2250: , 1, -- basis_type /* LBM project */
2251: cto_msutil_pub.bom_batch_id
2252: from
2253: bom_cto_order_lines_upg bcol
2254: where bcol.line_id = pLineId
2255: and bcol.ordered_quantity <> 0
2256: and bcol.inventory_item_id = pModelId;
2257:
2459: nvl(operation_type,1),
2460: os1.routing_sequence_id,
2461: l_batch_id
2462: from
2463: bom_cto_order_lines_upg bcol1,
2464: mtl_system_items si1,
2465: bom_operational_routings or1,
2466: bom_operation_sequences os1
2467: where bcol1.line_id = pLineId
2492: NVL(os1.operation_type,1),
2493: os1.routing_sequence_id,
2494: l_batch_id
2495: from
2496: bom_cto_order_lines_upg bcol1, -- components
2497: bom_cto_order_lines_upg bcol2, -- parent models or option classes
2498: mtl_system_items msi,
2499: bom_inventory_components ic1,
2500: bom_bill_of_materials b1,
2493: os1.routing_sequence_id,
2494: l_batch_id
2495: from
2496: bom_cto_order_lines_upg bcol1, -- components
2497: bom_cto_order_lines_upg bcol2, -- parent models or option classes
2498: mtl_system_items msi,
2499: bom_inventory_components ic1,
2500: bom_bill_of_materials b1,
2501: bom_operational_routings or1,
2884: nvl(os1.operation_type,1),
2885: os1.routing_sequence_id
2886: from
2887: mtl_system_items si1,
2888: bom_cto_order_lines_upg bcol,
2889: bom_operational_routings or1,
2890: bom_operation_sequences os1
2891: where bcol.parent_ato_line_id = pLineId
2892: and si1.organization_id = pOrgId
2913: os1.operation_seq_num,
2914: nvl(os1.operation_type,1),
2915: os1.routing_sequence_id
2916: from
2917: bom_cto_order_lines_upg bcol1, /* components */
2918: bom_cto_order_lines_upg bcol2, /* parents model */
2919: bom_inventory_components ic1,
2920: bom_bill_of_materials b1,
2921: bom_operational_routings or1,
2914: nvl(os1.operation_type,1),
2915: os1.routing_sequence_id
2916: from
2917: bom_cto_order_lines_upg bcol1, /* components */
2918: bom_cto_order_lines_upg bcol2, /* parents model */
2919: bom_inventory_components ic1,
2920: bom_bill_of_materials b1,
2921: bom_operational_routings or1,
2922: bom_operation_sequences os1
2980: mtl_system_items si2,
2981: bom_inventory_components ic1,
2982: bom_bill_of_materials b1,
2983: mtl_system_items si1,
2984: bom_cto_order_lines_upg bcol /* Model or option class */
2985: where bcol.parent_ato_line_id = pLineId
2986: and bcol.component_sequence_id is not null
2987: and bcol.ordered_quantity <> 0
2988: and si1.organization_id = pOrgId
5196: NULL, /* ATTRIBUTE14 */
5197: NULL /* ATTRIBUTE15 */
5198: from bom_operational_routings bor,
5199: mtl_parameters mp,
5200: bom_cto_order_lines_upg bcolu
5201: where bcolu.sequence = p_seq
5202: and bcolu.status = 'BOM_LOOP'
5203: and bcolu.config_item_id = bor.assembly_item_id
5204: and bor.alternate_routing_designator is null
5308: bor.principle_flag
5309: from
5310: bom_operation_sequences osi,
5311: bom_operation_resources bor,
5312: bom_cto_order_lines_upg bcolu,
5313: bom_operational_routings bor1
5314: where bcolu.sequence = p_seq
5315: and bcolu.status = 'BOM_LOOP'
5316: and bcolu.config_item_id = bor1.assembly_item_id
5426: NULL /*program_update_date*/
5427: from
5428: bom_operation_sequences osi,
5429: bom_sub_operation_resources bsor,
5430: bom_cto_order_lines_upg bcolu,
5431: bom_operational_routings bor
5432: where bcolu.sequence = p_seq
5433: and bcolu.status = 'BOM_LOOP'
5434: and bcolu.config_item_id = bor.assembly_item_id
5515: bom_operation_sequences bos2, /* 'to' Ops of model */
5516: bom_operation_sequences bos3, /* 'from' Ops of config */
5517: bom_operation_sequences bos4, /* 'to' Ops of config */
5518: bom_operational_routings brif,
5519: bom_cto_order_lines_upg bcolu
5520: WHERE bon.from_op_seq_id = bos1.operation_sequence_id
5521: AND bon.to_op_seq_id = bos2.operation_sequence_id
5522: AND bos1.routing_sequence_id = bos2.routing_sequence_id
5523: AND bos3.routing_sequence_id = brif.routing_sequence_id
5662: xMessageName out NOCOPY VARCHAR2)
5663: RETURN INTEGER IS
5664:
5665: CURSOR c_incl_items_all_level ( xOrgId mtl_system_items.organization_id%TYPE,
5666: xLineId bom_cto_order_lines_upg.line_id%TYPE,
5667: xConfigBillId bom_inventory_components.bill_sequence_id%TYPE ,
5668: xSchShpdt date,
5669: xEstReldt date ) IS
5670: select bbm.organization_id,
5710: bic.effectivity_date ,
5711: sysdate ) eff_date,
5712: nvl(bic.disable_date,g_futuredate) dis_date, -- 3222932 /* 02-14-2005 Sushant */
5713: nvl(bic.basis_type,1) basis_type
5714: from bom_cto_order_lines_upg bcol1, -- COMPONENT
5715: bom_cto_order_lines_upg bcol2, -- MODEL
5716: mtl_system_items si1,
5717: mtl_system_items si2,
5718: bom_bill_of_materials bbm,
5711: sysdate ) eff_date,
5712: nvl(bic.disable_date,g_futuredate) dis_date, -- 3222932 /* 02-14-2005 Sushant */
5713: nvl(bic.basis_type,1) basis_type
5714: from bom_cto_order_lines_upg bcol1, -- COMPONENT
5715: bom_cto_order_lines_upg bcol2, -- MODEL
5716: mtl_system_items si1,
5717: mtl_system_items si2,
5718: bom_bill_of_materials bbm,
5719: bom_inventory_components bic, -- Components
5919: nvl(ic1.disable_date,g_futuredate),
5920: bcol3.inventory_item_id , /* Bug Fix: 4147224 */
5921: nvl(ic1.basis_type,1)
5922: from bom_inventory_components ic1,
5923: bom_cto_order_lines_upg bcol1,
5924: bom_cto_order_lines_upg bcol2,
5925: bom_cto_order_lines_upg bcol3,
5926: mtl_system_items msi_child,
5927: mtl_system_items msi_parent
5920: bcol3.inventory_item_id , /* Bug Fix: 4147224 */
5921: nvl(ic1.basis_type,1)
5922: from bom_inventory_components ic1,
5923: bom_cto_order_lines_upg bcol1,
5924: bom_cto_order_lines_upg bcol2,
5925: bom_cto_order_lines_upg bcol3,
5926: mtl_system_items msi_child,
5927: mtl_system_items msi_parent
5928: where ic1.bill_sequence_id = (
5921: nvl(ic1.basis_type,1)
5922: from bom_inventory_components ic1,
5923: bom_cto_order_lines_upg bcol1,
5924: bom_cto_order_lines_upg bcol2,
5925: bom_cto_order_lines_upg bcol3,
5926: mtl_system_items msi_child,
5927: mtl_system_items msi_parent
5928: where ic1.bill_sequence_id = (
5929: select common_bill_sequence_id
6119: bic.effectivity_date ,
6120: sysdate ),
6121: nvl(bic.disable_date,g_futuredate) -- 3222932
6122: , nvl(bic.basis_type,1) /* LBM project */
6123: from bom_cto_order_lines_upg bcol,
6124: bom_bill_of_materials bbm,
6125: bom_inventory_components bic
6126: where bcol.line_id = pLineId
6127: and bcol.ordered_quantity <> 0