[Home] [Help]
PACKAGE BODY: APPS.OE_ORDER_ADJ_PVT
Source
1 PACKAGE BODY oe_order_adj_pvt AS
2 /* $Header: OEXVADJB.pls 120.13.12010000.10 2008/12/31 09:35:00 amimukhe ship $ */
3
4 G_DEBUG BOOLEAN;
5 G_Pricing_Phase_Id_Tbl Char_Tbl_Type;
6 G_11iG_PERFORMANCE varchar2(1)
7 := nvl(fnd_profile.value('ONT_11IG_PERFORMANCE'),'Y');
8 G_CHARGES_FOR_INCLUDED_ITEM Varchar2(1) := nvl(fnd_profile.value('ONT_CHARGES_FOR_INCLUDED_ITEM'),'N');
9 G_REQUEST_ID NUMBER:=NULL;
10 G_ORDER_CURRENCY VARCHAR2(30);
11 G_IPL_ERRORS_TBL Index_Tbl_Type;
12
13
14 procedure Adj_Debug (p_text IN VARCHAR2, p_dummy IN NUMBER:=0) As
15 Begin
16 If G_DEBUG Then
17 oe_debug_pub.add(p_text,3);
18 End If;
19 End;
20
21 --btea perf end
22
23
24 Function get_version Return Varchar2 is
25 Begin
26
27 Return('/* $Header: OEXVADJB.pls 120.13.12010000.10 2008/12/31 09:35:00 amimukhe ship $ */');
28
29 End;
30
31 -- BLANKETS: Start Code Merge, Local Functions
32
33 Function Get_List_Type (p_price_list_id in number)
34 Return VARCHAR2
35 IS
36 l_list_type VARCHAR2(30);
37 Begin
38
39 SELECT list_type_code
40 INTO l_list_type
41 FROM QP_LIST_HEADERS
42 WHERE LIST_HEADER_ID = p_price_list_id;
43
44 RETURN l_list_type;
45
46 Exception
47 WHEN OTHERS THEN
48 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
49 THEN
50 OE_MSG_PUB.Add_Exc_Msg
51 ( G_PKG_NAME
52 , 'Get_List_Type'
53 );
54 END IF;
55 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
56 End Get_List_Type;
57
58 Function Get_Enforce_Price_List
59 (p_blanket_number in number
60 ,p_blanket_line_number in number)
61 Return VARCHAR2
62 IS
63 l_flag VARCHAR2(1);
64 Begin
65
66 SELECT enforce_price_list_flag
67 INTO l_flag
68 FROM OE_BLANKET_LINES_EXT E
69 WHERE E.ORDER_NUMBER = p_blanket_number
70 AND E.LINE_NUMBER = p_blanket_line_number;
71
72 RETURN l_flag;
73
74 Exception
75 WHEN OTHERS THEN
76 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
77 THEN
78 OE_MSG_PUB.Add_Exc_Msg
79 ( G_PKG_NAME
80 , 'Get_Enforce_Price_List'
81 );
82 END IF;
83 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
84 End Get_Enforce_Price_List;
85
86 -- BLANKETS: End Code Merge, Local Functions
87
88
89 --As per discussion with AMY and RAVI
90 --If error occurs from pricing engine we need to look at pricing temp table
91 --copy the temp table unit selling price to the line
92 Procedure Reset_Fields(p_line_rec in Oe_Order_Pub.Line_Rec_Type)As
93
94 Cursor get_price(p_line_id in Number) is
95 Select Unit_Price,
96 Adjusted_Unit_Price,
97 priced_quantity,
98 priced_uom_code
99 From QP_PREQ_LINES_TMP
100 Where Line_Id = p_line_id;
101
102 Cursor c_line(p_line_id in Number) is
103 Select line_id,
104 blanket_number,
105 blanket_line_number,
106 unit_selling_price,
107 ordered_quantity,
108 order_quantity_uom,
109 inventory_item_id,
110 line_set_id,
111 fulfilled_flag,
112 header_id,
113 line_category_code,
114 commitment_id,
115 transaction_phase_code --for bug 3108881
116 From OE_ORDER_LINES
117 Where Line_Id = p_line_id;
118
119 l_qp_unit_price Number;
120 l_qp_adjusted_unit_price Number;
121 l_pricing_quantity Number;
122 l_pricing_quantity_uom Varchar2(15);
123 l_unit_price Number;
124 l_selling_price Number;
125 l_tax_value Number;
126
127 l_return_status Varchar2(30);
128 --
129 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
130 --
131
132 Begin
133 oe_debug_pub.add('Entering Reset Field:line_id:'||(p_line_rec.line_id));
134 open get_price(p_line_rec.line_id);
135 fetch get_price into l_qp_unit_price,
136 l_qp_adjusted_unit_price,
137 l_pricing_quantity,
138 l_pricing_quantity_uom;
139 close get_price;
140
141 If l_qp_adjusted_unit_price is not null OR
142 l_qp_unit_price is not null Then
143 If nvl(p_line_rec.ordered_quantity,0) <> 0 Then
144 If OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
145 l_unit_price := Null;
146 l_selling_price := Null;
147 l_qp_unit_price := Null;
148 l_qp_adjusted_unit_price := Null;
149 else
150 l_unit_price :=
151 (l_qp_unit_price * p_line_rec.pricing_quantity)/ p_line_rec.ordered_quantity;
152 l_selling_price :=
153 (l_qp_adjusted_unit_price * p_line_rec.pricing_quantity)/ p_line_rec.ordered_quantity;
154 end if;
155 Else
156 l_unit_price := Null;
157 l_selling_price := Null;
158 End If;
159
160 End If;
161
162 -- Bug 2757443, need to set tax value accordingly if unit selling
163 -- price gets set to null.
164 IF l_selling_price is null THEN
165 l_tax_value := null;
166 ELSE
167 l_tax_value := p_line_rec.tax_value;
168 END IF;
169
170 -- BUG 2746595 => if a valid price list is not found when currency is updated,
171 -- the price list and price is nulled out in this procedure. This should log
172 -- a request to update the total released amount on the blanket.
173 -- BLANKETS: log request to update blanket amounts if price changes
174 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110509'
175 THEN
176
177 FOR update_line IN c_line(p_line_rec.line_id) LOOP
178
179 IF update_line.line_category_code = 'ORDER'
180 AND update_line.blanket_number IS NOT NULL
181 THEN
182
183 IF l_debug_level > 0 THEN
184 oe_debug_pub.add('OEXVADJB log blanket request');
185 oe_debug_pub.add('old SP :'||update_line.unit_selling_price);
186 oe_debug_pub.add('new SP :'||l_selling_price);
187 END IF;
188
189 OE_Order_Cache.Load_Order_Header(update_line.header_id);
190 --for bug 3108881.Log the request for Orders only
191 IF nvl(update_line.transaction_phase_code,'F') = 'F' THEN
192
193 OE_Delayed_Requests_Pvt.Log_Request
194 (p_entity_code => OE_GLOBALS.G_ENTITY_ALL
195 ,p_entity_id => update_line.line_id
196 ,p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE
197 ,p_requesting_entity_id => update_line.line_id
198 ,p_request_type => OE_GLOBALS.G_PROCESS_RELEASE
199 -- Old values
200 ,p_param1 => update_line.blanket_number
201 ,p_param2 => update_line.blanket_line_number
202 ,p_param3 => update_line.ordered_quantity
203 ,p_param4 => update_line.order_quantity_uom
204 ,p_param5 => update_line.unit_selling_price
205 ,p_param6 => update_line.inventory_item_id
206 -- New values
207 ,p_param11 => update_line.blanket_number
208 ,p_param12 => update_line.blanket_line_number
209 ,p_param13 => update_line.ordered_quantity
210 ,p_param14 => update_line.order_quantity_uom
211 ,p_param15 => l_selling_price
212 ,p_param16 => update_line.inventory_item_id
213 -- Other parameters
214 ,p_param8 => update_line.fulfilled_flag
215 ,p_param9 => update_line.line_set_id
216 ,p_request_unique_key1 =>
217 OE_Order_Cache.g_header_rec.transactional_curr_code
218 ,x_return_status => l_return_status
219 );
220
221 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
222 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
223 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
224 RAISE FND_API.G_EXC_ERROR;
225 END IF;
226
227 IF update_line.line_set_id IS NOT NULL THEN
228 OE_Delayed_Requests_Pvt.Log_Request
229 (p_entity_code => OE_GLOBALS.G_ENTITY_ALL
230 ,p_entity_id => update_line.line_set_id
231 ,p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE
232 ,p_requesting_entity_id => update_line.line_id
233 ,p_request_type => 'VALIDATE_RELEASE_SHIPMENTS'
234 ,p_request_unique_key1 => update_line.blanket_number
235 ,p_request_unique_key2 => update_line.blanket_line_number
236 ,p_param1 =>
237 OE_Order_Cache.g_header_rec.transactional_curr_code
238 ,x_return_status => l_return_status
239 );
240 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
241 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
242 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
243 RAISE FND_API.G_EXC_ERROR;
244 END IF;
245 END IF;
246 END IF;--End of check for order/quote
247
248 END IF; -- End of log blanket request for release order line
249
250 -- bug 2757443.
251 IF update_line.commitment_id IS NOT NULL
252 AND OE_Commitment_Pvt.Do_Commitment_Sequencing THEN
253
254 oe_debug_pub.add('Logging delayed request for Commitment.', 2);
255 OE_Delayed_Requests_Pvt.Log_Request(
256 p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
257 p_entity_id => update_line.line_id,
258 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
259 p_requesting_entity_id => update_line.line_id,
260 p_request_type => OE_GLOBALS.G_CALCULATE_COMMITMENT,
261 x_return_status => l_return_status);
262
263 END IF;
264
265
266 END LOOP; -- End of loop to fetch line fields
267
268 END IF; -- End of check for code release level
269
270 Update Oe_Order_Lines
271 Set Unit_Selling_Price= l_selling_price,
272 Unit_List_Price = l_unit_price,
273 unit_selling_price_per_pqty = l_qp_adjusted_unit_price,
274 unit_list_price_per_pqty = l_qp_unit_price,
275 pricing_quantity = l_pricing_quantity,
276 pricing_quantity_uom = l_pricing_quantity_uom,
277 tax_value = l_tax_value,
278 lock_control = lock_control +1
279 Where Line_id = p_line_rec.line_id;
280
281 --Delete all related adjustments
282 oe_line_adj_util.delete_row(p_line_id => p_line_rec.line_id);
283
284 --set cascade flag to reflect changes.
285 OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
286 Oe_Debug_Pub.add('Leaving reset_fields');
287 Exception When Others Then
288 Oe_Debug_Pub.add('In procedure reset_fields:'||SQLERRM);
289 End;
290
291
292 Function Get_List_Lines (p_line_id Number) Return Varchar2 As
293 Cursor list_lines_no is
294 Select c.name,
295 a.list_line_no
296 From qp_preq_ldets_tmp a,
297 qp_preq_lines_tmp b,
298 qp_list_headers_vl c
299 Where b.line_id = p_line_id
300 And b.line_index = a.line_index
301 And a.created_from_list_header_id = c.list_header_id
302 And a.automatic_flag = 'Y'
303 And a.pricing_status_code = 'N'
304 And a.created_from_list_line_type <> 'PLL';
305
306 l_list_line_nos Varchar2(2000):=' ';
307 l_sperator Varchar2(1):='';
308 Begin
309 For i in List_Lines_no Loop
310 l_list_line_nos := i.name||':'||i.list_line_no||l_sperator||l_list_line_nos;
311 l_sperator := ',';
312 End Loop;
313 Return l_list_line_nos;
314 End;
315
316
317 PROCEDURE Header_Adjs
318 ( p_init_msg_list IN VARCHAR2:=FND_API.G_FALSE
319 , p_validation_level IN NUMBER
320 , p_control_rec IN OE_GLOBALS.Control_Rec_Type
321 , p_x_Header_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Tbl_Type
322 , p_x_old_Header_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Tbl_Type
323 )
324 IS
325 l_return_status VARCHAR2(1);
326 l_control_rec OE_GLOBALS.Control_Rec_Type;
327 l_Header_Adj_rec OE_Order_PUB.Header_Adj_Rec_Type;
328 l_old_Header_Adj_rec OE_Order_PUB.Header_Adj_Rec_Type;
329 -- local variables to store OUT parameters from security check procedures
330 l_sec_result NUMBER;
331 l_on_operation_action NUMBER;
332 I pls_integer; -- Used as index for while loop
333 --
334 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
335 --
336 l_order_source_id NUMBER;
337 l_orig_sys_document_ref VARCHAR2(50);
338 l_change_sequence VARCHAR2(50);
339 l_source_document_type_id NUMBER;
340 l_source_document_id NUMBER;
341
342 BEGIN
343
344 IF l_debug_level > 0 THEN
345 G_DEBUG:=TRUE;
346 END IF;
347
348 oe_order_pvt.set_recursion_mode(p_Entity_Code => 3,
349 p_In_out => 1);
350
351 IF FND_API.to_Boolean(p_init_msg_list) THEN
352 OE_MSG_PUB.initialize;
353 END IF;
354
355 IF l_control_rec.Process_Partial THEN
356 SAVEPOINT Header_Adjs;
357 END IF;
358
359 -- Init local table variables.
360
361 adj_debug('Entering oe_order_Adj_pvt.HEADER_ADJS', 1);
362
363
364 -- FOR I IN 1..p_x_Header_Adj_tbl.COUNT LOOP
365
366 I := p_x_header_adj_tbl.FIRST;
367
368 WHILE I IS NOT NULL LOOP
369 BEGIN
370
371 -- Load local records.
372
373 l_Header_Adj_rec := p_x_header_adj_tbl(I);
374
375 IF p_x_old_Header_Adj_tbl.EXISTS(I) THEN
376 l_old_Header_Adj_rec := p_x_old_Header_Adj_tbl(I);
377 ELSE
378 l_old_Header_Adj_rec := OE_Order_PUB.G_MISS_HEADER_ADJ_REC;
379 END IF;
380
381 if l_old_header_adj_rec.price_adjustment_id = FND_API.G_MISS_NUM then
382
383 IF l_header_adj_rec.header_Id IS NOT NULL AND
384 l_header_adj_rec.header_Id <> FND_API.G_MISS_NUM THEN
385 BEGIN
386 IF l_debug_level > 0 THEN
387 oe_debug_pub.add('Getting reference data for header_id:'||l_header_adj_rec.header_Id);
388 END IF;
389 SELECT order_source_id, orig_sys_document_ref, change_sequence,
390 source_document_type_id, source_document_id
391 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
392 l_source_document_type_id, l_source_document_id
393 FROM OE_ORDER_HEADERS_ALL
394 WHERE header_id = l_header_adj_rec.header_Id;
395 EXCEPTION
396 WHEN NO_DATA_FOUND THEN
397 l_order_source_id := null;
398 l_orig_sys_document_ref := null;
399 l_change_sequence := null;
400 l_source_document_type_id := null;
401 l_source_document_id := null;
402 WHEN OTHERS THEN
403 l_order_source_id := null;
404 l_orig_sys_document_ref := null;
405 l_change_sequence := null;
406 l_source_document_type_id := null;
407 l_source_document_id := null;
408 END;
409 END IF;
410
411 OE_MSG_PUB.set_msg_context(
412 p_entity_code => 'HEADER_ADJ'
413 ,p_entity_id => l_header_adj_rec.price_adjustment_id
414 ,p_header_id => l_header_adj_rec.header_Id
415 ,p_line_id => null
416 ,p_order_source_id => l_order_source_id
417 ,p_orig_sys_document_ref => l_orig_sys_document_ref
418 ,p_orig_sys_document_line_ref => null
419 ,p_change_sequence => l_change_sequence
420 ,p_source_document_type_id => l_source_document_type_id
421 ,p_source_document_id => l_source_document_id
422 ,p_source_document_line_id => null );
423
424 else
425
426 IF l_old_header_adj_rec.header_Id IS NOT NULL AND
427 l_old_header_adj_rec.header_Id <> FND_API.G_MISS_NUM THEN
428
429 BEGIN
430 IF l_debug_level > 0 THEN
431 oe_debug_pub.add('Getting reference data for old header_id:'||l_old_header_adj_rec.header_id);
432 END IF;
433 SELECT order_source_id, orig_sys_document_ref, change_sequence,
434 source_document_type_id, source_document_id
435 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
436 l_source_document_type_id, l_source_document_id
437 FROM OE_ORDER_HEADERS_ALL
438 WHERE header_id = l_old_header_adj_rec.header_id;
439 EXCEPTION
440 WHEN NO_DATA_FOUND THEN
441 l_order_source_id := null;
442 l_orig_sys_document_ref := null;
443 l_change_sequence := null;
444 l_source_document_type_id := null;
445 l_source_document_id := null;
446 WHEN OTHERS THEN
447 l_order_source_id := null;
448 l_orig_sys_document_ref := null;
449 l_change_sequence := null;
450 l_source_document_type_id := null;
451 l_source_document_id := null;
452 END;
453 END IF;
454
455 OE_MSG_PUB.set_msg_context(
456 p_entity_code => 'HEADER_ADJ'
457 ,p_entity_id => l_old_header_adj_rec.price_adjustment_id
458 ,p_header_id => l_old_header_adj_rec.header_Id
459 ,p_line_id => null
460 ,p_order_source_id => l_order_source_id
461 ,p_orig_sys_document_ref => l_orig_sys_document_ref
462 ,p_orig_sys_document_line_ref => null
463 ,p_change_sequence => l_change_sequence
464 ,p_source_document_type_id => l_source_document_type_id
465 ,p_source_document_id => l_source_document_id
466 ,p_source_document_line_id => null );
467
468 end if;
469
470 -- Load API control record
471
472 l_control_rec := OE_GLOBALS.Init_Control_Rec
473 ( p_operation => l_Header_Adj_rec.operation
474 , p_control_rec => p_control_rec
475 );
476
477 -- Set record return status.
478
479 l_Header_Adj_rec.return_status := FND_API.G_RET_STS_SUCCESS;
480 p_x_Header_Adj_tbl(I).return_status := FND_API.G_RET_STS_SUCCESS;
481
482 -- Prepare record.
483
484 IF l_Header_Adj_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
485
486 l_Header_Adj_rec.db_flag := FND_API.G_FALSE;
487
488 -- Set missing old record elements to NULL.
489
490 adj_debug('Entering OE_Header_Adj_Util.Convert_Miss_To_Null', 1);
491 /* change to nocopy procedure
492 l_old_Header_Adj_rec :=
493 OE_Header_Adj_Util.Convert_Miss_To_Null (l_old_Header_Adj_rec);
494 */
495 OE_Header_Adj_Util.Convert_Miss_To_Null(l_old_Header_Adj_rec);
496
497 ELSIF l_Header_Adj_rec.operation = OE_GLOBALS.G_OPR_UPDATE
498 OR l_Header_Adj_rec.operation = OE_GLOBALS.G_OPR_DELETE
499 THEN
500
501 l_Header_Adj_rec.db_flag := FND_API.G_TRUE;
502
503 -- Query Old if missing
504
505 IF l_old_Header_Adj_rec.price_adjustment_id = FND_API.G_MISS_NUM
506 OR l_old_Header_Adj_rec.price_adjustment_id IS NULL
507 THEN
508
509 OE_Header_Adj_Util.Query_Row
510 ( p_price_adjustment_id => l_Header_Adj_rec.price_adjustment_id
511 , x_Header_Adj_Rec => l_old_Header_Adj_rec
512 );
513 p_x_old_Header_Adj_tbl(I) := l_old_Header_Adj_rec;
514
515 ELSE
516
517 -- Set missing old record elements to NULL.
518
519 -- l_old_Header_Adj_rec :=
520 OE_Header_Adj_Util.Convert_Miss_To_Null (l_old_Header_Adj_rec);
521
522 END IF;
523
524 -- Complete new record from old
525
526 -- l_Header_Adj_rec :=
527 OE_Header_Adj_Util.Complete_Record
528 ( p_x_Header_Adj_rec => l_Header_Adj_rec
529 , p_old_Header_Adj_rec => l_old_Header_Adj_rec
530 );
531
532 OE_MSG_PUB.update_msg_context(
533 p_entity_code => 'HEADER_ADJ'
534 ,p_entity_id => l_header_adj_rec.price_adjustment_id
535 ,p_header_id => l_header_adj_rec.header_Id);
536
537 END IF;
538
539 IF I = p_x_header_adj_tbl.FIRST THEN
540 IF NOT oe_order_pvt.Valid_Upgraded_Order(l_header_adj_rec.header_id) THEN
541 RAISE FND_API.G_EXC_ERROR;
542 END IF;
543 END IF;
544
545 -- Check security
546 IF l_control_rec.check_security
547 AND (l_header_adj_rec.operation = OE_GLOBALS.G_OPR_CREATE
548 OR l_header_adj_rec.operation = OE_GLOBALS.G_OPR_UPDATE)
549 THEN
550
551 adj_debug('Check Attributes Security');
552 -- check if this operation is allowed
553 -- on all the changed attributes
554 OE_Header_Adj_Security.Attributes
555 (p_header_adj_rec => l_header_adj_rec
556 , p_old_header_adj_rec => l_old_header_adj_rec
557 , x_result => l_sec_result
558 , x_return_status => l_return_status
559 );
560
561 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
562 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
563 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
564 RAISE FND_API.G_EXC_ERROR;
565 END IF;
566
567 IF l_sec_result = OE_PC_GLOBALS.YES THEN
568 RAISE FND_API.G_EXC_ERROR;
569 END IF;
570
571 END IF;
572
573 -- Attribute level validation.
574
575 IF p_validation_level > FND_API.G_VALID_LEVEL_NONE THEN
576
577 OE_Validate_Header_Adj.Attributes
578 ( x_return_status => l_return_status
579 , p_Header_Adj_rec => l_Header_Adj_rec
580 , p_old_Header_Adj_rec => l_old_Header_Adj_rec
581 );
582
583 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
584 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
585 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
586 RAISE FND_API.G_EXC_ERROR;
587 END IF;
588
589 END IF;
590
591
592 -- Clear dependent attributes.
593
594 IF l_control_rec.clear_dependents THEN
595
596 OE_Header_Adj_Util.Clear_Dependent_Attr
597 ( p_x_Header_Adj_rec => l_Header_Adj_rec
598 , p_old_Header_Adj_rec => l_old_Header_Adj_rec
599 --, x_Header_Adj_rec => l_Header_Adj_rec
600 );
601
602 END IF;
603
604 -- Default missing attributes
605
606 IF l_control_rec.default_attributes
607 THEN
608
609 OE_Default_Header_Adj.Attributes
610 ( p_x_Header_Adj_rec => l_Header_Adj_rec
611 , p_old_header_adj_rec => l_old_header_adj_rec
612 --, x_Header_Adj_rec => l_Header_Adj_rec
613 );
614 null;
615
616 END IF;
617
618 -- Apply attribute changes
619
620 IF l_control_rec.change_attributes
621 THEN
622
623 -- This will also log request/s to check duplicity of
624 -- price adjustment entered
625 OE_Header_Adj_Util.Apply_Attribute_Changes
626 ( p_x_Header_Adj_rec => l_Header_Adj_rec
627 , p_old_Header_Adj_rec => l_old_Header_Adj_rec
628 --, x_Header_Adj_rec => l_Header_Adj_rec
629 );
630
631 END IF;
632
633 -- If there has any activity causing a change in any attribute
634 -- log a request for repricing
635
636 -- Entity level validation.
637
638 IF l_control_rec.validate_entity THEN
639
640 IF l_Header_Adj_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
641
642 OE_Validate_Header_Adj.Entity_Delete
643 ( x_return_status => l_return_status
644 , p_Header_Adj_rec => l_Header_Adj_rec
645 );
646
647 ELSE
648
649 OE_Validate_Header_Adj.Entity
650 ( x_return_status => l_return_status
651 , p_Header_Adj_rec => l_Header_Adj_rec
652 , p_old_Header_Adj_rec => l_old_Header_Adj_rec
653 );
654
655 END IF;
656
657 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
658 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
659 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
660 RAISE FND_API.G_EXC_ERROR;
661 END IF;
662
663 END IF;
664
665 -- Check entity level security again as some attributes
666 -- may have changed due to defaulting.
667 --IF l_control_rec.check_security THEN
668 --bug5467785
669 IF NOT (l_Header_Adj_rec.operation = OE_GLOBALS.G_OPR_UPDATE
670 AND OE_Header_Adj_Security.g_check_all_cols_constraint = 'Y')
671 AND l_control_rec.check_security THEN
672
673 adj_debug('Check Entity Security');
674
675 OE_Header_Adj_Security.Entity
676 (p_header_adj_rec => l_header_adj_rec
677 , x_result => l_sec_result
678 , x_return_status => l_return_status
679 );
680
681 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
682 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
683 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
684 RAISE FND_API.G_EXC_ERROR;
685 END IF;
686
687 IF l_sec_result = OE_PC_GLOBALS.YES THEN
688 RAISE FND_API.G_EXC_ERROR;
689 END IF;
690
691 END IF;
692
693 -- Step 4. Write to DB
694
695 IF l_control_rec.write_to_db THEN
696
697 /* Start AuditTrail */
698 OE_DEBUG_PUB.add('OEXVADJB:calling to insert audit history reason for header adj in pre_write_process', 2);
699
700 Oe_Header_ADJ_Util.Pre_Write_Process
701 (p_x_header_adj_rec => l_header_adj_rec,
702 p_old_header_adj_rec => l_old_header_adj_rec);
703
704 oe_debug_pub.add('OEXVADJB:After calling to insert audit history');
705 /* End AuditTrail */
706
707 IF l_Header_Adj_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
708
709 OE_Header_Adj_Util.Delete_Row
710 ( p_price_adjustment_id => l_Header_Adj_rec.price_adjustment_id
711 );
712
713 -- Log a delayed request to cause repricing due to deleted
714 -- record
715 -- NOTE: Requesting entity is header, not header adj. as the adj. itself
716 -- has been deleted and this request should be deleted when the order is
717 -- deleted. Should be revisited if the entity logged against is changed
718 -- to header.
719 IF OE_Globals.G_RECURSION_MODE <> 'Y' AND
720 l_header_adj_rec.list_line_type_code NOT IN ('COST','TAX')
721 then
722
723 adj_debug('Log header level PRICE_ADJ');
724 oe_delayed_requests_pvt.log_request(p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
725 p_entity_id => l_header_adj_rec.Header_id,
726 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_HEADER,
727 p_requesting_entity_id => l_header_adj_rec.HEader_id,
728 p_request_type => OE_GLOBALS.G_PRICE_ADJ,
729 x_return_status => l_return_status);
730 End If;
731
732 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
733 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
734 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
735 RAISE FND_API.G_EXC_ERROR;
736 END IF;
737
738 ELSE
739
740 -- Get Who Information
741
742 l_Header_Adj_rec.last_update_date := SYSDATE;
743 l_Header_Adj_rec.last_updated_by := FND_GLOBAL.USER_ID;
744 l_Header_Adj_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
745
746 IF l_Header_Adj_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
747
748 OE_Header_Adj_Util.Update_Row (l_Header_Adj_rec);
749
750 ELSIF l_Header_Adj_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
751
752 l_Header_Adj_rec.creation_date := SYSDATE;
753 l_Header_Adj_rec.created_by := FND_GLOBAL.USER_ID;
754
755 OE_Header_Adj_Util.Insert_Row (l_Header_Adj_rec);
756
757 END IF;
758
759 END IF;
760
761 END IF;
762
763 -- Load tables.
764
765 p_x_header_adj_tbl(I) := l_Header_Adj_rec;
766 p_x_old_Header_Adj_tbl(I) := l_old_Header_Adj_rec;
767
768 IF l_header_adj_rec.return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
769 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
770 ELSIF l_header_adj_rec.return_status = FND_API.G_RET_STS_ERROR THEN
771 RAISE FND_API.G_EXC_ERROR;
772 END IF;
773
774 OE_Header_Adj_Security.g_check_all_cols_constraint := 'Y';
775 OE_MSG_PUB.reset_msg_context('HEADER_ADJ');
776 -- loop exception handler.
777
778
779
780
781 --
782 -- Start : Changes made as a part of DBI ER # 4185227
783 --
784 IF l_debug_level > 0 THEN
785 oe_debug_pub.add( 'CALLING OE_DBI_UTIL FOR HEADER PRICE ADJUSTMENTS' , 1 ) ;
786 oe_debug_pub.add( 'CACHED VALUE' || OE_ORDER_CACHE.G_HEADER_REC.BOOKED_FLAG ) ;
787 oe_debug_pub.add( 'RECURSION VALUE' || OE_ORDER_UTIL.G_RECURSION_WITHOUT_EXCEPTION ) ;
788 oe_debug_pub.add( 'PROFILE VALUE' || FND_PROFILE.VALUE ( 'ONT_DBI_INSTALLED' ) ) ;
789 END IF;
790
791 IF NVL(FND_PROFILE.VALUE('ONT_DBI_INSTALLED'), 'N') = 'Y' AND
792 oe_order_cache.g_header_rec.booked_flag = 'Y' AND
793 oe_order_util.g_recursion_without_exception = 'N' AND
794 l_control_rec.write_to_db
795 THEN
796
797 OE_DBI_UTIL.Update_DBI_Log( x_return_status => l_return_status);
798
799 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
800 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
801 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
802 RAISE FND_API.G_EXC_ERROR;
803 END IF;
804 END IF;
805
806 --
807 -- End : Changes made as a part of DBI ER # 4185227
808 --
809
810
811 EXCEPTION
812
813 WHEN FND_API.G_EXC_ERROR THEN
814
815 l_Header_Adj_rec.return_status := FND_API.G_RET_STS_ERROR;
816 p_x_header_adj_tbl(I) := l_Header_Adj_rec;
817 p_x_old_Header_Adj_tbl(I) := l_old_Header_Adj_rec;
818 OE_Header_Adj_Security.g_check_all_cols_constraint := 'Y';
819 OE_MSG_PUB.reset_msg_context('HEADER_ADJ');
820 oe_delayed_requests_pvt.delete_request(p_entity_code =>OE_GLOBALS.G_ENTITY_HEADER_ADJ,
821 p_entity_id => l_header_adj_rec.Price_adjustment_id,
822 p_request_type => NULL,
823 x_return_status => l_return_status);
824 IF l_control_rec.Process_Partial THEN
825 ROLLBACK TO SAVEPOINT Header_Adjs;
826 ELSE
827 RAISE FND_API.G_EXC_ERROR;
828 END IF;
829
830
831 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
832
833 l_Header_Adj_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
834 p_x_header_adj_tbl(I) := l_Header_Adj_rec;
835 p_x_old_Header_Adj_tbl(I) := l_old_Header_Adj_rec;
836 OE_Header_Adj_Security.g_check_all_cols_constraint := 'Y';
837 OE_MSG_PUB.reset_msg_context('HEADER_ADJ');
838 oe_delayed_requests_pvt.delete_request(p_entity_code =>OE_GLOBALS.G_ENTITY_HEADER_ADJ,
839 p_entity_id => l_header_adj_rec.Price_adjustment_id,
840 p_request_type => NULL,
841 x_return_status => l_return_status);
842 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
843
844 WHEN OTHERS THEN
845
846 l_Header_Adj_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
847 p_x_header_adj_tbl(I) := l_Header_Adj_rec;
848 p_x_old_Header_Adj_tbl(I) := l_old_Header_Adj_rec;
849 OE_Header_Adj_Security.g_check_all_cols_constraint := 'Y';
850 oe_delayed_requests_pvt.delete_request(p_entity_code =>OE_GLOBALS.G_ENTITY_HEADER_ADJ,
851 p_entity_id => l_header_adj_rec.Price_adjustment_id,
852 p_request_type => NULL,
853 x_return_status => l_return_status);
854
855 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
856 THEN
857 OE_MSG_PUB.Add_Exc_Msg
858 ( G_PKG_NAME
859 , 'Header_Adjs'
860 );
861 END IF;
862
863 OE_MSG_PUB.reset_msg_context('HEADER_ADJ');
864 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
865
866 END;
867 I := p_x_header_adj_tbl.NEXT(I);
868 END LOOP;
869
870 -- Load OUT parameters
871
872 adj_debug('Exiting oe_order_Adj_pvt.HEADER_ADJS', 1);
873 OE_MSG_PUB.reset_msg_context('HEADER_ADJ');
874
875 oe_order_pvt.set_recursion_mode(p_Entity_Code => 3,
876 p_In_out => 0);
877
878 EXCEPTION
879
880 WHEN FND_API.G_EXC_ERROR THEN
881 oe_order_pvt.set_recursion_mode(p_Entity_Code => 3,
882 p_In_out => 0);
883
884 OE_MSG_PUB.reset_msg_context('HEADER_ADJ');
885 RAISE;
886
887 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
888 oe_order_pvt.set_recursion_mode(p_Entity_Code => 3,
889 p_In_out => 0);
890
891 OE_MSG_PUB.reset_msg_context('HEADER_ADJ');
892 RAISE;
893
894 WHEN OTHERS THEN
895 oe_order_pvt.set_recursion_mode(p_Entity_Code => 3,
896 p_In_out => 0);
897
898 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
899 THEN
900 OE_MSG_PUB.Add_Exc_Msg
901 ( G_PKG_NAME
902 , 'Header_Adjs'
903 );
904 END IF;
905
906
907 OE_MSG_PUB.reset_msg_context('HEADER_ADJ');
908 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
909
910 END Header_Adjs;
911
912 -- Line_Adjs
913
914 PROCEDURE Line_Adjs
915 ( p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
916 , p_validation_level IN NUMBER
917 , p_control_rec IN OE_GLOBALS.Control_Rec_Type
918 , p_x_Line_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Tbl_Type
919 , p_x_old_Line_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Tbl_Type
920 )
921 IS
922 l_return_status VARCHAR2(1);
923 l_control_rec OE_GLOBALS.Control_Rec_Type;
924 l_Line_Adj_rec OE_Order_PUB.Line_Adj_Rec_Type;
925 l_old_Line_Adj_rec OE_Order_PUB.Line_Adj_Rec_Type;
926 -- local variables to store OUT parameters from security check procedures
927 l_sec_result NUMBER;
928 l_on_operation_action NUMBER;
929 I pls_integer; -- Used as table index for the loop.
930 --
931 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
932 --
933 l_last_line_id Number; --bug 2721485
934 l_line_found Varchar2(1); --bug 2721485
935
936 l_order_source_id NUMBER;
937 l_orig_sys_document_ref VARCHAR2(50);
938 l_orig_sys_line_ref VARCHAR2(50);
939 l_orig_sys_shipment_ref VARCHAR2(50);
940 l_change_sequence VARCHAR2(50);
941 l_source_document_type_id NUMBER;
942 l_source_document_id NUMBER;
943 l_source_document_line_id NUMBER;
944 l_line_temp_rec OE_Order_PUB.Line_Rec_Type;
945
946 BEGIN
947
948 IF l_debug_level > 0 THEN
949 G_DEBUG := TRUE;
950 END IF;
951
952 adj_debug('Entering oe_order_Adj_pvt.LINE_ADJS', 1);
953 oe_order_pvt.set_recursion_mode(p_Entity_Code => 6,
954 p_In_out => 1);
955
956 IF FND_API.to_Boolean(p_init_msg_list) THEN
957 OE_MSG_PUB.initialize;
958 END IF;
959
960 IF l_control_rec.Process_Partial THEN
961 SAVEPOINT Line_Adjs;
962 END IF;
963
964
965 -- FOR I IN 1..p_x_Line_Adj_tbl.COUNT LOOP
966
967 I := p_x_Line_Adj_tbl.FIRST;
968
969 WHILE I IS NOT NULL LOOP
970 BEGIN
971
972 -- Load local records.
973
974 l_Line_Adj_rec := p_x_Line_Adj_tbl(I);
975
976 adj_debug('price_adj_id :'||l_line_adj_rec.price_adjustment_id,3);
977 adj_debug('operation is :'||l_line_adj_rec.operation,3);
978
979 IF p_x_old_Line_Adj_tbl.EXISTS(I) THEN
980 l_old_Line_Adj_rec := p_x_old_Line_Adj_tbl(I);
981 ELSE
982 l_old_Line_Adj_rec := OE_Order_PUB.G_MISS_LINE_ADJ_REC;
983 END IF;
984
985 if l_old_line_Adj_rec.price_adjustment_id = FND_API.G_MISS_NUM then
986
987 IF l_line_adj_rec.line_id IS NOT NULL AND
988 l_line_adj_rec.line_id <> FND_API.G_MISS_NUM THEN
989 BEGIN
990 IF l_debug_level > 0 THEN
991 oe_debug_pub.add('Getting reference data for line_id:'||l_line_adj_rec.line_id);
992 END IF;
993 SELECT order_source_id, orig_sys_document_ref, change_sequence,
994 source_document_type_id, source_document_id, orig_sys_line_ref,
995 source_document_line_id, orig_sys_shipment_ref
996 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
997 l_source_document_type_id, l_source_document_id, l_orig_sys_line_ref,
998 l_source_document_line_id, l_orig_sys_shipment_ref
999 FROM OE_ORDER_LINES_ALL
1000 WHERE line_id = l_line_adj_rec.line_id;
1001 EXCEPTION
1002 WHEN NO_DATA_FOUND THEN
1003 l_order_source_id := null;
1004 l_orig_sys_document_ref := null;
1005 l_change_sequence := null;
1006 l_source_document_type_id := null;
1007 l_source_document_id := null;
1008 l_orig_sys_line_ref := null;
1009 l_source_document_line_id := null;
1010 l_orig_sys_shipment_ref := null;
1011 WHEN OTHERS THEN
1012 l_order_source_id := null;
1013 l_orig_sys_document_ref := null;
1014 l_change_sequence := null;
1015 l_source_document_type_id := null;
1016 l_source_document_id := null;
1017 l_orig_sys_line_ref := null;
1018 l_source_document_line_id := null;
1019 l_orig_sys_shipment_ref := null;
1020 END;
1021 END IF;
1022
1023 OE_MSG_PUB.set_msg_context(
1024 p_entity_code => 'LINE_ADJ'
1025 ,p_entity_id => l_line_adj_rec.price_adjustment_id
1026 ,p_header_id => l_line_adj_rec.header_id
1027 ,p_line_id => l_line_adj_rec.line_id
1028 ,p_order_source_id => l_order_source_id
1029 ,p_orig_sys_document_ref => l_orig_sys_document_ref
1030 ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
1031 ,p_orig_sys_shipment_ref => l_orig_sys_shipment_ref
1032 ,p_change_sequence => l_change_sequence
1033 ,p_source_document_type_id => l_source_document_type_id
1034 ,p_source_document_id => l_source_document_id
1035 ,p_source_document_line_id => l_source_document_line_id );
1036
1037 else
1038
1039 IF l_old_line_adj_rec.line_id IS NOT NULL AND
1040 l_old_line_adj_rec.line_id <> FND_API.G_MISS_NUM THEN
1041 BEGIN
1042 IF l_debug_level > 0 THEN
1043 oe_debug_pub.add('Getting reference data for old line_id:'||l_old_line_adj_rec.line_id);
1044 END IF;
1045 SELECT order_source_id, orig_sys_document_ref, change_sequence,
1046 source_document_type_id, source_document_id, orig_sys_line_ref,
1047 source_document_line_id, orig_sys_shipment_ref
1048 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
1049 l_source_document_type_id, l_source_document_id, l_orig_sys_line_ref,
1050 l_source_document_line_id, l_orig_sys_shipment_ref
1051 FROM OE_ORDER_LINES_ALL
1052 WHERE line_id = l_old_line_adj_rec.line_id;
1053 EXCEPTION
1054 WHEN NO_DATA_FOUND THEN
1055 l_order_source_id := null;
1056 l_orig_sys_document_ref := null;
1057 l_change_sequence := null;
1058 l_source_document_type_id := null;
1059 l_source_document_id := null;
1060 l_orig_sys_line_ref := null;
1061 l_source_document_line_id := null;
1062 l_orig_sys_shipment_ref := null;
1063 WHEN OTHERS THEN
1064 l_order_source_id := null;
1065 l_orig_sys_document_ref := null;
1066 l_change_sequence := null;
1067 l_source_document_type_id := null;
1068 l_source_document_id := null;
1069 l_orig_sys_line_ref := null;
1070 l_source_document_line_id := null;
1071 l_orig_sys_shipment_ref := null;
1072 END;
1073 END IF;
1074
1075 OE_MSG_PUB.set_msg_context(
1076 p_entity_code => 'LINE_ADJ'
1077 ,p_entity_id => l_old_line_adj_rec.price_adjustment_id
1078 ,p_header_id => l_old_line_adj_rec.header_id
1079 ,p_line_id => l_old_line_adj_rec.line_id
1080 ,p_order_source_id => l_order_source_id
1081 ,p_orig_sys_document_ref => l_orig_sys_document_ref
1082 ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
1083 ,p_orig_sys_shipment_ref => l_orig_sys_shipment_ref
1084 ,p_change_sequence => l_change_sequence
1085 ,p_source_document_type_id => l_source_document_type_id
1086 ,p_source_document_id => l_source_document_id
1087 ,p_source_document_line_id => l_source_document_line_id );
1088 end if;
1089
1090 -- Load API control record
1091
1092 l_control_rec := OE_GLOBALS.Init_Control_Rec
1093 ( p_operation => l_Line_Adj_rec.operation
1094 , p_control_rec => p_control_rec
1095 );
1096
1097 -- Set record return status.
1098
1099 l_Line_Adj_rec.return_status := FND_API.G_RET_STS_SUCCESS;
1100 p_x_line_adj_tbl(I).return_status := FND_API.G_RET_STS_SUCCESS;
1101
1102 -- Prepare record.
1103
1104 IF l_Line_Adj_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
1105
1106 l_Line_Adj_rec.db_flag := FND_API.G_FALSE;
1107
1108 -- Set missing old record elements to NULL.
1109
1110 -- l_old_Line_Adj_rec :=
1111 OE_Line_Adj_Util.Convert_Miss_To_Null (l_old_Line_Adj_rec);
1112 --bug 2721485 Begin
1113 adj_debug('Line id :'||l_line_adj_rec.line_id,3);
1114 if OE_GLOBALS.G_PRICING_RECURSION = 'N' and
1115 l_line_adj_rec.line_id is not null then
1116 if l_last_line_id = l_line_adj_rec.line_id
1117 and l_line_found = 'Y' then
1118 null;
1119 elsif l_last_line_id = l_line_adj_rec.line_id
1120 and l_line_found = 'N' then
1121 adj_debug('Line ID not found 1',3);
1122 GOTO line_not_in_db;
1123 else
1124 Begin
1125 --bug 2825766 begin
1126 oe_oe_form_line.get_line(p_db_record => FALSE,
1127 p_line_id => l_line_adj_rec.line_id,
1128 x_line_rec => l_line_temp_rec);
1129 l_last_line_id := l_line_adj_rec.line_id;
1130 if nvl(l_line_temp_rec.line_id,FND_API.G_MISS_NUM) <>
1131 FND_API.G_MISS_NUM then
1132 l_line_found := 'Y';
1133 adj_debug('Line id found:');
1134 else
1135 l_line_found := 'N';
1136 adj_debug('Line id not found 1:');
1137 GOTO line_not_in_db;
1138 end if;
1139 --bug 2825766 end
1140 Exception
1141 when others then
1142 adj_debug('line adjs - others 2 ',3);
1143 l_line_found := 'N';
1144 l_last_line_id := l_line_adj_rec.line_id;
1145 GOTO line_not_in_db;
1146 end;
1147 end if;
1148 end if;
1149 --bug 2721485 End
1150
1151 ELSIF l_Line_Adj_rec.operation = OE_GLOBALS.G_OPR_UPDATE
1152 OR l_Line_Adj_rec.operation = OE_GLOBALS.G_OPR_DELETE
1153 THEN
1154
1155 l_Line_Adj_rec.db_flag := FND_API.G_TRUE;
1156
1157 -- Query Old if missing
1158
1159 IF l_old_Line_Adj_rec.price_adjustment_id = FND_API.G_MISS_NUM
1160 OR l_old_Line_Adj_rec.line_id IS NULL
1161 THEN
1162
1163 OE_Line_Adj_Util.Query_Row
1164 ( p_price_adjustment_id => l_Line_Adj_rec.price_adjustment_id
1165 , x_line_adj_rec => l_old_Line_Adj_rec
1166 );
1167
1168 p_x_old_line_adj_tbl(I) := l_old_line_adj_rec;
1169
1170 ELSE
1171
1172 -- Set missing old record elements to NULL.
1173
1174 -- l_old_Line_Adj_rec :=
1175 OE_Line_Adj_Util.Convert_Miss_To_Null (l_old_Line_Adj_rec);
1176
1177 END IF;
1178
1179 -- Complete new record from old
1180
1181 -- l_Line_Adj_rec :=
1182 OE_Line_Adj_Util.Complete_Record
1183 ( p_x_Line_Adj_rec => l_Line_Adj_rec
1184 , p_old_Line_Adj_rec => l_old_Line_Adj_rec
1185 );
1186
1187 OE_MSG_PUB.update_msg_context(
1188 p_entity_code => 'LINE_ADJ'
1189 ,p_entity_id => l_line_adj_rec.price_adjustment_id
1190 ,p_header_id => l_line_adj_rec.header_id
1191 ,p_line_id => l_line_adj_rec.line_id);
1192
1193 END IF;
1194
1195
1196 IF I = p_x_line_adj_tbl.FIRST THEN
1197 IF NOT oe_order_pvt.Valid_Upgraded_Order(l_line_adj_rec.header_id) THEN
1198 RAISE FND_API.G_EXC_ERROR;
1199 END IF;
1200 END IF;
1201
1202 -- Check security
1203 IF l_control_rec.check_security
1204 AND (l_line_adj_rec.operation = OE_GLOBALS.G_OPR_CREATE
1205 OR l_line_adj_rec.operation = OE_GLOBALS.G_OPR_UPDATE)
1206 THEN
1207
1208 adj_debug('Check Attributes Security',2);
1209 -- check if this operation is allowed
1210 -- on all the changed attributes
1211 OE_Line_Adj_Security.Attributes
1212 (p_line_Adj_rec => l_line_adj_rec
1213 , p_old_line_adj_rec => l_old_line_adj_rec
1214 , x_result => l_sec_result
1215 , x_return_status => l_return_status
1216 );
1217
1218 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1219 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1220 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1221 RAISE FND_API.G_EXC_ERROR;
1222 END IF;
1223
1224 IF l_sec_result = OE_PC_GLOBALS.YES THEN
1225 RAISE FND_API.G_EXC_ERROR;
1226 END IF;
1227
1228 END IF;
1229
1230 -- Attribute level validation.
1231
1232 IF p_validation_level > FND_API.G_VALID_LEVEL_NONE THEN
1233
1234 adj_debug('Before OE_Validate_Line_Adj.Attributes . ' ||
1235 ' adj_id = '|| To_char(l_line_adj_rec.price_adjustment_id), 2);
1236
1237 OE_Validate_Line_Adj.Attributes
1238 ( x_return_status => l_return_status
1239 , p_Line_Adj_rec => l_Line_Adj_rec
1240 , p_old_Line_Adj_rec => l_old_Line_Adj_rec
1241 );
1242
1243 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1244 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1245 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1246 RAISE FND_API.G_EXC_ERROR;
1247 END IF;
1248
1249
1250 END IF;
1251
1252
1253 -- Clear dependent attributes.
1254
1255 IF l_control_rec.clear_dependents THEN
1256
1257 OE_Line_Adj_Util.Clear_Dependent_Attr
1258 ( p_x_Line_Adj_rec => l_Line_Adj_rec
1259 , p_old_Line_Adj_rec => l_old_Line_Adj_rec
1260 --, x_Line_Adj_rec => l_Line_Adj_rec
1261 );
1262
1263 END IF;
1264
1265 -- Default missing attributes
1266
1267 IF l_control_rec.default_attributes
1268 THEN
1269
1270 OE_Default_Line_Adj.Attributes
1271 ( p_x_Line_Adj_rec => l_Line_Adj_rec
1272 , p_old_line_adj_rec => l_old_line_adj_rec
1273 --, x_Line_Adj_rec => l_Line_Adj_rec
1274 );
1275
1276 /* adj_debug('After OE_Default_Line_Adj.Attributes . ' ||
1277 'discount_id = ' || To_char(l_line_adj_rec.discount_id)
1278 || ' discount_line_id = '||
1279 To_char(l_line_adj_rec.discount_line_id)
1280 || ' percent = '|| To_char(l_line_adj_rec.percent), 2);
1281 */
1282
1283 END IF;
1284
1285 -- Apply attribute changes
1286
1287 IF l_control_rec.change_attributes
1288 THEN
1289
1290 -- This will also log request/s to check duplicity/fixed_price
1291 -- check of price adjustment entered
1292 adj_debug('Before OE_Line_Adj_Util.Apply_Attribute_Changes ',2);
1293 OE_Line_Adj_Util.Apply_Attribute_Changes
1294 ( p_x_Line_Adj_rec => l_Line_Adj_rec
1295 , p_old_Line_Adj_rec => l_old_Line_Adj_rec
1296 --, x_Line_Adj_rec => l_Line_Adj_rec
1297 );
1298 adj_debug('After OE_Line_Adj_Util.Apply_Attribute_Changes ',2);
1299
1300 END IF;
1301
1302
1303 -- If there has any activity causing a change in any attribute
1304 -- log a request for repricing
1305 /* IF l_control_rec.change_attributes
1306 THEN
1307 oe_line_adj_util.log_adj_requests(l_return_status,
1308 l_line_adj_rec,
1309 l_old_line_adj_rec);
1310
1311 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1312 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1313 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1314 RAISE FND_API.G_EXC_ERROR;
1315 END IF;
1316
1317 END IF; */
1318
1319
1320
1321 -- Entity level validation.
1322
1323 IF l_control_rec.validate_entity THEN
1324
1325 IF l_Line_Adj_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
1326
1327 OE_Validate_Line_Adj.Entity_Delete
1328 ( x_return_status => l_return_status
1329 , p_Line_Adj_rec => l_Line_Adj_rec
1330 );
1331
1332 adj_debug('After OE_Validate_Line_Adj.delete ',2);
1333 ELSE
1334
1335 -- logs maximum percentage request check also
1336 adj_debug('Before OE_Validate_Line_Adj.Entity ',2);
1337 OE_Validate_Line_Adj.Entity
1338 ( x_return_status => l_return_status
1339 , p_Line_Adj_rec => l_Line_Adj_rec
1340 , p_old_Line_Adj_rec => l_old_Line_Adj_rec
1341 );
1342 adj_debug('After OE_Validate_Line_Adj.Entity ',2);
1343
1344 END IF;
1345
1346 adj_debug('Stt '||l_return_status,3);
1347 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1348 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1349 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1350 RAISE FND_API.G_EXC_ERROR;
1351 END IF;
1352
1353 END IF;
1354 adj_debug('Before Check_security..',2);
1355
1356 -- Check entity level security again as some attributes
1357 -- may have changed due to defaulting.
1358 IF l_control_rec.check_security THEN
1359
1360 adj_debug('Check Entity Security',2);
1361
1362 OE_Line_Adj_Security.Entity
1363 (p_line_adj_rec => l_line_adj_rec
1364 , x_result => l_sec_result
1365 , x_return_status => l_return_status
1366 );
1367
1368 adj_debug('After Check Entity Security',2);
1369
1370 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1371 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1372 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1373 RAISE FND_API.G_EXC_ERROR;
1374 END IF;
1375
1376 IF l_sec_result = OE_PC_GLOBALS.YES THEN
1377 RAISE FND_API.G_EXC_ERROR;
1378 END IF;
1379
1380 END IF;
1381
1382 -- Step 4. Write to DB
1383
1384 adj_debug('Before write_to_db',2);
1385 IF l_control_rec.write_to_db THEN
1386
1387 /* Start AuditTrail */
1388 OE_DEBUG_PUB.add('OEXVADJB:calling to insert audit history for line adj from pre_write_process', 2);
1389
1390 Oe_LINE_ADJ_Util.Pre_Write_Process
1391 (p_x_line_adj_rec => l_line_adj_rec,
1392 p_old_line_adj_rec => l_old_line_adj_rec);
1393 OE_DEBUG_PUB.add('OEXVADJB:After calling to insert audit history for line adj from pre_write_process', 2);
1394 /* End AuditTrail */
1395
1396 IF l_Line_Adj_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
1397
1398 OE_Line_Adj_Util.Delete_Row
1399 ( p_price_adjustment_id => l_Line_Adj_rec.price_adjustment_id
1400 );
1401
1402 -- Log a delayed request to cause repricing due to deleted
1403 -- record
1404 -- NOTE: Requesting entity is line, not line adj. as the adj. itself
1405 -- has been deleted and this request should be deleted when the line gets
1406 -- deleted. Should be revisited if the entity logged against is changed
1407 -- to line.
1408 IF OE_Globals.G_RECURSION_MODE <> 'Y' and
1409 l_Line_adj_rec.list_line_type_code NOT IN ('COST','TAX')
1410 THEN
1411
1412 /* 1905650 - G_PRICE_ADJ request should be logged against LINE entity,
1413 not against LINE_ADJ entity
1414 1503357 - Minor change to handle header level adjustments
1415 */
1416
1417 if (l_line_adj_rec.line_id is NULL) Then
1418 oe_delayed_requests_pvt.log_request(
1419 p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
1420 p_entity_id => l_Line_adj_rec.header_id,
1421 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_HEADER,
1422 p_requesting_entity_id => l_Line_adj_rec.header_id,
1423 p_request_type => OE_GLOBALS.G_PRICE_ADJ,
1424 x_return_status => l_return_status);
1425 else
1426 If OE_GLOBALS.G_UI_FLAG and nvl(l_Line_adj_rec.automatic_flag,'Y') = 'N' Then
1427 oe_delayed_requests_pvt.log_request(
1428 p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
1429 p_entity_id => l_Line_adj_rec.Line_id,
1430 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE_ADJ,
1431 p_requesting_entity_id => l_Line_adj_rec.Line_id,
1432 p_request_type => OE_GLOBALS.G_PRICE_ADJ,
1433 p_param1 => 'UI',
1434 x_return_status => l_return_status);
1435
1436 else
1437 oe_delayed_requests_pvt.log_request(
1438 p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
1439 p_entity_id => l_Line_adj_rec.Line_id,
1440 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
1441 p_requesting_entity_id => l_Line_adj_rec.Line_id,
1442 p_request_type => OE_GLOBALS.G_PRICE_ADJ,
1443 x_return_status => l_return_status);
1444 end if;
1445 end if;
1446 End If;
1447
1448 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1449 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1450 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1451 RAISE FND_API.G_EXC_ERROR;
1452 END IF;
1453
1454
1455 ELSE
1456
1457 -- Get Who Information
1458
1459 l_Line_Adj_rec.last_update_date := SYSDATE;
1460 l_Line_Adj_rec.last_updated_by := FND_GLOBAL.USER_ID;
1461 l_Line_Adj_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
1462
1463 IF l_Line_Adj_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
1464 oe_debug_pub.add(' updating list line id:'||l_Line_Adj_rec.list_line_id);
1465 oe_debug_pub.add(' l_line_adj_rec adjusted_amount:'||l_Line_Adj_rec.adjusted_amount);
1466 oe_debug_pub.add(' line_id:'||l_Line_Adj_rec.line_id);
1467 OE_Line_Adj_Util.Update_Row (l_Line_Adj_rec);
1468
1469 ELSIF l_Line_Adj_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
1470
1471 l_Line_Adj_rec.creation_date := SYSDATE;
1472 l_Line_Adj_rec.created_by := FND_GLOBAL.USER_ID;
1473
1474 adj_debug('Before insert row',2);
1475 OE_Line_Adj_Util.Insert_Row (l_Line_Adj_rec);
1476 adj_debug('After insert row',2);
1477
1478 END IF;
1479
1480 END IF;
1481
1482 END IF;
1483
1484 -- Load tables.
1485
1486 p_x_Line_Adj_tbl(I) := l_Line_Adj_rec;
1487 p_x_old_Line_Adj_tbl(I) := l_old_Line_Adj_rec;
1488
1489 OE_Line_Adj_Security.g_check_all_cols_constraint := 'Y';
1490 OE_MSG_PUB.reset_msg_context('LINE_ADJ');
1491 -- Check return status and rollaback
1492
1493 IF l_line_adj_rec.return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1494 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1495 ELSIF l_line_adj_rec.return_status = FND_API.G_RET_STS_ERROR THEN
1496 RAISE FND_API.G_EXC_ERROR;
1497 END IF;
1498
1499 -- loop exception handler.
1500
1501 /*
1502 -- Bug 6838610 below Code is comented to Imporve Performance
1503 --
1504 -- Start : Changes made as a part of DBI ER # 4185227
1505 --
1506 IF l_debug_level > 0 THEN
1507 oe_debug_pub.add( 'CALLING OE_DBI_UTIL FOR ORDER LINE PRICE ADJUSTMENTS' , 1 ) ;
1508 oe_debug_pub.add( 'CACHED VALUE' || OE_ORDER_CACHE.G_HEADER_REC.BOOKED_FLAG ) ;
1509 oe_debug_pub.add( 'RECURSION VALUE' || OE_ORDER_UTIL.G_RECURSION_WITHOUT_EXCEPTION ) ;
1510 oe_debug_pub.add( 'PROFILE VALUE' || FND_PROFILE.VALUE ( 'ONT_DBI_INSTALLED' ) ) ;
1511 END IF;
1512
1513 IF NVL(FND_PROFILE.VALUE('ONT_DBI_INSTALLED'), 'N') = 'Y' AND
1514 oe_order_cache.g_header_rec.booked_flag = 'Y' AND
1515 oe_order_util.g_recursion_without_exception = 'N' AND
1516 l_control_rec.write_to_db
1517 THEN
1518 OE_DBI_UTIL.Update_DBI_Log( x_return_status => l_return_status);
1519
1520 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1521 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1522 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1523 RAISE FND_API.G_EXC_ERROR;
1524 END IF;
1525 END IF;
1526
1527 --
1528 -- End : Changes made as a part of DBI ER # 4185227
1529 --
1530
1531 */
1532 --End of changes for 6838610
1533
1534
1535
1536
1537
1538 EXCEPTION
1539
1540 WHEN FND_API.G_EXC_ERROR THEN
1541
1542 l_Line_Adj_rec.return_status := FND_API.G_RET_STS_ERROR;
1543 p_x_Line_Adj_tbl(I) := l_Line_Adj_rec;
1544 p_x_old_Line_Adj_tbl(I) := l_old_Line_Adj_rec;
1545 OE_Line_Adj_Security.g_check_all_cols_constraint := 'Y';
1546 OE_MSG_PUB.reset_msg_context('LINE_ADJ');
1547 oe_delayed_requests_pvt.delete_request(p_entity_code =>OE_GLOBALS.G_ENTITY_LINE_ADJ,
1548 p_entity_id => l_line_adj_rec.Price_adjustment_id,
1549 p_request_type => NULL,
1550 x_return_status => l_return_status);
1551 IF l_control_rec.Process_Partial THEN
1552 ROLLBACK TO SAVEPOINT Line_Adjs;
1553 ELSE
1554 RAISE FND_API.G_EXC_ERROR;
1555 END IF;
1556
1557 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1558
1559 l_Line_Adj_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1560 p_x_Line_Adj_tbl(I) := l_Line_Adj_rec;
1561 p_x_old_Line_Adj_tbl(I) := l_old_Line_Adj_rec;
1562 OE_Line_Adj_Security.g_check_all_cols_constraint := 'Y';
1563 OE_MSG_PUB.reset_msg_context('LINE_ADJ');
1564 oe_delayed_requests_pvt.delete_request(p_entity_code =>OE_GLOBALS.G_ENTITY_LINE_ADJ,
1565 p_entity_id => l_line_adj_rec.Price_adjustment_id,
1566 p_request_type => NULL,
1567 x_return_status => l_return_status);
1568 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1569
1570 WHEN OTHERS THEN
1571
1572 l_Line_Adj_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1573 p_x_Line_Adj_tbl(I) := l_Line_Adj_rec;
1574 p_x_old_Line_Adj_tbl(I) := l_old_Line_Adj_rec;
1575 OE_Line_Adj_Security.g_check_all_cols_constraint := 'Y';
1576 oe_delayed_requests_pvt.delete_request(p_entity_code =>OE_GLOBALS.G_ENTITY_LINE_ADJ,
1577 p_entity_id => l_line_adj_rec.Price_adjustment_id,
1578 p_request_type => NULL,
1579 x_return_status => l_return_status);
1580
1581 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1582 THEN
1583 OE_MSG_PUB.Add_Exc_Msg
1584 ( G_PKG_NAME
1585 , 'Line_Adjs'
1586 );
1587 END IF;
1588
1589 OE_MSG_PUB.reset_msg_context('LINE_ADJ');
1590 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1591
1592 END;
1593 <<line_not_in_db>> --bug 2721485
1594 I := p_x_Line_Adj_tbl.NEXT(I);
1595 END LOOP;
1596
1597 -- Load OUT parameters
1598
1599 OE_MSG_PUB.reset_msg_context('LINE_ADJ');
1600
1601 oe_order_pvt.set_recursion_mode(p_Entity_Code => 6,
1602 p_In_out => 0);
1603
1604 EXCEPTION
1605
1606 WHEN FND_API.G_EXC_ERROR THEN
1607
1608 oe_order_pvt.set_recursion_mode(p_Entity_Code => 6,
1609 p_In_out => 0);
1610
1611 adj_debug('Exiting oe_order_Adj_pvt.LINE_ADJS', 1);
1612 OE_MSG_PUB.reset_msg_context('LINE_ADJ');
1613 RAISE;
1614
1615 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1616 oe_order_pvt.set_recursion_mode(p_Entity_Code => 6,
1617 p_In_out => 0);
1618
1619
1620 OE_MSG_PUB.reset_msg_context('LINE_ADJ');
1621 RAISE;
1622
1623 WHEN OTHERS THEN
1624 oe_order_pvt.set_recursion_mode(p_Entity_Code => 6,
1625 p_In_out => 0);
1626
1627 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1628 THEN
1629 OE_MSG_PUB.Add_Exc_Msg
1630 ( G_PKG_NAME
1631 , 'Line_Adjs'
1632 );
1633 END IF;
1634
1635
1636 OE_MSG_PUB.reset_msg_context('LINE_ADJ');
1637 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1638
1639 END Line_Adjs;
1640
1641 PROCEDURE HEader_Price_Atts
1642 ( p_init_msg_list IN VARCHAR2:=FND_API.G_FALSE
1643 , p_validation_level IN NUMBER
1644 , p_control_rec IN OE_GLOBALS.Control_Rec_Type
1645 , p_x_HEader_Price_Att_tbl IN OUT NOCOPY OE_Order_PUB.HEader_Price_Att_Tbl_Type
1646 , p_x_old_HEader_Price_Att_tbl IN OUT NOCOPY OE_Order_PUB.HEader_Price_Att_Tbl_Type
1647 )
1648 is
1649 l_return_status VARCHAR2(1);
1650 l_control_rec OE_GLOBALS.Control_Rec_Type;
1651 l_Header_Price_Att_rec OE_Order_PUB.Header_Price_Att_Rec_Type;
1652 l_old_Header_Price_Att_rec OE_Order_PUB.Header_Price_Att_Rec_Type;
1653 -- local variables to store OUT parameters from security check procedures
1654 l_sec_result NUMBER;
1655 l_on_operation_action NUMBER;
1656 I pls_integer; -- Used as index for while loop
1657 l_booked_flag varchar2(1);
1658 l_Shipped_quantity number;
1659 l_pricing_event varchar2(30);
1660
1661 --
1662 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1663 --
1664 l_order_source_id NUMBER;
1665 l_orig_sys_document_ref VARCHAR2(50);
1666 l_change_sequence VARCHAR2(50);
1667 l_source_document_type_id NUMBER;
1668 l_source_document_id NUMBER;
1669
1670 BEGIN
1671
1672 l_control_rec := p_control_rec; -- Added for Bug #5679839
1673
1674 IF FND_API.to_Boolean(p_init_msg_list) THEN
1675 OE_MSG_PUB.initialize;
1676 END IF;
1677
1678 IF l_control_rec.Process_Partial THEN
1679 SAVEPOINT Header_Price_Atts;
1680 END IF;
1681
1682 -- Init local table variables.
1683
1684 --dbms_output.put_line('Entering oe_order_Adj_pvt.HEader_Price_Atts');
1685 oe_debug_pub.add('Entering oe_order_Adj_pvt.HEader_Price_Atts', 1);
1686
1687
1688 I := p_x_Header_Price_Att_tbl.FIRST;
1689
1690 WHILE I IS NOT NULL LOOP
1691 BEGIN
1692
1693 -- Load local records.
1694
1695 l_Header_Price_Att_rec := p_x_Header_Price_Att_tbl(I);
1696
1697 IF p_x_old_Header_Price_Att_tbl.EXISTS(I) THEN
1698 l_old_Header_Price_Att_rec := p_x_old_Header_Price_Att_tbl(I);
1699 ELSE
1700 l_old_Header_Price_Att_rec := OE_Order_PUB.G_MISS_HEADER_Price_Att_REC;
1701 END IF;
1702
1703 if l_old_header_Price_Att_rec.Order_price_attrib_id = FND_API.G_MISS_NUM then
1704 IF l_header_Price_Att_rec.header_Id IS NOT NULL AND
1705 l_header_Price_Att_rec.header_Id <> FND_API.G_MISS_NUM THEN
1706 BEGIN
1707 IF l_debug_level > 0 THEN
1708 oe_debug_pub.add('Getting reference data for header_id:'||l_header_Price_Att_rec.header_Id);
1709 END IF;
1710 SELECT order_source_id, orig_sys_document_ref, change_sequence,
1711 source_document_type_id, source_document_id
1712 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
1713 l_source_document_type_id, l_source_document_id
1714 FROM OE_ORDER_HEADERS_ALL
1715 WHERE header_id = l_header_Price_Att_rec.header_Id;
1716 EXCEPTION
1717 WHEN NO_DATA_FOUND THEN
1718 l_order_source_id := null;
1719 l_orig_sys_document_ref := null;
1720 l_change_sequence := null;
1721 l_source_document_type_id := null;
1722 l_source_document_id := null;
1723 WHEN OTHERS THEN
1724 l_order_source_id := null;
1725 l_orig_sys_document_ref := null;
1726 l_change_sequence := null;
1727 l_source_document_type_id := null;
1728 l_source_document_id := null;
1729 END;
1730 END IF;
1731
1732 OE_MSG_PUB.set_msg_context(
1733 p_entity_code => 'HEADER_PATTS'
1734 ,p_entity_id => l_header_Price_Att_rec.Order_price_attrib_id
1735 ,p_header_id => l_header_Price_Att_rec.header_Id
1736 ,p_line_id => null
1737 ,p_order_source_id => l_order_source_id
1738 ,p_orig_sys_document_ref => l_orig_sys_document_ref
1739 ,p_orig_sys_document_line_ref => null
1740 ,p_change_sequence => l_change_sequence
1741 ,p_source_document_type_id => l_source_document_type_id
1742 ,p_source_document_id => l_source_document_id
1743 ,p_source_document_line_id => null );
1744
1745 else
1746
1747 IF l_old_header_Price_Att_rec.header_Id IS NOT NULL AND
1748 l_old_header_Price_Att_rec.header_Id <> FND_API.G_MISS_NUM THEN
1749
1750 BEGIN
1751 IF l_debug_level > 0 THEN
1752 oe_debug_pub.add('Getting reference data for old header_id:'||l_old_header_Price_Att_rec.header_Id);
1753 END IF;
1754 SELECT order_source_id, orig_sys_document_ref, change_sequence,
1755 source_document_type_id, source_document_id
1756 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
1757 l_source_document_type_id, l_source_document_id
1758 FROM OE_ORDER_HEADERS_ALL
1759 WHERE header_id = l_old_header_Price_Att_rec.header_Id;
1760 EXCEPTION
1761 WHEN NO_DATA_FOUND THEN
1762 l_order_source_id := null;
1763 l_orig_sys_document_ref := null;
1764 l_change_sequence := null;
1765 l_source_document_type_id := null;
1766 l_source_document_id := null;
1767 WHEN OTHERS THEN
1768 l_order_source_id := null;
1769 l_orig_sys_document_ref := null;
1770 l_change_sequence := null;
1771 l_source_document_type_id := null;
1772 l_source_document_id := null;
1773 END;
1774 END IF;
1775
1776 OE_MSG_PUB.set_msg_context(
1777 p_entity_code => 'HEADER_PATTS'
1778 ,p_entity_id => l_old_header_Price_Att_rec.Order_price_attrib_id
1779 ,p_header_id => l_old_header_Price_Att_rec.header_Id
1780 ,p_line_id => null
1781 ,p_order_source_id => l_order_source_id
1782 ,p_orig_sys_document_ref => l_orig_sys_document_ref
1783 ,p_orig_sys_document_line_ref => null
1784 ,p_change_sequence => l_change_sequence
1785 ,p_source_document_type_id => l_source_document_type_id
1786 ,p_source_document_id => l_source_document_id
1787 ,p_source_document_line_id => null );
1788
1789 end if;
1790
1791 -- Load API control record
1792
1793 l_control_rec := OE_GLOBALS.Init_Control_Rec
1794 ( p_operation => l_Header_Price_Att_rec.operation
1795 , p_control_rec => p_control_rec
1796 );
1797
1798 -- Set record return status.
1799
1800 l_Header_Price_Att_rec.return_status := FND_API.G_RET_STS_SUCCESS;
1801
1802 oe_debug_pub.add(' After initializing record,operation:'||l_Header_Price_Att_rec.operation);
1803 -- Prepare record.
1804
1805 IF l_Header_Price_Att_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
1806
1807 l_Header_Price_Att_rec.db_flag := FND_API.G_FALSE;
1808
1809 -- Set missing old record elements to NULL.
1810
1811 oe_debug_pub.add('Entering OE_Header_Price_Att_Util.Convert_Miss_To_Null', 2);
1812 -- l_old_Header_Price_Att_rec :=
1813 OE_Header_PAttr_Util.Convert_Miss_To_Null (l_old_Header_Price_Att_rec);
1814
1815 ELSIF l_Header_Price_Att_rec.operation = OE_GLOBALS.G_OPR_UPDATE
1816 OR l_Header_Price_Att_rec.operation = OE_GLOBALS.G_OPR_DELETE
1817 THEN
1818
1819 l_Header_Price_Att_rec.db_flag := FND_API.G_TRUE;
1820
1821 -- Query Old if missing
1822
1823 IF l_old_Header_Price_Att_rec.order_price_attrib_id = FND_API.G_MISS_NUM
1824 THEN
1825
1826
1827 OE_Header_PAttr_Util.Query_Row
1828 ( p_order_price_attrib_id => l_Header_Price_Att_rec.order_price_attrib_id
1829 , x_Header_Price_Att_rec => l_old_Header_Price_Att_rec
1830 );
1831
1832 ELSE
1833
1834 -- Set missing old record elements to NULL.
1835
1836 -- l_old_Header_Price_Att_rec :=
1837 OE_Header_PAttr_Util.Convert_Miss_To_Null (l_old_Header_Price_Att_rec);
1838
1839 END IF;
1840
1841 -- Complete new record from old
1842
1843 -- l_Header_Price_Att_rec :=
1844 OE_Header_PAttr_Util.Complete_Record
1845 ( p_x_Header_Price_Att_rec => l_Header_Price_Att_rec
1846 , p_old_Header_Price_Att_rec => l_old_Header_Price_Att_rec
1847 );
1848
1849 OE_MSG_PUB.update_msg_context(
1850 p_entity_code => 'HEADER_ADJ'
1851 ,p_entity_id => l_header_Price_Att_rec.order_price_attrib_id
1852 ,p_header_id => l_header_Price_Att_rec.header_Id);
1853
1854 END IF;
1855
1856
1857 IF I = p_x_header_Price_Att_tbl.FIRST THEN
1858 IF NOT oe_order_pvt.Valid_Upgraded_Order(l_header_Price_Att_rec.header_id) THEN
1859 RAISE FND_API.G_EXC_ERROR;
1860 END IF;
1861 END IF;
1862
1863
1864 -- Attribute level validation.
1865
1866 IF p_validation_level > FND_API.G_VALID_LEVEL_NONE THEN
1867 oe_debug_pub.add(' In OE_Validate_Header_Pattr.Attributes');
1868 OE_Validate_Header_Pattr.Attributes
1869 ( x_return_status => l_return_status
1870 , p_Header_Price_Attr_rec => l_Header_Price_Att_rec
1871 , p_old_Header_Price_Attr_rec => l_old_Header_Price_Att_rec
1872 , p_validation_level => p_validation_level
1873 );
1874
1875 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1876 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1877 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1878 RAISE FND_API.G_EXC_ERROR;
1879 END IF;
1880
1881 END IF;
1882
1883 -- Clear dependent attributes.
1884
1885 IF l_control_rec.clear_dependents THEN
1886
1887 OE_Header_PAttr_Util.Clear_Dependent_Attr
1888 ( p_x_Header_Price_Att_rec => l_Header_Price_Att_rec
1889 , p_old_Header_Price_Att_rec => l_old_Header_Price_Att_rec
1890 --, x_Header_Price_Att_rec => l_Header_Price_Att_rec
1891 );
1892
1893 END IF;
1894
1895 -- Default missing attributes
1896 IF l_control_rec.default_attributes
1897 THEN
1898
1899 OE_Default_Header_Pattr.Attributes
1900 ( p_x_Header_Price_Att_rec => l_Header_Price_Att_rec
1901 --, p_old_header_Price_Att_rec => l_old_header_Price_Att_rec
1902 --, x_Header_Price_Att_rec => l_Header_Price_Att_rec
1903 );
1904
1905 END IF;
1906
1907 -- Apply attribute changes
1908
1909 IF l_control_rec.change_attributes
1910 THEN
1911
1912 -- This will also log request/s to check duplicity of
1913 -- price adjustment entered
1914 oe_debug_pub.add(' In apply attribute changes');
1915 OE_Header_PAttr_Util.Apply_Attribute_Changes
1916 ( p_x_Header_Price_Att_rec => l_Header_Price_Att_rec
1917 , p_old_Header_Price_Att_rec => l_old_Header_Price_Att_rec
1918 );
1919
1920 END IF;
1921
1922 -- If there has any activity causing a change in any attribute
1923 -- log a request for repricing
1924
1925 -- Entity level validation.
1926
1927 IF l_control_rec.validate_entity THEN
1928
1929 IF l_Header_Price_Att_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
1930
1931 OE_Validate_Header_Pattr.Entity_Delete
1932 ( x_return_status => l_return_status
1933 , p_Header_Price_Attr_rec => l_Header_Price_Att_rec
1934 );
1935
1936 ELSE
1937
1938 /*OE_Validate_Header_Pattr.Entity
1939 ( x_return_status => l_return_status
1940 , p_Header_Price_Attr_rec => l_Header_Price_Att_rec
1941 , p_old_Header_Price_Attr_rec => l_old_Header_Price_Att_rec
1942 );*/
1943
1944 null;
1945
1946 END IF;
1947
1948 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1949 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1950 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1951 RAISE FND_API.G_EXC_ERROR;
1952 END IF;
1953
1954 END IF;
1955
1956 -- Step 4. Write to DB
1957
1958 IF l_control_rec.write_to_db THEN
1959
1960 IF l_Header_Price_Att_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
1961
1962 OE_Header_PAttr_Util.Delete_Row
1963 ( p_order_price_attrib_id => l_Header_Price_Att_rec.order_price_attrib_id
1964 );
1965
1966 -- Log a delayed request to cause repricing due to deleted
1967 -- record
1968 --2442012
1969
1970 /* OE_delayed_requests_Pvt.log_request(
1971 p_entity_code => OE_GLOBALS.G_ENTITY_HEader_Price_Att,
1972 p_entity_id => l_Header_Price_Att_Rec.Header_Id,
1973 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_HEader_Price_Att,
1974 p_requesting_entity_id => l_Header_Price_Att_Rec.Header_Id,
1975 p_param1 => l_Header_Price_Att_Rec.Header_Id,
1976 p_param2 => 'LINE',
1977 p_request_type => OE_GLOBALS.G_PRICE_ORDER,
1978 x_return_status => l_return_status);
1979
1980 OE_delayed_requests_Pvt.log_request(
1981 p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
1982 p_entity_id => l_Header_Price_Att_Rec.Header_Id,
1983 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
1984 p_requesting_entity_id => l_Header_Price_Att_Rec.Header_Id,
1985 p_param1 => l_Header_Price_Att_Rec.Header_Id,
1986 p_param2 => 'ORDER',
1987 p_request_type => OE_GLOBALS.G_PRICE_ORDER,
1988 x_return_status => l_return_status);
1989 */
1990 Begin
1991 -- use order_header cache instead of sql : bug 4200055
1992 if ( OE_Order_Cache.g_header_rec.header_id <> FND_API.G_MISS_NUM
1993 and OE_Order_Cache.g_header_rec.header_id IS NOT NULL
1994 and OE_Order_Cache.g_header_rec.header_id = l_header_price_att_rec.header_id ) then
1995 l_booked_flag := OE_Order_Cache.g_header_rec.booked_flag ;
1996 else
1997 OE_ORDER_CACHE.Load_Order_Header(l_header_price_att_rec.header_id);
1998 l_booked_flag := OE_Order_Cache.g_header_rec.booked_flag ;
1999 end if ;
2000 /*Select booked_flag Into
2001 l_booked_flag
2002 From OE_Order_Headers where
2003 Header_id = l_Header_Price_Att_Rec.Header_Id;
2004 Exception when no_data_found then
2005 Null;
2006 -- we shouldn't supress no_data_found error.
2007 */
2008 --end bug 4200055
2009 End;
2010
2011 If l_booked_flag='Y' Then
2012 l_pricing_event := 'BATCH,BOOK,SHIP';
2013 /* OE_delayed_requests_Pvt.log_request(
2014 p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
2015 p_entity_id => l_Header_Price_Att_Rec.Header_Id,
2016 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
2017 p_requesting_entity_id => l_Header_Price_Att_Rec.Header_Id,
2018 p_param1 => l_Header_Price_Att_Rec.Header_Id,
2019 p_param2 => 'BOOK',
2020 p_request_type => OE_GLOBALS.G_PRICE_ORDER,
2021 x_return_status => l_return_status);
2022 */
2023 Else
2024 l_pricing_event := 'BATCH';
2025 End If;
2026
2027 OE_delayed_requests_Pvt.log_request(
2028 p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
2029 p_entity_id => l_Header_Price_Att_Rec.Header_Id,
2030 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
2031 p_requesting_entity_id => l_Header_Price_Att_Rec.Header_Id,
2032 p_request_unique_key1 => l_pricing_event,
2033 p_param1 => l_Header_Price_Att_Rec.Header_Id,
2034 p_param2 => l_pricing_event,
2035 p_request_type => OE_GLOBALS.G_PRICE_ORDER,
2036 x_return_status => l_return_status);
2037
2038
2039 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2040 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2041 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2042 RAISE FND_API.G_EXC_ERROR;
2043 END IF;
2044 --2442012
2045 ELSE
2046
2047 -- Get Who Information
2048
2049 l_Header_Price_Att_rec.last_update_date := SYSDATE;
2050 l_Header_Price_Att_rec.last_updated_by := FND_GLOBAL.USER_ID;
2051 l_Header_Price_Att_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
2052
2053 IF l_Header_Price_Att_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
2054
2055 OE_Header_PAttr_Util.Update_Row (l_Header_Price_Att_rec);
2056
2057 ELSIF l_Header_Price_Att_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
2058
2059 l_Header_Price_Att_rec.creation_date := SYSDATE;
2060 l_Header_Price_Att_rec.created_by := FND_GLOBAL.USER_ID;
2061 oe_debug_pub.add(' Before calling pattr_util.insert_row');
2062
2063 select OE_ORDER_PRICE_ATTRIBS_S.nextval
2064 into l_header_price_att_rec.order_price_attrib_id
2065 from dual;
2066
2067 OE_Header_PAttr_Util.Insert_Row (l_Header_Price_Att_rec);
2068
2069 END IF;
2070
2071 END IF;
2072
2073 END IF;
2074
2075 -- Load tables.
2076
2077 p_x_Header_Price_Att_tbl(I) := l_Header_Price_Att_rec;
2078 p_x_old_Header_Price_Att_tbl(I) := l_old_Header_Price_Att_rec;
2079
2080 IF l_header_Price_Att_rec.return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2081 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2082 ELSIF l_header_Price_Att_rec.return_status = FND_API.G_RET_STS_ERROR THEN
2083 RAISE FND_API.G_EXC_ERROR;
2084 END IF;
2085 /*
2086
2087 OE_Header_PAttr_Security.g_check_all_cols_constraint := 'Y';
2088 */
2089 OE_MSG_PUB.reset_msg_context('HEADER_ADJ');
2090 -- loop exception handler.
2091
2092 EXCEPTION
2093
2094 WHEN FND_API.G_EXC_ERROR THEN
2095
2096 l_Header_Price_Att_rec.return_status := FND_API.G_RET_STS_ERROR;
2097 p_x_Header_Price_Att_tbl(I) := l_Header_Price_Att_rec;
2098 p_x_old_Header_Price_Att_tbl(I) := l_old_Header_Price_Att_rec;
2099 /*
2100 OE_Header_PAttr_Security.g_check_all_cols_constraint := 'Y';
2101 OE_MSG_PUB.reset_msg_context('HEADER_ADJ');
2102 oe_delayed_requests_pvt.delete_request
2103 (p_entity_code =>OE_GLOBALS.G_ENTITY_HEADER_ADJ,
2104 p_entity_id => l_header_Price_Att_rec.order_price_attrib_id,
2105 p_request_type => NULL,
2106 x_return_status => l_return_status);
2107 */
2108 IF l_control_rec.Process_Partial THEN
2109 ROLLBACK TO SAVEPOINT Header_Price_Atts;
2110 ELSE
2111 RAISE FND_API.G_EXC_ERROR;
2112 END IF;
2113
2114
2115 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2116
2117 l_Header_Price_Att_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2118 p_x_Header_Price_Att_tbl(I) := l_Header_Price_Att_rec;
2119 p_x_old_Header_Price_Att_tbl(I) := l_old_Header_Price_Att_rec;
2120 /*
2121 OE_Header_PAttr_Security.g_check_all_cols_constraint := 'Y';
2122 OE_MSG_PUB.reset_msg_context('HEADER_ADJ');
2123 oe_delayed_requests_pvt.delete_request
2124 (p_entity_code =>OE_GLOBALS.G_ENTITY_HEADER_ADJ,
2125 p_entity_id => l_header_Price_Att_rec.order_price_attrib_id,
2126 p_request_type => NULL,
2127 x_return_status => l_return_status);
2128 */
2129 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2130
2131 WHEN OTHERS THEN
2132
2133 l_Header_Price_Att_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2134 p_x_Header_Price_Att_tbl(I) := l_Header_Price_Att_rec;
2135 p_x_old_Header_Price_Att_tbl(I) := l_old_Header_Price_Att_rec;
2136
2137 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2138 THEN
2139 OE_MSG_PUB.Add_Exc_Msg
2140 ( G_PKG_NAME
2141 , 'Header_Price_Atts'
2142 );
2143 END IF;
2144
2145 OE_MSG_PUB.reset_msg_context('HEADER_PATTS');
2146 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2147
2148 END;
2149 I := p_x_Header_Price_Att_tbl.NEXT(I);
2150 END LOOP;
2151
2152 -- Load OUT parameters
2153
2154
2155 oe_debug_pub.add('Exiting oe_order_Price_Att_pvt.HEADER_Price_Atts', 1);
2156 OE_MSG_PUB.reset_msg_context('HEADER_PATTS');
2157
2158 EXCEPTION
2159
2160 WHEN FND_API.G_EXC_ERROR THEN
2161
2162 OE_MSG_PUB.reset_msg_context('HEADER_PATTS');
2163 RAISE;
2164
2165 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2166
2167 OE_MSG_PUB.reset_msg_context('HEADER_PATTS');
2168 RAISE;
2169
2170 WHEN OTHERS THEN
2171
2172 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2173 THEN
2174 OE_MSG_PUB.Add_Exc_Msg
2175 ( G_PKG_NAME
2176 , 'Header_Price_Atts'
2177 );
2178 END IF;
2179
2180
2181 OE_MSG_PUB.reset_msg_context('HEADER_PATTS');
2182 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2183 adj_debug('Exiting oe_order_Adj_pvt.HEader_Price_Atts', 1);
2184
2185 end HEader_Price_Atts;
2186
2187 PROCEDURE Header_Adj_Atts
2188 ( p_init_msg_list IN VARCHAR2:=FND_API.G_FALSE
2189 , p_validation_level IN NUMBER
2190 , p_control_rec IN OE_GLOBALS.Control_Rec_Type
2191 , p_x_Header_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Att_Tbl_Type
2192 , p_x_old_Header_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Att_Tbl_Type
2193 )
2194 is
2195 l_return_status VARCHAR2(1);
2196 l_control_rec OE_GLOBALS.Control_Rec_Type;
2197 l_Header_Adj_Att_rec OE_Order_PUB.Header_Adj_Att_Rec_Type;
2198 l_old_Header_Adj_Att_rec OE_Order_PUB.Header_Adj_Att_Rec_Type;
2199 -- local variables to store OUT parameters from security check procedures
2200 I pls_integer; -- Used as index for while loop
2201 BEGIN
2202
2203 IF FND_API.to_Boolean(p_init_msg_list) THEN
2204 OE_MSG_PUB.initialize;
2205 END IF;
2206
2207
2208 IF l_control_rec.Process_Partial THEN
2209 SAVEPOINT Header_price_atts;
2210 END IF;
2211
2212 -- Init local table variables.
2213
2214 --dbms_output.put_line('Entering oe_order_Adj_pvt.Header_price_atts');
2215 adj_debug('Enetring oe_order_Adj_pvt.HEader_Adj_Atts', 1);
2216
2217 I := p_x_Header_Adj_Att_tbl.FIRST;
2218
2219 WHILE I IS NOT NULL LOOP
2220 BEGIN
2221
2222 -- Load local records.
2223
2224 l_Header_Adj_Att_rec := p_x_Header_Adj_Att_tbl(I);
2225
2226 IF p_x_old_Header_Adj_Att_tbl.EXISTS(I) THEN
2227 l_old_Header_Adj_Att_rec := p_x_old_Header_Adj_Att_tbl(I);
2228 ELSE
2229 l_old_Header_Adj_Att_rec := OE_Order_PUB.G_MISS_Header_Adj_Att_REC;
2230 END IF;
2231
2232 if l_old_Header_Adj_Att_rec.Price_Adj_attrib_id = FND_API.G_MISS_NUM then
2233
2234 OE_MSG_PUB.set_msg_context(
2235 p_entity_code => 'ADJ_ATTS'
2236 ,p_entity_id => l_Header_Adj_Att_rec.Price_adj_attrib_id);
2237
2238 else
2239
2240 OE_MSG_PUB.set_msg_context(
2241 p_entity_code => 'ADJ_ATTS'
2242 ,p_entity_id => l_old_Header_Adj_Att_rec.Price_adj_attrib_id);
2243
2244 end if;
2245
2246 -- Load API control record
2247
2248 l_control_rec := OE_GLOBALS.Init_Control_Rec
2249 ( p_operation => l_Header_Adj_Att_rec.operation
2250 , p_control_rec => p_control_rec
2251 );
2252
2253 -- Set record return status.
2254
2255 l_Header_Adj_Att_rec.return_status := FND_API.G_RET_STS_SUCCESS;
2256
2257 -- Prepare record.
2258
2259 IF l_Header_Adj_Att_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
2260
2261 l_Header_Adj_Att_rec.db_flag := FND_API.G_FALSE;
2262
2263 -- Set missing old record elements to NULL.
2264
2265 adj_debug('Entering OE_Header_Adj_Att_Util.Convert_Miss_To_Null', 1);
2266 -- l_old_Header_Adj_Att_rec :=
2267 Oe_Header_Price_Aattr_util.Convert_Miss_To_Null (l_old_Header_Adj_Att_rec);
2268
2269 ELSIF l_Header_Adj_Att_rec.operation = OE_GLOBALS.G_OPR_UPDATE
2270 OR l_Header_Adj_Att_rec.operation = OE_GLOBALS.G_OPR_DELETE
2271 THEN
2272
2273 l_Header_Adj_Att_rec.db_flag := FND_API.G_TRUE;
2274
2275 -- Query Old if missing
2276
2277 IF l_old_Header_Adj_Att_rec.Price_adj_attrib_id = FND_API.G_MISS_NUM
2278 THEN
2279
2280
2281 Oe_Header_Price_Aattr_util.Query_Row
2282 ( p_Price_Adj_Attrib_id => l_Header_Adj_Att_rec.Price_adj_attrib_id
2283 , x_Header_Adj_Att_rec => l_old_Header_Adj_Att_rec
2284 );
2285
2286 ELSE
2287
2288 -- Set missing old record elements to NULL.
2289
2290 -- l_old_Header_Adj_Att_rec :=
2291 Oe_Header_Price_Aattr_util.Convert_Miss_To_Null (l_old_Header_Adj_Att_rec);
2292
2293 END IF;
2294
2295 -- Complete new record from old
2296
2297 -- l_Header_Adj_Att_rec :=
2298 Oe_Header_Price_Aattr_util.Complete_Record
2299 ( p_x_Header_Adj_Att_rec => l_Header_Adj_Att_rec
2300 , p_old_Header_Adj_Att_rec => l_old_Header_Adj_Att_rec
2301 );
2302
2303 OE_MSG_PUB.update_msg_context(
2304 p_entity_code => 'ADJ_ATTS'
2305 ,p_entity_id => l_Header_Adj_Att_rec.Price_adj_attrib_id);
2306
2307 END IF;
2308
2309 -- Default missing attributes
2310 IF l_control_rec.default_attributes
2311 THEN
2312
2313 OE_DEfault_Header_Aattr.Attributes
2314 ( p_Header_Adj_Att_rec => l_Header_Adj_Att_rec
2315 --, x_Header_Adj_Att_rec => l_Header_Adj_Att_rec
2316 );
2317
2318 END IF;
2319
2320 -- Apply attribute changes
2321
2322 IF l_control_rec.change_attributes
2323 THEN
2324
2325 -- This will also log request/s to check duplicity of
2326 -- price adjustment entered
2327 Oe_Header_Price_Aattr_util.Apply_Attribute_Changes
2328 ( p_x_Header_Adj_Att_rec => l_Header_Adj_Att_rec
2329 , p_old_Header_Adj_Att_rec => l_old_Header_Adj_Att_rec
2330 --, x_Header_Adj_Att_rec => l_Header_Adj_Att_rec
2331 );
2332
2333 END IF;
2334
2335 -- If there has any activity causing a change in any attribute
2336 -- log a request for repricing
2337
2338 -- Entity level validation.
2339
2340 -- Step 4. Write to DB
2341
2342 IF l_control_rec.write_to_db THEN
2343
2344 IF l_Header_Adj_Att_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
2345
2346 Oe_Header_Price_Aattr_util.Delete_Row
2347 ( p_Price_Adj_Attrib_id => l_Header_Adj_Att_rec.Price_adj_attrib_id
2348 );
2349
2350 ELSE
2351
2352 -- Get Who Information
2353
2354 l_Header_Adj_Att_rec.last_update_date := SYSDATE;
2355 l_Header_Adj_Att_rec.last_updated_by := FND_GLOBAL.USER_ID;
2356 l_Header_Adj_Att_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
2357
2358 IF l_Header_Adj_Att_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
2359
2360 Oe_Header_Price_Aattr_util.Update_Row (l_Header_Adj_Att_rec);
2361
2362 ELSIF l_Header_Adj_Att_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
2363
2364 l_Header_Adj_Att_rec.creation_date := SYSDATE;
2365 l_Header_Adj_Att_rec.created_by := FND_GLOBAL.USER_ID;
2366
2367 Oe_Header_Price_Aattr_util.Insert_Row (l_Header_Adj_Att_rec);
2368
2369 END IF;
2370
2371 END IF;
2372
2373 END IF;
2374
2375 -- Load tables.
2376
2377 p_x_Header_Adj_Att_tbl(I) := l_Header_Adj_Att_rec;
2378 p_x_old_Header_Adj_Att_tbl(I) := l_old_Header_Adj_Att_rec;
2379
2380 IF l_Header_Adj_Att_rec.return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2381 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2382 ELSIF l_Header_Adj_Att_rec.return_status = FND_API.G_RET_STS_ERROR THEN
2383 RAISE FND_API.G_EXC_ERROR;
2384 END IF;
2385
2386 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
2387 -- loop exception handler.
2388
2389 EXCEPTION
2390
2391 WHEN FND_API.G_EXC_ERROR THEN
2392
2393 l_Header_Adj_Att_rec.return_status := FND_API.G_RET_STS_ERROR;
2394 p_x_Header_Adj_Att_tbl(I) := l_Header_Adj_Att_rec;
2395 p_x_old_Header_Adj_Att_tbl(I) := l_old_Header_Adj_Att_rec;
2396
2397 IF l_control_rec.Process_Partial THEN
2398 ROLLBACK TO SAVEPOINT Header_price_atts;
2399 ELSE
2400 RAISE FND_API.G_EXC_ERROR;
2401 END IF;
2402
2403
2404 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2405
2406 l_Header_Adj_Att_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2407 p_x_Header_Adj_Att_tbl(I) := l_Header_Adj_Att_rec;
2408 p_x_old_Header_Adj_Att_tbl(I) := l_old_Header_Adj_Att_rec;
2409
2410 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2411
2412 WHEN OTHERS THEN
2413
2414 l_Header_Adj_Att_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2415 p_x_Header_Adj_Att_tbl(I) := l_Header_Adj_Att_rec;
2416 p_x_old_Header_Adj_Att_tbl(I) := l_old_Header_Adj_Att_rec;
2417
2418 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2419 THEN
2420 OE_MSG_PUB.Add_Exc_Msg
2421 ( G_PKG_NAME
2422 , 'Header_price_atts'
2423 );
2424 END IF;
2425
2426 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
2427 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2428
2429 END;
2430 I := p_x_Header_Adj_Att_tbl.NEXT(I);
2431 END LOOP;
2432
2433 -- Load OUT parameters
2434
2435 adj_debug('Exiting oe_order_Adj_pvt.Header_Adj_Atts', 1);
2436 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
2437
2438 EXCEPTION
2439
2440 WHEN FND_API.G_EXC_ERROR THEN
2441
2442 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
2443 RAISE;
2444
2445 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2446
2447 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
2448 RAISE;
2449
2450 WHEN OTHERS THEN
2451
2452 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2453 THEN
2454 OE_MSG_PUB.Add_Exc_Msg
2455 ( G_PKG_NAME
2456 , 'Header_Adj_Atts'
2457 );
2458 END IF;
2459
2460
2461 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
2462 adj_debug('Exiting oe_order_Adj_pvt.HEader_Adj_Atts', 1);
2463
2464 end Header_Adj_Atts;
2465
2466 PROCEDURE Header_Adj_Assocs
2467 ( p_init_msg_list IN VARCHAR2:=FND_API.G_FALSE
2468 , p_validation_level IN NUMBER
2469 , p_control_rec IN OE_GLOBALS.Control_Rec_Type
2470 , p_x_Header_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Assoc_Tbl_Type
2471 , p_x_old_Header_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Assoc_Tbl_Type
2472 )
2473 is
2474 l_return_status VARCHAR2(1);
2475 l_control_rec OE_GLOBALS.Control_Rec_Type;
2476 l_Header_Adj_Assoc_rec OE_Order_PUB.Header_Adj_Assoc_Rec_Type;
2477 l_old_Header_Adj_Assoc_rec OE_Order_PUB.Header_Adj_Assoc_Rec_Type;
2478 -- local variables to store OUT parameters from security check procedures
2479 I pls_integer; -- Used as index for while loop
2480 BEGIN
2481
2482 IF FND_API.to_Boolean(p_init_msg_list) THEN
2483 OE_MSG_PUB.initialize;
2484 END IF;
2485
2486 IF l_control_rec.Process_Partial THEN
2487 SAVEPOINT Header_Adj_Assocs;
2488 END IF;
2489
2490 -- Init local table variables.
2491
2492 --dbms_output.put_line('Entering oe_order_Adj_pvt.HEader_Price_assocs');
2493 adj_debug('Enetring oe_order_Adj_pvt.Header_Adj_Assocs', 1);
2494
2495
2496 I := p_x_Header_Adj_Assoc_tbl.FIRST;
2497
2498 WHILE I IS NOT NULL LOOP
2499 BEGIN
2500
2501 -- Load local records.
2502
2503 l_Header_Adj_Assoc_rec := p_x_Header_Adj_Assoc_tbl(I);
2504
2505 IF p_x_old_Header_Adj_Assoc_tbl.EXISTS(I) THEN
2506 l_old_Header_Adj_Assoc_rec := p_x_old_Header_Adj_Assoc_tbl(I);
2507 ELSE
2508 l_old_Header_Adj_Assoc_rec := OE_Order_PUB.G_MISS_Header_Adj_Assoc_REC;
2509 END IF;
2510
2511 if l_old_Header_Adj_Assoc_rec.Price_Adj_assoc_id = FND_API.G_MISS_NUM then
2512
2513 OE_MSG_PUB.set_msg_context(
2514 p_entity_code => 'ADJ_ATTS'
2515 ,p_entity_id => l_Header_Adj_Assoc_rec.Price_Adj_assoc_id);
2516
2517 else
2518
2519 OE_MSG_PUB.set_msg_context(
2520 p_entity_code => 'ADJ_ATTS'
2521 ,p_entity_id => l_old_Header_Adj_Assoc_rec.Price_Adj_assoc_id);
2522
2523 end if;
2524
2525 -- Load API control record
2526
2527 l_control_rec := OE_GLOBALS.Init_Control_Rec
2528 ( p_operation => l_Header_Adj_Assoc_rec.operation
2529 , p_control_rec => p_control_rec
2530 );
2531
2532 -- Set record return status.
2533
2534 l_Header_Adj_Assoc_rec.return_status := FND_API.G_RET_STS_SUCCESS;
2535
2536 -- Prepare record.
2537
2538 IF l_Header_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
2539
2540 l_Header_Adj_Assoc_rec.db_flag := FND_API.G_FALSE;
2541
2542 -- Set missing old record elements to NULL.
2543
2544 adj_debug('Entering OE_Header_Adj_Assoc_Util.Convert_Miss_To_Null', 1);
2545 -- l_old_Header_Adj_Assoc_rec :=
2546 Oe_Header_Adj_Assocs_util.Convert_Miss_To_Null (l_old_Header_Adj_Assoc_rec);
2547
2548 ELSIF l_Header_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_UPDATE
2549 OR l_Header_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_DELETE
2550 THEN
2551
2552 l_Header_Adj_Assoc_rec.db_flag := FND_API.G_TRUE;
2553
2554 -- Query Old if missing
2555
2556 IF l_old_Header_Adj_Assoc_rec.Price_Adj_assoc_id = FND_API.G_MISS_NUM
2557 THEN
2558
2559
2560 Oe_Header_Adj_Assocs_util.Query_Row
2561 ( p_Price_Adj_assoc_id => l_Header_Adj_Assoc_rec.Price_Adj_assoc_id
2562 , x_header_adj_Assoc_rec => l_old_Header_Adj_Assoc_rec
2563 );
2564
2565 ELSE
2566
2567 -- Set missing old record elements to NULL.
2568
2569 -- l_old_Header_Adj_Assoc_rec :=
2570 Oe_Header_Adj_Assocs_util.Convert_Miss_To_Null (l_old_Header_Adj_Assoc_rec);
2571
2572 END IF;
2573
2574 -- Complete new record from old
2575
2576 -- l_Header_Adj_Assoc_rec :=
2577 Oe_Header_Adj_Assocs_util.Complete_Record
2578 ( p_x_Header_Adj_Assoc_rec => l_Header_Adj_Assoc_rec
2579 , p_old_Header_Adj_Assoc_rec => l_old_Header_Adj_Assoc_rec
2580 );
2581
2582 OE_MSG_PUB.update_msg_context(
2583 p_entity_code => 'ADJ_ATTS'
2584 ,p_entity_id => l_Header_Adj_Assoc_rec.Price_Adj_assoc_id);
2585
2586 END IF;
2587
2588 -- Default missing attributes
2589 IF l_control_rec.default_attributes
2590 THEN
2591
2592 OE_DEfault_Header_Adj_Assocs.Attributes
2593 ( p_x_Header_Adj_Assoc_rec => l_Header_Adj_Assoc_rec
2594 --, x_Header_Adj_Assoc_rec => l_Header_Adj_Assoc_rec
2595 );
2596
2597 END IF;
2598
2599 -- Apply attribute changes
2600
2601 IF l_control_rec.change_attributes
2602 THEN
2603
2604 -- This will also log request/s to check duplicity of
2605 -- price adjustment entered
2606 Oe_Header_Adj_Assocs_util.Apply_Attribute_Changes
2607 ( p_x_Header_Adj_Assoc_rec => l_Header_Adj_Assoc_rec
2608 , p_old_Header_Adj_Assoc_rec => l_old_Header_Adj_Assoc_rec
2609 --, x_Header_Adj_Assoc_rec => l_Header_Adj_Assoc_rec
2610 );
2611
2612 END IF;
2613
2614 -- If there has any activity causing a change in any attribute
2615 -- log a request for repricing
2616
2617 -- Entity level validation.
2618
2619 -- Step 4. Write to DB
2620
2621 IF l_control_rec.write_to_db THEN
2622
2623 IF l_Header_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
2624
2625 Oe_Header_Adj_Assocs_util.Delete_Row
2626 ( p_Price_Adj_assoc_id => l_Header_Adj_Assoc_rec.Price_Adj_assoc_id
2627 );
2628
2629 ELSE
2630
2631 -- Get Who Information
2632
2633 l_Header_Adj_Assoc_rec.last_update_date := SYSDATE;
2634 l_Header_Adj_Assoc_rec.last_updated_by := FND_GLOBAL.USER_ID;
2635 l_Header_Adj_Assoc_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
2636
2637 IF l_Header_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
2638
2639 Oe_Header_Adj_Assocs_util.Update_Row (l_Header_Adj_Assoc_rec);
2640
2641 ELSIF l_Header_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
2642
2643 l_Header_Adj_Assoc_rec.creation_date := SYSDATE;
2644 l_Header_Adj_Assoc_rec.created_by := FND_GLOBAL.USER_ID;
2645
2646 Oe_Header_Adj_Assocs_util.Insert_Row (l_Header_Adj_Assoc_rec);
2647
2648 END IF;
2649
2650 END IF;
2651
2652 END IF;
2653
2654 -- Load tables.
2655
2656 p_x_Header_Adj_Assoc_tbl(I) := l_Header_Adj_Assoc_rec;
2657 p_x_old_Header_Adj_Assoc_tbl(I) := l_old_Header_Adj_Assoc_rec;
2658
2659 IF l_Header_Adj_Assoc_rec.return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2660 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2661 ELSIF l_Header_Adj_Assoc_rec.return_status = FND_API.G_RET_STS_ERROR THEN
2662 RAISE FND_API.G_EXC_ERROR;
2663 END IF;
2664
2665 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
2666 -- loop exception handler.
2667
2668 EXCEPTION
2669
2670 WHEN FND_API.G_EXC_ERROR THEN
2671
2672 l_Header_Adj_Assoc_rec.return_status := FND_API.G_RET_STS_ERROR;
2673 p_x_Header_Adj_Assoc_tbl(I) := l_Header_Adj_Assoc_rec;
2674 p_x_old_Header_Adj_Assoc_tbl(I) := l_old_Header_Adj_Assoc_rec;
2675
2676 IF l_control_rec.Process_Partial THEN
2677 ROLLBACK TO SAVEPOINT Header_Price_Assocs;
2678 ELSE
2679 RAISE FND_API.G_EXC_ERROR;
2680 END IF;
2681
2682
2683 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2684
2685 l_Header_Adj_Assoc_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2686 p_x_Header_Adj_Assoc_tbl(I) := l_Header_Adj_Assoc_rec;
2687 p_x_old_Header_Adj_Assoc_tbl(I) := l_old_Header_Adj_Assoc_rec;
2688
2689 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2690
2691 WHEN OTHERS THEN
2692
2693 l_Header_Adj_Assoc_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2694 p_x_Header_Adj_Assoc_tbl(I) := l_Header_Adj_Assoc_rec;
2695 p_x_old_Header_Adj_Assoc_tbl(I) := l_old_Header_Adj_Assoc_rec;
2696
2697 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2698 THEN
2699 OE_MSG_PUB.Add_Exc_Msg
2700 ( G_PKG_NAME
2701 , 'Header_price_atts'
2702 );
2703 END IF;
2704
2705 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
2706 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2707
2708 END;
2709 I := p_x_Header_Adj_Assoc_tbl.NEXT(I);
2710 END LOOP;
2711
2712 -- Load OUT parameters
2713
2714 adj_debug('Exiting oe_order_Adj_pvt.Header_Adj_Assocs', 1);
2715 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
2716
2717 EXCEPTION
2718
2719 WHEN FND_API.G_EXC_ERROR THEN
2720
2721 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
2722 RAISE;
2723
2724 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2725
2726 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
2727 RAISE;
2728
2729 WHEN OTHERS THEN
2730
2731 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2732 THEN
2733 OE_MSG_PUB.Add_Exc_Msg
2734 ( G_PKG_NAME
2735 , 'Header_Adj_Assocs'
2736 );
2737 END IF;
2738
2739
2740 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
2741 adj_debug('Exiting oe_order_Adj_pvt.Header_Adj_Assocs', 1);
2742 end Header_Adj_Assocs;
2743
2744 PROCEDURE Line_Price_Atts
2745 ( p_init_msg_list IN VARCHAR2:=FND_API.G_FALSE
2746 , p_validation_level IN NUMBER
2747 , p_control_rec IN OE_GLOBALS.Control_Rec_Type
2748 , p_x_Line_Price_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Price_Att_Tbl_Type
2749 , p_x_old_Line_Price_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Price_Att_Tbl_Type
2750 )
2751 is
2752 l_return_status VARCHAR2(1);
2753 l_control_rec OE_GLOBALS.Control_Rec_Type;
2754 l_Line_price_att_rec OE_Order_PUB.Line_Price_Att_Rec_Type;
2755 l_old_Line_price_att_rec OE_Order_PUB.Line_Price_Att_Rec_Type;
2756 -- local variables to store OUT parameters from security check procedures
2757 l_sec_result NUMBER;
2758 l_on_operation_action NUMBER;
2759 I pls_integer; -- Used as index for while loop
2760 l_booked_flag varchar2(1);
2761 l_Shipped_quantity number;
2762 l_pricing_event varchar2(30);
2763
2764 --
2765 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2766 --
2767 l_order_source_id NUMBER;
2768 l_orig_sys_document_ref VARCHAR2(50);
2769 l_orig_sys_line_ref VARCHAR2(50);
2770 l_orig_sys_shipment_ref VARCHAR2(50);
2771 l_change_sequence VARCHAR2(50);
2772 l_source_document_type_id NUMBER;
2773 l_source_document_id NUMBER;
2774 l_source_document_line_id NUMBER;
2775
2776 BEGIN
2777 l_control_rec := p_control_rec; -- Added for 1433292
2778 IF FND_API.to_Boolean(p_init_msg_list) THEN
2779 OE_MSG_PUB.initialize;
2780 END IF;
2781
2782 IF l_control_rec.Process_Partial THEN
2783 SAVEPOINT Line_price_atts;
2784 END IF;
2785
2786 -- Init local table variables.
2787
2788 --dbms_output.put_line('Entering oe_order_Adj_pvt.Line_price_atts');
2789 adj_debug('Entering oe_order_Adj_pvt.Line_price_atts', 1);
2790
2791 I := p_x_Line_price_att_tbl.FIRST;
2792
2793 WHILE I IS NOT NULL LOOP
2794 BEGIN
2795
2796 -- Load local records.
2797
2798 l_Line_price_att_rec := p_x_Line_price_att_tbl(I);
2799
2800 IF p_x_old_Line_price_att_tbl.EXISTS(I) THEN
2801 l_old_Line_price_att_rec := p_x_old_Line_price_att_tbl(I);
2802 ELSE
2803 l_old_Line_price_att_rec := OE_Order_PUB.G_MISS_Line_Price_Att_REC;
2804 END IF;
2805
2806 if l_old_Line_price_att_rec.Order_price_attrib_id = FND_API.G_MISS_NUM then
2807
2808 IF l_Line_price_att_rec.Line_Id IS NOT NULL AND
2809 l_Line_price_att_rec.Line_Id <> FND_API.G_MISS_NUM THEN
2810 BEGIN
2811 IF l_debug_level > 0 THEN
2812 oe_debug_pub.add('Getting reference data for line_id:'||l_Line_price_att_rec.Line_Id);
2813 END IF;
2814 SELECT order_source_id, orig_sys_document_ref, change_sequence,
2815 source_document_type_id, source_document_id, orig_sys_line_ref,
2816 source_document_line_id, orig_sys_shipment_ref
2817 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
2818 l_source_document_type_id, l_source_document_id, l_orig_sys_line_ref,
2819 l_source_document_line_id, l_orig_sys_shipment_ref
2820 FROM OE_ORDER_LINES_ALL
2821 WHERE line_id = l_Line_price_att_rec.Line_Id;
2822 EXCEPTION
2823 WHEN NO_DATA_FOUND THEN
2824 l_order_source_id := null;
2825 l_orig_sys_document_ref := null;
2826 l_change_sequence := null;
2827 l_source_document_type_id := null;
2828 l_source_document_id := null;
2829 l_orig_sys_line_ref := null;
2830 l_source_document_line_id := null;
2831 l_orig_sys_shipment_ref := null;
2832 WHEN OTHERS THEN
2833 l_order_source_id := null;
2834 l_orig_sys_document_ref := null;
2835 l_change_sequence := null;
2836 l_source_document_type_id := null;
2837 l_source_document_id := null;
2838 l_orig_sys_line_ref := null;
2839 l_source_document_line_id := null;
2840 l_orig_sys_shipment_ref := null;
2841 END;
2842 END IF;
2843
2844 OE_MSG_PUB.set_msg_context(
2845 p_entity_code => 'LINE_PATTS'
2846 ,p_entity_id => l_Line_price_att_rec.Order_price_attrib_id
2847 ,p_header_id => l_Line_price_att_rec.header_Id
2848 ,p_line_id => l_Line_price_att_rec.Line_Id
2849 ,p_order_source_id => l_order_source_id
2850 ,p_orig_sys_document_ref => l_orig_sys_document_ref
2851 ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
2852 ,p_orig_sys_shipment_ref => l_orig_sys_shipment_ref
2853 ,p_change_sequence => l_change_sequence
2854 ,p_source_document_type_id => l_source_document_type_id
2855 ,p_source_document_id => l_source_document_id
2856 ,p_source_document_line_id => l_source_document_line_id );
2857
2858 else
2859
2860 IF l_old_Line_price_att_rec.Line_Id IS NOT NULL AND
2861 l_old_Line_price_att_rec.Line_Id <> FND_API.G_MISS_NUM THEN
2862 BEGIN
2863 IF l_debug_level > 0 THEN
2864 oe_debug_pub.add('Getting reference data for old line_id:'||l_old_Line_price_att_rec.Line_Id);
2865 END IF;
2866 SELECT order_source_id, orig_sys_document_ref, change_sequence,
2867 source_document_type_id, source_document_id, orig_sys_line_ref,
2868 source_document_line_id, orig_sys_shipment_ref
2869 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
2870 l_source_document_type_id, l_source_document_id, l_orig_sys_line_ref,
2871 l_source_document_line_id, l_orig_sys_shipment_ref
2872 FROM OE_ORDER_LINES_ALL
2873 WHERE line_id = l_old_Line_price_att_rec.Line_Id;
2874 EXCEPTION
2875 WHEN NO_DATA_FOUND THEN
2876 l_order_source_id := null;
2877 l_orig_sys_document_ref := null;
2878 l_change_sequence := null;
2879 l_source_document_type_id := null;
2880 l_source_document_id := null;
2881 l_orig_sys_line_ref := null;
2882 l_source_document_line_id := null;
2883 l_orig_sys_shipment_ref := null;
2884 WHEN OTHERS THEN
2885 l_order_source_id := null;
2886 l_orig_sys_document_ref := null;
2887 l_change_sequence := null;
2888 l_source_document_type_id := null;
2889 l_source_document_id := null;
2890 l_orig_sys_line_ref := null;
2891 l_source_document_line_id := null;
2892 l_orig_sys_shipment_ref := null;
2893 END;
2894 END IF;
2895
2896 OE_MSG_PUB.set_msg_context(
2897 p_entity_code => 'LINE_PATTS'
2898 ,p_entity_id => l_old_Line_price_att_rec.Order_price_attrib_id
2899 ,p_header_id => l_old_Line_price_att_rec.header_Id
2900 ,p_line_id => l_old_Line_price_att_rec.Line_Id
2901 ,p_order_source_id => l_order_source_id
2902 ,p_orig_sys_document_ref => l_orig_sys_document_ref
2903 ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
2904 ,p_orig_sys_shipment_ref => l_orig_sys_shipment_ref
2905 ,p_change_sequence => l_change_sequence
2906 ,p_source_document_type_id => l_source_document_type_id
2907 ,p_source_document_id => l_source_document_id
2908 ,p_source_document_line_id => l_source_document_line_id );
2909
2910 end if;
2911
2912 -- Load API control record
2913
2914 l_control_rec := OE_GLOBALS.Init_Control_Rec
2915 ( p_operation => l_Line_price_att_rec.operation
2916 , p_control_rec => p_control_rec
2917 );
2918
2919 -- Set record return status.
2920
2921 l_Line_price_att_rec.return_status := FND_API.G_RET_STS_SUCCESS;
2922
2923 -- Prepare record.
2924
2925 IF l_Line_price_att_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
2926
2927 l_Line_price_att_rec.db_flag := FND_API.G_FALSE;
2928
2929 -- Set missing old record elements to NULL.
2930
2931 adj_debug('Entering OE_Line_price_att_Util.Convert_Miss_To_Null', 1);
2932 -- l_old_Line_price_att_rec :=
2933 OE_Line_Pattr_Util.Convert_Miss_To_Null (l_old_Line_price_att_rec);
2934
2935 ELSIF l_Line_price_att_rec.operation = OE_GLOBALS.G_OPR_UPDATE
2936 OR l_Line_price_att_rec.operation = OE_GLOBALS.G_OPR_DELETE
2937 THEN
2938
2939 l_Line_price_att_rec.db_flag := FND_API.G_TRUE;
2940
2941 -- Query Old if missing
2942
2943 IF l_old_Line_price_att_rec.order_price_attrib_id = FND_API.G_MISS_NUM
2944 THEN
2945
2946 OE_Line_Pattr_Util.Query_Row
2947 ( p_order_price_attrib_id => l_Line_price_att_rec.order_price_attrib_id
2948 , x_Line_price_att_rec => l_old_Line_price_att_rec
2949 );
2950
2951 ELSE
2952
2953 -- Set missing old record elements to NULL.
2954
2955 -- l_old_Line_price_att_rec :=
2956 OE_Line_Pattr_Util.Convert_Miss_To_Null (l_old_Line_price_att_rec);
2957
2958 END IF;
2959
2960 -- Complete new record from old
2961
2962 -- l_Line_price_att_rec :=
2963 OE_Line_Pattr_Util.Complete_Record
2964 ( p_x_Line_price_att_rec => l_Line_Price_Att_rec
2965 , p_old_Line_price_att_rec => l_old_Line_Price_Att_rec
2966 );
2967
2968 OE_MSG_PUB.update_msg_context(
2969 p_entity_code => 'LINE_PATTS'
2970 ,p_entity_id => l_Line_price_att_rec.order_price_attrib_id
2971 ,p_header_id => l_Line_price_att_rec.header_Id
2972 ,p_line_id => l_Line_price_att_rec.line_id);
2973
2974 END IF;
2975
2976
2977 IF I = p_x_line_Price_Att_tbl.FIRST THEN
2978 IF NOT oe_order_pvt.Valid_Upgraded_Order(l_line_Price_Att_rec.header_id) THEN
2979 RAISE FND_API.G_EXC_ERROR;
2980 END IF;
2981 END IF;
2982
2983 /*
2984 -- Check security
2985 IF l_control_rec.check_security
2986 AND (l_Line_price_att_rec.operation = OE_GLOBALS.G_OPR_CREATE
2987 OR l_Line_price_att_rec.operation = OE_GLOBALS.G_OPR_UPDATE)
2988 THEN
2989
2990 adj_debug('Check Attributes Security');
2991 -- check if this operation is allowed
2992 -- on all the changed attributes
2993 OE_Line_price_att_Security.Attributes
2994 (p_Line_price_att_rec => l_Line_Price_Att_rec
2995 , p_old_Line_price_att_rec => l_old_Line_Price_Att_rec
2996 , x_result => l_sec_result
2997 , x_return_status => l_return_status
2998 );
2999
3000 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3001 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3002 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3003 RAISE FND_API.G_EXC_ERROR;
3004 END IF;
3005
3006 IF l_sec_result = OE_PC_GLOBALS.YES THEN
3007 RAISE FND_API.G_EXC_ERROR;
3008 END IF;
3009
3010 END IF;
3011 */
3012 -- Attribute level validation.
3013
3014 IF p_validation_level > FND_API.G_VALID_LEVEL_NONE THEN
3015
3016 OE_Validate_Line_Pattr.Attributes
3017 ( x_return_status => l_return_status
3018 , p_Line_price_attr_rec => l_Line_Price_Att_rec
3019 , p_old_Line_price_attr_rec => l_old_Line_Price_Att_rec
3020 , p_validation_level => p_validation_level
3021 );
3022
3023 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3024 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3025 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3026 RAISE FND_API.G_EXC_ERROR;
3027 END IF;
3028
3029 END IF;
3030
3031 -- Clear dependent attributes.
3032
3033 IF l_control_rec.clear_dependents THEN
3034
3035 OE_Line_Pattr_Util.Clear_Dependent_Attr
3036 ( p_x_Line_price_att_rec => l_Line_Price_Att_rec
3037 , p_old_Line_price_att_rec => l_old_Line_Price_Att_rec
3038 --, x_Line_price_att_rec => l_Line_Price_Att_rec
3039 );
3040
3041 END IF;
3042
3043 -- Default missing attributes
3044 IF l_control_rec.default_attributes
3045 THEN
3046
3047 OE_Default_Line_Pattr.Attributes
3048 ( p_x_Line_price_att_rec => l_Line_Price_Att_rec
3049 --, p_old_Line_price_att_rec => l_old_Line_Price_Att_rec
3050 --, x_Line_price_att_rec => l_Line_Price_Att_rec
3051 );
3052
3053 END IF;
3054
3055 -- Apply attribute changes
3056
3057 IF l_control_rec.change_attributes
3058 THEN
3059
3060 -- This will also log request/s to check duplicity of
3061 -- price adjustment entered
3062 OE_Line_Pattr_Util.Apply_Attribute_Changes
3063 ( p_x_Line_price_att_rec => l_Line_Price_Att_rec
3064 , p_old_Line_price_att_rec => l_old_Line_Price_Att_rec
3065 --, x_Line_price_att_rec => l_Line_Price_Att_rec
3066 );
3067
3068 END IF;
3069
3070 -- If there has any activity causing a change in any attribute
3071 -- log a request for repricing
3072
3073 -- Entity level validation.
3074
3075 IF l_control_rec.validate_entity THEN
3076
3077 IF l_Line_price_att_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
3078
3079 OE_Validate_Line_Pattr.Entity_Delete
3080 ( x_return_status => l_return_status
3081 , p_Line_price_attr_rec => l_Line_Price_Att_rec
3082 );
3083
3084 ELSE
3085
3086 /*OE_Validate_Line_Pattr.Entity
3087 ( x_return_status => l_return_status
3088 , p_Line_price_attr_rec => l_Line_Price_Att_rec
3089 , p_old_Line_price_attr_rec => l_old_Line_Price_Att_rec
3090 );*/
3091
3092 NULL;
3093
3094 END IF;
3095
3096 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3097 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3098 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3099 RAISE FND_API.G_EXC_ERROR;
3100 END IF;
3101
3102 END IF;
3103
3104 -- Step 4. Write to DB
3105
3106 IF l_control_rec.write_to_db THEN
3107
3108 IF l_Line_price_att_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
3109
3110 OE_Line_Pattr_Util.Delete_Row
3111 ( p_order_price_attrib_id => l_Line_price_att_rec.order_price_attrib_id
3112 );
3113 --2442012
3114 /* OE_delayed_requests_Pvt.log_request(
3115 p_entity_code => OE_GLOBALS.G_ENTITY_Line_Price_Att,
3116 p_entity_id => l_Line_Price_Att_rec.line_id,
3117 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_Line_Price_Att,
3118 p_requesting_entity_id => l_Line_Price_Att_rec.line_id,
3119 p_param1 => l_Line_Price_Att_rec.header_id,
3120 p_param2 => 'LINE',
3121 p_request_type => OE_GLOBALS.G_PRICE_LINE,
3122 x_return_status => l_return_status);
3123
3124 OE_delayed_requests_Pvt.log_request(
3125 p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
3126 p_entity_id => l_Line_Price_Att_rec.Header_Id,
3127 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
3128 p_requesting_entity_id => l_Line_Price_Att_rec.Header_Id,
3129 p_param1 => l_Line_Price_Att_rec.header_id,
3130 p_param2 => 'ORDER',
3131 p_request_type => OE_GLOBALS.G_PRICE_ORDER,
3132 x_return_status => l_return_status);
3133 */
3134 Begin
3135 Select booked_flag,Shipped_quantity into
3136 l_booked_flag,l_Shipped_quantity
3137 From OE_Order_lines where
3138 Line_id = l_Line_Price_Att_rec.Line_Id;
3139 Exception when no_data_found then
3140 Null;
3141 End;
3142
3143 If l_booked_flag='Y' Then
3144 l_pricing_event := 'ORDER,BOOK';
3145 Else
3146 l_pricing_event := 'ORDER';
3147 End If;
3148 OE_delayed_requests_Pvt.log_request(
3149 p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
3150 p_entity_id => l_Line_Price_Att_rec.Header_Id,
3151 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
3152 p_requesting_entity_id => l_Line_Price_Att_rec.Header_Id,
3153 p_request_unique_key1 => l_pricing_event,
3154 p_param1 => l_Line_Price_Att_rec.header_id,
3155 p_param2 => l_pricing_event,
3156 p_request_type => OE_GLOBALS.G_PRICE_ORDER,
3157 x_return_status => l_return_status);
3158 -- End If;
3159
3160 If l_Shipped_quantity > 0 Then
3161 l_pricing_event := 'LINE,SHIP';
3162 Else
3163 l_pricing_event := 'LINE';
3164 End if;
3165 OE_delayed_requests_Pvt.log_request(
3166 p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
3167 p_entity_id => l_Line_Price_Att_rec.Line_Id,
3168 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
3169 p_requesting_entity_id => l_Line_Price_Att_rec.Line_Id,
3170 p_request_unique_key1 => l_pricing_event,
3171 p_param1 => l_Line_Price_Att_rec.header_id,
3172 p_param2 => l_pricing_event,
3173 p_request_type => OE_GLOBALS.G_PRICE_LINE,
3174 x_return_status => l_return_status);
3175 --2442012 End If;
3176
3177
3178 ELSE
3179
3180 -- Get Who Information
3181
3182
3183 l_Line_price_att_rec.last_update_date := SYSDATE;
3184 l_Line_price_att_rec.last_updated_by := FND_GLOBAL.USER_ID;
3185 l_Line_price_att_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
3186
3187 IF l_Line_price_att_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
3188
3189 OE_Line_Pattr_Util.Update_Row (l_Line_price_att_rec);
3190
3191 ELSIF l_Line_price_att_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
3192
3193 l_Line_price_att_rec.creation_date := SYSDATE;
3194 l_Line_price_att_rec.created_by := FND_GLOBAL.USER_ID;
3195
3196 --BT
3197 --Added the If loop for Bug 3402434
3198 If(l_Line_price_att_rec.order_price_attrib_id is NULL or
3199 l_Line_price_att_rec.order_price_attrib_id=FND_API.G_MISS_NUM) THEN
3200 select OE_ORDER_PRICE_ATTRIBS_S.nextval
3201 into l_Line_price_att_rec.order_price_attrib_id
3202 from dual;
3203 End If;
3204 OE_Line_Pattr_Util.Insert_Row (l_Line_price_att_rec);
3205
3206 END IF;
3207
3208 END IF;
3209
3210 END IF;
3211
3212 -- Load tables.
3213
3214 p_x_Line_price_att_tbl(I) := l_Line_Price_Att_rec;
3215 p_x_old_Line_price_att_tbl(I) := l_old_Line_Price_Att_rec;
3216
3217 IF l_Line_price_att_rec.return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3218 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3219 ELSIF l_Line_price_att_rec.return_status = FND_API.G_RET_STS_ERROR THEN
3220 RAISE FND_API.G_EXC_ERROR;
3221 END IF;
3222
3223 OE_MSG_PUB.reset_msg_context('HEADER_ADJ');
3224 -- loop exception handler.
3225
3226 EXCEPTION
3227
3228 WHEN FND_API.G_EXC_ERROR THEN
3229
3230 l_Line_price_att_rec.return_status := FND_API.G_RET_STS_ERROR;
3231 p_x_Line_price_att_tbl(I) := l_Line_Price_Att_rec;
3232 p_x_old_Line_price_att_tbl(I) := l_old_Line_Price_Att_rec;
3233
3234 IF l_control_rec.Process_Partial THEN
3235 ROLLBACK TO SAVEPOINT Line_price_atts;
3236 ELSE
3237 RAISE FND_API.G_EXC_ERROR;
3238 END IF;
3239
3240
3241 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3242
3243 l_Line_price_att_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3244 p_x_Line_price_att_tbl(I) := l_Line_Price_Att_rec;
3245 p_x_old_Line_price_att_tbl(I) := l_old_Line_Price_Att_rec;
3246
3247 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3248
3249 WHEN OTHERS THEN
3250
3251 l_Line_price_att_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3252 p_x_Line_price_att_tbl(I) := l_Line_Price_Att_rec;
3253 p_x_old_Line_price_att_tbl(I) := l_old_Line_Price_Att_rec;
3254
3255 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3256 THEN
3257 OE_MSG_PUB.Add_Exc_Msg
3258 ( G_PKG_NAME
3259 , 'Line_price_atts'
3260 );
3261 END IF;
3262
3263 OE_MSG_PUB.reset_msg_context('HEADER_PATTS');
3264 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3265
3266 END;
3267 I := p_x_Line_price_att_tbl.NEXT(I);
3268 END LOOP;
3269
3270 -- Load OUT parameters
3271
3272 adj_debug('Exiting oe_order_Adj_pvt.Line_price_atts', 1);
3273 OE_MSG_PUB.reset_msg_context('HEADER_PATTS');
3274
3275 EXCEPTION
3276
3277 WHEN FND_API.G_EXC_ERROR THEN
3278
3279 OE_MSG_PUB.reset_msg_context('HEADER_PATTS');
3280 RAISE;
3281
3282 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3283
3284 OE_MSG_PUB.reset_msg_context('HEADER_PATTS');
3285 RAISE;
3286
3287 WHEN OTHERS THEN
3288
3289 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3290 THEN
3291 OE_MSG_PUB.Add_Exc_Msg
3292 ( G_PKG_NAME
3293 , 'Line_price_atts'
3294 );
3295 END IF;
3296
3297
3298 OE_MSG_PUB.reset_msg_context('LINE_PATTS');
3299 adj_debug('Exiting oe_order_Adj_pvt.Line_Price_Atts', 1);
3300 end Line_Price_Atts;
3301
3302
3303 PROCEDURE Insert_Adj_Atts
3304 (p_Line_Adj_attribs_tbl IN OE_Order_PUB.Line_Adj_Att_Tbl_Type
3305 )
3306 is
3307 I PLS_INTEGER;
3308 l_line_dummy_adj_att_tbl OE_Order_PUB.Line_Adj_Att_Tbl_Type;
3309 l_line_adj_att_tbl OE_Order_PUB.Line_Adj_Att_Tbl_Type;
3310 l_control_rec OE_GLOBALS.Control_Rec_Type;
3311 Begin
3312 l_line_adj_att_tbl := p_Line_Adj_attribs_tbl;
3313
3314 l_control_rec.private_call := TRUE;
3315 l_control_rec.controlled_operation := TRUE;
3316 l_control_rec.check_security := TRUE;
3317 l_control_rec.validate_entity := FALSE;
3318 l_control_rec.write_to_db := TRUE;
3319 l_control_rec.change_attributes := FALSE;
3320
3321 I := p_Line_Adj_attribs_tbl.first;
3322
3323 While I Is Not Null Loop
3324 --l_line_adj_assoc_tbl(i) := OE_ORDER_PUB.G_MISS_LINE_ADJ_ASSOC_REC;
3325 l_line_adj_att_tbl(i).Operation := OE_Globals.G_OPR_CREATE;
3326
3327 Select OE_PRICE_ADJ_ATTRIBS_S.nextval
3328 Into l_line_adj_att_tbl(i).price_adj_attrib_id
3329 From dual;
3330
3331 I:= p_Line_Adj_attribs_tbl.Next(I);
3332 End Loop;
3333
3334 Oe_Order_Adj_Pvt.Line_Adj_Atts( p_validation_level=>FND_API.G_VALID_LEVEL_NONE,
3335 p_control_rec=>l_control_rec,
3336 p_x_Line_Adj_Att_tbl =>l_line_adj_att_tbl,
3337 p_x_old_Line_Adj_Att_tbl=>l_line_dummy_adj_att_tbl);
3338
3339 End Insert_Adj_Atts;
3340
3341
3342
3343 PROCEDURE Line_Adj_Atts
3344 ( p_init_msg_list IN VARCHAR2:=FND_API.G_FALSE
3345 , p_validation_level IN NUMBER
3346 , p_control_rec IN OE_GLOBALS.Control_Rec_Type
3347 , p_x_Line_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Att_Tbl_Type
3348 , p_x_old_Line_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Att_Tbl_Type
3349 )
3350 is
3351 l_return_status VARCHAR2(1);
3352 l_control_rec OE_GLOBALS.Control_Rec_Type;
3353 l_Line_Adj_att_rec OE_Order_PUB.Line_Adj_Att_Rec_Type;
3354 l_old_Line_Adj_att_rec OE_Order_PUB.Line_Adj_Att_Rec_Type;
3355 -- local variables to store OUT parameters from security check procedures
3356 I pls_integer; -- Used as index for while loop
3357 BEGIN
3358
3359 IF FND_API.to_Boolean(p_init_msg_list) THEN
3360 OE_MSG_PUB.initialize;
3361 END IF;
3362
3363 IF l_control_rec.Process_Partial THEN
3364 SAVEPOINT Line_Adj_atts;
3365 END IF;
3366
3367 -- Init local table variables.
3368
3369 --dbms_output.put_line('Entering oe_order_Adj_pvt.Line_price_atts');
3370 adj_debug('Entering oe_order_Adj_pvt.Line_Adj_atts', 1);
3371
3372 I := p_x_Line_Adj_Att_tbl.FIRST;
3373
3374 WHILE I IS NOT NULL LOOP
3375 BEGIN
3376
3377 -- Load local records.
3378
3379 l_Line_Adj_Att_rec := p_x_Line_Adj_Att_tbl(I);
3380
3381 IF p_x_old_Line_Adj_Att_tbl.EXISTS(I) THEN
3382 l_old_Line_Adj_Att_rec := p_x_old_Line_Adj_Att_tbl(I);
3383 ELSE
3384 l_old_Line_Adj_Att_rec := OE_Order_PUB.G_MISS_Line_Adj_Att_REC;
3385 END IF;
3386
3387 if l_old_Line_Adj_Att_rec.Price_Adj_attrib_id = FND_API.G_MISS_NUM then
3388
3389 OE_MSG_PUB.set_msg_context(
3390 p_entity_code => 'ADJ_ATTS'
3391 ,p_entity_id => l_Line_Adj_Att_rec.Price_adj_attrib_id);
3392
3393 else
3394
3395 OE_MSG_PUB.set_msg_context(
3396 p_entity_code => 'ADJ_ATTS'
3397 ,p_entity_id => l_old_Line_Adj_Att_rec.Price_adj_attrib_id);
3398
3399 end if;
3400
3401 -- Load API control record
3402
3403 l_control_rec := OE_GLOBALS.Init_Control_Rec
3404 ( p_operation => l_Line_Adj_Att_rec.operation
3405 , p_control_rec => p_control_rec
3406 );
3407
3408 -- Set record return status.
3409
3410 l_Line_Adj_Att_rec.return_status := FND_API.G_RET_STS_SUCCESS;
3411
3412 -- Prepare record.
3413
3414 IF l_Line_Adj_Att_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
3415
3416 l_Line_Adj_Att_rec.db_flag := FND_API.G_FALSE;
3417
3418 -- Set missing old record elements to NULL.
3419
3420 adj_debug('Entering OE_Line_Adj_Att_Util.Convert_Miss_To_Null', 1);
3421 -- l_old_Line_Adj_Att_rec :=
3422 Oe_Line_Price_Aattr_util.Convert_Miss_To_Null (l_old_Line_Adj_Att_rec);
3423
3424 ELSIF l_Line_Adj_Att_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3425 OR l_Line_Adj_Att_rec.operation = OE_GLOBALS.G_OPR_DELETE
3426 THEN
3427
3428 l_Line_Adj_Att_rec.db_flag := FND_API.G_TRUE;
3429
3430 -- Query Old if missing
3431
3432 IF l_old_Line_Adj_Att_rec.Price_adj_attrib_id = FND_API.G_MISS_NUM
3433 THEN
3434
3435
3436 Oe_Line_Price_Aattr_util.Query_Row
3437 ( p_Price_Adj_Attrib_id => l_Line_Adj_Att_rec.Price_adj_attrib_id
3438 , x_Line_Adj_Att_rec => l_old_Line_Adj_Att_rec
3439 );
3440
3441 ELSE
3442
3443 -- Set missing old record elements to NULL.
3444
3445 -- l_old_Line_Adj_Att_rec :=
3446 Oe_Line_Price_Aattr_util.Convert_Miss_To_Null (l_old_Line_Adj_Att_rec);
3447
3448 END IF;
3449
3450 -- Complete new record from old
3451
3452 -- l_Line_Adj_Att_rec :=
3453 Oe_Line_Price_Aattr_util.Complete_Record
3454 ( p_x_Line_Adj_Att_rec => l_Line_Adj_Att_rec
3455 , p_old_Line_Adj_Att_rec => l_old_Line_Adj_Att_rec
3456 );
3457
3458 OE_MSG_PUB.update_msg_context(
3459 p_entity_code => 'ADJ_ATTS'
3460 ,p_entity_id => l_Line_Adj_Att_rec.Price_adj_attrib_id);
3461
3462 END IF;
3463
3464 /*
3465 -- Attribute level validation.
3466
3467 IF p_validation_level > FND_API.G_VALID_LEVEL_NONE THEN
3468
3469 OE_Validate_Line_Pattr.Attributes
3470 ( x_return_status => l_return_status
3471 , p_Line_price_attr_rec => l_Line_Adj_Att_rec
3472 , p_old_Line_price_attr_rec => l_old_Line_Adj_Att_rec
3473 , p_validation_level => p_validation_level
3474 );
3475
3476 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3477 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3478 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3479 RAISE FND_API.G_EXC_ERROR;
3480 END IF;
3481
3482 END IF;
3483 */
3484
3485 -- Default missing attributes
3486 IF l_control_rec.default_attributes
3487 THEN
3488
3489 OE_DEfault_Line_Aattr.Attributes
3490 ( p_Line_Adj_Att_rec => l_Line_Adj_Att_rec
3491 --, x_Line_Adj_Att_rec => l_Line_Adj_Att_rec
3492 );
3493
3494 END IF;
3495
3496 -- Apply attribute changes
3497
3498 IF l_control_rec.change_attributes
3499 THEN
3500
3501 -- This will also log request/s to check duplicity of
3502 -- price adjustment entered
3503 Oe_Line_Price_Aattr_util.Apply_Attribute_Changes
3504 ( p_x_Line_Adj_Att_rec => l_Line_Adj_Att_rec
3505 , p_old_Line_Adj_Att_rec => l_old_Line_Adj_Att_rec
3506 --, x_Line_Adj_Att_rec => l_Line_Adj_Att_rec
3507 );
3508
3509 END IF;
3510
3511 -- If there has any activity causing a change in any attribute
3512 -- log a request for repricing
3513
3514 -- Entity level validation.
3515
3516 -- Step 4. Write to DB
3517
3518 IF l_control_rec.write_to_db THEN
3519
3520 IF l_Line_Adj_Att_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
3521
3522 Oe_Line_Price_Aattr_util.Delete_Row
3523 ( p_Price_Adj_Attrib_id => l_Line_Adj_Att_rec.Price_adj_attrib_id
3524 );
3525
3526 ELSE
3527
3528 -- Get Who Information
3529
3530 l_Line_Adj_Att_rec.last_update_date := SYSDATE;
3531 l_Line_Adj_Att_rec.last_updated_by := FND_GLOBAL.USER_ID;
3532 l_Line_Adj_Att_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
3533
3534 IF l_Line_Adj_Att_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
3535
3536 Oe_Line_Price_Aattr_util.Update_Row (l_Line_Adj_Att_rec);
3537
3538 ELSIF l_Line_Adj_Att_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
3539
3540 l_Line_Adj_Att_rec.creation_date := SYSDATE;
3541 l_Line_Adj_Att_rec.created_by := FND_GLOBAL.USER_ID;
3542
3543 Oe_Line_Price_Aattr_util.Insert_Row (l_Line_Adj_Att_rec);
3544
3545 END IF;
3546
3547 END IF;
3548
3549 END IF;
3550
3551 -- Load tables.
3552
3553 p_x_Line_Adj_Att_tbl(I) := l_Line_Adj_Att_rec;
3554 p_x_old_Line_Adj_Att_tbl(I) := l_old_Line_Adj_Att_rec;
3555
3556 IF l_Line_Adj_Att_rec.return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3557 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3558 ELSIF l_Line_Adj_Att_rec.return_status = FND_API.G_RET_STS_ERROR THEN
3559 RAISE FND_API.G_EXC_ERROR;
3560 END IF;
3561
3562 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
3563 -- loop exception handler.
3564
3565 EXCEPTION
3566
3567 WHEN FND_API.G_EXC_ERROR THEN
3568
3569 l_Line_Adj_Att_rec.return_status := FND_API.G_RET_STS_ERROR;
3570 p_x_Line_Adj_Att_tbl(I) := l_Line_Adj_Att_rec;
3571 p_x_old_Line_Adj_Att_tbl(I) := l_old_Line_Adj_Att_rec;
3572
3573 IF l_control_rec.Process_Partial THEN
3574 ROLLBACK TO SAVEPOINT Line_Adj_atts;
3575 ELSE
3576 RAISE FND_API.G_EXC_ERROR;
3577 END IF;
3578
3579
3580 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3581
3582 l_Line_Adj_Att_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3583 p_x_Line_Adj_Att_tbl(I) := l_Line_Adj_Att_rec;
3584 p_x_old_Line_Adj_Att_tbl(I) := l_old_Line_Adj_Att_rec;
3585
3586 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3587
3588 WHEN OTHERS THEN
3589
3590 l_Line_Adj_Att_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3591 p_x_Line_Adj_Att_tbl(I) := l_Line_Adj_Att_rec;
3592 p_x_old_Line_Adj_Att_tbl(I) := l_old_Line_Adj_Att_rec;
3593
3594 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3595 THEN
3596 OE_MSG_PUB.Add_Exc_Msg
3597 ( G_PKG_NAME
3598 , 'Line_Adj_atts'
3599 );
3600 END IF;
3601
3602 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
3603 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3604
3605 END;
3606 I := p_x_Line_Adj_Att_tbl.NEXT(I);
3607 END LOOP;
3608
3609 -- Load OUT parameters
3610
3611 adj_debug('Exiting oe_order_Adj_pvt.Line_Adj_atts', 1);
3612 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
3613
3614 EXCEPTION
3615
3616 WHEN FND_API.G_EXC_ERROR THEN
3617
3618 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
3619 RAISE;
3620
3621 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3622
3623 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
3624 RAISE;
3625
3626 WHEN OTHERS THEN
3627
3628 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3629 THEN
3630 OE_MSG_PUB.Add_Exc_Msg
3631 ( G_PKG_NAME
3632 , 'Line_Adj_atts'
3633 );
3634 END IF;
3635
3636
3637 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
3638
3639 adj_debug('Exiting oe_order_Adj_pvt.Line_Adj_Atts', 1);
3640 end Line_Adj_Atts;
3641
3642 PROCEDURE Insert_Adj_Assocs
3643 (p_Line_Adj_Assoc_tbl IN OE_Order_PUB.Line_Adj_Assoc_Tbl_Type
3644 )
3645 is
3646 I PLS_INTEGER;
3647 l_line_dummy_adj_assoc_tbl OE_Order_PUB.Line_Adj_Assoc_Tbl_Type;
3648 l_line_adj_assoc_tbl OE_Order_PUB.Line_Adj_Assoc_Tbl_Type;
3649 l_control_rec OE_GLOBALS.Control_Rec_Type;
3650 Begin
3651 l_line_adj_assoc_tbl := p_Line_Adj_Assoc_tbl;
3652 l_control_rec.private_call := TRUE;
3653 l_control_rec.controlled_operation := TRUE;
3654 l_control_rec.check_security := TRUE;
3655 l_control_rec.validate_entity := FALSE;
3656 l_control_rec.write_to_db := TRUE;
3657 l_control_rec.change_attributes := FALSE;
3658
3659 I := p_line_adj_assoc_tbl.first;
3660
3661 While I Is Not Null Loop
3662 --l_line_adj_assoc_tbl(i) := OE_ORDER_PUB.G_MISS_LINE_ADJ_ASSOC_REC;
3663 l_Line_Adj_Assoc_tbl(i).Operation := OE_Globals.G_OPR_CREATE;
3664
3665 Select oe_price_adj_assocs_s.nextval
3666 Into l_line_adj_assoc_tbl(i).price_adj_assoc_id
3667 From dual;
3668
3669 I:= p_line_adj_assoc_tbl.Next(I);
3670 End Loop;
3671
3672 Oe_Order_Adj_Pvt.Line_Adj_Assocs(p_validation_level=>FND_API.G_VALID_LEVEL_NONE,
3673 p_control_rec=>l_control_rec,
3674 p_x_line_adj_assoc_tbl=>l_line_adj_assoc_tbl,
3675 p_x_old_line_adj_assoc_tbl=>l_line_dummy_adj_assoc_tbl);
3676
3677 End;
3678
3679
3680 PROCEDURE Line_Adj_Assocs
3681 ( p_init_msg_list IN VARCHAR2:=FND_API.G_FALSE
3682 , p_validation_level IN NUMBER
3683 , p_control_rec IN OE_GLOBALS.Control_Rec_Type
3684 , p_x_Line_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Assoc_Tbl_Type
3685 , p_x_old_Line_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Assoc_Tbl_Type
3686 )
3687 is
3688 l_return_status VARCHAR2(1);
3689 l_control_rec OE_GLOBALS.Control_Rec_Type;
3690 l_Line_Adj_Assoc_rec OE_Order_PUB.Line_Adj_Assoc_Rec_Type;
3691 l_old_Line_Adj_Assoc_rec OE_Order_PUB.Line_Adj_Assoc_Rec_Type;
3692 -- local variables to store OUT parameters from security check procedures
3693 I pls_integer; -- Used as index for while loop
3694 BEGIN
3695
3696 IF FND_API.to_Boolean(p_init_msg_list) THEN
3697 OE_MSG_PUB.initialize;
3698 END IF;
3699
3700 IF l_control_rec.Process_Partial THEN
3701 SAVEPOINT Line_Adj_Assocs;
3702 END IF;
3703
3704 -- Init local table variables.
3705
3706 --dbms_output.put_line('Entering oe_order_Adj_pvt.Line_price_atts');
3707 adj_debug('Entering oe_order_Adj_pvt.Line_Adj_Assocs', 1);
3708
3709 I := p_x_Line_Adj_Assoc_tbl.FIRST;
3710
3711 WHILE I IS NOT NULL LOOP
3712 BEGIN
3713
3714 -- Load local records.
3715
3716 l_Line_Adj_Assoc_rec := p_x_Line_Adj_Assoc_tbl(I);
3717
3718 adj_debug('The operation is '||l_Line_Adj_Assoc_rec.operation,2);
3719 adj_debug('rltd_Adj '||l_Line_Adj_Assoc_rec.RLTD_PRICE_ADJ_ID,2);
3720 adj_debug('price adj '||l_Line_Adj_Assoc_rec.PRICE_ADJUSTMENT_ID,2);
3721 IF p_x_old_Line_Adj_Assoc_tbl.EXISTS(I) THEN
3722 l_old_Line_Adj_Assoc_rec := p_x_old_Line_Adj_Assoc_tbl(I);
3723 ELSE
3724 l_old_Line_Adj_Assoc_rec := OE_Order_PUB.G_MISS_Line_Adj_Assoc_REC;
3725 END IF;
3726
3727 if l_old_Line_Adj_Assoc_rec.Price_Adj_assoc_id = FND_API.G_MISS_NUM then
3728
3729 OE_MSG_PUB.set_msg_context(
3730 p_entity_code => 'ADJ_ATTS'
3731 ,p_entity_id => l_Line_Adj_Assoc_rec.Price_Adj_assoc_id);
3732
3733 else
3734
3735 OE_MSG_PUB.set_msg_context(
3736 p_entity_code => 'ADJ_ATTS'
3737 ,p_entity_id => l_old_Line_Adj_Assoc_rec.Price_Adj_assoc_id);
3738
3739 end if;
3740
3741 -- Load API control record
3742
3743 l_control_rec := OE_GLOBALS.Init_Control_Rec
3744 ( p_operation => l_Line_Adj_Assoc_rec.operation
3745 , p_control_rec => p_control_rec
3746 );
3747
3748 -- Set record return status.
3749
3750 l_Line_Adj_Assoc_rec.return_status := FND_API.G_RET_STS_SUCCESS;
3751
3752 -- Prepare record.
3753
3754
3755 IF l_Line_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
3756
3757 l_Line_Adj_Assoc_rec.db_flag := FND_API.G_FALSE;
3758
3759 -- Set missing old record elements to NULL.
3760
3761 adj_debug('Entering OE_Line_Adj_Assoc_Util.Convert_Miss_To_Null', 1);
3762 -- l_old_Line_Adj_Assoc_rec :=
3763 Oe_Line_Adj_Assocs_util.Convert_Miss_To_Null (l_old_Line_Adj_Assoc_rec);
3764
3765 ELSIF l_Line_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3766 OR l_Line_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_DELETE
3767 THEN
3768
3769 l_Line_Adj_Assoc_rec.db_flag := FND_API.G_TRUE;
3770
3771 -- Query Old if missing
3772
3773 IF l_old_Line_Adj_Assoc_rec.Price_Adj_assoc_id = FND_API.G_MISS_NUM
3774 THEN
3775
3776
3777 Oe_Line_Adj_Assocs_util.Query_Row
3778 ( p_Price_Adj_assoc_id => l_Line_Adj_Assoc_rec.Price_Adj_assoc_id
3779 , x_Line_Adj_Assoc_rec => l_old_Line_Adj_Assoc_rec
3780 );
3781
3782 ELSE
3783
3784 -- Set missing old record elements to NULL.
3785
3786 -- l_old_Line_Adj_Assoc_rec :=
3787 Oe_Line_Adj_Assocs_util.Convert_Miss_To_Null (l_old_Line_Adj_Assoc_rec);
3788
3789 END IF;
3790
3791 -- Complete new record from old
3792
3793 -- l_Line_Adj_Assoc_rec :=
3794 Oe_Line_Adj_Assocs_util.Complete_Record
3795 ( p_x_Line_Adj_Assoc_rec => l_Line_Adj_Assoc_rec
3796 , p_old_Line_Adj_Assoc_rec => l_old_Line_Adj_Assoc_rec
3797 );
3798
3799 OE_MSG_PUB.update_msg_context(
3800 p_entity_code => 'ADJ_ATTS'
3801 ,p_entity_id => l_Line_Adj_Assoc_rec.Price_Adj_assoc_id);
3802
3803 END IF;
3804
3805 -- Default missing attributes
3806 IF l_control_rec.default_attributes
3807 THEN
3808
3809 adj_debug('defaulting line adj attributes',2);
3810 OE_DEfault_Line_Adj_Assocs.Attributes
3811 ( p_x_Line_Adj_Assoc_rec => l_Line_Adj_Assoc_rec
3812 -- , x_Line_Adj_Assoc_rec => l_Line_Adj_Assoc_rec
3813 );
3814
3815 END IF;
3816
3817 -- Apply attribute changes
3818
3819 IF l_control_rec.change_attributes
3820 THEN
3821
3822 -- This will also log request/s to check duplicity of
3823 -- price adjustment entered
3824 Oe_Line_Adj_Assocs_util.Apply_Attribute_Changes
3825 ( p_x_Line_Adj_Assoc_rec => l_Line_Adj_Assoc_rec
3826 , p_old_Line_Adj_Assoc_rec => l_old_Line_Adj_Assoc_rec
3827 --, x_Line_Adj_Assoc_rec => l_Line_Adj_Assoc_rec
3828 );
3829
3830 END IF;
3831
3832 -- If there has any activity causing a change in any attribute
3833 -- log a request for repricing
3834
3835 -- Entity level validation.
3836
3837 -- Step 4. Write to DB
3838
3839 IF l_control_rec.write_to_db THEN
3840
3841 IF l_Line_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
3842
3843
3844 adj_debug('deleting line adj assocs',2);
3845 Oe_Line_Adj_Assocs_util.Delete_Row
3846 ( p_Price_Adj_assoc_id => l_Line_Adj_Assoc_rec.Price_Adj_assoc_id
3847 );
3848
3849 ELSE
3850
3851 -- Get Who Information
3852
3853 l_Line_Adj_Assoc_rec.last_update_date := SYSDATE;
3854 l_Line_Adj_Assoc_rec.last_updated_by := FND_GLOBAL.USER_ID;
3855 l_Line_Adj_Assoc_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
3856
3857 IF l_Line_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
3858 adj_debug('updating line adj assocs',2);
3859 Oe_Line_Adj_Assocs_util.Update_Row (l_Line_Adj_Assoc_rec);
3860
3861 ELSIF l_Line_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
3862 adj_debug('inserting into line adj assocs',2);
3863 l_Line_Adj_Assoc_rec.creation_date := SYSDATE;
3864 l_Line_Adj_Assoc_rec.created_by := FND_GLOBAL.USER_ID;
3865
3866 Oe_Line_Adj_Assocs_util.Insert_Row (l_Line_Adj_Assoc_rec);
3867
3868 END IF;
3869
3870 END IF;
3871
3872 END IF;
3873
3874 -- Load tables.
3875
3876 p_x_Line_Adj_Assoc_tbl(I) := l_Line_Adj_Assoc_rec;
3877 p_x_old_Line_Adj_Assoc_tbl(I) := l_old_Line_Adj_Assoc_rec;
3878
3879 IF l_Line_Adj_Assoc_rec.return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3880 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3881 ELSIF l_Line_Adj_Assoc_rec.return_status = FND_API.G_RET_STS_ERROR THEN
3882 RAISE FND_API.G_EXC_ERROR;
3883 END IF;
3884
3885 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
3886 -- loop exception handler.
3887
3888 EXCEPTION
3889
3890 WHEN FND_API.G_EXC_ERROR THEN
3891
3892 l_Line_Adj_Assoc_rec.return_status := FND_API.G_RET_STS_ERROR;
3893 p_x_Line_Adj_Assoc_tbl(I) := l_Line_Adj_Assoc_rec;
3894 p_x_old_Line_Adj_Assoc_tbl(I) := l_old_Line_Adj_Assoc_rec;
3895
3896 IF l_control_rec.Process_Partial THEN
3897 ROLLBACK TO SAVEPOINT Line_price_atts;
3898 ELSE
3899 RAISE FND_API.G_EXC_ERROR;
3900 END IF;
3901
3902
3903 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3904
3905 l_Line_Adj_Assoc_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3906 p_x_Line_Adj_Assoc_tbl(I) := l_Line_Adj_Assoc_rec;
3907 p_x_old_Line_Adj_Assoc_tbl(I) := l_old_Line_Adj_Assoc_rec;
3908
3909 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3910
3911 WHEN OTHERS THEN
3912
3913 l_Line_Adj_Assoc_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3914 p_x_Line_Adj_Assoc_tbl(I) := l_Line_Adj_Assoc_rec;
3915 p_x_old_Line_Adj_Assoc_tbl(I) := l_old_Line_Adj_Assoc_rec;
3916
3917 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3918 THEN
3919 OE_MSG_PUB.Add_Exc_Msg
3920 ( G_PKG_NAME
3921 , 'Header_price_atts'
3922 );
3923 END IF;
3924
3925 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
3926 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3927
3928 END;
3929 I := p_x_Line_Adj_Assoc_tbl.NEXT(I);
3930 END LOOP;
3931
3932 -- Load OUT parameters
3933
3934 adj_debug('Exiting oe_order_Adj_pvt.Line_Adj_Assocs', 1);
3935 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
3936
3937 EXCEPTION
3938
3939 WHEN FND_API.G_EXC_ERROR THEN
3940
3941 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
3942 RAISE;
3943
3944 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3945
3946 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
3947 RAISE;
3948
3949 WHEN OTHERS THEN
3950
3951 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3952 THEN
3953 OE_MSG_PUB.Add_Exc_Msg
3954 ( G_PKG_NAME
3955 , 'Line_Adj_Assocs'
3956 );
3957 END IF;
3958
3959
3960 OE_MSG_PUB.reset_msg_context('ADJ_ATTS');
3961 adj_debug('Exiting oe_order_Adj_pvt.Line_Adj_Assocs', 1);
3962 end Line_Adj_Assocs;
3963
3964 Function Enforce_list_Price
3965 return varchar2
3966 is
3967 l_enforce_price_flag varchar2(1);
3968 begin
3969 adj_debug('Entering oe_order_Adj_pvt.Enforce_Price_lists_Flag',1);
3970 begin
3971
3972 G_STMT_NO := 'Enforce_Price_lists_Flag#10';
3973 select nvl(enforce_line_prices_flag,'N') into l_enforce_price_flag
3974 from oe_line_types_v where line_type_id=OE_Order_PUB.G_Line.Line_Type_id;
3975 exception when no_data_found then
3976 l_enforce_price_flag := 'N';
3977 end ;
3978
3979 If l_enforce_price_flag='N' then
3980 begin
3981 G_STMT_NO := 'Enforce_Price_lists_Flag#20';
3982 select nvl(enforce_line_prices_flag,'N') into l_enforce_price_flag
3983 from oe_Order_types_v where Order_type_id=OE_Order_PUB.g_hdr.Order_Type_Id;
3984 exception when no_data_found then
3985 l_enforce_price_flag := 'N';
3986 end ;
3987 end if;
3988
3989 adj_debug('Exiting oe_order_Adj_pvt.Enforce_Price_lists_Flag',1);
3990
3991 Return l_enforce_price_flag;
3992
3993 end Enforce_list_Price;
3994
3995 Procedure Enforce_list_Price(
3996 p_line_id IN NUMBER,
3997 p_header_id IN NUMBER,
3998 p_line_type_id IN NUMBER,
3999 px_order_enforce_list_price IN OUT NOCOPY VARCHAR2,
4000 x_line_enforce_list_price OUT NOCOPY VARCHAR2)
4001
4002 is
4003 l_literal_order varchar2(5):='ORDER';
4004 begin
4005 adj_debug('Entering oe_order_Adj_pvt.Enforce_Price_lists_Flag',1);
4006 adj_debug('line id:'||p_line_id||' line type:'||p_line_Type_id);
4007 G_STMT_NO := 'Enforce_Price_lists_Flag#10';
4008 IF (px_order_enforce_list_price IS NULL) THEN
4009 begin
4010 select /* MOAC_SQL_CHANGE */ nvl(enforce_line_prices_flag,'N') into px_order_enforce_list_price
4011 from oe_transaction_types_all o,oe_order_headers h
4012 where h.header_id=p_header_id and h.order_type_id=o.transaction_type_id
4013 and o.transaction_type_code=l_literal_order;
4014 exception when no_data_found then
4015 px_order_enforce_list_price := 'N';
4016 end;
4017 IF (px_order_enforce_list_price IS NULL) THEN
4018 px_order_enforce_list_price := 'N';
4019 END IF;
4020 END IF;
4021 IF (px_order_enforce_list_price = 'Y') THEN
4022 x_line_enforce_list_price := 'Y';
4023 ELSE
4024 begin
4025 select nvl(enforce_line_prices_flag,'N') into x_line_enforce_list_price
4026 from oe_line_types_v where line_type_id=p_line_type_id;
4027 exception when no_data_found then
4028 x_line_enforce_list_price := 'N';
4029 end ;
4030 END IF;
4031 adj_debug('Exiting oe_order_Adj_pvt.Enforce_Price_lists_Flag',1);
4032
4033 end Enforce_list_Price;
4034
4035 Function Get_Rounding_factor(p_list_header_id number)
4036 return number
4037 is
4038 begin
4039 If g_rounding_factor_rec.list_header_id = p_list_header_id then
4040 Return g_rounding_factor_rec.rounding_factor;
4041 Else
4042 g_rounding_factor_rec.list_header_id := p_list_header_id;
4043 select rounding_factor into g_rounding_factor_rec.rounding_factor from
4044 qp_list_headers_b where list_header_id=p_list_header_id;
4045
4046 If g_rounding_factor_rec.rounding_factor = fnd_api.g_miss_num then
4047 g_rounding_factor_rec.rounding_factor:= Null;
4048 End If;
4049
4050 Return g_rounding_factor_rec.rounding_factor;
4051
4052 End if;
4053 Exception when no_data_found then
4054 Return Null;
4055 end Get_Rounding_factor;
4056
4057 procedure copy_Header_to_request(
4058 p_header_rec OE_Order_PUB.Header_Rec_Type
4059 ,px_req_line_tbl in out nocopy QP_PREQ_GRP.LINE_TBL_TYPE
4060 --,p_pricing_event varchar2
4061 ,p_Request_Type_Code varchar2
4062 ,p_calculate_price_flag varchar2
4063 )
4064 is
4065 l_line_index pls_integer := px_req_line_tbl.count;
4066 begin
4067 G_STMT_NO := 'copy_Header_to_request#10';
4068 adj_debug('Entering oe_order_Adj_pvt.copy_Header_to_request',1);
4069
4070 l_line_index := l_line_index+1;
4071 px_req_line_tbl(l_line_index).REQUEST_TYPE_CODE :=p_Request_Type_Code;
4072 --px_req_line_tbl(l_line_index).PRICING_EVENT :=p_pricing_event;
4073 --px_req_line_tbl(l_line_index).LIST_LINE_LEVEL_CODE :=p_Request_Type_Code;
4074 px_req_line_tbl(l_line_index).LINE_INDEX := l_line_index;
4075 px_req_line_tbl(l_line_index).LINE_TYPE_CODE := 'ORDER';
4076 -- Hold the header_id in line_id for 'HEADER' Records
4077 px_req_line_tbl(l_line_index).line_id := p_Header_rec.header_id;
4078 if p_header_rec.pricing_date is null or
4079 p_header_rec.pricing_date = fnd_api.g_miss_date then
4080 px_req_line_tbl(l_line_index).PRICING_EFFECTIVE_DATE := trunc(sysdate);
4081 Else
4082 px_req_line_tbl(l_line_index).PRICING_EFFECTIVE_DATE := p_header_rec.pricing_date;
4083 End If;
4084 px_req_line_tbl(l_line_index).CURRENCY_CODE := p_Header_rec.transactional_curr_code;
4085 px_req_line_tbl(l_line_index).PRICE_FLAG := p_calculate_price_flag;
4086 px_req_line_tbl(l_line_index).Active_date_first_type := 'ORD';
4087 px_req_line_tbl(l_line_index).Active_date_first := p_Header_rec.Ordered_date;
4088
4089 If p_Header_rec.transactional_curr_code is Not Null Then
4090 G_ORDER_CURRENCY := p_Header_rec.transactional_curr_code;
4091 Else
4092 G_ORDER_CURRENCY := OE_Order_PUB.g_hdr.transactional_curr_code;
4093 End If;
4094
4095 --Rounding factor now will be handled by pricing engine.
4096
4097 px_req_line_tbl(l_line_index).price_request_code := p_header_rec.price_request_code; -- PROMOTIONS SEP/01
4098 adj_debug('Existing oe_order_Adj_pvt.copy_Header_to_request',1);
4099
4100 end copy_Header_to_request;
4101
4102 procedure copy_Line_to_request(
4103 p_Line_rec OE_Order_PUB.Line_Rec_Type
4104 ,px_req_line_tbl in out nocopy QP_PREQ_GRP.LINE_TBL_TYPE
4105 ,p_pricing_event varchar2
4106 ,p_Request_Type_Code varchar2
4107 ,p_honor_price_flag VARCHAR2 Default 'Y'
4108 )
4109 is
4110 l_line_index pls_integer := nvl(px_req_line_tbl.count,0);
4111 l_uom_rate NUMBER;
4112 v_discounting_privilege VARCHAR2(30);
4113 l_item_type_code VARCHAR2(30);
4114
4115 l_item_rec OE_ORDER_CACHE.item_rec_type; --OPM 2046190
4116
4117 begin
4118 G_STMT_NO := 'copy_Line_to_request#10';
4119 adj_debug('Entering oe_order_Adj_pvt.copy_Line_to_request',1);
4120 l_line_index := l_line_index+1;
4121 px_req_line_tbl(l_line_index).Line_id := p_Line_rec.line_id;
4122 px_req_line_tbl(l_line_index).REQUEST_TYPE_CODE := p_Request_Type_Code;
4123 --px_req_line_tbl(l_line_index).PRICING_EVENT :=p_pricing_event;
4124 --px_req_line_tbl(l_line_index).LIST_LINE_LEVEL_CODE :=p_price_level_code;
4125 px_req_line_tbl(l_line_index).LINE_INDEX := l_line_index;
4126 px_req_line_tbl(l_line_index).LINE_TYPE_CODE := 'LINE';
4127 If p_Line_rec.pricing_date is null or
4128 p_Line_rec.pricing_date = fnd_api.g_miss_date then
4129 px_req_line_tbl(l_line_index).PRICING_EFFECTIVE_DATE := trunc(sysdate);
4130 Else
4131 px_req_line_tbl(l_line_index).PRICING_EFFECTIVE_DATE := p_Line_rec.pricing_date;
4132 End If;
4133
4134 px_req_line_tbl(l_line_index).LINE_QUANTITY := p_Line_rec.Ordered_quantity ;
4135
4136 /* -- No need to substract cancell quantity
4137 If p_Line_rec.cancelled_quantity = fnd_api.g_miss_num Then
4138 else
4139 px_req_line_tbl(l_line_index).LINE_QUANTITY := p_Line_rec.Ordered_quantity -
4140 nvl(p_Line_rec.cancelled_quantity,0);
4141 End If;
4142 */
4143 px_req_line_tbl(l_line_index).LINE_UOM_CODE := p_Line_rec.Order_quantity_uom;
4144 px_req_line_tbl(l_line_index).PRICED_QUANTITY := p_Line_rec.pricing_quantity; -- OPM 2547940 moved this up to here from below next block
4145
4146 -- start OPM 2046190
4147 -- IF oe_line_util.Process_Characteristics -- INVCONV
4148 IF oe_line_util.dual_uom_control -- INVCONV
4149 (p_line_rec.inventory_item_id
4150 ,p_line_rec.ship_from_org_id
4151 ,l_item_rec) THEN
4152
4153 IF l_item_rec.ont_pricing_qty_source = 'S' THEN -- price by quantity 2 -- invconv
4154 oe_debug_pub.add('OPM - ont_pricing_qty_source = S in OEXVADJB.pls ');
4155 px_req_line_tbl(l_line_index).LINE_QUANTITY := p_Line_rec.Ordered_quantity2 ;
4156 px_req_line_tbl(l_line_index).LINE_UOM_CODE := p_Line_rec.Ordered_quantity_uom2 ;
4157 -- OPM 2547940 start
4158 IF p_line_rec.CALCULATE_PRICE_FLAG in ( 'N', 'P' ) THEN -- usually split from shipping
4159 -- below line - need a UOM conversion below if pricing UOM off price list not same as secondary UOM
4160 -- need check whether split from shipping or not
4161 IF (p_Line_rec.pricing_quantity_uom = p_Line_rec.Ordered_quantity_uom2) Then
4162 px_req_line_tbl(l_line_index).PRICED_QUANTITY := nvl(p_Line_rec.shipped_quantity2,p_Line_rec.Ordered_quantity2);
4163 Else
4164 adj_debug('OPM in split scenario about to convert ') ;
4165 INV_CONVERT.INV_UM_CONVERSION(From_Unit => p_Line_rec.Ordered_quantity_uom2
4166 ,To_Unit => p_Line_rec.pricing_quantity_uom
4167 ,Item_ID => p_Line_rec.Inventory_item_id
4168 ,Uom_Rate => l_Uom_rate);
4169 px_req_line_tbl(l_line_index).PRICED_QUANTITY := nvl(p_Line_rec.shipped_quantity2,p_Line_rec.Ordered_quantity2) * l_uom_rate;
4170 adj_debug('OPM priced quantity after convert is : ' ||px_req_line_tbl(l_line_index).PRICED_QUANTITY) ;
4171 END IF;
4172
4173 END IF; -- OPM 2547940 end
4174
4175
4176 else
4177 px_req_line_tbl(l_line_index).LINE_QUANTITY := p_Line_rec.Ordered_quantity ;
4178 px_req_line_tbl(l_line_index).LINE_UOM_CODE := p_Line_rec.Order_quantity_uom ;
4179 END IF;
4180
4181 adj_debug('OPM pricing quantity is : ' ||px_req_line_tbl(l_line_index).LINE_QUANTITY) ;
4182 adj_debug('OPM pricing quantity uom is : ' ||px_req_line_tbl(l_line_index).LINE_UOM_CODE) ;
4183
4184 END IF;
4185
4186 -- end OPM 2046190
4187
4188
4189
4190 px_req_line_tbl(l_line_index).PRICED_UOM_CODE := p_Line_rec.pricing_quantity_uom;
4191
4192 px_req_line_tbl(l_line_index).CURRENCY_CODE :=
4193 OE_Order_PUB.g_hdr.transactional_curr_code;
4194 -- uom begin
4195 If p_Line_rec.unit_list_price_per_pqty <> FND_API.G_MISS_NUM Then
4196 px_req_line_tbl(l_line_index).UNIT_PRICE := p_Line_rec.unit_list_price_per_pqty;
4197
4198 -- Fix for bug 1834409
4199 -- Patch 1766558 introduced two new columns in oe_order_lines_all
4200 -- namely, unit_list_price_per_pqty and unit_selling_price_per_pqty
4201 -- So, when adding new order lines to upgraded sales orders,
4202 -- pass the values of unit_list_price and unit_selling_price
4203 -- to pricing engine for the old order lines
4204
4205 Elsif p_line_rec.unit_list_price <> FND_API.G_MISS_NUM Then
4206 px_req_line_tbl(l_line_index).UNIT_PRICE := p_line_rec.unit_list_price;
4207 else
4208 px_req_line_tbl(l_line_index).UNIT_PRICE := Null;
4209 End If;
4210 -- uom end
4211
4212 px_req_line_tbl(l_line_index).PERCENT_PRICE := p_Line_rec.unit_list_percent;
4213
4214 If (p_Line_rec.service_period = p_Line_rec.Order_quantity_uom) Then
4215 px_req_line_tbl(l_line_index).UOM_QUANTITY := p_Line_rec.service_duration;
4216 Else
4217 INV_CONVERT.INV_UM_CONVERSION(From_Unit => p_Line_rec.service_period
4218 ,To_Unit => p_Line_rec.Order_quantity_uom
4219 ,Item_ID => p_Line_rec.Inventory_item_id
4220 ,Uom_Rate => l_Uom_rate);
4221 px_req_line_tbl(l_line_index).UOM_QUANTITY := p_Line_rec.service_duration * l_uom_rate;
4222 End If;
4223
4224 --Rounding factor is now handled by pricing engine
4225
4226 -- modified by lkxu
4227 IF p_honor_price_flag = 'N' THEN
4228 IF p_line_rec.CALCULATE_PRICE_FLAG = 'X' THEN
4229 -- this is service parent line, for information only, so don't price it.
4230 px_req_line_tbl(l_line_index).PRICE_FLAG := 'N';
4231 ELSE
4232 px_req_line_tbl(l_line_index).PRICE_FLAG := 'Y';
4233 END IF;
4234
4235 ELSE
4236 If p_Line_rec.calculate_Price_flag = fnd_api.g_miss_char then
4237 px_req_line_tbl(l_line_index).PRICE_FLAG := 'Y';
4238 --included for bug 2046841 Begin
4239 elsif p_line_rec.calculate_price_flag = 'X' then
4240 px_req_line_tbl(l_line_index).PRICE_FLAG := 'N';
4241 --included for bug 2046841 End
4242 else
4243 px_req_line_tbl(l_line_index).PRICE_FLAG := nvl(p_Line_rec.calculate_Price_flag,'Y');
4244 end if;
4245 END IF;
4246
4247 -- end of modification made by lkxu
4248
4249 -- Added by JAUTOMO on 20-DEC-00
4250
4251 -- Get Discounting Privilege Profile Option value
4252 fnd_profile.get('ONT_DISCOUNTING_PRIVILEGE', v_discounting_privilege);
4253
4254 -- If the profile is set to UNLIMITED, then even if the Order Type
4255 -- restrict price changes, the user can change the price
4256
4257 -- If Enforce list price then execute only the PRICE Event
4258 If p_pricing_event <> 'PRICE' and
4259 Enforce_list_price = 'Y' and
4260 px_req_line_tbl(l_line_index).PRICE_FLAG = 'Y' and
4261 v_discounting_privilege <> 'UNLIMITED' then
4262
4263 px_req_line_tbl(l_line_index).PRICE_FLAG := 'P';
4264
4265 End If;
4266
4267 -- Execute the pricing phase if the list price is null
4268
4269 If p_pricing_event = 'PRICE' and
4270 px_req_line_tbl(l_line_index).UNIT_PRICE is null then
4271
4272 px_req_line_tbl(l_line_index).PRICE_FLAG := 'Y' ;
4273
4274 End If;
4275 -- Do not execute SHIP event for a line if the line is not ship interfaced.
4276 If px_req_line_tbl(l_line_index).PRICE_FLAG = 'Y' and
4277 (p_Line_rec.Shipped_quantity is null or
4278 p_Line_rec.Shipped_quantity = fnd_api.g_miss_num or
4279 p_Line_rec.Shipped_quantity = 0 ) and
4280 --cc1
4281 p_pricing_event ='SHIP' Then
4282 px_req_line_tbl(l_line_index).PRICE_FLAG := 'N';
4283 End If;
4284
4285 l_item_type_code := oe_line_util.Get_Return_Item_Type_Code(p_Line_rec);
4286
4287 -- Do not fetch the price for Configuration items and Included Items
4288 If l_item_type_code in( 'CONFIG','INCLUDED')
4289 Then
4290
4291 IF p_line_rec.calculate_price_flag in ( 'Y', 'P' )
4292 Then
4293 If ( G_CHARGES_FOR_INCLUDED_ITEM = 'N' and
4294 l_item_type_code = 'INCLUDED')
4295 Then
4296 px_req_line_tbl(l_line_index).PRICE_FLAG := 'N';
4297 Else
4298 px_req_line_tbl(l_line_index).PRICE_FLAG := 'P';
4299 End If;
4300 Else
4301 px_req_line_tbl(l_line_index).PRICE_FLAG := 'N';
4302
4303 End IF;
4304
4305 End If;
4306
4307 px_req_line_tbl(l_line_index).Active_date_first_type := 'ORD';
4308 px_req_line_tbl(l_line_index).Active_date_first := OE_Order_Pub.G_HDR.Ordered_date;
4309
4310 If p_Line_rec.schedule_ship_date is not null then
4311 px_req_line_tbl(l_line_index).Active_date_Second_type := 'SHIP';
4312 px_req_line_tbl(l_line_index).Active_date_Second := p_Line_rec.schedule_ship_date;
4313 End If;
4314 px_req_line_tbl(l_line_index).price_request_code := p_line_rec.price_request_code; -- PROMOTIONS SEP/01
4315 px_req_line_tbl(l_line_index).line_category
4316 := p_line_rec.line_category_code;
4317
4318 adj_debug('Existing oe_order_Adj_pvt.copy_Line_to_request',1);
4319
4320 end copy_Line_to_request;
4321
4322 procedure copy_adjs_to_request(
4323 p_line_index pls_integer
4324 ,p_adj_index pls_integer
4325 ,p_Line_adj_rec OE_Order_PUB.Line_Adj_Rec_Type
4326 ,px_Req_LINE_DETAIL_tbl in out nocopy QP_PREQ_GRP.LINE_DETAIL_tbl_Type
4327 )
4328 is
4329 l_RLD_Index pls_integer := p_adj_index;
4330 begin
4331
4332 adj_debug('Entering oe_order_Adj_pvt.copy_adjs_to_request',1);
4333
4334 G_STMT_NO := 'copy_adjs_to_request#10';
4335
4336 --l_RLD_Index := l_RLD_Index +1 ;
4337
4338 -- We want to retain the same index as that of Adj
4339 px_Req_LINE_DETAIL_tbl(l_RLD_Index).Line_Detail_Index := l_RLD_Index;
4340 px_Req_LINE_DETAIL_tbl(l_RLD_Index).Line_Detail_Type_Code := 'NULL';
4341
4342 px_Req_LINE_DETAIL_tbl(l_RLD_Index).Line_Index := p_line_index;
4343
4344 px_Req_LINE_DETAIL_tbl(l_RLD_Index).List_header_id := p_Line_Adj_rec.List_Header_Id;
4345 px_Req_LINE_DETAIL_tbl(l_RLD_Index).List_Line_Id := p_Line_Adj_rec.List_Line_id;
4346 px_Req_LINE_DETAIL_tbl(l_RLD_Index).List_Line_type_Code := p_Line_Adj_rec.List_Line_type_Code;
4347 Begin
4348 Select list_type_code into
4349 px_Req_LINE_DETAIL_tbl(l_RLD_Index).created_from_list_type_code
4350 from qp_list_headers_b where
4351 list_header_id= p_Line_Adj_rec.List_Header_Id;
4352 Exception when no_data_found then
4353 adj_debug('Invalid list header '|| p_Line_Adj_rec.List_Header_Id,1);
4354 End;
4355
4356 px_Req_LINE_DETAIL_tbl(l_RLD_Index).substitution_from := p_Line_Adj_rec.modified_from;
4357 px_Req_LINE_DETAIL_tbl(l_RLD_Index).substitution_to := p_Line_Adj_rec.modified_to;
4358 px_Req_LINE_DETAIL_tbl(l_RLD_Index).automatic_flag := p_Line_Adj_rec.automatic_flag;
4359 px_Req_LINE_DETAIL_tbl(l_RLD_Index).override_flag := p_Line_Adj_rec.update_allowed;
4360 px_Req_LINE_DETAIL_tbl(l_RLD_Index).Operand_Calculation_Code :=
4361 p_Line_Adj_rec.Arithmetic_Operator;
4362 px_Req_LINE_DETAIL_tbl(l_RLD_Index).Operand_Value := p_Line_Adj_rec.Operand_Per_Pqty;
4363 px_Req_LINE_DETAIL_tbl(l_RLD_Index).pricing_group_sequence := p_Line_Adj_rec.pricing_group_sequence;
4364 px_Req_LINE_DETAIL_tbl(l_RLD_Index).price_break_type_code := p_Line_Adj_rec.price_break_type_code;
4365 px_Req_LINE_DETAIL_tbl(l_RLD_Index).pricing_phase_id := p_Line_Adj_rec.pricing_phase_id;
4366 px_Req_LINE_DETAIL_tbl(l_RLD_Index).line_quantity := p_Line_Adj_rec.range_break_quantity;
4367 px_Req_LINE_DETAIL_tbl(l_RLD_Index).adjustment_amount := p_Line_Adj_rec.adjusted_amount_per_pqty;
4368 px_Req_LINE_DETAIL_tbl(l_RLD_Index).applied_flag := p_Line_Adj_rec.applied_flag;
4369
4370 end copy_adjs_to_request;
4371
4372 procedure copy_attribs_to_Req(
4373 p_line_index number
4374 ,p_pricing_contexts_Tbl QP_Attr_Mapping_PUB.Contexts_Result_Tbl_Type
4375 ,p_qualifier_contexts_Tbl QP_Attr_Mapping_PUB.Contexts_Result_Tbl_Type
4376 ,px_Req_line_attr_tbl in out nocopy QP_PREQ_GRP.LINE_ATTR_TBL_TYPE
4377 ,px_Req_qual_tbl in out nocopy QP_PREQ_GRP.QUAL_TBL_TYPE
4378 )
4379 is
4380 i pls_integer := 0;
4381 l_attr_index pls_integer := nvl(px_Req_line_attr_tbl.last,0);
4382 l_qual_index pls_integer := nvl(px_Req_qual_tbl.last,0);
4383 begin
4384 adj_debug('Entering oe_order_Adj_pvt.copy_attribs_to_Req',1);
4385 i := p_pricing_contexts_Tbl.First;
4386 While i is not null loop
4387 l_attr_index := l_attr_index +1;
4388 px_Req_line_attr_tbl(l_attr_index).VALIDATED_FLAG := 'N';
4389 px_Req_line_attr_tbl(l_attr_index).line_index := p_line_index;
4390
4391 -- Product and Pricing Contexts go into pricing contexts...
4392 px_Req_line_attr_tbl(l_attr_index).PRICING_CONTEXT :=
4393 p_pricing_contexts_Tbl(i).context_name;
4394 px_Req_line_attr_tbl(l_attr_index).PRICING_ATTRIBUTE :=
4395 p_pricing_contexts_Tbl(i).Attribute_Name;
4396 px_Req_line_attr_tbl(l_attr_index).PRICING_ATTR_VALUE_FROM :=
4397 p_pricing_contexts_Tbl(i).attribute_value;
4398
4399 i := p_pricing_contexts_Tbl.Next(i);
4400 end loop;
4401 -- Copy the qualifiers
4402 G_STMT_NO := 'copy_attribs_to_Req#20';
4403 i := p_qualifier_contexts_Tbl.First;
4404 While i is not null loop
4405 l_qual_index := l_qual_index +1;
4406
4407 If p_qualifier_contexts_Tbl(i).context_name ='MODLIST' and
4408 p_qualifier_contexts_Tbl(i).Attribute_Name ='QUALIFIER_ATTRIBUTE4' then
4409
4410 If OE_Order_PUB.G_Line.agreement_id is not null and
4411 OE_Order_PUB.G_Line.agreement_id <> fnd_api.g_miss_num then
4412 px_Req_Qual_Tbl(l_qual_index).Validated_Flag := 'Y';
4413 -- BLANKETS: Start Code Merge
4414 Elsif OE_Code_Control.Code_Release_Level >= '110509' and
4415 OE_Order_PUB.G_Line.blanket_number is not null and
4416 OE_Order_PUB.G_Line.blanket_number <> fnd_api.g_miss_num and
4417 OE_Order_PUB.G_Line.blanket_line_number is not null and
4418 OE_Order_PUB.G_Line.blanket_line_number <> fnd_api.g_miss_num
4419 Then
4420
4421 -- Set validated_flag to 'Y' if price list is AGR
4422 -- type or enforce price list is checked on blanket.
4423 If Get_List_Type
4424 (OE_Order_PUB.G_Line.price_list_id) = 'AGR'
4425 OR Get_Enforce_Price_List
4426 (OE_Order_PUB.G_Line.blanket_number
4427 ,OE_Order_PUB.G_Line.blanket_line_number)='Y'
4428 Then
4429
4430 px_Req_Qual_Tbl(l_qual_index).Validated_Flag := 'Y';
4431
4432 Else
4433
4434 px_Req_Qual_Tbl(l_qual_index).Validated_Flag := 'N';
4435
4436 End If;
4437
4438 -- BLANKETS: End Code Merge
4439
4440 Else
4441 px_Req_Qual_Tbl(l_qual_index).Validated_Flag := 'N';
4442 End If;
4443
4444 Else
4445 px_Req_Qual_Tbl(l_qual_index).Validated_Flag := 'N';
4446 End If;
4447
4448 px_Req_qual_tbl(l_qual_index).line_index := p_line_index;
4449
4450 px_Req_qual_tbl(l_qual_index).QUALIFIER_CONTEXT :=
4451 p_qualifier_contexts_Tbl(i).context_name;
4452 px_Req_qual_tbl(l_qual_index).QUALIFIER_ATTRIBUTE :=
4453 p_qualifier_contexts_Tbl(i).Attribute_Name;
4454 px_Req_qual_tbl(l_qual_index).QUALIFIER_ATTR_VALUE_FROM :=
4455 p_qualifier_contexts_Tbl(i).attribute_value;
4456
4457 i := p_qualifier_contexts_Tbl.Next(i);
4458 end loop;
4459
4460 adj_debug('Exiting oe_order_Adj_pvt.copy_attribs_to_Req',1);
4461
4462 end copy_attribs_to_Req;
4463
4464 procedure Append_asked_for(
4465 p_header_id number default null
4466 ,p_Line_id number default null
4467 ,p_line_index number
4468 ,px_Req_line_attr_tbl in out nocopy QP_PREQ_GRP.LINE_ATTR_TBL_TYPE
4469 ,px_Req_qual_tbl in out nocopy QP_PREQ_GRP.QUAL_TBL_TYPE
4470 )
4471 is
4472 i pls_integer;
4473 -- Using union all to eliminate sort unique
4474 cursor asked_for_cur is
4475 select flex_title, pricing_context, pricing_attribute1,
4476 pricing_attribute2 , pricing_attribute3 , pricing_attribute4 , pricing_attribute5 ,
4477 pricing_attribute6 , pricing_attribute7 , pricing_attribute8 , pricing_attribute9 ,
4478 pricing_attribute10 , pricing_attribute11 , pricing_attribute12 , pricing_attribute13 ,
4479 pricing_attribute14 , pricing_attribute15 , pricing_attribute16 , pricing_attribute17 ,
4480 pricing_attribute18 , pricing_attribute19 , pricing_attribute20 , pricing_attribute21 ,
4481 pricing_attribute22 , pricing_attribute23 , pricing_attribute24 , pricing_attribute25 ,
4482 pricing_attribute26 , pricing_attribute27 , pricing_attribute28 , pricing_attribute29 ,
4483 pricing_attribute30 , pricing_attribute31 , pricing_attribute32 , pricing_attribute33 ,
4484 pricing_attribute34 , pricing_attribute35 , pricing_attribute36 , pricing_attribute37 ,
4485 pricing_attribute38 , pricing_attribute39 , pricing_attribute40 , pricing_attribute41 ,
4486 pricing_attribute42 , pricing_attribute43 , pricing_attribute44 , pricing_attribute45 ,
4487 pricing_attribute46 , pricing_attribute47 , pricing_attribute48 , pricing_attribute49 ,
4488 pricing_attribute50 , pricing_attribute51 , pricing_attribute52 , pricing_attribute53 ,
4489 pricing_attribute54 , pricing_attribute55 , pricing_attribute56 , pricing_attribute57 ,
4490 pricing_attribute58 , pricing_attribute59 , pricing_attribute60 , pricing_attribute61 ,
4491 pricing_attribute62 , pricing_attribute63 , pricing_attribute64 , pricing_attribute65 ,
4492 pricing_attribute66 , pricing_attribute67 , pricing_attribute68 , pricing_attribute69 ,
4493 pricing_attribute70 , pricing_attribute71 , pricing_attribute72 , pricing_attribute73 ,
4494 pricing_attribute74 , pricing_attribute75 , pricing_attribute76 , pricing_attribute77 ,
4495 pricing_attribute78 , pricing_attribute79 , pricing_attribute80 , pricing_attribute81 ,
4496 pricing_attribute82 , pricing_attribute83 , pricing_attribute84 , pricing_attribute85 ,
4497 pricing_attribute86 , pricing_attribute87 , pricing_attribute88 , pricing_attribute89 ,
4498 pricing_attribute90 , pricing_attribute91 , pricing_attribute92 , pricing_attribute93 ,
4499 pricing_attribute94 , pricing_attribute95 , pricing_attribute96 , pricing_attribute97 ,
4500 pricing_attribute98 , pricing_attribute99 , pricing_attribute100
4501 ,Override_Flag
4502 from oe_order_price_attribs a
4503 where (a.line_id is null and a.header_id = p_header_id )
4504 union all
4505 select flex_title, pricing_context, pricing_attribute1,
4506 pricing_attribute2 , pricing_attribute3 , pricing_attribute4 , pricing_attribute5 ,
4507 pricing_attribute6 , pricing_attribute7 , pricing_attribute8 , pricing_attribute9 ,
4508 pricing_attribute10 , pricing_attribute11 , pricing_attribute12 , pricing_attribute13 ,
4509 pricing_attribute14 , pricing_attribute15 , pricing_attribute16 , pricing_attribute17 ,
4510 pricing_attribute18 , pricing_attribute19 , pricing_attribute20 , pricing_attribute21 ,
4511 pricing_attribute22 , pricing_attribute23 , pricing_attribute24 , pricing_attribute25 ,
4512 pricing_attribute26 , pricing_attribute27 , pricing_attribute28 , pricing_attribute29 ,
4513 pricing_attribute30 , pricing_attribute31 , pricing_attribute32 , pricing_attribute33 ,
4514 pricing_attribute34 , pricing_attribute35 , pricing_attribute36 , pricing_attribute37 ,
4515 pricing_attribute38 , pricing_attribute39 , pricing_attribute40 , pricing_attribute41 ,
4516 pricing_attribute42 , pricing_attribute43 , pricing_attribute44 , pricing_attribute45 ,
4517 pricing_attribute46 , pricing_attribute47 , pricing_attribute48 , pricing_attribute49 ,
4518 pricing_attribute50 , pricing_attribute51 , pricing_attribute52 , pricing_attribute53 ,
4519 pricing_attribute54 , pricing_attribute55 , pricing_attribute56 , pricing_attribute57 ,
4520 pricing_attribute58 , pricing_attribute59 , pricing_attribute60 , pricing_attribute61 ,
4521 pricing_attribute62 , pricing_attribute63 , pricing_attribute64 , pricing_attribute65 ,
4522 pricing_attribute66 , pricing_attribute67 , pricing_attribute68 , pricing_attribute69 ,
4523 pricing_attribute70 , pricing_attribute71 , pricing_attribute72 , pricing_attribute73 ,
4524 pricing_attribute74 , pricing_attribute75 , pricing_attribute76 , pricing_attribute77 ,
4525 pricing_attribute78 , pricing_attribute79 , pricing_attribute80 , pricing_attribute81 ,
4526 pricing_attribute82 , pricing_attribute83 , pricing_attribute84 , pricing_attribute85 ,
4527 pricing_attribute86 , pricing_attribute87 , pricing_attribute88 , pricing_attribute89 ,
4528 pricing_attribute90 , pricing_attribute91 , pricing_attribute92 , pricing_attribute93 ,
4529 pricing_attribute94 , pricing_attribute95 , pricing_attribute96 , pricing_attribute97 ,
4530 pricing_attribute98 , pricing_attribute99 , pricing_attribute100
4531 ,Override_Flag
4532 from oe_order_price_attribs a
4533 where (p_line_id is not null and a.line_id = p_line_id )
4534 ;
4535 begin
4536 G_STMT_NO := 'Append_asked_for#10';
4537 adj_debug('Entering oe_order_Adj_pvt.Append_asked_for',1);
4538 for asked_for_rec in asked_for_cur loop
4539 If asked_for_rec.flex_title = 'QP_ATTR_DEFNS_PRICING' then
4540 if asked_for_rec.PRICING_ATTRIBUTE1 is not null then
4541 i := px_Req_line_attr_tbl.count+1;
4542 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4543 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4544 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4545 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE1';
4546 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE1;
4547 end if;
4548 if asked_for_rec.PRICING_ATTRIBUTE2 is not null then
4549 i := px_Req_line_attr_tbl.count+1;
4550 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4551 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4552 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4553 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE2';
4554 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE2;
4555 end if;
4556 if asked_for_rec.PRICING_ATTRIBUTE3 is not null then
4557 i := px_Req_line_attr_tbl.count+1;
4558 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4559 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4560 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4561 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE3';
4562 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE3;
4563 end if;
4564 if asked_for_rec.PRICING_ATTRIBUTE4 is not null then
4565 i := px_Req_line_attr_tbl.count+1;
4566 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4567 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4568 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4569 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE4';
4570 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE4;
4571 end if;
4572 if asked_for_rec.PRICING_ATTRIBUTE5 is not null then
4573 i := px_Req_line_attr_tbl.count+1;
4574 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4575 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4576 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4577 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE5';
4578 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE5;
4579 end if;
4580 if asked_for_rec.PRICING_ATTRIBUTE6 is not null then
4581 i := px_Req_line_attr_tbl.count+1;
4582 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4583 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4584 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4585 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE6';
4586 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE6;
4587 end if;
4588 if asked_for_rec.PRICING_ATTRIBUTE7 is not null then
4589 i := px_Req_line_attr_tbl.count+1;
4590 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4591 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4592 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4593 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE7';
4594 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE7;
4595 end if;
4596 if asked_for_rec.PRICING_ATTRIBUTE8 is not null then
4597 i := px_Req_line_attr_tbl.count+1;
4598 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4599 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4600 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4601 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE8';
4602 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE8;
4603 end if;
4604 if asked_for_rec.PRICING_ATTRIBUTE9 is not null then
4605 i := px_Req_line_attr_tbl.count+1;
4606 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4607 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4608 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4609 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE9';
4610 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE9;
4611 end if;
4612
4613 if asked_for_rec.PRICING_ATTRIBUTE10 is not null then
4614 i := px_Req_line_attr_tbl.count+1;
4615 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4616 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4617 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4618 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE10';
4619 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE10;
4620 end if;
4621 if asked_for_rec.PRICING_ATTRIBUTE11 is not null then
4622 i := px_Req_line_attr_tbl.count+1;
4623 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4624 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4625 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4626 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE11';
4627 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE11;
4628 end if;
4629 if asked_for_rec.PRICING_ATTRIBUTE12 is not null then
4630 i := px_Req_line_attr_tbl.count+1;
4631 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4632 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4633 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4634 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE12';
4635 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE12;
4636 end if;
4637 if asked_for_rec.PRICING_ATTRIBUTE13 is not null then
4638 i := px_Req_line_attr_tbl.count+1;
4639 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4640 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4641 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4642 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE13';
4643 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE13;
4644 end if;
4645 if asked_for_rec.PRICING_ATTRIBUTE14 is not null then
4646 i := px_Req_line_attr_tbl.count+1;
4647 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4648 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4649 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4650 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE14';
4651 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE14;
4652 end if;
4653 if asked_for_rec.PRICING_ATTRIBUTE15 is not null then
4654 i := px_Req_line_attr_tbl.count+1;
4655 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4656 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4657 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4658 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE15';
4659 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE15;
4660 end if;
4661 if asked_for_rec.PRICING_ATTRIBUTE16 is not null then
4662 i := px_Req_line_attr_tbl.count+1;
4663 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4664 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4665 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4666 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE16';
4667 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE16;
4668 end if;
4669 if asked_for_rec.PRICING_ATTRIBUTE17 is not null then
4670 i := px_Req_line_attr_tbl.count+1;
4671 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4672 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4673 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4674 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE17';
4675 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE17;
4676 end if;
4677 if asked_for_rec.PRICING_ATTRIBUTE18 is not null then
4678 i := px_Req_line_attr_tbl.count+1;
4679 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4680 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4681 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4682 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE18';
4683 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE18;
4684 end if;
4685 if asked_for_rec.PRICING_ATTRIBUTE19 is not null then
4686 i := px_Req_line_attr_tbl.count+1;
4687 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4688 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4689 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4690 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE19';
4691 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE19;
4692 end if;
4693
4694 if asked_for_rec.PRICING_ATTRIBUTE20 is not null then
4695 i := px_Req_line_attr_tbl.count+1;
4696 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4697 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4698 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4699 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE20';
4700 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE20;
4701 end if;
4702 if asked_for_rec.PRICING_ATTRIBUTE21 is not null then
4703 i := px_Req_line_attr_tbl.count+1;
4704 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4705 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4706 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4707 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE21';
4708 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE21;
4709 end if;
4710 if asked_for_rec.PRICING_ATTRIBUTE22 is not null then
4711 i := px_Req_line_attr_tbl.count+1;
4712 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4713 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4714 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4715 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE22';
4716 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE22;
4717 end if;
4718 if asked_for_rec.PRICING_ATTRIBUTE23 is not null then
4719 i := px_Req_line_attr_tbl.count+1;
4720 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4721 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4722 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4723 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE23';
4724 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE23;
4725 end if;
4726 if asked_for_rec.PRICING_ATTRIBUTE24 is not null then
4727 i := px_Req_line_attr_tbl.count+1;
4728 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4729 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4730 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4731 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE24';
4732 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE24;
4733 end if;
4734 if asked_for_rec.PRICING_ATTRIBUTE25 is not null then
4735 i := px_Req_line_attr_tbl.count+1;
4736 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4737 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4738 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4739 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE25';
4740 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE25;
4741 end if;
4742 if asked_for_rec.PRICING_ATTRIBUTE26 is not null then
4743 i := px_Req_line_attr_tbl.count+1;
4744 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4745 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4746 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4747 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE26';
4748 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE26;
4749 end if;
4750 if asked_for_rec.PRICING_ATTRIBUTE27 is not null then
4751 i := px_Req_line_attr_tbl.count+1;
4752 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4753 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4754 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4755 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE27';
4756 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE27;
4757 end if;
4758 if asked_for_rec.PRICING_ATTRIBUTE28 is not null then
4759 i := px_Req_line_attr_tbl.count+1;
4760 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4761 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4762 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4763 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE28';
4764 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE28;
4765 end if;
4766 if asked_for_rec.PRICING_ATTRIBUTE29 is not null then
4767 i := px_Req_line_attr_tbl.count+1;
4768 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4769 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4770 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4771 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE29';
4772 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE29;
4773 end if;
4774
4775 if asked_for_rec.PRICING_ATTRIBUTE30 is not null then
4776 i := px_Req_line_attr_tbl.count+1;
4777 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4778 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4779 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4780 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE30';
4781 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE30;
4782 end if;
4783 if asked_for_rec.PRICING_ATTRIBUTE31 is not null then
4784 i := px_Req_line_attr_tbl.count+1;
4785 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4786 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4787 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4788 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE31';
4789 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE31;
4790 end if;
4791 if asked_for_rec.PRICING_ATTRIBUTE32 is not null then
4792 i := px_Req_line_attr_tbl.count+1;
4793 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4794 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4795 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4796 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE32';
4797 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE32;
4798 end if;
4799 if asked_for_rec.PRICING_ATTRIBUTE33 is not null then
4800 i := px_Req_line_attr_tbl.count+1;
4801 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4802 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4803 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4804 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE33';
4805 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE33;
4806 end if;
4807 if asked_for_rec.PRICING_ATTRIBUTE34 is not null then
4808 i := px_Req_line_attr_tbl.count+1;
4809 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4810 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4811 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4812 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE34';
4813 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE34;
4814 end if;
4815 if asked_for_rec.PRICING_ATTRIBUTE35 is not null then
4816 i := px_Req_line_attr_tbl.count+1;
4817 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4818 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4819 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4820 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE35';
4821 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE35;
4822 end if;
4823 if asked_for_rec.PRICING_ATTRIBUTE36 is not null then
4824 i := px_Req_line_attr_tbl.count+1;
4825 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4826 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4827 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4828 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE36';
4829 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE36;
4830 end if;
4831 if asked_for_rec.PRICING_ATTRIBUTE37 is not null then
4832 i := px_Req_line_attr_tbl.count+1;
4833 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4834 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4835 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4836 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE37';
4837 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE37;
4838 end if;
4839 if asked_for_rec.PRICING_ATTRIBUTE38 is not null then
4840 i := px_Req_line_attr_tbl.count+1;
4841 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4842 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4843 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4844 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE38';
4845 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE38;
4846 end if;
4847 if asked_for_rec.PRICING_ATTRIBUTE39 is not null then
4848 i := px_Req_line_attr_tbl.count+1;
4849 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4850 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4851 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4852 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE39';
4853 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE39;
4854 end if;
4855
4856 if asked_for_rec.PRICING_ATTRIBUTE40 is not null then
4857 i := px_Req_line_attr_tbl.count+1;
4858 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4859 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4860 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4861 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE40';
4862 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE40;
4863 end if;
4864 if asked_for_rec.PRICING_ATTRIBUTE41 is not null then
4865 i := px_Req_line_attr_tbl.count+1;
4866 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4867 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4868 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4869 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE41';
4870 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE41;
4871 end if;
4872 if asked_for_rec.PRICING_ATTRIBUTE42 is not null then
4873 i := px_Req_line_attr_tbl.count+1;
4874 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4875 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4876 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4877 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE42';
4878 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE42;
4879 end if;
4880 if asked_for_rec.PRICING_ATTRIBUTE43 is not null then
4881 i := px_Req_line_attr_tbl.count+1;
4882 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4883 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4884 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4885 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE43';
4886 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE43;
4887 end if;
4888 if asked_for_rec.PRICING_ATTRIBUTE44 is not null then
4889 i := px_Req_line_attr_tbl.count+1;
4890 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4891 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4892 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4893 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE44';
4894 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE44;
4895 end if;
4896 if asked_for_rec.PRICING_ATTRIBUTE45 is not null then
4897 i := px_Req_line_attr_tbl.count+1;
4898 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4899 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4900 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4901 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE45';
4902 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE45;
4903 end if;
4904 if asked_for_rec.PRICING_ATTRIBUTE46 is not null then
4905 i := px_Req_line_attr_tbl.count+1;
4906 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4907 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4908 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4909 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE46';
4910 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE46;
4911 end if;
4912 if asked_for_rec.PRICING_ATTRIBUTE47 is not null then
4913 i := px_Req_line_attr_tbl.count+1;
4914 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4915 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4916 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4917 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE47';
4918 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE47;
4919 end if;
4920 if asked_for_rec.PRICING_ATTRIBUTE48 is not null then
4921 i := px_Req_line_attr_tbl.count+1;
4922 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4923 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4924 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4925 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE48';
4926 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE48;
4927 end if;
4928 if asked_for_rec.PRICING_ATTRIBUTE49 is not null then
4929 i := px_Req_line_attr_tbl.count+1;
4930 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4931 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4932 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4933 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE49';
4934 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE49;
4935 end if;
4936
4937 if asked_for_rec.PRICING_ATTRIBUTE50 is not null then
4938 i := px_Req_line_attr_tbl.count+1;
4939 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4940 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4941 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4942 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE50';
4943 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE50;
4944 end if;
4945 if asked_for_rec.PRICING_ATTRIBUTE51 is not null then
4946 i := px_Req_line_attr_tbl.count+1;
4947 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4948 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4949 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4950 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE51';
4951 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE51;
4952 end if;
4953 if asked_for_rec.PRICING_ATTRIBUTE52 is not null then
4954 i := px_Req_line_attr_tbl.count+1;
4955 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4956 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4957 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4958 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE52';
4959 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE52;
4960 end if;
4961 if asked_for_rec.PRICING_ATTRIBUTE53 is not null then
4962 i := px_Req_line_attr_tbl.count+1;
4963 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4964 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4965 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4966 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE53';
4967 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE53;
4968 end if;
4969 if asked_for_rec.PRICING_ATTRIBUTE54 is not null then
4970 i := px_Req_line_attr_tbl.count+1;
4971 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4972 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4973 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4974 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE54';
4975 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE54;
4976 end if;
4977 if asked_for_rec.PRICING_ATTRIBUTE55 is not null then
4978 i := px_Req_line_attr_tbl.count+1;
4979 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4980 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4981 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4982 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE55';
4983 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE55;
4984 end if;
4985 if asked_for_rec.PRICING_ATTRIBUTE56 is not null then
4986 i := px_Req_line_attr_tbl.count+1;
4987 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4988 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4989 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4990 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE56';
4991 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE56;
4992 end if;
4993 if asked_for_rec.PRICING_ATTRIBUTE57 is not null then
4994 i := px_Req_line_attr_tbl.count+1;
4995 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
4996 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
4997 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
4998 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE57';
4999 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE57;
5000 end if;
5001 if asked_for_rec.PRICING_ATTRIBUTE58 is not null then
5002 i := px_Req_line_attr_tbl.count+1;
5003 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5004 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5005 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5006 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE58';
5007 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE58;
5008 end if;
5009 if asked_for_rec.PRICING_ATTRIBUTE59 is not null then
5010 i := px_Req_line_attr_tbl.count+1;
5011 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5012 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5013 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5014 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE59';
5015 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE59;
5016 end if;
5017
5018 if asked_for_rec.PRICING_ATTRIBUTE60 is not null then
5019 i := px_Req_line_attr_tbl.count+1;
5020 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5021 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5022 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5023 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE60';
5024 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE60;
5025 end if;
5026 if asked_for_rec.PRICING_ATTRIBUTE61 is not null then
5027 i := px_Req_line_attr_tbl.count+1;
5028 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5029 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5030 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5031 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE61';
5032 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE61;
5033 end if;
5034 if asked_for_rec.PRICING_ATTRIBUTE62 is not null then
5035 i := px_Req_line_attr_tbl.count+1;
5036 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5037 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5038 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5039 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE62';
5040 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE62;
5041 end if;
5042 if asked_for_rec.PRICING_ATTRIBUTE63 is not null then
5043 i := px_Req_line_attr_tbl.count+1;
5044 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5045 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5046 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5047 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE63';
5048 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE63;
5049 end if;
5050 if asked_for_rec.PRICING_ATTRIBUTE64 is not null then
5051 i := px_Req_line_attr_tbl.count+1;
5052 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5053 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5054 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5055 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE64';
5056 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE64;
5057 end if;
5058 if asked_for_rec.PRICING_ATTRIBUTE65 is not null then
5059 i := px_Req_line_attr_tbl.count+1;
5060 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5061 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5062 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5063 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE65';
5064 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE65;
5065 end if;
5066 if asked_for_rec.PRICING_ATTRIBUTE66 is not null then
5067 i := px_Req_line_attr_tbl.count+1;
5068 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5069 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5070 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5071 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE66';
5072 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE66;
5073 end if;
5074 if asked_for_rec.PRICING_ATTRIBUTE67 is not null then
5075 i := px_Req_line_attr_tbl.count+1;
5076 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5077 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5078 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5079 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE67';
5080 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE67;
5081 end if;
5082 if asked_for_rec.PRICING_ATTRIBUTE68 is not null then
5083 i := px_Req_line_attr_tbl.count+1;
5084 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5085 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5086 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5087 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE68';
5088 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE68;
5089 end if;
5090 if asked_for_rec.PRICING_ATTRIBUTE69 is not null then
5091 i := px_Req_line_attr_tbl.count+1;
5092 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5093 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5094 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5095 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE69';
5096 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE69;
5097 end if;
5098
5099 if asked_for_rec.PRICING_ATTRIBUTE70 is not null then
5100 i := px_Req_line_attr_tbl.count+1;
5101 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5102 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5103 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5104 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE70';
5105 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE70;
5106 end if;
5107 if asked_for_rec.PRICING_ATTRIBUTE71 is not null then
5108 i := px_Req_line_attr_tbl.count+1;
5109 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5110 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5111 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5112 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE71';
5113 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE71;
5114 end if;
5115 if asked_for_rec.PRICING_ATTRIBUTE72 is not null then
5116 i := px_Req_line_attr_tbl.count+1;
5117 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5118 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5119 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5120 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE72';
5121 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE72;
5122 end if;
5123 if asked_for_rec.PRICING_ATTRIBUTE73 is not null then
5124 i := px_Req_line_attr_tbl.count+1;
5125 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5126 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5127 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5128 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE73';
5129 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE73;
5130 end if;
5131 if asked_for_rec.PRICING_ATTRIBUTE74 is not null then
5132 i := px_Req_line_attr_tbl.count+1;
5133 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5134 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5135 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5136 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE74';
5137 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE74;
5138 end if;
5139 if asked_for_rec.PRICING_ATTRIBUTE75 is not null then
5140 i := px_Req_line_attr_tbl.count+1;
5141 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5142 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5143 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5144 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE75';
5145 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE75;
5146 end if;
5147 if asked_for_rec.PRICING_ATTRIBUTE76 is not null then
5148 i := px_Req_line_attr_tbl.count+1;
5149 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5150 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5151 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5152 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE76';
5153 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE76;
5154 end if;
5155 if asked_for_rec.PRICING_ATTRIBUTE77 is not null then
5156 i := px_Req_line_attr_tbl.count+1;
5157 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5158 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5159 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5160 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE77';
5161 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE77;
5162 end if;
5163 if asked_for_rec.PRICING_ATTRIBUTE78 is not null then
5164 i := px_Req_line_attr_tbl.count+1;
5165 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5166 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5167 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5168 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE78';
5169 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE78;
5170 end if;
5171 if asked_for_rec.PRICING_ATTRIBUTE79 is not null then
5172 i := px_Req_line_attr_tbl.count+1;
5173 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5174 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5175 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5176 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE79';
5177 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE79;
5178 end if;
5179
5180 if asked_for_rec.PRICING_ATTRIBUTE80 is not null then
5181 i := px_Req_line_attr_tbl.count+1;
5182 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5183 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5184 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5185 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE80';
5186 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE80;
5187 end if;
5188 if asked_for_rec.PRICING_ATTRIBUTE81 is not null then
5189 i := px_Req_line_attr_tbl.count+1;
5190 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5191 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5192 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5193 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE81';
5194 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE81;
5195 end if;
5196 if asked_for_rec.PRICING_ATTRIBUTE82 is not null then
5197 i := px_Req_line_attr_tbl.count+1;
5198 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5199 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5200 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5201 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE82';
5202 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE82;
5203 end if;
5204 if asked_for_rec.PRICING_ATTRIBUTE83 is not null then
5205 i := px_Req_line_attr_tbl.count+1;
5206 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5207 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5208 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5209 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE83';
5210 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE83;
5211 end if;
5212 if asked_for_rec.PRICING_ATTRIBUTE84 is not null then
5213 i := px_Req_line_attr_tbl.count+1;
5214 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5215 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5216 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5217 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE84';
5218 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE84;
5219 end if;
5220 if asked_for_rec.PRICING_ATTRIBUTE85 is not null then
5221 i := px_Req_line_attr_tbl.count+1;
5222 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5223 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5224 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5225 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE85';
5226 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE85;
5227 end if;
5228 if asked_for_rec.PRICING_ATTRIBUTE86 is not null then
5229 i := px_Req_line_attr_tbl.count+1;
5230 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5231 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5232 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5233 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE86';
5234 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE86;
5235 end if;
5236 if asked_for_rec.PRICING_ATTRIBUTE87 is not null then
5237 i := px_Req_line_attr_tbl.count+1;
5238 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5239 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5240 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5241 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE87';
5242 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE87;
5243 end if;
5244 if asked_for_rec.PRICING_ATTRIBUTE88 is not null then
5245 i := px_Req_line_attr_tbl.count+1;
5246 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5247 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5248 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5249 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE88';
5250 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE88;
5251 end if;
5252 if asked_for_rec.PRICING_ATTRIBUTE89 is not null then
5253 i := px_Req_line_attr_tbl.count+1;
5254 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5255 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5256 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5257 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE89';
5258 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE89;
5259 end if;
5260
5261 if asked_for_rec.PRICING_ATTRIBUTE90 is not null then
5262 i := px_Req_line_attr_tbl.count+1;
5263 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5264 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5265 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5266 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE90';
5267 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE90;
5268 end if;
5269 if asked_for_rec.PRICING_ATTRIBUTE91 is not null then
5270 i := px_Req_line_attr_tbl.count+1;
5271 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5272 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5273 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5274 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE91';
5275 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE91;
5276 end if;
5277 if asked_for_rec.PRICING_ATTRIBUTE92 is not null then
5278 i := px_Req_line_attr_tbl.count+1;
5279 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5280 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5281 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5282 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE92';
5283 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE92;
5284 end if;
5285 if asked_for_rec.PRICING_ATTRIBUTE93 is not null then
5286 i := px_Req_line_attr_tbl.count+1;
5287 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5288 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5289 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5290 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE93';
5291 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE93;
5292 end if;
5293 if asked_for_rec.PRICING_ATTRIBUTE94 is not null then
5294 i := px_Req_line_attr_tbl.count+1;
5295 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5296 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5297 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5298 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE94';
5299 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE94;
5300 end if;
5301 if asked_for_rec.PRICING_ATTRIBUTE95 is not null then
5302 i := px_Req_line_attr_tbl.count+1;
5303 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5304 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5305 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5306 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE95';
5307 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE95;
5308 end if;
5309 if asked_for_rec.PRICING_ATTRIBUTE96 is not null then
5310 i := px_Req_line_attr_tbl.count+1;
5311 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5312 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5313 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5314 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE96';
5315 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE96;
5316 end if;
5317 if asked_for_rec.PRICING_ATTRIBUTE97 is not null then
5318 i := px_Req_line_attr_tbl.count+1;
5319 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5320 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5321 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5322 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE97';
5323 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE97;
5324 end if;
5325 if asked_for_rec.PRICING_ATTRIBUTE98 is not null then
5326 i := px_Req_line_attr_tbl.count+1;
5327 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5328 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5329 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5330 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE98';
5331 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE98;
5332 end if;
5333 if asked_for_rec.PRICING_ATTRIBUTE99 is not null then
5334 i := px_Req_line_attr_tbl.count+1;
5335 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5336 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5337 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5338 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE99';
5339 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE99;
5340 end if;
5341 if asked_for_rec.PRICING_ATTRIBUTE100 is not null then
5342 i := px_Req_line_attr_tbl.count+1;
5343 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
5344 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
5345 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
5346 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE100';
5347 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From:=asked_for_rec.PRICING_ATTRIBUTE100;
5348 end if;
5349
5350 else -- Copy the Qualifiers
5351 G_STMT_NO := 'Append_asked_for#20';
5352 if asked_for_rec.PRICING_ATTRIBUTE1 is not null and asked_for_rec.PRICING_ATTRIBUTE2 is null then -- Promotion
5353 i := px_Req_Qual_Tbl.count+1;
5354 px_Req_Qual_Tbl(i).Line_Index := p_Line_Index;
5355 px_Req_Qual_Tbl(i).Validated_Flag := nvl(asked_for_rec.Override_Flag,'N');
5356 px_Req_Qual_Tbl(i).Qualifier_Context := asked_for_rec.pricing_context;
5357 px_Req_Qual_Tbl(i).Qualifier_Attribute := 'QUALIFIER_ATTRIBUTE1';
5358 px_Req_Qual_Tbl(i).Qualifier_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE1;
5359 end if;
5360 if asked_for_rec.PRICING_ATTRIBUTE2 is not null then --Deal Component
5361 i := px_Req_Qual_Tbl.count+1;
5362 px_Req_Qual_Tbl(i).Line_Index := p_Line_Index;
5363 px_Req_Qual_Tbl(i).Validated_Flag := nvl(asked_for_rec.Override_Flag,'N');
5364 px_Req_Qual_Tbl(i).Qualifier_Context := asked_for_rec.pricing_context;
5365 px_Req_Qual_Tbl(i).Qualifier_Attribute := 'QUALIFIER_ATTRIBUTE2';
5366 px_Req_Qual_Tbl(i).Qualifier_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE2;
5367 end if;
5368 if asked_for_rec.PRICING_ATTRIBUTE3 is not null then -- Coupons
5369 i := px_Req_Qual_Tbl.count+1;
5370 px_Req_Qual_Tbl(i).Line_Index := p_Line_Index;
5371 px_Req_Qual_Tbl(i).Validated_Flag := nvl(asked_for_rec.Override_Flag,'N');
5372 px_Req_Qual_Tbl(i).Qualifier_Context := asked_for_rec.pricing_context;
5373 px_Req_Qual_Tbl(i).Qualifier_Attribute := 'QUALIFIER_ATTRIBUTE3';
5374 px_Req_Qual_Tbl(i).Qualifier_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE3;
5375 end if;
5376
5377 end if;
5378 end loop;
5379
5380 adj_debug('Exiting oe_order_Adj_pvt.Append_asked_for',1);
5381
5382 end Append_asked_for;
5383
5384 procedure Get_the_parent_Line(p_Reference_line_Id Number,
5385 px_Line_Tbl in out nocopy OE_Order_Pub.Line_Tbl_Type,
5386 px_Req_related_lines_tbl in out nocopy QP_PREQ_GRP.Related_Lines_Tbl_Type,
5387 p_line_Tbl_index Number)
5388 is
5389 l_Line_Rec OE_Order_Pub.Line_Rec_Type;
5390 line_Tbl_Index pls_integer;
5391 l_related_lines_Index pls_integer;
5392 Begin
5393 G_STMT_NO := 'Get_the_parent_Line#10';
5394 adj_debug('Entering oe_order_Adj_pvt.Get_the_parent_Line',1);
5395 line_Tbl_Index := px_Line_Tbl.First;
5396 While line_Tbl_Index is not null loop
5397 If px_Line_Tbl(line_Tbl_Index).line_Id = p_Reference_line_Id Then
5398 Exit;
5399 End If;
5400 line_Tbl_Index := px_Line_Tbl.Next(line_Tbl_Index);
5401 End Loop;
5402
5403 G_STMT_NO := 'Get_the_parent_Line#20';
5404
5405 If line_Tbl_Index is null Then
5406 -- Parent Line is not found in px_line_tbl
5407 Begin
5408 line_Tbl_index := px_line_tbl.count+1;
5409
5410 oe_line_util.query_row(p_Reference_line_Id,L_Line_Rec );
5411 px_Line_Tbl(line_Tbl_index) := L_Line_Rec;
5412 -- Parent Line is only for info purpose, don't calculate price
5413 -- px_Line_Tbl(line_Tbl_index).calculate_price_flag := 'N';
5414 -- modified by lkxu, to be used in repricing
5415 px_Line_Tbl(line_Tbl_index).calculate_price_flag := 'X';
5416 Exception when No_Data_Found Then
5417 Null;
5418 End;
5419 End If;
5420 -- Populate the Relationship
5421 l_related_lines_Index := px_Req_related_lines_tbl.count+1;
5422 px_Req_related_lines_tbl(l_related_lines_Index).Line_Index := line_Tbl_index;
5423 px_Req_related_lines_tbl(l_related_lines_Index).Related_Line_Index := p_line_Tbl_index;
5424 px_Req_related_lines_tbl(l_related_lines_Index).Relationship_Type_Code
5425 := QP_PREQ_GRP.G_SERVICE_LINE;
5426
5427 adj_debug('Exiting oe_order_Adj_pvt.Get_the_parent_Line',1);
5428
5429 End Get_the_parent_Line;
5430
5431 procedure set_item_for_iue(
5432 px_line_rec in out nocopy OE_Order_PUB.line_rec_type
5433 ,p_req_line_detail_rec QP_PREQ_GRP.line_detail_rec_type
5434 )
5435 is
5436 -- This change is required since we are dropping the profile OE_ORGANIZATION -- _ID. Change made by Esha.
5437 /*l_org_id NUMBER := FND_PROFILE.Value('OE_ORGANIZATION_ID');*/
5438 l_org_id NUMBER := OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');
5439 l_ordered_item varchar2(300);
5440
5441 begin
5442 adj_debug('Entering oe_order_Adj_pvt.set_item_for_iue');
5443
5444 /*begin original item*/
5445 oe_debug_pub.ADD('px_line_rec.original_inventory_item_id:'||px_line_rec.INVENTORY_ITEM_ID,1);
5446 oe_debug_pub.ADD('px_line_rec.original_inventory_item_id:'||px_line_rec.original_INVENTORY_ITEM_ID,1);
5447 oe_debug_pub.ADD('px_line_rec.original_ordered_item_id:'||px_line_rec.ordered_item_id,1);
5448 oe_debug_pub.ADD('px_line_rec.original_item_identifier_type:'||px_line_rec.item_identifier_type,1);
5449 oe_debug_pub.ADD('px_line_rec.original_ordered_item:'||px_line_rec.ordered_item,1);
5450
5451 IF px_line_rec.original_inventory_item_id IS NULL THEN
5452 px_line_rec.original_inventory_item_id :=px_line_rec.INVENTORY_ITEM_ID;
5453 px_line_rec.original_ordered_item_id :=px_line_rec.ORDERED_ITEM_ID;
5454 px_line_rec.original_item_identifier_type :=px_line_rec.item_identifier_type;
5455 px_line_rec.original_ordered_item :=px_line_rec.ordered_item;
5456 px_line_rec.item_relationship_type :=14;
5457 END IF;
5458
5459 /*end original item*/
5460
5461 -- There is an item upgrade for this line
5462 px_line_rec.inventory_item_id := p_req_line_detail_rec.RELATED_ITEM_ID;
5463 px_line_rec.item_identifier_type := 'INT'; --bug 2281351
5464 If px_line_rec.item_identifier_type ='INT' then
5465 px_line_rec.ordered_item_id := p_req_line_detail_rec.RELATED_ITEM_ID;
5466 Begin
5467 SELECT concatenated_segments
5468 INTO px_line_rec.ordered_item
5469 FROM mtl_system_items_kfv
5470 WHERE inventory_item_id = px_line_rec.inventory_item_id
5471 AND organization_id = l_org_id;
5472 Exception when no_data_found then
5473 Null;
5474 End;
5475 End If;
5476
5477 adj_debug('Exiting oe_order_Adj_pvt.set_item_for_iue');
5478 end set_item_for_iue;
5479
5480 procedure Get_item_for_iue(px_line_rec in out nocopy OE_Order_PUB.line_rec_type)
5481 is
5482 -- This change is required since we are dropping the profile OE_ORGANIZATION -- _ID. Change made by Esha.
5483 l_org_id Number:= OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');
5484 /*l_org_id NUMBER := FND_PROFILE.Value('OE_ORGANIZATION_ID');*/
5485 l_ordered_item varchar2(300);
5486 cursor adj_cur is
5487 select modified_from from oe_price_adjustments
5488 where line_id=px_line_rec.line_id
5489 and list_line_type_code='IUE';
5490 begin
5491 adj_debug('Entering oe_order_Adj_pvt.Get_item_for_iue',1);
5492 For Adj_rec in Adj_cur loop
5493 -- There is an item upgrade for this line
5494 px_line_rec.inventory_item_id := to_number(Adj_rec.modified_from);
5495
5496
5497 If px_line_rec.item_identifier_type ='INT' then
5498 px_line_rec.ordered_item_id := to_number(Adj_rec.modified_from);
5499 Begin
5500 SELECT concatenated_segments
5501 INTO px_line_rec.ordered_item
5502 FROM mtl_system_items_kfv
5503 WHERE inventory_item_id = px_line_rec.inventory_item_id
5504 AND organization_id = l_org_id;
5505 Exception when no_data_found then
5506 Null;
5507 End;
5508 End If;
5509 Exit;
5510 End Loop;
5511
5512 adj_debug('Exiting oe_order_Adj_pvt.Get_item_for_iue',1);
5513 end Get_item_for_iue;
5514
5515 procedure calculate_adjustments(
5516 x_return_status out nocopy varchar2,
5517
5518 p_line_id number default null,
5519 p_header_id number Default null,
5520 p_Request_Type_Code varchar2 ,
5521 p_Control_Rec QP_PREQ_GRP.CONTROL_RECORD_TYPE,
5522 x_req_line_tbl out nocopy QP_PREQ_GRP.LINE_TBL_TYPE,
5523 x_Req_qual_tbl out nocopy QP_PREQ_GRP.QUAL_TBL_TYPE,
5524 x_Req_line_attr_tbl out nocopy QP_PREQ_GRP.LINE_ATTR_TBL_TYPE,
5525 x_Req_LINE_DETAIL_tbl out nocopy QP_PREQ_GRP.LINE_DETAIL_TBL_TYPE,
5526 x_Req_LINE_DETAIL_qual_tbl out nocopy QP_PREQ_GRP.LINE_DETAIL_QUAL_TBL_TYPE,
5527 x_Req_LINE_DETAIL_attr_tbl out nocopy QP_PREQ_GRP.LINE_DETAIL_ATTR_TBL_TYPE,
5528 x_Req_related_lines_tbl out nocopy QP_PREQ_GRP.RELATED_LINES_TBL_TYPE,
5529 p_use_current_header in Boolean Default FALSE
5530 --if use_current_header set to true, it will not set the header info
5531 --and it will use current header information set by the caller.
5532 --It is useful when getting a quote where header_id is not available.
5533 --in this case the caller will need to set Oe_Order_Pub.G_Hdr values
5534 ,p_write_to_db Boolean Default TRUE
5535 ,x_any_frozen_line out nocopy Boolean
5536
5537 ,x_Header_Rec out nocopy oe_Order_Pub.Header_REc_Type
5538
5539 ,x_line_Tbl in out nocopy oe_Order_Pub.Line_Tbl_Type
5540 ,p_honor_price_flag VARCHAR2 Default 'Y'
5541 ,p_multiple_events in VARCHAR2 Default 'N'
5542 ,p_action_code in VARCHAR2 Default 'NONE'
5543 )
5544 is
5545 l_return_status varchar2(1) := FND_API.G_RET_STS_SUCCESS;
5546 l_return_status_Text varchar2(240) ;
5547 l_header_rec OE_Order_PUB.Header_Rec_Type;
5548 l_Line_Tbl OE_Order_PUB.Line_Tbl_Type;
5549 l_line_tbl_tmp OE_Order_PUB.Line_Tbl_Type;
5550 --1472635
5551 l_temp_line_tbl OE_Order_PUB.Line_Tbl_type;
5552 i2 PLS_INTEGER;
5553 l_all_lines_from_db Boolean :=False;
5554
5555 l_Line_Rec OE_Order_PUB.Line_Rec_Type;
5556 l_req_line_tbl QP_PREQ_GRP.LINE_TBL_TYPE;
5557 l_Req_qual_tbl QP_PREQ_GRP.QUAL_TBL_TYPE;
5558 l_Req_line_attr_tbl QP_PREQ_GRP.LINE_ATTR_TBL_TYPE;
5559 l_Req_LINE_DETAIL_tbl QP_PREQ_GRP.LINE_DETAIL_TBL_TYPE;
5560 l_Req_LINE_DETAIL_qual_tbl QP_PREQ_GRP.LINE_DETAIL_QUAL_TBL_TYPE;
5561 l_Req_LINE_DETAIL_attr_tbl QP_PREQ_GRP.LINE_DETAIL_ATTR_TBL_TYPE;
5562 l_Req_related_lines_tbl QP_PREQ_GRP.RELATED_LINES_TBL_TYPE;
5563 l_pricing_contexts_Tbl QP_Attr_Mapping_PUB.Contexts_Result_Tbl_Type;
5564 l_qualifier_contexts_Tbl QP_Attr_Mapping_PUB.Contexts_Result_Tbl_Type;
5565 lx_req_line_tbl QP_PREQ_GRP.LINE_TBL_TYPE;
5566 lx_Req_qual_tbl QP_PREQ_GRP.QUAL_TBL_TYPE;
5567 lx_Req_line_attr_tbl QP_PREQ_GRP.LINE_ATTR_TBL_TYPE;
5568 lx_Req_LINE_DETAIL_tbl QP_PREQ_GRP.LINE_DETAIL_TBL_TYPE;
5569 lx_Req_LINE_DETAIL_qual_tbl QP_PREQ_GRP.LINE_DETAIL_QUAL_TBL_TYPE;
5570 lx_Req_LINE_DETAIL_attr_tbl QP_PREQ_GRP.LINE_DETAIL_ATTR_TBL_TYPE;
5571 lx_Req_related_lines_tbl QP_PREQ_GRP.RELATED_LINES_TBL_TYPE;
5572 Process_Service_Lines Boolean := FALSE;
5573 l_related_lines_Index pls_integer;
5574 line_tbl_index pls_integer;
5575 i pls_integer;
5576 l_bypass_pricing varchar2(30) := nvl(FND_PROFILE.VALUE('QP_BYPASS_PRICING'),'N');
5577 l_dummy Varchar2(1);
5578 l_header_id NUMBER;
5579 l_any_frozen_line BOOLEAN:=FALSE;
5580 l_calculate_price_flag varchar2(1);
5581 l_message_displayed Boolean:=FALSE;
5582 /* Variables added for bug 1828553 */
5583 l_order_line_id number;
5584 l_service_reference_line_id number;
5585 --btea begin
5586 l_Control_Rec QP_PREQ_GRP.CONTROL_RECORD_TYPE;
5587 --btea end
5588 -- Variable for Bug 2124989
5589 l_agreement_name varchar2(240);
5590 l_revision varchar2(50);
5591 OE_AGREEMENT_ERROR Exception;
5592 -- End of 21249898
5593
5594 QP_ATTR_MAPPING_ERROR Exception;
5595 l_completely_frozen BOOLEAN := TRUE;
5596
5597 l_order_status_rec QP_UTIL_PUB.ORDER_LINES_STATUS_REC_TYPE;
5598 l_pass_all_lines VARCHAR2(30);
5599 l_exists_phase VARCHAR2(1) := 'N';
5600 l_set_of_books Oe_Order_Cache.Set_Of_Books_Rec_Type;
5601 j PLS_INTEGER :=1;
5602 G_INT_CHANGED_LINE_ON Varchar2(3):= nvl(FND_PROFILE.VALUE('ONT_INTERNAL_CHANGED_LINE'),'Y');
5603 l_header_id2 NUMBER;
5604 begin
5605
5606
5607 adj_debug('Entering oe_line_adj.calulate_adjustments', 1);
5608
5609 G_STMT_NO := 'calculate_adjustments#10';
5610 if (p_line_id is null or p_line_id = FND_API.G_MISS_NUM)
5611 and ( p_header_id is null or p_header_id = FND_API.G_MISS_NUM)
5612 and x_line_Tbl.count =0
5613 and p_use_current_header = FALSE
5614 then
5615 l_return_status := FND_API.G_RET_STS_ERROR;
5616
5617 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
5618 THEN
5619
5620 FND_MESSAGE.SET_NAME('ONT','OE_ATTRIBUTE_REQUIRED');
5621 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','line_id or Header Id ');
5622 OE_MSG_PUB.Add;
5623 END IF;
5624 RAISE FND_API.G_EXC_ERROR;
5625 end if;
5626
5627 G_STMT_NO := 'calculate_adjustments#20';
5628 if p_Line_id is not null and p_Header_id is not null then
5629 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5630 THEN
5631 OE_MSG_PUB.Add_Exc_Msg ( G_PKG_NAME ,
5632 'oe_line_adj.calulate_adjustments'
5633 ,'Keys are mutually exclusive');
5634 END IF;
5635 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5636 end if;
5637
5638 -- Query the header Record
5639 if p_header_id is not null and p_Header_id <> FND_API.G_MISS_NUM then
5640
5641 G_STMT_NO := 'calculate_adjustments#30';
5642
5643 Begin
5644
5645 oe_Header_util.query_row (p_header_id => p_Header_id
5646 ,x_header_rec=>OE_Order_PUB.g_hdr );
5647 Exception when no_data_found then
5648 x_return_status := 'NOOP';
5649 adj_debug(G_STMT_NO||'Invalid header_id '||p_Header_id,1);
5650 Return;
5651 End;
5652 G_STMT_NO := 'calculate_adjustments#40';
5653
5654 oe_debug_pub.add('Passed in event code:'||p_control_rec.pricing_event);
5655
5656 QP_UTIL_PUB.Get_Order_Lines_Status
5657 (p_control_rec.pricing_event,l_order_status_rec);
5658
5659 oe_debug_pub.add('Pricing Engine return pass all_lines value:'||l_order_status_rec.ALL_LINES_FLAG);
5660 oe_debug_pub.add('Pricing Engine return pass changed line value:'||l_order_status_rec.Changed_Lines_Flag);
5661 oe_debug_pub.add('Cache header operation:'||oe_order_pub.g_hdr.operation);
5662
5663
5664 If G_INT_CHANGED_LINE_ON = 'Y' Then
5665 If (l_order_status_rec.ALL_LINES_FLAG = 'Y' and nvl(OE_LINE_ADJ_UTIL.G_SEND_ALL_LINES_FOR_DSP,'Y') = 'Y') --bug 2965218
5666 -- or p_multiple_events = 'Y'
5667 or (OE_GLOBALS.G_RECURSION_MODE <> FND_API.G_TRUE
5668 and p_control_rec.pricing_event = 'BOOK')
5669 or p_action_code = 'PRICE_ORDER' --user request to reprice all lines
5670 or Oe_Line_Adj_Util.has_service_lines(p_header_id)
5671 Then
5672 ----------------------------------------------------------------
5673 --Pricing says pass all lines, use query_lines is more efficient
5674 ----------------------------------------------------------------
5675 adj_debug('Query all_lines');
5676 oe_Line_util.query_rows(p_header_id => p_Header_id, x_line_tbl => l_Line_Tbl);
5677 g_pass_all_lines:='Y';
5678 Elsif l_order_status_rec.CHANGED_LINES_FLAG = 'Y' OR nvl(OE_LINE_ADJ_UTIL.G_SEND_ALL_LINES_FOR_DSP,'Y') = 'N' Then
5679 -------------------------------------------------------------------
5680 --Pricing says pass only changed lines, use query_line
5681 --------------------------------------------------------------------
5682 oe_debug_pub.add('Query individual line');
5683 g_pass_all_lines:='N';
5684 i := Oe_Line_Adj_Util.G_CHANGED_LINE_TBL.FIRST;
5685 While i is Not Null Loop
5686 Begin
5687 --bug 3020702
5688 oe_debug_pub.add(' header_id:'||Oe_Line_Adj_Util.G_CHANGED_LINE_TBL(i).header_id);
5689 if oe_line_adj_util.G_CHANGED_LINE_TBL(i).header_id = p_header_id then
5690 oe_debug_pub.add(' trying to query line_id:'||Oe_Line_Adj_Util.G_CHANGED_LINE_TBL(i).line_id);
5691 l_line_tbl(j):=oe_line_util.query_row(p_line_id =>Oe_Line_Adj_Util.G_CHANGED_LINE_TBL(i).line_id);
5692 j:=j+1;
5693 end if;
5694 Exception when no_data_found then
5695 oe_debug_pub.add('Not found line id:'||Oe_Line_Adj_Util.G_CHANGED_LINE_TBL(i).line_id);
5696 End;
5697 i:= Oe_Line_Adj_Util.G_CHANGED_LINE_TBL.Next(i);
5698 End Loop;
5699 End If;
5700
5701 Else
5702
5703 If p_multiple_events = 'N' Then
5704 -- bug 2089312, call QP API to determine whether or not to
5705 -- all lines to pricing engine.
5706 If l_order_status_rec.ALL_LINES_FLAG = 'Y' Or
5707 l_order_status_rec.Changed_Lines_Flag = 'Y' Then
5708 G_PASS_ALL_LINES := 'Y';
5709 End If;
5710 Else --it is a multiple events we always pass all lines when it is a multiple events call
5711 -- G_PASS_ALL_LINES := 'Y';
5712 null;
5713 End If;
5714
5715 --temporary fix for bug 2199678 for patchset G, we will need
5716 --to change this later for performacne in book event
5717 If p_control_rec.pricing_event = 'BOOK' or p_action_code = 'PRICE_ORDER' Then
5718 G_PASS_ALL_LINES := 'Y';
5719 End If;
5720
5721 adj_debug('in calculate_adjustments, all_lines_flag is: '||G_PASS_ALL_LINES,1);
5722 -- only to pass all lines when the returned all_lines_flag is Y.
5723 IF G_PASS_ALL_LINES = 'Y' THEN
5724 Begin
5725 adj_debug('querying up all lines in header: '||p_Header_id,3);
5726 oe_Line_util.query_rows(p_header_id => p_Header_id, x_line_tbl => l_Line_Tbl);
5727 --1472635
5728 l_all_lines_from_db := True;
5729 Exception when no_data_found then
5730 -- No need to process this order
5731 x_return_status := 'NOOP';
5732 adj_debug(G_STMT_NO||'Invalid header_id '||p_Header_id,1);
5733 Return;
5734 End ;
5735 END IF;
5736 End If; --G_INT_CHANGED_LINE_ON
5737 else -- Query the line Record
5738 G_STMT_NO := 'calculate_adjustments#50';
5739 If x_line_Tbl.count = 0 Then
5740 Begin
5741
5742 oe_line_util.query_rows(p_line_id =>p_line_id, x_line_tbl=>l_Line_Tbl );
5743
5744
5745 Exception when no_data_found then
5746 -- No need to process this line
5747 x_return_status := 'NOOP';
5748 adj_debug(G_STMT_NO||'Invalid line_id '||p_line_id,1);
5749 Return;
5750 End ;
5751 Else
5752 l_Line_Tbl := x_line_Tbl;
5753 End If;
5754 G_STMT_NO := 'calculate_adjustments#60';
5755
5756 If p_use_current_header = FALSE Then
5757 Begin
5758 If l_line_tbl.first is not null Then
5759 oe_Header_util.query_row
5760 (p_header_id=> l_line_Tbl(l_line_tbl.first).Header_id, x_header_rec => OE_Order_PUB.g_hdr );
5761 Else
5762 oe_debug_pub.add(' Error: No line records in l_line_tbl');
5763 End If;
5764
5765 Exception when no_data_found then
5766 -- No need to process this order
5767 x_return_status := 'NOOP';
5768 adj_debug(G_STMT_NO||'Invalid header_id '||l_line_Tbl(1).Header_id,1);
5769 Return;
5770 End ;
5771 Else
5772 --Do Nothing since the flag says that the global record has been set
5773 NULL;
5774 End If;
5775 end if;
5776
5777 G_STMT_NO := 'calculate_adjustments#110';
5778 line_Tbl_Index := l_Line_Tbl.First;
5779 While line_Tbl_Index is not null loop
5780
5781 -- Added to check if Agreement is Active for Bug#2124989
5782
5783
5784 If l_line_tbl(line_Tbl_Index).agreement_id is not null Then
5785 BEGIN
5786 Select 'x' into l_dummy from dual
5787 where exists (select 'x' from oe_agreements_vl where
5788 agreement_id = l_line_tbl(line_Tbl_Index).agreement_id and
5789 ( trunc(nvl(l_line_tbl(line_Tbl_Index).PRICING_DATE,sysdate))
5790 between
5791 trunc(nvl(start_date_active, nvl(l_line_tbl(line_Tbl_Index).PRICING_DATE,sysdate)))
5792 and
5793 trunc(nvl(end_date_active, nvl(l_line_tbl(line_Tbl_Index).PRICING_DATE, sysdate)))));
5794
5795 --If l_dummy <>'x' then
5796
5797 Exception
5798 When no_data_found then
5799 Begin
5800 select name, revision into l_agreement_name, l_revision
5801 from oe_agreements_vl where agreement_id =
5802 l_line_tbl(line_Tbl_Index).agreement_id;
5803
5804 Exception
5805 When no_data_found then
5806 null;
5807 End;
5808 fnd_message.set_name('ONT','ONT_INVALID_AGR_REVISION');
5809 fnd_message.set_TOKEN('AGREEMENT',l_agreement_name||' : '||l_revision);
5810 fnd_message.set_TOKEN('PRICING_DATE',l_line_tbl(line_Tbl_Index).PRICING_DATE);
5811 OE_MSG_PUB.Add;
5812 RAISE OE_AGREEMENT_ERROR;
5813 END;
5814 End If;
5815 --End 2124989
5816
5817 -- Do not price the config items
5818 --If oe_line_util.Get_Return_Item_Type_Code(l_Line_Tbl(line_Tbl_Index)) <> 'CONFIG' Then
5819
5820
5821 -- Populate that Global Structure
5822 OE_Order_PUB.G_LINE := l_Line_Tbl(line_Tbl_Index);
5823 -- uom begin
5824 If OE_Order_PUB.G_LINE.unit_list_price_per_pqty = fnd_api.g_miss_num then
5825 OE_Order_PUB.G_LINE.unit_list_price_per_pqty:= Null;
5826 End If;
5827 -- uom end
5828
5829 -- Check if the line is service item
5830
5831 G_STMT_NO := 'calculate_adjustments#120';
5832 If (OE_Order_PUB.G_LINE.Service_Reference_Line_Id <>
5833 FND_API.G_MISS_NUM and
5834 OE_Order_PUB.G_LINE.Service_Reference_Line_Id is not null)
5835 Then
5836
5837 /* Added the following if condition for fixing the bug 1828553 */
5838 /* If the service reference context is ORDER, then the service_reference*/
5839 /*line_id is the line_id of the parent. However, if the service ref */
5840 /*context is Customer Product then we need to first retrieve the */
5841 /*original order line id */
5842
5843 IF l_Line_Tbl(line_Tbl_Index).item_type_code = 'SERVICE' AND
5844 l_Line_Tbl(line_Tbl_Index).service_reference_type_code='CUSTOMER_PRODUCT' AND
5845 l_Line_Tbl(line_Tbl_Index).service_reference_line_id IS NOT NULL THEN
5846 oe_debug_pub.add('1828553: Line is a customer product');
5847 OE_SERVICE_UTIL.Get_Cust_Product_Line_Id
5848 ( x_return_status => l_return_status
5849 , p_reference_line_id => l_Line_Tbl(line_Tbl_Index).service_reference_line_id
5850 , p_customer_id => l_Line_Tbl(line_Tbl_Index).sold_to_org_id
5851 , x_cust_product_line_id => l_order_line_id
5852 );
5853 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
5854 oe_debug_pub.add('1828553: Success');
5855 oe_debug_pub.add('1828553: Service line id is ' || l_order_line_id)
5856 ;
5857 l_service_reference_line_id := l_order_line_id;
5858 ELSE
5859 oe_debug_pub.add('Not able to retrieve cust product line id');
5860 RAISE NO_DATA_FOUND;
5861 END IF;
5862
5863 ELSE
5864 l_service_reference_line_id := l_Line_Tbl(line_Tbl_Index).service_reference_line_id;
5865 END IF;
5866
5867
5868 oe_debug_pub.add('1828553: l_Service_Reference_Line_Id: '||l_Service_Reference_Line_Id);
5869 --3273289{
5870 If(l_Service_Reference_Line_Id is NOT NULL) THEN
5871
5872 Get_the_parent_Line(p_Reference_line_Id =>
5873 l_Service_Reference_Line_Id,
5874 p_line_Tbl_Index => line_Tbl_Index,
5875 px_Req_related_lines_tbl => l_Req_related_lines_tbl,
5876 px_Line_Tbl => l_Line_Tbl) ;
5877 END IF;
5878 --3273289}
5879 End If;
5880
5881 -- Get Line Attributes
5882 G_STMT_NO := 'calculate_adjustments#130';
5883 Get_Item_For_Iue(px_line_rec => OE_Order_Pub.G_Line);
5884
5885 If l_bypass_pricing = 'Y' Then
5886
5887 adj_debug('Bypassing the qualifier build',1);
5888 Else
5889 adj_debug('Before QP_Attr_Mapping_PUB.Build_Contexts for line',1);
5890 Begin
5891 QP_Attr_Mapping_PUB.Build_Contexts(
5892 p_request_type_code => 'ONT',
5893 p_pricing_type => 'L',
5894 x_price_contexts_result_tbl => l_pricing_contexts_Tbl,
5895 x_qual_contexts_result_tbl => l_qualifier_Contexts_Tbl
5896 );
5897 Exception when others then
5898 Raise QP_ATTR_MAPPING_ERROR;
5899 End;
5900 End if;
5901
5902 G_STMT_NO := 'calculate_adjustments#135';
5903
5904 --Manual Begin
5905 If l_line_tbl(line_tbl_index).open_flag = 'N' Then
5906 l_line_tbl(line_tbl_index).calculate_price_flag := 'N';
5907 End If;
5908 --Manaul End
5909
5910 --Set a flag if this line has a calculate flag of N or P
5911 --which is frozen line. This flag will be used later
5912 --when passing summary line (order level) to pricing engine
5913 --with calculate_price of N (do not touch the order level amount).
5914
5915 IF l_line_tbl(line_tbl_index).item_type_code not in ('CONFIG', 'INCLUDED') THEN
5916 IF ( l_line_tbl(line_tbl_index).calculate_price_flag IN ('N','P') AND
5917 l_line_tbl(line_tbl_index).cancelled_flag = 'N') THEN
5918
5919 l_any_frozen_line := TRUE;
5920 x_any_frozen_line := TRUE;
5921 adj_debug('Any frozen line is true');
5922
5923 IF l_line_tbl(line_tbl_index).calculate_price_flag = 'P' THEN
5924 l_completely_frozen := FALSE;
5925 END IF;
5926
5927 ELSIF l_line_tbl(line_tbl_index).calculate_price_flag = 'Y' THEN
5928 l_completely_frozen := FALSE;
5929 END IF;
5930
5931 END IF; /* if item_type_code not in config and included */
5932
5933 copy_Line_to_request(
5934 p_Line_rec => l_Line_Tbl(line_Tbl_Index)
5935 ,p_pricing_event => p_control_rec.pricing_event
5936 ,px_req_line_tbl => l_req_line_tbl
5937 ,p_Request_Type_Code => p_Request_Type_Code
5938 ,p_honor_price_flag => p_honor_price_flag
5939 );
5940
5941 -- added by lkxu, to set the value back to 'N' after setting price flag.
5942 IF l_line_Tbl(line_Tbl_Index).calculate_price_flag = 'X' THEN
5943 l_line_Tbl(line_Tbl_Index).calculate_price_flag := 'N';
5944 END IF;
5945
5946 G_STMT_NO := 'calculate_adjustments#140';
5947 copy_attribs_to_Req(
5948 p_line_index => l_req_line_tbl.count
5949 ,p_pricing_contexts_Tbl => l_pricing_contexts_Tbl
5950 ,p_qualifier_contexts_Tbl => l_qualifier_Contexts_Tbl
5951 ,px_Req_line_attr_tbl => l_Req_line_attr_tbl
5952 ,px_Req_qual_tbl => l_Req_qual_tbl
5953 );
5954
5955
5956 G_STMT_NO := 'calculate_adjustments#150';
5957 Begin
5958 l_header_id2:=nvl(p_header_id,l_line_tbl(line_tbl_index).header_id);
5959 Select 'x' into l_dummy from dual
5960 Where exists
5961 (select 'x' from
5962 oe_order_price_attribs oopa
5963 where
5964 nvl(oopa.line_id,l_Line_Tbl(line_Tbl_Index).line_id) = l_Line_Tbl(line_Tbl_Index).line_id
5965 and oopa.header_id = l_header_id2);
5966
5967 Append_asked_for(p_header_id => l_header_id2,
5968 p_line_id => l_Line_Tbl(line_Tbl_Index).line_id,
5969 p_line_index => l_req_line_tbl.count ,
5970 px_Req_line_attr_tbl => l_Req_line_attr_tbl,
5971 px_Req_qual_tbl => l_Req_qual_tbl
5972 );
5973 Exception when no_data_found then null;
5974 End;
5975
5976 If G_DEBUG Then
5977 for i in 1..l_Req_line_attr_tbl.count
5978 loop
5979 adj_debug('Pricing context '|| l_Req_line_attr_tbl(i).pricing_Context,3);
5980 adj_debug('Value '|| l_Req_line_attr_tbl(i).Pricing_Attribute,3);
5981 adj_debug('Name '|| l_Req_line_attr_tbl(i).Pricing_attr_value_from,3);
5982 end loop;
5983
5984 for i in 1..l_Req_qual_tbl.Count
5985 loop
5986 adj_debug('qualifier context '|| l_Req_qual_tbl(i).Qualifier_Context,3);
5987 adj_debug('Value '|| l_Req_qual_tbl(i).Qualifier_Attribute,3);
5988 adj_debug('Name '|| l_Req_qual_tbl(i).Qualifier_Attr_Value_From,3);
5989 end loop;
5990 End If;
5991
5992 --End If; -- Item is not Config
5993
5994 line_Tbl_Index := l_Line_Tbl.Next(line_Tbl_Index);
5995
5996 end loop;
5997
5998 -- Get Header Attributes
5999
6000 G_STMT_NO := 'calculate_adjustments#70';
6001
6002 If l_bypass_pricing = 'Y' Then
6003
6004 adj_debug('Bypassing the qualifier build',1);
6005 Else
6006 adj_debug('Before QP_Attr_Mapping_PUB.Build_Contexts for Header',1);
6007 Begin
6008 QP_Attr_Mapping_PUB.Build_Contexts(
6009 p_request_type_code => 'ONT',
6010 p_pricing_type => 'H',
6011 x_price_contexts_result_tbl => l_pricing_contexts_Tbl,
6012 x_qual_contexts_result_tbl => l_qualifier_Contexts_Tbl
6013 );
6014 Exception when others then
6015 Raise QP_ATTR_MAPPING_ERROR;
6016 End;
6017
6018 end if;
6019 -- Build header Request
6020
6021 G_STMT_NO := 'calculate_adjustments#80';
6022
6023 IF (l_any_frozen_line=TRUE) THEN
6024
6025 IF l_completely_frozen = FALSE THEN
6026 l_calculate_price_flag := 'P';
6027 ELSE
6028 l_calculate_price_flag := 'N';
6029 END IF;
6030
6031
6032 If Not l_message_displayed Then
6033 -- FND_MESSAGE.SET_NAME('ONT','ONT_LINE_FROZEN');
6034 --need to a method to display message as hint in the future
6035 l_message_displayed := TRUE;
6036 End If;
6037 l_any_frozen_line:=FALSE;
6038 --adj_debug('BCT:ONT_LINE_FROZEN');
6039 Elsif l_all_lines_from_db = False Then
6040 --1472635
6041 --Didn't query from db, need to do that to check if
6042 --all other previously save lines is frozen
6043 --adj_debug('BCT all line from db is false');
6044
6045 If p_header_id is null then
6046 --ine_tbl_index := l_line_tbl.first;
6047 l_header_id := l_line_tbl(l_line_tbl.first).header_id;
6048 Else
6049 l_header_id := p_header_id;
6050 End If;
6051 --adj_debug('BCT order header id '||l_header_id);
6052
6053 /*oe_line_util.query_rows(p_header_id =>l_header_id, x_line_tbl=>l_temp_Line_Tbl );
6054 i2 := l_temp_line_tbl.first;
6055 While i2 is not Null Loop
6056 If l_temp_line_tbl(i2).calculate_price_flag In ('N','P') Then
6057 --adj_debug('BCT2000 any frozen line found');
6058 l_any_frozen_line :=True;
6059 x_any_frozen_line :=True;
6060 l_calculate_price_flag := 'N';
6061 Exit;
6062 End If;
6063 i2:=l_temp_line_tbl.next(i2);
6064
6065 End Loop;*/
6066
6067 Begin
6068
6069 BEGIN
6070
6071 Select 'x' into l_dummy
6072 from dual where
6073 exists(select 'x' from oe_order_lines
6074 Where header_id = l_header_id
6075 and calculate_price_flag in ('Y','P')
6076 and item_type_code not in ('CONFIG', 'INCLUDED'));
6077
6078 l_completely_frozen := FALSE;
6079
6080 EXCEPTION
6081 WHEN NO_DATA_FOUND THEN
6082 l_completely_frozen := TRUE;
6083 l_any_frozen_line :=True;
6084 x_any_frozen_line :=True;
6085 l_calculate_price_flag := 'N';
6086 END;
6087
6088 IF l_completely_frozen = FALSE THEN
6089
6090 Select 'p' into l_dummy
6091 from dual where
6092 exists (select 'x' from oe_order_lines
6093 where header_id = l_header_id
6094 and calculate_price_flag in ('N', 'P')
6095 and cancelled_flag = 'N'
6096 and item_type_code not in ('CONFIG', 'INCLUDED') );
6097
6098 l_any_frozen_line := TRUE;
6099 x_any_frozen_line := TRUE;
6100 l_calculate_price_flag := 'P';
6101
6102 END IF;
6103
6104 Exception when no_data_found then
6105 null;
6106 End;
6107
6108 If nvl(l_calculate_price_flag,'X') not in ('N', 'P') Then
6109 l_calculate_price_flag:='Y';
6110 End If;
6111
6112 ELSE
6113 l_calculate_price_flag := 'Y';
6114 END IF;
6115
6116 copy_Header_to_request(
6117 p_header_rec => OE_Order_PUB.g_hdr
6118 ,px_req_line_tbl => l_req_line_tbl
6119 ,p_Request_Type_Code => p_Request_Type_Code
6120 ,p_calculate_price_flag =>l_calculate_price_flag
6121 );
6122
6123 G_STMT_NO := 'calculate_adjustments#90';
6124 copy_attribs_to_Req(
6125 p_line_index => l_req_line_tbl.count
6126 ,p_pricing_contexts_Tbl => l_pricing_contexts_Tbl
6127 ,p_qualifier_contexts_Tbl => l_qualifier_Contexts_Tbl
6128 ,px_Req_line_attr_tbl => l_Req_line_attr_tbl
6129 ,px_Req_qual_tbl => l_Req_qual_tbl
6130 );
6131
6132 G_STMT_NO := 'calculate_adjustments#100';
6133 Begin
6134 -- Modified for bug 3502454
6135 --l_header_id2:= nvl(p_header_id,l_line_tbl(l_line_tbl.first).header_id);
6136 IF ( p_header_id IS NULL ) THEN
6137 l_header_id2 := l_line_tbl(l_line_tbl.first).header_id;
6138 ELSE
6139 l_header_id2 := p_header_id;
6140 END IF;
6141 -- End of 3502454
6142
6143 Select 'x' into l_dummy from dual
6144 where exists(
6145 Select 'X' from oe_order_price_attribs oopa
6146 where oopa.header_id = l_header_id2 and oopa.line_id is null);
6147
6148 Append_asked_for(
6149 p_header_id => l_header_id2
6150 ,p_line_index => l_req_line_tbl.count
6151 ,px_Req_line_attr_tbl => l_Req_line_attr_tbl
6152 ,px_Req_qual_tbl => l_Req_qual_tbl
6153 );
6154
6155 Exception when no_data_found then null;
6156 when others then
6157 oe_debug_pub.add(sqlerrm);
6158 oe_debug_pub.add('l_line_tbl.first'||l_line_tbl.first);
6159 End;
6160
6161 G_STMT_NO := 'calculate_adjustments#101';
6162
6163 If G_Debug Then
6164 for i in 1..l_Req_line_attr_tbl.count
6165 loop
6166 adj_debug('Pricing context '|| l_Req_line_attr_tbl(i).pricing_Context,3);
6167 adj_debug('Value '|| l_Req_line_attr_tbl(i).Pricing_Attribute,3);
6168 adj_debug('Name '|| l_Req_line_attr_tbl(i).Pricing_attr_value_from,3);
6169 adj_debug('---------------------------------------------',3);
6170 end loop;
6171
6172 for i in 1..l_Req_qual_tbl.Count
6173 loop
6174 adj_debug('qualifier context '|| l_Req_qual_tbl(i).Qualifier_Context,3);
6175 adj_debug('Value '|| l_Req_qual_tbl(i).Qualifier_Attribute,3);
6176 adj_debug('Name '|| l_Req_qual_tbl(i).Qualifier_Attr_Value_From,3);
6177 adj_debug('---------------------------------------------',3);
6178 end loop;
6179
6180
6181 i:= l_Req_line_tbl.First;
6182 While i is not null loop
6183 adj_debug('The Line Index '||l_Req_line_tbl(i).line_index,3);
6184 adj_debug('The Line_id '||l_Req_line_tbl(i).line_id,3);
6185 adj_debug('The Line Type '||l_Req_line_tbl(i).Line_type_code,3);
6186 adj_debug('---------------------------------------------',3);
6187 i:= l_Req_line_tbl.Next(i);
6188 end loop;
6189
6190 End If; --g_debug
6191
6192 G_STMT_NO := 'calculate_adjustments#160';
6193 adj_debug('Before QP_PREQ_GRP.PRICE_REQUEST',1);
6194
6195 --btea begin
6196 l_control_rec := p_control_rec;
6197
6198 --Q means ask pricing engine to determine rounding options.
6199 l_control_rec.rounding_flag := 'Q';
6200 l_control_rec.use_multi_currency:='Y';
6201 l_control_rec.USER_CONVERSION_RATE:= OE_ORDER_PUB.G_HDR.CONVERSION_RATE;
6202 l_control_rec.USER_CONVERSION_TYPE:= OE_ORDER_PUB.G_HDR.CONVERSION_TYPE_CODE;
6203 l_set_of_books := Oe_Order_Cache.Load_Set_Of_Books;
6204 l_control_rec.FUNCTION_CURRENCY := l_set_of_books.currency_code;
6205
6206 G_STMT_NO := 'QP_PRICE_REQUEST_GRP';
6207 QP_PREQ_GRP.PRICE_REQUEST
6208 (p_control_rec => l_control_rec
6209 ,p_line_tbl => l_Req_line_tbl
6210 ,p_qual_tbl => l_Req_qual_tbl
6211 ,p_line_attr_tbl => l_Req_line_attr_tbl
6212 ,p_line_detail_tbl =>l_req_line_detail_tbl
6213 ,p_line_detail_qual_tbl =>l_req_line_detail_qual_tbl
6214 ,p_line_detail_attr_tbl =>l_req_line_detail_attr_tbl
6215 ,p_related_lines_tbl =>l_req_related_lines_tbl
6216 ,x_line_tbl =>x_req_line_tbl
6217 ,x_line_qual =>x_Req_qual_tbl
6218 ,x_line_attr_tbl =>x_Req_line_attr_tbl
6219 ,x_line_detail_tbl =>x_req_line_detail_tbl
6220 ,x_line_detail_qual_tbl =>x_req_line_detail_qual_tbl
6221 ,x_line_detail_attr_tbl =>x_req_line_detail_attr_tbl
6222 ,x_related_lines_tbl =>x_req_related_lines_tbl
6223 ,x_return_status =>l_return_status
6224 ,x_return_status_Text =>l_return_status_Text
6225 );
6226 --btea end
6227 G_STMT_NO := 'calculate_adjustments#161';
6228 adj_debug('------------ After the Price_Request CAll -----------');
6229
6230 If G_DEBUG Then
6231 i:= x_Req_line_tbl.First;
6232 While i is not null loop
6233 adj_debug('The Line Index '||x_Req_line_tbl(i).line_index,3);
6234 adj_debug('The Line_id '||x_Req_line_tbl(i).line_id,3);
6235 adj_debug('The Line Type '||x_Req_line_tbl(i).Line_type_code,3);
6236 adj_debug('Status code '||x_Req_line_tbl(i).status_code,3);
6237 adj_debug('---------------------------------------------',3);
6238 i:= x_Req_line_tbl.Next(i);
6239 end loop;
6240 i:= x_req_line_detail_tbl.First;
6241 While i is not null loop
6242 adj_debug('('||i||')The line Index '||x_req_line_detail_tbl(i).Line_index,3);
6243 adj_debug('The line Detail Index '||x_req_line_detail_tbl(i).Line_Detail_Index,3);
6244 adj_debug('The List Line '||x_req_line_detail_tbl(i).List_Line_id,3);
6245 adj_debug('------------------------------------------------',3);
6246 i:= x_req_line_detail_tbl.Next(i);
6247 End Loop;
6248 i:= x_Req_related_lines_tbl.First;
6249 While i is not null loop
6250 adj_debug('Line Detail '||x_Req_related_lines_tbl(i).Line_detail_index,3);
6251 adj_debug('relation type '||x_Req_related_lines_tbl(i).relationship_type_code,3);
6252 adj_debug('rltd line detail index '||x_Req_related_lines_tbl(i).related_line_detail_index,3);
6253 adj_debug('--------------------------------------------------------',3);
6254 i:= x_Req_related_lines_tbl.Next(i);
6255 end loop;
6256 End If;
6257
6258 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6259 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6260 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6261 RAISE FND_API.G_EXC_ERROR;
6262 END IF;
6263
6264 x_return_status := l_return_status;
6265 /*
6266 x_Req_line_tbl := l_req_line_tbl;
6267 x_Req_qual_Tbl := l_Req_qual_tbl;
6268 x_Req_line_attr_tbl := l_Req_line_attr_tbl;
6269 x_Req_line_detail_tbl := l_req_line_detail_tbl;
6270 x_Req_line_detail_qual_tbl := l_req_line_detail_qual_tbl;
6271 x_Req_line_detail_attr_tbl := l_req_line_detail_attr_tbl;
6272 x_Req_related_lines_tbl := l_req_related_lines_tbl;
6273 */
6274
6275 x_header_Rec := OE_Order_PUB.g_hdr;
6276 x_line_tbl := l_line_tbl;
6277
6278 --reseting global structure after engine call
6279 OE_Order_PUB.G_LINE := NULL;
6280 OE_Order_PUB.G_HDR := NULL;
6281 -- Process the lines...
6282
6283 adj_debug('Exiting oe_order_Adj_pvt.calulate_adjustments', 1);
6284
6285 EXCEPTION
6286
6287 WHEN FND_API.G_EXC_ERROR THEN
6288
6289 FND_MESSAGE.SET_NAME('ONT','OE_PRICING_ERROR');
6290 FND_MESSAGE.SET_TOKEN('ERR_TEXT',l_return_status_Text);
6291 OE_MSG_PUB.Add;
6292 x_return_status := FND_API.G_RET_STS_ERROR;
6293
6294 adj_debug('g_exc_error is '||g_stmt_no||' '||sqlerrm,1);
6295 adj_debug('g_exc_error is '||l_return_status_Text);
6296
6297 RAISE FND_API.G_EXC_ERROR;
6298
6299 /* Added for Bug 2124989 */
6300 WHEN OE_AGREEMENT_ERROR Then
6301 x_return_status := FND_API.G_RET_STS_ERROR;
6302 oe_debug_pub.add('Error: Invalid AAgreement');
6303 RAISE FND_API.G_EXC_ERROR;
6304
6305 /* END 2124989 */
6306 WHEN QP_ATTR_MAPPING_ERROR THEN
6307 FND_MESSAGE.SET_NAME('ONT','OE_PRICING_ERROR');
6308 FND_MESSAGE.SET_TOKEN('ERR_TEXT','Please make sure Run QP Build Sourcing Rule has completed sucessfully');
6309 OE_MSG_PUB.Add;
6310 oe_debug_pub.add(' QP Attr Mapping threw exception');
6311 RAISE FND_API.G_EXC_ERROR;
6312 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6313
6314 FND_MESSAGE.SET_NAME('ONT','OE_PRICING_ERROR');
6315 FND_MESSAGE.SET_TOKEN('ERR_TEXT',l_return_status_Text);
6316 OE_MSG_PUB.Add;
6317 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6318 adj_debug('G_EXC_UNEXPECTED_ERROR is '||g_stmt_no||' '||sqlerrm,1);
6319 adj_debug('G_EXC_UNEXPECTED_ERROR is '||l_return_status_Text);
6320
6321 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6322
6323 WHEN OTHERS THEN
6324
6325 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6326 --dbms_output.put_line('Error is '||sqlerrm);
6327 adj_debug('Error Code is '||g_stmt_no||' '||sqlerrm,1);
6328
6329 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6330 THEN
6331 OE_MSG_PUB.Add_Exc_Msg
6332 ( G_PKG_NAME
6333 , 'oe_line_adj.calulate_adjustments',
6334 g_stmt_no||' '||sqlerrm
6335 );
6336 END IF;
6337
6338 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6339
6340 end calculate_adjustments;
6341
6342 Function Update_Adj_Line_rec(
6343 p_Line_Adj_Rec in out nocopy OE_Order_Pub.Line_Adj_Rec_Type
6344 ,p_req_line_detail_Rec qp_preq_grp.line_detail_rec_type
6345 )
6346 Return Boolean
6347 is
6348 l_updated_Flag Boolean := False;
6349 x_return_status VARCHAR2(240);
6350 x_return_status_txt VARCHAR2(240);
6351 Begin
6352 /* Start: Added by Manish */
6353 IF p_Line_Adj_Rec.OPERATION <> OE_GLOBALS.G_OPR_CREATE THEN
6354 p_Line_Adj_Rec.operation := OE_GLOBALS.G_OPR_UPDATE;
6355 END IF;
6356 /* End: Added by Manish */
6357
6358 adj_debug('Entering oe_order_Adj_pvt.Update_Adj_Line_rec',1);
6359 G_STMT_NO := 'Update_Adj_Line_rec#10';
6360
6361 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.list_header_id,
6362 p_req_line_detail_Rec.list_header_id) then
6363 p_Line_Adj_Rec.list_header_id :=
6364 p_req_line_detail_Rec.list_header_id;
6365 l_updated_Flag := True;
6366 end If;
6367
6368 If not OE_GLOBALS.Equal(p_Line_Adj_Rec.list_Line_id,
6369 p_req_line_detail_Rec.list_Line_id) Then
6370 p_Line_Adj_Rec.list_Line_id :=
6371 p_req_line_detail_Rec.list_Line_id;
6372 l_updated_Flag := True;
6373 end If;
6374
6375 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.Automatic_flag,
6376 p_req_line_detail_Rec.Automatic_flag) Then
6377 p_Line_Adj_Rec.Automatic_flag :=
6378 p_req_line_detail_Rec.Automatic_flag;
6379 l_updated_Flag := True;
6380 end If;
6381
6382 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.list_line_type_code,
6383 p_req_line_detail_Rec.list_line_type_code) Then
6384 p_Line_Adj_Rec.list_line_type_code :=
6385 p_req_line_detail_Rec.list_line_type_code;
6386 l_updated_Flag := True;
6387 end If;
6388
6389 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.list_line_no, p_req_line_detail_Rec.list_line_no) Then
6390 if (not l_updated_flag) and p_Line_Adj_Rec.list_line_type_code = 'CIE' Then
6391 adj_debug('CIE:to delete coupon'||p_req_line_detail_rec.list_line_no);
6392 -- retain the original coupon number, delete the new number
6393 QP_COUPON_PVT.Delete_Coupon(p_req_line_detail_Rec.list_line_no,
6394 x_return_status,
6395 x_return_status_txt
6396 );
6397 IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
6398 FND_MESSAGE.SET_NAME('ONT','OE_PRICING_ERROR');
6399 FND_MESSAGE.SET_TOKEN('ERR_TEXT',x_return_status_txt);
6400 OE_MSG_PUB.Add;
6401 RAISE FND_API.G_EXC_ERROR;
6402 END IF;
6403 else
6404 p_Line_Adj_Rec.list_line_no := p_req_line_detail_Rec.list_line_no;
6405 l_updated_Flag := True;
6406 end If;
6407 end If;
6408
6409 if p_Line_Adj_Rec.list_line_type_code = 'TSN' and -- Terms substitution
6410 not OE_GLOBALS.Equal(p_Line_Adj_Rec.modified_from,
6411 p_req_line_detail_Rec.substitution_from) Then
6412
6413 Begin
6414 p_Line_Adj_Rec.modified_from := p_req_line_detail_Rec.substitution_from;
6415 l_updated_Flag := True;
6416 Exception when value_error then
6417 adj_debug('Value error , The term is not updated '||p_req_line_detail_Rec.substitution_From);
6418 End;
6419
6420 end If;
6421
6422 if p_Line_Adj_Rec.list_line_type_code = 'TSN' and -- Terms substitution
6423 not OE_GLOBALS.Equal(p_Line_Adj_Rec.modified_to,
6424 p_req_line_detail_Rec.substitution_to) Then
6425
6426 Begin
6427 p_Line_Adj_Rec.modified_to := p_req_line_detail_Rec.substitution_to;
6428 l_updated_Flag := True;
6429 Exception when value_error then
6430 adj_debug('Value error , The term is not updated '||p_req_line_detail_Rec.substitution_to);
6431 End;
6432
6433 end If;
6434
6435 if p_Line_Adj_Rec.list_line_type_code = 'IUE' and -- Terms substitution
6436 not OE_GLOBALS.Equal(p_Line_Adj_Rec.modified_from,
6437 to_char(p_req_line_detail_Rec.INVENTORY_ITEM_ID)) Then
6438
6439 p_Line_Adj_Rec.modified_from := to_char(p_req_line_detail_Rec.INVENTORY_ITEM_ID);
6440 l_updated_Flag := True;
6441
6442 end If;
6443
6444 if p_Line_Adj_Rec.list_line_type_code = 'IUE' and -- Terms substitution
6445 not OE_GLOBALS.Equal(p_Line_Adj_Rec.modified_to,
6446 to_char(p_req_line_detail_Rec.RELATED_ITEM_ID)) Then
6447
6448 p_Line_Adj_Rec.modified_to := to_char(p_req_line_detail_Rec.RELATED_ITEM_ID);
6449 l_updated_Flag := True;
6450
6451 end If;
6452
6453 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.arithmetic_operator,
6454 p_req_line_detail_Rec.Operand_Calculation_Code) Then
6455 p_Line_Adj_Rec.arithmetic_operator := p_req_line_detail_Rec.Operand_Calculation_Code;
6456 l_updated_Flag := True;
6457 end If;
6458
6459 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.operand_per_pqty,
6460 p_req_line_detail_Rec.Operand_Value) Then
6461 p_Line_Adj_Rec.operand_per_pqty := p_req_line_detail_Rec.Operand_Value;
6462 If p_req_line_detail_Rec.Operand_Value is null Then
6463 Oe_Debug_Pub.add(' Null operand returned by pricing');
6464 Oe_Debug_pub.add(' List line type:'||p_req_line_detail_Rec.list_line_type_code);
6465 Oe_debug_pub.add(' list line id:'||p_req_line_detail_Rec.list_line_id);
6466 End If;
6467 l_updated_Flag := True;
6468 end If;
6469
6470 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.Applied_flag ,
6471 p_req_line_detail_Rec.Applied_Flag) or p_Line_Adj_Rec.Applied_flag is null
6472 Then
6473 p_Line_Adj_Rec.Applied_flag := nvl(p_req_line_detail_Rec.Applied_Flag,'N');
6474 l_updated_Flag := True;
6475 end If;
6476
6477 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.update_allowed,
6478 p_req_line_detail_Rec.Override_flag) Then
6479 p_Line_Adj_Rec.update_allowed := p_req_line_detail_Rec.Override_flag;
6480 l_updated_Flag := True;
6481 end If;
6482
6483 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.Pricing_phase_id,
6484 p_req_line_detail_Rec.Pricing_phase_id) Then
6485 p_Line_Adj_Rec.Pricing_phase_id := p_req_line_detail_Rec.Pricing_phase_id;
6486 l_updated_Flag := True;
6487 end If;
6488
6489 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.adjusted_amount_per_pqty,
6490 p_req_line_detail_Rec.Adjustment_Amount) Then
6491 p_Line_Adj_Rec.adjusted_amount_per_pqty := p_req_line_detail_Rec.Adjustment_Amount;
6492 l_updated_Flag := True;
6493 end If;
6494
6495 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.pricing_group_sequence,
6496 p_req_line_detail_Rec.pricing_group_sequence) Then
6497 p_Line_Adj_Rec.pricing_group_sequence := p_req_line_detail_Rec.pricing_group_sequence;
6498 l_updated_Flag := True;
6499 end If;
6500
6501 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.range_break_quantity,
6502 p_req_line_detail_Rec.line_quantity) Then
6503 p_Line_Adj_Rec.range_break_quantity := p_req_line_detail_Rec.line_quantity;
6504 l_updated_Flag := True;
6505 end If;
6506
6507 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.price_break_type_code,
6508 p_req_line_detail_Rec.price_break_type_code) Then
6509 p_Line_Adj_Rec.price_break_type_code := p_req_line_detail_Rec.price_break_type_code;
6510 l_updated_Flag := True;
6511 end If;
6512
6513 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.print_on_invoice_flag,
6514 p_req_line_detail_Rec.print_on_invoice_flag) Then
6515 p_Line_Adj_Rec.print_on_invoice_flag := p_req_line_detail_Rec.print_on_invoice_flag;
6516 l_updated_Flag := True;
6517 end If;
6518
6519 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.print_on_invoice_flag,
6520 p_req_line_detail_Rec.print_on_invoice_flag) Then
6521 p_Line_Adj_Rec.print_on_invoice_flag := p_req_line_detail_Rec.print_on_invoice_flag;
6522 l_updated_Flag := True;
6523 end If;
6524
6525 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.substitution_attribute,
6526 p_req_line_detail_Rec.substitution_attribute) Then
6527 p_Line_Adj_Rec.substitution_attribute := p_req_line_detail_Rec.substitution_attribute;
6528 l_updated_Flag := True;
6529 end If;
6530
6531 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.Accrual_flag,
6532 p_req_line_detail_Rec.Accrual_flag) Then
6533 p_Line_Adj_Rec.Accrual_flag := p_req_line_detail_Rec.Accrual_flag;
6534 l_updated_Flag := True;
6535 end If;
6536
6537 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.accrual_conversion_rate,
6538 p_req_line_detail_Rec.accrual_conversion_rate) Then
6539 p_Line_Adj_Rec.accrual_conversion_rate := p_req_line_detail_Rec.accrual_conversion_rate;
6540 l_updated_Flag := True;
6541 end If;
6542
6543 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.charge_type_code,
6544 p_req_line_detail_Rec.charge_type_code) Then
6545 p_Line_Adj_Rec.charge_type_code := p_req_line_detail_Rec.charge_type_code;
6546 l_updated_Flag := True;
6547 end If;
6548
6549 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.charge_subtype_code,
6550 p_req_line_detail_Rec.charge_subtype_code) Then
6551 p_Line_Adj_Rec.charge_subtype_code := p_req_line_detail_Rec.charge_subtype_code;
6552 l_updated_Flag := True;
6553 end If;
6554
6555
6556 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.include_on_returns_flag,
6557 p_req_line_detail_Rec.include_on_returns_flag) Then
6558 p_Line_Adj_Rec.include_on_returns_flag := p_req_line_detail_Rec.include_on_returns_flag;
6559 l_updated_Flag := True;
6560 end If;
6561
6562 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.benefit_uom_code,
6563 p_req_line_detail_Rec.benefit_uom_code) Then
6564 p_Line_Adj_Rec.benefit_uom_code := p_req_line_detail_Rec.benefit_uom_code;
6565 l_updated_Flag := True;
6566 end If;
6567
6568 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.Benefit_qty, p_req_line_detail_Rec.Benefit_qty) Then
6569 p_Line_Adj_Rec.Benefit_qty := p_req_line_detail_Rec.Benefit_qty;
6570 l_updated_Flag := True;
6571 end If;
6572
6573 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.proration_type_code,
6574 p_req_line_detail_Rec.proration_type_code) Then
6575 p_Line_Adj_Rec.proration_type_code := p_req_line_detail_Rec.proration_type_code;
6576 l_updated_Flag := True;
6577 end If;
6578
6579 /* if not OE_GLOBALS.Equal(p_Line_Adj_Rec.list_line_no, p_req_line_detail_Rec.list_line_no) Then
6580 p_Line_Adj_Rec.list_line_no := p_req_line_detail_Rec.list_line_no;
6581 l_updated_Flag := True;
6582 end If;
6583 */
6584 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.source_system_code,
6585 p_req_line_detail_Rec.source_system_code) Then
6586 p_Line_Adj_Rec.source_system_code := p_req_line_detail_Rec.source_system_code;
6587 l_updated_Flag := True;
6588 end If;
6589
6590 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.expiration_date,
6591 p_req_line_detail_Rec.expiration_date) Then
6592 p_Line_Adj_Rec.expiration_date := p_req_line_detail_Rec.expiration_date;
6593 l_updated_Flag := True;
6594 end If;
6595
6596 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.Rebate_transaction_type_code,
6597 p_req_line_detail_Rec.Rebate_transaction_type_code) Then
6598 p_Line_Adj_Rec.Rebate_transaction_type_code :=
6599 p_req_line_detail_Rec.Rebate_transaction_type_code;
6600 l_updated_Flag := True;
6601 end If;
6602
6603 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.modifier_level_code,
6604 p_req_line_detail_Rec.modifier_level_code) Then
6605 p_Line_Adj_Rec.modifier_level_code :=
6606 p_req_line_detail_Rec.modifier_level_code;
6607 l_updated_Flag := True;
6608 end If;
6609 if not OE_GLOBALS.Equal(p_Line_Adj_Rec.group_value,
6610 p_req_line_detail_Rec.group_value) Then
6611 p_Line_Adj_Rec.group_value :=
6612 p_req_line_detail_Rec.group_value;
6613 l_updated_Flag := True;
6614 end If;
6615
6616 /* bug 1915846 */
6617
6618 IF ( p_line_adj_rec.list_line_type_code = 'FREIGHT_CHARGE'
6619 and p_line_adj_rec.modifier_level_code = 'ORDER'
6620 and p_line_adj_rec.arithmetic_operator = 'LUMPSUM' ) THEN
6621
6622 p_line_adj_rec.adjusted_amount := p_line_adj_rec.adjusted_amount_per_pqty;
6623
6624 p_line_adj_rec.operand := p_line_adj_rec.operand_per_pqty;
6625
6626 END IF;
6627
6628 /* end bug 1915846 */
6629
6630
6631 adj_debug('Exiting oe_order_Adj_pvt.Update_Adj_Line_rec',1);
6632
6633 Return l_updated_Flag;
6634
6635 End Update_Adj_Line_rec;
6636
6637 --Function line_quantity_changed
6638
6639 Procedure Find_Duplicate_Adj_Lines(
6640 p_header_Id Number default null
6641 ,p_Line_id Number default null
6642 ,p_req_line_detail_Rec qp_preq_grp.line_detail_rec_type
6643 ,px_Line_Adj_Tbl in out nocopy OE_Order_Pub.Line_Adj_Tbl_Type
6644 ,X_Adj_Index out nocopy Number
6645
6646 ,p_mode in Varchar2
6647 ,px_line_key_tbl in out nocopy key_tbl_type
6648 ,px_header_key_tbl in out nocopy key_tbl_type
6649 )
6650 is
6651 l_end_index PLS_INTEGER;
6652 l_temp NUMBER;
6653 Begin
6654
6655 adj_debug('Entering oe_order_Adj_pvt.Find_Duplicate_Adj_Lines'||p_mode||'line_id'||p_line_id,1);
6656 adj_debug('BCT x_adj_index '||x_adj_index);
6657 G_STMT_NO := 'Find_Duplicate_Adj_Lines#10';
6658
6659 --retrieve start and end index from key_table to save extra scaning
6660
6661 IF p_mode = 'L' and px_line_key_tbl.exists(nvl(p_line_id,-1)) Then
6662 x_adj_index := px_line_key_tbl(p_line_id).db_start;
6663 l_end_index := px_line_key_tbl(p_line_id).db_end;
6664 adj_debug('BCT line id :'||p_line_id);
6665 adj_debug('BCT x_adj_index :'||x_adj_index);
6666 adj_debug('BCT l_end_index :'||l_end_index);
6667 Elsif p_mode = 'H' and px_header_key_tbl.exists(nvl(p_header_id,-1)) Then
6668 x_adj_index := px_header_key_tbl(p_header_id).db_start;
6669 l_end_index := px_header_key_tbl(p_header_id).db_end;
6670 Else
6671 --no record exists in key_tbl
6672 --reset the index so that it can skip the subsequence loop
6673 x_adj_index := -1;
6674 l_end_index := -2;
6675 End If;
6676
6677 --for the freight we need to loop thru everything, no shortcut
6678 If p_req_line_detail_Rec.list_line_type_code = 'FREIGHT_CHARGE'
6679 and px_line_adj_tbl.count > 0 Then
6680 x_adj_index := px_line_adj_tbl.first;
6681 l_end_index := px_line_adj_tbl.last;
6682 End If;
6683
6684 --G_STMT_NO := 'Find_Duplicate_Adj_Lines#10.5';
6685
6686 While nvl(X_Adj_Index,l_end_index + 1) <= l_end_index Loop
6687 If (px_Line_Adj_Tbl(X_Adj_Index).line_id = p_Line_id
6688 or
6689 px_Line_Adj_Tbl(X_Adj_Index).line_index = p_req_line_detail_Rec.line_index
6690 or -- for header adjustments
6691 ( px_Line_Adj_Tbl(X_Adj_Index).header_id = p_header_id and
6692 ( px_Line_Adj_Tbl(X_Adj_Index).line_id is null or
6693 px_Line_Adj_Tbl(X_Adj_Index).line_id = fnd_api.g_miss_num ) and
6694 ( px_Line_Adj_Tbl(X_Adj_Index).line_index is null or
6695 px_Line_Adj_Tbl(X_Adj_Index).line_index = fnd_api.g_miss_num )
6696 ))
6697 then
6698
6699 if px_Line_Adj_Tbl(X_Adj_Index).list_Line_id=p_req_line_detail_Rec.list_Line_id
6700 Then
6701 adj_debug('BCT found duplicate list line id:'||px_line_adj_tbl(x_adj_index).list_line_id);
6702 Exit;
6703 End if;
6704
6705 --G_STMT_NO := 'Find_Duplicate_Adj_Lines#10.55';
6706 adj_debug('BCT x_adj_index '||x_adj_index);
6707 IF px_Line_Adj_Tbl(X_Adj_Index).list_line_type_code
6708 = 'FREIGHT_CHARGE'
6709 AND px_Line_Adj_Tbl(X_Adj_Index).charge_type_code
6710 = p_req_line_detail_Rec.charge_type_code
6711 AND NVL(px_Line_Adj_Tbl(X_Adj_Index).charge_subtype_code
6712 ,'SUB') = NVL(p_req_line_detail_Rec.charge_subtype_code,'SUB')
6713 and
6714 nvl(px_Line_Adj_Tbl(X_Adj_Index).applied_flag,'Y') ='Y' and
6715 nvl(p_req_line_detail_Rec.Applied_Flag,'Y') = 'Y'
6716
6717 Then
6718 adj_debug('BCT found duplicate list line id:'||px_line_adj_tbl(x_adj_index).list_line_id);
6719 Exit;
6720 End If;
6721
6722 end if;
6723 --G_STMT_NO := 'Find_Duplicate_Adj_Lines#10.551';
6724 x_Adj_Index := px_Line_Adj_Tbl.Next(X_Adj_Index);
6725 end loop;
6726
6727 -- IF x_adj_index is not null THEN
6728 If x_adj_index is Null then x_adj_index := -1; end if;
6729
6730 If x_adj_index= -1 or x_adj_index > l_end_index Then
6731 -- This is a new Record
6732 --
6733 x_Adj_Index := px_line_adj_Tbl.count + 1;
6734 px_line_adj_tbl(x_adj_index) := OE_ORDER_PUB.G_MISS_LINE_ADJ_REC;
6735 px_line_adj_Tbl(x_Adj_Index).operation := OE_GLOBALS.G_OPR_CREATE;
6736 px_line_adj_Tbl(x_Adj_Index).Updated_Flag := 'N';
6737 px_line_adj_Tbl(x_Adj_Index).adjusted_amount_per_pqty := null;
6738 --
6739 elsif px_Line_Adj_Tbl(x_Adj_Index).price_adjustment_id is null or
6740 px_Line_Adj_Tbl(x_Adj_Index).price_adjustment_id = FND_API.g_miss_num Then
6741 --Record is not yet created in the database
6742 px_line_adj_Tbl(x_Adj_Index).Updated_Flag := 'N';
6743 px_line_adj_Tbl(x_Adj_Index).operation := OE_GLOBALS.G_OPR_CREATE;
6744 /* Taking out nocopy this part to be set in update_adj_line_rec: Manish */
6745
6746 -- Else
6747 -- px_Line_Adj_Tbl(x_Adj_Index).operation := OE_GLOBALS.G_OPR_UPDATE;
6748 end if;
6749
6750 --G_STMT_NO := 'Find_Duplicate_Adj_Lines#10.57';
6751
6752 oe_debug_pub.add('list_line_id:'||px_Line_Adj_Tbl(x_Adj_Index).list_line_id);
6753 oe_debug_pub.add('updated_flag:'||px_Line_Adj_Tbl(x_Adj_Index).updated_Flag);
6754 if px_Line_Adj_Tbl(x_Adj_Index).updated_Flag = 'Y' Then
6755 -- User has updated this record Do not touch this
6756 px_Line_Adj_Tbl(x_Adj_Index).Operation := FND_API.G_MISS_CHAR;
6757
6758 elsif px_Line_Adj_Tbl(X_Adj_Index).list_line_type_code =
6759 'FREIGHT_CHARGE'
6760 AND
6761 (NOT OE_GLOBALS.EQUAL(px_Line_Adj_Tbl(X_Adj_Index).list_Line_id,
6762 p_req_line_detail_Rec.list_Line_id))
6763 AND
6764 px_line_adj_Tbl(X_Adj_Index).operation <>
6765 OE_GLOBALS.G_OPR_DELETE
6766 AND
6767 nvl(px_Line_Adj_Tbl(x_Adj_Index).adjusted_amount_per_pqty,0) >=
6768 nvl(p_req_line_detail_Rec.adjustment_amount,0)
6769 Then
6770 -- Retain the freight charge of higher amount.
6771 Null;
6772 adj_debug('In Freight Compare',3);
6773
6774 elsif Not Update_Adj_Line_rec(
6775 p_Line_Adj_Rec => px_Line_Adj_Tbl(x_Adj_Index)
6776 ,p_req_line_detail_Rec => p_req_line_detail_Rec
6777 )
6778 Then
6779 -- There is no change in the adjustment record
6780
6781 px_Line_Adj_Tbl(x_Adj_Index).Operation := FND_API.G_MISS_CHAR;
6782
6783 --fix bug 1461198
6784 --if pricing engine return a prg line set the operation
6785 --to update because parent quantity might have changed
6786
6787 If p_req_line_detail_rec.list_line_type_code = 'PRG' Then
6788 px_line_adj_tbl(x_adj_index).operation := OE_GLOBALS.G_OPR_UPDATE;
6789 End If;
6790
6791 End If; -- Check Updated_Flag
6792
6793 --END IF;
6794
6795 adj_debug(' x_adj_index:'||x_Adj_Index);
6796 adj_debug('Exiting oe_order_Adj_pvt.Find_Duplicate_Adj_Lines',1);
6797
6798
6799
6800
6801
6802 End Find_Duplicate_Adj_Lines;
6803
6804 Procedure Query_Adj_Assocs(
6805 p_price_adjustment_id Number,
6806 p_Adj_Index Number,
6807 p_Line_Adj_Assoc_Tbl in out nocopy OE_Order_Pub.line_adj_Assoc_tbl_Type,
6808 p_delete_flag in Varchar2 default 'Y'
6809 ) Is
6810 L_Line_Adj_Assoc_Tbl OE_Order_Pub.line_adj_Assoc_tbl_Type;
6811 l_index pls_integer;
6812 i pls_integer;
6813 Begin
6814 adj_debug('Entering oe_order_Adj_pvt.Query_Adj_Assocs',1);
6815 G_STMT_NO := 'Query_Adj_Assocs#10';
6816
6817 -- Check If the price adjustment has been already queried
6818
6819 l_index := p_Line_Adj_Assoc_Tbl.First;
6820
6821 While l_index is not null loop
6822 If p_Line_Adj_Assoc_Tbl(l_index).price_adjustment_id = p_price_adjustment_id then
6823 Return;
6824 End If;
6825 l_index := p_Line_Adj_Assoc_Tbl.Next(l_Index);
6826
6827 End Loop;
6828
6829 adj_debug('query line adj assocs for price adjustment:'||p_price_adjustment_id, 2);
6830 OE_Line_Adj_Assocs_Util.Query_Rows(
6831 p_price_adjustment_id => p_price_adjustment_id
6832 , x_Line_Adj_Assoc_Tbl => L_Line_Adj_Assoc_Tbl );
6833
6834 -- Append to the tbl with Delete flag set.
6835 -- The row would be removed from this structure if there is a match.
6836
6837 G_STMT_NO := 'Query_Adj_Assocs#20';
6838
6839 --For i in 1..L_Line_Adj_Assoc_Tbl.count loop
6840 oe_debug_pub.add('zBefore Assoc QUery:');
6841 i:= L_Line_Adj_Assoc_Tbl.FIRST;
6842 WHILE i IS NOT NULL LOOP
6843 oe_debug_pub.add('zInside Assoc Query i value:'||i);
6844 l_index := p_Line_Adj_Assoc_Tbl.count+1;
6845 If p_delete_flag = 'Y' Then
6846 p_Line_Adj_Assoc_Tbl(l_index).Operation := OE_GLOBALS.G_OPR_DELETE;
6847 Else
6848 p_line_adj_assoc_tbl(l_index).Operation := FND_API.G_MISS_CHAR;
6849 End If;
6850 oe_debug_pub.add('zl_index:'||l_index);
6851 p_Line_Adj_Assoc_Tbl(l_index).Adj_Index := p_Adj_Index;
6852 p_Line_Adj_Assoc_Tbl(l_index).price_adjustment_id := p_price_adjustment_id;
6853 p_Line_Adj_Assoc_tbl(l_index).Rltd_Price_Adj_Id := l_Line_Adj_Assoc_tbl(i).Rltd_Price_Adj_Id;
6854 p_Line_Adj_Assoc_tbl(l_index).Line_Id := l_Line_Adj_Assoc_tbl(i).Line_Id;
6855 p_Line_Adj_Assoc_tbl(l_index).price_adj_assoc_id := l_Line_Adj_Assoc_tbl(i).price_adj_assoc_id;
6856 oe_debug_pub.add('z10');
6857 i:=l_Line_Adj_Assoc_tbl.NEXT(i);
6858 oe_debug_pub.add('z14');
6859 END LOOP;
6860 --end loop;
6861
6862 adj_debug('Exiting oe_order_Adj_pvt.Query_Adj_Assocs',1);
6863
6864 End Query_Adj_Assocs;
6865
6866 Procedure Append_Adjustment_Lines(
6867 p_header_id Number default null,
6868 p_line_id Number default null,
6869 p_Pricing_Event Varchar2 default null,
6870 p_any_frozen_line Boolean default FALSE,
6871 p_price_flag VARCHAR2 default null,
6872 px_Line_Adj_Tbl in out nocopy OE_Order_Pub.Line_Adj_Tbl_Type,
6873 px_line_key_tbl in out nocopy key_tbl_type,
6874 px_header_key_tbl in out nocopy key_tbl_type,
6875 p_mode in varchar2 default NULL,
6876 px_line_rec in out nocopy Oe_Order_Pub.Line_Rec_Type,
6877 px_line_adj_assoc_tbl in out nocopy OE_Order_PUB.Line_Adj_Assoc_Tbl_type,
6878 x_updated_flag out nocopy varchar2,
6879
6880 p_multiple_events in VARCHAR2 Default 'N'
6881 )
6882 is
6883 l_Pricing_Phase_id Index_Tbl_Type;
6884 l_Line_Adj_Tbl OE_Order_Pub.Line_Adj_Tbl_Type;
6885 i pls_integer;
6886 J pls_integer;
6887 p_override_freeze_flag VARCHAR2(1) := NULL;
6888 l_visited_flag BOOLEAN Default FALSE;
6889 l_dummy VARCHAR2(1);
6890 l_event_code1 Varchar2(240);
6891 l_mark_for_delete Varchar2(1);
6892 begin
6893
6894 adj_debug('Entering oe_order_Adj_pvt.Append_Adjustment_Lines, line_id = ' || p_line_id);
6895 adj_debug('price flag = ' || p_price_flag);
6896
6897 --If p_any_frozen_line Then l_dummy:='Y'; else l_dummy:='N'; End If;
6898 --adj_debug('BCT p_any_frozen_line '||l_dummy);
6899 G_STMT_NO := 'Append_Adjustment_Lines#10';
6900
6901 IF (p_price_flag = 'P') THEN
6902 p_override_freeze_flag := 'Y';
6903 END IF;
6904
6905
6906 if p_line_id is not null then
6907 G_STMT_NO := 'Append_Adjustment_Lines#20';
6908 adj_debug('BCT p_line_id is not null:'||TO_CHAR(p_line_id));
6909 OE_Line_Adj_Util.Query_Rows(p_Line_Id => p_line_id,x_line_adj_tbl=>l_Line_Adj_Tbl );
6910 else
6911 adj_debug('BCT p_line_id is null');
6912 G_STMT_NO := 'Append_Adjustment_Lines#25';
6913
6914 OE_Line_Adj_Util.Query_Rows(p_header_Id => p_header_id,x_line_adj_tbl=>l_Line_Adj_Tbl);
6915 End If;
6916
6917 x_updated_flag := 'N';
6918 i:= l_Line_Adj_Tbl.First;
6919 While i is not Null Loop
6920 IF l_Line_Adj_Tbl(i).updated_flag = 'Y' and x_updated_flag = 'N' THEN
6921 x_updated_flag := 'Y';
6922 END IF;
6923
6924 --The index of G_Pricing_Phase_Id_Tbl stores pricing phase id
6925 --and the content of this table stores freeze_override_flag
6926 If p_Pricing_Event is Not Null Then
6927
6928 If l_Line_Adj_Tbl(i).pricing_Phase_id is null
6929 or l_Line_Adj_Tbl(i).pricing_Phase_id = fnd_api.g_miss_num Then
6930 l_mark_for_delete:='Y';
6931 Elsif G_Pricing_Phase_Id_Tbl.Exists(l_Line_Adj_Tbl(i).pricing_Phase_id) Then
6932 If (G_Pricing_Phase_Id_Tbl(l_Line_Adj_Tbl(i).pricing_Phase_id) = 'Y' and p_price_flag = 'P')
6933 or p_price_flag = 'Y'
6934 Then
6935 l_mark_for_delete := 'Y';
6936 Else
6937 l_mark_for_delete := 'N';
6938 End If;
6939 Else
6940 l_mark_for_delete := 'N';
6941 End If;
6942
6943 adj_debug('Delete ' || l_Line_adj_tbl(i).price_adjustment_id || '? ' || l_mark_for_delete);
6944
6945 If l_mark_for_delete = 'Y' Then
6946 G_STMT_NO := 'Append_Adjustment_Lines#30';
6947 if l_Line_Adj_Tbl(i).Modifier_Level_Code= 'ORDER'
6948 and p_any_frozen_line
6949 and px_line_rec.ordered_quantity > 0 then
6950
6951 --We need to mark it as unchanged for the order level adjustments
6952 --that have a frozen line
6953
6954 L_Line_Adj_Tbl(i).operation := FND_API.G_MISS_CHAR;
6955
6956 elsif nvl(l_Line_Adj_Tbl(i).Updated_Flag,'N') = 'N' or
6957 l_Line_Adj_Tbl(i).Updated_Flag = fnd_api.g_miss_char then
6958 adj_debug('BCT'||l_Line_Adj_Tbl(i).price_adjustment_id);
6959 L_Line_Adj_Tbl(i).operation := OE_GLOBALS.G_OPR_DELETE;
6960
6961 --Fix bug 1758251
6962 If l_line_adj_tbl(i).list_line_type_code = 'IUE' Then
6963 get_item_for_iue(px_line_rec => px_line_rec);
6964 End If;
6965
6966 end if;
6967
6968 End if;
6969
6970 End If;
6971
6972 G_STMT_NO := 'Append_Adjustment_Lines#31';
6973
6974 -- bug 1834409
6975
6976 if ((l_line_adj_tbl(i).operand_per_pqty IS NULL) OR
6977 (L_line_adj_Tbl(i).operand_per_pqty = FND_API.G_MISS_NUM))
6978 then
6979 l_line_adj_tbl(i).operand_per_pqty :=
6980 l_line_adj_tbl(i).operand;
6981 end if;
6982
6983 if ((l_line_adj_tbl(i).adjusted_amount_per_pqty IS NULL) OR
6984 (L_line_adj_Tbl(i).adjusted_amount_per_pqty = FND_API.G_MISS_NUM))
6985 then
6986 l_line_adj_tbl(i).adjusted_amount_per_pqty := l_line_adj_tbl(i).adjusted_amount;
6987 end if;
6988
6989 -- end 1834409
6990
6991 px_line_adj_tbl(px_line_adj_tbl.count+1) := L_Line_Adj_Tbl(i);
6992
6993 If px_line_adj_tbl(px_line_adj_tbl.count).list_line_type_code In('PBH','PRG','OID','CIE')
6994 Then
6995 If px_line_adj_tbl(px_line_adj_tbl.count).operation = OE_GLOBALS.G_OPR_DELETE
6996 Then
6997 Query_Adj_Assocs(p_price_adjustment_id=>px_line_adj_tbl(px_line_adj_tbl.count).price_adjustment_id,
6998 p_Adj_Index => px_line_adj_tbl.count,
6999 p_Line_Adj_Assoc_Tbl => px_line_adj_Assoc_tbl,
7000 p_delete_flag => 'Y');
7001 Else
7002
7003 Query_Adj_Assocs(p_price_adjustment_id=>px_line_adj_tbl(px_line_adj_tbl.count).price_adjustment_id,
7004 p_Adj_Index => px_line_adj_tbl.count,
7005 p_Line_Adj_Assoc_Tbl => px_line_adj_Assoc_tbl,
7006 p_delete_flag => 'N');
7007
7008 End If;
7009 End If;
7010
7011 --This code is to set the begin and end key of adjustments for a given line
7012 --with this begin and end key find_duplicate_adj_line will find adjustments for
7013 --a given line more effieciently hence improve performance.
7014 adj_debug('BCT *** append list line id'||px_line_adj_tbl(px_line_adj_tbl.count).list_line_id);
7015 If not l_visited_flag Then
7016 If p_mode = 'L' Then
7017 px_line_key_tbl(p_line_id).db_start := px_line_adj_tbl.count;
7018 adj_debug('line '||p_line_id||' line key:'||px_line_key_tbl(p_line_id).db_start);
7019 G_STMT_NO := 'Append_Adjustment_Lines#32';
7020 Elsif p_mode = 'H' Then
7021 px_header_key_tbl(p_header_id).db_start := px_line_adj_tbl.count;
7022 adj_debug('header '||p_header_id||' header key:'||px_header_key_tbl(p_header_id).db_start);
7023 G_STMT_NO := 'Append_Adjustment_Lines#33';
7024 End If;
7025 l_visited_flag := TRUE;
7026 End If;
7027
7028 i:= l_Line_Adj_Tbl.Next(i);
7029 end loop;
7030
7031 --record the end index
7032 If l_line_adj_tbl.count > 0 Then --make sure there are adjustments
7033 If p_mode = 'L' Then
7034 px_line_key_tbl(p_line_id).db_end := px_line_adj_tbl.count;
7035 adj_debug('line end key: '||px_line_key_tbl(p_line_id).db_end);
7036 Elsif p_mode = 'H' Then
7037 px_header_key_tbl(p_header_id).db_end := px_line_adj_tbl.count;
7038 End If;
7039 End if;
7040
7041 i:=l_line_adj_tbl.first;
7042
7043 adj_debug('Exiting oe_order_Adj_pvt.Append_Adjustment_Lines',1);
7044 end Append_Adjustment_Lines;
7045
7046 Procedure Query_Adj_Attribs(
7047 p_price_adjustment_id Number,
7048 p_Adj_Index Number,
7049 p_Line_Adj_Att_Tbl in out nocopy OE_Order_Pub.line_adj_att_tbl_Type
7050 ) Is
7051 L_Line_Adj_Att_Tbl OE_Order_Pub.line_adj_att_tbl_Type;
7052 l_index pls_integer;
7053 Begin
7054 adj_debug('Entering oe_order_Adj_pvt.Query_Adj_Attribs',1);
7055
7056 G_STMT_NO := 'Query_Adj_Attribs#10';
7057
7058 adj_debug('Query for price Adjustment '||p_price_adjustment_id,2);
7059
7060 -- Check If the price adjustment has been already queried
7061
7062 l_index := p_Line_Adj_Att_Tbl.First;
7063
7064 While l_index is not null loop
7065 If p_Line_Adj_Att_Tbl(l_index).price_adjustment_id = p_price_adjustment_id then
7066 Return;
7067 End If;
7068 l_index := p_Line_Adj_Att_Tbl.Next(l_Index);
7069
7070 End Loop;
7071
7072 G_STMT_NO := 'Query_Adj_Attribs#15';
7073
7074
7075 Oe_Line_Price_Aattr_util.Query_Rows(
7076 p_price_adjustment_id => p_price_adjustment_id
7077 , x_Line_Adj_Att_Tbl=>L_Line_Adj_Att_Tbl);
7078
7079 -- Append to the tbl with Delete flag set.
7080 -- The row would be removed from this structure if there is a match.
7081
7082 G_STMT_NO := 'Query_Adj_Attribs#20';
7083
7084 For i in 1..L_Line_Adj_Att_Tbl.count loop
7085
7086 l_index := p_Line_Adj_Att_Tbl.count+1;
7087 p_Line_Adj_Att_Tbl(l_index) := l_Line_Adj_Att_tbl(i);
7088 p_Line_Adj_Att_Tbl(l_index).Operation := OE_GLOBALS.G_OPR_DELETE;
7089 p_Line_Adj_Att_Tbl(l_index).Adj_Index := p_Adj_Index;
7090 p_Line_Adj_Att_Tbl(l_index).price_adjustment_id := p_price_adjustment_id;
7091
7092 end loop;
7093
7094
7095 adj_debug('Exiting oe_order_Adj_pvt.Query_Adj_Attribs',1);
7096
7097 End Query_Adj_Attribs;
7098
7099 Procedure Find_Duplicate_Adj_Attribs(
7100 p_Req_Line_Detail_Qual_Rec
7101 QP_PREQ_GRP.Line_Detail_Qual_Rec_Type,
7102 p_Req_Line_Detail_Attr_Rec
7103 QP_PREQ_GRP.Line_Detail_Attr_Rec_Type,
7104 p_Adj_index Number,
7105 p_Line_Adj_Att_Tbl in out nocopy OE_Order_Pub.Line_Adj_Att_Tbl_Type,
7106 p_att_type Varchar2,
7107 p_price_adjustment_id Number
7108 )
7109 is
7110 l_Index pls_integer;
7111 I pls_integer;
7112 Begin
7113
7114 adj_debug('Entering oe_order_Adj_pvt.Find_Duplicate_Adj_Attribs',1);
7115 G_STMT_NO := 'Find_Duplicate_Adj_Attribs#10';
7116
7117 If p_att_Type='QUALIFIER' and p_Req_Line_Detail_Qual_Rec.Qualifier_Context IS Not Null Then
7118
7119 i:= p_Line_Adj_Att_Tbl.First;
7120 While i is not null loop
7121 If p_Line_Adj_Att_Tbl(i).Adj_Index = p_Adj_index Then
7122
7123 If OE_GLOBALS.Equal(p_Line_Adj_Att_tbl(i).flex_title ,
7124 'QP_ATTR_DEFNS_QUALIFIER') and
7125 OE_GLOBALS.Equal(p_Line_Adj_Att_tbl(i).pricing_context,
7126 p_Req_LINE_DETAIL_qual_Rec.Qualifier_Context) And
7127 OE_GLOBALS.Equal(p_Line_Adj_Att_tbl(i).pricing_attribute ,
7128 p_Req_LINE_DETAIL_qual_Rec.Qualifier_Attribute) And
7129 OE_GLOBALS.Equal(p_Line_Adj_Att_tbl(i).pricing_attr_value_from ,
7130 p_Req_LINE_DETAIL_qual_Rec.Qualifier_Attr_Value_From) And
7131 OE_GLOBALS.Equal(p_Line_Adj_Att_tbl(i).pricing_attr_value_To ,
7132 p_Req_LINE_DETAIL_qual_Rec.Qualifier_Attr_Value_To) And
7133 OE_GLOBALS.Equal(p_Line_Adj_Att_tbl(i).comparison_operator ,
7134 p_Req_LINE_DETAIL_qual_Rec.comparison_operator_Code)
7135 Then
7136 -- Do not delete the record from oe_order_Price_adj_Attribs
7137
7138 If p_Line_Adj_Att_Tbl(i).Operation = OE_GLobals.g_opr_delete then
7139 p_Line_Adj_Att_Tbl(i).Operation := FND_API.G_MISS_CHAR;
7140 End If;
7141
7142 Return;
7143
7144 End If;
7145
7146 End if; -- Adj_Index
7147 i:= p_Line_Adj_Att_Tbl.Next(i);
7148 End Loop;
7149
7150 G_STMT_NO := 'Find_Duplicate_Adj_Attribs#20';
7151 -- Create a New Record
7152 l_index := p_Line_Adj_Att_Tbl.count+1;
7153 p_Line_Adj_Att_Tbl(l_index) := OE_ORDER_PUB.G_MISS_LINE_ADJ_ATT_REC;
7154 p_Line_Adj_Att_Tbl(l_index).operation := OE_GLOBALS.G_OPR_CREATE;
7155 p_Line_Adj_Att_Tbl(l_index).Adj_index := P_Adj_Index;
7156 p_Line_Adj_Att_Tbl(l_index).price_adjustment_id := p_price_adjustment_id;
7157 p_Line_Adj_Att_Tbl(l_index).flex_title := 'QP_ATTR_DEFNS_QUALIFIER';
7158 p_Line_Adj_Att_Tbl(l_index).pricing_context :=
7159 p_Req_LINE_DETAIL_qual_Rec.Qualifier_Context;
7160 p_Line_Adj_Att_Tbl(l_index).pricing_attribute :=
7161 p_Req_LINE_DETAIL_qual_Rec.Qualifier_Attribute;
7162 p_Line_Adj_Att_Tbl(l_index).pricing_attr_value_from :=
7163 p_Req_LINE_DETAIL_qual_Rec.Qualifier_Attr_Value_From;
7164 p_Line_Adj_Att_Tbl(l_index).pricing_attr_value_To :=
7165 p_Req_LINE_DETAIL_qual_Rec.Qualifier_Attr_Value_To;
7166 p_Line_Adj_Att_Tbl(l_index).comparison_operator :=
7167 p_Req_LINE_DETAIL_qual_Rec.comparison_operator_Code;
7168
7169 End If; -- Qualifier Contexts
7170
7171
7172 G_STMT_NO := 'Find_Duplicate_Adj_Attribs#30';
7173 If p_att_type='PRICING' and p_Req_Line_Detail_Attr_Rec.Pricing_Context IS Not Null Then
7174
7175 i:= p_Line_Adj_Att_Tbl.First;
7176 While i is not null loop
7177
7178 If p_Line_Adj_Att_Tbl(i).Adj_Index = p_Adj_index Then
7179
7180 If OE_GLOBALS.Equal(p_Line_Adj_Att_tbl(i).flex_title ,
7181 'QP_ATTR_DEFNS_PRICING') and
7182 OE_GLOBALS.Equal(p_Line_Adj_Att_tbl(i).pricing_context,
7183 p_Req_Line_Detail_Attr_Rec.Pricing_Context) And
7184 OE_GLOBALS.Equal(p_Line_Adj_Att_tbl(i).pricing_attribute ,
7185 p_Req_Line_Detail_Attr_Rec.Pricing_Attribute) And
7186 OE_GLOBALS.Equal(p_Line_Adj_Att_tbl(i).pricing_attr_value_from ,
7187 p_Req_Line_Detail_Attr_Rec.Pricing_Attr_Value_From) And
7188 OE_GLOBALS.Equal(p_Line_Adj_Att_tbl(i).pricing_attr_value_To ,
7189 p_Req_Line_Detail_Attr_Rec.Pricing_Attr_Value_To)
7190 --And
7191 --OE_GLOBALS.Equal(p_Line_Adj_Att_tbl(i).comparison_operator ,
7192 --p_Req_Line_Detail_Attr_Rec.comparison_operator_Code)
7193 Then
7194 -- Do not delete the record from oe_order_Price_adj_Attribs
7195
7196 If p_Line_Adj_Att_Tbl(i).Operation = oe_globals.g_opr_delete Then
7197 p_Line_Adj_Att_Tbl(i).Operation := FND_API.G_MISS_CHAR;
7198 End If;
7199
7200 Return;
7201
7202 End If;
7203 End if; -- Adj_Index
7204 i:= p_Line_Adj_Att_Tbl.Next(I);
7205 End Loop;
7206
7207 -- Create a New Record
7208 l_index := p_Line_Adj_Att_Tbl.count+1;
7209 p_line_adj_att_tbl(l_index) := OE_ORDER_PUB.G_MISS_LINE_ADJ_ATT_REC;
7210 p_Line_Adj_Att_Tbl(l_index).operation := OE_GLOBALS.G_OPR_CREATE;
7211 p_Line_Adj_Att_Tbl(l_index).Adj_index := P_Adj_Index;
7212 p_Line_Adj_Att_Tbl(l_index).price_adjustment_id := p_price_adjustment_id;
7213 p_Line_Adj_Att_Tbl(l_index).flex_title := 'QP_ATTR_DEFNS_PRICING';
7214 p_Line_Adj_Att_Tbl(l_index).pricing_context :=
7215 p_Req_Line_Detail_Attr_Rec.Pricing_Context;
7216 p_Line_Adj_Att_Tbl(l_index).pricing_attribute :=
7217 p_Req_Line_Detail_Attr_Rec.Pricing_Attribute;
7218 p_Line_Adj_Att_Tbl(l_index).pricing_attr_value_from :=
7219 p_Req_Line_Detail_Attr_Rec.Pricing_Attr_Value_From;
7220 p_Line_Adj_Att_Tbl(l_index).pricing_attr_value_To :=
7221 p_Req_Line_Detail_Attr_Rec.Pricing_Attr_Value_To;
7222 End If;
7223
7224 adj_debug('Exiting oe_order_Adj_pvt.Find_Duplicate_Adj_Attribs',1);
7225
7226 End Find_Duplicate_Adj_Attribs;
7227
7228 Function Match_Product_Ids(
7229 p_price_Adjustment_Id Number,
7230 p_Line_Detail_Index Number ,
7231 p_Req_line_detail_Attr_Tbl QP_PREQ_GRP.line_detail_Attr_Tbl_Type
7232 )
7233 Return Boolean
7234 is
7235 l_inventory_item_id Varchar2(240);
7236 Begin
7237 adj_debug('Entering oe_order_Adj_pvt.Match_Product_Ids',1);
7238 G_STMT_NO := 'Match_Product_Ids#10';
7239 Begin
7240 /*
7241 select PRICING_ATTR_VALUE_FROM into l_inventory_item_id
7242 from oe_price_adj_attribs opaa
7243 where price_adjustment_id =p_price_Adjustment_Id and
7244 Flex_Title ='QP_ATTR_DEFNS_PRICING' and
7245 Pricing_Context='ITEM' and
7246 Pricing_attribute='PRICING_ATTRIBUTE1' and
7247 Rownum < 2;
7248 */
7249
7250 Select inventory_item_id into l_inventory_item_id
7251 from oe_price_adjustments opa,oe_order_lines_all ola
7252 where opa.line_id=ola.line_id and
7253 opa.price_adjustment_id=p_price_Adjustment_Id;
7254
7255 Exception when no_data_found then
7256 Return False; -- Treat this as new Item
7257 End;
7258
7259 G_STMT_NO := 'Match_Product_Ids#20';
7260 for i in 1..p_Req_line_detail_Attr_Tbl.count loop
7261 if p_Req_line_detail_Attr_Tbl(i).line_detail_index = p_Line_Detail_Index and
7262 p_Req_line_detail_Attr_Tbl(i).Pricing_Context='ITEM' and
7263 p_Req_line_detail_Attr_Tbl(i).Pricing_attribute='PRICING_ATTRIBUTE1' and
7264 p_Req_line_detail_Attr_Tbl(i).Pricing_Attr_Value_From = l_inventory_item_id
7265 Then
7266 -- Got a match
7267 adj_debug('Exiting oe_order_Adj_pvt.Match_Product_Ids',1);
7268 Return True;
7269 End If;
7270 End Loop;
7271 Return False;
7272
7273 End Match_Product_Ids;
7274
7275 Procedure Process_Other_Item_Line (
7276 p_Line_Detail_Index Number
7277 ,p_req_line_Tbl QP_PREQ_GRP.LINE_TBL_TYPE
7278 ,p_req_line_detail_Tbl QP_PREQ_GRP.LINE_DETAIL_TBL_TYPE
7279 ,p_Req_line_detail_Attr_Tbl QP_PREQ_GRP.line_detail_Attr_Tbl_Type
7280 ,p_Price_Adjustment_Id Number
7281 ,p_Header_Id Number
7282 ,p_Parent_Adj_Index Number
7283 ,p_parent_line_index Number
7284 ,p_Rltd_line_details_prcd in out nocopy Index_Tbl_Type
7285 ,p_Rltd_lines_prcd in out nocopy Index_Tbl_Type
7286 ,p_Line_Tbl in out nocopy OE_Order_Pub.Line_Tbl_Type
7287 ,p_Line_Adj_Tbl in out nocopy OE_Order_Pub.Line_Adj_Tbl_Type
7288 ,p_Line_Adj_Assoc_Tbl in out nocopy OE_Order_Pub.Line_Adj_Assoc_Tbl_Type
7289 ,p_line_detail_replaced in out nocopy Index_Tbl_Type
7290 ,p_buy_line_rec in Oe_Order_Pub.Line_Rec_Type
7291 )
7292 is
7293 l_line_Adj_Rec OE_Order_Pub.Line_Adj_Rec_Type;
7294 l_line_Rec OE_Order_Pub.Line_Rec_Type;
7295 l_Match_Exists Boolean := False;
7296 l_Req_Line_Index pls_integer;
7297 l_Adj_Index pls_integer;
7298 l_assoc_index pls_integer;
7299 i Pls_Integer;
7300 j Pls_Integer;
7301 -- Including variables for bug 1820961 begin
7302 l_first pls_integer;
7303 l_tot_qty OE_ORDER_LINES_ALL.ordered_quantity%TYPE;
7304 l_tot_price_qty OE_ORDER_LINES_ALL.pricing_quantity%TYPE;
7305 -- Including variables for bug 1820961 end
7306 l_found_discount_line boolean:=FALSE;
7307 -- This change is required since we are dropping the profile OE_ORGANIZATION -- _ID. Change made by Esha.
7308 l_org_id Number:= OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');
7309 E_CLOSED_PRG_LINE Exception;
7310 l_new_prg_created boolean := FALSE;
7311 Begin
7312 adj_debug('Entering oe_order_Adj_pvt.Process_Other_Item_Line',1);
7313 G_STMT_NO := 'Process_Other_Item_Line#10';
7314
7315 If p_Price_Adjustment_Id <> FND_API.G_MISS_NUM And
7316 p_Price_Adjustment_Id is not null Then
7317 -- The Adjustment Record for OID Adlready exits
7318 -- That Also means that the "Other Item Line" also exists in the order
7319 -- Find the "Other Item" Line and update the attributes
7320
7321 adj_debug('The PRG already exists '||p_Price_Adjustment_Id);
7322 -- First find the related Adjustment record
7323 i:= p_Line_Adj_Assoc_Tbl.First;
7324 -- making changes for bug 1820961 begin
7325 l_first := i;
7326 -- making changes for bug 1820961 end
7327 While i is not null loop
7328 Begin
7329 If p_Line_Adj_Assoc_Tbl(i).price_adjustment_id = p_Price_Adjustment_Id
7330 Then
7331 -- Get the Product ID Associated with the adjustment
7332 IF Match_Product_Ids(
7333 p_price_Adjustment_Id => p_Line_Adj_Assoc_Tbl(i).rltd_Price_Adj_Id,
7334 p_Line_Detail_Index => p_Line_Detail_Index,
7335 p_Req_line_detail_Attr_Tbl => p_Req_line_detail_Attr_Tbl
7336 ) Then
7337
7338 l_Match_Exists := True;
7339 -- Retain the Association Record
7340 G_STMT_NO := 'Process_Other_Item_Line#15';
7341
7342 -- Update The Adjustment Record of the "Other Item"
7343 -- bug 1843872, find whether the discount line is in memory
7344 j := p_line_adj_tbl.first;
7345 while j is not null loop
7346 if p_line_adj_tbl(j).price_adjustment_id
7347 = p_line_adj_assoc_tbl(i).rltd_price_adj_id THEN
7348 l_line_adj_rec := p_line_adj_tbl(j);
7349 l_found_discount_line := TRUE;
7350 exit;
7351 end if;
7352 j:=p_line_adj_tbl.next(j);
7353 end loop;
7354 IF NOT l_found_discount_line THEN
7355 OE_Line_Adj_Util.Query_Row
7356 (p_price_Adjustment_Id => p_Line_Adj_Assoc_Tbl(i).rltd_Price_Adj_Id
7357 , x_line_adj_rec => l_line_adj_rec);
7358 j:=p_line_adj_tbl.count+1;
7359 p_Line_Adj_Tbl(p_Line_Adj_Tbl.count+1) := l_Line_Adj_Rec;
7360 END IF;
7361
7362 p_Line_Adj_Assoc_Tbl.delete(i);
7363
7364 -- Bug 2270949
7365 IF (p_Rltd_line_details_prcd.exists(p_line_detail_index)
7366 and p_line_adj_tbl(p_Rltd_line_details_prcd(p_line_detail_index)).operation = OE_GLOBALS.G_OPR_CREATE) THEN
7367 adj_debug('2270949:replace '||p_Rltd_line_details_prcd(p_line_detail_index)||' with '||j);
7368 p_line_adj_tbl(p_Rltd_line_details_prcd(p_line_detail_index)).operation :=NULL;
7369 p_line_detail_replaced(p_Rltd_line_details_prcd(p_line_detail_index)) := j;
7370 End If;
7371
7372 p_Rltd_line_Details_prcd(p_Line_detail_Index) := j;
7373 -- End 2270949
7374
7375 If Update_Adj_Line_rec(
7376 p_Line_Adj_Rec => l_line_Adj_Rec
7377 ,p_req_line_detail_Rec => p_req_line_detail_Tbl(p_Line_Detail_Index)
7378 )
7379 Then
7380 -- There is a Change is the Adjsutment Record
7381 l_Line_Adj_Rec.operation := OE_GLOBALS.G_OPR_UPDATE;
7382 p_Line_Adj_Tbl(j) := l_Line_Adj_Rec;
7383 End If;
7384
7385 l_Req_Line_Index := p_req_line_detail_Tbl(p_Line_Detail_Index).Line_Index;
7386
7387 -- Check If this Related Line Has Already been processed in an earlier loop
7388 G_STMT_NO := 'Process_Other_Item_Line#18';
7389 -- 2270949
7390 If p_Rltd_lines_prcd.exists(l_Req_Line_Index) Then
7391 adj_debug('req line index'||l_Req_Line_Index||' '||p_Rltd_lines_prcd(l_Req_line_Index));
7392 adj_debug('operation:'||p_line_tbl(p_Rltd_lines_prcd(l_Req_line_index)).operation);
7393 if p_line_tbl(p_Rltd_lines_prcd(l_Req_Line_Index)).operation = OE_GLOBALS.G_OPR_CREATE THEN
7394 -- replace this line with the old line
7395 adj_debug('delete line'||p_rltd_lines_prcd(l_req_line_index));
7396 l_new_prg_created := TRUE;
7397
7398 End If;
7399 End If;
7400
7401 If l_new_prg_created OR NOT p_Rltd_lines_prcd.exists(l_Req_Line_Index) Then
7402 -- End 2270949
7403
7404 G_STMT_NO := 'Process_Other_Item_Line#20';
7405
7406 OE_Line_Util.Query_Row
7407 ( p_Line_id => l_line_Adj_Rec.Line_Id
7408 , x_line_rec => l_line_rec);
7409
7410 if l_line_rec.operation = FND_API.G_MISS_CHAR then
7411 l_line_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
7412 End If;
7413
7414 adj_debug(' GET line, line_id:'||l_line_rec.line_id);
7415 adj_debug(' GET line, open_flag:'||l_line_rec.open_flag);
7416
7417 --Do not process if open_flag set to 'N'
7418 --BT
7419 If l_line_rec.open_flag = 'N' Then
7420 Raise E_Closed_PRG_Line;
7421 End If;
7422
7423 --adj_debug('BCT!!!Adjusted_unit_price:'||p_req_line_tbl(l_Req_Line_Index).adjusted_unit_price);
7424 l_line_rec.unit_selling_price_per_pqty := p_req_line_tbl(l_Req_Line_Index).adjusted_unit_price ;
7425 l_line_rec.unit_list_price_per_pqty := p_req_line_tbl(l_Req_Line_Index).unit_price ;
7426 l_line_rec.unit_list_percent := p_req_line_tbl(l_Req_Line_Index).percent_price ;
7427 if nvl(p_req_line_tbl(l_Req_Line_Index).percent_price,0) <> 0 then
7428 l_line_rec.unit_selling_percent :=
7429 ( l_line_rec.unit_selling_price_per_pqty * l_line_rec.unit_list_percent)/
7430 p_req_line_tbl(l_Req_Line_Index).percent_price ;
7431 end if;
7432 adj_debug('populate change reason!!!',3);
7433
7434 -- For bug 1916585, cancellation needs reason
7435 IF (l_line_rec.change_reason IS NULL
7436 or l_line_rec.change_reason = fnd_api.g_miss_char) THEN
7437 l_line_rec.change_reason := 'SYSTEM';
7438 l_line_rec.change_comments := 'REPRICING';
7439 END IF;
7440 -- Code included for bug 1820961 begin
7441 -- header_id validation is added for the Bug 2215903
7442 if l_first = i then
7443 begin
7444 select nvl(sum(ordered_quantity),0),nvl(sum(pricing_quantity),0)
7445 into l_tot_qty,l_tot_price_qty
7446 from oe_order_lines
7447 where split_from_line_id = l_line_rec.line_id
7448 and header_id = l_line_rec.header_id;
7449 exception
7450 when others then
7451 null;
7452 end;
7453 l_line_rec.pricing_quantity :=
7454 p_req_line_tbl(l_req_line_index).priced_quantity - nvl(l_tot_price_qty,0);
7455 l_line_rec.ordered_quantity :=
7456 p_req_line_tbl(l_req_line_index).line_quantity - nvl(l_tot_qty,0);
7457 else
7458 l_line_rec.pricing_quantity :=
7459 p_req_line_tbl(l_Req_Line_Index).priced_quantity ;
7460 l_line_rec.ordered_quantity :=
7461 p_req_line_tbl(l_req_line_index).line_quantity;
7462 end if;
7463
7464
7465 l_line_rec.pricing_quantity_uom := p_req_line_tbl(l_Req_Line_Index).priced_uom_code ;
7466 l_line_rec.price_request_code := p_req_line_tbl(l_Req_Line_Index).price_request_code; -- PROMOTIONS SEP/01
7467
7468 --for bug 2412868 begin
7469 oe_debug_pub.add('bug 2412868 in update1:');
7470 if p_req_line_tbl(l_req_line_index).line_quantity < 0
7471 and ( p_req_line_tbl(l_req_line_index).line_category is null or
7472 p_req_line_tbl(l_req_line_index).line_category = 'ORDER'
7473 ) then
7474 l_line_rec.line_category_code := 'RETURN' ;
7475 l_line_rec.return_reason_code := 'RETURN' ;
7476 oe_debug_pub.add('bug 2412868 in update:');
7477 elsif p_req_line_tbl(l_req_line_index).line_category = 'RETURN'
7478 then
7479 l_line_rec.line_category_code := 'ORDER' ;
7480 end if;
7481 if l_line_rec.pricing_quantity < 0 and
7482 l_line_rec.ordered_quantity < 0 then
7483 l_line_rec.pricing_quantity :=
7484 abs(p_req_line_tbl(l_Req_Line_Index).priced_quantity);
7485 l_line_rec.ordered_quantity :=
7486 abs(p_req_line_tbl(l_req_line_index).line_quantity);
7487 end if;
7488 --for bug 2412868 end
7489 IF (l_new_prg_created) THEN
7490 p_Line_Tbl(p_Rltd_lines_prcd(l_Req_Line_Index)) := l_line_rec;
7491 Else
7492 p_Line_Tbl(p_Line_Tbl.last+1) := l_line_rec;
7493
7494 p_Rltd_lines_prcd(l_Req_Line_Index) := p_line_Tbl.last;
7495 -- p_Line_Tbl(p_Line_Tbl.count+1) := l_line_rec;
7496
7497 -- p_Rltd_lines_prcd(l_Req_Line_Index) := p_line_Tbl.count;
7498 End If;
7499
7500 End If; -- p_Rltd_lines_prcd
7501
7502 End If; -- Match Exists for Item
7503 End If;
7504
7505 Exception
7506 When E_Closed_PRG_Line Then
7507 oe_debug_pub.add(' PRG ignore, Closed line!');
7508 End; --End for the begin in 'FOR' loop
7509
7510 i:= p_Line_Adj_Assoc_Tbl.Next(i);
7511 End loop; -- Process Adjustments
7512 End If;
7513
7514 G_STMT_NO := 'Process_Other_Item_Line#30';
7515
7516 If Not l_Match_exists Then
7517
7518 adj_debug('There is no existing product match');
7519 l_Req_Line_Index := p_req_line_detail_Tbl(p_Line_Detail_Index).Line_Index;
7520
7521 -- Introduce New Order Line , Order Adjustments and Association Record
7522 --
7523 -- Check If this Related Line Has Already been processed in an earlier loop
7524 If Not p_Rltd_lines_prcd.exists(l_Req_Line_Index) Then
7525
7526 adj_debug('Creating a new line record for header '||P_Header_Id);
7527 l_line_rec:=OE_ORDER_PUB.G_MISS_LINE_REC;
7528 l_line_rec.operation := OE_GLOBALS.G_OPR_CREATE;
7529
7530 l_line_rec.Header_id := P_Header_Id;
7531 --for bug 2412868 Begin
7532 oe_debug_pub.add('b2412868:'||p_req_line_tbl(l_req_line_index).line_quantity);
7533 oe_debug_pub.add('b2412868:'||p_req_line_tbl(l_req_line_index).priced_quantity);
7534 if p_req_line_tbl(l_req_line_index).line_quantity < 0
7535 and
7536 ( p_req_line_tbl(l_req_line_index).line_category is null or
7537 p_req_line_tbl(l_req_line_index).line_category = 'ORDER'
7538 ) then
7539 l_line_rec.line_category_code := 'RETURN' ;
7540 l_line_rec.return_reason_code := 'RETURN' ;
7541 oe_debug_pub.add('bug 2412868 in if :');
7542 elsif p_req_line_tbl(l_req_line_index).line_category = 'RETURN' then
7543 l_line_rec.line_category_code := 'ORDER';
7544 end if;
7545 --for bug 2412868 end
7546 -- uom begin
7547 l_line_rec.unit_selling_price_per_pqty := p_req_line_tbl(l_Req_Line_Index).adjusted_unit_price ;
7548 l_line_rec.unit_list_price_per_pqty := p_req_line_tbl(l_Req_Line_Index).unit_price ;
7549 --for bug 2412868 begin
7550 if l_line_rec.unit_selling_price_per_pqty < 0
7551 --bug 2992310
7552 and p_req_line_tbl(l_req_line_index).line_quantity < 0 then
7553 l_line_rec.unit_selling_price_per_pqty :=
7554 abs(p_req_line_tbl(l_Req_Line_Index).adjusted_unit_price ) ;
7555 l_line_rec.unit_list_price_per_pqty :=
7556 abs(p_req_line_tbl(l_Req_Line_Index).unit_price );
7557 end if;
7558 --for bug 2412868 end
7559 -- uom end
7560 l_line_rec.unit_list_percent := p_req_line_tbl(l_Req_Line_Index).percent_price ;
7561 if nvl(p_req_line_tbl(l_Req_Line_Index).percent_price,0) <> 0 then
7562 l_line_rec.unit_selling_percent :=
7563 ( l_line_rec.unit_selling_price_per_pqty * l_line_rec.unit_list_percent)/
7564 p_req_line_tbl(l_Req_Line_Index).percent_price ;
7565 end if;
7566 l_line_rec.pricing_quantity := p_req_line_tbl(l_Req_Line_Index).priced_quantity ;
7567 l_line_rec.Ordered_Quantity := p_req_line_tbl(l_Req_Line_Index).priced_quantity ;
7568 --for bug 2412868 begin
7569 if l_line_rec.pricing_quantity < 0 and l_line_rec.Ordered_quantity < 0
7570 then
7571 l_line_rec.pricing_quantity := abs(l_line_rec.pricing_quantity);
7572 l_line_rec.ordered_quantity := abs(l_line_rec.ordered_quantity);
7573 end if;
7574 --for bug 2412868 end
7575 l_line_rec.pricing_quantity_uom := p_req_line_tbl(l_Req_Line_Index).priced_uom_code ;
7576 l_line_rec.price_request_code := p_req_line_tbl(l_Req_Line_Index).price_request_code;
7577
7578 --Why hardcode to INT ?
7579 l_line_rec.item_identifier_type := 'INT';
7580
7581 --This is a return, need to copy the return reason code from buy item
7582 If p_buy_line_rec.return_reason_code is Not Null Then
7583 l_line_rec.return_reason_code := p_buy_line_rec.return_reason_code;
7584 End If;
7585
7586 /* Fix for Bug 1805134
7587 Set the UOM for the new line created by PRG to be
7588 the same as defined in the modifer
7589 and NOT the base UOM
7590 */
7591
7592 oe_debug_pub.add('rlanka: setting ordered quantity UOM');
7593 oe_debug_pub.add('UOM = ' || p_req_line_tbl(l_Req_Line_Index).line_uom_code);
7594 l_line_rec.order_quantity_uom := p_req_line_tbl(l_Req_Line_Index).line_uom_code;
7595
7596 --end Bug 1805134
7597
7598 /*
7599 Fix for Bug 1729372 : Change calculate_price_flag to 'R'
7600 so that charges can be applied to the new line. This will be
7601 handled in OEXULINB.pls
7602 */
7603
7604 l_line_rec.calculate_price_flag := 'R';
7605 -- Create the new line in the same ship set as the parent line.
7606 l_line_rec.ship_set_id := p_line_tbl(p_parent_line_index).ship_set_id;
7607
7608 G_STMT_NO := 'Process_Other_Item_Line#35';
7609 i:= p_req_line_detail_Tbl.First;
7610 While i is not null loop
7611 If p_req_line_detail_Tbl(i).line_index = l_Req_Line_Index and
7612 (p_req_line_detail_Tbl(i).created_from_list_type_code = 'PRL' or
7613 p_req_line_detail_Tbl(i).created_from_list_type_code = 'AGR' or
7614 p_req_line_detail_Tbl(i).list_line_type_code = 'PLL')
7615 Then
7616
7617 l_line_rec.price_list_id := p_req_line_detail_Tbl(i).list_header_id;
7618
7619 exit;
7620
7621 End if;
7622 i:= p_req_line_detail_Tbl.next(i);
7623
7624 End loop;
7625
7626 G_STMT_NO := 'Process_Other_Item_Line#135';
7627 i:= p_Req_line_detail_Attr_Tbl.First;
7628 While i is not null loop
7629 if p_Req_line_detail_Attr_Tbl(i).line_detail_index = p_Line_Detail_Index and
7630 p_Req_line_detail_Attr_Tbl(i).Pricing_Context='ITEM' and
7631 p_Req_line_detail_Attr_Tbl(i).Pricing_attribute='PRICING_ATTRIBUTE1'
7632 Then
7633 adj_debug('The PRG item is '||p_Req_line_detail_Attr_Tbl(i).Pricing_Attr_Value_From);
7634 l_line_rec.Inventory_Item_id := p_Req_line_detail_Attr_Tbl(i).Pricing_Attr_Value_From ;
7635 G_STMT_NO := 'Process_Other_Item_Line#140';
7636 Begin
7637 SELECT concatenated_segments
7638 INTO l_line_rec.ordered_item
7639 FROM mtl_system_items_kfv
7640 WHERE inventory_item_id = l_line_rec.inventory_item_id
7641 AND organization_id = l_org_id;
7642 Exception when no_data_found then
7643 Null;
7644 End;
7645
7646
7647 Exit;
7648
7649 End If;
7650
7651 i := p_Req_line_detail_Attr_Tbl.next(i);
7652 End Loop;
7653
7654 p_Line_Tbl(p_Line_Tbl.last+1) := l_line_rec;
7655
7656 -- Display the PRG Item
7657 /* 2270949 : delay logging message
7658 FND_MESSAGE.SET_NAME('ONT','ONT_CREATED_NEW_LINE');
7659 FND_MESSAGE.SET_TOKEN('ITEM',l_line_rec.ordered_item);
7660 FND_MESSAGE.SET_TOKEN('QUANTITY',l_line_rec.Ordered_quantity);
7661 OE_MSG_PUB.Add('N');
7662 */
7663 adj_debug('inside price line: setting cascade');
7664
7665 p_Rltd_lines_prcd(l_Req_Line_Index) := p_line_Tbl.last;
7666
7667 End If; -- p_Rltd_lines_prcd
7668
7669
7670 -- Insert Adjustment Records
7671
7672 -- Check If this Related Adjustment Line Has Already been processed in an earlier loop
7673
7674 G_STMT_NO := 'Process_Other_Item_Line#40';
7675
7676 If Not p_Rltd_line_details_prcd.exists(p_Line_detail_Index) Then
7677
7678 l_Adj_Index := p_line_adj_Tbl.count+1;
7679 p_line_adj_tbl(l_adj_index) := OE_ORDER_PUB.G_MISS_LINE_ADJ_REC;
7680 p_line_adj_Tbl(l_Adj_Index).operation := OE_GLOBALS.G_OPR_CREATE;
7681
7682 adj_debug('Creating an adjustment record for PRG '||l_Adj_Index);
7683 If Update_Adj_Line_rec(
7684 p_Line_Adj_Rec => p_Line_Adj_Tbl(l_Adj_Index)
7685 ,p_req_line_detail_Rec => p_req_line_detail_Tbl(p_Line_Detail_Index)
7686 )
7687 Then
7688 p_line_adj_Tbl(l_Adj_Index).Updated_Flag := 'N';
7689 p_line_adj_Tbl(l_Adj_Index).Header_id := p_Header_Id;
7690 p_line_adj_Tbl(l_Adj_Index).Line_Index := p_Rltd_lines_prcd(l_Req_Line_Index);
7691 End If;
7692
7693 p_Rltd_line_Details_prcd(p_Line_detail_Index) := l_Adj_Index;
7694
7695 End If; -- p_Rltd_lines_prcd
7696
7697 G_STMT_NO := 'Process_Other_Item_Line#50';
7698 -- Process the Relationship recordS
7699
7700 /* Added following if condition for Bug2211670 */
7701 If p_Line_Adj_Assoc_tbl.Count > 0 Then
7702 l_assoc_index := p_Line_Adj_Assoc_tbl.last+1;
7703 Else
7704 l_assoc_index := 1;
7705 End If;
7706
7707 --Commented for Bug2211670
7708 -- l_assoc_index := p_Line_Adj_Assoc_tbl.count+1;
7709
7710 p_line_adj_assoc_tbl(l_assoc_index) := OE_ORDER_PUB.G_MISS_LINE_ADJ_ASSOC_REC;
7711 p_Line_Adj_Assoc_tbl(l_assoc_index).line_index := Null;
7712 p_Line_Adj_Assoc_tbl(l_assoc_index).Adj_Index := P_Parent_Adj_Index;
7713 p_Line_Adj_Assoc_tbl(l_assoc_index).Rltd_Adj_Index :=
7714 p_Rltd_line_Details_prcd(p_Line_detail_Index);
7715 p_Line_Adj_Assoc_tbl(l_assoc_index).Operation := OE_Globals.G_OPR_CREATE;
7716
7717 End If; -- Match_exists
7718
7719 adj_debug('Exiting oe_order_Adj_pvt.Process_Other_Item_Line',1);
7720
7721 End Process_Other_Item_Line;
7722
7723 Procedure Shell_Sort(p_sorted_tbl in out Nocopy oe_order_adj_pvt.sorted_adjustment_tbl_type) Is
7724 h PLS_INTEGER:=1;
7725 i PLS_INTEGER;
7726 j PLS_INTEGER;
7727 N PLS_INTEGER;
7728
7729 adj_rec oe_order_adj_pvt.Sorted_Adjustment_Rec_Type;
7730
7731 Begin
7732 N := p_sorted_tbl.count;
7733
7734 --DBMS_OUTPUT.PUT_LINE('Determining h step size...');
7735
7736 For k in 1..N Loop
7737 h:= h*3 + 1;
7738 exit when h*3 + 1 > N;
7739 End Loop;
7740
7741 --DBMS_OUTPUT.PUT_LINE('h: '||h);
7742
7743 For k in 1..h Loop
7744 --DBMS_OUTPUT.PUT_LINE('h2:'||h);
7745 i:= h + 1;
7746 For i in h+1..N Loop
7747 adj_rec := p_sorted_tbl(i);
7748 j:=i;
7749
7750 While ((j > h)
7751 and adj_rec.pricing_group_sequence IS NOT NULL
7752 and (p_sorted_tbl(j-h).pricing_group_sequence IS NULL OR
7753 p_sorted_tbl(j-h).pricing_group_sequence > adj_rec.pricing_group_sequence))
7754 Loop
7755 p_sorted_tbl(j) := p_sorted_tbl(j-h);
7756 j:=j-h;
7757 END Loop;
7758 p_sorted_tbl(j):=adj_rec;
7759 End Loop;
7760 h:= h/3;
7761 Exit When h < 1;
7762 End Loop;
7763
7764 End;
7765
7766 Procedure sort_on_pgs(
7767 p_Sorted_Tbl in out nocopy Oe_Order_Adj_Pvt.Sorted_Adjustment_Tbl_Type
7768 ,p_lo pls_integer
7769 ,p_hi pls_integer)
7770 is
7771 l_lo pls_integer := p_lo;
7772 l_hi pls_integer := p_hi;
7773 l_Sorted_Adjustment_Rec1 Oe_Order_Adj_Pvt.Sorted_Adjustment_Rec_Type;
7774 l_Sorted_Adjustment_Rec Oe_Order_Adj_Pvt.Sorted_Adjustment_Rec_Type;
7775 begin
7776 if p_lo >= p_hi Then
7777 Return;
7778 Elsif p_lo = p_hi -1 then
7779 if nvl(p_Sorted_Tbl(l_lo).pricing_group_sequence,-1) >
7780 nvl(p_Sorted_Tbl(l_hi).pricing_group_sequence,-1)
7781 Then
7782 l_Sorted_Adjustment_Rec1 := p_Sorted_Tbl(l_lo);
7783 p_Sorted_Tbl(l_lo) := p_Sorted_Tbl(l_hi);
7784 p_Sorted_Tbl(l_hi) := l_Sorted_Adjustment_Rec1;
7785 End If;
7786 Return;
7787 End If;
7788
7789 l_Sorted_Adjustment_Rec := p_Sorted_Tbl((l_lo+l_hi)/2);
7790 p_Sorted_Tbl((l_lo+l_hi)/2):= p_Sorted_Tbl(l_hi);
7791 p_Sorted_Tbl(l_hi) := l_Sorted_Adjustment_Rec;
7792
7793 While l_lo < l_hi loop
7794
7795 While nvl(p_Sorted_Tbl(l_lo).pricing_group_sequence,fnd_api.g_miss_num) <=
7796 nvl(l_Sorted_Adjustment_Rec.pricing_group_sequence,fnd_api.g_miss_num) and
7797 l_lo < l_hi loop
7798
7799 l_lo := l_lo+1;
7800 end loop;
7801
7802 While nvl(l_Sorted_Adjustment_Rec.pricing_group_sequence ,fnd_api.g_miss_num)<=
7803 nvl(p_Sorted_Tbl(l_hi).pricing_group_sequence,fnd_api.g_miss_num) and
7804 l_lo < l_hi loop
7805 l_hi := l_hi-1;
7806 end loop;
7807
7808 If l_lo < l_hi then
7809 l_Sorted_Adjustment_Rec1 := p_Sorted_Tbl(l_lo);
7810 p_Sorted_Tbl(l_lo) := p_Sorted_Tbl(l_hi);
7811 p_Sorted_Tbl(l_hi) := l_Sorted_Adjustment_Rec1;
7812 end if;
7813
7814 End loop;
7815
7816 p_Sorted_Tbl(p_hi) := p_Sorted_Tbl(l_hi);
7817 p_Sorted_Tbl(l_hi) := l_Sorted_Adjustment_Rec;
7818 l_lo := l_lo -1;
7819 l_hi := l_hi+1;
7820
7821 sort_on_pgs( p_Sorted_Tbl => p_Sorted_Tbl
7822 ,p_lo => p_lo
7823 ,p_hi => l_lo);
7824
7825 sort_on_pgs( p_Sorted_Tbl => p_Sorted_Tbl
7826 ,p_lo => l_hi
7827 ,p_hi => p_hi);
7828
7829 End sort_on_pgs;
7830
7831 Function find_updated_adjustments(
7832 p_header_id number default null
7833 ,p_Line_id number default null
7834 ,p_Line_Adj_Tbl oe_order_pub.line_adj_tbl_type
7835 )
7836 Return boolean
7837 is
7838 i pls_integer;
7839 begin
7840 i := p_Line_Adj_Tbl.first;
7841 while i is not null loop
7842 If ( p_Line_Adj_Tbl(i).line_id = p_Line_id or
7843 p_line_id is null and p_Line_Adj_Tbl(i).header_id = p_header_id ) and
7844 p_Line_Adj_Tbl(i).updated_flag = 'Y' and
7845 p_Line_Adj_Tbl(i).Applied_Flag = 'Y' then
7846 Return True; -- Atleast one adjustment has been updated
7847 end if;
7848 i := p_Line_Adj_Tbl.Next(i);
7849 end loop;
7850 Return False;
7851 end find_updated_adjustments;
7852
7853 Procedure Gsa_Check(
7854 p_header_id Number
7855 ,p_line_id Number
7856 ,p_inventory_item_id Varchar2 --bug 2673506
7857 ,p_pricing_date date
7858 ,p_request_type_code Varchar2
7859 ,p_unit_selling_price_per_pqty number
7860 ,p_gsa_violation_action Varchar2
7861 ,p_price_event1 Varchar2 default null --for bug 2273446
7862 )
7863 is
7864 l_hold_source_rec OE_Holds_Pvt.hold_source_rec_type;
7865 l_hold_release_rec OE_Holds_Pvt.Hold_Release_REC_Type;
7866 l_return_status varchar2(30);
7867 l_x_msg_count number;
7868 l_x_msg_data Varchar2(2000);
7869 l_x_result_out Varchar2(30);
7870 l_list_name varchar2(240);
7871 --for bug 2028480 Begin
7872 l_gsa_released varchar2(1):= 'N';
7873 --for bug 2028480 end
7874 l_operand number;
7875 l_msg_text Varchar2(200);
7876 l_org_id Number:= OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');
7877
7878 Cursor get_gsa_list_lines is
7879 Select/*+ ordered use_nl(qpq qppa qpll qplh) */ min(qpll.operand)
7880 From
7881 qp_qualifiers qpq
7882 , qp_pricing_attributes qppa
7883 , qp_list_lines qpll
7884 , qp_list_headers_b qplh
7885 , qp_price_req_sources qpprs
7886 where
7887 qpq.qualifier_context='CUSTOMER'
7888 and qpq.qualifier_attribute='QUALIFIER_ATTRIBUTE15'
7889 and qpq.qualifier_attr_value='Y'
7890 and qppa.list_header_id=qplh.list_header_id
7891 and qplh.Active_flag='Y'
7892 and qpprs.request_type_code = p_request_type_code
7893 and qpprs.source_system_code=qplh.source_system_code
7894 and qppa.pricing_phase_id = 2
7895 and qppa.qualification_ind = 6
7896 and qppa.product_attribute_context ='ITEM'
7897 and qppa.product_attribute='PRICING_ATTRIBUTE1'
7898 and qppa.product_attr_value= p_inventory_item_id
7899 and qppa.excluder_flag = 'N'
7900 and qppa.list_header_id=qpq.list_header_id
7901 and qppa.list_line_id=qpll.list_line_id
7902 and p_pricing_date between nvl(trunc(qplh.start_date_active),p_pricing_date)
7903 and nvl(trunc(qplh.End_date_active),p_pricing_date);
7904
7905
7906 Begin
7907
7908 G_STMT_NO := 'Gsa_Check#10';
7909 open get_gsa_list_lines;
7910 fetch get_gsa_list_lines into l_operand;
7911 close get_gsa_list_lines;
7912
7913 G_STMT_NO := 'Gsa_Check#20';
7914 if p_unit_selling_price_per_pqty <= l_operand then
7915 --Check if the GSA check needs to be done.
7916 If p_gsa_violation_action = 'WARNING' then
7917 Begin
7918 SELECT concatenated_segments
7919 INTO l_msg_text
7920 FROM mtl_system_items_kfv
7921 WHERE inventory_item_id = p_inventory_item_id
7922 AND organization_id = l_org_id;
7923 Exception when no_data_found then
7924 Null;
7925 End;
7926 if nvl(p_price_event1,'N') <> 'PRICE' then --bug 2273446
7927 FND_MESSAGE.SET_NAME('ONT','OE_GSA_VIOLATION');
7928 l_msg_text := l_operand||' ( '||l_msg_text||' )';
7929 FND_MESSAGE.SET_TOKEN('GSA_PRICE',l_msg_text);
7930 OE_MSG_PUB.Add;
7931 end if; --bug 2273446
7932
7933 Else
7934 G_STMT_NO := 'Gsa_Check#20.15';
7935 -- bug 1381660, duplicate holds with type_code='GSA'
7936 -- use the seeded hold_id
7937 l_hold_source_rec.hold_id := G_SEEDED_GSA_HOLD_ID;
7938 /*Begin
7939 Select hold_id into l_hold_source_rec.hold_id
7940 from oe_hold_definitions where type_code='GSA';
7941 Exception when no_data_found then
7942 FND_MESSAGE.SET_NAME('ONT','OE_PRICING_ERROR');
7943 FND_MESSAGE.SET_TOKEN('ERR_TEXT','Missing hold_definition for type_code GSA');
7944 OE_MSG_PUB.Add;
7945 adj_debug('Missing hold_definition for type_code GSA');
7946 End;*/
7947
7948 If p_line_id is null or
7949 p_line_id = fnd_api.g_miss_num then
7950 FND_MESSAGE.SET_NAME('ONT','OE_PRICING_ERROR');
7951 FND_MESSAGE.SET_TOKEN('ERR_TEXT','GSA_INVALID_LINE_ID');
7952 OE_MSG_PUB.Add;
7953 RAISE FND_API.G_EXC_ERROR;
7954 End if;
7955
7956 G_STMT_NO := 'Gsa_Check#20.20';
7957 l_hold_source_rec.hold_entity_id := p_header_id;
7958 l_hold_source_rec.header_id := p_header_id;
7959 l_hold_source_rec.line_id := p_line_id;
7960 l_hold_source_rec.Hold_Entity_code := 'O';
7961 --for bug 2028480 Begin
7962 --check if hold released earlier for this line , if so, do not go
7963 --thru the holds logic
7964 adj_debug('Hold Id :'||l_hold_source_rec.hold_id);
7965 Begin
7966 --changed select below to fix bug 3039915
7967 select 'Y' into l_gsa_released from
7968 oe_order_holds ooh,oe_hold_sources ohs,oe_hold_releases ohr
7969 where ooh.line_id = p_line_id
7970 and ooh.hold_source_id = ohs.hold_source_id
7971 and ohr.hold_release_id = ooh.hold_release_id
7972 and ohs.hold_id = l_hold_source_rec.hold_id
7973 and ohr.created_by <> 1
7974 and ohr.release_reason_code <> 'PASS_GSA';
7975 exception
7976 when others then
7977 l_gsa_released := 'N';
7978 end;
7979 adj_debug('GSA released value :'||l_gsa_released);
7980 --for bug 2028480 end
7981 if l_gsa_released = 'N' then --for bug 2028480
7982 -- check if line already on gsa hold, place hold if not
7983 OE_Holds_Pub.Check_Holds(
7984 p_api_version => 1.0
7985 ,p_header_id => p_header_id
7986 ,p_line_id => p_line_id
7987 ,p_hold_id => l_hold_source_rec.Hold_id
7988 ,x_return_status => l_return_status
7989 ,x_msg_count => l_x_msg_count
7990 ,x_msg_data => l_x_msg_data
7991 ,x_result_out => l_x_result_out
7992 );
7993
7994 If l_x_result_out = FND_API.G_FALSE then
7995 adj_debug('hold line with header_id:'||p_header_id||' line_id: '||p_line_id,1);
7996 OE_HOLDS_PUB.Apply_Holds(
7997 p_api_version => 1.0
7998 ,p_hold_source_rec => l_hold_source_rec
7999 ,x_return_status => l_return_status
8000 ,x_msg_count => l_x_msg_count
8001 ,x_msg_data => l_x_msg_data
8002 );
8003
8004 If l_return_status = FND_API.g_ret_sts_success then
8005 if nvl(p_price_event1,'N') <> 'PRICE' then --bug 2273446
8006
8007 FND_MESSAGE.SET_NAME('ONT','OE_GSA_HOLD_APPLIED');
8008 OE_MSG_PUB.Add;
8009 end if; --bug 2273446
8010 Else
8011 FND_MESSAGE.SET_NAME('ONT','OE_PRICING_ERROR');
8012 FND_MESSAGE.SET_TOKEN('ERR_TEXT','APPLY_GSA_HOLD');
8013 OE_MSG_PUB.Add;
8014 RAISE FND_API.G_EXC_ERROR;
8015 End If;
8016 End If; /* check hold */
8017 End If; --for bug 2028480 end
8018 End if; /* violation action */
8019
8020 Else -- Check if a hold was placed before , release the hold
8021 If p_line_id is not null and
8022 p_line_id <> fnd_api.g_miss_num then
8023
8024 If l_hold_source_rec.hold_id is null or
8025 l_hold_source_rec.hold_id = fnd_api.g_miss_num then
8026 G_STMT_NO := 'Gsa_Check#20.25';
8027 -- bug 1381660, duplicate holds with type_code='GSA'
8028 -- use the seeded hold_id
8029 l_hold_source_rec.hold_id := G_SEEDED_GSA_HOLD_ID;
8030 /*Begin
8031 Select hold_id into l_hold_source_rec.hold_id
8032 from oe_hold_definitions where type_code='GSA';
8033 Exception when no_data_found then
8034 FND_MESSAGE.SET_NAME('ONT','OE_PRICING_ERROR');
8035 FND_MESSAGE.SET_TOKEN('ERR_TEXT','Missing hold_definition for type_code GSA');
8036 OE_MSG_PUB.Add;
8037 adj_debug('Missing hold_definition for type_code GSA');
8038 End;*/
8039
8040 End if; -- Hold id
8041 G_STMT_NO := 'Gsa_Check#20.30';
8042
8043 l_hold_source_rec.hold_entity_id := p_header_id;
8044 l_hold_source_rec.header_id := p_header_id;
8045 l_hold_source_rec.line_id := p_line_id;
8046 l_hold_source_rec.Hold_Entity_code := 'O';
8047
8048
8049 OE_Holds_Pub.Check_Holds(
8050 p_api_version => 1.0
8051 ,p_header_id => p_header_id
8052 ,p_line_id => p_line_id
8053 ,p_hold_id => l_hold_source_rec.Hold_id
8054 ,x_return_status => l_return_status
8055 ,x_msg_count => l_x_msg_count
8056 ,x_msg_data => l_x_msg_data
8057 ,x_result_out => l_x_result_out
8058 );
8059
8060
8061 If l_x_result_out = FND_API.G_TRUE then
8062 -- Hold is found , Release the hold.
8063
8064 G_STMT_NO := 'Gsa_Check#20.35';
8065 l_hold_release_rec.release_reason_code :='PASS_GSA';
8066 --for bug 3039915 set created_by = 1 to indicate automatic hold release
8067 l_hold_release_rec.created_by := 1;
8068
8069 OE_Holds_Pub.Release_Holds(
8070 p_api_version => 1.0
8071 -- ,p_hold_id => l_hold_source_rec.Hold_id
8072 -- ,p_entity_code => l_hold_source_rec.Hold_entity_code
8073 -- ,p_entity_id => l_hold_source_rec.Hold_entity_id
8074 ,p_hold_source_rec => l_hold_source_rec
8075 ,p_hold_release_rec => l_hold_release_rec
8076 ,x_return_status => l_return_status
8077 ,x_msg_count => l_x_msg_count
8078 ,x_msg_data => l_x_msg_data
8079 );
8080
8081 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
8082 adj_debug('Error while releasing GSA Hold');
8083 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8084 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
8085 adj_debug('Error while releasing GSA Hold');
8086 RAISE FND_API.G_EXC_ERROR;
8087 END IF;
8088 End if; -- Release Hold
8089
8090 End if; -- GSA Check Hold
8091
8092 End If; -- GSA Violation
8093
8094
8095 End Gsa_Check;
8096
8097 Procedure CAlculate_Adjusted_Price(
8098 p_bucketed_price Number
8099 ,p_line_category Varchar2
8100 ,p_arithmetic_operator Varchar2
8101 ,p_operand Number
8102 ,p_Pricing_Quantity Number
8103 ,p_rounding_Factor Number
8104 ,p_modifier_level_code Varchar2 := NULL
8105 ,p_group_value Number := NULL
8106 ,x_Adjusted_Amount out nocopy NUMBER
8107
8108 )
8109 Is
8110 Begin
8111 adj_debug('Entering oe_order_Adj_pvt.CAlculate_Adjusted_Price');
8112 If p_arithmetic_operator = 'AMT' Then
8113 x_Adjusted_Amount := p_operand;
8114 Elsif p_arithmetic_operator = '%' then
8115 --bug 2764291
8116 x_Adjusted_Amount := abs(p_bucketed_price) *p_operand /100;
8117 Elsif p_arithmetic_operator = 'NEWPRICE' Then
8118 x_Adjusted_Amount := - p_bucketed_price + p_operand;
8119
8120 Elsif p_arithmetic_operator = 'LUMPSUM' then
8121 --
8122 IF (p_modifier_level_code = QP_PREQ_GRP.G_LINE_GROUP) THEN
8123 --
8124 -- p_modifier_level_code = 'LINEGROUP'
8125 --
8126 adj_debug('LINEGROUP');
8127 IF nvl(p_group_value,0) <> 0 THEN
8128 x_Adjusted_Amount := p_operand / p_group_value;
8129 adj_debug('p_group_value');
8130 ELSE
8131 --x_Adjusted_Amount := p_operand;
8132 x_adjusted_amount:=0;
8133 adj_debug('p_group_value is 0');
8134 END IF;
8135 ELSE
8136 If nvl(p_Pricing_Quantity,0) <> 0 then
8137 x_Adjusted_Amount := p_operand / p_Pricing_Quantity;
8138 Else
8139 x_Adjusted_Amount := p_operand;
8140 END IF;
8141 End IF;
8142 End If;
8143
8144
8145 adj_debug('Exiting oe_order_Adj_pvt.CAlculate_Adjusted_Price');
8146
8147 end CAlculate_Adjusted_Price;
8148
8149 Procedure Calculate_Price (
8150 p_Header_Rec Oe_Order_Pub.Header_Rec_Type
8151 ,p_Line_Tbl in out nocopy Oe_Order_Pub.Line_Tbl_Type
8152 ,p_Line_Adj_Tbl in out nocopy Oe_Order_Pub.Line_Adj_Tbl_Type
8153 ,p_line_adj_assoc_Tbl Oe_Order_Pub.line_adj_assoc_Tbl_Type
8154 ,p_allow_Negative_Price Varchar2
8155 ,p_request_Type_Code Varchar2
8156 ,p_any_line_frozen Boolean default False
8157 ,p_price_event Varchar2 default null --for bug 2273446
8158 ,p_honor_price_flag Varchar2 default 'Y' --bug 2503186
8159 )
8160 is
8161 lx_return_status varchar2(1) := FND_API.G_RET_STS_SUCCESS;
8162 lx_return_status_Text varchar2(240) ;
8163 l_discount_surcharge Boolean;
8164 i pls_integer;
8165 J pls_integer;
8166 J1 pls_integer;
8167 J2 pls_integer;
8168 l_Bucketed_price Number;
8169 l_pricing_group_sequence Number := fnd_api.g_miss_num;
8170 l_Total_Quantity Number;
8171 l_sign Number;
8172 l_rounding_factor Number;
8173 l_gsa_violation_action Varchar2(30); --moac moving the initialization to the body
8174 l_GSA_Enabled_Flag Varchar2(30) := FND_PROFILE.VALUE('QP_VERIFY_GSA');
8175 l_Sorted_Adjustment_Tbl oe_order_Adj_pvt.Sorted_Adjustment_Tbl_Type;
8176 l_Sort_Index Pls_Integer;
8177 l_pricing_quantity Number;
8178 l_assoc_exist Boolean;
8179 l_adjusted_amt_changed Boolean;
8180 -- for bug 1717501 Begin
8181 l_gsa_cust_check varchar2(1);
8182 -- for bug 1717501 end
8183 l_status_code Varchar2(5);
8184
8185 l_item_rec OE_ORDER_CACHE.item_rec_type; -- OPM 2547940
8186 l_process Boolean; -- OPM 2547940
8187
8188 Begin
8189
8190 adj_debug('Entering oe_order_Adj_pvt.Calculate_Price');
8191
8192 --moac
8193 l_gsa_violation_action := oe_sys_parameters.value('ONT_GSA_VIOLATION_ACTION',p_header_rec.org_id);
8194
8195 --OE_Order_Pub.G_HDR := p_header_rec;
8196
8197 G_STMT_NO := 'Calculate_Price#05';
8198 i := p_Line_Adj_Tbl.First;
8199
8200 While i is not null loop
8201 l_Sorted_Adjustment_Tbl(i).Adj_Index := i;
8202 l_Sorted_Adjustment_Tbl(i).pricing_group_sequence := p_Line_Adj_Tbl(i).pricing_group_sequence;
8203 i := p_Line_Adj_Tbl.Next(i);
8204 End Loop;
8205
8206 shell_sort(p_Sorted_Tbl => l_Sorted_Adjustment_Tbl);
8207
8208 G_STMT_NO := 'Calculate_Price#10';
8209 i:= p_Line_Tbl.First;
8210 adj_debug('Honor Price flag :'||p_honor_price_flag,2);
8211 While i is not null Loop
8212 l_process := -- INVCONV oe_line_util.Process_Characteristics -- OPM 2547940
8213 oe_line_util.dual_uom_control -- INVCONV
8214 (p_line_tbl(i).inventory_item_id
8215 ,p_line_tbl(i).ship_from_org_id
8216 ,l_item_rec);
8217
8218 If p_line_tbl(i).calculate_price_flag in ('Y','P')
8219 OR (p_price_event is NULL and
8220 p_line_tbl(i).operation = oe_globals.G_OPR_UPDATE)
8221 OR p_honor_price_flag = 'N' --bug 2503186
8222 OR -- OPM 2547940 start - for copy of order OR split from shipping - need to re-price as these lines
8223 -- as may have freeze price for calulate price flag when pricing by quantity2
8224 (
8225 ( l_process)
8226 and (l_item_rec.ont_pricing_qty_source = 1 ) -- price by quantity 2
8227 and ( p_line_tbl(i).calculate_price_flag In ('N','P') )
8228 and ( p_line_tbl(i).split_by is not null )
8229 and ( p_line_tbl(i).split_from_line_id is not null and p_line_tbl(i).split_from_line_id <> FND_API.G_MISS_NUM)
8230 ) -- OPM 2547940 end
8231
8232
8233 Then
8234 adj_debug('Processing Line id '||p_line_tbl(i).line_id,2);
8235
8236 If p_Line_Tbl(i).operation in (oe_globals.g_opr_delete, oe_globals.g_opr_lock) or
8237 (p_Line_Tbl(i).Unit_list_price is null
8238 and p_Line_Tbl(i).Unit_list_price_per_pqty is null)
8239 Then
8240 adj_debug('Line '||p_line_tbl(i).line_id||' price is not calculated');
8241 adj_debug(' Unit_list_price:'||p_Line_Tbl(i).Unit_list_price);
8242 adj_debug(' Unit_list_price_per_pqty:'||p_Line_Tbl(i).Unit_list_price_per_pqty);
8243 adj_debug(' Line opr '||p_Line_Tbl(i).operation);
8244 Else
8245
8246
8247 adj_debug('selling price before ..'||p_Line_Tbl(i).Unit_Selling_Price_Per_Pqty);
8248
8249 --For backward compatiblity, to correct the old data
8250 If nvl(p_Line_Tbl(i).unit_list_price_Per_Pqty,FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM and
8251 p_Line_Tbl(i).unit_list_price is Not Null Then
8252 If nvl(p_line_tbl(i).pricing_quantity,0) <> 0 and
8253 p_line_tbl(i).pricing_quantity <> FND_API.G_MISS_NUM
8254 Then
8255 p_line_tbl(i).unit_list_price_per_pqty :=(p_line_tbl(i).unit_list_price * p_line_tbl(i).ordered_quantity)/p_line_tbl(i).pricing_quantity;
8256 Else
8257 p_Line_Tbl(i).unit_list_price_Per_Pqty := p_Line_Tbl(i).unit_list_price;
8258 End If;
8259 End If;
8260
8261 If nvl(p_Line_Tbl(i).unit_selling_price_per_pqty,FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM and
8262 p_Line_Tbl(i).unit_selling_price Is Not Null Then
8263 If nvl(p_line_tbl(i).pricing_quantity,0) <> 0 and
8264 p_line_tbl(i).pricing_quantity <> FND_API.G_MISS_NUM
8265 Then
8266 p_line_tbl(i).unit_selling_price_per_pqty :=(p_Line_Tbl(i).unit_selling_price * p_line_tbl(i).ordered_quantity)/p_line_tbl(i).pricing_quantity;
8267 Else
8268 p_Line_Tbl(i).unit_selling_price_per_pqty := p_Line_Tbl(i).unit_selling_price;
8269 End If;
8270 End If;
8271
8272 -- uom begin
8273 p_line_tbl(i).Unit_Selling_Price_Per_Pqty := p_Line_Tbl(i).unit_list_price_Per_Pqty;
8274 l_bucketed_price := p_line_Tbl(i).unit_list_price_per_pqty;
8275 -- uom end
8276
8277 l_pricing_group_sequence := fnd_api.g_miss_num;
8278
8279
8280 adj_debug('No of adjs in Calculate_Price '||p_Line_Adj_Tbl.count);
8281 l_Sort_Index:= l_Sorted_Adjustment_Tbl.First;
8282 While l_Sort_Index is not null Loop
8283
8284 J := l_Sorted_Adjustment_Tbl(l_Sort_Index).Adj_Index;
8285 l_adjusted_amt_changed := FALSE;
8286 oe_debug_pub.add(' Sorted index value:'||J);
8287 G_STMT_NO := 'Calculate_Price#20';
8288
8289 If ( p_Line_Adj_Tbl(j).Line_Index = i or
8290 (p_Line_Adj_Tbl(j).line_id = p_Line_Tbl(i).line_id and
8291 p_Line_Adj_Tbl(j).line_id <> fnd_api.g_miss_num
8292 )or
8293 ( ( p_Line_Adj_Tbl(j).line_id is null or
8294 p_Line_Adj_Tbl(j).line_id = fnd_api.g_miss_num ) and
8295 (p_Line_Adj_Tbl(j).line_index is null or
8296 p_Line_Adj_Tbl(j).line_index = fnd_api.g_miss_num) and
8297 p_Line_Adj_Tbl(j).Header_Id = p_header_Rec.Header_Id
8298 )) and -- Header Level Adjustments
8299 p_Line_Adj_Tbl(j).Operation <> OE_Globals.G_OPR_DELETE and
8300 nvl(p_Line_Adj_Tbl(j).applied_flag,'N')='Y' and
8301 /* Modified the nvl to 'N' in the above statement to fix the bug 2164508 */
8302 p_Line_Adj_Tbl(j).list_line_type_code in ('DIS','SUR','FREIGHT_CHARGE','PBH')
8303 then
8304
8305 --adj_debug('BCT+fullfilled calculate');
8306 If p_Line_Adj_Tbl(j).pricing_group_sequence is null then
8307 If nvl(p_line_Tbl(i).unit_list_price_per_pqty,FND_API.G_MISS_NUM)
8308 <> FND_API.G_MISS_NUM
8309 Then
8310 l_bucketed_price := p_line_Tbl(i).unit_list_price_per_pqty;
8311 Else
8312 l_bucketed_price := p_line_Tbl(i).unit_list_price;
8313 End If;
8314 Elsif p_Line_Adj_Tbl(j).pricing_group_sequence <> l_pricing_group_sequence then
8315 If nvl(p_line_Tbl(i).unit_selling_price_per_pqty,FND_API.G_MISS_NUM)
8316 <> FND_API.G_MISS_NUM
8317 Then
8318 l_bucketed_price := p_line_Tbl(i).unit_selling_price_per_pqty;
8319 Else
8320 l_bucketed_price := p_line_Tbl(i).unit_selling_price;
8321 End If;
8322 End If;
8323
8324 If p_Line_Adj_Tbl(j).List_line_type_code = 'PBH' Then
8325
8326 adj_debug('First Time Adj Amount: ' || p_Line_Adj_Tbl(j).Adjusted_Amount_Per_Pqty,3);
8327 --reset adj amount for parent PBH.
8328 --will be recalculated.
8329 If p_line_adj_tbl(j).price_break_type_code = QP_PREQ_GRP.G_RANGE_BREAK Then
8330 p_Line_Adj_Tbl(j).adjusted_amount_per_pqty:=0;
8331 End If;
8332 oe_debug_pub.add('xNo of assoc in assoc_tbl:'|| p_line_adj_assoc_Tbl.count);
8333 J1 := p_line_adj_assoc_Tbl.First;
8334 l_Total_Quantity := 0;
8335 l_assoc_exist := FALSE;
8336 While J1 is not null loop
8337 If ( (p_line_adj_assoc_Tbl(j1).Adj_index = J Or
8338 (p_line_adj_assoc_Tbl(j1).Price_adjustment_id =
8339 p_Line_Adj_Tbl(j).Price_Adjustment_id and
8340 p_Line_Adj_Tbl(j).Price_Adjustment_id <> fnd_api.g_miss_num )) and (nvl(p_line_adj_assoc_Tbl(j1).operation,'xxyz') <> OE_GLOBALS.G_OPR_DELETE)
8341 ) Then
8342 l_assoc_exist := TRUE;
8343 p_Line_Adj_Tbl(j).Adjusted_Amount_Per_Pqty := 0;
8344 l_adjusted_amt_changed := TRUE;
8345 End If;
8346 J1 := p_line_adj_assoc_Tbl.Next(J1);
8347 End Loop;
8348
8349 If (p_Line_Adj_Tbl(j).Adjusted_Amount_Per_Pqty <> 0 and l_assoc_exist = FALSE) Then
8350 adj_debug('Adjusted Amount pqty : ' || nvl(p_line_adj_tbl(j).adjusted_amount_per_pqty,0));
8351 adj_debug('adjusted amount :'||p_line_adj_tbl(j).adjusted_amount);
8352 adj_debug('Unit Selling Price #100 : ' || nvl(p_line_tbl(i).Unit_Selling_Price,0));
8353
8354
8355 p_line_tbl(i).Unit_Selling_Price_Per_Pqty :=
8356 p_line_tbl(i).Unit_Selling_Price_Per_Pqty + nvl(p_Line_Adj_Tbl(j).Adjusted_Amount_Per_Pqty,0);
8357 p_Line_Adj_Tbl(j).Adjusted_Amount_Per_Pqty := 0;
8358 l_adjusted_amt_changed := TRUE;
8359 End If;
8360
8361 J1 := p_line_adj_assoc_Tbl.First;
8362 G_STMT_NO := 'Calculate_Price#30';
8363
8364 adj_debug('Calculate_Price: PBH Line ('||j||')'||
8365 p_Line_Adj_Tbl(j).price_adjustment_id,2);
8366 adj_debug('PBH Adjustment ('||j||')'||
8367 p_Line_Adj_Tbl(j).adjusted_amount_per_pqty,2);
8368 While J1 is not null loop
8369 If ( (p_line_adj_assoc_Tbl(j1).Adj_index = J Or
8370 (p_line_adj_assoc_Tbl(j1).Price_adjustment_id =
8371 p_Line_Adj_Tbl(j).Price_Adjustment_id and
8372 p_Line_Adj_Tbl(j).Price_Adjustment_id <> fnd_api.g_miss_num )) And (nvl(p_line_adj_assoc_Tbl(j1).operation,'xxyz') <> OE_GLOBALS.G_OPR_DELETE)
8373
8374 ) Then
8375
8376 adj_debug('Got an association Rltd_index '||p_line_adj_assoc_Tbl(j1).Rltd_Adj_index,2);
8377 adj_debug('line_adj_assoc_operation:'||p_line_adj_assoc_Tbl(j1).operation);
8378 -- Get the Related Adj Line
8379 J2 := p_Line_Adj_Tbl.First;
8380
8381 G_STMT_NO := 'Calculate_Price#40';
8382 While J2 is not null loop
8383 If ( p_line_adj_assoc_Tbl(j1).Rltd_Adj_index = J2 Or
8384 ( p_line_adj_assoc_Tbl(j1).Rltd_Price_Adj_Id =
8385 p_Line_Adj_Tbl(j2).Price_adjustment_id and
8386 p_line_adj_assoc_Tbl(j1).Rltd_Price_Adj_Id <> fnd_api.g_miss_num )
8387 ) and
8388 p_Line_Adj_Tbl(j2).Range_Break_Quantity > 0 and
8389 p_Line_Adj_Tbl(j2).list_line_type_code in ('DIS','SUR','FREIGHT_CHARGE')
8390 Then
8391
8392 adj_debug(j2||')The Child line is '||p_Line_Adj_Tbl(j2).list_line_type_code,2);
8393 adj_debug('List line id '||p_Line_Adj_Tbl(j2).list_line_id,2);
8394 adj_debug('Pricing Qty #150 '||p_Line_Tbl(i).pricing_quantity,2);
8395 adj_debug('Range Break Qty #151 '||p_Line_adj_Tbl(j2).range_break_quantity,2);
8396
8397 If p_Line_Adj_Tbl(j2).list_line_type_code in ('DIS','SUR') Then
8398 l_discount_surcharge := TRUE;
8399 Else
8400 l_discount_surcharge := FALSE;
8401 End If;
8402 If p_Line_Adj_Tbl(j2).list_line_type_code = 'DIS'
8403 AND p_Line_Adj_Tbl(j2).arithmetic_operator <> 'NEWPRICE' Then
8404 l_sign := -1;
8405 Else
8406 l_sign := +1;
8407 End If;
8408
8409 IF p_Line_Adj_Tbl(j2).updated_flag = 'Y' and p_Line_Adj_Tbl(j).updated_flag <> 'Y' THEN
8410 p_Line_Adj_Tbl(j).updated_flag := 'Y';
8411 p_Line_Adj_Tbl(j).change_reason_code := p_Line_Adj_Tbl(J2).change_reason_code;
8412 p_Line_Adj_Tbl(j).change_reason_text := p_Line_Adj_Tbl(J2).change_reason_text;
8413
8414 END IF;
8415
8416 G_STMT_NO := 'Calculate_Price#50';
8417
8418 If p_Line_Adj_Tbl(j).Price_break_Type_Code = QP_PREQ_GRP.G_RANGE_BREAK Then
8419 l_pricing_quantity := p_line_adj_tbl(j2).Range_Break_Quantity;
8420
8421 Else
8422 l_pricing_quantity := p_line_tbl(i).pricing_quantity;
8423 End If;
8424
8425 If p_Line_Adj_Tbl(j2).Operand_per_pqty is Null Then
8426 p_Line_Adj_Tbl(j2).Operand_per_pqty := p_Line_Adj_Tbl(j2).Operand;
8427 End If;
8428
8429 /* Added for the bug#2647485 */
8430 IF (
8431 --p_line_adj_tbl(j).list_line_type_code <> 'FREIGHT_CHARGE' AND ** Commented for bug#3594917 **
8432 p_line_tbl(i).calculate_price_flag = 'P' AND
8433 p_line_tbl(i).line_category_code = 'RETURN' AND
8434 p_Line_Adj_Tbl(j2).Arithmetic_operator = 'LUMPSUM' ) THEN
8435 NULL;
8436 ELSE
8437 --For bug 2874499.
8438 If (p_Line_Adj_Tbl(j2).Arithmetic_operator = 'LUMPSUM'
8439 and p_line_adj_tbl(j2).modifier_level_code = QP_PREQ_GRP.G_LINE_GROUP and
8440 p_line_adj_tbl(j2).automatic_flag = 'N')then
8441 p_line_adj_tbl(j2).group_value := 1;
8442 end if ;
8443 CAlculate_Adjusted_Price(
8444 p_bucketed_price=> l_bucketed_price,
8445 p_line_category=> p_line_tbl(i).line_category_code,
8446 p_arithmetic_operator=> p_Line_Adj_Tbl(j2).Arithmetic_operator,
8447 p_operand => l_sign*p_Line_Adj_Tbl(j2).Operand_per_pqty,
8448 p_Pricing_Quantity=> l_pricing_quantity,
8449 p_rounding_Factor=> l_rounding_FActor,
8450 p_modifier_level_code => p_line_adj_tbl(j2).modifier_level_code,
8451 p_group_value => p_line_adj_tbl(j2).group_value,
8452 x_Adjusted_Amount=> p_Line_Adj_Tbl(j2).Adjusted_Amount_Per_Pqty
8453 );
8454 END IF;
8455
8456 G_STMT_NO := 'Calculate_Price#60';
8457 If p_Line_Adj_Tbl(j).Price_break_Type_Code = QP_PREQ_GRP.G_RANGE_BREAK Then
8458 If nvl(p_Line_Adj_Tbl(j).Adjusted_Amount_Per_Pqty,FND_API.G_MISS_NUM)=FND_API.G_MISS_NUM Then
8459 p_Line_Adj_Tbl(j).Adjusted_Amount_Per_Pqty:=0;
8460 End If;
8461
8462 p_Line_Adj_Tbl(j).Adjusted_Amount_Per_Pqty :=
8463 p_Line_Adj_Tbl(j).Adjusted_Amount_Per_Pqty +
8464 p_Line_Adj_Tbl(j2).Adjusted_Amount_Per_Pqty * p_Line_Adj_Tbl(j2).Range_break_Quantity;
8465 l_adjusted_amt_changed := TRUE;
8466 l_total_Quantity := l_total_Quantity + p_Line_Adj_Tbl(j2).Range_break_Quantity;
8467
8468 oe_debug_pub.add(' Rounding adj list line ty:'|| p_Line_Adj_Tbl(j).list_line_type_code);
8469 oe_debug_pub.add(' Rounding adj list line id:'||p_Line_Adj_Tbl(j).list_line_id);
8470 oe_debug_pub.add(' Rounding adj operand:'||p_Line_Adj_Tbl(j).operand);
8471
8472 Else
8473 p_Line_Adj_Tbl(j).Adjusted_Amount_Per_Pqty := p_Line_Adj_Tbl(j2).Adjusted_Amount_Per_Pqty;
8474 l_adjusted_amt_changed := TRUE;
8475 End If; -- Break Type
8476
8477 adj_debug('Adj Amount '||p_Line_Adj_Tbl(j).Adjusted_Amount_Per_Pqty,2);
8478
8479 End If; -- Rltd Lines ( Child lines for PBH )
8480
8481 J2:= p_Line_Adj_Tbl.Next(J2);
8482
8483 End Loop; -- J2
8484
8485 End If; -- J1 if
8486 J1 := p_line_adj_assoc_Tbl.Next(J1);
8487 End loop; -- J1
8488
8489 If p_Line_Adj_Tbl(j).Price_Break_Type_Code = QP_PREQ_GRP.G_RANGE_BREAK Then
8490 oe_debug_pub.add('xAdj_amt_pqty:'||p_line_adj_tbl(j).adjusted_amount_per_pqty);
8491 if p_line_adj_tbl(j).range_break_quantity is null and l_total_quantity > 0
8492 then --bug 2813670
8493 oe_debug_pub.add('Value of l_tot_qty :'||l_total_quantity);
8494 p_line_adj_tbl(j).adjusted_amount_per_pqty :=
8495 p_line_adj_tbl(j).adjusted_amount_per_pqty/l_total_quantity;
8496 else
8497 p_line_adj_tbl(j).adjusted_amount_per_pqty :=
8498 p_line_adj_tbl(j).adjusted_amount_per_pqty/p_line_adj_tbl(j).range_break_quantity;
8499 end if;
8500 oe_debug_pub.add('xRange break qty:'||p_line_adj_tbl(j).range_break_quantity);
8501
8502 oe_debug_pub.add('xFinal Range break adj amt:'||p_line_adj_tbl(j).adjusted_amount_per_pqty);
8503 End If;
8504
8505 If p_Line_Adj_Tbl(j).operand is not null Then
8506 QP_UTIL_PUB.round_price
8507 (p_operand => p_Line_Adj_Tbl(j).adjusted_amount_per_pqty,
8508 p_rounding_factor => NULL,
8509 p_use_multi_currency => 'Y',
8510 p_price_list_id => p_line_tbl(i).price_list_id,
8511 p_currency_code => g_order_currency,
8512 p_pricing_effective_date => p_line_tbl(i).pricing_date,
8513 x_rounded_operand => p_Line_Adj_Tbl(j).adjusted_amount_per_pqty,
8514 x_status_code => l_status_code,
8515 p_operand_type => 'A'
8516 );
8517 Else
8518 p_Line_Adj_Tbl(j).adjusted_amount_per_pqty:=nvl(p_Line_Adj_Tbl(j).adjusted_amount_per_pqty,0);
8519 p_Line_Adj_Tbl(j).operand:=0;
8520 End if;
8521
8522
8523 Else -- Not a Price Break Line
8524
8525 G_STMT_NO := 'Calculate_Price#80';
8526 If p_Line_Adj_Tbl(j).list_line_type_code in ('DIS','SUR') Then
8527 l_discount_surcharge := TRUE;
8528 Else
8529 l_discount_surcharge := FALSE;
8530 End If;
8531 If p_Line_Adj_Tbl(j).list_line_type_code = 'DIS'
8532 AND p_Line_Adj_Tbl(j).arithmetic_operator <> 'NEWPRICE' Then
8533 l_sign := -1;
8534 Else
8535 l_sign := +1;
8536 End If;
8537
8538 G_STMT_NO := 'Calculate_Price#90';
8539
8540 adj_debug(j||')Line Index '||p_Line_Adj_Tbl(j).line_index,3);
8541 adj_debug('Operand '||p_Line_Adj_Tbl(j).operand_per_pqty,3);
8542 adj_debug('Arithmetic op '||p_Line_Adj_Tbl(j).Arithmetic_operator,3);
8543 adj_debug('Pricing Quantity '||p_line_tbl(i).Pricing_Quantity,3);
8544 adj_debug('Bucketed price '||l_bucketed_price,3);
8545 adj_debug('-----------------',3);
8546
8547 /* Added for the bug#2647485 */
8548 IF (
8549 --p_line_adj_tbl(j).list_line_type_code <> 'FREIGHT_CHARGE' AND ** Commented for bug#3594917 **
8550 p_line_tbl(i).calculate_price_flag = 'P' AND
8551 p_line_tbl(i).line_category_code = 'RETURN' AND
8552 p_Line_Adj_Tbl(j).Arithmetic_operator = 'LUMPSUM' ) THEN
8553
8554 p_Line_Adj_Tbl(j).operand := p_line_tbl(i).Ordered_Quantity
8555 * p_Line_Adj_Tbl(j).Adjusted_Amount
8556 * l_sign;
8557 p_Line_Adj_Tbl(j).operand_per_pqty := NULL;
8558
8559 ELSE
8560 --For bug 2874499.
8561 If (p_Line_Adj_Tbl(j).Arithmetic_operator = 'LUMPSUM'
8562 and p_line_adj_tbl(j).modifier_level_code = QP_PREQ_GRP.G_LINE_GROUP and
8563 p_line_adj_tbl(j).automatic_flag = 'N')then
8564 p_line_adj_tbl(j).group_value := 1;
8565 end if ;
8566
8567 CAlculate_Adjusted_Price(
8568 p_bucketed_price => l_bucketed_price,
8569 p_line_category=> p_line_tbl(i).line_category_code,
8570 p_arithmetic_operator => p_Line_Adj_Tbl(j).Arithmetic_operator,
8571 p_operand => l_sign*p_Line_Adj_Tbl(j).Operand_per_pqty,
8572 p_Pricing_Quantity => p_line_tbl(i).pricing_quantity,
8573 p_rounding_Factor => l_rounding_FActor,
8574 p_modifier_level_code => p_line_adj_tbl(j).modifier_level_code,
8575 p_group_value => p_line_adj_tbl(j).group_value,
8576 --p_price_list_id => p_line_tbl(i).price_list_id,
8577 --p_pricing_effecitve_date => p_line_tbl(i).pricing_date,
8578 x_Adjusted_Amount => p_Line_Adj_Tbl(j).Adjusted_Amount_Per_Pqty
8579 );
8580 END IF;
8581 l_adjusted_amt_changed := TRUE;
8582
8583 adj_debug('+Adjusted_Amount pqty '||p_Line_Adj_Tbl(j).Adjusted_Amount_Per_Pqty,2);
8584 adj_debug('+Adjusted_Amount '||p_Line_Adj_Tbl(j).Adjusted_Amount,2);
8585
8586 If p_Line_Adj_Tbl(j).operand is not null Then
8587 --commenting call to round price to fix bug 3043251
8588 /* QP_UTIL_PUB.round_price
8589 (p_operand => p_Line_Adj_Tbl(j).adjusted_amount_per_pqty,
8590 p_rounding_factor => NULL,
8591 p_use_multi_currency => 'Y',
8592 p_price_list_id => p_line_tbl(i).price_list_id,
8593 p_currency_code => g_order_currency,
8594 p_pricing_effective_date => p_line_tbl(i).pricing_date,
8595 x_rounded_operand => p_Line_Adj_Tbl(j).adjusted_amount_per_pqty,
8596 x_status_code => l_status_code,
8597 p_operand_type => 'A'
8598 ); */
8599 NULL;
8600 Else
8601 p_Line_Adj_Tbl(j).adjusted_amount_per_pqty:=nvl(p_Line_Adj_Tbl(j).adjusted_amount_per_pqty,0);
8602 p_Line_Adj_Tbl(j).operand:=0;
8603 End if;
8604
8605 End If; -- Check list line type for price break
8606
8607 G_STMT_NO := 'Calculate_Price#100';
8608 If l_discount_surcharge and nvl(p_Line_Adj_Tbl(j).Accrual_Flag,'N') <> 'Y'
8609 then -- Do not Add Freight charges to the selling price
8610 adj_debug('Adjusted Amount : ' || nvl(p_line_adj_tbl(j).adjusted_amount_per_pqty,0),3);
8611 adj_debug('Unit Selling Price #100 : ' || nvl(p_line_tbl(i).Unit_Selling_Price_Per_Pqty,0),3);
8612 p_line_tbl(i).Unit_Selling_Price_Per_Pqty := p_line_tbl(i).Unit_Selling_Price_Per_Pqty + nvl(p_Line_Adj_Tbl(j).Adjusted_Amount_Per_Pqty,0);
8613 End If;
8614
8615 l_pricing_group_sequence := p_Line_Adj_Tbl(j).pricing_group_sequence;
8616 End If; -- Adj Lines
8617 If (l_adjusted_amt_changed AND p_Line_Adj_Tbl(j).operation = FND_API.G_MISS_CHAR) Then
8618
8619 If not (p_any_line_frozen and p_line_adj_tbl(j).modifier_level_code = 'ORDER') Then
8620 adj_debug('Calculate Price:'||p_Line_Adj_Tbl(j).list_line_id);
8621 If p_Line_Adj_Tbl(j).updated_flag = 'N' Then
8622 p_Line_Adj_Tbl(j).operation := OE_GLOBALS.G_OPR_UPDATE;
8623 End If;
8624 End If;
8625 End If;
8626 l_Sort_Index:= l_Sorted_Adjustment_Tbl.Next(l_Sort_Index);
8627
8628 -- uom begin
8629 If p_line_adj_tbl(j).arithmetic_operator IN ('AMT','NEWPRICE') Then
8630 --bsadri fixed zero division error for cancelled lines
8631 IF NVL(p_line_tbl(i).ordered_quantity,0) <> 0 AND
8632 p_line_tbl(i).ordered_quantity <> fnd_api.g_miss_num THEN
8633 p_Line_Adj_Tbl(j).operand := p_Line_Adj_tbl(j).operand_per_pqty * p_line_tbl(i).pricing_quantity/p_line_tbl(i).ordered_quantity;
8634 END IF;
8635
8636 -- OPM 2547940 start - if pricing by quantity2 then if line is shipped and has shipped qty2 != ordered qty2
8637 -- need to adjust the operand so that invoicing will show correct amount (ordered qty * USP (adjusted) )
8638 IF oe_line_util.dual_uom_control -- INVCONV
8639 -- Process_Characteristics invconv
8640 (p_line_tbl(i).inventory_item_id
8641 ,p_line_tbl(i).ship_from_org_id
8642 ,l_item_rec) THEN
8643 oe_debug_pub.add('OPM - this IS a process line in proc calculate_price in OEXVADJB.pls ');
8644 IF l_item_rec.ont_pricing_qty_source = 'S' THEN -- price by quantity 2 INVCONV
8645
8646 IF (p_line_tbl(i).ordered_quantity2 IS NOT NULL and p_line_tbl(i).ordered_quantity2 <> 0 )
8647 AND ( p_line_tbl(i).shipped_quantity2 IS NOT NULL and p_line_tbl(i).shipped_quantity2 <> 0 )
8648 AND (p_line_tbl(i).ordered_quantity2 <> p_line_tbl(i).shipped_quantity2) THEN
8649 oe_debug_pub.add('OPM Updating operand ' ,5);
8650 p_Line_Adj_Tbl(j).operand := (p_Line_Adj_tbl(j).operand_per_pqty* p_line_tbl(i).pricing_quantity )/p_line_tbl(i).ordered_quantity2
8651 * (p_line_tbl(i).shipped_quantity2/p_line_tbl(i).ordered_quantity);
8652 oe_debug_pub.ADD('OPM NEW operand : '|| to_char(p_Line_Adj_Tbl(j).operand),5);
8653 END IF;
8654 END IF;
8655 END IF; --oe_line_util.dual_uom_control -- INVCONV
8656 -- OPM 2547940 end
8657
8658
8659 Else
8660 --for the % discount and lumpsum there is no difference
8661 p_line_adj_tbl(j).operand := p_Line_Adj_tbl(j).operand_per_pqty;
8662 End If;
8663
8664 IF NVL(p_line_tbl(i).ordered_quantity,0) <> 0 AND
8665 p_line_tbl(i).ordered_quantity <> FND_API.G_MISS_NUM THEN
8666
8667 IF ( p_line_adj_tbl(j).modifier_level_code = 'ORDER'
8668 and p_line_adj_tbl(j).list_line_type_code = 'FREIGHT_CHARGE'
8669 and p_line_adj_tbl(j).arithmetic_operator = 'LUMPSUM') THEN /* bug 1915846 */
8670
8671 p_line_adj_tbl(j).adjusted_amount := p_line_adj_tbl(j).adjusted_amount_per_pqty;
8672
8673 ELSE /* bug 1915846 */
8674 If p_Line_Adj_Tbl(j).line_id = p_line_tbl(i).line_id Then
8675 p_Line_Adj_Tbl(j).adjusted_amount := p_Line_Adj_tbl(j).adjusted_amount_per_pqty * p_line_tbl(i).pricing_quantity/p_line_tbl(i).ordered_quantity;
8676
8677 -- OPM 2547940 start - if pricing by quantity2 then if line is shipped and has shipped qty2 != ordered qty2
8678 -- need to adjust the adjusted_amount so that invoicing will show correct amount (ordered qty * USP (adjusted) )
8679
8680 IF oe_line_util.dual_uom_control -- INVCONV PROCESS_CHAR
8681
8682 (p_line_tbl(i).inventory_item_id
8683 ,p_line_tbl(i).ship_from_org_id
8684 ,l_item_rec) THEN
8685 IF l_item_rec.ont_pricing_qty_source = 'S' THEN -- price by quantity 2 -- INVCONV
8686
8687 IF (p_line_tbl(i).ordered_quantity2 IS NOT NULL and p_line_tbl(i).ordered_quantity2 <> 0 )
8688 AND ( p_line_tbl(i).shipped_quantity2 IS NOT NULL and p_line_tbl(i).shipped_quantity2 <> 0 )
8689 AND p_line_tbl(i).ordered_quantity2 <> p_line_tbl(i).shipped_quantity2 THEN
8690 oe_debug_pub.add('OPM Updating adjusted amount ' ,5);
8691 p_Line_Adj_Tbl(j).adjusted_amount := (p_Line_Adj_tbl(j).adjusted_amount_per_pqty* p_line_tbl(i).pricing_quantity )/p_line_tbl(i).ordered_quantity2
8692 * (p_line_tbl(i).shipped_quantity2/p_line_tbl(i).ordered_quantity);
8693 END IF;
8694 END IF;
8695 END IF; --oe_line_util.dual_uom_control -- INVCONV
8696 -- OPM 2547940 end
8697
8698
8699 If G_DEBUG Then
8700 oe_debug_pub.add(' p_line_tbl(i).line_id:'||i||' '||p_line_tbl(i).line_id);
8701 oe_debug_pub.add(' p_line_tbl(i).pricing_quantity:'||i||': '||p_line_tbl(i).pricing_quantity);
8702 oe_debug_pub.add(' p_line_tbl(i).ordered_quantity:'||i||': '||p_line_tbl(i).ordered_quantity);
8703 oe_debug_pub.add(' p_Line_Adj_Tbl(j).adjusted_amount:'||j||': '|| p_Line_Adj_Tbl(j).adjusted_amount);
8704 oe_debug_pub.add(' p_line_adj_tbl(j).list_line_id:'||j||': '||p_line_adj_tbl(j).list_line_id);
8705 oe_debug_pub.add(' p_line_adj_tbl(j).adjusted_amount_per_pqty:'||p_line_adj_tbl(j).adjusted_amount_per_pqty);
8706 End If;
8707 End If;
8708
8709 END IF;
8710
8711
8712 END IF;
8713 -- uom end
8714 IF nvl(p_line_adj_tbl(j).adjusted_amount_per_pqty,0) <> 0 Then
8715 QP_UTIL_PUB.round_price
8716 (p_operand => p_Line_Adj_Tbl(j).adjusted_amount_per_pqty,
8717 p_rounding_factor => NULL,
8718 p_use_multi_currency => 'Y',
8719 p_price_list_id => p_line_tbl(i).price_list_id,
8720 p_currency_code => g_order_currency,
8721 p_pricing_effective_date => p_line_tbl(i).pricing_date,
8722 x_rounded_operand => p_Line_Adj_Tbl(j).adjusted_amount_per_pqty,
8723 x_status_code => l_status_code,
8724 p_operand_type => 'A'
8725 );
8726
8727 END If;
8728
8729 IF nvl(p_line_adj_tbl(j).adjusted_amount,0) <> 0 Then
8730 QP_UTIL_PUB.round_price
8731 (p_operand => p_Line_Adj_Tbl(j).adjusted_amount,
8732 p_rounding_factor => NULL,
8733 p_use_multi_currency => 'Y',
8734 p_price_list_id => p_line_tbl(i).price_list_id,
8735 p_currency_code => g_order_currency,
8736 p_pricing_effective_date => p_line_tbl(i).pricing_date,
8737 x_rounded_operand => p_Line_Adj_Tbl(j).adjusted_amount,
8738 x_status_code => l_status_code,
8739 p_operand_type => 'A'
8740 );
8741
8742 END If;
8743
8744 End Loop; -- Adj Lines
8745
8746 G_STMT_NO := 'Calculate_Price#200';
8747 -- Do GSA Check
8748
8749 If l_gsa_enabled_flag = 'Y' Then
8750 -- for bug 1717501 begin
8751 --Added condition to check item type code for bug 2693025
8752 l_gsa_cust_check := oe_gsa_util.check_gsa_indicator(p_line_tbl(i));
8753 if l_gsa_cust_check = 'N'
8754 and p_line_tbl(i).item_type_code not in ('INCLUDED','CONFIG')
8755 then
8756 Gsa_Check(
8757 p_header_id => p_line_tbl(i).header_id
8758 ,p_line_id => p_line_tbl(i).line_id
8759 ,p_inventory_item_id => to_char(p_line_tbl(i).inventory_item_id) --bug 2673506
8760 ,p_pricing_date => p_line_tbl(i).pricing_date
8761 ,p_request_type_code => p_request_type_code
8762 ,p_unit_selling_price_per_pqty => p_line_tbl(i).unit_selling_price_per_pqty
8763 ,p_gsa_violation_action => l_gsa_violation_action
8764 ,p_price_event1 => p_price_event --bug 2273446
8765 );
8766 end if;
8767 End If;
8768
8769 -- DO Negative price Check
8770
8771 If p_line_tbl(i).unit_selling_price_per_pqty < 0 And
8772 p_allow_negative_price = 'N' then
8773
8774 adj_debug('Negative list price '||p_line_tbl(i).unit_List_price_per_pqty ||
8775 'Or selling price '||p_line_tbl(i).Unit_Selling_price_per_pqty);
8776 FND_MESSAGE.SET_NAME('ONT','ONT_NEGATIVE_PRICE');
8777 FND_MESSAGE.SET_TOKEN('ITEM',p_line_tbl(i).Ordered_Item);
8778 FND_MESSAGE.SET_TOKEN('LIST_PRICE',p_line_tbl(i).unit_List_price_per_pqty);
8779 FND_MESSAGE.SET_TOKEN('SELLING_PRICE',p_line_tbl(i).Unit_Selling_price_per_pqty);
8780 OE_MSG_PUB.Add;
8781 FND_MESSAGE.SET_NAME('ONT','ONT_NEGATIVE_MODIFIERS');
8782 FND_MESSAGE.SET_TOKEN('LIST_LINE_NO',get_list_lines(p_line_tbl(i).line_id));
8783 OE_MSG_PUB.ADD;
8784
8785 RAISE FND_API.G_EXC_ERROR;
8786
8787 End If; -- Negative Price
8788
8789 End If ; -- Of lines.operation in update or create
8790 adj_debug('selling price after ..'||p_Line_Tbl(i).Unit_Selling_Price_Per_Pqty);
8791 End If; --calculate price flag in ('Y','P');
8792 I := p_Line_Tbl.Next(I);
8793 End Loop; -- Lines
8794
8795 adj_debug('Exiting oe_order_Adj_pvt.Calculate_Price');
8796
8797 End Calculate_Price;
8798
8799 Function Get_unit_precision(p_header_id number)
8800 return Number
8801 is
8802 l_currency_code varchar2(30) := 'USD';
8803 l_precision Number;
8804 l_ext_precision number;
8805 l_min_acct_unit number;
8806 begin
8807 begin
8808 select nvl(transactional_curr_code,'USD') into l_currency_code from oe_order_headers
8809 where header_id=p_header_id;
8810 exception when no_data_found then
8811 l_currency_code := 'USD';
8812 end ;
8813
8814 FND_CURRENCY.Get_Info(l_currency_code, -- IN variable
8815 l_precision,
8816 l_ext_precision,
8817 l_min_acct_unit);
8818
8819 if fnd_profile.value('OE_UNIT_PRICE_PRECISION_TYPE') = 'STANDARD' then
8820 return l_precision;
8821 else
8822 return l_ext_precision;
8823 end if;
8824
8825 end Get_unit_precision;
8826
8827
8828 /* Bug 1503357
8829 Order no longer qualifies for PRG modifier. Either delete (or) update
8830 the free goods lines, depending on whether they are shipped or not
8831 */
8832 PROCEDURE change_prg_lines(p_price_adjustment_id IN NUMBER,
8833 p_line_tbl IN OUT NoCopy OE_Order_PUB.Line_Tbl_Type,
8834 p_line_adj_tbl IN OUT NoCopy OE_Order_PUB.Line_Adj_Tbl_Type,
8835 p_delete_prg_lines IN OUT NoCopy index_tbl_type) IS
8836
8837 Cursor prg_lines is
8838 Select radj.line_id
8839 from oe_price_adjustments radj,
8840 oe_price_adj_assocs assoc
8841 where radj.price_adjustment_id =assoc.rltd_price_adj_id and
8842 assoc.price_adjustment_id = p_price_adjustment_id;
8843
8844 Cursor ph_ids IS
8845 Select pricing_phase_id
8846 from qp_event_phases
8847 where pricing_event_code like 'BOOK';
8848
8849 l_prg_line_id NUMBER;
8850 l_found_prg_line BOOLEAN;
8851 l_match_phase_id BOOLEAN := FALSE;
8852 l_line_rec OE_ORDER_PUB.line_rec_type;
8853 l_phase_id NUMBER;
8854 pricing_ph_id NUMBER;
8855 j PLS_INTEGER;
8856 l_return_status VARCHAR2(30);
8857 l_replaced BOOLEAN := FALSE;
8858 l_pricing_event varchar2(30);
8859
8860 Begin
8861 adj_debug('Entering VADJB.CHANGE_PRG_LINES');
8862 adj_debug('price_adjustment_id = ' || p_price_adjustment_id);
8863 begin
8864 select pricing_phase_id
8865 into pricing_ph_id
8866 from oe_price_adjustments
8867 where price_adjustment_id = p_price_adjustment_id;
8868 exception when no_data_found Then
8869 adj_debug('No pricing phase id for this price adjustment');
8870 pricing_ph_id := NULL;
8871 end;
8872
8873 --Determine if modifier is in Book phase
8874 if (pricing_ph_id is not NULL) Then
8875 OPEN ph_ids;
8876 FETCH ph_ids into l_phase_id;
8877 WHILE ph_ids%FOUND Loop
8878 if (l_phase_id = pricing_ph_id) Then
8879 l_match_phase_id := TRUE;
8880 exit;
8881 end if;
8882 FETCH ph_ids into l_phase_id;
8883 End Loop;
8884 End if;
8885 CLOSE ph_ids;
8886
8887 OPEN prg_lines;
8888 FETCH prg_lines into l_prg_line_id;
8889 while prg_lines%FOUND Loop
8890 adj_debug('PRG Line id = ' || l_prg_line_id);
8891
8892 IF (l_prg_line_id is not NULL) THEN
8893 l_found_prg_line := FALSE;
8894 j := p_line_tbl.first;
8895 while j is not null Loop
8896 if (p_line_tbl(j).line_id = l_prg_line_id) Then
8897 adj_debug('found prg line '||l_prg_line_id);
8898 l_line_rec := p_line_tbl(j);
8899 l_found_prg_line := TRUE;
8900 exit;
8901 end if;
8902 j := p_line_tbl.next(j);
8903 End Loop;
8904 END IF;
8905
8906 IF NOT l_found_prg_line then
8907 adj_debug('PRG not in p_line_tbl, so query for line '||l_prg_line_id);
8908 OE_Line_Util.Query_Row(p_Line_id => l_prg_line_id,
8909 x_line_rec => l_line_rec);
8910 END IF;
8911
8912 if (l_line_rec.booked_flag <> 'Y' OR
8913 l_line_rec.booked_flag is NULL) Then
8914 adj_debug('Order not booked');
8915 l_line_rec.operation := OE_GLOBALS.G_OPR_DELETE;
8916 p_delete_prg_lines(l_line_rec.line_id) := l_line_rec.line_id;
8917 else
8918 l_line_rec.change_reason := 'SYSTEM';
8919 l_line_rec.change_comments := 'REPRICING';
8920 if (l_line_rec.shipped_quantity is NULL) Then
8921 adj_debug('Booked order, line not shipped');
8922 l_line_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
8923 l_line_rec.ordered_quantity := 0;
8924 l_line_rec.pricing_quantity := 0;
8925 p_delete_prg_lines(l_line_rec.line_id) := l_line_rec.line_id;
8926 else
8927 adj_debug('Booked order, shipped line');
8928 l_line_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
8929 l_line_rec.calculate_price_flag := 'Y';
8930 adj_debug('logging delayed request to price line');
8931 l_pricing_event := 'BATCH'; --2442012
8932 /* OE_delayed_requests_Pvt.log_request(
8933 p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
8934 p_entity_id => l_line_rec.line_id,
8935 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
8936 p_requesting_entity_id => l_line_rec.line_id,
8937 p_request_unique_key1 => 'BATCH',
8938 p_param1 => l_line_rec.header_id,
8939 p_param2 => 'BATCH',
8940 p_request_type => OE_GLOBALS.G_PRICE_LINE,
8941 x_return_status => l_return_status);
8942 */
8943 if (l_match_phase_id) Then
8944 -- modifier in BOOK phase
8945 l_pricing_event := 'BATCH,BOOK';
8946 end if;
8947 OE_delayed_requests_Pvt.log_request(
8948 p_entity_code =>OE_GLOBALS.G_ENTITY_ALL,
8949 p_entity_id => l_line_rec.line_Id,
8950 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
8951 p_requesting_entity_id => l_line_rec.line_Id,
8952 p_request_unique_key1 => l_pricing_event,
8953 p_param1 => l_line_rec.header_id,
8954 p_param2 => l_pricing_event,
8955 p_request_type => OE_GLOBALS.G_PRICE_LINE,
8956 x_return_status => l_return_status);
8957 --2442012 end if;
8958 end if;
8959 end if;
8960
8961 -- Now replace/append this record in p_line_tbl
8962 if (l_found_prg_line) Then
8963 adj_debug('Replacing line in p_line_tbl ' || l_line_rec.line_id);
8964 p_line_tbl(j) := l_line_rec;
8965 else
8966 adj_debug('Appended to p_line_tbl ' || l_line_rec.line_id);
8967 p_line_tbl(p_line_tbl.last+1) := l_line_rec;
8968 end if;
8969
8970 FETCH prg_lines into l_prg_line_id;
8971 End Loop;
8972
8973 CLOSE prg_lines;
8974 adj_debug('Exiting VADJB.CHANGE_PRG_LINES');
8975
8976 End change_prg_lines;
8977
8978
8979
8980 procedure process_adjustments
8981 (
8982 p_request_type_code varchar2,
8983 x_return_status out nocopy Varchar2,
8984
8985 p_Req_Control_Rec QP_PREQ_GRP.Control_record_type,
8986 p_req_line_tbl QP_PREQ_GRP.line_tbl_type,
8987 p_Req_qual_tbl QP_PREQ_GRP.qual_tbl_type,
8988 p_Req_line_attr_tbl QP_PREQ_GRP.line_attr_tbl_type,
8989 p_Req_Line_Detail_tbl QP_PREQ_GRP.line_detail_tbl_type,
8990 p_Req_Line_Detail_Qual_tbl QP_PREQ_GRP.line_detail_qual_tbl_type,
8991 p_Req_Line_Detail_Attr_tbl QP_PREQ_GRP.line_detail_attr_tbl_type,
8992 p_Req_related_lines_tbl QP_PREQ_GRP.related_lines_tbl_type
8993 ,p_write_to_db Boolean
8994 ,p_any_frozen_line in Boolean
8995 ,x_line_Tbl in out nocopy oe_Order_Pub.Line_Tbl_Type
8996 ,p_header_rec oe_Order_Pub.header_rec_type
8997 ,p_multiple_events in Varchar2 Default 'N'
8998 ,p_honor_price_flag in Varchar2 Default 'Y' --bug 2503186
8999 )
9000 is
9001 l_Req_Line_Detail_qual_Rec QP_PREQ_GRP.line_detail_qual_rec_type;
9002 l_Req_Line_Detail_attr_Rec QP_PREQ_GRP.line_detail_attr_rec_type;
9003 l_req_line_rec qp_preq_grp.line_rec_type;
9004 l_control_rec Oe_Globals.Control_rec_type;
9005 l_header_rec oe_Order_Pub.header_rec_type := p_header_rec;
9006 --l_old_line_rec oe_order_pub.line_rec_type;
9007 l_line_rec oe_order_pub.line_rec_type;
9008 l_old_line_tbl OE_Order_PUB.Line_Tbl_Type;
9009 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
9010 l_line_tbl_Final OE_Order_PUB.Line_Tbl_Type;
9011 l_Line_Adj_rec OE_Order_PUB.Line_Adj_Rec_Type;
9012 l_Line_Adj_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
9013 l_Line_Adj_Att_Rec OE_Order_PUB.Line_Adj_Att_Rec_type;
9014 l_Line_Adj_Att_tbl OE_Order_PUB.Line_Adj_Att_tbl_type;
9015 l_Line_Adj_Assoc_Rec OE_Order_PUB.Line_Adj_Assoc_Rec_type;
9016 l_Line_Adj_Assoc_tbl OE_Order_PUB.Line_Adj_Assoc_tbl_type;
9017 --l_x_header_rec OE_Order_PUB.Header_Rec_Type;
9018 l_x_Header_Adj_tbl OE_Order_PUB.Header_Adj_Tbl_Type;
9019 l_x_Header_Scredit_tbl OE_Order_PUB.Header_Scredit_Tbl_Type;
9020 --l_x_line_tbl OE_Order_PUB.Line_Tbl_Type;
9021 --l_x_Line_Adj_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
9022 l_x_Line_Scredit_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
9023 l_x_action_request_tbl OE_Order_PUB.request_tbl_type;
9024 l_x_lot_serial_tbl OE_Order_PUB.lot_serial_tbl_type;
9025 l_x_Header_price_Att_tbl OE_Order_PUB.Header_price_Att_tbl_type;
9026 l_x_Header_Adj_Att_tbl OE_Order_PUB.Header_Adj_Att_tbl_type;
9027 l_x_Header_Adj_Assoc_tbl OE_Order_PUB.Header_Adj_Assoc_tbl_type;
9028 l_x_Line_price_Att_tbl OE_Order_PUB.Line_price_Att_tbl_type;
9029 --l_x_Line_Adj_Att_tbl OE_Order_PUB.Line_Adj_Att_tbl_type;
9030 --l_x_Line_Adj_Assoc_tbl OE_Order_PUB.Line_Adj_Assoc_tbl_type;
9031 l_x_msg_count number;
9032 l_x_msg_data Varchar2(2000);
9033 l_x_result_out Varchar2(30);
9034 l_line_details_prcd Index_Tbl_Type;
9035 l_Rltd_lines_prcd Index_Tbl_Type;
9036 l_Rltd_line_details_prcd Index_Tbl_Type;
9037 l_lines_prcd Index_Tbl_Type;
9038 l_index pls_Integer;
9039 l_Adj_index pls_Integer;
9040 l_assoc_index pls_Integer;
9041 i pls_Integer;
9042 j pls_Integer;
9043 k pls_Integer;
9044 l pls_Integer;
9045 l_line_term Boolean := FALSE;
9046 l_price_list Varchar2(240);
9047 l_price_adjustment_id number;
9048 l_allow_negative_price Varchar2(30) := nvl(fnd_profile.value('ONT_NEGATIVE_PRICING'),'N');
9049 l_return_status varchar2(30);
9050 l_index NUMBER;
9051 l_request_id NUMBER;
9052 --btea perf begin
9053 l_header_key_tbl key_tbl_type;
9054 l_line_key_tbl key_tbl_type;
9055 --btea perf end
9056 l_updated_flag varchar2(1);
9057 -- Added by JAUTOMO on 20-DEC-00 (bug# 1303352)
9058 v_discounting_privilege VARCHAR2(30);
9059 -- Added by JAUTOMO on 10-APR-01
9060 l_item_type_code VARCHAR2(30);
9061 v_order_enforce_list_price varchar2(1):=NULL;
9062 v_line_enforce_list_price varchar2(1);
9063 l_invalid_line Varchar2(1):= 'N';
9064 --Manual begin
9065 l_preinsert_manual_adj VARCHAR2(1):= Nvl(Fnd_Profile.Value('ONT_PREINSERT_MANUAL_ADJ'),'N');
9066 --Manual end
9067 l_dummy_line_rec Oe_Order_Pub.Line_Rec_Type;
9068 l_limit_hold_action varchar2(30):=NVL(fnd_profile.value('ONT_PROMOTION_LIMIT_VIOLATION_ACTION'), 'NO_HOLD'); -- PROMOTIONS SEP/01
9069
9070 /* Promotional modifier issues - Bug 1503357 */
9071 l_delete_prg_lines index_tbl_type;
9072 l_num_changed_lines PLS_INTEGER := 0;
9073
9074 l_status_code Varchar2(5);
9075 l_line_detail_replaced Index_Tbl_Type;
9076
9077 l_item_rec OE_ORDER_CACHE.item_rec_type; -- OPM 2547940
9078 l_process Boolean; -- OPM 2547940
9079
9080 --
9081 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
9082 --
9083 l_order_source_id NUMBER;
9084 l_orig_sys_document_ref VARCHAR2(50);
9085 l_orig_sys_line_ref VARCHAR2(50);
9086 l_orig_sys_shipment_ref VARCHAR2(50);
9087 l_change_sequence VARCHAR2(50);
9088 l_source_document_type_id NUMBER;
9089 l_source_document_id NUMBER;
9090 l_source_document_line_id NUMBER;
9091
9092 rec_cnt NUMBER := 0;
9093 --serla begin
9094 l_x_Header_Payment_tbl OE_Order_PUB.Header_Payment_Tbl_Type;
9095 l_x_Line_Payment_tbl OE_Order_PUB.Line_Payment_Tbl_Type;
9096 --serla end
9097 begin
9098
9099 x_return_status := FND_API.G_RET_STS_SUCCESS;
9100 adj_debug('Entering oe_order_Adj_pvt.process_adjustments',1);
9101 G_STMT_NO := 'process_adjustments#10';
9102
9103 i:= p_req_line_tbl.first;
9104 While I is not null Loop
9105
9106 If x_Line_Tbl.count = 0 Then
9107 Begin
9108
9109 OE_Line_Util.Query_Row
9110 ( p_Line_id => p_req_line_tbl(i).line_id
9111 , x_line_rec => l_line_rec);
9112 Exception when no_data_found then
9113 null;
9114 adj_debug('process_adjustments OE_Line_Util.Query_Row , no data found');
9115 End;
9116 Else
9117 J:= x_Line_Tbl.First;
9118 While J is not null loop
9119 If x_Line_Tbl(j).line_id = p_req_line_tbl(i).line_id or
9120 J = p_req_line_tbl(i).line_index then
9121 l_line_rec := x_Line_Tbl(J);
9122 exit;
9123 End if;
9124 J:= x_Line_Tbl.next(j);
9125 end loop;
9126 End If;
9127 adj_debug('The status code '||p_req_line_tbl(i).status_code);
9128 l_invalid_line := 'N';
9129 if p_req_line_tbl(i).line_Type_code ='LINE' and
9130 p_req_line_tbl(i).status_code in ( QP_PREQ_GRP.G_STATUS_INVALID_PRICE_LIST,
9131 QP_PREQ_GRP.G_STS_LHS_NOT_FOUND,
9132 QP_PREQ_GRP.G_STATUS_FORMULA_ERROR,
9133 QP_PREQ_GRP.G_STATUS_OTHER_ERRORS,
9134 FND_API.G_RET_STS_UNEXP_ERROR,
9135 FND_API.G_RET_STS_ERROR,
9136 QP_PREQ_GRP.G_STATUS_CALC_ERROR,
9137 QP_PREQ_GRP.G_STATUS_UOM_FAILURE,
9138 QP_PREQ_GRP.G_STATUS_INVALID_UOM,
9139 QP_PREQ_GRP.G_STATUS_DUP_PRICE_LIST,
9140 QP_PREQ_GRP.G_STATUS_INVALID_UOM_CONV,
9141 QP_PREQ_GRP.G_STATUS_INVALID_INCOMP,
9142 QP_PREQ_GRP.G_STATUS_BEST_PRICE_EVAL_ERROR)
9143 then
9144 OE_MSG_PUB.set_msg_context
9145 ( p_entity_code => 'LINE'
9146 ,p_entity_id => l_line_rec.line_id
9147 ,p_header_id => l_line_rec.header_id
9148 ,p_line_id => l_line_rec.line_id
9149 ,p_order_source_id => l_line_rec.order_source_id
9150 ,p_orig_sys_document_ref => l_line_rec.orig_sys_document_ref
9151 ,p_orig_sys_document_line_ref => l_line_rec.orig_sys_line_ref
9152 ,p_orig_sys_shipment_ref => l_line_rec.orig_sys_shipment_ref
9153 ,p_change_sequence => l_line_rec.change_sequence
9154 ,p_source_document_type_id => l_line_rec.source_document_type_id
9155 ,p_source_document_id => l_line_rec.source_document_id
9156 ,p_source_document_line_id => l_line_rec.source_document_line_id
9157 );
9158
9159 l_invalid_line := 'Y';
9160 Begin
9161 Select name into l_price_list
9162 from qp_list_headers_vl where
9163 list_header_id = l_line_rec.price_list_id;
9164 Exception When No_data_found then
9165 l_price_list := l_line_rec.price_list_id;
9166 End;
9167
9168 If p_req_line_tbl(i).status_code = QP_PREQ_GRP.G_STATUS_INVALID_PRICE_LIST then
9169 adj_debug('Invalid Item/Price List combination');
9170 If not G_IPL_ERRORS_TBL.exists(l_line_rec.line_id)
9171 or (G_IPL_ERRORS_TBL.exists(l_line_rec.line_id)
9172 and
9173 G_IPL_ERRORS_TBL(l_line_rec.line_id)<>l_line_rec.price_list_id)
9174 Then
9175 FND_MESSAGE.SET_NAME('ONT','OE_PRC_NO_LIST_PRICE');
9176 FND_MESSAGE.SET_TOKEN('ITEM',l_line_rec.Ordered_Item);
9177 FND_MESSAGE.SET_TOKEN('UNIT',l_line_rec.Order_Quantity_uom);
9178 FND_MESSAGE.SET_TOKEN('PRICE_LIST',l_Price_List);
9179 OE_MSG_PUB.Add;
9180 End If;
9181
9182 G_IPL_ERRORS_TBL(l_line_rec.line_id):=l_line_rec.price_list_id;
9183
9184 oe_debug_pub.add('Before checking book flag');
9185 oe_debug_pub.add('Invalid line flag:'||l_invalid_line);
9186
9187 If nvl(l_line_rec.booked_flag,'X') = 'Y' Then
9188 oe_debug_pub.add(' Before setting message');
9189 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
9190 oe_debug_pub.add(' Before setting token');
9191 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','price list');
9192 OE_MSG_PUB.ADD;
9193 oe_debug_pub.add('Process adjustments before raising g_exc_error');
9194 RAISE FND_API.G_EXC_ERROR;
9195 End If;
9196
9197 --Fix bug 1650637
9198 --If l_line_rec.unit_selling_price Is Not Null or
9199 --l_line_rec.unit_list_price Is Not Null Then
9200 /* Begin
9201 Update Oe_Order_Lines
9202 set Unit_Selling_Price = Null,Unit_list_price = Null
9203 where line_id = l_line_rec.line_id;
9204
9205 oe_line_adj_util.delete_row(p_line_id => l_line_rec.line_id);
9206 oe_debug_pub.add(' Updating unit price to null');
9207
9208 l_line_rec.unit_selling_price := NULL;
9209 l_line_rec.unit_list_price:=NULL;
9210 l_line_rec.unit_selling_price_per_pqty :=NULL;
9211 l_line_rec.unit_list_price_per_pqty:=NULL;
9212 Exception When Others Then
9213 Oe_Debug_Pub.add('Oe_Order_Adj_Pvt:Failed to update price:'||SQLERRM);
9214 End;*/
9215 --End If;
9216
9217 l_line_rec.unit_selling_price := NULL;
9218 l_line_rec.unit_list_price:=NULL;
9219 l_line_rec.unit_selling_price_per_pqty :=NULL;
9220 l_line_rec.unit_list_price_per_pqty:=NULL;
9221
9222 Elsif p_req_line_tbl(i).status_code = QP_PREQ_GRP.G_STS_LHS_NOT_FOUND Then
9223 adj_debug('Price List Not found');
9224 FND_MESSAGE.SET_NAME('ONT','ONT_NO_PRICE_LIST_FOUND');
9225 FND_MESSAGE.SET_TOKEN('ITEM',l_line_rec.Ordered_Item);
9226 FND_MESSAGE.SET_TOKEN('UOM',l_line_rec.Order_Quantity_uom);
9227 OE_MSG_PUB.Add;
9228 Elsif p_req_line_tbl(i).status_code = QP_PREQ_GRP.G_STATUS_FORMULA_ERROR then
9229 adj_debug('Error in Formula processing');
9230 FND_MESSAGE.SET_NAME('ONT','ONT_PRC_ERROR_IN_FORMULA');
9231 FND_MESSAGE.SET_TOKEN('ERR_TEXT',p_req_line_tbl(i).status_text||SQLERRM);
9232 OE_MSG_PUB.Add;
9233 Elsif p_req_line_tbl(i).status_code in
9234 ( QP_PREQ_GRP.G_STATUS_OTHER_ERRORS , FND_API.G_RET_STS_UNEXP_ERROR,
9235 FND_API.G_RET_STS_ERROR)
9236 then
9237 adj_debug('Other errors processing');
9238 FND_MESSAGE.SET_NAME('ONT','ONT_PRICING_ERRORS'); --bug#7149497
9239 FND_MESSAGE.SET_TOKEN('ERR_TEXT',p_req_line_tbl(i).status_text||SQLERRM);
9240 OE_MSG_PUB.Add;
9241 Elsif p_req_line_tbl(i).status_code = QP_PREQ_GRP.G_STATUS_INVALID_UOM then
9242 adj_debug('Invalid uom');
9243 FND_MESSAGE.SET_NAME('ONT','ONT_PRC_INVALID_UOM');
9244 FND_MESSAGE.SET_TOKEN('ITEM',l_line_rec.Ordered_Item);
9245 FND_MESSAGE.SET_TOKEN('UOM',l_line_rec.Order_Quantity_uom);
9246 OE_MSG_PUB.Add;
9247 Elsif p_req_line_tbl(i).status_code = QP_PREQ_GRP.G_STATUS_DUP_PRICE_LIST then
9248 adj_debug('Duplicate price list');
9249 FND_MESSAGE.SET_NAME('ONT','ONT_PRC_DUPLICATE_PRICE_LIST');
9250
9251 Begin
9252 Select name into l_price_list
9253 from qp_list_headers_vl a,qp_list_lines b where
9254 b.list_line_id = to_number(substr(p_req_line_tbl(i).status_text,1,
9255 instr(p_req_line_tbl(i).status_text,',')-1))
9256 and a.list_header_id=b.list_header_id
9257 ;
9258 Exception When No_data_found then
9259 l_price_list := to_number(substr(p_req_line_tbl(i).status_text,1,
9260 instr(p_req_line_tbl(i).status_text,',')-1));
9261 When invalid_number then
9262 l_price_list := substr(p_req_line_tbl(i).status_text,1,
9263 instr(p_req_line_tbl(i).status_text,',')-1);
9264
9265 End;
9266
9267 FND_MESSAGE.SET_TOKEN('PRICE_LIST1','( '||l_line_rec.Ordered_Item||' ) '||
9268 l_price_list);
9269 Begin
9270 Select name into l_price_list
9271 from qp_list_headers_vl a,qp_list_lines b where
9272 b.list_line_id = to_number(substr(p_req_line_tbl(i).status_text,
9273 instr(p_req_line_tbl(i).status_text,',')+1))
9274 and a.list_header_id=b.list_header_id ;
9275 Exception When No_data_found then
9276 l_price_list := to_number(substr(p_req_line_tbl(i).status_text,
9277 instr(p_req_line_tbl(i).status_text,',')+1));
9278 When invalid_number then
9279 l_price_list := substr(p_req_line_tbl(i).status_text,
9280 instr(p_req_line_tbl(i).status_text,',')+1);
9281
9282 End;
9283 FND_MESSAGE.SET_TOKEN('PRICE_LIST2',l_price_list);
9284 OE_MSG_PUB.Add;
9285 Elsif p_req_line_tbl(i).status_code = QP_PREQ_GRP.G_STATUS_INVALID_UOM_CONV then
9286 adj_debug('Invalid UOM Conversion');
9287 FND_MESSAGE.SET_NAME('ONT','ONT_PRC_INVALID_UOM_CONVERSION');
9288 FND_MESSAGE.SET_TOKEN('UOM_TEXT','( '||l_line_rec.Ordered_Item||' ) '||
9289 p_req_line_tbl(i).status_text);
9290 OE_MSG_PUB.Add;
9291 Elsif p_req_line_tbl(i).status_code = QP_PREQ_GRP.G_STATUS_INVALID_INCOMP then
9292 adj_debug('Unable to resolve incompatibility');
9293 FND_MESSAGE.SET_NAME('ONT','ONT_PRC_INVALID_INCOMP');
9294 FND_MESSAGE.SET_TOKEN('ERR_TEXT','( '||l_line_rec.Ordered_Item||' ) '||
9295 p_req_line_tbl(i).status_text);
9296 OE_MSG_PUB.Add;
9297 Elsif p_req_line_tbl(i).status_code = QP_PREQ_GRP.G_STATUS_BEST_PRICE_EVAL_ERROR then
9298 adj_debug('Error while evaluating the best price');
9299 FND_MESSAGE.SET_NAME('ONT','ONT_PRC_BEST_PRICE_ERROR');
9300 FND_MESSAGE.SET_TOKEN('ITEM',l_line_rec.Ordered_Item);
9301 FND_MESSAGE.SET_TOKEN('ERR_TEXT',p_req_line_tbl(i).status_text);
9302 OE_MSG_PUB.Add;
9303 End if;
9304
9305 --RAISE FND_API.G_EXC_ERROR;
9306 --btea begin if do not write to db, we still need to
9307 --return line and status code to the caller
9308 If Not p_write_to_db Then
9309 l_line_rec.Header_id := p_header_rec.Header_id;
9310 l_line_rec.line_id := p_req_line_tbl(i).line_id;
9311 -- uom begin
9312 l_line_rec.unit_selling_price_per_pqty := p_req_line_tbl(i).adjusted_unit_price ;
9313 l_line_rec.unit_list_price_per_pqty := p_req_line_tbl(i).unit_price ;
9314 -- uom end
9315 l_line_rec.pricing_quantity := p_req_line_tbl(i).priced_quantity ;
9316 l_line_rec.pricing_quantity_uom := p_req_line_tbl(i).priced_uom_code ;
9317 l_line_rec.price_request_code := p_req_line_tbl(i).price_request_code; -- PROMOTIONS SEP/01
9318 --use industry_attribute30 as the place holder to hold error status
9319 --since the line_rec doesn't have the place holder to hold error status
9320 l_line_rec.industry_attribute30 := p_req_line_tbl(i).status_code;
9321 l_line_tbl(i) := l_line_rec;
9322 End If;
9323 --btea end
9324
9325 elsif ( p_req_line_tbl(i).unit_price < 0 or p_req_line_tbl(i).Adjusted_unit_price < 0) and l_allow_negative_price = 'N' then
9326
9327 adj_debug('Negative list price '||p_req_line_tbl(i).unit_price ||'Or selling price '||p_req_line_tbl(i).Adjusted_unit_price);
9328 FND_MESSAGE.SET_NAME('ONT','ONT_NEGATIVE_PRICE');
9329 FND_MESSAGE.SET_TOKEN('ITEM',l_line_rec.Ordered_Item);
9330 FND_MESSAGE.SET_TOKEN('LIST_PRICE',p_req_line_tbl(i).unit_price);
9331 FND_MESSAGE.SET_TOKEN('SELLING_PRICE',p_req_line_tbl(i).Adjusted_unit_price);
9332 OE_MSG_PUB.Add;
9333 FND_MESSAGE.SET_NAME('ONT','ONT_NEGATIVE_MODIFIERS');
9334 FND_MESSAGE.SET_TOKEN('LIST_LINE_NO',get_list_lines(p_req_line_tbl(i).line_id));
9335 OE_MSG_PUB.Add;
9336
9337 RAISE FND_API.G_EXC_ERROR;
9338 elsif
9339 p_req_line_tbl(i).line_Type_code ='LINE' and
9340 p_req_line_tbl(i).status_code = QP_PREQ_GRP.G_STATUS_OTHER_ERRORS
9341 Then
9342
9343 FND_MESSAGE.SET_NAME('ONT','OE_PRICING_ERROR');
9344 FND_MESSAGE.SET_TOKEN('ERR_TEXT','( '||l_line_rec.Ordered_Item||' ) '||
9345 p_req_line_tbl(i).STATUS_TEXT);
9346 OE_MSG_PUB.Add;
9347
9348 elsif
9349 ( p_req_line_tbl(i).line_Type_code ='LINE' and
9350 p_req_line_tbl(i).status_code in
9351 ( QP_PREQ_GRP.G_STATUS_UPDATED,
9352 QP_PREQ_GRP.G_STATUS_GSA_VIOLATION,
9353 QP_PREQ_GRP.G_STATUS_UNCHANGED) and
9354 nvl(p_req_line_tbl(i).processed_code,'0') <> QP_PREQ_GRP.G_BY_ENGINE
9355 and p_req_line_tbl(i).price_flag IN ('Y','P') )
9356
9357 or -- OPM 2547940 start
9358 -- pricing by quantity2 - this is for case when order line is split from shipping and new line gets generated
9359 -- and this line has to be re-priced for catchweight pricing for OPM if pricing in secondary quantity
9360 ( ( oe_line_util.dual_uom_control -- INVCONV
9361 (l_line_rec.inventory_item_id
9362 ,l_line_rec.ship_from_org_id
9363 ,l_item_rec) )
9364 and p_req_line_tbl(i).line_Type_code ='LINE'
9365 and (l_item_rec.ont_pricing_qty_source = 'S' ) -- price by quantity 2 -- INVCONV
9366 and ( p_req_line_tbl(i).price_flag In ('N','P') )
9367 and ( l_line_rec.split_by is not null )
9368 and ( l_line_rec.split_from_line_id is not null and l_line_rec.split_from_line_id <> FND_API.G_MISS_NUM) )
9369 -- OPM 2547940 end
9370
9371 --we do not want to go in this loop if price_flag is set up 'N' because
9372 --engine doesn't look at the line and will not return adjustments. In this
9373 --case we DON't want to remove the adjustments that engine doesn't return.
9374 then
9375
9376 G_STMT_NO := 'process_adjustments11.5';
9377 l_invalid_line := 'N';
9378 l_line_rec.Header_id := p_header_rec.Header_id;
9379 l_line_rec.line_id := p_req_line_tbl(i).line_id;
9380 -- uom begin
9381 l_line_rec.unit_selling_price_per_pqty := p_req_line_tbl(i).adjusted_unit_price ;
9382 l_line_rec.unit_list_price_per_pqty := p_req_line_tbl(i).unit_price ;
9383 -- uom end
9384
9385 If l_line_rec.item_type_code in ('INCLUDED', 'CONFIG') Then
9386 l_line_rec.pricing_quantity := l_line_rec.ordered_quantity;
9387 l_line_rec.pricing_quantity_uom := l_line_rec.order_quantity_uom;
9388 Else
9389 l_line_rec.pricing_quantity := p_req_line_tbl(i).priced_quantity ;
9390 l_line_rec.pricing_quantity_uom := p_req_line_tbl(i).priced_uom_code ;
9391 End If;
9392
9393 l_line_rec.price_request_code := p_req_line_tbl(i).price_request_code; -- PROMOTIONS SEP/01
9394
9395 -- Handle the percent Price
9396
9397 If nvl(p_req_line_tbl(i).Percent_Price,0) <> 0 and
9398 p_req_line_tbl(i).Percent_Price <> fnd_api.g_miss_num then
9399
9400 l_line_rec.unit_list_percent := p_req_line_tbl(i).Percent_Price ;
9401 l_line_rec.unit_percent_base_price := p_req_line_tbl(i).Parent_price;
9402 -- For bug 1367793, avoid dividing by zero
9403
9404 If nvl(l_line_rec.unit_percent_base_price, 0) <> 0 Then
9405 l_line_rec.unit_selling_percent :=
9406 l_line_rec.Unit_Selling_Price_Per_Pqty * 100 / l_line_rec.unit_percent_base_price;
9407 Else
9408 l_line_rec.unit_selling_percent := 0;
9409 End If;
9410
9411 end if;
9412
9413
9414 -- Query the adjustment Lines for this line
9415
9416 G_STMT_NO := 'process_adjustments#30';
9417 --adj_debug('BCT+***L line id: '||p_req_line_tbl(i).line_id);
9418 Append_Adjustment_Lines(p_line_id => l_line_rec.line_id,
9419 p_pricing_event => p_Req_Control_Rec.Pricing_Event,
9420 p_price_flag => p_req_line_tbl(i).price_flag,
9421 p_any_frozen_line => p_any_frozen_line,
9422 px_Line_Adj_Tbl => l_line_adj_Tbl,
9423 px_line_key_tbl => l_line_key_tbl,
9424 px_header_key_tbl => l_header_key_tbl,
9425 p_mode => 'L',
9426 px_line_rec => l_line_rec,
9427 px_line_adj_assoc_tbl => l_line_adj_assoc_tbl,
9428 x_updated_flag => l_updated_flag,
9429 p_multiple_events => p_multiple_events);
9430
9431 -- Using the same index as that in p_req_line_tbl although there is going to be holes.
9432
9433 --l_line_tbl(l_line_tbl.count+1) := l_line_rec;
9434 --l_old_line_tbl(l_line_tbl.count) := l_old_line_rec;
9435 adj_debug('Setting l_line_tbl...'||l_line_tbl.count||' '||i||' '||l_line_rec.line_id);
9436 l_line_tbl(i) := l_line_rec;
9437 --l_old_line_tbl(i) := l_old_line_rec;
9438
9439 Elsif -- Process header level adjustments
9440 p_req_line_tbl(i).line_type_code ='ORDER' and
9441 (p_req_line_tbl(i).status_code in ( QP_PREQ_GRP.G_STATUS_UPDATED ,
9442 QP_PREQ_GRP.G_STATUS_GSA_VIOLATION)
9443 --btea
9444 --In this case even engine doesn't update the order (status = UNCHANGED)
9445 --because of one of the lined is frozen,
9446 --there can be some order level adjustments in database which
9447 --need to be pulled out by append_adjustment_lines routine
9448 or (p_req_line_tbl(i).status_code = QP_PREQ_GRP.G_STATUS_UNCHANGED
9449 -- and p_any_frozen_line = TRUE -- bug 1675449
9450 ))
9451 Then
9452 G_STMT_NO := 'Process_Adjustments#35';
9453 --adj_debug('BCT'||G_STMT_NO);
9454 --adj_debug('BCT+***H line id: '||p_req_line_tbl(i).line_id);
9455
9456 IF (l_header_rec.price_request_code IS NULL OR -- PROMOTIONS SEP/01
9457 l_header_rec.price_request_code = FND_API.G_MISS_CHAR) THEN
9458 l_header_rec.price_request_code := p_req_line_tbl(i).price_request_code;
9459 l_header_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
9460 END IF;
9461
9462 append_Adjustment_Lines(p_header_id => p_req_line_tbl(i).line_id,
9463 -- line_id contains header_id for line_type_code='ORDER'
9464 p_pricing_event => p_Req_Control_Rec.Pricing_Event,
9465 p_price_flag => p_req_line_tbl(i).price_flag,
9466 p_any_frozen_line => p_any_frozen_line,
9467 px_Line_Adj_Tbl => l_line_adj_Tbl,
9468 px_line_key_tbl => l_line_key_tbl,
9469 px_header_key_tbl => l_header_key_tbl,
9470 p_mode => 'H',
9471 px_line_rec => l_dummy_line_rec,
9472 px_line_adj_assoc_tbl => l_line_adj_assoc_tbl,
9473 x_updated_flag => l_updated_flag,
9474 p_multiple_events => p_multiple_events);
9475
9476 End If;-- Status_Code
9477
9478 oe_debug_pub.add('Before Reset_fields');
9479 If l_invalid_line = 'Y' Then
9480 select oe_msg_request_id_s.nextval into l_request_id from dual;
9481 OE_MSG_PUB.INSERT_MESSAGE(OE_MSG_PUB.COUNT_MSG, l_request_id,'U');
9482 Reset_Fields(l_line_rec);
9483 l_invalid_line := 'N';
9484 End If;
9485
9486 G_STMT_NO := 'Process_Adjustments#36';
9487 -- adj_debug('PAL PROMOTIONS '||G_STMT_NO);
9488 -- adj_debug('PROMOTIONS - status code is ' ||p_req_line_tbl(i).status_code);
9489
9490 -- Process header level adjustments -- PROMOTIONS SEP/01 start
9491 adj_debug('limit profile:'||l_limit_hold_action,3);
9492
9493 IF (p_req_line_tbl(i).hold_code = QP_PREQ_GRP.G_STATUS_LIMIT_HOLD) or
9494 p_req_line_tbl(i).hold_code = QP_PREQ_GRP.G_STATUS_LIMIT_ADJUSTED THEN
9495 IF (l_limit_hold_action = 'NO_HOLD') THEN
9496 FND_MESSAGE.SET_NAME('ONT','ONT_PROMO_LIMIT_EXCEEDED');
9497 OE_MSG_PUB.ADD;
9498 ELSE
9499 IF ( p_req_line_tbl(i).line_type_code = 'LINE' )
9500 Then
9501 -- adj_debug('PAL PROMOTIONS - putting entity on HOLD - line type code is ' || p_req_line_tbl(i).line_type_code);
9502 Promotion_Put_Hold (p_header_id => p_header_rec.Header_id,
9503 p_line_id => p_req_line_tbl(i).line_id);
9504 IF (l_limit_hold_action = 'ORDER_HOLD') THEN
9505 Promotion_Put_Hold(p_header_id => p_header_rec.header_id,
9506 p_line_id => NULL);
9507 END IF;
9508
9509 ELSIF ( p_req_line_tbl(i).line_type_code = 'ORDER' )
9510 Then
9511 -- adj_debug('PAL PROMOTIONS - putting entity on HOLD - line type code is ' || p_req_line_tbl(i).line_type_code);
9512 Promotion_Put_Hold (p_header_id => p_req_line_tbl(i).line_id,
9513 p_line_id => NULL) ;
9514
9515 END IF; -- ( p_req_line_tbl(i).line_type_code = 'LINE' )
9516 END IF; -- limit violation action
9517 END IF; -- (p_req_line_tbl(i).hold_code = QP_PREQ_GRP.G_STATUS_LIMIT_HOLD)
9518 IF p_req_line_tbl(i).line_id IS NOT NULL AND
9519 p_req_line_tbl(i).line_id <> FND_API.G_MISS_NUM THEN
9520 BEGIN
9521 IF l_debug_level > 0 THEN
9522 oe_debug_pub.add('Getting reference data for line_id:'||p_req_line_tbl(i).line_id);
9523 END IF;
9524 SELECT order_source_id, orig_sys_document_ref, change_sequence,
9525 source_document_type_id, source_document_id, orig_sys_line_ref,
9526 source_document_line_id, orig_sys_shipment_ref
9527 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
9528 l_source_document_type_id, l_source_document_id, l_orig_sys_line_ref,
9529 l_source_document_line_id, l_orig_sys_shipment_ref
9530 FROM OE_ORDER_LINES_ALL
9531 WHERE line_id = p_req_line_tbl(i).line_id;
9532 EXCEPTION
9533 WHEN NO_DATA_FOUND THEN
9534 l_order_source_id := null;
9535 l_orig_sys_document_ref := null;
9536 l_change_sequence := null;
9537 l_source_document_type_id := null;
9538 l_source_document_id := null;
9539 l_orig_sys_line_ref := null;
9540 l_source_document_line_id := null;
9541 l_orig_sys_shipment_ref := null;
9542 WHEN OTHERS THEN
9543 l_order_source_id := null;
9544 l_orig_sys_document_ref := null;
9545 l_change_sequence := null;
9546 l_source_document_type_id := null;
9547 l_source_document_id := null;
9548 l_orig_sys_line_ref := null;
9549 l_source_document_line_id := null;
9550 l_orig_sys_shipment_ref := null;
9551 END;
9552 END IF;
9553
9554 OE_MSG_PUB.set_msg_context
9555 ( p_entity_code => 'LINE'
9556 ,p_entity_id => p_req_line_tbl(i).line_id
9557 ,p_header_id => p_req_line_tbl(i).header_id
9558 ,p_line_id => p_req_line_tbl(i).line_id
9559 ,p_order_source_id => l_order_source_id
9560 ,p_orig_sys_document_ref => l_orig_sys_document_ref
9561 ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
9562 ,p_orig_sys_shipment_ref => l_orig_sys_shipment_ref
9563 ,p_change_sequence => l_change_sequence
9564 ,p_source_document_type_id => l_source_document_type_id
9565 ,p_source_document_id => l_source_document_id
9566 ,p_source_document_line_id => l_source_document_line_id); -- PROMOTIONS MAY/01 end
9567
9568 i:= p_req_line_tbl.Next(i);
9569 end loop; -- Req_line_tbl
9570
9571 G_STMT_NO := 'process_adjustments#40';
9572
9573 J:= p_req_line_detail_Tbl.First;
9574 While J is Not null loop
9575 if p_req_line_tbl( p_req_line_detail_Tbl(j).line_index).status_code in (
9576 QP_PREQ_GRP.G_STATUS_UPDATED ,QP_PREQ_GRP.G_STATUS_GSA_VIOLATION )
9577 and nvl(p_req_line_tbl( p_req_line_detail_Tbl(j).line_index).processed_code,'0')
9578 <> QP_PREQ_GRP.G_BY_ENGINE
9579
9580 --only process/insert automatic adjustments, with freight charge as exception
9581 and (p_req_line_detail_Tbl(j).automatic_flag = 'Y' or
9582 (p_req_line_detail_Tbl(j).automatic_flag = 'N' and (p_req_line_detail_Tbl(j).list_line_type_code = 'FREIGHT_CHARGE' or l_preinsert_manual_adj = 'Y' )))
9583 and (
9584 ((
9585 ( l_line_tbl.exists( p_req_line_detail_Tbl(j).line_index)
9586 and
9587 oe_line_util.Get_Return_Item_Type_Code
9588 (l_line_tbl( p_req_line_detail_Tbl(j).line_index))<> 'INCLUDED'
9589 )
9590 Or not l_line_tbl.exists (p_req_line_detail_Tbl(j).line_index )
9591
9592 )
9593 And
9594 G_CHARGES_FOR_INCLUDED_ITEM = 'N'
9595 )
9596 Or
9597 G_CHARGES_FOR_INCLUDED_ITEM = 'Y'
9598 )
9599
9600
9601 then
9602 --adj_debug('BCT+Engine returned status fullfilled');
9603 --adj_debug('BCT+list_line_type_code+'||p_req_line_detail_Tbl(j).list_line_type_code);
9604 if p_req_line_detail_Tbl(j).created_from_list_type_code = 'PRL' or
9605 p_req_line_detail_Tbl(j).created_from_list_type_code = 'AGR' or
9606 p_req_line_detail_Tbl(j).list_line_type_code = 'PLL'
9607 then
9608 If l_line_tbl.exists( p_req_line_detail_Tbl(j).line_index) then
9609 l_line_tbl( p_req_line_detail_Tbl(j).line_index).price_list_id :=
9610 p_req_line_detail_Tbl(j).list_header_id;
9611 End if;
9612
9613 else
9614 G_STMT_NO := 'process_adjustments#50';
9615
9616 If p_req_line_tbl( p_req_line_detail_Tbl(j).line_index).line_type_code = 'LINE' Then
9617
9618 -- Changes by JAUTOMO on 20-DEC-00 (bug# 1303352)
9619
9620 -- Get Discounting Privilege Profile Option value
9621 fnd_profile.get('ONT_DISCOUNTING_PRIVILEGE', v_discounting_privilege);
9622
9623 IF (v_order_enforce_list_price = 'Y') THEN
9624 v_line_enforce_list_price := 'Y';
9625 ELSE
9626 enforce_list_price(
9627 p_req_line_tbl(p_req_line_detail_tbl(j).line_index).line_id,
9628 l_line_tbl(p_req_line_detail_tbl(j).line_index).header_id,
9629 l_line_tbl(p_req_line_detail_tbl(j).line_index).line_type_id,
9630 v_order_enforce_list_price,
9631 v_line_enforce_list_price);
9632 END IF;
9633
9634 adj_debug('2441779 line_id '||p_req_line_detail_tbl(j).line_index||' '||p_req_line_tbl(p_req_line_detail_tbl(j).line_index).line_id);
9635 adj_debug('2441779'||l_line_tbl(p_req_line_detail_tbl(j).line_index).line_id);
9636 IF (nvl(v_line_enforce_list_price,'N') <> 'Y'
9637 AND p_req_line_detail_Tbl(j).automatic_flag = 'Y')
9638 OR
9639 p_req_line_detail_tbl(j).list_line_type_code = 'FREIGHT_CHARGE' THEN
9640
9641 If p_req_line_detail_Tbl(j).list_line_type_code ='TSN' then
9642 adj_debug('Before Terms-- Line Level');
9643 -- Updated the Terms at Line Level
9644 If p_req_line_detail_Tbl(j).Substitution_Attribute ='QUALIFIER_ATTRIBUTE1' Then
9645 adj_debug('Payment_term updated to '||p_req_line_detail_Tbl(j).Substitution_to);
9646 l_line_tbl( p_req_line_detail_Tbl(j).line_index).payment_term_id :=
9647 p_req_line_detail_Tbl(j).Substitution_to;
9648 elsIf p_req_line_detail_Tbl(j).Substitution_Attribute ='QUALIFIER_ATTRIBUTE11' Then
9649 adj_debug('shipping_method_code updated to '||p_req_line_detail_Tbl(j).Substitution_to);
9650 l_line_tbl( p_req_line_detail_Tbl(j).line_index).shipping_method_code :=
9651 p_req_line_detail_Tbl(j).Substitution_to;
9652 elsIf p_req_line_detail_Tbl(j).Substitution_Attribute ='QUALIFIER_ATTRIBUTE10' Then
9653 adj_debug('freight_terms_code updated to '||p_req_line_detail_Tbl(j).Substitution_to);
9654 l_line_tbl( p_req_line_detail_Tbl(j).line_index).freight_terms_code :=
9655 p_req_line_detail_Tbl(j).Substitution_to;
9656 End If;
9657
9658 End If; -- TSN
9659
9660
9661 -- Check If the List_Header/ Line Combination Exists
9662 l_adj_index := NULL;
9663 Find_Duplicate_Adj_Lines(
9664 p_Line_id =>
9665 l_line_tbl( p_req_line_detail_Tbl(j).line_index).line_id,
9666 p_req_line_detail_Rec => p_req_line_detail_Tbl(j),
9667 px_Line_Adj_Tbl => l_line_adj_Tbl,
9668 x_Adj_Index => l_Adj_Index,
9669 p_mode => 'L',
9670 px_line_key_tbl => l_line_key_tbl,
9671 px_header_key_tbl => l_header_key_tbl) ;
9672
9673 END IF; -- For Unlimited Discouting Privilege
9674 adj_debug('2441779:'||l_line_tbl(p_req_line_detail_tbl(j).line_index).line_id);
9675
9676 Else -- HEader Level
9677
9678 If p_req_line_detail_Tbl(j).list_line_type_code ='TSN' then
9679 adj_debug('Before Terms-- Header Level');
9680 -- Updated the Terms at Line Level
9681 If p_req_line_detail_Tbl(j).Substitution_Attribute ='QUALIFIER_ATTRIBUTE1' Then
9682 adj_debug('Payment_term updated to '||p_req_line_detail_Tbl(j).Substitution_to);
9683 l_header_rec.payment_term_id := p_req_line_detail_Tbl(j).Substitution_to;
9684 elsIf p_req_line_detail_Tbl(j).Substitution_Attribute ='QUALIFIER_ATTRIBUTE11' Then
9685 adj_debug('shipping_method_code updated to '||p_req_line_detail_Tbl(j).Substitution_to);
9686 l_header_rec.shipping_method_code := p_req_line_detail_Tbl(j).Substitution_to;
9687 elsIf p_req_line_detail_Tbl(j).Substitution_Attribute ='QUALIFIER_ATTRIBUTE10' Then
9688 adj_debug('freight_terms_code updated to '||p_req_line_detail_Tbl(j).Substitution_to);
9689 l_header_rec.freight_terms_code := p_req_line_detail_Tbl(j).Substitution_to;
9690 End If;
9691
9692 l_header_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
9693
9694 End If; -- TSN
9695
9696
9697 -- Check If the List_Header/ header Combination Exists
9698
9699 G_STMT_NO := 'process_adjustments#55';
9700 l_adj_index:=NULL;
9701 Find_Duplicate_Adj_Lines(
9702 p_header_Id =>
9703 p_req_line_tbl(p_req_line_detail_Tbl(j).line_index).line_id,
9704 -- line_id hold header_id for 'HEADER'
9705 p_req_line_detail_Rec => p_req_line_detail_Tbl(j),
9706 px_Line_Adj_Tbl => l_line_adj_Tbl,
9707 x_Adj_Index => l_Adj_Index,
9708 p_mode => 'H',
9709 px_line_key_tbl => l_line_key_tbl,
9710 px_header_key_tbl => l_header_key_tbl
9711 ) ;
9712
9713 End if; --header_level
9714
9715 If nvl(l_adj_index,-1) > 0 Then
9716 -- Populate the line_details processed table
9717 l_line_details_prcd(j) := l_Adj_Index;
9718
9719 adj_debug('details_prcd: ('||J||')'||l_Adj_Index,2);
9720
9721 -- Mark Adjustment Attributes and Adjustment Associations to
9722 -- Delete
9723 -- Subsequently these rows would be reinstated
9724 -- Delete is cascaded to children when adjustment is deleted.
9725
9726
9727 G_STMT_NO := 'process_adjustments#60';
9728
9729 Query_Adj_Attribs(
9730 p_price_adjustment_id=>
9731 l_line_adj_Tbl(l_Adj_Index).price_adjustment_id,
9732 p_Adj_Index => l_Adj_Index,
9733 p_Line_Adj_Att_Tbl => l_line_adj_att_tbl);
9734
9735 G_STMT_NO := 'process_adjustments#70';
9736
9737
9738
9739 --adj_debug('BCT+operation:'||l_line_adj_Tbl(l_Adj_Index).operation);
9740 if l_line_adj_Tbl(l_Adj_Index).operation in ( OE_GLOBALS.G_OPR_CREATE,
9741 OE_GLOBALS.G_OPR_UPDATE ) Then
9742 -- This Record Needs to be processed
9743 if p_req_line_tbl( p_req_line_detail_Tbl(j).line_index).line_type_code = 'LINE'
9744 Then
9745
9746 if p_req_line_detail_Tbl(j).list_line_type_code ='IUE' then
9747 -- Do not give item upgrades to config items.
9748 If l_line_tbl( p_req_line_detail_Tbl(j).line_index).top_model_line_id is null
9749 or l_line_tbl( p_req_line_detail_Tbl(j).line_index).top_model_line_id= fnd_api.g_miss_num
9750 then
9751 If -- Allow Item upgrade only if the order is not booked.
9752 nvl(l_line_tbl( p_req_line_detail_Tbl(j).line_index).booked_flag,'N')
9753 = 'N'
9754 then
9755
9756 -- Set the Line Item to the new item
9757
9758 Set_item_for_iue(
9759 px_line_rec => l_line_tbl( p_req_line_detail_Tbl(j).line_index)
9760 ,p_req_line_detail_rec => p_req_line_detail_Tbl(j)
9761 );
9762
9763
9764 Elsif to_char(l_line_tbl( p_req_line_detail_Tbl(j).line_index).Inventory_item_id ) <>
9765 p_req_line_detail_Tbl(j).RELATED_ITEM_ID Then
9766
9767 FND_MESSAGE.SET_NAME('ONT','ONT_ITEM_UPGRADE_NOT_ALLOWED');
9768 OE_MSG_PUB.Add;
9769 adj_debug('Item Upgrade not allowed after booking...');
9770 l_line_adj_Tbl(l_Adj_Index).operation := fnd_api.g_miss_char;
9771
9772 End If; -- Booked_Flag
9773
9774 End if ; -- Config item
9775 end if; -- IUE
9776
9777 l_line_adj_Tbl(l_Adj_Index).line_id :=
9778 l_line_tbl( p_req_line_detail_Tbl(j).line_index).line_id;
9779 l_line_adj_Tbl(l_Adj_Index).Header_id :=
9780 l_line_tbl( p_req_line_detail_Tbl(j).line_index).Header_id;
9781 l_line_adj_Tbl(l_Adj_Index).Line_index := p_req_line_detail_Tbl(j).line_index;
9782
9783 else -- HEADER Level
9784
9785 l_line_adj_Tbl(l_Adj_Index).line_id := null;
9786 l_line_adj_Tbl(l_Adj_Index).Header_id :=
9787 p_req_line_tbl(p_req_line_detail_Tbl(j).line_index).line_id;
9788 -- line_id hold header_id for 'HEADER'
9789 l_line_adj_Tbl(l_Adj_Index).Line_index := null;
9790
9791 --OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
9792
9793 End If ; -- list_line_level
9794
9795
9796 -- Process "Other Item Discounts" (Including Free goods)
9797
9798 G_STMT_NO := 'process_adjustments#80';
9799
9800
9801 -- Process Promotional Goods
9802
9803 If p_req_line_detail_Tbl(j).list_line_type_code ='PRG' Then
9804 adj_debug('The Detail is a PRG '||p_req_line_detail_Tbl(j).line_detail_index);
9805
9806 i:= p_Req_Related_Lines_Tbl.First;
9807 While i is not null loop
9808
9809 if p_Req_Related_Lines_Tbl(i).Line_Detail_Index =
9810 p_req_line_detail_Tbl(j).line_detail_index and
9811 p_Req_Related_Lines_Tbl(i).Relationship_Type_Code
9812 =QP_PREQ_GRP.G_GENERATED_LINE Then
9813
9814 adj_debug('The related line is '||p_Req_Related_Lines_Tbl(i).Related_Line_Detail_Index);
9815 -- Process the "Other Item"
9816
9817 If p_Req_Related_Lines_Tbl(i).Related_Line_Detail_Index is not Null
9818 Then
9819 -- Inserts Rows into Line_Tbl and Adjustments
9820
9821 G_STMT_NO := 'process_adjustments#90';
9822
9823 Begin
9824 oe_debug_pub.add('Line id:'||
9825 l_line_tbl(p_req_line_detail_Tbl(p_req_related_lines_tbl(i).line_detail_index).line_index).line_id);
9826
9827 oe_debug_pub.add('Reason:'||
9828 l_line_tbl(p_req_line_detail_Tbl(p_req_related_lines_tbl(i).line_detail_index).line_index).return_reason_code);
9829 Exception when others then
9830 oe_debug_pub.add(SQLERRM||G_STMT_NO);
9831 End;
9832
9833 Process_Other_Item_Line
9834 (p_Line_Detail_Index =>
9835 p_Req_Related_Lines_Tbl(i).Related_Line_Detail_Index,
9836 p_req_line_Tbl => p_req_line_Tbl,
9837 p_req_line_detail_Tbl => p_req_line_detail_Tbl,
9838 p_req_line_detail_Attr_Tbl => p_req_line_detail_Attr_Tbl,
9839 p_Price_Adjustment_Id => l_line_adj_Tbl(l_Adj_Index).Price_Adjustment_Id,
9840 p_Header_id => p_header_rec.Header_id,
9841 p_Parent_Adj_Index => l_Adj_Index,
9842 p_parent_line_index => p_req_line_detail_Tbl(j).line_index,
9843 p_Rltd_line_details_prcd=> l_Rltd_line_details_prcd,
9844 --p_Rltd_line_details_prcd=> l_line_details_prcd,
9845 p_Rltd_lines_prcd => l_Rltd_lines_prcd,
9846 p_Line_Tbl => l_Line_Tbl,
9847 p_Line_Adj_Tbl => l_line_adj_Tbl,
9848 p_Line_Adj_Assoc_Tbl => l_line_adj_Assoc_Tbl,
9849 p_line_detail_replaced => l_line_detail_replaced,
9850 p_buy_line_rec => l_line_tbl(p_req_line_detail_Tbl(p_req_related_lines_tbl(i).line_detail_index).line_index));
9851
9852 End If; -- RelationShips
9853 End If;
9854 i:= p_Req_Related_Lines_Tbl.next(i);
9855 End Loop;
9856
9857 End If; -- PRG
9858
9859 end if; -- Duplicate list lines in the adjustments
9860 -- Process the Qualifiers
9861 end if; -- for list_line_type
9862
9863 end if; -- Status_code = Updated.
9864
9865 If ( (p_req_line_detail_Tbl(j).limit_code = QP_PREQ_GRP.G_STATUS_LIMIT_EXCEEDED ) -- PROMOTIONS SEP/01 START
9866 or (p_req_line_detail_Tbl(j).limit_code = QP_PREQ_GRP.G_STATUS_LIMIT_ADJUSTED ) )
9867 then
9868 -- adj_debug('PAL PROMOTIONS - G_STATUS_LIMIT_EXCEEDED or G_STATUS_LIMIT_ADJUSTED IN _Adj_pvt.process_adjustments',1);
9869 IF (p_req_line_tbl(p_req_line_detail_tbl(j).line_index).LINE_TYPE_CODE='ORDER') THEN
9870 OE_MSG_PUB.set_msg_context
9871 ( p_entity_code => 'HEADER'
9872 ,p_entity_id => p_header_rec.header_id--p_req_line_tbl(j).line_id
9873 ,p_header_id => p_header_rec.header_id
9874 ,p_line_id => NULL--p_req_line_tbl(j).line_id
9875 ,p_orig_sys_document_ref => p_header_rec.orig_sys_document_ref
9876 ,p_orig_sys_document_line_ref => NULL
9877 ,p_change_sequence => p_header_rec.change_sequence
9878 ,p_source_document_id => p_header_rec.source_document_id
9879 ,p_source_document_line_id => NULL
9880 ,p_order_source_id => p_header_rec.order_source_id
9881 ,p_source_document_type_id => p_header_rec.source_document_type_id);
9882 ELSE
9883 IF p_req_line_tbl(p_req_line_detail_tbl(j).line_index).line_id IS NOT NULL AND
9884 p_req_line_tbl(p_req_line_detail_tbl(j).line_index).line_id <> FND_API.G_MISS_NUM THEN
9885 BEGIN
9886 IF l_debug_level > 0 THEN
9887 oe_debug_pub.add('Getting reference data for line_id:'||p_req_line_tbl(p_req_line_detail_tbl(j).line_index).line_id);
9888 END IF;
9889 SELECT order_source_id, orig_sys_document_ref, change_sequence,
9890 source_document_type_id, source_document_id, orig_sys_line_ref,
9891 source_document_line_id, orig_sys_shipment_ref
9892 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
9893 l_source_document_type_id, l_source_document_id, l_orig_sys_line_ref,
9894 l_source_document_line_id, l_orig_sys_shipment_ref
9895 FROM OE_ORDER_LINES_ALL
9896 WHERE line_id = p_req_line_tbl(p_req_line_detail_tbl(j).line_index).line_id;
9897 EXCEPTION
9898 WHEN NO_DATA_FOUND THEN
9899 l_order_source_id := null;
9900 l_orig_sys_document_ref := null;
9901 l_change_sequence := null;
9902 l_source_document_type_id := null;
9903 l_source_document_id := null;
9904 l_orig_sys_line_ref := null;
9905 l_source_document_line_id := null;
9906 l_orig_sys_shipment_ref := null;
9907 WHEN OTHERS THEN
9908 l_order_source_id := null;
9909 l_orig_sys_document_ref := null;
9910 l_change_sequence := null;
9911 l_source_document_type_id := null;
9912 l_source_document_id := null;
9913 l_orig_sys_line_ref := null;
9914 l_source_document_line_id := null;
9915 l_orig_sys_shipment_ref := null;
9916 END;
9917 END IF;
9918 OE_MSG_PUB.set_msg_context
9919 ( p_entity_code => 'LINE'
9920 ,p_entity_id => p_req_line_tbl(p_req_line_detail_tbl(j).line_index).LINE_ID
9921 ,p_header_id => p_header_rec.header_id
9922 ,p_line_id => p_req_line_tbl(p_req_line_detail_tbl(j).line_index).line_id
9923 ,p_order_source_id => l_order_source_id
9924 ,p_orig_sys_document_ref => l_orig_sys_document_ref
9925 ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
9926 ,p_orig_sys_shipment_ref => l_orig_sys_shipment_ref
9927 ,p_change_sequence => l_change_sequence
9928 ,p_source_document_type_id => l_source_document_type_id
9929 ,p_source_document_id => l_source_document_id
9930 ,p_source_document_line_id => l_source_document_line_id);
9931 END IF;
9932
9933 FND_MESSAGE.SET_NAME('ONT','ONT_PROMO_LIMIT_EXCEEDED');
9934 FND_MESSAGE.SET_TOKEN('ERR_TEXT', p_req_line_detail_tbl(j).LIMIT_TEXT);
9935 OE_MSG_PUB.Add;
9936 IF (OE_GLOBALS.G_UI_FLAG ) THEN
9937 IF (G_REQUEST_ID IS NULL) THEN
9938 select oe_msg_request_id_s.nextval into g_request_id from dual;
9939 END IF;
9940 OE_MSG_PUB.INSERT_MESSAGE(OE_MSG_PUB.COUNT_MSG, G_REQUEST_ID,'U');
9941 OE_MSG_PUB.DELETE_MSG(OE_MSG_PUB.COUNT_MSG);
9942 END IF;
9943
9944 end if; --PROMOTIONS SEP/01 end
9945
9946 end if; --l_adj_line_index is either postive of 0 nvl(l_adj_index,-1)
9947
9948 J:=p_req_line_detail_Tbl.Next(j);
9949
9950 end loop; -- p_req_line_detail_Tbl
9951
9952 G_STMT_NO := 'process_adjustments#100';
9953
9954 --No adjustment records, or relationsip,attributes record need to be looked at becasue
9955 --enforce list price is set to 'Y'
9956 If nvl(v_line_enforce_list_price,'N') <> 'Y' Then
9957 -- Process Price Break Lines
9958 i:= p_Req_Related_Lines_Tbl.First;
9959 While i is not null loop
9960 if
9961 p_Req_Related_Lines_Tbl(i).Relationship_Type_Code in (
9962 QP_PREQ_GRP.G_PBH_LINE ,QP_PREQ_GRP.G_GENERATED_LINE ) and
9963 p_Req_Related_Lines_Tbl(i).Line_Detail_Index is not null and
9964 p_Req_Related_Lines_Tbl(i).Related_Line_Detail_Index is not null and
9965 l_line_details_prcd.exists(p_Req_Related_Lines_Tbl(i).Line_Detail_Index) and
9966 l_line_details_prcd.exists(p_Req_Related_Lines_Tbl(i).Related_Line_Detail_Index)
9967 and l_line_adj_tbl(l_line_details_prcd(p_Req_Related_Lines_Tbl(i).Line_Detail_Index)).updated_flag = 'N'
9968 Then
9969 If G_DEBUG Then
9970 adj_debug('RLTD: line detail '||p_Req_Related_Lines_Tbl(i).Line_Detail_Index,2);
9971 adj_debug('RLTD: rltd line detail '||p_Req_Related_Lines_Tbl(i).Related_Line_Detail_Index,2);
9972 adj_debug('RLTD: Relationship type '||p_Req_Related_Lines_Tbl(i).Relationship_Type_Code,2);
9973 End If;
9974
9975 -- Process the Relationship records
9976 -- l_assoc_index := l_Line_Adj_Assoc_tbl.count+1;
9977 /* Commented the above line and added following 5 lines to fix the bug 2312402 */
9978 IF (l_Line_Adj_Assoc_tbl.count > 0) THEN
9979 l_assoc_index := l_Line_Adj_Assoc_tbl.last+1;
9980 ELSE
9981 l_assoc_index := 1;
9982 END IF;
9983 l_Line_Adj_Assoc_tbl(l_assoc_index) := OE_ORDER_PUB.G_MISS_LINE_ADJ_ASSOC_REC;
9984 l_Line_Adj_Assoc_tbl(l_assoc_index).Line_Index := Null;
9985 l_Line_Adj_Assoc_tbl(l_assoc_index).Adj_Index :=
9986 l_line_details_prcd(p_Req_Related_Lines_Tbl(i).Line_Detail_Index);
9987 l_Line_Adj_Assoc_tbl(l_assoc_index).Rltd_Adj_Index :=
9988 l_line_details_prcd(p_Req_Related_Lines_Tbl(i).Related_Line_Detail_Index);
9989 l_Line_Adj_Assoc_tbl(l_assoc_index).Operation := OE_Globals.G_OPR_CREATE;
9990
9991 If l_line_adj_Tbl.exists(l_line_details_prcd(p_Req_Related_Lines_Tbl(i).line_detail_Index))
9992 and l_line_adj_Tbl(l_line_details_prcd(p_Req_Related_Lines_Tbl(i).line_detail_Index)).price_adjustment_id <> FND_API.G_MISS_NUM and
9993 l_line_adj_Tbl(l_line_details_prcd(p_Req_Related_Lines_Tbl(i).line_detail_Index)).price_adjustment_id is not null then
9994
9995 l_Line_Adj_Assoc_tbl(l_assoc_index).price_adjustment_id :=
9996 l_line_adj_Tbl(l_line_details_prcd(p_Req_Related_Lines_Tbl(i).line_detail_Index)).price_adjustment_id ;
9997 End If; -- Populate Adjustment_id
9998 If l_line_adj_Tbl.exists(l_line_details_prcd(p_Req_Related_Lines_Tbl(i).Related_Line_Detail_Index))
9999 and l_line_adj_Tbl(l_line_details_prcd(p_Req_Related_Lines_Tbl(i).Related_Line_Detail_Index)).price_adjustment_id <> FND_API.G_MISS_NUM and
10000 l_line_adj_Tbl(l_line_details_prcd(p_Req_Related_Lines_Tbl(i).Related_Line_Detail_Index)).price_adjustment_id is not null then
10001
10002 l_Line_Adj_Assoc_tbl(l_assoc_index).rltd_price_adj_id :=
10003 l_line_adj_Tbl(l_line_details_prcd(p_Req_Related_Lines_Tbl(i).Related_Line_Detail_Index)).price_adjustment_id ;
10004 End If; -- Populate Adjustment_id
10005
10006 End If; -- RelationShips
10007 i:= p_Req_Related_Lines_Tbl.Next(i);
10008 End Loop;
10009
10010 -- Process Qualifier Attributes
10011
10012 i:= p_Req_LINE_DETAIL_qual_tbl.First;
10013 While i is not null Loop
10014 --For i in 1..p_Req_LINE_DETAIL_qual_tbl.count loop
10015 if l_line_details_prcd.exists(p_Req_LINE_DETAIL_qual_tbl(i).line_detail_index)
10016 --or l_Rltd_line_details_prcd.exists(p_Req_LINE_DETAIL_qual_tbl(i).line_detail_index)
10017 then
10018
10019 G_STMT_NO := 'process_adjustments#110';
10020 If l_line_adj_Tbl.exists(l_line_details_prcd(p_Req_LINE_DETAIL_qual_tbl(i).line_detail_Index))
10021 and l_line_adj_Tbl(l_line_details_prcd(p_Req_LINE_DETAIL_qual_tbl(i).line_detail_Index)).price_adjustment_id <> FND_API.G_MISS_NUM and
10022 l_line_adj_Tbl(l_line_details_prcd(p_Req_LINE_DETAIL_qual_tbl(i).line_detail_Index)).price_adjustment_id is not null then
10023
10024 l_price_adjustment_id :=
10025 l_line_adj_Tbl(l_line_details_prcd(p_Req_LINE_DETAIL_qual_tbl(i).line_detail_Index)).price_adjustment_id ;
10026 Else
10027 l_price_adjustment_id := NULL;
10028 End If; -- Populate Adjustment_id
10029
10030 adj_debug('In Qual loop',2);
10031 Find_Duplicate_Adj_Attribs(
10032 p_Req_LINE_DETAIL_qual_Rec => p_Req_LINE_DETAIL_qual_tbl(i),
10033 p_Req_Line_Detail_Attr_Rec => l_Req_Line_Detail_Attr_Rec,
10034 p_Adj_index =>
10035 l_line_details_prcd(
10036 p_Req_LINE_DETAIL_qual_tbl(i).line_detail_Index),
10037 p_Line_Adj_Att_Tbl => l_Line_Adj_Att_tbl,
10038 p_Att_Type => 'QUALIFIER',
10039 p_price_adjustment_id => l_price_adjustment_id
10040 );
10041
10042 End If;
10043 i:= p_Req_LINE_DETAIL_qual_tbl.next(i);
10044 end loop;
10045
10046 -- Process Pricing Attributes
10047
10048 i:= p_Req_LINE_DETAIL_Attr_tbl.First;
10049 While i is not null Loop
10050 --For i in 1..p_Req_LINE_DETAIL_Attr_tbl.count loop
10051
10052 if l_line_details_prcd.exists(p_Req_LINE_DETAIL_Attr_tbl(i).line_detail_index)
10053 --or l_Rltd_line_details_prcd.exists(p_Req_LINE_DETAIL_Attr_tbl(i).line_detail_index)
10054 Then
10055
10056 If l_line_adj_Tbl.exists(l_line_details_prcd(p_Req_LINE_DETAIL_attr_tbl(i).line_detail_Index))
10057 and l_line_adj_Tbl(l_line_details_prcd(p_Req_LINE_DETAIL_attr_tbl(i).line_detail_Index)).price_adjustment_id <> FND_API.G_MISS_NUM and
10058 l_line_adj_Tbl(l_line_details_prcd(p_Req_LINE_DETAIL_attr_tbl(i).line_detail_Index)).price_adjustment_id is not null
10059 then
10060
10061 l_price_adjustment_id :=
10062 l_line_adj_Tbl(l_line_details_prcd(p_Req_LINE_DETAIL_attr_tbl(i).line_detail_Index)).price_adjustment_id ;
10063 Else
10064 l_price_adjustment_id := NULL;
10065 End If; -- Populate Adjustment_id
10066
10067 G_STMT_NO := 'process_adjustments#120';
10068 adj_debug('In Attr loop Index '||p_Req_LINE_DETAIL_Attr_tbl(i).line_detail_index,2);
10069 Find_Duplicate_Adj_Attribs(
10070 p_Req_LINE_DETAIL_qual_Rec => l_Req_LINE_DETAIL_qual_Rec,
10071 p_Req_LINE_DETAIL_Attr_Rec => p_Req_LINE_DETAIL_Attr_tbl(i),
10072 p_Adj_index =>
10073 l_line_details_prcd(
10074 p_Req_LINE_DETAIL_Attr_tbl(i).line_detail_Index),
10075 p_Line_Adj_Att_Tbl => l_Line_Adj_Att_tbl,
10076 p_Att_Type => 'PRICING',
10077 p_price_adjustment_id => l_price_adjustment_id
10078 );
10079 End If;
10080 i:= p_Req_LINE_DETAIL_Attr_tbl.Next(i);
10081 end loop;
10082
10083 adj_debug('Before cal #adjs '||l_Line_Adj_Tbl.count);
10084
10085 --If p_Req_Control_Rec.Calculate_Flag = QP_PREQ_GRP.G_SEARCH_ONLY Then
10086 -- The calculation Engine was not called , when the price request was made
10087 G_STMT_NO := 'process_adjustments#130';
10088
10089 i:=l_line_adj_tbl.first;
10090 adj_debug('before calling calculate_price');
10091 while i is not null loop
10092 adj_debug('line_index:'||l_line_adj_tbl(i).line_index);
10093 adj_debug('list line id:'||l_line_adj_tbl(i).list_line_id);
10094 adj_debug('operation : ' || l_line_adj_tbl(i).operation);
10095 IF (l_line_adj_tbl(i).operation = oe_globals.g_opr_delete
10096 and l_line_adj_tbl(i).list_line_type_code='PRG') THEN
10097
10098 adj_debug('Need to delete/update free goods line');
10099 /* 1503357 */
10100 OE_ORDER_ADJ_PVT.change_prg_lines(
10101 p_price_adjustment_id => l_line_adj_tbl(i).price_adjustment_id,
10102 p_line_tbl => l_line_tbl,
10103 p_line_adj_tbl => l_line_adj_tbl,
10104 p_delete_prg_lines => l_delete_prg_lines);
10105 END IF;
10106 i:=l_line_adj_tbl.next(i);
10107 End loop;
10108
10109 end if; ---enforce list price flag checked
10110
10111 Calculate_Price (
10112 p_Header_Rec => p_Header_Rec
10113 ,p_Line_Tbl => l_line_Tbl
10114 ,p_Line_Adj_Tbl => l_Line_Adj_Tbl
10115 ,p_line_adj_assoc_Tbl => l_line_adj_assoc_Tbl
10116 ,p_allow_negative_price => l_allow_negative_price
10117 ,p_request_Type_Code => p_request_Type_Code
10118 ,p_any_line_frozen => p_any_frozen_line
10119 ,p_price_event => p_req_control_rec.pricing_event --bug 2273446
10120 ,p_honor_price_flag => p_honor_price_flag --bug 2503186
10121 );
10122
10123
10124 adj_debug('After cal #adjs '||l_Line_Adj_Tbl.count);
10125
10126
10127 G_STMT_NO := 'process_adjustments#161';
10128 I:= l_line_tbl.First;
10129 while i is not null loop
10130
10131 If G_DEBUG Then
10132 adj_debug('--------------------------------------',2);
10133 adj_debug('index '||i,2);
10134 adj_debug('The list price before call'||l_line_tbl(i).unit_list_price_per_pqty,2);
10135 adj_debug('The selling price before call'||l_line_tbl(i).unit_Selling_price_per_pqty,2);
10136 adj_debug('The line id'||l_line_tbl(i).Line_id,2);
10137 adj_debug('The Inventory_item_id '||l_line_tbl(i).Inventory_item_id,2);
10138 adj_debug('The header id'||l_line_tbl(i).header_id,2);
10139 adj_debug('Payment_term , before process order '||l_line_tbl(i).payment_term_id,2);
10140 End If;
10141
10142 -- uom begin
10143 If oe_line_util.Get_Return_Item_Type_Code(l_line_tbl(i)) in ('INCLUDED', 'CONFIG') then
10144 l_line_tbl(i).unit_list_price_per_pqty := 0;
10145 end if;
10146
10147 If l_line_tbl(i).unit_Selling_price_per_pqty is null or
10148 oe_line_util.Get_Return_Item_Type_Code(l_line_tbl(i)) in ('INCLUDED', 'CONFIG')
10149 then
10150 l_line_tbl(i).unit_Selling_price_per_pqty := l_line_tbl(i).unit_list_price_per_pqty;
10151 end if;
10152
10153 If l_line_tbl(i).ordered_quantity IS NOT NULL and l_line_tbl(i).ordered_quantity <> 0
10154 then
10155 l_line_tbl(i).unit_selling_price := l_line_tbl(i).unit_selling_price_per_pqty * l_line_tbl(i).pricing_quantity/l_line_tbl(i).ordered_quantity;
10156
10157 l_line_tbl(i).unit_list_price := l_line_tbl(i).unit_list_price_per_pqty * l_line_tbl(i).pricing_quantity/l_line_tbl(i).ordered_quantity;
10158 end if;
10159
10160 -- OPM 2547940 start - if pricing by quantity2 then if line is shipped and has shipped qty2 != ordered qty2
10161 -- need to adjust the unit selling price so that invoicing will show correct amount (ordered qty * USP (adjusted) )
10162
10163 IF oe_line_util.dual_uom_control -- INVCONV
10164 (l_line_tbl(i).inventory_item_id
10165 ,l_line_tbl(i).ship_from_org_id
10166 ,l_item_rec) THEN
10167 IF l_item_rec.ont_pricing_qty_source = 'S' THEN -- price by quantity 2 -- INVCONV
10168 IF (l_line_tbl(i).ordered_quantity2 IS NOT NULL and l_line_tbl(i).ordered_quantity2 <> 0 )
10169 AND ( l_line_tbl(i).shipped_quantity2 IS NOT NULL and l_line_tbl(i).shipped_quantity2 <> 0 )
10170 AND l_line_tbl(i).ordered_quantity2 <> l_line_tbl(i).shipped_quantity2 THEN
10171 l_line_tbl(i).unit_selling_price := (l_line_tbl(i).unit_selling_price_per_pqty * l_line_tbl(i).pricing_quantity )/l_line_tbl(i).ordered_quantity2
10172 * (l_line_tbl(i).shipped_quantity2/l_line_tbl(i).ordered_quantity);
10173 l_line_tbl(i).unit_list_price := (l_line_tbl(i).unit_list_price_per_pqty * l_line_tbl(i).pricing_quantity )/l_line_tbl(i).ordered_quantity2
10174 * (l_line_tbl(i).shipped_quantity2/l_line_tbl(i).ordered_quantity);
10175 oe_debug_pub.ADD('OPM NEW USP : '|| to_char(l_line_tbl(i).unit_selling_price),5);
10176 END IF;
10177 END IF;
10178 END IF; --oe_line_util.dual_uom_control -- INVCONV
10179 -- OPM 2547940 end
10180
10181
10182 -- uom end
10183
10184
10185 adj_debug(' Values passed into QP_UTIL_PUB.round_price api:');
10186 adj_debug(' p_operand:'||l_line_tbl(i).unit_selling_price);
10187 adj_debug(' price_list_id:'||l_line_tbl(i).price_list_id);
10188 adj_debug(' currency_code:'||g_order_currency);
10189 adj_debug(' pricing_effective_date:'||l_line_tbl(i).pricing_date);
10190 If l_line_tbl(i).unit_selling_price is not null Then
10191 QP_UTIL_PUB.round_price(p_operand => l_line_tbl(i).unit_selling_price,
10192 p_rounding_factor => NULL,
10193 p_use_multi_currency => 'Y',
10194 p_price_list_id => l_line_tbl(i).price_list_id,
10195 p_currency_code => g_order_currency,
10196 p_pricing_effective_date => l_line_tbl(i).pricing_date,
10197 x_rounded_operand => l_line_tbl(i).unit_selling_price,
10198 x_status_code => l_status_code);
10199 adj_debug(' Rounded Unit Selling Price Returned By pricing API:'||l_line_tbl(i).unit_selling_price);
10200 adj_debug(' x_status_code:'||l_status_code);
10201 End If;
10202
10203
10204 -- If a service reference line of different order is present set the operation.
10205 If l_line_tbl(i).header_id <> l_header_rec.header_id then
10206 l_line_tbl(i).operation := oe_globals.g_opr_none;
10207 End If;
10208
10209
10210 -- Remove the holes in the structure.
10211 l_lines_prcd(i) := l_Line_Tbl_Final.Count+1;
10212
10213 l_Line_Tbl_Final(l_lines_prcd(i)) := l_line_tbl(i);
10214
10215 J:= x_line_tbl.First;
10216 While J is not null loop
10217 If x_line_tbl(j).line_id = l_line_tbl(i).line_id and
10218 l_line_tbl(i).line_id <> fnd_api.g_miss_num then
10219 l_old_line_tbl(l_Line_Tbl_Final.Count) := x_line_tbl(j);
10220 Exit;
10221 end if;
10222
10223 j:= x_line_tbl.next(j);
10224 End Loop;
10225
10226 l := l_line_tbl_final.count;
10227 adj_debug('operation'||l_line_tbl_final(l).operation,1);
10228 -- 2270949: logging message about free goods line
10229 if (l_line_Tbl_final(l).operation = OE_GLOBALS.G_OPR_CREATE) and p_write_to_db = TRUE then
10230 -- Display the PRG Item
10231 FND_MESSAGE.SET_NAME('ONT','ONT_CREATED_NEW_LINE');
10232 FND_MESSAGE.SET_TOKEN('ITEM',l_line_tbl_final(l).ordered_item);
10233 --bug 2412868 begin
10234 if l_line_tbl_final(l).line_category_code = 'RETURN' then
10235 FND_MESSAGE.SET_TOKEN('QUANTITY',(-1) * l_line_tbl_final(l).Ordered_quantity);
10236 else
10237 --bug 2412868 end
10238 FND_MESSAGE.SET_TOKEN('QUANTITY',l_line_tbl_final(l).Ordered_quantity);
10239 end if;
10240 OE_MSG_PUB.Add('N');
10241 OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
10242 end if;
10243 -- end 2270949
10244
10245 -- only Lock the lines that needs to be updated
10246 if (l_line_tbl_final(l).operation = FND_API.G_MISS_CHAR or
10247 l_line_tbl_final(l).operation = OE_GLOBALS.G_OPR_NONE or
10248 l_line_tbl_final(l).operation is null )
10249 and p_write_to_db = TRUE then
10250
10251
10252 /* Fix for bug 1889762
10253 Added condition to check if the old and new unit selling price are the same
10254 */
10255 /* Added an extra condition in the following If condition to check price_list has changed.
10256 This is done to fix the bug 2242256 */
10257 If (l_line_tbl_final(l).unit_selling_price_per_pqty = l_old_line_tbl(l).unit_selling_price_per_pqty AND
10258 l_line_tbl_final(l).unit_list_price_per_pqty = l_old_line_tbl(l).unit_list_price_per_pqty AND
10259 l_line_tbl_final(l).unit_selling_price = l_old_line_tbl(l).unit_selling_price AND
10260 l_line_tbl_final(l).price_list_id = l_old_line_tbl(l).price_list_id AND
10261 l_line_tbl_final(l).pricing_quantity = l_old_line_tbl(l).pricing_quantity AND
10262 l_line_tbl_final(l).pricing_quantity_uom = l_old_line_tbl(l).pricing_quantity_uom AND
10263 l_line_tbl_final(l).inventory_item_id = l_old_line_tbl(l).inventory_item_id AND
10264 ((l_line_tbl_final(l).payment_term_id IS NULL AND l_old_line_tbl(l).payment_term_id IS NULL) OR
10265 l_line_tbl_final(l).payment_term_id = l_old_line_tbl(l).payment_term_id) AND
10266 ((l_line_tbl_final(l).shipping_method_code IS NULL AND l_old_line_tbl(l).shipping_method_code IS NULL) OR
10267 l_line_tbl_final(l).shipping_method_code = l_old_line_tbl(l).shipping_method_code) AND
10268 ((l_line_tbl_final(l).freight_terms_code IS NULL AND l_old_line_tbl(l).freight_terms_code IS NULL) OR
10269 l_line_tbl_final(l).freight_terms_code = l_old_line_tbl(l).freight_terms_code)
10270 )AND
10271 ((l_line_tbl_final(l).price_request_code IS NULL AND l_old_line_tbl(l).price_request_code IS NULL) OR
10272 l_line_tbl_final(l).price_request_code =l_old_line_tbl(l).price_request_code)
10273
10274 then
10275 l_line_tbl_final(l).operation := OE_GLOBALS.G_OPR_NONE;
10276 adj_debug('do nothing to '||i||' '||l_old_line_tbl(l).line_id,1);
10277 Else
10278 l_line_tbl_final(l).operation := OE_GLOBALS.G_OPR_UPDATE;
10279 l_num_changed_lines := l_num_changed_lines + 1;
10280 adj_debug('lock row '||i||' '||l_old_line_tbl(l).line_id,1);
10281 OE_LINE_UTIL.Lock_Row(x_return_status => x_return_status,
10282 p_x_line_rec => l_old_line_tbl(l)
10283 );
10284
10285 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10286 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10287 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
10288 RAISE FND_API.G_EXC_ERROR;
10289 END IF;
10290
10291 End If;
10292 ELSIF p_write_to_db = TRUE THEN
10293 adj_debug('original operation'||l_line_tbl_final(l).operation);
10294 l_num_changed_lines := l_num_changed_lines + 1;
10295 End If;
10296
10297 i:= l_line_tbl.next(i);
10298 end loop;
10299 adj_debug('number of changed lines'||l_num_changed_lines||' out nocopy of'||l_line_tbl_final.count);
10300
10301
10302 -- Delete the record with operation not set
10303 G_STMT_NO := 'process_adjustments#140';
10304
10305 --currently for NOT write to db mode, which is getting-a-quote mode
10306 --this procedure is not returning adjustments details. Will
10307 --need to implement it in the later version where will return
10308 --adustment detail even if it is only a getting-a-quote mode.
10309 If p_write_to_db Then
10310
10311 i := l_line_adj_tbl.First;
10312
10313 While i is not null loop
10314
10315 If G_DEBUG Then
10316 adj_debug('----------------------',3);
10317 adj_debug('The Adjustment_id '||l_Line_Adj_Tbl(i).price_adjustment_id,3);
10318 adj_debug('The list_line_id '||l_Line_Adj_Tbl(i).list_line_id,3);
10319 adj_debug('The line_id '||l_Line_Adj_Tbl(i).line_id,3);
10320 adj_debug('The line_typ '||l_Line_Adj_Tbl(i).list_line_type_code,3);
10321 adj_debug('The operation '||l_Line_Adj_Tbl(i).operation,3);
10322 adj_debug('The adjusted amount '||l_Line_Adj_Tbl(i).adjusted_amount);
10323 End If;
10324
10325 -- Assign the new line index
10326 If l_line_adj_tbl(i).Line_Index is not null and
10327 l_line_adj_tbl(i).Line_Index <> fnd_api.g_miss_num and
10328 l_lines_prcd.exists(l_line_adj_tbl(i).Line_Index) then
10329 l_line_adj_tbl(i).Line_Index := l_lines_prcd(l_line_adj_tbl(i).Line_Index);
10330 End If;
10331
10332 adj_debug(' The line_index:'||l_line_adj_tbl(i).Line_Index);
10333 -- bug 2089312
10334 -- to check if it is a Header Level Adjustment
10335 IF (l_Line_Adj_Tbl(i).line_id is null or
10336 l_Line_Adj_Tbl(i).line_id = fnd_api.g_miss_num)
10337 AND (l_Line_Adj_Tbl(i).line_index is null or
10338 l_Line_Adj_Tbl(i).line_index = fnd_api.g_miss_num)
10339 AND l_Line_Adj_Tbl(i).Header_Id = p_header_Rec.Header_Id
10340 AND l_Line_Adj_Tbl(i).operation IN (OE_GLOBALS.G_OPR_CREATE, OE_GLOBALS.G_OPR_UPDATE, OE_GLOBALS.G_OPR_DELETE)
10341 AND l_Line_Adj_Tbl(i).list_line_type_code NOT IN ('FREIGHT_CHARGE','TAX','COST')
10342 AND nvl(g_pass_all_lines,'N') <> 'Y' THEN
10343 -- This is a header level adjustments, and not a freight charge.
10344 -- Need to log a delayed request to apply this header level adjustment
10345 -- to all lines on this order if not all lines were passed to pricing engine.
10346
10347 adj_debug('Logging request to update all lines for header level adjustment.', 1);
10348 OE_DELAYED_REQUESTS_PVT.LOG_REQUEST(
10349 p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
10350 p_entity_id => l_Line_adj_tbl(i).header_id,
10351 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_HEADER,
10352 p_requesting_entity_id => l_Line_adj_tbl(i).header_id,
10353 p_request_type => OE_GLOBALS.G_PRICE_ADJ,
10354 x_return_status => l_return_status);
10355
10356 END IF;
10357
10358
10359 G_STMT_NO := 'process_adjustments#140.1';
10360 -- Update the Header Level TERM Substitution on all Lines.
10361 If l_header_rec.operation = oe_globals.g_opr_update then
10362 If l_line_adj_tbl(i).list_line_type_code = 'TSN' and
10363 l_line_adj_tbl(i).modifier_level_code ='ORDER'
10364 then
10365 adj_debug('In Header TSN ');
10366 adj_debug('Attribute '||l_line_adj_tbl(i).substitution_attribute);
10367 -- Loop through all the lines and update
10368 j:= l_Line_Tbl_Final.first;
10369 while j is not null loop
10370 -- Check if there is a line level term substitution
10371 l_Line_Term := FALSE;
10372 k:= l_line_adj_tbl.First;
10373 while k is not null loop
10374 If l_line_adj_tbl(k).line_index = J and
10375 l_line_adj_tbl(k).list_line_type_code = 'TSN' and
10376 l_line_adj_tbl(k).substitution_attribute = l_line_adj_tbl(i).substitution_attribute
10377 Then
10378 l_line_term := TRUE;
10379 Exit;
10380 End If;
10381 k:= l_line_adj_tbl.Next(k);
10382 End Loop; -- line_adj K
10383
10384 If not l_line_term then
10385
10386 If l_line_adj_tbl(i).Substitution_Attribute ='QUALIFIER_ATTRIBUTE1' Then
10387 adj_debug('Updating Payment term '||l_line_adj_tbl(i).Modified_to);
10388 l_Line_Tbl_Final(j).payment_term_id := l_line_adj_tbl(i).Modified_to;
10389 elsIf l_line_adj_tbl(i).Substitution_Attribute ='QUALIFIER_ATTRIBUTE11' Then
10390 adj_debug('Updating shipping_method_code '||l_line_adj_tbl(i).Modified_to);
10391 l_Line_Tbl_Final(j).shipping_method_code := l_line_adj_tbl(i).Modified_to;
10392
10393 elsIf l_line_adj_tbl(i).Substitution_Attribute ='QUALIFIER_ATTRIBUTE10' Then
10394 adj_debug('Updating freight_terms_code '||l_line_adj_tbl(i).Modified_to);
10395 l_Line_Tbl_Final(j).freight_terms_code := l_line_adj_tbl(i).Modified_to;
10396
10397 End If;
10398 If (l_Line_Tbl_Final(j).operation = OE_GLOBALS.G_OPR_NONE) Then
10399 l_Line_Tbl_Final(j).operation := OE_GLOBALS.G_OPR_UPDATE;
10400 End If;
10401 --adj_debug('----------------------');
10402 End If;
10403
10404 --
10405 IF l_Line_Tbl_Final(j).booked_flag = 'Y' THEN
10406 --
10407 IF l_Line_Tbl_Final(j).unit_selling_price IS NULL
10408 OR l_line_tbl_final(j).unit_list_price IS NULL
10409 OR l_line_tbl_final(j).price_list_id IS NULL THEN
10410 --
10411 l_item_type_code := oe_line_util.Get_Return_Item_Type_Code(l_Line_Tbl_Final(j));
10412 --
10413 IF (l_item_type_code <> 'CONFIG'
10414 AND l_item_type_code <> 'INCLUDED') THEN
10415 --
10416 --
10417 If l_Line_Tbl_Final(j).unit_selling_price IS NULL Then
10418 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
10419 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
10420 OE_Order_UTIL.Get_Attribute_Name('UNIT_SELLING_PRICE'));
10421 OE_MSG_PUB.ADD;
10422 End If;
10423
10424 If l_line_tbl_final(j).unit_list_price IS NULL Then
10425 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
10426 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
10427 OE_Order_UTIL.Get_Attribute_Name('UNIT_LIST_PRICE'));
10428 OE_MSG_PUB.ADD;
10429 End If;
10430
10431 If l_line_tbl_final(j).price_list_id IS NULL Then
10432 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
10433 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','LIST PRICE');
10434 OE_MSG_PUB.ADD;
10435 End If;
10436
10437 RAISE FND_API.G_EXC_ERROR;
10438 --
10439 END IF;
10440 --
10441 END IF;
10442 --
10443 END IF;
10444 --
10445
10446 j:= l_Line_Tbl_Final.next(j);
10447 end loop;
10448
10449 End If;
10450 end if;
10451 G_STMT_NO := 'process_adjustments#140.2';
10452 if l_line_adj_tbl(i).operation = fnd_api.g_miss_char or
10453 l_Line_Adj_Tbl(i).list_line_type_code in ('TAX','COST')
10454 or l_line_adj_tbl(i).operation is null
10455 or l_line_adj_tbl(i).operation =oe_globals.g_opr_none then
10456 l_line_adj_tbl.delete(i);
10457 Elsif l_line_adj_tbl(i).operation = oe_globals.g_opr_update and
10458 ( l_line_adj_tbl(i).price_adjustment_id is null or
10459 l_line_adj_tbl(i).price_adjustment_id = fnd_api.g_miss_num ) then
10460 l_line_adj_tbl(i).operation := oe_globals.g_opr_Create;
10461 ELsif l_line_adj_tbl(i).line_id IS NOT NULL and
10462 l_line_adj_tbl(i).line_id <> FND_API.G_MISS_NUM and
10463 l_delete_prg_lines.exists(l_line_adj_tbl(i).line_id) THEN
10464 l_line_adj_tbl.delete(i);
10465 End if;
10466
10467
10468 i:= l_line_adj_tbl.next(i);
10469 End loop;
10470
10471 G_STMT_NO := 'process_adjustments#150';
10472 i:= l_line_adj_att_tbl.First;
10473
10474 while i is not null loop
10475 If G_DEBUG Then
10476 adj_debug('Adj Index '||l_line_adj_Att_tbl(i).Adj_Index,3);
10477 Adj_Debug('The Price Adj '||l_line_adj_Att_tbl(i).price_adjustment_id,3);
10478 Adj_Debug('Operation '||l_line_adj_Att_tbl(i).operation,3);
10479 Adj_Debug('flex_title '||l_line_adj_Att_tbl(i).flex_title,3);
10480 Adj_Debug('pricing_context '||l_line_adj_Att_tbl(i).pricing_context,3);
10481 Adj_Debug('pricing_attribute '||l_line_adj_Att_tbl(i).pricing_attribute,3);
10482 Adj_Debug('pricing_attr_value_from '||l_line_adj_Att_tbl(i).pricing_attr_value_from,3);
10483 Adj_Debug('pricing_attr_value_To '||l_line_adj_Att_tbl(i).pricing_attr_value_To,3);
10484 Adj_Debug('comparison_operator '||l_line_adj_Att_tbl(i).comparison_operator,3);
10485 Adj_Debug('------------------------------',3);
10486 End If;
10487
10488 if l_line_adj_Att_tbl(i).operation = fnd_api.g_miss_char then
10489 l_line_adj_Att_tbl.delete(i);
10490 Elsif l_line_adj_Att_tbl(i).price_adjustment_id = fnd_api.g_miss_num or
10491 l_line_adj_Att_tbl(i).price_adjustment_id is null Then
10492
10493 -- Check if the adjustment record exists
10494 If l_line_adj_Att_tbl(i).Adj_Index = fnd_api.g_miss_num Then
10495 l_line_adj_Att_tbl.delete(i);
10496 ElsIf Not l_line_adj_tbl.exists(l_line_adj_Att_tbl(i).Adj_Index) Then
10497 l_line_adj_Att_tbl.delete(i);
10498 End If;
10499
10500 end if;
10501
10502 i:= l_line_adj_att_tbl.next(i);
10503
10504 End loop;
10505
10506
10507 G_STMT_NO := 'process_adjustments#160';
10508 i:= l_Line_Adj_Assoc_tbl.First;
10509 While i is not null loop
10510 If G_Debug Then
10511 adj_debug('Assocs: adj index '||l_Line_Adj_Assoc_tbl(i).adj_index,3);
10512 adj_debug('Assocs: rltd adj index '||l_Line_Adj_Assoc_tbl(i).Rltd_Adj_Index,3);
10513 adj_debug('Assocs: price adj '||l_Line_Adj_Assoc_tbl(i).price_adjustment_id,3);
10514 adj_debug('Assocs: rltd price adj '||l_Line_Adj_Assoc_tbl(i).rltd_Price_Adj_Id,3);
10515 adj_debug('---------------------------',3);
10516 End If;
10517 If l_Line_Adj_Assoc_tbl(i).operation = Fnd_Api.g_Miss_Char Then
10518 l_Line_Adj_Assoc_tbl.delete(i);
10519 Else
10520 if l_Line_Adj_Assoc_tbl(i).Price_Adjustment_Id = fnd_Api.g_miss_num and
10521 l_Line_Adj_Assoc_tbl(i).adj_index = fnd_Api.g_miss_num Then
10522 l_Line_Adj_Assoc_tbl.delete(i);
10523 Elsif l_Line_Adj_Assoc_tbl(i).Adj_Index <> fnd_Api.g_miss_num and
10524 Not l_line_adj_tbl.exists(l_Line_Adj_Assoc_tbl(i).Adj_Index) Then
10525 l_Line_Adj_Assoc_tbl.delete(i);
10526 Elsif l_Line_Adj_Assoc_tbl(i).rltd_Price_Adj_Id = fnd_Api.g_miss_num and
10527 l_Line_Adj_Assoc_tbl(i).Rltd_Adj_Index = fnd_Api.g_miss_num Then
10528 l_Line_Adj_Assoc_tbl.delete(i);
10529 Elsif l_Line_Adj_Assoc_tbl(i).Rltd_Adj_Index <> fnd_Api.g_miss_num and
10530 Not l_line_adj_tbl.exists(l_Line_Adj_Assoc_tbl(i).Rltd_Adj_Index) Then
10531 IF l_line_detail_replaced.exists(l_line_adj_assoc_tbl(i).rltd_adj_index) THEN
10532 l_line_adj_assoc_tbl(i).rltd_adj_index
10533 := l_line_detail_replaced(l_line_adj_assoc_tbl(i).rltd_adj_index);
10534 ELSE
10535 l_Line_Adj_Assoc_tbl.delete(i);
10536 END IF;
10537 End If;
10538 End If;
10539 i:= l_Line_Adj_Assoc_tbl.next(i);
10540 End Loop;
10541
10542 G_STMT_NO := 'process_adjustments#170.0';
10543 If G_Debug Then
10544 adj_debug('Header id '||l_header_rec.header_id);
10545 adj_debug('payment term '||l_header_rec.payment_term_id);
10546 adj_debug('Ship term '||l_header_rec.shipping_method_code);
10547 adj_debug('Freight term '||l_header_rec.freight_terms_code);
10548 adj_debug('operantion '||l_header_rec.operation);
10549 adj_debug('---------------------------');
10550 End If;
10551
10552 G_STMT_NO := 'process_adjustments#170';
10553 End If; --end if for p_write_to_db mode
10554
10555 -- Audit Trail reason code passed #3006072 */
10556
10557 adj_debug('Line final table count is : '||l_line_tbl_final.count);
10558
10559 IF l_line_tbl_final.count > 0 THEN
10560
10561 FOR rec_cnt in l_line_tbl_final.first..l_line_tbl_final.last LOOP
10562
10563 adj_debug('Line ID processed : '||l_line_tbl_final(rec_cnt).line_id);
10564
10565 l_line_tbl_final(rec_cnt).change_reason := 'SYSTEM';
10566 l_line_tbl_final(rec_cnt).change_comments := 'PRICING';
10567
10568 END LOOP;
10569
10570 END IF;
10571
10572 -- bug 2404990 begin
10573 x_line_tbl := l_line_tbl_final;
10574 IF (p_write_to_db and l_num_changed_lines<1+l_line_tbl_final.count/2) THEN
10575 j:= l_Line_Tbl_Final.first;
10576 while j is not null loop
10577 IF (l_line_tbl_final(j).operation = OE_GLOBALS.G_OPR_NONE) THEN
10578 l_line_tbl_Final.delete(j);
10579 END IF;
10580 j:= l_Line_Tbl_Final.next(j);
10581 end loop;
10582
10583 End If; --end if for p_write_to_db mode
10584 -- bug 2404990 end
10585
10586
10587 If p_Write_To_Db and
10588 ( l_line_tbl_Final.count > 0 or
10589 l_Line_Adj_tbl.count > 0 or
10590 l_Line_Adj_att_tbl.count > 0 or
10591 l_Line_Adj_Assoc_tbl.count > 0
10592 )
10593 Then
10594
10595
10596 -- set control record
10597 l_control_rec.controlled_operation := TRUE;
10598 l_control_rec.write_to_DB := TRUE;
10599 l_control_rec.change_attributes := TRUE;
10600 l_control_rec.default_attributes := TRUE;
10601 l_control_rec.validate_entity := TRUE;
10602 l_control_rec.clear_dependents := TRUE;
10603 --change made for bug 2351099 Begin
10604 --2366123: execute delayed requests if not from UI
10605 if (NOT OE_GLOBALS.G_UI_FLAG ) then
10606 l_control_rec.process := TRUE;
10607 else
10608 l_control_rec.process := FALSE;
10609 end if;
10610 --change made for bug 2351099 End
10611 l_control_rec.clear_api_cache := FALSE;
10612 l_control_rec.clear_api_requests := FALSE;
10613
10614
10615 -- Call OE_Order_PVT.Process_order
10616
10617 adj_debug('Before OE_Order_PVT.Process_order',1);
10618 IF (oe_globals.G_CASCADING_REQUEST_LOGGED) THEN
10619 adj_debug('inside price line: cascading set');
10620 ELSE
10621 adj_debug('inside price line: cascading not set');
10622 END IF;
10623 -- OE_Globals.G_RECURSION_MODE := 'Y';
10624 OE_Globals.G_PRICING_RECURSION := 'Y';
10625
10626 G_STMT_NO := 'Failure in Process_Order API Call';
10627 --cc1
10628 IF (p_Req_Control_Rec.pricing_event = 'PRICE' AND
10629 l_Line_Adj_tbl.count = 0 AND
10630 l_Line_Adj_att_tbl.count = 0 AND
10631 l_Line_Adj_Assoc_tbl.count = 0
10632 ) THEN
10633 OE_ORDER_PVT.Lines
10634 ( p_validation_level => FND_API.G_VALID_LEVEL_FULL
10635 , p_control_rec => l_control_rec
10636 , p_x_line_tbl => l_line_tbl_Final
10637 , p_x_old_line_tbl => l_old_line_tbl
10638 , x_return_status => x_return_status
10639 );
10640
10641 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10642 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10643 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
10644 RAISE FND_API.G_EXC_ERROR;
10645 END IF;
10646
10647 ELSE
10648 OE_Order_PVT.Process_order
10649 ( p_api_version_number => 1.0
10650 , x_return_status => x_return_status
10651 , x_msg_count => l_x_msg_count
10652 , x_msg_data => l_x_msg_data
10653 , p_control_rec => l_control_rec
10654 , p_x_Header_rec => l_header_rec
10655 , p_x_line_tbl => l_line_tbl_Final
10656 , p_x_Line_Adj_tbl => l_Line_Adj_tbl
10657 , p_x_Line_Adj_att_tbl => l_Line_Adj_att_tbl
10658 , p_x_Line_Adj_Assoc_tbl => l_Line_Adj_Assoc_tbl
10659 , p_old_line_tbl => l_old_line_tbl
10660 -- , x_header_rec => l_x_header_rec
10661 , p_x_Header_Adj_tbl => l_x_Header_Adj_tbl
10662 , p_x_header_price_att_tbl => l_x_header_price_att_tbl
10663 , p_x_Header_Adj_att_tbl => l_x_Header_Adj_att_tbl
10664 , p_x_Header_Adj_Assoc_tbl => l_x_Header_Adj_Assoc_tbl
10665 , p_x_Header_Scredit_tbl => l_x_Header_Scredit_tbl
10666 --serla begin
10667 , p_x_Header_Payment_tbl => l_x_Header_Payment_tbl
10668 --serla end
10669 -- , x_line_tbl => l_x_line_tbl
10670 -- , x_Line_Adj_tbl => l_x_Line_Adj_tbl
10671 , p_x_Line_Price_att_tbl => l_x_Line_Price_att_tbl
10672 -- , x_Line_Adj_att_tbl => l_x_Line_Adj_att_tbl
10673 -- , x_Line_Adj_Assoc_tbl => l_x_Line_Adj_Assoc_tbl
10674 , p_x_Line_Scredit_tbl => l_x_Line_Scredit_tbl
10675 --serla begin
10676 , p_x_Line_Payment_tbl => l_x_Line_Payment_tbl
10677 --serla end
10678 , p_x_Lot_Serial_tbl => l_x_Lot_Serial_Tbl
10679 , p_x_action_request_tbl => l_x_Action_Request_tbl
10680 );
10681
10682 -- OE_Globals.G_RECURSION_MODE := 'N';
10683 OE_Globals.G_PRICING_RECURSION := 'N';
10684
10685 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10686 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10687 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
10688 RAISE FND_API.G_EXC_ERROR;
10689 END IF;
10690
10691 END IF;
10692
10693 G_STMT_NO := 'process_adjustments#140';
10694 /*
10695 -- Process Requests for Pricing line (for new line created for PRG)
10696 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
10697 (p_request_type =>OE_GLOBALS.G_PRICE_LINE
10698 ,p_delete => FND_API.G_TRUE
10699 ,x_return_status => x_return_status
10700 );
10701 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10702 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10703 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
10704 RAISE FND_API.G_EXC_ERROR;
10705 END IF;
10706 */
10707 End If;
10708
10709 -- x_Line_Tbl := l_Line_Tbl_Final;
10710 G_STMT_NO := 'process_adjustments#150';
10711
10712 -- Performance change for Legato
10713 -- Not refresh order when no attributes changed
10714 -- Freight charge change doesn't result in line change
10715 If p_req_control_rec.pricing_event in ('ORDER','SHIP','BOOK', 'BATCH') then
10716 IF (l_num_changed_lines > 0) THEN
10717 adj_debug('setting cascading flag to refresh order');
10718 OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
10719 END IF;
10720 Elsif INSTR(p_req_control_rec.pricing_event,'ORDER') > 0 or
10721 INSTR(p_req_control_rec.pricing_event,'BOOK') > 0 or
10722 INSTR(p_req_control_rec.pricing_event,'BATCH') > 0 or
10723 INSTR(p_req_control_rec.pricing_event,'SHIP') > 0 then
10724 IF (l_num_changed_lines > 0) THEN
10725 adj_debug(' multiple events setting cascading flag to refresh order');
10726 OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
10727 END IF;
10728 End if;
10729
10730 adj_debug('Exiting oe_order_Adj_pvt.process_adjustments',1);
10731
10732
10733 EXCEPTION
10734
10735 WHEN FND_API.G_EXC_ERROR THEN
10736
10737 x_return_status := FND_API.G_RET_STS_ERROR;
10738 adj_debug(' exc_error'||g_stmt_no||' '||sqlerrm||' '||l_x_msg_data,1);
10739 -- OE_Globals.G_RECURSION_MODE := 'N';
10740 OE_Globals.G_PRICING_RECURSION := 'N';
10741
10742 RAISE FND_API.G_EXC_ERROR;
10743 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
10744
10745 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
10746 adj_debug(' '||g_stmt_no||' '||sqlerrm||' '||l_x_msg_data,1);
10747
10748 -- OE_Globals.G_RECURSION_MODE := 'N';
10749 OE_Globals.G_PRICING_RECURSION := 'N';
10750 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10751
10752 WHEN OTHERS THEN
10753
10754 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
10755 --dbms_output.put_line('Error is '||sqlerrm);
10756 adj_debug('Error in oe_order_Adj_pvt.process_adjustments',1);
10757 adj_debug(' '||g_stmt_no||' '||sqlerrm,1);
10758
10759 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
10760 THEN
10761 OE_MSG_PUB.Add_Exc_Msg
10762 ( G_PKG_NAME
10763 , 'oe_order_Adj_pvt.process_adjustments',
10764 g_stmt_no||' '||sqlerrm
10765 );
10766 END IF;
10767
10768 -- OE_Globals.G_RECURSION_MODE := 'N';
10769 OE_Globals.G_PRICING_RECURSION := 'N';
10770 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10771
10772 end process_adjustments;
10773
10774 Procedure Populate_Pricing_Phases(p_pricing_event in Varchar2) Is
10775
10776 Cursor get_phases(l_event_code1 in Varchar2) Is
10777 Select e.Pricing_Phase_Id,nvl(p.user_freeze_override_flag,p.freeze_override_flag) freeze_override_flag
10778 from qp_event_Phases e, qp_pricing_phases p
10779 where e.pricing_phase_id = p.pricing_phase_id and
10780 trunc(sysdate) between Trunc(nvl(start_date_active,sysdate)) and
10781 trunc(nvl(End_Date_Active,sysdate))
10782 and e.pricing_event_code IN
10783 (SELECT decode(rownum
10784 ,1 ,substr(p_pricing_event,1,instr(l_event_code1,',',1,1)-1)
10785 ,2 ,substr(p_pricing_event , instr(l_event_code1,',',1,rownum-1) + 1,
10786 instr(l_event_code1,',',1,rownum)-1 - instr(l_event_code1,',',1,rownum-1))
10787 ,3 ,substr(p_pricing_event , instr(l_event_code1,',',1,rownum-1) + 1,
10788 instr(l_event_code1,',',1,rownum)-1 - instr(l_event_code1,',',1,rownum-1))
10789 ,4 ,substr(p_pricing_event , instr(l_event_code1,',',1,rownum-1) + 1,
10790 instr(l_event_code1,',',1,rownum)-1 - instr(l_event_code1,',',1,rownum-1))
10791 ,5 ,substr(p_pricing_event , instr(l_event_code1,',',1,rownum-1) + 1,
10792 instr(l_event_code1,',',1,rownum)-1 - instr(l_event_code1,',',1,rownum-1))
10793 ,6 ,substr(p_pricing_event , instr(l_event_code1,',',1,rownum-1) + 1,
10794 instr(l_event_code1,',',1,rownum)-1 - instr(l_event_code1,',',1,rownum-1)))
10795 FROM qp_event_phases
10796 WHERE rownum < 7);
10797 Begin
10798
10799 G_Pricing_Phase_Id_Tbl.delete;
10800 --null;
10801 For i in get_phases(p_pricing_event||',') Loop
10802 G_Pricing_Phase_id_Tbl(i.pricing_phase_id):=i.freeze_override_flag;
10803 adj_debug('Pricing Phase:'||i.pricing_phase_id);
10804 adj_debug('Freeze Override:'||i.freeze_override_flag);
10805 End Loop;
10806 End;
10807
10808 Function Bypass_Performance_Path(
10809 p_Header_id Number Default Null
10810 , p_Line_id Number Default Null
10811 , px_line_tbl IN OUT NOCOPY OE_Order_Pub.Line_Tbl_Type
10812 ) Return Boolean
10813 IS
10814 l_source_document_type_id NUMBER;
10815 l_booked_flag Varchar2(1);
10816 l_header_rec OE_Order_PUB.Header_Rec_Type;
10817 l_header_id NUMBER;
10818 l_tmp_no number;
10819 Begin
10820
10821 IF OE_GLOBALS.G_GMI_INSTALLED IS NULL THEN -- OPM 2547940 start GMA = OPM
10822 OE_GLOBALS.G_GMI_INSTALLED := OE_GLOBALS.CHECK_PRODUCT_INSTALLED(550);
10823 END IF;
10824
10825 If (OE_GLOBALS.G_GMI_INSTALLED = 'Y')
10826 and nvl(OE_LINE_ADJ_UTIL.G_OPM_ITEM_CATCHWEIGHT_USED,'N') = 'Y' -- bug 2965218
10827 Then
10828 adj_debug('OPM - GMA installed');
10829 RETURN TRUE;
10830 End If; -- OPM 2547940 end
10831
10832
10833 IF OE_GLOBALS.G_ASO_INSTALLED IS NULL THEN
10834 OE_GLOBALS.G_ASO_INSTALLED := OE_GLOBALS.CHECK_PRODUCT_INSTALLED(697);
10835 END IF;
10836
10837 If (OE_GLOBALS.G_ASO_INSTALLED = 'N') Then
10838 adj_debug('aso not installed');
10839 RETURN FALSE;
10840 End If;
10841
10842 IF (nvl(fnd_profile.value('ONT_ALWAYS_PERF_PATH'), 'N') = 'Y') THEN
10843 adj_debug('always use performance path');
10844 RETURN FALSE;
10845 END IF;
10846
10847 -- ASO installed; check whether it's a CRM order
10848 If (p_Header_id Is Not Null AND p_header_id <> FND_API.G_MISS_NUM) Then
10849 adj_debug('query source document type for header :'||p_header_id);
10850 OE_Header_Util.Query_Row(p_header_id => p_header_id
10851 , x_header_rec => l_header_rec);
10852 l_source_document_type_id := l_header_rec.source_document_type_id;
10853 l_booked_flag := l_header_rec.booked_flag;
10854 l_header_id := p_header_id;
10855 Else
10856 if (px_line_tbl.count = 0 and (p_line_id is Null OR p_line_id = FND_API.G_MISS_NUM)) Then
10857
10858 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
10859 THEN
10860
10861 FND_MESSAGE.SET_NAME('ONT','OE_ATTRIBUTE_REQUIRED');
10862 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','line_id or Header Id ');
10863 OE_MSG_PUB.Add;
10864 END IF;
10865 RAISE FND_API.G_EXC_ERROR;
10866 elsif (px_line_Tbl.count = 0) Then
10867 OE_Line_Util.Query_Rows(p_line_id => p_line_id
10868 , x_line_tbl => px_line_tbl);
10869 end if;
10870 adj_debug('lines count'||px_line_tbl.count);
10871 l_source_document_type_id := px_line_Tbl(1).source_document_type_id;
10872 l_booked_flag := px_line_Tbl(1).booked_flag;
10873 l_header_id := px_line_tbl(1).header_id;
10874 End If;
10875
10876 adj_debug('source_document_type:'||l_source_document_type_id);
10877 If (nvl(l_booked_flag, 'N') = 'Y'
10878 and nvl(l_source_document_type_id, 0) IN (1, 3, 4, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18 , 19))
10879 Then
10880 adj_debug('booked CRM order');
10881 Return TRUE;
10882 Elsif (nvl(l_booked_flag, 'N') = 'Y') --begin 2608577
10883 Then
10884 -- check whether there is an AMS modifier defined
10885 adj_debug('in ams mod check ');
10886 BEGIN
10887 SELECT 1 into l_tmp_no from dual where exists (
10888 select 1 from qp_list_headers_b qh
10889 , oe_order_headers_all oh
10890 where qh.currency_code = oh.transactional_curr_code
10891 and oh.header_id = l_header_id
10892 and qh.source_system_code='AMS'
10893 and qh.active_flag = 'Y');
10894 EXCEPTION
10895 WHEN NO_DATA_FOUND THEN
10896 RETURN FALSE;
10897 WHEN OTHERS THEN
10898 NULL;
10899 END;
10900 RETURN TRUE; -- end 2608577
10901 Else
10902 Return FALSE;
10903 End If;
10904 EXCEPTION
10905 WHEN FND_API.G_EXC_ERROR THEN
10906 RAISE FND_API.G_EXC_ERROR;
10907 WHEN OTHERS THEN
10908 adj_debug('error in bypass_performance_path'||sqlerrm);
10909 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10910 End Bypass_Performance_Path;
10911
10912 Procedure Price_line(
10913 X_Return_Status out nocopy Varchar2
10914
10915 ,p_Line_id Number Default Null
10916 ,p_Header_id Number Default Null
10917 ,p_Request_Type_code Varchar2
10918 ,p_Control_Rec QP_PREQ_GRP.control_record_type
10919 ,p_write_to_db Boolean Default TRUE
10920 ,p_request_rec OE_Order_PUB.request_rec_type default oe_order_pub.G_MISS_REQUEST_REC
10921 ,x_line_Tbl in out nocopy oe_Order_Pub.Line_Tbl_Type
10922 ,p_honor_price_flag VARCHAR2 Default 'Y'
10923 ,p_multiple_events in Varchar2 default 'N'
10924 ,p_action_code in Varchar2 default Null
10925 )
10926 is
10927 l_return_status varchar2(10);
10928 l_Control_Rec QP_PREQ_GRP.CONTROL_RECORD_TYPE;
10929 l_req_line_tbl QP_PREQ_GRP.LINE_TBL_TYPE;
10930 l_Req_qual_tbl QP_PREQ_GRP.QUAL_TBL_TYPE;
10931 l_Req_line_attr_tbl QP_PREQ_GRP.LINE_ATTR_TBL_TYPE;
10932 l_Req_LINE_DETAIL_tbl QP_PREQ_GRP.LINE_DETAIL_TBL_TYPE;
10933 l_Req_LINE_DETAIL_qual_tbl QP_PREQ_GRP.LINE_DETAIL_QUAL_TBL_TYPE;
10934 l_Req_LINE_DETAIL_attr_tbl QP_PREQ_GRP.LINE_DETAIL_ATTR_TBL_TYPE;
10935 l_Req_related_lines_tbl QP_PREQ_GRP.RELATED_LINES_TBL_TYPE;
10936 lx_Header_Rec oe_Order_Pub.Header_REc_Type;
10937 l_dummy varchar2(1);
10938 l_any_frozen_line Boolean;
10939 l_price_control_rec OE_ORDER_PRICE_pvt.control_rec_type;
10940 --For bug#2675212
10941 i pls_integer;
10942 l_call_process_adjustments varchar2(1) := 'N';
10943 cursor check_lines is
10944 select 'x' from qp_event_phases ep
10945 where ep.pricing_event_code = p_control_rec.pricing_event
10946 and trunc(sysdate) between trunc(nvl(start_date_active, sysdate)) and
10947 trunc(nvl(end_date_active, sysdate));
10948 /*cursor check_lines2 is
10949 select 'x' from qp_event_phases ep
10950 where ep.pricing_event_code IN ('BATCH','BOOK','SHIP')
10951 and trunc(sysdate) between trunc(nvl(start_date_active, sysdate)) and
10952 trunc(nvl(end_date_active, sysdate));*/
10953
10954 cursor check_lines2 is
10955 select 'x' from qp_event_phases ep
10956 where instr(p_control_rec.pricing_event||',',
10957 ep.pricing_event_code||',') > 0
10958 and trunc(sysdate) between trunc(nvl(start_date_active, sysdate)) and
10959 trunc(nvl(end_date_active, sysdate));
10960
10961 l_multiple_events VARCHAR2(1);
10962 cursor unfrozen_lines is
10963 select 'x' from dual where
10964 exists (select 'x' from oe_order_lines where header_id = p_header_id
10965 and calculate_price_flag in ('Y','P'));
10966 begin
10967 x_return_status := FND_API.G_RET_STS_SUCCESS;
10968
10969 --btea perf begin
10970 If OE_DEBUG_PUB.G_DEBUG = FND_API.G_TRUE Then
10971 G_DEBUG := TRUE;
10972 adj_debug('Entering oe_order_Adj_pvt.Price_line',1);
10973 adj_debug('Version:'||get_version);
10974 Else
10975 G_DEBUG := FALSE;
10976 End If;
10977 --btea perf end
10978
10979
10980 Populate_Pricing_Phases(p_control_rec.pricing_event);
10981
10982 IF (INSTR(p_control_rec.pricing_event, ',') > 0) THEN
10983 l_multiple_events := 'Y';
10984 ELSE
10985 l_multiple_events := 'N';
10986 END IF;
10987
10988 If l_multiple_events = 'N' Then
10989 open check_lines;
10990 fetch check_lines into l_dummy;
10991 IF check_lines%NOTFOUND THEN
10992 close check_lines;
10993 RETURN;
10994 End If;
10995 Else
10996 Oe_Debug_Pub.add('In Multiple events');
10997 open check_lines2;
10998 fetch check_lines2 into l_dummy;
10999 IF check_lines2%NOTFOUND THEN
11000 close check_lines2;
11001 RETURN;
11002 End If;
11003 END IF;
11004
11005 -- 2378843: check the existence of any line with 'Partial Price' or 'Calculate Price'
11006 IF (p_header_id IS NOT NULL and p_honor_price_flag = 'Y' and p_control_rec.pricing_event <> 'SHIP') THEN
11007 open unfrozen_lines;
11008 fetch unfrozen_lines into l_dummy;
11009 IF unfrozen_lines%NOTFOUND THEN
11010 close unfrozen_lines;
11011 adj_debug('all lines frozen, returning from price_line');
11012 RETURN;
11013 END IF;
11014 close unfrozen_lines;
11015 END IF;
11016 -- End 2378843
11017
11018 IF (G_11IG_PERFORMANCE = 'Y' AND QP_UTIL_PUB.Basic_Pricing_Setup = 'Y'
11019 AND Not Bypass_Performance_Path( p_header_id => p_header_id
11020 , p_line_id => p_line_id
11021 , px_line_Tbl => x_line_tbl))
11022 OR OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
11023 l_price_control_rec.p_request_type_code:=p_request_type_code;
11024 l_Price_control_rec.p_write_to_db:=p_write_to_db;
11025 l_price_control_rec.p_honor_price_flag:=p_honor_price_flag;
11026 l_price_control_rec.p_multiple_events:=l_multiple_events;
11027 l_price_control_rec.p_get_freight_flag := p_Control_rec.get_freight_flag;
11028
11029 oe_order_price_pvt.price_line
11030 (p_Header_id => p_Header_id
11031 ,p_Line_id =>p_Line_id
11032 ,px_line_Tbl =>x_line_tbl
11033 ,p_Control_Rec =>l_price_control_rec
11034 ,p_action_code =>p_action_code
11035 ,p_Pricing_Events =>p_Control_rec.pricing_event
11036 ,p_request_rec =>p_request_rec
11037 ,x_Return_Status =>l_return_status
11038 );
11039
11040 If nvl(l_return_status,'x-x') NOT IN (FND_API.G_RET_STS_UNEXP_ERROR,FND_API.G_RET_STS_ERROR) Then
11041 l_return_status:=FND_API.G_RET_STS_SUCCESS;
11042 End If;
11043
11044 -- added for HVOP Tax project
11045 IF OE_BULK_ORDER_PVT.G_HEADER_REC.HEADER_ID.COUNT > 0 THEN
11046 OE_BULK_PRICE_PVT.Update_Pricing_Attributes(p_line_tbl => x_line_tbl);
11047 END IF;
11048
11049
11050 x_return_status := l_return_status;
11051 RETURN;
11052 END IF;
11053
11054
11055 adj_debug('Exiting oe_order_Adj_pvt.Price_line',1);
11056
11057
11058
11059 Exception
11060 WHEN FND_API.G_EXC_ERROR THEN
11061
11062 x_return_status := FND_API.G_RET_STS_ERROR;
11063
11064 --Bug 7566697
11065 adj_debug('Setting prcing error flag for mass change');
11066 OE_MASS_CHANGE_PVT.G_PRICING_ERROR := 'Y';
11067
11068 adj_debug('Exiting oe_order_Adj_pvt.Price_line',1);
11069 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
11070
11071 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
11072
11073 --Bug 7566697
11074 adj_debug('Setting prcing error flag for mass change');
11075 OE_MASS_CHANGE_PVT.G_PRICING_ERROR := 'Y';
11076
11077 adj_debug('Exiting oe_order_Adj_pvt.Price_line',1);
11078 WHEN OTHERS THEN
11079
11080 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
11081 adj_debug('Error in oe_order_Adj_pvt.Price_line',1);
11082 adj_debug(sqlerrm,1);
11083
11084 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
11085 THEN
11086 OE_MSG_PUB.Add_Exc_Msg
11087 ( G_PKG_NAME
11088 , 'Price_line',
11089 sqlerrm
11090 );
11091 END IF;
11092
11093 --Bug 7566697
11094 adj_debug('Setting prcing error flag for mass change');
11095 OE_MASS_CHANGE_PVT.G_PRICING_ERROR := 'Y';
11096
11097 adj_debug('Exiting oe_order_Adj_pvt.Price_line',1);
11098 --RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11099
11100 End Price_line;
11101
11102 Procedure Price_Adjustments(
11103 X_Return_Status out nocopy Varchar2
11104
11105 ,p_Header_id Number DEfault null
11106 ,p_Line_id Number DEfault null
11107 ,p_request_type_code varchar2
11108 ,p_request_rec OE_Order_PUB.request_rec_type default oe_order_pub.G_MISS_REQUEST_REC
11109
11110 )
11111 is
11112 l_Req_Control_Rec QP_PREQ_GRP.CONTROL_RECORD_TYPE;
11113 l_control_rec Oe_Globals.Control_rec_type;
11114 l_Line_tbl OE_Order_PUB.Line_tbl_type;
11115 l_old_Line_tbl OE_Order_PUB.Line_tbl_type;
11116 l_Line_tbl1 OE_Order_PUB.Line_tbl_type;
11117 l_Line_Adj_Att_tbl OE_Order_PUB.Line_Adj_Att_tbl_type;
11118 l_Line_Adj_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
11119 l_Old_Line_Adj_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
11120 l_Line_Adj_Assoc_tbl OE_Order_PUB.Line_Adj_Assoc_tbl_type;
11121 l_dummy_adj_assoc_tbl OE_Order_PUB.line_adj_assoc_tbl_type;
11122 l_header_rec OE_Order_PUB.Header_Rec_Type;
11123 l_x_header_rec OE_Order_PUB.Header_Rec_Type;
11124 l_x_Header_Adj_tbl OE_Order_PUB.Header_Adj_Tbl_Type;
11125 l_x_Header_Scredit_tbl OE_Order_PUB.Header_Scredit_Tbl_Type;
11126 --l_x_line_tbl OE_Order_PUB.Line_Tbl_Type;
11127 --l_x_Line_Adj_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
11128 l_x_Line_Scredit_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
11129 l_x_action_request_tbl OE_Order_PUB.request_tbl_type;
11130 l_x_lot_serial_tbl OE_Order_PUB.lot_serial_tbl_type;
11131 l_x_Header_price_Att_tbl OE_Order_PUB.Header_price_Att_tbl_type;
11132 l_x_Header_Adj_Att_tbl OE_Order_PUB.Header_Adj_Att_tbl_type;
11133 l_x_Header_Adj_Assoc_tbl OE_Order_PUB.Header_Adj_Assoc_tbl_type;
11134 l_x_Line_price_Att_tbl OE_Order_PUB.Line_price_Att_tbl_type;
11135 l_x_Line_Adj_Att_tbl OE_Order_PUB.Line_Adj_Att_tbl_type;
11136 l_x_Line_Adj_Assoc_tbl OE_Order_PUB.Line_Adj_Assoc_tbl_type;
11137 l_x_msg_count number;
11138 l_x_msg_data Varchar2(2000);
11139 i pls_integer;
11140 l_line_index pls_integer;
11141 l_allow_negative_price Varchar2(30) := nvl(fnd_profile.value('ONT_NEGATIVE_PRICING'),'N');
11142 --Manual Begin
11143 --Set calculate price flag to 'P' when manual adjustment is applied
11144 l_set_price_flag_on_manual Varchar2(30) := nvl(fnd_profile.value('ONT_SET_PRICE_FLAG_ON_MANUAL'),'N');
11145 --Manual End
11146 l_dummy key_tbl_type;
11147 l_updated_flag varchar2(1);
11148 l_dummy_line_rec Oe_Order_Pub.Line_Rec_Type;
11149 l_price_control_rec OE_ORDER_PRICE_PVT.CONTROL_REC_TYPE;
11150 x_line_tbl oe_order_pub.line_tbl_type;
11151 l_status_code Varchar2(5);
11152 l_item_rec OE_ORDER_CACHE.item_rec_type; -- OPM 2547940
11153 --serla begin
11154 l_x_Header_Payment_tbl OE_Order_PUB.Header_Payment_Tbl_Type;
11155 l_x_Line_Payment_tbl OE_Order_PUB.Line_Payment_Tbl_Type;
11156 --serla end
11157 begin
11158
11159 adj_debug('Entering oe_order_Adj_pvt.Price_adjustments',1);
11160
11161 --btea perf begin
11162 If OE_DEBUG_PUB.G_DEBUG = FND_API.G_TRUE Then
11163 G_DEBUG := TRUE;
11164 adj_debug('BCT G_DEBUG IS:'||OE_DEBUG_PUB.G_DEBUG );
11165 Else
11166 G_DEBUG := FALSE;
11167 End If;
11168 --btea perf end
11169
11170
11171
11172 IF OE_GLOBALS.G_ASO_INSTALLED IS NULL THEN
11173 OE_GLOBALS.G_ASO_INSTALLED := OE_GLOBALS.CHECK_PRODUCT_INSTALLED(697);
11174 END IF;
11175
11176 IF OE_GLOBALS.G_GMI_INSTALLED IS NULL THEN -- OPM 2547940
11177 OE_GLOBALS.G_GMI_INSTALLED := OE_GLOBALS.CHECK_PRODUCT_INSTALLED(550);
11178 END IF;
11179
11180
11181 IF (OE_GLOBALS.G_ASO_INSTALLED = 'N' AND
11182 OE_GLOBALS.G_GMI_INSTALLED = 'N' AND -- OPM 2547940
11183 G_11IG_PERFORMANCE = 'Y' AND
11184 QP_UTIL_PUB.Basic_Pricing_Setup = 'Y' AND
11185 nvl(p_request_rec.param1,'XX') <> 'UI') OR
11186 OE_CODE_CONTROL.Get_Code_Release_Level >= '110509'
11187 THEN
11188 l_price_control_rec.p_request_type_code:=p_request_type_code;
11189 l_price_control_rec.p_calculate_flag := QP_PREQ_GRP.G_CALCULATE_ONLY;
11190 IF (p_line_id IS NOT NULL and nvl(p_request_rec.param1,'XX') = 'UI') THEN
11191 l_price_control_rec.p_honor_price_flag := 'N';
11192 END IF;
11193 oe_order_price_pvt.price_line
11194 (p_Header_id => p_Header_id
11195 ,p_Line_id =>p_Line_id
11196 ,px_line_Tbl =>x_line_tbl
11197 ,p_Control_Rec =>l_price_control_rec
11198 ,p_Pricing_Events =>NULL
11199 ,x_Return_Status =>x_return_status
11200 );
11201 RETURN;
11202 END IF;
11203 -- Query Line Record
11204
11205 l_Req_Control_Rec.Simulation_Flag := 'N';
11206
11207 If p_header_id is null then
11208
11209 oe_line_util.query_rows(
11210 p_line_id => p_line_id
11211 , x_line_tbl => l_line_tbl1
11212 );
11213
11214 OE_Header_Util.Query_Row(
11215 p_header_id => l_Line_Tbl1(1).header_id
11216 , x_header_rec => l_header_rec
11217 );
11218 Else
11219
11220 OE_Header_Util.Query_Row(
11221 p_header_id => p_header_id
11222 , x_header_rec => l_header_rec
11223 );
11224
11225 oe_line_util.query_rows(
11226 p_header_id => p_header_id
11227 , x_line_tbl => l_Line_Tbl1
11228 );
11229 end if;
11230 g_order_currency := l_header_rec.transactional_curr_code; --bug 2595626
11231
11232 oe_debug_pub.add(' Param1 UI Flag value:'|| p_request_rec.param1);
11233 l_line_index := l_Line_Tbl1.First;
11234 While l_line_index is not null loop -- Retain the ones with calculate_price_flag=Y'
11235 /* Added elsif condition so that price is calculated even if price flag is N
11236 when request is logged for a line */
11237 If nvl(l_Line_Tbl1(l_line_index).calculate_price_flag,'Y') in ('Y','P') then
11238 l_Line_Tbl(l_Line_Tbl.count+1) := l_Line_Tbl1(l_line_index);
11239 Elsif p_line_id is not NULL
11240 and l_Line_Tbl1(l_line_index).line_id = p_line_id
11241 and p_request_rec.param1 = 'UI' Then --bug 2354465
11242 l_Line_Tbl(l_Line_Tbl.count+1) :=l_Line_Tbl1(l_line_index);
11243 end if;
11244 l_line_index := l_Line_Tbl1.Next(l_line_index);
11245 end loop;
11246
11247 l_line_index := l_Line_Tbl.First;
11248
11249 While l_line_index is not null loop
11250 -- Query the Adjustments
11251
11252 -- added by lkxu
11253 l_line_tbl(l_line_index).operation := OE_GLOBALS.G_OPR_UPDATE;
11254
11255 append_Adjustment_lines(p_line_id => l_Line_Tbl(l_line_index).line_id,
11256 px_line_adj_tbl => l_Line_Adj_Tbl
11257 ,px_line_key_tbl => l_dummy
11258 ,px_header_key_tbl => l_dummy
11259 ,px_line_adj_assoc_tbl =>l_dummy_adj_assoc_tbl
11260 ,px_line_rec => l_line_tbl(l_line_index)
11261 , x_updated_flag =>l_updated_flag);
11262
11263 If (l_updated_flag = 'Y' and l_line_tbl(l_line_index).calculate_price_flag = 'Y') THEN
11264 If l_set_price_flag_on_manual = 'Y' Then
11265 l_line_tbl(l_line_index).calculate_price_flag := 'P';
11266 End If;
11267 End if;
11268 l_line_index := l_Line_Tbl.next(l_line_index);
11269 End loop;
11270
11271 append_Adjustment_Lines(p_header_id => l_header_rec.header_id
11272 ,px_Line_Adj_Tbl => l_line_adj_Tbl
11273 ,px_line_key_tbl => l_dummy
11274 ,px_header_key_tbl => l_dummy
11275 ,px_line_adj_assoc_tbl => l_dummy_adj_assoc_tbl
11276 ,px_line_rec => l_dummy_line_rec
11277 ,x_updated_flag => l_updated_flag);
11278
11279 l_old_line_adj_tbl := l_line_adj_tbl;
11280
11281 -- Query the assocs
11282 i:= l_Line_Adj_Tbl.First;
11283 While I is not null loop
11284 Query_Adj_Assocs(
11285 p_price_adjustment_id=> l_line_adj_Tbl(i).price_adjustment_id,
11286 p_Adj_Index => i,
11287 p_Line_Adj_Assoc_Tbl => l_line_adj_Assoc_tbl,
11288 p_delete_flag => 'N');
11289
11290 oe_debug_pub.add('xPrice_Adj query assocs-adj_id:'|| l_line_adj_Tbl(i).price_adjustment_id);
11291 oe_debug_pub.add('xAdj asso count:'||l_line_adj_Assoc_tbl.count);
11292 i:= l_Line_Adj_Tbl.Next(i);
11293 End loop;
11294
11295 --Performance change: To update only changed lines
11296 l_old_line_tbl := l_line_tbl;
11297
11298 --Return;
11299 Calculate_Price (
11300 p_Header_Rec => l_Header_Rec
11301 ,p_Line_Tbl => l_line_Tbl
11302 ,p_Line_Adj_Tbl => l_Line_Adj_Tbl
11303 ,p_line_adj_assoc_Tbl => l_line_adj_assoc_Tbl
11304 ,p_allow_negative_price => l_allow_negative_price
11305 ,p_request_Type_Code => p_request_Type_Code
11306 ) ;
11307
11308 -- lkxu, only retain those records with changed adjusted_amount
11309 i:= l_Line_Adj_Tbl.First;
11310 While i is not Null Loop
11311 IF OE_GLOBALS.Equal(l_Old_Line_Adj_Tbl(i).adjusted_amount_per_pqty,
11312 l_Line_Adj_Tbl(i).adjusted_amount_per_pqty) THEN
11313 l_Line_Adj_Tbl.delete(i);
11314 ELSE
11315 oe_debug_pub.add(' price adj amount:'|| L_Line_Adj_Tbl(i).adjusted_amount);
11316 L_Line_Adj_Tbl(i).operation := OE_GLOBALS.G_OPR_UPDATE;
11317 END IF;
11318 i:= l_Line_Adj_Tbl.next(i);
11319 END LOOP;
11320
11321
11322 -- set control record
11323 l_control_rec.controlled_operation := TRUE;
11324 l_control_rec.write_to_DB := TRUE;
11325 l_control_rec.change_attributes := TRUE;
11326 l_control_rec.default_attributes := TRUE;
11327 l_control_rec.validate_entity := TRUE;
11328 l_control_rec.clear_dependents := TRUE;
11329
11330 l_control_rec.process := FALSE;
11331 l_control_rec.clear_api_cache := FALSE;
11332 l_control_rec.clear_api_requests := FALSE;
11333
11334
11335 -- Call OE_Order_PVT.Process_order
11336
11337 -- OE_Globals.G_RECURSION_MODE := 'Y';
11338 OE_Globals.G_PRICING_RECURSION := 'Y';
11339
11340
11341 I:= l_line_tbl.First;
11342 While I is not null loop
11343
11344 -- 3129046
11345 adj_debug('Line ID processed : '||l_line_tbl(i).line_id,1);
11346 l_line_tbl(i).change_reason := 'SYSTEM';
11347 l_line_tbl(i).change_comments := 'PRICING';
11348 adj_debug('Audit Reason passed as '||l_line_tbl(i).change_reason,1);
11349
11350 -- uom begin
11351 If oe_line_util.Get_Return_Item_Type_Code(l_line_tbl(i)) in ('INCLUDED', 'CONFIG') then
11352 l_line_tbl(i).unit_list_price_per_pqty := 0;
11353 l_line_tbl(i).pricing_quantity := l_line_tbl(i).ordered_quantity;
11354 l_line_tbl(i).pricing_quantity_uom := l_line_tbl(i).order_quantity_uom;
11355 end if;
11356
11357 If l_line_tbl(i).unit_Selling_price_per_pqty is null or
11358 oe_line_util.Get_Return_Item_Type_Code(l_line_tbl(i)) in ('INCLUDED', 'CONFIG')
11359 then
11360 l_line_tbl(i).unit_Selling_price_per_pqty := l_line_tbl(i).unit_list_price_per_pqty;
11361
11362 End If;
11363
11364 If l_line_tbl(i).ordered_quantity IS NOT NULL and l_line_tbl(i).ordered_quantity <> 0
11365 then
11366 l_line_tbl(i).unit_selling_price := l_line_tbl(i).unit_selling_price_per_pqty * l_line_tbl(i).pricing_quantity/l_line_tbl(i).ordered_quantity;
11367
11368 l_line_tbl(i).unit_list_price := l_line_tbl(i).unit_list_price_per_pqty * l_line_tbl(i).pricing_quantity/l_line_tbl(i).ordered_quantity;
11369 end if;
11370
11371 -- OPM 2547940 start - if pricing by quantity2 then if line is shipped and has shipped qty2 != ordered qty2
11372 -- need to adjust the adjusted_amount so that invoicing will show correct amount (ordered qty * USP (adjusted) )
11373
11374 IF oe_line_util.dual_uom_control -- invconv
11375 (l_line_tbl(i).inventory_item_id
11376 ,l_line_tbl(i).ship_from_org_id
11377 ,l_item_rec) THEN
11378 IF l_item_rec.ont_pricing_qty_source = 'S' THEN -- price by quantity 2 -- INVCONV
11379
11380 IF (l_line_tbl(i).ordered_quantity2 IS NOT NULL and l_line_tbl(i).ordered_quantity2 <> 0 )
11381 AND ( l_line_tbl(i).shipped_quantity2 IS NOT NULL and l_line_tbl(i).shipped_quantity2 <> 0 )
11382 AND l_line_tbl(i).ordered_quantity2 <> l_line_tbl(i).shipped_quantity2 THEN
11383
11384 l_line_tbl(i).unit_selling_price := (l_line_tbl(i).unit_selling_price_per_pqty * l_line_tbl(i).pricing_quantity )/l_line_tbl(i).ordered_quantity2
11385 * (l_line_tbl(i).shipped_quantity2/l_line_tbl(i).ordered_quantity);
11386 l_line_tbl(i).unit_list_price := (l_line_tbl(i).unit_list_price_per_pqty * l_line_tbl(i).pricing_quantity )/l_line_tbl(i).ordered_quantity2
11387 * (l_line_tbl(i).shipped_quantity2/l_line_tbl(i).ordered_quantity);
11388
11389 END IF;
11390 END IF;
11391 END IF; --oe_line_util.dual_uom_control -- INVCONV
11392 -- OPM 2547940 end
11393
11394 oe_debug_pub.add('unit price'||l_line_tbl(i).unit_list_price||'+'||l_line_tbl(i).unit_selling_price,1);
11395 oe_debug_pub.add('unit price per pqty'||l_line_tbl(i).unit_list_price_per_pqty||'+'||l_line_tbl(i).unit_selling_price_per_pqty,1);
11396
11397 -- uom end
11398
11399 -- commented the assigment below and included above to fix bug 2595626
11400 -- g_order_currency := l_header_rec.transactional_curr_code;
11401
11402
11403 adj_debug(' Values passed into QP_UTIL_PUB.round_price api:');
11404 adj_debug(' p_operand:'||l_line_tbl(i).unit_selling_price);
11405 adj_debug(' price_list_id:'||l_line_tbl(i).price_list_id);
11406 adj_debug(' currency_code:'||l_header_rec.transactional_curr_code);
11407 adj_debug(' pricing_effective_date:'||l_line_tbl(i).pricing_date);
11408 QP_UTIL_PUB.round_price(p_operand => l_line_tbl(i).unit_selling_price,
11409 p_rounding_factor => NULL,
11410 p_use_multi_currency => 'Y',
11411 p_price_list_id => l_line_tbl(i).price_list_id,
11412 p_currency_code => l_header_rec.transactional_curr_code,
11413 p_pricing_effective_date => l_line_tbl(i).pricing_date,
11414 x_rounded_operand => l_line_tbl(i).unit_selling_price,
11415 x_status_code => l_status_code);
11416 adj_debug(' Rounded Unit Selling Price Returned By pricing API:'||l_line_tbl(i).unit_selling_price);
11417 adj_debug(' x_status_code:'||l_status_code);
11418
11419
11420 -- Performance change: not update line if no change
11421 IF (OE_GLOBALS.Equal(l_line_tbl(i).unit_list_price, l_old_line_tbl(i).unit_list_price) AND
11422 OE_GLOBALS.Equal(l_line_tbl(i).unit_selling_price, l_old_line_tbl(i).unit_selling_price) AND
11423 OE_GLOBALS.Equal(l_line_tbl(i).unit_list_price_per_pqty, l_old_line_tbl(i).unit_list_price_per_pqty) AND
11424 OE_GLOBALS.Equal(l_line_tbl(i).unit_selling_price_per_pqty, l_old_line_tbl(i).unit_selling_price_per_pqty)) THEN
11425 adj_debug('not updating '||l_line_tbl(i).line_id);
11426 -- l_line_tbl(i).operation := OE_GLOBALS.G_OPR_NONE;
11427 l_line_tbl.delete(i);
11428 ELSE
11429 OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
11430 END IF;
11431
11432 i:= l_line_tbl.next(i);
11433 end loop;
11434
11435 adj_debug('Before OE_Order_PVT.Process_order',1);
11436
11437 OE_Order_PVT.Process_order
11438 ( p_api_version_number => 1.0
11439 , x_return_status => x_return_status
11440 , x_msg_count => l_x_msg_count
11441 , x_msg_data => l_x_msg_data
11442 , p_control_rec => l_control_rec
11443 , p_x_line_tbl => l_line_tbl
11444 , p_x_Line_Adj_tbl => l_Line_Adj_tbl
11445 , p_x_header_rec => l_x_header_rec
11446 , p_x_Header_Adj_tbl => l_x_Header_Adj_tbl
11447 , p_x_header_price_att_tbl => l_x_header_price_att_tbl
11448 , p_x_Header_Adj_att_tbl => l_x_Header_Adj_att_tbl
11449 , p_x_Header_Adj_Assoc_tbl => l_x_Header_Adj_Assoc_tbl
11450 , p_x_Header_Scredit_tbl => l_x_Header_Scredit_tbl
11451 --serla begin
11452 , p_x_Header_Payment_tbl => l_x_Header_Payment_tbl
11453 --serla end
11454 -- , p_x_line_tbl => l_x_line_tbl
11455 -- , p_x_Line_Adj_tbl => l_x_Line_Adj_tbl
11456 , p_x_Line_Price_att_tbl => l_x_Line_Price_att_tbl
11457 , p_x_Line_Adj_att_tbl => l_x_Line_Adj_att_tbl
11458 , p_x_Line_Adj_Assoc_tbl => l_x_Line_Adj_Assoc_tbl
11459 , p_x_Line_Scredit_tbl => l_x_Line_Scredit_tbl
11460 --serla begin
11461 , p_x_Line_Payment_tbl => l_x_Line_Payment_tbl
11462 --serla end
11463 , p_x_Lot_Serial_tbl => l_x_Lot_Serial_Tbl
11464 , p_x_action_request_tbl => l_x_Action_Request_tbl
11465 );
11466
11467
11468 -- OE_Globals.G_RECURSION_MODE := 'N';
11469 OE_Globals.G_PRICING_RECURSION := 'N';
11470
11471 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
11472 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11473 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
11474 RAISE FND_API.G_EXC_ERROR;
11475 END IF;
11476
11477 adj_debug('Exiting oe_order_Adj_pvt.Price_adjustments',1);
11478
11479
11480 EXCEPTION
11481
11482 WHEN FND_API.G_EXC_ERROR THEN
11483
11484 x_return_status := FND_API.G_RET_STS_ERROR;
11485 adj_debug(' '||g_stmt_no||' '||sqlerrm||' '||l_x_msg_data,1);
11486
11487 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
11488
11489 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
11490 adj_debug(' '||g_stmt_no||' '||sqlerrm||' '||l_x_msg_data,1);
11491
11492 WHEN OTHERS THEN
11493
11494 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
11495 --dbms_output.put_line('Error is '||sqlerrm);
11496 adj_debug('Error in oe_order_Adj_pvt.Price_adjustments',1);
11497 adj_debug(' '||g_stmt_no||' '||sqlerrm,1);
11498
11499 End Price_Adjustments;
11500
11501 procedure price_action
11502 (
11503 p_selected_records Oe_Globals.Selected_Record_Tbl
11504 ,P_price_level varchar2
11505 ,p_header_id Number default null
11506 ,x_Return_Status out nocopy varchar2
11507
11508 ,x_msg_count out nocopy number
11509
11510 ,x_msg_data out nocopy varchar2
11511
11512 )
11513 is
11514 l_Price_Control_rec QP_PREQ_GRP.control_record_type;
11515 l_return_status varchar2(1);
11516 l_x_line_tbl oe_order_pub.line_tbl_type;
11517 l_line_id number;
11518 l_header_id number;
11519 l_delimiter1 number;
11520 l_delimiter2 number;
11521 l_delimiter number;
11522 l_booked_flag varchar2(1);
11523 l_multiple_events Varchar2(1);
11524 l_order_status_rec QP_UTIL_PUB.ORDER_LINES_STATUS_REC_TYPE;
11525 l_prev_line_hdr_id Number;
11526
11527 cursor has_prg_lines(p_line_id IN NUMBER) is
11528 Select 'Y'
11529 From OE_PRICE_ADJUSTMENTS a, OE_ORDER_LINES_ALL b
11530 Where b.line_id = p_line_id
11531 AND b.header_id = a.header_id
11532 And a.list_line_type_code = 'PRG';
11533
11534 l_has_prg_lines varchar2(1):= 'Q';
11535 --MOAC PI
11536 J Number := 1;
11537 L_org_id Number;
11538 L_prev_org_id Number;
11539 L_prev_hdr_id Number;
11540 L_call_pricing varchar2(1) := 'N';
11541 last_record_line_id Number := p_selected_records(p_selected_records.count).id1;
11542 L_new_header Boolean;
11543 L_ID3 Boolean := TRUE;
11544 i Number;
11545 --MOAC PI
11546
11547 begin
11548 adj_debug('Performing Price Action for level '||P_price_level);
11549
11550 If P_price_level ='LINE' then
11551
11552 l_Price_Control_Rec.pricing_event := 'LINE';
11553 l_Price_Control_Rec.calculate_flag := QP_PREQ_GRP.G_SEARCH_N_CALCULATE;
11554 l_Price_Control_Rec.Simulation_Flag := 'N';
11555 l_has_prg_lines := 'Q';
11556
11557 --MOAC PI BEGIN
11558 oe_debug_pub.add('p_header_id : ' || p_header_id);
11559 IF p_header_id is not null THEN
11560 oe_debug_pub.add('before the loop');
11561 i := p_selected_records.first;
11562 while I is not null loop
11563 L_line_id := p_selected_records(i).id1;
11564 --Bug 7330561
11565 l_has_prg_lines := 'Q';
11566 Begin
11567 open has_prg_lines(L_line_id);
11568 fetch has_prg_lines into l_has_prg_lines;
11569 close has_prg_lines;
11570 Exception
11571 When no_data_found Then
11572 l_has_prg_lines:='N';
11573 When others Then
11574 l_has_prg_lines:='Y';
11575 End;
11576 oe_debug_pub.add('Lalit calling Price Line with l_has_prg_lines-' || l_has_prg_lines );
11577 IF l_has_prg_lines = 'Y' THEN
11578 oe_order_Adj_pvt.Price_line(
11579 X_Return_Status => l_Return_Status
11580 ,p_Request_Type_code=> 'ONT'
11581 ,p_Control_rec => l_Price_Control_Rec
11582 ,p_Write_To_Db => TRUE
11583 ,p_Line_id => l_line_id
11584 ,x_Line_Tbl => l_x_Line_Tbl
11585 );
11586 ELSE
11587 adj_debug('Old price_action way, order has no prg');
11588 Begin
11589 l_x_line_tbl(i).Line_id := l_Line_id;
11590 oe_Line_util.query_row(
11591 p_Line_id => l_Line_id
11592 , x_line_rec => l_x_Line_Tbl(i)
11593 );
11594 Exception when no_data_found then
11595 null;
11596 End;
11597
11598 END IF;
11599 i := p_selected_records.next(i);
11600 End Loop;
11601 IF l_has_prg_lines IN ('N','Q') THEN
11602 oe_order_Adj_pvt.Price_line(
11603 X_Return_Status => l_Return_Status
11604 ,p_Request_Type_code=> 'ONT'
11605 ,p_Control_rec => l_Price_Control_Rec
11606 ,p_Write_To_Db => TRUE
11607 ,x_Line_Tbl => l_x_Line_Tbl
11608 );
11609 END IF;
11610
11611 ELSE
11612 i := p_selected_records.first;
11613 while i is not null loop
11614 oe_debug_pub.add('id1 : ' || p_selected_records(i).id1);
11615 oe_debug_pub.add('org_id : ' || p_selected_records(i).org_id);
11616 oe_debug_pub.add('id3 : ' || p_selected_records(i).id3);
11617 l_line_id := p_selected_records(i).id1;
11618 l_org_id := p_selected_records(i).org_id;
11619 L_header_id := p_selected_records(i).id3;
11620 If l_prev_org_id is null or l_prev_org_id <> l_org_id Then
11621 MO_GLOBAL.set_policy_context(p_access_mode => 'S', p_org_id => l_Org_Id);
11622 l_prev_org_id := l_org_id;
11623 End If;
11624 L_new_header := FALSE;
11625 IF l_prev_hdr_id Is Null Or l_prev_hdr_id <> l_header_id Then
11626 L_new_header := TRUE;
11627 l_has_prg_lines:='Q';
11628 j := 1;
11629 l_prev_hdr_id := l_header_id;
11630 Begin
11631 open has_prg_lines(l_header_id);
11632 fetch has_prg_lines into l_has_prg_lines;
11633 close has_prg_lines;
11634 Exception
11635 When no_data_found Then
11636 l_has_prg_lines:='N';
11637 When others Then
11638 l_has_prg_lines:='Y';
11639 End;
11640 End If;
11641
11642 IF l_has_prg_lines = 'Y' THEN
11643 oe_order_Adj_pvt.Price_line(
11644 X_Return_Status => l_Return_Status
11645 ,p_Request_Type_code=> 'ONT'
11646 ,p_Control_rec => l_Price_Control_Rec
11647 ,p_Write_To_Db => TRUE
11648 ,p_Line_id => l_line_id
11649 ,x_Line_Tbl => l_x_Line_Tbl
11650 );
11651 ELSE
11652 IF (l_new_header or last_record_line_id = l_line_id) and l_x_line_tbl.count > 0 THEN
11653 IF last_record_line_id = l_line_id and l_prev_line_hdr_id = l_header_id THEN
11654 Begin
11655 l_x_line_tbl(j).Line_id := l_Line_id;
11656 oe_Line_util.query_row(
11657 p_Line_id => l_Line_id
11658 , x_line_rec => l_x_Line_Tbl(j)
11659 );
11660 Exception when no_data_found then
11661 null;
11662 End;
11663 END IF;
11664
11665 oe_order_Adj_pvt.Price_line(
11666 X_Return_Status => l_Return_Status
11667 ,p_Request_Type_code=> 'ONT'
11668 ,p_Control_rec => l_Price_Control_Rec
11669 ,p_Write_To_Db => TRUE
11670 ,x_Line_Tbl => l_x_Line_Tbl
11671 );
11672
11673 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
11674 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11675 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
11676 RAISE FND_API.G_EXC_ERROR;
11677 END IF;
11678
11679 L_x_line_tbl.delete;
11680 END IF;
11681
11682 adj_debug('Old price_action way, order has no prg');
11683 Begin
11684 l_x_line_tbl(j).Line_id := l_Line_id;
11685 oe_Line_util.query_row(
11686 p_Line_id => l_Line_id
11687 , x_line_rec => l_x_Line_Tbl(j)
11688 );
11689 j := j + 1;
11690 Exception when no_data_found then
11691 null;
11692 End;
11693 END IF;
11694 l_prev_line_hdr_id := l_header_id;
11695 i := p_selected_records.next(i);
11696 End Loop;
11697 IF l_x_line_tbl.count > 0 THEN
11698 oe_order_Adj_pvt.Price_line(
11699 X_Return_Status => l_Return_Status
11700 ,p_Request_Type_code=> 'ONT'
11701 ,p_Control_rec => l_Price_Control_Rec
11702 ,p_Write_To_Db => TRUE
11703 ,x_Line_Tbl => l_x_Line_Tbl
11704 );
11705
11706 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
11707 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11708 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
11709 RAISE FND_API.G_EXC_ERROR;
11710 END IF;
11711
11712 L_x_line_tbl.delete;
11713 END IF;
11714
11715 END IF;
11716 ELSE
11717 IF p_selected_records(1).id3 IS NULL THEN
11718 L_id3 := FALSE;
11719 END IF;
11720 IF NOT L_id3 THEN
11721 i := p_selected_records.first;
11722 while i is not null loop
11723 l_header_id := p_selected_records(i).id1;
11724 l_org_id := p_selected_records(i).org_id;
11725 IF l_prev_org_id Is Null or l_prev_org_id <> l_org_id Then
11726 MO_GLOBAL.set_policy_context(p_access_mode => 'S', p_org_id => l_Org_Id);
11727 l_prev_org_id := l_org_id;
11728 END IF;
11729 adj_debug('Price Action Header_id :'||l_HEader_id);
11730
11731 -- use order_header cache instead of sql : bug 4200055
11732 if ( OE_Order_Cache.g_header_rec.header_id <> FND_API.G_MISS_NUM
11733 and OE_Order_Cache.g_header_rec.header_id IS NOT NULL
11734 and OE_Order_Cache.g_header_rec.header_id = l_header_id ) then
11735 l_booked_flag := OE_Order_Cache.g_header_rec.booked_flag ;
11736 else
11737 OE_ORDER_CACHE.Load_Order_Header(l_header_id);
11738 l_booked_flag := OE_Order_Cache.g_header_rec.booked_flag ;
11739 end if ;
11740 /*Select booked_flag into l_booked_flag from oe_order_headers_all
11741 where header_id=l_header_id; */
11742 --end bug 4200055
11743
11744 If l_booked_flag <> 'Y' Then
11745 l_price_control_rec.pricing_event := 'BATCH';
11746 l_multiple_events := 'N';
11747 Elsif l_booked_flag = 'Y' Then
11748 l_price_control_rec.pricing_event := 'BATCH,BOOK,SHIP';
11749 l_multiple_events := 'Y';
11750 End If;
11751
11752 l_Price_Control_Rec.calculate_flag := QP_PREQ_GRP.G_SEARCH_N_CALCULATE;
11753 l_Price_Control_Rec.Simulation_Flag := 'N';
11754
11755 oe_order_Adj_pvt.Price_line(
11756 X_Return_Status => l_Return_Status
11757 ,p_header_id => l_header_id
11758 ,p_Request_Type_code=> 'ONT'
11759 ,p_Control_rec => l_Price_Control_Rec
11760 ,p_Write_To_Db => TRUE
11761 ,x_Line_Tbl => l_x_Line_Tbl
11762 ,p_multiple_events => l_multiple_events
11763 ,p_action_code => 'PRICE_ORDER');
11764
11765 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
11766 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11767 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
11768 RAISE FND_API.G_EXC_ERROR;
11769 END IF;
11770 i := p_selected_records.next(i);
11771 end loop;
11772 ELSE
11773 i := p_selected_records.first;
11774 while i is not null loop
11775 l_header_id := p_selected_records(i).id3;
11776 l_org_id := p_selected_records(i).org_id;
11777 IF l_prev_org_id Is Null or l_prev_org_id <> l_org_id Then
11778 MO_GLOBAL.set_policy_context(p_access_mode => 'S', p_org_id => l_Org_Id);
11779 l_prev_org_id := l_org_id;
11780 END IF;
11781 IF l_prev_hdr_id IS NULL OR l_prev_hdr_id <> l_header_id THEN
11782 adj_debug('Price Action Header_id :'||l_HEader_id);
11783 Select booked_flag into l_booked_flag from oe_order_headers_all
11784 where header_id=l_header_id;
11785 If l_booked_flag <> 'Y' Then
11786 l_price_control_rec.pricing_event := 'BATCH';
11787 l_multiple_events := 'N';
11788 Elsif l_booked_flag = 'Y' Then
11789 l_price_control_rec.pricing_event := 'BATCH,BOOK,SHIP';
11790 l_multiple_events := 'Y';
11791 End If;
11792
11793 l_Price_Control_Rec.calculate_flag := QP_PREQ_GRP.G_SEARCH_N_CALCULATE;
11794 l_Price_Control_Rec.Simulation_Flag := 'N';
11795
11796 oe_order_Adj_pvt.Price_line(
11797 X_Return_Status => l_Return_Status
11798 ,p_header_id => l_header_id
11799 ,p_Request_Type_code=> 'ONT'
11800 ,p_Control_rec => l_Price_Control_Rec
11801 ,p_Write_To_Db => TRUE
11802 ,x_Line_Tbl => l_x_Line_Tbl
11803 ,p_multiple_events => l_multiple_events
11804 ,p_action_code => 'PRICE_ORDER');
11805
11806 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
11807 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11808 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
11809 RAISE FND_API.G_EXC_ERROR;
11810 END IF;
11811 l_prev_hdr_id := l_header_id;
11812 END IF;
11813 i := p_selected_records.next(i);
11814 end loop;
11815 END IF;
11816
11817 END IF;
11818
11819 --MOAC PI END
11820
11821 OE_MSG_PUB.Count_And_Get
11822 ( p_count => x_msg_count
11823 , p_data => x_msg_data
11824 );
11825
11826 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
11827 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11828 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
11829 RAISE FND_API.G_EXC_ERROR;
11830 END IF;
11831
11832 x_Return_Status := FND_API.G_RET_STS_SUCCESS;
11833
11834 adj_debug('Exiting oe_order_Adj_pvt.Price_adjustments',1);
11835
11836
11837 EXCEPTION
11838
11839 WHEN FND_API.G_EXC_ERROR THEN
11840 x_return_status := FND_API.G_RET_STS_ERROR;
11841 OE_MSG_PUB.Count_And_Get
11842 ( p_count => x_msg_count
11843 ,p_data => x_msg_data
11844 );
11845
11846 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
11847 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
11848 OE_MSG_PUB.Count_And_Get
11849 ( p_count => x_msg_count
11850 ,p_data => x_msg_data
11851 );
11852
11853 WHEN OTHERS THEN
11854 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
11855 adj_debug(' '||sqlerrm,1);
11856 OE_MSG_PUB.Count_And_Get
11857 ( p_count => x_msg_count
11858 , p_data => x_msg_data
11859 );
11860
11861 end price_action;
11862
11863
11864 /* For Backward Compatibility */
11865
11866 procedure price_action
11867 (p_Header_count Number
11868 ,p_Header_list varchar2
11869 ,p_line_count number
11870 ,p_line_List Varchar2
11871 ,P_price_level varchar2
11872 ,x_Return_Status out nocopy varchar2
11873
11874 ,x_msg_count out nocopy number
11875
11876 ,x_msg_data out nocopy varchar2
11877
11878 )
11879 is
11880 l_Price_Control_rec QP_PREQ_GRP.control_record_type;
11881 l_return_status varchar2(1);
11882 l_x_line_tbl oe_order_pub.line_tbl_type;
11883 l_line_list varchar2(32000) := p_line_list;
11884 l_Header_list varchar2(32000) := p_Header_list;
11885 l_line_id number;
11886 l_header_id number;
11887 l_delimiter1 number;
11888 l_delimiter2 number;
11889 l_delimiter number;
11890 l_booked_flag varchar2(1);
11891 l_multiple_events Varchar2(1);
11892 l_order_status_rec QP_UTIL_PUB.ORDER_LINES_STATUS_REC_TYPE;
11893
11894 cursor has_prg_lines(p_line_id IN NUMBER) is
11895 Select 'Y'
11896 From OE_PRICE_ADJUSTMENTS a, OE_ORDER_LINES_ALL b
11897 Where b.line_id = p_line_id
11898 AND b.header_id = a.header_id
11899 And a.list_line_type_code = 'PRG';
11900
11901 l_has_prg_lines varchar2(1):= 'Q';
11902
11903 begin
11904 adj_debug('Performing Price Action for level '||P_price_level);
11905
11906 If P_price_level ='LINE' then
11907
11908 l_Price_Control_Rec.pricing_event := 'LINE';
11909 l_Price_Control_Rec.calculate_flag := QP_PREQ_GRP.G_SEARCH_N_CALCULATE;
11910 l_Price_Control_Rec.Simulation_Flag := 'N';
11911 l_has_prg_lines := 'Q';
11912
11913 -- Made changes to get line_id from p_line_list for Bug 2532740
11914
11915 l_delimiter2 := 0;
11916 for i in 1..p_line_count loop
11917 l_delimiter1 := l_delimiter2;
11918 l_delimiter2 := INSTR(p_line_list,',',l_delimiter1+1);
11919
11920 If l_delimiter2 = 0 Then
11921 l_line_id := to_number(substr(p_line_list,l_delimiter1+1));
11922 else
11923 -- 2665650 fix
11924 l_line_id := to_number(substr(p_line_list,l_delimiter1+1,l_delimiter2-1-l_delimiter1));
11925 end if;
11926
11927 IF l_has_prg_lines = 'Q' THEN
11928 Begin
11929 open has_prg_lines(l_line_id);
11930 fetch has_prg_lines into l_has_prg_lines;
11931 close has_prg_lines;
11932 Exception
11933 When no_data_found Then
11934 l_has_prg_lines:='N';
11935 When others Then
11936 l_has_prg_lines:='Y';
11937 End;
11938 END IF;
11939
11940 adj_debug('Price Action Line_Id:'||l_line_id);
11941 -- End of changes for 2532740
11942
11943 adj_debug('all_lines_flag from pricing api:'|| l_order_status_rec.ALL_LINES_FLAG);
11944 IF l_has_prg_lines = 'Y' THEN
11945 --fix bug 2788649,if PRG exists we will need to do price_line line per line --Need to call price_line line by line because PRG exists
11946 adj_debug('New price action, line by line because the order has prg');
11947
11948 oe_order_Adj_pvt.Price_line(
11949 X_Return_Status => l_Return_Status
11950 ,p_Request_Type_code=> 'ONT'
11951 ,p_Control_rec => l_Price_Control_Rec
11952 ,p_Write_To_Db => TRUE
11953 ,p_Line_id => l_line_id
11954 ,x_Line_Tbl => l_x_Line_Tbl
11955 );
11956
11957 ELSE
11958 --Regular old way,prepare all lines in one pl/sql table
11959 adj_debug('Old price_action way, order has no prg');
11960 Begin
11961
11962 l_x_line_tbl(i).Line_id := l_Line_id;
11963 oe_Line_util.query_row(
11964 p_Line_id => l_Line_id
11965 , x_line_rec => l_x_Line_Tbl(i)
11966 );
11967 Exception when no_data_found then
11968 null;
11969 End;
11970
11971 END IF;
11972
11973 End loop;
11974
11975 IF l_has_prg_lines IN ('N','Q') THEN
11976 oe_order_Adj_pvt.Price_line(
11977 X_Return_Status => l_Return_Status
11978 ,p_Request_Type_code=> 'ONT'
11979 ,p_Control_rec => l_Price_Control_Rec
11980 ,p_Write_To_Db => TRUE
11981 ,x_Line_Tbl => l_x_Line_Tbl
11982 );
11983 END IF;
11984
11985 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
11986 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11987 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
11988 RAISE FND_API.G_EXC_ERROR;
11989 END IF;
11990
11991
11992
11993 Else
11994 -- Made changes to get Header Id from p_Header_list for Bug 2532740
11995
11996 l_delimiter2 := 0;
11997 for i in 1..p_Header_count loop
11998 l_delimiter1 := l_delimiter2;
11999 l_delimiter2 := INSTR(p_Header_list,',',l_delimiter1+1);
12000
12001 If l_delimiter2 = 0 Then
12002 l_HEader_id := to_number(substr(p_Header_list,l_delimiter1+1));
12003 else
12004 -- 2665650 fix
12005 l_HEader_id := to_number(substr(p_Header_list,l_delimiter1+1,l_delimiter2-1-l_delimiter1));
12006 end if;
12007
12008 adj_debug('Price Action Header_id :'||l_HEader_id);
12009 -- End of changes for 2532740
12010
12011 Select booked_flag into l_booked_flag from oe_order_headers_all
12012 where header_id=l_header_id;
12013
12014 --Following code are commented out due to unresolved dependencies issue
12015 --with Oracle Pricing. However, this code will greatly improve performance
12016 --of action-->price_order if restored.
12017 --In order for this commented code to work pricing patch
12018 --1802580,1806021 and 1796034 must get applied.
12019
12020 If l_booked_flag <> 'Y' Then
12021 l_price_control_rec.pricing_event := 'BATCH';
12022 l_multiple_events := 'N';
12023 Elsif l_booked_flag = 'Y' Then
12024 l_price_control_rec.pricing_event := 'BATCH,BOOK,SHIP';
12025 l_multiple_events := 'Y';
12026 End If;
12027
12028 l_Price_Control_Rec.calculate_flag := QP_PREQ_GRP.G_SEARCH_N_CALCULATE;
12029 l_Price_Control_Rec.Simulation_Flag := 'N';
12030
12031 oe_order_Adj_pvt.Price_line(
12032 X_Return_Status => l_Return_Status
12033 ,p_header_id => l_header_id
12034 ,p_Request_Type_code=> 'ONT'
12035 ,p_Control_rec => l_Price_Control_Rec
12036 ,p_Write_To_Db => TRUE
12037 ,x_Line_Tbl => l_x_Line_Tbl
12038 ,p_multiple_events => l_multiple_events
12039 ,p_action_code => 'PRICE_ORDER');
12040
12041 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
12042 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
12043 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
12044 RAISE FND_API.G_EXC_ERROR;
12045 END IF;
12046
12047 end loop; -- Headers
12048
12049 End If;
12050
12051 OE_MSG_PUB.Count_And_Get
12052 ( p_count => x_msg_count
12053 , p_data => x_msg_data
12054 );
12055
12056 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
12057 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
12058 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
12059 RAISE FND_API.G_EXC_ERROR;
12060 END IF;
12061
12062 x_Return_Status := FND_API.G_RET_STS_SUCCESS;
12063
12064 adj_debug('Exiting oe_order_Adj_pvt.Price_adjustments',1);
12065
12066
12067 EXCEPTION
12068
12069 WHEN FND_API.G_EXC_ERROR THEN
12070 x_return_status := FND_API.G_RET_STS_ERROR;
12071 OE_MSG_PUB.Count_And_Get
12072 ( p_count => x_msg_count
12073 ,p_data => x_msg_data
12074 );
12075
12076 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
12077 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
12078 OE_MSG_PUB.Count_And_Get
12079 ( p_count => x_msg_count
12080 ,p_data => x_msg_data
12081 );
12082
12083 WHEN OTHERS THEN
12084 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
12085 adj_debug(' '||sqlerrm,1);
12086 OE_MSG_PUB.Count_And_Get
12087 ( p_count => x_msg_count
12088 , p_data => x_msg_data
12089 );
12090
12091 end price_action;
12092
12093
12094 Procedure Set_Header(p_header IN quote_header_rec_type) As
12095 Begin
12096 oe_order_pub.g_hdr.accounting_rule_id :=p_header.accounting_rule_id ;
12097 oe_order_pub.g_hdr.agreement_id :=p_header.agreement_id ;
12098 oe_order_pub.g_hdr.booked_flag :=p_header.booked_flag ;
12099 oe_order_pub.g_hdr.cancelled_flag :=p_header.cancelled_flag ;
12100 oe_order_pub.g_hdr.context :=p_header.context ;
12101 oe_order_pub.g_hdr.conversion_rate :=p_header.conversion_rate ;
12102 oe_order_pub.g_hdr.conversion_rate_date :=p_header.conversion_rate_date ;
12103 oe_order_pub.g_hdr.conversion_type_code :=p_header.conversion_type_code ;
12104 oe_order_pub.g_hdr.customer_preference_set_code :=p_header.customer_preference_set_code;
12105 oe_order_pub.g_hdr.cust_po_number :=p_header.cust_po_number ;
12106 oe_order_pub.g_hdr.deliver_to_contact_id :=p_header.deliver_to_contact_id ;
12107 oe_order_pub.g_hdr.deliver_to_org_id :=p_header.deliver_to_org_id ;
12108 oe_order_pub.g_hdr.demand_class_code :=p_header.demand_class_code ;
12109 oe_order_pub.g_hdr.expiration_date :=p_header.expiration_date ;
12110 oe_order_pub.g_hdr.fob_point_code :=p_header.fob_point_code ;
12111 oe_order_pub.g_hdr.freight_carrier_code :=p_header.freight_carrier_code ;
12112 oe_order_pub.g_hdr.freight_terms_code :=p_header.freight_terms_code ;
12113 oe_order_pub.g_hdr.invoice_to_contact_id :=p_header.invoice_to_contact_id ;
12114 oe_order_pub.g_hdr.invoice_to_org_id :=p_header.invoice_to_org_id ;
12115 oe_order_pub.g_hdr.invoicing_rule_id :=p_header.invoicing_rule_id ;
12116 oe_order_pub.g_hdr.order_category_code :=p_header.order_category_code ;
12117 oe_order_pub.g_hdr.ordered_date :=p_header.ordered_date ;
12118 oe_order_pub.g_hdr.order_date_type_code :=p_header.order_date_type_code ;
12119 oe_order_pub.g_hdr.order_number :=p_header.order_number ;
12120 oe_order_pub.g_hdr.order_source_id :=p_header.order_source_id ;
12121 oe_order_pub.g_hdr.order_type_id :=p_header.order_type_id ;
12122 oe_order_pub.g_hdr.org_id :=p_header.org_id ;
12123 oe_order_pub.g_hdr.payment_term_id :=p_header.payment_term_id ;
12124 oe_order_pub.g_hdr.price_list_id :=p_header.price_list_id ;
12125 oe_order_pub.g_hdr.pricing_date :=p_header.pricing_date ;
12126 oe_order_pub.g_hdr.request_date :=p_header.request_date ;
12127 oe_order_pub.g_hdr.request_id :=p_header.request_id ;
12128 oe_order_pub.g_hdr.salesrep_id :=p_header.salesrep_id ;
12129 oe_order_pub.g_hdr.sales_channel_code :=p_header.sales_channel_code ;
12130 oe_order_pub.g_hdr.shipment_priority_code :=p_header.shipment_priority_code ;
12131 oe_order_pub.g_hdr.shipping_method_code :=p_header.shipping_method_code ;
12132 oe_order_pub.g_hdr.ship_from_org_id :=p_header.ship_from_org_id ;
12133 oe_order_pub.g_hdr.ship_to_contact_id :=p_header.ship_to_contact_id ;
12134 oe_order_pub.g_hdr.ship_to_org_id :=p_header.ship_to_org_id ;
12135 oe_order_pub.g_hdr.sold_from_org_id :=p_header.sold_from_org_id ;
12136 oe_order_pub.g_hdr.sold_to_contact_id :=p_header.sold_to_contact_id ;
12137 oe_order_pub.g_hdr.sold_to_org_id :=p_header.sold_to_org_id ;
12138 oe_order_pub.g_hdr.source_document_id :=p_header.source_document_id ;
12139 oe_order_pub.g_hdr.source_document_type_id :=p_header.source_document_type_id ;
12140 oe_order_pub.g_hdr.transactional_curr_code :=p_header.transactional_curr_code ;
12141 oe_order_pub.g_hdr.drop_ship_flag :=p_header.drop_ship_flag ;
12142 oe_order_pub.g_hdr.customer_payment_term_id :=p_header.customer_payment_term_id ;
12143 oe_order_pub.g_hdr.payment_type_code :=p_header.payment_type_code ;
12144 oe_order_pub.g_hdr.payment_amount :=p_header.payment_amount ;
12145 oe_order_pub.g_hdr.credit_card_code :=p_header.credit_card_code ;
12146 oe_order_pub.g_hdr.credit_card_holder_name :=p_header.credit_card_holder_name ;
12147 oe_order_pub.g_hdr.credit_card_number :=p_header.credit_card_number ;
12148 oe_order_pub.g_hdr.marketing_source_code_id :=p_header.marketing_source_code_id ;
12149
12150 End Set_Header;
12151
12152 Procedure Load_Line_Tbl(p_quote_line_tbl in quote_line_tbl_type,
12153 x_line_tbl out nocopy Oe_Order_Pub.line_tbl_type) As
12154
12155 i PLS_INTEGER;
12156 Begin
12157 --DBMS_OUTPUT.PUT_LINE('In load line tbl');
12158 i := p_quote_line_tbl.First;
12159 While i Is Not Null Loop
12160 x_line_tbl(i).actual_arrival_date :=p_quote_line_tbl(i).actual_arrival_date ;
12161 x_line_tbl(i).actual_shipment_date :=p_quote_line_tbl(i).actual_shipment_date ;
12162 x_line_tbl(i).agreement_id :=p_quote_line_tbl(i).agreement_id ;
12163 x_line_tbl(i).cancelled_quantity :=p_quote_line_tbl(i).cancelled_quantity ;
12164 x_line_tbl(i).cust_po_number :=p_quote_line_tbl(i).cust_po_number ;
12165 x_line_tbl(i).deliver_to_contact_id :=p_quote_line_tbl(i).deliver_to_contact_id ;
12166 x_line_tbl(i).deliver_to_org_id :=p_quote_line_tbl(i).deliver_to_org_id ;
12167 x_line_tbl(i).freight_carrier_code :=p_quote_line_tbl(i).freight_carrier_code ;
12168 x_line_tbl(i).freight_terms_code :=p_quote_line_tbl(i).freight_terms_code ;
12169 x_line_tbl(i).intermed_ship_to_org_id :=p_quote_line_tbl(i).intermed_ship_to_org_id ;
12170 x_line_tbl(i).intermed_ship_to_contact_id:=p_quote_line_tbl(i).intermed_ship_to_contact_id;
12171 x_line_tbl(i).inventory_item_id :=p_quote_line_tbl(i).inventory_item_id ;
12172 x_line_tbl(i).invoice_interface_status_code:=p_quote_line_tbl(i).invoice_interface_status_code;
12173 x_line_tbl(i).invoice_to_contact_id :=p_quote_line_tbl(i).invoice_to_contact_id ;
12174 x_line_tbl(i).invoice_to_org_id :=p_quote_line_tbl(i).invoice_to_org_id ;
12175 x_line_tbl(i).ordered_item :=p_quote_line_tbl(i).ordered_item ;
12176 x_line_tbl(i).item_type_code :=p_quote_line_tbl(i).item_type_code ;
12177 x_line_tbl(i).line_type_id :=p_quote_line_tbl(i).line_type_id ;
12178 x_line_tbl(i).ordered_quantity :=p_quote_line_tbl(i).ordered_quantity ;
12179 x_line_tbl(i).ordered_quantity2 :=p_quote_line_tbl(i).ordered_quantity2 ;
12180 x_line_tbl(i).order_quantity_uom :=p_quote_line_tbl(i).order_quantity_uom ;
12181 x_line_tbl(i).ordered_quantity_uom2 :=p_quote_line_tbl(i).ordered_quantity_uom2 ;
12182 x_line_tbl(i).org_id :=p_quote_line_tbl(i).org_id ;
12183 x_line_tbl(i).payment_term_id :=p_quote_line_tbl(i).payment_term_id ;
12184 x_line_tbl(i).price_list_id :=p_quote_line_tbl(i).price_list_id ;
12185 x_line_tbl(i).pricing_context :=p_quote_line_tbl(i).pricing_context ;
12186 x_line_tbl(i).pricing_date :=p_quote_line_tbl(i).pricing_date ;
12187 x_line_tbl(i).pricing_quantity :=p_quote_line_tbl(i).pricing_quantity ;
12188 x_line_tbl(i).pricing_quantity_uom :=p_quote_line_tbl(i).pricing_quantity_uom ;
12189 x_line_tbl(i).project_id :=p_quote_line_tbl(i).project_id ;
12190 x_line_tbl(i).promise_date :=p_quote_line_tbl(i).promise_date ;
12191 x_line_tbl(i).salesrep_id :=p_quote_line_tbl(i).salesrep_id ;
12192 x_line_tbl(i).schedule_arrival_date :=p_quote_line_tbl(i).schedule_arrival_date ;
12193 x_line_tbl(i).schedule_ship_date :=p_quote_line_tbl(i).schedule_ship_date ;
12194 x_line_tbl(i).ship_from_org_id :=p_quote_line_tbl(i).ship_from_org_id ;
12195 x_line_tbl(i).ship_to_org_id :=p_quote_line_tbl(i).ship_to_org_id ;
12196 x_line_tbl(i).sold_to_org_id :=p_quote_line_tbl(i).sold_to_org_id ;
12197 x_line_tbl(i).sold_from_org_id :=p_quote_line_tbl(i).sold_from_org_id ;
12198 x_line_tbl(i).source_document_type_id :=p_quote_line_tbl(i).source_document_type_id ;
12199 x_line_tbl(i).task_id :=p_quote_line_tbl(i).task_id ;
12200 x_line_tbl(i).tax_code :=p_quote_line_tbl(i).tax_code ;
12201 x_line_tbl(i).unit_list_price_per_pqty :=p_quote_line_tbl(i).unit_list_price ;
12202 x_line_tbl(i).unit_selling_price_per_pqty:=p_quote_line_tbl(i).unit_selling_price ;
12203 x_line_tbl(i).order_source_id :=p_quote_line_tbl(i).order_source_id ;
12204 x_line_tbl(i).customer_payment_term_id :=p_quote_line_tbl(i).customer_payment_term_id ;
12205 x_line_tbl(i).ordered_item_id :=p_quote_line_tbl(i).ordered_item_id ;
12206 x_line_tbl(i).item_identifier_type :=p_quote_line_tbl(i).item_identifier_type ;
12207 x_line_tbl(i).unit_list_percent :=p_quote_line_tbl(i).unit_list_percent ;
12208 x_line_tbl(i).unit_selling_percent :=p_quote_line_tbl(i).unit_selling_percent ;
12209 x_line_tbl(i).unit_percent_base_price :=p_quote_line_tbl(i).unit_percent_base_price ;
12210 x_line_tbl(i).service_number :=p_quote_line_tbl(i).service_number ;
12211 x_line_tbl(i).revenue_amount :=p_quote_line_tbl(i).revenue_amount ;
12212 x_line_tbl(i).line_id :=p_quote_line_tbl(i).line_id ;
12213 i :=p_quote_line_tbl.Next(i);
12214 /*if i > 100 then DBMS_OUTPUT.PUT_LINE('Inf Loop2'); end if;
12215 exit when i > 100; */
12216 End Loop;
12217
12218 End;
12219
12220 Procedure Load_Out_Quote_Line (p_line_tbl In Oe_Order_Pub.Line_tbl_Type,
12221 p_req_line_tbl In QP_PREQ_GRP.LINE_TBL_TYPE,
12222 x_quote_line_tbl out nocopy quote_line_tbl_type) As
12223
12224 i PLS_INTEGER;
12225 Begin
12226 --DBMS_OUTPUT.PUT_LINE('In load out quote');
12227 i := p_line_tbl.First;
12228 While i Is Not Null Loop
12229 x_quote_line_tbl(i).actual_arrival_date :=p_line_tbl(i).actual_arrival_date ;
12230 x_quote_line_tbl(i).actual_shipment_date :=p_line_tbl(i).actual_shipment_date ;
12231 x_quote_line_tbl(i).agreement_id :=p_line_tbl(i).agreement_id ;
12232 x_quote_line_tbl(i).cancelled_quantity :=p_line_tbl(i).cancelled_quantity ;
12233 x_quote_line_tbl(i).cust_po_number :=p_line_tbl(i).cust_po_number ;
12234 x_quote_line_tbl(i).deliver_to_contact_id :=p_line_tbl(i).deliver_to_contact_id ;
12235 x_quote_line_tbl(i).deliver_to_org_id :=p_line_tbl(i).deliver_to_org_id ;
12236 x_quote_line_tbl(i).freight_carrier_code :=p_line_tbl(i).freight_carrier_code ;
12237 x_quote_line_tbl(i).freight_terms_code :=p_line_tbl(i).freight_terms_code ;
12238 x_quote_line_tbl(i).intermed_ship_to_org_id :=p_line_tbl(i).intermed_ship_to_org_id ;
12239 x_quote_line_tbl(i).intermed_ship_to_contact_id:=p_line_tbl(i).intermed_ship_to_contact_id;
12240 x_quote_line_tbl(i).inventory_item_id :=p_line_tbl(i).inventory_item_id ;
12241 x_quote_line_tbl(i).invoice_interface_status_code:=p_line_tbl(i).invoice_interface_status_code;
12242 x_quote_line_tbl(i).invoice_to_contact_id :=p_line_tbl(i).invoice_to_contact_id ;
12243 x_quote_line_tbl(i).invoice_to_org_id :=p_line_tbl(i).invoice_to_org_id ;
12244 x_quote_line_tbl(i).ordered_item :=p_line_tbl(i).ordered_item ;
12245 x_quote_line_tbl(i).item_type_code :=p_line_tbl(i).item_type_code ;
12246 x_quote_line_tbl(i).line_type_id :=p_line_tbl(i).line_type_id ;
12247 x_quote_line_tbl(i).ordered_quantity :=p_line_tbl(i).ordered_quantity ;
12248 x_quote_line_tbl(i).ordered_quantity2 :=p_line_tbl(i).ordered_quantity2 ;
12249 x_quote_line_tbl(i).order_quantity_uom :=p_line_tbl(i).order_quantity_uom ;
12250 x_quote_line_tbl(i).ordered_quantity_uom2 :=p_line_tbl(i).ordered_quantity_uom2 ;
12251 x_quote_line_tbl(i).org_id :=p_line_tbl(i).org_id ;
12252 x_quote_line_tbl(i).payment_term_id :=p_line_tbl(i).payment_term_id ;
12253 x_quote_line_tbl(i).price_list_id :=p_line_tbl(i).price_list_id ;
12254 x_quote_line_tbl(i).pricing_context :=p_line_tbl(i).pricing_context ;
12255 x_quote_line_tbl(i).pricing_date :=p_line_tbl(i).pricing_date ;
12256 x_quote_line_tbl(i).pricing_quantity :=p_line_tbl(i).pricing_quantity ;
12257 x_quote_line_tbl(i).pricing_quantity_uom :=p_line_tbl(i).pricing_quantity_uom ;
12258 x_quote_line_tbl(i).project_id :=p_line_tbl(i).project_id ;
12259 x_quote_line_tbl(i).promise_date :=p_line_tbl(i).promise_date ;
12260 x_quote_line_tbl(i).salesrep_id :=p_line_tbl(i).salesrep_id ;
12261 x_quote_line_tbl(i).schedule_arrival_date :=p_line_tbl(i).schedule_arrival_date ;
12262 x_quote_line_tbl(i).schedule_ship_date :=p_line_tbl(i).schedule_ship_date ;
12263 x_quote_line_tbl(i).ship_from_org_id :=p_line_tbl(i).ship_from_org_id ;
12264 x_quote_line_tbl(i).ship_to_org_id :=p_line_tbl(i).ship_to_org_id ;
12265 x_quote_line_tbl(i).sold_to_org_id :=p_line_tbl(i).sold_to_org_id ;
12266 x_quote_line_tbl(i).sold_from_org_id :=p_line_tbl(i).sold_from_org_id ;
12267 x_quote_line_tbl(i).source_document_type_id :=p_line_tbl(i).source_document_type_id ;
12268 x_quote_line_tbl(i).task_id :=p_line_tbl(i).task_id ;
12269 x_quote_line_tbl(i).tax_code :=p_line_tbl(i).tax_code ;
12270 x_quote_line_tbl(i).unit_list_price :=p_line_tbl(i).unit_list_price_per_pqty ;
12271 x_quote_line_tbl(i).unit_selling_price :=p_line_tbl(i).unit_selling_price_per_pqty;
12272 x_quote_line_tbl(i).order_source_id :=p_line_tbl(i).order_source_id ;
12273 x_quote_line_tbl(i).customer_payment_term_id :=p_line_tbl(i).customer_payment_term_id ;
12274 x_quote_line_tbl(i).ordered_item_id :=p_line_tbl(i).ordered_item_id ;
12275 x_quote_line_tbl(i).item_identifier_type :=p_line_tbl(i).item_identifier_type ;
12276 x_quote_line_tbl(i).unit_list_percent :=p_line_tbl(i).unit_list_percent ;
12277 x_quote_line_tbl(i).unit_selling_percent :=p_line_tbl(i).unit_selling_percent ;
12278 x_quote_line_tbl(i).unit_percent_base_price :=p_line_tbl(i).unit_percent_base_price ;
12279 x_quote_line_tbl(i).service_number :=p_line_tbl(i).service_number ;
12280 x_quote_line_tbl(i).revenue_amount :=p_line_tbl(i).revenue_amount ;
12281 x_quote_line_tbl(i).line_id :=p_line_tbl(i).line_id ;
12282 --use this attribute for place holder of status code. Because there are
12283 --no place holder for status on line_rec record type
12284 If (p_line_tbl(i).industry_attribute30) In
12285 (QP_PREQ_GRP.G_STATUS_INVALID_PRICE_LIST,
12286 QP_PREQ_GRP.G_STS_LHS_NOT_FOUND,
12287 QP_PREQ_GRP.G_STATUS_FORMULA_ERROR,
12288 QP_PREQ_GRP.G_STATUS_OTHER_ERRORS,
12289 FND_API.G_RET_STS_UNEXP_ERROR,
12290 FND_API.G_RET_STS_ERROR,
12291 QP_PREQ_GRP.G_STATUS_CALC_ERROR,
12292 QP_PREQ_GRP.G_STATUS_UOM_FAILURE,
12293 QP_PREQ_GRP.G_STATUS_INVALID_UOM,
12294 QP_PREQ_GRP.G_STATUS_DUP_PRICE_LIST,
12295 QP_PREQ_GRP.G_STATUS_INVALID_UOM_CONV,
12296 QP_PREQ_GRP.G_STATUS_INVALID_INCOMP,
12297 QP_PREQ_GRP.G_STATUS_BEST_PRICE_EVAL_ERROR
12298 ) Then
12299
12300 x_quote_line_tbl(i).Status_Code:= p_line_tbl(i).industry_attribute30;
12301 --DBMS_OUTPUT.PUT_LINE('+++F++:'||x_quote_line_tbl(i).Status_Code);
12302 Else
12303 x_quote_line_tbl(i).Status_Code:=FND_API.G_RET_STS_SUCCESS;
12304 --DBMS_OUTPUT.PUT_LINE('+++S++:'|| x_quote_line_tbl(i).Status_Code);
12305 End If;
12306
12307 i:= p_line_tbl.Next(i);
12308
12309 End Loop;
12310
12311 End;
12312
12313 Procedure Get_Quote(p_quote_header in quote_header_rec_type,
12314 p_quote_line_tbl in quote_line_tbl_type,
12315 p_request_type_code in Varchar2, --'ONT','QP' etc
12316 p_event in varchar2 default 'BATCH',
12317 x_quote_line_tbl out nocopy quote_line_tbl_type,
12318
12319 x_return_status out nocopy Varchar2,
12320
12321 x_return_status_text out nocopy Varchar2) As
12322
12323
12324 l_line_tbl Oe_Order_Pub.line_tbl_type;
12325 l_control_rec Qp_Preq_Grp.control_record_type;
12326 l_req_line_tbl QP_PREQ_GRP.LINE_TBL_TYPE;
12327 l_Req_qual_tbl QP_PREQ_GRP.QUAL_TBL_TYPE;
12328 l_Req_line_attr_tbl QP_PREQ_GRP.LINE_ATTR_TBL_TYPE;
12329 l_Req_LINE_DETAIL_tbl QP_PREQ_GRP.LINE_DETAIL_TBL_TYPE;
12330 l_Req_LINE_DETAIL_qual_tbl QP_PREQ_GRP.LINE_DETAIL_QUAL_TBL_TYPE;
12331 l_Req_LINE_DETAIL_attr_tbl QP_PREQ_GRP.LINE_DETAIL_ATTR_TBL_TYPE;
12332 l_Req_related_lines_tbl QP_PREQ_GRP.RELATED_LINES_TBL_TYPE;
12333 l_any_frozen_line Boolean;
12334 l_hdr_rec Oe_Order_Pub.Header_Rec_Type;
12335 l_stmt Varchar2(50);
12336 i PLS_INTEGER;
12337 Begin
12338
12339 Set_Header(p_quote_header);
12340 Load_line_Tbl(p_quote_line_tbl,l_line_tbl);
12341
12342 --getting a quote is always a batch event
12343 l_control_rec.pricing_event := p_event;
12344
12345 l_control_rec.calculate_flag := QP_PREQ_GRP.G_SEARCH_N_CALCULATE;
12346 l_control_rec.simulation_Flag := 'N';
12347 l_stmt := 'quote 1';
12348 calculate_adjustments
12349 (x_return_status =>x_return_status ,
12350 p_Request_Type_Code =>p_request_type_code ,
12351 p_Control_Rec =>l_control_rec ,
12352 x_req_line_tbl =>l_req_line_tbl ,
12353 x_Req_qual_tbl =>l_Req_qual_tbl ,
12354 x_Req_line_attr_tbl =>l_Req_line_attr_tbl ,
12355 x_Req_LINE_DETAIL_tbl =>l_Req_LINE_DETAIL_tbl ,
12356 x_Req_LINE_DETAIL_qual_tbl =>l_Req_LINE_DETAIL_qual_tbl ,
12357 x_Req_LINE_DETAIL_attr_tbl =>l_Req_LINE_DETAIL_attr_tbl ,
12358 x_Req_related_lines_tbl =>l_Req_related_lines_tbl ,
12359 p_use_current_header =>TRUE,
12360 p_write_to_db =>FALSE,
12361 x_any_frozen_line =>l_any_frozen_line,
12362 x_Header_Rec =>l_hdr_rec,
12363 x_line_Tbl =>l_line_tbl);
12364
12365 l_stmt := 'quote 2';
12366
12367 process_adjustments
12368 (
12369 p_Request_Type_Code => p_request_type_code,
12370 x_return_status => x_Return_Status,
12371 p_Req_Control_Rec => l_control_rec,
12372 p_req_line_tbl => l_req_line_tbl,
12373 p_Req_qual_tbl => l_Req_qual_tbl,
12374 p_Req_line_attr_tbl => l_Req_line_attr_tbl,
12375 p_Req_Line_Detail_tbl => l_Req_LINE_DETAIL_tbl,
12376 p_Req_Line_Detail_Qual_tbl => l_Req_LINE_DETAIL_qual_tbl,
12377 p_Req_Line_Detail_Attr_tbl => l_Req_LINE_DETAIL_attr_tbl,
12378 p_Req_related_lines_tbl => l_Req_related_lines_tbl,
12379 p_write_to_db => FALSE,
12380 p_any_frozen_line => l_any_frozen_line,
12381 p_Header_Rec => l_Hdr_Rec,
12382 x_line_Tbl => l_Line_Tbl,
12383 p_honor_price_flag => 'Y' --bug 2503186
12384 );
12385
12386 Load_Out_Quote_Line(l_Line_Tbl,l_req_line_tbl,x_quote_line_tbl);
12387
12388 Exception
12389 When Others Then
12390 x_return_status := FND_API.G_RET_STS_ERROR;
12391 x_return_status_text := 'Oe_Order_Adj_Pvt.Get_Quote: '||l_stmt||': '||SQLERRM;
12392
12393 End get_quote;
12394
12395 /***************************************************************************************************
12396 Procedure Create_Manual_Adjustments
12397 Purpose : Insert manual overriable adjustment into Oe_Price_Adjustments
12398 Called by : Mass Change pld
12399 Known Issues: Doesn't handle order level manual overriable adjustment
12400 ****************************************************************************************************/
12401 Procedure Create_Manual_Adjustments(p_line_id In Number)
12402 As
12403 l_return_stauts Varchar2(15);
12404 l_manual_adj_tbl Oe_Order_Adj_Pvt.Manual_Adj_Tbl_Type;
12405 l_line_adj_tbl Oe_Order_Pub.line_adj_tbl_type;
12406 l_dummy_tbl Oe_Order_Pub.line_adj_tbl_type;
12407 l_control_rec OE_GLOBALS.Control_Rec_Type;
12408 i PLS_INTEGER;
12409 k PLS_INTEGER:=1;
12410 l_return_status Varchar2(15);
12411 l_found Varchar2(1):='N';
12412 stmt Varchar2(240);
12413 l_header_id NUMBER;
12414
12415
12416 Begin
12417 l_control_rec.private_call := TRUE;
12418 l_control_rec.controlled_operation := TRUE;
12419 l_control_rec.check_security := FALSE;
12420 l_control_rec.validate_entity := FALSE;
12421 l_control_rec.write_to_db := TRUE;
12422 l_control_rec.change_attributes := FALSE;
12423
12424 Oe_Debug_Pub.add('Mass Change line id: '||p_line_id);
12425 stmt:='1';
12426
12427 --For mass change it could be different order headers for lines therefore p_cross_order = 'Y'
12428 Get_Manual_Adjustments(p_line_id => p_line_id,
12429 p_cross_order => 'Y',
12430 x_manual_adj_tbl => l_manual_adj_tbl,
12431 x_return_status => l_return_status,
12432 x_header_id => l_header_id,
12433 p_called_from => 'SO');
12434 stmt:='2';
12435 i := l_manual_adj_tbl.First;
12436 While i Is Not Null Loop
12437 If l_manual_adj_tbl(i).override_flag = 'Y' Then
12438 --check if such modifier list exists in Oe_Price_Adjustments
12439 --If it is there don't insert a new one
12440 Oe_debug_Pub.add(' Override_flag:'||l_manual_adj_tbl(i).override_flag);
12441 Begin
12442 Select 'Y' Into l_found
12443 From Dual
12444 Where exists (Select 'X' From Oe_Price_Adjustments
12445 Where line_id = p_line_id
12446 and list_line_id = l_manual_adj_tbl(i).list_line_id);
12447 l_found:='Y';
12448 Exception
12449 When No_Data_Found Then
12450 l_found := 'N';
12451 End;
12452 stmt:='10';
12453 --Insert only if no modifier list line found.
12454 If l_found = 'N' Then
12455 oe_debug_pub.add(' Creating overridable manual in oe_price_adjustments');
12456 l_line_adj_tbl(1).list_line_no := l_manual_adj_tbl(i).modifier_number; /* Bug #3738023 */
12457 l_line_adj_tbl(1).list_header_id := l_manual_adj_tbl(i).list_header_id;
12458 l_line_adj_tbl(1).list_line_id := l_manual_adj_tbl(i).list_line_id;
12459 l_line_adj_tbl(1).list_line_type_code := l_manual_adj_tbl(i).list_line_type_code;
12460 l_line_adj_tbl(1).modifier_level_code := l_manual_adj_tbl(i).modifier_level_code;
12461 l_line_adj_tbl(1).operand := l_manual_adj_tbl(i).operand;
12462 l_line_adj_tbl(1).arithmetic_operator := l_manual_adj_tbl(i).operator;
12463 l_line_adj_tbl(1).update_allowed := l_manual_adj_tbl(i).override_flag;
12464 l_line_adj_tbl(k).header_id := l_header_id;
12465 l_line_adj_tbl(1).line_id := p_line_id;
12466 l_line_adj_tbl(1).applied_flag := 'N';
12467 l_line_adj_tbl(1).updated_flag := 'N';
12468 l_line_adj_tbl(1).automatic_flag := 'N';
12469 l_line_adj_tbl(1).operation := OE_GLOBALS.G_OPR_CREATE;
12470 Select Oe_Price_Adjustments_S.Nextval
12471 Into l_line_adj_tbl(1).price_adjustment_id
12472 From dual;
12473 stmt:='20';
12474 Line_Adjs(p_validation_level => FND_API.G_VALID_LEVEL_NONE,
12475 p_control_rec => l_control_rec,
12476 p_x_line_adj_tbl => l_line_adj_tbl,
12477 p_x_old_line_adj_tbl => l_dummy_tbl);
12478 stmt:='30';
12479 End If;
12480 --k:=k+1;
12481 End If;
12482 i:= l_manual_adj_tbl.Next(i);
12483 End Loop;
12484
12485 Exception When Others Then
12486 Oe_Debug_Pub.Add('Error occured in oe_order_adj_pvt.create_manual_adjustments:'||stmt||':'||SQLERRM);
12487 Raise;
12488 End Create_Manual_Adjustments;
12489
12490
12491
12492 /******************************************************************************************************
12493 Procedure Get_Manual_Adjustments
12494 Called by: Unit selling price lov
12495 Purpose: Return manual adjustments
12496 Input:
12497 p_header_id: For the case of linegroup manual adjustment, all lines will need to pass to engine
12498 for evaluation.
12499 p_line_rec: For the case of no linegroup manual adjustment, one line rec is sufficient
12500 *******************************************************************************************************/
12501
12502 Procedure Get_Manual_Adjustments (
12503 p_header_id in number Default Null,
12504 p_line_id in number Default Null,
12505 p_line_rec in oe_Order_Pub.Line_Rec_Type Default oe_order_pub.g_miss_line_rec,
12506 p_level in Varchar2 default 'LINE',
12507 p_pbh_mode in Varchar2 default 'CHILD',
12508 p_cross_order in Varchar2 Default 'N',
12509 p_line_level in Varchar2 Default 'N',
12510 x_manual_adj_tbl out Nocopy Oe_Order_Adj_Pvt.Manual_Adj_Tbl_Type,
12511 x_return_status out nocopy Varchar2,
12512
12513 x_header_id out nocopy Number,
12514 p_freight_flag in boolean default false,
12515 p_called_from in varchar2 default null
12516
12517 --if no header id passed in this procedure it will return header id based on line id passed in
12518 )
12519 As
12520 l_profile_value Varchar2(1):= Nvl(Fnd_Profile.Value('ONT_MANUAL_LINEGROUP'),'Y');
12521 l_line_tbl oe_Order_Pub.Line_tbl_Type;
12522 l_line_rec oe_order_pub.line_rec_type;
12523 l_pricing_contexts_Tbl QP_Attr_Mapping_PUB.Contexts_Result_Tbl_Type;
12524 l_qualifier_contexts_Tbl QP_Attr_Mapping_PUB.Contexts_Result_Tbl_Type;
12525 l_Req_qual_tbl QP_PREQ_GRP.QUAL_TBL_TYPE;
12526 l_Req_line_attr_tbl QP_PREQ_GRP.LINE_ATTR_TBL_TYPE;
12527 l_req_line_tbl QP_PREQ_GRP.LINE_TBL_TYPE;
12528 l_Req_LINE_DETAIL_tbl QP_PREQ_GRP.LINE_DETAIL_TBL_TYPE;
12529 l_Req_LINE_DETAIL_qual_tbl QP_PREQ_GRP.LINE_DETAIL_QUAL_TBL_TYPE;
12530 l_Req_LINE_DETAIL_attr_tbl QP_PREQ_GRP.LINE_DETAIL_ATTR_TBL_TYPE;
12531 l_Req_related_lines_tbl QP_PREQ_GRP.RELATED_LINES_TBL_TYPE;
12532 lx_Req_qual_tbl QP_PREQ_GRP.QUAL_TBL_TYPE;
12533 lx_Req_line_attr_tbl QP_PREQ_GRP.LINE_ATTR_TBL_TYPE;
12534 lx_req_line_tbl QP_PREQ_GRP.LINE_TBL_TYPE;
12535 lx_Req_LINE_DETAIL_tbl QP_PREQ_GRP.LINE_DETAIL_TBL_TYPE;
12536 lx_Req_LINE_DETAIL_qual_tbl QP_PREQ_GRP.LINE_DETAIL_QUAL_TBL_TYPE;
12537 lx_Req_LINE_DETAIL_attr_tbl QP_PREQ_GRP.LINE_DETAIL_ATTR_TBL_TYPE;
12538 lx_Req_related_lines_tbl QP_PREQ_GRP.RELATED_LINES_TBL_TYPE;
12539 l_Control_Rec QP_PREQ_GRP.CONTROL_RECORD_TYPE;
12540 l_event Varchar2(30) Default 'BATCH';
12541 l_return_status Varchar2(10);
12542 l_return_status_text Varchar2(240);
12543 i PLS_INTEGER;
12544 j PLS_INTEGER;
12545 k PLS_INTEGER;
12546 line_tbl_index PLS_INTEGER;
12547 QP_ATTR_MAPPING_ERRORS Exception;
12548
12549 l_ask_for_profile Varchar2(1):=NVL(Fnd_Profile.Value('ONT_ASK_FOR_PROMOTION'),'Y');
12550 l_dummy Varchar2(1);
12551
12552 l_header_id Number;
12553 --indicates whether line has already been written to DB
12554 l_posted_to_DB BOOLEAN := FALSE;
12555 l_header_id2 NUMBER;
12556 --bucket man
12557 l_pass_line varchar2(1);
12558 l_check_line_flag varchar2(1); --5598523
12559 l_line_index NUMBER := 0;
12560 l_line_attr_index number:=0;
12561 --bug 3531938
12562 l_order_status_rec QP_UTIL_PUB.ORDER_LINES_STATUS_REC_TYPE;
12563 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
12564
12565 l_manual_all_lines_status Varchar2(1); --bug 7600510
12566
12567 cursor man_adj is
12568 select ld.automatic_flag, ld.line_index, ld.modifier_level_code,
12569 ld.line_quantity, ld.line_detail_type_code,
12570 ld.CREATED_FROM_LIST_LINE_TYPE list_line_type_code,
12571 ld.list_line_no, ld.operand_value,
12572 ld.CREATED_FROM_LIST_LINE_ID list_line_id,
12573 ld.CREATED_FROM_LIST_HEADER_ID list_header_id,
12574 ld.pricing_phase_id, ll.override_flag, ld.operand_calculation_code,
12575 ld.ADJUSTMENT_AMOUNT, ll.CHARGE_TYPE_CODE, ll.CHARGE_SUBTYPE_CODE,
12576 l.line_type_code, l.line_id, ld.PRICE_BREAK_TYPE_CODE,
12577 ld.pricing_group_sequence
12578 from QP_PREQ_LINES_TMP l, QP_PREQ_LDETS_TMP ld, QP_LIST_LINES ll
12579 where l.line_index = ld.line_index
12580 and ld.CREATED_FROM_LIST_LINE_ID = ll.LIST_LINE_ID
12581 and ld.PRICING_STATUS_CODE = QP_PREQ_GRP.G_STATUS_NEW
12582 ORDER BY ld.list_line_no; -- bug 6323362
12583
12584 --bucket man
12585 Begin
12586 if p_freight_flag then
12587 oe_debug_pub.add('freight flag is true');
12588 else
12589 oe_debug_pub.add('freight flag is false');
12590 end if;
12591 x_return_status:=FND_API.G_RET_STS_SUCCESS;
12592 --l_profile_value := Fnd_Profile.Value('QP_MANUAL_LINEGROUP');
12593 oe_debug_pub.add('Entering Get Manual Adj');
12594 --bucket man
12595 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
12596 oe_order_price_pvt.reset_all_tbls;
12597 qp_price_request_context.set_request_id;
12598 END IF;
12599 -- bucket man
12600
12601 G_STMT_NO := 'Get_manual_adjustment#0';
12602
12603
12604 --this profile_value is to indicate if want to pass all the lines or just one line
12605 --to pricing engine
12606 --In the case of order level manual adjustments we will always pass in
12607 --all the lines regardless of profile_value
12608 --bug 3531938 calling qp api to determine whether to pass all lines
12609 QP_UTIL_PUB.Get_Order_Lines_Status('BATCH',l_order_status_rec);
12610
12611 oe_debug_pub.add(' All_lines_flag returned from pricing:'||l_order_status_rec.all_lines_flag);
12612 -- bug 6817566
12613 oe_debug_pub.add(' manual_adv_modifier '||OE_GLOBALS.G_MANUAL_ADV_MODIFIER);
12614
12615 IF (OE_GLOBALS.G_MANUAL_ADV_MODIFIER IS NULL AND (p_level = 'ORDER' or l_order_status_rec.ALL_LINES_FLAG = 'Y')) THEN
12616 oe_debug_pub.add(' manual_adv_modifier 1 '||OE_GLOBALS.G_MANUAL_ADV_MODIFIER);
12617 oe_debug_pub.add(' p_level '||p_level);
12618 oe_debug_pub.add(' Check for Manual Advanced modifiers ',3);
12619 --- bug# 7600510 Start
12620 -- GET_MANUAL_ADV_STATUS('BATCH');
12621 QP_UTIL_PUB.Get_Manual_All_Lines_Status ('BATCH', l_manual_all_lines_status ) ;
12622 OE_GLOBALS.G_MANUAL_ADV_MODIFIER := l_manual_all_lines_status;
12623 --- bug# 7600510 End
12624 oe_debug_pub.add(' manual_adv_modifier 2 '||OE_GLOBALS.G_MANUAL_ADV_MODIFIER);
12625 END IF;
12626
12627 IF (((p_level = 'ORDER' or l_order_status_rec.ALL_LINES_FLAG = 'Y')
12628 AND(p_level = 'ORDER' or OE_GLOBALS.G_MANUAL_ADV_MODIFIER = 'Y')) -- 6851818
12629 AND p_header_id Is Not Null) Then
12630
12631 if not (p_level = 'ORDER' and p_freight_flag) then --- bug 7655559
12632 --passing all lines under this header
12633 oe_debug_pub.add(' Query Rows under same header');
12634
12635 oe_Line_util.query_rows(p_header_id => p_Header_id, x_line_tbl => l_Line_Tbl);
12636 oe_debug_pub.add('#of rows returned='|| to_char(l_line_tbl.count));
12637 oe_debug_pub.add('no.rows in l_line_tbl = '|| to_char(l_line_tbl.count));
12638
12639 -- Bug 1713035
12640 -- Loop through all the lines in database
12641 -- Replace with the line in memory if found
12642 -- else append
12643
12644 oe_debug_pub.add('Get line currently in memory');
12645 OE_OE_FORM_LINE.get_line(p_line_id => p_line_id,
12646 x_line_rec => l_line_rec);
12647 For i in 1..l_line_tbl.count Loop
12648 if (l_line_tbl(i).line_id = l_line_rec.line_id) then
12649 oe_debug_pub.add('Line already posted to DB, so replace');
12650 l_posted_to_db := TRUE;
12651 l_line_tbl(i) := l_line_rec;
12652 exit;
12653 end if;
12654 end loop;
12655
12656 if NOT l_posted_to_db then
12657 oe_debug_pub.add('line not in DB, new line');
12658 oe_debug_pub.add('appending line with line_id '
12659 || to_char(p_line_id) ||
12660 ' to l_line_tbl');
12661 /*Bug 3280291*/
12662 IF l_line_rec.line_id is not NULL THEN
12663 l_line_tbl(l_line_tbl.count + 1) := l_line_rec;
12664 END IF;
12665 end if;
12666 end if;--- bug 7655559
12667
12668 Elsif p_line_id is not null Then
12669 --just pass one line
12670 oe_debug_pub.add(' Query Rows under for line line id:'||p_line_id);
12671 --oe_line_util.query_row(p_line_id =>p_line_id,x_line_rec=>l_line_rec);
12672
12673 -- Bug 1713035
12674 -- Use oe_oe_form_line.get_line instead of query_rows
12675 oe_debug_pub.add('calling get_line in oe_oe_form_line');
12676 OE_OE_FORM_LINE.get_line(
12677 p_line_id => p_line_id,
12678 x_line_rec => l_line_rec);
12679
12680 l_line_tbl(1):=l_line_rec;
12681 Else
12682 l_line_tbl(1):= p_line_rec;
12683 End If;
12684
12685 OE_Order_PUB.G_LINE := NULL;
12686 OE_Order_PUB.G_HDR := NULL;
12687
12688 If p_header_id is Not Null and p_cross_order = 'N' Then
12689 oe_Header_util.query_row(p_header_id=>p_header_id,x_header_rec => OE_Order_PUB.g_hdr );
12690 End If;
12691
12692
12693 G_STMT_NO := 'Get_manual_adjustment#1';
12694 line_tbl_index := l_line_tbl.First;
12695 While line_Tbl_Index is not null loop
12696
12697 --Cross order lines, lines may not came from same header need to query header for each line
12698 If p_cross_order = 'Y' and p_header_id Is Null Then
12699 oe_Header_util.query_row(p_header_id=>l_line_tbl(line_tbl_index).header_id,
12700 x_header_rec => OE_Order_PUB.g_hdr );
12701 oe_debug_pub.add(' Currency Code:'||OE_Order_PUB.g_hdr.transactional_curr_code);
12702 x_header_id := l_line_tbl(line_tbl_index).header_id;
12703 End If;
12704
12705 --Populate global structure since attribute mapping only read global structure
12706 OE_Order_PUB.G_LINE := l_Line_Tbl(line_Tbl_Index);
12707 Begin
12708 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
12709 --5598523
12710 IF l_line_tbl(line_tbl_index).line_id=p_line_id THEN
12711 l_check_line_flag := 'N';
12712 ELSE
12713 l_check_line_flag := 'Y';
12714 END IF;
12715 QP_Attr_Mapping_PUB.Build_Contexts(p_request_type_code => 'ONT',
12716 p_pricing_type_code => 'L',
12717 p_line_index => line_Tbl_Index, --l_line_tbl(line_tbl_index).header_id + l_line_tbl(line_tbl_index).line_id,
12718 p_check_line_flag => l_check_line_flag, --5598523
12719 p_pricing_event => l_event,
12720 x_pass_line => l_pass_line);
12721 ELSE
12722 QP_Attr_Mapping_PUB.Build_Contexts(p_request_type_code => 'ONT',
12723 p_pricing_type => 'L',
12724 x_price_contexts_result_tbl => l_pricing_contexts_Tbl,
12725 x_qual_contexts_result_tbl => l_qualifier_Contexts_Tbl);
12726 END IF;
12727 OE_Order_PUB.G_LINE := NULL;
12728 Exception
12729 When Others then
12730 oe_debug_pub.add(' QP ATTR MAPPING ERRORS 1');
12731 Raise QP_ATTR_MAPPING_ERRORS;
12732 End;
12733 G_STMT_NO := 'Get_manual_adjustment#2';
12734
12735 -- Fix for bug 1807636
12736 -- Pass 'N' as the value of the p_honor_price_flag
12737 -- so that manual modifiers can be applied to RMA
12738 -- which is a copy of an order
12739 -- bucket man
12740 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
12741 IF l_pass_line='Y' OR l_check_line_flag = 'N' THEN --5598523
12742 l_line_index := l_line_index + 1;
12743 oe_order_price_pvt.copy_Line_to_request( p_Line_rec
12744 => l_Line_Tbl(line_Tbl_Index)
12745 ,p_pricing_events => l_event
12746 ,px_req_line_tbl => l_req_line_tbl
12747 ,p_Request_Type_Code => 'ONT'
12748 ,p_honor_price_flag => 'N'
12749 ,px_line_index => l_line_index
12750 );
12751 END IF; --5598523
12752 ELSE
12753 copy_Line_to_request( p_Line_rec => l_Line_Tbl(line_Tbl_Index)
12754 ,p_pricing_event => l_event
12755 ,px_req_line_tbl => l_req_line_tbl
12756 ,p_Request_Type_Code => 'ONT'
12757 ,p_honor_price_flag => 'N'
12758 );
12759 END IF;
12760 /* --5598523 No need for this code as change done by this logic is not reflected while inserting data
12761 --into qp tables because direct insert is done using global str and hence changes made here are not used.
12762 --In the case of Order level manual adjustments we will need to set calculate price
12763 --flag for all the lines to 'N'and summary line to 'Y'
12764 If p_level = 'ORDER' or l_profile_value = 'Y' Then
12765 l_req_line_tbl(l_req_line_tbl.count).price_flag := 'N';
12766 null;
12767 End If;
12768
12769 If l_profile_value = 'Y' and l_req_line_tbl(l_req_line_tbl.count).line_id = p_line_id Then
12770 --set the current line to 'Y' in the case of linegroup option. We need to pass all other lines
12771 --to pricing engine with N.
12772 l_req_line_tbl(l_req_line_tbl.count).price_flag := 'Y';
12773 End If;
12774 */
12775 -- bucket man
12776 IF OE_CODE_CONTROL.Get_Code_Release_Level < '110510' THEN
12777 copy_attribs_to_Req( p_line_index => l_req_line_tbl.count
12778 ,p_pricing_contexts_Tbl => l_pricing_contexts_Tbl
12779 ,p_qualifier_contexts_Tbl => l_qualifier_Contexts_Tbl
12780 ,px_Req_line_attr_tbl => l_Req_line_attr_tbl
12781 ,px_Req_qual_tbl => l_Req_qual_tbl );
12782 END IF;
12783
12784 If l_ask_for_profile = 'Y' Then
12785 Begin
12786 l_header_id2:=nvl(p_header_id,l_line_tbl(line_tbl_index).header_id);
12787
12788 Select 'x' into l_dummy from dual
12789 Where exists
12790 (select 'x' from
12791 oe_order_price_attribs oopa
12792 where
12793 nvl(oopa.line_id,l_Line_Tbl(line_Tbl_Index).line_id) = l_Line_Tbl(line_Tbl_Index).line_id
12794 and oopa.header_id = l_header_id2);
12795
12796 -- bucket man
12797 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
12798 IF l_pass_line='Y' THEN --5598523
12799 oe_order_price_pvt.Append_asked_for(p_header_id => l_header_id2,
12800
12801 p_line_id => l_Line_Tbl(line_Tbl_Index).line_id,
12802
12803 p_line_index => l_line_index,
12804
12805 px_line_attr_index => l_line_attr_index
12806 );
12807 END IF; --5598523
12808
12809 ELSE
12810 Append_asked_for(p_header_id => l_header_id2,
12811 p_line_id => l_Line_Tbl(line_Tbl_Index).line_id,
12812 p_line_index => l_req_line_tbl.count ,
12813 px_Req_line_attr_tbl => l_Req_line_attr_tbl,
12814 px_Req_qual_tbl => l_Req_qual_tbl
12815 );
12816 END IF;
12817 Exception when no_data_found then null;
12818 End;
12819 End If;
12820
12821
12822
12823 line_Tbl_Index := l_Line_Tbl.Next(line_Tbl_Index);
12824
12825 End Loop;
12826 G_STMT_NO := 'Get_manual_adjustment#3';
12827
12828 Begin
12829 -- bucket man
12830 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
12831 QP_Attr_Mapping_PUB.Build_Contexts(
12832 p_request_type_code => 'ONT',
12833 p_pricing_type_code => 'H',
12834 p_line_index=> l_line_index + 1 --oe_order_pub.g_hdr.header_id
12835 );
12836 ELSE
12837 QP_Attr_Mapping_PUB.Build_Contexts(
12838 p_request_type_code => 'ONT',
12839 p_pricing_type => 'H',
12840 x_price_contexts_result_tbl => l_pricing_contexts_Tbl,
12841 x_qual_contexts_result_tbl => l_qualifier_Contexts_Tbl
12842 );
12843 END IF;
12844 Exception
12845 --when no_data_found then
12846 --(' QP ATTR MAPPING ERRORS 2');
12847 When Others then
12848 Oe_Debug_Pub.Add(' QP ATTR MAPPING ERRORS 2');
12849 Raise QP_ATTR_MAPPING_ERRORS;
12850
12851 End;
12852
12853 -- bucket man
12854 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
12855 oe_order_price_pvt.copy_Header_to_request(
12856 p_header_rec => OE_Order_PUB.g_hdr
12857 ,px_req_line_tbl => l_req_line_tbl
12858 ,p_Request_Type_Code => 'ONT'
12859 ,p_calculate_price_flag =>'Y'
12860 ,px_line_index => l_line_index
12861 );
12862 ELSE
12863 copy_Header_to_request(
12864 p_header_rec => OE_Order_PUB.g_hdr
12865 ,px_req_line_tbl => l_req_line_tbl
12866 ,p_Request_Type_Code => 'ONT'
12867 ,p_calculate_price_flag =>'Y'
12868 );
12869 END IF;
12870
12871 G_STMT_NO := 'Get_manual_adjustment#90';
12872 IF OE_CODE_CONTROL.Get_Code_Release_Level < '110510' THEN
12873 copy_attribs_to_Req(
12874 p_line_index => l_req_line_tbl.count
12875 ,p_pricing_contexts_Tbl => l_pricing_contexts_Tbl
12876 ,p_qualifier_contexts_Tbl => l_qualifier_Contexts_Tbl
12877 ,px_Req_line_attr_tbl => l_Req_line_attr_tbl
12878 ,px_Req_qual_tbl => l_Req_qual_tbl
12879 );
12880 END IF;
12881
12882 If l_ask_for_profile = 'Y' Then
12883 Begin
12884 --Modified for bug 3502454
12885 --l_header_id2:=nvl(p_header_id,l_line_tbl(l_line_tbl.first).header_id);
12886 IF ( p_header_id IS NULL ) THEN
12887 l_header_id2 := l_line_tbl(l_line_tbl.first).header_id;
12888 ELSE
12889 l_header_id2 := p_header_id;
12890 END IF;
12891 -- End of 3502454
12892 Select 'x' into l_dummy from dual
12893 where exists(
12894 Select 'X' from oe_order_price_attribs oopa
12895 where oopa.header_id = l_header_id2 and oopa.line_id is null);
12896
12897 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
12898 oe_order_price_pvt.Append_asked_for(
12899 p_header_id => l_header_id2
12900 , p_line_id => NULL
12901 ,p_line_index => l_line_index
12902 , px_line_attr_index => l_line_attr_index
12903 );
12904 ELSE
12905 Append_asked_for(
12906 p_header_id => l_header_id2
12907 ,p_line_index => l_req_line_tbl.count
12908 ,px_Req_line_attr_tbl => l_Req_line_attr_tbl
12909 ,px_Req_qual_tbl => l_Req_qual_tbl
12910 );
12911 END IF;
12912 Exception when no_data_found then null;
12913 End;
12914 End If;
12915
12916 If l_req_line_tbl(l_req_line_tbl.count).line_type_code = 'ORDER' and
12917 p_level = 'ORDER' Then
12918 l_req_line_tbl(l_req_line_tbl.count).price_flag := 'Y';
12919 End If;
12920
12921 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
12922 IF l_line_index > 0 THEN
12923 If l_debug_level > 0 Then
12924 oe_debug_pub.add('before Populate_Temp_Table');
12925 End If;
12926 oe_order_price_pvt.Populate_Temp_Table;
12927 END IF;
12928 l_control_rec.request_type_code := 'ONT';
12929 l_control_rec.temp_table_insert_flag := 'N';
12930 END IF;
12931 l_control_rec.pricing_event := l_event;
12932 l_control_rec.calculate_flag:= qp_preq_grp.G_SEARCH_N_CALCULATE;
12933 l_control_rec.manual_adjustments_call_flag:=qp_preq_grp.G_YES;
12934 --Will need to do the same thing for header level manual adjustment
12935 -- sgowtham
12936 if( p_freight_flag = TRUE) then
12937 l_control_rec.GET_FREIGHT_FLAG := 'Y';
12938 else
12939 l_control_rec.GET_FREIGHT_FLAG := 'N';
12940 end if;
12941
12942 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
12943 QP_PREQ_PUB.PRICE_REQUEST
12944 (p_control_rec => l_control_rec
12945 ,x_return_status =>l_return_status
12946 ,x_return_status_Text =>l_return_status_Text
12947 );
12948 ELSE
12949 QP_PREQ_GRP.PRICE_REQUEST
12950 (p_control_rec => l_control_rec
12951 ,p_line_tbl => l_Req_line_tbl
12952 ,p_qual_tbl => l_Req_qual_tbl
12953 ,p_line_attr_tbl => l_Req_line_attr_tbl
12954 ,p_line_detail_tbl =>l_req_line_detail_tbl
12955 ,p_line_detail_qual_tbl =>l_req_line_detail_qual_tbl
12956 ,p_line_detail_attr_tbl =>l_req_line_detail_attr_tbl
12957 ,p_related_lines_tbl =>l_req_related_lines_tbl
12958 ,x_line_tbl =>lx_req_line_tbl
12959 ,x_line_qual =>lx_Req_qual_tbl
12960 ,x_line_attr_tbl =>lx_Req_line_attr_tbl
12961 ,x_line_detail_tbl =>lx_req_line_detail_tbl
12962 ,x_line_detail_qual_tbl =>lx_req_line_detail_qual_tbl
12963 ,x_line_detail_attr_tbl =>lx_req_line_detail_attr_tbl
12964 ,x_related_lines_tbl =>lx_req_related_lines_tbl
12965 ,x_return_status =>l_return_status
12966 ,x_return_status_Text =>l_return_status_Text
12967 );
12968 END IF;
12969
12970 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
12971 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
12972 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
12973 RAISE FND_API.G_EXC_ERROR;
12974 END IF;
12975 g_stmt_no :='Get Manual Adj#5';
12976 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
12977 i := 1;
12978 g_stmt_no :='Get Manual Adj#5.5';
12979 for k In man_adj Loop
12980 If k.automatic_flag = 'N' Then
12981 If l_debug_level > 0 Then
12982 Oe_Debug_Pub.Add('+Line_type_code:'||k.line_type_code);
12983 Oe_Debug_Pub.Add('+List_line_no:'||k.list_line_no);
12984 End If;
12985
12986 --Only return 1 set of lov per line id or per header id
12987 If (p_level In ('ORDER') and
12988 (k.line_type_code = 'ORDER' or
12989 k.modifier_level_code = 'LINEGROUP'))
12990 Or
12991 (p_level in ('LINE','LINEGROUP') and
12992 k.line_type_code = 'LINE' and
12993 k.line_id=p_line_id)
12994 Or
12995 (p_level = 'ALL' and
12996 ((k.line_type_code = 'LINE' and
12997 k.line_id=p_line_id)
12998 or
12999 k.line_type_code = 'ORDER')
13000 )
13001
13002 Then
13003 If (p_pbh_mode = 'CHILD' and nvl(k.line_quantity,0) > 0
13004 and k.line_detail_type_code = QP_PREQ_GRP.G_CHILD_DETAIL_TYPE)
13005 --Regular discount lines
13006 or (k.list_line_type_code <> 'PBH' AND
13007 k.line_detail_type_code <> QP_PREQ_GRP.G_CHILD_DETAIL_TYPE)
13008 --Price break header (parent)
13009 or (p_pbh_mode = 'PARENT' and k.list_line_type_code = 'PBH')
13010 Then
13011 If p_called_from = 'SO' Then
13012 If k.pricing_group_sequence is null then
13013 x_manual_adj_tbl(i).modifier_number:=k.list_line_no;
13014 x_manual_adj_tbl(i).list_line_type_code :=k.list_line_type_code;
13015 x_manual_adj_tbl(i).operand := k.operand_value;
13016 x_manual_adj_tbl(i).list_line_id :=k.list_line_id;
13017 x_manual_adj_tbl(i).list_header_id :=k.list_header_id;
13018 x_manual_adj_tbl(i).pricing_phase_id :=k.pricing_phase_id;
13019 x_manual_adj_tbl(i).automatic_flag :=k.automatic_flag;
13020 x_manual_adj_tbl(i).modifier_level_code:=k.modifier_level_code;
13021 x_manual_adj_tbl(i).override_flag :=k.override_flag;
13022 x_manual_adj_tbl(i).operator :=k.operand_calculation_code;
13023 x_manual_adj_tbl(i).adjusted_amount :=k.ADJUSTMENT_AMOUNT;
13024 x_manual_adj_tbl(i).charge_type_code :=k.CHARGE_TYPE_CODE;
13025 x_manual_adj_tbl(i).CHARGE_SUBTYPE_CODE :=k.CHARGE_SUBTYPE_CODE;
13026 x_manual_adj_tbl(i).PRICE_BREAK_TYPE_CODE := k.PRICE_BREAK_TYPE_CODE;
13027 i := i + 1;
13028 End If;
13029 Else
13030 x_manual_adj_tbl(i).modifier_number:=k.list_line_no;
13031 x_manual_adj_tbl(i).list_line_type_code :=k.list_line_type_code;
13032 x_manual_adj_tbl(i).operand := k.operand_value;
13033 x_manual_adj_tbl(i).list_line_id :=k.list_line_id;
13034 x_manual_adj_tbl(i).list_header_id :=k.list_header_id; x_manual_adj_tbl(i).pricing_phase_id :=k.pricing_phase_id;
13035 x_manual_adj_tbl(i).automatic_flag :=k.automatic_flag; x_manual_adj_tbl(i).modifier_level_code:=k.modifier_level_code;
13036 x_manual_adj_tbl(i).override_flag :=k.override_flag;
13037 x_manual_adj_tbl(i).operator :=k.operand_calculation_code;
13038 x_manual_adj_tbl(i).adjusted_amount :=k.ADJUSTMENT_AMOUNT;
13039 x_manual_adj_tbl(i).charge_type_code :=k.CHARGE_TYPE_CODE;
13040 x_manual_adj_tbl(i).CHARGE_SUBTYPE_CODE :=k.CHARGE_SUBTYPE_CODE;
13041 x_manual_adj_tbl(i).PRICE_BREAK_TYPE_CODE := k.PRICE_BREAK_TYPE_CODE;
13042 x_manual_adj_tbl(i).PRICING_GROUP_SEQUENCE := k.PRICING_GROUP_SEQUENCE;
13043 i := i + 1;
13044 End If;
13045 End If;
13046
13047 End If;
13048 End If;
13049
13050
13051 End Loop;
13052 ELSE
13053 i:=lx_req_line_detail_tbl.first;
13054 g_stmt_no :='Get Manual Adj#5.5';
13055 While i Is not Null Loop
13056 If lx_req_line_detail_tbl(i).automatic_flag = 'N' Then
13057 Oe_Debug_Pub.Add('+Line_type_code:'||l_req_line_tbl(lx_req_line_detail_tbl(i).line_index).line_type_code);
13058 Oe_Debug_Pub.Add('+List_line_no:'||lx_req_line_detail_tbl(i).list_line_no);
13059
13060 --Only return 1 set of lov per line id or per header id
13061 If (p_level In ('ORDER') and
13062 (l_req_line_tbl(lx_req_line_detail_tbl(i).line_index).line_type_code = 'ORDER' or
13063 lx_req_line_detail_tbl(i).modifier_level_code = 'LINEGROUP'))
13064 Or
13065 (p_level in ('LINE','LINEGROUP') and
13066 l_req_line_tbl(lx_req_line_detail_tbl(i).line_index).line_type_code = 'LINE' and
13067 l_req_line_tbl(lx_req_line_detail_tbl(i).line_index).line_id=p_line_id)
13068 Or
13069 (p_level = 'ALL' and
13070 ((l_req_line_tbl(lx_req_line_detail_tbl(i).line_index).line_type_code = 'LINE' and
13071 l_req_line_tbl(lx_req_line_detail_tbl(i).line_index).line_id=p_line_id)
13072 or
13073 l_req_line_tbl(lx_req_line_detail_tbl(i).line_index).line_type_code = 'ORDER')
13074 )
13075
13076 Then
13077 If (p_pbh_mode = 'CHILD' and nvl(lx_req_line_detail_tbl(i).line_quantity,0) > 0
13078 and lx_req_line_detail_tbl(i).line_detail_type_code = QP_PREQ_GRP.G_CHILD_DETAIL_TYPE)
13079 --Regular discount lines
13080 or (lx_req_line_detail_tbl(i).list_line_type_code <> 'PBH' AND
13081 lx_req_line_detail_tbl(i).line_detail_type_code <> QP_PREQ_GRP.G_CHILD_DETAIL_TYPE)
13082 --Price break header (parent)
13083 or (p_pbh_mode = 'PARENT' and lx_req_line_detail_tbl(i).list_line_type_code = 'PBH')
13084 Then
13085 x_manual_adj_tbl(i).modifier_number:=lx_req_line_detail_tbl(i).list_line_no;
13086 x_manual_adj_tbl(i).list_line_type_code :=lx_req_line_detail_tbl(i).list_line_type_code;
13087 x_manual_adj_tbl(i).operand :=lx_req_line_detail_tbl(i).operand_value;
13088 x_manual_adj_tbl(i).list_line_id :=lx_req_line_detail_tbl(i).list_line_id;
13089 x_manual_adj_tbl(i).list_header_id :=lx_req_line_detail_tbl(i).list_header_id;
13090 x_manual_adj_tbl(i).pricing_phase_id :=lx_req_line_detail_tbl(i).pricing_phase_id;
13091 x_manual_adj_tbl(i).automatic_flag :=lx_req_line_detail_tbl(i).automatic_flag;
13092 x_manual_adj_tbl(i).modifier_level_code:=lx_req_line_detail_tbl(i).modifier_level_code;
13093 x_manual_adj_tbl(i).override_flag :=lx_req_line_detail_tbl(i).override_flag;
13094 x_manual_adj_tbl(i).operator :=lx_req_line_detail_tbl(i).operand_calculation_code;
13095 x_manual_adj_tbl(i).adjusted_amount :=round(lx_req_line_detail_tbl(i).ADJUSTMENT_AMOUNT,6);
13096 oe_debug_pub.add('get manual adj:after round:'||x_manual_adj_tbl(i).adjusted_amount);
13097 x_manual_adj_tbl(i).charge_type_code :=lx_req_line_detail_tbl(i).CHARGE_TYPE_CODE;
13098 x_manual_adj_tbl(i).CHARGE_SUBTYPE_CODE :=lx_req_line_detail_tbl(i).CHARGE_SUBTYPE_CODE;
13099 End If;
13100
13101 End If;
13102 End If;
13103
13104
13105 i:=lx_req_line_detail_tbl.next(i);
13106 End Loop;
13107
13108 END IF;
13109 -- Bug 1713035
13110 -- if p_line_level='Y', then we want
13111 -- only line/linegroup level manual adjustments
13112 -- Loop through x_manual_adj_tbl and delete all ORDER
13113 -- level adjustments in case p_line_level='Y'
13114
13115
13116 if (p_line_level = 'Y') then
13117 j:=x_manual_adj_tbl.first;
13118 while j is NOT NULL Loop
13119 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
13120 if (x_manual_adj_tbl(j).modifier_level_code = 'ORDER' or
13121 (x_manual_adj_tbl(j).price_break_type_code = 'RANGE' --bucket man
13122 and p_pbh_mode <> 'PARENT'
13123 )
13124 ) then
13125 oe_debug_pub.add(' Manual adj call: deleting order level adjustment');
13126 oe_debug_pub.add(' Manual adj call: remove RANGE break');
13127 x_manual_adj_tbl.delete(j);
13128 end if;
13129 ELSE
13130 if (x_manual_adj_tbl(j).modifier_level_code = 'ORDER' or
13131 (lx_req_line_detail_tbl(j).price_break_type_code = 'RANGE'
13132 and p_pbh_mode <> 'PARENT'
13133 )
13134 ) then
13135
13136 --we do not support range break from 'LINE' tab of sales order form.
13137 --because due to the fact that in 'LINE' tab we only shows
13138 --eligible child break. And, 'RANGE' break goes across multiple
13139 --children. We support manual range break from view adjustments form
13140 --because in view adjustments, it is the parent PBH a user get to choose
13141 --and the system will insert all range break children.
13142
13143 oe_debug_pub.add(' Manual adj call: deleting order level adjustment');
13144 oe_debug_pub.add(' Manual adj call: remove RANGE break');
13145 x_manual_adj_tbl.delete(j);
13146 end if;
13147 END IF;
13148 j := x_manual_adj_tbl.next(j);
13149 End loop;
13150 end if;
13151
13152 Oe_Debug_Pub.add('Exiting Get manual adj');
13153
13154 EXCEPTION
13155
13156 WHEN FND_API.G_EXC_ERROR THEN
13157
13158 FND_MESSAGE.SET_NAME('ONT','OE_PRICING_ERROR');
13159 FND_MESSAGE.SET_TOKEN('ERR_TEXT',l_return_status_Text);
13160 OE_MSG_PUB.Add;
13161 x_return_status := FND_API.G_RET_STS_ERROR;
13162
13163 Oe_Debug_Pub.add('g_exc_error is '||g_stmt_no||' '||sqlerrm,1);
13164 Oe_Debug_Pub.add('g_exc_error is '||l_return_status_Text);
13165 --DBMS_OUTPUT.PUT_LINE('g_exc_error is '||l_return_status_Text);
13166 RAISE FND_API.G_EXC_ERROR;
13167
13168 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
13169
13170 FND_MESSAGE.SET_NAME('ONT','OE_PRICING_ERROR');
13171 FND_MESSAGE.SET_TOKEN('ERR_TEXT',l_return_status_Text);
13172 OE_MSG_PUB.Add;
13173 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
13174 Oe_Debug_Pub.add('G_EXC_UNEXPECTED_ERROR is '||g_stmt_no||' '||sqlerrm,1);
13175 Oe_Debug_Pub.add('G_EXC_UNEXPECTED_ERROR is '||l_return_status_Text);
13176 --DBMS_OUTPUT.PUT_LINE('G_EXC_UNEXPECTED_ERROR is '||l_return_status_Text);
13177 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
13178 WHEN QP_ATTR_MAPPING_ERRORS Then
13179 FND_MESSAGE.SET_NAME('ONT','OE_PRICING_ERROR');
13180 FND_MESSAGE.SET_TOKEN('ERR_TEXT','Errors return from QP_Attr_Mapping_PUB.Build_Context');
13181 OE_MSG_PUB.Add;
13182 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
13183 Oe_Debug_Pub.add('G_EXC_UNEXPECTED_ERROR is: QP_Attr_Mapping_PUB.Build_Context'||sqlerrm,1);
13184 Oe_Debug_Pub.add('G_EXC_UNEXPECTED_ERROR is '||l_return_status_Text);
13185 Oe_Debug_Pub.add('QP_ATTR_MAPPING_ERRORS');
13186 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
13187 WHEN OTHERS THEN
13188
13189 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
13190 Oe_Debug_Pub.add('Error is '||sqlerrm);
13191 Oe_Debug_Pub.add('Error Code is '||g_stmt_no||' '||sqlerrm,1);
13192
13193 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
13194 THEN
13195 OE_MSG_PUB.Add_Exc_Msg
13196 ( G_PKG_NAME
13197 , 'oe_line_adj.calulate_adjustments',
13198 g_stmt_no||' '||sqlerrm
13199 );
13200 END IF;
13201
13202 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
13203
13204 End Get_Manual_Adjustments;
13205
13206 -- PROMOTIONS SEP/01
13207 Procedure Promotion_Put_Hold(
13208 p_header_id Number
13209 ,p_line_id Number
13210 )
13211 is
13212 l_hold_source_rec OE_Holds_Pvt.hold_source_rec_type;
13213 l_hold_release_rec OE_Holds_Pvt.Hold_Release_REC_Type;
13214 l_return_status varchar2(30);
13215 l_x_msg_count number;
13216 l_x_msg_data Varchar2(2000);
13217 l_x_result_out Varchar2(30);
13218 l_list_name varchar2(240);
13219 l_operand number;
13220 l_msg_text Varchar2(200);
13221
13222 Begin
13223
13224 adj_debug('PROMOTIONS - start of procedure Promotion_Put_Hold ');
13225
13226 -- use the seeded hold_id
13227 IF (p_line_id IS NULL) THEN
13228 adj_debug('putting header '||p_header_id||' on hold',3);
13229
13230 l_hold_source_rec.hold_id := G_SEEDED_PROM_ORDER_HOLD_ID;
13231 ELSE
13232 adj_debug('putting line '||p_line_id||' on hold',3);
13233 l_hold_source_rec.hold_id := G_SEEDED_PROM_LINE_HOLD_ID;
13234 END IF;
13235
13236 --adj_debug('PAL PROMOTIONS - after select in procedure Promotion_Put_Hold ');
13237 --adj_debug('PAL PROMOTIONS - hold id is '|| l_hold_source_rec.hold_id,2);
13238 --adj_debug('PAL PROMOTIONS - header_id is '|| p_header_id,2);
13239 --adj_debug('PAL PROMOTIONS - line_id is '|| p_line_id,2);
13240
13241
13242 l_hold_source_rec.hold_entity_id := p_header_id;
13243 l_hold_source_rec.header_id := p_header_id;
13244 l_hold_source_rec.line_id := p_line_id;
13245 l_hold_source_rec.Hold_Entity_code := 'O';
13246
13247 -- check if line already on PROMOTION hold, place hold if not
13248
13249 OE_Holds_Pub.Check_Holds(
13250 p_api_version => 1.0
13251 ,p_header_id => p_header_id
13252 ,p_line_id => p_line_id
13253 ,p_hold_id => l_hold_source_rec.Hold_id
13254 ,x_return_status => l_return_status
13255 ,x_msg_count => l_x_msg_count
13256 ,x_msg_data => l_x_msg_data
13257 ,x_result_out => l_x_result_out
13258 );
13259
13260 --adj_debug('PAL PROMOTIONS - hold_entity_code is '|| l_hold_source_rec.Hold_Entity_code||l_x_result_out,2);
13261
13262 IF (l_return_status <> FND_API.g_ret_sts_success) THEN
13263 RAISE FND_API.G_EXC_ERROR;
13264 END IF;
13265 If l_x_result_out = FND_API.G_FALSE then
13266 adj_debug('PAL PROMOTIONS - apply holds in procedure Promotion_Put_Hold ');
13267 adj_debug('hold line with header_id:'||p_header_id||' line_id: '||p_line_id,1);
13268 OE_HOLDS_PUB.Apply_Holds(
13269 p_api_version => 1.0
13270 ,p_hold_source_rec => l_hold_source_rec
13271 ,x_return_status => l_return_status
13272 ,x_msg_count => l_x_msg_count
13273 ,x_msg_data => l_x_msg_data
13274 );
13275
13276 If l_return_status = FND_API.g_ret_sts_success then
13277 IF (p_line_id IS NULL) THEN
13278 FND_MESSAGE.SET_NAME('ONT','ONT_PROMO_HOLD_APPLIED');
13279 ELSE
13280 FND_MESSAGE.SET_NAME('ONT', 'ONT_LINE_PROMO_HOLD_APPLIED');
13281 END IF;
13282 OE_MSG_PUB.Add;
13283 Else
13284 adj_debug('error applying hold',3);
13285 RAISE FND_API.G_EXC_ERROR;
13286 End If;
13287 End If; /* check hold */
13288
13289 -- adj_debug('PROMOTIONS - end of procedure Promotion_Put_Hold ');
13290 end Promotion_Put_Hold; -- PROMOTIONS SEP/01
13291
13292 PROCEDURE GET_MANUAL_ADV_STATUS(p_event_code IN VARCHAR2) AS
13293
13294 CURSOR l_send_all_lines_cur(p_event_code1 VARCHAR2) IS
13295 SELECT 'X'
13296 FROM
13297 qp_list_headers_b qh,
13298 qp_list_lines ql,
13299 qp_pricing_attributes qppr
13300 WHERE ql.list_line_id = qppr.list_line_id
13301 AND ql.automatic_flag = 'N'
13302 AND qh.list_header_id = ql.list_header_id
13303 AND qh.active_flag = 'Y'
13304 AND qh.list_type_code not in ('AGR','PRL')
13305 AND ql.list_line_type_code <> 'PLL'
13306 AND (ql.list_line_type_code IN ('PRG','OID') OR ql.modifier_level_code =
13307 'LINEGROUP')
13308 AND qppr.product_attribute_context='ITEM' -- bug#7488440
13309 AND qppr.product_attribute='PRICING_ATTRIBUTE3' -- bug#7488440
13310 AND qppr.product_attr_value='ALL' -- bug#7488440
13311 AND qppr.pricing_phase_id
13312 IN ( SELECT distinct a.pricing_phase_id
13313 FROM qp_pricing_phases a , qp_event_phases b
13314 WHERE
13315 a.pricing_phase_id = b.pricing_phase_id
13316 -- AND (a.oid_exists = 'Y' OR a.line_group_exists = 'Y' OR a.rltd_exists = 'Y') -- bug#7488440
13317 AND b.pricing_event_code in (SELECT decode(rownum
13318 ,1 ,substr(p_event_code,1,instr(p_event_code1,',',1,1)-1)
13319 ,2 ,substr(p_event_code , instr(p_event_code1,',',1,rownum-1) + 1,
13320 instr(p_event_code1,',',1,rownum)-1 -
13321 instr(p_event_code1,',',1,rownum-1))
13322 ,3 ,substr(p_event_code , instr(p_event_code1,',',1,rownum-1) + 1,
13323 instr(p_event_code1,',',1,rownum)-1 -
13324 instr(p_event_code1,',',1,rownum-1))
13325 ,4 ,substr(p_event_code , instr(p_event_code1,',',1,rownum-1) + 1,
13326 instr(p_event_code1,',',1,rownum)-1 -
13327 instr(p_event_code1,',',1,rownum-1))
13328 ,5 ,substr(p_event_code , instr(p_event_code1,',',1,rownum-1) + 1,
13329 instr(p_event_code1,',',1,rownum)-1 -
13330 instr(p_event_code1,',',1,rownum-1))
13331 ,6 ,substr(p_event_code , instr(p_event_code1,',',1,rownum-1) + 1,
13332 instr(p_event_code1,',',1,rownum)-1 -
13333 instr(p_event_code1,',',1,rownum-1)))
13334 FROM qp_event_phases
13335 WHERE rownum < 7))
13336 AND ROWNUM = 1;
13337
13338 x_get_manual_adv VARCHAR2(1);
13339
13340 BEGIN
13341 oe_debug_pub.add(' Inside GET_MANUAL_ADV_STATUS ',3);
13342 x_get_manual_adv := NULL;
13343
13344 OPEN l_send_all_lines_cur(p_event_code || ',') ;
13345 FETCH l_send_all_lines_cur INTO x_get_manual_adv;
13346 CLOSE l_send_all_lines_cur;
13347
13348 If x_get_manual_adv = 'X' THEN
13349 oe_debug_pub.add('Manual adv modifiers exist');
13350 OE_GLOBALS.G_MANUAL_ADV_MODIFIER := 'Y';
13351 ELSE
13352 oe_debug_pub.add('Manual adv modifiers do not exist');
13353 OE_GLOBALS.G_MANUAL_ADV_MODIFIER := 'N';
13354 END IF;
13355
13356
13357 oe_debug_pub.add('return_value '||OE_GLOBALS.G_MANUAL_ADV_MODIFIER,3);
13358 oe_debug_pub.add(' Leaving GET_MANUAL_ADV_STATUS ',3);
13359 END GET_MANUAL_ADV_STATUS;
13360
13361 end Oe_Order_Adj_Pvt;