DBA Data[Home] [Help]

PACKAGE BODY: APPS.OE_OE_AVAILABILITY

Source


1 PACKAGE BODY oe_oe_availability AS
2 /* $Header: OEXFAVAB.pls 120.3.12020000.2 2012/07/03 09:52:08 amallik ship $ */
3 
4   --Global variables
5 
6   G_PKG_NAME         CONSTANT VARCHAR2(30) := 'oe_oe_availability';
7   G_ATP_TBL          OE_ATP.atp_tbl_type;
8   G_line_id          CONSTANT NUMBER :=1234;
9   G_atp_line_id      CONSTANT NUMBER := -9987;
10   g_header_id        CONSTANT NUMBER :=2345;
11   g_hsecs            number;
12   g_place            varchar2(100);
13   g_total            number :=0;
14   g_total2           number ;
15 
16    -- Things from her would go
17 /*
18 g_inventory_item_id      number;
19 g_qty                    number;
20 g_uom                    varchar2(20);
21 g_request_date           date;
22 g_customer_id            number;
23 g_item_identifier_type   varchar2(40);
24 g_agreement_id           number;
25 g_price_list_id          number;
26 g_ship_to_org_id         number;
27 g_invoice_to_org_id      number;
28 g_ship_from_org_id       number;
29 g_pricing_date           date;
30 g_order_type_id          number;
31 g_currency               varchar2(20);
32 g_pricing_context        varchar2(30);
33 g_pricing_attribute1     varchar2(240);
34 g_pricing_attribute2     varchar2(240);
35 g_pricing_attribute3     varchar2(240);
36 g_pricing_attribute4     varchar2(240);
37 g_pricing_attribute5     varchar2(240);
38 g_pricing_attribute6     varchar2(240);
39 g_pricing_attribute7     varchar2(240);
40 g_pricing_attribute8     varchar2(240);
41 g_pricing_attribute9     varchar2(240);
42 g_pricing_attribute10    varchar2(240);
43 g_pricing_attribute11    varchar2(240);
44 g_pricing_attribute12    varchar2(240);
45 g_pricing_attribute13    varchar2(240);
46 g_pricing_attribute14    varchar2(240);
47 g_pricing_attribute15    varchar2(240);
48 g_pricing_attribute16    varchar2(240);
49 g_pricing_attribute17    varchar2(240);
50 g_pricing_attribute18    varchar2(240);
51 g_pricing_attribute19    varchar2(240);
52 g_pricing_attribute20    varchar2(240);
53 g_pricing_attribute21    varchar2(240);
54 g_pricing_attribute22    varchar2(240);
55 g_pricing_attribute23    varchar2(240);
56 g_pricing_attribute24    varchar2(240);
57 g_pricing_attribute25    varchar2(240);
58 g_pricing_attribute26    varchar2(240);
59 g_pricing_attribute27    varchar2(240);
60 g_pricing_attribute28    varchar2(240);
61 g_pricing_attribute29    varchar2(240);
62 g_pricing_attribute30    varchar2(240);
63 g_pricing_attribute31    varchar2(240);
64 g_pricing_attribute32    varchar2(240);
65 g_pricing_attribute33    varchar2(240);
66 g_pricing_attribute34    varchar2(240);
67 g_pricing_attribute35    varchar2(240);
68 g_pricing_attribute36    varchar2(240);
69 g_pricing_attribute37    varchar2(240);
70 g_pricing_attribute38    varchar2(240);
71 g_pricing_attribute39    varchar2(240);
72 g_pricing_attribute40    varchar2(240);
73 g_pricing_attribute41    varchar2(240);
74 g_pricing_attribute42    varchar2(240);
75 g_pricing_attribute43    varchar2(240);
76 g_pricing_attribute44    varchar2(240);
77 g_pricing_attribute45    varchar2(240);
78 g_pricing_attribute46    varchar2(240);
79 g_pricing_attribute47    varchar2(240);
80 g_pricing_attribute48    varchar2(240);
81 g_pricing_attribute49    varchar2(240);
82 g_pricing_attribute50    varchar2(240);
83 g_pricing_attribute51    varchar2(240);
84 g_pricing_attribute52    varchar2(240);
85 g_pricing_attribute53    varchar2(240);
86 g_pricing_attribute54    varchar2(240);
87 g_pricing_attribute55    varchar2(240);
88 g_pricing_attribute56    varchar2(240);
89 g_pricing_attribute57    varchar2(240);
90 g_pricing_attribute58    varchar2(240);
91 g_pricing_attribute59    varchar2(240);
92 g_pricing_attribute60    varchar2(240);
93 g_pricing_attribute61    varchar2(240);
94 g_pricing_attribute62    varchar2(240);
95 g_pricing_attribute63    varchar2(240);
96 g_pricing_attribute64    varchar2(240);
97 g_pricing_attribute65    varchar2(240);
98 g_pricing_attribute66    varchar2(240);
99 g_pricing_attribute67    varchar2(240);
100 g_pricing_attribute68    varchar2(240);
101 g_pricing_attribute69    varchar2(240);
102 g_pricing_attribute70    varchar2(240);
103 g_pricing_attribute71    varchar2(240);
104 g_pricing_attribute72    varchar2(240);
105 g_pricing_attribute73    varchar2(240);
106 g_pricing_attribute74    varchar2(240);
107 g_pricing_attribute75    varchar2(240);
108 g_pricing_attribute76    varchar2(240);
109 g_pricing_attribute77    varchar2(240);
110 g_pricing_attribute78    varchar2(240);
111 g_pricing_attribute79    varchar2(240);
112 g_pricing_attribute80    varchar2(240);
113 g_pricing_attribute81    varchar2(240);
114 g_pricing_attribute82    varchar2(240);
115 g_pricing_attribute83    varchar2(240);
116 g_pricing_attribute84    varchar2(240);
117 g_pricing_attribute85    varchar2(240);
118 g_pricing_attribute86    varchar2(240);
119 g_pricing_attribute87    varchar2(240);
120 g_pricing_attribute88    varchar2(240);
121 g_pricing_attribute89    varchar2(240);
122 g_pricing_attribute90    varchar2(240);
123 g_pricing_attribute91    varchar2(240);
124 g_pricing_attribute92    varchar2(240);
125 g_pricing_attribute93    varchar2(240);
126 g_pricing_attribute94    varchar2(240);
127 g_pricing_attribute95    varchar2(240);
128 g_pricing_attribute96    varchar2(240);
129 g_pricing_attribute97    varchar2(240);
130 g_pricing_attribute98    varchar2(240);
131 g_pricing_attribute99    varchar2(240);
132 g_pricing_attribute100   varchar2(240);
133 */
134    -- Till here it would go
135    --Global Tables required for temp_table population.
136 
137   G_LINE_INDEX_tbl               QP_PREQ_GRP.pls_integer_type;
138   G_LINE_TYPE_CODE_TBL           QP_PREQ_GRP.VARCHAR_TYPE;
139   G_PRICING_EFFECTIVE_DATE_TBL   QP_PREQ_GRP.DATE_TYPE   ;
140   G_ACTIVE_DATE_FIRST_TBL        QP_PREQ_GRP.DATE_TYPE   ;
141   G_ACTIVE_DATE_FIRST_TYPE_TBL   QP_PREQ_GRP.VARCHAR_TYPE;
142   G_ACTIVE_DATE_SECOND_TBL       QP_PREQ_GRP.DATE_TYPE   ;
143   G_ACTIVE_DATE_SECOND_TYPE_TBL  QP_PREQ_GRP.VARCHAR_TYPE ;
144   G_LINE_QUANTITY_TBL            QP_PREQ_GRP.NUMBER_TYPE ;
145   G_LINE_UOM_CODE_TBL            QP_PREQ_GRP.VARCHAR_TYPE;
146   G_REQUEST_TYPE_CODE_TBL        QP_PREQ_GRP.VARCHAR_TYPE;
147   G_PRICED_QUANTITY_TBL          QP_PREQ_GRP.NUMBER_TYPE;
148   G_UOM_QUANTITY_TBL             QP_PREQ_GRP.NUMBER_TYPE;
149   G_PRICED_UOM_CODE_TBL          QP_PREQ_GRP.VARCHAR_TYPE;
150   G_CURRENCY_CODE_TBL            QP_PREQ_GRP.VARCHAR_TYPE;
151   G_UNIT_PRICE_TBL               QP_PREQ_GRP.NUMBER_TYPE;
152   G_PERCENT_PRICE_TBL            QP_PREQ_GRP.NUMBER_TYPE;
153   G_ADJUSTED_UNIT_PRICE_TBL      QP_PREQ_GRP.NUMBER_TYPE;
154   G_UPD_ADJUSTED_UNIT_PRICE_TBL  QP_PREQ_GRP.NUMBER_TYPE;
155   G_PROCESSED_FLAG_TBL           QP_PREQ_GRP.VARCHAR_TYPE;
156   G_PRICE_FLAG_TBL               QP_PREQ_GRP.VARCHAR_TYPE;
157   G_LINE_ID_TBL                  QP_PREQ_GRP.NUMBER_TYPE;
158   G_PROCESSING_ORDER_TBL         QP_PREQ_GRP.PLS_INTEGER_TYPE;
159   G_ROUNDING_FACTOR_TBL          QP_PREQ_GRP.PLS_INTEGER_TYPE;
160   G_ROUNDING_FLAG_TBL            QP_PREQ_GRP.FLAG_TYPE;
161   G_QUALIFIERS_EXIST_FLAG_TBL    QP_PREQ_GRP.VARCHAR_TYPE;
162   G_PRICING_ATTRS_EXIST_FLAG_TBL QP_PREQ_GRP.VARCHAR_TYPE;
163   G_PRICE_LIST_ID_TBL            QP_PREQ_GRP.NUMBER_TYPE;
164   G_PL_VALIDATED_FLAG_TBL        QP_PREQ_GRP.VARCHAR_TYPE;
165   G_PRICE_REQUEST_CODE_TBL       QP_PREQ_GRP.VARCHAR_TYPE;
166   G_USAGE_PRICING_TYPE_TBL       QP_PREQ_GRP.VARCHAR_TYPE;
167   G_LINE_CATEGORY_TBL            QP_PREQ_GRP.VARCHAR_TYPE;
168   G_PRICING_STATUS_CODE_tbl      QP_PREQ_GRP.VARCHAR_TYPE;
169   G_PRICING_STATUS_TEXT_tbl      QP_PREQ_GRP.VARCHAR_TYPE;
170   G_ATTR_LINE_INDEX_tbl          QP_PREQ_GRP.PLS_INTEGER_TYPE;
171   G_ATTR_LINE_DETAIL_INDEX_tbl   QP_PREQ_GRP.PLS_INTEGER_TYPE;
172   G_ATTR_VALIDATED_FLAG_tbl      QP_PREQ_GRP.VARCHAR_TYPE;
173   G_ATTR_PRICING_CONTEXT_tbl     QP_PREQ_GRP.VARCHAR_TYPE;
174   G_ATTR_PRICING_ATTRIBUTE_tbl   QP_PREQ_GRP.VARCHAR_TYPE;
175   G_ATTR_ATTRIBUTE_LEVEL_tbl	 QP_PREQ_GRP.VARCHAR_TYPE;
176   G_ATTR_ATTRIBUTE_TYPE_tbl	 QP_PREQ_GRP.VARCHAR_TYPE;
177   G_ATTR_APPLIED_FLAG_tbl	 QP_PREQ_GRP.VARCHAR_TYPE;
178   G_ATTR_PRICING_STATUS_CODE_tbl QP_PREQ_GRP.VARCHAR_TYPE;
179   G_ATTR_PRICING_ATTR_FLAG_tbl 	 QP_PREQ_GRP.VARCHAR_TYPE;
180   G_ATTR_LIST_HEADER_ID_tbl	 QP_PREQ_GRP.NUMBER_TYPE;
181   G_ATTR_LIST_LINE_ID_tbl	 QP_PREQ_GRP.NUMBER_TYPE;
182   G_ATTR_VALUE_FROM_tbl          QP_PREQ_GRP.VARCHAR_TYPE;
183   G_ATTR_SETUP_VALUE_FROM_tbl    QP_PREQ_GRP.VARCHAR_TYPE;
184   G_ATTR_VALUE_TO_tbl     	 QP_PREQ_GRP.VARCHAR_TYPE;
185   G_ATTR_SETUP_VALUE_TO_tbl	 QP_PREQ_GRP.VARCHAR_TYPE;
186   G_ATTR_GROUPING_NUMBER_tbl 	 QP_PREQ_GRP.PLS_INTEGER_TYPE;
187   G_ATTR_NO_QUAL_IN_GRP_tbl      QP_PREQ_GRP.PLS_INTEGER_TYPE;
188   G_ATTR_COMP_OPERATOR_TYPE_tbl  QP_PREQ_GRP.VARCHAR_TYPE;
189   G_ATTR_PRICING_STATUS_TEXT_tbl QP_PREQ_GRP.VARCHAR_TYPE;
190   G_ATTR_QUAL_PRECEDENCE_tbl     QP_PREQ_GRP.PLS_INTEGER_TYPE;
191   G_ATTR_DATATYPE_tbl            QP_PREQ_GRP.VARCHAR_TYPE;
192   G_ATTR_QUALIFIER_TYPE_tbl      QP_PREQ_GRP.VARCHAR_TYPE;
193   G_ATTR_PRODUCT_UOM_CODE_TBL    QP_PREQ_GRP.VARCHAR_TYPE;
194   G_ATTR_EXCLUDER_FLAG_TBL       QP_PREQ_GRP.VARCHAR_TYPE;
195   G_ATTR_PRICING_PHASE_ID_TBL    QP_PREQ_GRP.PLS_INTEGER_TYPE;
196   G_ATTR_INCOM_GRP_CODE_TBL      QP_PREQ_GRP.VARCHAR_TYPE;
197   G_ATTR_LDET_TYPE_CODE_TBL      QP_PREQ_GRP.VARCHAR_TYPE;
198   G_ATTR_MODIFIER_LEVEL_CODE_TBL QP_PREQ_GRP.VARCHAR_TYPE;
199   G_ATTR_PRIMARY_UOM_FLAG_TBL    QP_PREQ_GRP.VARCHAR_TYPE;
200   G_CATCHWEIGHT_QTY_TBL          QP_PREQ_GRP.NUMBER_TYPE;
201   G_ACTUAL_ORDER_QTY_TBL         QP_PREQ_GRP.NUMBER_TYPE;
202   G_IS_THERE_FREEZE_OVERRIDE  Boolean:=TRUE;
203 
204 
205 --g_panda_rec_table panda_rec_table;
206 
207 
208 Procedure Call_MRP_ATP(
209                in_global_orgs  in varchar2,
210                in_ship_from_org_id in number,
211                out_available_qty out nocopy varchar2,
212                out_ship_from_org_id out nocopy number,
213                out_available_date out nocopy date,
214                out_qty_uom out nocopy varchar2,
215                x_out_message out nocopy varchar2,
216                x_return_status OUT NOCOPY VARCHAR2,
217                x_msg_count OUT NOCOPY NUMBER,
218                x_msg_data OUT NOCOPY VARCHAR2,
219                x_error_message out nocopy varchar2
220                       ) IS
221 
222 l_session_id              NUMBER := 0;
223 l_mrp_atp_rec             MRP_ATP_PUB.ATP_Rec_Typ;
224 l_atp_supply_demand       MRP_ATP_PUB.ATP_Supply_Demand_Typ;
225 l_atp_period              MRP_ATP_PUB.ATP_Period_Typ;
226 l_atp_details             MRP_ATP_PUB.ATP_Details_Typ;
227 x_atp_rec                 MRP_ATP_PUB.ATP_Rec_Typ;
228 in_atp_rec                 MRP_ATP_PUB.ATP_Rec_Typ;
229 I                         NUMBER := 1;
230 l_mrp_calc_sd             VARCHAR2(240);--bug14222176
231 
232 --
233 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
234 --
235 BEGIN
236 
237    IF l_debug_level  > 0 THEN
238        oe_debug_pub.add(  'ENTERING CALL ATP' ) ;
239    END IF;
240 
241    Initialize_mrp_record
242        ( p_x_atp_rec => in_atp_rec
243          ,l_count    =>1 );
244 
245 
246                     IF l_debug_level  > 0 THEN
247                         oe_debug_pub.add(  'INVENTORY_ITEM_ID='||g_panda_rec_table(1).P_INVENTORY_ITEM_ID
248 					   || ' SHIP_FORM_ORG_ID='||G_panda_rec_table(1).p_SHIP_FROM_ORG_ID
249 					   || ' IN_GLOBAL_ORGS='||IN_GLOBAL_ORGS);
250                         oe_debug_pub.add(' CUST_ID='||G_panda_rec_table(1).p_CUSTOMER_ID|| ' SHIP_TO_ORG_ID='
251 					 ||G_panda_rec_table(1).p_SHIP_TO_ORG_ID||' QTY='||G_panda_rec_table(1).p_QTY
252 					 || ' UOM='||G_panda_rec_table(1).p_UOM||' REQ DATE='||
253 					 G_panda_rec_table(1).p_REQUEST_DATE ) ;
254                     END IF;
255 
256    --if the call is made for GA then the org_id is passed
257    IF in_global_orgs = 'Y' and
258       in_ship_from_org_id is not null then
259 
260      in_atp_rec.Source_Organization_Id(1)  := in_ship_from_org_id;
261    ELSE
262 
263      in_atp_rec.Source_Organization_Id(1)  := g_panda_rec_table(1).p_ship_from_org_id;
264    END IF;
265 
266    /*SELECT  OE_ORDER_LINES_S.NEXTVAL
267      INTO  l_line_id
268      FROM  DUAL;
269    */
270    IF l_debug_level  > 0 THEN
271        oe_debug_pub.add(  'LINE_ID='||G_ATP_LINE_ID ) ;
272    END IF;
273 
274    in_atp_rec.Identifier(I)              := g_atp_line_id;
275    in_atp_rec.Action(I)                  := 100;
276    in_atp_rec.calling_module(I)          := 660;
277    in_atp_rec.customer_id(I)             := g_panda_rec_table(1).p_customer_id;
278    in_atp_rec.customer_site_id(I)        := g_panda_rec_table(1).p_ship_to_org_id;
279    in_atp_rec.inventory_item_id(I)       := g_panda_rec_table(1).p_inventory_item_id;
280    in_atp_rec.quantity_ordered(I)        := g_panda_rec_table(1).p_qty;
281    in_atp_rec.quantity_uom(I)            := g_panda_rec_table(1).p_uom;
282    in_atp_rec.Earliest_Acceptable_Date(I):= null;
283    in_atp_rec.Requested_Ship_Date(I)     := g_panda_rec_table(1).p_request_date;
284    in_atp_rec.Requested_Arrival_Date(I)  := null;
285    in_atp_rec.Delivery_Lead_Time(I)      := Null;
286    in_atp_rec.Freight_Carrier(I)         := null;
287    in_atp_rec.Ship_Method(I)             := null;
288    in_atp_rec.Demand_Class(I)            := null;
289    in_atp_rec.Ship_Set_Name(I)           := null;
290    in_atp_rec.Arrival_Set_Name(I)        := null;
291    in_atp_rec.Override_Flag(I)           := 'N';
292    in_atp_rec.Ship_Date(I)               := null;
293    in_atp_rec.Available_Quantity(I)      := null;
294    in_atp_rec.Requested_Date_Quantity(I) := null;
295    in_atp_rec.Group_Ship_Date(I)         := null;
296    in_atp_rec.Group_Arrival_Date(I)      := null;
297    in_atp_rec.Vendor_Id(I)               := null;
298    in_atp_rec.Vendor_Site_Id(I)          := null;
299  --in_atp_rec.Insert_Flag(I)             := 1; -- it can be 0 or 1
300 -- commented by bug14222176
301    in_atp_rec.Error_Code(I)              := null;
302    in_atp_rec.Message(I)                 := null;
303    in_atp_rec.atp_lead_time(I)           := 0;
304 
305  --bug14222176
306    l_mrp_calc_sd :=  fnd_profile.value('MRP_ATP_CALC_SD');
307     IF nvl(l_mrp_calc_sd,'N') = 'Y' THEN
308         oe_debug_pub.add('in OEXFAVAB, MRP_ATP_CALC_SD profile set to yes ' );
309         in_atp_rec.Insert_Flag(I)    := 1;
310     ELSE
311         oe_debug_pub.add('in OEXFAVAB, MRP_ATP_CALC_SD profile set to No  ' );
312         in_atp_rec.Insert_Flag(I)    := 0;
313     END IF;
314 --end bug14222176
315 
316    SELECT mrp_atp_schedule_temp_s.nextval
317      INTO l_session_id
318      FROM dual;
319 
320    -- Call ATP
321 
322    IF l_debug_level  > 0 THEN
323        oe_debug_pub.add('1.CALLING MRP API WITH SESSION ID '||L_SESSION_ID);
324    END IF;
325 
326     IF l_debug_level  > 0 THEN
327      print_time('Calling MRP');
328     END IF;
329 
330    MRP_ATP_PUB.Call_ATP (
331                  p_session_id             =>  l_session_id
332                , p_atp_rec                =>  in_atp_rec
333                , x_atp_rec                =>  x_atp_rec
334                , x_atp_supply_demand      =>  l_atp_supply_demand
335                , x_atp_period             =>  l_atp_period
336                , x_atp_details            =>  l_atp_details
337                , x_return_status          =>  x_return_status
338                , x_msg_data               =>  x_msg_data
339                , x_msg_count              =>  x_msg_count
340                     );
341 
342     IF l_debug_level  > 0 THEN
343      print_time('After Calling MRP');
344     END IF;
345 
346    IF l_debug_level  > 0 THEN
347      oe_debug_pub.add(  'AFTER CALL MRP_ATP_PUB.CALL_ATP STS='||X_RETURN_STATUS|| ' MSG COUNT='||X_MSG_COUNT);
348 
349      IF x_atp_rec.available_quantity.COUNT > 0 AND
350         x_atp_rec.source_organization_id.COUNT > 0 then
351      oe_debug_pub.add( ' MSG DATA='||X_MSG_DATA|| 'AVL QTY='|| X_ATP_REC.AVAILABLE_QUANTITY ( 1 ) ||
352 		       'SHIP_FROM_ORG_ID =' ||X_ATP_REC.SOURCE_ORGANIZATION_ID ( 1 ) ) ;
353      END IF;
354    END IF;
355 
356    IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
357        IF l_debug_level  > 0 THEN
358            oe_debug_pub.add(  'ERROR IS' || X_MSG_DATA , 1 ) ;
359        END IF;
360        RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
361    END IF;
362 
363 
364    Check_Results_from_rec(
365                        in_global_orgs =>in_global_orgs
366                       ,p_atp_rec       => x_atp_rec
367                       ,x_return_status => x_return_status
368                       ,x_msg_count  =>x_msg_count
369                       ,x_msg_data =>x_msg_data
370                       ,x_error_message  =>x_error_message
371                          );
372 
373    IF l_debug_level  > 0 THEN
374      oe_debug_pub.add(  'STATUS='||X_RETURN_STATUS|| ' X_ERROR_MESSAGE ='
375 			||X_ERROR_MESSAGE|| ' MSG DATA='||X_MSG_DATA ) ;
376    END IF;
377 
378 /* Commented the following code to fix fp bug 3498932 */
379 /*
380 
381    IF nvl(x_return_status,'E') <> 'P' then
382 
383      IF l_debug_level  > 0 THEN
384          oe_debug_pub.add(  'RETURN_STATUS<>P' ) ;
385      END IF;
386 
387      IF nvl(x_return_status,'E') <> 'E' THEN
388        IF  nvl(x_atp_rec.available_quantity(1),0) = 0 then
389 
390          IF l_debug_level  > 0 THEN
391            oe_debug_pub.add(  'AVAILABLE QUANTITY IS 0' ) ;
392          END IF;
393          out_available_date   := null;
394          out_available_qty    := 0;
395 
396        ELSE
397          IF x_atp_rec.available_quantity.COUNT > 0 THEN
398            out_available_qty    := x_atp_rec.available_quantity(1);
399          END IF;
400          IF x_atp_rec.ship_date.COUNT > 0 THEN
401            out_available_date    := x_atp_rec.ship_date(1);
402          END IF;
403          IF x_atp_rec.group_ship_date.COUNT > 0 THEN
404            IF x_atp_rec.group_ship_date(1) is not null THEN
405              out_available_date  := x_atp_rec.group_ship_date(1);
406            END IF;
407          END IF;
408 
409        END IF;
410      ELSE
411        out_available_date   := null;
412        out_available_qty    := 0;
413 
414      END IF; -- if status is not E
415 
416    ELSE -- if status is P
417 
418      IF l_debug_level  > 0 THEN
419          oe_debug_pub.add(  'RETURN_STATUS=P MESG='||X_ERROR_MESSAGE ) ;
420      END IF;
421      out_available_qty    := x_error_message;
422      out_available_date   := null;
423      x_error_message := null;
424 
425    END IF; -- if return status is not P
426  */
427 /* End of code commented to fix the bug 3498932 */
428  /* Added the following code to fix the bug 3498932 */
429 
430          IF x_atp_rec.available_quantity.COUNT > 0 THEN
431            out_available_qty    := x_atp_rec.available_quantity(1);
432          END IF;
433          IF x_atp_rec.ship_date.COUNT > 0 THEN
434            out_available_date    := x_atp_rec.ship_date(1);
435          END IF;
436          IF x_atp_rec.group_ship_date.COUNT > 0 THEN
437            IF x_atp_rec.group_ship_date(1) is not null THEN
438              out_available_date  := x_atp_rec.group_ship_date(1);
439            END IF;
440          END IF;
441          IF x_atp_rec.error_code(1) = 53 then
442            out_available_qty    := x_atp_rec.requested_date_quantity(1);
443          END IF;
444 
445 /* End of new code added to fix the bug 3498932 */
446 
447    IF x_atp_rec.source_organization_id.COUNT > 0 THEN
448      out_ship_from_org_id := x_atp_rec.source_organization_id(1);
449    END IF;
450    IF x_atp_rec.quantity_uom.COUNT > 0 THEN
451      out_qty_uom          := x_atp_rec.quantity_uom(1);
452    END IF;
453 
454 
455    IF l_debug_level  > 0 THEN
456      oe_debug_pub.add( 'OUT_AVAL_QTY='||OUT_AVAILABLE_QTY|| ' SHIP_FORM_ORG_ID='||
457 		       OUT_SHIP_FROM_ORG_ID|| ' UOM='||OUT_QTY_UOM);
458 
459 
460      IF x_atp_rec.ship_date.COUNT > 0 THEN
461        oe_debug_pub.add(' OUT SHIP DATE='||X_ATP_REC.SHIP_DATE(1));
462      END IF;
463 
464      IF x_atp_rec.group_ship_date.COUNT > 0 THEN
465         oe_debug_pub.add(' OUT GRP SHIP DATE='||X_ATP_REC.GROUP_SHIP_DATE(1));
466      END IF;
467 
468      IF x_atp_rec.arrival_date.COUNT > 0 THEN
469       oe_debug_pub.add(' OUT ARRIVAL DATE='||X_ATP_REC.ARRIVAL_DATE(1));
470      END IF;
471 
472      IF x_atp_rec.requested_date_quantity.COUNT > 0 THEN
473         oe_debug_pub.add('REQ DATE QTY='||X_ATP_REC.REQUESTED_DATE_QUANTITY(1));
474      END IF;
475      IF x_atp_rec.available_quantity.COUNT > 0 THEN
476         oe_debug_pub.add(' AVAILABLE QTY='||X_ATP_REC.AVAILABLE_QUANTITY(1));
477      END IF;
478 
479    END IF; -- if debug is on
480 
481 
482    IF l_debug_level  > 0 THEN
483        oe_debug_pub.add(  'EXITING CALL ATP' , 1 ) ;
484    END IF;
485 
486 
487 EXCEPTION
488 
489    WHEN OTHERS THEN
490 
491         IF l_debug_level  > 0 THEN
492             oe_debug_pub.add(  'WHEN OTHERS OF CALL_MRP_ATP' ) ;
493         END IF;
494         IF l_debug_level  > 0 THEN
495             oe_debug_pub.add(  'CODE='||SQLCODE||' MSG='||SQLERRM ) ;
496         END IF;
497         x_return_status := 'E';
498         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
499         --  Get message count and data
500         OE_MSG_PUB.Count_And_Get
501         (   p_count                       => x_msg_count
502         ,   p_data                        => x_msg_data
503         );
504 
505         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
506             OE_MSG_PUB.Add_Exc_Msg
507             (   G_PKG_NAME,
508               'Call_MRP_ATP');
509         END IF;
510 
511         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
512 
513 END Call_MRP_ATP;
514 
515 
516 
517 PROCEDURE defaulting(
518             in_source in varchar2
519             ,in_org_id in varchar2
520             ,in_item_id in number
521             ,in_customer_id in number
522             ,in_ship_to_org_id in number
523             ,in_bill_to_org_id in number
524             ,in_agreement_id in number
525             ,in_order_type_id in number
526             ,out_wsh_id out nocopy number
527             ,out_uom out nocopy varchar2
528             ,out_item_type_code  out nocopy varchar2
529             ,out_price_list_id out nocopy number
530             ,out_conversion_type out nocopy varchar2
531 
532                      ) IS
533 
534 x_msg_count number;
535 tmp_var varchar2(2000);
536 tmp_var1 varchar2(2000);
537 x_msg_data varchar2(2000);
538 x_return_status varchar2(2000);
539 
540 l_old_rec oe_ak_order_lines_v%ROWTYPE;
541 l_rec     oe_ak_order_lines_v%ROWTYPE;
542 l_out_rec oe_ak_order_lines_v%ROWTYPE;
543 l_old_header_rec OE_AK_ORDER_HEADERS_V%ROWTYPE;
544 l_record         OE_AK_ORDER_HEADERS_V%ROWTYPE;
545 l_out_record         OE_AK_ORDER_HEADERS_V%ROWTYPE;
546 
547 --
548 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
549 --
550 l_bom_item_type Varchar2(1);
551 l_pick_components_flag Varchar2(1);
552 BEGIN
553 
554 
555                   IF l_debug_level  > 0 THEN
556                       oe_debug_pub.add(  'ENTERING OE_AVAILABILITY.DEFAULTING '|| ' ITEM_ID='||
557 					 IN_ITEM_ID|| ' SOURCE TYPE ='||IN_SOURCE|| ' ORG ID TYPE ='||IN_ORG_ID);
558                      oe_debug_pub.add( ' CUSTOMER_ID ='||IN_CUSTOMER_ID|| ' SHIP_TO_ORG_ID ='||
559 				       IN_SHIP_TO_ORG_ID|| ' IN_BILL_TO_ORG_ID ='||IN_BILL_TO_ORG_ID
560 				       || ' IN_AGREEMENT_ID ='||IN_AGREEMENT_ID|| ' IN_ORDER_TYPE_ID ='
561 				       ||IN_ORDER_TYPE_ID ) ;
562                   END IF;
563 
564 
565 
566   IF in_source = 'ITEM' then
567 
568     l_rec.inventory_item_id     := in_item_id;
569     l_rec.org_id                := in_org_id;
570     l_rec.sold_to_org_id        := in_customer_id;
571     l_rec.ship_to_org_id        := in_ship_to_org_id;
572     l_rec.ship_from_org_id      := FND_API.G_MISS_NUM;
573     l_rec.order_quantity_uom    := FND_API.G_MISS_CHAR;
574     --l_rec.price_list_id       := FND_API.G_MISS_NUM;
575 
576     l_out_rec := l_rec;
577 
578     ONT_LINE_DEF_HDLR.Default_record(
579                         p_x_rec => l_out_rec,
580                         p_initial_rec =>l_rec,
581                         p_in_old_rec  => l_old_rec
582                                     );
583     out_wsh_id           := l_out_rec.ship_from_org_id;
584     out_uom              := l_out_rec.order_quantity_uom;
585     out_price_list_id    := null;
586     BEGIN
587       SELECT BOM_ITEM_TYPE,PICK_COMPONENTS_FLAG
588       INTO l_bom_item_type,l_pick_components_flag
589       FROM MTL_SYSTEM_ITEMS
590       WHERE INVENTORY_ITEM_ID= in_item_id
591       AND ORGANIZATION_ID=in_org_id;
592       IF l_bom_item_type=4 AND l_pick_components_flag='N' THEN
593         out_item_type_code := 'STANDARD';
594       END IF;
595     EXCEPTION
596     WHEN NO_DATA_FOUND THEN
597       Null;
598     WHEN TOO_MANY_ROWS THEN
599       Null;
600     WHEN OTHERS THEN
601       Null;
602     END;
603 
604                      IF l_debug_level  > 0 THEN
605                          oe_debug_pub.add(  'WSH_ID='||OUT_WSH_ID|| ' UOM='||OUT_UOM|| ' PRICE_LIST_ID='||
606 					    OUT_PRICE_LIST_ID ) ;
607                      END IF;
608 
609   ELSIF in_source = 'CUSTOMER' then
610 
611     IF l_debug_level  > 0 THEN
612         oe_debug_pub.add(  'SOURCE = CUSTOMER' ) ;
613     END IF;
614     l_record.sold_to_org_id        := in_customer_id;
615     l_record.org_id                := in_org_id;
616     l_record.ship_to_org_id        := in_ship_to_org_id;
617     l_record.agreement_id          := in_agreement_id;
618     l_record.invoice_to_org_id     := in_bill_to_org_id;
619     l_record.ship_from_org_id      := FND_API.G_MISS_NUM;
620     l_record.price_list_id         := FND_API.G_MISS_NUM;
621 
622     l_out_record := l_record;
623 
624     ONT_HEADER_Def_Hdlr.Default_Record
625          ( p_x_rec       => l_out_record
626          , p_initial_rec => l_record
627          , p_in_old_rec	 => l_old_header_rec
628          , p_iteration	 => 1
629          );
630 
631     out_wsh_id           := l_out_record.ship_from_org_id;
632     out_price_list_id    := l_out_record.price_list_id;
633 
634                      IF l_debug_level  > 0 THEN
635                          oe_debug_pub.add(  'WSH_ID='||OUT_WSH_ID|| ' UOM='||OUT_UOM|| ' PRICE_LIST_ID='
636 					    ||OUT_PRICE_LIST_ID ) ;
637                      END IF;
638 
639   ELSIF in_source = 'SHIP_TO' then
640 
641     l_record.sold_to_org_id        := in_customer_id;
642     l_record.org_id                := in_org_id;
643     l_record.ship_to_org_id        := in_ship_to_org_id;
644     l_record.agreement_id          := in_agreement_id;
645     l_record.invoice_to_org_id     := in_bill_to_org_id;
646     l_record.ship_from_org_id      := FND_API.G_MISS_NUM;
647     l_record.price_list_id         := FND_API.G_MISS_NUM;
648 
649     l_out_record := l_record;
650 
651     ONT_HEADER_Def_Hdlr.Default_Record
652          ( p_x_rec       => l_out_record
653          , p_initial_rec => l_record
654          , p_in_old_rec	 => l_old_header_rec
655          , p_iteration	 => 1
656          );
657 
658     out_wsh_id           := l_out_record.ship_from_org_id;
659     out_price_list_id    := l_out_record.price_list_id;
660 
661                      IF l_debug_level  > 0 THEN
662                          oe_debug_pub.add(  'WSH_ID='||OUT_WSH_ID|| ' UOM='||OUT_UOM||
663 					    ' PRICE_LIST_ID='||OUT_PRICE_LIST_ID ) ;
664                      END IF;
665 
666   ELSIF in_source = 'BILL_TO' then
667 
668     l_record.sold_to_org_id        := in_customer_id;
669     l_record.org_id                := in_org_id;
670     l_record.ship_to_org_id        := in_ship_to_org_id;
671     l_record.agreement_id          := in_agreement_id;
672     l_record.invoice_to_org_id     := in_bill_to_org_id;
673     l_record.price_list_id         := FND_API.G_MISS_NUM;
674 
675     l_out_record := l_record;
676 
677     ONT_HEADER_Def_Hdlr.Default_Record
678          ( p_x_rec       => l_out_record
679          , p_initial_rec => l_record
680          , p_in_old_rec	 => l_old_header_rec
681          , p_iteration	 => 1
682          );
683 
684     out_wsh_id           := null;
685     out_uom              := null;
686     out_price_list_id    := l_out_record.price_list_id;
687 
688                      IF l_debug_level  > 0 THEN
689                          oe_debug_pub.add(  'WSH_ID='||OUT_WSH_ID|| ' UOM='||OUT_UOM
690 					    || ' PRICE_LIST_ID='||OUT_PRICE_LIST_ID ) ;
691                      END IF;
692 
693   ELSIF in_source = 'AGREEMENT' then
694 
695     l_rec.agreement_id          := in_agreement_id;
696     l_rec.ship_to_org_id        := in_ship_to_org_id;
697     l_rec.invoice_to_org_id     := in_bill_to_org_id;
698     l_rec.sold_to_org_id        := in_customer_id;
699     l_rec.org_id                := in_org_id;
700     l_rec.price_list_id         := FND_API.G_MISS_NUM;
701 
702     l_out_rec := l_rec;
703 
704     ONT_LINE_DEF_HDLR.Default_record(
705                         p_x_rec => l_out_rec,
706                         p_initial_rec =>l_rec,
707                         p_in_old_rec  => l_old_rec
708                                     );
709     out_wsh_id           := null;
710     out_uom              := null;
711     out_price_list_id    := l_out_rec.price_list_id;
712 
713                      IF l_debug_level  > 0 THEN
714                          oe_debug_pub.add(  'WSH_ID='||OUT_WSH_ID|| ' UOM='||
715 					    OUT_UOM|| ' PRICE_LIST_ID='||OUT_PRICE_LIST_ID ) ;
716                      END IF;
717 
718   ELSIF in_source = 'ORDER_TYPE' then
719 
720     l_record.org_id                := in_org_id;
721     l_record.order_type_id         := in_order_type_id;
722     l_record.conversion_type_code  := FND_API.G_MISS_CHAR;
723 
724     l_out_record := l_record;
725 
726 
727     ONT_HEADER_Def_Hdlr.Default_Record
728          ( p_x_rec       => l_out_record
729          , p_initial_rec => l_record
730          , p_in_old_rec	 => l_old_header_rec
731          , p_iteration	 => 1
732          );
733 
734     out_conversion_type  := l_out_record.conversion_type_code;
735     out_uom              := null;
736     out_price_list_id    := null;
737     out_wsh_id           := null;
738 
739                      IF l_debug_level  > 0 THEN
740                          oe_debug_pub.add(  'WSH_ID='||OUT_WSH_ID|| ' UOM='||OUT_UOM
741 					    || ' CONVERSION_TYPE_CODE='||OUT_CONVERSION_TYPE ) ;
742                      END IF;
743 
744   ELSIF in_source = 'STARTUP' then
745 
746     l_record.org_id                := in_org_id;
747 
748     l_record.conversion_type_code  := FND_API.G_MISS_CHAR;
749     l_record.price_list_id         := FND_API.G_MISS_NUM;
750     l_record.ship_from_org_id      := FND_API.G_MISS_NUM;
751 
752     l_out_record := l_record;
753 
754     ONT_HEADER_Def_Hdlr.Default_Record
755          ( p_x_rec       => l_out_record
756          , p_initial_rec => l_record
757          , p_in_old_rec	 => l_old_header_rec
758          , p_iteration	 => 1
759          );
760 
761     out_wsh_id           := l_out_rec.ship_from_org_id;
762     out_uom              := l_out_rec.order_quantity_uom;
763     out_price_list_id    := l_out_record.price_list_id;
764     out_conversion_type  := l_out_record.conversion_type_code;
765 
766   END IF; -- in source_type
767 
768   IF l_debug_level  > 0 THEN
769       oe_debug_pub.add(  'EXITING OE_AVAILABILITY.DEFAULTING' ) ;
770   END IF;
771 
772 EXCEPTION
773 
774     WHEN FND_API.G_EXC_ERROR THEN
775 
776         x_return_status := FND_API.G_RET_STS_ERROR;
777 
778         --  Get message count and data
779 
780         OE_MSG_PUB.Count_And_Get
781         (   p_count                       => x_msg_count
782         ,   p_data                        => x_msg_data
783         );
784 
785     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
786 
787         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
788 
789         --  Get message count and data
790 
791         OE_MSG_PUB.Count_And_Get
792         (   p_count                       => x_msg_count
793         ,   p_data                        => x_msg_data
794         );
795 
796     WHEN OTHERS THEN
797 
798         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
799 
800         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
801         THEN
802             OE_MSG_PUB.Add_Exc_Msg
803             (   G_PKG_NAME
804             ,   'defaulting'
805             );
806         END IF;
807 
808         --  Get message count and data
809 
810         OE_MSG_PUB.Count_And_Get
811         (   p_count                       => x_msg_count
812         ,   p_data                        => x_msg_data
813         );
814 
815 END defaulting;
816 
817 
818 Procedure Check_Results_from_rec (
819         in_global_orgs in varchar2
820        ,p_atp_rec         IN  MRP_ATP_PUB.ATP_Rec_Typ
821 ,x_return_status OUT NOCOPY VARCHAR2
822 
823 ,x_msg_count OUT NOCOPY NUMBER
824 
825 ,x_msg_data OUT NOCOPY VARCHAR2
826 
827 ,x_error_message OUT NOCOPY varchar2
828 
829                                 )IS
830 
831 atp_count          NUMBER := 1;
832 J                  NUMBER := 1;
833 l_explanation      VARCHAR2(80);
834 l_type_code        VARCHAR2(30);
835 l_ship_set_name    VARCHAR2(30);
836 l_arrival_set_name VARCHAR2(30);
837 l_arrival_date     DATE := NULL;
838 l_sch_action       varchar2(100) := 'OESCH_ACT_ATP_CHECK';
839 --
840 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
841 --
842 BEGIN
843 
844   x_return_status :=  'S';
845   IF l_debug_level  > 0 AND
846     p_atp_rec.error_code.COUNT > 0 THEN
847     oe_debug_pub.add(  '2. ENTERING CHECK_RESULTS ERROR_CODE='|| P_ATP_REC.ERROR_CODE ( J ) ||
848 		       ' IN_GLOBAL_ORGS='||IN_GLOBAL_ORGS ) ;
849   END IF;
850 
851   IF p_atp_rec.error_code.COUNT > 0 AND
852      p_atp_rec.error_code(J) <> 0 AND
853         p_atp_rec.error_code(J) <> -99  AND -- Multi org changes.
854         p_atp_rec.error_code(J) <> 150 -- to fix bug 1880166
855 
856      THEN
857 
858       IF l_debug_level  > 0 THEN
859           oe_debug_pub.add(  'ERROR FROM MRP: ' || P_ATP_REC.ERROR_CODE ( J ) , 1 ) ;
860       END IF;
861 
862       IF p_atp_rec.error_code(J) = 80 THEN
863 
864           l_explanation := null;
865 
866           select meaning
867             into l_explanation
868             from mfg_lookups
869            where lookup_type = 'MTL_DEMAND_INTERFACE_ERRORS'
870              and lookup_code = 80;
871 
872           IF l_debug_level  > 0 THEN
873               oe_debug_pub.add(  'SETTING THE MESSAGE FOR OE_SCH_NO_SOURCE' ) ;
874           END IF;
875           --FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_SOURCE');
876           IF in_global_orgs = 'N' then
877 
878             FND_MESSAGE.SET_NAME('ONT','ONT_AVAIL_NO_SOURCES');
879             OE_MSG_PUB.Add;
880           ELSE
881             x_error_message := l_explanation;
882           END IF;
883 
884       ELSE
885 
886           IF l_debug_level  > 0 THEN
887               oe_debug_pub.add(  'SCH FAILED ERROR CODE='||P_ATP_REC.ERROR_CODE ( J ) ) ;
888           END IF;
889 
890           l_explanation := null;
891 
892           select meaning
893             into l_explanation
894             from mfg_lookups
895            where lookup_type = 'MTL_DEMAND_INTERFACE_ERRORS'
896              and lookup_code = p_atp_rec.error_code(J) ;
897 
898           IF p_atp_rec.error_code(J) = 19 THEN
899              -- This error code is given for those lines which are
900              -- in a group and whose scheduling failed due to some other lines.
901              -- We do not want to give this out as a message.
902              null;
903 
904           ELSIF p_atp_rec.error_code(J) = 61 THEN
905 
906             -- setting the status flag to partial for ATP not applicable
907             IF l_debug_level  > 0 THEN
908                 oe_debug_pub.add(  'ERROR CODE = 61' ) ;
909             END IF;
910 
911             x_return_status := 'P';
912             x_error_message := l_explanation;
913 
914          /* Added the following code to fix the bug 3498932 */
915 
916           ELSIF p_atp_rec.error_code(J) = 53 THEN
917 
918             x_return_status := 'E';
919             IF l_debug_level  > 0 THEN
920                 oe_debug_pub.add(  'ERROR CODE = 53' ) ;
921             END IF;
922 
923             FND_MESSAGE.SET_NAME('ONT','ONT_PRC_AVA_NO_REQUESTED_QTY');
924             FND_MESSAGE.SET_TOKEN('PARTIAL_QUANTITY', p_atp_rec.requested_date_quantity(J));
925             FND_MESSAGE.SET_TOKEN('REQUEST_DATE', p_atp_rec.requested_ship_date(J));
926             FND_MESSAGE.SET_TOKEN('EARLIEST_DATE', p_atp_rec.ship_date(J));
927 
928             IF in_global_orgs = 'N' then
929                 OE_MSG_PUB.Add;
930             ELSE
931                 x_error_message := fnd_message.get;
932             END IF;
933 
934 /* End of code added to fix the bug 3498932 */
935 
936 
937           ELSIF p_atp_rec.Ship_Set_Name(J) is not null OR
938                   p_atp_rec.Arrival_Set_Name(J) is not null THEN
939 
940              -- This line belongs to a scheduling group. We do not want
941              -- to give out individual messages for each line.
942              null;
943 
944           ELSE
945               IF l_debug_level  > 0 THEN
946                   oe_debug_pub.add(  'ADDING MESSAGE TO THE STACK' , 1 ) ;
947               END IF;
948               --FND_MESSAGE.SET_NAME('ONT','OE_SCH_OE_ORDER_FAILED');
949               --FND_MESSAGE.SET_TOKEN('EXPLANATION',l_explanation);
950 
951               IF in_global_orgs = 'N' then
952                 FND_MESSAGE.SET_NAME('ONT','ONT_INLNE_CUSTOMER');
953                 FND_MESSAGE.SET_TOKEN('TEXT',l_explanation);
954                 OE_MSG_PUB.Add;
955               ELSE
956                 x_error_message := l_explanation;
957               END IF;
958 
959           END IF;
960 
961       END IF; -- 80
962 
963       IF l_debug_level  > 0 THEN
964           oe_debug_pub.add(  'SETTING ERROR' , 1 ) ;
965       END IF;
966       IF x_return_status <> 'P' then
967         x_return_status := 'E';
968       END IF;
969 
970   ELSE
971 
972                       IF l_debug_level  > 0 THEN
973                           oe_debug_pub.add(  ' ELSE '||P_ATP_REC.SOURCE_ORGANIZATION_ID ( 1 ) ||
974 					     ' ERROR CODE : ' || P_ATP_REC.ERROR_CODE ( J ) ) ;
975                       END IF;
976 
977       -- Muti org changes.
978       IF (p_atp_rec.error_code(J) <> -99 ) THEN
979 
980                         IF l_debug_level  > 0 THEN
981                             oe_debug_pub.add(  'ERROR CODE : ' || P_ATP_REC.ERROR_CODE ( J ) || 'IDENTIFIER : ' ||
982 					       P_ATP_REC.IDENTIFIER ( J ) || 'ITEM : ' ||
983 					       P_ATP_REC.INVENTORY_ITEM_ID ( J ));
984                             oe_debug_pub.add( 'REQUEST SHIP DATE :' ||
985 					      TO_CHAR ( P_ATP_REC.REQUESTED_SHIP_DATE ( J ) , 'DD-MON-RR:HH:MM:SS' )
986 					      || 'REQUEST ARRIVAL DATE :' || P_ATP_REC.REQUESTED_ARRIVAL_DATE ( J ));
987                             oe_debug_pub.add( 'ARRIVAL DATE :' ||
988 					      TO_CHAR ( P_ATP_REC.ARRIVAL_DATE ( J ) , 'DD-MON-RR:HH:MM:SS' ) ||
989 					      'SHIP DATE :' ||
990 					      TO_CHAR ( P_ATP_REC.SHIP_DATE ( J ) , 'DD-MON-RR:HH:MM:SS' ));
991                            oe_debug_pub.add( 'LEAD TIME :' ||P_ATP_REC.DELIVERY_LEAD_TIME ( J ) ||
992 					     'GROUP SHIP DATE :'||P_ATP_REC.GROUP_SHIP_DATE ( J ) ||
993 					     'GROUP ARR DATE :'||P_ATP_REC.GROUP_ARRIVAL_DATE ( J ) ) ;
994                         END IF;
995 
996         l_explanation := null;
997 
998         IF (p_atp_rec.error_code(J) <> 0) THEN
999 
1000           BEGIN
1001               select meaning
1002                 into l_explanation
1003                 from mfg_lookups
1004                where lookup_type = 'MTL_DEMAND_INTERFACE_ERRORS'
1005                  and lookup_code = p_atp_rec.error_code(J) ;
1006 
1007               g_atp_tbl(atp_count).error_message   := l_explanation;
1008               IF l_debug_level  > 0 THEN
1009                   oe_debug_pub.add(  'EXPLANATION IS : ' || L_EXPLANATION , 1 ) ;
1010               END IF;
1011               x_error_message := l_explanation;
1012 
1013               IF p_atp_rec.error_code(J) = 150 THEN
1014                 OE_MSG_PUB.add_text(l_explanation);
1015               END IF;
1016 
1017           EXCEPTION
1018               WHEN OTHERS THEN
1019                   Null;
1020           END;
1021 
1022         END IF;
1023 
1024       END IF; --Check for -99.
1025 
1026   END IF; -- Main If;
1027 
1028   -- umcomment for testing the error handling
1029   --x_return_status := 'E';
1030   --FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_SOURCE');
1031   --OE_MSG_PUB.Add;
1032 
1033   IF x_return_status ='E'  and in_global_orgs = 'N' then
1034     IF l_debug_level  > 0 THEN
1035         oe_debug_pub.add(  'DOING COUNT_AND_GET' ) ;
1036     END IF;
1037     oe_msg_pub.count_and_get(p_encoded=>fnd_api.G_TRUE,
1038                              p_count => x_msg_count,
1039                              p_data=>x_msg_data
1040                              );
1041     IF l_debug_level  > 0 THEN
1042         oe_debug_pub.add(  'COUNT = '||X_MSG_COUNT||' MSG='||X_MSG_DATA ) ;
1043     END IF;
1044   END IF;
1045 
1046   IF l_debug_level  > 0 THEN
1047       oe_debug_pub.add(  'EXITING CHECK_RESULTS: ' || X_RETURN_STATUS , 1 ) ;
1048   END IF;
1049 
1050 EXCEPTION
1051   WHEN OTHERS THEN
1052       IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1053       THEN
1054             OE_MSG_PUB.Add_Exc_Msg
1055             (   G_PKG_NAME
1056             ,   'Check_Results'
1057             );
1058       END IF;
1059       IF l_debug_level  > 0 THEN
1060           oe_debug_pub.add(  'UNEXPECTED ERROR IN CHECK_RESULTS' ) ;
1061       END IF;
1062       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1063 
1064 END Check_Results_from_rec;
1065 
1066 
1067 Procedure Initialize_mrp_record
1068          ( p_x_atp_rec IN  OUT NOCOPY MRP_ATP_PUB.ATP_Rec_Typ
1069           ,l_count     IN  NUMBER) IS
1070 
1071 l_return_status varchar2(10);
1072 
1073 --
1074 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1075 --
1076 BEGIN
1077 
1078   IF l_debug_level  > 0 THEN
1079       oe_debug_pub.add(  'EXTENDING THE TABLE BY ' || L_COUNT , 5 ) ;
1080   END IF;
1081 
1082   MSC_SATP_FUNC.Extend_ATP
1083   (p_atp_tab       => p_x_atp_rec,
1084    p_index         => l_count,
1085    x_return_status => l_return_status);
1086 
1087   /*p_x_atp_rec.Inventory_Item_Id.extend(l_count);
1088   p_x_atp_rec.Source_Organization_Id.extend(l_count);
1089   p_x_atp_rec.Identifier.extend(l_count);
1090   p_x_atp_rec.Order_Number.extend(l_count);
1091   p_x_atp_rec.Calling_Module.extend(l_count);
1092   p_x_atp_rec.Customer_Id.extend(l_count);
1093   p_x_atp_rec.Customer_Site_Id.extend(l_count);
1094   p_x_atp_rec.Destination_Time_Zone.extend(l_count);
1095   p_x_atp_rec.Quantity_Ordered.extend(l_count);
1096   p_x_atp_rec.Quantity_UOM.extend(l_count);
1097   p_x_atp_rec.Requested_Ship_Date.extend(l_count);
1098   p_x_atp_rec.Requested_Arrival_Date.extend(l_count);
1099   p_x_atp_rec.Earliest_Acceptable_Date.extend(l_count);
1100   p_x_atp_rec.Latest_Acceptable_Date.extend(l_count);
1101   p_x_atp_rec.Delivery_Lead_Time.extend(l_count);
1102   p_x_atp_rec.Atp_Lead_Time.extend(l_count);
1103   p_x_atp_rec.Freight_Carrier.extend(l_count);
1104   p_x_atp_rec.Ship_Method.extend(l_count);
1105   p_x_atp_rec.Demand_Class.extend(l_count);
1106   p_x_atp_rec.Ship_Set_Name.extend(l_count);
1107   p_x_atp_rec.Arrival_Set_Name.extend(l_count);
1108   p_x_atp_rec.Override_Flag.extend(l_count);
1109   p_x_atp_rec.Action.extend(l_count);
1110   p_x_atp_rec.ship_date.extend(l_count);
1111   p_x_atp_rec.Available_Quantity.extend(l_count);
1112   p_x_atp_rec.Requested_Date_Quantity.extend(l_count);
1113   p_x_atp_rec.Group_Ship_Date.extend(l_count);
1114   p_x_atp_rec.Group_Arrival_Date.extend(l_count);
1115   p_x_atp_rec.Vendor_Id.extend(l_count);
1116   p_x_atp_rec.Vendor_Site_Id.extend(l_count);
1117   p_x_atp_rec.Insert_Flag.extend(l_count);
1118   p_x_atp_rec.Error_Code.extend(l_count);
1119   p_x_atp_rec.Message.extend(l_count);
1120   p_x_atp_rec.Old_Source_Organization_Id.extend(l_count);
1121   p_x_atp_rec.Old_Demand_Class.extend(l_count);
1122   p_x_atp_rec.oe_flag.extend(l_count);
1123   p_x_atp_rec.ato_delete_flag.extend(l_count);
1124   p_x_atp_rec.attribute_01.extend(l_count);
1125   p_x_atp_rec.attribute_05.extend(l_count);*/
1126 
1127 
1128 EXCEPTION
1129 
1130    WHEN OTHERS THEN
1131 
1132        IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
1133             OE_MSG_PUB.Add_Exc_Msg
1134             (   G_PKG_NAME,
1135               'Initialize_mrp_record');
1136        END IF;
1137 
1138 END Initialize_mrp_record;
1139 
1140 
1141 
1142 Procedure Query_Qty_Tree(p_org_id            IN NUMBER,
1143                          p_item_id           IN NUMBER,
1144                          p_sch_date          IN DATE DEFAULT NULL,
1145 x_on_hand_qty OUT NOCOPY NUMBER,
1146 
1147 x_avail_to_reserve OUT NOCOPY NUMBER
1148 
1149                          ) IS
1150 
1151 l_return_status           VARCHAR2(1);
1152 l_msg_count               NUMBER;
1153 l_msg_data                VARCHAR2(2000);
1154 l_qoh                     NUMBER;
1155 l_rqoh                    NUMBER;
1156 l_qr                      NUMBER;
1157 l_qs                      NUMBER;
1158 l_att                     NUMBER;
1159 l_atr                     NUMBER;
1160 l_msg_index               NUMBER;
1161 l_lot_control_flag        BOOLEAN;
1162 l_lot_control_code        NUMBER;
1163 l_org_id                  NUMBER;
1164 
1165 --
1166 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1167 --
1168 BEGIN
1169 
1170                    IF l_debug_level  > 0 THEN
1171                        oe_debug_pub.add(  'ENTERING QUERY_QTY_TREE'|| 'ORG IS : ' || P_ORG_ID
1172 					  || 'ITEM IS : ' || P_ITEM_ID ) ;
1173                    END IF;
1174 
1175   BEGIN
1176     IF p_org_id is null THEN
1177        l_org_id := OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');
1178     END IF;
1179 
1180     SELECT msi.lot_control_code
1181     INTO   l_lot_control_code
1182     FROM   mtl_system_items msi
1183     WHERE  msi.inventory_item_id = p_item_id
1184     AND    msi.organization_id   = nvl(p_org_id,l_org_id);
1185 
1186     IF l_lot_control_code = 2 THEN
1187        l_lot_control_flag := TRUE;
1188     ELSE
1189        l_lot_control_flag := FALSE;
1190     END IF;
1191 
1192   EXCEPTION
1193    WHEN OTHERS THEN
1194    l_lot_control_flag := FALSE;
1195   END;
1196 
1197   inv_quantity_tree_pub.query_quantities
1198     (  p_api_version_number      => 1.0
1199      , x_return_status           => l_return_status
1200      , x_msg_count               => l_msg_count
1201      , x_msg_data                => l_msg_data
1202      , p_organization_id         => p_org_id
1203      , p_inventory_item_id       => p_item_id
1204      , p_tree_mode               => 2
1205      , p_is_revision_control     => false
1206      , p_is_lot_control          => l_lot_control_flag
1207      , p_lot_expiration_date     => nvl(p_sch_date,sysdate)
1208      , p_is_serial_control       => false
1209      , p_revision                => null
1210      , p_lot_number              => null
1211      , p_subinventory_code       => null
1212      , p_locator_id              => null
1213      , x_qoh                     => l_qoh
1214      , x_rqoh                    => l_rqoh
1215      , x_qr                      => l_qr
1216      , x_qs                      => l_qs
1217      , x_att                     => l_att
1218      , x_atr                     => l_atr
1219      );
1220 
1221                    IF l_debug_level  > 0 THEN
1222                        oe_debug_pub.add(  'RR: L_QOH ' || L_QOH|| 'RR: L_QOH ' || L_ATR ) ;
1223                    END IF;
1224 
1225   x_on_hand_qty      := l_qoh;
1226   x_avail_to_reserve := l_atr;
1227 
1228   IF l_debug_level  > 0 THEN
1229       oe_debug_pub.add(  'EXITING QUERY_QTY_TREE ' , 1 ) ;
1230   END IF;
1231 
1232 END Query_Qty_Tree;
1233 
1234 
1235 
1236 PROCEDURE get_ship_from_org(in_org_id in number,
1237 out_code out nocopy varchar2,
1238 
1239 out_name out nocopy varchar2
1240 
1241                            )IS
1242 
1243 --
1244 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1245 --
1246 BEGIN
1247     SELECT organization_code,
1248            name
1249       INTO out_code,
1250            out_name
1251       FROM oe_ship_from_orgs_v
1252      WHERE organization_id = in_org_id;
1253 
1254 EXCEPTION
1255 
1256 WHEN OTHERS THEN
1257                      IF l_debug_level  > 0 THEN
1258                          oe_debug_pub.add(  'GET_SHIP_FROM_ORG WHEN OTHERS '|| SQLCODE||SQLERRM ) ;
1259                      END IF;
1260 
1261 END get_ship_From_org;
1262 
1263 
1264 
1265 procedure copy_Header_to_request(
1266 				 p_request_type_code in varchar2
1267 				 ,p_calculate_price_flag in varchar2
1268 				 ,px_req_line_tbl   in out nocopy	QP_PREQ_GRP.LINE_TBL_TYPE
1269 				 ) is
1270 
1271    l_line_index	pls_integer := 0;
1272 
1273    --
1274    l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1275    --
1276 BEGIN
1277 
1278    IF l_debug_level  > 0 THEN
1279       oe_debug_pub.add(  'ENTERING OE_AVAILABILITY.COPY_HEADER_TO_REQUEST' , 1 ) ;
1280    END IF;
1281 
1282    l_line_index := l_line_index+1;
1283    px_req_line_tbl(l_line_index).REQUEST_TYPE_CODE :=p_Request_Type_Code;
1284    px_req_line_tbl(l_line_index).LINE_INDEX := l_line_index;
1285    px_req_line_tbl(l_line_index).LINE_TYPE_CODE := 'ORDER';
1286    -- Hold the header_id in line_id for 'HEADER' Records
1287 
1288    px_req_line_tbl(l_line_index).line_id := g_line_id;
1289 
1290    if g_panda_rec_table(1).p_pricing_date is null or g_panda_rec_table(1).p_pricing_date = fnd_api.g_miss_date then
1291       px_req_line_tbl(l_line_index).PRICING_EFFECTIVE_DATE := trunc(sysdate);
1292    Else
1293       px_req_line_tbl(l_line_index).PRICING_EFFECTIVE_DATE := g_panda_rec_table(1).p_pricing_date;
1294    End If;
1295 
1296    px_req_line_tbl(l_line_index).CURRENCY_CODE := g_panda_rec_table(1).p_currency;
1297    px_req_line_tbl(l_line_index).PRICE_FLAG := p_calculate_price_flag;
1298    px_req_line_tbl(l_line_index).Active_date_first_type := 'ORD';
1299    px_req_line_tbl(l_line_index).Active_date_first := g_panda_rec_table(1).p_request_date;
1300 
1301 
1302    --If G_ROUNDING_FLAG = 'Y' Then
1303    IF g_panda_rec_table(1).p_price_list_id is not null then
1304       px_req_line_tbl(l_line_index).Rounding_factor := Get_Rounding_factor(g_panda_rec_table(1).p_price_list_id);
1305    END IF;
1306    --End If;
1307    IF l_debug_level  > 0 THEN
1308       oe_debug_pub.add(  'CURR='||G_panda_rec_table(1).p_CURRENCY||' REQ DATE='||
1309 			 G_panda_rec_table(1).p_REQUEST_DATE||' ROUNDING_FACTOR='||
1310 			 PX_REQ_LINE_TBL ( L_LINE_INDEX ) .ROUNDING_FACTOR ) ;
1311    END IF;
1312 
1313    --px_req_line_tbl(l_line_index).price_request_code := p_header_rec.price_request_code; -- PROMOTIONS SEP/01
1314    --populating temp tables
1315     G_LINE_INDEX_TBL.delete;
1316    if l_debug_level > 0 then
1317       oe_debug_pub.add('********** POPULATING HEADER RECORD INTO TEMP TABLE *********************');
1318       --oe_debug_pub.add('line index is='||G_LINE_INDEX_TBL(l_line_index));
1319    end if;
1320    G_LINE_INDEX_TBL(l_line_index)             :=  px_req_line_tbl(l_line_index).LINE_INDEX;
1321    G_LINE_TYPE_CODE_TBL(l_line_index)         :=  px_req_line_tbl(l_line_index).LINE_TYPE_CODE;
1322    G_PRICING_EFFECTIVE_DATE_TBL(l_line_index) :=  TRUNC(px_req_line_tbl(l_line_index).PRICING_EFFECTIVE_DATE);
1323    G_ACTIVE_DATE_FIRST_TBL(l_line_index)      :=  TRUNC(px_req_line_tbl(l_line_index).ACTIVE_DATE_FIRST);
1324    G_ACTIVE_DATE_FIRST_TYPE_TBL(l_line_index) :=  px_req_line_tbl(l_line_index).ACTIVE_DATE_FIRST_TYPE;
1325    G_ACTIVE_DATE_SECOND_TBL(l_line_index)     :=  TRUNC(px_req_line_tbl(l_line_index).ACTIVE_DATE_SECOND);
1326    G_ACTIVE_DATE_SECOND_TYPE_TBL(l_line_index):= px_req_line_tbl(l_line_index).ACTIVE_DATE_SECOND_TYPE;
1327    G_LINE_QUANTITY_TBL(l_line_index)          := px_req_line_tbl(l_line_index).LINE_QUANTITY;
1328    G_LINE_UOM_CODE_TBL(l_line_index)          := px_req_line_tbl(l_line_index).LINE_UOM_CODE;
1329    G_REQUEST_TYPE_CODE_TBL(l_line_index)      := px_req_line_tbl(l_line_index).REQUEST_TYPE_CODE;
1330    G_PRICED_QUANTITY_TBL(l_line_index)        := px_req_line_tbl(l_line_index).PRICED_QUANTITY;
1331    G_UOM_QUANTITY_TBL(l_line_index)           := px_req_line_tbl(l_line_index).UOM_QUANTITY;
1332    G_PRICED_UOM_CODE_TBL(l_line_index)        := px_req_line_tbl(l_line_index).PRICED_UOM_CODE;
1333    G_CURRENCY_CODE_TBL(l_line_index)          := px_req_line_tbl(l_line_index).CURRENCY_CODE;
1334    G_UNIT_PRICE_TBL(l_line_index)             := px_req_line_tbl(l_line_index).unit_price;  -- AG
1335    G_PERCENT_PRICE_TBL(l_line_index)          := px_req_line_tbl(l_line_index).PERCENT_PRICE;
1336    G_ADJUSTED_UNIT_PRICE_TBL(l_line_index)    := px_req_line_tbl(l_line_index).ADJUSTED_UNIT_PRICE;
1337    G_PROCESSED_FLAG_TBL(l_line_index)         := QP_PREQ_GRP.G_NOT_PROCESSED;
1338    G_PRICE_FLAG_TBL(l_line_index)             := px_req_line_tbl(l_line_index).PRICE_FLAG;
1339    G_LINE_ID_TBL(l_line_index)                := px_req_line_tbl(l_line_index).LINE_ID;
1340    if l_debug_level >0 then
1341       oe_debug_pub.add('the order line id'||G_LINE_ID_TBL(l_line_index));
1342    end if;
1343    G_ROUNDING_FLAG_TBL(l_line_index)          := NULL;
1344    G_ROUNDING_FACTOR_TBL(l_line_index)        := px_req_line_tbl(l_line_index).ROUNDING_FACTOR;
1345    G_PROCESSING_ORDER_TBL(l_line_index)       := NULL;
1346    G_PRICING_STATUS_CODE_tbl(l_line_index)    := QP_PREQ_GRP.G_STATUS_UNCHANGED;
1347    G_PRICING_STATUS_TEXT_tbl(l_line_index)    := NULL;
1348 
1349    G_QUALIFIERS_EXIST_FLAG_TBL(l_line_index)            :='N';
1350    G_PRICING_ATTRS_EXIST_FLAG_TBL(l_line_index)       :='N';
1351    G_PRICE_LIST_ID_TBL(l_line_index)                 :=g_panda_rec_table(1).p_price_list_id;
1352    G_PL_VALIDATED_FLAG_TBL(l_line_index)                := 'N';
1353    G_PRICE_REQUEST_CODE_TBL(l_line_index)        := NULL;
1354    G_USAGE_PRICING_TYPE_TBL(l_line_index)        :='REGULAR';
1355    G_UPD_ADJUSTED_UNIT_PRICE_TBL(l_line_index) :=NULL;
1356    G_LINE_CATEGORY_TBL(l_line_index)           :=NULL;
1357    G_CATCHWEIGHT_QTY_TBL(l_line_index)         := NULL;
1358    G_ACTUAL_ORDER_QTY_TBL(l_line_index)        :=NULL;
1359 
1360    --Temp Table population done
1361 
1362    IF l_debug_level  > 0 THEN
1363       oe_debug_pub.add(  'EXITING OE_OE_AVAILABILITY.COPY_HEADER_TO_REQUEST' ) ;
1364    END IF;
1365 
1366 END copy_Header_to_request;
1367 
1368 
1369 PROCEDURE copy_Line_to_request(
1370 			       px_req_line_tbl   in out nocopy QP_PREQ_GRP.LINE_TBL_TYPE
1371 			       ,p_pricing_event   in    varchar2
1372 			       ,p_Request_Type_Code in	varchar2
1373 			       ,p_honor_price_flag in VARCHAR2 Default 'Y'
1374 			       ,p_line_index in number
1375 			       ) IS
1376 
1377    l_line_index	pls_integer := nvl(px_req_line_tbl.count,0);
1378    l_uom_rate      NUMBER;
1379    v_discounting_privilege VARCHAR2(30);
1380    l_item_type_code VARCHAR2(30);
1381 
1382    --
1383    l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1384    --
1385 begin
1386 
1387    IF l_debug_level  > 0 THEN
1388       oe_debug_pub.add(  'ENTERING OE_ORDER_ADJ_PVT.COPY_LINE_TO_REQUEST' , 1 ) ;
1389    END IF;
1390 
1391    l_line_index := l_line_index+1;
1392    px_req_line_tbl(l_line_index).Line_id := g_line_id;
1393    px_req_line_tbl(l_line_index).REQUEST_TYPE_CODE := p_Request_Type_Code;
1394    px_req_line_tbl(l_line_index).LINE_INDEX := l_line_index;
1395    px_req_line_tbl(l_line_index).LINE_TYPE_CODE := 'LINE';
1396 
1397    IF g_panda_rec_table(p_line_index).p_pricing_date is null or
1398       g_panda_rec_table(p_line_index).p_pricing_date = fnd_api.g_miss_date then
1399       px_req_line_tbl(l_line_index).PRICING_EFFECTIVE_DATE := trunc(sysdate);
1400    ELSE
1401       px_req_line_tbl(l_line_index).PRICING_EFFECTIVE_DATE := g_panda_rec_table(p_line_index).p_pricing_date;
1402    END IF;
1403 
1404    px_req_line_tbl(l_line_index).LINE_QUANTITY := g_panda_rec_table(p_line_index).p_qty ;
1405    px_req_line_tbl(l_line_index).LINE_UOM_CODE := g_panda_rec_table(p_line_index).p_uom;
1406    px_req_line_tbl(l_line_index).PRICED_QUANTITY := g_panda_rec_table(p_line_index).p_qty;
1407    px_req_line_tbl(l_line_index).PRICED_UOM_CODE := g_panda_rec_table(p_line_index).p_uom;
1408    px_req_line_tbl(l_line_index).CURRENCY_CODE :=g_panda_rec_table(p_line_index).p_currency;
1409    px_req_line_tbl(l_line_index).UNIT_PRICE := Null;
1410    --px_req_line_tbl(l_line_index).PERCENT_PRICE := p_Line_rec.unit_list_percent;
1411    IF l_debug_level  > 0 THEN
1412       oe_debug_pub.add(  'QTY='||G_panda_rec_table(p_line_index).p_QTY||' UOM ='||
1413 			 G_panda_rec_table(p_line_index).p_UOM||' CURR='||G_panda_rec_table(p_line_index).p_CURRENCY ) ;
1414    END IF;
1415 
1416   /*If (p_Line_rec.service_period = p_Line_rec.Order_quantity_uom) Then
1417     px_req_line_tbl(l_line_index).UOM_QUANTITY := p_Line_rec.service_duration;
1418   Else
1419     INV_CONVERT.INV_UM_CONVERSION(From_Unit => p_Line_rec.service_period
1420                              ,To_Unit   => p_Line_rec.Order_quantity_uom
1421                              ,Item_ID   => p_Line_rec.Inventory_item_id
1422                              ,Uom_Rate  => l_Uom_rate);
1423     px_req_line_tbl(l_line_index).UOM_QUANTITY := p_Line_rec.service_duration * l_uom_rate;
1424   End If; */
1425 
1426    --If G_ROUNDING_FLAG = 'Y' Then
1427    px_req_line_tbl(l_line_index).Rounding_factor :=
1428       Get_Rounding_factor(g_panda_rec_table(p_line_index).p_price_list_id);
1429    --End If;
1430 
1431    px_req_line_tbl(l_line_index).PRICE_FLAG := 'Y';
1432 
1433 
1434    -- Get Discounting Privilege Profile Option value
1435    fnd_profile.get('ONT_DISCOUNTING_PRIVILEGE', v_discounting_privilege);
1436 
1437    -- Execute the pricing phase if the list price is null
1438 
1439    IF p_pricing_event = 'PRICE' and
1440 
1441 
1442      px_req_line_tbl(l_line_index).UNIT_PRICE is null then
1443 
1444     px_req_line_tbl(l_line_index).PRICE_FLAG := 'Y' ;
1445 
1446   END IF;
1447 
1448   --l_item_type_code := oe_line_util.Get_Return_Item_Type_Code(p_Line_rec);
1449   l_item_type_code := 'STANDARD';
1450 
1451   px_req_line_tbl(l_line_index).Active_date_first_type := 'ORD';
1452   px_req_line_tbl(l_line_index).Active_date_first := g_panda_rec_table(p_line_index).p_request_date;
1453 
1454   IF g_panda_rec_table(p_line_index).p_request_date is not null then
1455     px_req_line_tbl(l_line_index).Active_date_Second_type := 'SHIP';
1456     px_req_line_tbl(l_line_index).Active_date_Second := g_panda_rec_table(p_line_index).p_request_date;
1457   End If;
1458 
1459   --px_req_line_tbl(l_line_index).price_request_code := p_line_rec.price_request_code; -- PROMOTIONS  SEP/01
1460   --px_req_line_tbl(l_line_index).line_category :=p_line_rec.line_category_code;
1461 
1462    oe_debug_pub.add('********Temp tables population for lines **************');
1463    oe_debug_pub.add('LINE INDEX'||l_line_index);
1464 
1465    G_LINE_INDEX_TBL(l_line_index)            :=  px_req_line_tbl(l_line_index).LINE_INDEX;
1466    G_LINE_TYPE_CODE_TBL(l_line_index)        :=  px_req_line_tbl(l_line_index).LINE_TYPE_CODE;
1467    G_PRICING_EFFECTIVE_DATE_TBL(l_line_index):=  TRUNC(px_req_line_tbl(l_line_index).PRICING_EFFECTIVE_DATE);
1468    G_ACTIVE_DATE_FIRST_TBL(l_line_index)     :=  TRUNC(px_req_line_tbl(l_line_index).ACTIVE_DATE_FIRST);
1469    G_ACTIVE_DATE_FIRST_TYPE_TBL(l_line_index):=  px_req_line_tbl(l_line_index).ACTIVE_DATE_FIRST_TYPE;
1470    G_ACTIVE_DATE_SECOND_TBL(l_line_index)    :=  TRUNC(px_req_line_tbl(l_line_index).ACTIVE_DATE_SECOND);
1471    G_ACTIVE_DATE_SECOND_TYPE_TBL(l_line_index):= px_req_line_tbl(l_line_index).ACTIVE_DATE_SECOND_TYPE;
1472   --px_req_line_tbl(l_line_index).priced_quantity := NULL;
1473    IF l_debug_level  > 0 THEN
1474        oe_debug_pub.add(  'QUANTITY'||PX_REQ_LINE_TBL(L_LINE_INDEX).LINE_QUANTITY||' '||
1475 			  PX_REQ_LINE_TBL(L_LINE_INDEX).PRICED_QUANTITY , 3 ) ;
1476    END IF;
1477    IF l_debug_level  > 0 THEN
1478        oe_debug_pub.add(  'PRICE FLAG'||PX_REQ_LINE_TBL(L_LINE_INDEX).PRICE_FLAG ) ;
1479    END IF;
1480    G_LINE_QUANTITY_TBL(l_line_index)          := px_req_line_tbl(l_line_index).LINE_QUANTITY;
1481 
1482    G_LINE_UOM_CODE_TBL(l_line_index)          := px_req_line_tbl(l_line_index).LINE_UOM_CODE;
1483    G_REQUEST_TYPE_CODE_TBL(l_line_index)      := px_req_line_tbl(l_line_index).REQUEST_TYPE_CODE;
1484    G_PRICED_QUANTITY_TBL(l_line_index)        := px_req_line_tbl(l_line_index).PRICED_QUANTITY;
1485    G_UOM_QUANTITY_TBL(l_line_index)           := NULL;
1486    G_PRICED_UOM_CODE_TBL(l_line_index)        := px_req_line_tbl(l_line_index).PRICED_UOM_CODE;
1487    G_CURRENCY_CODE_TBL(l_line_index)          := px_req_line_tbl(l_line_index).CURRENCY_CODE;
1488     IF l_debug_level  > 0 THEN
1489         oe_debug_pub.add(  'UNIT PRICE'||PX_REQ_LINE_TBL(L_LINE_INDEX).UNIT_PRICE||' '||
1490 			   PX_REQ_LINE_TBL(L_LINE_INDEX).ADJUSTED_UNIT_PRICE ) ;
1491     END IF;
1492    G_UNIT_PRICE_TBL(l_line_index)             := px_req_line_tbl(l_line_index).unit_price;  -- AG
1493    G_PERCENT_PRICE_TBL(l_line_index)          := NULL;
1494    G_ADJUSTED_UNIT_PRICE_TBL(l_line_index)    := px_req_line_tbl(l_line_index).ADJUSTED_UNIT_PRICE;
1495    G_PROCESSED_FLAG_TBL(l_line_index)         := QP_PREQ_GRP.G_NOT_PROCESSED;
1496    G_PRICE_FLAG_TBL(l_line_index)             := px_req_line_tbl(l_line_index).PRICE_FLAG;
1497    G_LINE_ID_TBL(l_line_index)                := px_req_line_tbl(l_line_index).LINE_ID;
1498    IF l_debug_level  > 0 THEN
1499        oe_debug_pub.add(  'LINE ID IN G_LINE_ID_TBL:'|| G_LINE_ID_TBL ( L_LINE_INDEX ) ) ;
1500    END IF;
1501    G_ROUNDING_FLAG_TBL(l_line_index)          := NULL;  -- AG
1502    G_ROUNDING_FACTOR_TBL(l_line_index)        := px_req_line_tbl(l_line_index).ROUNDING_FACTOR;
1503    G_PROCESSING_ORDER_TBL(l_line_index)       := NULL;
1504    G_PRICING_STATUS_CODE_tbl(l_line_index)    := QP_PREQ_GRP.G_STATUS_UNCHANGED;  -- AG
1505    G_PRICING_STATUS_TEXT_tbl(l_line_index)    := NULL;
1506    G_QUALIFIERS_EXIST_FLAG_TBL(l_line_index)            :='N';
1507    G_PRICING_ATTRS_EXIST_FLAG_TBL(l_line_index)       :='N';
1508    G_PRICE_LIST_ID_TBL(l_line_index)                 :=g_panda_rec_table(1).p_price_list_id;
1509    G_PL_VALIDATED_FLAG_TBL(l_line_index)                := 'N';
1510    G_PRICE_REQUEST_CODE_TBL(l_line_index)        := NULL;
1511    G_USAGE_PRICING_TYPE_TBL(l_line_index)        :='REGULAR';
1512    G_UPD_ADJUSTED_UNIT_PRICE_TBL(l_line_index) :=NULL;
1513    G_LINE_CATEGORY_TBL(l_line_index) := NULL;
1514 
1515 
1516   IF l_debug_level  > 0 THEN
1517       oe_debug_pub.add(  'EXITING OE_OE_AVAILABILITY.COPY_LINE_TO_REQUEST' , 1 ) ;
1518   END IF;
1519 
1520 END copy_Line_to_request;
1521 
1522 
1523 
1524 PROCEDURE set_pricing_control_record (
1525 				      l_Control_Rec  in out nocopy  QP_PREQ_GRP.CONTROL_RECORD_TYPE
1526 				      ,in_pricing_event in varchar2)IS
1527 
1528    --
1529    l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1530    --
1531 BEGIN
1532 
1533    l_control_rec.pricing_event    := in_pricing_event;
1534    l_Control_Rec.calculate_flag   := QP_PREQ_GRP.G_SEARCH_N_CALCULATE;
1535    --l_control_rec.simulation_flag  := 'Y';
1536    l_control_rec.simulation_flag :='Y';
1537    l_control_rec.gsa_check_flag := 'Y';
1538    l_control_rec.gsa_dup_check_flag := 'Y';
1539    --newly added
1540    l_control_rec.temp_table_insert_flag := 'N';
1541    l_control_rec.request_type_code := 'ONT';
1542    l_control_rec.rounding_flag := 'Q';
1543    l_control_rec.use_multi_currency:='Y';
1544 
1545 END set_pricing_control_record;
1546 
1547 
1548 
1549 PROCEDURE build_context_for_line(
1550         p_req_line_tbl_count in number,
1551         p_price_request_code in varchar2,
1552         p_item_type_code in varchar2,
1553         p_Req_line_attr_tbl in out nocopy  QP_PREQ_GRP.LINE_ATTR_TBL_TYPE,
1554         p_Req_qual_tbl in out  nocopy  QP_PREQ_GRP.QUAL_TBL_TYPE,
1555 	p_line_index in number
1556        )IS
1557 
1558 qp_attr_mapping_error exception;
1559 --l_org_id Number:= OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');
1560 l_org_id Number := to_number( fnd_profile.value('ORG_ID'));
1561 l_master_org_id Number:= OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');
1562 p_pricing_contexts_Tbl	  QP_Attr_Mapping_PUB.Contexts_Result_Tbl_Type;
1563 p_qualifier_contexts_Tbl  QP_Attr_Mapping_PUB.Contexts_Result_Tbl_Type;
1564 
1565 --
1566 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1567 l_pass_line VARCHAR2(1) :='N';
1568 --
1569 BEGIN
1570 
1571   IF l_debug_level  > 0 THEN
1572       oe_debug_pub.add(  'BEFORE QP_ATTR_MAPPING_PUB.BUILD_CONTEXTS FOR LINE' , 1 ) ;
1573   END IF;
1574 
1575                   IF l_debug_level  > 0 THEN
1576                       oe_debug_pub.add(  'ORG_ID='||L_ORG_ID|| ' PRICING_DATE='||
1577 					 G_panda_rec_table(p_line_index).p_PRICING_DATE|| ' INV ITEM_IE='
1578                                         ||' master_org='||l_master_org_id
1579 					 ||G_panda_rec_table(p_line_index).p_INVENTORY_ITEM_ID);
1580                       oe_debug_pub.add( ' AGREEMENT_ID='||G_panda_rec_table(p_line_index).p_AGREEMENT_ID||
1581 					' REQ DATE='||G_panda_rec_table(p_line_index).p_REQUEST_DATE||
1582 					' SHIP_TO_ORG_ID='||G_panda_rec_table(p_line_index).p_SHIP_TO_ORG_ID||
1583 					' INVOICE_TO_ORG_ID='||G_panda_rec_table(p_line_index).p_INVOICE_TO_ORG_ID ) ;
1584                   END IF;
1585 
1586                  IF l_debug_level  > 0 THEN
1587                      oe_debug_pub.add(  'QTY='||G_panda_rec_table(p_line_index).p_QTY||
1588 					' ITEM_TYPE_CODE='||P_ITEM_TYPE_CODE||
1589 					' PRICE_LIST_ID='||G_panda_rec_table(p_line_index).p_PRICE_LIST_ID||
1590 					' CUST_ID='||G_panda_rec_table(p_line_index).p_CUSTOMER_ID||
1591 					' PRICE REQ CODE='||P_PRICE_REQUEST_CODE||
1592 					' UOM='||G_panda_rec_table(p_line_index).p_UOM ) ;
1593                  END IF;
1594 
1595   oe_order_pub.g_line.org_id             := l_org_id;
1596   oe_order_pub.g_line.pricing_date       := g_panda_rec_table(p_line_index).p_pricing_date;
1597   oe_order_pub.g_line.inventory_item_id  := g_panda_rec_table(p_line_index).p_inventory_item_id;
1598   oe_order_pub.g_line.agreement_id       := g_panda_rec_table(p_line_index).p_agreement_id;
1599   --oe_order_pub.g_line.ordered_date     := g_request_date;
1600   oe_order_pub.g_line.ship_to_org_id     := g_panda_rec_table(p_line_index).p_ship_to_org_id;
1601   oe_order_pub.g_line.invoice_to_org_id  := g_panda_rec_table(p_line_index).p_invoice_to_org_id;
1602   oe_order_pub.g_line.ordered_quantity   := g_panda_rec_table(p_line_index).p_qty;
1603   oe_order_pub.g_line.item_identifier_type := g_panda_rec_table(p_line_index).p_item_identifier_type; -- 3661905
1604   oe_order_pub.g_line.ordered_item_id    := g_panda_rec_table(p_line_index).p_ordered_item_id; -- 3661905
1605   oe_order_pub.g_line.line_id            := g_line_id;
1606   oe_order_pub.g_line.header_id          := g_header_id;
1607   oe_order_pub.g_line.item_type_code     := p_item_type_code;
1608   oe_order_pub.g_line.price_list_id      := g_panda_rec_table(p_line_index).p_price_list_id;
1609   oe_order_pub.g_line.sold_to_org_id     := g_panda_rec_table(p_line_index).p_customer_id;
1610   oe_order_pub.g_line.price_request_code := p_price_request_code;
1611   oe_order_pub.g_line.order_quantity_uom := g_panda_rec_table(p_line_index).p_uom;
1612 
1613 --Bug 6697648/6759791 --copy header level attribute, Index should be 1(for header) and NOT p_line_index
1614   oe_order_pub.g_hdr.order_type_id      := g_panda_rec_table(1).p_order_type_id;
1615 
1616   IF g_panda_rec_table(p_line_index).p_item_identifier_type ='INT' then
1617 
1618      SELECT concatenated_segments
1619        INTO  oe_order_pub.g_line.ordered_item
1620        FROM   mtl_system_items_kfv
1621        WHERE  inventory_item_id = g_panda_rec_table(p_line_index).p_inventory_item_id
1622        AND    organization_id = l_master_org_id;
1623 
1624   End IF;
1625 
1626   QP_Attr_Mapping_PUB.Build_Contexts(
1627      p_request_type_code => 'ONT',
1628      p_line_index =>2,
1629      p_pricing_type_code =>'L',
1630      p_check_line_flag => 'N',
1631      p_pricing_event =>'BATCH',
1632      x_pass_line =>l_pass_line);
1633 
1634 				--     x_price_contexts_result_tbl => p_pricing_contexts_Tbl,
1635 --     x_qual_contexts_result_tbl  => p_qualifier_Contexts_Tbl
1636   --   );
1637 
1638   /*copy_attribs_to_Req(
1639      p_line_index         => 	p_req_line_tbl_count
1640      ,px_Req_line_attr_tbl    =>p_Req_line_attr_tbl
1641      ,px_Req_qual_tbl         =>p_Req_qual_tbl
1642      ,p_pricing_contexts_tbl => p_pricing_contexts_Tbl
1643      ,p_qualifier_contexts_tbl  => p_qualifier_Contexts_Tbl
1644      );*/
1645   IF l_debug_level > 0 THEN
1646      oe_debug_pub.add('l_PASS_LINE'||l_pass_line);
1647      END IF;
1648 
1649   IF l_debug_level  > 0 THEN
1650       oe_debug_pub.add(  'EXIT QP_ATTR_MAPPING_PUB.BUILD_CONTEXTS FOR LINE' , 1 ) ;
1651   END IF;
1652 
1653 EXCEPTION
1654     when no_data_found then
1655       Null;
1656     when others then
1657       Raise QP_ATTR_MAPPING_ERROR;
1658 
1659 END build_context_for_line;
1660 
1661 
1662 
1663 PROCEDURE build_context_for_header(
1664         p_req_line_tbl_count in number,
1665         p_price_request_code in varchar2,
1666         p_item_type_code in varchar2,
1667         p_Req_line_attr_tbl in out nocopy  QP_PREQ_GRP.LINE_ATTR_TBL_TYPE,
1668         p_Req_qual_tbl in out  nocopy  QP_PREQ_GRP.QUAL_TBL_TYPE
1669        )IS
1670 
1671 qp_attr_mapping_error exception;
1672 --l_org_id Number:= OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');
1673 l_org_id Number := to_number( fnd_profile.value('ORG_ID'));
1674 p_pricing_contexts_Tbl	  QP_Attr_Mapping_PUB.Contexts_Result_Tbl_Type;
1675 p_qualifier_contexts_Tbl  QP_Attr_Mapping_PUB.Contexts_Result_Tbl_Type;
1676 
1677 --
1678 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1679 --
1680 BEGIN
1681 
1682   IF l_debug_level  > 0 THEN
1683       oe_debug_pub.add(  'BEFORE QP_ATTR_MAPPING_PUB.BUILD_CONTEXTS FOR HEADER' , 1 ) ;
1684   END IF;
1685 
1686 
1687                   IF l_debug_level  > 0 THEN
1688                       oe_debug_pub.add(  'ORG_ID='||L_ORG_ID|| ' PRICING_DATE='||
1689 					 G_panda_rec_table(1).p_PRICING_DATE|| ' AGREEMENT_ID='||
1690 					 G_panda_rec_table(1).p_AGREEMENT_ID|| ' REQ DATE='||
1691 					 G_panda_rec_table(1).p_REQUEST_DATE|| ' SHIP_TO_ORG_ID='||
1692 					 G_panda_rec_table(1).p_SHIP_TO_ORG_ID|| ' INVOICE_TO_ORG_ID='||
1693 					 G_panda_rec_table(1).p_INVOICE_TO_ORG_ID ) ;
1694                   END IF;
1695 
1696                  IF l_debug_level  > 0 THEN
1697                      oe_debug_pub.add(  'QTY='||G_panda_rec_table(1).p_QTY||
1698 					' PRICE_LIST_ID='||G_panda_rec_table(1).p_PRICE_LIST_ID||
1699 					' CUST_ID='||G_panda_rec_table(1).p_CUSTOMER_ID|| ' PRICE REQ CODE='||
1700 					P_PRICE_REQUEST_CODE ) ;
1701                  END IF;
1702 
1703   oe_order_pub.g_hdr.agreement_id       := g_panda_rec_table(1).p_agreement_id;
1704   oe_order_pub.g_hdr.invoice_to_org_id  := g_panda_rec_table(1).p_invoice_to_org_id;
1705   oe_order_pub.g_hdr.ordered_date       := g_panda_rec_table(1).p_request_date;
1706   oe_order_pub.g_hdr.header_id          := g_header_id;
1707   oe_order_pub.g_hdr.org_id             := l_org_id;
1708   oe_order_pub.g_hdr.price_list_id      := g_panda_rec_table(1).p_price_list_id;
1709   oe_order_pub.g_hdr.price_request_code := p_price_request_code;
1710   oe_order_pub.g_hdr.pricing_date       := g_panda_rec_table(1).p_pricing_date;
1711   oe_order_pub.g_hdr.request_date       := g_panda_rec_table(1).p_request_date;
1712   oe_order_pub.g_hdr.ship_to_org_id     := g_panda_rec_table(1).p_ship_to_org_id;
1713   oe_order_pub.g_hdr.sold_to_org_id     := g_panda_rec_table(1).p_customer_id;
1714   oe_order_pub.g_hdr.order_type_id      := g_panda_rec_table(1).p_order_type_id;
1715   oe_order_pub.g_hdr.ship_from_org_id   := g_panda_rec_table(1).p_ship_from_org_id;
1716   oe_order_pub.g_hdr.CONVERSION_TYPE_CODE :=g_panda_rec_table(1).p_conversion_type_code;  --added for bug 12541442
1717   oe_order_pub.g_hdr.CONVERSION_RATE      :=g_panda_rec_table(1).p_conversion_rate;       --added for bug 12541442
1718   --oe_order_pub.g_line.inventory_item_id  := p_inventory_item_id;
1719   --oe_order_pub.g_line.ordered_quantity   := p_ordered_quantity;
1720   --oe_order_pub.g_line.line_id            := g_line_id;
1721   --oe_order_pub.g_line.item_type_code     := p_item_type_code;
1722   --oe_order_pub.g_line.order_quantity_uom := p_uom;
1723 
1724 
1725   /*If p_item_identifier_type ='INT' then
1726 
1727      SELECT concatenated_segments
1728        INTO  oe_order_pub.g_line.ordered_item
1729        FROM   mtl_system_items_kfv
1730        WHERE  inventory_item_id = g_inventory_item_id
1731        AND    organization_id = l_org_id;
1732 
1733   End If;*/
1734 
1735   /*
1736   QP_Attr_Mapping_PUB.Build_Contexts(
1737      p_request_type_code => 'ONT',
1738      p_pricing_type	=>'H',
1739      x_price_contexts_result_tbl => p_pricing_contexts_Tbl,
1740      x_qual_contexts_result_tbl  => p_qualifier_Contexts_Tbl
1741      );*/
1742 
1743      QP_ATTR_Mapping_PUB.Build_Contexts(
1744           p_request_type_code =>'ONT',
1745           p_line_index =>1,
1746           p_pricing_type_code =>'H');
1747 
1748 
1749   /*
1750   copy_attribs_to_Req(
1751      p_line_index         => 	p_req_line_tbl_count
1752      ,px_Req_line_attr_tbl    =>p_Req_line_attr_tbl
1753      ,px_Req_qual_tbl         =>p_Req_qual_tbl
1754      ,p_pricing_contexts_tbl => p_pricing_contexts_Tbl
1755      ,p_qualifier_contexts_tbl  => p_qualifier_Contexts_Tbl
1756      );*/
1757 
1758   IF l_debug_level  > 0 THEN
1759       oe_debug_pub.add(  'EXIT QP_ATTR_MAPPING_PUB.BUILD_CONTEXTS FOR HEADER' , 1 ) ;
1760   END IF;
1761 
1762 EXCEPTION
1763     when no_data_found then
1764       Null;
1765     when others then
1766       Raise QP_ATTR_MAPPING_ERROR;
1767 
1768 END build_context_for_header;
1769 
1770 
1771 
1772 procedure  Append_attributes(
1773 			     p_header_id number default null
1774 			     ,p_Line_id number default null
1775 			     ,p_line_index number
1776 			     ,px_Req_line_attr_tbl in out nocopy  QP_PREQ_GRP.LINE_ATTR_TBL_TYPE
1777 			     ,px_Req_qual_tbl in out nocopy  QP_PREQ_GRP.QUAL_TBL_TYPE
1778 			     ,p_g_line_index in number
1779 
1780 			     ) is
1781 
1782    i	pls_integer;
1783 
1784    --
1785    l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1786 
1787       --
1788 BEGIN
1789 
1790    IF l_debug_level  > 0 THEN
1791       oe_debug_pub.add(  'ENTERING OE_OE_AVAILABILITY.APPEND_ATTRIBUTES' , 1 ) ;
1792    END IF;
1793 
1794    IF g_panda_rec_table(p_g_line_index).p_pricing_attribute1 is not null then
1795       i := px_Req_line_attr_tbl.count+1;
1796       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1797       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1798       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1799       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE1';
1800       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE1;
1801    END IF;
1802 
1803    IF g_panda_rec_table(p_g_line_index).p_pricing_attribute2 is not null then
1804       i := px_Req_line_attr_tbl.count+1;
1805       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1806       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1807       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1808       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE2';
1809       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE2;
1810    END IF;
1811 
1812    IF g_panda_rec_table(p_g_line_index).p_pricing_attribute3 is not null then
1813       i := px_Req_line_attr_tbl.count+1;
1814       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1815       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1816       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1817       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE3';
1818       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE3;
1819    END IF;
1820 
1821    IF g_panda_rec_table(p_g_line_index).p_pricing_attribute4 is not null then
1822       i := px_Req_line_attr_tbl.count+1;
1823       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1824       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1825       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1826       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE4';
1827       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE4;
1828    END IF;
1829 
1830    if g_panda_rec_table(p_g_line_index).p_pricing_attribute5 is not null then
1831       i := px_Req_line_attr_tbl.count+1;
1832       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1833       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1834       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1835       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE5';
1836       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE5;
1837    end if;
1838 
1839    if g_panda_rec_table(p_g_line_index).p_pricing_attribute6 is not null then
1840       i := px_Req_line_attr_tbl.count+1;
1841       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1842       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1843       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1844       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE6';
1845       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE6;
1846    end if;
1847 
1848    if g_panda_rec_table(p_g_line_index).p_pricing_attribute7 is not null then
1849       i := px_Req_line_attr_tbl.count+1;
1850       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1851       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1852       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1853       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE7';
1854       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE7;
1855    end if;
1856 
1857    if g_panda_rec_table(p_g_line_index).p_pricing_attribute8 is not null then
1858       i := px_Req_line_attr_tbl.count+1;
1859       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1860       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1861       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1862       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE8';
1863       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE8;
1864    end if;
1865 
1866    if g_panda_rec_table(p_g_line_index).p_pricing_attribute9 is not null then
1867       i := px_Req_line_attr_tbl.count+1;
1868       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1869       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1870       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1871       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE9';
1872       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE9;
1873    end if;
1874 
1875    if g_panda_rec_table(p_g_line_index).p_pricing_attribute10 is not null then
1876       i := px_Req_line_attr_tbl.count+1;
1877       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1878       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1879       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1880       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE10';
1881       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE10;
1882    end if;
1883 
1884    if g_panda_rec_table(p_g_line_index).p_pricing_attribute11 is not null then
1885       i := px_Req_line_attr_tbl.count+1;
1886       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1887       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1888       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1889       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE11';
1890       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE11;
1891    end if;
1892 
1893    if g_panda_rec_table(p_g_line_index).p_pricing_attribute12 is not null then
1894       i := px_Req_line_attr_tbl.count+1;
1895       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1896       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1897       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1898       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE12';
1899       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE12;
1900    end if;
1901 
1902    if g_panda_rec_table(p_g_line_index).p_pricing_attribute13 is not null then
1903       i := px_Req_line_attr_tbl.count+1;
1904       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1905       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1906       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1907       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE13';
1908       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE13;
1909    end if;
1910 
1911    if g_panda_rec_table(p_g_line_index).p_pricing_attribute14 is not null then
1912       i := px_Req_line_attr_tbl.count+1;
1913       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1914       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1915       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1916       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE14';
1917       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE14;
1918    end if;
1919 
1920    if g_panda_rec_table(p_g_line_index).p_pricing_attribute15 is not null then
1921       i := px_Req_line_attr_tbl.count+1;
1922       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1923       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1924       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1925       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE15';
1926       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE15;
1927    end if;
1928 
1929    if g_panda_rec_table(p_g_line_index).p_pricing_attribute16 is not null then
1930       i := px_Req_line_attr_tbl.count+1;
1931       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1932       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1933       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1934       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE16';
1935       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE16;
1936    end if;
1937 
1938    if g_panda_rec_table(p_g_line_index).p_pricing_attribute17 is not null then
1939       i := px_Req_line_attr_tbl.count+1;
1940       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1941       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1942       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1943       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE17';
1944       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE17;
1945    end if;
1946 
1947    if g_panda_rec_table(p_g_line_index).p_pricing_attribute18 is not null then
1948       i := px_Req_line_attr_tbl.count+1;
1949       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1950       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1951       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1952       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE18';
1953       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE18;
1954    end if;
1955 
1956    if g_panda_rec_table(p_g_line_index).p_pricing_attribute19 is not null then
1957       i := px_Req_line_attr_tbl.count+1;
1958       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1959       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1960       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1961       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE19';
1962       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE19;
1963    end if;
1964 
1965    if g_panda_rec_table(p_g_line_index).p_pricing_attribute20 is not null then
1966       i := px_Req_line_attr_tbl.count+1;
1967       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1968       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1969       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1970       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE20';
1971       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE20;
1972    end if;
1973 
1974    if g_panda_rec_table(p_g_line_index).p_pricing_attribute21 is not null then
1975       i := px_Req_line_attr_tbl.count+1;
1976       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1977       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1978       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1979       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE21';
1980       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE21;
1981    end if;
1982 
1983    if g_panda_rec_table(p_g_line_index).p_pricing_attribute22 is not null then
1984       i := px_Req_line_attr_tbl.count+1;
1985       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1986       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1987       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1988       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE22';
1989       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE22;
1990    end if;
1991 
1992    if g_panda_rec_table(p_g_line_index).p_pricing_attribute23 is not null then
1993       i := px_Req_line_attr_tbl.count+1;
1994       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
1995       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
1996       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
1997       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE23';
1998       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE23;
1999    end if;
2000 
2001    if g_panda_rec_table(p_g_line_index).p_pricing_attribute24 is not null then
2002       i := px_Req_line_attr_tbl.count+1;
2003       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2004       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2005       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2006       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE24';
2007       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE24;
2008    end if;
2009 
2010    if g_panda_rec_table(p_g_line_index).p_pricing_attribute25 is not null then
2011       i := px_Req_line_attr_tbl.count+1;
2012       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2013       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2014       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2015       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE25';
2016       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE25;
2017    end if;
2018 
2019    if g_panda_rec_table(p_g_line_index).p_pricing_attribute26 is not null then
2020       i := px_Req_line_attr_tbl.count+1;
2021       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2022       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2023       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2024       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE26';
2025       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE26;
2026    end if;
2027 
2028    if g_panda_rec_table(p_g_line_index).p_pricing_attribute27 is not null then
2029       i := px_Req_line_attr_tbl.count+1;
2030       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2031       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2032       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2033       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE27';
2034       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE27;
2035    end if;
2036 
2037    if g_panda_rec_table(p_g_line_index).p_pricing_attribute28 is not null then
2038       i := px_Req_line_attr_tbl.count+1;
2039       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2040       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2041       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2042       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE28';
2043       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE28;
2044    end if;
2045 
2046    if g_panda_rec_table(p_g_line_index).p_pricing_attribute29 is not null then
2047       i := px_Req_line_attr_tbl.count+1;
2048       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2049       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2050       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2051       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE29';
2052       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_PRICING_ATTRIBUTE29;
2053    end if;
2054 
2055    if g_panda_rec_table(p_g_line_index).p_pricing_attribute30 is not null then
2056       i := px_Req_line_attr_tbl.count+1;
2057       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2058       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2059       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2060       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE30';
2061       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute30;
2062    end if;
2063 
2064    if g_panda_rec_table(p_g_line_index).p_pricing_attribute31 is not null then
2065       i := px_Req_line_attr_tbl.count+1;
2066       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2067       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2068       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2069       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE31';
2070       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute31;
2071    end if;
2072 
2073    if g_panda_rec_table(p_g_line_index).p_pricing_attribute32 is not null then
2074       i := px_Req_line_attr_tbl.count+1;
2075       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2076       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2077       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2078       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE32';
2079       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute32;
2080    end if;
2081 
2082    if g_panda_rec_table(p_g_line_index).p_pricing_attribute33 is not null then
2083       i := px_Req_line_attr_tbl.count+1;
2084       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2085       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2086       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2087       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE33';
2088       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute33;
2089    end if;
2090 
2091    if g_panda_rec_table(p_g_line_index).p_pricing_attribute34 is not null then
2092       i := px_Req_line_attr_tbl.count+1;
2093       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2094       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2095       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2096       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE34';
2097       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute34;
2098    end if;
2099 
2100    if g_panda_rec_table(p_g_line_index).p_pricing_attribute35 is not null then
2101       i := px_Req_line_attr_tbl.count+1;
2102       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2103       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2104       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2105       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE35';
2106       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute35;
2107    end if;
2108 
2109    if g_panda_rec_table(p_g_line_index).p_pricing_attribute36 is not null then
2110       i := px_Req_line_attr_tbl.count+1;
2111       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2112       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2113       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2114       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE36';
2115       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute36;
2116    end if;
2117 
2118    if g_panda_rec_table(p_g_line_index).p_pricing_attribute37 is not null then
2119       i := px_Req_line_attr_tbl.count+1;
2120       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2121       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2122       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2123       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE37';
2124       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute37;
2125    end if;
2126 
2127    if g_panda_rec_table(p_g_line_index).p_pricing_attribute38 is not null then
2128       i := px_Req_line_attr_tbl.count+1;
2129       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2130       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2131       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2132       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE38';
2133       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute38;
2134    end if;
2135 
2136    if g_panda_rec_table(p_g_line_index).p_pricing_attribute39 is not null then
2137       i := px_Req_line_attr_tbl.count+1;
2138       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2139       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2140       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2141       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE39';
2142       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute39;
2143    end if;
2144 
2145    if g_panda_rec_table(p_g_line_index).p_pricing_attribute40 is not null then
2146       i := px_Req_line_attr_tbl.count+1;
2147       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2148       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2149       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2150       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE40';
2151       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute40;
2152    end if;
2153 
2154    if g_panda_rec_table(p_g_line_index).p_pricing_attribute41 is not null then
2155       i := px_Req_line_attr_tbl.count+1;
2156       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2157       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2158       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2159       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE41';
2160       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute41;
2161    end if;
2162 
2163    if g_panda_rec_table(p_g_line_index).p_pricing_attribute42 is not null then
2164       i := px_Req_line_attr_tbl.count+1;
2165       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2166       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2167       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2168       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE42';
2169       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute42;
2170    end if;
2171 
2172    if g_panda_rec_table(p_g_line_index).p_pricing_attribute43 is not null then
2173       i := px_Req_line_attr_tbl.count+1;
2174       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2175       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2176       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2177       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE43';
2178       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute43;
2179    end if;
2180 
2181    if g_panda_rec_table(p_g_line_index).p_pricing_attribute44 is not null then
2182       i := px_Req_line_attr_tbl.count+1;
2183       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2184       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2185       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2186       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE44';
2187       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute44;
2188    end if;
2189 
2190    if g_panda_rec_table(p_g_line_index).p_pricing_attribute45 is not null then
2191       i := px_Req_line_attr_tbl.count+1;
2192       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2193       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2194       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2195       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE45';
2196       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute45;
2197    end if;
2198 
2199    if g_panda_rec_table(p_g_line_index).p_pricing_attribute46 is not null then
2200       i := px_Req_line_attr_tbl.count+1;
2201       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2202       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2203       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2204       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE46';
2205       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute46;
2206    end if;
2207 
2208    if g_panda_rec_table(p_g_line_index).p_pricing_attribute47 is not null then
2209       i := px_Req_line_attr_tbl.count+1;
2210       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2211       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2212       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2213       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE47';
2214       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute47;
2215    end if;
2216 
2217    if g_panda_rec_table(p_g_line_index).p_pricing_attribute48 is not null then
2218       i := px_Req_line_attr_tbl.count+1;
2219       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2220       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2221       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2222       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE48';
2223       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute48;
2224    end if;
2225 
2226    if g_panda_rec_table(p_g_line_index).p_pricing_attribute49 is not null then
2227       i := px_Req_line_attr_tbl.count+1;
2228       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2229       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2230       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2231       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE49';
2232       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute49;
2233    end if;
2234 
2235 
2236    if g_panda_rec_table(p_g_line_index).p_pricing_attribute50 is not null then
2237       i := px_Req_line_attr_tbl.count+1;
2238       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2239       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2240       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2241       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE20';
2242       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute20;
2243    end if;
2244 
2245    if g_panda_rec_table(p_g_line_index).p_pricing_attribute51 is not null then
2246       i := px_Req_line_attr_tbl.count+1;
2247       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2248       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2249       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2250       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE51';
2251       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute51;
2252    end if;
2253 
2254    if g_panda_rec_table(p_g_line_index).p_pricing_attribute52 is not null then
2255       i := px_Req_line_attr_tbl.count+1;
2256       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2257       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2258       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2259       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE52';
2260       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute52;
2261    end if;
2262 
2263    if g_panda_rec_table(p_g_line_index).p_pricing_attribute53 is not null then
2264       i := px_Req_line_attr_tbl.count+1;
2265       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2266       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2267       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2268       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE53';
2269       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute53;
2270    end if;
2271 
2272    if g_panda_rec_table(p_g_line_index).p_pricing_attribute54 is not null then
2273       i := px_Req_line_attr_tbl.count+1;
2274       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2275       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2276       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2277       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE54';
2278       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute54;
2279    end if;
2280 
2281    if g_panda_rec_table(p_g_line_index).p_pricing_attribute55 is not null then
2282       i := px_Req_line_attr_tbl.count+1;
2283       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2284       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2285       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2286       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE55';
2287       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute55;
2288    end if;
2289 
2290    if g_panda_rec_table(p_g_line_index).p_pricing_attribute56 is not null then
2291       i := px_Req_line_attr_tbl.count+1;
2292       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2293       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2294       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2295       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE56';
2296       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute56;
2297    end if;
2298 
2299    if g_panda_rec_table(p_g_line_index).p_pricing_attribute57 is not null then
2300       i := px_Req_line_attr_tbl.count+1;
2301       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2302       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2303       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2304       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE57';
2305       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute57;
2306    end if;
2307 
2308    if g_panda_rec_table(p_g_line_index).p_pricing_attribute58 is not null then
2309       i := px_Req_line_attr_tbl.count+1;
2310       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2311       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2312       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2313       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE58';
2314       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute58;
2315    end if;
2316 
2317    if g_panda_rec_table(p_g_line_index).p_pricing_attribute59 is not null then
2318       i := px_Req_line_attr_tbl.count+1;
2319       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2320       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2321       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2322       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE59';
2323       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute59;
2324    end if;
2325 
2326 
2327    if g_panda_rec_table(p_g_line_index).p_pricing_attribute60 is not null then
2328       i := px_Req_line_attr_tbl.count+1;
2329       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2330       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2331       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2332       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE60';
2333       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute60;
2334    end if;
2335 
2336    if g_panda_rec_table(p_g_line_index).p_pricing_attribute61 is not null then
2337       i := px_Req_line_attr_tbl.count+1;
2338       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2339       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2340       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2341       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE61';
2342       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute61;
2343    end if;
2344 
2345    if g_panda_rec_table(p_g_line_index).p_pricing_attribute62 is not null then
2346       i := px_Req_line_attr_tbl.count+1;
2347       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2348       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2349       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2350       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE62';
2351       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute62;
2352    end if;
2353 
2354    if g_panda_rec_table(p_g_line_index).p_pricing_attribute63 is not null then
2355       i := px_Req_line_attr_tbl.count+1;
2356       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2357       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2358       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2359       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE63';
2360       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute63;
2361    end if;
2362 
2363    if g_panda_rec_table(p_g_line_index).p_pricing_attribute64 is not null then
2364       i := px_Req_line_attr_tbl.count+1;
2365       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2366       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2367       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2368       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE64';
2369       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute64;
2370    end if;
2371 
2372    if g_panda_rec_table(p_g_line_index).p_pricing_attribute65 is not null then
2373       i := px_Req_line_attr_tbl.count+1;
2374       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2375       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2376       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2377       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE65';
2378       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute65;
2379    end if;
2380 
2381    if g_panda_rec_table(p_g_line_index).p_pricing_attribute66 is not null then
2382       i := px_Req_line_attr_tbl.count+1;
2383       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2384       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2385       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2386       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE66';
2387       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute66;
2388    end if;
2389 
2390    if g_panda_rec_table(p_g_line_index).p_pricing_attribute67 is not null then
2391       i := px_Req_line_attr_tbl.count+1;
2392       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2393       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2394       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2395       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE67';
2396       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute67;
2397    end if;
2398 
2399    if g_panda_rec_table(p_g_line_index).p_pricing_attribute68 is not null then
2400       i := px_Req_line_attr_tbl.count+1;
2401       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2402       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2403       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2404       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE68';
2405       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute68;
2406    end if;
2407 
2408    if g_panda_rec_table(p_g_line_index).p_pricing_attribute69 is not null then
2409       i := px_Req_line_attr_tbl.count+1;
2410       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2411       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2412       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2413       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE69';
2414       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute69;
2415    end if;
2416 
2417 
2418    if g_panda_rec_table(p_g_line_index).p_pricing_attribute70 is not null then
2419       i := px_Req_line_attr_tbl.count+1;
2420       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2421       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2422       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2423       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE70';
2424       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute70;
2425    end if;
2426 
2427    if g_panda_rec_table(p_g_line_index).p_pricing_attribute71 is not null then
2428       i := px_Req_line_attr_tbl.count+1;
2429       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2430       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2431       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2432       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE71';
2433       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute71;
2434    end if;
2435 
2436    if g_panda_rec_table(p_g_line_index).p_pricing_attribute72 is not null then
2437       i := px_Req_line_attr_tbl.count+1;
2438       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2439       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2440       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2441       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE72';
2442       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute72;
2443    end if;
2444 
2445    if g_panda_rec_table(p_g_line_index).p_pricing_attribute73 is not null then
2446       i := px_Req_line_attr_tbl.count+1;
2447       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2448       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2449       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2450       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE73';
2451       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute73;
2452    end if;
2453 
2454    if g_panda_rec_table(p_g_line_index).p_pricing_attribute74 is not null then
2455       i := px_Req_line_attr_tbl.count+1;
2456       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2457       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2458       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2459       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE74';
2460       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute74;
2461    end if;
2462 
2463    if g_panda_rec_table(p_g_line_index).p_pricing_attribute75 is not null then
2464       i := px_Req_line_attr_tbl.count+1;
2465       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2466       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2467       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2468       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE75';
2469       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute75;
2470    end if;
2471 
2472    if g_panda_rec_table(p_g_line_index).p_pricing_attribute76 is not null then
2473       i := px_Req_line_attr_tbl.count+1;
2474       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2475       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2476       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2477       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE76';
2478       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute76;
2479    end if;
2480 
2481    if g_panda_rec_table(p_g_line_index).p_pricing_attribute77 is not null then
2482       i := px_Req_line_attr_tbl.count+1;
2483       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2484       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2485       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2486       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE77';
2487       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute77;
2488    end if;
2489 
2490    if g_panda_rec_table(p_g_line_index).p_pricing_attribute78 is not null then
2491       i := px_Req_line_attr_tbl.count+1;
2492       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2493       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2494       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2495       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE78';
2496       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute27;
2497    end if;
2498 
2499    if g_panda_rec_table(p_g_line_index).p_pricing_attribute79 is not null then
2500       i := px_Req_line_attr_tbl.count+1;
2501       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2502       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2503       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2504       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE79';
2505       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute27;
2506    end if;
2507 
2508 
2509    if g_panda_rec_table(p_g_line_index).p_pricing_attribute80 is not null then
2510       i := px_Req_line_attr_tbl.count+1;
2511       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2512       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2513       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2514       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE80';
2515       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute80;
2516    end if;
2517 
2518    if g_panda_rec_table(p_g_line_index).p_pricing_attribute81 is not null then
2519       i := px_Req_line_attr_tbl.count+1;
2520       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2521       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2522       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2523       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE81';
2524       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute81;
2525    end if;
2526 
2527    if g_panda_rec_table(p_g_line_index).p_pricing_attribute82 is not null then
2528       i := px_Req_line_attr_tbl.count+1;
2529       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2530       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2531       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2532       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE82';
2533       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute82;
2534    end if;
2535 
2536    if g_panda_rec_table(p_g_line_index).p_pricing_attribute83 is not null then
2537       i := px_Req_line_attr_tbl.count+1;
2538       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2539       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2540       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2541       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE83';
2542       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute83;
2543    end if;
2544 
2545    if g_panda_rec_table(p_g_line_index).p_pricing_attribute84 is not null then
2546       i := px_Req_line_attr_tbl.count+1;
2547       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2548       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2549       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2550       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE84';
2551       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute84;
2552    end if;
2553 
2554    if g_panda_rec_table(p_g_line_index).p_pricing_attribute85 is not null then
2555       i := px_Req_line_attr_tbl.count+1;
2556       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2557       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2558       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2559       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE85';
2560       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute85;
2561    end if;
2562 
2563    if g_panda_rec_table(p_g_line_index).p_pricing_attribute86 is not null then
2564       i := px_Req_line_attr_tbl.count+1;
2565       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2566       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2567       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2568       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE86';
2569       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute86;
2570    end if;
2571 
2572    if g_panda_rec_table(p_g_line_index).p_pricing_attribute87 is not null then
2573       i := px_Req_line_attr_tbl.count+1;
2574       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2575       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2576       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2577       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE87';
2578       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute87;
2579    end if;
2580 
2581    if g_panda_rec_table(p_g_line_index).p_pricing_attribute88 is not null then
2582       i := px_Req_line_attr_tbl.count+1;
2583       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2584       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2585       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2586       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE88';
2587       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute88;
2588    end if;
2589 
2590    if g_panda_rec_table(p_g_line_index).p_pricing_attribute89 is not null then
2591       i := px_Req_line_attr_tbl.count+1;
2592       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2593       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2594       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2595       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE89';
2596       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute89;
2597    end if;
2598 
2599 
2600    if g_panda_rec_table(p_g_line_index).p_pricing_attribute90 is not null then
2601       i := px_Req_line_attr_tbl.count+1;
2602       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2603       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2604       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2605       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE90';
2606       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute90;
2607    end if;
2608 
2609    if g_panda_rec_table(p_g_line_index).p_pricing_attribute91 is not null then
2610       i := px_Req_line_attr_tbl.count+1;
2611       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2612       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2613       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2614       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE91';
2615       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute91;
2616    end if;
2617 
2618    if g_panda_rec_table(p_g_line_index).p_pricing_attribute92 is not null then
2619       i := px_Req_line_attr_tbl.count+1;
2620       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2621       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2622       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2623       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE92';
2624       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute92;
2625    end if;
2626 
2627    if g_panda_rec_table(p_g_line_index).p_pricing_attribute93 is not null then
2628       i := px_Req_line_attr_tbl.count+1;
2629       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2630       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2631       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2632       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE93';
2633       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From :=g_panda_rec_table(p_g_line_index).p_pricing_attribute93;
2634    end if;
2635 
2636    if g_panda_rec_table(p_g_line_index).p_pricing_attribute94 is not null then
2637       i := px_Req_line_attr_tbl.count+1;
2638       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2639       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2640       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2641       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE94';
2642       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute94;
2643    end if;
2644 
2645    if g_panda_rec_table(p_g_line_index).p_pricing_attribute95 is not null then
2646       i := px_Req_line_attr_tbl.count+1;
2647       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2648       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2649       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2650       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE95';
2651       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute95;
2652    end if;
2653 
2654    if g_panda_rec_table(p_g_line_index).p_pricing_attribute96 is not null then
2655       i := px_Req_line_attr_tbl.count+1;
2656       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2657       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2658       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2659       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE96';
2660       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute96;
2661    end if;
2662 
2663    if g_panda_rec_table(p_g_line_index).p_pricing_attribute97 is not null then
2664       i := px_Req_line_attr_tbl.count+1;
2665       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2666       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2667       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2668       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE97';
2669       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute97;
2670    end if;
2671 
2672    if g_panda_rec_table(p_g_line_index).p_pricing_attribute98 is not null then
2673       i := px_Req_line_attr_tbl.count+1;
2674       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2675       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2676       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2677       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE98';
2678       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute98;
2679    end if;
2680 
2681    if g_panda_rec_table(p_g_line_index).p_pricing_attribute99 is not null then
2682       i := px_Req_line_attr_tbl.count+1;
2683       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2684       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2685       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2686       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE99';
2687       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From := g_panda_rec_table(p_g_line_index).p_pricing_attribute99;
2688    end if;
2689 
2690    if g_panda_rec_table(p_g_line_index).p_pricing_attribute100 is not null then
2691       i := px_Req_line_attr_tbl.count+1;
2692       px_Req_line_attr_tbl(i).Line_Index := p_Line_Index;
2693       px_Req_line_attr_tbl(i).Validated_Flag := 'N';
2694       px_Req_line_attr_tbl(i).pricing_context := g_panda_rec_table(p_g_line_index).p_pricing_context;
2695       px_Req_line_attr_tbl(i).Pricing_Attribute := 'PRICING_ATTRIBUTE100';
2696       px_Req_line_attr_tbl(i).Pricing_Attr_Value_From:=g_panda_rec_table(p_g_line_index).p_pricing_attribute100;
2697    end if;
2698 
2699    IF l_debug_level  > 0 THEN
2700       oe_debug_pub.add(  'EXITING OE_OE_AVAILABILITY.APPEND_ATTRIBUTES' , 1 ) ;
2701    END IF;
2702 
2703 END Append_attributes;
2704 
2705 PROCEDURE Append_attr_to_ttables(px_req_line_attr_tbl in out nocopy QP_PREQ_GRP.LINE_ATTR_TBL_TYPE
2706 				 )
2707 IS
2708    i number;
2709    k number;
2710    l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2711    l_attribute_type VARCHAR2(30);
2712 BEGIN
2713    --Temp Tables
2714    k:=G_ATTR_PRICING_ATTRIBUTE_TBL.count;
2715    i := px_req_line_attr_tbl.first;
2716    if l_debug_level >0 then
2717       oe_debug_pub.add('****populating attributes in to temp table **********');
2718    end if;
2719 
2720    if l_debug_level > 0 then
2721 
2722       oe_debug_pub.add('k='||k||'i='||i);
2723    end if;
2724 
2725    while i is not null  loop
2726       k:=k+1;
2727       IF l_debug_level  > 0 THEN
2728 	 oe_debug_pub.add(  'POPULATE LINE ATTRS'||K||' '||PX_REQ_LINE_ATTR_TBL ( I ) .PRICING_CONTEXT , 3 ) ;
2729       END IF;
2730 
2731       IF (px_req_line_attr_tbl(I).PRICING_CONTEXT = QP_PREQ_GRP.G_ITEM_CONTEXT) THEN
2732 	 l_attribute_type := QP_PREQ_GRP.G_PRODUCT_TYPE;
2733       ELSIF (px_req_line_attr_tbl(I).PRICING_CONTEXT = 'MODLIST') THEN
2734 	 l_attribute_type := QP_PREQ_GRP.G_QUALIFIER_TYPE;
2735       ELSE
2736 	 l_attribute_type := QP_PREQ_GRP.G_PRICING_TYPE;
2737       END IF;
2738       G_ATTR_LINE_INDEX_tbl(k) := px_req_line_attr_tbl(i).line_index;
2739       IF l_debug_level  > 0 THEN
2740 	 oe_debug_pub.add(  'LINE_INDEX:'||G_ATTR_LINE_INDEX_TBL ( K ) ) ;
2741       END IF;
2742       G_ATTR_LINE_DETAIL_INDEX_tbl(k) := NULL;
2743       G_ATTR_ATTRIBUTE_LEVEL_tbl(k) := QP_PREQ_GRP.G_LINE_LEVEL;
2744       G_ATTR_VALIDATED_FLAG_tbl(k) := 'N';
2745       G_ATTR_ATTRIBUTE_TYPE_tbl(k) := l_attribute_type;
2746       G_ATTR_PRICING_CONTEXT_tbl(k)
2747 	 := px_req_line_attr_tbl(i).pricing_context;
2748       G_ATTR_PRICING_ATTRIBUTE_tbl(k)
2749 	 := px_req_line_attr_tbl(i).pricing_attribute;
2750       G_ATTR_APPLIED_FLAG_tbl(k) := QP_PREQ_GRP.G_LIST_NOT_APPLIED;--NULL;
2751 	 G_ATTR_PRICING_STATUS_CODE_tbl(k) := QP_PREQ_GRP.G_STATUS_UNCHANGED;
2752       G_ATTR_PRICING_ATTR_FLAG_tbl (k) := QP_PREQ_GRP.G_YES;--NULL;
2753 	 G_ATTR_LIST_HEADER_ID_tbl(k) := NULL;
2754       G_ATTR_LIST_LINE_ID_tbl(k) := NULL;
2755       G_ATTR_VALUE_FROM_tbl(k)      :=px_req_line_attr_tbl(i).pricing_attr_value_from;
2756       G_ATTR_SETUP_VALUE_FROM_tbl(k):=NULL;
2757       G_ATTR_VALUE_TO_tbl(k)      :=NULL;
2758       G_ATTR_SETUP_VALUE_TO_tbl(k) := NULL;
2759       G_ATTR_GROUPING_NUMBER_tbl(k) := NULL;
2760       G_ATTR_NO_QUAL_IN_GRP_tbl(k)     :=NULL;
2761       G_ATTR_COMP_OPERATOR_TYPE_tbl(k):= NULL;
2762       G_ATTR_PRICING_STATUS_TEXT_tbl(k) :=NULL;
2763       G_ATTR_QUAL_PRECEDENCE_tbl(k):=NULL;
2764       G_ATTR_DATATYPE_tbl(k)          := NULL;
2765       G_ATTR_QUALIFIER_TYPE_tbl(k)   := NULL;
2766       G_ATTR_PRODUCT_UOM_CODE_TBL(k) := NULL;
2767       G_ATTR_EXCLUDER_FLAG_TBL(k) := NULL;
2768       G_ATTR_PRICING_PHASE_ID_TBL(k) := NULL;
2769       G_ATTR_INCOM_GRP_CODE_TBL(k):=NULL;
2770       G_ATTR_LDET_TYPE_CODE_TBL(k):=NULL;
2771       G_ATTR_MODIFIER_LEVEL_CODE_TBL(k):=NULL;
2772       G_ATTR_PRIMARY_UOM_FLAG_TBL(k):=NULL;
2773       i:= px_req_line_attr_tbl.next(i);
2774     END LOOP;
2775 
2776 
2777   --G_ATTR_LINE_INDEX_tbl(G_ATTR_LINE_INDEX_tbl.count+1):=2;
2778   --G_ATTR_ATTRIBUTE_LEVEL_tbl(G_ATTR_LINE_INDEX_tbl.count):=QP_PREQ_GRP.G_LINE_LEVEL;
2779 
2780    --Temp_tables population ends
2781 
2782 end append_attr_to_TTables;
2783 
2784 PROCEDURE Reset_All_Tbls
2785 AS
2786 
2787 
2788 l_routine VARCHAR2(240):='QP_PREQ_GRP.Reset_All_Tbls';
2789 --
2790 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2791 --
2792 BEGIN
2793  G_LINE_INDEX_tbl.delete;
2794  G_LINE_TYPE_CODE_TBL.delete          ;
2795  G_PRICING_EFFECTIVE_DATE_TBL.delete  ;
2796  G_ACTIVE_DATE_FIRST_TBL.delete       ;
2797  G_ACTIVE_DATE_FIRST_TYPE_TBL.delete  ;
2798  G_ACTIVE_DATE_SECOND_TBL.delete      ;
2799  G_ACTIVE_DATE_SECOND_TYPE_TBL.delete ;
2800  G_LINE_QUANTITY_TBL.delete           ;
2801  G_LINE_UOM_CODE_TBL.delete           ;
2802  G_REQUEST_TYPE_CODE_TBL.delete       ;
2803  G_PRICED_QUANTITY_TBL.delete         ;
2804  G_UOM_QUANTITY_TBL.delete         ;
2805  G_PRICED_UOM_CODE_TBL.delete         ;
2806  G_CURRENCY_CODE_TBL.delete           ;
2807  G_UNIT_PRICE_TBL.delete              ;
2808  G_PERCENT_PRICE_TBL.delete           ;
2809  G_ADJUSTED_UNIT_PRICE_TBL.delete     ;
2810  G_PROCESSED_FLAG_TBL.delete          ;
2811  G_PRICE_FLAG_TBL.delete              ;
2812  G_LINE_ID_TBL.delete                 ;
2813  G_PROCESSING_ORDER_TBL.delete        ;
2814  G_ROUNDING_FLAG_TBL.delete;
2815  G_ROUNDING_FACTOR_TBL.delete              ;
2816  G_PRICING_STATUS_CODE_TBL.delete       ;
2817  G_PRICING_STATUS_TEXT_TBL.delete       ;
2818  G_ATTR_LINE_INDEX_tbl.delete;
2819  G_ATTR_ATTRIBUTE_LEVEL_tbl.delete;
2820  G_ATTR_VALIDATED_FLAG_tbl.delete;
2821  G_ATTR_ATTRIBUTE_TYPE_tbl.delete;
2822  G_ATTR_PRICING_CONTEXT_tbl.delete;
2823  G_ATTR_PRICING_ATTRIBUTE_tbl.delete;
2824  G_ATTR_APPLIED_FLAG_tbl.delete;
2825  G_ATTR_PRICING_STATUS_CODE_tbl.delete;
2826  G_ATTR_PRICING_ATTR_FLAG_tbl.delete;
2827  G_ATTR_LIST_HEADER_ID_tbl.delete;
2828  G_ATTR_LIST_LINE_ID_tbl.delete;
2829  G_ATTR_VALUE_FROM_tbl.delete;
2830  G_ATTR_SETUP_VALUE_FROM_tbl.delete;
2831  G_ATTR_VALUE_TO_tbl.delete;
2832  G_ATTR_SETUP_VALUE_TO_tbl.delete;
2833  G_ATTR_GROUPING_NUMBER_tbl.delete;
2834  G_ATTR_NO_QUAL_IN_GRP_tbl.delete;
2835  G_ATTR_COMP_OPERATOR_TYPE_tbl.delete;
2836  G_ATTR_VALIDATED_FLAG_tbl.delete;
2837  G_ATTR_APPLIED_FLAG_tbl.delete;
2838  G_ATTR_PRICING_STATUS_CODE_tbl.delete;
2839  G_ATTR_PRICING_STATUS_TEXT_tbl.delete;
2840  G_ATTR_QUAL_PRECEDENCE_tbl.delete;
2841  G_ATTR_DATATYPE_tbl.delete;
2842  G_ATTR_PRICING_ATTR_FLAG_tbl.delete    ;
2843  G_ATTR_QUALIFIER_TYPE_tbl.delete;
2844  G_ATTR_PRODUCT_UOM_CODE_TBL.delete;
2845  G_ATTR_EXCLUDER_FLAG_TBL.delete;
2846  G_ATTR_PRICING_PHASE_ID_TBL.delete;
2847  G_ATTR_INCOM_GRP_CODE_TBL.delete;
2848  G_ATTR_LDET_TYPE_CODE_TBL.delete;
2849  G_ATTR_MODIFIER_LEVEL_CODE_TBL.delete;
2850  G_ATTR_PRIMARY_UOM_FLAG_TBL.delete;
2851 EXCEPTION
2852 WHEN OTHERS THEN
2853 IF l_debug_level  > 0 THEN
2854     oe_debug_pub.add(  L_ROUTINE||': '||SQLERRM , 1 ) ;
2855 END IF;
2856 END reset_all_tbls;
2857 
2858 
2859 procedure Populate_Temp_Table
2860 IS
2861    l_return_status  varchar2(1) := FND_API.G_RET_STS_SUCCESS;
2862    l_return_status_Text     varchar2(240) ;
2863    --
2864    l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2865    --
2866 BEGIN
2867    IF l_debug_level  > 0 THEN
2868       oe_debug_pub.add(  'BEFORE DIRECT INSERT INTO TEMP TABLE: BULK INSERT'||G_LINE_INDEX_TBL.COUNT , 1 ) ;
2869    END IF;
2870    QP_PREQ_GRP.INSERT_LINES2
2871       (p_LINE_INDEX =>   G_LINE_INDEX_TBL,
2872        p_LINE_TYPE_CODE =>  G_LINE_TYPE_CODE_TBL,
2873        p_PRICING_EFFECTIVE_DATE =>G_PRICING_EFFECTIVE_DATE_TBL,
2874        p_ACTIVE_DATE_FIRST       =>G_ACTIVE_DATE_FIRST_TBL,
2875        p_ACTIVE_DATE_FIRST_TYPE  =>G_ACTIVE_DATE_FIRST_TYPE_TBL,
2876        p_ACTIVE_DATE_SECOND      =>G_ACTIVE_DATE_SECOND_TBL,
2877        p_ACTIVE_DATE_SECOND_TYPE =>G_ACTIVE_DATE_SECOND_TYPE_TBL,
2878        p_LINE_QUANTITY =>     G_LINE_QUANTITY_TBL,
2879        p_LINE_UOM_CODE =>     G_LINE_UOM_CODE_TBL,
2880        p_REQUEST_TYPE_CODE => G_REQUEST_TYPE_CODE_TBL,
2881        p_PRICED_QUANTITY =>   G_PRICED_QUANTITY_TBL,
2882        p_PRICED_UOM_CODE =>   G_PRICED_UOM_CODE_TBL,
2883        p_CURRENCY_CODE   =>   G_CURRENCY_CODE_TBL,
2884        p_UNIT_PRICE      =>   G_UNIT_PRICE_TBL,
2885        p_PERCENT_PRICE   =>   G_PERCENT_PRICE_TBL,
2886        p_UOM_QUANTITY =>      G_UOM_QUANTITY_TBL,
2887        p_ADJUSTED_UNIT_PRICE =>G_ADJUSTED_UNIT_PRICE_TBL,
2888        p_UPD_ADJUSTED_UNIT_PRICE =>G_UPD_ADJUSTED_UNIT_PRICE_TBL,
2889        p_PROCESSED_FLAG      =>G_PROCESSED_FLAG_TBL,
2890        p_PRICE_FLAG          =>G_PRICE_FLAG_TBL,
2891        p_LINE_ID             =>G_LINE_ID_TBL,
2892        p_PROCESSING_ORDER    =>G_PROCESSING_ORDER_TBL,
2893        p_PRICING_STATUS_CODE =>G_PRICING_STATUS_CODE_tbl,
2894        p_PRICING_STATUS_TEXT =>G_PRICING_STATUS_TEXT_tbl,
2895        p_ROUNDING_FLAG       =>G_ROUNDING_FLAG_TBL,
2896        p_ROUNDING_FACTOR     =>G_ROUNDING_FACTOR_TBL,
2897        p_QUALIFIERS_EXIST_FLAG => G_QUALIFIERS_EXIST_FLAG_TBL,
2898        p_PRICING_ATTRS_EXIST_FLAG =>G_PRICING_ATTRS_EXIST_FLAG_TBL,
2899        p_PRICE_LIST_ID          => G_PRICE_LIST_ID_TBL,
2900        p_VALIDATED_FLAG         => G_PL_VALIDATED_FLAG_TBL,
2901        p_PRICE_REQUEST_CODE     => G_PRICE_REQUEST_CODE_TBL,
2902        p_USAGE_PRICING_TYPE  =>    G_USAGE_PRICING_TYPE_tbl,
2903        p_line_category       =>    G_LINE_CATEGORY_tbl,
2904        --p_catchweight_qty     =>    G_CATCHWEIGHT_QTY_tbl,
2905        --p_actual_order_qty    =>    G_ACTUAL_ORDER_QTY_TBL,
2906        x_status_code         =>l_return_status,
2907        x_status_text         =>l_return_status_text);
2908 
2909    IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2910       IF l_debug_level  > 0 THEN
2911 	 oe_debug_pub.add(  'WRONG IN INSERT_LINES2'||L_RETURN_STATUS_TEXT , 1 ) ;
2912       END IF;
2913       FND_MESSAGE.SET_NAME('ONT','ONT_PRICING_ERRORS'); --bug#7149497
2914       FND_MESSAGE.SET_TOKEN('ERR_TEXT',l_return_status_text);
2915       OE_MSG_PUB.Add;
2916       RAISE FND_API.G_EXC_ERROR;
2917    END IF;
2918 
2919    IF G_ATTR_LINE_INDEX_tbl.count > 0 THEN
2920       QP_PREQ_GRP.INSERT_LINE_ATTRS2
2921 	 (    G_ATTR_LINE_INDEX_tbl,
2922 	      G_ATTR_LINE_DETAIL_INDEX_tbl  ,
2923 	      G_ATTR_ATTRIBUTE_LEVEL_tbl    ,
2924 	      G_ATTR_ATTRIBUTE_TYPE_tbl     ,
2925 	      G_ATTR_LIST_HEADER_ID_tbl     ,
2926 	      G_ATTR_LIST_LINE_ID_tbl       ,
2927 	      G_ATTR_PRICING_CONTEXT_tbl            ,
2928 	      G_ATTR_PRICING_ATTRIBUTE_tbl          ,
2929 	      G_ATTR_VALUE_FROM_tbl         ,
2930 	      G_ATTR_SETUP_VALUE_FROM_tbl   ,
2931 	      G_ATTR_VALUE_TO_tbl           ,
2932 	      G_ATTR_SETUP_VALUE_TO_tbl     ,
2933 	      G_ATTR_GROUPING_NUMBER_tbl         ,
2934 	      G_ATTR_NO_QUAL_IN_GRP_tbl      ,
2935 	      G_ATTR_COMP_OPERATOR_TYPE_tbl  ,
2936 	      G_ATTR_VALIDATED_FLAG_tbl            ,
2937 	      G_ATTR_APPLIED_FLAG_tbl              ,
2938 	      G_ATTR_PRICING_STATUS_CODE_tbl       ,
2939 	      G_ATTR_PRICING_STATUS_TEXT_tbl       ,
2940 	      G_ATTR_QUAL_PRECEDENCE_tbl      ,
2941 	      G_ATTR_DATATYPE_tbl                  ,
2942 	      G_ATTR_PRICING_ATTR_FLAG_tbl         ,
2943 	      G_ATTR_QUALIFIER_TYPE_tbl            ,
2944 	      G_ATTR_PRODUCT_UOM_CODE_TBL          ,
2945 	      G_ATTR_EXCLUDER_FLAG_TBL             ,
2946 	      G_ATTR_PRICING_PHASE_ID_TBL ,
2947 	      G_ATTR_INCOM_GRP_CODE_TBL,
2948 	      G_ATTR_LDET_TYPE_CODE_TBL,
2949 	      G_ATTR_MODIFIER_LEVEL_CODE_TBL,
2950 	      G_ATTR_PRIMARY_UOM_FLAG_TBL,
2951 	      l_return_status                   ,
2952 	      l_return_status_text                   );
2953 
2954       IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2955 	 IF l_debug_level  > 0 THEN
2956 	    oe_debug_pub.add(  'ERROR INSERTING INTO LINE ATTRS'||SQLERRM ) ;
2957 	 END IF;
2958 	 FND_MESSAGE.SET_NAME('ONT','ONT_PRICING_ERRORS'); --bug#7149497
2959 	 FND_MESSAGE.SET_TOKEN('ERR_TEXT',l_return_status_text);
2960 	 OE_MSG_PUB.Add;
2961 	 raise fnd_api.g_exc_unexpected_error;
2962       END IF;
2963 
2964    END IF;
2965    IF l_debug_level  > 0 THEN
2966       oe_debug_pub.add(  'AFTER DIRECT INSERT INTO TEMP TABLE: BULK INSERT' , 1 ) ;
2967    END IF;
2968 
2969 EXCEPTION
2970    WHEN OTHERS THEN
2971       RAISE FND_API.G_EXC_ERROR;
2972 END POPULATE_TEMP_TABLE;
2973 
2974 
2975 PROCEDURE Populate_results
2976    (x_line_tbl          OUT nocopy  QP_PREQ_GRP.LINE_TBL_TYPE,
2977     x_line_qual_tbl        OUT nocopy  QP_PREQ_GRP.QUAL_TBL_TYPE,
2978     x_line_attr_tbl        OUT  nocopy QP_PREQ_GRP.LINE_ATTR_TBL_TYPE,
2979     x_line_detail_tbl      OUT  nocopy QP_PREQ_GRP.LINE_DETAIL_TBL_TYPE,
2980     x_line_detail_qual_tbl OUT  nocopy QP_PREQ_GRP.LINE_DETAIL_QUAL_TBL_TYPE,
2981     x_line_detail_attr_tbl OUT  nocopy QP_PREQ_GRP.LINE_DETAIL_ATTR_TBL_TYPE,
2982     x_related_lines_tbl    OUT  nocopy QP_PREQ_GRP.RELATED_LINES_TBL_TYPE)
2983 AS
2984 
2985   CURSOR l_lines_cur IS
2986     SELECT LINE_INDEX,
2987            LINE_ID,
2988            PRICE_LIST_HEADER_ID, -- shu, print out this
2989            LINE_TYPE_CODE,
2990            LINE_QUANTITY,
2991            LINE_UOM_CODE,
2992            LINE_UNIT_PRICE, -- shu
2993            ROUNDING_FACTOR, -- shu
2994            PRICED_QUANTITY,
2995            UOM_QUANTITY,
2996            PRICED_UOM_CODE,
2997            CURRENCY_CODE,
2998            UNIT_PRICE,
2999            PERCENT_PRICE,
3000            PARENT_PRICE,
3001            PARENT_QUANTITY,
3002            PARENT_UOM_CODE,
3003            PRICE_FLAG,
3004            ADJUSTED_UNIT_PRICE,
3005 	   UPDATED_ADJUSTED_UNIT_PRICE,
3006            PROCESSING_ORDER,
3007            PROCESSED_CODE,
3008            PRICING_STATUS_CODE,
3009            PRICING_STATUS_TEXT,
3010            HOLD_CODE,
3011            HOLD_TEXT,
3012            PRICE_REQUEST_CODE,
3013            PRICING_EFFECTIVE_DATE,
3014            EXTENDED_PRICE, 		/* block pricing */
3015 	   ORDER_UOM_SELLING_PRICE
3016     FROM   QP_PREQ_LINES_TMP;
3017 
3018 
3019   CURSOR l_qual_cur (L_ATTRIBUTE_LEVEL VARCHAR2)IS
3020     SELECT QPLAT.LINE_INDEX,
3021            QPLAT.LINE_DETAIL_INDEX,
3022            QPLAT.CONTEXT,
3023            QPLAT.ATTRIBUTE,
3024            QPLAT.SETUP_VALUE_FROM,
3025            QPLAT.SETUP_VALUE_TO,
3026            QPLAT.COMPARISON_OPERATOR_TYPE_CODE,
3027            QPLAT.VALIDATED_FLAG,
3028            QPLAT.PRICING_STATUS_CODE,
3029            QPLAT.PRICING_STATUS_TEXT
3030       FROM  QP_PREQ_LDETS_TMP QPLD ,
3031 	    QP_PREQ_LINE_ATTRS_TMP QPLAT
3032      WHERE QPLD.LINE_DETAIL_INDEX = QPLAT.LINE_DETAIL_INDEX
3033        AND   QPLD.PRICING_STATUS_CODE = QP_PREQ_GRP.G_STATUS_NEW
3034        AND   QPLAT.ATTRIBUTE_TYPE = 'QUALIFIER';
3035            --AND QPLAT.PRICING_STATUS_CODE = G_STATUS_NEW;
3036 
3037 
3038   CURSOR l_pricing_attr_cur IS
3039     SELECT QPLAT_PRICING.CONTEXT        PRICING_CONTEXT,
3040            QPLAT_PRICING.ATTRIBUTE      PRICING_ATTRIBUTE,
3041            nvl(QPLAT_PRICING.SETUP_VALUE_FROM,QPLAT_PRICING.VALUE_FROM)     PRICING_ATTR_VALUE_FROM,
3042            QPLAT_PRICING.SETUP_VALUE_TO       PRICING_ATTR_VALUE_TO,
3043            QPLAT_PRICING.COMPARISON_OPERATOR_TYPE_CODE,
3044            QPLAT_PRICING.LINE_DETAIL_INDEX,
3045            QPLAT_PRICING.LINE_INDEX,
3046            QPLAT_PRICING.VALIDATED_FLAG
3047       FROM  QP_PREQ_LDETS_TMP QPLD ,
3048 	    QP_PREQ_LINE_ATTRS_TMP QPLAT_PRICING
3049      WHERE QPLD.LINE_DETAIL_INDEX = QPLAT_PRICING.LINE_DETAIL_INDEX
3050        AND   QPLD.PRICING_STATUS_CODE = QP_PREQ_GRP.G_STATUS_NEW
3051        AND   QPLAT_PRICING.ATTRIBUTE_TYPE IN ('PRICING','PRODUCT');
3052   --AND QPLAT_PRICING.PRICING_STATUS_CODE = G_STATUS_NEW;
3053 
3054 
3055   CURSOR l_ldets_cur IS
3056 
3057     SELECT /*+ ORDERED USE_NL(A B C) l_ldets_cur */
3058 
3059            a.LINE_DETAIL_INDEX,
3060            a.LINE_DETAIL_TYPE_CODE,
3061            a.LINE_INDEX,
3062            a.CREATED_FROM_LIST_HEADER_ID LIST_HEADER_ID,
3063            a.CREATED_FROM_LIST_LINE_ID   LIST_LINE_ID,
3064            a.CREATED_FROM_LIST_LINE_TYPE LIST_LINE_TYPE_CODE,
3065            a.PRICE_BREAK_TYPE_CODE,
3066            a.LINE_QUANTITY,
3067            a.ADJUSTMENT_AMOUNT,
3068 	   a.AUTOMATIC_FLAG,
3069            a.PRICING_PHASE_ID,
3070            a.OPERAND_CALCULATION_CODE,
3071            a.OPERAND_VALUE,
3072            a.PRICING_GROUP_SEQUENCE,
3073            a.CREATED_FROM_LIST_TYPE_CODE,
3074            a.APPLIED_FLAG,
3075            a.PRICING_STATUS_CODE,
3076            a.PRICING_STATUS_TEXT,
3077            a.LIMIT_CODE,
3078            a.LIMIT_TEXT,
3079            a.LIST_LINE_NO,
3080            a.GROUP_QUANTITY,
3081            a.GROUP_AMOUNT, -- 2388011_new
3082            a.UPDATED_FLAG,
3083 	   a.PROCESS_CODE,
3084 	   a.CALCULATION_CODE,
3085 	   a.CHANGE_REASON_CODE,
3086 	   a.CHANGE_REASON_TEXT,
3087 	   a.ORDER_QTY_ADJ_AMT,
3088            b.SUBSTITUTION_VALUE SUBSTITUTION_VALUE_TO,
3089            b.SUBSTITUTION_ATTRIBUTE,
3090            b.ACCRUAL_FLAG,
3091            b.modifier_level_code,
3092            b.ESTIM_GL_VALUE,
3093            b.ACCRUAL_CONVERSION_RATE,
3094            --Pass throuh components
3095            b.OVERRIDE_FLAG,
3096            b.PRINT_ON_INVOICE_FLAG,
3097            b.INVENTORY_ITEM_ID,
3098            b.ORGANIZATION_ID,
3099            b.RELATED_ITEM_ID,
3100            b.RELATIONSHIP_TYPE_ID,
3101            b.ESTIM_ACCRUAL_RATE,
3102            b.EXPIRATION_DATE,
3103            b.BENEFIT_PRICE_LIST_LINE_ID,
3104            b.RECURRING_FLAG,
3105            b.RECURRING_VALUE,
3106 	   b.BENEFIT_LIMIT,
3107            b.CHARGE_TYPE_CODE,
3108            b.CHARGE_SUBTYPE_CODE,
3109            b.BENEFIT_QTY,
3110            b.BENEFIT_UOM_CODE,
3111            b.PRORATION_TYPE_CODE,
3112            b.INCLUDE_ON_RETURNS_FLAG,
3113            b.REBATE_TRANSACTION_TYPE_CODE,
3114            b.NUMBER_EXPIRATION_PERIODS,
3115            b.EXPIRATION_PERIOD_UOM,
3116            b.COMMENTS
3117       FROM  QP_PREQ_LDETS_TMP a,
3118 	    QP_LIST_LINES     b
3119      WHERE a.CREATED_FROM_LIST_LINE_ID = b.LIST_LINE_ID
3120        AND   a.PRICING_STATUS_CODE = QP_PREQ_GRP.G_STATUS_NEW;
3121 
3122 
3123   CURSOR l_rltd_lines_cur IS
3124     SELECT  LINE_INDEX,
3125             LINE_DETAIL_INDEX,
3126             RELATIONSHIP_TYPE_CODE,
3127             RELATED_LINE_INDEX,
3128             RELATED_LINE_DETAIL_INDEX,
3129             PRICING_STATUS_CODE,
3130             PRICING_STATUS_TEXT
3131       FROM QP_PREQ_RLTD_LINES_TMP
3132      WHERE PRICING_STATUS_CODE = QP_PREQ_GRP.G_STATUS_NEW
3133      ORDER BY SETUP_VALUE_FROM;
3134 
3135 
3136 I PLS_INTEGER :=1;
3137 J PLS_INTEGER :=1;
3138 l_expiration_period_end_date Date;
3139 l_status_code VARCHAR2(30);
3140 l_status_text VARCHAR2(30);
3141 E_ROUTINE_ERROR EXCEPTION;
3142 l_routine VARCHAR2(240):='QP_PREQ_GRP.POPULATE_OUTPUT';
3143 
3144 BEGIN
3145 
3146 
3147    oe_debug_pub.add('----Before populate l_line_tbl-----');
3148    oe_debug_pub.add('----Line information return back to caller----');
3149 
3150    FOR l_line IN l_lines_cur LOOP
3151       --requirement from Jay, will cause holes in pl/sql table.
3152       I :=  l_line.LINE_INDEX;
3153       x_line_tbl(I).LINE_INDEX := l_line.LINE_INDEX;
3154       x_line_tbl(I).LINE_ID    := l_line.LINE_ID;
3155       x_line_tbl(I).HEADER_ID    := l_line.PRICE_LIST_HEADER_ID;
3156       x_line_tbl(I).LINE_TYPE_CODE := l_line.LINE_TYPE_CODE;
3157       x_line_tbl(I).PRICED_QUANTITY := l_line.PRICED_QUANTITY;
3158       x_line_tbl(I).CURRENCY_CODE := l_line.CURRENCY_CODE;
3159       x_line_tbl(I).ROUNDING_FACTOR := l_line.ROUNDING_FACTOR;
3160       x_line_tbl(I).PRICED_UOM_CODE := l_line.PRICED_UOM_CODE;
3161       x_line_tbl(I).UNIT_PRICE := l_line.UNIT_PRICE; --shu_latest
3162       x_line_tbl(I).LINE_QUANTITY:=l_line.LINE_QUANTITY;
3163       x_line_tbl(I).LINE_UOM_CODE:=l_line.LINE_UOM_CODE;
3164       x_line_tbl(I).LINE_UNIT_PRICE := l_line.LINE_UNIT_PRICE; --shu_latest
3165       x_line_tbl(I).UOM_QUANTITY := l_line.UOM_QUANTITY; --shu_latest
3166       x_line_tbl(I).PERCENT_PRICE := l_line.PERCENT_PRICE;
3167    -- x_line_tbl(I).ADJUSTED_UNIT_PRICE := l_line.ADJUSTED_UNIT_PRICE;
3168       x_line_tbl(I).ADJUSTED_UNIT_PRICE:= l_line.ORDER_UOM_SELLING_PRICE;
3169       x_line_tbl(I).UPDATED_ADJUSTED_UNIT_PRICE := l_line.UPDATED_ADJUSTED_UNIT_PRICE;
3170       x_line_tbl(I).PARENT_PRICE := l_line.PARENT_PRICE;
3171       x_line_tbl(I).PARENT_QUANTITY := l_line.PARENT_QUANTITY;
3172       x_line_tbl(I).PARENT_UOM_CODE := l_line.PARENT_UOM_CODE;
3173       x_line_tbl(I).PROCESSED_CODE := l_line.PROCESSED_CODE;
3174       x_line_tbl(I).PRICE_FLAG := l_line.PRICE_FLAG;
3175       x_line_tbl(I).STATUS_CODE := l_line.PRICING_STATUS_CODE;
3176       x_line_tbl(I).STATUS_TEXT := substr(l_line.PRICING_STATUS_TEXT,1,2000); -- shulin, fix bug 1745788
3177       x_line_tbl(I).HOLD_CODE := l_line.HOLD_CODE;
3178       x_line_tbl(I).HOLD_TEXT := substr(l_line.HOLD_TEXT,1,240);
3179       x_line_tbl(I).PRICE_REQUEST_CODE := l_line.PRICE_REQUEST_CODE;
3180       x_line_tbl(I).PRICING_EFFECTIVE_DATE := l_line.PRICING_EFFECTIVE_DATE;
3181       x_line_tbl(I).EXTENDED_PRICE := l_line.EXTENDED_PRICE; -- block pricing
3182 
3183 
3184    END LOOP;
3185    I:=1;
3186 
3187 
3188    --Populate Line detail
3189 
3190    oe_debug_pub.add('----Line detail information return back to caller----');
3191 
3192    FOR l_dets IN l_ldets_cur LOOP
3193 
3194       oe_debug_pub.add('----populating line detail output------');
3195       --requirement by Jay, will cause holes in pl/sql tbl
3196       I := l_dets.line_detail_index;
3197       x_line_detail_tbl(I).LINE_DETAIL_INDEX := l_dets.LINE_DETAIL_INDEX;
3198       x_line_detail_tbl(I).LINE_DETAIL_TYPE_CODE:=l_dets.LINE_DETAIL_TYPE_CODE;
3199       x_line_detail_tbl(I).LINE_INDEX:=l_dets.LINE_INDEX;
3200       x_line_detail_tbl(I).LIST_HEADER_ID:=l_dets.LIST_HEADER_ID;
3201       x_line_detail_tbl(I).LIST_LINE_ID:=l_dets.LIST_LINE_ID;
3202       x_line_detail_tbl(I).LIST_LINE_TYPE_CODE:=l_dets.LIST_LINE_TYPE_CODE;
3203       x_line_detail_tbl(I).SUBSTITUTION_TO:=l_dets.SUBSTITUTION_VALUE_TO;
3204       x_line_detail_tbl(I).LINE_QUANTITY :=l_dets.LINE_QUANTITY;
3205       --x_line_detail_tbl(I).ADJUSTMENT_AMOUNT := l_dets.ADJUSTMENT_AMOUNT;
3206       x_line_detail_tbl(I).ADJUSTMENT_AMOUNT:= nvl(l_dets.ORDER_QTY_ADJ_AMT,l_dets.ADJUSTMENT_AMOUNT);
3207       --   nvl(ldets.order_qty_adj_amt, ldets.adjustment_amount*nvl(lines.priced_quantity,1)/nvl(lines.line_quantity,1))
3208       x_line_detail_tbl(I).AUTOMATIC_FLAG    := l_dets.AUTOMATIC_FLAG;
3209       x_line_detail_tbl(I).APPLIED_FLAG      := l_dets.APPLIED_FLAG;
3210       x_line_detail_tbl(I).PRICING_GROUP_SEQUENCE := l_dets.PRICING_GROUP_SEQUENCE;
3211       x_line_detail_tbl(I).CREATED_FROM_LIST_TYPE_CODE:=l_dets.CREATED_FROM_LIST_TYPE_CODE;
3212       x_line_detail_tbl(I).PRICE_BREAK_TYPE_CODE := l_dets.PRICE_BREAK_TYPE_CODE;
3213       x_line_detail_tbl(I).OVERRIDE_FLAG   := L_Dets.override_flag;
3214       x_line_detail_tbl(I).PRINT_ON_INVOICE_FLAG :=l_dets.print_on_invoice_flag;
3215       x_line_detail_tbl(I).PRICING_PHASE_ID := l_dets.PRICING_PHASE_ID;
3216       x_line_detail_tbl(I).APPLIED_FLAG := l_dets.APPLIED_FLAG;
3217       x_line_detail_tbl(I).OPERAND_CALCULATION_CODE := l_dets.OPERAND_CALCULATION_CODE;
3218       x_line_detail_tbl(I).OPERAND_VALUE := l_dets.OPERAND_VALUE;
3219       x_line_detail_tbl(I).STATUS_CODE:=l_dets.PRICING_STATUS_CODE;
3220       x_line_detail_tbl(I).STATUS_TEXT:=substr(l_dets.PRICING_STATUS_TEXT,1,240);
3221       x_line_detail_tbl(I).SUBSTITUTION_ATTRIBUTE:=l_dets.SUBSTITUTION_ATTRIBUTE;
3222       x_line_detail_tbl(I).ACCRUAL_FLAG:=l_dets.ACCRUAL_FLAG;
3223       x_line_detail_tbl(I).LIST_LINE_NO:=l_dets.LIST_LINE_NO;
3224       x_line_detail_tbl(I).ESTIM_GL_VALUE:=l_dets.ESTIM_GL_VALUE;
3225       x_line_detail_tbl(I).ACCRUAL_CONVERSION_RATE:=l_dets.ACCRUAL_CONVERSION_RATE;
3226       --Pass throuh components
3227       x_line_detail_tbl(I).OVERRIDE_FLAG:= l_dets.OVERRIDE_FLAG;
3228       x_line_detail_tbl(I).PRINT_ON_INVOICE_FLAG:=l_dets.PRINT_ON_INVOICE_FLAG;
3229       x_line_detail_tbl(I).INVENTORY_ITEM_ID:=l_dets.INVENTORY_ITEM_ID;
3230       x_line_detail_tbl(I).ORGANIZATION_ID:=l_dets.ORGANIZATION_ID;
3231       x_line_detail_tbl(I).RELATED_ITEM_ID:= l_dets.RELATED_ITEM_ID;
3232       x_line_detail_tbl(I).RELATIONSHIP_TYPE_ID:=l_dets.RELATIONSHIP_TYPE_ID;
3233       x_line_detail_tbl(I).ESTIM_ACCRUAL_RATE:=l_dets.ESTIM_ACCRUAL_RATE;
3234 
3235       x_line_detail_tbl(I).BENEFIT_PRICE_LIST_LINE_ID:=l_dets.BENEFIT_PRICE_LIST_LINE_ID;
3236       x_line_detail_tbl(I).RECURRING_FLAG:= l_dets.RECURRING_FLAG;
3237       x_line_detail_tbl(I).RECURRING_VALUE:= l_dets.RECURRING_VALUE;
3238       x_line_detail_tbl(I).BENEFIT_LIMIT:= l_dets.BENEFIT_LIMIT;
3239       x_line_detail_tbl(I).CHARGE_TYPE_CODE:=  l_dets.CHARGE_TYPE_CODE;
3240       x_line_detail_tbl(I).CHARGE_SUBTYPE_CODE:=l_dets.CHARGE_SUBTYPE_CODE;
3241       x_line_detail_tbl(I).BENEFIT_QTY:=l_dets.BENEFIT_QTY;
3242       x_line_detail_tbl(I).BENEFIT_UOM_CODE:=l_dets.BENEFIT_UOM_CODE;
3243       x_line_detail_tbl(I).PRORATION_TYPE_CODE:=l_dets.PRORATION_TYPE_CODE;
3244       x_line_detail_tbl(I).INCLUDE_ON_RETURNS_FLAG := l_dets.INCLUDE_ON_RETURNS_FLAG;
3245       x_line_detail_tbl(I).LIST_LINE_NO := l_dets.LIST_LINE_NO;
3246       x_line_detail_tbl(I).MODIFIER_LEVEL_CODE := l_dets.MODIFIER_LEVEL_CODE;
3247       x_line_detail_tbl(I).GROUP_VALUE := nvl(l_dets.GROUP_QUANTITY,l_dets.GROUP_AMOUNT); -- 2388011_new
3248       x_line_detail_tbl(I).COMMENTS := l_dets.COMMENTS;
3249       x_line_detail_tbl(I).UPDATED_FLAG := l_dets.UPDATED_FLAG;
3250       x_line_detail_tbl(I).PROCESS_CODE := l_dets.PROCESS_CODE;
3251       x_line_detail_tbl(I).LIMIT_CODE := l_dets.LIMIT_CODE;
3252       x_line_detail_tbl(I).LIMIT_TEXT := substr(l_dets.LIMIT_TEXT,1,240);
3253       x_line_detail_tbl(I).CALCULATION_CODE := l_dets.CALCULATION_CODE;
3254       x_line_detail_tbl(I).CHANGE_REASON_CODE := l_dets.CHANGE_REASON_CODE;
3255       x_line_detail_tbl(I).CHANGE_REASON_CODE := substr(l_dets.CHANGE_REASON_CODE,1,240);
3256 
3257       IF l_status_code = FND_API.G_RET_STS_ERROR THEN
3258 	 --  IF G_DEBUG_ENGINE = FND_API.G_TRUE THEN
3259 	 oe_debug_pub.add(l_routine||':'||substr(l_status_text,1,240));
3260 	 --END IF;
3261       END IF;
3262 
3263       x_line_detail_tbl(I).EXPIRATION_DATE :=l_expiration_period_end_date;
3264    END LOOP;
3265    I:=1;
3266 
3267    --Populate Qualifier detail
3268    --IF G_DEBUG_ENGINE = FND_API.G_TRUE THEN
3269    oe_debug_pub.add('----Before populate x_qual_tbl-----');
3270    --END IF;
3271    FOR l_qual IN l_qual_cur(QP_PREQ_GRP.G_DETAIL_LEVEL) LOOP
3272       x_line_detail_qual_tbl(I).LINE_DETAIL_INDEX := l_qual.LINE_DETAIL_INDEX;
3273       x_line_detail_qual_tbl(I).QUALIFIER_CONTEXT := l_qual.CONTEXT;
3274       x_line_detail_qual_tbl(I).QUALIFIER_ATTRIBUTE := l_qual.ATTRIBUTE;
3275       x_line_detail_qual_tbl(I).QUALIFIER_ATTR_VALUE_FROM := l_qual.SETUP_VALUE_FROM;
3276       x_line_detail_qual_tbl(I).QUALIFIER_ATTR_VALUE_TO := l_qual.SETUP_VALUE_TO;
3277       x_line_detail_qual_tbl(I).COMPARISON_OPERATOR_CODE := l_qual.COMPARISON_OPERATOR_TYPE_CODE;
3278       x_line_detail_qual_tbl(I).status_code := l_qual.PRICING_STATUS_CODE;
3279       x_line_detail_qual_tbl(I).VALIDATED_FLAG :=l_qual.VALIDATED_FLAG;
3280 
3281       I:=I+1;
3282    END LOOP;
3283    I:=1;
3284 
3285    --LINE ATTRIBUTE DETAIL NEEDED
3286    --IF G_DEBUG_ENGINE = FND_API.G_TRUE THEN
3287    oe_debug_pub.add('----Before populate attr_tbl-----');
3288    --END IF;
3289    FOR l_prc IN l_pricing_attr_cur LOOP
3290       --IF G_DEBUG_ENGINE = FND_API.G_TRUE THEN
3291       oe_debug_pub.add('--------populating x_line_detail_attr----------');
3292       oe_debug_pub.add('Line Detail Index: '||l_prc.LINE_DETAIL_INDEX);
3293       --END IF;
3294       x_line_detail_attr_tbl(I).LINE_DETAIL_INDEX := l_prc.LINE_DETAIL_INDEX;
3295       x_line_detail_attr_tbl(I).PRICING_CONTEXT := l_prc.PRICING_CONTEXT;
3296       x_line_detail_attr_tbl(I).PRICING_ATTRIBUTE := l_prc.PRICING_ATTRIBUTE;
3297       x_line_detail_attr_tbl(I).PRICING_ATTR_VALUE_FROM :=l_prc.PRICING_ATTR_VALUE_FROM;
3298       x_line_detail_attr_tbl(I).PRICING_ATTR_VALUE_TO :=l_prc.PRICING_ATTR_VALUE_TO;
3299       x_line_detail_attr_tbl(I).VALIDATED_FLAG :=l_prc.VALIDATED_FLAG;
3300       --x_line_attr_tbl(I).PRICING_STATUS_CODE := l_prc.PRICING_STATUS_CODE;
3301       --x_line_attr_tbl(I).PRICING_STATUS_TEXT := l_prc.PRICING_STATUS_TEXT;
3302       I:=I+1;
3303    END LOOP;
3304 
3305    I:=1;
3306 
3307    --IF G_DEBUG_ENGINE = FND_API.G_TRUE THEN
3308    oe_debug_pub.add('----Before populate l_rltd_lines_tbl-----');
3309    --END IF;
3310    FOR l_rltd IN l_rltd_lines_cur LOOP
3311       x_related_lines_tbl(I).LINE_INDEX := l_rltd.Line_index;
3312       x_related_lines_tbl(I).LINE_DETAIL_INDEX :=  l_rltd.LINE_DETAIL_INDEX;
3313       x_related_lines_tbl(I).RELATIONSHIP_TYPE_CODE :=l_rltd.RELATIONSHIP_TYPE_CODE;
3314       x_related_lines_tbl(I).RELATED_LINE_INDEX     :=l_rltd.RELATED_LINE_INDEX;
3315       x_related_lines_tbl(I).RELATED_LINE_DETAIL_INDEX :=l_rltd.RELATED_LINE_DETAIL_INDEX;
3316       x_related_lines_tbl(I).STATUS_CODE :=l_rltd.PRICING_STATUS_CODE;
3317       x_related_lines_tbl(I).STATUS_TEXT :=l_rltd.PRICING_STATUS_TEXT;
3318       I:=I+1;
3319    END LOOP;
3320 
3321 EXCEPTION
3322    WHEN E_ROUTINE_ERROR THEN
3323       --   IF G_DEBUG_ENGINE = FND_API.G_TRUE THEN
3324       oe_debug_pub.add(l_routine||':'||substr(l_status_text,1,240));
3325       -- END IF;
3326 
3327 END Populate_results;
3328 
3329 
3330 
3331 
3332 PROCEDURE price_item(out_req_line_tbl in out NOCOPY /* file.sql.39 change */ QP_PREQ_GRP.LINE_TBL_TYPE,
3333 		     out_Req_line_attr_tbl         in out nocopy  QP_PREQ_GRP.LINE_ATTR_TBL_TYPE,
3334 		     out_Req_LINE_DETAIL_attr_tbl  in out nocopy  QP_PREQ_GRP.LINE_DETAIL_ATTR_TBL_TYPE,
3335 		     out_Req_LINE_DETAIL_tbl        in out nocopy QP_PREQ_GRP.LINE_DETAIL_TBL_TYPE,
3336 		     out_Req_related_lines_tbl      in out nocopy QP_PREQ_GRP.RELATED_LINES_TBL_TYPE,
3337 		     out_Req_qual_tbl               in out nocopy QP_PREQ_GRP.QUAL_TBL_TYPE,
3338 		     out_Req_LINE_DETAIL_qual_tbl   in out nocopy QP_PREQ_GRP.LINE_DETAIL_QUAL_TBL_TYPE,
3339 		     out_child_detail_type out nocopy varchar2
3340 
3341                      ) IS
3342 
3343    l_return_status               varchar2(10);
3344    l_return_status_Text	      varchar2(240) ;
3345    l_Control_Rec                 QP_PREQ_GRP.CONTROL_RECORD_TYPE;
3346    l_req_line_tbl                QP_PREQ_GRP.LINE_TBL_TYPE;
3347    l_Req_qual_tbl                QP_PREQ_GRP.QUAL_TBL_TYPE;
3348    l_Req_line_attr_tbl           QP_PREQ_GRP.LINE_ATTR_TBL_TYPE;
3349    l_Req_LINE_DETAIL_tbl         QP_PREQ_GRP.LINE_DETAIL_TBL_TYPE;
3350    l_Req_LINE_DETAIL_qual_tbl    QP_PREQ_GRP.LINE_DETAIL_QUAL_TBL_TYPE;
3351    l_Req_LINE_DETAIL_attr_tbl    QP_PREQ_GRP.LINE_DETAIL_ATTR_TBL_TYPE;
3352    l_Req_related_lines_tbl       QP_PREQ_GRP.RELATED_LINES_TBL_TYPE;
3353    l_set_of_books                Oe_Order_Cache.Set_Of_Books_Rec_Type;   --added for bug 12541442
3354    --
3355    l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3356    --
3357 BEGIN
3358 
3359    out_child_detail_type := qp_preq_grp.G_CHILD_DETAIL_TYPE;
3360    reset_all_tbls;
3361 
3362    IF l_debug_level  > 0 THEN
3363       oe_debug_pub.add(  'SETTING REQUEST ID' , 1 ) ;
3364    END IF;
3365 
3366    qp_price_request_context.set_request_id;
3367 
3368    IF l_debug_level  > 0 THEN
3369       oe_debug_pub.add('REQUEST ID IS : ' || QP_PREQ_GRP.G_REQUEST_ID , 1 ) ;
3370    END IF;
3371 
3372 
3373    OE_ORDER_PUB.G_HDR:=NULL;
3374    OE_ORDER_PUB.G_LINE:=NULL;
3375 
3376    copy_Header_to_request(
3377 			  p_request_type_code => 'ONT'
3378 			  ,p_calculate_price_flag  => 'Y'
3379 			  ,px_req_line_tbl => l_req_line_tbl
3380 			  );
3381 
3382    set_pricing_control_record (
3383 			       l_Control_Rec  => l_control_rec
3384 			       ,in_pricing_event => 'BATCH'
3385                                );
3386 
3387 
3388    for l_line_index in g_panda_rec_table.first..g_panda_rec_table.last
3389 		       LOOP
3390       copy_Line_to_request(
3391 			   px_req_line_tbl => l_req_line_tbl
3392 			   ,p_pricing_event => 'BATCH'
3393 			   ,p_Request_Type_Code => 'ONT'
3394 			   ,p_honor_price_flag => 'Y'
3395 			   ,p_line_index=>l_line_index
3396 			   );
3397 
3398       build_context_for_line(
3399 			     p_req_line_tbl_count =>l_req_line_tbl.count,
3400 			     p_price_request_code => null,
3401 			     p_item_type_code => null,
3402 			     p_Req_line_attr_tbl =>l_req_line_attr_tbl,
3403 			     p_Req_qual_tbl =>l_req_qual_tbl,
3404 			     p_line_index=>l_line_index
3405 			     );
3406 
3407       Append_attributes(
3408 			p_header_id => g_header_id
3409 			,p_Line_id   => g_line_id
3410 			,p_line_index =>l_req_line_tbl.count
3411 			,px_Req_line_attr_tbl => l_req_line_attr_tbl
3412 			,px_Req_qual_tbl => l_req_qual_tbl
3413 			,p_g_line_index =>l_line_index
3414 			);
3415 
3416    end loop; -- Looping for each line
3417 
3418 
3419    build_context_for_header(
3420 			    p_req_line_tbl_count =>l_req_line_tbl.count,
3421 			    p_price_request_code => null,
3422 			    p_item_type_code => null,
3423 			    p_Req_line_attr_tbl =>l_req_line_attr_tbl,
3424 			    p_Req_qual_tbl =>l_req_qual_tbl
3425 			    );
3426 
3427 
3428    Append_attributes(
3429 		     p_header_id => g_header_id
3430 		     ,p_Line_id   => g_line_id
3431 		     ,p_line_index => l_req_line_tbl.count
3432 		     ,px_Req_line_attr_tbl => l_req_line_attr_tbl
3433 		     ,px_Req_qual_tbl => l_req_qual_tbl
3434 		     ,p_g_line_index =>1
3435 		     );
3436 
3437    oe_Debug_pub.add(' Populating the attr tables');
3438    append_attr_to_TTables(px_req_line_attr_tbl=>l_req_line_attr_tbl);
3439 
3440    out_req_line_tbl(1).status_Code := null;
3441    out_req_line_tbl(1).status_text := null;
3442 
3443    IF l_debug_level  > 0 THEN
3444       print_time('Calling PE');
3445    END IF;
3446 
3447    oe_Debug_pub.add(' Populating the temp tables');
3448    populate_temp_table;
3449 
3450       --added for bug 12541442
3451    IF l_debug_level > 0 THEN
3452    oe_Debug_pub.add('Value of OE_ORDER_PUB.G_HDR.CONVERSION_RATE is '||OE_ORDER_PUB.G_HDR.CONVERSION_RATE);
3453    oe_Debug_pub.add('Value of OE_ORDER_PUB.G_HDR.CONVERSION_TYPE_CODE is '||OE_ORDER_PUB.G_HDR.CONVERSION_TYPE_CODE);
3454    END IF;
3455 
3456    l_control_rec.USER_CONVERSION_RATE:= OE_ORDER_PUB.G_HDR.CONVERSION_RATE;
3457    l_control_rec.USER_CONVERSION_TYPE:= OE_ORDER_PUB.G_HDR.CONVERSION_TYPE_CODE;
3458    l_set_of_books := Oe_Order_Cache.Load_Set_Of_Books;
3459    l_control_rec.FUNCTION_CURRENCY   := l_set_of_books.currency_code;
3460     --end bug 12541442 code change
3461 
3462    QP_PREQ_PUB.PRICE_REQUEST
3463       (p_control_rec           =>l_control_rec,
3464        x_return_status         =>l_return_status,
3465        x_return_status_Text    =>l_return_status_Text
3466        );
3467 
3468    IF l_debug_level  > 0 THEN
3469       print_time('After Calling PE');
3470    END IF;
3471    oe_debug_pub.add('After caling the pricing engine');
3472 
3473    populate_results(
3474 		    x_line_tbl =>out_req_line_tbl
3475 		    ,x_line_qual_tbl =>out_Req_qual_tbl
3476 		    ,x_line_attr_tbl =>out_Req_line_attr_tbl
3477 		    ,x_line_detail_tbl =>out_req_line_detail_tbl
3478 		    ,x_line_detail_qual_tbl=>out_req_line_detail_qual_tbl
3479 		    ,x_line_detail_attr_tbl =>out_req_line_detail_attr_tbl
3480 		    ,x_related_lines_tbl=>out_req_related_lines_tbl);
3481 
3482    IF l_debug_level > 0 THEN
3483       print_time('After populating the pl/sql records');
3484    END IF;
3485 
3486    IF l_debug_level  > 0 THEN
3487       oe_debug_pub.add(  '******AFTER CALLING PRICING ENGINE' ) ;
3488       oe_debug_pub.add(  'MAIN STATUS ='||L_RETURN_STATUS ) ;
3489       oe_debug_pub.add(  'MAIN TEXT ='||L_RETURN_STATUS_TEXT ) ;
3490       oe_debug_pub.add(  'COUNT LINE TABLE='||OUT_REQ_LINE_TBL.COUNT ) ;
3491    END IF;
3492 
3493    if out_req_line_tbl.count > 0 then
3494       for i in out_req_line_tbl.first..out_req_line_tbl.last
3495 	       loop
3496 
3497 	 IF l_debug_level  > 0 THEN
3498 	    oe_debug_pub.add(  '*******************************' ) ;
3499 	    oe_debug_pub.add(  'REQUEST_TYPE_CODE ='|| OUT_REQ_LINE_TBL ( I ) .REQUEST_TYPE_CODE ) ;
3500 	    oe_debug_pub.add(  'PRICING_EVENT ='||OUT_REQ_LINE_TBL ( I ) .PRICING_EVENT ) ;
3501 	    oe_debug_pub.add(  'HEADER_ID ='||OUT_REQ_LINE_TBL ( I ) .HEADER_ID ) ;
3502 	    oe_debug_pub.add(  'LINE_TYPE_CODE='||OUT_REQ_LINE_TBL ( I ) .LINE_TYPE_CODE ) ;
3503 	    oe_debug_pub.add(  'LINE_QUANTITY ='||OUT_REQ_LINE_TBL ( I ) .LINE_QUANTITY ) ;
3504 	    oe_debug_pub.add(  'LINE_UOM_CODE ='||OUT_REQ_LINE_TBL ( I ) .LINE_UOM_CODE ) ;
3505 	    oe_debug_pub.add(  'UOM_QUANTITY ='||OUT_REQ_LINE_TBL ( I ) .UOM_QUANTITY ) ;
3506 	    oe_debug_pub.add(  'PRI_QUANTITY='||OUT_REQ_LINE_TBL ( I ) .PRICED_QUANTITY ) ;
3507 	    oe_debug_pub.add(  'PR_UOM_CODE ='||OUT_REQ_LINE_TBL ( I ) .PRICED_UOM_CODE ) ;
3508 	    oe_debug_pub.add(  'CURRENCY_CODE ='||OUT_REQ_LINE_TBL ( I ) .CURRENCY_CODE ) ;
3509 	    oe_debug_pub.add(  'UNIT_PRICE ='||OUT_REQ_LINE_TBL ( I ) .UNIT_PRICE ) ;
3510 	    oe_debug_pub.add(  'PERCENT_PRICE ='||OUT_REQ_LINE_TBL ( I ) .PERCENT_PRICE ) ;
3511 	    oe_debug_pub.add(  'ADJ_UNIT_PRICE='|| OUT_REQ_LINE_TBL ( I ) .ADJUSTED_UNIT_PRICE ) ;
3512 	    oe_debug_pub.add(  'UPDATED_ADJUSTED_UNIT_PRICE ='|| OUT_REQ_LINE_TBL ( I ) .UPDATED_ADJUSTED_UNIT_PRICE ) ;
3513 	    oe_debug_pub.add(  'ROUNDING_FAC='||OUT_REQ_LINE_TBL ( I ) .ROUNDING_FACTOR ) ;
3514 	    oe_debug_pub.add(  'PRICE_FLAG ='||OUT_REQ_LINE_TBL ( I ) .PRICE_FLAG ) ;
3515 	    oe_debug_pub.add(  'PRICE_REQUEST_CODE ='|| OUT_REQ_LINE_TBL ( I ) .PRICE_REQUEST_CODE ) ;
3516 	    oe_debug_pub.add(  'HOLD_CODE ='||OUT_REQ_LINE_TBL ( I ) .HOLD_CODE ) ;
3517 	    oe_debug_pub.add(  'HOLD_TEXT ='||OUT_REQ_LINE_TBL ( I ) .HOLD_TEXT ) ;
3518 	    oe_debug_pub.add(  'STATUS_CODE ='||OUT_REQ_LINE_TBL ( I ) .STATUS_CODE ) ;
3519 	    oe_debug_pub.add(  'STATUS_TEXT ='||OUT_REQ_LINE_TBL ( I ) .STATUS_TEXT ) ;
3520 	    oe_debug_pub.add(  'USAGE_PRICING_TYPE ='|| OUT_REQ_LINE_TBL ( I ) .USAGE_PRICING_TYPE ) ;
3521 	    oe_debug_pub.add(  'LINE_CATEGORY ='||OUT_REQ_LINE_TBL ( I ) .LINE_CATEGORY ) ;
3522 	    oe_debug_pub.add(  'PRICING EFFECTIVE DATE='|| OUT_REQ_LINE_TBL ( I ) .PRICING_EFFECTIVE_DATE ) ;
3523 	    oe_debug_pub.add(  'ACTIVE_DATE_FIRST ='|| OUT_REQ_LINE_TBL ( I ) .ACTIVE_DATE_FIRST ) ;
3524 	    oe_debug_pub.add(  'ACTIVE_DATE_FIRST_TYPE ='|| OUT_REQ_LINE_TBL ( I ) .ACTIVE_DATE_FIRST_TYPE ) ;
3525 	    oe_debug_pub.add(  'ACTIVE_DATE_SECOND ='|| OUT_REQ_LINE_TBL ( I ) .ACTIVE_DATE_SECOND ) ;
3526 	    oe_debug_pub.add(  'ACTIVE_DATE_SECOND_TYPE ='|| OUT_REQ_LINE_TBL ( I ) .ACTIVE_DATE_SECOND_TYPE ) ;
3527 	 END IF;
3528       end loop;
3529    end if;
3530 
3531    IF l_debug_level  > 0 THEN
3532       oe_debug_pub.add(  'COUNT LINE DETAIL TABLE='||OUT_REQ_LINE_DETAIL_TBL.COUNT ) ;
3533    END IF;
3534 
3535    if out_req_line_detail_tbl.count > 0 then
3536 
3537       for i in out_req_line_detail_tbl.first..out_req_line_detail_tbl.last
3538 	       loop
3539 
3540 	 IF l_debug_level  > 0 THEN
3541 	    oe_debug_pub.add(  'LINE DETAIL TABLE RECORD='||I ) ;
3542 	 END IF;
3543 
3544 	 IF out_req_line_detail_tbl.exists(i) then
3545 
3546 	    IF l_debug_level  > 0 THEN
3547 	       oe_debug_pub.add(  '*******************************' ) ;
3548 	       oe_debug_pub.add(  'LIN_INDEX='||OUT_REQ_LINE_DETAIL_TBL ( I ) .LINE_INDEX ) ;
3549 	       oe_debug_pub.add(  'LIST_LINE_TYPE_CODE='|| OUT_REQ_LINE_DETAIL_TBL ( I ) .LIST_LINE_TYPE_CODE ) ;
3550 	       oe_debug_pub.add(  'LINE_DETAIL_TYPE_CODE='|| OUT_REQ_LINE_DETAIL_TBL ( I ) .LINE_DETAIL_TYPE_CODE ) ;
3551 	       oe_debug_pub.add(  'CREATED_FROM_LIST_TYPE_CODE='|| OUT_REQ_LINE_DETAIL_TBL ( I ) .CREATED_FROM_LIST_TYPE_CODE ) ;
3552 	       oe_debug_pub.add(  'AUTOMATIC_FLAG='|| OUT_REQ_LINE_DETAIL_TBL ( I ) .AUTOMATIC_FLAG ) ;
3553 	       oe_debug_pub.add(  'ACCRUAL='||OUT_REQ_LINE_DETAIL_TBL ( I ) .ACCRUAL_FLAG ) ;
3554 	       oe_debug_pub.add(  'STATUS='||OUT_REQ_LINE_DETAIL_TBL ( I ) .STATUS_CODE ) ;
3555 	       oe_debug_pub.add(  'STS_TEXT='||OUT_REQ_LINE_DETAIL_TBL ( I ) .STATUS_TEXT ) ;
3556 	       oe_debug_pub.add(  'LIST_HEADER_ID='|| OUT_REQ_LINE_DETAIL_TBL ( I ) .LIST_HEADER_ID ) ;
3557 	       oe_debug_pub.add(  'LIST_LINE_ID='|| OUT_REQ_LINE_DETAIL_TBL ( I ) .LIST_LINE_ID ) ;
3558 	       oe_debug_pub.add(  'PRICE_BREAK_TYPE_CODE='|| OUT_REQ_LINE_DETAIL_TBL ( I ) .PRICE_BREAK_TYPE_CODE ) ;
3559                oe_debug_pub.add(  'OPERAND_CALCULATION_CODE='||OUT_REQ_LINE_DETAIL_TBL(I).OPERAND_CALCULATION_CODE);
3560 	       oe_debug_pub.add(  'LST_PRICE='||OUT_REQ_LINE_DETAIL_TBL ( I ) .LIST_PRICE ) ;
3561 	       oe_debug_pub.add(  'ADJUSTMENT_AMOUNT='|| OUT_REQ_LINE_DETAIL_TBL ( I ) .ADJUSTMENT_AMOUNT ) ;
3562 	       oe_debug_pub.add(  'LINE_QUANTITY='|| OUT_REQ_LINE_DETAIL_TBL ( I ) .LINE_QUANTITY ) ;
3563 	       oe_debug_pub.add(  'MODIFIER_LEVEL_CODE='|| OUT_REQ_LINE_DETAIL_TBL ( I ) .MODIFIER_LEVEL_CODE ) ;
3564 	       oe_debug_pub.add(  'INVENTORY_ITEM_ID='|| OUT_REQ_LINE_DETAIL_TBL ( I ) .INVENTORY_ITEM_ID ) ;
3565 	       oe_debug_pub.add(  'RECURRING_FLAG='||OUT_REQ_LINE_DETAIL_TBL (I).RECURRING_FLAG );
3566 	       oe_debug_pub.add(  'RECURRING_VALUE='||OUT_REQ_LINE_DETAIL_TBL(I).RECURRING_VALUE);
3567 	    end if;
3568 	 end if;
3569       end loop;
3570 
3571    end if;
3572 
3573 
3574    IF l_debug_level  > 0 THEN
3575       oe_debug_pub.add(  'COUNT LINE DETAIL ATTR TBL='|| OUT_REQ_LINE_DETAIL_ATTR_TBL.COUNT ) ;
3576    END IF;
3577 
3578    if out_req_line_detail_attr_tbl.count > 0 then
3579       for i in out_req_line_detail_attr_tbl.first..out_req_line_detail_attr_tbl.last
3580 	       loop
3581 	 IF l_debug_level  > 0 THEN
3582 	    oe_debug_pub.add(  '*******************************' ) ;
3583 	    oe_debug_pub.add(  'LINE DETAIL ATTR_TABLE RECORD='||I ) ;
3584 	    oe_debug_pub.add(  'LINE_DETAIL_INDEX='|| OUT_REQ_LINE_DETAIL_ATTR_TBL ( I ) .LINE_DETAIL_INDEX ) ;
3585 	    oe_debug_pub.add(  'PRICING_CONTEXT='|| OUT_REQ_LINE_DETAIL_ATTR_TBL ( I ) .PRICING_CONTEXT ) ;
3586 	    oe_debug_pub.add(  'PRICING_ATTRIBUTE='|| OUT_REQ_LINE_DETAIL_ATTR_TBL ( I ) .PRICING_ATTRIBUTE ) ;
3587 	    oe_debug_pub.add(  'PRICING_ATTR_VALUE_FROM='|| OUT_REQ_LINE_DETAIL_ATTR_TBL ( I ) .PRICING_ATTR_VALUE_FROM ) ;
3588 	    oe_debug_pub.add(  'PRICING_ATTR_VALUE_TO='|| OUT_REQ_LINE_DETAIL_ATTR_TBL ( I ) .PRICING_ATTR_VALUE_TO ) ;
3589 	 END IF;
3590 
3591       end loop;
3592    end if;
3593 
3594 
3595    IF l_debug_level  > 0 THEN
3596       oe_debug_pub.add(  'COUNT LINE ATTR TBL='||OUT_REQ_LINE_ATTR_TBL.COUNT ) ;
3597    END IF;
3598 
3599    if out_req_line_attr_tbl.count > 0 then
3600       for i in out_req_line_attr_tbl.first..out_req_line_attr_tbl.last
3601 	       loop
3602 	 IF l_debug_level  > 0 THEN
3603 	    oe_debug_pub.add(  '*******************************' ) ;
3604 	    oe_debug_pub.add(  'LINE ATTR_TABLE RECORD='||I ) ;
3605 	    oe_debug_pub.add(  'LINE_INDEX='||OUT_REQ_LINE_ATTR_TBL ( I ) .LINE_INDEX ) ;
3606 	    oe_debug_pub.add(  'PRICING_CONTEXT='|| OUT_REQ_LINE_ATTR_TBL ( I ) .PRICING_CONTEXT ) ;
3607 	    oe_debug_pub.add(  'PRICING_ATTRIBUTE='|| OUT_REQ_LINE_ATTR_TBL ( I ) .PRICING_ATTRIBUTE ) ;
3608 	    oe_debug_pub.add(  'PRICING_ATTR_VALUE_FROM='|| OUT_REQ_LINE_ATTR_TBL ( I ) .PRICING_ATTR_VALUE_FROM ) ;
3609 	    oe_debug_pub.add(  'PRICING_ATTR_VALUE_TO='|| OUT_REQ_LINE_ATTR_TBL ( I ) .PRICING_ATTR_VALUE_TO ) ;
3610 	 END IF;
3611 
3612       end loop;
3613    end if;
3614 
3615 
3616    IF l_debug_level  > 0 THEN
3617       oe_debug_pub.add(  'COUNT RELATED LINES TBL='|| OUT_REQ_RELATED_LINES_TBL.COUNT ) ;
3618    END IF;
3619 
3620    if out_req_related_lines_tbl.count > 0 then
3621       for i in out_req_related_lines_tbl.first..out_req_related_lines_tbl.last
3622 	       loop
3623 	 IF l_debug_level  > 0 THEN
3624 	    oe_debug_pub.add(  '*******************************' ) ;
3625 	    oe_debug_pub.add(  'RELATD LINES RECORD='||I ) ;
3626 	    oe_debug_pub.add(  'LIN_INDEX='||OUT_REQ_RELATED_LINES_TBL ( I ) .LINE_INDEX ) ;
3627 	    oe_debug_pub.add(  'LINE_DETAIL_INDEX='|| OUT_REQ_RELATED_LINES_TBL ( I ) .LINE_DETAIL_INDEX ) ;
3628 	    oe_debug_pub.add(  'RELATIONSHIP_TYPE_CODE='|| OUT_REQ_RELATED_LINES_TBL ( I ) .RELATIONSHIP_TYPE_CODE ) ;
3629 	    oe_debug_pub.add(  'RELATED_LINE_INDEX='|| OUT_REQ_RELATED_LINES_TBL ( I ) .RELATED_LINE_INDEX ) ;
3630 	    oe_debug_pub.add(  'RELATED_LINE_DETAIL_INDEX='|| OUT_REQ_RELATED_LINES_TBL ( I ) .RELATED_LINE_DETAIL_INDEX ) ;
3631 	 END IF;
3632 
3633       end loop;
3634    end if;
3635 
3636 
3637    IF l_debug_level  > 0 THEN
3638       oe_debug_pub.add(  'COUNT LINE QUAL TBL='||OUT_REQ_QUAL_TBL.COUNT ) ;
3639    END IF;
3640 
3641    if out_req_qual_tbl.count > 0 then
3642       for i in out_req_qual_tbl.first..out_req_qual_tbl.last
3643 	       loop
3644 	 IF l_debug_level  > 0 THEN
3645 	    oe_debug_pub.add('*******************************' ) ;
3646 	    oe_debug_pub.add('QUAL TABLE RECORD='||I ) ;
3647 	    oe_debug_pub.add('LINE_INDEX='||OUT_REQ_QUAL_TBL ( I ) .LINE_INDEX ) ;
3648 	    oe_debug_pub.add('QUALIFIER_CONTEXT='|| OUT_REQ_QUAL_TBL ( I ) .QUALIFIER_CONTEXT ) ;
3649 	    oe_debug_pub.add(  'QUALIFIER_ATTRIBUTE='|| OUT_REQ_QUAL_TBL ( I ) .QUALIFIER_ATTRIBUTE ) ;
3650 	    oe_debug_pub.add(  'QUALIFIER_ATTR_VALUE_FROM='|| OUT_REQ_QUAL_TBL ( I ) .QUALIFIER_ATTR_VALUE_FROM ) ;
3651 	    oe_debug_pub.add(  'QUALIFIER_ATTR_VALUE_TO='|| OUT_REQ_QUAL_TBL ( I ) .QUALIFIER_ATTR_VALUE_TO ) ;
3652 	    oe_debug_pub.add(  'COMPARISON_OPERATOR_CODE='|| OUT_REQ_QUAL_TBL ( I ) .COMPARISON_OPERATOR_CODE ) ;
3653 	    oe_debug_pub.add(  'VALIDATED_FLAG='||OUT_REQ_QUAL_TBL ( I ) .VALIDATED_FLAG ) ;
3654 	 END IF;
3655 
3656       end loop;
3657    end if;
3658 
3659 
3660    IF l_debug_level  > 0 THEN
3661       oe_debug_pub.add(  'COUNT LINE DETAIL QUAL TBL='|| OUT_REQ_LINE_DETAIL_QUAL_TBL.COUNT ) ;
3662    END IF;
3663 
3664    if out_req_line_detail_qual_tbl.count > 0 then
3665       for i in out_req_line_detail_qual_tbl.first..out_req_line_detail_qual_tbl.last
3666 	       loop
3667 	 IF l_debug_level  > 0 THEN
3668 	    oe_debug_pub.add(  '*******************************' ) ;
3669 	    oe_debug_pub.add(  'LINE DETAIL QUAL TABLE RECORD='||I ) ;
3670 	    oe_debug_pub.add(  'LINE_DETAIL_INDEX='|| OUT_REQ_LINE_DETAIL_QUAL_TBL ( I ) .LINE_DETAIL_INDEX ) ;
3671 	    oe_debug_pub.add(  'QUALIFIER_CONTEXT='|| OUT_REQ_LINE_DETAIL_QUAL_TBL ( I ) .QUALIFIER_CONTEXT ) ;
3672 	    oe_debug_pub.add(  'QUALIFIER_ATTRIBUTE='|| OUT_REQ_LINE_DETAIL_QUAL_TBL ( I ) .QUALIFIER_ATTRIBUTE ) ;
3673 	    oe_debug_pub.add(  'QUALIFIER_ATTR_VALUE_FROM='|| OUT_REQ_LINE_DETAIL_QUAL_TBL ( I ) .QUALIFIER_ATTR_VALUE_FROM ) ;
3674 	    oe_debug_pub.add(  'QUALIFIER_ATTR_VALUE_TO='|| OUT_REQ_LINE_DETAIL_QUAL_TBL ( I ) .QUALIFIER_ATTR_VALUE_TO ) ;
3675 	    oe_debug_pub.add(  'COMPARISON_OPERATOR_CODE='|| OUT_REQ_LINE_DETAIL_QUAL_TBL ( I ) .COMPARISON_OPERATOR_CODE ) ;
3676 	    oe_debug_pub.add(  'VALIDATED_FLAG='|| OUT_REQ_LINE_DETAIL_QUAL_TBL ( I ) .VALIDATED_FLAG ) ;
3677 	 END IF;
3678 
3679       end loop;
3680    end if;
3681 
3682 
3683    IF l_debug_level  > 0 THEN
3684       oe_debug_pub.add( 'EXITING PRICE_ITEM*******************************' ) ;
3685    END IF;
3686 
3687 EXCEPTION
3688    when others then
3689 
3690       IF l_debug_level  > 0 THEN
3691 	 oe_debug_pub.add(  'PRICE ITEM EXCEPTION WHEN OTHERS CODE='|| SQLCODE||' MESSAGE='||SQLERRM ) ;
3692 END IF;
3693 
3694 END price_item;
3695 
3696 PROCEDURE pass_values_to_backend (
3697 				  in_panda_rec_table in panda_rec_table)
3698 IS
3699 
3700 BEGIN
3701 
3702    g_panda_rec_table.delete;
3703    for i in in_panda_rec_table.first..in_panda_rec_table.last
3704       loop
3705       oe_debug_pub.add(' Line Record Nbr='||i);
3706 
3707       g_panda_rec_table(i):=in_panda_rec_table(i);
3708             oe_debug_pub.add('*******IT STARTS HERE*****');
3709 	    oe_debug_pub.add('index is'||i||' item is='||g_panda_rec_table(i).p_inventory_item_id);
3710 
3711       end loop;
3712 
3713 END pass_values_to_backend;
3714 
3715 
3716 
3717 PROCEDURE copy_attribs_to_Req(
3718        p_line_index number
3719       ,px_Req_line_attr_tbl in out nocopy  QP_PREQ_GRP.LINE_ATTR_TBL_TYPE
3720       ,px_Req_qual_tbl in out  nocopy  QP_PREQ_GRP.QUAL_TBL_TYPE
3721       ,p_pricing_contexts_Tbl  QP_Attr_Mapping_PUB.Contexts_Result_Tbl_Type
3722       ,p_qualifier_contexts_Tbl  QP_Attr_Mapping_PUB.Contexts_Result_Tbl_Type
3723 ) IS
3724 
3725 i pls_integer := 0;
3726 l_attr_index	pls_integer := nvl(px_Req_line_attr_tbl.last,0);
3727 l_qual_index	pls_integer := nvl(px_Req_qual_tbl.last,0);
3728 
3729 --
3730 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3731 --
3732 BEGIN
3733 
3734   IF l_debug_level  > 0 THEN
3735       oe_debug_pub.add(  'ENTERING OE_OE_AVAILABILITY.COPY_ATTRIBS_TO_REQ' , 1 ) ;
3736   END IF;
3737   i := p_pricing_contexts_Tbl.First;
3738   While i is not null loop
3739     l_attr_index := l_attr_index +1;
3740     px_Req_line_attr_tbl(l_attr_index).VALIDATED_FLAG := 'N';
3741     px_Req_line_attr_tbl(l_attr_index).line_index := p_line_index;
3742 
3743     -- Product and Pricing Contexts go into pricing contexts...
3744     px_Req_line_attr_tbl(l_attr_index).PRICING_CONTEXT :=
3745     p_pricing_contexts_Tbl(i).context_name;
3746     px_Req_line_attr_tbl(l_attr_index).PRICING_ATTRIBUTE :=
3747     p_pricing_contexts_Tbl(i).Attribute_Name;
3748     px_Req_line_attr_tbl(l_attr_index).PRICING_ATTR_VALUE_FROM :=
3749     p_pricing_contexts_Tbl(i).attribute_value;
3750 
3751     i := p_pricing_contexts_Tbl.Next(i);
3752   end loop;
3753 
3754   -- Copy the qualifiers
3755   i := p_qualifier_contexts_Tbl.First;
3756   While i is not null loop
3757     l_qual_index := l_qual_index +1;
3758 
3759     If p_qualifier_contexts_Tbl(i).context_name ='MODLIST' and
3760       p_qualifier_contexts_Tbl(i).Attribute_Name ='QUALIFIER_ATTRIBUTE4' then
3761 
3762       If OE_Order_PUB.G_Line.agreement_id is not null and
3763         OE_Order_PUB.G_Line.agreement_id <> fnd_api.g_miss_num then
3764         px_Req_Qual_Tbl(l_qual_index).Validated_Flag := 'Y';
3765       Else
3766         px_Req_Qual_Tbl(l_qual_index).Validated_Flag := 'N';
3767       End If;
3768 
3769     Else
3770       px_Req_Qual_Tbl(l_qual_index).Validated_Flag := 'N';
3771     End If;
3772 
3773     px_Req_qual_tbl(l_qual_index).line_index := p_line_index;
3774 
3775     px_Req_qual_tbl(l_qual_index).QUALIFIER_CONTEXT :=
3776     p_qualifier_contexts_Tbl(i).context_name;
3777     px_Req_qual_tbl(l_qual_index).QUALIFIER_ATTRIBUTE :=
3778     p_qualifier_contexts_Tbl(i).Attribute_Name;
3779     px_Req_qual_tbl(l_qual_index).QUALIFIER_ATTR_VALUE_FROM :=
3780     p_qualifier_contexts_Tbl(i).attribute_value;
3781 
3782     i := p_qualifier_contexts_Tbl.Next(i);
3783   end loop;
3784 
3785 IF l_debug_level  > 0 THEN
3786     oe_debug_pub.add(  'EXITING OE_OE_AVAILABILITY.COPY_ATTRIBS_TO_REQ' , 1 ) ;
3787 END IF;
3788 
3789 END copy_attribs_to_Req;
3790 
3791 
3792 
3793 
3794 PROCEDURE process_pricing_errors(in_line_type_code in varchar2,
3795                                  in_status_code    in varchar2,
3796                                  in_status_text    in varchar2,
3797                                  in_ordered_item    in varchar2,
3798                                  in_uom    in varchar2,
3799                                  in_unit_price    in number,
3800                                  in_adjusted_unit_price    in number,
3801                                  in_process_code    in varchar2 ,
3802                                  in_price_flag    in varchar2,
3803                                  in_price_list_id in number,
3804 l_return_status out nocopy varchar2,
3805 
3806 l_msg_count out nocopy number,
3807 
3808 l_msg_data out nocopy varchar2
3809 
3810                                  ) IS
3811 
3812 l_price_list varchar2(200);
3813 l_allow_negative_price varchar2(10):= nvl(OE_Sys_Parameters.VALUE('ONT_NEGATIVE_PRICING'),'N');
3814 l_gsa_violation_action Varchar2(30) :=fnd_profile.value('ONT_GSA_VIOLATION_ACTION');
3815 l_org_id Number:= OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');
3816 
3817 
3818 Cursor get_gsa_list_lines is
3819 Select/*+ ordered use_nl(qpq qppa qpll qplh) */ min(qpll.operand)
3820  From
3821       qp_qualifiers qpq
3822  ,    qp_pricing_attributes qppa
3823  ,    qp_list_lines qpll
3824  ,    qp_list_headers_b qplh
3825  ,    qp_price_req_sources qpprs
3826  where
3827  qpq.qualifier_context='CUSTOMER'
3828  and qpq.qualifier_attribute='QUALIFIER_ATTRIBUTE15'
3829  and qpq.qualifier_attr_value='Y'
3830  and qppa.list_header_id=qplh.list_header_id
3831  and qplh.Active_flag='Y'
3832  and qpprs.request_type_code = 'ONT'
3833  and qpprs.source_system_code=qplh.source_system_code
3834  and    qppa.pricing_phase_id  = 2
3835  and    qppa.qualification_ind = 6
3836  and qppa.product_attribute_context ='ITEM'
3837  and qppa.product_attribute='PRICING_ATTRIBUTE1'
3838  and qppa.product_attr_value= g_panda_rec_table(1).p_inventory_item_id
3839  and qppa.excluder_flag = 'N'
3840  and qppa.list_header_id=qpq.list_header_id
3841  and qppa.list_line_id=qpll.list_line_id
3842  and  g_panda_rec_table(1).p_pricing_date between nvl(trunc(qplh.start_date_active),g_panda_rec_table(1).p_pricing_date)
3843  and nvl(trunc(qplh.End_date_active),g_panda_rec_table(1).p_pricing_date);
3844 
3845 l_operand  number;
3846 l_msg_text Varchar2(2000);
3847 
3848 --
3849 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3850 --
3851 BEGIN
3852 
3853   IF l_debug_level  > 0 THEN
3854       oe_debug_pub.add(  'ENTERING PROCESS_PRICING_ERRORS' ) ;
3855   END IF;
3856                    IF l_debug_level  > 0 THEN
3857  oe_debug_pub.add(  'LINE_TYPE_CODE='||IN_LINE_TYPE_CODE|| ' STATUS CODE='||IN_STATUS_CODE|| ' NEGATIVE PRICE ='||L_ALLOW_NEGATIVE_PRICE|| ' IN_UNIT_PRICE ='||IN_UNIT_PRICE|| ' IN_ADJUSTED_UNIT_PRICE ='||IN_ADJUSTED_UNIT_PRICE ) ;
3858                    END IF;
3859 
3860 
3861   IF in_line_Type_code ='LINE' and
3862     in_status_code in ( QP_PREQ_GRP.G_STATUS_INVALID_PRICE_LIST,
3863                         QP_PREQ_GRP.G_STS_LHS_NOT_FOUND,
3864                         QP_PREQ_GRP.G_STATUS_FORMULA_ERROR,
3865                         QP_PREQ_GRP.G_STATUS_OTHER_ERRORS,
3866                         FND_API.G_RET_STS_UNEXP_ERROR,
3867                         FND_API.G_RET_STS_ERROR,
3868                         QP_PREQ_GRP.G_STATUS_CALC_ERROR,
3869                         QP_PREQ_GRP.G_STATUS_UOM_FAILURE,
3870                         QP_PREQ_GRP.G_STATUS_INVALID_UOM,
3871                         QP_PREQ_GRP.G_STATUS_DUP_PRICE_LIST,
3872                         QP_PREQ_GRP.G_STATUS_INVALID_UOM_CONV,
3873                         QP_PREQ_GRP.G_STATUS_INVALID_INCOMP,
3874                         QP_PREQ_GRP.G_STATUS_BEST_PRICE_EVAL_ERROR)
3875   then
3876 
3877     l_return_status := 'E';
3878 
3879     IF in_price_list_id is not null then
3880       Begin
3881         Select name into l_price_list
3882           from qp_list_headers_vl
3883          where list_header_id = in_price_list_id;
3884       Exception When No_data_found then
3885         l_price_list := in_price_list_id;
3886       End;
3887     END IF;
3888 
3889     IF in_status_code  = QP_PREQ_GRP.G_STATUS_INVALID_PRICE_LIST then
3890 
3891                       IF l_debug_level  > 0 THEN
3892                           oe_debug_pub.add(  'INVALID PRICE LIST'|| ' PRICE_LIST_ID='||G_panda_rec_table(1).p_PRICE_LIST_ID ) ;
3893                       END IF;
3894       IF g_panda_rec_table(1).p_price_list_id is null then
3895 
3896         FND_MESSAGE.SET_NAME('ONT','ONT_AVAIL_GENERIC');
3897         FND_MESSAGE.SET_TOKEN('TEXT',in_status_text);
3898         IF l_debug_level  > 0 THEN
3899             oe_debug_pub.add(  'INVALID PL ERR TXT='||IN_STATUS_TEXT ) ;
3900         END IF;
3901         OE_MSG_PUB.Add;
3902 
3903       ELSE
3904         IF l_debug_level  > 0 THEN
3905             oe_debug_pub.add(  'INVALID PRICE LIST' ) ;
3906         END IF;
3907         FND_MESSAGE.SET_NAME('ONT','OE_PRC_NO_LIST_PRICE');
3908         FND_MESSAGE.SET_TOKEN('ITEM',in_Ordered_Item);
3909         FND_MESSAGE.SET_TOKEN('UNIT',in_uom);
3910         FND_MESSAGE.SET_TOKEN('PRICE_LIST',l_Price_List);
3911         OE_MSG_PUB.Add;
3912 
3913       END IF;
3914 
3915     ELSIF in_status_code = QP_PREQ_GRP.G_STS_LHS_NOT_FOUND Then
3916 
3917       FND_MESSAGE.SET_NAME('ONT','ONT_NO_PRICE_LIST_FOUND');
3918       FND_MESSAGE.SET_TOKEN('ITEM',in_Ordered_Item);
3919       FND_MESSAGE.SET_TOKEN('UOM',in_uom);
3920       OE_MSG_PUB.Add;
3921 
3922     ELSIF in_status_code = QP_PREQ_GRP.G_STATUS_FORMULA_ERROR then
3923       FND_MESSAGE.SET_NAME('ONT','ONT_PRC_ERROR_IN_FORMULA');
3924       OE_MSG_PUB.Add;
3925 
3926     ELSIF in_status_code in
3927     ( QP_PREQ_GRP.G_STATUS_OTHER_ERRORS , FND_API.G_RET_STS_UNEXP_ERROR,
3928       FND_API.G_RET_STS_ERROR) then
3929       FND_MESSAGE.SET_NAME('ONT','ONT_PRICING_ERRORS'); --bug#7149497
3930       FND_MESSAGE.SET_TOKEN('ERR_TEXT',in_status_text);
3931       OE_MSG_PUB.Add;
3932 
3933     ELSIF in_status_code = QP_PREQ_GRP.G_STATUS_INVALID_UOM then
3934       FND_MESSAGE.SET_NAME('ONT','ONT_PRC_INVALID_UOM');
3935       FND_MESSAGE.SET_TOKEN('ITEM',in_Ordered_Item);
3936       FND_MESSAGE.SET_TOKEN('UOM',in_uom);
3937       OE_MSG_PUB.Add;
3938 
3939     ElSIF in_status_code = QP_PREQ_GRP.G_STATUS_DUP_PRICE_LIST then
3940       FND_MESSAGE.SET_NAME('ONT','ONT_PRC_DUPLICATE_PRICE_LIST');
3941 
3942       IF l_debug_level  > 0 THEN
3943           oe_debug_pub.add(  'DUPLICATE PRICE LIST ERROR' ) ;
3944       END IF;
3945       Begin
3946         Select name into l_price_list
3947         from qp_list_headers_vl a,qp_list_lines b where
3948         b.list_line_id =  to_number(substr(in_status_text,1,
3949         instr(in_status_text,',')-1))
3950         and a.list_header_id=b.list_header_id ;
3951       Exception When No_data_found then
3952         l_price_list := to_number(substr(in_status_text,1,
3953         instr(in_status_text,',')-1));
3954       When invalid_number then
3955         l_price_list := substr(in_status_text,1,
3956         instr(in_status_text,',')-1);
3957       End;
3958 
3959       IF l_debug_level  > 0 THEN
3960           oe_debug_pub.add(  'PRICE LIST 1='||L_PRICE_LIST ) ;
3961       END IF;
3962       FND_MESSAGE.SET_TOKEN('PRICE_LIST1','( '||in_Ordered_Item||' ) '|| l_price_list);
3963       Begin
3964         Select name into l_price_list
3965         from qp_list_headers_vl a,qp_list_lines b where
3966         b.list_line_id =  to_number(substr(in_status_text,
3967         instr(in_status_text,',')+1))
3968         and a.list_header_id=b.list_header_id	;
3969       Exception When No_data_found then
3970         l_price_list := to_number(substr(in_status_text,
3971         instr(in_status_text,',')+1));
3972       When invalid_number then
3973         l_price_list := substr(in_status_text,
3974         instr(in_status_text,',')+1);
3975       End;
3976       IF l_debug_level  > 0 THEN
3977           oe_debug_pub.add(  'PRICE LIST 2='||L_PRICE_LIST ) ;
3978       END IF;
3979 
3980       FND_MESSAGE.SET_TOKEN('PRICE_LIST2',l_price_list);
3981       OE_MSG_PUB.Add;
3982 
3983     ELSIF in_status_code = QP_PREQ_GRP.G_STATUS_INVALID_UOM_CONV then
3984       FND_MESSAGE.SET_NAME('ONT','ONT_PRC_INVALID_UOM_CONVERSION');
3985       FND_MESSAGE.SET_TOKEN('UOM_TEXT','( '||in_Ordered_Item||' ) '||
3986 				in_status_text);
3987       OE_MSG_PUB.Add;
3988 
3989     ElSIF in_status_code = QP_PREQ_GRP.G_STATUS_INVALID_INCOMP then
3990       FND_MESSAGE.SET_NAME('ONT','ONT_PRC_INVALID_INCOMP');
3991       FND_MESSAGE.SET_TOKEN('ERR_TEXT','( '||in_Ordered_Item||' ) '||
3992                            in_status_text);
3993       OE_MSG_PUB.Add;
3994 
3995     ELSIF in_status_code = QP_PREQ_GRP.G_STATUS_BEST_PRICE_EVAL_ERROR then
3996       FND_MESSAGE.SET_NAME('ONT','ONT_PRC_BEST_PRICE_ERROR');
3997       FND_MESSAGE.SET_TOKEN('ITEM',in_Ordered_Item);
3998       FND_MESSAGE.SET_TOKEN('ERR_TEXT',in_status_text);
3999       OE_MSG_PUB.Add;
4000     END IF;
4001 
4002 
4003   /*elsif ( in_unit_price < 0 or in_Adjusted_unit_price < 0) and
4004           l_allow_negative_price = 'N' then
4005 
4006     oe_debug_pub.add('Error as Negative Pricing is not Allowed');
4007     FND_MESSAGE.SET_NAME('ONT','ONT_NEGATIVE_PRICE');
4008     FND_MESSAGE.SET_TOKEN('ITEM',in_Ordered_Item);
4009     FND_MESSAGE.SET_TOKEN('LIST_PRICE',in_unit_price);
4010     FND_MESSAGE.SET_TOKEN('SELLING_PRICE',in_Adjusted_unit_price);
4011     OE_MSG_PUB.Add;
4012     --FND_MESSAGE.SET_NAME('ONT','ONT_NEGATIVE_MODIFIERS');
4013     --FND_MESSAGE.SET_TOKEN('LIST_LINE_NO',get_list_lines(g_line_id));
4014     --OE_MSG_PUB.Add;
4015     l_return_status := 'E';
4016     --RAISE FND_API.G_EXC_ERROR;*/
4017 
4018   ELSIF in_line_Type_code ='LINE' and
4019    in_status_code = QP_PREQ_GRP.G_STATUS_OTHER_ERRORS Then
4020 
4021     IF l_debug_level  > 0 THEN
4022         oe_debug_pub.add(  'OE_PRICING_ERROR' ) ;
4023     END IF;
4024     FND_MESSAGE.SET_NAME('ONT','OE_PRICING_ERROR');
4025     FND_MESSAGE.SET_TOKEN('ERR_TEXT','( '||in_Ordered_Item||' ) '||in_STATUS_TEXT);
4026     OE_MSG_PUB.Add;
4027 
4028   ELSIF in_line_Type_code ='LINE' and in_status_code in
4029              --( QP_PREQ_GRP.G_STATUS_UPDATED,
4030                (QP_PREQ_GRP.G_STATUS_GSA_VIOLATION) and
4031              --  QP_PREQ_GRP.G_STATUS_UNCHANGED) and
4032 	   nvl(in_process_code,'0') <> QP_PREQ_GRP.G_BY_ENGINE
4033 	   and in_price_flag IN ('Y','P')
4034       --we do not want to go in this loop if price_flag is set up 'N' because
4035       --engine doesn't look at the line and will not return adjustments. In this
4036       --case we DON't want to remove the adjustments that engine doesn't return.
4037     then
4038       IF l_debug_level  > 0 THEN
4039           oe_debug_pub.add(  'OE_PRICING_ERROR 2' ) ;
4040       END IF;
4041 
4042       IF in_status_text is not null then
4043         l_return_status := 'E';
4044         FND_MESSAGE.SET_NAME('ONT','ONT_PRICING_ERRORS'); --bug#7149497
4045         FND_MESSAGE.SET_TOKEN('ERR_TEXT',in_status_text);
4046         OE_MSG_PUB.Add;
4047       END IF;
4048 
4049       -- we need to do this check in UPDATED code or do the gsa check through
4050       -- the control record of Pricing
4051       /*OPEN get_gsa_list_lines;
4052       FETCH get_gsa_list_lines
4053        INTO l_operand;
4054       CLOSE get_gsa_list_lines;
4055       oe_debug_pub.add('After select OE_PRICING_ERROR 2');
4056       oe_debug_pub.add('Adj price='||in_adjusted_unit_price||
4057                        ' Operand='||l_operand);
4058 
4059       IF in_adjusted_unit_price <= l_operand then
4060         oe_debug_pub.add('If unit price less than operand violation='||
4061                           l_gsa_violation_action);
4062         --Check if the GSA check needs to be done.
4063         If l_gsa_violation_action in ('WARNING','ERROR') then
4064 
4065           oe_debug_pub.add('GSA warning or error');
4066           Begin
4067             SELECT concatenated_segments
4068               INTO l_msg_text
4069               FROM mtl_system_items_kfv
4070              WHERE inventory_item_id = g_inventory_item_id
4071                AND organization_id = l_org_id;
4072           Exception
4073             when no_data_found then
4074             Null;
4075           End;
4076 
4077           l_return_status := 'E';
4078           oe_debug_pub.add('GSA warning or error 2 msg_Text='||l_msg_text);
4079           FND_MESSAGE.SET_NAME('ONT','OE_GSA_VIOLATION');
4080           l_msg_text := l_operand||' ( '||l_msg_text||' )';
4081           FND_MESSAGE.SET_TOKEN('GSA_PRICE',l_msg_text);
4082           OE_MSG_PUB.Add;
4083         END IF;
4084       END IF; */
4085 
4086 
4087   ELSIF  -- Process header level adjustments
4088     in_line_type_code ='ORDER' and
4089     (in_status_code in ( QP_PREQ_GRP.G_STATUS_UPDATED ,
4090                          QP_PREQ_GRP.G_STATUS_GSA_VIOLATION)
4091      --In this case even engine doesn't update the order (status = UNCHANGED)
4092      --because of one of the lined is frozen,
4093      --there can be some order level adjustments in database which
4094      --need to be pulled out by append_adjustment_lines routine
4095       or (in_status_code = QP_PREQ_GRP.G_STATUS_UNCHANGED))
4096 	Then
4097     IF l_debug_level  > 0 THEN
4098         oe_debug_pub.add(  'OE_PRICING_ERROR 3' ) ;
4099     END IF;
4100     null;
4101 
4102   ELSIF in_line_Type_code ='LINE' and in_status_code = 'UPDATED' then
4103 
4104     IF l_debug_level  > 0 THEN
4105         oe_debug_pub.add(  'STATUS = UPDATED' ) ;
4106     END IF;
4107 
4108   END IF;-- Status_Code
4109 
4110 
4111   IF l_debug_level  > 0 THEN
4112       oe_debug_pub.add(  'PROCESS PRICING ERROR AFTER ERR CHK ST='||L_RETURN_STATUS ) ;
4113   END IF;
4114 
4115   IF l_return_status ='E' then
4116     IF l_debug_level  > 0 THEN
4117         oe_debug_pub.add(  'DOING COUNT_AND_GET' ) ;
4118     END IF;
4119     oe_msg_pub.count_and_get(p_encoded=>fnd_api.G_TRUE,
4120                              p_count => l_msg_count,
4121                              p_data=>l_msg_data
4122                                     );
4123   END IF;
4124 
4125   IF l_debug_level  > 0 THEN
4126       oe_debug_pub.add(  'EXITING PROCESS_PRICING_ERRORS' ) ;
4127   END IF;
4128 
4129 EXCEPTION
4130 
4131   when others then
4132                         IF l_debug_level  > 0 THEN
4133                             oe_debug_pub.add(  'PROCESS PRICING ERRORS WHEN OTHERS EXCEPTION CODE='|| SQLCODE||' MESSAGE='||SQLERRM ) ;
4134                         END IF;
4135 
4136 END process_pricing_errors;
4137 
4138 
4139 
4140 FUNCTION Get_Rounding_factor(p_list_header_id number) return number is
4141 
4142 l_rounding_factor number;
4143 
4144 --
4145 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4146 --
4147 BEGIN
4148 
4149     select rounding_factor
4150       into l_rounding_factor
4151       from qp_list_headers_b
4152      where list_header_id = p_list_header_id;
4153 
4154     If l_rounding_factor = fnd_api.g_miss_num then
4155       l_rounding_factor:= Null;
4156     End If;
4157 
4158     Return l_rounding_factor;
4159 
4160 
4161 EXCEPTION
4162     when no_data_found then
4163         Return Null;
4164 END Get_Rounding_factor;
4165 
4166 
4167 
4168 PROCEDURE Get_modifier_name( in_list_header_id in number
4169 ,out_name out nocopy varchar2
4170 
4171 ,out_description out nocopy varchar2
4172 
4173 ,out_end_date out nocopy date
4174 
4175 ,out_start_date out nocopy date
4176 
4177 ,out_currency out nocopy varchar2
4178 
4179 ,out_ask_for_flag out nocopy varchar2
4180 
4181                            ) IS
4182 
4183 
4184 l_list_type_code varchar2(300);
4185 
4186 --
4187 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4188 --
4189 BEGIN
4190 
4191     SELECT name,
4192            description,
4193            list_type_code,
4194            end_date_active,
4195            start_date_active,
4196            currency_code,
4197            ask_for_flag
4198       INTO out_name,
4199            out_description,
4200            l_list_type_code,
4201            out_end_date,
4202            out_start_date,
4203            out_currency,
4204            out_ask_for_flag
4205 
4206       FROM qp_list_headers_vl
4207      WHERE list_header_id = in_list_header_id;
4208 
4209 
4210                      IF l_debug_level  > 0 THEN
4211                          oe_debug_pub.add(  'END_DATE='||OUT_END_DATE|| ' START_DATE='||OUT_START_DATE ) ;
4212                      END IF;
4213     IF l_debug_level  > 0 THEN
4214         oe_debug_pub.add(  'EXITING OE_AVA.GET_MODIFIER_NAME TYP='||L_LIST_TYPE_CODE ) ;
4215     END IF;
4216 
4217 EXCEPTION
4218     when no_data_found then
4219         IF l_debug_level  > 0 THEN
4220             oe_debug_pub.add(  'OE_AVAILABILITY.GET_MODIFIER_NAME NO DATA FOUND' ) ;
4221         END IF;
4222     when others then
4223                         IF l_debug_level  > 0 THEN
4224                             oe_debug_pub.add(  'OE_AVAILABILITY.GET_MODIFIER_NAME WHEN OTHERS '|| SQLERRM||SQLCODE ) ;
4225                         END IF;
4226 
4227 END get_modifier_name;
4228 
4229 
4230 
4231 PROCEDURE Get_list_line_details( in_list_line_id in number
4232 ,out_end_date out nocopy date
4233 
4234 ,out_start_date out nocopy date
4235 
4236 ,out_list_line_type_Code out nocopy varchar2
4237 
4238 ,out_modifier_level_code out nocopy varchar2
4239 
4240                            ) IS
4241 
4242 --
4243 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4244 --
4245 BEGIN
4246 
4247     SELECT
4248            list_line_type_code,
4249            end_date_active,
4250            start_date_active,
4251            modifier_level_code
4252       INTO
4253            out_list_line_type_code,
4254            out_end_date,
4255            out_start_date,
4256            out_modifier_level_code
4257 
4258       FROM qp_list_lines
4259      WHERE list_line_id = in_list_line_id;
4260 
4261 
4262                      IF l_debug_level  > 0 THEN
4263                          oe_debug_pub.add(  'EXITING OE_AVA.GET_LINE_DETAILS TYPE='|| 'LIST_LINE_TYPE_CODE='|| OUT_LIST_LINE_TYPE_CODE|| 'END_DATE='||OUT_END_DATE|| ' START_DATE='||OUT_START_DATE ) ;
4264                      END IF;
4265 
4266 EXCEPTION
4267     when no_data_found then
4268         IF l_debug_level  > 0 THEN
4269             oe_debug_pub.add(  'OE_AVAILABILITY.GET_LIST_LINE_DETAILS NO DATA FOUND' ) ;
4270         END IF;
4271     when others then
4272                         IF l_debug_level  > 0 THEN
4273                             oe_debug_pub.add(  'OE_AVAILABILITY.GET_LIST_LINE_DETAILS WHEN OTHERS '|| SQLERRM||SQLCODE ) ;
4274                         END IF;
4275 
4276 END get_list_line_details;
4277 
4278 
4279 FUNCTION Get_qp_lookup_meaning( in_lookup_code in varchar2,
4280                                 in_lookup_type in varchar2) return varchar2 IS
4281 
4282 l_meaning varchar2(300);
4283 
4284 --
4285 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4286 --
4287 BEGIN
4288 
4289     IF l_debug_level  > 0 THEN
4290         oe_debug_pub.add(  'CODE='||IN_LOOKUP_CODE||' TYPE='||IN_LOOKUP_TYPE ) ;
4291     END IF;
4292 
4293     SELECT meaning
4294       INTO l_meaning
4295       FROM qp_lookups
4296      WHERE lookup_type = in_lookup_type
4297        AND lookup_code = in_lookup_code;
4298 
4299     IF l_meaning = fnd_api.g_miss_char then
4300       l_meaning:= Null;
4301     END IF;
4302 
4303     Return l_meaning;
4304 
4305 EXCEPTION
4306     when no_data_found then
4307         IF l_debug_level  > 0 THEN
4308             oe_debug_pub.add(  'OE_AVAILABILITY.GET_QP_LOOKUP_MEANING NO DATA FOUND' ) ;
4309         END IF;
4310         Return Null;
4311 
4312 END get_qp_lookup_meaning;
4313 
4314 
4315 FUNCTION get_pricing_attribute(
4316                        in_CONTEXT_NAME in varchar2,
4317                        in_ATTRIBUTE_NAME in varchar2
4318                                           ) return varchar2 IS
4319 l_pricing_attribute varchar2(300);
4320 
4321 --
4322 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4323 --
4324 BEGIN
4325 
4326                     IF l_debug_level  > 0 THEN
4327                         oe_debug_pub.add(  'GET_PRICING_ATTRIBUTE '|| 'IN_CONTEXT = '||IN_CONTEXT_NAME|| 'IN_ATTRIBUTE_NAME='||IN_ATTRIBUTE_NAME ) ;
4328                     END IF;
4329     l_pricing_attribute := QP_UTIL.get_attribute_name(
4330               p_application_short_name=> 'QP',
4331               P_FLEXFIELD_NAME =>'QP_ATTR_DEFNS_PRICING',
4332               P_CONTEXT_NAME =>in_context_name,
4333               P_ATTRIBUTE_NAME =>in_attribute_name
4334                       );
4335     IF l_debug_level  > 0 THEN
4336         oe_debug_pub.add(  'EXITING GET_PRICING_ATTRIBUTE ='||L_PRICING_ATTRIBUTE ) ;
4337     END IF;
4338 
4339     return l_pricing_attribute;
4340 
4341 EXCEPTION
4342 
4343   WHEN others then
4344                      IF l_debug_level  > 0 THEN
4345                          oe_debug_pub.add(  'WHEN OTHERS FOR GET_PRICING_ATTRIBUTE'|| SQLCODE||SQLERRM ) ;
4346                      END IF;
4347     return null;
4348 
4349 END get_pricing_attribute;
4350 
4351 
4352 
4353 PROCEDURE get_Price_List_info(
4354                           p_price_list_id IN  NUMBER,
4355 out_name out nocopy varchar2,
4356 
4357 out_end_date out nocopy date,
4358 
4359 out_start_date out nocopy date,
4360 
4361 out_automatic_flag out nocopy varchar2,
4362 
4363 out_rounding_factor out nocopy varchar2,
4364 
4365 out_terms_id out nocopy number,
4366 
4367 out_gsa_indicator out nocopy varchar2,
4368 
4369 out_currency out nocopy varchar2,
4370 
4371 out_freight_terms_code out nocopy varchar2
4372 
4373                          ) IS
4374 
4375 --
4376 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4377 --
4378 BEGIN
4379 
4380     IF l_debug_level  > 0 THEN
4381         oe_debug_pub.add(  'GET PRICE_LIST ID='||P_PRICE_LIST_ID ) ;
4382     END IF;
4383 
4384     IF p_price_list_id IS NOT NULL THEN
4385 
4386         SELECT  NAME,
4387                 end_date_active,
4388                 start_date_active,
4389                 automatic_flag,
4390                 rounding_factor,
4391                 terms_id,
4392                 gsa_indicator,
4393                 currency_code,
4394                 freight_terms_code
4395         INTO    out_name,
4396                 out_end_date,
4397                 out_start_date,
4398                 out_automatic_flag,
4399                 out_rounding_factor,
4400                 out_terms_id,
4401                 out_gsa_indicator,
4402                 out_currency,
4403                 out_freight_terms_code
4404 
4405         FROM    qp_list_headers_vl
4406         WHERE   list_header_id = p_price_list_id
4407           and   list_type_code in ('PRL', 'AGR');
4408 
4409     END IF;
4410 
4411                      IF l_debug_level  > 0 THEN
4412                          oe_debug_pub.add(  'END_DATE='||OUT_END_DATE|| ' START_DATE='||OUT_START_DATE ) ;
4413                      END IF;
4414 
4415 EXCEPTION
4416 
4417     WHEN NO_DATA_FOUND THEN
4418         IF l_debug_level  > 0 THEN
4419             oe_debug_pub.add(  'NO DATA FOUND GET PRICE LIST_INFO' ) ;
4420         END IF;
4421 
4422     WHEN OTHERS THEN
4423                          IF l_debug_level  > 0 THEN
4424                              oe_debug_pub.add(  'WHEN OTHERS GET PRICE LIST_INFO'|| SQLCODE||SQLERRM ) ;
4425                          END IF;
4426 
4427 END get_Price_List_info;
4428 
4429 
4430 
4431 
4432 PROCEDURE  get_item_information(
4433             in_inventory_item_id in number
4434            ,in_org_id in number
4435 ,out_item_status out nocopy varchar2
4436 
4437 ,out_wsh out nocopy varchar2
4438 
4439 ,out_wsh_name out nocopy varchar2
4440 
4441 ,out_category out nocopy varchar2
4442 
4443 ,out_lead_time out nocopy number
4444 
4445 ,out_cost out nocopy number
4446 
4447 ,out_primary_uom out nocopy varchar2
4448 
4449 ,out_user_item_type out nocopy varchar2
4450 
4451 ,out_make_or_buy out nocopy varchar2
4452 
4453 ,out_weight_uom out nocopy varchar2
4454 
4455 ,out_unit_weight out nocopy number
4456 
4457 ,out_volume_uom out nocopy varchar2
4458 
4459 ,out_unit_volume out nocopy number
4460 
4461 ,out_min_order_quantity out nocopy number
4462 
4463 ,out_max_order_quantity out nocopy number
4464 
4465 ,out_fixed_order_quantity out nocopy number
4466 
4467 ,out_customer_order_flag out nocopy varchar2
4468 
4469 ,out_internal_order_flag out nocopy varchar2
4470 
4471 ,out_stockable out nocopy varchar2
4472 
4473 ,out_reservable out nocopy varchar2
4474 
4475 ,out_returnable out nocopy varchar2
4476 
4477 ,out_shippable out nocopy varchar2
4478 
4479 ,out_orderable_on_web out nocopy varchar2
4480 
4481 ,out_taxable out nocopy varchar2
4482 
4483 ,out_serviceable out nocopy varchar2
4484 
4485 ,out_atp_flag out nocopy varchar2
4486 
4487           ) IS
4488 
4489   CURSOR c_item_info IS
4490     SELECT shippable_item_flag,
4491            customer_order_enabled_flag,
4492            internal_order_enabled_flag,
4493            stock_enabled_flag,
4494            default_shipping_org,
4495            returnable_flag,
4496            source_organization_id,
4497            unit_weight,
4498            weight_uom_code,
4499            unit_volume,
4500            volume_uom_code,
4501            cum_manufacturing_lead_time,
4502            cumulative_total_lead_time,
4503            primary_unit_of_measure,
4504            inventory_item_status_code,
4505            full_lead_time,
4506            order_cost,
4507            minimum_order_quantity,
4508            maximum_order_quantity,
4509            fixed_order_quantity,
4510            reservable_type,
4511            item_type,
4512            orderable_on_web_flag,
4513            planning_make_buy_code,
4514            taxable_flag ,
4515            serviceable_product_flag,
4516            atp_flag
4517       FROM mtl_system_items
4518      WHERE inventory_item_id = in_inventory_item_id
4519        AND organization_id   = in_org_id;
4520 
4521  l_default_shipping_org number;
4522  l_source_organization_id number;
4523  l_weight_uom_code varchar2(3);
4524  l_volumne_uom_code varchar2(3);
4525  l_cum_manufactureing_lead_time number;
4526  l_cummulative_total_lead_time number;
4527  l_inventory_item_status_code varchar2(10);
4528  l_full_lead_time number;
4529  l_order_cost number;
4530  l_reservable_type number;
4531  l_user_item_type varchar2(30);
4532  l_ship_from_org varchar2(200);
4533  l_ship_from_org_name varchar2(200);
4534  l_make_buy number;
4535 
4536   --
4537   l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4538   --
4539 BEGIN
4540 
4541                   IF l_debug_level  > 0 THEN
4542                       oe_debug_pub.add(  'ENTERING OE_OE_AVAILABILITY.GET_ITEM_INFO'||
4543 					 'INV_ITEM_ID='||IN_INVENTORY_ITEM_ID|| 'ORG_ID='||IN_ORG_ID ) ;
4544                   END IF;
4545 
4546   OPEN  c_item_info;
4547   FETCH c_item_info
4548    INTO out_shippable,
4549         out_customer_order_flag,
4550         out_internal_order_flag,
4551         out_stockable,
4552         l_default_shipping_org,
4553         out_returnable,
4554         l_source_organization_id,
4555         out_unit_weight,
4556         l_weight_uom_code,
4557         out_unit_volume,
4558         l_volumne_uom_code,
4559         l_cum_manufactureing_lead_time,
4560         l_cummulative_total_lead_time,
4561         out_primary_uom,
4562         l_inventory_item_status_code,
4563         l_full_lead_time,
4564         l_order_cost,
4565         out_min_order_quantity,
4566         out_max_order_quantity,
4567         out_fixed_order_quantity,
4568         l_reservable_type,
4569         l_user_item_type,
4570         out_orderable_on_web,
4571         l_make_buy,
4572         out_taxable,
4573         out_serviceable,
4574         out_atp_flag;
4575 
4576   CLOSE c_item_Info;
4577 
4578   out_item_status := l_inventory_item_status_code;
4579 
4580   IF l_make_buy = 1 then
4581     out_make_or_buy := 'Make';
4582   ELSE
4583     out_make_or_buy := 'Buy';
4584   END IF;
4585 
4586 
4587   oe_oe_availability.get_Ship_From_Org
4588          (   in_org_id => in_org_id
4589          ,   out_code=>out_wsh
4590          ,   out_name =>out_wsh_name
4591           );
4592 
4593   IF l_debug_level  > 0 THEN
4594       oe_debug_pub.add(  'USER_ITEM_TYPE='||L_USER_ITEM_TYPE ) ;
4595   END IF;
4596 
4597   out_lead_time := l_cummulative_total_lead_time;
4598   out_cost := l_order_cost;
4599 
4600   IF l_reservable_type = 1 then
4601     out_reservable := 'Y';
4602   ELSE
4603     out_reservable := 'N';
4604 
4605   END IF;
4606 
4607   IF l_user_item_type is NOT NULL then
4608     select meaning
4609       into out_user_item_type
4610       from fnd_common_lookups
4611      where lookup_type = 'ITEM_TYPE'
4612        and lookup_code = l_user_item_type;
4613   ELSE
4614     out_user_item_type := null;
4615 
4616   END IF;
4617                   IF l_debug_level  > 0 THEN
4618                       oe_debug_pub.add(  'EXITING OE_OE_AVAILABILITY.GET_ITEM_INFO'||
4619 					 ' ITEM_STATUS ='||OUT_ITEM_STATUS ) ;
4620                   END IF;
4621 
4622 EXCEPTION
4623 
4624   WHEN OTHERS THEN
4625     IF c_item_info%ISOPEN then
4626       CLOSE c_item_info;
4627     END IF;
4628 
4629                      IF l_debug_level  > 0 THEN
4630                          oe_debug_pub.add(  'WHEN OTHERS OE_OE_AVAILABILITY.GET_ITEM_INFO '||
4631 					    'INV_ITEM_ID='||IN_INVENTORY_ITEM_ID|| 'ORG_ID='||IN_ORG_ID||
4632 					    'SQLCODE='||SQLCODE|| 'SQLERRM='||SQLERRM ) ;
4633                      END IF;
4634 
4635 END get_item_information;
4636 
4637 
4638 
4639 PROCEDURE print_time(in_place in varchar2) IS
4640 
4641  cursor c_hsecs is
4642    select hsecs
4643      from v$timer;
4644 
4645 l_hsecs number;
4646 l_total number;
4647 
4648 --
4649 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4650 --
4651 BEGIN
4652 
4653   --print_time2;
4654   OPEN c_hsecs;
4655   FETCH c_hsecs
4656    INTO l_hsecs;
4657   CLOSE c_hsecs;
4658 
4659   IF g_hsecs is null then
4660 
4661     g_hsecs := l_hsecs;
4662     g_place := in_place;
4663     IF l_debug_level  > 0 THEN
4664         oe_debug_pub.add(  'TIME STARTING AT PLACE '||G_PLACE||' TIME='||G_HSECS ) ;
4665     END IF;
4666 
4667   ELSE
4668     l_total := (l_hsecs - g_hsecs)/100;
4669     g_total := g_total + l_total;
4670                       IF l_debug_level  > 0 THEN
4671                           oe_debug_pub.add(  'TIME FROM ' ||G_PLACE||' TO '||IN_PLACE||
4672 					     ' TIME DIFF='|| L_TOTAL||' SECONDS'||' TOTAL SO FAR='||G_TOTAL ) ;
4673                       END IF;
4674     g_hsecs := l_hsecs;
4675     g_place := in_place;
4676 
4677   END IF;
4678   --print_time2;
4679 
4680 END print_time;
4681 
4682 
4683 PROCEDURE print_time2 IS
4684 
4685  cursor c2_hsecs is
4686    select hsecs
4687      from v$timer;
4688 
4689 l_hsecs number;
4690 l_total number;
4691 
4692 --
4693 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4694 --
4695 BEGIN
4696 
4697   OPEN c2_hsecs;
4698   FETCH c2_hsecs
4699    INTO l_hsecs;
4700   CLOSE c2_hsecs;
4701 
4702   IF g_total2 is null then
4703     IF l_debug_level  > 0 THEN
4704         oe_debug_pub.add(  'G_TOTAL2 IS NULL L_HSECS='||L_HSECS ) ;
4705     END IF;
4706     g_total2 := l_hsecs;
4707   ELSE
4708     IF l_debug_level  > 0 THEN
4709         oe_debug_pub.add(  'L_HSECS='||L_HSECS||' TOTAL2='||G_TOTAL2 ) ;
4710     END IF;
4711     l_total := (l_hsecs - g_total2)/100;
4712     IF l_debug_level  > 0 THEN
4713         oe_debug_pub.add(  'G_TOTAL2='||L_TOTAL ) ;
4714     END IF;
4715     g_total2 := l_hsecs;
4716   END IF;
4717 
4718 END print_time2;
4719 
4720 
4721 PROCEDURE get_global_availability (
4722                 in_customer_id in number
4723                ,in_customer_site_id in number
4724                ,in_inventory_item_id in number
4725                ,in_org_id            in number
4726                ,x_return_status out nocopy varchar2
4727                ,x_msg_data out nocopy varchar2
4728                ,x_msg_count out nocopy number
4729                ,l_source_orgs_table out nocopy source_orgs_table
4730                            )IS
4731 
4732 l_instance_id number;
4733 CURSOR c_instance_id IS
4734   SELECT instance_id,
4735          instance_code
4736     FROM mrp_ap_apps_instances;
4737 
4738 l_mrp_atp_database_link varchar2(300);
4739 x_assignment_set_id number;
4740 x_assignment_set_name varchar2(300);
4741 x_plan_id number;
4742 x_plan_name varchar2(300);
4743 x_ret_code varchar2(300);
4744 x_err_mesg varchar2(2000);
4745 l_session_id number;
4746 --l_item_arr  mrp_atp_pub.number_arr := mrp_atp_pub.number_arr(1);
4747 l_organization_id number;
4748 x_sources mrp_atp_pvt.atp_source_typ;
4749 l_calling_module number;
4750 x_error_mesg varchar2(2000);
4751 l_other_cols  order_sch_wb.other_cols_typ;
4752 --l_source_orgs_table source_orgs_table;
4753 l_count number := 1;
4754 l_on_hand_qty number;
4755 l_reservable_qty number;
4756 l_available_qty    number;
4757 l_ship_from_org_id number;
4758 l_available_date   date;
4759 l_qty_uom          varchar2(25);
4760 l_out_message      varchar2(300);
4761 l_return_status    VARCHAR2(1);
4762 l_msg_count        NUMBER;
4763 l_msg_data         VARCHAR2(2000);
4764 l_error_message varchar2(2000);
4765 l_org_id number;
4766 l_customer_id number;
4767 l_customer_site_id number;
4768 l_ship_method varchar2(30);
4769 l_dynstring           VARCHAR2(500) := NULL;
4770 l_instance_code varchar2(100);
4771 
4772 l_inv_ctp number;
4773 
4774 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4775 
4776 CURSOR c_temp_table(in_session_id in number) IS
4777   SELECT source_organization_id,
4778          sr_instance_id,
4779          ship_method,
4780          delivery_lead_time,
4781          freight_carrier
4782     FROM mrp_atp_schedule_temp
4783    WHERE session_id = in_session_id
4784      --AND status_flag = -99;
4785      AND status_flag = 22;
4786 
4787 sql_stmt              VARCHAR2(3200);
4788 
4789 BEGIN
4790 
4791   IF l_debug_level  > 0 THEN
4792     oe_debug_pub.add(  'ENTERING GA IN_ORG_ID='||IN_ORG_ID|| ' IN_CUSTOMER_ID='||IN_CUSTOMER_ID
4793 		       || ' IN_SITE_ID ='||IN_CUSTOMER_SITE_ID|| ' IN_ITEM_ID ='||IN_INVENTORY_ITEM_ID ) ;
4794   END IF;
4795 
4796   OPEN c_instance_id;
4797   FETCH c_instance_id
4798    INTO l_instance_id,
4799         l_instance_code;
4800   CLOSE c_instance_id;
4801 
4802 
4803   x_return_status := 'S';
4804   l_mrp_atp_database_link := fnd_profile.value('MRP_ATP_DATABASE_LINK');
4805 
4806   IF l_debug_level  > 0 THEN
4807     oe_debug_pub.add(  'L_INSTANCE_ID='||L_INSTANCE_ID|| ' DB LINK='
4808 		       ||L_MRP_ATP_DATABASE_LINK ||' Ins Code='||l_instance_code) ;
4809   END IF;
4810 
4811   msc_sch_wb.get_assignment_set(
4812          x_dblink        => l_mrp_atp_database_link
4813          ,x_assignment_set_id=>x_assignment_set_id
4814          ,x_assignment_set_name=>x_assignment_set_name
4815          ,x_plan_id            =>x_plan_id
4816          ,x_plan_name          =>x_plan_name
4817          ,x_sr_instance_id=>l_instance_id
4818          ,x_inst          =>'APPS'
4819          ,x_ret_code      =>x_return_status
4820          ,x_err_mesg      =>x_err_mesg
4821                         );
4822 
4823   IF l_debug_level  > 0 THEN
4824     oe_debug_pub.add(  'ASSIGNMENT_SET_ID='||X_ASSIGNMENT_SET_ID|| ' SET NAME='||
4825 		       X_ASSIGNMENT_SET_NAME|| ' PLAN ID='||X_PLAN_ID|| ' PLAN NAME='
4826 		       ||X_PLAN_NAME|| ' RET CODE='||X_RETURN_STATUS|| ' ERR MESG='||X_ERR_MESG ) ;
4827   END IF;
4828 
4829   IF nvl(x_return_status,'E') = 'E'
4830        and x_assignment_set_id is null  then
4831 
4832     x_msg_data := x_err_mesg;
4833     IF l_debug_level  > 0 THEN
4834         oe_debug_pub.add(  'RETURNING IN GA 1' ) ;
4835     END IF;
4836 
4837     IF x_msg_data is not null then
4838 
4839       IF l_debug_level  > 0 THEN
4840           oe_debug_pub.add(  'MSG DATA IS NOT NULL' ) ;
4841       END IF;
4842       x_return_status := 'E';
4843       FND_MESSAGE.SET_NAME('ONT','ONT_AVAIL_GENERIC');
4844       IF l_debug_level  > 0 THEN
4845           oe_debug_pub.add(  'MSG DATA IS NOT NULL 2' ) ;
4846       END IF;
4847       FND_MESSAGE.SET_TOKEN('TEXT',x_msg_data);
4848       OE_MSG_PUB.Add;
4849 
4850     END IF;
4851 
4852 
4853   ELSE -- if get_assignment_set was sucessful
4854 
4855 
4856     SELECT mrp_atp_schedule_temp_s.nextval
4857       INTO l_session_id
4858       FROM dual;
4859 
4860     x_return_status := 'S';
4861 
4862     IF in_customer_site_id is not null and in_customer_id is not null then
4863       l_customer_id := in_customer_id;
4864       l_customer_site_id := in_customer_site_id;
4865       l_org_id := null;
4866     ELSE
4867       l_org_id := in_org_id;
4868       l_customer_id := null;
4869       l_customer_site_id := null;
4870     END IF;
4871 
4872 
4873     /*fnd_profile.get('INV_CTP',l_inv_ctp);
4874     IF l_debug_level  > 0 THEN
4875       oe_debug_pub.add(' Inventory Capable to Promise='||l_inv_ctp);
4876     END IF;
4877 
4878     --Profile Inventory Capable to Prmise
4879     -- 4= PDS and we need to select a plan_id for org-org sourcing
4880     -- 5= ODS and we need to pass -1 as plan_id
4881     IF l_inv_ctp = 5 then
4882       x_plan_id := -1;
4883     END IF;
4884 
4885     -- if destination is the org, then for looking at the sourcing rule
4886     -- we need to pass the plan_id from the planning server
4887     -- get_assignment_set currently does not return plan_id
4888     IF l_inv_ctp <> 5 AND
4889        l_org_id is not null and
4890       (l_customer_id is null and l_customer_site_id is null) then
4891 
4892       IF l_mrp_atp_database_link IS NOT NULL THEN
4893         l_dynstring := '@'||l_mrp_atp_database_link;
4894       END IF;
4895 
4896       IF l_debug_level  > 0 THEN
4897         oe_debug_pub.add('Getting Plan Id dynamic string='||l_dynstring);
4898       END IF;
4899 
4900       sql_stmt :=
4901        ' SELECT '||
4902        ' mast.plan_id '||
4903        ' FROM msc_atp_plan_sn'||l_dynstring||' mast '||
4904        ' WHERE mast.sr_instance_id = :in_instance_id '||
4905        ' AND mast.sr_inventory_item_id = :in_inventory_item_id'||
4906        ' AND mast.organization_id = :in_org_id';
4907 
4908       IF l_debug_level  > 0 THEN
4909         oe_debug_pub.add('Planning Sql='||sql_stmt);
4910       END IF;
4911 
4912 
4913       EXECUTE IMMEDIATE sql_stmt INTO x_plan_id
4914 		using l_instance_id,in_inventory_item_id,l_org_id;
4915 
4916 
4917       IF x_plan_id is null then
4918         fnd_message.set_name('MSC', 'MSC_NO_PLANS_DEFINED');
4919         oe_msg_pub.add;
4920         x_return_status := 'E';
4921         oe_debug_pub.add('Plan Id NOT FOUND');
4922       END IF;
4923 
4924     END IF; -- if plan_id needs to be fetched */
4925 
4926 
4927     IF x_plan_id is null then
4928       x_plan_id := -1;
4929     END IF;
4930 
4931     -- if the plan was fetched and found then continue
4932     IF nvl(x_return_status,'E') <> 'E' then
4933 
4934     IF l_debug_level  > 0 THEN
4935       oe_debug_pub.add(' Before inserting into temp table '||
4936                 ' instance_id='||l_instance_id||
4937                 ' session_id='||l_session_id||
4938                 ' inv_item_id='||in_inventory_item_id||
4939                 ' customer_id='||l_customer_id||
4940                 ' customer_site_id='||l_customer_site_id||
4941                 ' org_id='||l_org_id||
4942                 ' ship_method='||l_ship_method
4943                        );
4944     END IF;
4945 
4946     -- insert into mrp_atp_schedule_Temp
4947     INSERT INTO MRP_ATP_SCHEDULE_TEMP(
4948                   sr_instance_id,
4949                   session_id,
4950                   inventory_item_id,
4951                   organization_id,
4952                   scenario_id,
4953                   customer_id,
4954                   customer_site_id,
4955                   ship_method,
4956                   status_flag)
4957              VALUES
4958                   (l_instance_id,
4959                    l_session_id,
4960                    in_inventory_item_id,
4961                    l_org_id,
4962                    -1,
4963                    l_customer_id,
4964                    l_customer_site_id,
4965                    l_ship_method,
4966                    4
4967                   );
4968 
4969 
4970     IF l_debug_level  > 0 THEN
4971       print_time('Calling Get Supply Sources');
4972     END IF;
4973 
4974     msc_sch_wb.get_supply_sources_local(
4975                 x_dblink=>l_mrp_atp_database_link,
4976 		x_session_id=>l_session_id,
4977 		x_sr_instance_id=>l_instance_id,
4978 		x_assignment_set_id=>x_assignment_set_id,
4979 		x_plan_id=>x_plan_id,
4980                 x_calling_inst=>'APPS',
4981 		x_ret_status=>x_return_status,
4982                 x_error_mesg=>x_err_mesg);
4983 
4984     IF l_debug_level  > 0 THEN
4985       print_time('After Calling Get Supply Sources');
4986 
4987       oe_debug_pub.add(  ' After CALLing  get_supply_sources_local '||
4988                          ' status='||x_return_status||
4989                          ' message='||x_err_mesg);
4990 
4991     END IF;
4992 
4993     IF nvl(x_return_status,'S') <> 'S' THEN
4994       IF l_debug_level  > 0 THEN
4995         oe_debug_pub.add(  ' ERROR IN CALL TO get_supply_sources_local');
4996       END IF;
4997       fnd_message.set_name('MSC', x_err_mesg);
4998       oe_msg_pub.add;
4999 
5000     ELSE
5001 
5002       IF x_return_status IS NULL THEN
5003         x_return_status := 'S';
5004       END IF;
5005 
5006       IF l_debug_level  > 0 THEN
5007         oe_debug_pub.add(  ' SUCCESS IN CALL TO get_supply_sources_local');
5008       END IF;
5009 
5010       -- Read from mrp_atp_schedule_Temp
5011       -- Insert into l_sources_orgs_table org_id and instance_id
5012       -- delete from mrp_atp_schedule_temp
5013 
5014       FOR l_temp_rec in c_temp_table(l_session_id)
5015       LOOP
5016         IF l_debug_level  > 0 THEN
5017           oe_debug_pub.add(  ' Reading data from temp table');
5018         END IF;
5019         l_source_orgs_table(l_count).org_id:=l_temp_rec.source_organization_id;
5020         l_source_orgs_table(l_count).instance_id:=l_temp_rec.sr_instance_id;
5021         l_source_orgs_table(l_count).ship_method:=l_temp_rec.ship_method;
5022         l_source_orgs_table(l_count).delivery_lead_time:=l_temp_rec.delivery_lead_time;
5023         l_source_orgs_table(l_count).freight_carrier:=l_temp_rec.freight_carrier;
5024         l_source_orgs_table(l_count).instance_code:=l_instance_code;
5025         l_count := l_count + 1;
5026 
5027       END LOOP;
5028 
5029       IF l_debug_level  > 0 THEN
5030         oe_debug_pub.add(  ' After Reading data from temp table');
5031       END IF;
5032 
5033       IF l_source_orgs_table.COUNT > 0 then
5034         FOR i in l_source_orgs_table.FIRST..l_source_orgs_table.LAST
5035         LOOP
5036           IF l_debug_level  > 0 THEN
5037             oe_debug_pub.add(' Record = '||i||
5038              ' org_id ='||l_source_orgs_table(i).org_id||
5039              ' instance_id ='||l_source_orgs_table(i).instance_id||
5040              ' ship_method ='||l_source_orgs_table(i).ship_method||
5041              ' del_lead_time ='||l_source_orgs_table(i).delivery_lead_time||
5042              ' Instance_Code ='||l_source_orgs_table(i).Instance_Code
5043                             );
5044 
5045           END IF;
5046 
5047         END LOOP;
5048       ELSE
5049 
5050         IF l_debug_level  > 0 THEN
5051           oe_debug_pub.add(  ' THERE ARE NO SOURCES TO BE DISPLAYED ' ) ;
5052         END IF;
5053         x_return_status := 'E';
5054         x_error_mesg := 'MRP_ATP_NO_SOURCES';
5055         FND_MESSAGE.SET_NAME('MSC','MRP_ATP_NO_SOURCES');
5056         OE_MSG_PUB.Add;
5057         x_return_status := 'E';
5058 
5059       END IF; -- IF x_sources.organization_id.COUNT > 0
5060 
5061     END IF; -- if get_supply_sources is not successful
5062 
5063     --deleting from the temp table
5064     DELETE mrp_atp_schedule_temp
5065      WHERE session_id = l_session_id;
5066 
5067   END IF; -- if the fetching of plan was successful
5068 
5069   END IF; -- if get_assignment fails
5070 
5071 
5072   -- if it was a failure then we retrieve the message
5073   IF nvl(x_return_status,'E') <> 'S' then
5074     IF l_debug_level  > 0 THEN
5075         oe_debug_pub.add(  'DOING COUNT_AND_GET' ) ;
5076     END IF;
5077     oe_msg_pub.count_and_get(p_encoded=>fnd_api.G_TRUE,
5078                              p_count => x_msg_count,
5079                              p_data=>x_msg_data
5080                              );
5081     IF l_debug_level  > 0 THEN
5082         oe_debug_pub.add(  'COUNT = '||X_MSG_COUNT||' MSG='||X_MSG_DATA ) ;
5083     END IF;
5084   END IF;
5085 
5086   IF l_debug_level  > 0 THEN
5087       oe_debug_pub.add(  'EXITING GA' ) ;
5088   END IF;
5089 
5090 EXCEPTION
5091   WHEN OTHERS THEN
5092 
5093         IF l_debug_level  > 0 THEN
5094             oe_debug_pub.add(  'WHEN OTHERS OF get_global_availability' ) ;
5095             oe_debug_pub.add(  'CODE='||SQLCODE||' MSG='||SQLERRM ) ;
5096         END IF;
5097 
5098         x_return_status := 'E';
5099         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
5100 
5101         --  Get message count and data
5102         OE_MSG_PUB.Count_And_Get
5103         (   p_count                       => x_msg_count
5104         ,   p_data                        => x_msg_data
5105         );
5106 
5107         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
5108             OE_MSG_PUB.Add_Exc_Msg
5109             (   G_PKG_NAME,
5110               'Get_Global_Availability');
5111         END IF;
5112 
5113         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5114 
5115 END get_global_availability;
5116 
5117 
5118 
5119 PROCEDURE different_uom(
5120                         in_org_id in number
5121                        ,in_ordered_uom in varchar2
5122                        ,in_pricing_uom in varchar2
5123 ,out_conversion_rate out nocopy number
5124 
5125                        )IS
5126 
5127 CURSOR c_items IS
5128   SELECT primary_uom_code
5129     FROM mtl_system_items_b
5130    WHERE organization_id = in_org_id
5131      AND inventory_item_id = g_panda_rec_table(1).p_Inventory_item_id;
5132 
5133 CURSOR c_class(in_ordered_uom in varchar2) is
5134   SELECT uom_Class
5135     FROM mtl_units_of_measure_tl
5136    WHERE uom_code = in_ordered_uom;
5137 
5138 CURSOR c_base_uom(in_class in varchar2) IS
5139   SELECT uom_code
5140     FROM mtl_units_of_measure_tl
5141    WHERE uom_class = in_class
5142      AND base_uom_flag = 'Y';
5143 
5144 l_primary_Uom varchar2(100);
5145 l_uom_class varchar2(50);
5146 l_base_uom varchar2(50);
5147 l_conversion_rate number;
5148 l_ordered_conversion number;
5149 l_pricing_conversion number;
5150 
5151 --
5152 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5153 --
5154 BEGIN
5155 
5156                   IF l_debug_level  > 0 THEN
5157                       oe_debug_pub.add(  'ENTERING OE_AVAILABILITY.DIFFERENT_UOM'||
5158 					 ' ORDERED_UOM ='||IN_ORDERED_UOM|| ' PRICING_UOM='||
5159 					 IN_PRICING_UOM|| ' IN_INV_ITEM_ID='||
5160 					 G_panda_rec_table(1).p_INVENTORY_ITEM_ID|| ' IN_ORG_ID='||IN_ORG_ID ) ;
5161                   END IF;
5162 
5163   OPEN c_items;
5164   FETCH c_items
5165    INTO l_primary_uom;
5166 
5167   IF c_items%FOUND then
5168 
5169     OPEN c_class(l_primary_uom);
5170     FETCH c_class
5171      INTO l_uom_class;
5172 
5173     IF c_class%FOUND then
5174 
5175       OPEN c_base_uom(l_uom_class);
5176       FETCH c_base_Uom
5177        INTO l_base_uom;
5178 
5179       IF c_base_uom%FOUND then
5180 
5181         -- Both Ordered and Pricing are not Base UOM
5182         IF in_ordered_uom <> l_base_uom AND
5183            in_pricing_uom <> l_base_uom THEN
5184 
5185           IF l_debug_level  > 0 THEN
5186               oe_debug_pub.add(  'NEITHER THE ORDERED OR PRICING UOM IS BASE UOM' ) ;
5187           END IF;
5188 
5189           l_ordered_conversion := get_conversion_rate(
5190                                      in_uom_code => in_ordered_uom,
5191                                      in_base_uom => l_base_uom
5192                                                       );
5193           IF l_debug_level  > 0 THEN
5194               oe_debug_pub.add(  'THE ORD RATE ='||L_ORDERED_CONVERSION ) ;
5195           END IF;
5196           l_pricing_conversion := get_conversion_rate(
5197                                      in_uom_code => in_pricing_uom,
5198                                      in_base_uom => l_base_uom
5199                                                       );
5200           IF l_debug_level  > 0 THEN
5201               oe_debug_pub.add(  'THE PRICING RATE ='||L_PRICING_CONVERSION ) ;
5202           END IF;
5203 
5204           out_conversion_rate := l_ordered_conversion/l_pricing_conversion;
5205           IF l_debug_level  > 0 THEN
5206               oe_debug_pub.add(  'THE RATE ='||OUT_CONVERSION_RATE ) ;
5207           END IF;
5208 
5209         -- Ordered Uom is the Base Uom,sending the pricing uom for conversion
5210         ELSIF  in_ordered_uom = l_base_uom then
5211 
5212           IF l_debug_level  > 0 THEN
5213               oe_debug_pub.add(  'THE ORDERED UOM IS BASE UOM' ) ;
5214           END IF;
5215 
5216           l_ordered_conversion := get_conversion_rate(
5217                                      in_uom_code => in_pricing_uom,
5218                                      in_base_uom => l_base_uom
5219                                                       );
5220           out_conversion_rate := l_ordered_conversion;
5221           IF l_debug_level  > 0 THEN
5222               oe_debug_pub.add(  'THE RATE ='||OUT_CONVERSION_RATE ) ;
5223           END IF;
5224 
5225         -- Pricing Uom is the Base Uom
5226         ELSIF  in_pricing_uom = l_base_uom then
5227 
5228           IF l_debug_level  > 0 THEN
5229               oe_debug_pub.add(  'THE PRICING UOM IS BASE UOM' ) ;
5230           END IF;
5231           l_pricing_conversion := get_conversion_rate(
5232                                      in_uom_code => in_ordered_uom,
5233                                      in_base_uom => l_base_uom
5234                                                       );
5235           out_conversion_rate := l_pricing_conversion;
5236           IF l_debug_level  > 0 THEN
5237               oe_debug_pub.add(  'THE RATE ='||OUT_CONVERSION_RATE ) ;
5238           END IF;
5239 
5240         END IF;
5241 
5242       END IF;
5243 
5244       CLOSE c_base_uom;
5245 
5246     END IF;
5247 
5248     CLOSE c_class;
5249 
5250   END IF;
5251   CLOSE c_items;
5252 
5253 EXCEPTION
5254 
5255   WHEN NO_DATA_FOUND THEN
5256     IF l_debug_level  > 0 THEN
5257         oe_debug_pub.add(  'NO DATA FONUNG DIFFERENT_UOM ' ) ;
5258     END IF;
5259 
5260   WHEN OTHERS THEN
5261     IF c_items%ISOPEN then
5262       CLOSE c_items;
5263     END IF;
5264     IF c_class%ISOPEN then
5265       CLOSE c_class;
5266     END IF;
5267     IF c_base_uom%ISOPEN then
5268       CLOSE c_base_uom;
5269     END IF;
5270                     IF l_debug_level  > 0 THEN
5271                         oe_debug_pub.add(  'ERROR IN DIFFERENT_UOM '|| SQLCODE||SQLERRM ) ;
5272                     END IF;
5273 
5274 END different_uom;
5275 
5276 
5277 
5278 FUNCTION get_conversion_rate (in_uom_code in varchar2,
5279                               in_base_uom in varchar2
5280                              ) RETURN number is
5281 
5282 
5283 CURSOR c_item_conversion IS
5284   SELECT round(1/conversion_rate,6)
5285     FROM mtl_uom_conversions
5286    WHERE uom_code  = in_uom_code
5287      AND inventory_item_id = g_panda_rec_table(1).p_inventory_item_id;
5288 
5289 CURSOR c_conversion IS
5290   SELECT round(1/conversion_rate,6)
5291     FROM mtl_uom_conversions
5292    WHERE uom_Code = in_uom_code
5293      AND inventory_item_id = 0;
5294 
5295 CURSOR c_inter_class IS
5296   SELECT round(1/conversion_rate,6)
5297     FROM mtl_uom_class_conversions
5298    WHERE to_uom_code = in_uom_code
5299      AND from_uom_code  = in_base_uom
5300      AND inventory_item_id = g_panda_rec_table(1).p_inventory_item_id;
5301 
5302 l_conversion_rate number;
5303 l_uom_code varchar2(50);
5304 
5305 --
5306 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5307 --
5308 BEGIN
5309 
5310                     IF l_debug_level  > 0 THEN
5311                         oe_debug_pub.add(  'INSIDE GET_CONVERSION_RATE '|| ' IN_UOM_CODE='||IN_UOM_CODE|| ' IN_BASE_UOM='||IN_BASE_UOM ) ;
5312                     END IF;
5313 
5314     OPEN c_item_conversion;
5315     FETCH c_item_conversion
5316      INTO l_conversion_rate;
5317 
5318     IF c_item_conversion%NOTFOUND THEN
5319 
5320       IF l_debug_level  > 0 THEN
5321           oe_debug_pub.add(  'ITEM SPECIFIC CONVERSION RATE NOT FOUND' ) ;
5322       END IF;
5323 
5324       OPEN c_conversion;
5325       FETCH c_conversion
5326        INTO l_conversion_rate;
5327 
5328       IF c_conversion%NOTFOUND THEN
5329 
5330         IF l_debug_level  > 0 THEN
5331             oe_debug_pub.add(  'GENERIC CONVERSION NOT FOUND' ) ;
5332         END IF;
5333         OPEN c_inter_class;
5334         FETCH c_inter_class
5335          INTO l_conversion_rate;
5336 
5337         IF c_inter_class%NOTFOUND THEN
5338            IF l_debug_level  > 0 THEN
5339                oe_debug_pub.add(  'INTER CLASS RETURN RATE NOT FOUND= 1' ) ;
5340            END IF;
5341            l_conversion_rate := 1;
5342 
5343         ELSE
5344            IF l_debug_level  > 0 THEN
5345                oe_debug_pub.add(  'INTER CLASS RETURN RATE = '||L_CONVERSION_RATE ) ;
5346            END IF;
5347 
5348         END IF;
5349         CLOSE c_inter_class;
5350 
5351       ELSIF c_conversion%FOUND then
5352 
5353            IF l_debug_level  > 0 THEN
5354                oe_debug_pub.add(  'RETURN RATE GENERIC= '||L_CONVERSION_RATE ) ;
5355            END IF;
5356 
5357       END IF;
5358       CLOSE c_conversion;
5359 
5360     ELSIF c_item_conversion%FOUND THEN
5361 
5362         IF l_debug_level  > 0 THEN
5363             oe_debug_pub.add(  'ITEM SPECIFIC CONVERSION RATE='||L_CONVERSION_RATE ) ;
5364         END IF;
5365 
5366     END IF;
5367     CLOSE c_item_conversion;
5368 
5369     return l_conversion_rate;
5370 
5371 EXCEPTION
5372 
5373   WHEN ZERO_DIVIDE THEN
5374                      IF l_debug_level  > 0 THEN
5375                          oe_debug_pub.add(  'DIVIDE BY ZERO ERROR IN_UOM_CODE='||IN_UOM_CODE|| ' BASE UOM='||IN_BASE_UOM ) ;
5376                      END IF;
5377 
5378     IF c_item_conversion%ISOPEN then
5379       CLOSE c_item_conversion;
5380     END IF;
5381     IF c_conversion%ISOPEN then
5382       CLOSE c_conversion;
5383     END IF;
5384     IF c_inter_class%ISOPEN then
5385       CLOSE c_inter_class;
5386     END IF;
5387 
5388   WHEN OTHERS THEN
5389 
5390     IF c_item_conversion%ISOPEN then
5391       CLOSE c_item_conversion;
5392     END IF;
5393     IF c_conversion%ISOPEN then
5394       CLOSE c_conversion;
5395     END IF;
5396     IF c_inter_class%ISOPEN then
5397       CLOSE c_inter_class;
5398     END IF;
5399                     IF l_debug_level  > 0 THEN
5400                         oe_debug_pub.add(  'ERROR IN GET_CONVERSION_RATE '|| SQLCODE||SQLERRM ) ;
5401                     END IF;
5402     return 1;
5403 END get_conversion_rate;
5404 
5405 
5406 PROCEDURE Call_mrp_and_inventory(
5407                         in_org_id in number
5408 ,out_on_hand_qty out nocopy number
5409 
5410 ,out_reservable_qty out nocopy number
5411 
5412 ,out_available_qty out nocopy varchar2
5413 
5414 ,out_available_date out nocopy date
5415 
5416 ,out_error_message out nocopy varchar2
5417 
5418 ,out_qty_uom out nocopy varchar2
5419 
5420                                 ) IS
5421 
5422 l_ship_from_org_id number;
5423 l_out_message varchar2(4000);
5424 l_return_status varchar2(1);
5425 l_msg_count number;
5426 l_msg_data varchar2(4000);
5427 
5428 --
5429 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5430 --
5431 BEGIN
5432 
5433 
5434     Query_Qty_Tree( p_org_id=>in_org_id
5435                    ,p_item_id=>g_panda_rec_table(1).p_inventory_item_id
5436                    ,p_sch_date=>g_panda_rec_table(1).p_request_date
5437                    ,x_on_hand_qty =>out_on_hand_qty
5438                    ,x_avail_to_reserve =>out_reservable_qty
5439                    );
5440 
5441 
5442     Call_MRP_ATP(
5443           in_global_orgs => 'Y'
5444          ,in_ship_from_org_id =>in_org_id
5445          ,out_available_qty => out_available_qty
5446          ,out_ship_from_org_id =>l_ship_from_org_id
5447          ,out_available_date  =>out_available_date
5448          ,out_qty_uom        =>out_qty_uom
5449          ,x_out_message      =>l_out_message
5450          ,x_return_status    =>l_return_status
5451          ,x_msg_count        =>l_msg_count
5452          ,x_msg_data         =>l_msg_data
5453          ,x_error_message    =>out_error_message
5454                 );
5455 
5456                     IF l_debug_level  > 0 THEN
5457                         oe_debug_pub.add(  'L_RETURN_STATUS='||L_RETURN_STATUS|| ' OUT_AVAILABLE_QTY='||OUT_AVAILABLE_QTY|| ' L_OUT_MESSAGE='||L_OUT_MESSAGE|| ' OUT_ERROR_MESSAGE='||OUT_ERROR_MESSAGE ) ;
5458                     END IF;
5459 
5460 
5461                     IF l_debug_level  > 0 THEN
5462                         oe_debug_pub.add(  'CALL_MRP_AND_INVENTORY'|| ' OUT_AVAILABLE_DATE ='||OUT_AVAILABLE_DATE|| ' OUT_AVAILABLE_QTY ='||OUT_AVAILABLE_QTY);
5463                         oe_debug_pub.add( ' OUT_ON_HAND_QTY ='||OUT_ON_HAND_QTY|| ' OUT_RESERVABLE_QTY ='||OUT_RESERVABLE_QTY|| ' OUT_ERROR_MESSAGE ='||OUT_ERROR_MESSAGE ) ;
5464                     END IF;
5465 
5466 EXCEPTION
5467    WHEN OTHERS THEN
5468                      IF l_debug_level  > 0 THEN
5469                          oe_debug_pub.add(  'INSIDE CALL_MRP_AND_INVENTORY '|| SQLERRM||SQLERRM ) ;
5470                      END IF;
5471 
5472 END call_mrp_and_inventory;
5473 
5474 
5475 
5476 PROCEDURE set_mrp_debug(out_mrp_file out nocopy varchar2) IS
5477 
5478 
5479 l_session_id number;
5480 l_mrp_dir varchar2(200);
5481 
5482 --
5483 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5484 --
5485 BEGIN
5486 
5487     SELECT mrp_atp_schedule_temp_s.nextval
5488       INTO l_session_id
5489       FROM dual;
5490 
5491     SELECT ltrim(rtrim(substr(value, instr(value,',',-1,1)+1)))
5492       INTO l_mrp_dir
5493       FROM v$parameter
5494      WHERE name='utl_file_dir';
5495 
5496     order_sch_wb.mr_debug := 'Y';
5497     order_sch_wb.debug_session_id := l_session_id;
5498 
5499                     IF l_debug_level  > 0 THEN
5500                         oe_debug_pub.add(  'MSC_ATP_DEBUG DIR='||L_MRP_DIR|| ' SESSION ID ='||L_SESSION_ID ) ;
5501                     END IF;
5502     l_mrp_dir := substr(l_mrp_dir,1,18);
5503     IF l_debug_level  > 0 THEN
5504         oe_debug_pub.add(  'MSC_ATP_DEBUG DIR2='||L_MRP_DIR ) ;
5505     END IF;
5506     out_mrp_file := l_mrp_dir||'/session-'||l_session_id;
5507 
5508 EXCEPTION
5509   WHEN NO_DATA_FOUND THEN
5510     IF l_debug_level  > 0 THEN
5511         oe_debug_pub.add(  'OE_OE_AVAILABILITY.SET_MRP_DEBUG NO_DATA_FOUND' ) ;
5512     END IF;
5513   WHEN OTHERS THEN
5514                     IF l_debug_level  > 0 THEN
5515                         oe_debug_pub.add(  'WHEN OTHERS OE_OE_AVAILABILITY.SET_MRP_DEBUG '|| SQLCODE||SQLERRM ) ;
5516                     END IF;
5517 
5518 END set_mrp_debug;
5519 
5520 
5521 PROCEDURE copy_fields_to_globals(
5522                 in_inventory_item_id      in number,
5523                 in_qty                    in number,
5524                 in_uom                    in varchar2,
5525                 in_request_date           in date,
5526                 in_customer_id            in number,
5527                 in_item_identifier_type   in varchar2,
5528                 in_agreement_id           in number,
5529                 in_price_list_id          in number,
5530                 in_ship_to_org_id         in number,
5531                 in_invoice_to_org_id      in number,
5532                 in_ship_from_org_id       in number,
5533                 in_pricing_date           in date,
5534                 in_order_type_id          in number,
5535                 in_currency               in varchar2,
5536                 in_pricing_context        in varchar2,
5537                 in_pricing_attribute1     in varchar2,
5538                 in_pricing_attribute2     in varchar2,
5539                 in_pricing_attribute3     in varchar2,
5540                 in_pricing_attribute4     in varchar2,
5541                 in_pricing_attribute5     in varchar2,
5542                 in_pricing_attribute6     in varchar2,
5543                 in_pricing_attribute7     in varchar2,
5544                 in_pricing_attribute8     in varchar2,
5545                 in_pricing_attribute9     in varchar2,
5546                 in_pricing_attribute10    in varchar2,
5547                 in_pricing_attribute11    in varchar2,
5548                 in_pricing_attribute12    in varchar2,
5549                 in_pricing_attribute13    in varchar2,
5550                 in_pricing_attribute14    in varchar2,
5551                 in_pricing_attribute15    in varchar2,
5552                 in_pricing_attribute16    in varchar2,
5553                 in_pricing_attribute17    in varchar2,
5554                 in_pricing_attribute18    in varchar2,
5555                 in_pricing_attribute19    in varchar2,
5556                 in_pricing_attribute20    in varchar2,
5557                 in_pricing_attribute21    in varchar2,
5558                 in_pricing_attribute22    in varchar2,
5559                 in_pricing_attribute23    in varchar2,
5560                 in_pricing_attribute24    in varchar2,
5561                 in_pricing_attribute25    in varchar2,
5562                 in_pricing_attribute26    in varchar2,
5563                 in_pricing_attribute27    in varchar2,
5564                 in_pricing_attribute28    in varchar2,
5565                 in_pricing_attribute29    in varchar2,
5566                 in_pricing_attribute30    in varchar2,
5567                 in_pricing_attribute31    in varchar2,
5568                 in_pricing_attribute32    in varchar2,
5569                 in_pricing_attribute33    in varchar2,
5570                 in_pricing_attribute34    in varchar2,
5571                 in_pricing_attribute35    in varchar2,
5572                 in_pricing_attribute36    in varchar2,
5573                 in_pricing_attribute37    in varchar2,
5574                 in_pricing_attribute38    in varchar2,
5575                 in_pricing_attribute39    in varchar2,
5576                 in_pricing_attribute40    in varchar2,
5577                 in_pricing_attribute41    in varchar2,
5578                 in_pricing_attribute42    in varchar2,
5579                 in_pricing_attribute43    in varchar2,
5580                 in_pricing_attribute44    in varchar2,
5581                 in_pricing_attribute45    in varchar2,
5582                 in_pricing_attribute46    in varchar2,
5583                 in_pricing_attribute47    in varchar2,
5584                 in_pricing_attribute48    in varchar2,
5585                 in_pricing_attribute49    in varchar2,
5586                 in_pricing_attribute50    in varchar2,
5587                 in_pricing_attribute51    in varchar2,
5588                 in_pricing_attribute52    in varchar2,
5589                 in_pricing_attribute53    in varchar2,
5590                 in_pricing_attribute54    in varchar2,
5591                 in_pricing_attribute55    in varchar2,
5592                 in_pricing_attribute56    in varchar2,
5593                 in_pricing_attribute57    in varchar2,
5594                 in_pricing_attribute58    in varchar2,
5595                 in_pricing_attribute59    in varchar2,
5596                 in_pricing_attribute60    in varchar2,
5597                 in_pricing_attribute61    in varchar2,
5598                 in_pricing_attribute62    in varchar2,
5599                 in_pricing_attribute63    in varchar2,
5600                 in_pricing_attribute64    in varchar2,
5601                 in_pricing_attribute65    in varchar2,
5602                 in_pricing_attribute66    in varchar2,
5603                 in_pricing_attribute67    in varchar2,
5604                 in_pricing_attribute68    in varchar2,
5605                 in_pricing_attribute69    in varchar2,
5606                 in_pricing_attribute70    in varchar2,
5607                 in_pricing_attribute71    in varchar2,
5608                 in_pricing_attribute72    in varchar2,
5609                 in_pricing_attribute73    in varchar2,
5610                 in_pricing_attribute74    in varchar2,
5611                 in_pricing_attribute75    in varchar2,
5612                 in_pricing_attribute76    in varchar2,
5613                 in_pricing_attribute77    in varchar2,
5614                 in_pricing_attribute78    in varchar2,
5615                 in_pricing_attribute79    in varchar2,
5616                 in_pricing_attribute80    in varchar2,
5617                 in_pricing_attribute81    in varchar2,
5618                 in_pricing_attribute82    in varchar2,
5619                 in_pricing_attribute83    in varchar2,
5620                 in_pricing_attribute84    in varchar2,
5621                 in_pricing_attribute85    in varchar2,
5622                 in_pricing_attribute86    in varchar2,
5623                 in_pricing_attribute87    in varchar2,
5624                 in_pricing_attribute88    in varchar2,
5625                 in_pricing_attribute89    in varchar2,
5626                 in_pricing_attribute90    in varchar2,
5627                 in_pricing_attribute91    in varchar2,
5628                 in_pricing_attribute92    in varchar2,
5629                 in_pricing_attribute93    in varchar2,
5630                 in_pricing_attribute94    in varchar2,
5631                 in_pricing_attribute95    in varchar2,
5632                 in_pricing_attribute96    in varchar2,
5633                 in_pricing_attribute97    in varchar2,
5634                 in_pricing_attribute98    in varchar2,
5635                 in_pricing_attribute99    in varchar2,
5636                 in_pricing_attribute100   in varchar2,
5637                 in_conversion_type_code   IN VARCHAR2 DEFAULT NULL,    --added for bug 12541442
5638                 in_conversion_rate        IN NUMBER   DEFAULT NULL     --added for bug 12541442
5639                 ) IS
5640 
5641 --
5642 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5643 --
5644 l_index number :=1;
5645 BEGIN
5646 
5647    g_panda_rec_table.delete;
5648 
5649 
5650    l_index:=1;
5651    g_panda_rec_table(l_index).p_inventory_item_id := in_inventory_item_id;
5652    g_panda_rec_table(l_index).p_qty               := in_qty;
5653    g_panda_rec_table(l_index).p_uom               := in_uom;
5654    g_panda_rec_table(l_index).p_request_date      := in_request_date;
5655    g_panda_rec_table(l_index).p_customer_id       := in_customer_id;
5656    g_panda_rec_table(l_index).p_item_identIFier_type:= in_item_identifier_type;
5657    g_panda_rec_table(l_index).p_agreement_id      := in_agreement_id;
5658    g_panda_rec_table(l_index).p_price_list_id     := in_price_list_id;
5659    g_panda_rec_table(l_index).p_ship_to_org_id    := in_ship_to_org_id;
5660    g_panda_rec_table(l_index).p_invoice_to_org_id := in_invoice_to_org_id;
5661    g_panda_rec_table(l_index).p_ship_from_org_id  := in_ship_from_org_id;
5662    g_panda_rec_table(l_index).p_pricing_date      := in_pricing_date;
5663    g_panda_rec_table(l_index).p_order_type_id     := in_order_type_id;
5664    g_panda_rec_table(l_index).p_currency          := in_currency;
5665    g_panda_rec_table(l_index).p_pricing_context   := in_pricing_context;
5666    g_panda_rec_table(l_index).p_pricing_attribute1:= in_pricing_attribute1;
5667    g_panda_rec_table(l_index).p_pricing_attribute2:= in_pricing_attribute2;
5668    g_panda_rec_table(l_index).p_pricing_attribute3:= in_pricing_attribute3;
5669    g_panda_rec_table(l_index).p_pricing_attribute4:= in_pricing_attribute4;
5670    g_panda_rec_table(l_index).p_pricing_attribute5:= in_pricing_attribute5;
5671    g_panda_rec_table(l_index).p_pricing_attribute6:= in_pricing_attribute6;
5672    g_panda_rec_table(l_index).p_pricing_attribute7:= in_pricing_attribute7;
5673    g_panda_rec_table(l_index).p_pricing_attribute8:= in_pricing_attribute8;
5674    g_panda_rec_table(l_index).p_pricing_attribute9:= in_pricing_attribute9;
5675    g_panda_rec_table(l_index).p_pricing_attribute10  := in_pricing_attribute10;
5676    g_panda_rec_table(l_index).p_pricing_attribute11  := in_pricing_attribute11;
5677    g_panda_rec_table(l_index).p_pricing_attribute12  := in_pricing_attribute12;
5678    g_panda_rec_table(l_index).p_pricing_attribute13  := in_pricing_attribute13;
5679    g_panda_rec_table(l_index).p_pricing_attribute14  := in_pricing_attribute14;
5680    g_panda_rec_table(l_index).p_pricing_attribute15  := in_pricing_attribute15;
5681    g_panda_rec_table(l_index).p_pricing_attribute16  := in_pricing_attribute16;
5682    g_panda_rec_table(l_index).p_pricing_attribute17  := in_pricing_attribute17;
5683    g_panda_rec_table(l_index).p_pricing_attribute18  := in_pricing_attribute18;
5684    g_panda_rec_table(l_index).p_pricing_attribute19  := in_pricing_attribute19;
5685    g_panda_rec_table(l_index).p_pricing_attribute20  := in_pricing_attribute20;
5686    g_panda_rec_table(l_index).p_pricing_attribute21  := in_pricing_attribute21;
5687     g_panda_rec_table(l_index).p_pricing_attribute22  :=in_pricing_attribute22;
5688     g_panda_rec_table(l_index).p_pricing_attribute23  :=in_pricing_attribute23;
5689     g_panda_rec_table(l_index).p_pricing_attribute24  :=in_pricing_attribute24;
5690     g_panda_rec_table(l_index).p_pricing_attribute25  :=in_pricing_attribute25;
5691     g_panda_rec_table(l_index).p_pricing_attribute26  :=in_pricing_attribute26;
5692     g_panda_rec_table(l_index).p_pricing_attribute27  :=in_pricing_attribute27;
5693     g_panda_rec_table(l_index).p_pricing_attribute28  :=in_pricing_attribute28;
5694     g_panda_rec_table(l_index).p_pricing_attribute29  := in_pricing_attribute29;
5695     g_panda_rec_table(l_index).p_pricing_attribute30  := in_pricing_attribute30;
5696     g_panda_rec_table(l_index).p_pricing_attribute31  := in_pricing_attribute31;
5697     g_panda_rec_table(l_index).p_pricing_attribute32  := in_pricing_attribute32;
5698     g_panda_rec_table(l_index).p_pricing_attribute33  := in_pricing_attribute33;
5699     g_panda_rec_table(l_index).p_pricing_attribute34  := in_pricing_attribute34;
5700     g_panda_rec_table(l_index).p_pricing_attribute35  := in_pricing_attribute35;
5701     g_panda_rec_table(l_index).p_pricing_attribute36  := in_pricing_attribute36;
5702     g_panda_rec_table(l_index).p_pricing_attribute37  := in_pricing_attribute37;
5703     g_panda_rec_table(l_index).p_pricing_attribute38  := in_pricing_attribute38;
5704     g_panda_rec_table(l_index).p_pricing_attribute39  := in_pricing_attribute39;
5705     g_panda_rec_table(l_index).p_pricing_attribute40  := in_pricing_attribute40;
5706     g_panda_rec_table(l_index).p_pricing_attribute41  := in_pricing_attribute41;
5707     g_panda_rec_table(l_index).p_pricing_attribute42  := in_pricing_attribute42;
5708     g_panda_rec_table(l_index).p_pricing_attribute43  := in_pricing_attribute43;
5709     g_panda_rec_table(l_index).p_pricing_attribute44  := in_pricing_attribute44;
5710     g_panda_rec_table(l_index).p_pricing_attribute45  := in_pricing_attribute45;
5711     g_panda_rec_table(l_index).p_pricing_attribute46  := in_pricing_attribute46;
5712     g_panda_rec_table(l_index).p_pricing_attribute47  := in_pricing_attribute47;
5713     g_panda_rec_table(l_index).p_pricing_attribute48  := in_pricing_attribute48;
5714     g_panda_rec_table(l_index).p_pricing_attribute49  := in_pricing_attribute49;
5715     g_panda_rec_table(l_index).p_pricing_attribute50  := in_pricing_attribute50;
5716     g_panda_rec_table(l_index).p_pricing_attribute51  := in_pricing_attribute51;
5717     g_panda_rec_table(l_index).p_pricing_attribute52  := in_pricing_attribute52;
5718     g_panda_rec_table(l_index).p_pricing_attribute53  := in_pricing_attribute53;
5719     g_panda_rec_table(l_index).p_pricing_attribute54  := in_pricing_attribute54;
5720     g_panda_rec_table(l_index).p_pricing_attribute55  := in_pricing_attribute55;
5721     g_panda_rec_table(l_index).p_pricing_attribute56  := in_pricing_attribute56;
5722     g_panda_rec_table(l_index).p_pricing_attribute57  := in_pricing_attribute57;
5723     g_panda_rec_table(l_index).p_pricing_attribute58  := in_pricing_attribute58;
5724     g_panda_rec_table(l_index).p_pricing_attribute59  := in_pricing_attribute59;
5725     g_panda_rec_table(l_index).p_pricing_attribute60  := in_pricing_attribute60;
5726     g_panda_rec_table(l_index).p_pricing_attribute61  := in_pricing_attribute61;
5727     g_panda_rec_table(l_index).p_pricing_attribute62  := in_pricing_attribute62;
5728     g_panda_rec_table(l_index).p_pricing_attribute63  := in_pricing_attribute63;
5729     g_panda_rec_table(l_index).p_pricing_attribute64  := in_pricing_attribute64;
5730     g_panda_rec_table(l_index).p_pricing_attribute65  := in_pricing_attribute65;
5731     g_panda_rec_table(l_index).p_pricing_attribute66  := in_pricing_attribute66;
5732     g_panda_rec_table(l_index).p_pricing_attribute67  := in_pricing_attribute67;
5733     g_panda_rec_table(l_index).p_pricing_attribute68  := in_pricing_attribute68;
5734     g_panda_rec_table(l_index).p_pricing_attribute69  := in_pricing_attribute69;
5735     g_panda_rec_table(l_index).p_pricing_attribute70  := in_pricing_attribute70;
5736     g_panda_rec_table(l_index).p_pricing_attribute71  := in_pricing_attribute71;
5737     g_panda_rec_table(l_index).p_pricing_attribute72  := in_pricing_attribute72;
5738     g_panda_rec_table(l_index).p_pricing_attribute73  := in_pricing_attribute73;
5739     g_panda_rec_table(l_index).p_pricing_attribute74  := in_pricing_attribute74;
5740     g_panda_rec_table(l_index).p_pricing_attribute75  := in_pricing_attribute75;
5741     g_panda_rec_table(l_index).p_pricing_attribute76  := in_pricing_attribute76;
5742     g_panda_rec_table(l_index).p_pricing_attribute77  := in_pricing_attribute77;
5743     g_panda_rec_table(l_index).p_pricing_attribute78  := in_pricing_attribute78;
5744     g_panda_rec_table(l_index).p_pricing_attribute79  := in_pricing_attribute79;
5745     g_panda_rec_table(l_index).p_pricing_attribute80  := in_pricing_attribute80;
5746     g_panda_rec_table(l_index).p_pricing_attribute81  := in_pricing_attribute81;
5747     g_panda_rec_table(l_index).p_pricing_attribute82  := in_pricing_attribute82;
5748     g_panda_rec_table(l_index).p_pricing_attribute83  := in_pricing_attribute83;
5749     g_panda_rec_table(l_index).p_pricing_attribute84  := in_pricing_attribute84;
5750     g_panda_rec_table(l_index).p_pricing_attribute85  := in_pricing_attribute85;
5751     g_panda_rec_table(l_index).p_pricing_attribute86  := in_pricing_attribute86;
5752     g_panda_rec_table(l_index).p_pricing_attribute87  := in_pricing_attribute87;
5753     g_panda_rec_table(l_index).p_pricing_attribute88  := in_pricing_attribute88;
5754     g_panda_rec_table(l_index).p_pricing_attribute89  := in_pricing_attribute89;
5755     g_panda_rec_table(l_index).p_pricing_attribute90  := in_pricing_attribute90;
5756     g_panda_rec_table(l_index).p_pricing_attribute91  := in_pricing_attribute91;
5757     g_panda_rec_table(l_index).p_pricing_attribute92  := in_pricing_attribute92;
5758     g_panda_rec_table(l_index).p_pricing_attribute93  := in_pricing_attribute93;
5759     g_panda_rec_table(l_index).p_pricing_attribute94  := in_pricing_attribute94;
5760     g_panda_rec_table(l_index).p_pricing_attribute95  := in_pricing_attribute95;
5761     g_panda_rec_table(l_index).p_pricing_attribute96  := in_pricing_attribute96;
5762     g_panda_rec_table(l_index).p_pricing_attribute97  := in_pricing_attribute97;
5763     g_panda_rec_table(l_index).p_pricing_attribute98  := in_pricing_attribute98;
5764     g_panda_rec_table(l_index).p_pricing_attribute99  := in_pricing_attribute99;
5765     g_panda_rec_table(l_index).p_pricing_attribute100 := in_pricing_attribute100;
5766     g_panda_rec_table(l_index).p_conversion_type_code := in_conversion_type_code; --added for bug 12541442
5767     g_panda_rec_table(l_index).p_conversion_rate      := in_conversion_rate;      --added for bug 12541442
5768 
5769 
5770 END copy_fields_to_globals;
5771 
5772 
5773 END oe_oe_availability;