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