[Home] [Help]
PACKAGE BODY: APPS.OE_UPG_SO_NEW
Source
1 PACKAGE BODY OE_UPG_SO_NEW as
2 /* $Header: OEXNUSOB.pls 120.4 2007/11/20 13:18:26 amallik ship $ */
3
4
5 G_EXC_INVALID_ORDER_CATEGORY Exception;
6 G_EXC_INVALID_SOURCE_CODE Exception;
7 G_EXC_INVALID_COPY_SOURCE Exception;
8 G_EXC_INVALID_INTERNAL_SOURCE Exception;
9 G_EXC_INVALID_RMA_REFERENCE Exception;
10 G_EXC_INVALID_ORIGSYS_LINEREF Exception;
11 G_EXC_INVALID_SRC_DOC_LINE Exception;
12
13 G_ERROR_MESSAGE Varchar2(240);
14 G_SOURCE_DOCUMENT_ID Number;
15 G_SOURCE_DOCUMENT_TYPE_ID Number;
16 G_ORDER_SOURCE_ID Number;
17 G_ORDER_SOURCE_ID_LINE Number;
18 G_ORIG_SYS_DOCUMENT_REF Varchar2(50);
19 G_OPEN_FLAG VARCHAR2(1);
20
21 G_SHIPPING_INSTRUCTIONS varchar2(240);
22 G_PACKING_INSTRUCTIONS varchar2(240);
23 G_FOB_POINT_CODE varchar2(30);
24 G_OPEN_ATO_MODEL number;
25 --g_list_header_id number := -1; /* Renga */
26
27 Procedure Mark_Order_As_Non_Updatable(p_header_id in number);
28 Procedure Query_And_Set_Price_Attribs(p_line_id in number,
29 p_header_id in number);
30
31 Procedure Upgrade_Price_adjustments
32 ( L_level_flag IN Varchar2)
33 is
34 cursor padj_l is
35 select
36 pa.price_adjustment_id,
37 pa.creation_date,
38 pa.created_by,
39 pa.last_update_date,
40 pa.last_updated_by,
41 pa.last_update_login,
42 pa.program_application_id,
43 pa.program_id,
44 pa.program_update_date,
45 pa.request_id,
46 pa.header_id,
47 pa.discount_id,
48 pa.discount_line_id,
49 pa.automatic_flag,
50 round(pa.percent,38) percent,
51 pa.line_id,
52 pa.context,
53 pa.attribute1,
54 pa.attribute2,
55 pa.attribute3,
56 pa.attribute4,
57 pa.attribute5,
58 pa.attribute6,
59 pa.attribute7,
60 pa.attribute8,
61 pa.attribute9,
62 pa.attribute10,
63 pa.attribute11,
64 pa.attribute12,
65 pa.attribute13,
66 pa.attribute14,
67 pa.attribute15
68 from
69 so_price_adjustments pa
70 where ( pa.line_id = G_OLD_LINE_ID and
71 pa.header_id = G_HEADER_Id and
72 L_level_flag = 'L');
73
74 cursor padj_h is
75 select
76 pa.price_adjustment_id,
77 pa.creation_date,
78 pa.created_by,
79 pa.last_update_date,
80 pa.last_updated_by,
81 pa.last_update_login,
82 pa.program_application_id,
83 pa.program_id,
84 pa.program_update_date,
85 pa.request_id,
86 pa.header_id,
87 pa.discount_id,
88 pa.discount_line_id,
89 pa.automatic_flag,
90 round(pa.percent,38) percent, --fix bug 2854690
91 pa.line_id,
92 pa.context,
93 pa.attribute1,
94 pa.attribute2,
95 pa.attribute3,
96 pa.attribute4,
97 pa.attribute5,
98 pa.attribute6,
99 pa.attribute7,
100 pa.attribute8,
101 pa.attribute9,
102 pa.attribute10,
103 pa.attribute11,
104 pa.attribute12,
105 pa.attribute13,
106 pa.attribute14,
107 pa.attribute15
108 from
109 so_price_adjustments pa
110 where ( pa.header_id = G_header_id and
111 L_level_flag = 'H' and
112 pa.line_id is null );
113
114 mpa padj_l%ROWTYPE; /* alias defined for pa (price adjustments)*/
115 v_price_adjustment_id number;
116 pa_rec QP_Upg_OE_PVT.PRICE_ADJ_REC_TYPE;
117
118
119 --
120 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
121 --
122 begin
123 -- dbms_output.enable(999999999999);
124 if L_level_flag = 'L' then
125 open padj_l;
126 else
127 open padj_h;
128 end if;
129
130 G_ERROR_LOCATION := 1;
131 loop /* start loop for Price adjustments*/
132
133 if L_level_flag = 'L' then
134 fetch padj_l into mpa;
135 exit when padj_l%NOTFOUND;
136 else
137 fetch padj_h into mpa;
138 exit when padj_h%NOTFOUND;
139 end if;
140
141 G_ERROR_LOCATION := 101;
142
143 begin
144 select
145 price_adjustment_id
146 into
147 v_price_adjustment_id
148 from
149 oe_price_adjustments
150 where price_adjustment_id = mpa.price_adjustment_id;
151
152 G_ERROR_LOCATION := 102;
153
154 select
155 oe_price_adjustments_s.nextval
156 into
157 v_price_adjustment_id
158 from dual;
159 G_ERROR_LOCATION := 103;
160 exception
161 when no_data_found then
162 v_price_adjustment_id := mpa.price_adjustment_id;
163 /*
164 when others then
165 null;
166 */
167 /* Should also process ERRORS here */
168 end;
169
170 -- dbms_output.put_line('ins oe_price_adjs');
171
172 G_ERROR_LOCATION := 104;
173
174 /* Added by jefflee 6/21/00 */
175 /*
176 QP_Util.Log_Error(p_id1 => G_OLD_LINE_ID,
177 p_error_type => 'PRICE_ADJUSTMENT-Before call',
178 p_error_desc => mpa.price_adjustment_id ,
179 p_error_module => 'Upg_Price_Adjustments');
180 */
181
182 QP_Upg_OE_PVT.Upg_Price_Adj_OE_to_QP(mpa.discount_id,mpa.discount_line_id,
183 mpa.percent, g_line_rec.list_price,
184 g_line_rec.pricing_context, mpa.line_id, pa_rec);
185 /*
186 QP_Util.Log_Error(p_id1 => pa_rec.list_header_id,
187 p_error_type => 'PRICE_ADJUSTMENT-After call',
188 p_error_desc => pa_rec.list_line_id ,
189 p_error_module => 'Upg_Price_Adjustments');
190 */
191 insert into oe_price_adjustments
192 (
193 price_adjustment_id,
194 creation_date,
195 created_by,
196 last_update_date,
197 last_updated_by,
198 last_update_login,
199 program_application_id,
200 program_id,
201 program_update_date,
202 request_id,
203 header_id,
204 discount_id,
205 discount_line_id,
206 automatic_flag,
207 percent,
208 line_id,
209 context,
210 attribute1,
211 attribute2,
212 attribute3,
213 attribute4,
214 attribute5,
215 attribute6,
216 attribute7,
217 attribute8,
218 attribute9,
219 attribute10,
220 attribute11,
221 attribute12,
222 attribute13,
223 attribute14,
224 attribute15,
225 list_header_id, /* New columns added by jefflee 6/21/00 */
226 list_line_id,
227 list_line_type_code,
228 modified_from,
229 modified_to,
230 update_allowed,
231 updated_flag,
232 applied_flag,
233 operand,
234 arithmetic_operator,
235 adjusted_amount,
236 pricing_phase_id,
237 charge_type_code,
238 charge_subtype_code,
239 pricing_group_sequence,
240 list_line_no,
241 source_system_code,
242 benefit_qty,
243 benefit_uom_code,
244 print_on_invoice_flag,
245 expiration_date,
246 modifier_level_code,
247 price_break_type_code,
248 lock_control
249
250 )
251 values
252 (
253 v_price_adjustment_id,
254 mpa.creation_date,
255 mpa.created_by,
256 mpa.last_update_date,
257 mpa.last_updated_by,
258 mpa.last_update_login,
259 mpa.program_application_id,
260 mpa.program_id,
261 mpa.program_update_date,
262 mpa.request_id,
263 mpa.header_id,
264 mpa.discount_id,
265 mpa.discount_line_id,
266 mpa.automatic_flag,
267 mpa.percent,
268 decode(L_level_flag,'L',G_LINE_ID,null),
269 mpa.context,
270 mpa.attribute1,
271 mpa.attribute2,
272 mpa.attribute3,
273 mpa.attribute4,
274 mpa.attribute5,
275 mpa.attribute6,
276 mpa.attribute7,
277 mpa.attribute8,
278 mpa.attribute9,
279 mpa.attribute10,
280 mpa.attribute11,
281 mpa.attribute12,
282 mpa.attribute13,
283 mpa.attribute14,
284 mpa.attribute15,
285 pa_rec.list_header_id, /* New columns added by jefflee 6/21/00 */
286 pa_rec.list_line_id,
287 pa_rec.list_line_type_code,
288 pa_rec.modified_from,
289 pa_rec.modified_to,
290 pa_rec.update_allowed,
291 --bug 2121206 Begin
292 decode(mpa.automatic_flag,'N','Y',pa_rec.updated_flag),
293 --bug 2121206 End
294 pa_rec.applied_flag,
295 pa_rec.operand,
296 pa_rec.arithmetic_operator,
297 pa_rec.adjusted_amount,
298 pa_rec.pricing_phase_id,
299 pa_rec.charge_type_code,
300 pa_rec.charge_subtype_code,
301 pa_rec.pricing_group_sequence,
302 pa_rec.list_line_no,
303 pa_rec.source_system_code,
304 pa_rec.benefit_qty,
305 pa_rec.benefit_uom_code,
306 pa_rec.print_on_invoice_flag,
307 pa_rec.expiration_date,
308 pa_rec.modifier_level_code,
309 pa_rec.price_break_type_code,
310 1
311 );
312
313 G_ERROR_LOCATION := 105;
314
315 end loop; /* end loop for price adjustments */
316 G_ERROR_LOCATION := 2;
317 if L_level_flag = 'L' then
318 close padj_l;
319 else
320 close padj_h;
321 end if;
322 End upgrade_price_adjustments;
323
324 Procedure Upgrade_Sales_Credits
325 ( L_level_flag IN Varchar2)
326 is
327 cursor sc is
328 select
329 ssc.sales_credit_id,
330 ssc.creation_date,
331 ssc.created_by,
332 ssc.last_update_date,
333 ssc.last_updated_by,
334 ssc.last_update_login,
335 ssc.header_id,
336 ssc.sales_credit_type_id,
337 ssc.salesrep_id,
338 ssc.percent,
339 ssc.line_id,
340 ssc.context,
341 ssc.attribute1,
342 ssc.attribute2,
343 ssc.attribute3,
344 ssc.attribute4,
345 ssc.attribute5,
346 ssc.attribute6,
347 ssc.attribute7,
348 ssc.attribute8,
349 ssc.attribute9,
350 ssc.attribute10,
351 ssc.attribute11,
352 ssc.attribute12,
353 ssc.attribute13,
354 ssc.attribute14,
355 ssc.attribute15,
356 null dw_update_advice_flag,
357 ssc.wh_update_date
358 from
359 so_sales_credits ssc
360 where ( (ssc.line_id = G_OLD_LINE_ID and
361 ssc.header_id = G_header_id and
362 L_level_flag = 'L')
363 or (ssc.header_id = G_header_id and
364 L_level_flag = 'H' and
365 ssc.line_id is null ) );
366
367 mscx sc%ROWTYPE; /* alias defined for sc (sales credits)*/ -- GSCC change
368 v_sales_credit_id number;
369
370 --
371 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
372 --
373 begin
374 -- dbms_output.enable(999999999);
375 open sc;
376 G_ERROR_LOCATION := 3;
377 loop /* start loop for sales credits*/
378
379 fetch sc into mscx;
380 exit when sc%NOTFOUND;
381
382 begin
383 select
384 sales_credit_id
385 into
386 v_sales_credit_id
387 from
388 oe_sales_credits
389 where sales_credit_id = mscx.sales_credit_id;
390
391 select
392 oe_sales_credits_s.nextval
393 into
394 v_sales_credit_id
395 from dual;
396 exception
397 when no_data_found then
398 v_sales_credit_id := mscx.sales_credit_id;
399 when others then
400 null;
401 /* Should also process ERRORS here */
402 end;
403
404 -- dbms_output.put_line('Ins oe_sales_credits');
405 insert into oe_sales_credits
406 (
407 sales_credit_id,
408 creation_date,
409 created_by,
410 last_update_date,
411 last_updated_by,
412 last_update_login,
413 header_id,
414 sales_credit_type_id,
415 salesrep_id,
416 percent,
417 line_id,
418 context,
419 attribute1,
420 attribute2,
421 attribute3,
422 attribute4,
423 attribute5,
424 attribute6,
425 attribute7,
426 attribute8,
427 attribute9,
428 attribute10,
429 attribute11,
430 attribute12,
431 attribute13,
432 attribute14,
433 attribute15,
434 dw_update_advice_flag,
435 wh_update_date,
436 lock_control
437 )
438 values
439 (
440 v_sales_credit_id,
441 mscx.creation_date,
442 mscx.created_by,
443 mscx.last_update_date,
444 mscx.last_updated_by,
445 mscx.last_update_login,
446 mscx.header_id,
447 mscx.sales_credit_type_id,
448 mscx.salesrep_id,
449 mscx.percent,
450 decode(L_level_flag,'L',G_LINE_ID,null),
451 mscx.context,
452 mscx.attribute1,
453 mscx.attribute2,
454 mscx.attribute3,
455 mscx.attribute4,
456 mscx.attribute5,
457 mscx.attribute6,
458 mscx.attribute7,
459 mscx.attribute8,
460 mscx.attribute9,
461 mscx.attribute10,
462 mscx.attribute11,
463 mscx.attribute12,
464 mscx.attribute13,
465 mscx.attribute14,
466 mscx.attribute15,
467 mscx.dw_update_advice_flag,
468 mscx.wh_update_date,
469 1
470 );
471 end loop; /* end loop for Sales credits*/
472 G_ERROR_LOCATION := 4;
473 close sc;
474 End Upgrade_Sales_Credits;
475
476 Procedure Upgrade_Cancellations
477 is
478 cursor can is
479 select
480 soc.header_id,
481 soc.line_id,
482 soc.created_by,
483 soc.creation_date,
484 soc.last_updated_by,
485 soc.last_update_date,
486 soc.last_update_login,
487 soc.program_application_id,
488 soc.program_id,
489 soc.program_update_date,
490 soc.request_id,
491 soc.cancel_code,
492 soc.cancelled_by,
493 soc.cancel_date,
494 soc.cancelled_quantity,
495 soc.cancel_comment,
496 soc.context,
497 soc.attribute1,
498 soc.attribute2,
499 soc.attribute3,
500 soc.attribute4,
501 soc.attribute5,
502 soc.attribute6,
503 soc.attribute7,
504 soc.attribute8,
505 soc.attribute9,
506 soc.attribute10,
507 soc.attribute11,
508 soc.attribute12,
509 soc.attribute13,
510 soc.attribute14,
511 soc.attribute15
512 from
513 so_order_cancellations soc
514 where soc.line_id = G_old_line_id
515 and soc.header_id = G_header_id;
516 v_cancel_comment long;
517 --
518 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
519 --
520 begin
521 -- dbms_output.enable(999999999);
522 G_ERROR_LOCATION := 5;
523 for mcan in can loop
524 G_ERROR_LOCATION := 51;
525 G_canc_rec := NULL;
526 G_ERROR_LOCATION := 52;
527 g_canc_rec.can_header_id := mcan.header_id;
528 g_canc_rec.can_line_id := mcan.line_id;
529 g_canc_rec.can_created_by := mcan.created_by;
530 g_canc_rec.can_creation_date := mcan.creation_date;
531 g_canc_rec.can_last_updated_by := mcan.last_updated_by;
532 g_canc_rec.can_last_update_date := mcan.last_update_date;
533 g_canc_rec.can_last_update_login := mcan.last_update_login;
534 g_canc_rec.can_program_application_id := mcan.program_application_id;
535 g_canc_rec.can_program_id := mcan.program_id;
536 g_canc_rec.can_program_update_date := mcan.program_update_date;
537 g_canc_rec.can_request_id := mcan.request_id;
538 g_canc_rec.can_cancel_code := mcan.cancel_code;
539 g_canc_rec.can_cancelled_by := mcan.cancelled_by;
540 g_canc_rec.can_cancel_date := mcan.cancel_date;
541 g_canc_rec.can_cancelled_quantity := mcan.cancelled_quantity;
542 v_cancel_comment := mcan.cancel_comment;
543 g_canc_rec.can_cancel_comment := v_cancel_comment;
544
545 g_canc_rec.can_cancel_comment:=substrb(g_canc_rec.can_cancel_comment,1,2000);
546
547 g_canc_rec.can_context := mcan.context;
548 g_canc_rec.can_attribute1 := mcan.attribute1;
549 g_canc_rec.can_attribute2 := mcan.attribute2;
550 g_canc_rec.can_attribute3 := mcan.attribute3;
551 g_canc_rec.can_attribute4 := mcan.attribute4;
552 g_canc_rec.can_attribute5 := mcan.attribute5;
553 g_canc_rec.can_attribute6 := mcan.attribute6;
554 g_canc_rec.can_attribute7 := mcan.attribute7;
555 g_canc_rec.can_attribute8 := mcan.attribute8;
556 g_canc_rec.can_attribute9 := mcan.attribute9;
557 g_canc_rec.can_attribute10 := mcan.attribute10;
558 g_canc_rec.can_attribute11 := mcan.attribute11;
559 g_canc_rec.can_attribute12 := mcan.attribute12;
560 g_canc_rec.can_attribute13 := mcan.attribute13;
561 g_canc_rec.can_attribute14 := mcan.attribute14;
562 g_canc_rec.can_attribute15 := mcan.attribute15;
563 -- G_canc_rec := mcan;
564 -- dbms_output.put_line('Ins cancellations');
565 G_ORD_CANC_FLAG := 'Y';
566 OE_UPG_SO_NEW.Upgrade_Insert_Lines_History;
567 G_ORD_CANC_FLAG := 'N';
568 end loop; /* end loop for Cancellations */
569 G_ERROR_LOCATION := 6;
570 End Upgrade_Cancellations;
571
572 Procedure Upgrade_Create_Order_Lines
573 is
574 cursor ol is
575 select
576 sla.line_id,
577 sla.org_id,
578 sla.header_id,
579 sla.line_number,
580 sla.date_requested_current,
581 sla.promise_date,
582 nvl(sld.schedule_date,sla.schedule_date) schedule_date,
583 /*
584 decode(sld.schedule_status_code,
585 NULL, NULL ,
586 nvl(sld.schedule_date,sla.schedule_date)) schedule_date,
587 */
588 nvl(sld.quantity,(nvl(sla.ordered_quantity,0)-nvl(sla.cancelled_quantity,0))) ordered_quantity,
589 decode(sla.ordered_quantity,sla.cancelled_quantity,'Y','N') line_cancel_flag,
590 sla.cancelled_quantity,
591 /*
592 decode(nvl(sld.picking_line_id,0),0,sla.shipped_quantity,
593 sld.shipped_quantity) shipped_quantity,
594 */
595 decode(sla.line_type_code,'RETURN',sla.shipped_quantity,decode(
596 nvl(decode(sla.item_type_code,'SERVICE','N',
597 decode(sla.ato_line_id,null,sld.shippable_flag,
598 decode(sla.item_type_code,'CONFIG',sld.shippable_flag,'N'))),'-'), 'Y',
599 decode(sla.source_type_code,'EXTERNAL',
600 decode(sld.receipt_status_code,'INTERFACED',sld.quantity,null),sld.shipped_quantity),
601 decode((nvl(sla.ordered_quantity,0)- nvl(sla.cancelled_quantity,0)),nvl(sla.shipped_quantity,0),sla.shipped_quantity,
602 null))) shipped_quantity,
603 /*Bug2639916 start */
604 nvl(sld.invoiced_quantity,sla.invoiced_quantity) invoiced_quantity,
605 sld.invoiced_quantity sld_invoiced_quantity,
606 sla.invoiced_quantity sla_invoiced_quantity,
607 sla.parent_line_id sla_parent_line_id,
608 /* Bug2639916 end */
609 sla.tax_exempt_number,
610 sla.tax_exempt_reason_code,
611 nvl(sld.warehouse_id,sla.warehouse_id) warehouse_id,
612 sld.subinventory,
613 sla.ship_to_site_use_id,
614 sla.ship_to_contact_id,
615 decode(G_AUTO_FLAG,'Y',sla.customer_item_id,
616 nvl(sld.customer_item_id,sla.customer_item_id)) customer_item_id,
617 sla.demand_stream_id,
618 sla.customer_dock_code,
619 sla.customer_job,
620 sla.customer_production_line,
621 sla.customer_model_serial_number,
622 sla.project_id,
623 sla.task_id,
624 nvl(sld.inventory_item_id,sla.inventory_item_id) inventory_item_id,
625 sla.inventory_item_id service_inventory_item_id,
626 sla.tax_code,
627 sla.demand_class_code,
628 sla.price_list_id,
629 sla.agreement_id,
630 sla.shipment_priority_code,
631 sla.ship_method_code,
632 sla.invoicing_rule_id,
633 sla.accounting_rule_id,
634 sla.commitment_id,
635 sla.original_system_line_reference,
636 sla.selling_price,
637 sla.list_price,
638 sla.context,
639 sla.attribute1,
640 sla.attribute2,
641 sla.attribute3,
642 sla.attribute4,
643 sla.attribute5,
644 sla.attribute6,
645 sla.attribute7,
646 sla.attribute8,
647 sla.attribute9,
648 sla.attribute10,
649 sla.attribute11,
650 sla.attribute12,
651 sla.attribute13,
652 sla.attribute14,
653 sla.attribute15,
654 slattr.industry_context,
655 slattr.industry_attribute1,
656 slattr.industry_attribute2,
657 slattr.industry_attribute3,
658 slattr.industry_attribute4,
659 slattr.industry_attribute5,
660 slattr.industry_attribute6,
661 slattr.industry_attribute7,
662 slattr.industry_attribute8,
663 slattr.industry_attribute9,
664 slattr.industry_attribute10,
665 slattr.industry_attribute11,
666 slattr.industry_attribute12,
667 slattr.industry_attribute13,
668 slattr.industry_attribute14,
669 slattr.industry_attribute15,
670 slattr.global_attribute_category,
671 slattr.global_attribute1,
672 slattr.global_attribute2,
673 slattr.global_attribute3,
674 slattr.global_attribute4,
675 slattr.global_attribute5,
676 slattr.global_attribute6,
677 slattr.global_attribute7,
678 slattr.global_attribute8,
679 slattr.global_attribute9,
680 slattr.global_attribute10,
681 slattr.global_attribute11,
682 slattr.global_attribute12,
683 slattr.global_attribute13,
684 slattr.global_attribute14,
685 slattr.global_attribute15,
686 slattr.global_attribute16,
687 slattr.global_attribute17,
688 slattr.global_attribute18,
689 slattr.global_attribute19,
690 slattr.global_attribute20,
691 sla.pricing_context,
692 sla.pricing_attribute1,
693 sla.pricing_attribute2,
694 sla.pricing_attribute3,
695 sla.pricing_attribute4,
696 sla.pricing_attribute5,
697 sla.pricing_attribute6,
698 sla.pricing_attribute7,
699 sla.pricing_attribute8,
700 sla.pricing_attribute9,
701 sla.pricing_attribute10,
702 sla.pricing_attribute11,
703 sla.pricing_attribute12,
704 sla.pricing_attribute13,
705 sla.pricing_attribute14,
706 sla.pricing_attribute15,
707 nvl(sla.creation_date,sysdate) creation_date,
708 nvl(sld.created_by,sla.created_by) created_by,
709 nvl(sld.last_update_date,sla.last_update_date) last_update_date,
710 nvl(sld.last_updated_by,sla.last_updated_by) last_updated_by,
711 nvl(sld.last_update_login,sla.last_update_login) last_update_login,
712 sla.program_application_id,
713 sla.program_id,
714 sla.program_update_date,
715 sla.request_id,
716 decode(sla.item_type_code,
717 'MODEL', decode(sla.parent_line_id,
718 NULL,sla.line_id,
719 sla.parent_line_id),
720 'KIT', decode(sla.parent_line_id,
721 NULL,sla.line_id,
722 sla.parent_line_id),
723 sla.parent_line_id) parent_Line_id,
724 sla.link_to_line_id,
725 nvl(sld.component_sequence_id,sla.component_sequence_id) component_sequence_id,
726 nvl(sld.component_code,sla.component_code) component_code,
727 /* Following lines are changed to fix the item type problem(from ontupg53)
728 decode(sla.item_type_code,'STANDARD',
729 decode(sla.option_flag,'Y','OPTION',
730 sla.item_type_code),sla.item_type_code) item_type_code,
731 */
732 decode(sla.item_type_code,
733 'STANDARD', decode(sla.option_flag,
734 'Y','OPTION',
735 sla.item_type_code),
736 'MODEL', decode(sla.parent_line_id,
737 NULL,'MODEL',
738 'CLASS'),
739 sla.item_type_code) item_type_code,
740 nvl(sla.source_type_code,'INTERNAL') source_type_code,
741 sla.transaction_reason_code,
742 nvl(sld.latest_acceptable_date,sla.latest_acceptable_date) latest_acceptable_date,
743 sld.dep_plan_required_flag,
744 decode(sla.item_type_code,'SERVICE',NULL,
745 decode(nvl(sld.schedule_status_code,'0'),'0',NULL,'SCHEDULED')) schedule_status_code,
746 sld.configuration_item_flag,
747 sld.delivery,
748 /* sld.load_seq_number, */
749 ' ' load_seq_number,
750 sla.ship_set_number,
751 sla.option_flag,
752 sla.unit_code,
753 sld.line_detail_id,
754 sla.credit_invoice_line_id,
755 sld.included_item_flag,
756 /* Fix from ontupg39(Rupal)
757 decode(sla.item_type_code,'MODEL',
758 decode(sla.ato_line_id, NULL,
759 decode(ato_flag, 'Y', sla.line_id, sla.ato_line_id), sla.ato_line_id),
760 sla.ato_line_id) ato_line_id,
761 */
762 decode(sla.item_type_code,
763 'MODEL', decode(sla.ato_line_id,
764 NULL, decode(ato_flag,
765 'Y', sla.line_id,
766 sla.ato_line_id),
767 sla.ato_line_id),
768 'STANDARD', decode(sla.ato_line_id,
769 NULL, decode(ato_flag,
770 'Y', sla.line_id,
771 sla.ato_line_id),
772 sla.ato_line_id),
773 sla.ato_line_id) ato_line_id,
774 decode(sla.line_type_code,'RETURN','RETURN','ORDER') line_category_code,
775 sla.planning_priority,
776 decode(sla.return_reference_type_code,'ORDER','ORDER',
777 'PO','PO','INVOICE','INVOICE',sla.return_reference_type_code)
778 return_reference_type_code,
779 sla.line_type_code,
780 sla.return_reference_id,
781 decode(sla.ordered_quantity,
782 sla.cancelled_quantity,'N',nvl(sla.open_flag,'N')) open_flag,
783 sla.ship_model_complete_flag,
784 sla.standard_component_freeze_date,
785 decode(sla.s1,1,'Y','N') booked_flag,
786 decode(nvl(sld.picking_line_id,0),0,'N','Y') shipping_interfaced_flag,
787 decode(sla.s4,6,'Y',NULL) fulfilled_flag,
788 decode(sla.s5,9,'YES',NULL) invoice_interface_status_code,
789 sla.intermediate_ship_to_id,
790 sla.transaction_type_code,
791 sla.transaction_comments,
792 sla.selling_percent,
793 sla.customer_product_id,
794 sla.cp_service_id,
795 nvl(sld.quantity,sla.serviced_quantity) serviced_quantity,
796 sla.service_duration,
797 sla.service_start_date,
798 sla.service_end_date,
799 sla.service_coterminate_flag,
800 sla.service_period_conversion_rate,
801 sla.service_mass_txn_temp_id,
802 sla.service_parent_line_id,
803 sla.list_percent,
804 sla.percent_base_price,
805 sld.picking_line_id,
806 sla.planning_prod_seq_number,
807 sld.actual_departure_date,
808 decode(sla.item_type_code,'SERVICE',NULL,
809 decode(nvl(sld.schedule_status_code,'-'),'-','','Y')) visible_demand_flag,
810 decode(sla.item_type_code,'SERVICE','N',
811 sld.shippable_flag) shippable_flag,
812 sla.component_sort_code sort_order,
813 sla.terms_id
814 from
815 so_lines_all sla,
816 so_line_attributes slattr,
817 oe_upgrade_wsh_iface sld
818 /* so_line_details sld */
819 where
820 sla.line_id = slattr.line_id (+) and
821 sla.header_id = G_header_id and
822 decode(sla.item_type_code,'SERVICE',
823 nvl(sla.service_parent_line_id,0),sla.line_id) = sld.line_id(+) and
824 sla.line_type_code <> 'PARENT' and
825 not exists
826 (select NE.line_id from so_lines_all NE
827 where NE.line_Id = sla.service_parent_line_id
828 and NE.line_type_code = 'PARENT') /* Standalone service not upgraded */
829 order by
830 /* Bug #4681686, reshuffled the order by clause to make sure the at the Lines are pulled by
831 line_id first */
832 sla.line_id,
833 sla.ship_set_number,
834 sld.component_code,
835 sld.line_detail_id;
836
837 mol ol%ROWTYPE; /* alias defined for detail-less lines cursor*/
838
839 v_product_name char(2) := 'JL'; -- GSCC fix
840 v_service_flag varchar2(1);
841 v_system_id number;
842 v_line_id number;
843 v_cancelled_quantity number;
844 v_ship_set_number number;
845 v_shipped_line_id number;
846 v_ins_return_quantity number;
847 v_avl_return_quantity number;
848 v_bal_return_quantity number;
849 v_return_new_line_id number;
850 v_return_new_line_number number;
851 v_return_lctr number;
852 v_return_created_line_id number;
853 v_line_exit_flag number;
854 v_cust_trx_attribute6 number;
855 v_customer_trx_id number;
856 v_received_quantity number;
857 v_actual_ordered_quantity number;
858 r_pto_m_c_k boolean := FALSE;
859 r_upgraded_flag varchar2(1):= null;
860 --to pass this record structure to QP
861 l_qp_upg_line_rec OE_UPG_SO_NEW.LINE_REC_TYPE;
862 --
863 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
864 --
865 begin
866 -- bug fix 1759900
867 G_OPEN_ATO_MODEL := 0;
868
869 -- dbms_output.enable(999999999);
870
871 G_ERROR_LOCATION := 7;
872 v_line_id := 0;
873 g_line_id_change_flag := 'N';
874 g_last_line_number := 0;
875 v_ship_set_number := 0;
876 g_set_id := NULL;
877
878
879 open ol;
880 <<begining_of_lines_loop>>
881 loop /* start loop for Order lines */
882 G_ERROR_LOCATION := 701;
883
884 r_shipment_number := 1;
885 r_ato_model := FALSE;
886 r_pto_m_c_k := FALSE;
887 r_no_config_item := FALSE;
888 r_ato_option := FALSE;
889 r_upgraded_flag := null;
890 r_line_set_id := null;
891 r_inventory_item_id := null;
892 r_uom_code := null;
893 r_warehouse_id := null;
894 v_return_created_line_id := null;
895
896 fetch ol into mol;
897 exit when ol%NOTFOUND;
898
899 /* Services are not split in terms with its parents' details
900 if the Parent's detail
901 is a Included item or a config item (changed on 12/22/99)*/
902
903 if mol.item_type_code = 'SERVICE' and
904 (nvl(mol.included_item_flag,'-') = 'Y'
905 or nvl(mol.configuration_item_flag,'-') = 'Y') then
906 goto begining_of_lines_loop;
907 end if;
908
909 /* g_line_rec := mol; */
910
911 if mol.item_type_code = 'SERVICE' then
912 v_service_flag := 'Y';
913 else
914 v_service_flag := 'N';
915 end if;
916
917 G_OLD_LINE_ID :=mol.line_id;
918
919 g_line_rec.option_number := NULL;
920 g_line_rec.line_id :=mol.line_id;
921 g_line_rec.org_id :=mol.org_id;
922 g_line_rec.header_id :=mol.header_id;
923 g_line_rec.line_number :=mol.line_number;
924 g_line_rec.date_requested_current :=mol.date_requested_current;
925 g_line_rec.promise_date :=mol.promise_date;
926 g_line_rec.schedule_date :=mol.schedule_date;
927 g_line_rec.terms_id :=mol.terms_id;
928
929 if v_service_flag = 'Y' then
930 g_line_rec.ordered_quantity := mol.serviced_quantity;
931 else
932 g_line_rec.ordered_quantity := mol.ordered_quantity;
933 end if;
934
935 if g_line_rec.ordered_quantity = 0 then
936 g_line_rec.ordered_quantity := NULL;
937 end if;
938
939 g_line_rec.cancelled_quantity :=mol.cancelled_quantity;
940 g_line_rec.shipped_quantity :=mol.shipped_quantity;
941
942 if g_line_rec.shipped_quantity = 0 then
943 g_line_rec.shipped_quantity := NULL;
944 end if;
945
946
947 if mol.invoice_interface_status_code = 'YES' then
948 g_line_rec.invoiced_quantity :=mol.ordered_quantity;
949 /*Bug2639916-Added elsif condition */
950 elsif (mol.item_type_code = 'STANDARD' and mol.sla_parent_line_id is NULL and mol.shippable_flag = 'Y') then
951 g_line_rec.invoiced_quantity := mol.sld_invoiced_quantity;
952 else
953 g_line_rec.invoiced_quantity :=mol.invoiced_quantity;
954 end if;
955
956 if g_line_rec.invoiced_quantity = 0 then
957 g_line_rec.invoiced_quantity := NULL;
958 end if;
959
960 g_line_rec.tax_exempt_number :=mol.tax_exempt_number;
961 g_line_rec.tax_exempt_reason_code :=mol.tax_exempt_reason_code;
962 g_line_rec.warehouse_id :=mol.warehouse_id;
963 g_line_rec.subinventory :=mol.subinventory;
964 g_line_rec.ship_to_site_use_id :=mol.ship_to_site_use_id;
965 g_line_rec.ship_to_contact_id :=mol.ship_to_contact_id;
966 g_line_rec.customer_item_id :=mol.customer_item_id;
967 g_line_rec.demand_stream_id :=mol.demand_stream_id;
968 g_line_rec.customer_dock_code :=mol.customer_dock_code;
969 g_line_rec.customer_job :=mol.customer_job;
970 g_line_rec.customer_production_line :=mol.customer_production_line;
971 g_line_rec.customer_model_serial_number :=mol.customer_model_serial_number;
972 g_line_rec.project_id :=mol.project_id;
973 g_line_rec.task_id :=mol.task_id;
974 /* from ontupg73 */
975 if nvl(mol.item_type_code,'-') = 'SERVICE' then
976 g_line_rec.inventory_item_id :=mol.service_inventory_item_id;
977 else
978 g_line_rec.inventory_item_id :=mol.inventory_item_id;
979 end if;
980
981 g_line_rec.tax_code :=mol.tax_code;
982 g_line_rec.demand_class_code :=mol.demand_class_code;
983 g_line_rec.price_list_id :=mol.price_list_id;
984 g_line_rec.agreement_id :=mol.agreement_id;
985 g_line_rec.shipment_priority_code :=mol.shipment_priority_code;
986 g_line_rec.ship_method_code :=mol.ship_method_code;
987 g_line_rec.commitment_id :=mol.commitment_id;
988
989 g_line_rec.original_system_line_reference :=mol.original_system_line_reference;
990 g_line_rec.selling_price :=mol.selling_price;
991 g_line_rec.list_price :=mol.list_price;
992 g_line_rec.context :=mol.context;
993 g_line_rec.attribute1 :=mol.attribute1;
994 g_line_rec.attribute2 :=mol.attribute2;
995 g_line_rec.attribute3 :=mol.attribute3;
996 g_line_rec.attribute4 :=mol.attribute4;
997 g_line_rec.attribute5 :=mol.attribute5;
998 g_line_rec.attribute6 :=mol.attribute6;
999 g_line_rec.attribute7 :=mol.attribute7;
1000 g_line_rec.attribute8 :=mol.attribute8;
1001 g_line_rec.attribute9 :=mol.attribute9;
1002 g_line_rec.attribute10 :=mol.attribute10;
1003 g_line_rec.attribute11 :=mol.attribute11;
1004 g_line_rec.attribute12 :=mol.attribute12;
1005 g_line_rec.attribute13 :=mol.attribute13;
1006 g_line_rec.attribute14 :=mol.attribute14;
1007 g_line_rec.attribute15 :=mol.attribute15;
1008 g_line_rec.industry_context :=mol.industry_context;
1009 g_line_rec.industry_attribute1 :=mol.industry_attribute1;
1010 g_line_rec.industry_attribute2 :=mol.industry_attribute2;
1011 g_line_rec.industry_attribute3 :=mol.industry_attribute3;
1012 g_line_rec.industry_attribute4 :=mol.industry_attribute4;
1013 g_line_rec.industry_attribute5 :=mol.industry_attribute5;
1014 g_line_rec.industry_attribute6 :=mol.industry_attribute6;
1015 g_line_rec.industry_attribute7 :=mol.industry_attribute7;
1016 g_line_rec.industry_attribute8 :=mol.industry_attribute8;
1017 g_line_rec.industry_attribute9 :=mol.industry_attribute9;
1018 g_line_rec.industry_attribute10 :=mol.industry_attribute10;
1019 g_line_rec.industry_attribute11 :=mol.industry_attribute11;
1020 g_line_rec.industry_attribute12 :=mol.industry_attribute12;
1021 g_line_rec.industry_attribute13 :=mol.industry_attribute13;
1022 g_line_rec.industry_attribute14 :=mol.industry_attribute14;
1023 g_line_rec.industry_attribute15 :=mol.industry_attribute15;
1024 G_ERROR_LOCATION := 702;
1025
1026 if substr(mol.global_attribute_category,1,5) in (v_product_name||'.BR', v_product_name||'.AR', v_product_name||'.CO') then
1027 g_line_rec.global_attribute_category :=
1028 substr(mol.global_attribute_category,1,5)||'.OEXOEORD.LINES';
1029 else
1030 g_line_rec.global_attribute_category := mol.global_attribute_category;
1031 end if;
1032
1033 G_ERROR_LOCATION := 7021;
1034
1035 g_line_rec.global_attribute1 :=mol.global_attribute1;
1036 g_line_rec.global_attribute2 :=mol.global_attribute2;
1037 g_line_rec.global_attribute3 :=mol.global_attribute3;
1038 g_line_rec.global_attribute4 :=mol.global_attribute4;
1039 g_line_rec.global_attribute5 :=mol.global_attribute5;
1040 g_line_rec.global_attribute6 :=mol.global_attribute6;
1041 g_line_rec.global_attribute7 :=mol.global_attribute7;
1042 g_line_rec.global_attribute8 :=mol.global_attribute8;
1043 g_line_rec.global_attribute9 :=mol.global_attribute9;
1044 g_line_rec.global_attribute10 :=mol.global_attribute10;
1045 g_line_rec.global_attribute11 :=mol.global_attribute11;
1046 g_line_rec.global_attribute12 :=mol.global_attribute12;
1047 g_line_rec.global_attribute13 :=mol.global_attribute13;
1048 g_line_rec.global_attribute14 :=mol.global_attribute14;
1049 g_line_rec.global_attribute15 :=mol.global_attribute15;
1050 g_line_rec.global_attribute16 :=mol.global_attribute16;
1051 g_line_rec.global_attribute17 :=mol.global_attribute17;
1052 g_line_rec.global_attribute18 :=mol.global_attribute18;
1053 g_line_rec.global_attribute19 :=mol.global_attribute19;
1054 g_line_rec.global_attribute20 :=mol.global_attribute20;
1055 g_line_rec.pricing_context :=mol.pricing_context;
1056 g_line_rec.pricing_attribute1 :=mol.pricing_attribute1;
1057 g_line_rec.pricing_attribute2 :=mol.pricing_attribute2;
1058 g_line_rec.pricing_attribute3 :=mol.pricing_attribute3;
1059 g_line_rec.pricing_attribute4 :=mol.pricing_attribute4;
1060 g_line_rec.pricing_attribute5 :=mol.pricing_attribute5;
1061 g_line_rec.pricing_attribute6 :=mol.pricing_attribute6;
1062 g_line_rec.pricing_attribute7 :=mol.pricing_attribute7;
1063 g_line_rec.pricing_attribute8 :=mol.pricing_attribute8;
1064 g_line_rec.pricing_attribute9 :=mol.pricing_attribute9;
1065 g_line_rec.pricing_attribute10 :=mol.pricing_attribute10;
1066 g_line_rec.pricing_attribute11 :=mol.pricing_attribute11;
1067 g_line_rec.pricing_attribute12 :=mol.pricing_attribute12;
1068 g_line_rec.pricing_attribute13 :=mol.pricing_attribute13;
1069 g_line_rec.pricing_attribute14 :=mol.pricing_attribute14;
1070 g_line_rec.pricing_attribute15 :=mol.pricing_attribute15;
1071 g_line_rec.creation_date :=mol.creation_date;
1072 g_line_rec.created_by :=mol.created_by;
1073 g_line_rec.last_update_date :=mol.last_update_date;
1074 g_line_rec.last_updated_by :=mol.last_updated_by;
1075 g_line_rec.last_update_login :=mol.last_update_login;
1076 g_line_rec.program_application_id :=mol.program_application_id;
1077 g_line_rec.program_id :=mol.program_id;
1078 g_line_rec.program_update_date :=mol.program_update_date;
1079 g_line_rec.request_id :=mol.request_id;
1080
1081 G_ERROR_LOCATION := 7022;
1082
1083 g_line_rec.parent_line_id :=mol.parent_line_id;
1084 g_line_rec.link_to_line_id :=mol.link_to_line_id;
1085 g_line_rec.component_sequence_id :=mol.component_sequence_id;
1086 g_line_rec.component_code :=mol.component_code;
1087 g_line_rec.item_type_code :=mol.item_type_code;
1088 g_line_rec.source_type_code :=mol.source_type_code;
1089 g_line_rec.transaction_reason_code :=mol.transaction_reason_code;
1090 g_line_rec.latest_acceptable_date :=mol.latest_acceptable_date;
1091 g_line_rec.dep_plan_required_flag :=mol.dep_plan_required_flag;
1092 g_line_rec.schedule_status_code :=mol.schedule_status_code;
1093 g_line_rec.configuration_item_flag :=mol.configuration_item_flag;
1094 g_line_rec.ship_set_number :=mol.ship_set_number;
1095 g_line_rec.option_flag :=mol.option_flag;
1096 g_line_rec.unit_code :=mol.unit_code;
1097 g_line_rec.line_detail_id :=mol.line_detail_id;
1098 g_line_rec.credit_invoice_line_id :=mol.credit_invoice_line_id;
1099 g_line_rec.included_item_flag :=mol.included_item_flag;
1100 g_line_rec.ato_line_id :=mol.ato_line_id;
1101 g_line_rec.line_category_code :=mol.line_category_code;
1102 g_line_rec.planning_priority :=mol.planning_priority;
1103 g_line_rec.return_reference_type_code :=mol.return_reference_type_code;
1104 g_line_rec.line_type_code :=mol.line_type_code;
1105 g_line_rec.return_reference_id :=mol.return_reference_id;
1106 g_line_rec.open_flag :=mol.open_flag;
1107 g_line_rec.ship_model_complete_flag :=mol.ship_model_complete_flag;
1108 g_line_rec.standard_component_freeze_date :=mol.standard_component_freeze_date;
1109
1110 G_ERROR_LOCATION := 7023;
1111
1112 g_line_rec.booked_flag :=mol.booked_flag;
1113 g_line_rec.shipping_interfaced_flag :=mol.shipping_interfaced_flag;
1114
1115 IF g_line_rec.line_type_code = 'RETURN' THEN
1116 if nvl(mol.shipped_quantity,0)
1117 >= nvl(mol.ordered_quantity,0) then
1118 g_line_rec.fulfilled_flag := 'Y';
1119 else
1120 g_line_rec.fulfilled_flag := NULL;
1121 end if;
1122
1123 ELSE
1124
1125 if nvl(mol.shipped_quantity,0) > 0 then
1126 g_line_rec.fulfilled_flag := 'Y';
1127 else
1128 g_line_rec.fulfilled_flag := NULL;
1129 end if;
1130 END IF;
1131
1132
1133 g_line_rec.invoice_interface_status_code :=mol.invoice_interface_status_code;
1134 g_line_rec.intermediate_ship_to_id :=mol.intermediate_ship_to_id;
1135 g_line_rec.transaction_type_code :=mol.transaction_type_code;
1136 g_line_rec.transaction_comments :=mol.transaction_comments;
1137 g_line_rec.selling_percent :=mol.selling_percent;
1138 g_line_rec.customer_product_id :=mol.customer_product_id;
1139 g_line_rec.cp_service_id :=mol.cp_service_id;
1140 g_line_rec.serviced_quantity :=mol.serviced_quantity;
1141 g_line_rec.service_duration :=mol.service_duration;
1142 g_line_rec.service_start_date :=mol.service_start_date;
1143 g_line_rec.service_end_date :=mol.service_end_date;
1144 g_line_rec.service_coterminate_flag :=mol.service_coterminate_flag;
1145 g_line_rec.service_period_conversion_rate :=mol.service_period_conversion_rate;
1146 g_line_rec.service_mass_txn_temp_id :=mol.service_mass_txn_temp_id;
1147 g_line_rec.service_parent_line_id :=mol.service_parent_line_id;
1148 -- g_line_rec.service_period :=NULL; Bug4193589
1149 g_line_rec.list_percent :=mol.list_percent;
1150 g_line_rec.percent_base_price :=mol.percent_base_price;
1151 g_line_rec.picking_line_id :=mol.picking_line_id;
1152
1153 G_ERROR_LOCATION := 7024;
1154
1155 g_line_rec.planning_prod_seq_number :=mol.planning_prod_seq_number;
1156 g_line_rec.actual_departure_date :=mol.actual_departure_date;
1157 g_line_rec.re_source_flag :='N';
1158 g_line_rec.tp_context :=null;
1159 g_line_rec.tp_attribute1 :=null;
1160 g_line_rec.tp_attribute2 :=null;
1161 g_line_rec.tp_attribute3 :=null;
1162 g_line_rec.tp_attribute4 :=null;
1163 g_line_rec.tp_attribute5 :=null;
1164 g_line_rec.tp_attribute6 :=null;
1165 g_line_rec.tp_attribute7 :=null;
1166 g_line_rec.tp_attribute8 :=null;
1167 g_line_rec.tp_attribute9 :=null;
1168 g_line_rec.tp_attribute10 :=null;
1169 g_line_rec.tp_attribute11 :=null;
1170 g_line_rec.tp_attribute12 :=null;
1171 g_line_rec.tp_attribute13 :=null;
1172 g_line_rec.tp_attribute14 :=null;
1173 g_line_rec.tp_attribute15 :=null;
1174
1175 g_line_rec.fulfilled_quantity :=mol.shipped_quantity;
1176 if g_line_rec.fulfilled_quantity = 0 then
1177 g_line_rec.fulfilled_quantity := NULL;
1178
1179 end if;
1180
1181 G_ERROR_LOCATION := 7025;
1182
1183 g_line_rec.marketing_source_code_id :=null;
1184
1185 -- modified by linda
1186 -- set the flag to N for system initiated split lines
1187 IF NVL(g_order_source_id, 0) = 10 THEN
1188 g_line_rec.calculate_price_flag :='N';
1189 ELSE
1190 g_line_rec.calculate_price_flag :='Y';
1191 END IF;
1192
1193 G_ERROR_LOCATION := 7026;
1194
1195 g_line_rec.fulfillment_method_code :=null;
1196
1197 G_ERROR_LOCATION := 7027;
1198
1199 g_line_rec.revenue_amount :=null;
1200
1201 if nvl(g_line_rec.shipped_quantity,0) > 0 then
1202 g_line_rec.shipping_quantity_uom :=mol.unit_code;
1203 g_line_rec.fulfillment_date :=mol.actual_departure_date;
1204 else
1205 g_line_rec.fulfillment_date :=null;
1206 g_line_rec.shipping_quantity_uom :=null;
1207 end if;
1208
1209 G_ERROR_LOCATION := 7028;
1210
1211 g_line_rec.visible_demand_flag :=mol.visible_demand_flag;
1212 g_line_rec.flow_status_code :=null;
1213
1214 IF mol.sort_order is not null THEN
1215 IF instr(mol.sort_order,'1') = 3 THEN
1216 g_line_rec.sort_order :=
1217 OE_TEMP_ADD_ZERO.oe_add_zero(mol.sort_order);
1218 ELSE
1219 g_line_rec.sort_order := mol.sort_order;
1220 END IF;
1221 ELSE
1222 g_line_rec.sort_order := mol.sort_order;
1223 END IF;
1224
1225 G_ERROR_LOCATION := 703;
1226
1227 -- if G_CANCELLED_FLAG = 'Y' or (mol.ordered_quantity = mol.cancelled_quantity and mol.line_cancel_flag = 'Y') then
1228 if G_CANCELLED_FLAG = 'Y' or mol.ordered_quantity = 0 then
1229 g_line_rec.cancelled_flag :='Y';
1230 g_line_rec.flow_status_code :='CANCELLED';
1231 else
1232
1233 /* Following line replaced from script ontupg74
1234 g_line_rec.cancelled_flag :=NULL; */
1235
1236 g_line_rec.cancelled_flag := 'N';
1237
1238 if mol.open_flag = 'N' then
1239 g_line_rec.flow_status_code :='CLOSED';
1240 elsif mol.booked_Flag = 'N' then
1241 g_line_rec.flow_status_code :='ENTERED';
1242 elsif mol.booked_Flag = 'Y' then
1243 g_line_rec.flow_status_code :='BOOKED';
1244 else
1245 g_line_rec.flow_status_code :=NULL;
1246 end if;
1247 end if;
1248
1249 if v_service_flag = 'Y' then
1250 g_line_rec.service_txn_reason_code := mol.transaction_reason_code;
1251 g_line_rec.service_txn_comments := mol.transaction_comments;
1252 g_line_rec.service_number := mol.line_number;
1253 g_line_rec.service_period :=mol.unit_code; --Bug 4193589
1254 -- Fix made for Bug-1894965
1255 if mol.customer_product_id is NOT NULL then
1256
1257 g_line_rec.service_reference_type_Code := 'CUSTOMER_PRODUCT';
1258 g_line_rec.service_reference_line_id := mol.customer_product_id;
1259 else
1260 g_line_rec.service_reference_type_Code := 'ORDER';
1261 g_line_rec.service_reference_line_id := mol.service_parent_line_id;
1262
1263 end if;
1264
1265 -- Fix made for Bug-1894965
1266
1267 v_system_id := NULL;
1268
1269 select max(system_id) into v_system_id from so_line_service_details
1270 where line_id = mol.line_id;
1271
1272 g_line_rec.service_reference_system_id :=v_system_id;
1273 else
1274 g_line_rec.service_txn_reason_code := NULL;
1275 g_line_rec.service_txn_comments := NULL;
1276 g_line_rec.service_number := NULL;
1277 g_line_rec.service_reference_type_Code :=NULL;
1278 g_line_rec.service_reference_line_id :=NULL;
1279 g_line_rec.service_reference_system_id :=NULL;
1280 g_line_rec.service_period :=NULL; --Bug 4193589
1281 end if;
1282
1283 if (nvl(v_ship_set_number,0) <> nvl(mol.ship_set_number,0)
1284 and mol.ship_set_number is not NULL
1285 and mol.schedule_date is not NULL
1286 and mol.warehouse_id is not NULL
1287 and mol.schedule_status_code is NOT NULL
1288 and mol.ship_to_site_use_id is not NULL) then
1289 /*
1290 and mol.shipment_priority_code is not NULL
1291 and mol.ship_method_code is not NULL) then
1292 */
1293
1294 -- Make sure that no line is shipped whithing the ship set.
1295 -- We must take out the lines from the ship set even if one line gets
1296 -- shipped
1297
1298 v_ship_set_number := mol.ship_set_number;
1299
1300 g_include_ship_set := 'N';
1301
1302 IF mol.ship_set_number is not null THEN
1303 begin
1304 -- 4234107 :shipped_quantity condition modified to have nvl check
1305 Select line_id into
1306 v_shipped_line_id from
1307 so_lines_all where
1308 header_id = g_line_rec.header_id and
1309 --shipped_quantity is not null and
1310 NVL(shipped_quantity,0) > 0 and
1311 ship_set_number = v_ship_set_number
1312 and rownum = 1;
1313 g_include_ship_set := 'N';
1314 exception
1315 when no_data_found then
1316 g_include_ship_set := 'Y';
1317 end ;
1318
1319 end if;
1320 IF g_include_ship_set = 'Y' THEN
1321 select
1322 oe_sets_s.nextval
1323 into
1324 g_set_id
1325 from dual;
1326
1327 G_ERROR_LOCATION := 704;
1328
1329 insert into oe_sets
1330 (
1331 set_id,
1332 set_name,
1333 set_type,
1334 header_id,
1335 ship_from_org_id,
1336 ship_to_org_id,
1337 shipment_priority_code,
1338 schedule_ship_date,
1339 schedule_arrival_date,
1340 freight_carrier_code,
1341 shipping_method_code,
1342 set_status,
1343 created_by,
1344 creation_date,
1345 update_date,
1346 updated_by,
1347 update_login
1348 )
1349 values
1350 (
1351 g_set_id, /* SET_ID */
1352 mol.ship_set_number, /* SET_NAME */
1353 'SHIP_SET', /* SET_TYPE */
1354 G_header_id, /* HEADER_ID */
1355 mol.warehouse_id, /* SHIP_FROM_ORG_ID */
1356 NULL, /* SHIP_TO_ORG_ID */
1357 mol.shipment_priority_code, /* SHIPMENT_PRIORITY_CODE */
1358 mol.schedule_date, /* SCHEDULE_SHIP_DATE */
1359 null, /* SCHEDULE_ARRIVAL_DATE */
1360 mol.ship_method_code, /* FREIGHT_CARRIER_CODE */
1361 mol.ship_method_code, /* SHIP_METHOD_CODE */
1362 null, /* SET_STATUS */
1363 1, /* CREATED_BY */
1364 SYSDATE, /* CREATION_DATE */
1365 SYSDATE, /* LAST_UPDATE_DATE */
1366 1, /* LAST_UPDATED_BY */
1367 0 /* LAST_UPDATE_LOGIN */
1368 );
1369 end if;
1370 G_ERROR_LOCATION := 705;
1371 elsif mol.ship_set_number is null
1372 OR mol.schedule_date is NULL
1373 OR mol.warehouse_id is NULL
1374 OR mol.schedule_status_code is NULL
1375 OR mol.ship_to_site_use_id is NULL then
1376 G_ERROR_LOCATION := 706;
1377 g_set_id := NULL;
1378 g_include_ship_set := 'N';
1379 end if;
1380
1381 g_copied_line_flag := 'N';
1382
1383 if v_line_id = mol.line_id then
1384 select
1385 oe_order_lines_s.nextval
1386 into
1387 g_line_id
1388 from dual;
1389 g_line_id_change_flag := 'N';
1390 g_line_rec.split_from_line_id := g_orig_line_id; -- 3103312
1391 else
1392 v_line_id := mol.line_id;
1393 g_line_id := mol.line_id;
1394 g_orig_line_id := mol.line_id;
1395 g_line_id_change_flag := 'Y';
1396 g_line_rec.split_from_line_id := NULL;
1397
1398 end if;
1399
1400 if G_COPIED_FLAG = 'Y' and mol.original_system_line_reference is not null then
1401 G_COPIED_LINE_FLAG := 'Y';
1402 end if;
1403
1404 if G_ORDER_SOURCE_ID_LINE IS NOT NULL AND
1405 mol.original_system_line_reference IS NOT NULL then
1406
1407 if G_AUTO_FLAG = 'Y' then
1408 g_line_rec.source_document_type_id := 5;
1409 elsif G_COPIED_LINE_FLAG = 'Y' then
1410 g_line_rec.source_document_type_id := 2;
1411 elsif G_INTERNAL_ORDER = 'Y' then
1412 null;
1413 else
1414 g_line_rec.order_source_id := G_ORDER_SOURCE_ID_LINE;
1415 g_line_rec.orig_sys_document_ref := G_ORIG_SYS_DOCUMENT_REF;
1416 g_line_rec.original_system_line_reference := mol.original_system_line_reference;
1417 g_line_rec.source_document_type_id := NULL;
1418 g_line_rec.source_document_id := NULL;
1419 g_line_rec.source_document_line_id := NULL;
1420 end if;
1421 else
1422 g_line_rec.order_source_id := NULL;
1423 g_line_rec.orig_sys_document_ref := NULL;
1424 g_line_rec.original_system_line_reference := NULL;
1425 g_line_rec.source_document_type_id := NULL;
1426 g_line_rec.source_document_id := NULL;
1427 g_line_rec.source_document_line_id := NULL;
1428
1429 end if;
1430
1431 if nvl(mol.included_item_flag,'-') = 'Y' then
1432 g_line_rec.link_to_line_id := g_orig_line_id;
1433 /* Following line commented to fix the data problem
1434 g_line_rec.parent_line_id := g_orig_line_id;
1435 */
1436 g_line_rec.parent_line_id := mol.parent_line_id;
1437 g_line_rec.item_type_code := 'INCLUDED';
1438 elsif nvl(mol.configuration_item_flag,'-') = 'Y' then
1439 g_line_rec.link_to_line_id := g_orig_line_id;
1440 /* Following line commented to fix the data problem
1441 g_line_rec.parent_line_id := g_orig_line_id;
1442 */
1443 g_line_rec.parent_line_id := mol.parent_line_id;
1444 g_line_rec.ato_line_id := g_orig_line_id;
1445 g_line_rec.item_type_code := 'CONFIG';
1446 elsif ((mol.line_id <> mol.parent_line_id) AND
1447 (mol.item_type_code = 'MODEL')) THEN
1448 g_line_rec.link_to_line_id := mol.link_to_line_id;
1449 g_line_rec.parent_line_id := mol.parent_line_id;
1450 g_line_rec.ato_line_id := mol.ato_line_id;
1451 g_line_rec.item_type_code := 'CLASS';
1452 else
1453 g_line_rec.link_to_line_id := mol.link_to_line_id;
1454 g_line_rec.parent_line_id := mol.parent_line_id;
1455 g_line_rec.ato_line_id := mol.ato_line_id;
1456 g_line_rec.item_type_code := mol.item_type_code;
1457 end if;
1458
1459 -- Fix accounting and invoicing rule ids
1460 IF g_line_id_change_flag = 'Y' THEN
1461 if nvl(mol.accounting_rule_id,0) = 0 or nvl(mol.invoicing_rule_id,0) = 0 then
1462 BEGIN
1463 SELECT decode(agr.override_arule_flag,
1464 'N', agr.accounting_rule_id,
1465 decode(comt.override_arule_flag,
1466 'N', comt.accounting_rule_id,
1467 nvl(si.accounting_rule_id,
1468 nvl(comt.accounting_rule_id,
1469 nvl(agr.accounting_rule_id,
1470 nvl(g_accounting_rule_id,NULL)))))),
1471 decode(agr.override_irule_flag,
1472 'N', agr.invoicing_rule_id,
1473 decode(comt.override_irule_flag,
1474 'N', comt.invoicing_rule_id,
1475 nvl(si.invoicing_rule_id,
1476 nvl(comt.invoicing_rule_id,
1477 nvl(agr.invoicing_rule_id,
1478 nvl(g_invoicing_rule_id,NULL))))))
1479 INTO g_line_rec.accounting_rule_id,
1480 g_line_rec.invoicing_rule_id
1481 FROM so_lines_all l,
1482 so_agreements_b agr,
1483 ra_customer_trx_all ct,
1484 so_agreements_b comt,
1485 mtl_system_items si
1486 WHERE l.line_id= mol.line_id
1487 AND l.agreement_id = agr.agreement_id (+)
1488 AND l.commitment_id = ct.customer_trx_id (+)
1489 AND ct.agreement_id = comt.agreement_id (+)
1490 AND nvl(l.warehouse_id, nvl(v_master_org_for_single_org, oe_sys_parameters.value('MASTER_ORGANIZATION_ID', l.org_id))) = si.organization_id
1491 AND l.inventory_item_id = si.inventory_item_id;
1492
1493 EXCEPTION
1494 WHEN NO_DATA_FOUND THEN
1495 /* oe_debug_pub.add('accounting, invoicing rule ids not found. Setting to Null ');*/
1496 g_line_rec.accounting_rule_id := NULL;
1497 g_line_rec.invoicing_rule_id := NULL;
1498 END;
1499 else
1500 g_line_rec.invoicing_rule_id :=mol.invoicing_rule_id;
1501 g_line_rec.accounting_rule_id :=mol.accounting_rule_id;
1502 end if;
1503 END IF;
1504
1505 /* from ontupg73 */
1506
1507 if g_line_rec.item_type_code = 'SERVICE' then
1508 g_line_rec.parent_line_id := null;
1509 end if;
1510
1511 /* Null out nocopy schedule date for service lines */
1512
1513
1514 if g_line_rec.item_type_code = 'SERVICE' then
1515 g_line_rec.schedule_date := null;
1516 end if;
1517
1518 /* Null out nocopy the service columns if service_duration is */
1519
1520 /* less than zero */
1521 if nvl(g_line_rec.service_duration,0) < 0 then
1522 g_line_rec.service_duration := null;
1523 g_line_rec.service_period := null;
1524 g_line_rec.service_start_date := null;
1525 g_line_rec.service_end_date := null;
1526 end if;
1527
1528
1529 g_Last_Line_Number := g_Last_Line_Number + 1;
1530
1531 /* Initializing temporary variables */
1532
1533 v_ins_return_quantity := NULL;
1534 v_avl_return_quantity := NULL;
1535 v_bal_return_quantity := NULL;
1536 v_return_new_line_id := NULL;
1537 v_return_new_line_number := NULL;
1538 v_reference_line_id := NULL;
1539 v_reference_header_id := NULL;
1540 v_return_lctr := NULL;
1541 v_return_created_line_id := NULL;
1542 v_line_exit_flag := NULL;
1543 G_log_rec.comments := NULL;
1544
1545
1546 v_ins_return_quantity := g_line_rec.ordered_quantity;
1547 v_avl_return_quantity := 0;
1548
1549 if g_line_rec.line_type_code = 'RETURN' THEN
1550 --v_bal_return_quantity := g_line_rec.ordered_quantity;
1551
1552 if g_line_rec.return_reference_type_code is not null then
1553
1554 /* Bug2192797: Modified the from clause of following */
1555 /* query to go againt _all table. */
1556
1557 if g_line_rec.return_reference_type_code = 'INVOICE' then
1558 begin
1559 select customer_trx_id
1560 into v_customer_trx_id
1561 from RA_CUSTOMER_TRX_LINES_ALL
1562 where customer_trx_line_id =
1563 g_line_rec.return_reference_id;
1564 -- and ( interface_line_attribute6 is null or
1565 -- interface_line_attribute6 between
1566 -- '000000000000000' and '999999999999999');
1567 exception
1568 when others then
1569 v_customer_trx_id := NULL;
1570 end;
1571 end if;
1572
1573 /* Fix for bug 2001159 */
1574 v_reference_line_id := nvl(mol.link_to_line_id,
1575 mol.return_reference_id);
1576
1577 end if;
1578
1579 if v_reference_line_id is not null then
1580 begin
1581 select l.header_id into v_reference_header_id
1582 from oe_order_lines_all l
1583 where line_id = v_reference_line_id;
1584 exception
1585 when no_data_found then
1586 G_ERROR_MESSAGE := 'Referenced Order of the RMA'
1587 ||' is not upgraded. line: '
1588 ||to_char(mol.line_id);
1589 raise G_EXC_INVALID_RMA_REFERENCE;
1590 end;
1591 end if;
1592
1593
1594 if g_line_rec.return_reference_type_code is not null then
1595 begin
1596 Select item_type_code, ato_flag,option_flag
1597 into r_original_item_type_code,
1598 r_ato_flag,r_option_flag
1599 from so_lines_all
1600 where line_id = mol.link_to_line_id;
1601 exception
1602 when others then
1603 null;
1604 end;
1605
1606 if r_original_item_type_code = 'MODEL' and
1607 r_ato_flag = 'Y' then
1608 r_ato_model := TRUE;
1609 end if;
1610
1611 -- if r_option_flag = 'Y' and
1612 -- r_ato_flag = 'Y' then
1613 -- r_ato_option := TRUE;
1614 -- end if;
1615
1616 if r_ato_flag = 'N' and
1617 r_original_item_type_code in
1618 ('MODEL','KIT','CLASS') then
1619 r_pto_m_c_k := TRUE;
1620 end if;
1621
1622 -- Fetch config if line is open
1623 if r_ato_model then
1624 if mol.open_flag = 'Y' THEN
1625 begin
1626 Select inventory_item_id,unit_code
1627 into r_inventory_item_id_2,
1628 r_uom_code_2
1629 from mtl_so_rma_interface
1630 where rma_line_id = mol.line_id;
1631 exception
1632 when others then
1633 r_no_config_item := TRUE;
1634 end;
1635 else
1636 r_no_config_item := TRUE;
1637 end if;
1638 end if; /* ato model */
1639
1640 end if; /* reference_type_code is not null */
1641
1642
1643 begin
1644 IF r_pto_m_c_k THEN
1645 select received_quantity into v_received_quantity
1646 from mtl_so_rma_interface
1647 where mol.line_id = rma_line_id
1648 and mol.inventory_item_id = inventory_item_id;
1649 ELSE
1650 select received_quantity into v_received_quantity
1651 from mtl_so_rma_interface
1652 where mol.line_id = rma_line_id;
1653 END IF;
1654
1655 if v_received_quantity = 0 THEN
1656 v_received_quantity := NULL;
1657 end if;
1658 exception
1659 when no_data_found then
1660 v_received_quantity := null;
1661 when others then
1662 v_received_quantity := null;
1663 end;
1664
1665 else
1666 v_bal_return_quantity := 0;
1667 v_reference_line_id := NULL;
1668 end if;
1669
1670 /*
1671 v_actual_ordered_quantity := nvl(mol.ordered_quantity,0) -
1672 nvl(mol.cancelled_quantity,0);
1673 */
1674 v_actual_ordered_quantity := nvl(mol.ordered_quantity,0) ;
1675
1676 if g_hdr_canc_flag = 'Y' or mol.line_cancel_flag = 'Y' then
1677 g_line_rec.ordered_quantity := 0;
1678 else
1679 g_line_rec.ordered_quantity := mol.ordered_quantity;
1680 end if;
1681
1682 G_ERROR_LOCATION := 707;
1683
1684 v_line_exit_flag := 0;
1685 v_return_lctr := 1;
1686 r_lctr := 1;
1687
1688 loop
1689 /* v_return_lctr := v_return_lctr + 1; */
1690
1691 if g_line_rec.line_type_code = 'RETURN' THEN
1692
1693 if v_received_quantity is not NULL and
1694 v_actual_ordered_quantity > v_received_quantity THEN
1695
1696 If v_return_lctr = 1 then
1697 IF not (r_ato_model) THEN
1698 g_line_rec.shipped_quantity := v_received_quantity;
1699 g_line_rec.ordered_quantity := v_received_quantity;
1700 v_return_lctr := 2;
1701 ELSIF r_no_config_item THEN
1702 g_line_rec.shipped_quantity := v_received_quantity;
1703 v_line_exit_flag := 1;
1704 ELSE /* it is a model */
1705 g_line_rec.shipped_quantity := v_received_quantity;
1706 v_return_lctr := 3;
1707 END IF;
1708 elsif v_return_lctr = 2 then
1709 g_line_rec.shipped_quantity := null;
1710 g_line_rec.ordered_quantity :=
1711 nvl(v_actual_ordered_quantity,0) - nvl(v_received_quantity,0);
1712 g_line_rec.cancelled_quantity := null;
1713 g_line_rec.fulfilled_quantity := null;
1714 g_line_rec.invoiced_quantity := null;
1715 r_shipment_number := 2;
1716 v_return_lctr := 10;
1717 v_line_exit_flag := 1;
1718 elsif v_return_lctr in (3,4) then
1719 r_inventory_item_id := r_inventory_item_id_2;
1720 r_uom_code := r_uom_code_2;
1721 r_warehouse_id := r_warehouse_id_2;
1722 IF v_return_lctr = 3 Then
1723 g_line_rec.shipped_quantity := v_received_quantity;
1724 g_line_rec.ordered_quantity := v_received_quantity;
1725
1726 v_return_lctr := 4;
1727 ELSIF v_return_lctr = 4 Then
1728 g_line_rec.shipped_quantity := null;
1729 g_line_rec.ordered_quantity :=
1730 nvl(v_actual_ordered_quantity,0) - nvl(v_received_quantity,0);
1731 g_line_rec.cancelled_quantity := null;
1732 g_line_rec.fulfilled_quantity := null;
1733 g_line_rec.invoiced_quantity := null;
1734 r_shipment_number := 2;
1735 v_return_lctr := 5;
1736 v_line_exit_flag := 1;
1737 END IF;
1738 end if;
1739 else
1740 IF (not r_ato_model) or r_no_config_item then
1741 v_line_exit_flag := 1;
1742 ELSIF v_return_lctr = 3 THEN
1743 r_inventory_item_id := r_inventory_item_id_2;
1744 r_uom_code := r_uom_code_2;
1745 r_warehouse_id := r_warehouse_id_2;
1746 v_return_lctr := 4;
1747 v_line_exit_flag := 1;
1748 ELSE
1749 v_return_lctr := 3;
1750 END IF;
1751 end if;
1752
1753 IF (v_received_quantity is not null and
1754 v_actual_ordered_quantity > v_received_quantity)
1755 AND v_return_lctr in (2,4) THEN
1756 select oe_sets_s.nextval
1757 into r_line_set_id from dual;
1758 -- Also Insert into oe_sets
1759 insert into oe_sets
1760 (
1761 SET_ID,
1762 SET_NAME,
1763 SET_TYPE,
1764 HEADER_ID,
1765 SHIP_FROM_ORG_ID,
1766 SHIP_TO_ORG_ID,
1767 SCHEDULE_SHIP_DATE,
1768 SCHEDULE_ARRIVAL_DATE,
1769 FREIGHT_CARRIER_CODE,
1770 SHIPPING_METHOD_CODE,
1771 SHIPMENT_PRIORITY_CODE,
1772 SET_STATUS,
1773 CREATED_BY,
1774 CREATION_DATE,
1775 UPDATED_BY,
1776 UPDATE_DATE,
1777 UPDATE_LOGIN,
1778 INVENTORY_ITEM_ID,
1779 ORDERED_QUANTITY_UOM,
1780 LINE_TYPE_ID,
1781 SHIP_TOLERANCE_ABOVE,
1782 SHIP_TOLERANCE_BELOW
1783 )
1784 values
1785 (
1786 r_line_set_id, /* SET_ID, */
1787 to_char(r_line_set_id), /* SET_NAME, */
1788 'LINE_SET', /* SET_TYPE, */
1789 g_line_rec.header_id, /* HEADER_ID,*/
1790 null, /* SHIP_FROM_ORG_ID, */
1791 null, /* SHIP_TO_ORG_ID, */
1792 null, /* SCHEDULE_SHIP_DATE, */
1793 null, /* SCHEDULE_ARRIVAL_DATE, */
1794 null, /* FREIGHT_CARRIER_CODE, */
1795 null, /* SHIPPING_METHOD_CODE, */
1796 null, /* SHIPMENT_PRIORITY_CODE, */
1797 null, /* SET_STATUS, */
1798 0, /* CREATED_BY, */
1799 sysdate, /* CREATION_DATE, */
1800 0, /* UPDATED_BY, */
1801 sysdate, /* UPDATE_DATE, */
1802 0, /* UPDATE_LOGIN, */
1803 null, /* INVENTORY_ITEM_ID, */
1804 null, /* ORDERED_QUANTITY_UOM,*/
1805 null, /* LINE_TYPE_ID, */
1806 null, /* SHIP_TOLERANCE_ABOVE,*/
1807 null /* SHIP_TOLERANCE_BELOW */
1808 );
1809 END IF;
1810
1811 IF v_return_lctr = 4 THEN
1812 Select max(line_number) + 1
1813 into g_line_rec.line_number
1814 from so_lines_all
1815 where header_id = G_HEADER_ID;
1816 END IF;
1817 else
1818 v_line_exit_flag := 1;
1819 end if; /* line_type_code = 'RETURN' */
1820
1821 if G_AUTO_FLAG = 'Y' then
1822 begin
1823 select
1824 H.schedule_type_ext,
1825 L.header_id,
1826 L.line_id
1827 into
1828 g_line_rec.rla_schedule_type_code,
1829 g_line_rec.source_document_id,
1830 g_line_rec.source_document_line_id
1831 from
1832 RLM_SCHEDULE_LINES_ALL L,
1833 RLM_SCHEDULE_HEADERS_ALL H
1834 where to_char(mol.demand_stream_id) = L.ITEM_DETAIL_REF_VALUE_3
1835 and L.Header_id = H.Header_id
1836 and L.ITEM_DETAIL_REF_CODE_3 = 'ID';
1837 exception
1838 when no_data_found then
1839 g_line_rec.rla_schedule_type_code := NULL;
1840 g_line_rec.source_document_id := NUll;
1841 g_line_rec.source_document_line_id:= NUll;
1842 when too_many_rows then
1843 g_line_rec.rla_schedule_type_code := NULL;
1844 g_line_rec.source_document_id := NULL;
1845 g_line_rec.source_document_line_id:= NULL;
1846 when others then
1847 NULL;
1848 end;
1849 else
1850 g_line_rec.rla_schedule_type_code := NULL;
1851 end if;
1852
1853 if G_COPIED_LINE_FLAG = 'Y' then
1854 g_line_rec.source_document_id := G_SOURCE_DOCUMENT_ID;
1855 g_line_rec.order_source_id := NULL;
1856 g_line_rec.orig_sys_document_ref := NULL;
1857 g_line_rec.original_system_line_reference := NULL;
1858 begin
1859 g_line_rec.source_document_line_id
1860 := g_line_rec.original_system_line_reference;
1861 exception
1862 when others then
1863 G_ERROR_MESSAGE := 'Invalid Original System Line Reference line : '||to_char(mol.line_id);
1864 raise G_EXC_INVALID_ORIGSYS_LINEREF;
1865 end;
1866 else
1867 g_line_rec.source_document_id := NULL;
1868 g_line_rec.source_document_line_id:= NULL;
1869 end if;
1870
1871 if G_INTERNAL_ORDER = 'Y' AND
1872 mol.original_system_line_reference IS NOT NULL THEN
1873
1874 g_line_rec.source_document_type_id := 10;
1875 g_line_rec.order_source_id := 10;
1876 g_line_rec.source_document_id := G_SOURCE_DOCUMENT_ID;
1877
1878 begin
1879 select requisition_line_id
1880 into g_line_rec.source_document_line_id
1881 from po_requisition_lines_all
1882 where requisition_header_id = G_SOURCE_DOCUMENT_ID
1883 and line_num = mol.original_system_line_reference
1884 and nvl(org_id,-99) = nvl(mol.org_id,-99);
1885
1886 exception
1887
1888 when others then
1889 G_ERROR_MESSAGE := 'Invalid Internal Line Source line : '||to_char(mol.line_id);
1890 raise G_EXC_INVALID_SRC_DOC_LINE;
1891 end;
1892
1893 g_line_rec.orig_sys_document_ref := G_ORIG_SYS_DOCUMENT_REF;
1894 g_line_rec.original_system_line_reference := mol.original_system_line_reference;
1895
1896 end if;
1897 G_ERROR_LOCATION := 708;
1898
1899 begin
1900 select
1901 nvl(decode(G_ORDER_CATEGORY_CODE,
1902 'ORDER',DEFAULT_OUTBOUND_LINE_TYPE_ID,
1903 'RETURN',DEFAULT_INBOUND_LINE_TYPE_ID,0),0)
1904 into
1905 g_line_rec.line_type_id
1906 from
1907 oe_transaction_types_all tta
1908 where tta.transaction_type_id = G_ORDER_TYPE_ID;
1909 exception
1910 when others then
1911 g_line_rec.line_type_id := 0;
1912 end;
1913
1914 if r_lctr > 1 then
1915 select
1916 oe_order_lines_s.nextval
1917 into
1918 v_return_created_line_id
1919 from dual;
1920 end if;
1921
1922 if r_lctr = 1 then
1923 g_line_id := g_line_id;
1924 else
1925 g_line_id := v_return_created_line_id;
1926 end if;
1927
1928
1929 /* From ontupg39 */
1930 if (g_line_rec.ato_line_id IS NOT NULL and
1931 g_line_rec.ato_line_id = g_line_rec.line_id and
1932 nvl(mol.shippable_flag,'Y') = 'Y' and
1933 g_line_rec.item_type_code IN ('MODEL','CLASS')) OR
1934 (g_line_rec.ato_line_id IS NOT NULL and
1935 g_line_rec.ato_line_id <> g_line_rec.line_id and
1936 nvl(mol.shippable_flag,'Y') = 'Y' and
1937 g_line_rec.item_type_code IN ('OPTION','CLASS')) THEN
1938
1939 g_line_rec.shippable_flag := 'N';
1940 else
1941
1942 g_line_rec.shippable_flag :=mol.shippable_flag;
1943 end if;
1944
1945 --bug 1869550 fix. for ato_item
1946 IF g_line_rec.ato_line_id is NOT NULL AND
1947 g_line_rec.item_type_code = 'STANDARD' THEN
1948 g_line_rec.ato_line_id := g_line_rec.line_id;
1949 END IF;
1950
1951 /* Added by Manish/Swami on 6/7/00 to replace ontupg10.sql and merge it
1952 into this package */
1953
1954 if g_line_rec.actual_departure_date is null then
1955 if g_line_rec.schedule_date is null then
1956 if g_line_rec.promise_date is null then
1957 if g_line_rec.date_requested_current is null then
1958 g_line_rec.tax_date := sysdate;
1959 else
1960 g_line_rec.tax_date := g_line_rec.date_requested_current;
1961 end if;
1962 else
1963 g_line_rec.tax_date := g_line_rec.promise_date;
1964 end if;
1965 else
1966 g_line_rec.tax_date := g_line_rec.schedule_date;
1967 end if;
1968 else
1969 g_line_rec.tax_date := g_line_rec.actual_departure_date;
1970 end if;
1971
1972 /* Update of line_number/option_number */
1973
1974 /* Update from ontupg81 */
1975 if g_line_rec.line_type_code = 'RETURN' THEN
1976
1977 g_line_rec.ato_line_id := NULL;
1978 g_line_rec.link_to_line_id := NULL;
1979 g_line_rec.parent_line_id := NULL;
1980 g_line_rec.item_type_code := 'STANDARD';
1981
1982 end if;
1983
1984 if g_line_rec.line_type_code = 'REGULAR' AND
1985 ((g_line_rec.item_type_code = 'STANDARD') OR
1986 (g_line_rec.item_type_code IN ('MODEL','KIT') AND
1987 g_line_rec.parent_line_id = g_line_id)) THEN
1988
1989 g_line_rec.line_number := mol.line_number;
1990
1991 end if;
1992 if g_line_rec.line_type_code = 'DETAIL' AND
1993 ((g_line_rec.item_type_code = 'STANDARD') OR
1994 (g_line_rec.item_type_code IN ('MODEL','KIT') AND
1995 g_line_rec.parent_line_id = g_line_id)) THEN
1996
1997 r_shipment_number := mol.line_number;
1998
1999 SELECT line_number
2000 INTO g_line_rec.line_number
2001 FROM so_lines_all
2002 WHERE line_id = (select shipment_schedule_line_id
2003 from so_lines_all
2004 where line_id = mol.line_id);
2005
2006 end if;
2007
2008 if g_line_rec.item_type_code IN ('KIT','CLASS','OPTION') AND
2009 g_line_rec.parent_line_id <> g_line_id AND
2010 g_line_rec.link_to_line_id IS NOT NULL THEN
2011
2012 g_line_rec.option_number := mol.line_number;
2013 end if;
2014
2015 -- Fix bug 1661010: if null, copy payment term from header to all lines
2016 -- except returns
2017 if g_line_rec.line_category_code <> 'RETURN'
2018 and g_line_rec.terms_id is null then
2019 g_line_rec.terms_id := G_TERMS_ID;
2020 end if;
2021
2022 -- Fix bug 1661010: update null ship to on regular lines (except for
2023 -- returns and services)
2024 if g_line_rec.line_category_code <> 'RETURN'
2025 and g_line_rec.item_type_code <> 'SERVICE'
2026 and g_line_rec.ship_to_site_use_id is null then
2027
2028 if g_line_rec.item_type_code not in ('STANDARD','MODEL') then
2029 -- check for ship_to on ATO model first
2030 if g_line_rec.ato_line_id <> g_line_rec.line_id then
2031 select ship_to_site_use_id
2032 into g_line_rec.ship_to_site_use_id
2033 from so_lines_all
2034 where line_id = g_line_rec.ato_line_id;
2035 end if;
2036 -- check for ship_to on top model next
2037 if g_line_rec.ship_to_site_use_id is null
2038 and g_line_rec.parent_line_id <> g_line_rec.line_id then
2039 select ship_to_site_use_id
2040 into g_line_rec.ship_to_site_use_id
2041 from so_lines_all
2042 where line_id = g_line_rec.parent_line_id;
2043 end if;
2044 end if;
2045
2046 -- if still null, copy it from header
2047 if g_line_rec.ship_to_site_use_id is null then
2048 g_line_rec.ship_to_site_use_id := G_SHIP_TO_SITE_USE_ID;
2049 end if;
2050
2051 end if;
2052
2053 -- Fix for the bug 2696779
2054
2055 IF g_line_rec.line_category_code = 'RETURN' THEN
2056
2057 IF g_line_rec.ship_to_site_use_id is null THEN
2058 g_line_rec.ship_to_site_use_id := G_SHIP_TO_SITE_USE_ID;
2059 END IF;
2060
2061 END IF;
2062
2063 -- Fix for bug 6640180
2064 IF g_line_rec.item_type_code = 'SERVICE' THEN
2065 IF g_line_rec.ship_to_site_use_id IS NULL THEN
2066 g_line_rec.ship_to_site_use_id := G_SHIP_TO_SITE_USE_ID;
2067 END IF;
2068 END IF;
2069 -- End of fix for bug 6640180
2070
2071 -- bug fix 1759900
2072 IF g_line_rec.ato_line_id is not null AND
2073 g_line_rec.open_flag = 'Y' AND
2074 g_line_rec.ato_line_id = g_line_rec.line_id AND
2075 g_line_rec.item_type_code in ('MODEL', 'CLASS')
2076 THEN
2077 G_OPEN_ATO_MODEL := 1;
2078 END IF;
2079
2080 insert into oe_order_lines_all
2081 (
2082 line_id,
2083 org_id,
2084 header_id,
2085 line_type_id,
2086 line_number,
2087 ordered_item,
2088 request_date,
2089 promise_date,
2090 schedule_ship_date,
2091 order_quantity_uom,
2092 pricing_quantity,
2093 pricing_quantity_uom,
2094 cancelled_quantity,
2095 shipped_quantity,
2096 ordered_quantity,
2097 fulfilled_quantity,
2098 shipping_quantity,
2099 shipping_quantity_uom,
2100 delivery_lead_time,
2101 tax_exempt_flag,
2102 tax_exempt_number,
2103 tax_exempt_reason_code,
2104 ship_from_org_id,
2105 subinventory,
2106 ship_to_org_id,
2107 invoice_to_org_id,
2108 deliver_to_org_id,
2109 ship_to_contact_id,
2110 deliver_to_contact_id,
2111 invoice_to_contact_id,
2112 sold_to_org_id,
2113 cust_po_number,
2114 ship_tolerance_above,
2115 ship_tolerance_below,
2116 demand_bucket_type_code,
2117 veh_cus_item_cum_key_id,
2118 rla_schedule_type_code,
2119 customer_dock_code,
2120 customer_job,
2121 customer_production_line,
2122 cust_model_serial_number,
2123 project_id,
2124 task_id,
2125 inventory_item_id,
2126 tax_date,
2127 tax_code,
2128 tax_rate,
2129 demand_class_code,
2130 price_list_id,
2131 pricing_date,
2132 shipment_number,
2133 agreement_id,
2134 shipment_priority_code,
2135 shipping_method_code,
2136 freight_carrier_code,
2137 freight_terms_code,
2138 fob_point_code,
2139 tax_point_code,
2140 payment_term_id,
2141 invoicing_rule_id,
2142 accounting_rule_id,
2143 source_document_type_id,
2144 orig_sys_document_ref,
2145 source_document_id,
2146 orig_sys_line_ref,
2147 source_document_line_id,
2148 reference_line_id,
2149 reference_type,
2150 reference_header_id,
2151 item_revision,
2152 unit_selling_price,
2153 unit_list_price,
2154 tax_value,
2155 context,
2156 attribute1,
2157 attribute2,
2158 attribute3,
2159 attribute4,
2160 attribute5,
2161 attribute6,
2162 attribute7,
2163 attribute8,
2164 attribute9,
2165 attribute10,
2166 attribute11,
2167 attribute12,
2168 attribute13,
2169 attribute14,
2170 attribute15,
2171 global_attribute_category,
2172 global_attribute1,
2173 global_attribute2,
2174 global_attribute3,
2175 global_attribute4,
2176 global_attribute5,
2177 global_attribute6,
2178 global_attribute7,
2179 global_attribute8,
2180 global_attribute9,
2181 global_attribute10,
2182 global_attribute11,
2183 global_attribute12,
2184 global_attribute13,
2185 global_attribute14,
2186 global_attribute15,
2187 global_attribute16,
2188 global_attribute17,
2189 global_attribute18,
2190 global_attribute19,
2191 global_attribute20,
2192 pricing_context,
2193 pricing_attribute1,
2194 pricing_attribute2,
2195 pricing_attribute3,
2196 pricing_attribute4,
2197 pricing_attribute5,
2198 pricing_attribute6,
2199 pricing_attribute7,
2200 pricing_attribute8,
2201 pricing_attribute9,
2202 pricing_attribute10,
2203 industry_context,
2204 industry_attribute1,
2205 industry_attribute2,
2206 industry_attribute3,
2207 industry_attribute4,
2208 industry_attribute5,
2209 industry_attribute6,
2210 industry_attribute7,
2211 industry_attribute8,
2212 industry_attribute9,
2213 industry_attribute10,
2214 industry_attribute11,
2215 industry_attribute12,
2216 industry_attribute13,
2217 industry_attribute14,
2218 industry_attribute15,
2219 industry_attribute16,
2220 industry_attribute17,
2221 industry_attribute18,
2222 industry_attribute19,
2223 industry_attribute20,
2224 industry_attribute21,
2225 industry_attribute22,
2226 industry_attribute23,
2227 industry_attribute24,
2228 industry_attribute25,
2229 industry_attribute26,
2230 industry_attribute27,
2231 industry_attribute28,
2232 industry_attribute29,
2233 industry_attribute30,
2234 creation_date,
2235 created_by,
2236 last_update_date,
2237 last_updated_by,
2238 last_update_login,
2239 program_application_id,
2240 program_id,
2241 program_update_date,
2242 request_id,
2243 top_model_line_id,
2244 link_to_line_id,
2245 component_sequence_id,
2246 component_code,
2247 config_display_sequence,
2248 sort_order,
2249 item_type_code,
2250 option_number,
2251 option_flag,
2252 dep_plan_required_flag,
2253 visible_demand_flag,
2254 line_category_code,
2255 actual_shipment_date,
2256 reference_customer_trx_line_id,
2257 return_context,
2258 return_attribute1,
2259 return_attribute2,
2260 return_attribute3,
2261 return_attribute4,
2262 return_attribute5,
2263 return_attribute6,
2264 return_attribute7,
2265 return_attribute8,
2266 return_attribute9,
2267 return_attribute10,
2268 return_attribute11,
2269 return_attribute12,
2270 return_attribute13,
2271 return_attribute14,
2272 return_attribute15,
2273 intmed_ship_to_org_id,
2274 intmed_ship_to_contact_id,
2275 actual_arrival_date,
2276 ato_line_id,
2277 auto_selected_quantity,
2278 component_number,
2279 earliest_acceptable_date,
2280 explosion_date,
2281 latest_acceptable_date,
2282 model_group_number,
2283 schedule_arrival_date,
2284 ship_model_complete_flag,
2285 schedule_status_code,
2286 return_reason_code,
2287 salesrep_id,
2288 split_from_line_id,
2289 cust_production_seq_num,
2290 authorized_to_ship_flag,
2291 invoice_interface_status_code,
2292 ship_set_id,
2293 arrival_set_id,
2294 over_ship_reason_code,
2295 over_ship_resolved_flag,
2296 shipping_interfaced_flag,
2297 ordered_item_id,
2298 item_identifier_type,
2299 configuration_id,
2300 credit_invoice_line_id,
2301 source_type_code,
2302 planning_priority,
2303 open_flag,
2304 booked_flag,
2305 fulfilled_flag,
2306 service_txn_reason_code,
2307 service_txn_comments,
2308 service_duration,
2309 service_start_date,
2310 service_end_date,
2311 service_coterminate_flag,
2312 unit_selling_percent,
2313 unit_list_percent,
2314 unit_percent_base_price,
2315 service_number,
2316 service_period,
2317 order_source_id,
2318 tp_context,
2319 tp_attribute1,
2320 tp_attribute2,
2321 tp_attribute3,
2322 tp_attribute4,
2323 tp_attribute5,
2324 tp_attribute6,
2325 tp_attribute7,
2326 tp_attribute8,
2327 tp_attribute9,
2328 tp_attribute10,
2329 tp_attribute11,
2330 tp_attribute12,
2331 tp_attribute13,
2332 tp_attribute14,
2333 tp_attribute15,
2334 flow_status_code,
2335 re_source_flag,
2336 service_reference_type_Code,
2337 service_reference_line_id,
2338 service_reference_system_id,
2339 calculate_price_flag,
2340 marketing_source_code_id,
2341 shippable_flag,
2342 fulfillment_method_code,
2343 revenue_amount,
2344 fulfillment_date,
2345 cancelled_flag,
2346 sold_from_org_id,
2347 commitment_id,
2348 end_item_unit_number,
2349 mfg_component_sequence_id,
2350 config_header_id,
2351 config_rev_nbr,
2352 packing_instructions,
2353 shipping_instructions,
2354 invoiced_quantity,
2355 customer_trx_line_id,
2356 split_by,
2357 line_set_id,
2358 orig_sys_shipment_ref,
2359 change_sequence,
2360 drop_ship_flag,
2361 customer_line_number,
2362 customer_shipment_number,
2363 customer_item_net_price,
2364 customer_payment_term_id,
2365 first_ack_code,
2366 last_ack_code,
2367 first_ack_date,
2368 last_ack_date,
2369 model_remnant_flag,
2370 upgraded_flag,
2371 lock_control
2372 )
2373 values
2374 (
2375 g_line_id, /* LINE_ID */
2376 g_line_rec.org_id, /* ORG_ID */
2377 g_line_rec.header_id, /* HEADER_ID */
2378 g_line_rec.line_type_id, /* LINE_TYPE_ID, */
2379 g_line_rec.line_number, /* LINE_NUMBER */
2380 null, /* ordered_item, */
2381 g_line_rec.date_requested_current, /* REQUEST_DATE */
2382 g_line_rec.promise_date, /* PROMISE_DATE */
2383 g_line_rec.schedule_date, /* SCHEDULE_SHIP_DATE */
2384 nvl(r_uom_code,g_line_rec.unit_code), /* ORDER_QUANTITY_UOM */
2385 g_line_rec.ordered_quantity, /* PRICING_QUANTITY */
2386 nvl(r_uom_code,g_line_rec.unit_code), /* PRICING_QUANTITY_UOM */
2387 decode(g_hdr_canc_flag,'Y', g_line_rec.cancelled_quantity,
2388 decode(g_line_id_Change_flag,'Y',
2389 g_line_rec.cancelled_quantity,0)), /* CANCELLED_QUANTITY */
2390 g_line_rec.shipped_quantity, /* SHIPPED_QUANTITY */
2391 decode(g_hdr_canc_flag,'Y',0,
2392 nvl(g_line_rec.ordered_quantity,0)), /* ORDERED_QUANTITY */
2393 g_line_rec.fulfilled_quantity, /* FULFILLED_QUANTITY */
2394 g_line_rec.shipped_quantity, /* SHIPPING_QUANTITY */
2395 nvl(r_uom_code,
2396 g_line_rec.shipping_quantity_uom), /* SHIPPING_QUANTITY_UOM */
2397 null, /* DELIVERY_LEAD_TIME */
2398 G_TAX_EXEMPT_FLAG, /* TAX_EXEMPT_FLAG */
2399 g_line_rec.tax_exempt_number, /* TAX_EXEMPT_NUMBER */
2400 g_line_rec.tax_exempt_reason_code, /* TAX_EXEMPT_REASON_CODE */
2401 g_line_rec.warehouse_id, /* SHIP_FROM_ORG_ID */
2402 g_line_rec.subinventory, /* SUBINVENOTRY */
2403 g_line_rec.ship_to_site_use_id, /* SHIP_TO_ORG_ID */
2404 G_INVOICE_TO_SITE_USE_ID, /* INVOICE_TO_ORG_ID */
2405 null, /* DELIVER_TO_ORG_ID */
2406 g_line_rec.ship_to_contact_id, /* SHIP_TO_CONTACT_ID */
2407 null, /* DELIVER_TO_CONTACT_ID */
2408 null, /* INVOICE_TO_CONTACT_ID */
2409 G_CUSTOMER_ID, /* SOLD_TO_ORG_ID */
2410 decode(G_AUTO_FLAG,'Y',
2411 g_line_rec.industry_attribute3,
2412 G_PURCHASE_ORDER_NUM), /* CUST_PO_NUMBER */
2413 null, /* SHIP_TOLERANCE_ABOVE */
2414 null, /* SHIP_TOLERANCE_BELOW */
2415 decode(G_AUTO_FLAG,'Y','DAY',NULL), /* DEMAND_BUCKET_TYPE_CODE */
2416 decode(G_AUTO_FLAG,'Y',-1,NULL), /* VEH_CUS_ITEM_CUM_KEY_ID */
2417 g_line_rec.rla_schedule_type_code, /* RLA_SCHEDULE_TYPE_CODE */
2418 g_line_rec.customer_dock_code, /* CUSTOMER_DOCK_CODE */
2419 g_line_rec.customer_job, /* CUSTOMER_JOB */
2420 g_line_rec.customer_production_line, /* CUSTOMER_PRODUCTION_LINE */
2421 g_line_rec.customer_model_serial_number, /* CUST_MODEL_SERIAL_NUMBER */
2422 g_line_rec.project_id, /* PROJECT_ID */
2423 g_line_rec.task_id, /* TASK_ID */
2424 nvl(r_inventory_item_id,g_line_rec.inventory_item_id), /* INVENTORY_ITEM_ID */
2425 g_line_rec.tax_date, /* TAX_DATE */
2426 g_line_rec.tax_code, /* TAX_CODE */
2427 null, /* TAX_RATE */
2428 g_line_rec.demand_class_code, /* DEMAND_CLASS_CODE */
2429 g_line_rec.price_list_id, /* Renga PRICE_LIST_ID */
2430 null, /* PRICING_DATE */
2431 r_shipment_number, /* SHIPMENT_NUMBER */
2432 g_line_rec.agreement_id, /* AGREEMENT_ID */
2433 g_line_rec.shipment_priority_code, /* SHIPMENT_PRIORITY_CODE */
2434 g_line_rec.ship_method_code, /* SHIPPPING_METHOD_CODE */
2435 g_line_rec.ship_method_code, /* FREIGHT_CARRIER_CODE */
2436 G_freight_terms_code, /* FREIGHT_TERMS_CODE */
2437 G_FOB_POINT_CODE, /* FOB_POINT_CODE */
2438 'INVOICE', /* TAX_POINT_CODE */
2439 g_line_rec.terms_id, /* PAYMENT_TERM_ID */
2440 g_line_rec.invoicing_rule_id, /* INVOICING_RULE_ID */
2441 g_line_rec.accounting_rule_id, /* ACCOUNTING_RULE_ID */
2442 g_line_rec.source_document_type_id, /* SOURCE_DOCUMENT_TYPE_ID */
2443 g_line_rec.orig_sys_document_ref, /* ORIG_SYS_DOCUMENT_REF */
2444 g_line_rec.source_document_id, /* SOURCE_DOCUMENT_ID */
2445 g_line_rec.original_system_line_reference, /* ORIG_SYS_LINE_REFERENCE */
2446 g_line_rec.source_document_line_id, /* SOURCE_DOCUMENT_LINE_ID */
2447 v_reference_line_id, /* REFERENCE_LINE_ID */
2448 g_line_rec.return_reference_type_code, /* REFERENCE_TYPE */
2449 v_reference_header_id, /* REFERENCE_HEADER_ID */
2450 null, /* ITEM_REVISION */
2451 g_line_rec.selling_price, /* SELLING_PRICE */
2452 g_line_rec.list_price, /* LIST_PRICE */
2453 null, /* TAX_VALUE */
2454 g_line_rec.context, /* CONTEXT */
2455 g_line_rec.attribute1, /* ATTRIBUTE1 */
2456 g_line_rec.attribute2, /* ATTRIBUTE2 */
2457 g_line_rec.attribute3, /* ATTRIBUTE3 */
2458 g_line_rec.attribute4, /* ATTRIBUTE4 */
2459 g_line_rec.attribute5, /* ATTRIBUTE5 */
2460 g_line_rec.attribute6, /* ATTRIBUTE6 */
2461 g_line_rec.attribute7, /* ATTRIBUTE7 */
2462 g_line_rec.attribute8, /* ATTRIBUTE8 */
2463 g_line_rec.attribute9, /* ATTRIBUTE9 */
2464 g_line_rec.attribute10, /* ATTRIBUTE10 */
2465 g_line_rec.attribute11, /* ATTRIBUTE11 */
2466 g_line_rec.attribute12, /* ATTRIBUTE12 */
2467 g_line_rec.attribute13, /* ATTRIBUTE13 */
2468 g_line_rec.attribute14, /* ATTRIBUTE14 */
2469 g_line_rec.attribute15, /* ATTRIBUTE15 */
2470 g_line_rec.global_attribute_category, /* GLOBAL_ATTRIBUTE_CATEGORY */
2471 g_line_rec.global_attribute1, /* GLOBAL_ATTRIBUTE1 */
2472 g_line_rec.global_attribute2, /* GLOBAL_ATTRIBUTE2 */
2473 g_line_rec.global_attribute3, /* GLOBAL_ATTRIBUTE3 */
2474 g_line_rec.global_attribute4, /* GLOBAL_ATTRIBUTE4 */
2475 g_line_rec.global_attribute5, /* GLOBAL_ATTRIBUTE5 */
2476 g_line_rec.global_attribute6, /* GLOBAL_ATTRIBUTE6 */
2477 g_line_rec.global_attribute7, /* GLOBAL_ATTRIBUTE7 */
2478 g_line_rec.global_attribute8, /* GLOBAL_ATTRIBUTE8 */
2479 g_line_rec.global_attribute9, /* GLOBAL_ATTRIBUTE9 */
2480 g_line_rec.global_attribute10, /* GLOBAL_ATTRIBUTE10 */
2481 g_line_rec.global_attribute11, /* GLOBAL_ATTRIBUTE11 */
2482 g_line_rec.global_attribute12, /* GLOBAL_ATTRIBUTE12 */
2483 g_line_rec.global_attribute13, /* GLOBAL_ATTRIBUTE13 */
2484 g_line_rec.global_attribute14, /* GLOBAL_ATTRIBUTE14 */
2485 g_line_rec.global_attribute15, /* GLOBAL_ATTRIBUTE15 */
2486 g_line_rec.global_attribute16, /* GLOBAL_ATTRIBUTE16 */
2487 g_line_rec.global_attribute17, /* GLOBAL_ATTRIBUTE17 */
2488 g_line_rec.global_attribute18, /* GLOBAL_ATTRIBUTE18 */
2489 g_line_rec.global_attribute19, /* GLOBAL-ATTRIBUTE19 */
2490 g_line_rec.global_attribute20, /* GLOBAL_ATTRIBUTE20 */
2491 g_line_rec.pricing_context, /* PRICING_CONTEXT */
2492 g_line_rec.pricing_attribute1, /* PRICING_ATTRIBUTE1 */
2493 g_line_rec.pricing_attribute2, /* PRICING_ATTRIBUTE2 */
2494 g_line_rec.pricing_attribute3, /* PRICING_ATTRIBUTE3 */
2495 g_line_rec.pricing_attribute4, /* PRICING_ATTRIBUTE4 */
2496 g_line_rec.pricing_attribute5, /* PRICING_ATTRIBUTE5 */
2497 g_line_rec.pricing_attribute6, /* PRICING_ATTRIBUTE6 */
2498 g_line_rec.pricing_attribute7, /* PRICING_ATTRIBUTE7 */
2499 g_line_rec.pricing_attribute8, /* PRICING_ATTRIBUTE8 */
2500 g_line_rec.pricing_attribute9, /* PRICING_ATTRIBUTE9 */
2501 g_line_rec.pricing_attribute10, /* PRICING_ATTRIBUTE10*/
2502 g_line_rec.industry_context, /* INDUSTRY_CONTEXT */
2503 g_line_rec.industry_attribute1, /* INDUSTRY_ATTRIBUTE1 */
2504 decode(g_auto_Flag,'Y',
2505 NULL,g_line_rec.industry_attribute2), /* INDUSTRY_ATTRIBUTE2 */
2506 decode(g_auto_Flag,'Y',
2507 NULL,g_line_rec.industry_attribute3), /* INDUSTRY_ATTRIBUTE3 */
2508 decode(g_auto_Flag,'Y',
2509 NULL,g_line_rec.industry_attribute4), /* INDUSTRY_ATTRIBUTE4 */
2510 decode(g_auto_Flag,'Y',
2511 NULL,g_line_rec.industry_attribute5), /* INDUSTRY_ATTRIBUTE5 */
2512 decode(g_auto_Flag,'Y',
2513 NULL,g_line_rec.industry_attribute6), /* INDUSTRY_ATTRIBUTE6 */
2514 decode(g_auto_Flag,'Y',
2515 NULL,g_line_rec.industry_attribute7), /* INDUSTRY_ATTRIBUTE7 */
2516 decode(g_auto_Flag,'Y',
2517 NULL,g_line_rec.industry_attribute8), /* INDUSTRY_ATTRIBUTE8 */
2518 decode(g_auto_Flag,'Y',
2519 NULL,g_line_rec.industry_attribute9), /* INDUSTRY_ATTRIBUTE9 */
2520 decode(g_auto_Flag,'Y',
2521 NULL,g_line_rec.industry_attribute10), /* INDUSTRY_ATTRIBUTE10 */
2522 decode(g_auto_Flag,'Y',
2523 NULL,g_line_rec.industry_attribute11), /* INDUSTRY_ATTRIBUTE11 */
2524 decode(g_auto_Flag,'Y',
2525 NULL,g_line_rec.industry_attribute12), /* INDUSTRY_ATTRIBUTE12 */
2526 decode(g_auto_Flag,'Y',
2527 NULL,g_line_rec.industry_attribute13), /* INDUSTRY_ATTRIBUTE13 */
2528 decode(g_auto_Flag,'Y',
2529 NULL,g_line_rec.industry_attribute14), /* INDUSTRY_ATTRIBUTE14 */
2530 decode(g_auto_Flag,'Y',
2531 NULL,g_line_rec.industry_attribute15), /* INDUSTRY_ATTRIBUTE15 */
2532 NULL, /* INDUSTRY_ATTRIBUTE16 */
2533 NULL, /* INDUSTRY_ATTRIBUTE17 */
2534 NULL, /* INDUSTRY_ATTRIBUTE18 */
2535 NULL, /* INDUSTRY_ATTRIBUTE19 */
2536 NULL, /* INDUSTRY_ATTRIBUTE20 */
2537 NULL, /* INDUSTRY_ATTRIBUTE21 */
2538 NULL, /* INDUSTRY_ATTRIBUTE22 */
2539 NULL, /* INDUSTRY_ATTRIBUTE23 */
2540 NULL, /* INDUSTRY_ATTRIBUTE24 */
2541 NULL, /* INDUSTRY_ATTRIBUTE25 */
2542 NULL, /* INDUSTRY_ATTRIBUTE26 */
2543 NULL, /* INDUSTRY_ATTRIBUTE27 */
2544 NULL, /* INDUSTRY_ATTRIBUTE28 */
2545 NULL, /* INDUSTRY_ATTRIBUTE29 */
2546 NULL, /* INDUSTRY_ATTRIBUTE30 */
2547 g_line_rec.creation_date, /* CREATION_DATE */
2548 g_line_rec.created_by, /* CREATED_BY */
2549 g_line_rec.last_update_date, /* LAST_UPDATE_DATE */
2550 g_line_rec.last_updated_by, /* LAST_UPDATED_BY */
2551 g_line_rec.last_update_login, /* LAST_UPDATE_LOGIN */
2552 nvl(g_line_rec.program_application_id,0), /* PROGRAM_APPLICATION_ID */
2553 g_line_rec.program_id, /* PROGRAM_ID */
2554 g_line_rec.program_update_date, /* PROGRAM_UPDATE_DATE */
2555 g_line_rec.request_id, /* REQUEST_ID */
2556 g_line_rec.parent_line_id, /* TOP_MODEL_LINE_ID */
2557 g_line_rec.link_to_line_id, /* LINK_TO_LINE_ID */
2558 g_line_rec.component_sequence_id, /* COMPONENT_SEQUENCE_ID */
2559 g_line_rec.component_code, /* COMPONENT_CODE */
2560 null, /* CONFIG_DISPLAY_SEQUENCE */
2561 g_line_rec.sort_order, /* SORT_ORDER, */
2562 g_line_rec.item_type_code, /* ITEM_TYPE_CODE */
2563 g_line_rec.option_number, /* OPTION_NUMBER */
2564 g_line_rec.option_flag, /* OPTION_FLAG, */
2565 g_line_rec.dep_plan_required_flag, /* DEP_PLAN_REQUIRED_FLAG */
2566 g_line_rec.visible_demand_flag, /* VISIBLE_DEMAND_FLAG */
2567 g_line_rec.line_category_code, /* LINE_CATEGORY_CODE */
2568 g_line_rec.actual_departure_date, /* ACTUAL_SHIPMENT_DATE */
2569 decode(g_line_rec.line_type_code,'RETURN',
2570 decode(g_line_rec.return_reference_type_code,
2571 'INVOICE',g_line_rec.return_reference_id,NULL), NULL), /* REFERENCE_CUSTOMER_TRX_LINE_ID */
2572
2573 /* Fixing bug 2001159 */
2574 decode(g_line_rec.line_type_code,'RETURN',g_line_rec.return_reference_type_Code,NULL), /* RETURN_CONTEXT */
2575
2576 decode(g_line_rec.line_type_code,'RETURN',
2577 decode(g_line_rec.return_reference_type_code,
2578 'INVOICE',v_customer_trx_id,
2579 v_reference_header_id),NULL), /* RETURN_ATTRIBUTE1 */
2580 decode(g_line_rec.line_type_code,'RETURN',
2581 decode(g_line_rec.return_reference_type_code,
2582 'INVOICE',g_line_rec.return_reference_id,
2583 v_reference_line_id),NULL), /* RETURN_ATTRIBUTE2 */
2584 NULL, /* RETURN_ATTRIBUTE3 */
2585 NULL, /* RETURN_ATTRIBUTE4 */
2586 null, /* RETURN_ATTRIBUTE5 */
2587 null, /* RETURN_ATTRIBUTE6 */
2588 null, /* RETURN_ATTRIBUTE7 */
2589 null, /* RETURN_ATTRIBUTE8 */
2590 null, /* RETURN_ATTRIBUTE9 */
2591 null, /* RETURN_ATTRIBUTE10 */
2592 null, /* RETURN_ATTRIBUTE11 */
2593 null, /* RETURN_ATTRIBUTE12 */
2594 null, /* RETURN_ATTRIBUTE13 */
2595 null, /* RETURN_ATTRIBUTE14 */
2596 null, /* RETURN_ATTRIBUTE15 */
2597 g_line_rec.intermediate_ship_to_id, /* intmed_ship_to_org_id, */
2598 g_line_rec.ship_to_contact_id, /* intmed_ship_to_contact_id, */
2599 null, /* actual_arrival_date, */
2600 g_line_rec.ato_line_id, /* ATO_LINE_ID */
2601 null, /* auto_selected_quantity, */
2602 null, /* component_number, */
2603 null, /* earliest_acceptable_date, */
2604 g_line_rec.standard_component_freeze_date, /* explosion_date, */
2605 g_line_rec.latest_acceptable_date, /* latest_acceptable_date, */
2606 null, /* model_group_number, */
2607 null, /* schedule_arrival_date, */
2608 g_line_rec.ship_model_complete_flag, /* ship_model_complete_flag, */
2609 g_line_rec.schedule_status_code, /* schedule_status_code, */
2610 g_line_rec.transaction_reason_code, /* return_reason_code */
2611 g_salesrep_id, /* salesrep_id */
2612 g_line_rec.split_from_line_id, /* split_from_line_id */
2613 g_line_rec.planning_prod_seq_number, /* cust_production_seq_num */
2614 decode(G_AUTO_FLAG,'Y','Y',NULL), /* authorized_to_ship_flag */
2615 g_line_rec.invoice_interface_status_code, /* invoice_interface_status_code */
2616 decode(g_include_ship_set,'N',null,
2617 decode(g_line_rec.cancelled_flag,'Y',null,g_set_id)),
2618 /* Ship_Set_Id */
2619 null, /* Arrival_Set_Id */
2620 null, /* over_ship_reason_code */
2621 null, /* over_ship_resolved_flag */
2622 g_line_rec.shipping_interfaced_flag, /* shipping_interfaced_flag */
2623 decode(nvl(g_line_rec.customer_item_id,-1),
2624 -1,g_line_rec.inventory_item_id,
2625 g_line_rec.customer_item_id), /* ordered_item_id */
2626 decode(nvl(g_line_rec.customer_item_id,-1),
2627 -1,'INT','CUST'), /* item_identifier_type*/
2628 null, /* configuration_id */
2629 g_line_rec.credit_invoice_line_id, /* credit_invoice_line_id */
2630 g_line_rec.source_type_code, /* source_type_code */
2631 g_line_rec.planning_priority, /* planning_priority */
2632 g_line_rec.open_flag, /* open_flag */
2633 g_line_rec.booked_flag, /* booked_flag */
2634 g_line_rec.fulfilled_flag, /* fulfilled_Flag */
2635 g_line_rec.service_txn_reason_code, /* service_txn_reason_code */
2636 g_line_rec.service_txn_comments, /* service_txn_comments */
2637 g_line_rec.service_duration, /* service_duration */
2638 g_line_rec.service_start_date, /* service_start_date */
2639 g_line_rec.service_end_date, /* service_end_date */
2640 g_line_rec.service_coterminate_flag, /* service_coterminate_flag */
2641 g_line_rec.selling_percent, /* unit_selling_percent */
2642 g_line_rec.list_percent, /* unit_list_percent */
2643 g_line_rec.percent_base_price, /* unit_percent_base_price */
2644 g_line_rec.service_number, /* service_number */
2645 g_line_rec.service_period, /* service_period */
2646 g_line_rec.order_source_id, /* ORDER_SOURCE_ID, */
2647 g_line_rec.tp_context, /* tp_context */
2648 g_line_rec.tp_attribute1, /* tp_attribute1 */
2649 g_line_rec.tp_attribute2, /* tp_attribute2 */
2650 g_line_rec.tp_attribute3, /* tp_attribute3 */
2651 g_line_rec.tp_attribute4, /* tp_attribute4 */
2652 g_line_rec.tp_attribute5, /* tp_attribute5 */
2653 g_line_rec.tp_attribute6, /* tp_attribute6 */
2654 g_line_rec.tp_attribute7, /* tp_attribute7 */
2655 g_line_rec.tp_attribute8, /* tp_attribute8 */
2656 g_line_rec.tp_attribute9, /* tp_attribute9 */
2657 g_line_rec.tp_attribute10, /* tp_attribute10 */
2658 g_line_rec.tp_attribute11, /* tp_attribute11 */
2659 g_line_rec.tp_attribute12, /* tp_attribute12 */
2660 g_line_rec.tp_attribute13, /* tp_attribute13 */
2661 g_line_rec.tp_attribute14, /* tp_attribute14 */
2662 g_line_rec.tp_attribute15, /* tp_attribute15 */
2663 g_line_rec.flow_status_code, /* flow_status_code */
2664 g_line_rec.re_source_flag, /* re_source_flag */
2665 g_line_rec.service_reference_type_Code, /* service_reference_type_code */
2666 g_line_rec.service_reference_line_id, /* service_reference_line_id */
2667 g_line_rec.service_reference_system_id, /* service_reference_system_id */
2668 g_line_rec.calculate_price_flag, /* calculate_price_flag */
2669 g_line_rec.marketing_source_code_id, /* marketing_source_code_id */
2670 g_line_rec.shippable_flag, /* shippable_flag */
2671 g_line_rec.fulfillment_method_code, /* fulfillment_method_code */
2672 g_line_rec.revenue_amount, /* revenue_amount */
2673 g_line_rec.fulfillment_date, /* fulfillment_date */
2674 g_line_rec.cancelled_flag, /* cancelled_flag */
2675 g_line_rec.org_id, /* sold_from_org_id */
2676 g_line_rec.commitment_id, /* commitment_id */
2677 null, /* end_item_unit_number */
2678 null, /* mfg_component_sequence_id */
2679 null, /* config_header_id */
2680 null, /* config_rev_nbr */
2681 G_PACKING_INSTRUCTIONS, /* packing_instructions */
2682 G_SHIPPING_INSTRUCTIONS, /* shipping_instructions */
2683 g_line_rec.invoiced_quantity, /* invoiced_quantity */
2684 null, /* customer_trx_line_id */
2685 null, /* split_by */
2686 nvl(r_line_set_id,null), /* line_set_id */
2687 null, /* orig_sys_shipment_ref */
2688 null, /* change_sequence */
2689 null, /* drop_ship_flag */
2690 null, /* customer_line_number */
2691 null, /* customer_shipment_number */
2692 null, /* customer_item_net_price */
2693 null, /* customer_payment_term_id */
2694 null, /* first_ack_code */
2695 null, /* last_ack_code */
2696 null, /* first_ack_date */
2697 null, /* last_ack_date */
2698 null, /* model_remnant_flag */
2699 decode(g_line_rec.open_flag,'Y','I','Y'),/* upgraded_flag */
2700 1
2701 );
2702
2703 /* To fix oe_drop_ship_source if an external line
2704 is shipped partially */
2705
2706 IF g_line_id <> g_orig_line_id AND
2707 g_line_rec.source_type_code = 'EXTERNAL' AND
2708 g_line_rec.shipped_quantity is null THEN
2709 BEGIN
2710 UPDATE oe_drop_ship_sources
2711 SET line_id=g_line_id
2712 WHERE line_id=g_orig_line_id;
2713 EXCEPTION
2714 WHEN OTHERS THEN
2715 null;
2716 END;
2717 END IF;
2718
2719
2720
2721 r_lctr := r_lctr + 1;
2722
2723 G_ERROR_LOCATION := 709;
2724
2725 G_Log_Rec.Header_Id := g_header_id;
2726 G_Log_Rec.Old_Line_Id := mol.line_id;
2727 G_Log_Rec.picking_Line_Id := mol.picking_line_id;
2728 G_Log_Rec.Old_Line_Detail_id := mol.line_detail_id;
2729 G_Log_Rec.Delivery := mol.Delivery;
2730
2731 G_Log_Rec.New_Line_ID := g_line_id; -- 2/24/2000
2732 g_log_rec.return_qty_available := g_line_rec.ordered_quantity; -- 2/24/2000
2733
2734 G_Log_Rec.New_Line_Number := g_line_rec.line_number;
2735 G_Log_Rec.mtl_sales_order_id := g_mtl_sales_order_id;
2736
2737 OE_UPG_SO_NEW.Upgrade_Insert_Upgrade_Log;
2738
2739 g_log_rec.comments := NULL;
2740
2741 begin
2742
2743 IF v_return_lctr = 4 THEN
2744 -- Update PO Tables
2745 -- rcv_shipment_lines, rcv_transactions,rcv_supply
2746 update rcv_shipment_lines
2747 set oe_order_line_id = v_return_created_line_id
2748 where oe_order_line_id = g_old_line_id;
2749
2750 update rcv_transactions
2751 set oe_order_line_id = v_return_created_line_id
2752 where oe_order_line_id = g_old_line_id;
2753
2754 update rcv_supply
2755 set oe_order_line_id = v_return_created_line_id
2756 where oe_order_line_id = g_old_line_id;
2757 END IF;
2758 exception
2759 when others then
2760 OE_UPG_SO_NEW.upgrade_insert_errors
2761 (
2762 L_header_id => g_header_id,
2763 L_comments => 'Updating RCV shipment failed for line :'
2764 ||to_char(g_old_line_id)||' with oracle error ORA-'
2765 ||to_char(sqlcode));
2766 end;
2767
2768 /* For return config items do not copy pricing attributes*/
2769 IF v_return_lctr < 4 or v_return_lctr = 10 then
2770
2771 /* ========== Line Level Pricing Attributes =========== Added by jefflee 6/21/00 */
2772 l_qp_upg_line_rec := g_line_rec;
2773 l_qp_upg_line_rec.line_id:=g_line_id;
2774 QP_Upg_OE_PVT.Upg_Pricing_Attribs(l_qp_upg_line_rec);
2775
2776 /* ========== Line Level Price Adjustments =========== */
2777
2778 IF ( (g_line_rec.item_type_code <> 'INCLUDED' )
2779 AND (g_line_rec.item_type_code <> 'CONFIG') ) THEN
2780
2781 OE_UPG_SO_NEW.Upgrade_Price_Adjustments
2782 ( L_level_flag => 'L');
2783
2784 END IF;
2785
2786 END IF;
2787
2788 /* ========== Line Level Sales Credits =========== */
2789 OE_UPG_SO_NEW.Upgrade_Sales_Credits
2790 ( L_level_flag => 'L');
2791
2792 if OE_UPG_SO_NEW.G_HDR_CANC_FLAG = 'Y' then
2793 G_ERROR_LOCATION := 710;
2794 g_canc_rec := g_hdr_canc_rec;
2795 G_ORD_CANC_FLAG := 'N';
2796 OE_UPG_SO_NEW.Upgrade_Insert_Lines_History;
2797 end if;
2798
2799 if v_bal_return_quantity <= 0 or v_line_exit_flag = 1 then
2800 exit;
2801 end if;
2802
2803 end loop; /* extra loop for returns */
2804
2805 /* ========== Line Level Cancellations =========== */
2806 /* if nvl(mol.cancelled_quantity,0) > 0 and OE_UPG_SO_NEW.G_HDR_CANC_FLAG <> 'Y' then */
2807
2808 if g_line_id_Change_flag = 'Y' then
2809 if nvl(mol.cancelled_quantity,0) > 0 then
2810 OE_UPG_SO_NEW.Upgrade_Cancellations ;
2811 end if;
2812 end if;
2813
2814 end loop; /* end loop for Order lines*/
2815 close ol;
2816 G_ERROR_LOCATION := 8;
2817
2818 End Upgrade_Create_Order_Lines;
2819
2820 Procedure Upgrade_Create_Order_Headers
2821 ( L_Line_Type IN varchar2,
2822 L_Slab IN number )
2823 is
2824 commit_counter number;
2825 v_start_header number;
2826 v_end_header number;
2827
2828 /* The oh cursor is declared to bring Order Headers details */
2829
2830 cursor oh is
2831 select /*+ ORDERED USE_NL(SHA SHATTR) */
2832 sha.header_id,
2833 sha.org_id,
2834 sha.order_type_id,
2835 sha.order_number,
2836 sha.credit_card_expiration_date,
2837 sha.original_system_source_code,
2838 sha.original_system_reference,
2839 sha.date_ordered,
2840 sha.date_requested_current,
2841 sha.shipment_priority_code,
2842 sha.demand_class_code,
2843 sha.price_list_id,
2844 sha.tax_exempt_flag,
2845 sha.tax_exempt_num tax_exempt_num,
2846 sha.tax_exempt_reason_code,
2847 sha.conversion_rate,
2848 sha.conversion_type_code,
2849 sha.conversion_date,
2850 sha.ship_partial_flag,
2851 sha.currency_code,
2852 sha.agreement_id,
2853 sha.purchase_order_num,
2854 sha.invoicing_rule_id,
2855 sha.accounting_rule_id,
2856 sha.terms_id,
2857 sha.sales_channel_code, -- Added by JAUTOMO
2858 sha.ship_method_code,
2859 sha.fob_code,
2860 sha.freight_terms_code,
2861 sha.ship_to_contact_id,
2862 sha.invoice_to_contact_id,
2863 sha.creation_date,
2864 sha.created_by,
2865 sha.last_updated_by,
2866 sha.last_update_date,
2867 sha.last_update_login,
2868 sha.program_application_id,
2869 sha.program_id,
2870 sha.program_update_date,
2871 sha.request_id,
2872 sha.customer_id,
2873 sha.salesrep_id,
2874 sha.cancelled_flag,
2875 sha.context,
2876 sha.attribute1,
2877 sha.attribute2,
2878 sha.attribute3,
2879 sha.attribute4,
2880 sha.attribute5,
2881 sha.attribute6,
2882 sha.attribute7,
2883 sha.attribute8,
2884 sha.attribute9,
2885 sha.attribute10,
2886 sha.attribute11,
2887 sha.attribute12,
2888 sha.attribute13,
2889 sha.attribute14,
2890 sha.attribute15,
2891 sha.payment_type_code,
2892 sha.payment_amount,
2893 sha.check_number,
2894 sha.credit_card_code,
2895 sha.credit_card_holder_name,
2896 sha.credit_card_number,
2897 sha.credit_card_approval_code,
2898 shattr.global_attribute_category,
2899 shattr.global_attribute1,
2900 shattr.global_attribute2,
2901 shattr.global_attribute3,
2902 shattr.global_attribute4,
2903 shattr.global_attribute5,
2904 shattr.global_attribute6,
2905 shattr.global_attribute7,
2906 shattr.global_attribute8,
2907 shattr.global_attribute9,
2908 shattr.global_attribute10,
2909 shattr.global_attribute11,
2910 shattr.global_attribute12,
2911 shattr.global_attribute13,
2912 shattr.global_attribute14,
2913 shattr.global_attribute15,
2914 shattr.global_attribute16,
2915 shattr.global_attribute17,
2916 shattr.global_attribute18,
2917 shattr.global_attribute19,
2918 shattr.global_attribute20,
2919 sha.invoice_to_site_use_id,
2920 sha.order_category,
2921 sha.ordered_by_contact_id,
2922 sha.ship_to_site_use_id,
2923 sha.warehouse_id,
2924 decode(sha.cancelled_flag ,'Y', 'N',nvl(sha.open_flag,'N')) open_flag,
2925 decode(sha.s1,1,'Y','N') booked_flag,
2926 sha.s1_date,
2927 sha.shipping_instructions,
2928 sha.packing_instructions
2929 from
2930 so_headers_all sha,
2931 so_header_attributes shattr
2932 where
2933 sha.upgrade_flag = 'N' and
2934 sha.header_id = shattr.header_id(+) and
2935 (( L_Line_type = 'R' and sha.order_category = 'RMA') or
2936 ( L_Line_type = 'O' and sha.order_category <> 'RMA')) and
2937 sha.header_id between v_start_header and v_end_header
2938 order by
2939 sha.header_id;
2940
2941 v_source_code_profile_value varchar2(100);
2942 v_auto_source_code varchar2(30);
2943 v_error_code number;
2944 l_source_code varchar2(30);
2945 l_count NUMBER := 0;
2946 v_cancel_comment long;
2947 --
2948 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2949 --
2950 begin
2951 -- dbms_output.enable(999999999);
2952 G_ERROR_LOCATION := 9;
2953 begin
2954 select
2955 start_header_id,
2956 end_header_id
2957 into
2958 v_start_header,
2959 v_end_header
2960 from oe_upgrade_distribution
2961 where slab = L_slab
2962 and nvl(line_type,'O') = L_line_type ;
2963
2964 /* where nvl(alloted_flag,'N') = 'N' */
2965
2966 exception
2967 when no_data_found then
2968 OE_UPG_SO_NEW.upgrade_insert_errors
2969 (
2970 L_header_id => 0,
2971 L_comments => 'FYI Only: Parallel process of Sales Order Upgrade not used for the slab:'||to_char(L_slab)
2972 );
2973 v_start_header := 0;
2974 v_end_header := 0;
2975 commit;
2976 return;
2977 end;
2978
2979 commit_counter := 0;
2980
2981 OE_UPG_SO_NEW.g_earliest_schedule_limit :=
2982 to_number(FND_PROFILE.VALUE('OE_SCHEDULE_DATE_WINDOW'));
2983
2984 OE_UPG_SO_NEW.g_latest_schedule_limit := OE_UPG_SO_NEW.g_earliest_schedule_limit;
2985
2986 v_source_code_profile_value := fnd_profile.value('SO_SOURCE_CODE');
2987
2988 --5302907: Ref. to old sys. param table commented
2989 /*
2990 select count(*) into l_count from oe_system_parameters_all;
2991 IF l_count = 1 THEN
2992 select master_organization_id
2993 into v_master_org_for_single_org
2994 from oe_system_parameters_all;
2995 END IF;
2996 */
2997 v_auto_source_code := NULL;
2998
2999 fnd_profile.get('RLA_ORDERIMPORT_SOURCE',v_auto_source_code);
3000
3001 for moh in oh loop /* start loop for Order Headers */
3002 begin
3003
3004 G_Error_Alert := 'N';
3005 SAVEPOINT HEADER_SAVE_POINT;
3006
3007 -- dbms_output.put_line('Inserting Header ==============>');
3008
3009 G_LOG_Rec := NULL;
3010
3011 G_HEADER_ID := moh.header_id;
3012 G_TAX_EXEMPT_FLAG := moh.tax_exempt_flag;
3013 G_CUSTOMER_ID := moh.customer_id;
3014 G_FREIGHT_TERMS_CODE := moh.freight_terms_code;
3015 G_INVOICE_TO_SITE_USE_ID := moh.invoice_to_site_use_id;
3016 G_PURCHASE_ORDER_NUM := moh.purchase_order_num;
3017 G_SALESREP_ID := moh.salesrep_id;
3018 G_TERMS_ID := moh.terms_id;
3019 G_ACCOUNTING_RULE_ID := moh.accounting_rule_id;
3020 G_INVOICING_RULE_ID := moh.invoicing_rule_id;
3021 G_CANCELLED_FLAG := moh.cancelled_flag;
3022 G_ORDER_TYPE_ID := moh.order_type_id;
3023 G_SOURCE_DOCUMENT_ID := NULL;
3024 G_SOURCE_DOCUMENT_TYPE_ID := NULL;
3025 G_ORDER_SOURCE_ID := NULL;
3026 G_ORIG_SYS_DOCUMENT_REF := NULL;
3027 G_COPIED_FLAG := 'N';
3028 G_ERROR_MESSAGE := NULL;
3029 G_INTERNAL_ORDER := 'N';
3030 G_ORDER_SOURCE_ID_LINE := NULL;
3031 G_OPEN_FLAG := NULL;
3032
3033 G_ORDER_SOURCE_ID_LINE := moh.original_system_source_code;
3034
3035 G_SHIPPING_INSTRUCTIONS := moh.shipping_instructions;
3036 G_PACKING_INSTRUCTIONS := moh.packing_instructions;
3037
3038 G_FOB_POINT_CODE := moh.fob_code;
3039 -- bug 1661010
3040 G_SHIP_TO_SITE_USE_ID := moh.ship_to_site_use_id;
3041
3042 if moh.open_flag = 'Y' then
3043 G_OPEN_FLAG := 'Y';
3044 else
3045 G_OPEN_FLAG := 'N';
3046 end if;
3047
3048 if moh.order_category = 'P' then
3049 G_INTERNAL_ORDER := 'Y';
3050 end if;
3051
3052 if moh.order_category in ('P','R') then
3053 G_ORDER_CATEGORY_CODE := 'ORDER';
3054 elsif moh.order_category = 'RMA' then
3055 G_ORDER_CATEGORY_CODE := 'RETURN';
3056 else
3057 -- insert error message for invalid order category
3058 G_ERROR_MESSAGE := 'Invalid Order Category.';
3059 raise G_EXC_INVALID_ORDER_CATEGORY;
3060 end if;
3061
3062 -- IF original_system_source_code is alphanumeric
3063 -- do not process the order
3064 if moh.original_system_source_code is not null then
3065 begin
3066 l_source_code :=
3067 to_number(moh.original_system_source_code);
3068 exception
3069 When others then
3070 -- insert error message for invalid source
3071 G_ERROR_MESSAGE := 'Invalid Order Source code.';
3072 raise G_EXC_INVALID_SOURCE_CODE;
3073 end;
3074 end if;
3075
3076 if moh.original_system_source_code = '2' and
3077 moh.original_system_reference is not null then
3078 G_SOURCE_DOCUMENT_TYPE_ID := 2;
3079 G_COPIED_FLAG := 'Y';
3080 begin
3081 G_SOURCE_DOCUMENT_ID :=
3082 to_number(moh.original_system_reference);
3083 exception
3084 When Others then
3085 -- Error message alphanumeric copy reference
3086 G_ERROR_MESSAGE := 'Invalid Copy Order Source.';
3087 raise G_EXC_INVALID_COPY_SOURCE;
3088 end;
3089
3090 elsif moh.order_category = 'P' and
3091 moh.original_system_reference is not null then
3092 G_ORDER_SOURCE_ID := 10;
3093 G_ORIG_SYS_DOCUMENT_REF := moh.original_system_reference;
3094 G_SOURCE_DOCUMENT_TYPE_ID := 10;
3095
3096 begin
3097 select requisition_header_id into G_SOURCE_DOCUMENT_ID
3098 from po_requisition_headers_all
3099 where segment1 = moh.original_system_reference
3100 and nvl(org_id,-99) = nvl(moh.org_id,-99);
3101 exception
3102 When no_data_found Then
3103 -- Message invalid internal order reference
3104 G_ERROR_MESSAGE := 'Invalid Internal Order Source.';
3105 raise G_EXC_INVALID_INTERNAL_SOURCE;
3106 end;
3107 elsif moh.original_system_source_code is not NULL then
3108 G_ORDER_SOURCE_ID := moh.original_system_source_code;
3109 G_ORIG_SYS_DOCUMENT_REF := moh.original_system_reference;
3110 end if;
3111
3112
3113 /* Setting Automotive Order Flag */
3114
3115 if moh.original_system_source_code = v_auto_source_code then
3116 G_AUTO_FLAG := 'Y';
3117 else
3118 G_AUTO_FLAG := 'N';
3119 end if;
3120
3121
3122 /* Getting MTL_SALES_ORDER_ID */
3123
3124 begin
3125 select
3126 sales_order_id
3127 into
3128 G_MTL_SALES_ORDER_ID
3129 from
3130 mtl_sales_orders mso,
3131 so_order_types_115_all sota
3132 where segment1 = to_char(moh.order_number)
3133 and segment2 = sota.name
3134 and segment3 = v_source_code_profile_value
3135 and moh.order_type_id = sota.order_type_id
3136 and rownum = 1;
3137 exception
3138 when no_data_found then
3139 G_MTL_SALES_ORDER_ID := NULL;
3140 when others then
3141 G_MTL_SALES_ORDER_ID := NULL;
3142 end;
3143
3144 /* Renga - get new list_header_id for the
3145 agreement's price_list_id */
3146 --Sameer: retaining old price_list_id for agreements
3147 /* begin
3148
3149 select new_list_header_id
3150 into g_list_header_id
3151 from qp_discount_mapping
3152 where old_discount_id = moh.price_list_id
3153 and old_discount_line_id is null
3154 and new_list_line_id is null
3155 and new_type = 'P';
3156
3157 exception
3158
3159 when no_data_found then
3160 g_list_header_id := moh.price_list_id;
3161
3162 end;
3163 */
3164 /* Renga */
3165
3166 insert into oe_order_headers_all
3167 (
3168 header_id,
3169 org_id,
3170 order_type_id,
3171 order_number,
3172 version_number,
3173 expiration_date,
3174 order_source_id,
3175 source_document_type_id,
3176 orig_sys_document_ref,
3177 source_document_id,
3178 ordered_date,
3179 request_date,
3180 pricing_date,
3181 shipment_priority_code,
3182 demand_class_code,
3183 price_list_id,
3184 tax_exempt_flag,
3185 tax_exempt_number,
3186 tax_exempt_reason_code,
3187 conversion_rate,
3188 conversion_type_code,
3189 conversion_rate_date,
3190 partial_shipments_allowed,
3191 ship_tolerance_above,
3192 ship_tolerance_below,
3193 transactional_curr_code,
3194 agreement_id,
3195 tax_point_code,
3196 cust_po_number,
3197 invoicing_rule_id,
3198 accounting_rule_id,
3199 payment_term_id,
3200 shipping_method_code,
3201 freight_carrier_code,
3202 fob_point_code,
3203 freight_terms_code,
3204 sold_to_org_id,
3205 ship_from_org_id,
3206 ship_to_org_id,
3207 invoice_to_org_id,
3208 deliver_to_org_id,
3209 sold_to_contact_id,
3210 ship_to_contact_id,
3211 invoice_to_contact_id,
3212 deliver_to_contact_id,
3213 creation_date,
3214 created_by,
3215 last_updated_by,
3216 last_update_date,
3217 last_update_login,
3218 program_application_id,
3219 program_id,
3220 program_update_date,
3221 request_id,
3222 salesrep_id,
3223 return_reason_code,
3224 context,
3225 attribute1,
3226 attribute2,
3227 attribute3,
3228 attribute4,
3229 attribute5,
3230 attribute6,
3231 attribute7,
3232 attribute8,
3233 attribute9,
3234 attribute10,
3235 attribute11,
3236 attribute12,
3237 attribute13,
3238 attribute14,
3239 attribute15,
3240 global_attribute_category,
3241 global_attribute1,
3242 global_attribute2,
3243 global_attribute3,
3244 global_attribute4,
3245 global_attribute5,
3246 global_attribute6,
3247 global_attribute7,
3248 global_attribute8,
3249 global_attribute9,
3250 global_attribute10,
3251 global_attribute11,
3252 global_attribute12,
3253 global_attribute13,
3254 global_attribute14,
3255 global_attribute15,
3256 global_attribute16,
3257 global_attribute17,
3258 global_attribute18,
3259 global_attribute19,
3260 global_attribute20,
3261 order_date_type_code,
3262 earliest_schedule_limit,
3263 latest_schedule_limit,
3264 payment_type_code,
3265 payment_amount,
3266 check_number,
3267 credit_card_code,
3268 credit_card_holder_name,
3269 credit_card_number,
3270 credit_card_expiration_date,
3271 credit_card_approval_code,
3272 credit_card_approval_date,
3273 sales_channel_code,
3274 order_category_code,
3275 cancelled_flag,
3276 open_flag,
3277 booked_flag,
3278 marketing_source_code_id,
3279 tp_context,
3280 tp_attribute1,
3281 tp_attribute2,
3282 tp_attribute3,
3283 tp_attribute4,
3284 tp_attribute5,
3285 tp_attribute6,
3286 tp_attribute7,
3287 tp_attribute8,
3288 tp_attribute9,
3289 tp_attribute10,
3290 tp_attribute11,
3291 tp_attribute12,
3292 tp_attribute13,
3293 tp_attribute14,
3294 tp_attribute15,
3295 flow_status_code,
3296 upgraded_flag,
3297 booked_date,
3298 sold_from_org_id,
3299 lock_control,
3300 shipping_instructions,
3301 packing_instructions
3302 )
3303 values
3304 (
3305 moh.header_id, /* HEADER_ID */
3306 moh.org_id, /* ORG_ID */
3307 moh.order_type_id, /* ORDER_TYPE_ID */
3308 moh.order_number, /* ORDER_NUMBER */
3309 1, /* VERSION_NUMBER, */
3310 NULL, /* EXPIRATION_DATE, */
3311 G_ORDER_SOURCE_ID, /* ORDER_SOURCE_ID, */
3312 G_SOURCE_DOCUMENT_TYPE_ID, /* SOURCE_DOCUMENT_TYPE_ID,*/
3313 G_ORIG_SYS_DOCUMENT_REF, /* ORIG_SYS_DOCUMENT_REF,*/
3314 G_SOURCE_DOCUMENT_ID, /* SOURCE_DOCUMENT_ID, */
3315 moh.date_ordered, /* ORDERED_DATE */
3316 moh.date_requested_current, /* REQUEST_DATE */
3317 null, /* PRICING_DATE, */
3318 moh.shipment_priority_code, /* SHIPMENT_PRIORITY_CODE */
3319 moh.demand_class_code, /* DEMAND_CLASS_CODE */
3320 moh.price_list_id, /* Renga PRICE_LIST_ID */
3321 moh.tax_exempt_flag, /* TAX_EXEMPT_FLAG */
3322 moh.tax_exempt_num, /* TAX_EXEMPT_NUMBER */
3323 moh.tax_exempt_reason_code, /* TAX_EXEMPT_REASON_CODE */
3324 moh.conversion_rate, /* CONVERSION_RATE */
3325 moh.conversion_type_code, /* CONVERSION_TYPE_CODE */
3326 moh.conversion_date, /* CONVERSION_RATE_DATE */
3327 moh.ship_partial_flag, /* PARTIAL_SHIPMENTS_ALLOWED */
3328 null, /* SHIP_TOLERANCE_ABOVE, */
3329 null, /* SHIP_TOLERANCE_BELOW, */
3330 moh.currency_code, /* TRANSACTIONAL_CURR_CODE */
3331 moh.agreement_id, /* AGREEMENT_ID */
3332 'INVOICE', /* TAX_POINT_CODE */
3333 decode(G_AUTO_FLAG,'Y',
3334 g_line_rec.industry_attribute3,
3335 G_PURCHASE_ORDER_NUM), /* CUST_PO_NUMBER */
3336 moh.invoicing_rule_id, /* INVOICING_RULE_ID */
3337 moh.accounting_rule_id, /* ACCOUNTING_RULE_ID */
3338 moh.terms_id, /* PAYMENT_TERM_ID */
3339 moh.ship_method_code, /* SHIPING_METHOD_CODE */
3340 moh.ship_method_code, /* FREIGHT_CARRIER_CODE */
3341 moh.fob_code, /* FOB_POINT_CODE */
3342 moh.freight_terms_code, /* FREIGHT_TERMS_CODE */
3343 G_customer_id, /* SOLD_TO_ORG_ID */
3344 moh.warehouse_id, /* SHIP_FROM_ORG_ID */
3345 moh.ship_to_site_use_id, /* SHIP_TO_ORG_ID */
3346 moh.invoice_to_site_use_id, /* INVOICE_TO_ORG_ID */
3347 null, /* DELIVER_TO_ORG_ID */
3348 moh.ordered_by_contact_id, /* SOLD_TO_CONTACT_ID */
3349 moh.ship_to_contact_id, /* SHIP_TO_CONTACT_ID */
3350 moh.invoice_to_contact_id, /* INVOICE_TO_CONTACT_ID */
3351 null, /* DELIVER_TO_CONTACT_ID */
3352 moh.creation_date, /* CREATION_DATE */
3353 moh.created_by, /* CREATED_BY */
3354 moh.last_updated_by, /* LAST_UPDATED_BY */
3355 moh.last_update_date, /* LAST_UPDATE_DATE */
3356 moh.last_update_login, /* LAST_UPDATE_LOGIN */
3357 nvl(moh.program_application_id,0), /* PROGRAM_APPLICATION_ID */
3358 moh.program_id, /* PROGRAM_ID */
3359 moh.program_update_date, /* PROGRAM_UPDATE_DATE */
3360 moh.request_id, /* REQUEST_ID */
3361 moh.salesrep_id, /* SALESREP_ID */
3362 null, /* RETURN_REASON_CODE */
3363 moh.context, /* CONTEXT */
3364 moh.attribute1, /* ATTRIBUTE1 */
3365 moh.attribute2, /* ATTRIBUTE2 */
3366 moh.attribute3, /* ATTRIBUTE3 */
3367 moh.attribute4, /* ATTRIBUTE4 */
3368 moh.attribute5, /* ATTRIBUTE5 */
3369 moh.attribute6, /* ATTRIBUTE6 */
3370 moh.attribute7, /* ATTRIBUTE7 */
3371 moh.attribute8, /* ATTRIBUTE8 */
3372 moh.attribute9, /* ATTRIBUTE9 */
3373 moh.attribute10, /* ATTRIBUTE10 */
3374 moh.attribute11, /* ATTRIBUTE11 */
3375 moh.attribute12, /* ATTRIBUTE12 */
3376 moh.attribute13, /* ATTRIBUTE13 */
3377 moh.attribute14, /* ATTRIBUTE14 */
3378 moh.attribute15, /* ATTRIBUTE15 */
3379 moh.global_attribute_category, /* GLOBAL_ATTRIBUTE_CATEGORY */
3380 moh.global_attribute1, /* GLOBAL_ATTRIBUTE1 */
3381 moh.global_attribute2, /* GLOBAL_ATTRIBUTE2 */
3382 moh.global_attribute3, /* GLOBAL_ATTRIBUTE3 */
3383 moh.global_attribute4, /* GLOBAL_ATTRIBUTE4 */
3384 moh.global_attribute5, /* GLOBAL_ATTRIBUTE5 */
3385 moh.global_attribute6, /* GLOBAL_ATTRIBUTE6 */
3386 moh.global_attribute7, /* GLOBAL_ATTRIBUTE7 */
3387 moh.global_attribute8, /* GLOBAL_ATTRIBUTE8 */
3388 moh.global_attribute9, /* GLOBAL_ATTRIBUTE9 */
3389 moh.global_attribute10, /* GLOBAL_ATTRIBUTE10 */
3390 moh.global_attribute11, /* GLOBAL_ATTRIBUTE11 */
3391 moh.global_attribute12, /* GLOBAL_ATTRIBUTE12 */
3392 moh.global_attribute13, /* GLOBAL_ATTRIBUTE13 */
3393 moh.global_attribute14, /* GLOBAL_ATTRIBUTE14 */
3394 moh.global_attribute15, /* GLOBAL_ATTRIBUTE15 */
3395 moh.global_attribute16, /* GLOBAL_ATTRIBUTE16 */
3396 moh.global_attribute17, /* GLOBAL_ATTRIBUTE17 */
3397 moh.global_attribute18, /* GLOBAL_ATTRIBUTE18 */
3398 moh.global_attribute19, /* GLOBAL_ATTRIBUTE19 */
3399 moh.global_attribute20, /* GLOBAL_ATTRIBUTE20 */
3400 'SHIP', /* ORDER_DATE_TYPE_CODE */
3401 OE_UPG_SO_NEW.G_Earliest_Schedule_Limit, /* EARLIEST_SCHEDULE_LIMIT */
3402 OE_UPG_SO_NEW.G_Latest_Schedule_Limit, /* LATEST_SCHEDULE_LIMIT */
3403 moh.payment_type_code, /* PAYMENT_TYPE_CODE */
3404 moh.payment_amount, /* PAYMENT_AMOUNT */
3405 moh.check_number, /* CHECK_NUMBER */
3406 moh.credit_card_code, /* CREDIT_CARD_CODE */
3407 moh.credit_card_holder_name, /* CREDIT_CARD_HOLDER_NAME */
3408 moh.credit_card_number, /* CREDIT_CARD_NUMBER */
3409 moh.credit_card_expiration_date, /* CREDIT_CARD_EXPIRATION_DATE */
3410 moh.credit_card_approval_code, /* CREDIT_CARD_APPROVAL_CODE */
3411 decode(moh.credit_card_approval_code,NULL,NULL,
3412 moh.s1_date), /* CREDIT_CARD_APPROVAL_DATE */
3413 moh.sales_channel_code, /* SALES CHANNEL CODE */
3414 G_ORDER_CATEGORY_CODE, /* ORDER_CATEGORY_CODE */
3415 nvl(moh.cancelled_flag,'N'), /* CANCELLED_FLAG */
3416 moh.open_flag, /* OPEN_FLAG */
3417 moh.booked_flag, /* BOOKED_FLAG */
3418 null, /* MARKETING_SOURCE_CODE_ID */
3419 null, /* TP_CONTEXT */
3420 null, /* TP_ATTRIBUTE1 */
3421 null, /* TP_ATTRIBUTE2 */
3422 null, /* TP_ATTRIBUTE3 */
3423 null, /* TP_ATTRIBUTE4 */
3424 null, /* TP_ATTRIBUTE5 */
3425 null, /* TP_ATTRIBUTE6 */
3426 null, /* TP_ATTRIBUTE7 */
3427 null, /* TP_ATTRIBUTE8 */
3428 null, /* TP_ATTRIBUTE9 */
3429 null, /* TP_ATTRIBUTE10 */
3430 null, /* TP_ATTRIBUTE11 */
3431 null, /* TP_ATTRIBUTE12 */
3432 null, /* TP_ATTRIBUTE13 */
3433 null, /* TP_ATTRIBUTE14 */
3434 null, /* TP_ATTRIBUTE15 */
3435 decode(G_CANCELLED_FLAG,'Y','CANCELLED',
3436 decode(moh.open_flag,'N','CLOSED',
3437 decode(moh.booked_flag,'N','ENTERED',
3438 'Y','BOOKED',NULL))), /* FLOW_STATUS_CODE */
3439 decode(moh.open_flag,'Y','I','Y'), /* UPGRADED_FLAG */
3440 decode(nvl(moh.booked_flag,'-'),'Y',
3441 moh.s1_date,NULL), /* BOOKED_DATE */
3442 moh.org_id, /* SOLD_FROM_ORG_ID */
3443 1,
3444 moh.shipping_instructions,
3445 moh.packing_instructions
3446 );
3447
3448 G_HDR_CANC_FLAG := NULL;
3449 G_HDR_CANC_FLAG := moh.cancelled_flag;
3450
3451 begin
3452 G_canc_rec := NULL;
3453 if nvl(moh.cancelled_Flag,'-') = 'Y' then
3454 select
3455 soc.header_id,
3456 soc.line_id,
3457 soc.created_by,
3458 soc.creation_date,
3459 soc.last_updated_by,
3460 soc.last_update_date,
3461 soc.last_update_login,
3462 soc.program_application_id,
3463 soc.program_id,
3464 soc.program_update_date,
3465 soc.request_id,
3466 soc.cancel_code,
3467 soc.cancelled_by,
3468 soc.cancel_date,
3469 soc.cancelled_quantity,
3470 soc.cancel_comment,
3471 soc.context,
3472 soc.attribute1,
3473 soc.attribute2,
3474 soc.attribute3,
3475 soc.attribute4,
3476 soc.attribute5,
3477 soc.attribute6,
3478 soc.attribute7,
3479 soc.attribute8,
3480 soc.attribute9,
3481 soc.attribute10,
3482 soc.attribute11,
3483 soc.attribute12,
3484 soc.attribute13,
3485 soc.attribute14,
3486 soc.attribute15
3487 into
3488 g_hdr_canc_rec.can_header_id ,
3489 g_hdr_canc_rec.can_line_id ,
3490 g_hdr_canc_rec.can_created_by ,
3491 g_hdr_canc_rec.can_creation_date ,
3492 g_hdr_canc_rec.can_last_updated_by ,
3493 g_hdr_canc_rec.can_last_update_date ,
3494 g_hdr_canc_rec.can_last_update_login ,
3495 g_hdr_canc_rec.can_program_application_id ,
3496 g_hdr_canc_rec.can_program_id ,
3497 g_hdr_canc_rec.can_program_update_date ,
3498 g_hdr_canc_rec.can_request_id ,
3499 g_hdr_canc_rec.can_cancel_code ,
3500 g_hdr_canc_rec.can_cancelled_by ,
3501 g_hdr_canc_rec.can_cancel_date ,
3502 g_hdr_canc_rec.can_cancelled_quantity ,
3503 v_cancel_comment ,
3504 g_hdr_canc_rec.can_context ,
3505 g_hdr_canc_rec.can_attribute1 ,
3506 g_hdr_canc_rec.can_attribute2 ,
3507 g_hdr_canc_rec.can_attribute3 ,
3508 g_hdr_canc_rec.can_attribute4 ,
3509 g_hdr_canc_rec.can_attribute5 ,
3510 g_hdr_canc_rec.can_attribute6 ,
3511 g_hdr_canc_rec.can_attribute7 ,
3512 g_hdr_canc_rec.can_attribute8 ,
3513 g_hdr_canc_rec.can_attribute9 ,
3514 g_hdr_canc_rec.can_attribute10 ,
3515 g_hdr_canc_rec.can_attribute11 ,
3516 g_hdr_canc_rec.can_attribute12 ,
3517 g_hdr_canc_rec.can_attribute13 ,
3518 g_hdr_canc_rec.can_attribute14 ,
3519 g_hdr_canc_rec.can_attribute15
3520 -- G_Hdr_Canc_Rec
3521 from
3522 so_order_cancellations soc
3523 where soc.header_id = g_header_id
3524 and soc.line_Id is null
3525 and rownum =1 ;
3526 g_hdr_canc_rec.can_cancel_comment := v_cancel_comment;
3527 g_hdr_canc_rec.can_cancel_comment:=substrb(g_hdr_canc_rec.can_cancel_comment,1,2000) ;
3528 end if;
3529 exception
3530 when others then
3531 null;
3532 end;
3533
3534 /* ============ Order Lines Creation ===========*/
3535
3536 G_LINE_ID := NULL;
3537 OE_UPG_SO_NEW.Upgrade_Create_Order_Lines;
3538
3539 /* ============ Line Sets Creation (ontupg46.sql )=======*/
3540 -- bug fix 1759900
3541 IF G_OPEN_ATO_MODEL = 1 THEN
3542 OE_UPG_SO_NEW.Insert_Multiple_Models;
3543 END IF;
3544
3545 /* ============ Line Sets Creation (ontupg16.sql )=======*/
3546
3547 -- Changed to conditional execution on 10/23/01 by stsukuma
3548 IF G_OPEN_FLAG = 'Y' THEN
3549 OE_UPG_SO_NEW.Upgrade_Create_Line_Sets;
3550 END IF;
3551
3552 /* ============ Updates After Creation =======*/
3553
3554 OE_UPG_SO_NEW.Update_After_Insert;
3555
3556 /* ============ Update Remnant Flag(ontupg53) =======*/
3557
3558 IF G_OPEN_FLAG = 'Y' THEN
3559
3560 OE_UPG_SO_NEW.Update_remnant_flag;
3561 END IF;
3562
3563 /* ============ Updates for Returns =======*/
3564
3565 IF G_ORDER_CATEGORY_CODE = 'RETURN' THEN
3566 Process_Upgraded_Returns(G_HEADER_ID);
3567 Return_Fulfillment_Sets(G_HEADER_ID);
3568 END IF;
3569
3570 /* ============ Header Level Sales Credits ===========*/
3571 OE_UPG_SO_NEW.Upgrade_Sales_Credits
3572 ( L_level_flag => 'H');
3573
3574 /* ============ Header Level Price Adjustments ===========*/
3575 OE_UPG_SO_NEW.Upgrade_Price_Adjustments ( L_level_flag => 'H');
3576
3577 /* ============ Upgrade Log Handling ===========*/
3578
3579 g_log_rec := NULL;
3580 g_log_rec.header_id := g_header_id;
3581 g_log_rec.mtl_sales_order_id := g_mtl_sales_order_id;
3582
3583 OE_UPG_SO_NEW.Upgrade_Insert_Upgrade_Log;
3584
3585 Update SO_HEADERS_ALL
3586 set upgrade_flag = 'Y'
3587 where header_id = G_HEADER_ID;
3588
3589 G_ERROR_LOCATION := 10;
3590
3591 if G_ERROR_ALERT = 'Y' then
3592 G_ERROR_LOCATION := 11;
3593 ROLLBACK TO HEADER_SAVE_POINT;
3594 v_error_code := sqlcode;
3595 OE_UPG_SO_NEW.upgrade_insert_errors
3596 (
3597 L_header_id => g_header_id,
3598 L_comments => 'Exception tapped: Alert level = '
3599 ||to_char(G_ERROR_LOCATION)||' Code -'
3600 ||to_char(v_error_code)
3601 ||' - Line id '||to_char(g_line_id)
3602 ||' Line detail id'
3603 ||to_char(g_line_rec.line_detail_id)
3604 );
3605 COMMIT;
3606 commit_counter := 0;
3607 G_ERROR_ALERT := 'N';
3608 end if;
3609 exception
3610 when G_EXC_INVALID_COPY_SOURCE THEN
3611 ROLLBACK TO HEADER_SAVE_POINT;
3612 OE_UPG_SO_NEW.upgrade_insert_errors
3613 ( L_header_id => G_HEADER_ID,
3614 L_comments => G_ERROR_MESSAGE
3615 );
3616 Mark_Order_As_Non_Updatable(G_HEADER_ID);
3617 COMMIT;
3618 commit_counter := 0;
3619 G_ERROR_ALERT := 'N';
3620 when G_EXC_INVALID_INTERNAL_SOURCE THEN
3621 ROLLBACK TO HEADER_SAVE_POINT;
3622 OE_UPG_SO_NEW.upgrade_insert_errors
3623 ( L_header_id => G_HEADER_ID,
3624 L_comments => G_ERROR_MESSAGE
3625 );
3626 Mark_Order_As_Non_Updatable(G_HEADER_ID);
3627 COMMIT;
3628 commit_counter := 0;
3629 G_ERROR_ALERT := 'N';
3630 when G_EXC_INVALID_SOURCE_CODE THEN
3631 ROLLBACK TO HEADER_SAVE_POINT;
3632 OE_UPG_SO_NEW.upgrade_insert_errors
3633 ( L_header_id => G_HEADER_ID,
3634 L_comments => G_ERROR_MESSAGE
3635 );
3636 Mark_Order_As_Non_Updatable(G_HEADER_ID);
3637 COMMIT;
3638 commit_counter := 0;
3639 G_ERROR_ALERT := 'N';
3640 when G_EXC_INVALID_ORDER_CATEGORY THEN
3641 ROLLBACK TO HEADER_SAVE_POINT;
3642 OE_UPG_SO_NEW.upgrade_insert_errors
3643 ( L_header_id => G_HEADER_ID,
3644 L_comments => G_ERROR_MESSAGE
3645 );
3646 Mark_Order_As_Non_Updatable(G_HEADER_ID);
3647 COMMIT;
3648 commit_counter := 0;
3649 G_ERROR_ALERT := 'N';
3650 when G_EXC_INVALID_RMA_REFERENCE THEN
3651 ROLLBACK TO HEADER_SAVE_POINT;
3652 OE_UPG_SO_NEW.upgrade_insert_errors
3653 ( L_header_id => G_HEADER_ID,
3654 L_comments => G_ERROR_MESSAGE
3655 );
3656 Mark_Order_As_Non_Updatable(G_HEADER_ID);
3657 COMMIT;
3658 commit_counter := 0;
3659 G_ERROR_ALERT := 'N';
3660 when G_EXC_INVALID_ORIGSYS_LINEREF THEN
3661 ROLLBACK TO HEADER_SAVE_POINT;
3662 OE_UPG_SO_NEW.upgrade_insert_errors
3663 ( L_header_id => G_HEADER_ID,
3664 L_comments => G_ERROR_MESSAGE
3665 );
3666 Mark_Order_As_Non_Updatable(G_HEADER_ID);
3667 COMMIT;
3668 commit_counter := 0;
3669 G_ERROR_ALERT := 'N';
3670 when G_EXC_INVALID_SRC_DOC_LINE THEN
3671 ROLLBACK TO HEADER_SAVE_POINT;
3672 OE_UPG_SO_NEW.upgrade_insert_errors
3673 ( L_header_id => G_HEADER_ID,
3674 L_comments => G_ERROR_MESSAGE
3675 );
3676 Mark_Order_As_Non_Updatable(G_HEADER_ID);
3677 COMMIT;
3678 commit_counter := 0;
3679 G_ERROR_ALERT := 'N';
3680 when others then
3681 /* G_ERROR_LOCATION := 12; */
3682 ROLLBACK TO HEADER_SAVE_POINT;
3683 v_error_code := sqlcode;
3684 OE_UPG_SO_NEW.upgrade_insert_errors
3685 (
3686 L_header_id => G_HEADER_ID,
3687 L_comments => 'Exception tapped: Exception level ='
3688 ||to_char(G_ERROR_LOCATION)||'code -'
3689 ||to_char(v_error_code)
3690 ||' - Line id '||to_char(G_LINE_ID)
3691 ||' Line detail id'
3692 ||to_char(g_line_rec.line_detail_id)
3693 );
3694 COMMIT;
3695 commit_counter := 0;
3696 G_ERROR_ALERT := 'N';
3697 raise;
3698 end;
3699
3700 G_ERROR_LOCATION := 120;
3701 if commit_counter > 100 then
3702 G_ERROR_LOCATION := 121;
3703 commit;
3704 commit_counter := 0;
3705 else
3706 G_ERROR_LOCATION := 122;
3707 commit_counter := commit_counter + 1;
3708 end if;
3709 end loop; /* end loop for Order Headers */
3710 G_ERROR_LOCATION := 13;
3711 commit;
3712
3713 -- dbms_output.put_line('just ending');
3714 End Upgrade_Create_Order_Headers;
3715
3716 Procedure Upgrade_Insert_Lines_History is
3717 --
3718 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3719 --
3720 begin
3721 G_ERROR_LOCATION := 14;
3722 insert into oe_order_lines_history
3723 (
3724 line_id,
3725 org_id,
3726 header_id,
3727 line_type_id,
3728 line_number,
3729 ordered_item,
3730 request_date,
3731 promise_date,
3732 schedule_ship_date,
3733 order_quantity_uom,
3734 pricing_quantity,
3735 pricing_quantity_uom,
3736 cancelled_quantity,
3737 shipped_quantity,
3738 ordered_quantity,
3739 fulfilled_quantity,
3740 shipping_quantity,
3741 shipping_quantity_uom,
3742 delivery_lead_time,
3743 tax_exempt_flag,
3744 tax_exempt_number,
3745 tax_exempt_reason_code,
3746 ship_from_org_id,
3747 ship_to_org_id,
3748 invoice_to_org_id,
3749 deliver_to_org_id,
3750 ship_to_contact_id,
3751 deliver_to_contact_id,
3752 invoice_to_contact_id,
3753 sold_to_org_id,
3754 cust_po_number,
3755 ship_tolerance_above,
3756 ship_tolerance_below,
3757 demand_bucket_type_code,
3758 veh_cus_item_cum_key_id,
3759 rla_schedule_type_code,
3760 customer_dock_code,
3761 customer_job,
3762 customer_production_line,
3763 cust_model_serial_number,
3764 project_id,
3765 task_id,
3766 inventory_item_id,
3767 tax_date,
3768 tax_code,
3769 tax_rate,
3770 demand_class_code,
3771 price_list_id,
3772 pricing_date,
3773 shipment_number,
3774 agreement_id,
3775 shipment_priority_code,
3776 shipping_method_code,
3777 freight_carrier_code,
3778 freight_terms_code,
3779 fob_point_code,
3780 tax_point_code,
3781 payment_term_id,
3782 invoicing_rule_id,
3783 accounting_rule_id,
3784 source_document_type_id,
3785 orig_sys_document_ref,
3786 source_document_id,
3787 orig_sys_line_ref,
3788 source_document_line_id,
3789 reference_line_id,
3790 reference_type,
3791 reference_header_id,
3792 item_revision,
3793 unit_selling_price,
3794 unit_list_price,
3795 tax_value,
3796 context,
3797 attribute1,
3798 attribute2,
3799 attribute3,
3800 attribute4,
3801 attribute5,
3802 attribute6,
3803 attribute7,
3804 attribute8,
3805 attribute9,
3806 attribute10,
3807 attribute11,
3808 attribute12,
3809 attribute13,
3810 attribute14,
3811 attribute15,
3812 global_attribute_category,
3813 global_attribute1,
3814 global_attribute2,
3815 global_attribute3,
3816 global_attribute4,
3817 global_attribute5,
3818 global_attribute6,
3819 global_attribute7,
3820 global_attribute8,
3821 global_attribute9,
3822 global_attribute10,
3823 global_attribute11,
3824 global_attribute12,
3825 global_attribute13,
3826 global_attribute14,
3827 global_attribute15,
3828 global_attribute16,
3829 global_attribute17,
3830 global_attribute18,
3831 global_attribute19,
3832 global_attribute20,
3833 pricing_context,
3834 pricing_attribute1,
3835 pricing_attribute2,
3836 pricing_attribute3,
3837 pricing_attribute4,
3838 pricing_attribute5,
3839 pricing_attribute6,
3840 pricing_attribute7,
3841 pricing_attribute8,
3842 pricing_attribute9,
3843 pricing_attribute10,
3844 industry_context,
3845 industry_attribute1,
3846 industry_attribute2,
3847 industry_attribute3,
3848 industry_attribute4,
3849 industry_attribute5,
3850 industry_attribute6,
3851 industry_attribute7,
3852 industry_attribute8,
3853 industry_attribute9,
3854 industry_attribute10,
3855 industry_attribute11,
3856 industry_attribute12,
3857 industry_attribute13,
3858 industry_attribute14,
3859 industry_attribute15,
3860 industry_attribute16,
3861 industry_attribute17,
3862 industry_attribute18,
3863 industry_attribute19,
3864 industry_attribute20,
3865 industry_attribute21,
3866 industry_attribute22,
3867 industry_attribute23,
3868 industry_attribute24,
3869 industry_attribute25,
3870 industry_attribute26,
3871 industry_attribute27,
3872 industry_attribute28,
3873 industry_attribute29,
3874 industry_attribute30,
3875 creation_date,
3876 created_by,
3877 last_update_date,
3878 last_updated_by,
3879 last_update_login,
3880 program_application_id,
3881 program_id,
3882 program_update_date,
3883 request_id,
3884 configuration_id,
3885 link_to_line_id,
3886 component_sequence_id,
3887 component_code,
3888 config_display_sequence,
3889 sort_order,
3890 item_type_code,
3891 option_number,
3892 option_flag,
3893 dep_plan_required_flag,
3894 visible_demand_flag,
3895 line_category_code,
3896 actual_shipment_date,
3897 reference_customer_trx_line_id,
3898 return_context,
3899 return_attribute1,
3900 return_attribute2,
3901 return_attribute3,
3902 return_attribute4,
3903 return_attribute5,
3904 return_attribute6,
3905 return_attribute7,
3906 return_attribute8,
3907 return_attribute9,
3908 return_attribute10,
3909 return_attribute11,
3910 return_attribute12,
3911 return_attribute13,
3912 return_attribute14,
3913 return_attribute15,
3914 intmed_ship_to_org_id,
3915 intmed_ship_to_contact_id,
3916 actual_arrival_date,
3917 ato_line_id,
3918 auto_selected_quantity,
3919 component_number,
3920 earliest_acceptable_date,
3921 explosion_date,
3922 latest_acceptable_date,
3923 model_group_number,
3924 schedule_arrival_date,
3925 ship_model_complete_flag,
3926 schedule_status_code,
3927 return_reason_code,
3928 salesrep_id,
3929 split_from_line_id,
3930 cust_production_seq_num,
3931 authorized_to_ship_flag,
3932 invoice_interface_status_code,
3933 ship_set_id,
3934 arrival_set_id,
3935 hist_comments,
3936 hist_type_code,
3937 reason_code,
3938 hist_created_by,
3939 hist_creation_date,
3940 source_type_code,
3941 booked_flag,
3942 fulfilled_flag,
3943 sold_from_org_id,
3944 top_model_line_id,
3945 cancelled_flag,
3946 open_flag,
3947 over_ship_reason_code,
3948 over_ship_resolved_flag,
3949 item_identifier_type,
3950 commitment_id,
3951 shipping_interfaced_flag,
3952 credit_invoice_line_id,
3953 end_item_unit_number,
3954 mfg_component_sequence_id,
3955 config_header_id,
3956 config_rev_nbr,
3957 shipping_instructions,
3958 packing_instructions,
3959 invoiced_quantity,
3960 customer_trx_line_id,
3961 split_by,
3962 line_set_id,
3963 tp_context,
3964 tp_attribute1,
3965 tp_attribute2,
3966 tp_attribute3,
3967 tp_attribute4,
3968 tp_attribute5,
3969 tp_attribute6,
3970 tp_attribute7,
3971 tp_attribute8,
3972 tp_attribute9,
3973 tp_attribute10,
3974 tp_attribute11,
3975 tp_attribute12,
3976 tp_attribute13,
3977 tp_attribute14,
3978 tp_attribute15,
3979 fulfillment_method_code,
3980 service_reference_type_code,
3981 service_reference_line_id,
3982 service_reference_system_id,
3983 ordered_item_id,
3984 service_number,
3985 service_duration,
3986 service_start_date,
3987 re_source_flag,
3988 flow_status_code,
3989 service_end_date,
3990 service_coterminate_flag,
3991 shippable_flag,
3992 order_source_id,
3993 orig_sys_shipment_ref,
3994 change_sequence,
3995 drop_ship_flag,
3996 customer_line_number,
3997 customer_shipment_number,
3998 customer_item_net_price,
3999 customer_payment_term_id,
4000 first_ack_date,
4001 first_ack_code,
4002 last_ack_code,
4003 last_ack_date,
4004 planning_priority,
4005 service_txn_comments,
4006 service_period,
4007 unit_selling_percent,
4008 unit_list_percent,
4009 unit_percent_base_price,
4010 model_remnant_flag,
4011 service_txn_reason_code,
4012 calculate_price_flag,
4013 revenue_amount
4014 )
4015 values
4016 (
4017 g_line_id, /* LINE_ID */
4018 g_line_rec.org_id, /* ORG_ID */
4019 g_line_rec.header_id, /* HEADER_ID */
4020 g_line_rec.line_type_id, /* LINE_TYPE_ID, */
4021 g_line_rec.line_number, /* LINE_NUMBER */
4022 null, /* ordered_item, */
4023 g_line_rec.date_requested_current, /* REQUEST_DATE */
4024 g_line_rec.promise_date, /* PROMISE_DATE */
4025 g_line_rec.schedule_date, /* SCHEDULE_SHIP_DATE */
4026 nvl(r_uom_code,g_line_rec.unit_code), /* ORDER_QUANTITY_UOM */
4027 g_line_rec.ordered_quantity, /* PRICING_QUANTITY */
4028 nvl(r_uom_code,g_line_rec.unit_code), /* PRICING_QUANTITY_UOM */
4029 decode(G_ORD_CANC_FLAG,'Y',G_canc_rec.can_cancelled_quantity,
4030 decode(g_hdr_canc_flag,'Y', g_line_rec.cancelled_quantity,
4031 decode(g_line_id_Change_flag,'Y', g_line_rec.cancelled_quantity,0))),
4032 /* CANCELLED_QUANTITY */
4033 g_line_rec.shipped_quantity, /* SHIPPED_QUANTITY */
4034 decode(g_hdr_canc_flag,'Y',0,
4035 nvl(g_line_rec.ordered_quantity,0)), /* ORDERED_QUANTITY */
4036 g_line_rec.fulfilled_quantity, /* FULFILLED_QUANTITY */
4037 g_line_rec.shipped_quantity, /* SHIPPING_QUANTITY */
4038 nvl(r_uom_code,
4039 g_line_rec.shipping_quantity_uom), /* SHIPPING_QUANTITY_UOM */
4040 null, /* DELIVERY_LEAD_TIME */
4041 G_tax_exempt_flag, /* TAX_EXEMPT_FLAG */
4042 g_line_rec.tax_exempt_number, /* TAX_EXEMPT_NUMBER */
4043 g_line_rec.tax_exempt_reason_code, /* TAX_EXEMPT_REASON_CODE */
4044 g_line_rec.warehouse_id, /* SHIP_FROM_ORG_ID */
4045 g_line_rec.ship_to_site_use_id, /* SHIP_TO_ORG_ID */
4046 g_invoice_to_site_use_id, /* INVOICE_TO_ORG_ID */
4047 null, /* DELIVER_TO_ORG_ID */
4048 g_line_rec.ship_to_contact_id, /* SHIP_TO_CONTACT_ID */
4049 null, /* DELIVER_TO_CONTACT_ID */
4050 null, /* INVOICE_TO_CONTACT_ID */
4051 G_customer_id, /* SOLD_TO_ORG_ID */
4052 G_Purchase_Order_Num, /* CUST_PO_NUMBER */
4053 null, /* SHIP_TOLERANCE_ABOVE */
4054 null, /* SHIP_TOLERANCE_BELOW */
4055 decode(G_AUTO_FLAG,'Y','DAY',NULL), /* DEMAND_BUCKET_TYPE_CODE */
4056 decode(G_AUTO_FLAG,'Y',-1,NULL), /* VEH_CUS_ITEM_CUM_KEY_ID */
4057 g_line_rec.rla_schedule_type_code, /* RLA_SCHEDULE_TYPE_CODE */
4058 g_line_rec.customer_dock_code, /* CUSTOMER_DOCK_CODE */
4059 g_line_rec.customer_job, /* CUSTOMER_JOB */
4060 g_line_rec.customer_production_line, /* CUSTOMER_PRODUCTION_LINE */
4061 g_line_rec.customer_model_serial_number, /* CUST_MODEL_SERIAL_NUMBER */
4062 g_line_rec.project_id, /* PROJECT_ID */
4063 g_line_rec.task_id, /* TASK_ID */
4064 nvl(r_inventory_item_id,g_line_rec.inventory_item_id), /* INVENTORY_ITEM_ID */
4065 g_line_rec.tax_date, /* TAX_DATE */
4066 g_line_rec.tax_code, /* TAX_CODE */
4067 null, /* TAX_RATE */
4068 g_line_rec.demand_class_code, /* DEMAND_CLASS_CODE */
4069 g_line_rec.price_list_id, /* PRICE_LIST_ID */
4070 null, /* PRICING_DATE */
4071 r_shipment_number, /* SHIPMENT_NUMBER */
4072 g_line_rec.agreement_id, /* AGREEMENT_ID */
4073 g_line_rec.shipment_priority_code, /* SHIPMENT_PRIORITY_CODE */
4074 g_line_rec.ship_method_code, /* SHIPPPING_METHOD_CODE */
4075 g_line_rec.ship_method_code, /* FREIGHT_CARRIER_CODE */
4076 G_freight_terms_code, /* FREIGHT_TERMS_CODE */
4077 G_FOB_POINT_CODE, /* FOB_POINT_CODE */
4078 'INVOICE', /* TAX_POINT_CODE */
4079 g_line_rec.terms_id, /* PAYMENT_TERM_ID */
4080 g_line_rec.invoicing_rule_id, /* INVOICING_RULE_ID */
4081 g_line_rec.accounting_rule_id, /* ACCOUNTING_RULE_ID */
4082
4083 g_line_rec.source_document_type_id, /* SOURCE_DOCUMENT_TYPE_ID */
4084 null, /* ORIG_SYS_DOCUMENT_REF */
4085 g_line_rec.source_document_id, /* SOURCE_DOCUMENT_ID */
4086 g_line_rec.original_system_line_reference, /* ORIG_SYS_LINE_REFERENCE */
4087 g_line_rec.source_document_line_id, /* SOURCE_DOCUMENT_LINE_ID */
4088 v_reference_line_id, /* REFERENCE_LINE_ID */
4089 g_line_rec.return_reference_type_code, /* REFERENCE_TYPE */
4090 v_reference_header_id, /* REFERENCE_HEADER_ID */
4091 null, /* ITEM_REVISION */
4092 g_line_rec.selling_price, /* SELLING_PRICE */
4093 g_line_rec.list_price, /* LIST_PRICE */
4094 null, /* TAX_VALUE */
4095 g_line_rec.context, /* CONTEXT */
4096 g_line_rec.attribute1, /* ATTRIBUTE1 */
4097 g_line_rec.attribute2, /* ATTRIBUTE2 */
4098 g_line_rec.attribute3, /* ATTRIBUTE3 */
4099 g_line_rec.attribute4, /* ATTRIBUTE4 */
4100 g_line_rec.attribute5, /* ATTRIBUTE5 */
4101 g_line_rec.attribute6, /* ATTRIBUTE6 */
4102 g_line_rec.attribute7, /* ATTRIBUTE7 */
4103 g_line_rec.attribute8, /* ATTRIBUTE8 */
4104 g_line_rec.attribute9, /* ATTRIBUTE9 */
4105 g_line_rec.attribute10, /* ATTRIBUTE10 */
4106 g_line_rec.attribute11, /* ATTRIBUTE11 */
4107 g_line_rec.attribute12, /* ATTRIBUTE12 */
4108 g_line_rec.attribute13, /* ATTRIBUTE13 */
4109 g_line_rec.attribute14, /* ATTRIBUTE14 */
4110 g_line_rec.attribute15, /* ATTRIBUTE15 */
4111 g_line_rec.global_attribute_category, /* GLOBAL_ATTRIBUTE_CATEGORY */
4112 g_line_rec.global_attribute1, /* GLOBAL_ATTRIBUTE1 */
4113 g_line_rec.global_attribute2, /* GLOBAL_ATTRIBUTE2 */
4114 g_line_rec.global_attribute3, /* GLOBAL_ATTRIBUTE3 */
4115 g_line_rec.global_attribute4, /* GLOBAL_ATTRIBUTE4 */
4116 g_line_rec.global_attribute5, /* GLOBAL_ATTRIBUTE5 */
4117 g_line_rec.global_attribute6, /* GLOBAL_ATTRIBUTE6 */
4118 g_line_rec.global_attribute7, /* GLOBAL_ATTRIBUTE7 */
4119 g_line_rec.global_attribute8, /* GLOBAL_ATTRIBUTE8 */
4120 g_line_rec.global_attribute9, /* GLOBAL_ATTRIBUTE9 */
4121 g_line_rec.global_attribute10, /* GLOBAL_ATTRIBUTE10 */
4122 g_line_rec.global_attribute11, /* GLOBAL_ATTRIBUTE11 */
4123 g_line_rec.global_attribute12, /* GLOBAL_ATTRIBUTE12 */
4124 g_line_rec.global_attribute13, /* GLOBAL_ATTRIBUTE13 */
4125 g_line_rec.global_attribute14, /* GLOBAL_ATTRIBUTE14 */
4126 g_line_rec.global_attribute15, /* GLOBAL_ATTRIBUTE15 */
4127 g_line_rec.global_attribute16, /* GLOBAL_ATTRIBUTE16 */
4128 g_line_rec.global_attribute17, /* GLOBAL_ATTRIBUTE17 */
4129 g_line_rec.global_attribute18, /* GLOBAL_ATTRIBUTE18 */
4130 g_line_rec.global_attribute19, /* GLOBAL-ATTRIBUTE19 */
4131 g_line_rec.global_attribute20, /* GLOBAL_ATTRIBUTE20 */
4132 g_line_rec.pricing_context, /* PRICING_CONTEXT */
4133 g_line_rec.pricing_attribute1, /* PRICING_ATTRIBUTE1 */
4134 g_line_rec.pricing_attribute2, /* PRICING_ATTRIBUTE2 */
4135 g_line_rec.pricing_attribute3, /* PRICING_ATTRIBUTE3 */
4136 g_line_rec.pricing_attribute4, /* PRICING_ATTRIBUTE4 */
4137 g_line_rec.pricing_attribute5, /* PRICING_ATTRIBUTE5 */
4138 g_line_rec.pricing_attribute6, /* PRICING_ATTRIBUTE6 */
4139 g_line_rec.pricing_attribute7, /* PRICING_ATTRIBUTE7 */
4140 g_line_rec.pricing_attribute8, /* PRICING_ATTRIBUTE8 */
4141 g_line_rec.pricing_attribute9, /* PRICING_ATTRIBUTE9 */
4142 g_line_rec.pricing_attribute10, /* PRICING_ATTRIBUTE10*/
4143 g_line_rec.industry_context, /* INDUSTRY_CONTEXT */
4144 g_line_rec.industry_attribute1, /* INDUSTRY_ATTRIBUTE1 */
4145 decode(G_AUTO_FLAG,'Y',NULL,
4146 g_line_rec.industry_attribute2), /* INDUSTRY_ATTRIBUTE2 */
4147 decode(G_AUTO_FLAG,'Y',NULL,
4148 g_line_rec.industry_attribute3), /* INDUSTRY_ATTRIBUTE3 */
4149 decode(G_AUTO_FLAG,'Y',NULL,
4150 g_line_rec.industry_attribute4), /* INDUSTRY_ATTRIBUTE4 */
4151 decode(G_AUTO_FLAG,'Y',NULL,
4152 g_line_rec.industry_attribute5), /* INDUSTRY_ATTRIBUTE5 */
4153 decode(G_AUTO_FLAG,'Y',NULL,
4154 g_line_rec.industry_attribute6), /* INDUSTRY_ATTRIBUTE6 */
4155 decode(G_AUTO_FLAG,'Y',NULL,
4156 g_line_rec.industry_attribute7), /* INDUSTRY_ATTRIBUTE7 */
4157 decode(G_AUTO_FLAG,'Y',NULL,
4158 g_line_rec.industry_attribute8), /* INDUSTRY_ATTRIBUTE8 */
4159 decode(G_AUTO_FLAG,'Y',NULL,
4160 g_line_rec.industry_attribute9), /* INDUSTRY_ATTRIBUTE9 */
4161 decode(G_AUTO_FLAG,'Y',NULL,
4162 g_line_rec.industry_attribute10), /* INDUSTRY_ATTRIBUTE10 */
4163 decode(G_AUTO_FLAG,'Y',NULL,
4164 g_line_rec.industry_attribute11), /* INDUSTRY_ATTRIBUTE11 */
4165 decode(G_AUTO_FLAG,'Y',NULL,
4166 g_line_rec.industry_attribute12), /* INDUSTRY_ATTRIBUTE12 */
4167 decode(G_AUTO_FLAG,'Y',NULL,
4168 g_line_rec.industry_attribute13), /* INDUSTRY_ATTRIBUTE13 */
4169 decode(G_AUTO_FLAG,'Y',NULL,
4170 g_line_rec.industry_attribute14), /* INDUSTRY_ATTRIBUTE14 */
4171 decode(G_AUTO_FLAG,'Y',NULL,
4172 g_line_rec.industry_attribute15), /* INDUSTRY_ATTRIBUTE15 */
4173 NULL, /* INDUSTRY_ATTRIBUTE16 */
4174 NULL, /* INDUSTRY_ATTRIBUTE17 */
4175 NULL, /* INDUSTRY_ATTRIBUTE18 */
4176 NULL, /* INDUSTRY_ATTRIBUTE19 */
4177 NULL, /* INDUSTRY_ATTRIBUTE20 */
4178 NULL, /* INDUSTRY_ATTRIBUTE21 */
4179 NULL, /* INDUSTRY_ATTRIBUTE22 */
4180 NULL, /* INDUSTRY_ATTRIBUTE23 */
4181 NULL, /* INDUSTRY_ATTRIBUTE24 */
4182 NULL, /* INDUSTRY_ATTRIBUTE25 */
4183 NULL, /* INDUSTRY_ATTRIBUTE26 */
4184 NULL, /* INDUSTRY_ATTRIBUTE27 */
4185 NULL, /* INDUSTRY_ATTRIBUTE28 */
4186 NULL, /* INDUSTRY_ATTRIBUTE29 */
4187 NULL, /* INDUSTRY_ATTRIBUTE30 */
4188 g_line_rec.creation_date, /* CREATION_DATE */
4189 g_line_rec.created_by, /* CREATED_BY */
4190 g_line_rec.last_update_date, /* LAST_UPDATE_DATE */
4191 g_line_rec.last_updated_by, /* LAST_UPDATED_BY */
4192 g_line_rec.last_update_login, /* LAST_UPDATE_LOGIN */
4193 nvl(g_line_rec.program_application_id,0), /* PROGRAM_APPLICATION_ID */
4194 g_line_rec.program_id, /* PROGRAM_ID */
4195 g_line_rec.program_update_date, /* PROGRAM_UPDATE_DATE */
4196 g_line_rec.request_id, /* REQUEST_ID */
4197 g_line_rec.parent_line_id, /* CONFIGURATION_ID */
4198 g_line_rec.link_to_line_id, /* LINK_TO_LINE_ID */
4199 g_line_rec.component_sequence_id, /* COMPONENT_SEQUENCE_ID */
4200 g_line_rec.component_code, /* COMPONENT_CODE */
4201 null, /* CONFIG_DISPLAY_SEQUENCE */
4202 g_line_rec.sort_order, /* SORT_ORDER, */
4203 g_line_rec.item_type_code, /* ITEM_TYPE_CODE */
4204 null, /* OPTION_NUMBER */
4205 g_line_rec.option_flag, /* OPTION_FLAG, */
4206 g_line_rec.dep_plan_required_flag, /* DEP_PLAN_REQUIRED_FLAG */
4207 g_line_rec.visible_demand_flag, /* VISIBLE_DEMAND_FLAG */
4208 g_line_rec.line_category_code, /* LINE_CATEGORY_CODE */
4209 g_line_rec.actual_departure_date, /* ACTUAL_SHIPMENT_DATE */
4210 decode(g_line_rec.line_type_code,'RETURN',
4211 decode(g_line_rec.return_reference_type_code,
4212 'INVOICE',g_line_rec.return_reference_id,NULL),
4213 NULL), /* REFERENCE_CUSTOMER_TRX_LINE_ID */
4214 g_line_rec.return_reference_type_Code, /* RETURN_CONTEXT */
4215 decode(g_line_rec.line_type_code,'RETURN',
4216 decode(g_line_rec.return_reference_type_code,
4217 'INVOICE',v_customer_trx_id,
4218 v_reference_header_id),NULL), /* RETURN_ATTRIBUTE1 */
4219 decode(g_line_rec.line_type_code,'RETURN',
4220 decode(g_line_rec.return_reference_type_code,
4221 'INVOICE',g_line_rec.return_reference_id,
4222 v_reference_line_id),NULL), /* RETURN_ATTRIBUTE2 */
4223 null, /* RETURN_ATTRIBUTE3 */
4224 null, /* RETURN_ATTRIBUTE4 */
4225 null, /* RETURN_ATTRIBUTE5 */
4226 null, /* RETURN_ATTRIBUTE6 */
4227 null, /* RETURN_ATTRIBUTE7 */
4228 null, /* RETURN_ATTRIBUTE8 */
4229 null, /* RETURN_ATTRIBUTE9 */
4230 null, /* RETURN_ATTRIBUTE10 */
4231 null, /* RETURN_ATTRIBUTE11 */
4232 null, /* RETURN_ATTRIBUTE12 */
4233 null, /* RETURN_ATTRIBUTE13 */
4234 null, /* RETURN_ATTRIBUTE14 */
4235 null, /* RETURN_ATTRIBUTE15 */
4236 g_line_rec.intermediate_ship_to_id, /* intmed_ship_to_org_id, */
4237 g_line_rec.ship_to_contact_id, /* intmed_ship_to_contact_id, */
4238 null, /* actual_arrival_date, */
4239 g_line_rec.ato_line_id, /* ATO_LINE_ID */
4240 null, /* auto_selected_quantity, */
4241 null, /* component_number, */
4242 null, /* earliest_acceptable_date, */
4243 g_line_rec.standard_component_freeze_date, /* explosion_date, */
4244 g_line_rec.latest_acceptable_date, /* latest_acceptable_date, */
4245 null, /* model_group_number, */
4246 null, /* schedule_arrival_date, */
4247 g_line_rec.ship_model_complete_flag, /* ship_model_complete_flag, */
4248 g_line_rec.schedule_status_code, /* schedule_status_code, */
4249 g_line_rec.transaction_reason_code, /* return_reason_code */
4250 g_salesrep_id, /* salesrep_id */
4251 g_line_rec.split_from_line_id, /* split_from_line_id */
4252 g_line_rec.planning_prod_seq_number, /* cust_production_seq_num */
4253 decode(G_AUTO_FLAG,'Y','Y',NULL), /* authorized_to_ship_flag */
4254 g_line_rec.invoice_interface_status_code, /* invoice_interface_status_code */
4255 decode(g_include_ship_set,'N',null,
4256 decode(g_line_rec.cancelled_flag,'Y',null,g_set_id)), /* Ship_Set_Id */
4257 null, /* Arrival_Set_Id */
4258 g_canc_rec.can_cancel_comment, /* Hist_Comments */
4259 'CANCELLATION', /* Hist_Type_Code */
4260 g_canc_rec.can_cancel_code, /* Reason_Code */
4261 g_canc_rec.can_cancelled_by, /* Hist_Created_By */
4262 g_canc_rec.can_cancel_date, /* Hist_Creation_Date */
4263 g_line_rec.source_type_code, /* Source_Type_Code */
4264 g_line_rec.Booked_Flag, /* booked_Flag */
4265 g_line_rec.fulfilled_flag, /* fulfilled_flag */
4266 g_line_rec.org_id, /* sold_from_org_id, */
4267 g_line_rec.parent_line_id, /* top_model_line_id, */
4268 g_line_rec.cancelled_flag, /* cancelled_flag, */
4269 g_line_rec.open_flag, /* open_flag, */
4270 null, /* over_ship_reason_code, */
4271 null, /* over_ship_resolved_flag, */
4272 decode(nvl(g_line_rec.customer_item_id,-1),
4273 -1,'INT','CUST'), /* item_identifier_type, */
4274 g_line_rec.commitment_id, /* commitment_id, */
4275 g_line_rec.shipping_interfaced_flag, /* shipping_interfaced_flag, */
4276 g_line_rec.credit_invoice_line_id, /* credit_invoice_line_id, */
4277 null, /* end_item_unit_number, */
4278 null, /* mfg_component_sequence_id, */
4279 null, /* config_header_id, */
4280 null, /* config_rev_nbr, */
4281 g_shipping_instructions, /* shipping_instructions, */
4282 g_packing_instructions, /* packing_instructions, */
4283 g_line_rec.invoiced_quantity, /* invoiced_quantity, */
4284 null, /* customer_trx_line_id, */
4285 null, /* split_by, */
4286 null, /* line_set_id, */
4287 g_line_rec.tp_context, /* tp_context */
4288 g_line_rec.tp_attribute1, /* tp_attribute1 */
4289 g_line_rec.tp_attribute2, /* tp_attribute2 */
4290 g_line_rec.tp_attribute3, /* tp_attribute3 */
4291 g_line_rec.tp_attribute4, /* tp_attribute4 */
4292 g_line_rec.tp_attribute5, /* tp_attribute5 */
4293 g_line_rec.tp_attribute6, /* tp_attribute6 */
4294 g_line_rec.tp_attribute7, /* tp_attribute7 */
4295 g_line_rec.tp_attribute8, /* tp_attribute8 */
4296 g_line_rec.tp_attribute9, /* tp_attribute9 */
4297 g_line_rec.tp_attribute10, /* tp_attribute10 */
4298 g_line_rec.tp_attribute11, /* tp_attribute11 */
4299 g_line_rec.tp_attribute12, /* tp_attribute12 */
4300 g_line_rec.tp_attribute13, /* tp_attribute13 */
4301 g_line_rec.tp_attribute14, /* tp_attribute14 */
4302 g_line_rec.tp_attribute15, /* tp_attribute15 */
4303 g_line_rec.fulfillment_method_code, /* fulfillment_method_code, */
4304 g_line_rec.service_reference_type_code, /* service_reference_type_code, */
4305 g_line_rec.service_reference_line_id, /* service_reference_line_id, */
4306 g_line_rec.service_reference_system_id, /* service_reference_system_id, */
4307 decode(nvl(g_line_rec.customer_item_id,-1),
4308 -1,g_line_rec.inventory_item_id,
4309 g_line_rec.customer_item_id), /* ordered_item_id */
4310 g_line_rec.service_number, /* service_number, */
4311 g_line_rec.service_duration, /* service_duration, */
4312 g_line_rec.service_start_date, /* service_start_date, */
4313 g_line_rec.re_source_flag, /* re_source_flag, */
4314 g_line_rec.flow_status_code, /* flow_status_code, */
4315 g_line_rec.service_end_date, /* service_end_date, */
4316 g_line_rec.service_coterminate_flag, /* service_coterminate_flag, */
4317 g_line_rec.shippable_flag, /* shippable_flag, */
4318 nvl(G_ORDER_SOURCE_ID,0), /* order_source_id, */
4319 null, /* orig_sys_shipment_ref, */
4320 null, /* change_sequence, */
4321 null, /* drop_ship_flag, */
4322 null, /* customer_line_number, */
4323 null, /* customer_shipment_number, */
4324 null, /* customer_item_net_price, */
4325 null, /* customer_payment_term_id, */
4326 null, /* first_ack_date, */
4327 null, /* first_ack_code, */
4328 null, /* last_ack_code, */
4329 null, /* last_ack_date, */
4330 g_line_rec.planning_priority, /* planning_priority, */
4331 g_line_rec.service_txn_comments, /* service_txn_comments, */
4332 g_line_rec.service_period, /* service_period, */
4333 g_line_rec.selling_percent, /* unit_selling_percent, */
4334 g_line_rec.list_percent, /* unit_list_percent, */
4335 g_line_rec.percent_base_price, /* unit_percent_base_price, */
4336 null, /* model_remnant_flag, */
4337 g_line_rec.service_txn_reason_code, /* service_txn_reason_code, */
4338 g_line_rec.calculate_price_flag, /* calculate_price_flag, */
4339 g_line_rec.revenue_amount /* revenue_amount, */
4340 );
4341 G_ERROR_LOCATION := 15;
4342 End Upgrade_Insert_Lines_History;
4343
4344 Procedure Upgrade_Insert_Upgrade_log
4345 is
4346 --
4347 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4348 --
4349 begin
4350
4351 G_ERROR_LOCATION := 16;
4352 insert into oe_upgrade_log
4353 (
4354 header_id,
4355 old_line_id,
4356 old_line_detail_id,
4357 new_line_id,
4358 picking_line_id,
4359 new_line_number,
4360 mtl_sales_order_id,
4361 return_qty_available,
4362 comments,
4363 creation_date,
4364 delivery
4365 )
4366 values
4367 (
4368 g_log_rec.header_id, /* HEADER_ID */
4369 g_log_rec.old_line_id, /* OLD_LINE_ID */
4370 g_log_rec.old_line_detail_id, /* OLD_LINE_DETAIL_ID */
4371 g_log_rec.new_line_id, /* NEW_LINE_ID */
4372 g_log_rec.picking_line_id, /* PICKING_LINE_ID */
4373 g_log_rec.new_line_number, /* NEW_LINE_NUMBER */
4374 g_log_rec.mtl_sales_order_id, /* MTL_SALES_ORDER_ID */
4375 g_log_rec.return_qty_available, /* RETURN_QTY_AVAILABLE */
4376 g_log_rec.comments, /* COMMENTS */
4377 sysdate, /* CREATION_DATE */
4378 g_log_rec.delivery /* DELIVERY */
4379 );
4380 G_ERROR_LOCATION := 17;
4381
4382 End Upgrade_Insert_Upgrade_log;
4383
4384 Procedure Upgrade_Process_Distbns
4385 ( L_total_slabs IN number,
4386 L_type IN varchar2)
4387 is
4388 v_type varchar2(1);
4389 cursor RDis
4390 is
4391 select
4392 sha.header_id
4393 from
4394 so_headers_all sha
4395 where
4396 ( sha.upgrade_flag = 'N' and (sha.order_category = 'RMA' and v_type = 'R') ) or
4397 ( sha.upgrade_flag = 'N' and (sha.order_category <> 'RMA' and v_type = 'O' ) ) or
4398 ( nvl(sha.upgrade_flag,'N') in ('N','X') and v_type = 'M') or
4399 ( sha.open_flag = 'Y' and sha.upgrade_flag = 'Y' and v_type = 'W')
4400 order by sha.header_id;
4401
4402 v_total_headers number;
4403 v_min_header number;
4404 v_max_header number;
4405 v_counter number;
4406 v_gap number;
4407 v_slab_count number;
4408 v_slab_start number;
4409 v_slab_end number;
4410 v_dis_header_id number;
4411 v_start_flag number;
4412 v_total_slabs number;
4413
4414 --
4415 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4416 --
4417 Begin
4418 v_type := L_type;
4419
4420 delete oe_upgrade_distribution
4421 where line_type = v_type;
4422 commit;
4423
4424
4425 begin
4426 select
4427 count(*),
4428 nvl(min(sha.header_id),0),
4429 nvl(max(sha.header_id),0)
4430 into
4431 v_total_headers,
4432 v_min_header,
4433 v_max_header
4434 from
4435 so_headers_all sha
4436 where
4437 ( sha.upgrade_flag = 'N' and (sha.order_category = 'RMA' and v_type = 'R') ) or
4438 ( sha.upgrade_flag = 'N' and (sha.order_category <> 'RMA' and v_type = 'O') ) or
4439 ( nvl(sha.upgrade_flag,'N') in ('N','X') and v_type = 'M') or
4440 ( sha.open_flag = 'Y' and sha.upgrade_flag = 'Y' and v_type = 'W');
4441 exception
4442 when others then
4443 null;
4444 end;
4445
4446 if v_total_headers < 500 or l_total_slabs = 1 then
4447
4448 OE_UPG_SO_NEW.Upgrade_Insert_Distbn_Record
4449 (
4450 L_slab => 1,
4451 L_start_header_id => v_min_header,
4452 L_end_Header_id => v_max_header,
4453 L_type_var => v_type
4454 );
4455
4456 else
4457 v_max_header := 0;
4458 v_min_header := 0;
4459 v_total_slabs := L_total_slabs;
4460 v_counter := 0;
4461 v_start_flag := 0;
4462 v_slab_count := 0;
4463 v_gap := round(v_total_headers / v_total_slabs);
4464
4465 for MRdis in Rdis loop
4466
4467 v_dis_header_id := MRdis.header_id;
4468 v_counter := v_counter + 1;
4469
4470 if v_start_flag = 0 then
4471 v_start_flag := 1;
4472 v_min_header := MRdis.header_id;
4473 v_max_header := NULL;
4474 v_slab_count := v_slab_count + 1;
4475 end if;
4476
4477 if v_counter = v_gap and v_slab_count < v_total_slabs then
4478 v_max_header := MRdis.header_id;
4479
4480 OE_UPG_SO_NEW.Upgrade_Insert_Distbn_Record
4481 (
4482 L_slab => v_slab_count,
4483 L_start_header_id => v_min_header,
4484 L_end_Header_id => v_max_header,
4485 L_type_var => v_type
4486 );
4487
4488 v_counter := 0;
4489 v_start_flag := 0;
4490 end if;
4491
4492 end loop;
4493 v_max_header := v_dis_header_id;
4494
4495 OE_UPG_SO_NEW.Upgrade_Insert_Distbn_Record
4496 (
4497 L_slab => v_slab_count,
4498 L_start_header_id => v_min_header,
4499 L_end_Header_id => v_max_header ,
4500 L_type_var => v_type
4501 );
4502
4503 commit;
4504 end if;
4505 commit;
4506
4507 End Upgrade_Process_Distbns;
4508
4509
4510 PROCEDURE upgrade_inst_detail_distbns
4511 (
4512 p_number_of_slabs IN NUMBER
4513 )
4514 IS
4515
4516 TYPE line_service_cursor_type IS REF CURSOR;
4517
4518 line_service_detail_count line_service_cursor_type;
4519
4520 -- Dynamic SQL used because the select based column expressions
4521 -- did not compile when used directly as a cursor definition.
4522 -- This cursor allows us to determine the actual slab distribution
4523 -- by doing only one index scan of the primary key index for this table
4524
4525 l_cursor_stmt VARCHAR2(2000) :=
4526 'select ' ||
4527 ' line_service_detail_id,'||
4528 ' (select count(1) from so_line_service_details),' ||
4529 ' (select min(line_service_detail_id) from so_line_service_details),' ||
4530 ' (select max(line_service_detail_id) from so_line_service_details)' ||
4531 ' from so_line_service_details' ||
4532 ' order by line_service_detail_id';
4533
4534 l_total_slabs NUMBER := p_number_of_slabs;
4535 l_current_slab NUMBER := 1;
4536 l_record_counter NUMBER := 0;
4537 l_records_per_slab NUMBER := 0;
4538
4539 l_line_service_detail_id NUMBER := NULL;
4540 l_row_count NUMBER := NULL;
4541 l_min_id NUMBER := NULL;
4542 l_max_id NUMBER := NULL;
4543
4544 l_starting_id NUMBER := NULL;
4545 l_ending_id NUMBER := NULL;
4546
4547 --
4548 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4549 --
4550 BEGIN
4551
4552 DELETE FROM oe_upgrade_distribution
4553 WHERE line_type = 'I';
4554
4555 OPEN line_service_detail_count FOR l_cursor_stmt;
4556
4557 FETCH line_service_detail_count INTO
4558 l_line_service_detail_id, l_row_count, l_min_id, l_max_id;
4559
4560 IF line_service_detail_count%NOTFOUND THEN
4561
4562 NULL;
4563
4564 ELSIF l_row_count < 500 OR l_total_slabs = 1 THEN
4565
4566 oe_upg_so_new.upgrade_insert_distbn_record
4567 (
4568 l_slab => 1,
4569 l_start_header_id => l_min_id,
4570 l_end_header_id => l_max_id,
4571 l_type_var => 'I'
4572 );
4573
4574 ELSE
4575
4576 l_records_per_slab := Round(l_row_count / l_total_slabs);
4577 l_starting_id := l_line_service_detail_id;
4578 l_record_counter := l_record_counter + 1;
4579
4580 LOOP
4581
4582 IF (l_record_counter = l_records_per_slab
4583 AND l_current_slab < l_total_slabs) THEN
4584
4585 oe_upg_so_new.upgrade_insert_distbn_record
4586 (
4587 l_slab => l_current_slab,
4588 l_start_header_id => l_starting_id,
4589 l_end_header_id => l_line_service_detail_id,
4590 l_type_var => 'I'
4591 );
4592
4593 l_current_slab := l_current_slab + 1;
4594 l_record_counter := 0;
4595
4596 FETCH line_service_detail_count INTO
4597 l_line_service_detail_id, l_row_count, l_min_id, l_max_id;
4598 EXIT WHEN line_service_detail_count%notfound;
4599
4600 l_starting_id := l_line_service_detail_id;
4601
4602 ELSE
4603
4604 FETCH line_service_detail_count INTO
4605 l_line_service_detail_id, l_row_count, l_min_id, l_max_id;
4606 EXIT WHEN line_service_detail_count%notfound;
4607
4608 END IF;
4609
4610 l_record_counter := l_record_counter + 1;
4611
4612 END LOOP;
4613
4614 IF l_record_counter <> 0 THEN
4615
4616 oe_upg_so_new.upgrade_insert_distbn_record
4617 (
4618 l_slab => l_current_slab,
4619 l_start_header_id => l_starting_id,
4620 l_end_header_id => l_max_id,
4621 l_type_var => 'I'
4622 );
4623
4624 END IF;
4625
4626 END IF;
4627
4628 CLOSE line_service_detail_count;
4629
4630 COMMIT;
4631
4632 END upgrade_inst_detail_distbns;
4633
4634 ---------------------------------
4635 -- Upgrade_holds_Distbns --
4636 ---------------------------------
4637 Procedure Upgrade_holds_Distbns
4638 ( L_total_slabs IN number )
4639 is
4640 v_type varchar2(1);
4641 cursor RDis
4642 is
4643 select
4644 shsa.hold_source_id
4645 from
4646 so_hold_sources_all shsa
4647 order by shsa.hold_source_id;
4648
4649 v_total_sources number;
4650 v_min_source number;
4651 v_max_source number;
4652 v_counter number;
4653 v_gap number;
4654 v_slab_count number;
4655 v_slab_start number;
4656 v_slab_end number;
4657 v_dis_hold_source_id number;
4658 v_start_flag number;
4659 v_total_slabs number;
4660
4661 --
4662 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4663 --
4664 Begin
4665 v_type := 'H';
4666
4667 delete oe_upgrade_distribution
4668 where line_type = v_type;
4669 commit;
4670
4671
4672 begin
4673 select
4674 count(*),
4675 nvl(min(shsa.hold_source_id),0),
4676 nvl(max(shsa.hold_source_id),0)
4677 into
4678 v_total_sources,
4679 v_min_source,
4680 v_max_source
4681 from
4682 so_hold_sources_all shsa;
4683 exception
4684 when others then
4685 null;
4686 end;
4687
4688 if v_total_sources < 500 or l_total_slabs = 1 then
4689
4690 OE_UPG_SO_NEW.Upgrade_Insert_Distbn_Record
4691 (
4692 L_slab => 1,
4693 L_start_header_id => v_min_source,
4694 L_end_Header_id => v_max_source,
4695 L_type_var => v_type
4696 );
4697
4698 else
4699 v_min_source := 0;
4700 v_max_source := 0;
4701 v_total_slabs := L_total_slabs;
4702 v_counter := 0;
4703 v_start_flag := 0;
4704 v_slab_count := 0;
4705 v_gap := round(v_total_sources / v_total_slabs);
4706
4707 for MRdis in Rdis loop
4708
4709 v_dis_hold_source_id := MRdis.hold_source_id;
4710 v_counter := v_counter + 1;
4711
4712 if v_start_flag = 0 then
4713 v_start_flag := 1;
4714 v_min_source := MRdis.hold_source_id;
4715 v_max_source := NULL;
4716 v_slab_count := v_slab_count + 1;
4717 end if;
4718
4719 if v_counter = v_gap and v_slab_count < v_total_slabs then
4720 v_max_source := MRdis.hold_source_id;
4721
4722 OE_UPG_SO_NEW.Upgrade_Insert_Distbn_Record
4723 (
4724 L_slab => v_slab_count,
4725 L_start_header_id => v_min_source,
4726 L_end_Header_id => v_max_source,
4727 L_type_var => v_type
4728 );
4729
4730 v_counter := 0;
4731 v_start_flag := 0;
4732 end if;
4733
4734 end loop;
4735 v_max_source := v_dis_hold_source_id;
4736
4737 OE_UPG_SO_NEW.Upgrade_Insert_Distbn_Record
4738 (
4739 L_slab => v_slab_count,
4740 L_start_header_id => v_min_source,
4741 L_end_Header_id => v_max_source ,
4742 L_type_var => v_type
4743 );
4744
4745 commit;
4746 end if;
4747 commit;
4748
4749 End Upgrade_holds_Distbns;
4750
4751 ---------------------------------------
4752 -- Upgrade Freight Charges Distribution
4753 ---------------------------------------
4754
4755 Procedure Upgrade_Freight_Distbns
4756 ( L_total_slabs IN number)
4757 is
4758 v_type varchar2(1);
4759 CURSOR C_FREIGHT
4760 IS
4761 SELECT freight_charge_id
4762 FROM so_freight_charges
4763 ORDER BY freight_charge_id;
4764
4765 v_total_headers number;
4766 v_min_header number;
4767 v_max_header number;
4768 v_counter number;
4769 v_gap number;
4770 v_slab_count number;
4771 v_slab_start number;
4772 v_slab_end number;
4773 v_dis_header_id number;
4774 v_start_flag number;
4775 v_total_slabs number;
4776
4777 --
4778 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4779 --
4780 BEGIN
4781 v_type := 'F';
4782
4783 DELETE oe_upgrade_distribution
4784 WHERE line_type = v_type;
4785 COMMIT;
4786
4787
4788 BEGIN
4789 SELECT
4790 count(*),
4791 nvl(min(freight_charge_id),0),
4792 nvl(max(freight_charge_id),0)
4793 INTO
4794 v_total_headers,
4795 v_min_header,
4796 v_max_header
4797 FROM
4798 so_freight_charges;
4799 EXCEPTION
4800 WHEN OTHERS THEN
4801 NULL;
4802 END;
4803
4804 IF v_total_headers < 500 or l_total_slabs = 1 then
4805
4806 OE_UPG_SO_NEW.Upgrade_Insert_Distbn_Record
4807 (
4808 L_slab => 1,
4809 L_start_header_id => v_min_header,
4810 L_end_Header_id => v_max_header,
4811 L_type_var => v_type
4812 );
4813
4814 ELSE
4815 v_max_header := 0;
4816 v_min_header := 0;
4817 v_total_slabs := L_total_slabs;
4818 v_counter := 0;
4819 v_start_flag := 0;
4820 v_slab_count := 0;
4821 v_gap := round(v_total_headers / v_total_slabs);
4822
4823 FOR C1 IN C_FREIGHT LOOP
4824 v_dis_header_id := C1.freight_charge_id;
4825 v_counter := v_counter + 1;
4826
4827 IF v_start_flag = 0 then
4828 v_start_flag := 1;
4829 v_min_header := C1.freight_charge_id;
4830 v_max_header := NULL;
4831 v_slab_count := v_slab_count + 1;
4832 END IF;
4833
4834 IF v_counter = v_gap and v_slab_count < v_total_slabs then
4835 v_max_header := C1.freight_charge_id;
4836
4837 OE_UPG_SO_NEW.Upgrade_Insert_Distbn_Record
4838 (
4839 L_slab => v_slab_count,
4840 L_start_header_id => v_min_header,
4841 L_end_Header_id => v_max_header,
4842 L_type_var => v_type
4843 );
4844
4845 v_counter := 0;
4846 v_start_flag := 0;
4847 END IF;
4848
4849 END LOOP;
4850 v_max_header := v_dis_header_id;
4851
4852 OE_UPG_SO_NEW.Upgrade_Insert_Distbn_Record
4853 (
4854 L_slab => v_slab_count,
4855 L_start_header_id => v_min_header,
4856 L_end_Header_id => v_max_header ,
4857 L_type_var => v_type
4858 );
4859
4860 END IF;
4861 COMMIT;
4862
4863 END Upgrade_Freight_Distbns;
4864
4865
4866 Procedure Upgrade_Insert_Distbn_Record
4867 (
4868 L_slab IN Varchar2,
4869 L_start_Header_id IN Number,
4870 L_end_Header_Id IN Number,
4871 L_type_var IN Varchar2
4872 )
4873 is
4874
4875 --
4876 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4877 --
4878 Begin
4879 insert into oe_upgrade_distribution
4880 (
4881 slab,
4882 start_header_id,
4883 end_header_id,
4884 alloted_flag,
4885 line_type,
4886 creation_date
4887 )
4888 values
4889 (
4890 L_slab,
4891 L_start_Header_id,
4892 L_end_Header_id,
4893 'N',
4894 L_type_var,
4895 sysdate
4896 );
4897
4898 End Upgrade_Insert_Distbn_Record;
4899
4900 Procedure Upgrade_Insert_Errors
4901 (
4902 L_header_id IN Varchar2,
4903 L_comments IN varchar2
4904 )
4905 is
4906
4907 --
4908 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4909 --
4910 Begin
4911 G_ERROR_LOCATION := 18;
4912 insert into oe_upgrade_errors
4913 (
4914 header_id,
4915 comments,
4916 creation_date
4917 )
4918 values
4919 (
4920 l_header_id,
4921 substr(l_comments,1,240),
4922 sysdate
4923 );
4924
4925 G_ERROR_LOCATION := 19;
4926 End Upgrade_Insert_Errors;
4927
4928 Procedure update_remnant_flag
4929 IS
4930
4931 cursor model_lines IS
4932 select /*+ INDEX(SO_LINES_N1) */ lines.line_id
4933 from so_lines_all lines
4934 where lines.header_id = G_HEADER_ID
4935 and lines.item_type_code in ('MODEL','KIT')
4936 and parent_line_id is null
4937 and lines.line_type_code in ('REGULAR','DETAIL');
4938
4939 cursor option_lines(p_parent_line_id IN NUMBER) IS
4940 select line_id,inventory_item_id,item_type_code
4941 from so_lines_all
4942 where parent_line_id=p_parent_line_id;
4943
4944 cursor included_items(p_line_id IN NUMBER) IS
4945 select line_detail_id
4946 from so_line_details
4947 where line_id=p_line_id
4948 AND included_item_flag = 'Y';
4949
4950 l_parent_line_id NUMBER := 0;
4951 l_ii_line_id NUMBER;
4952 l_detail_line_id NUMBER;
4953 no_of_details NUMBER;
4954 no_of_picking_details NUMBER;
4955 l_valid VARCHAR2(1) := 'N';
4956 multiple_details_exist BOOLEAN := FALSE;
4957 l_count NUMBER := 0;
4958 l_option_line_id NUMBER;
4959 l_item_type_code VARCHAR2(30);
4960 l_inventory_item_id NUMBER;
4961
4962 --
4963 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4964 --
4965 begin
4966
4967 OPEN model_lines;
4968
4969 LOOP
4970
4971 FETCH model_lines INTO l_parent_line_id;
4972 EXIT WHEN model_lines%notfound;
4973
4974 /* Check for the model line if there are multiple included items */
4975
4976 IF l_debug_level > 0 THEN
4977 oe_debug_pub.add( 'MODEL LINE ID : ' || L_PARENT_LINE_ID ) ;
4978 END IF;
4979
4980 SELECT count(*)
4981 INTO no_of_details
4982 FROM SO_LINE_DETAILS
4983 WHERE LINE_ID = l_parent_line_id
4984 AND INCLUDED_ITEM_FLAG = 'N'
4985 AND nvl(CONFIGURATION_ITEM_FLAG,'N') = 'N';
4986
4987 IF no_of_details > 1 THEN
4988 IF l_debug_level > 0 THEN
4989 oe_debug_pub.add( 'MULTIPLE DETAILS EXIST FOR :' || L_PARENT_LINE_ID ) ;
4990 END IF;
4991 multiple_details_exist := TRUE;
4992 goto mld;
4993 END IF;
4994
4995 BEGIN
4996 SELECT line_detail_id
4997 INTO l_detail_line_id
4998 FROM SO_LINE_DETAILS
4999 WHERE LINE_ID = l_parent_line_id
5000 AND INCLUDED_ITEM_FLAG = 'N'
5001 AND nvl(CONFIGURATION_ITEM_FLAG,'N') = 'N';
5002 EXCEPTION
5003 WHEN OTHERS THEN
5004 l_detail_line_id:=0;
5005 END;
5006
5007 /* Check to see if the oe_upgrade_wsh_iface have multiple
5008 details */
5009
5010 SELECT /*+ INDEX(oe_upgrade_wsh_iface OE_UPGRADE_WSH_IFACE_N2) */
5011 count(*)
5012 INTO no_of_picking_details
5013 from oe_upgrade_wsh_iface
5014 where line_detail_id = l_detail_line_id;
5015
5016 IF no_of_picking_details > 1 THEN
5017 IF l_debug_level > 0 THEN
5018 oe_debug_pub.add( 'MULTIPLE PICKING DETAILS EXIST FOR :' || L_PARENT_LINE_ID ) ;
5019 END IF;
5020 multiple_details_exist := TRUE;
5021 goto mld;
5022 END IF;
5023
5024 BEGIN
5025 SELECT 'Y'
5026 INTO l_valid
5027 FROM so_line_details
5028 WHERE line_id=l_parent_line_id
5029 AND included_item_flag='Y'
5030 group by inventory_item_id
5031 having count(*) > 1;
5032
5033 IF l_debug_level > 0 THEN
5034 oe_debug_pub.add( 'MULTIPLE INCLUDED ITEM EXISTS FOR :' || L_PARENT_LINE_ID ) ;
5035 END IF;
5036
5037 EXCEPTION
5038 WHEN OTHERS THEN
5039 null;
5040 END ;
5041
5042 IF l_valid = 'Y' THEN
5043 IF l_debug_level > 0 THEN
5044 oe_debug_pub.add( '1. SETTING MULTIPLE_DETAILS_EXIST TO TRUE' , 1 ) ;
5045 END IF;
5046 multiple_details_exist := TRUE;
5047 goto mld;
5048 END IF;
5049
5050 OPEN included_items(l_parent_line_id);
5051
5052 LOOP
5053
5054 FETCH included_items
5055 INTO l_ii_line_id;
5056 EXIT WHEN included_items%notfound;
5057
5058 SELECT count(*)
5059 INTO no_of_picking_details
5060 from oe_upgrade_wsh_iface
5061 where line_detail_id = l_ii_line_id;
5062
5063 IF no_of_picking_details > 1 THEN
5064 IF l_debug_level > 0 THEN
5065 oe_debug_pub.add( 'MULTIPLE PICKING DETAILS EXIST FOR :' || L_II_LINE_ID ) ;
5066 END IF;
5067 multiple_details_exist := TRUE;
5068 EXIT;
5069 END IF;
5070
5071 END LOOP;
5072
5073 CLOSE included_items;
5074
5075 IF multiple_details_exist THEN
5076 IF l_debug_level > 0 THEN
5077 oe_debug_pub.add( '1. GOTO MULTIPLE_DETAILS_EXIST' , 1 ) ;
5078 END IF;
5079 goto mld;
5080 END IF;
5081
5082 -- Get the multiple config lines.
5083 OPEN option_lines(l_parent_line_id);
5084
5085 LOOP
5086
5087 -- Get next config line. You should create new model and options
5088 -- only for the second config detail.
5089
5090 FETCH option_lines
5091 INTO l_option_line_id,l_inventory_item_id,l_item_type_code;
5092 EXIT WHEN option_lines%notfound;
5093
5094 -- See if the option has multiple details
5095
5096 SELECT count(*)
5097 INTO no_of_details
5098 FROM SO_LINE_DETAILS
5099 WHERE LINE_ID = l_option_line_id
5100 AND INVENTORY_ITEM_ID = l_inventory_item_id
5101 AND INCLUDED_ITEM_FLAG = 'N'
5102 AND nvl(CONFIGURATION_ITEM_FLAG,'N') = 'N';
5103
5104 IF no_of_details > 1 THEN
5105 IF l_debug_level > 0 THEN
5106 oe_debug_pub.add( 'MULTIPLE DETAILS EXIST FOR :' || L_OPTION_LINE_ID ) ;
5107 END IF;
5108 multiple_details_exist := TRUE;
5109 EXIT;
5110 END IF;
5111
5112 /* Check to see if the oe_upgrade_wsh_iface have multiple
5113 details */
5114 BEGIN
5115 SELECT line_detail_id
5116 INTO l_detail_line_id
5117 FROM SO_LINE_DETAILS
5118 WHERE LINE_ID = l_option_line_id
5119 AND INVENTORY_ITEM_ID = l_inventory_item_id
5120 AND INCLUDED_ITEM_FLAG = 'N'
5121 AND nvl(CONFIGURATION_ITEM_FLAG,'N') = 'N';
5122 EXCEPTION
5123 WHEN OTHERS THEN
5124 l_detail_line_id := 0;
5125 END;
5126
5127
5128 SELECT count(*)
5129 INTO no_of_picking_details
5130 from oe_upgrade_wsh_iface
5131 where line_detail_id = l_detail_line_id;
5132
5133 IF no_of_picking_details > 1 THEN
5134 IF l_debug_level > 0 THEN
5135 oe_debug_pub.add( 'MULTIPLE PICKING DETAILS EXIST FOR :' || L_OPTION_LINE_ID ) ;
5136 END IF;
5137 multiple_details_exist := TRUE;
5138 EXIT;
5139 END IF;
5140
5141 /* Check to see if the included items of this option class
5142 have multiple details. */
5143 IF l_item_type_code = 'CLASS' THEN
5144 BEGIN
5145 SELECT 'Y'
5146 INTO l_valid
5147 FROM so_line_details
5148 WHERE line_id=l_option_line_id
5149 AND included_item_flag='Y'
5150 group by inventory_item_id
5151 having count(*) > 1;
5152
5153 IF l_debug_level > 0 THEN
5154 oe_debug_pub.add( 'MULTIPLE INCLUDED ITEM EXISTS FOR :' || L_OPTION_LINE_ID ) ;
5155 END IF;
5156
5157 EXCEPTION
5158 WHEN OTHERS THEN
5159 null;
5160 END ;
5161
5162 IF l_valid = 'Y' THEN
5163 IF l_debug_level > 0 THEN
5164 oe_debug_pub.add( '1. EXITING' , 1 ) ;
5165 END IF;
5166 EXIT;
5167 END IF;
5168 END IF;
5169
5170 IF l_item_type_code ='CLASS' THEN
5171 OPEN included_items(l_option_line_id);
5172
5173 LOOP
5174
5175 FETCH included_items
5176 INTO l_ii_line_id;
5177 EXIT WHEN included_items%notfound;
5178
5179 SELECT count(*)
5180 INTO no_of_picking_details
5181 from oe_upgrade_wsh_iface
5182 where line_detail_id = l_ii_line_id;
5183
5184 IF no_of_picking_details > 1 THEN
5185 IF l_debug_level > 0 THEN
5186 oe_debug_pub.add( 'MULTIPLE PICKING DETAILS EXIST FOR :' || L_II_LINE_ID ) ;
5187 END IF;
5188 multiple_details_exist := TRUE;
5189 EXIT;
5190 END IF;
5191
5192 END LOOP;
5193
5194 CLOSE included_items;
5195 IF multiple_details_exist THEN
5196 IF l_debug_level > 0 THEN
5197 oe_debug_pub.add( '2. EXITING' , 1 ) ;
5198 END IF;
5199 EXIT;
5200 END IF;
5201 END IF;
5202 END LOOP;
5203
5204 CLOSE option_lines;
5205 <<mld>>
5206 IF multiple_details_exist THEN
5207 -- Update remnant_flag in oe_order_lines
5208
5209 l_count := l_count + 1;
5210
5211 UPDATE /*+ INDEX(OE_ORDER_LINES_N10) */ OE_ORDER_LINES_ALL
5212 SET model_remnant_flag='Y'
5213 WHERE top_model_line_id=l_parent_line_id
5214 AND model_remnant_flag is null ;
5215
5216
5217 multiple_details_exist := FALSE;
5218 l_valid := null;
5219 /*
5220 IF l_count > 500 THEN
5221 l_count := 0;
5222 commit;
5223 END IF;
5224 */
5225 END IF;
5226
5227 END LOOP;
5228 CLOSE model_lines;
5229
5230 exception
5231 when others then
5232 OE_UPG_SO_NEW.upgrade_insert_errors
5233 ( L_header_id => g_header_id,
5234 L_comments => 'Update_Remnant_Flag failed on ora error: '||to_char(sqlcode)
5235 );
5236 raise;
5237
5238 end update_remnant_flag;
5239
5240 Procedure Update_After_Insert
5241 IS
5242
5243 Cursor c_get_record is
5244 select /*+ INDEX(OE_ORDER_LINES_N1) */
5245 line_id,
5246 item_type_code,
5247 top_model_line_id,
5248 ato_line_id,
5249 shippable_flag,
5250 shipped_quantity,
5251 line_number,
5252 shipment_number,
5253 model_remnant_flag,
5254 link_to_line_id,
5255 line_category_code,
5256 fulfilled_quantity,
5257 fulfilled_flag,
5258 fulfillment_date,
5259 actual_shipment_date,
5260 ordered_quantity,
5261 service_reference_line_id,
5262 option_number,
5263 component_number,
5264 unit_selling_price,
5265 unit_list_price,
5266 ship_set_id,
5267 ship_from_org_id,
5268 ship_to_org_id,
5269 schedule_ship_date,
5270 schedule_status_code
5271 from
5272 oe_order_lines_all
5273 where
5274 header_id = G_HEADER_ID;
5275
5276 cursor service_product_lines (p_serviceable_line_id IN NUMBER) IS
5277 select line_id , service_parent_line_id
5278 from so_lines_all
5279 where service_parent_line_id = p_serviceable_line_id;
5280
5281 cursor log_product_lines (p_service_parent_line_id IN NUMBER) IS
5282
5283 select old_line_id, new_line_id from
5284 oe_upgrade_log_v where
5285 old_line_id = p_service_parent_line_id
5286 and old_line_id <> new_line_id
5287 order by new_line_id;
5288
5289 cursor log_service_lines (p_line_id IN NUMBER) IS
5290
5291 select old_line_id, new_line_id from
5292 oe_upgrade_log_v where
5293 old_line_id = p_line_id
5294 and old_line_id <> new_line_id
5295 order by new_line_id;
5296
5297 v_new_line_id number;
5298 l_serviceable_line_id NUMBER;
5299 l_line_id NUMBER;
5300 l_service_parent_line_id NUMBER;
5301 l_old_line_id1 NUMBER;
5302 l_old_line_id2 NUMBER;
5303 l_new_line_id1 NUMBER;
5304 l_new_line_id2 NUMBER;
5305 l_count NUMBER;
5306 l_get_record c_get_record%rowtype;
5307 -- l_get_table get_update_tbl_type;
5308 TYPE temp_get_table IS TABLE OF c_get_record%rowtype
5309 INDEX BY BINARY_INTEGER;
5310 l_get_table temp_get_table;
5311 l_get_index NUMBER := 0;
5312 l_temp_index NUMBER := 0;
5313 l_ii_table temp_get_table;
5314 l_ii_index NUMBER := 0;
5315 TYPE top_model_tbl IS TABLE OF NUMBER
5316 INDEX BY BINARY_INTEGER;
5317 l_top_model_tbl top_model_tbl;
5318 l_top_model_index NUMBER := 0;
5319 l_not_shipped_line BOOLEAN;
5320 l_shipped_line BOOLEAN;
5321 l_update_table update_tbl_type;
5322 l_update_index NUMBER:=0;
5323 l_main_component NUMBER :=0;
5324 l_ii_component NUMBER :=0;
5325 l_option_number NUMBER := 0;
5326 l_service_reference_line_id NUMBER := 0;
5327 l_new_line_id NUMBER;
5328 l_not_in_the_set BOOLEAN;
5329 l_in_the_set BOOLEAN;
5330 l_invalid_set BOOLEAN;
5331 l_ship_set_id NUMBER;
5332 l_set_index NUMBER;
5333
5334 --
5335 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5336 --
5337 BEGIN
5338
5339 FOR l_temp_record IN c_get_record
5340 LOOP
5341
5342 l_get_index := l_temp_record.line_id;
5343 l_get_record := l_temp_record;
5344 l_get_table(l_get_index) := l_temp_record;
5345 l_update_table(l_get_index).line_number := l_temp_record.line_number;
5346 l_update_table(l_get_index).option_number := l_temp_record.option_number;
5347 l_update_table(l_get_index).shipment_number := l_temp_record.shipment_number;
5348 l_update_table(l_get_index).component_number := l_temp_record.component_number;
5349 l_update_table(l_get_index).ordered_quantity := l_temp_record.ordered_quantity;
5350 l_update_table(l_get_index).shipped_quantity := l_temp_record.shipped_quantity;
5351 l_update_table(l_get_index).fulfilled_quantity := l_temp_record.fulfilled_quantity;
5352 l_update_table(l_get_index).fulfilled_flag := l_temp_record.fulfilled_flag;
5353 l_update_table(l_get_index).fulfillment_date := l_temp_record.fulfillment_date;
5354 l_update_table(l_get_index).actual_shipment_date := l_temp_record.actual_shipment_date;
5355 l_update_table(l_get_index).model_remnant_flag := l_temp_record.model_remnant_flag;
5356 l_update_table(l_get_index).service_reference_line_id := l_temp_record.service_reference_line_id;
5357 l_update_table(l_get_index).item_type_code := l_temp_record.item_type_code;
5358 l_update_table(l_get_index).top_model_line_id := l_temp_record.top_model_line_id;
5359
5360 l_update_table(l_get_index).ato_line_id := l_temp_record.ato_line_id;
5361 --bug 1869550 fix. for ato_item under pto model.
5362
5363 IF l_temp_record.ato_line_id is NOT NULL and
5364 l_temp_record.ato_line_id <> l_temp_record.line_id and
5365 l_temp_record.item_type_code = 'OPTION'
5366 THEN
5367
5368 SELECT /*+ INDEX(OE_ORDER_LINES_N1) */
5369 count(*)
5370 INTO l_count
5371 FROM oe_order_lines_all
5372 WHERE ato_line_id = l_temp_record.ato_line_id
5373 AND top_model_line_id = l_temp_record.top_model_line_id
5374 AND header_id = G_HEADER_ID;
5375
5376 IF l_count = 1 THEN
5377 l_update_table(l_get_index).ato_line_id := l_temp_record.line_id;
5378 END IF;
5379 END IF;
5380
5381 l_update_table(l_get_index).shippable_flag := l_temp_record.shippable_flag;
5382 l_update_table(l_get_index).temp_update_flag := 'N';
5383
5384
5385 IF l_temp_record.item_type_code = 'INCLUDED' THEN
5386 l_update_table(l_get_index).unit_selling_price := 0;
5387 l_update_table(l_get_index).unit_list_price := 0;
5388 l_update_table(l_get_index).temp_update_flag := 'Y';
5389 ELSIF l_temp_record.item_type_code = 'CONFIG' THEN
5390 l_update_table(l_get_index).unit_selling_price := 0;
5391 l_update_table(l_get_index).unit_list_price := 0;
5392 l_update_table(l_get_index).temp_update_flag := 'Y';
5393 ELSE
5394 l_update_table(l_get_index).unit_selling_price := l_temp_record.unit_selling_price;
5395 l_update_table(l_get_index).unit_list_price := l_temp_record.unit_list_price;
5396 END IF;
5397
5398
5399 IF l_temp_record.line_id = l_temp_record.top_model_line_id THEN
5400 l_top_model_index := l_top_model_index + 1;
5401 l_top_model_tbl(l_top_model_index) := l_temp_record.line_id;
5402 END IF;
5403
5404 /* From ont00106.sql */
5405
5406 l_update_table(l_get_index).ship_set_id := l_temp_record.ship_set_id;
5407
5408 /* End ont00106.sql */
5409 END LOOP;
5410
5411 /* If there are no lines */
5412 IF l_get_table.count <= 0 then
5413
5414 GOTO NO_LINES;
5415
5416 END IF;
5417
5418 /* From ontupg17 */
5419
5420 l_temp_index := l_get_table.FIRST;
5421 WHILE l_temp_index IS NOT NULL
5422 LOOP
5423
5424 /* First retrieve all the serviceable lines */
5425
5426 IF l_get_table(l_temp_index).item_type_code = 'SERVICE' THEN
5427
5428 GOTO NEXT_SERVICE_LINE;
5429 END IF;
5430
5431 BEGIN
5432
5433 -- Get the equivalent records from so_lines_all
5434 l_serviceable_line_id := l_get_table(l_temp_index).line_id;
5435
5436 OPEN service_product_lines (l_serviceable_line_id);
5437
5438 LOOP
5439
5440 FETCH service_product_lines
5441 into l_line_id, l_service_parent_line_id;
5442 EXIT WHEN service_product_lines%NOTFOUND;
5443
5444 /*Have 2 open cursors for retrieving log records */
5445
5446 OPEN log_product_lines (l_service_parent_line_id);
5447 OPEN log_service_lines (l_line_id);
5448
5449 LOOP
5450
5451 FETCH log_product_lines
5452 into l_old_line_id1, l_new_line_id1;
5453 EXIT WHEN log_product_lines%NOTFOUND;
5454
5455 FETCH log_service_lines
5456 into l_old_line_id2, l_new_line_id2;
5457 EXIT WHEN log_service_lines%NOTFOUND;
5458
5459 -- Now update the service line
5460 -- in oe_order_lines_all table
5461
5462 l_update_table(l_new_line_id2).service_reference_line_id := l_new_line_id1;
5463 l_update_table(l_new_line_id2).temp_update_flag := 'Y';
5464
5465 END LOOP;
5466
5467 CLOSE log_service_lines;
5468
5469 CLOSE log_product_lines;
5470
5471 END LOOP; /* Loop for service product lines */
5472
5473 CLOSE service_product_lines;
5474
5475 EXCEPTION
5476 WHEN NO_DATA_FOUND THEN
5477 OE_UPG_SO_NEW.Upgrade_Insert_Errors(
5478 G_HEADER_ID,
5479 'FYI Only: Service Ref.Line id not updated in OM for Line '
5480 ||to_char(l_new_line_id2));
5481
5482 END;
5483
5484 <<NEXT_SERVICE_LINE>>
5485
5486 l_temp_index := l_get_table.NEXT(l_temp_index);
5487
5488 END LOOP; /* ontupg17 */
5489
5490 /* No model Lines */
5491 IF l_top_model_tbl.count <= 0 THEN
5492
5493 GOTO END_MODELS;
5494
5495 END IF;
5496
5497 /* from ontupg53 */
5498
5499 l_ii_table := l_get_table;
5500
5501 FOR I IN l_top_model_tbl.FIRST .. l_top_model_tbl.LAST
5502 LOOP
5503 l_shipped_line := FALSE;
5504 l_not_shipped_line := FALSE;
5505 l_main_component := 0;
5506 l_option_number := 0;
5507 l_not_in_the_set := FALSE;
5508 l_in_the_set := FALSE;
5509 l_invalid_set := FALSE;
5510 l_ship_set_id := Null;
5511 l_set_index := Null;
5512
5513 l_temp_index := l_get_table.FIRST;
5514 WHILE l_temp_index IS NOT NULL
5515 LOOP
5516
5517 IF nvl(l_get_table(l_temp_index).top_model_line_id,0) <> l_top_model_tbl(I) THEN
5518
5519 GOTO NEXT_LINE;
5520 END IF;
5521
5522 IF l_set_index is null THEN
5523
5524 l_set_index := l_temp_index;
5525
5526 END IF;
5527
5528 /** From ont00106.sql **/
5529
5530 IF l_get_table(l_temp_index).ship_set_id is not null THEN
5531
5532 l_in_the_set := TRUE;
5533 l_ship_set_id := l_get_table(l_temp_index).ship_set_id;
5534
5535 IF l_get_table(l_temp_index).ship_from_org_id is null
5536 OR l_get_table(l_temp_index).ship_to_org_id is null
5537 OR l_get_table(l_temp_index).schedule_ship_date is null
5538 OR l_get_table(l_temp_index).schedule_status_code is null
5539 THEN
5540 l_invalid_set := TRUE;
5541 END IF;
5542
5543
5544 ELSE
5545
5546 IF l_invalid_set = FALSE
5547 AND l_get_table(l_temp_index).ship_from_org_id is not null
5548 AND l_get_table(l_temp_index).ship_to_org_id is not null
5549 AND l_get_table(l_temp_index).schedule_ship_date is not null
5550 AND l_get_table(l_temp_index).schedule_status_code is not null
5551 AND l_get_table(l_temp_index).ship_from_org_id = l_get_table(l_set_index).ship_from_org_id
5552 AND l_get_table(l_temp_index).ship_to_org_id = l_get_table(l_set_index).ship_to_org_id
5553 AND l_get_table(l_temp_index).schedule_ship_date = l_get_table(l_set_index).schedule_ship_date
5554 THEN
5555
5556 Null;
5557 ELSE
5558 l_invalid_set := TRUE;
5559 END IF;
5560
5561
5562 l_not_in_the_set := TRUE;
5563
5564 END IF; -- Main If
5565
5566 /** End ont00106.sql **/
5567
5568 IF nvl(l_get_table(l_temp_index).shippable_flag,'N') = 'Y' THEN
5569 IF l_get_table(l_temp_index).shipped_quantity is null OR
5570 l_get_table(l_temp_index).shipped_quantity = 0 THEN
5571 l_not_shipped_line := TRUE;
5572 ELSIF l_get_table(l_temp_index).shipped_quantity > 0 THEN
5573 l_shipped_line := TRUE;
5574 END IF;
5575 ELSE
5576
5577 -- Change for #3145399
5578 IF l_get_table(l_temp_index).ato_line_id is not NULL THEN
5579 BEGIN
5580 SELECT /*+ INDEX(OE_ORDER_LINES_N1) */ ACTUAL_SHIPMENT_DATE
5581 INTO l_update_table(l_temp_index).actual_shipment_date
5582 FROM OE_ORDER_LINES_ALL
5583 WHERE TOP_MODEL_LINE_ID = l_get_table(l_temp_index).top_model_line_id
5584 AND ATO_LINE_ID = l_get_table(l_temp_index).ato_line_id
5585 AND ITEM_TYPE_CODE='CONFIG'
5586 AND header_id=G_HEADER_ID;
5587 EXCEPTION WHEN OTHERS THEN
5588 NULL;
5589 END;
5590 END IF;
5591 END IF;
5592
5593 IF l_get_table(l_temp_index).link_to_line_id = l_top_model_tbl(I) AND
5594 l_get_table(l_temp_index).item_type_code = 'INCLUDED' THEN
5595
5596 l_main_component := l_main_component + 1;
5597 l_update_table(l_temp_index).line_number := l_get_table(l_top_model_tbl(I)).line_number;
5598 l_update_table(l_temp_index).shipment_number := l_get_table(l_top_model_tbl(I)).shipment_number;
5599 l_update_table(l_temp_index).component_number := l_main_component;
5600 l_update_table(l_temp_index).option_number := NULL;
5601 l_update_table(l_temp_index).temp_update_flag := 'Y';
5602
5603 END IF;
5604
5605 IF l_get_table(l_temp_index).top_model_line_id = l_top_model_tbl(I) AND
5606 l_get_table(l_temp_index).item_type_code <> 'INCLUDED' AND
5607 l_get_table(l_temp_index).line_id <> l_top_model_tbl(I) THEN
5608
5609 IF l_get_table(l_temp_index).item_type_code = 'CONFIG' THEN
5610
5611 l_update_table(l_temp_index).line_number := l_get_table(l_top_model_tbl(I)).line_number;
5612 l_update_table(l_temp_index).shipment_number := l_get_table(l_top_model_tbl(I)).shipment_number;
5613 l_update_table(l_temp_index).component_number := NULL;
5614 l_update_table(l_temp_index).option_number := NULL;
5615 l_update_table(l_temp_index).temp_update_flag := 'Y';
5616
5617 ELSE
5618 l_update_table(l_temp_index).line_number := l_get_table(l_top_model_tbl(I)).line_number;
5619 l_update_table(l_temp_index).shipment_number := l_get_table(l_top_model_tbl(I)).shipment_number;
5620 l_update_table(l_temp_index).component_number := l_get_table(l_temp_index).component_number;
5621 l_update_table(l_temp_index).option_number := l_get_table(l_temp_index).option_number;
5622 l_update_table(l_temp_index).temp_update_flag := 'Y';
5623
5624 END IF;
5625
5626 IF (l_get_table(l_temp_index).item_type_code = 'KIT' OR
5627 l_get_table(l_temp_index).item_type_code = 'CLASS') AND
5628 (l_get_table(l_temp_index).ato_line_id is null) THEN
5629
5630 l_ii_component := 0;
5631 l_ii_index := l_ii_table.FIRST;
5632
5633 WHILE l_ii_index IS NOT NULL
5634 LOOP
5635 IF nvl(l_ii_table(l_ii_index).top_model_line_id,0) <> l_top_model_tbl(I) THEN
5636
5637 GOTO NEXT_LINE_1;
5638 END IF;
5639
5640 IF l_ii_table(l_ii_index).link_to_line_id = l_get_table(l_temp_index).line_id AND
5641 l_ii_table(l_ii_index).item_type_code = 'INCLUDED' THEN
5642
5643 l_ii_component := l_ii_component + 1;
5644
5645 l_update_table(l_ii_index).line_number := l_get_table(l_top_model_tbl(I)).line_number;
5646 l_update_table(l_ii_index).shipment_number := l_get_table(l_top_model_tbl(I)).shipment_number;
5647 l_update_table(l_ii_index).component_number := l_ii_component;
5648 l_update_table(l_ii_index).option_number := l_get_table(l_top_model_tbl(I)).option_number;
5649 l_update_table(l_ii_index).temp_update_flag := 'Y';
5650
5651 END IF;
5652
5653 << NEXT_LINE_1>>
5654
5655 l_ii_index := l_ii_table.NEXT(l_ii_index);
5656 END LOOP;
5657
5658 END IF;
5659
5660 END IF;
5661
5662 <<NEXT_LINE>>
5663
5664 l_temp_index := l_get_table.NEXT(l_temp_index);
5665
5666 END LOOP;
5667
5668 IF (l_shipped_line = TRUE AND l_not_shipped_line = TRUE) THEN
5669
5670 l_update_index := l_update_table.FIRST;
5671
5672 WHILE l_update_index IS NOT NULL
5673 LOOP
5674 IF nvl(l_update_table(l_update_index).top_model_line_id,0) <> l_top_model_tbl(I) THEN
5675 GOTO NEXT_LINE_2;
5676 END IF;
5677
5678 l_update_table(l_update_index).model_remnant_flag := 'Y';
5679 l_update_table(l_update_index).temp_update_flag := 'Y';
5680
5681 <<NEXT_LINE_2>>
5682 l_update_index := l_update_table.NEXT(l_update_index);
5683
5684 END LOOP;
5685
5686 END IF;
5687
5688 IF (l_shipped_line = TRUE AND l_not_shipped_line = FALSE) THEN
5689
5690 l_update_index := l_update_table.FIRST;
5691
5692 WHILE l_update_index IS NOT NULL
5693 LOOP
5694 IF nvl(l_update_table(l_update_index).top_model_line_id,0) <> l_top_model_tbl(I) THEN
5695 GOTO NEXT_LINE_3;
5696 END IF;
5697
5698 IF l_update_table(l_update_index).ato_line_id IS NULL AND
5699 l_update_table(l_update_index).shippable_flag = 'N' THEN
5700
5701 l_update_table(l_update_index).shipped_quantity := l_update_table(l_update_index).ordered_quantity;
5702 l_update_table(l_update_index).fulfilled_quantity := l_update_table(l_update_index).ordered_quantity;
5703 l_update_table(l_update_index).fulfilled_flag := 'Y';
5704 l_update_table(l_update_index).fulfillment_date := l_update_table(l_update_index).actual_shipment_date;
5705 l_update_table(l_update_index).temp_update_flag := 'Y';
5706
5707 END IF;
5708
5709 <<NEXT_LINE_3>>
5710 l_update_index := l_update_table.NEXT(l_update_index);
5711 END LOOP; /* Shipped Quantity */
5712
5713 END IF;
5714
5715 /** From 0nt00106.sql **/
5716
5717 IF (l_in_the_set = TRUE AND l_not_in_the_set = TRUE)
5718 AND l_invalid_set = FALSE
5719 AND l_ship_set_id is not null THEN
5720
5721 l_update_index := l_update_table.FIRST;
5722
5723 WHILE l_update_index IS NOT NULL
5724 LOOP
5725 IF nvl(l_update_table(l_update_index).top_model_line_id,0) <> l_top_model_tbl(I) THEN
5726 GOTO NEXT_LINE_4;
5727 END IF;
5728
5729 l_update_table(l_update_index).ship_set_id := l_ship_set_id;
5730 l_update_table(l_update_index).temp_update_flag := 'Y';
5731
5732 <<NEXT_LINE_4>>
5733
5734 l_update_index := l_update_table.NEXT(l_update_index);
5735
5736 END LOOP;
5737
5738 ELSIF (l_in_the_set = TRUE AND l_not_in_the_set = TRUE)
5739 OR l_invalid_set = TRUE THEN
5740
5741 l_update_index := l_update_table.FIRST;
5742
5743 WHILE l_update_index IS NOT NULL
5744 LOOP
5745 IF nvl(l_update_table(l_update_index).top_model_line_id,0) <> l_top_model_tbl(I) THEN
5746 GOTO NEXT_LINE_5;
5747 END IF;
5748
5749 l_update_table(l_update_index).ship_set_id := Null;
5750 l_update_table(l_update_index).temp_update_flag := 'Y';
5751
5752 <<NEXT_LINE_5>>
5753
5754 l_update_index := l_update_table.NEXT(l_update_index);
5755
5756 END LOOP;
5757
5758 END IF;
5759 /** End 0nt00106.sql **/
5760
5761 END LOOP; /* For Models ontupg53 */
5762
5763 <<END_MODELS>>
5764 NULL;
5765
5766 /* From ontupg14 */
5767 l_update_index := l_update_table.FIRST;
5768
5769 WHILE l_update_index IS NOT NULL
5770 LOOP
5771
5772 BEGIN
5773
5774 IF l_update_table(l_update_index).item_type_code = 'SERVICE' AND
5775 l_update_table(l_update_index).service_reference_line_id IS NOT NULL THEN
5776
5777 l_service_reference_line_id := l_update_table(l_update_index).service_reference_line_id;
5778 l_update_table(l_update_index).line_number := l_update_table(l_service_reference_line_id).line_number;
5779 l_update_table(l_update_index).shipment_number := l_update_table(l_service_reference_line_id).shipment_number;
5780 l_update_table(l_update_index).option_number := l_update_table(l_service_reference_line_id).option_number;
5781 l_update_table(l_update_index).temp_update_flag := 'Y';
5782
5783 END IF;
5784
5785 EXCEPTION
5786
5787 WHEN NO_DATA_FOUND THEN
5788
5789 OE_UPG_SO_NEW.Upgrade_Insert_Errors(
5790 G_HEADER_ID,
5791 'FYI Only: Service Ref information not updated since parent line does not exist'
5792 ||to_char(l_update_index));
5793
5794 END;
5795
5796 l_update_index := l_update_table.NEXT(l_update_index);
5797 END LOOP; /* ontupg14 */
5798
5799
5800 /* Update the lines */
5801
5802 l_update_index := l_update_table.FIRST;
5803
5804 WHILE l_update_index IS NOT NULL
5805 LOOP
5806
5807 IF l_update_table(l_update_index).temp_update_flag = 'Y' THEN
5808
5809 UPDATE /*+ INDEX(OE_ORDER_LINES_U1) */ OE_ORDER_LINES_ALL
5810 SET SHIPPED_QUANTITY = l_update_table(l_update_index).shipped_quantity,
5811 FULFILLED_FLAG = l_update_table(l_update_index).fulfilled_flag,
5812 FULFILLED_QUANTITY = l_update_table(l_update_index).fulfilled_quantity,
5813 ACTUAL_SHIPMENT_DATE = l_update_table(l_update_index).actual_shipment_date,
5814 FULFILLMENT_DATE = l_update_table(l_update_index).fulfillment_date,
5815 LINE_NUMBER = l_update_table(l_update_index).line_number,
5816 OPTION_NUMBER = l_update_table(l_update_index).option_number,
5817 SHIPMENT_NUMBER = l_update_table(l_update_index).shipment_number,
5818 COMPONENT_NUMBER = l_update_table(l_update_index).component_number,
5819 MODEL_REMNANT_FLAG = l_update_table(l_update_index).model_remnant_flag,
5820 SERVICE_REFERENCE_LINE_ID = l_update_table(l_update_index).service_reference_line_id,
5821 SHIPPABLE_FLAG = l_update_table(l_update_index).shippable_flag,
5822 UNIT_SELLING_PRICE = l_update_table(l_update_index).unit_selling_price,
5823 UNIT_LIST_PRICE = l_update_table(l_update_index).unit_list_price,
5824 ATO_LINE_ID = l_update_table(l_update_index).ato_line_id,
5825 SHIP_SET_ID = l_update_table(l_update_index).ship_set_id
5826 WHERE LINE_ID = l_update_index;
5827 END IF;
5828
5829 l_update_index := l_update_table.NEXT(l_update_index);
5830
5831 END LOOP;
5832
5833 <<NO_LINES>>
5834 NULL;
5835
5836 exception
5837 when others then
5838 OE_UPG_SO_NEW.upgrade_insert_errors
5839 ( L_header_id => g_header_id,
5840 L_comments => 'Update_After_Insert failed on ora error: '||to_char(sqlcode)
5841 );
5842 raise;
5843
5844 END Update_After_Insert;
5845
5846 Procedure Upgrade_Create_Line_Sets
5847 is
5848 v_set_id number;
5849 v_line_number number;
5850 v_shipment_number number;
5851 v_header_id number;
5852 v_line_id number;
5853 v_commit_ctr number;
5854 v_mem_line_num number;
5855
5856 cursor c1 is
5857
5858 /*Hints are changed to fix the bug 1826762 for the bug1974897*/
5859 select /*+ ORDERED USE_NL(sla1,sla2,upg,oeol)
5860 INDEX (sla1 SO_LINES_N1)
5861 INDEX (sla2 SO_LINES_N18)
5862 INDEX (upg OE_UPGRADE_LOG_N1)
5863 INDEX (oeol OE_ORDER_LINES_U1)
5864 */
5865 sla1.header_id,
5866 sla1.line_id,
5867 sla1.line_number,
5868 sla1.inventory_item_id,
5869 sla1.unit_code
5870 from
5871 so_lines_all sla1, so_lines_all sla2, oe_upgrade_log upg,
5872 oe_order_lines_all oeol
5873 where sla1.header_id = G_HEADER_ID
5874 and sla1.line_type_code = 'PARENT'
5875 and sla1.item_type_code in ('KIT','MODEL','STANDARD')
5876 and sla1.parent_line_id is null -- To filter out option lines
5877 and sla1.parent_line_id is null -- To filter out option lines
5878 and sla1.line_id = sla2.shipment_schedule_line_id
5879 and sla2.line_id = upg.old_line_id
5880 and upg.new_line_id = oeol.line_id
5881 order by sla1.line_id;
5882
5883 /* Performance changes bug 1961136 */
5884 cursor c3 is
5885
5886 SELECT /*+ ORDERED USE_NL(OOLA SLA UPG) INDEX(oola OE_ORDER_LINES_N1)
5887 INDEX(upg OE_UPGRADE_LOG_N6) index(sla SO_LINES_U1) */
5888 OOLA.LINE_ID,OOLA.LINE_NUMBER
5889 FROM OE_ORDER_LINES_ALL OOLA,
5890 OE_UPGRADE_LOG UPG ,
5891 SO_LINES_ALL SLA
5892 WHERE OOLA.HEADER_ID = G_HEADER_ID AND
5893 OOLA.LINE_ID = UPG.NEW_LINE_ID AND
5894 UPG.OLD_LINE_ID = SLA.LINE_ID AND
5895 SLA.SHIPMENT_SCHEDULE_LINE_ID = v_line_id
5896 ORDER BY OOLA.LINE_ID;
5897
5898
5899 cursor c5 is
5900 select
5901 header_id,
5902 line_id,
5903 line_number,
5904 inventory_item_id,
5905 unit_code
5906 from
5907 so_lines_all sla
5908 where sla.header_id = G_HEADER_ID
5909 AND sla.line_type_code = 'REGULAR'
5910 AND item_type_code in ('KIT','MODEL','STANDARD')
5911 and parent_line_id is null -- To filter out options (included on Leena's instn.)
5912 and parent_line_id is null -- To filter out options (included on Leena's instn.)
5913 -- and sla.line_id in
5914 and exists
5915 (select /*+ INDEX(ln OE_ORDER_LINES_N1) */lg.old_line_id
5916 from oe_upgrade_log_v lg, oe_order_lines_all ln
5917 where ln.header_id = sla.header_id
5918 and lg.old_line_id = sla.line_id
5919 and lg.new_line_id = ln.line_id
5920 and ln.item_type_code not in ('INCLUDED','CONFIG')
5921 group by lg.old_line_id
5922 having count(*) > 1);
5923
5924 cursor c7 is
5925 select /*+ INDEX(oe_upgrade_log OE_UPGRADE_LOG_N1) */ --bug5909908
5926 new_line_id line_id,
5927 new_line_number line_number
5928 from oe_upgrade_log
5929 where old_line_id = v_line_id
5930 and old_line_id is not null;
5931 v_ctr number;
5932 p_line_number number;
5933 v_item_type_code varchar2(200);
5934 --
5935 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5936 --
5937 begin
5938 v_header_id := 0;
5939 v_commit_ctr := 0;
5940
5941 for c2 in c1 loop
5942
5943 v_line_id := c2.line_id;
5944 p_line_number := c2.line_number;
5945
5946 /* Create a set */
5947
5948 select oe_sets_s.nextval into v_set_id from dual;
5949
5950 insert into oe_sets
5951 (
5952 SET_ID,
5953 SET_NAME,
5954 SET_TYPE,
5955 HEADER_ID,
5956 SHIP_FROM_ORG_ID,
5957 SHIP_TO_ORG_ID,
5958 SCHEDULE_SHIP_DATE,
5959 SCHEDULE_ARRIVAL_DATE,
5960 FREIGHT_CARRIER_CODE,
5961 SHIPPING_METHOD_CODE,
5962 SHIPMENT_PRIORITY_CODE,
5963 SET_STATUS,
5964 CREATED_BY,
5965 CREATION_DATE,
5966 UPDATED_BY,
5967 UPDATE_DATE,
5968 UPDATE_LOGIN,
5969 INVENTORY_ITEM_ID,
5970 ORDERED_QUANTITY_UOM,
5971 LINE_TYPE_ID,
5972 SHIP_TOLERANCE_ABOVE,
5973 SHIP_TOLERANCE_BELOW
5974 )
5975 values
5976 (
5977 v_set_id, /* SET_ID, */
5978 to_char(v_set_id), /* SET_NAME, */
5979 'LINE_SET', /* SET_TYPE, */
5980 c2.header_id, /* HEADER_ID,*/
5981 null, /* SHIP_FROM_ORG_ID, */
5982 null, /* SHIP_TO_ORG_ID, */
5983 null, /* SCHEDULE_SHIP_DATE, */
5984 null, /* SCHEDULE_ARRIVAL_DATE, */
5985 null, /* FREIGHT_CARRIER_CODE, */
5986 null, /* SHIPPING_METHOD_CODE, */
5987 null, /* SHIPMENT_PRIORITY_CODE, */
5988 null, /* SET_STATUS, */
5989 0, /* CREATED_BY, */
5990 sysdate, /* CREATION_DATE, */
5991 0, /* UPDATED_BY, */
5992 sysdate, /* UPDATE_DATE, */
5993 0, /* UPDATE_LOGIN, */
5994 c2.inventory_item_id, /* INVENTORY_ITEM_ID, */
5995 c2.unit_code, /* ORDERED_QUANTITY_UOM, */
5996 null, /* LINE_TYPE_ID, */
5997 null, /* SHIP_TOLERANCE_ABOVE, */
5998 null /* SHIP_TOLERANCE_BELOW */
5999 );
6000
6001 v_shipment_number := 0;
6002 v_ctr := 0;
6003 for c4 in c3 loop
6004
6005 v_shipment_number := v_shipment_number + 1;
6006
6007 update oe_order_lines_all
6008 set line_set_id = v_set_id,
6009 line_number = p_line_number,
6010 shipment_number = v_shipment_number
6011 where line_id = c4.line_id;
6012 end loop;
6013 v_commit_ctr := v_commit_ctr + 1;
6014 /*
6015 if v_commit_ctr > 500 then
6016 commit;
6017 v_commit_ctr := 0;
6018 end if;
6019 */
6020 end loop;
6021
6022 v_line_number := 0;
6023 v_header_id := 0;
6024
6025 for c6 in c5 loop
6026 v_line_id := c6.line_id;
6027 p_line_number := c6.line_number;
6028
6029 select oe_sets_s.nextval into v_set_id from dual;
6030
6031 insert into oe_sets
6032 (
6033 SET_ID,
6034 SET_NAME,
6035 SET_TYPE,
6036 HEADER_ID,
6037 SHIP_FROM_ORG_ID,
6038 SHIP_TO_ORG_ID,
6039 SCHEDULE_SHIP_DATE,
6040 SCHEDULE_ARRIVAL_DATE,
6041 FREIGHT_CARRIER_CODE,
6042 SHIPPING_METHOD_CODE,
6043 SHIPMENT_PRIORITY_CODE,
6044 SET_STATUS,
6045 CREATED_BY,
6046 CREATION_DATE,
6047 UPDATED_BY,
6048 UPDATE_DATE,
6049 UPDATE_LOGIN,
6050 INVENTORY_ITEM_ID,
6051 ORDERED_QUANTITY_UOM,
6052 LINE_TYPE_ID,
6053 SHIP_TOLERANCE_ABOVE,
6054 SHIP_TOLERANCE_BELOW
6055 )
6056 values
6057 (
6058 v_set_id, /* SET_ID, */
6059 to_char(v_set_id), /* SET_NAME, */
6060 'LINE_SET', /* SET_TYPE, */
6061 c6.header_id, /* HEADER_ID,*/
6062 null, /* SHIP_FROM_ORG_ID, */
6063 null, /* SHIP_TO_ORG_ID, */
6064 null, /* SCHEDULE_SHIP_DATE, */
6065 null, /* SCHEDULE_ARRIVAL_DATE, */
6066 null, /* FREIGHT_CARRIER_CODE, */
6067 null, /* SHIPPING_METHOD_CODE, */
6068 null, /* SHIPMENT_PRIORITY_CODE, */
6069 null, /* SET_STATUS, */
6070 0, /* CREATED_BY, */
6071 sysdate, /* CREATION_DATE, */
6072 0, /* UPDATED_BY, */
6073 sysdate, /* UPDATE_DATE, */
6074 0, /* UPDATE_LOGIN, */
6075 c6.inventory_item_id, /* INVENTORY_ITEM_ID, */
6076 c6.unit_code, /* ORDERED_QUANTITY_UOM, */
6077 null, /* LINE_TYPE_ID, */
6078 null, /* SHIP_TOLERANCE_ABOVE, */
6079 null /* SHIP_TOLERANCE_BELOW */
6080 );
6081
6082 v_shipment_number := 0;
6083
6084 v_ctr := 0;
6085 for c8 in c7 loop
6086 begin
6087 v_item_type_code := null;
6088 select item_type_code into
6089 v_item_type_code from
6090 oe_order_lines_all
6091 where
6092 line_id = c8.line_id;
6093 exception
6094 when no_data_found then
6095 null;
6096 end ;
6097 IF v_item_type_code = 'MODEL' OR
6098 v_item_type_code = 'STANDARD' OR
6099 v_item_type_code = 'KIT' THEN
6100
6101 v_shipment_number := v_shipment_number + 1;
6102
6103 update oe_order_lines_all ooal
6104 set line_set_id = v_set_id,
6105 line_number = p_line_number,
6106 shipment_number = v_shipment_number
6107 where ooal.line_id = c8.line_id;
6108 END IF;
6109 end loop;
6110 v_commit_ctr := v_commit_ctr + 1;
6111 /*
6112 if v_commit_ctr > 500 then
6113 commit;
6114 v_commit_ctr := 0;
6115 end if;
6116 */
6117 end loop;
6118 exception
6119 when others then
6120 OE_UPG_SO_NEW.upgrade_insert_errors
6121 ( L_header_id => g_header_id,
6122 L_comments => 'Line set updation failed on ora error: '||to_char(sqlcode)
6123 );
6124 raise;
6125 End Upgrade_Create_Line_Sets;
6126
6127 -- 1. Select all the models which have multiple config details.
6128 -- 2. Select all the options for the model.
6129 -- 3. Create new lines for the options of the model and for the model itself.
6130 -- 4. Attach the config item to the model line.
6131 -- 5. update the option quantity for the original option lines.
6132
6133 PROCEDURE Insert_Row
6134 ( p_line_rec IN OE_Order_PUB.Line_Rec_Type,
6135 p_orig_line_id IN Number,
6136 p_upgraded_flag IN Varchar2 default 'Y',
6137 p_apply_price_adj IN Varchar2 default 'Y'
6138 );
6139
6140 FUNCTION Query_Row
6141 ( p_line_id IN NUMBER) RETURN OE_Order_PUB.Line_Rec_Type;
6142
6143 PROCEDURE insert_multiple_models IS
6144
6145 cursor multiple_cfg_detail(p_ato_line_id IN NUMBER) IS
6146 select /*+ INDEX(OE_ORDER_LINES_ALL OE_ORDER_LINES_N1) */ line_id,ordered_quantity,shipped_quantity
6147 from oe_order_lines_all
6148 where header_id = G_HEADER_ID
6149 and ato_line_id=p_ato_line_id
6150 and item_type_code = 'CONFIG';
6151
6152 cursor multiple_cfg_parent IS
6153 select /*+ INDEX(OE_ORDER_LINES_ALL OE_ORDER_LINES_N1) */
6154 ato_line_id
6155 from oe_order_lines_all
6156 where header_id = G_HEADER_ID
6157 group by ato_line_id,item_type_code
6158 having item_type_code = 'CONFIG'
6159 and count(*) > 1;
6160
6161 cursor model_and_options(p_ato_line_id IN NUMBER) IS
6162 select /*+ INDEX(OE_ORDER_LINES_ALL OE_ORDER_LINES_N1) */
6163 line_id
6164 from oe_order_lines_all
6165 where header_id = G_HEADER_ID
6166 and ato_line_id=p_ato_line_id
6167 and item_type_code <> 'CONFIG'
6168 order by component_code;
6169
6170 cursor service_lines(p_service_reference_line_id IN NUMBER) IS
6171 select /*+ INDEX(OE_ORDER_LINES_ALL OE_ORDER_LINES_N1) */
6172 line_id
6173 from oe_order_lines_all
6174 where header_id = G_HEADER_ID
6175 and service_reference_line_id = p_service_reference_line_id;
6176
6177 l_cfg_line_id NUMBER;
6178 l_cfg_ordered_quantity NUMBER;
6179 l_cfg_shipped_quantity NUMBER;
6180 p_ato_line_id NUMBER;
6181 l_line_id NUMBER;
6182 l_service_count NUMBER;
6183 l_service_line_id NUMBER;
6184
6185 l_model_rec OE_ORDER_PUB.line_rec_type;
6186 l_line_rec OE_ORDER_PUB.line_rec_type;
6187 l_service_line_rec OE_ORDER_PUB.line_rec_type;
6188 l_new_line_rec OE_ORDER_PUB.line_rec_type;
6189 v_error_code NUMBER;
6190 l_orig_model_quantity NUMBER := 0;
6191 --
6192 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6193 --
6194 BEGIN
6195
6196 -- Get the model line which has multiple config lines.
6197 OPEN multiple_cfg_parent;
6198
6199 LOOP
6200
6201 FETCH multiple_cfg_parent INTO p_ato_line_id;
6202 EXIT WHEN multiple_cfg_parent%notfound;
6203
6204 -- Get the original model quantity. This is needed to calculate
6205 -- any new option quantities.
6206
6207 BEGIN
6208 SELECT ordered_quantity
6209 INTO l_orig_model_quantity
6210 FROM oe_order_lines_all
6211 WHERE line_id=p_ato_line_id;
6212 EXCEPTION
6213 WHEN OTHERS THEN
6214 l_orig_model_quantity := 0;
6215 END;
6216
6217 IF l_orig_model_quantity is null THEN
6218 l_orig_model_quantity := 0;
6219 END IF;
6220
6221 -- Get the multiple config lines.
6222 OPEN multiple_cfg_detail(p_ato_line_id);
6223 FETCH multiple_cfg_detail
6224 INTO l_cfg_line_id,l_cfg_ordered_quantity,l_cfg_shipped_quantity;
6225
6226 -- This is the first config detail. If the quantity of the config is
6227 -- not the same as that model, then we should update the whole
6228 -- configuration.
6229
6230 IF l_cfg_ordered_quantity <> l_orig_model_quantity THEN
6231 BEGIN
6232
6233 IF l_orig_model_quantity > 0 THEN
6234
6235 UPDATE OE_ORDER_LINES_ALL
6236
6237 SET ordered_quantity = ordered_quantity/l_orig_model_quantity *
6238 l_cfg_ordered_quantity,
6239 shipped_quantity = ordered_quantity/l_orig_model_quantity *
6240 l_cfg_shipped_quantity,
6241 fulfilled_quantity = ordered_quantity/l_orig_model_quantity *
6242 l_cfg_shipped_quantity,
6243 fulfilled_flag = decode((ordered_quantity/l_orig_model_quantity *
6244 l_cfg_shipped_quantity),null,'N','Y'),
6245 fulfillment_date = decode((ordered_quantity/l_orig_model_quantity *
6246 l_cfg_shipped_quantity),null,NULL,actual_shipment_date)
6247
6248 WHERE header_id=G_HEADER_ID
6249 AND ato_line_id=p_ato_line_id
6250 AND item_type_code <> 'CONFIG';
6251
6252 UPDATE OE_ORDER_LINES_ALL OOL
6253 SET OOL.ORDERED_QUANTITY = (SELECT ORDERED_QUANTITY
6254 FROM OE_ORDER_LINES_ALL OOL1
6255 WHERE OOL1.LINE_ID = OOL.SERVICE_REFERENCE_LINE_ID)
6256 WHERE OOL.HEADER_ID = G_HEADER_ID
6257 AND OOL.ITEM_TYPE_CODE = 'SERVICE';
6258
6259 -- Select the model quantity again
6260
6261 BEGIN
6262 SELECT ordered_quantity
6263 INTO l_orig_model_quantity
6264 FROM oe_order_lines_all
6265 WHERE line_id=p_ato_line_id;
6266 EXCEPTION
6267 WHEN OTHERS THEN
6268 l_orig_model_quantity := 0;
6269 END;
6270 END IF;
6271
6272
6273 EXCEPTION
6274 WHEN OTHERS THEN
6275 null;
6276 END;
6277 END IF;
6278
6279 IF l_orig_model_quantity is null THEN
6280 l_orig_model_quantity := 0;
6281 END IF;
6282
6283 IF multiple_cfg_parent%found
6284 THEN
6285
6286 LOOP
6287
6288 -- Get next config line. You should create new model and options
6289 -- only for the second config detail.
6290
6291 FETCH multiple_cfg_detail
6292 INTO l_cfg_line_id,l_cfg_ordered_quantity,l_cfg_shipped_quantity;
6293 EXIT WHEN multiple_cfg_detail%notfound;
6294
6295
6296 -- dbms_output.put_line('Cfg Line Id: ' || l_cfg_line_id);
6297 IF l_debug_level > 0 THEN
6298 oe_debug_pub.add( 'CFG LINE ID: ' || L_CFG_LINE_ID , 1 ) ;
6299 END IF;
6300
6301 -- Create model and option lines for each of the config line.
6302
6303 OPEN model_and_options(p_ato_line_id);
6304
6305 LOOP
6306
6307 FETCH model_and_options
6308 INTO l_line_id;
6309 EXIT WHEN model_and_options%notfound;
6310
6311
6312 l_line_rec := Query_Row(l_line_id);
6313 Query_And_Set_Price_Attribs(l_line_rec.line_id,l_line_rec.header_id);
6314 IF l_line_rec.line_id = l_line_rec.ato_line_id AND
6315 l_line_rec.item_type_code in ('MODEL','CLASS') THEN
6316
6317 IF l_debug_level > 0 THEN
6318 oe_debug_pub.add( 'CREATING A NEW MODEL LINE' ) ;
6319 END IF;
6320
6321 l_new_line_rec := l_line_rec;
6322
6323 SELECT oe_order_lines_s.nextval
6324 INTO l_new_line_rec.line_id
6325 FROM dual;
6326
6327 l_new_line_rec.ato_line_id := l_new_line_rec.line_id;
6328
6329 IF l_line_rec.line_id = l_line_rec.top_model_line_id
6330 THEN
6331 l_new_line_rec.top_model_line_id := l_new_line_rec.line_id;
6332 ELSE
6333 l_new_line_rec.top_model_line_id := l_line_rec.top_model_line_id;
6334 END IF;
6335
6336 IF l_line_rec.link_to_line_id is null THEN
6337 l_new_line_rec.link_to_line_id := null;
6338 ELSE
6339 l_new_line_rec.link_to_line_id := l_line_rec.link_to_line_id;
6340 END IF;
6341
6342 l_new_line_rec.ordered_quantity := l_cfg_ordered_quantity;
6343 l_new_line_rec.shipped_quantity := l_cfg_shipped_quantity;
6344 l_new_line_rec.fulfilled_quantity := l_cfg_shipped_quantity;
6345
6346 IF nvl(l_cfg_shipped_quantity,0) <> 0 THEN
6347
6348 l_new_line_rec.fulfilled_flag := 'Y';
6349 l_new_line_rec.fulfillment_date := l_line_rec.actual_shipment_date;
6350 ELSE
6351 l_new_line_rec.fulfilled_flag := 'N';
6352 l_new_line_rec.fulfillment_date := NULL;
6353
6354 END IF;
6355
6356 l_model_rec := l_new_line_rec;
6357
6358 IF l_debug_level > 0 THEN
6359 oe_debug_pub.add( 'INSERTING A MODEL LINE :' || L_NEW_LINE_REC.LINE_ID ) ;
6360 END IF;
6361
6362 INSERT_ROW(l_new_line_rec, l_line_id);
6363
6364 -- Update the config item to point to the new model.
6365
6366 UPDATE oe_order_lines_all
6367 SET ato_line_id = l_model_rec.line_id,
6368 top_model_line_id = l_model_rec.top_model_line_id,
6369 link_to_line_id = l_model_rec.line_id
6370 WHERE line_id=l_cfg_line_id;
6371 /*
6372 UPDATE oe_order_lines_all
6373 SET link_to_line_id = l_model_rec.line_id
6374 WHERE line_id=l_cfg_line_id;
6375 */
6376 OPEN service_lines(l_line_id);
6377
6378 LOOP
6379 FETCH SERVICE_LINES INTO
6380 l_service_line_id;
6381 EXIT WHEN SERVICE_LINES%NOTFOUND;
6382
6383 l_service_line_rec := Query_Row(l_service_line_id);
6384 Query_And_Set_Price_Attribs(l_service_line_rec.line_id,l_service_line_rec.header_id);
6385 SELECT oe_order_lines_s.nextval
6386 INTO l_service_line_rec.line_id
6387 FROM dual;
6388
6389 l_service_line_rec.service_reference_line_id
6390 := l_new_line_rec.line_id;
6391 l_service_line_rec.ordered_quantity
6392 := l_new_line_rec.ordered_quantity;
6393 INSERT_ROW(l_service_line_rec,l_service_line_id);
6394
6395 END LOOP;
6396 CLOSE service_lines;
6397
6398 ELSE
6399 -- dbms_output.put_line('Creating a new option line ');
6400 IF l_debug_level > 0 THEN
6401 oe_debug_pub.add( 'CREATING A NEW OPTION LINE ' , 1 ) ;
6402 END IF;
6403 l_new_line_rec := l_line_rec;
6404
6405 SELECT oe_order_lines_s.nextval
6406 INTO l_new_line_rec.line_id
6407 FROM dual;
6408
6409 l_new_line_rec.ato_line_id := l_model_rec.line_id;
6410 l_new_line_rec.top_model_line_id := l_model_rec.top_model_line_id;
6411 l_new_line_rec.link_to_line_id := null;
6412 IF l_orig_model_quantity > 0 THEN
6413 l_new_line_rec.ordered_quantity :=
6414 (l_new_line_rec.ordered_quantity /
6415 l_orig_model_quantity) *
6416 l_cfg_ordered_quantity;
6417
6418 l_new_line_rec.shipped_quantity :=
6419 (l_new_line_rec.ordered_quantity /
6420 l_orig_model_quantity) *
6421 l_cfg_shipped_quantity;
6422
6423 IF nvl(l_cfg_shipped_quantity,0) <> 0 THEN
6424
6425 l_new_line_rec.fulfilled_flag := 'Y';
6426 l_new_line_rec.fulfillment_date := l_line_rec.actual_shipment_date;
6427 l_new_line_rec.fulfilled_quantity :=
6428 (l_new_line_rec.ordered_quantity /
6429 l_orig_model_quantity) *
6430 l_cfg_shipped_quantity;
6431 ELSE
6432 l_new_line_rec.fulfilled_flag := 'N';
6433 l_new_line_rec.fulfillment_date := NULL;
6434 l_new_line_rec.fulfilled_quantity := NULL;
6435
6436 END IF;
6437
6438 END IF;
6439
6440 INSERT_ROW(l_new_line_rec,l_line_id);
6441
6442 OPEN service_lines(l_line_id);
6443
6444 LOOP
6445 FETCH SERVICE_LINES INTO
6446 l_service_line_id;
6447 EXIT WHEN SERVICE_LINES%NOTFOUND;
6448
6449 l_service_line_rec := Query_Row(l_service_line_id);
6450 Query_And_Set_Price_Attribs(l_service_line_rec.line_id,l_service_line_rec.header_id);
6451 SELECT oe_order_lines_s.nextval
6452 INTO l_service_line_rec.line_id
6453 FROM dual;
6454
6455 l_service_line_rec.service_reference_line_id
6456 := l_new_line_rec.line_id;
6457 l_service_line_rec.ordered_quantity
6458 := l_new_line_rec.ordered_quantity;
6459
6460 INSERT_ROW(l_service_line_rec,l_service_line_id);
6461
6462 END LOOP;
6463 CLOSE service_lines;
6464 END IF;
6465
6466 END LOOP;
6467
6468 CLOSE model_and_options;
6469
6470 /* Update LINK_TO_LINE_ID for all the new classes and options
6471 created */
6472
6473 UPDATE OE_ORDER_LINES_ALL OEOPT
6474 SET LINK_TO_LINE_ID = (
6475 SELECT OELNK.LINE_ID
6476 FROM OE_ORDER_LINES_ALL OELNK
6477 WHERE( OELNK.LINE_ID = OEOPT.TOP_MODEL_LINE_ID
6478 OR OELNK.TOP_MODEL_LINE_ID = OEOPT.TOP_MODEL_LINE_ID )
6479 AND OELNK.COMPONENT_CODE =
6480 SUBSTR( OEOPT.COMPONENT_CODE,
6481 1, LENGTH( RTRIM( OEOPT.COMPONENT_CODE,
6482 '0123456789' ) ) - 1 )
6483 AND OELNK.ATO_LINE_ID = l_model_rec.line_id)
6484 WHERE HEADER_ID = l_model_rec.header_id
6485 AND ATO_LINE_ID = l_model_rec.line_id
6486 AND ITEM_TYPE_CODE <> 'SERVICE';
6487
6488 END LOOP;
6489
6490 END IF;
6491
6492 CLOSE multiple_cfg_detail;
6493
6494 END LOOP;
6495 exception
6496 when others then
6497 v_error_code := sqlcode;
6498 OE_UPG_SO_NEW.upgrade_insert_errors
6499 ( L_header_id => g_header_id,
6500 L_comments => 'Exception insert_multiple_models: '
6501 ||'Error code -'
6502 ||to_char(v_error_code)
6503 );
6504 raise;
6505
6506 END insert_multiple_models;
6507
6508
6509 FUNCTION Query_Row
6510 ( p_line_id IN NUMBER) RETURN OE_Order_PUB.Line_Rec_Type
6511 IS
6512 l_line_rec OE_Order_PUB.Line_Rec_Type;
6513 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
6514
6515 CURSOR l_line_csr IS
6516 SELECT ACCOUNTING_RULE_ID
6517 , ACTUAL_ARRIVAL_DATE
6518 , ACTUAL_SHIPMENT_DATE
6519 , AGREEMENT_ID
6520 , ARRIVAL_SET_ID
6521 , ATO_LINE_ID
6522 , ATTRIBUTE1
6523 , ATTRIBUTE10
6524 , ATTRIBUTE11
6525 , ATTRIBUTE12
6526 , ATTRIBUTE13
6527 , ATTRIBUTE14
6528 , ATTRIBUTE15
6529 , ATTRIBUTE2
6530 , ATTRIBUTE3
6531 , ATTRIBUTE4
6532 , ATTRIBUTE5
6533 , ATTRIBUTE6
6534 , ATTRIBUTE7
6535 , ATTRIBUTE8
6536 , ATTRIBUTE9
6537 , AUTO_SELECTED_QUANTITY
6538 , AUTHORIZED_TO_SHIP_FLAG
6539 , BOOKED_FLAG
6540 , CANCELLED_FLAG
6541 , CANCELLED_QUANTITY
6542 , COMPONENT_CODE
6543 , COMPONENT_NUMBER
6544 , COMPONENT_SEQUENCE_ID
6545 , CONFIG_HEADER_ID
6546 , CONFIG_REV_NBR
6547 , CONFIG_DISPLAY_SEQUENCE
6548 , CONFIGURATION_ID
6549 , CONTEXT
6550
6551 , CREATED_BY
6552 , CREATION_DATE
6553 , CREDIT_INVOICE_LINE_ID
6554 , CUSTOMER_DOCK_CODE
6555 , CUSTOMER_JOB
6556 , CUSTOMER_PRODUCTION_LINE
6557 , CUST_PRODUCTION_SEQ_NUM
6558 , CUSTOMER_TRX_LINE_ID
6559 , CUST_MODEL_SERIAL_NUMBER
6560 , CUST_PO_NUMBER
6561 , DELIVERY_LEAD_TIME
6562 , DELIVER_TO_CONTACT_ID
6563 , DELIVER_TO_ORG_ID
6564 , DEMAND_BUCKET_TYPE_CODE
6565 , DEMAND_CLASS_CODE
6566 , DEP_PLAN_REQUIRED_FLAG
6567
6568 , EARLIEST_ACCEPTABLE_DATE
6569 , END_ITEM_UNIT_NUMBER
6570 , EXPLOSION_DATE
6571 , FIRST_ACK_CODE
6572 , FIRST_ACK_DATE
6573 , FOB_POINT_CODE
6574 , FREIGHT_CARRIER_CODE
6575 , FREIGHT_TERMS_CODE
6576 , FULFILLED_QUANTITY
6577 , FULFILLED_FLAG
6578 , FULFILLMENT_METHOD_CODE
6579 , FULFILLMENT_DATE
6580 , GLOBAL_ATTRIBUTE1
6581 , GLOBAL_ATTRIBUTE10
6582 , GLOBAL_ATTRIBUTE11
6583 , GLOBAL_ATTRIBUTE12
6584 , GLOBAL_ATTRIBUTE13
6585 , GLOBAL_ATTRIBUTE14
6586 , GLOBAL_ATTRIBUTE15
6587 , GLOBAL_ATTRIBUTE16
6588 , GLOBAL_ATTRIBUTE17
6589 , GLOBAL_ATTRIBUTE18
6590 , GLOBAL_ATTRIBUTE19
6591 , GLOBAL_ATTRIBUTE2
6592 , GLOBAL_ATTRIBUTE20
6593 , GLOBAL_ATTRIBUTE3
6594 , GLOBAL_ATTRIBUTE4
6595 , GLOBAL_ATTRIBUTE5
6596 , GLOBAL_ATTRIBUTE6
6597 , GLOBAL_ATTRIBUTE7
6598 , GLOBAL_ATTRIBUTE8
6599 , GLOBAL_ATTRIBUTE9
6600 , GLOBAL_ATTRIBUTE_CATEGORY
6601 , HEADER_ID
6602 , INDUSTRY_ATTRIBUTE1
6603 , INDUSTRY_ATTRIBUTE10
6604 , INDUSTRY_ATTRIBUTE11
6605 , INDUSTRY_ATTRIBUTE12
6606 , INDUSTRY_ATTRIBUTE13
6607 , INDUSTRY_ATTRIBUTE14
6608 , INDUSTRY_ATTRIBUTE15
6609 , INDUSTRY_ATTRIBUTE16
6610 , INDUSTRY_ATTRIBUTE17
6611 , INDUSTRY_ATTRIBUTE18
6612 , INDUSTRY_ATTRIBUTE19
6613 , INDUSTRY_ATTRIBUTE20
6614 , INDUSTRY_ATTRIBUTE21
6615 , INDUSTRY_ATTRIBUTE22
6616 , INDUSTRY_ATTRIBUTE23
6617 , INDUSTRY_ATTRIBUTE24
6618 , INDUSTRY_ATTRIBUTE25
6619 , INDUSTRY_ATTRIBUTE26
6620 , INDUSTRY_ATTRIBUTE27
6621 , INDUSTRY_ATTRIBUTE28
6622 , INDUSTRY_ATTRIBUTE29
6623 , INDUSTRY_ATTRIBUTE30
6624 , INDUSTRY_ATTRIBUTE2
6625 , INDUSTRY_ATTRIBUTE3
6626 , INDUSTRY_ATTRIBUTE4
6627 , INDUSTRY_ATTRIBUTE5
6628 , INDUSTRY_ATTRIBUTE6
6629 , INDUSTRY_ATTRIBUTE7
6630 , INDUSTRY_ATTRIBUTE8
6631 , INDUSTRY_ATTRIBUTE9
6632 , INDUSTRY_CONTEXT
6633 , INTMED_SHIP_TO_CONTACT_ID
6634 , INTMED_SHIP_TO_ORG_ID
6635 , INVENTORY_ITEM_ID
6636 , INVOICE_INTERFACE_STATUS_CODE
6637
6638
6639
6640 , INVOICE_TO_CONTACT_ID
6641 , INVOICE_TO_ORG_ID
6642 , INVOICED_QUANTITY
6643 , INVOICING_RULE_ID
6644 , ORDERED_ITEM_ID
6645 , ITEM_IDENTIFIER_TYPE
6646 , ORDERED_ITEM
6647 , ITEM_REVISION
6648 , ITEM_TYPE_CODE
6649 , LAST_ACK_CODE
6650 , LAST_ACK_DATE
6651 , LAST_UPDATED_BY
6652 , LAST_UPDATE_DATE
6653 , LAST_UPDATE_LOGIN
6654 , LATEST_ACCEPTABLE_DATE
6655 , LINE_CATEGORY_CODE
6656 , LINE_ID
6657 , LINE_NUMBER
6658 , LINE_TYPE_ID
6659 , LINK_TO_LINE_ID
6660
6661 , MODEL_GROUP_NUMBER
6662 -- , MFG_COMPONENT_SEQUENCE_ID
6663 , OPEN_FLAG
6664 , OPTION_FLAG
6665 , OPTION_NUMBER
6666 , ORDERED_QUANTITY
6667 , ORDER_QUANTITY_UOM
6668 , ORG_ID
6669 , ORIG_SYS_DOCUMENT_REF
6670 , ORIG_SYS_LINE_REF
6671 , OVER_SHIP_REASON_CODE
6672 , OVER_SHIP_RESOLVED_FLAG
6673 , PAYMENT_TERM_ID
6674 , PLANNING_PRIORITY
6675 , PRICE_LIST_ID
6676 , PRICING_ATTRIBUTE1
6677 , PRICING_ATTRIBUTE10
6678 , PRICING_ATTRIBUTE2
6679 , PRICING_ATTRIBUTE3
6680 , PRICING_ATTRIBUTE4
6681 , PRICING_ATTRIBUTE5
6682 , PRICING_ATTRIBUTE6
6683 , PRICING_ATTRIBUTE7
6684 , PRICING_ATTRIBUTE8
6685 , PRICING_ATTRIBUTE9
6686 , PRICING_CONTEXT
6687 , PRICING_DATE
6688 , PRICING_QUANTITY
6689 , PRICING_QUANTITY_UOM
6690 , PROGRAM_APPLICATION_ID
6691 , PROGRAM_ID
6692 , PROGRAM_UPDATE_DATE
6693 , PROJECT_ID
6694 , PROMISE_DATE
6695 , RE_SOURCE_FLAG
6696 , REFERENCE_CUSTOMER_TRX_LINE_ID
6697 , REFERENCE_HEADER_ID
6698 , REFERENCE_LINE_ID
6699 , REFERENCE_TYPE
6700
6701 , REQUEST_DATE
6702 , REQUEST_ID
6703 , RETURN_ATTRIBUTE1
6704 , RETURN_ATTRIBUTE10
6705 , RETURN_ATTRIBUTE11
6706 , RETURN_ATTRIBUTE12
6707 , RETURN_ATTRIBUTE13
6708 , RETURN_ATTRIBUTE14
6709 , RETURN_ATTRIBUTE15
6710 , RETURN_ATTRIBUTE2
6711 , RETURN_ATTRIBUTE3
6712 , RETURN_ATTRIBUTE4
6713 , RETURN_ATTRIBUTE5
6714 , RETURN_ATTRIBUTE6
6715 , RETURN_ATTRIBUTE7
6716 , RETURN_ATTRIBUTE8
6717 , RETURN_ATTRIBUTE9
6718 , RETURN_CONTEXT
6719 , RETURN_REASON_CODE
6720 , RLA_SCHEDULE_TYPE_CODE
6721 , SALESREP_ID
6722 , SCHEDULE_ARRIVAL_DATE
6723 , SCHEDULE_SHIP_DATE
6724 , SCHEDULE_STATUS_CODE
6725 , SHIPMENT_NUMBER
6726 , SHIPMENT_PRIORITY_CODE
6727 , SHIPPED_QUANTITY
6728 , SHIPPING_METHOD_CODE
6729 , SHIPPING_QUANTITY
6730 , SHIPPING_QUANTITY_UOM
6731 , SHIP_FROM_ORG_ID
6732 , SHIP_SET_ID
6733 , SHIP_TOLERANCE_ABOVE
6734 , SHIP_TOLERANCE_BELOW
6735 , SHIPPABLE_FLAG
6736 , SHIPPING_INTERFACED_FLAG
6737 , SHIP_TO_CONTACT_ID
6738 , SHIP_TO_ORG_ID
6739 , SHIP_MODEL_COMPLETE_FLAG
6740 , SOLD_TO_ORG_ID
6741 , SOLD_FROM_ORG_ID
6742 , SORT_ORDER
6743 , SOURCE_DOCUMENT_ID
6744 , SOURCE_DOCUMENT_LINE_ID
6745 , SOURCE_DOCUMENT_TYPE_ID
6746 , SOURCE_TYPE_CODE
6747 , SPLIT_FROM_LINE_ID
6748 , LINE_SET_ID
6749 , SPLIT_BY
6750 , MODEL_REMNANT_FLAG
6751 , TASK_ID
6752 , TAX_CODE
6753 , TAX_DATE
6754 , TAX_EXEMPT_FLAG
6755 , TAX_EXEMPT_NUMBER
6756 , TAX_EXEMPT_REASON_CODE
6757 , TAX_POINT_CODE
6758 , TAX_RATE
6759 , TAX_VALUE
6760 , TOP_MODEL_LINE_ID
6761 , UNIT_LIST_PRICE
6762 , UNIT_SELLING_PRICE
6763 , VISIBLE_DEMAND_FLAG
6764 , VEH_CUS_ITEM_CUM_KEY_ID
6765 , SHIPPING_INSTRUCTIONS
6766 , PACKING_INSTRUCTIONS
6767 , SERVICE_TXN_REASON_CODE
6768 , SERVICE_TXN_COMMENTS
6769 , SERVICE_DURATION
6770 , SERVICE_PERIOD
6771 , SERVICE_START_DATE
6772 , SERVICE_END_DATE
6773 , SERVICE_COTERMINATE_FLAG
6774 , UNIT_LIST_PERCENT
6775 , UNIT_SELLING_PERCENT
6776 , UNIT_PERCENT_BASE_PRICE
6777 , SERVICE_NUMBER
6778 , SERVICE_REFERENCE_TYPE_CODE
6779 , SERVICE_REFERENCE_LINE_ID
6780 , SERVICE_REFERENCE_SYSTEM_ID
6781 , TP_CONTEXT
6782 , TP_ATTRIBUTE1
6783 , TP_ATTRIBUTE2
6784 , TP_ATTRIBUTE3
6785 , TP_ATTRIBUTE4
6786 , TP_ATTRIBUTE5
6787 , TP_ATTRIBUTE6
6788 , TP_ATTRIBUTE7
6789 , TP_ATTRIBUTE8
6790 , TP_ATTRIBUTE9
6791 , TP_ATTRIBUTE10
6792 , TP_ATTRIBUTE11
6793 , TP_ATTRIBUTE12
6794 , TP_ATTRIBUTE13
6795 , TP_ATTRIBUTE14
6796 , TP_ATTRIBUTE15
6797 , FLOW_STATUS_CODE
6798 , MARKETING_SOURCE_CODE_ID
6799 , CALCULATE_PRICE_FLAG
6800 , COMMITMENT_ID
6801 , UPGRADED_FLAG
6802 , ORDER_SOURCE_ID -- aksingh
6803 FROM OE_ORDER_LINES_ALL
6804 WHERE LINE_ID = p_line_id ;
6805
6806
6807 --
6808 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6809 --
6810 BEGIN
6811
6812 -- Loop over fetched records
6813
6814 FOR l_implicit_rec IN l_line_csr LOOP
6815
6816 l_line_rec.accounting_rule_id := l_implicit_rec.ACCOUNTING_RULE_ID;
6817 l_line_rec.actual_arrival_date := l_implicit_rec.ACTUAL_ARRIVAL_DATE;
6818 l_line_rec.actual_shipment_date := l_implicit_rec.ACTUAL_SHIPMENT_DATE;
6819 l_line_rec.agreement_id := l_implicit_rec.AGREEMENT_ID;
6820 l_line_rec.arrival_Set_id := l_implicit_rec.ARRIVAL_SET_ID;
6821 l_line_rec.ato_line_id := l_implicit_rec.ATO_LINE_ID;
6822 l_line_rec.attribute1 := l_implicit_rec.ATTRIBUTE1;
6823 l_line_rec.attribute10 := l_implicit_rec.ATTRIBUTE10;
6824 l_line_rec.attribute11 := l_implicit_rec.ATTRIBUTE11;
6825 l_line_rec.attribute12 := l_implicit_rec.ATTRIBUTE12;
6826 l_line_rec.attribute13 := l_implicit_rec.ATTRIBUTE13;
6827 l_line_rec.attribute14 := l_implicit_rec.ATTRIBUTE14;
6828 l_line_rec.attribute15 := l_implicit_rec.ATTRIBUTE15;
6829 l_line_rec.attribute2 := l_implicit_rec.ATTRIBUTE2;
6830 l_line_rec.attribute3 := l_implicit_rec.ATTRIBUTE3;
6831 l_line_rec.attribute4 := l_implicit_rec.ATTRIBUTE4;
6832 l_line_rec.attribute5 := l_implicit_rec.ATTRIBUTE5;
6833 l_line_rec.attribute6 := l_implicit_rec.ATTRIBUTE6;
6834 l_line_rec.attribute7 := l_implicit_rec.ATTRIBUTE7;
6835 l_line_rec.attribute8 := l_implicit_rec.ATTRIBUTE8;
6836 l_line_rec.attribute9 := l_implicit_rec.ATTRIBUTE9;
6837 l_line_rec.auto_selected_quantity := l_implicit_rec.AUTO_SELECTED_QUANTITY;
6838 l_line_rec.Authorized_to_ship_flag := l_implicit_rec.Authorized_to_ship_flag;
6839 l_line_rec.booked_flag := l_implicit_rec.booked_flag;
6840 l_line_rec.cancelled_flag := l_implicit_rec.cancelled_flag;
6841 l_line_rec.cancelled_quantity := l_implicit_rec.CANCELLED_QUANTITY;
6842 l_line_rec.component_code := l_implicit_rec.COMPONENT_CODE;
6843 l_line_rec.component_number := l_implicit_rec.COMPONENT_NUMBER;
6844 l_line_rec.component_sequence_id := l_implicit_rec.COMPONENT_SEQUENCE_ID;
6845 l_line_rec.config_header_id := l_implicit_rec.CONFIG_HEADER_ID;
6846 l_line_rec.config_rev_nbr := l_implicit_rec.CONFIG_REV_NBR;
6847 l_line_rec.config_display_sequence := l_implicit_rec.CONFIG_DISPLAY_SEQUENCE;
6848 l_line_rec.configuration_id := l_implicit_rec.CONFIGURATION_ID;
6849 l_line_rec.context := l_implicit_rec.CONTEXT;
6850
6851 l_line_rec.created_by := l_implicit_rec.CREATED_BY;
6852 l_line_rec.creation_date := l_implicit_rec.CREATION_DATE;
6853 l_line_rec.credit_invoice_line_id := l_implicit_rec.CREDIT_INVOICE_LINE_ID;
6854 l_line_rec.customer_dock_code := l_implicit_rec.CUSTOMER_DOCK_CODE;
6855 l_line_rec.customer_job := l_implicit_rec.CUSTOMER_JOB;
6856 l_line_rec.customer_production_line := l_implicit_rec.CUSTOMER_PRODUCTION_LINE;
6857 l_line_rec.cust_production_seq_num := l_implicit_rec.CUST_PRODUCTION_SEQ_NUM;
6858 l_line_rec.customer_trx_line_id := l_implicit_rec.CUSTOMER_TRX_LINE_ID;
6859 l_line_rec.cust_model_serial_number := l_implicit_rec.CUST_MODEL_SERIAL_NUMBER;
6860 l_line_rec.cust_po_number := l_implicit_rec.CUST_PO_NUMBER;
6861 l_line_rec.delivery_lead_time := l_implicit_rec.DELIVERY_LEAD_TIME;
6862 l_line_rec.deliver_to_contact_id := l_implicit_rec.DELIVER_TO_CONTACT_ID;
6863 l_line_rec.deliver_to_org_id := l_implicit_rec.DELIVER_TO_ORG_ID;
6864 l_line_rec.demand_bucket_type_code := l_implicit_rec.DEMAND_BUCKET_TYPE_CODE;
6865 l_line_rec.demand_class_code := l_implicit_rec.DEMAND_CLASS_CODE;
6866 l_line_rec.dep_plan_required_flag := l_implicit_rec.DEP_PLAN_REQUIRED_FLAG;
6867
6868 l_line_rec.earliest_acceptable_date := l_implicit_rec.EARLIEST_ACCEPTABLE_DATE;
6869 l_line_rec.end_item_unit_number := l_implicit_rec.END_ITEM_UNIT_NUMBER;
6870 l_line_rec.explosion_date := l_implicit_rec.EXPLOSION_DATE;
6871 l_line_rec.first_ack_code := l_implicit_rec.FIRST_ACK_CODE;
6872 l_line_rec.first_ack_date := l_implicit_rec.FIRST_ACK_DATE;
6873 l_line_rec.fob_point_code := l_implicit_rec.FOB_POINT_CODE;
6874 l_line_rec.freight_carrier_code := l_implicit_rec.FREIGHT_CARRIER_CODE;
6875 l_line_rec.freight_terms_code := l_implicit_rec.FREIGHT_TERMS_CODE;
6876 l_line_rec.fulfilled_quantity := l_implicit_rec.FULFILLED_QUANTITY;
6877 l_line_rec.fulfilled_flag := l_implicit_rec.FULFILLED_FLAG;
6878 l_line_rec.fulfillment_method_code := l_implicit_rec.FULFILLMENT_METHOD_CODE;
6879 l_line_rec.fulfillment_date := l_implicit_rec.FULFILLMENT_DATE;
6880 l_line_rec.global_attribute1 := l_implicit_rec.GLOBAL_ATTRIBUTE1;
6881 l_line_rec.global_attribute10 := l_implicit_rec.GLOBAL_ATTRIBUTE10;
6882 l_line_rec.global_attribute11 := l_implicit_rec.GLOBAL_ATTRIBUTE11;
6883 l_line_rec.global_attribute12 := l_implicit_rec.GLOBAL_ATTRIBUTE12;
6884 l_line_rec.global_attribute13 := l_implicit_rec.GLOBAL_ATTRIBUTE13;
6885 l_line_rec.global_attribute14 := l_implicit_rec.GLOBAL_ATTRIBUTE14;
6886 l_line_rec.global_attribute15 := l_implicit_rec.GLOBAL_ATTRIBUTE15;
6887 l_line_rec.global_attribute16 := l_implicit_rec.GLOBAL_ATTRIBUTE16;
6888 l_line_rec.global_attribute17 := l_implicit_rec.GLOBAL_ATTRIBUTE17;
6889 l_line_rec.global_attribute18 := l_implicit_rec.GLOBAL_ATTRIBUTE18;
6890 l_line_rec.global_attribute19 := l_implicit_rec.GLOBAL_ATTRIBUTE19;
6891 l_line_rec.global_attribute2 := l_implicit_rec.GLOBAL_ATTRIBUTE2;
6892 l_line_rec.global_attribute20 := l_implicit_rec.GLOBAL_ATTRIBUTE20;
6893 l_line_rec.global_attribute3 := l_implicit_rec.GLOBAL_ATTRIBUTE3;
6894 l_line_rec.global_attribute4 := l_implicit_rec.GLOBAL_ATTRIBUTE4;
6895 l_line_rec.global_attribute5 := l_implicit_rec.GLOBAL_ATTRIBUTE5;
6896 l_line_rec.global_attribute6 := l_implicit_rec.GLOBAL_ATTRIBUTE6;
6897 l_line_rec.global_attribute7 := l_implicit_rec.GLOBAL_ATTRIBUTE7;
6898 l_line_rec.global_attribute8 := l_implicit_rec.GLOBAL_ATTRIBUTE8;
6899 l_line_rec.global_attribute9 := l_implicit_rec.GLOBAL_ATTRIBUTE9;
6900 l_line_rec.global_attribute_category := l_implicit_rec.GLOBAL_ATTRIBUTE_CATEGORY;
6901 l_line_rec.header_id := l_implicit_rec.HEADER_ID;
6902 l_line_rec.industry_attribute1 := l_implicit_rec.INDUSTRY_ATTRIBUTE1;
6903 l_line_rec.industry_attribute10 := l_implicit_rec.INDUSTRY_ATTRIBUTE10;
6904 l_line_rec.industry_attribute11 := l_implicit_rec.INDUSTRY_ATTRIBUTE11;
6905 l_line_rec.industry_attribute12 := l_implicit_rec.INDUSTRY_ATTRIBUTE12;
6906 l_line_rec.industry_attribute13 := l_implicit_rec.INDUSTRY_ATTRIBUTE13;
6907 l_line_rec.industry_attribute14 := l_implicit_rec.INDUSTRY_ATTRIBUTE14;
6908 l_line_rec.industry_attribute15 := l_implicit_rec.INDUSTRY_ATTRIBUTE15;
6909 l_line_rec.industry_attribute16 := l_implicit_rec.INDUSTRY_ATTRIBUTE16;
6910 l_line_rec.industry_attribute17 := l_implicit_rec.INDUSTRY_ATTRIBUTE17;
6911 l_line_rec.industry_attribute18 := l_implicit_rec.INDUSTRY_ATTRIBUTE18;
6912 l_line_rec.industry_attribute19 := l_implicit_rec.INDUSTRY_ATTRIBUTE19;
6913 l_line_rec.industry_attribute20 := l_implicit_rec.INDUSTRY_ATTRIBUTE20;
6914 l_line_rec.industry_attribute21 := l_implicit_rec.INDUSTRY_ATTRIBUTE21;
6915 l_line_rec.industry_attribute22 := l_implicit_rec.INDUSTRY_ATTRIBUTE22;
6916 l_line_rec.industry_attribute23:= l_implicit_rec.INDUSTRY_ATTRIBUTE23;
6917 l_line_rec.industry_attribute24 := l_implicit_rec.INDUSTRY_ATTRIBUTE24;
6918 l_line_rec.industry_attribute25 := l_implicit_rec.INDUSTRY_ATTRIBUTE25;
6919 l_line_rec.industry_attribute26 := l_implicit_rec.INDUSTRY_ATTRIBUTE26;
6920 l_line_rec.industry_attribute27 := l_implicit_rec.INDUSTRY_ATTRIBUTE27;
6921 l_line_rec.industry_attribute28 := l_implicit_rec.INDUSTRY_ATTRIBUTE28;
6922 l_line_rec.industry_attribute29 := l_implicit_rec.INDUSTRY_ATTRIBUTE29;
6923 l_line_rec.industry_attribute30 := l_implicit_rec.INDUSTRY_ATTRIBUTE30;
6924 l_line_rec.industry_attribute2 := l_implicit_rec.INDUSTRY_ATTRIBUTE2;
6925 l_line_rec.industry_attribute3 := l_implicit_rec.INDUSTRY_ATTRIBUTE3;
6926 l_line_rec.industry_attribute4 := l_implicit_rec.INDUSTRY_ATTRIBUTE4;
6927 l_line_rec.industry_attribute5 := l_implicit_rec.INDUSTRY_ATTRIBUTE5;
6928 l_line_rec.industry_attribute6 := l_implicit_rec.INDUSTRY_ATTRIBUTE6;
6929 l_line_rec.industry_attribute7 := l_implicit_rec.INDUSTRY_ATTRIBUTE7;
6930 l_line_rec.industry_attribute8 := l_implicit_rec.INDUSTRY_ATTRIBUTE8;
6931 l_line_rec.industry_attribute9 := l_implicit_rec.INDUSTRY_ATTRIBUTE9;
6932 l_line_rec.industry_context := l_implicit_rec.INDUSTRY_CONTEXT;
6933 l_line_rec.intermed_ship_to_contact_id := l_implicit_rec.INTMED_SHIP_TO_CONTACT_ID;
6934 l_line_rec.intermed_ship_to_org_id := l_implicit_rec.INTMED_SHIP_TO_ORG_ID;
6935 l_line_rec.inventory_item_id := l_implicit_rec.INVENTORY_ITEM_ID;
6936 l_line_rec.invoice_interface_status_code := l_implicit_rec.INVOICE_INTERFACE_STATUS_CODE;
6937
6938 l_line_rec.invoice_to_contact_id := l_implicit_rec.INVOICE_TO_CONTACT_ID;
6939 l_line_rec.invoice_to_org_id := l_implicit_rec.INVOICE_TO_ORG_ID;
6940 l_line_rec.invoiced_quantity := l_implicit_rec.INVOICED_QUANTITY;
6941 l_line_rec.invoicing_rule_id := l_implicit_rec.INVOICING_RULE_ID;
6942 l_line_rec.ordered_item_id := l_implicit_rec.ORDERED_ITEM_ID;
6943 l_line_rec.item_identifier_type := l_implicit_rec.ITEM_IDENTIFIER_TYPE;
6944 l_line_rec.ordered_item := l_implicit_rec.ORDERED_ITEM;
6945 l_line_rec.item_revision := l_implicit_rec.ITEM_REVISION;
6946 l_line_rec.item_type_code := l_implicit_rec.ITEM_TYPE_CODE;
6947 l_line_rec.last_ack_code := l_implicit_rec.LAST_ACK_CODE;
6948 l_line_rec.last_ack_date := l_implicit_rec.LAST_ACK_DATE;
6949 l_line_rec.last_updated_by := l_implicit_rec.LAST_UPDATED_BY;
6950 l_line_rec.last_update_date := l_implicit_rec.LAST_UPDATE_DATE;
6951 l_line_rec.last_update_login := l_implicit_rec.LAST_UPDATE_LOGIN;
6952 l_line_rec.latest_acceptable_date := l_implicit_rec.LATEST_ACCEPTABLE_DATE;
6953 l_line_rec.line_category_code := l_implicit_rec.LINE_CATEGORY_CODE;
6954 l_line_rec.line_id := l_implicit_rec.LINE_ID;
6955 l_line_rec.line_number := l_implicit_rec.LINE_NUMBER;
6956 l_line_rec.line_type_id := l_implicit_rec.LINE_TYPE_ID;
6957 l_line_rec.link_to_line_id := l_implicit_rec.LINK_TO_LINE_ID;
6958
6959 l_line_rec.model_group_number := l_implicit_rec.MODEL_GROUP_NUMBER;
6960 -- l_line_rec.mfg_component_sequence_id := l_implicit_rec.MFG_COMPONENT_SEQUENCE_ID;
6961 l_line_rec.open_flag := l_implicit_rec.open_flag;
6962 l_line_rec.option_flag := l_implicit_rec.OPTION_FLAG;
6963 l_line_rec.option_number := l_implicit_rec.OPTION_NUMBER;
6964 l_line_rec.ordered_quantity := l_implicit_rec.ORDERED_QUANTITY;
6965 l_line_rec.order_quantity_uom := l_implicit_rec.ORDER_QUANTITY_UOM;
6966 l_line_rec.org_id := l_implicit_rec.ORG_ID;
6967 l_line_rec.orig_sys_document_ref := l_implicit_rec.ORIG_SYS_DOCUMENT_REF;
6968 l_line_rec.orig_sys_line_ref := l_implicit_rec.ORIG_SYS_LINE_REF;
6969 l_line_rec.over_ship_reason_code := l_implicit_rec.OVER_SHIP_REASON_CODE;
6970 l_line_rec.over_ship_resolved_flag := l_implicit_rec.OVER_SHIP_RESOLVED_FLAG;
6971 l_line_rec.source_document_line_id := l_implicit_rec.SOURCE_DOCUMENT_LINE_ID;
6972 l_line_rec.payment_term_id := l_implicit_rec.PAYMENT_TERM_ID;
6973 l_line_rec.planning_priority := l_implicit_rec.PLANNING_PRIORITY;
6974 l_line_rec.price_list_id := l_implicit_rec.PRICE_LIST_ID;
6975 l_line_rec.pricing_attribute1 := l_implicit_rec.PRICING_ATTRIBUTE1;
6976 l_line_rec.pricing_attribute10 := l_implicit_rec.PRICING_ATTRIBUTE10;
6977 l_line_rec.pricing_attribute2 := l_implicit_rec.PRICING_ATTRIBUTE2;
6978 l_line_rec.pricing_attribute3 := l_implicit_rec.PRICING_ATTRIBUTE3;
6979 l_line_rec.pricing_attribute4 := l_implicit_rec.PRICING_ATTRIBUTE4;
6980 l_line_rec.pricing_attribute5 := l_implicit_rec.PRICING_ATTRIBUTE5;
6981 l_line_rec.pricing_attribute6 := l_implicit_rec.PRICING_ATTRIBUTE6;
6982 l_line_rec.pricing_attribute7 := l_implicit_rec.PRICING_ATTRIBUTE7;
6983 l_line_rec.pricing_attribute8 := l_implicit_rec.PRICING_ATTRIBUTE8;
6984 l_line_rec.pricing_attribute9 := l_implicit_rec.PRICING_ATTRIBUTE9;
6985 l_line_rec.pricing_context := l_implicit_rec.PRICING_CONTEXT;
6986 l_line_rec.pricing_date := l_implicit_rec.PRICING_DATE;
6987 l_line_rec.pricing_quantity := l_implicit_rec.PRICING_QUANTITY;
6988 l_line_rec.pricing_quantity_uom := l_implicit_rec.PRICING_QUANTITY_UOM;
6989 l_line_rec.program_application_id := l_implicit_rec.PROGRAM_APPLICATION_ID;
6990 l_line_rec.program_id := l_implicit_rec.PROGRAM_ID;
6991 l_line_rec.program_update_date := l_implicit_rec.PROGRAM_UPDATE_DATE;
6992 l_line_rec.project_id := l_implicit_rec.PROJECT_ID;
6993 l_line_rec.promise_date := l_implicit_rec.PROMISE_DATE;
6994 l_line_rec.re_source_flag := l_implicit_rec.RE_SOURCE_FLAG;
6995 l_line_rec.reference_customer_trx_line_id := l_implicit_rec.reference_customer_trx_line_id;
6996 l_line_rec.reference_header_id := l_implicit_rec.REFERENCE_HEADER_ID;
6997 l_line_rec.reference_line_id := l_implicit_rec.REFERENCE_LINE_ID;
6998 l_line_rec.reference_type := l_implicit_rec.REFERENCE_TYPE;
6999
7000 l_line_rec.request_date := l_implicit_rec.REQUEST_DATE;
7001 l_line_rec.request_id := l_implicit_rec.REQUEST_ID;
7002 l_line_rec.return_attribute1 := l_implicit_rec.RETURN_ATTRIBUTE1;
7003 l_line_rec.return_attribute10 := l_implicit_rec.RETURN_ATTRIBUTE10;
7004 l_line_rec.return_attribute11 := l_implicit_rec.RETURN_ATTRIBUTE11;
7005 l_line_rec.return_attribute12 := l_implicit_rec.RETURN_ATTRIBUTE12;
7006 l_line_rec.return_attribute13 := l_implicit_rec.RETURN_ATTRIBUTE13;
7007 l_line_rec.return_attribute14 := l_implicit_rec.RETURN_ATTRIBUTE14;
7008 l_line_rec.return_attribute15 := l_implicit_rec.RETURN_ATTRIBUTE15;
7009 l_line_rec.return_attribute2 := l_implicit_rec.RETURN_ATTRIBUTE2;
7010 l_line_rec.return_attribute3 := l_implicit_rec.RETURN_ATTRIBUTE3;
7011 l_line_rec.return_attribute4 := l_implicit_rec.RETURN_ATTRIBUTE4;
7012 l_line_rec.return_attribute5 := l_implicit_rec.RETURN_ATTRIBUTE5;
7013 l_line_rec.return_attribute6 := l_implicit_rec.RETURN_ATTRIBUTE6;
7014 l_line_rec.return_attribute7 := l_implicit_rec.RETURN_ATTRIBUTE7;
7015 l_line_rec.return_attribute8 := l_implicit_rec.RETURN_ATTRIBUTE8;
7016 l_line_rec.return_attribute9 := l_implicit_rec.RETURN_ATTRIBUTE9;
7017 l_line_rec.return_context := l_implicit_rec.RETURN_CONTEXT;
7018 l_line_rec.return_reason_code := l_implicit_rec.RETURN_REASON_CODE;
7019 l_line_rec.salesrep_id := l_implicit_rec.SALESREP_ID;
7020 l_line_rec.rla_schedule_type_code := l_implicit_rec.RLA_SCHEDULE_TYPE_CODE;
7021 l_line_rec.schedule_arrival_date := l_implicit_rec.SCHEDULE_ARRIVAL_DATE;
7022 l_line_rec.schedule_ship_date := l_implicit_rec.SCHEDULE_SHIP_DATE;
7023 l_line_rec.schedule_status_code := l_implicit_rec.SCHEDULE_STATUS_CODE;
7024 l_line_rec.shipment_number := l_implicit_rec.SHIPMENT_NUMBER;
7025 l_line_rec.shipment_priority_code := l_implicit_rec.SHIPMENT_PRIORITY_CODE;
7026 l_line_rec.shipped_quantity := l_implicit_rec.SHIPPED_QUANTITY;
7027 l_line_rec.shipping_method_code := l_implicit_rec.SHIPPING_METHOD_CODE;
7028 l_line_rec.shipping_quantity := l_implicit_rec.SHIPPING_QUANTITY;
7029 l_line_rec.shipping_quantity_uom := l_implicit_rec.SHIPPING_QUANTITY_UOM;
7030 l_line_rec.ship_from_org_id := l_implicit_rec.SHIP_FROM_ORG_ID;
7031 l_line_rec.ship_set_id := l_implicit_rec.SHIP_SET_ID;
7032 l_line_rec.ship_tolerance_above := l_implicit_rec.SHIP_TOLERANCE_ABOVE;
7033 l_line_rec.ship_tolerance_below := l_implicit_rec.SHIP_TOLERANCE_BELOW;
7034 l_line_rec.shippable_flag := l_implicit_rec.SHIPPABLE_FLAG;
7035 l_line_rec.shipping_interfaced_flag := l_implicit_rec.SHIPPING_INTERFACED_FLAG;
7036 l_line_rec.ship_to_contact_id := l_implicit_rec.SHIP_TO_CONTACT_ID;
7037 l_line_rec.ship_to_org_id := l_implicit_rec.SHIP_TO_ORG_ID;
7038 l_line_rec.ship_model_complete_flag := l_implicit_rec.SHIP_MODEL_COMPLETE_FLAG;
7039
7040 l_line_rec.sold_to_org_id := l_implicit_rec.SOLD_TO_ORG_ID;
7041 l_line_rec.sold_from_org_id := l_implicit_rec.SOLD_FROM_ORG_ID;
7042 l_line_rec.sort_order := l_implicit_rec.SORT_ORDER;
7043 l_line_rec.source_document_id := l_implicit_rec.SOURCE_DOCUMENT_ID;
7044 l_line_rec.source_document_line_id := l_implicit_rec.SOURCE_DOCUMENT_LINE_ID;
7045 l_line_rec.source_document_type_id := l_implicit_rec.SOURCE_DOCUMENT_TYPE_ID;
7046 l_line_rec.source_type_code := l_implicit_rec.SOURCE_TYPE_CODE;
7047 l_line_rec.split_from_line_id := l_implicit_rec.SPLIT_FROM_LINE_ID;
7048 l_line_rec.line_set_id := l_implicit_rec.LINE_SET_ID;
7049 l_line_rec.split_by := l_implicit_rec.SPLIT_BY;
7050 l_line_rec.model_remnant_flag := l_implicit_rec.MODEL_REMNANT_FLAG;
7051 l_line_rec.task_id := l_implicit_rec.TASK_ID;
7052 l_line_rec.tax_code := l_implicit_rec.TAX_CODE;
7053 l_line_rec.tax_date := l_implicit_rec.TAX_DATE;
7054 l_line_rec.tax_exempt_flag := l_implicit_rec.TAX_EXEMPT_FLAG;
7055 l_line_rec.tax_exempt_number := l_implicit_rec.TAX_EXEMPT_NUMBER;
7056 l_line_rec.tax_exempt_reason_code := l_implicit_rec.TAX_EXEMPT_REASON_CODE;
7057 l_line_rec.tax_point_code := l_implicit_rec.TAX_POINT_CODE;
7058 l_line_rec.tax_rate := l_implicit_rec.TAX_RATE;
7059 l_line_rec.tax_value := l_implicit_rec.TAX_VALUE;
7060 l_line_rec.top_model_line_id := l_implicit_rec.TOP_MODEL_LINE_ID;
7061 l_line_rec.unit_list_price := l_implicit_rec.UNIT_LIST_PRICE;
7062 l_line_rec.unit_selling_price := l_implicit_rec.UNIT_SELLING_PRICE;
7063 l_line_rec.visible_demand_flag := l_implicit_rec.VISIBLE_DEMAND_FLAG;
7064 l_line_rec.veh_cus_item_cum_key_id := l_implicit_rec.VEH_CUS_ITEM_CUM_KEY_ID;
7065 l_line_rec.shipping_instructions := l_implicit_rec.shipping_instructions;
7066 l_line_rec.packing_instructions := l_implicit_rec.packing_instructions;
7067 l_line_rec.service_txn_reason_code := l_implicit_rec.service_txn_reason_code;
7068 l_line_rec.service_txn_comments := l_implicit_rec.service_txn_comments;
7069 l_line_rec.service_duration := l_implicit_rec.service_duration;
7070 l_line_rec.service_period := l_implicit_rec.service_period;
7071 l_line_rec.service_start_date := l_implicit_rec.service_start_date;
7072 l_line_rec.service_end_date := l_implicit_rec.service_end_date;
7073 l_line_rec.service_coterminate_flag := l_implicit_rec.service_coterminate_flag;
7074 l_line_rec.unit_list_percent := l_implicit_rec.unit_list_percent;
7075 l_line_rec.unit_selling_percent := l_implicit_rec.unit_selling_percent;
7076 l_line_rec.unit_percent_base_price := l_implicit_rec.unit_percent_base_price;
7077 l_line_rec.service_number := l_implicit_rec.service_number;
7078 l_line_rec.service_reference_type_code := l_implicit_rec.service_reference_type_code;
7079 l_line_rec.service_reference_line_id:= l_implicit_rec.service_reference_line_id;
7080 l_line_rec.service_reference_system_id:= l_implicit_rec.service_reference_system_id;
7081
7082 l_line_rec.tp_context := l_implicit_rec.tp_context;
7083 l_line_rec.tp_attribute1 := l_implicit_rec.tp_attribute1;
7084 l_line_rec.tp_attribute2 := l_implicit_rec.tp_attribute2;
7085 l_line_rec.tp_attribute3 := l_implicit_rec.tp_attribute3;
7086 l_line_rec.tp_attribute4 := l_implicit_rec.tp_attribute4;
7087 l_line_rec.tp_attribute5 := l_implicit_rec.tp_attribute5;
7088 l_line_rec.tp_attribute6 := l_implicit_rec.tp_attribute6;
7089 l_line_rec.tp_attribute7 := l_implicit_rec.tp_attribute7;
7090 l_line_rec.tp_attribute8 := l_implicit_rec.tp_attribute8;
7091 l_line_rec.tp_attribute9 := l_implicit_rec.tp_attribute9;
7092 l_line_rec.tp_attribute10:= l_implicit_rec.tp_attribute10;
7093 l_line_rec.tp_attribute11:= l_implicit_rec.tp_attribute11;
7094 l_line_rec.tp_attribute12:= l_implicit_rec.tp_attribute12;
7095 l_line_rec.tp_attribute13:= l_implicit_rec.tp_attribute13;
7096 l_line_rec.tp_attribute14:= l_implicit_rec.tp_attribute14;
7097 l_line_rec.tp_attribute15:= l_implicit_rec.tp_attribute15;
7098 l_line_rec.flow_status_code := l_implicit_rec.flow_status_code;
7099 l_line_rec.marketing_source_code_id := l_implicit_rec.marketing_source_code_id;
7100 l_line_rec.calculate_price_flag := l_implicit_rec.calculate_price_flag;
7101 l_line_rec.commitment_id := l_implicit_rec.commitment_id;
7102 l_line_rec.order_source_id := l_implicit_rec.order_source_id;
7103 l_line_rec.upgraded_flag := l_implicit_rec.upgraded_flag;
7104 l_line_tbl(l_line_tbl.COUNT + 1) := l_line_rec;
7105
7106 END LOOP;
7107
7108
7109 RETURN l_line_tbl(1);
7110
7111 EXCEPTION
7112
7113 WHEN NO_DATA_FOUND THEN
7114
7115 RAISE NO_DATA_FOUND;
7116
7117 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7118
7119 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7120
7121 WHEN OTHERS THEN
7122
7123 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7124
7125 END Query_Row;
7126
7127 PROCEDURE Insert_Row
7128 ( p_line_rec IN OE_Order_PUB.Line_Rec_Type,
7129 p_orig_line_id IN Number,
7130 p_upgraded_flag IN Varchar2 default 'Y',
7131 p_apply_price_adj IN Varchar2 default 'Y'
7132 )
7133 IS
7134 --
7135 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
7136 --
7137 BEGIN
7138
7139 /* bring old_line_id from log table using the L_Line_id as the new_line_id */
7140
7141 G_OLD_LINE_ID := 0;
7142 begin
7143 select max(old_line_id) into G_OLD_LINE_ID from oe_upgrade_log_v
7144 where new_line_id = p_orig_line_id;
7145 exception
7146 when others then
7147 G_OLD_LINE_ID := 0;
7148 end;
7149
7150 INSERT INTO OE_ORDER_LINES_ALL
7151 ( ORG_ID
7152 , ACCOUNTING_RULE_ID
7153 , ACTUAL_ARRIVAL_DATE
7154 , ACTUAL_SHIPMENT_DATE
7155 , AGREEMENT_ID
7156 , ARRIVAL_SET_ID
7157 , ATO_LINE_ID
7158 , ATTRIBUTE1
7159 , ATTRIBUTE10
7160 , ATTRIBUTE11
7161 , ATTRIBUTE12
7162 , ATTRIBUTE13
7163 , ATTRIBUTE14
7164 , ATTRIBUTE15
7165 , ATTRIBUTE2
7166 , ATTRIBUTE3
7167 , ATTRIBUTE4
7168 , ATTRIBUTE5
7169 , ATTRIBUTE6
7170 , ATTRIBUTE7
7171 , ATTRIBUTE8
7172 , ATTRIBUTE9
7173 , AUTO_SELECTED_QUANTITY
7174 , AUTHORIZED_TO_SHIP_FLAG
7175 , BOOKED_FLAG
7176 , CANCELLED_FLAG
7177 , CANCELLED_QUANTITY
7178 , COMPONENT_CODE
7179 , COMPONENT_NUMBER
7180 , COMPONENT_SEQUENCE_ID
7181 , CONFIG_HEADER_ID
7182 , CONFIG_REV_NBR
7183 , CONFIG_DISPLAY_SEQUENCE
7184 , CONFIGURATION_ID
7185 , CONTEXT
7186 , CREATED_BY
7187 , CREATION_DATE
7188 , CREDIT_INVOICE_LINE_ID
7189 , CUSTOMER_LINE_NUMBER
7190 , CUSTOMER_SHIPMENT_NUMBER
7191 , CUSTOMER_ITEM_NET_PRICE
7192 , CUSTOMER_PAYMENT_TERM_ID
7193 , CUSTOMER_DOCK_CODE
7194 , CUSTOMER_JOB
7195 , CUSTOMER_PRODUCTION_LINE
7196 , CUST_PRODUCTION_SEQ_NUM
7197 , CUSTOMER_TRX_LINE_ID
7198 , CUST_MODEL_SERIAL_NUMBER
7199 , CUST_PO_NUMBER
7200 , DELIVERY_LEAD_TIME
7201 , DELIVER_TO_CONTACT_ID
7202 , DELIVER_TO_ORG_ID
7203 , DEMAND_BUCKET_TYPE_CODE
7204 , DEMAND_CLASS_CODE
7205 , DEP_PLAN_REQUIRED_FLAG
7206 --, DROP_SHIP_FLAG
7207 , EARLIEST_ACCEPTABLE_DATE
7208 , END_ITEM_UNIT_NUMBER
7209 , EXPLOSION_DATE
7210 , FIRST_ACK_CODE
7211 , FIRST_ACK_DATE
7212 , FOB_POINT_CODE
7213 , FREIGHT_CARRIER_CODE
7214 , FREIGHT_TERMS_CODE
7215 , FULFILLED_QUANTITY
7216 , FULFILLED_FLAG
7217 , FULFILLMENT_METHOD_CODE
7218 , FULFILLMENT_DATE
7219 , GLOBAL_ATTRIBUTE1
7220 , GLOBAL_ATTRIBUTE10
7221 , GLOBAL_ATTRIBUTE11
7222 , GLOBAL_ATTRIBUTE12
7223 , GLOBAL_ATTRIBUTE13
7224 , GLOBAL_ATTRIBUTE14
7225 , GLOBAL_ATTRIBUTE15
7226 , GLOBAL_ATTRIBUTE16
7227 , GLOBAL_ATTRIBUTE17
7228 , GLOBAL_ATTRIBUTE18
7229 , GLOBAL_ATTRIBUTE19
7230 , GLOBAL_ATTRIBUTE2
7231 , GLOBAL_ATTRIBUTE20
7232 , GLOBAL_ATTRIBUTE3
7233 , GLOBAL_ATTRIBUTE4
7234 , GLOBAL_ATTRIBUTE5
7235 , GLOBAL_ATTRIBUTE6
7236 , GLOBAL_ATTRIBUTE7
7237 , GLOBAL_ATTRIBUTE8
7238 , GLOBAL_ATTRIBUTE9
7239 , GLOBAL_ATTRIBUTE_CATEGORY
7240 , HEADER_ID
7241 , INDUSTRY_ATTRIBUTE1
7242 , INDUSTRY_ATTRIBUTE10
7243 , INDUSTRY_ATTRIBUTE11
7244 , INDUSTRY_ATTRIBUTE12
7245 , INDUSTRY_ATTRIBUTE13
7246 , INDUSTRY_ATTRIBUTE14
7247 , INDUSTRY_ATTRIBUTE15
7248 , INDUSTRY_ATTRIBUTE16
7249 , INDUSTRY_ATTRIBUTE17
7250 , INDUSTRY_ATTRIBUTE18
7251 , INDUSTRY_ATTRIBUTE19
7252 , INDUSTRY_ATTRIBUTE20
7253 , INDUSTRY_ATTRIBUTE21
7254 , INDUSTRY_ATTRIBUTE22
7255 , INDUSTRY_ATTRIBUTE23
7256 , INDUSTRY_ATTRIBUTE24
7257 , INDUSTRY_ATTRIBUTE25
7258 , INDUSTRY_ATTRIBUTE26
7259 , INDUSTRY_ATTRIBUTE27
7260 , INDUSTRY_ATTRIBUTE28
7261 , INDUSTRY_ATTRIBUTE29
7262 , INDUSTRY_ATTRIBUTE30
7263 , INDUSTRY_ATTRIBUTE2
7264 , INDUSTRY_ATTRIBUTE3
7265 , INDUSTRY_ATTRIBUTE4
7266 , INDUSTRY_ATTRIBUTE5
7267 , INDUSTRY_ATTRIBUTE6
7268 , INDUSTRY_ATTRIBUTE7
7269 , INDUSTRY_ATTRIBUTE8
7270 , INDUSTRY_ATTRIBUTE9
7271 , INDUSTRY_CONTEXT
7272 , INTMED_SHIP_TO_CONTACT_ID
7273 , INTMED_SHIP_TO_ORG_ID
7274 , INVENTORY_ITEM_ID
7275 , INVOICE_INTERFACE_STATUS_CODE
7276 , INVOICE_TO_CONTACT_ID
7277 , INVOICE_TO_ORG_ID
7278 , INVOICED_QUANTITY
7279 , INVOICING_RULE_ID
7280 , ORDERED_ITEM_ID
7281 , ITEM_IDENTIFIER_TYPE
7282 , ORDERED_ITEM
7283 , ITEM_REVISION
7284 , ITEM_TYPE_CODE
7285 , LAST_ACK_CODE
7286 , LAST_ACK_DATE
7287 , LAST_UPDATED_BY
7288 , LAST_UPDATE_DATE
7289 , LAST_UPDATE_LOGIN
7290 , LATEST_ACCEPTABLE_DATE
7291 , LINE_CATEGORY_CODE
7292 , LINE_ID
7293 , LINE_NUMBER
7294 , LINE_TYPE_ID
7295 , LINK_TO_LINE_ID
7296 , MODEL_GROUP_NUMBER
7297 -- , MFG_COMPONENT_SEQUENCE_ID
7298 , OPEN_FLAG
7299 , OPTION_FLAG
7300 , OPTION_NUMBER
7301 , ORDERED_QUANTITY
7302 , ORDER_QUANTITY_UOM
7303 --, ORG_ID
7304 , ORDER_SOURCE_ID
7305 , ORIG_SYS_DOCUMENT_REF
7306 , ORIG_SYS_LINE_REF
7307 , ORIG_SYS_SHIPMENT_REF
7308 , CHANGE_SEQUENCE
7309 , OVER_SHIP_REASON_CODE
7310 , OVER_SHIP_RESOLVED_FLAG
7311 , PAYMENT_TERM_ID
7312 , PLANNING_PRIORITY
7313 , PRICE_LIST_ID
7314 , PRICING_ATTRIBUTE1
7315 , PRICING_ATTRIBUTE10
7316 , PRICING_ATTRIBUTE2
7317 , PRICING_ATTRIBUTE3
7318 , PRICING_ATTRIBUTE4
7319 , PRICING_ATTRIBUTE5
7320 , PRICING_ATTRIBUTE6
7321 , PRICING_ATTRIBUTE7
7322 , PRICING_ATTRIBUTE8
7323 , PRICING_ATTRIBUTE9
7324 , PRICING_CONTEXT
7325 , PRICING_DATE
7326 , PRICING_QUANTITY
7327 , PRICING_QUANTITY_UOM
7328 , PROGRAM_APPLICATION_ID
7329 , PROGRAM_ID
7330 , PROGRAM_UPDATE_DATE
7331 , PROJECT_ID
7332 , PROMISE_DATE
7333 , RE_SOURCE_FLAG
7334 , REFERENCE_CUSTOMER_TRX_LINE_ID
7335 , REFERENCE_HEADER_ID
7336 , REFERENCE_LINE_ID
7337 , REFERENCE_TYPE
7338 , REQUEST_DATE
7339 , REQUEST_ID
7340 , RETURN_ATTRIBUTE1
7341 , RETURN_ATTRIBUTE10
7342 , RETURN_ATTRIBUTE11
7343 , RETURN_ATTRIBUTE12
7344 , RETURN_ATTRIBUTE13
7345 , RETURN_ATTRIBUTE14
7346 , RETURN_ATTRIBUTE15
7347 , RETURN_ATTRIBUTE2
7348 , RETURN_ATTRIBUTE3
7349 , RETURN_ATTRIBUTE4
7350 , RETURN_ATTRIBUTE5
7351 , RETURN_ATTRIBUTE6
7352 , RETURN_ATTRIBUTE7
7353 , RETURN_ATTRIBUTE8
7354 , RETURN_ATTRIBUTE9
7355 , RETURN_CONTEXT
7356 , RETURN_REASON_CODE
7357 , RLA_SCHEDULE_TYPE_CODE
7358 , SALESREP_ID
7359 , SCHEDULE_ARRIVAL_DATE
7360 , SCHEDULE_SHIP_DATE
7361 , SCHEDULE_STATUS_CODE
7362 , SHIPMENT_NUMBER
7363 , SHIPMENT_PRIORITY_CODE
7364 , SHIPPED_QUANTITY
7365 , SHIPPING_METHOD_CODE
7366 , SHIPPING_QUANTITY
7367 , SHIPPING_QUANTITY_UOM
7368 , SHIP_FROM_ORG_ID
7369 , SHIP_SET_ID
7370 , SHIP_TOLERANCE_ABOVE
7371 , SHIP_TOLERANCE_BELOW
7372 , SHIPPABLE_FLAG
7373 , SHIPPING_INTERFACED_FLAG
7374 , SHIP_TO_CONTACT_ID
7375 , SHIP_TO_ORG_ID
7376 , SHIP_MODEL_COMPLETE_FLAG
7377 , SOLD_TO_ORG_ID
7378 , SOLD_FROM_ORG_ID
7379 , SORT_ORDER
7380 , SOURCE_DOCUMENT_ID
7381 , SOURCE_DOCUMENT_LINE_ID
7382 , SOURCE_DOCUMENT_TYPE_ID
7383 , SOURCE_TYPE_CODE
7384 , SPLIT_FROM_LINE_ID
7385 , LINE_SET_ID
7386 , SPLIT_BY
7387 , model_remnant_flag
7388 , TASK_ID
7389 , TAX_CODE
7390 , TAX_DATE
7391 , TAX_EXEMPT_FLAG
7392 , TAX_EXEMPT_NUMBER
7393 , TAX_EXEMPT_REASON_CODE
7394 , TAX_POINT_CODE
7395 , TAX_RATE
7396 , TAX_VALUE
7397 , TOP_MODEL_LINE_ID
7398 , UNIT_LIST_PRICE
7399 , UNIT_SELLING_PRICE
7400 , VISIBLE_DEMAND_FLAG
7401 , VEH_CUS_ITEM_CUM_KEY_ID
7402 , SHIPPING_INSTRUCTIONS
7403 , PACKING_INSTRUCTIONS
7404 , SERVICE_TXN_REASON_CODE
7405 , SERVICE_TXN_COMMENTS
7406 , SERVICE_DURATION
7407 , SERVICE_PERIOD
7408 , SERVICE_START_DATE
7409 , SERVICE_END_DATE
7410 , SERVICE_COTERMINATE_FLAG
7411 , UNIT_LIST_PERCENT
7412 , UNIT_SELLING_PERCENT
7413 , UNIT_PERCENT_BASE_PRICE
7414 , SERVICE_NUMBER
7415 , SERVICE_REFERENCE_TYPE_CODE
7416 , SERVICE_REFERENCE_LINE_ID
7417 , SERVICE_REFERENCE_SYSTEM_ID
7418 , TP_CONTEXT
7419 , TP_ATTRIBUTE1
7420 , TP_ATTRIBUTE2
7421 , TP_ATTRIBUTE3
7422 , TP_ATTRIBUTE4
7423 , TP_ATTRIBUTE5
7424 , TP_ATTRIBUTE6
7425 , TP_ATTRIBUTE7
7426 , TP_ATTRIBUTE8
7427 , TP_ATTRIBUTE9
7428 , TP_ATTRIBUTE10
7429 , TP_ATTRIBUTE11
7430 , TP_ATTRIBUTE12
7431 , TP_ATTRIBUTE13
7432 , TP_ATTRIBUTE14
7433 , TP_ATTRIBUTE15
7434 , FLOW_STATUS_CODE
7435 , MARKETING_SOURCE_CODE_ID
7436 , CALCULATE_PRICE_FLAG
7437 , COMMITMENT_ID
7438 , UPGRADED_FLAG
7439 , LOCK_CONTROL
7440 )
7441 VALUES
7442 ( p_line_rec.org_id
7443 , p_line_rec.accounting_rule_id
7444 , p_line_rec.actual_arrival_date
7445 , p_line_rec.actual_shipment_date
7446 , p_line_rec.agreement_id
7447 , p_line_rec.arrival_set_id
7448 , p_line_rec.ato_line_id
7449 , p_line_rec.attribute1
7450 , p_line_rec.attribute10
7451 , p_line_rec.attribute11
7452 , p_line_rec.attribute12
7453 , p_line_rec.attribute13
7454 , p_line_rec.attribute14
7455 , p_line_rec.attribute15
7456 , p_line_rec.attribute2
7457 , p_line_rec.attribute3
7458 , p_line_rec.attribute4
7459 , p_line_rec.attribute5
7460 , p_line_rec.attribute6
7461 , p_line_rec.attribute7
7462 , p_line_rec.attribute8
7463 , p_line_rec.attribute9
7464 , p_line_rec.auto_selected_quantity
7465 , p_line_rec.authorized_to_ship_flag
7466 , p_line_rec.booked_flag
7467 , p_line_rec.cancelled_flag
7468 , p_line_rec.cancelled_quantity
7469 , p_line_rec.component_code
7470 , p_line_rec.component_number
7471 , p_line_rec.component_sequence_id
7472 , p_line_rec.config_header_id
7473 , p_line_rec.config_rev_nbr
7474 , p_line_rec.config_display_sequence
7475 , p_line_rec.configuration_id
7476 , p_line_rec.context
7477 , p_line_rec.created_by
7478 , p_line_rec.creation_date
7479 , p_line_rec.credit_invoice_line_id
7480 , p_line_rec.customer_line_number
7481 , p_line_rec.customer_shipment_number
7482 , p_line_rec.customer_item_net_price
7483 , p_line_rec.customer_payment_term_id
7484 , p_line_rec.customer_dock_code
7485 , p_line_rec.customer_job
7486 , p_line_rec.customer_production_line
7487 , p_line_rec.cust_production_seq_num
7488 , p_line_rec.customer_trx_line_id
7489 , p_line_rec.cust_model_serial_number
7490 , p_line_rec.cust_po_number
7491 , p_line_rec.delivery_lead_time
7492 , p_line_rec.deliver_to_contact_id
7493 , p_line_rec.deliver_to_org_id
7494 , p_line_rec.demand_bucket_type_code
7495 , p_line_rec.demand_class_code
7496 , p_line_rec.dep_plan_required_flag
7497 --, p_line_rec.drop_ship_flag
7498 , p_line_rec.earliest_acceptable_date
7499 , p_line_rec.end_item_unit_number
7500 , p_line_rec.explosion_date
7501 , p_line_rec.first_ack_code
7502 , p_line_rec.first_ack_date
7503 , p_line_rec.fob_point_code
7504 , p_line_rec.freight_carrier_code
7505 , p_line_rec.freight_terms_code
7506 , p_line_rec.fulfilled_quantity
7507 , p_line_rec.fulfilled_flag
7508 , p_line_rec.fulfillment_method_code
7509 , p_line_rec.fulfillment_date
7510 , p_line_rec.global_attribute1
7511 , p_line_rec.global_attribute10
7512 , p_line_rec.global_attribute11
7513 , p_line_rec.global_attribute12
7514 , p_line_rec.global_attribute13
7515 , p_line_rec.global_attribute14
7516 , p_line_rec.global_attribute15
7517 , p_line_rec.global_attribute16
7518 , p_line_rec.global_attribute17
7519 , p_line_rec.global_attribute18
7520 , p_line_rec.global_attribute19
7521 , p_line_rec.global_attribute2
7522 , p_line_rec.global_attribute20
7523 , p_line_rec.global_attribute3
7524 , p_line_rec.global_attribute4
7525 , p_line_rec.global_attribute5
7526 , p_line_rec.global_attribute6
7527 , p_line_rec.global_attribute7
7528 , p_line_rec.global_attribute8
7529 , p_line_rec.global_attribute9
7530 , p_line_rec.global_attribute_category
7531 , p_line_rec.header_id
7532 , p_line_rec.industry_attribute1
7533 , p_line_rec.industry_attribute10
7534 , p_line_rec.industry_attribute11
7535 , p_line_rec.industry_attribute12
7536 , p_line_rec.industry_attribute13
7537 , p_line_rec.industry_attribute14
7538 , p_line_rec.industry_attribute15
7539 , p_line_rec.industry_attribute16
7540 , p_line_rec.industry_attribute17
7541 , p_line_rec.industry_attribute18
7542 , p_line_rec.industry_attribute19
7543 , p_line_rec.industry_attribute20
7544 , p_line_rec.industry_attribute21
7545 , p_line_rec.industry_attribute22
7546 , p_line_rec.industry_attribute23
7547 , p_line_rec.industry_attribute24
7548 , p_line_rec.industry_attribute25
7549 , p_line_rec.industry_attribute26
7550 , p_line_rec.industry_attribute27
7551 , p_line_rec.industry_attribute28
7552 , p_line_rec.industry_attribute29
7553 , p_line_rec.industry_attribute30
7554 , p_line_rec.industry_attribute2
7555 , p_line_rec.industry_attribute3
7556 , p_line_rec.industry_attribute4
7557 , p_line_rec.industry_attribute5
7558 , p_line_rec.industry_attribute6
7559 , p_line_rec.industry_attribute7
7560 , p_line_rec.industry_attribute8
7561 , p_line_rec.industry_attribute9
7562 , p_line_rec.industry_context
7563 , p_line_rec.intermed_ship_to_contact_id
7564 , p_line_rec.intermed_ship_to_org_id
7565 , p_line_rec.inventory_item_id
7566 , p_line_rec.invoice_interface_status_code
7567 , p_line_rec.invoice_to_contact_id
7568 , p_line_rec.invoice_to_org_id
7569 , p_line_rec.invoiced_quantity
7570 , p_line_rec.invoicing_rule_id
7571 , p_line_rec.ordered_item_id
7572 , p_line_rec.item_identifier_type
7573 , p_line_rec.ordered_item
7574 , p_line_rec.item_revision
7575 , p_line_rec.item_type_code
7576 , p_line_rec.last_ack_code
7577 , p_line_rec.last_ack_date
7578 , p_line_rec.last_updated_by
7579 , p_line_rec.last_update_date
7580 , p_line_rec.last_update_login
7581 , p_line_rec.latest_acceptable_date
7582 , p_line_rec.line_category_code
7583 , p_line_rec.line_id
7584 , p_line_rec.line_number
7585 , p_line_rec.line_type_id
7586 , p_line_rec.link_to_line_id
7587 , p_line_rec.model_group_number
7588 --, p_line_rec.mfg_component_sequence_id
7589 , p_line_rec.open_flag
7590 , p_line_rec.option_flag
7591 , p_line_rec.option_number
7592 , p_line_rec.ordered_quantity
7593 , p_line_rec.order_quantity_uom
7594 --, l_org_id
7595 , p_line_rec.order_source_id
7596 , p_line_rec.orig_sys_document_ref
7597 , p_line_rec.orig_sys_line_ref
7598 , p_line_rec.orig_sys_shipment_ref
7599 , p_line_rec.change_sequence
7600 , p_line_rec.over_ship_reason_code
7601 , p_line_rec.over_ship_resolved_flag
7602 , p_line_rec.payment_term_id
7603 , p_line_rec.planning_priority
7604 , p_line_rec.price_list_id
7605 , p_line_rec.pricing_attribute1
7606 , p_line_rec.pricing_attribute10
7607 , p_line_rec.pricing_attribute2
7608 , p_line_rec.pricing_attribute3
7609 , p_line_rec.pricing_attribute4
7610 , p_line_rec.pricing_attribute5
7611 , p_line_rec.pricing_attribute6
7612 , p_line_rec.pricing_attribute7
7613 , p_line_rec.pricing_attribute8
7614 , p_line_rec.pricing_attribute9
7615 , p_line_rec.pricing_context
7616 , p_line_rec.pricing_date
7617 , p_line_rec.pricing_quantity
7618 , p_line_rec.pricing_quantity_uom
7619 , p_line_rec.program_application_id
7620 , p_line_rec.program_id
7621 , p_line_rec.program_update_date
7622 , p_line_rec.project_id
7623 , p_line_rec.promise_date
7624 , p_line_rec.re_source_flag
7625 , p_line_rec.reference_customer_trx_line_id
7626 , p_line_rec.reference_header_id
7627 , p_line_rec.reference_line_id
7628 , p_line_rec.reference_type
7629 , p_line_rec.request_date
7630 , p_line_rec.request_id
7631 , p_line_rec.return_attribute1
7632 , p_line_rec.return_attribute10
7633 , p_line_rec.return_attribute11
7634 , p_line_rec.return_attribute12
7635 , p_line_rec.return_attribute13
7636 , p_line_rec.return_attribute14
7637 , p_line_rec.return_attribute15
7638 , p_line_rec.return_attribute2
7639 , p_line_rec.return_attribute3
7640 , p_line_rec.return_attribute4
7641 , p_line_rec.return_attribute5
7642 , p_line_rec.return_attribute6
7643 , p_line_rec.return_attribute7
7644 , p_line_rec.return_attribute8
7645 , p_line_rec.return_attribute9
7646 , p_line_rec.return_context
7647 , p_line_rec.return_reason_code
7648 , p_line_rec.rla_schedule_type_code
7649 , p_line_rec.salesrep_id
7650 , p_line_rec.schedule_arrival_date
7651 , p_line_rec.schedule_ship_date
7652 , p_line_rec.schedule_status_code
7653 , p_line_rec.shipment_number
7654 , p_line_rec.shipment_priority_code
7655 , p_line_rec.shipped_quantity
7656 , p_line_rec.shipping_method_code
7657 , p_line_rec.shipping_quantity
7658 , p_line_rec.shipping_quantity_uom
7659 , p_line_rec.ship_from_org_id
7660 , p_line_rec.ship_set_id
7661 , p_line_rec.ship_tolerance_above
7662 , p_line_rec.ship_tolerance_below
7663 , p_line_rec.shippable_flag
7664 , p_line_rec.shipping_interfaced_flag
7665 , p_line_rec.ship_to_contact_id
7666 , p_line_rec.ship_to_org_id
7667 , p_line_rec.ship_model_complete_flag
7668
7669 , p_line_rec.sold_to_org_id
7670 , p_line_rec.sold_from_org_id
7671 , p_line_rec.sort_order
7672 , p_line_rec.source_document_id
7673 , p_line_rec.source_document_line_id
7674 , p_line_rec.source_document_type_id
7675 , p_line_rec.source_type_code
7676 , p_line_rec.split_from_line_id
7677 , p_line_rec.line_set_id
7678 , p_line_rec.split_by
7679 , p_line_rec.model_remnant_flag
7680 , p_line_rec.task_id
7681 , p_line_rec.tax_code
7682 , p_line_rec.tax_date
7683 , p_line_rec.tax_exempt_flag
7684 , p_line_rec.tax_exempt_number
7685 , p_line_rec.tax_exempt_reason_code
7686 , p_line_rec.tax_point_code
7687 , p_line_rec.tax_rate
7688 , p_line_rec.tax_value
7689 , p_line_rec.top_model_line_id
7690 , p_line_rec.unit_list_price
7691 , p_line_rec.unit_selling_price
7692 , p_line_rec.visible_demand_flag
7693 , p_line_rec.veh_cus_item_cum_key_id
7694 , p_line_rec.shipping_instructions
7695 , p_line_rec.packing_instructions
7696 , p_line_rec.service_txn_reason_code
7697 , p_line_rec.service_txn_comments
7698 , p_line_rec.service_duration
7699 , p_line_rec.service_period
7700 , p_line_rec.service_start_date
7701 , p_line_rec.service_end_date
7702 , p_line_rec.service_coterminate_flag
7703 , p_line_rec.unit_list_percent
7704 , p_line_rec.unit_selling_percent
7705 , p_line_rec.unit_percent_base_price
7706 , p_line_rec.service_number
7707 , p_line_rec.service_reference_type_code
7708 , p_line_rec.service_reference_line_id
7709 , p_line_rec.service_reference_system_id
7710 , p_line_rec.tp_context
7711 , p_line_rec.tp_attribute1
7712 , p_line_rec.tp_attribute2
7713 , p_line_rec.tp_attribute3
7714 , p_line_rec.tp_attribute4
7715 , p_line_rec.tp_attribute5
7716 , p_line_rec.tp_attribute6
7717 , p_line_rec.tp_attribute7
7718 , p_line_rec.tp_attribute8
7719 , p_line_rec.tp_attribute9
7720 , p_line_rec.tp_attribute10
7721 , p_line_rec.tp_attribute11
7722 , p_line_rec.tp_attribute12
7723 , p_line_rec.tp_attribute13
7724 , p_line_rec.tp_attribute14
7725 , p_line_rec.tp_attribute15
7726 , p_line_rec.flow_status_code
7727 , p_line_rec.marketing_source_code_id
7728 , p_line_rec.calculate_price_flag
7729 , p_line_rec.commitment_id
7730 -- , p_upgraded_flag
7731 , p_line_rec.upgraded_flag
7732 , 1
7733 );
7734
7735 insert into oe_order_lines_history
7736 (
7737 line_id,
7738 org_id,
7739 header_id,
7740 line_type_id,
7741 line_number,
7742 ordered_item,
7743 request_date,
7744 promise_date,
7745 schedule_ship_date,
7746 order_quantity_uom,
7747 pricing_quantity,
7748 pricing_quantity_uom,
7749 cancelled_quantity,
7750 shipped_quantity,
7751 ordered_quantity,
7752 fulfilled_quantity,
7753 shipping_quantity,
7754 shipping_quantity_uom,
7755 delivery_lead_time,
7756 tax_exempt_flag,
7757 tax_exempt_number,
7758 tax_exempt_reason_code,
7759 ship_from_org_id,
7760 ship_to_org_id,
7761 invoice_to_org_id,
7762 deliver_to_org_id,
7763 ship_to_contact_id,
7764 deliver_to_contact_id,
7765 invoice_to_contact_id,
7766 sold_to_org_id,
7767 cust_po_number,
7768 ship_tolerance_above,
7769 ship_tolerance_below,
7770 demand_bucket_type_code,
7771 veh_cus_item_cum_key_id,
7772 rla_schedule_type_code,
7773 customer_dock_code,
7774 customer_job,
7775 customer_production_line,
7776 cust_model_serial_number,
7777 project_id,
7778 task_id,
7779 inventory_item_id,
7780 tax_date,
7781 tax_code,
7782 tax_rate,
7783 demand_class_code,
7784 price_list_id,
7785 pricing_date,
7786 shipment_number,
7787 agreement_id,
7788 shipment_priority_code,
7789 shipping_method_code,
7790 freight_carrier_code,
7791 freight_terms_code,
7792 fob_point_code,
7793 tax_point_code,
7794 payment_term_id,
7795 invoicing_rule_id,
7796 accounting_rule_id,
7797 source_document_type_id,
7798 orig_sys_document_ref,
7799 source_document_id,
7800 orig_sys_line_ref,
7801 source_document_line_id,
7802 reference_line_id,
7803 reference_type,
7804 reference_header_id,
7805 item_revision,
7806 unit_selling_price,
7807 unit_list_price,
7808 tax_value,
7809 context,
7810 attribute1,
7811 attribute2,
7812 attribute3,
7813 attribute4,
7814 attribute5,
7815 attribute6,
7816 attribute7,
7817 attribute8,
7818 attribute9,
7819 attribute10,
7820 attribute11,
7821 attribute12,
7822 attribute13,
7823 attribute14,
7824 attribute15,
7825 global_attribute_category,
7826 global_attribute1,
7827 global_attribute2,
7828 global_attribute3,
7829 global_attribute4,
7830 global_attribute5,
7831 global_attribute6,
7832 global_attribute7,
7833 global_attribute8,
7834 global_attribute9,
7835 global_attribute10,
7836 global_attribute11,
7837 global_attribute12,
7838 global_attribute13,
7839 global_attribute14,
7840 global_attribute15,
7841 global_attribute16,
7842 global_attribute17,
7843 global_attribute18,
7844 global_attribute19,
7845 global_attribute20,
7846 pricing_context,
7847 pricing_attribute1,
7848 pricing_attribute2,
7849 pricing_attribute3,
7850 pricing_attribute4,
7851 pricing_attribute5,
7852 pricing_attribute6,
7853 pricing_attribute7,
7854 pricing_attribute8,
7855 pricing_attribute9,
7856 pricing_attribute10,
7857 industry_context,
7858 industry_attribute1,
7859 industry_attribute2,
7860 industry_attribute3,
7861 industry_attribute4,
7862 industry_attribute5,
7863 industry_attribute6,
7864 industry_attribute7,
7865 industry_attribute8,
7866 industry_attribute9,
7867 industry_attribute10,
7868 industry_attribute11,
7869 industry_attribute12,
7870 industry_attribute13,
7871 industry_attribute14,
7872 industry_attribute15,
7873 industry_attribute16,
7874 industry_attribute17,
7875 industry_attribute18,
7876 industry_attribute19,
7877 industry_attribute20,
7878 industry_attribute21,
7879 industry_attribute22,
7880 industry_attribute23,
7881 industry_attribute24,
7882 industry_attribute25,
7883 industry_attribute26,
7884 industry_attribute27,
7885 industry_attribute28,
7886 industry_attribute29,
7887 industry_attribute30,
7888 creation_date,
7889 created_by,
7890 last_update_date,
7891 last_updated_by,
7892 last_update_login,
7893 program_application_id,
7894 program_id,
7895 program_update_date,
7896 request_id,
7897 configuration_id,
7898 link_to_line_id,
7899 component_sequence_id,
7900 component_code,
7901 config_display_sequence,
7902 sort_order,
7903 item_type_code,
7904 option_number,
7905 option_flag,
7906 dep_plan_required_flag,
7907 visible_demand_flag,
7908 line_category_code,
7909 actual_shipment_date,
7910 reference_customer_trx_line_id,
7911 return_context,
7912 return_attribute1,
7913 return_attribute2,
7914 return_attribute3,
7915 return_attribute4,
7916 return_attribute5,
7917 return_attribute6,
7918 return_attribute7,
7919 return_attribute8,
7920 return_attribute9,
7921 return_attribute10,
7922 return_attribute11,
7923 return_attribute12,
7924 return_attribute13,
7925 return_attribute14,
7926 return_attribute15,
7927 intmed_ship_to_org_id,
7928 intmed_ship_to_contact_id,
7929 actual_arrival_date,
7930 ato_line_id,
7931 auto_selected_quantity,
7932 component_number,
7933 earliest_acceptable_date,
7934 explosion_date,
7935 latest_acceptable_date,
7936 model_group_number,
7937 schedule_arrival_date,
7938 ship_model_complete_flag,
7939 schedule_status_code,
7940 return_reason_code,
7941 salesrep_id,
7942 split_from_line_id,
7943 cust_production_seq_num,
7944 authorized_to_ship_flag,
7945 invoice_interface_status_code,
7946 ship_set_id,
7947 arrival_set_id,
7948 hist_comments,
7949 hist_type_code,
7950 reason_code,
7951 hist_created_by,
7952 hist_creation_date,
7953 source_type_code,
7954 booked_flag,
7955 fulfilled_flag,
7956 sold_from_org_id,
7957 top_model_line_id,
7958 cancelled_flag,
7959 open_flag,
7960 over_ship_reason_code,
7961 over_ship_resolved_flag,
7962 item_identifier_type,
7963 commitment_id,
7964 shipping_interfaced_flag,
7965 credit_invoice_line_id,
7966 end_item_unit_number,
7967 mfg_component_sequence_id,
7968 config_header_id,
7969 config_rev_nbr,
7970 shipping_instructions,
7971 packing_instructions,
7972 invoiced_quantity,
7973 customer_trx_line_id,
7974 split_by,
7975 line_set_id,
7976 tp_context,
7977 tp_attribute1,
7978 tp_attribute2,
7979 tp_attribute3,
7980 tp_attribute4,
7981 tp_attribute5,
7982 tp_attribute6,
7983 tp_attribute7,
7984 tp_attribute8,
7985 tp_attribute9,
7986 tp_attribute10,
7987 tp_attribute11,
7988 tp_attribute12,
7989 tp_attribute13,
7990 tp_attribute14,
7991 tp_attribute15,
7992 fulfillment_method_code,
7993 service_reference_type_code,
7994 service_reference_line_id,
7995 service_reference_system_id,
7996 ordered_item_id,
7997 service_number,
7998 service_duration,
7999 service_start_date,
8000 re_source_flag,
8001 flow_status_code,
8002 service_end_date,
8003 service_coterminate_flag,
8004 shippable_flag,
8005 order_source_id,
8006 orig_sys_shipment_ref,
8007 change_sequence,
8008 drop_ship_flag,
8009 customer_line_number,
8010 customer_shipment_number,
8011 customer_item_net_price,
8012 customer_payment_term_id,
8013 first_ack_date,
8014 first_ack_code,
8015 last_ack_code,
8016 last_ack_date,
8017 planning_priority,
8018 service_txn_comments,
8019 service_period,
8020 unit_selling_percent,
8021 unit_list_percent,
8022 unit_percent_base_price,
8023 model_remnant_flag,
8024 service_txn_reason_code,
8025 calculate_price_flag,
8026 revenue_amount
8027 )
8028 select
8029 p_line_rec.line_id,
8030 org_id,
8031 header_id,
8032 line_type_id,
8033 line_number,
8034 ordered_item,
8035 request_date,
8036 promise_date,
8037 schedule_ship_date,
8038 order_quantity_uom,
8039 pricing_quantity,
8040 pricing_quantity_uom,
8041 cancelled_quantity,
8042 shipped_quantity,
8043 ordered_quantity,
8044 fulfilled_quantity,
8045 shipping_quantity,
8046 shipping_quantity_uom,
8047 delivery_lead_time,
8048 tax_exempt_flag,
8049 tax_exempt_number,
8050 tax_exempt_reason_code,
8051 ship_from_org_id,
8052 ship_to_org_id,
8053 invoice_to_org_id,
8054 deliver_to_org_id,
8055 ship_to_contact_id,
8056 deliver_to_contact_id,
8057 invoice_to_contact_id,
8058 sold_to_org_id,
8059 cust_po_number,
8060 ship_tolerance_above,
8061 ship_tolerance_below,
8062 demand_bucket_type_code,
8063 veh_cus_item_cum_key_id,
8064 rla_schedule_type_code,
8065 customer_dock_code,
8066 customer_job,
8067 customer_production_line,
8068 cust_model_serial_number,
8069 project_id,
8070 task_id,
8071 inventory_item_id,
8072 tax_date,
8073 tax_code,
8074 tax_rate,
8075 demand_class_code,
8076 price_list_id,
8077 pricing_date,
8078 shipment_number,
8079 agreement_id,
8080 shipment_priority_code,
8081 shipping_method_code,
8082 freight_carrier_code,
8083 freight_terms_code,
8084 fob_point_code,
8085 tax_point_code,
8086 payment_term_id,
8087 invoicing_rule_id,
8088 accounting_rule_id,
8089 source_document_type_id,
8090 orig_sys_document_ref,
8091 source_document_id,
8092 orig_sys_line_ref,
8093 source_document_line_id,
8094 reference_line_id,
8095 reference_type,
8096 reference_header_id,
8097 item_revision,
8098 unit_selling_price,
8099 unit_list_price,
8100 tax_value,
8101 context,
8102 attribute1,
8103 attribute2,
8104 attribute3,
8105 attribute4,
8106 attribute5,
8107 attribute6,
8108 attribute7,
8109 attribute8,
8110 attribute9,
8111 attribute10,
8112 attribute11,
8113 attribute12,
8114 attribute13,
8115 attribute14,
8116 attribute15,
8117 global_attribute_category,
8118 global_attribute1,
8119 global_attribute2,
8120 global_attribute3,
8121 global_attribute4,
8122 global_attribute5,
8123 global_attribute6,
8124 global_attribute7,
8125 global_attribute8,
8126 global_attribute9,
8127 global_attribute10,
8128 global_attribute11,
8129 global_attribute12,
8130 global_attribute13,
8131 global_attribute14,
8132 global_attribute15,
8133 global_attribute16,
8134 global_attribute17,
8135 global_attribute18,
8136 global_attribute19,
8137 global_attribute20,
8138 pricing_context,
8139 pricing_attribute1,
8140 pricing_attribute2,
8141 pricing_attribute3,
8142 pricing_attribute4,
8143 pricing_attribute5,
8144 pricing_attribute6,
8145 pricing_attribute7,
8146 pricing_attribute8,
8147 pricing_attribute9,
8148 pricing_attribute10,
8149 industry_context,
8150 industry_attribute1,
8151 industry_attribute2,
8152 industry_attribute3,
8153 industry_attribute4,
8154 industry_attribute5,
8155 industry_attribute6,
8156 industry_attribute7,
8157 industry_attribute8,
8158 industry_attribute9,
8159 industry_attribute10,
8160 industry_attribute11,
8161 industry_attribute12,
8162 industry_attribute13,
8163 industry_attribute14,
8164 industry_attribute15,
8165 industry_attribute16,
8166 industry_attribute17,
8167 industry_attribute18,
8168 industry_attribute19,
8169 industry_attribute20,
8170 industry_attribute21,
8171 industry_attribute22,
8172 industry_attribute23,
8173 industry_attribute24,
8174 industry_attribute25,
8175 industry_attribute26,
8176 industry_attribute27,
8177 industry_attribute28,
8178 industry_attribute29,
8179 industry_attribute30,
8180 creation_date,
8181 created_by,
8182 last_update_date,
8183 last_updated_by,
8184 last_update_login,
8185 program_application_id,
8186 program_id,
8187 program_update_date,
8188 request_id,
8189 configuration_id,
8190 link_to_line_id,
8191 component_sequence_id,
8192 component_code,
8193 config_display_sequence,
8194 sort_order,
8195 item_type_code,
8196 option_number,
8197 option_flag,
8198 dep_plan_required_flag,
8199 visible_demand_flag,
8200 line_category_code,
8201 actual_shipment_date,
8202 reference_customer_trx_line_id,
8203 return_context,
8204 return_attribute1,
8205 return_attribute2,
8206 return_attribute3,
8207 return_attribute4,
8208 return_attribute5,
8209 return_attribute6,
8210 return_attribute7,
8211 return_attribute8,
8212 return_attribute9,
8213 return_attribute10,
8214 return_attribute11,
8215 return_attribute12,
8216 return_attribute13,
8217 return_attribute14,
8218 return_attribute15,
8219 intmed_ship_to_org_id,
8220 intmed_ship_to_contact_id,
8221 actual_arrival_date,
8222 ato_line_id,
8223 auto_selected_quantity,
8224 component_number,
8225 earliest_acceptable_date,
8226 explosion_date,
8227 latest_acceptable_date,
8228 model_group_number,
8229 schedule_arrival_date,
8230 ship_model_complete_flag,
8231 schedule_status_code,
8232 return_reason_code,
8233 salesrep_id,
8234 split_from_line_id,
8235 cust_production_seq_num,
8236 authorized_to_ship_flag,
8237 invoice_interface_status_code,
8238 ship_set_id,
8239 arrival_set_id,
8240 hist_comments,
8241 hist_type_code,
8242 reason_code,
8243 hist_created_by,
8244 hist_creation_date,
8245 source_type_code,
8246 booked_flag,
8247 fulfilled_flag,
8248 sold_from_org_id,
8249 top_model_line_id,
8250 cancelled_flag,
8251 open_flag,
8252 over_ship_reason_code,
8253 over_ship_resolved_flag,
8254 item_identifier_type,
8255 commitment_id,
8256 shipping_interfaced_flag,
8257 credit_invoice_line_id,
8258 end_item_unit_number,
8259 mfg_component_sequence_id,
8260 config_header_id,
8261 config_rev_nbr,
8262 shipping_instructions,
8263 packing_instructions,
8264 invoiced_quantity,
8265 customer_trx_line_id,
8266 split_by,
8267 line_set_id,
8268 tp_context,
8269 tp_attribute1,
8270 tp_attribute2,
8271 tp_attribute3,
8272 tp_attribute4,
8273 tp_attribute5,
8274 tp_attribute6,
8275 tp_attribute7,
8276 tp_attribute8,
8277 tp_attribute9,
8278 tp_attribute10,
8279 tp_attribute11,
8280 tp_attribute12,
8281 tp_attribute13,
8282 tp_attribute14,
8283 tp_attribute15,
8284 fulfillment_method_code,
8285 service_reference_type_code,
8286 service_reference_line_id,
8287 service_reference_system_id,
8288 ordered_item_id,
8289 service_number,
8290 service_duration,
8291 service_start_date,
8292 re_source_flag,
8293 flow_status_code,
8294 service_end_date,
8295 service_coterminate_flag,
8296 shippable_flag,
8297 order_source_id,
8298 orig_sys_shipment_ref,
8299 change_sequence,
8300 drop_ship_flag,
8301 customer_line_number,
8302 customer_shipment_number,
8303 customer_item_net_price,
8304 customer_payment_term_id,
8305 first_ack_date,
8306 first_ack_code,
8307 last_ack_code,
8308 last_ack_date,
8309 planning_priority,
8310 service_txn_comments,
8311 service_period,
8312 unit_selling_percent,
8313 unit_list_percent,
8314 unit_percent_base_price,
8315 model_remnant_flag,
8316 service_txn_reason_code,
8317 calculate_price_flag,
8318 revenue_amount
8319 from oe_order_lines_history
8320 where line_id = p_orig_line_id;
8321
8322 /* Insert log record here */
8323 G_Log_Rec.Header_Id := p_line_rec.header_id;
8324 G_Log_Rec.Old_Line_Id := g_Old_line_id;
8325 G_Log_Rec.picking_Line_Id := null;
8326 G_Log_Rec.Old_Line_Detail_id := null;
8327 G_Log_Rec.Delivery := null;
8328 G_Log_Rec.New_Line_ID := p_line_rec.line_id;
8329 g_log_rec.return_qty_available := null;
8330 G_Log_Rec.New_Line_Number := null;
8331 G_Log_Rec.mtl_sales_order_id := null; /* to check with Rupal if this is okay */
8332 g_log_rec.comments := 'Created through sub-program for Upgrade';
8333 OE_UPG_SO_NEW.Upgrade_Insert_Upgrade_Log;
8334
8335 g_line_id := p_line_rec.line_id;
8336 g_header_id := p_line_rec.header_id;
8337
8338
8339 IF p_apply_price_adj = 'Y' THEN
8340 /* ========== Line Level Pricing Attributes =========== Added by jefflee 6/21/00 */
8341 QP_Upg_OE_PVT.Upg_Pricing_Attribs(p_line_rec);
8342
8343 g_line_rec.pricing_attribute11:=null;
8344 g_line_rec.pricing_attribute12:=null;
8345 g_line_rec.pricing_attribute13:=null;
8346 g_line_rec.pricing_attribute14:=null;
8347 g_line_rec.pricing_attribute15:=null;
8348
8349 /* ========== Price Adjustments =========== */
8350 IF ( (p_line_rec.item_type_code <> 'INCLUDED' )
8351 AND (p_line_rec.item_type_code <> 'CONFIG') ) THEN
8352
8353 OE_UPG_SO_NEW.Upgrade_Price_Adjustments
8354 ( L_level_flag => 'L');
8355
8356 END IF;
8357
8358 END IF;
8359
8360
8361 /* ========== Sales Credits =========== */
8362 OE_UPG_SO_NEW.Upgrade_Sales_Credits
8363 ( L_level_flag => 'L');
8364
8365 IF l_debug_level > 0 THEN
8366 oe_debug_pub.add( 'EXITING INSERT_ROW' , 1 ) ;
8367 END IF;
8368
8369 EXCEPTION
8370 WHEN OTHERS THEN
8371
8372 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8373
8374 END Insert_Row;
8375
8376 Procedure Insert_Return_Included_Items(p_line_id NUMBER,module varchar2 default null)
8377 IS
8378 l_inventory_item_id NUMBER;
8379 l_line_set_id NUMBER;
8380 l_line_number NUMBER;
8381 l_shipment_line_id NUMBER;
8382 l_line_id NUMBER;
8383 l_line_id1 NUMBER;
8384 l_received_quantity NUMBER;
8385 l_delivered_quantity NUMBER;
8386 l_line_rec OE_Order_PUB.Line_Rec_Type;
8387 l_line_rec1 OE_Order_PUB.Line_Rec_Type;
8388 Cursor C1 is
8389 Select rma_interface_id,rma_id,rma_line_id,
8390 inventory_item_id,component_sequence_id,
8391 quantity, unit_code,received_quantity,delivered_quantity
8392 from mtl_so_rma_interface
8393 where rma_line_id = p_line_id
8394 and inventory_item_id <> l_inventory_item_id;
8395 --
8396 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
8397 --
8398 BEGIN
8399
8400 l_line_rec := Query_Row(p_line_id);
8401 l_inventory_item_id := l_line_rec.inventory_item_id;
8402
8403 For l_rec in C1 LOOP
8404
8405 select oe_order_lines_s.nextval into l_line_id from dual;
8406
8407 IF module is null then
8408 g_Last_Line_Number := g_Last_Line_Number +1;
8409 l_line_number := g_Last_Line_Number;
8410 else
8411 begin
8412 Select max(line_number) into l_line_number
8413 from oe_order_lines_all
8414 where header_id = l_line_rec.header_id;
8415
8416 l_line_number := l_line_number + 1;
8417 exception
8418 when others then
8419 l_line_number := 1;
8420 end;
8421 end if;
8422
8423 l_received_quantity := l_rec.received_quantity;
8424 l_delivered_quantity := l_rec.delivered_quantity;
8425
8426 IF l_received_quantity = 0 THEN
8427 l_received_quantity := NULL;
8428 END IF;
8429
8430 IF l_delivered_quantity = 0 THEN
8431 l_delivered_quantity := NULL;
8432 END IF;
8433
8434
8435 l_line_rec1 := l_line_rec;
8436 l_line_rec1.line_number := l_line_number;
8437 l_line_rec1.inventory_item_id := l_rec.inventory_item_id;
8438 l_line_rec1.ordered_item_id := l_rec.inventory_item_id;
8439 l_line_rec1.ordered_item := NULL;
8440 l_line_rec1.order_quantity_uom := l_rec.unit_code;
8441 l_line_rec1.shipping_quantity_uom := l_rec.unit_code;
8442 l_line_rec1.pricing_quantity_uom := l_rec.unit_code;
8443 l_line_rec1.unit_list_price := 0;
8444 l_line_rec1.unit_selling_price := 0;
8445
8446
8447 IF l_received_quantity is NULL or
8448 (l_rec.quantity <= l_received_quantity) THEN
8449 l_line_rec1.line_id := l_line_id;
8450 l_line_rec1.shipment_number := 1;
8451 l_line_rec1.ordered_quantity := l_rec.quantity;
8452 l_line_rec1.pricing_quantity := l_rec.quantity;
8453 l_line_rec1.shipped_quantity := l_received_quantity;
8454 l_line_rec1.fulfilled_quantity := l_delivered_quantity;
8455 l_line_rec1.invoiced_quantity := NULL;
8456
8457 Insert_Row(l_line_rec1,p_line_id,'Y','N');
8458
8459 ELSE
8460
8461 select oe_sets_s.nextval into l_line_set_id from dual;
8462
8463 insert into oe_sets
8464 ( SET_ID, SET_NAME, SET_TYPE, HEADER_ID, SHIP_FROM_ORG_ID,
8465 SHIP_TO_ORG_ID,SCHEDULE_SHIP_DATE, SCHEDULE_ARRIVAL_DATE,
8466 FREIGHT_CARRIER_CODE, SHIPPING_METHOD_CODE,
8467 SHIPMENT_PRIORITY_CODE, SET_STATUS,
8468 CREATED_BY, CREATION_DATE, UPDATED_BY, UPDATE_DATE,
8469 UPDATE_LOGIN, INVENTORY_ITEM_ID,ORDERED_QUANTITY_UOM,
8470 LINE_TYPE_ID,SHIP_TOLERANCE_ABOVE, SHIP_TOLERANCE_BELOW)
8471 values
8472 (l_line_set_id, to_char(l_line_set_id),
8473 'LINE_SET',l_line_rec.header_id,null,null, null,null,null,
8474 null,null,null, 0,sysdate,0, sysdate,
8475 0,null,null,null,null,null
8476 );
8477
8478
8479 l_line_rec1.line_id := l_line_id;
8480 l_line_rec1.shipment_number := 1;
8481 l_line_rec1.ordered_quantity := l_rec.received_quantity;
8482 l_line_rec1.pricing_quantity := l_line_rec1.ordered_quantity;
8483 l_line_rec1.shipped_quantity := l_rec.received_quantity;
8484 l_line_rec1.fulfilled_quantity := l_delivered_quantity;
8485 l_line_rec1.invoiced_quantity := NULL;
8486
8487 l_line_rec1.line_set_id := l_line_set_id;
8488
8489 Insert_Row(l_line_rec1,p_line_id,'Y','N');
8490
8491 select oe_order_lines_s.nextval into l_line_id1 from dual;
8492
8493 l_line_rec1.line_id := l_line_id1;
8494 l_line_rec1.shipment_number := 2;
8495 l_line_rec1.ordered_quantity := l_rec.quantity-l_rec.received_quantity;
8496 l_line_rec1.pricing_quantity := l_line_rec1.ordered_quantity;
8497 l_line_rec1.shipped_quantity := NULL;
8498 l_line_rec1.fulfilled_quantity := NULL;
8499 l_line_rec1.invoiced_quantity := NULL;
8500
8501 Insert_Row(l_line_rec1,p_line_id,'Y','N');
8502
8503 END IF;
8504
8505 begin
8506 -- Update PO Tables
8507 -- rcv_shipment_lines, rcv_transactions,rcv_supply
8508
8509 select shipment_line_id
8510 into l_shipment_line_id
8511 from rcv_shipment_lines
8512 where oe_order_line_id = p_line_id
8513 and item_id = l_rec.inventory_item_id;
8514
8515 update rcv_shipment_lines
8516 set oe_order_line_id = l_line_id
8517 where shipment_line_id = l_shipment_line_id;
8518
8519 update rcv_transactions
8520 set oe_order_line_id = l_line_id
8521 where shipment_line_id = l_shipment_line_id;
8522
8523 update rcv_supply
8524 set oe_order_line_id = l_line_id
8525 where shipment_line_id = l_shipment_line_id;
8526
8527 exception
8528 when others then
8529 null;
8530 end;
8531
8532 END LOOP; -- End loop for C1
8533
8534 END Insert_Return_Included_Items;
8535
8536 Procedure Process_Upgraded_Returns(p_header_id in NUMBER) is
8537 l_commit_counter number := 0;
8538 l_line_id number;
8539 l_header_id number;
8540 v_error_code number;
8541 Cursor C1 is
8542 Select/*+ INDEX(l1 OE_ORDER_LINES_N1) INDEX(l2 OE_ORDER_LINES_U1) */ l1.line_id,l1.header_id
8543 from oe_order_lines_all l1, oe_order_lines_all l2
8544 where l1.reference_line_id = l2.line_id
8545 and l2.item_type_code in ('MODEL','CLASS','KIT')
8546 and l2.ato_line_id is null
8547 and l1.line_category_code = 'RETURN'
8548 and l1.reference_type is not null
8549 and nvl(l1.open_flag,'-') = 'Y'
8550 and l1.header_id = p_header_id;
8551 --
8552 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
8553 --
8554 begin
8555
8556 For l_rec in C1 LOOP
8557 l_header_id := l_rec.header_id;
8558 l_line_id := l_rec.line_id;
8559
8560 BEGIN
8561 Insert_Return_Included_Items(l_line_id,'Process_Returns');
8562 Exception
8563 when others then
8564 v_error_code := sqlcode;
8565 OE_UPG_SO_NEW.upgrade_insert_errors
8566 ( L_header_id => l_header_id,
8567 L_comments => 'Exception in Process_Upgraded_Returns: '
8568 ||'Error code -'
8569 ||to_char(v_error_code)
8570 ||' - Line id '||to_char(l_line_id)
8571 );
8572 raise;
8573 END;
8574
8575 End LOOP;
8576
8577 end Process_Upgraded_Returns;
8578
8579 Procedure Mark_Order_As_Non_Updatable(p_header_id in number)
8580 IS
8581 --
8582 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
8583 --
8584 BEGIN
8585 Update so_headers_all
8586 set upgrade_flag = 'X'
8587 where header_id = p_header_id;
8588
8589 -- Check to see if any referenced Returns Should also be marked
8590
8591 END Mark_Order_As_Non_Updatable;
8592
8593
8594 Procedure Return_Fulfillment_Sets(p_header_id in NUMBER)
8595 IS
8596 l_commit_counter number := 0;
8597 v_error_code number;
8598 l_header_id number;
8599 l_line_id number;
8600 l_ref_line_id number;
8601 l_ref_header_id number;
8602 l_config_line_id number;
8603 l_line_id1 number;
8604 l_fulfillment_set_id number;
8605 l_fulfillment_ref_line_id number;
8606 Cursor C1 is
8607 Select /*+ INDEX(l1 OE_ORDER_LINES_N1) INDEX(l2 OE_ORDER_LINES_U1) */ l1.header_id
8608 from oe_order_lines_all l1, oe_order_lines_all l2
8609 where l1.header_id = p_header_id
8610 and l1.reference_line_id = l2.line_id
8611 and nvl(l1.open_flag,'-') = 'Y'
8612 and l2.item_type_code in ('MODEL','CLASS','KIT')
8613 and l1.line_category_code = 'RETURN';
8614
8615 Cursor C2 is
8616 Select /*+ INDEX(l1 OE_ORDER_LINES_N1) INDEX(l2 OE_ORDER_LINES_U1) */
8617 l1.line_id,l2.item_type_code,l2.line_id ref_line_id,l2.header_id ref_header_id
8618 from oe_order_lines_all l1, oe_order_lines_all l2
8619 where l1.reference_line_id = l2.line_id
8620 and l1.inventory_item_id = l2.inventory_item_id
8621 and nvl(l1.open_flag,'-') = 'Y'
8622 and l2.item_type_code in ('MODEL','CLASS')
8623 and l2.ato_line_id = l2.line_id
8624 and l1.header_id = l_header_id;
8625 Cursor C3_1 is
8626 Select /*+ INDEX(OE_ORDER_LINES_N1) */ line_id
8627 from oe_order_lines_all
8628 where ato_line_id = l_ref_line_id
8629 and header_id = l_ref_header_id
8630 and item_type_code = 'CONFIG';
8631 Cursor C3_2 is
8632 Select /*+ INDEX(OE_ORDER_LINES_N1) */ line_id
8633 from oe_order_lines_all
8634 where item_type_code in ('CLASS','CONFIG','OPTION')
8635 and header_id = l_ref_header_id
8636 and ato_line_id = l_ref_line_id
8637 and ato_line_id <> line_id;
8638 Cursor C3_3 is
8639 Select /*+ INDEX(OE_ORDER_LINES_N1) */ line_id
8640 from oe_order_lines_all
8641 where reference_line_id = l_fulfillment_ref_line_id
8642 and header_id = l_header_id;
8643 Cursor C4 is
8644 Select /*+ INDEX(l1 OE_ORDER_LINES_N1) INDEX(l2 OE_ORDER_LINES_U1) */
8645 l1.line_id,l2.item_type_code,l2.line_id ref_line_id,l2.header_id ref_header_id
8646 from oe_order_lines_all l1, oe_order_lines_all l2
8647 where l1.reference_line_id = l2.line_id
8648 and l1.inventory_item_id = l2.inventory_item_id
8649 and l2.item_type_code in ('MODEL','CLASS','KIT')
8650 and l2.ato_line_id is null
8651 and nvl(l1.open_flag,'-') = 'Y'
8652 and l1.header_id = l_header_id;
8653 Cursor C5 is
8654 Select /*+ INDEX(OE_ORDER_LINES_N1) */
8655 line_id,inventory_item_id
8656 from oe_order_lines_all
8657 where item_type_code in ('INCLUDED')
8658 and header_id = l_ref_header_id
8659 and link_to_line_id = l_ref_line_id;
8660 Cursor C5_1 is
8661 Select /*+ INDEX(OE_ORDER_LINES_N1) */
8662 line_id
8663 from oe_order_lines_all
8664 where reference_line_id = l_fulfillment_ref_line_id
8665 and header_id = l_header_id;
8666 l_temp_rec C1%ROWTYPE;
8667 --
8668 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
8669 --
8670 BEGIN
8671
8672 Open C1;
8673 Fetch C1 into l_temp_rec;
8674
8675 IF C1%NOTFOUND THEN
8676 Close C1;
8677 Return;
8678 end if;
8679
8680 Close C1;
8681
8682 begin
8683
8684 l_header_id := p_header_id;
8685
8686 -- Loop for ATO
8687 FOR l_rec1 in C2 LOOP -- Loop for ATO
8688 l_line_id := l_rec1.line_id;
8689 l_ref_line_id := l_rec1.ref_line_id;
8690 l_ref_header_id := l_rec1.ref_header_id;
8691
8692 --
8693 -- Fix References for Config Items
8694 --
8695 Open C3_1;
8696 Fetch C3_1 into l_config_line_id;
8697 Close C3_1;
8698
8699 IF l_config_line_id is not null THEN
8700 Update /*+ INDEX(OE_ORDER_LINES_ALL OE_ORDER_LINES_N1) */
8701 oe_order_lines_all
8702 set reference_line_id = l_config_line_id,
8703 ordered_item_id = inventory_item_id,
8704 unit_list_price = null,
8705 unit_selling_price = null
8706 where reference_line_id = l_ref_line_id
8707 and line_id <> l_line_id
8708 and header_id = l_header_id;
8709 /*
8710 delete from oe_price_adjustments
8711 where line_id in (select line_id
8712 from oe_order_lines_all
8713 where reference_line_id = l_config_line_id);
8714 */
8715 END IF;
8716
8717
8718 --
8719 -- Add ATO model and its children into a Fulfillment Set
8720 --
8721
8722 select oe_sets_s.nextval into l_fulfillment_set_id from dual;
8723 --insert into sets .....
8724
8725 insert into oe_sets
8726 ( SET_ID, SET_NAME, SET_TYPE, HEADER_ID, SHIP_FROM_ORG_ID,
8727 SHIP_TO_ORG_ID,SCHEDULE_SHIP_DATE, SCHEDULE_ARRIVAL_DATE,
8728 FREIGHT_CARRIER_CODE, SHIPPING_METHOD_CODE,
8729 SHIPMENT_PRIORITY_CODE, SET_STATUS,
8730 CREATED_BY, CREATION_DATE, UPDATED_BY, UPDATE_DATE,
8731 UPDATE_LOGIN, INVENTORY_ITEM_ID,ORDERED_QUANTITY_UOM,
8732 LINE_TYPE_ID,SHIP_TOLERANCE_ABOVE, SHIP_TOLERANCE_BELOW)
8733 values
8734 ( l_fulfillment_set_id, to_char(l_fulfillment_set_id),
8735 'FULFILLMENT_SET',l_header_id,null,null, null,null,null,
8736 null,null,null, 0,sysdate,0, sysdate,
8737 0,null,null,null,null,null
8738 );
8739
8740
8741 -- Add line to set
8742 Insert into oe_line_sets( Line_id, Set_id, SYSTEM_REQUIRED_FLAG)
8743 Values (l_line_id, l_fulfillment_set_id, 'Y');
8744
8745
8746 FOR l_rec2 in C3_2 LOOP
8747 l_fulfillment_ref_line_id := l_rec2.line_id;
8748 FOR l_rec21 in C3_3 LOOP
8749 -- Add line to set
8750 Insert into oe_line_sets( Line_id, Set_id, SYSTEM_REQUIRED_FLAG)
8751 Values (l_rec21.line_id, l_fulfillment_set_id, 'Y');
8752 END LOOP;
8753 END LOOP;
8754
8755 END LOOP; -- Loop for ATO
8756
8757
8758
8759 FOR l_rec1 in C4 LOOP -- Loop for PTO
8760 l_line_id := l_rec1.line_id;
8761 l_ref_line_id := l_rec1.ref_line_id;
8762 l_ref_header_id := l_rec1.ref_header_id;
8763
8764 --
8765 -- Fix References for Included Items
8766 --
8767
8768 FOR l_rec1_1 in C5 LOOP
8769 Update /*+ INDEX(OE_ORDER_LINES_ALL OE_ORDER_LINES_N1) */
8770 oe_order_lines_all
8771 set reference_line_id = l_rec1_1.line_id
8772 where reference_line_id = l_ref_line_id
8773 and inventory_item_id = l_rec1_1.inventory_item_id
8774 and line_id <> l_line_id
8775 and header_id = l_header_id;
8776 END LOOP;
8777
8778
8779 --
8780 -- Add PTO model/class/kit and its included items into a Fulfillment Set
8781 --
8782
8783 select oe_sets_s.nextval into l_fulfillment_set_id from dual;
8784 --insert into sets .....
8785
8786 insert into oe_sets
8787 ( SET_ID, SET_NAME, SET_TYPE, HEADER_ID, SHIP_FROM_ORG_ID,
8788 SHIP_TO_ORG_ID,SCHEDULE_SHIP_DATE, SCHEDULE_ARRIVAL_DATE,
8789 FREIGHT_CARRIER_CODE, SHIPPING_METHOD_CODE,
8790 SHIPMENT_PRIORITY_CODE, SET_STATUS,
8791 CREATED_BY, CREATION_DATE, UPDATED_BY, UPDATE_DATE,
8792 UPDATE_LOGIN, INVENTORY_ITEM_ID,ORDERED_QUANTITY_UOM,
8793 LINE_TYPE_ID,SHIP_TOLERANCE_ABOVE, SHIP_TOLERANCE_BELOW)
8794 values
8795 ( l_fulfillment_set_id, to_char(l_fulfillment_set_id),
8796 'FULFILLMENT_SET',l_header_id,null,null, null,null,null,
8797 null,null,null, 0,sysdate,0, sysdate,
8798 0,null,null,null,null,null
8799 );
8800
8801
8802 -- Add line to set
8803 Insert into oe_line_sets( Line_id, Set_id, SYSTEM_REQUIRED_FLAG)
8804 Values (l_line_id, l_fulfillment_set_id, 'Y');
8805
8806 FOR l_rec2 in C5 LOOP
8807 l_fulfillment_ref_line_id := l_rec2.line_id;
8808 FOR l_rec21 in C5_1 LOOP
8809 -- Add line to set
8810 Insert into oe_line_sets( Line_id, Set_id, SYSTEM_REQUIRED_FLAG)
8811 Values (l_rec21.line_id, l_fulfillment_set_id, 'Y');
8812 END LOOP;
8813 END LOOP;
8814
8815 END LOOP; -- Loop for PTO
8816
8817 exception
8818 when others then
8819 v_error_code := sqlcode;
8820 OE_UPG_SO_NEW.upgrade_insert_errors
8821 ( L_header_id => l_header_id,
8822 L_comments => 'Exception return_fulfillment_sets: '
8823 ||'Error code -'
8824 ||to_char(v_error_code)
8825 ||' - Line id '||to_char(l_line_id)
8826 );
8827 raise;
8828 end;
8829
8830 END Return_Fulfillment_Sets;
8831
8832 Procedure Upgrade_Upd_Serv_Ref_line_id
8833 IS
8834 cursor serviceable_lines is
8835 select line_id from oe_order_lines_all
8836 where item_type_code <> 'SERVICE';
8837
8838 cursor service_product_lines (p_serviceable_line_id IN NUMBER) IS
8839 select line_id , service_parent_line_id
8840 from so_lines_all
8841 where service_parent_line_id = p_serviceable_line_id;
8842
8843 cursor log_product_lines (p_service_parent_line_id IN NUMBER) IS
8844
8845 select old_line_id, new_line_id from
8846 oe_upgrade_log_v where
8847 old_line_id = p_service_parent_line_id
8848 and old_line_id <> new_line_id
8849 order by new_line_id;
8850
8851 cursor log_service_lines (p_line_id IN NUMBER) IS
8852
8853 select old_line_id, new_line_id from
8854 oe_upgrade_log_v where
8855 old_line_id = p_line_id
8856 and old_line_id <> new_line_id
8857 order by new_line_id;
8858
8859 v_new_line_id number;
8860 l_serviceable_line_id NUMBER;
8861 l_line_id NUMBER;
8862 l_service_parent_line_id NUMBER;
8863 l_old_line_id1 NUMBER;
8864 l_old_line_id2 NUMBER;
8865 l_new_line_id1 NUMBER;
8866 l_new_line_id2 NUMBER;
8867
8868 --
8869 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
8870 --
8871 begin
8872
8873 OPEN serviceable_lines;
8874
8875 LOOP
8876
8877 /* First retrieve all the serviceable lines */
8878
8879 FETCH serviceable_lines into l_serviceable_line_id;
8880 EXIT WHEN serviceable_lines%NOTFOUND;
8881
8882 -- Get the equivalent records from so_lines_all
8883 OPEN service_product_lines (l_serviceable_line_id);
8884
8885 LOOP
8886
8887 FETCH service_product_lines
8888 into l_line_id, l_service_parent_line_id;
8889 EXIT WHEN service_product_lines%NOTFOUND;
8890
8891 /* Have 2 open cursors for retrieving log records */
8892
8893 OPEN log_product_lines (l_service_parent_line_id);
8894 OPEN log_service_lines (l_line_id);
8895
8896 LOOP
8897
8898 FETCH log_product_lines
8899 into l_old_line_id1, l_new_line_id1;
8900 EXIT WHEN log_product_lines%NOTFOUND;
8901
8902 FETCH log_service_lines
8903 into l_old_line_id2, l_new_line_id2;
8904 EXIT WHEN log_service_lines%NOTFOUND;
8905
8906
8907 -- Now update the service line
8908 -- in oe_order_lines_all table
8909
8910 update oe_order_lines_all
8911 set service_reference_line_id = l_new_line_id1
8912 where line_id = l_new_line_id2;
8913
8914 END LOOP;
8915
8916 CLOSE log_service_lines;
8917
8918 CLOSE log_product_lines;
8919
8920 END LOOP; /* Loop for service product lines */
8921
8922 CLOSE service_product_lines;
8923
8924 END LOOP; /* Loop for serviceable lines */
8925
8926 CLOSE serviceable_lines;
8927
8928 EXCEPTION
8929 WHEN OTHERS
8930 then NULL;
8931
8932 END Upgrade_Upd_Serv_Ref_line_id;
8933
8934 Procedure Query_And_Set_Price_Attribs(p_line_id IN NUMBER, p_header_id NUMBER) IS
8935 --
8936 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
8937 --
8938 Begin
8939 Select pricing_attribute11,pricing_attribute12,
8940 pricing_attribute13,pricing_attribute14,pricing_attribute15
8941 INTO g_line_rec.pricing_attribute11,
8942 g_line_rec.pricing_attribute12,
8943 g_line_rec.pricing_attribute13,
8944 g_line_rec.pricing_attribute14,
8945 g_line_rec.pricing_attribute15
8946 From oe_order_price_attribs
8947 Where line_id = p_line_id
8948 and header_id = p_header_id;
8949
8950 Exception When others then null;
8951 End;
8952
8953 End OE_UPG_SO_NEW;