[Home] [Help]
PACKAGE BODY: APPS.OE_DELAYED_REQUESTS_UTIL
Source
1 PACKAGE BODY oe_delayed_requests_util AS
2 /* $Header: OEXUREQB.pls 120.41.12020000.10 2013/05/23 14:28:45 nilegupt ship $ */
3
4 -- Global constant holding the package name
5
6 G_PKG_NAME CONSTANT VARCHAR2(30) := 'OE_Delayed_Requests_UTIL';
7
8 -- Procedure to validate quota percent total
9
10 PROCEDURE Validate_LSC_QUOTA_TOTAL
11 ( x_return_status OUT NOCOPY Varchar2
12
13 , p_line_id IN NUMBER
14 ) IS
15 l_percent_total Number;
16
17 Cursor C_LSC_Quota_Total(p_line_id number) IS
18 Select sum(Percent) Per_total
19 From oe_sales_credits sc,
20 oe_sales_credit_types sct
21 Where line_id = p_line_id
22 And sct.sales_credit_type_id = sc.sales_credit_type_id
23 And sct.quota_flag = 'Y';
24
25 BEGIN
26
27 oe_debug_pub.add('Entering OE_DELAYED_REQUESTS_UTIL.VALIDATE_LSC_QUOTA_TOTAL', 1);
28
29 x_return_status := FND_API.G_RET_STS_SUCCESS;
30 OPEN C_LSC_Quota_Total(p_line_id);
31 FETCH C_LSC_Quota_Total
32 INTO l_percent_total;
33 CLOSE C_LSC_Quota_Total;
34
35 -- The Zero percent is added to include functionality which will exclude
36 -- Salesperson from getting Sales Credit
37 IF (l_percent_total <> 100 AND
38 l_percent_total <> 0)THEN
39 fnd_message.set_name('ONT','OE_VAL_TTL_LINE_CREDIT');
40 FND_MESSAGE.SET_TOKEN('TOTAL',to_char(l_percent_total));
41 OE_MSG_PUB.Add;
42 x_return_status := FND_API.G_RET_STS_ERROR;
43 END IF;
44
45 oe_debug_pub.add('Exiting OE_DELAYED_REQUESTS_UTIL.VALIDATE_LSC_QUOTA_TOTAL', 1);
46
47 EXCEPTION
48
49 WHEN FND_API.G_EXC_ERROR THEN
50
51 x_return_status := FND_API.G_RET_STS_ERROR;
52
53 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
54
55 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
56
57 WHEN OTHERS THEN
58
59 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
60
61 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
62 THEN
63 OE_MSG_PUB.Add_Exc_Msg
64 ( G_PKG_NAME
65 , 'Validate_LSC_QUOTA_TOTAL'
66 );
67 END IF;
68 END Validate_LSC_QUOTA_TOTAL;
69
70 -- Procedure to validate quota percent total
71 PROCEDURE Validate_HSC_QUOTA_TOTAL
72 ( x_return_status OUT NOCOPY Varchar2
73
74 , p_header_id IN NUMBER
75 ) IS
76
77 BEGIN
78
79 oe_debug_pub.add('Entering OE_DELAYED_REQUESTS_UTIL.VALIDATE_HSC_QUOTA_TOTAL', 1);
80
81 OE_Validate_Header_Scredit.Validate_HSC_QUOTA_TOTAL(x_return_status => x_return_status,
82 p_header_id => p_header_id);
83
84 oe_debug_pub.add('Exiting OE_DELAYED_REQUESTS_UTIL.VALIDATE_HSC_QUOTA_TOTAL', 1);
85
86 EXCEPTION
87
88 WHEN OTHERS THEN
89
90 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
91
92 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
93 THEN
94 OE_MSG_PUB.Add_Exc_Msg
95 ( G_PKG_NAME
96 , 'Validate_HSC_QUOTA_TOTAL:'||SQLERRM
97 );
98 END IF;
99 END Validate_HSC_QUOTA_TOTAL;
100
101
102 PROCEDURE DFLT_Hscredit_Primary_Srep
103 ( p_header_id IN Number
104 ,p_SalesRep_id IN Number
105 ,x_return_status OUT NOCOPY Varchar2
106
107 ) IS
108 l_sales_credits_count Number;
109 l_sales_credit_id Number;
110
111 /* Changed the above cursor definition to fix the bug 1822931 */
112 l_scredit_type_id number;
113 l_Header_Scredit_rec OE_Order_PUB.Header_Scredit_Rec_Type;
114 l_old_Header_Scredit_rec OE_Order_PUB.Header_Scredit_Rec_Type;
115 l_Header_Scredit_tbl OE_Order_PUB.Header_Scredit_Tbl_Type;
116 l_old_Header_Scredit_tbl OE_Order_PUB.Header_Scredit_Tbl_Type;
117 l_control_rec OE_GLOBALS.Control_Rec_Type;
118 l_return_status VARCHAR2(30);
119 x_msg_count NUMBER;
120 x_msg_data VARCHAR2(2000);
121 Begin
122
123 oe_debug_pub.add('Entering OE_DELAYED_REQUESTS_UTIL.DFLT_HSCREDIT_PRIMARY_SREP', 1);
124 OE_HEADER_SCREDIT_UTIL.DFLT_Hscredit_Primary_Srep
125 ( p_header_id =>p_header_id
126 ,p_SalesRep_id =>p_SalesRep_id
127 ,x_return_status=>x_return_status);
128 oe_debug_pub.add('Exiting OE_DELAYED_REQUESTS_UTIL.DFLT_HSCREDIT_PRIMARY_SREP', 1);
129
130 EXCEPTION
131
132 WHEN OTHERS THEN
133
134 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
135
136 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
137 THEN
138 OE_MSG_PUB.Add_Exc_Msg
139 ( G_PKG_NAME
140 , 'DFLT_Hscredit_Primary_Srep:'||SQLERRM
141 );
142 END IF;
143 End DFLT_Hscredit_Primary_Srep;
144
145
146 Procedure Cascade_Service_Scredit
147 ( x_return_status OUT NOCOPY Varchar2
148
149 ,p_request_rec IN OE_ORDER_PUB.request_rec_type)
150 IS
151 l_Line_Scredit_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
152 l_old_Line_Scredit_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
153 l_control_rec OE_GLOBALS.Control_Rec_Type;
154 l_line_id NUMBER;
155 l_line_id1 NUMBER;
156 l_line_set_id NUMBER;
157 l_item_type_code VARCHAR2(30);
158 l_temp NUMBER;
159 l_service_reference_line_id NUMBER;
160 l_inv_item_id number;
161 l_temp_inv_item_id number;
162 l_count NUMBER := 0;
163 l_new_quota_flag VARCHAR2(1);
164 l_old_quota_flag VARCHAR2(1);
165 l_per_total NUMBER;
166 l_new_salesrep_id NUMBER;
167 l_old_salesrep_id NUMBER;
168 l_new_sales_credit_type_id NUMBER;
169 l_old_sales_credit_type_id NUMBER;
170 l_new_percent NUMBER;
171 l_old_percent NUMBER;
172 l_operation VARCHAR2(30);
173 l_sales_credit_type_id NUMBER;
174 l_salesrep_id NUMBER;
175 l_percent NUMBER;
176 l_q_percent NUMBER;
177 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
178 l_sales_credit_id NUMBER;
179 l_service_type_code VARCHAR2(30); --Bug 4946843
180
181 CURSOR PARENT IS
182 SELECT Line_id, item_type_code,line_set_id,
183 Service_reference_line_id,
184 inventory_item_id,
185 service_reference_type_code --Bug 4946843
186 FROM OE_ORDER_LINES_ALL
187 WHERE Line_id = l_line_id;
188
189 CURSOR MODEL_SERVICES IS
190 SELECT /* MOAC_SQL_CHANGE */ line_id, header_id
191 FROM OE_ORDER_LINES
192 WHERE service_reference_line_id
193 in (SELECT line_id
194 FROM oe_order_lines_all
195 WHERE top_model_line_id = l_line_id1)
196 AND line_id <> l_line_id and
197 inventory_item_id = l_temp_inv_item_id;
198
199
200 BEGIN
201
202 OE_DEBUG_PUB.Add('Entering OE_DELAYED_REQUESTS_UTIL.Cascade_Service_Scredit',1);
203 l_line_id := p_request_rec.param8;
204 l_new_salesrep_id := p_request_rec.param1;
205 l_old_salesrep_id := p_request_rec.param2;
206 l_new_sales_credit_type_id := p_request_rec.param3;
207 l_old_sales_credit_type_id := p_request_rec.param4;
208 l_new_percent := p_request_rec.param5;
209 l_old_percent := p_request_rec.param6;
210 l_operation := p_request_rec.param7;
211
212 oe_debug_pub.add('l_line_id := ' || p_request_rec.param8,2);
213 oe_debug_pub.add('l_new_salesrep_id := ' || p_request_rec.param1,2);
214 oe_debug_pub.add('l_old_salesrep_id := ' || p_request_rec.param2,2);
215 oe_debug_pub.add('l_new_sales_credit_type_id :=' || p_request_rec.param3,2);
216 oe_debug_pub.add('l_old_sales_credit_type_id := ' || p_request_rec.param4,2);
217 oe_debug_pub.add('l_new_percent := ' || p_request_rec.param5,2);
218 oe_debug_pub.add('l_old_percent := ' || p_request_rec.param6,2);
219 oe_debug_pub.add('l_operation := ' || p_request_rec.param7,2);
220
221 OPEN PARENT;
222 FETCH PARENT
223 INTO l_line_id,l_item_type_code,l_line_set_id,l_service_reference_line_id,
224 l_inv_item_id,l_service_type_code; --Bug 4946843
225 CLOSE PARENT;
226
227 IF l_item_type_code = 'SERVICE'
228 AND l_service_type_code = 'ORDER' --Bug 4946843
229 AND l_service_reference_line_id IS NOT NULL THEN
230
231 l_line_id := l_service_reference_line_id;
232 l_temp_inv_item_id := l_inv_item_id;
233
234 OPEN PARENT;
235 FETCH PARENT
236 INTO l_line_id1,l_item_type_code,l_line_set_id,l_service_reference_line_id
237 ,l_inv_item_id,l_service_type_code; --Bug 4946843
238 CLOSE PARENT;
239
240 IF l_item_type_code = 'MODEL' THEN
241
242 oe_debug_pub.Add('Need to cascade the sales credit');
243
244 FOR I IN MODEL_SERVICES LOOP
245 l_temp := 0;
246 -- For create check the existance of the record based on the
247 -- new data and for other operations check based on the old data.
248
249
250 IF l_operation = OE_GLOBALS.G_OPR_CREATE THEN
251
252 l_sales_credit_type_id := l_new_sales_credit_type_id;
253 l_salesrep_id := l_new_salesrep_id;
254 l_percent := l_new_percent;
255 oe_debug_pub.Add('In l_operation if');
256 ELSE
257 l_sales_credit_type_id := l_old_sales_credit_type_id;
258 l_salesrep_id := l_old_salesrep_id;
259 l_percent := l_old_percent;
260 END IF;
261 BEGIN
262 Select '1', sales_credit_id, nvl(percent,0)
263 INTO l_temp, l_sales_credit_id, l_q_percent
264 from oe_sales_credits
265 Where header_id = i.header_id
266 AND line_id = i.line_id
267 And sales_credit_type_id = l_sales_credit_type_id
268 AND salesrep_id = l_salesrep_id;
269 -- AND Percent = l_percent;
270
271 oe_debug_pub.Add('l_q_percent ' || l_q_percent);
272 oe_debug_pub.Add('l_percent ' || l_percent);
273 EXCEPTION
274
275 WHEN NO_DATA_FOUND THEN
276
277 l_temp := 0;
278
279 WHEN TOO_MANY_ROWS THEN
280
281 l_temp := 2;
282
283 WHEN OTHERS THEN
284
285 l_temp := 10;
286
287 END;
288
289 oe_debug_pub.Add('l_temp: ' || l_temp);
290 --Get Quota flag.
291
292 BEGIN
293
294 Select quota_flag
295 Into l_new_quota_flag
296 From oe_sales_credit_types
297 Where sales_credit_type_id = l_new_sales_credit_type_id;
298
299 IF l_new_sales_credit_type_id <> l_old_sales_credit_type_id THEN
300
301 Select quota_flag
302 Into l_old_quota_flag
303 From oe_sales_credit_types
304 Where sales_credit_type_id = l_old_sales_credit_type_id;
305
306 ELSE
307
308 l_old_quota_flag := l_new_quota_flag;
309
310 END IF;
311
312 END;
313
314 IF l_temp = 0 THEN -- Only when record not exist for child.
315 IF l_operation = OE_GLOBALS.G_OPR_CREATE THEN
316
317 IF l_new_quota_flag = 'Y' THEN
318
319 oe_debug_pub.Add(' In create and quota');
320 Select nvl(sum(Percent),0) Per_total
321 Into l_per_total
322 From oe_sales_credits sc,
323 oe_sales_credit_types sct
324 Where header_id = i.header_id
325 AND line_id = i.line_id
326 And sct.sales_credit_type_id = sc.sales_credit_type_id
327 And sct.quota_flag = 'Y';
328
329 END IF; -- Quota flag.
330
331 oe_debug_pub.Add(' L_per_total : ' || nvl(l_per_total,0) || 'End');
332 oe_debug_pub.Add(' L_new_percent : ' || nvl(l_new_percent,0) || 'End');
333
334 IF (l_per_total + l_new_percent) <= 100
335 OR l_new_quota_flag = 'N' THEN
336
337 oe_debug_pub.Add(' Populate sales credit ');
338 -- Child.service does not have a sales credit and create the
339 -- same.
340 l_count := l_count + 1;
341
342 l_Line_Scredit_tbl(l_count) := OE_Order_PUB.G_MISS_LINE_SCREDIT_REC;
343 l_Line_Scredit_tbl(l_count).Header_id := I.Header_id;
344 l_Line_Scredit_tbl(l_count).Line_id := I.Line_id;
345 l_Line_Scredit_tbl(l_count).SalesRep_Id := l_new_salesRep_id;
346 l_Line_Scredit_tbl(l_count).Sales_credit_type_id :=
347 l_new_sales_credit_type_id;
348 l_Line_Scredit_tbl(l_count).PERCENT := l_new_percent;
349 l_Line_Scredit_tbl(l_count).Operation := OE_GLOBALS.G_OPR_CREATE;
350
351 END IF; -- Check the percent
352
353 END IF; -- Create.
354 ELSIF l_temp = 1
355 AND l_percent = l_q_percent THEN
356
357 --Sales credir record exists for the child service line.
358
359 IF l_operation = OE_GLOBALS.G_OPR_UPDATE THEN
360
361 oe_msg_pub.add('In Update');
362
363 IF l_new_quota_flag = 'Y' THEN
364
365 Select nvl(sum(Percent),0) Per_total
366 Into l_per_total
367 From oe_sales_credits sc,
368 oe_sales_credit_types sct
369 Where header_id = i.header_id
370 AND line_id = i.line_id
371 And sct.sales_credit_type_id = sc.sales_credit_type_id
372 And sct.quota_flag = 'Y';
373
374
375 IF l_old_quota_flag = 'Y' THEN
376
377 l_per_total := l_per_total - nvl(l_old_percent,0) +
378 nvl(l_new_percent,0);
379
380 ELSE
381
382 l_per_total := l_per_total + nvl(l_new_percent,0);
383
384 END IF;
385
386 END IF; -- Quota flag.
387
388 oe_debug_pub.Add(' L_per_total : ' || nvl(l_per_total,0) || 'End');
389 oe_debug_pub.Add(' L_new_percent : ' || nvl(l_new_percent,0) || 'End');
390
391
392 IF nvl(l_per_total,0) <= 100
393 OR l_new_quota_flag = 'N' THEN
394
395 l_count := l_count + 1;
396
397 -- Setup new sales scredit record.
398 l_Line_Scredit_tbl(l_count) := OE_Order_PUB.G_MISS_LINE_SCREDIT_REC;
399 l_Line_Scredit_tbl(l_count).sales_credit_id := l_sales_credit_id;
400 l_Line_Scredit_tbl(l_count).Header_id := I.Header_id;
401 l_Line_Scredit_tbl(l_count).Line_id := I.Line_id;
402 l_Line_Scredit_tbl(l_count).SalesRep_Id := l_new_salesRep_id;
403 l_Line_Scredit_tbl(l_count).Sales_credit_type_id :=
404 l_new_sales_credit_type_id;
405 l_Line_Scredit_tbl(l_count).PERCENT := l_new_percent;
406 /* Start Audit Trail */
407 l_Line_Scredit_tbl(l_count).change_reason := 'SYSTEM';
408 /* End Audit Trail */
409 l_Line_Scredit_tbl(l_count).Operation := OE_GLOBALS.G_OPR_UPDATE;
410
411 END IF; -- Percent.
412 ELSIF l_operation = OE_GLOBALS.G_OPR_DELETE
413 AND l_percent = l_q_percent THEN
414
415 l_count := l_count + 1;
416 l_Line_Scredit_tbl(l_count) := OE_Order_PUB.G_MISS_LINE_SCREDIT_REC;
417 l_Line_Scredit_tbl(l_count).sales_credit_id := l_sales_credit_id;
418 l_Line_Scredit_tbl(l_count).Header_id := I.Header_id;
419 l_Line_Scredit_tbl(l_count).Line_id := I.Line_id;
420 l_Line_Scredit_tbl(l_count).Operation := OE_GLOBALS.G_OPR_DELETE;
421 END IF; -- operation
422 END IF; -- temp
423 END LOOP;
424 END IF; -- Model.
425 END IF; -- Service
426
427 oe_debug_pub.Add(' l_count : ' || to_char(l_count));
428 IF l_count > 0 THEN -- Have some data that need to get cascaded.
429
430 -- Call OE_Order_PVT.Process_order to insert sales credits.
431 -- Set recursion mode.
432 -- OE_GLOBALS.G_RECURSION_MODE := 'Y';
433
434 OE_ORDER_PVT.Line_Scredits
435 (p_validation_level => FND_API.G_VALID_LEVEL_FULL
436 ,p_control_rec => l_control_rec
437 ,p_x_Line_Scredit_tbl => l_Line_Scredit_tbl
438 ,p_x_old_Line_Scredit_tbl => l_old_Line_Scredit_tbl
439 ,x_return_status => l_return_status);
440
441 -- Reset recursion mode.
442 -- OE_GLOBALS.G_RECURSION_MODE := 'N';
443
444 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
445 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
446 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
447 RAISE FND_API.G_EXC_ERROR;
448 END IF;
449
450 --comment out for notification project
451 /* OE_ORDER_PVT.Process_Requests_And_notify
452 ( p_process_requests => FALSE
453 ,p_notify => TRUE
454 ,x_return_status => l_return_status
455 ,p_Line_Scredit_tbl => l_Line_Scredit_tbl
456 ,p_old_Line_Scredit_tbl => l_old_Line_Scredit_tbl);
457
458 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
459 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
460 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
461 RAISE FND_API.G_EXC_ERROR;
462 END IF;
463 */
464 -- Clear Table
465 l_Line_Scredit_tbl.DELETE;
466
467 END IF; -- l_count.
468
469 OE_DEBUG_PUB.Add('Exiting OE_DELAYED_REQUESTS_UTIL.Cascade_Service_Scredit',1);
470 x_return_status := l_return_status;
471
472 EXCEPTION
473
474 WHEN FND_API.G_EXC_ERROR THEN
475
476 x_return_status := FND_API.G_RET_STS_ERROR;
477
478 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
479
480 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
481
482 WHEN OTHERS THEN
483
484 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
485
486 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
487 THEN
488 OE_MSG_PUB.Add_Exc_Msg
489 ( G_PKG_NAME
490 , 'CASCADE_SERVICE_SCREDIT'
491 );
492 END IF;
493
494
495
496 END Cascade_Service_Scredit;
497
498 PROCEDURE UPDATE_LINK_TO_LINE_ID
499 ( x_return_status OUT NOCOPY Varchar2
500
501 ,p_top_model_line_id IN NUMBER
502 )
503 IS
504 BEGIN
505
506 null;
507
508 END UPDATE_LINK_TO_LINE_ID;
509
510 -- Procedure to Check for Duplicate Discounts
511 PROCEDURE check_duplicate
512 (p_request_rec IN oe_order_pub.request_rec_type,
513 x_return_status OUT NOCOPY VARCHAR2)
514
515 IS
516 l_entity_code VARCHAR2(30);
517 l_entity_id NUMBER := NULL;
518 l_header_id NUMBER := NULL;
519 l_line_id NUMBER := NULL;
520 l_discount_id NUMBER := 0;
521 l_duplicate VARCHAR2(30) := NULL;
522 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
523
524 DUPLICATE_DISCOUNT EXCEPTION;
525
526 BEGIN
527
528 oe_debug_pub.add('Entering OE_DELAYED_REQUESTS_UTIL.CHECK_DUPLICATE', 1);
529
530 l_entity_id := p_request_rec.entity_id;
531 l_entity_code := p_request_rec.entity_code;
532 l_discount_id := To_number(p_request_rec.param1);
533 l_header_id := To_number(p_request_rec.param2);
534 l_line_id := To_number(p_request_rec.param3);
535
536 oe_debug_pub.ADD('OEXSRLNB: Check Duplicate. '||
537 ' entity_code = ' || l_entity_code, 2);
538
539
540 -- Check if same discount has already been applied
541 -- before on the header or any line
542 IF l_entity_code = OE_GLOBALS.G_ENTITY_HEADER_ADJ THEN
543
544 SELECT 'DUPLICATE_DISCOUNT'
545 INTO l_duplicate
546 FROM oe_price_adjustments
547 WHERE header_id = l_header_id
548 AND discount_id = l_discount_id
549 AND price_adjustment_id <> Nvl(l_entity_id, -1)
550 AND line_id IS NULL;
551
552 IF SQL%rowcount <> 0
553 THEN
554 l_return_status := FND_API.G_RET_STS_ERROR;
555
556 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
557 THEN
558
559 fnd_message.set_name('ONT', 'OE_DIS_DUPLICATE_ORD_DISC');
560 OE_MSG_PUB.Add;
561
562 END IF;
563
564 RAISE DUPLICATE_DISCOUNT;
565
566 END IF;
567
568
569 -- Check if same discount has already been applied
570 -- before on the line
571 ELSIF l_entity_code = OE_GLOBALS.G_ENTITY_LINE_ADJ THEN
572
573 SELECT 'DUPLICATE_DISCOUNT'
574 INTO l_duplicate
575 FROM oe_price_adjustments
576 WHERE header_id = l_header_id
577 AND discount_id = l_discount_id
578 AND line_id = l_line_id
579 AND price_adjustment_id <> Nvl(l_entity_id, -1);
580
581 IF SQL%rowcount <> 0 THEN
582 l_return_status := FND_API.G_RET_STS_ERROR;
583
584 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
585 THEN
586
587 fnd_message.set_name('ONT', 'OE_DIS_DUPLICATE_LIN_DISC');
588 OE_MSG_PUB.Add;
589
590 END IF;
591
592 RAISE DUPLICATE_DISCOUNT;
593
594 END IF;
595
596 END IF;
597
598
599 x_return_status := l_return_status;
600
601 oe_debug_pub.add('Exiting OE_DELAYED_REQUESTS_UTIL.CHECK_DUPLICATE', 1);
602
603 EXCEPTION
604
605 WHEN NO_DATA_FOUND OR DUPLICATE_DISCOUNT
606 THEN
607 x_return_status := l_return_status;
608
609 WHEN OTHERS
610 THEN
611 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
612
613 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
614 THEN
615 OE_MSG_PUB.Add_Exc_Msg
616 ( G_PKG_NAME
617 , 'CHECK_DUPLICATE'
618 );
619 END IF;
620
621 END CHECK_DUPLICATE;
622
623 --Procedure to Check Fixed price Discounts
624 PROCEDURE check_fixed_price
625 (p_request_rec IN oe_order_pub.request_rec_type,
626 x_return_status OUT NOCOPY VARCHAR2)
627
628 IS
629 l_entity_code VARCHAR2(30);
630 l_entity_id NUMBER := NULL;
631 l_header_id NUMBER := NULL;
632 l_line_id NUMBER := NULL;
633 l_discount_line_id NUMBER := 0;
634 l_count NUMBER;
635 l_discount_count NUMBER;
636 l_fixed_price VARCHAR2(30) := NULL;
637 l_discount_name VARCHAR2(30) := NULL;
638 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
639 l_number NUMBER := 0;
640
641
642 FIXED_PRICE EXCEPTION;
643 FIXED_PRICE_VIOLATE EXCEPTION;
644
645 CURSOR all_adjustments IS
646 SELECT count(p.price_adjustment_id)
647 FROM oe_price_adjustments p
648 WHERE p.header_id = l_header_id
649 AND (p.line_id = l_line_id
650 OR p.line_id IS NULL) ;
651
652 CURSOR hdr_line_adjustments IS
653 SELECT p.line_id
654 FROM oe_price_adjustments p
655 WHERE p.header_id = l_header_id
656 AND p.line_id IS NOT NULL
657 ORDER by p.line_id;
658
659
660 BEGIN
661
662 oe_debug_pub.add('Entering OE_DELAYED_REQUESTS_UTIL.CHECK_FIXED_PRICE', 1);
663
664 l_entity_id := p_request_rec.entity_id;
665 l_entity_code := p_request_rec.entity_code;
666 l_discount_line_id := To_number(p_request_rec.param1);
667 l_header_id := To_number(p_request_rec.param2);
668 l_line_id := To_number(p_request_rec.param3);
669
670
671 oe_debug_pub.ADD('OEXSRLNB: Check Fixed Price. '||
672 ' entity_code = ' || l_entity_code, 2);
673
674 IF l_entity_code = OE_GLOBALS.G_ENTITY_HEADER_ADJ THEN
675 FOR l_hdr_adjustment IN hdr_line_adjustments LOOP
676
677 l_line_id := l_hdr_adjustment.line_id;
678 l_number := l_number + 1;
679
680 OPEN all_adjustments;
681 FETCH all_adjustments INTO l_discount_count;
682 CLOSE all_adjustments;
683
684 SELECT count(d.name)
685 INTO l_count
686 FROM oe_price_adjustments adj,
687 oe_discount_lines dln,
688 oe_discounts d
689 WHERE adj.header_id = l_header_id
690 AND Nvl(adj.line_id, l_line_id) = l_line_id
691 AND d.discount_id = adj.discount_id
692 AND dln.discount_line_id = adj.discount_line_id
693 AND dln.price IS NOT NULL
694 AND ROWNUM = 1;
695
696 IF l_count <> 0
697 AND l_discount_count = 1 THEN
698 oe_debug_pub.ADD('OEXSRLNB2: Check Fixed Price. '||
699 ' entity_code = ' || l_entity_code, 2);
700 l_return_status := FND_API.G_RET_STS_ERROR;
701 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
702 THEN
703
704 FND_MESSAGE.SET_NAME('ONT', 'OE_DIS_FIXED_PRICE_HEADER');
705 FND_MESSAGE.SET_TOKEN('NUMBER', to_char(l_number));
706 OE_MSG_PUB.Add;
707
708
709 END IF;
710 RAISE FIXED_PRICE_VIOLATE;
711 END IF;
712 END LOOP;
713 END IF;
714
715 IF l_entity_code = OE_GLOBALS.G_ENTITY_LINE_ADJ THEN
716
717 SELECT count(adj.price_adjustment_id)
718 INTO l_count
719 FROM oe_price_adjustments adj
720 WHERE adj.header_id = l_header_id
721 AND Nvl(adj.line_id, l_line_id) = l_line_id
722 AND exists
723 (SELECT 'fixed_price'
724 FROM oe_discount_lines dln
725 WHERE dln.discount_line_id = l_discount_line_id
726 AND dln.price IS NOT NULL)
727 AND ROWNUM = 1;
728
729 IF l_count <> 0 THEN
730
731 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
732 THEN
733
734 FND_MESSAGE.SET_NAME('ONT', 'OE_DIS_FIXED_PRICE');
735 OE_MSG_PUB.Add;
736
737 END IF;
738
739 RAISE FIXED_PRICE;
740
741 END IF;
742
743 OPEN all_adjustments;
744 FETCH all_adjustments INTO l_discount_count;
745 CLOSE all_adjustments;
746
747
748 SELECT d.name
749 INTO l_fixed_price
750 FROM oe_price_adjustments adj,
751 oe_discount_lines dln,
752 oe_discounts d
753 WHERE adj.header_id = l_header_id
754 AND Nvl(adj.line_id, l_line_id) = l_line_id
755 AND d.discount_id = adj.discount_id
756 AND dln.discount_line_id = adj.discount_line_id
757 AND dln.price IS NOT NULL
758 AND ROWNUM = 1;
759
760 oe_debug_pub.ADD('OEXSRLNB1: Check Fixed Price. '||
761 ' entity_code = ' || l_entity_code, 2);
762 IF SQL%rowcount <> 0
763 AND l_discount_count = 1 THEN
764 oe_debug_pub.ADD('OEXSRLNB2: Check Fixed Price. '||
765 ' entity_code = ' || l_entity_code, 2);
766 l_return_status := FND_API.G_RET_STS_ERROR;
767 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
768 THEN
769
770 FND_MESSAGE.SET_NAME('ONT', 'OE_DIS_FIXED_PRICE_VIOL');
771 FND_MESSAGE.SET_TOKEN('NAME', l_fixed_price);
772 OE_MSG_PUB.Add;
773
774 END IF;
775
776 RAISE FIXED_PRICE_VIOLATE;
777
778 END IF;
779 END IF;
780
781
782 x_return_status := FND_API.G_RET_STS_SUCCESS;
783
784 oe_debug_pub.add('Exiting OE_DELAYED_REQUESTS_UTIL.CHECK_FIXED_PRICE', 1);
785
786 EXCEPTION
787
788 WHEN NO_DATA_FOUND OR FIXED_PRICE
789 THEN
790 x_return_status := FND_API.G_RET_STS_SUCCESS;
791
792 WHEN FIXED_PRICE_VIOLATE
793 THEN
794 x_return_status := l_return_status;
795
796
797 WHEN OTHERS
798 THEN
799 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
800
801 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
802 THEN
803 OE_MSG_PUB.Add_Exc_Msg
804 ( G_PKG_NAME
805 , 'CHECK_FIXED_PRICE'
806 );
807 END IF;
808
809 END CHECK_FIXED_PRICE;
810
811
812 PROCEDURE check_percentage
813 (p_request_rec IN oe_order_pub.request_rec_type,
814 x_return_status OUT NOCOPY VARCHAR2)
815
816 IS
817 l_control_rec OE_GLOBALS.Control_Rec_Type;
818 l_entity_code VARCHAR2(30);
819 l_entity_id NUMBER := NULL;
820 l_header_id NUMBER := NULL;
821 l_line_id NUMBER := NULL;
822 l_percentage NUMBER := 0;
823 l_percent_total NUMBER := 0;
824 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
825 l_apply_order_adjs VARCHAR2(1) :=
826 Nvl(fnd_profile.value('OE_APPLY_ORDER_ADJS_TO_SERVICE'),
827 'N');
828
829 percentage_exceeded EXCEPTION;
830
831
832 CURSOR all_adjustments IS
833 SELECT p.price_adjustment_id, Nvl(p.line_id, -1) line_id
834 FROM oe_price_adjustments p,
835 oe_order_lines o
836 WHERE p.header_id = l_header_id
837 AND o.header_id = l_header_id
838 AND (p.line_id = o.line_id
839 OR p.line_id IS NULL)
840 ORDER BY p.line_id;
841
842
843 CURSOR hdr_adj_total IS
844 SELECT Nvl(SUM(percent), 0)
845 FROM oe_price_adjustments p
846 WHERE header_id = l_header_id
847 AND line_id IS NULL;
848
849
850 CURSOR line_adj_total IS
851 SELECT Nvl(SUM(percent), 0) + l_percent_total
852 FROM oe_price_adjustments
853 WHERE header_id = l_header_id
854 AND line_id = l_line_id;
855
856
857
858 CURSOR max_line_adj_total IS
859 SELECT NVL( MAX(SUM(PERCENT)), 0) + l_percent_total
860 FROM OE_PRICE_ADJUSTMENTS P, OE_ORDER_LINES L
861 WHERE P.HEADER_ID = l_header_id
862 AND P.LINE_ID IS NOT NULL
863 AND P.LINE_ID = L.LINE_ID
864 GROUP BY P.line_id;
865
866
867 BEGIN
868
869 oe_debug_pub.add('Entering OE_DELAYED_REQUESTS_UTIL.CHECK_PERCENTAGE', 1);
870
871 l_entity_code := p_request_rec.entity_code;
872
873 oe_debug_pub.ADD('OEXSRLNB: Check Percentage. '||
874 ' entity_code = ' || l_entity_code, 2);
875
876
877 -- Check if maximum percentage has not been execeded on the
878 -- header price adjustment
879 IF l_entity_code = OE_GLOBALS.G_ENTITY_HEADER_ADJ
880 THEN
881
882 l_header_id := p_request_rec.entity_id;
883
884 oe_debug_pub.ADD('OEXSRLNB: check header percentage', 2);
885
886 OPEN hdr_adj_total;
887 FETCH hdr_adj_total INTO l_percent_total;
888 CLOSE hdr_adj_total;
889
890 OPEN max_line_adj_total;
891 FETCH max_line_adj_total INTO l_percent_total;
892 CLOSE max_line_adj_total;
893
894 oe_debug_pub.ADD('OEXSRLNB: maximum percentage total = ' ||
895 To_char(l_percent_total), 2);
896
897 IF ( l_percent_total > 100 ) THEN
898
899 l_return_status := FND_API.G_RET_STS_ERROR;
900
901 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
902 THEN
903
904 FND_MESSAGE.SET_NAME('ONT','OE_DIS_ADJUSTMENT_TOTAL');
905 FND_MESSAGE.SET_TOKEN('TOTAL', To_char(l_percent_total));
906 OE_MSG_PUB.Add;
907
908 END IF;
909
910 RAISE percentage_exceeded;
911
912 END IF;
913
914
915 -- Check if maximum percentage has not been execeded on the
916 -- line price adjustment
917 ELSIF l_entity_code = OE_GLOBALS.G_ENTITY_LINE_ADJ THEN
918
919 l_line_id := p_request_rec.entity_id;
920 l_header_id := To_number(p_request_rec.param1);
921
922 oe_debug_pub.ADD('OEXSRLNB: check line percentage', 2);
923
924 OPEN hdr_adj_total;
925 FETCH hdr_adj_total INTO l_percent_total;
926 CLOSE hdr_adj_total;
927
928 OPEN line_adj_total;
929 FETCH line_adj_total INTO l_percent_total;
930 CLOSE line_adj_total;
931
932 oe_debug_pub.ADD('OEXSRLNB: line percentage total = ' ||
933 To_char(l_percent_total), 2);
934
935
936 IF ( l_percent_total > 100 ) THEN
937
938 l_return_status := FND_API.G_RET_STS_ERROR;
939
940 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
941 THEN
942
943 FND_MESSAGE.SET_NAME('ONT','OE_DIS_ADJUSTMENT_TOTAL');
944 FND_MESSAGE.SET_TOKEN('TOTAL', To_char(l_percent_total));
945 OE_MSG_PUB.Add;
946
947 END IF;
948
949 RAISE percentage_exceeded;
950
951 END IF;
952
953
954 -- Check all header and line level price adjustments in execess of
955 -- maximum allowable price adjustments
956 -- This is a call from Order Import
957
958 ELSIF l_entity_code IS NULL
959 THEN
960
961 FOR l_adjustment IN all_adjustments LOOP
962
963 -- How to get header id in this case ????????
964 l_line_id := l_adjustment.line_id;
965 l_entity_id := l_adjustment.price_adjustment_id;
966
967 IF l_line_id = -1 THEN -- header level price adjustment
968
969 OPEN hdr_adj_total;
970 FETCH hdr_adj_total INTO l_percent_total;
971 CLOSE hdr_adj_total;
972
973 OPEN max_line_adj_total;
974 FETCH max_line_adj_total INTO l_percent_total;
975 CLOSE max_line_adj_total;
976
977 ELSE -- line level price adjustment
978
979 OPEN line_adj_total;
980 FETCH line_adj_total INTO l_percent_total;
981 CLOSE line_adj_total;
982
983 END IF;
984
985 END LOOP;
986
987 END IF;
988
989
990 x_return_status := l_return_status;
991
992 oe_debug_pub.add('Exiting OE_DELAYED_REQUESTS_UTIL.CHECK_PERCENTAGE', 1);
993
994 EXCEPTION
995
996 WHEN PERCENTAGE_EXCEEDED
997 THEN
998 x_return_status := l_return_status;
999
1000
1001 WHEN OTHERS THEN
1002 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1003
1004 IF line_adj_total%isopen THEN
1005 CLOSE line_adj_total;
1006 END IF;
1007
1008 IF all_adjustments%isopen THEN
1009 CLOSE all_adjustments;
1010 END IF;
1011
1012 IF hdr_adj_total%isopen THEN
1013 CLOSE hdr_adj_total;
1014 END IF;
1015
1016 IF max_line_adj_total%isopen THEN
1017 CLOSE max_line_adj_total;
1018 END IF;
1019
1020 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1021 THEN
1022 OE_MSG_PUB.Add_Exc_Msg
1023 ( G_PKG_NAME
1024 , 'CHECK_PERCENTAGE'
1025 );
1026 END IF;
1027
1028 END check_percentage;
1029
1030 PROCEDURE CREATE_CONFIG_ITEM
1031 ( x_return_status OUT NOCOPY Varchar2
1032
1033 ,p_top_model_line_id IN NUMBER
1034 ,p_header_id IN NUMBER
1035 )
1036 IS
1037 l_return_status VARCHAR2(1);
1038 l_control_rec OE_GLOBALS.Control_Rec_Type;
1039 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
1040 l_old_line_tbl OE_Order_PUB.Line_Tbl_Type;
1041 l_line_rec OE_Order_PUB.Line_Rec_Type;
1042 l_api_name CONSTANT VARCHAR2(30) := 'Insert_Order';
1043 l_line_id NUMBER;
1044 l_component_sequence_id NUMBER;
1045 l_component_code VARCHAR2(1000);
1046 l_component_item_id NUMBER;
1047 l_sort_order VARCHAR2(240);
1048 l_component_quantity NUMBER;
1049 l_bom_item_type VARCHAR2(30);
1050 l_top_model_line_id NUMBER;
1051 l_config_rec OE_ORDER_PUB.line_rec_type;
1052 l_select_flag VARCHAR2(1);
1053 l_bill_sequence_id NUMBER;
1054 l_top_bill_sequence_id NUMBER;
1055 l_option_number NUMBER;
1056 l_request_rec OE_Order_Pub.request_rec_type;
1057 l_request_tbl OE_Order_Pub.Request_Tbl_Type;
1058 req_ind NUMBER;
1059 BEGIN
1060
1061 oe_debug_pub.add('Entering OE_DELAYED_REQUESTS_UTIL.CREATE_CONFIG_ITEM', 1);
1062
1063
1064 oe_debug_pub.add('In procedure Create_Config', 2);
1065
1066 l_line_rec := OE_Order_PUB.G_MISS_LINE_REC;
1067
1068
1069 -- Set Control Record
1070
1071 l_control_rec.controlled_operation := TRUE;
1072 l_control_rec.default_attributes := TRUE;
1073 l_control_rec.change_attributes := TRUE;
1074 l_control_rec.validate_entity := TRUE;
1075 l_control_rec.write_to_DB := TRUE;
1076 l_control_rec.process := FALSE;
1077
1078
1079 OE_DEBUG_PUB.ADD('Loading top_model_line_id: ' || p_top_model_line_id, 2);
1080 l_config_rec :=
1081 OE_Order_Cache.Load_Top_Model_Line (p_top_model_line_id);
1082
1083 l_line_rec.top_model_line_id := p_top_model_line_id;
1084 l_line_rec.header_id := p_header_id;
1085 l_line_rec.item_type_code := OE_GLOBALS.G_ITEM_CONFIG;
1086 l_line_rec.line_number := l_config_rec.line_number;
1087 l_line_rec.shipment_number := l_config_rec.shipment_number;
1088 l_line_rec.option_number := NULL;
1089 -- l_line_rec.component_number := NULL;
1090 l_line_rec.operation := OE_GLOBALS.G_OPR_CREATE;
1091
1092 l_line_tbl(1) := l_line_rec;
1093
1094 -- Set recursion mode.
1095 -- OE_GLOBALS.G_RECURSION_MODE := 'Y';
1096
1097 OE_ORDER_PVT.Lines
1098 (p_validation_level => FND_API.G_VALID_LEVEL_FULL
1099 ,p_control_rec => l_control_rec
1100 ,p_x_line_tbl => l_line_tbl
1101 ,p_x_old_line_tbl => l_old_line_tbl
1102 ,x_return_status => l_return_status);
1103
1104 -- Reset recursion mode.
1105 -- OE_GLOBALS.G_RECURSION_MODE := 'N';
1106
1107 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1108 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1109 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1110 RAISE FND_API.G_EXC_ERROR;
1111 END IF;
1112
1113 --comment out for notification project
1114 /* OE_ORDER_PVT.Process_Requests_And_notify
1115 ( p_process_requests => FALSE
1116 ,p_notify => TRUE
1117 ,x_return_status => l_return_status
1118 ,p_line_tbl => l_line_tbl
1119 ,p_old_line_tbl => l_old_line_tbl);
1120
1121 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1122 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1123 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1124 RAISE FND_API.G_EXC_ERROR;
1125 END IF;
1126 */
1127
1128 oe_debug_pub.add('Exiting OE_DELAYED_REQUESTS_UTIL.CREATE_CONFIG_ITEM', 1);
1129
1130 EXCEPTION
1131
1132 WHEN FND_API.G_EXC_ERROR THEN
1133
1134 x_return_status := FND_API.G_RET_STS_ERROR;
1135
1136 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1137
1138 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1139
1140 WHEN OTHERS THEN
1141
1142 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1143
1144 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1145 THEN
1146 OE_MSG_PUB.Add_Exc_Msg
1147 ( G_PKG_NAME
1148 , 'Validate_LSC_QUOTA_TOTAL'
1149 );
1150 END IF;
1151 END CREATE_CONFIG_ITEM;
1152
1153 PROCEDURE INS_INCLUDED_ITEMS
1154 ( x_return_status OUT NOCOPY Varchar2
1155
1156 ,p_line_id IN NUMBER
1157 )
1158 IS
1159 BEGIN
1160
1161 oe_debug_pub.add('Entering OE_DELAYED_REQUESTS_UTIL.INS_INCLUDED_ITEMS', 1);
1162
1163 OE_DEBUG_PUB.ADD('Inserting Included Items', 2);
1164
1165 oe_debug_pub.add('Exiting OE_DELAYED_REQUESTS_UTIL.INS_INCLUDED_ITEMS', 1);
1166 Null;
1167 END;
1168
1169 PROCEDURE verify_payment
1170 ( x_return_status OUT NOCOPY varchar2
1171
1172 ,p_header_id IN Number
1173 )
1174 IS
1175 l_return_status VARCHAR2(30);
1176 l_msg_count NUMBER;
1177 l_msg_data VARCHAR2(2000);
1178 BEGIN
1179
1180 x_return_status := FND_API.G_RET_STS_SUCCESS;
1181
1182 oe_debug_pub.ADD('Entering delayed request utility for verify payment',1);
1183
1184 OE_Verify_Payment_PUB.Verify_Payment
1185 ( p_header_id => p_header_id
1186 , p_calling_action => 'UPDATE'
1187 , p_delayed_request=> FND_API.G_TRUE
1188 , p_msg_count => l_msg_count
1189 , p_msg_data => l_msg_data
1190 , p_return_status => l_return_status
1191 );
1192
1193 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1194 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1195 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1196 RAISE FND_API.G_EXC_ERROR;
1197 END IF;
1198
1199 oe_debug_pub.ADD('Exiting delayed request utility for verify payment',1);
1200
1201 EXCEPTION
1202
1203 WHEN FND_API.G_EXC_ERROR THEN
1204
1205 x_return_status := FND_API.G_RET_STS_ERROR;
1206
1207 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1208
1209 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1210
1211 WHEN OTHERS THEN
1212
1213 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1214
1215 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1216 THEN
1217 OE_MSG_PUB.Add_Exc_Msg
1218 ( G_PKG_NAME
1219 , 'Verify_Payment'
1220 );
1221 END IF;
1222
1223 END Verify_Payment;
1224
1225
1226 /* procedure insert_rma_scredit_adjustment
1227 To insert sales credit of corresponding RMA lines.
1228 if sales credit exists on the existing line, delete them first,
1229 then insert new ones taken from the referenced line.
1230 Price adjustments has been moved to apply change attributes
1231 */
1232 Procedure INSERT_RMA_SCREDIT_ADJUSTMENT
1233 (p_line_id IN NUMBER
1234 ,x_return_status OUT NOCOPY VARCHAR2
1235
1236 )
1237 IS
1238 l_Line_Scredit_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
1239 l_ref_header_id NUMBER;
1240 l_ref_line_id NUMBER;
1241 l_header_id NUMBER;
1242 I NUMBER := 1;
1243 I1 NUMBER := 1;
1244 I2 NUMBER := 1;
1245 l_api_name CONSTANT VARCHAR(30) := 'INSERT_RMA_SCREDIT_ADJUSTMENT';
1246 l_control_rec OE_GLOBALS.Control_Rec_Type;
1247 l_x_Line_Scredit_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
1248 l_x_old_Line_Scredit_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
1249 l_return_status VARCHAR2(30);
1250 l_count NUMBER := 0;
1251 l_split_by VARCHAR2(30);
1252 l_src_doc_type_id NUMBER; -- added for bug 6778016
1253 BEGIN
1254
1255 OE_DEBUG_PUB.ADD('RMA: In INSERT_RMA_SCREDIT_ADJUSTMENT',1);
1256
1257 OE_DEBUG_PUB.ADD('RMA: Line Id is '||TO_CHAR(p_line_id),2);
1258
1259 x_return_status := FND_API.G_RET_STS_SUCCESS;
1260
1261 -- bug 3317323
1262 BEGIN
1263 SELECT header_id, reference_header_id, reference_line_id,split_by
1264 ,SOURCE_DOCUMENT_TYPE_ID --added source document id as a part of 6778016
1265 INTO l_header_id,l_ref_header_id, l_ref_line_id, l_split_by
1266 ,l_src_doc_type_id --added l_src_doc_type_id as a part of 6778016
1267 FROM oe_order_lines
1268 WHERE line_id = p_line_id;
1269 EXCEPTION
1270 WHEN NO_DATA_FOUND THEN
1271 OE_DEBUG_PUB.ADD('Invalid line_id',1);
1272 RETURN;
1273 END;
1274 IF l_split_by = 'SYSTEM' THEN
1275 RETURN;
1276 END IF;
1277 -- bug 3317323
1278
1279 -- delete the existing Sales Credit on the RMA line
1280 BEGIN
1281 OE_Line_Scredit_Util.Lock_Rows
1282 (p_line_id => p_line_id
1283 ,x_line_Scredit_tbl => l_Line_Scredit_tbl
1284 ,x_return_status => l_return_status);
1285
1286 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1287 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1288 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1289 RAISE FND_API.G_EXC_ERROR;
1290 END IF;
1291 EXCEPTION
1292 WHEN NO_DATA_FOUND THEN
1293 OE_DEBUG_PUB.ADD('There are no existing sales credits to delete',1);
1294 NULL;
1295 END;
1296
1297 IF l_Line_Scredit_tbl.COUNT > 0 THEN
1298
1299 FOR I IN l_Line_Scredit_tbl.FIRST .. l_Line_Scredit_tbl.LAST LOOP
1300
1301 l_x_Line_Scredit_tbl(I):= l_line_Scredit_tbl(I);
1302 l_x_Line_Scredit_tbl(I).operation := OE_GLOBALS.G_OPR_DELETE;
1303
1304 END LOOP;
1305
1306 -- Clear Table
1307 l_Line_Scredit_tbl.DELETE;
1308
1309 END IF; /* end delete existing sales credit */
1310
1311 -- get new sales credit and insert into RMA
1312
1313 -- get the reference_id first
1314 /* moved to the beginning of the procedure to fix bug 3317323
1315 BEGIN
1316 SELECT header_id, reference_header_id, reference_line_id
1317 INTO l_header_id,l_ref_header_id, l_ref_line_id
1318 FROM oe_order_lines
1319 WHERE line_id = p_line_id;
1320 EXCEPTION
1321 WHEN NO_DATA_FOUND THEN
1322 OE_DEBUG_PUB.ADD('Invalid line_id',1);
1323 RETURN;
1324 END;
1325 */
1326
1327 BEGIN
1328 OE_Line_Scredit_Util.Query_Rows(p_line_id => l_ref_line_id
1329 ,x_line_Scredit_tbl => l_Line_Scredit_tbl);
1330 EXCEPTION
1331 WHEN NO_DATA_FOUND THEN
1332 --RETURN;
1333 OE_DEBUG_PUB.ADD('There are no Sales credits on the reference line',1);
1334 NULL;
1335 END;
1336
1337 IF l_Line_Scredit_tbl.COUNT > 0 THEN
1338
1339 l_count := l_x_line_Scredit_tbl.count;
1340
1341 FOR I IN l_Line_Scredit_tbl.FIRST .. l_Line_Scredit_tbl.LAST LOOP
1342
1343 l_x_Line_Scredit_tbl(l_count + I):= l_line_Scredit_tbl(I);
1344 l_x_Line_Scredit_tbl(l_count + I).operation := OE_GLOBALS.G_OPR_CREATE;
1345 l_x_Line_Scredit_tbl(l_count + I).header_id := l_header_id;
1346 l_x_Line_Scredit_tbl(l_count + I).line_id := p_line_id;
1347 l_x_Line_Scredit_tbl(l_count + I).sales_credit_id := FND_API.G_MISS_NUM;
1348
1349 END LOOP;
1350
1351 END IF; /* end inserting sales credit */
1352
1353 IF l_x_Line_Scredit_tbl.COUNT > 0 THEN
1354 -- Call OE_Order_PVT.Process_order to insert sales credits.
1355 -- Set recursion mode.
1356 -- OE_GLOBALS.G_RECURSION_MODE := 'Y';
1357
1358 /* Adding the if condition for bug 6778016/
1359 /* The control record structure passsed while calling process_order oe_copy_util.copy_order
1360 has process_partial to true and clear_dependents to false. However, in between as we were
1361 initializing the control record in to oe_globals.Control_Rec_Type, the values are getting
1362 changed.This is resulting in some issues. Hence we are resetting these two parametes to the
1363 initial values passed.
1364 */
1365 if l_src_doc_type_id=2 or NOT (OE_GLOBALS.G_UI_FLAG) --2nd condition added for bug 8820838
1366 then
1367 OE_DEBUG_PUB.ADD('Order is getting copied, Setting process partial flag to true');
1368 l_control_rec.controlled_operation:=true;
1369 l_control_rec.process_partial:=true;
1370 l_control_rec.clear_dependents:= FALSE;
1371 end if; /*End of changes for bug 6778016*/
1372
1373 OE_DEBUG_PUB.ADD('Calling OE_ORDER_PVT.Line_Scredits',1);
1374 OE_ORDER_PVT.Line_Scredits
1375 (p_validation_level => FND_API.G_VALID_LEVEL_FULL
1376 ,p_control_rec => l_control_rec
1377 ,p_x_Line_Scredit_tbl => l_x_Line_Scredit_tbl
1378 ,p_x_old_Line_Scredit_tbl => l_x_old_Line_Scredit_tbl
1379 ,x_return_status => l_return_status);
1380
1381 OE_DEBUG_PUB.ADD('After Calling OE_ORDER_PVT.Line_Scredits',1);
1382 -- Reset recursion mode.
1383 -- OE_GLOBALS.G_RECURSION_MODE := 'N';
1384
1385 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1386 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1387 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1388 RAISE FND_API.G_EXC_ERROR;
1389 END IF;
1390
1391 --comment out for notification project
1392 /* OE_ORDER_PVT.Process_Requests_And_notify
1393 ( p_process_requests => FALSE
1394 ,p_notify => TRUE
1395 ,x_return_status => l_return_status
1396 ,p_Line_Scredit_tbl => l_x_Line_Scredit_tbl
1397 ,p_old_Line_Scredit_tbl => l_x_old_Line_Scredit_tbl);
1398
1399 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1400 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1401 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1402 RAISE FND_API.G_EXC_ERROR;
1403 END IF;
1404 */
1405 -- Clear Table
1406 l_Line_Scredit_tbl.DELETE;
1407
1408 END IF; /* end inserting sales credit */
1409
1410 oe_debug_pub.add('Exit INSERT_RMA_SCREDIT_ADJUSTMENT',1);
1411 EXCEPTION
1412
1413
1414 WHEN FND_API.G_EXC_ERROR THEN
1415
1416 x_return_status := FND_API.G_RET_STS_ERROR;
1417
1418 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1419
1420 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1421
1422 WHEN OTHERS THEN
1423
1424 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1425
1426 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1427 THEN
1428 OE_MSG_PUB.Add_Exc_Msg
1429 ( G_PKG_NAME
1430 , 'INSERT_RMA_SCREDIT_ADJUSTMENT'
1431 );
1432 END IF;
1433
1434 END INSERT_RMA_SCREDIT_ADJUSTMENT;
1435
1436 /*
1437 Commented out the procedure tax_line as it is not called from
1438 anywhere in the OM code.
1439
1440 -------------------------------------------------------------------
1441 Procedure: TAX_LINE
1442 -------------------------------------------------------------------
1443
1444
1445 PROCEDURE Tax_Line ( x_return_status OUT NOCOPY VARCHAR2
1446 , p_line_id IN NUMBER
1447 )
1448 IS
1449 l_return_status Varchar2(30):= FND_API.G_RET_STS_SUCCESS;
1450 --l_tax_value NUMBER := 0;
1451 l_line_id NUMBER := p_line_id;
1452 l_msg_count NUMBER := 0;
1453 l_count NUMBER := 0;
1454 l_counter NUMBER := 0;
1455 l_msg_data VARCHAR2(2000);
1456 l_tax_value NUMBER := 0;
1457 l_control_rec OE_GLOBALS.Control_Rec_Type;
1458 l_tax_code VARCHAR2(50);
1459 l_line_rec OE_Order_PUB.Line_Rec_Type;
1460 l_old_line_rec OE_Order_PUB.Line_Rec_Type;
1461 l_line_val_rec OE_Order_PUB.Line_Val_Rec_Type;
1462 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
1463 l_old_line_tbl OE_Order_PUB.Line_Tbl_Type;
1464 l_Line_Adj_rec OE_Order_PUB.Line_Adj_Rec_Type;
1465 l_Line_Adj_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
1466 l_l_Line_Adj_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
1467 l_Line_Adj_val_rec OE_Order_PUB.Line_Adj_Val_Rec_Type;
1468 l_x_header_rec OE_Order_PUB.Header_Rec_Type;
1469 l_x_Header_Adj_rec OE_Order_PUB.Header_Adj_Rec_Type;
1470 l_x_Header_Adj_tbl OE_Order_PUB.Header_Adj_Tbl_Type;
1471 l_x_Header_Scredit_rec OE_Order_PUB.Header_Scredit_Rec_Type;
1472 l_x_Header_Scredit_tbl OE_Order_PUB.Header_Scredit_Tbl_Type;
1473 l_x_line_rec OE_Order_PUB.Line_Rec_Type;
1474 l_x_line_tbl OE_Order_PUB.Line_Tbl_Type;
1475 l_x_Line_Adj_rec OE_Order_PUB.Line_Adj_Rec_Type;
1476 l_x_Line_Adj_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
1477 l_x_Line_Scredit_rec OE_Order_PUB.Line_Scredit_Rec_Type;
1478 l_x_Line_Scredit_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
1479 l_x_Action_Request_tbl OE_Order_PUB.Request_Tbl_Type;
1480 l_x_Lot_Serial_Tbl OE_Order_PUB.Lot_Serial_Tbl_Type;
1481 l_x_Header_price_Att_tbl OE_Order_PUB.Header_Price_Att_Tbl_Type;
1482 l_x_Header_Adj_Att_tbl OE_Order_PUB.Header_Adj_Att_Tbl_Type;
1483 l_x_Header_Adj_Assoc_tbl OE_Order_PUB.Header_Adj_Assoc_Tbl_Type;
1484 l_x_Line_price_Att_tbl OE_Order_PUB.Line_Price_Att_Tbl_Type;
1485 l_x_Line_Adj_Att_tbl OE_Order_PUB.Line_Adj_Att_Tbl_Type;
1486 l_x_Line_Adj_Assoc_tbl OE_Order_PUB.Line_Adj_Assoc_Tbl_Type;
1487 l_tax_rec_out_tbl OM_TAX_UTIL.om_tax_out_tab_type;
1488 currency_code varchar2(30) := NULL;
1489 header_org_id number;
1490 inventory_org_id number;
1491 conversion_rate number;
1492 --serla begin
1493 l_x_Header_Payment_tbl OE_Order_PUB.Header_Payment_Tbl_Type;
1494 l_x_Line_Payment_tbl OE_Order_PUB.Line_Payment_Tbl_Type;
1495 --serla end
1496 l_header_rec OE_Order_PUB.Header_Rec_Type;
1497 BEGIN
1498 x_return_status := l_return_status;
1499
1500 -- Get the Line record
1501 oe_debug_pub.add('Entering Tax line',1);
1502
1503 BEGIN
1504
1505 OE_LINE_UTIL.Query_Row(p_line_id => l_line_id,
1506 x_line_rec => l_line_rec);
1507 l_old_line_rec := l_line_rec;
1508
1509 EXCEPTION
1510 WHEN OTHERS THEN
1511 RAISE NO_DATA_FOUND;
1512 END;
1513
1514
1515 -- Call the procedure to get the Tax on the order line
1516 oe_order_cache.load_order_header(l_line_rec.header_id);
1517 l_header_rec := oe_order_cache.g_header_rec;
1518
1519 OM_TAX_UTIL.TAX_LINE(p_line_rec => l_line_rec,
1520 p_header_rec => l_header_Rec,
1521 x_tax_value => l_tax_value,
1522 x_tax_out_tbl => l_tax_rec_out_tbl,
1523 x_return_status => l_return_status );
1524
1525 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1526 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1527 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1528 RAISE FND_API.G_EXC_ERROR;
1529 END IF;
1530
1531 l_line_rec.tax_value := l_tax_value;
1532
1533 oe_debug_pub.add('After Successfully calculating Tax',2);
1534
1535 -- Check for existing TAX records in OE_PRICE_ADJUSTMENTS table for the
1536 -- given line record.
1537 -- Replace Query_rows with lock rows --
1538 BEGIN
1539 OE_Line_Adj_UTIL.Lock_Rows
1540 ( p_line_id => l_line_id
1541 ,x_line_adj_tbl => l_l_line_adj_tbl
1542 ,x_return_status => l_return_status);
1543 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1544 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1545 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1546 RAISE FND_API.G_EXC_ERROR;
1547 END IF;
1548 EXCEPTION
1549 WHEN OTHERS THEN
1550 x_return_status := FND_API.G_RET_STS_SUCCESS;
1551 END;
1552
1553 -- If any TAX records exists, then delete those records.
1554 oe_debug_pub.add('line_adj_tbl count is : ' || l_l_line_adj_tbl.count , 1);
1555
1556 IF l_l_line_adj_tbl.COUNT > 0 THEN
1557
1558 FOR I IN 1..l_l_line_adj_tbl.COUNT LOOP
1559 oe_debug_pub.add('Parent adj Id is '||
1560 to_char(l_l_line_adj_tbl(I).parent_adjustment_id),2);
1561 IF l_l_line_adj_tbl(I).list_line_type_code = 'TAX' AND
1562 l_l_line_adj_tbl(I).parent_adjustment_id IS NULL
1563 THEN
1564 l_counter := l_counter + 1;
1565 l_line_adj_tbl(l_counter) := l_l_line_adj_tbl(I);
1566 -- Set Operation to delete
1567 l_Line_Adj_tbl(l_counter).operation := OE_GLOBALS.G_OPR_DELETE;
1568 END IF;
1569 END LOOP;
1570 END IF;
1571
1572 -- Load IN parameters for Line Adjustment record
1573
1574 oe_debug_pub.add('line tax rec out nocopy table 1: ' || l_tax_rec_out_tbl.count , 1);
1575
1576 IF l_tax_rec_out_tbl.COUNT > 0
1577 THEN
1578 FOR I IN 1..l_tax_rec_out_tbl.COUNT LOOP
1579
1580 IF l_tax_rec_out_tbl(I).trx_line_id = l_line_rec.line_id
1581 THEN
1582
1583 l_Line_adj_tbl(l_counter+I) := OE_ORDER_PUB.G_MISS_LINE_ADJ_REC;
1584 l_Line_adj_tbl(l_counter+I).header_id := l_line_rec.header_id;
1585 l_Line_adj_tbl(l_counter+I).line_id := l_line_rec.line_id;
1586 l_Line_adj_tbl(l_counter+I).tax_code := l_tax_rec_out_tbl(I).tax_rate_code;
1587 l_Line_Adj_tbl(l_counter+I).operand := l_tax_rec_out_tbl(I).tax_rate;
1588 l_Line_Adj_tbl(l_counter+I).adjusted_amount :=
1589 l_tax_rec_out_tbl(I).tax_amount;
1590 l_Line_Adj_tbl(l_counter+I).automatic_flag := 'N';
1591 l_Line_Adj_tbl(l_counter+I).list_line_type_code := 'TAX';
1592 l_Line_Adj_tbl(l_counter+I).arithmetic_operator := 'AMT';
1593
1594 -- Set flex attributes to NULL in order to avoid defaulting them.
1595
1596 l_Line_Adj_tbl(l_counter+I).context := NULL;
1597 l_Line_Adj_tbl(l_counter+I).attribute1 := NULL;
1598 l_Line_Adj_tbl(l_counter+I).attribute2 := NULL;
1599 l_Line_Adj_tbl(l_counter+I).attribute3 := NULL;
1600 l_Line_Adj_tbl(l_counter+I).attribute4 := NULL;
1601 l_Line_Adj_tbl(l_counter+I).attribute5 := NULL;
1602 l_Line_Adj_tbl(l_counter+I).attribute6 := NULL;
1603 l_Line_Adj_tbl(l_counter+I).attribute7 := NULL;
1604 l_Line_Adj_tbl(l_counter+I).attribute8 := NULL;
1605 l_Line_Adj_tbl(l_counter+I).attribute9 := NULL;
1606 l_Line_Adj_tbl(l_counter+I).attribute10 := NULL;
1607 l_Line_Adj_tbl(l_counter+I).attribute11 := NULL;
1608 l_Line_Adj_tbl(l_counter+I).attribute12 := NULL;
1609 l_Line_Adj_tbl(l_counter+I).attribute13 := NULL;
1610 l_Line_Adj_tbl(l_counter+I).attribute14 := NULL;
1611 l_Line_Adj_tbl(l_counter+I).attribute15 := NULL;
1612
1613 -- Set other attributes to NULL
1614
1615 l_Line_Adj_tbl(l_counter+I).OPERATION := NULL;
1616 l_Line_Adj_tbl(l_counter+I).PERCENT := NULL;
1617 l_Line_Adj_tbl(l_counter+I).DISCOUNT_ID := NULL;
1618 l_Line_Adj_tbl(l_counter+I).DISCOUNT_LINE_ID := NULL;
1619 l_Line_Adj_tbl(l_counter+I).request_id := NULL;
1620 l_Line_Adj_tbl(l_counter+I).orig_sys_discount_ref := NULL;
1621 l_Line_Adj_tbl(l_counter+I).list_header_id := NULL;
1622 l_Line_Adj_tbl(l_counter+I).list_line_id := NULL;
1623 l_Line_Adj_tbl(l_counter+I).modifier_mechanism_type_code:= NULL;
1624 l_Line_Adj_tbl(l_counter+I).modified_from := NULL;
1625 l_Line_Adj_tbl(l_counter+I).modified_to := NULL;
1626 l_Line_Adj_tbl(l_counter+I).updated_flag := NULL;
1627 l_Line_Adj_tbl(l_counter+I).update_allowed := NULL;
1628 l_Line_Adj_tbl(l_counter+I).applied_flag := NULL;
1629 l_Line_Adj_tbl(l_counter+I).change_reason_code := NULL;
1630 l_Line_Adj_tbl(l_counter+I).change_reason_text := NULL;
1631 l_Line_Adj_tbl(l_counter+I).cost_id := NULL;
1632 l_Line_Adj_tbl(l_counter+I).tax_exempt_flag := NULL;
1633 l_Line_Adj_tbl(l_counter+I).tax_exempt_number := NULL;
1634 l_Line_Adj_tbl(l_counter+I).tax_exempt_reason_code := NULL;
1635 l_Line_Adj_tbl(l_counter+I).parent_adjustment_id := NULL;
1636 l_Line_Adj_tbl(l_counter+I).invoiced_flag := NULL;
1637 l_Line_Adj_tbl(l_counter+I).estimated_flag := NULL;
1638 l_Line_Adj_tbl(l_counter+I).inc_in_sales_performance := NULL;
1639 l_Line_Adj_tbl(l_counter+I).split_action_code := NULL;
1640
1641 -- Set Operation to Create
1642 l_Line_Adj_tbl(l_counter+I).operation := OE_GLOBALS.G_OPR_CREATE;
1643
1644 END IF;
1645
1646 END LOOP;
1647 END IF;
1648
1649 -- Load IN parameters for Line record
1650 IF NOT OE_GLOBALS.Equal(l_line_rec.tax_value, l_old_line_rec.tax_value)
1651 THEN
1652 -- Start Audit Trail --
1653 l_Line_rec.change_reason := 'SYSTEM';
1654 -- End Audit Trail --
1655 l_Line_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
1656 ELSE
1657 l_Line_rec.operation := OE_GLOBALS.G_OPR_NONE;
1658 END IF;
1659
1660 -- Check to see if there are any records needed to be modified.
1661
1662 IF NOT (OE_GLOBALS.Equal(l_line_rec.operation, OE_GLOBALS.G_OPR_NONE) AND
1663 l_line_adj_tbl.COUNT = 0)
1664 THEN
1665
1666 -- Populate Line table
1667 l_Line_tbl(1) := l_Line_rec;
1668 l_Old_Line_tbl(1) := l_Old_Line_rec;
1669
1670 -- Set control flags.
1671 l_control_rec.controlled_operation := FALSE;
1672
1673 oe_debug_pub.add('Before calling Process Order API',2);
1674
1675 -- Set recursion mode.
1676 -- OE_GLOBALS.G_RECURSION_MODE := 'Y';
1677
1678 OE_Order_PVT.Process_order
1679 ( p_api_version_number => 1.0
1680 , p_init_msg_list => FND_API.G_FALSE
1681 , x_return_status => l_return_status
1682 , x_msg_count => l_msg_count
1683 , x_msg_data => l_msg_data
1684 , p_control_rec => l_control_rec
1685 , p_x_header_rec => l_x_header_rec
1686 , p_x_Header_Adj_tbl => l_x_Header_Adj_tbl
1687 , p_x_Header_price_Att_tbl => l_x_Header_price_Att_tbl
1688 , p_x_Header_Adj_Att_tbl => l_x_Header_Adj_Att_tbl
1689 , p_x_Header_Adj_Assoc_tbl => l_x_Header_Adj_Assoc_tbl
1690 , p_x_Header_Scredit_tbl => l_x_Header_Scredit_tbl
1691 --serla begin
1692 , p_x_Header_Payment_tbl => l_x_Header_Payment_tbl
1693 --serla end
1694 , p_x_line_tbl => l_line_tbl
1695 , p_old_Line_tbl => l_old_Line_tbl
1696 , p_x_Line_Adj_tbl => l_Line_Adj_tbl
1697 , p_x_Line_price_Att_tbl => l_x_Line_price_Att_tbl
1698 , p_x_Line_Adj_Att_tbl => l_x_Line_Adj_Att_tbl
1699 , p_x_Line_Adj_Assoc_tbl => l_x_Line_Adj_Assoc_tbl
1700 , p_x_Line_Scredit_tbl => l_x_Line_Scredit_tbl
1701 --serla begin
1702 , p_x_Line_Payment_tbl => l_x_Line_Payment_tbl
1703 --serla end
1704 , p_x_Lot_Serial_tbl => l_x_Lot_Serial_tbl
1705 , p_x_action_request_tbl => l_x_action_request_tbl
1706 );
1707
1708 -- Reset recursion mode.
1709 -- OE_GLOBALS.G_RECURSION_MODE := 'N';
1710
1711 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1712 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1713 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1714 RAISE FND_API.G_EXC_ERROR;
1715 END IF;
1716 oe_debug_pub.add('After calling Process_order API',2);
1717 END IF;
1718 l_tax_rec_out_tbl.delete;
1719 x_return_status := l_return_status;
1720 oe_debug_pub.add('Exiting Tax Line',1);
1721 EXCEPTION
1722 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1723 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1724
1725 WHEN FND_API.G_EXC_ERROR THEN
1726 x_return_status := FND_API.G_RET_STS_ERROR;
1727
1728 WHEN NO_DATA_FOUND THEN
1729 x_return_status := FND_API.G_RET_STS_SUCCESS;
1730
1731 WHEN OTHERS THEN
1732
1733 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1734 THEN
1735 OE_MSG_PUB.Add_Exc_Msg
1736 ( G_PKG_NAME ,
1737 'Tax Line'
1738 );
1739 END IF;
1740 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1741 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1742
1743 END Tax_Line;
1744
1745 */
1746
1747
1748
1749
1750 ------------------------------------------------------------------
1751 -- procedure: SPLIT_HOLD
1752 -- Copy's the hold when a line gets split that has an active hold
1753 -----------------------------------------------------------------
1754 PROCEDURE split_hold (p_entity_code IN VARCHAR2
1755 ,p_entity_id IN NUMBER
1756 ,p_split_from_line_id IN NUMBER
1757 ,x_return_status OUT NOCOPY VARCHAR2
1758
1759 )
1760 IS
1761 l_return_status VARCHAR2(30);
1762 l_msg_count NUMBER;
1763 l_msg_data VARCHAR2(2000);
1764
1765 BEGIN
1766
1767 OE_Debug_PUB.Add('Entering OE_Delayed_Requests_Util.split_Hold',1);
1768 -- call the oe_holds_pub to split the line
1769 OE_Holds_pvt.split_hold (
1770 p_line_id => p_entity_id
1771 , p_split_from_line_id => p_split_from_line_id
1772 , x_return_status => x_return_status
1773 , x_msg_count => l_msg_count
1774 , x_msg_data => l_msg_data
1775 );
1776 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1777 OE_Debug_PUB.Add('Error in OE_Holds_PUB.split_Holds',2);
1778 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1779 RAISE FND_API.G_EXC_ERROR;
1780 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1781 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1782 END IF;
1783 END IF; -- if split hold was successful
1784
1785 OE_Debug_PUB.Add('Exiting OE_Delayed_Requests_Util.split_Hold',2);
1786
1787 EXCEPTION
1788
1789 WHEN FND_API.G_EXC_ERROR THEN
1790
1791 x_return_status := FND_API.G_RET_STS_ERROR;
1792
1793 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1794
1795 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1796
1797 WHEN OTHERS THEN
1798
1799 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1800 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1801 THEN
1802 OE_MSG_PUB.Add_Exc_Msg
1803 ( G_PKG_NAME
1804 , 'Split_Hold'
1805 );
1806 END IF;
1807
1808
1809 END split_hold;
1810
1811 -------------------------------------------------------------------
1812 -- Procedure: EVAL_HOLD_SOURCE
1813 -- Applies or removes holds if a hold source entity is updated
1814 -- on the order or line.
1815 -- Changed(1/3/2000): Moved all the login to the oe_holds_pub.evaluate_holds
1816 -------------------------------------------------------------------
1817
1818 PROCEDURE Eval_Hold_Source(
1819 x_return_status OUT NOCOPY VARCHAR2
1820
1821 , p_entity_code IN VARCHAR2
1822 , p_entity_id IN NUMBER
1823 , p_hold_entity_code IN VARCHAR2
1824 --ER#7479609, p_hold_entity_id IN NUMBER
1825 , p_hold_entity_id IN oe_hold_sources_all.hold_entity_id%TYPE --ER#7479609
1826 )
1827 IS
1828 l_return_status VARCHAR2(30);
1829 l_msg_count NUMBER;
1830 l_msg_data VARCHAR2(2000);
1831
1832 BEGIN
1833
1834 OE_Debug_PUB.Add('Entering Eval_Hold_Source', 1);
1835 Oe_debug_pub.add('Hold entity: '|| p_hold_entity_code ||' '|| p_hold_entity_id,2);
1836 x_return_status := FND_API.G_RET_STS_SUCCESS;
1837
1838 oe_holds_pub.evaluate_holds ( p_entity_code => p_entity_code
1839 ,p_entity_id => p_entity_id
1840 ,p_hold_entity_code => p_hold_entity_code
1841 ,p_hold_entity_id => p_hold_entity_id
1842 ,x_return_status => x_return_status
1843 ,x_msg_count => l_msg_count
1844 ,x_msg_data => l_msg_data
1845 );
1846
1847
1848
1849 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1850 OE_Debug_PUB.Add('Error in OE_Holds_PUB.evaluate_holds',2);
1851 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1852 RAISE FND_API.G_EXC_ERROR;
1853 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1854 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1855 END IF;
1856 END IF;
1857
1858 OE_Debug_PUB.Add('Exiting Eval_Hold_Source', 1);
1859
1860 EXCEPTION
1861 WHEN FND_API.G_EXC_ERROR THEN
1862
1863 x_return_status := FND_API.G_RET_STS_ERROR;
1864
1865 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1866
1867 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1868
1869 WHEN OTHERS THEN
1870
1871 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1872 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1873 THEN
1874 OE_MSG_PUB.Add_Exc_Msg
1875 ( G_PKG_NAME
1876 , 'Eval_Hold_Source'
1877 );
1878 END IF;
1879
1880 END Eval_Hold_Source;
1881
1882 -------------------------------------------------------------------
1883 -- Procedure: APPLY_HOLD
1884 -- Applies holds to an order or line using hold ID, entity code and
1885 -- entity ID
1886 -------------------------------------------------------------------
1887
1888 PROCEDURE Apply_Hold(p_validation_level IN NUMBER
1889 ,x_request_rec IN OUT NOCOPY OE_Order_PUB.Request_Rec_Type
1890 )
1891 IS
1892 l_header_id NUMBER DEFAULT NULL;
1893 l_line_id NUMBER DEFAULT NULL;
1894 l_hold_source_rec OE_Holds_PVT.Hold_Source_REC_type;
1895 l_request_rec OE_Order_PUB.request_rec_type := x_request_rec;
1896 l_return_status VARCHAR2(30);
1897 l_msg_count NUMBER := 0;
1898 l_msg_data VARCHAR2(2000) := NULL;
1899 l_line_rec OE_Order_PUB.Line_Rec_Type;
1900 BEGIN
1901
1902 OE_Debug_PUB.Add('Entering OE_Delayed_Requests_Util.Apply_Hold',1);
1903
1904 IF l_request_rec.entity_code = OE_Globals.G_ENTITY_HEADER THEN
1905 -- Indicates Header Level action
1906 --l_header_id := l_request_rec.entity_id;
1907 l_hold_source_rec.header_id := l_request_rec.entity_id;
1908 OE_Debug_PUB.Add('Header ID: '|| l_hold_source_rec.header_id,1);
1909
1910 ELSIF l_request_rec.entity_code = OE_Globals.G_ENTITY_LINE THEN
1911
1912 OE_debug_pub.add('Line ID: '|| l_request_rec.entity_id,1);
1913 BEGIN
1914 SELECT header_id
1915 INTO l_header_id
1916 FROM oe_order_lines
1917 WHERE line_id = l_request_rec.entity_id;
1918 OE_debug_pub.add('OEXUREQB:Header ID: '|| l_header_id);
1919
1920
1921 EXCEPTION
1922 WHEN OTHERS THEN
1923 OE_debug_pub.add('OEXUREQB:No header ID for this line');
1924 RAISE NO_DATA_FOUND;
1925 END;
1926
1927 l_hold_source_rec.header_id := l_header_id;
1928 l_hold_source_rec.line_id := l_request_rec.entity_id;
1929
1930 END IF;
1931
1932 l_hold_source_rec.hold_entity_code := l_request_rec.param2;
1933 l_hold_source_rec.hold_id := l_request_rec.param1;
1934
1935 -- Since an Order based source and Header is created at the same time, caller
1936 -- is unable to populate param3 with header_id. We can user entity_id
1937
1938 IF ((l_request_rec.entity_code = OE_GLOBALS.G_ENTITY_HEADER) AND
1939 (l_hold_source_rec.hold_entity_code = 'O')) THEN
1940 l_hold_source_rec.hold_entity_id := l_request_rec.entity_id;
1941 ELSIF ((l_request_rec.entity_code = OE_GLOBALS.G_ENTITY_LINE) AND
1942 (l_hold_source_rec.hold_entity_code = 'O')) THEN
1943 l_hold_source_rec.hold_entity_id := l_header_id;
1944 ELSE
1945 l_hold_source_rec.hold_entity_id := l_request_rec.param3;
1946 END IF;
1947
1948 l_hold_source_rec.hold_comment := l_request_rec.param4;
1949
1950 l_hold_source_rec.hold_until_date := l_request_rec.date_param1;
1951
1952 -- Load Desc Flex
1953 l_hold_source_rec.context := l_request_rec.param10;
1954 l_hold_source_rec.attribute1 := l_request_rec.param11;
1955 l_hold_source_rec.attribute2 := l_request_rec.param12;
1956 l_hold_source_rec.attribute3 := l_request_rec.param13;
1957 l_hold_source_rec.attribute4 := l_request_rec.param14;
1958 l_hold_source_rec.attribute5 := l_request_rec.param15;
1959 l_hold_source_rec.attribute6 := l_request_rec.param16;
1960 l_hold_source_rec.attribute7 := l_request_rec.param17;
1961 l_hold_source_rec.attribute8 := l_request_rec.param18;
1962 l_hold_source_rec.attribute9 := l_request_rec.param19;
1963 l_hold_source_rec.attribute10 := l_request_rec.param20;
1964 l_hold_source_rec.attribute11 := l_request_rec.param21;
1965 l_hold_source_rec.attribute12 := l_request_rec.param22;
1966 l_hold_source_rec.attribute13 := l_request_rec.param23;
1967 l_hold_source_rec.attribute14 := l_request_rec.param24;
1968 l_hold_source_rec.attribute15 := l_request_rec.param25;
1969
1970 l_request_rec.return_status := FND_API.G_RET_STS_SUCCESS;
1971
1972 -- Changed the following to new signiture 2/24/2000 - ZB
1973 /*
1974 OE_Holds_PUB.Apply_Holds
1975 ( p_api_version => 1.0
1976 , p_validation_level => p_validation_level
1977 , p_header_id => l_header_id
1978 , p_line_id => l_line_id
1979 , p_hold_source_rec => l_hold_source_rec
1980 , x_return_status => l_return_status
1981 , x_msg_count => l_msg_count
1982 , x_msg_data => l_msg_data
1983 );
1984 */
1985 OE_Holds_PUB.Apply_Holds
1986 ( p_api_version => 1.0
1987 , p_validation_level => FND_API.G_VALID_LEVEL_NONE
1988 , p_hold_source_rec => l_hold_source_rec
1989 , p_check_authorization_flag => 'Y' -- bug 8477694
1990 , x_return_status => l_return_status
1991 , x_msg_count => l_msg_count
1992 , x_msg_data => l_msg_data
1993 );
1994
1995
1996 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1997 OE_Debug_PUB.Add('OEXUREQB:Error in OE_Holds_PUB.Apply_Holds',1);
1998 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1999 RAISE FND_API.G_EXC_ERROR;
2000 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2001 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2002 END IF;
2003 ELSE
2004 OE_Debug_PUB.Add('OEXUREQB:Hold applied',1);
2005 END IF;
2006
2007 x_request_rec := l_request_rec;
2008
2009 OE_Debug_PUB.Add('Exiting OE_Delayed_Requests_Util.Apply_Hold',1);
2010 EXCEPTION
2011
2012 WHEN FND_API.G_EXC_ERROR THEN
2013
2014 l_request_rec.return_status := FND_API.G_RET_STS_ERROR;
2015 x_request_rec := l_request_rec;
2016
2017 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2018
2019 l_request_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2020 x_request_rec := l_request_rec;
2021
2022 WHEN OTHERS THEN
2023
2024 l_request_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2025 x_request_rec := l_request_rec;
2026 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2027 THEN
2028 OE_MSG_PUB.Add_Exc_Msg
2029 ( G_PKG_NAME
2030 , 'Apply_Hold'
2031 );
2032 END IF;
2033
2034
2035 END Apply_Hold;
2036
2037 -------------------------------------------------------------------
2038 -- Procedure: RELEASE_HOLD
2039 -- Releases hold on an order or line that has a hold source that
2040 -- uses this hold ID, entity code and entity ID.
2041 -------------------------------------------------------------------
2042
2043 PROCEDURE Release_Hold(
2044 p_validation_level IN NUMBER
2045 ,x_request_rec IN OUT NOCOPY OE_Order_PUB.Request_Rec_Type
2046 )
2047 IS
2048 l_header_id NUMBER DEFAULT NULL;
2049 l_line_id NUMBER DEFAULT NULL;
2050 l_hold_id NUMBER DEFAULT NULL;
2051 --ER#7479609 l_entity_code VARCHAR2(1) DEFAULT NULL;
2052 --ER#7479609 l_entity_id NUMBER DEFAULT NULL;
2053 l_entity_code oe_hold_sources_all.hold_entity_code%TYPE DEFAULT NULL; --ER#7479609
2054 l_entity_id oe_hold_sources_all.hold_entity_id%TYPE DEFAULT NULL; --ER#7479609
2055 l_request_rec OE_Order_PUB.request_rec_type := x_request_rec;
2056 l_return_status VARCHAR2(30);
2057 l_msg_count NUMBER := 0;
2058 l_msg_data VARCHAR2(2000) := NULL;
2059
2060 l_hold_release_rec OE_HOLDS_PVT.Hold_Release_Rec_Type;
2061 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
2062 BEGIN
2063
2064 OE_Debug_PUB.Add('Entering OE_Delayed_Requests_Util.Release_Hold',1);
2065
2066 IF l_request_rec.entity_code = OE_Globals.G_ENTITY_HEADER THEN
2067 -- Indicates Header Level action
2068
2069 l_header_id := l_request_rec.entity_id;
2070 l_hold_source_rec.header_id := l_header_id; --Bug 5042664
2071 OE_Debug_PUB.Add('Header ID: '|| l_header_id,1);
2072
2073 ELSIF l_request_rec.entity_code = OE_Globals.G_ENTITY_LINE THEN
2074
2075 --l_line_id := l_request_rec.entity_id;
2076 OE_debug_pub.add('Line ID: '|| l_request_rec.entity_id,1);
2077 BEGIN
2078 SELECT header_id
2079 INTO l_header_id
2080 FROM oe_order_lines
2081 WHERE line_id = l_request_rec.entity_id;
2082 OE_debug_pub.add('OEXUREQB:Header ID: '|| l_header_id);
2083
2084
2085 EXCEPTION
2086 WHEN OTHERS THEN
2087 OE_debug_pub.add('OEXUREQB:No header ID for this line');
2088 RAISE NO_DATA_FOUND;
2089 END;
2090
2091 l_hold_source_rec.header_id := l_header_id;
2092 l_hold_source_rec.line_id := l_request_rec.entity_id;
2093
2094 END IF;
2095
2096 l_request_rec.return_status := FND_API.G_RET_STS_SUCCESS;
2097
2098 l_hold_id := l_request_rec.param1;
2099 l_entity_code := l_request_rec.param2;
2100
2101 -- Order Import is unable to send Hold Entity Id/Header Id as Param3
2102 -- Need to modify the code to use header id for hold entity code = 'O'
2103
2104 IF ((l_request_rec.entity_code = OE_GLOBALS.G_ENTITY_HEADER) AND
2105 (l_entity_code = 'O')) THEN
2106 l_entity_id := l_request_rec.entity_id;
2107 ELSIF ((l_request_rec.entity_code = OE_GLOBALS.G_ENTITY_LINE) AND
2108 (l_entity_code = 'O')) THEN
2109 l_entity_id := l_header_id;
2110 ELSE
2111 l_entity_id := l_request_rec.param3;
2112 END IF;
2113
2114 l_hold_release_rec.release_reason_code := l_request_rec.param4;
2115 l_hold_release_rec.release_comment := l_request_rec.param5;
2116
2117 l_hold_source_rec.hold_id := l_hold_id;
2118 l_hold_source_rec.HOLD_ENTITY_CODE := l_entity_code;
2119 l_hold_source_rec.HOLD_ENTITY_ID := l_entity_id;
2120
2121
2122 OE_Debug_PUB.Add('Calling OE_Holds_PUB.Release_Holds',1);
2123 /*
2124 OE_Holds_PUB.Release_Holds
2125 ( p_api_version => 1.0
2126 , p_validation_level => p_validation_level
2127 , p_header_id => l_header_id
2128 , p_line_id => l_line_id
2129 , p_hold_id => l_hold_id
2130 , p_entity_code => l_entity_code
2131 , p_entity_id => l_entity_id
2132 , p_hold_release_rec => l_hold_release_rec
2133 , x_return_status => l_return_status
2134 , x_msg_count => l_msg_count
2135 , x_msg_data => l_msg_data
2136 );
2137 */
2138
2139 oe_holds_pvt.Release_Holds(
2140 p_hold_source_rec => l_hold_source_rec
2141 ,p_hold_release_rec => l_hold_release_rec
2142 ,p_check_authorization_flag => 'Y' -- bug 8477694
2143 ,x_return_status => l_return_status
2144 ,x_msg_count => l_msg_count
2145 ,x_msg_data => l_msg_data
2146 );
2147 OE_DEBUG_PUB.Add('x_return_status:' || l_return_status,1);
2148
2149 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2150 OE_Debug_PUB.Add('Error in OE_Holds_PUB.Release_Holds',2);
2151 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2152 RAISE FND_API.G_EXC_ERROR;
2153 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2154 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2155 END IF;
2156 ELSE
2157 OE_Debug_PUB.Add('Hold released',1);
2158 END IF;
2159
2160 x_request_rec := l_request_rec;
2161 OE_Debug_PUB.Add('Exiting OE_Delayed_Requests_Util.Release_Hold',1);
2162 EXCEPTION
2163
2164 WHEN FND_API.G_EXC_ERROR THEN
2165
2166 l_request_rec.return_status := FND_API.G_RET_STS_ERROR;
2167 x_request_rec := l_request_rec;
2168
2169 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2170
2171 l_request_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2172 x_request_rec := l_request_rec;
2173
2174 WHEN OTHERS THEN
2175
2176 l_request_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2177 x_request_rec := l_request_rec;
2178 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2179 THEN
2180 OE_MSG_PUB.Add_Exc_Msg
2181 ( G_PKG_NAME
2182 , 'Release_Hold'
2183 );
2184 END IF;
2185
2186
2187 END Release_Hold;
2188
2189
2190 PROCEDURE Split_Set
2191 (p_request_rec IN oe_order_pub.request_rec_type,
2192 x_return_status OUT NOCOPY VARCHAR2)
2193
2194 IS
2195 l_return_status VARCHAR2(30);
2196 x_msg_data varchar2(2000);
2197 x_msg_count number;
2198 l_set_name varchar2(80);
2199 Begin
2200 l_set_name := p_request_rec.param1 ;
2201 OE_SET_UTIL.Split_Set
2202 (p_set_id => p_request_rec.entity_id,
2203 p_set_name => l_set_name,
2204 x_return_Status => l_return_status,
2205 x_msg_count => x_msg_count,
2206 x_msg_data => x_msg_data);
2207 x_return_status := l_return_status;
2208 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2209 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2210 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2211 RAISE FND_API.G_EXC_ERROR;
2212 END IF;
2213
2214
2215 EXCEPTION
2216
2217 WHEN FND_API.G_EXC_ERROR THEN
2218
2219 x_return_status := FND_API.G_RET_STS_ERROR;
2220
2221 -- Get message count and data
2222
2223 OE_MSG_PUB.Count_And_Get
2224 ( p_count => x_msg_count
2225 , p_data => x_msg_data
2226 );
2227
2228 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2229
2230 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2231 -- Get message count and data
2232
2233 OE_MSG_PUB.Count_And_Get
2234 ( p_count => x_msg_count
2235 , p_data => x_msg_data
2236 );
2237
2238 WHEN OTHERS THEN
2239
2240 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2241
2242 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2243 THEN
2244 OE_MSG_PUB.Add_Exc_Msg
2245 ( G_PKG_NAME
2246 , 'Split_Set'
2247 );
2248 END IF;
2249
2250 -- Get message count and data
2251
2252 OE_MSG_PUB.Count_And_Get
2253 ( p_count => x_msg_count
2254 , p_data => x_msg_data
2255 );
2256
2257 End Split_set;
2258
2259 PROCEDURE Insert_Set
2260 (p_request_rec IN oe_order_pub.request_rec_type,
2261 x_return_status OUT NOCOPY VARCHAR2)
2262
2263 IS
2264 l_return_status VARCHAR2(30);
2265 x_msg_data varchar2(2000);
2266 x_msg_count number;
2267 p_set_request oe_order_pub.request_tbl_type;
2268 Begin
2269 p_set_request(1) := p_request_rec;
2270 OE_SET_UTIL.Insert_Into_Set
2271 (p_set_request_tbl => p_set_request,
2272 p_Push_Set_Date => 'N',
2273 X_Return_Status => l_return_status,
2274 x_msg_count => x_msg_count,
2275 x_msg_data => x_msg_data);
2276 x_return_status := l_return_status;
2277 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2278 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2279 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2280 RAISE FND_API.G_EXC_ERROR;
2281 END IF;
2282
2283
2284 EXCEPTION
2285
2286 WHEN FND_API.G_EXC_ERROR THEN
2287
2288 x_return_status := FND_API.G_RET_STS_ERROR;
2289
2290 -- Get message count and data
2291
2292 OE_MSG_PUB.Count_And_Get
2293 ( p_count => x_msg_count
2294 , p_data => x_msg_data
2295 );
2296
2297 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2298
2299 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2300 -- Get message count and data
2301
2302 OE_MSG_PUB.Count_And_Get
2303 ( p_count => x_msg_count
2304 , p_data => x_msg_data
2305 );
2306
2307 WHEN OTHERS THEN
2308
2309 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2310
2311 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2312 THEN
2313 OE_MSG_PUB.Add_Exc_Msg
2314 ( G_PKG_NAME
2315 , 'Insert_Set'
2316 );
2317 END IF;
2318 -- Get message count and data
2319
2320 OE_MSG_PUB.Count_And_Get
2321 ( p_count => x_msg_count
2322 , p_data => x_msg_data
2323 );
2324
2325 NULL;
2326
2327 End Insert_Set;
2328
2329
2330 PROCEDURE Book_Order
2331 ( p_validation_level IN NUMBER
2332 , p_header_id IN NUMBER
2333 , x_return_status OUT NOCOPY VARCHAR2
2334
2335 )
2336 IS
2337 l_msg_count NUMBER;
2338 l_msg_data VARCHAR2(2000);
2339 BEGIN
2340
2341 x_return_status := FND_API.G_RET_STS_SUCCESS;
2342
2343 OE_Order_Book_Util.Complete_Book_Eligible
2344 ( p_api_version_number => 1.0
2345 , p_header_id => p_header_id
2346 , x_return_status => x_return_status
2347 , x_msg_count => l_msg_count
2348 , x_msg_data => l_msg_data);
2349
2350 EXCEPTION
2351 WHEN OTHERS THEN
2352 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2353 IF OE_MSG_PUB.Check_Msg_Level
2354 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2355 THEN
2356 OE_MSG_PUB.Add_Exc_Msg
2357 ( G_PKG_NAME
2358 , 'Book_Order'
2359 );
2360 END IF;
2361 END Book_Order;
2362
2363 PROCEDURE Get_Ship_Method
2364 ( p_entity_code IN VARCHAR2
2365 , p_entity_id IN NUMBER
2366 , p_action_code IN VARCHAR2
2367 , x_return_status OUT NOCOPY VARCHAR2
2368
2369 )
2370 IS
2371 l_msg_count NUMBER;
2372 l_msg_data VARCHAR2(2000);
2373 l_header_id NUMBER;
2374 l_action VARCHAR2(1);
2375
2376 BEGIN
2377
2378 x_return_status := FND_API.G_RET_STS_SUCCESS;
2379
2380 IF p_entity_code = OE_Globals.G_ENTITY_HEADER THEN
2381
2382 l_header_id := p_entity_id;
2383
2384 ELSIF p_entity_code = OE_Globals.G_ENTITY_LINE THEN
2385
2386 BEGIN
2387 SELECT header_id
2388 INTO l_header_id
2389 FROM oe_order_lines_all
2390 WHERE line_id = p_entity_id;
2391 EXCEPTION
2392 WHEN OTHERS THEN
2393 RAISE;
2394 END;
2395
2396 END IF;
2397
2398 IF OE_SYS_PARAMETERS.Value('FTE_INTEGRATION') = 'Y'
2399 AND p_action_code = OE_GLOBALS.G_GET_SHIP_METHOD_AND_RATES THEN
2400 l_action := 'B';
2401 ELSIF (OE_SYS_PARAMETERS.Value('FTE_INTEGRATION') = 'S'
2402 OR OE_SYS_PARAMETERS.Value('FTE_INTEGRATION') = 'Y')
2403 AND p_action_code = OE_GLOBALS.G_GET_SHIP_METHOD THEN
2404 l_action := 'C';
2405 ELSIF (OE_SYS_PARAMETERS.Value('FTE_INTEGRATION') = 'F'
2406 OR OE_SYS_PARAMETERS.Value('FTE_INTEGRATION') = 'Y')
2407 AND p_action_code = OE_GLOBALS.G_GET_FREIGHT_RATES THEN
2408 l_action := 'R';
2409 END IF;
2410
2411 IF l_action IN ('B', 'C', 'R') THEN
2412
2413 oe_debug_pub.add('calling Process_FTE_Action for Order Import.', 3);
2414
2415 -- set p_ui_flag to Y since this is called from Action
2416 -- through Order Import.
2417 OE_FTE_INTEGRATION_PVT.Process_FTE_Action
2418 ( p_header_id => l_header_id
2419 ,p_line_id => null
2420 ,p_ui_flag => 'Y'
2421 ,p_action => l_action
2422 ,p_call_pricing_for_FR => 'Y'
2423 ,x_return_status => x_return_status
2424 ,x_msg_count => l_msg_count
2425 ,x_msg_data => l_msg_data);
2426 ELSE
2427 fnd_message.set_name('ONT','OE_FTE_NOT_ENABLED');
2428 OE_MSG_PUB.Add;
2429 oe_debug_pub.add('Unable to process FTE integration either due to
2430 FTE is not enabled or action code is invalid.', 3);
2431 x_return_status := FND_API.G_RET_STS_ERROR;
2432 END IF;
2433
2434 OE_DEBUG_PUB.Add('Return Status fte action: '||x_return_status);
2435
2436 EXCEPTION
2437 WHEN OTHERS THEN
2438 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2439 IF OE_MSG_PUB.Check_Msg_Level
2440 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2441 THEN
2442 OE_MSG_PUB.Add_Exc_Msg
2443 ( G_PKG_NAME
2444 , 'Get_Ship_Method'
2445 );
2446 END IF;
2447 END Get_Ship_Method;
2448
2449 PROCEDURE Fulfillment_Sets
2450 ( p_entity_code IN VARCHAR2
2451 , p_entity_id IN VARCHAR2
2452 , p_action_code IN VARCHAR2
2453 , p_fulfillment_set_name IN VARCHAR2
2454 , x_return_status OUT NOCOPY VARCHAR2
2455 )
2456 IS
2457 l_msg_count NUMBER;
2458 l_msg_data VARCHAR2(2000);
2459 l_header_id NUMBER;
2460 l_set_id NUMBER;
2461 l_action VARCHAR2(10);
2462 --R12.MOAC
2463 l_selelect_line_tbl OE_GLOBALS.Selected_Record_Tbl;
2464 BEGIN
2465
2466 x_return_status := FND_API.G_RET_STS_SUCCESS;
2467
2468
2469 BEGIN
2470 SELECT header_id
2471 INTO l_header_id
2472 FROM oe_order_lines_all
2473 WHERE line_id = p_entity_id;
2474 EXCEPTION
2475 WHEN OTHERS THEN
2476 RAISE;
2477 END;
2478
2479 IF p_action_code = OE_GLOBALS.G_ADD_FULFILLMENT_SET THEN
2480 l_action := 'ADD';
2481 ELSIF p_action_code = OE_GLOBALS.G_REMOVE_FULFILLMENT_SET THEN
2482 l_action := 'REMOVE';
2483 END IF;
2484
2485 l_selelect_line_tbl(1).id1 := p_entity_id; --R12.MOAC
2486 OE_DEBUG_PUB.Add(' Before Calling Process Sets',1);
2487
2488 --R12.MOAC
2489 OE_SET_UTIL.Process_Sets
2490 ( p_selected_line_tbl => l_selelect_line_tbl,
2491 p_record_count => 1,
2492 p_set_name => p_fulfillment_set_name,
2493 p_set_type => 'FULFILLMENT',
2494 p_operation => l_action,
2495 p_header_id => l_header_id,
2496 x_Set_Id => l_set_id,
2497 x_return_status => x_return_status,
2498 x_msg_count => l_msg_count ,
2499 x_msg_data => l_msg_data);
2500
2501
2502 OE_DEBUG_PUB.Add('After Calling Process Sets'||x_return_status,1);
2503
2504
2505 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2506 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2507 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
2508 RAISE FND_API.G_EXC_ERROR;
2509 END IF;
2510
2511 EXCEPTION
2512 WHEN OTHERS THEN
2513 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2514 IF OE_MSG_PUB.Check_Msg_Level
2515 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2516 THEN
2517 OE_MSG_PUB.Add_Exc_Msg
2518 ( G_PKG_NAME
2519 ,'Fulfillment_Sets'
2520 );
2521 END IF;
2522
2523 END Fulfillment_Sets;
2524
2525 --sol_ord_er #16014165 start
2526 PROCEDURE First_period_bill_amt (p_header_id IN NUMBER DEFAULT NULL,
2527 p_line_id IN NUMBER DEFAULT NULL,
2528 x_return_status OUT nocopy VARCHAR2)
2529 IS
2530 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2531 l_line_rec OE_ORDER_PUB.line_rec_type;
2532 l_old_line_tbl OE_ORDER_PUB.line_tbl_type;
2533 l_line_tbl OE_ORDER_PUB.line_tbl_type;
2534 l_item_type VARCHAR2(50) :='';
2535 l_curr_code varchar2(20) := '';
2536 l_sub_template NUMBER;
2537 l_first_period_amt NUMBER;
2538 l_first_period_enddate DATE;
2539 l_return_status VARCHAR2(30) := FND_API.G_RET_STS_SUCCESS;
2540 l_global_index NUMBER;
2541 CURSOR l_servbill_lin (
2542 p_header_id IN NUMBER) IS
2543 SELECT line_id
2544 FROM oe_order_lines_all
2545 WHERE header_id = p_header_id
2546 AND service_bill_option_code = 'FPOM'
2547 AND service_bill_profile_id IS NOT NULL
2548 AND service_start_date is NOT NULL --16621149
2549 AND service_end_date is NOT NULL --16621149
2550 AND NVL(FULFILLED_FLAG,'N') = 'N';
2551 BEGIN
2552 x_return_status := fnd_api.g_ret_sts_success;
2553
2554 IF l_debug_level > 0 THEN
2555 oe_debug_pub.ADD('Entering UTIL.CALCULATE_FIRST_PERIOD_BILL_AMT p_header_id= '
2556 ||p_header_id
2557 ||' p_line_id= '
2558 ||p_line_id, 1);
2559 END IF;
2560 IF ( p_header_id IS NOT NULL
2561 AND p_line_id IS NOT NULL ) THEN
2562 x_return_status := fnd_api.g_ret_sts_unexp_error;
2563 IF l_debug_level > 0 THEN
2564 oe_debug_pub.ADD(' Both Header ID and Line ID cannot be passed ');
2565 END IF;
2566 ELSIF p_line_id IS NOT NULL THEN
2567 l_line_rec := OE_line_UTIL.Query_Row(p_line_id=> p_line_id);
2568 -- OE_Order_Cache.Load_Order_Header(l_line_rec.header_id);
2569 l_curr_code := OE_Order_Cache.g_header_rec.transactional_curr_code;
2570 If NVL(l_line_rec.subscription_enable_flag,'N') = 'Y' then
2571 l_item_type := 'SUBSCRIPTION';
2572 l_sub_template := l_line_rec.service_subs_template_id;
2573 elsif l_line_rec.item_type_code = 'SERVICE' then
2574 l_item_type := 'SERVICE';
2575 l_sub_template := '';
2576 end if;
2577 IF l_debug_level > 0 THEN
2578 oe_debug_pub.ADD('usp= '||l_line_rec.unit_selling_price
2579 ||' ord_qty= '||l_line_rec.ordered_quantity
2580 ||' sub_enableflag= '||l_line_rec.subscription_enable_flag
2581 ||' bill_code= '||l_line_rec.service_bill_option_code);
2582 oe_debug_pub.ADD( ' StartDate= '||l_line_rec.service_start_date
2583 ||' EndDate= '||l_line_rec.service_end_date
2584 ||' Org ID= '||l_line_rec.org_id
2585 ||' Item Type= '||l_item_type
2586 ||' Curr Code= '||l_curr_code);
2587 oe_debug_pub.ADD( ' Bill Profile= '||l_line_rec.service_bill_profile_id
2588 ||' Subs Template= '||l_sub_template);
2589 END IF;
2590 If l_line_rec.service_bill_option_code = 'FPOM'
2591 AND NVL(l_line_rec.service_bill_profile_id,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM THEN
2592 --16621149 start
2593 IF NVL(l_line_rec.service_start_date,FND_API.G_MISS_DATE)<>FND_API.G_MISS_DATE
2594 AND NVL(l_line_rec.service_end_date,FND_API.G_MISS_DATE)<>FND_API.G_MISS_DATE THEN
2595 --16621149 end
2596 -- Call OKS API to get First Period Bill Amount
2597 OKS_BILL_SCH.Get_Billed_Amount(
2598 p_start_date => l_line_rec.service_start_date
2599 ,p_end_date => l_line_rec.service_end_date
2600 ,p_total_amount => (l_line_rec.unit_selling_price*l_line_rec.ordered_quantity)
2601 ,p_item_type => l_item_type
2602 ,p_org_id => l_line_rec.org_id
2603 ,p_billingprofile_Id => l_line_rec.service_bill_profile_id
2604 ,p_currency_code => l_curr_code
2605 ,p_substemplate_id => l_sub_template
2606 ,x_bill_amount => l_first_period_amt
2607 ,x_bill_enddate => l_first_period_enddate
2608 ) ;
2609 IF l_debug_level > 0 THEN
2610 oe_debug_pub.ADD( ' (1) After OKS Get Billed Amount, first_period_amt= '||l_first_period_amt
2611 ||' first_period_enddate= '||l_first_period_enddate);
2612 End If;
2613 --16621149 start
2614 Else
2615 l_first_period_amt := '';
2616 l_first_period_enddate := '';
2617 IF l_debug_level > 0 THEN
2618 oe_debug_pub.ADD( ' Start Date,End Date are NULL, so Update FirstPeriod Amt and EndDate to NULL');
2619 End If;
2620 End If;
2621 --16621149 end
2622 UPDATE oe_order_lines_all
2623 SET service_first_period_amount = l_first_period_amt,
2624 service_first_period_enddate = l_first_period_enddate
2625 WHERE line_id = p_line_id;
2626 l_old_line_tbl(1) := l_line_rec;
2627 l_line_tbl(1) := l_line_rec;
2628 l_line_tbl(1).service_first_period_amount := l_first_period_amt;
2629 l_line_tbl(1).service_first_period_enddate := l_first_period_enddate;
2630 IF (Oe_Code_Control.Code_Release_Level >= '110508') THEN
2631 Oe_Order_Util.Update_Global_Picture ( p_Upd_New_Rec_If_Exists => FALSE,
2632 p_header_id => l_line_rec.header_id,
2633 p_old_line_rec => l_old_line_tbl(1),
2634 p_line_rec => l_line_tbl(1),
2635 p_line_id => l_line_rec.line_id,
2636 x_index => l_global_index,
2637 x_return_status => l_return_status );
2638 IF l_debug_level > 0 THEN
2639 oe_debug_pub.add('S.F.P.A: after update global picture, status: ' || l_return_status, 1 ) ;
2640 oe_debug_pub.add('S.F.P.A: global picture index: ' || l_global_index , 1 ) ;
2641 END IF;
2642 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2643 RAISE Fnd_Api.G_EXC_ERROR;
2644 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2645 RAISE Fnd_Api.G_EXC_UNEXPECTED_ERROR;
2646 END IF;
2647 IF l_global_index IS NOT NULL THEN
2648 Oe_Order_Util.g_line_tbl(l_global_index).service_first_period_amount := l_line_tbl(1).service_first_period_amount;
2649 Oe_Order_Util.g_line_tbl(l_global_index).service_first_period_enddate := l_line_tbl(1).service_first_period_enddate;
2650 END IF; -- on l_index being non-null
2651 END IF; -- on code release level
2652 End IF; -- end if for bill option FPOM
2653 ELSIF p_header_id IS NOT NULL THEN
2654 FOR l_rec IN l_servbill_lin(p_header_id) LOOP
2655 l_line_rec := OE_line_UTIL.Query_Row(p_line_id=> l_rec.line_id);
2656 -- OE_Order_Cache.Load_Order_Header(l_line_rec.header_id);
2657 l_curr_code := OE_Order_Cache.g_header_rec.transactional_curr_code;
2658 If NVL(l_line_rec.subscription_enable_flag,'N') = 'Y' then
2659 l_item_type := 'SUBSCRIPTION';
2660 l_sub_template := l_line_rec.service_subs_template_id;
2661 elsif l_line_rec.item_type_code = 'SERVICE' then
2662 l_item_type := 'SERVICE';
2663 l_sub_template := '';
2664 end if;
2665 IF l_debug_level > 0 THEN
2666 oe_debug_pub.ADD('usp= '||l_line_rec.unit_selling_price
2667 ||' ord_qty= '||l_line_rec.ordered_quantity
2668 ||' sub_enableflag= '||l_line_rec.subscription_enable_flag
2669 ||' bill_code= '||l_line_rec.service_bill_option_code);
2670 oe_debug_pub.ADD( ' StartDate= '||l_line_rec.service_start_date
2671 ||' EndDate= '||l_line_rec.service_end_date
2672 ||' Org ID= '||l_line_rec.org_id
2673 ||' Item Type= '||l_item_type
2674 ||' Curr Code= '||l_curr_code
2675 ||' Line ID='||l_rec.line_id);
2676 oe_debug_pub.ADD( ' Bill Profile= '||l_line_rec.service_bill_profile_id
2677 ||' Subs Template= '||l_sub_template);
2678 END IF;
2679 -- Call OKS API to get First Period Bill Amount
2680 OKS_BILL_SCH.Get_Billed_Amount(
2681 p_start_date => l_line_rec.service_start_date
2682 ,p_end_date => l_line_rec.service_end_date
2683 ,p_total_amount => (l_line_rec.unit_selling_price*l_line_rec.ordered_quantity)
2684 ,p_item_type => l_item_type
2685 ,p_org_id => l_line_rec.org_id
2686 ,p_billingprofile_Id => l_line_rec.service_bill_profile_id
2687 ,p_currency_code => l_curr_code
2688 ,p_substemplate_id => l_sub_template
2689 ,x_bill_amount => l_first_period_amt
2690 ,x_bill_enddate => l_first_period_enddate
2691 ) ;
2692 IF l_debug_level > 0 THEN
2693 oe_debug_pub.ADD( ' (2) After OKS Get Billed Amount, first_period_amt= '||l_first_period_amt
2694 ||' first_period_enddate= '||l_first_period_enddate);
2695 End If;
2696 -- Update the current line being processed
2697 UPDATE oe_order_lines_all
2698 SET service_first_period_amount = l_first_period_amt,
2699 service_first_period_enddate = l_first_period_enddate
2700 WHERE line_id = l_rec.line_id;
2701 l_old_line_tbl(1) := l_line_rec;
2702 l_line_tbl(1) := l_line_rec;
2703 l_line_tbl(1).service_first_period_amount := l_first_period_amt;
2704 l_line_tbl(1).service_first_period_enddate := l_first_period_enddate;
2705 IF (Oe_Code_Control.Code_Release_Level >= '110508') THEN
2706 Oe_Order_Util.Update_Global_Picture ( p_Upd_New_Rec_If_Exists => FALSE,
2707 p_header_id => l_line_rec.header_id,
2708 p_old_line_rec => l_old_line_tbl(1),
2709 p_line_rec => l_line_tbl(1),
2710 p_line_id => l_line_rec.line_id,
2711 x_index => l_global_index,
2712 x_return_status => l_return_status );
2713 IF l_debug_level > 0 THEN
2714 oe_debug_pub.add('S.F.P.A: after update global picture, status: ' || l_return_status, 1 ) ;
2715 oe_debug_pub.add('S.F.P.A: global picture index: ' || l_global_index , 1 ) ;
2716 END IF;
2717 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2718 RAISE Fnd_Api.G_EXC_ERROR;
2719 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2720 RAISE Fnd_Api.G_EXC_UNEXPECTED_ERROR;
2721 END IF;
2722 IF l_global_index IS NOT NULL THEN
2723 Oe_Order_Util.g_line_tbl(l_global_index).service_first_period_amount := l_line_tbl(1).service_first_period_amount;
2724 Oe_Order_Util.g_line_tbl(l_global_index).service_first_period_enddate := l_line_tbl(1).service_first_period_enddate;
2725 END IF; -- on l_index being non-null
2726 END IF; -- on code release level
2727 END LOOP;
2728 END IF;
2729 oe_debug_pub.ADD('Exiting UTIL.CALCULATE_FIRST_PERIOD_BILL_AMT', 1);
2730 EXCEPTION
2731 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2732 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2733 WHEN FND_API.G_EXC_ERROR THEN
2734 x_return_status := FND_API.G_RET_STS_ERROR;
2735 WHEN OTHERS THEN
2736 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
2737 OE_MSG_PUB.Add_Exc_Msg ( G_PKG_NAME , 'FIRST_PERIOD_BILL_AMT' );
2738 END IF;
2739 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2740 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2741 END first_period_bill_amt;
2742 --sol_ord_er #16014165 end
2743
2744 /*----------------------------------------------------------------------
2745 PROCEDURE Update_shipping
2746 -----------------------------------------------------------------------*/
2747 PROCEDURE Update_shipping
2748 ( p_update_shipping_tbl IN OE_ORDER_PUB.request_tbl_type
2749 , p_line_id IN NUMBER
2750 , p_operation IN VARCHAR2
2751 , x_return_status OUT NOCOPY VARCHAR2)
2752
2753 IS
2754 l_update_shipping_index NUMBER := 0;
2755 l_update_lines_tbl OE_ORDER_PUB.request_tbl_type;
2756 l_update_lines_index NUMBER := 0;
2757 BEGIN
2758
2759 oe_debug_pub.add('Entering UTIL.Update_Shipping'||p_line_id, 1);
2760 -- bug 4741573
2761 OE_MSG_PUB.set_msg_context ( p_entity_code => 'LINE'
2762 ,p_entity_id => p_line_id
2763 ,p_line_id => p_line_id );
2764
2765 l_update_shipping_index := p_update_shipping_tbl.FIRST;
2766
2767 WHILE l_update_shipping_index IS NOT NULL
2768 LOOP
2769
2770 IF p_update_shipping_tbl(l_update_shipping_index).request_type
2771 = OE_GLOBALS.G_UPDATE_SHIPPING
2772 THEN
2773
2774 l_update_lines_index := l_update_lines_index + 1;
2775 l_update_lines_tbl(l_update_lines_index)
2776 := p_update_shipping_tbl(l_update_shipping_index);
2777
2778 END IF;
2779
2780 l_update_shipping_index := p_update_shipping_tbl.NEXT(l_update_shipping_index);
2781
2782 END LOOP;
2783
2784 OE_Shipping_Integration_PVT.Update_Shipping_From_OE
2785 ( p_update_lines_tbl => l_update_lines_tbl,
2786 x_return_status => x_return_status);
2787
2788
2789 IF x_return_status = FND_API.G_RET_STS_SUCCESS THEN
2790
2791 l_update_shipping_index := p_update_shipping_tbl.FIRST;
2792 WHILE l_update_shipping_index IS NOT NULL
2793 LOOP
2794
2795 IF p_update_shipping_tbl(l_update_shipping_index).request_type
2796 = OE_GLOBALS.G_UPDATE_SHIPPING
2797 THEN
2798
2799 IF NOT(p_line_id = p_update_shipping_tbl(l_update_shipping_index).entity_id AND
2800 p_operation
2801 = p_update_shipping_tbl(l_update_shipping_index).request_unique_key1)
2802 THEN
2803
2804 oe_debug_pub.add
2805 ('deleting req '|| p_update_shipping_tbl(l_update_shipping_index).entity_id);
2806
2807 OE_Delayed_Requests_PVT.Delete_Request
2808 (p_entity_code => p_update_shipping_tbl(l_update_shipping_index).entity_code
2809 ,p_entity_id => p_update_shipping_tbl(l_update_shipping_index).entity_id
2810 ,p_request_Type => p_update_shipping_tbl(l_update_shipping_index).request_type
2811 ,p_request_unique_key1
2812 => p_update_shipping_tbl(l_update_shipping_index).request_unique_key1
2813 ,x_return_status => x_return_status);
2814
2815 END IF;
2816
2817 END IF;
2818
2819 l_update_shipping_index := p_update_shipping_tbl.NEXT(l_update_shipping_index);
2820
2821 END LOOP;
2822 END IF;
2823
2824 -- bug 4741573
2825 OE_MSG_PUB.reset_msg_context('LINE');
2826
2827 OE_Debug_PUB.Add('Exiting OE_Delayed_Requests_Util.Update_Shipping',1);
2828 EXCEPTION
2829 WHEN OTHERS THEN
2830 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2831
2832 IF OE_MSG_PUB.Check_Msg_Level
2833 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2834 THEN
2835 OE_MSG_PUB.Add_Exc_Msg
2836 ( G_PKG_NAME
2837 , 'Update_Shipping'
2838 );
2839 END IF;
2840
2841 END Update_Shipping;
2842
2843
2844 PROCEDURE Ship_Confirmation
2845 (
2846 p_ship_confirmation_tbl IN OE_ORDER_PUB.request_tbl_type
2847 , p_line_id IN NUMBER
2848 , p_process_type IN VARCHAR2
2849 , p_process_id IN VARCHAR2
2850 , x_return_status OUT NOCOPY VARCHAR2
2851
2852 )
2853 IS
2854 l_process_id NUMBER;
2855 l_shipping_index NUMBER :=0 ;
2856 BEGIN
2857
2858 OE_Debug_PUB.Add('Entering OE_Delayed_Requests_Util.Ship_Confirmation'||p_process_type||p_process_id,1);
2859
2860 l_process_id := to_number(p_process_id);
2861 l_shipping_index := p_ship_confirmation_tbl.First;
2862 oe_debug_pub.add('P_line_id :'||to_char(p_line_id),2);
2863
2864 WHILE l_shipping_index IS NOT NULL LOOP
2865
2866 oe_debug_pub.add('Request Type : '||p_ship_confirmation_tbl(l_shipping_index).request_type,2);
2867 oe_debug_pub.add('Param1 : '||p_ship_confirmation_tbl(l_shipping_index).param1,2);
2868 IF p_ship_confirmation_tbl(l_shipping_index).request_type
2869 = OE_GLOBALS.G_SHIP_CONFIRMATION AND
2870 p_ship_confirmation_tbl(l_shipping_index).param1 = p_process_id THEN
2871 oe_debug_pub.add('RUnique 1 : '||p_ship_confirmation_tbl(l_shipping_index).request_unique_key1,2);
2872 oe_debug_pub.add('Entity Id : '||to_char(p_ship_confirmation_tbl(l_shipping_index).entity_id),2);
2873 IF p_line_id <> p_ship_confirmation_tbl(l_shipping_index).entity_id THEN
2874
2875 OE_Delayed_Requests_PVT.Delete_Request
2876 (p_entity_code => p_ship_confirmation_tbl(l_shipping_index).entity_code
2877 ,p_entity_id => p_ship_confirmation_tbl(l_shipping_index).entity_id
2878 ,p_request_Type => p_ship_confirmation_tbl(l_shipping_index).request_type
2879 ,p_request_unique_key1 => p_ship_confirmation_tbl(l_shipping_index).request_unique_key1
2880 ,x_return_status => x_return_status);
2881
2882 END IF;
2883 END IF;
2884
2885 l_shipping_index := p_ship_confirmation_tbl.NEXT(l_shipping_index);
2886
2887 END LOOP;
2888
2889 OE_Shipping_Integration_PVT.Process_Ship_Confirm
2890 (
2891 p_process_id => l_process_id,
2892 p_process_type => p_process_type,
2893 x_return_status => x_return_status
2894 );
2895 OE_Debug_PUB.Add('Exiting OE_Delayed_Requests_Util.Ship_Confirmation',1);
2896
2897 EXCEPTION
2898 WHEN OTHERS THEN
2899 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2900 IF OE_MSG_PUB.Check_Msg_Level
2901 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2902 THEN
2903 OE_MSG_PUB.Add_Exc_Msg
2904 ( G_PKG_NAME
2905 , 'Ship_Confirmation'
2906 );
2907 END IF;
2908 END Ship_Confirmation;
2909
2910
2911 Procedure SPLIT_RESERVATIONS
2912 ( p_reserved_line_id IN NUMBER
2913 , p_ordered_quantity IN NUMBER
2914 , p_reserved_quantity IN NUMBER
2915 , x_return_status OUT NOCOPY VARCHAR2)
2916
2917 IS
2918 l_return_status VARCHAR2(1);
2919 BEGIN
2920
2921 oe_debug_pub.add('Entering SPLIT_RESERVATIONS',1);
2922
2923 oe_debug_pub.add('Calling OE_ORDER_SCH_UTIL.SPLIT_RESERVATIONS',1);
2924
2925 OE_ORDER_SCH_UTIL.SPLIT_RESERVATIONS
2926 (p_reserved_line_id => p_reserved_line_id,
2927 p_ordered_quantity => p_ordered_quantity,
2928 p_reserved_quantity => p_reserved_quantity,
2929 x_return_status => l_return_status);
2930
2931 oe_debug_pub.add('After Calling OE_ORDER_SCH_UTIL.SPLIT_RESERVATIONS: '
2932 || l_return_status ,1);
2933
2934 x_return_status := l_return_status;
2935
2936 END SPLIT_RESERVATIONS;
2937
2938
2939 /*-------------------------------------------------------
2940 Not used at all.
2941 --------------------------------------------------------*/
2942 Procedure COMPLETE_CONFIGURATION
2943 ( p_top_model_line_id IN NUMBER
2944 , x_return_status OUT NOCOPY VARCHAR2)
2945
2946 IS
2947 l_return_status VARCHAR2(1);
2948 l_valid_config VARCHAR2(10);
2949 l_complete_config VARCHAR2(10);
2950 BEGIN
2951
2952 oe_config_util.Validate_Configuration
2953 (p_model_line_id => p_top_model_line_id,
2954 p_validate_flag => 'Y',
2955 p_complete_flag => 'Y',
2956 x_valid_config => l_valid_config,
2957 x_complete_config => l_complete_config,
2958 x_return_status => l_return_status);
2959
2960 END COMPLETE_CONFIGURATION;
2961
2962
2963 /*---------------------------------------------------
2964 The call to oe_config_util does all the work.
2965 ----------------------------------------------------*/
2966 Procedure VALIDATE_CONFIGURATION
2967 ( p_top_model_line_id IN NUMBER
2968 , p_deleted_options_tbl IN OE_Order_PUB.request_tbl_type
2969 , p_updated_options_tbl IN OE_Order_PUB.request_tbl_type
2970 , x_return_status OUT NOCOPY VARCHAR2
2971
2972 )
2973 IS
2974 l_return_status VARCHAR2(1);
2975 l_complete_flag VARCHAR2(1):= 'N';
2976 l_valid_config VARCHAR2(10);
2977 l_complete_config VARCHAR2(10);
2978
2979 BEGIN
2980 -- any option added to a booked order,
2981 -- validate_configuration should check
2982 -- for valid as well as complete .
2983
2984 select booked_flag
2985 into l_complete_flag
2986 from oe_order_lines
2987 where line_id = p_top_model_line_id;
2988
2989 l_complete_flag := nvl(l_complete_flag, 'N');
2990 oe_debug_pub.add('option added to a booked order? : '||l_complete_flag , 2);
2991
2992 oe_config_util.Validate_Configuration
2993 (p_model_line_id => p_top_model_line_id,
2994 p_deleted_options_tbl => p_deleted_options_tbl,
2995 p_updated_options_tbl => p_updated_options_tbl,
2996 p_validate_flag => 'Y',
2997 p_complete_flag => l_complete_flag,
2998 x_valid_config => l_valid_config,
2999 x_complete_config => l_complete_config,
3000 x_return_status => l_return_status);
3001
3002 x_return_status := l_return_status;
3003
3004 oe_debug_pub.add('leaving ureqb, validate config: '|| l_return_status, 1);
3005
3006 EXCEPTION
3007 when no_data_found then
3008 oe_debug_pub.add
3009 ('no_data_found in OE_Delayed_Req_Util.VALIDATE_CONFIGURATION', 1);
3010 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3011 when others then
3012 oe_debug_pub.add
3013 ('Exception in OE_Delayed_Req_Util.VALIDATE_CONFIGURATION', 1);
3014 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3015 END VALIDATE_CONFIGURATION;
3016
3017 Procedure Match_And_Reserve
3018 ( p_line_id IN NUMBER
3019 , x_return_status OUT NOCOPY VARCHAR2)
3020
3021 IS
3022 BEGIN
3023 oe_config_util.match_and_reserve
3024 (p_line_id => p_line_id,
3025 x_return_status => x_return_status);
3026 END;
3027
3028
3029 Procedure Group_Schedule
3030 ( p_request_rec IN oe_order_pub.request_rec_type
3031 , x_return_status OUT NOCOPY VARCHAR2)
3032
3033 IS
3034 l_group_req_rec OE_GRP_SCH_UTIL.Sch_Group_Rec_Type;
3035 l_atp_tbl OE_ATP.ATP_Tbl_Type;
3036 l_line_rec OE_ORDER_PUB.line_rec_type;
3037 l_return_status VARCHAR2(1);
3038 BEGIN
3039
3040 oe_debug_pub.add('Entering OE_Delayed_Requests_UTIL.Group_Schedule',1);
3041
3042 oe_debug_pub.add('Entity is :' || p_request_rec.param3,2);
3043 oe_debug_pub.add('Action is :' || p_request_rec.param4,2);
3044
3045 l_group_req_rec.entity_type := p_request_rec.param3;
3046 l_group_req_rec.action := p_request_rec.param4;
3047 l_group_req_rec.line_id := p_request_rec.entity_id;
3048 l_group_req_rec.header_id := p_request_rec.param2;
3049 l_group_req_rec.old_schedule_ship_date := p_request_rec.date_param1;
3050 l_group_req_rec.old_schedule_arrival_date := p_request_rec.date_param2;
3051 l_group_req_rec.old_request_date := p_request_rec.date_param3;
3052 l_group_req_rec.old_ship_from_org_id := p_request_rec.param7;
3053 l_group_req_rec.old_ship_set_number := p_request_rec.param9;
3054 l_group_req_rec.old_arrival_set_number := p_request_rec.param10;
3055
3056 OE_LINE_UTIL.Query_Row(p_line_id => p_request_rec.entity_id
3057 ,x_line_rec => l_line_rec);
3058
3059 IF NVL(p_request_rec.param11,'N') = 'Y' THEN
3060
3061 oe_debug_pub.add('param 11' || p_request_rec.param11,1);
3062 l_group_req_rec.old_schedule_ship_date := l_line_rec.schedule_ship_date;
3063 l_group_req_rec.old_schedule_arrival_date := l_line_rec.schedule_arrival_date
3064 ;
3065 l_group_req_rec.old_request_date := l_line_rec.request_date;
3066 l_group_req_rec.old_ship_set_number := l_line_rec.ship_set_id;
3067 l_group_req_rec.old_arrival_set_number := l_line_rec.arrival_set_id;
3068
3069
3070 END IF;
3071
3072
3073 IF l_group_req_rec.entity_type = OE_ORDER_SCH_UTIL.OESCH_ENTITY_ARRIVAL_SET
3074 THEN
3075 l_group_req_rec.arrival_set_number := p_request_rec.param1;
3076 l_group_req_rec.ship_to_org_id := l_line_rec.ship_to_org_id;
3077
3078 IF NOT OE_GLOBALS.Equal(l_line_rec.schedule_arrival_date,
3079 l_group_req_rec.old_schedule_arrival_date)
3080 THEN
3081 l_group_req_rec.schedule_arrival_date :=
3082 l_line_rec.schedule_arrival_date;
3083 END IF;
3084
3085 ELSE
3086 l_group_req_rec.ship_set_number := p_request_rec.param1;
3087 l_group_req_rec.ship_from_org_id := l_line_rec.ship_from_org_id;
3088 l_group_req_rec.ship_to_org_id := l_line_rec.ship_to_org_id;
3089 l_group_req_rec.freight_carrier := l_line_rec.shipping_method_code;
3090
3091 IF NOT OE_GLOBALS.Equal(l_line_rec.schedule_ship_date,
3092 l_group_req_rec.old_schedule_ship_date)
3093 THEN
3094 l_group_req_rec.schedule_ship_date :=
3095 l_line_rec.schedule_ship_date;
3096 END IF;
3097
3098 -- Added this part here. If there is a change in arrival date
3099 -- we should pass this to group_schedule.
3100
3101 IF NOT OE_GLOBALS.Equal(l_line_rec.schedule_arrival_date,
3102 l_group_req_rec.old_schedule_arrival_date)
3103 THEN
3104 l_group_req_rec.schedule_arrival_date :=
3105 l_line_rec.schedule_arrival_date;
3106 END IF;
3107
3108 IF NOT OE_GLOBALS.Equal(l_line_rec.request_date,
3109 l_group_req_rec.old_request_date)
3110 THEN
3111 l_group_req_rec.request_date :=
3112 l_line_rec.request_date;
3113 END IF;
3114
3115
3116 END IF;
3117
3118 oe_debug_pub.add('*********Printing Group Request Attributes***********',2);
3119 oe_debug_pub.add('Grp Entity :' || l_group_req_rec.entity_type,2);
3120 oe_debug_pub.add('Grp Header Id :' || l_group_req_rec.header_id,2);
3121 oe_debug_pub.add('Line Id :' || l_group_req_rec.line_id,2);
3122 oe_debug_pub.add('Grp Action :' || l_group_req_rec.action,2);
3123 oe_debug_pub.add('Grp Warehouse :' || l_group_req_rec.ship_from_org_id,2);
3124 oe_debug_pub.add('Grp Ship to :' || l_group_req_rec.ship_to_org_id,2);
3125 oe_debug_pub.add('Group Sh Set# :' || l_group_req_rec.ship_set_number,2);
3126 oe_debug_pub.add('Group Ar Set# :' || l_group_req_rec.arrival_set_number,2);
3127 oe_debug_pub.add('Grp Ship Date :' || l_group_req_rec.schedule_ship_date,2);
3128 oe_debug_pub.add('Grp Ship Meth :' || l_group_req_rec.freight_carrier,2);
3129 oe_debug_pub.add('Grp Arr Date :' || l_group_req_rec.schedule_arrival_date,2);
3130 oe_debug_pub.add('***************************************************',2);
3131
3132 OE_GRP_SCH_UTIL.Group_Schedule
3133 (p_group_req_rec => l_group_req_rec
3134 ,x_atp_tbl => l_atp_tbl
3135 ,x_return_status => l_return_status);
3136
3137 -- Set the cascade_flag to TRUE, so that we query the block,
3138 -- since multiple lines have changed.
3139
3140 oe_debug_pub.add('Setting G_CASCADING_REQUEST_LOGGED',2);
3141
3142 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
3143 OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
3144 END IF;
3145
3146 x_return_status := l_return_status;
3147
3148 EXCEPTION
3149
3150 WHEN FND_API.G_EXC_ERROR THEN
3151 x_return_status := FND_API.G_RET_STS_ERROR;
3152
3153 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3154
3155 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3156 THEN
3157 OE_MSG_PUB.Add_Exc_Msg
3158 ( G_PKG_NAME
3159 , 'Group_Schedule'
3160 );
3161 END IF;
3162
3163
3164 WHEN OTHERS THEN
3165
3166
3167 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3168 THEN
3169 OE_MSG_PUB.Add_Exc_Msg
3170 ( G_PKG_NAME
3171 , 'Group_Schedule'
3172 );
3173 END IF;
3174
3175 END Group_Schedule;
3176
3177 Procedure Delink_Config
3178 ( p_line_id IN NUMBER
3179 , x_return_status OUT NOCOPY VARCHAR2)
3180
3181 IS
3182 BEGIN
3183
3184 oe_config_util.delink_config_batch
3185 (p_line_id => p_line_id,
3186 x_return_status => x_return_status);
3187 END;
3188
3189
3190
3191 /* procedure insert_rma_options_included
3192 to insert options and included items
3193 for the corresponding RMA lines.
3194 */
3195 Procedure INSERT_RMA_OPTIONS_INCLUDED
3196 (p_line_id IN NUMBER
3197 ,x_return_status OUT NOCOPY VARCHAR2
3198
3199 )
3200 IS
3201
3202 l_number NUMBER := 0;
3203 l_api_name CONSTANT VARCHAR(30) := 'INSERT_RMA_OPTIONS_INCLUDED';
3204 l_control_rec OE_GLOBALS.Control_Rec_Type;
3205 l_return_status VARCHAR2(30);
3206 l_orig_line_rec OE_Order_PUB.Line_Rec_Type;
3207 l_reference_line_rec OE_Order_Pub.Line_Rec_Type;
3208 l_child_line_rec OE_Order_Pub.Line_Rec_Type;
3209 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
3210 l_old_line_tbl OE_Order_PUB.Line_Tbl_Type;
3211 I NUMBER;
3212 l_line_id NUMBER;
3213 l_reference_line_id NUMBER;
3214 l_top_model_line_id NUMBER;
3215 l_ato_line_id NUMBER;
3216 l_link_to_line_id NUMBER;
3217 l_header_id NUMBER;
3218 l_fulfillment_set_id NUMBER := NULL;
3219 l_copy_call BOOLEAN;
3220
3221 -- l_component_code VARCHAR2(2000);
3222 CURSOR rma_children IS
3223 SELECT l.header_id, l.line_id, l.ordered_quantity
3224 FROM oe_order_lines l,mtl_system_items m
3225 WHERE l.top_model_line_id = l_top_model_line_id
3226 AND nvl(l.ato_line_id,1) = nvl(l_ato_line_id,nvl(l.ato_line_id,1))
3227 AND l.link_to_line_id = nvl(l_link_to_line_id,l.link_to_line_id)
3228 AND line_id <> l_reference_line_id
3229 AND l.header_id = l_header_id
3230 AND l.inventory_item_id = m.inventory_item_id
3231 AND nvl(m.returnable_flag,'Y') = 'Y'
3232 AND nvl(l.cancelled_flag,'N') = 'N'
3233 AND m.organization_id =
3234 OE_Sys_Parameters.VALUE_WNPS('MASTER_ORGANIZATION_ID')
3235 ORDER BY LINE_NUMBER , SHIPMENT_NUMBER ,NVL(OPTION_NUMBER, -1),
3236 NVL(COMPONENT_NUMBER,-1),NVL(SERVICE_NUMBER,-1);
3237
3238 /* Added the order by to fix bug 2226940 */
3239
3240
3241 BEGIN
3242
3243 OE_DEBUG_PUB.ADD('Entering INSERT_RMA_OPTIONS_INCLUDED',1);
3244
3245 x_return_status := FND_API.G_RET_STS_SUCCESS;
3246
3247 BEGIN
3248 -- query the return line and to see if it's a referenced line
3249 OE_Line_Util.query_row(p_line_id => p_line_id,
3250 x_line_rec => l_orig_line_rec);
3251 EXCEPTION
3252 WHEN NO_DATA_FOUND THEN
3253 RETURN;
3254 END;
3255
3256 IF l_orig_line_rec.return_context is NOT NULL THEN
3257
3258 OE_Line_Util.query_row(p_line_id => l_orig_line_rec.reference_line_id
3259 ,x_line_rec => l_reference_line_rec);
3260
3261 IF l_reference_line_rec.item_type_code in ('STANDARD','OPTION',
3262 'INCLUDED','CONFIG','SERVICE') THEN
3263 return;
3264 END IF;
3265
3266 -- find the partial return proportion, which applies to all the options and included item lines
3267
3268 l_reference_line_id := l_orig_line_rec.reference_line_id;
3269 l_header_id := l_reference_line_rec.header_id;
3270
3271 IF l_orig_line_rec.source_document_type_id = 2 THEN
3272 l_copy_call := TRUE;
3273 END IF;
3274
3275 IF l_reference_line_rec.top_model_line_id = l_reference_line_rec.line_id THEN
3276 l_top_model_line_id := l_reference_line_rec.line_id;
3277 ELSIF l_reference_line_rec.ato_line_id = l_reference_line_rec.line_id THEN
3278 l_ato_line_id := l_reference_line_rec.line_id;
3279 l_top_model_line_id := l_reference_line_rec.top_model_line_id;
3280 ELSIF l_reference_line_rec.component_code is NOT NULL THEN
3281 /* commented out nocopy to fix 2410422 */
3282
3283 /* l_component_code := l_reference_line_rec.component_code||'%'; */
3284 l_top_model_line_id := l_reference_line_rec.top_model_line_id;
3285 /* Added to fix 2410422 */
3286 l_link_to_line_id := l_reference_line_rec.line_id;
3287 ELSE
3288 return;
3289 END IF;
3290
3291
3292 FOR l_child IN rma_children LOOP
3293 l_number := l_number + 1;
3294
3295 l_line_tbl(l_number) := OE_ORDER_PUB.G_MISS_LINE_REC;
3296 IF l_number = 1 THEN
3297 select oe_sets_s.nextval into l_fulfillment_set_id from dual;
3298
3299 insert into oe_sets
3300 ( SET_ID, SET_NAME, SET_TYPE, HEADER_ID, SHIP_FROM_ORG_ID,
3301 SHIP_TO_ORG_ID,SCHEDULE_SHIP_DATE, SCHEDULE_ARRIVAL_DATE,
3302 FREIGHT_CARRIER_CODE, SHIPPING_METHOD_CODE,
3303 SHIPMENT_PRIORITY_CODE, SET_STATUS,
3304 CREATED_BY, CREATION_DATE, UPDATED_BY, UPDATE_DATE,
3305 UPDATE_LOGIN, INVENTORY_ITEM_ID,ORDERED_QUANTITY_UOM,
3306 LINE_TYPE_ID,SHIP_TOLERANCE_ABOVE, SHIP_TOLERANCE_BELOW)
3307 values
3308 ( l_fulfillment_set_id, to_char(l_fulfillment_set_id),
3309 'FULFILLMENT_SET',l_orig_line_rec.header_id,
3310 null,null, null,null,null,
3311 null,null,null, 0,sysdate,0, sysdate,
3312 0,null,null,null,null,null
3313 );
3314
3315 Insert into oe_line_sets(Line_id, Set_id, SYSTEM_REQUIRED_FLAG)
3316 Values (p_line_id, l_fulfillment_set_id, 'Y');
3317
3318 END IF;
3319
3320 -- If COPY is calling and DFF is to be copied over
3321 IF OE_ORDER_COPY_UTIL.CALL_DFF_COPY_EXTN_API(l_orig_line_rec.org_id) AND
3322 l_copy_call
3323 THEN
3324 OE_Line_Util.query_row(p_line_id => l_child.line_id,
3325 x_line_rec => l_child_line_rec);
3326
3327 IF OE_ORDER_COPY_UTIL.G_COPY_REC.line_descflex = FND_API.G_TRUE THEN
3328 -- Pre populate the DFF info from reference line
3329 OE_ORDER_COPY_UTIL.copy_line_dff_from_ref
3330 (p_ref_line_rec => l_child_line_rec,
3331 p_x_line_rec => l_line_tbl(l_number));
3332
3333 END IF;
3334
3335 OE_COPY_UTIL_EXT.Copy_Line_DFF(
3336 p_copy_rec => OE_ORDER_COPY_UTIL.G_COPY_REC,
3337 p_operation => 'ORDER_TO_RETURN',
3338 p_ref_line_rec => l_child_line_rec,
3339 p_copy_line_rec => l_line_tbl(l_number));
3340 END IF;
3341
3342 oe_debug_pub.add(' line id '|| to_char(l_line_tbl(l_number).line_id), 2);
3343 oe_debug_pub.add(to_char(l_line_tbl(l_number).ordered_quantity), 2);
3344 oe_debug_pub.add(to_char(l_child.ordered_quantity), 2);
3345 oe_debug_pub.add(to_char(l_orig_line_rec.ordered_quantity), 2);
3346 oe_debug_pub.add(to_char(l_reference_line_rec.ordered_quantity), 2);
3347
3348
3349 l_line_tbl(l_number).return_context := 'ORDER';
3350 l_line_tbl(l_number).return_attribute1 := l_child.header_id;
3351 l_line_tbl(l_number).return_attribute2 := l_child.line_id;
3352 l_line_tbl(l_number).ordered_quantity := ( l_child.ordered_quantity *
3353 l_orig_line_rec.ordered_quantity)/l_reference_line_rec.ordered_quantity;
3354 l_line_tbl(l_number).item_type_code := OE_GLOBALS.G_ITEM_STANDARD;
3355 l_line_tbl(l_number).operation := OE_GLOBALS.G_OPR_CREATE;
3356 l_line_tbl(l_number).header_id := l_orig_line_rec.header_id;
3357 l_line_tbl(l_number).line_type_id := l_orig_line_rec.line_type_id;
3358 l_line_tbl(l_number).return_reason_code := l_orig_line_rec.return_reason_code;
3359 -- Added for bug fix 2600923
3360 l_line_tbl(l_number).calculate_price_flag :=
3361 l_orig_line_rec.calculate_price_flag;
3362 l_line_tbl(l_number).pricing_date := l_orig_line_rec.pricing_date;
3363
3364 oe_debug_pub.add('RMA: Found options : '|| to_char(l_child.line_id), 2);
3365 END LOOP;
3366
3367 END IF;
3368
3369 IF l_number > 0 THEN
3370 oe_debug_pub.add('RMA: Found options and included item lines', 2);
3371
3372 -- Set control flags.
3373 l_control_rec.controlled_operation := TRUE;
3374 l_control_rec.validate_entity := TRUE;
3375 l_control_rec.write_to_DB := TRUE;
3376
3377 l_control_rec.default_attributes := TRUE;
3378 l_control_rec.change_attributes := TRUE;
3379 l_control_rec.clear_dependents := TRUE;
3380 l_control_rec.process := FALSE;
3381
3382 -- Instruct API to retain its caches
3383
3384 l_control_rec.clear_api_cache := FALSE;
3385 l_control_rec.clear_api_requests := FALSE;
3386
3387 -- Call OE_Order_PVT.Process_order to insert lines
3388 -- Set recursion mode.
3389 -- OE_GLOBALS.G_RECURSION_MODE := 'Y';
3390
3391 -- Set the global so that delayed request will not be
3392 -- logged for the child return line
3393 OE_GLOBALS.G_RETURN_CHILDREN_MODE := 'Y';
3394
3395 OE_ORDER_PVT.Lines
3396 (p_validation_level => FND_API.G_VALID_LEVEL_FULL
3397 ,p_control_rec => l_control_rec
3398 ,p_x_line_tbl => l_line_tbl
3399 ,p_x_old_line_tbl => l_old_line_tbl
3400 ,x_return_status => l_return_status);
3401
3402 -- Reset recursion mode.
3403 -- OE_GLOBALS.G_RECURSION_MODE := 'N';
3404
3405 OE_GLOBALS.G_RETURN_CHILDREN_MODE := 'N';
3406
3407 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3408 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3409 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3410 RAISE FND_API.G_EXC_ERROR;
3411 END IF;
3412
3413 --comment out for notification project
3414 /* OE_ORDER_PVT.Process_Requests_And_notify
3415 ( p_process_requests => FALSE
3416 ,p_notify => TRUE
3417 ,x_return_status => l_return_status
3418 ,p_line_tbl => l_line_tbl
3419 ,p_old_line_tbl => l_old_line_tbl);
3420
3421 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3422 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3423 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3424 RAISE FND_API.G_EXC_ERROR;
3425 END IF;
3426 */
3427 I := l_line_tbl.FIRST;
3428 WHILE I is not NULL LOOP
3429
3430 -- Insert into Fulfillment set
3431 Insert into oe_line_sets(Line_id, Set_id, SYSTEM_REQUIRED_FLAG)
3432 Values (l_line_tbl(I).line_id, l_fulfillment_set_id, 'Y');
3433
3434 -- Insert RMA Sales Credits and Adjustments
3435 INSERT_RMA_SCREDIT_ADJUSTMENT
3436 ( x_return_status => l_return_status
3437 ,p_line_id => l_line_tbl(I).line_id
3438 );
3439
3440 -- Insert RMA Lot and Serial Numbers
3441 INSERT_RMA_LOT_SERIAL
3442 ( x_return_status => l_return_status
3443 ,p_line_id => l_line_tbl(I).line_id
3444 );
3445
3446 I := l_line_tbl.NEXT(I);
3447 END LOOP;
3448
3449 OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
3450
3451 END IF; /* end inserting lines */
3452
3453 OE_DEBUG_PUB.ADD(' Exiting INSERT_RMA_OPTIONS_INCLUDED',1);
3454 EXCEPTION
3455
3456 WHEN FND_API.G_EXC_ERROR THEN
3457
3458 x_return_status := FND_API.G_RET_STS_ERROR;
3459
3460 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3461
3462 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3463
3464 WHEN OTHERS THEN
3465
3466 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3467
3468 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3469 THEN
3470 OE_MSG_PUB.Add_Exc_Msg
3471 ( G_PKG_NAME
3472 , 'INSERT_RMA_OPTIONS_INCLUDED'
3473 );
3474 END IF;
3475
3476 END INSERT_RMA_OPTIONS_INCLUDED;
3477
3478 /* procedure insert_rma_lot_serial
3479 to insert lot and serial numbers
3480 for the corresponding RMA lines.
3481
3482 * Bug7195205 : All serial numbers from referenced header are inserted in case
3483 * of partial return RMA
3484 */
3485 Procedure INSERT_RMA_LOT_SERIAL
3486 (p_line_id IN NUMBER
3487 ,x_return_status OUT NOCOPY VARCHAR2
3488
3489 )
3490 IS
3491
3492 l_number NUMBER := 0;
3493 l_api_name CONSTANT VARCHAR(30) := 'INSERT_RMA_LOT_SERIAL';
3494 l_control_rec OE_GLOBALS.Control_Rec_Type;
3495 l_x_lot_serial_tbl OE_Order_PUB.Lot_Serial_Tbl_Type;
3496 l_x_old_lot_serial_tbl OE_Order_PUB.Lot_Serial_Tbl_Type;
3497 l_return_status VARCHAR2(30);
3498 l_orig_line_rec OE_Order_PUB.Line_Rec_Type;
3499 l_reference_line_rec OE_Order_Pub.Line_Rec_Type;
3500 l_lot_serial_tbl OE_Order_PUB.Lot_Serial_Tbl_Type;
3501 l_line_id NUMBER;
3502 l_inventory_item_id NUMBER;
3503 l_reference_line_id NUMBER;
3504 l_lot_control_flag VARCHAR2(1) := 'N';
3505 l_serial_number_control_flag VARCHAR2(1) := 'N';
3506 l_count NUMBER := 0;
3507 l_serial_number VARCHAR2(30) := NULL;
3508 l_return_qty NUMBER := 0;
3509 l_lot_trxn_qty NUMBER := 0;
3510 l_return_qty2 NUMBER := 0; -- INVCONV
3511 l_lot_trxn_qty2 NUMBER := 0; -- INVCONV
3512
3513 l_ship_from_org_id NUMBER;
3514 /* OPM Bug 2739964 */
3515 l_item_rec OE_ORDER_CACHE.item_rec_type;
3516 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3517
3518 -- Added for 10204440 --
3519 CURSOR control_codes_org(p_ref_org_id NUMBER) IS
3520 SELECT decode(msi.lot_control_code,2,'Y','N'),
3521 decode(msi.serial_number_control_code,2,'Y',5,'Y',6,'Y','N'),
3522 primary_uom_code
3523 FROM mtl_system_items msi
3524 WHERE msi.inventory_item_id = l_inventory_item_id
3525 AND msi.organization_id = p_ref_org_id;
3526 -- End of 10204440
3527
3528
3529 CURSOR control_codes IS
3530 SELECT decode(msi.lot_control_code,2,'Y','N'),
3531 decode(msi.serial_number_control_code,2,'Y',5,'Y',6,'Y','N'),
3532 primary_uom_code
3533 FROM mtl_system_items msi
3534 WHERE msi.inventory_item_id = l_inventory_item_id
3535 AND msi.organization_id =
3536 OE_Sys_Parameters.VALUE_WNPS('MASTER_ORGANIZATION_ID');
3537
3538 -- Now Absolute value of transaction_quantity is selected to fix 1610964.
3539 -- Modified query to take care of over-shipped order lines(Bug # 1643433).
3540 -- Removed the view mtl_transaction_lot_val_v in the below cursor and used the tables involved in the view for bug 5395763
3541 CURSOR lot_numbers is
3542 SELECT u.lot_number,
3543 ABS(SUM(u.transaction_quantity)) transaction_quantity,
3544 ABS(SUM(u.secondary_transaction_quantity)) secondary_transaction_quantity -- INVCONV
3545 FROM mtl_transaction_lot_numbers u,
3546 mtl_lot_numbers l,
3547 mtl_material_transactions m
3548 WHERE m.transaction_id = u.transaction_id
3549 AND u.inventory_item_id = l_inventory_item_id
3550 AND m.transaction_source_type_id = 2
3551 AND m.trx_source_line_id = l_reference_line_id
3552 AND m.ORGANIZATION_ID = l_ship_from_org_id
3553 AND m.INVENTORY_ITEM_ID = l_inventory_item_id
3554 and u.organization_id=l.organization_id
3555 and u.inventory_item_id=l.inventory_item_id
3556 and u.lot_number = l.lot_number
3557 GROUP BY u.lot_number;
3558
3559 -- Added fix for bug 4493305
3560 CURSOR serial_numbers is
3561 SELECT DISTINCT u.serial_number
3562 FROM mtl_unit_transactions_all_v u,
3563 mtl_material_transactions m
3564 WHERE m.transaction_id = u.transaction_id
3565 AND m.INVENTORY_ITEM_ID = l_inventory_item_id
3566 AND u.serial_number = NVL(l_serial_number,u.serial_number)
3567 AND u.inventory_item_id = l_inventory_item_id
3568 AND m.transaction_source_type_id = 2
3569 AND m.trx_source_line_id = l_reference_line_id
3570 AND m.organization_id = l_ship_from_org_id
3571 AND m.transaction_action_id = 1
3572 AND m.transaction_type_id = 33;
3573
3574 CURSOR lot_serial_numbers is
3575 SELECT DISTINCT t.lot_number,
3576 u.serial_number
3577 FROM mtl_unit_transactions_all_v u,
3578 mtl_material_transactions m,
3579 mtl_transaction_lot_val_v t
3580 WHERE u.serial_number = NVL(l_serial_number,u.serial_number)
3581 AND u.INVENTORY_ITEM_ID = t.inventory_item_id
3582 AND t.serial_transaction_id = u.transaction_id
3583 AND t.INVENTORY_ITEM_ID = m.INVENTORY_ITEM_ID
3584 AND m.transaction_id = t.transaction_id
3585 AND m.transaction_source_type_id = 2
3586 AND m.trx_source_line_id = l_reference_line_id
3587 AND m.ORGANIZATION_ID = l_ship_from_org_id
3588 AND m.INVENTORY_ITEM_ID = l_inventory_item_id;
3589
3590 -- Added following variables for RMA bug 5288547
3591 l_need_to_fetch_all BOOLEAN := FALSE;
3592 l_primary_uom VARCHAR2(3);
3593
3594 BEGIN
3595
3596 OE_DEBUG_PUB.ADD(' Entering INSERT_RMA_LOT_SERIAL',1);
3597
3598 OE_DEBUG_PUB.ADD('RMA: Line Id is '||TO_CHAR(p_line_id),2);
3599
3600 -- if lot serial numbers exist, delete first
3601
3602
3603 x_return_status := FND_API.G_RET_STS_SUCCESS;
3604
3605 BEGIN
3606 OE_Line_Util.query_row(p_line_id => p_line_id
3607 ,x_line_rec => l_orig_line_rec);
3608 EXCEPTION
3609 WHEN NO_DATA_FOUND THEN
3610 Return;
3611 END;
3612
3613
3614 oe_debug_pub.add(l_orig_line_rec.return_context,2);
3615 -- IF l_orig_line_rec.return_context is NULL THEN
3616 -- RETURN;
3617 -- END IF;
3618 IF l_orig_line_rec.return_context = 'SERIAL' THEN
3619 l_serial_number := l_orig_line_rec.return_attribute2;
3620 ELSE
3621 l_serial_number := NULL;
3622 END IF;
3623
3624 BEGIN
3625 OE_Lot_serial_util.Lock_rows(p_line_id => p_line_id,
3626 x_lot_serial_tbl => l_lot_serial_tbl,
3627 x_return_status => l_return_status);
3628
3629 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3630 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3631 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3632 RAISE FND_API.G_EXC_ERROR;
3633 END IF;
3634
3635 EXCEPTION
3636 WHEN NO_DATA_FOUND THEN
3637 NULL;
3638 END;
3639
3640 IF (l_lot_serial_tbl.count > 0) THEN
3641
3642 oe_debug_pub.add('RMA: rma_lot_serial.DELETE_ROW', 2);
3643
3644 FOR I IN l_lot_serial_tbl.FIRST .. l_Lot_Serial_tbl.LAST LOOP
3645
3646 l_x_Lot_Serial_tbl(I) := l_Lot_Serial_tbl(I);
3647 l_x_Lot_Serial_tbl(I).operation := OE_GLOBALS.G_OPR_DELETE;
3648
3649 END LOOP;
3650
3651 -- Clear Table
3652 l_Lot_serial_tbl.DELETE;
3653
3654 END IF; /* end delete existing lot serial numbers */
3655
3656 l_reference_line_id := l_orig_line_rec.reference_line_id;
3657 IF l_reference_line_id IS NOT NULL AND
3658 l_reference_line_id <> FND_API.G_MISS_NUM THEN
3659
3660 OE_DEBUG_PUB.ADD(' There is a reference Line',1);
3661 OE_Line_Util.query_row(p_line_id => l_reference_line_id,
3662 x_line_rec => l_reference_line_rec);
3663 l_inventory_item_id := l_reference_line_rec.inventory_item_id;
3664 l_ship_from_org_id := l_reference_line_rec.ship_from_org_id;
3665 oe_debug_pub.add(to_char(l_inventory_item_id)||':'||to_char(l_ship_from_org_id),2);
3666
3667 IF l_ship_from_org_id is NULL
3668 OR l_ship_from_org_id = FND_API.G_MISS_NUM THEN --Added for 10204440
3669
3670 OPEN control_codes;
3671 FETCH control_codes INTO l_lot_control_flag,
3672 l_serial_number_control_flag,
3673 l_primary_uom;
3674 IF control_codes%notfound THEN
3675 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3676 END IF;
3677 CLOSE control_codes;
3678
3679 --Added for 10204440
3680 ELSE
3681
3682 OPEN control_codes_org(l_ship_from_org_id);
3683 FETCH control_codes_org INTO l_lot_control_flag,
3684 l_serial_number_control_flag,
3685 l_primary_uom;
3686 IF control_codes_org%notfound THEN
3687 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3688 END IF;
3689 CLOSE control_codes_org;
3690 END IF;
3691 --End of 10204440
3692
3693
3694 -- Added following for RMA bug 5155914
3695
3696 -- Shipping UOM is always the Primary UOM for an item. If the original order
3697 -- that shipped out, has non-primary order_quantity_UOM then we should be
3698 -- fetching all data from the MTL tables for all LOT and Serial numbers that
3699 -- shipped on the originalorder(Not restrict it by the quantity on the RMA)
3700 -- It will be left to users to manually edit the data if needed in
3701 -- oe_lot_serial_numbers table.
3702
3703 IF l_reference_line_rec.order_quantity_uom <> l_primary_uom THEN
3704 l_need_to_fetch_all := TRUE;
3705 END IF;
3706
3707
3708 IF (l_lot_control_flag = 'Y' and l_serial_number_control_flag <> 'N') THEN
3709
3710 -- If the Item is LOT and Serial controlled
3711
3712 FOR l_lot_serial_numbers IN lot_serial_numbers LOOP
3713 /*
3714 ** Exit the loop if lot serial qty reaches line return qty.
3715 */
3716 IF l_return_qty >= l_orig_line_rec.ordered_quantity AND
3717 NOT l_need_to_fetch_all -- bug 5155914
3718 THEN
3719 EXIT;
3720 ELSE
3721 l_return_qty := l_return_qty + 1;
3722 END IF;
3723
3724 OE_DEBUG_PUB.ADD(' In LOT-SERIAL-NUMBERS cursor',1);
3725 l_number := l_number + 1;
3726 l_lot_serial_tbl(l_number) := OE_ORDER_PUB.G_MISS_LOT_SERIAL_REC;
3727 l_lot_serial_tbl(l_number).lot_number := l_lot_serial_numbers.lot_number;
3728 l_lot_serial_tbl(l_number).from_serial_number := l_lot_serial_numbers.serial_number;
3729 l_lot_serial_tbl(l_number).quantity := 1;
3730 END LOOP;
3731
3732 ELSIF (l_lot_control_flag = 'Y') THEN
3733
3734 -- If the Item is just LOT controlled
3735
3736 FOR l_lot_numbers IN lot_numbers LOOP
3737 /*
3738 ** Exit the loop if lot item qty reaches line return qty.
3739 */
3740 IF l_return_qty = l_orig_line_rec.ordered_quantity AND
3741 NOT l_need_to_fetch_all -- bug 5155914
3742 THEN
3743 EXIT;
3744 END IF;
3745
3746 l_return_qty := l_return_qty + l_lot_numbers.transaction_quantity;
3747 l_return_qty2 := l_return_qty2 + l_lot_numbers.secondary_transaction_quantity; -- INVCONV
3748
3749 IF l_return_qty > l_orig_line_rec.ordered_quantity AND
3750 NOT l_need_to_fetch_all -- bug 5155914
3751 THEN
3752 l_lot_trxn_qty := l_orig_line_rec.ordered_quantity - (l_return_qty - l_lot_numbers.transaction_quantity);
3753 l_return_qty := l_orig_line_rec.ordered_quantity;
3754 l_lot_trxn_qty2 := l_orig_line_rec.ordered_quantity2 - (l_return_qty2 - l_lot_numbers.secondary_transaction_quantity); -- INVCONV
3755 l_return_qty2 := l_orig_line_rec.ordered_quantity2; -- INVCONV
3756
3757
3758 ELSE
3759 l_lot_trxn_qty := l_lot_numbers.transaction_quantity;
3760 l_lot_trxn_qty2 := l_lot_numbers.secondary_transaction_quantity; -- INVCONV
3761 END IF;
3762
3763 l_number := l_number + 1;
3764 OE_DEBUG_PUB.ADD(' In LOT-NUMBERS cursor',1);
3765 l_lot_serial_tbl(l_number) := OE_ORDER_PUB.G_MISS_LOT_SERIAL_REC;
3766 l_lot_serial_tbl(l_number).lot_number := l_lot_numbers.lot_number;
3767
3768 -- transaction quantity is negative because of sales order issue
3769 -- Removed -ve sign to fix 1643433.
3770 l_lot_serial_tbl(l_number).quantity := l_lot_trxn_qty;
3771 l_lot_serial_tbl(l_number).quantity2 := l_lot_trxn_qty2; -- INVCONV
3772
3773 END LOOP;
3774
3775 ELSIF (l_serial_number_control_flag <> 'N') THEN
3776
3777 -- If the Item is just Serial controlled
3778
3779 FOR l_serial_numbers IN serial_numbers LOOP
3780 /*
3781 ** Exit the loop if serial item qty reaches line return qty.
3782 */
3783 --Bug7195205 : Changed l_orig_line_rec.ordered_quantity
3784 -- with l_reference_line_rec.ordered_quantity in order to
3785 -- insert all serial numbers from referenced sales order
3786 -- in case of partial return of an RMA
3787 IF l_return_qty >= l_reference_line_rec.ordered_quantity AND
3788 NOT l_need_to_fetch_all -- bug 5155914
3789 THEN
3790 EXIT;
3791 ELSE
3792 l_return_qty := l_return_qty + 1;
3793 END IF;
3794
3795 l_number := l_number + 1;
3796 OE_DEBUG_PUB.ADD(' In SERIAL-NUMBERS cursor',1);
3797 l_lot_serial_tbl(l_number) := OE_ORDER_PUB.G_MISS_LOT_SERIAL_REC;
3798 l_lot_serial_tbl(l_number).from_serial_number := l_serial_numbers.serial_number;
3799 l_lot_serial_tbl(l_number).quantity := 1;
3800 END LOOP;
3801
3802 END IF;
3803 END IF;
3804 -- END IF;-- INVCONV
3805 IF l_number > 0 THEN
3806 oe_debug_pub.add('RMA: FOUND LOT/SERIAL NUMBERS FOR THE LINE'||to_char(l_number), 1);
3807
3808 FOR I IN l_Lot_serial_tbl.FIRST .. l_Lot_serial_tbl.LAST LOOP
3809
3810 l_count := l_x_lot_serial_tbl.count;
3811 l_x_lot_serial_tbl(l_count + I) := l_lot_serial_tbl(I);
3812 l_x_lot_serial_tbl(l_count + I).operation := OE_GLOBALS.G_OPR_CREATE;
3813 l_x_lot_serial_tbl(l_count + I).line_id := l_orig_line_rec.line_id;
3814
3815 END LOOP;
3816 END IF; /* end inserting lot serial numbers */
3817
3818 IF l_x_lot_serial_tbl.count > 0 THEN
3819 OE_DEBUG_PUB.ADD(' Before calling OE_ORDER_PVT.Lot_Serials',1);
3820 -- Call OE_Order_PVT.Process_order to insert lines
3821 -- Set recursion mode.
3822 -- OE_GLOBALS.G_RECURSION_MODE := 'Y';
3823
3824 OE_ORDER_PVT.Lot_Serials
3825 (p_validation_level => FND_API.G_VALID_LEVEL_FULL
3826 ,p_control_rec => l_control_rec
3827 ,P_x_lot_serial_tbl => l_x_lot_serial_tbl
3828 ,p_x_old_lot_serial_tbl => l_x_old_lot_serial_tbl
3829 ,x_return_status => l_return_status);
3830 -- Reset recursion mode.
3831 -- OE_GLOBALS.G_RECURSION_MODE := 'N';
3832 OE_DEBUG_PUB.ADD(' After calling OE_ORDER_PVT.Lot_Serials',1);
3833
3834 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3835 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3836 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3837 RAISE FND_API.G_EXC_ERROR;
3838 END IF;
3839
3840 --comment out for nitification project
3841 /* OE_ORDER_PVT.Process_Requests_And_notify
3842 ( p_process_requests => FALSE
3843 ,p_notify => TRUE
3844 ,x_return_status => l_return_status
3845 ,p_lot_serial_tbl => l_x_lot_serial_tbl
3846 ,p_old_lot_serial_tbl => l_x_old_lot_serial_tbl);
3847
3848 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3849 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3850 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3851 RAISE FND_API.G_EXC_ERROR;
3852 END IF;
3853 */
3854
3855 END IF; /* end calling process order */
3856 -- Clear Table
3857 l_Lot_serial_tbl.DELETE;
3858
3859 OE_DEBUG_PUB.ADD(' Exiting INSERT_RMA_LOT_SERIAL',1);
3860
3861 EXCEPTION
3862
3863
3864 WHEN FND_API.G_EXC_ERROR THEN
3865
3866 x_return_status := FND_API.G_RET_STS_ERROR;
3867
3868 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3869
3870 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3871
3872 WHEN OTHERS THEN
3873
3874 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3875
3876 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3877 THEN
3878 OE_MSG_PUB.Add_Exc_Msg
3879 ( G_PKG_NAME
3880 , 'INSERT_RMA_LOT_SERIAL'
3881 );
3882 END IF;
3883
3884 END INSERT_RMA_LOT_SERIAL;
3885
3886 PROCEDURE Validate_Line_Set(P_line_set_id IN NUMBER,
3887 x_return_status OUT NOCOPY VARCHAR2) IS
3888
3889 l_line_tbl OE_ORDER_PUB.LINE_TBL_TYPE;
3890 l_item_id NUMBER;
3891 l_order_qty_uom VARCHAR2(30);
3892 l_line_type_id NUMBER;
3893 l_ship_tolerance_above NUMBER;
3894 l_ship_tolerance_below NUMBER;
3895 l_project_id NUMBER;
3896 l_task_id NUMBER;
3897 l_lin_line_id NUMBER; -- Bug 5754554
3898 l_fulfillment_base VARCHAR2(1);--ER#14763609
3899
3900 BEGIN
3901 oe_debug_pub.add('Entering oe_delayed_requests_util.Validate_Line_Set',1);
3902 oe_line_util.query_rows(p_line_set_id => p_line_set_id,
3903 x_line_tbl => l_line_tbl);
3904
3905 -- Start for bug 5754554
3906 IF l_line_tbl.count > 0 THEN
3907 FOR I IN 1 .. l_line_tbl.count LOOP
3908 IF l_line_tbl(I).open_flag = 'N' AND l_line_tbl(I).cancelled_flag = 'Y'
3909 THEN
3910 oe_debug_pub.add(' Line_id '||l_line_tbl(I).line_id||' is canceled. Discarding it from Line Set');
3911 l_line_tbl.DELETE(I);
3912 END IF;
3913 END LOOP;
3914 END IF;
3915
3916 IF l_line_tbl.count > 0 THEN
3917 FOR I IN l_line_tbl.first .. l_line_tbl.last LOOP
3918 IF l_line_tbl.EXISTS(I) THEN
3919 l_item_id := nvl(l_line_tbl(I).inventory_item_id,-99);
3920 l_order_qty_uom := nvl(l_line_tbl(I).order_quantity_uom,'-99');
3921 l_line_type_id := nvl(l_line_tbl(I).line_type_id,-99) ;
3922 l_ship_tolerance_above := nvl(l_line_tbl(I).ship_tolerance_above,-99);
3923 l_ship_tolerance_below := Nvl(l_line_tbl(I).ship_tolerance_below,-99);
3924 l_task_id := Nvl(l_line_tbl(I).task_id,-99);
3925 l_project_id := Nvl(l_line_tbl(I).project_id,-99);
3926 l_lin_line_id := Nvl(l_line_tbl(I).line_id,-99);
3927 l_fulfillment_base := Nvl(l_line_tbl(I).fulfillment_base,'P'); ----ER#14763609
3928 EXIT;
3929 END IF;
3930 END LOOP;
3931
3932 /*
3933 l_item_id := nvl(l_line_tbl(1).inventory_item_id,-99);
3934 l_order_qty_uom := nvl(l_line_tbl(1).order_quantity_uom,'-99');
3935 l_line_type_id := nvl(l_line_tbl(1).line_type_id,-99) ;
3936 l_ship_tolerance_above := nvl(l_line_tbl(1).ship_tolerance_above,-99);
3937 l_ship_tolerance_below := Nvl(l_line_tbl(1).ship_tolerance_below,-99);
3938 l_project_id := Nvl(l_line_tbl(1).project_id,-99);
3939 l_task_id := Nvl(l_line_tbl(1).task_id,-99);
3940
3941 FOR I IN 2 .. l_line_tbl.count */
3942 FOR I IN l_line_tbl.first .. l_line_tbl.last
3943 LOOP
3944 IF l_line_tbl.EXISTS(I) AND l_line_tbl(I).line_id <> l_lin_line_id
3945 THEN
3946 -- End for bug 5754554
3947
3948 IF (l_line_tbl(I).inventory_item_id <>
3949 l_item_id ) THEN
3950 FND_MESSAGE.SET_NAME('ONT','OE_VAL_LINE_SET_ATTR');
3951 FND_MESSAGE.SET_TOKEN('ATTRIBUTE_NAME','Item');
3952 FND_MESSAGE.SET_TOKEN('LINE_NUMBER',
3953 to_char(l_line_tbl(I).shipment_number));
3954 FND_MESSAGE.SET_TOKEN('PARENT_LINE_NUMBER',
3955 to_char(l_line_tbl(I).line_number));
3956 OE_MSG_PUB.ADD;
3957 RAISE FND_API.G_EXC_ERROR;
3958 ELSIF (l_line_tbl(I).order_quantity_uom <>
3959 l_order_qty_uom ) THEN
3960 FND_MESSAGE.SET_NAME('ONT','OE_VAL_LINE_SET_ATTR');
3961 FND_MESSAGE.SET_TOKEN('ATTRIBUTE_NAME','Unit of Measure');
3962 FND_MESSAGE.SET_TOKEN('LINE_NUMBER',
3963 to_char(l_line_tbl(I).shipment_number));
3964 FND_MESSAGE.SET_TOKEN('PARENT_LINE_NUMBER',
3965 to_char(l_line_tbl(I).line_number));
3966 OE_MSG_PUB.ADD;
3967 RAISE FND_API.G_EXC_ERROR;
3968 ELSIF (l_line_tbl(I).line_type_id <>
3969 l_line_type_id ) THEN
3970 FND_MESSAGE.SET_NAME('ONT','OE_VAL_LINE_SET_ATTR');
3971 FND_MESSAGE.SET_TOKEN('ATTRIBUTE_NAME','Line Type');
3972 FND_MESSAGE.SET_TOKEN('LINE_NUMBER',
3973 to_char(l_line_tbl(I).shipment_number));
3974 FND_MESSAGE.SET_TOKEN('PARENT_LINE_NUMBER',
3975 to_char(l_line_tbl(I).line_number));
3976 OE_MSG_PUB.ADD;
3977 RAISE FND_API.G_EXC_ERROR;
3978 ELSIF (l_line_tbl(I).ship_tolerance_above <>
3979 l_ship_tolerance_above ) THEN
3980 FND_MESSAGE.SET_NAME('ONT','OE_VAL_LINE_SET_ATTR');
3981 FND_MESSAGE.SET_TOKEN('ATTRIBUTE_NAME','Ship tolerance above');
3982 FND_MESSAGE.SET_TOKEN('LINE_NUMBER',
3983 to_char(l_line_tbl(I).shipment_number));
3984 FND_MESSAGE.SET_TOKEN('PARENT_LINE_NUMBER',
3985 to_char(l_line_tbl(I).line_number));
3986 OE_MSG_PUB.ADD;
3987 RAISE FND_API.G_EXC_ERROR;
3988 ELSIF (l_line_tbl(I).ship_tolerance_below <>
3989 l_ship_tolerance_below ) THEN
3990 FND_MESSAGE.SET_NAME('ONT','OE_VAL_LINE_SET_ATTR');
3991 FND_MESSAGE.SET_TOKEN('ATTRIBUTE_NAME','Ship tolerance below');
3992 FND_MESSAGE.SET_TOKEN('LINE_NUMBER',
3993 to_char(l_line_tbl(I).shipment_number));
3994 FND_MESSAGE.SET_TOKEN('PARENT_LINE_NUMBER',
3995 to_char(l_line_tbl(I).line_number));
3996 OE_MSG_PUB.ADD;
3997 RAISE FND_API.G_EXC_ERROR;
3998 ELSIF (l_line_tbl(I).project_id <>
3999 l_project_id ) THEN
4000 FND_MESSAGE.SET_NAME('ONT','OE_VAL_LINE_SET_ATTR');
4001 FND_MESSAGE.SET_TOKEN('ATTRIBUTE_NAME','Project');
4002 FND_MESSAGE.SET_TOKEN('LINE_NUMBER',
4003 to_char(l_line_tbl(I).shipment_number));
4004 FND_MESSAGE.SET_TOKEN('PARENT_LINE_NUMBER',
4005 to_char(l_line_tbl(I).line_number));
4006 OE_MSG_PUB.ADD;
4007 RAISE FND_API.G_EXC_ERROR;
4008 ELSIF (l_line_tbl(I).Task_id <>
4009 l_Task_id ) THEN
4010 FND_MESSAGE.SET_NAME('ONT','OE_VAL_LINE_SET_ATTR');
4011 FND_MESSAGE.SET_TOKEN('ATTRIBUTE_NAME','Task');
4012 FND_MESSAGE.SET_TOKEN('LINE_NUMBER',
4013 to_char(l_line_tbl(I).shipment_number));
4014 FND_MESSAGE.SET_TOKEN('PARENT_LINE_NUMBER',
4015 to_char(l_line_tbl(I).line_number));
4016 OE_MSG_PUB.ADD;
4017 RAISE FND_API.G_EXC_ERROR;
4018 ----ER#14763609
4019 ELSIF (Nvl(l_line_tbl(I).fulfillment_base,'P') <> l_fulfillment_base) THEN
4020 FND_MESSAGE.SET_NAME('ONT','OE_VAL_LINE_SET_ATTR');
4021 FND_MESSAGE.SET_TOKEN('ATTRIBUTE_NAME','Fulfillment Base');
4022 FND_MESSAGE.SET_TOKEN('LINE_NUMBER',
4023 to_char(l_line_tbl(I).shipment_number));
4024 FND_MESSAGE.SET_TOKEN('PARENT_LINE_NUMBER',
4025 to_char(l_line_tbl(I).line_number));
4026 OE_MSG_PUB.ADD;
4027 RAISE FND_API.G_EXC_ERROR;
4028 --END ER#14763609
4029 END IF;
4030 END IF; -- For Bug 5754554
4031 END LOOP;
4032 END IF;
4033 oe_debug_pub.add('Exiting oe_delayed_requests_util.Validate_Line_Set',1);
4034 EXCEPTION
4035 WHEN FND_API.G_EXC_ERROR THEN
4036
4037 OE_MSG_PUB.reset_msg_context('SPLIT');
4038 RAISE;
4039
4040 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4041
4042 OE_MSG_PUB.reset_msg_context('SPLIT');
4043 RAISE;
4044
4045
4046 WHEN OTHERS THEN
4047 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4048 THEN
4049 OE_MSG_PUB.Add_Exc_Msg
4050 ( G_PKG_NAME ,
4051 'Validate Line Set'
4052 );
4053 END IF;
4054 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4055
4056 END Validate_line_Set;
4057
4058 PROCEDURE Process_Adjustments
4059 (p_adjust_tbl IN OE_ORDER_PUB.REQUEST_TBL_TYPE,
4060 x_return_status OUT NOCOPY VARCHAR2)
4061
4062 IS
4063 l_return_status VARCHAR2(30);
4064 x_msg_data VARCHAR2(2000);
4065 x_msg_count NUMBER;
4066 l_adj_rec OE_ORDER_PUB.LINE_ADJ_REC_TYPE;
4067 l_adj_tbl OE_ORDER_PUB.LINE_ADJ_TBL_TYPE;
4068 l_x_header_rec OE_Order_PUB.Header_Rec_Type;
4069 l_x_Header_Adj_tbl OE_Order_PUB.Header_Adj_Tbl_Type;
4070 l_x_Header_Scredit_tbl OE_Order_PUB.Header_Scredit_Tbl_Type;
4071 l_x_line_tbl OE_Order_PUB.Line_Tbl_Type;
4072 l_x_Line_Adj_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
4073 l_x_Line_Scredit_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
4074 l_x_Lot_Serial_tbl OE_Order_PUB.Lot_Serial_Tbl_Type;
4075 l_x_action_request_tbl OE_Order_PUB.Request_Tbl_Type;
4076 l_x_Header_price_Att_tbl OE_Order_PUB.Header_Price_Att_Tbl_Type;
4077 l_x_Header_Adj_Att_tbl OE_Order_PUB.Header_Adj_Att_Tbl_Type;
4078 l_x_Header_Adj_Assoc_tbl OE_Order_PUB.Header_Adj_Assoc_Tbl_Type;
4079 l_x_Line_price_Att_tbl OE_Order_PUB.Line_Price_Att_Tbl_Type;
4080 l_x_Line_Adj_Att_tbl OE_Order_PUB.Line_Adj_Att_Tbl_Type;
4081 l_x_Line_Adj_Assoc_tbl OE_Order_PUB.Line_Adj_Assoc_Tbl_Type;
4082 l_list_line_type_code VARCHAR2(30) := NULL;
4083 l_list_line_id NUMBER;
4084 --serla begin
4085 l_x_Header_Payment_tbl OE_Order_PUB.Header_Payment_Tbl_Type;
4086 l_x_Line_Payment_tbl OE_Order_PUB.Line_Payment_Tbl_Type;
4087 --serla end
4088 Begin
4089
4090
4091 oe_debug_pub.add('Entering oe_delayed_requests_util.Process_adjustments',1);
4092 FOR I IN 1..(p_adjust_tbl.COUNT) LOOP
4093
4094 oe_debug_pub.add('I in p_adjust_tbl is : ' || I,2);
4095
4096 oe_debug_pub.add(p_adjust_tbl(I).param3 || ' is there ',2);
4097
4098 Select list_line_type_code
4099 Into l_list_line_type_code
4100 From qp_list_lines
4101 Where list_line_id = to_number(p_adjust_tbl(I).param3);
4102
4103 l_adj_rec := Oe_Order_Pub.G_MISS_LINE_ADJ_REC;
4104 /* l_adj_rec.list_line_type_code := 'DIS'; */
4105 l_adj_rec.price_adjustment_id := to_number(p_adjust_tbl(I).param1);
4106 l_adj_rec.list_header_id := to_number(p_adjust_tbl(I).param2);
4107
4108 l_adj_rec.list_line_id := to_number(p_adjust_tbl(I).param3);
4109 /*
4110 l_adj_rec.list_line_id := l_list_line_id;
4111 */
4112 l_adj_rec.automatic_flag := p_adjust_tbl(I).param4;
4113 l_adj_rec.list_line_type_code := l_list_line_type_code;
4114 l_adj_rec.arithmetic_operator := '%';
4115 l_adj_rec.operand := to_number(p_adjust_tbl(I).param5);
4116 l_adj_rec.line_id := p_adjust_tbl(I).entity_id;
4117 l_adj_rec.header_id := to_number(p_adjust_tbl(I).param7);
4118 l_adj_rec.operation := p_adjust_tbl(I).param8;
4119
4120 l_adj_tbl(I) := l_adj_rec;
4121
4122
4123 END LOOP;
4124
4125 /* call process order */
4126
4127 IF (l_adj_tbl.COUNT >= 1) THEN
4128
4129 -- Set recursion mode.
4130 -- OE_GLOBALS.G_RECURSION_MODE := 'Y';
4131
4132 OE_Order_PVT.Process_order
4133 ( p_api_version_number => 1.0
4134 , x_return_status => l_return_status
4135 , x_msg_count => x_msg_count
4136 , x_msg_data => x_msg_data
4137 , p_x_header_rec => l_x_header_rec
4138 , p_x_Header_Adj_tbl => l_x_Header_Adj_tbl
4139 , p_x_Header_Scredit_tbl => l_x_Header_Scredit_tbl
4140 --serla begin
4141 , p_x_Header_Payment_tbl => l_x_Header_Payment_tbl
4142 --serla end
4143 , p_x_line_tbl => l_x_line_tbl
4144 , p_x_Line_Adj_tbl => l_Adj_tbl
4145 , p_x_Line_Scredit_tbl => l_x_Line_Scredit_tbl
4146 --serla begin
4147 , p_x_Line_Payment_tbl => l_x_Line_Payment_tbl
4148 --serla end
4149 , p_x_Lot_Serial_tbl => l_x_Lot_Serial_tbl
4150 , p_x_action_request_tbl => l_x_action_request_tbl
4151 , p_x_header_price_att_tbl => l_x_header_price_att_tbl
4152 , p_x_Header_Adj_att_tbl => l_x_Header_Adj_att_tbl
4153 , p_x_Header_Adj_Assoc_tbl => l_x_Header_Adj_Assoc_tbl
4154 , p_x_Line_Price_att_tbl => l_x_Line_Price_att_tbl
4155 , p_x_Line_Adj_att_tbl => l_x_Line_Adj_att_tbl
4156 , p_x_Line_Adj_Assoc_tbl => l_x_Line_Adj_Assoc_tbl
4157 );
4158
4159
4160 -- Reset recursion mode.
4161 -- OE_GLOBALS.G_RECURSION_MODE := 'N';
4162
4163 oe_debug_pub.add('after process order call ',2);
4164 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4165 oe_debug_pub.add('error1',2);
4166 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4167 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4168 oe_debug_pub.add('error2',2);
4169 RAISE FND_API.G_EXC_ERROR;
4170 END IF;
4171
4172 end if; /* if l_adj_tbl.count >= 1 */
4173
4174 oe_debug_pub.add('no error in process order ',2);
4175 x_return_status := l_return_status;
4176 oe_debug_pub.add('Exiting oe_delayed_requests_util.Process_adjustments',1);
4177
4178
4179 EXCEPTION
4180
4181 WHEN FND_API.G_EXC_ERROR THEN
4182
4183 x_return_status := FND_API.G_RET_STS_ERROR;
4184
4185 -- Get message count and data
4186
4187 OE_MSG_PUB.Count_And_Get
4188 ( p_count => x_msg_count
4189 , p_data => x_msg_data
4190 );
4191
4192 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4193
4194 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4195 -- Get message count and data
4196
4197 OE_MSG_PUB.Count_And_Get
4198 ( p_count => x_msg_count
4199 , p_data => x_msg_data
4200 );
4201
4202 WHEN OTHERS THEN
4203
4204 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4205
4206 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4207 THEN
4208 OE_MSG_PUB.Add_Exc_Msg
4209 ( G_PKG_NAME
4210 , 'Process_Adjustments'
4211 );
4212 END IF;
4213 -- Get message count and data
4214
4215 OE_MSG_PUB.Count_And_Get
4216 ( p_count => x_msg_count
4217 , p_data => x_msg_data
4218 );
4219
4220 NULL;
4221
4222 End Process_Adjustments;
4223
4224 PROCEDURE INSERT_SERVICE_FOR_OPTIONS
4225 (p_serviced_line_id IN NUMBER
4226 ,x_return_status OUT NOCOPY VARCHAR2
4227
4228 )
4229
4230 IS
4231
4232 l_number NUMBER := 0;
4233 l_api_name CONSTANT VARCHAR(30) := 'INSERT_SERVICE_FOR_OPTIONS';
4234 l_control_rec OE_GLOBALS.Control_Rec_Type;
4235 l_return_status Varchar2(30);
4236 l_orig_line_rec OE_Order_PUB.Line_Rec_Type;
4237 l_reference_line_rec OE_Order_Pub.Line_Rec_Type;
4238 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
4239 l_old_line_tbl OE_Order_PUB.Line_Tbl_Type;
4240 l_line_id NUMBER;
4241 l_service_reference_line_id NUMBER;
4242 l_header_id NUMBER;
4243 l_line_number NUMBER;
4244 l_order_number NUMBER;
4245 l_shipment_number NUMBER;
4246 l_option_number NUMBER;
4247 l_component_number NUMBER;
4248 x_del_req_ret_status VARCHAR2(1);
4249
4250 l_prg VARCHAR2(1) := 'N'; --bug 16848168
4251
4252
4253 -- For bug 2372098
4254 TYPE Line_Cur_Type IS ref CURSOR;
4255 srv_children line_cur_type;
4256
4257 -- Commented for bug 2372098, this static cursor is replaced
4258 -- with a cursor variable named srv_children
4259
4260 -- CURSOR srv_children IS
4261 -- SELECT l.header_id,
4262 -- l.line_id,
4263 -- l.shipment_number,
4264 -- l.line_number,
4265 -- l.option_number,
4266 -- l.component_number,
4267 -- l.service_txn_reason_code,
4268 -- l.service_txn_comments,
4269 -- l.service_duration,
4270 -- l.service_period,
4271 -- l.service_start_date,
4272 -- l.service_end_date,
4273 -- l.service_coterminate_flag,
4274 -- l.ordered_quantity
4275 -- FROM oe_order_lines l
4276 -- WHERE l.top_model_line_id = l_service_reference_line_id
4277 -- AND l.item_type_code in ('INCLUDED','CLASS','OPTION')
4278 -- AND exists (select null from mtl_system_items mtl where
4279 -- mtl.inventory_item_id = l.inventory_item_id and
4280 -- mtl.serviceable_product_flag = 'Y' and
4281 -- mtl.organization_id=OE_SYS_PARAMETERS.VALUE('MASTER_ORGANIZATION_ID') );
4282 --lchen added check for organizations to fix bug 2039304
4283
4284 CURSOR srv_number IS
4285 SELECT max(l.service_number) service_number
4286 FROM oe_order_lines l
4287 WHERE l.header_id = l_header_id
4288 AND l.line_number = l_line_number
4289 AND l.shipment_number = l_shipment_number
4290 AND nvl(l.option_number,0) = nvl(l_option_number,0)
4291 AND nvl(l.component_number,0) = nvl(l_component_number,0);
4292 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level; -- sol_ord_er #16014165
4293
4294 BEGIN
4295
4296 OE_DEBUG_PUB.ADD('Entering INSERT_SERVICE_FOR_OPTIONS',1);
4297
4298 IF fnd_profile.value('ONT_CASCADE_SERVICE') = 'N' THEN
4299 /* 3128684 */
4300 oe_debug_pub.add('Do not cascade services', 2);
4301 x_return_status := FND_API.G_RET_STS_SUCCESS;
4302 RETURN;
4303 END IF;
4304 oe_debug_pub.add('Do cascade services', 2);
4305
4306 -- query the service line and to see if it's a referenced line
4307 OE_Line_Util.query_row(p_line_id => p_serviced_line_id,
4308 x_line_rec => l_orig_line_rec);
4309
4310 SELECT /* MOAC_SQL_CHANGE */ h.order_number
4311 INTO l_order_number
4312 FROM oe_order_headers_all h, oe_order_lines l
4313 WHERE h.header_id = l.header_id
4314 AND h.header_id = l_orig_line_rec.header_id
4315 AND rownum = 1;
4316
4317
4318
4319 IF l_orig_line_rec.service_reference_type_code is NOT NULL THEN
4320 OE_Line_Util.query_row(p_line_id => l_orig_line_rec.service_reference_line_id,
4321 x_line_rec => l_reference_line_rec);
4322 l_service_reference_line_id := l_orig_line_rec.service_reference_line_id;
4323 oe_debug_pub.add('JPN: Service Reference Line is' || l_service_reference_line_id,2);
4324
4325 --bug 16848168 changes
4326 BEGIN
4327 oe_debug_pub.ADD('l_reference_line_rec.line_id : '||l_reference_line_rec.line_id,1);
4328 oe_debug_pub.ADD('l_orig_line_rec.line_id : '||l_orig_line_rec.line_id,1);
4329 oe_debug_pub.ADD('l_orig_line_rec.item_type_code : '||l_orig_line_rec.item_type_code,1);
4330 oe_debug_pub.ADD('l_orig_line_rec.SUBSCRIPTION_ENABLE_FLAG : '||l_orig_line_rec.SUBSCRIPTION_ENABLE_FLAG,1);
4331
4332
4333 SELECT 'Y'
4334 INTO l_prg
4335 FROM oe_price_adjustments prg, oe_price_adj_assocs a,
4336 oe_price_adjustments p
4337 WHERE prg.line_id = l_reference_line_rec.line_id
4338 AND prg.list_line_type_code = 'PRG'
4339 AND prg.price_adjustment_id = a.price_adjustment_id
4340 AND p.price_adjustment_id = a.rltd_price_adj_id
4341 AND p.line_id = l_orig_line_rec.line_id
4342 AND l_orig_line_rec.item_type_code = 'SERVICE' AND l_orig_line_rec.SUBSCRIPTION_ENABLE_FLAG <> 'Y'
4343 AND ROWNUM <2;
4344
4345 EXCEPTION
4346 WHEN NO_DATA_FOUND THEN
4347 oe_debug_pub.ADD('prg does not exist',1);
4348 l_prg := 'N';
4349 END;
4350
4351 oe_debug_pub.ADD('l_prg is '||l_prg);
4352 IF l_prg = 'Y' THEN
4353
4354 oe_debug_pub.add('Do not cascade services', 2);
4355 x_return_status := FND_API.G_RET_STS_SUCCESS;
4356 RETURN;
4357
4358 END IF;
4359
4360 --bug 16848168 end
4361
4362 -- For bug 2372098, the cursor variable srv_children would be associated
4363 -- with different queries based on source_type_document_id.
4364
4365 -- * IMPORTANT *
4366 -- If the following SELECT statements are modified, then the definition of
4367 -- t_line_rec in OEXUREQS.pls also needs to be modified, else fetching
4368 -- records from the cursor variable srv_children into l_child would
4369 -- raise an exception
4370
4371 IF (l_orig_line_rec.source_document_type_id = 2 ) THEN
4372
4373 OPEN srv_children FOR
4374 SELECT l.header_id,
4375 l.line_id,
4376 l.shipment_number,
4377 l.line_number,
4378 l.option_number,
4379 l.component_number,
4380 l.service_txn_reason_code,
4381 l.service_txn_comments,
4382 l.service_duration,
4383 l.service_period,
4384 l.service_start_date,
4385 l.service_end_date,
4386 l.service_coterminate_flag,
4387 l.ordered_quantity
4388 FROM oe_order_lines l
4389 WHERE l.top_model_line_id = l_service_reference_line_id
4390 AND l.item_type_code = 'INCLUDED'
4391 AND exists (select null from mtl_system_items mtl where
4392 mtl.inventory_item_id = l.inventory_item_id and
4393 mtl.serviceable_product_flag = 'Y' and
4394 mtl.organization_id=OE_SYS_PARAMETERS.VALUE('MASTER_ORGANIZATION_ID') );
4395 ELSE
4396
4397 OPEN srv_children FOR
4398 SELECT l.header_id,
4399 l.line_id,
4400 l.shipment_number,
4401 l.line_number,
4402 l.option_number,
4403 l.component_number,
4404 l.service_txn_reason_code,
4405 l.service_txn_comments,
4406 l.service_duration,
4407 l.service_period,
4408 l.service_start_date,
4409 l.service_end_date,
4410 l.service_coterminate_flag,
4411 l.ordered_quantity
4412 FROM oe_order_lines l
4413 WHERE l.top_model_line_id = l_service_reference_line_id
4414 AND l.top_model_line_id <> l.line_id -- For bug 2938790
4415 AND l.item_type_code in ('INCLUDED','CLASS','OPTION', 'KIT') -- For bug 2447402
4416 AND exists (select null from mtl_system_items mtl where
4417 mtl.inventory_item_id = l.inventory_item_id and
4418 mtl.serviceable_product_flag = 'Y' and
4419 mtl.organization_id=OE_SYS_PARAMETERS.VALUE('MASTER_ORGANIZATION_ID') );
4420 END IF; /* source_type_doc_id = 2 */
4421 -- End 2372098
4422
4423 -- For bug 2372098
4424 -- FOR cannot be used on cursor variables, so adding the following
4425 -- loop to fetch the records.
4426 -- FOR l_child IN srv_children LOOP
4427
4428 LOOP
4429 FETCH srv_children INTO l_child;
4430 EXIT WHEN srv_children%NOTFOUND;
4431
4432 -- Bug 7717223
4433 -- Delete the G_CASCADE_OPTIONS_SERVICE delayed request logged for the option/included lines
4434 -- this is necessary when both G_INSERT_SERVICE and G_CASCADE_OPTIONS_SERVICE requests are logged in the same session
4435 -- Execution of both will result in duplicate service lines attached to included items
4436
4437 OE_Delayed_Requests_PVT.Delete_Request
4438 (p_entity_code => OE_GLOBALS.G_ENTITY_LINE
4439 ,p_entity_id => l_child.line_id
4440 ,p_request_Type => OE_GLOBALS.G_CASCADE_OPTIONS_SERVICE
4441 ,x_return_status => x_del_req_ret_status);
4442
4443 OE_DEBUG_PUB.ADD('x_del_req_ret_status :'||x_del_req_ret_status);
4444
4445 --End bug7717223
4446
4447 l_number := l_number + 1;
4448 l_line_tbl(l_number) := OE_ORDER_PUB.G_MISS_LINE_REC;
4449 l_line_tbl(l_number).service_reference_type_code := 'ORDER';
4450 l_line_tbl(l_number).service_reference_line_id := l_child.line_id;
4451 -- aksingh change it not right
4452 l_line_tbl(l_number).service_reference_system_id := l_child.line_id;
4453 l_line_tbl(l_number).service_txn_reason_code := l_child.service_txn_reason_code;
4454 l_line_tbl(l_number).service_txn_comments := l_child.service_txn_comments;
4455 l_line_tbl(l_number).service_duration := l_orig_line_rec.service_duration;
4456 l_line_tbl(l_number).service_period := l_orig_line_rec.service_period;
4457 l_line_tbl(l_number).service_start_date := l_orig_line_rec.service_start_date;
4458 l_line_tbl(l_number).service_end_date := l_orig_line_rec.service_end_date;
4459 l_line_tbl(l_number).service_coterminate_flag := l_orig_line_rec.service_coterminate_flag;
4460 -- sol_ord_er #16014165 start
4461 l_line_tbl(l_number).service_bill_option_code := l_orig_line_rec.service_bill_option_code;
4462 l_line_tbl(l_number).service_bill_profile_id := l_orig_line_rec.service_bill_profile_id;
4463 l_line_tbl(l_number).service_cov_template_id := l_orig_line_rec.service_cov_template_id;
4464 -- sol_ord_er #16014165 end
4465 l_line_tbl(l_number).ordered_quantity := l_child.ordered_quantity;
4466 l_line_tbl(l_number).order_quantity_uom := l_orig_line_rec.order_quantity_uom;
4467 l_line_tbl(l_number).item_identifier_type := 'INT';
4468 l_line_tbl(l_number).item_type_code := OE_GLOBALS.G_ITEM_SERVICE;
4469 l_Line_tbl(l_number).operation := OE_GLOBALS.G_OPR_CREATE;
4470 l_line_tbl(l_number).header_id := l_orig_line_rec.header_id;
4471 l_line_tbl(l_number).inventory_item_id := l_orig_line_rec.inventory_item_id;
4472 l_line_tbl(l_number).service_reference_line_id := l_child.line_id;
4473 --l_line_tbl(l_number).top_model_line_id := l_service_reference_line_id;
4474 --for bug 2545545
4475 l_line_tbl(l_number).context := l_orig_line_rec.context;
4476 l_line_tbl(l_number).attribute1 := l_orig_line_rec.attribute1;
4477 l_line_tbl(l_number).attribute2 := l_orig_line_rec.attribute2;
4478 l_line_tbl(l_number).attribute3 := l_orig_line_rec.attribute3;
4479 l_line_tbl(l_number).attribute4 := l_orig_line_rec.attribute4;
4480 l_line_tbl(l_number).attribute5 := l_orig_line_rec.attribute5;
4481 l_line_tbl(l_number).attribute6 := l_orig_line_rec.attribute6;
4482 l_line_tbl(l_number).attribute7 := l_orig_line_rec.attribute7;
4483 l_line_tbl(l_number).attribute8 := l_orig_line_rec.attribute8;
4484 l_line_tbl(l_number).attribute9 := l_orig_line_rec.attribute9;
4485 l_line_tbl(l_number).attribute10 := l_orig_line_rec.attribute10;
4486 l_line_tbl(l_number).attribute11 := l_orig_line_rec.attribute11;
4487 l_line_tbl(l_number).attribute12 := l_orig_line_rec.attribute12;
4488 l_line_tbl(l_number).attribute13 := l_orig_line_rec.attribute13;
4489 l_line_tbl(l_number).attribute14 := l_orig_line_rec.attribute14;
4490 l_line_tbl(l_number).attribute15 := l_orig_line_rec.attribute15;
4491 --end 2545545
4492 l_header_id := l_child.header_id;
4493 l_line_number := l_child.line_number;
4494 l_shipment_number := l_child.shipment_number;
4495 l_option_number := l_child.option_number;
4496 oe_debug_pub.add('l_number => ' || to_char(l_number),2);
4497 oe_debug_pub.add('l_child.header_id=> ' || to_char(l_child.header_id),2);
4498 -- oe_debug_pub.add('item_type_code => ' || to_char(l_child.item_type_code),2);
4499 oe_debug_pub.add('l_child.line_id=> ' || to_char(l_child.line_id),2);
4500 oe_debug_pub.add('l_child.shipment_number=> ' || to_char(l_child.shipment_number),2);
4501 oe_debug_pub.add('l_child.option_number=> ' || to_char(l_child.option_number),2);
4502 oe_debug_pub.add('l_child.component_number=> ' || to_char(l_child.component_number),2);
4503 oe_debug_pub.add('l_child.service_txn_reason_code=> ' || l_child.service_txn_reason_code,2);
4504 oe_debug_pub.add('l_orig_line_rec.service_duration => ' || l_orig_line_rec.service_duration,2);
4505 oe_debug_pub.add('l_orig_line_rec.service_period=> ' || l_orig_line_rec.service_period ,2);
4506 oe_debug_pub.add('l_orig_line_rec.service_start_date=> ' || l_orig_line_rec.service_start_date,2);
4507 oe_debug_pub.add('l_orig_line_rec.service_end_date=> ' ||l_orig_line_rec.service_end_date ,2);
4508 -- sol_ord_er #16014165
4509 IF l_debug_level > 0 THEN
4510 oe_debug_pub.add('l_orig_line_rec.service_bill_option_code=> ' ||l_orig_line_rec.service_bill_option_code ,2);
4511 oe_debug_pub.add('l_orig_line_rec.service_bill_profile_id=> ' ||l_orig_line_rec.service_bill_profile_id ,2);
4512 oe_debug_pub.add('l_orig_line_rec.service_cov_template_id=> ' ||l_orig_line_rec.service_cov_template_id ,2);
4513 End IF;
4514
4515 -- l_line_tbl(l_number).line_number := l_child.line_number;
4516 -- l_line_tbl(l_number).shipment_number := l_child.shipment_number;
4517 l_line_tbl(l_number).line_number := l_orig_line_rec.line_number; -- For bug 2924241
4518 l_line_tbl(l_number).shipment_number := l_orig_line_rec.shipment_number;
4519 l_line_tbl(l_number).option_number := l_child.option_number;
4520 l_line_tbl(l_number).component_number := l_child.component_number;
4521
4522 FOR l_srv_number IN srv_number LOOP
4523 oe_debug_pub.add('Inside l_srv_number loop ',2);
4524 l_line_tbl(l_number).service_number := l_srv_number.service_number + 1;
4525 END LOOP;
4526 END LOOP;
4527
4528 -- for bug 2372098
4529 IF ( srv_children%ISOPEN ) THEN
4530 CLOSE srv_children;
4531 END IF;
4532 -- end 2372098
4533
4534 END IF;
4535
4536 IF l_number > 0 THEN
4537 oe_debug_pub.add('SRV: Found options and included item lines', 1);
4538
4539 -- Set control flags.
4540 l_control_rec.controlled_operation := TRUE;
4541 l_control_rec.validate_entity := TRUE;
4542 l_control_rec.write_to_DB := TRUE;
4543
4544 l_control_rec.default_attributes := TRUE;
4545 l_control_rec.change_attributes := TRUE;
4546 l_control_rec.clear_dependents := TRUE;
4547 l_control_rec.process := FALSE;
4548
4549 -- Instruct API to retain its caches
4550
4551 l_control_rec.clear_api_cache := FALSE;
4552 l_control_rec.clear_api_requests := FALSE;
4553
4554 -- Call OE_Order_PVT.Process_order to insert lines
4555 -- Set recursion mode.
4556 -- OE_GLOBALS.G_RECURSION_MODE := 'Y';
4557
4558 OE_ORDER_PVT.Lines
4559 (P_validation_level => FND_API.G_VALID_LEVEL_FULL
4560 ,p_control_rec => l_control_rec
4561 ,p_x_line_tbl => l_line_tbl
4562 ,p_x_old_line_tbl => l_old_line_tbl
4563 ,x_return_status => l_return_status);
4564
4565 -- Reset recursion mode.
4566 -- OE_GLOBALS.G_RECURSION_MODE := 'N';
4567
4568 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4569 oe_debug_pub.add('Inside unexpected error ',2);
4570 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4571 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4572 oe_debug_pub.add('Inside error ',2);
4573 RAISE FND_API.G_EXC_ERROR;
4574 END IF;
4575
4576 --comment out for notification project
4577 /* OE_ORDER_PVT.Process_Requests_And_notify
4578 ( p_process_requests => FALSE
4579 ,p_notify => TRUE
4580 ,x_return_status => l_return_status
4581 ,p_line_tbl => l_line_tbl
4582 ,p_old_line_tbl => l_old_line_tbl);
4583
4584 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4585 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4586 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4587 RAISE FND_API.G_EXC_ERROR;
4588 END IF;
4589 */
4590 -- Clear Table
4591 l_line_tbl.DELETE;
4592 END IF; /* End inserting lines */
4593 OE_DEBUG_PUB.ADD('Exiting INSERT_SERVICE_FOR_OPTIONS',1);
4594
4595 EXCEPTION
4596
4597 WHEN FND_API.G_EXC_ERROR THEN
4598 oe_debug_pub.add('Inside exception exe error ',1);
4599 x_return_status := FND_API.G_RET_STS_ERROR;
4600
4601 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4602 oe_debug_pub.add('Inside exception unexp error ',1);
4603 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4604
4605 WHEN OTHERS THEN
4606
4607 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4608 oe_debug_pub.add('Inside exception other error ',1);
4609
4610 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4611 THEN
4612 OE_MSG_PUB.Add_Exc_Msg
4613 ( G_PKG_NAME
4614 , 'INSERT_SERVICE_FOR_OPTIONS'
4615 );
4616 END IF;
4617
4618 END INSERT_SERVICE_FOR_OPTIONS;
4619
4620
4621 /* lchen added procedure CASCADE_SERVICE_FOR_OPTIONS for bug 1761154 */
4622
4623 PROCEDURE CASCADE_SERVICE_FOR_OPTIONS
4624 (p_option_line_id IN NUMBER
4625 ,x_return_status OUT NOCOPY VARCHAR2
4626
4627 )
4628
4629 IS
4630
4631 l_number NUMBER := 0;
4632 l_api_name CONSTANT VARCHAR(30) := 'CASCADE_SERVICE_FOR_OPTIONS';
4633 l_control_rec OE_GLOBALS.Control_Rec_Type;
4634 l_return_status Varchar2(30);
4635 l_orig_line_rec OE_Order_PUB.Line_Rec_Type;
4636 --l_reference_line_rec OE_Order_Pub.Line_Rec_Type;
4637 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
4638 l_old_line_tbl OE_Order_PUB.Line_Tbl_Type;
4639 --l_line_id NUMBER;
4640 l_header_id NUMBER;
4641 l_line_number NUMBER;
4642 l_order_number NUMBER;
4643 l_shipment_number NUMBER;
4644 l_option_number NUMBER;
4645 l_component_number NUMBER; -- bug 2447402
4646 l_top_model_line_id NUMBER;
4647 l_prg_exist VARCHAR2(1) := 'N'; --bug16848168
4648
4649
4650 CURSOR srv_line IS
4651 SELECT l.header_id,
4652 l.line_id,
4653 l.service_txn_reason_code,
4654 l.service_txn_comments,
4655 l.service_duration,
4656 l.service_period,
4657 l.service_start_date,
4658 l.service_end_date,
4659 l.service_coterminate_flag,
4660 l.order_quantity_uom,
4661 l.inventory_item_id,
4662 l.subscription_enable_flag
4663 FROM oe_order_lines l
4664 where l.service_reference_line_id=l_top_model_line_id
4665 and l.item_type_code = 'SERVICE'
4666 and l.service_reference_type_code = 'ORDER';
4667
4668 CURSOR srv_number IS
4669 SELECT max(l.service_number) service_number
4670 FROM oe_order_lines l
4671 WHERE l.header_id = l_header_id
4672 AND l.line_number = l_line_number
4673 AND l.shipment_number = l_shipment_number
4674 AND nvl(l.option_number,0) = nvl(l_option_number,0)
4675 AND nvl(l.component_number,0) = nvl(l_component_number,0); --bug 2447402
4676 BEGIN
4677
4678 OE_DEBUG_PUB.ADD('Entering CASCADE_SERVICE_FOR_OPTIONS',1);
4679
4680 IF fnd_profile.value('ONT_CASCADE_SERVICE') = 'N' THEN
4681 /* 3128684 */
4682 oe_debug_pub.add('Do not cascade services', 2);
4683 x_return_status := FND_API.G_RET_STS_SUCCESS;
4684 RETURN;
4685 END IF;
4686 oe_debug_pub.add('Do cascade services', 2);
4687
4688 -- query the option line
4689 OE_Line_Util.query_row(p_line_id => p_option_line_id,
4690 x_line_rec => l_orig_line_rec);
4691
4692 SELECT /* MOAC_SQL_CHANGE */ h.order_number
4693 INTO l_order_number
4694 FROM oe_order_headers_all h, oe_order_lines l
4695 WHERE h.header_id = l.header_id
4696 AND h.header_id = l_orig_line_rec.header_id
4697 AND rownum = 1;
4698
4699
4700 l_top_model_line_id := l_orig_line_rec.top_model_line_id;
4701 oe_debug_pub.add('Top Model Line is' || l_top_model_line_id,2);
4702
4703
4704 FOR l_child IN srv_line LOOP
4705 --start bug 16848168
4706 --Checking if the service line is added by the PRG modifier or not.
4707 oe_debug_pub.add('line id is: ' || l_child.line_id,1);
4708 BEGIN
4709
4710 SELECT 'Y'
4711 INTO l_prg_exist
4712 FROM oe_price_adjustments prg, oe_price_adj_assocs a,
4713 oe_price_adjustments p
4714 WHERE prg.line_id = l_top_model_line_id
4715 AND prg.list_line_type_code = 'PRG'
4716 AND prg.price_adjustment_id = a.price_adjustment_id
4717 AND p.price_adjustment_id = a.rltd_price_adj_id
4718 AND p.line_id = l_child.line_id
4719 AND l_child.SUBSCRIPTION_ENABLE_FLAG <> 'Y'
4720 AND ROWNUM <2;
4721 EXCEPTION
4722 WHEN NO_DATA_FOUND THEN
4723 oe_debug_pub.ADD('prg does not exist',1);
4724 l_prg_exist := 'N';
4725 END;
4726 --end bug 16848168
4727 oe_debug_pub.add('prg_exist flag is: ' || l_prg_exist,1);
4728
4729 IF l_prg_exist = 'N' THEN --bug 16848168
4730 l_number := l_number + 1;
4731 l_line_tbl(l_number) := OE_ORDER_PUB.G_MISS_LINE_REC;
4732 l_line_tbl(l_number).service_reference_type_code := 'ORDER';
4733 l_line_tbl(l_number).service_reference_line_id := l_orig_line_rec.line_id;
4734 l_line_tbl(l_number).service_reference_system_id := l_orig_line_rec.line_id;
4735 l_line_tbl(l_number).service_txn_reason_code := l_orig_line_rec.service_txn_reason_code;
4736 l_line_tbl(l_number).service_txn_comments := l_orig_line_rec.service_txn_comments;
4737 l_line_tbl(l_number).service_duration := l_child.service_duration;
4738 l_line_tbl(l_number).service_period := l_child.service_period;
4739 l_line_tbl(l_number).service_start_date := l_child.service_start_date;
4740 l_line_tbl(l_number).service_end_date := l_child.service_end_date;
4741 l_line_tbl(l_number).service_coterminate_flag := l_child.service_coterminate_flag;
4742 l_line_tbl(l_number).ordered_quantity := l_orig_line_rec.ordered_quantity;
4743 l_line_tbl(l_number).order_quantity_uom := l_child.order_quantity_uom;
4744 l_line_tbl(l_number).item_identifier_type := 'INT';
4745 l_line_tbl(l_number).item_type_code := OE_GLOBALS.G_ITEM_SERVICE;
4746 l_Line_tbl(l_number).operation := OE_GLOBALS.G_OPR_CREATE;
4747 l_line_tbl(l_number).header_id := l_child.header_id;
4748 l_line_tbl(l_number).inventory_item_id := l_child.inventory_item_id;
4749 --l_line_tbl(l_number).top_model_line_id := l_top_model_line_id;
4750 l_header_id := l_orig_line_rec.header_id;
4751 l_line_number := l_orig_line_rec.line_number;
4752 l_shipment_number := l_orig_line_rec.shipment_number;
4753 l_option_number := l_orig_line_rec.option_number;
4754 l_component_number := l_orig_line_rec.component_number; --bug 2447402
4755
4756 oe_debug_pub.add('l_number => ' || to_char(l_number),2);
4757 oe_debug_pub.add('l_orig_line_rec.header_id=> ' || to_char(l_orig_line_rec.header_id),2);
4758 -- oe_debug_pub.add('item_type_code => ' || to_char(l_orig_line_rec.item_type_code),2);
4759 oe_debug_pub.add('l_orig_line_rec.line_id=> ' || to_char(l_orig_line_rec.line_id),2);
4760 oe_debug_pub.add('l_orig_line_rec.shipment_number=> ' || to_char(l_orig_line_rec.shipment_number),2);
4761 oe_debug_pub.add('l_orig_line_rec.option_number=> ' || to_char(l_orig_line_rec.option_number),2);
4762 oe_debug_pub.add('l_orig_line_rec.service_txn_reason_code=> ' || l_orig_line_rec.service_txn_reason_code,2);
4763 oe_debug_pub.add('l_child.service_duration => ' || l_child.service_duration,2);
4764 oe_debug_pub.add('l_child.service_period=> ' || l_child.service_period ,2);
4765 oe_debug_pub.add('l_child.service_start_date=> ' || l_child.service_start_date,2);
4766 oe_debug_pub.add('l_child.service_end_date=> ' ||l_child.service_end_date ,2);
4767
4768 l_line_tbl(l_number).shipment_number := l_orig_line_rec.shipment_number;
4769 l_line_tbl(l_number).option_number := l_orig_line_rec.option_number;
4770 l_line_tbl(l_number).line_number := l_orig_line_rec.line_number;
4771 l_line_tbl(l_number).component_number := l_orig_line_rec.component_number; --bug 2447402
4772
4773 FOR l_srv_number IN srv_number LOOP
4774 oe_debug_pub.add('Inside l_srv_number loop ',2);
4775 l_line_tbl(l_number).service_number := l_srv_number.service_number + 1;
4776 END LOOP;
4777
4778 END IF;
4779
4780 END LOOP;
4781
4782
4783 IF l_number > 0 THEN
4784 oe_debug_pub.add('Inside cascade_service_for_options, Found top model service and options lines', 1);
4785
4786 -- Set control flags.
4787 l_control_rec.controlled_operation := TRUE;
4788 l_control_rec.validate_entity := TRUE;
4789 l_control_rec.write_to_DB := TRUE;
4790
4791 l_control_rec.default_attributes := TRUE;
4792 l_control_rec.change_attributes := TRUE;
4793 l_control_rec.clear_dependents := TRUE;
4794 l_control_rec.process := FALSE;
4795
4796 -- Instruct API to retain its caches
4797
4798 l_control_rec.clear_api_cache := FALSE;
4799 l_control_rec.clear_api_requests := FALSE;
4800
4801 -- Call OE_Order_PVT.Process_order to insert lines
4802 -- Set recursion mode.
4803 -- OE_GLOBALS.G_RECURSION_MODE := 'Y';
4804
4805 OE_ORDER_PVT.Lines
4806 (P_validation_level => FND_API.G_VALID_LEVEL_FULL
4807 ,p_control_rec => l_control_rec
4808 ,p_x_line_tbl => l_line_tbl
4809 ,p_x_old_line_tbl => l_old_line_tbl
4810 ,x_return_status => l_return_status);
4811
4812 -- Reset recursion mode.
4813 -- OE_GLOBALS.G_RECURSION_MODE := 'N';
4814
4815 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4816 oe_debug_pub.add('Inside unexpected error ',2);
4817 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4818 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4819 oe_debug_pub.add('Inside error ',2);
4820 RAISE FND_API.G_EXC_ERROR;
4821 END IF;
4822
4823 --comment out for notification project
4824 /* OE_ORDER_PVT.Process_Requests_And_notify
4825 ( p_process_requests => FALSE
4826 ,p_notify => TRUE
4827 ,x_return_status => l_return_status
4828 ,p_line_tbl => l_line_tbl
4829 ,p_old_line_tbl => l_old_line_tbl);
4830
4831 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4832 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4833 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4834 RAISE FND_API.G_EXC_ERROR;
4835 END IF;
4836 */
4837 -- Clear Table
4838 l_line_tbl.DELETE;
4839 END IF; /* End inserting lines */
4840 OE_DEBUG_PUB.ADD('Exiting CASCADE_SERVICE_FOR_OPTIONS',1);
4841
4842 EXCEPTION
4843
4844 WHEN FND_API.G_EXC_ERROR THEN
4845 oe_debug_pub.add('Inside exception exe error ',1);
4846 x_return_status := FND_API.G_RET_STS_ERROR;
4847
4848 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4849 oe_debug_pub.add('Inside exception unexp error ',1);
4850 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4851
4852 WHEN OTHERS THEN
4853
4854 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4855 oe_debug_pub.add('Inside exception other error ',1);
4856
4857 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4858 THEN
4859 OE_MSG_PUB.Add_Exc_Msg
4860 ( G_PKG_NAME
4861 , 'CASCADE_SERVICE_FOR_OPTIONS'
4862 );
4863 END IF;
4864
4865 END CASCADE_SERVICE_FOR_OPTIONS;
4866
4867
4868 PROCEDURE Apply_Automatic_Attachments
4869 ( p_entity_code IN VARCHAR2
4870 , p_entity_id IN NUMBER
4871 , p_is_user_action IN VARCHAR2
4872 , x_return_status OUT NOCOPY VARCHAR2
4873
4874 )
4875 IS
4876 l_attachment_count NUMBER;
4877 l_msg_count NUMBER;
4878 l_msg_data VARCHAR2(2000);
4879 BEGIN
4880
4881 OE_DEBUG_PUB.Add('Enter OE_DELAYED_REQUESTS_UTIL.Apply_Automatic_Attachments', 0.5); --debug level changed to 0.5 for bug 13435459
4882
4883 x_return_status := FND_API.G_RET_STS_SUCCESS;
4884
4885 OE_Atchmt_Util.Apply_Automatic_Attachments
4886 ( p_entity_code => p_entity_code
4887 , p_entity_id => p_entity_id
4888 , p_is_user_action => p_is_user_action
4889 , x_attachment_count => l_attachment_count
4890 , x_return_status => x_return_status
4891 , x_msg_count => l_msg_count
4892 , x_msg_data => l_msg_data
4893 );
4894 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4895 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4896 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
4897 RAISE FND_API.G_EXC_ERROR;
4898 END IF;
4899
4900 OE_DEBUG_PUB.Add('Exit OE_DELAYED_REQUESTS_UTIL.Apply_Automatic_Attachments', 0.5); --debug level changed to 0.5 for bug 13435459
4901
4902 EXCEPTION
4903 WHEN FND_API.G_EXC_ERROR THEN
4904 x_return_status := FND_API.G_RET_STS_ERROR;
4905 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4906 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4907 WHEN OTHERS THEN
4908 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4909 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4910 THEN
4911 OE_MSG_PUB.Add_Exc_Msg
4912 ( G_PKG_NAME
4913 , 'Apply_Automatic_Attachments'
4914 );
4915 END IF;
4916 END Apply_Automatic_Attachments;
4917
4918 PROCEDURE Copy_Attachments
4919 ( p_entity_code IN VARCHAR2
4920 , p_from_entity_id IN NUMBER
4921 , p_to_entity_id IN NUMBER
4922 , p_manual_attachments_only IN VARCHAR2
4923 , x_return_status OUT NOCOPY VARCHAR2
4924
4925 )
4926 IS
4927 BEGIN
4928
4929 OE_DEBUG_PUB.Add('Enter OE_DELAYED_REQUESTS_UTIL.Copy_Attachments, manual only'||
4930 p_manual_attachments_only, 0.5); --debug level changed to 0.5 for bug 13435459
4931
4932 x_return_status := FND_API.G_RET_STS_SUCCESS;
4933
4934 OE_Atchmt_Util.Copy_Attachments
4935 ( p_entity_code => p_entity_code
4936 , p_from_entity_id => p_from_entity_id
4937 , p_to_entity_id => p_to_entity_id
4938 , p_manual_attachments_only => NVL(p_manual_attachments_only,'N')
4939 , x_return_status => x_return_status
4940 );
4941 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4942 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4943 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
4944 RAISE FND_API.G_EXC_ERROR;
4945 END IF;
4946
4947 OE_DEBUG_PUB.Add('Exit OE_DELAYED_REQUESTS_UTIL.Copy_Attachments', 0.5); --debug level changed to 0.5 for bug 13435459
4948
4949 EXCEPTION
4950 WHEN FND_API.G_EXC_ERROR THEN
4951 x_return_status := FND_API.G_RET_STS_ERROR;
4952 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4953 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4954 WHEN OTHERS THEN
4955 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4956 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4957 THEN
4958 OE_MSG_PUB.Add_Exc_Msg
4959 ( G_PKG_NAME
4960 , 'Copy_Attachments'
4961 );
4962 END IF;
4963 END Copy_Attachments;
4964 /*-------------------------------------------------------------------
4965 Procedure: Schedule_Line
4966 Description: This procedure will be called when the delayed request
4967 SCHEDULE_LINE is logged. This delayed request is logged
4968 when new lines are inserted to a SCHEDULE SET. A set being
4969 a user defined ship or arrival set, or a system defined
4970 ATO or SMC PTO model. When multiple lines are inserted
4971 to the same set, this procedure is called once for all the
4972 lines of the set.
4973 -------------------------------------------------------------------*/
4974 Procedure Schedule_Line
4975 ( p_sch_set_tbl IN OE_ORDER_PUB.request_tbl_type
4976 , x_return_status OUT NOCOPY VARCHAR2)
4977
4978 IS
4979 l_ship_set_id NUMBER := null;
4980 l_arrival_set_id NUMBER := null;
4981 l_request_rec OE_Order_PUB.request_rec_type;
4982 l_line_rec OE_ORDER_PUB.line_rec_type;
4983 l_old_line_rec OE_ORDER_PUB.line_rec_type;
4984 l_out_line_rec OE_ORDER_PUB.line_rec_type;
4985 l_atp_tbl OE_ATP.atp_tbl_type;
4986 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
4987 l_group_req_rec OE_GRP_SCH_UTIL.Sch_Group_Rec_Type;
4988 l_group_sch_required BOOLEAN := TRUE;
4989 BEGIN
4990
4991 oe_debug_pub.add('Entering OE_Delayed_Requests_UTIL.Schedule_Line',1);
4992
4993 OE_ORDER_SCH_UTIL.OESCH_PERFORM_GRP_SCHEDULING := 'N';
4994
4995 FOR I in 1..p_sch_set_tbl.count LOOP
4996
4997 l_request_rec := p_sch_set_tbl(I);
4998 -- Assiging miss rec.
4999 l_line_rec := OE_ORDER_PUB.G_MISS_LINE_REC;
5000
5001 OE_LINE_UTIL.Lock_Row(p_line_id => l_request_rec.entity_id,
5002 p_x_line_rec => l_line_rec,
5003 x_return_status => l_return_status);
5004
5005 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5006 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5007 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5008 RAISE FND_API.G_EXC_ERROR;
5009 END IF;
5010
5011 l_old_line_rec := l_line_rec;
5012
5013 l_old_line_rec.schedule_ship_date := null;
5014 l_old_line_rec.schedule_arrival_date:= null;
5015
5016 /* Start Audit Trail */
5017 l_line_rec.change_reason := 'SYSTEM';
5018 /* End Audit Trail */
5019
5020 l_line_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
5021
5022 IF p_sch_set_tbl(I).request_type = OE_GLOBALS.G_SCHEDULE_LINE THEN
5023 l_line_rec.schedule_action_code :=
5024 OE_ORDER_SCH_UTIL.OESCH_ACT_SCHEDULE;
5025 l_old_line_rec.ship_set_id := l_request_rec.param9;
5026 l_old_line_rec.arrival_set_id := l_request_rec.param10;
5027 ELSE
5028
5029 l_old_line_rec.request_date := l_request_rec.date_param1;
5030 l_old_line_rec.schedule_ship_date := l_request_rec.date_param2;
5031 l_old_line_rec.schedule_arrival_date := l_request_rec.date_param3;
5032 l_old_line_rec.ship_from_org_id := l_request_rec.param7;
5033 l_old_line_rec.ship_to_org_id := l_request_rec.param8;
5034 l_old_line_rec.ship_set_id := l_request_rec.param9;
5035 l_old_line_rec.arrival_set_id := l_request_rec.param10;
5036 END IF;
5037
5038 IF (l_line_rec.ato_line_id is not null and
5039 NOT (l_line_rec.ato_line_id = l_line_rec.line_id and
5040 l_line_rec.item_type_code IN (OE_GLOBALS.G_ITEM_STANDARD,
5041 OE_GLOBALS.G_ITEM_OPTION,
5042 OE_GLOBALS.G_ITEM_INCLUDED))) OR --9775352
5043 nvl(l_line_rec.ship_model_complete_flag,'N') = 'Y'
5044 THEN
5045 IF l_request_rec.param3 =
5046 OE_ORDER_SCH_UTIL.OESCH_ENTITY_ARRIVAL_SET OR
5047 l_request_rec.param3 =
5048 OE_ORDER_SCH_UTIL.OESCH_ENTITY_SHIP_SET THEN
5049
5050 IF (l_line_rec.line_id = l_line_rec.ato_line_id OR
5051 l_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL)
5052 THEN
5053 -- ATO model or SMC Model
5054 l_group_sch_required := TRUE;
5055 ELSE
5056 -- The ato or smc pto line is being inserted into a ship
5057 -- or arrival set. Check to see if it is the first line
5058 -- to go into the set. If it is, then we will need to
5059 -- schedule the whole ATO model.
5060 BEGIN
5061 SELECT ship_set_id,arrival_set_id
5062 INTO l_ship_set_id,l_arrival_set_id
5063 FROM oe_order_lines_all
5064 WHERE line_id = l_line_rec.ato_line_id;
5065 EXCEPTION
5066 WHEN OTHERS THEN
5067 l_ship_set_id := null;
5068 l_arrival_set_id := null;
5069 END;
5070
5071 IF l_request_rec.param3 =
5072 OE_ORDER_SCH_UTIL.OESCH_ENTITY_SHIP_SET
5073 AND l_ship_set_id = to_number(l_request_rec.param1)
5074 THEN
5075 l_group_sch_required := FALSE;
5076 ELSIF l_request_rec.param3 =
5077 OE_ORDER_SCH_UTIL.OESCH_ENTITY_ARRIVAL_SET
5078 AND l_arrival_set_id = to_number(l_request_rec.param1)
5079 THEN
5080 l_group_sch_required := FALSE;
5081 ELSE
5082 l_group_sch_required := TRUE;
5083 END IF;
5084 END IF;
5085
5086 ELSE
5087 -- Line being inserted to an schedule ATO model
5088 l_group_sch_required := FALSE;
5089 END IF;
5090
5091 ELSE
5092 -- Line is not an ATO model or option
5093 l_group_sch_required := FALSE;
5094 END IF;
5095
5096 IF l_group_sch_required THEN
5097
5098 -- If the line being scheduled is a ATO model, or a SMC PTO, we
5099 -- need to call group scheduling API.
5100
5101 OE_ORDER_SCH_UTIL.Create_Group_Request
5102 ( p_line_rec => l_line_rec
5103 , p_old_line_rec => l_old_line_rec
5104 , x_group_req_rec => l_group_req_rec
5105 , x_return_status => l_return_status
5106 );
5107
5108 l_group_req_rec.old_ship_set_number := l_request_rec.param9;
5109 l_group_req_rec.old_arrival_set_number := l_request_rec.param10;
5110
5111 -- Set the Entity as ATO or SMC and not ship set.
5112 IF l_line_rec.ato_line_id is not null AND
5113 NOT (l_line_rec.ato_line_id = l_line_rec.line_id AND
5114 l_line_rec.item_type_code IN (OE_GLOBALS.G_ITEM_STANDARD,
5115 OE_GLOBALS.G_ITEM_OPTION,
5116 OE_GLOBALS.G_ITEM_INCLUDED)) THEN --9775352
5117
5118 l_group_req_rec.entity_type :=
5119 OE_ORDER_SCH_UTIL.OESCH_ENTITY_ATO_CONFIG;
5120 l_group_req_rec.ship_set_number := l_line_rec.ato_line_id;
5121 ELSE
5122
5123 l_group_req_rec.entity_type :=
5124 OE_ORDER_SCH_UTIL.OESCH_ENTITY_SMC;
5125 l_group_req_rec.ship_set_number := l_line_rec.top_model_line_id;
5126 END IF;
5127
5128 oe_debug_pub.add('****Printing Group Request Attributes****',2);
5129 oe_debug_pub.add('Entity :' || l_group_req_rec.entity_type,2);
5130 oe_debug_pub.add('Header Id :' || l_group_req_rec.header_id,2);
5131 oe_debug_pub.add('Line Id :' || l_group_req_rec.line_id,2);
5132 oe_debug_pub.add('Action :' || l_group_req_rec.action,2);
5133 oe_debug_pub.add('Warehouse :' || l_group_req_rec.ship_from_org_id,2);
5134 oe_debug_pub.add('Ship to :' || l_group_req_rec.ship_to_org_id,2);
5135 oe_debug_pub.add('Sh Set# :' || l_group_req_rec.ship_set_number,2);
5136 oe_debug_pub.add('Ar Set# :' || l_group_req_rec.arrival_set_number,2);
5137 oe_debug_pub.add('Ship Date :' || l_group_req_rec.schedule_ship_date,2);
5138 oe_debug_pub.add('Arr Date :' || l_group_req_rec.schedule_arrival_date,2);
5139 oe_debug_pub.add('*******************************************',2);
5140
5141 oe_debug_pub.add('Calling Grp Schedule : ',2);
5142 OE_GRP_SCH_UTIL.Group_Schedule
5143 (p_group_req_rec => l_group_req_rec
5144 ,x_atp_tbl => l_atp_tbl
5145 ,x_return_status => l_return_status);
5146
5147 oe_debug_pub.add('After Calling Grp Schedule : || l_return_status',2);
5148
5149 oe_debug_pub.add('Setting G_CASCADING_REQUEST_LOGGED to TRUE',2);
5150
5151 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
5152 OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
5153 END IF;
5154
5155 ELSE
5156
5157 oe_debug_pub.add('Sch_Line for line : '|| l_line_rec.line_id,2);
5158
5159 oe_debug_pub.add('Sch_Line for line : '|| l_line_rec.line_id,2);
5160
5161 -- We are doing this to retain the copy of l_line_rec.
5162 l_out_line_rec := l_line_rec;
5163
5164 OE_ORDER_SCH_UTIL.Schedule_line
5165 ( p_x_line_rec => l_out_line_rec
5166 , p_old_line_rec => l_old_line_rec
5167 , p_write_to_db => FND_API.G_TRUE
5168 , x_atp_tbl => l_atp_tbl
5169 , x_return_status => l_return_status);
5170
5171
5172 oe_debug_pub.add('After Calling Sch_Line : '|| l_return_status,2);
5173
5174 END IF;
5175
5176 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
5177
5178 oe_debug_pub.add('Line Id error out nocopy : ' || l_line_rec.line_id,2);
5179
5180
5181 IF l_request_rec.param3 =
5182 OE_ORDER_SCH_UTIL.OESCH_ENTITY_ARRIVAL_SET OR
5183 l_request_rec.param3 =
5184 OE_ORDER_SCH_UTIL.OESCH_ENTITY_SHIP_SET THEN
5185
5186 -- Could not schedule the line on the set date. Let's schedule
5187 -- the whole set to see if we get another date got the whole
5188 -- set.
5189
5190 IF fnd_profile.value('ONT_AUTO_PUSH_GRP_DATE') = 'Y' THEN
5191
5192 oe_debug_pub.add('Auto Push Group Date is Yes',2);
5193
5194 -- Added this stmt to fix big 1899651.
5195 l_line_rec.schedule_action_code :=
5196 OE_ORDER_SCH_UTIL.OESCH_ACT_RESCHEDULE;
5197
5198 OE_ORDER_SCH_UTIL.Create_Group_Request
5199 ( p_line_rec => l_line_rec
5200 , p_old_line_rec => l_old_line_rec
5201 , x_group_req_rec => l_group_req_rec
5202 , x_return_status => l_return_status
5203 );
5204
5205 oe_debug_pub.add('****Printing Group Request Attributes****',2);
5206 oe_debug_pub.add('Entity :' ||
5207 l_group_req_rec.entity_type,20);
5208 oe_debug_pub.add('Header Id :' ||
5209 l_group_req_rec.header_id,2);
5210 oe_debug_pub.add('Line Id :' ||
5211 l_group_req_rec.line_id,2);
5212 oe_debug_pub.add('Action :' ||
5213 l_group_req_rec.action,2);
5214 oe_debug_pub.add('Warehouse :' ||
5215 l_group_req_rec.ship_from_org_id,2);
5216 oe_debug_pub.add('Ship to :' ||
5217 l_group_req_rec.ship_to_org_id,2);
5218 oe_debug_pub.add('Sh Set# :' ||
5219 l_group_req_rec.ship_set_number,2);
5220 oe_debug_pub.add('Ar Set# :' ||
5221 l_group_req_rec.arrival_set_number,2);
5222 oe_debug_pub.add('Ship Date :' ||
5223 l_group_req_rec.schedule_ship_date,2);
5224 oe_debug_pub.add('Arr Date :' ||
5225 l_group_req_rec.schedule_arrival_date,2);
5226 oe_debug_pub.add('****************************************',2);
5227
5228 OE_ORDER_SCH_UTIL.OESCH_PERFORM_GRP_SCHEDULING := 'Y';
5229
5230 oe_debug_pub.add('Calling Grp Schedule : ',2);
5231
5232 OE_GRP_SCH_UTIL.Group_Schedule
5233 (p_group_req_rec => l_group_req_rec
5234 ,x_atp_tbl => l_atp_tbl
5235 ,x_return_status => l_return_status);
5236
5237 oe_debug_pub.add('After Calling Grp Schedule : ||
5238 l_return_status',1);
5239
5240 oe_debug_pub.add('Stng G_CASCADING_REQUEST_LOGGED to TRUE',2);
5241
5242 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
5243 OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
5244 END IF;
5245 END IF; /* If Auto Push Group Date is Yes */
5246
5247 -- Scheduling Failed. If the line belongs to a Ship Set or Arrival
5248 -- Set, then just clear out the scheduling attributes and return a
5249 -- message that the line schedule failed. We will return a success
5250 -- since we do not want to fail the line insert due to this.
5251
5252 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
5253
5254 fnd_message.set_name('ONT','OE_SCH_SET_INS_FAILED');
5255 OE_MSG_PUB.Add;
5256
5257 IF p_sch_set_tbl(I).request_type = OE_GLOBALS.G_SCHEDULE_LINE
5258 THEN
5259
5260 UPDATE OE_ORDER_LINES_ALL
5261 SET
5262 (SCHEDULE_SHIP_DATE,
5263 SCHEDULE_ARRIVAL_DATE,
5264 SHIP_FROM_ORG_ID,
5265 SHIP_SET_ID,
5266 ARRIVAL_SET_ID) =
5267 (SELECT null,
5268 null,
5269 decode(re_source_flag,'Y',ship_from_org_id,null),
5270 null,
5271 null
5272 FROM OE_ORDER_LINES_ALL
5273 WHERE line_id=l_line_rec.line_id)
5274 WHERE line_id = l_line_rec.line_id;
5275
5276 ELSE
5277 UPDATE OE_ORDER_LINES_ALL
5278 SET
5279 SCHEDULE_SHIP_DATE = l_old_line_rec.schedule_ship_date,
5280 SCHEDULE_ARRIVAL_DATE = l_old_line_rec.schedule_arrival_date,
5281 SHIP_FROM_ORG_ID = l_old_line_rec.ship_from_org_id,
5282 SHIP_SET_ID = null,
5283 ARRIVAL_SET_ID = null
5284 WHERE line_id = l_line_rec.line_id;
5285 END IF;
5286
5287 IF l_line_rec.ship_model_complete_flag = 'Y'
5288 OR (l_line_rec.ato_line_id is not null
5289 AND NOT (l_line_rec.ato_line_id = l_line_rec.line_id AND
5290 l_line_rec.item_type_code IN
5291 (OE_GLOBALS.G_ITEM_STANDARD,
5292 OE_GLOBALS.G_ITEM_OPTION,
5293 OE_GLOBALS.G_ITEM_INCLUDED))) --9775352
5294 THEN
5295 -- Line is part of ato model or smc. Cannot insert a
5296 -- line without scheduling the same when parent is
5297 -- scheduled.
5298
5299 -- Bug 2185769
5300 oe_debug_pub.add('Before failing the line',1);
5301 fnd_message.set_name('ONT','OE_SCH_SET_INS_FAILED');
5302 OE_MSG_PUB.Add;
5303
5304 END IF;
5305
5306 x_return_status := FND_API.G_RET_STS_SUCCESS;
5307 END IF; /* l_return_status = error */
5308
5309 ELSE
5310
5311 -- Scheduling Failed. If the line belongs to a ATO Model or SMC
5312 -- PTO, then return an error, since the option cannot be inserted
5313 -- to a scheduled ATO or SMC PTO if it cannot be scheduled on
5314 -- the same date as that of the model.
5315
5316 fnd_message.set_name('ONT','OE_SCH_SET_INS_FAILED');
5317 OE_MSG_PUB.Add;
5318
5319 RAISE FND_API.G_EXC_ERROR;
5320
5321
5322 END IF;
5323 END IF; /* If g_ret_status is error */
5324
5325 END LOOP;
5326 OE_ORDER_SCH_UTIL.OESCH_PERFORM_GRP_SCHEDULING := 'Y';
5327
5328 oe_debug_pub.add('Exiting OE_Delayed_Requests_UTIL.Schedule_Line');
5329 EXCEPTION
5330
5331 WHEN FND_API.G_EXC_ERROR THEN
5332 x_return_status := FND_API.G_RET_STS_ERROR;
5333
5334 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5335
5336 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5337 THEN
5338 OE_MSG_PUB.Add_Exc_Msg
5339 ( G_PKG_NAME
5340 , 'Schedule_Line'
5341 );
5342 END IF;
5343
5344
5345 WHEN OTHERS THEN
5346
5347
5348 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5349 THEN
5350 OE_MSG_PUB.Add_Exc_Msg
5351 ( G_PKG_NAME
5352 , 'Schedule_Line'
5353 );
5354 END IF;
5355
5356 END Schedule_Line;
5357
5358 PROCEDURE Process_Tax(
5359 p_entity_id_tbl IN OE_Delayed_Requests_PVT.Entity_Id_Tbl_Type ,
5360 x_return_status OUT NOCOPY VARCHAR2)
5361 IS
5362 l_return_status VARCHAR2(30) := FND_API.G_RET_STS_SUCCESS;
5363 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5364 v_start NUMBER;
5365 v_end NUMBER;
5366 l_entity_id_tbl OE_Delayed_Requests_PVT.Entity_Id_Tbl_Type ;
5367 l_tax_rec_out_tbl OM_TAX_UTIL.om_tax_out_tab_type;
5368 l_requesting_entity_id NUMBER; --TaxER
5369 l_request_ind NUMBER;
5370 l_call_credit_checking VARCHAR2(30);
5371 l_tax_on_charge NUMBER;
5372 l_total_tax NUMBER;
5373 l_old_total_tax NUMBER;
5374 l_line_rec OE_Order_PUB.Line_Rec_Type;
5375 l_header_rec OE_Order_PUB.Header_Rec_Type;
5376 l_old_line_tbl oe_order_pub.line_tbl_type; -- Bug 8825061
5377 l_line_tbl oe_order_pub.line_tbl_type; -- Bug 8825061
5378 l_hold_result VARCHAR2(30);
5379 l_msg_count NUMBER := 0;
5380 l_msg_data VARCHAR2(2000);
5381 l_Line_Adj_rec OE_Order_PUB.Line_Adj_Rec_Type;
5382 l_l_Line_Adj_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
5383 l_l_header_adj_tbl OE_Order_PUB.header_Adj_Tbl_Type;
5384 l_return NUMBER;
5385 l_tax_index NUMBER := 0;
5386 l_tax_count NUMBER := 0;
5387 l_index NUMBER := 0;
5388 l_global_index NUMBER; -- Bug 8825061
5389 l_payment_type_code VARCHAR2(30);
5390 l_match_flag VARCHAR2(1);
5391 l_tax_rate_id NUMBER;
5392 l_price_adjustment_id NUMBER;
5393 l_Adj_rec OE_Order_PUB.Line_Adj_Rec_Type;
5394 l_h_Adj_rec OE_Order_PUB.Header_Adj_Rec_Type; --TaxER
5395 BEGIN
5396 IF l_debug_level > 0 THEN
5397 v_start := DBMS_UTILITY.GET_TIME;
5398 oe_debug_pub.add('Entering Process_Tax ',0.5); --debug level changed to 0.5 for bug 13435459
5399 END IF;
5400 x_return_status := l_return_status;
5401 l_entity_id_tbl := p_entity_id_tbl;
5402 l_tax_rec_out_tbl.delete;
5403 /* initializing the l_tax_rec_out_tbl */
5404 /* calling tax_line procedure to calculate tax */
5405 IF l_debug_level > 0 THEN
5406 oe_debug_pub.add('Calling OM_TAX_UTIL.TAX_LINE',1);
5407 END IF;
5408
5409 OM_TAX_UTIL.TAX_LINE( p_entity_id_tbl =>l_entity_id_tbl, x_tax_out_tbl => l_tax_rec_out_tbl, x_return_status => l_return_status);
5410 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5411 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5412 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5413 RAISE FND_API.G_EXC_ERROR;
5414 END IF;
5415 IF l_debug_level > 0 THEN
5416 oe_debug_pub.add('After Successfully calculating Tax',2);
5417 oe_debug_pub.add('return status : ' || l_return_status, 1);
5418 END IF;
5419
5420 FOR i IN 1..p_entity_id_tbl.count
5421 LOOP
5422 l_requesting_entity_id := p_entity_id_tbl(i).entity_id; --TaxER
5423 l_request_ind := p_entity_id_tbl(i).request_ind; --TaxER
5424 IF l_debug_level > 0 THEN
5425 oe_debug_pub.add( 'value count '|| OE_Delayed_Requests_PVT.G_Delayed_Requests.count);
5426 END IF;
5427 /* Bug # 3337661: Corrected IF stmt by using OE_GLOBALS.G_TAX_LINE */
5428 -- Front Ported for bug 3397062
5429 IF OE_Delayed_Requests_PVT.G_Delayed_Requests.exists(l_request_ind) AND OE_Delayed_Requests_PVT.G_Delayed_Requests(l_request_ind).request_type = OE_GLOBALS.G_TAX_LINE THEN
5430 l_call_credit_checking := OE_Delayed_Requests_PVT.G_Delayed_Requests(l_request_ind).param1;
5431 END IF;
5432 IF l_debug_level > 0 THEN
5433 oe_debug_pub.add('OEXUREQB: call_credit_checking is: '||l_call_credit_checking,1);
5434 END IF;
5435 l_tax_on_charge := 0;
5436 l_total_tax := 0;
5437
5438 IF p_entity_id_tbl(i).requesting_entity_code = 'LINE' THEN
5439 /* Calculating total new tax value from l_tax_rec_out_tbl record*/
5440 FOR j IN 1..l_tax_rec_out_tbl.count
5441 LOOP
5442 IF (l_tax_rec_out_tbl(j).line_id = p_entity_id_tbl(i).entity_id
5443 AND nvl( l_tax_rec_out_tbl(j).amount_includes_tax_flag, 'N' ) <> 'Y') --added for bug 12895421
5444 THEN
5445 IF l_tax_rec_out_tbl(j).trx_level_type = 'FREIGHT_CHARGE' THEN
5446 l_tax_on_charge := l_tax_on_charge + l_tax_rec_out_tbl(j).tax_amount;
5447 END IF;
5448 l_total_tax:= l_total_tax + l_tax_rec_out_tbl(j).tax_amount ;
5449 END IF;
5450 END LOOP;
5451 /* getting total tax value from oe_order_lines_all table for line id*/
5452 SELECT TAX_VALUE
5453 INTO l_old_total_tax
5454 FROM oe_order_lines_all
5455 WHERE line_id = p_entity_id_tbl(i).entity_id;
5456
5457 l_line_rec := OE_line_UTIL.Query_Row(p_line_id=> p_entity_id_tbl(i).entity_id );
5458
5459
5460 IF ( (l_old_total_tax IS NOT NULL AND l_total_tax IS NOT NULL AND l_old_total_tax = l_total_tax) OR (l_old_total_tax IS NULL AND l_total_tax IS NULL ) ) THEN
5461 NULL;
5462 ELSE
5463 IF l_debug_level > 0 THEN
5464 oe_debug_pub.add('Updateing tax value from '||TO_CHAR(l_old_total_tax)|| ' To ' ||TO_CHAR(l_total_tax) ,2);
5465 END IF;
5466
5467 /* updating the tax value and tax line value on oe_order_lines_all table for line id*/
5468 UPDATE OE_ORDER_LINES_ALL
5469 SET TAX_VALUE = l_total_tax,
5470 TAX_LINE_VALUE = l_total_tax - l_tax_on_charge --TaxER
5471 WHERE line_id = p_entity_id_tbl(i).entity_id;
5472 /* getting line record*/
5473 --TaxER l_line_rec := OE_line_UTIL.Query_Row(p_line_id=> p_entity_id_tbl(i).entity_id );
5474 SELECT payment_type_code
5475 INTO l_payment_type_code
5476 FROM oe_order_lines_all
5477 WHERE line_id = l_line_rec.line_id;
5478 -- Bug 8825061: Update the global picture given that the line attribute
5479 -- "tax_value" has undergone an update.
5480 IF l_debug_level > 0 THEN
5481 oe_debug_pub.ADD('8825061: Line_ID: ' || l_line_rec.line_id, 1);
5482 oe_debug_pub.add(' 8825061: New Tax Value: ' || l_total_tax) ;
5483 END IF; -- check on l_debug_level
5484 l_old_line_tbl(1) := l_line_rec;
5485 l_line_tbl(1) := l_line_rec;
5486 l_line_tbl(1).tax_value := l_total_tax;
5487 IF (Oe_Code_Control.Code_Release_Level >= '110508') THEN
5488 Oe_Order_Util.Update_Global_Picture ( p_Upd_New_Rec_If_Exists => FALSE,
5489 p_header_id => l_line_rec.header_id,
5490 p_old_line_rec => l_old_line_tbl(1),
5491 p_line_rec => l_line_tbl(1),
5492 p_line_id => l_line_rec.line_id,
5493 x_index => l_global_index,
5494 x_return_status => l_return_status );
5495 IF l_debug_level > 0 THEN
5496 oe_debug_pub.add('8825061: after update global picture, status: ' || l_return_status, 1 ) ;
5497 oe_debug_pub.add('8825061: global picture index: ' || l_global_index , 1 ) ;
5498 END IF;
5499 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
5500 RAISE Fnd_Api.G_EXC_ERROR;
5501 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5502 RAISE Fnd_Api.G_EXC_UNEXPECTED_ERROR;
5503 END IF;
5504 IF l_index IS NOT NULL THEN
5505 Oe_Order_Util.g_line_tbl(l_global_index).tax_value := l_line_tbl(1).tax_value;
5506 END IF; -- Check on l_index being non-null
5507 END IF; -- Check on code release level
5508 -- Bug 8825061
5509 -- lkxu, if tax_value changes, log delayed request for commitment.
5510 -- bug 1768906
5511 IF OE_Commitment_Pvt.Do_Commitment_Sequencing AND l_line_rec.commitment_id IS NOT NULL THEN
5512 IF l_debug_level > 0 THEN
5513 oe_debug_pub.add('Logging delayed request for Commitment when tax value changes.', 2);
5514 END IF;
5515 OE_Delayed_Requests_Pvt.Log_Request( p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5516 p_entity_id => l_line_rec.line_id,
5517 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5518 p_requesting_entity_id => l_line_rec.line_id,
5519 p_request_type => OE_GLOBALS.G_CALCULATE_COMMITMENT,
5520 x_return_status => l_return_status);
5521 END IF;
5522 -- Do not log Verify Payment Delayed Requests for Return Lines
5523 --
5524 IF l_line_rec.line_category_code <> 'RETURN' THEN
5525 -- lkxu, added for bug 1581188
5526 -- Logging delayed requests for Verify Payment if tax value
5527 -- has increased AND Payment Type Code is Credit Card.
5528 IF NVL(l_total_tax,0) > NVL(l_old_total_tax,0) AND l_line_rec.commitment_id IS NULL AND l_payment_type_code = 'CREDIT_CARD' THEN
5529 -- if it is a prepaid, do not log request after shipping.
5530 IF OE_PrePayment_UTIL.is_prepaid_order(l_line_rec.header_id) = 'N' OR (OE_PrePayment_UTIL.is_prepaid_order(l_line_rec.header_id) = 'Y' AND l_line_rec.booked_flag ='Y' AND l_line_rec.shipped_quantity IS NULL) THEN
5531 IF l_debug_level > 0 THEN
5532 oe_debug_pub.ADD('Logging delayed request for Verify Payment for change in tax value',2);
5533 END IF;
5534 OE_delayed_requests_Pvt.log_request (p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5535 p_entity_id => l_line_rec.header_id,
5536 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5537 p_requesting_entity_id => l_line_rec.line_id,
5538 p_request_type => OE_GLOBALS.G_VERIFY_PAYMENT,
5539 x_return_status => l_return_status);
5540 END IF;
5541 -- bug 2238438, credit card collection project.
5542 -- log delayed request for prepaid order even the tax value
5543 -- decreased, as a refund request might be needed.
5544 ELSIF NVL(l_total_tax,0) < NVL(l_old_total_tax,0)
5545 AND l_line_rec.commitment_id IS NULL
5546 AND OE_PrePayment_UTIL.is_prepaid_order(l_line_rec.header_id) = 'Y'
5547 AND l_line_rec.booked_flag ='Y'
5548 AND l_payment_type_code = 'CREDIT_CARD'
5549 AND l_line_rec.shipped_quantity IS NULL THEN
5550 IF l_debug_level > 0 THEN
5551 oe_debug_pub.ADD('Logging delayed request for Verify Payment for change in tax value for prepaid order',2);
5552 END IF;
5553 OE_delayed_requests_Pvt.log_request (p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5554 p_entity_id => l_line_rec.header_id,
5555 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5556 p_requesting_entity_id => l_line_rec.line_id,
5557 p_request_type => OE_GLOBALS.G_VERIFY_PAYMENT,
5558 x_return_status => l_return_status);
5559 END IF;
5560 -- Start fix for bug# 4378531
5561 -- end of change for bug 1581188
5562 -- tbharti, Added for bug 1952363
5563 -- Tax Value changed, log a delayed request for Verify
5564 -- Payment if Payment Type Code is not Credit Card.
5565 -- Fix Bug # 2565813: Added IF condition to check for real change in tax value.
5566 IF NVL(l_payment_type_code, ' ') <> 'CREDIT_CARD' --bug 2679223
5567 AND NVL(l_call_credit_checking, 'Y') <> 'No_Credit_Checking' THEN
5568 IF NVL(l_total_tax, 0) > NVL(l_old_total_tax, 0) THEN
5569 oe_debug_pub.ADD('Logging delayed request for Verify Payment for change in tax value',2);
5570 OE_delayed_requests_Pvt.log_request (p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5571 p_entity_id => l_line_rec.header_id,
5572 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5573 p_requesting_entity_id => l_line_rec.line_id,
5574 p_request_type => OE_GLOBALS.G_VERIFY_PAYMENT,
5575 x_return_status => l_return_status);
5576 ELSIF NVL(l_total_tax,0) < NVL(l_old_total_tax,0) THEN
5577 oe_debug_pub.add('CHECKING CREDIT CHECK HOLD FOR HEADER/LINE ID : ' || TO_CHAR (l_line_rec.header_id) || '/' || TO_CHAR (l_line_rec.line_id) ) ;
5578 OE_HOLDS_PUB.Check_Holds ( p_api_version => 1.0 ,
5579 p_header_id => l_line_rec.header_id ,
5580 p_line_id => l_line_rec.line_id ,
5581 p_hold_id => 1 ,
5582 p_entity_code => 'O' ,
5583 p_entity_id => l_line_rec.header_id ,
5584 x_result_out => l_hold_result ,
5585 x_msg_count => l_msg_count ,
5586 x_msg_data => l_msg_data ,
5587 x_return_status => l_return_status );
5588 IF ( l_hold_result = FND_API.G_TRUE ) THEN
5589 oe_debug_pub.add('Logging delayed request for verify payment for change in tax value and hold exist') ;
5590 OE_delayed_requests_Pvt.log_request (p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5591 p_entity_id => l_line_rec.header_id,
5592 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5593 p_requesting_entity_id => l_line_rec.line_id,
5594 p_request_type => OE_GLOBALS.G_VERIFY_PAYMENT,
5595 x_return_status => l_return_status);
5596 END IF;
5597 END IF;
5598 END IF;
5599 -- End fix for bug# 4378531
5600 END IF; -- Line Category not RETURN
5601 END IF; -- tax value is different
5602 BEGIN
5603 l_l_line_adj_tbl.delete;
5604 /* initializing l_l_line_adj_tbl */
5605 OE_Line_Adj_UTIL.Lock_Rows ( p_line_id => l_line_rec.line_id, x_line_adj_tbl => l_l_line_adj_tbl, x_return_status => l_return_status);
5606 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5607 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5608 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5609 RAISE FND_API.G_EXC_ERROR;
5610 END IF;
5611 EXCEPTION
5612 WHEN NO_DATA_FOUND THEN
5613 l_l_line_adj_tbl.delete;
5614 x_return_status := FND_API.G_RET_STS_SUCCESS;
5615 END;
5616 FOR I IN 1..l_tax_rec_out_tbl.COUNT
5617 LOOP
5618 IF l_tax_rec_out_tbl(I).line_id = l_requesting_entity_id THEN --TaxER
5619 l_match_flag := 'N';
5620 l_tax_rate_id := l_tax_rec_out_tbl(I).tax_rate_id;
5621 IF l_l_line_adj_tbl.COUNT > 0 THEN
5622 FOR J IN 1..l_l_line_adj_tbl.COUNT
5623 LOOP
5624 /* if condition for line */
5625 IF l_tax_rec_out_tbl(i).trx_line_id = l_l_line_adj_tbl(j).line_id
5626 AND l_l_line_adj_tbl(j).parent_adjustment_id IS NULL
5627 AND l_tax_rec_out_tbl(i).line_id= l_l_line_adj_tbl(j).line_id
5628 THEN
5629 IF l_l_line_adj_tbl(J).list_line_type_code = 'TAX'
5630 AND l_l_line_adj_tbl(J).tax_rate_id = l_tax_rate_id
5631 AND l_l_line_adj_tbl(J).OPERATION <> OE_GLOBALS.G_OPR_UPDATE
5632 THEN
5633 l_match_flag := 'Y';
5634 l_l_line_adj_tbl(J).OPERATION :=OE_GLOBALS.G_OPR_UPDATE;
5635 IF NOT OE_GLOBALS.Equal( l_tax_rec_out_tbl(I).tax_amount, l_l_line_adj_tbl(J).adjusted_amount)
5636 OR NOT OE_GLOBALS.Equal(l_tax_rec_out_tbl(I).tax_rate, l_l_line_adj_tbl(J).operand)
5637 OR l_tax_rec_out_tbl(I).amount_includes_tax_flag <> l_l_line_adj_tbl(j).applied_flag -- added for bug#12895421
5638 THEN
5639 IF l_debug_level > 0 THEN
5640 oe_debug_pub.add('Updating the Adj record '|| TO_CHAR(l_l_line_adj_tbl(J).price_adjustment_id),2);
5641 END IF;
5642 UPDATE OE_PRICE_ADJUSTMENTS
5643 SET ADJUSTED_AMOUNT = l_tax_rec_out_tbl(I).tax_amount,
5644 OPERAND = l_tax_rec_out_tbl(I).tax_rate,
5645 tax_Rate_id = l_tax_rec_out_tbl(I).tax_rate_id,
5646 LAST_UPDATE_DATE = sysdate,
5647 APPLIED_FLAG = Nvl(l_tax_rec_out_tbl(I).amount_includes_tax_flag,'N'), --for bug#12895421
5648 LAST_UPDATED_BY = FND_GLOBAL.USER_ID,
5649 LAST_UPDATE_LOGIN = FND_GLOBAL.LOGIN_ID
5650 WHERE price_adjustment_id = l_l_line_adj_tbl(J).price_adjustment_id;
5651
5652 l_l_line_adj_tbl(J).OPERATION := OE_GLOBALS.G_OPR_UPDATE;
5653 l_match_flag := 'Y';
5654 END IF;
5655 EXIT; --If match found then exit from loop .added for bug#1947306
5656 END IF;--- end if for tax record
5657 END IF;
5658 /* end if condition for line */
5659 /* if condition for line level freight charge */
5660 IF l_tax_rec_out_tbl(i).trx_line_id = l_l_line_adj_tbl(j).parent_adjustment_id
5661 AND l_tax_rec_out_tbl(i).line_id = l_l_line_adj_tbl(j).line_id
5662 THEN
5663 IF l_l_line_adj_tbl(J).list_line_type_code = 'TAX'
5664 AND l_l_line_adj_tbl(J).tax_rate_id = l_tax_rate_id
5665 AND l_l_line_adj_tbl(J).OPERATION <> OE_GLOBALS.G_OPR_UPDATE
5666 THEN
5667 l_match_flag := 'Y';
5668 l_l_line_adj_tbl(J).OPERATION :=OE_GLOBALS.G_OPR_UPDATE;
5669 IF NOT OE_GLOBALS.Equal( l_tax_rec_out_tbl(I).tax_amount, l_l_line_adj_tbl(J).adjusted_amount)
5670 OR NOT OE_GLOBALS.Equal(l_tax_rec_out_tbl(I).tax_rate, l_l_line_adj_tbl(J).operand)
5671 OR l_tax_rec_out_tbl(I).amount_includes_tax_flag <> l_l_line_adj_tbl(j).applied_flag -- added for bug#12895421
5672 THEN
5673 IF l_debug_level > 0 THEN
5674 oe_debug_pub.add('Updating the Adj record '|| TO_CHAR(l_l_line_adj_tbl(J).price_adjustment_id),2);
5675 END IF;
5676 UPDATE OE_PRICE_ADJUSTMENTS
5677 SET ADJUSTED_AMOUNT = l_tax_rec_out_tbl(I).tax_amount,
5678 OPERAND = l_tax_rec_out_tbl(I).tax_rate,
5679 tax_Rate_id = l_tax_rec_out_tbl(I).tax_rate_id,
5680 LAST_UPDATE_DATE = sysdate,
5681 applied_flag = Nvl(l_tax_rec_out_tbl(I).amount_includes_tax_flag,'N'),--for bug#12895421
5682 LAST_UPDATED_BY = FND_GLOBAL.USER_ID,
5683 LAST_UPDATE_LOGIN = FND_GLOBAL.LOGIN_ID
5684 WHERE price_adjustment_id = l_l_line_adj_tbl(J).price_adjustment_id;
5685 l_l_line_adj_tbl(J).OPERATION := OE_GLOBALS.G_OPR_UPDATE;
5686 l_match_flag := 'Y';
5687 END IF;
5688 EXIT; -- If match found then exit from loop .added for bug#1947306
5689 END IF; --- end if for tax record
5690 END IF;
5691 /* end if condition for line level freight charge */
5692 END LOOP; --l_l_line_adj_tbl for
5693 END IF; --l_l_line_adj_tbl.COUNT > 0
5694 IF l_match_flag = 'N' THEN
5695 SELECT OE_PRICE_ADJUSTMENTS_S.nextval INTO l_price_adjustment_id FROM DUAL;
5696 l_adj_rec.parent_adjustment_id := NULL;
5697 l_adj_rec.price_adjustment_id := l_price_adjustment_id;
5698 l_adj_rec.header_id := l_tax_rec_out_tbl(i).trx_id;
5699 l_adj_rec.last_update_date := SYSDATE;
5700 l_adj_rec.last_updated_by := FND_GLOBAL.USER_ID;
5701 l_adj_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
5702 l_adj_rec.applied_flag := Nvl(l_tax_rec_out_tbl(I).amount_includes_tax_flag,'N'); --for bug#12895421
5703 l_adj_rec.creation_date := SYSDATE;
5704 l_adj_rec.created_by := FND_GLOBAL.USER_ID;
5705 l_adj_rec.line_id := l_tax_rec_out_tbl(i).line_id;
5706 --l_adj_rec.tax_code := l_tax_rate_code;
5707 l_adj_rec.tax_rate_id := l_tax_rec_out_tbl(I).tax_rate_id;
5708 IF l_debug_level > 0 THEN
5709 oe_debug_pub.add('Inserting the Adj record '|| TO_CHAR(l_adj_rec.price_adjustment_id),2);
5710 END IF;
5711 l_adj_rec.operand := l_tax_rec_out_tbl(I).tax_rate;
5712 l_adj_rec.adjusted_amount := l_tax_rec_out_tbl(I).tax_amount;
5713 l_adj_rec.automatic_flag := 'N';
5714 l_adj_rec.list_line_type_code := 'TAX';
5715 l_adj_rec.arithmetic_operator := 'AMT';
5716 l_adj_rec.operation := OE_GLOBALS.g_opr_create;
5717 --TaxER start
5718 IF l_tax_rec_out_tbl(I).trx_level_type = 'FREIGHT_CHARGE' THEN
5719 l_adj_rec.parent_adjustment_id := l_tax_rec_out_tbl(i).trx_line_id; --TaxER
5720 END IF;
5721 --TaxER end
5722 OE_LINE_ADJ_UTIL.INSERT_ROW(p_Line_Adj_rec => l_adj_rec);
5723 END IF;
5724 --TaxER END IF; --l_l_line_adj_tbl.COUNT > 0
5725 END IF; --TaxER
5726 END LOOP; -- For Tax_Rec_Out_Tbl
5727 IF l_l_line_adj_tbl.COUNT > 0 THEN
5728 FOR J IN 1..l_l_line_adj_tbl.COUNT
5729 LOOP
5730 IF l_l_line_adj_tbl(J).list_line_type_code = 'TAX' AND (l_l_line_adj_tbl(J).operation IS NULL OR l_l_line_adj_tbl(J).operation = FND_API.G_MISS_CHAR) THEN
5731 IF l_debug_level > 0 THEN
5732 oe_debug_pub.add('Deleting adj Id '|| TO_CHAR(l_l_line_adj_tbl(J).price_adjustment_id),2);
5733 END IF;
5734 DELETE
5735 FROM OE_PRICE_ADJUSTMENTS
5736 WHERE PRICE_ADJUSTMENT_ID = l_l_line_adj_tbl(J).price_adjustment_id;
5737 END IF;
5738 END LOOP;
5739 END IF;
5740 elsif p_entity_id_tbl(i).requesting_entity_code = 'HEADER' THEN
5741 /* Calculating total new tax value from l_tax_rec_out_tbl record*/
5742 l_header_rec:= OE_Header_UTIL.Query_Row(p_header_id=> p_entity_id_tbl(i).entity_id ); --added for bug 12895421
5743 FOR j IN 1..l_tax_rec_out_tbl.count
5744 LOOP
5745 IF l_tax_rec_out_tbl(j).trx_id = p_entity_id_tbl(i).entity_id AND l_tax_rec_out_tbl(j).line_id IS NULL THEN
5746 l_total_tax := l_total_tax + l_tax_rec_out_tbl(j).tax_amount;
5747 END IF;
5748 END LOOP;
5749 /* getting total tax value from oe_price_adjustments table for header_id */
5750 SELECT SUM(ADJUSTED_AMOUNT)
5751 INTO l_old_total_tax
5752 FROM oe_price_adjustments
5753 WHERE header_id = p_entity_id_tbl(i).entity_id
5754 AND line_id IS NULL
5755 AND list_line_type_code = 'TAX' ;
5756 IF ( (l_old_total_tax IS NOT NULL AND l_total_tax IS NOT NULL AND l_old_total_tax = l_total_tax) OR (l_old_total_tax IS NULL AND l_total_tax IS NULL ) ) THEN
5757 NULL;
5758 ELSE
5759 IF l_debug_level > 0 THEN
5760 oe_debug_pub.add('Updateing tax value from '||TO_CHAR(l_old_total_tax)|| ' To ' ||TO_CHAR(l_total_tax) ,2);
5761 END IF;
5762 /* getting header record*/
5763 l_header_rec:= OE_Header_UTIL.Query_Row(p_header_id=> p_entity_id_tbl(i).entity_id );
5764 SELECT payment_type_code
5765 INTO l_payment_type_code
5766 FROM oe_order_headers_all
5767 WHERE header_id = l_header_rec.header_id;
5768 -- Bug 8825061: Update the global picture given that the line attribute
5769 -- "tax_value" has undergone an update.
5770 IF l_debug_level > 0 THEN
5771 oe_debug_pub.ADD('8825061: Header_id : ' || l_header_rec.header_id, 1);
5772 oe_debug_pub.add(' 8825061: New Tax Value: ' || l_total_tax) ;
5773 END IF; -- check on l_debug_level
5774 /* getting return count*/
5775 SELECT COUNT(1)
5776 INTO l_return
5777 FROM oe_order_lines_all
5778 WHERE 1 =1
5779 AND header_id = l_header_rec.header_id
5780 AND line_category_code = 'RETURN';
5781 IF l_return = 0 THEN -- logging delayed requests only when return lines are zero
5782 -- lkxu, added for bug 1581188
5783 -- Logging delayed requests for Verify Payment if tax value
5784 -- has increased AND Payment Type Code is Credit Card.
5785 IF NVL(l_total_tax,0) > NVL(l_old_total_tax,0) AND l_payment_type_code = 'CREDIT_CARD' AND l_header_rec.booked_flag ='Y' THEN
5786 OE_delayed_requests_Pvt.log_request (p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5787 p_entity_id => l_header_rec.header_id,
5788 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5789 p_requesting_entity_id => l_header_rec.header_id,
5790 p_request_type => OE_GLOBALS.G_VERIFY_PAYMENT,
5791 x_return_status => l_return_status);
5792 -- bug 2238438, credit card collection project.
5793 -- log delayed request for prepaid order even the tax value
5794 -- decreased, as a refund request might be needed.
5795 ELSIF NVL(l_total_tax,0) < NVL(l_old_total_tax,0) AND OE_PrePayment_UTIL.is_prepaid_order(l_header_rec.header_id) = 'Y' AND l_header_rec.booked_flag ='Y' AND l_payment_type_code = 'CREDIT_CARD' THEN
5796 IF l_debug_level > 0 THEN
5797 oe_debug_pub.ADD('Logging delayed request for Verify Payment for change in tax value for prepaid order',2);
5798 END IF;
5799 OE_delayed_requests_Pvt.log_request (p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5800 p_entity_id => l_header_rec.header_id,
5801 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5802 p_requesting_entity_id => l_header_rec.header_id,
5803 p_request_type => OE_GLOBALS.G_VERIFY_PAYMENT,
5804 x_return_status => l_return_status);
5805 END IF;
5806 -- Start fix for bug# 4378531
5807 -- end of change for bug 1581188
5808 -- tbharti, Added for bug 1952363
5809 -- Tax Value changed, log a delayed request for Verify
5810 -- Payment if Payment Type Code is not Credit Card.
5811 -- Fix Bug # 2565813: Added IF condition to check for real change in tax value.
5812 IF NVL(l_payment_type_code, ' ') <> 'CREDIT_CARD' --bug 2679223
5813 AND NVL(l_call_credit_checking, 'Y') <> 'No_Credit_Checking' THEN
5814 IF NVL(l_total_tax, 0) > NVL(l_old_total_tax, 0) THEN
5815 oe_debug_pub.ADD('Logging delayed request for Verify Payment for change in tax value',2);
5816 OE_delayed_requests_Pvt.log_request (p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5817 p_entity_id => l_header_rec.header_id,
5818 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5819 p_requesting_entity_id => l_header_rec.header_id,
5820 p_request_type => OE_GLOBALS.G_VERIFY_PAYMENT,
5821 x_return_status => l_return_status);
5822 ELSIF NVL(l_total_tax,0) < NVL(l_old_total_tax,0) THEN
5823 OE_delayed_requests_Pvt.log_request (p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5824 p_entity_id => l_header_rec.header_id,
5825 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5826 p_requesting_entity_id => l_header_rec.header_id,
5827 p_request_type => OE_GLOBALS.G_VERIFY_PAYMENT,
5828 x_return_status => l_return_status);
5829 END IF;
5830 END IF;
5831 -- End fix for bug# 4378531
5832 END IF; -- Line Category not RETURN
5833 END IF; -- tax value is different
5834 BEGIN
5835 l_l_header_adj_tbl.delete;
5836 /* initializing l_l_header_adj_tbl */
5837 OE_Header_Adj_Util.Lock_Rows ( p_header_id => l_header_rec.header_id, X_HEADER_ADJ_TBL=>l_l_header_adj_tbl, X_RETURN_STATUS => l_return_status);
5838 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5839 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5840 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5841 RAISE FND_API.G_EXC_ERROR;
5842 END IF;
5843 EXCEPTION
5844 WHEN NO_DATA_FOUND THEN
5845 l_l_header_adj_tbl.delete;
5846 x_return_status := FND_API.G_RET_STS_SUCCESS;
5847 END;
5848 FOR I IN 1..l_tax_rec_out_tbl.COUNT
5849 LOOP
5850 IF l_tax_rec_out_tbl(I).trx_id = l_requesting_entity_id THEN --TaxER
5851 l_match_flag := 'N';
5852 l_tax_rate_id := l_tax_rec_out_tbl(I).tax_rate_id;
5853 IF l_l_header_adj_tbl.COUNT > 0 THEN
5854 FOR J IN 1..l_l_header_adj_tbl.COUNT
5855 LOOP
5856
5857 /* if condition for Header level freight charge */
5858 IF l_tax_rec_out_tbl(i).trx_line_id = l_l_header_adj_tbl(j).parent_adjustment_id
5859 AND l_tax_rec_out_tbl(i).line_id IS NULL
5860 AND l_l_header_adj_tbl(j).line_id IS NULL
5861 THEN
5862 IF l_l_header_adj_tbl(J).list_line_type_code = 'TAX'
5863 AND l_l_header_adj_tbl(J).tax_rate_id = l_tax_rate_id
5864 AND l_l_header_adj_tbl(J).OPERATION <> OE_GLOBALS.G_OPR_UPDATE
5865 THEN
5866 l_match_flag := 'Y';
5867 l_l_header_adj_tbl(J).OPERATION :=OE_GLOBALS.G_OPR_UPDATE;
5868 IF NOT OE_GLOBALS.Equal( l_tax_rec_out_tbl(I).tax_amount, l_l_header_adj_tbl(J).adjusted_amount)
5869 OR NOT OE_GLOBALS.Equal(l_tax_rec_out_tbl(I).tax_rate, l_l_header_adj_tbl(J).operand)
5870 OR l_tax_rec_out_tbl(I).amount_includes_tax_flag <> l_l_header_adj_tbl(j).applied_flag -- added for bug#12895421
5871 THEN
5872 IF l_debug_level > 0 THEN
5873 oe_debug_pub.add('Updating the Adj record '|| TO_CHAR(l_l_header_adj_tbl(J).price_adjustment_id),2);
5874 END IF;
5875 UPDATE OE_PRICE_ADJUSTMENTS
5876 SET ADJUSTED_AMOUNT = l_tax_rec_out_tbl(I).tax_amount,
5877 OPERAND = l_tax_rec_out_tbl(I).tax_rate,
5878 tax_Rate_id = l_tax_rec_out_tbl(I).tax_rate_id,
5879 LAST_UPDATE_DATE = sysdate,
5880 applied_flag = Nvl(l_tax_rec_out_tbl(I).amount_includes_tax_flag,'N') , ----for bug#12895421
5881 LAST_UPDATED_BY = FND_GLOBAL.USER_ID,
5882 LAST_UPDATE_LOGIN = FND_GLOBAL.LOGIN_ID
5883 WHERE price_adjustment_id = l_l_header_adj_tbl(J).price_adjustment_id;
5884 l_l_header_adj_tbl(J).OPERATION := OE_GLOBALS.G_OPR_UPDATE;
5885 l_match_flag := 'Y';
5886 END IF;
5887 EXIT; -- If match found then exit from loop .added for bug#1947306
5888 END IF; --- end if for tax record
5889 END IF;
5890 /* end if condition for Header level freight charge */
5891 END LOOP; --l_l_header_adj_tbl for
5892 IF l_match_flag = 'N' AND l_tax_rec_out_tbl(i).line_id IS NULL THEN --TaxER
5893 SELECT OE_PRICE_ADJUSTMENTS_S.nextval INTO l_price_adjustment_id FROM DUAL;
5894 --TaxER start
5895 l_h_adj_rec.parent_adjustment_id := NULL;
5896 l_h_adj_rec.price_adjustment_id := l_price_adjustment_id;
5897 l_h_adj_rec.header_id := l_tax_rec_out_tbl(i).trx_id;
5898 l_h_adj_rec.last_update_date := SYSDATE;
5899 l_h_adj_rec.last_updated_by := FND_GLOBAL.USER_ID;
5900 l_h_adj_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
5901 l_h_adj_rec.creation_date := SYSDATE;
5902 l_h_adj_rec.applied_flag := Nvl(l_tax_rec_out_tbl(I).amount_includes_tax_flag,'N');----for bug#12895421
5903 l_h_adj_rec.created_by := FND_GLOBAL.USER_ID;
5904 l_h_adj_rec.line_id := l_tax_rec_out_tbl(i).line_id;
5905 --l_adj_rec.tax_code := l_tax_rate_code;
5906 l_h_adj_rec.tax_rate_id := l_tax_rec_out_tbl(I).tax_rate_id;
5907 IF l_debug_level > 0 THEN
5908 oe_debug_pub.add('Inserting the Adj record '|| TO_CHAR(l_adj_rec.price_adjustment_id),2);
5909 END IF;
5910 l_h_adj_rec.operand := l_tax_rec_out_tbl(I).tax_rate;
5911 l_h_adj_rec.adjusted_amount := l_tax_rec_out_tbl(I).tax_amount;
5912 l_h_adj_rec.automatic_flag := 'N';
5913 l_h_adj_rec.list_line_type_code := 'TAX';
5914 l_h_adj_rec.arithmetic_operator := 'AMT';
5915 l_h_adj_rec.operation := OE_GLOBALS.g_opr_create;
5916 --TaxER start
5917 IF l_tax_rec_out_tbl(I).trx_level_type = 'FREIGHT_CHARGE' THEN
5918 l_h_adj_rec.parent_adjustment_id := l_tax_rec_out_tbl(i).trx_line_id;
5919 END IF;
5920 --TaxER end
5921 OE_Header_Adj_Util.INSERT_ROW(p_Header_Adj_rec => l_h_adj_rec);
5922 END IF;
5923 END IF; --l_l_header_adj_tbl.COUNT > 0
5924 END IF; --TaxER
5925 END LOOP; -- For Tax_Rec_Out_Tbl
5926 IF l_l_header_adj_tbl.COUNT > 0 THEN
5927 FOR J IN 1..l_l_header_adj_tbl.COUNT
5928 LOOP
5929 --TaxER IF l_l_header_adj_tbl(J).list_line_type_code = 'TAX' AND l_l_header_adj_tbl(J).parent_adjustment_id IS NULL AND (l_l_header_adj_tbl(J).operation IS NULL OR l_l_header_adj_tbl(J).operation = FND_API.G_MISS_CHAR) THEN
5930 IF l_l_header_adj_tbl(J).list_line_type_code = 'TAX' AND (l_l_header_adj_tbl(J).operation IS NULL OR l_l_header_adj_tbl(J).operation = FND_API.G_MISS_CHAR) THEN --TaxER
5931 IF l_debug_level > 0 THEN
5932 oe_debug_pub.add('Deleting adj Id '|| TO_CHAR(l_l_header_adj_tbl(J).price_adjustment_id),2);
5933 END IF;
5934 DELETE
5935 FROM OE_PRICE_ADJUSTMENTS
5936 WHERE PRICE_ADJUSTMENT_ID = l_l_header_adj_tbl(J).price_adjustment_id;
5937 END IF;
5938 END LOOP;
5939 END IF;
5940 END IF;
5941 END LOOP;
5942 x_return_status := l_return_status;
5943 IF l_debug_level > 0 THEN
5944 v_end := DBMS_UTILITY.GET_TIME;
5945 oe_debug_pub.add('Time Of execution for Process_Tax '|| TO_CHAR((v_end-v_start)/100),1);
5946 END IF;
5947 l_tax_rec_out_tbl.delete;
5948 IF l_debug_level > 0 THEN
5949 oe_debug_pub.add('Exiting Process_Tax ',0.5); --debug level changed to 0.5 for bug 13435459
5950 END IF;
5951 EXCEPTION
5952 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5953 l_tax_rec_out_tbl.delete;
5954 l_l_line_adj_tbl.delete;
5955 l_l_header_adj_tbl.DELETE ;
5956 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5957 WHEN FND_API.G_EXC_ERROR THEN
5958 l_tax_rec_out_tbl.delete;
5959 l_l_line_adj_tbl.delete;
5960 l_l_header_adj_tbl.DELETE;
5961 x_return_status := FND_API.G_RET_STS_ERROR;
5962 WHEN NO_DATA_FOUND THEN
5963 l_tax_rec_out_tbl.delete;
5964 l_l_line_adj_tbl.delete;
5965 l_l_header_adj_tbl.DELETE;
5966 IF l_debug_level > 0 THEN
5967 oe_debug_pub.add('Tax_Order: In No DATA Found',2);
5968 END IF;
5969 x_return_status := FND_API.G_RET_STS_SUCCESS;
5970 WHEN OTHERS THEN
5971 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
5972 OE_MSG_PUB.Add_Exc_Msg ( G_PKG_NAME , 'Tax Header' );
5973 END IF;
5974 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5975 l_tax_rec_out_tbl.delete;
5976 l_l_line_adj_tbl.delete;
5977 l_l_header_adj_tbl.DELETE;
5978 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5979 END Process_Tax;
5980
5981
5982
5983 --Added by Mushenoy for the auto Internal Requisition Creation (ikon) Aug 22 2001
5984 PROCEDURE auto_create_internal_req
5985 (p_ord_header_id IN NUMBER
5986 ,x_return_status OUT NOCOPY VARCHAR2)
5987
5988 IS
5989 /*
5990 ** PROGRAM LOGIC
5991 **--Query Order Header
5992 **--Query Order Line
5993 **--Derive Values not available on the Internal Sales Order
5994 **--Pass the Internal Sales Order Header values to the internal req header record
5995 **--Pass the Internal Sales Order Line values to the internal req Line table
5996 **--Call the Purchasing API and pass the internal req header record and line tables to Create the Internal Req
5997 **--Check return status of the Purchasing API
5998 **--Update the Internal Sales Order with the Req header id, Req line Ids, Req number and line numbers.
5999 **--Check for return status
6000 **--Handle Exceptions
6001 */
6002 l_int_req_Ret_sts varchar2(1);
6003 l_req_header_rec PO_CREATE_REQUISITION_SV.Header_rec_Type;
6004 l_req_line_tbl PO_CREATE_REQUISITION_SV.Line_Tbl_Type;
6005 l_created_by number;
6006 l_org_id number;
6007 l_preparer_id number;
6008 l_destination_org_id number;
6009 l_deliver_to_locn_id number;
6010 l_msg_count number;
6011 l_msg_data varchar2(2000);
6012 k number := 0;
6013 j number := 0;
6014
6015 Cursor ord_hdr_cur (p_header_id in number) is
6016 SELECT created_by
6017 ,org_id
6018 FROM OE_ORDER_HEADERS
6019 WHERE header_id = p_header_id;
6020
6021 Cursor ord_line_cur (p_header_id in number) is
6022 SELECT line_id
6023 ,order_quantity_uom
6024 ,ordered_quantity
6025 ,sold_to_org_id
6026 ,inventory_item_id
6027 ,schedule_ship_date
6028 ,org_id
6029 ,ship_from_org_id
6030 ,subinventory
6031 ,source_document_id
6032 ,source_document_line_id
6033 ,item_type_code
6034 FROM OE_ORDER_LINES
6035 WHERE header_id = p_header_id;
6036
6037 CURSOR employee_id_cur(p_user_id in number) IS
6038 SELECT employee_id
6039 FROM fnd_user
6040 WHERE user_id = p_user_id;
6041
6042 CURSOR dest_org_locn_cur (p_cust_id in number) is
6043 SELECT b.location_id,
6044 b.organization_id
6045 FROM hz_party_sites_V a
6046 ,PO_LOCATION_ASSOCIATIONS b
6047 WHERE a.party_site_use_id = b.SITE_USE_ID
6048 and b.customer_id = p_cust_id
6049 and primary_per_type = 'Y'
6050 and site_use_type = 'SHIP_TO';
6051
6052 BEGIN
6053
6054 oe_debug_pub.add(' Entering procedure auto_create_internal_req ',2);
6055 x_return_status := FND_API.G_RET_STS_SUCCESS;
6056 --Query Order Header
6057 OPEN ord_hdr_cur(p_ord_header_id);
6058 FETCH ord_hdr_cur into l_created_by,l_org_id;
6059 CLOSE ord_hdr_cur;
6060 oe_debug_pub.add('auto_create_internal_req after hdr query ',2);
6061 --Derive Values not available on the Internal Sales Order
6062 --Derive the Preparer_id
6063 BEGIN
6064 OPEN employee_id_cur(l_created_by);
6065 FETCH employee_id_cur into l_preparer_id;
6066 CLOSE employee_id_cur;
6067 EXCEPTION
6068 WHEN NO_DATA_FOUND THEN
6069 --This is a required field however PO will handle the error if these Fields are null
6070 l_preparer_id := null;
6071 WHEN OTHERS THEN
6072 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6073 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6074 END;
6075
6076 --Pass the Internal Sales Order Header values to the internal req header record
6077 l_req_header_rec.preparer_id := l_preparer_id;
6078 l_req_header_rec.summary_flag := 'N';
6079 l_req_header_rec.enabled_flag := 'Y';
6080 l_req_header_rec.authorization_status := 'APPROVED';
6081 l_req_header_rec.type_lookup_code := 'INTERNAL';
6082 l_req_header_rec.transferred_to_oe_flag := 'Y';
6083 l_req_header_rec.org_id := l_org_id;
6084
6085 --Pass the Internal Sales Order Line values to the internal req Line table
6086 --Here Loop for each Order Line
6087 FOR Cur_Ord_line in ord_line_cur(p_ord_header_id)
6088 LOOP
6089 j := j+1;
6090 IF cur_ord_line.item_type_code <> OE_GLOBALS.G_ITEM_STANDARD THEN
6091 fnd_message.set_name('ONT','ONT_ISO_ITEM_TYPE_NOT_STD');
6092 OE_MSG_PUB.Add;
6093 x_return_status := FND_API.G_RET_STS_ERROR;
6094 RAISE FND_API.G_EXC_ERROR;
6095 END IF;
6096 --get the destination organization id and deliver to location id for this order line
6097 BEGIN
6098 OPEN dest_org_locn_cur(cur_Ord_line.sold_to_org_id);
6099 FETCH dest_org_locn_cur INTO l_deliver_to_locn_id,l_destination_org_id;
6100 CLOSE dest_org_locn_cur;
6101
6102 EXCEPTION
6103 WHEN NO_DATA_FOUND THEN
6104 --This is a required field however PO will handle the error if these Fields are null
6105 l_destination_org_id := null;
6106 l_deliver_to_locn_id := null;
6107 END;
6108
6109 l_req_line_tbl(j).line_num := j;
6110 l_req_line_tbl(j).source_doc_line_reference:= Cur_Ord_line.line_id;
6111 l_req_line_tbl(j).uom_code := Cur_Ord_line.order_quantity_uom;
6112 l_req_line_tbl(j).quantity := Cur_Ord_line.ordered_quantity;
6113 l_req_line_tbl(j).deliver_to_location_id := l_deliver_to_locn_id;
6114 l_req_line_tbl(j).destination_type_code := 'INVENTORY';
6115 l_req_line_tbl(j).destination_organization_id := l_destination_org_id;
6116 l_req_line_tbl(j).destination_subinventory := Null;
6117 l_req_line_tbl(j).to_person_id := l_preparer_id;
6118 l_req_line_tbl(j).source_type_code := 'INVENTORY';
6119 l_req_line_tbl(j).item_id := Cur_Ord_line.inventory_item_id;
6120 l_req_line_tbl(j).need_by_date := Cur_Ord_line.schedule_ship_date;
6121 l_req_line_tbl(j).source_organization_id := Cur_Ord_line.ship_from_org_id;
6122 l_req_line_tbl(j).source_subinventory := Cur_Ord_line.subinventory;
6123 l_req_line_tbl(j).org_id := Cur_Ord_line.org_id;
6124 END LOOP;
6125 oe_debug_pub.add(' auto_create_internal_req before PO API call ',2);
6126
6127 --Call the PO API and pass the internal req header record and line tables to Create the Internal Req
6128 BEGIN /* Call to the Purchasing API*/
6129
6130 PO_CREATE_REQUISITION_SV.process_requisition(px_header_rec => l_req_header_rec
6131 ,px_line_table => l_req_line_tbl
6132 ,x_return_status => l_int_req_Ret_sts
6133 ,x_msg_count => l_msg_count
6134 ,x_msg_data => l_msg_data );
6135 --Check return status of the Purchasing API
6136 IF l_int_req_Ret_sts = FND_API.G_RET_STS_UNEXP_ERROR THEN
6137 oe_debug_pub.add(' PO API call returned unexpected error '||l_msg_data,2);
6138 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6139
6140 ELSIF l_int_req_Ret_sts = FND_API.G_RET_STS_ERROR THEN
6141 oe_debug_pub.add(' PO API call returned error '||l_msg_data,2);
6142 RAISE FND_API.G_EXC_ERROR;
6143 END IF;
6144
6145 END;/* Call to the Purchasing API*/
6146
6147 --if it returns success Update the Internal Sales Order with the Req header id and Req line Ids
6148 IF l_int_req_ret_sts = FND_API.G_RET_STS_SUCCESS THEN
6149
6150 --Update the header with the requisition header id
6151 Update OE_Order_Headers
6152 set source_document_Id = l_req_header_rec.requisition_header_id
6153 ,orig_sys_document_ref = l_req_header_rec.segment1
6154 ,source_document_type_id = OE_GLOBALS.G_ORDER_SOURCE_INTERNAL -- i.e 10 for internal
6155 ,order_source_id = OE_GLOBALS.G_ORDER_SOURCE_INTERNAL --i.e 10 for internal
6156 Where header_id = p_ord_header_id;
6157 oe_debug_pub.add('auto_create_internal_req after hdr update ',2);
6158 -- Update the lines with the requisition header and requisition line ids, requisition number and line number
6159
6160 FOR k in 1..l_req_line_tbl.count
6161 LOOP
6162 IF (l_req_line_tbl(k).requisition_line_id is not null) then
6163 BEGIN
6164 Update Oe_Order_lines
6165 Set source_document_id = l_req_header_rec.requisition_header_id
6166 ,source_document_line_id = l_req_line_tbl(k).requisition_line_id
6167 ,source_document_type_id = OE_GLOBALS.G_ORDER_SOURCE_INTERNAL -- i.e 10 for internal
6168 ,orig_sys_document_ref= l_req_header_rec.segment1
6169 ,orig_sys_line_ref = l_req_line_tbl(k).line_num
6170 where oe_order_lines.line_id = l_req_line_tbl(k).source_doc_line_reference;
6171 END;
6172 END IF;
6173 END LOOP;
6174 oe_debug_pub.add('auto_create_internal_req after line update ',2);
6175 END IF;
6176 --Handle Exceptions
6177 EXCEPTION
6178
6179 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6180 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6181 oe_debug_pub.add('auto_create_internal_req: In Unexpected error',2);
6182
6183 WHEN FND_API.G_EXC_ERROR THEN
6184 x_return_status := FND_API.G_RET_STS_ERROR;
6185 oe_debug_pub.add('auto_create_internal_req: In execution error',2);
6186
6187 --WHEN NO_DATA_FOUND THEN
6188 --x_return_status := FND_API.G_RET_STS_SUCCESS;
6189 --oe_debug_pub.add('auto_create_internal_req: In No DATA Found',2);
6190
6191 WHEN OTHERS THEN
6192 oe_debug_pub.add('auto_create_internal_req: In Other error',2);
6193 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6194 THEN
6195 OE_MSG_PUB.Add_Exc_Msg (G_PKG_NAME,'auto_create_internal_req');
6196 END IF;
6197 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6198
6199 END auto_create_internal_req;
6200
6201 -------------------------------------------------------------------
6202 -- Procedure: REVERSE_LIMITS
6203 -- Increments promotional limit balance in response to a cancellation
6204 -- or return against the order or line.
6205 -- Introduced for BUG 2013611
6206 -------------------------------------------------------------------
6207
6208 Procedure Reverse_Limits (p_action_code IN VARCHAR2,
6209 p_cons_price_request_code IN VARCHAR2,
6210 p_orig_ordered_qty IN NUMBER,
6211 p_amended_qty IN NUMBER,
6212 p_ret_price_request_code IN VARCHAR2,
6213 p_returned_qty IN NUMBER,
6214 p_line_id IN NUMBER,
6215 x_return_status OUT NOCOPY VARCHAR2)
6216
6217 IS
6218 l_return_status VARCHAR2(30);
6219 l_return_message VARCHAR2(2000);
6220 l_orig_ordered_qty NUMBER;
6221
6222 --bug#7491829
6223 l_parent_line_id NUMBER;
6224 l_header_id NUMBER;
6225 --bug#7491829
6226
6227 l_cons_price_request_code OE_ORDER_LINES_ALL.price_request_code%TYPE;
6228 l_ret_price_request_code OE_ORDER_LINES_ALL.price_request_code%TYPE;
6229
6230 CURSOR REFERENCED_LINE is
6231 SELECT return.price_request_code,
6232 referenced.pricing_quantity,
6233 referenced.price_request_code
6234 FROM OE_ORDER_LINES_ALL return , OE_ORDER_LINES_ALL referenced
6235 WHERE return.line_id = p_line_id
6236 and referenced.line_id = return.reference_line_id;
6237
6238 --bug #7491829
6239 CURSOR SPLIT_LINE IS
6240 SELECT parent.header_id,
6241 parent.pricing_quantity,
6242 parent.line_id
6243 FROM OE_ORDER_LINES_ALL child, OE_ORDER_LINES_ALL parent
6244 WHERE child.line_id = p_line_id
6245 and parent.line_id = child.split_from_line_id;
6246 --bug #7491829
6247
6248 BEGIN
6249
6250 OE_Debug_PUB.Add('Entering OE_Delayed_Requests_Util.Reverse_Limits', 1);
6251 OE_Debug_PUB.Add('BOTTOM LEVEL before QP call', 1);
6252 x_return_status := FND_API.G_RET_STS_SUCCESS;
6253
6254 -- BUG 2670775 Reverse Limits Begin
6255 -- If Limits processing is not installed, no need to proceed further
6256 IF NVL(FND_PROFILE.VALUE('QP_LIMITS_INSTALLED'),'N') = 'N' THEN
6257 oe_debug_pub.add('QP LIMITS NOT installed so no call to QP_UTIL_PUB.Reverse_Limits',1);
6258 RETURN;
6259 END IF;
6260 -- BUG 2670775 Reverse Limits End
6261
6262 l_cons_price_request_code := p_cons_price_request_code;
6263 l_orig_ordered_qty := p_orig_ordered_qty;
6264
6265 IF p_action_code = 'RETURN' THEN
6266 -- Retrieve price_request_code for the current return line and the one it references
6267 OPEN REFERENCED_LINE;
6268 FETCH REFERENCED_LINE INTO
6269 l_ret_price_request_code,l_orig_ordered_qty, l_cons_price_request_code;
6270 CLOSE REFERENCED_LINE;
6271 END IF;
6272
6273 --bug #7491829
6274 IF p_action_code = 'SPLIT_NEW' THEN
6275 -- Retrieve price_request_code for the current child split line and its parent
6276 oe_debug_pub.add('Action code : ' || p_action_code);
6277 OPEN SPLIT_LINE;
6278 FETCH SPLIT_LINE INTO
6279 l_header_id, l_orig_ordered_qty, l_parent_line_id;
6280 CLOSE SPLIT_LINE;
6281 oe_Debug_pub.add('l_header_id : ' || l_header_id);
6282 oe_Debug_pub.add('l_orig_ordered_qty : ' || l_orig_ordered_qty);
6283 oe_Debug_pub.add('l_parent_line_id : ' || l_parent_line_id);
6284
6285 l_ret_price_request_code := 'ONT-' || l_header_id || '-' || p_line_id;
6286 l_cons_price_request_code := 'ONT-' || l_header_id || '-' || l_parent_line_id;
6287 oe_Debug_pub.add('l_ret_price_request_code : ' || l_ret_price_request_code);
6288 oe_Debug_pub.add('l_cons_price_request_code : ' || l_cons_price_request_code);
6289 END IF;
6290 --bug #7491829
6291
6292 IF p_action_code = 'RETURN' and l_ret_price_request_code is NULL THEN
6293 OE_Debug_PUB.Add('NO CALL made to QP_UTIL_PUB.Reverse_Limits ', 1);
6294 OE_DEBUG_PUB.Add('return price_request_code is null so block limits call', 1);
6295 RETURN;
6296 END IF;
6297
6298 --bug#7491829
6299 IF p_action_code = 'SPLIT_NEW' and l_ret_price_request_code is NULL THEN
6300 OE_Debug_PUB.Add('NO CALL made to QP_UTIL_PUB.Reverse_Limits ', 1);
6301 OE_DEBUG_PUB.Add('split line price_request_code is null so block limits call', 1);
6302 END IF;
6303 --bug#7491829
6304
6305 IF l_cons_price_request_code is NULL THEN
6306 OE_Debug_PUB.Add('NO CALL made to QP_UTIL_PUB.Reverse_Limits ', 1);
6307 OE_DEBUG_PUB.Add('consuming price_request_code is null so no limit for reversal', 1);
6308 RETURN;
6309 END IF;
6310
6311 OE_Debug_PUB.Add('Call to QP_UTIL_PUB.Reverse_Limits: action_code is '||p_action_code, 1);
6312 OE_Debug_PUB.Add('Call to QP_UTIL_PUB.Reverse_Limits: price_request_code is '||l_cons_price_request_code, 1);
6313 OE_Debug_PUB.Add('Call to QP_UTIL_PUB.Reverse_Limits: orig_ordered_qty is '||l_orig_ordered_qty, 1);
6314 OE_Debug_PUB.Add('Call to QP_UTIL_PUB.Reverse_Limits: return request code '||l_ret_price_request_code, 1);
6315 OE_Debug_PUB.Add('Call to QP_UTIL_PUB.Reverse_Limits: return qty '||p_returned_qty, 1);
6316
6317 QP_UTIL_PUB.Reverse_Limits (p_action_code => p_action_code,
6318 p_cons_price_request_code => l_cons_price_request_code,
6319 p_orig_ordered_qty => l_orig_ordered_qty,
6320 p_amended_qty => p_amended_qty,
6321 p_ret_price_request_code => l_ret_price_request_code,
6322 p_returned_qty => p_returned_qty,
6323 x_return_status => l_return_status,
6324 x_return_message => l_return_message
6325 );
6326
6327
6328 OE_Debug_PUB.Add('QP_UTIL_PUB.Reverse_Limits returns status of '|| l_return_status, 1);
6329 OE_Debug_PUB.Add('QP_UTIL_PUB.Reverse_Limits returns message of '|| l_return_message , 1);
6330 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6331 OE_Debug_PUB.Add('Error returned by QP_UTIL_PUB.Reverse_Limits',1);
6332 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
6333 RAISE FND_API.G_EXC_ERROR;
6334 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6335 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6336 END IF;
6337 END IF;
6338
6339 --bug 7491829
6340 IF p_action_code = 'SPLIT_NEW' THEN
6341 update oe_order_lines_All
6342 set price_request_code = l_ret_price_request_code
6343 where line_id = p_line_id;
6344 END IF;
6345 --bug 7491829
6346
6347 OE_Debug_PUB.Add('Exiting OE_Delayed_Requests_Util.Reverse_Limits with status of '|| x_return_status, 1);
6348
6349 EXCEPTION
6350 WHEN FND_API.G_EXC_ERROR THEN
6351
6352 x_return_status := FND_API.G_RET_STS_ERROR;
6353
6354 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6355
6356 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6357
6358 WHEN OTHERS THEN
6359
6360 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6361 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6362 THEN
6363 OE_MSG_PUB.Add_Exc_Msg
6364 ( G_PKG_NAME
6365 , 'Reverse_Limits'
6366 );
6367 END IF;
6368
6369 END Reverse_Limits;
6370
6371 Procedure Process_XML_Delayed_Request (p_request_ind IN NUMBER,
6372 x_return_status OUT NOCOPY VARCHAR2)
6373
6374 IS
6375
6376 l_request_rec OE_ORDER_PUB.REQUEST_REC_TYPE;
6377 l_header_id NUMBER;
6378 l_order_source_id NUMBER;
6379 l_orig_sys_document_ref VARCHAR2(50);
6380 l_sold_to_org_id NUMBER;
6381 l_change_sequence VARCHAR2(50);
6382 l_org_id NUMBER;
6383 l_acknowledgment_type VARCHAR2(30);
6384 l_flow_status_code VARCHAR2(30);
6385 l_party_id NUMBER;
6386 l_party_site_id NUMBER;
6387 l_order_number NUMBER;
6388 l_customer_id NUMBER;
6389 l_return_status VARCHAR2(1);
6390 l_line_found VARCHAR2(1) := 'N';
6391 l_line_ids VARCHAR2(2000);
6392 l_count NUMBER;
6393 l_count_old NUMBER;
6394 l_itemkey NUMBER;
6395 l_bulk_line_rec OE_WSH_BULK_GRP.LINE_REC_TYPE;
6396 i PLS_INTEGER := 1;
6397 ctr NUMBER;
6398 l_reciever_code VARCHAR2(1);
6399 l_line_id_tbl Line_ID_List;
6400 Raise_Event_XML BOOLEAN := FALSE;
6401
6402 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6403
6404 Begin
6405
6406
6407 l_request_rec := OE_Delayed_Requests_PVT.G_Delayed_Requests(p_request_ind);
6408 l_header_id := l_request_rec.entity_id;
6409
6410 IF l_debug_level > 0 THEN
6411 oe_debug_pub.add( 'retrieving key information from base table') ;
6412 END IF;
6413
6414 BEGIN
6415 SELECT order_source_id, orig_sys_document_ref, sold_to_org_id, change_sequence
6416 INTO l_order_source_id, l_orig_sys_document_ref, l_sold_to_org_id, l_change_sequence
6417 FROM oe_order_headers
6418 WHERE header_id=l_header_id;
6419 EXCEPTION
6420 WHEN NO_DATA_FOUND THEN
6421 IF l_debug_level > 0 THEN
6422 oe_debug_pub.add( 'EXITING oe_delayed_requests_util.Process_XML_Delayed_Request,header not created' , 1 ) ;
6423 END IF;
6424 RETURN;
6425 END; --exception added for bug16586206
6426
6427 /* to fix issue in bug 3478862, now retrieve key information from base table
6428 l_order_source_id := to_number(l_request_rec.param2);
6429 l_orig_sys_document_ref := l_request_rec.param3;
6430 l_sold_to_org_id := to_number(l_request_rec.param4);
6431 l_change_sequence := l_request_rec.param5;
6432 */
6433
6434 l_org_id := to_number(l_request_rec.param6);
6435 l_acknowledgment_type := l_request_rec.param7;
6436 l_flow_status_code := l_request_rec.param8;
6437 l_party_id := to_number(l_request_rec.param9);
6438 l_party_site_id := to_number(l_request_rec.param10);
6439 l_customer_id := to_number(l_request_rec.param11);
6440 l_reciever_code := l_request_rec.param12;
6441 l_order_number := to_number(l_request_rec.param13);
6442
6443
6444 IF l_debug_level > 0 THEN
6445 oe_debug_pub.add( 'l_reciever_code before:' || l_reciever_code ) ;
6446 END IF;
6447
6448
6449 IF l_reciever_code = FND_API.G_MISS_CHAR OR
6450 l_reciever_code IS NULL THEN
6451 l_reciever_code := 'C';
6452 END IF;
6453
6454 -- l_reciever_code has 3 valid values:
6455 -- C => 'generate customer acknowledgment'
6456 -- P => 'raise product-level integration event'
6457 -- B => do both
6458 -- interpret a passed for acknowledgment_type as signaling a product-level raise event
6459
6460 IF l_acknowledgment_type IS NULL THEN
6461 l_reciever_code := 'P';
6462 END IF;
6463
6464 IF l_debug_level > 0 THEN
6465 oe_debug_pub.add( 'l_reciever_code after:' || l_reciever_code ) ;
6466 END IF;
6467
6468 IF l_request_rec.param1 IS NULL THEN
6469 -- header level request that should acknowledge all lines
6470 IF l_debug_level > 0 THEN
6471 oe_debug_pub.add( 'RAISING HEADER-LEVEL EVENT TO ACK ALL LINES') ;
6472 END IF;
6473
6474
6475 IF l_reciever_code IN ('C', 'B') THEN
6476 IF l_acknowledgment_type in (OE_ACKNOWLEDGMENT_PUB.G_TRANSACTION_SSO, OE_ACKNOWLEDGMENT_PUB.G_TRANSACTION_CSO) THEN
6477
6478 IF l_debug_level > 0 THEN
6479 oe_debug_pub.add( 'SSO or CSO request' ) ;
6480 END IF;
6481 OE_Acknowledgment_Pub.Raise_Event_Showso
6482 (
6483 p_header_id => l_header_id,
6484 p_line_id => Null,
6485 p_customer_id => l_sold_to_org_id,
6486 p_orig_sys_document_ref => l_orig_sys_document_ref,
6487 p_change_sequence => l_change_sequence,
6488 p_itemtype => OE_ORDER_IMPORT_WF.G_WFI_CONC_PGM,
6489 p_party_id => l_party_id,
6490 p_party_site_id => l_party_site_id,
6491 p_transaction_type => l_acknowledgment_type,
6492 p_commit_flag => 'N',
6493 x_return_status => l_return_status
6494 );
6495
6496 ELSIF l_acknowledgment_type = OE_ACKNOWLEDGMENT_PUB.G_TRANSACTION_POI THEN
6497
6498 IF l_debug_level > 0 THEN
6499 oe_debug_pub.add( '3A4 ACK request' ) ;
6500 END IF;
6501 Oe_Acknowledgment_Pub.Raise_Event_From_Oeoi(
6502 p_transaction_type => l_acknowledgment_type,
6503 p_orig_sys_document_ref => l_orig_sys_document_ref,
6504 p_request_id => null,
6505 p_order_imported => 'Y',
6506 p_sold_to_org_id => l_sold_to_org_id,
6507 p_change_sequence => l_change_sequence,
6508 p_org_id => l_org_id,
6509 p_check_for_delivery => 'N',
6510 x_return_status => l_return_status);
6511
6512
6513 END IF;
6514 END IF;
6515
6516
6517
6518 IF l_reciever_code IN ('P', 'B') THEN
6519 -- raise integration event
6520 IF l_debug_level > 0 THEN
6521 oe_debug_pub.add( 'RAISING INTEGRATION EVENT' ) ;
6522 END IF;
6523 OE_Acknowledgment_Pub.Raise_Event_XMLInt (
6524 p_order_source_id => l_order_source_id,
6525 p_partner_document_num => l_orig_sys_document_ref,
6526 p_sold_to_org_id => l_sold_to_org_id,
6527 p_itemtype => NULL,
6528 p_itemkey => NULL,
6529 p_transaction_type => NULL,
6530 p_message_text => NULL,
6531 p_document_num => l_order_number,
6532 p_change_sequence => l_change_sequence,
6533 p_org_id => l_org_id,
6534 p_header_id => l_header_id,
6535 p_subscriber_list => 'DEFAULT',
6536 p_line_ids => 'ALL',
6537 x_return_status => l_return_status);
6538
6539 END IF;
6540
6541
6542 ELSE --do seeding of acknowledgment tables for passed header and line information
6543
6544
6545 IF l_reciever_code IN ('C', 'B') THEN --start of check for customer ack request
6546 select OE_XML_MESSAGE_SEQ_S.nextval
6547 into l_itemkey
6548 from dual;
6549
6550 IF l_debug_level > 0 THEN
6551 oe_debug_pub.add( 'sequence value: ' || l_itemkey) ;
6552 end if;
6553
6554
6555 --insert provided header information into table
6556 IF l_debug_level > 0 THEN
6557 oe_debug_pub.add( 'SEEDEDING HEADER_ID FOR ACKNOWLEDGMENT => ' || l_header_id ) ;
6558 END IF;
6559
6560
6561 Insert Into OE_HEADER_ACKS (header_id, acknowledgment_type, last_ack_code, request_id, sold_to_org_id, change_sequence)
6562 Values (l_header_id, l_acknowledgment_type, l_flow_status_code, l_itemkey,
6563 l_sold_to_org_id, l_change_sequence);
6564
6565 IF l_debug_level > 0 THEN
6566 oe_debug_pub.add( 'AFTER HEADER INSERT') ;
6567 END IF;
6568 END IF; -- end of check for customer ack request
6569
6570
6571 l_count := OE_Delayed_Requests_PVT.G_Delayed_Requests.first;
6572
6573 --find and insert lines for that header
6574 WHILE l_count IS NOT NULL LOOP
6575
6576 --Check to see if this is a line-level xml request for the same transaction type and header id
6577 IF OE_Delayed_Requests_PVT.G_Delayed_Requests(l_count).request_type = OE_GLOBALS.G_GENERATE_XML_REQ_LN
6578 AND OE_Delayed_Requests_PVT.G_Delayed_Requests(l_count).param1 = l_header_id
6579 AND nvl(OE_Delayed_Requests_PVT.G_Delayed_Requests(l_count).param7, 'INT') = nvl(l_acknowledgment_type, 'INT') THEN
6580
6581 -- add this line to the lines table for insertion
6582 IF l_debug_level > 0 THEN
6583 oe_debug_pub.add( 'LINE_ID FOR ACKNOWLEDGMENT => ' || OE_Delayed_Requests_PVT.G_Delayed_Requests(l_count).entity_id ) ;
6584 END IF;
6585
6586 If l_line_found = 'N' then
6587 --set flag to show that a line has been found
6588 l_line_found := 'Y';
6589 End If;
6590
6591 --extend the length of elements in the nested tables
6592
6593 IF l_reciever_code IN ('C', 'B') THEN
6594
6595 l_bulk_line_rec.header_id.extend;
6596 l_bulk_line_rec.line_id.extend;
6597 l_bulk_line_rec.xml_transaction_type_code.extend;
6598 l_bulk_line_rec.last_ack_code.extend;
6599 l_bulk_line_rec.request_id.extend;
6600 l_bulk_line_rec.sold_to_org_id.extend;
6601 l_bulk_line_rec.change_sequence.extend;
6602
6603 l_bulk_line_rec.header_id(i) := l_header_id;
6604 l_bulk_line_rec.line_id(i) := OE_Delayed_Requests_PVT.G_Delayed_Requests(l_count).entity_id;
6605 l_bulk_line_rec.xml_transaction_type_code(i) := l_acknowledgment_type;
6606 l_bulk_line_rec.last_ack_code(i) := OE_Delayed_Requests_PVT.G_Delayed_Requests(l_count).param8;
6607 l_bulk_line_rec.request_id(i) := l_itemkey;
6608 l_bulk_line_rec.sold_to_org_id(i) := to_number(OE_Delayed_Requests_PVT.G_Delayed_Requests(l_count).param4);
6609 l_bulk_line_rec.change_sequence(i) :=OE_Delayed_Requests_PVT. G_Delayed_Requests(l_count).param5;
6610
6611 IF l_debug_level > 0 THEN
6612 oe_debug_pub.add( 'after assignment to bulk record') ;
6613 end if;
6614
6615 END IF;
6616
6617 IF l_reciever_code IN ('P', 'B') THEN
6618 -- 5738023
6619 IF l_debug_level > 0 THEN
6620 oe_debug_pub.add( 'Assigning entity id to line table', 3);
6621 END IF;
6622 l_line_id_tbl(i).line_id := OE_Delayed_Requests_PVT.G_Delayed_Requests(l_count).entity_id;
6623 END IF;
6624
6625 i := i + 1;
6626
6627
6628 l_count_old := l_count;
6629 l_count := OE_Delayed_Requests_PVT.G_Delayed_Requests.Next(l_count);
6630
6631 -- Processing has been done, so delete line-level request now
6632 OE_Delayed_Requests_PVT.G_Delayed_Requests.Delete(l_count_old);
6633
6634 ELSE
6635 l_count := OE_Delayed_Requests_PVT.G_Delayed_Requests.Next(l_count);
6636 END IF;
6637
6638 END LOOP;
6639
6640 IF l_reciever_code IN ('C', 'B') THEN
6641 IF l_line_found = 'Y' THEN
6642 --only do line insert if lines were found
6643
6644 --bulk insert the lines into the lines table
6645 ctr := l_bulk_line_rec.line_id.count;
6646
6647
6648 IF l_debug_level > 0 THEN
6649 oe_debug_pub.add( 'LINE COUNT:' || ctr) ;
6650 oe_debug_pub.add( 'BEFORE BULK INSERT OF LINES') ;
6651 END IF;
6652
6653 FORALL j IN 1..ctr
6654 INSERT INTO OE_LINE_ACKS
6655 (header_id
6656 ,line_id
6657 ,acknowledgment_type
6658 ,last_ack_code
6659 ,request_id
6660 ,sold_to_org_id
6661 ,change_sequence)
6662 VALUES
6663 (l_bulk_line_rec.header_id(j)
6664 ,l_bulk_line_rec.line_id(j)
6665 ,l_acknowledgment_type
6666 ,l_bulk_line_rec.last_ack_code(j)
6667 ,l_bulk_line_rec.request_id(j)
6668 ,l_bulk_line_rec.sold_to_org_id(j)
6669 ,l_bulk_line_rec.change_sequence(j)
6670 );
6671
6672 IF l_debug_level > 0 THEN
6673 oe_debug_pub.add( 'AFTER BULK INSERT OF LINES') ;
6674 END IF;
6675
6676 END IF; --end of l_line_found conditional
6677 END IF;
6678
6679 IF l_reciever_code IN ('C', 'B') THEN
6680 IF l_acknowledgment_type IN (OE_ACKNOWLEDGMENT_PUB.G_TRANSACTION_SSO, OE_ACKNOWLEDGMENT_PUB.G_TRANSACTION_CSO) THEN
6681
6682 IF l_debug_level > 0 THEN
6683 oe_debug_pub.add( 'SSO or CSO request' ) ;
6684 END IF;
6685
6686 OE_Acknowledgment_Pub.Raise_Event_Showso
6687 (
6688 p_header_id => l_header_id,
6689 p_line_id => Null,
6690 p_customer_id => l_sold_to_org_id,
6691 p_orig_sys_document_ref => l_orig_sys_document_ref,
6692 p_change_sequence => l_change_sequence,
6693 p_itemtype => Null,
6694 p_itemkey => l_itemkey,
6695 p_party_id => l_party_id,
6696 p_party_site_id => l_party_site_id,
6697 p_transaction_type => l_acknowledgment_type,
6698 x_return_status => l_return_status
6699 );
6700
6701
6702 ELSIF l_acknowledgment_type = OE_ACKNOWLEDGMENT_PUB.G_TRANSACTION_POI THEN
6703
6704 IF l_debug_level > 0 THEN
6705 oe_debug_pub.add( '3A4 ACK request' ) ;
6706 END IF;
6707 Oe_Acknowledgment_Pub.Raise_Event_From_Oeoi(
6708 p_transaction_type => l_acknowledgment_type,
6709 p_orig_sys_document_ref => l_orig_sys_document_ref,
6710 p_request_id => null,
6711 p_order_imported => 'Y',
6712 p_sold_to_org_id => l_sold_to_org_id,
6713 p_change_sequence => l_change_sequence,
6714 p_org_id => l_org_id,
6715 p_start_from_flow => OE_ORDER_IMPORT_WF.G_WFI_PROC,
6716 p_check_for_delivery => 'N',
6717 x_return_status => l_return_status);
6718
6719 END IF;
6720
6721 END IF;
6722
6723
6724 IF l_reciever_code IN ('P', 'B') THEN
6725 IF l_line_id_tbl.COUNT > 0 THEN --5939693
6726 -- FOR I IN l_line_id_tbl.FIRST..l_line_id_tbl.LAST LOOP Commented for bug 5939693
6727 i := l_line_id_tbl.FIRST;
6728 WHILE i IS NOT NULL LOOP
6729 IF ((length(l_line_ids) + 2 * length(l_line_id_tbl(i).line_id)) > 2000 ) THEN
6730 Raise_Event_XML := TRUE;
6731 ELSE
6732 IF l_line_ids IS NULL THEN
6733 l_line_ids := l_line_id_tbl(i).line_id;
6734 ELSE
6735 l_line_ids := l_line_ids || ':' || l_line_id_tbl(i).line_id;
6736 END IF;
6737 IF I = l_line_id_tbl.LAST THEN
6738 Raise_Event_XML := TRUE;
6739 END IF;
6740 END IF;
6741 IF Raise_Event_XML THEN
6742 IF l_debug_level > 0 THEN
6743 oe_debug_pub.add( 'Raising Event with line id '|| l_line_id_tbl(i).line_id, 3);
6744 oe_debug_pub.add( 'Line_ids:' || l_line_ids, 3);
6745 END IF;
6746
6747 -- raise integration event
6748 OE_Acknowledgment_Pub.Raise_Event_XMLInt (
6749 p_order_source_id => l_order_source_id,
6750 p_partner_document_num => l_orig_sys_document_ref,
6751 p_sold_to_org_id => l_sold_to_org_id,
6752 p_itemtype => NULL,
6753 p_itemkey => NULL,
6754 p_transaction_type => NULL,
6755 p_message_text => NULL,
6756 p_document_num => l_order_number,
6757 p_change_sequence => l_change_sequence,
6758 p_org_id => l_org_id,
6759 p_header_id => l_header_id,
6760 p_subscriber_list => 'DEFAULT',
6761 p_line_ids => l_line_ids,
6762 x_return_status => l_return_status);
6763
6764
6765 IF l_debug_level > 0 THEN
6766 oe_debug_pub.add( 'line ids: ' || l_line_ids ) ;
6767 END IF;
6768 l_line_ids := NULL;
6769 Raise_Event_XML := FALSE;
6770
6771 END IF;
6772 i:=l_line_id_tbl.NEXT(i);
6773 END LOOP;
6774
6775 -- Added for bug #6726949
6776 /* Below code is needed for this new regression bug
6777 ------------------------------------------------ */
6778 ELSE -- l_line_id_tbl.COUNT is 0
6779 IF l_debug_level > 0 THEN
6780 oe_debug_pub.add(' Raising XML Event for Order Header');
6781 END IF;
6782 l_line_ids := NULL;
6783 OE_Acknowledgment_Pub.Raise_Event_XMLInt (
6784 p_order_source_id => l_order_source_id,
6785 p_partner_document_num => l_orig_sys_document_ref,
6786 p_sold_to_org_id => l_sold_to_org_id,
6787 p_itemtype => NULL,
6788 p_itemkey => NULL,
6789 p_transaction_type => NULL,
6790 p_message_text => NULL,
6791 p_document_num => l_order_number,
6792 p_change_sequence => l_change_sequence,
6793 p_org_id => l_org_id,
6794 p_header_id => l_header_id,
6795 p_subscriber_list => 'DEFAULT',
6796 p_line_ids => l_line_ids,
6797 x_return_status => l_return_status);
6798 /* Changes Ends for this new regression bug
6799 ---------------------------------------- */
6800
6801 END IF;
6802 END IF;
6803 END IF;
6804
6805 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6806 IF l_debug_level > 0 THEN
6807 OE_Debug_PUB.Add('ERROR RETURNED BY RAISE_EVENT FOR: ' || l_acknowledgment_type);
6808 END IF;
6809 END IF;
6810
6811
6812 x_return_status := l_return_status;
6813
6814
6815
6816
6817
6818
6819 Exception
6820 When others then
6821 IF l_debug_level > 0 THEN
6822 oe_debug_pub.add( 'IN OTHERS EXCEPTION:' || SQLERRM) ;
6823 END IF;
6824 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6825 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6826 End Process_XML_Delayed_Request;
6827
6828
6829 /* 7576948: IR ISO Change Management project Start */
6830 /*
6831 Procedure Name : Update_Requisition_Info
6832 Input Params : P_Header_id - Primary key of the order header
6833 P_Line_id - Primary key of the order line. This parameter
6834 will be null for order header cancellation
6835 P_Requisition_Header_id - Primary key of the requisition
6836 header
6837 P_Requisition_Line_id - Primary key of the requisition line
6838 p_Line_ids - String variable containing line_ids delimited
6839 by comma ?Q,?R. Will be populated only if it is
6840 a partial order cancellation
6841 p_num_records - Number of total order line records cancelled
6842 while processing partial order cancellation
6843 P_Quantity_Change - It will denote net change in order quantity
6844 with respective single requisition line.
6845 If it is greater than 0 then it is an
6846 increment in the quantity, while if it is
6847 less than 0 then it is a decrement in the
6848 ordered quantity. If it is 0 then it
6849 indicates there is no change in ordered
6850 quantity value
6851 P_New_Schedule_Ship_Date - It will denote the change in
6852 Schedule Ship Date
6853 P_Cancel_Order - It will denote whether internal sales order
6854 is cancelled or not. If it is cancelled then
6855 respective Purchasing api will be called to
6856 trigger the requisition header cancellation.
6857 Output Params : X_Return_Status - The return status of the API
6858 (Expected/Unexpected/Success)
6859 Brief Description : This program unit is added for IR ISO Change
6860 management project, so as to trigger the new
6861 program unit OE_Process_Requisition_Pvt.Updat
6862 e_Internal_Requisition introduced as part of
6863 this project, and responsible for calling several
6864 Purchasing APIs based on the action performed
6865 on the internal sales order header/line.
6866
6867 Possible actions can be:
6868 Header Level FULL Cancellation
6869 Header Level PARTIAL Cancellation
6870 Line Level Cancellation
6871 Line Ordered Quantity update
6872 Line Schedule Ship/Arrival Date update
6873 Line Ordered Quantity and Schedule Ship/Arrival
6874 Date update
6875
6876 -- For details on IR ISO CMS project, please refer to FOL >
6877 -- OM Development > OM GM > 12.1.1 > TDD > IR_ISO_CMS_TDD.doc
6878 */
6879
6880 Procedure Update_Requisition_Info -- Package Body
6881 ( p_header_id IN NUMBER -- Param5 or Entity id
6882 , p_line_id IN NUMBER -- Entity id
6883 , P_Line_ids IN VARCHAR2 -- Long_Param1
6884 , P_num_records IN NUMBER -- Param6
6885 , P_Requisition_Header_id IN NUMBER -- Param3
6886 , P_Requisition_Line_id IN NUMBER DEFAULT NULL -- Param4
6887 , P_Quantity_Change IN NUMBER DEFAULT NULL -- Param1
6888 , P_Quantity2_Change IN NUMBER DEFAULT NULL --Bug 14211120
6889 , P_New_Schedule_Ship_Date IN DATE -- Date_Param1
6890 , P_Cancel_order IN BOOLEAN -- Param2
6891 , x_return_status OUT NOCOPY varchar2
6892 )
6893 IS
6894 --
6895 l_return_status VARCHAR2(30);
6896 l_msg_count NUMBER;
6897 l_msg_data VARCHAR2(2000);
6898 l_new_ord_quantity NUMBER;
6899 l_cancel_line BOOLEAN := FALSE;
6900 l_New_Schedule_Ship_Date DATE;
6901 --
6902 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6903 --
6904 BEGIN
6905 IF l_debug_level > 0 THEN
6906 oe_debug_pub.ADD('Entering delayed request utility for Update_Requisition_Info',1);
6907 oe_debug_pub.ADD(' Header id '||p_header_id,5);
6908 oe_debug_pub.ADD(' Line id '||p_line_id,5);
6909 oe_debug_pub.ADD(' Number of shipment Lines updated '||p_num_records,5);
6910 oe_debug_pub.ADD(' Req Header id '||p_requisition_header_id,5);
6911 oe_debug_pub.ADD(' Req Line id '||p_requisition_line_id,5);
6912 oe_debug_pub.ADD(' Quantity Change '||p_quantity_change,5);
6913 oe_debug_pub.ADD(' New Schedule Ship Date '||p_new_schedule_ship_date,5);
6914 IF p_cancel_order THEN
6915 oe_debug_pub.ADD(' Order Level Cancellation',5);
6916 ELSE
6917 oe_debug_pub.ADD(' Not an Order Level Cancellation',5);
6918 END IF;
6919 END IF;
6920
6921 x_return_status := FND_API.G_RET_STS_SUCCESS;
6922 l_New_Schedule_Ship_Date := p_New_Schedule_Ship_Date;
6923
6924 IF NOT p_Cancel_Order THEN
6925 IF p_line_id IS NULL THEN
6926 IF l_debug_level > 0 THEN
6927 oe_debug_pub.add(' Invalid processing since Line_id is null for non-order header cancellation',1);
6928 END IF;
6929 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6930 END IF;
6931 Begin
6932 select nvl(ordered_quantity,0)
6933 into l_new_ord_quantity
6934 from oe_order_lines_all
6935 where line_id = p_line_id;
6936 End;
6937 IF l_new_ord_quantity = 0 THEN
6938 IF l_debug_level > 0 THEN
6939 oe_debug_pub.ADD(' Line is cancelled, cancel the Requisition Line',5);
6940 END IF;
6941 l_cancel_line := TRUE;
6942 END IF;
6943 END IF; -- Not P_Cancel_Order
6944
6945 OE_Process_Requisition_Pvt.Update_Internal_Requisition
6946 ( P_Header_id => p_header_id
6947 , P_Line_id => p_line_id
6948 , p_line_ids => p_line_ids
6949 , p_num_records => p_num_records
6950 , P_Req_Header_id => P_Requisition_Header_id
6951 , P_Req_Line_id => P_Requisition_Line_id
6952 , P_Quantity_Change => P_Quantity_Change
6953 , P_Quantity2_Change => P_Quantity2_Change --Bug 14211120
6954 , P_New_Schedule_Ship_Date => l_New_Schedule_Ship_Date
6955 , P_Cancel_Order => P_Cancel_order
6956 , P_Cancel_line => l_cancel_line
6957 , X_msg_count => l_msg_count
6958 , X_msg_data => l_msg_data
6959 , X_return_status => l_return_status
6960 );
6961
6962 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6963 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6964 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6965 RAISE FND_API.G_EXC_ERROR;
6966 END IF;
6967
6968 X_return_status := l_return_status;
6969
6970 IF l_debug_level > 0 THEN
6971 oe_debug_pub.ADD('Exiting delayed request utility for Update_Requisition_Info',1);
6972 END IF;
6973 EXCEPTION
6974 WHEN FND_API.G_EXC_ERROR THEN
6975 x_return_status := FND_API.G_RET_STS_ERROR;
6976 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6977 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6978 WHEN OTHERS THEN
6979 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6980 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
6981 OE_MSG_PUB.Add_Exc_Msg
6982 ( G_PKG_NAME
6983 , 'Update_Requisition_Info'
6984 );
6985 END IF;
6986 END Update_Requisition_Info;
6987
6988
6989 /* ============================= */
6990 /* IR ISO Change Management Ends */
6991
6992 -- This new procedure is added for DOO Pre Exploded Kit ER 9339742
6993 PROCEDURE Process_Pre_Exploded_Kits
6994 ( p_top_model_line_id IN NUMBER
6995 , p_explosion_date IN DATE
6996 , x_return_status OUT NOCOPY VARCHAR2
6997 ) IS
6998 --
6999 l_return_status VARCHAR2(30);
7000 --
7001 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
7002 --
7003 BEGIN
7004
7005 if l_debug_level > 0 then
7006 oe_debug_pub.add(' Entering OE_Delayed_Requests_Util.Process_Pre_Exploded_Kits',1);
7007 oe_debug_pub.add(' Top Model Line_id is : '||p_top_model_line_id,5);
7008 oe_debug_pub.add(' Explosion Date is : '||p_explosion_date,5);
7009 end if;
7010
7011 OE_Config_Util.Process_Pre_Exploded_Kits
7012 ( p_top_model_line_id => p_top_model_line_id
7013 , p_explosion_date => p_explosion_date
7014 , x_return_status => l_return_status);
7015
7016 x_return_status := l_return_status;
7017
7018 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7019 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7020 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
7021 RAISE FND_API.G_EXC_ERROR;
7022 END IF;
7023
7024 if l_debug_level > 0 then
7025 oe_debug_pub.add(' Exiting OE_Delayed_Requests_Util.Process_Pre_Exploded_Kits',1);
7026 end if;
7027
7028 EXCEPTION
7029 WHEN FND_API.G_EXC_ERROR THEN
7030 x_return_status := FND_API.G_RET_STS_ERROR;
7031 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7032 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7033 WHEN OTHERS THEN
7034 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7035 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
7036 OE_MSG_PUB.Add_Exc_Msg
7037 ( G_PKG_NAME
7038 , 'Process_Pre_Exploded_Kits'
7039 );
7040 END IF;
7041 END Process_Pre_Exploded_Kits;
7042 -- End DOO Pre Exploded Kit ER 9339742
7043
7044
7045
7046 END OE_Delayed_Requests_UTIL;