[Home] [Help]
PACKAGE BODY: APPS.OE_ORDER_PRICE_PVT
Source
1 PACKAGE BODY OE_ORDER_PRICE_PVT AS
2 /* $Header: OEXVOPRB.pls 120.48.12020000.9 2013/03/13 21:21:06 cpati ship $ */
3
4 G_DEBUG BOOLEAN;
5 --2649821 Changed G_ROUNDING_FLAG to Q
6 G_ROUNDING_FLAG VARCHAR2(1):= 'Q'; --nvl(Fnd_Profile.value('OE_UNIT_PRICE_ROUNDING'),'N');
7 G_SEEDED_GSA_HOLD_ID CONSTANT NUMBER:= 2;
8 G_CHARGES_FOR_INCLUDED_ITEM Varchar2(30)
9 := nvl(fnd_profile.value('ONT_CHARGES_FOR_INCLUDED_ITEM'),'N');
10 G_PASS_ALL_LINES VARCHAR2(30);
11 --bug4080363 commented the following
12 -- bug 3491752
13 --G_LIST_PRICE_OVERRIDE Varchar2(30)
14 -- := nvl(fnd_profile.value('ONT_LIST_PRICE_OVERRIDE_PRIV'), 'NONE');
15
16 g_request_id number := null;
17 G_IPL_ERRORS_TBL OE_GLOBALS.Number_Tbl_Type;
18 -- G_BINARY_LIMIT CONSTANT NUMBER:=2147483647; -- Bug 8631297
19 G_BINARY_LIMIT CONSTANT NUMBER := OE_GLOBALS.G_BINARY_LIMIT; -- Added for bug 8631297
20
21 --rc
22 G_CHARGE_PERIODICITY_CODE_TBL QP_PREQ_GRP.VARCHAR_3_TYPE;
23
24 --
25 G_ADDED_PARENT_TBL OE_GLOBALS.Number_Tbl_Type;
26
27 -- AG Changes
28 TYPE PLS_INTEGER_TYPE IS TABLE OF PLS_INTEGER INDEX BY BINARY_INTEGER;
29 TYPE NUMBER_TYPE IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
30 TYPE VARCHAR_TYPE IS TABLE OF VARCHAR2(240) INDEX BY BINARY_INTEGER;
31 TYPE FLAG_TYPE IS TABLE OF VARCHAR2(1) INDEX BY BINARY_INTEGER;
32 TYPE ROWID_TYPE IS TABLE OF ROWID INDEX BY BINARY_INTEGER;
33 TYPE DATE_TYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER;
34 Type rounding_factor_rec is Record
35 (List_Header_id number
36 ,rounding_factor number
37 );
38 g_rounding_factor_rec rounding_factor_rec;
39 Type Index_Tbl_Type is table of number
40 Index by Binary_Integer;
41
42 Type key_rec_type is record
43 (db_start NUMBER DEFAULT NULL,
44 db_end NUMBER DEFAULT NULL
45 );
46 Type key_tbl_type is table of key_rec_type index by binary_integer;
47 --3021992
48 TYPE g_lineid_tbl_type IS TABLE OF number INDEX BY BINARY_INTEGER ;
49 g_lineid_tbl g_lineid_tbl_type ;
50 --3021992 ends
51
52 -- AG change
53 G_LINE_INDEX_tbl QP_PREQ_GRP.pls_integer_type;
54 G_LINE_TYPE_CODE_TBL QP_PREQ_GRP.VARCHAR_TYPE;
55 G_PRICING_EFFECTIVE_DATE_TBL QP_PREQ_GRP.DATE_TYPE ;
56 G_ACTIVE_DATE_FIRST_TBL QP_PREQ_GRP.DATE_TYPE ;
57 G_ACTIVE_DATE_FIRST_TYPE_TBL QP_PREQ_GRP.VARCHAR_TYPE;
58 G_ACTIVE_DATE_SECOND_TBL QP_PREQ_GRP.DATE_TYPE ;
59 G_ACTIVE_DATE_SECOND_TYPE_TBL QP_PREQ_GRP.VARCHAR_TYPE ;
60 G_LINE_QUANTITY_TBL QP_PREQ_GRP.NUMBER_TYPE ;
61 G_LINE_UOM_CODE_TBL QP_PREQ_GRP.VARCHAR_TYPE;
62 G_REQUEST_TYPE_CODE_TBL QP_PREQ_GRP.VARCHAR_TYPE;
63 G_PRICED_QUANTITY_TBL QP_PREQ_GRP.NUMBER_TYPE;
64 G_UOM_QUANTITY_TBL QP_PREQ_GRP.NUMBER_TYPE;
65 G_CONTRACT_START_DATE_TBL QP_PREQ_GRP.DATE_TYPE;
66 G_CONTRACT_END_DATE_TBL QP_PREQ_GRP.DATE_TYPE;
67 G_PRICED_UOM_CODE_TBL QP_PREQ_GRP.VARCHAR_TYPE;
68 G_CURRENCY_CODE_TBL QP_PREQ_GRP.VARCHAR_TYPE;
69 G_UNIT_PRICE_TBL QP_PREQ_GRP.NUMBER_TYPE;
70 G_PERCENT_PRICE_TBL QP_PREQ_GRP.NUMBER_TYPE;
71 G_ADJUSTED_UNIT_PRICE_TBL QP_PREQ_GRP.NUMBER_TYPE;
72 G_UPD_ADJUSTED_UNIT_PRICE_TBL QP_PREQ_GRP.NUMBER_TYPE;
73 G_PROCESSED_FLAG_TBL QP_PREQ_GRP.VARCHAR_TYPE;
74 G_PRICE_FLAG_TBL QP_PREQ_GRP.VARCHAR_TYPE;
75 G_LINE_ID_TBL QP_PREQ_GRP.NUMBER_TYPE;
76 G_PROCESSING_ORDER_TBL QP_PREQ_GRP.PLS_INTEGER_TYPE;
77 G_ROUNDING_FACTOR_TBL QP_PREQ_GRP.PLS_INTEGER_TYPE;
78 G_ROUNDING_FLAG_TBL QP_PREQ_GRP.FLAG_TYPE;
79 G_QUALIFIERS_EXIST_FLAG_TBL QP_PREQ_GRP.VARCHAR_TYPE;
80 G_PRICING_ATTRS_EXIST_FLAG_TBL QP_PREQ_GRP.VARCHAR_TYPE;
81 G_PRICE_LIST_ID_TBL QP_PREQ_GRP.NUMBER_TYPE;
82 G_PL_VALIDATED_FLAG_TBL QP_PREQ_GRP.VARCHAR_TYPE;
83 G_PRICE_REQUEST_CODE_TBL QP_PREQ_GRP.VARCHAR_TYPE;
84 G_USAGE_PRICING_TYPE_TBL QP_PREQ_GRP.VARCHAR_TYPE;
85 G_LINE_CATEGORY_TBL QP_PREQ_GRP.VARCHAR_TYPE;
86 G_PRICING_STATUS_CODE_tbl QP_PREQ_GRP.VARCHAR_TYPE;
87 G_PRICING_STATUS_TEXT_tbl QP_PREQ_GRP.VARCHAR_TYPE;
88 G_ATTR_LINE_INDEX_tbl QP_PREQ_GRP.PLS_INTEGER_TYPE;
89 G_ATTR_LINE_DETAIL_INDEX_tbl QP_PREQ_GRP.PLS_INTEGER_TYPE;
90 G_ATTR_VALIDATED_FLAG_tbl QP_PREQ_GRP.VARCHAR_TYPE;
91 G_ATTR_PRICING_CONTEXT_tbl QP_PREQ_GRP.VARCHAR_TYPE;
92 G_ATTR_PRICING_ATTRIBUTE_tbl QP_PREQ_GRP.VARCHAR_TYPE;
93 G_ATTR_ATTRIBUTE_LEVEL_tbl QP_PREQ_GRP.VARCHAR_TYPE;
94 G_ATTR_ATTRIBUTE_TYPE_tbl QP_PREQ_GRP.VARCHAR_TYPE;
95 G_ATTR_APPLIED_FLAG_tbl QP_PREQ_GRP.VARCHAR_TYPE;
96 G_ATTR_PRICING_STATUS_CODE_tbl QP_PREQ_GRP.VARCHAR_TYPE;
97 G_ATTR_PRICING_ATTR_FLAG_tbl QP_PREQ_GRP.VARCHAR_TYPE;
98 G_ATTR_LIST_HEADER_ID_tbl QP_PREQ_GRP.NUMBER_TYPE;
99 G_ATTR_LIST_LINE_ID_tbl QP_PREQ_GRP.NUMBER_TYPE;
100 G_ATTR_VALUE_FROM_tbl QP_PREQ_GRP.VARCHAR_TYPE;
101 G_ATTR_SETUP_VALUE_FROM_tbl QP_PREQ_GRP.VARCHAR_TYPE;
102 G_ATTR_VALUE_TO_tbl QP_PREQ_GRP.VARCHAR_TYPE;
103 G_ATTR_SETUP_VALUE_TO_tbl QP_PREQ_GRP.VARCHAR_TYPE;
104 G_ATTR_GROUPING_NUMBER_tbl QP_PREQ_GRP.PLS_INTEGER_TYPE;
105 G_ATTR_NO_QUAL_IN_GRP_tbl QP_PREQ_GRP.PLS_INTEGER_TYPE;
106 G_ATTR_COMP_OPERATOR_TYPE_tbl QP_PREQ_GRP.VARCHAR_TYPE;
107 G_ATTR_PRICING_STATUS_TEXT_tbl QP_PREQ_GRP.VARCHAR_TYPE;
108 G_ATTR_QUAL_PRECEDENCE_tbl QP_PREQ_GRP.PLS_INTEGER_TYPE;
109 G_ATTR_DATATYPE_tbl QP_PREQ_GRP.VARCHAR_TYPE;
110 G_ATTR_QUALIFIER_TYPE_tbl QP_PREQ_GRP.VARCHAR_TYPE;
111 G_ATTR_PRODUCT_UOM_CODE_TBL QP_PREQ_GRP.VARCHAR_TYPE;
112 G_ATTR_EXCLUDER_FLAG_TBL QP_PREQ_GRP.VARCHAR_TYPE;
113 G_ATTR_PRICING_PHASE_ID_TBL QP_PREQ_GRP.PLS_INTEGER_TYPE;
114 G_ATTR_INCOM_GRP_CODE_TBL QP_PREQ_GRP.VARCHAR_TYPE;
115 G_ATTR_LDET_TYPE_CODE_TBL QP_PREQ_GRP.VARCHAR_TYPE;
116 G_ATTR_MODIFIER_LEVEL_CODE_TBL QP_PREQ_GRP.VARCHAR_TYPE;
117 G_ATTR_PRIMARY_UOM_FLAG_TBL QP_PREQ_GRP.VARCHAR_TYPE;
118 G_CATCHWEIGHT_QTY_TBL QP_PREQ_GRP.NUMBER_TYPE;
119 G_ACTUAL_ORDER_QTY_TBL QP_PREQ_GRP.NUMBER_TYPE;
120 G_LIST_PRICE_OVERRIDE_FLAG_TBL QP_PREQ_GRP.VARCHAR_TYPE;
121 G_LINE_UNIT_PRICE_TBL QP_PREQ_GRP.NUMBER_TYPE;
122 G_IS_THERE_FREEZE_OVERRIDE Boolean:=TRUE;
123
124 --RT{
125 G_PRICING_EVENT VARCHAR2(80);
126 --3289822{Changed the size from 10 to 240
127 G_RETROBILL_OPERATION VARCHAR2(240);
128 --3289822}
129 --RT}
130
131 Function get_version Return Varchar2 is
132 Begin
133
134 Return('/* $Header: OEXVOPRB.pls 120.48.12020000.9 2013/03/13 21:21:06 cpati ship $ */');
135
136 End;
137
138 procedure Adj_Debug (p_text IN VARCHAR2, p_level IN NUMBER:=5) As
139 --
140 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
141 --
142 Begin
143 If G_DEBUG Then
144 IF l_debug_level > 0 THEN
145 oe_debug_pub.add( P_TEXT , P_LEVEL ) ;
146 END IF;
147 End If;
148 End Adj_Debug;
149
150
151 Function Check_Freeze_Override(p_pricing_event in Varchar2) Return
152 Boolean Is
153
154 Cursor get_phases(l_event_code1 in Varchar2) Is
155 Select e.Pricing_Phase_Id,
156 nvl(p.user_freeze_override_flag,p.freeze_override_flag) pof
157 from qp_event_Phases e, qp_pricing_phases p
158 where e.pricing_phase_id = p.pricing_phase_id and
159 trunc(sysdate) between Trunc(nvl(start_date_active,sysdate)) and
160 trunc(nvl(End_Date_Active,sysdate))
161 and e.pricing_event_code IN
162 (SELECT decode(rownum
163 ,1 ,substr(p_pricing_event,1,instr(l_event_code1,',',1,1)-1)
164 ,2 ,substr(p_pricing_event , instr(l_event_code1,',',1,rownum-1) + 1,
165 instr(l_event_code1,',',1,rownum)-1 - instr(l_event_code1,',',1,rownum-1))
166 ,3 ,substr(p_pricing_event , instr(l_event_code1,',',1,rownum-1) + 1,
167 instr(l_event_code1,',',1,rownum)-1 - instr(l_event_code1,',',1,rownum-1))
168 ,4 ,substr(p_pricing_event , instr(l_event_code1,',',1,rownum-1) + 1,
169 instr(l_event_code1,',',1,rownum)-1 - instr(l_event_code1,',',1,rownum-1))
170 ,5 ,substr(p_pricing_event , instr(l_event_code1,',',1,rownum-1) + 1,
171 instr(l_event_code1,',',1,rownum)-1 - instr(l_event_code1,',',1,rownum-1))
172 ,6 ,substr(p_pricing_event , instr(l_event_code1,',',1,rownum-1) + 1,
173 instr(l_event_code1,',',1,rownum)-1 - instr(l_event_code1,',',1,rownum-1)))
174 FROM qp_event_phases
175 WHERE rownum < 7);
176 --
177 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
178 --
179 Begin
180
181 For i in get_phases(p_pricing_event||',') Loop
182
183 IF l_debug_level > 0 THEN
184 oe_debug_pub.add( 'PRICING PHASE:'||I.PRICING_PHASE_ID ) ;
185 END IF;
186 IF l_debug_level > 0 THEN
187 oe_debug_pub.add( 'FREEZE OVERRIDE-NEW:'||I.POF ) ;
188 END IF;
189
190 If (i.pof = 'Y' and i.pricing_phase_id <> 1) Then
191 IF l_debug_level > 0 THEN
192 oe_debug_pub.add( 'FREEZE OVERRIDE IS Y' ) ;
193 END IF;
194 Return True;
195 End If;
196 End Loop;
197
198 Return False;
199 End;
200
201
202
203 Function Get_List_Lines (p_line_id Number) Return Varchar2 As
204 Cursor list_lines_no is
205 Select c.name,
206 a.list_line_no
207 From qp_preq_ldets_tmp a,
208 qp_preq_lines_tmp b,
209 qp_list_headers_vl c
210 Where b.line_id = p_line_id
211 And b.line_index = a.line_index
212 And a.created_from_list_header_id = c.list_header_id
213 And a.automatic_flag = 'Y'
214 And a.pricing_status_code = 'N'
215 And b.process_status <> 'NOT_VALID'
216 And a.created_from_list_line_type <> 'PLL';
217
218 l_list_line_nos Varchar2(2000):=null;
219 l_separator Varchar2(1):='';
220 --
221 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
222 --
223 Begin
224 For i in List_Lines_no Loop
225 l_list_line_nos := i.name||':'||i.list_line_no||l_separator||l_list_line_nos;
226 l_separator := ',';
227 End Loop;
228 Return l_list_line_nos;
229 End Get_List_Lines;
230
231
232 -- Function Query_Header
233
234 PROCEDURE Query_Header
235 ( p_header_id IN NUMBER,
236 x_header_rec IN OUT NOCOPY OE_Order_PUB.Header_Rec_Type
237 )
238 IS
239 l_org_id NUMBER;
240 l_x_header_rec_oper VARCHAR2(30);
241 --
242 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
243 --
244 BEGIN
245
246 l_org_id := OE_GLOBALS.G_ORG_ID;
247 IF l_org_id IS NULL THEN
248 OE_GLOBALS.Set_Context;
249 l_org_id := OE_GLOBALS.G_ORG_ID;
250 END IF;
251
252 -- aksingh use global record if exists for header_id
253 IF oe_order_cache.g_header_rec.header_id = p_header_id THEN
254 l_x_header_rec_oper := x_header_rec.operation;
255 x_header_rec := oe_order_cache.g_header_rec;
256 x_header_rec.operation := l_x_header_rec_oper;
257 return;
258 END IF;
259
260 IF (QP_UTIL.GET_QP_STATUS = 'I') THEN
261 OE_Header_UTIL.query_row(p_header_id=>p_header_id
262 , x_header_rec => x_header_rec
263 );
264
265 RETURN;
266 END IF;
267
268 IF l_debug_level > 0 THEN
269 oe_debug_pub.add( 'QUERYING HEADER'||P_HEADER_ID , 3 ) ;
270 END IF;
271 SELECT AGREEMENT_ID
272 , CUST_PO_NUMBER
273 , FREIGHT_TERMS_CODE
274 , HEADER_ID
275 , INVOICE_TO_ORG_ID
276 , ORDER_CATEGORY_CODE
277 , ORDER_TYPE_ID
278 , ORDERED_DATE
279 , PAYMENT_TERM_ID
280 , PAYMENT_TYPE_CODE
281 , PRICE_LIST_ID
282 , PRICE_REQUEST_CODE
283 , PRICING_DATE
284 , REQUEST_DATE
285 , SHIP_FROM_ORG_ID
286 , SHIP_TO_ORG_ID
287 , SHIPMENT_PRIORITY_CODE
288 , SHIPPING_METHOD_CODE
289 , SOLD_TO_ORG_ID
290 , TRANSACTIONAL_CURR_CODE
291 , LOCK_CONTROL
292 INTO x_header_rec.AGREEMENT_ID
293 , x_header_rec.CUST_PO_NUMBER
294 , x_header_rec.FREIGHT_TERMS_CODE
295 , x_header_rec.HEADER_ID
296 , x_header_rec.INVOICE_TO_ORG_ID
297 , x_header_rec.ORDER_CATEGORY_CODE
298 , x_header_rec.ORDER_TYPE_ID
299 , x_header_rec.ORDERED_DATE
300 , x_header_rec.PAYMENT_TERM_ID
301 , x_header_rec.PAYMENT_TYPE_CODE
302 , x_header_rec.PRICE_LIST_ID
303 , x_header_rec.PRICE_REQUEST_CODE
304 , x_header_rec.PRICING_DATE
305 , x_header_rec.REQUEST_DATE
306 , x_header_rec.SHIP_FROM_ORG_ID
307 , x_header_rec.SHIP_TO_ORG_ID
308 , x_header_rec.SHIPMENT_PRIORITY_CODE
309 , x_header_rec.SHIPPING_METHOD_CODE
310 , x_header_rec.SOLD_TO_ORG_ID
311 , x_header_rec.TRANSACTIONAL_CURR_CODE
312 , x_header_rec.LOCK_CONTROL
313 FROM OE_ORDER_HEADERS_ALL
314 WHERE HEADER_ID = p_header_id;
315
316 EXCEPTION
317 WHEN NO_DATA_FOUND THEN
318
319 RAISE NO_DATA_FOUND;
320
321 WHEN OTHERS THEN
322
323 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
324 THEN
325 OE_MSG_PUB.Add_Exc_Msg
326 ( G_PKG_NAME
327 , 'Query_Header'
328 );
329 END IF;
330
331 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
332
333 END Query_Header;
334
335 PROCEDURE Query_Lines
336 ( p_line_id IN NUMBER
337 , p_header_id IN NUMBER
338 , x_line_tbl IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
339 )
340 IS
341 l_org_id NUMBER;
342 l_count NUMBER;
343 l_entity VARCHAR2(1);
344 CURSOR l_line_csr IS
345 SELECT AGREEMENT_ID
346 , BOOKED_FLAG
347 , CANCELLED_FLAG
348 , CUST_PO_NUMBER
349 , COMMITMENT_ID
350 , FREIGHT_TERMS_CODE
351 , HEADER_ID
352 , INVENTORY_ITEM_ID
353 , INVOICE_TO_ORG_ID
354 , ITEM_IDENTIFIER_TYPE
355 , ITEM_TYPE_CODE
356 , ORDERED_ITEM_ID
357 , LINE_CATEGORY_CODE
358 , LINE_ID
359 , LINE_TYPE_ID
360 , ORDERED_QUANTITY
361 , ORDER_QUANTITY_UOM
362 , ORDERED_QUANTITY2 -- OPM 2434270
363 , ORDERED_QUANTITY_UOM2 -- OPM 2434270
364 , ORG_ID
365 , PAYMENT_TERM_ID
366 , PLANNING_PRIORITY
367 , PREFERRED_GRADE --OPM 02/JUN/00
368 , PRICE_LIST_ID
369 , PRICE_REQUEST_CODE
370 , PRICING_DATE
371 , PRICING_QUANTITY
372 , PRICING_QUANTITY_UOM
373 , PROMISE_DATE
374 , REQUEST_DATE
375 , SHIPMENT_PRIORITY_CODE
376 , SHIPPING_METHOD_CODE
377 , SHIP_FROM_ORG_ID
378 , SHIPPABLE_FLAG
379 , SHIPPED_QUANTITY
380 , SHIP_SET_ID
381 , SHIP_TO_ORG_ID
382 , SOLD_TO_ORG_ID
383 , SOLD_FROM_ORG_ID
384 , SOURCE_TYPE_CODE
385 , SPLIT_FROM_LINE_ID
386 , TAX_EXEMPT_FLAG
387 , UNIT_LIST_PRICE
388 , UNIT_LIST_PRICE_PER_PQTY
389 , UNIT_SELLING_PRICE
390 , UNIT_SELLING_PRICE_PER_PQTY
391 , UNIT_LIST_PERCENT
392 , UNIT_SELLING_PERCENT
393 , UNIT_PERCENT_BASE_PRICE
394 , CALCULATE_PRICE_FLAG
395 , upgraded_flag
396 , CHARGE_PERIODICITY_CODE --rc
397 , LOCK_CONTROL
398 FROM OE_ORDER_LINES /* MOAC SQL NO CHANGE */
399 WHERE l_entity = 'L'
400 -- AND ORDERED_QUANTITY <> 0 (--bug 3018537) commented for the FP bug 3335024
401 AND LINE_ID = p_line_id
402 UNION
403 SELECT AGREEMENT_ID
404 , BOOKED_FLAG
405 , CANCELLED_FLAG
406 , CUST_PO_NUMBER
407 , COMMITMENT_ID
408 , FREIGHT_TERMS_CODE
409 , HEADER_ID
410 , INVENTORY_ITEM_ID
411 , INVOICE_TO_ORG_ID
412 , ITEM_IDENTIFIER_TYPE
413 , ITEM_TYPE_CODE
414 , ORDERED_ITEM_ID
415 , LINE_CATEGORY_CODE
416 , LINE_ID
417 , LINE_TYPE_ID
418 , ORDERED_QUANTITY
419 , ORDER_QUANTITY_UOM
420 , ORDERED_QUANTITY2 -- OPM 2434270
421 , ORDERED_QUANTITY_UOM2 -- OPM 2434270
422 , ORG_ID
423 , PAYMENT_TERM_ID
424 , PLANNING_PRIORITY
425 , PREFERRED_GRADE --OPM 02/JUN/00
426 , PRICE_LIST_ID
427 , PRICE_REQUEST_CODE
428 , PRICING_DATE
429 , PRICING_QUANTITY
430 , PRICING_QUANTITY_UOM
431 , PROMISE_DATE
432 , REQUEST_DATE
433 , SHIPMENT_PRIORITY_CODE
434 , SHIPPING_METHOD_CODE
435 , SHIP_FROM_ORG_ID
436 , SHIPPABLE_FLAG
437 , SHIPPED_QUANTITY
438 , SHIP_SET_ID
439 , SHIP_TO_ORG_ID
440 , SOLD_TO_ORG_ID
441 , SOLD_FROM_ORG_ID
442 , SOURCE_TYPE_CODE
443 , SPLIT_FROM_LINE_ID
444 , TAX_EXEMPT_FLAG
445 , UNIT_LIST_PRICE
446 , UNIT_LIST_PRICE_PER_PQTY
447 , UNIT_SELLING_PRICE
448 , UNIT_SELLING_PRICE_PER_PQTY
449 , UNIT_LIST_PERCENT
450 , UNIT_SELLING_PERCENT
451 , UNIT_PERCENT_BASE_PRICE
452 , CALCULATE_PRICE_FLAG
453 , CHARGE_PERIODICITY_CODE --rc
454 , upgraded_flag
455 , LOCK_CONTROL
456 FROM OE_ORDER_LINES /* MOAC SQL NO CHANGE */
457 WHERE l_entity = 'H'
458 --AND ORDERED_QUANTITY <> 0 (--bug 3018537) commented for the FP bug 3335024
459 AND HEADER_ID = p_header_id;
460
461 --
462 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
463 --
464 BEGIN
465
466 IF l_debug_level > 0 THEN
467 oe_debug_pub.add( 'IN QUERY LINES. GET_QP_STATUS:'||QP_UTIL.GET_QP_STATUS ) ;
468 END IF;
469 IF l_debug_level > 0 THEN
470 oe_debug_pub.add( 'G_RECURSION_MODE:'||OE_GLOBALS.G_RECURSION_MODE ) ;
471 END IF;
472 IF (QP_UTIL.GET_QP_STATUS = 'I' OR OE_GLOBALS.G_RECURSION_MODE <> FND_API.G_TRUE) THEN
473 OE_LINE_UTIL.query_rows(p_line_id=>p_line_id
474 , p_header_id => p_header_id
475 , x_line_tbl => x_line_tbl
476 );
477 IF l_debug_level > 0 THEN
478 oe_debug_pub.add( ' X_LINE_TBL COUNT FROM OE_LINE_UTIL.QUERY_ROWS:'||X_LINE_TBL.COUNT ) ;
479 END IF;
480 --commented for the FP bug 3335024
481 /*
482 --bug 3289322, pl/sql error when count is zero
483 if (x_line_tbl.count > 0) then
484 --bug 3018537 begin
485 for i in x_line_tbl.first..x_line_tbl.last loop
486 if x_line_tbl(i).ordered_quantity = 0 then
487 oe_debug_pub.add(' Not passing line id:'||x_line_tbl(i).line_id||' to pricing engine -- 0 ord qty ');
488 x_line_tbl.delete(i);
489 end if;
490 end loop;
491 oe_debug_pub.add(' New x_line_tbl count:'||x_line_tbl.count);
492 end if;
493 --bug 3018537 end
494 */
495 RETURN;
496 END IF;
497
498 IF nvl(p_line_id,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM THEN
499
500 l_entity := 'L';
501
502 ELSIF nvl(p_header_id,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM THEN
503 IF l_debug_level > 0 THEN
504 oe_debug_pub.add( 'SETTING ENTITY TO H' ) ;
505 END IF;
506 l_entity := 'H';
507
508 END IF;
509
510 l_org_id := OE_GLOBALS.G_ORG_ID;
511 if l_org_id IS NULL THEN
512 OE_GLOBALS.Set_Context;
513 l_org_id := OE_GLOBALS.G_ORG_ID;
514 end if;
515
516 IF l_debug_level > 0 THEN
517 oe_debug_pub.add( 'ENTERING OE_ORDER_PRICE_PVT.QUERY_LINES '||TO_CHAR ( L_ORG_ID ) , 1 ) ;
518 END IF;
519 IF l_debug_level > 0 THEN
520 oe_debug_pub.add( 'HEADER_ID:'||P_HEADER_ID||' LINE_ID:'||P_LINE_ID , 3 ) ;
521 END IF;
522
523
524 -- Loop over fetched records
525
526 l_count := 1;
527
528 FOR l_implicit_rec IN l_line_csr LOOP
529
530 x_line_tbl(l_count).AGREEMENT_ID := l_implicit_rec.AGREEMENT_ID;
531 x_line_tbl(l_count).CUST_PO_NUMBER := l_implicit_rec.CUST_PO_NUMBER;
532 x_line_tbl(l_count).FREIGHT_TERMS_CODE := l_implicit_rec.FREIGHT_TERMS_CODE;
533 x_line_tbl(l_count).HEADER_ID := l_implicit_rec.HEADER_ID;
534 x_line_tbl(l_count).INVENTORY_ITEM_ID := l_implicit_rec.INVENTORY_ITEM_ID;
535 x_line_tbl(l_count).INVOICE_TO_ORG_ID := l_implicit_rec.INVOICE_TO_ORG_ID;
536 x_line_tbl(l_count).ITEM_IDENTIFIER_TYPE:= l_implicit_rec.ITEM_IDENTIFIER_TYPE;
537 x_line_tbl(l_count).ITEM_TYPE_CODE := l_implicit_rec.ITEM_TYPE_CODE;
538 x_line_tbl(l_count).ORDERED_ITEM_ID := l_implicit_rec.ORDERED_ITEM_ID;
539 x_line_tbl(l_count).LINE_CATEGORY_CODE := l_implicit_rec.LINE_CATEGORY_CODE;
540 x_line_tbl(l_count).LINE_ID := l_implicit_rec.LINE_ID;
541 x_line_tbl(l_count).LINE_TYPE_ID := l_implicit_rec.LINE_TYPE_ID;
542 x_line_tbl(l_count).ORDERED_QUANTITY := l_implicit_rec.ORDERED_QUANTITY;
543 x_line_tbl(l_count).ORDER_QUANTITY_UOM := l_implicit_rec.ORDER_QUANTITY_UOM;
544 x_line_tbl(l_count).ORDERED_QUANTITY2 := l_implicit_rec.ORDERED_QUANTITY2; -- OPM 2434270
545 x_line_tbl(l_count).ORDERED_QUANTITY_UOM2 := l_implicit_rec.ORDERED_QUANTITY_UOM2; -- OPM 2434270
546 x_line_tbl(l_count).ORG_ID := l_implicit_rec.ORG_ID;
547 x_line_tbl(l_count).payment_term_id := l_implicit_rec.PAYMENT_TERM_ID;
548 x_line_tbl(l_count).planning_priority := l_implicit_rec.PLANNING_PRIORITY;
549 x_line_tbl(l_count).preferred_grade := l_implicit_rec.PREFERRED_GRADE;
550 x_line_tbl(l_count).price_list_id := l_implicit_rec.PRICE_LIST_ID;
551 x_line_tbl(l_count).pricing_date := l_implicit_rec.PRICING_DATE;
552 x_line_tbl(l_count).pricing_quantity := l_implicit_rec.PRICING_QUANTITY;
553 x_line_tbl(l_count).pricing_quantity_uom := l_implicit_rec.PRICING_QUANTITY_UOM;
554 x_line_tbl(l_count).promise_date := l_implicit_rec.PROMISE_DATE;
555 x_line_tbl(l_count).request_date := l_implicit_rec.REQUEST_DATE;
556 x_line_tbl(l_count).shipment_priority_code := l_implicit_rec.SHIPMENT_PRIORITY_CODE;
557 x_line_tbl(l_count).shipping_method_code := l_implicit_rec.SHIPPING_METHOD_CODE;
558 x_line_tbl(l_count).ship_from_org_id := l_implicit_rec.SHIP_FROM_ORG_ID;
559 x_line_tbl(l_count).shippable_flag := l_implicit_rec.SHIPPABLE_FLAG;
560 x_line_tbl(l_count).ship_set_id := l_implicit_rec.ship_set_id;
561 x_line_tbl(l_count).ship_to_org_id := l_implicit_rec.SHIP_TO_ORG_ID;
562 x_line_tbl(l_count).sold_to_org_id := l_implicit_rec.SOLD_TO_ORG_ID;
563 x_line_tbl(l_count).sold_from_org_id := l_implicit_rec.SOLD_FROM_ORG_ID;
564 x_line_tbl(l_count).source_type_code := l_implicit_rec.SOURCE_TYPE_CODE;
565 x_line_tbl(l_count).split_from_line_id := l_implicit_rec.SPLIT_FROM_LINE_ID;
566 x_line_tbl(l_count).unit_list_price := l_implicit_rec.UNIT_LIST_PRICE;
567 x_line_tbl(l_count).unit_list_price_per_pqty := l_implicit_rec.UNIT_LIST_PRICE_PER_PQTY;
568 x_line_tbl(l_count).unit_selling_price := l_implicit_rec.UNIT_SELLING_PRICE;
569 x_line_tbl(l_count).unit_selling_price_per_pqty := l_implicit_rec.UNIT_SELLING_PRICE_PER_PQTY;
570 x_line_tbl(l_count).unit_list_percent := l_implicit_rec.unit_list_percent;
571 x_line_tbl(l_count).unit_selling_percent := l_implicit_rec.unit_selling_percent;
572 x_line_tbl(l_count).unit_percent_base_price := l_implicit_rec.unit_percent_base_price;
573 x_line_tbl(l_count).calculate_price_flag := l_implicit_rec.calculate_price_flag;
574 x_line_tbl(l_count).charge_periodicity_code := l_implicit_rec.charge_periodicity_code; --rc
575 x_line_tbl(l_count).lock_control:= l_implicit_rec.lock_control;
576
577 -- set values for non-DB fields
578 x_line_tbl(l_count).db_flag := FND_API.G_TRUE;
579 x_line_tbl(l_count).operation := FND_API.G_MISS_CHAR;
580 x_line_tbl(l_count).return_status := FND_API.G_MISS_CHAR;
581 x_line_tbl(l_count).change_reason := FND_API.G_MISS_CHAR;
582 x_line_tbl(l_count).change_comments := FND_API.G_MISS_CHAR;
583 l_count := l_count + 1;
584
585 END LOOP;
586
587
588 -- PK sent and no rows found
589
590 IF
591 (p_line_id IS NOT NULL
592 AND
593 p_line_id <> FND_API.G_MISS_NUM)
594 AND
595 (x_line_tbl.COUNT = 0)
596 THEN
597 RAISE NO_DATA_FOUND;
598 END IF;
599
600
601 -- Return fetched table
602 IF l_debug_level > 0 THEN
603 oe_debug_pub.add( 'EXITING OE_ORDER_PRICE_PVT.QUERY_LINES' , 1 ) ;
604 END IF;
605
606 EXCEPTION
607
608 WHEN NO_DATA_FOUND THEN
609
610 RAISE NO_DATA_FOUND;
611
612 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
613
614 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
615
616 WHEN OTHERS THEN
617
618 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
619 THEN
620 OE_MSG_PUB.Add_Exc_Msg
621 ( G_PKG_NAME
622 , 'Query_lines'
623 );
624 END IF;
625
626 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
627
628 END Query_Lines;
629
630 -- Procedure Query_Line
631
632 PROCEDURE Query_Line
633 ( p_line_id IN NUMBER
634 , x_line_rec IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type
635 )
636 IS
637 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
638 --
639 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
640 --
641 BEGIN
642 IF l_debug_level > 0 THEN
643 oe_debug_pub.add( ' QUERY_LINE' ) ;
644 END IF;
645 Query_Lines
646 ( p_line_id => p_line_id
647 , p_header_id => Null
648 , x_line_tbl => l_line_tbl
649 );
650
651 x_line_rec := l_line_tbl(1);
652 IF l_debug_level > 0 THEN
653 oe_debug_pub.add( ' LEAVING QUERY_LINE' ) ;
654 END IF;
655 END Query_Line;
656
657 Function Enforce_list_Price
658 return varchar2
659 is
660 l_enforce_price_flag varchar2(1);
661 --
662 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
663 --
664 begin
665 IF l_debug_level > 0 THEN
666 oe_debug_pub.add( 'ENTERING OE_ORDER_PRICE_PVT.ENFORCE_PRICE_LISTS_FLAG' , 1 ) ;
667 END IF;
668 begin
669
670 G_STMT_NO := 'Enforce_Price_lists_Flag#10';
671 -- changes for bug 4200055
672 IF ( OE_Order_PUB.G_Line.Line_Type_id is not null
673 AND OE_Order_PUB.G_Line.Line_Type_id <> FND_API.G_MISS_NUM ) THEN
674 if (OE_Order_Cache.g_line_type_rec.line_type_id <> OE_Order_PUB.G_Line.Line_Type_id) then
675 OE_Order_Cache.Load_Line_type(OE_Order_PUB.G_Line.Line_Type_id) ;
676 end if ;
677 if (OE_Order_Cache.g_line_type_rec.line_type_id = OE_Order_PUB.G_Line.Line_Type_id ) then
678 l_enforce_price_flag := nvl(OE_Order_Cache.g_line_type_rec.enforce_line_prices_flag,'N') ;
679 else
680 l_enforce_price_flag := 'N';
681 end if ;
682 ELSE
683 l_enforce_price_flag := 'N';
684 END IF ;
685 /* select nvl(enforce_line_prices_flag,'N') into l_enforce_price_flag
686 from oe_line_types_v where line_type_id=OE_Order_PUB.G_Line.Line_Type_id; */
687 --end bug 4200055
688 -- exception when no_data_found then
689 exception when others then
690 l_enforce_price_flag := 'N';
691 end ;
692
693 If l_enforce_price_flag='N' then
694 begin
695 G_STMT_NO := 'Enforce_Price_lists_Flag#20';
696 --changes for bug 4200055
697 IF ( OE_Order_PUB.G_Hdr.Order_Type_id is not null
698 AND OE_Order_PUB.G_Hdr.Order_Type_id <> FND_API.G_MISS_NUM ) THEN
699 if (OE_Order_Cache.g_order_type_rec.order_type_id <> OE_Order_PUB.G_Hdr.Order_Type_id) then
700 OE_Order_Cache.Load_Order_type(OE_Order_PUB.G_Hdr.Order_Type_id) ;
701 end if ;
702 if (OE_Order_Cache.g_order_type_rec.order_type_id = OE_Order_PUB.G_Hdr.Order_Type_id ) then
703 l_enforce_price_flag := nvl(OE_Order_Cache.g_order_type_rec.enforce_line_prices_flag,'N') ;
704 else
705 l_enforce_price_flag := 'N';
706 end if ;
707 ELSE
708 l_enforce_price_flag := 'N';
709 END IF ;
710 /*select nvl(enforce_line_prices_flag,'N') into l_enforce_price_flag
711 from oe_Order_types_v where Order_type_id=OE_Order_PUB.g_hdr.Order_Type_Id;*/
712 -- end bug 4200055
713 -- exception when no_data_found then
714 exception when others then
715 l_enforce_price_flag := 'N';
716 end ;
717 end if;
718
719 IF l_debug_level > 0 THEN
720 oe_debug_pub.add( 'EXITING OE_ORDER_PRICE_PVT.ENFORCE_PRICE_LISTS_FLAG' , 1 ) ;
721 END IF;
722
723 Return l_enforce_price_flag;
724
725 end Enforce_list_Price;
726
727 Function Get_Rounding_factor(p_list_header_id number)
728 return number
729 is
730 --
731 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
732 --
733 begin
734 IF l_debug_level > 0 THEN
735 oe_debug_pub.add( 'ENTERING GET_ROUNDING_FACTOR'||G_ROUNDING_FACTOR_REC.ROUNDING_FACTOR , 3 ) ;
736 END IF;
737 If g_rounding_factor_rec.list_header_id = p_list_header_id then
738 Return g_rounding_factor_rec.rounding_factor;
739 Else
740 g_rounding_factor_rec.list_header_id := p_list_header_id;
741 select rounding_factor into g_rounding_factor_rec.rounding_factor from
742 qp_list_headers_b where list_header_id=p_list_header_id;
743
744 If g_rounding_factor_rec.rounding_factor = fnd_api.g_miss_num then
745 g_rounding_factor_rec.rounding_factor:= Null;
746 End If;
747
748 IF l_debug_level > 0 THEN
749 oe_debug_pub.add( 'ROUNDING FACTOR'||G_ROUNDING_FACTOR_REC.ROUNDING_FACTOR , 3 ) ;
750 END IF;
751 Return g_rounding_factor_rec.rounding_factor;
752
753 End if;
754 Exception when no_data_found then
755 Return Null;
756 end Get_Rounding_factor;
757
758 procedure Append_asked_for(
759 p_header_id number
760 ,p_Line_id number
761 ,p_line_index number
762 ,px_line_attr_index in out NOCOPY number
763 )
764 is
765 i pls_integer;
766 -- Using union all to eliminate sort unique
767 cursor asked_for_cur is
768 select flex_title, pricing_context, pricing_attribute1,
769 pricing_attribute2 , pricing_attribute3 , pricing_attribute4 , pricing_attribute5 ,
770 pricing_attribute6 , pricing_attribute7 , pricing_attribute8 , pricing_attribute9 ,
771 pricing_attribute10 , pricing_attribute11 , pricing_attribute12 , pricing_attribute13 ,
772 pricing_attribute14 , pricing_attribute15 , pricing_attribute16 , pricing_attribute17 ,
773 pricing_attribute18 , pricing_attribute19 , pricing_attribute20 , pricing_attribute21 ,
774 pricing_attribute22 , pricing_attribute23 , pricing_attribute24 , pricing_attribute25 ,
775 pricing_attribute26 , pricing_attribute27 , pricing_attribute28 , pricing_attribute29 ,
776 pricing_attribute30 , pricing_attribute31 , pricing_attribute32 , pricing_attribute33 ,
777 pricing_attribute34 , pricing_attribute35 , pricing_attribute36 , pricing_attribute37 ,
778 pricing_attribute38 , pricing_attribute39 , pricing_attribute40 , pricing_attribute41 ,
779 pricing_attribute42 , pricing_attribute43 , pricing_attribute44 , pricing_attribute45 ,
780 pricing_attribute46 , pricing_attribute47 , pricing_attribute48 , pricing_attribute49 ,
781 pricing_attribute50 , pricing_attribute51 , pricing_attribute52 , pricing_attribute53 ,
782 pricing_attribute54 , pricing_attribute55 , pricing_attribute56 , pricing_attribute57 ,
783 pricing_attribute58 , pricing_attribute59 , pricing_attribute60 , pricing_attribute61 ,
784 pricing_attribute62 , pricing_attribute63 , pricing_attribute64 , pricing_attribute65 ,
785 pricing_attribute66 , pricing_attribute67 , pricing_attribute68 , pricing_attribute69 ,
786 pricing_attribute70 , pricing_attribute71 , pricing_attribute72 , pricing_attribute73 ,
787 pricing_attribute74 , pricing_attribute75 , pricing_attribute76 , pricing_attribute77 ,
788 pricing_attribute78 , pricing_attribute79 , pricing_attribute80 , pricing_attribute81 ,
789 pricing_attribute82 , pricing_attribute83 , pricing_attribute84 , pricing_attribute85 ,
790 pricing_attribute86 , pricing_attribute87 , pricing_attribute88 , pricing_attribute89 ,
791 pricing_attribute90 , pricing_attribute91 , pricing_attribute92 , pricing_attribute93 ,
792 pricing_attribute94 , pricing_attribute95 , pricing_attribute96 , pricing_attribute97 ,
793 pricing_attribute98 , pricing_attribute99 , pricing_attribute100
794 ,Override_Flag
795 from oe_order_price_attribs a
796 where (a.line_id is null and a.header_id = p_header_id )
797 union all
798 select flex_title, pricing_context, pricing_attribute1,
799 pricing_attribute2 , pricing_attribute3 , pricing_attribute4 , pricing_attribute5 ,
800 pricing_attribute6 , pricing_attribute7 , pricing_attribute8 , pricing_attribute9 ,
801 pricing_attribute10 , pricing_attribute11 , pricing_attribute12 , pricing_attribute13 ,
802 pricing_attribute14 , pricing_attribute15 , pricing_attribute16 , pricing_attribute17 ,
803 pricing_attribute18 , pricing_attribute19 , pricing_attribute20 , pricing_attribute21 ,
804 pricing_attribute22 , pricing_attribute23 , pricing_attribute24 , pricing_attribute25 ,
805 pricing_attribute26 , pricing_attribute27 , pricing_attribute28 , pricing_attribute29 ,
806 pricing_attribute30 , pricing_attribute31 , pricing_attribute32 , pricing_attribute33 ,
807 pricing_attribute34 , pricing_attribute35 , pricing_attribute36 , pricing_attribute37 ,
808 pricing_attribute38 , pricing_attribute39 , pricing_attribute40 , pricing_attribute41 ,
809 pricing_attribute42 , pricing_attribute43 , pricing_attribute44 , pricing_attribute45 ,
810 pricing_attribute46 , pricing_attribute47 , pricing_attribute48 , pricing_attribute49 ,
811 pricing_attribute50 , pricing_attribute51 , pricing_attribute52 , pricing_attribute53 ,
812 pricing_attribute54 , pricing_attribute55 , pricing_attribute56 , pricing_attribute57 ,
813 pricing_attribute58 , pricing_attribute59 , pricing_attribute60 , pricing_attribute61 ,
814 pricing_attribute62 , pricing_attribute63 , pricing_attribute64 , pricing_attribute65 ,
815 pricing_attribute66 , pricing_attribute67 , pricing_attribute68 , pricing_attribute69 ,
816 pricing_attribute70 , pricing_attribute71 , pricing_attribute72 , pricing_attribute73 ,
817 pricing_attribute74 , pricing_attribute75 , pricing_attribute76 , pricing_attribute77 ,
818 pricing_attribute78 , pricing_attribute79 , pricing_attribute80 , pricing_attribute81 ,
819 pricing_attribute82 , pricing_attribute83 , pricing_attribute84 , pricing_attribute85 ,
820 pricing_attribute86 , pricing_attribute87 , pricing_attribute88 , pricing_attribute89 ,
821 pricing_attribute90 , pricing_attribute91 , pricing_attribute92 , pricing_attribute93 ,
822 pricing_attribute94 , pricing_attribute95 , pricing_attribute96 , pricing_attribute97 ,
823 pricing_attribute98 , pricing_attribute99 , pricing_attribute100
824 ,Override_Flag
825 from oe_order_price_attribs a
826 where (p_line_id is not null and a.line_id = p_line_id);
827
828 --l_Req_qual_tbl QP_PREQ_GRP.QUAL_TBL_TYPE;
829 px_Req_line_attr_tbl QP_PREQ_GRP.LINE_ATTR_TBL_TYPE;
830 k NUMBER := px_line_attr_index;
831 l_attribute_type varchar2(30);
832 --
833 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
834 --
835 begin
836 G_STMT_NO := 'Append_asked_for#10';
837 IF l_debug_level > 0 THEN
838 oe_debug_pub.add( 'ENTERING OE_ORDER_PRICE_PVT.APPEND_ASKED_FOR' , 1 ) ;
839 END IF;
840 for asked_for_rec in asked_for_cur loop
841 If asked_for_rec.flex_title = 'QP_ATTR_DEFNS_PRICING' then
842 if asked_for_rec.PRICING_ATTRIBUTE1 is not null then
843 i := px_Req_line_attr_tbl.count+1;
844 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
845 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
846 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
847 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE1';
848 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE1;
849 end if;
850 if asked_for_rec.PRICING_ATTRIBUTE2 is not null then
851 i := px_Req_line_attr_tbl.count+1;
852 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
853 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
854 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
855 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE2';
856 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE2;
857 end if;
858 if asked_for_rec.PRICING_ATTRIBUTE3 is not null then
859 i := px_Req_line_attr_tbl.count+1;
860 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
861 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
862 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
863 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE3';
864 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE3;
865 end if;
866 if asked_for_rec.PRICING_ATTRIBUTE4 is not null then
867 i := px_Req_line_attr_tbl.count+1;
868 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
869 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
870 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
871 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE4';
872 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE4;
873 end if;
874 if asked_for_rec.PRICING_ATTRIBUTE5 is not null then
875 i := px_Req_line_attr_tbl.count+1;
876 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
877 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
878 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
879 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE5';
880 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE5;
881 end if;
882 if asked_for_rec.PRICING_ATTRIBUTE6 is not null then
883 i := px_Req_line_attr_tbl.count+1;
884 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
885 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
886 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
887 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE6';
888 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE6;
889 end if;
890 if asked_for_rec.PRICING_ATTRIBUTE7 is not null then
891 i := px_Req_line_attr_tbl.count+1;
892 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
893 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
894 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
895 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE7';
896 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE7;
897 end if;
898 if asked_for_rec.PRICING_ATTRIBUTE8 is not null then
899 i := px_Req_line_attr_tbl.count+1;
900 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
901 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
902 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
903 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE8';
904 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE8;
905 end if;
906 if asked_for_rec.PRICING_ATTRIBUTE9 is not null then
907 i := px_Req_line_attr_tbl.count+1;
908 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
909 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
910 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
911 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE9';
912 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE9;
913 end if;
914
915 if asked_for_rec.PRICING_ATTRIBUTE10 is not null then
916 i := px_Req_line_attr_tbl.count+1;
917 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
918 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
919 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
920 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE10';
921 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE10;
922 end if;
923 if asked_for_rec.PRICING_ATTRIBUTE11 is not null then
924 i := px_Req_line_attr_tbl.count+1;
925 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
926 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
927 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
928 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE11';
929 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE11;
930 end if;
931 if asked_for_rec.PRICING_ATTRIBUTE12 is not null then
932 i := px_Req_line_attr_tbl.count+1;
933 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
934 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
935 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
936 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE12';
937 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE12;
938 end if;
939 if asked_for_rec.PRICING_ATTRIBUTE13 is not null then
940 i := px_Req_line_attr_tbl.count+1;
941 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
942 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
943 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
944 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE13';
945 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE13;
946 end if;
947 if asked_for_rec.PRICING_ATTRIBUTE14 is not null then
948 i := px_Req_line_attr_tbl.count+1;
949 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
950 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
951 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
952 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE14';
953 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE14;
954 end if;
955 if asked_for_rec.PRICING_ATTRIBUTE15 is not null then
956 i := px_Req_line_attr_tbl.count+1;
957 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
958 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
959 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
960 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE15';
961 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE15;
962 end if;
963 if asked_for_rec.PRICING_ATTRIBUTE16 is not null then
964 i := px_Req_line_attr_tbl.count+1;
965 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
966 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
967 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
968 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE16';
969 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE16;
970 end if;
971 if asked_for_rec.PRICING_ATTRIBUTE17 is not null then
972 i := px_Req_line_attr_tbl.count+1;
973 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
974 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
975 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
976 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE17';
977 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE17;
978 end if;
979 if asked_for_rec.PRICING_ATTRIBUTE18 is not null then
980 i := px_Req_line_attr_tbl.count+1;
981 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
982 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
983 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
984 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE18';
985 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE18;
986 end if;
987 if asked_for_rec.PRICING_ATTRIBUTE19 is not null then
988 i := px_Req_line_attr_tbl.count+1;
989 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
990 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
991 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
992 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE19';
993 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE19;
994 end if;
995
996 if asked_for_rec.PRICING_ATTRIBUTE20 is not null then
997 i := px_Req_line_attr_tbl.count+1;
998 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
999 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1000 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1001 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE20';
1002 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE20;
1003 end if;
1004 if asked_for_rec.PRICING_ATTRIBUTE21 is not null then
1005 i := px_Req_line_attr_tbl.count+1;
1006 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1007 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1008 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1009 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE21';
1010 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE21;
1011 end if;
1012 if asked_for_rec.PRICING_ATTRIBUTE22 is not null then
1013 i := px_Req_line_attr_tbl.count+1;
1014 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1015 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1016 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1017 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE22';
1018 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE22;
1019 end if;
1020 if asked_for_rec.PRICING_ATTRIBUTE23 is not null then
1021 i := px_Req_line_attr_tbl.count+1;
1022 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1023 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1024 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1025 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE23';
1026 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE23;
1027 end if;
1028 if asked_for_rec.PRICING_ATTRIBUTE24 is not null then
1029 i := px_Req_line_attr_tbl.count+1;
1030 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1031 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1032 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1033 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE24';
1034 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE24;
1035 end if;
1036 if asked_for_rec.PRICING_ATTRIBUTE25 is not null then
1037 i := px_Req_line_attr_tbl.count+1;
1038 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1039 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1040 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1041 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE25';
1042 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE25;
1043 end if;
1044 if asked_for_rec.PRICING_ATTRIBUTE26 is not null then
1045 i := px_Req_line_attr_tbl.count+1;
1046 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1047 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1048 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1049 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE26';
1050 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE26;
1051 end if;
1052 if asked_for_rec.PRICING_ATTRIBUTE27 is not null then
1053 i := px_Req_line_attr_tbl.count+1;
1054 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1055 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1056 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1057 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE27';
1058 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE27;
1059 end if;
1060 if asked_for_rec.PRICING_ATTRIBUTE28 is not null then
1061 i := px_Req_line_attr_tbl.count+1;
1062 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1063 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1064 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1065 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE28';
1066 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE28;
1067 end if;
1068 if asked_for_rec.PRICING_ATTRIBUTE29 is not null then
1069 i := px_Req_line_attr_tbl.count+1;
1070 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1071 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1072 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1073 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE29';
1074 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE29;
1075 end if;
1076
1077 if asked_for_rec.PRICING_ATTRIBUTE30 is not null then
1078 i := px_Req_line_attr_tbl.count+1;
1079 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1080 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1081 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1082 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE30';
1083 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE30;
1084 end if;
1085 if asked_for_rec.PRICING_ATTRIBUTE31 is not null then
1086 i := px_Req_line_attr_tbl.count+1;
1087 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1088 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1089 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1090 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE31';
1091 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE31;
1092 end if;
1093 if asked_for_rec.PRICING_ATTRIBUTE32 is not null then
1094 i := px_Req_line_attr_tbl.count+1;
1095 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1096 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1097 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1098 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE32';
1099 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE32;
1100 end if;
1101 if asked_for_rec.PRICING_ATTRIBUTE33 is not null then
1102 i := px_Req_line_attr_tbl.count+1;
1103 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1104 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1105 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1106 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE33';
1107 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE33;
1108 end if;
1109 if asked_for_rec.PRICING_ATTRIBUTE34 is not null then
1110 i := px_Req_line_attr_tbl.count+1;
1111 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1112 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1113 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1114 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE34';
1115 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE34;
1116 end if;
1117 if asked_for_rec.PRICING_ATTRIBUTE35 is not null then
1118 i := px_Req_line_attr_tbl.count+1;
1119 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1120 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1121 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1122 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE35';
1123 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE35;
1124 end if;
1125 if asked_for_rec.PRICING_ATTRIBUTE36 is not null then
1126 i := px_Req_line_attr_tbl.count+1;
1127 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1128 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1129 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1130 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE36';
1131 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE36;
1132 end if;
1133 if asked_for_rec.PRICING_ATTRIBUTE37 is not null then
1134 i := px_Req_line_attr_tbl.count+1;
1135 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1136 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1137 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1138 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE37';
1139 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE37;
1140 end if;
1141 if asked_for_rec.PRICING_ATTRIBUTE38 is not null then
1142 i := px_Req_line_attr_tbl.count+1;
1143 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1144 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1145 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1146 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE38';
1147 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE38;
1148 end if;
1149 if asked_for_rec.PRICING_ATTRIBUTE39 is not null then
1150 i := px_Req_line_attr_tbl.count+1;
1151 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1152 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1153 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1154 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE39';
1155 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE39;
1156 end if;
1157
1158 if asked_for_rec.PRICING_ATTRIBUTE40 is not null then
1159 i := px_Req_line_attr_tbl.count+1;
1160 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1161 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1162 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1163 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE40';
1164 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE40;
1165 end if;
1166 if asked_for_rec.PRICING_ATTRIBUTE41 is not null then
1167 i := px_Req_line_attr_tbl.count+1;
1168 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1169 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1170 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1171 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE41';
1172 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE41;
1173 end if;
1174 if asked_for_rec.PRICING_ATTRIBUTE42 is not null then
1175 i := px_Req_line_attr_tbl.count+1;
1176 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1177 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1178 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1179 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE42';
1180 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE42;
1181 end if;
1182 if asked_for_rec.PRICING_ATTRIBUTE43 is not null then
1183 i := px_Req_line_attr_tbl.count+1;
1184 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1185 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1186 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1187 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE43';
1188 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE43;
1189 end if;
1190 if asked_for_rec.PRICING_ATTRIBUTE44 is not null then
1191 i := px_Req_line_attr_tbl.count+1;
1192 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1193 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1194 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1195 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE44';
1196 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE44;
1197 end if;
1198 if asked_for_rec.PRICING_ATTRIBUTE45 is not null then
1199 i := px_Req_line_attr_tbl.count+1;
1200 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1201 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1202 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1203 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE45';
1204 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE45;
1205 end if;
1206 if asked_for_rec.PRICING_ATTRIBUTE46 is not null then
1207 i := px_Req_line_attr_tbl.count+1;
1208 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1209 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1210 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1211 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE46';
1212 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE46;
1213 end if;
1214 if asked_for_rec.PRICING_ATTRIBUTE47 is not null then
1215 i := px_Req_line_attr_tbl.count+1;
1216 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1217 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1218 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1219 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE47';
1220 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE47;
1221 end if;
1222 if asked_for_rec.PRICING_ATTRIBUTE48 is not null then
1223 i := px_Req_line_attr_tbl.count+1;
1224 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1225 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1226 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1227 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE48';
1228 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE48;
1229 end if;
1230 if asked_for_rec.PRICING_ATTRIBUTE49 is not null then
1231 i := px_Req_line_attr_tbl.count+1;
1232 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1233 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1234 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1235 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE49';
1236 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE49;
1237 end if;
1238
1239 if asked_for_rec.PRICING_ATTRIBUTE50 is not null then
1240 i := px_Req_line_attr_tbl.count+1;
1241 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1242 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1243 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1244 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE50';
1245 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE50;
1246 end if;
1247 if asked_for_rec.PRICING_ATTRIBUTE51 is not null then
1248 i := px_Req_line_attr_tbl.count+1;
1249 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1250 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1251 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1252 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE51';
1253 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE51;
1254 end if;
1255 if asked_for_rec.PRICING_ATTRIBUTE52 is not null then
1256 i := px_Req_line_attr_tbl.count+1;
1257 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1258 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1259 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1260 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE52';
1261 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE52;
1262 end if;
1263 if asked_for_rec.PRICING_ATTRIBUTE53 is not null then
1264 i := px_Req_line_attr_tbl.count+1;
1265 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1266 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1267 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1268 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE53';
1269 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE53;
1270 end if;
1271 if asked_for_rec.PRICING_ATTRIBUTE54 is not null then
1272 i := px_Req_line_attr_tbl.count+1;
1273 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1274 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1275 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1276 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE54';
1277 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE54;
1278 end if;
1279 if asked_for_rec.PRICING_ATTRIBUTE55 is not null then
1280 i := px_Req_line_attr_tbl.count+1;
1281 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1282 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1283 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1284 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE55';
1285 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE55;
1286 end if;
1287 if asked_for_rec.PRICING_ATTRIBUTE56 is not null then
1288 i := px_Req_line_attr_tbl.count+1;
1289 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1290 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1291 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1292 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE56';
1293 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE56;
1294 end if;
1295 if asked_for_rec.PRICING_ATTRIBUTE57 is not null then
1296 i := px_Req_line_attr_tbl.count+1;
1297 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1298 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1299 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1300 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE57';
1301 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE57;
1302 end if;
1303 if asked_for_rec.PRICING_ATTRIBUTE58 is not null then
1304 i := px_Req_line_attr_tbl.count+1;
1305 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1306 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1307 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1308 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE58';
1309 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE58;
1310 end if;
1311 if asked_for_rec.PRICING_ATTRIBUTE59 is not null then
1312 i := px_Req_line_attr_tbl.count+1;
1313 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1314 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1315 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1316 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE59';
1317 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE59;
1318 end if;
1319
1320 if asked_for_rec.PRICING_ATTRIBUTE60 is not null then
1321 i := px_Req_line_attr_tbl.count+1;
1322 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1323 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1324 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1325 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE60';
1326 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE60;
1327 end if;
1328 if asked_for_rec.PRICING_ATTRIBUTE61 is not null then
1329 i := px_Req_line_attr_tbl.count+1;
1330 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1331 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1332 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1333 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE61';
1334 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE61;
1335 end if;
1336 if asked_for_rec.PRICING_ATTRIBUTE62 is not null then
1337 i := px_Req_line_attr_tbl.count+1;
1338 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1339 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1340 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1341 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE62';
1342 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE62;
1343 end if;
1344 if asked_for_rec.PRICING_ATTRIBUTE63 is not null then
1345 i := px_Req_line_attr_tbl.count+1;
1346 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1347 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1348 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1349 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE63';
1350 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE63;
1351 end if;
1352 if asked_for_rec.PRICING_ATTRIBUTE64 is not null then
1353 i := px_Req_line_attr_tbl.count+1;
1354 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1355 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1356 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1357 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE64';
1358 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE64;
1359 end if;
1360 if asked_for_rec.PRICING_ATTRIBUTE65 is not null then
1361 i := px_Req_line_attr_tbl.count+1;
1362 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1363 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1364 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1365 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE65';
1366 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE65;
1367 end if;
1368 if asked_for_rec.PRICING_ATTRIBUTE66 is not null then
1369 i := px_Req_line_attr_tbl.count+1;
1370 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1371 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1372 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1373 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE66';
1374 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE66;
1375 end if;
1376 if asked_for_rec.PRICING_ATTRIBUTE67 is not null then
1377 i := px_Req_line_attr_tbl.count+1;
1378 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1379 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1380 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1381 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE67';
1382 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE67;
1383 end if;
1384 if asked_for_rec.PRICING_ATTRIBUTE68 is not null then
1385 i := px_Req_line_attr_tbl.count+1;
1386 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1387 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1388 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1389 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE68';
1390 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE68;
1391 end if;
1392 if asked_for_rec.PRICING_ATTRIBUTE69 is not null then
1393 i := px_Req_line_attr_tbl.count+1;
1394 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1395 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1396 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1397 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE69';
1398 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE69;
1399 end if;
1400
1401 if asked_for_rec.PRICING_ATTRIBUTE70 is not null then
1402 i := px_Req_line_attr_tbl.count+1;
1403 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1404 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1405 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1406 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE70';
1407 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE70;
1408 end if;
1409 if asked_for_rec.PRICING_ATTRIBUTE71 is not null then
1410 i := px_Req_line_attr_tbl.count+1;
1411 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1412 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1413 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1414 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE71';
1415 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE71;
1416 end if;
1417 if asked_for_rec.PRICING_ATTRIBUTE72 is not null then
1418 i := px_Req_line_attr_tbl.count+1;
1419 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1420 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1421 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1422 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE72';
1423 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE72;
1424 end if;
1425 if asked_for_rec.PRICING_ATTRIBUTE73 is not null then
1426 i := px_Req_line_attr_tbl.count+1;
1427 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1428 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1429 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1430 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE73';
1431 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE73;
1432 end if;
1433 if asked_for_rec.PRICING_ATTRIBUTE74 is not null then
1434 i := px_Req_line_attr_tbl.count+1;
1435 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1436 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1437 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1438 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE74';
1439 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE74;
1440 end if;
1441 if asked_for_rec.PRICING_ATTRIBUTE75 is not null then
1442 i := px_Req_line_attr_tbl.count+1;
1443 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1444 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1445 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1446 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE75';
1447 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE75;
1448 end if;
1449 if asked_for_rec.PRICING_ATTRIBUTE76 is not null then
1450 i := px_Req_line_attr_tbl.count+1;
1451 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1452 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1453 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1454 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE76';
1455 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE76;
1456 end if;
1457 if asked_for_rec.PRICING_ATTRIBUTE77 is not null then
1458 i := px_Req_line_attr_tbl.count+1;
1459 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1460 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1461 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1462 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE77';
1463 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE77;
1464 end if;
1465 if asked_for_rec.PRICING_ATTRIBUTE78 is not null then
1466 i := px_Req_line_attr_tbl.count+1;
1467 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1468 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1469 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1470 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE78';
1471 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE78;
1472 end if;
1473 if asked_for_rec.PRICING_ATTRIBUTE79 is not null then
1474 i := px_Req_line_attr_tbl.count+1;
1475 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1476 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1477 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1478 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE79';
1479 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE79;
1480 end if;
1481
1482 if asked_for_rec.PRICING_ATTRIBUTE80 is not null then
1483 i := px_Req_line_attr_tbl.count+1;
1484 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1485 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1486 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1487 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE80';
1488 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE80;
1489 end if;
1490 if asked_for_rec.PRICING_ATTRIBUTE81 is not null then
1491 i := px_Req_line_attr_tbl.count+1;
1492 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1493 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1494 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1495 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE81';
1496 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE81;
1497 end if;
1498 if asked_for_rec.PRICING_ATTRIBUTE82 is not null then
1499 i := px_Req_line_attr_tbl.count+1;
1500 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1501 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1502 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1503 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE82';
1504 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE82;
1505 end if;
1506 if asked_for_rec.PRICING_ATTRIBUTE83 is not null then
1507 i := px_Req_line_attr_tbl.count+1;
1508 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1509 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1510 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1511 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE83';
1512 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE83;
1513 end if;
1514 if asked_for_rec.PRICING_ATTRIBUTE84 is not null then
1515 i := px_Req_line_attr_tbl.count+1;
1516 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1517 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1518 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1519 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE84';
1520 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE84;
1521 end if;
1522 if asked_for_rec.PRICING_ATTRIBUTE85 is not null then
1523 i := px_Req_line_attr_tbl.count+1;
1524 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1525 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1526 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1527 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE85';
1528 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE85;
1529 end if;
1530 if asked_for_rec.PRICING_ATTRIBUTE86 is not null then
1531 i := px_Req_line_attr_tbl.count+1;
1532 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1533 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1534 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1535 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE86';
1536 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE86;
1537 end if;
1538 if asked_for_rec.PRICING_ATTRIBUTE87 is not null then
1539 i := px_Req_line_attr_tbl.count+1;
1540 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1541 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1542 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1543 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE87';
1544 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE87;
1545 end if;
1546 if asked_for_rec.PRICING_ATTRIBUTE88 is not null then
1547 i := px_Req_line_attr_tbl.count+1;
1548 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1549 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1550 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1551 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE88';
1552 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE88;
1553 end if;
1554 if asked_for_rec.PRICING_ATTRIBUTE89 is not null then
1555 i := px_Req_line_attr_tbl.count+1;
1556 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1557 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1558 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1559 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE89';
1560 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE89;
1561 end if;
1562
1563 if asked_for_rec.PRICING_ATTRIBUTE90 is not null then
1564 i := px_Req_line_attr_tbl.count+1;
1565 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1566 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1567 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1568 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE90';
1569 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE90;
1570 end if;
1571 if asked_for_rec.PRICING_ATTRIBUTE91 is not null then
1572 i := px_Req_line_attr_tbl.count+1;
1573 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1574 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1575 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1576 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE91';
1577 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE91;
1578 end if;
1579 if asked_for_rec.PRICING_ATTRIBUTE92 is not null then
1580 i := px_Req_line_attr_tbl.count+1;
1581 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1582 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1583 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1584 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE92';
1585 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE92;
1586 end if;
1587 if asked_for_rec.PRICING_ATTRIBUTE93 is not null then
1588 i := px_Req_line_attr_tbl.count+1;
1589 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1590 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1591 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1592 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE93';
1593 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE93;
1594 end if;
1595 if asked_for_rec.PRICING_ATTRIBUTE94 is not null then
1596 i := px_Req_line_attr_tbl.count+1;
1597 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1598 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1599 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1600 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE94';
1601 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE94;
1602 end if;
1603 if asked_for_rec.PRICING_ATTRIBUTE95 is not null then
1604 i := px_Req_line_attr_tbl.count+1;
1605 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1606 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1607 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1608 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE95';
1609 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE95;
1610 end if;
1611 if asked_for_rec.PRICING_ATTRIBUTE96 is not null then
1612 i := px_Req_line_attr_tbl.count+1;
1613 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1614 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1615 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1616 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE96';
1617 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE96;
1618 end if;
1619 if asked_for_rec.PRICING_ATTRIBUTE97 is not null then
1620 i := px_Req_line_attr_tbl.count+1;
1621 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1622 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1623 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1624 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE97';
1625 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE97;
1626 end if;
1627 if asked_for_rec.PRICING_ATTRIBUTE98 is not null then
1628 i := px_Req_line_attr_tbl.count+1;
1629 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1630 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1631 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1632 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE98';
1633 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE98;
1634 end if;
1635 if asked_for_rec.PRICING_ATTRIBUTE99 is not null then
1636 i := px_Req_line_attr_tbl.count+1;
1637 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1638 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1639 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1640 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE99';
1641 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=asked_for_rec.PRICING_ATTRIBUTE99;
1642 end if;
1643 if asked_for_rec.PRICING_ATTRIBUTE100 is not null then
1644 i := px_Req_line_attr_tbl.count+1;
1645 px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1646 px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1647 px_Req_line_attr_tbl(i).pricing_context := asked_for_rec.pricing_context;
1648 px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE100';
1649 px_Req_line_attr_tbl(i).Pricing_Attr_Value_From:=asked_for_rec.PRICING_ATTRIBUTE100;
1650 end if;
1651
1652
1653
1654
1655
1656 else -- Copy the Qualifiers
1657 G_STMT_NO := 'Append_asked_for#20';
1658 if asked_for_rec.PRICING_ATTRIBUTE1 is not null and asked_for_rec.PRICING_ATTRIBUTE2 is null then -- Promotion
1659 i := px_Req_line_attr_Tbl.count+1;
1660 px_Req_line_attr_Tbl(i).Line_Index := p_Line_Index;
1661 px_Req_line_attr_Tbl(i).Validated_Flag := nvl(asked_for_rec.Override_Flag,'N');
1662 px_Req_line_attr_Tbl(i).pricing_context := asked_for_rec.pricing_context;
1663 px_Req_line_attr_Tbl(i).Pricing_Attribute := 'QUALIFIER_ATTRIBUTE1';
1664 px_Req_line_attr_Tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE1;
1665 end if;
1666 if asked_for_rec.PRICING_ATTRIBUTE2 is not null then --Deal Component
1667 i := px_Req_line_attr_Tbl.count+1;
1668 px_Req_line_attr_Tbl(i).Line_Index := p_Line_Index;
1669 px_Req_line_attr_Tbl(i).Validated_Flag := nvl(asked_for_rec.Override_Flag,'N');
1670 px_Req_line_attr_Tbl(i).Pricing_Context := asked_for_rec.pricing_context;
1671 px_Req_line_attr_Tbl(i).Pricing_Attribute := 'QUALIFIER_ATTRIBUTE2';
1672 px_Req_line_attr_Tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE2;
1673 end if;
1674 if asked_for_rec.PRICING_ATTRIBUTE3 is not null then -- Coupons
1675 i := px_Req_line_attr_Tbl.count+1;
1676 px_Req_line_attr_Tbl(i).Line_Index := p_Line_Index;
1677 px_Req_line_attr_Tbl(i).Validated_Flag := nvl(asked_for_rec.Override_Flag,'N');
1678 px_Req_line_attr_Tbl(i).Pricing_Context := asked_for_rec.pricing_context;
1679 px_Req_line_attr_Tbl(i).Pricing_Attribute := 'QUALIFIER_ATTRIBUTE3';
1680 px_Req_line_attr_Tbl(i).Pricing_Attr_Value_From := asked_for_rec.PRICING_ATTRIBUTE3;
1681 end if;
1682
1683 end if;
1684
1685 end loop;
1686
1687 i := px_req_line_attr_tbl.first;
1688 while i is not null loop
1689 k:=k+1;
1690 IF l_debug_level > 0 THEN
1691 oe_debug_pub.add( 'POPULATE LINE ATTRS'||K||' '||PX_REQ_LINE_ATTR_TBL ( I ) .PRICING_CONTEXT , 3 ) ;
1692 END IF;
1693 IF (px_req_line_attr_tbl(I).PRICING_CONTEXT = QP_PREQ_GRP.G_ITEM_CONTEXT) THEN
1694 l_attribute_type := QP_PREQ_GRP.G_PRODUCT_TYPE;
1695 ELSIF (px_req_line_attr_tbl(I).PRICING_CONTEXT = 'MODLIST') THEN
1696 l_attribute_type := QP_PREQ_GRP.G_QUALIFIER_TYPE;
1697 ELSE
1698 l_attribute_type := QP_PREQ_GRP.G_PRICING_TYPE;
1699 END IF;
1700 G_ATTR_LINE_INDEX_tbl(k) := p_line_index; --p_header_id + nvl(p_line_id,0);
1701 IF l_debug_level > 0 THEN
1702 oe_debug_pub.add( 'LINE_INDEX:'||G_ATTR_LINE_INDEX_TBL ( K ) ) ;
1703 END IF;
1704 G_ATTR_LINE_DETAIL_INDEX_tbl(k) := NULL;
1705 G_ATTR_ATTRIBUTE_LEVEL_tbl(k) := QP_PREQ_GRP.G_LINE_LEVEL;
1706 G_ATTR_VALIDATED_FLAG_tbl(k) := px_Req_line_attr_Tbl(i).Validated_Flag; --'N';
1707 G_ATTR_ATTRIBUTE_TYPE_tbl(k) := l_attribute_type;
1708 G_ATTR_PRICING_CONTEXT_tbl(k)
1709 := px_req_line_attr_tbl(i).pricing_context;
1710 G_ATTR_PRICING_ATTRIBUTE_tbl(k)
1711 := px_req_line_attr_tbl(i).pricing_attribute;
1712 G_ATTR_APPLIED_FLAG_tbl(k) := QP_PREQ_GRP.G_LIST_NOT_APPLIED;
1713 G_ATTR_PRICING_STATUS_CODE_tbl(k) := QP_PREQ_GRP.G_STATUS_UNCHANGED;
1714 G_ATTR_PRICING_ATTR_FLAG_tbl (k) := QP_PREQ_GRP.G_YES;
1715 G_ATTR_LIST_HEADER_ID_tbl(k) := NULL;
1716 G_ATTR_LIST_LINE_ID_tbl(k) := NULL;
1717 G_ATTR_VALUE_FROM_tbl(k) :=px_req_line_attr_tbl(i).pricing_attr_value_from;
1718 G_ATTR_SETUP_VALUE_FROM_tbl(k):=NULL;
1719 G_ATTR_VALUE_TO_tbl(k) :=NULL;
1720 G_ATTR_SETUP_VALUE_TO_tbl(k) := NULL;
1721 G_ATTR_GROUPING_NUMBER_tbl(k) := NULL;
1722 G_ATTR_NO_QUAL_IN_GRP_tbl(k) :=NULL;
1723 G_ATTR_COMP_OPERATOR_TYPE_tbl(k):= NULL;
1724 G_ATTR_PRICING_STATUS_TEXT_tbl(k) :=NULL;
1725 G_ATTR_QUAL_PRECEDENCE_tbl(k):=NULL;
1726 G_ATTR_DATATYPE_tbl(k) := NULL;
1727 G_ATTR_QUALIFIER_TYPE_tbl(k) := NULL;
1728 G_ATTR_PRODUCT_UOM_CODE_TBL(k) := NULL;
1729 G_ATTR_EXCLUDER_FLAG_TBL(k) := NULL;
1730 G_ATTR_PRICING_PHASE_ID_TBL(k) := NULL;
1731 G_ATTR_INCOM_GRP_CODE_TBL(k):=NULL;
1732 G_ATTR_LDET_TYPE_CODE_TBL(k):=NULL;
1733 G_ATTR_MODIFIER_LEVEL_CODE_TBL(k):=NULL;
1734 G_ATTR_PRIMARY_UOM_FLAG_TBL(k):=NULL;
1735 i := px_req_line_attr_tbl.next(i);
1736 end loop;
1737 px_line_attr_index := k;
1738 IF l_debug_level > 0 THEN
1739 oe_debug_pub.add( 'EXITING OE_ORDER_PRICE_PVT.APPEND_ASKED_FOR' , 1 ) ;
1740 END IF;
1741
1742 end Append_asked_for;
1743
1744 procedure Get_the_parent_Line(
1745 p_Reference_line_Id Number
1746 , px_Line_Tbl in out nocopy OE_Order_Pub.Line_Tbl_Type
1747 , p_line_Tbl_index Number
1748 )
1749 is
1750 l_Line_Rec OE_Order_Pub.Line_Rec_Type;
1751 line_Tbl_Index pls_integer;
1752 l_line_index QP_PREQ_GRP.PLS_INTEGER_TYPE;
1753 l_line_detail_index QP_PREQ_GRP.PLS_INTEGER_TYPE;
1754 l_relationship_type_code QP_PREQ_GRP.VARCHAR_TYPE;
1755 l_related_line_index QP_PREQ_GRP.PLS_INTEGER_TYPE;
1756 l_related_line_detail_index QP_PREQ_GRP.PLS_INTEGER_TYPE;
1757 l_status_code varchar2(1);
1758 l_status_text varchar2(240);
1759 --bug 3968023 start
1760 l_set_of_books Oe_Order_Cache.Set_Of_Books_Rec_Type;
1761 l_transactional_curr_code VARCHAR2(15);
1762 l_conversion_type_code VARCHAR2(30);
1763 l_conversion_rate NUMBER;
1764 l_conversion_rate_date DATE;
1765 l_denominator NUMBER;
1766 l_numerator NUMBER;
1767 l_rate NUMBER;
1768 --bug 3968023 end
1769
1770 --
1771 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1772 --
1773 Begin
1774 G_STMT_NO := 'Get_the_parent_Line#10';
1775 IF l_debug_level > 0 THEN
1776 oe_debug_pub.add( 'ENTERING OE_ORDER_PRICE_PVT.GET_THE_PARENT_LINE' , 1 ) ;
1777 END IF;
1778 line_Tbl_Index := px_Line_Tbl.First;
1779 While line_Tbl_Index is not null loop
1780 If px_Line_Tbl(line_Tbl_Index).line_Id = p_Reference_line_Id Then
1781 Exit;
1782 End If;
1783 line_Tbl_Index := px_Line_Tbl.Next(line_Tbl_Index);
1784 End Loop;
1785
1786 G_STMT_NO := 'Get_the_parent_Line#20';
1787 If line_Tbl_Index is null Then
1788 -- Parent Line is not found in px_line_tbl
1789 Begin
1790 line_Tbl_index := px_line_tbl.count+1;
1791
1792 Query_line(p_Reference_line_Id,L_Line_Rec );
1793 px_Line_Tbl(line_Tbl_index) := L_Line_Rec;
1794 -- Parent Line is only for info purpose, don't calculate price
1795 -- px_Line_Tbl(line_Tbl_index).calculate_price_flag := 'N';
1796 -- modified by lkxu, to be used in repricing
1797 px_Line_Tbl(line_Tbl_index).calculate_price_flag := 'X';
1798
1799 --bug 3968023 start
1800 l_set_of_books := Oe_Order_Cache.Load_Set_Of_Books;
1801
1802
1803 SELECT transactional_curr_code,
1804 conversion_type_code,
1805 conversion_rate,
1806 conversion_rate_date
1807 INTO l_transactional_curr_code,
1808 l_conversion_type_code,
1809 l_conversion_rate,
1810 l_conversion_rate_date
1811 FROM OE_ORDER_HEADERS_ALL
1812 WHERE header_id = l_line_rec.header_id;
1813
1814 IF l_debug_level > 0 THEN
1815
1816 oe_debug_pub.add('pviprana: l_transactional_curr_code is ' || l_transactional_curr_code);
1817 oe_debug_pub.add('pviprana: l_set_of_books.currency_code' || l_set_of_books.currency_code);
1818 oe_debug_pub.add('pviprana: l_conversion_type_code' || l_conversion_type_code);
1819 oe_debug_pub.add('pviprana: l_conversion_rate_date ' || l_conversion_rate_date);
1820 oe_debug_pub.add('pviprana: l_conversion_rate' || l_conversion_rate);
1821 END IF;
1822
1823 IF (nvl(l_transactional_curr_code, 'XXX') <> nvl(oe_order_pub.g_hdr.transactional_curr_code,'XXX')) THEN
1824 IF (nvl(l_transactional_curr_code, 'XXX') <> nvl(l_set_of_books.currency_code,'XXX') AND
1825 (l_conversion_type_code IS NULL OR
1826 (l_conversion_type_code= 'User' AND
1827 l_conversion_rate IS NULL))) OR
1828 (nvl(oe_order_pub.g_hdr.transactional_curr_code,'XXX') <> nvl(l_set_of_books.currency_code,'XXX') AND
1829 (oe_order_pub.g_hdr.conversion_type_code IS NULL OR
1830 (oe_order_pub.g_hdr.conversion_type_code= 'User' AND
1831 oe_order_pub.g_hdr.conversion_rate IS NULL))) THEN
1832 FND_MESSAGE.SET_NAME('ONT', 'ONT_CONV_INFO_NEEDED');
1833 FND_MESSAGE.SET_TOKEN('SERVICE_CURR', oe_order_pub.g_hdr.transactional_curr_code);
1834 FND_MESSAGE.SET_TOKEN('PARENT_CURR',l_transactional_curr_code);
1835 FND_MESSAGE.SET_TOKEN('FUNC_CURR', l_set_of_books.currency_code);
1836 OE_MSG_PUB.Add;
1837 px_Line_Tbl(line_Tbl_index).unit_list_price := null;
1838 px_Line_Tbl(line_Tbl_index).unit_list_price_per_pqty := null;
1839 ELSE
1840
1841 IF nvl(l_transactional_curr_code,'XXX') <> nvl(l_set_of_books.currency_code,'XXX') THEN
1842 IF l_debug_level > 0 THEN
1843 oe_debug_pub.add('pviprana: first conversion: conversion_type is '|| l_transactional_curr_code);
1844 END IF;
1845 gl_currency_api.convert_closest_amount
1846 ( x_from_currency => l_transactional_curr_code
1847 , x_to_currency => l_set_of_books.currency_code
1848 , x_conversion_date => nvl(l_conversion_rate_date,sysdate)
1849 , x_conversion_type => l_conversion_type_code
1850 , x_amount => l_line_rec.unit_list_price
1851 , x_user_rate => l_conversion_rate
1852 , x_max_roll_days => -1
1853 , x_converted_amount => px_Line_Tbl(line_Tbl_index).unit_list_price
1854 , x_denominator => l_denominator
1855 , x_numerator => l_numerator
1856 , x_rate => l_rate
1857 );
1858
1859 END IF;
1860
1861 IF nvl(l_set_of_books.currency_code,'XXX') <> nvl(oe_order_pub.g_hdr.transactional_curr_code,'XXX') THEN
1862 IF l_debug_level > 0 THEN
1863 oe_debug_pub.add('pviprana: second conversion: conversion_type is '|| oe_order_pub.g_hdr.conversion_type_code);
1864 END IF;
1865 gl_currency_api.convert_closest_amount
1866 ( x_from_currency => l_set_of_books.currency_code
1867 , x_to_currency => oe_order_pub.g_hdr.transactional_curr_code
1868 , x_conversion_date => nvl(oe_order_pub.g_hdr.conversion_rate_date,sysdate)
1869 , x_conversion_type => oe_order_pub.g_hdr.conversion_type_code
1870 , x_amount => px_Line_Tbl(line_Tbl_index).unit_list_price
1871 , x_user_rate => oe_order_pub.g_hdr.conversion_rate
1872 , x_max_roll_days => -1
1873 , x_converted_amount => px_Line_Tbl(line_Tbl_index).unit_list_price
1874 , x_denominator => l_denominator
1875 , x_numerator => l_numerator
1876 , x_rate => l_rate
1877 );
1878
1879 END IF;
1880 px_Line_Tbl(line_Tbl_index).unit_list_price_per_pqty := px_Line_Tbl(line_Tbl_index).unit_list_price * px_Line_Tbl(line_Tbl_index).ordered_quantity / nvl(px_Line_Tbl(line_Tbl_index).pricing_quantity,px_Line_Tbl(line_Tbl_index).ordered_quantity);
1881 IF l_debug_level > 0 THEN
1882 oe_debug_pub.add('pviprana: unit_list_price_per_pqty '||px_Line_Tbl(line_Tbl_index).unit_list_price_per_pqty );
1883 END IF;
1884 END IF;
1885 END IF;
1886
1887 --bug 3968023 end
1888
1889 Exception when No_Data_Found Then
1890 Null;
1891 WHEN OTHERS THEN
1892 IF l_debug_level > 0 THEN
1893 oe_debug_pub.add('pviprana: error while converting the parent lines unit_list_price to the service orders currency' );
1894 END IF;
1895 px_Line_Tbl(line_Tbl_index).unit_list_price := null;
1896 px_Line_Tbl(line_Tbl_index).unit_list_price_per_pqty := null;
1897
1898 End;
1899 End If;
1900
1901 BEGIN
1902 IF l_debug_level > 0 THEN
1903 oe_debug_pub.add( 'INSERT INTO RLTD LINES TBL FOR SERVICE' , 3 ) ;
1904 END IF;
1905
1906 -- Added if condition for Bug 2604056
1907
1908 IF px_Line_Tbl.EXISTS(line_Tbl_index) THEN
1909
1910 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
1911 l_line_index(1) := line_Tbl_Index; --px_line_tbl(line_tbl_index).header_id + px_line_tbl(line_tbl_index).line_id;
1912 l_line_detail_index(1) := NULL;
1913 l_relationship_type_code(1) := QP_PREQ_GRP.G_SERVICE_LINE;
1914 l_related_line_index(1) := p_line_Tbl_index; --px_line_tbl(p_line_tbl_index).header_id + px_line_tbl(p_line_tbl_index).line_id;
1915 l_related_line_detail_index(1) := NULL;
1916
1917 QP_PREQ_GRP.INSERT_RLTD_LINES2(
1918 p_LINE_INDEX => l_line_index
1919 ,p_LINE_DETAIL_INDEX => l_line_detail_index
1920 ,p_RELATIONSHIP_TYPE_CODE => l_relationship_type_code
1921 ,p_RELATED_LINE_INDEX => l_related_line_index
1922 ,p_RELATED_LINE_DETAIL_INDEX => l_related_line_detail_index
1923 ,x_status_code => l_status_code
1924 ,x_status_text => l_status_text
1925 );
1926
1927 IF l_status_code = FND_API.G_RET_STS_UNEXP_ERROR THEN
1928 oe_debug_pub.add('QP_PREQ_GRP.INSERT_RLTD_LINES2 has reported errors:'||SQLERRM);
1929 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1930 ELSIF l_status_code = FND_API.G_RET_STS_ERROR THEN
1931 oe_debug_pub.add('QP_PREQ_GRP.INSERT_RLTD_LINES2 has reported errors:'||SQLERRM);
1932 RAISE FND_API.G_EXC_ERROR;
1933 END IF;
1934 ELSE --lower than 110510
1935 INSERT INTO QP_PREQ_RLTD_LINES_TMP
1936 (LINE_INDEX,
1937 LINE_DETAIL_INDEX,
1938 RELATIONSHIP_TYPE_CODE,
1939 RELATED_LINE_INDEX,
1940 RELATED_LINE_DETAIL_INDEX,
1941 REQUEST_TYPE_CODE,
1942 PRICING_STATUS_CODE)
1943
1944 VALUES ( line_Tbl_Index /*px_line_tbl(line_tbl_index).header_id
1945 + px_line_tbl(line_tbl_index).line_id*/,
1946 NULL,
1947 QP_PREQ_GRP.G_SERVICE_LINE,
1948 p_line_tbl_index /*px_line_tbl(p_line_tbl_index).header_id
1949 + px_line_tbl(p_line_tbl_index).line_id*/,
1950 NULL,
1951 'NULL',
1952 QP_PREQ_PUB.G_STATUS_UNCHANGED
1953 );
1954 END IF;
1955 End If;
1956 EXCEPTION
1957 WHEN OTHERS THEN
1958 IF l_debug_level > 0 THEN
1959 oe_debug_pub.add( 'ERROR INSERTING'||SQLERRM , 3 ) ;
1960 END IF;
1961 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1962 END;
1963 IF l_debug_level > 0 THEN
1964 oe_debug_pub.add( 'EXITING OE_ORDER_PRICE_PVT.GET_THE_PARENT_LINE' , 1 ) ;
1965 END IF;
1966
1967 End Get_the_parent_Line;
1968
1969 procedure Get_PRG_Lines(
1970 p_line_Id Number
1971 , px_Line_Tbl in out nocopy OE_Order_Pub.Line_Tbl_Type
1972 , p_line_Tbl_index Number
1973 )
1974 is
1975 l_Line_Rec OE_Order_Pub.Line_Rec_Type;
1976 line_Tbl_Index pls_integer;
1977 Cursor prg_lines is
1978 select adj1.line_id prg_line_id, assoc.rltd_price_adj_id
1979 from oe_price_adjustments adj1,
1980 oe_price_adj_assocs assoc,
1981 oe_price_adjustments adj2
1982 where adj1.price_adjustment_id = assoc.rltd_price_adj_id AND
1983 assoc.price_adjustment_id = adj2.price_adjustment_id AND
1984 adj2.list_line_type_code = 'PRG' AND
1985 adj2.line_id = p_line_id;
1986 l_prg_line_id NUMBER;
1987 l_rltd_price_adj_id NUMBER;
1988 --
1989 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1990 --
1991 Begin
1992 G_STMT_NO := 'Get_prg_Line#10';
1993 IF l_debug_level > 0 THEN
1994 oe_debug_pub.add( 'ENTERING OE_ORDER_PRICE_PVT.GET_PRG_LINES'||P_LINE_ID , 1 ) ;
1995 END IF;
1996
1997 for i in prg_lines loop
1998 IF l_debug_level > 0 THEN
1999 oe_debug_pub.add( 'PRG LINE ID = ' || I.PRG_LINE_ID ) ;
2000 END IF;
2001 BEGIN
2002 Query_line(i.prg_line_Id,L_Line_Rec );
2003 line_Tbl_index := px_line_tbl.last + 1;
2004 --if (line_tbl_index > 3) then return;end if;
2005 px_Line_Tbl(line_Tbl_index) := L_Line_Rec;
2006 -- PRG Line is only for info purpose, don't calculate price
2007 px_Line_Tbl(line_Tbl_index).calculate_price_flag := 'N';
2008 -- modified by lkxu, to be used in repricing
2009 -- px_Line_Tbl(line_Tbl_index).calculate_price_flag := 'X';
2010 Exception when No_Data_Found Then
2011 Null;
2012 End;
2013 End LOOP;
2014
2015 IF l_debug_level > 0 THEN
2016 oe_debug_pub.add( 'EXITING OE_ORDER_PRICE_PVT.GET_PRG_LINES' , 1 ) ;
2017 END IF;
2018
2019 End Get_prg_Lines;
2020
2021 -- 3529369
2022 -- This procedure retrives the service line for the parent. The service lines will be repriced
2023 -- in the case of overriding the list price of the parent
2024 procedure Get_Service_Lines(
2025 p_line_Id Number
2026 , p_header_id Number
2027 , px_Line_Tbl in out nocopy OE_Order_Pub.Line_Tbl_Type
2028 , p_line_Tbl_index Number
2029 )
2030 is
2031 l_Line_Rec OE_Order_Pub.Line_Rec_Type;
2032 line_Tbl_Index pls_integer;
2033
2034 CURSOR service_lines is
2035 select line_id from oe_order_lines_all
2036 where
2037 service_reference_line_id=p_line_Id and
2038 service_reference_type_code='ORDER'and
2039 header_id=p_header_id and
2040 original_list_price is NULL;
2041
2042 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2043 BEGIN
2044 IF l_debug_level > 0 THEN
2045 oe_debug_pub.add( 'ENTERING OE_ORDER_PRICE_PVT.GET_SERVICE_LINES'||P_LINE_ID , 1 ) ;
2046 END IF;
2047
2048 FOR I in service_lines loop
2049 IF l_debug_level > 0 THEN
2050 oe_debug_pub.add( 'SERVICE LINE ID = ' || I.LINE_ID ) ;
2051 END IF;
2052 line_Tbl_Index := px_Line_Tbl.First;
2053
2054 While line_Tbl_Index is not null loop
2055 If px_Line_Tbl(line_Tbl_Index).line_Id = I.line_Id Then
2056 Exit;
2057 End If;
2058 line_Tbl_Index := px_Line_Tbl.Next(line_Tbl_Index);
2059 End Loop;
2060 -- Only if the service line is not already added we add it
2061 If line_Tbl_Index is null Then
2062 BEGIN
2063 Query_line(I.line_Id,L_Line_Rec );
2064 line_Tbl_index := px_line_tbl.last + 1;
2065 px_Line_Tbl(line_Tbl_index) := L_Line_Rec;
2066 Exception when No_Data_Found Then
2067 Null;
2068 End;
2069 End If;
2070 End LOOP;
2071 END Get_Service_Lines;
2072 -- 3529369
2073
2074 procedure Get_item_for_iue(px_line_rec in out nocopy OE_Order_PUB.line_rec_type)
2075 is
2076 -- This change is required since we are dropping the profile OE_ORGANIZATION -- _ID. Change made by Esha.
2077 l_org_id Number:= OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');
2078 /*l_org_id NUMBER := FND_PROFILE.Value('OE_ORGANIZATION_ID');*/
2079 l_ordered_item varchar2(300);
2080 cursor adj_cur is
2081 select modified_from from oe_price_adjustments
2082 where line_id=px_line_rec.line_id
2083 and list_line_type_code='IUE';
2084 --
2085 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2086 --
2087 begin
2088 IF l_debug_level > 0 THEN
2089 oe_debug_pub.add( 'ENTERING OE_ORDER_PRICE_PVT.GET_ITEM_FOR_IUE' , 1 ) ;
2090 END IF;
2091 For Adj_rec in Adj_cur loop
2092 -- There is an item upgrade for this line
2093 px_line_rec.inventory_item_id := to_number(Adj_rec.modified_from);
2094
2095
2096 If px_line_rec.item_identifier_type ='INT' then
2097 px_line_rec.ordered_item_id := to_number(Adj_rec.modified_from);
2098 Begin
2099 SELECT concatenated_segments
2100 INTO px_line_rec.ordered_item
2101 FROM mtl_system_items_kfv
2102 WHERE inventory_item_id = px_line_rec.inventory_item_id
2103 AND organization_id = l_org_id;
2104 Exception when no_data_found then
2105 Null;
2106 End;
2107 End If;
2108 Exit;
2109 End Loop;
2110
2111 IF l_debug_level > 0 THEN
2112 oe_debug_pub.add( 'EXITING OE_ORDER_PRICE_PVT.GET_ITEM_FOR_IUE' , 1 ) ;
2113 END IF;
2114 end Get_item_for_iue;
2115
2116
2117 /*+--------------------------------------------------------------------
2118 |Reset_All_Tbls
2119 |To Reset all pl/sql tables.
2120 +--------------------------------------------------------------------
2121 */
2122 PROCEDURE Reset_All_Tbls
2123 AS
2124 l_routine VARCHAR2(240):='QP_PREQ_GRP.Reset_All_Tbls';
2125 --
2126 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2127 --
2128 BEGIN
2129 G_LINE_INDEX_tbl.delete;
2130 G_LINE_TYPE_CODE_TBL.delete ;
2131 G_PRICING_EFFECTIVE_DATE_TBL.delete ;
2132 G_ACTIVE_DATE_FIRST_TBL.delete ;
2133 G_ACTIVE_DATE_FIRST_TYPE_TBL.delete ;
2134 G_ACTIVE_DATE_SECOND_TBL.delete ;
2135 G_ACTIVE_DATE_SECOND_TYPE_TBL.delete ;
2136 G_LINE_QUANTITY_TBL.delete ;
2137 G_LINE_UOM_CODE_TBL.delete ;
2138 G_REQUEST_TYPE_CODE_TBL.delete ;
2139 G_PRICED_QUANTITY_TBL.delete ;
2140 G_UOM_QUANTITY_TBL.delete ;
2141 G_CONTRACT_START_DATE_TBL.delete;
2142 G_CONTRACT_END_DATE_TBL.delete;
2143 G_PRICED_UOM_CODE_TBL.delete ;
2144 G_CURRENCY_CODE_TBL.delete ;
2145 G_UNIT_PRICE_TBL.delete ;
2146 G_PERCENT_PRICE_TBL.delete ;
2147 G_ADJUSTED_UNIT_PRICE_TBL.delete ;
2148 G_PROCESSED_FLAG_TBL.delete ;
2149 G_PRICE_FLAG_TBL.delete ;
2150 G_LINE_ID_TBL.delete ;
2151 G_PROCESSING_ORDER_TBL.delete ;
2152 G_ROUNDING_FLAG_TBL.delete;
2153 G_ROUNDING_FACTOR_TBL.delete ;
2154 G_PRICING_STATUS_CODE_TBL.delete ;
2155 G_PRICING_STATUS_TEXT_TBL.delete ;
2156
2157 G_ATTR_LINE_INDEX_tbl.delete;
2158 G_ATTR_ATTRIBUTE_LEVEL_tbl.delete;
2159 G_ATTR_VALIDATED_FLAG_tbl.delete;
2160 G_ATTR_ATTRIBUTE_TYPE_tbl.delete;
2161 G_ATTR_PRICING_CONTEXT_tbl.delete;
2162 G_ATTR_PRICING_ATTRIBUTE_tbl.delete;
2163 G_ATTR_APPLIED_FLAG_tbl.delete;
2164 G_ATTR_PRICING_STATUS_CODE_tbl.delete;
2165 G_ATTR_PRICING_ATTR_FLAG_tbl.delete;
2166 G_ATTR_LIST_HEADER_ID_tbl.delete;
2167 G_ATTR_LIST_LINE_ID_tbl.delete;
2168 G_ATTR_VALUE_FROM_tbl.delete;
2169 G_ATTR_SETUP_VALUE_FROM_tbl.delete;
2170 G_ATTR_VALUE_TO_tbl.delete;
2171 G_ATTR_SETUP_VALUE_TO_tbl.delete;
2172 G_ATTR_GROUPING_NUMBER_tbl.delete;
2173 G_ATTR_NO_QUAL_IN_GRP_tbl.delete;
2174 G_ATTR_COMP_OPERATOR_TYPE_tbl.delete;
2175 G_ATTR_VALIDATED_FLAG_tbl.delete;
2176 G_ATTR_APPLIED_FLAG_tbl.delete;
2177 G_ATTR_PRICING_STATUS_CODE_tbl.delete;
2178 G_ATTR_PRICING_STATUS_TEXT_tbl.delete;
2179 G_ATTR_QUAL_PRECEDENCE_tbl.delete;
2180 G_ATTR_DATATYPE_tbl.delete;
2181 G_ATTR_PRICING_ATTR_FLAG_tbl.delete ;
2182 G_ATTR_QUALIFIER_TYPE_tbl.delete;
2183 G_ATTR_PRODUCT_UOM_CODE_TBL.delete;
2184 G_ATTR_EXCLUDER_FLAG_TBL.delete;
2185 G_ATTR_PRICING_PHASE_ID_TBL.delete;
2186 G_ATTR_INCOM_GRP_CODE_TBL.delete;
2187 G_ATTR_LDET_TYPE_CODE_TBL.delete;
2188 G_ATTR_MODIFIER_LEVEL_CODE_TBL.delete;
2189 G_ATTR_PRIMARY_UOM_FLAG_TBL.delete;
2190 G_CHARGE_PERIODICITY_CODE_TBL.delete;
2191 G_ADDED_PARENT_TBL.delete;
2192 EXCEPTION
2193 WHEN OTHERS THEN
2194 IF l_debug_level > 0 THEN
2195 oe_debug_pub.add( L_ROUTINE||': '||SQLERRM , 1 ) ;
2196 END IF;
2197 END reset_all_tbls;
2198
2199 PROCEDURE UPDATE_GLOBAL(p_old_line_rec IN OE_ORDER_PUB.LINE_REC_TYPE,
2200 p_line_rec IN OE_ORDER_PUB.LINE_REC_TYPE)
2201 IS
2202 l_notify_index NUMBER;
2203 l_return_status VARCHAR2(1);
2204 l_line_rec OE_ORDER_PUB.LINE_REC_TYPE;
2205 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2206 --
2207 BEGIN
2208 l_line_rec:= p_line_rec;
2209 --need to update global picture when line changes
2210 IF l_debug_level > 0 THEN
2211 oe_debug_pub.add(' Calling update_global_picture to register line changes');
2212 END IF;
2213
2214 l_notify_index := NULL;
2215
2216 OE_ORDER_UTIL.Update_Global_Picture(p_Upd_New_Rec_If_Exists =>False,
2217 p_header_id=>l_line_rec.header_id,
2218 --p_old_line_rec=>p_old_line_rec,
2219 --p_line_rec =>p_line_rec,
2220 p_line_id => l_line_rec.line_id,
2221 x_index => l_notify_index,
2222 x_return_status => l_return_status);
2223
2224
2225 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
2226 oe_debug_pub.add(' Update_global_price called from oe_order_price_pvt.populate_line_tbl reports errors');
2227 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2228 END IF;
2229
2230 IF l_notify_index IS NOT NULL THEN
2231 IF l_debug_level > 0 THEN
2232 oe_debug_pub.add(' Global index obtained is:'||l_notify_index);
2233 oe_debug_pub.add(' Global OLD_LINE USP BEFORE ASSIGNMENT:'||OE_ORDER_UTIL.g_old_line_tbl(l_notify_index).unit_selling_price);
2234 oe_debug_pub.add(' p_old_line_rec.usp:'||p_old_line_rec.unit_selling_price);
2235 oe_debug_pub.add(' new line rec.usp:'||l_line_rec.unit_selling_price);
2236 END IF;
2237 --update Global Picture directly
2238 --OE_ORDER_UTIL.g_old_line_tbl(l_notify_index):= p_old_line_rec;
2239
2240 --As per HASHRAF 12/01/03 05:58 pm in bug 2920261
2241 --it could potentially undo bug 2806544
2242
2243 IF OE_ORDER_UTIL.g_line_tbl.exists(l_notify_index) Then
2244 If OE_ORDER_UTIL.g_line_tbl(l_notify_index).flow_status_code IS NULL then
2245 --for the create case
2246 OE_ORDER_UTIL.g_line_tbl(l_notify_index):= OE_ORDER_UTIL.g_old_line_tbl(l_notify_index);
2247 End If;
2248 Else
2249 --The record does not exists at all in g_line_tbl, creating one
2250 OE_ORDER_UTIL.g_line_tbl(l_notify_index):= OE_ORDER_UTIL.g_old_line_tbl(l_notify_index);
2251 End If;
2252
2253 OE_ORDER_UTIL.g_line_tbl(l_notify_index).unit_selling_price:=l_line_rec.unit_selling_price;
2254 OE_ORDER_UTIL.g_line_tbl(l_notify_index).unit_list_price :=l_line_rec.unit_list_price;
2255 OE_ORDER_UTIL.g_line_tbl(l_notify_index).unit_selling_price_per_pqty:=l_line_rec.unit_selling_price_per_pqty;
2256 OE_ORDER_UTIL.g_line_tbl(l_notify_index).unit_list_price_per_pqty:=l_line_rec.unit_list_price_per_pqty;
2257 OE_ORDER_UTIL.g_line_tbl(l_notify_index).pricing_quantity :=l_line_rec.pricing_quantity;
2258 OE_ORDER_UTIL.g_line_tbl(l_notify_index).pricing_quantity_uom :=l_line_rec.pricing_quantity_uom;
2259 OE_ORDER_UTIL.g_line_tbl(l_notify_index).price_list_id := l_line_rec.price_list_id;
2260 OE_ORDER_UTIL.g_line_tbl(l_notify_index).unit_list_percent :=l_line_rec.unit_list_percent;
2261 OE_ORDER_UTIL.g_line_tbl(l_notify_index).unit_percent_base_price :=l_line_rec.unit_percent_base_price;
2262 OE_ORDER_UTIL.g_line_tbl(l_notify_index).unit_selling_percent :=l_line_rec.unit_selling_percent;
2263 OE_ORDER_UTIL.g_line_tbl(l_notify_index).operation :=l_line_rec.operation;
2264 --AS per Jyothi Narayan April 23 11:40, we need to assign line_id as well when it is a direct call from booking api
2265
2266 OE_ORDER_UTIL.g_line_tbl(l_notify_index).line_id :=nvl(OE_ORDER_UTIL.g_line_tbl(l_notify_index).line_id,l_line_rec.line_id);
2267
2268
2269
2270 IF l_debug_level > 0 THEN
2271 oe_debug_pub.add('Global picture OLD USP is:'||OE_ORDER_UTIL.G_OLD_LINE_TBL(L_NOTIFY_INDEX).UNIT_SELLING_PRICE);
2272 oe_debug_pub.add('Global picture NEW USP is:'||OE_ORDER_UTIL.G_LINE_TBL(L_NOTIFY_INDEX).UNIT_SELLING_PRICE) ;
2273 oe_debug_pub.add('Global picture NEW OPR is:'||OE_ORDER_UTIL.G_LINE_TBL(L_NOTIFY_INDEX).operation);
2274 oe_debug_pub.add('Global picture OLD QTY is:'||OE_ORDER_UTIL.G_OLD_LINE_TBL(L_NOTIFY_INDEX).ordered_quantity);
2275 oe_debug_pub.add('Global picture NEW QTY is:'||OE_ORDER_UTIL.G_LINE_TBL(L_NOTIFY_INDEX).ordered_quantity);
2276 END IF;
2277 END IF;
2278
2279 END;
2280
2281
2282 PROCEDURE POPULATE_LINE_TBL(
2283 px_line_tbl IN OUT NOCOPY OE_ORDER_PUB.LINE_TBL_TYPE
2284 )
2285 IS
2286 lx_old_line_price_tbl OE_ORDER_PUB.LINE_TBL_TYPE;
2287 l_control_rec OE_GLOBALS.Control_Rec_Type;
2288 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
2289 l_call_lines BOOLEAN := FALSE;
2290 l_check_sec BOOLEAN := FALSE;
2291 l_line_index NUMBER;
2292 l_line_rec OE_ORDER_PUB.LINE_REC_TYPE;
2293 --
2294 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2295 --
2296 l_validate_desc_flex varchar2(1) := 'N';
2297 Begin
2298
2299 IF l_debug_level > 0 THEN
2300 oe_debug_pub.add( 'INSIDE POPULATE_LINE_TBL:'||PX_LINE_TBL.COUNT , 3 ) ;
2301 END IF;
2302 l_line_index := px_line_tbl.first;
2303 while l_line_index is not null loop
2304 l_line_rec := px_line_tbl(l_line_index);
2305 oe_debug_pub.add('Ord Qty:'||l_line_rec.ordered_quantity, 3 ) ;
2306 if l_line_rec.ordered_quantity <> 0 then --bug 2823498
2307 BEGIN
2308 select /*+ INDEX(lines qp_preq_lines_tmp_n1) */
2309 nvl(lines.order_uom_selling_price, lines.ADJUSTED_UNIT_PRICE * nvl(lines.priced_quantity,l_line_rec.ordered_quantity)/l_line_rec.ordered_quantity)
2310 , nvl(lines.line_unit_price, lines.UNIT_PRICE * nvl(lines.priced_quantity,l_line_rec.ordered_quantity)/l_line_rec.ordered_quantity)
2311 , lines.ADJUSTED_UNIT_PRICE
2312 , lines.UNIT_PRICE
2313 , decode(lines.priced_quantity,-99999,l_line_rec.ordered_quantity
2314 ,lines.priced_quantity)
2315 , decode(lines.priced_quantity,-99999,l_line_rec.order_quantity_uom
2316 ,lines.priced_uom_code)
2317 , decode(lines.price_list_header_id,-9999,NULL,lines.price_list_header_id) --Bug#2830609
2318 , nvl(lines.percent_price, NULL)
2319 , nvl(lines.parent_price, NULL)
2320 , decode(lines.parent_price, NULL, 0, 0, 0,
2321 lines.adjusted_unit_price/lines.parent_price)
2322 INTO
2323 l_line_rec.UNIT_SELLING_PRICE
2324 , l_line_rec.UNIT_LIST_PRICE
2325 , l_line_rec.UNIT_SELLING_PRICE_PER_PQTY
2326 , l_line_rec.UNIT_LIST_PRICE_PER_PQTY
2327 , l_line_rec.PRICING_QUANTITY
2328 , l_line_rec.PRICING_QUANTITY_UOM
2329 , l_line_rec.PRICE_LIST_ID
2330 , l_line_rec.UNIT_LIST_PERCENT
2331 , l_line_rec.UNIT_PERCENT_BASE_PRICE
2332 , l_line_rec.UNIT_SELLING_PERCENT
2333 from qp_preq_lines_tmp lines
2334 where lines.line_id=l_line_rec.line_id
2335 and lines.line_type_code='LINE'
2336 and lines.process_status <> 'NOT_VALID'
2337 and lines.pricing_status_code in
2338 (QP_PREQ_GRP.G_STATUS_GSA_VIOLATION,
2339 QP_PREQ_GRP.G_STATUS_UPDATED);
2340
2341 IF l_debug_level > 0 THEN
2342 oe_debug_pub.add( 'UNIT_SELLING_PRICE:'||L_LINE_REC.UNIT_SELLING_PRICE||' FOR LINE:'||L_LINE_REC.LINE_ID , 3 ) ;
2343 oe_debug_pub.add(' QTY:'||l_line_rec.ordered_quantity,3);
2344 oe_debug_pub.add( 'SCHEDULE_DATE'||L_LINE_REC.SCHEDULE_SHIP_DATE||':'||L_LINE_REC.SCHEDULE_ARRIVAL_DATE ) ;
2345 oe_debug_pub.add('New price list id : ' ||l_line_rec.price_list_id);
2346 oe_debug_pub.add('Old price list id : ' ||px_line_tbl(l_line_index).price_list_id);
2347 END IF;
2348
2349 --bug 3702538
2350 If nvl(l_line_rec.price_list_id,-9999) <> nvl(px_line_tbl(l_line_index).price_list_id,-9999) THEN
2351 l_call_lines := TRUE;
2352 IF l_line_rec.operation NOT IN (OE_GLOBALS.G_OPR_CREATE, OE_GLOBALS.G_OPR_INSERT) THEN
2353 l_check_sec := TRUE;
2354 END IF;
2355 End If;
2356 --bug 3702538
2357
2358 EXCEPTION
2359 WHEN NO_DATA_FOUND THEN
2360 IF l_debug_level > 0 THEN
2361 oe_debug_pub.add( 'LINE '||L_LINE_REC.LINE_ID||' DID NOT GET NEW PRICE' ) ;
2362 END IF;
2363 END;
2364
2365 --UPDATE_GLOBAL(p_old_line_rec=>px_line_tbl(l_line_index),p_line_rec=>l_line_rec);
2366
2367 --bug 3702538
2368 lx_old_line_price_tbl(l_line_index) := px_line_tbl(l_line_index);
2369 --bug 3702538
2370 px_line_tbl(l_line_index) := l_line_rec;
2371 --For Bug# 7695217
2372 oe_debug_pub.add('7695217 - l_line_rec.line_id - ' || l_line_rec.line_id);
2373 IF l_line_rec.line_id < 0 THEN
2374 l_call_lines := FALSE;
2375 END IF;
2376 --End of Bug# 7695217
2377 end if; --bug 2823498
2378 l_line_index := px_line_tbl.next(l_line_index);
2379
2380 END LOOP;
2381 --bug 3702538
2382 IF l_call_lines THEN
2383 l_control_rec.default_attributes := TRUE;
2384 l_control_rec.controlled_operation := TRUE;
2385 l_control_rec.change_attributes := TRUE;
2386 l_control_rec.check_security := l_check_sec;
2387 l_control_rec.validate_entity := FALSE;
2388 l_control_rec.write_to_DB := FALSE;
2389 l_control_rec.process_entity := OE_GLOBALS.G_ENTITY_LINE;
2390 l_control_rec.process := FALSE;
2391
2392 OE_GLOBALS.G_PRICING_RECURSION := 'Y';
2393
2394 IF l_debug_level > 0 THEN
2395 oe_debug_pub.add( 'validate desc flex:'||OE_GLOBALS.g_validate_desc_flex) ;
2396 END IF;
2397 l_validate_desc_flex := OE_GLOBALS.g_validate_desc_flex;
2398 OE_GLOBALS.g_validate_desc_flex := 'N';
2399 OE_Order_Pvt.Lines
2400 ( p_validation_level => FND_API.G_VALID_LEVEL_FULL
2401 ,p_control_rec => l_control_rec
2402 ,p_x_line_tbl => px_line_tbl
2403 ,p_x_old_line_tbl => lx_old_line_price_tbl
2404 ,x_return_status => l_return_status);
2405
2406 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2407 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2408 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2409 RAISE FND_API.G_EXC_ERROR;
2410 END IF;
2411 OE_GLOBALS.g_validate_desc_flex := l_validate_desc_flex;
2412 IF l_debug_level > 0 THEN
2413 oe_debug_pub.add( 'reset validate desc flex:'||OE_GLOBALS.g_validate_desc_flex) ;
2414 END IF;
2415 OE_GLOBALS.G_PRICING_RECURSION := 'N';
2416 END IF;
2417 --bug 3702538
2418 END POPULATE_LINE_TBL;
2419
2420 PROCEDURE SECURITY_AND_GLOBAL_PICTURE(
2421 px_line_tbl IN OUT NOCOPY OE_ORDER_PUB.LINE_TBL_TYPE,
2422 p_write_to_db IN BOOLEAN
2423 )
2424 IS
2425 l_line_index NUMBER;
2426 l_line_rec OE_ORDER_PUB.LINE_REC_TYPE;
2427 l_old_line_rec OE_ORDER_PUB.LINE_REC_TYPE;
2428 l_sec_result varchar2(1);
2429 l_return_status varchar2(1);
2430 --
2431 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2432 --
2433 l_old_change_reason varchar2(30);
2434 l_old_change_comments varchar2(2000);
2435 Begin
2436 IF l_debug_level > 0 THEN
2437 oe_debug_pub.add( 'INSIDE SECURITY_AND_GLOBAL_PICTURE' , 3 ) ;
2438 END IF;
2439
2440 l_line_index := px_line_tbl.first;
2441 while l_line_index is not null loop
2442 l_line_rec := px_line_tbl(l_line_index);
2443 l_old_line_rec := l_line_rec;
2444 IF l_debug_level > 0 THEN
2445 oe_debug_pub.add( 'LINE ID'||L_LINE_REC.LINE_ID ) ;
2446 END IF;
2447 -- bug 4866684 setting the msg context
2448 OE_MSG_PUB.set_msg_context
2449 ( p_entity_code => 'LINE'
2450 ,p_entity_id => l_line_rec.line_id
2451 ,p_header_id => l_line_rec.header_id
2452 ,p_line_id => l_line_rec.line_id
2453 ,p_orig_sys_document_ref => l_line_rec.orig_sys_document_ref
2454 ,p_orig_sys_document_line_ref => l_line_rec.orig_sys_line_ref
2455 ,p_source_document_id => l_line_rec.source_document_id
2456 ,p_source_document_line_id => l_line_rec.source_document_line_id
2457 ,p_order_source_id => l_line_rec.order_source_id
2458 ,p_source_document_type_id => l_line_rec.source_document_type_id);
2459 BEGIN
2460 select /*+ INDEX(lines qp_preq_lines_tmp_n1) */
2461 nvl(lines.order_uom_selling_price, lines.ADJUSTED_UNIT_PRICE * nvl(lines.priced_quantity,l_line_rec.ordered_quantity)/l_line_rec.ordered_quantity)
2462 , nvl(lines.line_unit_price, lines.UNIT_PRICE * lines.priced_quantity/l_line_rec.ordered_quantity)
2463 , lines.ADJUSTED_UNIT_PRICE
2464 , lines.UNIT_PRICE
2465 , decode(lines.priced_quantity,-99999,l_line_rec.ordered_quantity
2466 ,lines.priced_quantity)
2467 , decode(lines.priced_quantity,-99999,l_line_rec.order_quantity_uom
2468 ,lines.priced_uom_code)
2469 , decode(lines.price_list_header_id,-9999,NULL,lines.price_list_header_id) --Bug#2830609
2470 , nvl(lines.percent_price, NULL)
2471 , nvl(lines.parent_price, NULL)
2472 , decode(lines.parent_price, NULL, 0, 0, 0,
2473 lines.adjusted_unit_price/lines.parent_price)
2474 INTO
2475 l_line_rec.UNIT_SELLING_PRICE
2476 , l_line_rec.UNIT_LIST_PRICE
2477 , l_line_rec.UNIT_SELLING_PRICE_PER_PQTY
2478 , l_line_rec.UNIT_LIST_PRICE_PER_PQTY
2479 , l_line_rec.PRICING_QUANTITY
2480 , l_line_rec.PRICING_QUANTITY_UOM
2481 , l_line_rec.PRICE_LIST_ID
2482 , l_line_rec.UNIT_LIST_PERCENT
2483 , l_line_rec.UNIT_PERCENT_BASE_PRICE
2484 , l_line_rec.UNIT_SELLING_PERCENT
2485 from qp_preq_lines_tmp lines
2486 where lines.line_id=l_line_rec.line_id
2487 and lines.line_type_code='LINE'
2488 and l_line_rec.ordered_quantity <> 0
2489 and lines.process_status <> 'NOT_VALID'
2490 and l_line_rec.open_flag <> 'N'
2491 and lines.pricing_status_code in (QP_PREQ_GRP.G_STATUS_GSA_VIOLATION,
2492 QP_PREQ_GRP.G_STATUS_UPDATED);
2493
2494 IF (l_line_rec.operation IS NULL
2495 OR l_line_rec.operation= FND_API.G_MISS_CHAR) THEN
2496 l_line_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
2497 END IF;
2498 IF l_debug_level > 0 THEN
2499 oe_debug_pub.add( 'LINE PRICE'||L_LINE_REC.UNIT_SELLING_PRICE||L_LINE_REC.OPERATION||' '||L_OLD_LINE_REC.OPERATION , 3 ) ;
2500 END IF;
2501
2502 --IF (NOT OE_GLOBALS.G_HEADER_CREATED ) THEN
2503 IF l_debug_level > 0 THEN
2504 oe_debug_pub.add(' Checking Security');
2505 END IF;
2506
2507 --bug 2823794, the security api doesn't like delete operation.
2508 --it will raise error if a delete operation is passed.
2509 --therefore we check, if delete or create operation, do not call the security api.
2510
2511 IF l_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
2512
2513 -- bug 3554060
2514 l_old_change_reason := l_line_rec.change_reason;
2515 l_old_change_comments := l_line_rec.change_comments;
2516 l_line_rec.change_reason := 'SYSTEM';
2517 l_line_rec.change_comments := 'REPRICING';
2518 --end bug 3554060
2519 OE_Line_Security.Attributes
2520 (p_line_rec => l_line_rec
2521 , p_old_line_rec => l_old_line_rec
2522 , x_result => l_sec_result
2523 , x_return_status => l_return_status
2524 );
2525
2526 -- Adding code to log versioning/audit request
2527 OE_Line_Util.Version_Audit_Process(p_x_line_rec => l_line_rec,
2528 p_old_line_rec => l_old_line_rec);
2529
2530 -- bug 3554060
2531 l_line_rec.change_reason := l_old_change_reason;
2532 l_line_rec.change_comments := l_old_change_comments;
2533 -- end bug 3554060
2534 END IF;
2535
2536 --END IF;
2537 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2538 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2539 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2540 RAISE FND_API.G_EXC_ERROR;
2541 END IF;
2542
2543
2544 -- if operation on any attribute is constrained
2545 IF l_sec_result = OE_PC_GLOBALS.YES THEN
2546 RAISE FND_API.G_EXC_ERROR;
2547 END IF;
2548
2549 IF l_debug_level > 0 THEN
2550 oe_debug_pub.add( 'AFTER CHECK_SECURITY'||L_SEC_RESULT ) ;
2551 oe_debug_Pub.add( 'BEFORE UPDATE GLOBAL');
2552 END IF;
2553
2554 IF p_write_to_db THEN
2555 UPDATE_GLOBAL(p_old_line_rec=>l_old_line_rec,p_line_rec=>l_line_rec);
2556 END IF;
2557
2558 IF l_debug_level > 0 THEN
2559 oe_debug_pub.add(' AFTER UPDATE GLOBAL');
2560 oe_debug_pub.add('old SP :'||l_old_line_rec.unit_selling_price);
2561 oe_debug_pub.add('new SP :'||l_line_rec.unit_selling_price);
2562 oe_debug_pub.add('order_source_id:'||l_line_rec.order_source_id);
2563 oe_debug_pub.add('xml_transaction_type_code:'||l_line_rec.xml_transaction_type_code);
2564 END IF;
2565
2566 -- Moved to OE_ACKNOWLEDGMENT_PUB as part of 3417899 and 3412458
2567 /* IF l_line_rec.unit_selling_price <> l_old_line_rec.unit_selling_price
2568 AND OE_Code_Control.code_release_level >= '110510'
2569 AND NVL(FND_PROFILE.VALUE('ONT_3A7_RESPONSE_REQUIRED'), 'N') = 'Y'
2570 AND l_line_rec.order_source_id = OE_Acknowledgment_Pub.G_XML_ORDER_SOURCE_ID
2571 AND nvl(l_line_rec.xml_transaction_type_code, OE_Acknowledgment_Pub.G_TRANSACTION_CSO) = OE_Acknowledgment_Pub.G_TRANSACTION_CSO
2572 AND nvl(l_line_rec.booked_flag, 'X') = 'Y'
2573 AND l_line_rec.ordered_quantity <> 0 THEN
2574 IF l_debug_level > 0 THEN
2575 oe_debug_pub.add( 'calling OE_Acknowlegment_PUB.apply_3a7_hold', 2 ) ;
2576 END IF;
2577 OE_Acknowledgment_PUB.Apply_3A7_Hold(
2578 p_header_id => l_line_rec.header_id
2579 , p_line_id => l_line_rec.line_id
2580 , p_sold_to_org_id => l_line_rec.sold_to_org_id
2581 , x_return_status => l_return_status);
2582 IF l_debug_level > 0 THEN
2583 oe_debug_pub.add( 'Return status after call to apply_3a7_hold:' || l_return_status, 2 ) ;
2584 END IF;
2585 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2586 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2587 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2588 RAISE FND_API.G_EXC_ERROR;
2589 END IF;
2590 END IF;*/
2591 px_line_tbl(l_line_index) := l_line_rec;
2592
2593 EXCEPTION
2594 WHEN NO_DATA_FOUND THEN
2595 IF l_debug_level > 0 THEN
2596 oe_debug_pub.add( 'LINE '||L_LINE_REC.LINE_ID||' DID NOT GET NEW PRICE' ) ;
2597 END IF;
2598 END;
2599
2600 l_line_index := px_line_tbl.next(l_line_index);
2601 END LOOP;
2602
2603 IF l_debug_level > 0 THEN
2604 oe_debug_pub.add('Leaving SERURITY_AND_GLOBAL_PICTURE');
2605 END IF;
2606
2607 END SECURITY_AND_GLOBAL_PICTURE;
2608
2609 PROCEDURE CHECK_GSA
2610 IS
2611 l_GSA_Enabled_Flag Varchar2(30) := FND_PROFILE.VALUE('QP_VERIFY_GSA');
2612 --l_gsa_violation_action Varchar2(30) := nvl(fnd_profile.value('ONT_GSA_VIOLATION_ACTION'), 'WARNING');
2613 l_gsa_violation_action Varchar2(30) := nvl(oe_sys_parameters.value('ONT_GSA_VIOLATION_ACTION'), 'WARNING'); --moac
2614 l_hold_source_rec OE_Holds_Pvt.hold_source_rec_type;
2615 l_hold_release_rec OE_Holds_Pvt.Hold_Release_REC_Type;
2616 l_return_status varchar2(30);
2617 l_x_msg_count number;
2618 l_x_msg_data Varchar2(2000);
2619 l_x_result_out Varchar2(30);
2620 l_msg_text Varchar2(200);
2621 l_header_id NUMBER:=oe_order_pub.g_hdr.header_id;
2622 --bug 2028480 begin
2623 l_gsa_released varchar2(1) := 'N';
2624 --bug 2028480 end
2625 CURSOR gsa_violators IS
2626 SELECT ql.LINE_ID, l.ordered_item, l.inventory_item_id, ql.pricing_status_text
2627 FROM QP_PREQ_LINES_TMP ql
2628 , OE_ORDER_LINES l
2629 WHERE ql.line_id=l.line_id
2630 AND ql.LINE_TYPE_CODE='LINE'
2631 AND ql.PROCESS_STATUS <> 'NOT_VALID'
2632 AND ql.PRICING_STATUS_CODE =
2633 QP_PREQ_GRP.G_STATUS_GSA_VIOLATION
2634 AND l.ITEM_TYPE_CODE NOT IN ('INCLUDED','CONFIG')
2635 AND l.TRANSACTION_PHASE_CODE ='F'; -- Bug 6617462;
2636 CURSOR updated_lines IS
2637 SELECT LINE_ID FROM QP_PREQ_LINES_TMP
2638 WHERE LINE_TYPE_CODE='LINE'
2639 AND PROCESS_STATUS <> 'NOT_VALID'
2640 AND PRICING_STATUS_CODE = (QP_PREQ_GRP.G_STATUS_UPDATED);
2641 --
2642 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2643 --
2644 --these variables are introduced for bug 3021992
2645 l_mod_lineid NUMBER;
2646 l_line_num VARCHAR2(10);
2647 BEGIN
2648 IF l_debug_level > 0 THEN
2649 oe_debug_pub.add( 'GSA ENABLED?'||L_GSA_ENABLED_FLAG||' ACTION:'||L_GSA_VIOLATION_ACTION ) ;
2650 END IF;
2651 IF (l_GSA_Enabled_Flag = 'Y') THEN
2652
2653 FOR i IN gsa_violators LOOP
2654 IF l_debug_level > 0 THEN
2655 oe_debug_pub.add( 'GSA VIOLATION LINE:'||I.LINE_ID , 3 ) ;
2656 END IF;
2657 l_mod_lineid := MOD(i.line_id,2147483647) ;
2658 IF l_gsa_violation_action = 'WARNING' THEN
2659
2660 /* FND_MESSAGE.SET_NAME('ONT','OE_GSA_VIOLATION');
2661 l_msg_text := i.pricing_status_text||' ( '||nvl(i.ordered_item,i.inventory_item_id)||' )';
2662 FND_MESSAGE.SET_TOKEN('GSA_PRICE',l_msg_text);
2663 OE_MSG_PUB.Add;*/
2664 --3021992
2665 IF not(g_lineid_tbl.EXISTS(l_mod_lineid)) THEN
2666 FND_MESSAGE.SET_NAME('ONT','OE_GSA_VIOLATION');
2667 l_line_num := OE_ORDER_MISC_PUB.get_concat_line_number(i.line_id);
2668 l_msg_text := nvl(i.ordered_item,i.inventory_item_id);
2669 FND_MESSAGE.SET_TOKEN('LINE_NUMBER',l_line_num);
2670 FND_MESSAGE.SET_TOKEN('ITEM_NAME',l_msg_text);
2671 FND_MESSAGE.SET_TOKEN('GSA_PRICE',i.pricing_status_text);
2672 OE_MSG_PUB.Add;
2673 END IF ;
2674 g_lineid_tbl(l_mod_lineid) := i.line_id ;
2675 --3021992 ends
2676 ELSE -- violation action is error
2677 G_STMT_NO := 'Gsa_Check#20.15';
2678 -- bug 1381660, duplicate holds with type_code='GSA'
2679 -- use the seeded hold_id
2680 l_hold_source_rec.hold_id := G_SEEDED_GSA_HOLD_ID;
2681
2682 If i.line_id is null or
2683 i.line_id = fnd_api.g_miss_num then
2684 FND_MESSAGE.SET_NAME('ONT','OE_PRICING_ERROR');
2685 FND_MESSAGE.SET_TOKEN('ERR_TEXT','GSA_INVALID_LINE_ID');
2686 OE_MSG_PUB.Add;
2687 RAISE FND_API.G_EXC_ERROR;
2688 End if;
2689
2690 G_STMT_NO := 'Gsa_Check#20.20';
2691 l_hold_source_rec.hold_entity_id := l_header_id;
2692 l_hold_source_rec.header_id := l_header_id;
2693 l_hold_source_rec.line_id := i.line_id;
2694 l_hold_source_rec.Hold_Entity_code := 'O';
2695 --for bug 2028480 Begin
2696 --check if hold released earlier for this line , if so, do not go
2697 --thru the holds logic
2698 IF l_debug_level > 0 THEN
2699 oe_debug_pub.add( 'HOLD ID :'||L_HOLD_SOURCE_REC.HOLD_ID ) ;
2700 END IF;
2701 Begin
2702 --changed select below to fix bug 3039915
2703 select 'Y' into l_gsa_released from
2704 oe_order_holds ooh,oe_hold_sources ohs,oe_hold_releases ohr
2705 where ooh.line_id = i.line_id
2706 and ooh.hold_source_id = ohs.hold_source_id
2707 and ohr.hold_release_id = ooh.hold_release_id
2708 and ohs.hold_id = l_hold_source_rec.hold_id
2709 and ohr.created_by <> 1
2710 and ohr.release_reason_code <> 'PASS_GSA' ;
2711 exception
2712 when others then
2713 l_gsa_released := 'N';
2714 end;
2715 IF l_debug_level > 0 THEN
2716 oe_debug_pub.add( 'GSA RELEASED VALUE :'||L_GSA_RELEASED ) ;
2717 END IF;
2718 --for bug 2028480 end
2719 if l_gsa_released = 'N' then --for bug 2028480
2720 -- check if line already on gsa hold, place hold if not
2721 OE_Holds_Pub.Check_Holds(
2722 p_api_version => 1.0
2723 ,p_header_id => l_header_id
2724 ,p_line_id => i.line_id
2725 ,p_hold_id => l_hold_source_rec.Hold_id
2726 ,x_return_status => l_return_status
2727 ,x_msg_count => l_x_msg_count
2728 ,x_msg_data => l_x_msg_data
2729 ,x_result_out => l_x_result_out
2730 );
2731
2732 If l_x_result_out = FND_API.G_FALSE then
2733 IF l_debug_level > 0 THEN
2734 oe_debug_pub.add( 'HOLD LINE WITH HEADER_ID:'||L_HEADER_ID||' LINE_ID: '||I.LINE_ID , 1 ) ;
2735 END IF;
2736 OE_HOLDS_PUB.Apply_Holds(
2737 p_api_version => 1.0
2738 ,p_hold_source_rec => l_hold_source_rec
2739 ,x_return_status => l_return_status
2740 ,x_msg_count => l_x_msg_count
2741 ,x_msg_data => l_x_msg_data
2742 );
2743
2744 If l_return_status = FND_API.g_ret_sts_success then
2745
2746 /*FND_MESSAGE.SET_NAME('ONT','OE_GSA_HOLD_APPLIED');
2747 OE_MSG_PUB.Add;*/
2748 --3021992
2749 if not(g_lineid_tbl.EXISTS(l_mod_lineid)) THEN
2750 FND_MESSAGE.SET_NAME('ONT','OE_GSA_HOLD_APPLIED');
2751 OE_MSG_PUB.Add;
2752 END IF;
2753 g_lineid_tbl(l_mod_lineid) := i.line_id;
2754 --3021992 ends
2755
2756 Else
2757 FND_MESSAGE.SET_NAME('ONT','OE_PRICING_ERROR');
2758 FND_MESSAGE.SET_TOKEN('ERR_TEXT','APPLY_GSA_HOLD');
2759 OE_MSG_PUB.Add;
2760 RAISE FND_API.G_EXC_ERROR;
2761 End If;
2762 End If; /* check hold */
2763 End if; --for bug 2028480
2764 End if; /* violation action */
2765 END LOOP;
2766
2767 IF (l_gsa_violation_action = 'ERROR') THEN
2768 FOR i in updated_lines LOOP
2769 IF l_debug_level > 0 THEN
2770 oe_debug_pub.add( 'UPDATING LINE:'||I.LINE_ID||' RELEASING HOLD IF ANY' , 3 ) ;
2771 END IF;
2772 -- release hold if there is one
2773
2774 If l_hold_source_rec.hold_id is null or
2775 l_hold_source_rec.hold_id = fnd_api.g_miss_num then
2776 G_STMT_NO := 'Gsa_Check#20.25';
2777 -- bug 1381660, duplicate holds with type_code='GSA'
2778 -- use the seeded hold_id
2779 l_hold_source_rec.hold_id := G_SEEDED_GSA_HOLD_ID;
2780
2781 End if; -- Hold id
2782 G_STMT_NO := 'Gsa_Check#20.30';
2783
2784 l_hold_source_rec.hold_entity_id := l_header_id;
2785 l_hold_source_rec.header_id := l_header_id;
2786 l_hold_source_rec.line_id := i.line_id;
2787 l_hold_source_rec.Hold_Entity_code := 'O';
2788
2789 OE_Holds_Pub.Check_Holds(
2790 p_api_version => 1.0
2791 ,p_header_id => l_header_id
2792 ,p_line_id => i.line_id
2793 ,p_hold_id => l_hold_source_rec.Hold_id
2794 ,x_return_status => l_return_status
2795 ,x_msg_count => l_x_msg_count
2796 ,x_msg_data => l_x_msg_data
2797 ,x_result_out => l_x_result_out
2798 );
2799
2800 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2801 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2802 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2803 RAISE FND_API.G_EXC_ERROR;
2804 END IF;
2805
2806 If l_x_result_out = FND_API.G_TRUE then
2807 IF l_debug_level > 0 THEN
2808 oe_debug_pub.add( 'RELEASING GSA_HOLD ON LINE'||I.LINE_ID , 3 ) ;
2809 END IF;
2810 -- Hold is found , Release the hold.
2811
2812 G_STMT_NO := 'Gsa_Check#20.35';
2813 l_hold_release_rec.release_reason_code :='PASS_GSA';
2814 --for bug 3039915 set created_by = 1 to indicate automatic hold release
2815 l_hold_release_rec.created_by := 1;
2816
2817 OE_Holds_Pub.Release_Holds(
2818 p_api_version => 1.0
2819 -- ,p_hold_id => l_hold_source_rec.Hold_id
2820 -- ,p_entity_code => l_hold_source_rec.Hold_entity_code
2821 -- ,p_entity_id => l_hold_source_rec.Hold_entity_id
2822 ,p_hold_source_rec => l_hold_source_rec
2823 ,p_hold_release_rec => l_hold_release_rec
2824 ,x_return_status => l_return_status
2825 ,x_msg_count => l_x_msg_count
2826 ,x_msg_data => l_x_msg_data
2827 );
2828
2829 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2830 IF l_debug_level > 0 THEN
2831 oe_debug_pub.add( 'ERROR WHILE RELEASING GSA HOLD' ) ;
2832 END IF;
2833 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2834 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2835 IF l_debug_level > 0 THEN
2836 oe_debug_pub.add( 'ERROR WHILE RELEASING GSA HOLD' ) ;
2837 END IF;
2838 RAISE FND_API.G_EXC_ERROR;
2839 END IF;
2840 End if; -- Release Hold
2841
2842 END LOOP;
2843 End If; -- GSA Violation
2844
2845 END IF; -- gsa_enabled
2846 END Check_GSA;
2847
2848 PROCEDURE UPDATE_ORDER_HEADER(
2849 px_header_rec IN OE_ORDER_PUB.HEADER_REC_TYPE
2850 )
2851 IS
2852 --
2853 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2854 l_price_request_code VARCHAR2(250);--bug 9777018
2855 BEGIN
2856 oe_debug_pub.add('Entering UPDATE_ORDER_HEADER with header_id: '|| px_header_rec.header_id); --bug 9777018
2857 -- NULL; --commented for bug 9777018
2858 --/* --un-commented for bug 9777018: Start
2859 --The below code was commenetd for some un-known fix but due to this the PRC was being populated as NULL
2860 --for the Header Record and the request to reverse limits was not made.
2861 IF (px_header_rec.price_request_code IS NULL)
2862 THEN
2863
2864 --bug 9777018 : Start
2865 select price_request_code into l_price_request_code
2866 from qp_preq_lines_tmp
2867 where line_type_code='ORDER' and line_id=px_header_rec.header_id;
2868
2869 oe_debug_pub.add(' l_price_request_code = '|| l_price_request_code);
2870
2871 update oe_order_headers
2872 set price_request_code = l_price_request_code
2873 where header_id = px_header_rec.header_id;
2874 --bug 9777018: End
2875
2876 END IF;
2877 --*/--un-commented forbug 9777018: End
2878 oe_debug_pub.add('Exiting UPDATE_ORDER_HEADER() ... ');
2879
2880 --- bug 9777018: Start: commenting the exception handling so as to
2881 -- handle in Exception Block of Process_Adjustments()
2882 /*
2883 EXCEPTION
2884 WHEN NO_DATA_FOUND THEN
2885 NULL;
2886 */
2887 --- bug 9777018: End
2888
2889 END UPDATE_ORDER_HEADER;
2890
2891 PROCEDURE LOG_REQUEST(
2892 px_line_tbl IN OUT NOCOPY OE_ORDER_PUB.LINE_TBL_TYPE
2893 )
2894 IS
2895 l_verify_payment varchar2(1);
2896 l_commitment_sequencing boolean
2897 := OE_COMMITMENT_PVT.Do_Commitment_Sequencing;
2898 l_return_status varchar2(1);
2899 l_tax_event_code number := 0;
2900 l_tax_calculation_flag varchar2(1):=NULL;
2901 l_tax_calc_rec OE_ORDER_CACHE.Tax_Calc_Rec_Type;
2902 l_line_rec OE_ORDER_PUB.LINE_REC_TYPE;
2903 l_order_adj_changed_flag varchar2(1);
2904 l_commt_tax_flag varchar2(1); --bug 2505961
2905 cursor updated_lines IS
2906 SELECT l.LINE_ID
2907 , l.UNIT_SELLING_PRICE_PER_PQTY
2908 , l.unit_selling_price usp
2909 , LINES.ADJUSTED_UNIT_PRICE
2910 , lines.order_uom_Selling_price ousp
2911 , l.COMMITMENT_ID
2912 , l.BOOKED_FLAG
2913 , l.LINE_CATEGORY_CODE
2914 , l.line_type_id
2915 , l.shippable_flag
2916 , l.shipped_quantity
2917 , l.tax_exempt_flag
2918 , l.org_id
2919 , l.header_id
2920 , l.reference_line_id
2921 , l.return_context
2922 , l.reference_customer_trx_line_id
2923 -- BLANKETS: select following fields for logging request
2924 -- to update blanket amount
2925 , nvl(lines.order_uom_selling_price, lines.ADJUSTED_UNIT_PRICE*nvl(lines.priced_quantity,l.ordered_quantity)/l.ordered_quantity) new_selling_price
2926 , l.blanket_number
2927 , l.blanket_line_number
2928 , l.unit_selling_price
2929 , l.ordered_quantity
2930 , l.pricing_quantity
2931 , l.order_quantity_uom
2932 , l.fulfilled_flag
2933 , l.line_set_id
2934 , l.inventory_item_id
2935 , l.sold_to_org_id
2936 , l.transaction_phase_code--for bug 3108881
2937 , l.order_source_id
2938 FROM QP_PREQ_LINES_TMP lines
2939 , OE_ORDER_LINES l
2940 WHERE lines.pricing_status_code IN
2941 ( QP_PREQ_GRP.G_STATUS_UPDATED
2942 , QP_PREQ_GRP.G_STATUS_GSA_VIOLATION)
2943 AND lines.process_status <> 'NOT_VALID'
2944 AND lines.line_type_code='LINE'
2945 AND (lines.adjusted_unit_price <> nvl(l.unit_selling_price_per_pqty,0)
2946 or nvl(lines.order_uom_Selling_price,0) <> nvl(l.unit_selling_price,0))
2947 AND l.ordered_quantity <> 0 -- bug 3958480
2948 AND l.line_id = lines.line_id;
2949
2950 --
2951 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2952 --
2953 l_notify_index NUMBER:=NULL;
2954 --bug 4332307
2955 l_header_id Number;
2956 l_log_mrg_hold_req Varchar2(1) := 'N';
2957 Begin
2958
2959 -- Log delayed requests for the attributes change on the line
2960 BEGIN
2961 IF OE_Order_pub.g_hdr.order_type_id is not null THEN
2962
2963 --changes for bug 4200055
2964 IF ( OE_Order_PUB.G_Hdr.Order_Type_id <> FND_API.G_MISS_NUM ) THEN
2965 if (OE_Order_Cache.g_order_type_rec.order_type_id <> OE_Order_PUB.G_Hdr.Order_Type_id) then
2966 OE_Order_Cache.Load_Order_type(OE_Order_PUB.G_Hdr.Order_Type_id) ;
2967 end if ;
2968 if (OE_Order_Cache.g_order_type_rec.order_type_id = OE_Order_PUB.G_Hdr.Order_Type_id ) then
2969 if (OE_Order_Cache.g_order_type_rec.tax_calculation_event_code = 'ENTERING') then
2970 l_tax_event_code := 0;
2971 elsif (OE_Order_Cache.g_order_type_rec.tax_calculation_event_code = 'BOOKING') then
2972 l_tax_event_code := 1;
2973 elsif (OE_Order_Cache.g_order_type_rec.tax_calculation_event_code = 'SHIPPING') then
2974 l_tax_event_code := 2;
2975 elsif (OE_Order_Cache.g_order_type_rec.tax_calculation_event_code = 'INVOICING') then
2976 l_tax_event_code := 3;
2977 else
2978 l_tax_event_code := -1;
2979 end if ;
2980 else
2981 l_tax_event_code := 0 ;
2982 end if ;
2983 ELSE
2984 l_tax_event_code := 0 ;
2985 END IF ;
2986
2987 /*SELECT DECODE( TAX_CALCULATION_EVENT_CODE, 'ENTERING', 0,
2988 'BOOKING', 1,
2989 'SHIPPING', 2,
2990 'INVOICING', 3,
2991 -1)
2992 into l_tax_event_code
2993 from oe_transaction_types_all
2994 where transaction_type_id = OE_Order_pub.g_hdr.order_type_id;*/
2995 -- end bug 4200055
2996 END IF;
2997
2998 EXCEPTION
2999 when no_data_found then
3000 l_tax_event_code := 0;
3001 when others then
3002 IF l_debug_level > 0 THEN
3003 oe_debug_pub.add( 'REN: FAILED WHILE QUERY UP TAX_EVENT' ) ;
3004 END IF;
3005 RAISE;
3006
3007 END;
3008 IF l_debug_level > 0 THEN
3009 oe_debug_pub.add( 'TAX EVENT CODE'||L_TAX_EVENT_CODE ) ;
3010 END IF;
3011
3012 for update_line in updated_lines loop
3013 IF l_debug_level > 0 THEN
3014 oe_debug_pub.add( 'LOG REQUEST FOR UPDATED LINE '||UPDATE_LINE.LINE_ID ) ;
3015 oe_debug_pub.add('adjusted_unit_price : '||update_line.adjusted_unit_price);
3016 oe_debug_pub.add('order_uom_selling_price : '||update_line.ousp);
3017 oe_debug_pub.add('unit_selling_price_per_pqty : '||update_line.unit_selling_price_per_pqty);
3018 oe_debug_pub.add('unit_selling_price : '||update_line.usp);
3019 END IF;
3020 -- Delayed Requests to be logged if selling price change
3021 -- Tax, Verify_Payment, Commitment
3022 --populate a temp l_line_rec, only fields necessary to get tax flag
3023 l_line_rec.line_id := update_line.line_id;
3024 l_line_rec.header_id := update_line.header_id;
3025 l_line_rec.reference_line_id := update_line.reference_line_id;
3026 l_line_rec.line_type_id := update_line.line_type_id;
3027 l_line_rec.org_id := update_line.org_id;
3028 l_line_rec.line_category_code := update_line.line_category_code;
3029 l_line_rec.return_context := update_line.return_context;
3030 l_line_Rec.reference_customer_trx_line_id
3031 := update_line.reference_customer_trx_line_id;
3032 l_tax_calc_rec := oe_order_cache.get_tax_calculation_flag
3033 (update_line.line_type_id,
3034 l_line_rec);
3035
3036 l_tax_calculation_flag := l_tax_calc_rec.tax_calculation_flag;
3037 --changes for bug 2505961 Begin
3038 --commented the following for bug7306510 as the sql execution is no more required
3039 /*if update_line.commitment_id is not null
3040 and update_line.commitment_id <> FND_API.G_MISS_NUM then
3041 begin
3042 select nvl(tax_calculation_flag,'N') into l_commt_tax_flag
3043 from ra_cust_trx_types_all ract where ract.cust_trx_type_id =
3044 (
3045 select nvl(cust_type.subsequent_trx_type_id,cust_type.cust_trx_type_id)
3046 from ra_cust_trx_types cust_type,ra_customer_trx_all cust_trx where
3047 cust_type.cust_trx_type_id = cust_trx.cust_trx_type_id
3048 and cust_trx.customer_trx_id = update_line.commitment_id
3049 );
3050 IF l_debug_level > 0 THEN
3051 oe_debug_pub.add( 'L_COMMIT TAX FLAG: '||L_COMMT_TAX_FLAG , 1 ) ;
3052 END IF;
3053 exception
3054 when others then
3055 IF l_debug_level > 0 THEN
3056 oe_debug_pub.add( 'IN EXCEPTION COMMITMENT ' , 1 ) ;
3057 END IF;
3058 l_commt_tax_flag := 'N';
3059 end;
3060 end if;
3061 */
3062 --changes for bug 2505961 end
3063
3064 --l_tax_calculation_flag := 'Y';
3065
3066 IF l_debug_level > 0 THEN
3067 oe_debug_pub.add( 'L_TAX_CALCULATION_FLAG'||L_TAX_CALCULATION_FLAG ) ;
3068 END IF;
3069
3070 -- commented portion of the following condition for bug7306510
3071 -- with ebtax upkae in R12 ,meaning of ra_cust_trx_types.tax_calculation_flag has changed
3072 -- now this flag will be checcked by customers only if they want the 11i migrated Tax Classification
3073 -- code approach,other wise tax will be calculated based on tax rules .It no more controls wheter tax code is a required filed in AR transactions or not
3074 -- OM will depend on Tax_event alone ( specfied transaction type level) to automatically trigger
3075 -- tax calcualtion .ra_cust_trx_types.tax_calculation_flag is no more considered while logging delayed requests for tax
3076
3077
3078 IF ((l_tax_event_code = 0 OR
3079 (l_tax_event_code = 1 AND nvl(update_line.booked_flag,'X') = 'Y') OR
3080 (l_tax_event_code = 2 AND (update_line.shippable_flag = 'N' OR (update_line.shippable_flag = 'Y' and update_line.shipped_quantity IS NOT NULL))) OR
3081 l_tax_event_code = -1)
3082 --AND 7306510 (l_tax_calculation_flag = 'Y' OR
3083 --update_line.tax_exempt_flag = 'R' OR l_commt_tax_flag = 'Y' )
3084 ) THEN
3085
3086 IF l_debug_level > 0 THEN
3087 oe_debug_pub.add( 'LOGGING DELAYED REQUEST FOR TAXING' ) ;
3088 END IF;
3089 l_commt_tax_flag := 'N' ; --bug 2505961
3090 -- lkxu, make changes for bug 1581188
3091 IF (OE_GLOBALS.G_UI_FLAG)
3092 AND nvl(FND_PROFILE.VALUE('ONT_DELAY_TAX_CALC'), 'N') = 'N' THEN --TaxER
3093 OE_delayed_requests_Pvt.log_request(
3094 p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3095 p_entity_id => update_line.line_id,
3096 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3097 p_requesting_entity_id => update_line.line_id,
3098 p_request_type => OE_GLOBALS.g_tax_line,
3099 x_return_status => l_return_status);
3100 ELSE
3101 -- added p_param1 for bug 1786533.
3102 OE_delayed_requests_Pvt.log_request(
3103 p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
3104 p_entity_id => update_line.line_id,
3105 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3106 p_requesting_entity_id => update_line.line_id,
3107 p_request_type => OE_GLOBALS.g_tax_line,
3108 --p_param1 => l_param1,
3109 x_return_status => l_return_status);
3110 END IF;
3111 oe_globals.g_tax_flag := 'N';
3112 END IF;
3113
3114 l_verify_payment := 'N';
3115 --IF OE_ORDER_PUB.G_HDR.PAYMENT_TYPE_CODE = 'CREDIT_CARD' THEN --CC Reversal ER#16014135 Commented
3116 IF OE_ORDER_PUB.G_HDR.PAYMENT_TYPE_CODE = 'CREDIT_CARD' AND OE_VERIFY_PAYMENT_PUB.Get_CC_Rev_Reauth_Code( oe_order_pub.g_hdr.header_id) IS NULL THEN --CC Reversal ER#16014135
3117 IF l_debug_level > 0 THEN
3118 oe_debug_pub.add( 'CREDIT CARD:'||UPDATE_LINE.ADJUSTED_UNIT_PRICE||'>'||UPDATE_LINE.UNIT_SELLING_PRICE_PER_PQTY||'?' ) ;
3119 END IF;
3120 IF update_line.adjusted_unit_price > update_line.unit_selling_price_per_pqty or
3121 nvl(update_line.ousp,0) > nvl(update_line.usp,0)
3122 THEN
3123 -- Log Request if commitment id is NULL
3124 IF update_line.commitment_id is NULL THEN
3125 IF l_debug_level > 0 THEN
3126 oe_debug_pub.add( 'LOG VERIFY PAYMENT DELAYED REQUSET IN SELLING PRICE' ) ;
3127 END IF;
3128 l_verify_payment := 'Y';
3129 ELSE
3130 IF l_debug_level > 0 THEN
3131 oe_debug_pub.add( 'COMMITMENT:'||UPDATE_LINE.COMMITMENT_ID ) ;
3132 END IF;
3133 END IF;
3134 END IF;
3135 ELSE
3136 IF l_debug_level > 0 THEN
3137 oe_debug_pub.add( 'PAYMENT TYPE:'||OE_ORDER_PUB.G_HDR.PAYMENT_TYPE_CODE||' BOOKED?'||UPDATE_LINE.BOOKED_FLAG ) ;
3138 END IF;
3139 IF nvl(update_line.booked_flag,'X') = 'Y' THEN
3140 IF l_debug_level > 0 THEN
3141 oe_debug_pub.add( 'LOG VERIFY PAYMENT REQUEST' ) ;
3142 END IF;
3143 l_verify_payment := 'Y';
3144 END IF;
3145 END IF;
3146 IF (l_verify_payment = 'Y' AND update_line.line_category_code <> 'RETURN') THEN
3147 IF l_debug_level > 0 THEN
3148 oe_debug_pub.add( 'LOGGING DELAYED REQUEST FOR VERIFY PAYMENT' ) ;
3149 END IF;
3150 --
3151 OE_delayed_requests_Pvt.log_request
3152 (p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
3153 p_entity_id => oe_order_pub.g_hdr.header_id,
3154 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3155 p_requesting_entity_id => update_line.line_id,
3156 p_request_type => OE_GLOBALS.G_VERIFY_PAYMENT,
3157 x_return_status => l_return_status);
3158 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3159 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3160 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3161 RAISE FND_API.G_EXC_ERROR;
3162 END IF;
3163 END IF;
3164
3165 IF l_debug_level > 0 THEN
3166 oe_debug_pub.add( 'COMMITMENT '||UPDATE_LINE.COMMITMENT_ID ) ;
3167 END IF;
3168
3169 IF l_commitment_sequencing AND update_line.commitment_id IS NOT NULL THEN
3170 IF l_debug_level > 0 THEN
3171 oe_debug_pub.add( 'LOGGING DELAYED REQUEST FOR COMMITMENT.' , 2 ) ;
3172 END IF;
3173 OE_Delayed_Requests_Pvt.Log_Request(
3174 p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3175 p_entity_id => update_line.line_id,
3176 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3177 p_requesting_entity_id => update_line.line_id,
3178 p_request_type => OE_GLOBALS.G_CALCULATE_COMMITMENT,
3179 x_return_status => l_return_status);
3180 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3181 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3182 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3183 RAISE FND_API.G_EXC_ERROR;
3184 END IF;
3185 END IF;
3186
3187 IF l_debug_level > 0 THEN
3188 oe_debug_pub.add('old SP :'||update_line.unit_selling_price);
3189 oe_debug_pub.add('new SP :'||update_line.new_selling_price);
3190 END IF;
3191
3192 -- BLANKETS: log request to update blanket amounts if price changes
3193 -- BUG 2746595, send currency code as request_unique_key1 parameter to
3194 -- process release request. This is required as 2 distinct requests need to
3195 -- be logged for currency updates.
3196
3197 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110509'
3198 -- Bug 2739731 => do not log blanket requests for return lines
3199 AND update_line.line_category_code = 'ORDER'
3200 AND update_line.blanket_number IS NOT NULL
3201 THEN
3202
3203 IF l_debug_level > 0 THEN
3204 oe_debug_pub.add('OEXVOPRB log blanket request');
3205 oe_debug_pub.add('old SP :'||update_line.unit_selling_price);
3206 oe_debug_pub.add('new SP :'||update_line.new_selling_price);
3207 END IF;
3208
3209 OE_Order_Cache.Load_Order_Header(update_line.header_id);
3210 --for bug 3108881
3211 --request should be logged only for Sales order and not for quotes
3212 IF nvl(update_line.transaction_phase_code,'F') = 'F' THEN
3213
3214 OE_Delayed_Requests_Pvt.Log_Request
3215 (p_entity_code => OE_GLOBALS.G_ENTITY_ALL
3216 ,p_entity_id => update_line.line_id
3217 ,p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE
3218 ,p_requesting_entity_id => update_line.line_id
3219 ,p_request_type => OE_GLOBALS.G_PROCESS_RELEASE
3220 -- Old values
3221 ,p_param1 => update_line.blanket_number
3222 ,p_param2 => update_line.blanket_line_number
3223 ,p_param3 => update_line.ordered_quantity
3224 ,p_param4 => update_line.order_quantity_uom
3225 ,p_param5 => update_line.unit_selling_price
3226 ,p_param6 => update_line.inventory_item_id
3227 -- New values
3228 ,p_param11 => update_line.blanket_number
3229 ,p_param12 => update_line.blanket_line_number
3230 ,p_param13 => update_line.ordered_quantity
3231 ,p_param14 => update_line.order_quantity_uom
3232 ,p_param15 => update_line.new_selling_price
3233 ,p_param16 => update_line.inventory_item_id
3234 -- Other parameters
3235 ,p_param8 => update_line.fulfilled_flag
3236 ,p_param9 => update_line.line_set_id
3237 ,p_request_unique_key1 =>
3238 OE_Order_Cache.g_header_rec.transactional_curr_code
3239 ,x_return_status => l_return_status
3240 );
3241 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3242 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3243 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3244 RAISE FND_API.G_EXC_ERROR;
3245 END IF;
3246
3247 IF update_line.line_set_id IS NOT NULL THEN
3248 OE_Delayed_Requests_Pvt.Log_Request
3249 (p_entity_code => OE_GLOBALS.G_ENTITY_ALL
3250 ,p_entity_id => update_line.line_set_id
3251 ,p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE
3252 ,p_requesting_entity_id => update_line.line_id
3253 ,p_request_type => 'VALIDATE_RELEASE_SHIPMENTS'
3254 ,p_request_unique_key1 => update_line.blanket_number
3255 ,p_request_unique_key2 => update_line.blanket_line_number
3256 ,p_param1 =>
3257 OE_Order_Cache.g_header_rec.transactional_curr_code
3258 ,x_return_status => l_return_status
3259 );
3260 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3261 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3262 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3263 RAISE FND_API.G_EXC_ERROR;
3264 END IF;
3265 END IF;
3266 END IF;--End for quote/order check
3267 END IF; -- End for log blanket request
3268
3269 --Bug 4332307 Logging Margin Hold delayed request
3270 IF update_line.booked_flag = 'Y' THEN
3271 IF OE_FEATURES_PVT.Is_Margin_Avail THEN
3272 IF Oe_Sys_Parameters.Value('COMPUTE_MARGIN') <> 'N' Then
3273 l_log_mrg_hold_req := 'Y';
3274 l_header_id := update_line.header_id;
3275 END IF;
3276 END IF;
3277 END IF;
3278 --Bug 4332307
3279
3280 end loop;
3281
3282 --bug 4332307
3283 IF l_log_mrg_hold_req = 'Y' THEN
3284 IF l_debug_level > 0 THEN
3285 oe_debug_pub.add( 'LOGGING DELAYED REQUEST FOR MARGIN HOLD FOR BOOKED HEADER_ID:'||l_header_id ) ;
3286 END IF;
3287 oe_delayed_requests_pvt.log_request(
3288 p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
3289 p_entity_id => l_header_id,
3290
3291 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
3292 p_requesting_entity_id => l_header_id,
3293
3294 p_request_type => 'MARGIN_HOLD',
3295 x_return_status => l_return_status);
3296 END IF;
3297 --bug 4332307
3298
3299
3300 IF (G_PASS_ALL_LINES in ('N', 'R')) THEN
3301 IF l_debug_level > 0 THEN
3302 oe_debug_pub.add( 'DID NOT PASS ALL LINES , LOG REQUEST' ) ;
3303 END IF;
3304 BEGIN
3305 SELECT processed_flag
3306 INTO l_order_adj_changed_flag
3307 FROM qp_preq_lines_tmp
3308 WHERE line_type_code='ORDER' and price_flag='Y';
3309 IF l_debug_level > 0 THEN
3310 oe_debug_pub.add( 'ORDER ADJ CHANGED:'||L_ORDER_ADJ_CHANGED_FLAG ) ;
3311 END IF;
3312 IF (l_order_adj_changed_flag = 'C') THEN
3313 IF l_debug_level > 0 THEN
3314 oe_debug_pub.add( 'LOGGING REQUEST TO UPDATE ALL LINES FOR HEADER LEVEL ADJUSTMENT.' , 1 ) ;
3315 END IF;
3316 OE_DELAYED_REQUESTS_PVT.LOG_REQUEST(
3317 p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
3318 p_entity_id => oe_order_pub.g_hdr.header_id,
3319 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_HEADER,
3320 p_requesting_entity_id => oe_order_pub.g_hdr.header_id,
3321 p_request_type => OE_GLOBALS.G_PRICE_ADJ,
3322 x_return_status => l_return_status);
3323
3324 END IF;
3325 EXCEPTION
3326 WHEN NO_DATA_FOUND THEN
3327 IF l_debug_level > 0 THEN
3328 oe_debug_pub.add( 'NO SUMMARY LINE WITH PRICE FLAG OF Y' ) ;
3329 END IF;
3330 NULL;
3331 WHEN OTHERS THEN
3332 IF l_debug_level > 0 THEN
3333 oe_debug_pub.add( 'PROBLEM?'||SQLERRM ) ;
3334 END IF;
3335 END;
3336 END IF;
3337
3338 IF l_debug_level > 0 THEN
3339 oe_debug_pub.add( 'AFTER LOG_REQUEST' , 3 ) ;
3340 END IF;
3341
3342 EXCEPTION
3343 WHEN OTHERS THEN
3344 IF l_debug_level > 0 THEN
3345 oe_debug_pub.add( 'WRONG IN LOG_REQUEST'||SQLERRM , 1 ) ;
3346 END IF;
3347 raise fnd_api.g_exc_error;
3348 End LOG_REQUEST;
3349
3350 PROCEDURE UPDATE_ORDER_LINES(
3351 px_line_tbl IN OUT NOCOPY OE_ORDER_PUB.LINE_TBL_TYPE
3352 , x_num_changed_lines OUT NOCOPY NUMBER
3353 ,p_write_to_db BOOLEAN DEFAULT FALSE
3354 )
3355 IS
3356 l_return_status varchar2(1);
3357
3358 DEADLOCK_DETECTED EXCEPTION;
3359 PRAGMA EXCEPTION_INIT(DEADLOCK_DETECTED, -60);
3360
3361 /*
3362 Cursor get_lock_info is
3363 Select Waiting_Session,Holding_session,lock_type,MODE_HELD,MODE_REQUESTED,LOCK_ID1,LOCK_ID2
3364 From dba_waiters;
3365 */
3366 --
3367 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3368 --
3369 Begin
3370 --RT{
3371 IF nvl(G_PRICING_EVENT,';xx-') = 'RETROBILL' THEN
3372 oe_debug_pub.add('Calling update retrobill lines');
3373 LOG_REQUEST(px_line_tbl);
3374 Oe_Retrobill_Pvt.UPDATE_RETROBILL_LINES(G_RETROBILL_OPERATION);
3375 ELSE --RT
3376 IF l_debug_level > 0 THEN
3377 oe_debug_pub.add( ' ENTERING OE_ORDER_PRICE_PVT.UPDATE_ORDER_LINES' ) ;
3378 END IF;
3379
3380 SECURITY_AND_GLOBAL_PICTURE(px_line_tbl,p_write_to_db);
3381
3382 LOG_REQUEST(px_line_tbl);
3383
3384 --Bug 13473036 starts
3385 /*When the same line is being updated by some other user should raise an exception
3386 This will work only when we try to update a single line.
3387 Ex: Actions -> Promotions/Pricing Attributes
3388 All other cases, lock will not be acquired
3389 */
3390 DECLARE
3391 l_dummy NUMBER;
3392 BEGIN
3393
3394 SELECT line_id
3395 INTO l_dummy
3396 FROM oe_order_lines_all
3397 WHERE ordered_quantity <> 0
3398 AND open_flag <> 'N'
3399 AND line_id in (select line_id
3400 from qp_preq_lines_tmp lines
3401 where lines.pricing_status_code in
3402 (QP_PREQ_GRP.G_STATUS_UPDATED,
3403 QP_PREQ_GRP.G_STATUS_GSA_VIOLATION
3404 )
3405 and lines.process_status <> 'NOT_VALID'
3406 and lines.line_type_code='LINE'
3407 )
3408 FOR UPDATE NOWAIT;
3409
3410 oe_debug_pub.add('Selected for update');
3411
3412 EXCEPTION
3413 WHEN APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION
3414 THEN
3415 IF l_debug_level > 0 THEN
3416 oe_debug_pub.add('in lock record exception, someone else working on the row');
3417 END IF;
3418
3419 FND_MESSAGE.Set_Name('ONT', 'OE_LINE_LOCKED');
3420 OE_MSG_PUB.Add;
3421 RAISE fnd_api.g_exc_unexpected_error;
3422 WHEN OTHERS
3423 THEN
3424 IF l_debug_level > 0 THEN
3425 oe_debug_pub.add('Exceptions have occured, Continuing with the update statement.');
3426 oe_debug_pub.add('SQLCODE: '||SQLCODE);
3427 oe_debug_pub.add('SQLERRM: '||SQLERRM);
3428 END IF;
3429 END;
3430 --Bug 13473036 ends
3431
3432 IF l_debug_level > 0 THEN
3433 oe_debug_pub.add( ' BEFORE UPDATING ORDER LINES' , 3 ) ;
3434 END IF;
3435 UPDATE OE_ORDER_LINES_all l
3436 SET (UNIT_SELLING_PRICE
3437 , UNIT_LIST_PRICE
3438 ,UNIT_SELLING_PRICE_PER_PQTY
3439 ,UNIT_LIST_PRICE_PER_PQTY
3440 , PRICING_QUANTITY
3441 , PRICING_QUANTITY_UOM
3442 , PRICE_LIST_ID
3443 , PRICE_REQUEST_CODE
3444 , UNIT_LIST_PERCENT
3445 , UNIT_PERCENT_BASE_PRICE
3446 , UNIT_SELLING_PERCENT
3447 , LOCK_CONTROL
3448 , LAST_UPDATE_DATE -- Added WHO columns for the bug 3105197
3449 , LAST_UPDATED_BY
3450 , LAST_UPDATE_LOGIN)
3451 =
3452 (select
3453 nvl(lines.order_uom_selling_price, lines.ADJUSTED_UNIT_PRICE*nvl(lines.priced_quantity,l.ordered_quantity)/l.ordered_quantity)
3454 , nvl(lines.line_unit_price, lines.UNIT_PRICE*nvl(lines.priced_quantity,l.ordered_quantity)/l.ordered_quantity)
3455 , lines.ADJUSTED_UNIT_PRICE
3456 , lines.UNIT_PRICE
3457 , decode(lines.priced_quantity,-99999,l.ordered_quantity,lines.priced_quantity)
3458 , decode(lines.priced_quantity,-99999,l.order_quantity_uom,lines.priced_uom_code)
3459 , decode(lines.price_list_header_id,-9999,NULL,lines.price_list_header_id) --Bug#2830609
3460 , lines.price_request_code
3461 , nvl(lines.percent_price, NULL)
3462 , nvl(lines.parent_price, NULL)
3463 , decode(lines.parent_price, NULL, 0, 0, 0,
3464 lines.adjusted_unit_price/lines.parent_price)
3465 , l.lock_control + 1
3466 , SYSDATE
3467 , FND_GLOBAL.USER_ID
3468 , FND_GLOBAL.LOGIN_ID
3469 from qp_preq_lines_tmp lines
3470 where lines.line_id=l.line_id
3471 and l.open_flag <> 'N'
3472 and lines.line_type_code='LINE'
3473 and lines.pricing_status_code in (QP_PREQ_GRP.G_STATUS_UPDATED, QP_PREQ_GRP.G_STATUS_GSA_VIOLATION)
3474 and lines.process_status <> 'NOT_VALID'
3475 )
3476 where
3477 --l.header_id=oe_order_pub.g_hdr.header_id
3478 --and
3479 l.ordered_quantity <> 0
3480 and l.open_flag <> 'N'
3481 and l.line_id in (select line_id from qp_preq_lines_tmp lines
3482 where
3483 lines.pricing_status_code in
3484 (QP_PREQ_GRP.G_STATUS_UPDATED,
3485 QP_PREQ_GRP.G_STATUS_GSA_VIOLATION)
3486 and lines.process_status <> 'NOT_VALID'
3487 and
3488 lines.line_type_code='LINE');
3489 IF l_debug_level > 0 THEN
3490 oe_debug_pub.add( ' LEAVING UPDATE_ORDER_LINES:'||SQL%ROWCOUNT , 3 ) ;
3491 END IF;
3492 x_num_changed_lines := SQL%ROWCOUNT;
3493 END IF; --RT
3494 EXCEPTION
3495 WHEN DEADLOCK_DETECTED THEN
3496 IF l_debug_level > 0 THEN
3497 oe_debug_pub.add( 'WRONG IN UPDATE_ORDER_LINES'||SQLERRM , 1 ) ;
3498 END IF;
3499 /*
3500 For i in get_lock_info Loop
3501 oe_debug_pub.add('Waiting_Session:'||i.waiting_Session||' Holding_session:'||i.Holding_session);
3502 oe_debug_pub.add('Lock_type:'||i.lock_type||' MODE_HELD:'||i.MODE_HELD||' MODE_REQUESTED'||i.MODE_REQUESTED);
3503 oe_debug_pub.add('Lock_ID1:'||i.Lock_ID1||' Lock_ID2:'||i.Lock_ID2);
3504 End Loop;
3505 */
3506 raise fnd_api.g_exc_unexpected_error;
3507 WHEN OTHERS THEN
3508 IF l_debug_level > 0 THEN
3509 oe_debug_pub.add( 'WRONG IN UPDATE_ORDER_LINES'||SQLERRM , 1 ) ;
3510 END IF;
3511 raise fnd_api.g_exc_unexpected_error;
3512 End UPDATE_ORDER_LINES;
3513
3514 --bug 3882620 Changed the Signature for the procedure Delete_dependents
3515 PROCEDURE DELETE_DEPENDENTS(
3516 p_adj_id_tbl IN OUT NOCOPY NUMBER_TYPE,
3517 p_header_id_tbl IN OUT NOCOPY NUMBER_TYPE,
3518 p_line_id_tbl IN OUT NOCOPY NUMBER_TYPE,
3519 p_list_line_id_tbl IN OUT NOCOPY NUMBER_TYPE,
3520 p_list_header_id_tbl IN OUT NOCOPY NUMBER_TYPE,
3521 p_list_line_type_code_tbl IN OUT NOCOPY VARCHAR_TYPE,
3522 p_applied_flag_tbl IN OUT NOCOPY VARCHAR_TYPE,
3523 p_adjusted_amount_tbl IN OUT NOCOPY NUMBER_TYPE
3524 ) IS
3525 i NUMBER;
3526 l_Line_Adj_rec OE_Order_PUB.Line_Adj_Rec_Type;
3527 l_Header_Adj_rec OE_Order_PUB.Header_Adj_Rec_Type; -- bug 8415941
3528 l_return_status VARCHAR2(30);
3529 l_index NUMBER;
3530 l_booked_flag varchar2(1) := oe_order_cache.g_header_rec.booked_flag;
3531
3532 --
3533 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3534 --
3535 BEGIN
3536 IF l_debug_level > 0 THEN
3537 oe_debug_pub.add('l_booked_flag in delete dependents = '||l_booked_flag);
3538 END IF;
3539 If p_adj_id_tbl.count > 0 Then
3540 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
3541 --IF l_booked_flag = 'Y' THEN
3542 --IF oe_adv_price_pvt.check_notify_OC then
3543 IF l_debug_level > 0 THEN
3544 oe_debug_pub.add('Delete adjustments notify to OC');
3545 END IF;
3546 i := p_adj_id_tbl.first;
3547 while i is not null loop
3548 IF (p_line_id_tbl(i) is NOT NULL) THEN -- Line Level Adjustment 8415941
3549 IF l_debug_level > 0 THEN
3550 oe_debug_pub.add('Line Level Adjustment 8415941 ');
3551 END IF;
3552 l_Line_Adj_rec.operation := OE_GLOBALS.G_OPR_DELETE;
3553 l_Line_Adj_rec.price_adjustment_id := p_adj_id_tbl(i);
3554 --bug 3882620
3555 l_Line_Adj_rec.header_id := p_header_id_tbl(i);
3556 l_Line_Adj_rec.line_id := p_line_id_tbl(i);
3557 l_Line_Adj_rec.list_line_id := p_list_line_id_tbl(i);
3558 l_Line_Adj_rec.list_header_id := p_list_header_id_tbl(i);
3559 l_Line_Adj_rec.list_line_type_code := p_list_line_type_code_tbl(i);
3560 l_Line_Adj_rec.applied_flag := p_applied_flag_tbl(i);
3561 l_Line_Adj_rec.adjusted_amount := p_adjusted_amount_tbl(i);
3562 l_Line_Adj_rec.last_update_date := sysdate;
3563 IF l_debug_level > 0 THEN
3564 oe_debug_pub.add('header_id:'||l_Line_Adj_rec.header_id||'line_id:'|| l_Line_Adj_rec.line_id);
3565 oe_debug_pub.add('list_line_id:'||l_Line_Adj_rec.list_line_id||'list_header_id:'||l_Line_Adj_rec.list_header_id);
3566 oe_debug_pub.add('last_update_date:'||l_Line_Adj_rec.last_update_date);
3567 END IF;
3568 --bug 3882620
3569 OE_ORDER_UTIL.Update_Global_Picture(p_Upd_New_Rec_If_Exists => True,
3570 p_line_adj_rec =>l_line_adj_rec,
3571 p_line_adj_id => l_line_adj_rec.price_adjustment_id,
3572 p_old_line_adj_rec =>l_line_adj_rec,
3573 x_index => l_index,
3574 x_return_status => l_return_status);
3575 IF l_debug_level > 0 THEN
3576 oe_debug_pub.add( 'UPDATE_GLOBAL RETURN STATUS FROM OE_ORDER_PRICE_PVT.DELETE_DEPENDENTS IS: ' || L_RETURN_STATUS ) ;
3577 END IF;
3578
3579 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3580
3581 IF l_debug_level > 0 THEN
3582 oe_debug_pub.add( 'EVENT NOTIFY - UNEXPECTED ERROR' ) ;
3583 oe_debug_pub.add( 'EXITING OE_ORDER_PRICE_PVT.DELETE_DEPENDENTS', 1 ) ;
3584 END IF;
3585 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3586 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3587 IF l_debug_level > 0 THEN
3588 oe_debug_pub.add( 'UPDATE_GLOBAL_PICTURE ERROR IN OE_ORDER_PRICE_PVT.DELETE_DEPENDENTS' ) ;
3589 oe_debug_pub.add( 'EXITING OE_ORDER_PRICE_PVT.DELETE_DEPENDENTS', 1 ) ;
3590 END IF;
3591 RAISE FND_API.G_EXC_ERROR;
3592 END IF;
3593 ELSE -- Header Level Adjustment
3594 IF l_debug_level > 0 THEN
3595 oe_debug_pub.add('Header Level Adjustment 8415941 ');
3596 END IF;
3597
3598 l_Header_Adj_rec.operation := OE_GLOBALS.G_OPR_DELETE;
3599 l_Header_Adj_rec.price_adjustment_id := p_adj_id_tbl(i);
3600 l_Header_Adj_rec.header_id := p_header_id_tbl(i);
3601 l_Header_Adj_rec.list_line_id := p_list_line_id_tbl(i);
3602 l_Header_Adj_rec.list_header_id := p_list_header_id_tbl(i);
3603 l_Header_Adj_rec.list_line_type_code := p_list_line_type_code_tbl(i);
3604 l_Header_Adj_rec.applied_flag := p_applied_flag_tbl(i);
3605 l_Header_Adj_rec.adjusted_amount := p_adjusted_amount_tbl(i);
3606 l_Header_Adj_rec.last_update_date := sysdate;
3607
3608
3609 OE_ORDER_UTIL.Update_Global_Picture(p_Upd_New_Rec_If_Exists => True,
3610 p_hdr_adj_rec =>l_header_adj_rec,
3611 p_hdr_adj_id => l_header_adj_rec.price_adjustment_id,
3612 p_old_hdr_adj_rec =>l_header_adj_rec,
3613 x_index => l_index,
3614 x_return_status => l_return_status);
3615 IF l_debug_level > 0 THEN
3616 oe_debug_pub.add( 'UPDATE_GLOBAL RETURN STATUS FROM Header Level Adj: ' || L_RETURN_STATUS ) ;
3617 END IF;
3618 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3619 IF l_debug_level > 0 THEN
3620 oe_debug_pub.add( 'Delete - UNEXPECTED ERROR' ) ;
3621 END IF;
3622 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3623 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3624 IF l_debug_level > 0 THEN
3625 oe_debug_pub.add( 'Delete -Error' ) ;
3626 END IF;
3627 RAISE FND_API.G_EXC_ERROR;
3628 END IF;
3629
3630 END IF; -- End Line Adjustment
3631 i := p_adj_id_tbl.next(i);
3632 end loop;
3633 --END IF;
3634 --END IF;
3635 END IF;
3636
3637 FORALL i IN p_adj_id_tbl.FIRST..p_adj_id_tbl.LAST
3638 DELETE FROM OE_PRICE_ADJ_ATTRIBS WHERE price_adjustment_id = p_adj_id_tbl(i);
3639 IF l_debug_level > 0 THEN
3640 oe_debug_pub.add( ' DELETED '||SQL%ROWCOUNT||' ATTRIBS' , 3 ) ;
3641 END IF;
3642
3643 FORALL i IN p_adj_id_tbl.FIRST..p_adj_id_tbl.LAST
3644 DELETE FROM OE_PRICE_ADJ_ASSOCS WHERE price_adjustment_id = p_adj_id_tbl(i);
3645 IF l_debug_level > 0 THEN
3646 oe_debug_pub.add( ' DELETED '||SQL%ROWCOUNT||' ASSOCS' , 3 ) ;
3647 END IF;
3648
3649 FORALL i IN p_adj_id_tbl.FIRST..p_adj_id_tbl.LAST
3650 DELETE FROM OE_PRICE_ADJ_ASSOCS WHERE rltd_price_adj_id = p_adj_id_tbl(i);
3651 IF l_debug_level > 0 THEN
3652 oe_debug_pub.add( ' DELETED '||SQL%ROWCOUNT||' RLTD ASSOCS' , 3 ) ;
3653 END IF;
3654
3655 p_adj_id_tbl.delete;
3656 End If;
3657
3658 END DELETE_DEPENDENTS;
3659
3660 ---bug 3740009
3661 PROCEDURE DELETE_HDR_ADJS( p_pricing_events varchar2
3662 ,p_hdr_line_id number
3663 ,p_hdr_line_index number
3664 ,p_hdr_price_flag varchar2
3665 ,p_hdr_pricing_status_code varchar2)
3666
3667 IS
3668
3669 l_adj_id_tbl Number_Type;
3670 --bug 3882620
3671 l_line_id_tbl Number_Type;
3672 l_list_line_type_code_tbl Varchar_Type;
3673 l_header_id_tbl Number_Type;
3674 l_applied_flag_tbl Varchar_Type;
3675 l_list_header_id_tbl Number_Type;
3676 l_adjusted_amount_tbl Number_Type;
3677 l_list_line_id_tbl Number_Type;
3678 --bug 3882620
3679 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3680
3681 BEGIN
3682
3683 IF p_hdr_price_flag in ('Y', 'P') AND p_hdr_pricing_status_code IN
3684 (QP_PREQ_PUB.G_STATUS_UPDATED,
3685 QP_PREQ_PUB.G_STATUS_GSA_VIOLATION
3686 )
3687 THEN
3688 DELETE FROM OE_PRICE_ADJUSTMENTS
3689 WHERE HEADER_ID=oe_order_pub.g_hdr.header_id
3690 AND LINE_ID IS NULL
3691 --AND LIST_LINE_TYPE_CODE NOT IN ('TAX') --Bug 13573144
3692 AND LIST_LINE_TYPE_CODE NOT IN ('TAX','TSN') --Bug 13573144
3693 AND NVL(UPDATED_FLAG, 'N')='N'
3694 AND PRICING_PHASE_ID IN (select b.pricing_phase_id
3695 from qp_event_phases a,
3696 qp_pricing_phases b
3697 where instr(p_pricing_events, a.pricing_event_code||',') > 0
3698 and b.pricing_phase_id = a.pricing_phase_id
3699 and nvl(b.user_freeze_override_flag,freeze_override_flag)
3700 = decode(p_hdr_price_flag, 'Y', nvl(b.user_freeze_override_flag,b.freeze_override_flag), 'P', 'Y'))
3701 AND HEADER_ID = p_hdr_line_id
3702 AND list_line_id not in (select list_line_id from qp_ldets_v ld
3703 where ld.process_code in (QP_PREQ_GRP.G_STATUS_NEW, --bug 4190357
3704 QP_PREQ_GRP.G_STATUS_UPDATED,
3705 QP_PREQ_GRP.G_STATUS_UNCHANGED)
3706 and ld.line_index = p_hdr_line_index
3707 and p_hdr_line_id = oe_order_pub.g_hdr.header_id)
3708 returning price_adjustment_id,
3709 header_id,
3710 line_id,
3711 list_line_id,
3712 list_header_id,
3713 list_line_type_code,
3714 applied_flag,
3715 adjusted_amount
3716 bulk collect into
3717 l_adj_id_tbl,
3718 l_header_id_tbl,
3719 l_line_id_tbl,
3720 l_list_line_id_tbl,
3721 l_list_header_id_tbl,
3722 l_list_line_type_code_tbl,
3723 l_applied_flag_tbl,
3724 l_adjusted_amount_tbl;
3725
3726 IF l_debug_level > 0 THEN
3727 oe_debug_pub.add( 'DELETED '||SQL%ROWCOUNT||' HEADER LEVEL ADJUSTMENTS/CHARGES' , 3 ) ;
3728 END IF;
3729 DELETE_DEPENDENTS(l_adj_id_tbl,l_header_id_tbl,l_line_id_tbl,l_list_line_id_tbl,l_list_header_id_tbl,l_list_line_type_code_tbl,l_applied_flag_tbl,l_adjusted_amount_tbl);
3730 END IF;
3731 END DELETE_HDR_ADJS;
3732
3733 PROCEDURE DELETE_LINES_ADJS(p_pricing_events IN varchar2)
3734
3735 IS
3736
3737 l_line_type_code varchar2(6);
3738 cursor updated_order_lines(l_line_type_code in varchar2) is
3739 select line_id, price_flag, line_index from qp_preq_lines_tmp
3740 where price_flag IN ('Y','P')
3741 and line_type_code = l_line_type_code
3742 and process_status <> 'NOT_VALID'
3743 and pricing_status_code in (QP_PREQ_PUB.G_STATUS_UPDATED
3744 , QP_PREQ_PUB.G_STATUS_GSA_VIOLATION);
3745
3746 l_adj_id_tbl Number_Type;
3747 --bug 3882620
3748 l_line_id_tbl Number_Type;
3749 l_list_line_type_code_tbl Varchar_Type;
3750 l_header_id_tbl Number_Type;
3751 l_applied_flag_tbl Varchar_Type;
3752 l_list_header_id_tbl Number_Type;
3753 l_adjusted_amount_tbl Number_Type;
3754 l_list_line_id_tbl Number_Type;
3755 --bug 3882620
3756 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3757
3758 BEGIN
3759
3760 l_line_type_code := 'LINE';
3761 For one_line in updated_order_lines(l_line_type_code) loop
3762 DELETE /*+ index (adj oe_price_adjustments_n2) */
3763 FROM OE_PRICE_ADJUSTMENTS adj
3764 WHERE --HEADER_ID=oe_order_pub.g_hdr.header_id
3765 LINE_ID = one_line.line_id
3766 --AND LIST_LINE_TYPE_CODE NOT IN ('TAX','IUE') --bug 2858712 --Bug 13573144
3767 AND LIST_LINE_TYPE_CODE NOT IN ('TAX','IUE','TSN') --Bug 13573144
3768 AND NVL(UPDATED_FLAG, 'N')='N'
3769 AND PRICING_PHASE_ID IN (select b.pricing_phase_id
3770 from qp_event_phases a,
3771 qp_pricing_phases b
3772 where instr(p_pricing_events, a.pricing_event_code||',') > 0
3773 and b.pricing_phase_id = a.pricing_phase_id
3774 and nvl(b.user_freeze_override_flag,freeze_override_flag)
3775 = decode(one_line.price_flag, 'Y', nvl(b.user_freeze_override_flag,b.freeze_override_flag), 'P', 'Y'))
3776 AND list_line_id not in (select list_line_id from qp_ldets_v ld
3777 where ld. process_code in (QP_PREQ_PUB.G_STATUS_UPDATED,
3778 QP_PREQ_PUB.G_STATUS_UNCHANGED,
3779 QP_PREQ_PUB.G_STATUS_NEW)
3780 and ld.line_index = one_line.line_index
3781 and (ld.applied_flag = decode(one_line.price_flag, 'Y', 'Y', 'P', ld.applied_flag)
3782 OR
3783 ((nvl(ld.applied_flag,'N') = decode(one_line.price_flag, 'Y', 'N', 'P', nvl(ld.applied_flag,'N'))
3784 AND
3785 nvl(ld.line_detail_type_code,'x') = decode(one_line.price_flag, 'Y', 'CHILD_DETAIL_LINE', 'P', nvl(ld.line_detail_type_code,'x'))
3786 ))
3787 ))
3788 returning price_adjustment_id,
3789 header_id,
3790 line_id,
3791 list_line_id,
3792 list_header_id,
3793 list_line_type_code,
3794 applied_flag,
3795 adjusted_amount
3796 bulk collect into
3797 l_adj_id_tbl,
3798 l_header_id_tbl,
3799 l_line_id_tbl,
3800 l_list_line_id_tbl,
3801 l_list_header_id_tbl,
3802 l_list_line_type_code_tbl,
3803 l_applied_flag_tbl,
3804 l_adjusted_amount_tbl;
3805
3806 IF l_debug_level > 0 THEN
3807 oe_debug_pub.add( 'DELETED '||SQL%ROWCOUNT||' LINE LEVEL ADJUSTMENTS/CHARGES FOR LINE:'||ONE_LINE.LINE_ID , 3 ) ;
3808 END IF;
3809 DELETE_DEPENDENTS(l_adj_id_tbl,l_header_id_tbl,l_line_id_tbl,l_list_line_id_tbl,l_list_header_id_tbl,l_list_line_type_code_tbl,l_applied_flag_tbl,l_adjusted_amount_tbl);
3810 END LOOP;
3811
3812 END DELETE_LINES_ADJS;
3813
3814 PROCEDURE DELETE_ONE_LINE_ADJS(p_line_id in number, p_pricing_events IN varchar2)
3815
3816 IS
3817
3818 l_line_id Number;
3819 l_price_flag Varchar2(1);
3820 l_adj_id_tbl Number_Type;
3821 --bug 3882620
3822 l_line_id_tbl Number_Type;
3823 l_list_line_type_code_tbl Varchar_Type;
3824 l_header_id_tbl Number_Type;
3825 l_applied_flag_tbl Varchar_Type;
3826 l_list_header_id_tbl Number_Type;
3827 l_adjusted_amount_tbl Number_Type;
3828 l_list_line_id_tbl Number_Type;
3829 --bug 3882620
3830 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3831
3832 BEGIN
3833
3834 select line_id,
3835 price_flag
3836 into l_line_id,
3837 l_price_flag
3838 from qp_preq_lines_tmp
3839 where line_id = p_line_id
3840 and line_type_code = 'LINE'
3841 and price_flag in ('Y', 'P')
3842 and process_status <> 'NOT_VALID'
3843 and pricing_status_code in (QP_PREQ_PUB.G_STATUS_UPDATED,
3844 QP_PREQ_PUB.G_STATUS_GSA_VIOLATION);
3845
3846 DELETE FROM OE_PRICE_ADJUSTMENTS
3847 WHERE HEADER_ID=oe_order_pub.g_hdr.header_id
3848 AND LINE_ID=p_line_id
3849 AND NVL(UPDATED_FLAG, 'N')='N'
3850 AND PRICING_PHASE_ID IN (select b.pricing_phase_id
3851 from qp_event_phases a,
3852 qp_pricing_phases b
3853 where instr(p_pricing_events, a.pricing_event_code||',') > 0
3854 and b.pricing_phase_id = a.pricing_phase_id
3855 and nvl(b.user_freeze_override_flag,b.freeze_override_flag)
3856 = decode(l_price_flag, 'Y', nvl(b.user_freeze_override_flag,b.freeze_override_flag), 'P', 'Y'))
3857 AND LINE_ID = p_line_id
3858 --AND LIST_LINE_TYPE_CODE NOT IN ('TAX','IUE') --bug 2858712 --Bug 13573144
3859 AND LIST_LINE_TYPE_CODE NOT IN ('TAX','IUE','TSN') --Bug 13573144
3860 AND list_line_id not in (select list_line_id
3861 from qp_ldets_v ld
3862 where ld.process_code in
3863 (QP_PREQ_GRP.G_STATUS_UPDATED,
3864 QP_PREQ_GRP.G_STATUS_UNCHANGED,
3865 QP_PREQ_PUB.G_STATUS_NEW)
3866 and (ld.applied_flag = 'Y'
3867 OR
3868 (nvl(ld.applied_flag,'N') = 'N'
3869 AND
3870 nvl(ld.line_detail_type_code,'x') = 'CHILD_DETAIL_LINE'
3871 )
3872 )
3873 )
3874 returning price_adjustment_id,
3875 header_id,
3876 line_id,
3877 list_line_id,
3878 list_header_id,
3879 list_line_type_code,
3880 applied_flag,
3881 adjusted_amount
3882 bulk collect into
3883 l_adj_id_tbl,
3884 l_header_id_tbl,
3885 l_line_id_tbl,
3886 l_list_line_id_tbl,
3887 l_list_header_id_tbl,
3888 l_list_line_type_code_tbl,
3889 l_applied_flag_tbl,
3890 l_adjusted_amount_tbl;
3891
3892 IF l_debug_level > 0 THEN
3893 oe_debug_pub.add( 'DELETED '||SQL%ROWCOUNT||' LINE LEVEL ADJUSTMENTS/CHARGES' , 3 ) ;
3894 END IF;
3895 DELETE_DEPENDENTS(l_adj_id_tbl,l_header_id_tbl,l_line_id_tbl,l_list_line_id_tbl,l_list_header_id_tbl,l_list_line_type_code_tbl,l_applied_flag_tbl,l_adjusted_amount_tbl);
3896
3897 END DELETE_ONE_LINE_ADJS;
3898 ---bug 3740009
3899
3900
3901 --bug 3836854
3902 PROCEDURE update_adj(
3903 p_price_adjustment_id IN NUMBER
3904 ,p_line_detail_index IN NUMBER
3905 ,px_debug_upd_adj_tbl OUT NOCOPY NUMBER_TYPE
3906 )
3907 IS
3908
3909 l_price_adjustment_id NUMBER;
3910 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3911
3912 BEGIN
3913
3914 IF l_debug_level > 0 THEN
3915 oe_debug_pub.add('entering procedure update_adj');
3916 oe_debug_pub.add('p_price_adjustment_id : '||p_price_adjustment_id);
3917 oe_debug_pub.add('p_line_detail_index : '||p_line_detail_index);
3918 END IF;
3919
3920 --bug 5497035
3921 BEGIN
3922
3923 SELECT price_adjustment_id
3924 INTO l_price_adjustment_id
3925 FROM oe_price_adjustments
3926 WHERE price_adjustment_id = p_price_adjustment_id
3927 FOR UPDATE NOWAIT;
3928
3929 IF l_debug_level > 0 Then
3930 oe_Debug_pub.add('Adjustment row successfully locked');
3931 END IF;
3932
3933 EXCEPTION
3934 WHEN APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION THEN
3935 IF l_debug_level > 0 THEN
3936 oe_debug_pub.add('in lock record exception, someone else working on the row');
3937 END IF;
3938 FND_MESSAGE.SET_NAME('ONT','OE_LOCK_ROW_ALREADY_LOCKED');
3939 OE_MSG_PUB.Add;
3940 RAISE FND_API.G_EXC_ERROR;
3941
3942 WHEN NO_DATA_FOUND THEN
3943 IF l_debug_level > 0 THEN
3944 oe_debug_pub.add('no_data_found, record lock exception');
3945 END IF;
3946 --bug 5709185 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3947
3948 WHEN OTHERS THEN
3949 IF l_debug_level > 0 THEN
3950 oe_debug_pub.add('record lock exception, others');
3951 END IF;
3952 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3953
3954 END;
3955 --bug 5497035
3956
3957 UPDATE OE_PRICE_ADJUSTMENTS adj
3958 SET ( operand
3959 , operand_per_pqty
3960 , adjusted_amount
3961 , adjusted_amount_per_pqty
3962 , arithmetic_operator
3963 , pricing_phase_id
3964 , pricing_group_sequence
3965 , automatic_flag
3966 , list_line_type_code
3967 --, applied_flag
3968 , modified_from
3969 , modified_to
3970 , update_allowed
3971 --, modifier_mechanism_type_code
3972 --, updated_flag
3973 , charge_type_code
3974 , charge_subtype_code
3975 , range_break_quantity
3976 , accrual_conversion_rate
3977 , accrual_flag
3978 , list_line_no
3979 --, source_system_code
3980 , benefit_qty
3981 , benefit_uom_code
3982 , print_on_invoice_flag
3983 , expiration_date
3984 , rebate_transaction_type_code
3985 --, rebate_transaction_reference
3986 --, rebate_payment_system_code
3987 --, redeemed_date
3988 --, redeemed_Flag
3989 , modifier_level_code
3990 , price_break_type_code
3991 , substitution_attribute
3992 , proration_type_code
3993 , include_on_returns_flag
3994 , lock_control
3995 --bug#7369643
3996 --This code is added to update the last update information in who columns
3997 , LAST_UPDATE_DATE
3998 , LAST_UPDATED_BY
3999 , LAST_UPDATE_LOGIN
4000 --bug#7369643
4001 )
4002 =
4003 (select
4004 ldets.order_qty_operand
4005 , ldets.operand_value
4006 , ldets.order_qty_adj_amt
4007 , ldets.adjustment_amount
4008 , ldets.operand_calculation_code
4009 , ldets.pricing_phase_id
4010 , ldets.pricing_group_sequence
4011 , ldets.automatic_flag
4012 , ldets.list_line_type_code
4013 --, ldets.applied_flag
4014 --, decode(ldets.list_line_type_code, 'TSN', ldets.substitution_attribute,'IUE', to_char(ldets.inventory_item_id), NULL) --Bug 13573144
4015 , decode(ldets.list_line_type_code, 'TSN', modified_from, 'IUE', to_char(ldets.inventory_item_id), NULL) --Bug 13573144
4016 , decode(ldets.list_line_type_code, 'TSN', ldets.substitution_value_to,'IUE',to_char(ldets.related_item_id), NULL)
4017 , ldets.override_flag
4018 --, modifier_mechanism_type_code
4019 --, ldets.updated_flag
4020 , ldets.charge_type_code
4021 , ldets.charge_subtype_code
4022 , ldets.line_quantity --range_break_quantity (?)
4023 , ldets.accrual_conversion_rate
4024 , ldets.accrual_flag
4025 , ldets.list_line_no
4026 --, source_system_code
4027 , ldets.benefit_qty
4028 , ldets.benefit_uom_code
4029 , ldets.print_on_invoice_flag
4030 , ldets.expiration_date
4031 , ldets.rebate_transaction_type_code
4032 --, rebate_transaction_reference
4033 --, rebate_payment_system_code
4034 --, redeemed_date
4035 --, redeemed_Flag
4036 , ldets.modifier_level_code
4037 , ldets.price_break_type_code
4038 , ldets.substitution_attribute
4039 , ldets.proration_type_code
4040 , ldets.include_on_returns_flag
4041 , adj.lock_control + 1
4042 --bug#7369643
4043 --This code is added to update the last update information in who columns
4044 , sysdate
4045 , fnd_global.user_id
4046 , fnd_global.LOGIN_ID
4047 --bug#7369643
4048 from
4049 QP_LDETS_v ldets
4050 where ldets.line_detail_index = p_line_detail_index
4051 )
4052 where adj.price_adjustment_id = p_price_adjustment_id
4053 returning adj.list_line_id bulk collect into px_debug_upd_adj_tbl;
4054 IF l_debug_level > 0 THEN
4055 oe_debug_pub.add('exiting update_adj procedure');
4056 END IF;
4057 END update_adj;
4058 --bug 3836854
4059
4060 PROCEDURE REFRESH_ADJS(
4061 p_line_id IN NUMBER
4062 , p_pricing_events IN VARCHAR2
4063 , p_calculate_flag IN VARCHAR2
4064 , p_header_id IN Number default null
4065 ) IS
4066 l_adjustment_count NUMBER:=0;
4067
4068 l_adj_id_tbl Number_Type;
4069 l_debug_upd_order_adj_tbl Number_Type;
4070 l_debug_upd_line_adj_tbl Number_Type;
4071 l_line_detail_index_tbl Number_type;
4072 i number;
4073 l_pricing_events varchar2(40) := p_pricing_events||',';
4074 l_stmt number:=0;
4075 cursor del_attribs1 Is
4076 Select /*+ ORDERED USE_NL(ADJ LDETS) index(QPLINES QP_PREQ_LINES_TMP_N2) index(ADJ OE_PRICE_ADJUSTMENTS_N2)*/
4077 adj.price_adjustment_id, ldets.line_detail_index
4078 From QP_PREQ_LINES_TMP QPLINES
4079 ,OE_PRICE_ADJUSTMENTS ADJ
4080 ,QP_LDETS_V LDETS
4081 Where LDETS.LIST_LINE_ID = ADJ.LIST_LINE_ID
4082 AND LDETS.LINE_INDEX = QPLINES.LINE_INDEX
4083 AND ADJ.PRICING_PHASE_ID in (select pricing_phase_id from qp_event_phases
4084 -- where pricing_event_code = p_pricing_events)
4085 --changes to enable multiple events passed as a string
4086 where instr(l_pricing_events, pricing_event_code||',') > 0)
4087 AND LDETS.PROCESS_CODE in (QP_PREQ_GRP.G_STATUS_UNCHANGED,
4088 QP_PREQ_GRP.G_STATUS_UPDATED)
4089 AND nvl(ADJ.updated_flag,'N') = 'N'
4090 AND QPLINES.LINE_ID = ADJ.LINE_ID
4091 AND QPLINES.PROCESS_STATUS <> 'NOT_VALID'
4092 AND QPLINES.LINE_TYPE_CODE = 'LINE';
4093
4094 cursor del_attribs2(p_hdr_line_index in number, p_hdr_line_id in number) Is
4095 Select ADJ.PRICE_ADJUSTMENT_ID, LDETS.LINE_DETAIL_INDEX
4096 From
4097 OE_PRICE_ADJUSTMENTS ADJ
4098 ,QP_LDETS_V LDETS
4099 Where LDETS.LIST_LINE_ID = ADJ.LIST_LINE_ID
4100 AND LDETS.LINE_INDEX = p_hdr_line_index
4101 AND ADJ.PRICING_PHASE_ID in (select pricing_phase_id from qp_event_phases
4102 -- where pricing_event_code = p_pricing_events)
4103 --changes to enable multiple events passed as a string
4104 where instr(l_pricing_events, pricing_event_code||',') > 0)
4105 AND LDETS.PROCESS_CODE in (QP_PREQ_GRP.G_STATUS_UNCHANGED,
4106 QP_PREQ_GRP.G_STATUS_UPDATED)
4107 AND nvl(ADJ.updated_flag,'N') = 'N'
4108 AND ADJ.HEADER_ID = p_hdr_line_id;
4109
4110 --pviprana: cursors retrieving the needed values from qp temp tables for debugging purpose *start*
4111 cursor debug_updatable_order_adj is
4112 select ldets.list_line_id,
4113 ldets.adjustment_amount,
4114 ldets.order_qty_adj_amt,
4115 ldets.order_qty_operand,
4116 ldets.operand_calculation_code,
4117 ldets.operand_value,
4118 lines.priced_quantity,
4119 lines.line_quantity,
4120 ldets.pricing_phase_id,
4121 ldets.pricing_group_sequence,
4122 ldets.automatic_flag,
4123 ldets.list_line_type_code,
4124 ldets.applied_flag,
4125 ldets.substitution_attribute,
4126 ldets.inventory_item_id,
4127 ldets.substitution_value_to,
4128 ldets.related_item_id,
4129 ldets.override_flag,
4130 ldets.updated_flag,
4131 ldets.charge_type_code,
4132 ldets.charge_subtype_code,
4133 ldets.accrual_conversion_rate,
4134 ldets.accrual_flag,
4135 ldets.list_line_no,
4136 ldets.benefit_qty,
4137 ldets.benefit_uom_code,
4138 ldets.print_on_invoice_flag,
4139 ldets.expiration_date,
4140 ldets.rebate_transaction_type_code,
4141 ldets.modifier_level_code,
4142 ldets.price_break_type_code,
4143 ldets.proration_type_code,
4144 ldets.include_on_returns_flag,
4145 adj.lock_control + 1 adj_lock_control
4146 from OE_PRICE_ADJUSTMENTS adj
4147 , QP_LDETS_v ldets
4148 , QP_PREQ_LINES_TMP lines
4149 WHERE
4150 adj.header_id=oe_order_pub.g_hdr.header_id
4151 and lines.line_index = ldets.line_index
4152 and lines.process_status <> 'NOT_VALID'
4153 and ldets.list_line_id = adj.list_line_id
4154 and lines.line_type_code='ORDER' and lines.line_id=adj.header_id
4155 and ldets.process_code = QP_PREQ_GRP.G_STATUS_UPDATED;
4156
4157 cursor debug_updatable_line_adj is
4158 select ldets.list_line_id,
4159 ldets.adjustment_amount,
4160 ldets.order_qty_adj_amt,
4161 ldets.order_qty_operand,
4162 ldets.operand_calculation_code,
4163 ldets.operand_value,
4164 lines.priced_quantity,
4165 lines.line_quantity,
4166 ldets.pricing_phase_id,
4167 ldets.pricing_group_sequence,
4168 ldets.automatic_flag,
4169 ldets.list_line_type_code,
4170 ldets.applied_flag,
4171 ldets.substitution_attribute,
4172 ldets.inventory_item_id,
4173 ldets.substitution_value_to,
4174 ldets.related_item_id,
4175 ldets.override_flag,
4176 ldets.updated_flag,
4177 ldets.charge_type_code,
4178 ldets.charge_subtype_code,
4179 ldets.accrual_conversion_rate,
4180 ldets.accrual_flag,
4181 ldets.list_line_no,
4182 ldets.benefit_qty,
4183 ldets.benefit_uom_code,
4184 ldets.print_on_invoice_flag,
4185 ldets.expiration_date,
4186 ldets.rebate_transaction_type_code,
4187 ldets.modifier_level_code,
4188 ldets.price_break_type_code,
4189 ldets.proration_type_code,
4190 ldets.include_on_returns_flag,
4191 adj.lock_control + 1 adj_lock_control
4192 from OE_PRICE_ADJUSTMENTS adj
4193 , QP_LDETS_v ldets
4194 , QP_PREQ_LINES_TMP lines
4195 WHERE
4196 adj.header_id=oe_order_pub.g_hdr.header_id
4197 and lines.line_index = ldets.line_index
4198 and lines.process_status <> 'NOT_VALID'
4199 and ldets.list_line_id = adj.list_line_id
4200 and lines.line_type_code='LINE' and lines.line_id=adj.line_id
4201 and ldets.process_code = QP_PREQ_GRP.G_STATUS_UPDATED;
4202
4203 --pviprana: cursors retrieving the needed values from qp temp tables for debugging purpose *end*
4204
4205 l_booked_flag varchar2(1) := oe_order_cache.g_header_rec.booked_flag;
4206
4207 --bug 3836854
4208 Cursor upd_adj(l_line_type IN Varchar2) Is
4209 select ldets2.price_adjustment_id, ldets2.line_detail_index
4210 from qp_ldets_v ldets2, QP_PREQ_LINES_TMP lines2
4211 where ldets2.process_code=QP_PREQ_GRP.G_STATUS_UPDATED
4212 AND lines2.pricing_status_code in (QP_PREQ_GRP.G_STATUS_NEW,QP_PREQ_GRP.G_STATUS_UPDATED,QP_PREQ_GRP.G_STATUS_GSA_VIOLATION)
4213 and lines2.process_status <> 'NOT_VALID'
4214 and lines2.line_index = ldets2.line_index
4215 and lines2.line_type_code = l_line_type
4216 AND (l_booked_flag = 'N' or ldets2.list_line_type_code<>'IUE');
4217 --bug 3836854
4218
4219 ---bug 3740009
4220 l_hdr_price_flag varchar2(1);
4221 l_hdr_line_index number;
4222 l_hdr_line_id number;
4223 l_hdr_pricing_status_code VARCHAR2(30);
4224 l_no_summary_line boolean := FALSE;
4225 ---bug 3740009
4226 --
4227 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4228 --
4229 BEGIN
4230
4231 IF l_debug_level > 0 THEN
4232 oe_debug_pub.add( 'INSIDE REFRESH_ADJS FOR LINE ID:'||P_LINE_ID|| ' EVENT:'||P_PRICING_EVENTS , 3 ) ;
4233 END IF;
4234
4235 ---bug 3740009
4236 BEGIN
4237 select price_flag,
4238 line_index,
4239 line_id,
4240 pricing_status_code
4241 into l_hdr_price_flag,
4242 l_hdr_line_index,
4243 l_hdr_line_id,
4244 l_hdr_pricing_status_code
4245 from
4246 qp_preq_lines_tmp
4247 where line_type_code = 'ORDER'
4248 and process_status <> 'NOT_VALID';
4249 EXCEPTION
4250 WHEN NO_DATA_FOUND THEN
4251 oe_debug_pub.add('No summary line');
4252 l_no_summary_line := TRUE;
4253 END;
4254 ---bug 3740009
4255
4256 --bug3654144
4257 IF nvl(G_PRICING_EVENT,'x-c1') <> 'RETROBILL' THEN
4258
4259 IF (p_calculate_flag <> QP_PREQ_GRP.G_CALCULATE_ONLY) THEN
4260 IF (p_LINE_id IS NULL) THEN
4261 ---bug 3740009
4262 delete_hdr_adjs(l_pricing_events,l_hdr_line_id,l_hdr_line_index,l_hdr_price_flag,l_hdr_pricing_status_code);
4263 delete_lines_adjs(l_pricing_events);
4264 ---bug 3740009
4265 -- header level adjustments
4266
4267 ELSE -- (p_LINE_ID IS NOT NULL)
4268
4269 ---bug 3740009
4270 delete_one_line_Adjs(p_line_id,l_pricing_events);
4271 ---bug 3740009
4272
4273 END IF; -- line_id is NULL
4274 END IF;
4275 --bug3654144 start
4276 ELSE
4277 OE_RETROBILL_PVT.Update_Invalid_Diff_Adj;
4278 END IF;
4279 --bug3654144 end
4280
4281 l_stmt:=6;
4282 --RT{
4283 IF nvl(G_PRICING_EVENT,'x-c1') <> 'RETROBILL' THEN
4284 --pviprana: Debug messages to show the contents in the qp temp tables
4285 -- THE FOLLOWING CURSORS RETRIEVE ALL THE NEEDED VALUES FROM QP TEMP TABLES
4286 -- PLEASE PRINT THE NEEDED VALUES FOR DEBUGGING PURPOSES
4287 IF l_debug_level > 0 THEN
4288 oe_debug_pub.add('UPDATABLE ORDER LEVEL ADJUSTMENTS :');
4289 FOR updble_order_adj IN debug_updatable_order_adj LOOP
4290 oe_debug_pub.add( '************************************************************************');
4291 oe_debug_pub.add('LIST_LINE_ID : '||updble_order_adj.list_line_id);
4292 oe_debug_pub.add('ORDER_QTY_ADJ_AMT: '||updble_order_adj.order_qty_adj_amt);
4293 oe_debug_pub.add('ADJUSTMENT_AMOUNT: '||updble_order_adj.adjustment_amount);
4294 oe_debug_pub.add( '************************************************************************');
4295 END LOOP;
4296 oe_debug_pub.add('UPDATABLE LINE LEVEL ADJUSTMENTS :');
4297 FOR updble_line_adj IN debug_updatable_line_adj LOOP
4298 oe_debug_pub.add( '************************************************************************');
4299 oe_debug_pub.add('LIST_LINE_ID : '||updble_line_adj.list_line_id);
4300 oe_debug_pub.add('ORDER_QTY_ADJ_AMT: '||updble_line_adj.order_qty_adj_amt);
4301 oe_debug_pub.add('ADJUSTMENT_AMOUNT: '||updble_line_adj.adjustment_amount);
4302 oe_debug_pub.add( '************************************************************************');
4303 END LOOP;
4304 END IF;
4305
4306 --bug 3836854
4307 for i in upd_adj('ORDER') loop
4308 IF l_debug_level > 0 THEN
4309 oe_debug_pub.add('within upd_adj cursor for order');
4310 oe_debug_pub.add('l_hdr_price_flag : '||l_hdr_price_flag);
4311 IF l_no_summary_line THEN
4312 oe_debug_pub.add('l_no_summary_line : '|| 'TRUE');
4313 ELSE
4314 oe_debug_pub.add('l_no_summary_line : '|| 'FALSE');
4315 END IF;
4316 END IF;
4317 IF nvl(l_hdr_price_flag,'N') <> 'N' OR NOT l_no_summary_line THEN
4318 IF l_debug_level > 0 THEN
4319 oe_debug_pub.add('within if l_hdr_price_flag');
4320 END IF;
4321 update_adj(i.price_adjustment_id, i.line_detail_index , l_debug_upd_order_adj_tbl);
4322 IF l_debug_level > 0 THEN
4323 oe_debug_pub.add('after update_adj order');
4324 END IF;
4325 END IF;
4326 IF l_debug_level > 0 THEN
4327 oe_debug_pub.add( 'UPDATED '||SQL%ROWCOUNT||' ORDER LEVEL ADJUSTMENTS' , 3 ) ;
4328 END IF;
4329 end loop;
4330
4331 for i in upd_adj('LINE') loop
4332 IF l_debug_level > 0 THEN
4333 oe_debug_pub.add('within upd_adj cursor for line');
4334 END IF;
4335 update_adj(i.price_adjustment_id, i.line_detail_index, l_debug_upd_line_adj_tbl);
4336 IF l_debug_level > 0 THEN
4337 oe_debug_pub.add('after update_adj for line');
4338 oe_debug_pub.add( 'UPDATED '||SQL%ROWCOUNT||' LINE LEVEL ADJUSTMENTS' , 3 ) ;
4339 END IF;
4340 end loop;
4341 --bug 3836854
4342
4343 --pviprana: printing the list_line_ids of order level adjustments that were updated
4344 IF l_debug_level > 0 THEN
4345 oe_debug_pub.add( '************************************************************************');
4346 oe_debug_pub.add('UPDATED ORDER LEVEL ADJ LIST LINE IDS ARE:');
4347 IF(l_debug_upd_order_adj_tbl.count > 0) THEN
4348 FOR i IN l_debug_upd_order_adj_tbl.FIRST..l_debug_upd_order_adj_tbl.LAST LOOP
4349 oe_debug_pub.add(l_debug_upd_order_adj_tbl(i));
4350 END LOOP;
4351 END IF;
4352 oe_debug_pub.add( '************************************************************************');
4353 END IF;
4354
4355
4356 IF l_debug_level > 0 THEN
4357 --pviprana: printing the list_line_ids of line level adjustments that were updated
4358 oe_debug_pub.add( '************************************************************************');
4359 oe_debug_pub.add('UPDATED LINE LEVEL ADJ LIST LINE IDS ARE:');
4360 IF(l_debug_upd_line_adj_tbl.count > 0) THEN
4361 FOR i IN l_debug_upd_line_adj_tbl.FIRST..l_debug_upd_line_adj_tbl.LAST LOOP
4362 oe_debug_pub.add(l_debug_upd_line_adj_tbl(i));
4363 END LOOP;
4364 END IF;
4365 oe_debug_pub.add( '************************************************************************');
4366 END IF;
4367
4368 IF (p_Calculate_Flag <> QP_PREQ_GRP.G_CALCULATE_ONLY) THEN
4369 l_stmt:=7;
4370 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
4371 OE_ADV_PRICE_PVT.Insert_Adj(p_header_id);
4372 ELSE
4373 INSERT INTO OE_PRICE_ADJUSTMENTS
4374 ( PRICE_ADJUSTMENT_ID
4375 , CREATION_DATE
4376 , CREATED_BY
4377 , LAST_UPDATE_DATE
4378 , LAST_UPDATED_BY
4379 , LAST_UPDATE_LOGIN
4380 , PROGRAM_APPLICATION_ID
4381 , PROGRAM_ID
4382 , PROGRAM_UPDATE_DATE
4383 , REQUEST_ID
4384 , HEADER_ID
4385 , DISCOUNT_ID
4386 , DISCOUNT_LINE_ID
4387 , AUTOMATIC_FLAG
4388 , PERCENT
4389 , LINE_ID
4390 , CONTEXT
4391 , ATTRIBUTE1
4392 , ATTRIBUTE2
4393 , ATTRIBUTE3
4394 , ATTRIBUTE4
4395 , ATTRIBUTE5
4396 , ATTRIBUTE6
4397 , ATTRIBUTE7
4398 , ATTRIBUTE8
4399 , ATTRIBUTE9
4400 , ATTRIBUTE10
4401 , ATTRIBUTE11
4402 , ATTRIBUTE12
4403 , ATTRIBUTE13
4404 , ATTRIBUTE14
4405 , ATTRIBUTE15
4406 , ORIG_SYS_DISCOUNT_REF
4407 , LIST_HEADER_ID
4408 , LIST_LINE_ID
4409 , LIST_LINE_TYPE_CODE
4410 , MODIFIER_MECHANISM_TYPE_CODE
4411 , MODIFIED_FROM
4412 , MODIFIED_TO
4413 , UPDATED_FLAG
4414 , UPDATE_ALLOWED
4415 , APPLIED_FLAG
4416 , CHANGE_REASON_CODE
4417 , CHANGE_REASON_TEXT
4418 , operand
4419 , Arithmetic_operator
4420 , COST_ID
4421 , TAX_CODE
4422 , TAX_EXEMPT_FLAG
4423 , TAX_EXEMPT_NUMBER
4424 , TAX_EXEMPT_REASON_CODE
4425 , PARENT_ADJUSTMENT_ID
4426 , INVOICED_FLAG
4427 , ESTIMATED_FLAG
4428 , INC_IN_SALES_PERFORMANCE
4429 , SPLIT_ACTION_CODE
4430 , ADJUSTED_AMOUNT
4431 , PRICING_PHASE_ID
4432 , CHARGE_TYPE_CODE
4433 , CHARGE_SUBTYPE_CODE
4434 , list_line_no
4435 , source_system_code
4436 , benefit_qty
4437 , benefit_uom_code
4438 , print_on_invoice_flag
4439 , expiration_date
4440 , rebate_transaction_type_code
4441 , rebate_transaction_reference
4442 , rebate_payment_system_code
4443 , redeemed_date
4444 , redeemed_flag
4445 , accrual_flag
4446 , range_break_quantity
4447 , accrual_conversion_rate
4448 , pricing_group_sequence
4449 , modifier_level_code
4450 , price_break_type_code
4451 , substitution_attribute
4452 , proration_type_code
4453 , CREDIT_OR_CHARGE_FLAG
4454 , INCLUDE_ON_RETURNS_FLAG
4455 , AC_CONTEXT
4456 , AC_ATTRIBUTE1
4457 , AC_ATTRIBUTE2
4458 , AC_ATTRIBUTE3
4459 , AC_ATTRIBUTE4
4460 , AC_ATTRIBUTE5
4461 , AC_ATTRIBUTE6
4462 , AC_ATTRIBUTE7
4463 , AC_ATTRIBUTE8
4464 , AC_ATTRIBUTE9
4465 , AC_ATTRIBUTE10
4466 , AC_ATTRIBUTE11
4467 , AC_ATTRIBUTE12
4468 , AC_ATTRIBUTE13
4469 , AC_ATTRIBUTE14
4470 , AC_ATTRIBUTE15
4471 , OPERAND_PER_PQTY
4472 , ADJUSTED_AMOUNT_PER_PQTY
4473 , LOCK_CONTROL
4474 )
4475 ( SELECT /*+ ORDERED USE_NL(ldets lines qh) */
4476 oe_price_adjustments_s.nextval -- p_Line_Adj_rec.price_adjustment_id
4477 , sysdate --p_Line_Adj_rec.creation_date
4478 , fnd_global.user_id --p_Line_Adj_rec.created_by
4479 , sysdate --p_Line_Adj_rec.last_update_date
4480 , fnd_global.user_id --p_Line_Adj_rec.last_updated_by
4481 , fnd_global.login_id --p_Line_Adj_rec.last_update_login
4482 , NULL --p_Line_Adj_rec.program_application_id
4483 , NULL --p_Line_Adj_rec.program_id
4484 , NULL --p_Line_Adj_rec.program_update_date
4485 , NULL --p_Line_Adj_rec.request_id
4486 , oe_order_pub.g_hdr.header_id --p_Line_Adj_rec.header_id
4487 , NULL --p_Line_Adj_rec.discount_id
4488 , NULL --p_Line_Adj_rec.discount_line_id
4489 , ldets.automatic_flag
4490 , NULL --p_Line_Adj_rec.percent
4491 , decode(ldets.modifier_level_code,'ORDER',NULL,lines.line_id)
4492 , NULL --p_Line_Adj_rec.context
4493 , NULL --p_Line_Adj_rec.attribute1
4494 , NULL --p_Line_Adj_rec.attribute2
4495 , NULL --p_Line_Adj_rec.attribute3
4496 , NULL --p_Line_Adj_rec.attribute4
4497 , NULL --p_Line_Adj_rec.attribute5
4498 , NULL --p_Line_Adj_rec.attribute6
4499 , NULL --p_Line_Adj_rec.attribute7
4500 , NULL --p_Line_Adj_rec.attribute8
4501 , NULL --p_Line_Adj_rec.attribute9
4502 , NULL --p_Line_Adj_rec.attribute10
4503 , NULL --p_Line_Adj_rec.attribute11
4504 , NULL --p_Line_Adj_rec.attribute12
4505 , NULL --p_Line_Adj_rec.attribute13
4506 , NULL --p_Line_Adj_rec.attribute14
4507 , NULL --p_Line_Adj_rec.attribute15
4508 , NULL --p_Line_Adj_rec.orig_sys_discount_ref
4509 , ldets.LIST_HEADER_ID
4510 , ldets.LIST_LINE_ID
4511 , ldets.LIST_LINE_TYPE_CODE
4512 , NULL --p_Line_Adj_rec.MODIFIER_MECHANISM_TYPE_CODE
4513 , decode(ldets.list_line_type_code, 'TSN', ldets.substitution_attribute, 'IUE', to_char(ldets.inventory_item_id), NULL)
4514 , decode(ldets.list_line_type_code, 'TSN', ldets.substitution_value_to, 'IUE', to_char(ldets.related_item_id), NULL)
4515 , 'N' --p_Line_Adj_rec.UPDATED_FLAG
4516 , ldets.override_flag
4517 , ldets.APPLIED_FLAG
4518 , NULL --p_Line_Adj_rec.CHANGE_REASON_CODE
4519 , NULL --p_Line_Adj_rec.CHANGE_REASON_TEXT
4520 , nvl(ldets.order_qty_operand, decode(ldets.operand_calculation_code,
4521 '%', ldets.operand_value,
4522 'LUMPSUM', ldets.operand_value,
4523 ldets.operand_value*lines.priced_quantity/lines.line_quantity))
4524 , ldets.operand_calculation_code --p_Line_Adj_rec.arithmetic_operator
4525 , NULl --p_line_Adj_rec.COST_ID
4526 , NULL --p_line_Adj_rec.TAX_CODE
4527 , NULL --p_line_Adj_rec.TAX_EXEMPT_FLAG
4528 , NULL --p_line_Adj_rec.TAX_EXEMPT_NUMBER
4529 , NULL --p_line_Adj_rec.TAX_EXEMPT_REASON_CODE
4530 , NULL --p_line_Adj_rec.PARENT_ADJUSTMENT_ID
4531 , NULL --p_line_Adj_rec.INVOICED_FLAG
4532 , NULL --p_line_Adj_rec.ESTIMATED_FLAG
4533 , NULL --p_line_Adj_rec.INC_IN_SALES_PERFORMANCE
4534 , NULL --p_line_Adj_rec.SPLIT_ACTION_CODE
4535 , nvl(ldets.order_qty_adj_amt, ldets.adjustment_amount*nvl(lines.priced_quantity,1)/nvl(lines.line_quantity,1))
4536 , ldets.pricing_phase_id --p_line_Adj_rec.PRICING_PHASE_ID
4537 , ldets.CHARGE_TYPE_CODE
4538 , ldets.CHARGE_SUBTYPE_CODE
4539 , ldets.list_line_no
4540 , qh.source_system_code
4541 , ldets.benefit_qty
4542 , ldets.benefit_uom_code
4543 , NULL --p_Line_Adj_rec.print_on_invoice_flag
4544 , ldets.expiration_date
4545 , ldets.rebate_transaction_type_code
4546 , NULL --p_Line_Adj_rec.rebate_transaction_reference
4547 , NULL --p_Line_Adj_rec.rebate_payment_system_code
4548 , NULL --p_Line_Adj_rec.redeemed_date
4549 , NULL --p_Line_Adj_rec.redeemed_flag
4550 , ldets.accrual_flag
4551 , ldets.line_quantity --p_Line_Adj_rec.range_break_quantity
4552 , ldets.accrual_conversion_rate
4553 , ldets.pricing_group_sequence
4554 , ldets.modifier_level_code
4555 , ldets.price_break_type_code
4556 , ldets.substitution_attribute
4557 , ldets.proration_type_code
4558 , NULL --p_Line_Adj_rec.credit_or_charge_flag
4559 , ldets.include_on_returns_flag
4560 , NULL -- p_Line_Adj_rec.ac_context
4561 , NULL -- p_Line_Adj_rec.ac_attribute1
4562 , NULL -- p_Line_Adj_rec.ac_attribute2
4563 , NULL -- p_Line_Adj_rec.ac_attribute3
4564 , NULL -- p_Line_Adj_rec.ac_attribute4
4565 , NULL -- p_Line_Adj_rec.ac_attribute5
4566 , NULL -- p_Line_Adj_rec.ac_attribute6
4567 , NULL -- p_Line_Adj_rec.ac_attribute7
4568 , NULL -- p_Line_Adj_rec.ac_attribute8
4569 , NULL -- p_Line_Adj_rec.ac_attribute9
4570 , NULL -- p_Line_Adj_rec.ac_attribute10
4571 , NULL -- p_Line_Adj_rec.ac_attribute11
4572 , NULL -- p_Line_Adj_rec.ac_attribute12
4573 , NULL -- p_Line_Adj_rec.ac_attribute13
4574 , NULL -- p_Line_Adj_rec.ac_attribute14
4575 , NULL -- p_Line_Adj_rec.ac_attribute15
4576 , ldets.OPERAND_value
4577 , ldets.adjustment_amount
4578 , 1
4579 FROM
4580 QP_LDETS_v ldets
4581 , QP_PREQ_LINES_TMP lines
4582 , QP_LIST_HEADERS_B QH
4583 WHERE
4584 ldets.list_header_id=qh.list_header_id
4585 AND ldets.process_code=QP_PREQ_GRP.G_STATUS_NEW
4586 AND lines.pricing_status_code in (QP_PREQ_GRP.G_STATUS_NEW,QP_PREQ_GRP.G_STATUS_UPDATED,QP_PREQ_GRP.G_STATUS_GSA_VIOLATION)
4587 AND lines.process_status <> 'NOT_VALID'
4588 AND ldets.line_index=lines.line_index
4589 --AND ldets.pricing_status_code = QP_PREQ_GRP.G_STATUS_NEW
4590 AND nvl(ldets.automatic_flag,'N') = 'Y'
4591 -- or
4592 -- (ldets.list_line_type_code = 'FREIGHT_CHARGE'))
4593 AND ldets.created_from_list_type_code not in ('PRL','AGR')
4594 AND ldets.list_line_type_code<>'PLL'
4595 AND (l_booked_flag = 'N' or ldets.list_line_type_code<>'IUE')
4596 );
4597
4598
4599 IF l_debug_level > 0 THEN
4600 oe_debug_pub.add( 'INSERTED '||SQL%ROWCOUNT||' ADJUSTMENTS' , 3 ) ;
4601 END IF;
4602
4603 /*Insert ASSO for header level adj
4604 * Comment out--Not possible to have header level adjustments with associations
4605 INSERT INTO OE_PRICE_ADJ_ASSOCS
4606 ( PRICE_ADJUSTMENT_ID
4607 ,CREATION_DATE
4608 ,CREATED_BY
4609 ,LAST_UPDATE_DATE
4610 ,LAST_UPDATED_BY
4611 ,LAST_UPDATE_LOGIN
4612 ,PROGRAM_APPLICATION_ID
4613 ,PROGRAM_ID
4614 ,PROGRAM_UPDATE_DATE
4615 ,REQUEST_ID
4616 ,PRICE_ADJ_ASSOC_ID
4617 ,LINE_ID
4618 ,RLTD_PRICE_ADJ_ID
4619 ,LOCK_CONTROL
4620 )
4621 (SELECT *+ ORDERED USE_NL(ADJ RADJ) *
4622 adj.price_adjustment_id
4623 ,sysdate --p_Line_Adj_Assoc_Rec.creation_date
4624 ,fnd_global.user_id --p_Line_Adj_Assoc_Rec.CREATED_BY
4625 ,sysdate --p_Line_Adj_Assoc_Rec.LAST_UPDATE_DATE
4626 ,fnd_global.user_id --p_Line_Adj_Assoc_Rec.LAST_UPDATED_BY
4627 ,fnd_global.login_id --p_Line_Adj_Assoc_Rec.LAST_UPDATE_LOGIN
4628 ,NULL --p_Line_Adj_Assoc_Rec.PROGRAM_APPLICATION_ID
4629 ,NULL --p_Line_Adj_Assoc_Rec.PROGRAM_ID
4630 ,NULL --p_Line_Adj_Assoc_Rec.PROGRAM_UPDATE_DATE
4631 ,NULL --p_Line_Adj_Assoc_Rec.REQUEST_ID
4632 ,OE_PRICE_ADJ_ASSOCS_S.nextval
4633 ,ADJ.LINE_ID
4634 ,RADJ.PRICE_ADJUSTMENT_ID
4635 ,1
4636 FROM QP_PREQ_RLTD_LINES_TMP RLTD ,
4637 OE_PRICE_ADJUSTMENTS ADJ,
4638 OE_PRICE_ADJUSTMENTS RADJ,
4639 QP_PREQ_LINES_TMP QPL
4640 WHERE
4641 ADJ.HEADER_ID = RLTD.LINE_INDEX AND
4642 ADJ.LIST_LINE_ID = RLTD.LIST_LINE_ID AND
4643 RADJ.HEADER_ID = RLTD.RELATED_LINE_INDEX AND
4644 RADJ.LIST_LINE_ID = RLTD.RELATED_LIST_LINE_ID AND
4645 RADJ.HEADER_ID = ADJ.HEADER_ID AND
4646 RLTD.PRICING_STATUS_CODE = 'N' AND
4647 QPL.LINE_INDEX = RLTD.LINE_INDEX AND
4648 QPL.LINE_TYPE_CODE = 'ORDER');
4649 */
4650 l_stmt:=8;
4651 INSERT INTO OE_PRICE_ADJ_ASSOCS
4652 ( PRICE_ADJUSTMENT_ID
4653 ,CREATION_DATE
4654 ,CREATED_BY
4655 ,LAST_UPDATE_DATE
4656 ,LAST_UPDATED_BY
4657 ,LAST_UPDATE_LOGIN
4658 ,PROGRAM_APPLICATION_ID
4659 ,PROGRAM_ID
4660 ,PROGRAM_UPDATE_DATE
4661 ,REQUEST_ID
4662 ,PRICE_ADJ_ASSOC_ID
4663 ,LINE_ID
4664 ,RLTD_PRICE_ADJ_ID
4665 ,LOCK_CONTROL
4666 )
4667 (SELECT /*+ ORDERED USE_NL(QPL ADJ RADJ) */
4668 adj.price_adjustment_id
4669 ,sysdate --p_Line_Adj_Assoc_Rec.creation_date
4670 ,fnd_global.user_id --p_Line_Adj_Assoc_Rec.CREATED_BY
4671 ,sysdate --p_Line_Adj_Assoc_Rec.LAST_UPDATE_DATE
4672 ,fnd_global.user_id --p_Line_Adj_Assoc_Rec.LAST_UPDATED_BY
4673 ,fnd_global.login_id --p_Line_Adj_Assoc_Rec.LAST_UPDATE_LOGIN
4674 ,NULL --p_Line_Adj_Assoc_Rec.PROGRAM_APPLICATION_ID
4675 ,NULL --p_Line_Adj_Assoc_Rec.PROGRAM_ID
4676 ,NULL --p_Line_Adj_Assoc_Rec.PROGRAM_UPDATE_DATE
4677 ,NULL --p_Line_Adj_Assoc_Rec.REQUEST_ID
4678 ,OE_PRICE_ADJ_ASSOCS_S.nextval
4679 ,ADJ.LINE_ID
4680 ,RADJ.PRICE_ADJUSTMENT_ID
4681 ,1
4682 FROM
4683 QP_PREQ_RLTD_LINES_TMP RLTD,
4684 QP_PREQ_LINES_TMP QPL,
4685 OE_PRICE_ADJUSTMENTS ADJ,
4686 OE_PRICE_ADJUSTMENTS RADJ
4687 WHERE QPL.LINE_INDEX = RLTD.LINE_INDEX AND
4688 QPL.LINE_ID = ADJ.LINE_ID AND
4689 QPL.LINE_TYPE_CODE = 'LINE' AND
4690 QPL.PROCESS_STATUS <> 'NOT_VALID' AND
4691 RLTD.LIST_LINE_ID = ADJ.LIST_LINE_ID AND
4692 RLTD.RELATED_LINE_INDEX = QPL.LINE_INDEX AND
4693 RLTD.RELATED_LIST_LINE_ID = RADJ.LIST_LINE_ID AND
4694 ADJ.LINE_ID = RADJ.LINE_ID AND
4695 RADJ.PRICE_ADJUSTMENT_ID
4696 NOT IN (SELECT RLTD_PRICE_ADJ_ID
4697 FROM OE_PRICE_ADJ_ASSOCS
4698 WHERE PRICE_ADJUSTMENT_ID = ADJ.PRICE_ADJUSTMENT_ID ) AND
4699 RLTD.PRICING_STATUS_CODE = 'N');
4700
4701
4702 IF l_debug_level > 0 THEN
4703 oe_debug_pub.add( 'INSERTED '||SQL%ROWCOUNT||' PRICE ADJ ASSOCS' , 3 ) ;
4704 END IF;
4705
4706 End If; -- insert_adj
4707
4708 l_adj_id_tbl.delete;
4709
4710 open del_attribs1;
4711 fetch del_attribs1 Bulk Collect into l_adj_id_tbl, l_line_detail_index_tbl;
4712
4713 If l_adj_id_tbl.count > 0 Then
4714 l_stmt:=9;
4715 FORALL i IN l_adj_id_tbl.FIRST..l_adj_id_tbl.LAST
4716 DELETE FROM OE_PRICE_ADJ_ATTRIBS WHERE price_adjustment_id = l_adj_id_tbl(i)
4717 AND ( pricing_context
4718 , pricing_attribute
4719 , pricing_attr_value_from
4720 , pricing_attr_value_to)
4721 not in (select qplat.context
4722 , qplat.attribute
4723 , qplat.setup_value_from
4724 , qplat.setup_value_to
4725 FROM QP_PREQ_LINE_ATTRS_TMP QPLAT
4726 -- , QP_PREQ_LDETS_TMP LDETS
4727 -- , OE_PRICE_ADJUSTMENTS ADJ
4728 WHERE QPLAT.pricing_status_code=QP_PREQ_PUB.G_STATUS_NEW
4729 --AND QPLAT.LINE_INDEX = ADJ.HEADER_ID + nvl(ADJ.LINE_ID, 0)
4730 --AND QPLAT.LINE_DETAIL_INDEX = LDETS.LINE_DETAIL_INDEX
4731 AND QPLAT.LINE_DETAIL_INDEX = l_line_detail_index_tbl(i)
4732 --AND QPLAT.LINE_INDEX = LDETS.LINE_INDEX
4733 --AND LDETS.LIST_LINE_ID=ADJ.LIST_LINE_ID
4734 --AND LDETS.LIST_LINE_ID = l_list_line_id_tbl(i)
4735 --AND LDETS.PROCESS_CODE IN (QP_PREQ_PUB.G_STATUS_UNCHANGED,
4736 -- QP_PREQ_PUB.G_STATUS_UPDATED)
4737 --AND LDETS.LINE_INDEX = ADJ.HEADER_ID + ADJ.LINE_ID
4738 --AND LDETS.LINE_INDEX = oe_order_pub.g_hdr.header_id + l_line_id_tbl(i)
4739 --AND ADJ.PRICE_ADJUSTMENT_ID = l_adj_id_tbl(i)
4740 ) ;
4741 IF l_debug_level > 0 THEN
4742 oe_debug_pub.add( 'DELETED '||SQL%ROWCOUNT||' ATTRIBUTES' ) ;
4743 END IF;
4744 l_stmt:=10;
4745 FORALL i IN l_adj_id_tbl.FIRST..l_adj_id_tbl.LAST
4746 INSERT INTO OE_PRICE_ADJ_ATTRIBS
4747 ( PRICE_ADJUSTMENT_ID
4748 ,PRICING_CONTEXT
4749 ,PRICING_ATTRIBUTE
4750 ,CREATION_DATE
4751 ,CREATED_BY
4752 ,LAST_UPDATE_DATE
4753 ,LAST_UPDATED_BY
4754 ,LAST_UPDATE_LOGIN
4755 ,PROGRAM_APPLICATION_ID
4756 ,PROGRAM_ID
4757 ,PROGRAM_UPDATE_DATE
4758 ,REQUEST_ID
4759 ,PRICING_ATTR_VALUE_FROM
4760 ,PRICING_ATTR_VALUE_TO
4761 ,COMPARISON_OPERATOR
4762 ,FLEX_TITLE
4763 ,PRICE_ADJ_ATTRIB_ID
4764 ,LOCK_CONTROL
4765 )
4766 (SELECT /*+ index (QPLAT QP_PREQ_LINE_ATTRS_TMP_N3) */
4767 l_adj_id_tbl(i) --ADJ.PRICE_ADJUSTMENT_ID
4768 ,QPLAT.CONTEXT
4769 ,QPLAT.ATTRIBUTE
4770 ,sysdate
4771 ,fnd_global.user_id
4772 ,sysdate
4773 ,fnd_global.user_id
4774 ,fnd_global.login_id
4775 ,NULL
4776 ,NULL
4777 ,NULL
4778 ,NULL
4779 ,QPLAT.SETUP_VALUE_FROM --VALUE_FROM
4780 ,QPLAT.SETUP_VALUE_TO --VALUE_TO
4781 ,QPLAT.COMPARISON_OPERATOR_TYPE_CODE
4782 ,decode(QPLAT.ATTRIBUTE_TYPE,
4783 'QUALIFIER','QP_ATTR_DEFNS_QUALIFIER',
4784 'QP_ATTR_DEFNS_PRICING')
4785 ,OE_PRICE_ADJ_ATTRIBS_S.nextval
4786 ,1
4787 FROM QP_PREQ_LINE_ATTRS_TMP QPLAT
4788 -- , QP_LDETS_v LDETS
4789 -- , OE_PRICE_ADJUSTMENTS ADJ
4790 WHERE QPLAT.pricing_status_code=QP_PREQ_PUB.G_STATUS_NEW
4791 --AND LDETS.LINE_INDEX = ADJ.HEADER_ID + ADJ.LINE_ID
4792 --AND QPLAT.LINE_DETAIL_INDEX = LDETS.LINE_DETAIL_INDEX
4793 AND QPLAT.LINE_DETAIL_INDEX = l_line_detail_index_tbl(i)
4794 --AND QPLAT.LINE_INDEX = LDETS.LINE_INDEX
4795 --AND LDETS.LIST_LINE_ID=ADJ.LIST_LINE_ID
4796 --AND LDETS.PROCESS_CODE in (QP_PREQ_PUB.G_STATUS_UNCHANGED,
4797 -- QP_PREQ_PUB.G_STATUS_UPDATED)
4798 --AND ADJ.PRICE_ADJUSTMENT_ID = l_adj_id_tbl(i)
4799 AND ( qplat.context
4800 , qplat.attribute
4801 , qplat.setup_value_from
4802 , qplat.setup_value_to)
4803 not in (select pricing_context
4804 , pricing_attribute
4805 , pricing_attr_value_from
4806 , pricing_attr_value_to
4807 FROM OE_PRICE_ADJ_ATTRIBS
4808 WHERE PRICE_ADJUSTMENT_ID = l_adj_id_tbl(i)
4809 ));
4810 IF l_debug_level > 0 THEN
4811 oe_debug_pub.add( 'INSERTED '||SQL%ROWCOUNT||' CHANGED ATTRIBS' ) ;
4812 END IF;
4813 End If;
4814 close del_attribs1;
4815 l_stmt:=11;
4816 l_adj_id_tbl.delete;
4817 l_line_detail_index_tbl.delete;
4818
4819 open del_attribs2(l_hdr_line_index, l_hdr_line_id);
4820 fetch del_attribs2 Bulk Collect into l_adj_id_tbl, l_line_detail_index_tbl;
4821
4822 If l_adj_id_tbl.count > 0 Then
4823 FORALL i IN l_adj_id_tbl.FIRST..l_adj_id_tbl.LAST
4824 DELETE FROM OE_PRICE_ADJ_ATTRIBS WHERE price_adjustment_id = l_adj_id_tbl(i)
4825 AND ( pricing_context
4826 , pricing_attribute
4827 , pricing_attr_value_from
4828 , pricing_attr_value_to)
4829 not in (select qplat.context
4830 , qplat.attribute
4831 , qplat.setup_value_from
4832 , qplat.setup_value_to
4833 FROM QP_PREQ_LINE_ATTRS_TMP QPLAT
4834 -- , QP_LDETS_v LDETS
4835 -- , OE_PRICE_ADJUSTMENTS ADJ
4836 WHERE QPLAT.pricing_status_code=QP_PREQ_PUB.G_STATUS_NEW
4837 --AND QPLAT.LINE_INDEX = ADJ.HEADER_ID + nvl(ADJ.LINE_ID, 0)
4838 --AND QPLAT.LINE_DETAIL_INDEX = LDETS.LINE_DETAIL_INDEX
4839 AND QPLAT.LINE_DETAIL_INDEX = l_line_detail_index_tbl(i)
4840 --AND QPLAT.LINE_INDEX = LDETS.LINE_INDEX
4841 --AND LDETS.LIST_LINE_ID=ADJ.LIST_LINE_ID
4842 --AND LDETS.PROCESS_CODE IN (QP_PREQ_PUB.G_STATUS_UNCHANGED,
4843 -- QP_PREQ_PUB.G_STATUS_UPDATED)
4844 --AND LDETS.LINE_INDEX = ADJ.HEADER_ID
4845 --AND ADJ.PRICE_ADJUSTMENT_ID = l_adj_id_tbl(i)
4846 ) ;
4847 IF l_debug_level > 0 THEN
4848 oe_debug_pub.add( 'DELETED '||SQL%ROWCOUNT||'ORDER ADJ LEVEL ATTRIBUTES' ) ;
4849 END IF;
4850 l_stmt:=12;
4851 FORALL i IN l_adj_id_tbl.FIRST..l_adj_id_tbl.LAST
4852 INSERT INTO OE_PRICE_ADJ_ATTRIBS
4853 ( PRICE_ADJUSTMENT_ID
4854 ,PRICING_CONTEXT
4855 ,PRICING_ATTRIBUTE
4856 ,CREATION_DATE
4857 ,CREATED_BY
4858 ,LAST_UPDATE_DATE
4859 ,LAST_UPDATED_BY
4860 ,LAST_UPDATE_LOGIN
4861 ,PROGRAM_APPLICATION_ID
4862 ,PROGRAM_ID
4863 ,PROGRAM_UPDATE_DATE
4864 ,REQUEST_ID
4865 ,PRICING_ATTR_VALUE_FROM
4866 ,PRICING_ATTR_VALUE_TO
4867 ,COMPARISON_OPERATOR
4868 ,FLEX_TITLE
4869 ,PRICE_ADJ_ATTRIB_ID
4870 ,LOCK_CONTROL
4871 )
4872 (SELECT /*+ index (QPLAT QP_PREQ_LINE_ATTRS_TMP_N3) */
4873 l_adj_id_tbl(i) --ADJ.PRICE_ADJUSTMENT_ID
4874 ,QPLAT.CONTEXT
4875 ,QPLAT.ATTRIBUTE
4876 ,sysdate
4877 ,fnd_global.user_id
4878 ,sysdate
4879 ,fnd_global.user_id
4880 ,fnd_global.login_id
4881 ,NULL
4882 ,NULL
4883 ,NULL
4884 ,NULL
4885 ,QPLAT.SETUP_VALUE_FROM --VALUE_FROM
4886 ,QPLAT.SETUP_VALUE_TO --VALUE_TO
4887 ,QPLAT.COMPARISON_OPERATOR_TYPE_CODE
4888 ,decode(QPLAT.ATTRIBUTE_TYPE,
4889 'QUALIFIER','QP_ATTR_DEFNS_QUALIFIER',
4890 'QP_ATTR_DEFNS_PRICING')
4891 ,OE_PRICE_ADJ_ATTRIBS_S.nextval
4892 ,1
4893 FROM QP_PREQ_LINE_ATTRS_TMP QPLAT
4894 --, QP_LDETS_v LDETS
4895 --, OE_PRICE_ADJUSTMENTS ADJ
4896 --, QP_PREQ_LINES_TMP QPL
4897 WHERE QPLAT.pricing_status_code=QP_PREQ_PUB.G_STATUS_NEW
4898 --AND QPLAT.LINE_DETAIL_INDEX = LDETS.LINE_DETAIL_INDEX
4899 AND QPLAT.LINE_DETAIL_INDEX = l_line_detail_index_tbl(i)
4900 --AND QPLAT.LINE_INDEX = LDETS.LINE_INDEX
4901 --AND LDETS.LIST_LINE_ID=ADJ.LIST_LINE_ID
4902 --AND LDETS.PROCESS_CODE in (QP_PREQ_PUB.G_STATUS_UNCHANGED,
4903 -- QP_PREQ_PUB.G_STATUS_UPDATED)
4904 --AND LDETS.LINE_INDEX = ADJ.HEADER_ID
4905 --AND ADJ.PRICE_ADJUSTMENT_ID = l_adj_id_tbl(i)
4906 AND ( qplat.context
4907 , qplat.attribute
4908 , qplat.setup_value_from
4909 , qplat.setup_value_to)
4910 not in (select pricing_context
4911 , pricing_attribute
4912 , pricing_attr_value_from
4913 , pricing_attr_value_to
4914 FROM OE_PRICE_ADJ_ATTRIBS
4915 WHERE PRICE_ADJUSTMENT_ID = l_adj_id_tbl(i)
4916 ));
4917 End If;
4918 close del_attribs2;
4919 l_stmt:=13;
4920 /* Delete price_adj_attribs for order level adj*/
4921 /*DELETE FROM Oe_Price_Adj_Attribs adjattrs
4922 WHERE exists
4923 (Select ADJ.PRICE_ADJUSTMENT_ID
4924 From QP_LDETS_V LDETS
4925 ,OE_PRICE_ADJUSTMENTS ADJ
4926 ,QP_PREQ_LINES_TMP QPLINES
4927 Where LDETS.LIST_LINE_ID = ADJ.LIST_LINE_ID
4928 AND LDETS.LINE_INDEX = QPLINES.LINE_INDEX
4929 AND QPLINES.LINE_TYPE_CODE = 'ORDER'
4930 AND QPLINES.LINE_ID = ADJ.HEADER_ID
4931 AND ADJ.price_adjustment_id = adjattrs.price_adjustment_id);*/
4932
4933 /* Delete price_adj_attribs for line level adj*/
4934 /*DELETE FROM Oe_Price_Adj_Attribs adjattrs
4935 WHERE exists
4936 (Select ADJ.PRICE_ADJUSTMENT_ID
4937 From QP_LDETS_V LDETS
4938 ,OE_PRICE_ADJUSTMENTS ADJ
4939 ,QP_PREQ_LINES_TMP QPLINES
4940 Where LDETS.LIST_LINE_ID = ADJ.LIST_LINE_ID
4941 AND LDETS.LINE_INDEX = QPLINES.LINE_INDEX
4942 AND QPLINES.LINE_ID = ADJ.LINE_ID
4943 AND QPLINES.LINE_TYPE_CODE = 'LINE'
4944 AND ADJ.price_adjustment_id = adjattrs.price_adjustment_id);*/
4945
4946 /* insert header level adjustment attributes */
4947 INSERT INTO OE_PRICE_ADJ_ATTRIBS
4948 ( PRICE_ADJUSTMENT_ID
4949 ,PRICING_CONTEXT
4950 ,PRICING_ATTRIBUTE
4951 ,CREATION_DATE
4952 ,CREATED_BY
4953 ,LAST_UPDATE_DATE
4954 ,LAST_UPDATED_BY
4955 ,LAST_UPDATE_LOGIN
4956 ,PROGRAM_APPLICATION_ID
4957 ,PROGRAM_ID
4958 ,PROGRAM_UPDATE_DATE
4959 ,REQUEST_ID
4960 ,PRICING_ATTR_VALUE_FROM
4961 ,PRICING_ATTR_VALUE_TO
4962 ,COMPARISON_OPERATOR
4963 ,FLEX_TITLE
4964 ,PRICE_ADJ_ATTRIB_ID
4965 ,LOCK_CONTROL
4966 )
4967 (SELECT ADJ.PRICE_ADJUSTMENT_ID
4968 ,QPLAT.CONTEXT
4969 ,QPLAT.ATTRIBUTE
4970 ,sysdate
4971 ,fnd_global.user_id
4972 ,sysdate
4973 ,fnd_global.user_id
4974 ,fnd_global.login_id
4975 ,NULL
4976 ,NULL
4977 ,NULL
4978 ,NULL
4979 ,QPLAT.SETUP_VALUE_FROM --VALUE_FROM
4980 ,QPLAT.SETUP_VALUE_TO --VALUE_TO
4981 ,QPLAT.COMPARISON_OPERATOR_TYPE_CODE
4982 ,decode(QPLAT.ATTRIBUTE_TYPE,
4983 'QUALIFIER','QP_ATTR_DEFNS_QUALIFIER',
4984 'QP_ATTR_DEFNS_PRICING')
4985 ,OE_PRICE_ADJ_ATTRIBS_S.nextval
4986 ,1
4987 FROM QP_PREQ_LINE_ATTRS_TMP QPLAT
4988 , QP_LDETS_v LDETS
4989 , OE_PRICE_ADJUSTMENTS ADJ
4990 WHERE QPLAT.pricing_status_code=QP_PREQ_PUB.G_STATUS_NEW
4991 -- AND LDETS.LINE_INDEX = ADJ.HEADER_ID
4992 AND ADJ.LINE_ID IS NULL
4993 AND ADJ.HEADER_ID = oe_order_pub.g_hdr.header_id
4994 AND QPLAT.LINE_DETAIL_INDEX = LDETS.LINE_DETAIL_INDEX
4995 AND QPLAT.LINE_INDEX = LDETS.LINE_INDEX
4996 AND LDETS.LIST_LINE_ID=ADJ.LIST_LINE_ID
4997 AND LDETS.PROCESS_CODE=QP_PREQ_PUB.G_STATUS_NEW
4998 AND LDETS.LINE_INDEX = l_hdr_line_index
4999 AND l_hdr_line_id = oe_order_pub.g_hdr.header_id
5000 --AND QPL.PRICING_STATUS_CODE IN (QP_PREQ_PUB.G_STATUS_UPDATED,
5001 -- QP_PREQ_PUB.G_STATUS_GSA_VIOLATION)
5002 );
5003 l_stmt:=14;
5004 --13582129 Start
5005 /*
5006 INSERT INTO OE_PRICE_ADJ_ATTRIBS
5007 ( PRICE_ADJUSTMENT_ID
5008 ,PRICING_CONTEXT
5009 ,PRICING_ATTRIBUTE
5010 ,CREATION_DATE
5011 ,CREATED_BY
5012 ,LAST_UPDATE_DATE
5013 ,LAST_UPDATED_BY
5014 ,LAST_UPDATE_LOGIN
5015 ,PROGRAM_APPLICATION_ID
5016 ,PROGRAM_ID
5017 ,PROGRAM_UPDATE_DATE
5018 ,REQUEST_ID
5019 ,PRICING_ATTR_VALUE_FROM
5020 ,PRICING_ATTR_VALUE_TO
5021 ,COMPARISON_OPERATOR
5022 ,FLEX_TITLE
5023 ,PRICE_ADJ_ATTRIB_ID
5024 ,LOCK_CONTROL
5025 )
5026 (SELECT ADJ.PRICE_ADJUSTMENT_ID
5027 ,QPLAT.CONTEXT
5028 ,QPLAT.ATTRIBUTE
5029 ,sysdate
5030 ,fnd_global.user_id
5031 ,sysdate
5032 ,fnd_global.user_id
5033 ,fnd_global.login_id
5034 ,NULL
5035 ,NULL
5036 ,NULL
5037 ,NULL
5038 ,QPLAT.SETUP_VALUE_FROM --VALUE_FROM
5039 ,QPLAT.SETUP_VALUE_TO --VALUE_TO
5040 ,QPLAT.COMPARISON_OPERATOR_TYPE_CODE
5041 ,decode(QPLAT.ATTRIBUTE_TYPE,
5042 'QUALIFIER','QP_ATTR_DEFNS_QUALIFIER',
5043 'QP_ATTR_DEFNS_PRICING')
5044 ,OE_PRICE_ADJ_ATTRIBS_S.nextval
5045 ,1
5046 FROM QP_PREQ_LINE_ATTRS_TMP QPLAT
5047 , QP_LDETS_v LDETS
5048 , OE_PRICE_ADJUSTMENTS ADJ
5049 , QP_PREQ_LINES_TMP QPLINE
5050 WHERE QPLAT.pricing_status_code=QP_PREQ_PUB.G_STATUS_NEW
5051 -- AND QPLAT.LINE_INDEX = ADJ.HEADER_ID+nvl(ADJ.LINE_ID,0)
5052 AND QPLAT.LINE_DETAIL_INDEX = LDETS.LINE_DETAIL_INDEX
5053 AND QPLAT.LINE_INDEX = LDETS.LINE_INDEX
5054 AND LDETS.LIST_LINE_ID=ADJ.LIST_LINE_ID
5055 AND LDETS.PROCESS_CODE=QP_PREQ_PUB.G_STATUS_NEW
5056 AND LDETS.LINE_INDEX = QPLINE.LINE_INDEX
5057 -- AND ADJ.HEADER_ID = oe_order_pub.g_hdr.header_id
5058 AND QPLINE.LINE_ID = ADJ.LINE_ID
5059 AND QPLINE.LINE_TYPE_CODE = 'LINE'
5060 AND QPLINE.PRICING_STATUS_CODE IN (QP_PREQ_PUB.G_STATUS_UPDATED,
5061 QP_PREQ_PUB.G_STATUS_GSA_VIOLATION)
5062 AND QPLINE.PROCESS_STATUS <> 'NOT_VALID'
5063 );
5064 */
5065 INSERT INTO OE_PRICE_ADJ_ATTRIBS
5066 ( PRICE_ADJUSTMENT_ID
5067 ,PRICING_CONTEXT
5068 ,PRICING_ATTRIBUTE
5069 ,CREATION_DATE
5070 ,CREATED_BY
5071 ,LAST_UPDATE_DATE
5072 ,LAST_UPDATED_BY
5073 ,LAST_UPDATE_LOGIN
5074 ,PROGRAM_APPLICATION_ID
5075 ,PROGRAM_ID
5076 ,PROGRAM_UPDATE_DATE
5077 ,REQUEST_ID
5078 ,PRICING_ATTR_VALUE_FROM
5079 ,PRICING_ATTR_VALUE_TO
5080 ,COMPARISON_OPERATOR
5081 ,FLEX_TITLE
5082 ,PRICE_ADJ_ATTRIB_ID
5083 ,LOCK_CONTROL
5084 )
5085 (SELECT /*+ index (QPLAT QP_PREQ_LINE_ATTRS_TMP_N3) */
5086 ADJ.PRICE_ADJUSTMENT_ID
5087 ,QPLAT.CONTEXT
5088 ,QPLAT.ATTRIBUTE
5089 ,sysdate
5090 ,fnd_global.user_id
5091 ,sysdate
5092 ,fnd_global.user_id
5093 ,fnd_global.login_id
5094 ,NULL
5095 ,NULL
5096 ,NULL
5097 ,NULL
5098 ,QPLAT.SETUP_VALUE_FROM --VALUE_FROM
5099 ,QPLAT.SETUP_VALUE_TO --VALUE_TO
5100 ,QPLAT.COMPARISON_OPERATOR_TYPE_CODE
5101 ,decode(QPLAT.ATTRIBUTE_TYPE,
5102 'QUALIFIER','QP_ATTR_DEFNS_QUALIFIER',
5103 'QP_ATTR_DEFNS_PRICING')
5104 ,OE_PRICE_ADJ_ATTRIBS_S.nextval
5105 ,1
5106 FROM QP_PREQ_LINE_ATTRS_TMP QPLAT
5107 , QP_PREQ_LDETS_TMP LDETS
5108 , OE_PRICE_ADJUSTMENTS ADJ
5109 , QP_PREQ_LINES_TMP QPLINE
5110 WHERE QPLAT.pricing_status_code=QP_PREQ_PUB.G_STATUS_NEW
5111 AND QPLAT.LINE_DETAIL_INDEX = LDETS.LINE_DETAIL_INDEX
5112 AND QPLAT.LINE_INDEX = LDETS.LINE_INDEX
5113 AND LDETS.CREATED_FROM_LIST_LINE_ID=ADJ.LIST_LINE_ID
5114 AND LDETS.PRICING_STATUS_CODE = 'N'
5115 AND LDETS.PROCESS_CODE=QP_PREQ_PUB.G_STATUS_NEW
5116 AND LDETS.LINE_INDEX = QPLINE.LINE_INDEX
5117 AND QPLINE.LINE_ID = ADJ.LINE_ID
5118 AND QPLINE.LINE_ID = Nvl(p_line_id,QPLINE.LINE_ID) --15845679
5119 AND QPLINE.LINE_TYPE_CODE = 'LINE'
5120 AND QPLINE.PRICING_STATUS_CODE IN (QP_PREQ_PUB.G_STATUS_UPDATED,
5121 QP_PREQ_PUB.G_STATUS_GSA_VIOLATION)
5122 AND QPLINE.PROCESS_STATUS <> 'NOT_VALID'
5123 );
5124 --13582129 End
5125 IF l_debug_level > 0 THEN
5126 oe_debug_pub.add( 'INSERTED '||SQL%ROWCOUNT||' ATTRIBS' , 3 ) ;
5127 END IF;
5128 END IF;
5129
5130 ELSE
5131 --RETOBILL REQUEST EVENT
5132 --Different handling..
5133 oe_debug_pub.add('Retro:Calling Oe_Retrobill_Pvt.Process_Retrobill_Adjustments,Operation:'||G_RETROBILL_OPERATION);
5134 Oe_Retrobill_Pvt.Process_Retrobill_Adjustments(G_RETROBILL_OPERATION);
5135 END IF;
5136 --RT}
5137
5138 EXCEPTION
5139 WHEN NO_DATA_FOUND THEN
5140 NULL;
5141 WHEN OTHERS THEN
5142 IF l_debug_level > 0 THEN
5143 oe_debug_pub.add( 'WRONG IN REFRESH_ADJ'||SQLERRM||L_STMT , 1 ) ;
5144 END IF;
5145 raise fnd_api.g_exc_error;
5146
5147 End REFRESH_ADJS;
5148 --end AG change
5149
5150 -- AG change --
5151 procedure copy_Header_to_request(
5152 p_header_rec OE_Order_PUB.Header_Rec_Type
5153 ,px_req_line_tbl in out NOCOPY QP_PREQ_GRP.LINE_TBL_TYPE
5154 --,p_pricing_event varchar2
5155 ,p_Request_Type_Code varchar2
5156 ,p_calculate_price_flag varchar2
5157 ,px_line_index in out NOCOPY NUMBER
5158 )
5159 is
5160 l_req_line_rec QP_PREQ_GRP.LINE_REC_TYPE;
5161 --l_line_index pls_integer := px_req_line_tbl.count;
5162 --
5163 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5164 --
5165 begin
5166 G_STMT_NO := 'copy_Header_to_request#10';
5167 IF l_debug_level > 0 THEN
5168 oe_debug_pub.add( 'ENTERING OE_ORDER_PRICE_PVT.COPY_HEADER_TO_REQUEST' , 1 ) ;
5169 END IF;
5170
5171 --l_line_index := l_line_index+1;
5172 px_line_index := px_line_index+1;
5173 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
5174 px_req_line_tbl(px_line_index).line_id := p_Header_rec.header_id;
5175 px_req_line_tbl(px_line_index).LINE_TYPE_CODE := 'ORDER';
5176 END IF;
5177 l_req_line_rec.REQUEST_TYPE_CODE :=p_Request_Type_Code;
5178 --l_req_line_rec.PRICING_EVENT :=p_pricing_event;
5179 --l_req_line_rec.LIST_LINE_LEVEL_CODE :=p_Request_Type_Code;
5180 l_req_line_rec.LINE_INDEX := px_line_index; --p_header_rec.header_id;
5181 l_req_line_rec.LINE_TYPE_CODE := 'ORDER';
5182 -- Hold the header_id in line_id for 'HEADER' Records
5183 l_req_line_rec.line_id := p_Header_rec.header_id;
5184 if p_header_rec.pricing_date is null or
5185 p_header_rec.pricing_date = fnd_api.g_miss_date then
5186 l_req_line_rec.PRICING_EFFECTIVE_DATE := trunc(sysdate);
5187 Else
5188 l_req_line_rec.PRICING_EFFECTIVE_DATE := p_header_rec.pricing_date;
5189 End If;
5190 IF (QP_PREQ_GRP.G_MIN_PRICING_DATE IS NULL) THEN
5191 QP_PREQ_GRP.G_MIN_PRICING_DATE := TRUNC(l_req_line_rec.PRICING_EFFECTIVE_DATE);
5192 QP_PREQ_GRP.G_MAX_PRICING_DATE := TRUNC(l_req_line_rec.PRICING_EFFECTIVE_DATE);
5193 ELSE
5194 IF (TRUNC(l_req_line_rec.PRICING_EFFECTIVE_DATE)
5195 < TRUNC(QP_PREQ_GRP.G_MIN_PRICING_DATE))
5196 THEN
5197 QP_PREQ_GRP.G_MIN_PRICING_DATE := TRUNC(l_req_line_rec.PRICING_EFFECTIVE_DATE);
5198 END IF;
5199
5200 IF (TRUNC(l_req_line_rec.PRICING_EFFECTIVE_DATE)
5201 > TRUNC(QP_PREQ_GRP.G_MAX_PRICING_DATE))
5202 THEN
5203 QP_PREQ_GRP.G_MAX_PRICING_DATE := TRUNC(l_req_line_rec.PRICING_EFFECTIVE_DATE);
5204 END IF;
5205
5206 END IF;
5207 l_req_line_rec.CURRENCY_CODE := p_Header_rec.transactional_curr_code;
5208 QP_PREQ_GRP.G_CURRENCY_CODE := l_req_line_rec.currency_code;
5209 l_req_line_rec.PRICE_FLAG := p_calculate_price_flag;
5210 l_req_line_rec.Active_date_first_type := 'ORD';
5211 l_req_line_rec.Active_date_first := p_Header_rec.Ordered_date;
5212 If G_ROUNDING_FLAG = 'Y' Then
5213 l_req_line_rec.Rounding_factor
5214 := Get_Rounding_factor(p_Header_rec.price_list_id);
5215 End If;
5216
5217 G_LINE_INDEX_TBL(px_line_index) := l_req_line_rec.LINE_INDEX;
5218 G_LINE_TYPE_CODE_TBL(px_line_index) := l_req_line_rec.LINE_TYPE_CODE;
5219 G_PRICING_EFFECTIVE_DATE_TBL(px_line_index)
5220 := TRUNC(l_req_line_rec.PRICING_EFFECTIVE_DATE);
5221 G_ACTIVE_DATE_FIRST_TBL(px_line_index)
5222 := TRUNC(l_req_line_rec.ACTIVE_DATE_FIRST);
5223 G_ACTIVE_DATE_FIRST_TYPE_TBL(px_line_index)
5224 := l_req_line_rec.ACTIVE_DATE_FIRST_TYPE;
5225 G_ACTIVE_DATE_SECOND_TBL(px_line_index)
5226 := TRUNC(l_req_line_rec.ACTIVE_DATE_SECOND);
5227 G_ACTIVE_DATE_SECOND_TYPE_TBL(px_line_index)
5228 := l_req_line_rec.ACTIVE_DATE_SECOND_TYPE;
5229 G_LINE_QUANTITY_TBL(px_line_index) := l_req_line_rec.LINE_QUANTITY;
5230 G_LINE_UOM_CODE_TBL(px_line_index) := l_req_line_rec.LINE_UOM_CODE;
5231 G_REQUEST_TYPE_CODE_TBL(px_line_index) := l_req_line_rec.REQUEST_TYPE_CODE;
5232 G_PRICED_QUANTITY_TBL(px_line_index) := l_req_line_rec.PRICED_QUANTITY;
5233 G_UOM_QUANTITY_TBL(px_line_index) := l_req_line_rec.UOM_QUANTITY;
5234 G_CONTRACT_START_DATE_TBL(px_line_index) := l_req_line_rec.CONTRACT_START_DATE;
5235 G_CONTRACT_END_DATE_TBL(px_line_index) := l_req_line_rec.CONTRACT_END_DATE;
5236 G_PRICED_UOM_CODE_TBL(px_line_index) := l_req_line_rec.PRICED_UOM_CODE;
5237 G_CURRENCY_CODE_TBL(px_line_index) := l_req_line_rec.CURRENCY_CODE;
5238 G_UNIT_PRICE_TBL(px_line_index) := l_req_line_rec.unit_price; -- AG
5239 G_PERCENT_PRICE_TBL(px_line_index) := l_req_line_rec.PERCENT_PRICE;
5240 G_ADJUSTED_UNIT_PRICE_TBL(px_line_index) := l_req_line_rec.ADJUSTED_UNIT_PRICE;
5241 G_PROCESSED_FLAG_TBL(px_line_index) := QP_PREQ_GRP.G_NOT_PROCESSED;
5242 G_PRICE_FLAG_TBL(px_line_index) := l_req_line_rec.PRICE_FLAG;
5243 G_LINE_ID_TBL(px_line_index) := l_req_line_rec.LINE_ID;
5244 G_ROUNDING_FLAG_TBL(px_line_index)
5245 := G_ROUNDING_FLAG; -- AG
5246 G_ROUNDING_FACTOR_TBL(px_line_index) := l_req_line_rec.ROUNDING_FACTOR;
5247 G_PROCESSING_ORDER_TBL(px_line_index) := NULL;
5248 G_PRICING_STATUS_CODE_tbl(px_line_index) := QP_PREQ_GRP.G_STATUS_UNCHANGED;
5249 G_PRICING_STATUS_TEXT_tbl(px_line_index) := NULL;
5250
5251 G_QUALIFIERS_EXIST_FLAG_TBL(px_line_index) :='N';
5252 G_PRICING_ATTRS_EXIST_FLAG_TBL(px_line_index) :='N';
5253 G_PRICE_LIST_ID_TBL(px_line_index) :=NULL;
5254 G_PL_VALIDATED_FLAG_TBL(px_line_index) := 'N';
5255 G_PRICE_REQUEST_CODE_TBL(px_line_index) := p_header_rec.price_request_code;
5256 G_USAGE_PRICING_TYPE_TBL(px_line_index) :='REGULAR';
5257 G_UPD_ADJUSTED_UNIT_PRICE_TBL(px_line_index) :=NULL;
5258 G_LINE_CATEGORY_TBL(px_line_index):=NULL;
5259 G_CATCHWEIGHT_QTY_TBL(px_line_index) := NULL;
5260 G_ACTUAL_ORDER_QTY_TBL(px_line_index) :=NULL;
5261 G_LINE_UNIT_PRICE_TBL(px_line_index) := NULL;
5262 G_LIST_PRICE_OVERRIDE_FLAG_TBL(px_line_index):=NULL;
5263 G_CHARGE_PERIODICITY_CODE_TBL(px_line_index):=NULL;
5264
5265 IF l_debug_level > 0 THEN
5266 oe_debug_pub.add( 'EXISTING OE_ORDER_PRICE_PVT.COPY_HEADER_TO_REQUEST' , 1 ) ;
5267 END IF;
5268
5269 end copy_Header_to_request;
5270
5271 procedure copy_Line_to_request(
5272 p_Line_rec OE_Order_PUB.Line_Rec_Type
5273 ,px_req_line_tbl in out nocopy QP_PREQ_GRP.LINE_TBL_TYPE
5274 ,p_pricing_events varchar2
5275 ,p_request_type_code varchar2
5276 ,p_honor_price_flag varchar2
5277 ,px_line_index in out NOCOPY NUMBER
5278 )
5279 is
5280 --l_line_index pls_integer := nvl(px_req_line_tbl.count,0);
5281 l_req_line_rec QP_PREQ_GRP.LINE_REC_TYPE;
5282 l_uom_rate NUMBER;
5283 v_discounting_privilege VARCHAR2(30);
5284 l_item_type_code VARCHAR2(30);
5285 l_item_rec OE_ORDER_CACHE.item_rec_type; --OPM 2434270
5286 l_dummy VARCHAR2(30);
5287 x_return_status VARCHAR2(30);
5288 x_msg_count NUMBER;
5289 x_msg_data VARCHAR2(2000);
5290 x_secondary_quantity NUMBER;
5291 x_secondary_uom_code VARCHAR2(3);
5292 l_shipped_quantity2 NUMBER;
5293 x_item_rec OE_Order_Cache.Item_Rec_Type;
5294 l_fulfilled_qty NUMBER;
5295 --16206165 CW Start
5296 l_ref_line_rec OE_ORDER_PUB.LINE_REC_TYPE;
5297 l_catch_weight_pricing varchar2(1) := NULL;
5298 --16206165 CW End
5299
5300
5301 --
5302 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5303 --
5304 begin
5305 G_STMT_NO := 'copy_Line_to_request#10';
5306 IF l_debug_level > 0 THEN
5307 oe_debug_pub.add( 'ENTERING OE_ORDER_PRICE_PVT.COPY_LINE_TO_REQUEST' , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
5308 END IF;
5309
5310
5311 --RT{
5312 IF p_line_rec.retrobill_request_id IS NOT NULL AND p_pricing_events <> 'RETROBILL' THEN
5313 --Do not price this retrobill line with other events
5314 oe_debug_pub.add( 'LEAVING OE_ORDER_PRICE_PVT.COPY_LINE_TO_REQUEST' , 1 ) ;
5315 RETURN;
5316 END IF;
5317 --RT}
5318
5319
5320
5321 -- px_line_index := px_line_index+1;
5322 IF l_debug_level > 0 THEN
5323 oe_debug_pub.add( 'LINE ID:FROM COPY LINE TO REQUEST:'||P_LINE_REC.LINE_ID ) ;
5324 END IF;
5325 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
5326 px_req_line_tbl(px_line_index).line_id := p_Line_rec.line_id;
5327 px_req_line_tbl(px_line_index).LINE_TYPE_CODE := 'LINE';
5328 END IF;
5329 l_req_line_rec.Line_id := p_Line_rec.line_id;
5330 l_req_line_rec.REQUEST_TYPE_CODE := p_Request_Type_Code;
5331 --l_req_line_rec.PRICING_EVENT :=p_pricing_event;
5332 --l_req_line_rec.LIST_LINE_LEVEL_CODE :=p_price_level_code;
5333 l_req_line_rec.LINE_INDEX := px_line_index; --p_line_rec.header_id+p_line_rec.line_id;
5334 l_req_line_rec.LINE_TYPE_CODE := 'LINE';
5335 If p_Line_rec.pricing_date is null or
5336 p_Line_rec.pricing_date = fnd_api.g_miss_date then
5337 l_req_line_rec.PRICING_EFFECTIVE_DATE := trunc(sysdate);
5338 Else
5339 l_req_line_rec.PRICING_EFFECTIVE_DATE := p_Line_rec.pricing_date;
5340 End If;
5341
5342 --rc
5343 l_req_line_rec.charge_periodicity_code := p_line_rec.charge_periodicity_code;
5344
5345 IF (QP_PREQ_GRP.G_MIN_PRICING_DATE IS NULL) THEN
5346 QP_PREQ_GRP.G_MIN_PRICING_DATE := TRUNC(l_req_line_rec.PRICING_EFFECTIVE_DATE);
5347 QP_PREQ_GRP.G_MAX_PRICING_DATE := TRUNC(l_req_line_rec.PRICING_EFFECTIVE_DATE);
5348 ELSE
5349 IF (TRUNC(l_req_line_rec.PRICING_EFFECTIVE_DATE)
5350 < TRUNC(QP_PREQ_GRP.G_MIN_PRICING_DATE))
5351 THEN
5352 QP_PREQ_GRP.G_MIN_PRICING_DATE := TRUNC(l_req_line_rec.PRICING_EFFECTIVE_DATE);
5353 END IF;
5354
5355 IF (TRUNC(l_req_line_rec.PRICING_EFFECTIVE_DATE)
5356 > TRUNC(QP_PREQ_GRP.G_MAX_PRICING_DATE))
5357 THEN
5358 QP_PREQ_GRP.G_MAX_PRICING_DATE := TRUNC(l_req_line_rec.PRICING_EFFECTIVE_DATE);
5359
5360 END IF;
5361 END IF;
5362 l_req_line_rec.LINE_QUANTITY := p_Line_rec.Ordered_quantity ;
5363
5364 l_req_line_rec.LINE_UOM_CODE := p_Line_rec.Order_quantity_uom;
5365
5366 l_req_line_rec.PRICED_QUANTITY := p_Line_rec.pricing_quantity;
5367 l_req_line_rec.PRICED_UOM_CODE := p_Line_rec.pricing_quantity_uom;
5368
5369 l_req_line_rec.CURRENCY_CODE :=
5370 OE_Order_PUB.g_hdr.transactional_curr_code;
5371 IF l_debug_level > 0 THEN
5372 oe_debug_pub.add( 'UNIT PRICE'||P_LINE_REC.UNIT_LIST_PRICE||L_REQ_LINE_REC.CURRENCY_CODE , 3 ) ;
5373 END IF;
5374 If p_Line_rec.unit_list_price_per_pqty <> FND_API.G_MISS_NUM Then
5375 l_req_line_rec.UNIT_PRICE := p_Line_rec.unit_list_price_per_pqty;
5376 Elsif p_line_rec.unit_list_price <> FND_API.G_MISS_NUM THEN
5377 l_req_line_rec.UNIT_PRICE := p_line_rec.unit_list_price;
5378 Else
5379 l_req_line_rec.UNIT_PRICE := Null;
5380 End If;
5381
5382 l_req_line_rec.adjusted_unit_price := nvl(p_line_rec.unit_selling_price_per_pqty,
5383 nvl(p_line_rec.unit_selling_price,p_line_rec.unit_list_price));
5384 --bug 2650505
5385 IF l_debug_level > 0 THEN
5386 oe_debug_pub.add( 'ADJ PRICE 1:'||L_REQ_LINE_REC.ADJUSTED_UNIT_PRICE ) ;
5387 END IF;
5388 if l_req_line_rec.adjusted_unit_price = FND_API.G_MISS_NUM then
5389 l_req_line_rec.adjusted_unit_price := NULL;
5390 end if;
5391 l_req_line_rec.PERCENT_PRICE := p_Line_rec.unit_list_percent;
5392
5393 -- bug 4642002 begin call OKS API to get the UOM_QUANTITY
5394 -- also changed the logic to pass 0 whenever service duration or period not present
5395 IF (p_line_rec.item_type_code = 'SERVICE'
5396 OR NVL(p_line_rec.subscription_enable_flag,'N')='Y') THEN --sol_ord_er #16014165
5397 IF (nvl(p_line_rec.service_start_date, FND_API.G_MISS_DATE) <> FND_API.G_MISS_DATE) THEN
5398 l_req_line_rec.contract_start_date := p_line_rec.service_start_date;
5399 END IF;
5400
5401 IF (nvl(p_line_rec.service_end_date, FND_API.G_MISS_DATE) <> FND_API.G_MISS_DATE) THEN
5402 l_req_line_rec.contract_end_date := p_line_rec.service_end_date;
5403 END IF;
5404
5405 IF (nvl(p_line_rec.service_duration,0) = 0
5406 OR p_line_rec.service_duration = FND_API.G_MISS_NUM
5407 OR nvl(p_line_rec.service_period,FND_API.G_MISS_CHAR) = FND_API.G_MISS_CHAR) THEN
5408 l_req_line_rec.UOM_QUANTITY := 0;
5409 Elsif (p_Line_rec.service_period = p_Line_rec.Order_quantity_uom) Then
5410 l_req_line_rec.UOM_QUANTITY := p_Line_rec.service_duration;
5411 Elsif (p_line_rec.service_period IS NOT NULL) THEN
5412 /*
5413 INV_CONVERT.INV_UM_CONVERSION(From_Unit => p_Line_rec.service_period
5414 ,To_Unit => p_Line_rec.Order_quantity_uom
5415 ,Item_ID => p_Line_rec.Inventory_item_id
5416 ,Uom_Rate => l_Uom_rate);
5417 l_req_line_rec.UOM_QUANTITY := p_Line_rec.service_duration * l_uom_rate;
5418 */
5419 If NVL(p_line_rec.subscription_enable_flag,'N')='N' then -- sol_ord_er #16014165
5420 l_req_line_rec.UOM_QUANTITY := OKS_OMINT_PUB.get_target_duration(
5421 p_start_date => p_line_rec.service_start_date
5422 ,p_end_date => p_line_rec.service_end_date
5423 ,p_source_uom => p_line_rec.service_period
5424 ,p_source_duration => p_line_rec.service_duration
5425 ,p_target_uom => p_line_rec.Order_quantity_uom
5426 ,p_org_id => p_line_rec.org_id);
5427 -- sol_ord_er #16014165 start
5428 Else
5429 /* For Subscription Item find the multiplier for List Price */
5430 l_req_line_rec.UOM_QUANTITY := OKS_SUBSCRIPTION_PVT.get_subscription_qty_OM(
5431 p_start_date => p_line_rec.service_start_date
5432 ,p_end_date => p_line_rec.service_end_date
5433 ,p_ou_id => p_line_rec.org_id
5434 ,p_subscription_template_id => p_line_rec.service_subs_template_id
5435 ,p_inventory_item_id => p_line_rec.inventory_item_id );
5436 IF (l_debug_level > 0) THEN
5437 oe_debug_pub.add('After UOM derivation for Subscription Item');
5438 End If;
5439 End IF;
5440 -- sol_ord_er #16014165 end
5441 END IF;
5442 IF (l_debug_level > 0) THEN
5443 oe_debug_pub.add('uom quantity:'||l_req_line_rec.uom_quantity, 3);
5444 oe_debug_pub.add('service start date:'||l_req_line_rec.contract_start_Date, 3);
5445 oe_debug_pub.add('service end date:'||l_req_line_rec.contract_end_date, 3);
5446 END IF;
5447 -- bug 4642002 end
5448 End If;
5449
5450 If G_ROUNDING_FLAG = 'Y' Then
5451 l_req_line_rec.Rounding_factor
5452 := Get_Rounding_factor(p_Line_rec.price_list_id);
5453 End If;
5454
5455 --bug3558168,if cal price = 'X' indicates a service parent line.
5456 IF p_line_rec.CALCULATE_PRICE_FLAG = 'X' THEN
5457 l_req_line_rec.line_unit_price := p_line_rec.unit_list_price;
5458 END IF;
5459
5460 -- modified by lkxu
5461 IF p_honor_price_flag = 'N' THEN
5462 IF p_line_rec.CALCULATE_PRICE_FLAG = 'X' THEN
5463 -- this is service parent line, for information only, so don't price it.
5464 l_req_line_rec.PRICE_FLAG := 'N';
5465 ELSE
5466 l_req_line_rec.PRICE_FLAG := 'Y';
5467 END IF;
5468 ELSE
5469 If p_Line_rec.calculate_Price_flag = fnd_api.g_miss_char then
5470 l_req_line_rec.PRICE_FLAG := 'Y';
5471 else
5472 l_req_line_rec.PRICE_FLAG := nvl(p_Line_rec.calculate_Price_flag,'Y');
5473 end if;
5474 END IF;
5475
5476 -- end of modification made by lkxu
5477
5478 --fnd_profile.get('ONT_DISCOUNTING_PRIVILEGE', v_discounting_privilege);
5479
5480 -- If the profile is set to UNLIMITED, then even if the Order Type
5481 -- restrict price changes, the user can change the price
5482
5483 -- If Enforce list price then execute only the PRICE Event
5484 If p_pricing_events <> 'PRICE' and
5485 l_req_line_rec.PRICE_FLAG = 'Y' and
5486 Enforce_list_price = 'Y'
5487 -- and v_discounting_privilege <> 'UNLIMITED'
5488 then
5489
5490 l_req_line_rec.PRICE_FLAG := 'P';
5491
5492 End If;
5493
5494 -- Execute the pricing phase if the list price is null
5495
5496 If p_pricing_events = 'PRICE' and
5497 l_req_line_rec.line_quantity <> 0 and
5498 l_req_line_rec.UNIT_PRICE is null then
5499
5500 l_req_line_rec.PRICE_FLAG := 'Y' ;
5501
5502 End If;
5503 -- Do not execute SHIP event for a line if the line is not ship interfaced.
5504 If l_req_line_rec.PRICE_FLAG = 'Y' and
5505 (p_Line_rec.Shipped_quantity is null or
5506 p_Line_rec.Shipped_quantity = fnd_api.g_miss_num or
5507 p_Line_rec.Shipped_quantity = 0 ) and
5508 p_pricing_events ='SHIP' Then
5509 l_req_line_rec.PRICE_FLAG := 'N';
5510 End If;
5511
5512 l_item_type_code := oe_line_util.Get_Return_Item_Type_Code(p_Line_rec);
5513 -- Do not fetch the price for Configuration items and Included Items
5514 If l_item_type_code in( 'CONFIG','INCLUDED')
5515 Then
5516
5517 l_req_line_rec.unit_price := 0;
5518 l_req_line_rec.adjusted_unit_price := 0;
5519 l_req_line_rec.priced_quantity := p_line_rec.ordered_quantity;
5520 l_req_line_rec.priced_uom_code := p_line_rec.order_quantity_uom;
5521
5522 IF p_line_rec.calculate_price_flag in ( 'Y', 'P' )
5523 Then
5524 If ( G_CHARGES_FOR_INCLUDED_ITEM = 'N' and
5525 l_item_type_code = 'INCLUDED')
5526 Then
5527 l_req_line_rec.PRICE_FLAG := 'N';
5528 Else
5529 l_req_line_rec.PRICE_FLAG := 'P';
5530 End If;
5531 Else
5532 l_req_line_rec.PRICE_FLAG := 'N';
5533
5534 End IF;
5535
5536 End If;
5537
5538 IF l_debug_level > 0 THEN
5539 oe_debug_pub.add( 'ITEM TYPE CODE'||P_LINE_REC.ITEM_TYPE_CODE , 3 ) ;
5540 END IF;
5541
5542 l_req_line_rec.Active_date_first_type := 'ORD';
5543 l_req_line_rec.Active_date_first := OE_Order_Pub.G_HDR.Ordered_date;
5544
5545 If p_Line_rec.schedule_ship_date is not null then
5546 l_req_line_rec.Active_date_Second_type := 'SHIP';
5547 l_req_line_rec.Active_date_Second := p_Line_rec.schedule_ship_date;
5548 End If;
5549
5550 -- Copied Logic from populate_temp_Tables
5551 If l_req_line_rec.currency_code is NULL
5552 or l_req_line_rec.currency_code = FND_API.G_MISS_CHAR
5553 THEN
5554 IF l_debug_level > 0 THEN
5555 oe_debug_pub.add( 'CURRENCY CODE IS NULL' , 4 ) ;
5556 END IF;
5557 RAISE FND_API.G_EXC_ERROR;
5558 -- Question: Pricing Engine should populate g_currency_code?
5559 End If;
5560
5561 IF ( l_req_line_rec.PRICING_EFFECTIVE_DATE IS NULL ) THEN
5562 RAISE FND_API.G_EXC_ERROR;
5563 END IF;
5564 -- ?? Pricing Engine should populate G_MIN_PRICING_DATE, G_MAX_PRICING_DATE
5565
5566 /* IF ( l_req_line_rec.price_flag = 'Y') THEN
5567 l_req_line_rec.unit_price := NULL;
5568 END IF; */
5569
5570 -- start OPM 2434270
5571 G_catchweight_qty_tbl(px_line_index) := NULL;
5572 g_actual_order_qty_tbl(px_line_index):= NULL;
5573
5574 -- for bug 4938837, do not need OPM logic and original list price check for service parent line
5575 IF (nvl(p_line_rec.calculate_price_flag, 'Y') <> 'X') THEN -- bug 4938837
5576 -- bug 3658057
5577 l_fulfilled_qty := NVL(p_line_rec.fulfilled_quantity, NVL(p_line_rec.shipped_quantity, NVL(p_line_rec.ordered_quantity, 0)));
5578
5579 IF l_debug_level > 0 THEN
5580 oe_debug_pub.add('l_fulfilled_qty:'|| l_fulfilled_qty);
5581 END IF;
5582
5583 IF oe_line_util.dual_uom_control -- INVCONV Process_Characteristics
5584 (p_line_rec.inventory_item_id
5585 ,p_line_rec.ship_from_org_id
5586 ,l_item_rec) THEN
5587
5588
5589 -- IF l_item_rec.ont_pricing_qty_source = 1 THEN -- INVCONV price by quantity 2
5590 IF p_line_rec.fulfillment_base IS NULL THEN --16206165 CW
5591 IF l_item_rec.ont_pricing_qty_source = 'S' THEN -- INVCONV
5592 IF l_debug_level > 0 THEN
5593 oe_debug_pub.add( 'DUAL - ONT_PRICING_QTY_SOURCE = S IN OEXVOPRB.PLS ' ) ;
5594 END IF;
5595 l_req_line_rec.LINE_QUANTITY := p_Line_rec.Ordered_quantity2 ;
5596 l_req_line_rec.LINE_UOM_CODE := p_Line_rec.Ordered_quantity_uom2 ;
5597 G_catchweight_qty_tbl(px_line_index) := p_line_rec.shipped_quantity2;
5598 g_actual_order_qty_tbl(px_line_index) := l_fulfilled_qty; -- bug 3658057
5599
5600 IF (l_req_line_rec.price_flag = 'N') THEN
5601 l_req_line_rec.price_flag := 'C';
5602 END IF;
5603
5604
5605 IF l_debug_level > 0 THEN
5606 oe_debug_pub.add('OM Order Qty:'||p_line_rec.ordered_quantity);
5607 oe_debug_pub.add('actual order qty :'|| g_actual_order_qty_tbl(px_line_index) ) ;
5608 END IF;
5609
5610 else
5611 l_req_line_rec.LINE_QUANTITY := p_Line_rec.Ordered_quantity ;
5612 l_req_line_rec.LINE_UOM_CODE := p_Line_rec.Order_quantity_uom ;
5613 END IF;
5614 END IF; --16206165 CW
5615
5616 --16206165 CW start
5617 IF p_line_rec.reference_line_id is NOT NULL THEN
5618 l_ref_line_rec := OE_line_UTIL.Query_Row(p_line_rec.reference_line_id);
5619 END IF;
5620
5621 IF p_line_rec.fulfillment_base IS NOT NULL OR l_ref_line_rec.fulfillment_base IS NOT NULL THEN
5622
5623 l_catch_weight_pricing := oe_line_util.is_catch_weight(p_Line_rec);
5624
5625 IF l_catch_weight_pricing = 'S' THEN
5626
5627 IF p_line_rec.shipped_quantity2 IS NOT NULL THEN
5628 l_req_line_rec.LINE_QUANTITY := OE_Order_Misc_Util.Convert_Uom
5629 (p_item_id => p_Line_rec.inventory_item_id,
5630 p_from_uom_code => p_Line_rec.order_quantity_uom,
5631 p_to_uom_code => l_item_rec.secondary_uom_code,
5632 p_from_qty => p_Line_rec.Ordered_quantity);
5633 ELSE
5634 l_req_line_rec.LINE_QUANTITY := p_Line_rec.Ordered_quantity2 ;
5635 END IF;
5636 l_req_line_rec.LINE_UOM_CODE := p_Line_rec.Ordered_quantity_uom2 ;
5637 G_catchweight_qty_tbl(px_line_index) := p_line_rec.shipped_quantity2;
5638 g_actual_order_qty_tbl(px_line_index) := l_fulfilled_qty;
5639
5640 IF (l_req_line_rec.price_flag = 'N') THEN
5641 l_req_line_rec.price_flag := 'C';
5642 END IF;
5643
5644 ELSIF l_catch_weight_pricing = 'P' THEN
5645
5646 l_req_line_rec.LINE_QUANTITY := OE_Order_Misc_Util.Convert_Uom
5647 (p_item_id => p_Line_rec.inventory_item_id,
5648 p_from_uom_code => p_Line_rec.order_quantity_uom,
5649 p_to_uom_code => l_item_rec.primary_uom_code,
5650 p_from_qty => p_Line_rec.Ordered_quantity);
5651 oe_debug_pub.ADD('LINE_QUANTITY:'||l_req_line_rec.LINE_QUANTITY);
5652 l_req_line_rec.LINE_UOM_CODE := l_item_rec.primary_uom_code ;
5653
5654 /** Eventhough Receiving Team is not supporting Fulfillment by Secondary , for referenced RMA the Credit Memo should not
5655 exceed Invoice, thats the reason the non-Referenced RMA pricing will be in sync with the base order pricing **/
5656
5657 IF p_line_rec.reference_line_id is NOT NULL THEN
5658 G_catchweight_qty_tbl(px_line_index) := l_ref_line_rec.Shipping_quantity * ( Nvl(p_Line_rec.Shipped_quantity,p_Line_rec.Ordered_quantity) / Nvl(l_ref_line_rec.Shipped_quantity,l_ref_line_rec.Ordered_quantity));
5659 ELSE
5660
5661 G_catchweight_qty_tbl(px_line_index) := p_line_rec.Shipping_quantity;
5662 END IF;
5663
5664 g_actual_order_qty_tbl(px_line_index) := l_fulfilled_qty;
5665
5666 IF (l_req_line_rec.price_flag = 'N') THEN
5667 l_req_line_rec.price_flag := 'C';
5668 END IF;
5669
5670 ELSE
5671 l_req_line_rec.LINE_QUANTITY := p_Line_rec.Ordered_quantity ;
5672 l_req_line_rec.LINE_UOM_CODE := p_Line_rec.Order_quantity_uom ;
5673
5674 END IF;
5675
5676 END IF;
5677
5678
5679 IF l_debug_level > 0 THEN
5680 oe_debug_pub.ADD('Catch Weight Re-Pricing Primary UOM:'||l_item_rec.primary_uom_code);
5681 oe_debug_pub.ADD('Catch Weight Re-Pricing Secondary UOM'||l_item_rec.secondary_uom_code);
5682 oe_debug_pub.ADD('Catch Weight Re-Pricing Ordered Quantity Uom:'||p_Line_rec.order_quantity_uom);
5683 oe_debug_pub.ADD('Catch Weight Re-Pricing Ordered_quantity:'||p_Line_rec.Ordered_quantity);
5684 oe_debug_pub.ADD('Catch Weight Re-Pricing Catch Weight Qty:'||G_catchweight_qty_tbl(px_line_index));
5685 oe_debug_pub.ADD('Catch Weight Re-Pricing Actual Ordered Qty:'||g_actual_order_qty_tbl(px_line_index));
5686 oe_debug_pub.ADD('Catch Weight Re-Pricing Line Req Qty:'||l_req_line_rec.LINE_QUANTITY);
5687 oe_debug_pub.ADD('Catch Weight Re-Pricing Line Req UOM:'||l_req_line_rec.LINE_UOM_CODE);
5688 oe_debug_pub.ADD('Catch Weight Re-Pricing Ref Line Shipping Qty:'||l_ref_line_rec.Shipping_quantity);
5689 oe_debug_pub.ADD('Catch Weight Re-Pricing Ref Line Ordered Qty:'||l_ref_line_rec.Ordered_quantity);
5690 END IF;
5691
5692 --16206165 CW end
5693
5694 IF l_debug_level > 0 THEN
5695 oe_debug_pub.add( 'DUAL - PRICING QUANTITY IS : ' ||L_REQ_LINE_REC.LINE_QUANTITY ) ;
5696 END IF;
5697 IF l_debug_level > 0 THEN
5698 oe_debug_pub.add( 'DUAL - PRICING QUANTITY UOM IS : ' || L_REQ_LINE_REC.LINE_UOM_CODE )
5699 ;
5700 END IF;
5701 -- Pack J catchweight
5702 ELSIF OE_CODE_CONTROL.Code_Release_level >= '110510' THEN
5703 IF l_debug_level > 0 THEN
5704 oe_debug_pub.add('inventory_item_id:'|| p_line_rec.inventory_item_id);
5705 oe_debug_pub.add('ship_from_org_id :'|| p_line_rec.ship_from_org_id );
5706 END IF;
5707
5708 IF (p_line_rec.inventory_item_id IS NOT NULL AND
5709 p_line_rec.inventory_item_id <> FND_API.G_MISS_NUM) AND
5710 (p_line_rec.ship_from_org_id IS NOT NULL AND
5711 p_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM) THEN
5712 x_item_rec := OE_Order_Cache.Load_Item (p_line_rec.inventory_item_id
5713 ,p_line_rec.ship_from_org_id);
5714 END IF;
5715 IF l_debug_level > 0 THEN
5716 oe_debug_pub.add('ont_pricing_qty_source:'|| l_item_rec.ont_pricing_qty_source);
5717 oe_debug_pub.add('tracking_quantity_ind:'|| l_item_rec.tracking_quantity_ind);
5718 oe_debug_pub.add('wms_enabled_flag:'|| l_item_rec.wms_enabled_flag);
5719 END IF;
5720 --IF x_item_rec.ont_pricing_qty_source = 1 AND -- INVCONV
5721 IF x_item_rec.ont_pricing_qty_source = 'S' AND -- INVCONV
5722 x_item_rec.tracking_quantity_ind = 'P' and
5723 x_item_rec.wms_enabled_flag = 'Y' THEN
5724 IF (l_req_line_rec.price_flag = 'N') THEN
5725 l_req_line_rec.price_flag := 'C';
5726 END IF;
5727 IF p_Line_rec.Ordered_quantity2 IS NOT NULL THEN
5728 /*<< This should be possible for referenced returns if ordered qty2 is populated based on shipped_quantity2>> */
5729 IF l_debug_level > 0 THEN
5730 oe_debug_pub.add('Ordered_quantity2 is NOT null ');
5731 END IF;
5732 l_req_line_rec.LINE_QUANTITY := p_Line_rec.Ordered_quantity2 ;
5733 l_req_line_rec.LINE_UOM_CODE := p_Line_rec.Ordered_quantity_uom2 ;
5734 g_actual_order_qty_tbl(px_line_index) := l_fulfilled_qty; -- bug 3658057
5735 ELSE
5736 IF l_debug_level > 0 THEN
5737 oe_debug_pub.add('Ordered_quantity2 is null');
5738 END IF;
5739
5740 l_dummy := WMS_CATCH_WEIGHT_GRP.Get_Default_Secondary_Quantity (
5741 p_api_version => 1.0
5742 ,x_return_status => x_return_status
5743 ,x_msg_count => x_msg_count
5744 ,x_msg_data => x_msg_data
5745 , p_organization_id => p_line_rec.ship_from_org_id
5746 , p_inventory_item_id => p_line_rec.inventory_item_id , p_quantity => p_line_rec.ordered_quantity
5747 , p_uom_code => p_line_rec.order_quantity_uom
5748 , x_secondary_quantity => x_secondary_quantity --returns default catch wt qty
5749 , x_secondary_uom_code => x_secondary_uom_code --returns default catch wt uom
5750 );
5751
5752 IF l_debug_level > 0 THEN
5753 oe_debug_pub.add('x_secondary_qauntity:'|| x_secondary_quantity);
5754 oe_debug_pub.add('x_secondary_uom_code:'|| x_secondary_uom_code);
5755 END IF;
5756 /* Populating x_secondary_uom_code with the value in x_item_rec, because wms api is returning null */
5757 x_secondary_uom_code := x_item_rec.secondary_uom_code;
5758 IF l_debug_level > 0 THEN
5759 oe_debug_pub.add('after populating from x_item_rec :');
5760 oe_debug_pub.add('x_secondary_uom_code : '||x_secondary_uom_code);
5761 END IF;
5762 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
5763 IF l_debug_level > 0 THEN
5764 oe_debug_pub.add('Error getting secondary UOM/quantity from WMS API. Return Status: '||x_return_status||' msg_count:'||x_msg_count);
5765 END IF;
5766 oe_msg_pub.transfer_msg_stack;
5767 RAISE FND_API.G_EXC_ERROR;
5768 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5769 IF l_debug_level > 0 THEN
5770 oe_debug_pub.add('Error getting secondary UOM/quantity from WMS API. Return Status: '||x_return_status||' msg_count:'||x_msg_count);
5771 END IF;
5772 oe_msg_pub.transfer_msg_stack;
5773 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5774 END IF;
5775
5776 l_req_line_rec.LINE_QUANTITY := x_secondary_quantity;
5777
5778 l_req_line_rec.LINE_UOM_CODE := x_secondary_uom_code;
5779 g_actual_order_qty_tbl(px_line_index) := l_fulfilled_qty; -- bug3658057
5780 END IF; -- end check for ordered_quantity2
5781
5782 IF l_debug_level > 0 THEN
5783 oe_debug_pub.add('fulfilled_quantity:'|| p_line_rec.fulfilled_quantity);
5784 oe_debug_pub.add('shipped_quantity:'|| p_line_rec.shipped_quantity);
5785 oe_debug_pub.add('shipped_quantity2 :'|| p_line_rec.shipped_quantity2);
5786 oe_debug_pub.add('source_type_code :'|| p_line_rec.source_type_code);
5787 oe_debug_pub.add('line_category_code :'|| p_line_rec.line_category_code);
5788 oe_debug_pub.add('reference_line_id :'|| p_line_rec.reference_line_id);
5789 END IF;
5790
5791 IF p_line_rec.shipped_quantity IS NOT NULL AND
5792 p_line_rec.shipped_quantity <> FND_API.G_MISS_NUM THEN
5793 IF p_line_rec.shipped_quantity2 IS NOT NULL AND
5794 p_line_rec.shipped_quantity2 <> FND_API.G_MISS_NUM AND
5795 p_line_rec.shipped_quantity2 <> 0 THEN
5796 G_catchweight_qty_tbl(px_line_index) := p_line_rec.shipped_quantity2;
5797 ELSE -- shipped_quantity2 is null
5798 IF p_line_rec.source_type_code = 'EXTERNAL' OR
5799 p_line_rec.line_category_code = 'RETURN' THEN -- convert shipped_quantity to shipped_quantity2 for dropship and un-referenced returns
5800
5801 IF p_line_rec.reference_line_id is NOT NULL THEN --referenced return
5802 -- G_catchweight_qty_tbl(px_line_index) := NULL;
5803 /*<<since there is tolerance in returns also, for reference returns, we need to
5804 prorate. For example, return 12 qty of 24lb, return tolerance is 20%. If received qty is 11, we should prorate the catchweight qty to be 22lb.>> */
5805 G_catchweight_qty_tbl(px_line_index):= p_line_rec.ordered_quantity2 * (p_line_rec.shipped_quantity/p_line_rec.ordered_quantity);
5806 ELSE --unrefernced return and dropship lines
5807 l_shipped_quantity2 :=
5808 INV_CONVERT.INV_UM_CONVERT(
5809 item_id => p_line_rec.inventory_item_id,
5810 precision =>NULL,
5811 from_quantity => p_line_rec.shipped_quantity,
5812 from_unit => p_line_rec.order_quantity_uom,
5813 to_unit => x_item_rec.secondary_uom_code,
5814 from_name =>NULL,
5815 to_name =>NULL);
5816 G_catchweight_qty_tbl(px_line_index) :=l_shipped_quantity2;
5817 END IF; --check for reference_line_id
5818 ELSE /*<< raise error here if shipped_quantity exists but not shipped_quantity2>> -- This error should not be raised for returns and dropship orders. */
5819 IF l_debug_level > 0 THEN
5820 oe_debug_pub.add('Shipped_quantity2 is null and not dropship, return- Raise error');
5821 END IF;
5822 FND_MESSAGE.SET_NAME('ONT','ONT_CATCHWEIGHT_QTY2_REQUIRED');
5823 OE_MSG_PUB.Add;
5824 RAISE FND_API.G_EXC_ERROR;
5825 END IF; -- end checks for source_type_code
5826 END IF; -- end checks for shipped_quantity2
5827 END IF; -- end check for shipped_quantity
5828 END IF; -- end checks for discrete catchweight
5829 END IF; -- end of check for opm/discrete
5830
5831 -- Pack J catchweight
5832 -- end OPM 2434270
5833
5834 -- Override List Price
5835 IF OE_CODE_CONTROL.Code_Release_level >= '110510' THEN
5836 IF p_line_rec.original_list_price IS NOT NULL AND
5837 p_line_rec.unit_list_price IS NOT NULL THEN --AND --bug4080363
5838 -- p_line_rec.unit_list_price <> p_line_rec.original_list_price AND
5839 -- bug 3491752
5840 /*nvl(fnd_profile.value('ONT_LIST_PRICE_OVERRIDE_PRIV'), 'NONE')*/ -- G_LIST_PRICE_OVERRIDE = 'UNLIMITED' THEN --bug4080363
5841 l_req_line_rec.list_price_override_flag := 'Y';
5842 l_req_line_rec.line_unit_price := p_line_rec.unit_list_price;
5843 IF (l_req_line_rec.price_flag = 'N') THEN
5844 l_req_line_rec.price_flag := 'C';
5845 END IF;
5846 ELSE
5847 -- adding this because qp did not handle null value in some file versions
5848 l_req_line_rec.list_price_override_flag := 'N';
5849 END IF;
5850 END IF;
5851 -- Override List Price
5852 END IF; -- bug 4938837
5853
5854 IF l_debug_level > 0 THEN
5855 oe_debug_pub.add('list_price_override_flag:'||l_req_line_rec.list_price_override_flag);
5856 oe_debug_pub.add('unit_price:'||l_req_line_rec.unit_price);
5857 oe_debug_pub.add('line_unit_price:'||l_req_line_rec.line_unit_price);
5858 oe_debug_pub.add('unit_list_price_per_pqty:'||p_line_rec.unit_list_price_per_pqty);
5859 oe_debug_pub.add('original_list_price:'||p_line_rec.original_list_price||':unit_list_price:'||p_line_rec.unit_list_price);
5860 END IF;
5861 -- bug 2812566, set price_flag to be 'N' when line is cancelled
5862 IF p_line_rec.ordered_quantity = 0 THEN
5863 l_req_line_rec.PRICE_FLAG := 'N';
5864 END IF;
5865
5866 IF l_debug_level > 0 THEN
5867 oe_debug_pub.add( 'POPULATING BULK INSERT TABLES' , 4 ) ;
5868 oe_debug_pub.add('inserting line index:'||l_req_line_rec.line_index);
5869 END IF;
5870
5871 G_LINE_INDEX_TBL(px_line_index) := l_req_line_rec.LINE_INDEX;
5872 G_LINE_TYPE_CODE_TBL(px_line_index) := l_req_line_rec.LINE_TYPE_CODE;
5873 G_PRICING_EFFECTIVE_DATE_TBL(px_line_index):= TRUNC(l_req_line_rec.PRICING_EFFECTIVE_DATE);
5874 G_ACTIVE_DATE_FIRST_TBL(px_line_index) := TRUNC(l_req_line_rec.ACTIVE_DATE_FIRST);
5875 G_ACTIVE_DATE_FIRST_TYPE_TBL(px_line_index):= l_req_line_rec.ACTIVE_DATE_FIRST_TYPE;
5876 G_ACTIVE_DATE_SECOND_TBL(px_line_index) := TRUNC(l_req_line_rec.ACTIVE_DATE_SECOND);
5877 G_ACTIVE_DATE_SECOND_TYPE_TBL(px_line_index):= l_req_line_rec.ACTIVE_DATE_SECOND_TYPE;
5878 --l_req_line_rec.priced_quantity := NULL;
5879 IF l_debug_level > 0 THEN
5880 oe_debug_pub.add( 'QUANTITY'||L_REQ_LINE_REC.LINE_QUANTITY||' '||L_REQ_LINE_REC.PRICED_QUANTITY , 3 ) ;
5881 END IF;
5882 IF l_debug_level > 0 THEN
5883 oe_debug_pub.add( 'PRICE FLAG'||L_REQ_LINE_REC.PRICE_FLAG ) ;
5884 END IF;
5885 G_LINE_QUANTITY_TBL(px_line_index) := l_req_line_rec.LINE_QUANTITY;
5886 G_LINE_UOM_CODE_TBL(px_line_index) := l_req_line_rec.LINE_UOM_CODE;
5887 G_REQUEST_TYPE_CODE_TBL(px_line_index) := l_req_line_rec.REQUEST_TYPE_CODE;
5888 G_PRICED_QUANTITY_TBL(px_line_index) := l_req_line_rec.PRICED_QUANTITY;
5889 G_UOM_QUANTITY_TBL(px_line_index) := l_req_line_rec.UOM_QUANTITY;
5890 G_CONTRACT_START_DATE_TBL(px_line_index) := l_req_line_rec.CONTRACT_START_DATE;
5891 G_CONTRACT_END_DATE_TBL(px_line_index) := l_req_line_rec.CONTRACT_END_DATE;
5892 G_PRICED_UOM_CODE_TBL(px_line_index) := l_req_line_rec.PRICED_UOM_CODE;
5893 G_CURRENCY_CODE_TBL(px_line_index) := l_req_line_rec.CURRENCY_CODE;
5894 IF l_debug_level > 0 THEN
5895 oe_debug_pub.add( 'UNIT PRICE'||L_REQ_LINE_REC.UNIT_PRICE||' '||L_REQ_LINE_REC.ADJUSTED_UNIT_PRICE ) ;
5896 END IF;
5897 G_UNIT_PRICE_TBL(px_line_index) := l_req_line_rec.unit_price; -- AG
5898 G_PERCENT_PRICE_TBL(px_line_index) := l_req_line_rec.PERCENT_PRICE;
5899 G_ADJUSTED_UNIT_PRICE_TBL(px_line_index) := l_req_line_rec.ADJUSTED_UNIT_PRICE;
5900 G_PROCESSED_FLAG_TBL(px_line_index) := QP_PREQ_GRP.G_NOT_PROCESSED;
5901 G_PRICE_FLAG_TBL(px_line_index) := l_req_line_rec.PRICE_FLAG;
5902 G_LINE_ID_TBL(px_line_index) := l_req_line_rec.LINE_ID;
5903 IF l_debug_level > 0 THEN
5904 oe_debug_pub.add( 'LINE ID IN G_LINE_ID_TBL:'|| G_LINE_ID_TBL ( PX_LINE_INDEX ) ) ;
5905 END IF;
5906 G_ROUNDING_FLAG_TBL(px_line_index) := G_ROUNDING_FLAG; -- AG
5907 G_ROUNDING_FACTOR_TBL(px_line_index) := l_req_line_rec.ROUNDING_FACTOR;
5908 G_PROCESSING_ORDER_TBL(px_line_index) := NULL;
5909 G_PRICING_STATUS_CODE_tbl(px_line_index) := QP_PREQ_GRP.G_STATUS_UNCHANGED; -- AG
5910 G_PRICING_STATUS_TEXT_tbl(px_line_index) := NULL;
5911 G_QUALIFIERS_EXIST_FLAG_TBL(px_line_index) :='N';
5912 G_PRICING_ATTRS_EXIST_FLAG_TBL(px_line_index) :='N';
5913 G_PRICE_LIST_ID_TBL(px_line_index) :=p_line_rec.price_list_id;
5914 G_PL_VALIDATED_FLAG_TBL(px_line_index) := 'N';
5915 G_PRICE_REQUEST_CODE_TBL(px_line_index) := p_line_rec.price_request_code;
5916 G_USAGE_PRICING_TYPE_TBL(px_line_index) :='REGULAR';
5917 G_UPD_ADJUSTED_UNIT_PRICE_TBL(px_line_index) :=NULL;
5918 G_LINE_CATEGORY_TBL(px_line_index) := p_line_rec.line_category_code;
5919 G_LIST_PRICE_OVERRIDE_FLAG_TBL(px_line_index) := l_req_line_rec.list_price_override_flag;
5920 G_LINE_UNIT_PRICE_TBL(px_line_index) := l_req_line_rec.line_unit_price;
5921 --rc
5922 G_CHARGE_PERIODICITY_CODE_TBL(px_line_index) := l_req_line_rec.CHARGE_PERIODICITY_CODE;
5923 -- Bug3380345
5924 IF G_LIST_PRICE_OVERRIDE_FLAG_TBL(px_line_index) = 'Y' AND
5925 p_pricing_events = 'PRICE' THEN
5926 IF l_debug_level > 0 THEN
5927 oe_debug_pub.add( 'setting process code as UPDATED for override list price');
5928 END IF;
5929 G_PRICING_STATUS_CODE_tbl(px_line_index) := QP_PREQ_GRP.G_STATUS_UPDATED;
5930 END IF;
5931
5932
5933 IF l_debug_level > 0 THEN
5934 oe_debug_pub.add( 'EXISTING OE_ORDER_PRICE_PVT.COPY_LINE_TO_REQUEST' , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
5935 END IF;
5936
5937 end copy_Line_to_request;
5938
5939 procedure Populate_Temp_Table
5940 IS
5941 l_return_status varchar2(1) := FND_API.G_RET_STS_SUCCESS;
5942 l_return_status_Text varchar2(240) ;
5943 --
5944 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5945 --
5946 BEGIN
5947 IF l_debug_level > 0 THEN
5948 oe_debug_pub.add( 'BEFORE DIRECT INSERT INTO TEMP TABLE: BULK INSERT'||G_LINE_INDEX_TBL.COUNT , 1 ) ;
5949 oe_debug_pub.add('G_CHARGE_PERIODICITY_CODE_TBL.Count:'||G_CHARGE_PERIODICITY_CODE_TBL.COUNT);
5950 END IF;
5951 QP_PREQ_GRP.INSERT_LINES2
5952 (p_LINE_INDEX => G_LINE_INDEX_TBL,
5953 p_LINE_TYPE_CODE => G_LINE_TYPE_CODE_TBL,
5954 p_PRICING_EFFECTIVE_DATE =>G_PRICING_EFFECTIVE_DATE_TBL,
5955 p_ACTIVE_DATE_FIRST =>G_ACTIVE_DATE_FIRST_TBL,
5956 p_ACTIVE_DATE_FIRST_TYPE =>G_ACTIVE_DATE_FIRST_TYPE_TBL,
5957 p_ACTIVE_DATE_SECOND =>G_ACTIVE_DATE_SECOND_TBL,
5958 p_ACTIVE_DATE_SECOND_TYPE =>G_ACTIVE_DATE_SECOND_TYPE_TBL,
5959 p_LINE_QUANTITY => G_LINE_QUANTITY_TBL,
5960 p_LINE_UOM_CODE => G_LINE_UOM_CODE_TBL,
5961 p_REQUEST_TYPE_CODE => G_REQUEST_TYPE_CODE_TBL,
5962 p_PRICED_QUANTITY => G_PRICED_QUANTITY_TBL,
5963 p_PRICED_UOM_CODE => G_PRICED_UOM_CODE_TBL,
5964 p_CURRENCY_CODE => G_CURRENCY_CODE_TBL,
5965 p_UNIT_PRICE => G_UNIT_PRICE_TBL,
5966 p_PERCENT_PRICE => G_PERCENT_PRICE_TBL,
5967 p_UOM_QUANTITY => G_UOM_QUANTITY_TBL,
5968 p_ADJUSTED_UNIT_PRICE =>G_ADJUSTED_UNIT_PRICE_TBL,
5969 p_UPD_ADJUSTED_UNIT_PRICE =>G_UPD_ADJUSTED_UNIT_PRICE_TBL,
5970 p_PROCESSED_FLAG =>G_PROCESSED_FLAG_TBL,
5971 p_PRICE_FLAG =>G_PRICE_FLAG_TBL,
5972 p_LINE_ID =>G_LINE_ID_TBL,
5973 p_PROCESSING_ORDER =>G_PROCESSING_ORDER_TBL,
5974 p_PRICING_STATUS_CODE =>G_PRICING_STATUS_CODE_tbl,
5975 p_PRICING_STATUS_TEXT =>G_PRICING_STATUS_TEXT_tbl,
5976 p_ROUNDING_FLAG =>G_ROUNDING_FLAG_TBL,
5977 p_ROUNDING_FACTOR =>G_ROUNDING_FACTOR_TBL,
5978 p_QUALIFIERS_EXIST_FLAG => G_QUALIFIERS_EXIST_FLAG_TBL,
5979 p_PRICING_ATTRS_EXIST_FLAG =>G_PRICING_ATTRS_EXIST_FLAG_TBL,
5980 p_PRICE_LIST_ID => G_PRICE_LIST_ID_TBL,
5981 p_VALIDATED_FLAG => G_PL_VALIDATED_FLAG_TBL,
5982 p_PRICE_REQUEST_CODE => G_PRICE_REQUEST_CODE_TBL,
5983 p_USAGE_PRICING_TYPE => G_USAGE_PRICING_TYPE_tbl,
5984 p_line_category => G_LINE_CATEGORY_tbl,
5985 p_contract_start_date => G_CONTRACT_START_DATE_tbl,
5986 p_contract_end_date => G_CONTRACT_END_DATE_tbl,
5987 p_catchweight_qty => G_CATCHWEIGHT_QTY_tbl,
5988 p_actual_order_qty => G_ACTUAL_ORDER_QTY_TBL,
5989 p_LINE_UNIT_PRICE => G_LINE_UNIT_PRICE_TBL,
5990 p_LIST_PRICE_OVERRIDE_FLAG => G_LIST_PRICE_OVERRIDE_FLAG_TBL,
5991 p_CHARGE_PERIODICITY_CODE => G_CHARGE_PERIODICITY_CODE_TBL, --rc
5992 x_status_code =>l_return_status,
5993 x_status_text =>l_return_status_text);
5994
5995 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
5996 IF l_debug_level > 0 THEN
5997 oe_debug_pub.add( 'WRONG IN INSERT_LINES2'||L_RETURN_STATUS_TEXT , 1 ) ;
5998 END IF;
5999 FND_MESSAGE.SET_NAME('ONT','ONT_PRICING_ERRORS'); --bug#7149497
6000 FND_MESSAGE.SET_TOKEN('ERR_TEXT',l_return_status_text);
6001 OE_MSG_PUB.Add;
6002 RAISE FND_API.G_EXC_ERROR;
6003 END IF;
6004
6005 IF G_ATTR_LINE_INDEX_tbl.count > 0 THEN
6006 QP_PREQ_GRP.INSERT_LINE_ATTRS2
6007 ( G_ATTR_LINE_INDEX_tbl,
6008 G_ATTR_LINE_DETAIL_INDEX_tbl ,
6009 G_ATTR_ATTRIBUTE_LEVEL_tbl ,
6010 G_ATTR_ATTRIBUTE_TYPE_tbl ,
6011 G_ATTR_LIST_HEADER_ID_tbl ,
6012 G_ATTR_LIST_LINE_ID_tbl ,
6013 G_ATTR_PRICING_CONTEXT_tbl ,
6014 G_ATTR_PRICING_ATTRIBUTE_tbl ,
6015 G_ATTR_VALUE_FROM_tbl ,
6016 G_ATTR_SETUP_VALUE_FROM_tbl ,
6017 G_ATTR_VALUE_TO_tbl ,
6018 G_ATTR_SETUP_VALUE_TO_tbl ,
6019 G_ATTR_GROUPING_NUMBER_tbl ,
6020 G_ATTR_NO_QUAL_IN_GRP_tbl ,
6021 G_ATTR_COMP_OPERATOR_TYPE_tbl ,
6022 G_ATTR_VALIDATED_FLAG_tbl ,
6023 G_ATTR_APPLIED_FLAG_tbl ,
6024 G_ATTR_PRICING_STATUS_CODE_tbl ,
6025 G_ATTR_PRICING_STATUS_TEXT_tbl ,
6026 G_ATTR_QUAL_PRECEDENCE_tbl ,
6027 G_ATTR_DATATYPE_tbl ,
6028 G_ATTR_PRICING_ATTR_FLAG_tbl ,
6029 G_ATTR_QUALIFIER_TYPE_tbl ,
6030 G_ATTR_PRODUCT_UOM_CODE_TBL ,
6031 G_ATTR_EXCLUDER_FLAG_TBL ,
6032 G_ATTR_PRICING_PHASE_ID_TBL ,
6033 G_ATTR_INCOM_GRP_CODE_TBL,
6034 G_ATTR_LDET_TYPE_CODE_TBL,
6035 G_ATTR_MODIFIER_LEVEL_CODE_TBL,
6036 G_ATTR_PRIMARY_UOM_FLAG_TBL,
6037 l_return_status ,
6038 l_return_status_text );
6039
6040 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
6041 IF l_debug_level > 0 THEN
6042 oe_debug_pub.add( 'ERROR INSERTING INTO LINE ATTRS'||SQLERRM ) ;
6043 END IF;
6044 FND_MESSAGE.SET_NAME('ONT','ONT_PRICING_ERRORS'); --bug#7149497
6045 FND_MESSAGE.SET_TOKEN('ERR_TEXT',l_return_status_text);
6046 OE_MSG_PUB.Add;
6047 raise fnd_api.g_exc_unexpected_error;
6048 END IF;
6049
6050 END IF;
6051 IF l_debug_level > 0 THEN
6052 oe_debug_pub.add( 'AFTER DIRECT INSERT INTO TEMP TABLE: BULK INSERT' , 1 ) ;
6053 END IF;
6054
6055 EXCEPTION
6056 WHEN OTHERS THEN
6057 RAISE FND_API.G_EXC_ERROR;
6058 END POPULATE_TEMP_TABLE;
6059
6060 -- This function is to find out whether it's better to query all lines in the order
6061 -- or query changed lines one by one
6062 FUNCTION Need_Query_All_Lines(
6063 p_header_id NUMBER
6064 ) RETURN VARCHAR2
6065 IS
6066 l_total_lines NUMBER;
6067 l_num_changed_lines NUMBER;
6068 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6069 i pls_integer;
6070 BEGIN
6071
6072 -- only one changed line, query that line
6073 IF (OE_Line_Adj_Util.G_CHANGED_LINE_TBL.count < 2) THEN
6074 RETURN 'N';
6075 END IF;
6076
6077 -- find out the total number of lines in the order
6078 BEGIN
6079 Select count(header_id) into l_total_lines from oe_order_lines
6080 where header_id = p_header_id;
6081 EXCEPTION
6082 WHEN OTHERS THEN
6083 IF l_debug_level > 0 THEN
6084 oe_debug_pub.add('could not find out nocopy total number of lines!');
6085 END IF;
6086 RETURN 'N';
6087 END;
6088
6089 IF (l_total_lines > OE_Line_Adj_Util.G_CHANGED_LINE_TBL.count) THEN
6090 IF l_debug_level > 0 THEN
6091 oe_debug_pub.add('total lines larger than changed '||l_total_lines
6092 ||' '||OE_Line_Adj_Util.G_CHANGED_LINE_TBL.count);
6093 END IF;
6094 RETURN 'N';
6095 ELSE
6096 IF l_debug_level > 0 THEN
6097 oe_debug_pub.add('total lines smaller than or equal to changed '||l_total_lines
6098 ||' '||OE_Line_Adj_Util.G_CHANGED_LINE_TBL.count);
6099 END IF;
6100
6101 l_num_changed_lines := 0;
6102 i := Oe_Line_Adj_Util.G_CHANGED_LINE_TBL.FIRST;
6103 While i is Not Null Loop
6104 if oe_line_adj_util.G_CHANGED_LINE_TBL(i).header_id = p_header_id then
6105 l_num_changed_lines := l_num_changed_lines + 1;
6106 end if;
6107 i:= Oe_Line_Adj_Util.G_CHANGED_LINE_TBL.Next(i);
6108 End Loop;
6109
6110 IF l_debug_level > 0 THEN
6111 oe_debug_pub.add('total changed lines in this order '||l_num_changed_lines);
6112 END IF;
6113 IF (l_total_lines = l_num_changed_lines) THEN
6114 RETURN 'Y';
6115 ELSE
6116 RETURN 'N';
6117 END IF;
6118 END IF;
6119
6120 RETURN 'N';
6121
6122 EXCEPTION
6123 WHEN OTHERS THEN
6124 RETURN 'N';
6125 END Need_Query_All_Lines;
6126
6127
6128 -- bug4529937
6129 PROCEDURE Query_Changed_Lines(p_header_id IN NUMBER,
6130 x_line_tbl OUT NOCOPY OE_ORDER_PUB.LINE_TBL_TYPE ) AS
6131 i PLS_INTEGER;
6132 l_line_rec OE_ORDER_PUB.LINE_REC_TYPE;
6133 j PLS_INTEGER;
6134 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6135 BEGIN
6136 i := Oe_Line_Adj_Util.G_CHANGED_LINE_TBL.FIRST;
6137 j := 1;
6138 While i is Not Null Loop
6139 Begin
6140 --bug 3020702
6141 IF l_debug_level > 0 THEN
6142 oe_debug_pub.add('header_id:'||Oe_Line_Adj_Util.G_CHANGED_LINE_TBL(i).header_id);
6143 END IF;
6144 if oe_line_adj_util.G_CHANGED_LINE_TBL(i).header_id = p_header_id then
6145
6146 IF l_debug_level > 0 THEN
6147 oe_debug_pub.add('query line_id:'||Oe_Line_Adj_Util.G_CHANGED_LINE_TBL(i).line_id);
6148 END IF;
6149 query_line(Oe_Line_Adj_Util.G_CHANGED_LINE_TBL(i).line_id,l_line_rec);
6150 x_line_tbl(j):=l_line_rec;
6151 j:=j+1;
6152
6153 oe_debug_pub.add('link to line id:'|| l_line_rec.link_to_line_id);
6154
6155 LOOP
6156 IF l_line_rec.link_to_line_id IS NOT null
6157 and l_line_rec.link_to_line_id <> FND_API.G_MISS_NUM
6158 and l_line_rec.link_to_line_id <> l_line_rec.line_id
6159 and NOT OE_LINE_ADJ_UTIL.G_CHANGED_LINE_TBL.exists(mod(l_line_rec.link_to_line_id,G_BINARY_LIMIT))
6160 and NOT G_ADDED_PARENT_TBL.exists(mod(l_line_rec.link_to_line_id,G_BINARY_LIMIT)) THEN
6161 --child line has changed, need to send in parent lines to be repriced.
6162 --model line should not be added aga if exists in G_CHANGED_LINE_TBL.
6163 --use linked to line id to find the immediate parent.
6164 G_ADDED_PARENT_TBL(mod(l_line_rec.link_to_line_id,G_BINARY_LIMIT)) := l_line_rec.link_to_line_id;
6165 query_line(l_line_rec.link_to_line_id,l_line_rec);
6166 x_line_tbl(j):=l_line_rec;
6167 j:=j+1;
6168 ELSE
6169 EXIT;
6170 END IF;
6171 END LOOP;
6172
6173
6174
6175 end if;
6176 Exception
6177 When no_data_found Then
6178 IF l_debug_level > 0 THEN
6179 Oe_Debug_Pub.add('No data found for line id:'||Oe_Line_Adj_Util.G_CHANGED_LINE_TBL(i).line_id);
6180 END IF;
6181 End;
6182 i:= Oe_Line_Adj_Util.G_CHANGED_LINE_TBL.Next(i);
6183 End Loop;
6184 END Query_Changed_Lines;
6185
6186 procedure calculate_adjustments(
6187 x_return_status out nocopy varchar2
6188
6189 ,p_line_id number
6190 ,p_header_id number
6191 ,p_pricing_events varchar2
6192 ,p_Control_Rec OE_ORDER_PRICE_PVT.CONTROL_REC_TYPE
6193 ,p_action_code in Varchar2
6194 ,x_any_frozen_line out nocopy Boolean
6195
6196 ,x_Header_Rec out nocopy oe_Order_Pub.Header_REc_Type
6197
6198 ,px_line_Tbl in out nocopy oe_Order_Pub.Line_Tbl_Type
6199 )
6200 is
6201 l_return_status varchar2(1) := FND_API.G_RET_STS_SUCCESS;
6202 l_return_status_Text varchar2(240) ;
6203 l_header_rec OE_Order_PUB.Header_Rec_Type;
6204 l_Line_Tbl OE_Order_PUB.Line_Tbl_Type;
6205
6206 --1472635
6207 l_temp_line_tbl OE_Order_PUB.Line_Tbl_type;
6208 i2 PLS_INTEGER;
6209 l_all_lines_from_db Boolean :=False;
6210
6211 l_Line_Rec OE_Order_PUB.Line_Rec_Type;
6212
6213 -- AG change
6214 l_line_index NUMBER := 0;
6215 line_tbl_index pls_integer;
6216 i pls_integer;
6217 j pls_integer;
6218 l_bypass_pricing varchar2(30) := nvl(FND_PROFILE.VALUE('QP_BYPASS_PRICING'),'N');
6219 l_dummy Varchar2(1);
6220 l_header_id NUMBER;
6221 l_any_frozen_line BOOLEAN:=FALSE;
6222 l_calculate_price_flag varchar2(1);
6223 l_message_displayed Boolean:=FALSE;
6224 --btea begin
6225 l_Control_Rec QP_PREQ_GRP.CONTROL_RECORD_TYPE;
6226 --btea end
6227 l_order_line_id NUMBER;
6228 l_service_reference_line_id NUMBER;
6229 l_completely_frozen BOOLEAN := TRUE;
6230 l_line_attr_index number:=0;
6231 l_order_status_rec QP_UTIL_PUB.ORDER_LINES_STATUS_REC_TYPE;
6232 l_total_lines NUMBER;
6233 G_INT_CHANGED_LINE_ON Varchar2(3):= nvl(FND_PROFILE.VALUE('ONT_INTERNAL_CHANGED_LINE'),'Y');
6234 l_header_id2 NUMBER;
6235 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6236 l_check_line_flag varchar2(1);
6237 l_pass_line varchar2(1);
6238 --2740845 begin
6239 l_agreement_name varchar2(240);
6240 l_revision varchar2(50);
6241 --2740845 end
6242 l_req_line_tbl QP_PREQ_GRP.LINE_TBL_TYPE;
6243 --bug 3968023
6244 l_event_in_phase1 VARCHAR2(1);
6245 l_sql varchar2(4000); --bug 9436193
6246
6247 begin
6248
6249 IF l_debug_level > 0 THEN
6250 oe_debug_pub.add('Entering oe_order_price_pvt.calulate_adjustments', 0.5); -- debug level changed to 0.5 for bug 13435459
6251 END IF;
6252
6253 reset_all_tbls;
6254 --DELETE FROM QP_PREQ_LINES_TMP;
6255 --DELETE FROM QP_PREQ_LINE_ATTRS_TMP;
6256 --DELETE FROM QP_PREQ_LDETS_TMP;
6257 --DELETE FROM QP_PREQ_QUAL_TMP;
6258 --DELETE FROM QP_PREQ_RLTD_LINES_TMP;
6259
6260 G_STMT_NO := 'calculate_adjustments#10';
6261
6262
6263 if (p_line_id is null or p_line_id = FND_API.G_MISS_NUM)
6264 and ( p_header_id is null or p_header_id = FND_API.G_MISS_NUM)
6265 and px_line_Tbl.count =0
6266 and p_control_rec.p_use_current_header = FALSE
6267 then
6268 l_return_status := FND_API.G_RET_STS_ERROR;
6269
6270 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
6271 THEN
6272
6273 FND_MESSAGE.SET_NAME('ONT','OE_ATTRIBUTE_REQUIRED');
6274 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','line_id or Header Id ');
6275 OE_MSG_PUB.Add;
6276 END IF;
6277 RAISE FND_API.G_EXC_ERROR;
6278 end if;
6279
6280 G_STMT_NO := 'calculate_adjustments#20';
6281 if p_Line_id is not null and p_Header_id is not null then
6282 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6283 THEN
6284 OE_MSG_PUB.Add_Exc_Msg ( G_PKG_NAME ,
6285 'oe_line_adj.calulate_adjustments'
6286 ,'Keys are mutually exclusive');
6287 END IF;
6288 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6289 end if;
6290
6291 -- Query the header Record
6292 if p_header_id is not null and p_Header_id <> FND_API.G_MISS_NUM then
6293
6294 G_STMT_NO := 'calculate_adjustments#30';
6295
6296 Begin
6297 -- OE_Order_PUB.g_hdr := OE_ORDER_CACHE.g_header_rec;
6298 query_header( p_header_id => p_header_id, x_header_rec=>oe_order_pub.g_hdr);
6299 Exception when no_data_found then
6300 x_return_status := 'NOOP';
6301 IF l_debug_level > 0 THEN
6302 oe_debug_pub.add( G_STMT_NO||'INVALID HEADER_ID '||P_HEADER_ID , 1 ) ;
6303 END IF;
6304 Return;
6305 End;
6306
6307 G_STMT_NO := 'calculate_adjustments#40';
6308 j:=1;
6309
6310 Begin
6311
6312 oe_debug_pub.add('Before querying lines for header:'||p_Header_id||' event:'||p_pricing_events);
6313 -- How to determine whether all lines needs to be passed to Pricing Engine?
6314 -- 1. When BOOK button is pressed, all lines needs to be passed
6315 -- because caller wants line information back
6316 -- 2. When this procedure is called for G_PRICE_ADJ delayed request, pass all
6317 -- 3. If QP API says all line needs to be passed, do so
6318 -- 4. If QP API says all line no but changed line yes, see whether changed line
6319 -- table has all lines, if yes, pass all lines; if no, pass changed lines
6320 -- 5. If QP API says all line no and changed line no, do not pass any line
6321
6322 G_PASS_ALL_LINES := 'N';
6323 If G_INT_CHANGED_LINE_ON = 'Y'
6324 AND p_pricing_Events IS NOT NULL
6325 AND NOT (OE_GLOBALS.G_RECURSION_MODE <> 'Y' and p_pricing_events = 'BOOK')
6326 AND (p_pricing_events = 'SHIP' OR (NOT Oe_Line_Adj_Util.has_service_lines(p_header_id)))
6327 AND (p_action_code IS NULL or p_action_code <> 'PRICE_ORDER')
6328 --RT{
6329 AND p_pricing_events <> 'RETROBILL'
6330 --RT}
6331 Then
6332
6333 -- call QP API to determine whether or not to
6334 -- call lines to pricing engine.
6335 -- bug 9728497 start
6336 -- modified below for p_x_new_line_rec.header_id and p_x_new_line_rec.line_id
6337 -- being passed on to call the overloaded function.
6338 -- QP_UTIL_PUB.Get_Order_Lines_Status(p_pricing_events,l_order_status_rec);
6339 QP_UTIL_PUB.Get_Order_Lines_Status(p_event_code => p_pricing_events,
6340 p_header_id => p_header_id,
6341 p_line_id => p_Line_id,
6342 x_order_status_rec =>l_order_status_rec);
6343 -- bug 9728497 end
6344
6345
6346 oe_debug_pub.add(' All_lines_flag returned from pricing:'||l_order_status_rec.all_lines_flag);
6347 oe_debug_pub.add(' Changed_lines_flag returned from pricing:'||l_order_status_rec.Changed_lines_flag);
6348
6349
6350 If l_order_status_rec.ALL_LINES_FLAG = 'Y'
6351 and nvl(OE_LINE_ADJ_UTIL.G_SEND_ALL_LINES_FOR_DSP,'Y') = 'Y'
6352 and p_pricing_events <> 'SHIP'
6353 Then --bug 2965218
6354 ----------------------------------------------------------------
6355 --Pricing says pass all lines, use query_lines is more efficient
6356 --action_code = 'PRICE_ORDER' user asks for repricing all lines
6357 ----------------------------------------------------------------
6358 /* query_lines(p_header_id => p_Header_id
6359 , p_line_id => Null
6360 , x_line_tbl => l_Line_Tbl);
6361 */
6362 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
6363 G_PASS_ALL_LINES := 'R';
6364 ELSE
6365 G_PASS_ALL_LINES := 'Y';
6366 END IF;
6367 Elsif l_order_status_rec.CHANGED_LINES_FLAG = 'Y'
6368 OR nvl(OE_LINE_ADJ_UTIL.G_SEND_ALL_LINES_FOR_DSP,'Y') = 'N'
6369 OR p_pricing_events = 'SHIP'
6370 Then
6371 IF Need_Query_All_Lines(p_header_id) = 'Y' THEN
6372 IF l_debug_level > 0 THEN
6373 oe_debug_pub.add(' Need query all lines because all lines are changed');
6374 END IF;
6375 G_PASS_ALL_LINES := 'Y';
6376 ELSE
6377 -------------------------------------------------------------------
6378 --Pricing says passing only changed lines, use query_line
6379 --------------------------------------------------------------------
6380 oe_debug_pub.add('Query individual line changed:'||OE_Line_Adj_Util.G_CHANGED_LINE_TBL.count);
6381
6382 --bug4529937 have put the code to query for changed lines in a procedure
6383 Query_Changed_Lines(p_header_id => p_header_id,
6384 x_line_tbl => l_line_tbl);
6385 G_PASS_ALL_LINES := 'N';
6386 END IF; -- Need_Query_All_Lines
6387 END IF; -- QP API;
6388 Else
6389 G_PASS_ALL_LINES := 'Y';
6390 End If; -- changed_line no, no book button, no price_adj delayed request
6391
6392 If G_PASS_ALL_LINES in ('Y', 'R') Then
6393 --bug4529937 if the call is from mass change api, and there are more lines remaining to be processed after the current set, we would just pass the changed lines to pricing engine
6394 IF oe_mass_change_pvt.Lines_Remaining = 'Y' THEN
6395 IF l_debug_level > 0 THEN
6396 oe_debug_pub.add(' Query only changed line');
6397 END IF;
6398 Query_Changed_Lines(p_header_id => p_header_id, x_line_tbl => l_line_tbl);
6399 l_all_lines_from_db := FALSE;
6400 ELSE
6401 IF l_debug_level > 0 THEN
6402 oe_debug_pub.add(' Pass all the lines');
6403 END IF;
6404 query_lines(p_header_id => p_Header_id, p_line_id => Null, x_line_tbl => l_Line_Tbl);
6405 --1472635
6406 l_all_lines_from_db := True;
6407 END IF;
6408 End If;
6409 oe_debug_pub.add('line_count after querying:'||l_Line_Tbl.count);
6410
6411 /* debug statement
6412 For i in l_Line_Tbl.first .. l_Line_Tbl.last Loop
6413 oe_debug_pub.add('line id in l_line_tbl!:'||l_Line_Tbl(i).line_id);
6414 End Loop; */
6415
6416 Exception when no_data_found then
6417 -- No need to process this order
6418 x_return_status := 'NOOP';
6419 oe_debug_pub.add(G_STMT_NO||'Invalid header_id '||p_Header_id,1);
6420 Return;
6421 End;
6422
6423 ELSE -- Query the line Record
6424 G_STMT_NO := 'calculate_adjustments#50';
6425 If px_line_Tbl.count = 0 Then
6426 Begin
6427 query_lines(p_line_id =>p_line_id, p_header_id => Null, x_line_tbl=>l_Line_Tbl );
6428 Exception when no_data_found then
6429 -- No need to process this line
6430 x_return_status := 'NOOP';
6431 oe_debug_pub.add(G_STMT_NO||'Invalid line_id '||p_line_id,1);
6432 Return;
6433 End ;
6434 Else
6435 l_Line_Tbl := px_line_Tbl;
6436 End If;
6437
6438 G_STMT_NO := 'calculate_adjustments#60';
6439
6440 If p_control_rec.p_use_current_header = FALSE Then
6441 Begin
6442 query_header(l_line_tbl(1).header_id, oe_order_pub.g_hdr);
6443 Exception when no_data_found then
6444 -- No need to process this order
6445 x_return_status := 'NOOP';
6446 oe_debug_pub.add(G_STMT_NO||'Invalid header_id '||l_line_Tbl(1).Header_id,1);
6447 Return;
6448 End ;
6449 Else
6450 --Do Nothing since the flag says that the global record has been set
6451 NULL;
6452 End If;
6453 END IF;
6454
6455 x_header_rec := oe_order_pub.g_hdr;
6456 G_STMT_NO := 'calculate_adjustments#110';
6457
6458 line_Tbl_Index := l_Line_Tbl.First;
6459 While line_Tbl_Index is not null loop
6460 -- Do not price the config items
6461 --If oe_line_util.Get_Return_Item_Type_Code(l_Line_Tbl(line_Tbl_Index)) <> 'CONFIG' Then
6462
6463 -- Added to check if Agreement is Active for Bug#2740845
6464 If l_line_tbl(line_Tbl_Index).agreement_id is not null Then
6465 BEGIN
6466 Select 'x' into l_dummy from dual
6467 where exists (select 'x' from oe_agreements_vl where
6468 agreement_id = l_line_tbl(line_Tbl_Index).agreement_id and
6469 ( trunc(nvl(l_line_tbl(line_Tbl_Index).PRICING_DATE,sysdate))
6470 between
6471 trunc(nvl(start_date_active, nvl(l_line_tbl(line_Tbl_Index).PRICING_DATE,sysdate)))
6472 and
6473 trunc(nvl(end_date_active, nvl(l_line_tbl(line_Tbl_Index).PRICING_DATE, sysdate)))));
6474
6475 --If l_dummy <>'x' then
6476
6477 Exception
6478 When no_data_found then
6479 Begin
6480 select name, revision into l_agreement_name, l_revision
6481 from oe_agreements_vl where agreement_id =
6482 l_line_tbl(line_Tbl_Index).agreement_id;
6483
6484 Exception
6485 When no_data_found then
6486 null;
6487 End;
6488 fnd_message.set_name('ONT','ONT_INVALID_AGR_REVISION');
6489 fnd_message.set_TOKEN('AGREEMENT',l_agreement_name||' : '||l_revision);
6490 fnd_message.set_TOKEN('PRICING_DATE',l_line_tbl(line_Tbl_Index).PRICING_DATE);
6491 OE_MSG_PUB.Add;
6492 RAISE FND_API.G_EXC_ERROR;
6493 END;
6494 End If;
6495 --End 2740845
6496
6497 -- Populate that Global Structure
6498 OE_Order_PUB.G_LINE := l_Line_Tbl(line_Tbl_Index);
6499 If OE_Order_PUB.G_LINE.unit_list_price = fnd_api.g_miss_num then
6500 OE_Order_PUB.G_LINE.unit_list_price:= Null;
6501 End If;
6502
6503 --RT{
6504 IF G_PRICING_EVENT='RETROBILL'
6505 AND nvl(G_RETROBILL_OPERATION,'xx')<>'CREATE'
6506 AND l_Line_Tbl(line_Tbl_Index).retrobill_request_id IS NOT NULL THEN
6507 --a reprice of retrobill order, need to preprocess adjustments
6508 Oe_Retrobill_Pvt.Preprocess_Adjustments(l_Line_Tbl(line_Tbl_Index).orig_sys_document_ref,
6509 l_Line_Tbl(line_Tbl_Index).orig_sys_line_ref,
6510 l_Line_Tbl(line_Tbl_Index).header_id, --bug3738043
6511 l_Line_Tbl(line_Tbl_Index).line_id );
6512 END IF;
6513 --RT}
6514
6515
6516 If (OE_Order_PUB.G_LINE.Service_Reference_Line_Id <> FND_API.G_MISS_NUM and
6517 OE_Order_PUB.G_LINE.Service_Reference_Line_Id is not null)
6518 Then
6519 /* Added the following if condition for fixing the bug 1828553 */
6520 /* If the service reference context is ORDER, then the service_reference*/
6521 /*line_id is the line_id of the parent. However, if the service ref */
6522 /*context is Customer Product then we need to first retrieve the */
6523 /*original order line id */
6524
6525 IF l_Line_Tbl(line_Tbl_Index).item_type_code = 'SERVICE' AND
6526 l_Line_Tbl(line_Tbl_Index).service_reference_type_code='CUSTOMER_PRODUCT' AND
6527 l_line_Tbl(line_Tbl_Index).cancelled_flag = 'N' AND
6528 l_Line_Tbl(line_Tbl_Index).service_reference_line_id IS NOT NULL
6529 THEN
6530 oe_debug_pub.add('1828553: Line is a customer product');
6531 OE_SERVICE_UTIL.Get_Cust_Product_Line_Id
6532 ( x_return_status => l_return_status
6533 , p_reference_line_id => l_Line_Tbl(line_Tbl_Index).service_reference_line_id
6534 , p_customer_id => l_Line_Tbl(line_Tbl_Index).sold_to_org_id
6535 , x_cust_product_line_id => l_order_line_id
6536 );
6537 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
6538 oe_debug_pub.add('1828553: Success');
6539 oe_debug_pub.add('1828553: Service line id is ' || l_order_line_id);
6540 l_service_reference_line_id := l_order_line_id;
6541 ELSE
6542 oe_debug_pub.add('Not able to retrieve cust product line id');
6543 RAISE NO_DATA_FOUND;
6544 END IF;
6545 ELSE
6546 l_service_reference_line_id := l_Line_Tbl(line_Tbl_Index).service_reference_line_id;
6547 END IF;
6548
6549 oe_debug_pub.add('1828553: l_Service_Reference_Line_Id: '||l_Service_Reference_line_id);
6550
6551 --3273289{
6552 If(l_Service_Reference_Line_Id is NOT NULL) THEN
6553 --bug 3968023 to call the procedure Get_The_Parent_Line only if the event contains phase 1
6554 BEGIN
6555 l_event_in_phase1 := 'N';
6556 --- bug# 9436193 : Start : using dynamic sql
6557 oe_debug_pub.add(' l_event_in_phase1 = '||l_event_in_phase1||' p_pricing_events = '||p_pricing_events);
6558 l_sql := 'SELECT ''Y'' FROM qp_pricing_phases p, qp_event_phases e WHERE p.pricing_phase_id=e.pricing_phase_id'
6559 ||' AND p.pricing_phase_id = 1 AND trunc(sysdate) BETWEEN trunc(nvl(e.end_date_active,sysdate)) AND trunc(nvl(e.end_date_active,sysdate))'
6560 ||' AND e.pricing_event_code in ('''||replace(trim(p_pricing_events),',',''',''')||''') ' ;
6561 oe_debug_pub.add(' l_sql = '||l_sql);
6562 EXECUTE IMMEDIATE l_sql INTO l_event_in_phase1;
6563 oe_debug_pub.add('after l_sql: l_event_in_phase1 =>> '||l_event_in_phase1);
6564 /*
6565 SELECT 'Y' INTO l_event_in_phase1
6566 FROM qp_pricing_phases p,
6567 qp_event_phases e
6568 WHERE p.pricing_phase_id=e.pricing_phase_id
6569 AND p.pricing_phase_id = 1
6570 AND e.pricing_event_code= p_pricing_events
6571 AND trunc(sysdate) BETWEEN trunc(nvl(e.end_date_active,sysdate)) AND trunc(nvl(e.end_date_active,sysdate));
6572 */
6573 --- bug# 9436193 : Ends
6574
6575 IF l_event_in_phase1 = 'Y' THEN
6576 Get_the_parent_Line(p_Reference_line_Id => l_Service_Reference_Line_Id,
6577 p_line_Tbl_Index => line_Tbl_Index,
6578 px_Line_Tbl => l_Line_Tbl) ;
6579 END IF;
6580 EXCEPTION
6581 WHEN NO_DATA_FOUND THEN
6582 oe_debug_pub.add(' <exception block>: no_Data_found error ... ');
6583 null;
6584
6585 WHEN OTHERS THEN
6586 oe_debug_pub.add(' <exception block>: SQLERRM ... '|| SQLERRM );
6587 END;
6588 --bug 3968023
6589 END IF;
6590 --3273289}
6591 End If; --- IF (OE_Order_PUB.G_LINE.Service_Reference_Line_Id <> FND_API.G_MISS_NUM
6592
6593 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
6594 oe_debug_pub.add('calling get_prg_lines 5647210 added mass change');
6595 IF ((p_line_id IS NOT NULL and p_control_rec.p_write_to_db) OR oe_mass_change_pvt.Lines_Remaining = 'Y')
6596 THEN
6597 Get_PRG_Lines(l_line_tbl(line_tbl_index).line_id, l_line_tbl, line_tbl_index);
6598 -- 3529369 In the case overriding the list price of servicable line the service lines will be
6599 -- repriced if they are in the same order and service line has an service_reference_type of order
6600 IF (l_line_tbl(line_tbl_index).item_type_code <> 'SERVICE' AND
6601 l_line_tbl(line_tbl_index).calculate_price_flag <> 'X' AND
6602 l_line_tbl(line_tbl_index).original_list_price is NOT NULL )
6603 THEN
6604 Get_Service_Lines(l_line_tbl(line_tbl_index).line_id,l_line_tbl(line_tbl_index).header_id, l_line_tbl, line_tbl_index);
6605 END IF;
6606 -- 3529369
6607 END IF;
6608 END IF;
6609
6610 -- Get Line Attributes
6611 G_STMT_NO := 'calculate_adjustments#125';
6612
6613 -- Set the old item during pricing
6614 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
6615 Get_item_for_iue(px_line_rec => OE_Order_PUB.G_LINE);
6616 END IF;
6617
6618 G_STMT_NO := 'calculate_adjustments#135';
6619
6620
6621 --Set a flag if this line has a calculate flag of N or P
6622 --which is frozen line. This flag will be used later
6623 --when passing summary line (order level) to pricing engine
6624 --with calculate_price of N (do not touch the order level amount).
6625 IF l_line_tbl(line_tbl_index).item_type_code not in ('CONFIG', 'INCLUDED') THEN
6626 IF (l_line_tbl(line_tbl_index).calculate_price_flag IN ('N','P')
6627 AND l_line_tbl(line_tbl_index).cancelled_flag = 'N')
6628 THEN
6629 l_any_frozen_line := TRUE;
6630 x_any_frozen_line := TRUE;
6631 oe_debug_pub.add('Any frozen line is true');
6632 IF l_line_tbl(line_tbl_index).calculate_price_flag = 'P' THEN
6633 l_completely_frozen := FALSE;
6634 END IF;
6635 ELSIF l_line_tbl(line_tbl_index).calculate_price_flag = 'Y' THEN
6636 l_completely_frozen := FALSE;
6637 END IF;
6638 END IF; /* if item type code in ('CONFIG', 'INCLUDED') */
6639
6640
6641 --RT{
6642 IF p_pricing_events = 'RETROBILL' and l_line_tbl(line_tbl_index).retrobill_request_id IS NULL
6643 OR
6644 p_pricing_events <> 'RETROBILL' and nvl(l_line_tbl(line_tbl_index).retrobill_request_id,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM
6645 THEN
6646 --Do nothing for these invalid combinations
6647 --RETROBILL event must have retrobill_request_id
6648 --Request None retrobill event with retrobill_request_id should be ignored
6649 oe_debug_pub.add('VOPRB:event'||p_pricing_events||'retrobill id:'||l_line_tbl(line_tbl_index).retrobill_request_id);
6650 NULL;
6651 ELSE
6652 --RT{
6653 IF l_line_tbl(line_tbl_index).retrobill_request_id IS NOT NULL THEN
6654 --the order has retrobill lines, no header level adjustment should be allowed
6655 --set following flags so that header level adjustment will not be fetched.
6656 l_any_frozen_line:=TRUE;
6657 l_completely_frozen:=FALSE;
6658 END IF;
6659 --RT}
6660
6661 G_STMT_NO := 'Build_Context for Line';
6662 If l_bypass_pricing = 'Y' OR l_line_tbl(line_tbl_index).calculate_price_flag = 'X' Then
6663 oe_debug_pub.add('Bypassing the qualifier build',1);
6664 l_check_line_flag := 'N';
6665 l_pass_line := 'Y';
6666 l_line_index := l_line_index + 1;
6667 Else
6668 oe_debug_pub.add('Before QP_Attr_Mapping_PUB.Build_Contexts for line',1);
6669 IF (G_PASS_ALL_LINES = 'R' and
6670 NOT OE_LINE_ADJ_UTIL.G_CHANGED_LINE_TBL.exists(mod(l_line_Tbl(line_tbl_index).line_id,G_BINARY_LIMIT))
6671 and OE_CODE_CONTROL.Get_Code_Release_Level >= '110509')
6672 THEN
6673 l_check_line_flag := 'Y';
6674 ELSE
6675 l_check_line_flag := 'N';
6676 END IF;
6677
6678 --Check_line_flag is to tell QP attr mapping api wether it should
6679 --check if there is any attribute, that could affect pricing, has changed.
6680 --if 'Y', QP sourcing api will check. If there are changes of attribute
6681 --,which could affect the pricing, it will return x_pass_line = 'Y'. This
6682 --means we will need to pass this line. If QP return 'N', we will not pass
6683 --this line to pricing. Copy_line_to_request will not copy the line to pricing
6684 --request line if QP 'N'.
6685
6686 --If we pass check_line_flag = 'N' to QP, this means a old behavior (pre I), or
6687 --we want to force sourcing and repricing of a line. This is usually the case
6688 --for action-->price_line call in UI.
6689
6690 --If p_header_id is null means caller tries to price individual line
6691 --in this case, we should force a reprice of the line. No optimization
6692 --like to check the l_pass_line is needed #bug 289804100.
6693 --QP will need to unconditionally build sourcing.
6694 --BTEA
6695
6696 oe_debug_pub.add('p_header_id:'||nvl(p_header_id,-100));
6697
6698 IF p_header_id IS NULL THEN
6699 l_check_line_flag := 'N';
6700 END IF;
6701
6702 -- bug 3643645
6703 l_line_index := l_line_index + 1;
6704 oe_debug_pub.add('before build_context:'||l_line_index, 5);
6705 QP_Attr_Mapping_PUB.Build_Contexts(
6706 p_request_type_code => 'ONT',
6707 p_line_index => l_line_index,
6708 p_pricing_type_code => 'L',
6709 p_check_line_flag => l_check_line_flag,
6710 p_pricing_event => p_pricing_events,
6711 x_pass_line => l_pass_line
6712 );
6713 -- bug 3643645
6714 IF (l_pass_line = 'N') THEN
6715 l_line_index := l_line_index - 1;
6716 END IF;
6717
6718 if (l_debug_level > 0) Then
6719 oe_debug_pub.add('after build_context:'||l_line_index);
6720 end if;
6721 End If; -- bypass pricing
6722
6723 IF l_debug_level > 0 THEN
6724 oe_debug_pub.add('check line'||l_check_line_flag||' pass line:'||l_pass_line);
6725 END IF;
6726
6727
6728 If l_check_line_flag = 'N' or l_pass_line = 'Y' Then
6729
6730 G_STMT_NO := 'calculate_adjustments#140';
6731 -- AG change
6732 copy_Line_to_request(
6733 p_Line_rec => l_Line_Tbl(line_Tbl_Index)
6734 ,p_pricing_events => p_pricing_events
6735 ,px_req_line_tbl => l_req_line_tbl
6736 ,p_request_type_code =>p_control_rec.p_request_type_code
6737 ,p_honor_price_flag =>p_control_rec.p_honor_price_flag
6738 ,px_line_index => l_line_index );
6739 Begin
6740 l_header_id2:=nvl(p_header_id, l_line_tbl(line_tbl_index).header_id);
6741 Select 'x' into l_dummy from dual
6742 Where exists
6743 (select 'x' from oe_order_price_attribs oopa
6744 where nvl(oopa.line_id,l_Line_Tbl(line_Tbl_Index).line_id) = l_Line_Tbl(line_Tbl_Index).line_id
6745 and oopa.header_id = l_header_id2);
6746
6747
6748 -- AG change --
6749 Append_asked_for(p_header_id => l_header_id2,
6750 p_line_id => l_Line_Tbl(line_Tbl_Index).line_id,
6751 p_line_index => l_line_index, --l_req_line_tbl.count
6752 px_line_attr_index => l_line_attr_index
6753 );
6754 Exception
6755 when no_data_found then null;
6756 End;
6757 End If; -- pass line
6758
6759 -- added by lkxu, to set the value back to 'N' after setting price flag.
6760 IF l_line_Tbl(line_Tbl_Index).calculate_price_flag = 'X' THEN
6761 l_line_Tbl(line_Tbl_Index).calculate_price_flag := 'N';
6762 END IF;
6763 --End If; -- Item is not Config
6764 END IF; --END IF for checking retrobill event and id combination
6765 --RT}
6766
6767 line_Tbl_Index := l_Line_Tbl.Next(line_Tbl_Index);
6768
6769 END LOOP;
6770
6771 -- Get Header Attributes
6772
6773
6774 G_STMT_NO := 'calculate_adjustments#145';
6775 -- Build header Request
6776
6777 G_STMT_NO := 'calculate_adjustments#150';
6778
6779
6780 IF nvl(p_control_rec.p_honor_price_flag,'Y') = 'N' THEN
6781 --As per bug 3472375
6782 -- This affects two cases:
6783 -- 1. apply line level manual adjustments when every line on the order is set to
6784 -- frozen and there is an order level adjustment already applied
6785 -- 2. repricing at shipment, when the workflow attribute honor price flag is set
6786 -- to "No" and there is an order level adjustment already applied
6787 -- .
6788 -- For both cases, we can make the same change, when honor_price_flag is set to
6789 -- "No", send the price_flag on the summary line as "Y".
6790 l_calculate_price_flag :='Y';
6791 ELSE
6792 IF (l_any_frozen_line=TRUE) THEN
6793
6794 IF l_completely_frozen = FALSE THEN
6795 l_calculate_price_flag := 'P';
6796 ELSE
6797 l_calculate_price_flag := 'N';
6798 END IF;
6799
6800 If Not l_message_displayed Then
6801 l_message_displayed := TRUE;
6802 End If;
6803
6804 l_any_frozen_line:=FALSE;
6805 oe_debug_pub.add('BCT:ONT_LINE_FROZEN');
6806
6807 Elsif l_all_lines_from_db = False Then
6808 --1472635
6809 --Didn't query from db, need to do that to check if
6810 --all other previously save lines is frozen
6811 oe_debug_pub.add('BCT all line from db is false');
6812
6813 If p_header_id is null then
6814 --ine_tbl_index := l_line_tbl.first;
6815 l_header_id := l_line_tbl(l_line_tbl.first).header_id;
6816 Else
6817 l_header_id := p_header_id;
6818 End If;
6819 oe_debug_pub.add('BCT order header id '||l_header_id);
6820
6821 Begin
6822 BEGIN
6823
6824 Select 'x' into l_dummy
6825 from dual where
6826 exists(select 'x' from oe_order_lines
6827 Where header_id = l_header_id
6828 and calculate_price_flag in ('Y','P')
6829 and item_type_code not in ('CONFIG', 'INCLUDED'));
6830 l_completely_frozen := FALSE;
6831 EXCEPTION
6832 WHEN NO_DATA_FOUND THEN
6833 l_completely_frozen := TRUE;
6834 l_any_frozen_line :=True;
6835 x_any_frozen_line :=True;
6836 l_calculate_price_flag := 'N';
6837 END;
6838
6839 IF l_completely_frozen = FALSE THEN
6840 Select 'p' into l_dummy
6841 from dual where
6842 exists (select 'x' from oe_order_lines
6843 where header_id = l_header_id
6844 and calculate_price_flag in ('N', 'P')
6845 and cancelled_flag = 'N'
6846 and item_type_code not in ('CONFIG', 'INCLUDED') );
6847
6848 l_any_frozen_line := TRUE;
6849 x_any_frozen_line := TRUE;
6850 l_calculate_price_flag := 'P';
6851 END IF;
6852
6853 Exception
6854 when no_data_found then
6855 null;
6856 End;
6857
6858 If nvl(l_calculate_price_flag,'X') not in ('N','P') Then
6859 l_calculate_price_flag:='Y';
6860 End If;
6861 ELSE
6862 oe_debug_pub.add('BCT:any_frozen_line is false');
6863 l_calculate_price_flag := 'Y';
6864 END IF;
6865 END IF; --end if for honor price flag check
6866
6867
6868
6869 -- AG change --
6870 copy_Header_to_request(
6871 p_header_rec => OE_Order_PUB.g_hdr
6872 ,px_req_line_tbl => l_req_line_tbl
6873 ,p_Request_Type_Code => p_control_rec.p_Request_Type_Code
6874 ,p_calculate_price_flag =>l_calculate_price_flag
6875 ,px_line_index => l_line_index);
6876
6877 G_STMT_NO := 'Build_Context for Header';
6878 IF l_bypass_pricing = 'Y' Then
6879 oe_debug_pub.add('Bypassing the qualifier build',1);
6880 Else
6881 oe_debug_pub.add('Before QP_Attr_Mapping_PUB.Build_Contexts for Header',1);
6882 QP_Attr_Mapping_PUB.Build_Contexts(
6883 p_request_type_code => 'ONT',
6884 --p_line_index=> l_line_index,
6885 p_line_index=> l_line_index, --oe_order_pub.g_hdr.header_id,
6886 p_pricing_type_code => 'H');
6887
6888 END IF;
6889
6890 G_STMT_NO := 'calculate_adjustments#170';
6891
6892 Begin
6893 l_header_id2:= nvl(p_header_id,l_line_tbl(l_line_tbl.first).header_id);
6894 Select 'x' into l_dummy from dual
6895 where exists(
6896 Select 'X' from oe_order_price_attribs oopa
6897 where oopa.header_id = l_header_id2 and oopa.line_id is null);
6898
6899 -- AG change --
6900 Append_asked_for(
6901 p_header_id => l_header_id2
6902 , p_line_id => NULL
6903 ,p_line_index => l_line_index --l_req_line_tbl.count
6904 , px_line_attr_index => l_line_attr_index);
6905 Exception
6906 when no_data_found then
6907 null;
6908 when others then
6909 Oe_Debug_Pub.Add('Error when querying asked_for:'||SQLERRM);
6910 End;
6911
6912 G_STMT_NO := 'calculate_adjustments#180';
6913 -- AG change --
6914 IF l_line_index > 0 THEN
6915 Populate_Temp_Table;
6916 END IF;
6917
6918 x_header_Rec := OE_Order_PUB.g_hdr;
6919 px_line_tbl := l_line_tbl;
6920
6921 EXCEPTION
6922 when FND_API.G_EXC_ERROR then
6923 oe_debug_pub.add('error in calculate adjustments'||G_STMT_NO, 2);
6924 RAISE FND_API.G_EXC_ERROR;
6925 when others then
6926 oe_debug_pub.add('others error in calculate adjustments'||G_STMT_NO,2);
6927 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6928 End Calculate_Adjustments;
6929
6930
6931
6932
6933
6934
6935 Procedure Call_Pricing_Engine(
6936 p_Control_Rec IN OE_ORDER_PRICE_PVT.control_rec_type
6937 ,p_Pricing_Events IN VARCHAR2
6938 ,x_return_status OUT NOCOPY VARCHAR2
6939
6940 )
6941 IS
6942 l_return_status_text varchar(2000);
6943 l_control_rec QP_PREQ_GRP.control_record_type;
6944 l_set_of_books Oe_Order_Cache.Set_Of_Books_Rec_Type;
6945 /*
6946 l_req_line_tbl QP_PREQ_GRP.LINE_TBL_TYPE;
6947 l_Req_qual_tbl QP_PREQ_GRP.QUAL_TBL_TYPE;
6948 l_Req_line_attr_tbl QP_PREQ_GRP.LINE_ATTR_TBL_TYPE;
6949 l_Req_LINE_DETAIL_tbl QP_PREQ_GRP.LINE_DETAIL_TBL_TYPE;
6950 l_Req_LINE_DETAIL_qual_tbl QP_PREQ_GRP.LINE_DETAIL_QUAL_TBL_TYPE;
6951 l_Req_LINE_DETAIL_attr_tbl QP_PREQ_GRP.LINE_DETAIL_ATTR_TBL_TYPE;
6952 l_Req_related_lines_tbl QP_PREQ_GRP.RELATED_LINES_TBL_TYPE;
6953 l_pricing_contexts_Tbl QP_Attr_Mapping_PUB.Contexts_Result_Tbl_Type;
6954 l_qualifier_contexts_Tbl QP_Attr_Mapping_PUB.Contexts_Result_Tbl_Type;
6955 x_req_line_tbl QP_PREQ_GRP.LINE_TBL_TYPE;
6956 x_Req_qual_tbl QP_PREQ_GRP.QUAL_TBL_TYPE;
6957 x_Req_line_attr_tbl QP_PREQ_GRP.LINE_ATTR_TBL_TYPE;
6958 x_Req_LINE_DETAIL_tbl QP_PREQ_GRP.LINE_DETAIL_TBL_TYPE;
6959 x_Req_LINE_DETAIL_qual_tbl QP_PREQ_GRP.LINE_DETAIL_QUAL_TBL_TYPE;
6960 x_Req_LINE_DETAIL_attr_tbl QP_PREQ_GRP.LINE_DETAIL_ATTR_TBL_TYPE;
6961 x_Req_related_lines_tbl QP_PREQ_GRP.RELATED_LINES_TBL_TYPE;
6962 */
6963 --
6964 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6965 --
6966 BEGIN
6967 IF l_debug_level > 0 THEN
6968 oe_debug_pub.add( 'BEFORE QP_PREQ_PUB.PRICE_REQUEST' , 1 ) ;
6969 END IF;
6970
6971 l_control_rec.calculate_flag := p_control_rec.p_calculate_flag;
6972 l_control_rec.simulation_flag := p_control_rec.p_simulation_flag;
6973 l_control_rec.pricing_event := p_Pricing_Events;
6974 l_control_rec.temp_table_insert_flag := 'N';
6975 l_control_rec.check_cust_view_flag := 'Y';
6976 l_control_rec.request_type_code := p_control_rec.p_request_type_code;
6977 --now pricing take care of all the roundings.
6978 l_control_rec.rounding_flag := 'Q';
6979 --For multi_currency price list
6980 l_control_rec.use_multi_currency:='Y';
6981 l_control_rec.USER_CONVERSION_RATE:= OE_ORDER_PUB.G_HDR.CONVERSION_RATE;
6982 l_control_rec.USER_CONVERSION_TYPE:= OE_ORDER_PUB.G_HDR.CONVERSION_TYPE_CODE;
6983 l_set_of_books := Oe_Order_Cache.Load_Set_Of_Books;
6984 l_control_rec.FUNCTION_CURRENCY := l_set_of_books.currency_code;
6985
6986 If l_Control_Rec.pricing_event IN ('BATCH','RETROBILL') OR
6987 nvl(instr( l_Control_Rec.pricing_event,'BATCH'),0) > 0
6988 Then
6989 l_control_rec.source_order_amount_flag := 'Y';
6990 End If;
6991
6992 -- added for freight rating.
6993 l_control_rec.get_freight_flag := p_control_rec.p_get_freight_flag;
6994 IF l_debug_level > 0 THEN
6995 oe_debug_pub.add('get_freight_flag before calling pricing engine is: '||l_control_rec.get_freight_flag, 3 ) ;
6996 END IF;
6997
6998 IF (G_PASS_ALL_LINES in ('N', 'R')) THEN
6999 l_control_rec.full_pricing_call := 'N';
7000 ELSE
7001 l_control_rec.full_pricing_call := 'Y';
7002 END IF;
7003 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
7004 l_control_rec.manual_adjustments_call_flag := 'N';
7005 END IF;
7006
7007 G_STMT_NO := 'QP_PRICE_REQUEST_GRP';
7008 QP_PREQ_PUB.PRICE_REQUEST
7009 (p_control_rec => l_control_rec
7010 --,p_line_tbl => l_Req_line_tbl
7011 --,p_qual_tbl => l_Req_qual_tbl
7012 --,p_line_attr_tbl => l_Req_line_attr_tbl
7013 --,p_line_detail_tbl =>l_req_line_detail_tbl
7014 --,p_line_detail_qual_tbl =>l_req_line_detail_qual_tbl
7015 --,p_line_detail_attr_tbl =>l_req_line_detail_attr_tbl
7016 --,p_related_lines_tbl =>l_req_related_lines_tbl
7017 --,x_line_tbl =>x_req_line_tbl
7018 --,x_line_qual =>x_Req_qual_tbl
7019 --,x_line_attr_tbl =>x_Req_line_attr_tbl
7020 --,x_line_detail_tbl =>x_req_line_detail_tbl
7021 --,x_line_detail_qual_tbl =>x_req_line_detail_qual_tbl
7022 --,x_line_detail_attr_tbl =>x_req_line_detail_attr_tbl
7023 --,x_related_lines_tbl =>x_req_related_lines_tbl
7024 ,x_return_status =>x_return_status
7025 ,x_return_status_Text =>l_return_status_Text
7026 );
7027
7028 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7029 FND_MESSAGE.SET_NAME('ONT','ONT_PRICING_ERRORS'); --bug#7149497
7030 FND_MESSAGE.SET_TOKEN('ERR_TEXT',l_return_status_text);
7031 OE_MSG_PUB.Add;
7032 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7033 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
7034 FND_MESSAGE.SET_NAME('ONT','ONT_PRICING_ERRORS'); --bug#7149497
7035 FND_MESSAGE.SET_TOKEN('ERR_TEXT',l_return_status_text);
7036 OE_MSG_PUB.Add;
7037 RAISE FND_API.G_EXC_ERROR;
7038 END IF;
7039
7040 END Call_Pricing_Engine;
7041
7042
7043
7044 procedure pricing_errors_hold(
7045 p_header_id number
7046 ,p_line_id number
7047 , pmsg varchar2
7048 )
7049
7050 is
7051 l_hold_source_rec OE_Holds_Pvt.hold_source_rec_type;
7052 l_return_status varchar2(30);
7053 l_x_msg_count number;
7054 l_x_msg_data Varchar2(2000);
7055 l_x_result_out Varchar2(30);
7056 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
7057
7058 begin
7059
7060 l_hold_source_rec.hold_id := G_SEEDED_PRICE_ERROR_HOLD_ID;
7061 l_hold_source_rec.hold_entity_id := p_header_id;
7062 l_hold_source_rec.Hold_Entity_code := 'O';
7063 l_hold_source_rec.header_id := p_header_id;
7064 l_hold_source_rec.line_id := p_line_id;
7065 IF l_debug_level > 0 THEN
7066 oe_debug_pub.add('p_line_id = '||p_line_id,1);
7067 END IF;
7068
7069 OE_Holds_Pub.Check_Holds(
7070 p_api_version => 1.0
7071 ,p_header_id => p_header_id
7072 ,p_line_id => p_line_id
7073 ,p_hold_id => l_hold_source_rec.Hold_id
7074 ,p_wf_item => 'OEOL'
7075 ,p_wf_activity => 'INVENTORY_INTERFACE'
7076 ,x_return_status => l_return_status
7077 ,x_msg_count => l_x_msg_count
7078 ,x_msg_data => l_x_msg_data
7079 ,x_result_out => l_x_result_out
7080
7081 );
7082
7083 IF (l_return_status <> FND_API.g_ret_sts_success) THEN
7084 IF l_debug_level > 0 THEN
7085 oe_debug_pub.add(' OE_HOLD_PUB.Check_Holds returns unexpected error!');
7086 END IF;
7087 RAISE FND_API.G_EXC_ERROR;
7088 null;
7089 END IF;
7090 IF l_x_result_out = FND_API.G_FALSE THEN
7091 OE_HOLDS_PUB.Apply_Holds(
7092 p_api_version => 1.0
7093 ,p_hold_source_rec => l_hold_source_rec
7094 -- ,p_header_id => l_line_rec.header_id
7095 -- ,p_line_id => l_line_rec.line_id
7096 ,x_return_status => l_return_status
7097 ,x_msg_count => l_x_msg_count
7098 ,x_msg_data => l_x_msg_data
7099 );
7100 END IF;
7101
7102 IF l_return_status = FND_API.g_ret_sts_success then
7103 IF l_debug_level > 0 THEN
7104 oe_debug_pub.add('just before showing formula error',1);
7105 END IF;
7106
7107 FND_MESSAGE.SET_NAME('ONT','ONT_PRICING_ERROR_HOLD');
7108 FND_MESSAGE.SET_TOKEN('ERR_TEXT',pmsg);
7109 OE_MSG_PUB.Add;
7110 End if;
7111 exception
7112 WHEN FND_API.G_EXC_ERROR then
7113 null;
7114 end;
7115
7116
7117
7118 Function get_formula(p_line_index In Number) Return Varchar2 IS
7119 Cursor Get_Formula Is
7120 Select f.formula
7121 From qp_ldets_v ldet, qp_list_lines qpll, qp_price_formulas_vl f
7122 Where ldet.line_index = p_line_index
7123 AND ldet.list_line_id = qpll.list_line_id
7124 AND f.price_formula_id = nvl(qpll.price_by_formula_id,qpll.generate_using_formula_id);
7125 l_formula_name Varchar2(2000);
7126 Begin
7127 open get_formula;
7128 fetch get_formula into l_formula_name;
7129 return l_formula_name;
7130 close get_formula;
7131 Exception
7132 when no_data_found then
7133 oe_debug_pub.add('Formula name not found for the errorneous formula');
7134 return null;
7135 End;
7136
7137 procedure Report_Engine_Errors(
7138 x_return_status out nocopy Varchar2
7139
7140 , p_Control_Rec IN OE_ORDER_PRICE_PVT.Control_rec_type
7141 , px_line_Tbl in out NOCOPY oe_Order_Pub.Line_Tbl_Type
7142 , p_header_rec IN oe_Order_Pub.header_rec_type
7143 )
7144 is
7145 l_line_rec oe_order_pub.line_rec_type;
7146 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
7147 i pls_Integer;
7148 j pls_Integer:=0;
7149 l_price_list Varchar2(240);
7150 l_allow_negative_price Varchar2(30) := nvl(fnd_profile.value('ONT_NEGATIVE_PRICING'),'N');
7151 l_invalid_line Varchar2(1):='N';
7152 l_temp_line_rec oe_order_pub.line_rec_type;
7153 l_request_id NUMBER;
7154 vmsg Varchar2(2000);
7155 l_list_line_no Varchar2(2000);
7156 --bug 3696768
7157 cursor reset_ipl_tbl is
7158 select line_id
7159 from qp_preq_lines_tmp
7160 where pricing_status_code <> QP_PREQ_GRP.G_STATUS_INVALID_PRICE_LIST;
7161 --bug 3696768
7162 cursor wrong_lines is
7163 select line_id
7164 , line_index
7165 , line_type_code
7166 , processed_code
7167 , pricing_status_code
7168 , pricing_status_text status_text
7169 , unit_price
7170 , adjusted_unit_price
7171 , priced_quantity
7172 , line_quantity
7173 , priced_uom_code
7174 from qp_preq_lines_tmp
7175 where process_status <> 'NOT_VALID' and
7176 (pricing_status_code not in
7177 (QP_PREQ_GRP.G_STATUS_UNCHANGED,
7178 QP_PREQ_GRP.G_STATUS_UPDATED,
7179 QP_PREQ_GRP.G_STATUS_GSA_VIOLATION,
7180 'NOT_VALID')
7181 OR (l_allow_negative_price = 'N' AND (unit_price<0 OR adjusted_unit_price<0)));
7182 cursor wrong_book_lines is
7183 select lines.line_id
7184 , lines.unit_price
7185 , lines.adjusted_unit_price
7186 , lines.price_list_header_id
7187 , lines.priced_quantity
7188 , lines.line_quantity
7189 , l.shipped_quantity
7190 , l.header_id
7191 , lines.line_index
7192 from oe_order_lines l
7193 , qp_preq_lines_tmp lines
7194 where lines.line_id = l.line_id
7195 and lines.line_type_code='LINE'
7196 and l.booked_flag = 'Y'
7197 and l.item_type_code NOT IN ('INCLUDED','CONFIG')
7198 and l.header_id = oe_order_pub.g_hdr.header_id --bug#12384028
7199 and (lines.unit_price is NULL
7200 or lines.adjusted_unit_price is NULL
7201 or lines.price_list_header_id is NULL)
7202 and lines.process_status <> 'NOT_VALID'
7203 --bug 3968023
7204 and lines.pricing_status_code <> QP_PREQ_PUB.G_STATUS_UNCHANGED
7205 ;
7206 -- Bug 2079138: booked lines should always have price
7207 --and lines.pricing_status_code in (QP_PREQ_GRP.G_STATUS_UPDATED
7208 -- , QP_PREQ_GRP.G_STATUS_GSA_VIOLATION
7209 -- );
7210 --
7211 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
7212 --
7213
7214 l_booking_error varchar2(1) := 'N'; -- Bug 8236945
7215 begin
7216 -- Update Order Lines
7217 IF l_debug_level > 0 THEN
7218 oe_debug_pub.add( 'ENTERING OE_ORDER_PRICE_PVT.REPORT_ENGINE_ERROR' , 1 ) ;
7219 END IF;
7220 --bug 3696768
7221 IF G_IPL_ERRORS_TBL.count <> 0 THEN
7222 FOR I in reset_ipl_tbl LOOP
7223 IF (G_IPL_ERRORS_TBL.exists(MOD(I.line_id,G_BINARY_LIMIT))) THEN
7224 G_IPL_ERRORS_TBL.delete(MOD(I.line_id,G_BINARY_LIMIT));
7225 END IF;
7226 END LOOP;
7227 END IF;
7228 --bug 3696768
7229 G_STMT_NO := 'Report_Engine_Error#10';
7230
7231 For wrong_line in wrong_lines loop --i:= p_req_line_tbl.first;
7232
7233 If px_Line_Tbl.count = 0 Then
7234 Begin
7235
7236 Query_line
7237 ( p_Line_id => wrong_line.line_id
7238 , x_line_rec => l_line_rec);
7239 Exception when no_data_found then
7240 null;
7241 IF l_debug_level > 0 THEN
7242 oe_debug_pub.add( 'REPORT_ENGINE_ERROR QUERY_LINE , NO DATA FOUND' ) ;
7243 END IF;
7244 End;
7245 Else
7246 J:= px_Line_Tbl.First;
7247 While J is not null loop
7248 IF l_debug_level > 0 THEN
7249 oe_debug_pub.add( 'ERROR '||J||' LINE'||PX_LINE_TBL ( J ) .LINE_ID||' '||WRONG_LINE.LINE_ID ) ;
7250 END IF;
7251 If px_Line_Tbl(j).line_id = wrong_line.line_id
7252 --or
7253 -- J = wrong_line.line_index
7254 then
7255 l_line_rec := px_Line_Tbl(J);
7256 IF l_debug_level > 0 THEN
7257 oe_debug_pub.add( 'PRICE'||L_LINE_REC.UNIT_LIST_PRICE||'+'||L_LINE_REC.UNIT_LIST_PRICE_PER_PQTY ) ;
7258 END IF;
7259 exit;
7260 End if;
7261 J:= px_Line_Tbl.next(j);
7262 end loop;
7263 End If;
7264
7265 OE_MSG_PUB.set_msg_context
7266 ( p_entity_code => 'LINE'
7267 ,p_entity_id => l_line_rec.line_id
7268 ,p_header_id => l_line_rec.header_id
7269 ,p_line_id => l_line_rec.line_id
7270 ,p_order_source_id => l_line_rec.order_source_id
7271 ,p_orig_sys_document_ref => l_line_rec.orig_sys_document_ref
7272 ,p_orig_sys_document_line_ref => l_line_rec.orig_sys_line_ref
7273 ,p_orig_sys_shipment_ref => l_line_rec.orig_sys_shipment_ref
7274 ,p_change_sequence => l_line_rec.change_sequence
7275 ,p_source_document_type_id => l_line_rec.source_document_type_id
7276 ,p_source_document_id => l_line_rec.source_document_id
7277 ,p_source_document_line_id => l_line_rec.source_document_line_id
7278 );
7279
7280 IF l_debug_level > 0 THEN
7281 oe_debug_pub.add( 'THE STATUS'||WRONG_LINE.PRICING_STATUS_CODE||':'||WRONG_LINE.PROCESSED_CODE||':'||WRONG_LINE.STATUS_TEXT ) ;
7282 END IF;
7283 l_invalid_line := 'N';
7284 -- add message when the price list is found to be inactive
7285 /*IF wrong_line.line_Type_code ='LINE' and
7286 wrong_line.processed_code = QP_PREQ_GRP.G_STS_LHS_NOT_FOUND Then
7287 IF not G_IPL_ERRORS_TBL.exists(MOD(l_line_rec.line_id,G_BINARY_LIMIT))
7288 or (G_IPL_ERRORS_TBL.exists(MOD(l_line_rec.line_id,G_BINARY_LIMIT))
7289 and
7290 G_IPL_ERRORS_TBL(MOD(l_line_rec.line_id,G_BINARY_LIMIT))<>l_line_rec.price_list_id)
7291 Then
7292 IF l_debug_level > 0 THEN
7293 oe_debug_pub.add( 'PRICE LIST NOT FOUND' ) ;
7294 END IF;
7295 IF l_debug_level > 0 THEN
7296 oe_debug_pub.add( 'INVALID PRICE LIST ' , 1 ) ;
7297 END IF;
7298 FND_MESSAGE.SET_NAME('ONT','ONT_NO_PRICE_LIST_FOUND');
7299 FND_MESSAGE.SET_TOKEN('ITEM',nvl(l_line_rec.Ordered_Item,l_line_rec.inventory_item_id));
7300 FND_MESSAGE.SET_TOKEN('UOM',l_line_rec.Order_Quantity_uom);
7301 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
7302 if l_line_rec.shipped_quantity is not null and l_line_rec.shipped_quantity <> FND_API.G_MISS_NUM then
7303 vmsg := FND_MESSAGE.GET;
7304 else
7305 OE_MSG_PUB.Add;
7306 end if;
7307 ELSE
7308 OE_MSG_PUB.Add;
7309 END IF;
7310 END IF;
7311 l_invalid_line := 'Y';
7312 END IF; */
7313
7314 if wrong_line.line_Type_code ='LINE' and
7315 wrong_line.pricing_status_code in ( QP_PREQ_GRP.G_STATUS_INVALID_PRICE_LIST,
7316 QP_PREQ_GRP.G_STS_LHS_NOT_FOUND,
7317 QP_PREQ_GRP.G_STATUS_FORMULA_ERROR,
7318 QP_PREQ_GRP.G_STATUS_OTHER_ERRORS,
7319 FND_API.G_RET_STS_UNEXP_ERROR,
7320 FND_API.G_RET_STS_ERROR,
7321 QP_PREQ_GRP.G_STATUS_CALC_ERROR,
7322 QP_PREQ_GRP.G_STATUS_UOM_FAILURE,
7323 QP_PREQ_GRP.G_STATUS_INVALID_UOM,
7324 QP_PREQ_GRP.G_STATUS_DUP_PRICE_LIST,
7325 QP_PREQ_GRP.G_STATUS_INVALID_UOM_CONV,
7326 QP_PREQ_GRP.G_STATUS_INVALID_INCOMP,
7327 QP_PREQ_GRP.G_STATUS_BEST_PRICE_EVAL_ERROR)
7328 then
7329
7330 l_invalid_line := 'Y';
7331 Begin
7332 Select name into l_price_list
7333 from qp_list_headers_vl where
7334 list_header_id = l_line_rec.price_list_id;
7335 Exception When No_data_found then
7336 l_price_list := l_line_rec.price_list_id;
7337 End;
7338
7339 If wrong_line.pricing_status_code = QP_PREQ_GRP.G_STATUS_INVALID_PRICE_LIST then
7340 IF l_debug_level > 0 THEN
7341 oe_debug_pub.add( 'INVALID ITEM/PRICE LIST COMBINATION'||L_LINE_REC.ORDERED_ITEM||L_LINE_REC.ORDER_QUANTITY_UOM||L_PRICE_LIST ) ;
7342 END IF;
7343
7344
7345 IF not G_IPL_ERRORS_TBL.exists(MOD(l_line_rec.line_id,G_BINARY_LIMIT))
7346 or (G_IPL_ERRORS_TBL.exists(MOD(l_line_rec.line_id,G_BINARY_LIMIT))
7347 and
7348 G_IPL_ERRORS_TBL(MOD(l_line_rec.line_id,G_BINARY_LIMIT))<>l_line_rec.price_list_id)
7349 Then
7350
7351 FND_MESSAGE.SET_NAME('ONT','OE_PRC_NO_LIST_PRICE');
7352 FND_MESSAGE.SET_TOKEN('ITEM',nvl(l_line_rec.Ordered_Item,l_line_rec.inventory_item_id));
7353 FND_MESSAGE.SET_TOKEN('UNIT',l_line_rec.Order_Quantity_uom);
7354 FND_MESSAGE.SET_TOKEN('PRICE_LIST',l_Price_List);
7355 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
7356 IF l_line_rec.shipped_quantity is not null and l_line_rec.shipped_quantity <> FND_API.G_MISS_NUM then
7357 vmsg := FND_MESSAGE.GET;
7358 ELSE
7359 OE_MSG_PUB.Add;
7360 END IF;
7361 ELSE
7362 OE_MSG_PUB.Add;
7363 END IF;
7364 ELSE
7365 l_invalid_line := 'N';
7366 End IF;
7367
7368 IF l_line_rec.price_list_id IS NOT NULL THEN
7369 G_IPL_ERRORS_TBL(MOD(l_line_rec.line_id,G_BINARY_LIMIT)):=l_line_rec.price_list_id;
7370 END IF;
7371
7372 IF l_debug_level > 0 THEN
7373 oe_debug_pub.add( 'BEFORE CHECKING BOOK FLAG' ) ;
7374 END IF;
7375
7376 If nvl(l_line_rec.booked_flag,'X') = 'Y' Then
7377 IF l_debug_level > 0 THEN
7378 oe_debug_pub.add( ' EXCEPTION: PRICE LIST MISSING FOR BOOKED ORDER' ) ;
7379 END IF;
7380 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
7381 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_ORDER_UTIL.GET_ATTRIBUTE_NAME('UNIT_LIST_PRICE'));
7382 OE_MSG_PUB.ADD;
7383 -- Bug 8236945
7384 IF OE_GLOBALS.G_UI_FLAG THEN
7385 RAISE FND_API.G_EXC_ERROR;
7386 ELSE
7387 l_booking_error := 'Y';
7388 END IF;
7389 End If;
7390 IF l_debug_level > 0 THEN
7391 oe_debug_pub.add( 'PRICE'||L_LINE_REC.UNIT_SELLING_PRICE||':'||L_LINE_REC.UNIT_LIST_PRICE ) ;
7392 END IF;
7393
7394 --Fix bug 1650637
7395 If (l_line_rec.unit_selling_price Is Not Null or
7396 l_line_rec.unit_list_price Is Not Null
7397 ) AND NOT (p_control_rec.p_write_to_db)
7398 THEN
7399 l_line_rec.unit_selling_price := NULL;
7400 l_line_rec.unit_selling_price_per_pqty := NULL;
7401 l_line_rec.unit_list_price := NULL;
7402 l_line_rec.unit_list_price_per_pqty := NULL;
7403 END IF;
7404
7405 IF l_debug_level > 0 THEN
7406 oe_debug_pub.add('invalid price done');
7407 END IF;
7408 Elsif wrong_line.pricing_status_code = QP_PREQ_GRP.G_STS_LHS_NOT_FOUND Then
7409 IF l_debug_level > 0 THEN
7410 oe_debug_pub.add( 'PRICE LIST NOT FOUND' ) ;
7411 END IF;
7412 FND_MESSAGE.SET_NAME('ONT','ONT_NO_PRICE_LIST_FOUND');
7413 FND_MESSAGE.SET_TOKEN('ITEM',nvl(l_line_rec.Ordered_Item,l_line_rec.inventory_item_id));
7414 FND_MESSAGE.SET_TOKEN('UOM',l_line_rec.Order_Quantity_uom);
7415 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
7416 if l_line_rec.shipped_quantity is not null and l_line_rec.shipped_quantity <> FND_API.G_MISS_NUM then
7417 vmsg := FND_MESSAGE.GET;
7418 else
7419 OE_MSG_PUB.Add;
7420 end if;
7421 else
7422 OE_MSG_PUB.Add;
7423 end if;
7424 Elsif wrong_line.pricing_status_code = QP_PREQ_GRP.G_STATUS_FORMULA_ERROR then
7425 IF l_debug_level > 0 THEN
7426 oe_debug_pub.add( 'ERROR IN FORMULA PROCESSING' ) ;
7427 END IF;
7428 FND_MESSAGE.SET_NAME('ONT','ONT_PRC_ERROR_IN_FORMULA');
7429 FND_MESSAGE.SET_TOKEN('ERR_TEXT',wrong_line.status_text||','||get_formula(wrong_line.line_index));
7430 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
7431 if l_line_rec.shipped_quantity is not null and l_line_rec.shipped_quantity <> FND_API.G_MISS_NUM then
7432 vmsg := FND_MESSAGE.GET;
7433 else
7434 OE_MSG_PUB.Add;
7435 end if;
7436 else
7437 OE_MSG_PUB.Add;
7438 end if;
7439 Elsif wrong_line.pricing_status_code in
7440 ( QP_PREQ_GRP.G_STATUS_OTHER_ERRORS , FND_API.G_RET_STS_UNEXP_ERROR,
7441 FND_API.G_RET_STS_ERROR)
7442 then
7443 IF l_debug_level > 0 THEN
7444 oe_debug_pub.add( 'OTHER ERRORS PROCESSING' ) ;
7445 END IF;
7446 FND_MESSAGE.SET_NAME('ONT','ONT_PRICING_ERRORS'); --bug#7149497
7447 FND_MESSAGE.SET_TOKEN('ERR_TEXT',wrong_line.status_text);
7448 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
7449 if l_line_rec.shipped_quantity is not null and l_line_rec.shipped_quantity <> FND_API.G_MISS_NUM then
7450 vmsg := FND_MESSAGE.GET;
7451 else
7452 OE_MSG_PUB.Add;
7453 end if;
7454 else
7455 OE_MSG_PUB.Add;
7456 end if;
7457 Elsif wrong_line.pricing_status_code = QP_PREQ_GRP.G_STATUS_INVALID_UOM then
7458 IF l_debug_level > 0 THEN
7459 oe_debug_pub.add( 'INVALID UOM' ) ;
7460 END IF;
7461 FND_MESSAGE.SET_NAME('ONT','ONT_PRC_INVALID_UOM');
7462 FND_MESSAGE.SET_TOKEN('ITEM',nvl(l_line_rec.Ordered_Item,l_line_rec.inventory_item_id));
7463 FND_MESSAGE.SET_TOKEN('UOM',l_line_rec.Order_Quantity_uom);
7464 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
7465 if l_line_rec.shipped_quantity is not null and l_line_rec.shipped_quantity <> FND_API.G_MISS_NUM then
7466 vmsg := FND_MESSAGE.GET;
7467 else
7468 OE_MSG_PUB.Add;
7469 end if;
7470 else
7471 OE_MSG_PUB.Add;
7472 end if;
7473 Elsif wrong_line.pricing_status_code = QP_PREQ_GRP.G_STATUS_DUP_PRICE_LIST then
7474 IF l_debug_level > 0 THEN
7475 oe_debug_pub.add( 'DUPLICATE PRICE LIST' ) ;
7476 END IF;
7477 FND_MESSAGE.SET_NAME('ONT','ONT_PRC_DUPLICATE_PRICE_LIST');
7478
7479 Begin
7480 Select name into l_price_list
7481 from qp_list_headers_vl a,qp_list_lines b where
7482 b.list_line_id = to_number(substr(wrong_line.status_text,1,
7483 instr(wrong_line.status_text,',')-1))
7484 and a.list_header_id=b.list_header_id
7485 ;
7486 Exception When No_data_found then
7487 l_price_list := to_number(substr(wrong_line.status_text,1,
7488 instr(wrong_line.status_text,',')-1));
7489 When invalid_number then
7490 l_price_list := substr(wrong_line.status_text,1,
7491 instr(wrong_line.status_text,',')-1);
7492
7493 End;
7494
7495 FND_MESSAGE.SET_TOKEN('PRICE_LIST1',
7496 '( '||l_line_rec.Ordered_Item||' ) '||l_price_list);
7497 Begin
7498 Select name into l_price_list
7499 from qp_list_headers_vl a,qp_list_lines b where
7500 b.list_line_id =
7501 to_number(substr(wrong_line.status_text,
7502 instr(wrong_line.status_text,',')+1))
7503 and a.list_header_id=b.list_header_id ;
7504 Exception When No_data_found then
7505 l_price_list := to_number(substr(wrong_line.status_text,
7506 instr(wrong_line.status_text,',')+1));
7507 When invalid_number then
7508 l_price_list := substr(wrong_line.status_text,
7509 instr(wrong_line.status_text,',')+1);
7510 End;
7511 FND_MESSAGE.SET_TOKEN('PRICE_LIST2',l_price_list);
7512 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
7513 if l_line_rec.shipped_quantity is not null and l_line_rec.shipped_quantity <> FND_API.G_MISS_NUM then
7514 vmsg := FND_MESSAGE.GET;
7515 else
7516 OE_MSG_PUB.Add;
7517 end if;
7518 else
7519 OE_MSG_PUB.Add;
7520 end if;
7521 Elsif wrong_line.pricing_status_code = QP_PREQ_GRP.G_STATUS_INVALID_UOM_CONV then
7522 IF l_debug_level > 0 THEN
7523 oe_debug_pub.add( 'INVALID UOM CONVERSION' ) ;
7524 END IF;
7525 FND_MESSAGE.SET_NAME('ONT','ONT_PRC_INVALID_UOM_CONVERSION');
7526 FND_MESSAGE.SET_TOKEN('UOM_TEXT','( '||l_line_rec.Ordered_Item||' ) '||
7527 wrong_line.status_text);
7528 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
7529 if l_line_rec.shipped_quantity is not null and l_line_rec.shipped_quantity <> FND_API.G_MISS_NUM then
7530 vmsg := FND_MESSAGE.GET;
7531 else
7532 OE_MSG_PUB.Add;
7533 end if;
7534 else
7535 OE_MSG_PUB.Add;
7536 end if;
7537 Elsif wrong_line.pricing_status_code = QP_PREQ_GRP.G_STATUS_INVALID_INCOMP then
7538 IF l_debug_level > 0 THEN
7539 oe_debug_pub.add( 'UNABLE TO RESOLVE INCOMPATIBILITY' ) ;
7540 END IF;
7541 FND_MESSAGE.SET_NAME('ONT','ONT_PRC_INVALID_INCOMP');
7542 FND_MESSAGE.SET_TOKEN('ERR_TEXT','( '||
7543 l_line_rec.Ordered_Item||' ) '||wrong_line.status_text);
7544 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
7545 if l_line_rec.shipped_quantity is not null and l_line_rec.shipped_quantity <> FND_API.G_MISS_NUM then
7546 vmsg := FND_MESSAGE.GET;
7547 else
7548 OE_MSG_PUB.Add;
7549 end if;
7550 else
7551 OE_MSG_PUB.Add;
7552 end if;
7553 Elsif wrong_line.pricing_status_code = QP_PREQ_GRP.G_STATUS_BEST_PRICE_EVAL_ERROR then
7554 IF l_debug_level > 0 THEN
7555 oe_debug_pub.add( 'ERROR WHILE EVALUATING THE BEST PRICE' ) ;
7556 END IF;
7557 FND_MESSAGE.SET_NAME('ONT','ONT_PRC_BEST_PRICE_ERROR');
7558 FND_MESSAGE.SET_TOKEN('ITEM',nvl(l_line_rec.Ordered_Item,l_line_rec.inventory_item_id));
7559 FND_MESSAGE.SET_TOKEN('ERR_TEXT',wrong_line.status_text);
7560 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
7561 if l_line_rec.shipped_quantity is not null and l_line_rec.shipped_quantity <> FND_API.G_MISS_NUM then
7562 vmsg := FND_MESSAGE.GET;
7563 else
7564 OE_MSG_PUB.Add;
7565 end if;
7566 else
7567 OE_MSG_PUB.Add;
7568 end if;
7569 End if; /* wrong pricing status code */
7570
7571 --RAISE FND_API.G_EXC_ERROR;
7572 --btea begin if do not write to db, we still need to
7573 --return line and status code to the caller
7574 If Not p_control_rec.p_write_to_db Then
7575 l_line_rec.Header_id := p_header_rec.Header_id;
7576 l_line_rec.line_id := wrong_line.line_id;
7577 l_line_rec.unit_selling_price_per_pqty
7578 := wrong_line.adjusted_unit_price ;
7579 l_line_rec.unit_list_price_per_pqty
7580 := wrong_line.unit_price ;
7581 l_line_rec.pricing_quantity
7582 := wrong_line.priced_quantity ;
7583 l_line_rec.pricing_quantity_uom
7584 := wrong_line.priced_uom_code ;
7585 --use industry_attribute30 as the place holder to hold error status
7586 --since the line_rec doesn't have the place holder to hold error status
7587 l_line_rec.industry_attribute30
7588 := wrong_line.pricing_status_code;
7589 IF l_debug_level > 0 THEN
7590 oe_debug_pub.add( 'J IS '||J ) ;
7591 END IF;
7592 if (j<>0) THEN
7593 px_line_tbl(j) := l_line_rec;
7594 END IF;
7595
7596 IF l_debug_level > 0 THEN
7597 oe_debug_pub.add( 'PASSING BACK PRICE'||L_LINE_REC.UNIT_LIST_PRICE||' '||L_LINE_REC.UNIT_SELLING_PRICE ) ;
7598 END IF;
7599 IF l_debug_level > 0 THEN
7600 oe_debug_pub.add( 'LINE'||L_LINE_REC.HEADER_ID||'+'||L_LINE_REC.LINE_ID ) ;
7601 END IF;
7602 End If;
7603 --btea end
7604
7605 elsif
7606 wrong_line.line_Type_code ='LINE' and
7607 wrong_line.pricing_status_code = QP_PREQ_GRP.G_STATUS_OTHER_ERRORS
7608 Then
7609
7610 FND_MESSAGE.SET_NAME('ONT','OE_PRICING_ERROR');
7611 FND_MESSAGE.SET_TOKEN('ERR_TEXT','( '
7612 ||l_line_rec.Ordered_Item||' ) '||wrong_line.status_text);
7613 OE_MSG_PUB.Add;
7614 elsif wrong_line.line_type_code='LINE' and
7615 (wrong_line.unit_price <0 or wrong_line.adjusted_unit_price<0)
7616 Then
7617
7618 IF l_debug_level > 0 THEN
7619 oe_debug_pub.add( 'NEGATIVE LIST PRICE '||WRONG_LINE.UNIT_PRICE ||'OR SELLING PRICE '||WRONG_LINE.ADJUSTED_UNIT_PRICE ) ;
7620 END IF;
7621 FND_MESSAGE.SET_NAME('ONT','ONT_NEGATIVE_PRICE');
7622 FND_MESSAGE.SET_TOKEN('ITEM',nvl(l_line_rec.Ordered_Item,l_line_rec.inventory_item_id));
7623 FND_MESSAGE.SET_TOKEN('LIST_PRICE',wrong_line.unit_price);
7624 FND_MESSAGE.SET_TOKEN('SELLING_PRICE',wrong_line.Adjusted_unit_price);
7625 OE_MSG_PUB.Add;
7626 IF l_debug_level > 0 THEN
7627 oe_debug_pub.add( 'BEFORE SHOWING NEGATIVE MODIFIERS MESSAGE' ) ;
7628 END IF;
7629 l_list_line_no:=get_list_lines(wrong_line.line_id);
7630
7631 IF l_list_line_no IS NOT NULL THEN
7632 FND_MESSAGE.SET_NAME('ONT','ONT_NEGATIVE_MODIFIERS');
7633 FND_MESSAGE.SET_TOKEN('LIST_LINE_NO',get_list_lines(wrong_line.line_id));
7634 OE_MSG_PUB.Add;
7635 END IF;
7636
7637 IF l_debug_level > 0 THEN
7638 oe_debug_pub.add( 'MODIFIERS:'||GET_LIST_LINES ( WRONG_LINE.LINE_ID ) ) ;
7639 END IF;
7640
7641 --place the line on invoicing hold to avoid stuck order it the ship quatity is there.
7642 IF l_line_rec.shipped_quantity is not null and l_line_rec.shipped_quantity <> FND_API.G_MISS_NUM THEN
7643 vmsg := FND_MESSAGE.GET;
7644 oe_debug_pub.add('vmsg = '||vmsg,1);
7645 pricing_errors_hold(l_line_rec.header_id,l_line_rec.line_id,vmsg);
7646 -- select oe_msg_request_id_s.nextval into l_request_id from dual;
7647 -- OE_MSG_PUB.INSERT_MESSAGE(OE_MSG_PUB.COUNT_MSG, l_request_id,'U');
7648 -- 4919922
7649 IF (OE_GLOBALS.G_UI_FLAG ) THEN
7650 IF (G_REQUEST_ID IS NULL) THEN
7651 select oe_msg_request_id_s.nextval into g_request_id from dual;
7652 END IF;
7653 OE_MSG_PUB.INSERT_MESSAGE(OE_MSG_PUB.COUNT_MSG, G_REQUEST_ID,'U');
7654 END IF;
7655
7656 ELSE
7657 RAISE FND_API.G_EXC_ERROR;
7658 END IF;
7659
7660 end if;
7661
7662 IF wrong_line.line_type_code='ORDER' THEN
7663 if wrong_line.pricing_status_code = QP_PREQ_GRP.G_STATUS_FORMULA_ERROR then
7664 oe_debug_pub.add( 'ERROR IN ORDER LEVEL FORMULA PROCESSING' ) ;
7665 FND_MESSAGE.SET_NAME('ONT','ONT_PRC_ERROR_IN_FORMULA');
7666 FND_MESSAGE.SET_TOKEN('ERR_TEXT',wrong_line.status_text||','||get_formula(wrong_line.line_index));
7667 OE_MSG_PUB.Add;
7668 vmsg := FND_MESSAGE.GET;
7669 else
7670 oe_debug_pub.add( 'OTHER ERRORS PROCESSING' ) ;
7671 FND_MESSAGE.SET_NAME('ONT','ONT_PRICING_ERRORS'); --bug#7149497
7672 FND_MESSAGE.SET_TOKEN('ERR_TEXT',wrong_line.status_text);
7673 OE_MSG_PUB.Add;
7674 vmsg := FND_MESSAGE.GET;
7675 end if;
7676 END IF; --end if for 'ORDER' line_type_code
7677
7678 If l_invalid_line = 'Y' Then
7679 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
7680 if l_line_rec.shipped_quantity is not null and l_line_rec.shipped_quantity <> FND_API.G_MISS_NUM then
7681 IF l_debug_level > 0 THEN
7682 oe_debug_pub.add('vmsg = '||vmsg,1);
7683 END IF;
7684 pricing_errors_hold(l_line_rec.header_id,l_line_rec.line_id,vmsg);
7685 -- select oe_msg_request_id_s.nextval into l_request_id from dual;
7686
7687 -- OE_MSG_PUB.INSERT_MESSAGE(OE_MSG_PUB.COUNT_MSG, l_request_id,'U');
7688 -- 4919922
7689 IF (OE_GLOBALS.G_UI_FLAG ) THEN
7690 IF (G_REQUEST_ID IS NULL) THEN
7691 select oe_msg_request_id_s.nextval into g_request_id from dual;
7692 END IF;
7693 OE_MSG_PUB.INSERT_MESSAGE(OE_MSG_PUB.COUNT_MSG, G_REQUEST_ID,'U');
7694 END IF;
7695
7696 else
7697 oe_debug_pub.add('has invalid line');
7698 l_temp_line_rec.line_id := Wrong_line.line_id;
7699 oe_debug_pub.add('has invalid line2');
7700 l_temp_line_rec.ordered_quantity := Wrong_line.line_quantity;
7701 oe_debug_pub.add('has invalid line3');
7702 l_temp_line_rec.pricing_quantity := Wrong_line.priced_quantity;
7703 oe_debug_pub.add('has invalid line4');
7704 -- select oe_msg_request_id_s.nextval into l_request_id from dual;
7705
7706 -- OE_MSG_PUB.INSERT_MESSAGE(OE_MSG_PUB.COUNT_MSG, l_request_id,'U');
7707 -- 4919922
7708 IF (OE_GLOBALS.G_UI_FLAG ) THEN
7709 IF (G_REQUEST_ID IS NULL) THEN
7710 select oe_msg_request_id_s.nextval into g_request_id from dual;
7711 END IF;
7712 OE_MSG_PUB.INSERT_MESSAGE(OE_MSG_PUB.COUNT_MSG, G_REQUEST_ID,'U');
7713 END IF;
7714
7715 oe_debug_pub.add('has invalid line 5');
7716 Oe_Order_Adj_Pvt.Reset_Fields(l_temp_line_rec);
7717 end if;
7718 else
7719 l_temp_line_rec.line_id := Wrong_line.line_id;
7720 l_temp_line_rec.ordered_quantity := Wrong_line.line_quantity;
7721 l_temp_line_rec.pricing_quantity := Wrong_line.priced_quantity;
7722 -- select oe_msg_request_id_s.nextval into l_request_id from dual;
7723
7724 -- OE_MSG_PUB.INSERT_MESSAGE(OE_MSG_PUB.COUNT_MSG, l_request_id,'U');
7725 -- 4919922
7726 IF (OE_GLOBALS.G_UI_FLAG ) THEN
7727 IF (G_REQUEST_ID IS NULL) THEN
7728 select oe_msg_request_id_s.nextval into g_request_id from dual;
7729 END IF;
7730 OE_MSG_PUB.INSERT_MESSAGE(OE_MSG_PUB.COUNT_MSG, G_REQUEST_ID,'U');
7731 END IF;
7732
7733 Oe_Order_Adj_Pvt.Reset_Fields(l_temp_line_rec);
7734 end if;
7735 Else
7736 oe_debug_pub.add('No invalid line');
7737 l_invalid_line:='N';
7738 End If;
7739
7740 end loop; /* wrong_lines cursor */
7741
7742 For book_line in wrong_book_lines loop
7743
7744 If book_line.adjusted_unit_price IS NULL Then
7745 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
7746 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
7747 OE_Order_UTIL.Get_Attribute_Name('UNIT_SELLING_PRICE'));
7748 OE_MSG_PUB.ADD;
7749 End If;
7750
7751 If book_line.unit_price IS NULL
7752 Then
7753 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
7754 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
7755 OE_Order_UTIL.Get_Attribute_Name('UNIT_LIST_PRICE'));
7756 IF l_debug_level > 0 THEN
7757 oe_debug_pub.add( ' ERROR: UNIT LIST PRICE CAN NOT BE NULL' ) ;
7758 END IF;
7759 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
7760 if book_line.shipped_quantity is not null or book_line.shipped_quantity <> FND_API.G_MISS_NUM then
7761 vmsg := FND_MESSAGE.GET;
7762 pricing_errors_hold(book_line.header_id,book_line.line_id,vmsg);
7763 else
7764 OE_MSG_PUB.ADD;
7765 l_temp_line_rec.line_id := book_line.line_id;
7766 l_temp_line_rec.ordered_quantity := book_line.line_quantity;
7767 l_temp_line_rec.pricing_quantity := book_line.priced_quantity;
7768 Oe_Order_Adj_Pvt.Reset_Fields(l_temp_line_rec);
7769 -- Bug 8236945
7770 IF OE_GLOBALS.G_UI_FLAG THEN
7771 RAISE FND_API.G_EXC_ERROR;
7772 ELSE
7773 l_booking_error := 'Y';
7774 END IF;
7775 end if;
7776 else
7777 OE_MSG_PUB.ADD;
7778 end if;
7779 End If;
7780
7781 If book_line.price_list_header_id IS NULL Then
7782 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRUIBUTE');
7783 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_ORDER_UTIL.Get_Attribute_Name('PRICE_LIST_ID'));
7784 OE_MSG_PUB.ADD;
7785 IF l_debug_level > 0 THEN
7786 oe_debug_pub.add( ' ERROR: PRICE LIST ID CAN NOT BE NULL' ) ;
7787 END IF;
7788 -- Bug 8236945
7789 IF OE_GLOBALS.G_UI_FLAG THEN
7790 RAISE FND_API.G_EXC_ERROR;
7791 ELSE
7792 l_booking_error := 'Y';
7793 END IF;
7794 END IF;
7795
7796 End loop; /* wrong booked lines */
7797 IF l_debug_level > 0 THEN
7798 oe_debug_pub.add( 'EXITING REPORT_ENGINE_ERRORS' ) ;
7799 END IF;
7800
7801 -- Added for bug 8236945
7802 IF l_booking_error = 'Y' THEN
7803 RAISE FND_API.G_EXC_ERROR;
7804 END IF;
7805 -- End of bug 8236945
7806 End Report_Engine_Errors;
7807
7808 procedure process_adjustments
7809 (
7810 x_return_status out nocopy Varchar2,
7811
7812 p_Control_Rec OE_ORDER_PRICE_PVT.Control_rec_type,
7813 p_any_frozen_line in Boolean,
7814 px_line_Tbl in out NOCOPY oe_Order_Pub.Line_Tbl_Type,
7815 p_header_id in number,
7816 p_line_id in number,
7817 p_header_rec oe_Order_Pub.header_rec_type,
7818 p_pricing_events in varchar2
7819 )
7820 is
7821 l_line_rec oe_order_pub.line_rec_type;
7822 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
7823 i pls_Integer;
7824 j pls_Integer;
7825 l_price_list Varchar2(240);
7826 l_allow_negative_price Varchar2(30) := nvl(fnd_profile.value('ONT_NEGAT
7827 IVE_PRICING'),'N');
7828 l_sec_result NUMBER;
7829 l_adjustment_count NUMBER:=0;
7830 l_old_line_tbl OE_ORDER_PUB.Line_Tbl_Type;
7831 l_num_changed_lines NUMBER := 0;
7832 l_process_requests BOOLEAN := FALSE;
7833 l_process_ack BOOLEAN := FALSE;
7834 l_notify_flag BOOLEAN;
7835 l_booked_flag varchar2(1) := oe_order_cache.g_header_rec.booked_flag;
7836 l_return_status VARCHAR2(30);
7837 l_msg_count NUMBER;
7838 l_msg_data VARCHAR2(2000);
7839
7840
7841 --
7842 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
7843 --
7844 BEGIN
7845
7846 SAVEPOINT PROCESS_ADJUSTMENTS;
7847 l_old_line_tbl := px_line_Tbl;
7848 x_return_status := FND_API.G_RET_STS_SUCCESS;
7849 Report_Engine_Errors(x_return_status
7850 , p_control_rec
7851 , px_line_tbl
7852 , p_header_rec);
7853 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7854 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7855 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
7856 RAISE FND_API.G_EXC_ERROR;
7857 END IF;
7858
7859 IF p_control_rec.p_write_to_db THEN
7860 IF l_debug_level > 0 THEN
7861 oe_debug_pub.add( 'WRITING TO DATABASE' , 3 ) ;
7862 END IF;
7863
7864 CHECK_GSA;
7865
7866 UPDATE_ORDER_HEADER(p_header_rec);
7867
7868 /* UPDATE_ORDER_LINES(px_line_tbl
7869 , l_num_changed_lines); moved after oe_adv_price_pvt.process_adv_modifiers */
7870
7871 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
7872 IF l_debug_level > 0 THEN
7873 oe_debug_pub.add( 'CALLING OE_ADV_PRICE_PVT.PROCESS_ADV_MODIFIERS:'||OE_CODE_CONTROL.GET_CODE_RELEASE_LEVEL ) ;
7874 END IF;
7875 oe_adv_price_pvt.process_adv_modifiers
7876 (x_return_status => x_return_status,
7877 p_Control_Rec => p_Control_Rec,
7878 p_any_frozen_line => p_any_frozen_line,
7879 px_line_Tbl => px_line_Tbl,
7880 px_old_line_Tbl => l_old_line_Tbl,
7881 p_header_id => p_header_id,
7882 p_line_id => p_line_id,
7883 p_header_rec => p_header_rec,
7884 p_pricing_events => p_pricing_events);
7885 END IF;
7886
7887 UPDATE_ORDER_LINES(px_line_tbl
7888 ,l_num_changed_lines
7889 ,p_control_rec.p_write_to_db);
7890
7891 -- Performance change for Legato
7892 -- Not refresh order when no attributes changed
7893 -- Freight charge change doesn't result in line change
7894
7895 -- If p_pricing_events in ('ORDER','SHIP','BOOK') then
7896 --changes to enable multiple events passed as a string
7897 IF instr(p_pricing_events||',', 'ORDER,') > 0
7898 OR instr(p_pricing_events||',', 'SHIP') > 0
7899 OR instr(p_pricing_events||',', 'BOOK') > 0
7900 OR instr(p_pricing_events||',', 'BATCH') > 0 then
7901 IF (l_num_changed_lines > 0) THEN
7902 IF l_debug_level > 0 THEN
7903 oe_debug_pub.add( 'SETTING CASCADING FLAG TO REFRESH ORDER' ) ;
7904 END IF;
7905 OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
7906 END IF;
7907 End if;
7908
7909 -- calculate may change adjustments: adjusted_amount
7910 --IF (p_control_rec.p_calculate_flag <> QP_PREQ_GRP.G_CALCULATE_ONLY) THEN
7911 IF (p_header_id IS NOT NULL) THEN
7912 REFRESH_ADJS(p_line_id=>NULL
7913 , p_pricing_events=>p_pricing_events
7914 , p_calculate_flag => p_control_rec.p_calculate_flag);
7915 ELSIF (p_line_id IS NOT NULL) THEN
7916 REFRESH_ADJS(p_line_id => p_line_id
7917 , p_pricing_events => p_pricing_events
7918 , p_calculate_flag => p_control_rec.p_calculate_flag);
7919 ELSE
7920 i := px_line_tbl.FIRST;
7921 WHILE i IS NOT NULL LOOP
7922 REFRESH_ADJS(p_line_id=>px_line_tbl(i).line_id
7923 , p_pricing_events=>p_pricing_events
7924 , p_calculate_flag => p_control_rec.p_calculate_flag
7925 , p_header_id => px_line_tbl(i).header_id);
7926 i := px_line_tbl.next(i);
7927 END LOOP;
7928 END IF;
7929 --END IF;
7930
7931 END IF;
7932
7933 IF l_debug_level > 0 THEN
7934 oe_debug_pub.add( 'VOPRB RECURSION MODE'||OE_GLOBALS.G_RECURSION_MODE ) ;
7935 END IF;
7936
7937 -- 2366123: execute delayed requests only when not called by UI
7938 -- IF (OE_GLOBALS.G_RECURSION_MODE <> FND_API.G_TRUE
7939 IF (NOT OE_GLOBALS.G_UI_FLAG AND p_control_rec.p_write_to_db = TRUE AND l_num_changed_lines > 0 ) THEN
7940 l_process_requests := TRUE;
7941 l_old_line_tbl := px_line_tbl;
7942 END IF;
7943
7944 IF (p_control_rec.p_write_to_db = FALSE)
7945 THEN
7946 POPULATE_LINE_TBL(px_line_tbl);
7947 END IF;
7948
7949 IF l_process_requests THEN
7950 IF l_debug_level > 0 THEN
7951 oe_debug_pub.add( 'VOPRB BEFORE CALLING PROCESS_REQUESTS_AND_NOTIFY' ) ;
7952 END IF;
7953
7954 IF (oe_order_cache.g_header_rec.booked_flag = 'Y') Then
7955 l_process_ack := TRUE;
7956 END IF;
7957
7958 OE_Order_PVT.Process_Requests_And_Notify
7959 ( p_process_requests => TRUE
7960 , p_notify => l_process_ack
7961 , p_process_ack => l_process_ack
7962 , x_return_status => x_return_status
7963 , p_line_tbl => px_line_tbl
7964 , p_old_line_tbl => l_old_line_tbl
7965 );
7966
7967 IF l_debug_level > 0 THEN
7968 oe_debug_pub.add( 'RETRURNED FROM PROCESS_REQUEST AND NOTIFY : '||X_RETURN_STATUS , 3 ) ;
7969 END IF;
7970
7971 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
7972 RAISE FND_API.G_EXC_ERROR;
7973 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7974 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7975 END IF;
7976 END IF;
7977
7978 /*AS per Jyothi Narayan, Process_Requests_And_Notify has notify call. No extra call is needed
7979 If l_debug_level > 0 THEN
7980 oe_debug_pub.add('l_booked_flag in process_adjustments = '||l_booked_flag); End If;
7981 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
7982 IF l_booked_flag = 'Y' AND p_control_rec.p_write_to_db = TRUE THEN
7983 IF NOT OE_GLOBALS.G_UI_FLAG AND OE_GLOBALS.G_RECURSION_MODE = 'N' THEN
7984 If l_debug_level > 0 THEN
7985 oe_debug_pub.add('Before calling OE_SERVICE_UTIL.Notify_OC in process adj');
7986
7987 End If;
7988 OE_SERVICE_UTIL.Notify_OC
7989 ( p_api_version_number => 1.0
7990 , p_init_msg_list => FND_API.G_FALSE
7991 , x_return_status => l_return_status
7992 , x_msg_count => l_msg_count
7993 , x_msg_data => l_msg_data
7994 , p_Line_Adj_tbl => OE_ORDER_UTIL.g_Line_Adj_tbl
7995 , p_old_Line_Adj_tbl => OE_ORDER_UTIL.g_old_Line_Adj_tbl);
7996
7997 IF l_debug_level > 0 THEN
7998 oe_debug_pub.add( 'AFTER NOTIFY_OC API' , 1 ) ;
7999 END IF;
8000 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
8001 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8002 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
8003 RAISE FND_API.G_EXC_ERROR;
8004 END IF;
8005 END IF;
8006
8007 END IF;
8008 END IF; */
8009
8010
8011 Exception
8012 WHEN FND_API.G_EXC_ERROR THEN
8013 x_return_status := FND_API.G_RET_STS_ERROR;
8014
8015 IF l_debug_level > 0 THEN
8016 oe_debug_pub.add( 'EXITING PROCESS_ADJUSTMENTS WITH EXC ERROR with rollback' , 1 ) ;
8017 END IF;
8018 ROLLBACK TO SAVEPOINT PROCESS_ADJUSTMENTS;
8019
8020 RAISE FND_API.G_EXC_ERROR;
8021 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
8022 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8023
8024 IF l_debug_level > 0 THEN
8025 oe_debug_pub.add( 'EXITING PROCESS_ADJUSTMENTS WITH UNEXPECTED ERROR with rollback' , 1 ) ;
8026 END IF;
8027 ROLLBACK TO SAVEPOINT PROCESS_ADJUSTMENTS;
8028 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8029 WHEN OTHERS THEN
8030 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8031 IF l_debug_level > 0 THEN
8032 oe_debug_pub.add( 'ERROR IN OE_ORDER_PRICE_PVT.PROCESS_ADJUSTMENTS with rollback' , 1 ) ;
8033 END IF;
8034 IF l_debug_level > 0 THEN
8035 oe_debug_pub.add( SQLERRM , 1 ) ;
8036 END IF;
8037
8038 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
8039 THEN
8040 OE_MSG_PUB.Add_Exc_Msg
8041 ( G_PKG_NAME
8042 , 'Process_Adjustments',
8043 sqlerrm
8044 );
8045 END IF;
8046
8047 IF l_debug_level > 0 THEN
8048 oe_debug_pub.add( 'EXITING OE_ORDER_PRICE_PVT.PROCESS_ADJUSTMENTS with rollback' , 1 ) ;
8049 END IF;
8050 ROLLBACK TO SAVEPOINT PROCESS_ADJUSTMENTS;
8051 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8052 IF l_debug_level > 0 THEN
8053 oe_debug_pub.add( 'EXITING OE_ORDER_PRICE_PVT.PROCESS_ADJUSTMENTS' , 1 ) ;
8054 END IF;
8055 END Process_Adjustments;
8056
8057 -- Price_Line is the main Pricing Integration API
8058 -- It can be used to Price an order, an order line, or multiple lines
8059 Procedure Price_line(
8060 p_Header_id IN NUMBER
8061 ,p_Line_id IN NUMBER
8062 ,px_line_Tbl IN OUT NOCOPY oe_Order_Pub.Line_Tbl_Type
8063 ,p_Control_Rec IN OE_ORDER_PRICE_PVT.control_rec_type
8064 ,p_action_code IN VARCHAR2
8065 ,p_Pricing_Events IN VARCHAR2
8066 --RT{
8067 ,p_request_rec OE_Order_PUB.request_rec_type default oe_order_pub.G_MISS_REQUEST_REC
8068 --RT}
8069 ,x_Return_Status OUT NOCOPY VARCHAR2
8070
8071 )
8072 is
8073 l_any_frozen_line BOOLEAN;
8074 lx_header_rec OE_ORDER_PUB.HEADER_REC_TYPE;
8075 --
8076 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
8077 --
8078 l_org_id NUMBER(15):=MO_GLOBAL.Get_Current_Org_Id; --TaxER
8079 l_hdr_chg_count NUMBER; --TaxER
8080 l_current_event number := 0; --TaxER
8081 l_tax_calculation_event_code number := 0; --TaxER
8082 l_header_rec OE_Order_PUB.Header_Rec_Type; --TaxER
8083 l_line_rec OE_Order_PUB.Line_Rec_Type; --TaxER
8084 Begin
8085
8086 IF l_debug_level > 0 THEN
8087 oe_debug_pub.add('ENTERING OE_ORDER_PRICE_PVT.PRICE_LINE', 0.5) ;--Added for bug 13435459
8088 oe_debug_pub.add('Version:'||get_version);
8089 END IF;
8090
8091 --RT{
8092 G_PRICING_EVENT:=p_pricing_events;
8093 G_RETROBILL_OPERATION:=p_request_rec.param3;
8094
8095 oe_debug_pub.add('Retrobill Operation:'||g_retrobill_operation);
8096 --RT}
8097
8098 If OE_DEBUG_PUB.G_DEBUG = FND_API.G_TRUE Then
8099 G_DEBUG := TRUE;
8100 IF l_debug_level > 0 THEN
8101 oe_debug_pub.add( 'BCT G_DEBUG IS:'||OE_DEBUG_PUB.G_DEBUG ) ;
8102 END IF;
8103 Else
8104 G_DEBUG := FALSE;
8105 End If;
8106
8107 IF l_debug_level > 0 THEN
8108 oe_debug_pub.add( 'SETTING REQUEST ID' , 1 ) ;
8109 END IF;
8110
8111 qp_price_request_context.set_request_id;
8112
8113 IF l_debug_level > 0 THEN
8114 oe_debug_pub.add( ' REQUEST ID IS : ' || QP_PREQ_GRP.G_REQUEST_ID , 1 ) ;
8115 END IF;
8116
8117 G_IS_THERE_FREEZE_OVERRIDE:=TRUE;
8118 G_IS_THERE_FREEZE_OVERRIDE:=Check_Freeze_Override(p_pricing_events);
8119
8120 IF l_debug_level > 0 THEN
8121 oe_debug_pub.add( 'PRICE_LINE:'||P_HEADER_ID||'+'||P_LINE_ID||'OF EVENT '||P_PRICING_EVENTS , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
8122 END IF;
8123 x_return_status := FND_API.G_RET_STS_SUCCESS;
8124
8125 calculate_adjustments
8126 (x_return_status => x_return_status,
8127 p_line_Id => p_line_Id,
8128 p_header_Id => p_Header_Id,
8129 p_pricing_events => p_pricing_events,
8130 p_Control_Rec => p_control_rec,
8131 p_action_code => p_action_code,
8132 x_any_frozen_line => l_any_frozen_line,
8133 px_line_Tbl => px_Line_Tbl,
8134 x_Header_Rec => lx_Header_Rec
8135 );
8136
8137
8138 --l_Control_Rec.calculate_flag := 'N';
8139 -- Do no proceed , if there are no order lines
8140 IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
8141 IF l_debug_level > 0 THEN
8142 oe_debug_pub.add( 'CALCULATE ADJUSTMENTS ERROR' ) ;
8143 END IF;
8144 raise fnd_api.g_exc_error;
8145 END IF;
8146
8147 If x_return_status = 'NOOP' Then
8148 IF l_debug_level > 0 THEN
8149 oe_debug_pub.add( 'THERE ARE NO ORDER LINES FOR '||P_LINE_ID ) ;
8150 END IF;
8151 OE_Order_PUB.G_LINE := NULL;
8152 OE_Order_PUB.G_HDR := NULL;
8153 Return;
8154 End If;
8155
8156 IF l_debug_level > 0 THEN
8157 oe_debug_pub.add( 'CALLING PRICING ENGINE PUBLIC API' , 2 ) ;
8158 END IF;
8159 Call_Pricing_Engine(p_Control_Rec
8160 ,p_Pricing_Events
8161 ,x_return_status
8162 );
8163 IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
8164 IF l_debug_level > 0 THEN
8165 oe_debug_pub.add( 'PRICING ENGINE ERROR' ) ;
8166 END IF;
8167 raise fnd_api.g_exc_error;
8168 END IF;
8169
8170 IF l_debug_level > 0 THEN
8171 oe_debug_pub.add( 'BEFORE OE_ORDER_PRICE_PVT.PROCESS_ADJUSTMENTS' , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
8172 END IF;
8173
8174 process_adjustments
8175 (
8176 x_return_status => x_Return_Status,
8177 p_Control_Rec => p_control_rec,
8178 p_any_frozen_line =>l_any_frozen_line,
8179 p_Header_Rec => lx_Header_Rec,
8180 p_header_id => p_header_id,
8181 p_line_id => p_line_id,
8182 px_line_Tbl => px_Line_Tbl,
8183 p_pricing_events => p_pricing_events
8184 );
8185
8186 IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
8187 IF l_debug_level > 0 THEN
8188 oe_debug_pub.add( 'PROCESS ADJUSTMENTS ERROR' ) ;
8189 END IF;
8190 raise fnd_api.g_exc_error;
8191 END IF;
8192
8193 --TaxER start
8194 IF (NVL(oe_sys_parameters.value('OE_INVOICE_FREIGHT_AS_LINE',l_org_id), 'N') = 'Y') THEN
8195
8196 /*12598464 start
8197 SELECT Count(1)
8198 INTO l_hdr_chg_count
8199 FROM oe_price_adjustments
8200 WHERE header_id= px_Line_Tbl(1).header_id
8201 AND list_line_type_code='FREIGHT_CHARGE'
8202 AND line_id IS NULL;
8203 12598464 end*/
8204
8205
8206 --12598464 IF l_hdr_chg_count > 0 THEN
8207
8208 BEGIN
8209
8210 IF OE_Order_Cache.g_header_rec.order_type_id is not null THEN
8211
8212 IF (OE_Order_Cache.g_order_type_rec.order_type_id = FND_API.G_MISS_NUM) OR (OE_Order_Cache.g_order_type_rec.order_type_id is null)
8213 OR (OE_Order_Cache.g_order_type_rec.order_type_id <> OE_Order_Cache.g_header_rec.Order_Type_id)
8214 THEN
8215 OE_Order_Cache.Load_Order_type(OE_Order_CACHE.g_header_rec.Order_Type_id) ;
8216 END IF ;
8217
8218 IF (OE_Order_Cache.g_order_type_rec.order_type_id = OE_Order_Cache.g_header_rec.Order_Type_id) THEN
8219 if (OE_Order_Cache.g_order_type_rec.tax_calculation_event_code = 'ENTERING') then
8220 l_tax_calculation_event_code := 0;
8221 elsif (OE_Order_Cache.g_order_type_rec.tax_calculation_event_code = 'BOOKING') then
8222 l_tax_calculation_event_code := 1;
8223 elsif (OE_Order_Cache.g_order_type_rec.tax_calculation_event_code = 'SHIPPING') then
8224 l_tax_calculation_event_code := 2;
8225 elsif (OE_Order_Cache.g_order_type_rec.tax_calculation_event_code = 'INVOICING') then
8226 l_tax_calculation_event_code := 3;
8227 else
8228 l_tax_calculation_event_code := -1;
8229 end if ;
8230 ELSE
8231 l_tax_calculation_event_code := 0 ;
8232 END IF ;
8233
8234
8235 END IF;
8236
8237 EXCEPTION
8238 WHEN NO_DATA_FOUND THEN
8239 l_tax_calculation_event_code := 0;
8240 WHEN OTHERS THEN
8241 IF l_debug_level > 0 THEN
8242 oe_debug_pub.add('OEXVOPRB:Failed while trying to query up tax_calcualtion_event for order_type_id ');
8243 END IF;
8244
8245 RAISE;
8246
8247 END;
8248
8249
8250 l_header_rec := OE_Header_UTIL.Query_Row(p_header_id=> px_Line_Tbl(1).header_id);
8251
8252 IF nvl(l_header_rec.booked_flag, 'N') = 'Y' THEN
8253 l_current_event := 1; /* current event is booking or higher */
8254 END IF;
8255
8256 IF l_debug_level > 0 THEN
8257 oe_debug_pub.add('OEXVOPRB:Tax Event Code :'||l_tax_calculation_event_code);
8258 oe_debug_pub.add('OEXVOPRB:Current Event :'||l_current_event);
8259 END IF;
8260
8261
8262 IF l_current_event >= l_tax_calculation_event_code THEN
8263
8264 IF (OE_GLOBALS.G_UI_FLAG)
8265 AND nvl(FND_PROFILE.VALUE('ONT_DELAY_TAX_CALC'), 'N') = 'N'
8266 THEN
8267 OE_delayed_requests_Pvt.log_request(
8268 p_entity_code => OE_GLOBALS.G_ENTITY_HEADER,
8269 p_entity_id => px_Line_Tbl(1).header_id,
8270 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_HEADER,
8271 p_requesting_entity_id => px_Line_Tbl(1).header_id,
8272 p_request_type => OE_GLOBALS.g_tax_line,
8273 x_return_status => x_return_status);
8274 ELSE
8275 OE_delayed_requests_Pvt.log_request(
8276 p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
8277 p_entity_id => px_Line_Tbl(1).header_id,
8278 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_HEADER,
8279 p_requesting_entity_id => px_Line_Tbl(1).header_id,
8280 p_request_type => OE_GLOBALS.g_tax_line,
8281 p_param1 => NULL,
8282 x_return_status => x_return_status);
8283 END IF;
8284 END IF;
8285 --12598464 END IF;
8286
8287
8288 BEGIN
8289
8290 l_line_rec := OE_line_UTIL.Query_Row(p_line_id=> px_Line_Tbl(1).line_id);
8291
8292 IF nvl(l_line_rec.booked_flag, 'N') = 'Y' THEN
8293 l_current_event := 1; /* current event is booking or higher */
8294 END IF;
8295
8296 IF (l_line_rec.shippable_flag = 'Y' and
8297 l_line_rec.shipped_quantity is not null ) THEN
8298 l_current_event := 2; /* current event is shipping or higher */
8299 END IF;
8300
8301
8302 IF ( l_tax_calculation_event_code = 2 and
8303 l_line_rec.shippable_flag = 'N' ) THEN
8304 l_current_event := l_tax_calculation_event_code;
8305 END IF;
8306
8307 EXCEPTION
8308 WHEN OTHERS THEN
8309 l_current_event := -999;
8310 END;
8311
8312 IF l_debug_level > 0 THEN
8313 oe_debug_pub.add('OEXULADB:Tax Event Code :'||l_tax_calculation_event_code);
8314 oe_debug_pub.add('OEXULADB:Current Event :'||l_current_event);
8315 END IF;
8316
8317 IF l_current_event >= l_tax_calculation_event_code THEN
8318
8319 IF (OE_GLOBALS.G_UI_FLAG)
8320 AND nvl(FND_PROFILE.VALUE('ONT_DELAY_TAX_CALC'), 'N') = 'N'
8321 THEN
8322 OE_delayed_requests_Pvt.log_request(
8323 p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
8324 p_entity_id => l_line_rec.line_id,
8325 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
8326 p_requesting_entity_id => l_line_rec.line_id,
8327 p_request_type => OE_GLOBALS.g_tax_line,
8328 x_return_status => x_return_status);
8329 ELSE
8330 OE_delayed_requests_Pvt.log_request(
8331 p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
8332 p_entity_id => l_line_rec.line_id,
8333 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
8334 p_requesting_entity_id => l_line_rec.line_id,
8335 p_request_type => OE_GLOBALS.g_tax_line,
8336 p_param1 => NULL,
8337 x_return_status => x_return_status);
8338 END IF;
8339 END IF;
8340
8341
8342 END IF;
8343 --TaxER end
8344 --reseting global structure after engine call
8345 OE_Order_PUB.G_LINE := NULL;
8346 OE_Order_PUB.G_HDR := NULL;
8347
8348 IF l_debug_level > 0 THEN
8349 oe_debug_pub.add( 'EXITING OE_ORDER_PRICE_PVT.PRICE_LINE' , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
8350 END IF;
8351
8352 Exception
8353 WHEN FND_API.G_EXC_ERROR THEN
8354
8355 --reseting global structure after engine call
8356 OE_Order_PUB.G_LINE := NULL;
8357 OE_Order_PUB.G_HDR := NULL;
8358 x_return_status := FND_API.G_RET_STS_ERROR;
8359
8360 IF l_debug_level > 0 THEN
8361 oe_debug_pub.add( 'EXITING PRICE_LINE WITH EXC ERROR' , 1 ) ;
8362 END IF;
8363 RAISE FND_API.G_EXC_ERROR;
8364 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
8365
8366 --reseting global structure after engine call
8367 OE_Order_PUB.G_LINE := NULL;
8368 OE_Order_PUB.G_HDR := NULL;
8369 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8370 IF l_debug_level > 0 THEN
8371 oe_debug_pub.add( 'EXITING PRICE_LINE WITH UNEXPECTED ERROR' , 1 ) ;
8372 END IF;
8373 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8374 WHEN OTHERS THEN
8375
8376 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8377 --reseting global structure after engine call
8378 OE_Order_PUB.G_LINE := NULL;
8379 OE_Order_PUB.G_HDR := NULL;
8380 IF l_debug_level > 0 THEN
8381 oe_debug_pub.add( 'ERROR IN OE_ORDER_PRICE_PVT.PRICE_LINE' , 1 ) ;
8382 END IF;
8383 IF l_debug_level > 0 THEN
8384 oe_debug_pub.add( SQLERRM , 1 ) ;
8385 END IF;
8386
8387 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
8388 THEN
8389 OE_MSG_PUB.Add_Exc_Msg
8390 ( G_PKG_NAME
8391 , 'Price_line'
8392 );
8393 END IF;
8394
8395 IF l_debug_level > 0 THEN
8396 oe_debug_pub.add( 'EXITING OE_ORDER_PRICE_PVT.PRICE_LINE' , 1 ) ;
8397 END IF;
8398 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8399
8400 IF l_debug_level > 0 THEN
8401 oe_debug_pub.add( 'EXITING OE_ORDER_PRICE_PVT.PRICE_LINE' , 1 ) ;
8402 END IF;
8403
8404 End Price_Line;
8405
8406 end OE_ORDER_PRICE_PVT;