1 PACKAGE BODY OE_Order_Copy_Util AS
2 /* $Header: OEXUCPYB.pls 120.39.12020000.3 2012/10/15 10:51:19 alihussa ship $ */
3
4 G_DOC_HEADER_ID NUMBER := NULL;
5 G_ATT_HEADER_ID NUMBER := NULL;
6 G_ORDER_NUMBER NUMBER := NULL;
7 G_VERSION_NUMBER NUMBER := NULL;
8 G_ORDER_TYPE_ID NUMBER := NULL;
9 G_ADJ_HDR_ID NUMBER := NULL;
10 G_HDR_ADJ_TBL OE_Order_PUB.Header_Adj_Tbl_Type;
11 G_NEED_TO_EXPLODE_CONFIG BOOLEAN := FALSE;
12 G_COPY_TO_DIFFERENT_ORDER_TYPE BOOLEAN := FALSE; -- 5404002
13
14 -- Added for the ER 1480867
15
16 PROCEDURE Process_Line_Numbers(p_header_id IN NUMBER);
17
18 PROCEDURE Create_Line_Set(
19 p_src_line_id IN NUMBER,
20 p_line_id IN NUMBER,
21 p_line_set_id IN NUMBER,
22 p_header_id IN NUMBER,
23 p_line_type_id IN NUMBER
24 );
25
26 PROCEDURE EXTEND_TBL(p_num IN NUMBER);
27
28 PROCEDURE DELETE_TBL;
29
30 PROCEDURE sort_line_tbl(p_line_id_tbl IN OE_GLOBALS.Selected_Record_Tbl,
31 p_version_number IN NUMBER,
32 p_phase_change_flag IN VARCHAR2,
33 p_num_lines IN NUMBER,
34 x_line_tbl IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type);
35
36
37 --Added for bug 9004082
38
39 FUNCTION Only_Model(l_line_tbl IN OE_ORDER_PUB.Line_Tbl_Type,
40 model_line_id IN NUMBER) RETURN BOOLEAN;
41
42
43
44 FUNCTION Only_Model(l_line_tbl IN OE_ORDER_PUB.Line_Tbl_Type,
45 model_line_id IN NUMBER) RETURN BOOLEAN
46 IS
47 l_only_model BOOLEAN :=TRUE;
48 k NUMBER;
49
50 BEGIN
51
52 k:= l_line_tbl.FIRST;
53
54 WHILE k IS NOT NULL LOOP
55
56 BEGIN
57
58 IF (l_line_tbl(k).top_model_line_id = model_line_id AND
59 l_line_tbl(k).top_model_line_id <> l_line_tbl(k).line_id) THEN
60
61 l_only_model:=FALSE;
62
63 END IF;
64
65 k := l_line_tbl.NEXT(k);
66
67 END;
68
69 END LOOP;
70 RETURN l_only_model;
71 END Only_Model;
72
73 --End 9004082
74
75 -- End
76
77 -- Added as part of Inline Code Documentation Drive.
78 ------------------------------------------------------------------------------------
79 -- Function Name : Get_Copy_Rec
80 -- Input Params : None.
81 -- Return Type : Copy_Rec_Type : Copy Record Type
82 -- Description : This function returns default initialized values for control
83 -- variables (denoting Checkboxes on Copy Form),while creating a
84 -- copy record type variable. This is used only in Copy Flow, and
85 -- is called in OEORDCPY.pld for initializing p_copy_rec.
86 ------------------------------------------------------------------------------------
87
88 Function Get_copy_rec
89 Return Copy_rec_type
90 IS
91 x_copy_rec copy_rec_type;
92 --
93 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
94 --
95 BEGIN
96 x_copy_rec.init_msg_list := FND_API.G_FALSE;
97 x_copy_rec.commit := FND_API.G_FALSE;
98 x_copy_rec.copy_order := FND_API.G_TRUE;
99 x_copy_rec.hdr_info := FND_API.G_TRUE;
100 x_copy_rec.hdr_descflex := FND_API.G_TRUE;
101 x_copy_rec.hdr_scredits := FND_API.G_TRUE;
102 x_copy_rec.hdr_attchmnts := FND_API.G_TRUE;
103 x_copy_rec.hdr_holds := FND_API.G_TRUE;
104 x_copy_rec.hdr_credit_card_details := FND_API.G_FALSE;
105 x_copy_rec.all_lines := FND_API.G_TRUE;
106 x_copy_rec.incl_cancelled := FND_API.G_FALSE;
107 x_copy_rec.line_price_mode := G_CPY_ORIG_PRICE;
108 x_copy_rec.line_price_date := FND_API.G_MISS_DATE;
109 x_copy_rec.line_descflex := FND_API.G_TRUE;
110 x_copy_rec.line_scredits := FND_API.G_TRUE;
111 x_copy_rec.line_attchmnts := FND_API.G_TRUE;
112 x_copy_rec.line_fulfill_sets := FND_API.G_FALSE; -- Copy Sets ER #2830872 , #1566254.
113 x_copy_rec.line_ship_arr_sets := FND_API.G_FALSE; -- Copy Sets ER #2830872 , #1566254.
114
115 RETURN x_copy_rec;
116
117 END Get_copy_rec;
118
119 Function Find_LineIndex
120 (p_line_tbl IN OE_Order_PUB.Line_Tbl_type,
121 p_line_id IN NUMBER
122 )
123 Return Number
124 IS
125
126 K NUMBER; -- Used as Index for loop.
127 --
128 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
129 --
130 BEGIN
131
132 IF l_debug_level > 0 THEN
133 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.FIND_LINEINDEX ' , 1 ) ;
134 END IF;
135
136 k := p_line_tbl.FIRST;
137
138 WHILE K IS NOT NULL LOOP
139 BEGIN
140
141 IF p_line_tbl(k).line_id = p_line_id THEN
142
143 -- Return Index
144
145 IF l_debug_level > 0 THEN
146 oe_debug_pub.add( 'EXITING OE_ORDER_COPY_UTIL.FIND_LINEINDEX ' , 1 ) ;
147 END IF;
148 RETURN k;
149
150 END IF;
151 END;
152 k := p_line_tbl.NEXT(k);
153 END LOOP;
154
155 -- Line not in table
156
157 IF l_debug_level > 0 THEN
158 oe_debug_pub.add( 'EXITING OE_ORDER_COPY_UTIL.FIND_LINEINDEX ' , 1 ) ;
159 END IF;
160 RETURN FND_API.G_MISS_NUM;
161
162 END Find_LineIndex;
163
164
165 FUNCTION Get_Order_Category ( p_order_type_id IN NUMBER )
166 RETURN VARCHAR2
167 IS
168 l_api_name VARCHAR2(30) := 'Get_Order_Category';
169 l_category VARCHAR2(30) := NULL;
170
171 -- Bug 7829434 : Following cursor is changed to avoid org ctx change in case of
172 -- copy accross organization. Hence cat code is directly selected from master
173 -- table instead of org specific view.
174 CURSOR GET_ORDER_CAT (p_order_type_in NUMBER) IS
175 SELECT ORDER_CATEGORY_CODE --SELECT ORDER_CATEGORY_CODE
176 FROM OE_transaction_TYPES_all --FROM OE_ORDER_TYPES_V
177 WHERE TRANSACTION_TYPE_ID = p_order_type_in; --WHERE ORDER_TYPE_ID = p_order_type_in;
178 --
179 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
180 --
181 BEGIN
182
183 IF l_debug_level > 0 THEN
184 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.GET_ORDER_CATEGORY' , 1 ) ;
185 END IF;
186
187 OPEN GET_ORDER_CAT (p_order_type_id);
188 FETCH GET_ORDER_CAT
189 INTO l_category;
190
191 CLOSE GET_ORDER_CAT;
192
193 IF l_debug_level > 0 THEN
194 oe_debug_pub.add( 'EXITING OE_ORDER_COPY_UTIL.GET_ORDER_CATEGORY' , 1 ) ;
195 END IF;
196
197 RETURN l_category;
198 EXCEPTION
199 WHEN OTHERS THEN
200
201
202 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
203 THEN
204 OE_MSG_PUB.Add_Exc_Msg
205 ( G_PKG_NAME
206 , l_api_name
207 );
208 END IF;
209
210 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
211
212 END Get_Order_Category;
213
214 FUNCTION Get_Line_Category ( p_Line_type_id IN NUMBER )
215 RETURN VARCHAR2
216 IS
217 l_api_name VARCHAR2(30) := 'Get_Line_Category';
218 l_category VARCHAR2(30) := NULL;
219
220 -- Bug 7829434 : Following cursor is changed to avoid org ctx change in case of
221 -- copy accross organization. Hence cat code is directly selected from master
222 -- table instead of org specific view.
223 CURSOR GET_LINE_CAT (p_line_type_in NUMBER) IS
224 SELECT ORDER_CATEGORY_CODE --SELECT ORDER_CATEGORY_CODE
225 FROM OE_transaction_TYPES_all --FROM OE_LINE_TYPES_V
226 WHERE TRANSACTION_TYPE_ID = p_line_type_in; --WHERE LINE_TYPE_ID = p_line_type_in;
227 --
228 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
229 --
230 BEGIN
231
232 IF l_debug_level > 0 THEN
233 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.GET_LINE_CATEGORY' , 1 ) ;
234 END IF;
235
236 OPEN GET_LINE_CAT(p_line_type_id);
237 FETCH GET_LINE_CAT
238 INTO l_category;
239 CLOSE GET_LINE_CAT;
240
241 IF l_debug_level > 0 THEN
242 oe_debug_pub.add( 'EXITING OE_ORDER_COPY_UTIL.GET_LINE_CATEGORY' , 1 ) ;
243 END IF;
244
245 RETURN l_category;
246 EXCEPTION
247 WHEN OTHERS THEN
248 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
249 THEN
250 OE_MSG_PUB.Add_Exc_Msg
251 ( G_PKG_NAME
252 , l_api_name
253 );
254 END IF;
255
256 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
257
258 END Get_Line_Category;
259
260 FUNCTION Get_Default_Line ( p_order_type_id IN NUMBER
261 ,x_line_type_id OUT NOCOPY NUMBER)
262
263 RETURN VARCHAR2
264 IS
265 l_api_name VARCHAR2(30) := 'Get_Default_Line';
266 l_category VARCHAR2(30) := NULL;
267 l_line_type_id NUMBER;
268 l_line_type VARCHAR2(240);
269 --
270 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
271 --
272 BEGIN
273 IF l_debug_level > 0 THEN
274 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.GET_DEFAULT_LINE' , 1 ) ;
275 END IF;
276 l_category := get_order_category(p_order_type_id);
277
278 BEGIN
279 IF l_category = 'RETURN' THEN
280 SELECT default_inbound_line_type_id
281 INTO l_line_type_id
282 FROM oe_transaction_types_v
283 WHERE transaction_type_id = p_order_type_id;
284 ELSE
285
286 IF l_debug_level > 0 THEN
287 oe_debug_pub.add( 'BEFORE DEFAULT LINE_TYPE' , 2 ) ;
288 END IF;
289 SELECT default_outbound_line_type_id
290 INTO l_line_type_id
291 FROM oe_transaction_types_v
292 WHERE transaction_type_id = p_order_type_id;
293 END IF;
294
295 IF l_debug_level > 0 THEN
296 oe_debug_pub.add( 'BEFORE LINE_TYPE ID' , 2 ) ;
297 END IF;
298 SELECT name
299 INTO l_line_type
300 FROM Oe_line_types_v
301 WHERE line_type_id = l_line_type_id;
302
303
304 EXCEPTION
305
306 WHEN NO_DATA_FOUND THEN
307
308 Null;
309
310 END;
311
312 IF l_debug_level > 0 THEN
313 oe_debug_pub.add( 'EXITING OE_ORDER_COPY_UTIL.GET_DEFAULT_LINE' , 1 ) ;
314 END IF;
315 x_line_type_id := l_line_type_id;
316 Return l_line_type;
317
318 EXCEPTION
319 WHEN OTHERS THEN
320
321 IF l_debug_level > 0 THEN
322 oe_debug_pub.add( 'IN OTHERS ASWIN' , 2 ) ;
323 END IF;
324
325 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
326 THEN
327 OE_MSG_PUB.Add_Exc_Msg
328 ( G_PKG_NAME
329 , l_api_name
330 );
331 END IF;
332
333 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
334
335 END Get_Default_Line;
336
337
338 Procedure Get_Document_info (p_header_id IN NUMBER
339 ,x_order_number OUT NOCOPY NUMBER
340
341 ,x_version_number OUT NOCOPY NUMBER
342
343 ,x_order_type_id OUT NOCOPY NUMBER)
344
345 IS
346 l_order_number NUMBER;
347 l_version_number NUMBER;
348 l_order_type_id NUMBER;
349 l_api_name VARCHAR2(30) := 'Get_Document_info';
350
351 CURSOR GET_DOC_INFO(p_header_In NUMBER) IS
352 SELECT order_number,
353 version_number,
354 order_type_id
355 FROM OE_ORDER_HEADERS
356 WHERE header_id = p_header_in;
357
358 --
359 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
360 --
361 BEGIN
362
363 IF l_debug_level > 0 THEN
364 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.GET_DOCUMENT_INFO' , 1 ) ;
365 END IF;
366
367 IF G_DOC_HEADER_ID IS NOT NULL THEN
368 IF p_header_id = G_DOC_HEADER_ID THEN
369 x_order_number := G_ORDER_NUMBER;
370 x_version_number := G_VERSION_NUMBER;
371 x_order_type_id := G_ORDER_TYPE_ID;
372 RETURN;
373 END IF;
374 END IF;
375
376 OPEN GET_DOC_INFO(p_header_id);
377 FETCH GET_DOC_INFO
378 INTO l_order_number,
379 l_version_number,
380 l_order_type_id;
381
382 -- Set Cached Globals.
383
384 G_DOC_HEADER_ID := p_header_id;
385 G_ORDER_NUMBER := l_order_number;
386 G_VERSION_NUMBER := l_version_number;
387 G_ORDER_TYPE_ID := l_order_type_id;
388
389 -- Set Out variables
390
391 x_order_number := l_order_number;
392 x_version_number := l_version_number;
393 x_order_type_id := l_order_type_id;
394
395
396 CLOSE GET_DOC_INFO;
397
398 IF l_debug_level > 0 THEN
399 oe_debug_pub.add( 'EXITING OE_ORDER_COPY_UTIL.GET_DOCUMENT_INFO' , 1 ) ;
400 END IF;
401
402 EXCEPTION
403 WHEN OTHERS THEN
404 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
405 THEN
406 OE_MSG_PUB.Add_Exc_Msg
407 ( G_PKG_NAME
408 , l_api_name
409 );
410 END IF;
411
412 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
413
414 END Get_Document_info;
415
416 Procedure Copy_Header
417 ( p_header_id IN NUMBER
418 ,p_copy_rec IN copy_rec_type
419 ,x_header_rec IN OUT NOCOPY OE_Order_PUB.Header_Rec_Type)
420 IS
421 l_api_name CONSTANT VARCHAR(30) := 'Copy_Header';
422 l_orig_category VARCHAR2(30);
423 l_cpy_category VARCHAR2(30);
424 l_orig_ship_from_org_id OE_Order_Headers.ship_from_org_id%TYPE;
425 --
426 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
427 --
428 --R12 CC Encryption
429 l_payment_exists VARCHAR2(1) := 'N';
430 --R12 CC Encryption
431 BEGIN
432
433 IF l_debug_level > 0 THEN
434 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.COPY_HEADER' , 1 ) ;
435 END IF;
436
437 -- Query the Header to be copied
438
439 IF l_debug_level > 0 THEN
440 oe_debug_pub.add( 'ORDER HEADER IS '||TO_CHAR ( P_HEADER_ID ) , 2 ) ;
441 END IF;
442
443 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
444 OE_Version_History_Util.Query_row(p_header_id => p_header_id,
445 p_version_number => p_copy_rec.version_number,
446 p_phase_change_flag => p_copy_rec.phase_change_flag,
447 x_header_rec => x_header_rec);
448 ELSE
449 OE_Header_Util.Query_row(p_header_id => p_header_id,
450 x_header_rec => x_header_rec);
451 END IF;
452
453 IF l_debug_level > 0 THEN
454 oe_debug_pub.add( 'After querying Header '||x_header_rec.order_number,1);
455 END IF;
456
457 /* Added the following code to null out nocopy acknowledgement related fields in the order header , to fix the bug 1862719 */
458
459
460 x_header_rec.first_ack_code := FND_API.G_MISS_CHAR;
461 x_header_rec.first_ack_date := FND_API.G_MISS_DATE;
462 x_header_rec.last_ack_code := FND_API.G_MISS_CHAR;
463 x_header_rec.last_ack_date := FND_API.G_MISS_DATE;
464
465
466 -- added for bug#10380995
467
468 IF x_header_rec.tax_exempt_flag = 'S' THEN
469
470 x_header_rec.tax_exempt_number := NULL;
471 x_header_rec.tax_exempt_reason_code := NULL;
472
473 END IF;
474
475 -- added for bug#10380995
476
477 /* End of code added to fix the bug 1862719 */
478
479 -- Adding Code for New COPY chnages for 11.5.10
480 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
481
482 x_header_rec.USER_STATUS_CODE := FND_API.G_MISS_CHAR;
483 x_header_rec.DRAFT_SUBMITTED_FLAG := FND_API.G_MISS_CHAR;
484 x_header_rec.QUOTE_DATE := FND_API.G_MISS_DATE;
485 x_header_rec.SOURCE_DOCUMENT_VERSION_NUMBER :=
486 x_header_rec.version_number;
487
488 /* Added the following code to null out signature columns Bug:3698434*/
489 x_header_rec.supplier_signature := FND_API.G_MISS_CHAR;
490 x_header_rec.supplier_signature_date := FND_API.G_MISS_DATE;
491 x_header_rec.customer_signature := FND_API.G_MISS_CHAR;
492 x_header_rec.customer_signature_date := FND_API.G_MISS_DATE;
493
494 IF p_copy_rec.new_phase = 'N' THEN
495 x_header_rec.TRANSACTION_PHASE_CODE := 'N';
496 ELSE
497 x_header_rec.TRANSACTION_PHASE_CODE := 'F';
498 END IF;
499
500 IF p_copy_rec.copy_transaction_name = FND_API.G_FALSE THEN
501 x_header_rec.SALES_DOCUMENT_NAME := p_copy_rec.transaction_name;
502 END IF;
503
504 IF p_copy_rec.copy_expiration_date = FND_API.G_FALSE THEN
505 x_header_rec.EXPIRATION_DATE := NVL(p_copy_rec.expiration_date,
506 FND_API.G_MISS_DATE);
507 END IF;
508
509 IF p_copy_rec.manual_quote_number IS NOT NULL THEN
510 x_header_rec.quote_number := p_copy_rec.manual_quote_number;
511 ELSE
512 x_header_rec.quote_number := FND_API.G_MISS_NUM;
513 END IF;
514
515 END IF;
516
517 --key Transaction Dates Project
518 x_header_rec.order_firmed_date := FND_API.G_MISS_DATE ;
519 --end
520
521 IF l_debug_level > 0 THEN
522 oe_debug_pub.add( 'ORDER TO BE COPIED IS '||TO_CHAR ( X_HEADER_REC.ORDER_NUMBER ) , 2 ) ;
523 END IF;
524
525 -- Query Original Order Category
526
527 l_orig_category := Get_Order_category(x_header_rec.order_type_id);
528
529 -- Query Copy Order Category
530
531 IF p_copy_rec.hdr_type IS NULL THEN
532 l_cpy_category := l_orig_category;
533 ELSE
534 l_cpy_category := Get_Order_category(p_copy_rec.hdr_type);
535 END IF;
536
537 -- Is Order being copied to different Order Type ? 5404002
538 IF NVL(p_copy_rec.hdr_type, x_header_rec.order_type_id) <> x_header_rec.order_type_id THEN
539 G_COPY_TO_DIFFERENT_ORDER_TYPE := TRUE;
540 END IF;
541
542
543 -- Init required attributes on the Header Record
544
545
546 -- Set Order Type if passed in.
547 IF (p_copy_rec.hdr_type IS NOT NULL) THEN
548 x_header_rec.order_type_id := p_copy_rec.hdr_type;
549 END IF;
550
551 -- Clear category. Process Order will re-set this.
552 x_header_rec.order_category_code := FND_API.G_MISS_CHAR;
553
554 -- Set Source Information
555 x_header_rec.source_document_type_id := 2;
556 x_header_rec.source_document_id := x_header_rec.header_id;
557
558 --Set Order Number
559 IF p_copy_rec.manual_order_number IS NOT NULL THEN
560 x_header_rec.order_number := p_copy_rec.manual_order_number;
561 ELSE
562 x_header_rec.order_number := FND_API.G_MISS_NUM;
563 END IF;
564
565 x_header_rec.header_id := FND_API.G_MISS_NUM;
566 x_header_rec.version_number := FND_API.G_MISS_NUM;
567 x_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;
568
569 IF (x_header_rec.ordered_date < sysdate) THEN
570 x_header_rec.ordered_date := FND_API.G_MISS_DATE;
571 END IF;
572
573 IF (x_header_rec.request_date < sysdate) THEN
574 x_header_rec.request_date := FND_API.G_MISS_DATE;
575 END IF;
576
577 IF p_copy_rec.new_phase = 'F'
578 AND x_header_rec.ordered_date IS NULL THEN
579 x_header_rec.ordered_date := FND_API.G_MISS_DATE;
580
581 END IF;
582
583 /* To fix bug 1411329 */
584 -- x_header_rec.agreement_id := FND_API.G_MISS_NUM;
585 /* To fix bug 1765169 */
586 --commented for bug# 14098858 x_header_rec.pricing_date := sysdate ;
587 --start fix# 14098858 if pricing at original then copy the same else copy date from UI else depend upon defaulting rule
588 IF l_debug_level>0 then
589 oe_debug_pub.add('Bug# 14098858 p_copy_rec.line_price_mode - '||p_copy_rec.line_price_mode);
590 END IF ;
591
592 IF p_copy_rec.line_price_mode = G_CPY_REPRICE then
593 If p_copy_rec.line_price_date is not null then
594 x_header_rec.pricing_date := p_copy_rec.line_price_date ;
595 else
596 x_header_rec.pricing_date := FND_API.G_MISS_DATE;
597 end if;
598 END IF;
599 IF x_header_rec.PRICING_DATE IS NULL THEN
600 x_header_rec.PRICING_DATE := FND_API.G_MISS_DATE;
601 END IF;
602 IF l_debug_level>0 then
603 oe_debug_pub.add('Bug# 14098858 Header pricing_date - '||x_header_rec.pricing_date);
604 END IF ;
605 --end fix# 14098858
606
607 /* To fix bug 1794902 */
608 x_header_rec.booked_date := FND_API.G_MISS_DATE;
609
610 -- Clear Orig Sys ref columns
611
612 x_header_rec.order_source_id := 2;
613 x_header_rec.orig_sys_document_ref := FND_API.G_MISS_CHAR;
614
615 -- Clear who columns.
616 x_header_rec.creation_date := FND_API.G_MISS_DATE;
617 x_header_rec.created_by := FND_API.G_MISS_NUM;
618 x_header_rec.last_update_date := FND_API.G_MISS_DATE;
619 x_header_rec.last_updated_by := FND_API.G_MISS_NUM;
620 x_header_rec.last_update_login := FND_API.G_MISS_NUM;
621 x_header_rec.program_application_id := FND_API.G_MISS_NUM;
622 x_header_rec.program_id := FND_API.G_MISS_NUM;
623 x_header_rec.program_update_date := FND_API.G_MISS_DATE;
624 x_header_rec.request_id := FND_API.G_MISS_NUM;
625 /* Reverting the fix of 6519067 for fix 10385263
626 if x_header_rec.ACCOUNTING_RULE_ID is null then -- added for Bug 6519067
627 x_header_rec.ACCOUNTING_RULE_ID := FND_API.G_MISS_NUM; -- added for Bug 6519067
628 end if;
629 */
630 -- Clear Status flags
631 x_header_rec.booked_flag := FND_API.G_MISS_CHAR;
632 x_header_rec.cancelled_flag := FND_API.G_MISS_CHAR;
633 x_header_rec.open_flag := FND_API.G_MISS_CHAR;
634
635 IF p_copy_rec.new_phase = 'F' THEN
636 x_header_rec.flow_status_code := 'ENTERED';
637 ELSE
638 x_header_rec.flow_status_code := NULL;
639 END IF;
640
641 -- Do not copy credit card details if check box not checked
642 -- in Copy Orders form
643 -- Reason 1: User does not have privileges to copy CC details
644 -- Reason 2: User have privileges but did not choose to copy
645
646 -- retain the original behavior if multiple payments not enabled.
647 IF NOT OE_PREPAYMENT_UTIL.IS_MULTIPLE_PAYMENTS_ENABLED THEN
648 IF l_debug_level > 0 THEN
649 oe_debug_pub.add('Multiple Payments not enabled, old code path.', 3 ) ;
650 END IF;
651
652 IF (p_copy_rec.hdr_payments = FND_API.G_FALSE) THEN
653 x_header_rec.credit_card_number := FND_API.G_MISS_CHAR;
654 x_header_rec.credit_card_expiration_date := FND_API.G_MISS_DATE;
655 x_header_rec.credit_card_holder_name := FND_API.G_MISS_CHAR;
656 END IF;
657
658
659 -- don't copy any payment information to order of RETURN type.
660 --R12 CC Encryption
661 ELSIF OE_PREPAYMENT_UTIL.IS_MULTIPLE_PAYMENTS_ENABLED THEN
662 --x_header_rec.payment_type_code := FND_API.G_MISS_CHAR;
663 --x_header_rec.check_number := FND_API.G_MISS_CHAR; --Verify
664
665 --Before populating the header rec, have to make sure that the
666 --payment record corresponding to this order is not present in
667 --oe_payments already to avoid duplicate records while copying an
668 --order from 11510 non migrated order.
669 BEGIN
670 SELECT 'Y'
671 INTO l_payment_exists
672 FROM oe_payments
673 WHERE header_id = p_header_id
674 AND line_id is null -- bug 5167945
675 AND PAYMENT_COLLECTION_EVENT = 'INVOICE';
676 EXCEPTION
677 WHEN NO_DATA_FOUND THEN
678 l_payment_exists := 'N';
679 IF l_debug_level >0 THEN
680 oe_debug_pub.add('Header id'||p_header_id);
681 END IF;
682 END;
683 IF l_payment_exists = 'Y' THEN
684 x_header_rec.payment_type_code := FND_API.G_MISS_CHAR; --BUG#10089312
685 x_header_rec.credit_card_number := FND_API.G_MISS_CHAR;
686 x_header_rec.credit_card_code := FND_API.G_MISS_CHAR;
687 x_header_rec.credit_card_expiration_date := FND_API.G_MISS_DATE;
688 x_header_rec.credit_card_holder_name := FND_API.G_MISS_CHAR;
689 END IF;
690
691 IF (l_cpy_category = 'RETURN' OR NOT FND_API.to_Boolean(p_copy_rec.hdr_payments)) THEN
692 x_header_rec.payment_type_code := FND_API.G_MISS_CHAR; --Verify
693 x_header_rec.check_number := FND_API.G_MISS_CHAR;
694 x_header_rec.credit_card_number := FND_API.G_MISS_CHAR;
695 x_header_rec.credit_card_code := FND_API.G_MISS_CHAR;
696 x_header_rec.credit_card_expiration_date := FND_API.G_MISS_DATE;
697 x_header_rec.credit_card_holder_name := FND_API.G_MISS_CHAR;
698
699 --ELSIF x_header_rec.payment_type_code IN ('CHECK','CREDIT_CARD','CASH') THEN
700 --g_create_payment_flag := 'Y';
701 END IF;
702 --R12 CC Encryption
703 END IF;
704
705 -- Fix for Bug # 1691168 : Never Copy Credit_Card_Approval_Code,
706 -- Credit_Card_Approval_Date and Payment Amount.
707 x_header_rec.credit_card_approval_code := FND_API.G_MISS_CHAR;
708 x_header_rec.credit_card_approval_date := FND_API.G_MISS_DATE;
709 x_header_rec.payment_amount := FND_API.G_MISS_NUM;
710
711 -- Clear Descriptive flex if it isn't being copied
712
713 IF (p_copy_rec.hdr_descflex = FND_API.G_FALSE) THEN
714
715 x_header_rec.context := FND_API.G_MISS_CHAR;
716 x_header_rec.attribute1 := FND_API.G_MISS_CHAR;
717 x_header_rec.attribute10 := FND_API.G_MISS_CHAR;
718 x_header_rec.attribute11 := FND_API.G_MISS_CHAR;
719 x_header_rec.attribute12 := FND_API.G_MISS_CHAR;
720 x_header_rec.attribute13 := FND_API.G_MISS_CHAR;
721 x_header_rec.attribute14 := FND_API.G_MISS_CHAR;
722 x_header_rec.attribute15 := FND_API.G_MISS_CHAR;
723 x_header_rec.attribute16 := FND_API.G_MISS_CHAR; --For bug 2184255
724 x_header_rec.attribute17 := FND_API.G_MISS_CHAR;
725 x_header_rec.attribute18 := FND_API.G_MISS_CHAR;
726 x_header_rec.attribute19 := FND_API.G_MISS_CHAR;
727 x_header_rec.attribute2 := FND_API.G_MISS_CHAR;
728 x_header_rec.attribute20 := FND_API.G_MISS_CHAR; --For bug 2184255
729 x_header_rec.attribute3 := FND_API.G_MISS_CHAR;
730 x_header_rec.attribute4 := FND_API.G_MISS_CHAR;
731 x_header_rec.attribute5 := FND_API.G_MISS_CHAR;
732 x_header_rec.attribute6 := FND_API.G_MISS_CHAR;
733 x_header_rec.attribute7 := FND_API.G_MISS_CHAR;
734 x_header_rec.attribute8 := FND_API.G_MISS_CHAR;
735 x_header_rec.attribute9 := FND_API.G_MISS_CHAR;
736
737
738 x_header_rec.global_attribute_category := FND_API.G_MISS_CHAR;
739 x_header_rec.global_attribute1 := FND_API.G_MISS_CHAR;
740 x_header_rec.global_attribute2 := FND_API.G_MISS_CHAR;
741 x_header_rec.global_attribute3 := FND_API.G_MISS_CHAR;
742 x_header_rec.global_attribute4 := FND_API.G_MISS_CHAR;
743 x_header_rec.global_attribute5 := FND_API.G_MISS_CHAR;
744 x_header_rec.global_attribute6 := FND_API.G_MISS_CHAR;
745 x_header_rec.global_attribute7 := FND_API.G_MISS_CHAR;
746 x_header_rec.global_attribute8 := FND_API.G_MISS_CHAR;
747 x_header_rec.global_attribute9 := FND_API.G_MISS_CHAR;
748 x_header_rec.global_attribute10 := FND_API.G_MISS_CHAR;
749 x_header_rec.global_attribute11 := FND_API.G_MISS_CHAR;
750 x_header_rec.global_attribute12 := FND_API.G_MISS_CHAR;
751 x_header_rec.global_attribute13 := FND_API.G_MISS_CHAR;
752 x_header_rec.global_attribute14 := FND_API.G_MISS_CHAR;
753 x_header_rec.global_attribute15 := FND_API.G_MISS_CHAR;
754 x_header_rec.global_attribute16 := FND_API.G_MISS_CHAR;
755 x_header_rec.global_attribute17 := FND_API.G_MISS_CHAR;
756 x_header_rec.global_attribute18 := FND_API.G_MISS_CHAR;
757 x_header_rec.global_attribute19 := FND_API.G_MISS_CHAR;
758 x_header_rec.global_attribute20 := FND_API.G_MISS_CHAR;
759
760 x_header_rec.tp_context := FND_API.G_MISS_CHAR;
761 x_header_rec.tp_attribute1 := FND_API.G_MISS_CHAR;
762 x_header_rec.tp_attribute2 := FND_API.G_MISS_CHAR;
763 x_header_rec.tp_attribute3 := FND_API.G_MISS_CHAR;
764 x_header_rec.tp_attribute4 := FND_API.G_MISS_CHAR;
765 x_header_rec.tp_attribute5 := FND_API.G_MISS_CHAR;
766 x_header_rec.tp_attribute6 := FND_API.G_MISS_CHAR;
767 x_header_rec.tp_attribute7 := FND_API.G_MISS_CHAR;
768 x_header_rec.tp_attribute8 := FND_API.G_MISS_CHAR;
769 x_header_rec.tp_attribute9 := FND_API.G_MISS_CHAR;
770 x_header_rec.tp_attribute10 := FND_API.G_MISS_CHAR;
771 x_header_rec.tp_attribute11 := FND_API.G_MISS_CHAR;
772 x_header_rec.tp_attribute12 := FND_API.G_MISS_CHAR;
773 x_header_rec.tp_attribute13 := FND_API.G_MISS_CHAR;
774 x_header_rec.tp_attribute14 := FND_API.G_MISS_CHAR;
775 x_header_rec.tp_attribute15 := FND_API.G_MISS_CHAR;
776
777 END IF; -- We are not copying descflex
778
779
780 -- Special handling if we are copying a Regular Order to a Return
781 IF ((l_orig_category = 'ORDER') OR
782 (l_orig_category = 'MIXED')) AND
783 (l_cpy_category = 'RETURN')THEN
784
785 -- Set Freight cols to missing
786 x_header_rec.shipping_method_code := FND_API.G_MISS_CHAR;
787 x_header_rec.freight_carrier_code := FND_API.G_MISS_CHAR;
788 x_header_rec.fob_point_code := FND_API.G_MISS_CHAR;
789 x_header_rec.freight_terms_code := FND_API.G_MISS_CHAR;
790 x_header_rec.shipping_instructions := FND_API.G_MISS_CHAR;
791 x_header_rec.packing_instructions := FND_API.G_MISS_CHAR;
792
793 -- Deliver to Org should match Ship to Org
794
795 x_header_rec.deliver_to_org_id := FND_API.G_MISS_NUM;
796
797
798 -- Set Other attributes to Missing
799
800 /* Commented the following line to fix the bug 1901882 */
801 /* x_header_rec.ship_to_contact_id := FND_API.G_MISS_NUM; */
802
803 x_header_rec.deliver_to_contact_id := FND_API.G_MISS_NUM;
804 x_header_rec.demand_class_code := FND_API.G_MISS_CHAR;
805
806 x_header_rec.accounting_rule_duration := NULL;
807
808 END IF;
809
810 -- PROMOTIONS SEP/01 Set price_request_code to NULL
811 x_header_rec.price_request_code := NULL;
812
813 -- Clear line set information.
814 IF x_header_rec.customer_preference_set_code IS NULL THEN
815 x_header_rec.customer_preference_set_code := FND_API.G_MISS_CHAR;
816 END IF;
817
818 /* Take the comment out nocopy once testing is done in omhut2 */
819 IF l_debug_level > 0 THEN
820 oe_debug_pub.add( 'EXITING OE_ORDER_COPY_UTIL.COPY_HEADER ' , 1 ) ;
821 END IF;
822
823
824 EXCEPTION
825
826 WHEN OTHERS THEN
827
828 IF l_debug_level > 0 THEN
829 oe_debug_pub.add( 'IN OTHERS' , 2 ) ;
830 END IF;
831
832 If OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
833 THEN
834 OE_MSG_PUB.Add_Exc_Msg
835 ( G_PKG_NAME
836 , l_api_name
837 );
838 END IF;
839
840 OE_DEBUG_PUB.DumpDebug;
841
842 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
843
844 END Copy_Header;
845
846
847 PROCEDURE Load_and_Init_Hdr_Scredits
848 (p_header_Id IN Number
849 ,p_version_number IN NUMBER
850 ,p_phase_change_flag IN VARCHAR2
851 ,x_Header_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Header_Scredit_Tbl_Type)
852 IS
853 l_api_name CONSTANT VARCHAR(30) := 'Load_and_Init_Hdr_Scredits';
854 --
855 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
856 --
857 BEGIN
858
859 IF l_debug_level > 0 THEN
860 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.LOAD_AND_INIT_HDR_SCREDITS' , 1 ) ;
861 END IF;
862
863 -- Load Header Sales Credits
864 BEGIN
865
866 x_Header_Scredit_tbl.delete; -- 1724939
867 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
868 OE_Version_History_UTIL.query_rows(
869 p_sales_credit_id => NULL,
870 p_header_id => p_header_id,
871 p_version_number => p_version_number,
872 p_phase_change_flag => p_phase_change_flag,
873 x_header_scredit_tbl => x_header_scredit_tbl);
874 ELSE
875 OE_Header_Scredit_Util.query_rows(p_header_id => p_header_id,
876 x_header_scredit_tbl => x_header_scredit_tbl);
877 END IF;
878
879 EXCEPTION
880
881 WHEN NO_DATA_FOUND THEN
882 NULL;
883
884 END;
885 -- Init Table for Copying
886
887 IF x_header_scredit_tbl.COUNT > 0 THEN
888
889 FOR k IN x_header_scredit_tbl.FIRST .. x_header_scredit_tbl.LAST LOOP
890
891 x_header_scredit_tbl(k).operation := OE_GLOBALS.G_OPR_CREATE;
892 x_header_scredit_tbl(k).header_id := FND_API.G_MISS_NUM;
893 x_header_scredit_tbl(k).sales_credit_id := FND_API.G_MISS_NUM;
894 x_header_scredit_tbl(k).orig_sys_credit_ref := FND_API.G_MISS_CHAR;--bug 13980051
895 END LOOP;
896
897 END IF; -- Table has rows
898
899 IF l_debug_level > 0 THEN
900 oe_debug_pub.add( 'HEADER SC IS '||TO_CHAR ( X_HEADER_SCREDIT_TBL.COUNT ) , 2 ) ;
901 END IF;
902
903 IF l_debug_level > 0 THEN
904 oe_debug_pub.add( 'EXITING OE_ORDER_COPY_UTIL.LOAD_AND_INIT_HDR_SCREDITS' , 1 ) ;
905 END IF;
906
907
908
909 EXCEPTION
910
911 WHEN OTHERS THEN
912
913 IF l_debug_level > 0 THEN
914 oe_debug_pub.add( 'IN OTHERS' , 2 ) ;
915 END IF;
916
917 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
918 THEN
919 OE_MSG_PUB.Add_Exc_Msg
920 ( G_PKG_NAME
921 , l_api_name
922 );
923 END IF;
924
925 OE_DEBUG_PUB.DumpDebug;
926
927 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
928
929 END Load_and_Init_Hdr_Scredits;
930
931 -- This function loads header based holds into the action request table.
932 Function Load_and_Init_Hdr_Holds
933 (p_header_Id IN Number
934 ,p_version_number IN NUMBER
935 ,p_phase_change_flag IN VARCHAR2
936 ,p_action_request_tbl IN OE_Order_PUB.Request_Tbl_Type)
937 Return OE_Order_PUB.Request_Tbl_Type
938 IS
939 l_api_name CONSTANT VARCHAR(30) := 'Load_and_Init_Hdr_Holds';
940 l_action_request_tbl OE_Order_PUB.Request_Tbl_Type;
941 k NUMBER := 1;
942 l_hold_source_tbl OE_Hold_Sources_PVT.Hold_Source_TBL;
943 l_return_status VARCHAR2(1);
944 l_v_number NUMBER;
945
946 --
947 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
948 --
949 BEGIN
950
951
952 IF l_debug_level > 0 THEN
953 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.LOAD_AND_INIT_HDR_HOLDS' , 1 ) ;
954 END IF;
955
956 -- Since the action request table could already have rows in it
957 -- set the index appropriately.
958 l_action_request_tbl := p_action_request_tbl;
959
960 -- If the Source is from a History Table then No Need to COPY holds.
961
962 IF p_phase_change_flag = 'Y' THEN
963 RETURN l_action_request_tbl;
964 END IF;
965
966 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
967 SELECT version_number
968 INTO l_v_number
969 FROM oe_order_headers_all /*Modified to base table for bug 9701486 */
970 WHERE header_id = p_header_id;
971
972 IF NOT OE_GLOBALS.EQUAL(l_v_number,p_version_number) THEN
973 RETURN l_action_request_tbl;
974 END IF;
975 END IF;
976
977 k := l_action_request_tbl.COUNT + 1;
978
979 -- Load Order Based holds for Copying
980
981 IF l_debug_level > 0 THEN
982 oe_debug_pub.add( 'CALLING OE_HOLD_SOURCES_PVT.QUERY_HOLD_SOURCE' , 2 ) ;
983 END IF;
984
985 OE_HOLD_SOURCES_PVT.QUERY_HOLD_SOURCE(p_header_id,
986 l_hold_source_tbl,
987 l_return_status);
988
989 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
990 RAISE FND_API.G_EXC_ERROR;
991 END IF;
992
993 IF l_debug_level > 0 THEN
994 oe_debug_pub.add( 'AFTER OE_HOLD_SOURCES_PVT.QUERY_HOLD_SOURCE' , 2 ) ;
995 END IF;
996
997 IF (l_hold_source_tbl.COUNT > 0) THEN
998 FOR curr in l_hold_source_tbl.FIRST .. l_hold_source_tbl.LAST LOOP
999 -- copy only non seeded holds. Seeded holds are from 1 to 1000.
1000 -- only copy Order vbased source and holds
1001
1002 IF l_hold_source_tbl(curr).hold_entity_code = 'O'
1003 AND l_hold_source_tbl(curr).hold_id >= 1000 THEN
1004
1005 IF l_debug_level > 0 THEN
1006 oe_debug_pub.add( 'LOADING HOLD SOURCE '|| TO_CHAR ( L_HOLD_SOURCE_TBL ( CURR ) .HOLD_ID ) , 2 ) ;
1007 END IF;
1008
1009 l_action_request_tbl(k).entity_code := OE_GLOBALS.G_ENTITY_HEADER;
1010 l_action_request_tbl(k).request_type:= OE_Globals.G_APPLY_HOLD;
1011 l_action_request_tbl(k).param1 := l_hold_source_tbl(curr).hold_id;
1012 l_action_request_tbl(k).param2 := 'O';
1013
1014 -- load other source fields
1015 l_action_request_tbl(k).param4 := l_hold_source_tbl(curr).hold_comment;
1016 l_action_request_tbl(k).date_param1 :=
1017 l_hold_source_tbl(curr).hold_until_date;
1018
1019 IF l_debug_level > 0 THEN
1020 oe_debug_pub.add( 'AFTER LOADING HOLD SOURCE DATE' , 3 ) ;
1021 END IF;
1022
1023 -- load Hold source desc flex
1024 l_action_request_tbl(k).param10 := l_hold_source_tbl(curr).context;
1025 l_action_request_tbl(k).param11 := l_hold_source_tbl(curr).attribute1;
1026 l_action_request_tbl(k).param12 := l_hold_source_tbl(curr).attribute2;
1027 l_action_request_tbl(k).param13 := l_hold_source_tbl(curr).attribute3;
1028 l_action_request_tbl(k).param14 := l_hold_source_tbl(curr).attribute4;
1029 l_action_request_tbl(k).param15 := l_hold_source_tbl(curr).attribute5;
1030 l_action_request_tbl(k).param16 := l_hold_source_tbl(curr).attribute6;
1031 l_action_request_tbl(k).param17 := l_hold_source_tbl(curr).attribute7;
1032 l_action_request_tbl(k).param18 := l_hold_source_tbl(curr).attribute8;
1033 l_action_request_tbl(k).param19 := l_hold_source_tbl(curr).attribute9;
1034 l_action_request_tbl(k).param20 := l_hold_source_tbl(curr).attribute10;
1035 l_action_request_tbl(k).param21 := l_hold_source_tbl(curr).attribute11;
1036 l_action_request_tbl(k).param22 := l_hold_source_tbl(curr).attribute12;
1037 l_action_request_tbl(k).param23 := l_hold_source_tbl(curr).attribute13;
1038 l_action_request_tbl(k).param24 := l_hold_source_tbl(curr).attribute14;
1039 l_action_request_tbl(k).param25 := l_hold_source_tbl(curr).attribute15;
1040
1041 -- Increment index
1042 k := k + 1;
1043 END IF; -- IF Order Based Source
1044 END LOOP;
1045 END IF; -- Table has records
1046
1047 IF l_debug_level > 0 THEN
1048 oe_debug_pub.add( 'EXITING OE_ORDER_COPY_UTIL.LOAD_AND_INIT_HDR_HOLDS' , 1 ) ;
1049 END IF;
1050
1051 RETURN l_action_request_tbl;
1052
1053
1054 EXCEPTION
1055
1056 WHEN OTHERS THEN
1057
1058 IF l_debug_level > 0 THEN
1059 oe_debug_pub.add( 'IN OTHERS' , 3 ) ;
1060 END IF;
1061
1062 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1063 THEN
1064 OE_MSG_PUB.Add_Exc_Msg
1065 ( G_PKG_NAME
1066 , l_api_name
1067 );
1068 END IF;
1069
1070 OE_DEBUG_PUB.DumpDebug;
1071
1072 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1073
1074 END Load_and_Init_Hdr_Holds;
1075
1076 -- Added for multiple payments
1077 PROCEDURE Load_and_Init_Hdr_Payments
1078 (p_header_Id IN Number
1079 ,x_Header_Payment_tbl IN OUT NOCOPY OE_Order_PUB.Header_Payment_Tbl_Type)
1080 IS
1081 k pls_integer;
1082
1083 --R12 CC Encryption
1084 l_invoice_to_cust_id NUMBER;
1085 l_invoice_to_org_id NUMBER;
1086 L_trxn_extension_id NUMBER;
1087 l_return_status VARCHAR2(30);
1088 L_msg_count NUMBER;
1089 L_msg_data VARCHAR2(2000);
1090 --R12 CC Encryption
1091
1092 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1093
1094 BEGIN
1095
1096 IF l_debug_level > 0 THEN
1097 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.Load_and_Init_Hdr_Payments', 3
1098 ) ;
1099 END IF;
1100
1101 x_Header_Payment_tbl.delete;
1102 OE_Header_Payment_Util.query_rows
1103 (p_header_id => p_header_id,
1104 x_header_payment_tbl => x_header_payment_tbl);
1105
1106 IF l_debug_level > 0 THEN
1107 oe_debug_pub.add( 'After query_rows, the count is: '|| x_header_payment_tbl.COUNT,3) ;
1108 END IF;
1109
1110 IF x_header_payment_tbl.COUNT > 0 THEN
1111 -- assign G_MISS to those attributes that are not copied.
1112 FOR k IN x_header_payment_tbl.FIRST .. x_header_payment_tbl.LAST LOOP
1113 x_header_payment_tbl(k).operation := OE_GLOBALS.G_OPR_CREATE;
1114 x_header_payment_tbl(k).header_id := FND_API.G_MISS_NUM;
1115 x_header_payment_tbl(k).line_id := FND_API.G_MISS_NUM;
1116 x_header_payment_tbl(k).prepaid_amount := FND_API.G_MISS_NUM;
1117 x_header_payment_tbl(k).commitment_applied_amount:= FND_API.G_MISS_NUM;
1118 x_header_payment_tbl(k).commitment_interfaced_amount := FND_API.G_MISS_NUM;
1119 x_header_payment_tbl(k).credit_card_approval_code := FND_API.G_MISS_CHAR;
1120 x_header_payment_tbl(k).payment_amount := 0;
1121 x_header_payment_tbl(k).payment_set_id := FND_API.G_MISS_NUM;
1122 IF l_debug_level > 0 THEN
1123 oe_debug_pub.add('trxn_extension id'||x_header_payment_tbl(k).trxn_extension_id);
1124 END IF;
1125
1126 --R12 CC Encryption
1127 /*IF x_header_payment_tbl(k).payment_type_code
1128 IN ('CREDIT_CARD','ACH','DIRECT_DEBIT','CASH','CHECK','WIRE_TRANSFER') THEN
1129
1130 Select customer_id
1131 Into l_invoice_to_cust_id
1132 From Oe_invoice_to_orgs_v
1133 Where organization_id = oe_order_cache.g_header_rec.invoice_to_org_id;
1134 Select invoice_to_org_id
1135 into l_invoice_to_org_id
1136 from oe_order_headers_all
1137 where header_id = p_header_id;
1138
1139 --populate the header payment table with the trxn_extension_id
1140 --before process order api is called for the new order.
1141
1142 L_trxn_extension_id := x_header_payment_tbl(k).trxn_extension_id;
1143
1144 OE_PAYMENT_TRXN_UTIL.Create_Payment_Trxn(
1145 P_header_id => p_header_id, --Verify
1146 P_line_id => null,
1147 P_cust_id => l_invoice_to_cust_id,
1148 P_site_use_id => l_invoice_to_org_id,
1149 p_payment_number => x_header_payment_tbl(k).payment_number,
1150 P_payment_type_code => x_header_payment_tbl(k).payment_type_code,
1151 P_payment_trx_id => x_header_payment_tbl(k).payment_trx_id,
1152 P_card_number => x_header_payment_tbl(k).credit_card_number,
1153 p_card_code => x_header_payment_tbl(k).credit_card_code,
1154 P_card_holder_name => x_header_payment_tbl(k).credit_card_holder_name,
1155 P_exp_date => x_header_payment_tbl(k).credit_card_expiration_date,
1156 P_check_number => x_header_payment_tbl(k).check_number,
1157 P_instrument_security_code=> x_header_payment_tbl(k).instrument_security_code,
1158 P_X_trxn_extension_id => l_trxn_extension_id,
1159 X_return_status => l_return_status,
1160 X_msg_count => l_msg_count,
1161 X_msg_data => l_msg_data);
1162
1163 x_header_payment_tbl(k).credit_card_number := FND_API.G_MISS_CHAR;
1164 x_header_payment_tbl(k).credit_card_code := FND_API.G_MISS_CHAR;
1165 x_header_payment_tbl(k).credit_card_holder_name := FND_API.G_MISS_CHAR;
1166 x_header_payment_tbl(k).credit_card_expiration_date := FND_API.G_MISS_DATE;
1167 x_header_payment_tbl(k).check_number := FND_API.G_MISS_CHAR;
1168 x_header_payment_tbl(k).instrument_security_code := FND_API.G_MISS_CHAR;
1169 x_header_payment_tbl(k).trxn_extension_id := l_trxn_extension_id;
1170 END IF;*/
1171 --R12 CC Encryption
1172 END LOOP;
1173 END IF;
1174
1175 IF l_debug_level > 0 THEN
1176 oe_debug_pub.add( 'Exiting OE_ORDER_COPY_UTIL.Load_and_Init_Hdr_Payments', 3) ;
1177 END IF;
1178 END Load_and_Init_Hdr_Payments;
1179
1180
1181 -- This function loads Line based holds into the action request table.
1182 PROCEDURE Load_and_Init_line_Holds
1183 (p_line_Id IN Number
1184 ,p_new_line_id IN Number
1185 ,p_action_request_tbl IN OUT NOCOPY OE_Order_PUB.Request_Tbl_Type)
1186 IS
1187 l_api_name CONSTANT VARCHAR(30) := 'Load_and_Init_Line_Holds';
1188 l_action_request_tbl OE_Order_PUB.Request_Tbl_Type;
1189 k NUMBER := 1;
1190 l_hold_source_tbl OE_Hold_Sources_PVT.Hold_Source_TBL;
1191 l_return_status VARCHAR2(1);
1192
1193 --
1194 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1195 --
1196 BEGIN
1197
1198 IF l_debug_level > 0 THEN
1199 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.LOAD_AND_INIT_LINE_HOLDS' , 1 ) ;
1200 END IF;
1201
1202 k := p_action_request_tbl.COUNT + 1;
1203
1204 -- Load Order Based holds for Copying
1205
1206 IF l_debug_level > 0 THEN
1207 oe_debug_pub.add( 'CALLING OE_HOLD_SOURCES_PVT.Query_Line__Hold_Source' , 2 ) ;
1208 END IF;
1209
1210 OE_HOLD_SOURCES_PVT.Query_Line__Hold_Source(p_line_id,
1211 l_hold_source_tbl,
1212 l_return_status);
1213
1214 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1215 RAISE FND_API.G_EXC_ERROR;
1216 END IF;
1217
1218 IF l_debug_level > 0 THEN
1219 oe_debug_pub.add('AFTER Query_Line__Hold_Source count '||l_hold_source_tbl.COUNT) ;
1220 END IF;
1221
1222 IF (l_hold_source_tbl.COUNT > 0) THEN
1223
1224 FOR curr in l_hold_source_tbl.FIRST .. l_hold_source_tbl.LAST LOOP
1225 -- copy only non seeded holds. Seeded holds are from 1 to 1000.
1226 -- only copy Order vbased source and holds
1227
1228 IF l_hold_source_tbl(curr).hold_entity_code = 'O'
1229 AND l_hold_source_tbl(curr).hold_id >= 1000 THEN
1230
1231 IF l_debug_level > 0 THEN
1232 oe_debug_pub.add( 'LOADING HOLD SOURCE '|| TO_CHAR ( L_HOLD_SOURCE_TBL ( CURR ) .HOLD_ID ) , 2 ) ;
1233 END IF;
1234
1235 p_action_request_tbl(k).entity_code := OE_GLOBALS.G_ENTITY_LINE;
1236 p_action_request_tbl(k).entity_id := p_new_line_id;
1237 p_action_request_tbl(k).request_type:= OE_Globals.G_APPLY_HOLD;
1238 p_action_request_tbl(k).param1 := l_hold_source_tbl(curr).hold_id;
1239 p_action_request_tbl(k).param2 := 'O';
1240
1241 -- load other source fields
1242 p_action_request_tbl(k).param4 := l_hold_source_tbl(curr).hold_comment;
1243 p_action_request_tbl(k).date_param1 :=
1244 l_hold_source_tbl(curr).hold_until_date;
1245
1246 IF l_debug_level > 0 THEN
1247 oe_debug_pub.add( 'AFTER LOADING HOLD SOURCE DATE' , 3 ) ;
1248 END IF;
1249
1250 -- load Hold source desc flex
1251 p_action_request_tbl(k).param10 := l_hold_source_tbl(curr).context;
1252 p_action_request_tbl(k).param11 := l_hold_source_tbl(curr).attribute1;
1253 p_action_request_tbl(k).param12 := l_hold_source_tbl(curr).attribute2;
1254 p_action_request_tbl(k).param13 := l_hold_source_tbl(curr).attribute3;
1255 p_action_request_tbl(k).param14 := l_hold_source_tbl(curr).attribute4;
1256 p_action_request_tbl(k).param15 := l_hold_source_tbl(curr).attribute5;
1257 p_action_request_tbl(k).param16 := l_hold_source_tbl(curr).attribute6;
1258 p_action_request_tbl(k).param17 := l_hold_source_tbl(curr).attribute7;
1259 p_action_request_tbl(k).param18 := l_hold_source_tbl(curr).attribute8;
1260 p_action_request_tbl(k).param19 := l_hold_source_tbl(curr).attribute9;
1261 p_action_request_tbl(k).param20 := l_hold_source_tbl(curr).attribute10;
1262 p_action_request_tbl(k).param21 := l_hold_source_tbl(curr).attribute11;
1263 p_action_request_tbl(k).param22 := l_hold_source_tbl(curr).attribute12;
1264 p_action_request_tbl(k).param23 := l_hold_source_tbl(curr).attribute13;
1265 p_action_request_tbl(k).param24 := l_hold_source_tbl(curr).attribute14;
1266 p_action_request_tbl(k).param25 := l_hold_source_tbl(curr).attribute15;
1267
1268 -- Increment index
1269 k := k + 1;
1270 END IF; -- IF Order Based Source
1271 END LOOP;
1272 END IF; -- Table has records
1273
1274 IF l_debug_level > 0 THEN
1275 oe_debug_pub.add( 'EXITING OE_ORDER_COPY_UTIL.LOAD_AND_INIT_LINE_HOLDS' , 1 ) ;
1276 END IF;
1277
1278
1279 EXCEPTION
1280
1281 WHEN OTHERS THEN
1282
1283 IF l_debug_level > 0 THEN
1284 oe_debug_pub.add( 'IN OTHERS' , 3 ) ;
1285 END IF;
1286
1287 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1288 THEN
1289 OE_MSG_PUB.Add_Exc_Msg
1290 ( G_PKG_NAME
1291 , l_api_name
1292 );
1293 END IF;
1294
1295 OE_DEBUG_PUB.DumpDebug;
1296
1297 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1298
1299 END Load_and_Init_Line_Holds;
1300
1301 -- This function processes the rows in the Lines table to handle configuration
1302 -- issues when destination order type is RETURN.
1303 -- It deletes rows for Included Items, Config items and options when top model
1304 -- record is passed in since Process ORder will re-explode them.
1305 -- It converts rows for Included Items, Class items, Config items and options to
1306 -- Standard line when the model item record is not passed in.
1307 -- Delete Class items always.
1308 -- This functions also deletes fully cancelled lines based on the flag.
1309
1310 Procedure Handle_Return_Lines
1311 ( p_x_line_tbl IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type
1312 ,p_incl_cancelled IN VARCHAR2
1313 )
1314 IS
1315 l_line_tbl OE_ORDER_PUB.Line_Tbl_Type;
1316 l_line_out_tbl OE_ORDER_PUB.Line_Tbl_Type;
1317 l_api_name CONSTANT VARCHAR2(30) := 'Handle_Return_Lines';
1318 l_top_model_index NUMBER;
1319 k NUMBER;
1320 j NUMBER := 1;
1321 --
1322 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1323 --
1324 BEGIN
1325
1326 IF l_debug_level > 0 THEN
1327 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.HANDLE_RETURN_LINES ' , 1 ) ;
1328 END IF;
1329
1330 -- Initialize local table
1331
1332 l_line_tbl := p_x_line_tbl;
1333
1334 k := l_line_tbl.FIRST;
1335 WHILE k IS NOT NULL LOOP
1336 BEGIN
1337
1338 -- RetroBill Fix
1339 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
1340 -- Do not copy RetroBill Line
1341 IF p_x_line_tbl(k).retrobill_request_id IS NOT NULL THEN
1342 l_line_tbl.DELETE(k);
1343 GOTO Excluded_cancelled_line;
1344 END IF;
1345 END IF;
1346
1347 -- If Fully cancelled then delete if desired
1348 IF (l_line_tbl(k).cancelled_flag = 'Y') AND
1349 (p_incl_cancelled = FND_API.G_FALSE) THEN
1350 G_Canceled_Line_Deleted := TRUE;
1351 l_line_tbl.DELETE(k);
1352 GOTO Excluded_cancelled_line;
1353
1354 END IF;
1355
1356 -- If Model or Standard then do nothing.
1357 IF l_line_tbl(k).item_type_code IN (OE_GLOBALS.G_ITEM_STANDARD,
1358 OE_GLOBALS.G_ITEM_MODEL) THEN
1359
1360 GOTO Leave_record_as_is;
1361
1362 END IF;
1363
1364 -- Config item gets copied over as Standard if parent is not
1365 -- passed in. It gets deleted if parent is passed in since
1366 -- auto-create will recreate it as part of normal Order processing.
1367 -- Included item gets copied over as Standard if parent is not
1368 -- passed in. It gets deleted if parent is passed in since
1369 -- Process Order will re-exploded based on Freeze date.
1370
1371 IF l_line_tbl(k).item_type_code IN
1372 (OE_GLOBALS.G_ITEM_CONFIG,
1373 OE_GLOBALS.G_ITEM_INCLUDED,
1374 OE_GLOBALS.G_ITEM_OPTION) THEN
1375
1376 -- Find if Parent Line has been passed In
1377 IF l_line_tbl(k).top_model_line_id IS NOT NULL THEN
1378 l_top_model_index := Find_LineIndex(l_line_tbl,
1379 l_line_tbl(k).top_model_line_id);
1380 IF l_top_model_index = FND_API.G_MISS_NUM THEN
1381 l_line_tbl(k).item_type_code := OE_GLOBALS.G_ITEM_STANDARD;
1382 GOTO Leave_record_as_is;
1383 END IF;
1384 END IF;
1385
1386 -- delete row since auto-create/explode incl will
1387 -- recreate it as part of normal Order processing.
1388
1389 l_line_tbl.DELETE(k);
1390 GOTO Leave_record_as_is;
1391 END IF; -- End Included, Option or Config Item
1392
1393 -- Delete class lines.
1394 IF l_line_tbl(k).item_type_code = OE_GLOBALS.G_ITEM_CLASS THEN
1395
1396 l_line_tbl.DELETE(k);
1397 GOTO Leave_record_as_is;
1398
1399 END IF;
1400
1401 -- Delete Service Line if the Line category is Return
1402 -- Delete service lines.
1403 IF l_line_tbl(k).item_type_code = OE_GLOBALS.G_ITEM_SERVICE THEN
1404 l_line_tbl.DELETE(k);
1405 GOTO Leave_record_as_is;
1406 END IF;
1407
1408 /* Following If condition added to fix the bug 2012594 */
1409 IF (l_line_tbl(k).item_type_code = OE_GLOBALS.G_ITEM_KIT) AND
1410 (l_line_tbl(k).top_model_line_id IS NOT NULL) AND
1411 (l_line_tbl(k).top_model_line_id <>l_line_tbl(k).line_id) THEN
1412 l_top_model_index := Find_LineIndex(l_line_tbl,l_line_tbl(k).top_model_line_id);
1413 IF l_top_model_index <> FND_API.G_MISS_NUM THEN
1414
1415 l_line_tbl.DELETE(k);
1416 GOTO Leave_record_as_is;
1417 END IF;
1418 END IF;
1419
1420
1421 <<Leave_record_as_is>> -- For Model And standard
1422 <<Excluded_cancelled_line>> -- For fully cancelled lines
1423 NULL;
1424 END;
1425
1426 IF l_line_tbl.EXISTS(k) THEN
1427
1428 l_line_out_tbl(j) := l_line_tbl(k);
1429 j := j + 1;
1430
1431 END IF;
1432
1433 k := l_line_tbl.NEXT(k);
1434 END LOOP;
1435
1436 IF l_debug_level > 0 THEN
1437 oe_debug_pub.add('Exiting OE_ORDER_COPY_UTIL.HANDLE_RETURN_LINES',1);
1438 END IF;
1439
1440 p_x_line_tbl := l_line_out_tbl;
1441
1442 END Handle_Return_Lines;
1443
1444 -- This function processes the rows in the Lines table to handle configuration issues
1445 -- It deletes rows for Included Items, since Process ORder will re-explode them.
1446 -- It also changes the item-type code of options and classes if any of
1447 -- the parent lines have not been passed in.
1448
1449 --CHANGE RECORD:
1450 --MACD: as per ver 4.9 of HLD, the copy validations for lines
1451 --holding container models are moved to this API
1452
1453 --bug3441056 start
1454 --display message only for top container model
1455 --so that when a header level copy is done, multiple msgs
1456 --are not displayed. This is not applicable for a line level copy
1457 --Also, dont raise exception
1458 --bcoz non container model lines should not fail copy
1459
1460 --For bug 3923574, we added new parameter x_top_model_tbl to mark the
1461 -- has_canceled_flag on the model.
1462
1463 Procedure Handle_NonStandard_Lines
1464 ( p_x_line_tbl IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type
1465 ,p_incl_cancelled IN VARCHAR2
1466 ,x_top_model_tbl IN OUT NOCOPY Top_Model_Tbl_Type
1467 )
1468 IS
1469 l_line_tbl OE_ORDER_PUB.Line_Tbl_Type;
1470 l_line_out_tbl OE_ORDER_PUB.Line_Tbl_Type;
1471 l_api_name CONSTANT VARCHAR2(30) := 'Handle_NonStandard_Lines';
1472 l_top_model_index NUMBER;
1473 l_link_to_index NUMBER;
1474 l_service_index NUMBER;
1475 k NUMBER;
1476 j NUMBER := 1;
1477 --
1478 l_top_container_model VARCHAR2(1);
1479 l_part_of_container VARCHAR2(1);
1480 l_config_mode NUMBER;
1481 l_ret_status VARCHAR2(1);
1482 --
1483 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1484 --
1485 l_top NUMBER;
1486 idx NUMBER;
1487 BEGIN
1488
1489 IF l_debug_level > 0 THEN
1490 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.HANDLE_NONSTANDARD_LINES ' , 1 ) ;
1491 END IF;
1492 --ER 2264774
1493 --Load PRG lines in memory, it will used
1494 --for matching during line processing.
1495 --During line processing, we do not copy it is a PRG line
1496 IF G_LINE_PRICE_MODE IN (G_CPY_REPRICE,G_CPY_REPRICE_WITH_ORIG_DATE) THEN
1497 OE_LINE_ADJ_UTIL.Set_PRG_Cache(p_header_id=>p_x_line_tbl(p_x_line_tbl.first).header_id);
1498 END IF;
1499
1500 -- Initialize local table
1501
1502 l_line_tbl := p_x_line_tbl;
1503
1504 k := l_line_tbl.FIRST;
1505 WHILE k IS NOT NULL LOOP
1506 BEGIN
1507
1508 --Clear Indexes
1509 l_top_model_index := FND_API.G_MISS_NUM;
1510 l_link_to_index := FND_API.G_MISS_NUM;
1511
1512
1513 --MACD------------------------------------------------------
1514
1515 IF OE_CODE_CONTROL.GET_CODE_RELEASE_LEVEL >= '110510' THEN
1516 IF l_debug_level > 0 THEN
1517 OE_DEBUG_PUB.Add('RowCount:'||l_line_tbl.COUNT,3);
1518 OE_DEBUG_PUB.Add('MACD-Copy Level is:'
1519 ||G_ORDER_LEVEL_COPY,3);
1520 END IF;
1521
1522 OE_CONFIG_TSO_PVT.Is_Part_Of_Container_Model
1523 ( p_line_id => l_line_tbl(k).line_id
1524 ,p_top_model_line_id => l_line_tbl(k).top_model_line_id
1525 ,p_ato_line_id => l_line_tbl(k).ato_line_id
1526 ,p_inventory_item_id => NULL
1527 ,x_top_container_model => l_top_container_model
1528 ,x_part_of_container => l_part_of_container );
1529
1530 IF l_debug_level > 0 THEN
1531 OE_DEBUG_PUB.Add('Line ID:'||l_line_tbl(k).line_id,2);
1532 OE_DEBUG_PUB.Add('TopLine:'||l_line_tbl(k).top_model_line_id,2);
1533 OE_DEBUG_PUB.Add('Top Container:'||l_top_container_model,3);
1534 OE_DEBUG_PUB.Add('Part of Container:'||l_part_of_container,3);
1535 END IF;
1536
1537 IF l_part_of_container = 'Y' THEN
1538
1539 IF G_ORDER_LEVEL_COPY = 0 THEN
1540
1541 IF l_debug_level > 0 THEN
1542 OE_DEBUG_PUB.Add('MACD:No line level copy allowed!',3);
1543 END IF;
1544
1545 l_line_tbl.DELETE(k);
1546 --bug3441056 start
1547 FND_MESSAGE.SET_NAME('ONT','ONT_TSO_NO_LINE_COPY');
1548 OE_MSG_PUB.Add;
1549 --RAISE FND_API.G_EXC_ERROR;
1550 --bug3441056 contd
1551 GOTO OUT_OF_MACD_LOGIC;
1552 ELSIF G_ORDER_LEVEL_COPY = 1 THEN
1553
1554 IF l_line_tbl(k).booked_flag = 'Y' THEN
1555 IF l_debug_level > 0 THEN
1556 OE_DEBUG_PUB.Add('Order level copy, booked=Y',3);
1557 OE_DEBUG_PUB.Add('Header:'||l_line_tbl(k).header_id,3);
1558 OE_DEBUG_PUB.Add('TopLine:'||l_line_tbl(k).top_model_line_id,3);
1559 OE_DEBUG_PUB.Add('LineID:'||l_line_tbl(k).line_id,3);
1560 END IF;
1561
1562 OE_CONFIG_TSO_PVT.Get_MACD_Action_Mode
1563 ( p_top_model_line_id => l_line_tbl(k).top_model_line_id
1564 ,p_line_id => l_line_tbl(k).line_id
1565 ,x_config_mode => l_config_mode
1566 ,x_return_status => l_ret_status );
1567
1568 IF l_ret_status <> FND_API.G_RET_STS_SUCCESS THEN
1569 IF l_debug_level > 0 THEN
1570 OE_DEBUG_PUB.Add('Error in Get_MACD_Action_Mode',3);
1571 END IF;
1572 END IF;
1573
1574 -- config mode of 4 indicates macd reconfig
1575 IF l_config_mode = 4 THEN
1576 IF l_debug_level > 0 THEN
1577 OE_DEBUG_PUB.Add('Order is a reconfiguration!',2);
1578 END IF;
1579
1580 l_line_tbl.DELETE(k);
1581
1582 IF l_top_container_model = 'Y' THEN
1583 FND_MESSAGE.SET_NAME('ONT','ONT_TSO_NO_BOOKED_ORDER_COPY');
1584 OE_MSG_PUB.Add;
1585 END IF;
1586
1587 GOTO OUT_OF_MACD_LOGIC;
1588 END IF;
1589 END IF; --booked_flag = Y
1590 END IF; --order level copy = 1
1591 END IF; --part of container = Y
1592
1593 ELSE
1594 IF l_debug_level > 0 THEN
1595 OE_DEBUG_PUB.Add('Not in 110510. No MACD Logic Executed!',3);
1596 END IF;
1597 END IF;
1598 --bug3441056 contd
1599 --this label has been moved with the rest of the labels
1600 /*
1601 << OUT_OF_MACD_LOGIC >>
1602 NULL;
1603 */
1604 --bug3441056 contd
1605 --MACD------------------------------------------------------
1606
1607 -- RetroBill Fix
1608 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
1609 -- Do not copy RetroBill Line
1610 IF p_x_line_tbl(k).retrobill_request_id IS NOT NULL THEN
1611 l_line_tbl.DELETE(k);
1612 GOTO Excluded_cancelled_line;
1613 END IF;
1614 END IF;
1615
1616 --ER 2264774
1617 IF OE_LINE_ADJ_UTIL.IS_PRG_LINE(p_x_line_tbl(k).line_id) THEN
1618 IF G_LINE_PRICE_MODE IN (G_CPY_REPRICE,G_CPY_REPRICE_WITH_ORIG_DATE) THEN
1619 l_line_tbl.DELETE(k);
1620 GOTO Excluded_cancelled_line;
1621 END IF;
1622 END IF;
1623
1624 -- If Fully cancelled then delete if desired
1625 IF (l_line_tbl(k).cancelled_flag = 'Y') AND
1626 (p_incl_cancelled = FND_API.G_FALSE) THEN
1627 G_Canceled_Line_Deleted := TRUE;
1628 l_line_tbl.DELETE(k);
1629 GOTO Excluded_cancelled_line;
1630
1631 END IF;
1632
1633 -- If Model or Standard or KIT then do nothing.
1634 IF l_line_tbl(k).item_type_code IN (OE_GLOBALS.G_ITEM_STANDARD,
1635 OE_GLOBALS.G_ITEM_MODEL,
1636 OE_GLOBALS.G_ITEM_KIT) THEN
1637
1638 GOTO Leave_record_as_is;
1639
1640 END IF;
1641
1642 -- Delete options and class if remnant flag is true.
1643
1644 IF l_line_tbl(k).model_remnant_flag = 'Y' THEN
1645
1646 l_line_tbl.DELETE(k);
1647 GOTO Excluded_model_remnant_line;
1648
1649 END IF;
1650
1651 -- Config item gets copied over as Standard if parent is not
1652 -- passed in. It gets deleted if parent is passed in since
1653 -- auto-create will recreate it as part of normal Order processing.
1654 -- Included item gets copied over as Standard if parent is not
1655 -- passed in. It gets deleted if parent is passed in since
1656 -- Process Order will re-exploded based on Freeze date.
1657
1658 IF l_line_tbl(k).item_type_code IN (OE_GLOBALS.G_ITEM_CONFIG,
1659 OE_GLOBALS.G_ITEM_INCLUDED) THEN
1660
1661
1662 -- Find if Link to Line has been passed in.
1663
1664 IF l_line_tbl(k).link_to_line_id IS NOT NULL THEN
1665 l_link_to_index := Find_LineIndex(l_line_tbl,l_line_tbl(k).link_to_line_id);
1666 IF l_link_to_index = FND_API.G_MISS_NUM THEN
1667
1668 l_line_tbl(k).item_type_code := OE_GLOBALS.G_ITEM_STANDARD;
1669 l_line_tbl(k).option_number := NULL;
1670 l_line_tbl(k).component_number := NULL;
1671 l_line_tbl(k).split_from_line_id := NULL;
1672 l_line_tbl(k).split_by := NULL;
1673 GOTO Leave_record_as_is;
1674
1675 END IF;
1676 END IF;
1677
1678
1679 -- If Parent Line, ATO line and Link to Line have been passed in then
1680 -- delete row since auto-create/explode incl will recreate it as
1681 -- part of normal Order processing.
1682
1683 l_line_tbl.DELETE(k);
1684 GOTO Leave_record_as_is;
1685 END IF; -- End Included or Config Item
1686
1687 -- Option gets copied over as such if parent is passed in
1688 -- else it gets converted to a Standard item.
1689
1690 IF l_line_tbl(k).item_type_code = (OE_GLOBALS.G_ITEM_OPTION) THEN
1691
1692 IF l_debug_level > 0 THEN
1693 oe_debug_pub.add( ' OPTION 1' || TO_CHAR ( L_LINE_TBL ( K ) .LINE_ID ) , 1 ) ;
1694 END IF;
1695
1696 -- Find if Parent Line has been passed In
1697 IF l_line_tbl(k).top_model_line_id IS NOT NULL THEN
1698 l_top_model_index := Find_LineIndex(l_line_tbl,
1699 l_line_tbl(k).top_model_line_id);
1700
1701 IF l_top_model_index = FND_API.G_MISS_NUM THEN
1702
1703 l_line_tbl(k).item_type_code := OE_GLOBALS.G_ITEM_STANDARD;
1704 l_line_tbl(k).option_number := NULL;
1705 l_line_tbl(k).component_number := NULL;
1706 l_line_tbl(k).split_from_line_id := NULL;
1707 l_line_tbl(k).split_by := NULL;
1708 GOTO Leave_record_as_is;
1709
1710 END IF;
1711 END IF;
1712
1713 -- Find if Link to Line has been passed in.
1714 IF l_line_tbl(k).link_to_line_id IS NOT NULL THEN
1715 l_link_to_index := Find_LineIndex(l_line_tbl,
1716 l_line_tbl(k).link_to_line_id);
1717
1718 IF l_link_to_index = FND_API.G_MISS_NUM THEN
1719
1720 l_line_tbl(k).item_type_code := OE_GLOBALS.G_ITEM_STANDARD;
1721 l_line_tbl(k).option_number := NULL;
1722 l_line_tbl(k).component_number := NULL;
1723 l_line_tbl(k).split_from_line_id := NULL;
1724 l_line_tbl(k).split_by := NULL;
1725 GOTO Leave_record_as_is;
1726
1727 END IF;
1728
1729 END IF;
1730
1731 -- Parent Line, Link to Line have been passed.
1732 -- Therefore we need to set the index columns.
1733 /* Start 3923574 */
1734 -- Top Model Line is present in the COPY selection
1735 -- Check if user has selected to copy canceled lines and
1736 -- there are canceled lines in the config.
1737 IF p_incl_cancelled = FND_API.G_TRUE AND
1738 l_line_tbl(k).cancelled_flag = 'Y' AND
1739 l_top_model_index IS NOT NULL
1740 THEN
1741 -- Mark the top model
1742 x_top_model_tbl(l_top_model_index).has_canceled_lines := 'Y';
1743 END IF;
1744 /* End 3923574 */
1745
1746 /* Populate indexes in the new table.
1747
1748 oe_debug_pub.add('OPTION 3' || to_char(l_line_tbl(k).line_id));
1749 l_line_tbl(k).top_model_line_index := l_top_model_index;
1750 l_line_tbl(k).link_to_line_index := l_link_to_index;
1751 */
1752 END IF; -- Option
1753
1754 -- Classes get copied over as such if the parent is passed in
1755 -- else it gets deleted(Classes cannot be conveted to STANDARD)
1756
1757 IF l_line_tbl(k).item_type_code = (OE_GLOBALS.G_ITEM_CLASS) THEN
1758
1759 IF l_debug_level > 0 THEN
1760 oe_debug_pub.add( 'CLASS 1' || TO_CHAR ( L_LINE_TBL ( K ) .LINE_ID ) , 1 ) ;
1761 END IF;
1762
1763 -- Find if Parent Line has been passed In
1764 IF l_line_tbl(k).top_model_line_id IS NOT NULL THEN
1765 l_top_model_index := Find_LineIndex(l_line_tbl,
1766 l_line_tbl(k).top_model_line_id);
1767
1768 IF l_top_model_index = FND_API.G_MISS_NUM THEN
1769
1770 -- Delete when top model is not passed in.
1771 l_line_tbl.DELETE(K);
1772 GOTO Leave_record_as_is;
1773
1774 END IF;
1775 END IF;
1776
1777
1778 -- Find if Line to Line has been passed in.
1779 IF l_line_tbl(k).link_to_line_id IS NOT NULL THEN
1780 l_link_to_index := Find_LineIndex(l_line_tbl,
1781 l_line_tbl(k).link_to_line_id);
1782
1783 IF l_link_to_index = FND_API.G_MISS_NUM THEN
1784 l_line_tbl.DELETE(K);
1785 GOTO Leave_record_as_is;
1786 END IF;
1787
1788 END IF;
1789 /* Start 3923574 */
1790 -- Top Model Line is present in the COPY selection
1791 -- Check if user has selected to copy canceled lines and
1792 -- there are canceled lines in the config.
1793 IF p_incl_cancelled = FND_API.G_TRUE AND
1794 l_line_tbl(k).cancelled_flag = 'Y' AND
1795 l_top_model_index IS NOT NULL
1796 THEN
1797 -- Mark the top model
1798 x_top_model_tbl(l_top_model_index).has_canceled_lines := 'Y';
1799 END IF;
1800 /* End 3923574 */
1801
1802 -- l_line_tbl(k).top_model_line_index := l_top_model_index;
1803
1804 END IF; -- Class
1805
1806 -- For the Service Lines
1807
1808 IF l_line_tbl(k).item_type_code = (OE_GLOBALS.G_ITEM_SERVICE) THEN
1809
1810 IF l_debug_level > 0 THEN
1811 oe_debug_pub.add( 'SERVICE ' || TO_CHAR ( L_LINE_TBL ( K ) .LINE_ID ) , 2 ) ;
1812 END IF;
1813
1814 -- Find if Parent Line has been passed In and Not a Customer Product
1815 IF l_line_tbl(k).service_reference_line_id IS NOT NULL AND
1816 l_line_tbl(k).service_reference_type_code = 'ORDER' THEN
1817
1818 l_service_index :=
1819 Find_LineIndex(l_line_tbl,
1820 l_line_tbl(k).service_reference_line_id);
1821
1822 IF l_service_index = FND_API.G_MISS_NUM THEN
1823 l_line_tbl.delete(k);
1824 GOTO Leave_record_as_is;
1825 ELSE
1826 IF l_line_tbl(l_service_index).item_type_code =
1827 (OE_GLOBALS.G_ITEM_CLASS) THEN
1828
1829 IF l_line_tbl(l_service_index).top_model_line_id
1830 IS NOT NULL THEN
1831
1832 l_top_model_index := Find_LineIndex(l_line_tbl,
1833 l_line_tbl(l_service_index).top_model_line_id);
1834
1835 IF l_top_model_index = FND_API.G_MISS_NUM THEN
1836
1837 -- Delete when top model is not passed in.
1838 l_line_tbl.DELETE(K);
1839 GOTO Leave_record_as_is;
1840
1841 END IF;
1842 END IF; -- top_model_line_id not null
1843 END IF; -- CLASS
1844
1845 GOTO Leave_record_as_is;
1846
1847 END IF; -- l_service_index = FND_API.G_MISS_NUM
1848 END IF; -- l_line_tbl(k).service_reference_line_id is not null
1849
1850 GOTO Leave_record_as_is; -- No Parent for the Customer Product
1851 END IF; -- Service
1852
1853 <<Leave_record_as_is>> -- For Model And standard
1854 <<Excluded_cancelled_line>> -- For fully cancelled lines
1855 <<Excluded_model_remnant_line>> -- For model remnant lines.
1856 --bug3441056 contd
1857 << OUT_OF_MACD_LOGIC >>
1858 --bug3441056 end
1859 NULL;
1860 END;
1861
1862 IF l_line_tbl.EXISTS(k) THEN
1863 IF l_debug_level > 0 THEN
1864 OE_DEBUG_PUB.Add('Adding to Out tbl:'||l_line_tbl(k).line_id);
1865 END IF;
1866 l_line_out_tbl(j) := l_line_tbl(k);
1867 j := j + 1;
1868
1869 END IF;
1870
1871 k := l_line_tbl.NEXT(k);
1872 END LOOP;
1873
1874
1875 --Added for Bug 9004082
1876 k:= l_line_out_tbl.FIRST;
1877
1878 WHILE k IS NOT NULL LOOP
1879
1880 BEGIN
1881
1882 IF (l_line_out_tbl(k).top_model_line_id IS NOT NULL AND
1883 l_line_out_tbl(k).top_model_line_id = l_line_out_tbl(k).line_id )
1884 THEN
1885 IF l_debug_level > 0 THEN
1886 oe_debug_pub.add('top_model_line_id: :'||l_line_out_tbl(k).top_model_line_id,1);
1887 oe_debug_pub.add('line_id :'||l_line_out_tbl(k).line_id,1);
1888 END IF ;
1889 --bug 14072820 IF Only_Model(l_line_out_tbl,l_line_out_tbl(k).top_model_line_id) THEN
1890 IF G_COPY_REC.copy_complete_config = FND_API.G_FALSE AND Only_Model(l_line_out_tbl,l_line_out_tbl(k).top_model_line_id) THEN --added for bug 14072820
1891
1892 IF l_debug_level > 0 THEN
1893 oe_debug_pub.add(' Only Model Line being Copied, so no configuration :',1);
1894 END IF ;
1895
1896 l_line_out_tbl(k).config_header_id :=NULL;
1897 l_line_out_tbl(k).config_rev_nbr :=NULL;
1898 l_line_out_tbl(k).configuration_id := NULL;
1899
1900 END IF;
1901
1902 END IF;
1903
1904 k := l_line_out_tbl.NEXT(k);
1905
1906 END;
1907 END LOOP;
1908
1909 --end Bugfix 9004082
1910
1911
1912 IF l_debug_level > 0 THEN
1913 oe_debug_pub.add('Exiting OE_ORDER_COPY_UTIL.HANDLE_NONSTANDARD_LINES ',1);
1914 END IF;
1915 p_x_line_tbl := l_line_out_tbl;
1916
1917 --ER 2264774
1918 OE_LINE_ADJ_UTIL.RESET_PRG_CACHE;
1919
1920 END Handle_NonStandard_Lines;
1921
1922 Procedure Load_Lines
1923 ( p_num_lines IN NUMBER
1924 ,p_line_id_tbl IN OE_GLOBALS.Selected_Record_Tbl
1925 ,p_all_lines IN VARCHAR2
1926 ,p_incl_cancelled IN VARCHAR2
1927 ,p_header_id IN NUMBER
1928 ,p_hdr_type_id IN NUMBER
1929 ,p_line_type_id IN NUMBER
1930 ,p_version_number IN NUMBER
1931 ,p_phase_change_flag IN VARCHAR2
1932 ,x_line_tbl IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type
1933 /* Added the following line to fix the bug 1923460 */
1934 ,x_top_model_tbl IN OUT NOCOPY Top_Model_Tbl_Type
1935 )
1936 IS
1937 l_top_model_index NUMBER;
1938 l_line_id OE_Order_LINES.Line_id%Type;
1939 l_cpy_category VARCHAR2(30);
1940 l_line_category VARCHAR2(30);
1941 l_line_rec OE_Order_PUB.Line_Rec_Type;
1942
1943 l_api_name CONSTANT VARCHAR(30) := 'Load_Lines';
1944
1945 /* Start - Code added for the bug 1923460 */
1946
1947 out_config_hdr_id NUMBER;
1948 out_config_rev_nbr NUMBER;
1949 l_error_message VARCHAR2(100);
1950 l_return_value NUMBER;
1951 l_dynamicSqlString VARCHAR2(2000);
1952 l_new_config_flag VARCHAR2(1) :=NULL;
1953 l_handle_deleted_flag VARCHAR2(1) :=NULL;
1954 l_new_name VARCHAR2(1000):=NULL;
1955 /* End - Code added for the bug 1923460 */
1956
1957 l_orig_item_id_tbl CZ_API_PUB.number_tbl_type;
1958 l_new_item_id_tbl CZ_API_PUB.number_tbl_type;
1959
1960 l_msg_count NUMBER;
1961 l_msg_data VARCHAR2(2000);
1962 l_return_status VARCHAR2(1);
1963 K NUMBER;
1964 J NUMBER;
1965 l_in_config_header_id NUMBER;
1966 --
1967 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1968 --
1969
1970 l_part_of_container VARCHAR2(1);
1971 l_top_container_model VARCHAR2(1);
1972
1973 BEGIN
1974 IF l_debug_level > 0 THEN
1975 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.LOAD_LINES' , 1 ) ;
1976 oe_debug_pub.add('p_all_lines is ' || p_all_lines , 1 ) ;
1977 END IF;
1978
1979 IF p_hdr_type_id IS NOT NULL THEN
1980 l_cpy_category := get_order_category(p_hdr_type_id);
1981 END IF;
1982
1983 IF p_line_type_id IS NOT NULL THEN
1984 l_line_category := get_line_category(p_line_type_id);
1985 END If;
1986
1987 IF FND_API.to_Boolean(p_all_lines) THEN
1988 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
1989 OE_Version_History_UTIL.query_rows(
1990 p_line_id => NULL
1991 ,p_header_id => p_header_id
1992 ,p_line_set_id => NULL
1993 ,p_version_number => p_version_number
1994 ,p_phase_change_flag => p_phase_change_flag
1995 ,x_line_tbl => x_line_tbl);
1996 ELSE
1997 OE_LINE_UTIL.query_rows(p_header_id => p_header_id
1998 ,x_line_tbl => x_line_tbl);
1999 END IF;
2000
2001 ELSIF p_num_lines > 0 THEN
2002
2003 sort_line_tbl(p_line_id_tbl,
2004 p_version_number,
2005 p_phase_change_flag,
2006 p_num_lines,
2007 x_line_tbl);
2008
2009 END IF; -- If All Lines
2010
2011
2012 -- Handle Configurations
2013 IF x_line_tbl.count > 0 THEN
2014
2015 -- Fix for bug1959957
2016 FOR i IN x_line_tbl.FIRST .. x_line_tbl.LAST LOOP
2017 IF (x_line_tbl(i).line_category_code = 'RETURN') THEN
2018 x_line_tbl(i).reference_line_id := NULL;
2019 x_line_tbl(i).return_attribute2 := NULL;
2020 x_line_tbl(i).return_attribute1 := NULL;
2021 x_line_tbl(i).reference_header_id := NULL;
2022 x_line_tbl(i).reference_type := NULL;
2023 x_line_tbl(i).return_context := NULL;
2024 END IF;
2025 -- if added for bug 10335712
2026 IF x_line_tbl(i).tax_exempt_flag ='S' THEN
2027 -- Check for Tax exempt number/Tax exempt reason.
2028 IF ( x_line_tbl(i).tax_exempt_number IS NOT NULL OR x_line_tbl(i).tax_exempt_reason_code IS NOT NULL ) THEN
2029 x_line_tbl(i).tax_exempt_number := NULL;
2030 x_line_tbl(i).tax_exempt_reason_code:= NULL;
2031 END IF;
2032 END IF;
2033 -- if ended for bug 10335712
2034 END LOOP;
2035
2036 IF (l_cpy_category = 'RETURN' OR
2037 l_line_category = 'RETURN') THEN -- When Destination is return.
2038
2039 Handle_Return_Lines(x_line_tbl, p_incl_cancelled);
2040
2041 ELSE -- When the destination is Mixed or Order.
2042
2043
2044 IF l_debug_level > 0 THEN
2045 oe_debug_pub.add( 'CALLING HANDLE_NONSTANDARD_LINES' , 1 ) ;
2046 END IF;
2047 /* Start 3923574 */
2048 Handle_NonStandard_Lines(x_line_tbl
2049 ,p_incl_cancelled
2050 ,x_top_model_tbl);
2051 /* Start 3923574 */
2052
2053 -- Set top_model_index for options and classes.
2054
2055 IF x_line_tbl.count > 0 THEN
2056 FOR I in x_line_tbl.FIRST .. x_line_tbl.LAST LOOP
2057
2058 l_top_model_index := FND_API.G_MISS_NUM;
2059
2060 IF x_line_tbl(I).item_type_code = OE_GLOBALS.G_ITEM_OPTION
2061 OR x_line_tbl(I).item_type_code = OE_GLOBALS.G_ITEM_CLASS THEN
2062
2063
2064 l_top_model_index := Find_LineIndex(x_line_tbl,
2065 x_line_tbl(I).top_model_line_id);
2066 x_line_tbl(I).top_model_line_index := l_top_model_index;
2067
2068 ELSIF x_line_tbl(I).item_type_code = OE_GLOBALS.G_ITEM_KIT
2069 THEN
2070
2071 IF x_line_tbl(I).top_model_line_id <> x_line_tbl(I).line_id THEN
2072
2073 l_top_model_index := Find_LineIndex(x_line_tbl,
2074 x_line_tbl(I).top_model_line_id);
2075 x_line_tbl(I).top_model_line_index := l_top_model_index;
2076
2077 END IF;
2078
2079 -- ## fixed as a prt of 1826688, however we need to always
2080 -- populate the top_model_line_index on the model line,
2081 -- irrespective of this bug fix.
2082
2083 ELSIF x_line_tbl(I).item_type_code = OE_GLOBALS.G_ITEM_MODEL
2084 THEN
2085 x_line_tbl(I).top_model_line_index := I;
2086
2087 /* Start 3923574 */
2088 IF NOT x_top_model_tbl.EXISTS(I) THEN
2089 x_top_model_tbl(I).has_canceled_lines := 'N';
2090 END IF;
2091 /* End 3923574 */
2092
2093 /* Start - Code for bug 1923460 */
2094 -- For fixing the Line Level Config COPY 3508387
2095 -- IF G_ORDER_LEVEL_COPY = 1 AND
2096 /* Start 3923574 */
2097 -- Added extra condition to check if Model has canceled lines
2098 -- selected for copy. If true then do not call CZ api.
2099 /* End 3923574 */
2100 IF G_COPY_REC.copy_complete_config = FND_API.G_TRUE AND
2101 x_line_tbl(I).config_header_id IS NOT NULL AND
2102 x_line_tbl(I).config_rev_nbr IS NOT NULL AND
2103 x_line_tbl(I).cancelled_flag <> 'Y' AND
2104 NVL(x_top_model_tbl(I).has_canceled_lines, 'N') = 'N'
2105 THEN
2106 IF OE_CODE_CONTROL.Get_Code_Release_Level < '110509' THEN
2107 IF l_debug_level > 0 THEN
2108 oe_debug_pub.add('1923460: ABOUT TO RUN COPY CONFIGURATION' , 1 ) ;
2109 END IF;
2110
2111 l_dynamicSqlString := '
2112 Begin
2113 cz_cf_api.copy_configuration_auto(
2114 :config_hdr_id ,
2115 :config_rev_nbr,
2116 :new_config_flag,
2117 :out_config_hdr_id ,
2118 :out_config_rev_nbr,
2119 :Error_message ,
2120 :Return_value ,
2121 :handle_deleted_flag,
2122 :new_name);
2123 end;';
2124
2125 EXECUTE IMMEDIATE l_dynamicSqlString
2126 USING IN x_line_tbl(I).config_header_id,
2127 IN x_line_tbl(I).config_rev_nbr,
2128 IN l_new_config_flag,
2129 IN OUT out_config_hdr_id,
2130 IN OUT out_config_rev_nbr,
2131 IN OUT l_Error_message,
2132 IN OUT l_Return_value,
2133 IN l_handle_deleted_flag,
2134 IN l_new_name ;
2135
2136 IF (l_Return_value = 1) THEN
2137 x_top_model_tbl(I).config_header_id :=
2138 out_config_hdr_id;
2139 x_top_model_tbl(I).config_rev_nbr :=
2140 out_config_rev_nbr;
2141 IF l_debug_level > 0 THEN
2142 oe_debug_pub.add( '1923460: INDEX IS '
2143 ||TO_CHAR ( I ) , 1 ) ;
2144 oe_debug_pub.add( '1923460: OUT_CONFIG_HEADER_ID
2145 IS '||TO_CHAR ( OUT_CONFIG_HDR_ID ) , 1 ) ;
2146 oe_debug_pub.add( '1923460: OUT_CONFIG_REV_NBR IS '
2147 ||TO_CHAR ( OUT_CONFIG_REV_NBR ) , 1 ) ;
2148 END IF;
2149 ELSE
2150 IF l_debug_level > 0 THEN
2151 oe_debug_pub.add( '1923460: FAILED IN COPY
2152 CONFIGURATION' , 1 ) ;
2153 END IF;
2154 END IF;
2155
2156 ELSE -- pack I onwards
2157
2158 IF l_debug_level > 0 THEN
2159 oe_debug_pub.add( 'NEW COPY CONFIG API' , 1 ) ;
2160 END IF;
2161
2162 l_in_config_header_id := x_line_tbl(I).config_header_id;
2163
2164 CZ_Config_API_Pub.copy_configuration_auto
2165 ( p_api_version => 1.0
2166 ,p_config_hdr_id => x_line_tbl(I).config_header_id
2167 ,p_config_rev_nbr => x_line_tbl(I).config_rev_nbr
2168 ,p_copy_mode => CZ_API_PUB.G_NEW_HEADER_COPY_MODE
2169 ,x_config_hdr_id => out_config_hdr_id
2170 ,x_config_rev_nbr => out_config_rev_nbr
2171 ,x_orig_item_id_tbl => l_orig_item_id_tbl
2172 ,x_new_item_id_tbl => l_new_item_id_tbl
2173 ,x_return_status => l_return_status
2174 ,x_msg_count => l_msg_count
2175 ,x_msg_data => l_msg_data);
2176
2177 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2178 OE_Msg_Pub.Add_Text(l_msg_data);
2179 IF l_debug_level > 0 THEN
2180 oe_debug_pub.add( 'ERROR FROM NEW COPY: '
2181 || L_MSG_DATA , 1 ) ;
2182 END IF;
2183 END IF;
2184
2185 K := I;
2186
2187 WHILE K is not null
2188 LOOP
2189
2190 J := l_orig_item_id_tbl.FIRST;
2191
2192 WHILE J is not null
2193 LOOP
2194
2195 IF x_line_tbl(K).config_header_id is not null AND
2196 x_line_tbl(K).config_header_id = l_in_config_header_id
2197 THEN
2198 IF x_line_tbl(K).configuration_id =
2199 l_orig_item_id_tbl(J) THEN
2200
2201 x_line_tbl(K).configuration_id
2202 := l_new_item_id_tbl(J);
2203
2204 IF l_debug_level > 0 THEN
2205 oe_debug_pub.add( 'OLD CONFIG '||
2206 L_ORIG_ITEM_ID_TBL ( J ) , 1 ) ;
2207 END IF;
2208 IF l_debug_level > 0 THEN
2209 oe_debug_pub.add( 'NEW CONFIG '
2210 ||X_LINE_TBL ( K ) .CONFIGURATION_ID , 1 ) ;
2211 END IF;
2212 EXIT;
2213 END IF;
2214 END IF;
2215
2216 J := l_orig_item_id_tbl.NEXT(J);
2217 END LOOP;
2218
2219 K := x_line_tbl.NEXT(K);
2220 END LOOP;
2221
2222 IF l_debug_level > 0 THEN
2223 oe_debug_pub.add('DONE UPDATING NEW CONFIG ITEM IDS',1);
2224 END IF;
2225
2226 -- now set the new cofig hdr/rev on model.
2227 -- is this table always populated??
2228 x_top_model_tbl(I).config_header_id := out_config_hdr_id;
2229 x_top_model_tbl(I).config_rev_nbr := out_config_rev_nbr;
2230
2231 END IF; -- pack I check
2232 END IF;
2233 /* End - Code for bug 1923460 */
2234
2235 -- Set service line index for service lines.
2236 ELSIF x_line_tbl(I).item_type_code = OE_GLOBALS.G_ITEM_SERVICE
2237 THEN
2238
2239 l_top_model_index := Find_LineIndex(x_line_tbl,
2240 x_line_tbl(I).service_reference_line_id);
2241 x_line_tbl(I).service_line_index := l_top_model_index;
2242
2243 END IF;
2244
2245
2246 IF l_debug_level > 0 THEN
2247 oe_debug_pub.add( 'ITEM_TYPE_CODE IS'
2248 ||X_LINE_TBL ( I ) .ITEM_TYPE_CODE , 1 ) ;
2249 oe_debug_pub.add( 'LINE ID IS'||X_LINE_TBL ( I ) .LINE_ID , 1 ) ;
2250 oe_debug_pub.add( 'TOP_MODEL_LINE_INDEX IS '
2251 ||TO_CHAR ( L_TOP_MODEL_INDEX ) , 1 ) ;
2252 END IF;
2253 END LOOP;
2254 END IF; -- IF x_line_tbl.count > 0
2255 END IF; -- IF (l_cpy_category = 'RETURN' OR
2256
2257 END IF; -- IF x_line_tbl.count > 0
2258
2259 IF l_debug_level > 0 THEN
2260 oe_debug_pub.add( 'EXITING OE_ORDER_COPY_UTIL.LOAD_LINES' , 1 ) ;
2261 END IF;
2262
2263
2264 EXCEPTION
2265
2266 WHEN OTHERS THEN
2267
2268 IF l_debug_level > 0 THEN
2269 oe_debug_pub.add( 'IN OTHERS LOAD LINES '|| sqlerrm , 1 ) ;
2270 END IF;
2271
2272 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2273 THEN
2274 OE_MSG_PUB.Add_Exc_Msg
2275 ( G_PKG_NAME
2276 , l_api_name
2277 );
2278 END IF;
2279
2280 OE_DEBUG_PUB.DumpDebug;
2281
2282 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2283
2284 End Load_Lines;
2285
2286 procedure Clear_Missing_Attributes(
2287 p_line_rec IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type)
2288 IS
2289 --
2290 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2291 --
2292 BEGIN
2293
2294 IF p_line_rec.SERVICE_REFERENCE_TYPE_CODE IS NULL THEN
2295 p_line_rec.SERVICE_REFERENCE_TYPE_CODE := FND_API.G_MISS_CHAR;
2296 END IF;
2297
2298 IF p_line_rec.ORDERED_QUANTITY2 IS NULL THEN
2299 p_line_rec.ORDERED_QUANTITY2 := FND_API.G_MISS_NUM;
2300 END IF;
2301
2302 IF p_line_rec.ORDERED_QUANTITY_UOM2 IS NULL THEN
2303 p_line_rec.ORDERED_QUANTITY_UOM2 := FND_API.G_MISS_CHAR;
2304 END IF;
2305
2306 IF p_line_rec.PREFERRED_GRADE IS NULL THEN
2307 p_line_rec.PREFERRED_GRADE := FND_API.G_MISS_CHAR;
2308 END IF;
2309
2310 IF p_line_rec.TAX_EXEMPT_FLAG IS NULL THEN
2311 p_line_rec.TAX_EXEMPT_FLAG := FND_API.G_MISS_CHAR;
2312 END IF;
2313
2314 IF p_line_rec.TAX_EXEMPT_NUMBER IS NULL THEN
2315 p_line_rec.TAX_EXEMPT_NUMBER := FND_API.G_MISS_CHAR;
2316 END IF;
2317
2318 IF p_line_rec.PAYMENT_TERM_ID IS NULL THEN
2319 p_line_rec.PAYMENT_TERM_ID := FND_API.G_MISS_NUM;
2320 END IF;
2321
2322 IF p_line_rec.PRICE_LIST_ID IS NULL THEN
2323 p_line_rec.PRICE_LIST_ID := FND_API.G_MISS_NUM;
2324 END IF;
2325
2326 IF p_line_rec.PRICING_DATE IS NULL THEN
2327 p_line_rec.PRICING_DATE := FND_API.G_MISS_DATE;
2328 END IF;
2329
2330 IF p_line_rec.REQUEST_DATE IS NULL THEN
2331 p_line_rec.REQUEST_DATE := FND_API.G_MISS_DATE;
2332 END IF;
2333
2334 IF p_line_rec.RETURN_REASON_CODE IS NULL THEN
2335 p_line_rec.RETURN_REASON_CODE := FND_API.G_MISS_CHAR;
2336 END IF;
2337
2338 IF p_line_rec.SHIPPING_METHOD_CODE IS NULL THEN
2339 p_line_rec.SHIPPING_METHOD_CODE := FND_API.G_MISS_CHAR;
2340 END IF;
2341
2342 IF p_line_rec.SHIP_FROM_ORG_ID IS NULL THEN
2343 p_line_rec.SHIP_FROM_ORG_ID := FND_API.G_MISS_NUM;
2344 END IF;
2345
2346 IF p_line_rec.SHIP_TOLERANCE_ABOVE IS NULL THEN
2347 p_line_rec.SHIP_TOLERANCE_ABOVE := FND_API.G_MISS_NUM;
2348 END IF;
2349
2350 IF p_line_rec.SHIP_TO_CONTACT_ID IS NULL THEN
2351 p_line_rec.SHIP_TO_CONTACT_ID := FND_API.G_MISS_NUM;
2352 END IF;
2353
2354 IF p_line_rec.SOLD_TO_ORG_ID IS NULL THEN
2355 p_line_rec.SOLD_TO_ORG_ID := FND_API.G_MISS_NUM;
2356 END IF;
2357
2358 IF p_line_rec.SOURCE_TYPE_CODE IS NULL THEN
2359 p_line_rec.SOURCE_TYPE_CODE := FND_API.G_MISS_CHAR;
2360 END IF;
2361
2362 IF p_line_rec.TAX_CODE IS NULL THEN
2363 p_line_rec.TAX_CODE := FND_API.G_MISS_CHAR;
2364 END IF;
2365
2366 IF p_line_rec.INVOICE_TO_CONTACT_ID IS NULL THEN
2367 p_line_rec.INVOICE_TO_CONTACT_ID := FND_API.G_MISS_NUM;
2368 END IF;
2369
2370 IF p_line_rec.INVOICING_RULE_ID IS NULL THEN
2371 p_line_rec.INVOICING_RULE_ID := FND_API.G_MISS_NUM;
2372 END IF;
2373
2374 IF p_line_rec.ITEM_REVISION IS NULL THEN
2375 p_line_rec.ITEM_REVISION := FND_API.G_MISS_CHAR;
2376 END IF;
2377
2378 IF p_line_rec.ORDERED_QUANTITY IS NULL THEN
2379 p_line_rec.ORDERED_QUANTITY := FND_API.G_MISS_NUM;
2380 END IF;
2381
2382 IF p_line_rec.ORDER_QUANTITY_UOM IS NULL THEN
2383 p_line_rec.ORDER_QUANTITY_UOM := FND_API.G_MISS_CHAR;
2384 END IF;
2385
2386 IF p_line_rec.SUBINVENTORY IS NULL THEN
2387 p_line_rec.SUBINVENTORY := FND_API.G_MISS_CHAR;
2388 END IF;
2389
2390 IF p_line_rec.AGREEMENT_ID IS NULL THEN
2391 p_line_rec.AGREEMENT_ID := FND_API.G_MISS_NUM;
2392 END IF;
2393
2394 IF p_line_rec.CUST_PO_NUMBER IS NULL THEN
2395 p_line_rec.CUST_PO_NUMBER := FND_API.G_MISS_CHAR;
2396 END IF;
2397
2398 IF p_line_rec.DELIVER_TO_ORG_ID IS NULL THEN
2399 p_line_rec.DELIVER_TO_ORG_ID := FND_API.G_MISS_NUM;
2400 END IF;
2401
2402 IF p_line_rec.FOB_POINT_CODE IS NULL THEN
2403 p_line_rec.FOB_POINT_CODE := FND_API.G_MISS_CHAR;
2404 END IF;
2405
2406 IF p_line_rec.SALESREP_ID IS NULL THEN
2407 p_line_rec.SALESREP_ID := FND_API.G_MISS_NUM;
2408 END IF;
2409
2410 IF p_line_rec.SHIPMENT_PRIORITY_CODE IS NULL THEN
2411 p_line_rec.SHIPMENT_PRIORITY_CODE := FND_API.G_MISS_CHAR;
2412 END IF;
2413
2414 IF p_line_rec.SHIP_TO_ORG_ID IS NULL THEN
2415 p_line_rec.SHIP_TO_ORG_ID := FND_API.G_MISS_NUM;
2416 END IF;
2417
2418 IF p_line_rec.ACCOUNTING_RULE_ID IS NULL THEN
2419 p_line_rec.ACCOUNTING_RULE_ID := FND_API.G_MISS_NUM;
2420 END IF;
2421
2422 IF p_line_rec.DELIVER_TO_CONTACT_ID IS NULL THEN
2423 p_line_rec.DELIVER_TO_CONTACT_ID := FND_API.G_MISS_NUM;
2424 END IF;
2425
2426 IF p_line_rec.DEMAND_CLASS_CODE IS NULL THEN
2427 p_line_rec.DEMAND_CLASS_CODE := FND_API.G_MISS_CHAR;
2428 END IF;
2429
2430 IF p_line_rec.FREIGHT_TERMS_CODE IS NULL THEN
2431 p_line_rec.FREIGHT_TERMS_CODE := FND_API.G_MISS_CHAR;
2432 END IF;
2433
2434 IF p_line_rec.INVOICE_TO_ORG_ID IS NULL THEN
2435 p_line_rec.INVOICE_TO_ORG_ID := FND_API.G_MISS_NUM;
2436 END IF;
2437
2438 IF p_line_rec.SHIP_TOLERANCE_BELOW IS NULL THEN
2439 p_line_rec.SHIP_TOLERANCE_BELOW := FND_API.G_MISS_NUM;
2440 END IF;
2441
2442 IF p_line_rec.ITEM_IDENTIFIER_TYPE IS NULL THEN
2443 p_line_rec.ITEM_IDENTIFIER_TYPE := FND_API.G_MISS_CHAR;
2444 END IF;
2445
2446 IF p_line_rec.CALCULATE_PRICE_FLAG IS NULL THEN
2447 p_line_rec.CALCULATE_PRICE_FLAG := FND_API.G_MISS_CHAR;
2448 END IF;
2449
2450 IF p_line_rec.LINE_TYPE_ID IS NULL THEN
2451 p_line_rec.LINE_TYPE_ID := FND_API.G_MISS_NUM;
2452 END IF;
2453
2454 IF p_line_rec.SERVICE_PERIOD IS NULL THEN
2455 p_line_rec.SERVICE_PERIOD := FND_API.G_MISS_CHAR;
2456 END IF;
2457
2458 IF p_line_rec.SERVICE_START_DATE IS NULL THEN
2459 p_line_rec.SERVICE_START_DATE := FND_API.G_MISS_DATE;
2460 END IF;
2461
2462 IF p_line_rec.TAX_EXEMPT_REASON_CODE IS NULL THEN
2463 p_line_rec.TAX_EXEMPT_REASON_CODE := FND_API.G_MISS_CHAR;
2464 END IF;
2465
2466 IF p_line_rec.COMMITMENT_ID IS NULL THEN
2467 p_line_rec.COMMITMENT_ID := FND_API.G_MISS_NUM;
2468 END IF;
2469
2470 END Clear_Missing_Attributes;
2471
2472 Procedure Init_Lines_New
2473 ( p_x_line_tbl IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type
2474 ,p_x_top_model_tbl IN OUT NOCOPY Top_Model_Tbl_Type
2475 ,p_line_type IN NUMBER
2476 ,p_header_id IN NUMBER
2477 ,p_line_price_mode IN NUMBER
2478 ,p_line_price_date IN DATE
2479 ,p_line_descflex IN VARCHAR2
2480 ,p_create_rma IN VARCHAR2 := FND_API.G_FALSE
2481 ,p_return_reason_code IN VARCHAR2
2482 ,p_default_null_values IN VARCHAR2
2483 ,p_reason_code IN VARCHAR2
2484 ,p_comments IN VARCHAR2
2485 ,p_copy_rec IN COPY_REC_TYPE
2486 ,p_action_request_tbl IN OUT NOCOPY OE_Order_PUB.Request_Tbl_Type
2487 )
2488 IS
2489 l_api_name CONSTANT VARCHAR2(30) := 'Init_Lines_New';
2490 l_temp_line_rec OE_ORDER_PUB.Line_Rec_Type;
2491 l_orig_line_category VARCHAR2(30);
2492 l_cpy_line_category VARCHAR2(30);
2493 l_order_number NUMBER;
2494 l_order_type_id NUMBER;
2495 l_version_number NUMBER;
2496 l_rma_to_reg VARCHAR2(1) := FND_API.G_FALSE;
2497 l_reg_to_rma VARCHAR2(1) := FND_API.G_FALSE;
2498 k NUMBER;
2499 l_top_model_line_index NUMBER;
2500 j BINARY_INTEGER;
2501 /* Added the following 3 variables to fix the bug 2400441 */
2502 l_max_line_no NUMBER;
2503 l_total_lines NUMBER;
2504 l_copying_all_lines VARCHAR2(3);
2505 --
2506 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2507 --
2508 l_line_set_tbl Line_Set_Tbl_Type;
2509 l_count NUMBER;
2510 l_index NUMBER;
2511 l_parent_found BOOLEAN := FALSE;
2512 l_operation VARCHAR2(30);
2513 BEGIN
2514
2515 IF l_debug_level > 0 THEN
2516 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.INIT_LINES_NEW' , 1 ) ;
2517 END IF;
2518
2519 IF p_line_type IS NOT NULL THEN -- If Returns is calling us then this is NULL.
2520 IF l_debug_level > 0 THEN
2521 oe_debug_pub.add( ' GET LINE CATEGORY ' , 1 ) ;
2522 END IF;
2523 l_cpy_line_category := Get_Line_Category(p_line_type);
2524 END IF;
2525
2526 -- Delete all records from G_Line_Num_Rec
2527 DELETE_TBL;
2528
2529 -- Set the counter for global rec
2530 j := 0;
2531
2532 IF p_x_line_tbl.COUNT > 0 THEN
2533
2534 -- Allocate memory to the Global Line Number rec.
2535 EXTEND_TBL(p_x_line_tbl.COUNT);
2536
2537 k := p_x_line_tbl.FIRST;
2538 WHILE k IS NOT NULL LOOP
2539 BEGIN
2540
2541 -- Load Temporary Line Record to be used for setting various values
2542 -- Doing so removes dependency on the Order in which we clear attributes.
2543
2544 l_temp_line_rec := p_x_line_tbl(k);
2545
2546
2547 -- Populate the Global Line Number record
2548 j := j + 1;
2549
2550 G_Line_Num_Rec.line_id(J) := p_x_line_tbl(k).line_id;
2551 G_Line_Num_Rec.line_number(J) := p_x_line_tbl(k).line_number;
2552 G_Line_Num_Rec.shipment_number(J) := p_x_line_tbl(k).shipment_number;
2553 G_Line_Num_Rec.option_number(J) := p_x_line_tbl(k).option_number;
2554 G_Line_Num_Rec.component_number(J) := p_x_line_tbl(k).component_number;
2555 G_Line_Num_Rec.service_number(J) := p_x_line_tbl(k).service_number;
2556 G_Line_Num_Rec.split_from_line_id(J) := p_x_line_tbl(k).split_from_line_id;
2557
2558 -- Find the Split_from_line_id from pre-populated line_ids
2559 IF G_Line_Num_Rec.split_from_line_id(J) IS NOT NULL AND
2560 J > 1 THEN
2561
2562 G_Order_Has_Split_Lines := TRUE;
2563
2564 -- Find out the Split_from_line_id from G_Line_Num_Rec;
2565 FOR m in 1..J LOOP
2566 IF G_Line_Num_Rec.line_id(m) =
2567 G_Line_Num_Rec.split_from_line_id(J)
2568 THEN
2569 G_Line_Num_Rec.split_from_line_id(J) :=
2570 G_Line_Num_Rec.new_line_id(m);
2571 G_Line_Num_Rec.split_by(J) := 'USER';
2572 IF l_debug_level > 0 THEN
2573 oe_debug_pub.add( 'FOUND THE SPLIT_FROM '||G_LINE_NUM_REC.NEW_LINE_ID ( M ) , 1 ) ;
2574 END IF;
2575 EXIT;
2576 END IF;
2577
2578 END LOOP;
2579
2580 END IF;
2581
2582 -- Set Boolean to handle Return Lines
2583 -- If Returns is calling us then p_create_rma will be set to
2584 -- 'T' else the default is 'F'.
2585 l_reg_to_rma := p_create_rma;
2586
2587 -- Check if the Line Category is RETURN
2588
2589 IF Get_line_category(NVL(p_line_type,l_temp_line_rec.line_type_id)) =
2590 'RETURN' AND p_return_reason_code IS NOT NULL
2591 THEN
2592 p_x_line_tbl(k).return_reason_code := p_return_reason_code;
2593 END IF;
2594
2595 -- Get the line category for the source line
2596 l_orig_line_category := Get_line_category(l_temp_line_rec.line_type_id);
2597 -- Check If we are changing Line Type
2598
2599 IF p_line_type IS NOT NULL THEN -- IF return is calling us then this will be null.
2600 p_x_line_tbl(k).line_type_id := p_line_type;
2601 IF p_line_type <> l_temp_line_rec.line_type_id THEN
2602
2603 IF l_debug_level > 0 THEN
2604 oe_debug_pub.add( 'AK :COPY LINE CAT ' || L_CPY_LINE_CATEGORY , 2 ) ;
2605 oe_debug_pub.add( 'AK :ORIG LINE CAT ' || L_ORIG_LINE_CATEGORY , 2 ) ;
2606 END IF;
2607 -- If we are copying from a non-return to a return type
2608 IF (l_orig_line_category = 'ORDER') AND
2609 (l_cpy_line_category = 'RETURN') THEN
2610 l_reg_to_rma := FND_API.G_TRUE;
2611 l_operation := 'ORDER_TO_RETURN';
2612 ELSIF (l_orig_line_category = 'RETURN') AND
2613 (l_cpy_line_category = 'ORDER') THEN
2614 l_rma_to_reg := FND_API.G_TRUE;
2615 l_operation := 'RETURN_TO_ORDER';
2616 END IF;
2617 END IF;
2618 ELSE -- IF p_line_type IS NULL
2619
2620 IF l_orig_line_category = 'ORDER' THEN
2621 l_operation := 'ORDER_TO_ORDER';
2622 ELSE
2623 l_operation := 'RETURN_TO_RETURN';
2624 END IF;
2625 END IF;
2626 IF l_debug_level > 0 THEN
2627 oe_debug_pub.add( 'IF REG TO RET'||L_REG_TO_RMA , 1 ) ;
2628 END IF;
2629
2630
2631 -- Init various columns
2632 -- OE_DEBUG_PUB.ADD('Init various Cols');
2633 -- Set Date, Time, who columns
2634
2635 p_x_line_tbl(k).creation_date := FND_API.G_MISS_DATE;
2636 p_x_line_tbl(k).created_by := FND_API.G_MISS_NUM;
2637 p_x_line_tbl(k).last_update_date := FND_API.G_MISS_DATE;
2638 p_x_line_tbl(k).last_updated_by := FND_API.G_MISS_NUM;
2639 p_x_line_tbl(k).last_update_login := FND_API.G_MISS_NUM;
2640 p_x_line_tbl(k).program_application_id := FND_API.G_MISS_NUM;
2641 p_x_line_tbl(k).program_id := FND_API.G_MISS_NUM;
2642 p_x_line_tbl(k).request_id := FND_API.G_MISS_NUM;
2643 p_x_line_tbl(k).program_update_date := FND_API.G_MISS_DATE;
2644 /* Reverting the fix of 6519067 for the fix 10385363
2645 if p_x_line_tbl(k).ACCOUNTING_RULE_ID is null then -- added for Bug 6519067
2646 p_x_line_tbl(k).ACCOUNTING_RULE_ID := FND_API.G_MISS_NUM; -- added for Bug 6519067
2647 end if;
2648 */
2649 -- Clear Transaction Phase for New Lines
2650 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
2651 p_x_line_tbl(k).transaction_phase_code := FND_API.G_MISS_CHAR;
2652
2653 IF p_reason_code IS NOT NULL THEN
2654 p_x_line_tbl(k).change_reason := p_reason_code;
2655 END IF;
2656
2657 IF p_comments IS NOT NULL THEN
2658 p_x_line_tbl(k).change_comments := p_comments;
2659 END IF;
2660
2661 -- Copy the Source Version Number..
2662 p_x_line_tbl(k).SOURCE_DOCUMENT_VERSION_NUMBER := G_LN_VER_NUMBER;
2663
2664 END IF;
2665
2666 /* Start - code added for bug 1923460 */
2667
2668 l_top_model_line_index := p_x_line_tbl(k).top_model_line_index;
2669
2670 -- Added the check for FND_API.G_MISS_NUM to avoid the numeric
2671 -- overflow as reported in bug 3640804
2672
2673 IF l_top_model_line_index IS NOT NULL and
2674 l_top_model_line_index <> FND_API.G_MISS_NUM
2675 THEN
2676 IF p_x_top_model_tbl.EXISTS(l_top_model_line_index) THEN
2677 IF l_debug_level > 0 THEN
2678 oe_debug_pub.add( '1923460: IN INIT_LINES , MODEL_INDEX IS '||TO_CHAR ( L_TOP_MODEL_LINE_INDEX ) , 1 ) ;
2679 oe_debug_pub.add( '1923460: IN INIT_LINES , CONFIG_HEADER_ID IS '||TO_CHAR ( P_X_TOP_MODEL_TBL ( L_TOP_MODEL_LINE_INDEX ) .CONFIG_HEADER_ID ) , 1 ) ;
2680 oe_debug_pub.add( '1923460: IN INIT_LINES , CONFIG_REV_NBR IS '||TO_CHAR ( P_X_TOP_MODEL_TBL ( L_TOP_MODEL_LINE_INDEX ) .CONFIG_REV_NBR ) , 1 ) ;
2681 END IF;
2682 p_x_line_tbl(k).config_header_id
2683 := p_x_top_model_tbl(l_top_model_line_index).config_header_id;
2684 p_x_line_tbl(k).config_rev_nbr
2685 := p_x_top_model_tbl(l_top_model_line_index).config_rev_nbr;
2686 ELSE
2687 p_x_line_tbl(k).config_header_id := NULL;
2688 p_x_line_tbl(k).config_rev_nbr := NULL;
2689 END IF;
2690 ELSE
2691 p_x_line_tbl(k).config_header_id := NULL;
2692 p_x_line_tbl(k).config_rev_nbr := NULL;
2693 END IF;
2694
2695 /* End - code added for bug 1923460 */
2696
2697 /* Added the following code to null out nocopy acknowledgement related fields in the order header , to fix the bug 1862719 */
2698
2699
2700 p_x_line_tbl(k).first_ack_code := FND_API.G_MISS_CHAR;
2701 p_x_line_tbl(k).first_ack_date := FND_API.G_MISS_DATE;
2702 p_x_line_tbl(k).last_ack_code := FND_API.G_MISS_CHAR;
2703 p_x_line_tbl(k).last_ack_date := FND_API.G_MISS_DATE;
2704
2705 /* End of code added to fix the bug 1862719 */
2706
2707 -- Set foreign keys
2708 p_x_line_tbl(k).header_id := FND_API.G_MISS_NUM;
2709
2710 -- Pre-populate the line_id to load G_Line_Num_Rec
2711 SELECT OE_ORDER_LINES_S.NEXTVAL
2712 INTO p_x_line_tbl(k).line_id
2713 FROM dual;
2714 G_Line_Num_Rec.new_line_id(J) := p_x_line_tbl(k).line_id;
2715 IF l_debug_level > 0 THEN
2716 oe_debug_pub.add( 'NEW LINE ID IS '||P_X_LINE_TBL ( K ) .LINE_ID , 1 ) ;
2717 END IF;
2718
2719 -- Load line level holds for this line
2720 IF l_debug_level > 0 THEN
2721 oe_debug_pub.add('The COPy Line Level HOLDS '||p_copy_rec.line_holds);
2722 oe_debug_pub.add('REG to RMA '||l_reg_to_rma);
2723 oe_debug_pub.add('RMA to REG '||l_rma_to_reg);
2724 END IF;
2725
2726 IF p_copy_rec.line_holds = FND_API.G_TRUE AND
2727 l_reg_to_rma = FND_API.G_FALSE AND
2728 l_rma_to_reg = FND_API.G_FALSE
2729 THEN
2730 Load_and_Init_line_Holds(
2731 p_line_Id => l_temp_line_rec.line_id ,
2732 p_new_line_id => p_x_line_tbl(k).line_id ,
2733 p_action_request_tbl => p_action_request_tbl
2734 );
2735 END IF;
2736
2737
2738 -- Adding logic to check if the line is a part of the Split Set.
2739
2740 IF p_x_line_tbl(k).SPLIT_BY IS NOT NULL AND
2741 NOT (FND_API.to_Boolean(l_reg_to_rma) OR
2742 FND_API.to_Boolean(l_rma_to_reg))
2743 THEN
2744
2745 l_parent_found := FALSE;
2746
2747 IF l_line_set_tbl.COUNT > 0
2748 AND G_Line_Num_Rec.split_by(J) IS NOT NULL --Added for bug 5199676
2749 THEN
2750
2751 FOR x IN 1..l_line_set_tbl.COUNT LOOP
2752
2753 IF l_line_set_tbl(x).old_set_id =
2754 p_x_line_tbl(k).line_set_id
2755 THEN
2756
2757 IF l_line_set_tbl(x).set_count = 1 AND
2758 l_line_set_tbl(x).line_set_id IS NULL
2759 THEN
2760 SELECT OE_SETS_S.NEXTVAL
2761 INTO l_line_set_tbl(x).line_set_id
2762 FROM DUAL;
2763 l_index := l_line_set_tbl(x).line_index;
2764 p_x_line_tbl(l_index).line_set_id :=
2765 l_line_set_tbl(x).line_set_id;
2766 END IF;
2767 p_x_line_tbl(k).line_set_id :=
2768 l_line_set_tbl(x).line_set_id;
2769 l_line_set_tbl(x).set_count :=
2770 l_line_set_tbl(x).set_count + 1;
2771 IF l_debug_level > 0 THEN
2772 oe_debug_pub.add( 'Line Set Id is'||P_X_LINE_TBL( K ).line_set_id , 1 ) ;
2773 END IF;
2774 l_parent_found := TRUE;
2775 EXIT;
2776 END IF;
2777
2778 END LOOP;
2779
2780 END IF; -- IF l_line_set_tbl.COUNT > 0 THEN
2781
2782 IF NOT l_parent_found THEN
2783 l_count := l_line_set_tbl.COUNT;
2784 l_line_set_tbl(l_count+1).line_id := p_x_line_tbl(k).line_id;
2785 l_line_set_tbl(l_count+1).old_line_id :=
2786 G_Line_Num_Rec.line_id(J);
2787 l_line_set_tbl(l_count+1).header_id := p_header_id;
2788 l_line_set_tbl(l_count+1).line_type_id :=
2789 p_x_line_tbl(k).line_type_id;
2790 l_line_set_tbl(l_count+1).set_count := 1;
2791 l_line_set_tbl(l_count+1).old_set_id :=
2792 p_x_line_tbl(k).line_set_id;
2793 l_line_set_tbl(l_count+1).line_set_id := NULL;
2794 l_line_set_tbl(l_count+1).line_index := k;
2795 p_x_line_tbl(k).line_set_id := NULL;
2796 G_Line_Num_Rec.split_from_line_id(j) := NULL;
2797 END IF;
2798
2799 END IF;
2800
2801 p_x_line_tbl(k).commitment_id := FND_API.G_MISS_NUM;
2802
2803 p_x_line_tbl(k).line_number := FND_API.G_MISS_NUM;
2804 p_x_line_tbl(k).top_model_line_id := FND_API.G_MISS_NUM;
2805 p_x_line_tbl(k).link_to_line_id := FND_API.G_MISS_NUM;
2806
2807 IF
2808 ---- G_ORDER_LEVEL_COPY = 1 AND bug# 7436888 ,8439061
2809 OE_CODE_CONTROL.Get_Code_Release_Level >= '110508' AND
2810 p_x_line_tbl(k).config_header_id is not NULL AND
2811 p_x_line_tbl(k).config_header_id <> FND_API.G_MISS_NUM AND
2812 p_x_line_tbl(k).cancelled_flag <> 'Y'
2813 THEN
2814 IF l_debug_level > 0 THEN
2815 oe_debug_pub.add( 'COPY: PACK H NEW LOGIC MI '||P_X_LINE_TBL ( K ) .CONFIGURATION_ID , 1 ) ;
2816 END IF;
2817 ELSE
2818 p_x_line_tbl(k).configuration_id := FND_API.G_MISS_NUM;
2819 END IF;
2820
2821 -- Added following logic to retain split info.
2822 IF p_x_line_tbl(k).split_by IS NULL THEN
2823 p_x_line_tbl(k).line_set_id := FND_API.G_MISS_NUM;
2824 END IF;
2825
2826 p_x_line_tbl(k).split_from_line_id := FND_API.G_MISS_NUM;
2827 p_x_line_tbl(k).shipment_number := FND_API.G_MISS_NUM;
2828 p_x_line_tbl(k).option_number := FND_API.G_MISS_NUM;
2829 p_x_line_tbl(k).ato_line_id := FND_API.G_MISS_NUM;
2830
2831 -- Status flags
2832 p_x_line_tbl(k).booked_flag := FND_API.G_MISS_CHAR;
2833 p_x_line_tbl(k).cancelled_flag := FND_API.G_MISS_CHAR;
2834 p_x_line_tbl(k).open_flag := FND_API.G_MISS_CHAR;
2835 p_x_line_tbl(k).shipping_interfaced_flag := FND_API.G_MISS_CHAR;
2836 p_x_line_tbl(k).invoice_interface_status_code := FND_API.G_MISS_CHAR;
2837 p_x_line_tbl(k).model_remnant_flag := FND_API.G_MISS_CHAR;
2838 p_x_line_tbl(k).flow_status_code := 'ENTERED';
2839 p_x_line_tbl(k).fulfilled_flag := FND_API.G_MISS_CHAR;
2840
2841 -- Added this line to initialize ship_model_complete_flag
2842 -- to 'NULL'. Refer Bug1864983
2843 p_x_line_tbl(k).ship_model_complete_flag := FND_API.G_MISS_CHAR;
2844
2845 -- Set ordered_qty to cancelled lines for fully cancelled lines
2846 IF l_temp_line_rec.cancelled_flag = 'Y' THEN
2847 p_x_line_tbl(k).ordered_quantity :=
2848 l_temp_line_rec.cancelled_quantity;
2849 /*Bug#10183265 passing the secondary cancelled quantity to the new
2850 * * copied order's secondary ordered quantity */
2851 p_x_line_tbl(k).ordered_quantity2 :=
2852 l_temp_line_rec.cancelled_quantity2;
2853
2854 p_x_line_tbl(k).config_header_id := NULL;
2855 p_x_line_tbl(k).config_rev_nbr := NULL;
2856 END IF;
2857
2858 -- Various quantities
2859 p_x_line_tbl(k).cancelled_quantity := FND_API.G_MISS_NUM;
2860 p_x_line_tbl(k).reserved_quantity := FND_API.G_MISS_NUM;
2861 p_x_line_tbl(k).fulfilled_quantity := FND_API.G_MISS_NUM;
2862 p_x_line_tbl(k).shipped_quantity := FND_API.G_MISS_NUM;
2863
2864 -- INVCONV
2865 p_x_line_tbl(k).cancelled_quantity2 := FND_API.G_MISS_NUM;
2866 p_x_line_tbl(k).reserved_quantity2 := FND_API.G_MISS_NUM;
2867 p_x_line_tbl(k).fulfilled_quantity2 := FND_API.G_MISS_NUM;
2868 p_x_line_tbl(k).shipped_quantity2 := FND_API.G_MISS_NUM;
2869 p_x_line_tbl(k).shipping_quantity_uom2 := FND_API.G_MISS_CHAR;
2870
2871 --Customer Acceptance
2872 p_x_line_tbl(k).CONTINGENCY_ID := FND_API.G_MISS_NUM;
2873 p_x_line_tbl(k).REVREC_EVENT_CODE := FND_API.G_MISS_CHAR;
2874 p_x_line_tbl(k).REVREC_EXPIRATION_DAYS := FND_API.G_MISS_NUM;
2875 p_x_line_tbl(k).ACCEPTED_QUANTITY := FND_API.G_MISS_NUM;
2876 p_x_line_tbl(k).REVREC_COMMENTS := FND_API.G_MISS_CHAR;
2877 p_x_line_tbl(k).REVREC_SIGNATURE := FND_API.G_MISS_CHAR;
2878 p_x_line_tbl(k).REVREC_SIGNATURE_DATE := FND_API.G_MISS_DATE;
2879 p_x_line_tbl(k).ACCEPTED_BY := FND_API.G_MISS_NUM;
2880 p_x_line_tbl(k).REVREC_REFERENCE_DOCUMENT := FND_API.G_MISS_CHAR;
2881 p_x_line_tbl(k).REVREC_IMPLICIT_FLAG := FND_API.G_MISS_CHAR;
2882
2883 --key Transaction Dates Project
2884 p_x_line_tbl(k).order_firmed_date := FND_API.G_MISS_DATE ;
2885 p_x_line_tbl(k).actual_fulfillment_date := FND_API.G_MISS_DATE ;
2886 --end
2887
2888 -- Pack J catchweight
2889 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
2890 p_x_line_tbl(k).shipped_quantity2 := NULL;
2891 END IF;
2892 -- Pack J catchweight
2893 p_x_line_tbl(k).invoiced_quantity := FND_API.G_MISS_NUM;
2894 p_x_line_tbl(k).Auto_Selected_quantity := FND_API.G_MISS_NUM;
2895
2896 -- Scheduling attributes
2897
2898 -- If future date then copy it
2899 IF (p_x_line_tbl(k).Request_Date < sysdate) THEN
2900 p_x_line_tbl(k).Request_Date := FND_API.G_MISS_DATE;
2901 END IF;
2902
2903 IF (p_x_line_tbl(k).re_source_flag = 'Y') THEN
2904 p_x_line_tbl(k).ship_from_org_Id := FND_API.G_MISS_NUM;
2905 p_x_line_tbl(k).subinventory := FND_API.G_MISS_CHAR;
2906 END IF;
2907
2908
2909 p_x_line_tbl(k).Promise_Date := FND_API.G_MISS_DATE;
2910 p_x_line_tbl(k).Earliest_Acceptable_Date := FND_API.G_MISS_DATE;
2911 p_x_line_tbl(k).Latest_Acceptable_Date := FND_API.G_MISS_DATE;
2912 p_x_line_tbl(k).Schedule_Ship_Date := FND_API.G_MISS_DATE;
2913 p_x_line_tbl(k).Schedule_Arrival_date := FND_API.G_MISS_DATE;
2914 p_x_line_tbl(k).Actual_shipment_date := FND_API.G_MISS_DATE;
2915 p_x_line_tbl(k).Actual_arrival_date := FND_API.G_MISS_DATE;
2916 p_x_line_tbl(k).Fulfillment_date := FND_API.G_MISS_DATE;
2917
2918 p_x_line_tbl(k).delivery_lead_time := FND_API.G_MISS_NUM;
2919 p_x_line_tbl(k).schedule_status_code := FND_API.G_MISS_CHAR;
2920 p_x_line_tbl(k).visible_demand_flag := FND_API.G_MISS_CHAR;
2921 p_x_line_tbl(k).customer_trx_line_id := FND_API.G_MISS_NUM;
2922 p_x_line_tbl(k).Credit_Invoice_line_id := FND_API.G_MISS_NUM;
2923 p_x_line_tbl(k).First_Ack_Code := FND_API.G_MISS_CHAR;
2924 p_x_line_tbl(k).First_Ack_Date := FND_API.G_MISS_DATE;
2925 p_x_line_tbl(k).Last_Ack_Code := FND_API.G_MISS_CHAR;
2926 p_x_line_tbl(k).Last_Ack_Date := FND_API.G_MISS_DATE;
2927 p_x_line_tbl(k).Order_Source_Id := 2;
2928 p_x_line_tbl(k).Orig_Sys_shipment_Ref := FND_API.G_MISS_CHAR;
2929 p_x_line_tbl(k).Change_Sequence := FND_API.G_MISS_CHAR;
2930 p_x_line_tbl(k).Drop_Ship_Flag := FND_API.G_MISS_CHAR;
2931 p_x_line_tbl(k).Customer_Line_Number := FND_API.G_MISS_CHAR;
2932 p_x_line_tbl(k).Customer_Shipment_Number := FND_API.G_MISS_CHAR;
2933 p_x_line_tbl(k).Customer_Item_Net_Price := FND_API.G_MISS_NUM;
2934 p_x_line_tbl(k).Customer_Payment_Term_Id := FND_API.G_MISS_NUM;
2935 p_x_line_tbl(k).Planning_Priority := FND_API.G_MISS_NUM;
2936 p_x_line_tbl(k).Reference_Customer_Trx_line_Id := FND_API.G_MISS_NUM;
2937 p_x_line_tbl(k).Split_By := FND_API.G_MISS_CHAR;
2938 p_x_line_tbl(k).Model_Remnant_Flag := FND_API.G_MISS_CHAR;
2939
2940 -- Item substitution attributes.
2941
2942 p_x_line_tbl(k).Original_Inventory_Item_Id := FND_API.G_MISS_NUM;
2943 p_x_line_tbl(k).Original_item_identifier_Type := FND_API.G_MISS_CHAR;
2944 p_x_line_tbl(k).Original_ordered_item_id := FND_API.G_MISS_NUM;
2945 p_x_line_tbl(k).item_relationship_type := FND_API.G_MISS_NUM;
2946 p_x_line_tbl(k).Item_substitution_type_code := FND_API.G_MISS_CHAR;
2947 p_x_line_tbl(k).Late_Demand_Penalty_Factor := FND_API.G_MISS_NUM;
2948 p_x_line_tbl(k).Override_atp_date_code := FND_API.G_MISS_CHAR;
2949 p_x_line_tbl(k).Original_ordered_item := FND_API.G_MISS_CHAR;
2950 p_x_line_tbl(k).Firm_demand_flag := Null;
2951 p_x_line_tbl(k).Earliest_ship_date := Null;
2952
2953 -- Set attributes
2954 p_x_line_tbl(k).ship_set_id := FND_API.G_MISS_NUM;
2955 p_x_line_tbl(k).arrival_set_id := FND_API.G_MISS_NUM;
2956
2957 -- Clear Original System Ref Info
2958
2959 p_x_line_tbl(k).orig_sys_document_ref := FND_API.G_MISS_CHAR;
2960 p_x_line_tbl(k).orig_sys_line_ref := FND_API.G_MISS_CHAR;
2961
2962 -- Clear Service Reference Line ID
2963
2964 IF p_x_line_tbl(k).service_reference_type_code = 'ORDER' THEN
2965 p_x_line_tbl(k).service_reference_line_id := FND_API.G_MISS_NUM;
2966 END IF;
2967
2968 -- Clear Config related info if item type is STANDARD
2969
2970 IF l_temp_line_rec.item_type_code = 'STANDARD' THEN
2971 p_x_line_tbl(k).component_sequence_id := FND_API.G_MISS_NUM;
2972 p_x_line_tbl(k).component_code := FND_API.G_MISS_CHAR;
2973 -- p_x_line_tbl(k).component_number := FND_API.G_MISS_NUM;
2974 p_x_line_tbl(k).sort_order := FND_API.G_MISS_CHAR;
2975 p_x_line_tbl(k).config_display_sequence:= FND_API.G_MISS_NUM;
2976 END IF;
2977
2978 p_x_line_tbl(k).explosion_date := FND_API.G_MISS_DATE;
2979
2980 -- Clear shipping attributes
2981 p_x_line_tbl(k).over_ship_reason_code := FND_API.G_MISS_CHAR;
2982 p_x_line_tbl(k).over_ship_resolved_flag := FND_API.G_MISS_CHAR;
2983 p_x_line_tbl(k).shipping_instructions := FND_API.G_MISS_CHAR;
2984 p_x_line_tbl(k).packing_instructions := FND_API.G_MISS_CHAR;
2985 p_x_line_tbl(k).fulfillment_method_code := FND_API.G_MISS_CHAR;
2986 p_x_line_tbl(k).Shipping_quantity := FND_API.G_MISS_NUM;
2987 p_x_line_tbl(k).Shipping_quantity2 := FND_API.G_MISS_NUM; -- OPM 3482303
2988 p_x_line_tbl(k).Shipping_quantity_uom := FND_API.G_MISS_CHAR;
2989 p_x_line_tbl(k).Shipping_quantity_uom2 := FND_API.G_MISS_CHAR; -- OPM 3482303
2990 p_x_line_tbl(k).dep_plan_required_flag := FND_API.G_MISS_CHAR;
2991 p_x_line_tbl(k).Shippable_Flag := FND_API.G_MISS_CHAR;
2992
2993
2994 -- Service attributes
2995 p_x_line_tbl(k).Service_Number := FND_API.G_MISS_NUM;
2996
2997 -- Clear RLA related attributes
2998
2999 p_x_line_tbl(k).rla_schedule_type_code := FND_API.G_MISS_CHAR;
3000 p_x_line_tbl(k).veh_cus_item_cum_key_id := FND_API.G_MISS_NUM;
3001
3002 -- Tax related attributes.
3003
3004 p_x_line_tbl(k).tax_value := FND_API.G_MISS_NUM;
3005 p_x_line_tbl(k).tax_date := FND_API.G_MISS_DATE;
3006
3007 -- PROMOTIONS SEP/01 Clear price request code
3008 p_x_line_tbl(k).price_request_code := NULL;
3009
3010 -- If the line type or order type has changed tax related code will
3011 -- default tax code.
3012 -- But if it is a RETURN line don't default, 5404002 and 6449117
3013
3014 IF ( G_COPY_TO_DIFFERENT_ORDER_TYPE OR
3015 p_line_type <> l_temp_line_rec.line_type_id ) AND
3016 l_temp_line_rec.line_category_code <> 'RETURN' THEN
3017 oe_debug_pub.add( 'Redefaulting the Tax Code' ,1);
3018 p_x_line_tbl(k).tax_code := FND_API.G_MISS_CHAR;
3019 END IF;
3020
3021
3022
3023 -- Special handling if we are copying from a Return to a regular line
3024
3025 IF FND_API.to_Boolean(l_rma_to_reg) THEN
3026 -- Clear Reference Information.
3027 p_x_line_tbl(k).reference_line_id := FND_API.G_MISS_NUM;
3028 p_x_line_tbl(k).reference_type := FND_API.G_MISS_CHAR;
3029 p_x_line_tbl(k).reference_header_id := FND_API.G_MISS_NUM;
3030
3031 -- clear shipping information
3032 p_x_line_tbl(k).shipment_priority_code := FND_API.G_MISS_CHAR;
3033 p_x_line_tbl(k).shipping_method_code := FND_API.G_MISS_CHAR;
3034 p_x_line_tbl(k).freight_carrier_code := FND_API.G_MISS_CHAR;
3035 p_x_line_tbl(k).freight_terms_code := FND_API.G_MISS_CHAR;
3036 p_x_line_tbl(k).fob_point_code := FND_API.G_MISS_CHAR;
3037
3038 -- Clear Return Reason code
3039 p_x_line_tbl(k).return_reason_code := FND_API.G_MISS_CHAR;
3040
3041 -- Clear Line Category
3042 p_x_line_tbl(k).line_category_code := FND_API.G_MISS_CHAR;
3043
3044 -- Clear return descriptive information.
3045 p_x_line_tbl(k).return_context := FND_API.G_MISS_CHAR;
3046 p_x_line_tbl(k).return_attribute1 := FND_API.G_MISS_CHAR;
3047 p_x_line_tbl(k).return_attribute2 := FND_API.G_MISS_CHAR;
3048 p_x_line_tbl(k).return_attribute3 := FND_API.G_MISS_CHAR;
3049 p_x_line_tbl(k).return_attribute4 := FND_API.G_MISS_CHAR;
3050 p_x_line_tbl(k).return_attribute5 := FND_API.G_MISS_CHAR;
3051 p_x_line_tbl(k).return_attribute6 := FND_API.G_MISS_CHAR;
3052 p_x_line_tbl(k).return_attribute7 := FND_API.G_MISS_CHAR;
3053 p_x_line_tbl(k).return_attribute8 := FND_API.G_MISS_CHAR;
3054 p_x_line_tbl(k).return_attribute9 := FND_API.G_MISS_CHAR;
3055 p_x_line_tbl(k).return_attribute10 := FND_API.G_MISS_CHAR;
3056 p_x_line_tbl(k).return_attribute11 := FND_API.G_MISS_CHAR;
3057 p_x_line_tbl(k).return_attribute12 := FND_API.G_MISS_CHAR;
3058 p_x_line_tbl(k).return_attribute13 := FND_API.G_MISS_CHAR;
3059 p_x_line_tbl(k).return_attribute14 := FND_API.G_MISS_CHAR;
3060 p_x_line_tbl(k).return_attribute15 := FND_API.G_MISS_CHAR;
3061 p_x_line_tbl(k).ship_tolerance_above := FND_API.G_MISS_NUM;
3062 p_x_line_tbl(k).ship_tolerance_below := FND_API.G_MISS_NUM;
3063 END IF;
3064
3065
3066 IF l_debug_level > 0 THEN
3067 oe_debug_pub.add( 'AK: BEFORE REG_TO RETURN' , 3 ) ;
3068 END IF;
3069 -- Special Handling if we are copying to a Return Line.
3070 IF FND_API.to_Boolean(l_reg_to_rma) THEN
3071
3072 -- Set the global
3073 G_REGULAR_TO_RMA := TRUE;
3074 -- Process order will fill all remaining columns for the line,
3075 -- when it is copied from reg to return.
3076
3077 p_x_line_tbl(k) := OE_Order_PUB.G_MISS_LINE_REC;
3078 p_x_line_tbl(k).line_type_id :=
3079 nvl(p_line_type,l_temp_line_rec.line_type_id);
3080 p_x_line_tbl(k).return_reason_code := p_return_reason_code;
3081
3082
3083 -- Set return attributes to order.
3084
3085 p_x_line_tbl(k).return_context := 'ORDER';
3086 p_x_line_tbl(k).return_attribute1 := l_temp_line_rec.header_id;
3087 p_x_line_tbl(k).return_attribute2 := l_temp_line_rec.line_id;
3088 p_x_line_tbl(k).cust_po_number := l_temp_line_rec.cust_po_number ;
3089 /* Added the above line to fix the bug 12711919 , 12916309 */
3090
3091
3092
3093 -- Copy Reason for creating a Return.
3094 p_x_line_tbl(k).return_reason_code := p_return_reason_code;
3095
3096 -- Set Reference Information.
3097 p_x_line_tbl(k).reference_line_id := l_temp_line_rec.line_id;
3098 p_x_line_tbl(k).reference_type := 'ORDER';
3099 p_x_line_tbl(k).reference_header_id := l_temp_line_rec.header_id;
3100
3101 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
3102 IF p_reason_code IS NOT NULL THEN
3103 p_x_line_tbl(k).change_reason := p_reason_code;
3104 END IF;
3105
3106 IF p_comments IS NOT NULL THEN
3107 p_x_line_tbl(k).change_comments := p_comments;
3108 END IF;
3109 END IF;
3110
3111 END IF;
3112
3113
3114 -- Clear Descriptive flex if it isn't being copied
3115
3116 IF NOT (FND_API.to_boolean(p_line_descflex)) THEN
3117
3118 p_x_line_tbl(k).context := FND_API.G_MISS_CHAR;
3119 p_x_line_tbl(k).attribute1 := FND_API.G_MISS_CHAR;
3120 p_x_line_tbl(k).attribute2 := FND_API.G_MISS_CHAR;
3121 p_x_line_tbl(k).attribute3 := FND_API.G_MISS_CHAR;
3122 p_x_line_tbl(k).attribute4 := FND_API.G_MISS_CHAR;
3123 p_x_line_tbl(k).attribute5 := FND_API.G_MISS_CHAR;
3124 p_x_line_tbl(k).attribute6 := FND_API.G_MISS_CHAR;
3125 p_x_line_tbl(k).attribute7 := FND_API.G_MISS_CHAR;
3126 p_x_line_tbl(k).attribute8 := FND_API.G_MISS_CHAR;
3127 p_x_line_tbl(k).attribute9 := FND_API.G_MISS_CHAR;
3128 p_x_line_tbl(k).attribute10 := FND_API.G_MISS_CHAR;
3129 p_x_line_tbl(k).attribute11 := FND_API.G_MISS_CHAR;
3130 p_x_line_tbl(k).attribute12 := FND_API.G_MISS_CHAR;
3131 p_x_line_tbl(k).attribute13 := FND_API.G_MISS_CHAR;
3132 p_x_line_tbl(k).attribute14 := FND_API.G_MISS_CHAR;
3133 p_x_line_tbl(k).attribute15 := FND_API.G_MISS_CHAR;
3134 p_x_line_tbl(k).attribute16 := FND_API.G_MISS_CHAR; -- For bug 2184255
3135 p_x_line_tbl(k).attribute17 := FND_API.G_MISS_CHAR;
3136 p_x_line_tbl(k).attribute18 := FND_API.G_MISS_CHAR;
3137 p_x_line_tbl(k).attribute19 := FND_API.G_MISS_CHAR;
3138 p_x_line_tbl(k).attribute20 := FND_API.G_MISS_CHAR;
3139
3140 p_x_line_tbl(k).global_attribute_category := FND_API.G_MISS_CHAR;
3141 p_x_line_tbl(k).global_attribute1 := FND_API.G_MISS_CHAR;
3142 p_x_line_tbl(k).global_attribute2 := FND_API.G_MISS_CHAR;
3143 p_x_line_tbl(k).global_attribute3 := FND_API.G_MISS_CHAR;
3144 p_x_line_tbl(k).global_attribute4 := FND_API.G_MISS_CHAR;
3145 p_x_line_tbl(k).global_attribute5 := FND_API.G_MISS_CHAR;
3146 p_x_line_tbl(k).global_attribute6 := FND_API.G_MISS_CHAR;
3147 p_x_line_tbl(k).global_attribute7 := FND_API.G_MISS_CHAR;
3148 p_x_line_tbl(k).global_attribute8 := FND_API.G_MISS_CHAR;
3149 p_x_line_tbl(k).global_attribute9 := FND_API.G_MISS_CHAR;
3150 p_x_line_tbl(k).global_attribute10 := FND_API.G_MISS_CHAR;
3151 p_x_line_tbl(k).global_attribute11 := FND_API.G_MISS_CHAR;
3152 p_x_line_tbl(k).global_attribute12 := FND_API.G_MISS_CHAR;
3153 p_x_line_tbl(k).global_attribute13 := FND_API.G_MISS_CHAR;
3154 p_x_line_tbl(k).global_attribute14 := FND_API.G_MISS_CHAR;
3155 p_x_line_tbl(k).global_attribute15 := FND_API.G_MISS_CHAR;
3156 p_x_line_tbl(k).global_attribute16 := FND_API.G_MISS_CHAR;
3157 p_x_line_tbl(k).global_attribute17 := FND_API.G_MISS_CHAR;
3158 p_x_line_tbl(k).global_attribute18 := FND_API.G_MISS_CHAR;
3159 p_x_line_tbl(k).global_attribute19 := FND_API.G_MISS_CHAR;
3160 p_x_line_tbl(k).global_attribute20 := FND_API.G_MISS_CHAR;
3161
3162 p_x_line_tbl(k).industry_context := FND_API.G_MISS_CHAR;
3163 p_x_line_tbl(k).industry_attribute1 := FND_API.G_MISS_CHAR;
3164 p_x_line_tbl(k).industry_attribute2 := FND_API.G_MISS_CHAR;
3165 p_x_line_tbl(k).industry_attribute3 := FND_API.G_MISS_CHAR;
3166 p_x_line_tbl(k).industry_attribute4 := FND_API.G_MISS_CHAR;
3167 p_x_line_tbl(k).industry_attribute5 := FND_API.G_MISS_CHAR;
3168 p_x_line_tbl(k).industry_attribute6 := FND_API.G_MISS_CHAR;
3169 p_x_line_tbl(k).industry_attribute7 := FND_API.G_MISS_CHAR;
3170 p_x_line_tbl(k).industry_attribute8 := FND_API.G_MISS_CHAR;
3171 p_x_line_tbl(k).industry_attribute9 := FND_API.G_MISS_CHAR;
3172 p_x_line_tbl(k).industry_attribute10 := FND_API.G_MISS_CHAR;
3173 --Added for bug 9844952
3174 p_x_line_tbl(k).industry_attribute11 := FND_API.G_MISS_CHAR;
3175 p_x_line_tbl(k).industry_attribute12 := FND_API.G_MISS_CHAR;
3176 p_x_line_tbl(k).industry_attribute13 := FND_API.G_MISS_CHAR;
3177 p_x_line_tbl(k).industry_attribute14 := FND_API.G_MISS_CHAR;
3178 p_x_line_tbl(k).industry_attribute15 := FND_API.G_MISS_CHAR;
3179 p_x_line_tbl(k).industry_attribute16 := FND_API.G_MISS_CHAR;
3180 p_x_line_tbl(k).industry_attribute17 := FND_API.G_MISS_CHAR;
3181 p_x_line_tbl(k).industry_attribute18 := FND_API.G_MISS_CHAR;
3182 p_x_line_tbl(k).industry_attribute19 := FND_API.G_MISS_CHAR;
3183 p_x_line_tbl(k).industry_attribute20 := FND_API.G_MISS_CHAR;
3184 p_x_line_tbl(k).industry_attribute21 := FND_API.G_MISS_CHAR;
3185 p_x_line_tbl(k).industry_attribute22 := FND_API.G_MISS_CHAR;
3186 p_x_line_tbl(k).industry_attribute23 := FND_API.G_MISS_CHAR;
3187 p_x_line_tbl(k).industry_attribute24 := FND_API.G_MISS_CHAR;
3188 p_x_line_tbl(k).industry_attribute25 := FND_API.G_MISS_CHAR;
3189 p_x_line_tbl(k).industry_attribute26 := FND_API.G_MISS_CHAR;
3190 p_x_line_tbl(k).industry_attribute27 := FND_API.G_MISS_CHAR;
3191 p_x_line_tbl(k).industry_attribute28 := FND_API.G_MISS_CHAR;
3192 p_x_line_tbl(k).industry_attribute29 := FND_API.G_MISS_CHAR;
3193 p_x_line_tbl(k).industry_attribute30 := FND_API.G_MISS_CHAR;
3194 --End changes for bug 9844952
3195 p_x_line_tbl(k).tp_context := FND_API.G_MISS_CHAR;
3196 p_x_line_tbl(k).tp_attribute1 := FND_API.G_MISS_CHAR;
3197 p_x_line_tbl(k).tp_attribute2 := FND_API.G_MISS_CHAR;
3198 p_x_line_tbl(k).tp_attribute3 := FND_API.G_MISS_CHAR;
3199 p_x_line_tbl(k).tp_attribute4 := FND_API.G_MISS_CHAR;
3200 p_x_line_tbl(k).tp_attribute5 := FND_API.G_MISS_CHAR;
3201 p_x_line_tbl(k).tp_attribute6 := FND_API.G_MISS_CHAR;
3202 p_x_line_tbl(k).tp_attribute7 := FND_API.G_MISS_CHAR;
3203 p_x_line_tbl(k).tp_attribute8 := FND_API.G_MISS_CHAR;
3204 p_x_line_tbl(k).tp_attribute9 := FND_API.G_MISS_CHAR;
3205 p_x_line_tbl(k).tp_attribute10 := FND_API.G_MISS_CHAR;
3206 p_x_line_tbl(k).tp_attribute11 := FND_API.G_MISS_CHAR;
3207 p_x_line_tbl(k).tp_attribute12 := FND_API.G_MISS_CHAR;
3208 p_x_line_tbl(k).tp_attribute13 := FND_API.G_MISS_CHAR;
3209 p_x_line_tbl(k).tp_attribute14 := FND_API.G_MISS_CHAR;
3210 p_x_line_tbl(k).tp_attribute15 := FND_API.G_MISS_CHAR;
3211
3212 END IF; -- We are not copying descflex
3213
3214 -- If users have implementated the Hook API OE_COPY_UTIL_EXT.Copy_Line_DFF
3215
3216 IF CALL_DFF_COPY_EXTN_API(l_temp_line_rec.org_id) AND
3217 FND_API.to_boolean(p_line_descflex) AND
3218 FND_API.to_Boolean(l_reg_to_rma)
3219 THEN
3220 IF l_debug_level > 0 THEN
3221 oe_debug_pub.add('Copying DFF from REF Line '||
3222 l_temp_line_rec.context) ;
3223 END IF;
3224 -- Since we have cleared line record, we need to get back the
3225 -- values from reference line record.
3226 copy_line_dff_from_ref
3227 (p_ref_line_rec => l_temp_line_rec,
3228 p_x_line_rec => p_x_line_tbl(k));
3229
3230 END IF;
3231
3232
3233 -- Set calculate price falg to 'N' when repricing is not required.
3234
3235 IF p_line_price_mode = G_CPY_ORIG_PRICE THEN
3236
3237 p_x_line_tbl(k).calculate_price_flag := 'N';
3238
3239 -- Set pricing date if we are re-pricing and a date is provided.
3240 ELSIF (p_line_price_mode = G_CPY_REPRICE) THEN
3241 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
3242 p_x_line_tbl(k).original_list_price := NULL;
3243 END IF;
3244 IF (p_line_price_date IS NOT NULL) THEN
3245 p_x_line_tbl(k).pricing_date := p_line_price_date;
3246 ELSE --else we re-price based on a date that Process Order defaults
3247 p_x_line_tbl(k).pricing_date := FND_API.G_MISS_DATE;
3248 END IF;
3249
3250 /* Added the following line to fix the bug 1812860 */
3251 p_x_line_tbl(k).calculate_price_flag := 'Y';
3252 /* Added the following condition to fix the bug 2107810 */
3253 ELSIF (p_line_price_mode = G_CPY_REPRICE_PARTIAL) THEN
3254 p_x_line_tbl(k).calculate_price_flag := 'P';
3255 END IF;
3256
3257 -- Set operation
3258 p_x_line_tbl(k).operation := OE_GLOBALS.G_OPR_CREATE;
3259
3260 -- Set source Information
3261 p_x_line_tbl(k).source_document_type_id := 2;
3262 p_x_line_tbl(k).source_document_id := l_temp_line_rec.header_id;
3263 p_x_line_tbl(k).source_document_Line_id := l_temp_line_rec.line_id;
3264
3265 -- Added for bug 3426181 (FP:3442246)
3266 -- Initialize the source_type_code to G_MISS_CHAR so that it will get
3267 -- defaulted again
3268 IF FND_API.to_Boolean(l_rma_to_reg) THEN
3269 p_x_line_tbl(k).source_type_code := FND_API.G_MISS_CHAR;
3270 END IF;
3271
3272 -- Added for ER 2351654
3273 IF p_default_null_values = FND_API.G_TRUE THEN
3274 Clear_Missing_Attributes(p_x_line_tbl(k));
3275 END IF;
3276 END;
3277
3278 -- Added the following code to support a User Hook to copy DFF at
3279 -- line level.
3280 IF l_debug_level > 0 THEN
3281 oe_debug_pub.add('The Operation is '||l_operation) ;
3282 END IF;
3283
3284 IF CALL_DFF_COPY_EXTN_API(l_temp_line_rec.org_id) THEN
3285
3286 OE_COPY_UTIL_EXT.Copy_Line_DFF(
3287 p_copy_rec => p_copy_rec,
3288 p_operation => l_operation,
3289 p_ref_line_rec => l_temp_line_rec,
3290 p_copy_line_rec => p_x_line_tbl(k));
3291
3292 IF l_debug_level > 0 THEN
3293 oe_debug_pub.add('After COPY Line DFF '|| p_x_line_tbl(k).context) ;
3294 END IF;
3295 END IF;
3296
3297 k := p_x_line_tbl.NEXT(k);
3298 END LOOP;
3299
3300 -- Added following code to retain line set info for split lines.
3301 IF l_line_set_tbl.COUNT > 0 THEN
3302 FOR k IN 1..l_line_set_tbl.COUNT LOOP
3303 IF l_line_set_tbl(k).set_count > 1 THEN
3304 create_line_set(
3305 l_line_set_tbl(k).old_line_id,
3306 l_line_set_tbl(k).line_id,
3307 l_line_set_tbl(k).line_set_id,
3308 l_line_set_tbl(k).header_id,
3309 l_line_set_tbl(k).line_type_id
3310 );
3311 END IF;
3312 END LOOP;
3313 END IF;
3314
3315 END IF; -- Table has rows;
3316
3317 IF l_debug_level > 0 THEN
3318 oe_debug_pub.add( 'EXITING OE_ORDER_COPY_UTIL.INIT_LINES_NEW' , 1 ) ;
3319 END IF;
3320
3321
3322
3323 END Init_Lines_New;
3324
3325 Procedure Load_and_Init_Line_Scredits
3326 (p_line_tbl IN OE_Order_PUB.Line_Tbl_type
3327 ,p_version_number IN NUMBER
3328 ,p_phase_change_flag IN VARCHAR2
3329 ,x_Line_Scredit_Tbl IN OUT NOCOPY OE_Order_PUB.Line_Scredit_Tbl_Type )
3330 IS
3331
3332 l_line_id NUMBER;
3333 I NUMBER := 1;
3334 l_sub_scredit_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
3335 l_api_name CONSTANT VARCHAR(30) := 'Load_and_Init_Line_Scredits';
3336 K NUMBER; -- Used as loop index.
3337 --
3338 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3339 --
3340 BEGIN
3341
3342 IF l_debug_level > 0 THEN
3343 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.LOAD_AND_INIT_LINE_SCREDITS' , 1 ) ;
3344 END IF;
3345
3346 -- Load Line Sales Credits
3347
3348 IF p_line_tbl.COUNT > 0 THEN
3349
3350 -- For every line in the line table
3351 k := p_line_tbl.FIRST;
3352 WHILE k IS NOT NULL LOOP
3353 BEGIN
3354
3355 l_line_id := p_line_tbl(k).line_id;
3356 -- Load line level Sales Credits into temporary table
3357 BEGIN
3358 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
3359
3360 OE_Version_History_UTIL.Query_Rows(
3361 p_sales_credit_id => NULL
3362 ,p_line_id => l_line_id
3363 ,p_Header_id => NULL
3364 ,p_version_number => p_version_number
3365 ,p_phase_change_flag => p_phase_change_flag
3366 ,x_line_scredit_tbl => l_sub_scredit_tbl);
3367 ELSE
3368 OE_Line_Scredit_Util.Query_Rows(p_line_id => l_line_id
3369 ,x_line_scredit_tbl => l_sub_scredit_tbl);
3370 END IF;
3371
3372 EXCEPTION
3373
3374 WHEN NO_DATA_FOUND THEN
3375 NULL;
3376
3377 END;
3378
3379 -- Init Table for Copying
3380 IF l_sub_scredit_tbl.COUNT > 0 THEN
3381
3382 -- Load rows from Temp table into Sales Credit table
3383 FOR j IN l_sub_scredit_tbl.FIRST .. l_sub_scredit_tbl.LAST LOOP
3384
3385 x_Line_scredit_tbl(I) := l_sub_scredit_tbl(j);
3386
3387 -- Init columns
3388 x_line_scredit_tbl(I).operation := OE_GLOBALS.G_OPR_CREATE;
3389 x_Line_scredit_tbl(I).line_index := k;
3390 x_Line_scredit_tbl(I).header_id := FND_API.G_MISS_NUM;
3391 x_Line_scredit_tbl(I).line_id := FND_API.G_MISS_NUM;
3392 x_Line_scredit_tbl(I).sales_credit_id := FND_API.G_MISS_NUM;
3393 x_Line_scredit_tbl(I).orig_sys_credit_ref := FND_API.G_MISS_CHAR;--bug 13980051
3394 I := I + 1;
3395 END LOOP;
3396
3397 -- Clear Sub Table
3398 l_sub_scredit_tbl.DELETE;
3399
3400
3401 END IF; -- Sub table has rows
3402 END;
3403
3404 k := p_line_tbl.NEXT(k);
3405 END LOOP;
3406
3407 END IF; -- Line Table has rows
3408
3409 IF l_debug_level > 0 THEN
3410 oe_debug_pub.add( 'LINE SC IS '||TO_CHAR ( X_LINE_SCREDIT_TBL.COUNT ) , 2 ) ;
3411 END IF;
3412
3413 IF l_debug_level > 0 THEN
3414 oe_debug_pub.add( 'EXITING OE_ORDER_COPY_UTIL.LOAD_AND_INIT_LINE_SCREDITS' , 1 ) ;
3415 END IF;
3416
3417
3418 EXCEPTION
3419
3420 WHEN OTHERS THEN
3421
3422 IF l_debug_level > 0 THEN
3423 oe_debug_pub.add( 'IN OTHERS' , 1 ) ;
3424 END IF;
3425
3426 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3427 THEN
3428 OE_MSG_PUB.Add_Exc_Msg
3429 ( G_PKG_NAME
3430 , l_api_name
3431 );
3432 END IF;
3433
3434 OE_DEBUG_PUB.DumpDebug;
3435
3436 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3437
3438 END Load_and_Init_Line_Scredits;
3439
3440 -- Added for multiple payments
3441 PROCEDURE Load_and_Init_Line_Payments
3442 (p_line_tbl IN OE_Order_PUB.Line_Tbl_type
3443 ,p_line_type IN NUMBER
3444 ,x_Line_Payment_tbl IN OUT NOCOPY OE_Order_PUB.Line_Payment_Tbl_Type)
3445 IS
3446
3447 l_sub_payment_tbl OE_Order_PUB.Line_payment_Tbl_Type;
3448 l_line_id NUMBER;
3449 k NUMBER;
3450 I NUMBER := 1;
3451 l_line_category VARCHAR2(30);
3452 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3453
3454 --R12 CC Encryption
3455 l_invoice_to_cust_id NUMBER;
3456 l_invoice_to_org_id NUMBER;
3457 L_trxn_extension_id NUMBER;
3458 l_return_status VARCHAR2(30);
3459 l_msg_count NUMBER;
3460 l_msg_data VARCHAR2(2000);
3461 --R12 CC Encryption
3462
3463 BEGIN
3464
3465 IF l_debug_level > 0 THEN
3466 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.Load_and_Init_Line_Payments.' , 1 ) ;
3467 END IF;
3468
3469 IF p_line_tbl.COUNT > 0 THEN
3470 -- For every line in the line table
3471 k := p_line_tbl.FIRST;
3472 WHILE k IS NOT NULL LOOP
3473
3474 IF p_line_type IS NOT NULL THEN
3475 l_line_category := Get_Line_Category(p_line_type);
3476 ELSE
3477 l_line_category := Get_Line_Category(p_line_tbl(k).line_type_id);
3478 END IF;
3479
3480 IF l_debug_level > 0 THEN
3481 oe_debug_pub.add( ' Destination line type is: '||l_line_category, 3 ) ;
3482 END IF;
3483
3484 IF l_line_category = 'RETURN' THEN
3485 goto Next_Line;
3486 END IF;
3487
3488 BEGIN
3489 l_line_id := p_line_tbl(k).line_id;
3490 -- Load line level payments
3491 BEGIN
3492 OE_Line_payment_Util.Query_Rows
3493 (p_line_id => l_line_id
3494 ,p_header_id => p_line_tbl(k).header_id
3495 ,x_line_payment_tbl => l_sub_payment_tbl);
3496 EXCEPTION
3497 WHEN NO_DATA_FOUND THEN
3498 NULL;
3499 END;
3500
3501 IF l_debug_level > 0 THEN
3502 oe_debug_pub.add( 'After query_rows the count is: '||l_sub_payment_tbl.COUNT, 3 ) ;
3503 END IF;
3504
3505 -- Init Table for Copying
3506 IF l_sub_payment_tbl.COUNT > 0 THEN
3507 -- Load rows into payment table
3508 FOR J IN l_sub_payment_tbl.FIRST .. l_sub_payment_tbl.LAST LOOP
3509 --bug5741708
3510 IF l_sub_payment_tbl(j).payment_type_code = 'COMMITMENT' THEN
3511 goto Next_Payment;
3512 END IF;
3513 x_Line_payment_tbl(I) := l_sub_payment_tbl(j);
3514 -- Init columns
3515 x_line_payment_tbl(I).operation := OE_GLOBALS.G_OPR_CREATE;
3516 x_Line_payment_tbl(I).header_id := FND_API.G_MISS_NUM;
3517 x_Line_payment_tbl(I).line_id := FND_API.G_MISS_NUM;
3518 x_Line_payment_tbl(I).line_index := k;
3519 --bug5741708 setting the payment_number to G_MISS_NUM since we aren't copying commitments
3520 x_Line_payment_tbl(I).payment_number := FND_API.G_MISS_NUM;
3521 x_Line_payment_tbl(I).prepaid_amount := FND_API.G_MISS_NUM;
3522 x_Line_payment_tbl(I).payment_amount := FND_API.G_MISS_NUM;
3523 x_Line_payment_tbl(I).commitment_applied_amount:= FND_API.G_MISS_NUM;
3524 x_Line_payment_tbl(I).commitment_interfaced_amount := FND_API.G_MISS_NUM;
3525 x_Line_payment_tbl(I).credit_card_approval_code := FND_API.G_MISS_CHAR;
3526 x_Line_payment_tbl(I).payment_set_id := FND_API.G_MISS_NUM;
3527 --R12 CC Encryption
3528 /*IF x_line_payment_tbl(k).payment_type_code
3529 IN ('CREDIT_CARD','ACH','DIRECT_DEBIT','CASH','CHECK','WIRE_TRANSFER') THEN
3530
3531 Select oit.customer_id, ooh.invoice_to_org_id
3532 Into l_invoice_to_cust_id, l_invoice_to_org_id
3533 From oe_order_lines_all ooh,Oe_invoice_to_orgs_v oit
3534 Where ooh.line_id = x_line_payment_tbl(I).line_id
3535 And oit.organization_id = ooh.invoice_to_org_id;
3536
3537 -- need to create a new trxn extension id and populate
3538 -- x_line_payments_tbl(I).trxn_extension_id with the new id before
3539 -- calling process order api to create new order.
3540
3541 L_trxn_extension_id := x_line_payment_tbl(I).trxn_extension_id;
3542
3543 OE_PAYMENT_TRXN_UTIL.Create_Payment_Trxn(
3544 P_header_id => x_line_payment_tbl(I).header_id,
3545 P_line_id => x_line_payment_tbl(I).line_id,
3546 P_cust_id => l_invoice_to_cust_id,
3547 P_site_use_id => l_invoice_to_org_id,
3548 P_payment_type_code => x_line_payment_tbl(I).payment_type_code,
3549 P_Payment_trx_id => x_line_payment_tbl(I).payment_trx_id,
3550 p_payment_number => x_line_payment_tbl(I).payment_number,
3551 P_card_number => x_line_payment_tbl(I).credit_card_number,
3552 p_card_code => x_line_payment_tbl(I).credit_card_code,
3553 P_card_holder_name => x_line_payment_tbl(I).credit_card_holder_name,
3554 P_exp_date => x_line_payment_tbl(I).credit_card_expiration_date,
3555 P_check_number => x_line_payment_tbl(I).check_number,
3556 P_instrument_security_code=> x_line_payment_tbl(I).instrument_security_code,
3557 P_X_trxn_extension_id => l_trxn_extension_id,
3558 X_return_status => l_return_status,
3559 X_msg_count => l_msg_count,
3560 X_msg_data => l_msg_data);
3561
3562 x_line_payment_tbl(I).credit_card_number := FND_API.G_MISS_CHAR;
3563 x_line_payment_tbl(I).credit_card_code := FND_API.G_MISS_CHAR;
3564 x_line_payment_tbl(I).credit_card_holder_name := FND_API.G_MISS_CHAR;
3565 x_line_payment_tbl(I).credit_card_expiration_date := FND_API.G_MISS_DATE;
3566 x_line_payment_tbl(I).check_number := FND_API.G_MISS_CHAR;
3567 x_line_payment_tbl(I).instrument_security_code := FND_API.G_MISS_CHAR;
3568 x_line_payment_tbl(I).trxn_extension_id := l_trxn_extension_id;
3569 END IF;*/
3570 --R12 CC Encryption
3571
3572 I := I + 1;
3573 <<Next_Payment>>
3574 null;
3575 END LOOP;
3576 -- Clear Sub Table
3577 l_sub_payment_tbl.DELETE;
3578 END IF; -- Sub table has rows
3579 END;
3580
3581 <<Next_Line>>
3582 k := p_line_tbl.NEXT(k);
3583 END LOOP;
3584
3585 END IF; -- Line Table has rows
3586
3587 IF l_debug_level > 0 THEN
3588 oe_debug_pub.add( 'Exiting OE_ORDER_COPY_UTIL.Load_and_Init_Line_Payments.' , 1 ) ;
3589 END IF;
3590
3591 END Load_and_Init_Line_Payments;
3592
3593 /* Added the following procedure to fix the bug 1923460 */
3594
3595 Procedure delete_config(
3596 p_top_model_tbl top_model_tbl_type)
3597 IS
3598 k NUMBER; -- Used as Index for loop.
3599 l_return_status VARCHAR2(100);
3600 --
3601 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3602 --
3603 BEGIN
3604
3605 IF l_debug_level > 0 THEN
3606 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.DELETE_CONFIG ' , 1 ) ;
3607 END IF;
3608
3609 k := p_top_model_tbl.FIRST;
3610
3611 WHILE K IS NOT NULL LOOP
3612 oe_config_pvt.delete_config(
3613 p_top_model_tbl(k).config_header_id,
3614 p_top_model_tbl(k).config_rev_nbr,
3615 l_return_status );
3616 k := p_top_model_tbl.NEXT(k);
3617 END LOOP;
3618 IF l_debug_level > 0 THEN
3619 oe_debug_pub.add( 'EXITING OE_ORDER_COPY_UTIL.DELETE_CONFIG' , 1 ) ;
3620 END IF;
3621 EXCEPTION
3622
3623 WHEN OTHERS THEN
3624 NULL;
3625
3626 END delete_config;
3627
3628 --To insert the transaction extension id in the oe_payments table
3629 --after the credit card details have been stored in the payments tables.
3630 --R12 CC Encryption
3631 /*Procedure Create_Payment(p_header_id IN NUMBER) IS
3632 BEGIN
3633 INSERT INTO oe_payments
3634 (trxn_extension_id,
3635 payment_level_code,
3636 header_id,
3637 line_id,
3638 payment_type_code,
3639 creation_date,
3640 created_by,
3641 last_update_date,
3642 last_updated_by
3643 )
3644 VALUES
3645 (g_trxn_extension_id,
3646 'ORDER',
3647 p_header_id,
3648 null, -- line id
3649 g_payment_type_code,
3650 sysdate,
3651 1,
3652 sysdate,
3653 1);
3654 END Create_Payment;*/
3655 --R12 CC Encryption
3656
3657 -- Added as part of Inline Code Documentation Drive.
3658 ------------------------------------------------------------------------------------
3659 -- Procedure Name : Copy_Order
3660 -- Input Params : p_copy_rec : Copy Control record.
3661 -- p_hdr_id_tbl : Table of Header Ids to be processed.
3662 -- p_line_id_tbl : Table of Line Ids to be processed.
3663 -- Output Params : x_header_id : New Header ID of the Copied Order.
3664 -- x_return_status: Return status of the operation.
3665 -- x_msg_count : Count of messages returned.
3666 -- x_msg_data : Message Data returned.
3667 -- Description : This is the main procedure for Copying Orders. It takes
3668 -- header_id table, ine_id table, and a copy record for control
3669 -- variables as input and provides the new header_id output.
3670 -- It is called from OE_ORDER_COPY_MAIN.Copy_Main (OEORDCPY.pld).
3671 -- It internally makes a PO API Call to create the new order/lines.
3672 -- This procedure is used in this package and in this flow only
3673 -- and not used anywhere else in any other flow in the product.
3674 ------------------------------------------------------------------------------------
3675
3676 -- For Bug 1935675
3677 -- The code has been modified so as to deal with the partial copy case. Prior
3678 -- to this enhacement the Copy_Order procedure would return a complete success
3679 -- or a total failure, the partial case wasnot being dealt with.
3680
3681 -- Modification Done :
3682 -- Code has been modified after the call to the Process Order API, we would
3683 -- query the database to verify if a header has been created or not( in the
3684 -- case of copying an order ). If created, would indicate a case of partial
3685 -- success even if all the lines fail to get copied.
3686 -- Two variables l_all_lines_copied and l_all_lines_failed have been used to
3687 -- capture the three cases :
3688 -- 1. Complete Success in creating a new Order or all the selected lines
3689 -- appended successfully to an existing order
3690 -- 2. Failure in adding the lines
3691 -- 3. Partial Success case.
3692
3693 -- The flag l_copy_partial_or_full is used to capture patrial copy and
3694 -- the return status of the copy_order procedure depends on the value of
3695 -- this flag.
3696
3697 -- The issue that has been addressed in Bug 1923460 has been taken care off.
3698 -- end of bug 1935675
3699
3700
3701 PROCEDURE Copy_Order
3702 ( p_copy_rec IN copy_rec_type
3703 ,p_hdr_id_tbl IN OE_GLOBALS.Selected_Record_Tbl
3704 ,p_line_id_tbl IN OE_GLOBALS.Selected_Record_Tbl
3705 ,x_header_id OUT NOCOPY NUMBER
3706 ,x_return_status OUT NOCOPY VARCHAR2
3707 ,x_msg_count OUT NOCOPY NUMBER
3708 ,x_msg_data OUT NOCOPY VARCHAR2)
3709
3710 IS
3711 l_api_version_number CONSTANT NUMBER := 1.0;
3712 l_api_name CONSTANT VARCHAR(30) := 'Copy_Order';
3713
3714 l_header_id NUMBER;
3715 l_to_header_id NUMBER;
3716 l_line_header_id NUMBER;
3717 l_line_id NUMBER;
3718 l_destination_header_id NUMBER;
3719 l_get_type_from_line VARCHAR2(01) := FND_API.G_FALSE;
3720 l_hdr_type_id NUMBER;
3721 l_order_number NUMBER;
3722 l_Order_version NUMBER;
3723 l NUMBER; -- Used as loop index.
3724 k NUMBER; -- Used as loop index.
3725 j NUMBER; -- Used as loop index.
3726
3727 l_header_rec OE_Order_PUB.Header_Rec_Type;
3728 l_control_rec OE_GLOBALS.Control_Rec_Type;
3729 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
3730 /* Added the following line to fix the bug 1923460 */
3731 l_top_model_tbl top_model_tbl_type;
3732 l_line_final_tbl OE_Order_PUB.Line_Tbl_Type;
3733 l_header_out_rec OE_Order_PUB.Header_Rec_Type;
3734 l_line_out_tbl OE_Order_PUB.Line_Tbl_Type;
3735 l_line_rec OE_Order_PUB.Line_Rec_Type;
3736 l_header_adj_tbl OE_Order_PUB.Header_Adj_Tbl_Type;
3737 l_header_price_att_tbl OE_Order_PUB.Header_Price_Att_Tbl_Type;
3738 l_header_Adj_att_tbl OE_Order_PUB.Header_Adj_Att_Tbl_Type;
3739 l_header_adj_assoc_tbl OE_Order_PUB.Header_Adj_Assoc_Tbl_Type;
3740 l_header_adj_out_tbl OE_Order_PUB.Header_Adj_Tbl_Type;
3741 l_header_scredit_tbl OE_Order_PUB.Header_Scredit_Tbl_Type;
3742 l_header_scredit_out_tbl OE_Order_PUB.Header_Scredit_Tbl_Type;
3743 l_line_adj_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
3744 l_line_price_att_tbl OE_Order_PUB.Line_Price_Att_Tbl_Type;
3745 l_line_Adj_att_tbl OE_Order_PUB.Line_Adj_Att_Tbl_Type;
3746 l_line_adj_assoc_tbl OE_Order_PUB.Line_Adj_Assoc_Tbl_Type;
3747 l_line_adj_out_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
3748 l_line_scredit_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
3749 l_line_scredit_out_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
3750 l_lot_serial_out_tbl OE_Order_PUB.Lot_Serial_Tbl_Type;
3751 l_action_request_tbl OE_Order_PUB.Request_Tbl_Type;
3752 l_action_request_out_tbl OE_Order_PUB.Request_Tbl_Type;
3753
3754 l_header_exists BOOLEAN; -- variables added for bug 1935675
3755 l_copy_partial_or_full BOOLEAN := FALSE;
3756 l_all_lines_copied BOOLEAN;
3757 l_all_lines_failed BOOLEAN;
3758 l_delete_config BOOLEAN;
3759 l_dummy_header NUMBER; -- end 1935675
3760
3761 l_top_model_index NUMBER;
3762 l_return_status VARCHAR2(30);
3763
3764 --
3765 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3766 --
3767 l_copy_header_id NUMBER;
3768 l_temp_var VARCHAR2(2000) := NULL;
3769 l_copy_rec COPY_REC_TYPE;
3770 --serla begin
3771 l_x_Header_Payment_tbl OE_Order_PUB.Header_Payment_Tbl_Type;
3772 l_x_Line_Payment_tbl OE_Order_PUB.Line_Payment_Tbl_Type;
3773 --serla end
3774
3775 --R12 CC Encryption
3776 l_cpy_category VARCHAR2(30);
3777 l_msg_count NUMBER;
3778 l_msg_data VARCHAR2(2000);
3779 l_trxn_extension_id NUMBER;
3780 l_invoice_to_cust_id NUMBER;
3781 l_exists VARCHAR2(1);
3782 --R12 CC Encryption
3783 --bug 5113795
3784 l_payment_type_code VARCHAR2(80);
3785 l_copy_header_payments VARCHAR2(10);
3786 l_copy_line_payments VARCHAR2(10);
3787 l_cc_line_payments NUMBER;
3788
3789 -- Copy Sets ER #2830872 , #1566254 Begin.
3790 l_sets_result VARCHAR2(1);
3791 l_hdr_id_sets_tbl OE_GLOBALS.Selected_Record_Tbl;
3792 l_sets_found_flag BOOLEAN := FALSE;
3793 l_sets NUMBER := 0;
3794 l_sets_header_id NUMBER;
3795 l_copy_fulfill_sets BOOLEAN := FALSE;
3796 l_copy_ship_arr_sets BOOLEAN := FALSE;
3797 -- Copy Sets ER #2830872 , #1566254 End.
3798
3799 BEGIN
3800
3801 -- p_hdr_id_tbl and p_line_id_tbl are now passed as separate tables because client side pl-sql can
3802 -- not handle record of table of record
3803
3804 -- Set the Global COPY rec
3805 G_COPY_REC := p_copy_rec;
3806 --bug 5113795
3807 l_copy_header_payments := p_copy_rec.hdr_payments;
3808 l_copy_line_payments := p_copy_rec.line_payments;
3809
3810 IF l_debug_level > 0 THEN
3811 oe_debug_pub.add( 'ENTERING OE_ORDER_COPY_UTIL.COPY_ORDER' , 1 ) ;
3812 oe_debug_pub.add( 'BEFORE RESETTING LEVEL : '|| TO_CHAR ( G_ORDER_LEVEL_COPY ) , 3 ) ;
3813 oe_debug_pub.add( 'REDEFAULT MISSING IS ' || P_COPY_REC.DEFAULT_NULL_VALUES ) ;
3814 END IF;
3815
3816 G_LINE_PRICE_MODE := p_copy_rec.line_price_mode;
3817 G_ORDER_LEVEL_COPY := 0;
3818
3819 -- Standard call to check for call compatibility
3820
3821 IF NOT FND_API.Compatible_API_Call
3822 (l_api_version_number
3823 ,p_copy_rec.api_version_number
3824 ,l_api_name
3825 ,G_PKG_NAME
3826 )
3827 THEN
3828 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3829 END IF;
3830
3831 -- Initialize message list.
3832
3833 IF FND_API.to_Boolean(p_copy_rec.init_msg_list) THEN
3834 OE_MSG_PUB.initialize;
3835 END IF;
3836
3837 -- Initialize API return status to success
3838 x_return_status := FND_API.G_RET_STS_SUCCESS;
3839
3840 -- Set the global variable.
3841 G_REGULAR_TO_RMA := FALSE;
3842 G_NEED_TO_EXPLODE_CONFIG := FALSE;
3843 -- Loop Through the table of header Ids
3844 IF l_debug_level > 0 THEN
3845 oe_debug_pub.add('BEfore looping for '||p_hdr_id_tbl.COUNT);
3846 END IF;
3847
3848 FOR i IN p_hdr_id_tbl.FIRST..p_hdr_id_tbl.LAST LOOP
3849
3850 --Bug 7707530 : Moved following portion inside the loop to set org id with
3851 --each iteration
3852 --ER 7258165 : Start : Copy accross organizations
3853 --Set the org context to source lock in order to fetch all the source details
3854 IF G_COPY_REC.source_org_id IS NOT NULL THEN
3855 mo_global.set_policy_context(NVL(G_COPY_REC.source_access_mode,'S')
3856 ,G_COPY_REC.source_org_id);
3857 END IF;
3858 --ER 7258165 : End
3859 --Bug 7707530 : End
3860
3861 -- Set the global variables
3862 G_Canceled_Line_Deleted := FALSE;
3863 G_Order_Has_Split_Lines := FALSE;
3864
3865 IF l_debug_level > 0 THEN
3866 oe_debug_pub.add( 'HDR ID IS '||p_hdr_id_tbl(i).id1 , 2 ) ;
3867 END IF;
3868
3869 l_header_id := p_hdr_id_tbl(i).id1;
3870
3871 G_ATT_HEADER_ID := l_header_id;
3872
3873 -- Are we Copying an Order or Copying Lines to existing Order.
3874
3875 IF FND_API.to_Boolean(p_copy_rec.copy_order) THEN
3876 -- Copy Hdr Information
3877
3878 /* Added the following line to fix the bug 1923460 */
3879 IF l_debug_level > 0 THEN
3880 oe_debug_pub.add( 'BEFORE SETTING LEVEL : '|| TO_CHAR ( G_ORDER_LEVEL_COPY ) , 3 ) ;
3881 END IF;
3882 G_ORDER_LEVEL_COPY := 1;
3883 IF p_copy_rec.source_block_type = 'LINE' AND
3884 p_copy_rec.copy_complete_config = FND_API.G_TRUE
3885 THEN
3886 G_NEED_TO_EXPLODE_CONFIG := TRUE;
3887 IF l_debug_level > 0 THEN
3888 oe_debug_pub.add('Setting G_NEED_TO_EXPLODE_CONFIG ' , 3 ) ;
3889 END IF;
3890 END IF;
3891 l_destination_header_id := l_header_id;
3892 IF FND_API.to_Boolean(p_copy_rec.hdr_info) THEN
3893 Copy_Header(l_header_id,
3894 p_copy_rec,
3895 l_header_rec);
3896
3897 ---- Creating New Sales Order or Quoted Order
3898 l_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;
3899 l_header_rec.transaction_phase_code := p_copy_rec.new_phase;
3900
3901 IF l_debug_level > 0 THEN
3902 oe_debug_pub.add( 'AK1 HEADER ID ' || TO_CHAR ( L_HEADER_ID ) , 2 ) ;
3903 END IF;
3904 ELSE -- Create Blank Header
3905
3906 l_copy_rec := p_copy_rec;
3907 -- May need to explode config for line level COPY.
3908 IF p_copy_rec.source_block_type = 'LINE' AND
3909 p_copy_rec.copy_complete_config = FND_API.G_TRUE
3910 THEN
3911 G_NEED_TO_EXPLODE_CONFIG := TRUE;
3912 IF l_debug_level > 0 THEN
3913 oe_debug_pub.add('Setting G_NEED_TO_EXPLODE_CONFIG ' , 3 ) ;
3914 END IF;
3915
3916 END IF;
3917
3918 IF l_debug_level > 0 THEN
3919 oe_debug_pub.add( 'AK IN FIRST LINE HEADER LOGIC' , 2 ) ;
3920 END IF;
3921
3922 -- Get header_id from first line.
3923 l_line_id := p_line_id_tbl(1).id1;
3924
3925 -- Set the version number as NULL so that the current version
3926 -- of Order Header will be selected from oe_order_headers.
3927
3928 l_copy_rec.version_number := NULL;
3929 l_copy_rec.phase_change_flag := NULL;
3930
3931 BEGIN
3932
3933 Select header_id
3934 Into l_line_header_id
3935 From oe_order_lines
3936 Where line_id = l_line_id;
3937
3938 EXCEPTION
3939
3940 WHEN OTHERS THEN
3941
3942 l_line_header_id := Null;
3943
3944 END;
3945
3946 IF l_line_header_id is not null THEN
3947 Copy_Header(l_line_header_id,
3948 l_copy_rec,
3949 l_header_rec);
3950
3951 ELSE
3952
3953 IF l_debug_level > 0 THEN
3954 oe_debug_pub.add( 'AK BLANK HEADER' , 3 ) ;
3955 END IF;
3956 -- Set Source to COPY
3957 l_header_rec.source_document_type_id := 2;
3958 l_header_rec.source_document_id := l_header_id;
3959 l_header_rec.source_document_version_number := NULL;
3960
3961 -- Need to specify OrderType
3962 IF p_copy_rec.hdr_type IS NOT NULL THEN
3963 l_header_rec.order_type_id := p_copy_rec.hdr_type;
3964 END IF;
3965
3966 IF l_debug_level > 0 THEN
3967 oe_debug_pub.add( 'ORDER TYPE ' || TO_CHAR ( L_HEADER_REC.ORDER_TYPE_ID ) , 2 ) ;
3968 END IF;
3969 -- Set manual order number
3970 IF p_copy_rec.manual_order_number IS NOT NULL THEN
3971 l_header_rec.order_number := p_copy_rec.manual_order_number;
3972 END IF;
3973
3974 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
3975 IF p_copy_rec.new_phase = 'N' THEN
3976 l_header_rec.TRANSACTION_PHASE_CODE := 'N';
3977 ELSE
3978 l_header_rec.TRANSACTION_PHASE_CODE := 'F';
3979 END IF;
3980
3981 IF p_copy_rec.copy_transaction_name = FND_API.G_FALSE THEN
3982 l_header_rec.SALES_DOCUMENT_NAME :=
3983 p_copy_rec.transaction_name;
3984 END IF;
3985
3986 IF p_copy_rec.copy_expiration_date = FND_API.G_FALSE THEN
3987 l_header_rec.EXPIRATION_DATE :=
3988 NVL(p_copy_rec.expiration_date,FND_API.G_MISS_DATE);
3989 END IF;
3990
3991 -- Set manual quote number
3992 IF p_copy_rec.manual_quote_number IS NOT NULL THEN
3993 l_header_rec.quote_number :=
3994 p_copy_rec.manual_quote_number;
3995 END IF;
3996
3997 END IF;
3998
3999 END IF; -- l_line_header_id
4000 l_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;
4001 END IF; -- IF FND_API.to_Boolean(p_copy_rec.hdr_info)
4002
4003 -- Copy Header Sales Credits if desired.
4004 IF FND_API.to_Boolean(p_copy_rec.hdr_scredits) THEN
4005 Load_and_Init_Hdr_Scredits(l_header_id,
4006 p_copy_rec.version_number,
4007 p_copy_rec.phase_change_flag,
4008 l_header_scredit_tbl);
4009 END IF;
4010
4011
4012 -- Copy Order Based Holds if desired.
4013 IF FND_API.to_Boolean(p_copy_rec.hdr_holds) THEN
4014 l_action_request_tbl := Load_and_Init_Hdr_Holds(l_header_id,
4015 p_copy_rec.version_number,
4016 p_copy_rec.phase_change_flag,
4017 l_action_request_tbl);
4018 END IF;
4019
4020 -- for multiple payments.
4021 IF FND_API.to_Boolean(p_copy_rec.hdr_payments)
4022 AND OE_PREPAYMENT_UTIL.IS_MULTIPLE_PAYMENTS_ENABLED THEN
4023 -- don't copy payment information to order of RETURN type.
4024 IF l_debug_level > 0 THEN
4025 oe_Debug_pub.add('Before hdr payments processing, destination order type is: '||get_order_category(l_header_rec.order_type_id),3);
4026 END IF;
4027 --R12 CC Encryption
4028 l_cpy_category := Get_Order_Category(p_copy_rec.hdr_type);
4029 IF nvl(l_cpy_category,'NULL') <> 'RETURN' THEN --R12 CC Encryption
4030 --bug 5113795
4031 select payment_type_code into l_payment_type_code
4032 from oe_order_headers_all where header_id = l_header_id;
4033 IF l_debug_level > 0 THEN
4034 oe_debug_pub.add('Payment type code in copy order..ksurendr'||l_payment_type_code);
4035 oe_debug_pub.add('Header_id ...'||l_header_id);
4036 oe_debug_pub.add('Copy Header Payments flag...'||l_copy_header_payments);
4037 END IF;
4038 IF l_payment_type_code = 'CREDIT_CARD' and
4039 OE_Payment_Trxn_Util.Get_CC_Security_Code_Use = 'REQUIRED'
4040 AND l_copy_header_payments = 'T' THEN
4041 IF l_debug_level > 0 THEN
4042 oe_debug_pub.add('Error in Copy order');
4043 END IF;
4044 FND_MESSAGE.SET_NAME('ONT','OE_CC_NO_COPY_SEC_CODE_REQ');
4045 OE_MSG_PUB.Add;
4046 RAISE FND_API.G_EXC_ERROR;
4047 ELSE
4048 IF l_debug_level > 0 THEN
4049 oe_debug_pub.add('Before calling load and init header payments....');
4050 END IF;
4051 Load_and_Init_Hdr_Payments(l_header_id,l_x_header_payment_tbl);
4052 END IF;
4053 --bug 5113795
4054 END IF;
4055 END IF;
4056
4057 -- Pre-populate header_id on the header record.
4058 SELECT OE_ORDER_HEADERS_S.NEXTVAL
4059 INTO l_header_rec.header_id
4060 FROM DUAL;
4061
4062 --R12 CC Encryption
4063 oe_debug_pub.add('New header id...'||l_header_rec.header_id);
4064 --oe_debug_pub.adD('Original trxn extn id'||l_x_header_payment_tbl(1).trxn_extension_id);
4065 oe_debug_pub.add('category'||l_cpy_category);
4066 oe_debug_pub.add('g_create fl'||g_create_payment_flag||'and'||p_copy_rec.hdr_info||'and'||p_copy_rec.hdr_payments);
4067
4068 /*IF nvl(l_cpy_category,'-1') <> 'RETURN' AND FND_API.to_Boolean(p_copy_rec.hdr_info)
4069 AND FND_API.to_Boolean(p_copy_rec.hdr_payments) AND g_create_payment_flag = 'Y' THEN
4070 -- Condition for the payment types supported by order header
4071 IF l_header_rec.payment_type_code IN('CASH','CHECK','CREDIT_CARD') THEN
4072
4073 begin
4074 SELECT 'Y'
4075 INTO l_exists
4076 FROM oe_payments
4077 Where header_id = l_header_id;
4078 --0and trxn_extension_id is not null; --Verify
4079 exception
4080 when no_data_found then
4081 IF l_debug_level > 0 THEN
4082 oe_debug_pub.add('no data found while querying oe_payments in copy_order..'||sqlerrm);
4083 END IF;
4084 l_exists := 'N';
4085 end;
4086 begin
4087 Select customer_id
4088 Into l_invoice_to_cust_id
4089 From oe_invoice_to_orgs_v
4090 Where organization_id = l_header_rec.invoice_to_org_id;
4091 exception
4092 when no_data_found then
4093 IF l_debug_level > 0 THEN
4094 oe_debug_pub.add('no data found while querying for customer id in copy_order..'||sqlerrm);
4095 END IF;
4096 end;
4097
4098 IF nvl(l_exists, 'N') = 'N' THEN --Verify
4099 --New trxn_extension_id and a new record in oe_payments table
4100 OE_PAYMENT_TRXN_UTIL.Create_Payment_Trxn
4101 (P_header_id => l_header_rec.header_id, --Verify
4102 P_line_id => null,
4103 P_cust_id => l_invoice_to_cust_id,
4104 P_site_use_id => l_header_rec.invoice_to_org_id,
4105 P_payment_type_code => l_header_rec.payment_type_code,
4106 P_payment_trx_id => null,--l_x_header_payment_tbl.payment_trx_id,
4107 p_payment_number => null, --Verify
4108 P_card_number => l_header_rec.credit_card_number,
4109 p_card_code => l_header_rec.credit_card_code,
4110 P_card_holder_name => l_header_rec.credit_card_holder_name,
4111 P_exp_date => l_header_rec.credit_card_expiration_date,
4112 P_check_number => l_header_rec.check_number,
4113 P_instrument_security_code=> null,--l_header_rec.instrument_security_code,
4114 P_X_trxn_extension_id => l_trxn_extension_id,
4115 X_return_status => l_return_status,
4116 X_msg_count => l_msg_count,
4117 X_msg_data => l_msg_data);
4118
4119
4120 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4121 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4122 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
4123 RAISE FND_API.G_EXC_ERROR;
4124 END IF;
4125 l_header_rec.credit_card_number := FND_API.G_MISS_CHAR;
4126 l_header_rec.credit_card_code := FND_API.G_MISS_CHAR;
4127 l_header_rec.credit_card_expiration_date := FND_API.G_MISS_DATE;
4128 l_header_rec.credit_card_holder_name := FND_API.G_MISS_CHAR; --Verify
4129
4130 --set global variables before calling create_payment
4131 G_trxn_extension_id := l_trxn_extension_id;
4132 g_payment_type_code := l_header_rec.payment_type_code;
4133 Create_Payment(l_header_rec.header_id);
4134 null;
4135 END IF;
4136 END IF;
4137 END IF;*/
4138 -- R12 CC Encryption
4139 ELSE -- Append to Existing Order
4140 l_destination_header_id := p_copy_rec.append_to_header_id;
4141 l_header_rec.header_id := p_copy_rec.append_to_header_id;
4142 l_header_rec.operation := OE_GLOBALS.G_OPR_NONE; -- Add Lines to Existing Order
4143 -- May need to explode config for line level COPY.
4144 IF p_copy_rec.source_block_type = 'LINE' AND
4145 p_copy_rec.copy_complete_config = FND_API.G_TRUE
4146 THEN
4147 G_NEED_TO_EXPLODE_CONFIG := TRUE;
4148 IF l_debug_level > 0 THEN
4149 oe_debug_pub.add('Setting G_NEED_TO_EXPLODE_CONFIG ' , 3 ) ;
4150 END IF;
4151 END IF;
4152 END IF;
4153
4154 -- Initialize the Lines Table
4155
4156 IF l_line_tbl.COUNT > 0 THEN
4157 l_line_tbl.DELETE;
4158 END IF;
4159
4160 -- Initialize the Top_Model_Tbl
4161
4162 IF l_top_model_tbl.COUNT > 0 THEN
4163 l_top_model_tbl.DELETE;
4164 END IF;
4165
4166 -- Set the Globals for COPY (To be used by copy_adjustments)
4167
4168 G_HDR_VER_NUMBER := p_copy_rec.version_number;
4169 G_HDR_PHASE_CHANGE_FLAG := p_copy_rec.phase_change_flag;
4170 G_LN_VER_NUMBER := p_copy_rec.line_version_number;
4171 G_LN_PHASE_CHANGE_FLAG := p_copy_rec.line_phase_change_flag;
4172
4173 IF l_debug_level > 0 THEN
4174 oe_debug_pub.add('Header Version Number IS '|| G_HDR_VER_NUMBER , 1 ) ;
4175 oe_debug_pub.add('Header Phase Change Flag IS '|| G_HDR_PHASE_CHANGE_FLAG , 1 ) ;
4176 oe_debug_pub.add('Line Version Number IS '|| G_LN_VER_NUMBER , 1 ) ;
4177 oe_debug_pub.add('Line Phase Change Flag IS '|| G_LN_PHASE_CHANGE_FLAG , 1 ) ;
4178 END IF;
4179 -- Load Lines to be copied into table and handle configurations.
4180 -- Will be used in Nonstandard lines procedure.
4181
4182 l_hdr_type_id := nvl(p_copy_rec.hdr_type,l_header_rec.order_type_id);
4183 load_lines(p_copy_rec.line_count,
4184 p_line_id_tbl,
4185 p_copy_rec.all_lines,
4186 p_copy_rec.incl_cancelled,
4187 l_header_id,
4188 l_hdr_type_id,
4189 p_copy_rec.line_type,
4190 p_copy_rec.line_version_number,
4191 p_copy_rec.line_phase_change_flag,
4192 l_line_tbl,
4193 l_top_model_tbl);
4194
4195 -- Load Line Sales Credits
4196
4197 IF FND_API.to_Boolean(p_copy_rec.line_scredits) THEN
4198 Load_and_Init_line_scredits(l_line_tbl,
4199 p_copy_rec.line_version_number,
4200 p_copy_rec.line_phase_change_flag,
4201 l_line_scredit_tbl);
4202 END IF;
4203
4204 -- for multiple payments
4205 IF FND_API.to_Boolean(p_copy_rec.line_payments)
4206 AND OE_PREPAYMENT_UTIL.IS_MULTIPLE_PAYMENTS_ENABLED THEN
4207 --bug 5113795
4208 select count(*) into l_cc_line_payments
4209 from oe_payments where header_id = l_header_id
4210 and line_id is not null and payment_type_code = 'CREDIT_CARD';
4211
4212 IF l_debug_level > 0 THEN
4213 oe_debug_pub.add('In Line payments copy...');
4214 oe_debug_pub.add('Line cc payments count'|| l_cc_line_payments);
4215 oe_debug_pub.add('Header_id ..'||l_header_id);
4216 END IF;
4217
4218 IF l_cc_line_payments > 0 AND
4219 OE_Payment_Trxn_Util.Get_CC_Security_Code_Use = 'REQUIRED'
4220 AND l_copy_line_payments = 'T' THEN
4221 IF l_debug_level > 0 THEN
4222 oe_debug_pub.add('Error in Line Payments Copy order');
4223 oe_debug_pub.add('Copy line payments checkbox...'||l_copy_line_payments);
4224 END IF;
4225 FND_MESSAGE.SET_NAME('ONT','OE_CC_NO_COPY_SEC_CODE_REQ');
4226 OE_MSG_PUB.Add;
4227 RAISE FND_API.G_EXC_ERROR;
4228 ELSE
4229 IF l_debug_level > 0 THEN
4230 oe_debug_pub.add('Before calling load and init line payments...');
4231 END IF;
4232 Load_and_Init_Line_Payments(l_line_tbl
4233 ,p_copy_rec.line_type
4234 ,l_x_line_payment_tbl);
4235 END IF;
4236 --bug 5113795
4237 END IF;
4238
4239 -- Initialize Lines table after children have been loaded
4240 -- ,since we need the line_id to load children.
4241
4242 -- Modified for the ER 2351654 added extra parameter default_null_values
4243 --R12 CC Encryption
4244 IF l_debug_level > 0 THEN
4245 --oe_debug_pub.add('Credit card number in header rec...'||l_header_rec.credit_card_number);
4246 oe_debug_pub.add('Payment type code'||l_header_rec.payment_type_code);
4247 END IF;
4248
4249 -- Added for the ER 1480867. Call the Init_Lines_New for the ER.
4250 Init_lines_new(l_line_tbl,
4251 l_top_model_tbl,
4252 p_copy_rec.line_type,
4253 l_header_rec.header_id,
4254 p_copy_rec.line_price_mode,
4255 p_copy_rec.line_price_date,
4256 p_copy_rec.line_descflex,
4257 FND_API.G_FALSE,
4258 p_copy_rec.return_reason_code,
4259 p_copy_rec.default_null_values,
4260 p_copy_rec.version_reason_code,
4261 p_copy_rec.comments,
4262 p_copy_rec,
4263 l_action_request_tbl);
4264 -- Set Control Flags.
4265
4266 l_control_rec.controlled_operation := TRUE; -- Since we set PARTIAL_PROCESS to true
4267 l_control_rec.check_security := TRUE;
4268 l_control_rec.default_attributes := TRUE;
4269
4270 l_control_rec.change_attributes := TRUE; -- since we are creating Orders
4271 l_control_rec.clear_dependents := FALSE;
4272 l_control_rec.validate_entity := TRUE;
4273 l_control_rec.write_to_DB := TRUE;
4274 l_control_rec.process := TRUE;
4275 l_control_rec.process_entity := OE_GLOBALS.G_ENTITY_ALL;
4276
4277 -- Instruct API to process as many records as it can
4278
4279 l_control_rec.Process_Partial := TRUE;
4280
4281 -- Instruct API to retain its caches
4282
4283 l_control_rec.clear_api_cache := TRUE;
4284 l_control_rec.clear_api_requests := TRUE;
4285
4286
4287 -- Call Process Order API to process request.
4288
4289 IF l_debug_level > 0 THEN
4290 oe_debug_pub.add( 'BEFORE PROCESS ORDER' , 2 ) ;
4291 oe_debug_pub.add('Header Currency is '|| l_header_rec.transactional_curr_code);
4292 IF l_line_tbl.COUNT <> 0 THEN
4293 oe_debug_pub.add('Line Context is:'||l_line_tbl(1).context);
4294 END IF;
4295 END IF;
4296
4297 --ER 7258165 : Start : Copy accross organizations
4298 --Set the org context to OU in which the order is to be copied
4299 mo_global.set_policy_context('S',G_COPY_REC.copy_org_id);
4300
4301
4302 if G_COPY_REC.copy_org_id <> G_COPY_REC.source_org_id then
4303 l_header_rec.invoice_to_org_id := FND_API.G_MISS_NUM;
4304 l_header_rec.ship_to_org_id := FND_API.G_MISS_NUM;
4305 l_header_rec.deliver_to_org_id := FND_API.G_MISS_NUM;
4306 l_header_rec.deliver_to_contact_id := FND_API.G_MISS_NUM;
4307 for i in 1..l_line_tbl.COUNT LOOP
4308 l_line_tbl(i).invoice_to_org_id := FND_API.G_MISS_NUM;
4309 l_line_tbl(i).ship_to_org_id := FND_API.G_MISS_NUM;
4310 l_line_tbl(i).deliver_to_org_id := FND_API.G_MISS_NUM;
4311 l_line_tbl(i).DELIVER_TO_CONTACT_ID := FND_API.G_MISS_NUM;
4312 END LOOP ;
4313 end if ;
4314
4315 --ER 7258165 : End
4316
4317 OE_Order_PVT.Process_Order(
4318 p_api_version_number => 1
4319 ,p_init_msg_list => FND_API.G_FALSE
4320 -- to keep messages between calls
4321 ,p_validation_level => OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF
4322 -- to miss out invalid attrs.
4323 ,p_control_rec => l_control_rec
4324 ,p_x_header_rec => l_header_rec
4325 ,p_x_header_Adj_tbl => l_header_Adj_out_tbl
4326 ,p_x_header_price_att_tbl => l_header_price_att_tbl
4327 ,p_x_header_adj_att_tbl => l_header_adj_att_tbl
4328 ,p_x_header_adj_assoc_tbl => l_header_adj_assoc_tbl
4329 ,p_x_Header_Scredit_tbl => l_Header_Scredit_tbl
4330 --serla begin
4331 ,p_x_Header_Payment_tbl => l_x_Header_Payment_tbl
4332 --serla end
4333 ,p_x_line_tbl => l_line_tbl
4334 ,p_x_line_Adj_tbl => l_line_adj_out_tbl
4335 ,p_x_line_price_att_tbl => l_line_price_att_tbl
4336 ,p_x_line_adj_att_tbl => l_line_adj_att_tbl
4337 ,p_x_line_adj_assoc_tbl => l_line_adj_assoc_tbl
4338 ,p_x_line_Scredit_tbl => l_Line_Scredit_tbl
4339 --serla begin
4340 ,p_x_Line_Payment_tbl => l_x_Line_Payment_tbl
4341 --serla end
4342 ,p_x_lot_Serial_tbl => l_Lot_Serial_out_tbl
4343 ,p_x_action_request_tbl => l_action_request_tbl
4344 ,x_return_status => l_return_status
4345 ,x_msg_count => x_msg_count
4346 ,x_msg_data => x_msg_data
4347 );
4348
4349
4350 IF l_debug_level > 0 THEN
4351 oe_debug_pub.add( 'RETURN STATUS AFTER CALL TO PO '||L_RETURN_STATUS , 1 ) ;
4352 END IF;
4353
4354 -- Copy Sets ER #2830872 , #1566254 Begin.
4355 -- Creating the table of header ids for operation.
4356
4357 IF ((p_copy_rec.line_fulfill_sets = 'T' OR p_copy_rec.line_ship_arr_sets = 'T')
4358 AND l_line_tbl.Count > 0) THEN
4359
4360 IF p_copy_rec.line_fulfill_sets = 'T' THEN
4361 l_copy_fulfill_sets := TRUE;
4362 IF l_debug_level > 0 THEN
4363 oe_debug_pub.add(' Copying Fulfill Sets :'||p_copy_rec.line_fulfill_sets);
4364 END IF;
4365 END IF;
4366
4367 IF p_copy_rec.line_ship_arr_sets = 'T' THEN
4368 l_copy_ship_arr_sets := TRUE;
4369 IF l_debug_level > 0 THEN
4370 oe_debug_pub.add(' Copying Ship/Arr Sets :'||p_copy_rec.line_ship_arr_sets);
4371 END IF;
4372 END IF;
4373
4374 IF l_debug_level > 0 THEN
4375 oe_debug_pub.add(' Creating Header ID Table for Copy of Sets');
4376 END IF;
4377
4378 IF l_line_tbl.Count > 0 THEN
4379 FOR i in 1..l_line_tbl.Count LOOP
4380 IF l_line_tbl(i).source_document_type_id = 2 THEN
4381 l_sets_header_id := l_line_tbl(i).source_document_id;
4382 ELSE
4383 l_sets_header_id := NULL;
4384 END IF;
4385
4386 IF l_hdr_id_sets_tbl.Count > 0 THEN
4387 FOR j IN 1..l_hdr_id_sets_tbl.Count LOOP
4388 IF l_sets_header_id IS NOT NULL THEN
4389 IF l_hdr_id_sets_tbl(j).id1 = l_sets_header_id THEN
4390 l_sets_found_flag := TRUE;
4391 END IF;
4392 END IF;
4393 END LOOP;
4394 END IF;
4395
4396 IF NOT (l_sets_found_flag) THEN
4397 l_sets := l_sets + 1;
4398 l_hdr_id_sets_tbl(l_sets).id1 := l_sets_header_id;
4399 END IF;
4400 l_sets_found_flag :=FALSE;
4401 END LOOP;
4402 END IF;
4403 l_sets := 0;
4404
4405 -- Calling the Copy Line Sets Procedure.
4406 IF l_debug_level > 0 THEN
4407 oe_debug_pub.add(' Calling Copy Line Sets ');
4408 END IF;
4409
4410 IF l_hdr_id_sets_tbl.Count > 0 THEN
4411 FOR i IN 1..l_hdr_id_sets_tbl.Count LOOP
4412 COPY_LINE_SETS(l_hdr_id_sets_tbl(i).id1,
4413 l_header_rec.header_id,
4414 l_line_tbl,
4415 l_copy_fulfill_sets,
4416 l_copy_ship_arr_sets,
4417 l_sets_result);
4418 END LOOP;
4419 END IF;
4420
4421 IF l_sets_result = FND_API.G_RET_STS_SUCCESS THEN
4422 IF l_debug_level > 0 THEN
4423 oe_debug_pub.add(' Set Result :'||l_sets_result);
4424 END IF;
4425
4426 FND_MESSAGE.SET_NAME('ONT','OE_COPY_LINE_SETS');
4427 OE_MSG_PUB.Add;
4428 ELSE
4429 IF l_debug_level > 0 THEN
4430 oe_debug_pub.add(' Set Result :'||l_sets_result);
4431 END IF;
4432
4433 FND_MESSAGE.SET_NAME('ONT','OE_FAIL_LINE_SETS');
4434 OE_MSG_PUB.Add;
4435 END IF;
4436 END IF;
4437 -- Copy Sets ER #2830872 , #1566254 End.
4438
4439 -- code to deal with the partial request case
4440 -- being added for the bug 1935675
4441
4442 l_header_exists := TRUE;
4443 l_all_lines_copied := TRUE;
4444 l_all_lines_failed := TRUE;
4445 l_delete_config := FALSE;
4446 l_to_header_id := NULL;
4447
4448 IF FND_API.to_Boolean( p_copy_rec.copy_order ) THEN
4449
4450 BEGIN
4451 l_to_header_id := l_header_rec.header_id;
4452 SELECT header_id
4453 INTO l_dummy_header
4454 FROM OE_ORDER_HEADERS
4455 WHERE header_id = l_header_rec.header_id;
4456 EXCEPTION
4457 WHEN NO_DATA_FOUND THEN
4458 l_header_exists := FALSE;
4459 END;
4460 END IF; -- copy_order
4461
4462 IF ( l_header_exists ) THEN
4463
4464 IF FND_API.to_Boolean( p_copy_rec.copy_order ) THEN
4465
4466 IF l_header_rec.transaction_phase_code = 'F' OR
4467 l_header_rec.transaction_phase_code IS NULL THEN
4468 FND_MESSAGE.SET_NAME( 'ONT', 'OE_CPY_NEW_HEADER' );
4469 FND_MESSAGE.SET_TOKEN('ORDER', to_char(l_header_rec.order_number));
4470 ELSE
4471 FND_MESSAGE.SET_NAME( 'ONT', 'OE_CPY_NEW_QUOTE' );
4472 FND_MESSAGE.SET_TOKEN('QUOTE', to_char(l_header_rec.quote_number));
4473 END IF;
4474 OE_MSG_PUB.Add;
4475
4476 l_copy_partial_or_full := TRUE;
4477 x_header_id := l_header_rec.header_id;
4478
4479 IF FND_API.to_Boolean( p_copy_rec.hdr_attchmnts ) THEN
4480
4481 OE_Atchmt_Util.Copy_Attachments
4482 (p_entity_code => OE_GLOBALS.G_ENTITY_HEADER
4483 ,p_from_entity_id => G_ATT_HEADER_ID
4484 ,p_to_entity_id => l_header_rec.header_id
4485 ,p_manual_attachments_only => 'Y'
4486 ,x_return_status => l_return_status);
4487 END IF; -- attachments
4488
4489 --Copy Articles takintoy
4490 IF OE_CODE_CONTROL.Get_Code_Release_Level >='110510'Then
4491 OE_Contracts_Util.copy_articles
4492 (p_api_version => 1,
4493 p_doc_type => OE_Contracts_Util.G_SO_DOC_TYPE,
4494 p_copy_from_doc_id => G_ATT_HEADER_ID,
4495 ---p_version_number => l_copy_rec.version_number,
4496 p_version_number => p_copy_rec.version_number, --Bug 3689174 --l_copy_rec.version_number holds no value
4497 p_copy_to_doc_id => l_header_rec.header_id,
4498 p_copy_to_doc_number => l_header_rec.order_number,
4499 x_return_status => l_return_status,
4500 x_msg_count => x_msg_count,
4501 x_msg_data => x_msg_data
4502 );
4503 END IF;
4504
4505 END IF; -- copy order
4506
4507 k := l_line_tbl.first;
4508
4509 WHILE k IS NOT NULL LOOP
4510
4511 IF ( l_line_tbl(k).return_status = FND_API.g_ret_sts_success ) THEN
4512
4513 IF FND_API.to_Boolean( p_copy_rec.line_attchmnts ) THEN
4514 OE_Atchmt_Util.Copy_Attachments
4515 (p_entity_code => OE_GLOBALS.G_ENTITY_LINE
4516 ,p_from_entity_id => l_line_tbl(k).source_document_line_id
4517 ,p_to_entity_id => l_line_tbl(k).line_id
4518 ,p_manual_attachments_only => 'Y'
4519 ,x_return_status => l_return_status);
4520 END IF; -- attachments;
4521
4522 l_all_lines_failed := FALSE;
4523
4524 IF l_to_header_id IS NULL THEN
4525 l_to_header_id := l_line_tbl(k).header_id;
4526 END IF;
4527
4528 IF NOT FND_API.to_Boolean(p_copy_rec.copy_order) THEN
4529 l_copy_partial_or_full := TRUE;
4530 END IF ; -- case of appending lines to an existing order
4531
4532 ELSE
4533
4534 IF ( ( l_line_tbl(k).config_header_id IS NOT NULL ) AND
4535 ( l_line_tbl(k).config_rev_nbr IS NOT NULL ) ) THEN
4536 l_delete_config := TRUE;
4537 END IF;
4538
4539 l_all_lines_copied := FALSE;
4540
4541 END IF; -- return_status = 'S'
4542
4543 k := l_line_tbl.NEXT(k);
4544
4545 END LOOP; -- loop on lines
4546
4547 IF (l_all_lines_copied AND
4548 NOT G_Canceled_Line_Deleted AND
4549 NOT G_Order_Has_Split_Lines) OR
4550 G_REGULAR_TO_RMA OR
4551 OE_CODE_CONTROL.Get_Code_Release_Level < '110509' THEN
4552 -- Do nothing as the Line numbers will match
4553 NULL;
4554 ELSE
4555
4556 Process_Line_Numbers(p_header_id => l_to_header_id);
4557
4558 END IF;
4559
4560 IF ( l_all_lines_failed ) THEN
4561
4562
4563 IF l_header_rec.transaction_phase_code = 'F' OR
4564 l_header_rec.transaction_phase_code IS NULL THEN
4565 FND_MESSAGE.SET_NAME( 'ONT', 'OE_CPY_LINES_FAILED' );
4566 FND_MESSAGE.SET_TOKEN('ORDER', to_char(l_header_rec.order_number));
4567 ELSE
4568 FND_MESSAGE.SET_NAME( 'ONT', 'OE_QUOTE_CPY_LINES_FAILED' );
4569 FND_MESSAGE.SET_TOKEN('QUOTE', to_char(l_header_rec.quote_number));
4570 END IF;
4571 OE_MSG_PUB.Add;
4572
4573 ELSIF ( l_all_lines_copied ) THEN
4574
4575 IF FND_API.to_Boolean(p_copy_rec.copy_order) THEN
4576
4577 IF l_debug_level > 0 THEN
4578 oe_debug_pub.add( 'THE NEW ORDER IS '||TO_CHAR ( L_HEADER_REC.ORDER_NUMBER ) , 1 ) ;
4579 END IF;
4580
4581 IF l_header_rec.transaction_phase_code = 'F' OR
4582 l_header_rec.transaction_phase_code IS NULL THEN
4583
4584 FND_MESSAGE.SET_NAME('ONT','OE_CPY_NEW_ORDER');
4585 FND_MESSAGE.SET_TOKEN('ORDER',
4586 to_char(l_header_rec.order_number));
4587 ELSE
4588 FND_MESSAGE.SET_NAME('ONT','OE_CPY_NEW_QUOTE_SUCCESS');
4589 FND_MESSAGE.SET_TOKEN('QUOTE',
4590 to_char(l_header_rec.quote_number));
4591 END IF;
4592 OE_MSG_PUB.Add;
4593
4594 ELSE
4595
4596 IF l_debug_level > 0 THEN
4597 oe_debug_pub.add( 'APPENEDED LINES SUCCESSFULLY FOR ORDER : ' || TO_CHAR ( L_HEADER_REC.ORDER_NUMBER ) , 1 ) ;
4598 END IF;
4599
4600 FND_MESSAGE.SET_NAME('ONT','OE_CPY_APPEND_LINES');
4601 OE_MSG_PUB.Add;
4602
4603 END IF;
4604
4605 x_header_id := l_header_rec.header_id;
4606
4607 ELSE
4608
4609 IF l_header_rec.transaction_phase_code = 'F' OR
4610 l_header_rec.transaction_phase_code IS NULL THEN
4611 FND_MESSAGE.SET_NAME('ONT','OE_CPY_COPY_PARTIAL');
4612 FND_MESSAGE.SET_TOKEN('ORDER',
4613 to_char(l_header_rec.order_number));
4614 ELSE
4615 FND_MESSAGE.SET_NAME('ONT','OE_QUOTE_CPY_COPY_PARTIAL');
4616 FND_MESSAGE.SET_TOKEN('QUOTE',
4617 to_char(l_header_rec.quote_number));
4618 END IF;
4619 OE_MSG_PUB.Add;
4620
4621 IF l_debug_level > 0 THEN
4622 oe_debug_pub.add( 'COPY SUCCEEDED PARTIALLY FOR ORDER : ' || TO_CHAR ( L_HEADER_REC.ORDER_NUMBER ) , 1 ) ;
4623 END IF;
4624
4625 x_header_id := l_header_rec.header_id;
4626
4627 END IF; -- all_lines_failed
4628
4629 --debug information
4630 IF( l_all_lines_copied ) THEN
4631 IF l_debug_level > 0 THEN
4632 oe_debug_pub.add( ' ALL LINES COPIED : TRUE' , 5 ) ;
4633 END IF;
4634 ELSE
4635 IF l_debug_level > 0 THEN
4636 oe_debug_pub.add( ' ALL LINES COPIED : FALSE' , 5 ) ;
4637 END IF;
4638 END IF;
4639
4640 IF( l_all_lines_failed ) THEN
4641 IF l_debug_level > 0 THEN
4642 oe_debug_pub.add( ' ALL LINES FAILED : TRUE' , 5 ) ;
4643 END IF;
4644 ELSE
4645 IF l_debug_level > 0 THEN
4646 oe_debug_pub.add( ' ALL LINES FAILED : FALSE' , 5 ) ;
4647 END IF;
4648 END IF;
4649
4650 IF( l_delete_config ) THEN
4651 IF l_debug_level > 0 THEN
4652 oe_debug_pub.add( ' DELETE CONFIG : TRUE' , 5 ) ;
4653 END IF;
4654 ELSE
4655 IF l_debug_level > 0 THEN
4656 oe_debug_pub.add( ' DELETE CONFIG : FALSE' , 5 ) ;
4657 END IF;
4658 END IF;
4659 -- end of debug
4660
4661 ELSE -- l_header_exists
4662
4663 IF l_debug_level > 0 THEN
4664 oe_debug_pub.add( 'FAILED TO COPY ORDER' , 1 ) ;
4665 END IF;
4666
4667 FND_MESSAGE.SET_NAME('ONT','OE_CPY_COPY_FAILED');
4668 OE_MSG_PUB.Add;
4669
4670 END IF; -- header created or not;
4671
4672 IF ( l_delete_config ) THEN
4673 delete_config(l_top_model_tbl);
4674 END IF;
4675
4676 -- code ends here 1935675
4677
4678 /* Test 2288800 */
4679 j := l_line_tbl.FIRST;
4680 WHILE j IS NOT NULL LOOP
4681 BEGIN
4682 IF l_debug_level > 0 THEN
4683 oe_debug_pub.add( 'LINECOUNT : ' || TO_CHAR ( J ) , 1 ) ;
4684 END IF;
4685 l_line_tbl.DELETE(j);
4686 j := l_line_tbl.NEXT(j);
4687 END;
4688 END LOOP; -- loop on lines
4689 /* Test 2288800 */
4690
4691 END LOOP; -- l_hdr_lst
4692
4693 OE_MSG_PUB.Count_And_Get
4694 ( p_count => x_msg_count,
4695 p_data => x_msg_data );
4696
4697 -- for bug 1935675
4698 IF ( l_copy_partial_or_full ) THEN
4699 x_return_status := FND_API.G_RET_STS_SUCCESS;
4700 ELSE
4701 x_return_status := FND_API.G_RET_STS_ERROR;
4702 END IF;
4703 -- end 1935675;
4704
4705 G_LINE_PRICE_MODE := NULL;
4706
4707 IF l_debug_level > 0 THEN
4708 oe_debug_pub.add( 'RET STATUS SUCCESS ' || X_RETURN_STATUS , 1 ) ;
4709 END IF;
4710 IF l_debug_level > 0 THEN
4711 oe_debug_pub.add( 'EXITING OE_ORDER_COPY_UTIL.COPY_ORDER' , 1 ) ;
4712 END IF;
4713
4714 OE_DEBUG_PUB.DumpDebug;
4715
4716
4717 EXCEPTION
4718
4719 WHEN FND_API.G_EXC_ERROR THEN
4720
4721 IF l_debug_level > 0 THEN
4722 oe_debug_pub.add( 'IN G_EXC_ERROR ' , 1 ) ;
4723 END IF;
4724 G_LINE_PRICE_MODE := NULL;
4725
4726 x_return_status := FND_API.G_RET_STS_ERROR ;
4727 OE_MSG_PUB.Count_And_Get
4728 ( p_count => x_msg_count,
4729 p_data => x_msg_data
4730 );
4731 OE_DEBUG_PUB.DumpDebug;
4732
4733 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4734
4735 IF l_debug_level > 0 THEN
4736 oe_debug_pub.add( 'IN G_EXC_UNEXPECTED_ERROR' ) ;
4737 END IF;
4738 G_LINE_PRICE_MODE := NULL;
4739
4740 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4741 OE_MSG_PUB.Count_And_Get
4742 ( p_count => x_msg_count,
4743 p_data => x_msg_data
4744 );
4745 OE_DEBUG_PUB.DumpDebug;
4746
4747 WHEN OTHERS THEN
4748
4749 IF l_debug_level > 0 THEN
4750 oe_debug_pub.add( 'COPY_ORDER IN OTHERS '||SQLERRM , 1 ) ;
4751 END IF;
4752 G_LINE_PRICE_MODE := NULL;
4753
4754 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4755 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4756 THEN
4757 OE_MSG_PUB.Add_Exc_Msg
4758 ( G_PKG_NAME
4759 , l_api_name
4760 );
4761 END IF;
4762 OE_MSG_PUB.Count_And_Get
4763 ( p_count => x_msg_count,
4764 p_data => x_msg_data
4765 );
4766
4767 OE_DEBUG_PUB.DumpDebug;
4768
4769 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4770
4771 END Copy_Order;
4772
4773 -- Added for the ER 1480867
4774
4775 PROCEDURE EXTEND_TBL(p_num IN NUMBER)
4776 IS
4777 --
4778 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4779 --
4780 BEGIN
4781
4782 G_Line_Num_Rec.line_id.EXTEND(p_num);
4783 G_Line_Num_Rec.new_line_id.EXTEND(p_num);
4784 G_Line_Num_Rec.line_number.EXTEND(p_num);
4785 G_Line_Num_Rec.shipment_number.EXTEND(p_num);
4786 G_Line_Num_Rec.option_number.EXTEND(p_num);
4787 G_Line_Num_Rec.component_number.EXTEND(p_num);
4788 G_Line_Num_Rec.service_number.EXTEND(p_num);
4789 G_Line_Num_Rec.split_from_line_id.EXTEND(p_num);
4790 G_Line_Num_Rec.split_by.EXTEND(p_num);
4791
4792 END EXTEND_TBL;
4793
4794 -- Added for the ER 1480867
4795
4796 PROCEDURE DELETE_TBL
4797 IS
4798 --
4799 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4800 --
4801 BEGIN
4802
4803 G_Line_Num_Rec.line_id.DELETE;
4804 G_Line_Num_Rec.new_line_id.DELETE;
4805 G_Line_Num_Rec.line_number.DELETE;
4806 G_Line_Num_Rec.shipment_number.DELETE;
4807 G_Line_Num_Rec.option_number.DELETE;
4808 G_Line_Num_Rec.component_number.DELETE;
4809 G_Line_Num_Rec.service_number.DELETE;
4810 G_Line_Num_Rec.split_from_line_id.DELETE;
4811 G_Line_Num_Rec.split_by.DELETE;
4812
4813 END DELETE_TBL;
4814
4815 -- Added for the ER 1480867
4816
4817 PROCEDURE Process_Line_Numbers(p_header_id IN NUMBER)
4818 IS
4819 l_copied_rec Line_Number_Rec_Type;
4820 CURSOR C_Line_Nums IS
4821 SELECT line_id,
4822 line_number,
4823 shipment_number,
4824 option_number,
4825 component_number,
4826 service_number,
4827 split_from_line_id,
4828 source_document_Line_id,
4829 source_document_type_id,
4830 split_by,
4831 line_set_id,
4832 item_type_code,
4833 service_reference_line_id,
4834 link_to_line_id,
4835 top_model_line_id --9534576
4836 FROM oe_order_lines
4837 WHERE header_id = p_header_id
4838 ORDER BY line_number , shipment_number ,NVL(option_number, -1),
4839 NVL(component_number,-1),NVL(service_number,-1);
4840 l_split_by VARCHAR2(30);
4841 l_split_from_line_id BINARY_INTEGER;
4842 l_line_number_ctr BINARY_INTEGER;
4843 l_shipment_number_ctr BINARY_INTEGER;
4844 l_option_number_ctr BINARY_INTEGER;
4845 l_comp_number_ctr BINARY_INTEGER;
4846 l_service_number_ctr BINARY_INTEGER;
4847 k BINARY_INTEGER;
4848 l_counter BINARY_INTEGER;
4849
4850 TYPE l_number_tbl IS TABLE OF NUMBER
4851 INDEX BY BINARY_INTEGER;
4852 l_shipment_num_tbl l_number_tbl;
4853 l_option_num_tbl l_number_tbl; --Bug 5757050
4854 l_first_split_index l_number_tbl;
4855 l_prev_line_number NUMBER;
4856 l_line_number NUMBER;
4857 l_comp_number_tbl l_number_tbl;
4858 l_line_set_id NUMBER;
4859 --
4860 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4861 --
4862 BEGIN
4863
4864 IF l_debug_level > 0 THEN
4865 oe_debug_pub.add( 'ENTERING PROCESS_LINE_NUMBERS ' , 1 ) ;
4866 END IF;
4867 -- Get the lines from the copied order
4868 OPEN C_Line_Nums;
4869 FETCH C_Line_Nums BULK COLLECT INTO
4870 l_copied_rec.line_id,
4871 l_copied_rec.line_number,
4872 l_copied_rec.shipment_number,
4873 l_copied_rec.option_number,
4874 l_copied_rec.component_number,
4875 l_copied_rec.service_number,
4876 l_copied_rec.split_from_line_id,
4877 l_copied_rec.source_document_Line_id,
4878 l_copied_rec.source_document_type_id,
4879 l_copied_rec.split_by,
4880 l_copied_rec.line_set_id,
4881 l_copied_rec.item_type_code,
4882 l_copied_rec.service_reference_line_id,
4883 l_copied_rec.link_to_line_id,
4884 l_copied_rec.top_model_line_id;--9534576
4885
4886 CLOSE C_Line_Nums;
4887 IF l_debug_level > 0 THEN
4888 oe_debug_pub.add( 'CLOSING C_LINE_NUMS ' , 1 ) ;
4889 END IF;
4890
4891 -- Initialize the counters.
4892 l_line_number_ctr := NULL;
4893 l_shipment_number_ctr := NULL;
4894 l_option_number_ctr := NULL;
4895 l_comp_number_ctr := NULL;
4896 l_service_number_ctr := NULL;
4897 l_split_by := NULL;
4898 l_split_from_line_id := NULL;
4899
4900 IF l_debug_level > 0 THEN
4901 oe_debug_pub.add( 'C_LINE_NUMS COUNT IS '||L_COPIED_REC.LINE_ID.COUNT , 1 ) ;
4902 END IF;
4903
4904 -- Debugging loop, should be taken out
4905 FOR i in 1..l_copied_rec.line_id.COUNT LOOP
4906 IF l_debug_level > 0 THEN
4907 oe_debug_pub.add( 'LINE ID IS '||L_COPIED_REC.LINE_ID( I ) , 1 ) ;
4908 oe_debug_pub.add( 'ITEM TYPE CODE IS '||L_COPIED_REC.ITEM_TYPE_CODE ( I ) , 1 ) ;
4909 oe_debug_pub.add( 'set id IS '||L_COPIED_REC.line_set_id( I ) , 1 ) ;
4910 END IF;
4911 END LOOP;
4912
4913 l_prev_line_number := NULL;
4914 l_line_number := NULL;
4915
4916 FOR i in 1..l_copied_rec.line_id.COUNT LOOP
4917
4918 IF l_debug_level > 0 THEN
4919 oe_debug_pub.add( 'ITEM TYPE CODE IS '||L_COPIED_REC.ITEM_TYPE_CODE ( I ) , 1 ) ;
4920 END IF;
4921 -- Keep track of the original line_number
4922 l_line_number := l_copied_rec.line_number(i);
4923
4924 -- Need to track the shipment_numbers for Split Line Cases.
4925 -- So initialize is by setting to its own shipment_number returned by
4926 -- the l_copied_rec cursor
4927
4928 l_shipment_num_tbl(i) := l_copied_rec.shipment_number(i);
4929 l_option_num_tbl(i) := l_copied_rec.option_number(i); --Bug 5757050
4930
4931 -- This table keeps track of the Split_From line index. It points to the
4932 -- the first split line in the line set. Initialize this to NULL.
4933
4934 l_first_split_index(i) := NULL;
4935
4936 -- This table is used to track the link to line for included items and
4937 -- it keeps the track for the MAX component number under a KIT.
4938 l_comp_number_tbl(i) := l_copied_rec.component_number(i);
4939
4940
4941 -- Loop through the COPY Global Line Rec to find the match for the
4942 -- line_id and try to find whether the COPIED line is a aplit line.
4943
4944 -- If the line is a Service Line then get the line number components
4945 -- from the parent line.
4946
4947 IF l_copied_rec.item_type_code(i) = 'SERVICE' AND
4948 l_copied_rec.service_reference_line_id(i) IS NOT NULL
4949 THEN
4950 IF l_debug_level > 0 THEN
4951 oe_debug_pub.add( 'ENTERING SERVICE LINE' , 1 ) ;
4952 END IF;
4953
4954 FOR m in REVERSE 1..(i-1) LOOP
4955 IF l_copied_rec.line_id(m) =
4956 l_copied_rec.service_reference_line_id(i)
4957 THEN
4958 IF l_debug_level > 0 THEN
4959 oe_debug_pub.add( 'ENTERING SERVICE LINE M IS ' ||M , 1 ) ;
4960 END IF;
4961 l_copied_rec.line_number(i) := l_copied_rec.line_number(m);
4962 l_copied_rec.shipment_number(i) :=
4963 l_copied_rec.shipment_number(m);
4964 l_copied_rec.option_number(i) :=
4965 l_copied_rec.option_number(m);
4966 l_copied_rec.component_number(i) :=
4967 l_copied_rec.component_number(m);
4968 l_line_number_ctr := l_copied_rec.line_number(i);
4969 l_shipment_number_ctr := l_copied_rec.shipment_number(i);
4970 l_option_number_ctr := l_copied_rec.option_number(i);
4971 l_comp_number_ctr := l_copied_rec.component_number(i);
4972
4973 GOTO SERVICE_NUMBER;
4974 END IF;
4975
4976 END LOOP;
4977
4978 END IF;
4979
4980 -- If the line is an Included Item Line then get the line number
4981 -- components from the link to line id.
4982
4983 IF l_copied_rec.item_type_code(i) = 'INCLUDED'
4984 THEN
4985 IF l_debug_level > 0 THEN
4986 oe_debug_pub.add( 'ENTERING INCLUDED ITEM LINE ' , 1 ) ;
4987 END IF;
4988 -- Find the link_to_line_id to get the line numbers..
4989 FOR m in REVERSE 1..(i-1) LOOP
4990 IF l_copied_rec.line_id(m) =
4991 l_copied_rec.link_to_line_id(i)
4992 THEN
4993 IF l_debug_level > 0 THEN
4994 oe_debug_pub.add( 'LINK TO LINE ID IS ' ||L_COPIED_REC.LINE_ID ( M ) , 1 ) ;
4995 END IF;
4996 l_copied_rec.line_number(i) := l_copied_rec.line_number(m);
4997 l_copied_rec.shipment_number(i) :=
4998 l_copied_rec.shipment_number(m);
4999 l_copied_rec.option_number(i) :=
5000 l_copied_rec.option_number(m);
5001 l_line_number_ctr := l_copied_rec.line_number(i);
5002 l_shipment_number_ctr := l_copied_rec.shipment_number(i);
5003 l_option_number_ctr := l_copied_rec.option_number(i);
5004 l_comp_number_tbl(m) := nvl(l_comp_number_tbl(m),0) + 1;
5005 l_copied_rec.component_number(i) := l_comp_number_tbl(m);
5006 l_comp_number_ctr := l_comp_number_tbl(m);
5007
5008 GOTO COMPONENT_NUMBER;
5009 END IF;
5010
5011 END LOOP;
5012
5013 END IF;
5014
5015 /* Bug 5757050 */
5016 -- If the line is an Option Item Line then get the line number
5017 -- options from the link to line id.
5018
5019 -- IF l_copied_rec.item_type_code(i) = 'OPTION'
5020 IF l_copied_rec.item_type_code(i) in ('OPTION','CLASS') --9534576
5021 THEN
5022 IF l_debug_level > 0 THEN
5023 oe_debug_pub.add( 'ENTERING OPTION ITEM LINE ' , 1 ) ;
5024 END IF;
5025 -- Find the link_to_line_id to get the line numbers..
5026 FOR m in REVERSE 1..(i-1) LOOP
5027 IF l_copied_rec.line_id(m) =
5028 l_copied_rec.link_to_line_id(i)
5029 THEN
5030 IF l_debug_level > 0 THEN
5031 oe_debug_pub.add( 'LINK TO LINE ID IS ' ||L_COPIED_REC.LINE_ID ( M) , 1 ) ;
5032 END IF;
5033 l_copied_rec.line_number(i) := l_copied_rec.line_number(m);
5034 l_copied_rec.shipment_number(i) :=
5035 l_copied_rec.shipment_number(m);
5036
5037 l_option_num_tbl(m) := NVL(l_option_num_tbl(m),0) + 1;
5038 l_copied_rec.option_number(i) := l_option_num_tbl(m);
5039 l_copied_rec.component_number(i) := l_copied_rec.component_number(m);
5040
5041
5042 l_line_number_ctr := l_copied_rec.line_number(i);
5043 l_shipment_number_ctr := l_copied_rec.shipment_number(i);
5044 l_option_number_ctr := l_option_num_tbl(m);
5045 l_comp_number_ctr := l_copied_rec.component_number(i);
5046 ----9534576 adding new loop
5047 FOR n IN REVERSE 1..(i-1) LOOP
5048
5049 IF l_copied_rec.top_model_line_id(n)=l_copied_rec.top_model_line_id(i)
5050 AND l_copied_rec.option_number(n)>= l_option_number_ctr THEN
5051 --suneela loop
5052
5053 l_option_number_ctr := l_copied_rec.option_number(n)+1;
5054 -- l_option_num_tbl(m) := l_option_number_ctr;
5055 l_copied_rec.option_number(i) := l_option_number_ctr;
5056
5057 END IF ;
5058
5059 END LOOP ;
5060 ----9534576 ending new loop
5061 GOTO OPTION_NUMBER;
5062 END IF;
5063
5064 END LOOP;
5065
5066 END IF;
5067 /*END Bug 5757050 */
5068
5069 -- Ignore the line if it is not created by COPY. This may also include
5070 -- lines which are created as a part of the COPY call.
5071
5072 IF NOT OE_GLOBALS.EQUAL(l_copied_rec.source_document_type_id(i),2) THEN
5073 IF l_debug_level > 0 THEN
5074 oe_debug_pub.add( 'THIS IS NON COPIED LINE' , 1 ) ;
5075 END IF;
5076 GOTO NOT_COPIED_LINE;
5077 END IF;
5078
5079 -- Loop through the global copy rec to find out the match for Split Line
5080 -- cases.
5081
5082 FOR j in 1..G_Line_Num_Rec.line_id.COUNT LOOP
5083
5084 -- If the line is not a SPLIT line case then assign line numbers
5085 -- from the counters.
5086
5087 IF NOT ( l_copied_rec.line_id(i) = G_Line_Num_Rec.new_line_id(j) AND
5088 G_Line_Num_Rec.split_from_line_id(j) IS NOT NULL AND
5089 l_copied_rec.line_set_id(i) IS NOT NULL)
5090 THEN
5091 IF l_debug_level > 0 THEN
5092 oe_debug_pub.add( 'NON-SPLIT LINE' , 1 ) ;
5093 END IF;
5094 goto CONTINUE_LOOP;
5095 END IF;
5096
5097 IF l_debug_level > 0 THEN
5098 oe_debug_pub.add( 'SEARCHING FOR MATCH' , 1 ) ;
5099 END IF;
5100 -- Loop through the Copied Rec of tables to find the parent line
5101 FOR m in REVERSE 1..(i-1) LOOP
5102
5103 IF G_Line_Num_Rec.split_from_line_id(j) =
5104 l_copied_rec.line_id(m)
5105 THEN
5106 IF l_debug_level > 0 THEN
5107 oe_debug_pub.add( 'NEW_LINE_ID IS '||G_LINE_NUM_REC.NEW_LINE_ID ( J ) , 1 ) ;
5108 oe_debug_pub.add( 'COPY LINE_ID IS '||L_COPIED_REC.LINE_ID ( I ) , 1 ) ;
5109 oe_debug_pub.add( 'SPLIT_FROM_LINE_ID IS '||G_LINE_NUM_REC.SPLIT_FROM_LINE_ID ( J ) , 1 ) ;
5110 oe_debug_pub.add( 'MATCH FOUND WITH SPLIT FROM LINE_ID' , 1 ) ;
5111 END IF;
5112 IF l_copied_rec.line_set_id(m) IS NULL THEN
5113
5114 SELECT OE_SETS_S.NEXTVAL
5115 INTO l_copied_rec.line_set_id(m)
5116 FROM DUAL;
5117 /*
5118 Create_Line_Set(
5119 p_line_id => l_copied_rec.line_id(m),
5120 p_line_set_id => l_copied_rec.line_set_id(m)
5121 );
5122 */
5123 END IF;
5124
5125 -- Set the split_by on the parent line.
5126 l_copied_rec.split_by(m) := 'USER';
5127
5128 l_copied_rec.line_number(i) := l_copied_rec.line_number(m);
5129 l_copied_rec.line_set_id(i) := l_copied_rec.line_set_id(m);
5130 l_first_split_index(i) := m;
5131
5132 -- Added logic to figure out the original line in the
5133 -- Split Set. l_first_split_index will store the split from
5134 -- line index for each line.
5135
5136 k := i;
5137 l_counter := 1;
5138 WHILE (l_first_split_index(k) is NOT NULL)
5139 LOOP
5140 k := l_first_split_index(k);
5141 l_counter := l_counter + 1;
5142 IF l_counter > l_copied_rec.line_id.COUNT THEN
5143 EXIT;
5144 END IF;
5145
5146 END LOOP;
5147 IF l_debug_level > 0 THEN
5148 oe_debug_pub.add( 'THE SPLIT FROM IS M '||M , 1 ) ;
5149 oe_debug_pub.add( 'THE L_COUNTER IS '||L_COUNTER , 1 ) ;
5150 oe_debug_pub.add( 'THE FIRST SPLIT FROM INDEX K IS '||K , 1 ) ;
5151 oe_debug_pub.add( 'SHIPMENT_NUMBER FOR K IS '||L_SHIPMENT_NUM_TBL ( K ) , 1 ) ;
5152 END IF;
5153
5154 l_shipment_num_tbl(k) := l_shipment_num_tbl(k) + 1;
5155
5156 -- Set the shipment number
5157 l_copied_rec.shipment_number(i) := l_shipment_num_tbl(k);
5158 l_shipment_number_ctr := l_copied_rec.shipment_number(i); --9534576
5159 l_copied_rec.split_from_line_id(i) :=
5160 G_Line_Num_Rec.split_from_line_id(j);
5161 l_copied_rec.split_by(i) := G_Line_Num_Rec.split_by(j);
5162
5163 l_shipment_num_tbl(i) := l_copied_rec.shipment_number(i);
5164 l_copied_rec.option_number(i) :=
5165 G_Line_Num_Rec.option_number(j);
5166 l_copied_rec.component_number(i) :=
5167 G_Line_Num_Rec.component_number(j);
5168 l_copied_rec.service_number(i) :=
5169 G_Line_Num_Rec.service_number(j);
5170
5171 GOTO post_line_ship;
5172 END IF;
5173
5174 END LOOP;
5175 <<CONTINUE_LOOP>>
5176 NULL;
5177 END LOOP;
5178
5179 <<NOT_COPIED_LINE>>
5180
5181
5182 IF l_copied_rec.line_number(i) IS NOT NULL AND
5183 NOT OE_GLOBALS.EQUAL(l_line_number_ctr,l_copied_rec.line_number(i))
5184 AND NOT OE_GLOBALS.EQUAL(l_copied_rec.line_number(i),
5185 l_prev_line_number)
5186 THEN
5187 l_line_number_ctr := NVL(l_line_number_ctr,0) + 1;
5188 l_shipment_number_ctr := NULL;
5189 l_option_number_ctr := NULL;
5190 l_comp_number_ctr := NULL;
5191 l_service_number_ctr := NULL;
5192 IF l_debug_level > 0 THEN
5193 oe_debug_pub.add( 'IN L_LINE_NUMBER_CTR' , 1 ) ;
5194 END IF;
5195 END IF;
5196
5197 l_copied_rec.line_number(i) := l_line_number_ctr;
5198
5199 IF l_copied_rec.shipment_number(i) IS NOT NULL AND
5200 NOT OE_GLOBALS.EQUAL(l_shipment_number_ctr,
5201 l_copied_rec.shipment_number(i))
5202 THEN
5203 -- l_shipment_number_ctr := NVL(l_shipment_number_ctr,0) + 1;
5204 IF l_shipment_number_ctr IS NULL
5205 OR l_shipment_number_ctr<l_copied_rec.shipment_number(i)THEN --9534576
5206 l_shipment_number_ctr := NVL(l_shipment_number_ctr,0) + 1;
5207 END IF ; --9534576
5208 l_option_number_ctr := NULL;
5209 l_comp_number_ctr := NULL;
5210 l_service_number_ctr := NULL;
5211 IF l_debug_level > 0 THEN
5212 oe_debug_pub.add( 'IN L_SHIPMENT_NUMBER_CTR' , 1 ) ;
5213 END IF;
5214 END IF;
5215
5216 l_copied_rec.shipment_number(i) := l_shipment_number_ctr;
5217
5218 <<OPTION_NUMBER>> --Bug5757050
5219 IF l_copied_rec.option_number(i) IS NOT NULL AND
5220 NOT OE_GLOBALS.EQUAL(l_option_number_ctr,
5221 l_copied_rec.option_number(i))
5222 THEN
5223 l_option_number_ctr := NVL(l_option_number_ctr,0) + 1;
5224 l_comp_number_ctr := NULL;
5225 l_service_number_ctr := NULL;
5226 IF l_debug_level > 0 THEN
5227 oe_debug_pub.add( 'IN L_OPTION_NUMBER_CTR' , 1 ) ;
5228 END IF;
5229 END IF;
5230
5231 l_copied_rec.option_number(i) := l_option_number_ctr;
5232
5233 <<COMPONENT_NUMBER>>
5234 IF l_copied_rec.component_number(i) IS NOT NULL AND
5235 NOT OE_GLOBALS.EQUAL(l_comp_number_ctr,
5236 l_copied_rec.component_number(i))
5237 THEN
5238 l_comp_number_ctr := NVL(l_comp_number_ctr,0) + 1;
5239 l_service_number_ctr := NULL;
5240 IF l_debug_level > 0 THEN
5241 oe_debug_pub.add( 'IN L_COMP_NUMBER_CTR' , 1 ) ;
5242 END IF;
5243 END IF;
5244
5245 l_copied_rec.component_number(i) := l_comp_number_ctr;
5246
5247 <<SERVICE_NUMBER>>
5248 IF l_copied_rec.service_number(i) IS NOT NULL AND
5249 NOT OE_GLOBALS.EQUAL(l_service_number_ctr,
5250 l_copied_rec.service_number(i))
5251 THEN
5252 l_service_number_ctr := NVL(l_service_number_ctr,0) + 1;
5253 IF l_debug_level > 0 THEN
5254 oe_debug_pub.add( 'IN L_SERVICE_NUMBER_CTR' , 1 ) ;
5255 END IF;
5256 l_copied_rec.service_number(i) := l_service_number_ctr;
5257 END IF;
5258
5259
5260 <<post_line_ship>> -- All Numbers already assigned.
5261
5262 NULL;
5263 l_prev_line_number := l_line_number;
5264 END LOOP;
5265
5266 -- Added following loop for debuging
5267 FOR i in 1..l_copied_rec.line_id.COUNT LOOP
5268 IF l_debug_level > 0 THEN
5269 oe_debug_pub.add( 'LINE ID IS '||L_COPIED_REC.LINE_ID ( I ) , 1 ) ;
5270 oe_debug_pub.add( 'ITEM TYPE CODE IS '||L_COPIED_REC.ITEM_TYPE_CODE ( I ) , 1 ) ;
5271 END IF;
5272
5273 END LOOP;
5274 k := l_copied_rec.line_id.COUNT;
5275
5276 IF l_debug_level > 0 THEN
5277 oe_debug_pub.add( 'UPDATE ORDER LINES IN BULK' , 1 ) ;
5278 END IF;
5279 FORALL i in 1..K
5280 UPDATE OE_ORDER_LINES
5281 SET line_number = l_copied_rec.line_number(i)
5282 , shipment_number = l_copied_rec.shipment_number(i)
5283 , option_number = l_copied_rec.option_number(i)
5284 , component_number = l_copied_rec.component_number(i)
5285 , service_number = l_copied_rec.service_number(i)
5286 , split_from_line_id = l_copied_rec.split_from_line_id(i)
5287 , split_by = l_copied_rec.split_by(i)
5288 , line_set_id = l_copied_rec.line_set_id(i)
5289 WHERE line_id = l_copied_rec.line_id(i);
5290
5291 IF l_debug_level > 0 THEN
5292 oe_debug_pub.add( ' AFTER UPDATE ORDER LINES IN BULK' , 1 ) ;
5293 END IF;
5294 l_copied_rec.line_id.delete;
5295 l_copied_rec.line_number.delete;
5296 l_copied_rec.shipment_number.delete;
5297 l_copied_rec.option_number.delete;
5298 l_copied_rec.component_number.delete;
5299 l_copied_rec.service_number.delete;
5300 l_copied_rec.split_from_line_id.delete;
5301 l_copied_rec.source_document_Line_id.delete;
5302 l_copied_rec.source_document_type_id.delete;
5303 l_copied_rec.split_by.delete;
5304 l_copied_rec.line_set_id.delete;
5305 IF l_debug_level > 0 THEN
5306 oe_debug_pub.add( 'AFTER CLEAR L_COPY_REC' , 1 ) ;
5307 END IF;
5308
5309 EXCEPTION
5310 WHEN OTHERS THEN
5311 IF l_debug_level > 0 THEN
5312 oe_debug_pub.add( 'OTHERS ERROR , PROCESS_LINE_NUMBERS' ) ;
5313 oe_debug_pub.add( SUBSTR ( SQLERRM , 1 , 240 ) ) ;
5314 END IF;
5315 OE_MSG_PUB.Add_Exc_Msg
5316 ( G_PKG_NAME
5317 , 'Process_Line_Numbers'
5318 );
5319 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5320 END Process_Line_Numbers;
5321
5322 PROCEDURE Create_Line_Set(
5323 p_src_line_id IN NUMBER,
5324 p_line_id IN NUMBER,
5325 p_line_set_id IN NUMBER,
5326 p_header_id IN NUMBER,
5327 p_line_type_id IN NUMBER
5328 ) IS
5329 --
5330 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5331 --
5332 BEGIN
5333
5334 INSERT INTO OE_SETS(
5335 SET_ID
5336 , SET_NAME
5337 , SET_TYPE
5338 , Header_Id
5339 , inventory_item_id
5340 , ordered_quantity_uom
5341 , line_type_id
5342 , Ship_tolerance_above
5343 , ship_tolerance_below
5344 , CREATED_BY
5345 , CREATION_DATE
5346 , UPDATE_DATE
5347 , UPDATED_BY
5348 )
5349 SELECT
5350 p_line_set_id
5351 , to_char(p_line_id)
5352 , 'SPLIT'
5353 , p_header_id
5354 , l.inventory_item_id
5355 , l.order_quantity_uom
5356 , p_line_type_id
5357 , l.Ship_tolerance_above
5358 , l.ship_tolerance_below
5359 , FND_GLOBAL.USER_ID
5360 , sysdate
5361 , sysdate
5362 , 1001
5363 FROM OE_ORDER_LINES l
5364 WHERE line_id = p_src_line_id;
5365
5366 END Create_Line_Set;
5367
5368 -- Comment Label for procedure added as part of Inline Documentation Drive.
5369 ---------------------------------------------------------------------------------
5370 -- Procedure Name : Sort_Line_Tbl
5371 -- Input Params : p_line_id_tbl : Table of Lines to be sorted.
5372 -- p_version_number : Version of Lines to be sorted for Copy.
5373 -- p_phase_change_flag : To designate whether phase has changed
5374 -- from Fulfillment to Negotiation or
5375 -- vice versa.
5376 -- p_num_lines : Number of Lines to be sorted.
5377 -- Output Params : x_line_tbl : Sorted table of lines for Copy.
5378 -- Description : This procedure sorts the Table of Lines that need to be copied
5379 -- and gets them ready for Copy in Order. If there are any
5380 -- Configuration lines, or lines pertaining to any particular
5381 -- sales order version that need to be copied, it gets those
5382 -- lines in order and returns the list of sorted lines ready to
5383 -- be copied in the x_line_tbl. This procedure is exclusively
5384 -- used in this package only and in this particular flow only
5385 -- and not used anywhere else in any other flow in the product.
5386 -- This is called from the Load Lines procedure if any
5387 -- lines are being copied.
5388 ---------------------------------------------------------------------------------
5389
5390 PROCEDURE sort_line_tbl(p_line_id_tbl IN OE_GLOBALS.Selected_Record_Tbl,
5391 p_version_number IN NUMBER,
5392 p_phase_change_flag IN VARCHAR2,
5393 p_num_lines IN NUMBER,
5394 x_line_tbl IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type)
5395 IS
5396 i binary_integer := 1;
5397 j binary_integer := 1;
5398 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5399 l_line_id T_NUM := T_NUM();
5400 l_source T_V1 := T_V1();
5401 l_line_rec OE_Order_PUB.Line_Rec_Type;
5402 CURSOR C_MODEL IS
5403 SELECT line_id
5404 FROM OE_COPY_LINE_SORT_TMP
5405 WHERE top_model_line_id = line_id;
5406
5407 BEGIN
5408 IF l_debug_level > 0 THEN
5409 oe_debug_pub.add('Entering load_lines '||to_char(p_num_lines));
5410 END IF;
5411 -- Extend the tables
5412 l_line_id.EXTEND(p_num_lines);
5413
5414 -- Get the line ids sorted and insert them into the COPY temp table
5415
5416 i:= p_line_id_tbl.FIRST;
5417 WHILE i <= p_line_id_tbl.LAST LOOP
5418 l_line_id(j) := p_line_id_tbl(i).id1;
5419 IF l_debug_level > 0 THEN
5420 oe_debug_pub.add(' The line id is '|| l_line_id(j),1);
5421 END IF;
5422 j := j + 1;
5423 i := p_line_id_tbl.NEXT(i);
5424 END LOOP;
5425
5426 -- Few code changes have been done for bug 7443507. This is just for performance
5427 -- tuning. To remove NVL function from query, the value of the p_version_number
5428 -- is been checked before the query and accordingly the query is modified to
5429 -- either check for or not check the p_version_number value, in new IF - ELSE.
5430 -- Also, the condition to check for line_id not being same as top_model_line_id,
5431 -- the condition line_id <> top_model_line_id was commented and the item_type_code
5432 -- condition was modified to include 'MODEL' and 'KIT', wherever needed.
5433
5434 IF p_phase_change_flag = 'Y' THEN
5435 IF l_debug_level > 0 THEN
5436 oe_debug_pub.add(' For Phase Change ',1);
5437 END IF;
5438
5439 IF p_version_number IS NOT NULL THEN --bug 7443507
5440
5441 FORALL i IN 1..l_line_id.COUNT
5442 INSERT INTO OE_COPY_LINE_SORT_TMP(
5443 line_id,
5444 version_number,
5445 header_id,
5446 line_number,
5447 shipment_number,
5448 option_number,
5449 component_number,
5450 service_number,
5451 phase_change_flag,
5452 top_model_line_id,
5453 item_type_code
5454 )
5455 SELECT
5456 l_line_id(i),
5457 p_version_number,
5458 l.header_id,
5459 l.line_number,
5460 l.shipment_number,
5461 l.option_number,
5462 l.component_number,
5463 l.service_number,
5464 'Y',
5465 l.top_model_line_id,
5466 l.item_type_code
5467 FROM
5468 oe_order_lines_history l
5469 WHERE l.line_id = l_line_id(i)
5470 --and l.version_number = NVL(p_version_number,l.version_number) -- bug 7443507
5471 and l.version_number = p_version_number -- bug 7443507
5472 and l.phase_change_flag = 'Y';
5473
5474 ELSE -- bug 7443507
5475
5476 FORALL i IN 1..l_line_id.COUNT
5477
5478 -- bug 7443507 new code added
5479 INSERT INTO OE_COPY_LINE_SORT_TMP(
5480 line_id,
5481 version_number,
5482 header_id,
5483 line_number,
5484 shipment_number,
5485 option_number,
5486 component_number,
5487 service_number,
5488 phase_change_flag,
5489 top_model_line_id,
5490 item_type_code
5491 )
5492 SELECT
5493 l_line_id(i),
5494 p_version_number,
5495 l.header_id,
5496 l.line_number,
5497 l.shipment_number,
5498 l.option_number,
5499 l.component_number,
5500 l.service_number,
5501 'Y',
5502 l.top_model_line_id,
5503 l.item_type_code
5504 FROM
5505 oe_order_lines_history l
5506 WHERE l.line_id = l_line_id(i)
5507 and l.phase_change_flag = 'Y';
5508
5509 -- bug 7443507 new code ends.
5510 END IF; -- bug 7443507
5511
5512 -- For line level copy, we are exploding the full config if
5513 -- top model line has been selected for copy.
5514 IF G_NEED_TO_EXPLODE_CONFIG THEN
5515 DELETE FROM OE_COPY_LINE_SORT_TMP a
5516 WHERE a.top_model_line_id is NOT NULL
5517 AND a.line_id <> a.top_model_line_id
5518 AND EXISTS (select b.line_id
5519 from OE_COPY_LINE_SORT_TMP b
5520 WHERE b.line_id = a.top_model_line_id);
5521
5522 -- Select records for Model Line, get all child lines except
5523 -- for CONFIG item and INCLUDED items as we do not copy them.
5524
5525 IF p_version_number IS NOT NULL THEN -- bug 7443507
5526
5527 INSERT INTO OE_COPY_LINE_SORT_TMP(
5528 line_id,
5529 version_number,
5530 header_id,
5531 line_number,
5532 shipment_number,
5533 option_number,
5534 component_number,
5535 service_number,
5536 phase_change_flag,
5537 top_model_line_id,
5538 item_type_code
5539 )
5540 SELECT
5541 l.line_id,
5542 p_version_number,
5543 l.header_id,
5544 l.line_number,
5545 l.shipment_number,
5546 l.option_number,
5547 l.component_number,
5548 l.service_number,
5549 'Y',
5550 l.top_model_line_id,
5551 l.item_type_code
5552 FROM
5553 oe_order_lines_history l,
5554 oe_copy_line_sort_tmp c
5555 WHERE c.line_id = c.top_model_line_id
5556 and l.top_model_line_id = c.line_id
5557 --and l.line_id <> l.top_model_line_id -- bug 7443507
5558 and l.item_type_code not in ('CONFIG','INCLUDED','MODEL','KIT') -- bug 7443507
5559 --and l.version_number = NVL(p_version_number,l.version_number) -- bug 7443507
5560 and l.version_number = p_version_number -- bug 7443507
5561 and l.phase_change_flag = 'Y';
5562
5563 ELSE --bug 7443507
5564 -- bug 7443507 new code added
5565 INSERT INTO OE_COPY_LINE_SORT_TMP(
5566 line_id,
5567 version_number,
5568 header_id,
5569 line_number,
5570 shipment_number,
5571 option_number,
5572 component_number,
5573 service_number,
5574 phase_change_flag,
5575 top_model_line_id,
5576 item_type_code
5577 )
5578 SELECT
5579 l.line_id,
5580 p_version_number,
5581 l.header_id,
5582 l.line_number,
5583 l.shipment_number,
5584 l.option_number,
5585 l.component_number,
5586 l.service_number,
5587 'Y',
5588 l.top_model_line_id,
5589 l.item_type_code
5590 FROM
5591 oe_order_lines_history l,
5592 oe_copy_line_sort_tmp c
5593 WHERE c.line_id = c.top_model_line_id
5594 and l.top_model_line_id = c.line_id
5595 and l.item_type_code not in ('CONFIG','INCLUDED','MODEL','KIT')
5596 and l.phase_change_flag = 'Y';
5597
5598 --bug 7443507 new code ends
5599 END IF; --bug 7443507
5600
5601 END IF; -- IF G_NEED_TO_EXPLODE_CONFIG THEN
5602 ELSE
5603
5604 IF p_version_number IS NOT NULL THEN -- bug 7443507
5605
5606 FORALL i IN 1..l_line_id.COUNT
5607 INSERT INTO OE_COPY_LINE_SORT_TMP(
5608 line_id,
5609 version_number,
5610 header_id,
5611 line_number,
5612 shipment_number,
5613 option_number,
5614 component_number,
5615 service_number,
5616 top_model_line_id,
5617 item_type_code
5618 )
5619 SELECT
5620 l_line_id(i),
5621 p_version_number,
5622 l.header_id,
5623 l.line_number,
5624 l.shipment_number,
5625 l.option_number,
5626 l.component_number,
5627 l.service_number,
5628 l.top_model_line_id,
5629 l.item_type_code
5630 FROM
5631 oe_order_lines l,
5632 oe_order_headers h
5633 WHERE l.line_id = l_line_id(i)
5634 and l.header_id = h.header_id
5635 --and h.version_number = NVL(p_version_number,h.version_number) -- bug 7443507
5636 and h.version_number = p_version_number -- bug 7443507
5637 UNION
5638 SELECT
5639 l_line_id(i),
5640 p_version_number,
5641 l.header_id,
5642 l.line_number,
5643 l.shipment_number,
5644 l.option_number,
5645 l.component_number,
5646 l.service_number,
5647 l.top_model_line_id,
5648 l.item_type_code
5649 FROM
5650 oe_order_lines_history l
5651 WHERE l.line_id = l_line_id(i)
5652 --and l.version_number = NVL(p_version_number,-1) --bug 7443507
5653 and l.version_number = p_version_number -- bug 7443507
5654 and l.version_flag = 'Y';
5655
5656 ELSE --bug 7443507
5657
5658 FORALL i IN 1..l_line_id.COUNT
5659 --bug 7443507 new code added
5660 INSERT INTO OE_COPY_LINE_SORT_TMP(
5661 line_id,
5662 version_number,
5663 header_id,
5664 line_number,
5665 shipment_number,
5666 option_number,
5667 component_number,
5668 service_number,
5669 top_model_line_id,
5670 item_type_code
5671 )
5672 SELECT
5673 l_line_id(i),
5674 p_version_number,
5675 l.header_id,
5676 l.line_number,
5677 l.shipment_number,
5678 l.option_number,
5679 l.component_number,
5680 l.service_number,
5681 l.top_model_line_id,
5682 l.item_type_code
5683 FROM
5684 oe_order_lines l,
5685 oe_order_headers h
5686 WHERE l.line_id = l_line_id(i)
5687 and l.header_id = h.header_id;
5688
5689 --bug 7443507 new code ends
5690 END IF; --bug 7443507
5691
5692
5693 -- For line level copy, we are exploding the full config if
5694 -- top model line has been selected for copy.
5695
5696 IF G_NEED_TO_EXPLODE_CONFIG THEN
5697
5698 DELETE FROM OE_COPY_LINE_SORT_TMP a
5699 WHERE a.top_model_line_id is NOT NULL
5700 AND a.line_id <> a.top_model_line_id
5701 AND EXISTS (select b.line_id
5702 from OE_COPY_LINE_SORT_TMP b
5703 WHERE b.line_id = a.top_model_line_id);
5704
5705 -- Select records for Model Line, get all child lines except
5706 -- for CONFIG item and INCLUDED items as we do not copy them.
5707
5708 IF p_version_number IS NOT NULL THEN -- bug 7443507
5709
5710 INSERT INTO OE_COPY_LINE_SORT_TMP(
5711 line_id,
5712 version_number,
5713 header_id,
5714 line_number,
5715 shipment_number,
5716 option_number,
5717 component_number,
5718 service_number,
5719 top_model_line_id,
5720 item_type_code
5721 )
5722 SELECT
5723 l.line_id,
5724 p_version_number,
5725 l.header_id,
5726 l.line_number,
5727 l.shipment_number,
5728 l.option_number,
5729 l.component_number,
5730 l.service_number,
5731 l.top_model_line_id,
5732 l.item_type_code
5733 FROM
5734 oe_order_lines l,
5735 oe_order_headers h,
5736 oe_copy_line_sort_tmp c
5737 WHERE c.line_id = c.top_model_line_id
5738 and l.top_model_line_id = c.line_id
5739 --and l.line_id <> l.top_model_line_id --bug 7443507
5740 and l.item_type_code not in ('CONFIG','INCLUDED','MODEL','KIT') --bug 7443507
5741 and l.header_id = h.header_id
5742 --and h.version_number = NVL(p_version_number,h.version_number) --bug 7443507
5743 and h.version_number = p_version_number --bug 7443507
5744 UNION
5745 SELECT
5746 l.line_id,
5747 p_version_number,
5748 l.header_id,
5749 l.line_number,
5750 l.shipment_number,
5751 l.option_number,
5752 l.component_number,
5753 l.service_number,
5754 l.top_model_line_id,
5755 l.item_type_code
5756 FROM
5757 oe_order_lines_history l,
5758 oe_copy_line_sort_tmp c
5759 WHERE c.line_id = c.top_model_line_id
5760 and l.top_model_line_id = c.line_id
5761 --and l.line_id <> l.top_model_line_id -- bug 7443507
5762 and l.item_type_code not in ('CONFIG','INCLUDED','MODEL','KIT') -- bug 7443507
5763 --and l.version_number = NVL(p_version_number,-1) -- bug 7443507
5764 and l.version_number = p_version_number -- bug 7443507
5765 and l.version_flag = 'Y';
5766
5767 ELSE --bug 7443507
5768 --bug 7443507 new code added
5769
5770 INSERT INTO OE_COPY_LINE_SORT_TMP(
5771 line_id,
5772 version_number,
5773 header_id,
5774 line_number,
5775 shipment_number,
5776 option_number,
5777 component_number,
5778 service_number,
5779 top_model_line_id,
5780 item_type_code
5781 )
5782 SELECT
5783 l.line_id,
5784 p_version_number,
5785 l.header_id,
5786 l.line_number,
5787 l.shipment_number,
5788 l.option_number,
5789 l.component_number,
5790 l.service_number,
5791 l.top_model_line_id,
5792 l.item_type_code
5793 FROM
5794 oe_order_lines l,
5795 oe_order_headers h,
5796 oe_copy_line_sort_tmp c
5797 WHERE c.line_id = c.top_model_line_id
5798 and l.top_model_line_id = c.line_id
5799 and l.item_type_code not in ('CONFIG','INCLUDED','MODEL','KIT')
5800 and l.header_id = h.header_id;
5801
5802 --bug 7443507 new code ends
5803 END IF; --bug 7443507
5804
5805 END IF; -- IF G_NEED_TO_EXPLODE_CONFIG THEN
5806
5807 END IF;
5808
5809 -- Clear the line_id table
5810
5811 IF l_line_id.COUNT > 0 THEN
5812 l_line_id.DELETE;
5813 END IF;
5814
5815 -- Select the data from TEMP table and sort it by line numbers..
5816
5817 SELECT line_id
5818 BULK COLLECT INTO
5819 l_line_id
5820 FROM OE_COPY_LINE_SORT_TMP
5821 ORDER BY header_id, line_number, shipment_number, NVL(option_number, -1),
5822 NVL(component_number,-1),NVL(service_number,-1);
5823
5824 -- Populate the full line record by calling the oe_line_util.query_row
5825
5826 FOR i IN 1..l_line_id.COUNT LOOP
5827
5828 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
5829 OE_Version_History_UTIL.query_row(
5830 p_line_id => l_line_id(i)
5831 ,p_version_number => p_version_number
5832 ,p_phase_change_flag => p_phase_change_flag
5833 ,x_line_rec => l_line_rec);
5834 ELSE
5835 OE_Line_Util.Query_Row(p_line_id => l_line_id(i),
5836 x_line_rec => l_line_rec);
5837 END IF;
5838 x_line_tbl(i) := l_line_rec;
5839 END LOOP;
5840 IF l_debug_level > 0 THEN
5841 oe_debug_pub.add('The Line Table Count is ' || x_line_tbl.COUNT);
5842 END IF;
5843
5844 EXCEPTION
5845 WHEN OTHERS THEN
5846 oe_debug_pub.add('In Others exception');
5847 oe_debug_pub.add( SUBSTR ( SQLERRM , 1 , 240 ) ) ;
5848 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5849
5850 END sort_line_tbl;
5851
5852
5853 PROCEDURE copy_line_dff_from_ref
5854 (p_ref_line_rec IN OE_Order_PUB.Line_Rec_Type,
5855 p_x_line_rec IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type)
5856 IS
5857 BEGIN
5858 p_x_line_rec.context := p_ref_line_rec.context;
5859 p_x_line_rec.attribute1 := p_ref_line_rec.attribute1;
5860 p_x_line_rec.attribute2 := p_ref_line_rec.attribute2;
5861 p_x_line_rec.attribute3 := p_ref_line_rec.attribute3;
5862 p_x_line_rec.attribute4 := p_ref_line_rec.attribute4;
5863 p_x_line_rec.attribute5 := p_ref_line_rec.attribute5;
5864 p_x_line_rec.attribute6 := p_ref_line_rec.attribute6;
5865 p_x_line_rec.attribute7 := p_ref_line_rec.attribute7;
5866 p_x_line_rec.attribute8 := p_ref_line_rec.attribute8;
5867 p_x_line_rec.attribute9 := p_ref_line_rec.attribute9;
5868 p_x_line_rec.attribute10 := p_ref_line_rec.attribute10;
5869 p_x_line_rec.attribute11 := p_ref_line_rec.attribute11;
5870 p_x_line_rec.attribute12 := p_ref_line_rec.attribute12;
5871 p_x_line_rec.attribute13 := p_ref_line_rec.attribute13;
5872 p_x_line_rec.attribute14 := p_ref_line_rec.attribute14;
5873 p_x_line_rec.attribute15 := p_ref_line_rec.attribute15;
5874 p_x_line_rec.attribute16 := p_ref_line_rec.attribute16;
5875 p_x_line_rec.attribute17 := p_ref_line_rec.attribute17;
5876 p_x_line_rec.attribute18 := p_ref_line_rec.attribute18;
5877 p_x_line_rec.attribute19 := p_ref_line_rec.attribute19;
5878 p_x_line_rec.attribute20 := p_ref_line_rec.attribute20;
5879
5880 -- Retain the Global DFF Info
5881 p_x_line_rec.global_attribute_category
5882 := p_ref_line_rec.global_attribute_category;
5883 p_x_line_rec.global_attribute1 := p_ref_line_rec.global_attribute1;
5884 p_x_line_rec.global_attribute2 := p_ref_line_rec.global_attribute2;
5885 p_x_line_rec.global_attribute3 := p_ref_line_rec.global_attribute3;
5886 p_x_line_rec.global_attribute4 := p_ref_line_rec.global_attribute4;
5887 p_x_line_rec.global_attribute5 := p_ref_line_rec.global_attribute5;
5888 p_x_line_rec.global_attribute6 := p_ref_line_rec.global_attribute6;
5889 p_x_line_rec.global_attribute7 := p_ref_line_rec.global_attribute7;
5890 p_x_line_rec.global_attribute8 := p_ref_line_rec.global_attribute8;
5891 p_x_line_rec.global_attribute9 := p_ref_line_rec.global_attribute9;
5892 p_x_line_rec.global_attribute10 := p_ref_line_rec.global_attribute10;
5893 p_x_line_rec.global_attribute11 := p_ref_line_rec.global_attribute11;
5894 p_x_line_rec.global_attribute12 := p_ref_line_rec.global_attribute12;
5895 p_x_line_rec.global_attribute13 := p_ref_line_rec.global_attribute13;
5896 p_x_line_rec.global_attribute14 := p_ref_line_rec.global_attribute14;
5897 p_x_line_rec.global_attribute15 := p_ref_line_rec.global_attribute15;
5898 p_x_line_rec.global_attribute16 := p_ref_line_rec.global_attribute16;
5899 p_x_line_rec.global_attribute17 := p_ref_line_rec.global_attribute17;
5900 p_x_line_rec.global_attribute18 := p_ref_line_rec.global_attribute18;
5901 p_x_line_rec.global_attribute19 := p_ref_line_rec.global_attribute19;
5902 p_x_line_rec.global_attribute20 := p_ref_line_rec.global_attribute20;
5903
5904 -- Retain the Industry DFF Info
5905 p_x_line_rec.industry_context := p_ref_line_rec.industry_context;
5906 p_x_line_rec.industry_attribute1 := p_ref_line_rec.industry_attribute1;
5907 p_x_line_rec.industry_attribute2 := p_ref_line_rec.industry_attribute2;
5908 p_x_line_rec.industry_attribute3 := p_ref_line_rec.industry_attribute3;
5909 p_x_line_rec.industry_attribute4 := p_ref_line_rec.industry_attribute4;
5910 p_x_line_rec.industry_attribute5 := p_ref_line_rec.industry_attribute5;
5911 p_x_line_rec.industry_attribute6 := p_ref_line_rec.industry_attribute6;
5912 p_x_line_rec.industry_attribute7 := p_ref_line_rec.industry_attribute7;
5913 p_x_line_rec.industry_attribute8 := p_ref_line_rec.industry_attribute8;
5914 p_x_line_rec.industry_attribute9 := p_ref_line_rec.industry_attribute9;
5915 p_x_line_rec.industry_attribute10 := p_ref_line_rec.industry_attribute10;
5916 --Added for bug 9844952
5917 p_x_line_rec.industry_attribute11 := p_ref_line_rec.industry_attribute11;
5918 p_x_line_rec.industry_attribute12 := p_ref_line_rec.industry_attribute12;
5919 p_x_line_rec.industry_attribute13 := p_ref_line_rec.industry_attribute13;
5920 p_x_line_rec.industry_attribute14 := p_ref_line_rec.industry_attribute14;
5921 p_x_line_rec.industry_attribute15 := p_ref_line_rec.industry_attribute15;
5922 p_x_line_rec.industry_attribute16 := p_ref_line_rec.industry_attribute16;
5923 p_x_line_rec.industry_attribute17 := p_ref_line_rec.industry_attribute17;
5924 p_x_line_rec.industry_attribute18 := p_ref_line_rec.industry_attribute18;
5925 p_x_line_rec.industry_attribute19 := p_ref_line_rec.industry_attribute19;
5926 p_x_line_rec.industry_attribute20 := p_ref_line_rec.industry_attribute20;
5927 p_x_line_rec.industry_attribute21 := p_ref_line_rec.industry_attribute21;
5928 p_x_line_rec.industry_attribute22 := p_ref_line_rec.industry_attribute22;
5929 p_x_line_rec.industry_attribute23 := p_ref_line_rec.industry_attribute23;
5930 p_x_line_rec.industry_attribute24 := p_ref_line_rec.industry_attribute24;
5931 p_x_line_rec.industry_attribute25 := p_ref_line_rec.industry_attribute25;
5932 p_x_line_rec.industry_attribute26 := p_ref_line_rec.industry_attribute26;
5933 p_x_line_rec.industry_attribute27 := p_ref_line_rec.industry_attribute27;
5934 p_x_line_rec.industry_attribute28 := p_ref_line_rec.industry_attribute28;
5935 p_x_line_rec.industry_attribute29 := p_ref_line_rec.industry_attribute29;
5936 p_x_line_rec.industry_attribute30 := p_ref_line_rec.industry_attribute30;
5937 --End changes for bug 9844952
5938 -- Retain the Trading Partner DFF Info
5939 p_x_line_rec.tp_context := p_ref_line_rec.tp_context;
5940 p_x_line_rec.tp_attribute1 := p_ref_line_rec.tp_attribute1;
5941 p_x_line_rec.tp_attribute2 := p_ref_line_rec.tp_attribute2;
5942 p_x_line_rec.tp_attribute3 := p_ref_line_rec.tp_attribute3;
5943 p_x_line_rec.tp_attribute4 := p_ref_line_rec.tp_attribute4;
5944 p_x_line_rec.tp_attribute5 := p_ref_line_rec.tp_attribute5;
5945 p_x_line_rec.tp_attribute6 := p_ref_line_rec.tp_attribute6;
5946 p_x_line_rec.tp_attribute7 := p_ref_line_rec.tp_attribute7;
5947 p_x_line_rec.tp_attribute8 := p_ref_line_rec.tp_attribute8;
5948 p_x_line_rec.tp_attribute9 := p_ref_line_rec.tp_attribute9;
5949 p_x_line_rec.tp_attribute10 := p_ref_line_rec.tp_attribute10;
5950 p_x_line_rec.tp_attribute11 := p_ref_line_rec.tp_attribute11;
5951 p_x_line_rec.tp_attribute12 := p_ref_line_rec.tp_attribute12;
5952 p_x_line_rec.tp_attribute13 := p_ref_line_rec.tp_attribute13;
5953 p_x_line_rec.tp_attribute14 := p_ref_line_rec.tp_attribute14;
5954 p_x_line_rec.tp_attribute15 := p_ref_line_rec.tp_attribute15;
5955
5956 END copy_line_dff_from_ref;
5957
5958 Function CALL_DFF_COPY_EXTN_API(p_org_id IN NUMBER DEFAULT NULL)
5959 RETURN BOOLEAN
5960 IS
5961 BEGIN
5962 IF OE_COPY_UTIL_EXT.G_CALL_API = 'Y' THEN
5963 RETURN TRUE;
5964 ELSIF OE_Sys_Parameters.value('COPY_LINE_DFF_EXT_API',p_org_id) = 'Y'
5965 THEN
5966 RETURN TRUE;
5967 ELSE
5968 RETURN FALSE;
5969 END IF;
5970 END CALL_DFF_COPY_EXTN_API;
5971
5972 -- Copy Sets ER #2830872 , #1566254 Begin.
5973
5974 ------------------------------------------------------------------------------------
5975 -- Procedure Name : Copy_Line_Sets
5976 -- Input Params : p_old_header_id : Header Id of Order of source Line.
5977 -- p_new_header_id : Header Id of Order of destination Line.
5978 -- p_line_tbl : Table of all new copied lines.
5979 -- p_copy_fulfillment_sets : Flag to check user preference.
5980 -- p_copy_ship_arr_sets : Flag to check user preference.
5981 -- Output Params : x_result : Flag to Check result of the Operation.
5982 -- Description : This procedure copies the set information for lines being copied.
5983 -- It check the value of the Flags for user preference before
5984 -- doing the operation for a particular Line.
5985 -- It takes header id of the source and destination lines and
5986 -- returns FND_API.G_RET_STS_SUCCESS if all sets were copied
5987 -- successfully. It returns FND_API.G_RET_STS_ERROR or
5988 -- G_RET_STS_UNEXP_ERROR if some or all sets are not copied.
5989 -- This procedure is used in this package and in this flow only
5990 -- and not used anywhere else in any other flow in the product.
5991 -- This is called from the Copy Order procedure if user selects
5992 -- fulfillment / ship / arrival sets to be copied.
5993 ------------------------------------------------------------------------------------
5994
5995 PROCEDURE COPY_LINE_SETS(
5996 p_old_header_id IN NUMBER,
5997 p_new_header_id IN NUMBER,
5998 p_line_tbl IN OE_Order_PUB.Line_Tbl_Type,
5999 p_copy_fulfillment_sets IN BOOLEAN,
6000 p_copy_ship_arr_sets IN BOOLEAN,
6001 x_result OUT NOCOPY VARCHAR2)
6002 IS
6003
6004 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6005 l_selected_line_tbl OE_GLOBALS.Selected_Record_Tbl;
6006 I NUMBER := 0;
6007 l_set_id NUMBER;
6008 l_return_status VARCHAR2(30);
6009 l_msg_count NUMBER :=0;
6010 l_msg_data VARCHAR2(2000) := '';
6011
6012 -- Cursor for finding all sets of a particular type from source order.
6013 CURSOR set_cur(stype IN VARCHAR2)
6014 IS
6015 SELECT distinct set_id, set_name,set_type
6016 FROM oe_sets
6017 WHERE header_id = p_old_header_id
6018 AND set_type = stype
6019 ORDER BY set_id;
6020
6021 -- Cursor for finding all lines belonging to a particular ship set from source order.
6022 CURSOR line_cur_ship(p_set_id IN NUMBER)
6023 IS
6024 SELECT l.line_id
6025 FROM oe_order_lines_all l
6026 WHERE l.ship_set_id = p_set_id;
6027
6028 -- Cursor for finding all lines belonging to a particular arrival set from source order.
6029 CURSOR line_cur_arrival(p_set_id IN NUMBER)
6030 IS
6031 SELECT l.line_id
6032 FROM oe_order_lines_all l
6033 WHERE l.arrival_set_id = p_set_id;
6034
6035 -- Cursor for finding all lines belonging to a particular fulfillment set from source order.
6036 CURSOR line_cur_fulfill(p_set_id IN NUMBER)
6037 IS
6038 SELECT l.line_id
6039 FROM oe_order_lines_all l,
6040 oe_line_sets ols
6041 WHERE l.line_id = ols.line_id
6042 AND l.header_id = p_old_header_id
6043 AND ols.set_id = p_set_id;
6044
6045 BEGIN
6046
6047 -- Initializing the result to Success.
6048 x_result := FND_API.G_RET_STS_SUCCESS;
6049 IF l_debug_level > 0 THEN
6050 oe_debug_pub.add(' Entering Copy Line Sets.');
6051 END IF;
6052 -- Copying Fulfillment Sets based on user preference.
6053 IF p_copy_fulfillment_sets THEN
6054
6055 IF l_debug_level > 0 THEN
6056 oe_debug_pub.add(' Copying Fulfillment Sets.');
6057 END IF;
6058
6059 FOR set_rec IN set_cur('FULFILLMENT_SET')
6060 LOOP
6061 -- Initializing processing tools.
6062 I := 0;
6063 l_selected_line_tbl.DELETE;
6064
6065 IF l_debug_level > 0 THEN
6066 oe_debug_pub.add(' Copying Set ID :'||set_rec.set_id);
6067 oe_debug_pub.add(' Copying Set Name :'||set_rec.set_name);
6068 oe_debug_pub.add(' Copying Set Type :'||set_rec.set_type);
6069 END IF;
6070
6071 -- Initializing the Line Table for Set processing in new header.
6072 FOR line_rec IN line_cur_fulfill(set_rec.set_id)
6073 LOOP
6074 IF p_line_tbl.Count > 0 THEN
6075 FOR lindex IN 1..p_line_tbl.Count
6076 LOOP
6077 IF p_line_tbl(lindex).source_document_line_id = line_rec.line_id
6078 AND (p_line_tbl(lindex).item_type_code = 'STANDARD' OR
6079 p_line_tbl(lindex).item_type_code = 'MODEL' OR
6080 p_line_tbl(lindex).item_type_code = 'SERVICE' OR
6081 p_line_tbl(lindex).item_type_code = 'KIT')
6082 THEN
6083 -- Incrementing index and populating table.
6084 I := I + 1;
6085 l_selected_line_tbl(I).id1 := p_line_tbl(lindex).line_id;
6086 END IF;
6087 END LOOP;
6088 END IF;
6089 END LOOP;
6090
6091 IF l_selected_line_tbl.COUNT > 0 THEN
6092 IF l_debug_level > 0 THEN
6093 oe_debug_pub.add(' Line Table Ready. Processing this set:'||set_rec.set_name);
6094 END IF;
6095
6096 -- Processing the Set for New Lines.
6097 oe_set_util.Process_Sets
6098 ( p_selected_line_tbl => l_selected_line_tbl,
6099 p_record_count => l_selected_line_tbl.COUNT,
6100 p_set_name => set_rec.set_name,
6101 p_set_type => 'FULFILLMENT',
6102 p_operation => 'ADD' ,
6103 p_header_id => p_new_header_id,
6104 x_Set_Id => l_set_id,
6105 x_return_status => l_return_status,
6106 x_msg_count => l_msg_count ,
6107 x_msg_data => l_msg_data
6108 );
6109
6110 -- Checking Result Status.
6111 IF(l_return_status = FND_API.G_RET_STS_SUCCESS) THEN
6112 IF l_debug_level > 0 THEN
6113 oe_debug_pub.add(' Lines Copied to new/existing Set ID :'||l_set_id);
6114 END IF;
6115 ELSE
6116 x_result := FND_API.G_RET_STS_ERROR;
6117 IF l_debug_level > 0 THEN
6118 oe_debug_pub.add(' Copy of Set has errors :'||l_msg_data);
6119 END IF;
6120 l_msg_count := 0;
6121 l_msg_data := '';
6122 END IF;
6123 ELSE
6124 IF l_debug_level > 0 THEN
6125 oe_debug_pub.add(' Line Table Empty. Not processing this set:'||set_rec.set_name);
6126 END IF;
6127 END IF;
6128 END LOOP;
6129
6130 IF l_debug_level > 0 THEN
6131 oe_debug_pub.add(' Copied Fulfillment Sets.');
6132 END IF;
6133 END IF; -- Copy of Fulfillment Sets
6134
6135 -- Copying Ship Sets based on user preference.
6136 IF p_copy_ship_arr_sets THEN
6137
6138 IF l_debug_level > 0 THEN
6139 oe_debug_pub.add(' Copying Ship Sets.');
6140 END IF;
6141 FOR set_rec IN set_cur('SHIP_SET')
6142 LOOP
6143 -- Initializing processing tools.
6144 I := 0;
6145 l_selected_line_tbl.DELETE;
6146
6147 IF l_debug_level > 0 THEN
6148 oe_debug_pub.add(' Copying Set ID :'||set_rec.set_id);
6149 oe_debug_pub.add(' Copying Set Name :'||set_rec.set_name);
6150 oe_debug_pub.add(' Copying Set Type :'||set_rec.set_type);
6151 END IF;
6152
6153 -- Initializing the Line Table for Set processing in new header.
6154 FOR line_rec IN line_cur_ship(set_rec.set_id)
6155 LOOP
6156 IF p_line_tbl.Count > 0 THEN
6157 FOR lindex IN 1..p_line_tbl.Count
6158 LOOP
6159 IF p_line_tbl(lindex).source_document_line_id = line_rec.line_id
6160 AND (p_line_tbl(lindex).item_type_code = 'STANDARD' OR
6161 p_line_tbl(lindex).item_type_code = 'MODEL' OR
6162 p_line_tbl(lindex).item_type_code = 'KIT')
6163 THEN
6164 -- Incrementing index and populating table.
6165 I := I + 1;
6166 l_selected_line_tbl(I).id1 := p_line_tbl(lindex).line_id;
6167 END IF;
6168 END LOOP;
6169 END IF;
6170 END LOOP;
6171
6172 IF l_selected_line_tbl.COUNT > 0 THEN
6173 IF l_debug_level > 0 THEN
6174 oe_debug_pub.add(' Line Table Ready. Processing this set:'||set_rec.set_name);
6175 END IF;
6176
6177 -- Processing the Set for New Lines.
6178 oe_set_util.Process_Sets
6179 ( p_selected_line_tbl => l_selected_line_tbl,
6180 p_record_count => l_selected_line_tbl.COUNT,
6181 p_set_name => set_rec.set_name,
6182 p_set_type => 'SHIP',
6183 p_operation => 'ADD' ,
6184 p_header_id => p_new_header_id,
6185 x_Set_Id => l_set_id,
6186 x_return_status => l_return_status,
6187 x_msg_count => l_msg_count ,
6188 x_msg_data => l_msg_data
6189 );
6190
6191 -- Checking Result Status.
6192 IF(l_return_status = FND_API.G_RET_STS_SUCCESS) THEN
6193 IF l_debug_level > 0 THEN
6194 oe_debug_pub.add(' Lines copied to new/existing Set ID :'||l_set_id);
6195 END IF;
6196 ELSE
6197 x_result := FND_API.G_RET_STS_ERROR;
6198 IF l_debug_level > 0 THEN
6199 oe_debug_pub.add(' Copy of Set has errors :'||l_msg_data);
6200 END IF;
6201 l_msg_count := 0;
6202 l_msg_data := '';
6203 END IF;
6204 ELSE
6205 IF l_debug_level > 0 THEN
6206 oe_debug_pub.add(' Line Table Empty. Not processing this set:'||set_rec.set_name);
6207 END IF;
6208 END IF;
6209 END LOOP;
6210
6211 oe_debug_pub.add(' Copied Ship Sets.');
6212
6213 END IF; -- Copy of Ship Sets
6214
6215 -- Copying Arrival Sets based on user preference.
6216 IF p_copy_ship_arr_sets THEN
6217
6218 IF l_debug_level > 0 THEN
6219 oe_debug_pub.add(' Copying Arrival Sets.');
6220 END IF;
6221
6222 FOR set_rec IN set_cur('ARRIVAL_SET')
6223 LOOP
6224 -- Initializing processing tools.
6225 I := 0;
6226 l_selected_line_tbl.delete;
6227
6228 IF l_debug_level > 0 THEN
6229 oe_debug_pub.add(' Copying Set ID :'||set_rec.set_id);
6230 oe_debug_pub.add(' Copying Set Name :'||set_rec.set_name);
6231 oe_debug_pub.add(' Copying Set Type :'||set_rec.set_type);
6232 END IF;
6233
6234 -- Initializing the Line Table for Set processing in new header.
6235 FOR line_rec IN line_cur_arrival(set_rec.set_id)
6236 LOOP
6237 IF p_line_tbl.Count > 0 THEN
6238 FOR lindex IN 1..p_line_tbl.Count
6239 LOOP
6240 IF p_line_tbl(lindex).source_document_line_id = line_rec.line_id
6241 AND (p_line_tbl(lindex).item_type_code = 'STANDARD' OR
6242 p_line_tbl(lindex).item_type_code = 'MODEL' OR
6243 p_line_tbl(lindex).item_type_code = 'KIT')
6244 THEN
6245 -- Incrementing index and populating table.
6246 I := I + 1;
6247 l_selected_line_tbl(I).id1 := p_line_tbl(lindex).line_id;
6248 END IF;
6249 END LOOP;
6250 END IF;
6251 END LOOP;
6252
6253 IF l_selected_line_tbl.COUNT > 0 THEN
6254
6255 IF l_debug_level > 0 THEN
6256 oe_debug_pub.add(' Line Table Ready. Processing this set:'||set_rec.set_name);
6257 END IF;
6258
6259 -- Processing the Set for New Lines.
6260 oe_set_util.Process_Sets
6261 ( p_selected_line_tbl => l_selected_line_tbl,
6262 p_record_count => l_selected_line_tbl.COUNT,
6263 p_set_name => set_rec.set_name,
6264 p_set_type => 'ARRIVAL',
6265 p_operation => 'ADD' ,
6266 p_header_id => p_new_header_id,
6267 x_Set_Id => l_set_id,
6268 x_return_status => l_return_status,
6269 x_msg_count => l_msg_count ,
6270 x_msg_data => l_msg_data
6271 );
6272
6273 -- Checking Result Status.
6274 IF(l_return_status = FND_API.G_RET_STS_SUCCESS) THEN
6275 IF l_debug_level > 0 THEN
6276 oe_debug_pub.add(' Lines copied to new/existing Set ID :'||l_set_id);
6277 END IF;
6278 ELSE
6279 x_result := FND_API.G_RET_STS_ERROR;
6280 IF l_debug_level > 0 THEN
6281 oe_debug_pub.add(' Copy of Set has errors :'||l_msg_data);
6282 END IF;
6283 l_msg_count := 0;
6284 l_msg_data := '';
6285 END IF;
6286 ELSE
6287 IF l_debug_level > 0 THEN
6288 oe_debug_pub.add(' Line Table Empty. Not processing this set:'||set_rec.set_name);
6289 END IF;
6290 END IF;
6291 END LOOP;
6292
6293 IF l_debug_level > 0 THEN
6294 oe_debug_pub.add(' Copied Arrival Sets.');
6295 END IF;
6296
6297 END IF; -- Copy of Arrival Sets
6298
6299 EXCEPTION
6300 WHEN OTHERS THEN
6301
6302 x_result := FND_API.G_RET_STS_UNEXP_ERROR;
6303 IF l_debug_level > 0 THEN
6304 oe_debug_pub.add('Unexpected Error Occured during Copy of Line Sets');
6305 oe_debug_pub.add(SQLERRM);
6306 END IF;
6307
6308 END COPY_LINE_SETS;
6309
6310 -- Copy Sets ER #2830872 , #1566254 End.
6311
6312 END OE_Order_Copy_Util;