DBA Data[Home] [Help]

PACKAGE BODY: APPS.OE_LINE_UTIL

Source


1 PACKAGE BODY OE_LINE_UTIL AS
2 /* $Header: OEXULINB.pls 120.139.12020000.31 2013/05/23 13:36:02 nilegupt ship $ */
3 
4 --  Global constant holding the package name
5 
6 G_PKG_NAME                    CONSTANT VARCHAR2(30) := 'oe_line_util';
7 --bug4080363 commenting out the following
8 -- bug 3491752
9 --G_LIST_PRICE_OVERRIDE    Varchar2(30) := nvl(fnd_profile.value('ONT_LIST_PRICE_OVERRIDE_PRIV'), 'NONE');
10 G_BINARY_LIMIT CONSTANT NUMBER := OE_GLOBALS.G_BINARY_LIMIT; -- Added for bug 8636027
11 
12 -- Added new API for 12355310
13 FUNCTION Shipping_Interfaced_Status
14 (
15 p_line_id NUMBER
16 ) RETURN VARCHAR2;
17 
18 -- Added new API for FP bug 6628653 base bug 6513023
19 PROCEDURE HANDLE_RFR
20 (
21 p_line_id            IN NUMBER,
22 p_top_model_line_id  IN NUMBER,
23 p_link_to_line_id     IN NUMBER
24 );
25 
26 --  Procedure Clear_Dependent_Attr: Moved to OE_LINE_UTIL_EXT (OEXULXTS/B.pls)
27 
28 -- Added 09-DEC-2002
29 -- Forward declaration of LOCAL PROCEDURE Log_Blanket_Request
30 PROCEDURE Log_Blanket_Request
31 (   p_x_line_rec      IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
32 ,   p_old_line_rec    IN OE_Order_PUB.Line_Rec_Type
33 );
34 
35 Procedure Log_Dropship_CMS_Request
36 ( p_x_line_rec            IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
37 , p_old_line_rec          IN OE_Order_PUB.Line_Rec_Type
38 );
39 
40 PROCEDURE get_customer_details
41 (   p_org_id                IN  NUMBER
42 ,   p_site_use_code         IN  VARCHAR2
43 ,   x_customer_name         OUT NOCOPY /* file.sql.39 change */ VARCHAR2
44 ,   x_customer_number       OUT NOCOPY /* file.sql.39 change */ VARCHAR2
45 ,   x_customer_id           OUT NOCOPY /* file.sql.39 change */ NUMBER
46 ,   x_location              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
47 ,   x_address1              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
48 ,   x_address2              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
49 ,   x_address3              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
50 ,   x_address4              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
51 ,   x_city                  OUT NOCOPY /* file.sql.39 change */ VARCHAR2
52 ,   x_state                 OUT NOCOPY /* file.sql.39 change */ VARCHAR2
53 ,   x_zip                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
54 ,   x_country               OUT NOCOPY /* file.sql.39 change */ VARCHAR2);
55 
56 ------------------------------------------------------------
57 PROCEDURE Log_CTO_Requests
58 (p_x_line_rec    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
59 ,p_old_line_rec  IN             OE_Order_PUB.Line_Rec_Type :=
60                                    OE_Order_PUB.G_MISS_LINE_REC
61 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2);
62 
63 PROCEDURE Log_Config_Requests
64 (p_x_line_rec    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
65 ,p_old_line_rec  IN             OE_Order_PUB.Line_Rec_Type :=
66                                    OE_Order_PUB.G_MISS_LINE_REC
67 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2);
68 
69 PROCEDURE Log_Cascade_Requests
70 (p_x_line_rec    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
71 ,p_old_line_rec  IN             OE_Order_PUB.Line_Rec_Type :=
72                                    OE_Order_PUB.G_MISS_LINE_REC
73 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2);
74 --------------------------------------------------------------
75 
76 --16206165 CW Start
77 --------------------------------------------------------------------------------------------------
78 -- This Function is meant to identify if a item is a Catch Weight Item as per pricing is concerned
79 -- This will return 'P' if this is a Primary Catch Weight Case
80 -- This will return 'S' if this is a Secondary Catch Weight Case
81 -- This will return NULL  if this is not a Catch Weight Case
82 --------------------------------------------------------------------------------------------------
83 FUNCTION IS_CATCH_WEIGHT
84 (
85 	  p_Line_rec                     OE_Order_PUB.Line_Rec_Type
86 )
87 RETURN VARCHAR2
88 IS
89 
90 l_item_rec                    OE_ORDER_CACHE.ITEM_REC_TYPE;
91 l_hook_pricing_uom            OE_ORDER_LINES_ALL.PRICING_QUANTITY_UOM%TYPE;
92 l_primary_catch_weight        VARCHAR2(1) := NULL;
93 l_secondary_catch_weight      VARCHAR2(1) := NULL;
94 l_ref_line_rec  OE_ORDER_PUB.LINE_REC_TYPE;
95 TYPE uom_class_tbl IS TABLE of MTL_UNITS_OF_MEASURE.UOM_CLASS%TYPE index by MTL_UNITS_OF_MEASURE.UOM_CODE%TYPE;
96 l_uom_class_tbl 	uom_class_tbl;
97 l_debug_level  CONSTANT NUMBER := oe_debug_pub.g_debug_level;
98 
99 BEGIN
100 
101   IF l_debug_level  > 0 THEN
102      oe_debug_pub.ADD('Entering Is_Catch_Weight');
103   END IF;
104 
105   IF oe_line_util.dual_uom_control
106           (p_line_rec.inventory_item_id
107            ,p_line_rec.ship_from_org_id
108            ,l_item_rec)
109   THEN
110         IF p_line_rec.reference_line_id is NOT NULL THEN
111            l_ref_line_rec := OE_line_UTIL.Query_Row(p_line_rec.reference_line_id);
112         END IF;
113 
114         IF l_debug_level  > 0 THEN
115         	oe_debug_pub.ADD('Reference Line FB:'||l_ref_line_rec.fulfillment_base);
116         END IF;
117 
118 
119         IF p_line_rec.fulfillment_base IS NOT NULL OR l_ref_line_rec.fulfillment_base IS NOT NULL THEN
120 
121     	   l_hook_pricing_uom := OE_DUAL_UOM_HOOK.GET_PRICING_UOM(p_line_rec);
122 
123 	   IF l_hook_pricing_uom IS NOT NULL THEN
124 
125     	   	   IF l_hook_pricing_uom not in ('P','O','S')
126     	   	   THEN
127 
128         		     FND_MESSAGE.SET_NAME('ONT','OE_PRICING_HOOK_ERROR');
129         		     FND_MESSAGE.SET_TOKEN('HOOK_API','OE_DUAL_UOM_HOOK.GET_PRICING_UOM');
130         		     FND_MESSAGE.SET_TOKEN('VALID_VALUES','Ordered UOM (O), Primary UOM (P) or Secondary UOM (S)');
131         		     OE_MSG_PUB.Add;
132         		     RAISE FND_API.G_EXC_ERROR;
133 
134 	   	   END IF;
135 
136 
137 		   IF l_hook_pricing_uom ='P' THEN
138 
139 		     l_primary_catch_weight :='Y';
140 
141 		   ELSIF l_hook_pricing_uom ='S' THEN
142 
143 		     l_secondary_catch_weight :='Y';
144 
145 		   ELSE
146 
147 		      l_primary_catch_weight :='N';
148 		      l_secondary_catch_weight :='N';
149 
150 		   END IF;
151 
152 	   END IF;
153 
154            IF l_debug_level  > 0 THEN
155                oe_debug_pub.ADD('Hook Catch Weight Pricing UOM:'||l_hook_pricing_uom);
156            END IF;
157 
158 
159 
160 	   IF l_hook_pricing_uom IS NULL THEN
161 
162 	        FOR uom_class_rec IN (SELECT UOM_CODE,UOM_CLASS
163 				      FROM MTL_UNITS_OF_MEASURE
164 				      WHERE UOM_CODE in (p_line_rec.order_quantity_uom,l_item_rec.primary_uom_code,l_item_rec.secondary_uom_code) )
165 		LOOP
166 		    l_uom_class_tbl(uom_class_rec.uom_code) := uom_class_rec.uom_class;
167 		END LOOP;
168 
169               IF ( NVL(p_line_rec.fulfillment_base,l_ref_line_rec.fulfillment_base)= 'P')  AND
170                  l_item_rec.ont_pricing_qty_source = 'S'
171                  /** Retaining existing behavior of Null Fulfillment Base as Fulfillment Base NULL
172                      and Primary are treated same by all teams **/
173               THEN
174 
175                   l_secondary_catch_weight :='Y';
176 
177 
178                   IF l_debug_level  > 0 THEN
179                     oe_debug_pub.ADD('Secondary Catch Weight Pricing');
180                   END IF;
181 
182               END IF;
183 
184 
185               IF ( NVL(p_line_rec.fulfillment_base,l_ref_line_rec.fulfillment_base)= 'S') AND
186                  l_item_rec.ont_pricing_qty_source = 'P' AND
187                  l_uom_class_tbl(p_line_rec.order_quantity_uom)= l_uom_class_tbl(l_item_rec.secondary_uom_code) AND
188                  l_uom_class_tbl(l_item_rec.primary_uom_code)<> l_uom_class_tbl(l_item_rec.secondary_uom_code)
189               THEN
190 
191                   l_primary_catch_weight :='Y';
192 
193 
194                   /**Since Receiving Team is not supporting Fulfillment by Secondary , from pricing perspective
195                      also existing behaviour is retained for non-referenced RMA**/
196 
197                   IF p_line_rec.line_category_code ='RETURN' and p_line_rec.reference_line_id IS NULL
198                   THEN
199 
200                   	l_primary_catch_weight :='N';
201 
202                   END IF;
203 
204                   IF l_debug_level  > 0 THEN
205                      oe_debug_pub.ADD('Primary Catch Weight Pricing');
206                   END IF;
207 
208 
209                END IF;
210 
211            END IF;
212 
213       END IF;
214 
215   END IF;
216 
217 
218   IF  l_primary_catch_weight = 'Y' THEN
219 
220       RETURN 'P';
221 
222   ELSIF  l_secondary_catch_weight ='Y' THEN
223 
224       RETURN 'S';
225 
226   ELSE
227 
228      IF l_debug_level  > 0 THEN
229         oe_debug_pub.ADD('No Catch Weight Pricing');
230      END IF;
231 
232       RETURN NULL;
233 
234   END IF;
235 
236   IF l_debug_level  > 0 THEN
237      oe_debug_pub.ADD('Exiting Is_Catch_Weight');
238   END IF;
239 
240 EXCEPTION
241 WHEN OTHERS THEN
242 
243   IF l_debug_level  > 0 THEN
244      oe_debug_pub.ADD('Exception Is_Catch_Weight:'||substr(SQLERRM,1,250));
245   END IF;
246 
247   RAISE FND_API.G_EXC_ERROR;
248 
249 END IS_CATCH_WEIGHT;
250 --16206165 CW End
251 
252 
253 /*----------------------------------------------------------
254 Procedure Delete_Dependents
255 Delete dependents call out for line.
256 Keep your dependenceis on line here
257 bug fix 2127356: log update_shipping req here.
258 bug fix 2670775: Reverse Limits here.
259 -----------------------------------------------------------*/
260 
261 Procedure Delete_Dependents
262 ( p_line_id                  IN NUMBER
263  ,p_item_type_code           IN VARCHAR2
264  ,p_line_category_code       IN VARCHAR2
265  ,p_config_header_id         IN NUMBER
266  ,p_config_rev_nbr           IN NUMBER
267  ,p_schedule_status_code     IN VARCHAR2
268  ,p_shipping_interfaced_flag IN VARCHAR2
269  ,p_ordered_quantity         IN NUMBER         -- BUG 2670775 Reverse Limits
270  ,p_price_request_code       IN VARCHAR2       -- BUG 2670775 Reverse Limits
271  ,p_transaction_phase_code   IN VARCHAR2 default null       -- Bug 3315331
272 )IS
273 l_return_status varchar2(30);
274 l_set_tbl_count number;
275 l_header_id	number;
276 
277 l_debug_level  CONSTANT NUMBER := oe_debug_pub.g_debug_level;
278 l_delete_lines_tbl           OE_ORDER_PUB.Request_Tbl_Type; -- For bug 3754586
279 BEGIN
280   if l_debug_level > 0 then
281    oe_debug_pub.add('Entering in Delete Dependents');
282   end if;
283    /* set the set type in g_set_tbl to invalid if the line is being deleted */
284 
285 
286    IF  OE_SET_UTIL.g_set_tbl.count > 0 THEN
287 
288      if l_debug_level > 0 then
289        oe_debug_pub.add('Table Count : '||OE_SET_UTIL.g_set_tbl.count,3);
290      end if;
291 
292        l_set_tbl_count := OE_SET_UTIL.g_set_tbl.first;
293        WHILE l_set_tbl_count IS NOT NULL
294        LOOP
295 
296            IF  OE_SET_UTIL.g_set_tbl(l_set_tbl_count).line_id = p_line_id THEN
297 
298                OE_SET_UTIL.g_set_tbl(l_set_tbl_count).set_type := 'INVALID_SET';
299 
300              if l_debug_level > 0 then
301                oe_debug_pub.add('Set the set type as invalid ',3);
302              end if;
303            END IF;
304 
305            l_set_tbl_count := OE_SET_UTIL.g_set_tbl.next(l_set_tbl_count);
306 
307        END LOOP;
308 
309    END IF;
310 
311     OE_Atchmt_Util.Delete_Attachments
312                ( p_entity_code	=> OE_GLOBALS.G_ENTITY_LINE
313                , p_entity_id      	=> p_line_id
314                , x_return_status   => l_return_status
315                );
316     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
317           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
318     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
319           RAISE FND_API.G_EXC_ERROR;
320     END IF;
321 
322     -- BUG 2670775 Reverse Limits Begin
323     OE_DELAYED_REQUESTS_UTIL.REVERSE_LIMITS
324               ( x_return_status           => l_return_status
325               , p_action_code             => 'CANCEL'
326               , p_cons_price_request_code => p_price_request_code
327               , p_orig_ordered_qty        => p_ordered_quantity
328               , p_amended_qty             => NULL
329               , p_ret_price_request_code  => NULL
330               , p_returned_qty            => NULL
331               , p_line_id                 => p_line_id
332               );
333 
334     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
335           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
336     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
337           RAISE FND_API.G_EXC_ERROR;
338     END IF;
339     -- BUG 2670775 Reverse Limits End
340 
341     -- Scheduling restructure.
342     IF p_schedule_status_code IS NOT NULL
343     AND p_item_type_code <> OE_GLOBALS.G_ITEM_CONFIG THEN
344 
345       --4504362: Branch scheduling checs removed
346        OE_SCHEDULE_UTIL.Delete_row(p_line_id => p_line_id);
347 
348 
349     END IF;
350 
351     OE_Line_Adj_Util.delete_row(p_line_id => p_line_id);
352     OE_Line_PAttr_Util.delete_row(p_line_id => p_line_id);
353     OE_Line_Scredit_Util.delete_row(p_line_id => p_line_id);
354     OE_Lot_Serial_Util.delete_row(p_line_id => p_line_id);
355     -- Bug 3315531
356     -- Do not call WF delete for lines in negotiation phase as
357     -- line workflows are only started when order is in fulfillment phase.
358     IF nvl(p_transaction_phase_code,'F') = 'F' THEN
359        OE_Order_WF_Util.delete_row(p_type => 'LINE', p_id => p_line_id);
360     END IF;
361     OE_Holds_PUB.Delete_Holds(p_line_id => p_line_id );
362 
363     -- 1829201, commitment related changes.
364     -- OE_Payments_Util.delete_row(p_line_id => p_line_id);
365 
366     begin
367       select header_id
368       into   l_header_id
369       from   oe_order_lines_all
370       where  line_id = p_line_id;
371     exception when no_data_found then
372       null;
373     end;
374 
375     OE_Line_Payment_Util.delete_row
376                         (p_line_id => p_line_id
377                         ,p_header_id => l_header_id
378                         );
379 
380     oe_line_fullfill.cancel_line(p_line_id => p_line_id,
381 						  x_return_status => l_return_status);
382 
383     if l_return_status <> FND_API.G_RET_STS_SUCCESS then
384 
385 	 if l_return_status = FND_API.G_RET_STS_ERROR then
386 
387 	    raise FND_API.G_EXC_ERROR;
388       else
389 
390 	    raise FND_API.G_EXC_UNEXPECTED_ERROR;
391 	 end if;
392 
393     end if;
394 
395     OE_Set_Util.Remove_From_Fulfillment(p_line_id => p_line_id);
396 
397   /* Log and Execute the delayed request logged for update shipping
398        as they will get deleted in the next step */
399   if l_debug_level > 0 then
400    oe_debug_pub.ADD('p_shipping_interfaced_flag '|| p_shipping_interfaced_flag,1);
401   end if;
402 
403    IF	p_shipping_interfaced_flag = 'Y' THEN
404 
405     if l_debug_level > 0 then
406      oe_debug_pub.ADD('Update Shipping,Delete '|| p_line_id,1);
407     end if;
408 
409    /*
410    The code for logging and processing the delayed request for update shipping
411    was removed for bug 3754586 , instead we call update_shipping_from_oe
412    This was done for the following reason :
413    In case of multiple lines call to process order with some lines getting
414    deleted and others getting updated, we see that WSHcheck scripts api is called
415    even for DELETE case at the time of delayes request execution whereas we want
416    the call to be made at actually databse delete in delete_row api.
417    */
418    -- Preparing the table for calling Update_Shipping_From_OE for the deleted line
419 
420      l_delete_lines_tbl(1).entity_code            := OE_GLOBALS.G_ENTITY_LINE;
421      l_delete_lines_tbl(1).entity_id              := p_line_id;
422      l_delete_lines_tbl(1).param1                 := FND_API.G_TRUE;
423      l_delete_lines_tbl(1).param2                 := FND_API.G_FALSE;
424      l_delete_lines_tbl(1).request_unique_key1    := OE_GLOBALS.G_OPR_DELETE;
425 
426      OE_Shipping_Integration_PVT.Update_Shipping_From_OE
427         (p_update_lines_tbl      =>      l_delete_lines_tbl,
428          x_return_status         =>      l_return_status
429         );
430 
431    END IF;-- shipping interfaced = 'Y'
432    -- changes for bug 3754586 ends
433 
434      if l_debug_level > 0 then
435       oe_debug_pub.add('ret sts: '|| l_return_status, 4);
436      end if;
437 
438       IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
439 
440           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
441       ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
442           RAISE FND_API.G_EXC_ERROR;
443       END IF;
444 
445     OE_Delayed_Requests_Pvt.Delete_Reqs_for_deleted_entity(
446         p_entity_code  => OE_GLOBALS.G_ENTITY_LINE,
447         p_delete_against => FALSE, -- bug 5114189
448         p_entity_id     => p_line_id,
449         x_return_status => l_return_status
450         );
451 
452 
453 
454 EXCEPTION
455     WHEN NO_DATA_FOUND THEN
456 				NULL;
457     WHEN FND_API.G_EXC_ERROR THEN
458           RAISE FND_API.G_EXC_ERROR;
459     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
460           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
461     WHEN OTHERS THEN
462         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
463         THEN
464             OE_MSG_PUB.Add_Exc_Msg
465             (   G_PKG_NAME
466             ,   'Delete_Dependents'
467             );
468         END IF;
469         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
470 END Delete_Dependents;
471 
472 
473 Procedure Calc_Catchweight_Return_qty2
474 ( p_x_line_rec IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type
475 ,  p_old_line_rec                  IN  OE_Order_PUB.Line_Rec_Type) IS
476 x_item_rec  OE_ORDER_CACHE.item_rec_type;
477 l_debug_level  CONSTANT NUMBER := oe_debug_pub.g_debug_level;
478 
479 BEGIN
480    If l_debug_level > 0 Then
481       oe_debug_pub.add('Entering into Calc_Catchweight_Return_qty2',1);
482       oe_debug_pub.add('p_x_line_rec.line_category_code : '||p_x_line_rec.line_category_code||' p_x_line_rec.reference_line_id : '||p_x_line_rec.reference_line_id,3);
483       oe_debug_pub.add('p_x_line_rec.inventory_item_id : '||p_x_line_rec.inventory_item_id||' p_x_line_rec.ship_from_org_id : '||p_x_line_rec.ship_from_org_id,3);
484    End If;
485 
486    IF p_x_line_rec.line_category_code = 'RETURN' AND
487         p_x_line_rec.reference_line_id IS NOT NULL THEN  -- referenced return
488      IF (p_x_line_rec.inventory_item_id IS NOT NULL AND
489             p_x_line_rec.inventory_item_id <> FND_API.G_MISS_NUM) AND
490            (p_x_line_rec.ship_from_org_id  IS NOT NULL AND
491             p_x_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM) THEN
492             x_item_rec := OE_Order_Cache.Load_Item (p_x_line_rec.inventory_item_id
493                             ,p_x_line_rec.ship_from_org_id);
494             --IF  x_item_rec.ont_pricing_qty_source = 1  AND -- INVCONV
495             IF x_item_rec.ont_pricing_qty_source = 'S' AND -- INVCONV
496                    x_item_rec.tracking_quantity_ind = 'P'  THEN -- AND -- INVCONV -
497                   --x_item_rec.wms_enabled_flag = 'Y' THEN -- INVCONV - TAKE OUT AS OPENED UP TO ANY ORG
498                   IF l_debug_level  > 0 THEN
499                         oe_debug_pub.add(  'Discrete catchweight enabled. Prorating ordered_quantity2. p_old_line_rec.ordered_quantity2:'|| p_old_line_rec.ordered_quantity2||
500           ': p_old_line_rec.ordered_quantity:'|| p_old_line_rec.ordered_quantity||': p_x_line_rec.ordered_quantity:'|| p_x_line_rec.ordered_quantity);
501                          oe_debug_pub.add('p_x_line_rec.ordered_quantity2 : '||p_x_line_rec.ordered_quantity2,3);
502                   END IF;
503                   If p_old_line_rec.ordered_quantity2 Is NOT NULL AND
504                      p_old_line_rec.ordered_quantity2 <> FND_API.G_MISS_NUM AND
505                      p_old_line_rec.ordered_quantity Is NOT NULL AND
506                      p_old_line_rec.ordered_quantity <> FND_API.G_MISS_NUM Then
507                         p_x_line_rec.ordered_quantity2 := (p_old_line_rec.ordered_quantity2 / p_old_line_rec.ordered_quantity) * p_x_line_rec.ordered_quantity;
508                   END IF;
509                  -- Populate pricing quantity
510                   IF p_x_line_rec.ordered_quantity2 <> FND_API.G_MISS_NUM And
511                        p_x_line_rec.ordered_quantity2 IS NOT NULL and
512                        p_x_line_rec.pricing_quantity_uom is not null and
513                        p_x_line_rec.pricing_quantity_uom <> FND_API.G_MISS_CHAR
514 and
515                        p_x_line_rec.ordered_quantity_uom2 is not null  and
516                        p_x_line_rec.ordered_quantity_uom2 <> FND_API.G_MISS_CHAR Then
517                        IF p_x_line_rec.pricing_quantity_uom = p_x_line_rec.ordered_quantity_uom2 THEN
518                             IF l_debug_level  > 0 THEN
519                                   oe_debug_pub.add('pricing uom is same as ordered quantity2 uom');
520                             END IF;
521                             p_x_line_rec.Pricing_quantity := p_x_line_rec.ordered_quantity2;
522                        ELSE
523                              p_x_line_rec.Pricing_quantity :=
524                                         OE_Order_Misc_Util.convert_uom(
525                                                 p_x_line_rec.inventory_item_id,
526                                                 p_x_line_rec.order_quantity_uom,                                                p_x_line_rec.pricing_quantity_uom,
527                                                 p_x_line_rec.ordered_quantity
528                                                 );
529                               IF l_debug_level  > 0 THEN
530                                   oe_debug_pub.add('pricing uom is different than ordered quantity2 uom. p_x_line_rec.Pricing_quantity:'|| p_x_line_rec.Pricing_quantity);
531                             END IF;
532                          END IF; -- Pricing Quantity
533                    END IF; -- Check for existence of qty2, uom2 and pricing uom
534             END IF; -- end check for discrete catchweight
535       END IF; -- end check for item, warehouse existence
536    END IF; -- end check for referenced return
537 END Calc_Catchweight_Return_qty2;
538 
539 
540 
541 
542 /*----------------------------------------------------------
543 Procedure Apply_Attribute_Changes
544 -----------------------------------------------------------*/
545 
546 PROCEDURE Apply_Attribute_Changes
547 (   p_x_line_rec                    IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type
548 ,   p_old_line_rec                  IN  OE_Order_PUB.Line_Rec_Type :=
549                                         OE_Order_PUB.G_MISS_LINE_REC
550 )
551 IS
552 l_temp_pricing_quantity  NUMBER:=0;
553 L_RETURN_STATUS   		VARCHAR2(1);
554 L_IS_MODEL        		VARCHAR2(1);
555 -- The following variables have been declared for Shipping Integration
556 l_update_shipping			VARCHAR2(1) := FND_API.G_FALSE;
557 l_explosion_date_changed	VARCHAR2(1) := FND_API.G_FALSE;
558 l_ordered_quantity_changed	VARCHAR2(1) := FND_API.G_FALSE;
559 l_shipping_unique_key1		VARCHAR2(30);
560 l_shipping_param1			VARCHAR2(240);
561 l_x_line_Tbl                    OE_Order_PUB.Line_Tbl_Type;
562 l_temp_shipped_quantity		NUMBER;
563 l_validated_quantity		NUMBER;
564 l_primary_quantity			NUMBER;
565 l_qty_return_status			VARCHAR2(1);
566 --  End of Shipping Integration Variables
567 l_verify_payment_flag VARCHAR2(30) := 'N';
568 idx                   NUMBER; --ER 12363706
569 i					pls_integer;
570 l_Price_Control_Rec		QP_PREQ_GRP.control_record_type;
571 l_freeze_method   		VARCHAR2(30);
572 l_count           		NUMBER := 0;
573 l_copy_adjustments			boolean := FALSE;
574 l_copy_pricing_attributes	boolean := FALSE;
575 l_no_copy_adjustments		boolean := FALSE;
576 l_no_price_flag			boolean 	:= FALSE;
577 l_from_line_id				number;
578 l_from_Header_id			number;
579 l_return_code           		NUMBER;
580 l_error_buffer          		VARCHAR2(240);
581 l_x_result_out          		VARCHAR2(30);
582 l_turn_off_pricing      		VARCHAR2(30);
583 --OPM 06/SEP/00
584 l_item_rec                    OE_ORDER_CACHE.item_rec_type; -- INVCONV
585 -- l_OPM_shipped_quantity        NUMBER(19,9);  -- INVCONV
586 -- l_OPM_shipping_quantity_uom   VARCHAR2(4);   -- INVCONV
587 -- l_OPM_order_quantity_uom      VARCHAR2(4);   -- INVCONV
588 l_status                      VARCHAR2(1);
589 l_msg_count                   NUMBER;
590 l_msg_data                    VARCHAR2(2000);
591 --OPM 06/SEP/00 END
592 --OPM BUG 1491504 BEGIN
593 l_ordered_quantity            NUMBER := p_x_line_rec.ordered_quantity;
594 l_ordered_quantity2           NUMBER := p_x_line_rec.ordered_quantity2;
595 l_old_line_tbl	               OE_Order_PUB.Line_Tbl_Type;
596 l_line_tbl	               OE_Order_PUB.Line_Tbl_Type;
597 l_control_rec	               OE_GLOBALS.Control_Rec_Type;
598 --OPM BUG 1491504 END
599 /* csheu -- bug #1533658 start*/
600 l_copy_service_fields         boolean := FALSE;
601 /* csheu -- bug #1533658 end*/
602 l_zero_line_qty               boolean := FALSE;
603 /* lchen -- bug #1761154 start*/
604 l_serviceable_item   VARCHAR2(1);
605 l_serviced_model       VARCHAR2(1);
606 /* lchen -- bug #1761154 end*/
607 -- commitment bug 1829201
608 l_calculate_commitment_flag 	VARCHAR2(1) := 'N';
609 l_get_commitment_bal	 	VARCHAR2(1) := 'N';
610 l_update_commitment_flag 	VARCHAR2(1) := 'N';
611 l_update_commitment_applied 	VARCHAR2(1) := 'N';
612 l_class 			VARCHAR2(30);
613 l_so_source_code 		VARCHAR2(30);
614 l_oe_installed_flag 		VARCHAR2(30);
615 l_commitment_applied_amount	NUMBER := 0;
616 l_param1			VARCHAR2(30) := NULL;
617 l_item_chg_prof                 VARCHAR2(1);
618 --bug 1786835
619 l_charges_for_backorders     VARCHAR2(1):= G_CHARGES_FOR_BACKORDERS; /* Bug # 5036404 */
620 l_charges_for_included_item  VARCHAR2(1):= G_CHARGES_FOR_INCLUD_ITM; /* Bug # 5036404 */
621 -- bug 1406890
622 l_current_event number := 0;
623 l_tax_calculation_event_code number := 0; --renga's change
624 l_tax_calc_rec  OE_ORDER_CACHE.Tax_Calc_Rec_Type;
625 l_tax_calculation_flag varchar2(1) := NULL;  --end renga's change
626 l_tax_commt_flag varchar2(1) := 'N';   --bug 2505961
627 --B2037234  	EMC
628 --B2204216      EMC Assignment of IC$EPSILON profile value moved outside
629 --              declaration to OPM branch of code.
630 l_epsilon                       NUMBER;
631 n                       	NUMBER;
632 l_pricing_event                 VARCHAR2(30);
633 --RT{
634 l_retrobill_operation VARCHAR2(10);
635 --RT}
636 -- by default, pricing will be called for Freight Rating
637 -- after calling FTE.
638 l_get_FTE_freight_rate          VARCHAR2(1) := 'N';
639 l_3a7_attribute_change          VARCHAR2(1) := FND_API.G_FALSE;
640 l_wms_org_flag_new VARCHAR2(1) := 'X';
641 l_wms_org_flag_old  VARCHAR2(1) := 'X';
642 l_fte_count   NUMBER := 0;
643 l_call_pricing varchar2(1) := 'N';
644 
645 --Customer Acceptance
646 l_def_contingency_attributes VARCHAR2(1) := FND_API.G_FALSE;
647 --CC Encryption
648 l_delete_payment_count NUMBER;
649 --
650 -- bug 4378531
651 l_hold_result                   VARCHAR2(30);
652 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
653 --
654 --Bug#5026401
655 l_orig_line_calc_price_flag     VARCHAR2(1);
656 l_ship_inv_count NUMBER :=0;
657 
658 l_po_NeedByDate_Update   VARCHAR2(10); -- Adeed for IR ISO CMS project
659 --
660 l_credit_check_rule_rec OE_CREDIT_CHECK_UTIL.OE_credit_rules_rec_type; --ER 12363706
661 
662 -- ER#3667551 start
663 l_new_tbl_entry varchar2(10) := '';
664 l_bill_to_cust_id NUMBER := 0;
665 l_credithold_cust VARCHAR2(10) := NVL(OE_SYS_PARAMETERS.value('ONT_CREDITHOLD_TYPE'),'S') ;
666 -- ER#3667551 end
667 -- 14078867 start
668 l_old_itemcat NUMBER:= 0;
669 l_new_itemcat NUMBER:= 0;
670 -- 14078867 end
671 l_cc_rev_reauth_code VARCHAR2(30) := NULL; --CC Reversal ER#16014135
672 l_fulfillment_base  VARCHAR2(1);--ER#14763609
673 
674 --er 16317238
675 l_orig_pr_adjustment_id   NUMBER;
676 l_or_rltd_padj_id        NUMBER;
677 l_prg_list_line_id       NUMBER;
678 l_assoc_list_line_id     NUMBER;
679 l_prg_exist              VARCHAR2(1);
680 --er 16317238
681 
682 l_prg               VARCHAR2(1) := 'N'; --bug 16848168
683 
684 BEGIN
685 
686   if l_debug_level > 0 then
687     oe_debug_pub.add('Entering OE_LINE_UTIL.APPLY_ATTRIBUTE_CHANGES', 1);
688   end if;
689 
690     -- Query Header Record
691     -- Performance Improvement Bug 1929163
692     -- Use cached header rec instead of querying header rec into
693     -- a local variable
694     OE_Order_Cache.Load_Order_Header(p_x_line_rec.header_id);
695 
696     l_tax_calc_rec := oe_order_cache.get_tax_calculation_flag
697                                  (p_x_line_rec.line_type_id,
698                                   p_x_line_rec);
699 
700     l_tax_calculation_flag := l_tax_calc_rec.tax_calculation_flag;
701 
702     --CC Reversal ER#16014135 Start
703     l_cc_rev_reauth_code:= OE_VERIFY_PAYMENT_PUB.Get_CC_Rev_Reauth_Code(p_x_line_rec.header_id);
704    --CC Reversal ER#16014135 End
705 
706     IF NOT OE_GLOBALS.Equal(p_x_line_rec.accounting_rule_id,p_old_line_rec.accounting_rule_id)
707     THEN
708       --Customer Acceptance
709        l_def_contingency_attributes := FND_API.G_TRUE;
710     END IF;
711 
712     IF NOT OE_GLOBALS.Equal(p_x_line_rec.agreement_id,p_old_line_rec.agreement_id)
713     THEN
714          OE_GLOBALS.G_PRICE_FLAG := 'Y';
715 
716          -- bug 1829201, need to recalculate commitment.
717          IF p_x_line_rec.commitment_id is not null then
718            l_calculate_commitment_flag := 'Y';
719          END IF;
720     END IF;
721 
722     --bug3280378
723     --changes in the customer job field should be reflected in the
724     --shipping tables also
725     IF NOT
726 OE_GLOBALS.Equal(p_x_line_rec.customer_job,p_old_line_rec.customer_job) THEN
727 
728        l_update_shipping := FND_API.G_TRUE;
729 
730     END IF;
731     --bug3280378
732 
733     IF NOT OE_GLOBALS.Equal(p_x_line_rec.arrival_set_id,p_old_line_rec.arrival_set_id)
734     THEN
735 		-- Need to Call Shipping Update
736     		l_update_shipping	:= FND_API.G_TRUE;
737 
738     END IF;
739 
740     IF NOT OE_GLOBALS.Equal(p_x_line_rec.arrival_set,p_old_line_rec.arrival_set) THEN
741 
742 	NULL;
743 
744     END IF;
745 
746     -- CMS Date Changes
747 
748     IF NOT OE_GLOBALS.Equal(p_x_line_rec.schedule_arrival_date,p_old_line_rec.schedule_arrival_date)
749     THEN
750            -- Need to Call Shipping Update
751            l_update_shipping       := FND_API.G_TRUE;
752 
753     END IF;
754 
755     IF NOT OE_GLOBALS.Equal(p_x_line_rec.promise_date,p_old_line_rec.promise_date)
756     THEN
757            -- Need to Call Shipping Update
758            l_update_shipping       := FND_API.G_TRUE;
759 
760     END IF;
761 
762     IF NOT OE_GLOBALS.Equal(p_x_line_rec.earliest_acceptable_date,p_old_line_rec.earliest_acceptable_date)
763     THEN
764            -- Need to Call Shipping Update
765            l_update_shipping       := FND_API.G_TRUE;
766 
767     END IF;
768 
769     IF NOT OE_GLOBALS.Equal(p_x_line_rec.latest_acceptable_date,p_old_line_rec.latest_acceptable_date)
770     THEN
771            -- Need to Call Shipping Update
772            l_update_shipping       := FND_API.G_TRUE;
773 
774     END IF;
775 
776     IF NOT OE_GLOBALS.Equal(p_x_line_rec.earliest_ship_date,p_old_line_rec.earliest_ship_date)
777     THEN
778            -- Need to Call Shipping Update
779            l_update_shipping       := FND_API.G_TRUE;
780 
781     END IF;
782 
783 
784     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ato_line_id,p_old_line_rec.ato_line_id)
785     THEN
786 
787 		-- Need to Call Shipping Update
788     		l_update_shipping	:= FND_API.G_TRUE;
789 
790     END IF;
791 
792     -- Bug 10264299
793     IF NOT OE_GLOBALS.Equal(p_x_line_rec.line_number,p_old_line_rec.line_number)
794        OR NOT OE_GLOBALS.Equal(p_x_line_rec.shipment_number,p_old_line_rec.shipment_number)
795     THEN
796        --Need to Call Shipping Update
797        l_update_shipping   := FND_API.G_TRUE;
798      END IF;
799 
800 
801     IF NOT OE_GLOBALS.Equal(p_x_line_rec.cancelled_quantity,p_old_line_rec.cancelled_quantity)
802     THEN
803 
804 	-- Call Pricing
805         OE_GLOBALS.G_PRICE_FLAG := 'Y';
806 
807         -- bug 1829201, need to recalculate commitment.
808         IF p_x_line_rec.commitment_id is not null then
809           l_calculate_commitment_flag := 'Y';
810         END IF;
811 
812 	/* Additional task:
813 	Log delayed request for Verify Payment if the payment type
814 	is not CREDIT CARD and the Order line is Booked */
815 
816         IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
817 	    --IF NVL(OE_Order_Cache.g_header_rec.payment_type_code,'NULL') <> 'CREDIT_CARD'  --CC Reversal ER#16014135 Commented
818 	    IF (NVL(OE_Order_Cache.g_header_rec.payment_type_code,'NULL') <> 'CREDIT_CARD' OR l_cc_rev_reauth_code IS NOT NULL) --CC Reversal ER#16014135
819 		AND p_x_line_rec.booked_flag ='Y'
820 	    THEN
821 		-- Log Delayed Request for Verify Payment
822                if l_debug_level > 0 then
823 		oe_debug_pub.ADD('log verify payment delayed request for change in Canceled Qty');
824                end if;
825 		l_verify_payment_flag := 'Y';
826 	     END IF;
827 	 END IF;
828 
829     --Should not include any code here for cancellation specific
830     END IF;
831 
832     IF NOT OE_GLOBALS.Equal(p_x_line_rec.customer_dock_code,p_old_line_rec.customer_dock_code)
833     THEN
834 
835 		-- Need to Call Shipping Update
836     		l_update_shipping	:= FND_API.G_TRUE;
837 
838     END IF;
839 
840     IF NOT OE_GLOBALS.Equal(p_x_line_rec.cust_production_seq_num,p_old_line_rec.cust_production_seq_num)
841     THEN
842 	-- Need to Call Shipping Update
843     	l_update_shipping	:= FND_API.G_TRUE;
844     END IF;
845 
846 IF NOT OE_GLOBALS.Equal(p_x_line_rec.cust_po_number,p_old_line_rec.cust_po_number)
847     THEN
848 	 /*Changes for ER 6072870 begin*/
849 
850       IF (Nvl(p_x_line_rec.shipped_quantity,0)>0 AND          --suneela
851       p_x_line_rec.LINE_CATEGORY_CODE='ORDER')
852       THEN
853         l_ship_inv_count:= -1;
854         if l_debug_level > 0 THEN
855                oe_debug_pub.add('Need not query shipping tables hence setting the counter to -1');
856                oe_debug_pub.add('Line is already shipped,will not update shipping', 1);
857                end if;
858          FND_MESSAGE.SET_NAME('ONT', 'OE_PO_SHIPPED');
859          OE_MSG_PUB.ADD;
860 
861      ELSIF p_x_line_rec.LINE_CATEGORY_CODE='ORDER' THEN
862 
863       BEGIN
864        IF Nvl(p_x_line_rec.shipping_interfaced_flag,'N')='Y' THEN
865 
866           SELECT Count(1)
867           INTO l_ship_inv_count
868           FROM wsh_delivery_details wdd
869           WHERE  wdd.source_code='OE'
870                  AND wdd.source_line_id=p_x_line_rec.line_id
871                  AND (wdd.released_status IN ('C','I')
872                  OR oe_interfaced_flag='Y');
873 
874        ELSE
875           l_ship_inv_count:=0;
876        END IF;
877 
878       EXCEPTION
879       WHEN No_Data_Found THEN
880         l_ship_inv_count:=0;
881         if l_debug_level > 0 then
882          oe_debug_pub.add('the line is neither picked, shipped or interfaced. can call update shipping', 1);
883         end if;
884       END ;
885      END IF;
886 
887 	 -- Need to Call Shipping Update
888      IF l_ship_inv_count>0
889 
890       THEN
891                if l_debug_level > 0 then
892                oe_debug_pub.add('Line is already shipped,will not update shipping', 1);
893                end if;
894          FND_MESSAGE.SET_NAME('ONT', 'OE_PO_SHIPPED');
895          OE_MSG_PUB.ADD;
896 
897      ELSIF l_ship_inv_count=0 THEN
898 
899     	 l_update_shipping	:= FND_API.G_TRUE;
900 
901      END IF ;
902 
903     /*Changes for ER 6072870 end */
904 	 -- Call Pricing
905          OE_GLOBALS.G_PRICE_FLAG := 'Y';
906 
907         IF p_x_line_rec.commitment_id IS NOT NULL THEN
908           l_get_commitment_bal := 'Y';
909         END IF;
910 END IF;
911 
912     IF NOT OE_GLOBALS.Equal(p_x_line_rec.deliver_to_contact_id,p_old_line_rec.deliver_to_contact_id)
913     THEN
914 	 -- Need to Call Shipping Update
915     	 l_update_shipping	:= FND_API.G_TRUE;
916 	 -- Call Pricing
917          -- OE_GLOBALS.G_PRICE_FLAG := 'Y';  Commented out for fix 1419204
918     END IF;
919 
920     IF NOT OE_GLOBALS.Equal(p_x_line_rec.deliver_to_org_id,p_old_line_rec.deliver_to_org_id)
921     THEN
922 	 -- Need to Call Shipping Update
923     	 l_update_shipping	:= FND_API.G_TRUE;
924 	 -- Call Pricing
925       -- OE_GLOBALS.G_PRICE_FLAG := 'Y'; Commented out for fix 1419204
926 
927 
928     END IF;
929 
930     IF NOT OE_GLOBALS.Equal(p_x_line_rec.explosion_date,p_old_line_rec.explosion_date)
931     THEN
932 	IF OE_GLOBALS.EQUAL(p_x_line_rec.ship_model_complete_flag,'Y') THEN
933     		l_explosion_date_changed	:= FND_API.G_TRUE;
934 	END IF;
935     END IF;
936 
937     IF NOT OE_GLOBALS.Equal(p_x_line_rec.fob_point_code,p_old_line_rec.fob_point_code)
938     THEN
939 		-- Need to Call Shipping Update
940     		l_update_shipping	:= FND_API.G_TRUE;
941     END IF;
942 
943     IF NOT OE_GLOBALS.Equal(p_x_line_rec.freight_terms_code,p_old_line_rec.freight_terms_code)
944     THEN
945 		-- Need to Call Shipping Update
946     		l_update_shipping	:= FND_API.G_TRUE;
947     END IF;
948 
949     IF NOT OE_GLOBALS.Equal(p_x_line_rec.calculate_price_flag,p_old_line_rec.calculate_price_flag)
950     THEN
951 
952 	   If p_x_line_rec.calculate_price_flag = 'Y' then
953 	   	Begin
954 
955 			OE_Order_Cache.Enforce_List_price(p_line_type_id => p_x_line_rec.Line_Type_id
956 										, p_header_id => p_x_line_rec.header_id);
957 
958 	     	exception when no_data_found then
959 				OE_Order_Cache.g_Enforce_list_price_rec.enforce_line_prices_flag := 'N';
960 	   	end ;
961 
962         	If  OE_Order_Cache.g_Enforce_list_price_rec.enforce_line_prices_flag = 'Y'  Then
963 			p_x_line_rec.calculate_price_flag := 'P';
964 	   	End If;
965 
966 		IF p_x_line_rec.open_flag = 'N' or
967 			p_x_line_rec.cancelled_flag = 'Y'
968 		THEN
969 
970 			 p_x_line_rec.calculate_price_flag := 'N';
971 
972 		End If;
973 
974 	   End If; -- For price_flag='Y'
975 
976       -- bug 3585862
977       if l_debug_level > 0 then
978          oe_debug_pub.add('old calculate price flag'||p_old_line_rec.calculate_price_flag, 3);
979          oe_debug_pub.add('new calculate price flag'||p_x_line_rec.calculate_price_flag, 3);
980       end if;
981       IF Nvl(oe_globals.g_pricing_recursion,'N') = 'N'
982         AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
983         AND ((p_old_line_rec.calculate_price_flag in ('N','P') and p_x_line_rec.calculate_price_flag = 'Y')
984              OR (p_old_line_rec.calculate_price_flag = 'N' and p_x_line_rec.calculate_price_flag = 'P'))
985       THEN
986         if l_debug_level > 0 then
987           oe_debug_pub.add('setting price flag because of calculate price flag change', 3);
988         end if;
989         IF nvl(OE_GLOBALS.G_PRICE_FLAG, 'N') <> 'Y' THEN
990   	  OE_GLOBALS.G_PRICE_FLAG := 'Y';
991           OE_LINE_ADJ_UTIL.Register_Changed_Lines
992           (p_line_id         => p_x_line_rec.line_id,
993            p_header_id       => p_x_line_rec.header_id,
994            p_operation       => p_x_line_rec.operation );
995         END IF;
996       END IF;
997       -- end bug 3585862
998     END IF;
999 
1000     IF NOT OE_GLOBALS.Equal(p_x_line_rec.intermed_ship_to_org_id,p_old_line_rec.intermed_ship_to_org_id)
1001     THEN
1002 		-- Need to Call Shipping Update
1003     		l_update_shipping	:= FND_API.G_TRUE;
1004         /* may need to call pricing */
1005         /*
1006           OE_GLOBALS.G_PRICE_FLAG := 'Y';
1007         */
1008 
1009     END IF;
1010 
1011     IF NOT OE_GLOBALS.Equal(p_x_line_rec.intermed_ship_to_contact_id,p_old_line_rec.intermed_ship_to_contact_id)
1012     THEN
1013 		-- Need to Call Shipping Update
1014     		l_update_shipping	:= FND_API.G_TRUE;
1015         /* may need to call pricing */
1016         /*
1017           OE_GLOBALS.G_PRICE_FLAG := 'Y';
1018         */
1019     END IF;
1020 
1021 
1022     IF NOT OE_GLOBALS.Equal(p_x_line_rec.inventory_item_id,p_old_line_rec.inventory_item_id)
1023     THEN
1024 
1025       -- QUOTING changes - log explosion request only for lines in
1026       -- fulfillment phase
1027       IF nvl(p_x_line_rec.transaction_phase_code,'F') = 'F' THEN
1028 
1029     -- log a delayed request to get included items for this item if any.
1030 
1031       l_freeze_method := G_FREEZE_METHOD; /* Bug # 5036404 */
1032      if l_debug_level > 0 then
1033       oe_debug_pub.ADD('Freeze method is :' || l_freeze_method,2);
1034      end if;
1035       --3286378 : Added check for operation= create
1036       IF (l_freeze_method = OE_GLOBALS.G_IIFM_ENTRY AND
1037          (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE OR
1038           (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
1039            p_x_line_rec.split_from_line_id IS NULL)) AND
1040          p_x_line_rec.ato_line_id is NULL AND
1041          ( p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
1042            (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT AND
1043             p_x_line_rec.line_id = p_x_line_rec.top_model_line_id))
1044 /* Start DOO Pre Exploded Kit ER 9339742 */
1045            AND NOT(OE_GENESIS_UTIL.G_INCOMING_FROM_DOO))
1046           OR
1047            (((p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND (OE_GENESIS_UTIL.G_INCOMING_FROM_DOO)) OR
1048             (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
1049              p_x_line_rec.split_from_line_id IS NULL AND p_x_line_rec.pre_exploded_flag = 'Y'))
1050            AND p_x_line_rec.ato_line_id is NULL
1051            AND ( (( p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT OR p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL)
1052                AND p_x_line_rec.line_id = p_x_line_rec.top_model_line_id)
1053              OR p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS))
1054       THEN
1055            IF OE_GENESIS_UTIL.G_INCOMING_FROM_DOO THEN
1056              if l_debug_level > 0 then
1057                oe_debug_pub.ADD(' The update is from DOO Pre Exploded Kit ER',5);
1058              end if;
1059            END IF;
1060 /* End DOO Pre Exploded Kit ER 9339742 */
1061            if l_debug_level > 0 then
1062               oe_debug_pub.ADD('LINE ID : '||p_x_line_rec.line_id,2);
1063            end if;
1064            p_x_line_rec.explosion_date := null;
1065            l_count := l_count + 1;
1066            OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL(l_count):= p_x_line_rec.line_id;
1067       END IF;
1068 
1069       END IF; -- End if phase is fulfillment
1070       -- END QUOTING changes
1071 
1072       --Customer Acceptance
1073        l_def_contingency_attributes := FND_API.G_TRUE;
1074 
1075       --  NULL;
1076       -- Need to Call Shipping Update
1077       l_update_shipping	:= FND_API.G_TRUE;
1078 
1079 	 IF ( p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
1080 	    NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT' )
1081             -- QUOTING change
1082             AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
1083          THEN
1084      if l_debug_level > 0 then
1085       oe_debug_pub.ADD('item update: logging request for eval_hold_source');
1086          oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
1087                    ' Entity ID: '|| to_char(p_x_line_rec.inventory_item_id));
1088      end if;
1089 
1090          OE_delayed_requests_Pvt.log_request
1091                  (p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
1092                   p_entity_id         => p_x_line_rec.line_id,
1093                   p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
1094                   p_requesting_entity_id         => p_x_line_rec.line_id,
1095                   p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
1096                   p_request_unique_key1 => 'ITEM',
1097                   p_param1		 => 'I',
1098                   p_param2		 => p_x_line_rec.inventory_item_id,
1099                   x_return_status     => l_return_status);
1100        if l_debug_level > 0 then
1101          oe_debug_pub.ADD('after call to log_request: l_return_status: '||
1102 							   l_return_status , 1);
1103        end if;
1104 
1105 	   -- 14078867 Start
1106 	   -- Get Item Category IDs
1107 	   l_old_itemcat := OE_ITORD_UTIL.get_item_category_id(p_old_line_rec.inventory_item_id);
1108 	   l_new_itemcat := OE_ITORD_UTIL.get_item_category_id(p_x_line_rec.inventory_item_id);
1109 	   if l_debug_level > 0 then
1110         oe_debug_pub.ADD(' Old ItemID: '||p_old_line_rec.inventory_item_id||
1111 		                 ' -Old Category ID: '||l_old_itemcat||
1112 						 ' -New ItemID: '||p_x_line_rec.inventory_item_id||
1113 						 ' -New Category ID: '||l_new_itemcat);
1114         end if;
1115 	   If (l_old_itemcat <> l_new_itemcat )
1116 	   THEN
1117 	    if l_debug_level > 0 then
1118         oe_debug_pub.ADD('item update, Item Category Different: logging request for eval_hold_source');
1119          oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
1120                    ' Entity ID: '|| l_new_itemcat);
1121         end if;
1122 
1123          OE_delayed_requests_Pvt.log_request
1124                  (p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
1125                   p_entity_id         => p_x_line_rec.line_id,
1126                   p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
1127                   p_requesting_entity_id         => p_x_line_rec.line_id,
1128                   p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
1129                   p_request_unique_key1 => 'ITEMCATEGORY',
1130                   p_param1		 => 'IC',
1131                   p_param2		 => l_new_itemcat,
1132                   x_return_status     => l_return_status);
1133        if l_debug_level > 0 then
1134          oe_debug_pub.ADD('after call to log_request: l_return_status: '||
1135 							   l_return_status , 1);
1136        end if;
1137 	   End IF;
1138 	   -- 14078867 End
1139 
1140        END IF;
1141        -- Item ID has changed. Need to redo balance checking
1142        if p_x_line_rec.commitment_id is not null then
1143          null;
1144        end if;
1145 
1146        -- Redefault Globalization flexfield
1147        -- Performance Improvement Bug 1929163
1148        -- JG has provided a NOCOPY spec via bug 1950033
1149      if l_debug_level > 0 then
1150        oe_debug_pub.add('before calling jg');
1151      end if;
1152       ---Start bug 14317960 --Comparing so that User passed value are always honoured
1153      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute1,p_old_line_rec.global_attribute1) then
1154        if l_debug_level > 0 then
1155           oe_debug_pub.add('p_x_line_rec.global_attribute1'|| p_x_line_rec.global_attribute1);
1156        end if;
1157        p_x_line_rec.global_attribute1 := NULL;
1158      End IF ;
1159 
1160      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute2,p_old_line_rec.global_attribute2) then
1161        if l_debug_level > 0 then
1162           oe_debug_pub.add('p_x_line_rec.global_attribute2'|| p_x_line_rec.global_attribute2);
1163        end if;
1164        p_x_line_rec.global_attribute2 := NULL;
1165      End IF ;
1166 
1167 
1168      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute3,p_old_line_rec.global_attribute3) then
1169        if l_debug_level > 0 then
1170           oe_debug_pub.add('p_x_line_rec.global_attribute3'|| p_x_line_rec.global_attribute3);
1171        end if;
1172        p_x_line_rec.global_attribute3 := NULL;
1173      End IF ;
1174 
1175      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute4,p_old_line_rec.global_attribute4) then
1176        if l_debug_level > 0 then
1177           oe_debug_pub.add('p_x_line_rec.global_attribute4'|| p_x_line_rec.global_attribute4);
1178        end if;
1179        p_x_line_rec.global_attribute4 := NULL;
1180      End IF ;
1181 
1182      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute5,p_old_line_rec.global_attribute5) then
1183        if l_debug_level > 0 then
1184           oe_debug_pub.add('p_x_line_rec.global_attribute5'|| p_x_line_rec.global_attribute5);
1185        end if;
1186        p_x_line_rec.global_attribute5 := NULL;
1187      End IF ;
1188 
1189      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute6,p_old_line_rec.global_attribute6) then
1190        if l_debug_level > 0 then
1191           oe_debug_pub.add('p_x_line_rec.global_attribute6'|| p_x_line_rec.global_attribute6);
1192        end if;
1193        p_x_line_rec.global_attribute6 := NULL;
1194      End IF ;
1195 
1196      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute7,p_old_line_rec.global_attribute7) then
1197        if l_debug_level > 0 then
1198           oe_debug_pub.add('p_x_line_rec.global_attribute7'|| p_x_line_rec.global_attribute7);
1199        end if;
1200        p_x_line_rec.global_attribute7 := NULL;
1201      End IF ;
1202 
1203      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute8,p_old_line_rec.global_attribute8) then
1204        if l_debug_level > 0 then
1205           oe_debug_pub.add('p_x_line_rec.global_attribute8'|| p_x_line_rec.global_attribute8);
1206        end if;
1207        p_x_line_rec.global_attribute8 := NULL;
1208      End IF ;
1209 
1210      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute9,p_old_line_rec.global_attribute9) then
1211        if l_debug_level > 0 then
1212           oe_debug_pub.add('p_x_line_rec.global_attribute9'|| p_x_line_rec.global_attribute9);
1213        end if;
1214        p_x_line_rec.global_attribute9 := NULL;
1215      End IF ;
1216 
1217      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute10,p_old_line_rec.global_attribute10) then
1218        if l_debug_level > 0 then
1219          oe_debug_pub.add('p_x_line_rec.global_attribute10'|| p_x_line_rec.global_attribute10);
1220        end if;
1221        p_x_line_rec.global_attribute10 := NULL;
1222      End IF ;
1223 
1224      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute11,p_old_line_rec.global_attribute11) then
1225        if l_debug_level > 0 then
1226          oe_debug_pub.add('p_x_line_rec.global_attribute11'|| p_x_line_rec.global_attribute11);
1227        end if;
1228        p_x_line_rec.global_attribute11 := NULL;
1229      End IF ;
1230 
1231      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute12,p_old_line_rec.global_attribute12) then
1232        if l_debug_level > 0 then
1233           oe_debug_pub.add('p_x_line_rec.global_attribute12'|| p_x_line_rec.global_attribute12);
1234        end if;
1235        p_x_line_rec.global_attribute12 := NULL;
1236      End IF ;
1237 
1238      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute13,p_old_line_rec.global_attribute13) then
1239        if l_debug_level > 0 then
1240          oe_debug_pub.add('p_x_line_rec.global_attribute13'|| p_x_line_rec.global_attribute13);
1241        end if;
1242        p_x_line_rec.global_attribute13 := NULL;
1243      End IF ;
1244 
1245      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute14,p_old_line_rec.global_attribute14) then
1246       if l_debug_level > 0 then
1247          oe_debug_pub.add('p_x_line_rec.global_attribute14'|| p_x_line_rec.global_attribute14);
1248        end if;
1249        p_x_line_rec.global_attribute14:= NULL;
1250      End IF ;
1251 
1252      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute15,p_old_line_rec.global_attribute15) then
1253       if l_debug_level > 0 then
1254          oe_debug_pub.add('p_x_line_rec.global_attribute15'|| p_x_line_rec.global_attribute15);
1255       end if;
1256       p_x_line_rec.global_attribute15 := NULL;
1257      End IF ;
1258 
1259      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute16,p_old_line_rec.global_attribute16) then
1260        if l_debug_level > 0 then
1261         oe_debug_pub.add('p_x_line_rec.global_attribute16'|| p_x_line_rec.global_attribute16);
1262        end if;
1263        p_x_line_rec.global_attribute16 := NULL;
1264      End IF ;
1265 
1266      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute17,p_old_line_rec.global_attribute17) then
1267        if l_debug_level > 0 then
1268         oe_debug_pub.add('p_x_line_rec.global_attribute17'|| p_x_line_rec.global_attribute17);
1269        end if;
1270        p_x_line_rec.global_attribute17 := NULL;
1271      End IF ;
1272 
1273      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute18,p_old_line_rec.global_attribute18) then
1274        if l_debug_level > 0 then
1275           oe_debug_pub.add('p_x_line_rec.global_attribute18'|| p_x_line_rec.global_attribute18);
1276        end if;
1277        p_x_line_rec.global_attribute18 := NULL;
1278      End IF ;
1279 
1280      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute19,p_old_line_rec.global_attribute19) then
1281        if l_debug_level > 0 then
1282          oe_debug_pub.add('p_x_line_rec.global_attribute19'|| p_x_line_rec.global_attribute19);
1283        end if;
1284        p_x_line_rec.global_attribute19 := NULL;
1285      End IF ;
1286 
1287      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute20,p_old_line_rec.global_attribute20) then
1288        if l_debug_level > 0 then
1289          oe_debug_pub.add('p_x_line_rec.global_attribute20'|| p_x_line_rec.global_attribute20);
1290        end if;
1291        p_x_line_rec.global_attribute20 := NULL;
1292      End IF ;
1293 
1294      IF OE_GLOBALS.Equal(p_x_line_rec.global_attribute_category,p_old_line_rec.global_attribute_category) then
1295       if l_debug_level > 0 then
1296          oe_debug_pub.add('global_attribute_category'|| p_x_line_rec.global_attribute_category);
1297        end if;
1298        p_x_line_rec.global_attribute_category := NULL;
1299      End IF ;
1300 
1301 
1302       ---End Bug 14317960 , 14478792 , commenting the below code
1303    /* --Start of bug#12653896
1304        p_x_line_rec.global_attribute1 := NULL;
1305        p_x_line_rec.global_attribute2 := NULL;
1306        p_x_line_rec.global_attribute3 := NULL;
1307        p_x_line_rec.global_attribute4 := NULL;
1308        p_x_line_rec.global_attribute5 := NULL;
1309        p_x_line_rec.global_attribute6 := NULL;
1310        p_x_line_rec.global_attribute7 := NULL;
1311        p_x_line_rec.global_attribute8 := NULL;
1312        p_x_line_rec.global_attribute9 := NULL;
1313        p_x_line_rec.global_attribute10 := NULL;
1314        p_x_line_rec.global_attribute11 := NULL;
1315        p_x_line_rec.global_attribute12 := NULL;
1316        p_x_line_rec.global_attribute13 := NULL;
1317        p_x_line_rec.global_attribute14 := NULL;
1318        p_x_line_rec.global_attribute15 := NULL;
1319        p_x_line_rec.global_attribute16 := NULL;
1320        p_x_line_rec.global_attribute17 := NULL;
1321        p_x_line_rec.global_attribute18 := NULL;
1322        p_x_line_rec.global_attribute19 := NULL;
1323        p_x_line_rec.global_attribute20 := NULL;
1324        p_x_line_rec.global_attribute_category := NULL;  --End of bug#12653896   */
1325        JG_ZZ_OM_COMMON_PKG.default_gdf(
1326                                 x_line_rec=>p_x_line_rec,
1327 				x_return_code => l_return_code,
1328 				x_error_buffer => l_error_buffer);
1329      if l_debug_level > 0 then
1330        oe_debug_pub.add('after calling jg');
1331      end if;
1332        --bug 2971066 Begin
1333        l_item_chg_prof := fnd_profile.value('ONT_HONOR_ITEM_CHANGE');
1334 if l_debug_level > 0 then
1335  oe_debug_pub.add('value of ONT_HONOR_ITEM_CHANGE:'||l_item_chg_prof,5);
1336  oe_debug_pub.add('p_x_line_rec.inventory_item_id : '||p_x_line_rec.inventory_item_id);
1337  oe_debug_pub.add('p_old_line_rec.inventory_item_id : '||p_old_line_rec.inventory_item_id);
1338 end if;
1339        IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
1340         /*if nvl(p_x_line_rec.inventory_item_id,FND_API.G_MISS_NUM)
1341           <> FND_API.G_MISS_NUM
1342         and nvl(p_old_line_rec.inventory_item_id,FND_API.G_MISS_NUM) <>
1343              FND_API.G_MISS_NUM*/
1344         IF (
1345               (nvl(p_x_line_rec.inventory_item_id,FND_API.G_MISS_NUM)
1346                <> FND_API.G_MISS_NUM
1347                and nvl(p_old_line_rec.inventory_item_id,FND_API.G_MISS_NUM)
1348                <> FND_API.G_MISS_NUM )
1349            -- Bug# 3942402
1350            -- For Case1:
1351             or
1352               (nvl(p_x_line_rec.inventory_item_id,FND_API.G_MISS_NUM)
1353                = FND_API.G_MISS_NUM
1354                and nvl(p_old_line_rec.inventory_item_id,FND_API.G_MISS_NUM)
1355                <> FND_API.G_MISS_NUM )
1356             )
1357            -- Bug# 3942402 end
1358         and p_x_line_rec.calculate_price_flag in ('N','P')
1359         and nvl(l_item_chg_prof,'N') = 'N' then
1360           if l_debug_level > 0 then
1361             oe_debug_pub.add('Changing calculate price flag to Y');
1362           end if;
1363             p_x_line_rec.calculate_price_flag := 'Y';
1364         end if;
1365        -- bug 2971066 end
1366        -- bug 1819133, need to recalculate price if item is updated
1367        ELSIF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
1368         --change made for bug 1998333      Begin
1369           if nvl(l_item_chg_prof,'N') = 'N' then
1370            --retaining the old behaviour
1371             p_x_line_rec.calculate_price_flag := 'Y';
1372           else
1373            --we do not change anything
1374             null;
1375           end if;
1376         --change made for bug 1998333      End
1377        END IF;
1378 
1379        OE_GLOBALS.G_PRICE_FLAG := 'Y';
1380 
1381        -- bug 1829201, need to recalculate commitment.
1382        IF p_x_line_rec.commitment_id is not null then
1383          l_calculate_commitment_flag := 'Y';
1384        END IF;
1385 
1386        IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
1387           AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
1388                                      (p_x_line_rec.header_id)
1389               = 'OM_CALLED_FREIGHT_RATES' THEN
1390           if l_debug_level > 0 then
1391             oe_debug_pub.add('Log Freight Rating request for item change. ',3);
1392           end if;
1393             l_get_FTE_freight_rate := 'Y';
1394        END IF;
1395 
1396 
1397 /*sdatti*/
1398      if l_debug_level > 0 then
1399        oe_debug_pub.ADD('OE_GLOBALS.G_PRICING_RECURSION:'||oe_globals.g_pricing_recursion,1);
1400      end if;
1401        IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110509' THEN
1402         IF Nvl(oe_globals.g_pricing_recursion,'N') = 'N'  THEN
1403 	  update_adjustment_flags(p_old_line_rec,p_x_line_rec);
1404         END IF;
1405        END IF;
1406 /*sdatti*/
1407 
1408     END IF;
1409 
1410 
1411     IF NOT OE_GLOBALS.Equal(p_x_line_rec.invoice_to_org_id,p_old_line_rec.invoice_to_org_id)
1412     THEN
1413         /* may need to call pricing */
1414 
1415           OE_GLOBALS.G_PRICE_FLAG := 'Y';
1416 		  -- 12876258 Start Enable Log delayed request for taxing
1417 		  OE_GLOBALS.G_TAX_FLAG := 'Y';
1418 		  if l_debug_level > 0 then
1419 		  oe_debug_pub.add('TaxFlag set for invoice to org change');
1420 		  end if; -- 12876258 End addition
1421 	  --Customer Acceptance
1422 	  l_def_contingency_attributes := FND_API.G_TRUE;
1423 
1424           IF p_x_line_rec.commitment_id IS NOT NULL THEN
1425             l_get_commitment_bal := 'Y';
1426           END IF;
1427 
1428 	   IF ( p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
1429 	      NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT')
1430                -- QUOTING change
1431               AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
1432            THEN
1433                 if l_debug_level > 0 then
1434                   oe_debug_pub.ADD('invoice site update: logging request for eval_hold_source');
1435                   oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
1436 		         ' Entity ID: '|| to_char(p_x_line_rec.invoice_to_org_id));
1437                 end if;
1438                   OE_delayed_requests_Pvt.log_request(
1439                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
1440                     p_entity_id         => p_x_line_rec.line_id,
1441 			     p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
1442 			     p_requesting_entity_id         => p_x_line_rec.line_id,
1443                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
1444                     p_request_unique_key1 => 'BILL_TO',
1445                     p_param1		 => 'B',
1446                     p_param2		 => p_x_line_rec.invoice_to_org_id,
1447                     x_return_status     => l_return_status);
1448         END IF;
1449 
1450 	IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
1451 		--R12 CC Encryption
1452 		select count(payment_type_code) into
1453 		l_delete_payment_count from oe_payments
1454 		where header_id = p_x_line_rec.header_id
1455 		and line_id = p_x_line_rec.line_id and
1456 		payment_type_code in ('ACH','DIRECT_DEBIT','CREDIT_CARD');
1457 
1458 		 --Delayed request for deleting the payments when
1459 		 --invoice to changes
1460 		 IF l_delete_payment_count > 0 THEN
1461 			OE_delayed_requests_Pvt.log_request
1462 			    (p_entity_code            	=> OE_GLOBALS.G_ENTITY_LINE_PAYMENT,
1463 			     p_entity_id              	=> p_x_line_rec.line_id,
1464 			     p_requesting_entity_code	=> OE_GLOBALS.G_ENTITY_LINE_PAYMENT,
1465 			     p_requesting_entity_id  	=> p_x_line_rec.line_id,
1466 			     p_request_type           	=> OE_GLOBALS.G_DELETE_PAYMENTS,
1467 			     p_param1			=> p_x_line_rec.header_id,
1468 			     p_param2			=> to_char(p_old_line_rec.invoice_to_org_id),
1469 			     x_return_status         	=> l_return_status);
1470 		  END IF;--Payment type code check
1471 		  --R12 CC Encryption
1472 		/* Additional Task : Log a delayed request for Verify payment
1473 		(Credit Checking) when the bill to site changes for a booked line */
1474 		--IF NVL(OE_Order_Cache.g_header_rec.payment_type_code,'NULL') <>  'CREDIT_CARD' --CC Reversal ER#16014135 Commented
1475 		IF (NVL(OE_Order_Cache.g_header_rec.payment_type_code,'NULL') <> 'CREDIT_CARD' OR l_cc_rev_reauth_code IS NOT NULL) --CC Reversal ER#16014135
1476 		AND  p_x_line_rec.booked_flag ='Y'
1477 		THEN
1478                       if l_debug_level > 0 then
1479 			oe_debug_pub.ADD('log verify payment delayed request for change in invoice to site');
1480                       end if;
1481 			l_verify_payment_flag := 'Y';
1482 			OE_CREDIT_ENGINE_GRP.TOLERANCE_CHECK_REQUIRED := FALSE; --ER 12363706
1483 
1484 		END IF;
1485 	        --ER 12363706 start
1486 
1487 	        idx                                                                := OE_CREDIT_CHECK_UTIL.G_CC_Invoice_tab.count;
1488 	        OE_CREDIT_CHECK_UTIL.G_CC_Invoice_tab(idx+1).new_invoice_to_org_id := p_x_line_rec.invoice_to_org_id;
1489 	        OE_CREDIT_CHECK_UTIL.G_CC_Invoice_tab(idx+1).old_invoice_to_org_id := p_old_line_rec.invoice_to_org_id;
1490 	        OE_CREDIT_CHECK_UTIL.G_CC_Invoice_tab(idx+1).line_id               := p_x_line_rec.line_id;
1491 	        --ER 12363706 end
1492 	END IF;
1493 
1494     END IF;
1495 
1496    -- Changes for Blanket Orders
1497 
1498    IF NOT OE_GLOBALS.Equal(p_x_line_rec.blanket_number,p_old_line_rec.blanket_number)  OR
1499       NOT OE_GLOBALS.Equal(p_x_line_rec.blanket_line_number,p_old_line_rec.blanket_line_number)
1500     THEN
1501         --for ER 2901219
1502         --To trigger Pricing event if Blanket Number or Line Number is Changed
1503         OE_GLOBALS.G_PRICE_FLAG := 'Y';
1504 
1505         IF ( p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
1506 	     NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT')
1507              -- QUOTING change
1508              AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
1509         THEN
1510                   OE_delayed_requests_Pvt.log_request(
1511                     p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
1512                     p_entity_id              => p_x_line_rec.line_id,
1513                     p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
1514                     p_requesting_entity_id   => p_x_line_rec.line_id,
1515                     p_request_type           => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
1516                     p_param1                 => 'H',
1517                     p_param2                 => p_x_line_rec.blanket_number,
1518                     x_return_status          => l_return_status);
1519         END IF;
1520     END IF;
1521 
1522     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_item_id,p_old_line_rec.ordered_item_id)
1523     THEN
1524         /*  need to reprice the line*/
1525 
1526         -- bug 1819133, need to recalculate price if item is updated
1527         IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
1528       if l_debug_level > 0 then
1529         oe_debug_pub.add('before checking profile ONT_HONOR_ITEM_CHANGE',5);
1530       end if;
1531         --change made for bug 1998333      Begin
1532           l_item_chg_prof := fnd_profile.value('ONT_HONOR_ITEM_CHANGE');
1533 if l_debug_level > 0 then
1534  oe_debug_pub.add('value of profile ONT_HONOR_ITEM_CHANGE:'||l_item_chg_prof,5);
1535 end if;
1536           if nvl(l_item_chg_prof,'N') = 'N' then
1537            --retaining the old behaviour
1538             p_x_line_rec.calculate_price_flag := 'Y';
1539           else
1540            --we do not change anything
1541             null;
1542           end if;
1543         --change made for bug 1998333      End
1544         END IF;
1545 
1546         OE_GLOBALS.G_PRICE_FLAG := 'Y';
1547 
1548         -- bug 1829201, need to recalculate commitment.
1549         IF p_x_line_rec.commitment_id is not null then
1550           l_calculate_commitment_flag := 'Y';
1551         END IF;
1552 
1553     END IF;
1554 
1555     IF NOT OE_GLOBALS.Equal(p_x_line_rec.item_identifier_type,p_old_line_rec.item_identifier_type)
1556     THEN
1557         /*  need to reprice the line*/
1558         -- OE_GLOBALS.G_PRICE_FLAG := 'Y'; Commented out for fix 1419204
1559            null;
1560 
1561     END IF;
1562 
1563     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_item,p_old_line_rec.ordered_item)
1564     THEN
1565 	    -- Call Pricing
1566        -- bug 1819133, need to recalculate price if item is updated
1567        IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
1568       if l_debug_level > 0 then
1569         oe_debug_pub.add('before checking profile ONT_HONOR_ITEM_CHANGE',5);
1570       end if;
1571         --change made for bug 1998333      Begin
1572           l_item_chg_prof := fnd_profile.value('ONT_HONOR_ITEM_CHANGE');
1573 if l_debug_level > 0 then
1574  oe_debug_pub.add('value of profile ONT_HONOR_ITEM_CHANGE:'||l_item_chg_prof,5);
1575 end if;
1576           if nvl(l_item_chg_prof,'N') = 'N' then
1577            --retaining the old behaviour
1578             p_x_line_rec.calculate_price_flag := 'Y';
1579           else
1580            --we do not change anything
1581             null;
1582           end if;
1583         --change made for bug 1998333      End
1584        END IF;
1585 
1586        OE_GLOBALS.G_PRICE_FLAG := 'Y';
1587 
1588        OE_GLOBALS.G_TAX_FLAG := 'Y';
1589 
1590        -- bug 1829201, need to recalculate commitment.
1591        IF p_x_line_rec.commitment_id is not null then
1592          l_calculate_commitment_flag := 'Y';
1593        END IF;
1594     END IF;
1595 
1596     IF NOT OE_GLOBALS.Equal(p_x_line_rec.item_revision,p_old_line_rec.item_revision)
1597     THEN
1598 		-- Need to Call Shipping Update
1599     		l_update_shipping	:= FND_API.G_TRUE;
1600     END IF;
1601 
1602     IF NOT OE_GLOBALS.Equal(p_x_line_rec.item_type_code,p_old_line_rec.item_type_code)
1603     THEN
1604 
1605       -- Need to Call Shipping Update
1606     	 l_update_shipping	:= FND_API.G_TRUE;
1607 
1608       -- QUOTING changes - log explosion request only for lines in
1609       -- fulfillment phase
1610       IF nvl(p_x_line_rec.transaction_phase_code,'F') = 'F' THEN
1611 
1612       -- log a delayed request to get included items for this item if any.
1613 
1614       l_freeze_method := G_FREEZE_METHOD; /* Bug # 5036404 */
1615     if l_debug_level > 0 then
1616       oe_debug_pub.ADD('Freeze method is :' || l_freeze_method,2);
1617     end if;
1618 
1619       IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
1620          p_x_line_rec.booked_flag = 'Y' AND
1621          l_freeze_method <> OE_GLOBALS.G_IIFM_PICK_RELEASE
1622       THEN
1623         l_freeze_method := OE_GLOBALS.G_IIFM_ENTRY;
1624       END IF;
1625 
1626       l_freeze_method := nvl(l_freeze_method, OE_GLOBALS.G_IIFM_ENTRY);
1627 
1628       IF l_freeze_method = OE_GLOBALS.G_IIFM_ENTRY AND
1629          p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
1630          p_x_line_rec.ato_line_id is NULL AND
1631          ( p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
1632            p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
1633            p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT )
1634       THEN
1635        if l_debug_level > 0 then
1636          oe_debug_pub.ADD('freeze inc items ' || l_freeze_method,2);
1637        end if;
1638            l_count := l_count + 1;
1639            OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL(l_count)
1640                                           := p_x_line_rec.line_id;
1641       END IF;
1642       END IF; -- End if phase is fulfillment
1643       -- END QUOTING changes
1644 
1645       -- Need to log Freight Rating request for configured item.
1646       IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
1647           AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
1648                (p_x_line_rec.header_id) = 'OM_CALLED_FREIGHT_RATES'
1649           AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE
1650           AND p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CONFIG THEN
1651            if l_debug_level > 0 then
1652             oe_debug_pub.add('Log Freight Rating request for CONFIG item. ',3);
1653            end if;
1654             l_get_FTE_freight_rate := 'Y';
1655       END IF;
1656 
1657       --Customer Acceptance
1658        l_def_contingency_attributes := FND_API.G_TRUE;
1659 
1660     END IF;
1661 
1662     IF NOT OE_GLOBALS.Equal(p_x_line_rec.line_category_code,p_old_line_rec.line_category_code)
1663     THEN
1664 
1665 	 -- Need to Call Shipping Update
1666     	 l_update_shipping	:= FND_API.G_TRUE;
1667 	 -- Call Pricing
1668          OE_GLOBALS.G_PRICE_FLAG := 'Y';
1669 
1670          IF p_x_line_rec.commitment_id IS NOT NULL THEN
1671            l_get_commitment_bal := 'Y';
1672          END IF;
1673 
1674      -- For bugfix 3426865
1675         IF p_old_line_rec.line_category_code = 'RETURN' THEN
1676             p_x_line_rec.return_reason_code := NULL;
1677         END IF;
1678 
1679       --Customer Acceptance
1680        l_def_contingency_attributes := FND_API.G_TRUE;
1681 
1682     END IF;
1683 
1684     IF NOT OE_GLOBALS.Equal(p_x_line_rec.line_type_id,p_old_line_rec.line_type_id)
1685     THEN
1686 
1687 	-- Need to Call Shipping Update
1688     	l_update_shipping	:= FND_API.G_TRUE;
1689 	-- Call Pricing
1690         OE_GLOBALS.G_PRICE_FLAG := 'Y';
1691         --Customer Acceptance
1692         l_def_contingency_attributes := FND_API.G_TRUE;
1693 
1694 
1695         IF p_x_line_rec.commitment_id IS NOT NULL THEN
1696           l_get_commitment_bal := 'Y';
1697         END IF;
1698 
1699     END IF;
1700 
1701        -- bug 2072014, need to recalculate price if uom is updated BEGIN
1702     IF NOT OE_GLOBALS.Equal(p_x_line_rec.order_quantity_uom,p_old_line_rec.order_quantity_uom)
1703     THEN
1704 
1705        -- Added below debug messages for bug 9014929
1706        oe_debug_pub.add(' ORDER_QUANTITY_UOM has changed : p_x_line_rec.operation = '||p_x_line_rec.operation);
1707        oe_debug_pub.add('p_x_line_rec.Pricing_quantity = '||p_x_line_rec.Pricing_quantity);
1708        oe_debug_pub.add('p_x_line_rec.ordered_quantity = '||p_x_line_rec.ordered_quantity);
1709 
1710 /* Added the following if condition to fix the bug 2967630 */
1711        IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
1712 
1713         -- Added below code for bug 9014929
1714         OE_LINE_ADJ_UTIL.Change_adj_for_uom_change(p_x_line_rec);
1715         Oe_Debug_Pub.add('   p_x_line_rec.Pricing_quantity = ' || p_x_line_rec.Pricing_quantity);
1716         -- End of code changes for bug 9014929
1717 
1718         if (nvl(p_old_line_rec.order_quantity_uom,FND_API.G_MISS_CHAR) <> FND_API.G_MISS_CHAR)
1719           and (nvl(p_x_line_rec.order_quantity_uom,FND_API.G_MISS_CHAR) <> FND_API.G_MISS_CHAR)
1720           and p_x_line_rec.calculate_price_flag in ('P','N')
1721         then
1722             if l_debug_level > 0 then
1723                 oe_debug_pub.add('operation is :'||p_x_line_rec.operation);
1724             end if;
1725             p_x_line_rec.calculate_price_flag := 'Y';
1726         end if;
1727 
1728        ELSIF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
1729        --bug 3942402
1730         IF NOT OE_GLOBALS.Equal(p_x_line_rec.inventory_item_id, p_old_line_rec.inventory_item_id) THEN
1731           IF (nvl(p_x_line_rec.inventory_item_id,FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM
1732              and nvl(p_old_line_rec.inventory_item_id,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM)
1733              and p_x_line_rec.calculate_price_flag in ('N','P')
1734              and nvl(l_item_chg_prof,'N') = 'N' then
1735                 if l_debug_level > 0 then
1736                   oe_debug_pub.add('Changing calculate price flag to Y');
1737                 end if;
1738                 p_x_line_rec.calculate_price_flag := 'Y';
1739           ELSE
1740              null;
1741           END IF;
1742         ELSE
1743 		--For Bug#7648864
1744 		--ER 9059812
1745 		--LSP project OM Changes
1746 		--Calcualte_price_flag will be set to 'Y' only for non LSP orders.
1747 		--For LSP orders repricing will not happen during UOM change(LSP will always call
1748 		-- process_order API with calcualte_price_flag ='N' )
1749             if l_debug_level > 0 then
1750               oe_debug_pub.add(' In ELSE: ');
1751             end if;
1752             IF (WSH_INTEGRATION.Validate_Oe_Attributes(p_x_line_rec.order_source_id) = 'Y' ) THEN
1753     			p_x_line_rec.calculate_price_flag := 'Y';
1754             END IF;
1755 
1756         end if;
1757         --bug 3942402
1758 /* Added the following line to fix the bug 2917690 */
1759             OE_LINE_ADJ_UTIL.Change_adj_for_uom_change(p_x_line_rec);
1760        END IF;
1761        OE_GLOBALS.G_PRICE_FLAG := 'Y';
1762        l_3a7_attribute_change := FND_API.G_TRUE;
1763 
1764        -- Freight Rating.
1765        IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
1766           AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
1767                                     (p_x_line_rec.header_id)
1768              = 'OM_CALLED_FREIGHT_RATES' THEN
1769          if l_debug_level > 0 then
1770            oe_debug_pub.add('Log Freight Rating request for uom change. ',3);
1771          end if;
1772            l_get_FTE_freight_rate := 'Y';
1773        END IF;
1774     END IF;
1775        -- bug 2072014, need to recalculate price if uom is updated END
1776 
1777     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,p_old_line_rec.ordered_quantity)
1778     THEN
1779 
1780       if l_debug_level > 0 then
1781        oe_debug_pub.add('Ordered Qty has changed',1); -- PETER
1782        oe_debug_pub.add('New Ordered Qty : ' || p_x_line_rec.ordered_quantity, 1);
1783        oe_debug_pub.add('Old Ordered Qty : ' ||
1784                                 p_old_line_rec.ordered_quantity, 1);
1785       end if;
1786        l_3a7_attribute_change := FND_API.G_TRUE;
1787 
1788           /* Added the following code to fix the bug 3739180 */
1789           If p_x_line_rec.calculate_price_flag in ('N','P') and p_x_line_rec.reference_line_id IS NOT NULL THEN
1790             IF (OE_GLOBALS.G_UI_FLAG) THEN
1791              if l_debug_level > 0 then
1792               oe_debug_pub.add('Log REVERSE_LIMITS delayed request for ENTITY LINE return',1);
1793              end if;
1794               OE_delayed_requests_Pvt.log_request(
1795                                 p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
1796                                 p_entity_id              => p_x_line_rec.line_id,
1797                                 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
1798                                 p_requesting_entity_id   => p_x_line_rec.line_id,
1799                                 p_request_unique_key1    => 'LINE',
1800                                 p_param1                 => 'RETURN',
1801                                 p_param2                 => NULL,
1802                                 p_param3                 => NULL,
1803                                 p_param4                 => NULL,
1804                                 p_param5                 => NULL,
1805                                 p_param6                 => p_x_line_rec.ordered_quantity,
1806                                 p_request_type           => OE_GLOBALS.G_REVERSE_LIMITS,
1807                                 x_return_status          => l_return_status);
1808             ELSIF NOT (OE_GLOBALS.G_UI_FLAG) THEN
1809              if l_debug_level > 0 then
1810               oe_debug_pub.add('Log REVERSE_LIMITS delayed request for ENTITY ALL line return',1);
1811              end if;
1812               OE_delayed_requests_Pvt.log_request(
1813                                 p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
1814                                 p_entity_id              => p_x_line_rec.line_id,
1815                                 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
1816                                 p_requesting_entity_id   => p_x_line_rec.line_id,
1817                                 p_request_unique_key1    => 'LINE',
1818                                 p_param1                 => 'RETURN',
1819                                 p_param2                 => NULL,
1820                                 p_param3                 => NULL,
1821                                 p_param4                 => NULL,
1822                                 p_param5                 => NULL,
1823                                 p_param6                 => p_x_line_rec.ordered_quantity,
1824                                 p_request_type           => OE_GLOBALS.G_REVERSE_LIMITS,
1825                                 x_return_status          => l_return_status);
1826             END IF;
1827           END IF;
1828           /* End of the code added to fix the bug 3739180 */
1829 
1830        /* Fix for bug 2431953 / 2749740
1831        IF ((p_old_line_rec.ordered_quantity is not null) AND (nvl(p_x_line_rec.source_document_type_id,-99) <> 2) AND (p_x_line_rec.item_type_code = 'SERVICE'))
1832 
1833        THEN
1834           G_ORDERED_QTY_CHANGE := TRUE;
1835           OE_SERVICE_UTIL.Get_Service_Attribute
1836                           (x_return_status => l_return_status
1837                           , p_x_line_rec    => p_x_line_rec
1838                           );
1839 
1840           G_ORDERED_QTY_CHANGE := FALSE;
1841 
1842           IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1843             fnd_message.set_name('ONT', 'OE_CAN_SERV_AMT_NOT_ALLOWED');
1844             oe_msg_pub.add;
1845             RAISE FND_API.G_EXC_ERROR;
1846           END IF;
1847        END IF;
1848         Fix ends */
1849 
1850        IF (p_x_line_rec.order_source_id = 10) AND
1851 		(p_old_line_rec.ordered_quantity IS NOT NULL) THEN
1852 
1853 
1854 /* 7576948: IR ISO Change Management project Start */
1855 --
1856 -- This program unit will track the specific change in Ordered Quantity
1857 -- and/or Schedule Ship Date on an internal sales order line shipment,
1858 -- and in the event of any change in values, it will log a delayed request
1859 -- of type OE_Globals.G_UPDATE_REQUISITION.
1860 --
1861 -- This delayed request will be logged only if global OE_Internal_Requisi
1862 -- tion_Pvt.G_Update_ISO_From_Req set to FALSE. If this global is TRUE
1863 -- then it means, the change requests for quantity/date or cancellation
1864 -- request is initiated by internal requisition user, in which case, it is
1865 -- not required to log the delayed request for updating the change to the
1866 -- requesting organization. System will also check that global OE_SALES_CAN
1867 -- _UTIL.G_IR_ISO_HDR_CANCEL, and will log a delayed request only if it is
1868 -- FALSE. If this global is TRUE then signifies that it is a case of full
1869 -- internal sales order header cancellation. Thus, in the event of full
1870 -- order cancellation, we only need to inform Purchasing about the
1871 -- cancellation. There is no need to provide specific line level information.
1872 -- Additionally, while logging a delayed request specific to Schedule Ship
1873 -- Date change, system will ensure that it should be allowed via Purchasing
1874 -- profile 'POR: Sync Up Need By date on IR with OM'.
1875 --
1876 -- While logging the delayed request, we will log it for Order Header or
1877 -- Order Line entity, while Entity id will be the Header_id or Line_id
1878 -- respectively. In addition to this, we will even pass Unique_Params value
1879 -- to make this request very specific to Requisition Header or Requisition
1880 -- Line.
1881 --
1882 -- Please refer to following delayed request params with their meaning
1883 -- useful while logging the delayed request -
1884 --
1885 -- P_entity_code        Entity for which delayed request has to be logged.
1886 --                      In this project it can be OE_Globals.G_Entity_Line
1887 --                      or OE_Globals.G_Entity_Header
1888 -- P_entity_id          Primary key of the entity record. In this project,
1889 --                      it can be Order Line_id or Header_id
1890 -- P_requesting_entity_code Which entity has requested this delayed request to
1891 --                          be logged! In this project it will be OE_Globals.
1892 --                          G_Entity_Line or OE_Globals.G_Entity_Header
1893 -- P_requesting_entity_id       Primary key of the requesting entity. In this
1894 --                              project, it is Line_id or Header_id
1895 -- P_request_type       Indicates which business logic (or which procedure)
1896 --                      should be executed. In this project, it is OE_Global
1897 --                      s.G_UPDATE_REQUISITION
1898 -- P_request_unique_key1        Additional argument in form of parameters.
1899 --                              In this project, it will denote the Sales Order
1900 --                              Header id
1901 -- P_request_unique_key2        Additional argument in form of parameters.
1902 --                              In this project, it will denote the Requisition
1903 --                              Header id
1904 -- P_request_unique_key3        Additional argument in form of parameters. In
1905 --                              this project, it will denote the Requistion Line
1906 --                              id
1907 -- P_param1     Additional argument in form of parameters. In this project, it
1908 --              will denote net change in order quantity with respective single
1909 --              requisition line. If it is greater than 0 then it is an increment
1910 --              in the quantity, while if it is less than 0 then it is a decrement
1911 --              in the ordered quantity. If it is 0 then it indicates there is no
1912 --              change in ordered quantity value
1913 -- P_param2     Additional argument in form of parameters. In this project, it
1914 --              will denote whether internal sales order is cancelled or not. If
1915 --              it is cancelled then respective Purchasing api will be called to
1916 --              trigger the requisition header cancellation. It accepts a value of
1917 --              Y indicating requisition header has to be cancelled.
1918 -- P_param3     Additional argument in form of parameters. In this project, it
1919 --              will denote the number of sales order lines cancelled while order
1920 --              header is (Full/Partial) cancelled.
1921 -- p_date_param1        Additional date argument in form of parameters. In this
1922 --                      project, it will denote the change in Schedule Ship Date
1923 --                      with to respect to single requisition line.
1924 -- P_Long_param1        Additional argument in form of parameters. In this project,
1925 --                      it will store all the sales order line_ids, which are getting
1926 --                      cancelled while order header gets cancelled (Full/Partial).
1927 --                      These Line_ids will be separated by a delimiter comma ','
1928 --
1929 -- For details on IR ISO CMS project, please refer to FOL >
1930 -- OM Development > OM GM > 12.1.1 > TDD > IR_ISO_CMS_TDD.doc
1931 --
1932 
1933     IF NOT ((nvl(p_x_line_rec.split_by,'X') IN ('USER','SYSTEM'))
1934               AND (NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT')) THEN
1935 
1936       -- There is no need to update IR for System Split, as the net
1937       -- change in quantity during split operation is 0
1938 
1939       /* IR ISO Change Management : Comment this code Begins */
1940       /*
1941 	    FND_MESSAGE.SET_NAME('ONT','OE_CHG_CORR_REQ');
1942             -- { start fix for 2648277
1943 	    FND_MESSAGE.SET_TOKEN('CHG_ATTR',
1944                OE_Order_Util.Get_Attribute_Name('ordered_quantity'));
1945             -- end fix for 2648277}
1946 	    OE_MSG_PUB.Add;
1947 
1948       */
1949       /* IR ISO Change Management : Comment this code Ends */
1950 
1951       IF NOT OE_Internal_Requisition_Pvt.G_Update_ISO_From_Req THEN
1952         IF NOT OE_SALES_CAN_UTIL.G_IR_ISO_HDR_CANCEL THEN
1953           IF l_debug_level > 0 THEN
1954             oe_debug_pub.add(' Header Level Cancellation is FALSE',5);
1955           END IF;
1956 
1957           -- Log a delayed request to update the Internal Requisition. This delayed
1958           -- request will be logged only if the change is not initiated from Requesting
1959           -- Organization user, and it is not a Internal Sales Order Full Cancellation
1960 
1961           OE_delayed_requests_Pvt.log_request
1962           ( p_entity_code            => OE_GLOBALS.G_ENTITY_LINE
1963           , p_entity_id              => p_x_line_rec.line_id
1964           , p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE
1965           , p_requesting_entity_id   => p_x_line_rec.line_id
1966           , p_request_unique_key1    => p_x_line_rec.header_id  -- Order Hdr_id
1967           , p_request_unique_key2    => p_x_line_rec.source_document_id -- Req Hdr_id
1968           , p_request_unique_key3    => p_x_line_rec.source_document_line_id -- Req Line_id
1969           , p_param1                 => (p_x_line_rec.ordered_quantity - p_old_line_rec.ordered_quantity)
1970 --          , p_date_param1            => p_x_line_rec.schedule_ship_date
1971           , p_request_type           => OE_GLOBALS.G_UPDATE_REQUISITION
1972           , x_return_status          => l_return_status
1973           );
1974 
1975           IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1976             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1977           ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1978             RAISE FND_API.G_EXC_ERROR;
1979           END IF;
1980 
1981 /*        ELSIF OE_SALES_CAN_UTIL.G_IR_ISO_HDR_CANCEL THEN  -- Commented for IR ISO Tracking bug 7667702
1982           IF l_debug_level > 0 THEN
1983             oe_debug_pub.add(' Header Level Cancellation is TRUE',5);
1984           END IF;
1985 
1986           -- Log a delayed request to update the Internal Requisition. This delayed
1987           -- request will be logged only if the change is not initiated from Requesting
1988           -- Organization user, and it is not a Internal Sales Order Full Cancellation
1989 
1990           OE_delayed_requests_Pvt.log_request
1991           ( p_entity_code            => OE_GLOBALS.G_ENTITY_HEADER
1992           , p_entity_id              => p_x_line_rec.header_id
1993           , p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE
1994           , p_requesting_entity_id   => p_x_line_rec.line_id
1995           , p_request_unique_key2    => p_x_line_rec.source_document_id -- Req Hdr_id
1996           , p_param3                 => 1
1997           , p_long_param1            => p_x_line_rec.line_id
1998           , p_request_type           => OE_GLOBALS.G_UPDATE_REQUISITION
1999           , x_return_status          => l_return_status
2000           );
2001 
2002           IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2003             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2004           ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2005             RAISE FND_API.G_EXC_ERROR;
2006           END IF;
2007 */ -- Commented for IR ISO Tracking bug 7667702
2008 
2009         END IF;
2010       END IF;
2011     END IF; -- Split_by
2012 
2013 /* ============================= */
2014 /* IR ISO Change Management Ends */
2015 
2016 
2017        END IF;
2018 
2019       -- QUOTING changes - log explosion request only for lines in
2020       -- fulfillment phase
2021       IF nvl(p_x_line_rec.transaction_phase_code,'F') = 'F' THEN
2022 
2023       -- log a delayed request to get included items for this item if any.
2024 
2025       l_freeze_method := G_FREEZE_METHOD; /* Bug # 5036404 */
2026      if l_debug_level > 0 then
2027       oe_debug_pub.ADD('Freeze method is :' || l_freeze_method,2);
2028      end if;
2029       IF ( l_freeze_method = OE_GLOBALS.G_IIFM_ENTRY AND
2030          p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
2031          p_x_line_rec.ato_line_id is NULL AND
2032          p_old_line_rec.ordered_quantity = 0 AND
2033          ( p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
2034            (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT AND
2035             p_x_line_rec.line_id = p_x_line_rec.top_model_line_id))
2036 /* Start DOO Pre Exploded Kit ER 9339742 */
2037        AND NOT(OE_GENESIS_UTIL.G_INCOMING_FROM_DOO))
2038           OR
2039            (((p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND (OE_GENESIS_UTIL.G_INCOMING_FROM_DOO) ) OR
2040             (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
2041              p_x_line_rec.split_from_line_id IS NULL AND p_x_line_rec.pre_exploded_flag = 'Y'))
2042            AND p_x_line_rec.ato_line_id is NULL
2043            AND ( (( p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT OR p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL)
2044                AND p_x_line_rec.line_id = p_x_line_rec.top_model_line_id)
2045              OR p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS))
2046       THEN
2047            IF OE_GENESIS_UTIL.G_INCOMING_FROM_DOO THEN
2048              if l_debug_level > 0 then
2049                oe_debug_pub.ADD(' The update is from DOO Pre Exploded Kit ER',5);
2050              end if;
2051            END IF;
2052 /* End DOO Pre Exploded Kit ER 9339742 */
2053            p_x_line_rec.explosion_date := null;
2054            l_count := l_count + 1;
2055            OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL(l_count):= p_x_line_rec.line_id;
2056       END IF;
2057 
2058       END IF; -- End if phase is fulfillment
2059       -- END QUOTING changes
2060 
2061       -- Need to Call Shipping Update
2062       l_update_shipping	:= FND_API.G_TRUE;
2063 
2064       -- If the ordered quantity has been reduced then set the flag so
2065       -- that delayed request can check for shipment status.
2066       IF p_x_line_rec.ordered_quantity < p_old_line_rec.ordered_quantity THEN
2067     	   l_ordered_quantity_changed	:= FND_API.G_TRUE;
2068       END IF;
2069       --changes for bug 2315926  Begin
2070 
2071        IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE and
2072            p_x_line_rec.split_by = 'SYSTEM' and
2073            NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT')
2074            OR
2075            (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
2076             p_x_line_rec.split_from_line_id IS NOT NULL AND
2077             nvl(p_x_line_rec.split_by, 'USER') = 'SYSTEM') THEN
2078             -- don't call credit checking for system split when tax value changes.
2079            l_param1 := 'No_Credit_Checking';
2080          if l_debug_level > 0 then
2081            oe_debug_pub.add('System Split - l_param1 is: '||l_param1,1);
2082            oe_debug_pub.ADD('B2315926_1:',2);
2083               oe_debug_pub.add('In the split case, checking for catchweight item',3);
2084            end if;
2085            IF (p_x_line_rec.inventory_item_id IS NOT NULL AND
2086                p_x_line_rec.inventory_item_id <> FND_API.G_MISS_NUM) AND
2087               (p_x_line_rec.ship_from_org_id  IS NOT NULL AND
2088                p_x_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM) THEN
2089                    l_item_rec := OE_Order_Cache.Load_Item (p_x_line_rec.inventory_item_id
2090                             ,p_x_line_rec.ship_from_org_id);
2091                    -- IF  l_item_rec.ont_pricing_qty_source = 1   AND
2092                    IF l_item_rec.ont_pricing_qty_source = 'S' AND -- INVCONV
2093                        l_item_rec.tracking_quantity_ind = 'P' and
2094                        l_item_rec.wms_enabled_flag = 'Y' THEN
2095                        If l_debug_level > 0 Then
2096                           oe_debug_pub.add('Catchweight enabled item',3);
2097                           oe_debug_pub.add('Setting the price flag to Yes');
2098                        End If;
2099                        OE_GLOBALS.G_PRICE_FLAG := 'Y';
2100                    END IF;
2101            END IF;
2102        else
2103         OE_GLOBALS.G_PRICE_FLAG := 'Y';
2104         if l_debug_level > 0 then
2105          oe_debug_pub.ADD('B2315926_2:',2);
2106         end if;
2107        end if;
2108        --changes for bug 2315926 end
2109 
2110      --changes for bug#7491829
2111 
2112        IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE and
2113            p_x_line_rec.split_by = 'SYSTEM' and
2114            NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT') THEN
2115            IF l_debug_level > 0 THEN
2116               oe_debug_pub.add('Logging Reverse Limits delayed request for parent line');
2117               oe_debug_pub.add('Price request code for parent : ' || p_x_line_rec.price_request_code);
2118               oe_debug_pub.add('OLD Price request code for parent : ' || p_old_line_rec.price_request_code);
2119            END IF;
2120                          OE_delayed_requests_Pvt.log_request(
2121                                 p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
2122                                 p_entity_id              => p_x_line_rec.line_id,
2123                                 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
2124                                 p_requesting_entity_id   => p_x_line_rec.line_id,
2125                                 p_request_unique_key1    => 'LINE',
2126                                 p_param1                 => 'SPLIT_ORIG',
2127                                 p_param2                 => p_old_line_rec.price_request_code,
2128                                 p_param3                 => p_old_line_rec.ordered_quantity,
2129                                 p_param4                 => p_x_line_rec.ordered_quantity,
2130                                 p_param5                 => NULL,
2131                                 p_param6                 => NULL,
2132                                 p_request_type           => OE_GLOBALS.G_REVERSE_LIMITS,
2133                                 x_return_status          => l_return_status);
2134 
2135        END IF;
2136 
2137        IF   (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
2138             p_x_line_rec.split_from_line_id IS NOT NULL AND
2139             nvl(p_x_line_rec.split_by, 'USER') = 'SYSTEM') THEN
2140             IF l_debug_level > 0 THEN
2141               oe_debug_pub.add('Logging Reverse Limits delayed request for child line');
2142             END IF;
2143               OE_delayed_requests_Pvt.log_request(
2144                                 p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
2145                                 p_entity_id              => p_x_line_rec.line_id,
2146                                 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
2147                                 p_requesting_entity_id   => p_x_line_rec.line_id,
2148                                 p_request_unique_key1    => 'LINE',
2149                                 p_param1                 => 'SPLIT_NEW',
2150                                 p_param2                 => NULL,
2151                                 p_param3                 => NULL,
2152                                 p_param4                 => NULL,
2153                                 p_param5                 => NULL,
2154                                 p_param6                 => p_x_line_rec.ordered_quantity,
2155                                 p_request_type           => OE_GLOBALS.G_REVERSE_LIMITS,
2156                                 x_return_status          => l_return_status);
2157        END IF;
2158 
2159        --bug#7491829
2160 
2161       OE_GLOBALS.G_TAX_FLAG := 'Y';
2162 
2163       -- bug 1829201, need to recalculate commitment when quantity changes.
2164       IF p_x_line_rec.commitment_id is not null then
2165         l_calculate_commitment_flag := 'Y';
2166 
2167         -- lkxu, bug 1786533 for commitment during line split
2168         IF ( p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
2169              NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT' ) THEN
2170 
2171             l_update_commitment_flag := 'Y';
2172             OE_GLOBALS.g_original_commitment_applied
2173               := Oe_Commitment_Pvt.Get_Commitment_Applied_Amount
2174 		(p_header_id          => p_x_line_rec.header_id ,
2175                  p_line_id            => p_x_line_rec.line_id ,
2176                  p_commitment_id      => p_x_line_rec.commitment_id);
2177         END IF;
2178       END IF;
2179 
2180       -- Freight Rating.
2181       IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
2182          AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
2183                                     (p_x_line_rec.header_id)
2184              = 'OM_CALLED_FREIGHT_RATES' THEN
2185          if l_debug_level > 0 then
2186            oe_debug_pub.add('Log Freight Rating request for qty change. ',3);
2187          end if;
2188            l_get_FTE_freight_rate := 'Y';
2189       END IF;
2190 
2191             /* INVCONV ordered_quantity2 needs to be calculated for
2192       split line process items - CHILD
2193       ============================================================*/
2194       -- INVCONV
2195 
2196       IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
2197          p_x_line_rec.split_from_line_id IS NOT NULL AND
2198          nvl(p_x_line_rec.split_by, 'USER') = 'USER' AND
2199          p_x_line_rec.line_category_code <> 'RETURN'
2200          THEN
2201                 /*
2202           	p_x_line_rec.ordered_quantity2 :=
2203            		oe_line_util.Calculate_Ordered_Quantity2(p_x_line_rec);
2204            	*/
2205            	/* OPM - NC 3/8/02 Bug#2046641
2206            	   Commented the above call and added the call to calculate_dual_quantity */
2207                 IF (OE_CODE_CONTROL.CODE_RELEASE_LEVEL <= '110507') OR NOT(OE_GLOBALS.G_UI_FLAG) THEN
2208 
2209            						if l_debug_level > 0 then
2210                 				oe_debug_pub.add('about to call calculate_dual_quantity 1' );
2211                       end if;
2212                     oe_line_util.calculate_dual_quantity(
2213                          p_ordered_quantity => p_x_line_rec.ordered_quantity
2214                         ,p_old_ordered_quantity => NULL
2215                         ,p_ordered_quantity2 => p_x_line_rec.ordered_quantity2
2216                         ,p_old_ordered_quantity2 => NULL
2217                         ,p_ordered_quantity_uom  => p_x_line_rec.order_quantity_uom
2218                         ,p_ordered_quantity_uom2 => p_x_line_rec.ordered_quantity_uom2
2219                         ,p_inventory_item_id     => p_x_line_rec.inventory_item_id
2220                         ,p_ship_from_org_id      => p_x_line_rec.ship_from_org_id
2221                         ,x_ui_flag 		 => 0
2222                         ,x_return_status         => l_return_code
2223                         );
2224 
2225 
2226                         IF l_return_code <> 0 THEN -- INVCONV
2227 	     										 IF l_return_status = -1
2228 	     										 THEN
2229 															p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
2230 														else
2231 														p_x_line_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2232 														END IF;
2233 												END IF;
2234 
2235 
2236 
2237                 END IF;  -- Bug#2046641
2238            END IF;      -- INVCONV
2239 
2240       IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
2241        /* INVCONV 02/JUN/00 ordered_quantity2 needs to be calculated
2242         for split line process items  - PARENT
2243         =======================================================*/
2244         IF p_x_line_rec.split_action_code = 'SPLIT' AND
2245         p_x_line_rec.line_category_code <> 'RETURN' AND
2246         p_x_line_rec.split_by = 'USER'
2247         THEN
2248                 /*
2249             	p_x_line_rec.ordered_quantity2 :=
2250                      oe_line_util.Calculate_Ordered_Quantity2(p_x_line_rec);
2251                 */
2252                 /* OPM - NC 3/8/02 Bug#2046641
2253            	   Commented the above call and added the call to calculate_dual_quantity */
2254                 IF (OE_CODE_CONTROL.CODE_RELEASE_LEVEL <= '110507') OR NOT(OE_GLOBALS.G_UI_FLAG) THEN
2255                     if l_debug_level > 0 then
2256                 	oe_debug_pub.add('about to call calculate_dual_quantity 2' );
2257                       end if;
2258 
2259                     oe_line_util.calculate_dual_quantity(
2260                          p_ordered_quantity => p_x_line_rec.ordered_quantity
2261                         ,p_old_ordered_quantity => NULL
2262                         ,p_ordered_quantity2 => p_x_line_rec.ordered_quantity2
2263                         ,p_old_ordered_quantity2 => NULL
2264                         ,p_ordered_quantity_uom  => p_x_line_rec.order_quantity_uom
2265                         ,p_ordered_quantity_uom2 => p_x_line_rec.ordered_quantity_uom2
2266                         ,p_inventory_item_id     => p_x_line_rec.inventory_item_id
2267                         ,p_ship_from_org_id      => p_x_line_rec.ship_from_org_id
2268                         ,x_ui_flag 		 => 0
2269                         ,x_return_status         => l_return_code
2270                         );
2271 
2272 
2273                         IF l_return_code <> 0 THEN -- INVCONV
2274 	     										 IF l_return_status = -1
2275 	     										 THEN
2276 															p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
2277 														else
2278 														p_x_line_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2279 														END IF;
2280 												END IF;
2281 
2282 
2283 
2284 
2285 
2286                 END IF;  -- OPM Bug#2046641
2287 
2288         END IF;      -- OPM B1661023 04/02/01
2289 
2290         /* OPM END */
2291 
2292 	   oe_sales_can_util.check_constraints
2293 		      (p_x_line_rec	=> p_x_line_rec,
2294 		       p_old_line_rec	=> p_old_line_rec,
2295 		       x_return_status	=> l_return_status);
2296 	    IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2297 	      IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2298 	 		p_x_line_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2299               ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2300 			p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
2301               END IF;
2302 	    END IF;
2303 
2304 
2305 
2306 	    -- Additional task: Log the delayed request for verify payment
2307 	    -- when order quantity changes and the Payment Type Code
2308 	    -- is not CREDIT CARD and the Line is Booked.
2309 	    -- If the payment type is CREDIT CARD then the delayed req should be
2310 	    -- logged only if the quantity has increased.
2311 
2312 	    --IF OE_Order_Cache.g_header_rec.payment_type_code = 'CREDIT_CARD' THEN --CC Reversal ER#16014135 Commented
2313 	    IF (OE_Order_Cache.g_header_rec.payment_type_code = 'CREDIT_CARD' AND l_cc_rev_reauth_code IS NULL) THEN --CC Reversal ER#16014135
2314 	      IF  p_x_line_rec.ordered_quantity > p_old_line_rec.ordered_quantity
2315                 THEN
2316                 -- Log request here if commitment id is null
2317                 if p_x_line_rec.commitment_id is null then
2318                  if l_debug_level > 0 then
2319            	  oe_debug_pub.ADD('Log Verify Payment delayed request in Ord Qty');
2320                  end if;
2321 		  l_verify_payment_flag := 'Y';
2322 	        end if;
2323               END IF;
2324               -- if this is a prepaid order, also log delayed request if ordered
2325               -- quantity decreases, as refund may need to be issued.
2326               IF OE_PrePayment_UTIL.is_prepaid_order(p_x_line_rec.header_id)
2327                       = 'Y'  AND p_x_line_rec.booked_flag ='Y' THEN
2328                   if l_debug_level > 0 then
2329            	    oe_debug_pub.ADD('Log Verify Payment delayed request in Ord Qty for prepayment', 3);
2330                   end if;
2331 		    l_verify_payment_flag := 'Y';
2332               END IF;
2333 	    ELSE
2334 		  IF p_x_line_rec.booked_flag ='Y' THEN
2335                    if l_debug_level > 0 then
2336 	 	    oe_debug_pub.ADD('Log Verify Payment delayed request for change in Order Qty');
2337 
2338                    end if;
2339 
2340                    -- Start fix for bug# 4378531
2341                    IF l_debug_level  > 0 THEN
2342                     oe_debug_pub.add('CHECKING CREDIT CHECK HOLD FOR HEADER/LINE ID : ' || TO_CHAR ( p_x_line_rec.header_id ) || '/' || TO_CHAR ( p_x_line_rec.line_id ) ) ;
2343                    END IF;
2344 
2345                    OE_HOLDS_PUB.Check_Holds
2346                       (  p_api_version    => 1.0
2347                        , p_header_id      => p_x_line_rec.header_id
2348                        , p_line_id        => p_x_line_rec.line_id
2349                        , p_hold_id        => 1
2350                        , p_entity_code    => 'O'
2351                        , p_entity_id      => p_x_line_rec.header_id
2352                        , x_result_out     => l_hold_result
2353                        , x_msg_count      => l_msg_count
2354                        , x_msg_data       => l_msg_data
2355                        , x_return_status  => l_return_status
2356                       );
2357 
2358                    IF l_debug_level  > 0 THEN
2359                     oe_debug_pub.add('CHECKING FOR CANCEL FLAG : ' || p_x_line_rec.cancelled_flag ) ;
2360                    END IF;
2361 
2362                    IF NOT( l_hold_result = FND_API.G_FALSE AND p_x_line_rec.cancelled_flag='Y') THEN
2363                     l_verify_payment_flag := 'Y';
2364                    END IF;
2365 
2366           -- Start of the fix  8471719
2367           --CC Reversal ER#16014135 start
2368 		  IF p_x_line_rec.cancelled_flag ='Y' AND l_cc_rev_reauth_code IS NOT NULL then
2369 		  l_verify_payment_flag :='Y';
2370 		  END IF;
2371 		  --IF p_x_line_rec.cancelled_flag='Y' THEN
2372 		  IF p_x_line_rec.cancelled_flag='Y' AND l_cc_rev_reauth_code IS NULL THEN
2373 		  --CC Reversal ER#16014135 end
2374             --ER 12363706 start
2375             IF OE_Credit_Engine_GRP.Is_Tolerance_Enabled(p_x_line_rec.header_id,l_credit_check_rule_rec) THEN
2376 		oe_debug_pub.add('OEXULINB: Tolerance is enabled!') ;
2377             ELSE
2378               --ER 12363706 end
2379               OE_CREDIT_ENGINE_GRP.TOLERANCE_CHECK_REQUIRED := FALSE;
2380               IF ('Y'                                          =OE_SYS_PARAMETERS.VALUE('OE_CC_CANCEL_PARAM')) THEN
2381 	          l_verify_payment_flag                         := 'Y';
2382               ELSE
2383                 l_verify_payment_flag                         := 'N';
2384               END IF;
2385             END IF; --ER 12363706
2386           END IF;
2387           -- End of the fix  8471719
2388 
2389 
2390                    IF l_debug_level  > 0 THEN
2391                     oe_debug_pub.add('CHECKING FOR VERIFY PAYMENT FLAG : ' || l_verify_payment_flag ) ;
2392                    END IF;
2393                    -- End fix for bug# 4378531
2394 
2395 		  END IF;
2396          	END IF;
2397 
2398        END IF;
2399 
2400 
2401         -- Populate pricing quantity
2402     	IF p_x_line_rec.ordered_quantity <> FND_API.G_MISS_NUM And
2403 		p_x_line_rec.pricing_quantity_uom is not null and
2404 		p_x_line_rec.pricing_quantity_uom <> FND_API.G_MISS_CHAR and
2405 		p_x_line_rec.order_quantity_uom is not null  and
2406 		p_x_line_rec.order_quantity_uom <> FND_API.G_MISS_CHAR
2407 	Then
2408             l_temp_pricing_quantity :=
2409 		OE_Order_Misc_Util.convert_uom(
2410 		p_x_line_rec.inventory_item_id,
2411 		p_x_line_rec.order_quantity_uom,
2412 		p_x_line_rec.pricing_quantity_uom,
2413 		p_x_line_rec.ordered_quantity
2414 					);
2415 
2416 	    IF  l_temp_pricing_quantity >= 0 THEN
2417 	            p_x_line_rec.Pricing_quantity:=l_temp_pricing_quantity;
2418 		    oe_debug_pub.add('temp pricing quantity:'||l_temp_pricing_quantity);
2419 	    END IF;
2420 
2421 	End If; -- Pricing Quantity
2422       -- Pack J catchweight
2423        IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
2424        null; -- INVCONV COMMENTED OUT FOR NOW
2425           -- Calc_Catchweight_Return_qty2(p_x_line_rec => p_x_line_rec INVCONV COMMENTED OUT FOR NOW
2426           --                           , p_old_line_rec => p_old_line_rec); INVCONV COMMENTED OUT FOR NOW
2427        END IF;
2428     END IF;
2429 
2430     IF NOT OE_GLOBALS.Equal(p_x_line_rec.order_quantity_uom,p_old_line_rec.order_quantity_uom)
2431     THEN
2432 	-- Need to Call Shipping Update
2433     	l_update_shipping	:= FND_API.G_TRUE;
2434         OE_GLOBALS.G_PRICE_FLAG := 'Y';
2435         OE_GLOBALS.G_TAX_FLAG := 'Y';
2436     END IF;
2437 
2438     -- bug 1829201, need to recalculate commitment.
2439     --IF p_x_line_rec.commitment_id is not null then
2440     --  l_calculate_commitment_flag := 'Y';
2441     --END IF;
2442 
2443 -- INVCONV
2444     --OPM 02/JUN/00   Test for changes to process attributes
2445     --                (ordered_quantity2, preferred_grade)
2446     --------------------------------------------------------
2447     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity2,p_old_line_rec.ordered_quantity2) -- peter
2448     THEN
2449         if l_debug_level > 0 then
2450        			oe_debug_pub.add('Ordered Qty2 has changed',1); -- INVCONV
2451        			oe_debug_pub.add('New Ordered Qty2 : ' || p_x_line_rec.ordered_quantity2, 1);
2452        			oe_debug_pub.add('Old Ordered Qty2 : ' ||
2453                                 p_old_line_rec.ordered_quantity2, 1);
2454       	end if;
2455 
2456         l_update_shipping     := FND_API.G_TRUE;
2457         -- start 2046190
2458              IF dual_uom_control   --   INVCONV Process_Characteristics
2459                              (p_x_line_rec.inventory_item_id
2460                              ,p_x_line_rec.ship_from_org_id
2461                              ,l_item_rec) THEN
2462 
2463                 -- IF l_item_rec.ont_pricing_qty_source = 1 THEN INVCONV
2464                 IF l_item_rec.ont_pricing_qty_source = 'S' THEN -- INVCONV
2465                  -- need to call pricing
2466                       if l_debug_level > 0 then
2467                 				oe_debug_pub.add('dual uom  - ont_pricing_qty_source = ' || l_item_rec.ont_pricing_qty_source );
2468                       end if;
2469 								OE_GLOBALS.G_PRICE_FLAG := 'Y';
2470         				OE_GLOBALS.G_TAX_FLAG := 'Y';
2471 
2472         				END IF;
2473 
2474           oe_sales_can_util.check_constraints
2475 		      (p_x_line_rec	=> p_x_line_rec,
2476 		       p_old_line_rec	=> p_old_line_rec,
2477 		       x_return_status	=> l_return_status);
2478 	    		IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2479 	      		IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2480 	 							p_x_line_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2481             ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2482 								p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
2483             END IF;
2484 	    		END IF;
2485 
2486       --Bug 14211120 Start
2487       --log delayed request to update IR if secondary quantity changes on ISO
2488       IF (p_x_line_rec.order_source_id = 10) AND
2489                  (p_old_line_rec.ordered_quantity2 IS NOT NULL) THEN
2490        IF NOT ((nvl(p_x_line_rec.split_by,'X') IN ('USER','SYSTEM')) --Not a split
2491           AND (NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT')) THEN
2492        IF NOT OE_Internal_Requisition_Pvt.G_Update_ISO_From_Req THEN --change not initiated by PO
2493          IF NOT OE_SALES_CAN_UTIL.G_IR_ISO_HDR_CANCEL THEN --not a full order cancellation
2494            IF l_debug_level > 0 THEN
2495              oe_debug_pub.add(' Header Level Cancellation is FALSE',5);
2496              oe_debug_pub.add(' Secondary qty change: Logging delayed request for G_UPDATE_REQUISITION',5);
2497            END IF;
2498 
2499            -- Log a delayed request to update the Internal Requisition. This delayed
2500            -- request will be logged only if the change is not initiated from Requesting
2501            -- Organization user, and it is not a Internal Sales Order Full Cancellation
2502 
2503            OE_delayed_requests_Pvt.log_request
2504            ( p_entity_code            => OE_GLOBALS.G_ENTITY_LINE
2505            , p_entity_id              => p_x_line_rec.line_id
2506            , p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE
2507            , p_requesting_entity_id   => p_x_line_rec.line_id
2508            , p_request_unique_key1    => p_x_line_rec.header_id  -- Order Hdr_id
2509            , p_request_unique_key2    => p_x_line_rec.source_document_id -- Req Hdr_id
2510            , p_request_unique_key3    => p_x_line_rec.source_document_line_id -- Req Line_id
2511            , p_param4                 => (p_x_line_rec.ordered_quantity2 - p_old_line_rec.ordered_quantity2)
2512            --, p_date_param1            => p_x_line_rec.schedule_ship_date
2513            , p_request_type           => OE_GLOBALS.G_UPDATE_REQUISITION
2514            , x_return_status          => l_return_status
2515            );
2516            IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2517              RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2518            ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2519              RAISE FND_API.G_EXC_ERROR;
2520            END IF;
2521          END IF;
2522        END IF;
2523        END IF;
2524       END IF;
2525       --Bug 14211120 End
2526 
2527    			END IF; -- IF dual_uom_control   --   INVCONV Process_Characteristics
2528 -- end   2046190
2529 
2530 --      NULL;
2531     END IF; -- IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity2,p_old_line_rec.ordered_quantity2) -- peter
2532 
2533     IF NOT OE_GLOBALS.Equal(p_x_line_rec.preferred_grade,p_old_line_rec.preferred_grade
2534 )
2535     THEN
2536         -- Need to Call Shipping Update
2537         l_update_shipping     := FND_API.G_TRUE;
2538         OE_GLOBALS.G_PRICE_FLAG := 'Y';
2539         OE_GLOBALS.G_TAX_FLAG := 'Y';
2540 
2541         IF p_x_line_rec.commitment_id IS NOT NULL THEN
2542           l_get_commitment_bal := 'Y';
2543         END IF;
2544     END IF;
2545     --INVCONV  02/JUN/00 END
2546     --=================
2547 
2548     IF NOT OE_GLOBALS.Equal(p_x_line_rec.payment_term_id,p_old_line_rec.payment_term_id)
2549     THEN
2550 
2551         -- Need to Call Pricing: bug 1504821
2552         OE_GLOBALS.G_PRICE_FLAG := 'Y';
2553 
2554 	/* Additional task: If the payment type is not CREDIT CARD
2555 	then if the payment term changes for a line which is Booked
2556 	it should log a delayed request for Verify Payment */
2557 
2558 	IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
2559 
2560           if p_x_line_rec.booked_flag ='Y' then
2561 
2562             IF OE_PrePayment_UTIL.IS_MULTIPLE_PAYMENTS_ENABLED = TRUE THEN
2563 
2564               if l_debug_level > 0 then
2565                  oe_debug_pub.ADD('multpayments: logging delayed request for verify payment as payment term is changed');
2566               end if;
2567               l_verify_payment_flag := 'Y';
2568 
2569 	    --ELSIF NVL(OE_Order_Cache.g_header_rec.payment_type_code, 'NULL') <> 'CREDIT_CARD' --CC Reversal ER#16014135 Commented
2570 	    ELSIF (NVL(OE_Order_Cache.g_header_rec.payment_type_code, 'NULL') <> 'CREDIT_CARD' OR l_cc_rev_reauth_code IS NOT NULL) --CC Reversal ER#16014135
2571 	    THEN
2572 
2573               if l_debug_level > 0 then
2574 	        oe_debug_pub.ADD('logging delayed request for verify payment as payment term is changed');
2575               end if;
2576 	      l_verify_payment_flag := 'Y';
2577 
2578 	    END IF;   -- if multiple_payments is enabled
2579 
2580           end if; -- if booked_flag is Y
2581 
2582         END IF; -- if operation is update
2583 
2584     END IF;  -- if payment_term_id has changed
2585 
2586     IF NOT OE_GLOBALS.Equal(p_x_line_rec.price_list_id,p_old_line_rec.price_list_id)
2587     THEN
2588         OE_GLOBALS.G_PRICE_FLAG := 'Y';
2589 
2590         IF p_x_line_rec.commitment_id IS NOT NULL THEN
2591           l_get_commitment_bal := 'Y';
2592         END IF;
2593     END IF;
2594 
2595     IF NOT OE_GLOBALS.Equal(p_x_line_rec.pricing_date,p_old_line_rec.pricing_date)
2596     THEN
2597         OE_GLOBALS.G_PRICE_FLAG := 'Y';
2598 
2599        -- bug 2072014, need to recalculate price if pricing_date is updated BEGIN
2600         IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
2601 	   OE_GLOBALS.Equal(p_x_line_rec.reference_line_id,p_old_line_rec.reference_line_id) THEN --bug 5260190
2602             p_x_line_rec.calculate_price_flag := 'Y';
2603         END IF;
2604        -- bug 2072014, need to recalculate price if pricing_date is updated END
2605 
2606         IF p_x_line_rec.commitment_id IS NOT NULL THEN
2607           l_get_commitment_bal := 'Y';
2608         END IF;
2609     END IF;
2610 
2611     IF NOT OE_GLOBALS.Equal(p_x_line_rec.pricing_quantity,p_old_line_rec.pricing_quantity)
2612     THEN
2613        --commenting the below line for bug 2315926
2614         --OE_GLOBALS.G_PRICE_FLAG := 'Y';
2615 
2616         -- bug 1829201, need to recalculate commitment.
2617         IF p_x_line_rec.commitment_id is not null then
2618           l_calculate_commitment_flag := 'Y';
2619         END IF;
2620     END IF;
2621 
2622     IF NOT OE_GLOBALS.Equal(p_x_line_rec.pricing_quantity_uom,p_old_line_rec.pricing_quantity_uom)
2623     THEN
2624        --commenting the below line for bug 2315926
2625         --OE_GLOBALS.G_PRICE_FLAG := 'Y';
2626 
2627         -- bug 1829201, need to recalculate commitment.
2628         IF p_x_line_rec.commitment_id is not null then
2629           l_calculate_commitment_flag := 'Y';
2630         END IF;
2631     END IF;
2632 
2633     IF NOT OE_GLOBALS.Equal(p_x_line_rec.reference_line_id,p_old_line_rec.reference_line_id)
2634     THEN
2635       IF OE_GLOBALS.G_RETURN_CHILDREN_MODE = 'N' THEN
2636        if l_debug_level > 0 then
2637         oe_debug_pub.ADD('RMA: logging delayed request ');
2638        end if;
2639         IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE OR
2640            p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
2641 
2642            IF p_x_line_rec.split_from_line_id is NULL THEN -- Bug 5676051
2643 
2644            OE_delayed_requests_Pvt.log_request(
2645 				p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
2646                 p_entity_id              => p_x_line_rec.line_id,
2647 			    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
2648 			    p_requesting_entity_id   => p_x_line_rec.line_id,
2649                 p_param1    => p_x_line_rec.operation,  --Bug 4651421
2650                 p_param2    => p_x_line_rec.split_by,
2651                 p_param3    => p_x_line_rec.split_action_code,
2652                 p_param4    => to_char(p_x_line_rec.split_from_line_id),
2653                 p_request_type      => OE_GLOBALS.G_INSERT_RMA,
2654                 x_return_status     => l_return_status);
2655            END IF; -- Bug 5676051
2656 
2657           /* BUG 2013611 and 2109230 */
2658           If p_x_line_rec.calculate_price_flag in ('N','P') THEN
2659             IF (OE_GLOBALS.G_UI_FLAG) THEN
2660              if l_debug_level > 0 then
2661               oe_debug_pub.add('Log REVERSE_LIMITS delayed request for ENTITY LINE return',1);
2662              end if;
2663               OE_delayed_requests_Pvt.log_request(
2664                                 p_entity_code 		 => OE_GLOBALS.G_ENTITY_LINE,
2665 				p_entity_id              => p_x_line_rec.line_id,
2666 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
2667 				p_requesting_entity_id   => p_x_line_rec.line_id,
2668 				p_request_unique_key1  	 => 'LINE',
2669 		 		p_param1                 => 'RETURN',
2670 		 		p_param2                 => NULL,
2671 		 		p_param3                 => NULL,
2672 		 		p_param4                 => NULL,
2673 		 		p_param5                 => NULL,
2674 		 		p_param6                 => p_x_line_rec.ordered_quantity,
2675 		 		p_request_type           => OE_GLOBALS.G_REVERSE_LIMITS,
2676 		 		x_return_status          => l_return_status);
2677             ELSIF NOT (OE_GLOBALS.G_UI_FLAG) THEN
2678              if l_debug_level > 0 then
2679               oe_debug_pub.add('Log REVERSE_LIMITS delayed request for ENTITY ALL line return',1);
2680              end if;
2681               OE_delayed_requests_Pvt.log_request(
2682                                 p_entity_code 		 => OE_GLOBALS.G_ENTITY_ALL,
2683 				p_entity_id              => p_x_line_rec.line_id,
2684 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
2685 				p_requesting_entity_id   => p_x_line_rec.line_id,
2686 				p_request_unique_key1  	 => 'LINE',
2687 		 		p_param1                 => 'RETURN',
2688 		 		p_param2                 => NULL,
2689 		 		p_param3                 => NULL,
2690 		 		p_param4                 => NULL,
2691 		 		p_param5                 => NULL,
2692 		 		p_param6                 => p_x_line_rec.ordered_quantity,
2693 		 		p_request_type           => OE_GLOBALS.G_REVERSE_LIMITS,
2694 		 		x_return_status          => l_return_status);
2695             END IF;
2696 	  END IF;
2697           /* BUG 2013611 and 2109230 END */
2698         END IF;
2699        END IF;
2700 
2701         -- bug 1917869
2702 	IF p_x_line_rec.calculate_price_flag in ('N','P') then
2703 	  l_copy_adjustments := TRUE;
2704         END IF;
2705 
2706 	l_copy_pricing_attributes := TRUE;
2707 	If p_x_line_rec.calculate_price_flag = 'N' then
2708 		p_x_line_rec.calculate_price_flag := 'P';
2709 	end if;
2710 
2711     END IF;
2712 
2713     IF NOT OE_GLOBALS.Equal(p_x_line_rec.request_date,p_old_line_rec.request_date)
2714     THEN
2715 
2716 	 -- Need to Call Shipping Update
2717     	 l_update_shipping	:= FND_API.G_TRUE;
2718 
2719 	 -- Call Pricing
2720          OE_GLOBALS.G_PRICE_FLAG := 'Y';
2721 
2722          IF p_x_line_rec.commitment_id IS NOT NULL THEN
2723            l_get_commitment_bal := 'Y';
2724          END IF;
2725 
2726        /*
2727        ** Commented as part of 1655720 after discussion with zbutt
2728        IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
2729           p_x_line_rec.booked_flag ='Y'
2730        THEN
2731           if l_debug_level > 0 then
2732             oe_debug_pub.ADD('logging delayed request for Verify Payment
2733                                     forchange in Request date');
2734           end if;
2735             l_verify_payment_flag := 'Y';
2736        END IF;
2737        */
2738 
2739     END IF;
2740 
2741     IF NOT OE_GLOBALS.Equal(p_x_line_rec.schedule_ship_date,p_old_line_rec.schedule_ship_date)
2742     THEN
2743 
2744 	  -- Need to Call Shipping Update
2745     	  l_update_shipping	:= FND_API.G_TRUE;
2746 	   --  Taking out this because the TAX request should get fired only
2747 	   --  when the tax_date changes. And tax_date will change if the
2748 	   --  schedule_ship_date changes.
2749         IF p_old_line_rec.schedule_ship_date IS NOT NULL THEN
2750            l_3a7_attribute_change := FND_API.G_TRUE;
2751         END IF;
2752         --  OE_GLOBALS.G_TAX_FLAG := 'Y';
2753 
2754 	 -- Call Pricing
2755          -- For performance bug 1351111, turning off Pricing for scheduling
2756 
2757          /* Commenting out for 1419204
2758          l_turn_off_pricing := FND_PROFILE.VALUE('ONT_NO_PRICING_AT_SCHEDULING');
2759          -- by default, turn off pricing at scheduling
2760          IF l_turn_off_pricing = 'N' THEN
2761            OE_GLOBALS.G_PRICE_FLAG := 'Y';
2762          End If;
2763          */
2764 
2765          IF p_x_line_rec.commitment_id IS NOT NULL THEN
2766            l_get_commitment_bal := 'Y';
2767          END IF;
2768 
2769         -- Freight Rating
2770         IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
2771            AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
2772                                       (p_x_line_rec.header_id)
2773                = 'OM_CALLED_FREIGHT_RATES' THEN
2774            if l_debug_level > 0 then
2775              oe_debug_pub.add('Log Freight Rating request for schedule ship date. ',3);
2776            end if;
2777              l_get_FTE_freight_rate := 'Y';
2778         END IF;
2779 
2780 	  /* Additional task : Log delayed request for verify payment
2781 	  when payment type is not CREDIT CARD and when schedule date
2782 	  has changed for a booked Line  and it is not a drop-ship line*/
2783 
2784     -- modified for bug 1655720 to not perform credit checking if
2785     -- schedule_ship_date changes.
2786     /***
2787     IF (p_x_line_rec.source_type_code <> OE_GLOBALS.G_SOURCE_EXTERNAL) THEN
2788 
2789 	  IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
2790 	  THEN
2791 	     IF NVL(OE_Order_Cache.g_header_rec.payment_type_code, 'NULL') <> 'CREDIT_CARD' AND
2792              p_x_line_rec.booked_flag ='Y' AND
2793              (to_date(p_x_line_rec.schedule_ship_date, 'DD/MM/YYYY') <>
2794               to_date(p_x_line_rec.request_date, 'DD/MM/YYYY'))
2795 	     THEN
2796                if l_debug_level > 0 then
2797 		  oe_debug_pub.ADD('logging delayed request for Verify Payment
2798                                      for change in Scheduled Ship date');
2799                end if;
2800 		  l_verify_payment_flag := 'Y';
2801 	     END IF;
2802 	  END IF;
2803 
2804      END IF;
2805      ***/
2806 
2807        if l_debug_level > 0 then
2808 	 oe_debug_pub.add('opr = '||p_x_line_rec.operation);
2809        end if;
2810 
2811 /* 7576948: IR ISO Change Management project Start */
2812 --
2813 -- This program unit will track the specific change in Ordered Quantity
2814 -- and/or Schedule Ship Date on an internal sales order line shipment,
2815 -- and in the event of any change in values, it will log a delayed request
2816 -- of type OE_Globals.G_UPDATE_REQUISITION.
2817 --
2818 -- This delayed request will be logged only if global OE_Internal_Requisi
2819 -- tion_Pvt.G_Update_ISO_From_Req set to FALSE. If this global is TRUE
2820 -- then it means, the change requests for quantity/date or cancellation
2821 -- request is initiated by internal requisition user, in which case, it is
2822 -- not required to log the delayed request for updating the change to the
2823 -- requesting organization. System will also check that global OE_SALES_CAN
2824 -- _UTIL.G_IR_ISO_HDR_CANCEL, and will log a delayed request only if it is
2825 -- FALSE. If this global is TRUE then signifies that it is a case of full
2826 -- internal sales order header cancellation. Thus, in the event of full
2827 -- order cancellation, we only need to inform Purchasing about the
2828 -- cancellation. There is no need to provide specific line level information.
2829 -- Additionally, while logging a delayed request specific to Schedule Ship
2830 -- Date change, system will ensure that it should be allowed via Purchasing
2831 -- profile 'POR: Sync Up Need By date on IR with OM'.
2832 --
2833 -- While logging the delayed request, we will log it for Order Header or
2834 -- Order Line entity, while Entity id will be the Header_id or Line_id
2835 -- respectively. In addition to this, we will even pass Unique_Params value
2836 -- to make this request very specific to Requisition Header or Requisition
2837 -- Line.
2838 --
2839 -- Please refer to following delayed request params with their meaning
2840 -- useful while logging the delayed request -
2841 --
2842 -- P_entity_code        Entity for which delayed request has to be logged.
2843 --                      In this project it can be OE_Globals.G_Entity_Line
2844 --                      or OE_Globals.G_Entity_Header
2845 -- P_entity_id          Primary key of the entity record. In this project,
2846 --                      it can be Order Line_id or Header_id
2847 -- P_requesting_entity_code Which entity has requested this delayed request to
2848 --                          be logged! In this project it will be OE_Globals.
2849 --                          G_Entity_Line or OE_Globals.G_Entity_Header
2850 -- P_requesting_entity_id       Primary key of the requesting entity. In this
2851 --                              project, it is Line_id or Header_id
2852 -- P_request_type       Indicates which business logic (or which procedure)
2853 --                      should be executed. In this project, it is OE_Global
2854 --                      s.G_UPDATE_REQUISITION
2855 -- P_request_unique_key1        Additional argument in form of parameters.
2856 --                              In this project, it will denote the Sales Order
2857 --                              Header id
2858 -- P_request_unique_key2        Additional argument in form of parameters.
2859 --                              In this project, it will denote the Requisition
2860 --                              Header id
2861 -- P_request_unique_key3        Additional argument in form of parameters. In
2862 --                              this project, it will denote the Requistion Line
2863 --                              id
2864 -- P_param1     Additional argument in form of parameters. In this project, it
2865 --              will denote net change in order quantity with respective single
2866 --              requisition line. If it is greater than 0 then it is an increment
2867 --              in the quantity, while if it is less than 0 then it is a decrement
2868 --              in the ordered quantity. If it is 0 then it indicates there is no
2869 --              change in ordered quantity value
2870 -- P_param2     Additional argument in form of parameters. In this project, it
2871 --              will denote whether internal sales order is cancelled or not. If
2872 --              it is cancelled then respective Purchasing api will be called to
2873 --              trigger the requisition header cancellation. It accepts a value of
2874 --              Y indicating requisition header has to be cancelled.
2875 -- P_param3     Additional argument in form of parameters. In this project, it
2876 --              will denote the number of sales order lines cancelled while order
2877 --              header is (Full/Partial) cancelled.
2878 -- p_date_param1        Additional date argument in form of parameters. In this
2879 --                      project, it will denote the change in Schedule Ship Date
2880 --                      with to respect to single requisition line.
2881 -- P_Long_param1        Additional argument in form of parameters. In this project,
2882 --                      it will store all the sales order line_ids, which are getting
2883 --                      cancelled while order header gets cancelled (Full/Partial).
2884 --                      These Line_ids will be separated by a delimiter comma ','
2885 --
2886 -- For details on IR ISO CMS project, please refer to FOL >
2887 -- OM Development > OM GM > 12.1.1 > TDD > IR_ISO_CMS_TDD.doc
2888 --
2889 
2890 /* -- Commented for IR ISO : Starts
2891 
2892 	 IF (p_x_line_rec.order_source_id = 10) AND
2893 	    (p_old_line_rec.schedule_ship_date IS NOT NULL) THEN
2894             FND_MESSAGE.SET_NAME('ONT','OE_CHG_CORR_REQ');
2895             -- { start fix for 2648277
2896 	    FND_MESSAGE.SET_TOKEN('CHG_ATTR',
2897                OE_Order_Util.Get_Attribute_Name('schedule_ship_date'));
2898             -- end fix for 2648277}
2899 	   OE_MSG_PUB.Add;
2900       END IF;
2901 
2902       END IF;
2903 */ -- Commented for IR ISO Ends.
2904 
2905 
2906 /* -- Commented for IR ISO Tracking bug 7667702
2907  *
2908    IF (p_x_line_rec.order_source_id = 10) THEN
2909      IF (p_old_line_rec.schedule_ship_date IS NOT NULL) OR
2910         (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
2911          p_x_line_rec.split_from_line_id IS NOT NULL AND
2912          nvl(p_x_line_rec.split_by, 'X') = 'SYSTEM') THEN
2913        -- The above new OR condition is needed to ensure that a data
2914        -- change can happen either as a direct Update operation, OR
2915        -- during split of order lines, where original record will be
2916        -- Updated while new record will be Created
2917 
2918        l_po_NeedByDate_Update := NVL(FND_PROFILE.VALUE('POR_SYNC_NEEDBYDATE_OM'),'NO');
2919 
2920        IF l_debug_level > 0 THEN
2921          oe_debug_pub.add(' Need By Date update is allowed ? '||l_po_NeedByDate_Update);
2922        END IF;
2923 
2924        IF NOT OE_Internal_Requisition_Pvt.G_Update_ISO_From_Req
2925          AND NOT OE_SALES_CAN_UTIL.G_IR_ISO_HDR_CANCEL AND
2926          l_po_NeedByDate_Update = 'YES' THEN
2927 
2928          -- Log a delayed request to update the change in Schedule Ship Date to
2929          -- Requisition Line. This request will be logged only if the change is
2930          -- not initiated from Requesting Organization, and it is not a case of
2931          -- Internal Sales Order Full Cancellation. It will even not be logged
2932          -- Purchasing profile option does not allow update of Need By Date when
2933          -- Schedule Ship Date changes on internal sales order line
2934 
2935          OE_delayed_requests_Pvt.log_request
2936          ( p_entity_code            => OE_GLOBALS.G_ENTITY_LINE
2937          , p_entity_id              => p_x_line_rec.line_id
2938          , p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE
2939          , p_requesting_entity_id   => p_x_line_rec.line_id
2940          , p_request_unique_key1    => p_x_line_rec.header_id  -- Order Hdr_id
2941          , p_request_unique_key2    => p_x_line_rec.source_document_id -- Req Hdr_id
2942          , p_request_unique_key3    => p_x_line_rec.source_document_line_id -- Req Line_id
2943          , p_date_param1            => p_x_line_rec.schedule_ship_date
2944          , p_request_type           => OE_GLOBALS.G_UPDATE_REQUISITION
2945          , x_return_status          => l_return_status
2946          );
2947 
2948         IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2949           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2950         ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2951           RAISE FND_API.G_EXC_ERROR;
2952         END IF;
2953 
2954        END IF;
2955      END IF; -- Split_by
2956    END IF;  -- Order Source is 10.
2957 */ -- Commented for IR ISO Tracking bug 7667702
2958 
2959 /* ============================= */
2960 /* IR ISO Change Management Ends */
2961 
2962 
2963     END IF;
2964 
2965     IF NOT OE_GLOBALS.Equal(p_x_line_rec.schedule_arrival_date,p_old_line_rec.schedule_arrival_date)
2966     THEN
2967 
2968         -- Freight Rating
2969         IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
2970            AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
2971                                       (p_x_line_rec.header_id)
2972                = 'OM_CALLED_FREIGHT_RATES' THEN
2973            if l_debug_level > 0 then
2974              oe_debug_pub.add('Log Freight Rating request for schedule arrivale date. ',3);
2975            end if;
2976              l_get_FTE_freight_rate := 'Y';
2977         END IF;
2978 
2979 /* 7576948: IR ISO Change Management project Start */
2980 --
2981 -- For details on IR ISO CMS project, please refer to FOL >
2982 -- OM Development > OM GM > 12.1.1 > TDD > IR_ISO_CMS_TDD.doc
2983 --
2984 
2985 
2986    IF (p_x_line_rec.order_source_id = 10) THEN
2987      IF (p_old_line_rec.schedule_arrival_date IS NOT NULL) OR
2988         (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
2989          p_x_line_rec.split_from_line_id IS NOT NULL AND
2990          nvl(p_x_line_rec.split_by, 'X') = 'SYSTEM') THEN
2991        -- The above new OR condition is needed to ensure that a data
2992        -- change can happen either as a direct Update operation, OR
2993        -- during split of order lines, where original record will be
2994        -- Updated while new record will be Created
2995 
2996        l_po_NeedByDate_Update := NVL(FND_PROFILE.VALUE('POR_SYNC_NEEDBYDATE_OM'),'NO');
2997 
2998        IF l_debug_level > 0 THEN
2999          oe_debug_pub.add(' Need By Date update is allowed ? '||l_po_NeedByDate_Update);
3000        END IF;
3001 
3002        IF NOT OE_Internal_Requisition_Pvt.G_Update_ISO_From_Req
3003          AND NOT OE_SALES_CAN_UTIL.G_IR_ISO_HDR_CANCEL AND
3004          OE_Schedule_GRP.G_ISO_Planning_Update THEN -- Added for IR ISO Tracking bug 7667702
3005          -- l_po_NeedByDate_Update = 'YES' THEN -- Commented for IR ISO Tracking bug 7667702
3006          IF l_po_NeedByDate_Update = 'YES' THEN -- Added for IR ISO Tracking bug 7667702
3007 
3008          -- Log a delayed request to update the change in Schedule Arrival Date to
3009          -- Requisition Line. This request will be logged only if the change is
3010          -- not initiated from Requesting Organization, and it is not a case of
3011          -- Internal Sales Order Full Cancellation. It will even not be logged
3012          -- Purchasing profile option does not allow update of Need By Date when
3013          -- Schedule Arrival Date changes on internal sales order line
3014 
3015          OE_delayed_requests_Pvt.log_request
3016          ( p_entity_code            => OE_GLOBALS.G_ENTITY_LINE
3017          , p_entity_id              => p_x_line_rec.line_id
3018          , p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE
3019          , p_requesting_entity_id   => p_x_line_rec.line_id
3020          , p_request_unique_key1    => p_x_line_rec.header_id  -- Order Hdr_id
3021          , p_request_unique_key2    => p_x_line_rec.source_document_id -- Req Hdr_id
3022          , p_request_unique_key3    => p_x_line_rec.source_document_line_id -- Req Line_id
3023          , p_date_param1            => p_x_line_rec.schedule_arrival_date
3024 -- Note: p_date_param1 is used for both Schedule_Ship_Date and
3025 -- Schedule_Arrival_Date, as while executing G_UPDATE_REQUISITION delayed
3026 -- request via OE_Process_Requisition_Pvt.Update_Internal_Requisition,
3027 -- it can expect change with respect to Ship or Arrival date. Thus, will
3028 -- not raise any issues.
3029          , p_request_type           => OE_GLOBALS.G_UPDATE_REQUISITION
3030          , x_return_status          => l_return_status
3031          );
3032 
3033          IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3034            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3035          ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3036            RAISE FND_API.G_EXC_ERROR;
3037          END IF;
3038 
3039          ELSE -- Added for IR ISO Tracking bug 7667702
3040            IF l_debug_level > 0 THEN
3041              oe_debug_pub.add(' Need By Date is not allowed to update. Updating MTL_Supply only',5);
3042            END IF;
3043 
3044            OE_SCHEDULE_UTIL.Update_PO(p_x_line_rec.schedule_arrival_date,
3045                 p_x_line_rec.source_document_id,
3046                 p_x_line_rec.source_document_line_id);
3047          END IF;
3048 
3049        END IF;
3050      END IF; -- Split_by
3051    END IF;  -- Order Source is 10.
3052 
3053 /* ============================= */
3054 /* IR ISO Change Management Ends */
3055 
3056 
3057     END IF;
3058 
3059     IF NOT OE_GLOBALS.Equal(p_x_line_rec.shipment_priority_code,p_old_line_rec.shipment_priority_code)
3060     THEN
3061 	-- Need to Call Shipping Update
3062     	l_update_shipping	:= FND_API.G_TRUE;
3063     END IF;
3064 
3065     IF NOT OE_GLOBALS.Equal(p_x_line_rec.shipped_quantity,p_old_line_rec.shipped_quantity)
3066     THEN
3067 		--IF (p_x_line_rec.ship_set_id IS NOT NULL ) THEN
3068           --OE_delayed_requests_Pvt.log_request(
3069 	     --p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3070           --p_entity_id         => p_x_line_rec.ship_set_id,
3071 	     --p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3072 	     --p_requesting_entity_id         => p_x_line_rec.line_id,
3073           -- p_request_type      => OE_GLOBALS.G_SPLIT_SET_CHK,
3074           --p_param1 => to_char(p_x_line_rec.actual_shipment_date,'DD-MON-RRRR'),
3075           --x_return_status     => l_return_status);
3076 		--END IF;
3077 
3078         NULL;
3079 
3080     END IF;
3081 
3082     IF NOT OE_GLOBALS.Equal(p_x_line_rec.shipping_method_code,p_old_line_rec.shipping_method_code)
3083     THEN
3084         -- Need to Call Pricing: bug 3344835
3085         OE_GLOBALS.G_PRICE_FLAG := 'Y';
3086 
3087 	-- Need to Call Shipping Update
3088     	l_update_shipping	:= FND_API.G_TRUE;
3089         IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
3090            AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
3091                                       (p_x_line_rec.header_id)
3092                = 'OM_CALLED_FREIGHT_RATES'
3093            AND oe_globals.g_freight_recursion = 'N' THEN
3094             if l_debug_level > 0 then
3095              oe_debug_pub.add('Log Freight Rating request for shipping method. ',3);
3096             end if;
3097              l_get_FTE_freight_rate := 'Y';
3098         END IF;
3099 
3100     END IF;
3101 
3102     -- Don't change the order for the following, flow_status_code depends on this
3103     -- order to update the appropriate flow_status_code
3104 
3105     IF NOT OE_GLOBALS.Equal(p_x_line_rec.booked_flag, p_old_line_rec.booked_flag)
3106     THEN
3107   	   IF p_x_line_rec.booked_flag = 'Y' AND p_x_line_rec.flow_status_code = 'ENTERED' THEN
3108 	   -- only set status to BOOKED if we were at ENTERED
3109 		 p_x_line_rec.flow_status_code := 'BOOKED';
3110                  -- For bug 1304916. Booking wil call price_line directly
3111         	 --OE_GLOBALS.G_PRICE_FLAG := 'Y';
3112                if l_debug_level > 0 then
3113 		 oe_debug_pub.add('sam: flow_status_code is ' || p_x_line_rec.flow_status_code);
3114                end if;
3115 	   END IF;
3116     END IF;
3117 
3118 
3119 
3120   /*  WARNING !!!! The following code will not get executed after patchset 'G'.
3121   This code HAS BEEN MOVED to package OE_SHIP_CONFIRMATION_PUB.SHIP_CONFIRM. Please change the code in file OEXPSHCB.pls if any changes are required in the following IF */
3122 
3123     IF NOT OE_GLOBALS.Equal(p_x_line_rec.shipping_quantity,p_old_line_rec.shipping_quantity)
3124     THEN
3125 	   -- Convert the shipping quantity from shipping quantity UOM to
3126 	   -- Ordered quantity UOM and update the field shipped quantity
3127 
3128 	   -- Call API to convert the shipping quantity to shipped quantity from
3129 	   -- shipping quantity UOM to ordered quantity UOM and assign the returned
3130 	   -- quantity to shipped quantity of p_x_line_rec.
3131      if l_debug_level > 0 then
3132         oe_debug_pub.ADD('Order Quantity UOM : '|| p_x_line_rec.order_quantity_uom,2);
3133         oe_debug_pub.ADD('Shipping Quantity UOM : '|| p_x_line_rec.shipping_quantity_uom,2);
3134      end if;
3135 	   IF 	p_x_line_rec.shipping_quantity_uom <> p_x_line_rec.order_quantity_uom THEN
3136 
3137      /* --OPM 06/SEP/00 invoke process Uom Conversion for process line INVCONV
3138              --============================================================
3139              IF dual_uom_control  --   INVCONV Process_Characteristics
3140                              (p_x_line_rec.inventory_item_id
3141                              ,p_x_line_rec.ship_from_org_id
3142                              ,l_item_rec) THEN
3143 
3144              if l_debug_level > 0 then
3145                oe_debug_pub.ADD('OPM Process shipping update ',1);
3146              end if;
3147                 GMI_Reservation_Util.Get_OPMUOM_from_AppsUOM
3148                      (p_Apps_UOM       => p_x_line_rec.order_quantity_uom
3149                      ,x_OPM_UOM        => l_OPM_order_quantity_uom
3150                      ,x_return_status  => l_status
3151                      ,x_msg_count      => l_msg_count
3152                      ,x_msg_data       => l_msg_data);
3153 
3154 --             Get the OPM equivalent code for shipping_quantity_uom
3155 --               ========================================================
3156                GMI_Reservation_Util.Get_OPMUOM_from_AppsUOM
3157                      (p_Apps_UOM       => p_x_line_rec.shipping_quantity_uom
3158                      ,x_OPM_UOM        => l_OPM_shipping_quantity_uom
3159                      ,x_return_status  => l_status
3160                      ,x_msg_count      => l_msg_count
3161                      ,x_msg_data       => l_msg_data);
3162 
3163 --                Apply OPM unit of measure conversion
3164 --               ======================================
3165                l_OPM_shipped_quantity :=GMICUOM.uom_conversion
3166  	                     	(l_item_rec.opm_item_id,0
3167      	    	                ,p_x_line_rec.shipping_quantity
3168                                ,l_OPM_shipping_quantity_uom
3169     	    	                     ,l_OPM_order_quantity_uom,0);
3170 
3171 -- get_opm_converted_qty to resolve rounding issues
3172 
3173 
3174       l_OPM_shipped_quantity := GMI_Reservation_Util.get_opm_converted_qty(
3175               p_apps_item_id    => p_x_line_rec.inventory_item_id,
3176               p_organization_id => p_x_line_rec.ship_from_org_id,
3177               p_apps_from_uom   => p_x_line_rec.shipping_quantity_uom,
3178               p_apps_to_uom     => p_x_line_rec.order_quantity_uom,
3179               p_original_qty    => p_x_line_rec.shipping_quantity);
3180      if l_debug_level > 0 then
3181      end if;
3182 
3183 -- Feb 2003 2683316 end
3184 
3185 
3186 		-- B2037234 EMC  INVCONV
3187                 -- B2204216 EMC- Moved assignment of profile value out of
3188                 -- Declaration. Here, the profile value has the potential to
3189                 -- affect OPM customers only.
3190                 -- To accomodate for international date format and use of commas
3191 		-- instead of decimal points, introduced
3192                 -- fnd_number.canonical_to_number which converts the returned
3193                 -- VARCHAR value to a number.
3194 
3195 		l_epsilon :=fnd_number.canonical_to_number(NVL(FND_PROFILE.VALUE('IC$EPSILON'),0)) ;
3196  		n := (-1) * round(log(10,l_epsilon));
3197  		l_OPM_shipped_quantity:=round(l_OPM_shipped_quantity, n);
3198 
3199 
3200 
3201                -- Enforce precision of 19,9
3202                --===========================-
3203                l_temp_shipped_quantity := l_OPM_shipped_quantity;
3204              if l_debug_level > 0 then
3205                oe_debug_pub.ADD('OPM Process shipping update conversion gives shipped quantity of ' || l_temp_shipped_quantity,1);
3206              end if;
3207 
3208 
3209 
3210              ELSE */ --  INVCONV
3211 
3212 			l_temp_shipped_quantity := OE_Order_Misc_Util.Convert_Uom
3213 				  (
3214 				  p_x_line_rec.inventory_item_id,
3215 				  p_x_line_rec.shipping_quantity_uom,
3216 				  p_x_line_rec.order_quantity_uom,
3217 				  p_x_line_rec.shipping_quantity
3218 				  );
3219               if l_debug_level > 0 then
3220         	oe_debug_pub.ADD('Converted Shipped Quantity : '|| to_char(l_temp_shipped_quantity),1);
3221               end if;
3222             --   END IF; -- INVCONV
3223              --OPM 06/SEP/00 END
3224 
3225 
3226               if l_debug_level > 0 then
3227         	oe_debug_pub.ADD('Converted Shipped Quantity : '|| to_char(l_temp_shipped_quantity),1);
3228               end if;
3229 
3230 			IF	l_temp_shipped_quantity <> trunc(l_temp_shipped_quantity) THEN
3231 
3232 				Inv_Decimals_PUB.Validate_Quantity
3233 				(
3234 					p_item_id	=> p_x_line_rec.inventory_item_id,
3235 					p_organization_id => OE_Sys_Parameters.value('MASTER_ORGANIZATION_ID'),
3236 					p_input_quantity => l_temp_shipped_quantity,
3237 					p_uom_code		 => p_x_line_rec.order_quantity_uom,
3238 					x_output_quantity => l_validated_quantity,
3239 					x_primary_quantity => l_primary_quantity,
3240 					x_return_status		=> l_qty_return_status
3241 				);
3242 
3243                              if l_debug_level > 0 then
3244 				oe_debug_pub.add('Return status from INV API : '||l_qty_return_status,1);
3245                              end if;
3246 				IF	l_qty_return_status = 'W' THEN
3247 
3248 					p_x_line_rec.shipped_quantity := l_validated_quantity;
3249 				ELSE
3250 
3251 					p_x_line_rec.shipped_quantity := l_temp_shipped_quantity;
3252 
3253 				END IF;
3254 
3255 			ELSE
3256 				p_x_line_rec.shipped_quantity := l_temp_shipped_quantity;
3257 
3258 			END IF;
3259 
3260 		        p_x_line_rec.shipped_quantity2 := p_x_line_rec.shipping_quantity2; -- OPM B1873114 07/10/01
3261 	   ELSE
3262 
3263 			p_x_line_rec.shipped_quantity := p_x_line_rec.shipping_quantity;
3264 		        p_x_line_rec.shipped_quantity2 := p_x_line_rec.shipping_quantity2; -- OPM B1661023 04/02/01
3265 
3266 	   END IF;
3267 
3268       if l_debug_level > 0 then
3269         oe_debug_pub.ADD('Shipped Quantity : '|| to_char(p_x_line_rec.shipped_quantity),1);
3270       end if;
3271 	   -- The following line needs to assign the value of shipped quantity
3272 	   -- after the conversion of shipping quantity to ordered quantity UOM.
3273 
3274        -- Log the delayed request for Ship Confirmation if there is an update
3275        -- from Shipping for ship confirmation
3276        IF p_x_line_rec.line_category_code <> 'RETURN' THEN
3277          IF (p_x_line_rec.ship_set_id IS NOT NULL AND
3278              p_x_line_rec.ship_set_id <> FND_API.G_MISS_NUM) THEN
3279 
3280          l_shipping_unique_key1  :=  'SHIP_SET';
3281          l_shipping_param1       :=  p_x_line_rec.ship_set_id;
3282 
3283        ELSIF (p_x_line_rec.top_model_line_id  IS NOT NULL AND
3284               p_x_line_rec.top_model_line_id <> FND_API.G_MISS_NUM) AND
3285               nvl(p_x_line_rec.model_remnant_flag,'N') = 'N' THEN
3286 
3287          l_shipping_unique_key1  :=  'PTO_KIT';
3288          l_shipping_param1       :=  p_x_line_rec.top_model_line_id;
3289 
3290        ELSIF (p_x_line_rec.ato_line_id IS NOT NULL AND
3291               p_x_line_rec.ato_line_id <> FND_API.G_MISS_NUM) AND
3292               p_x_line_rec.item_type_code = Oe_Globals.G_ITEM_CONFIG AND
3293               nvl(p_x_line_rec.model_remnant_flag,'N') = 'N' THEN
3294          l_shipping_unique_key1  :=  'ATO';
3295          l_shipping_param1       :=  p_x_line_rec.line_id;
3296        ELSE
3297          l_shipping_unique_key1  :=  p_x_line_rec.item_type_code;
3298          l_shipping_param1       :=  p_x_line_rec.line_id;
3299        END IF;
3300 
3301 	   -- Log a delayed request for Ship Confirmation
3302       if l_debug_level > 0 then
3303         oe_debug_pub.ADD('Ship Confirmation : logging delayed request for '|| l_shipping_unique_key1 || l_shipping_param1,1);
3304       end if;
3305 
3306 		OE_Delayed_Requests_Pvt.Log_Request(
3307 		p_entity_code				=>	OE_GLOBALS.G_ENTITY_LINE,
3308 		p_entity_id					=>	p_x_line_rec.line_id,
3309 		p_requesting_entity_code	=>	OE_GLOBALS.G_ENTITY_LINE,
3310 		p_requesting_entity_id  	=>	p_x_line_rec.line_id,
3311 		p_request_type				=>	OE_GLOBALS.G_SHIP_CONFIRMATION,
3312 		p_request_unique_key1		=>	l_shipping_unique_key1,
3313 		p_param1             		=>	l_shipping_param1,
3314 		x_return_status				=>	l_return_status);
3315 
3316 		END IF;
3317 
3318     END IF;
3319 
3320 
3321 
3322     IF NOT OE_GLOBALS.Equal(p_x_line_rec.invoice_interface_status_code, p_old_line_rec.invoice_interface_status_code)
3323     THEN
3324         IF p_x_line_rec.invoice_interface_status_code = 'YES' THEN
3325            p_x_line_rec.flow_status_code := 'INVOICED';
3326          if l_debug_level > 0 then
3327            oe_debug_pub.add('sam: flow_status_code is ' || p_x_line_rec.flow_status_code);
3328          end if;
3329         ELSIF p_x_line_rec.invoice_interface_status_code = 'RFR-PENDING' THEN
3330            p_x_line_rec.flow_status_code := 'INVOICED_PARTIAL';
3331          if l_debug_level > 0 then
3332            oe_debug_pub.add('sam: flow_status_code is ' || p_x_line_rec.flow_status_code);
3333           end if;
3334         END IF;
3335 
3336     END IF;
3337 
3338 
3339     IF NOT OE_GLOBALS.Equal(p_x_line_rec.open_flag, p_old_line_rec.open_flag)
3340     THEN
3341 	IF p_x_line_rec.open_flag = 'N' THEN
3342 	 	p_x_line_rec.flow_status_code := 'CLOSED';
3343                 IF p_x_line_rec.cancelled_flag = 'Y' THEN
3344                    p_x_line_rec.flow_status_code := 'CANCELLED';
3345                 END IF;
3346               if l_debug_level > 0 then
3347 	 	oe_debug_pub.add('sam: flow_status_code is ' || p_x_line_rec.flow_status_code);
3348               end if;
3349 	 	p_x_line_rec.calculate_price_flag := 'N';
3350 	END IF;
3351 
3352     END IF;
3353 
3354     IF NOT OE_GLOBALS.Equal(p_x_line_rec.cancelled_flag, p_old_line_rec.cancelled_flag)
3355     THEN
3356 	IF p_x_line_rec.cancelled_flag = 'Y' THEN
3357 		 p_x_line_rec.flow_status_code := 'CANCELLED';
3358                if l_debug_level > 0 then
3359 		 oe_debug_pub.add('sam: flow_status_code is ' || p_x_line_rec.flow_status_code);
3360                end if;
3361 	 	 p_x_line_rec.calculate_price_flag := 'N';
3362 	END IF;
3363 
3364     END IF;
3365 
3366     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_from_org_id,p_old_line_rec.ship_from_org_id)
3367     THEN
3368 	   -- BUG 1491504 BEGIN -- INVCONV  stet
3369 	   -- Warehouse data CAN determine whether the line is treated as process or discrete OR SINGLE uom OR dUAL uom CONTROLLED .
3370 	   -- Warehouse data can impact quantity calculations, so check the quantites here
3371 	   -- pal
3372 	   OE_Line_Util.Sync_Dual_Qty (p_x_line_rec => p_x_line_rec
3373                                    ,p_old_line_rec => p_old_line_rec);
3374         -- Check to see if either the primary or secondary quantity has changed
3375 	   -- If there is a change, make a recursive call to OE_Order_Pvt.Lines
3376         IF p_x_line_rec.ordered_quantity <> l_ordered_quantity OR
3377           p_x_line_rec.ordered_quantity2 <> l_ordered_quantity2 THEN
3378           -- OE_GLOBALS.G_RECURSION_MODE           := 'Y';
3379 	     l_control_rec.controlled_operation    := TRUE;
3380 	     l_control_rec.check_security	        := TRUE;
3381     	     l_control_rec.clear_dependents 	   := FALSE;
3382 	     l_control_rec.default_attributes      := FALSE;
3383 	     l_control_rec.change_attributes	   := TRUE;
3384 	     l_control_rec.validate_entity	        := FALSE;
3385     	     l_control_rec.write_to_DB             := FALSE;
3386     	     l_control_rec.process                 := FALSE;
3387 	     l_old_line_tbl(1) 			        := p_old_line_rec;
3388           l_line_tbl(1)			             := p_x_line_rec;
3389 
3390           Oe_Order_Pvt.Lines
3391 	     ( p_validation_level	=> FND_API.G_VALID_LEVEL_NONE
3392           , p_control_rec		=> l_control_rec
3393           , p_x_line_tbl			=> l_line_tbl
3394           , p_x_old_line_tbl		=> l_old_line_tbl
3395 	     , x_return_status        => l_return_status
3396 	     );
3397 
3398           -- OE_GLOBALS.G_RECURSION_MODE           := 'N';
3399           IF l_return_status = FND_API.G_RET_STS_ERROR THEN
3400             RAISE FND_API.G_EXC_ERROR;
3401           ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3402             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3403           END IF;
3404         END IF;
3405 	   -- BUG 1491504 END
3406         -- =======================================
3407         -- Log the request for Tax Calculation
3408         OE_GLOBALS.G_TAX_FLAG := 'Y';
3409           -- Need to Call Shipping Update
3410         l_update_shipping := FND_API.G_TRUE;
3411         /* may need to call pricing */
3412         -- For performance bug 1351111, turning off Pricing for scheduling
3413         /* commenting out for fix 1419204
3414         l_turn_off_pricing := FND_PROFILE.VALUE('ONT_NO_PRICING_AT_SCHEDULING');
3415         -- by default, turn off pricing at scheduling
3416         IF l_turn_off_pricing = 'N' THEN
3417           OE_GLOBALS.G_PRICE_FLAG := 'Y';
3418         End If;
3419         */
3420 
3421        IF ( p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
3422 	    NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT')
3423             -- QUOTING change
3424             AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
3425        THEN
3426          if l_debug_level > 0 then
3427           oe_debug_pub.ADD('ship from update: logging request for eval_hold_source', 1);
3428           oe_debug_pub.add('line ID: '|| to_char(p_x_line_rec.line_id) ||
3429                ' Entity ID :'|| to_char(p_x_line_rec.ship_from_org_id), 1);
3430          end if;
3431 
3432           OE_delayed_requests_Pvt.log_request(
3433             p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3434             p_entity_id              => p_x_line_rec.line_id,
3435             p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3436             p_requesting_entity_id   => p_x_line_rec.line_id,
3437             p_request_type           => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
3438             p_request_unique_key1    => 'SHIP_FROM',
3439             p_param1                 => 'W',
3440             p_param2                 => p_x_line_rec.ship_from_org_id,
3441             x_return_status          => l_return_status);
3442 
3443         if l_debug_level > 0 then
3444           oe_debug_pub.add('return status after logging delayed request '||
3445                  l_return_status, 1);
3446         end if;
3447         END IF;
3448 
3449         -- Freight Rating
3450         IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
3451            AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
3452                                       (p_x_line_rec.header_id)
3453                = 'OM_CALLED_FREIGHT_RATES' THEN
3454            if l_debug_level > 0 then
3455              oe_debug_pub.add('Log Freight Rating request for ship from org. ',3);
3456            end if;
3457              l_get_FTE_freight_rate := 'Y';
3458         END IF;
3459 
3460        -- Pack J catchweight
3461         IF l_debug_level  > 0 THEN
3462            oe_debug_pub.add('old ship_from_org_id:'|| p_old_line_rec.ship_from_org_id  );
3463            oe_debug_pub.add('New ship_from_org_id  :'|| p_x_line_rec.ship_from_org_id  );
3464         END IF;
3465 
3466         IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
3467            IF p_x_line_rec.ship_from_org_id  IS NOT NULL AND
3468               p_x_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM THEN
3469                 SELECT wms_enabled_flag
3470                 INTO l_wms_org_flag_new
3471                 FROM mtl_parameters
3472                 WHERE organization_id= p_x_line_rec.ship_from_org_id;
3473            END IF;
3474            IF p_old_line_rec.ship_from_org_id  IS NOT NULL AND
3475               p_old_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM THEN
3476                 SELECT wms_enabled_flag
3477                 INTO l_wms_org_flag_old
3478                 FROM mtl_parameters
3479                 WHERE organization_id= p_old_line_rec.ship_from_org_id;
3480            END IF;
3481            IF l_debug_level  > 0 THEN
3482               oe_debug_pub.add('l_wms_org_flag_new:'|| l_wms_org_flag_new);
3483               oe_debug_pub.add('l_wms_org_flag_old:'|| l_wms_org_flag_old);
3484            END IF;
3485            IF l_wms_org_flag_new <> l_wms_org_flag_old
3486            AND (l_wms_org_flag_new = 'Y' OR l_wms_org_flag_old = 'Y') THEN -- added for bug 8449058
3487               OE_GLOBALS.G_PRICE_FLAG := 'Y';
3488            END IF;
3489         END IF;
3490        -- Pack J catchweight
3491 
3492 
3493     END IF;
3494 
3495     IF NOT OE_GLOBALS.Equal(p_x_line_rec.subinventory,p_old_line_rec.subinventory)
3496     THEN
3497        -- change of subinventory should not require tax or pricing calculation.
3498        -- or even hold evaluation
3499 	  l_update_shipping := FND_API.G_TRUE;
3500       if l_debug_level > 0 then
3501        oe_debug_pub.add('subinventory update',  1);
3502       end if;
3503     END IF;
3504 
3505 
3506     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_model_complete_flag,p_old_line_rec.ship_model_complete_flag)
3507     THEN
3508 	-- Need to Call Shipping Update
3509     	l_update_shipping	:= FND_API.G_TRUE;
3510     END IF;
3511 
3512     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_set_id,p_old_line_rec.ship_set_id)
3513     THEN
3514 	-- Need to Call Shipping Update
3515     	l_update_shipping	:= FND_API.G_TRUE;
3516 
3517     END IF;
3518 
3519     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_set,p_old_line_rec.ship_set)
3520     THEN
3521 
3522 	NULL;
3523 
3524     END IF;
3525 
3526 
3527     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_tolerance_above,p_old_line_rec.ship_tolerance_above)
3528     THEN
3529 	-- Need to Call Shipping Update
3530     	l_update_shipping	:= FND_API.G_TRUE;
3531     END IF;
3532 
3533     -- Changes for Bug-2579571
3534 
3535     IF NOT OE_GLOBALS.Equal(p_x_line_rec.line_set_id,p_old_line_rec.line_set_id)
3536     THEN
3537         -- Need to Call Shipping Update
3538         l_update_shipping       := FND_API.G_TRUE;
3539     END IF;
3540 
3541     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_tolerance_below,p_old_line_rec.ship_tolerance_below)
3542     THEN
3543 	-- Need to Call Shipping Update
3544     	l_update_shipping	:= FND_API.G_TRUE;
3545     END IF;
3546 
3547     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_to_contact_id,p_old_line_rec.ship_to_contact_id)
3548     THEN
3549 	-- Need to Call Shipping Update
3550     	l_update_shipping	:= FND_API.G_TRUE;
3551 	-- Call Pricing
3552      -- OE_GLOBALS.G_PRICE_FLAG := 'Y'; Commented out for fix 1419204
3553 
3554     END IF;
3555 
3556     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_to_org_id,p_old_line_rec.ship_to_org_id)
3557     THEN
3558 	-- Log the request for Tax Calculation
3559         OE_GLOBALS.G_TAX_FLAG := 'Y';
3560 	-- Need to Call Shipping Update
3561     	l_update_shipping	:= FND_API.G_TRUE;
3562         /* may need to call pricing */
3563           OE_GLOBALS.G_PRICE_FLAG := 'Y';
3564 	--Customer Acceptance
3565         l_def_contingency_attributes := FND_API.G_TRUE;  --added for BUG#12575548
3566 
3567           IF p_x_line_rec.commitment_id IS NOT NULL THEN
3568             l_get_commitment_bal := 'Y';
3569           END IF;
3570 
3571           IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
3572              AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
3573                                         (p_x_line_rec.header_id)
3574                  = 'OM_CALLED_FREIGHT_RATES' THEN
3575              if l_debug_level > 0 then
3576                oe_debug_pub.add('Log Freight Rating request for ship to org. ',3);
3577              end if;
3578                l_get_FTE_freight_rate := 'Y';
3579           END IF;
3580 
3581      IF ( p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
3582 	   NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT')
3583            -- QUOTING change
3584            AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
3585      THEN
3586          if l_debug_level > 0 then
3587            oe_debug_pub.ADD('ship to update: logging request for eval_hold_source', 1);
3588            oe_debug_pub.add('line ID: '|| to_char(p_x_line_rec.line_id) ||
3589 	           ' Entity ID :'|| to_char(p_x_line_rec.ship_to_org_id), 1);
3590          end if;
3591          OE_delayed_requests_Pvt.log_request(
3592                   p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3593                   p_entity_id         => p_x_line_rec.line_id,
3594                   p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3595                   p_requesting_entity_id         => p_x_line_rec.line_id,
3596                   p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
3597                   p_request_unique_key1 => 'SHIP_TO',
3598                   p_param1		 => 'S',
3599                   p_param2		 => p_x_line_rec.ship_to_org_id,
3600                   x_return_status     => l_return_status);
3601 
3602          if l_debug_level > 0 then
3603           oe_debug_pub.add('return status after logging delayed request '||
3604                          p_x_line_rec.return_status, 1);
3605          end if;
3606      END IF;
3607 
3608     END IF;
3609 
3610 
3611 
3612     IF NOT OE_GLOBALS.Equal(p_x_line_rec.sold_to_org_id,p_old_line_rec.sold_to_org_id)
3613     THEN
3614 
3615 	-- Need to Call Shipping Update
3616     	l_update_shipping	:= FND_API.G_TRUE;
3617 	--Customer Acceptance
3618         l_def_contingency_attributes := FND_API.G_TRUE;
3619 
3620        if l_debug_level > 0 then
3621         oe_debug_pub.add('In Apply Atrributes:Sold To', 1);
3622         oe_debug_pub.add('Return Status before is : '||p_x_line_rec.return_status, 1);
3623        end if;
3624 
3625 	-- Call Pricing
3626         OE_GLOBALS.G_PRICE_FLAG := 'Y';
3627 
3628 
3629         -- bug 1829201, need to recalculate commitment.
3630         IF p_x_line_rec.commitment_id is not null then
3631          l_calculate_commitment_flag := 'Y';
3632         END IF;
3633 
3634         IF (p_old_line_rec.sold_to_org_id IS NOT NULL AND
3635             p_x_line_rec.sold_to_org_id <> FND_API.G_MISS_NUM) THEN
3636           IF p_x_line_rec.item_identifier_type = 'CUST' THEN
3637              IF (p_x_line_rec.ordered_item_id IS NOT NULL AND
3638                  p_x_line_rec.ordered_item_id <> FND_API.G_MISS_NUM) THEN
3639                if l_debug_level > 0 then
3640                 oe_debug_pub.add('old sold_to is' || to_char(p_old_line_rec.sold_to_org_id), 1);
3641                 oe_debug_pub.add('new sold_to is' || to_char(p_x_line_rec.sold_to_org_id), 1);
3642                end if;
3643                 fnd_message.set_name('ONT','OE_CUSTOMER_ITEM_EXIST');
3644                 OE_MSG_PUB.Add;
3645                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
3646              END IF;
3647           END IF;
3648         END IF;
3649        if l_debug_level > 0 then
3650         oe_debug_pub.add('Return Status after is : '||p_x_line_rec.return_status, 1);
3651        end if;
3652 
3653         if p_x_line_rec.commitment_id is not null then
3654           l_get_commitment_bal := 'Y';
3655         end if;
3656 
3657     END IF;
3658 
3659     IF NOT OE_GLOBALS.Equal(p_x_line_rec.source_document_type_id,p_old_line_rec.source_document_type_id)
3660     THEN
3661 
3662 	If p_x_line_rec.source_document_type_id = 2 Then
3663           --
3664         -- bug 1917869
3665 	IF p_x_line_rec.calculate_price_flag in ('N','P') then
3666   	  l_copy_adjustments := TRUE;
3667         END IF;
3668 
3669 	  l_copy_pricing_attributes := TRUE;
3670 
3671           -- commented out for 1819133
3672           /***
3673           IF (NOT OE_GLOBALS.Equal(p_x_line_rec.inventory_item_id,p_old_line_rec.inventory_item_id)) OR (NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_item_id,p_old_line_rec.ordered_item_id)) THEN
3674             p_x_line_rec.calculate_price_flag := 'Y';
3675             OE_GLOBALS.G_PRICE_FLAG := 'Y';
3676           END IF;
3677           ***/
3678 
3679 	End If;
3680         --
3681       --Customer Acceptance
3682        l_def_contingency_attributes := FND_API.G_TRUE;
3683 
3684     END IF;
3685     --
3686 
3687     -- SAO
3688            IF p_x_line_rec.line_category_code <> 'RETURN'
3689                  and p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3690                  and p_x_line_rec.split_by = 'SYSTEM'
3691                  and NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT'
3692                  and p_x_line_rec.calculate_price_flag = 'Y' Then
3693                    p_x_line_rec.calculate_price_flag :='P';
3694            End IF;
3695 
3696 
3697     IF NOT OE_GLOBALS.Equal(p_x_line_rec.split_from_line_id,p_old_line_rec.split_from_line_id)
3698     THEN
3699 
3700 	   -- Do not attempt to copy the adjustments for the parent line
3701 	   IF p_x_line_rec.operation = oe_globals.g_opr_create THEN
3702 	      l_copy_adjustments := TRUE;
3703 	      l_copy_pricing_attributes := TRUE;
3704 
3705            IF p_x_line_rec.split_by = 'SYSTEM'
3706            THEN
3707                p_x_line_rec.calculate_price_flag := 'N';
3708 
3709                IF l_charges_for_backorders = 'Y' AND
3710                   p_x_line_rec.line_category_code <> 'RETURN'   /* For bug#2680291 */
3711 		   AND nvl(p_x_line_rec.order_source_id,-1) <>  10 --added for the FP bug 3709662
3712 
3713                THEN
3714 		   IF l_debug_level > 0 THEN
3715 		       oe_debug_pub.add('pviprana: the price_flag is changing to P here and order_source_id is '||p_x_line_rec.order_source_id);
3716 		        --oe_debug_pub.add('pviprana: order_source_id is ' ||p_x_line_rec.order_source_id);
3717                    END IF;
3718 	     	       p_x_line_rec.calculate_price_flag := 'P';
3719                END IF;
3720 
3721                /*Bug#5026401 - For RMA split lines, set the flag to 'P', if the original line's
3722                  calculate_price_flag is 'P' or 'Y' and if the profile option OM: Charges for Back
3723                  orders is set to 'Yes'.
3724                */
3725                IF l_charges_for_backorders = 'Y' AND
3726                   p_x_line_rec.line_category_code = 'RETURN' AND
3727                   p_x_line_rec.split_from_line_id IS NOT NULL
3728                THEN
3729                   BEGIN
3730                      SELECT calculate_price_flag
3731                      INTO l_orig_line_calc_price_flag
3732                      FROM OE_ORDER_LINES_ALL
3733                      WHERE LINE_ID = p_x_line_rec.split_from_line_id;
3734                   EXCEPTION
3735                      WHEN OTHERS THEN
3736                         l_orig_line_calc_price_flag := NULL;
3737                   END;
3738                   oe_debug_pub.add('Bug#5026401 l_orig_line_calc_price_flag:'||l_orig_line_calc_price_flag);
3739                   IF NVL(l_orig_line_calc_price_flag,'N') IN ('Y','P')
3740                   THEN
3741                      p_x_line_rec.calculate_price_flag := 'P';
3742                   END IF;
3743                END IF;
3744                oe_debug_pub.add('Bug#5026401 p_x_line_rec.calculate_price_flag:'|| p_x_line_rec.calculate_price_flag);
3745                /* Bug#5026401 - End */
3746 
3747            END IF;
3748 	   END IF;
3749 
3750 	   If p_x_line_rec.split_by = 'SYSTEM' then
3751 	   -- Do not reprice the lines when the split is system
3752               --changes for bug 2315926 Begin
3753                     /*    If l_charges_for_backorders = 'N' Then
3754 			  l_no_price_flag := TRUE;
3755                         Else
3756                           l_no_price_flag := FALSE;
3757                         End If;
3758                        */
3759          	  l_no_price_flag := TRUE;
3760               --changes for bug 2315926  end
3761 	   --Elsif p_x_line_rec.split_by = 'USER' Then
3762                -- Bug 1313728
3763                -- User split should keep the original calculate_price_flag
3764 		--	p_x_line_rec.calculate_price_flag:='P';
3765 	   End If;
3766 
3767     END IF;
3768 
3769     IF NOT OE_GLOBALS.Equal(p_x_line_rec.tax_code,p_old_line_rec.tax_code)
3770     THEN
3771         OE_GLOBALS.G_TAX_FLAG := 'Y';
3772 
3773         IF p_x_line_rec.commitment_id IS NOT NULL THEN
3774           l_get_commitment_bal := 'Y';
3775         END IF;
3776     END IF;
3777 
3778     IF NOT OE_GLOBALS.Equal(p_x_line_rec.tax_date,p_old_line_rec.tax_date)
3779     THEN
3780         OE_GLOBALS.G_TAX_FLAG := 'Y';
3781 
3782         IF p_x_line_rec.commitment_id IS NOT NULL THEN
3783           l_get_commitment_bal := 'Y';
3784         END IF;
3785     END IF;
3786 
3787     IF NOT OE_GLOBALS.Equal(p_x_line_rec.tax_exempt_flag,p_old_line_rec.tax_exempt_flag)
3788     THEN
3789         OE_GLOBALS.G_TAX_FLAG := 'Y';
3790 
3791         IF p_x_line_rec.commitment_id IS NOT NULL THEN
3792           l_get_commitment_bal := 'Y';
3793         END IF;
3794     END IF;
3795 
3796     IF NOT OE_GLOBALS.Equal(p_x_line_rec.tax_exempt_number,p_old_line_rec.tax_exempt_number)
3797     THEN
3798 	   -- Log the request for Tax Calculation
3799         OE_GLOBALS.G_TAX_FLAG := 'Y';
3800 
3801         IF p_x_line_rec.commitment_id IS NOT NULL THEN
3802           l_get_commitment_bal := 'Y';
3803         END IF;
3804     END IF;
3805 
3806     IF NOT OE_GLOBALS.Equal(p_x_line_rec.tax_exempt_reason_code,p_old_line_rec.tax_exempt_reason_code)
3807     THEN
3808 	   -- Log the request for Tax Calculation
3809         OE_GLOBALS.G_TAX_FLAG := 'Y';
3810 
3811         IF p_x_line_rec.commitment_id IS NOT NULL THEN
3812           l_get_commitment_bal := 'Y';
3813         END IF;
3814     END IF;
3815 
3816     IF NOT OE_GLOBALS.Equal(p_x_line_rec.tax_value,p_old_line_rec.tax_value)
3817     THEN
3818 
3819 	IF p_x_line_rec.commitment_id is NOT NULL THEN
3820 	   l_calculate_commitment_flag := 'Y';
3821 
3822       	END IF;
3823 	--CC Reversal ER#16014135 Start
3824         IF  p_x_line_rec.tax_value <> p_old_line_rec.tax_value AND l_cc_rev_reauth_code IS NOT NULL THEN
3825           if l_debug_level > 0 then
3826             oe_debug_pub.ADD('Log Verify Payment delayed request in Tax Value change',5);
3827           end if;
3828 	  l_verify_payment_flag := 'Y';
3829         END IF;
3830 	--CC Reversal ER#16014135 End
3831         IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
3832 	  -- Log Verify Payment only if the Tax Value has
3833 	  -- Increased AND Payment Type Code is Credit Card.
3834 	  IF  p_x_line_rec.tax_value > p_old_line_rec.tax_value AND
3835               --OE_Order_Cache.g_header_rec.payment_type_code = 'CREDIT_CARD' THEN --CC Reversal ER#16014135 Commented
3836 	      (OE_Order_Cache.g_header_rec.payment_type_code = 'CREDIT_CARD' AND l_cc_rev_reauth_code IS NULL) THEN --CC Reversal ER#16014135
3837              -- Set flag to log Verify Payment Delayed Request
3838             if l_debug_level > 0 then
3839              oe_debug_pub.ADD('Log Verify Payment delayed request in Tax Value');
3840             end if;
3841 	     l_verify_payment_flag := 'Y';
3842 
3843            ELSIF OE_PrePayment_UTIL.is_prepaid_order(p_x_line_rec.header_id)
3844                       = 'Y' AND p_x_line_rec.booked_flag ='Y' THEN
3845              -- if this is a prepaid order, also log delayed request if ordered
3846              -- quantity decreases, as refund may need to be issued.
3847             if l_debug_level > 0 then
3848              oe_debug_pub.ADD('Log Verify Payment delayed request in Tax Value for prepayment', 3);
3849             end if;
3850 	     l_verify_payment_flag := 'Y';
3851            END IF;
3852          END IF;
3853 
3854     END IF;
3855 
3856     IF NOT OE_GLOBALS.Equal(p_x_line_rec.top_model_line_id,p_old_line_rec.top_model_line_id)
3857     THEN
3858 		-- Need to Call Shipping Update
3859     	l_update_shipping	:= FND_API.G_TRUE;
3860 
3861       --Customer Acceptance
3862        l_def_contingency_attributes := FND_API.G_TRUE;
3863 
3864     END IF;
3865     -- Bug 3418496
3866     IF NOT OE_GLOBALS.Equal(p_x_line_rec.unit_list_price,p_old_line_rec.unit_list_price) THEN
3867        IF( p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3868          AND p_x_line_rec.booked_flag ='Y') THEN
3869          -- Log Delayed Request for Verify Payment
3870         if l_debug_level > 0 then
3871          oe_debug_pub.ADD('log verify payment delayed request for change in List price');
3872         end if;
3873          l_verify_payment_flag := 'Y';
3874        END IF;
3875     END IF;
3876     /* Fixed bug 1889762
3877        If the new selling price is NULL AND old selling price is NOT NULL Then
3878 	 Reprice the line
3879        End if;
3880     */
3881     IF NOT OE_GLOBALS.Equal(p_x_line_rec.unit_selling_price,p_old_line_rec.unit_selling_price)
3882     THEN
3883 
3884         l_3a7_attribute_change := FND_API.G_TRUE;
3885         IF (p_x_line_rec.unit_selling_price is NULL And
3886            p_old_line_rec.unit_selling_price is NOT NULL) Then
3887            if l_debug_level > 0 then
3888 	    oe_debug_pub.add('User has cleared unit selling price');
3889 	    oe_debug_pub.add('Just Reprice');
3890            end if;
3891             --Oe_Line_Adj_Util.Delete_Row(p_line_id=>p_x_line_rec.line_id); 7363196
3892             OE_GLOBALS.G_PRICE_FLAG := 'Y';
3893 	    p_x_line_rec.unit_list_price := NULL;
3894 	    p_x_line_rec.unit_list_price_per_pqty := NULL;
3895         End if;
3896 
3897         OE_GLOBALS.G_TAX_FLAG := 'Y';
3898         IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
3899 	   -- Additional task : Log Verify Payment always when the payment Type
3900 	   -- code is not CREDIT CARD. For CREDIT CARD, log this request only if
3901 	   -- the Unit Selling Price has increased.
3902 
3903 	  --IF OE_Order_Cache.g_header_rec.payment_type_code = 'CREDIT_CARD' THEN --CC Reversal ER#16014135 Commented
3904 	  IF (OE_Order_Cache.g_header_rec.payment_type_code = 'CREDIT_CARD' AND l_cc_rev_reauth_code IS NULL) THEN --CC Reversal ER#16014135
3905 	    IF  p_x_line_rec.unit_selling_price > p_old_line_rec.unit_selling_price
3906 		then
3907                -- Log request here if commitment id is null
3908                IF p_x_line_rec.commitment_id is null THEN
3909                   -- if it is not a prepaid order, log Verify Payment delayed request.
3910                   -- if it is a prepaid order, check the shipped_quantity to make
3911                   -- sure to not collect fund again during repricing at shipment.
3912 
3913                   IF OE_PrePayment_UTIL.is_prepaid_order(p_x_line_rec.header_id) = 'N'
3914                      OR (OE_PrePayment_UTIL.is_prepaid_order(p_x_line_rec.header_id)
3915                          = 'Y' AND p_x_line_rec.booked_flag ='Y'
3916                          AND p_x_line_rec.shipped_quantity IS NULL) THEN
3917                    if l_debug_level > 0 then
3918             	    oe_debug_pub.ADD('Log Verify Payment delayed request in Selling Price');
3919                    end if;
3920 		    l_verify_payment_flag := 'Y';
3921                   END IF;
3922 	        END IF;
3923              ELSIF OE_PrePayment_UTIL.is_prepaid_order(p_x_line_rec.header_id)
3924                     = 'Y'  AND p_x_line_rec.booked_flag ='Y'
3925                     AND p_x_line_rec.shipped_quantity IS NULL THEN
3926                -- if this is a prepaid order, also log delayed request if selling
3927                -- price decreases, as refund may need to be issued.
3928               if l_debug_level > 0 then
3929 	       oe_debug_pub.ADD('Log Verify Payment delayed request for change in Selling Price for prepayment', 3);
3930               end if;
3931 	       l_verify_payment_flag := 'Y';
3932              END IF;
3933 	   ELSE
3934 	     IF p_x_line_rec.booked_flag ='Y' THEN
3935                if l_debug_level > 0 then
3936 	        oe_debug_pub.ADD('Log Verify Payment delayed request for change in Selling Price');
3937                end if;
3938 	        l_verify_payment_flag := 'Y';
3939 	   END IF;
3940          END IF;
3941 
3942         END IF;
3943 
3944         IF p_x_line_rec.commitment_id is not null then
3945 	  l_calculate_commitment_flag := 'Y';
3946         END IF;
3947 
3948     END IF;
3949 
3950 /* csheu -- bug #1533658 S*/
3951 
3952     IF NOT OE_GLOBALS.Equal(p_x_line_rec.service_start_date,p_old_line_rec.service_start_date)
3953 
3954     THEN
3955 	    -- Call Pricing
3956         if l_debug_level > 0 then
3957 	 oe_debug_pub.add('CSH- service start_date is changed');
3958         end if;
3959          OE_GLOBALS.G_PRICE_FLAG := 'Y';
3960 	 l_copy_service_fields := TRUE;
3961 
3962          IF p_x_line_rec.commitment_id IS NOT NULL THEN
3963            l_get_commitment_bal := 'Y';
3964          END IF;
3965           --BUG#12542895
3966 	 	IF (p_x_line_rec.item_type_code = 'SERVICE'
3967 		    OR p_x_line_rec.subscription_enable_flag='Y' ) THEN --sol_ord_er #16014165
3968 	 		oe_debug_pub.add('Calling OE_SERVICE_UTIL.Get_Service_Duration for change in service start date');
3969 	 		      OE_SERVICE_UTIL.Get_Service_Duration
3970 	 				(x_return_status => l_return_status
3971 	 				 , p_x_line_rec    => p_x_line_rec);
3972 
3973 	 		      IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3974 	 			    RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3975 	 		      ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3976 	 			     RAISE FND_API.G_EXC_ERROR;
3977 	 		       END IF;
3978 	 	END IF;
3979 	 --BUG#12542895
3980     END IF;
3981 
3982 
3983     IF NOT OE_GLOBALS.Equal(p_x_line_rec.service_end_date,p_old_line_rec.service_end_date)
3984 
3985     THEN
3986         if l_debug_level > 0 then
3987 	 oe_debug_pub.add('CSH- service end_date is changed');
3988         end if;
3989 	 -- Call Pricing
3990          OE_GLOBALS.G_PRICE_FLAG := 'Y';
3991 	 l_copy_service_fields := TRUE;
3992 
3993          IF p_x_line_rec.commitment_id IS NOT NULL THEN
3994            l_get_commitment_bal := 'Y';
3995          END IF;
3996           --BUG#12542895
3997 	 	IF (p_x_line_rec.item_type_code = 'SERVICE'
3998 		    OR p_x_line_rec.subscription_enable_flag='Y' ) THEN --sol_ord_er #16014165
3999 	 		oe_debug_pub.add('Calling OE_SERVICE_UTIL.Get_Service_Duration for change in service end date');
4000 	 		      OE_SERVICE_UTIL.Get_Service_Duration
4001 	 				(x_return_status => l_return_status
4002 	 				 , p_x_line_rec    => p_x_line_rec);
4003 
4004 	 		      IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4005 	 			    RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4006 	 		      ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4007 	 			     RAISE FND_API.G_EXC_ERROR;
4008 	 		       END IF;
4009 	 	END IF;
4010 	 --BUG#12542895
4011     END IF;
4012 
4013 /* csheu -- bug #1533658 E*/
4014 
4015     IF NOT OE_GLOBALS.Equal(p_x_line_rec.service_duration,p_old_line_rec.service_duration)
4016 
4017     THEN
4018 	    -- Call Pricing
4019          OE_GLOBALS.G_PRICE_FLAG := 'Y';
4020 /* csheu -- bug #1533658 s*/
4021         if l_debug_level > 0 then
4022          oe_debug_pub.add('CSH- service duration is changed');
4023         end if;
4024          l_copy_service_fields := TRUE;
4025 /* csheu -- bug #1533658 e*/
4026 
4027          IF p_x_line_rec.commitment_id IS NOT NULL THEN
4028            l_get_commitment_bal := 'Y';
4029          END IF;
4030           --BUG#12542895
4031 	 	IF (p_x_line_rec.item_type_code = 'SERVICE'
4032 		    OR p_x_line_rec.subscription_enable_flag='Y' ) THEN --sol_ord_er #16014165
4033 	 		oe_debug_pub.add('Calling OE_SERVICE_UTIL.Get_Service_Duration for change in service Duration');
4034 	 		      OE_SERVICE_UTIL.Get_Service_Duration
4035 	 				(x_return_status => l_return_status
4036 	 				 , p_x_line_rec    => p_x_line_rec);
4037 
4038 	 		      IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4039 	 			    RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4040 	 		      ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4041 	 			     RAISE FND_API.G_EXC_ERROR;
4042 	 		       END IF;
4043 	 	END IF;
4044 	 --BUG#12542895
4045     END IF;
4046 
4047     IF NOT OE_GLOBALS.Equal(p_x_line_rec.service_period,p_old_line_rec.service_period)
4048     THEN
4049         -- Reprice the Line
4050         OE_GLOBALS.G_PRICE_FLAG := 'Y';
4051 
4052         IF p_x_line_rec.commitment_id IS NOT NULL THEN
4053           l_get_commitment_bal := 'Y';
4054         END IF;
4055 
4056 /* csheu -- bug #1533658 s*/
4057        if l_debug_level > 0 then
4058         oe_debug_pub.add('CSH- service period is changed');
4059        end if;
4060         l_copy_service_fields := TRUE;
4061 /* csheu -- bug #1533658 e*/
4062         --BUG#12542895
4063 		IF (p_x_line_rec.item_type_code = 'SERVICE'
4064 		    OR p_x_line_rec.subscription_enable_flag='Y' ) THEN --sol_ord_er #16014165
4065 			oe_debug_pub.add('Calling OE_SERVICE_UTIL.Get_Service_Duration for change in service Period');
4066 			      OE_SERVICE_UTIL.Get_Service_Duration
4067 					(x_return_status => l_return_status
4068 					 , p_x_line_rec    => p_x_line_rec);
4069 
4070 			      IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4071 				    RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4072 			      ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4073 				    RAISE FND_API.G_EXC_ERROR;
4074 			      END IF;
4075 	       END IF;
4076        --BUG#12542895
4077     END IF;
4078 
4079     IF NOT OE_GLOBALS.Equal(p_x_line_rec.service_reference_line_id,p_old_line_rec.service_reference_line_id)
4080 
4081     THEN
4082        if l_debug_level > 0 then
4083 	 oe_debug_pub.add('JPN: line id is: ' || to_char(p_x_line_rec.line_id));
4084 	 oe_debug_pub.add('JPN: Serviced line id is: ' || to_char(p_x_line_rec.service_reference_line_id));
4085        end if;
4086 
4087 -- The IF condition on source_type_document_type_id is being
4088 -- commented for bug 2372098
4089 
4090 --      IF (p_x_line_rec.source_document_type_id = 2) THEN
4091 --	    NULL; /* do nothing for copy order */
4092 --      ELSE /* cascade the service line to options */
4093 
4094 	IF (nvl(p_x_line_rec.source_document_type_id,-99) <> 2) THEN  -- for bug 2494517, 2567242(nvl condition)
4095 
4096 	   /* Call to retrieve service reference information */
4097 
4098 	   IF (p_x_line_rec.item_type_code = 'SERVICE') THEN
4099 
4100 	     OE_SERVICE_UTIL.Get_Service_Attribute
4101                              (x_return_status => l_return_status
4102                              , p_x_line_rec    => p_x_line_rec
4103                              );
4104 
4105          if l_debug_level > 0 then
4106           oe_debug_pub.add('AKS: Service num is: ' || to_char(p_x_line_rec.service_number));
4107           oe_debug_pub.add('UTIL call: Line num is: ' || to_char(p_x_line_rec.line_number));
4108          end if;
4109 
4110           IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4111             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4112           ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4113             RAISE FND_API.G_EXC_ERROR;
4114           END IF;
4115 
4116           OE_SERVICE_UTIL.Get_Service_Duration
4117                         (x_return_status => l_return_status
4118                          , p_x_line_rec    => p_x_line_rec);
4119 
4120           IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4121             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4122           ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4123             RAISE FND_API.G_EXC_ERROR;
4124           END IF;
4125 
4126 	   END IF; /* End of item_type_code */
4127 
4128 	 END IF; /* source_document_type_id */
4129 
4130 /* hashraf bug # 2757859 */
4131 
4132     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,p_old_line_rec.ordered_quantity) THEN
4133          OE_GLOBALS.G_PRICE_FLAG := 'Y';
4134     END IF;
4135 
4136 /* end of 2757859 */
4137 
4138 
4139 
4140         IF p_x_line_rec.service_reference_type_code  = 'ORDER' THEN
4141 	     BEGIN
4142 
4143      	  Select 'Y'
4144      	  INTO   l_is_model
4145      	  FROM   oe_order_lines
4146      	  WHERE  line_id = p_x_line_rec.service_reference_line_id
4147      	  AND    item_type_code in ('INCLUDED', 'MODEL', 'CLASS', 'OPTION', 'KIT') ; -- Included KIT Item Type Code for bug 2938790
4148 
4149           EXCEPTION
4150           WHEN OTHERS THEN
4151             l_is_model := 'N';
4152           END;
4153 
4154 -- Added for bug 2372098. The IF condition below would set the flag
4155 -- l_is_model to Y, if the configuration has any serviceable
4156 -- INCLUDED items. This check is for copied service lines.
4157 
4158 	   IF (p_x_line_rec.source_document_type_id = 2 AND l_is_model = 'Y') THEN
4159             if l_debug_level > 0 then
4160               oe_debug_pub.add( 'This is a copied service line', 5 );
4161             end if;
4162 	      BEGIN
4163 		 Select 'Y'
4164 		   INTO   l_is_model
4165 		   FROM   oe_order_lines l
4166 		   WHERE  top_model_line_id = p_x_line_rec.service_reference_line_id
4167 		   AND    item_type_code = 'INCLUDED'
4168  		   AND    exists (select null from mtl_system_items mtl where
4169  				  mtl.inventory_item_id = l.inventory_item_id and
4170  				  mtl.serviceable_product_flag = 'Y' and
4171  				  mtl.organization_id=OE_SYS_PARAMETERS.VALUE('MASTER_ORGANIZATION_ID') )
4172 		   AND    ROWNUM = 1;
4173 
4174 	      EXCEPTION
4175 		 WHEN OTHERS THEN
4176 		    l_is_model := 'N';
4177 	      END;
4178 	   END IF; /* source_document_id = 2 and l_is_model = 'Y'*/
4179 
4180 -- end 2372098
4181 
4182 
4183             /* Log the service delayed request only if it is not a split. */
4184             /* Fix for Bug 1802612 */
4185 
4186            if l_debug_level > 0 then
4187 	     oe_debug_pub.ADD('SERVICE: Logging delayed request ');
4188 	     oe_debug_pub.ADD('JPN: What type of item: '|| l_is_model);
4189              oe_debug_pub.add('Split action code:' || p_x_line_rec.split_action_code);
4190              oe_debug_pub.add('Operation:' || p_x_line_rec.operation);
4191              oe_debug_pub.add('Split from line:' || p_x_line_rec.split_from_line_id);
4192            end if;
4193 
4194              IF NOT (( NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT' and
4195                            p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE) or
4196                           (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE and
4197                            p_x_line_rec.split_from_line_id is NOT NULL)) then
4198 
4199 
4200 	     IF p_x_line_rec.service_reference_type_code = 'ORDER' and
4201 		  p_x_line_rec.service_reference_line_id is NOT NULL and
4202 		  (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE or
4203 		  p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE) and
4204 		  l_is_model = 'Y' THEN
4205       --bug 16848168 changes
4206       BEGIN
4207       oe_debug_pub.ADD('p_x_line_rec.service_reference_line_id : '||p_x_line_rec.service_reference_line_id,1);
4208       oe_debug_pub.ADD('p_x_line_rec.line_id : '||p_x_line_rec.line_id,1);
4209       oe_debug_pub.ADD('p_x_line_rec.item_type_code : '||p_x_line_rec.item_type_code,1);
4210       oe_debug_pub.ADD('p_x_line_rec.SUBSCRIPTION_ENABLE_FLAG : '||p_x_line_rec.SUBSCRIPTION_ENABLE_FLAG,1);
4211 
4212 
4213       SELECT 'Y'
4214         INTO l_prg
4215         FROM oe_price_adjustments prg, oe_price_adj_assocs a,
4216                oe_price_adjustments p
4217               WHERE prg.line_id = p_x_line_rec.service_reference_line_id
4218               AND prg.list_line_type_code = 'PRG'
4219               AND prg.price_adjustment_id = a.price_adjustment_id
4220               AND p.price_adjustment_id = a.rltd_price_adj_id
4221               AND p.line_id = p_x_line_rec.line_id
4222               AND p_x_line_rec.item_type_code = 'SERVICE' AND p_x_line_rec.SUBSCRIPTION_ENABLE_FLAG <> 'Y'
4223               AND ROWNUM <2;
4224 
4225       EXCEPTION
4226         WHEN NO_DATA_FOUND THEN
4227           oe_debug_pub.ADD('prg does not exist',1);
4228             l_prg := 'N';
4229       END;
4230 
4231       oe_debug_pub.ADD('l_prg is '||l_prg);
4232       IF l_prg = 'N' THEN
4233 
4234 		  OE_Delayed_Requests_Pvt.log_request(
4235 					p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4236 					p_entity_id   => p_x_line_rec.line_id,
4237 					p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4238 					p_requesting_entity_id   => p_x_line_rec.line_id,
4239 					p_request_type   => OE_GLOBALS.G_INSERT_SERVICE,
4240 					x_return_status  => l_return_status);
4241 
4242       ELSE
4243 
4244         oe_debug_pub.add('Do not cascade service:- service got added by PRG modifier', 2);
4245 
4246       END IF;
4247       --end bug 16848168 changes
4248 	     END IF; /* delayed request */
4249         END IF; /* service_reference_type_code = ORDER */
4250        END IF;  /*  Check if not split */
4251 -- commented for bug 2372098
4252 --      END IF; /* not from copy order */
4253     END IF; /* service_reference_line_id not equal */
4254 
4255 /*lchen -- bug #1761154 start*/
4256 --For bug 2447402, added INCLUDED, KIT item_type_codes in the IF condition
4257 
4258     IF (p_x_line_rec.item_type_code = 'OPTION' OR
4259         p_x_line_rec.item_type_code = 'CLASS' OR
4260         p_x_line_rec.item_type_code = 'INCLUDED' OR
4261         p_x_line_rec.item_type_code = 'KIT' ) and p_x_line_rec.top_model_line_id is NOT NULL then
4262 
4263    IF NOT (( NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT' and
4264             p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE) or
4265             (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE and
4266             p_x_line_rec.split_from_line_id is NOT NULL)) then
4267 
4268      IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE
4269      THEN
4270     if l_debug_level > 0 then
4271      oe_debug_pub.ADD('operation : '|| p_x_line_rec.operation);
4272      oe_debug_pub.ADD('inventory_item_id : '|| p_x_line_rec.inventory_item_id);
4273     end if;
4274      BEGIN
4275        select distinct 'Y'
4276        into l_serviceable_item
4277        from mtl_system_items mtl
4278        where mtl.inventory_item_id = p_x_line_rec.inventory_item_id
4279       and mtl.organization_id=OE_SYS_PARAMETERS.VALUE('MASTER_ORGANIZATION_ID')
4280       and mtl.serviceable_product_flag='Y';
4281    -- lchen added check for organizations to fix bug 2039304
4282 
4283       EXCEPTION
4284       WHEN OTHERS THEN
4285          l_serviceable_item := 'N';
4286      END;
4287 
4288      if l_debug_level > 0 then
4289       oe_debug_pub.ADD('serviceable option :  '|| l_serviceable_item);
4290 
4291       oe_debug_pub.ADD('service_reference_line_id:  '|| p_x_line_rec.top_model_line_id);
4292      end if;
4293 
4294        IF l_serviceable_item = 'Y' THEN
4295          BEGIN
4296           select distinct 'Y'
4297           into l_serviced_model
4298           from oe_order_lines
4299           where item_type_code = 'SERVICE'
4300           and service_reference_line_id = p_x_line_rec.top_model_line_id
4301           and service_reference_type_code = 'ORDER';
4302 
4303           EXCEPTION
4304           WHEN OTHERS THEN
4305              l_serviced_model := 'N';
4306           END;
4307 
4308          if l_debug_level > 0 then
4309           oe_debug_pub.ADD('serviced model :  '|| l_serviced_model);
4310          end if;
4311 
4312           IF l_serviced_model = 'Y' THEN
4313             if l_debug_level > 0 then
4314               oe_debug_pub.add('Before log delayed request -- G_CASCADE_OPTIONS_SERVICE',1);
4315             end if;
4316               OE_Delayed_Requests_Pvt.log_request(
4317 					p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4318 					p_entity_id   => p_x_line_rec.line_id,
4319 					p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4320 					p_requesting_entity_id   => p_x_line_rec.line_id,
4321 					p_request_type   => OE_GLOBALS.G_CASCADE_OPTIONS_SERVICE,
4322 					x_return_status  => l_return_status);
4323 
4324 	   END IF; /* delayed request -- G_CASCADE_OPTIONS_SERVICE  */
4325        END IF; /*l_serviceable_item = 'Y' */
4326      END IF; /*operation = CREATE */
4327    END IF; /* check if not split */
4328  END IF; /* item_type_code='OPTION' or 'CLASS'*/
4329 
4330     -- oe_debug_pub.add(' out of cascade option condition',1);
4331 
4332 /*lchen -- bug #1761154 end*/
4333 
4334    /* End of service related columns */
4335 
4336     IF NOT OE_GLOBALS.Equal(p_x_line_rec.shipping_instructions,p_old_line_rec.shipping_instructions)
4337     THEN
4338 		-- Need to Call Shipping Update
4339     	l_update_shipping	:= FND_API.G_TRUE;
4340     END IF;
4341 
4342     IF NOT OE_GLOBALS.Equal(p_x_line_rec.packing_instructions,p_old_line_rec.packing_instructions)
4343     THEN
4344 		-- Need to Call Shipping Update
4345     	l_update_shipping	:= FND_API.G_TRUE;
4346     END IF;
4347 
4348    -- Added for the bug 2939731
4349 
4350    IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_item_id,p_old_line_rec.ordered_item_id)
4351     THEN
4352         -- Need to Call Shipping Update
4353         l_update_shipping       := FND_API.G_TRUE;
4354    END IF;
4355 
4356 
4357 -- adding check for changes in project/task
4358 
4359    IF NOT OE_GLOBALS.Equal(p_x_line_rec.project_id,p_old_line_rec.project_id)
4360     THEN
4361         -- Need to Call Shipping Update
4362         l_update_shipping       := FND_API.G_TRUE;
4363    END IF;
4364 
4365 
4366    IF NOT OE_GLOBALS.Equal(p_x_line_rec.task_id,p_old_line_rec.task_id)
4367     THEN
4368         -- Need to Call Shipping Update
4369         l_update_shipping       := FND_API.G_TRUE;
4370    END IF;
4371 
4372 
4373 --ER#7479609 start
4374     IF NOT OE_GLOBALS.Equal(p_x_line_rec.created_by,p_old_line_rec.created_by)
4375        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4376        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
4377        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
4378     THEN
4379           IF l_debug_level > 0 then
4380              oe_debug_pub.ADD('created By update: logging request for eval_hold_source');
4381              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
4382 		             ' Entity ID: '|| to_char(p_x_line_rec.created_by));
4383           END IF;
4384 
4385           OE_delayed_requests_Pvt.log_request(
4386                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4387                     p_entity_id         => p_x_line_rec.line_id,
4388 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4389 		    p_requesting_entity_id         => p_x_line_rec.line_id,
4390                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
4391                     p_request_unique_key1 => 'CREATED_BY',
4392                     p_param1		 => 'CB',
4393                     p_param2		 => p_x_line_rec.created_by,
4394                     x_return_status     => l_return_status);
4395    END IF;
4396 
4397     IF NOT OE_GLOBALS.Equal(p_x_line_rec.creation_date,p_old_line_rec.creation_date)
4398        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4399        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
4400        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
4401     THEN
4402           IF l_debug_level > 0 then
4403              oe_debug_pub.ADD('Creation date update: logging request for eval_hold_source');
4404              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
4405 		             ' Entity ID: '|| to_char(p_x_line_rec.creation_date));
4406           END IF;
4407 
4408           OE_delayed_requests_Pvt.log_request(
4409                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4410                     p_entity_id         => p_x_line_rec.line_id,
4411 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4412 		    p_requesting_entity_id         => p_x_line_rec.line_id,
4413                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
4414                     p_request_unique_key1 => 'CREATION_DATE',
4415                     p_param1		 => 'CD',
4416                     p_param2		 => p_x_line_rec.creation_date,
4417                     x_return_status     => l_return_status);
4418    END IF;
4419 
4420     IF NOT OE_GLOBALS.Equal(p_x_line_rec.sold_to_org_id,p_old_line_rec.sold_to_org_id)
4421        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4422        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
4423        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
4424     THEN
4425           IF l_debug_level > 0 then
4426              oe_debug_pub.ADD('Customer update: logging request for eval_hold_source');
4427              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
4428 		             ' Entity ID: '|| to_char(p_x_line_rec.sold_to_org_id));
4429           END IF;
4430 
4431           OE_delayed_requests_Pvt.log_request(
4432                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4433                     p_entity_id         => p_x_line_rec.line_id,
4434 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4435 		    p_requesting_entity_id         => p_x_line_rec.line_id,
4436                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
4437                     p_request_unique_key1 => 'CUSTOMER',
4438                     p_param1		 => 'C',
4439                     p_param2		 => p_x_line_rec.sold_to_org_id,
4440                     x_return_status     => l_return_status);
4441    END IF;
4442 
4443     IF NOT OE_GLOBALS.Equal(p_x_line_rec.deliver_to_org_id,p_old_line_rec.deliver_to_org_id)
4444        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4445        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
4446        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
4447     THEN
4448           IF l_debug_level > 0 then
4449              oe_debug_pub.ADD('Delver to site update: logging request for eval_hold_source');
4450              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
4451 		             ' Entity ID: '|| to_char(p_x_line_rec.deliver_to_org_id));
4452           END IF;
4453 
4454           OE_delayed_requests_Pvt.log_request(
4455                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4456                     p_entity_id         => p_x_line_rec.line_id,
4457 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4458 		    p_requesting_entity_id         => p_x_line_rec.line_id,
4459                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
4460                     p_request_unique_key1 => 'DELIVER_TO',
4461                     p_param1		 => 'D',
4462                     p_param2		 => p_x_line_rec.deliver_to_org_id,
4463                     x_return_status     => l_return_status);
4464    END IF;
4465 
4466     IF NOT OE_GLOBALS.Equal(p_x_line_rec.line_type_id,p_old_line_rec.line_type_id)
4467        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4468        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
4469        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
4470     THEN
4471           IF l_debug_level > 0 then
4472              oe_debug_pub.ADD('Line Type update: logging request for eval_hold_source');
4473              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
4474 		             ' Entity ID: '|| to_char(p_x_line_rec.line_type_id));
4475           END IF;
4476 
4477           OE_delayed_requests_Pvt.log_request(
4478                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4479                     p_entity_id         => p_x_line_rec.line_id,
4480 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4481 		    p_requesting_entity_id         => p_x_line_rec.line_id,
4482                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
4483                     p_request_unique_key1 => 'LINE_TYPE',
4484                     p_param1		 => 'LT',
4485                     p_param2		 => p_x_line_rec.line_type_id,
4486                     x_return_status     => l_return_status);
4487    END IF;
4488 
4489     IF NOT OE_GLOBALS.Equal(p_x_line_rec.payment_term_id,p_old_line_rec.payment_term_id)
4490        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4491        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
4492        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
4493     THEN
4494           IF l_debug_level > 0 then
4495              oe_debug_pub.ADD('Payment Term update: logging request for eval_hold_source');
4496              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
4497 		             ' Entity ID: '|| to_char(p_x_line_rec.payment_term_id));
4498           END IF;
4499 
4500           OE_delayed_requests_Pvt.log_request(
4501                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4502                     p_entity_id         => p_x_line_rec.line_id,
4503 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4504 		    p_requesting_entity_id         => p_x_line_rec.line_id,
4505                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
4506                     p_request_unique_key1 => 'TERM',
4507                     p_param1		 => 'PT',
4508                     p_param2		 => p_x_line_rec.payment_term_id,
4509                     x_return_status     => l_return_status);
4510    END IF;
4511 
4512     IF NOT OE_GLOBALS.Equal(p_x_line_rec.price_list_id,p_old_line_rec.price_list_id)
4513        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4514        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
4515        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
4516     THEN
4517           IF l_debug_level > 0 then
4518              oe_debug_pub.ADD('Price List update: logging request for eval_hold_source');
4519              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
4520 		             ' Entity ID: '|| to_char(p_x_line_rec.price_list_id));
4521           END IF;
4522 
4523           OE_delayed_requests_Pvt.log_request(
4524                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4525                     p_entity_id         => p_x_line_rec.line_id,
4526 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4527 		    p_requesting_entity_id         => p_x_line_rec.line_id,
4528                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
4529                     p_request_unique_key1 => 'PRICE_LIST',
4530                     p_param1		 => 'PL',
4531                     p_param2		 => p_x_line_rec.price_list_id,
4532                     x_return_status     => l_return_status);
4533    END IF;
4534 
4535     IF NOT OE_GLOBALS.Equal(p_x_line_rec.project_id,p_old_line_rec.project_id)
4536        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4537        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
4538        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
4539     THEN
4540           IF l_debug_level > 0 then
4541              oe_debug_pub.ADD('Project update: logging request for eval_hold_source');
4542              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
4543 		             ' Entity ID: '|| to_char(p_x_line_rec.project_id));
4544           END IF;
4545 
4546           OE_delayed_requests_Pvt.log_request(
4547                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4548                     p_entity_id         => p_x_line_rec.line_id,
4549 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4550 		    p_requesting_entity_id         => p_x_line_rec.line_id,
4551                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
4552                     p_request_unique_key1 => 'PROJECT',
4553                     p_param1		 => 'PR',
4554                     p_param2		 => p_x_line_rec.project_id,
4555                     x_return_status     => l_return_status);
4556    END IF;
4557 
4558     IF NOT OE_GLOBALS.Equal(p_x_line_rec.shipping_method_code,p_old_line_rec.shipping_method_code)
4559        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4560        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
4561        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
4562     THEN
4563           IF l_debug_level > 0 then
4564              oe_debug_pub.ADD('Shipping Method update: logging request for eval_hold_source');
4565              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
4566 		             ' Entity ID: '|| to_char(p_x_line_rec.shipping_method_code));
4567           END IF;
4568 
4569           OE_delayed_requests_Pvt.log_request(
4570                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4571                     p_entity_id         => p_x_line_rec.line_id,
4572 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4573 		    p_requesting_entity_id         => p_x_line_rec.line_id,
4574                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
4575                     p_request_unique_key1 => 'SHIP_METHOD',
4576                     p_param1		 => 'SM',
4577                     p_param2		 => p_x_line_rec.shipping_method_code,
4578                     x_return_status     => l_return_status);
4579    END IF;
4580 
4581     IF NOT OE_GLOBALS.Equal(p_x_line_rec.source_type_code,p_old_line_rec.source_type_code)
4582        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4583        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
4584        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
4585     THEN
4586           IF l_debug_level > 0 then
4587              oe_debug_pub.ADD('Source Type update: logging request for eval_hold_source');
4588              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
4589 		             ' Entity ID: '|| to_char(p_x_line_rec.source_type_code));
4590           END IF;
4591 
4592           OE_delayed_requests_Pvt.log_request(
4593                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4594                     p_entity_id         => p_x_line_rec.line_id,
4595 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4596 		    p_requesting_entity_id         => p_x_line_rec.line_id,
4597                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
4598                     p_request_unique_key1 => 'SOURCE_TYPE',
4599                     p_param1		 => 'ST',
4600                     p_param2		 => p_x_line_rec.source_type_code,
4601                     x_return_status     => l_return_status);
4602    END IF;
4603 
4604     IF NOT OE_GLOBALS.Equal(p_x_line_rec.task_id,p_old_line_rec.task_id)
4605        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4606        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
4607        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
4608     THEN
4609           IF l_debug_level > 0 then
4610              oe_debug_pub.ADD('task id update: logging request for eval_hold_source');
4611              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
4612 		             ' Entity ID: '|| to_char(p_x_line_rec.task_id));
4613           END IF;
4614 
4615           OE_delayed_requests_Pvt.log_request(
4616                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4617                     p_entity_id         => p_x_line_rec.line_id,
4618 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4619 		    p_requesting_entity_id         => p_x_line_rec.line_id,
4620                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
4621                     p_request_unique_key1 => 'TASK',
4622                     p_param1		 => 'T',
4623                     p_param2		 => p_x_line_rec.task_id,
4624                     x_return_status     => l_return_status);
4625    END IF;
4626 
4627     IF NOT OE_GLOBALS.Equal(p_x_line_rec.inventory_item_id,p_old_line_rec.inventory_item_id)
4628        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4629        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
4630        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
4631     THEN
4632           IF l_debug_level > 0 then
4633              oe_debug_pub.ADD('Top Model update: logging request for eval_hold_source');
4634              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
4635 		             ' Entity ID: '|| to_char(p_x_line_rec.inventory_item_id));
4636           END IF;
4637 
4638           OE_delayed_requests_Pvt.log_request(
4639                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4640                     p_entity_id         => p_x_line_rec.line_id,
4641 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4642 		    p_requesting_entity_id         => p_x_line_rec.line_id,
4643                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
4644                     p_request_unique_key1 => 'TOP_MODEL',
4645                     p_param1		 => 'TM',
4646                     p_param2		 => p_x_line_rec.inventory_item_id,
4647                     x_return_status     => l_return_status);
4648    END IF;
4649 
4650 
4651 --ER#7479609 end
4652 
4653   --ER 12571983 start
4654   IF NOT OE_GLOBALS.Equal(p_x_line_rec.end_customer_id,p_old_line_rec.end_customer_id)
4655      AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4656 	 AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
4657 	 AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F' THEN
4658 
4659 	IF l_debug_level > 0 THEN
4660       oe_debug_pub.ADD('End Customer update: logging request for eval_hold_source');
4661       oe_debug_pub.ADD('line ID: '|| TO_CHAR(p_x_line_rec.line_id)||
4662                        ' Entity ID: '|| TO_CHAR(p_x_line_rec.end_customer_id));
4663     END IF;
4664 
4665 	OE_delayed_requests_Pvt.log_request(
4666 						p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4667 						p_entity_id => p_x_line_rec.line_id,
4668 						p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4669 						p_requesting_entity_id => p_x_line_rec.line_id,
4670 						p_request_type => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
4671 						p_request_unique_key1 => 'END_CUSTOMER',
4672 						p_param1 => 'EC',
4673 						p_param2 => p_x_line_rec.end_customer_id,
4674 						x_return_status => l_return_status);
4675    END IF;
4676    IF NOT OE_GLOBALS.Equal(p_x_line_rec.end_customer_site_use_id,p_old_line_rec.end_customer_site_use_id)
4677      AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4678 	 AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
4679 	 AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F' THEN
4680 
4681 	IF l_debug_level > 0 THEN
4682       oe_debug_pub.ADD('End Customer Location update: logging request for eval_hold_source');
4683       oe_debug_pub.ADD('line ID: '|| TO_CHAR(p_x_line_rec.line_id)||
4684                        ' Entity ID: '|| TO_CHAR(p_x_line_rec.end_customer_site_use_id));
4685     END IF;
4686 
4687 	OE_delayed_requests_Pvt.log_request(
4688 						p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4689 						p_entity_id => p_x_line_rec.line_id,
4690 						p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4691 						p_requesting_entity_id => p_x_line_rec.line_id,
4692 						p_request_type => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
4693 						p_request_unique_key1 => 'END_CUSTOMER_LOCATION',
4694 						p_param1 => 'EL',
4695 						p_param2 => p_x_line_rec.end_customer_site_use_id,
4696 						x_return_status => l_return_status);
4697    END IF;
4698   --ER 12571983 end
4699 
4700    --ER 3667551 start
4701    -- only if system parameter is set to BTL then processing for BTL case needs to be done
4702   IF NOT OE_GLOBALS.Equal(p_x_line_rec.invoice_to_org_id,p_old_line_rec.invoice_to_org_id)
4703      AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4704 	 AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
4705 	 AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
4706          AND l_credithold_cust ='BTL' THEN
4707 
4708 	 l_bill_to_cust_id := OE_Bulk_Holds_PVT.CustAcctID_func
4709 			                             (p_in_site_id => p_x_line_rec.invoice_to_org_id,
4710                                           p_out_IDfound=> l_new_tbl_entry);
4711 
4712 	IF l_debug_level > 0 THEN
4713       oe_debug_pub.ADD('Bill To Customer update: logging request for eval_hold_source');
4714       oe_debug_pub.ADD('line ID: '|| TO_CHAR(p_x_line_rec.line_id)||
4715                        ' Entity ID: '|| TO_CHAR(l_bill_to_cust_id));
4716     END IF;
4717 
4718 	OE_delayed_requests_Pvt.log_request(
4719 						p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4720 						p_entity_id => p_x_line_rec.line_id,
4721 						p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4722 						p_requesting_entity_id => p_x_line_rec.line_id,
4723 						p_request_type => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
4724 						p_request_unique_key1 => 'BILL_TO_CUSTOMER',
4725 						p_param1 => 'BTL',
4726 						p_param2 => l_bill_to_cust_id,
4727 						x_return_status => l_return_status);
4728    END IF;
4729   --ER 3667551 end
4730 
4731     -- bug 1829201, commitment related change.
4732     IF NOT OE_GLOBALS.Equal(p_x_line_rec.commitment_id,p_old_line_rec.commitment_id)
4733     THEN
4734 
4735       l_calculate_commitment_flag := 'Y';
4736       OE_GLOBALS.G_TAX_FLAG := 'Y';
4737 
4738       -- log delayed request for Verify_Payment.
4739      if l_debug_level > 0 then
4740       oe_debug_pub.add('log verify payment delayed request for change in commitment_id', 3);
4741      end if;
4742      l_verify_payment_flag                         := 'Y';
4743      OE_CREDIT_ENGINE_GRP.TOLERANCE_CHECK_REQUIRED := FALSE; --ER 12363706
4744     END IF;
4745 
4746     IF NOT OE_GLOBALS.Equal(p_x_line_rec.commitment_applied_amount,p_old_line_rec.commitment_applied_amount)
4747        AND OE_Commitment_Pvt.Do_Commitment_Sequencing
4748        AND oe_code_control.code_release_level >= '110510'
4749        AND p_x_line_rec.commitment_id IS NOT NULL
4750     THEN
4751      if l_debug_level > 0 then
4752       oe_debug_pub.add('Log verify payment delayed request for change in commitment_applied_amount.',3);
4753      end if;
4754       l_update_commitment_applied := 'Y';
4755       l_verify_payment_flag := 'Y'; --Added for CC Reversal ER Bug# 16654252
4756     END IF;
4757 
4758     -- QUOTING changes - log fulfillment requests when transaction phase is
4759     -- updated during complete negotiation WF activity
4760     IF
4761     OE_Quote_Util.G_COMPLETE_NEG = 'Y'
4762        AND
4763       NOT OE_GLOBALS.Equal(p_x_line_rec.transaction_phase_code
4764                            ,p_old_line_rec.transaction_phase_code)
4765     THEN
4766 
4767       -- NOTE: Evaluate Hold Source Requests will be directly executed
4768       -- in post_write, no need to log it here.
4769 
4770       if l_debug_level > 0 then
4771          oe_debug_pub.add('Log Complete Neg Requests for Line');
4772       end if;
4773 
4774       -- log a delayed request to get included items for this item if any.
4775 
4776       l_freeze_method := G_FREEZE_METHOD; /* Bug # 5036404 */
4777      if l_debug_level > 0 then
4778       oe_debug_pub.ADD('Freeze method is :' || l_freeze_method,2);
4779      end if;
4780 
4781       IF l_freeze_method = OE_GLOBALS.G_IIFM_ENTRY AND
4782          p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
4783          p_x_line_rec.ato_line_id is NULL AND
4784          ( p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
4785            (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT AND
4786             p_x_line_rec.line_id = p_x_line_rec.top_model_line_id))
4787       THEN
4788            p_x_line_rec.explosion_date := null;
4789            l_count := l_count + 1;
4790            OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL(l_count):= p_x_line_rec.line_id;
4791       END IF;
4792 
4793       -- log request to calculate commitment
4794       IF p_x_line_rec.commitment_id IS NOT NULL THEN
4795          l_calculate_commitment_flag := 'Y';
4796       END IF;
4797 
4798        --Customer Acceptance
4799        l_def_contingency_attributes := FND_API.G_TRUE;
4800 
4801     END IF; -- End if phase is updated and complete neg is 'Y'
4802     -- QUOTING changes: END
4803 
4804     --Customer Acceptance:: Log delayed request to default contingency attributes
4805 
4806     IF NOT OE_GLOBALS.Equal(p_x_line_rec.contingency_id,p_old_line_rec.contingency_id)
4807     THEN
4808       --Customer Acceptance
4809        l_def_contingency_attributes := FND_API.G_TRUE;
4810     END IF;
4811 
4812       IF l_debug_level > 0 then
4813          oe_debug_pub.add('operation:'||p_x_line_rec.operation||' booked_flag:'||p_x_line_rec.booked_flag||' new contingency_id: '||p_x_line_rec.contingency_id ||' old contingency_id: '||p_old_line_rec.contingency_id);
4814       END IF;
4815       IF NVL(OE_SYS_PARAMETERS.VALUE('ENABLE_FULFILLMENT_ACCEPTANCE'), 'N') = 'Y'
4816 	 AND (NVL( p_x_line_rec.booked_flag, 'N') = 'N' OR
4817                  p_x_line_rec.operation=OE_GLOBALS.G_OPR_CREATE)
4818          AND  l_def_contingency_attributes = FND_API.G_TRUE
4819          AND   p_x_line_rec.inventory_item_id IS NOT NULL
4820          AND   p_x_line_rec.inventory_item_id <> FND_API.G_MISS_NUM
4821          AND   p_x_line_rec.line_type_id IS NOT NULL
4822          AND   p_x_line_rec.line_type_id <> FND_API.G_MISS_NUM
4823         THEN
4824 
4825          IF ( p_x_line_rec.line_category_code = 'RETURN' OR
4826              p_x_line_rec.source_document_type_id = 10 OR
4827            (p_x_line_rec.order_source_id=27 AND p_x_line_rec.retrobill_request_id IS NOT NULL) OR
4828            (p_x_line_rec.item_type_code IN ('CONFIG', 'SERVICE', 'CLASS', 'OPTION', 'INCLUDED')) OR
4829            (p_x_line_rec.item_type_code='KIT' AND p_x_line_rec.top_model_line_id <> p_x_line_rec.line_id) OR
4830            (p_x_line_rec.operation=OE_GLOBALS.G_OPR_CREATE AND p_x_line_rec.split_from_line_id IS NULL AND NVL( p_x_line_rec.booked_flag, 'N') = 'N' AND nvl(p_x_line_rec.contingency_id, FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM) OR
4831            (p_x_line_rec.operation=OE_GLOBALS.G_OPR_CREATE AND p_x_line_rec.split_from_line_id IS NOT NULL) OR
4832            (p_x_line_rec.operation=OE_GLOBALS.G_OPR_UPDATE AND NOT OE_GLOBALS.Equal(p_x_line_rec.contingency_id,p_old_line_rec.contingency_id)) OR
4833             NVL(p_x_line_rec.transaction_phase_code, 'F') = 'N') THEN
4834 	     IF l_debug_level  > 0 THEN
4835               oe_debug_pub.add('Item_type_code:'||p_x_line_rec.item_type_code||'-Do not default Contingency Attributes for this line' );
4836              END IF;
4837 
4838 	     OE_ACCEPTANCE_UTIL.Register_Changed_Lines(
4839                 p_line_id           => p_x_line_rec.line_id
4840               , p_header_id         => p_x_line_rec.header_id
4841               , p_line_type_id      => p_x_line_rec.line_type_id
4842               , p_sold_to_org_id    => p_x_line_rec.sold_to_org_id
4843               , p_invoice_to_org_id => p_x_line_rec.invoice_to_org_id
4844               , p_inventory_item_id => p_x_line_rec.inventory_item_id
4845               , p_shippable_flag    => p_x_line_rec.shippable_flag
4846               , p_org_id            => p_x_line_rec.org_id
4847               , p_accounting_rule_id  => p_x_line_rec.accounting_rule_id
4848               , p_ship_to_org_id    => p_x_line_rec.ship_to_org_id  --For Bug#8262992
4849               , p_operation         => OE_GLOBALS.G_OPR_DELETE);
4850 
4851          ELSE
4852 
4853 	     OE_ACCEPTANCE_UTIL.Register_Changed_Lines(
4854                 p_line_id           => p_x_line_rec.line_id
4855               , p_header_id         => p_x_line_rec.header_id
4856               , p_line_type_id      => p_x_line_rec.line_type_id
4857               , p_sold_to_org_id    => p_x_line_rec.sold_to_org_id
4858               , p_invoice_to_org_id => p_x_line_rec.invoice_to_org_id
4859               , p_inventory_item_id => p_x_line_rec.inventory_item_id
4860               , p_shippable_flag    => p_x_line_rec.shippable_flag
4861               , p_org_id            => p_x_line_rec.org_id
4862               , p_accounting_rule_id  => p_x_line_rec.accounting_rule_id
4863               , p_ship_to_org_id    => p_x_line_rec.ship_to_org_id  --For Bug#8262992
4864               , p_operation         => p_x_line_rec.operation);
4865 
4866 	    /** Logic to Default Contingency attributes**/
4867 	    oe_delayed_requests_pvt.log_request(
4868                      p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
4869                      p_entity_id              => p_x_line_rec.header_id,
4870                      p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
4871                      p_requesting_entity_id   => p_x_line_rec.header_id,
4872                      p_request_type           => OE_GLOBALS.G_DFLT_CONTINGENCY_ATTRIBUTES,
4873                      x_return_status          => l_return_status);
4874 
4875 	 END IF;
4876      END IF;
4877      -- Customer Acceptance Changes End
4878 
4879 	 --sol_ord_er #16014165 start
4880       IF l_debug_level  > 0 THEN
4881 		oe_debug_pub.add('FIRST_PERIOD_AMOUNT:' ||p_x_line_rec.SERVICE_FIRST_PERIOD_AMOUNT
4882 		                 ||' Bill Option: '||p_x_line_rec.service_bill_option_code);
4883 	  End If;
4884 	 IF (NVL(p_x_line_rec.service_bill_option_code,'FBOM') <> 'FPOM'
4885 	     and p_x_line_rec.SERVICE_FIRST_PERIOD_AMOUNT is not null) then
4886 		IF l_debug_level  > 0 THEN
4887 			oe_debug_pub.add(' ..First Period Amount made NULL');
4888 		End If;
4889 		p_x_line_rec.SERVICE_FIRST_PERIOD_AMOUNT := '';
4890 		p_x_line_rec.service_first_period_enddate := '';
4891 	 End If;
4892 	 /* Set Bill Option, Bill Profile ID, Coverage and Subscription Template to NULL
4893 	 if line is not Service / subscription,	 to prevent wrong defaulting */
4894 	 IF  (NVL(p_x_line_rec.subscription_enable_flag,'N')='N'
4895 	      AND p_x_line_rec.item_type_code <>'SERVICE'
4896 	       AND NVL(p_x_line_rec.inventory_item_id,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM)
4897 	    THEN
4898 		 If(NVL(p_x_line_rec.service_bill_option_code,FND_API.G_MISS_CHAR) <> FND_API.G_MISS_CHAR) THEN
4899 				IF l_debug_level  > 0 THEN
4900 					oe_debug_pub.add(p_x_line_rec.service_bill_option_code||
4901 							' ..service_bill_option_code is Inavlid for this line, will be reset to NULL');
4902 				End If;
4903 			p_x_line_rec.service_bill_option_code := '';
4904 		 End If;
4905 		 If(NVL(p_x_line_rec.SERVICE_BILL_PROFILE_ID,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM) THEN
4906 				IF l_debug_level  > 0 THEN
4907 					oe_debug_pub.add(p_x_line_rec.SERVICE_BILL_PROFILE_ID||
4908 							' ..SERVICE_BILL_PROFILE_ID is Inavlid for this line, will be reset to NULL');
4909 				End If;
4910 			p_x_line_rec.SERVICE_BILL_PROFILE_ID := '';
4911 		 End If;
4912 		 If(NVL(p_x_line_rec.SERVICE_SUBS_TEMPLATE_ID,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM) THEN
4913 				IF l_debug_level  > 0 THEN
4914 					oe_debug_pub.add(p_x_line_rec.SERVICE_SUBS_TEMPLATE_ID||
4915 							' ..SERVICE_SUBS_TEMPLATE_ID is Inavlid for this line, will be reset to NULL');
4916 				End If;
4917 			p_x_line_rec.SERVICE_SUBS_TEMPLATE_ID := '';
4918 		 End If;
4919 		 If(NVL(p_x_line_rec.SERVICE_COV_TEMPLATE_ID,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM) THEN
4920 				IF l_debug_level  > 0 THEN
4921 					oe_debug_pub.add(p_x_line_rec.SERVICE_COV_TEMPLATE_ID||
4922 							' ..SERVICE_COV_TEMPLATE_ID is Inavlid for this line, will be reset to NULL');
4923 				End If;
4924 			p_x_line_rec.SERVICE_COV_TEMPLATE_ID := '';
4925 		 End If;
4926 	END IF;
4927 	/* Set Bill Profile to NULL if Bill Option is FBOM, To ensure for PO API Update */
4928 	IF NVL(p_x_line_rec.service_bill_option_code,'FBOM') = 'FBOM' AND
4929        NVL(p_x_line_rec.SERVICE_BILL_PROFILE_ID,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM THEN
4930 	   IF l_debug_level  > 0 THEN
4931 					oe_debug_pub.add(p_x_line_rec.SERVICE_BILL_PROFILE_ID||
4932 							' ..(2)..SERVICE_BILL_PROFILE_ID is Inavlid for this line, will be reset to NULL');
4933 		End If;
4934 	   p_x_line_rec.SERVICE_BILL_PROFILE_ID := '';
4935 	End IF;
4936 	 -- Log Delayed Request to Get First Period Billing Amount for Service Item
4937 	 -- Billing Option has to be 'First Period Billing from OM, Subsequent from OKS
4938 	 -- There should be a change in any of the dependent fields.
4939 	  IF l_debug_level  > 0 THEN
4940 		oe_debug_pub.add('Bill Option: '||p_x_line_rec.service_bill_option_code
4941 		                 ||' OLD Bill Option: '||p_old_line_rec.service_bill_option_code);
4942 		oe_debug_pub.add('Service Start: '||p_x_line_rec.service_start_Date
4943 		                 ||' OLD Service Start: '||p_old_line_rec.service_start_Date);
4944 		oe_debug_pub.add('Service End: '||p_x_line_rec.service_end_Date
4945 		                 ||' OLD Service End: '||p_old_line_rec.service_end_Date);
4946 		oe_debug_pub.add('service_period: '||p_x_line_rec.service_period
4947 		                 ||' OLD service_period: '||p_old_line_rec.service_period);
4948 		oe_debug_pub.add('service_duration: '||p_x_line_rec.service_duration
4949 		                 ||' OLD service_duration: '||p_old_line_rec.service_duration);
4950 		oe_debug_pub.add('Bill Profile: '||p_x_line_rec.service_bill_profile_id
4951 		                 ||' OLD Bill Profile: '||p_old_line_rec.service_bill_profile_id);
4952 		oe_debug_pub.add('Ordered Quantity: '||p_x_line_rec.ordered_quantity
4953 		                 ||' USP: '|| p_x_line_rec.unit_selling_price);
4954 		oe_debug_pub.add('item_type_code:' ||p_x_line_rec.item_type_code
4955 		                 ||' Subscription: '||p_x_line_rec.subscription_enable_flag);
4956 	  End If;
4957 		IF (p_x_line_rec.service_bill_option_code = 'FPOM' AND NVL(p_x_line_rec.fulfilled_flag,'N') = 'N'
4958 		AND (p_x_line_rec.item_type_code='SERVICE' OR NVL(p_x_line_rec.subscription_enable_flag,'N')='Y')
4959 		AND(
4960 		    NOT OE_GLOBALS.Equal(p_x_line_rec.service_bill_option_code,p_old_line_rec.service_bill_option_code) OR
4961 			NOT OE_GLOBALS.Equal(p_x_line_rec.service_start_Date,p_old_line_rec.service_start_Date) OR
4962 			NOT OE_GLOBALS.Equal(p_x_line_rec.service_end_Date,p_old_line_rec.service_end_Date) OR
4963 			NOT OE_GLOBALS.Equal(p_x_line_rec.service_period,p_old_line_rec.service_period) OR
4964 			NOT OE_GLOBALS.Equal(p_x_line_rec.service_duration,p_old_line_rec.service_duration) OR
4965 			NOT OE_GLOBALS.Equal(p_x_line_rec.service_bill_profile_id,p_old_line_rec.service_bill_profile_id)
4966 		    )
4967 			)
4968 		   THEN
4969 		 oe_delayed_requests_pvt.log_request(
4970 							 p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
4971 							 p_entity_id              => p_x_line_rec.line_id,
4972 							 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4973 							 p_requesting_entity_id   => p_x_line_rec.line_id,
4974 							 p_request_type           => OE_GLOBALS.G_SERVICE_FIRST_PERIOD_BILL,
4975 							 p_request_unique_key1    => 'LINE',
4976 							 p_param1                 => p_x_line_rec.line_id,
4977 							 x_return_status          => l_return_status);
4978 			-- Billing Profile change needs payment to be logged
4979             l_verify_payment_flag := 'Y';
4980 		END IF;
4981 		IF NOT OE_GLOBALS.Equal(p_x_line_rec.service_bill_option_code,p_old_line_rec.service_bill_option_code) THEN
4982 		   l_verify_payment_flag := 'Y';
4983 		END IF;
4984 		-- For Subscription Template change log Price Line
4985 		If NVL(p_x_line_rec.subscription_enable_flag,'N')='Y' AND
4986 		   NOT OE_GLOBALS.Equal(p_x_line_rec.service_subs_template_id,p_old_line_rec.service_subs_template_id)
4987 		THEN
4988 			IF l_debug_level  > 0 THEN
4989 			  oe_debug_pub.add(' Subscription Template changed, Logging Price Line for line_id = '||p_x_line_rec.line_id);
4990 			End If;
4991 			 OE_delayed_requests_Pvt.log_request(
4992 				p_entity_code 			=> OE_GLOBALS.G_ENTITY_LINE,
4993 				p_entity_id         	=> p_x_line_rec.line_id,
4994 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4995 				p_requesting_entity_id   => p_x_line_rec.line_id,
4996 				p_request_unique_key1  	=> 'LINE',
4997 				p_param1                 => p_x_line_rec.header_id,
4998 				p_param2                 => 'LINE',
4999 				p_request_type           => OE_GLOBALS.G_PRICE_LINE,
5000 				x_return_status          => l_return_status);
5001 			IF (p_x_line_rec.service_bill_option_code = 'FPOM') THEN
5002 				oe_delayed_requests_pvt.log_request(
5003 					p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
5004 					p_entity_id              => p_x_line_rec.line_id,
5005 					p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5006 					p_requesting_entity_id   => p_x_line_rec.line_id,
5007 					p_request_type           => OE_GLOBALS.G_SERVICE_FIRST_PERIOD_BILL,
5008 					p_request_unique_key1    => 'LINE',
5009 					p_param1                 => p_x_line_rec.line_id,
5010 					x_return_status          => l_return_status);
5011 			End If;
5012 		End If;
5013 		--sol_ord_er #16014165 end
5014 	-- Log the delayed request for Update Shipping if any of the attributes in
5015 	-- which Shipping is interested has been changed and the line has been
5016 	-- interfaced with Shipping.
5017 
5018 
5019      -- Bug 12355310 : Replacing check on SI flag by new API
5020      -- IF (p_x_line_rec.shipping_interfaced_flag = 'Y' AND
5021      IF((p_x_line_rec.shipping_interfaced_flag = 'Y' OR
5022         (p_x_line_rec.shippable_flag = 'Y' AND p_x_line_rec.booked_flag = 'Y'
5023          AND Shipping_Interfaced_Status(p_x_line_rec.line_id) = 'Y')) AND
5024         (l_update_shipping = FND_API.G_TRUE OR l_explosion_date_changed = FND_API.G_TRUE) AND
5025         (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT')) THEN
5026 
5027        if l_debug_level > 0 then
5028          oe_debug_pub.ADD('Logging update shipping delayed request for line ID :  '|| to_char(p_x_line_rec.line_id) ,1);
5029        end if;
5030 
5031        OE_Delayed_Requests_Pvt.Log_Request(
5032 		p_entity_code			=>	OE_GLOBALS.G_ENTITY_LINE,
5033 		p_entity_id			=>	p_x_line_rec.line_id,
5034 		p_requesting_entity_code	=>	OE_GLOBALS.G_ENTITY_LINE,
5035 		p_requesting_entity_id  	=>	p_x_line_rec.line_id,
5036 		p_request_type			=>	OE_GLOBALS.G_UPDATE_SHIPPING,
5037 		p_request_unique_key1		=>	p_x_line_rec.operation,
5038 		p_param1             		=>	l_update_shipping,
5039 		p_param2             		=>	l_explosion_date_changed,
5040 		p_param5             		=>	l_ordered_quantity_changed,
5041 		x_return_status			=>	l_return_status);
5042 
5043     END IF;
5044    /*Bug2848734 */
5045    IF NOT OE_GLOBALS.Equal(p_x_line_rec.return_context, p_old_line_rec.return_context) THEN
5046     IF (p_x_line_rec.line_category_code = 'RETURN' and
5047        p_x_line_rec.OPERATION = OE_GLOBALS.G_OPR_UPDATE and
5048        p_x_line_rec.return_context IS NULL ) THEN
5049 
5050        p_x_line_rec.reference_customer_trx_line_id := NULL;
5051        p_x_line_rec.credit_invoice_line_id := NULL;
5052        p_x_line_rec.reference_line_id := NULL;
5053        p_x_line_rec.reference_header_id := NULL;
5054     END IF;
5055   END IF;
5056   /*Bug2848734*/
5057 
5058 --ER#14763609 Start
5059    ------------------------------------------------------------------------
5060      -- Derive fulfillment_base
5061    ------------------------------------------------------------------------
5062 
5063       IF NOT OE_GLOBALS.Equal(p_x_line_rec.Inventory_Item_Id,
5064                               p_old_line_rec.Inventory_Item_Id)
5065          OR NOT OE_GLOBALS.Equal(p_x_line_rec.ship_from_org_id,
5066                                  p_old_line_rec.ship_from_org_id)
5067          OR NOT OE_GLOBALS.Equal(p_x_line_rec.order_quantity_uom,
5068                                  p_old_line_rec.order_quantity_uom)
5069          OR NOT OE_GLOBALS.Equal(p_x_line_rec.reference_line_id ,
5070                                  p_old_line_rec.reference_line_id)
5071          OR NOT OE_GLOBALS.Equal(p_x_line_rec.fulfillment_base ,   --added for bug#16547287
5072                                  p_old_line_rec.fulfillment_base)
5073         THEN
5074           IF l_debug_level > 0 THEN
5075               oe_debug_pub.add('Calling derive_fulfillment_base : ');
5076           END IF;
5077 
5078            l_fulfillment_base:= p_x_line_rec.fulfillment_base;
5079 
5080 	   p_x_line_rec.fulfillment_base := OE_DUAL_UOM_UTIL.derive_fulfillment_base (p_x_line_rec);
5081 
5082           IF l_debug_level > 0 THEN
5083               oe_debug_pub.add('After Calling derive_fulfillment_base :' || p_x_line_rec.fulfillment_base);
5084           END IF;
5085 
5086           IF Nvl( l_fulfillment_base ,'P') <> Nvl ( p_x_line_rec.fulfillment_base ,'P') THEN
5087 
5088              oe_dual_uom_util.validate_fulfillment_base(p_x_line_rec ) ;
5089 
5090           END IF ; --l_fulfillment_base <> p_x_line_rec.fulfillment_base
5091 
5092         END IF ; -- Deriving fulfillment_base
5093 
5094 --ER#14763609 End
5095 
5096 --16206165 CW start
5097        /**For Catch Weight Cases making the Calculate Price Flag as Y , so that re-pricing
5098           will happen during Shipping for both the lines**/
5099        IF p_x_line_rec.split_by = 'SYSTEM'
5100        THEN
5101 
5102            IF (p_x_line_rec.inventory_item_id IS NOT NULL AND
5103                p_x_line_rec.inventory_item_id <> FND_API.G_MISS_NUM) AND
5104               (p_x_line_rec.ship_from_org_id  IS NOT NULL AND
5105                p_x_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM) AND
5106               (p_x_line_rec.fulfillment_base  IS NOT NULL AND
5107                p_x_line_rec.fulfillment_base <> FND_API.G_MISS_CHAR) AND
5108               (p_x_line_rec.order_quantity_uom  IS NOT NULL AND
5109                p_x_line_rec.order_quantity_uom <> FND_API.G_MISS_CHAR)
5110            THEN
5111 
5112                    IF IS_CATCH_WEIGHT(p_x_line_rec) IS NOT NULL THEN
5113 
5114 	                IF l_debug_level  > 0 THEN
5115 	                  oe_debug_pub.ADD('Apply Attr Change Catch Weight Pricing');
5116 	                END IF;
5117 
5118 			p_x_line_rec.calculate_price_flag := 'Y';
5119 			OE_GLOBALS.G_PRICE_FLAG := 'Y';
5120 			OE_GLOBALS.G_TAX_FLAG := 'Y';
5121 
5122 	           END IF;
5123 
5124             END IF;
5125 
5126         END IF;
5127 --16206165 CW end
5128 
5129     If l_copy_adjustments and
5130 		not l_no_copy_adjustments THEN
5131 
5132                 -- commented out for bug 1917869
5133                 -- p_x_line_rec.calculate_price_flag in ('N','P') then
5134 
5135 	   If p_x_line_rec.split_from_line_id is not null and
5136 			p_x_line_rec.split_from_line_id <> fnd_api.g_miss_num then
5137 		l_from_line_id	:= p_x_line_rec.split_from_line_id ;
5138 		l_from_header_id := p_x_line_rec.header_id;
5139 	   elsif p_x_line_rec.reference_line_id is not null and
5140 			p_x_line_rec.reference_line_id <> fnd_api.g_miss_num then
5141 		l_from_line_id	:= p_x_line_rec.reference_line_id ;
5142 		l_from_header_id := p_x_line_rec.reference_Header_id;
5143 	   elsif p_x_line_rec.source_document_line_id is not null and
5144 			p_x_line_rec.source_document_line_id <> fnd_api.g_miss_num then
5145 		l_from_line_id	:= p_x_line_rec.source_document_line_id ;
5146 		l_from_header_id := p_x_line_rec.source_document_id;
5147 	   End If;
5148 
5149         OE_delayed_requests_Pvt.log_request(
5150 				p_entity_code 			=> OE_GLOBALS.G_ENTITY_LINE,
5151 				p_entity_id         	=> p_x_line_rec.line_id,
5152 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5153 				p_requesting_entity_id   => p_x_line_rec.line_id,
5154 		 		p_param1                 => p_x_line_rec.header_id,
5155                  	p_param2                 => l_from_line_id,
5156                  	p_param3                 => l_from_header_id,
5157 		 		p_param4                 => p_x_line_rec.line_category_code,
5158 		 		p_param5                 => p_x_line_rec.split_by,
5159 		 		p_param6                 => p_x_line_rec.booked_flag,
5160 		 		p_request_type           => OE_GLOBALS.G_COPY_ADJUSTMENTS,
5161 		 		x_return_status          => l_return_status);
5162 
5163        --bug 16317238 start
5164       copy_assoc(p_line_id => l_from_line_id,
5165                  px_org_pr_adjustment_id => l_orig_pr_adjustment_id,
5166                      px_or_rltd_padj_id  => l_or_rltd_padj_id,
5167                      px_prg_list_line_id => l_prg_list_line_id,
5168                      px_assoc_list_line_id  => l_assoc_list_line_id,
5169                      px_prg_exist    => l_prg_exist);
5170 
5171       IF l_prg_exist = 'Y' THEN
5172 
5173         OE_delayed_requests_Pvt.log_request(
5174 				p_entity_code 			=> OE_GLOBALS.G_ENTITY_LINE,
5175 				p_entity_id         	=> p_x_line_rec.line_id,
5176 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5177 				p_requesting_entity_id   => p_x_line_rec.line_id,
5178 		 		p_param1                 => p_x_line_rec.header_id,
5179         p_param2                 => l_from_line_id,
5180         p_param3                 => l_from_header_id,
5181 		 		p_param4                 => l_orig_pr_adjustment_id,
5182 		 		p_param5                 => l_or_rltd_padj_id,
5183 		 		p_param6                 => l_prg_list_line_id,
5184         p_param7                 => l_assoc_list_line_id,
5185 		 		p_request_type           => OE_GLOBALS.G_COPY_ASSOCIATION,
5186 		 		x_return_status          => l_return_status);
5187 
5188       END IF;
5189       --bug 16317238 end
5190 
5191 
5192     end if;
5193 
5194 
5195     --Bug#10052614 Start
5196     oe_debug_pub.ADD('OPERATION' ||p_x_line_rec.operation);
5197     oe_debug_pub.ADD('CALCULATE_PRICE_FLAG '||p_x_line_rec.CALCULATE_PRICE_FLAG);
5198     oe_debug_pub.ADD('LINE_CATEGORY_CODE '||p_x_line_rec.LINE_CATEGORY_CODE);
5199     oe_debug_pub.ADD('REFERENCE_LINE_ID '||p_x_line_rec.REFERENCE_LINE_ID);
5200     oe_debug_pub.ADD('RETURN_CONTEXT '||p_x_line_rec.RETURN_CONTEXT);
5201 
5202     IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND (p_x_line_rec.CALCULATE_PRICE_FLAG = 'N' OR
5203 												       (p_x_line_rec.CALCULATE_PRICE_FLAG = 'P' AND
5204 												       p_x_line_rec.LINE_CATEGORY_CODE = 'RETURN' AND
5205 												       p_x_line_rec.REFERENCE_LINE_ID IS NOT NULL AND
5206 												       p_x_line_rec.RETURN_CONTEXT IS NOT NULL))
5207     THEN
5208       oe_debug_pub.ADD('Logging DR_COPY_OTM_RECORDS relayed request fro Line '||p_x_line_rec.line_id||' From line '||l_from_line_id);
5209     	OE_delayed_requests_Pvt.log_request(
5210 		p_entity_code 		 => OE_GLOBALS.G_ENTITY_LINE,
5211 		p_entity_id         	 => p_x_line_rec.line_id,
5212 		p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5213 		p_requesting_entity_id   => p_x_line_rec.line_id,
5214 		p_param1                 => p_x_line_rec.header_id,
5215 		p_param2                 => l_from_line_id,
5216 		p_param3                 => l_from_header_id,
5217 		p_request_type           => OE_GLOBALS.G_DR_COPY_OTM_RECORDS,
5218 		x_return_status          => l_return_status
5219 	  );
5220     END IF;
5221     --Bug#10052614 End
5222 
5223 /* csheu -- bug #1533658 S */
5224     IF l_copy_service_fields and
5225 	  p_x_line_rec.item_type_code = 'SERVICE' and
5226 	  p_x_line_rec.service_reference_type_code  = 'ORDER' and
5227        p_x_line_rec.service_reference_line_id is NOT NULL and
5228 	  p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
5229 	  BEGIN
5230 
5231             Select 'Y'
5232             INTO   l_is_model
5233             FROM   oe_order_lines
5234             WHERE  line_id = p_x_line_rec.service_reference_line_id
5235             AND    item_type_code in ('INCLUDED', 'MODEL', 'CLASS', 'OPTION') ;
5236 
5237        EXCEPTION
5238         WHEN OTHERS THEN
5239           l_is_model := 'N';
5240        END;
5241 
5242        IF l_is_model = 'Y' THEN
5243         if l_debug_level > 0 then
5244          oe_debug_pub.add('CSH Before log request --G_UPDATE_SERVICE', 1);
5245         end if;
5246          OE_Delayed_Requests_Pvt.log_request(
5247                          p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5248                          p_entity_id   => p_x_line_rec.line_id,
5249                          p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5250                          p_requesting_entity_id   => p_x_line_rec.line_id,
5251                          p_request_type   => OE_GLOBALS.G_UPDATE_SERVICE,
5252                          x_return_status  => l_return_status);
5253        END IF;
5254     END IF; /* IF l_copy_service_fields... = TRUE */
5255 
5256    if l_debug_level > 0 then
5257     oe_debug_pub.add('CSH --OUT of l_copy_service_field condition ', 1);
5258    end if;
5259 /* csheu -- bug #1533658 E */
5260     -- added by lkxu
5261     IF l_copy_pricing_attributes THEN
5262 	   IF p_x_line_rec.split_from_line_id is not null and
5263 		p_x_line_rec.split_from_line_id <> fnd_api.g_miss_num THEN
5264 		  l_from_line_id	:= p_x_line_rec.split_from_line_id ;
5265 		  l_from_header_id := p_x_line_rec.header_id;
5266 	   ELSIF p_x_line_rec.reference_line_id is not null and
5267 		p_x_line_rec.reference_line_id <> fnd_api.g_miss_num THEN
5268 		  l_from_line_id	:= p_x_line_rec.reference_line_id ;
5269 		  l_from_header_id := p_x_line_rec.reference_Header_id;
5270 	   ELSIF p_x_line_rec.source_document_line_id is not null and
5271 		p_x_line_rec.source_document_line_id <> fnd_api.g_miss_num THEN
5272 		  l_from_line_id	:= p_x_line_rec.source_document_line_id ;
5273 		  l_from_header_id := p_x_line_rec.source_document_id;
5274 	   End IF;
5275 
5276         OE_delayed_requests_Pvt.log_request(
5277 				p_entity_code 			=> OE_GLOBALS.G_ENTITY_LINE,
5278 				p_entity_id         	=> p_x_line_rec.line_id,
5279 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5280 				p_requesting_entity_id   => p_x_line_rec.line_id,
5281 		 		p_param1                 => p_x_line_rec.header_id,
5282                  	p_param2                 => l_from_line_id,
5283                  	p_param3                 => l_from_header_id,
5284 		 		p_request_type           => OE_GLOBALS.G_COPY_PRICING_ATTRIBUTES,
5285 		 		x_return_status          => l_return_status);
5286 
5287     END IF;
5288 
5289     -----------------------------------------------------------
5290     --Set included item to 0 since it is should not be priced
5291     --No pricing should be called bug 1620213
5292     -----------------------------------------------------------
5293     If p_x_line_rec.item_type_code In ('INCLUDED','CONFIG') Then
5294          P_x_line_rec.unit_selling_price := 0;
5295          p_x_line_rec.unit_list_price := 0;
5296          P_x_line_rec.unit_selling_price_per_pqty := 0;
5297          p_x_line_rec.unit_list_price_per_pqty := 0;
5298 
5299 /* Added the following two lines to fix the bug 2175029 */
5300          p_x_line_rec.pricing_quantity := p_x_line_rec.ordered_quantity;
5301          p_x_line_rec.pricing_quantity_uom := p_x_line_rec.order_quantity_uom;
5302 
5303 
5304          If p_x_line_rec.item_type_code = 'INCLUDED' and
5305             l_charges_for_included_item = 'Y' Then
5306            oe_globals.g_price_flag := 'Y';
5307          --Elsif p_x_line_rec.item_type_code = 'CONFIG' THEN
5308          --  oe_globals.g_price_flag := 'Y';
5309          Else
5310           if l_debug_level > 0 then
5311            oe_debug_pub.add('2207809: no price for config item', 3);
5312           end if;
5313            oe_globals.g_price_flag := 'N';
5314          End If;
5315     End If;
5316 
5317     -------------------------------------------------------------------
5318     --In the future all pricing related operations will be handled
5319     --by process_pricing.  The purpose of this is to reduce file locking
5320     --issue on OEXULINB.pls
5321     -------------------------------------------------------------------
5322     OE_LINE_ADJ_UTIL.Process_Pricing(p_x_new_line_rec => p_x_line_rec,
5323                                      p_old_line_rec   => p_old_line_rec,
5324                                      p_no_price_flag  => l_no_price_flag);
5325 
5326   if l_debug_level > 0 then
5327    oe_debug_pub.add('unit_list_price:'||p_x_line_rec.unit_list_price);
5328    oe_debug_pub.add('old unit_list_price:'||p_old_line_rec.unit_list_price);
5329    oe_debug_pub.add('original_list_price:'||p_x_line_rec.original_list_price);
5330   end if;
5331 -- Override List Price
5332     IF  ((p_x_line_rec.unit_list_price IS NOT NULL AND
5333          p_x_line_rec.unit_list_price <> FND_API.G_MISS_NUM AND
5334 --       p_x_line_rec.unit_list_price <> p_x_line_rec.original_list_price AND
5335          p_x_line_rec.unit_list_price <> p_old_line_rec.unit_list_price)
5336        OR
5337          (p_x_line_rec.unit_list_price IS NULL))
5338        AND
5339          p_old_line_rec.unit_list_price IS NOT NULL AND
5340          p_old_line_rec.unit_list_price <> FND_API.G_MISS_NUM AND
5341          p_x_line_rec.original_list_price  IS NOT NULL AND
5342          p_x_line_rec.original_list_price <> FND_API.G_MISS_NUM AND
5343          p_x_line_rec.Ordered_Quantity <> fnd_api.g_miss_num and
5344          p_x_line_rec.order_quantity_uom is not null and
5345          p_x_line_rec.order_quantity_uom <> fnd_api.g_miss_char
5346          AND oe_code_control.code_release_level >= '110510'
5347          -- bug 3491752
5348          --AND /*nvl(fnd_profile.value('ONT_LIST_PRICE_OVERRIDE_PRIV'), 'NONE')*/          --G_LIST_PRICE_OVERRIDE  = 'UNLIMITED' --bug4080363
5349          -- AND  OE_GLOBALS.G_UI_FLAG bug# 13011328 - Commenting out this line since ULP, USP is not updatable from PO API
5350          AND  OE_Globals.G_PRICING_RECURSION = 'N' THEN
5351 
5352             IF p_x_line_rec.unit_list_price IS NOT NULL AND
5353                p_x_line_rec.unit_list_price <> FND_API.G_MISS_NUM AND
5354                p_x_line_rec.original_list_price  IS NOT NULL AND
5355                p_x_line_rec.original_list_price <> FND_API.G_MISS_NUM THEN
5356        --      p_x_line_rec.unit_list_price <> p_x_line_rec.original_list_price THEN
5357 
5358                    -- setting unit_list_price_per_pqty appropriately
5359                    p_x_line_rec.unit_list_price_per_pqty := (p_x_line_rec.ordered_quantity*p_x_line_rec.unit_list_price)/p_x_line_rec.pricing_quantity;
5360                  if l_debug_level > 0 then
5361                    oe_debug_pub.add('setting unit_list_price_per_pqty to:'||p_x_line_rec.unit_list_price_per_pqty);
5362                  end if;
5363             END IF;
5364 
5365             IF p_old_line_rec.unit_list_price IS NOT NULL AND
5366                p_x_line_rec.unit_list_price IS NULL AND
5367                p_x_line_rec.original_list_price IS NOT NULL THEN
5368 
5369                    -- setting unit_list_price_per_pqt, original_list_price to null
5370                  if l_debug_level > 0 then
5371                    oe_debug_pub.add('setting original_list_price, unit_list_price_per_pqty to null');
5372                  end if;
5373                    p_x_line_rec.original_list_price := NULL;
5374                    p_x_line_rec.unit_list_price_per_pqty := NULL;
5375 
5376             END IF;
5377            if l_debug_level > 0 then
5378             oe_debug_pub.add('setting call_pricing for list price override');
5379            end if;
5380             L_Call_pricing := 'Y';
5381     End If;
5382 -- Override List Price
5383     IF 	oe_globals.g_price_flag = 'Y' and
5384 		not l_no_price_flag  and
5385 		nvl(oe_globals.g_pricing_recursion,'N') <> 'Y'  and
5386 	  	--bsadri nvl(p_x_line_rec.ordered_quantity,0) <> 0 and
5387                 --For bug 7115648
5388                 p_x_line_rec.inventory_item_id  is not null and
5389 	  	--End of 7115648
5390 		p_x_line_rec.Ordered_Quantity <> fnd_api.g_miss_num and
5391 		p_x_line_rec.order_quantity_uom is not null and
5392 		p_x_line_rec.order_quantity_uom <> fnd_api.g_miss_char
5393        or  l_call_pricing = 'Y' --Override List Price
5394 	THEN
5395                 --bsadri for cancelled lines l_zero_line_qty is true
5396 
5397                 IF nvl(p_x_line_rec.ordered_quantity,0) = 0 THEN
5398                     l_zero_line_qty := TRUE;
5399                     /* BUG 2013611 BEGIN */
5400                   if l_debug_level > 0 then
5401 	            oe_debug_pub.ADD('Logging REVERSE_LIMITS delayed request for LINE CANCEL ',1);
5402                   end if;
5403                     OE_delayed_requests_Pvt.log_request(
5404 				p_entity_code 		 => OE_GLOBALS.G_ENTITY_LINE,
5405 				p_entity_id              => p_x_line_rec.line_id,
5406 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5407 				p_requesting_entity_id   => p_x_line_rec.line_id,
5408 				p_request_unique_key1  	 => 'LINE',
5409 		 		p_param1                 => 'CANCEL',
5410 		 		p_param2                 => p_x_line_rec.price_request_code,
5411 		 		p_param3                 => NULL,
5412 		 		p_param4                 => NULL,
5413 		 		p_param5                 => NULL,
5414 		 		p_param6                 => NULL,
5415 		 		p_request_type           => OE_GLOBALS.G_REVERSE_LIMITS,
5416 		 		x_return_status          => l_return_status);
5417                   if l_debug_level > 0 then
5418 	            oe_debug_pub.ADD('REVERSE_LIMITS Delayed request has been logged',1);
5419                   end if;
5420                     /* BUG 2013611 END */
5421                 ELSE
5422                     l_zero_line_qty := FALSE;
5423                 END IF;
5424 		If
5425 		( (p_x_line_rec.unit_list_price is null or
5426 		  p_x_line_rec.Unit_List_Price = fnd_api.g_miss_num or
5427 		  NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,p_old_line_rec.ordered_quantity) or
5428 		  NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity2,p_old_line_rec.ordered_quantity2) or -- INVCONV 2317146 - INVCONV STET
5429 		  NOT OE_GLOBALS.Equal(p_x_line_rec.cancelled_Quantity,p_old_line_rec.cancelled_Quantity) or
5430 		   NOT OE_GLOBALS.Equal(p_x_line_rec.order_quantity_uom,p_old_line_rec.order_quantity_uom) or
5431 		   NOT OE_GLOBALS.Equal(p_x_line_rec.inventory_item_id,p_old_line_rec.inventory_item_id) or   --fix bug 1388503 btea
5432                    NOT OE_GLOBALS.Equal(p_x_line_rec.unit_list_price,p_old_line_rec.unit_list_price)  )
5433                   and p_x_line_rec.item_type_code <> OE_GLOBALS.G_ITEM_SERVICE
5434 		   )
5435            --RT{
5436                and nvl(p_x_line_rec.retrobill_request_id,FND_API.G_MISS_NUM)= FND_API.G_MISS_NUM
5437            --RT}
5438                or l_call_pricing = 'Y' -- Override List Price
5439 	   then
5440 
5441 
5442                IF ((OE_GLOBALS.G_UI_FLAG)
5443                 and OE_GLOBALS.G_DEFER_PRICING='N'
5444                 and (nvl(Oe_Config_Pvt.oecfg_configuration_pricing,'N')='N'))
5445                THEN
5446 
5447           	l_Price_Control_Rec.pricing_event := 'PRICE';
5448 			l_Price_Control_Rec.calculate_flag := QP_PREQ_GRP.G_SEARCH_N_CALCULATE;
5449 			l_Price_Control_Rec.Simulation_Flag := 'N';
5450 
5451 			l_x_line_tbl(1) := p_x_line_rec;
5452                         IF NOT l_zero_line_qty THEN
5453                          --bsadri call the Price_line for non-cancelled lines
5454                          if l_debug_level > 0 then
5455                           oe_debug_pub.add('list price before call to price_line:'||p_x_line_rec.unit_list_price);
5456                           oe_debug_pub.add('list price per pqty  before call to price_line:'||p_x_line_rec.unit_list_price_per_pqty);
5457                          end if;
5458 			  oe_order_adj_pvt.Price_line(
5459 				X_Return_Status     => l_Return_Status
5460 				,p_Line_id          => p_x_line_rec.line_id
5461 				,p_Request_Type_code=> 'ONT'
5462 				,p_Control_rec      => l_Price_Control_Rec
5463 				,p_Write_To_Db		=> FALSE
5464 				,x_Line_Tbl		=> l_x_Line_Tbl
5465 				);
5466 
5467 			   -- Populate Line_rec
5468 			   -- Fix for Bug 3374889. Commented the while loop and
5469                            -- and assigned l_x_Line_Tbl(1) to line_rec.
5470                            p_x_line_rec := l_x_Line_Tbl(1);
5471                            /*
5472                             i:= l_x_Line_Tbl.First;
5473 			    While i is not null loop
5474 				  p_x_line_rec := l_x_Line_Tbl(i);
5475 				  i:= l_x_Line_Tbl.Next(i);
5476 			    End Loop;
5477                            */
5478                         if l_debug_level > 0 then
5479                           oe_debug_pub.add('list price after call to price_line:'||p_x_line_rec.unit_list_price);
5480                           oe_debug_pub.add('list price per pqty  after call to price_line:'||p_x_line_rec.unit_list_price_per_pqty);
5481                         end if;
5482                   -- Bug 2757443.
5483                   -- Need to log delayed request for tax and commitment
5484                   -- when unit_selling_price changes from null to not null
5485                   -- during PRICE event.
5486                   IF NOT OE_GLOBALS.Equal(p_old_line_rec.unit_selling_price,
5487                          l_x_Line_Tbl(1).unit_selling_price) THEN
5488 
5489                      OE_GLOBALS.G_TAX_FLAG := 'Y';
5490                      IF l_x_Line_Tbl(1).commitment_id IS NOT NULL THEN
5491                        l_calculate_commitment_flag := 'Y';
5492                      END IF;
5493                   END IF;
5494 
5495                 if l_debug_level > 0 then
5496                   oe_debug_pub.add('outside margin code',1);
5497                 end if;
5498                             --MRG BGN
5499                           If OE_FEATURES_PVT.Is_Margin_Avail Then
5500                  if l_debug_level > 0 then
5501                   oe_debug_pub.add('inside margin code',1);
5502                  end if;
5503                             p_x_line_rec.unit_cost:=OE_MARGIN_PVT.GET_COST(p_x_line_rec);
5504                           End If;
5505                             --MRG END
5506 
5507                           END IF;
5508 	   End If;
5509         End If;  --end if for UI Flag Check
5510          if l_debug_level > 0 then
5511 	   oe_debug_pub.ADD('Logging delayed request for pricing');
5512          end if;
5513         IF ((OE_GLOBALS.G_UI_FLAG)
5514           and OE_GLOBALS.G_DEFER_PRICING='N'
5515           and (nvl(Oe_Config_Pvt.oecfg_configuration_pricing,'N')='N'))
5516           OR (p_x_line_rec.item_type_code = 'INCLUDED' and OE_GLOBALS.G_DEFER_PRICING='N')
5517           --RT
5518           and nvl(p_x_line_rec.retrobill_request_id,FND_API.G_MISS_NUM)=FND_API.G_MISS_NUM THEN
5519          if l_debug_level > 0 then
5520           oe_debug_pub.add('ui mode or config, included item'||p_x_line_rec.line_id);
5521          end if;
5522          IF NOT l_zero_line_qty THEN
5523              --bsadri don't call this for a cancelled line
5524 
5525            IF nvl(p_x_line_rec.item_type_code,'x') <> 'INCLUDED' THEN
5526              --bug 2855794
5527      if l_debug_level > 0 then
5528       oe_debug_pub.ADD('Calc price flag:'||p_x_line_rec.calculate_price_flag);
5529      end if;
5530              if (p_x_line_rec.calculate_price_flag <> 'N' OR
5531                  l_item_rec.ont_pricing_qty_source = 'S' ) THEN -- INVCONV
5532                 if l_debug_level > 0 then
5533                  oe_debug_pub.ADD('logging price line request');
5534                 end if;
5535 
5536                 OE_delayed_requests_Pvt.log_request(
5537 		p_entity_code 			=> OE_GLOBALS.G_ENTITY_LINE,
5538 		p_entity_id         	=> p_x_line_rec.line_id,
5539 		p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5540 		p_requesting_entity_id   => p_x_line_rec.line_id,
5541 		p_request_unique_key1  	=> 'LINE',
5542 		p_param1                 => p_x_line_rec.header_id,
5543                	p_param2                 => 'LINE',
5544 		p_request_type           => OE_GLOBALS.G_PRICE_LINE,
5545 		x_return_status          => l_return_status);
5546 		-- sol_ord_er #16014165
5547 		IF (p_x_line_rec.service_bill_option_code = 'FPOM'
5548 		    AND NVL(p_x_line_rec.fulfilled_flag,'N') = 'N') THEN
5549 		 oe_delayed_requests_pvt.log_request(
5550 							 p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
5551 							 p_entity_id              => p_x_line_rec.line_id,
5552 							 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5553 							 p_requesting_entity_id   => p_x_line_rec.line_id,
5554 							 p_request_type           => OE_GLOBALS.G_SERVICE_FIRST_PERIOD_BILL,
5555 							 p_request_unique_key1    => 'LINE',
5556 							 p_param1                 => p_x_line_rec.line_id,
5557 							 x_return_status          => l_return_status);
5558 		END IF;
5559 		-- sol_ord_er #16014165 end
5560              end if; --bug 2855794
5561 
5562            ELSE
5563 
5564              IF OE_LINE_ADJ_UTIL.Is_Pricing_Related_Change(p_x_line_rec,p_old_line_rec)
5565 	     OR NOT OE_GLOBALS.Equal(p_x_line_rec.shipping_method_code,p_old_line_rec.shipping_method_code) THEN
5566                if l_debug_level > 0 then
5567                 oe_debug_pub.add('renga-logging delayed req freight_for_included',1);
5568                end if;
5569 
5570                OE_delayed_requests_Pvt.log_request(
5571 				p_entity_code 	=> OE_GLOBALS.G_ENTITY_ALL,
5572 				p_entity_id     => p_x_line_rec.header_id,
5573 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5574 				p_requesting_entity_id   => p_x_line_rec.header_id,
5575 				p_request_unique_key1  	=> 'ORDER',
5576 		 		p_param1                 => p_x_line_rec.header_id,
5577                  		p_param2                 => 'ORDER',
5578 		 		p_request_type           => OE_GLOBALS.G_FREIGHT_FOR_INCLUDED,
5579 		 		x_return_status          => l_return_status);
5580 
5581                if l_debug_level > 0 then
5582                 oe_debug_pub.add('renga-after logging delayed req freight_for_included',1);
5583                end if;
5584              END IF;
5585 
5586            END IF;  -- if item type code is not included
5587 
5588          END IF;  -- if not l_zero_line_qty
5589           IF p_x_line_rec.item_type_code <> 'INCLUDED' THEN
5590              IF p_x_line_rec.booked_flag='Y' THEN  --2442012
5591                  l_pricing_event := 'BATCH,ORDER,BOOK';  --7494393
5592              ELSE
5593                  l_pricing_event := 'ORDER';
5594              END IF;
5595            OE_delayed_requests_Pvt.log_request(
5596 				p_entity_code 			=> OE_GLOBALS.G_ENTITY_ALL,
5597 				p_entity_id         	=> p_x_line_rec.Header_Id,
5598 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5599 				p_requesting_entity_id   => p_x_line_rec.Header_Id,
5600 				p_request_unique_key1  	=> l_pricing_event,
5601 		 		p_param1                 => p_x_line_rec.header_id,
5602                  		p_param2                 => l_pricing_event,
5603 		 		p_request_type           => OE_GLOBALS.G_PRICE_ORDER,
5604 		 		x_return_status          => l_return_status);
5605 			-- sol_ord_er #16014165
5606 			IF (p_x_line_rec.service_bill_option_code = 'FPOM') THEN
5607 			 oe_delayed_requests_pvt.log_request(
5608 								 p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
5609 								 p_entity_id              => p_x_line_rec.Header_Id,
5610 								 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5611 								 p_requesting_entity_id   => p_x_line_rec.Header_Id,
5612 								 p_request_type           => OE_GLOBALS.G_SERVICE_FIRST_PERIOD_BILL,
5613 								 p_request_unique_key1    => 'ORDER',
5614 								 p_param1                 => p_x_line_rec.Header_Id,
5615 								 x_return_status          => l_return_status);
5616 			END IF;
5617 			-- sol_ord_er #16014165 end
5618           END IF;  -- item_type_code not included
5619         ELSE
5620          if l_debug_level > 0 then
5621           oe_debug_pub.add('batch mode or defer pricing');
5622          end if;
5623          --RT{
5624           IF nvl(p_x_line_rec.retrobill_request_id,FND_API.G_MISS_NUM)<>FND_API.G_MISS_NUM Then
5625               --call pricing for retrobilling lines in one shot (PRICE_ORDER)
5626              IF p_x_line_rec.operation=OE_GLOBALS.G_OPR_CREATE THEN
5627                l_retrobill_operation:='CREATE';
5628              ELSE
5629                l_retrobill_operation:='UPDATE';
5630              END IF;
5631 
5632 
5633               OE_delayed_requests_Pvt.log_request(
5634 				p_entity_code 			=> OE_GLOBALS.G_ENTITY_ALL,
5635 				p_entity_id         	=> p_x_line_rec.Header_Id,
5636 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5637 				p_requesting_entity_id   => p_x_line_rec.Header_Id,
5638 				p_request_unique_key1  	=> 'RETROBILL',
5639 		 		p_param1                 => p_x_line_rec.header_id,
5640                  		p_param2                 => 'RETROBILL',
5641                                 p_param3                 => l_retrobill_operation,
5642 		 		p_request_type           => OE_GLOBALS.G_PRICE_ORDER,
5643 		 		x_return_status          => l_return_status);
5644 
5645               --copy the adjustments over to the new retrobilling line
5646               OE_delayed_requests_Pvt.log_request(
5647 				p_entity_code 		=> OE_GLOBALS.G_ENTITY_LINE,
5648 				p_entity_id         	 => p_x_line_rec.line_id,
5649 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5650 				p_requesting_entity_id   => p_x_line_rec.line_id,
5651 		 		p_param1                 => p_x_line_rec.header_id,
5652                                 --x_line_rec.orig_sys_line_ref stores orignial line_id
5653                                 --p_param2 is copy_line_line_id
5654                  	        p_param2                 => p_x_line_rec.orig_sys_line_ref,
5655                                 --orig_sys_document_ref stores original header_id
5656                                 --p_param3 is copy_from_header_id
5657                  	        p_param3                 => p_x_line_rec.orig_sys_document_ref,
5658 		 		p_param4                 => p_x_line_rec.line_category_code,
5659 		 		p_param5                 => p_x_line_rec.split_by,
5660 		 		p_param6                 => p_x_line_rec.booked_flag,
5661 		 		p_request_type           => OE_GLOBALS.G_COPY_ADJUSTMENTS,
5662                                 p_param7                   => 'RETROBILL',
5663                                 p_param8   => p_x_line_rec.retrobill_request_id,
5664 		 		x_return_status          => l_return_status);
5665           --RT}
5666           Else
5667            IF p_x_line_rec.booked_flag='Y' and p_x_line_rec.item_type_code <> 'INCLUDED' Then
5668                   l_pricing_event := 'BATCH,BOOK';
5669            ELSE
5670                   l_pricing_event := 'BATCH';
5671            END IF;
5672 
5673            IF OE_GLOBALS.G_DEFER_PRICING='Y' AND
5674               p_x_line_rec.booked_flag='Y'AND
5675               p_x_line_rec.item_type_code <>'INCLUDED' THEN  --2442012
5676                 l_pricing_event := 'PRICE,BATCH,BOOK';
5677            ELSIF OE_GLOBALS.G_DEFER_PRICING='Y' THEN
5678                 l_pricing_event := 'PRICE,BATCH';
5679            END IF;
5680 
5681            OE_delayed_requests_Pvt.log_request(
5682 				p_entity_code 			=> OE_GLOBALS.G_ENTITY_ALL,
5683 				p_entity_id         	=> p_x_line_rec.Header_Id,
5684 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5685 				p_requesting_entity_id   => p_x_line_rec.Header_Id,
5686 				p_request_unique_key1  	=> l_pricing_event,
5687 		 		p_param1                 => p_x_line_rec.header_id,
5688                  		p_param2                 => l_pricing_event,
5689 		 		p_request_type           => OE_GLOBALS.G_PRICE_ORDER,
5690 		 		x_return_status          => l_return_status);
5691 			-- sol_ord_er #16014165
5692 			IF (p_x_line_rec.service_bill_option_code = 'FPOM') THEN
5693 			 oe_delayed_requests_pvt.log_request(
5694 								 p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
5695 								 p_entity_id              => p_x_line_rec.Header_Id,
5696 								 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5697 								 p_requesting_entity_id   => p_x_line_rec.Header_Id,
5698 								 p_request_type           => OE_GLOBALS.G_SERVICE_FIRST_PERIOD_BILL,
5699 								 p_request_unique_key1    => 'ORDER',
5700 								 p_param1                 => p_x_line_rec.Header_Id,
5701 								 x_return_status          => l_return_status);
5702 			END IF;
5703 			-- sol_ord_er #16014165 end
5704           END IF;   --RT
5705         END IF;     --2442012
5706 
5707   /*         If p_x_line_rec.booked_flag='Y' and p_x_line_rec.item_type_code <> 'INCLUDED' Then
5708            OE_delayed_requests_Pvt.log_request(
5709 				p_entity_code 			=> OE_GLOBALS.G_ENTITY_ALL,
5710 				p_entity_id         	=> p_x_line_rec.Header_Id,
5711 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5712 				p_requesting_entity_id   => p_x_line_rec.Header_Id,
5713 				p_request_unique_key1  	=> 'BOOK',
5714 		 		p_param1                 => p_x_line_rec.header_id,
5715                  		p_param2                 => 'BOOK',
5716 		 		p_request_type           => OE_GLOBALS.G_PRICE_ORDER,
5717 		 		x_return_status          => l_return_status);
5718 	   End If;
5719   */
5720       --  fixed bug 1688064, move the following line out of IF block.
5721 	 --  Oe_Globals.g_price_flag := 'N';
5722      END IF;
5723 
5724 	/* rlanka: Fix for Bug 1729372
5725 
5726             For the new line that is created by Promotional modifier
5727             need to log a delayed request to PRICE_LINE again to apply
5728 	    freight charges.
5729 
5730          */
5731 
5732       if l_debug_level > 0 then
5733         oe_debug_pub.add('g_price_flag = ' || oe_globals.g_price_flag);
5734         --oe_debug_pub.add('l_no_price_flag = '|| l_no_price_flag);
5735         oe_debug_pub.add('g_pricing_recursion = ' || oe_globals.g_pricing_recursion);
5736         oe_debug_pub.add('Ordered quantity = '|| to_char(p_x_line_rec.ordered_quantity));
5737         oe_debug_pub.add('Ordered qty UOM = ' || p_x_line_rec.order_quantity_uom);
5738         oe_debug_pub.add('Calculate_price_flag = '|| p_x_line_rec.calculate_price_flag);
5739       end if;
5740 
5741 	 if (oe_globals.g_price_flag = 'Y' and
5742             not l_no_price_flag and
5743             oe_globals.g_pricing_recursion = 'Y' and
5744             nvl(p_x_line_rec.ordered_quantity,0) <> 0 and
5745             p_x_line_rec.Ordered_Quantity <> fnd_api.g_miss_num and
5746             p_x_line_rec.order_quantity_uom is not null and
5747             p_x_line_rec.order_quantity_uom <> fnd_api.g_miss_char and
5748             p_x_line_rec.calculate_price_flag = 'R')
5749            --RT{
5750             and nvl(p_x_line_rec.retrobill_request_id,FND_API.G_MISS_NUM)=FND_API.G_MISS_NUM
5751            --RT}
5752         then
5753 
5754           if l_debug_level > 0 then
5755            oe_debug_pub.add('New line created by Promotional Modifier');
5756 
5757             oe_debug_pub.add('Resetting calc. price. flag to P');
5758           end if;
5759             p_x_line_rec.calculate_price_flag := 'P';
5760            if l_debug_level > 0 then
5761             oe_debug_pub.add('Logging a request to PRICE_LINE in batch mode');
5762            end if;
5763             if (p_x_line_rec.booked_flag = 'Y')  --2442012
5764             then
5765               if l_debug_level > 0 then
5766                oe_debug_pub.add('Booked order -- log a request to Price Line');
5767               end if;
5768                l_pricing_event := 'BATCH,BOOK';
5769             Else
5770                l_pricing_event := 'BATCH';
5771             End If;
5772             OE_delayed_requests_Pvt.log_request(
5773 				p_entity_code           =>OE_GLOBALS.G_ENTITY_ALL,
5774                                 p_entity_id             => p_x_line_rec.line_Id,
5775                                 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5776                                 p_requesting_entity_id   => p_x_line_rec.line_Id,
5777                                 p_request_unique_key1   => l_pricing_event,
5778                                 p_param1                 => p_x_line_rec.header_id,
5779                                 p_param2                 => l_pricing_event,
5780                                 p_request_type           => OE_GLOBALS.G_PRICE_LINE,
5781                                 x_return_status          => l_return_status);
5782 			-- sol_ord_er #16014165
5783 		/* The current Line is PRG line, hence Order has to be logged and check for FPOM should not be used */
5784 		 oe_delayed_requests_pvt.log_request(
5785 							 p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
5786 							 p_entity_id              => p_x_line_rec.line_Id,
5787 							 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5788 							 p_requesting_entity_id   => p_x_line_rec.line_Id,
5789 							 p_request_type           => OE_GLOBALS.G_SERVICE_FIRST_PERIOD_BILL,
5790 							 p_request_unique_key1    => 'ORDER',
5791 							 p_param1                 => p_x_line_rec.header_id,
5792 							 x_return_status          => l_return_status);
5793 		-- sol_ord_er #16014165 end
5794 
5795   /*        if (p_x_line_rec.booked_flag = 'Y')
5796           then
5797              oe_debug_pub.add('Booked order -- log a request to Price Line');
5798              OE_delayed_requests_Pvt.log_request(
5799                                 p_entity_code           =>OE_GLOBALS.G_ENTITY_ALL,
5800                                 p_entity_id             => p_x_line_rec.line_Id,
5801                                 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5802                                 p_requesting_entity_id   => p_x_line_rec.line_Id,
5803                                 p_request_unique_key1   => 'BOOK',
5804                                 p_param1                 => p_x_line_rec.header_id,
5805                                 p_param2                 => 'BOOK',
5806                                 p_request_type           => OE_GLOBALS.G_PRICE_LINE,
5807                                 x_return_status          => l_return_status);
5808           end if; -- if order is BOOKED
5809    */    --2442012
5810         end if; -- if new line created by Promotional modifier needs to be re-priced.
5811 
5812         -- end of fix for bug 1729372
5813 
5814      Oe_Globals.g_price_flag := 'N';
5815 
5816 	If NOT OE_GLOBALS.Equal(p_x_line_rec.Shipped_Quantity,p_old_line_rec.Shipped_Quantity)
5817            --RT{
5818              and nvl(p_x_line_rec.retrobill_request_id,FND_API.G_MISS_NUM)=FND_API.G_MISS_NUM
5819            --RT}
5820 	Then
5821            --btea
5822            IF p_x_line_rec.line_category_code <> 'RETURN' Then
5823               OE_Shipping_Integration_PVT.Check_Shipment_Line(
5824                  p_line_rec                => p_old_line_rec
5825               ,  p_shipped_quantity        => p_x_line_rec.Shipped_Quantity
5826               ,  x_result_out              => l_x_result_out
5827               );
5828 
5829               IF l_x_result_out = OE_GLOBALS.G_PARTIALLY_SHIPPED THEN
5830                -- This line will split, set the calculate_price_flag  to 'P' if 'Y'
5831                 IF (p_x_line_rec.calculate_price_flag = 'Y') THEN
5832                   p_x_line_rec.calculate_price_flag := 'P';
5833                 END IF;
5834 
5835 
5836               END IF;
5837 
5838            Elsif p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
5839                  and p_x_line_rec.split_by = 'SYSTEM'
5840                  and NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT'
5841                  and p_x_line_rec.calculate_price_flag = 'Y' Then
5842                    p_x_line_rec.calculate_price_flag :='P';
5843            End If;
5844 
5845            OE_delayed_requests_Pvt.log_request(
5846 				p_entity_code 		=> OE_GLOBALS.G_ENTITY_ALL,
5847 				p_entity_id         	=> p_x_line_rec.line_id,
5848 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5849 				p_requesting_entity_id   => p_x_line_rec.line_id,
5850 				p_request_unique_key1  	=> 'SHIP',
5851 		 		p_param1                 => p_x_line_rec.header_id,
5852                  		p_param2                 => 'SHIP',
5853 		 		p_request_type           => OE_GLOBALS.G_PRICE_LINE,
5854 		 		x_return_status          => l_return_status);
5855 	End If;
5856 
5857         -- change for bug 1406890
5858         -- Renga making changes for tax calculation event enhancement
5859         IF nvl(p_x_line_rec.booked_flag, 'N') = 'Y' THEN
5860             l_current_event := 1;  /* current event is booking or higher */
5861         END IF;
5862 
5863         IF (p_x_line_rec.shippable_flag = 'Y' and
5864             p_x_line_rec.shipped_quantity is not null ) THEN
5865            l_current_event := 2; /* current event is shipping or higher */
5866         END IF;
5867 
5868         BEGIN
5869 
5870          IF OE_Order_Cache.g_header_rec.order_type_id is not null THEN
5871 
5872               --use cache instead of SQL to fix bug 4200055
5873               if (OE_Order_Cache.g_order_type_rec.order_type_id = FND_API.G_MISS_NUM)
5874 		  OR (OE_Order_Cache.g_order_type_rec.order_type_id is null)
5875                   OR (OE_Order_Cache.g_order_type_rec.order_type_id <>
5876 OE_Order_Cache.g_header_rec.Order_Type_id) THEN
5877        	  		 OE_Order_Cache.Load_Order_type(OE_Order_CACHE.g_header_rec.Order_Type_id)
5878 ;
5879 	       END IF ;
5880 	       IF (OE_Order_Cache.g_order_type_rec.order_type_id =
5881 OE_Order_Cache.g_header_rec.Order_Type_id) THEN
5882 	  	        if (OE_Order_Cache.g_order_type_rec.tax_calculation_event_code =
5883 'ENTERING') then
5884 				l_tax_calculation_event_code := 0;
5885 			elsif (OE_Order_Cache.g_order_type_rec.tax_calculation_event_code =
5886 'BOOKING') then
5887 				l_tax_calculation_event_code := 1;
5888 			elsif (OE_Order_Cache.g_order_type_rec.tax_calculation_event_code =
5889 'SHIPPING') then
5890 				l_tax_calculation_event_code := 2;
5891 			elsif (OE_Order_Cache.g_order_type_rec.tax_calculation_event_code =
5892 'INVOICING') then
5893 				l_tax_calculation_event_code := 3;
5894 			else
5895 				l_tax_calculation_event_code := -1;
5896                         end if ;
5897 	       ELSE
5898 		      l_tax_calculation_event_code := 0 ;
5899 	       END IF ;
5900 
5901            /* SELECT DECODE( TAX_CALCULATION_EVENT_CODE, 'ENTERING',   0,
5902                                                   'BOOKING', 1,
5903                                                   'SHIPPING', 2,
5904                                                   'INVOICING', 3,
5905                                                   -1)
5906             into l_tax_calculation_event_code
5907             from oe_transaction_types_all
5908             where transaction_type_id = OE_Order_Cache.g_header_rec.order_type_id;
5909             */
5910             --end bug 4200055
5911 
5912          END IF;
5913 
5914         EXCEPTION
5915            when no_data_found then
5916                  l_tax_calculation_event_code := 0;
5917            when others then
5918             if l_debug_level > 0 then
5919              oe_debug_pub.add('Ren: failed while trying to query up tax_calcualtion_event for order_type_id ');
5920             end if;
5921              RAISE;
5922 
5923         END;
5924 
5925         -- all non-shippable lines need to get taxed at the time of entry
5926         -- itself - so we set the current event to same as
5927         --  tax_calculation_event
5928 
5929         IF ( l_tax_calculation_event_code = 2 and
5930              p_x_line_rec.shippable_flag = 'N' ) THEN
5931               l_current_event := l_tax_calculation_event_code;
5932         END IF;
5933 
5934         -- if current_event >= tax_calculation_event, then log
5935         -- the delayed request
5936         -- Renga end making changes for tax calculation event enhancement
5937 
5938         -- Modified the If condition as part of the fix for bug#2047434
5939         -- delayed request for taxing should not get logged for a line
5940         -- without an item thus added the condition to test the value of
5941         -- inventory item id .
5942 
5943         IF p_x_line_rec.item_type_code in ('INCLUDED', 'CONFIG') THEN
5944 
5945          if l_debug_level > 0 then
5946           oe_debug_pub.add('Ren: no tax delayed request for include and config',1);
5947          end if;
5948 
5949           oe_globals.g_tax_flag := 'N';
5950 
5951         END IF;
5952     --changes for bug 2505961  begin
5953 
5954     --commented the following for bug7306510 as the sql execution is no more required
5955     /*if p_x_line_rec.commitment_id is not null
5956        and p_x_line_rec.commitment_id <> FND_API.G_MISS_NUM
5957        and oe_globals.g_tax_flag = 'Y'
5958     then
5959      begin
5960       select  nvl(tax_calculation_flag,'N') into l_tax_commt_flag
5961       from ra_cust_trx_types ract where ract.cust_trx_type_id =
5962       (
5963       select nvl(cust_type.subsequent_trx_type_id,cust_type.cust_trx_type_id)
5964       from ra_cust_trx_types_all cust_type,ra_customer_trx_all cust_trx  where
5965       cust_type.cust_trx_type_id = cust_trx.cust_trx_type_id
5966       and cust_trx.customer_trx_id = p_x_line_rec.commitment_id
5967       );
5968      if l_debug_level > 0 then
5969       oe_debug_pub.add('OEXULINB:l_commit tax flag: '||l_tax_commt_flag,1);
5970      end if;
5971 
5972      exception
5973       when others then
5974      if l_debug_level > 0 then
5975       oe_debug_pub.add('OEXULINB: in exception commitment ',1);
5976      end if;
5977       l_tax_commt_flag := 'N';
5978      end;
5979     end if;*/
5980     --changes for bug 2505961  end
5981     --changes made in if condition below for bug 2573940
5982 
5983 
5984 
5985     -- commented portion of the following condition for bug7306510
5986        -- with ebtax upkae in R12 ,meaning of ra_cust_trx_types.tax_calculation_flag has changed
5987        -- now this flag will be checcked by customers only if they want the 11i migrated Tax Classification
5988        -- code approach,other wise tax will be calculated based on tax rules .It no more controls wheter tax code  is a  required  filed in AR transactions or not
5989        -- OM will depend on Tax_event alone ( specfied transaction type level) to automatically trigger
5990        -- tax calcualtion .ra_cust_trx_types.tax_calculation_flag is no more considered while logging delayed requests for tax
5991     -- 12876258 Added Debug
5992      if l_debug_level > 0 then
5993 	    oe_debug_pub.add('Before Tax delayed Req, taxFlag= '||oe_globals.g_tax_flag||' l_current_event= '||l_current_event);
5994      end if; -- end 12876258
5995 
5996 
5997    IF ( oe_globals.g_tax_flag = 'Y'  and
5998           l_current_event >= l_tax_calculation_event_code and
5999        /*bug7306510 ( l_tax_calculation_flag = 'Y' or
6000           p_x_line_rec.tax_exempt_flag = 'R' or l_tax_commt_flag = 'Y'
6001          or (l_tax_calculation_flag = 'N' and
6002           nvl(p_x_line_rec.tax_value,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM
6003             )
6004         ) and */
6005   nvl(p_x_line_rec.inventory_item_id,fnd_api.g_miss_num) <> fnd_api.g_miss_num)
6006   THEN
6007          if l_debug_level > 0 then
6008 	    oe_debug_pub.ADD('Logging delayed request for taxing');
6009          end if;
6010 	    -- lkxu, make changes for bug 1581188
6011             l_tax_commt_flag := 'N'; --bug 2505961
6012           IF (OE_GLOBALS.G_UI_FLAG)
6013              AND nvl(FND_PROFILE.VALUE('ONT_DELAY_TAX_CALC'), 'N') = 'N' THEN --TaxER
6014 	    OE_delayed_requests_Pvt.log_request(
6015 		p_entity_code 		=> OE_GLOBALS.G_ENTITY_LINE,
6016 		p_entity_id   		=> p_x_line_rec.line_id,
6017 		p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
6018 		p_requesting_entity_id   => p_x_line_rec.line_id,
6019                 p_request_type      	=> OE_GLOBALS.g_tax_line,
6020                 x_return_status     	=> l_return_status);
6021 		-- 14151216, Added IF for System Parameter check
6022 		IF (NVL(oe_sys_parameters.value('OE_INVOICE_FREIGHT_AS_LINE',p_x_line_rec.org_id), 'N') = 'Y') THEN
6023 		-- Bug 13777599 start
6024 		if l_debug_level > 0 then
6025 		oe_debug_pub.add(' OEXULINB 1 Tax Header Delayed Req');
6026 		End IF;
6027         OE_delayed_requests_Pvt.log_request(
6028                         p_entity_code           => OE_GLOBALS.G_ENTITY_HEADER,
6029                         p_entity_id             => p_x_line_rec.header_id,
6030                         p_requesting_entity_code => OE_GLOBALS.G_ENTITY_HEADER,
6031                         p_requesting_entity_id   => p_x_line_rec.header_id,
6032                         p_request_type          => OE_GLOBALS.g_tax_line,
6033                         p_param1                => NULL,
6034                         x_return_status         => l_return_status);
6035        -- Bug 13777599 end
6036 	    End If; --14151216, end if for System Parameter
6037           ELSE
6038             -- added p_param1 for bug 1786533.
6039 	    OE_delayed_requests_Pvt.log_request(
6040 		p_entity_code		=> OE_GLOBALS.G_ENTITY_ALL,
6041 		p_entity_id   		=> p_x_line_rec.line_id,
6042 		p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
6043 		p_requesting_entity_id   => p_x_line_rec.line_id,
6044                 p_request_type      	=> OE_GLOBALS.g_tax_line,
6045                 p_param1             	=> l_param1,
6046                 x_return_status     	=> l_return_status);
6047 		-- 14151216, Added IF for System Parameter check
6048 		IF (NVL(oe_sys_parameters.value('OE_INVOICE_FREIGHT_AS_LINE',p_x_line_rec.org_id), 'N') = 'Y') THEN
6049 		-- Bug 13777599 start
6050 		if l_debug_level > 0 then
6051 		oe_debug_pub.add(' OEXULINB 2 Tax Header Delayed Req');
6052 		End IF;
6053         OE_delayed_requests_Pvt.log_request(
6054                         p_entity_code           => OE_GLOBALS.G_ENTITY_ALL,
6055                         p_entity_id             => p_x_line_rec.header_id,
6056                         p_requesting_entity_code => OE_GLOBALS.G_ENTITY_HEADER,
6057                         p_requesting_entity_id   => p_x_line_rec.header_id,
6058                         p_request_type          => OE_GLOBALS.g_tax_line,
6059                         p_param1                => NULL,
6060                         x_return_status         => l_return_status);
6061        -- Bug 13777599 end
6062 	    End If; --14151216, end if for System Parameter
6063 	  END IF;
6064           oe_globals.g_tax_flag := 'N';
6065 	END IF;
6066 
6067 	/** commented out for bug 1581188
6068 	IF (oe_globals.g_tax_flag = 'Y') THEN
6069          if l_debug_level > 0 then
6070 	   oe_debug_pub.ADD('Logging delayed request for taxing');
6071          end if;
6072 	   OE_delayed_requests_Pvt.log_request(p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
6073 				p_entity_id         => p_x_line_rec.line_id,
6074 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
6075 				p_requesting_entity_id         => p_x_line_rec.line_id,
6076                                 p_request_type      => OE_GLOBALS.g_tax_line,
6077                                 x_return_status     => l_return_status);
6078           oe_globals.g_tax_flag := 'N';
6079 	END IF;
6080 	**/
6081 
6082     -- Log a verify payment request if the order is booked and a new line.
6083     -- Fix 1939779: Added condition to not log verify payment request for
6084     -- new config item lines being added to an order.
6085     IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
6086        p_x_line_rec.item_type_code <> OE_GLOBALS.G_ITEM_CONFIG AND
6087 	  p_x_line_rec.booked_flag = 'Y' THEN
6088       --IF (NVL(OE_Order_Cache.g_header_rec.payment_type_code, 'NULL') <> 'CREDIT_CARD' --CC Reversal ER#16014135 Commented
6089       --CC Reversal ER#16014135 Start
6090       IF ((NVL(OE_Order_Cache.g_header_rec.payment_type_code, 'NULL') <> 'CREDIT_CARD'
6091          OR (OE_Order_Cache.g_header_rec.payment_type_code = 'CREDIT_CARD' AND l_cc_rev_reauth_code IS NOT NULL))
6092       --CC Reversal ER#16014135 End
6093           AND OE_PrePayment_UTIL.is_prepaid_order(p_x_line_rec.header_id) = 'N')
6094          OR OE_PrePayment_UTIL.is_prepaid_order(p_x_line_rec.header_id) = 'Y'
6095           THEN
6096          if l_debug_level > 0 then
6097 	  oe_debug_pub.ADD('New line added to a booked order,'
6098 		 || 'Logging delayed request for Verify Payment', 1);
6099          end if;
6100        l_verify_payment_flag := 'Y';
6101       END IF;
6102     END IF;
6103 
6104     -- Suppress verify payment and credit checking if the line is split
6105     IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
6106 	   NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT' ) OR
6107        (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
6108 	    p_x_line_rec.split_from_line_id IS NOT NULL) THEN
6109       IF l_cc_rev_reauth_code IS NULL THEN --CC Reversal ER#16014135
6110          if l_debug_level > 0 then
6111 	  oe_debug_pub.ADD('Line is being Split, Suppress Verify Payment', 1);
6112          end if;
6113         l_verify_payment_flag := 'N';
6114       END IF; --CC Reversal ER#16014135
6115     END IF;
6116 
6117      -- If verify payment flag set to 'Y' then log a request for verify payment
6118      IF (l_verify_payment_flag = 'Y') THEN
6119 	  -- Log request only if the Line is NOT a RETURN.
6120 	  --IF	p_x_line_rec.line_category_code <> 'RETURN' THEN --16547815
6121           IF	p_x_line_rec.line_category_code <> 'RETURN' AND p_x_line_rec.ordered_quantity IS NOT NULL THEN --16547815
6122 	  --
6123       if l_debug_level > 0 then
6124        oe_debug_pub.ADD('Logging delayed request for Verify Payment');
6125       end if;
6126 	  --
6127        OE_delayed_requests_Pvt.log_request
6128                   (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
6129                    p_entity_id              => p_x_line_rec.header_id,
6130                    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
6131                    p_requesting_entity_id   => p_x_line_rec.line_id,
6132                    p_request_type           => OE_GLOBALS.G_VERIFY_PAYMENT,
6133                    x_return_status          => l_return_status);
6134           END IF;
6135      END IF;
6136 
6137      --bug 1829201, commitment related changes
6138      -- QUOTING change
6139      IF (l_calculate_commitment_flag = 'Y' OR l_get_commitment_bal = 'Y')
6140         AND nvl(p_x_line_rec.transaction_phase_code,'F') = 'F'
6141      THEN
6142 
6143          -- don't get the balance again, as this is the second call due to the change
6144          -- of unit_selling_price, and the returned value at this moment would be the
6145          -- balance after the current line is saved to database.
6146 
6147         IF NVL(OE_GLOBALS.g_pricing_recursion, 'N') <> 'Y'
6148            OR (NVL(OE_GLOBALS.g_pricing_recursion, 'N') = 'Y' AND
6149                oe_globals.g_commitment_balance IS NULL) THEN
6150   	   l_class := NULL;
6151            l_so_source_code := FND_PROFILE.VALUE('ONT_SOURCE_CODE');
6152            l_oe_installed_flag := 'I';
6153 
6154            -- get the available commitmenb balance before saving the line.
6155            IF NOT (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
6156 	         p_x_line_rec.split_from_line_id IS NOT NULL) THEN
6157               oe_globals.g_commitment_balance := ARP_BAL_UTIL.GET_COMMITMENT_BALANCE(
6158                         p_x_line_rec.commitment_id
6159                 	,l_class
6160                 	,l_so_source_code
6161                	 	,l_oe_installed_flag );
6162            END IF;
6163 
6164             -- if updating, then the applied commitment should become available
6165             IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
6166               l_commitment_applied_amount
6167                  := OE_Commitment_PVT.get_commitment_applied_amount
6168                      (p_header_id          => p_x_line_rec.header_id ,
6169                       p_line_id            => p_x_line_rec.line_id ,
6170                       p_commitment_id      => p_x_line_rec.commitment_id);
6171               /* Fix Bug # 2511389: This is now done in OE_Commitment_PVT.Calculate_Commitments
6172               oe_globals.g_commitment_balance
6173                  := oe_globals.g_commitment_balance + l_commitment_applied_amount;
6174               */
6175 
6176 
6177             END IF;
6178          END IF;
6179 
6180         IF l_calculate_commitment_flag = 'Y'
6181            AND OE_Commitment_Pvt.Do_Commitment_Sequencing
6182            AND l_update_commitment_applied <> 'Y' THEN
6183 
6184          if l_debug_level > 0 then
6185            oe_debug_pub.add('Logging delayed request for Commitment.', 2);
6186          end if;
6187 	   OE_Delayed_Requests_Pvt.Log_Request(
6188 	   p_entity_code		=>	OE_GLOBALS.G_ENTITY_LINE,
6189 	   p_entity_id			=>	p_x_line_rec.line_id,
6190 	   p_requesting_entity_code	=>	OE_GLOBALS.G_ENTITY_LINE,
6191 	   p_requesting_entity_id	=>	p_x_line_rec.line_id,
6192 	   p_request_type		=>	OE_GLOBALS.G_CALCULATE_COMMITMENT,
6193 	   x_return_status		=>	l_return_status);
6194 
6195         END IF;
6196 
6197     END IF;
6198 
6199     IF p_x_line_rec.commitment_id IS NOT NULL
6200        AND l_update_commitment_flag = 'Y'
6201        AND OE_Commitment_Pvt.Do_Commitment_Sequencing
6202        -- QUOTING change
6203        AND nvl(p_x_line_rec.transaction_phase_code,'F') = 'F'
6204     THEN
6205 
6206        -- lkxu, bug 1786533.
6207        IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
6208            NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT' ) THEN
6209 
6210          if l_debug_level > 0 then
6211            oe_debug_pub.add('Logging delayed request for updating commitment for line '||p_x_line_rec.line_id, 2);
6212          end if;
6213 
6214             -- should log as ENTITY_ALL, as SPLIT is a batch mode
6215 	   OE_Delayed_Requests_Pvt.Log_Request(
6216 		p_entity_code			=>OE_GLOBALS.G_ENTITY_ALL,
6217 		p_entity_id			=>p_x_line_rec.line_id,
6218 		p_requesting_entity_code	=>OE_GLOBALS.G_ENTITY_LINE,
6219 		p_requesting_entity_id 		=>p_x_line_rec.line_id,
6220 		p_request_type			=>OE_GLOBALS.G_UPDATE_COMMITMENT,
6221 		x_return_status			=>l_return_status);
6222          END IF;
6223     END IF;
6224 
6225     IF l_update_commitment_applied = 'Y'
6226        AND nvl(p_x_line_rec.transaction_phase_code,'F') = 'F' THEN
6227 
6228          if l_debug_level > 0 then
6229            oe_debug_pub.add('Logging delayed request for Commitment Applied Amount '|| p_x_line_rec.commitment_applied_amount, 3);
6230            oe_debug_pub.add('param2 is: '|| p_x_line_rec.header_id, 3);
6231            oe_debug_pub.add('param3 is: '|| p_x_line_rec.commitment_id, 3);
6232          end if;
6233 	   OE_Delayed_Requests_Pvt.Log_Request(
6234 	   p_entity_code		=>	OE_GLOBALS.G_ENTITY_LINE,
6235 	   p_entity_id			=>	p_x_line_rec.line_id,
6236 	   p_requesting_entity_code	=>	OE_GLOBALS.G_ENTITY_LINE,
6237 	   p_requesting_entity_id	=>	p_x_line_rec.line_id,
6238 	   p_request_type		=>	OE_GLOBALS.G_UPDATE_COMMITMENT_APPLIED,
6239            p_param1             	=>      p_x_line_rec.commitment_applied_amount,
6240            p_param2             	=>      p_x_line_rec.header_id,
6241            p_param3             	=>      p_x_line_rec.commitment_id,
6242 	   x_return_status		=>	l_return_status);
6243 
6244     END IF;
6245 
6246     -- bug 2668298, Freight Rating.
6247     IF l_get_FTE_freight_rate = 'Y' THEN
6248 
6249       if l_debug_level > 0 then
6250        oe_debug_pub.add('Logging delayed request for freight rate: '||p_x_line_rec.header_id, 2);
6251       end if;
6252 
6253        OE_delayed_requests_Pvt.log_request
6254                   (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
6255                    p_entity_id              => p_x_line_rec.header_id,
6256                    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
6257                    p_requesting_entity_id   => p_x_line_rec.line_id,
6258                    p_request_type           => OE_GLOBALS.G_FREIGHT_RATING,
6259                    x_return_status          => l_return_status);
6260 
6261         IF p_x_line_rec.booked_flag='Y' THEN
6262            l_pricing_event := 'BATCH,BOOK';
6263         ELSE
6264            l_pricing_event := 'BATCH';
6265         END IF;
6266 
6267         -- also log pricing request to calculate fregight rates.
6268         OE_delayed_requests_Pvt.log_request(
6269                    p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
6270                    p_entity_id              => p_x_line_rec.header_id,
6271                    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
6272                    p_requesting_entity_id   => p_x_line_rec.header_id,
6273                    p_request_unique_key1    => l_pricing_event,
6274                    p_request_unique_key2    => 'Y',  -- get freight flag
6275                    p_param1                 => p_x_line_rec.header_id,
6276                    p_param2                 => l_pricing_event,
6277                    p_request_type           => OE_GLOBALS.G_PRICE_ORDER,
6278                    x_return_status          => l_return_status);
6279     END IF;
6280     -- end of bug 2668298.
6281 
6282 
6283     -- Populate re_source_flag when project is not null, so that planning will
6284     -- not change Warehouse on the line.
6285     IF p_x_line_rec.project_id IS NOT NULL AND
6286 	p_x_line_rec.project_id <> FND_API.G_MISS_NUM THEN
6287 
6288 	p_x_line_rec.re_source_flag := 'N';
6289 
6290     END IF;
6291 
6292 
6293     /*
6294     ** Fix # 3147694 Start
6295     ** Following will be true only if the user is cancelling the
6296     ** order right after quantity on the lines was updated to 0.
6297     */
6298 
6299     IF p_x_line_rec.ordered_quantity = 0 AND
6300        p_old_line_rec.ordered_quantity = 0 AND
6301         OE_GLOBALS.g_recursion_mode = 'N' AND       -- Bug 3379121
6302        OE_OE_FORM_CANCEL_LINE.g_ord_lvl_can THEN
6303 
6304       IF l_debug_level > 0 THEN
6305         oe_debug_pub.add('Line Ord Qty already 0, Calling Check_Constraints based on Order Cancel Global');
6306       END IF;
6307 
6308       OE_SALES_CAN_UTIL.Check_Constraints
6309             (p_x_line_rec          => p_x_line_rec,
6310              p_old_line_rec  => p_old_line_rec,
6311              x_return_status => l_return_status
6312             );
6313       IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6314         p_x_line_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6315       ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6316         p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
6317       END IF;
6318 
6319     END IF;
6320     /* Fix # 3147694 End   */
6321 
6322 
6323   IF OE_CODE_CONTROL.GET_CODE_RELEASE_LEVEL >='110510' THEN
6324   IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE OR
6325     (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
6326      ( ( NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_from_org_id
6327                                                       ,p_old_line_rec.ship_from_org_id)
6328        AND p_old_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM) OR
6329      ( NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_to_org_id
6330                                                       ,p_old_line_rec.ship_to_org_id)
6331        AND p_old_line_rec.ship_to_org_id <> FND_API.G_MISS_NUM) OR
6332      ( NOT OE_GLOBALS.EQUAL(p_x_line_rec.inventory_item_id
6333                                                       ,p_old_line_rec.inventory_item_id)
6334        AND p_old_line_rec.inventory_item_id <> FND_API.G_MISS_NUM) OR
6335      ( NOT OE_GLOBALS.EQUAL(p_x_line_rec.order_quantity_uom
6336                                                       ,p_old_line_rec.order_quantity_uom)
6337        AND p_old_line_rec.order_quantity_uom <> FND_API.G_MISS_CHAR) OR
6338      ( NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity
6339                                                       ,p_old_line_rec.ordered_quantity)
6340        AND p_old_line_rec.ordered_quantity <> FND_API.G_MISS_NUM) OR
6341      ( NOT OE_GLOBALS.EQUAL(p_x_line_rec.schedule_ship_date
6342                                                       ,p_old_line_rec.schedule_ship_date)
6343        AND p_old_line_rec.schedule_ship_date <> FND_API.G_MISS_DATE) OR
6344      ( NOT OE_GLOBALS.EQUAL(p_x_line_rec.schedule_arrival_date
6345                                                       ,p_old_line_rec.schedule_arrival_date)
6346        AND p_old_line_rec.schedule_arrival_date <> FND_API.G_MISS_DATE) OR
6347      ( NOT OE_GLOBALS.EQUAL(p_x_line_rec.freight_terms_code
6348                                                       ,p_old_line_rec.freight_terms_code)
6349        AND p_old_line_rec.freight_terms_code <> FND_API.G_MISS_CHAR)))
6350        THEN
6351           IF OE_GLOBALS.G_FTE_REINVOKE IS NULL THEN
6352             Select Count(*) into l_fte_count
6353              from oe_price_adjustments where
6354              header_id = p_x_line_rec.header_id
6355              and LIST_LINE_TYPE_CODE = 'OM_CALLED_CHOOSE_SHIP_METHOD';
6356             if l_debug_level > 0 then
6357              oe_debug_pub.add( 'Value of fte count '||l_fte_count);
6358             end if;
6359             If l_fte_count > 0  Then
6360                   --fnd_message.set_name('ONT','MY_MESSAGE');
6361                   --OE_MSG_PUB.Add;
6362                     --NULL;
6363                      OE_GLOBALS.G_FTE_REINVOKE := 'Y';
6364             ELSE
6365 	             OE_GLOBALS.G_FTE_REINVOKE := 'N';
6366             End If;
6367 	  END IF;
6368   END IF;
6369   END IF;
6370 
6371     -- Moved to OE_ACKNOWLEDGMENT_PUB as part of 3417899 and 3412458
6372     /* IF l_3a7_attribute_change = FND_API.G_TRUE
6373        AND OE_Code_Control.code_release_level >= '110510'
6374        AND NVL(FND_PROFILE.VALUE('ONT_3A7_RESPONSE_REQUIRED'), 'N') = 'Y'
6375        AND p_x_line_rec.order_source_id= OE_Acknowledgment_Pub.G_XML_ORDER_SOURCE_ID
6376        AND nvl(p_x_line_rec.xml_transaction_type_code, OE_Acknowledgment_Pub.G_TRANSACTION_CSO) = OE_Acknowledgment_Pub.G_TRANSACTION_CSO
6377        AND p_x_line_rec.booked_flag = 'Y'
6378        AND p_x_line_rec.ordered_quantity <> 0 -- for bug 3421996
6379     THEN
6380            IF l_debug_level  > 0 THEN
6381               oe_debug_pub.add(  'Calling OE_Acknowlegment_PUB.Apply_3A7_Hold', 2 ) ;
6382            END IF;
6383            OE_Acknowledgment_PUB.Apply_3A7_Hold
6384                              ( p_header_id       =>  p_x_line_rec.header_id
6385                              , p_line_id         =>   p_x_line_rec.line_id
6386                              , p_sold_to_org_id  =>   p_x_line_rec.sold_to_org_id
6387                              , x_return_status   =>   l_return_status);
6388            IF l_debug_level  > 0 THEN
6389               oe_debug_pub.add(  'Return status after call to apply_3a7_hold:' || l_return_status, 2 ) ;
6390            END IF;
6391     END IF; */
6392 
6393    /*Bug2848734 */
6394  /* moved following code to above Derive_FB ER14763609
6395    IF NOT OE_GLOBALS.Equal(p_x_line_rec.return_context, p_old_line_rec.return_context) THEN
6396     IF (p_x_line_rec.line_category_code = 'RETURN' and
6397        p_x_line_rec.OPERATION = OE_GLOBALS.G_OPR_UPDATE and
6398        p_x_line_rec.return_context IS NULL ) THEN
6399 
6400        p_x_line_rec.reference_customer_trx_line_id := NULL;
6401        p_x_line_rec.credit_invoice_line_id := NULL;
6402        p_x_line_rec.reference_line_id := NULL;
6403        p_x_line_rec.reference_header_id := NULL;
6404     END IF;
6405   END IF;
6406   */--ER14763609
6407   /*Bug2848734*/
6408 
6409   if l_debug_level > 0 then
6410     oe_debug_pub.add('return status before exiting '|| p_x_line_rec.return_status, 1);
6411     oe_debug_pub.add('Exiting OE_LINE_UTIL.APPLY_ATTRIBUTE_CHANGES', 1);
6412   end if;
6413 
6414 END Apply_Attribute_Changes;
6415 
6416 
6417 
6418 /*----------------------------------------------------------
6419 PROCEDURE Complete_Record
6420 -----------------------------------------------------------*/
6421 
6422 PROCEDURE Complete_Record
6423 (   p_x_line_rec                    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
6424 ,   p_old_line_rec                  IN  OE_Order_PUB.Line_Rec_Type
6425 )
6426 IS
6427 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6428 BEGIN
6429 
6430   IF l_debug_level  > 0 THEN
6431     oe_debug_pub.add('Entering OE_LINE_UTIL.COMPLETE_RECORD', 1);
6432   END IF;
6433 
6434     IF p_x_line_rec.accounting_rule_id = FND_API.G_MISS_NUM THEN
6435         p_x_line_rec.accounting_rule_id := p_old_line_rec.accounting_rule_id;
6436     END IF;
6437 
6438     IF p_x_line_rec.accounting_rule_duration = FND_API.G_MISS_NUM THEN
6439         p_x_line_rec.accounting_rule_duration := p_old_line_rec.accounting_rule_duration;
6440     END IF;
6441 
6442     IF p_x_line_rec.actual_arrival_date = FND_API.G_MISS_DATE THEN
6443         p_x_line_rec.actual_arrival_date := p_old_line_rec.actual_arrival_date;
6444     END IF;
6445 
6446     IF p_x_line_rec.actual_shipment_date = FND_API.G_MISS_DATE THEN
6447         p_x_line_rec.actual_shipment_date := p_old_line_rec.actual_shipment_date;
6448     END IF;
6449 
6450     IF p_x_line_rec.agreement_id = FND_API.G_MISS_NUM THEN
6451         p_x_line_rec.agreement_id := p_old_line_rec.agreement_id;
6452     END IF;
6453 
6454     IF p_x_line_rec.arrival_set_id = FND_API.G_MISS_NUM THEN
6455         p_x_line_rec.arrival_Set_id := p_old_line_rec.arrival_set_id;
6456     END IF;
6457 
6458     IF p_x_line_rec.ato_line_id = FND_API.G_MISS_NUM THEN
6459         p_x_line_rec.ato_line_id := p_old_line_rec.ato_line_id;
6460     END IF;
6461     IF p_x_line_rec.upgraded_flag = FND_API.G_MISS_CHAR THEN
6462         p_x_line_rec.upgraded_flag := p_old_line_rec.upgraded_flag;
6463     END IF;
6464 
6465     IF p_x_line_rec.attribute1 = FND_API.G_MISS_CHAR THEN
6466         p_x_line_rec.attribute1 := p_old_line_rec.attribute1;
6467     END IF;
6468 
6469     IF p_x_line_rec.attribute10 = FND_API.G_MISS_CHAR THEN
6470         p_x_line_rec.attribute10 := p_old_line_rec.attribute10;
6471     END IF;
6472 
6473     IF p_x_line_rec.attribute11 = FND_API.G_MISS_CHAR THEN
6474         p_x_line_rec.attribute11 := p_old_line_rec.attribute11;
6475     END IF;
6476 
6477     IF p_x_line_rec.attribute12 = FND_API.G_MISS_CHAR THEN
6478         p_x_line_rec.attribute12 := p_old_line_rec.attribute12;
6479     END IF;
6480 
6481     IF p_x_line_rec.attribute13 = FND_API.G_MISS_CHAR THEN
6482         p_x_line_rec.attribute13 := p_old_line_rec.attribute13;
6483     END IF;
6484 
6485     IF p_x_line_rec.attribute14 = FND_API.G_MISS_CHAR THEN
6486         p_x_line_rec.attribute14 := p_old_line_rec.attribute14;
6487     END IF;
6488 
6489     IF p_x_line_rec.attribute15 = FND_API.G_MISS_CHAR THEN
6490         p_x_line_rec.attribute15 := p_old_line_rec.attribute15;
6491     END IF;
6492 
6493     IF p_x_line_rec.attribute16 = FND_API.G_MISS_CHAR THEN  --Bug 2184255
6494         p_x_line_rec.attribute16 := p_old_line_rec.attribute16;
6495     END IF;
6496 
6497     IF p_x_line_rec.attribute17 = FND_API.G_MISS_CHAR THEN
6498         p_x_line_rec.attribute17 := p_old_line_rec.attribute17;
6499     END IF;
6500 
6501     IF p_x_line_rec.attribute18 = FND_API.G_MISS_CHAR THEN
6502         p_x_line_rec.attribute18 := p_old_line_rec.attribute18;
6503     END IF;
6504 
6505     IF p_x_line_rec.attribute19 = FND_API.G_MISS_CHAR THEN
6506         p_x_line_rec.attribute19 := p_old_line_rec.attribute19;
6507     END IF;
6508 
6509     IF p_x_line_rec.attribute2 = FND_API.G_MISS_CHAR THEN
6510         p_x_line_rec.attribute2 := p_old_line_rec.attribute2;
6511     END IF;
6512 
6513     IF p_x_line_rec.attribute20 = FND_API.G_MISS_CHAR THEN  -- 2184255
6514         p_x_line_rec.attribute20 := p_old_line_rec.attribute20;
6515     END IF;
6516 
6517     IF p_x_line_rec.calculate_price_flag = FND_API.G_MISS_CHAR THEN
6518         p_x_line_rec.calculate_price_flag := p_old_line_rec.calculate_price_flag;
6519     END IF;
6520 
6521     IF p_x_line_rec.attribute3 = FND_API.G_MISS_CHAR THEN
6522         p_x_line_rec.attribute3 := p_old_line_rec.attribute3;
6523     END IF;
6524 
6525     IF p_x_line_rec.attribute4 = FND_API.G_MISS_CHAR THEN
6526         p_x_line_rec.attribute4 := p_old_line_rec.attribute4;
6527     END IF;
6528 
6529     IF p_x_line_rec.attribute5 = FND_API.G_MISS_CHAR THEN
6530         p_x_line_rec.attribute5 := p_old_line_rec.attribute5;
6531     END IF;
6532 
6533     IF p_x_line_rec.attribute6 = FND_API.G_MISS_CHAR THEN
6534         p_x_line_rec.attribute6 := p_old_line_rec.attribute6;
6535     END IF;
6536 
6537     IF p_x_line_rec.attribute7 = FND_API.G_MISS_CHAR THEN
6538         p_x_line_rec.attribute7 := p_old_line_rec.attribute7;
6539     END IF;
6540 
6541     IF p_x_line_rec.attribute8 = FND_API.G_MISS_CHAR THEN
6542         p_x_line_rec.attribute8 := p_old_line_rec.attribute8;
6543     END IF;
6544 
6545     IF p_x_line_rec.attribute9 = FND_API.G_MISS_CHAR THEN
6546         p_x_line_rec.attribute9 := p_old_line_rec.attribute9;
6547     END IF;
6548 
6549     IF p_x_line_rec.auto_selected_quantity = FND_API.G_MISS_NUM THEN
6550         p_x_line_rec.auto_selected_quantity := p_old_line_rec.auto_selected_quantity;
6551     END IF;
6552     IF p_x_line_rec.authorized_to_ship_flag = FND_API.G_MISS_CHAR THEN
6553         p_x_line_rec.authorized_to_ship_flag := p_old_line_rec.authorized_to_ship_flag;
6554     END IF;
6555 
6556     IF p_x_line_rec.booked_flag = FND_API.G_MISS_CHAR THEN
6557         p_x_line_rec.booked_flag := p_old_line_rec.booked_flag;
6558     END IF;
6559 
6560     IF p_x_line_rec.cancelled_flag = FND_API.G_MISS_CHAR THEN
6561         p_x_line_rec.cancelled_flag := p_old_line_rec.cancelled_flag;
6562     END IF;
6563 
6564     IF p_x_line_rec.cancelled_quantity = FND_API.G_MISS_NUM THEN
6565         p_x_line_rec.cancelled_quantity := p_old_line_rec.cancelled_quantity;
6566     END IF;
6567 
6568     IF p_x_line_rec.component_code = FND_API.G_MISS_CHAR THEN
6569         p_x_line_rec.component_code := p_old_line_rec.component_code;
6570     END IF;
6571 
6572     IF p_x_line_rec.component_number = FND_API.G_MISS_NUM THEN
6573         p_x_line_rec.component_number := p_old_line_rec.component_number;
6574     END IF;
6575 
6576     IF p_x_line_rec.component_sequence_id = FND_API.G_MISS_NUM THEN
6577         p_x_line_rec.component_sequence_id := p_old_line_rec.component_sequence_id;
6578     END IF;
6579 
6580     IF p_x_line_rec.config_header_id = FND_API.G_MISS_NUM THEN
6581         p_x_line_rec.config_header_id := p_old_line_rec.config_header_id;
6582     END IF;
6583 
6584     IF p_x_line_rec.config_rev_nbr = FND_API.G_MISS_NUM THEN
6585         p_x_line_rec.config_rev_nbr := p_old_line_rec.config_rev_nbr;
6586     END IF;
6587 
6588     IF p_x_line_rec.config_display_sequence = FND_API.G_MISS_NUM THEN
6589         p_x_line_rec.config_display_sequence := p_old_line_rec.config_display_sequence;
6590     END IF;
6591 
6592     IF p_x_line_rec.configuration_id = FND_API.G_MISS_NUM THEN
6593         p_x_line_rec.configuration_id := p_old_line_rec.configuration_id;
6594     END IF;
6595 
6596     IF p_x_line_rec.context = FND_API.G_MISS_CHAR THEN
6597         p_x_line_rec.context := p_old_line_rec.context;
6598     END IF;
6599 
6600     --recurring charges
6601     IF p_x_line_rec.charge_periodicity_code = FND_API.G_MISS_CHAR THEN
6602        p_x_line_rec.charge_periodicity_code :=
6603                          p_old_line_rec.charge_periodicity_code;
6604     END IF;
6605 
6606     --Customer Acceptance
6607      IF p_x_line_rec.CONTINGENCY_ID  = FND_API.G_MISS_NUM THEN
6608         p_x_line_rec.CONTINGENCY_ID  := p_old_line_rec.CONTINGENCY_ID  ;
6609     END IF;
6610      IF p_x_line_rec.REVREC_EVENT_CODE = FND_API.G_MISS_CHAR THEN
6611         p_x_line_rec.REVREC_EVENT_CODE:= p_old_line_rec.REVREC_EVENT_CODE  ;
6612     END IF;
6613      IF p_x_line_rec.REVREC_EXPIRATION_DAYS = FND_API.G_MISS_NUM THEN
6614         p_x_line_rec.REVREC_EXPIRATION_DAYS:= p_old_line_rec.REVREC_EXPIRATION_DAYS;
6615     END IF;
6616      IF p_x_line_rec.ACCEPTED_QUANTITY = FND_API.G_MISS_NUM THEN
6617         p_x_line_rec.ACCEPTED_QUANTITY:= p_old_line_rec.ACCEPTED_QUANTITY;
6618     END IF;
6619      IF p_x_line_rec.REVREC_COMMENTS = FND_API.G_MISS_CHAR THEN
6620         p_x_line_rec.REVREC_COMMENTS:= p_old_line_rec.REVREC_COMMENTS;
6621     END IF;
6622      IF p_x_line_rec.REVREC_SIGNATURE = FND_API.G_MISS_CHAR THEN
6623         p_x_line_rec.REVREC_SIGNATURE:= p_old_line_rec.REVREC_SIGNATURE;
6624     END IF;
6625      IF p_x_line_rec.REVREC_SIGNATURE_DATE = FND_API.G_MISS_DATE THEN
6626         p_x_line_rec.REVREC_SIGNATURE_DATE:= p_old_line_rec.REVREC_SIGNATURE_DATE;
6627     END IF;
6628      IF p_x_line_rec.ACCEPTED_BY = FND_API.G_MISS_NUM THEN
6629         p_x_line_rec.ACCEPTED_BY:= p_old_line_rec.ACCEPTED_BY;
6630     END IF;
6631      IF p_x_line_rec.REVREC_REFERENCE_DOCUMENT = FND_API.G_MISS_CHAR THEN
6632         p_x_line_rec.REVREC_REFERENCE_DOCUMENT:= p_old_line_rec.REVREC_REFERENCE_DOCUMENT;
6633     END IF;
6634      IF p_x_line_rec.REVREC_IMPLICIT_FLAG = FND_API.G_MISS_CHAR THEN
6635         p_x_line_rec.REVREC_IMPLICIT_FLAG:= p_old_line_rec.REVREC_IMPLICIT_FLAG;
6636     END IF;
6637     --Customer Acceptance end
6638 
6639 	-- sol_ord_er #16014165
6640 
6641 	IF p_x_line_rec.service_bill_option_code  = FND_API.G_MISS_CHAR THEN
6642 	p_x_line_rec.service_bill_option_code := p_old_line_rec.service_bill_option_code;
6643 	END IF;
6644 
6645 	IF p_x_line_rec.service_bill_profile_id  = FND_API.G_MISS_NUM THEN
6646 	p_x_line_rec.service_bill_profile_id := p_old_line_rec.service_bill_profile_id;
6647 	END IF;
6648 
6649 	IF p_x_line_rec.service_cov_template_id  = FND_API.G_MISS_NUM THEN
6650 	p_x_line_rec.service_cov_template_id := p_old_line_rec.service_cov_template_id;
6651 	END IF;
6652 
6653 	IF p_x_line_rec.service_subs_template_id  = FND_API.G_MISS_NUM THEN
6654 	p_x_line_rec.service_subs_template_id := p_old_line_rec.service_subs_template_id;
6655 	END IF;
6656 
6657 	IF p_x_line_rec.subscription_enable_flag  = FND_API.G_MISS_CHAR THEN
6658 	p_x_line_rec.subscription_enable_flag := p_old_line_rec.subscription_enable_flag;
6659 	END IF;
6660 
6661 	IF p_x_line_rec.SERVICE_FIRST_PERIOD_AMOUNT  = FND_API.G_MISS_NUM THEN
6662 	p_x_line_rec.SERVICE_FIRST_PERIOD_AMOUNT := p_old_line_rec.SERVICE_FIRST_PERIOD_AMOUNT;
6663 	END IF;
6664 
6665 	IF p_x_line_rec.SERVICE_FIRST_PERIOD_ENDDATE  = FND_API.G_MISS_DATE THEN
6666 	p_x_line_rec.SERVICE_FIRST_PERIOD_ENDDATE := p_old_line_rec.SERVICE_FIRST_PERIOD_ENDDATE;
6667 	END IF;
6668 	-- sol_ord_er #16014165 end
6669 
6670     IF p_x_line_rec.created_by = FND_API.G_MISS_NUM THEN
6671         p_x_line_rec.created_by := p_old_line_rec.created_by;
6672     END IF;
6673 
6674     IF p_x_line_rec.creation_date = FND_API.G_MISS_DATE THEN
6675         p_x_line_rec.creation_date := p_old_line_rec.creation_date;
6676     END IF;
6677 
6678      IF p_x_line_rec.credit_invoice_line_id = FND_API.G_MISS_NUM THEN
6679         p_x_line_rec.credit_invoice_line_id := p_old_line_rec.credit_invoice_line_id;
6680      END IF;
6681 
6682     IF p_x_line_rec.customer_dock_code = FND_API.G_MISS_CHAR THEN
6683         p_x_line_rec.customer_dock_code := p_old_line_rec.customer_dock_code;
6684     END IF;
6685 
6686     IF p_x_line_rec.customer_job = FND_API.G_MISS_CHAR THEN
6687         p_x_line_rec.customer_job := p_old_line_rec.customer_job;
6688     END IF;
6689 
6690     IF p_x_line_rec.customer_production_line = FND_API.G_MISS_CHAR THEN
6691         p_x_line_rec.customer_production_line := p_old_line_rec.customer_production_line;
6692     END IF;
6693      IF p_x_line_rec.cust_production_seq_num = FND_API.G_MISS_CHAR THEN
6694         p_x_line_rec.cust_production_seq_num := p_old_line_rec.cust_production_seq_num;
6695     END IF;
6696     IF p_x_line_rec.customer_trx_line_id = FND_API.G_MISS_NUM THEN
6697         p_x_line_rec.customer_trx_line_id := p_old_line_rec.customer_trx_line_id;
6698     END IF;
6699 
6700     IF p_x_line_rec.cust_model_serial_number = FND_API.G_MISS_CHAR THEN
6701         p_x_line_rec.cust_model_serial_number := p_old_line_rec.cust_model_serial_number;
6702     END IF;
6703 
6704     IF p_x_line_rec.cust_po_number = FND_API.G_MISS_CHAR THEN
6705         p_x_line_rec.cust_po_number := p_old_line_rec.cust_po_number;
6706     END IF;
6707 
6708     IF p_x_line_rec.customer_line_number = FND_API.G_MISS_CHAR THEN
6709         p_x_line_rec.customer_line_number := p_old_line_rec.customer_line_number;
6710     END IF;
6711 
6712     IF p_x_line_rec.customer_shipment_number = FND_API.G_MISS_CHAR THEN
6713         p_x_line_rec.customer_shipment_number := p_old_line_rec.customer_shipment_number;
6714     END IF;
6715 
6716     IF p_x_line_rec.delivery_lead_time = FND_API.G_MISS_NUM THEN
6717         p_x_line_rec.delivery_lead_time := p_old_line_rec.delivery_lead_time;
6718     END IF;
6719     IF p_x_line_rec.deliver_to_contact_id = FND_API.G_MISS_NUM THEN
6720         p_x_line_rec.deliver_to_contact_id := p_old_line_rec.deliver_to_contact_id;
6721     END IF;
6722 
6723     IF p_x_line_rec.deliver_to_org_id = FND_API.G_MISS_NUM THEN
6724         p_x_line_rec.deliver_to_org_id := p_old_line_rec.deliver_to_org_id;
6725     END IF;
6726 
6727     IF p_x_line_rec.demand_bucket_type_code = FND_API.G_MISS_CHAR THEN
6728         p_x_line_rec.demand_bucket_type_code := p_old_line_rec.demand_bucket_type_code;
6729     END IF;
6730 
6731     IF p_x_line_rec.demand_class_code = FND_API.G_MISS_CHAR THEN
6732         p_x_line_rec.demand_class_code := p_old_line_rec.demand_class_code;
6733     END IF;
6734 
6735     IF p_x_line_rec.dep_plan_required_flag = FND_API.G_MISS_CHAR THEN
6736         p_x_line_rec.dep_plan_required_flag := p_old_line_rec.dep_plan_required_flag;
6737     END IF;
6738 
6739 
6740 
6741     IF p_x_line_rec.earliest_acceptable_date = FND_API.G_MISS_DATE THEN
6742         p_x_line_rec.earliest_acceptable_date := p_old_line_rec.earliest_acceptable_date;
6743     END IF;
6744 
6745     IF p_x_line_rec.explosion_date = FND_API.G_MISS_DATE THEN
6746         p_x_line_rec.explosion_date := p_old_line_rec.explosion_date;
6747     END IF;
6748 
6749     IF p_x_line_rec.fob_point_code = FND_API.G_MISS_CHAR THEN
6750         p_x_line_rec.fob_point_code := p_old_line_rec.fob_point_code;
6751     END IF;
6752 
6753     IF p_x_line_rec.freight_carrier_code = FND_API.G_MISS_CHAR THEN
6754         p_x_line_rec.freight_carrier_code := p_old_line_rec.freight_carrier_code;
6755     END IF;
6756 
6757     IF p_x_line_rec.freight_terms_code = FND_API.G_MISS_CHAR THEN
6758         p_x_line_rec.freight_terms_code := p_old_line_rec.freight_terms_code;
6759     END IF;
6760 
6761     IF p_x_line_rec.fulfilled_quantity = FND_API.G_MISS_NUM THEN
6762         p_x_line_rec.fulfilled_quantity := p_old_line_rec.fulfilled_quantity;
6763     END IF;
6764 
6765     IF p_x_line_rec.fulfilled_flag = FND_API.G_MISS_CHAR THEN
6766         p_x_line_rec.fulfilled_flag := p_old_line_rec.fulfilled_flag;
6767     END IF;
6768 
6769     IF p_x_line_rec.fulfillment_method_code = FND_API.G_MISS_CHAR THEN
6770         p_x_line_rec.fulfillment_method_code := p_old_line_rec.fulfillment_method_code;
6771     END IF;
6772 
6773     IF p_x_line_rec.fulfillment_date = FND_API.G_MISS_DATE THEN
6774         p_x_line_rec.fulfillment_date := p_old_line_rec.fulfillment_date;
6775     END IF;
6776 
6777     IF p_x_line_rec.global_attribute1 = FND_API.G_MISS_CHAR THEN
6778         p_x_line_rec.global_attribute1 := p_old_line_rec.global_attribute1;
6779     END IF;
6780 
6781     IF p_x_line_rec.global_attribute10 = FND_API.G_MISS_CHAR THEN
6782         p_x_line_rec.global_attribute10 := p_old_line_rec.global_attribute10;
6783     END IF;
6784 
6785     IF p_x_line_rec.global_attribute11 = FND_API.G_MISS_CHAR THEN
6786         p_x_line_rec.global_attribute11 := p_old_line_rec.global_attribute11;
6787     END IF;
6788 
6789     IF p_x_line_rec.global_attribute12 = FND_API.G_MISS_CHAR THEN
6790         p_x_line_rec.global_attribute12 := p_old_line_rec.global_attribute12;
6791     END IF;
6792 
6793     IF p_x_line_rec.global_attribute13 = FND_API.G_MISS_CHAR THEN
6794         p_x_line_rec.global_attribute13 := p_old_line_rec.global_attribute13;
6795     END IF;
6796 
6797     IF p_x_line_rec.global_attribute14 = FND_API.G_MISS_CHAR THEN
6798         p_x_line_rec.global_attribute14 := p_old_line_rec.global_attribute14;
6799     END IF;
6800 
6801     IF p_x_line_rec.global_attribute15 = FND_API.G_MISS_CHAR THEN
6802         p_x_line_rec.global_attribute15 := p_old_line_rec.global_attribute15;
6803     END IF;
6804 
6805     IF p_x_line_rec.global_attribute16 = FND_API.G_MISS_CHAR THEN
6806         p_x_line_rec.global_attribute16 := p_old_line_rec.global_attribute16;
6807     END IF;
6808 
6809     IF p_x_line_rec.global_attribute17 = FND_API.G_MISS_CHAR THEN
6810         p_x_line_rec.global_attribute17 := p_old_line_rec.global_attribute17;
6811     END IF;
6812 
6813     IF p_x_line_rec.global_attribute18 = FND_API.G_MISS_CHAR THEN
6814         p_x_line_rec.global_attribute18 := p_old_line_rec.global_attribute18;
6815     END IF;
6816 
6817     IF p_x_line_rec.global_attribute19 = FND_API.G_MISS_CHAR THEN
6818         p_x_line_rec.global_attribute19 := p_old_line_rec.global_attribute19;
6819     END IF;
6820 
6821     IF p_x_line_rec.global_attribute2 = FND_API.G_MISS_CHAR THEN
6822         p_x_line_rec.global_attribute2 := p_old_line_rec.global_attribute2;
6823     END IF;
6824 
6825     IF p_x_line_rec.global_attribute20 = FND_API.G_MISS_CHAR THEN
6826         p_x_line_rec.global_attribute20 := p_old_line_rec.global_attribute20;
6827     END IF;
6828 
6829     IF p_x_line_rec.global_attribute3 = FND_API.G_MISS_CHAR THEN
6830         p_x_line_rec.global_attribute3 := p_old_line_rec.global_attribute3;
6831     END IF;
6832 
6833     IF p_x_line_rec.global_attribute4 = FND_API.G_MISS_CHAR THEN
6834         p_x_line_rec.global_attribute4 := p_old_line_rec.global_attribute4;
6835     END IF;
6836 
6837     IF p_x_line_rec.global_attribute5 = FND_API.G_MISS_CHAR THEN
6838         p_x_line_rec.global_attribute5 := p_old_line_rec.global_attribute5;
6839     END IF;
6840 
6841     IF p_x_line_rec.global_attribute6 = FND_API.G_MISS_CHAR THEN
6842         p_x_line_rec.global_attribute6 := p_old_line_rec.global_attribute6;
6843     END IF;
6844 
6845     IF p_x_line_rec.global_attribute7 = FND_API.G_MISS_CHAR THEN
6846         p_x_line_rec.global_attribute7 := p_old_line_rec.global_attribute7;
6847     END IF;
6848 
6849     IF p_x_line_rec.global_attribute8 = FND_API.G_MISS_CHAR THEN
6850         p_x_line_rec.global_attribute8 := p_old_line_rec.global_attribute8;
6851     END IF;
6852 
6853     IF p_x_line_rec.global_attribute9 = FND_API.G_MISS_CHAR THEN
6854         p_x_line_rec.global_attribute9 := p_old_line_rec.global_attribute9;
6855     END IF;
6856 
6857     IF p_x_line_rec.global_attribute_category = FND_API.G_MISS_CHAR THEN
6858         p_x_line_rec.global_attribute_category := p_old_line_rec.global_attribute_category;
6859     END IF;
6860 
6861     IF p_x_line_rec.header_id = FND_API.G_MISS_NUM THEN
6862         p_x_line_rec.header_id := p_old_line_rec.header_id;
6863     END IF;
6864 
6865     IF p_x_line_rec.industry_attribute1 = FND_API.G_MISS_CHAR THEN
6866         p_x_line_rec.industry_attribute1 := p_old_line_rec.industry_attribute1;
6867     END IF;
6868 
6869     IF p_x_line_rec.industry_attribute10 = FND_API.G_MISS_CHAR THEN
6870         p_x_line_rec.industry_attribute10 := p_old_line_rec.industry_attribute10;
6871     END IF;
6872 
6873     IF p_x_line_rec.industry_attribute11 = FND_API.G_MISS_CHAR THEN
6874         p_x_line_rec.industry_attribute11 := p_old_line_rec.industry_attribute11;
6875     END IF;
6876 
6877     IF p_x_line_rec.industry_attribute12 = FND_API.G_MISS_CHAR THEN
6878         p_x_line_rec.industry_attribute12 := p_old_line_rec.industry_attribute12;
6879     END IF;
6880 
6881     IF p_x_line_rec.industry_attribute13 = FND_API.G_MISS_CHAR THEN
6882         p_x_line_rec.industry_attribute13 := p_old_line_rec.industry_attribute13;
6883     END IF;
6884 
6885     IF p_x_line_rec.industry_attribute14 = FND_API.G_MISS_CHAR THEN
6886         p_x_line_rec.industry_attribute14 := p_old_line_rec.industry_attribute14;
6887     END IF;
6888 
6889     IF p_x_line_rec.industry_attribute15 = FND_API.G_MISS_CHAR THEN
6890         p_x_line_rec.industry_attribute15 := p_old_line_rec.industry_attribute15;
6891     END IF;
6892 
6893     IF p_x_line_rec.industry_attribute16 = FND_API.G_MISS_CHAR THEN
6894         p_x_line_rec.industry_attribute16 := p_old_line_rec.industry_attribute16;
6895     END IF;
6896     IF p_x_line_rec.industry_attribute17 = FND_API.G_MISS_CHAR THEN
6897         p_x_line_rec.industry_attribute17 := p_old_line_rec.industry_attribute17;
6898     END IF;
6899     IF p_x_line_rec.industry_attribute18 = FND_API.G_MISS_CHAR THEN
6900         p_x_line_rec.industry_attribute18 := p_old_line_rec.industry_attribute18;
6901     END IF;
6902     IF p_x_line_rec.industry_attribute19 = FND_API.G_MISS_CHAR THEN
6903         p_x_line_rec.industry_attribute19 := p_old_line_rec.industry_attribute19;
6904     END IF;
6905     IF p_x_line_rec.industry_attribute20 = FND_API.G_MISS_CHAR THEN
6906         p_x_line_rec.industry_attribute20 := p_old_line_rec.industry_attribute20;
6907     END IF;
6908     IF p_x_line_rec.industry_attribute21 = FND_API.G_MISS_CHAR THEN
6909         p_x_line_rec.industry_attribute21 := p_old_line_rec.industry_attribute21;
6910     END IF;
6911     IF p_x_line_rec.industry_attribute22 = FND_API.G_MISS_CHAR THEN
6912         p_x_line_rec.industry_attribute22 := p_old_line_rec.industry_attribute22;
6913     END IF;
6914     IF p_x_line_rec.industry_attribute23 = FND_API.G_MISS_CHAR THEN
6915         p_x_line_rec.industry_attribute23 := p_old_line_rec.industry_attribute23;
6916     END IF;
6917     IF p_x_line_rec.industry_attribute24 = FND_API.G_MISS_CHAR THEN
6918         p_x_line_rec.industry_attribute24 := p_old_line_rec.industry_attribute24;
6919     END IF;
6920     IF p_x_line_rec.industry_attribute25 = FND_API.G_MISS_CHAR THEN
6921         p_x_line_rec.industry_attribute25 := p_old_line_rec.industry_attribute25;
6922     END IF;
6923     IF p_x_line_rec.industry_attribute26 = FND_API.G_MISS_CHAR THEN
6924         p_x_line_rec.industry_attribute26 := p_old_line_rec.industry_attribute26;
6925     END IF;
6926     IF p_x_line_rec.industry_attribute27 = FND_API.G_MISS_CHAR THEN
6927         p_x_line_rec.industry_attribute27 := p_old_line_rec.industry_attribute27;
6928     END IF;
6929     IF p_x_line_rec.industry_attribute28 = FND_API.G_MISS_CHAR THEN
6930         p_x_line_rec.industry_attribute28 := p_old_line_rec.industry_attribute28;
6931     END IF;
6932     IF p_x_line_rec.industry_attribute29 = FND_API.G_MISS_CHAR THEN
6933         p_x_line_rec.industry_attribute29 := p_old_line_rec.industry_attribute29;
6934     END IF;
6935     IF p_x_line_rec.industry_attribute30 = FND_API.G_MISS_CHAR THEN
6936         p_x_line_rec.industry_attribute30 := p_old_line_rec.industry_attribute30;
6937     END IF;
6938     IF p_x_line_rec.industry_attribute2 = FND_API.G_MISS_CHAR THEN
6939         p_x_line_rec.industry_attribute2 := p_old_line_rec.industry_attribute2;
6940     END IF;
6941 
6942     IF p_x_line_rec.industry_attribute3 = FND_API.G_MISS_CHAR THEN
6943         p_x_line_rec.industry_attribute3 := p_old_line_rec.industry_attribute3;
6944     END IF;
6945 
6946     IF p_x_line_rec.industry_attribute4 = FND_API.G_MISS_CHAR THEN
6947         p_x_line_rec.industry_attribute4 := p_old_line_rec.industry_attribute4;
6948     END IF;
6949 
6950     IF p_x_line_rec.industry_attribute5 = FND_API.G_MISS_CHAR THEN
6951         p_x_line_rec.industry_attribute5 := p_old_line_rec.industry_attribute5;
6952     END IF;
6953 
6954     IF p_x_line_rec.industry_attribute6 = FND_API.G_MISS_CHAR THEN
6955         p_x_line_rec.industry_attribute6 := p_old_line_rec.industry_attribute6;
6956     END IF;
6957 
6958     IF p_x_line_rec.industry_attribute7 = FND_API.G_MISS_CHAR THEN
6959         p_x_line_rec.industry_attribute7 := p_old_line_rec.industry_attribute7;
6960     END IF;
6961 
6962     IF p_x_line_rec.industry_attribute8 = FND_API.G_MISS_CHAR THEN
6963         p_x_line_rec.industry_attribute8 := p_old_line_rec.industry_attribute8;
6964     END IF;
6965 
6966     IF p_x_line_rec.industry_attribute9 = FND_API.G_MISS_CHAR THEN
6967         p_x_line_rec.industry_attribute9 := p_old_line_rec.industry_attribute9;
6968     END IF;
6969 
6970     IF p_x_line_rec.industry_context = FND_API.G_MISS_CHAR THEN
6971         p_x_line_rec.industry_context := p_old_line_rec.industry_context;
6972     END IF;
6973 
6974     /* TP_ATTRIBUTE */
6975     IF p_x_line_rec.tp_context = FND_API.G_MISS_CHAR THEN
6976         p_x_line_rec.tp_context := p_old_line_rec.tp_context;
6977     END IF;
6978 
6979     IF p_x_line_rec.tp_attribute1 = FND_API.G_MISS_CHAR THEN
6980         p_x_line_rec.tp_attribute1 := p_old_line_rec.tp_attribute1;
6981     END IF;
6982     IF p_x_line_rec.tp_attribute2 = FND_API.G_MISS_CHAR THEN
6983         p_x_line_rec.tp_attribute2 := p_old_line_rec.tp_attribute2;
6984     END IF;
6985     IF p_x_line_rec.tp_attribute3 = FND_API.G_MISS_CHAR THEN
6986         p_x_line_rec.tp_attribute3 := p_old_line_rec.tp_attribute3;
6987     END IF;
6988     IF p_x_line_rec.tp_attribute4 = FND_API.G_MISS_CHAR THEN
6989         p_x_line_rec.tp_attribute4 := p_old_line_rec.tp_attribute4;
6990     END IF;
6991     IF p_x_line_rec.tp_attribute5 = FND_API.G_MISS_CHAR THEN
6992         p_x_line_rec.tp_attribute5 := p_old_line_rec.tp_attribute5;
6993     END IF;
6994     IF p_x_line_rec.tp_attribute6 = FND_API.G_MISS_CHAR THEN
6995         p_x_line_rec.tp_attribute6 := p_old_line_rec.tp_attribute6;
6996     END IF;
6997     IF p_x_line_rec.tp_attribute7 = FND_API.G_MISS_CHAR THEN
6998         p_x_line_rec.tp_attribute7 := p_old_line_rec.tp_attribute7;
6999     END IF;
7000     IF p_x_line_rec.tp_attribute8 = FND_API.G_MISS_CHAR THEN
7001         p_x_line_rec.tp_attribute8 := p_old_line_rec.tp_attribute8;
7002     END IF;
7003     IF p_x_line_rec.tp_attribute9 = FND_API.G_MISS_CHAR THEN
7004         p_x_line_rec.tp_attribute9 := p_old_line_rec.tp_attribute9;
7005     END IF;
7006     IF p_x_line_rec.tp_attribute10 = FND_API.G_MISS_CHAR THEN
7007         p_x_line_rec.tp_attribute10 := p_old_line_rec.tp_attribute10;
7008     END IF;
7009     IF p_x_line_rec.tp_attribute11 = FND_API.G_MISS_CHAR THEN
7010         p_x_line_rec.tp_attribute11 := p_old_line_rec.tp_attribute11;
7011     END IF;
7012     IF p_x_line_rec.tp_attribute12 = FND_API.G_MISS_CHAR THEN
7013         p_x_line_rec.tp_attribute12 := p_old_line_rec.tp_attribute12;
7014     END IF;
7015     IF p_x_line_rec.tp_attribute13 = FND_API.G_MISS_CHAR THEN
7016         p_x_line_rec.tp_attribute13 := p_old_line_rec.tp_attribute13;
7017     END IF;
7018     IF p_x_line_rec.tp_attribute14 = FND_API.G_MISS_CHAR THEN
7019         p_x_line_rec.tp_attribute14 := p_old_line_rec.tp_attribute14;
7020     END IF;
7021     IF p_x_line_rec.tp_attribute15 = FND_API.G_MISS_CHAR THEN
7022         p_x_line_rec.tp_attribute15 := p_old_line_rec.tp_attribute15;
7023     END IF;
7024 
7025 
7026     IF p_x_line_rec.intermed_ship_to_contact_id = FND_API.G_MISS_NUM THEN
7027         p_x_line_rec.intermed_ship_to_contact_id := p_old_line_rec.intermed_ship_to_contact_id;
7028     END IF;
7029 
7030     IF p_x_line_rec.intermed_ship_to_org_id = FND_API.G_MISS_NUM THEN
7031         p_x_line_rec.intermed_ship_to_org_id := p_old_line_rec.intermed_ship_to_org_id;
7032     END IF;
7033 
7034     IF p_x_line_rec.inventory_item_id = FND_API.G_MISS_NUM THEN
7035         p_x_line_rec.inventory_item_id := p_old_line_rec.inventory_item_id;
7036     END IF;
7037 
7038     IF p_x_line_rec.invoice_interface_status_code = FND_API.G_MISS_CHAR THEN
7039         p_x_line_rec.invoice_interface_status_code := p_old_line_rec.invoice_interface_status_code;
7040     END IF;
7041 
7042 
7043 
7044     IF p_x_line_rec.invoice_to_contact_id = FND_API.G_MISS_NUM THEN
7045         p_x_line_rec.invoice_to_contact_id := p_old_line_rec.invoice_to_contact_id;
7046     END IF;
7047 
7048     IF p_x_line_rec.invoice_to_org_id = FND_API.G_MISS_NUM THEN
7049         p_x_line_rec.invoice_to_org_id := p_old_line_rec.invoice_to_org_id;
7050     END IF;
7051 
7052     IF p_x_line_rec.invoiced_quantity = FND_API.G_MISS_NUM THEN
7053         p_x_line_rec.invoiced_quantity := p_old_line_rec.invoiced_quantity;
7054     END IF;
7055 
7056     IF p_x_line_rec.invoicing_rule_id = FND_API.G_MISS_NUM THEN
7057         p_x_line_rec.invoicing_rule_id := p_old_line_rec.invoicing_rule_id;
7058     END IF;
7059 
7060     IF p_x_line_rec.ordered_item_id = FND_API.G_MISS_NUM THEN
7061         p_x_line_rec.ordered_item_id := p_old_line_rec.ordered_item_id;
7062     END IF;
7063 
7064     IF p_x_line_rec.item_identifier_type = FND_API.G_MISS_CHAR THEN
7065         p_x_line_rec.item_identifier_type := p_old_line_rec.item_identifier_type;
7066     END IF;
7067 
7068     IF p_x_line_rec.ordered_item = FND_API.G_MISS_CHAR THEN
7069         p_x_line_rec.ordered_item := p_old_line_rec.ordered_item;
7070     END IF;
7071 
7072     IF p_x_line_rec.item_revision = FND_API.G_MISS_CHAR THEN
7073         p_x_line_rec.item_revision := p_old_line_rec.item_revision;
7074     END IF;
7075 
7076     IF p_x_line_rec.item_type_code = FND_API.G_MISS_CHAR THEN
7077         p_x_line_rec.item_type_code := p_old_line_rec.item_type_code;
7078     END IF;
7079 
7080     IF p_x_line_rec.last_updated_by = FND_API.G_MISS_NUM THEN
7081         p_x_line_rec.last_updated_by := p_old_line_rec.last_updated_by;
7082     END IF;
7083 
7084     IF p_x_line_rec.last_update_date = FND_API.G_MISS_DATE THEN
7085         p_x_line_rec.last_update_date := p_old_line_rec.last_update_date;
7086     END IF;
7087 
7088     IF p_x_line_rec.last_update_login = FND_API.G_MISS_NUM THEN
7089         p_x_line_rec.last_update_login := p_old_line_rec.last_update_login;
7090     END IF;
7091 
7092     IF p_x_line_rec.latest_acceptable_date = FND_API.G_MISS_DATE THEN
7093         p_x_line_rec.latest_acceptable_date := p_old_line_rec.latest_acceptable_date;
7094     END IF;
7095 
7096     IF p_x_line_rec.line_category_code = FND_API.G_MISS_CHAR THEN
7097         p_x_line_rec.line_category_code := p_old_line_rec.line_category_code;
7098     END IF;
7099 
7100     IF p_x_line_rec.line_id = FND_API.G_MISS_NUM THEN
7101         p_x_line_rec.line_id := p_old_line_rec.line_id;
7102     END IF;
7103 
7104     IF p_x_line_rec.line_number = FND_API.G_MISS_NUM THEN
7105         p_x_line_rec.line_number := p_old_line_rec.line_number;
7106     END IF;
7107 
7108     IF p_x_line_rec.line_type_id = FND_API.G_MISS_NUM THEN
7109         p_x_line_rec.line_type_id := p_old_line_rec.line_type_id;
7110     END IF;
7111 
7112     IF p_x_line_rec.link_to_line_id = FND_API.G_MISS_NUM THEN
7113         p_x_line_rec.link_to_line_id := p_old_line_rec.link_to_line_id;
7114     END IF;
7115 
7116     IF p_x_line_rec.model_group_number = FND_API.G_MISS_NUM THEN
7117         p_x_line_rec.model_group_number := p_old_line_rec.model_group_number;
7118     END IF;
7119 
7120     IF p_x_line_rec.mfg_component_sequence_id = FND_API.G_MISS_NUM THEN
7121         p_x_line_rec.mfg_component_sequence_id := p_old_line_rec.mfg_component_sequence_id;
7122     END IF;
7123 
7124     IF p_x_line_rec.mfg_lead_time = FND_API.G_MISS_NUM THEN
7125         p_x_line_rec.mfg_lead_time := p_old_line_rec.mfg_lead_time;
7126     END IF;
7127 
7128     IF p_x_line_rec.open_flag = FND_API.G_MISS_CHAR THEN
7129         p_x_line_rec.open_flag := p_old_line_rec.open_flag;
7130     END IF;
7131 
7132     IF p_x_line_rec.option_flag = FND_API.G_MISS_CHAR THEN
7133         p_x_line_rec.option_flag := p_old_line_rec.option_flag;
7134     END IF;
7135 
7136     IF p_x_line_rec.option_number = FND_API.G_MISS_NUM THEN
7137         p_x_line_rec.option_number := p_old_line_rec.option_number;
7138     END IF;
7139 
7140     IF p_x_line_rec.ordered_quantity = FND_API.G_MISS_NUM THEN
7141         p_x_line_rec.ordered_quantity := p_old_line_rec.ordered_quantity;
7142     END IF;
7143 
7144     -- OPM 02/JUN/00 INVCONV
7145     IF p_x_line_rec.ordered_quantity2 = FND_API.G_MISS_NUM THEN
7146         p_x_line_rec.ordered_quantity2 := p_old_line_rec.ordered_quantity2;
7147     END IF;
7148     -- OPM 02/JUN/00 END
7149 
7150     IF p_x_line_rec.order_quantity_uom = FND_API.G_MISS_CHAR THEN
7151         p_x_line_rec.order_quantity_uom := p_old_line_rec.order_quantity_uom;
7152     END IF;
7153 
7154     -- OPM 02/JUN/00 INVCONV
7155 
7156     IF p_x_line_rec.ordered_quantity_uom2 = FND_API.G_MISS_CHAR THEN
7157         p_x_line_rec.ordered_quantity_uom2 :=p_old_line_rec.ordered_quantity_uom2;
7158     END IF;
7159     -- OPM 02/JUN/00 END
7160 
7161     IF p_x_line_rec.org_id = FND_API.G_MISS_NUM THEN
7162         p_x_line_rec.org_id := p_old_line_rec.org_id;
7163     END IF;
7164 
7165     IF p_x_line_rec.orig_sys_document_ref = FND_API.G_MISS_CHAR THEN
7166         p_x_line_rec.orig_sys_document_ref := p_old_line_rec.orig_sys_document_ref;
7167     END IF;
7168 
7169     IF p_x_line_rec.orig_sys_line_ref = FND_API.G_MISS_CHAR THEN
7170         p_x_line_rec.orig_sys_line_ref := p_old_line_rec.orig_sys_line_ref;
7171     END IF;
7172 
7173     IF p_x_line_rec.orig_sys_shipment_ref = FND_API.G_MISS_CHAR THEN
7174         p_x_line_rec.orig_sys_shipment_ref := p_old_line_rec.orig_sys_shipment_ref;
7175     END IF;
7176 
7177 -- Override List Price
7178     IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
7179        IF p_x_line_rec.original_list_price = FND_API.G_MISS_NUM THEN
7180           p_x_line_rec.original_list_price:= p_old_line_rec.original_list_price;
7181        END IF;
7182     END IF;
7183 -- Override List Price
7184 
7185    IF p_x_line_rec.over_ship_reason_code = FND_API.G_MISS_CHAR THEN
7186         p_x_line_rec.over_ship_reason_code := p_old_line_rec.over_ship_reason_code;
7187     END IF;
7188 
7189     IF p_x_line_rec.over_ship_resolved_flag = FND_API.G_MISS_CHAR THEN
7190         p_x_line_rec.over_ship_resolved_flag := p_old_line_rec.over_ship_resolved_flag;
7191     END IF;
7192 
7193     IF p_x_line_rec.payment_term_id = FND_API.G_MISS_NUM THEN
7194         p_x_line_rec.payment_term_id := p_old_line_rec.payment_term_id;
7195     END IF;
7196 
7197     IF p_x_line_rec.planning_priority = FND_API.G_MISS_NUM THEN
7198         p_x_line_rec.planning_priority := p_old_line_rec.planning_priority;
7199     END IF;
7200 
7201     -- OPM 02/JUN/00 INVCONV
7202     IF p_x_line_rec.preferred_grade = FND_API.G_MISS_CHAR THEN
7203         p_x_line_rec.preferred_grade :=p_old_line_rec.preferred_grade;
7204     END IF;
7205     -- OPM 02/JUN/00 END
7206 
7207     IF p_x_line_rec.price_list_id = FND_API.G_MISS_NUM THEN
7208         p_x_line_rec.price_list_id := p_old_line_rec.price_list_id;
7209     END IF;
7210 
7211     -- PROMOTIONS SEP/01 BEGIN
7212     IF p_x_line_rec.price_request_code = FND_API.G_MISS_CHAR THEN
7213         p_x_line_rec.price_request_code := p_old_line_rec.price_request_code;
7214     END IF;
7215     -- PROMOTIONS SEP/01 END
7216 
7217     IF p_x_line_rec.pricing_attribute1 = FND_API.G_MISS_CHAR THEN
7218         p_x_line_rec.pricing_attribute1 := p_old_line_rec.pricing_attribute1;
7219     END IF;
7220 
7221     IF p_x_line_rec.pricing_attribute10 = FND_API.G_MISS_CHAR THEN
7222         p_x_line_rec.pricing_attribute10 := p_old_line_rec.pricing_attribute10;
7223     END IF;
7224 
7225     IF p_x_line_rec.pricing_attribute2 = FND_API.G_MISS_CHAR THEN
7226         p_x_line_rec.pricing_attribute2 := p_old_line_rec.pricing_attribute2;
7227     END IF;
7228 
7229     IF p_x_line_rec.pricing_attribute3 = FND_API.G_MISS_CHAR THEN
7230         p_x_line_rec.pricing_attribute3 := p_old_line_rec.pricing_attribute3;
7231     END IF;
7232 
7233     IF p_x_line_rec.pricing_attribute4 = FND_API.G_MISS_CHAR THEN
7234         p_x_line_rec.pricing_attribute4 := p_old_line_rec.pricing_attribute4;
7235     END IF;
7236 
7237     IF p_x_line_rec.pricing_attribute5 = FND_API.G_MISS_CHAR THEN
7238         p_x_line_rec.pricing_attribute5 := p_old_line_rec.pricing_attribute5;
7239     END IF;
7240 
7241     IF p_x_line_rec.pricing_attribute6 = FND_API.G_MISS_CHAR THEN
7242         p_x_line_rec.pricing_attribute6 := p_old_line_rec.pricing_attribute6;
7243     END IF;
7244 
7245     IF p_x_line_rec.pricing_attribute7 = FND_API.G_MISS_CHAR THEN
7246         p_x_line_rec.pricing_attribute7 := p_old_line_rec.pricing_attribute7;
7247     END IF;
7248 
7249     IF p_x_line_rec.pricing_attribute8 = FND_API.G_MISS_CHAR THEN
7250         p_x_line_rec.pricing_attribute8 := p_old_line_rec.pricing_attribute8;
7251     END IF;
7252 
7253     IF p_x_line_rec.pricing_attribute9 = FND_API.G_MISS_CHAR THEN
7254         p_x_line_rec.pricing_attribute9 := p_old_line_rec.pricing_attribute9;
7255     END IF;
7256 
7257     IF p_x_line_rec.pricing_context = FND_API.G_MISS_CHAR THEN
7258         p_x_line_rec.pricing_context := p_old_line_rec.pricing_context;
7259     END IF;
7260 
7261     IF p_x_line_rec.pricing_date = FND_API.G_MISS_DATE THEN
7262         p_x_line_rec.pricing_date := p_old_line_rec.pricing_date;
7263     END IF;
7264 
7265     IF p_x_line_rec.pricing_quantity = FND_API.G_MISS_NUM THEN
7266         p_x_line_rec.pricing_quantity := p_old_line_rec.pricing_quantity;
7267     END IF;
7268 
7269     IF p_x_line_rec.pricing_quantity_uom = FND_API.G_MISS_CHAR THEN
7270         p_x_line_rec.pricing_quantity_uom := p_old_line_rec.pricing_quantity_uom;
7271     END IF;
7272 
7273     IF p_x_line_rec.program_application_id = FND_API.G_MISS_NUM THEN
7274         p_x_line_rec.program_application_id := p_old_line_rec.program_application_id;
7275     END IF;
7276 
7277     IF p_x_line_rec.program_id = FND_API.G_MISS_NUM THEN
7278         p_x_line_rec.program_id := p_old_line_rec.program_id;
7279     END IF;
7280 
7281     IF p_x_line_rec.program_update_date = FND_API.G_MISS_DATE THEN
7282         p_x_line_rec.program_update_date := p_old_line_rec.program_update_date;
7283     END IF;
7284 
7285     IF p_x_line_rec.project_id = FND_API.G_MISS_NUM THEN
7286         p_x_line_rec.project_id := p_old_line_rec.project_id;
7287     END IF;
7288 
7289     IF p_x_line_rec.promise_date = FND_API.G_MISS_DATE THEN
7290         p_x_line_rec.promise_date := p_old_line_rec.promise_date;
7291     END IF;
7292 
7293     IF p_x_line_rec.re_source_flag = FND_API.G_MISS_CHAR THEN
7294         p_x_line_rec.re_source_flag := p_old_line_rec.re_source_flag;
7295     END IF;
7296 
7297     IF p_x_line_rec.reference_customer_trx_line_id = FND_API.G_MISS_NUM THEN
7298         p_x_line_rec.reference_customer_trx_line_id := p_old_line_rec.reference_customer_trx_line_id;
7299     END IF;
7300 
7301     IF p_x_line_rec.reference_header_id = FND_API.G_MISS_NUM THEN
7302         p_x_line_rec.reference_header_id := p_old_line_rec.reference_header_id;
7303     END IF;
7304 
7305     IF p_x_line_rec.reference_line_id = FND_API.G_MISS_NUM THEN
7306         p_x_line_rec.reference_line_id := p_old_line_rec.reference_line_id;
7307     END IF;
7308 
7309     IF p_x_line_rec.reference_type = FND_API.G_MISS_CHAR THEN
7310         p_x_line_rec.reference_type := p_old_line_rec.reference_type;
7311     END IF;
7312 
7313 
7314 
7315     IF p_x_line_rec.request_date = FND_API.G_MISS_DATE THEN
7316         p_x_line_rec.request_date := p_old_line_rec.request_date;
7317     END IF;
7318 
7319     IF p_x_line_rec.request_id = FND_API.G_MISS_NUM THEN
7320         p_x_line_rec.request_id := p_old_line_rec.request_id;
7321     END IF;
7322 
7323     IF p_x_line_rec.reserved_quantity = FND_API.G_MISS_NUM THEN
7324         p_x_line_rec.reserved_quantity := p_old_line_rec.reserved_quantity;
7325     END IF;
7326 
7327 
7328 
7329     IF p_x_line_rec.return_attribute1 = FND_API.G_MISS_CHAR THEN
7330         p_x_line_rec.return_attribute1 := p_old_line_rec.return_attribute1;
7331     END IF;
7332 
7333     IF p_x_line_rec.return_attribute10 = FND_API.G_MISS_CHAR THEN
7334         p_x_line_rec.return_attribute10 := p_old_line_rec.return_attribute10;
7335     END IF;
7336 
7337     IF p_x_line_rec.return_attribute11 = FND_API.G_MISS_CHAR THEN
7338         p_x_line_rec.return_attribute11 := p_old_line_rec.return_attribute11;
7339     END IF;
7340 
7341     IF p_x_line_rec.return_attribute12 = FND_API.G_MISS_CHAR THEN
7342         p_x_line_rec.return_attribute12 := p_old_line_rec.return_attribute12;
7343     END IF;
7344 
7345     IF p_x_line_rec.return_attribute13 = FND_API.G_MISS_CHAR THEN
7346         p_x_line_rec.return_attribute13 := p_old_line_rec.return_attribute13;
7347     END IF;
7348 
7349     IF p_x_line_rec.return_attribute14 = FND_API.G_MISS_CHAR THEN
7350         p_x_line_rec.return_attribute14 := p_old_line_rec.return_attribute14;
7351     END IF;
7352 
7353     IF p_x_line_rec.return_attribute15 = FND_API.G_MISS_CHAR THEN
7354         p_x_line_rec.return_attribute15 := p_old_line_rec.return_attribute15;
7355     END IF;
7356 
7357     IF p_x_line_rec.return_attribute2 = FND_API.G_MISS_CHAR THEN
7358         p_x_line_rec.return_attribute2 := p_old_line_rec.return_attribute2;
7359     END IF;
7360 
7361     IF p_x_line_rec.return_attribute3 = FND_API.G_MISS_CHAR THEN
7362         p_x_line_rec.return_attribute3 := p_old_line_rec.return_attribute3;
7363     END IF;
7364 
7365     IF p_x_line_rec.return_attribute4 = FND_API.G_MISS_CHAR THEN
7366         p_x_line_rec.return_attribute4 := p_old_line_rec.return_attribute4;
7367     END IF;
7368 
7369     IF p_x_line_rec.return_attribute5 = FND_API.G_MISS_CHAR THEN
7370         p_x_line_rec.return_attribute5 := p_old_line_rec.return_attribute5;
7371     END IF;
7372 
7373     IF p_x_line_rec.return_attribute6 = FND_API.G_MISS_CHAR THEN
7374         p_x_line_rec.return_attribute6 := p_old_line_rec.return_attribute6;
7375     END IF;
7376 
7377     IF p_x_line_rec.return_attribute7 = FND_API.G_MISS_CHAR THEN
7378         p_x_line_rec.return_attribute7 := p_old_line_rec.return_attribute7;
7379     END IF;
7380 
7381     IF p_x_line_rec.return_attribute8 = FND_API.G_MISS_CHAR THEN
7382         p_x_line_rec.return_attribute8 := p_old_line_rec.return_attribute8;
7383     END IF;
7384 
7385     IF p_x_line_rec.return_attribute9 = FND_API.G_MISS_CHAR THEN
7386         p_x_line_rec.return_attribute9 := p_old_line_rec.return_attribute9;
7387     END IF;
7388 
7389     IF p_x_line_rec.return_context = FND_API.G_MISS_CHAR THEN
7390         p_x_line_rec.return_context := p_old_line_rec.return_context;
7391     END IF;
7392 
7393     IF p_x_line_rec.return_reason_code = FND_API.G_MISS_CHAR THEN
7394         p_x_line_rec.return_reason_code := p_old_line_rec.return_reason_code;
7395     END IF;
7396     IF p_x_line_rec.salesrep_id = FND_API.G_MISS_NUM THEN
7397         p_x_line_rec.salesrep_id := p_old_line_rec.salesrep_id;
7398     END IF;
7399 
7400     IF p_x_line_rec.rla_schedule_type_code = FND_API.G_MISS_CHAR THEN
7401         p_x_line_rec.rla_schedule_type_code := p_old_line_rec.rla_schedule_type_code;
7402     END IF;
7403 
7404     IF p_x_line_rec.schedule_arrival_date = FND_API.G_MISS_DATE THEN
7405         p_x_line_rec.schedule_arrival_date := p_old_line_rec.schedule_arrival_date;
7406     END IF;
7407 
7408     IF p_x_line_rec.schedule_ship_date = FND_API.G_MISS_DATE THEN
7409         p_x_line_rec.schedule_ship_date := p_old_line_rec.schedule_ship_date;
7410     END IF;
7411 
7412     IF p_x_line_rec.schedule_action_code = FND_API.G_MISS_CHAR THEN
7413         p_x_line_rec.schedule_action_code := p_old_line_rec.schedule_action_code;
7414     END IF;
7415 
7416     IF p_x_line_rec.schedule_status_code = FND_API.G_MISS_CHAR THEN
7417         p_x_line_rec.schedule_status_code := p_old_line_rec.schedule_status_code;
7418     END IF;
7419 
7420     IF p_x_line_rec.shipment_number = FND_API.G_MISS_NUM THEN
7421         p_x_line_rec.shipment_number := p_old_line_rec.shipment_number;
7422     END IF;
7423 
7424     IF p_x_line_rec.shipment_priority_code = FND_API.G_MISS_CHAR THEN
7425         p_x_line_rec.shipment_priority_code := p_old_line_rec.shipment_priority_code;
7426     END IF;
7427 
7428     IF p_x_line_rec.shipped_quantity = FND_API.G_MISS_NUM THEN
7429         p_x_line_rec.shipped_quantity := p_old_line_rec.shipped_quantity;
7430     END IF;
7431 
7432     IF p_x_line_rec.shipped_quantity2 = FND_API.G_MISS_NUM THEN -- OPM B1661023 04/02/01 INVCONV
7433         p_x_line_rec.shipped_quantity2 := p_old_line_rec.shipped_quantity2;
7434     END IF;
7435 
7436     IF p_x_line_rec.shipping_method_code = FND_API.G_MISS_CHAR THEN
7437         p_x_line_rec.shipping_method_code := p_old_line_rec.shipping_method_code;
7438     END IF;
7439 
7440     IF p_x_line_rec.shipping_quantity = FND_API.G_MISS_NUM THEN
7441         p_x_line_rec.shipping_quantity := p_old_line_rec.shipping_quantity;
7442     END IF;
7443 
7444     IF p_x_line_rec.shipping_quantity2 = FND_API.G_MISS_NUM THEN -- OPM B1661023 04/02/01 INVCONV
7445         p_x_line_rec.shipping_quantity2 := p_old_line_rec.shipping_quantity2;
7446     END IF;
7447 
7448     IF p_x_line_rec.shipping_quantity_uom = FND_API.G_MISS_CHAR THEN
7449         p_x_line_rec.shipping_quantity_uom := p_old_line_rec.shipping_quantity_uom;
7450     END IF;
7451 
7452     IF p_x_line_rec.ship_from_org_id = FND_API.G_MISS_NUM THEN
7453         p_x_line_rec.ship_from_org_id := p_old_line_rec.ship_from_org_id;
7454     END IF;
7455 
7456     IF p_x_line_rec.subinventory = FND_API.G_MISS_CHAR THEN
7457         p_x_line_rec.subinventory := p_old_line_rec.subinventory;
7458     END IF;
7459 
7460     IF p_x_line_rec.ship_model_complete_flag = FND_API.G_MISS_CHAR THEN
7461         p_x_line_rec.ship_model_complete_flag := p_old_line_rec.ship_model_complete_flag;
7462     END IF;
7463     IF p_x_line_rec.ship_set_id = FND_API.G_MISS_NUM THEN
7464         p_x_line_rec.ship_Set_id := p_old_line_rec.ship_set_id;
7465     END IF;
7466 
7467     IF p_x_line_rec.ship_tolerance_above = FND_API.G_MISS_NUM THEN
7468         p_x_line_rec.ship_tolerance_above := p_old_line_rec.ship_tolerance_above;
7469     END IF;
7470 
7471     IF p_x_line_rec.ship_tolerance_below = FND_API.G_MISS_NUM THEN
7472         p_x_line_rec.ship_tolerance_below := p_old_line_rec.ship_tolerance_below;
7473     END IF;
7474 
7475     IF p_x_line_rec.shippable_flag = FND_API.G_MISS_CHAR THEN
7476         p_x_line_rec.shippable_flag := p_old_line_rec.shippable_flag;
7477     END IF;
7478 
7479     IF p_x_line_rec.shipping_interfaced_flag = FND_API.G_MISS_CHAR THEN
7480         p_x_line_rec.shipping_interfaced_flag := p_old_line_rec.shipping_interfaced_flag;
7481     END IF;
7482 
7483     IF p_x_line_rec.ship_to_contact_id = FND_API.G_MISS_NUM THEN
7484         p_x_line_rec.ship_to_contact_id := p_old_line_rec.ship_to_contact_id;
7485     END IF;
7486 
7487     IF p_x_line_rec.ship_to_org_id = FND_API.G_MISS_NUM THEN
7488         p_x_line_rec.ship_to_org_id := p_old_line_rec.ship_to_org_id;
7489     END IF;
7490 
7491     IF p_x_line_rec.sold_from_org_id = FND_API.G_MISS_NUM THEN
7492         p_x_line_rec.sold_from_org_id := p_old_line_rec.sold_from_org_id;
7493     END IF;
7494 
7495     IF p_x_line_rec.sold_to_org_id = FND_API.G_MISS_NUM THEN
7496         p_x_line_rec.sold_to_org_id := p_old_line_rec.sold_to_org_id;
7497     END IF;
7498 
7499     IF p_x_line_rec.sort_order = FND_API.G_MISS_CHAR THEN
7500         p_x_line_rec.sort_order := p_old_line_rec.sort_order;
7501     END IF;
7502 
7503     IF p_x_line_rec.source_document_id = FND_API.G_MISS_NUM THEN
7504         p_x_line_rec.source_document_id := p_old_line_rec.source_document_id;
7505     END IF;
7506 
7507     IF p_x_line_rec.source_document_line_id = FND_API.G_MISS_NUM THEN
7508         p_x_line_rec.source_document_line_id := p_old_line_rec.source_document_line_id;
7509     END IF;
7510 
7511     IF p_x_line_rec.source_document_type_id = FND_API.G_MISS_NUM THEN
7512         p_x_line_rec.source_document_type_id := p_old_line_rec.source_document_type_id;
7513     END IF;
7514 
7515     IF p_x_line_rec.source_type_code = FND_API.G_MISS_CHAR THEN
7516         p_x_line_rec.source_type_code := p_old_line_rec.source_type_code;
7517     END IF;
7518     IF p_x_line_rec.split_from_line_id = FND_API.G_MISS_NUM THEN
7519         p_x_line_rec.split_from_line_id := p_old_line_rec.split_from_line_id;
7520     END IF;
7521 
7522     IF p_x_line_rec.line_set_id = FND_API.G_MISS_NUM THEN
7523         p_x_line_rec.line_set_id := p_old_line_rec.line_set_id;
7524     END IF;
7525     IF p_x_line_rec.split_by = FND_API.G_MISS_CHAR THEN
7526         p_x_line_rec.split_by := p_old_line_rec.split_by;
7527     END IF;
7528     IF p_x_line_rec.model_remnant_flag = FND_API.G_MISS_CHAR THEN
7529         p_x_line_rec.model_remnant_flag := p_old_line_rec.model_remnant_flag;
7530     END IF;
7531 
7532     IF p_x_line_rec.task_id = FND_API.G_MISS_NUM THEN
7533         p_x_line_rec.task_id := p_old_line_rec.task_id;
7534     END IF;
7535 
7536     IF p_x_line_rec.tax_code = FND_API.G_MISS_CHAR THEN
7537         p_x_line_rec.tax_code := p_old_line_rec.tax_code;
7538     END IF;
7539 
7540     IF p_x_line_rec.tax_date = FND_API.G_MISS_DATE THEN
7541         p_x_line_rec.tax_date := p_old_line_rec.tax_date;
7542     END IF;
7543 
7544     IF p_x_line_rec.tax_exempt_flag = FND_API.G_MISS_CHAR THEN
7545         p_x_line_rec.tax_exempt_flag := p_old_line_rec.tax_exempt_flag;
7546     END IF;
7547 
7548     IF p_x_line_rec.tax_exempt_number = FND_API.G_MISS_CHAR THEN
7549         p_x_line_rec.tax_exempt_number := p_old_line_rec.tax_exempt_number;
7550     END IF;
7551 
7552     IF p_x_line_rec.tax_exempt_reason_code = FND_API.G_MISS_CHAR THEN
7553         p_x_line_rec.tax_exempt_reason_code := p_old_line_rec.tax_exempt_reason_code;
7554     END IF;
7555 
7556     IF p_x_line_rec.tax_point_code = FND_API.G_MISS_CHAR THEN
7557         p_x_line_rec.tax_point_code := p_old_line_rec.tax_point_code;
7558     END IF;
7559 
7560     IF p_x_line_rec.tax_rate = FND_API.G_MISS_NUM THEN
7561         p_x_line_rec.tax_rate := p_old_line_rec.tax_rate;
7562     END IF;
7563 
7564     IF p_x_line_rec.tax_value = FND_API.G_MISS_NUM THEN
7565         p_x_line_rec.tax_value := p_old_line_rec.tax_value;
7566     END IF;
7567 
7568     IF p_x_line_rec.top_model_line_id = FND_API.G_MISS_NUM THEN
7569         p_x_line_rec.top_model_line_id := p_old_line_rec.top_model_line_id;
7570     END IF;
7571 
7572     IF p_x_line_rec.unit_list_price = FND_API.G_MISS_NUM THEN
7573         p_x_line_rec.unit_list_price := p_old_line_rec.unit_list_price;
7574     END IF;
7575 
7576     IF p_x_line_rec.unit_list_price_per_pqty = FND_API.G_MISS_NUM THEN
7577         p_x_line_rec.unit_list_price_per_pqty := p_old_line_rec.unit_list_price_per_pqty;
7578     END IF;
7579 
7580     IF p_x_line_rec.unit_selling_price = FND_API.G_MISS_NUM THEN
7581         p_x_line_rec.unit_selling_price := p_old_line_rec.unit_selling_price;
7582     END IF;
7583 
7584     IF p_x_line_rec.unit_selling_price_per_pqty = FND_API.G_MISS_NUM THEN
7585         p_x_line_rec.unit_selling_price_per_pqty := p_old_line_rec.unit_selling_price_per_pqty;
7586     END IF;
7587 
7588     IF p_x_line_rec.visible_demand_flag = FND_API.G_MISS_CHAR THEN
7589         p_x_line_rec.visible_demand_flag := p_old_line_rec.visible_demand_flag;
7590     END IF;
7591      IF p_x_line_rec.veh_cus_item_cum_key_id = FND_API.G_MISS_NUM THEN
7592         p_x_line_rec.veh_cus_item_cum_key_id := p_old_line_rec.veh_cus_item_cum_key_id;
7593     END IF;
7594 
7595     IF p_x_line_rec.first_ack_code = FND_API.G_MISS_CHAR THEN
7596         p_x_line_rec.first_ack_code := p_old_line_rec.first_ack_code;
7597     END IF;
7598 
7599     IF p_x_line_rec.first_ack_date = FND_API.G_MISS_DATE THEN
7600         p_x_line_rec.first_ack_date := p_old_line_rec.first_ack_date;
7601     END IF;
7602 
7603     IF p_x_line_rec.last_ack_code = FND_API.G_MISS_CHAR THEN
7604         p_x_line_rec.last_ack_code := p_old_line_rec.last_ack_code;
7605     END IF;
7606 
7607     IF p_x_line_rec.last_ack_date = FND_API.G_MISS_DATE THEN
7608         p_x_line_rec.last_ack_date := p_old_line_rec.last_ack_date;
7609     END IF;
7610 
7611     IF p_x_line_rec.end_item_unit_number = FND_API.G_MISS_CHAR THEN
7612         p_x_line_rec.end_item_unit_number := p_old_line_rec.end_item_unit_number;
7613     END IF;
7614 
7615     IF p_x_line_rec.shipping_instructions = FND_API.G_MISS_CHAR THEN
7616         p_x_line_rec.shipping_instructions := p_old_line_rec.shipping_instructions;
7617     END IF;
7618 
7619     IF p_x_line_rec.packing_instructions = FND_API.G_MISS_CHAR THEN
7620         p_x_line_rec.packing_instructions := p_old_line_rec.packing_instructions;
7621     END IF;
7622 
7623     -- Service Related
7624 
7625     IF p_x_line_rec.service_txn_reason_code = FND_API.G_MISS_CHAR THEN
7626         p_x_line_rec.service_txn_reason_code := p_old_line_rec.service_txn_reason_code;
7627     END IF;
7628 
7629     IF p_x_line_rec.service_txn_comments = FND_API.G_MISS_CHAR THEN
7630         p_x_line_rec.service_txn_comments := p_old_line_rec.service_txn_comments;
7631     END IF;
7632 
7633 
7634     IF p_x_line_rec.service_duration = FND_API.G_MISS_NUM THEN
7635         p_x_line_rec.service_duration := p_old_line_rec.service_duration;
7636     END IF;
7637 
7638     IF p_x_line_rec.service_period = FND_API.G_MISS_CHAR THEN
7639         p_x_line_rec.service_period := p_old_line_rec.service_period;
7640     END IF;
7641 
7642     IF p_x_line_rec.service_start_date = FND_API.G_MISS_DATE THEN
7643         p_x_line_rec.service_start_date := p_old_line_rec.service_start_date;
7644     END IF;
7645 
7646     IF p_x_line_rec.service_end_date = FND_API.G_MISS_DATE THEN
7647         p_x_line_rec.service_end_date := p_old_line_rec.service_end_date;
7648     END IF;
7649 
7650     IF p_x_line_rec.service_coterminate_flag = FND_API.G_MISS_CHAR THEN
7651         p_x_line_rec.service_coterminate_flag := p_old_line_rec.service_coterminate_flag;
7652     END IF;
7653 
7654     IF p_x_line_rec.unit_list_percent = FND_API.G_MISS_NUM THEN
7655         p_x_line_rec.unit_list_percent := p_old_line_rec.unit_list_percent;
7656     END IF;
7657 
7658     IF p_x_line_rec.unit_selling_percent = FND_API.G_MISS_NUM THEN
7659         p_x_line_rec.unit_selling_percent := p_old_line_rec.unit_selling_percent;
7660     END IF;
7661 
7662     IF p_x_line_rec.unit_percent_base_price = FND_API.G_MISS_NUM THEN
7663         p_x_line_rec.unit_percent_base_price := p_old_line_rec.unit_percent_base_price;
7664     END IF;
7665 
7666     IF p_x_line_rec.service_number = FND_API.G_MISS_NUM THEN
7667         p_x_line_rec.service_number := p_old_line_rec.service_number;
7668     END IF;
7669 
7670     IF p_x_line_rec.service_reference_type_code = FND_API.G_MISS_CHAR THEN
7671         p_x_line_rec.service_reference_type_code := p_old_line_rec.service_reference_type_code;
7672     END IF;
7673 
7674     IF p_x_line_rec.calculate_price_flag = FND_API.G_MISS_CHAR THEN
7675         p_x_line_rec.calculate_price_flag := NULL;
7676     END IF;
7677 
7678     IF p_x_line_rec.service_reference_line_id = FND_API.G_MISS_NUM THEN
7679         p_x_line_rec.service_reference_line_id := p_old_line_rec.service_reference_line_id;
7680     END IF;
7681 
7682     IF p_x_line_rec.service_reference_system_id = FND_API.G_MISS_NUM THEN
7683         p_x_line_rec.service_reference_system_id := p_old_line_rec.service_reference_system_id;
7684     END IF;
7685 
7686    -- End of Service related columns
7687 
7688    /* Marketing source code related */
7689 
7690     IF p_x_line_rec.marketing_source_code_id = FND_API.G_MISS_NUM THEN
7691         p_x_line_rec.marketing_source_code_id := p_old_line_rec.marketing_source_code_id;
7692     END IF;
7693 
7694   /* end of Marketing source code id */
7695 
7696     IF p_x_line_rec.flow_status_code = 'ENTERED' THEN
7697        -- flow_status_code is initilized to ENTERED
7698        -- QUOTING change - do not override ENTERED status with old
7699        -- value as status should be set to entered during complete
7700        -- negotiation call
7701        IF OE_Quote_Util.G_COMPLETE_NEG = 'N' THEN
7702           p_x_line_rec.flow_status_code := p_old_line_rec.flow_status_code;
7703        END IF;
7704     -- elsif added for bug 8639681
7705     ELSIF p_x_line_rec.flow_status_code = fnd_api.g_miss_char THEN
7706        p_x_line_rec.flow_status_code := p_old_line_rec.flow_status_code;
7707     END IF;
7708 
7709     -- Commitment related
7710     IF p_x_line_rec.commitment_id = FND_API.G_MISS_NUM THEN
7711        p_x_line_rec.commitment_id := p_old_line_rec.commitment_id;
7712     END IF;
7713 
7714     IF p_x_line_rec.order_source_id = FND_API.G_MISS_NUM THEN
7715    if l_debug_level > 0 then
7716     oe_debug_pub.add('OEXULINB -aksingh complete_record - order_source_id');
7717    end if;
7718         p_x_line_rec.order_source_id := p_old_line_rec.order_source_id;
7719     END IF;
7720 
7721    -- Item Substitution changes.
7722    IF p_x_line_rec.Original_Inventory_Item_Id = FND_API.G_MISS_NUM THEN
7723        p_x_line_rec.Original_Inventory_Item_Id :=
7724                          p_old_line_rec.Original_Inventory_Item_Id;
7725    END IF;
7726 
7727    IF p_x_line_rec.Original_item_identifier_Type = FND_API.G_MISS_CHAR THEN
7728        p_x_line_rec.Original_item_identifier_Type :=
7729                          p_old_line_rec.Original_item_identifier_Type;
7730    END IF;
7731 
7732    IF p_x_line_rec.Original_ordered_item_id = FND_API.G_MISS_NUM THEN
7733        p_x_line_rec.Original_ordered_item_id :=
7734                          p_old_line_rec.Original_ordered_item_id;
7735    END IF;
7736 
7737    IF p_x_line_rec.Original_ordered_item = FND_API.G_MISS_CHAR THEN
7738        p_x_line_rec.Original_ordered_item :=
7739                          p_old_line_rec.Original_ordered_item;
7740    END IF;
7741 
7742    IF p_x_line_rec.item_relationship_type = FND_API.G_MISS_NUM THEN
7743        p_x_line_rec.item_relationship_type :=
7744                          p_old_line_rec.item_relationship_type;
7745    END IF;
7746 
7747    IF p_x_line_rec.Item_substitution_type_code = FND_API.G_MISS_CHAR THEN
7748        p_x_line_rec.Item_substitution_type_code :=
7749                          p_old_line_rec.Item_substitution_type_code;
7750    END IF;
7751 
7752    IF p_x_line_rec.Late_Demand_Penalty_Factor = FND_API.G_MISS_NUM THEN
7753        p_x_line_rec.Late_Demand_Penalty_Factor :=
7754                          p_old_line_rec.Late_Demand_Penalty_Factor;
7755    END IF;
7756 
7757    IF p_x_line_rec.Override_atp_date_code = FND_API.G_MISS_CHAR THEN
7758        p_x_line_rec.Override_atp_date_code :=
7759                          p_old_line_rec.Override_atp_date_code;
7760    END IF;
7761 
7762    -- Changes for Blanket Orders
7763 
7764    IF p_x_line_rec.Blanket_Number = FND_API.G_MISS_NUM THEN
7765       p_x_line_rec.Blanket_Number := p_old_line_rec.Blanket_Number;
7766    END IF;
7767 
7768    IF p_x_line_rec.Blanket_Line_Number = FND_API.G_MISS_NUM THEN
7769       p_x_line_rec.Blanket_Line_Number := p_old_line_rec.Blanket_Line_Number;
7770    END IF;
7771 
7772    IF p_x_line_rec.Blanket_Version_Number = FND_API.G_MISS_NUM THEN
7773       p_x_line_rec.Blanket_Version_Number := p_old_line_rec.Blanket_Version_Number;
7774    END IF;
7775 
7776    -- bug 2589332
7777    IF p_x_line_rec.User_Item_Description = FND_API.G_MISS_CHAR THEN
7778       p_x_line_rec.User_Item_Description := p_old_line_rec.User_Item_Description;
7779    END IF;
7780 
7781    -- QUOTING changes
7782    IF p_x_line_rec.transaction_phase_code = FND_API.G_MISS_CHAR THEN
7783        p_x_line_rec.transaction_phase_code :=
7784                          p_old_line_rec.transaction_phase_code;
7785    END IF;
7786 
7787    IF p_x_line_rec.source_document_version_number = FND_API.G_MISS_NUM THEN
7788        p_x_line_rec.source_document_version_number :=
7789                          p_old_line_rec.source_document_version_number;
7790    END IF;
7791    -- END QUOTING changes
7792     IF p_x_line_rec.Minisite_Id = FND_API.G_MISS_NUM THEN
7793         p_x_line_rec.Minisite_Id := p_old_line_rec.Minisite_Id;
7794     END IF;
7795 
7796     IF p_x_line_rec.End_customer_Id = FND_API.G_MISS_NUM THEN
7797         p_x_line_rec.End_customer_Id := p_old_line_rec.End_customer_Id;
7798     END IF;
7799 
7800     IF p_x_line_rec.End_customer_contact_Id = FND_API.G_MISS_NUM THEN
7801         p_x_line_rec.End_customer_contact_Id := p_old_line_rec.End_customer_contact_Id;
7802     END IF;
7803 
7804     IF p_x_line_rec.End_customer_site_use_Id = FND_API.G_MISS_NUM THEN
7805         p_x_line_rec.End_customer_site_use_Id := p_old_line_rec.End_customer_site_use_Id;
7806     END IF;
7807 
7808     IF p_x_line_rec.ib_owner = FND_API.G_MISS_CHAR THEN
7809         p_x_line_rec.ib_owner := p_old_line_rec.ib_owner;
7810     END IF;
7811 
7812     IF p_x_line_rec.ib_installed_at_location = FND_API.G_MISS_CHAR THEN
7813         p_x_line_rec.ib_installed_at_location := p_old_line_rec.ib_installed_at_location;
7814     END IF;
7815 
7816     IF p_x_line_rec.ib_current_location = FND_API.G_MISS_CHAR THEN
7817         p_x_line_rec.ib_current_location := p_old_line_rec.ib_current_location;
7818     END IF;
7819 
7820     IF p_x_line_rec.supplier_signature = FND_API.G_MISS_CHAR THEN
7821         p_x_line_rec.supplier_signature := p_old_line_rec.supplier_signature;
7822     END IF;
7823 
7824     --retro{
7825     IF p_x_line_rec.retrobill_request_id = FND_API.G_MISS_NUM THEN
7826         p_x_line_rec.retrobill_request_id :=
7827                          p_old_line_rec.retrobill_request_id;
7828     END IF;
7829 
7830     --retro}
7831 
7832     IF p_x_line_rec.firm_demand_flag = FND_API.G_MISS_CHAR THEN
7833         p_x_line_rec.firm_demand_flag := p_old_line_rec.firm_demand_flag;
7834     END IF;
7835 
7836 --key Transaction Dates Project
7837     IF p_x_line_rec.order_firmed_date = FND_API.G_MISS_DATE THEN
7838         p_x_line_rec.order_firmed_date := p_old_line_rec.order_firmed_date;
7839     END IF;
7840 
7841     IF p_x_line_rec.actual_fulfillment_date = FND_API.G_MISS_DATE THEN
7842         p_x_line_rec.actual_fulfillment_date := p_old_line_rec.actual_fulfillment_date;
7843     END IF;
7844 
7845 --end
7846 
7847 
7848 -- INVCONV OPM inventory convergence
7849 	  IF p_x_line_rec.fulfilled_quantity2 = FND_API.G_MISS_NUM THEN
7850         p_x_line_rec.fulfilled_quantity2 := p_old_line_rec.fulfilled_quantity2;
7851     END IF;
7852 		IF p_x_line_rec.cancelled_quantity2 = FND_API.G_MISS_NUM THEN
7853         p_x_line_rec.cancelled_quantity2 := p_old_line_rec.cancelled_quantity2;
7854     END IF;
7855  		IF p_x_line_rec.shipping_quantity_uom2 = FND_API.G_MISS_CHAR THEN
7856         p_x_line_rec.shipping_quantity_uom2 := p_old_line_rec.shipping_quantity_uom2;
7857     END IF;
7858 
7859 
7860     IF p_x_line_rec.reserved_quantity2 = FND_API.G_MISS_NUM THEN
7861            p_x_line_rec.reserved_quantity2 := p_old_line_rec.reserved_quantity2;  -- bug 4889860
7862     END IF;
7863 
7864 
7865 -- INVCONV end
7866 
7867 
7868 /*  IF p_x_line_rec.supplier_signature_date = FND_API.G_MISS_DATE THEN
7869         p_x_line_rec.supplier_signature_date := p_old_line_rec.supplier_signature_date;
7870     END IF;
7871 
7872   IF p_x_line_rec.customer_signature = FND_API.G_MISS_CHAR THEN
7873         p_x_line_rec.customer_signature := p_old_line_rec.customer_signature;
7874     END IF;
7875 
7876   IF p_x_line_rec.customer_signature_date = FND_API.G_MISS_DATE THEN
7877         p_x_line_rec.customer_signature_date := p_old_line_rec.customer_signature_date;
7878     END IF;
7879 
7880 */
7881 
7882  IF p_x_line_rec.customer_item_net_price = FND_API.G_MISS_NUM THEN
7883       p_x_line_rec.customer_item_net_price := p_old_line_rec.customer_item_net_price; -- 5465342
7884    END IF;
7885 
7886    IF p_x_line_rec.earliest_ship_date = FND_API.G_MISS_DATE THEN
7887       p_x_line_rec.earliest_ship_date := p_old_line_rec.earliest_ship_date; -- 8497317
7888    END IF;
7889 
7890    IF p_x_line_rec.fulfillment_base = FND_API.G_MISS_CHAR THEN
7891       p_x_line_rec.fulfillment_base :=p_old_line_rec.fulfillment_base;--ER#14763609
7892    END IF;
7893 
7894 if l_debug_level > 0 then
7895     oe_debug_pub.add('Exiting OE_LINE_UTIL.COMPLETE_RECORD', 1);
7896   end if;
7897 
7898 END Complete_Record;
7899 
7900 
7901 
7902 /*-----------------------------------------------------------
7903 PROCEDURE Convert_Miss_To_Null
7904 -----------------------------------------------------------*/
7905 
7906 PROCEDURE Convert_Miss_To_Null
7907 (   p_x_line_rec                    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
7908 )
7909 IS
7910 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
7911 BEGIN
7912 
7913   if l_debug_level > 0 then
7914     oe_debug_pub.add('Entering OE_LINE_UTIL.CONVERT_MISS_TO_NULL', 1);
7915 
7916 oe_debug_pub.add('outside margin convert miss to null',1);
7917   end if;
7918 --MRG BGN
7919 IF OE_FEATURES_PVT.Is_Margin_Avail Then
7920   if l_debug_level > 0 then
7921    oe_debug_pub.add('inside margin convert miss to null',1);
7922   end if;
7923     IF p_x_line_rec.unit_cost = FND_API.G_MISS_NUM THEN
7924         p_x_line_rec.unit_cost := NULL;
7925     END IF;
7926 END IF;
7927 --MRG END
7928 
7929 
7930     IF p_x_line_rec.accounting_rule_id = FND_API.G_MISS_NUM THEN
7931         p_x_line_rec.accounting_rule_id := NULL;
7932     END IF;
7933 
7934     IF p_x_line_rec.accounting_rule_duration = FND_API.G_MISS_NUM THEN
7935         p_x_line_rec.accounting_rule_duration := NULL;
7936     END IF;
7937 
7938     IF p_x_line_rec.actual_arrival_date = FND_API.G_MISS_DATE THEN
7939         p_x_line_rec.actual_arrival_date := NULL;
7940     END IF;
7941 
7942     IF p_x_line_rec.actual_shipment_date = FND_API.G_MISS_DATE THEN
7943         p_x_line_rec.actual_shipment_date := NULL;
7944     END IF;
7945 
7946     IF p_x_line_rec.agreement_id = FND_API.G_MISS_NUM THEN
7947         p_x_line_rec.agreement_id := NULL;
7948     END IF;
7949     IF p_x_line_rec.arrival_set_id = FND_API.G_MISS_NUM THEN
7950         p_x_line_rec.arrival_set_id := NULL;
7951     END IF;
7952 
7953     IF p_x_line_rec.ato_line_id = FND_API.G_MISS_NUM THEN
7954         p_x_line_rec.ato_line_id := NULL;
7955     END IF;
7956     IF p_x_line_rec.upgraded_flag = FND_API.G_MISS_CHAR THEN
7957         p_x_line_rec.upgraded_flag := NULL;
7958     END IF;
7959 
7960     IF p_x_line_rec.attribute1 = FND_API.G_MISS_CHAR THEN
7961         p_x_line_rec.attribute1 := NULL;
7962     END IF;
7963 
7964     IF p_x_line_rec.attribute10 = FND_API.G_MISS_CHAR THEN
7965         p_x_line_rec.attribute10 := NULL;
7966     END IF;
7967 
7968     IF p_x_line_rec.attribute11 = FND_API.G_MISS_CHAR THEN
7969         p_x_line_rec.attribute11 := NULL;
7970     END IF;
7971 
7972     IF p_x_line_rec.attribute12 = FND_API.G_MISS_CHAR THEN
7973         p_x_line_rec.attribute12 := NULL;
7974     END IF;
7975 
7976     IF p_x_line_rec.attribute13 = FND_API.G_MISS_CHAR THEN
7977         p_x_line_rec.attribute13 := NULL;
7978     END IF;
7979 
7980     IF p_x_line_rec.attribute14 = FND_API.G_MISS_CHAR THEN
7981         p_x_line_rec.attribute14 := NULL;
7982     END IF;
7983 
7984     IF p_x_line_rec.attribute15 = FND_API.G_MISS_CHAR THEN
7985         p_x_line_rec.attribute15 := NULL;
7986     END IF;
7987 
7988     IF p_x_line_rec.attribute16 = FND_API.G_MISS_CHAR THEN    --For bug 2184255
7989         p_x_line_rec.attribute16 := NULL;
7990     END IF;
7991 
7992     IF p_x_line_rec.attribute17 = FND_API.G_MISS_CHAR THEN
7993         p_x_line_rec.attribute17 := NULL;
7994     END IF;
7995 
7996     IF p_x_line_rec.attribute18 = FND_API.G_MISS_CHAR THEN
7997         p_x_line_rec.attribute18 := NULL;
7998     END IF;
7999 
8000     IF p_x_line_rec.attribute19 = FND_API.G_MISS_CHAR THEN
8001         p_x_line_rec.attribute19 := NULL;
8002     END IF;
8003 
8004     IF p_x_line_rec.attribute2 = FND_API.G_MISS_CHAR THEN
8005         p_x_line_rec.attribute2 := NULL;
8006     END IF;
8007 
8008     IF p_x_line_rec.attribute20 = FND_API.G_MISS_CHAR THEN
8009         p_x_line_rec.attribute20 := NULL;
8010     END IF;
8011 
8012     IF p_x_line_rec.attribute3 = FND_API.G_MISS_CHAR THEN
8013         p_x_line_rec.attribute3 := NULL;
8014     END IF;
8015 
8016     IF p_x_line_rec.attribute4 = FND_API.G_MISS_CHAR THEN
8017         p_x_line_rec.attribute4 := NULL;
8018     END IF;
8019 
8020     IF p_x_line_rec.attribute5 = FND_API.G_MISS_CHAR THEN
8021         p_x_line_rec.attribute5 := NULL;
8022     END IF;
8023 
8024     IF p_x_line_rec.attribute6 = FND_API.G_MISS_CHAR THEN
8025         p_x_line_rec.attribute6 := NULL;
8026     END IF;
8027 
8028     IF p_x_line_rec.attribute7 = FND_API.G_MISS_CHAR THEN
8029         p_x_line_rec.attribute7 := NULL;
8030     END IF;
8031 
8032     IF p_x_line_rec.attribute8 = FND_API.G_MISS_CHAR THEN
8033         p_x_line_rec.attribute8 := NULL;
8034     END IF;
8035 
8036     IF p_x_line_rec.attribute9 = FND_API.G_MISS_CHAR THEN
8037         p_x_line_rec.attribute9 := NULL;
8038     END IF;
8039 
8040     IF p_x_line_rec.auto_selected_quantity = FND_API.G_MISS_NUM THEN
8041         p_x_line_rec.auto_selected_quantity := NULL;
8042     END IF;
8043      IF p_x_line_rec.authorized_to_ship_flag = FND_API.G_MISS_CHAR THEN
8044         p_x_line_rec.authorized_to_ship_flag := NULL;
8045     END IF;
8046 
8047     IF p_x_line_rec.booked_flag = FND_API.G_MISS_CHAR THEN
8048         p_x_line_rec.booked_flag := NULL;
8049     END IF;
8050 
8051     IF p_x_line_rec.cancelled_flag = FND_API.G_MISS_CHAR THEN
8052         p_x_line_rec.cancelled_flag := NULL;
8053     END IF;
8054 
8055     IF p_x_line_rec.cancelled_quantity = FND_API.G_MISS_NUM THEN
8056         p_x_line_rec.cancelled_quantity := NULL;
8057     END IF;
8058 
8059     IF p_x_line_rec.component_code = FND_API.G_MISS_CHAR THEN
8060         p_x_line_rec.component_code := NULL;
8061     END IF;
8062 
8063     IF p_x_line_rec.component_number = FND_API.G_MISS_NUM THEN
8064         p_x_line_rec.component_number := NULL;
8065     END IF;
8066 
8067     IF p_x_line_rec.component_sequence_id = FND_API.G_MISS_NUM THEN
8068         p_x_line_rec.component_sequence_id := NULL;
8069     END IF;
8070 
8071     IF p_x_line_rec.config_header_id = FND_API.G_MISS_NUM THEN
8072         p_x_line_rec.config_header_id := NULL;
8073     END IF;
8074 
8075     IF p_x_line_rec.config_rev_nbr = FND_API.G_MISS_NUM THEN
8076         p_x_line_rec.config_rev_nbr := NULL;
8077     END IF;
8078 
8079     IF p_x_line_rec.config_display_sequence = FND_API.G_MISS_NUM THEN
8080         p_x_line_rec.config_display_sequence := NULL;
8081     END IF;
8082 
8083     IF p_x_line_rec.configuration_id = FND_API.G_MISS_NUM THEN
8084         p_x_line_rec.configuration_id := NULL;
8085     END IF;
8086 
8087     IF p_x_line_rec.context = FND_API.G_MISS_CHAR THEN
8088         p_x_line_rec.context := NULL;
8089     END IF;
8090     --recurring charges
8091     IF p_x_line_rec.charge_periodicity_code = FND_API.G_MISS_CHAR THEN
8092        p_x_line_rec.charge_periodicity_code := NULL;
8093     END IF;
8094 
8095     --Customer Acceptance
8096      IF p_x_line_rec.CONTINGENCY_ID  = FND_API.G_MISS_NUM THEN
8097         p_x_line_rec.CONTINGENCY_ID  := NULL  ;
8098     END IF;
8099      IF p_x_line_rec.REVREC_EVENT_CODE = FND_API.G_MISS_CHAR THEN
8100         p_x_line_rec.REVREC_EVENT_CODE:= NULL  ;
8101     END IF;
8102      IF p_x_line_rec.REVREC_EXPIRATION_DAYS = FND_API.G_MISS_NUM THEN
8103         p_x_line_rec.REVREC_EXPIRATION_DAYS:= NULL  ;
8104     END IF;
8105      IF p_x_line_rec.ACCEPTED_QUANTITY = FND_API.G_MISS_NUM THEN
8106         p_x_line_rec.ACCEPTED_QUANTITY:= NULL  ;
8107     END IF;
8108      IF p_x_line_rec.REVREC_COMMENTS = FND_API.G_MISS_CHAR THEN
8109         p_x_line_rec.REVREC_COMMENTS:= NULL  ;
8110     END IF;
8111      IF p_x_line_rec.REVREC_SIGNATURE = FND_API.G_MISS_CHAR THEN
8112         p_x_line_rec.REVREC_SIGNATURE:= NULL  ;
8113     END IF;
8114      IF p_x_line_rec.REVREC_SIGNATURE_DATE = FND_API.G_MISS_DATE THEN
8115         p_x_line_rec.REVREC_SIGNATURE_DATE:= NULL  ;
8116     END IF;
8117      IF p_x_line_rec.ACCEPTED_BY = FND_API.G_MISS_NUM THEN
8118         p_x_line_rec.ACCEPTED_BY:= NULL  ;
8119     END IF;
8120      IF p_x_line_rec.REVREC_REFERENCE_DOCUMENT = FND_API.G_MISS_CHAR THEN
8121         p_x_line_rec.REVREC_REFERENCE_DOCUMENT:= NULL  ;
8122     END IF;
8123      IF p_x_line_rec.REVREC_IMPLICIT_FLAG = FND_API.G_MISS_CHAR THEN
8124         p_x_line_rec.REVREC_IMPLICIT_FLAG:= NULL  ;
8125     END IF;
8126    --Customer Acceptance Changes End
8127 
8128 	 -- sol_ord_er #16014165
8129 
8130 	IF p_x_line_rec.service_bill_option_code  = FND_API.G_MISS_CHAR THEN
8131 	p_x_line_rec.service_bill_option_code := NULL;
8132 	END IF;
8133 
8134 	IF p_x_line_rec.service_bill_profile_id  = FND_API.G_MISS_NUM THEN
8135 	p_x_line_rec.service_bill_profile_id := NULL;
8136 	END IF;
8137 
8138 	IF p_x_line_rec.service_cov_template_id  = FND_API.G_MISS_NUM THEN
8139 	p_x_line_rec.service_cov_template_id := NULL;
8140 	END IF;
8141 
8142 	IF p_x_line_rec.service_subs_template_id  = FND_API.G_MISS_NUM THEN
8143 	p_x_line_rec.service_subs_template_id := NULL;
8144 	END IF;
8145 
8146 	IF p_x_line_rec.subscription_enable_flag  = FND_API.G_MISS_CHAR THEN
8147 	p_x_line_rec.subscription_enable_flag :=  NULL;
8148 	END IF;
8149 
8150 	IF p_x_line_rec.SERVICE_FIRST_PERIOD_AMOUNT  = FND_API.G_MISS_NUM THEN
8151 	p_x_line_rec.SERVICE_FIRST_PERIOD_AMOUNT := NULL;
8152 	END IF;
8153 
8154 	IF p_x_line_rec.SERVICE_FIRST_PERIOD_ENDDATE  = FND_API.G_MISS_DATE THEN
8155 	p_x_line_rec.SERVICE_FIRST_PERIOD_ENDDATE := NULL;
8156 	END IF;
8157 	-- sol_ord_er #16014165 end
8158 
8159     IF p_x_line_rec.created_by = FND_API.G_MISS_NUM THEN
8160         p_x_line_rec.created_by := NULL;
8161     END IF;
8162 
8163     IF p_x_line_rec.creation_date = FND_API.G_MISS_DATE THEN
8164         p_x_line_rec.creation_date := NULL;
8165     END IF;
8166 
8167     IF p_x_line_rec.credit_invoice_line_id = FND_API.G_MISS_NUM THEN
8168         p_x_line_rec.credit_invoice_line_id := NULL;
8169     END IF;
8170 
8171     IF p_x_line_rec.customer_dock_code = FND_API.G_MISS_CHAR THEN
8172         p_x_line_rec.customer_dock_code := NULL;
8173     END IF;
8174 
8175     IF p_x_line_rec.customer_job = FND_API.G_MISS_CHAR THEN
8176         p_x_line_rec.customer_job := NULL;
8177     END IF;
8178 
8179     IF p_x_line_rec.customer_production_line = FND_API.G_MISS_CHAR THEN
8180         p_x_line_rec.customer_production_line := NULL;
8181     END IF;
8182 
8183     IF p_x_line_rec.cust_production_seq_num = FND_API.G_MISS_CHAR THEN
8184         p_x_line_rec.cust_production_seq_num := NULL;
8185     END IF;
8186 
8187     IF p_x_line_rec.customer_trx_line_id = FND_API.G_MISS_NUM THEN
8188         p_x_line_rec.customer_trx_line_id := NULL;
8189     END IF;
8190 
8191     IF p_x_line_rec.cust_model_serial_number = FND_API.G_MISS_CHAR THEN
8192         p_x_line_rec.cust_model_serial_number := NULL;
8193     END IF;
8194 
8195     IF p_x_line_rec.cust_po_number = FND_API.G_MISS_CHAR THEN
8196         p_x_line_rec.cust_po_number := NULL;
8197     END IF;
8198 
8199     IF p_x_line_rec.customer_line_number = FND_API.G_MISS_CHAR THEN
8200         p_x_line_rec.customer_line_number := NULL;
8201     END IF;
8202 
8203     IF p_x_line_rec.customer_shipment_number = FND_API.G_MISS_CHAR THEN
8204         p_x_line_rec.customer_shipment_number := NULL;
8205     END IF;
8206 
8207     IF p_x_line_rec.delivery_lead_time = FND_API.G_MISS_NUM THEN
8208         p_x_line_rec.delivery_lead_time := NULL;
8209     END IF;
8210 
8211     IF p_x_line_rec.deliver_to_contact_id = FND_API.G_MISS_NUM THEN
8212         p_x_line_rec.deliver_to_contact_id := NULL;
8213     END IF;
8214 
8215     IF p_x_line_rec.deliver_to_org_id = FND_API.G_MISS_NUM THEN
8216         p_x_line_rec.deliver_to_org_id := NULL;
8217     END IF;
8218 
8219     IF p_x_line_rec.demand_bucket_type_code = FND_API.G_MISS_CHAR THEN
8220         p_x_line_rec.demand_bucket_type_code := NULL;
8221     END IF;
8222 
8223     IF p_x_line_rec.demand_class_code = FND_API.G_MISS_CHAR THEN
8224         p_x_line_rec.demand_class_code := NULL;
8225     END IF;
8226 
8227     IF p_x_line_rec.dep_plan_required_flag = FND_API.G_MISS_CHAR THEN
8228         p_x_line_rec.dep_plan_required_flag := NULL;
8229     END IF;
8230 
8231 
8232     IF p_x_line_rec.earliest_acceptable_date = FND_API.G_MISS_DATE THEN
8233         p_x_line_rec.earliest_acceptable_date := NULL;
8234     END IF;
8235 
8236     IF p_x_line_rec.explosion_date = FND_API.G_MISS_DATE THEN
8237         p_x_line_rec.explosion_date := NULL;
8238     END IF;
8239 
8240     IF p_x_line_rec.fob_point_code = FND_API.G_MISS_CHAR THEN
8241         p_x_line_rec.fob_point_code := NULL;
8242     END IF;
8243 
8244     IF p_x_line_rec.freight_carrier_code = FND_API.G_MISS_CHAR THEN
8245         p_x_line_rec.freight_carrier_code := NULL;
8246     END IF;
8247 
8248     IF p_x_line_rec.freight_terms_code = FND_API.G_MISS_CHAR THEN
8249         p_x_line_rec.freight_terms_code := NULL;
8250     END IF;
8251 
8252     IF p_x_line_rec.fulfilled_quantity = FND_API.G_MISS_NUM THEN
8253         p_x_line_rec.fulfilled_quantity := NULL;
8254     END IF;
8255 
8256     IF p_x_line_rec.fulfilled_flag = FND_API.G_MISS_CHAR THEN
8257         p_x_line_rec.fulfilled_flag := NULL;
8258     END IF;
8259 
8260     IF p_x_line_rec.fulfillment_method_code = FND_API.G_MISS_CHAR THEN
8261         p_x_line_rec.fulfillment_method_code := NULL;
8262     END IF;
8263 
8264     IF p_x_line_rec.fulfillment_date = FND_API.G_MISS_DATE THEN
8265         p_x_line_rec.fulfillment_date := NULL;
8266     END IF;
8267 
8268     IF p_x_line_rec.global_attribute1 = FND_API.G_MISS_CHAR THEN
8269         p_x_line_rec.global_attribute1 := NULL;
8270     END IF;
8271 
8272     IF p_x_line_rec.global_attribute10 = FND_API.G_MISS_CHAR THEN
8273         p_x_line_rec.global_attribute10 := NULL;
8274     END IF;
8275 
8276     IF p_x_line_rec.global_attribute11 = FND_API.G_MISS_CHAR THEN
8277         p_x_line_rec.global_attribute11 := NULL;
8278     END IF;
8279 
8280     IF p_x_line_rec.global_attribute12 = FND_API.G_MISS_CHAR THEN
8281         p_x_line_rec.global_attribute12 := NULL;
8282     END IF;
8283 
8284     IF p_x_line_rec.global_attribute13 = FND_API.G_MISS_CHAR THEN
8285         p_x_line_rec.global_attribute13 := NULL;
8286     END IF;
8287 
8288     IF p_x_line_rec.global_attribute14 = FND_API.G_MISS_CHAR THEN
8289         p_x_line_rec.global_attribute14 := NULL;
8290     END IF;
8291 
8292     IF p_x_line_rec.global_attribute15 = FND_API.G_MISS_CHAR THEN
8293         p_x_line_rec.global_attribute15 := NULL;
8294     END IF;
8295 
8296     IF p_x_line_rec.global_attribute16 = FND_API.G_MISS_CHAR THEN
8297         p_x_line_rec.global_attribute16 := NULL;
8298     END IF;
8299 
8300     IF p_x_line_rec.global_attribute17 = FND_API.G_MISS_CHAR THEN
8301         p_x_line_rec.global_attribute17 := NULL;
8302     END IF;
8303 
8304     IF p_x_line_rec.global_attribute18 = FND_API.G_MISS_CHAR THEN
8305         p_x_line_rec.global_attribute18 := NULL;
8306     END IF;
8307 
8308     IF p_x_line_rec.global_attribute19 = FND_API.G_MISS_CHAR THEN
8309         p_x_line_rec.global_attribute19 := NULL;
8310     END IF;
8311 
8312     IF p_x_line_rec.global_attribute2 = FND_API.G_MISS_CHAR THEN
8313         p_x_line_rec.global_attribute2 := NULL;
8314     END IF;
8315 
8316     IF p_x_line_rec.global_attribute20 = FND_API.G_MISS_CHAR THEN
8317         p_x_line_rec.global_attribute20 := NULL;
8318     END IF;
8319 
8320     IF p_x_line_rec.global_attribute3 = FND_API.G_MISS_CHAR THEN
8321         p_x_line_rec.global_attribute3 := NULL;
8322     END IF;
8323 
8324     IF p_x_line_rec.global_attribute4 = FND_API.G_MISS_CHAR THEN
8325         p_x_line_rec.global_attribute4 := NULL;
8326     END IF;
8327 
8328     IF p_x_line_rec.global_attribute5 = FND_API.G_MISS_CHAR THEN
8329         p_x_line_rec.global_attribute5 := NULL;
8330     END IF;
8331 
8332     IF p_x_line_rec.global_attribute6 = FND_API.G_MISS_CHAR THEN
8333         p_x_line_rec.global_attribute6 := NULL;
8334     END IF;
8335 
8336     IF p_x_line_rec.global_attribute7 = FND_API.G_MISS_CHAR THEN
8337         p_x_line_rec.global_attribute7 := NULL;
8338     END IF;
8339 
8340     IF p_x_line_rec.global_attribute8 = FND_API.G_MISS_CHAR THEN
8341         p_x_line_rec.global_attribute8 := NULL;
8342     END IF;
8343 
8344     IF p_x_line_rec.global_attribute9 = FND_API.G_MISS_CHAR THEN
8345         p_x_line_rec.global_attribute9 := NULL;
8346     END IF;
8347 
8348     IF p_x_line_rec.global_attribute_category = FND_API.G_MISS_CHAR THEN
8349         p_x_line_rec.global_attribute_category := NULL;
8350     END IF;
8351 
8352     IF p_x_line_rec.header_id = FND_API.G_MISS_NUM THEN
8353         p_x_line_rec.header_id := NULL;
8354     END IF;
8355 
8356     IF p_x_line_rec.industry_attribute1 = FND_API.G_MISS_CHAR THEN
8357         p_x_line_rec.industry_attribute1 := NULL;
8358     END IF;
8359 
8360     IF p_x_line_rec.industry_attribute10 = FND_API.G_MISS_CHAR THEN
8361         p_x_line_rec.industry_attribute10 := NULL;
8362     END IF;
8363 
8364     IF p_x_line_rec.industry_attribute11 = FND_API.G_MISS_CHAR THEN
8365         p_x_line_rec.industry_attribute11 := NULL;
8366     END IF;
8367 
8368     IF p_x_line_rec.industry_attribute12 = FND_API.G_MISS_CHAR THEN
8369         p_x_line_rec.industry_attribute12 := NULL;
8370     END IF;
8371 
8372     IF p_x_line_rec.industry_attribute13 = FND_API.G_MISS_CHAR THEN
8373         p_x_line_rec.industry_attribute13 := NULL;
8374     END IF;
8375 
8376     IF p_x_line_rec.industry_attribute14 = FND_API.G_MISS_CHAR THEN
8377         p_x_line_rec.industry_attribute14 := NULL;
8378     END IF;
8379 
8380     IF p_x_line_rec.industry_attribute15 = FND_API.G_MISS_CHAR THEN
8381         p_x_line_rec.industry_attribute15 := NULL;
8382     END IF;
8383 
8384 IF p_x_line_rec.industry_attribute16 = FND_API.G_MISS_CHAR THEN
8385         p_x_line_rec.industry_attribute16 := NULL;
8386     END IF;
8387 IF p_x_line_rec.industry_attribute17 = FND_API.G_MISS_CHAR THEN
8388         p_x_line_rec.industry_attribute17 := NULL;
8389     END IF;
8390 IF p_x_line_rec.industry_attribute18 = FND_API.G_MISS_CHAR THEN
8391         p_x_line_rec.industry_attribute18 := NULL;
8392     END IF;
8393 IF p_x_line_rec.industry_attribute19 = FND_API.G_MISS_CHAR THEN
8394         p_x_line_rec.industry_attribute19 := NULL;
8395     END IF;
8396 IF p_x_line_rec.industry_attribute20 = FND_API.G_MISS_CHAR THEN
8397         p_x_line_rec.industry_attribute20 := NULL;
8398     END IF;
8399 IF p_x_line_rec.industry_attribute21 = FND_API.G_MISS_CHAR THEN
8400         p_x_line_rec.industry_attribute21 := NULL;
8401     END IF;
8402 IF p_x_line_rec.industry_attribute22 = FND_API.G_MISS_CHAR THEN
8403         p_x_line_rec.industry_attribute22 := NULL;
8404     END IF;
8405 IF p_x_line_rec.industry_attribute23 = FND_API.G_MISS_CHAR THEN
8406         p_x_line_rec.industry_attribute23 := NULL;
8407     END IF;
8408 IF p_x_line_rec.industry_attribute24 = FND_API.G_MISS_CHAR THEN
8409         p_x_line_rec.industry_attribute24 := NULL;
8410     END IF;
8411 IF p_x_line_rec.industry_attribute25 = FND_API.G_MISS_CHAR THEN
8412         p_x_line_rec.industry_attribute25 := NULL;
8413     END IF;
8414 IF p_x_line_rec.industry_attribute26 = FND_API.G_MISS_CHAR THEN
8415         p_x_line_rec.industry_attribute26 := NULL;
8416     END IF;
8417 IF p_x_line_rec.industry_attribute27 = FND_API.G_MISS_CHAR THEN
8418         p_x_line_rec.industry_attribute27 := NULL;
8419     END IF;
8420 IF p_x_line_rec.industry_attribute28 = FND_API.G_MISS_CHAR THEN
8421         p_x_line_rec.industry_attribute28 := NULL;
8422     END IF;
8423  IF p_x_line_rec.industry_attribute29 = FND_API.G_MISS_CHAR THEN
8424         p_x_line_rec.industry_attribute29 := NULL;
8425     END IF;
8426 IF p_x_line_rec.industry_attribute30 = FND_API.G_MISS_CHAR THEN
8427         p_x_line_rec.industry_attribute30 := NULL;
8428     END IF;
8429 
8430 
8431     IF p_x_line_rec.industry_attribute2 = FND_API.G_MISS_CHAR THEN
8432         p_x_line_rec.industry_attribute2 := NULL;
8433     END IF;
8434 
8435     IF p_x_line_rec.industry_attribute3 = FND_API.G_MISS_CHAR THEN
8436         p_x_line_rec.industry_attribute3 := NULL;
8437     END IF;
8438 
8439     IF p_x_line_rec.industry_attribute4 = FND_API.G_MISS_CHAR THEN
8440         p_x_line_rec.industry_attribute4 := NULL;
8441     END IF;
8442 
8443     IF p_x_line_rec.industry_attribute5 = FND_API.G_MISS_CHAR THEN
8444         p_x_line_rec.industry_attribute5 := NULL;
8445     END IF;
8446 
8447     IF p_x_line_rec.industry_attribute6 = FND_API.G_MISS_CHAR THEN
8448         p_x_line_rec.industry_attribute6 := NULL;
8449     END IF;
8450 
8451     IF p_x_line_rec.industry_attribute7 = FND_API.G_MISS_CHAR THEN
8452         p_x_line_rec.industry_attribute7 := NULL;
8453     END IF;
8454 
8455     IF p_x_line_rec.industry_attribute8 = FND_API.G_MISS_CHAR THEN
8456         p_x_line_rec.industry_attribute8 := NULL;
8457     END IF;
8458 
8459     IF p_x_line_rec.industry_attribute9 = FND_API.G_MISS_CHAR THEN
8460         p_x_line_rec.industry_attribute9 := NULL;
8461     END IF;
8462 
8463     IF p_x_line_rec.industry_context = FND_API.G_MISS_CHAR THEN
8464         p_x_line_rec.industry_context := NULL;
8465     END IF;
8466 
8467     /* TP_ATTRIBUTE */
8468     IF p_x_line_rec.tp_context = FND_API.G_MISS_CHAR THEN
8469         p_x_line_rec.tp_context := NULL;
8470     END IF;
8471     IF p_x_line_rec.tp_attribute1 = FND_API.G_MISS_CHAR THEN
8472         p_x_line_rec.tp_attribute1 := NULL;
8473     END IF;
8474     IF p_x_line_rec.tp_attribute2 = FND_API.G_MISS_CHAR THEN
8475         p_x_line_rec.tp_attribute2 := NULL;
8476     END IF;
8477     IF p_x_line_rec.tp_attribute3 = FND_API.G_MISS_CHAR THEN
8478         p_x_line_rec.tp_attribute3 := NULL;
8479     END IF;
8480     IF p_x_line_rec.tp_attribute4 = FND_API.G_MISS_CHAR THEN
8481         p_x_line_rec.tp_attribute4 := NULL;
8482     END IF;
8483     IF p_x_line_rec.tp_attribute5 = FND_API.G_MISS_CHAR THEN
8484         p_x_line_rec.tp_attribute5 := NULL;
8485     END IF;
8486     IF p_x_line_rec.tp_attribute6 = FND_API.G_MISS_CHAR THEN
8487         p_x_line_rec.tp_attribute6 := NULL;
8488     END IF;
8489     IF p_x_line_rec.tp_attribute7 = FND_API.G_MISS_CHAR THEN
8490         p_x_line_rec.tp_attribute7 := NULL;
8491     END IF;
8492     IF p_x_line_rec.tp_attribute8 = FND_API.G_MISS_CHAR THEN
8493         p_x_line_rec.tp_attribute8 := NULL;
8494     END IF;
8495     IF p_x_line_rec.tp_attribute9 = FND_API.G_MISS_CHAR THEN
8496         p_x_line_rec.tp_attribute9 := NULL;
8497     END IF;
8498     IF p_x_line_rec.tp_attribute10 = FND_API.G_MISS_CHAR THEN
8499         p_x_line_rec.tp_attribute10 := NULL;
8500     END IF;
8501     IF p_x_line_rec.tp_attribute11 = FND_API.G_MISS_CHAR THEN
8502         p_x_line_rec.tp_attribute11 := NULL;
8503     END IF;
8504     IF p_x_line_rec.tp_attribute12 = FND_API.G_MISS_CHAR THEN
8505         p_x_line_rec.tp_attribute12 := NULL;
8506     END IF;
8507     IF p_x_line_rec.tp_attribute13 = FND_API.G_MISS_CHAR THEN
8508         p_x_line_rec.tp_attribute13 := NULL;
8509     END IF;
8510     IF p_x_line_rec.tp_attribute14 = FND_API.G_MISS_CHAR THEN
8511         p_x_line_rec.tp_attribute14 := NULL;
8512     END IF;
8513     IF p_x_line_rec.tp_attribute15 = FND_API.G_MISS_CHAR THEN
8514         p_x_line_rec.tp_attribute15 := NULL;
8515     END IF;
8516 
8517 
8518     IF p_x_line_rec.intermed_ship_to_contact_id = FND_API.G_MISS_NUM THEN
8519         p_x_line_rec.intermed_ship_to_contact_id := NULL;
8520     END IF;
8521 
8522     IF p_x_line_rec.intermed_ship_to_org_id = FND_API.G_MISS_NUM THEN
8523         p_x_line_rec.intermed_ship_to_org_id := NULL;
8524     END IF;
8525 
8526     IF p_x_line_rec.inventory_item_id = FND_API.G_MISS_NUM THEN
8527         p_x_line_rec.inventory_item_id := NULL;
8528     END IF;
8529 
8530     IF p_x_line_rec.invoice_interface_status_code = FND_API.G_MISS_CHAR THEN
8531         p_x_line_rec.invoice_interface_status_code := NULL;
8532     END IF;
8533 
8534 
8535 
8536     IF p_x_line_rec.invoice_to_contact_id = FND_API.G_MISS_NUM THEN
8537         p_x_line_rec.invoice_to_contact_id := NULL;
8538     END IF;
8539 
8540     IF p_x_line_rec.invoiced_quantity = FND_API.G_MISS_NUM THEN
8541         p_x_line_rec.invoiced_quantity := NULL;
8542     END IF;
8543 
8544     IF p_x_line_rec.invoice_to_org_id = FND_API.G_MISS_NUM THEN
8545         p_x_line_rec.invoice_to_org_id := NULL;
8546     END IF;
8547 
8548     IF p_x_line_rec.invoicing_rule_id = FND_API.G_MISS_NUM THEN
8549         p_x_line_rec.invoicing_rule_id := NULL;
8550     END IF;
8551 
8552     IF p_x_line_rec.ordered_item_id = FND_API.G_MISS_NUM THEN
8553         p_x_line_rec.ordered_item_id := NULL;
8554     END IF;
8555 
8556     IF p_x_line_rec.item_identifier_type = FND_API.G_MISS_CHAR THEN
8557         p_x_line_rec.item_identifier_type := NULL;
8558     END IF;
8559 
8560     IF p_x_line_rec.ordered_item = FND_API.G_MISS_CHAR THEN
8561         p_x_line_rec.ordered_item := NULL;
8562     END IF;
8563 
8564     IF p_x_line_rec.item_revision = FND_API.G_MISS_CHAR THEN
8565         p_x_line_rec.item_revision := NULL;
8566     END IF;
8567 
8568     IF p_x_line_rec.item_type_code = FND_API.G_MISS_CHAR THEN
8569         p_x_line_rec.item_type_code := NULL;
8570     END IF;
8571 
8572     IF p_x_line_rec.last_updated_by = FND_API.G_MISS_NUM THEN
8573         p_x_line_rec.last_updated_by := NULL;
8574     END IF;
8575 
8576     IF p_x_line_rec.last_update_date = FND_API.G_MISS_DATE THEN
8577         p_x_line_rec.last_update_date := NULL;
8578     END IF;
8579 
8580     IF p_x_line_rec.last_update_login = FND_API.G_MISS_NUM THEN
8581         p_x_line_rec.last_update_login := NULL;
8582     END IF;
8583 
8584     IF p_x_line_rec.latest_acceptable_date = FND_API.G_MISS_DATE THEN
8585         p_x_line_rec.latest_acceptable_date := NULL;
8586     END IF;
8587 
8588     IF p_x_line_rec.line_category_code = FND_API.G_MISS_CHAR THEN
8589         p_x_line_rec.line_category_code := NULL;
8590     END IF;
8591 
8592     IF p_x_line_rec.line_id = FND_API.G_MISS_NUM THEN
8593         p_x_line_rec.line_id := NULL;
8594     END IF;
8595 
8596     IF p_x_line_rec.line_number = FND_API.G_MISS_NUM THEN
8597         p_x_line_rec.line_number := NULL;
8598     END IF;
8599 
8600     IF p_x_line_rec.line_type_id = FND_API.G_MISS_NUM THEN
8601         p_x_line_rec.line_type_id := NULL;
8602     END IF;
8603 
8604     IF p_x_line_rec.link_to_line_id = FND_API.G_MISS_NUM THEN
8605         p_x_line_rec.link_to_line_id := NULL;
8606     END IF;
8607 
8608     IF p_x_line_rec.model_group_number = FND_API.G_MISS_NUM THEN
8609         p_x_line_rec.model_group_number := NULL;
8610     END IF;
8611 
8612     IF p_x_line_rec.mfg_component_sequence_id = FND_API.G_MISS_NUM THEN
8613         p_x_line_rec.mfg_component_sequence_id := NULL;
8614     END IF;
8615 
8616     IF p_x_line_rec.mfg_lead_time = FND_API.G_MISS_NUM THEN
8617         p_x_line_rec.mfg_lead_time := NULL;
8618     END IF;
8619 
8620     IF p_x_line_rec.open_flag = FND_API.G_MISS_CHAR THEN
8621         p_x_line_rec.open_flag := NULL;
8622     END IF;
8623 
8624     IF p_x_line_rec.option_flag = FND_API.G_MISS_CHAR THEN
8625         p_x_line_rec.option_flag := NULL;
8626     END IF;
8627 
8628     IF p_x_line_rec.option_number = FND_API.G_MISS_NUM THEN
8629         p_x_line_rec.option_number := NULL;
8630     END IF;
8631 
8632     IF p_x_line_rec.ordered_quantity = FND_API.G_MISS_NUM THEN
8633         p_x_line_rec.ordered_quantity := NULL;
8634     END IF;
8635 
8636     IF p_x_line_rec.order_quantity_uom = FND_API.G_MISS_CHAR THEN
8637         p_x_line_rec.order_quantity_uom := NULL;
8638     END IF;
8639 
8640     -- OPM 02/JUN/00 - Deal with process attributes INVCONV
8641     -- ============================================
8642     IF p_x_line_rec.ordered_quantity2 = FND_API.G_MISS_NUM THEN
8643         p_x_line_rec.ordered_quantity2 := NULL;
8644     END IF;
8645 
8646     IF p_x_line_rec.ordered_quantity_uom2 = FND_API.G_MISS_CHAR THEN
8647         p_x_line_rec.ordered_quantity_uom2 := NULL;
8648     END IF;
8649     -- OPM 02/JUN/00 - END
8650     -- ===================
8651 
8652     IF p_x_line_rec.org_id = FND_API.G_MISS_NUM THEN
8653         p_x_line_rec.org_id := NULL;
8654     END IF;
8655 
8656     IF p_x_line_rec.orig_sys_document_ref = FND_API.G_MISS_CHAR THEN
8657         p_x_line_rec.orig_sys_document_ref := NULL;
8658     END IF;
8659 
8660     IF p_x_line_rec.orig_sys_line_ref = FND_API.G_MISS_CHAR THEN
8661         p_x_line_rec.orig_sys_line_ref := NULL;
8662     END IF;
8663 
8664     IF p_x_line_rec.orig_sys_shipment_ref = FND_API.G_MISS_CHAR THEN
8665         p_x_line_rec.orig_sys_shipment_ref := NULL;
8666     END IF;
8667 
8668 -- Override List Price
8669     IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
8670        IF p_x_line_rec.original_list_price = FND_API.G_MISS_NUM THEN
8671           p_x_line_rec.original_list_price:= NULL;
8672        END IF;
8673     END IF;
8674 -- Override List Price
8675 
8676     IF p_x_line_rec.over_ship_reason_code = FND_API.G_MISS_CHAR THEN
8677         p_x_line_rec.over_ship_reason_code := NULL;
8678     END IF;
8679     IF p_x_line_rec.over_ship_resolved_flag = FND_API.G_MISS_CHAR THEN
8680         p_x_line_rec.over_ship_resolved_flag := NULL;
8681     END IF;
8682 
8683     IF p_x_line_rec.payment_term_id = FND_API.G_MISS_NUM THEN
8684         p_x_line_rec.payment_term_id := NULL;
8685     END IF;
8686 
8687     IF p_x_line_rec.planning_priority = FND_API.G_MISS_NUM THEN
8688         p_x_line_rec.planning_priority := NULL;
8689     END IF;
8690 
8691     -- OPM 02/JUN/00 - Deal with process attributes INVCONV
8692     -- ============================================
8693     IF p_x_line_rec.preferred_grade = FND_API.G_MISS_CHAR THEN
8694         p_x_line_rec.preferred_grade := NULL;
8695     END IF;
8696     -- OPM 02/JUN/00 - END
8697     -- ===================
8698 
8699     IF p_x_line_rec.price_list_id = FND_API.G_MISS_NUM THEN
8700         p_x_line_rec.price_list_id := NULL;
8701     END IF;
8702 
8703      IF p_x_line_rec.price_request_code = FND_API.G_MISS_CHAR THEN -- PROMOTIONS SEP/01
8704         p_x_line_rec.price_request_code := NULL;
8705     END IF;
8706 
8707     IF p_x_line_rec.pricing_attribute1 = FND_API.G_MISS_CHAR THEN
8708         p_x_line_rec.pricing_attribute1 := NULL;
8709     END IF;
8710 
8711     IF p_x_line_rec.pricing_attribute10 = FND_API.G_MISS_CHAR THEN
8712         p_x_line_rec.pricing_attribute10 := NULL;
8713     END IF;
8714 
8715     IF p_x_line_rec.pricing_attribute2 = FND_API.G_MISS_CHAR THEN
8716         p_x_line_rec.pricing_attribute2 := NULL;
8717     END IF;
8718 
8719     IF p_x_line_rec.pricing_attribute3 = FND_API.G_MISS_CHAR THEN
8720         p_x_line_rec.pricing_attribute3 := NULL;
8721     END IF;
8722 
8723     IF p_x_line_rec.pricing_attribute4 = FND_API.G_MISS_CHAR THEN
8724         p_x_line_rec.pricing_attribute4 := NULL;
8725     END IF;
8726 
8727     IF p_x_line_rec.pricing_attribute5 = FND_API.G_MISS_CHAR THEN
8728         p_x_line_rec.pricing_attribute5 := NULL;
8729     END IF;
8730 
8731     IF p_x_line_rec.pricing_attribute6 = FND_API.G_MISS_CHAR THEN
8732         p_x_line_rec.pricing_attribute6 := NULL;
8733     END IF;
8734 
8735     IF p_x_line_rec.pricing_attribute7 = FND_API.G_MISS_CHAR THEN
8736         p_x_line_rec.pricing_attribute7 := NULL;
8737     END IF;
8738 
8739     IF p_x_line_rec.pricing_attribute8 = FND_API.G_MISS_CHAR THEN
8740         p_x_line_rec.pricing_attribute8 := NULL;
8741     END IF;
8742 
8743     IF p_x_line_rec.pricing_attribute9 = FND_API.G_MISS_CHAR THEN
8744         p_x_line_rec.pricing_attribute9 := NULL;
8745     END IF;
8746 
8747     IF p_x_line_rec.pricing_context = FND_API.G_MISS_CHAR THEN
8748         p_x_line_rec.pricing_context := NULL;
8749     END IF;
8750 
8751     IF p_x_line_rec.pricing_date = FND_API.G_MISS_DATE THEN
8752         p_x_line_rec.pricing_date := NULL;
8753     END IF;
8754 
8755     IF p_x_line_rec.pricing_quantity = FND_API.G_MISS_NUM THEN
8756         p_x_line_rec.pricing_quantity := NULL;
8757     END IF;
8758 
8759     IF p_x_line_rec.pricing_quantity_uom = FND_API.G_MISS_CHAR THEN
8760         p_x_line_rec.pricing_quantity_uom := NULL;
8761     END IF;
8762 
8763     IF p_x_line_rec.program_application_id = FND_API.G_MISS_NUM THEN
8764         p_x_line_rec.program_application_id := NULL;
8765     END IF;
8766 
8767     IF p_x_line_rec.program_id = FND_API.G_MISS_NUM THEN
8768         p_x_line_rec.program_id := NULL;
8769     END IF;
8770 
8771     IF p_x_line_rec.program_update_date = FND_API.G_MISS_DATE THEN
8772         p_x_line_rec.program_update_date := NULL;
8773     END IF;
8774 
8775     IF p_x_line_rec.project_id = FND_API.G_MISS_NUM THEN
8776         p_x_line_rec.project_id := NULL;
8777     END IF;
8778 
8779     IF p_x_line_rec.promise_date = FND_API.G_MISS_DATE THEN
8780         p_x_line_rec.promise_date := NULL;
8781     END IF;
8782 
8783     IF p_x_line_rec.re_source_flag = FND_API.G_MISS_CHAR THEN
8784         p_x_line_rec.re_source_flag := NULL;
8785     END IF;
8786 
8787     IF p_x_line_rec.reference_customer_trx_line_id = FND_API.G_MISS_NUM THEN
8788         p_x_line_rec.reference_customer_trx_line_id := NULL;
8789     END IF;
8790 
8791     IF p_x_line_rec.reference_header_id = FND_API.G_MISS_NUM THEN
8792         p_x_line_rec.reference_header_id := NULL;
8793     END IF;
8794 
8795     IF p_x_line_rec.reference_line_id = FND_API.G_MISS_NUM THEN
8796         p_x_line_rec.reference_line_id := NULL;
8797     END IF;
8798 
8799     IF p_x_line_rec.reference_type = FND_API.G_MISS_CHAR THEN
8800         p_x_line_rec.reference_type := NULL;
8801     END IF;
8802 
8803 
8804 
8805     IF p_x_line_rec.request_date = FND_API.G_MISS_DATE THEN
8806         p_x_line_rec.request_date := NULL;
8807     END IF;
8808 
8809     IF p_x_line_rec.request_id = FND_API.G_MISS_NUM THEN
8810         p_x_line_rec.request_id := NULL;
8811     END IF;
8812 
8813     IF p_x_line_rec.return_attribute1 = FND_API.G_MISS_CHAR THEN
8814         p_x_line_rec.return_attribute1 := NULL;
8815     END IF;
8816 
8817     IF p_x_line_rec.return_attribute10 = FND_API.G_MISS_CHAR THEN
8818         p_x_line_rec.return_attribute10 := NULL;
8819     END IF;
8820 
8821     IF p_x_line_rec.return_attribute11 = FND_API.G_MISS_CHAR THEN
8822         p_x_line_rec.return_attribute11 := NULL;
8823     END IF;
8824 
8825     IF p_x_line_rec.return_attribute12 = FND_API.G_MISS_CHAR THEN
8826         p_x_line_rec.return_attribute12 := NULL;
8827     END IF;
8828 
8829     IF p_x_line_rec.return_attribute13 = FND_API.G_MISS_CHAR THEN
8830         p_x_line_rec.return_attribute13 := NULL;
8831     END IF;
8832 
8833     IF p_x_line_rec.return_attribute14 = FND_API.G_MISS_CHAR THEN
8834         p_x_line_rec.return_attribute14 := NULL;
8835     END IF;
8836 
8837     IF p_x_line_rec.return_attribute15 = FND_API.G_MISS_CHAR THEN
8838         p_x_line_rec.return_attribute15 := NULL;
8839     END IF;
8840 
8841     IF p_x_line_rec.return_attribute2 = FND_API.G_MISS_CHAR THEN
8842         p_x_line_rec.return_attribute2 := NULL;
8843     END IF;
8844 
8845     IF p_x_line_rec.return_attribute3 = FND_API.G_MISS_CHAR THEN
8846         p_x_line_rec.return_attribute3 := NULL;
8847     END IF;
8848 
8849     IF p_x_line_rec.return_attribute4 = FND_API.G_MISS_CHAR THEN
8850         p_x_line_rec.return_attribute4 := NULL;
8851     END IF;
8852 
8853     IF p_x_line_rec.return_attribute5 = FND_API.G_MISS_CHAR THEN
8854         p_x_line_rec.return_attribute5 := NULL;
8855     END IF;
8856 
8857     IF p_x_line_rec.return_attribute6 = FND_API.G_MISS_CHAR THEN
8858         p_x_line_rec.return_attribute6 := NULL;
8859     END IF;
8860 
8861     IF p_x_line_rec.return_attribute7 = FND_API.G_MISS_CHAR THEN
8862         p_x_line_rec.return_attribute7 := NULL;
8863     END IF;
8864 
8865     IF p_x_line_rec.return_attribute8 = FND_API.G_MISS_CHAR THEN
8866         p_x_line_rec.return_attribute8 := NULL;
8867     END IF;
8868 
8869     IF p_x_line_rec.return_attribute9 = FND_API.G_MISS_CHAR THEN
8870         p_x_line_rec.return_attribute9 := NULL;
8871     END IF;
8872 
8873     IF p_x_line_rec.return_context = FND_API.G_MISS_CHAR THEN
8874         p_x_line_rec.return_context := NULL;
8875     END IF;
8876     IF p_x_line_rec.return_reason_code = FND_API.G_MISS_CHAR THEN
8877         p_x_line_rec.return_reason_code := NULL;
8878     END IF;
8879     IF p_x_line_rec.salesrep_id = FND_API.G_MISS_NUM THEN
8880         p_x_line_rec.salesrep_id := NULL;
8881     END IF;
8882 
8883     IF p_x_line_rec.rla_schedule_type_code = FND_API.G_MISS_CHAR THEN
8884         p_x_line_rec.rla_schedule_type_code := NULL;
8885     END IF;
8886 
8887     IF p_x_line_rec.schedule_arrival_date = FND_API.G_MISS_DATE THEN
8888         p_x_line_rec.schedule_arrival_date := NULL;
8889     END IF;
8890 
8891     IF p_x_line_rec.schedule_ship_date = FND_API.G_MISS_DATE THEN
8892         p_x_line_rec.schedule_ship_date := NULL;
8893     END IF;
8894 
8895     IF p_x_line_rec.schedule_action_code = FND_API.G_MISS_CHAR THEN
8896         p_x_line_rec.schedule_action_code := NULL;
8897     END IF;
8898 
8899     IF p_x_line_rec.schedule_status_code = FND_API.G_MISS_CHAR THEN
8900         p_x_line_rec.schedule_status_code := NULL;
8901     END IF;
8902 
8903     IF p_x_line_rec.shipment_number = FND_API.G_MISS_NUM THEN
8904         p_x_line_rec.shipment_number := NULL;
8905     END IF;
8906 
8907     IF p_x_line_rec.shipment_priority_code = FND_API.G_MISS_CHAR THEN
8908         p_x_line_rec.shipment_priority_code := NULL;
8909     END IF;
8910 
8911     IF p_x_line_rec.shipped_quantity = FND_API.G_MISS_NUM THEN
8912         p_x_line_rec.shipped_quantity := NULL;
8913     END IF;
8914 
8915     IF p_x_line_rec.shipped_quantity2 = FND_API.G_MISS_NUM THEN -- OPM B1661023 04/02/01 INVCONV
8916         p_x_line_rec.shipped_quantity2 := NULL;
8917     END IF;
8918 
8919     IF p_x_line_rec.shipping_method_code = FND_API.G_MISS_CHAR THEN
8920         p_x_line_rec.shipping_method_code := NULL;
8921     END IF;
8922 
8923     IF p_x_line_rec.shipping_quantity = FND_API.G_MISS_NUM THEN
8924         p_x_line_rec.shipping_quantity := NULL;
8925     END IF;
8926 
8927     IF p_x_line_rec.shipping_quantity2 = FND_API.G_MISS_NUM THEN -- OPM B1661023 04/02/01 INVCONV
8928         p_x_line_rec.shipping_quantity2 := NULL;
8929     END IF;
8930 
8931     IF p_x_line_rec.shipping_quantity_uom = FND_API.G_MISS_CHAR THEN
8932         p_x_line_rec.shipping_quantity_uom := NULL;
8933     END IF;
8934 
8935     IF p_x_line_rec.ship_from_org_id = FND_API.G_MISS_NUM THEN
8936         p_x_line_rec.ship_from_org_id := NULL;
8937     END IF;
8938 
8939     IF p_x_line_rec.subinventory = FND_API.G_MISS_CHAR THEN
8940         p_x_line_rec.subinventory := NULL;
8941     END IF;
8942 
8943     IF p_x_line_rec.ship_model_complete_flag = FND_API.G_MISS_CHAR THEN
8944         p_x_line_rec.ship_model_complete_flag := NULL;
8945     END IF;
8946     IF p_x_line_rec.ship_set_id = FND_API.G_MISS_NUM THEN
8947         p_x_line_rec.ship_set_id := NULL;
8948     END IF;
8949 
8950     IF p_x_line_rec.ship_tolerance_above = FND_API.G_MISS_NUM THEN
8951         p_x_line_rec.ship_tolerance_above := NULL;
8952     END IF;
8953 
8954     IF p_x_line_rec.ship_tolerance_below = FND_API.G_MISS_NUM THEN
8955         p_x_line_rec.ship_tolerance_below := NULL;
8956     END IF;
8957 
8958     IF p_x_line_rec.shippable_flag = FND_API.G_MISS_CHAR THEN
8959         p_x_line_rec.shippable_flag := NULL;
8960     END IF;
8961 
8962     IF p_x_line_rec.shipping_interfaced_flag = FND_API.G_MISS_CHAR THEN
8963         p_x_line_rec.shipping_interfaced_flag := NULL;
8964     END IF;
8965 
8966     IF p_x_line_rec.ship_to_contact_id = FND_API.G_MISS_NUM THEN
8967         p_x_line_rec.ship_to_contact_id := NULL;
8968     END IF;
8969 
8970     IF p_x_line_rec.ship_to_org_id = FND_API.G_MISS_NUM THEN
8971         p_x_line_rec.ship_to_org_id := NULL;
8972     END IF;
8973 
8974     IF p_x_line_rec.sold_from_org_id = FND_API.G_MISS_NUM THEN
8975         p_x_line_rec.sold_from_org_id := NULL;
8976     END IF;
8977 
8978     IF p_x_line_rec.sold_to_org_id = FND_API.G_MISS_NUM THEN
8979         p_x_line_rec.sold_to_org_id := NULL;
8980     END IF;
8981 
8982     IF p_x_line_rec.sort_order = FND_API.G_MISS_CHAR THEN
8983         p_x_line_rec.sort_order := NULL;
8984     END IF;
8985 
8986     IF p_x_line_rec.source_document_id = FND_API.G_MISS_NUM THEN
8987         p_x_line_rec.source_document_id := NULL;
8988     END IF;
8989 
8990     IF p_x_line_rec.source_document_line_id = FND_API.G_MISS_NUM THEN
8991         p_x_line_rec.source_document_line_id := NULL;
8992     END IF;
8993 
8994     IF p_x_line_rec.source_document_type_id = FND_API.G_MISS_NUM THEN
8995         p_x_line_rec.source_document_type_id := NULL;
8996     END IF;
8997 
8998     IF p_x_line_rec.source_type_code = FND_API.G_MISS_CHAR THEN
8999         p_x_line_rec.source_type_code := NULL;
9000     END IF;
9001     IF p_x_line_rec.split_from_line_id = FND_API.G_MISS_NUM THEN
9002         p_x_line_rec.split_from_line_id := NULL;
9003     END IF;
9004     IF p_x_line_rec.line_set_id = FND_API.G_MISS_NUM THEN
9005         p_x_line_rec.line_set_id := NULL;
9006     END IF;
9007 
9008     IF p_x_line_rec.split_by = FND_API.G_MISS_CHAR THEN
9009         p_x_line_rec.split_by := NULL;
9010     END IF;
9011     IF p_x_line_rec.model_remnant_flag = FND_API.G_MISS_CHAR THEN
9012         p_x_line_rec.model_remnant_flag := NULL;
9013     END IF;
9014     IF p_x_line_rec.task_id = FND_API.G_MISS_NUM THEN
9015         p_x_line_rec.task_id := NULL;
9016     END IF;
9017 
9018     IF p_x_line_rec.tax_code = FND_API.G_MISS_CHAR THEN
9019         p_x_line_rec.tax_code := NULL;
9020     END IF;
9021 
9022     IF p_x_line_rec.tax_date = FND_API.G_MISS_DATE THEN
9023         p_x_line_rec.tax_date := NULL;
9024     END IF;
9025 
9026     IF p_x_line_rec.tax_exempt_flag = FND_API.G_MISS_CHAR THEN
9027         p_x_line_rec.tax_exempt_flag := NULL;
9028     END IF;
9029 
9030     IF p_x_line_rec.tax_exempt_number = FND_API.G_MISS_CHAR THEN
9031         p_x_line_rec.tax_exempt_number := NULL;
9032     END IF;
9033 
9034     IF p_x_line_rec.tax_exempt_reason_code = FND_API.G_MISS_CHAR THEN
9035         p_x_line_rec.tax_exempt_reason_code := NULL;
9036     END IF;
9037 
9038     IF p_x_line_rec.tax_point_code = FND_API.G_MISS_CHAR THEN
9039         p_x_line_rec.tax_point_code := NULL;
9040     END IF;
9041 
9042     IF p_x_line_rec.tax_rate = FND_API.G_MISS_NUM THEN
9043         p_x_line_rec.tax_rate := NULL;
9044     END IF;
9045 
9046     IF p_x_line_rec.tax_value = FND_API.G_MISS_NUM THEN
9047         p_x_line_rec.tax_value := NULL;
9048     END IF;
9049 
9050     IF p_x_line_rec.top_model_line_id = FND_API.G_MISS_NUM THEN
9051         p_x_line_rec.top_model_line_id := NULL;
9052     END IF;
9053 
9054     IF p_x_line_rec.unit_list_price = FND_API.G_MISS_NUM THEN
9055         p_x_line_rec.unit_list_price := NULL;
9056     END IF;
9057 
9058     IF p_x_line_rec.unit_list_price_per_pqty = FND_API.G_MISS_NUM THEN
9059         p_x_line_rec.unit_list_price_per_pqty := NULL;
9060     END IF;
9061 
9062     IF p_x_line_rec.unit_selling_price = FND_API.G_MISS_NUM THEN
9063         p_x_line_rec.unit_selling_price := NULL;
9064     END IF;
9065 
9066     IF p_x_line_rec.unit_selling_price_per_pqty = FND_API.G_MISS_NUM THEN
9067         p_x_line_rec.unit_selling_price_per_pqty := NULL;
9068     END IF;
9069 
9070 
9071     IF p_x_line_rec.visible_demand_flag = FND_API.G_MISS_CHAR THEN
9072         p_x_line_rec.visible_demand_flag := NULL;
9073     END IF;
9074     IF p_x_line_rec.veh_cus_item_cum_key_id = FND_API.G_MISS_NUM THEN
9075         p_x_line_rec.veh_cus_item_cum_key_id := NULL;
9076     END IF;
9077 
9078     IF p_x_line_rec.first_ack_code = FND_API.G_MISS_CHAR THEN
9079         p_x_line_rec.first_ack_code := NULL;
9080     END IF;
9081 
9082     IF p_x_line_rec.first_ack_date = FND_API.G_MISS_DATE THEN
9083         p_x_line_rec.first_ack_date := NULL;
9084     END IF;
9085 
9086     IF p_x_line_rec.last_ack_code = FND_API.G_MISS_CHAR THEN
9087         p_x_line_rec.last_ack_code := NULL;
9088     END IF;
9089 
9090     IF p_x_line_rec.last_ack_date = FND_API.G_MISS_DATE THEN
9091         p_x_line_rec.last_ack_date := NULL;
9092     END IF;
9093 
9094 
9095     IF p_x_line_rec.end_item_unit_number = FND_API.G_MISS_CHAR THEN
9096         p_x_line_rec.end_item_unit_number := NULL;
9097     END IF;
9098 
9099     IF p_x_line_rec.shipping_instructions = FND_API.G_MISS_CHAR THEN
9100         p_x_line_rec.shipping_instructions := NULL;
9101     END IF;
9102 
9103     IF p_x_line_rec.packing_instructions = FND_API.G_MISS_CHAR THEN
9104         p_x_line_rec.packing_instructions := NULL;
9105     END IF;
9106 
9107     -- Service related columns
9108 
9109     IF p_x_line_rec.service_txn_reason_code = FND_API.G_MISS_CHAR THEN
9110         p_x_line_rec.service_txn_reason_code := NULL;
9111     END IF;
9112 
9113     IF p_x_line_rec.service_txn_comments = FND_API.G_MISS_CHAR THEN
9114         p_x_line_rec.service_txn_comments := NULL;
9115     END IF;
9116 
9117     IF p_x_line_rec.service_duration = FND_API.G_MISS_NUM THEN
9118         p_x_line_rec.service_duration := NULL;
9119     END IF;
9120 
9121     IF p_x_line_rec.service_period = FND_API.G_MISS_CHAR THEN
9122         p_x_line_rec.service_period := NULL;
9123     END IF;
9124 
9125     IF p_x_line_rec.service_start_date = FND_API.G_MISS_DATE THEN
9126         p_x_line_rec.service_start_date := NULL;
9127     END IF;
9128 
9129     IF p_x_line_rec.service_end_date = FND_API.G_MISS_DATE THEN
9130         p_x_line_rec.service_end_date := NULL;
9131     END IF;
9132 
9133     IF p_x_line_rec.service_coterminate_flag = FND_API.G_MISS_CHAR THEN
9134         p_x_line_rec.service_coterminate_flag := NULL;
9135     END IF;
9136 
9137 
9138     IF p_x_line_rec.unit_list_percent = FND_API.G_MISS_NUM THEN
9139         p_x_line_rec.unit_list_percent := NULL;
9140     END IF;
9141 
9142     IF p_x_line_rec.unit_selling_percent = FND_API.G_MISS_NUM THEN
9143         p_x_line_rec.unit_selling_percent := NULL;
9144     END IF;
9145 
9146     IF p_x_line_rec.unit_percent_base_price = FND_API.G_MISS_NUM THEN
9147         p_x_line_rec.unit_percent_base_price := NULL;
9148     END IF;
9149 
9150     IF p_x_line_rec.service_number = FND_API.G_MISS_NUM THEN
9151         p_x_line_rec.service_number := NULL;
9152     END IF;
9153 
9154     IF p_x_line_rec.service_reference_type_code = FND_API.G_MISS_CHAR THEN
9155         p_x_line_rec.service_reference_type_code := NULL;
9156     END IF;
9157 
9158     IF p_x_line_rec.service_reference_line_id = FND_API.G_MISS_NUM THEN
9159         p_x_line_rec.service_reference_line_id := NULL;
9160     END IF;
9161 
9162     IF p_x_line_rec.service_reference_system_id = FND_API.G_MISS_NUM THEN
9163         p_x_line_rec.service_reference_system_id := NULL;
9164     END IF;
9165 
9166     /* Marketing source code related */
9167 
9168     IF p_x_line_rec.marketing_source_code_id = FND_API.G_MISS_NUM THEN
9169         p_x_line_rec.marketing_source_code_id := NULL;
9170     END IF;
9171 
9172     /* End of Marketing source code related */
9173 
9174     IF p_x_line_rec.order_source_id = FND_API.G_MISS_NUM THEN
9175   if l_debug_level > 0 then
9176     oe_debug_pub.add('OEXULIN-aksingh convert_miss_to_null - order_source_id');
9177   end if;
9178         p_x_line_rec.order_source_id := NULL;
9179     END IF;
9180 
9181     IF p_x_line_rec.flow_status_code = FND_API.G_MISS_CHAR THEN
9182         p_x_line_rec.flow_status_code := NULL;
9183     END IF;
9184 
9185     -- Commitment related
9186     IF p_x_line_rec.commitment_id = FND_API.G_MISS_NUM THEN
9187        p_x_line_rec.commitment_id := NULL;
9188     END IF;
9189 
9190 
9191    -- Item Substitution changes.
9192    IF p_x_line_rec.Original_Inventory_Item_Id = FND_API.G_MISS_NUM THEN
9193        p_x_line_rec.Original_Inventory_Item_Id := Null;
9194    END IF;
9195 
9196    IF p_x_line_rec.Original_item_identifier_Type = FND_API.G_MISS_CHAR THEN
9197        p_x_line_rec.Original_item_identifier_Type := Null;
9198    END IF;
9199 
9200    IF p_x_line_rec.Original_ordered_item_id = FND_API.G_MISS_NUM THEN
9201        p_x_line_rec.Original_ordered_item_id := Null;
9202    END IF;
9203 
9204    IF p_x_line_rec.Original_ordered_item = FND_API.G_MISS_CHAR THEN
9205        p_x_line_rec.Original_ordered_item := Null;
9206    END IF;
9207 
9208    IF p_x_line_rec.item_relationship_type = FND_API.G_MISS_NUM THEN
9209        p_x_line_rec.item_relationship_type := Null;
9210    END IF;
9211 
9212    IF p_x_line_rec.Item_substitution_type_code = FND_API.G_MISS_CHAR THEN
9213        p_x_line_rec.Item_substitution_type_code := Null;
9214    END IF;
9215 
9216    IF p_x_line_rec.Late_Demand_Penalty_Factor = FND_API.G_MISS_NUM THEN
9217        p_x_line_rec.Late_Demand_Penalty_Factor := Null;
9218    END IF;
9219 
9220    IF p_x_line_rec.Override_atp_date_code = FND_API.G_MISS_CHAR THEN
9221        p_x_line_rec.Override_atp_date_code := Null;
9222    END IF;
9223 
9224    -- Changes for Blanket Orders
9225 
9226    IF p_x_line_rec.Blanket_Number = FND_API.G_MISS_NUM THEN
9227       p_x_line_rec.Blanket_Number := NULL;
9228    END IF;
9229 
9230    IF p_x_line_rec.Blanket_Line_Number = FND_API.G_MISS_NUM THEN
9231       p_x_line_rec.Blanket_Line_Number := NULL;
9232    END IF;
9233 
9234    IF p_x_line_rec.Blanket_Version_Number = FND_API.G_MISS_NUM THEN
9235       p_x_line_rec.Blanket_Version_Number := NULL;
9236    END IF;
9237 
9238    -- QUOTING changes
9239    IF p_x_line_rec.transaction_phase_code = FND_API.G_MISS_CHAR THEN
9240       p_x_line_rec.transaction_phase_code := NULL;
9241    END IF;
9242 
9243    IF p_x_line_rec.source_document_version_number = FND_API.G_MISS_NUM THEN
9244       p_x_line_rec.source_document_version_number := NULL;
9245    END IF;
9246    -- END QUOTING changes
9247     IF p_x_line_rec.Minisite_id = FND_API.G_MISS_NUM THEN
9248         p_x_line_rec.Minisite_id := NULL;
9249     END IF;
9250 
9251     IF p_x_line_rec.End_customer_id = FND_API.G_MISS_NUM THEN
9252         p_x_line_rec.End_customer_id := NULL;
9253     END IF;
9254 
9255     IF p_x_line_rec.End_customer_contact_id = FND_API.G_MISS_NUM THEN
9256         p_x_line_rec.End_customer_contact_id := NULL;
9257     END IF;
9258 
9259     IF p_x_line_rec.End_customer_site_use_id = FND_API.G_MISS_NUM THEN
9260         p_x_line_rec.End_customer_site_use_id := NULL;
9261     END IF;
9262 
9263     IF p_x_line_rec.ib_owner = FND_API.G_MISS_CHAR THEN
9264         p_x_line_rec.ib_owner := NULL;
9265     END IF;
9266 
9267     IF p_x_line_rec.ib_installed_at_location = FND_API.G_MISS_CHAR THEN
9268         p_x_line_rec.ib_installed_at_location := NULL;
9269     END IF;
9270 
9271     IF p_x_line_rec.ib_current_location = FND_API.G_MISS_CHAR THEN
9272         p_x_line_rec.ib_current_location := NULL;
9273     END IF;
9274 
9275     --retro{
9276     IF p_x_line_rec.retrobill_request_id = FND_API.G_MISS_NUM THEN
9277        p_x_line_rec.retrobill_request_id := Null;
9278     END IF;
9279     --retro}
9280 
9281     IF p_x_line_rec.firm_demand_flag = FND_API.G_MISS_CHAR THEN
9282         p_x_line_rec.firm_demand_flag := NULL;
9283     END IF;
9284 
9285 --key Transaction Dates
9286     IF p_x_line_rec.order_firmed_date = FND_API.G_MISS_DATE THEN
9287       	p_x_line_rec.order_firmed_date := NULL;
9288     END IF;
9289 
9290    IF p_x_line_rec.actual_fulfillment_date = FND_API.G_MISS_DATE THEN
9291 	p_x_line_rec.actual_fulfillment_date := NULL;
9292     END IF;
9293 --end
9294 
9295 -- INVCONV OPM inventory convergence
9296 
9297 	  IF p_x_line_rec.fulfilled_quantity2 = FND_API.G_MISS_NUM THEN
9298         p_x_line_rec.fulfilled_quantity2 := NULL;
9299     END IF;
9300 
9301 	  IF p_x_line_rec.cancelled_quantity2 = FND_API.G_MISS_NUM THEN
9302         p_x_line_rec.cancelled_quantity2 := NULL;
9303     END IF;
9304  		IF p_x_line_rec.shipping_quantity_uom2 = FND_API.G_MISS_CHAR THEN
9305         p_x_line_rec.shipping_quantity_uom2 := NULL;
9306     END IF;
9307 
9308 -- INVCONV end
9309 
9310 --bug8468258
9311  IF p_x_line_rec.service_reference_line = FND_API.G_MISS_CHAR THEN
9312         p_x_line_rec.service_reference_line := NULL;
9313  END IF;
9314 
9315  IF p_x_line_rec.service_reference_order = FND_API.G_MISS_CHAR THEN
9316         p_x_line_rec.service_reference_order := NULL;
9317  END IF;
9318 
9319  IF p_x_line_rec.service_reference_system = FND_API.G_MISS_CHAR THEN
9320         p_x_line_rec.service_reference_system := NULL;
9321  END IF;
9322 --bug8468258
9323 
9324 
9325     IF p_x_line_rec.Pre_Exploded_Flag = FND_API.G_MISS_CHAR THEN
9326       p_x_line_rec.Pre_Exploded_Flag := NULL;
9327     END IF; -- DOO Pre Exploded Kit ER 9339742
9328 
9329     IF p_x_line_rec.bypass_sch_flag = FND_API.G_MISS_CHAR THEN
9330       p_x_line_rec.bypass_sch_flag := NULL;
9331     END IF; -- DOO Scheduling related support ER 11728366
9332 
9333     --Bug 12580407
9334     IF p_x_line_rec.earliest_ship_date = FND_API.G_MISS_DATE THEN
9335        p_x_line_rec.earliest_ship_date := NULL;
9336     END IF;
9337 
9338 /*   IF p_x_line_rec.supplier_signature = FND_API.G_MISS_CHAR THEN
9339         p_x_line_rec.supplier_signature := NULL;
9340     END IF;
9341 
9342    IF p_x_line_rec.supplier_signature_date = FND_API.G_MISS_DATE THEN
9343         p_x_line_rec.supplier_signature_date := NULL;
9344     END IF;
9345 
9346    IF p_x_line_rec.customer_signature = FND_API.G_MISS_CHAR THEN
9347         p_x_line_rec.customer_signature := NULL;
9348     END IF;
9349 
9350    IF p_x_line_rec.customer_signature_date = FND_API.G_MISS_CHAR THEN
9351         p_x_line_rec.customer_signature_date := NULL;
9352     END IF;
9353 */
9354     IF p_x_line_rec.fulfillment_base = FND_API.G_MISS_CHAR THEN
9355        p_x_line_rec.fulfillment_base := NULL ;--ER#14763609
9356     END IF;
9357 
9358   if l_debug_level > 0 then
9359    oe_debug_pub.add('Exiting OE_LINE_UTIL.CONVERT_MISS_TO_NULL', 1);
9360   end if;
9361 END Convert_Miss_To_Null;
9362 
9363 
9364 
9365 /*-----------------------------------------------------------
9366 Procedure Update_Row
9367 -----------------------------------------------------------*/
9368 
9369 PROCEDURE Update_Row
9370 (   p_line_rec                      IN  OUT NOCOPY OE_Order_PUB.Line_Rec_Type
9371 )
9372 IS
9373 l_org_id NUMBER;
9374 l_lock_control NUMBER;
9375 l_index    NUMBER;
9376 l_return_status VARCHAR2(1);
9377 
9378 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
9379 BEGIN
9380 
9381   if l_debug_level > 0 then
9382     oe_debug_pub.add('Entering OE_LINE_UTIL.UPDATE_ROW', 1);
9383   end if;
9384             --Commented for MOAC start
9385 	    /*if l_org_id IS NULL THEN
9386 		    OE_GLOBALS.Set_Context;
9387 		    l_org_id := OE_GLOBALS.G_ORG_ID;
9388 	    end if;*/
9389             --Commented for MOAC end
9390 
9391     SELECT lock_control
9392     INTO   l_lock_control
9393     FROM   oe_order_lines
9394     WHERE  line_id = p_line_rec.line_id;
9395 
9396     l_lock_control :=   l_lock_control + 1;
9397 
9398   -- calling notification framework to update global picture
9399    --check code release level first. Notification framework is at Pack H level
9400     IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508' THEN
9401       OE_ORDER_UTIL.Update_Global_Picture(p_Upd_New_Rec_If_Exists => True,
9402                     p_Line_rec =>p_line_rec,
9403                     p_line_id => p_line_rec.line_id,
9404                     x_index => l_index,
9405                     x_return_status => l_return_status);
9406       if l_debug_level > 0 then
9407        OE_DEBUG_PUB.ADD('Update_Global Return Status from OE_LINE_UTIL.update_row is: ' || l_return_status);
9408        OE_DEBUG_PUB.ADD('JFC: Line Booked Status in OE_LINE_UTIL.update_row is: ' || p_line_rec.booked_flag);
9409        OE_DEBUG_PUB.ADD('JFC: Line Flow Status in OE_LINE_UTIL.update_row is: ' || p_line_rec.flow_status_code);
9410       end if;
9411        IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
9412          if l_debug_level > 0 then
9413           OE_DEBUG_PUB.ADD('EVENT NOTIFY - Unexpected Error');
9414           OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.Update_ROW', 1);
9415          end if;
9416        	  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9417        ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
9418         if l_debug_level > 0 then
9419           OE_DEBUG_PUB.ADD('Update_Global_Picture Error in OE_LINE_UTIL.Update_row');
9420         OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.Update_ROW', 1);
9421         end if;
9422 	RAISE FND_API.G_EXC_ERROR;
9423        END IF;
9424     END IF; /*code_release_level*/
9425   -- notification framework end
9426 
9427   if l_debug_level > 0 then
9428     -- oe_debug_pub.add('Entering update'||to_char(l_org_id), 1);
9429     oe_debug_pub.add('arrivalset-'||to_char(p_line_rec.arrival_set_id), 1);
9430     oe_debug_pub.add('shipset-'||to_char(p_line_rec.ship_set_id), 1);
9431   end if;
9432     -- OPM 02/JUN/00 - Include process columns
9433     --                (ordered_quantity2,ordered_quantity_uom2,preferred_grade)
9434     UPDATE  OE_ORDER_LINES
9435     SET     ACCOUNTING_RULE_ID             = p_line_rec.accounting_rule_id
9436     ,       ACCOUNTING_RULE_DURATION       = p_line_rec.accounting_rule_duration
9437     ,       CALCULATE_PRICE_FLAG            = p_line_rec.calculate_price_flag
9438     ,       ACTUAL_ARRIVAL_DATE            = p_line_rec.actual_arrival_date
9439     ,       ACTUAL_SHIPMENT_DATE           = p_line_rec.actual_shipment_date
9440     ,       AGREEMENT_ID                   = p_line_rec.agreement_id
9441     ,       ARRIVAL_SET_ID                 = p_line_rec.arrival_set_id
9442     ,       ATO_LINE_ID                    = p_line_rec.ato_line_id
9443     ,       ATTRIBUTE1                     = p_line_rec.attribute1
9444     ,       ATTRIBUTE10                    = p_line_rec.attribute10
9445     ,       ATTRIBUTE11                    = p_line_rec.attribute11
9446     ,       ATTRIBUTE12                    = p_line_rec.attribute12
9447     ,       ATTRIBUTE13                    = p_line_rec.attribute13
9448     ,       ATTRIBUTE14                    = p_line_rec.attribute14
9449     ,       ATTRIBUTE15                    = p_line_rec.attribute15
9450     ,       ATTRIBUTE16                    = p_line_rec.attribute16   --For bug 2184255
9451     ,       ATTRIBUTE17                    = p_line_rec.attribute17
9452     ,       ATTRIBUTE18                    = p_line_rec.attribute18
9453     ,       ATTRIBUTE19                    = p_line_rec.attribute19
9454     ,       ATTRIBUTE2                     = p_line_rec.attribute2
9455     ,       ATTRIBUTE20                    = p_line_rec.attribute20
9456     ,       ATTRIBUTE3                     = p_line_rec.attribute3
9457     ,       ATTRIBUTE4                     = p_line_rec.attribute4
9458     ,       ATTRIBUTE5                     = p_line_rec.attribute5
9459     ,       ATTRIBUTE6                     = p_line_rec.attribute6
9460     ,       ATTRIBUTE7                     = p_line_rec.attribute7
9461     ,       ATTRIBUTE8                     = p_line_rec.attribute8
9462     ,       ATTRIBUTE9                     = p_line_rec.attribute9
9463     ,       AUTO_SELECTED_QUANTITY         = p_line_rec.auto_selected_quantity
9464     ,       AUTHORIZED_TO_SHIP_FLAG        = p_line_rec.authorized_to_ship_flag
9465     ,       BOOKED_FLAG                    = p_line_rec.booked_flag
9466     ,       CANCELLED_FLAG                 = p_line_rec.cancelled_flag
9467     ,       CANCELLED_QUANTITY             = p_line_rec.cancelled_quantity
9468     ,       COMMITMENT_ID                  = p_line_rec.commitment_id
9469     ,       COMPONENT_CODE                 = p_line_rec.component_code
9470     ,       COMPONENT_SEQUENCE_ID          = p_line_rec.component_sequence_id
9471     ,       CONFIG_HEADER_ID               = p_line_rec.config_header_id
9472     ,       CONFIG_REV_NBR                 = p_line_rec.config_rev_nbr
9473     ,       CONFIG_DISPLAY_SEQUENCE        = p_line_rec.config_display_sequence
9474     ,       CONFIGURATION_ID               = p_line_rec.configuration_id
9475     ,       CONTEXT                        = p_line_rec.context
9476     ,       CREATED_BY                     = p_line_rec.created_by
9477     ,       CREATION_DATE                  = p_line_rec.creation_date
9478     ,       CREDIT_INVOICE_LINE_ID         = p_line_rec.credit_invoice_line_id
9479     ,       CUSTOMER_LINE_NUMBER	   = p_line_rec.customer_line_number
9480     ,       CUSTOMER_SHIPMENT_NUMBER       = p_line_rec.customer_shipment_number
9481     ,       CUSTOMER_ITEM_NET_PRICE        = p_line_rec.customer_item_net_price
9482     ,       CUSTOMER_PAYMENT_TERM_ID       = p_line_rec.customer_payment_term_id
9483     ,       CUSTOMER_DOCK_CODE             = p_line_rec.customer_dock_code
9484     ,       CUSTOMER_JOB                   = p_line_rec.customer_job
9485     ,       CUSTOMER_PRODUCTION_LINE       = p_line_rec.customer_production_line
9486     ,       CUST_PRODUCTION_SEQ_NUM        = p_line_rec.cust_production_seq_num
9487     ,       CUSTOMER_TRX_LINE_ID           = p_line_rec.customer_trx_line_id
9488     ,       CUST_MODEL_SERIAL_NUMBER       = p_line_rec.cust_model_serial_number
9489     ,       CUST_PO_NUMBER                 = p_line_rec.cust_po_number
9490     ,       DELIVERY_LEAD_TIME             = p_line_rec.delivery_lead_time
9491     ,       DELIVER_TO_CONTACT_ID          = p_line_rec.deliver_to_contact_id
9492     ,       DELIVER_TO_ORG_ID              = p_line_rec.deliver_to_org_id
9493     ,       DEMAND_BUCKET_TYPE_CODE        = p_line_rec.demand_bucket_type_code
9494     ,       DEMAND_CLASS_CODE              = p_line_rec.demand_class_code
9495     ,       DEP_PLAN_REQUIRED_FLAG         = p_line_rec.dep_plan_required_flag
9496     --,       DROP_SHIP_FLAG		   = p_line_rec.drop_ship_flag
9497     ,       EARLIEST_ACCEPTABLE_DATE       = p_line_rec.earliest_acceptable_date
9498     ,       END_ITEM_UNIT_NUMBER           = p_line_rec.end_item_unit_number
9499     ,       EXPLOSION_DATE                 = p_line_rec.explosion_date
9500     ,       FIRST_ACK_CODE                 = p_line_rec.first_ack_code
9501     ,       FIRST_ACK_DATE                 = p_line_rec.first_ack_date
9502     ,       FOB_POINT_CODE                 = p_line_rec.fob_point_code
9503     ,       FREIGHT_CARRIER_CODE           = p_line_rec.freight_carrier_code
9504     ,       FREIGHT_TERMS_CODE             = p_line_rec.freight_terms_code
9505     ,       FULFILLED_QUANTITY             = p_line_rec.fulfilled_quantity
9506     ,       FULFILLED_FLAG                 = p_line_rec.fulfilled_flag
9507     ,       FULFILLMENT_METHOD_CODE        = p_line_rec.fulfillment_method_code
9508     ,       FULFILLMENT_DATE               = p_line_rec.fulfillment_date
9509     ,       GLOBAL_ATTRIBUTE1              = p_line_rec.global_attribute1
9510     ,       GLOBAL_ATTRIBUTE10             = p_line_rec.global_attribute10
9511     ,       GLOBAL_ATTRIBUTE11             = p_line_rec.global_attribute11
9512     ,       GLOBAL_ATTRIBUTE12             = p_line_rec.global_attribute12
9513     ,       GLOBAL_ATTRIBUTE13             = p_line_rec.global_attribute13
9514     ,       GLOBAL_ATTRIBUTE14             = p_line_rec.global_attribute14
9515     ,       GLOBAL_ATTRIBUTE15             = p_line_rec.global_attribute15
9516     ,       GLOBAL_ATTRIBUTE16             = p_line_rec.global_attribute16
9517     ,       GLOBAL_ATTRIBUTE17             = p_line_rec.global_attribute17
9518     ,       GLOBAL_ATTRIBUTE18             = p_line_rec.global_attribute18
9519     ,       GLOBAL_ATTRIBUTE19             = p_line_rec.global_attribute19
9520     ,       GLOBAL_ATTRIBUTE2              = p_line_rec.global_attribute2
9521     ,       GLOBAL_ATTRIBUTE20             = p_line_rec.global_attribute20
9522     ,       GLOBAL_ATTRIBUTE3              = p_line_rec.global_attribute3
9523     ,       GLOBAL_ATTRIBUTE4              = p_line_rec.global_attribute4
9524     ,       GLOBAL_ATTRIBUTE5              = p_line_rec.global_attribute5
9525     ,       GLOBAL_ATTRIBUTE6              = p_line_rec.global_attribute6
9526     ,       GLOBAL_ATTRIBUTE7              = p_line_rec.global_attribute7
9527     ,       GLOBAL_ATTRIBUTE8              = p_line_rec.global_attribute8
9528     ,       GLOBAL_ATTRIBUTE9              = p_line_rec.global_attribute9
9529     ,       GLOBAL_ATTRIBUTE_CATEGORY      = p_line_rec.global_attribute_category
9530     ,       HEADER_ID                      = p_line_rec.header_id
9531     ,       INDUSTRY_ATTRIBUTE1            = p_line_rec.industry_attribute1
9532     ,       INDUSTRY_ATTRIBUTE10           = p_line_rec.industry_attribute10
9533     ,       INDUSTRY_ATTRIBUTE11           = p_line_rec.industry_attribute11
9534     ,       INDUSTRY_ATTRIBUTE12           = p_line_rec.industry_attribute12
9535     ,       INDUSTRY_ATTRIBUTE13           = p_line_rec.industry_attribute13
9536     ,       INDUSTRY_ATTRIBUTE14           = p_line_rec.industry_attribute14
9537     ,       INDUSTRY_ATTRIBUTE15           = p_line_rec.industry_attribute15
9538     ,       INDUSTRY_ATTRIBUTE16           = p_line_rec.industry_attribute16
9539     ,       INDUSTRY_ATTRIBUTE17           = p_line_rec.industry_attribute17
9540     ,       INDUSTRY_ATTRIBUTE18           = p_line_rec.industry_attribute18
9541     ,       INDUSTRY_ATTRIBUTE19           = p_line_rec.industry_attribute19
9542     ,       INDUSTRY_ATTRIBUTE20           = p_line_rec.industry_attribute20
9543     ,       INDUSTRY_ATTRIBUTE21           = p_line_rec.industry_attribute21
9544     ,       INDUSTRY_ATTRIBUTE22           = p_line_rec.industry_attribute22
9545     ,       INDUSTRY_ATTRIBUTE23           = p_line_rec.industry_attribute23
9546     ,       INDUSTRY_ATTRIBUTE24           = p_line_rec.industry_attribute24
9547     ,       INDUSTRY_ATTRIBUTE25           = p_line_rec.industry_attribute25
9548     ,       INDUSTRY_ATTRIBUTE26           = p_line_rec.industry_attribute26
9549     ,       INDUSTRY_ATTRIBUTE27           = p_line_rec.industry_attribute27
9550     ,       INDUSTRY_ATTRIBUTE28           = p_line_rec.industry_attribute28
9551     ,       INDUSTRY_ATTRIBUTE29           = p_line_rec.industry_attribute29
9552     ,       INDUSTRY_ATTRIBUTE30           = p_line_rec.industry_attribute30
9553     ,       INDUSTRY_ATTRIBUTE2            = p_line_rec.industry_attribute2
9554     ,       INDUSTRY_ATTRIBUTE3            = p_line_rec.industry_attribute3
9555     ,       INDUSTRY_ATTRIBUTE4            = p_line_rec.industry_attribute4
9556     ,       INDUSTRY_ATTRIBUTE5            = p_line_rec.industry_attribute5
9557     ,       INDUSTRY_ATTRIBUTE6            = p_line_rec.industry_attribute6
9558     ,       INDUSTRY_ATTRIBUTE7            = p_line_rec.industry_attribute7
9559     ,       INDUSTRY_ATTRIBUTE8            = p_line_rec.industry_attribute8
9560     ,       INDUSTRY_ATTRIBUTE9            = p_line_rec.industry_attribute9
9561     ,       INDUSTRY_CONTEXT               = p_line_rec.industry_context
9562     ,       INTMED_SHIP_TO_CONTACT_ID = p_line_rec.intermed_ship_to_contact_id
9563     ,       INTMED_SHIP_TO_ORG_ID     = p_line_rec.intermed_ship_to_org_id
9564     ,       INVENTORY_ITEM_ID              = p_line_rec.inventory_item_id
9565     ,       INVOICE_INTERFACE_STATUS_CODE          = p_line_rec.invoice_interface_status_code
9566     ,       INVOICE_TO_CONTACT_ID          = p_line_rec.invoice_to_contact_id
9567     ,       INVOICE_TO_ORG_ID              = p_line_rec.invoice_to_org_id
9568     ,       INVOICED_QUANTITY              = p_line_rec.invoiced_quantity
9569     ,       INVOICING_RULE_ID              = p_line_rec.invoicing_rule_id
9570     ,       ORDERED_ITEM_ID                        = p_line_rec.ordered_item_id
9571     ,       ITEM_IDENTIFIER_TYPE           = p_line_rec.item_identifier_type
9572     ,       ORDERED_ITEM                     = p_line_rec.ordered_item
9573     ,       ITEM_REVISION                  = p_line_rec.item_revision
9574     ,       ITEM_TYPE_CODE                 = p_line_rec.item_type_code
9575     ,       LAST_ACK_CODE                  = p_line_rec.last_ack_code
9576     ,       LAST_ACK_DATE                  = p_line_rec.last_ack_date --bug6448638
9577     ,       LAST_UPDATED_BY                = p_line_rec.last_updated_by
9578     ,       LATEST_ACCEPTABLE_DATE         = p_line_rec.latest_acceptable_date
9579     ,       LAST_UPDATE_DATE               = p_line_rec.last_update_date
9580     ,       LAST_UPDATE_LOGIN              = p_line_rec.last_update_login
9581     ,       LINE_CATEGORY_CODE             = p_line_rec.line_category_code
9582     ,       LINE_NUMBER                    = p_line_rec.line_number
9583     ,       LINE_TYPE_ID                   = p_line_rec.line_type_id
9584     ,       LINK_TO_LINE_ID                = p_line_rec.link_to_line_id
9585     ,       MODEL_GROUP_NUMBER             = p_line_rec.model_group_number
9586  --   ,       MFG_COMPONENT_SEQUENCE_ID      = p_line_rec.mfg_component_sequence_id
9587     ,       MFG_LEAD_TIME                  = p_line_rec.mfg_lead_time
9588     ,       OPEN_FLAG                      = p_line_rec.open_flag
9589     ,       OPTION_FLAG                    = p_line_rec.option_flag
9590     ,       OPTION_NUMBER                  = p_line_rec.option_number
9591     ,       ORDERED_QUANTITY               = p_line_rec.ordered_quantity
9592     ,       ORDERED_QUANTITY2              = p_line_rec.ordered_quantity2
9593     ,       ORDER_QUANTITY_UOM             = p_line_rec.order_quantity_uom
9594     ,       ORDERED_QUANTITY_UOM2          = p_line_rec.ordered_quantity_uom2
9595 --We should not allow to update org_id(operting unit)
9596 --  ,       ORG_ID                         = p_line_rec.org_id
9597     ,       ORDER_SOURCE_ID	           = p_line_rec.order_source_id
9598     ,       ORIG_SYS_DOCUMENT_REF          = p_line_rec.orig_sys_document_ref
9599     ,       ORIG_SYS_LINE_REF              = p_line_rec.orig_sys_line_ref
9600     ,       ORIG_SYS_SHIPMENT_REF          = p_line_rec.orig_sys_shipment_ref
9601     ,       CHANGE_SEQUENCE                = p_line_rec.change_sequence
9602     ,       OVER_SHIP_REASON_CODE          = p_line_rec.over_ship_reason_code
9603     ,       OVER_SHIP_RESOLVED_FLAG        = p_line_rec.over_ship_resolved_flag
9604     ,       PAYMENT_TERM_ID                = p_line_rec.payment_term_id
9605     ,       PLANNING_PRIORITY              = p_line_rec.planning_priority
9606     ,       PREFERRED_GRADE                = p_line_rec.preferred_grade
9607     ,       PRICE_LIST_ID                  = p_line_rec.price_list_id
9608     ,       PRICE_REQUEST_CODE             = p_line_rec.price_request_code  -- PROMOTIONS SEP/01
9609     ,       PRICING_ATTRIBUTE1             = p_line_rec.pricing_attribute1
9610     ,       PRICING_ATTRIBUTE10            = p_line_rec.pricing_attribute10
9611     ,       PRICING_ATTRIBUTE2             = p_line_rec.pricing_attribute2
9612     ,       PRICING_ATTRIBUTE3             = p_line_rec.pricing_attribute3
9613     ,       PRICING_ATTRIBUTE4             = p_line_rec.pricing_attribute4
9614     ,       PRICING_ATTRIBUTE5             = p_line_rec.pricing_attribute5
9615     ,       PRICING_ATTRIBUTE6             = p_line_rec.pricing_attribute6
9616     ,       PRICING_ATTRIBUTE7             = p_line_rec.pricing_attribute7
9617     ,       PRICING_ATTRIBUTE8             = p_line_rec.pricing_attribute8
9618     ,       PRICING_ATTRIBUTE9             = p_line_rec.pricing_attribute9
9619     ,       PRICING_CONTEXT                = p_line_rec.pricing_context
9620     ,       PRICING_DATE                   = p_line_rec.pricing_date
9621     ,       PRICING_QUANTITY               = p_line_rec.pricing_quantity
9622     ,       PRICING_QUANTITY_UOM           = p_line_rec.pricing_quantity_uom
9623     ,       PROGRAM_APPLICATION_ID         = p_line_rec.program_application_id
9624     ,       PROGRAM_ID                     = p_line_rec.program_id
9625     ,       PROGRAM_UPDATE_DATE            = p_line_rec.program_update_date
9626     ,       PROJECT_ID                     = p_line_rec.project_id
9627     ,       PROMISE_DATE                   = p_line_rec.promise_date
9628     ,       RE_SOURCE_FLAG                 = p_line_rec.re_source_flag
9629     ,       REFERENCE_CUSTOMER_TRX_LINE_ID = p_line_rec.reference_customer_trx_line_id
9630     ,       REFERENCE_HEADER_ID            = p_line_rec.reference_header_id
9631     ,       REFERENCE_LINE_ID              = p_line_rec.reference_line_id
9632     ,       REFERENCE_TYPE                 = p_line_rec.reference_type
9633     ,       REQUEST_DATE                   = p_line_rec.request_date
9634     ,       REQUEST_ID                     = p_line_rec.request_id
9635     ,       RETURN_ATTRIBUTE1              = p_line_rec.return_attribute1
9636     ,       RETURN_ATTRIBUTE10             = p_line_rec.return_attribute10
9637     ,       RETURN_ATTRIBUTE11             = p_line_rec.return_attribute11
9638     ,       RETURN_ATTRIBUTE12             = p_line_rec.return_attribute12
9639     ,       RETURN_ATTRIBUTE13             = p_line_rec.return_attribute13
9640     ,       RETURN_ATTRIBUTE14             = p_line_rec.return_attribute14
9641     ,       RETURN_ATTRIBUTE15             = p_line_rec.return_attribute15
9642     ,       RETURN_ATTRIBUTE2              = p_line_rec.return_attribute2
9643     ,       RETURN_ATTRIBUTE3              = p_line_rec.return_attribute3
9644     ,       RETURN_ATTRIBUTE4              = p_line_rec.return_attribute4
9645     ,       RETURN_ATTRIBUTE5              = p_line_rec.return_attribute5
9646     ,       RETURN_ATTRIBUTE6              = p_line_rec.return_attribute6
9647     ,       RETURN_ATTRIBUTE7              = p_line_rec.return_attribute7
9648     ,       RETURN_ATTRIBUTE8              = p_line_rec.return_attribute8
9649     ,       RETURN_ATTRIBUTE9              = p_line_rec.return_attribute9
9650     ,       RETURN_CONTEXT                 = p_line_rec.return_context
9651     ,       RETURN_REASON_CODE             = p_line_rec.return_reason_code
9652     ,       RLA_SCHEDULE_TYPE_CODE         = p_line_rec.rla_schedule_type_code
9653     ,       SALESREP_ID                    = p_line_rec.salesrep_id
9654     ,       SCHEDULE_ARRIVAL_DATE          = p_line_rec.schedule_arrival_date
9655     ,       SCHEDULE_SHIP_DATE             = p_line_rec.schedule_ship_date
9656     ,       SCHEDULE_STATUS_CODE           = p_line_rec.schedule_status_code
9657     ,       SHIPMENT_NUMBER                = p_line_rec.shipment_number
9658     ,       SHIPMENT_PRIORITY_CODE         = p_line_rec.shipment_priority_code
9659     ,       SHIPPED_QUANTITY               = p_line_rec.shipped_quantity
9660     ,       SHIPPED_QUANTITY2              = p_line_rec.shipped_quantity2  -- OPM B1661023 04/02/01
9661     ,       SHIPPING_METHOD_CODE           = p_line_rec.shipping_method_code
9662     ,       SHIPPING_QUANTITY              = p_line_rec.shipping_quantity
9663     ,       SHIPPING_QUANTITY2             = p_line_rec.shipping_quantity2 -- OPM B1661023 04/02/01
9664     ,       SHIPPING_QUANTITY_UOM          = p_line_rec.shipping_quantity_uom
9665     ,       SHIP_FROM_ORG_ID               = p_line_rec.ship_from_org_id
9666     ,       SUBINVENTORY                   = p_line_rec.subinventory
9667     ,       SHIP_TOLERANCE_ABOVE           = p_line_rec.ship_tolerance_above
9668     ,       SHIP_TOLERANCE_BELOW           = p_line_rec.ship_tolerance_below
9669     ,       SHIPPABLE_FLAG                 = p_line_rec.shippable_flag
9670     ,       SHIPPING_INTERFACED_FLAG       = p_line_rec.shipping_interfaced_flag
9671     ,       SHIP_TO_CONTACT_ID             = p_line_rec.ship_to_contact_id
9672     ,       SHIP_TO_ORG_ID                 = p_line_rec.ship_to_org_id
9673     ,       SHIP_MODEL_COMPLETE_FLAG       = p_line_rec.ship_model_complete_flag
9674     ,       SHIP_SET_ID                    = p_line_rec.ship_set_id
9675     ,       SOLD_TO_ORG_ID                 = p_line_rec.sold_to_org_id
9676     ,       SOLD_FROM_ORG_ID               = p_line_rec.sold_from_org_id
9677     ,       SORT_ORDER                     = p_line_rec.sort_order
9678     ,       SOURCE_DOCUMENT_ID             = p_line_rec.source_document_id
9679     ,       SOURCE_DOCUMENT_LINE_ID        = p_line_rec.source_document_line_id
9680     ,       SOURCE_DOCUMENT_TYPE_ID        = p_line_rec.source_document_type_id
9681     ,       SOURCE_TYPE_CODE               = p_line_rec.source_type_code
9682     ,       SPLIT_FROM_LINE_ID             = p_line_rec.split_from_line_id
9683     ,       LINE_SET_ID                    = p_line_rec.line_set_id
9684     ,       SPLIT_BY                       = p_line_rec.split_by
9685     ,       MODEL_REMNANT_FLAG             = p_line_rec.model_remnant_flag
9686     ,       TASK_ID                        = p_line_rec.task_id
9687     ,       TAX_CODE                       = p_line_rec.tax_code
9688     ,       TAX_DATE                       = p_line_rec.tax_date
9689     ,       TAX_EXEMPT_FLAG                = p_line_rec.tax_exempt_flag
9690     ,       TAX_EXEMPT_NUMBER              = p_line_rec.tax_exempt_number
9691     ,       TAX_EXEMPT_REASON_CODE         = p_line_rec.tax_exempt_reason_code
9692     ,       TAX_POINT_CODE                 = p_line_rec.tax_point_code
9693     ,       TAX_RATE                       = p_line_rec.tax_rate
9694     ,       TAX_VALUE                      = p_line_rec.tax_value
9695     ,       TOP_MODEL_LINE_ID              = p_line_rec.top_model_line_id
9696     ,       UNIT_LIST_PRICE                = p_line_rec.unit_list_price
9697     ,       UNIT_LIST_PRICE_PER_PQTY       = p_line_rec.unit_list_price_per_pqty
9698     ,       UNIT_SELLING_PRICE             = p_line_rec.unit_selling_price
9699     ,       UNIT_SELLING_PRICE_PER_PQTY    = p_line_rec.unit_selling_price_per_pqty
9700     ,       VISIBLE_DEMAND_FLAG            = p_line_rec.visible_demand_flag
9701     ,       VEH_CUS_ITEM_CUM_KEY_ID        = p_line_rec.veh_cus_item_cum_key_id
9702     ,       SHIPPING_INSTRUCTIONS          = p_line_rec.shipping_instructions
9703     ,       PACKING_INSTRUCTIONS           = p_line_rec.packing_instructions
9704     ,       SERVICE_TXN_REASON_CODE        = p_line_rec.service_txn_reason_code
9705     ,       SERVICE_TXN_COMMENTS           = p_line_rec.service_txn_comments
9706     ,       SERVICE_DURATION               = p_line_rec.service_duration
9707     ,       SERVICE_PERIOD                 = p_line_rec.service_period
9708     ,       SERVICE_START_DATE             = p_line_rec.service_start_date
9709     ,       SERVICE_END_DATE               = p_line_rec.service_end_date
9710     ,       SERVICE_COTERMINATE_FLAG       = p_line_rec.service_coterminate_flag
9711     ,       UNIT_LIST_PERCENT           = p_line_rec.unit_list_percent
9712     ,       UNIT_SELLING_PERCENT        = p_line_rec.unit_selling_percent
9713     ,       UNIT_PERCENT_BASE_PRICE     = p_line_rec.unit_percent_base_price
9714     ,       SERVICE_NUMBER              = p_line_rec.service_number
9715     ,       SERVICE_REFERENCE_TYPE_CODE = p_line_rec.service_reference_type_code
9716     ,       SERVICE_REFERENCE_LINE_ID   = p_line_rec.service_reference_line_id
9717     ,       SERVICE_REFERENCE_SYSTEM_ID = p_line_rec.service_reference_system_id
9718     ,       TP_CONTEXT                  = p_line_rec.tp_context
9719     ,       TP_ATTRIBUTE1               = p_line_rec.tp_attribute1
9720     ,       TP_ATTRIBUTE2               = p_line_rec.tp_attribute2
9721     ,       TP_ATTRIBUTE3               = p_line_rec.tp_attribute3
9722     ,       TP_ATTRIBUTE4               = p_line_rec.tp_attribute4
9723     ,       TP_ATTRIBUTE5               = p_line_rec.tp_attribute5
9724     ,       TP_ATTRIBUTE6               = p_line_rec.tp_attribute6
9725     ,       TP_ATTRIBUTE7               = p_line_rec.tp_attribute7
9726     ,       TP_ATTRIBUTE8               = p_line_rec.tp_attribute8
9727     ,       TP_ATTRIBUTE9               = p_line_rec.tp_attribute9
9728     ,       TP_ATTRIBUTE10              = p_line_rec.tp_attribute10
9729     ,       TP_ATTRIBUTE11              = p_line_rec.tp_attribute11
9730     ,       TP_ATTRIBUTE12              = p_line_rec.tp_attribute12
9731     ,       TP_ATTRIBUTE13              = p_line_rec.tp_attribute13
9732     ,       TP_ATTRIBUTE14              = p_line_rec.tp_attribute14
9733     ,       TP_ATTRIBUTE15              = p_line_rec.tp_attribute15
9734     ,       FLOW_STATUS_CODE		     = p_line_rec.flow_status_code
9735     ,       MARKETING_SOURCE_CODE_ID    = p_line_rec.marketing_source_code_id
9736     ,       ORIGINAL_INVENTORY_ITEM_ID  = p_line_rec.Original_Inventory_Item_Id
9737     ,       ORIGINAL_ITEM_IDENTIFIER_TYPE = p_line_rec.Original_item_identifier_Type
9738     ,       ORIGINAL_ORDERED_ITEM_ID    = p_line_rec.Original_ordered_item_id
9739     ,       ORIGINAL_ORDERED_ITEM       = p_line_rec.Original_ordered_item
9740     ,       ITEM_RELATIONSHIP_TYPE      = p_line_rec.item_relationship_type
9741     ,       ITEM_SUBSTITUTION_TYPE_CODE = p_line_rec.Item_substitution_type_code
9742     ,       LATE_DEMAND_PENALTY_FACTOR  = p_line_rec.Late_Demand_Penalty_Factor
9743     ,       OVERRIDE_ATP_DATE_CODE      = p_line_rec.Override_atp_date_code
9744     ,       FIRM_DEMAND_FLAG            = p_line_rec.firm_demand_flag
9745     ,       EARLIEST_SHIP_DATE          = p_line_rec.earliest_ship_date
9746     ,       USER_ITEM_DESCRIPTION       = p_line_rec.User_Item_Description
9747     ,       BLANKET_NUMBER              = p_line_rec.Blanket_Number
9748     ,       BLANKET_LINE_NUMBER         = p_line_rec.Blanket_Line_Number
9749     ,       BLANKET_VERSION_NUMBER      = p_line_rec.Blanket_Version_Number
9750     --MRG B
9751     ,       UNIT_COST                   = p_line_rec.unit_cost
9752     --MRG E
9753     ,       LOCK_CONTROL                = l_lock_control
9754 -- Changes for quoting
9755     ,	    transaction_phase_code      = p_line_rec.transaction_phase_code
9756      ,      source_document_version_number = p_line_rec.source_document_version_number
9757 -- end changes for quoting
9758     ,       MINISITE_ID                 = p_line_rec.Minisite_Id
9759     ,       IB_OWNER                    = p_line_rec.Ib_owner
9760     ,       IB_INSTALLED_AT_LOCATION    = p_line_rec.Ib_INSTALLED_AT_LOCATION
9761     ,       IB_CURRENT_LOCATION         = p_line_rec.Ib_current_location
9762     ,       END_CUSTOMER_ID             = p_line_rec.End_Customer_Id
9763     ,       END_CUSTOMER_CONTACT_ID     = p_line_rec.End_Customer_CONTACT_Id
9764     ,       END_CUSTOMER_SITE_USE_ID    = p_line_rec.End_Customer_site_use_Id
9765  /*   ,       SUPPLIER_SIGNATURE          = p_line_rec.SUPPLIER_SIGNATURE
9766     ,       SUPPLIER_SIGNATURE_DATE     = p_line_rec.SUPPLIER_SIGNATURE_DATE
9767     ,       CUSTOMER_SIGNATURE          = p_line_rec.CUSTOMER_SIGNATURE
9768     ,       CUSTOMER_SIGNATURE_DATE     = p_line_rec.CUSTOMER_SIGNATURE_DATE
9769 */
9770     --retro{
9771     ,       RETROBILL_REQUEST_ID        = p_line_rec.retrobill_request_id
9772     --retro
9773     -- Override List Price
9774     ,       ORIGINAL_LIST_PRICE         = p_line_rec.original_list_price
9775 --key Transaction Dates
9776     ,       ORDER_FIRMED_DATE           = p_line_rec.order_firmed_date
9777     ,       ACTUAL_FULFILLMENT_DATE     = p_line_rec.actual_fulfillment_date
9778     --recurring charges
9779     , CHARGE_PERIODICITY_CODE = p_line_rec.charge_periodicity_code
9780 -- INVCONV
9781     ,       CANCELLED_QUANTITY2         = p_line_rec.cancelled_quantity2
9782     ,       SHIPPING_QUANTITY_UOM2      = p_line_rec.shipping_quantity_uom2
9783     ,       FULFILLED_QUANTITY2         = p_line_rec.fulfilled_quantity2
9784 --Customer Acceptance
9785     ,       CONTINGENCY_ID	        = p_line_rec.CONTINGENCY_ID
9786     ,       REVREC_EVENT_CODE	        = p_line_rec.REVREC_EVENT_CODE
9787     ,       REVREC_EXPIRATION_DAYS	= p_line_rec.REVREC_EXPIRATION_DAYS
9788     ,       ACCEPTED_QUANTITY	        = p_line_rec.ACCEPTED_QUANTITY
9789     ,       REVREC_COMMENTS	        = p_line_rec.REVREC_COMMENTS
9790     ,       REVREC_SIGNATURE	        = p_line_rec.REVREC_SIGNATURE
9791     ,       REVREC_SIGNATURE_DATE	= p_line_rec.REVREC_SIGNATURE_DATE
9792     ,       ACCEPTED_BY           	= p_line_rec.ACCEPTED_BY
9793     ,       REVREC_REFERENCE_DOCUMENT	= p_line_rec.REVREC_REFERENCE_DOCUMENT
9794     ,       REVREC_IMPLICIT_FLAG	= p_line_rec.REVREC_IMPLICIT_FLAG
9795     -- sol_ord_er #16014165
9796 	, 		SERVICE_BILL_PROFILE_ID = p_line_rec.service_bill_profile_id
9797 	, 		SERVICE_COV_TEMPLATE_ID = p_line_rec.service_cov_template_id
9798 	, 		SERVICE_SUBS_TEMPLATE_ID = p_line_rec.service_subs_template_id
9799 	, 		SERVICE_BILL_OPTION_CODE = p_line_rec.service_bill_option_code
9800 	, 		SUBSCRIPTION_ENABLE_FLAG = p_line_rec.subscription_enable_flag
9801 	,		SERVICE_FIRST_PERIOD_AMOUNT = p_line_rec.service_first_period_amount
9802 	,       SERVICE_FIRST_PERIOD_ENDDATE = p_line_rec.service_first_period_enddate
9803 	-- sol_ord_er #16014165 end
9804     ,       FULFILLMENT_BASE            = p_line_rec.FULFILLMENT_BASE--ER#14763609
9805     WHERE   LINE_ID 			   = p_line_rec.line_id
9806       AND   HEADER_ID 			   = p_line_rec.header_id ;
9807 
9808 	IF SQL%NOTFOUND THEN
9809         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9810         END IF;
9811 
9812     p_line_rec.lock_control := l_lock_control;
9813 
9814   if l_debug_level > 0 then
9815     oe_debug_pub.add('Exiting OE_LINE_UTIL.UPDATE_ROW', 1);
9816   end if;
9817 
9818 EXCEPTION
9819 
9820 
9821     WHEN OTHERS THEN
9822 
9823         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
9824         THEN
9825             OE_MSG_PUB.Add_Exc_Msg
9826             (   G_PKG_NAME
9827             ,   'Update_Row'
9828             );
9829         END IF;
9830 
9831         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9832 
9833 
9834 END Update_Row;
9835 
9836 
9837 /*-----------------------------------------------------------
9838 Procedure Insert_Row
9839 -----------------------------------------------------------*/
9840 
9841 PROCEDURE Insert_Row
9842 (   p_line_rec                      IN  OUT  NOCOPY OE_Order_PUB.Line_Rec_Type
9843 )
9844 IS
9845 l_org_id 	NUMBER ;
9846 l_sold_from_org NUMBER;
9847 l_upgraded_flag varchar2(1);
9848 l_lock_control  NUMBER:= 1;
9849 l_index         NUMBER;
9850 l_return_status VARCHAR2(1);
9851 
9852 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
9853 --bug 4446805
9854 l_price_request_code VARCHAR2(240);
9855 BEGIN
9856 
9857   if l_debug_level > 0 then
9858     oe_debug_pub.add('Entering OE_LINE_UTIL.INSERT_ROW', 1);
9859   end if;
9860 
9861  --MOAC change
9862  OE_GLOBALS.Set_Context;
9863  l_org_id := OE_GLOBALS.G_ORG_ID;
9864  IF l_org_id IS NULL THEN
9865      -- org_id is null, don't do insert. raise an error.
9866      IF l_debug_level > 0 then
9867           oe_debug_pub.ADD('Org_Id is NULL',1);
9868      END IF;
9869      FND_MESSAGE.SET_NAME('FND','MO_ORG_REQUIRED');
9870      FND_MSG_PUB.ADD;
9871      RAISE FND_API.G_EXC_ERROR;
9872  END IF;
9873  /*
9874 	    if l_org_id IS NULL THEN
9875 		    OE_GLOBALS.Set_Context;
9876 		    l_org_id := OE_GLOBALS.G_ORG_ID;
9877 	    end if;
9878  */
9879  l_sold_from_org := l_org_id;
9880 
9881 -- For the split's issue Bug #3721385
9882    if p_line_rec.split_from_line_id is not null and  p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
9883       (p_line_rec.sold_from_org_id is not null OR p_line_rec.sold_from_org_id <> FND_API.G_MISS_NUM)
9884    then
9885 
9886       l_sold_from_org := p_line_rec.sold_from_org_id;
9887    end if;
9888 
9889 -- This change is to ensure the upgraded flag is not populated through any
9890 -- source other than upgrade and split. Upgrade uses direct insertion and
9891 -- split follows this path.
9892 
9893 		IF  p_line_rec.split_from_line_id is null
9894 		THEN
9895 		  l_upgraded_flag := null;
9896 	     ELSE
9897 				l_upgraded_flag := p_line_rec.upgraded_flag;
9898 	     END IF;
9899 --bug 4446805 set the price request code to NULL if operation is create during splitting
9900         IF p_line_rec.split_from_line_id is not null AND
9901             p_line_rec.split_from_line_id <> FND_API.G_MISS_NUM AND
9902              p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE
9903         THEN
9904              l_price_request_code := NULL;
9905         ELSE
9906              l_price_request_code := p_line_rec.price_request_code;
9907         END IF;
9908 --End bug 4446805
9909 
9910     -- OPM 02/JUN/00 - Include process columns
9911     --                (ordered_quantity2,ordered_quantity_uom2,preferred_grade)
9912     -- =======================================================================
9913     INSERT  INTO OE_ORDER_LINES
9914     (       ACCOUNTING_RULE_ID
9915     ,       ACCOUNTING_RULE_DURATION
9916     ,       ACTUAL_ARRIVAL_DATE
9917     ,       ACTUAL_SHIPMENT_DATE
9918     ,       AGREEMENT_ID
9919     ,       ARRIVAL_SET_ID
9920     ,       ATO_LINE_ID
9921     ,       ATTRIBUTE1
9922     ,       ATTRIBUTE10
9923     ,       ATTRIBUTE11
9924     ,       ATTRIBUTE12
9925     ,       ATTRIBUTE13
9926     ,       ATTRIBUTE14
9927     ,       ATTRIBUTE15
9928     ,       ATTRIBUTE16   --For bug 2184255
9929     ,       ATTRIBUTE17
9930     ,       ATTRIBUTE18
9931     ,       ATTRIBUTE19
9932     ,       ATTRIBUTE2
9933     ,       ATTRIBUTE20
9934     ,       ATTRIBUTE3
9935     ,       ATTRIBUTE4
9936     ,       ATTRIBUTE5
9937     ,       ATTRIBUTE6
9938     ,       ATTRIBUTE7
9939     ,       ATTRIBUTE8
9940     ,       ATTRIBUTE9
9941     ,       AUTO_SELECTED_QUANTITY
9942     ,       AUTHORIZED_TO_SHIP_FLAG
9943     ,       BOOKED_FLAG
9944     ,       CANCELLED_FLAG
9945     ,       CANCELLED_QUANTITY
9946     ,       COMPONENT_CODE
9947     ,       COMPONENT_NUMBER
9948     ,       COMPONENT_SEQUENCE_ID
9949     ,       CONFIG_HEADER_ID
9950     ,       CONFIG_REV_NBR
9951     ,       CONFIG_DISPLAY_SEQUENCE
9952     ,       CONFIGURATION_ID
9953     ,       CONTEXT
9954     ,       CREATED_BY
9955     ,       CREATION_DATE
9956     ,       CREDIT_INVOICE_LINE_ID
9957     ,       CUSTOMER_LINE_NUMBER
9958     ,       CUSTOMER_SHIPMENT_NUMBER
9959     ,       CUSTOMER_ITEM_NET_PRICE
9960     ,       CUSTOMER_PAYMENT_TERM_ID
9961     ,       CUSTOMER_DOCK_CODE
9962     ,       CUSTOMER_JOB
9963     ,       CUSTOMER_PRODUCTION_LINE
9964     ,       CUST_PRODUCTION_SEQ_NUM
9965     ,       CUSTOMER_TRX_LINE_ID
9966     ,       CUST_MODEL_SERIAL_NUMBER
9967     ,       CUST_PO_NUMBER
9968     ,       DELIVERY_LEAD_TIME
9969     ,       DELIVER_TO_CONTACT_ID
9970     ,       DELIVER_TO_ORG_ID
9971     ,       DEMAND_BUCKET_TYPE_CODE
9972     ,       DEMAND_CLASS_CODE
9973     ,       DEP_PLAN_REQUIRED_FLAG
9974     --,       DROP_SHIP_FLAG
9975     ,       EARLIEST_ACCEPTABLE_DATE
9976     ,       END_ITEM_UNIT_NUMBER
9977     ,       EXPLOSION_DATE
9978     ,       FIRST_ACK_CODE
9979     ,       FIRST_ACK_DATE
9980     ,       FOB_POINT_CODE
9981     ,       FREIGHT_CARRIER_CODE
9982     ,       FREIGHT_TERMS_CODE
9983     ,       FULFILLED_QUANTITY
9984     ,       FULFILLED_FLAG
9985     ,       FULFILLMENT_METHOD_CODE
9986     ,       FULFILLMENT_DATE
9987     ,       GLOBAL_ATTRIBUTE1
9988     ,       GLOBAL_ATTRIBUTE10
9989     ,       GLOBAL_ATTRIBUTE11
9990     ,       GLOBAL_ATTRIBUTE12
9991     ,       GLOBAL_ATTRIBUTE13
9992     ,       GLOBAL_ATTRIBUTE14
9993     ,       GLOBAL_ATTRIBUTE15
9994     ,       GLOBAL_ATTRIBUTE16
9995     ,       GLOBAL_ATTRIBUTE17
9996     ,       GLOBAL_ATTRIBUTE18
9997     ,       GLOBAL_ATTRIBUTE19
9998     ,       GLOBAL_ATTRIBUTE2
9999     ,       GLOBAL_ATTRIBUTE20
10000     ,       GLOBAL_ATTRIBUTE3
10001     ,       GLOBAL_ATTRIBUTE4
10002     ,       GLOBAL_ATTRIBUTE5
10003     ,       GLOBAL_ATTRIBUTE6
10004     ,       GLOBAL_ATTRIBUTE7
10005     ,       GLOBAL_ATTRIBUTE8
10006     ,       GLOBAL_ATTRIBUTE9
10007     ,       GLOBAL_ATTRIBUTE_CATEGORY
10008     ,       HEADER_ID
10009     ,       INDUSTRY_ATTRIBUTE1
10010     ,       INDUSTRY_ATTRIBUTE10
10011     ,       INDUSTRY_ATTRIBUTE11
10012     ,       INDUSTRY_ATTRIBUTE12
10013     ,       INDUSTRY_ATTRIBUTE13
10014     ,       INDUSTRY_ATTRIBUTE14
10015     ,       INDUSTRY_ATTRIBUTE15
10016     ,       INDUSTRY_ATTRIBUTE16
10017     ,       INDUSTRY_ATTRIBUTE17
10018     ,       INDUSTRY_ATTRIBUTE18
10019     ,       INDUSTRY_ATTRIBUTE19
10020     ,       INDUSTRY_ATTRIBUTE20
10021     ,       INDUSTRY_ATTRIBUTE21
10022     ,       INDUSTRY_ATTRIBUTE22
10023     ,       INDUSTRY_ATTRIBUTE23
10024     ,       INDUSTRY_ATTRIBUTE24
10025     ,       INDUSTRY_ATTRIBUTE25
10026     ,       INDUSTRY_ATTRIBUTE26
10027     ,       INDUSTRY_ATTRIBUTE27
10028     ,       INDUSTRY_ATTRIBUTE28
10029     ,       INDUSTRY_ATTRIBUTE29
10030     ,       INDUSTRY_ATTRIBUTE30
10031     ,       INDUSTRY_ATTRIBUTE2
10032     ,       INDUSTRY_ATTRIBUTE3
10033     ,       INDUSTRY_ATTRIBUTE4
10034     ,       INDUSTRY_ATTRIBUTE5
10035     ,       INDUSTRY_ATTRIBUTE6
10036     ,       INDUSTRY_ATTRIBUTE7
10037     ,       INDUSTRY_ATTRIBUTE8
10038     ,       INDUSTRY_ATTRIBUTE9
10039     ,       INDUSTRY_CONTEXT
10040     ,       INTMED_SHIP_TO_CONTACT_ID
10041     ,       INTMED_SHIP_TO_ORG_ID
10042     ,       INVENTORY_ITEM_ID
10043     ,       INVOICE_INTERFACE_STATUS_CODE
10044     ,       INVOICE_TO_CONTACT_ID
10045     ,       INVOICE_TO_ORG_ID
10046     ,       INVOICED_QUANTITY
10047     ,       INVOICING_RULE_ID
10048     ,       ORDERED_ITEM_ID
10049     ,       ITEM_IDENTIFIER_TYPE
10050     ,       ORDERED_ITEM
10051     ,       ITEM_REVISION
10052     ,       ITEM_TYPE_CODE
10053     ,       LAST_ACK_CODE
10054     ,       LAST_ACK_DATE
10055     ,       LAST_UPDATED_BY
10056     ,       LAST_UPDATE_DATE
10057     ,       LAST_UPDATE_LOGIN
10058     ,       LATEST_ACCEPTABLE_DATE
10059     ,       LINE_CATEGORY_CODE
10060     ,       LINE_ID
10061     ,       LINE_NUMBER
10062     ,       LINE_TYPE_ID
10063     ,       LINK_TO_LINE_ID
10064     ,       MODEL_GROUP_NUMBER
10065    -- ,       MFG_COMPONENT_SEQUENCE_ID
10066     ,       MFG_LEAD_TIME
10067     ,       OPEN_FLAG
10068     ,       OPTION_FLAG
10069     ,       OPTION_NUMBER
10070     ,       ORDERED_QUANTITY
10071     ,       ORDERED_QUANTITY2           --OPM Added 02/JUN/00
10072     ,       ORDER_QUANTITY_UOM
10073     ,       ORDERED_QUANTITY_UOM2       --OPM Added 02/JUN/00
10074     ,       ORG_ID                      -- MOAC change
10075     ,       ORDER_SOURCE_ID
10076     ,       ORIG_SYS_DOCUMENT_REF
10077     ,       ORIG_SYS_LINE_REF
10078     ,       ORIG_SYS_SHIPMENT_REF
10079     ,       CHANGE_SEQUENCE
10080     ,       OVER_SHIP_REASON_CODE
10081     ,       OVER_SHIP_RESOLVED_FLAG
10082     ,       PAYMENT_TERM_ID
10083     ,       PLANNING_PRIORITY
10084     ,       PREFERRED_GRADE             --OPM Added 02/JUN/00
10085     ,       PRICE_LIST_ID
10086     ,       PRICE_REQUEST_CODE          --PROMOTIONS SEP/01
10087     ,       PRICING_ATTRIBUTE1
10088     ,       PRICING_ATTRIBUTE10
10089     ,       PRICING_ATTRIBUTE2
10090     ,       PRICING_ATTRIBUTE3
10091     ,       PRICING_ATTRIBUTE4
10092     ,       PRICING_ATTRIBUTE5
10093     ,       PRICING_ATTRIBUTE6
10094     ,       PRICING_ATTRIBUTE7
10095     ,       PRICING_ATTRIBUTE8
10096     ,       PRICING_ATTRIBUTE9
10097     ,       PRICING_CONTEXT
10098     ,       PRICING_DATE
10099     ,       PRICING_QUANTITY
10100     ,       PRICING_QUANTITY_UOM
10101     ,       PROGRAM_APPLICATION_ID
10102     ,       PROGRAM_ID
10103     ,       PROGRAM_UPDATE_DATE
10104     ,       PROJECT_ID
10105     ,       PROMISE_DATE
10106     ,       RE_SOURCE_FLAG
10107     ,       REFERENCE_CUSTOMER_TRX_LINE_ID
10108     ,       REFERENCE_HEADER_ID
10109     ,       REFERENCE_LINE_ID
10110     ,       REFERENCE_TYPE
10111     ,       REQUEST_DATE
10112     ,       REQUEST_ID
10113     ,       RETURN_ATTRIBUTE1
10114     ,       RETURN_ATTRIBUTE10
10115     ,       RETURN_ATTRIBUTE11
10116     ,       RETURN_ATTRIBUTE12
10117     ,       RETURN_ATTRIBUTE13
10118     ,       RETURN_ATTRIBUTE14
10119     ,       RETURN_ATTRIBUTE15
10120     ,       RETURN_ATTRIBUTE2
10121     ,       RETURN_ATTRIBUTE3
10122     ,       RETURN_ATTRIBUTE4
10123     ,       RETURN_ATTRIBUTE5
10124     ,       RETURN_ATTRIBUTE6
10125     ,       RETURN_ATTRIBUTE7
10126     ,       RETURN_ATTRIBUTE8
10127     ,       RETURN_ATTRIBUTE9
10128     ,       RETURN_CONTEXT
10129     ,       RETURN_REASON_CODE
10130     ,       RLA_SCHEDULE_TYPE_CODE
10131     ,       SALESREP_ID
10132     ,       SCHEDULE_ARRIVAL_DATE
10133     ,       SCHEDULE_SHIP_DATE
10134     ,       SCHEDULE_STATUS_CODE
10135     ,       SHIPMENT_NUMBER
10136     ,       SHIPMENT_PRIORITY_CODE
10137     ,       SHIPPED_QUANTITY
10138     ,       SHIPPED_QUANTITY2 -- OPM B1661023 04/02/01
10139     ,       SHIPPING_METHOD_CODE
10140     ,       SHIPPING_QUANTITY
10141     ,       SHIPPING_QUANTITY2 -- OPM B1661023 04/02/01
10142     ,       SHIPPING_QUANTITY_UOM
10143     ,       SHIP_FROM_ORG_ID
10144     ,       SUBINVENTORY
10145     ,       SHIP_SET_ID
10146     ,       SHIP_TOLERANCE_ABOVE
10147     ,       SHIP_TOLERANCE_BELOW
10148     ,       SHIPPABLE_FLAG
10149     ,       SHIPPING_INTERFACED_FLAG
10150     ,       SHIP_TO_CONTACT_ID
10151     ,       SHIP_TO_ORG_ID
10152     ,       SHIP_MODEL_COMPLETE_FLAG
10153     ,       SOLD_TO_ORG_ID
10154     ,       SOLD_FROM_ORG_ID
10155     ,       SORT_ORDER
10156     ,       SOURCE_DOCUMENT_ID
10157     ,       SOURCE_DOCUMENT_LINE_ID
10158     ,       SOURCE_DOCUMENT_TYPE_ID
10159     ,       SOURCE_TYPE_CODE
10160     ,       SPLIT_FROM_LINE_ID
10161     ,       LINE_SET_ID
10162     ,       SPLIT_BY
10163     ,       model_remnant_flag
10164     ,       TASK_ID
10165     ,       TAX_CODE
10166     ,       TAX_DATE
10167     ,       TAX_EXEMPT_FLAG
10168     ,       TAX_EXEMPT_NUMBER
10169     ,       TAX_EXEMPT_REASON_CODE
10170     ,       TAX_POINT_CODE
10171     ,       TAX_RATE
10172     ,       TAX_VALUE
10173     ,       TOP_MODEL_LINE_ID
10174     ,       UNIT_LIST_PRICE
10175     ,       UNIT_LIST_PRICE_PER_PQTY
10176     ,       UNIT_SELLING_PRICE
10177     ,       UNIT_SELLING_PRICE_PER_PQTY
10178     ,       VISIBLE_DEMAND_FLAG
10179     ,       VEH_CUS_ITEM_CUM_KEY_ID
10180     ,       SHIPPING_INSTRUCTIONS
10181     ,       PACKING_INSTRUCTIONS
10182     ,       SERVICE_TXN_REASON_CODE
10183     ,       SERVICE_TXN_COMMENTS
10184     ,       SERVICE_DURATION
10185     ,       SERVICE_PERIOD
10186     ,       SERVICE_START_DATE
10187     ,       SERVICE_END_DATE
10188     ,       SERVICE_COTERMINATE_FLAG
10189     ,       UNIT_LIST_PERCENT
10190     ,       UNIT_SELLING_PERCENT
10191     ,       UNIT_PERCENT_BASE_PRICE
10192     ,       SERVICE_NUMBER
10193     ,       SERVICE_REFERENCE_TYPE_CODE
10194     ,       SERVICE_REFERENCE_LINE_ID
10195     ,       SERVICE_REFERENCE_SYSTEM_ID
10196     ,       TP_CONTEXT
10197     ,       TP_ATTRIBUTE1
10198     ,       TP_ATTRIBUTE2
10199     ,       TP_ATTRIBUTE3
10200     ,       TP_ATTRIBUTE4
10201     ,       TP_ATTRIBUTE5
10202     ,       TP_ATTRIBUTE6
10203     ,       TP_ATTRIBUTE7
10204     ,       TP_ATTRIBUTE8
10205     ,       TP_ATTRIBUTE9
10206     ,       TP_ATTRIBUTE10
10207     ,       TP_ATTRIBUTE11
10208     ,       TP_ATTRIBUTE12
10209     ,       TP_ATTRIBUTE13
10210     ,       TP_ATTRIBUTE14
10211     ,       TP_ATTRIBUTE15
10212     ,       FLOW_STATUS_CODE
10213     ,       MARKETING_SOURCE_CODE_ID
10214     ,       CALCULATE_PRICE_FLAG
10215     ,       COMMITMENT_ID
10216     ,       UPGRADED_FLAG
10217     ,       ORIGINAL_INVENTORY_ITEM_ID
10218     ,       ORIGINAL_ITEM_IDENTIFIER_TYPE
10219     ,       ORIGINAL_ORDERED_ITEM_ID
10220     ,       ORIGINAL_ORDERED_ITEM
10221     ,       ITEM_RELATIONSHIP_TYPE
10222     ,       ITEM_SUBSTITUTION_TYPE_CODE
10223     ,       LATE_DEMAND_PENALTY_FACTOR
10224     ,       OVERRIDE_ATP_DATE_CODE
10225     ,       FIRM_DEMAND_FLAG
10226     ,       EARLIEST_SHIP_DATE
10227     ,       USER_ITEM_DESCRIPTION
10228     ,       BLANKET_NUMBER
10229     ,       BLANKET_LINE_NUMBER
10230     ,       BLANKET_VERSION_NUMBER
10231 --MRG B
10232     ,       UNIT_COST
10233 --MRG E
10234     ,       LOCK_CONTROL
10235 -- Changes for quoting
10236     ,	    transaction_phase_code
10237     ,       source_document_version_number
10238 -- end changes for quoting
10239    ,        Minisite_ID
10240    ,        Ib_Owner
10241    ,        Ib_installed_at_location
10242    ,        Ib_current_location
10243    ,        End_customer_ID
10244    ,        End_customer_contact_ID
10245    ,        End_customer_site_use_ID
10246  /*  ,        Supplier_signature
10247    ,        Supplier_signature_date
10248    ,        Customer_signature
10249    ,        Customer_signature_date  */
10250 --retro{
10251     ,       RETROBILL_REQUEST_ID
10252 --retro}
10253     ,       ORIGINAL_LIST_PRICE  -- Override List Price
10254  -- Key Transaction Dates
10255     ,       order_firmed_date
10256     ,       actual_fulfillment_date
10257     --recurring charges
10258     ,       charge_periodicity_code
10259 -- INVCONV
10260     ,       CANCELLED_QUANTITY2
10261     ,       SHIPPING_QUANTITY_UOM2
10262     ,       FULFILLED_QUANTITY2
10263 --Customer Acceptance
10264     ,       CONTINGENCY_ID
10265     ,       REVREC_EVENT_CODE
10266     ,       REVREC_EXPIRATION_DAYS
10267     ,       ACCEPTED_QUANTITY
10268     ,       REVREC_COMMENTS
10269     ,       REVREC_SIGNATURE
10270     ,       REVREC_SIGNATURE_DATE
10271     ,       ACCEPTED_BY
10272     ,       REVREC_REFERENCE_DOCUMENT
10273     ,       REVREC_IMPLICIT_FLAG
10274 
10275 -- { DOO/O2C Integration
10276     ,      BYPASS_SCH_FLAG
10277     ,      PRE_EXPLODED_FLAG
10278 --  DOO/O2C Integration }
10279 	-- sol_ord_er #16014165
10280 	, 		SERVICE_BILL_PROFILE_ID
10281 	, 		SERVICE_COV_TEMPLATE_ID
10282 	, 		SERVICE_SUBS_TEMPLATE_ID
10283 	, 		SERVICE_BILL_OPTION_CODE
10284 	, 		SUBSCRIPTION_ENABLE_FLAG
10285 	, 		SERVICE_FIRST_PERIOD_AMOUNT
10286 	,       SERVICE_FIRST_PERIOD_ENDDATE
10287 	-- sol_ord_er #16014165 end
10288     ,      FULFILLMENT_BASE--ER#14763609
10289     )
10290     VALUES
10291     (       p_line_rec.accounting_rule_id
10292     ,       p_line_rec.accounting_rule_duration
10293     ,       p_line_rec.actual_arrival_date
10294     ,       p_line_rec.actual_shipment_date
10295     ,       p_line_rec.agreement_id
10296     ,       p_line_rec.arrival_set_id
10297     ,       p_line_rec.ato_line_id
10298     ,       p_line_rec.attribute1
10299     ,       p_line_rec.attribute10
10300     ,       p_line_rec.attribute11
10301     ,       p_line_rec.attribute12
10302     ,       p_line_rec.attribute13
10303     ,       p_line_rec.attribute14
10304     ,       p_line_rec.attribute15
10305     ,       p_line_rec.attribute16   --For bug 2184255
10306     ,       p_line_rec.attribute17
10307     ,       p_line_rec.attribute18
10308     ,       p_line_rec.attribute19
10309     ,       p_line_rec.attribute2
10310     ,       p_line_rec.attribute20
10311     ,       p_line_rec.attribute3
10312     ,       p_line_rec.attribute4
10313     ,       p_line_rec.attribute5
10314     ,       p_line_rec.attribute6
10315     ,       p_line_rec.attribute7
10316     ,       p_line_rec.attribute8
10317     ,       p_line_rec.attribute9
10318     ,       p_line_rec.auto_selected_quantity
10319     ,       p_line_rec.authorized_to_ship_flag
10320     ,       p_line_rec.booked_flag
10321     ,       p_line_rec.cancelled_flag
10322     ,       p_line_rec.cancelled_quantity
10323     ,       p_line_rec.component_code
10324     ,       p_line_rec.component_number
10325     ,       p_line_rec.component_sequence_id
10326     ,       p_line_rec.config_header_id
10327     ,       p_line_rec.config_rev_nbr
10328     ,       p_line_rec.config_display_sequence
10329     ,       p_line_rec.configuration_id
10330     ,       p_line_rec.context
10331     ,       p_line_rec.created_by
10332     ,       p_line_rec.creation_date
10333     ,       p_line_rec.credit_invoice_line_id
10334     ,       p_line_rec.customer_line_number
10335     ,       p_line_rec.customer_shipment_number
10336     ,       p_line_rec.customer_item_net_price
10337     ,       p_line_rec.customer_payment_term_id
10338     ,       p_line_rec.customer_dock_code
10339     ,       p_line_rec.customer_job
10340     ,       p_line_rec.customer_production_line
10341     ,       p_line_rec.cust_production_seq_num
10342     ,       p_line_rec.customer_trx_line_id
10343     ,       p_line_rec.cust_model_serial_number
10344     ,       p_line_rec.cust_po_number
10345     ,       p_line_rec.delivery_lead_time
10346     ,       p_line_rec.deliver_to_contact_id
10347     ,       p_line_rec.deliver_to_org_id
10348     ,       p_line_rec.demand_bucket_type_code
10349     ,       p_line_rec.demand_class_code
10350     ,       p_line_rec.dep_plan_required_flag
10351     --,       p_line_rec.drop_ship_flag
10352     ,       p_line_rec.earliest_acceptable_date
10353     ,       p_line_rec.end_item_unit_number
10354     ,       p_line_rec.explosion_date
10355     ,       p_line_rec.first_ack_code
10356     ,       p_line_rec.first_ack_date
10357     ,       p_line_rec.fob_point_code
10358     ,       p_line_rec.freight_carrier_code
10359     ,       p_line_rec.freight_terms_code
10360     ,       p_line_rec.fulfilled_quantity
10361     ,       p_line_rec.fulfilled_flag
10362     ,       p_line_rec.fulfillment_method_code
10363     ,       p_line_rec.fulfillment_date
10364     ,       p_line_rec.global_attribute1
10365     ,       p_line_rec.global_attribute10
10366     ,       p_line_rec.global_attribute11
10367     ,       p_line_rec.global_attribute12
10368     ,       p_line_rec.global_attribute13
10369     ,       p_line_rec.global_attribute14
10370     ,       p_line_rec.global_attribute15
10371     ,       p_line_rec.global_attribute16
10372     ,       p_line_rec.global_attribute17
10373     ,       p_line_rec.global_attribute18
10374     ,       p_line_rec.global_attribute19
10375     ,       p_line_rec.global_attribute2
10376     ,       p_line_rec.global_attribute20
10377     ,       p_line_rec.global_attribute3
10378     ,       p_line_rec.global_attribute4
10379     ,       p_line_rec.global_attribute5
10380     ,       p_line_rec.global_attribute6
10381     ,       p_line_rec.global_attribute7
10382     ,       p_line_rec.global_attribute8
10383     ,       p_line_rec.global_attribute9
10384     ,       p_line_rec.global_attribute_category
10385     ,       p_line_rec.header_id
10386     ,       p_line_rec.industry_attribute1
10387     ,       p_line_rec.industry_attribute10
10388     ,       p_line_rec.industry_attribute11
10389     ,       p_line_rec.industry_attribute12
10390     ,       p_line_rec.industry_attribute13
10391     ,       p_line_rec.industry_attribute14
10392     ,       p_line_rec.industry_attribute15
10393     ,       p_line_rec.industry_attribute16
10394     ,       p_line_rec.industry_attribute17
10395     ,       p_line_rec.industry_attribute18
10396     ,       p_line_rec.industry_attribute19
10397     ,       p_line_rec.industry_attribute20
10398     ,       p_line_rec.industry_attribute21
10399     ,       p_line_rec.industry_attribute22
10400     ,       p_line_rec.industry_attribute23
10401     ,       p_line_rec.industry_attribute24
10402     ,       p_line_rec.industry_attribute25
10403     ,       p_line_rec.industry_attribute26
10404     ,       p_line_rec.industry_attribute27
10405     ,       p_line_rec.industry_attribute28
10406     ,       p_line_rec.industry_attribute29
10407     ,       p_line_rec.industry_attribute30
10408     ,       p_line_rec.industry_attribute2
10409     ,       p_line_rec.industry_attribute3
10410     ,       p_line_rec.industry_attribute4
10411     ,       p_line_rec.industry_attribute5
10412     ,       p_line_rec.industry_attribute6
10413     ,       p_line_rec.industry_attribute7
10414     ,       p_line_rec.industry_attribute8
10415     ,       p_line_rec.industry_attribute9
10416     ,       p_line_rec.industry_context
10417     ,       p_line_rec.intermed_ship_to_contact_id
10418     ,       p_line_rec.intermed_ship_to_org_id
10419     ,       p_line_rec.inventory_item_id
10420     ,       p_line_rec.invoice_interface_status_code
10421     ,       p_line_rec.invoice_to_contact_id
10422     ,       p_line_rec.invoice_to_org_id
10423     ,       p_line_rec.invoiced_quantity
10424     ,       p_line_rec.invoicing_rule_id
10425     ,       p_line_rec.ordered_item_id
10426     ,       p_line_rec.item_identifier_type
10427     ,       p_line_rec.ordered_item
10428     ,       p_line_rec.item_revision
10429     ,       p_line_rec.item_type_code
10430     ,       p_line_rec.last_ack_code
10431     ,       p_line_rec.last_ack_date
10432     ,       p_line_rec.last_updated_by
10433     ,       p_line_rec.last_update_date
10434     ,       p_line_rec.last_update_login
10435     ,       p_line_rec.latest_acceptable_date
10436     ,       p_line_rec.line_category_code
10437     ,       p_line_rec.line_id
10438     ,       p_line_rec.line_number
10439     ,       p_line_rec.line_type_id
10440     ,       p_line_rec.link_to_line_id
10441     ,       p_line_rec.model_group_number
10442     --,       p_line_rec.mfg_component_sequence_id
10443     ,       p_line_rec.mfg_lead_time
10444     ,       p_line_rec.open_flag
10445     ,       p_line_rec.option_flag
10446     ,       p_line_rec.option_number
10447     ,       p_line_rec.ordered_quantity
10448     ,       p_line_rec.ordered_quantity2          --OPM 02/JUN/00
10449     ,       p_line_rec.order_quantity_uom
10450     ,       p_line_rec.ordered_quantity_uom2      --OPM 02/JUN/00
10451     ,       l_org_id                              --MOAC change
10452     ,       p_line_rec.order_source_id
10453     ,       p_line_rec.orig_sys_document_ref
10454     ,       p_line_rec.orig_sys_line_ref
10455     ,       p_line_rec.orig_sys_shipment_ref
10456     ,       p_line_rec.change_sequence
10457     ,       p_line_rec.over_ship_reason_code
10458     ,       p_line_rec.over_ship_resolved_flag
10459     ,       p_line_rec.payment_term_id
10460     ,       p_line_rec.planning_priority
10461     ,       p_line_rec.preferred_grade            --OPM 02/JUN/00
10462     ,       p_line_rec.price_list_id
10463     ,       l_price_request_code         --PROMOTIONS SEP/01   --bug 4446805
10464     ,       p_line_rec.pricing_attribute1
10465     ,       p_line_rec.pricing_attribute10
10466     ,       p_line_rec.pricing_attribute2
10467     ,       p_line_rec.pricing_attribute3
10468     ,       p_line_rec.pricing_attribute4
10469     ,       p_line_rec.pricing_attribute5
10470     ,       p_line_rec.pricing_attribute6
10471     ,       p_line_rec.pricing_attribute7
10472     ,       p_line_rec.pricing_attribute8
10473     ,       p_line_rec.pricing_attribute9
10474     ,       p_line_rec.pricing_context
10475     ,       p_line_rec.pricing_date
10476     ,       p_line_rec.pricing_quantity
10477     ,       p_line_rec.pricing_quantity_uom
10478     ,       p_line_rec.program_application_id
10479     ,       p_line_rec.program_id
10480     ,       p_line_rec.program_update_date
10481     ,       p_line_rec.project_id
10482     ,       p_line_rec.promise_date
10483     ,       p_line_rec.re_source_flag
10484     ,       p_line_rec.reference_customer_trx_line_id
10485     ,       p_line_rec.reference_header_id
10486     ,       p_line_rec.reference_line_id
10487     ,       p_line_rec.reference_type
10488     ,       p_line_rec.request_date
10489     ,       p_line_rec.request_id
10490     ,       p_line_rec.return_attribute1
10491     ,       p_line_rec.return_attribute10
10492     ,       p_line_rec.return_attribute11
10493     ,       p_line_rec.return_attribute12
10494     ,       p_line_rec.return_attribute13
10495     ,       p_line_rec.return_attribute14
10496     ,       p_line_rec.return_attribute15
10497     ,       p_line_rec.return_attribute2
10498     ,       p_line_rec.return_attribute3
10499     ,       p_line_rec.return_attribute4
10500     ,       p_line_rec.return_attribute5
10501     ,       p_line_rec.return_attribute6
10502     ,       p_line_rec.return_attribute7
10503     ,       p_line_rec.return_attribute8
10504     ,       p_line_rec.return_attribute9
10505     ,       p_line_rec.return_context
10506     ,       p_line_rec.return_reason_code
10507     ,       p_line_rec.rla_schedule_type_code
10508     ,       p_line_rec.salesrep_id
10509     ,       p_line_rec.schedule_arrival_date
10510     ,       p_line_rec.schedule_ship_date
10511     ,       p_line_rec.schedule_status_code
10512     ,       p_line_rec.shipment_number
10513     ,       p_line_rec.shipment_priority_code
10514     ,       p_line_rec.shipped_quantity
10515     ,       p_line_rec.shipped_quantity2 -- OPM B1661023 04/02/01
10516     ,       p_line_rec.shipping_method_code
10517     ,       p_line_rec.shipping_quantity
10518     ,       p_line_rec.shipping_quantity2    -- OPM B1661023 04/02/01
10519     ,       p_line_rec.shipping_quantity_uom
10520     ,       p_line_rec.ship_from_org_id
10521     ,       p_line_Rec.subinventory
10522     ,       p_line_rec.ship_set_id
10523     ,       p_line_rec.ship_tolerance_above
10524     ,       p_line_rec.ship_tolerance_below
10525     ,       p_line_rec.shippable_flag
10526     ,       p_line_rec.shipping_interfaced_flag
10527     ,       p_line_rec.ship_to_contact_id
10528     ,       p_line_rec.ship_to_org_id
10529     ,       p_line_rec.ship_model_complete_flag
10530 
10531     ,       p_line_rec.sold_to_org_id
10532     ,       l_sold_from_org
10533     ,       p_line_rec.sort_order
10534     ,       p_line_rec.source_document_id
10535     ,       p_line_rec.source_document_line_id
10536     ,       p_line_rec.source_document_type_id
10537     ,       p_line_rec.source_type_code
10538     ,       p_line_rec.split_from_line_id
10539     ,       p_line_rec.line_set_id
10540     ,       p_line_rec.split_by
10541     ,       p_line_rec.model_remnant_flag
10542     ,       p_line_rec.task_id
10543     ,       p_line_rec.tax_code
10544     ,       p_line_rec.tax_date
10545     ,       p_line_rec.tax_exempt_flag
10546     ,       p_line_rec.tax_exempt_number
10547     ,       p_line_rec.tax_exempt_reason_code
10548     ,       p_line_rec.tax_point_code
10549     ,       p_line_rec.tax_rate
10550     ,       p_line_rec.tax_value
10551     ,       p_line_rec.top_model_line_id
10552     ,       p_line_rec.unit_list_price
10553     ,       p_line_rec.unit_list_price_per_pqty
10554     ,       p_line_rec.unit_selling_price
10555     ,       p_line_rec.unit_selling_price_per_pqty
10556     ,       p_line_rec.visible_demand_flag
10557     ,       p_line_rec.veh_cus_item_cum_key_id
10558     ,       p_line_rec.shipping_instructions
10559     ,       p_line_rec.packing_instructions
10560     ,       p_line_rec.service_txn_reason_code
10561     ,       p_line_rec.service_txn_comments
10562     ,       p_line_rec.service_duration
10563     ,       p_line_rec.service_period
10564     ,       p_line_rec.service_start_date
10565     ,       p_line_rec.service_end_date
10566     ,       p_line_rec.service_coterminate_flag
10567     ,       p_line_rec.unit_list_percent
10568     ,       p_line_rec.unit_selling_percent
10569     ,       p_line_rec.unit_percent_base_price
10570     ,       p_line_rec.service_number
10571     ,       p_line_rec.service_reference_type_code
10572     ,       p_line_rec.service_reference_line_id
10573     ,       p_line_rec.service_reference_system_id
10574     ,       p_line_rec.tp_context
10575     ,       p_line_rec.tp_attribute1
10576     ,       p_line_rec.tp_attribute2
10577     ,       p_line_rec.tp_attribute3
10578     ,       p_line_rec.tp_attribute4
10579     ,       p_line_rec.tp_attribute5
10580     ,       p_line_rec.tp_attribute6
10581     ,       p_line_rec.tp_attribute7
10582     ,       p_line_rec.tp_attribute8
10583     ,       p_line_rec.tp_attribute9
10584     ,       p_line_rec.tp_attribute10
10585     ,       p_line_rec.tp_attribute11
10586     ,       p_line_rec.tp_attribute12
10587     ,       p_line_rec.tp_attribute13
10588     ,       p_line_rec.tp_attribute14
10589     ,       p_line_rec.tp_attribute15
10590     ,       p_line_rec.flow_status_code
10591     ,       p_line_rec.marketing_source_code_id
10592     ,       p_line_rec.calculate_price_flag
10593     ,       p_line_rec.commitment_id
10594     ,       l_upgraded_flag
10595     ,       p_line_rec.original_inventory_item_id
10596     ,       p_line_rec.original_item_identifier_Type
10597     ,       p_line_rec.original_ordered_item_id
10598     ,       p_line_rec.original_ordered_item
10599     ,       p_line_rec.item_relationship_type
10600     ,       p_line_rec.item_substitution_type_code
10601     ,       p_line_rec.late_demand_penalty_factor
10602     ,       p_line_rec.Override_atp_date_code
10603     ,       p_line_rec.Firm_demand_flag
10604     ,       p_line_rec.Earliest_ship_date
10605     ,       p_line_rec.user_item_description
10606     ,       p_line_rec.Blanket_Number
10607     ,       p_line_rec.Blanket_Line_Number
10608     ,       p_line_rec.Blanket_Version_Number
10609 --MRG B
10610     ,       p_line_rec.unit_cost
10611 --MRG E
10612     ,       l_lock_control
10613 -- Changes for quoting
10614     ,	    p_line_rec.transaction_phase_code
10615     ,       p_line_rec.source_document_version_number
10616 -- end changes for quoting
10617    ,        p_line_rec.Minisite_Id
10618    ,        p_line_rec.Ib_owner
10619    ,        p_line_rec.Ib_installed_at_location
10620    ,        p_line_rec.Ib_current_location
10621    ,        p_line_rec.End_customer_Id
10622    ,        p_line_rec.End_customer_contact_Id
10623    ,        p_line_rec.End_customer_site_use_Id
10624  /*  ,        p_line_rec.Supplier_signature
10625    ,        p_line_rec.Supplier_signature_date
10626    ,        p_line_rec.customer_signature
10627    ,        p_line_rec.customer_signature_date */
10628 --retro{
10629    ,        p_line_rec.retrobill_request_id
10630 --retro}
10631    ,        p_line_rec.original_list_price -- Override List Price
10632 -- key Transaction Dates
10633    ,        p_line_rec.order_firmed_date
10634    ,        p_line_rec.actual_fulfillment_date
10635    --recurring charges
10636    ,        p_line_rec.charge_periodicity_code
10637 -- INVCONV
10638     ,       p_line_rec.cancelled_quantity2
10639     ,       p_line_rec.shipping_quantity_uom2
10640     ,       p_line_rec.fulfilled_quantity2
10641     ,       p_line_rec.CONTINGENCY_ID
10642     ,       p_line_rec.REVREC_EVENT_CODE
10643     ,       p_line_rec.REVREC_EXPIRATION_DAYS
10644     ,       p_line_rec.ACCEPTED_QUANTITY
10645     ,       p_line_rec.REVREC_COMMENTS
10646     ,       p_line_rec.REVREC_SIGNATURE
10647     ,       p_line_rec.REVREC_SIGNATURE_DATE
10648     ,       p_line_rec.ACCEPTED_BY
10649     ,       p_line_rec.REVREC_REFERENCE_DOCUMENT
10650     ,       p_line_rec.REVREC_IMPLICIT_FLAG
10651 
10652 -- { O2C/DOO Integration
10653     ,      p_line_rec.BYPASS_SCH_FLAG
10654     ,      p_line_rec.PRE_EXPLODED_FLAG
10655 --  O2C/DOO Integration }
10656 	-- sol_ord_er #16014165
10657 	, 	   p_line_rec.service_bill_profile_id
10658 	, 	   p_line_rec.service_cov_template_id
10659 	, 	   p_line_rec.service_subs_template_id
10660 	, 	   p_line_rec.service_bill_option_code
10661 	, 	   p_line_rec.subscription_enable_flag
10662 	, 	   p_line_rec.SERVICE_FIRST_PERIOD_AMOUNT
10663 	, 	   p_line_rec.SERVICE_FIRST_PERIOD_ENDDATE
10664 	-- sol_ord_er #16014165 end
10665     ,      p_line_rec.FULFILLMENT_BASE--ER#14763609
10666   );
10667 
10668     p_line_rec.lock_control := l_lock_control;
10669     p_line_rec.sold_from_org_id := l_sold_from_org;   /*Added for bug#12956482*/
10670     -- calling notification framework to update global picture
10671  -- check code release level first. Notification framework is at Pack H level
10672   IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508' THEN
10673       OE_ORDER_UTIL.Update_Global_Picture(p_Upd_New_Rec_If_Exists => True,
10674                     p_Line_rec =>p_line_rec,
10675                     p_old_line_rec => NULL,
10676                     p_line_id => p_line_rec.line_id,
10677                     x_index => l_index,
10678                     x_return_status => l_return_status);
10679       if l_debug_level > 0 then
10680        OE_DEBUG_PUB.ADD('Update_Global Return Status from OE_LINE_UTIL.inset_row is: ' || l_return_status);
10681        OE_DEBUG_PUB.ADD('returned index is: ' || l_index ,1);
10682       end if;
10683        IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10684          if l_debug_level > 0 then
10685           OE_DEBUG_PUB.ADD('EVENT NOTIFY - Unexpected Error');
10686           OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.insert_ROW', 1);
10687          end if;
10688 	  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10689         ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10690           if l_debug_level > 0 then
10691            OE_DEBUG_PUB.ADD('Update_Global_Picture Error in OE_LINE_UTIL.insert_row');
10692            OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.insert_ROW', 1);
10693           end if;
10694 	  RAISE FND_API.G_EXC_ERROR;
10695         END IF;
10696     END IF; /*code_release_code*/
10697  -- notification framework end
10698 
10699   if l_debug_level > 0 then
10700     oe_debug_pub.add('Exiting OE_LINE_UTIL.INSERT_ROW', 1);
10701   end if;
10702 
10703 EXCEPTION
10704 
10705     WHEN OTHERS THEN
10706 
10707         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
10708         THEN
10709             OE_MSG_PUB.Add_Exc_Msg
10710             (   G_PKG_NAME
10711             ,   'Insert_Row'
10712             );
10713         END IF;
10714         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10715 
10716 END Insert_Row;
10717 
10718 
10719 /*-----------------------------------------------------------
10720 Procedure Delete_Row
10721 -----------------------------------------------------------*/
10722 
10723 PROCEDURE Delete_Row
10724 ( p_line_id       IN  NUMBER := FND_API.G_MISS_NUM
10725  ,p_header_id     IN  NUMBER := FND_API.G_MISS_NUM)
10726 IS
10727   l_return_status            VARCHAR2(30);
10728   l_org_id                   NUMBER;
10729   l_line_rec                 oe_order_pub.line_rec_type;
10730   lsqlstmt                   varchar2(4000) ;
10731   lvariable1                 varchar2(80);
10732   lvariable2                 number;
10733   TYPE llinecur IS REF       CURSOR;
10734   llinetbl                   llinecur;
10735   llinetbl_svc               llinecur; -- for bug 2408321
10736   l_tmp_line_id              NUMBER;   -- for bug 2408321
10737   l_line_id                  number;
10738   l_item_type_code           varchar2(30);
10739   l_line_category_code       varchar2(30);
10740   l_config_header_id         number;
10741   l_config_rev_nbr           number;
10742   l_in_line_id               number := p_line_id;
10743   l_column                   varchar2(30);
10744   l_line_tbl                 OE_Order_PUB.Line_Tbl_Type;
10745   l_schedule_status_code     VARCHAR2(30);
10746   l_shipping_interfaced_flag VARCHAR2(1);
10747   l_ordered_quantity         NUMBER;           -- BUG 2670775 Reverse Limits
10748   l_price_request_code       varchar2(240);    -- BUG 2670775 Reverse Limits
10749   l_transaction_phase_code   varchar2(30);
10750   l_header_id                NUMBER;
10751   l_data                     VARCHAR2(1);
10752   l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
10753 
10754   -- BUG 2670775 - Add ordered_quantity,price_request_code to select list
10755   CURSOR order_line IS
10756   SELECT line_id, item_type_code,
10757          config_header_id, config_rev_nbr,
10758          line_category_code, schedule_status_code,
10759          shipping_interfaced_flag,
10760          ordered_quantity, price_request_code
10761          ,transaction_phase_code
10762   FROM   OE_ORDER_LINES
10763   WHERE  HEADER_ID = p_header_id;
10764   /*AND  NVL(ORG_ID,NVL(l_org_id,0))= NVL(l_org_id,0);*/
10765 
10766 -- added for notification framework
10767   l_new_line_rec     OE_Order_PUB.Line_Rec_Type;
10768   l_index    NUMBER;
10769 CURSOR svc_line IS
10770 	SELECT line_id, item_type_code
10771      	FROM OE_ORDER_LINES
10772 	  WHERE   service_reference_line_id  = p_line_id
10773 	  AND     service_reference_type_code = 'ORDER';   --bug 3056313
10774 
10775 BEGIN
10776 
10777   oe_debug_pub.add('Entering OE_LINE_UTIL.DELETE_ROW', 1);
10778   --Commented for MOAC start
10779   /*l_org_id := OE_GLOBALS.G_ORG_ID;
10780 
10781   IF l_org_id IS NULL THEN
10782     OE_GLOBALS.Set_Context;
10783     l_org_id := OE_GLOBALS.G_ORG_ID;
10784   END IF;
10785 
10786   oe_debug_pub.add('Entering delete '||to_char(l_org_id), 1); */
10787   --Commented for MOAC end
10788   IF p_header_id <> FND_API.G_MISS_NUM THEN
10789     FOR l_line IN order_line
10790     LOOP
10791 
10792        --added for notification framework
10793    --check code release level first. Notification framework is at Pack H level
10794     IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508' THEN
10795        oe_debug_pub.add('JFC: in delete row, l_line_id'|| l_line.line_id , 1);
10796       /* Set the operation on the record so that globals are updated as well */
10797       l_new_line_rec.operation := OE_GLOBALS.G_OPR_DELETE;
10798       l_new_line_rec.line_id :=l_line.line_id;
10799       OE_ORDER_UTIL.Update_Global_Picture(p_Upd_New_Rec_If_Exists => True,
10800                     p_line_rec =>l_new_line_rec,
10801                     p_line_id =>l_line.line_id,
10802                     x_index => l_index,
10803                     x_return_status => l_return_status);
10804         OE_DEBUG_PUB.ADD('Update_Global Return Status from OE_LINE_UTIL.delete_row  is: ' || l_return_status);
10805        IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10806           OE_DEBUG_PUB.ADD('EVENT NOTIFY - Unexpected Error');
10807           OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.DELETE_ROW', 1);
10808 	  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10809        ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10810           OE_DEBUG_PUB.ADD('Update_Global_Picture Error in OE_LINE_UTIL.Delete_row');
10811           OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.DELETE_ROW', 1);
10812 	  RAISE FND_API.G_EXC_ERROR;
10813        END IF;
10814     END IF; /*code_release_level*/
10815     -- notification framework end
10816 
10817       -- Keep all your dependencies in Delete Dependents Procedure
10818       -- If model is deleted, delete from SPC tables
10819       IF l_line.item_type_code = OE_GLOBALS.G_ITEM_MODEL THEN
10820         OE_Config_Pvt.Delete_Config
10821         ( p_config_hdr_id     => l_line.config_header_id,
10822           p_config_rev_nbr    => l_line.config_rev_nbr,
10823           x_return_status     => l_return_status );
10824       END IF;
10825 
10826       l_line_id                  := l_line.line_id;
10827       l_item_type_code           := l_line.item_type_code;
10828       l_line_category_code       := l_line.line_category_code;
10829       l_config_header_id         := l_line.config_header_id;
10830       l_config_rev_nbr           := l_line.config_rev_nbr;
10831       l_schedule_status_code     := l_line.schedule_status_code;
10832       l_shipping_interfaced_flag := l_line.shipping_interfaced_flag;
10833       l_ordered_quantity         := l_line.ordered_quantity;   -- BUG 2670775 Reverse Limits
10834       l_price_request_code       := l_line.price_request_code; -- BUG 2670775 Reverse Limits
10835       l_transaction_phase_code   := l_line.transaction_phase_code;
10836 
10837       oe_debug_pub.add(' Header - Before delete dependent');
10838 
10839       Delete_Dependents
10840       ( p_line_id                  => l_line_id
10841        ,p_item_type_code           => l_item_type_code
10842        ,p_line_category_code       => l_line_category_code
10843        ,p_config_header_id         => l_config_header_id
10844        ,p_config_rev_nbr           => l_config_rev_nbr
10845        ,p_schedule_status_code     => l_schedule_status_code
10846        ,p_shipping_interfaced_flag => l_shipping_interfaced_flag
10847        ,p_ordered_quantity         => l_ordered_quantity          -- BUG 2670775 Reverse Limits
10848        ,p_price_request_code       => l_price_request_code      -- BUG 2670775 Reverse Limits
10849        ,p_transaction_phase_code   => l_transaction_phase_code -- Bug 3315331
10850        );
10851 
10852     END LOOP; -- all the lines in a header.
10853 
10854     /* Start Audit Trail */
10855     DELETE  FROM OE_ORDER_LINES_HISTORY
10856     WHERE   HEADER_ID = p_header_id;
10857     /* End Audit Trail */
10858 
10859     DELETE  FROM OE_ORDER_LINES
10860     WHERE   HEADER_ID = p_header_id;
10861    /* AND NVL(ORG_ID,NVL(l_org_id,0))= NVL(l_org_id,0);*/
10862 
10863   ELSE -- header_id is missing.
10864     oe_debug_pub.add('hdr missing delete_row,line_id: '||p_line_id, 1);
10865 
10866     oe_line_util.query_row
10867     (p_line_id   => p_line_id
10868     ,x_line_rec  => l_line_rec );
10869 
10870     lvariable2 := p_line_id;
10871 
10872     IF l_line_rec.ITEM_TYPE_CODE = 'MODEL' OR
10873        (l_line_rec.ITEM_TYPE_CODE = 'KIT' AND
10874         l_line_rec.top_model_line_id = l_line_rec.line_id) THEN
10875       oe_debug_pub.add('Entering - MODEL', 1);
10876 
10877       -- BUG 2670775 Reverse Limits - add ordered_quantity,price_request_code to select
10878       lsqlstmt := 'Select line_id, item_type_code, line_category_code,
10879                    config_header_id, config_rev_nbr,
10880                    schedule_status_code, shipping_interfaced_flag,
10881                    ordered_quantity, price_request_code
10882                    from oe_order_lines
10883                    where top_model_line_id = :x and
10884                          line_id <> :y';
10885 
10886 
10887       OPEN llinetbl
10888       FOR lsqlstmt
10889       USING
10890       p_line_id,
10891       l_in_line_id;
10892 
10893       lvariable1 := 'TOP_MODEL';
10894       oe_debug_pub.add('end of loop for OPEN MODEL', 1);
10895 
10896     END IF; -- if top level model.
10897 
10898 
10899     IF llinetbl%ISOPEN THEN
10900       LOOP
10901         oe_debug_pub.add('Entering model LOOP', 1);
10902 
10903         FETCH llinetbl INTO l_line_id,l_item_type_code,
10904             l_line_category_code,l_config_header_id,
10905             l_config_rev_nbr,l_schedule_status_code,
10906             l_shipping_interfaced_flag,
10907             l_ordered_quantity, l_price_request_code;  -- BUG 2670775 Reverse Limits
10908 
10909         EXIT WHEN llinetbl%NOTFOUND;
10910 
10911         oe_debug_pub.add('After Fetch -IN  LOOP', 1);
10912         -- Keep all your dependencies in Delete Dependents Procedure
10913 
10914         oe_debug_pub.add(' model - Before delete dependent' || l_line_id);
10915 
10916         Delete_Dependents
10917         ( p_line_id                  => l_line_id
10918          ,p_item_type_code           => l_item_type_code
10919          ,p_line_category_code       => l_line_category_code
10920          ,p_config_header_id         => l_config_header_id
10921          ,p_config_rev_nbr           => l_config_rev_nbr
10922          ,p_schedule_status_code     => l_schedule_status_code
10923          ,p_shipping_interfaced_flag => l_shipping_interfaced_flag
10924          ,p_ordered_quantity         => l_ordered_quantity     -- BUG 2670775 Reverse Limits
10925          ,p_price_request_code       => l_price_request_code); -- BUG 2670775 Reverse Limits
10926 
10927 	-- start bug  2408321
10928 	l_tmp_line_id := l_line_id;
10929 
10930         -- BUG 2670775 Reverse Limits - add ordered_quantity,price_request_code to select
10931 	lsqlstmt := 'Select line_id, item_type_code, line_category_code,
10932 	  config_header_id, config_rev_nbr,
10933 	  schedule_status_code, shipping_interfaced_flag,
10934           ordered_quantity, price_request_code
10935 	  from oe_order_lines
10936 	  where service_reference_type_code = ' || '''' || 'ORDER' || ''' ' ||
10937 	  'AND service_reference_line_id = :x';  --bug 3056313
10938 
10939 	  OPEN llinetbl_svc
10940 	  FOR lsqlstmt
10941 	  using l_line_id;
10942 
10943 	IF llinetbl_svc%ISOPEN THEN
10944 	   LOOP
10945 	      FETCH llinetbl_svc
10946 		INTO l_line_id,l_item_type_code,l_line_category_code
10947 		,l_config_header_id,l_config_rev_nbr
10948 		,l_schedule_status_code,l_shipping_interfaced_flag
10949                 ,l_ordered_quantity, l_price_request_code;  -- BUG 2670775 Reverse Limits
10950 
10951 	      EXIT WHEN llinetbl_svc%NOTFOUND;
10952 
10953 	      oe_debug_pub.add('Service - Before delete dependent' || l_line_id);
10954 
10955 	      Delete_Dependents
10956 		( p_line_id                  => l_line_id
10957 		  ,p_item_type_code           => l_item_type_code
10958 		  ,p_line_category_code       => l_line_category_code
10959 		  ,p_config_header_id         => l_config_header_id
10960 		  ,p_config_rev_nbr           => l_config_rev_nbr
10961 		  ,p_schedule_status_code     => l_schedule_status_code
10962 		  ,p_shipping_interfaced_flag => l_shipping_interfaced_flag
10963                   ,p_ordered_quantity         => l_ordered_quantity      -- BUG 2670775 Reverse Limits
10964                   ,p_price_request_code       => l_price_request_code ); -- BUG 2670775 Reverse Limits
10965 
10966 	   END LOOP; -- loop of the service lines.
10967 
10968 	   CLOSE llinetbl_svc;
10969 
10970 	   DELETE  FROM OE_ORDER_LINES
10971 	     WHERE   SERVICE_REFERENCE_LINE_ID = l_tmp_line_id
10972 	     AND   SERVICE_REFERENCE_TYPE_CODE = 'ORDER';  -- bug 3056313
10973 
10974 	END IF; -- if service lines exist, for bug 2408321
10975 
10976         OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
10977       END LOOP; -- loop for models
10978 
10979       CLOSE llinetbl;
10980 
10981       IF lvariable1 = 'TOP_MODEL' THEN
10982         EXECUTE IMMEDIATE
10983         'Delete oe_order_lines where top_model_line_id = :x
10984          and line_id <> :y'
10985          USING
10986          p_line_id,
10987          p_line_id;
10988       END IF;
10989 
10990     END IF; -- end if model
10991 
10992    /* Remove the Parent Line and sub entities Here */
10993    /* Keep all your dependencies in Delete Dependents Procedure */
10994 
10995     oe_debug_pub.add('calling delete dep for the line', 1);
10996     Delete_Dependents
10997     ( p_line_id                  => l_line_rec.line_id
10998      ,p_item_type_code           => l_line_rec.item_type_code
10999      ,p_line_category_code       => l_line_rec.line_category_code
11000      ,p_config_header_id         => l_line_rec.config_header_id
11001      ,p_config_rev_nbr           => l_line_rec.config_rev_nbr
11002      ,p_schedule_status_code     => l_line_rec.schedule_status_code
11003      ,p_shipping_interfaced_flag => l_line_rec.shipping_interfaced_flag
11004      ,p_ordered_quantity         => l_line_rec.ordered_quantity     -- BUG 2670775 Reverse Limits
11005      ,p_price_request_code       => l_line_rec.price_request_code); -- BUG 2670775 Reverse Limits
11006 
11007     -- if model, call spc's delete
11008     IF p_header_id = FND_API.G_MISS_NUM THEN
11009       -- we already have l_line_rec
11010 
11011       IF l_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL THEN
11012         OE_Config_Pvt.Delete_Config
11013         ( p_config_hdr_id     => l_line_rec.config_header_id,
11014           p_config_rev_nbr    => l_line_rec.config_rev_nbr,
11015           x_return_status     => l_return_status );
11016       END IF;
11017     END IF;
11018 
11019     /* Delete all the dependents for service line */
11020     oe_debug_pub.add('Item Type for delete: ' || l_line_rec.item_type_code);
11021 
11022     /* When a standard line is being deleted, check if it has any service */
11023     /* lines attached to it. If so, get the line_id of the service line and */
11024     /* use this to delete the dependents */
11025 
11026     -- 02/NOV Reverse Limits add ordered_quantity, price_request_code to select
11027     lsqlstmt := 'Select line_id, item_type_code, line_category_code,
11028                  config_header_id, config_rev_nbr,
11029                  schedule_status_code, shipping_interfaced_flag,
11030                  ordered_quantity,price_request_code
11031                  from oe_order_lines
11032                  where service_reference_type_code = ' || '''' || 'ORDER' || ''' ' ||
11033                 'and service_reference_line_id = :x';  -- bug 3056313
11034 
11035     OPEN llinetbl
11036     FOR lsqlstmt
11037     using p_line_id;
11038 
11039     IF llinetbl%ISOPEN THEN
11040       LOOP
11041         FETCH llinetbl
11042         INTO l_line_id,l_item_type_code,l_line_category_code
11043             ,l_config_header_id,l_config_rev_nbr
11044             ,l_schedule_status_code,l_shipping_interfaced_flag
11045             ,l_ordered_quantity    ,l_price_request_code      ; -- BUG 2670775 Reverse Limits
11046 
11047         EXIT WHEN llinetbl%NOTFOUND;
11048 
11049         oe_debug_pub.add('Service - Before delete dependent' || l_line_id);
11050 
11051         Delete_Dependents
11052         ( p_line_id                  => l_line_id
11053          ,p_item_type_code           => l_item_type_code
11054          ,p_line_category_code       => l_line_category_code
11055          ,p_config_header_id         => l_config_header_id
11056          ,p_config_rev_nbr           => l_config_rev_nbr
11057          ,p_schedule_status_code     => l_schedule_status_code
11058          ,p_shipping_interfaced_flag => l_shipping_interfaced_flag
11059          ,p_ordered_quantity         => l_ordered_quantity     -- BUG 2670775 Reverse Limits
11060          ,p_price_request_code       => l_price_request_code); -- BUG 2670775 Reverse Limits
11061 
11062         OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
11063       END LOOP; -- loop of the service lines.
11064 
11065       CLOSE llinetbl;
11066 
11067     END IF; -- if service lines exist
11068 
11069     /* Start Audit Trail (modified for 11.5.10) */
11070     DELETE  FROM OE_ORDER_LINES_HISTORY
11071     WHERE   LINE_ID = p_line_id
11072     AND     NVL(AUDIT_FLAG, 'Y') = 'Y'
11073     AND     NVL(VERSION_FLAG, 'N') = 'N'
11074     AND     NVL(PHASE_CHANGE_FLAG, 'N') = 'N';
11075 
11076     UPDATE OE_ORDER_LINES_HISTORY
11077     SET    AUDIT_FLAG = 'N'
11078     WHERE  LINE_ID = p_line_id
11079     AND    NVL(AUDIT_FLAG, 'Y') = 'Y'
11080     AND   (NVL(VERSION_FLAG, 'N') = 'Y'
11081     OR     NVL(PHASE_CHANGE_FLAG, 'N') = 'Y');
11082     /* End Audit Trail */
11083 
11084 
11085   --added for notification framework to update global picture for standard line
11086    --check code release level first. Notification framework is at Pack H level
11087       oe_debug_pub.add('JPN: Delete all lines now');
11088     IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508' THEN
11089       /* Set the operation on the record so that globals are updated as well */
11090      l_new_line_rec.operation := OE_GLOBALS.G_OPR_DELETE;
11091      l_new_line_rec.line_id :=l_line_rec.line_id;
11092      l_new_line_rec.last_update_date :=l_line_rec.last_update_date;
11093 
11094       OE_ORDER_UTIL.Update_Global_Picture(p_Upd_New_Rec_If_Exists => True,
11095                     p_line_rec =>l_new_line_rec,
11096                     p_line_id =>l_line_rec.line_id,
11097                     x_index => l_index,
11098                     x_return_status => l_return_status);
11099         OE_DEBUG_PUB.ADD('Update_Global Return Status from OE_LINE_UTIL.delete_row for deleting standard line is: ' || l_return_status);
11100         IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
11101           OE_DEBUG_PUB.ADD('EVENT NOTIFY - Unexpected Error');
11102           OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.DELETE_ROW', 1);
11103 	  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11104        ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
11105           OE_DEBUG_PUB.ADD('Update_Global_Picture Error in OE_LINE_UTIL.Delete_row');
11106           OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.DELETE_ROW', 1);
11107 	  RAISE FND_API.G_EXC_ERROR;
11108         END IF;
11109       END IF; /*code_release_level*/
11110     -- notification framework end
11111 
11112 
11113     DELETE  FROM OE_ORDER_LINES
11114     WHERE   LINE_ID = p_line_id;
11115     /* AND   NVL(ORG_ID,NVL(l_org_id,0))= NVL(l_org_id,0);*/
11116 
11117 
11118  --added for notification framework to update global picture for service line
11119   --check code release level first. Notification framework is at Pack H level
11120     IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508' THEN
11121       FOR l_svc IN svc_line
11122        LOOP
11123          oe_debug_pub.add('JFC: in delete row, service line_id= '|| l_svc.line_id , 1);
11124       /* Set the operation on the record so that globals are updated as well */
11125           l_new_line_rec.operation := OE_GLOBALS.G_OPR_DELETE;
11126           l_new_line_rec.line_id :=l_svc.line_id;
11127           OE_ORDER_UTIL.Update_Global_Picture(p_Upd_New_Rec_If_Exists => True,
11128                     p_line_rec =>l_new_line_rec,
11129                     p_line_id =>l_svc.line_id,
11130                     x_index => l_index,
11131                     x_return_status => l_return_status);
11132 
11133           OE_DEBUG_PUB.ADD('Update_Global Return Status from OE_LINE_UTIL.delete_row for deleting service line is: ' || l_return_status);
11134           IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
11135              OE_DEBUG_PUB.ADD('EVENT NOTIFY - Unexpected Error');
11136              OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.DELETE_ROW', 1);
11137 	     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11138          ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
11139              OE_DEBUG_PUB.ADD('Update_Global_Picture Error in OE_LINE_UTIL.Delete_row');
11140              OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.DELETE_ROW', 1);
11141 	     RAISE FND_API.G_EXC_ERROR;
11142          END IF;
11143        END LOOP;
11144      END IF; /*code_release_level*/
11145      -- notification framework end
11146 
11147     -- For the Multiple service for Standard Line
11148     DELETE  FROM OE_ORDER_LINES
11149       WHERE   SERVICE_REFERENCE_LINE_ID = p_line_id
11150       AND   SERVICE_REFERENCE_TYPE_CODE = 'ORDER';  -- bug 3056313
11151     /* AND NVL(ORG_ID,NVL(l_org_id,0))= NVL(l_org_id,0);*/
11152 
11153   END IF;
11154 
11155 
11156   IF (NVL(FND_PROFILE.VALUE('WSH_ENABLE_DCP'), -1)  = 1 OR
11157       NVL(FND_PROFILE.VALUE('WSH_ENABLE_DCP'), -1)  = 2) AND
11158       WSH_DCP_PVT.G_CALL_DCP_CHECK = 'Y' THEN
11159 
11160     WSH_DCP_PVT.G_INIT_MSG_COUNT := fnd_msg_pub.count_msg;
11161 
11162     BEGIN
11163       IF l_debug_level  > 0 THEN
11164         oe_debug_pub.add(p_header_id ||'-----' || l_line_rec.header_id, 1);
11165       END IF;
11166 
11167       WSH_DCP_PVT.g_dc_table.DELETE;
11168 
11169       IF p_header_id is NULL OR
11170          p_header_id = FND_API.G_MISS_NUM THEN
11171         l_header_id :=  l_line_rec.header_id;
11172       ELSE
11173         l_header_id :=  p_header_id;
11174       END IF;
11175 
11176       IF l_debug_level  > 0 THEN
11177         oe_debug_pub.add('CALLING WSH_DCP_PVT.Check_Scripts '
11178                          ||'from delete row-'|| l_header_id, 1);
11179       END IF;
11180 
11181       WSH_DCP_PVT.Check_Scripts
11182       ( p_source_header_id  => l_header_id
11183        ,x_data_inconsistent => l_data);
11184 
11185       IF l_debug_level  > 0 THEN
11186         oe_debug_pub.add
11187         ('CALLING WSH_DCP_PVT.Post_Process '|| l_data, 1);
11188        END IF;
11189 
11190       WSH_DCP_PVT.Post_Process
11191       ( p_action_code     => 'OM'
11192        ,p_raise_exception => 'Y');
11193 
11194     EXCEPTION
11195       WHEN WSH_DCP_PVT.dcp_caught THEN
11196         IF l_debug_level  > 0 THEN
11197           oe_debug_pub.add('OM call to WSH DCP Caught in delete', 1);
11198         END IF;
11199 
11200         WHEN others THEN
11201           IF l_debug_level  > 0 THEN
11202             oe_msg_pub.add_text
11203             ('Update_Shipping_From_OE, DCP post process'|| sqlerrm);
11204               oe_debug_pub.add('OM call to WSH DCP,others '|| sqlerrm, 1);
11205           END IF;
11206     END;
11207   END IF; -- profile is yes
11208 
11209   oe_debug_pub.add('Exiting OE_LINE_UTIL.DELETE_ROW', 1);
11210 
11211 EXCEPTION
11212   WHEN FND_API.G_EXC_ERROR THEN
11213     RAISE FND_API.G_EXC_ERROR ;
11214 
11215   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
11216     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11217 
11218   WHEN OTHERS THEN
11219     IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
11220     THEN
11221       OE_MSG_PUB.Add_Exc_Msg
11222       (   G_PKG_NAME
11223          ,'Delete_Row');
11224     END IF;
11225 
11226     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11227 END Delete_Row;
11228 
11229 
11230 /*----------------------------------------------------------
11231 -- FUNCTION Query_Row
11232 -- IMPORTANT: DO NOT CHANGE THE SPEC OF THIS FUNCTION
11233 -- IT IS PUBLIC AND BEING CALLED BY OTHER PRODUCTS
11234 -- Private OM callers should call the procedure query_row instead
11235 -- as it has the nocopy option which would improve the performance
11236 -----------------------------------------------------------*/
11237 
11238 FUNCTION Query_Row
11239 (   p_line_id                       IN  NUMBER
11240 ) RETURN OE_Order_PUB.Line_Rec_Type
11241 IS
11242 l_line_rec               OE_Order_PUB.Line_Rec_Type;
11243 BEGIN
11244 
11245     Query_Row
11246         (   p_line_id                     => p_line_id
11247 	    ,   x_line_rec                    => l_line_rec
11248         );
11249 
11250     RETURN l_line_rec;
11251 
11252 END Query_Row;
11253 
11254 
11255 /*----------------------------------------------------------
11256  Procedure Query_Row
11257 -----------------------------------------------------------*/
11258 
11259 PROCEDURE Query_Row
11260 (   p_line_id                       IN  NUMBER
11261 ,   x_line_rec                      IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type
11262 )
11263 IS
11264 
11265 CURSOR l_line_csr IS
11266     SELECT  ACCOUNTING_RULE_ID
11267   , ACCOUNTING_RULE_DURATION
11268   , ACTUAL_ARRIVAL_DATE
11269   , ACTUAL_SHIPMENT_DATE
11270   , AGREEMENT_ID
11271   , ARRIVAL_SET_ID
11272   , ATO_LINE_ID
11273   , ATTRIBUTE1
11274   , ATTRIBUTE10
11275   , ATTRIBUTE11
11276   , ATTRIBUTE12
11277   , ATTRIBUTE13
11278   , ATTRIBUTE14
11279   , ATTRIBUTE15
11280   , ATTRIBUTE16   --For bug 2184255
11281   , ATTRIBUTE17
11282   , ATTRIBUTE18
11283   , ATTRIBUTE19
11284   , ATTRIBUTE2
11285   , ATTRIBUTE20
11286   , ATTRIBUTE3
11287   , ATTRIBUTE4
11288   , ATTRIBUTE5
11289   , ATTRIBUTE6
11290   , ATTRIBUTE7
11291   , ATTRIBUTE8
11292   , ATTRIBUTE9
11293   , AUTO_SELECTED_QUANTITY
11294   , AUTHORIZED_TO_SHIP_FLAG
11295   , BOOKED_FLAG
11296   , CANCELLED_FLAG
11297   , CANCELLED_QUANTITY
11298   , COMPONENT_CODE
11299   , COMPONENT_NUMBER
11300   , COMPONENT_SEQUENCE_ID
11301   , CONFIG_HEADER_ID
11302   , CONFIG_REV_NBR
11303   , CONFIG_DISPLAY_SEQUENCE
11304   , CONFIGURATION_ID
11305   , CONTEXT
11306   , CREATED_BY
11307   , CREATION_DATE
11308   , CREDIT_INVOICE_LINE_ID
11309   , CUSTOMER_DOCK_CODE
11310   , CUSTOMER_JOB
11311   , CUSTOMER_PRODUCTION_LINE
11312   , CUST_PRODUCTION_SEQ_NUM
11313   , CUSTOMER_TRX_LINE_ID
11314   , CUST_MODEL_SERIAL_NUMBER
11315   , CUST_PO_NUMBER
11316   , CUSTOMER_LINE_NUMBER
11317   , CUSTOMER_SHIPMENT_NUMBER
11318   , CUSTOMER_ITEM_NET_PRICE
11319   , DELIVERY_LEAD_TIME
11320   , DELIVER_TO_CONTACT_ID
11321   , DELIVER_TO_ORG_ID
11322   , DEMAND_BUCKET_TYPE_CODE
11323   , DEMAND_CLASS_CODE
11324   , DEP_PLAN_REQUIRED_FLAG
11325   , EARLIEST_ACCEPTABLE_DATE
11326   , END_ITEM_UNIT_NUMBER
11327   , EXPLOSION_DATE
11328   , FIRST_ACK_CODE
11329   , FIRST_ACK_DATE
11330   , FOB_POINT_CODE
11331   , FREIGHT_CARRIER_CODE
11332   , FREIGHT_TERMS_CODE
11333   , FULFILLED_QUANTITY
11334   , FULFILLED_FLAG
11335   , FULFILLMENT_METHOD_CODE
11336   , FULFILLMENT_DATE
11337   , GLOBAL_ATTRIBUTE1
11338   , GLOBAL_ATTRIBUTE10
11339   , GLOBAL_ATTRIBUTE11
11340   , GLOBAL_ATTRIBUTE12
11341   , GLOBAL_ATTRIBUTE13
11342   , GLOBAL_ATTRIBUTE14
11343   , GLOBAL_ATTRIBUTE15
11344   , GLOBAL_ATTRIBUTE16
11345   , GLOBAL_ATTRIBUTE17
11346   , GLOBAL_ATTRIBUTE18
11347   , GLOBAL_ATTRIBUTE19
11348   , GLOBAL_ATTRIBUTE2
11349   , GLOBAL_ATTRIBUTE20
11350   , GLOBAL_ATTRIBUTE3
11351   , GLOBAL_ATTRIBUTE4
11352   , GLOBAL_ATTRIBUTE5
11353   , GLOBAL_ATTRIBUTE6
11354   , GLOBAL_ATTRIBUTE7
11355   , GLOBAL_ATTRIBUTE8
11356   , GLOBAL_ATTRIBUTE9
11357   , GLOBAL_ATTRIBUTE_CATEGORY
11358   , HEADER_ID
11359   , INDUSTRY_ATTRIBUTE1
11360   , INDUSTRY_ATTRIBUTE10
11361   , INDUSTRY_ATTRIBUTE11
11362   , INDUSTRY_ATTRIBUTE12
11363   , INDUSTRY_ATTRIBUTE13
11364   , INDUSTRY_ATTRIBUTE14
11365   , INDUSTRY_ATTRIBUTE15
11366   , INDUSTRY_ATTRIBUTE16
11367   , INDUSTRY_ATTRIBUTE17
11368   , INDUSTRY_ATTRIBUTE18
11369   , INDUSTRY_ATTRIBUTE19
11370   , INDUSTRY_ATTRIBUTE20
11371   , INDUSTRY_ATTRIBUTE21
11372   , INDUSTRY_ATTRIBUTE22
11373   , INDUSTRY_ATTRIBUTE23
11374   , INDUSTRY_ATTRIBUTE24
11375   , INDUSTRY_ATTRIBUTE25
11376   , INDUSTRY_ATTRIBUTE26
11377   , INDUSTRY_ATTRIBUTE27
11378   , INDUSTRY_ATTRIBUTE28
11379   , INDUSTRY_ATTRIBUTE29
11380   , INDUSTRY_ATTRIBUTE30
11381   , INDUSTRY_ATTRIBUTE2
11382   , INDUSTRY_ATTRIBUTE3
11383   , INDUSTRY_ATTRIBUTE4
11384   , INDUSTRY_ATTRIBUTE5
11385   , INDUSTRY_ATTRIBUTE6
11386   , INDUSTRY_ATTRIBUTE7
11387   , INDUSTRY_ATTRIBUTE8
11388   , INDUSTRY_ATTRIBUTE9
11389   , INDUSTRY_CONTEXT
11390   , INTMED_SHIP_TO_CONTACT_ID
11391   , INTMED_SHIP_TO_ORG_ID
11392   , INVENTORY_ITEM_ID
11393   , INVOICE_INTERFACE_STATUS_CODE
11394   , INVOICE_TO_CONTACT_ID
11395   , INVOICE_TO_ORG_ID
11396   , INVOICED_QUANTITY
11397   , INVOICING_RULE_ID
11398   , ORDERED_ITEM_ID
11399   , ITEM_IDENTIFIER_TYPE
11400   , ORDERED_ITEM
11401   , ITEM_REVISION
11402   , ITEM_TYPE_CODE
11403   , LAST_ACK_CODE
11404   , LAST_ACK_DATE
11405   , LAST_UPDATED_BY
11406   , LAST_UPDATE_DATE
11407   , LAST_UPDATE_LOGIN
11408   , LATEST_ACCEPTABLE_DATE
11409   , LINE_CATEGORY_CODE
11410   , LINE_ID
11411   , LINE_NUMBER
11412   , LINE_TYPE_ID
11413   , LINK_TO_LINE_ID
11414   , MODEL_GROUP_NUMBER
11415   --  , MFG_COMPONENT_SEQUENCE_ID
11416   , MFG_LEAD_TIME
11417   , OPEN_FLAG
11418   , OPTION_FLAG
11419   , OPTION_NUMBER
11420   , ORDERED_QUANTITY
11421   , ORDERED_QUANTITY2              --OPM 02/JUN/00
11422   , ORDER_QUANTITY_UOM
11423   , ORDERED_QUANTITY_UOM2          --OPM 02/JUN/00
11424   , ORG_ID
11425   , ORIG_SYS_DOCUMENT_REF
11426   , ORIG_SYS_LINE_REF
11427   , ORIG_SYS_SHIPMENT_REF
11428   , OVER_SHIP_REASON_CODE
11429   , OVER_SHIP_RESOLVED_FLAG
11430   , PAYMENT_TERM_ID
11431   , PLANNING_PRIORITY
11432   , PREFERRED_GRADE                --OPM 02/JUN/00
11433   , PRICE_LIST_ID
11434   , PRICE_REQUEST_CODE             --PROMOTIONS MAY/01
11435   , PRICING_ATTRIBUTE1
11436   , PRICING_ATTRIBUTE10
11437   , PRICING_ATTRIBUTE2
11438   , PRICING_ATTRIBUTE3
11439   , PRICING_ATTRIBUTE4
11440   , PRICING_ATTRIBUTE5
11441   , PRICING_ATTRIBUTE6
11442   , PRICING_ATTRIBUTE7
11443   , PRICING_ATTRIBUTE8
11444   , PRICING_ATTRIBUTE9
11445   , PRICING_CONTEXT
11446   , PRICING_DATE
11447   , PRICING_QUANTITY
11448   , PRICING_QUANTITY_UOM
11449   , PROGRAM_APPLICATION_ID
11450   , PROGRAM_ID
11451   , PROGRAM_UPDATE_DATE
11452   , PROJECT_ID
11453   , PROMISE_DATE
11454   , RE_SOURCE_FLAG
11455   , REFERENCE_CUSTOMER_TRX_LINE_ID
11456   , REFERENCE_HEADER_ID
11457   , REFERENCE_LINE_ID
11458   , REFERENCE_TYPE
11459   , REQUEST_DATE
11460   , REQUEST_ID
11461   , RETURN_ATTRIBUTE1
11462   , RETURN_ATTRIBUTE10
11463   , RETURN_ATTRIBUTE11
11464   , RETURN_ATTRIBUTE12
11465   , RETURN_ATTRIBUTE13
11466   , RETURN_ATTRIBUTE14
11467   , RETURN_ATTRIBUTE15
11468   , RETURN_ATTRIBUTE2
11469   , RETURN_ATTRIBUTE3
11470   , RETURN_ATTRIBUTE4
11471   , RETURN_ATTRIBUTE5
11472   , RETURN_ATTRIBUTE6
11473   , RETURN_ATTRIBUTE7
11474   , RETURN_ATTRIBUTE8
11475   , RETURN_ATTRIBUTE9
11476   , RETURN_CONTEXT
11477   , RETURN_REASON_CODE
11478   , RLA_SCHEDULE_TYPE_CODE
11479   , SALESREP_ID
11480   , SCHEDULE_ARRIVAL_DATE
11481   , SCHEDULE_SHIP_DATE
11482   , SCHEDULE_STATUS_CODE
11483   , SHIPMENT_NUMBER
11484   , SHIPMENT_PRIORITY_CODE
11485   , SHIPPED_QUANTITY
11486   , SHIPPED_QUANTITY2 -- OPM B1661023 04/02/01
11487   , SHIPPING_METHOD_CODE
11488   , SHIPPING_QUANTITY
11489   , SHIPPING_QUANTITY2 -- OPM B1661023 04/02/01
11490   , SHIPPING_QUANTITY_UOM
11491   , SHIPPING_QUANTITY_UOM2 -- INVCONV
11492   , SHIP_FROM_ORG_ID
11493   , SUBINVENTORY
11494   , SHIP_SET_ID
11495   , SHIP_TOLERANCE_ABOVE
11496   , SHIP_TOLERANCE_BELOW
11497   , SHIPPABLE_FLAG
11498   , SHIPPING_INTERFACED_FLAG
11499   , SHIP_TO_CONTACT_ID
11500   , SHIP_TO_ORG_ID
11501   , SHIP_MODEL_COMPLETE_FLAG
11502   , SOLD_TO_ORG_ID
11503   , SOLD_FROM_ORG_ID
11504   , SORT_ORDER
11505   , SOURCE_DOCUMENT_ID
11506   , SOURCE_DOCUMENT_LINE_ID
11507   , SOURCE_DOCUMENT_TYPE_ID
11508   , SOURCE_TYPE_CODE
11509   , SPLIT_FROM_LINE_ID
11510   , LINE_SET_ID
11511   , SPLIT_BY
11512   , MODEL_REMNANT_FLAG
11513   , TASK_ID
11514   , TAX_CODE
11515   , TAX_DATE
11516   , TAX_EXEMPT_FLAG
11517   , TAX_EXEMPT_NUMBER
11518   , TAX_EXEMPT_REASON_CODE
11519   , TAX_POINT_CODE
11520   , TAX_RATE
11521   , TAX_VALUE
11522   , TOP_MODEL_LINE_ID
11523   , UNIT_LIST_PRICE
11524   , UNIT_LIST_PRICE_PER_PQTY
11525   , UNIT_SELLING_PRICE
11526   , UNIT_SELLING_PRICE_PER_PQTY
11527   , VISIBLE_DEMAND_FLAG
11528   , VEH_CUS_ITEM_CUM_KEY_ID
11529   , SHIPPING_INSTRUCTIONS
11530   , PACKING_INSTRUCTIONS
11531   , SERVICE_TXN_REASON_CODE
11532   , SERVICE_TXN_COMMENTS
11533   , SERVICE_DURATION
11534   , SERVICE_PERIOD
11535   , SERVICE_START_DATE
11536   , SERVICE_END_DATE
11537   , SERVICE_COTERMINATE_FLAG
11538   , UNIT_LIST_PERCENT
11539   , UNIT_SELLING_PERCENT
11540   , UNIT_PERCENT_BASE_PRICE
11541   , SERVICE_NUMBER
11542   , SERVICE_REFERENCE_TYPE_CODE
11543   , SERVICE_REFERENCE_LINE_ID
11544   , SERVICE_REFERENCE_SYSTEM_ID
11545   , TP_CONTEXT
11546   , TP_ATTRIBUTE1
11547   , TP_ATTRIBUTE2
11548   , TP_ATTRIBUTE3
11549   , TP_ATTRIBUTE4
11550   , TP_ATTRIBUTE5
11551   , TP_ATTRIBUTE6
11552   , TP_ATTRIBUTE7
11553   , TP_ATTRIBUTE8
11554   , TP_ATTRIBUTE9
11555   , TP_ATTRIBUTE10
11556   , TP_ATTRIBUTE11
11557   , TP_ATTRIBUTE12
11558   , TP_ATTRIBUTE13
11559   , TP_ATTRIBUTE14
11560   , TP_ATTRIBUTE15
11561   , FLOW_STATUS_CODE
11562   , MARKETING_SOURCE_CODE_ID
11563   , CALCULATE_PRICE_FLAG
11564   , COMMITMENT_ID
11565   , ORDER_SOURCE_ID        -- aksingh
11566   , UPGRADED_FLAG
11567   , ORIGINAL_INVENTORY_ITEM_ID
11568   , ORIGINAL_ITEM_IDENTIFIER_TYPE
11569   , ORIGINAL_ORDERED_ITEM_ID
11570   , ORIGINAL_ORDERED_ITEM
11571   , ITEM_RELATIONSHIP_TYPE
11572   , ITEM_SUBSTITUTION_TYPE_CODE
11573   , LATE_DEMAND_PENALTY_FACTOR
11574   , OVERRIDE_ATP_DATE_CODE
11575   , FIRM_DEMAND_FLAG
11576   , EARLIEST_SHIP_DATE
11577   , USER_ITEM_DESCRIPTION
11578   , BLANKET_NUMBER
11579   , BLANKET_LINE_NUMBER
11580   , BLANKET_VERSION_NUMBER
11581   , UNIT_COST
11582   , LOCK_CONTROL
11583   , CHANGE_SEQUENCE
11584   , transaction_phase_code
11585   , source_document_version_number
11586   , MINISITE_ID
11587   , Ib_Owner
11588   , Ib_installed_at_location
11589   , Ib_current_location
11590   , End_customer_ID
11591   , End_customer_contact_ID
11592   , End_customer_site_use_ID
11593   , RETROBILL_REQUEST_ID
11594   , ORIGINAL_LIST_PRICE  -- Override List Price
11595   , order_firmed_date
11596   , actual_fulfillment_date
11597   , charge_periodicity_code
11598   , cancelled_quantity2
11599   , fulfilled_quantity2
11600   , CONTINGENCY_ID
11601   , REVREC_EVENT_CODE
11602   , REVREC_EXPIRATION_DAYS
11603   , ACCEPTED_QUANTITY
11604   , REVREC_COMMENTS
11605   , REVREC_SIGNATURE
11606   , REVREC_SIGNATURE_DATE
11607   , ACCEPTED_BY
11608   , REVREC_REFERENCE_DOCUMENT
11609   , REVREC_IMPLICIT_FLAG
11610   , BYPASS_SCH_FLAG
11611   , PRE_EXPLODED_FLAG
11612   -- sol_ord_er #16014165
11613   , SERVICE_BILL_PROFILE_ID
11614   , SERVICE_COV_TEMPLATE_ID
11615   , SERVICE_SUBS_TEMPLATE_ID
11616   , SERVICE_BILL_OPTION_CODE
11617   , SUBSCRIPTION_ENABLE_FLAG
11618   , SERVICE_FIRST_PERIOD_AMOUNT
11619   , SERVICE_FIRST_PERIOD_ENDDATE
11620 	-- sol_ord_er #16014165 end
11621    , FULFILLMENT_BASE--ER#14763609
11622   FROM    OE_ORDER_LINES_ALL  -- Fix for FP bug 3391622
11623     WHERE LINE_ID = p_line_id;
11624 
11625     l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
11626 
11627 BEGIN
11628 
11629     IF l_debug_level  > 0 THEN
11630       oe_debug_pub.add('Entering OE_LINE_UTIL.QUERY_ROW, line_id:'||p_line_id, 1);
11631     END IF;
11632 
11633 
11634     OPEN l_line_csr;
11635 
11636     --  Loop over fetched records
11637 
11638     FETCH l_line_csr INTO
11639     x_line_rec.ACCOUNTING_RULE_ID
11640   , x_line_rec.ACCOUNTING_RULE_DURATION
11641   , x_line_rec.ACTUAL_ARRIVAL_DATE
11642   , x_line_rec.ACTUAL_SHIPMENT_DATE
11643   , x_line_rec.AGREEMENT_ID
11644   , x_line_rec.ARRIVAL_SET_ID
11645   , x_line_rec.ATO_LINE_ID
11646   , x_line_rec.ATTRIBUTE1
11647   , x_line_rec.ATTRIBUTE10
11648   , x_line_rec.ATTRIBUTE11
11649   , x_line_rec.ATTRIBUTE12
11650   , x_line_rec.ATTRIBUTE13
11651   , x_line_rec.ATTRIBUTE14
11652   , x_line_rec.ATTRIBUTE15
11653   , x_line_rec.ATTRIBUTE16   --For bug 2184255
11654   , x_line_rec.ATTRIBUTE17
11655   , x_line_rec.ATTRIBUTE18
11656   , x_line_rec.ATTRIBUTE19
11657   , x_line_rec.ATTRIBUTE2
11658   , x_line_rec.ATTRIBUTE20
11659   , x_line_rec.ATTRIBUTE3
11660   , x_line_rec.ATTRIBUTE4
11661   , x_line_rec.ATTRIBUTE5
11662   , x_line_rec.ATTRIBUTE6
11663   , x_line_rec.ATTRIBUTE7
11664   , x_line_rec.ATTRIBUTE8
11665   , x_line_rec.ATTRIBUTE9
11666   , x_line_rec.AUTO_SELECTED_QUANTITY
11667   , x_line_rec.AUTHORIZED_TO_SHIP_FLAG
11668   , x_line_rec.BOOKED_FLAG
11669   , x_line_rec.CANCELLED_FLAG
11670   , x_line_rec.CANCELLED_QUANTITY
11671   , x_line_rec.COMPONENT_CODE
11672   , x_line_rec.COMPONENT_NUMBER
11673   , x_line_rec.COMPONENT_SEQUENCE_ID
11674   , x_line_rec.CONFIG_HEADER_ID
11675   , x_line_rec.CONFIG_REV_NBR
11676   , x_line_rec.CONFIG_DISPLAY_SEQUENCE
11677   , x_line_rec.CONFIGURATION_ID
11678   , x_line_rec.CONTEXT
11679   , x_line_rec.CREATED_BY
11680   , x_line_rec.CREATION_DATE
11681   , x_line_rec.CREDIT_INVOICE_LINE_ID
11682   , x_line_rec.CUSTOMER_DOCK_CODE
11683   , x_line_rec.CUSTOMER_JOB
11684   , x_line_rec.CUSTOMER_PRODUCTION_LINE
11685   , x_line_rec.CUST_PRODUCTION_SEQ_NUM
11686   , x_line_rec.CUSTOMER_TRX_LINE_ID
11687   , x_line_rec.CUST_MODEL_SERIAL_NUMBER
11688   , x_line_rec.CUST_PO_NUMBER
11689   , x_line_rec.CUSTOMER_LINE_NUMBER
11690   , x_line_rec.CUSTOMER_SHIPMENT_NUMBER
11691   , x_line_rec.CUSTOMER_ITEM_NET_PRICE
11692   , x_line_rec.DELIVERY_LEAD_TIME
11693   , x_line_rec.DELIVER_TO_CONTACT_ID
11694   , x_line_rec.DELIVER_TO_ORG_ID
11695   , x_line_rec.DEMAND_BUCKET_TYPE_CODE
11696   , x_line_rec.DEMAND_CLASS_CODE
11697   , x_line_rec.DEP_PLAN_REQUIRED_FLAG
11698   , x_line_rec.EARLIEST_ACCEPTABLE_DATE
11699   , x_line_rec.END_ITEM_UNIT_NUMBER
11700   , x_line_rec.EXPLOSION_DATE
11701   , x_line_rec.FIRST_ACK_CODE
11702   , x_line_rec.FIRST_ACK_DATE
11703   , x_line_rec.FOB_POINT_CODE
11704   , x_line_rec.FREIGHT_CARRIER_CODE
11705   , x_line_rec.FREIGHT_TERMS_CODE
11706   , x_line_rec.FULFILLED_QUANTITY
11707   , x_line_rec.FULFILLED_FLAG
11708   , x_line_rec.FULFILLMENT_METHOD_CODE
11709   , x_line_rec.FULFILLMENT_DATE
11710   , x_line_rec.GLOBAL_ATTRIBUTE1
11711   , x_line_rec.GLOBAL_ATTRIBUTE10
11712   , x_line_rec.GLOBAL_ATTRIBUTE11
11713   , x_line_rec.GLOBAL_ATTRIBUTE12
11714   , x_line_rec.GLOBAL_ATTRIBUTE13
11715   , x_line_rec.GLOBAL_ATTRIBUTE14
11716   , x_line_rec.GLOBAL_ATTRIBUTE15
11717   , x_line_rec.GLOBAL_ATTRIBUTE16
11718   , x_line_rec.GLOBAL_ATTRIBUTE17
11719   , x_line_rec.GLOBAL_ATTRIBUTE18
11720   , x_line_rec.GLOBAL_ATTRIBUTE19
11721   , x_line_rec.GLOBAL_ATTRIBUTE2
11722   , x_line_rec.GLOBAL_ATTRIBUTE20
11723   , x_line_rec.GLOBAL_ATTRIBUTE3
11724   , x_line_rec.GLOBAL_ATTRIBUTE4
11725   , x_line_rec.GLOBAL_ATTRIBUTE5
11726   , x_line_rec.GLOBAL_ATTRIBUTE6
11727   , x_line_rec.GLOBAL_ATTRIBUTE7
11728   , x_line_rec.GLOBAL_ATTRIBUTE8
11729   , x_line_rec.GLOBAL_ATTRIBUTE9
11730   , x_line_rec.GLOBAL_ATTRIBUTE_CATEGORY
11731   , x_line_rec.HEADER_ID
11732   , x_line_rec.INDUSTRY_ATTRIBUTE1
11733   , x_line_rec.INDUSTRY_ATTRIBUTE10
11734   , x_line_rec.INDUSTRY_ATTRIBUTE11
11735   , x_line_rec.INDUSTRY_ATTRIBUTE12
11736   , x_line_rec.INDUSTRY_ATTRIBUTE13
11737   , x_line_rec.INDUSTRY_ATTRIBUTE14
11738   , x_line_rec.INDUSTRY_ATTRIBUTE15
11739   , x_line_rec.INDUSTRY_ATTRIBUTE16
11740   , x_line_rec.INDUSTRY_ATTRIBUTE17
11741   , x_line_rec.INDUSTRY_ATTRIBUTE18
11742   , x_line_rec.INDUSTRY_ATTRIBUTE19
11743   , x_line_rec.INDUSTRY_ATTRIBUTE20
11744   , x_line_rec.INDUSTRY_ATTRIBUTE21
11745   , x_line_rec.INDUSTRY_ATTRIBUTE22
11746   , x_line_rec.INDUSTRY_ATTRIBUTE23
11747   , x_line_rec.INDUSTRY_ATTRIBUTE24
11748   , x_line_rec.INDUSTRY_ATTRIBUTE25
11749   , x_line_rec.INDUSTRY_ATTRIBUTE26
11750   , x_line_rec.INDUSTRY_ATTRIBUTE27
11751   , x_line_rec.INDUSTRY_ATTRIBUTE28
11752   , x_line_rec.INDUSTRY_ATTRIBUTE29
11753   , x_line_rec.INDUSTRY_ATTRIBUTE30
11754   , x_line_rec.INDUSTRY_ATTRIBUTE2
11755   , x_line_rec.INDUSTRY_ATTRIBUTE3
11756   , x_line_rec.INDUSTRY_ATTRIBUTE4
11757   , x_line_rec.INDUSTRY_ATTRIBUTE5
11758   , x_line_rec.INDUSTRY_ATTRIBUTE6
11759   , x_line_rec.INDUSTRY_ATTRIBUTE7
11760   , x_line_rec.INDUSTRY_ATTRIBUTE8
11761   , x_line_rec.INDUSTRY_ATTRIBUTE9
11762   , x_line_rec.INDUSTRY_CONTEXT
11763   , x_line_rec.INTERMED_SHIP_TO_CONTACT_ID
11764   , x_line_rec.INTERMED_SHIP_TO_ORG_ID
11765   , x_line_rec.INVENTORY_ITEM_ID
11766   , x_line_rec.INVOICE_INTERFACE_STATUS_CODE
11767   , x_line_rec.INVOICE_TO_CONTACT_ID
11768   , x_line_rec.INVOICE_TO_ORG_ID
11769   , x_line_rec.INVOICED_QUANTITY
11770   , x_line_rec.INVOICING_RULE_ID
11771   , x_line_rec.ORDERED_ITEM_ID
11772   , x_line_rec.ITEM_IDENTIFIER_TYPE
11773   , x_line_rec.ORDERED_ITEM
11774   , x_line_rec.ITEM_REVISION
11775   , x_line_rec.ITEM_TYPE_CODE
11776   , x_line_rec.LAST_ACK_CODE
11777   , x_line_rec.LAST_ACK_DATE
11778   , x_line_rec.LAST_UPDATED_BY
11779   , x_line_rec.LAST_UPDATE_DATE
11780   , x_line_rec.LAST_UPDATE_LOGIN
11781   , x_line_rec.LATEST_ACCEPTABLE_DATE
11782   , x_line_rec.LINE_CATEGORY_CODE
11783   , x_line_rec.LINE_ID
11784   , x_line_rec.LINE_NUMBER
11785   , x_line_rec.LINE_TYPE_ID
11786   , x_line_rec.LINK_TO_LINE_ID
11787   , x_line_rec.MODEL_GROUP_NUMBER
11788   --  , x_line_rec.MFG_COMPONENT_SEQUENCE_ID
11789   , x_line_rec.MFG_LEAD_TIME
11790   , x_line_rec.OPEN_FLAG
11791   , x_line_rec.OPTION_FLAG
11792   , x_line_rec.OPTION_NUMBER
11793   , x_line_rec.ORDERED_QUANTITY
11794   , x_line_rec.ORDERED_QUANTITY2              --OPM 02/JUN/00
11795   , x_line_rec.ORDER_QUANTITY_UOM
11796   , x_line_rec.ORDERED_QUANTITY_UOM2          --OPM 02/JUN/00
11797   , x_line_rec.ORG_ID
11798   , x_line_rec.ORIG_SYS_DOCUMENT_REF
11799   , x_line_rec.ORIG_SYS_LINE_REF
11800   , x_line_rec.ORIG_SYS_SHIPMENT_REF
11801   , x_line_rec.OVER_SHIP_REASON_CODE
11802   , x_line_rec.OVER_SHIP_RESOLVED_FLAG
11803   , x_line_rec.PAYMENT_TERM_ID
11804   , x_line_rec.PLANNING_PRIORITY
11805   , x_line_rec.PREFERRED_GRADE                --OPM 02/JUN/00
11806   , x_line_rec.PRICE_LIST_ID
11807   , x_line_rec.PRICE_REQUEST_CODE             --PROMOTIONS MAY/01
11808   , x_line_rec.PRICING_ATTRIBUTE1
11809   , x_line_rec.PRICING_ATTRIBUTE10
11810   , x_line_rec.PRICING_ATTRIBUTE2
11811   , x_line_rec.PRICING_ATTRIBUTE3
11812   , x_line_rec.PRICING_ATTRIBUTE4
11813   , x_line_rec.PRICING_ATTRIBUTE5
11814   , x_line_rec.PRICING_ATTRIBUTE6
11815   , x_line_rec.PRICING_ATTRIBUTE7
11816   , x_line_rec.PRICING_ATTRIBUTE8
11817   , x_line_rec.PRICING_ATTRIBUTE9
11818   , x_line_rec.PRICING_CONTEXT
11819   , x_line_rec.PRICING_DATE
11820   , x_line_rec.PRICING_QUANTITY
11821   , x_line_rec.PRICING_QUANTITY_UOM
11822   , x_line_rec.PROGRAM_APPLICATION_ID
11823   , x_line_rec.PROGRAM_ID
11824   , x_line_rec.PROGRAM_UPDATE_DATE
11825   , x_line_rec.PROJECT_ID
11826   , x_line_rec.PROMISE_DATE
11827   , x_line_rec.RE_SOURCE_FLAG
11828   , x_line_rec.REFERENCE_CUSTOMER_TRX_LINE_ID
11829   , x_line_rec.REFERENCE_HEADER_ID
11830   , x_line_rec.REFERENCE_LINE_ID
11831   , x_line_rec.REFERENCE_TYPE
11832   , x_line_rec.REQUEST_DATE
11833   , x_line_rec.REQUEST_ID
11834   , x_line_rec.RETURN_ATTRIBUTE1
11835   , x_line_rec.RETURN_ATTRIBUTE10
11836   , x_line_rec.RETURN_ATTRIBUTE11
11837   , x_line_rec.RETURN_ATTRIBUTE12
11838   , x_line_rec.RETURN_ATTRIBUTE13
11839   , x_line_rec.RETURN_ATTRIBUTE14
11840   , x_line_rec.RETURN_ATTRIBUTE15
11841   , x_line_rec.RETURN_ATTRIBUTE2
11842   , x_line_rec.RETURN_ATTRIBUTE3
11843   , x_line_rec.RETURN_ATTRIBUTE4
11844   , x_line_rec.RETURN_ATTRIBUTE5
11845   , x_line_rec.RETURN_ATTRIBUTE6
11846   , x_line_rec.RETURN_ATTRIBUTE7
11847   , x_line_rec.RETURN_ATTRIBUTE8
11848   , x_line_rec.RETURN_ATTRIBUTE9
11849   , x_line_rec.RETURN_CONTEXT
11850   , x_line_rec.RETURN_REASON_CODE
11851   , x_line_rec.RLA_SCHEDULE_TYPE_CODE
11852   , x_line_rec.SALESREP_ID
11853   , x_line_rec.SCHEDULE_ARRIVAL_DATE
11854   , x_line_rec.SCHEDULE_SHIP_DATE
11855   , x_line_rec.SCHEDULE_STATUS_CODE
11856   , x_line_rec.SHIPMENT_NUMBER
11857   , x_line_rec.SHIPMENT_PRIORITY_CODE
11858   , x_line_rec.SHIPPED_QUANTITY
11859   , x_line_rec.SHIPPED_QUANTITY2 -- OPM B1661023 04/02/01
11860   , x_line_rec.SHIPPING_METHOD_CODE
11861   , x_line_rec.SHIPPING_QUANTITY
11862   , x_line_rec.SHIPPING_QUANTITY2 -- OPM B1661023 04/02/01
11863   , x_line_rec.SHIPPING_QUANTITY_UOM
11864   , x_line_rec.SHIPPING_QUANTITY_UOM2
11865   , x_line_rec.SHIP_FROM_ORG_ID
11866   , x_line_rec.SUBINVENTORY
11867   , x_line_rec.SHIP_SET_ID
11868   , x_line_rec.SHIP_TOLERANCE_ABOVE
11869   , x_line_rec.SHIP_TOLERANCE_BELOW
11870   , x_line_rec.SHIPPABLE_FLAG
11871   , x_line_rec.SHIPPING_INTERFACED_FLAG
11872   , x_line_rec.SHIP_TO_CONTACT_ID
11873   , x_line_rec.SHIP_TO_ORG_ID
11874   , x_line_rec.SHIP_MODEL_COMPLETE_FLAG
11875   , x_line_rec.SOLD_TO_ORG_ID
11876   , x_line_rec.SOLD_FROM_ORG_ID
11877   , x_line_rec.SORT_ORDER
11878   , x_line_rec.SOURCE_DOCUMENT_ID
11879   , x_line_rec.SOURCE_DOCUMENT_LINE_ID
11880   , x_line_rec.SOURCE_DOCUMENT_TYPE_ID
11881   , x_line_rec.SOURCE_TYPE_CODE
11882   , x_line_rec.SPLIT_FROM_LINE_ID
11883   , x_line_rec.LINE_SET_ID
11884   , x_line_rec.SPLIT_BY
11885   , x_line_rec.MODEL_REMNANT_FLAG
11886   , x_line_rec.TASK_ID
11887   , x_line_rec.TAX_CODE
11888   , x_line_rec.TAX_DATE
11889   , x_line_rec.TAX_EXEMPT_FLAG
11890   , x_line_rec.TAX_EXEMPT_NUMBER
11891   , x_line_rec.TAX_EXEMPT_REASON_CODE
11892   , x_line_rec.TAX_POINT_CODE
11893   , x_line_rec.TAX_RATE
11894   , x_line_rec.TAX_VALUE
11895   , x_line_rec.TOP_MODEL_LINE_ID
11896   , x_line_rec.UNIT_LIST_PRICE
11897   , x_line_rec.UNIT_LIST_PRICE_PER_PQTY
11898   , x_line_rec.UNIT_SELLING_PRICE
11899   , x_line_rec.UNIT_SELLING_PRICE_PER_PQTY
11900   , x_line_rec.VISIBLE_DEMAND_FLAG
11901   , x_line_rec.VEH_CUS_ITEM_CUM_KEY_ID
11902   , x_line_rec.SHIPPING_INSTRUCTIONS
11903   , x_line_rec.PACKING_INSTRUCTIONS
11904   , x_line_rec.SERVICE_TXN_REASON_CODE
11905   , x_line_rec.SERVICE_TXN_COMMENTS
11906   , x_line_rec.SERVICE_DURATION
11907   , x_line_rec.SERVICE_PERIOD
11908   , x_line_rec.SERVICE_START_DATE
11909   , x_line_rec.SERVICE_END_DATE
11910   , x_line_rec.SERVICE_COTERMINATE_FLAG
11911   , x_line_rec.UNIT_LIST_PERCENT
11912   , x_line_rec.UNIT_SELLING_PERCENT
11913   , x_line_rec.UNIT_PERCENT_BASE_PRICE
11914   , x_line_rec.SERVICE_NUMBER
11915   , x_line_rec.SERVICE_REFERENCE_TYPE_CODE
11916   , x_line_rec.SERVICE_REFERENCE_LINE_ID
11917   , x_line_rec.SERVICE_REFERENCE_SYSTEM_ID
11918   , x_line_rec.TP_CONTEXT
11919   , x_line_rec.TP_ATTRIBUTE1
11920   , x_line_rec.TP_ATTRIBUTE2
11921   , x_line_rec.TP_ATTRIBUTE3
11922   , x_line_rec.TP_ATTRIBUTE4
11923   , x_line_rec.TP_ATTRIBUTE5
11924   , x_line_rec.TP_ATTRIBUTE6
11925   , x_line_rec.TP_ATTRIBUTE7
11926   , x_line_rec.TP_ATTRIBUTE8
11927   , x_line_rec.TP_ATTRIBUTE9
11928   , x_line_rec.TP_ATTRIBUTE10
11929   , x_line_rec.TP_ATTRIBUTE11
11930   , x_line_rec.TP_ATTRIBUTE12
11931   , x_line_rec.TP_ATTRIBUTE13
11932   , x_line_rec.TP_ATTRIBUTE14
11933   , x_line_rec.TP_ATTRIBUTE15
11934   , x_line_rec.FLOW_STATUS_CODE
11935   , x_line_rec.MARKETING_SOURCE_CODE_ID
11936   , x_line_rec.CALCULATE_PRICE_FLAG
11937   , x_line_rec.COMMITMENT_ID
11938   , x_line_rec.ORDER_SOURCE_ID        -- aksingh
11939   , x_line_rec.UPGRADED_FLAG
11940   , x_line_rec.ORIGINAL_INVENTORY_ITEM_ID
11941   , x_line_rec.ORIGINAL_ITEM_IDENTIFIER_TYPE
11942   , x_line_rec.ORIGINAL_ORDERED_ITEM_ID
11943   , x_line_rec.ORIGINAL_ORDERED_ITEM
11944   , x_line_rec.ITEM_RELATIONSHIP_TYPE
11945   , x_line_rec.ITEM_SUBSTITUTION_TYPE_CODE
11946   , x_line_rec.LATE_DEMAND_PENALTY_FACTOR
11947   , x_line_rec.OVERRIDE_ATP_DATE_CODE
11948   , x_line_rec.FIRM_DEMAND_FLAG
11949   , x_line_rec.EARLIEST_SHIP_DATE
11950   , x_line_rec.USER_ITEM_DESCRIPTION
11951   , x_line_rec.BLANKET_NUMBER
11952   , x_line_rec.BLANKET_LINE_NUMBER
11953   , x_line_rec.BLANKET_VERSION_NUMBER
11954   , x_line_rec.UNIT_COST
11955   , x_line_rec.LOCK_CONTROL
11956   , x_line_rec.CHANGE_SEQUENCE
11957   , x_line_rec.transaction_phase_code
11958   , x_line_rec.source_document_version_number
11959   , x_line_rec.MINISITE_ID
11960    , x_line_rec.Ib_Owner
11961    , x_line_rec.Ib_installed_at_location
11962    , x_line_rec.Ib_current_location
11963    , x_line_rec.End_customer_ID
11964    , x_line_rec.End_customer_contact_ID
11965    , x_line_rec.End_customer_site_use_ID
11966    , x_line_rec.RETROBILL_REQUEST_ID
11967    , x_line_rec.ORIGINAL_LIST_PRICE  -- Override List Price
11968    , x_line_rec.order_firmed_date
11969    , x_line_rec.actual_fulfillment_date
11970    , x_line_rec.charge_periodicity_code
11971    , x_line_rec.cancelled_quantity2
11972    , x_line_rec.fulfilled_quantity2
11973    , x_line_rec.CONTINGENCY_ID
11974    , x_line_rec.REVREC_EVENT_CODE
11975    , x_line_rec.REVREC_EXPIRATION_DAYS
11976    , x_line_rec.ACCEPTED_QUANTITY
11977    , x_line_rec.REVREC_COMMENTS
11978    , x_line_rec.REVREC_SIGNATURE
11979    , x_line_rec.REVREC_SIGNATURE_DATE
11980    , x_line_rec.ACCEPTED_BY
11981    , x_line_rec.REVREC_REFERENCE_DOCUMENT
11982    , x_line_rec.REVREC_IMPLICIT_FLAG
11983    -- Added for DOO/O2C Integration purpose.
11984    , x_line_rec.BYPASS_SCH_FLAG
11985    , x_line_rec.PRE_EXPLODED_FLAG
11986     -- sol_ord_er #16014165
11987    , x_line_rec.service_bill_profile_id
11988    , x_line_rec.service_cov_template_id
11989    , x_line_rec.service_subs_template_id
11990    , x_line_rec.service_bill_option_code
11991    , x_line_rec.subscription_enable_flag
11992    , x_line_rec.SERVICE_FIRST_PERIOD_AMOUNT
11993    , x_line_rec.SERVICE_FIRST_PERIOD_ENDDATE
11994    , x_line_rec.FULFILLMENT_BASE--ER#14763609
11995    ;
11996 
11997   --Added for bug5068941 start
11998   if l_line_csr%notfound then
11999      raise NO_DATA_FOUND;
12000   end if;
12001   --Added for bug5068941 end
12002 
12003 If NOT OE_FEATURES_PVT.Is_Margin_Avail Then
12004    IF l_debug_level  > 0 THEN
12005      oe_debug_pub.add('inside margin ',1);
12006    END IF;
12007    x_line_rec.unit_cost:= NULL;
12008 End If;
12009 
12010 	   -- set values for non-DB fields
12011 	x_line_rec.db_flag 		:= FND_API.G_TRUE;
12012 	x_line_rec.operation 		:= FND_API.G_MISS_CHAR;
12013 	x_line_rec.return_status 	:= FND_API.G_MISS_CHAR;
12014 
12015 	x_line_rec.schedule_action_code 	:= FND_API.G_MISS_CHAR;
12016 	x_line_rec.reserved_quantity 	:= FND_API.G_MISS_NUM;
12017 	x_line_rec.reserved_quantity2 	:= FND_API.G_MISS_NUM; -- INVCONV
12018 	x_line_rec.change_reason 		:= FND_API.G_MISS_CHAR;
12019 	x_line_rec.change_comments 		:= FND_API.G_MISS_CHAR;
12020 	x_line_rec.arrival_set      	:= FND_API.G_MISS_CHAR;
12021 	x_line_rec.ship_set 			:= FND_API.G_MISS_CHAR;
12022 	x_line_rec.fulfillment_set 		:= FND_API.G_MISS_CHAR;
12023 	x_line_rec.split_action_code 	:= FND_API.G_MISS_CHAR;
12024 
12025 
12026     CLOSE l_line_csr;
12027 
12028    IF l_debug_level  > 0 THEN
12029       oe_debug_pub.add('Exiting OE_LINE_UTIL.QUERY_ROW', 1);
12030     END IF;
12031 
12032 
12033 EXCEPTION
12034 
12035     WHEN NO_DATA_FOUND THEN
12036 
12037        RAISE NO_DATA_FOUND;
12038 
12039     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
12040 
12041         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
12042 
12043     WHEN OTHERS THEN
12044 
12045         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
12046         THEN
12047             OE_MSG_PUB.Add_Exc_Msg
12048             (   G_PKG_NAME
12049           ,   'Query_Row'
12050             );
12051         END IF;
12052 
12053         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
12054 
12055 END Query_Row;
12056 
12057 
12058 /*----------------------------------------------------------
12059  PROCEDURE Query_Rows
12060 
12061  When you add/delete columns to query_rows function,
12062  Please do the same changes in OE_Config_Util package body
12063  Query_Config function.
12064 -----------------------------------------------------------*/
12065 
12066 PROCEDURE Query_Rows
12067 (   p_line_id                       IN  NUMBER :=
12068                                         FND_API.G_MISS_NUM
12069 ,   p_header_id                     IN  NUMBER :=
12070                                         FND_API.G_MISS_NUM
12071 ,   p_line_set_id                   IN  NUMBER :=
12072                                         FND_API.G_MISS_NUM
12073 ,   x_line_tbl                      IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
12074  )
12075 IS
12076 l_org_id 		      	NUMBER;
12077 i				NUMBER;
12078 l_entity                        NUMBER;
12079 
12080 -- OPM 02/JUN/00 - Include process columns
12081 --                (ordered_quantity2,ordered_quantity_uom2,preferred_grade)
12082 -- =======================================================================
12083 
12084 -- Fix bug 2868226: The SQL has been modified to use 3 separate cursors,
12085 -- allowing for a simpler explain plan and significantly reduced shared
12086 -- memory usage.
12087 
12088 CURSOR l_line_csr_h IS
12089     SELECT  ACCOUNTING_RULE_ID
12090   , ACCOUNTING_RULE_DURATION
12091   , ACTUAL_ARRIVAL_DATE
12092   , ACTUAL_SHIPMENT_DATE
12093   , AGREEMENT_ID
12094   , ARRIVAL_SET_ID
12095   , ATO_LINE_ID
12096   , ATTRIBUTE1
12097   , ATTRIBUTE10
12098   , ATTRIBUTE11
12099   , ATTRIBUTE12
12100   , ATTRIBUTE13
12101   , ATTRIBUTE14
12102   , ATTRIBUTE15
12103   , ATTRIBUTE16   --For bug 2184255
12104   , ATTRIBUTE17
12105   , ATTRIBUTE18
12106   , ATTRIBUTE19
12107   , ATTRIBUTE2
12108   , ATTRIBUTE20
12109   , ATTRIBUTE3
12110   , ATTRIBUTE4
12111   , ATTRIBUTE5
12112   , ATTRIBUTE6
12113   , ATTRIBUTE7
12114   , ATTRIBUTE8
12115   , ATTRIBUTE9
12116   , AUTO_SELECTED_QUANTITY
12117   , AUTHORIZED_TO_SHIP_FLAG
12118   , BOOKED_FLAG
12119   , CANCELLED_FLAG
12120   , CANCELLED_QUANTITY
12121   , COMPONENT_CODE
12122   , COMPONENT_NUMBER
12123   , COMPONENT_SEQUENCE_ID
12124   , CONFIG_HEADER_ID
12125   , CONFIG_REV_NBR
12126   , CONFIG_DISPLAY_SEQUENCE
12127   , CONFIGURATION_ID
12128   , CONTEXT
12129 
12130   , CREATED_BY
12131   , CREATION_DATE
12132   , CREDIT_INVOICE_LINE_ID
12133   , CUSTOMER_DOCK_CODE
12134   , CUSTOMER_JOB
12135   , CUSTOMER_PRODUCTION_LINE
12136   , CUST_PRODUCTION_SEQ_NUM
12137   , CUSTOMER_TRX_LINE_ID
12138   , CUST_MODEL_SERIAL_NUMBER
12139   , CUST_PO_NUMBER
12140   , CUSTOMER_LINE_NUMBER
12141   , CUSTOMER_SHIPMENT_NUMBER
12142   , CUSTOMER_ITEM_NET_PRICE
12143   , DELIVERY_LEAD_TIME
12144   , DELIVER_TO_CONTACT_ID
12145   , DELIVER_TO_ORG_ID
12146   , DEMAND_BUCKET_TYPE_CODE
12147   , DEMAND_CLASS_CODE
12148   , DEP_PLAN_REQUIRED_FLAG
12149 
12150   , EARLIEST_ACCEPTABLE_DATE
12151   , END_ITEM_UNIT_NUMBER
12152   , EXPLOSION_DATE
12153   , FIRST_ACK_CODE
12154   , FIRST_ACK_DATE
12155   , FOB_POINT_CODE
12156   , FREIGHT_CARRIER_CODE
12157   , FREIGHT_TERMS_CODE
12158   , FULFILLED_QUANTITY
12159   , FULFILLED_FLAG
12160   , FULFILLMENT_METHOD_CODE
12161   , FULFILLMENT_DATE
12162   , GLOBAL_ATTRIBUTE1
12163   , GLOBAL_ATTRIBUTE10
12164   , GLOBAL_ATTRIBUTE11
12165   , GLOBAL_ATTRIBUTE12
12166   , GLOBAL_ATTRIBUTE13
12167   , GLOBAL_ATTRIBUTE14
12168   , GLOBAL_ATTRIBUTE15
12169   , GLOBAL_ATTRIBUTE16
12170   , GLOBAL_ATTRIBUTE17
12171   , GLOBAL_ATTRIBUTE18
12172   , GLOBAL_ATTRIBUTE19
12173   , GLOBAL_ATTRIBUTE2
12174   , GLOBAL_ATTRIBUTE20
12175   , GLOBAL_ATTRIBUTE3
12176   , GLOBAL_ATTRIBUTE4
12177   , GLOBAL_ATTRIBUTE5
12178   , GLOBAL_ATTRIBUTE6
12179   , GLOBAL_ATTRIBUTE7
12180   , GLOBAL_ATTRIBUTE8
12181   , GLOBAL_ATTRIBUTE9
12182   , GLOBAL_ATTRIBUTE_CATEGORY
12183   , HEADER_ID
12184   , INDUSTRY_ATTRIBUTE1
12185   , INDUSTRY_ATTRIBUTE10
12186   , INDUSTRY_ATTRIBUTE11
12187   , INDUSTRY_ATTRIBUTE12
12188   , INDUSTRY_ATTRIBUTE13
12189   , INDUSTRY_ATTRIBUTE14
12190   , INDUSTRY_ATTRIBUTE15
12191   , INDUSTRY_ATTRIBUTE16
12192   , INDUSTRY_ATTRIBUTE17
12193   , INDUSTRY_ATTRIBUTE18
12194   , INDUSTRY_ATTRIBUTE19
12195   , INDUSTRY_ATTRIBUTE20
12196   , INDUSTRY_ATTRIBUTE21
12197   , INDUSTRY_ATTRIBUTE22
12198   , INDUSTRY_ATTRIBUTE23
12199   , INDUSTRY_ATTRIBUTE24
12200   , INDUSTRY_ATTRIBUTE25
12201   , INDUSTRY_ATTRIBUTE26
12202   , INDUSTRY_ATTRIBUTE27
12203   , INDUSTRY_ATTRIBUTE28
12204   , INDUSTRY_ATTRIBUTE29
12205   , INDUSTRY_ATTRIBUTE30
12206   , INDUSTRY_ATTRIBUTE2
12207   , INDUSTRY_ATTRIBUTE3
12208   , INDUSTRY_ATTRIBUTE4
12209   , INDUSTRY_ATTRIBUTE5
12210   , INDUSTRY_ATTRIBUTE6
12211   , INDUSTRY_ATTRIBUTE7
12212   , INDUSTRY_ATTRIBUTE8
12213   , INDUSTRY_ATTRIBUTE9
12214   , INDUSTRY_CONTEXT
12215   , INTMED_SHIP_TO_CONTACT_ID
12216   , INTMED_SHIP_TO_ORG_ID
12217   , INVENTORY_ITEM_ID
12218   , INVOICE_INTERFACE_STATUS_CODE
12219 
12220   , INVOICE_TO_CONTACT_ID
12221   , INVOICE_TO_ORG_ID
12222   , INVOICED_QUANTITY
12223   , INVOICING_RULE_ID
12224   , ORDERED_ITEM_ID
12225   , ITEM_IDENTIFIER_TYPE
12226   , ORDERED_ITEM
12227   , ITEM_REVISION
12228   , ITEM_TYPE_CODE
12229   , LAST_ACK_CODE
12230   , LAST_ACK_DATE
12231   , LAST_UPDATED_BY
12232   , LAST_UPDATE_DATE
12233   , LAST_UPDATE_LOGIN
12234   , LATEST_ACCEPTABLE_DATE
12235   , LINE_CATEGORY_CODE
12236   , LINE_ID
12237   , LINE_NUMBER
12238   , LINE_TYPE_ID
12239   , LINK_TO_LINE_ID
12240 
12241   , MODEL_GROUP_NUMBER
12242   --  , MFG_COMPONENT_SEQUENCE_ID
12243   , MFG_LEAD_TIME
12244   , OPEN_FLAG
12245   , OPTION_FLAG
12246   , OPTION_NUMBER
12247   , ORDERED_QUANTITY
12248   , ORDERED_QUANTITY2              --OPM 02/JUN/00
12249   , ORDER_QUANTITY_UOM
12250   , ORDERED_QUANTITY_UOM2          --OPM 02/JUN/00
12251   , ORG_ID
12252   , ORIG_SYS_DOCUMENT_REF
12253   , ORIG_SYS_LINE_REF
12254   , ORIG_SYS_SHIPMENT_REF
12255   , OVER_SHIP_REASON_CODE
12256   , OVER_SHIP_RESOLVED_FLAG
12257   , PAYMENT_TERM_ID
12258   , PLANNING_PRIORITY
12259   , PREFERRED_GRADE                --OPM 02/JUN/00
12260   , PRICE_LIST_ID
12261   , PRICE_REQUEST_CODE             --PROMOTIONS SEP/01
12262   , PRICING_ATTRIBUTE1
12263   , PRICING_ATTRIBUTE10
12264   , PRICING_ATTRIBUTE2
12265   , PRICING_ATTRIBUTE3
12266   , PRICING_ATTRIBUTE4
12267   , PRICING_ATTRIBUTE5
12268   , PRICING_ATTRIBUTE6
12269   , PRICING_ATTRIBUTE7
12270   , PRICING_ATTRIBUTE8
12271   , PRICING_ATTRIBUTE9
12272   , PRICING_CONTEXT
12273   , PRICING_DATE
12274   , PRICING_QUANTITY
12275   , PRICING_QUANTITY_UOM
12276   , PROGRAM_APPLICATION_ID
12277   , PROGRAM_ID
12278   , PROGRAM_UPDATE_DATE
12279   , PROJECT_ID
12280   , PROMISE_DATE
12281   , RE_SOURCE_FLAG
12282   , REFERENCE_CUSTOMER_TRX_LINE_ID
12283   , REFERENCE_HEADER_ID
12284   , REFERENCE_LINE_ID
12285   , REFERENCE_TYPE
12286 
12287   , REQUEST_DATE
12288   , REQUEST_ID
12289   , RETURN_ATTRIBUTE1
12290   , RETURN_ATTRIBUTE10
12291   , RETURN_ATTRIBUTE11
12292   , RETURN_ATTRIBUTE12
12293   , RETURN_ATTRIBUTE13
12294   , RETURN_ATTRIBUTE14
12295   , RETURN_ATTRIBUTE15
12296   , RETURN_ATTRIBUTE2
12297   , RETURN_ATTRIBUTE3
12298   , RETURN_ATTRIBUTE4
12299   , RETURN_ATTRIBUTE5
12300   , RETURN_ATTRIBUTE6
12301   , RETURN_ATTRIBUTE7
12302   , RETURN_ATTRIBUTE8
12303   , RETURN_ATTRIBUTE9
12304   , RETURN_CONTEXT
12305   , RETURN_REASON_CODE
12306   , RLA_SCHEDULE_TYPE_CODE
12307   , SALESREP_ID
12308   , SCHEDULE_ARRIVAL_DATE
12309   , SCHEDULE_SHIP_DATE
12310   , SCHEDULE_STATUS_CODE
12311   , SHIPMENT_NUMBER
12312   , SHIPMENT_PRIORITY_CODE
12313   , SHIPPED_QUANTITY
12314   , SHIPPED_QUANTITY2 -- OPM B1661023 04/02/01
12315   , SHIPPING_METHOD_CODE
12316   , SHIPPING_QUANTITY
12317   , SHIPPING_QUANTITY2 -- OPM B1661023 04/02/01
12318   , SHIPPING_QUANTITY_UOM
12319   , SHIPPING_QUANTITY_UOM2 -- INVCONV
12320   , SHIP_FROM_ORG_ID
12321   , SUBINVENTORY
12322   , SHIP_SET_ID
12323   , SHIP_TOLERANCE_ABOVE
12324   , SHIP_TOLERANCE_BELOW
12325   , SHIPPABLE_FLAG
12326   , SHIPPING_INTERFACED_FLAG
12327   , SHIP_TO_CONTACT_ID
12328   , SHIP_TO_ORG_ID
12329   , SHIP_MODEL_COMPLETE_FLAG
12330   , SOLD_TO_ORG_ID
12331   , SOLD_FROM_ORG_ID
12332   , SORT_ORDER
12333   , SOURCE_DOCUMENT_ID
12334   , SOURCE_DOCUMENT_LINE_ID
12335   , SOURCE_DOCUMENT_TYPE_ID
12336   , SOURCE_TYPE_CODE
12337   , SPLIT_FROM_LINE_ID
12338   , LINE_SET_ID
12339   , SPLIT_BY
12340   , MODEL_REMNANT_FLAG
12341   , TASK_ID
12342   , TAX_CODE
12343   , TAX_DATE
12344   , TAX_EXEMPT_FLAG
12345   , TAX_EXEMPT_NUMBER
12346   , TAX_EXEMPT_REASON_CODE
12347   , TAX_POINT_CODE
12348   , TAX_RATE
12349   , TAX_VALUE
12350   , TOP_MODEL_LINE_ID
12351   , UNIT_LIST_PRICE
12352   , UNIT_LIST_PRICE_PER_PQTY
12353   , UNIT_SELLING_PRICE
12354   , UNIT_SELLING_PRICE_PER_PQTY
12355   , VISIBLE_DEMAND_FLAG
12356   , VEH_CUS_ITEM_CUM_KEY_ID
12357   , SHIPPING_INSTRUCTIONS
12358   , PACKING_INSTRUCTIONS
12359   , SERVICE_TXN_REASON_CODE
12360   , SERVICE_TXN_COMMENTS
12361   , SERVICE_DURATION
12362   , SERVICE_PERIOD
12363   , SERVICE_START_DATE
12364   , SERVICE_END_DATE
12365   , SERVICE_COTERMINATE_FLAG
12366   , UNIT_LIST_PERCENT
12367   , UNIT_SELLING_PERCENT
12368   , UNIT_PERCENT_BASE_PRICE
12369   , SERVICE_NUMBER
12370   , SERVICE_REFERENCE_TYPE_CODE
12371   , SERVICE_REFERENCE_LINE_ID
12372   , SERVICE_REFERENCE_SYSTEM_ID
12373   , TP_CONTEXT
12374   , TP_ATTRIBUTE1
12375   , TP_ATTRIBUTE2
12376   , TP_ATTRIBUTE3
12377   , TP_ATTRIBUTE4
12378   , TP_ATTRIBUTE5
12379   , TP_ATTRIBUTE6
12380   , TP_ATTRIBUTE7
12381   , TP_ATTRIBUTE8
12382   , TP_ATTRIBUTE9
12383   , TP_ATTRIBUTE10
12384   , TP_ATTRIBUTE11
12385   , TP_ATTRIBUTE12
12386   , TP_ATTRIBUTE13
12387   , TP_ATTRIBUTE14
12388   , TP_ATTRIBUTE15
12389   , FLOW_STATUS_CODE
12390   , MARKETING_SOURCE_CODE_ID
12391   , CALCULATE_PRICE_FLAG
12392   , COMMITMENT_ID
12393   , ORDER_SOURCE_ID        -- aksingh
12394   , upgraded_flag
12395   , ORIGINAL_INVENTORY_ITEM_ID
12396   , ORIGINAL_ITEM_IDENTIFIER_TYPE
12397   , ORIGINAL_ORDERED_ITEM_ID
12398   , ORIGINAL_ORDERED_ITEM
12399   , ITEM_RELATIONSHIP_TYPE
12400   , ITEM_SUBSTITUTION_TYPE_CODE
12401   , LATE_DEMAND_PENALTY_FACTOR
12402   , OVERRIDE_ATP_DATE_CODE
12403   , FIRM_DEMAND_FLAG
12404   , EARLIEST_SHIP_DATE
12405   , USER_ITEM_DESCRIPTION
12406   , BLANKET_NUMBER
12407   , BLANKET_LINE_NUMBER
12408   , BLANKET_VERSION_NUMBER
12409     --MRG B
12410   , UNIT_COST
12411     --MRG E
12412   , LOCK_CONTROL
12413   , NVL(OPTION_NUMBER, -1)  OPN
12414   , NVL(COMPONENT_NUMBER, -1)  CPN
12415   , NVL(SERVICE_NUMBER, -1)  SVN
12416   , CHANGE_SEQUENCE
12417 	-- Changes to quoting
12418   , transaction_phase_code
12419    ,      source_document_version_number
12420 	-- End changes to quoting
12421   , MINISITE_ID
12422    ,  Ib_Owner
12423    ,  Ib_installed_at_location
12424    ,  Ib_current_location
12425    ,  End_customer_ID
12426    ,  End_customer_contact_ID
12427    ,  End_customer_site_use_ID
12428 /*   ,  Supplier_signature
12429    ,  Supplier_signature_date
12430    ,  Customer_signature
12431    ,  Customer_signature_date  */
12432    --retro{
12433    , RETROBILL_REQUEST_ID
12434    --retro}
12435    , ORIGINAL_LIST_PRICE  -- Override List Price
12436  -- key Transaction Dates
12437    , order_firmed_date
12438    , actual_fulfillment_date
12439 
12440    --recurring charges
12441    , charge_periodicity_code
12442 -- INVCONV
12443     , CANCELLED_QUANTITY2
12444     , FULFILLED_QUANTITY2
12445   --Customer Acceptance
12446    ,CONTINGENCY_ID
12447    ,REVREC_EVENT_CODE
12448    ,REVREC_EXPIRATION_DAYS
12449    ,ACCEPTED_QUANTITY
12450    ,REVREC_COMMENTS
12451    ,REVREC_SIGNATURE
12452    ,REVREC_SIGNATURE_DATE
12453    ,ACCEPTED_BY
12454    ,REVREC_REFERENCE_DOCUMENT
12455    ,REVREC_IMPLICIT_FLAG
12456    -- sol_ord_er #16014165
12457 	, SERVICE_BILL_PROFILE_ID
12458 	, SERVICE_COV_TEMPLATE_ID
12459 	, SERVICE_SUBS_TEMPLATE_ID
12460 	, SERVICE_BILL_OPTION_CODE
12461 	, SUBSCRIPTION_ENABLE_FLAG
12462 	, SERVICE_FIRST_PERIOD_AMOUNT
12463 	, SERVICE_FIRST_PERIOD_ENDDATE
12464 	-- sol_ord_er #16014165
12465    ,FULFILLMENT_BASE   --ER#14763609
12466     FROM    OE_ORDER_LINES_ALL  -- Fix for FP bug 3391622
12467     WHERE HEADER_ID = p_header_id
12468     ORDER BY LINE_NUMBER,SHIPMENT_NUMBER,OPN, CPN, SVN;
12469 
12470 
12471 CURSOR l_line_csr_s IS
12472     SELECT  ACCOUNTING_RULE_ID
12473   , ACCOUNTING_RULE_DURATION
12474   , ACTUAL_ARRIVAL_DATE
12475   , ACTUAL_SHIPMENT_DATE
12476   , AGREEMENT_ID
12477   , ARRIVAL_SET_ID
12478   , ATO_LINE_ID
12479   , ATTRIBUTE1
12480   , ATTRIBUTE10
12481   , ATTRIBUTE11
12482   , ATTRIBUTE12
12483   , ATTRIBUTE13
12484   , ATTRIBUTE14
12485   , ATTRIBUTE15
12486   , ATTRIBUTE16   --For bug 2184255
12487   , ATTRIBUTE17
12488   , ATTRIBUTE18
12489   , ATTRIBUTE19
12490   , ATTRIBUTE2
12491   , ATTRIBUTE20
12492   , ATTRIBUTE3
12493   , ATTRIBUTE4
12494   , ATTRIBUTE5
12495   , ATTRIBUTE6
12496   , ATTRIBUTE7
12497   , ATTRIBUTE8
12498   , ATTRIBUTE9
12499   , AUTO_SELECTED_QUANTITY
12500   , AUTHORIZED_TO_SHIP_FLAG
12501   , BOOKED_FLAG
12502   , CANCELLED_FLAG
12503   , CANCELLED_QUANTITY
12504   , COMPONENT_CODE
12505   , COMPONENT_NUMBER
12506   , COMPONENT_SEQUENCE_ID
12507   , CONFIG_HEADER_ID
12508   , CONFIG_REV_NBR
12509   , CONFIG_DISPLAY_SEQUENCE
12510   , CONFIGURATION_ID
12511   , CONTEXT
12512 
12513   , CREATED_BY
12514   , CREATION_DATE
12515   , CREDIT_INVOICE_LINE_ID
12516   , CUSTOMER_DOCK_CODE
12517   , CUSTOMER_JOB
12518   , CUSTOMER_PRODUCTION_LINE
12519   , CUST_PRODUCTION_SEQ_NUM
12520   , CUSTOMER_TRX_LINE_ID
12521   , CUST_MODEL_SERIAL_NUMBER
12522   , CUST_PO_NUMBER
12523   , CUSTOMER_LINE_NUMBER
12524   , CUSTOMER_SHIPMENT_NUMBER
12525   , CUSTOMER_ITEM_NET_PRICE
12526   , DELIVERY_LEAD_TIME
12527   , DELIVER_TO_CONTACT_ID
12528   , DELIVER_TO_ORG_ID
12529   , DEMAND_BUCKET_TYPE_CODE
12530   , DEMAND_CLASS_CODE
12531   , DEP_PLAN_REQUIRED_FLAG
12532 
12533   , EARLIEST_ACCEPTABLE_DATE
12534   , END_ITEM_UNIT_NUMBER
12535   , EXPLOSION_DATE
12536   , FIRST_ACK_CODE
12537   , FIRST_ACK_DATE
12538   , FOB_POINT_CODE
12539   , FREIGHT_CARRIER_CODE
12540   , FREIGHT_TERMS_CODE
12541   , FULFILLED_QUANTITY
12542   , FULFILLED_FLAG
12543   , FULFILLMENT_METHOD_CODE
12544   , FULFILLMENT_DATE
12545   , GLOBAL_ATTRIBUTE1
12546   , GLOBAL_ATTRIBUTE10
12547   , GLOBAL_ATTRIBUTE11
12548   , GLOBAL_ATTRIBUTE12
12549   , GLOBAL_ATTRIBUTE13
12550   , GLOBAL_ATTRIBUTE14
12551   , GLOBAL_ATTRIBUTE15
12552   , GLOBAL_ATTRIBUTE16
12553   , GLOBAL_ATTRIBUTE17
12554   , GLOBAL_ATTRIBUTE18
12555   , GLOBAL_ATTRIBUTE19
12556   , GLOBAL_ATTRIBUTE2
12557   , GLOBAL_ATTRIBUTE20
12558   , GLOBAL_ATTRIBUTE3
12559   , GLOBAL_ATTRIBUTE4
12560   , GLOBAL_ATTRIBUTE5
12561   , GLOBAL_ATTRIBUTE6
12562   , GLOBAL_ATTRIBUTE7
12563   , GLOBAL_ATTRIBUTE8
12564   , GLOBAL_ATTRIBUTE9
12565   , GLOBAL_ATTRIBUTE_CATEGORY
12566   , HEADER_ID
12567   , INDUSTRY_ATTRIBUTE1
12568   , INDUSTRY_ATTRIBUTE10
12569   , INDUSTRY_ATTRIBUTE11
12570   , INDUSTRY_ATTRIBUTE12
12571   , INDUSTRY_ATTRIBUTE13
12572   , INDUSTRY_ATTRIBUTE14
12573   , INDUSTRY_ATTRIBUTE15
12574   , INDUSTRY_ATTRIBUTE16
12575   , INDUSTRY_ATTRIBUTE17
12576   , INDUSTRY_ATTRIBUTE18
12577   , INDUSTRY_ATTRIBUTE19
12578   , INDUSTRY_ATTRIBUTE20
12579   , INDUSTRY_ATTRIBUTE21
12580   , INDUSTRY_ATTRIBUTE22
12581   , INDUSTRY_ATTRIBUTE23
12582   , INDUSTRY_ATTRIBUTE24
12583   , INDUSTRY_ATTRIBUTE25
12584   , INDUSTRY_ATTRIBUTE26
12585   , INDUSTRY_ATTRIBUTE27
12586   , INDUSTRY_ATTRIBUTE28
12587   , INDUSTRY_ATTRIBUTE29
12588   , INDUSTRY_ATTRIBUTE30
12589   , INDUSTRY_ATTRIBUTE2
12590   , INDUSTRY_ATTRIBUTE3
12591   , INDUSTRY_ATTRIBUTE4
12592   , INDUSTRY_ATTRIBUTE5
12593   , INDUSTRY_ATTRIBUTE6
12594   , INDUSTRY_ATTRIBUTE7
12595   , INDUSTRY_ATTRIBUTE8
12596   , INDUSTRY_ATTRIBUTE9
12597   , INDUSTRY_CONTEXT
12598   , INTMED_SHIP_TO_CONTACT_ID
12599   , INTMED_SHIP_TO_ORG_ID
12600   , INVENTORY_ITEM_ID
12601   , INVOICE_INTERFACE_STATUS_CODE
12602 
12603 
12604 
12605   , INVOICE_TO_CONTACT_ID
12606   , INVOICE_TO_ORG_ID
12607   , INVOICED_QUANTITY
12608   , INVOICING_RULE_ID
12609   , ORDERED_ITEM_ID
12610   , ITEM_IDENTIFIER_TYPE
12611   , ORDERED_ITEM
12612   , ITEM_REVISION
12613   , ITEM_TYPE_CODE
12614   , LAST_ACK_CODE
12615   , LAST_ACK_DATE
12616   , LAST_UPDATED_BY
12617   , LAST_UPDATE_DATE
12618   , LAST_UPDATE_LOGIN
12619   , LATEST_ACCEPTABLE_DATE
12620   , LINE_CATEGORY_CODE
12621   , LINE_ID
12622   , LINE_NUMBER
12623   , LINE_TYPE_ID
12624   , LINK_TO_LINE_ID
12625 
12626   , MODEL_GROUP_NUMBER
12627   --  , MFG_COMPONENT_SEQUENCE_ID
12628   , MFG_LEAD_TIME
12629   , OPEN_FLAG
12630   , OPTION_FLAG
12631   , OPTION_NUMBER
12632   , ORDERED_QUANTITY
12633   , ORDERED_QUANTITY2              --OPM 02/JUN/00
12634   , ORDER_QUANTITY_UOM
12635   , ORDERED_QUANTITY_UOM2          --OPM 02/JUN/00
12636   , ORG_ID
12637   , ORIG_SYS_DOCUMENT_REF
12638   , ORIG_SYS_LINE_REF
12639   , ORIG_SYS_SHIPMENT_REF
12640   , OVER_SHIP_REASON_CODE
12641   , OVER_SHIP_RESOLVED_FLAG
12642   , PAYMENT_TERM_ID
12643   , PLANNING_PRIORITY
12644   , PREFERRED_GRADE                --OPM 02/JUN/00
12645   , PRICE_LIST_ID
12646   , PRICE_REQUEST_CODE             --PROMOTIONS SEP/01
12647   , PRICING_ATTRIBUTE1
12648   , PRICING_ATTRIBUTE10
12649   , PRICING_ATTRIBUTE2
12650   , PRICING_ATTRIBUTE3
12651   , PRICING_ATTRIBUTE4
12652   , PRICING_ATTRIBUTE5
12653   , PRICING_ATTRIBUTE6
12654   , PRICING_ATTRIBUTE7
12655   , PRICING_ATTRIBUTE8
12656   , PRICING_ATTRIBUTE9
12657   , PRICING_CONTEXT
12658   , PRICING_DATE
12659   , PRICING_QUANTITY
12660   , PRICING_QUANTITY_UOM
12661   , PROGRAM_APPLICATION_ID
12662   , PROGRAM_ID
12663   , PROGRAM_UPDATE_DATE
12664   , PROJECT_ID
12665   , PROMISE_DATE
12666   , RE_SOURCE_FLAG
12667   , REFERENCE_CUSTOMER_TRX_LINE_ID
12668   , REFERENCE_HEADER_ID
12669   , REFERENCE_LINE_ID
12670   , REFERENCE_TYPE
12671 
12672   , REQUEST_DATE
12673   , REQUEST_ID
12674   , RETURN_ATTRIBUTE1
12675   , RETURN_ATTRIBUTE10
12676   , RETURN_ATTRIBUTE11
12677   , RETURN_ATTRIBUTE12
12678   , RETURN_ATTRIBUTE13
12679   , RETURN_ATTRIBUTE14
12680   , RETURN_ATTRIBUTE15
12681   , RETURN_ATTRIBUTE2
12682   , RETURN_ATTRIBUTE3
12683   , RETURN_ATTRIBUTE4
12684   , RETURN_ATTRIBUTE5
12685   , RETURN_ATTRIBUTE6
12686   , RETURN_ATTRIBUTE7
12687   , RETURN_ATTRIBUTE8
12688   , RETURN_ATTRIBUTE9
12689   , RETURN_CONTEXT
12690   , RETURN_REASON_CODE
12691   , RLA_SCHEDULE_TYPE_CODE
12692   , SALESREP_ID
12693   , SCHEDULE_ARRIVAL_DATE
12694   , SCHEDULE_SHIP_DATE
12695   , SCHEDULE_STATUS_CODE
12696   , SHIPMENT_NUMBER
12697   , SHIPMENT_PRIORITY_CODE
12698   , SHIPPED_QUANTITY
12699   , SHIPPED_QUANTITY2 -- OPM B1661023 04/02/01
12700   , SHIPPING_METHOD_CODE
12701   , SHIPPING_QUANTITY
12702   , SHIPPING_QUANTITY2 -- OPM B1661023 04/02/01
12703   , SHIPPING_QUANTITY_UOM
12704   , SHIPPING_QUANTITY_UOM2 -- INVCONV
12705   , SHIP_FROM_ORG_ID
12706   , SUBINVENTORY
12707   , SHIP_SET_ID
12708   , SHIP_TOLERANCE_ABOVE
12709   , SHIP_TOLERANCE_BELOW
12710   , SHIPPABLE_FLAG
12711   , SHIPPING_INTERFACED_FLAG
12712   , SHIP_TO_CONTACT_ID
12713   , SHIP_TO_ORG_ID
12714   , SHIP_MODEL_COMPLETE_FLAG
12715   , SOLD_TO_ORG_ID
12716   , SOLD_FROM_ORG_ID
12717   , SORT_ORDER
12718   , SOURCE_DOCUMENT_ID
12719   , SOURCE_DOCUMENT_LINE_ID
12720   , SOURCE_DOCUMENT_TYPE_ID
12721   , SOURCE_TYPE_CODE
12722   , SPLIT_FROM_LINE_ID
12723   , LINE_SET_ID
12724   , SPLIT_BY
12725   , MODEL_REMNANT_FLAG
12726   , TASK_ID
12727   , TAX_CODE
12728   , TAX_DATE
12729   , TAX_EXEMPT_FLAG
12730   , TAX_EXEMPT_NUMBER
12731   , TAX_EXEMPT_REASON_CODE
12732   , TAX_POINT_CODE
12733   , TAX_RATE
12734   , TAX_VALUE
12735   , TOP_MODEL_LINE_ID
12736   , UNIT_LIST_PRICE
12737   , UNIT_LIST_PRICE_PER_PQTY
12738   , UNIT_SELLING_PRICE
12739   , UNIT_SELLING_PRICE_PER_PQTY
12740   , VISIBLE_DEMAND_FLAG
12741   , VEH_CUS_ITEM_CUM_KEY_ID
12742   , SHIPPING_INSTRUCTIONS
12743   , PACKING_INSTRUCTIONS
12744   , SERVICE_TXN_REASON_CODE
12745   , SERVICE_TXN_COMMENTS
12746   , SERVICE_DURATION
12747   , SERVICE_PERIOD
12748   , SERVICE_START_DATE
12749   , SERVICE_END_DATE
12750   , SERVICE_COTERMINATE_FLAG
12751   , UNIT_LIST_PERCENT
12752   , UNIT_SELLING_PERCENT
12753   , UNIT_PERCENT_BASE_PRICE
12754   , SERVICE_NUMBER
12755   , SERVICE_REFERENCE_TYPE_CODE
12756   , SERVICE_REFERENCE_LINE_ID
12757   , SERVICE_REFERENCE_SYSTEM_ID
12758   , TP_CONTEXT
12759   , TP_ATTRIBUTE1
12760   , TP_ATTRIBUTE2
12761   , TP_ATTRIBUTE3
12762   , TP_ATTRIBUTE4
12763   , TP_ATTRIBUTE5
12764   , TP_ATTRIBUTE6
12765   , TP_ATTRIBUTE7
12766   , TP_ATTRIBUTE8
12767   , TP_ATTRIBUTE9
12768   , TP_ATTRIBUTE10
12769   , TP_ATTRIBUTE11
12770   , TP_ATTRIBUTE12
12771   , TP_ATTRIBUTE13
12772   , TP_ATTRIBUTE14
12773   , TP_ATTRIBUTE15
12774   , FLOW_STATUS_CODE
12775   , MARKETING_SOURCE_CODE_ID
12776   , CALCULATE_PRICE_FLAG
12777   , COMMITMENT_ID
12778   , ORDER_SOURCE_ID        -- aksingh
12779   , upgraded_flag
12780   , ORIGINAL_INVENTORY_ITEM_ID
12781   , ORIGINAL_ITEM_IDENTIFIER_TYPE
12782   , ORIGINAL_ORDERED_ITEM_ID
12783   , ORIGINAL_ORDERED_ITEM
12784   , ITEM_RELATIONSHIP_TYPE
12785   , ITEM_SUBSTITUTION_TYPE_CODE
12786   , LATE_DEMAND_PENALTY_FACTOR
12787   , OVERRIDE_ATP_DATE_CODE
12788   , FIRM_DEMAND_FLAG
12789   , EARLIEST_SHIP_DATE
12790   , USER_ITEM_DESCRIPTION
12791   , BLANKET_NUMBER
12792   , BLANKET_LINE_NUMBER
12793   , BLANKET_VERSION_NUMBER
12794 --MRG B
12795   , UNIT_COST
12796 --MRG E
12797   , LOCK_CONTROL
12798   , NVL(OPTION_NUMBER, -1)  OPN
12799   , NVL(COMPONENT_NUMBER, -1)  CPN
12800   , NVL(SERVICE_NUMBER, -1)  SVN
12801   , CHANGE_SEQUENCE
12802 	-- Changes to quoting
12803   , transaction_phase_code
12804    ,      source_document_version_number
12805 	-- End changes to quoting
12806   , MINISITE_ID
12807    ,  Ib_Owner
12808    ,  Ib_installed_at_location
12809    ,  Ib_current_location
12810    ,  End_customer_ID
12811    ,  End_customer_contact_ID
12812    ,  End_customer_site_use_ID
12813 /*   ,  Supplier_signature
12814    ,  Supplier_signature_date
12815    ,  Customer_signature
12816    ,  Customer_signature_date  */
12817    --retro{
12818    , RETROBILL_REQUEST_ID
12819    --retro}
12820    , ORIGINAL_LIST_PRICE  -- Override List Price
12821  -- key Transaction Dates
12822    , order_firmed_date
12823    , actual_fulfillment_date
12824    --recurring charges
12825    , charge_periodicity_code
12826    -- INVCONV
12827     , CANCELLED_QUANTITY2
12828     , FULFILLED_QUANTITY2
12829   --Customer Acceptance
12830    ,CONTINGENCY_ID
12831    ,REVREC_EVENT_CODE
12832    ,REVREC_EXPIRATION_DAYS
12833    ,ACCEPTED_QUANTITY
12834    ,REVREC_COMMENTS
12835    ,REVREC_SIGNATURE
12836    ,REVREC_SIGNATURE_DATE
12837    ,ACCEPTED_BY
12838    ,REVREC_REFERENCE_DOCUMENT
12839    ,REVREC_IMPLICIT_FLAG
12840    -- sol_ord_er #16014165
12841 	, SERVICE_BILL_PROFILE_ID
12842 	, SERVICE_COV_TEMPLATE_ID
12843 	, SERVICE_SUBS_TEMPLATE_ID
12844 	, SERVICE_BILL_OPTION_CODE
12845 	, SUBSCRIPTION_ENABLE_FLAG
12846 	, SERVICE_FIRST_PERIOD_AMOUNT
12847 	, SERVICE_FIRST_PERIOD_ENDDATE
12848 	-- sol_ord_er #16014165 end
12849    ,FULFILLMENT_BASE --ER#14763609
12850     FROM    OE_ORDER_LINES_ALL  -- Fix for FP bug 3391622
12851     WHERE LINE_SET_ID = p_line_set_id
12852     ORDER BY LINE_NUMBER,SHIPMENT_NUMBER,OPN, CPN, SVN;
12853 
12854     l_OPN   NUMBER;
12855     l_CPN   NUMBER;
12856     l_SVN   NUMBER;
12857 
12858 
12859 --
12860 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
12861 --
12862 l_line_rec OE_ORDER_PUB.line_rec_type;
12863 BEGIN
12864 
12865     IF l_debug_level  > 0 THEN
12866       oe_debug_pub.add('Entering OE_LINE_UTIL.QUERY_ROWS, line_id:'||p_line_id, 1);
12867     END IF;
12868 
12869     IF
12870     (p_line_id IS NOT NULL
12871      AND
12872      p_line_id <> FND_API.G_MISS_NUM)
12873     AND
12874     (p_header_id IS NOT NULL
12875      AND
12876      p_header_id <> FND_API.G_MISS_NUM)
12877     THEN
12878             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
12879             THEN
12880                 OE_MSG_PUB.Add_Exc_Msg
12881                 (   G_PKG_NAME
12882               ,   'Query Rows'
12883               ,   'Keys are mutually exclusive: line_id = '|| p_line_id || ', header_id = '|| p_header_id
12884                 );
12885             END IF;
12886 
12887         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
12888 
12889     END IF;
12890 
12891     -----------------------------------------------------------------
12892     -- Fix bug 1275972: Setup the l_entity variable based on the ID
12893     -- variable that is passed.
12894     -----------------------------------------------------------------
12895 
12896     IF nvl(p_line_id,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM THEN
12897 
12898 	   l_entity := 1;
12899         Query_Row(p_line_id => p_line_id,
12900                   x_line_rec => l_line_rec);
12901         x_line_tbl(1) := l_line_rec;
12902         RETURN;
12903     ELSIF nvl(p_header_id,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM THEN
12904 
12905 	   l_entity := 2;
12906            OPEN l_line_csr_h;
12907 
12908     ELSIF nvl(p_line_set_id,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM THEN
12909 
12910 	   l_entity := 3;
12911            OPEN l_line_csr_s;
12912 
12913     END IF;
12914 
12915     --Commented for MOAC start
12916     /*l_org_id := OE_GLOBALS.G_ORG_ID;
12917     if l_org_id IS NULL THEN
12918        OE_GLOBALS.Set_Context;
12919        l_org_id := OE_GLOBALS.G_ORG_ID;
12920     end if;
12921     IF l_debug_level  > 0 THEN
12922       oe_debug_pub.add('Entering '||to_char(l_org_id), 1);
12923     END IF;*/
12924   --Commented for MOAC end
12925 
12926     --  Loop over fetched records
12927 
12928     i := 1;
12929 
12930     LOOP
12931 
12932         IF l_entity = 2 THEN
12933              FETCH l_line_csr_h INTO
12934               x_line_tbl(i).ACCOUNTING_RULE_ID
12935             , x_line_tbl(i).ACCOUNTING_RULE_DURATION
12936             , x_line_tbl(i).ACTUAL_ARRIVAL_DATE
12937             , x_line_tbl(i).ACTUAL_SHIPMENT_DATE
12938             , x_line_tbl(i).AGREEMENT_ID
12939             , x_line_tbl(i).ARRIVAL_SET_ID
12940             , x_line_tbl(i).ATO_LINE_ID
12941             , x_line_tbl(i).ATTRIBUTE1
12942             , x_line_tbl(i).ATTRIBUTE10
12943             , x_line_tbl(i).ATTRIBUTE11
12944             , x_line_tbl(i).ATTRIBUTE12
12945             , x_line_tbl(i).ATTRIBUTE13
12946             , x_line_tbl(i).ATTRIBUTE14
12947             , x_line_tbl(i).ATTRIBUTE15
12948             , x_line_tbl(i).ATTRIBUTE16   --For bug 2184255
12949             , x_line_tbl(i).ATTRIBUTE17
12950             , x_line_tbl(i).ATTRIBUTE18
12951             , x_line_tbl(i).ATTRIBUTE19
12952             , x_line_tbl(i).ATTRIBUTE2
12953             , x_line_tbl(i).ATTRIBUTE20
12954             , x_line_tbl(i).ATTRIBUTE3
12955             , x_line_tbl(i).ATTRIBUTE4
12956             , x_line_tbl(i).ATTRIBUTE5
12957             , x_line_tbl(i).ATTRIBUTE6
12958             , x_line_tbl(i).ATTRIBUTE7
12959             , x_line_tbl(i).ATTRIBUTE8
12960             , x_line_tbl(i).ATTRIBUTE9
12961             , x_line_tbl(i).AUTO_SELECTED_QUANTITY
12962             , x_line_tbl(i).AUTHORIZED_TO_SHIP_FLAG
12963             , x_line_tbl(i).BOOKED_FLAG
12964             , x_line_tbl(i).CANCELLED_FLAG
12965             , x_line_tbl(i).CANCELLED_QUANTITY
12966             , x_line_tbl(i).COMPONENT_CODE
12967             , x_line_tbl(i).COMPONENT_NUMBER
12968             , x_line_tbl(i).COMPONENT_SEQUENCE_ID
12969             , x_line_tbl(i).CONFIG_HEADER_ID
12970             , x_line_tbl(i).CONFIG_REV_NBR
12971             , x_line_tbl(i).CONFIG_DISPLAY_SEQUENCE
12972             , x_line_tbl(i).CONFIGURATION_ID
12973             , x_line_tbl(i).CONTEXT
12974             , x_line_tbl(i).CREATED_BY
12975             , x_line_tbl(i).CREATION_DATE
12976             , x_line_tbl(i).CREDIT_INVOICE_LINE_ID
12977             , x_line_tbl(i).CUSTOMER_DOCK_CODE
12978             , x_line_tbl(i).CUSTOMER_JOB
12979             , x_line_tbl(i).CUSTOMER_PRODUCTION_LINE
12980             , x_line_tbl(i).CUST_PRODUCTION_SEQ_NUM
12981             , x_line_tbl(i).CUSTOMER_TRX_LINE_ID
12982             , x_line_tbl(i).CUST_MODEL_SERIAL_NUMBER
12983             , x_line_tbl(i).CUST_PO_NUMBER
12984             , x_line_tbl(i).CUSTOMER_LINE_NUMBER
12985             , x_line_tbl(i).CUSTOMER_SHIPMENT_NUMBER
12986             , x_line_tbl(i).CUSTOMER_ITEM_NET_PRICE
12987             , x_line_tbl(i).DELIVERY_LEAD_TIME
12988             , x_line_tbl(i).DELIVER_TO_CONTACT_ID
12989             , x_line_tbl(i).DELIVER_TO_ORG_ID
12990             , x_line_tbl(i).DEMAND_BUCKET_TYPE_CODE
12991             , x_line_tbl(i).DEMAND_CLASS_CODE
12992             , x_line_tbl(i).DEP_PLAN_REQUIRED_FLAG
12993             , x_line_tbl(i).EARLIEST_ACCEPTABLE_DATE
12994             , x_line_tbl(i).END_ITEM_UNIT_NUMBER
12995             , x_line_tbl(i).EXPLOSION_DATE
12996             , x_line_tbl(i).FIRST_ACK_CODE
12997             , x_line_tbl(i).FIRST_ACK_DATE
12998             , x_line_tbl(i).FOB_POINT_CODE
12999             , x_line_tbl(i).FREIGHT_CARRIER_CODE
13000             , x_line_tbl(i).FREIGHT_TERMS_CODE
13001             , x_line_tbl(i).FULFILLED_QUANTITY
13002             , x_line_tbl(i).FULFILLED_FLAG
13003             , x_line_tbl(i).FULFILLMENT_METHOD_CODE
13004             , x_line_tbl(i).FULFILLMENT_DATE
13005             , x_line_tbl(i).GLOBAL_ATTRIBUTE1
13006             , x_line_tbl(i).GLOBAL_ATTRIBUTE10
13007             , x_line_tbl(i).GLOBAL_ATTRIBUTE11
13008             , x_line_tbl(i).GLOBAL_ATTRIBUTE12
13009             , x_line_tbl(i).GLOBAL_ATTRIBUTE13
13010             , x_line_tbl(i).GLOBAL_ATTRIBUTE14
13011             , x_line_tbl(i).GLOBAL_ATTRIBUTE15
13012             , x_line_tbl(i).GLOBAL_ATTRIBUTE16
13013             , x_line_tbl(i).GLOBAL_ATTRIBUTE17
13014             , x_line_tbl(i).GLOBAL_ATTRIBUTE18
13015             , x_line_tbl(i).GLOBAL_ATTRIBUTE19
13016             , x_line_tbl(i).GLOBAL_ATTRIBUTE2
13017             , x_line_tbl(i).GLOBAL_ATTRIBUTE20
13018             , x_line_tbl(i).GLOBAL_ATTRIBUTE3
13019             , x_line_tbl(i).GLOBAL_ATTRIBUTE4
13020             , x_line_tbl(i).GLOBAL_ATTRIBUTE5
13021             , x_line_tbl(i).GLOBAL_ATTRIBUTE6
13022             , x_line_tbl(i).GLOBAL_ATTRIBUTE7
13023             , x_line_tbl(i).GLOBAL_ATTRIBUTE8
13024             , x_line_tbl(i).GLOBAL_ATTRIBUTE9
13025             , x_line_tbl(i).GLOBAL_ATTRIBUTE_CATEGORY
13026             , x_line_tbl(i).HEADER_ID
13027             , x_line_tbl(i).INDUSTRY_ATTRIBUTE1
13028             , x_line_tbl(i).INDUSTRY_ATTRIBUTE10
13029             , x_line_tbl(i).INDUSTRY_ATTRIBUTE11
13030             , x_line_tbl(i).INDUSTRY_ATTRIBUTE12
13031             , x_line_tbl(i).INDUSTRY_ATTRIBUTE13
13032             , x_line_tbl(i).INDUSTRY_ATTRIBUTE14
13033             , x_line_tbl(i).INDUSTRY_ATTRIBUTE15
13034             , x_line_tbl(i).INDUSTRY_ATTRIBUTE16
13035             , x_line_tbl(i).INDUSTRY_ATTRIBUTE17
13036             , x_line_tbl(i).INDUSTRY_ATTRIBUTE18
13037             , x_line_tbl(i).INDUSTRY_ATTRIBUTE19
13038             , x_line_tbl(i).INDUSTRY_ATTRIBUTE20
13039             , x_line_tbl(i).INDUSTRY_ATTRIBUTE21
13040             , x_line_tbl(i).INDUSTRY_ATTRIBUTE22
13041             , x_line_tbl(i).INDUSTRY_ATTRIBUTE23
13042             , x_line_tbl(i).INDUSTRY_ATTRIBUTE24
13043             , x_line_tbl(i).INDUSTRY_ATTRIBUTE25
13044             , x_line_tbl(i).INDUSTRY_ATTRIBUTE26
13045             , x_line_tbl(i).INDUSTRY_ATTRIBUTE27
13046             , x_line_tbl(i).INDUSTRY_ATTRIBUTE28
13047             , x_line_tbl(i).INDUSTRY_ATTRIBUTE29
13048             , x_line_tbl(i).INDUSTRY_ATTRIBUTE30
13049             , x_line_tbl(i).INDUSTRY_ATTRIBUTE2
13050             , x_line_tbl(i).INDUSTRY_ATTRIBUTE3
13051             , x_line_tbl(i).INDUSTRY_ATTRIBUTE4
13052             , x_line_tbl(i).INDUSTRY_ATTRIBUTE5
13053             , x_line_tbl(i).INDUSTRY_ATTRIBUTE6
13054             , x_line_tbl(i).INDUSTRY_ATTRIBUTE7
13055             , x_line_tbl(i).INDUSTRY_ATTRIBUTE8
13056             , x_line_tbl(i).INDUSTRY_ATTRIBUTE9
13057             , x_line_tbl(i).INDUSTRY_CONTEXT
13058             , x_line_tbl(i).INTERMED_SHIP_TO_CONTACT_ID
13059             , x_line_tbl(i).INTERMED_SHIP_TO_ORG_ID
13060             , x_line_tbl(i).INVENTORY_ITEM_ID
13061             , x_line_tbl(i).INVOICE_INTERFACE_STATUS_CODE
13062             , x_line_tbl(i).INVOICE_TO_CONTACT_ID
13063             , x_line_tbl(i).INVOICE_TO_ORG_ID
13064             , x_line_tbl(i).INVOICED_QUANTITY
13065             , x_line_tbl(i).INVOICING_RULE_ID
13066             , x_line_tbl(i).ORDERED_ITEM_ID
13067             , x_line_tbl(i).ITEM_IDENTIFIER_TYPE
13068             , x_line_tbl(i).ORDERED_ITEM
13069             , x_line_tbl(i).ITEM_REVISION
13070             , x_line_tbl(i).ITEM_TYPE_CODE
13071             , x_line_tbl(i).LAST_ACK_CODE
13072             , x_line_tbl(i).LAST_ACK_DATE
13073             , x_line_tbl(i).LAST_UPDATED_BY
13074             , x_line_tbl(i).LAST_UPDATE_DATE
13075             , x_line_tbl(i).LAST_UPDATE_LOGIN
13076             , x_line_tbl(i).LATEST_ACCEPTABLE_DATE
13077             , x_line_tbl(i).LINE_CATEGORY_CODE
13078             , x_line_tbl(i).LINE_ID
13079             , x_line_tbl(i).LINE_NUMBER
13080             , x_line_tbl(i).LINE_TYPE_ID
13081             , x_line_tbl(i).LINK_TO_LINE_ID
13082             , x_line_tbl(i).MODEL_GROUP_NUMBER
13083             --  , x_line_tbl(i).MFG_COMPONENT_SEQUENCE_ID
13084             , x_line_tbl(i).MFG_LEAD_TIME
13085             , x_line_tbl(i).OPEN_FLAG
13086             , x_line_tbl(i).OPTION_FLAG
13087             , x_line_tbl(i).OPTION_NUMBER
13088             , x_line_tbl(i).ORDERED_QUANTITY
13089             , x_line_tbl(i).ORDERED_QUANTITY2              --OPM 02/JUN/00
13090             , x_line_tbl(i).ORDER_QUANTITY_UOM
13091             , x_line_tbl(i).ORDERED_QUANTITY_UOM2          --OPM 02/JUN/00
13092             , x_line_tbl(i).ORG_ID
13093             , x_line_tbl(i).ORIG_SYS_DOCUMENT_REF
13094             , x_line_tbl(i).ORIG_SYS_LINE_REF
13095             , x_line_tbl(i).ORIG_SYS_SHIPMENT_REF
13096             , x_line_tbl(i).OVER_SHIP_REASON_CODE
13097             , x_line_tbl(i).OVER_SHIP_RESOLVED_FLAG
13098             , x_line_tbl(i).PAYMENT_TERM_ID
13099             , x_line_tbl(i).PLANNING_PRIORITY
13100             , x_line_tbl(i).PREFERRED_GRADE                --OPM 02/JUN/00
13101             , x_line_tbl(i).PRICE_LIST_ID
13102             , x_line_tbl(i).PRICE_REQUEST_CODE             --PROMOTIONS MAY/01
13103             , x_line_tbl(i).PRICING_ATTRIBUTE1
13104             , x_line_tbl(i).PRICING_ATTRIBUTE10
13105             , x_line_tbl(i).PRICING_ATTRIBUTE2
13106             , x_line_tbl(i).PRICING_ATTRIBUTE3
13107             , x_line_tbl(i).PRICING_ATTRIBUTE4
13108             , x_line_tbl(i).PRICING_ATTRIBUTE5
13109             , x_line_tbl(i).PRICING_ATTRIBUTE6
13110             , x_line_tbl(i).PRICING_ATTRIBUTE7
13111             , x_line_tbl(i).PRICING_ATTRIBUTE8
13112             , x_line_tbl(i).PRICING_ATTRIBUTE9
13113             , x_line_tbl(i).PRICING_CONTEXT
13114             , x_line_tbl(i).PRICING_DATE
13115             , x_line_tbl(i).PRICING_QUANTITY
13116             , x_line_tbl(i).PRICING_QUANTITY_UOM
13117             , x_line_tbl(i).PROGRAM_APPLICATION_ID
13118             , x_line_tbl(i).PROGRAM_ID
13119             , x_line_tbl(i).PROGRAM_UPDATE_DATE
13120             , x_line_tbl(i).PROJECT_ID
13121             , x_line_tbl(i).PROMISE_DATE
13122             , x_line_tbl(i).RE_SOURCE_FLAG
13123             , x_line_tbl(i).REFERENCE_CUSTOMER_TRX_LINE_ID
13124             , x_line_tbl(i).REFERENCE_HEADER_ID
13125             , x_line_tbl(i).REFERENCE_LINE_ID
13126             , x_line_tbl(i).REFERENCE_TYPE
13127             , x_line_tbl(i).REQUEST_DATE
13128             , x_line_tbl(i).REQUEST_ID
13129             , x_line_tbl(i).RETURN_ATTRIBUTE1
13130             , x_line_tbl(i).RETURN_ATTRIBUTE10
13131             , x_line_tbl(i).RETURN_ATTRIBUTE11
13132             , x_line_tbl(i).RETURN_ATTRIBUTE12
13133             , x_line_tbl(i).RETURN_ATTRIBUTE13
13134             , x_line_tbl(i).RETURN_ATTRIBUTE14
13135             , x_line_tbl(i).RETURN_ATTRIBUTE15
13136             , x_line_tbl(i).RETURN_ATTRIBUTE2
13137             , x_line_tbl(i).RETURN_ATTRIBUTE3
13138             , x_line_tbl(i).RETURN_ATTRIBUTE4
13139             , x_line_tbl(i).RETURN_ATTRIBUTE5
13140             , x_line_tbl(i).RETURN_ATTRIBUTE6
13141             , x_line_tbl(i).RETURN_ATTRIBUTE7
13142             , x_line_tbl(i).RETURN_ATTRIBUTE8
13143             , x_line_tbl(i).RETURN_ATTRIBUTE9
13144             , x_line_tbl(i).RETURN_CONTEXT
13145             , x_line_tbl(i).RETURN_REASON_CODE
13146             , x_line_tbl(i).RLA_SCHEDULE_TYPE_CODE
13147             , x_line_tbl(i).SALESREP_ID
13148             , x_line_tbl(i).SCHEDULE_ARRIVAL_DATE
13149             , x_line_tbl(i).SCHEDULE_SHIP_DATE
13150             , x_line_tbl(i).SCHEDULE_STATUS_CODE
13151             , x_line_tbl(i).SHIPMENT_NUMBER
13152             , x_line_tbl(i).SHIPMENT_PRIORITY_CODE
13153             , x_line_tbl(i).SHIPPED_QUANTITY
13154             , x_line_tbl(i).SHIPPED_QUANTITY2 -- OPM B1661023 04/02/01
13155             , x_line_tbl(i).SHIPPING_METHOD_CODE
13156             , x_line_tbl(i).SHIPPING_QUANTITY
13157             , x_line_tbl(i).SHIPPING_QUANTITY2 -- OPM B1661023 04/02/01
13158             , x_line_tbl(i).SHIPPING_QUANTITY_UOM
13159             , x_line_tbl(i).SHIPPING_QUANTITY_UOM2
13160             , x_line_tbl(i).SHIP_FROM_ORG_ID
13161             , x_line_tbl(i).SUBINVENTORY
13162             , x_line_tbl(i).SHIP_SET_ID
13163             , x_line_tbl(i).SHIP_TOLERANCE_ABOVE
13164             , x_line_tbl(i).SHIP_TOLERANCE_BELOW
13165             , x_line_tbl(i).SHIPPABLE_FLAG
13166             , x_line_tbl(i).SHIPPING_INTERFACED_FLAG
13167             , x_line_tbl(i).SHIP_TO_CONTACT_ID
13168             , x_line_tbl(i).SHIP_TO_ORG_ID
13169             , x_line_tbl(i).SHIP_MODEL_COMPLETE_FLAG
13170             , x_line_tbl(i).SOLD_TO_ORG_ID
13171             , x_line_tbl(i).SOLD_FROM_ORG_ID
13172             , x_line_tbl(i).SORT_ORDER
13173             , x_line_tbl(i).SOURCE_DOCUMENT_ID
13174             , x_line_tbl(i).SOURCE_DOCUMENT_LINE_ID
13175             , x_line_tbl(i).SOURCE_DOCUMENT_TYPE_ID
13176             , x_line_tbl(i).SOURCE_TYPE_CODE
13177             , x_line_tbl(i).SPLIT_FROM_LINE_ID
13178             , x_line_tbl(i).LINE_SET_ID
13179             , x_line_tbl(i).SPLIT_BY
13180             , x_line_tbl(i).MODEL_REMNANT_FLAG
13181             , x_line_tbl(i).TASK_ID
13182             , x_line_tbl(i).TAX_CODE
13183             , x_line_tbl(i).TAX_DATE
13184             , x_line_tbl(i).TAX_EXEMPT_FLAG
13185             , x_line_tbl(i).TAX_EXEMPT_NUMBER
13186             , x_line_tbl(i).TAX_EXEMPT_REASON_CODE
13187             , x_line_tbl(i).TAX_POINT_CODE
13188             , x_line_tbl(i).TAX_RATE
13189             , x_line_tbl(i).TAX_VALUE
13190             , x_line_tbl(i).TOP_MODEL_LINE_ID
13191             , x_line_tbl(i).UNIT_LIST_PRICE
13192             , x_line_tbl(i).UNIT_LIST_PRICE_PER_PQTY
13193             , x_line_tbl(i).UNIT_SELLING_PRICE
13194             , x_line_tbl(i).UNIT_SELLING_PRICE_PER_PQTY
13195             , x_line_tbl(i).VISIBLE_DEMAND_FLAG
13196             , x_line_tbl(i).VEH_CUS_ITEM_CUM_KEY_ID
13197             , x_line_tbl(i).SHIPPING_INSTRUCTIONS
13198             , x_line_tbl(i).PACKING_INSTRUCTIONS
13199             , x_line_tbl(i).SERVICE_TXN_REASON_CODE
13200             , x_line_tbl(i).SERVICE_TXN_COMMENTS
13201             , x_line_tbl(i).SERVICE_DURATION
13202             , x_line_tbl(i).SERVICE_PERIOD
13203             , x_line_tbl(i).SERVICE_START_DATE
13204             , x_line_tbl(i).SERVICE_END_DATE
13205             , x_line_tbl(i).SERVICE_COTERMINATE_FLAG
13206             , x_line_tbl(i).UNIT_LIST_PERCENT
13207             , x_line_tbl(i).UNIT_SELLING_PERCENT
13208             , x_line_tbl(i).UNIT_PERCENT_BASE_PRICE
13209             , x_line_tbl(i).SERVICE_NUMBER
13210             , x_line_tbl(i).SERVICE_REFERENCE_TYPE_CODE
13211             , x_line_tbl(i).SERVICE_REFERENCE_LINE_ID
13212             , x_line_tbl(i).SERVICE_REFERENCE_SYSTEM_ID
13213             , x_line_tbl(i).TP_CONTEXT
13214             , x_line_tbl(i).TP_ATTRIBUTE1
13215             , x_line_tbl(i).TP_ATTRIBUTE2
13216             , x_line_tbl(i).TP_ATTRIBUTE3
13217             , x_line_tbl(i).TP_ATTRIBUTE4
13218             , x_line_tbl(i).TP_ATTRIBUTE5
13219             , x_line_tbl(i).TP_ATTRIBUTE6
13220             , x_line_tbl(i).TP_ATTRIBUTE7
13221             , x_line_tbl(i).TP_ATTRIBUTE8
13222             , x_line_tbl(i).TP_ATTRIBUTE9
13223             , x_line_tbl(i).TP_ATTRIBUTE10
13224             , x_line_tbl(i).TP_ATTRIBUTE11
13225             , x_line_tbl(i).TP_ATTRIBUTE12
13226             , x_line_tbl(i).TP_ATTRIBUTE13
13227             , x_line_tbl(i).TP_ATTRIBUTE14
13228             , x_line_tbl(i).TP_ATTRIBUTE15
13229             , x_line_tbl(i).FLOW_STATUS_CODE
13230             , x_line_tbl(i).MARKETING_SOURCE_CODE_ID
13231             , x_line_tbl(i).CALCULATE_PRICE_FLAG
13232             , x_line_tbl(i).COMMITMENT_ID
13233             , x_line_tbl(i).ORDER_SOURCE_ID        -- aksingh
13234             , x_line_tbl(i).UPGRADED_FLAG
13235             , x_line_tbl(i).ORIGINAL_INVENTORY_ITEM_ID
13236             , x_line_tbl(i).ORIGINAL_ITEM_IDENTIFIER_TYPE
13237             , x_line_tbl(i).ORIGINAL_ORDERED_ITEM_ID
13238             , x_line_tbl(i).ORIGINAL_ORDERED_ITEM
13239             , x_line_tbl(i).ITEM_RELATIONSHIP_TYPE
13240             , x_line_tbl(i).ITEM_SUBSTITUTION_TYPE_CODE
13241             , x_line_tbl(i).LATE_DEMAND_PENALTY_FACTOR
13242             , x_line_tbl(i).OVERRIDE_ATP_DATE_CODE
13243             , x_line_tbl(i).FIRM_DEMAND_FLAG
13244             , x_line_tbl(i).EARLIEST_SHIP_DATE
13245             , x_line_tbl(i).USER_ITEM_DESCRIPTION
13246             , x_line_tbl(i).BLANKET_NUMBER
13247             , x_line_tbl(i).BLANKET_LINE_NUMBER
13248             , x_line_tbl(i).BLANKET_VERSION_NUMBER
13249             , x_line_tbl(i).UNIT_COST
13250             , x_line_tbl(i).LOCK_CONTROL
13251             , l_opn    --OPN
13252             , l_cpn    --CPN
13253             , l_svn    --SVN
13254             , x_line_tbl(i).CHANGE_SEQUENCE
13255             , x_line_tbl(i).transaction_phase_code
13256             , x_line_tbl(i).source_document_version_number
13257             , x_line_tbl(i).MINISITE_ID
13258              , x_line_tbl(i).Ib_Owner
13259              , x_line_tbl(i).Ib_installed_at_location
13260              , x_line_tbl(i).Ib_current_location
13261              , x_line_tbl(i).End_customer_ID
13262              , x_line_tbl(i).End_customer_contact_ID
13263              , x_line_tbl(i).End_customer_site_use_ID
13264              , x_line_tbl(i).RETROBILL_REQUEST_ID
13265              , x_line_tbl(i).ORIGINAL_LIST_PRICE  -- Override List Price
13266              , x_line_tbl(i).order_firmed_date
13267              , x_line_tbl(i).actual_fulfillment_date
13268              , x_line_tbl(i).charge_periodicity_code
13269              , x_line_tbl(i).cancelled_quantity2
13270              , x_line_tbl(i).fulfilled_quantity2
13271              , x_line_tbl(i).CONTINGENCY_ID
13272              , x_line_tbl(i).REVREC_EVENT_CODE
13273              , x_line_tbl(i).REVREC_EXPIRATION_DAYS
13274              , x_line_tbl(i).ACCEPTED_QUANTITY
13275              , x_line_tbl(i).REVREC_COMMENTS
13276              , x_line_tbl(i).REVREC_SIGNATURE
13277              , x_line_tbl(i).REVREC_SIGNATURE_DATE
13278              , x_line_tbl(i).ACCEPTED_BY
13279              , x_line_tbl(i).REVREC_REFERENCE_DOCUMENT
13280              , x_line_tbl(i).REVREC_IMPLICIT_FLAG
13281 			 -- sol_ord_er #16014165
13282 			 , x_line_tbl(i).service_bill_profile_id
13283 			 , x_line_tbl(i).service_cov_template_id
13284 			 , x_line_tbl(i).service_subs_template_id
13285 			 , x_line_tbl(i).service_bill_option_code
13286 			 , x_line_tbl(i).subscription_enable_flag
13287 			 , x_line_tbl(i).service_first_period_amount
13288 			 , x_line_tbl(i).service_first_period_enddate
13289 			 -- sol_ord_er #16014165
13290              , x_line_tbl(i).FULFILLMENT_BASE; --ER#14763609
13291 
13292              EXIT WHEN l_line_csr_h%NOTFOUND;
13293 
13294         ELSIF l_entity = 3 THEN
13295              FETCH l_line_csr_s INTO
13296               x_line_tbl(i).ACCOUNTING_RULE_ID
13297             , x_line_tbl(i).ACCOUNTING_RULE_DURATION
13298             , x_line_tbl(i).ACTUAL_ARRIVAL_DATE
13299             , x_line_tbl(i).ACTUAL_SHIPMENT_DATE
13300             , x_line_tbl(i).AGREEMENT_ID
13301             , x_line_tbl(i).ARRIVAL_SET_ID
13302             , x_line_tbl(i).ATO_LINE_ID
13303             , x_line_tbl(i).ATTRIBUTE1
13304             , x_line_tbl(i).ATTRIBUTE10
13305             , x_line_tbl(i).ATTRIBUTE11
13306             , x_line_tbl(i).ATTRIBUTE12
13307             , x_line_tbl(i).ATTRIBUTE13
13308             , x_line_tbl(i).ATTRIBUTE14
13309             , x_line_tbl(i).ATTRIBUTE15
13310             , x_line_tbl(i).ATTRIBUTE16   --For bug 2184255
13311             , x_line_tbl(i).ATTRIBUTE17
13312             , x_line_tbl(i).ATTRIBUTE18
13313             , x_line_tbl(i).ATTRIBUTE19
13314             , x_line_tbl(i).ATTRIBUTE2
13315             , x_line_tbl(i).ATTRIBUTE20
13316             , x_line_tbl(i).ATTRIBUTE3
13317             , x_line_tbl(i).ATTRIBUTE4
13318             , x_line_tbl(i).ATTRIBUTE5
13319             , x_line_tbl(i).ATTRIBUTE6
13320             , x_line_tbl(i).ATTRIBUTE7
13321             , x_line_tbl(i).ATTRIBUTE8
13322             , x_line_tbl(i).ATTRIBUTE9
13323             , x_line_tbl(i).AUTO_SELECTED_QUANTITY
13324             , x_line_tbl(i).AUTHORIZED_TO_SHIP_FLAG
13325             , x_line_tbl(i).BOOKED_FLAG
13326             , x_line_tbl(i).CANCELLED_FLAG
13327             , x_line_tbl(i).CANCELLED_QUANTITY
13328             , x_line_tbl(i).COMPONENT_CODE
13329             , x_line_tbl(i).COMPONENT_NUMBER
13330             , x_line_tbl(i).COMPONENT_SEQUENCE_ID
13331             , x_line_tbl(i).CONFIG_HEADER_ID
13332             , x_line_tbl(i).CONFIG_REV_NBR
13333             , x_line_tbl(i).CONFIG_DISPLAY_SEQUENCE
13334             , x_line_tbl(i).CONFIGURATION_ID
13335             , x_line_tbl(i).CONTEXT
13336             , x_line_tbl(i).CREATED_BY
13337             , x_line_tbl(i).CREATION_DATE
13338             , x_line_tbl(i).CREDIT_INVOICE_LINE_ID
13339             , x_line_tbl(i).CUSTOMER_DOCK_CODE
13340             , x_line_tbl(i).CUSTOMER_JOB
13341             , x_line_tbl(i).CUSTOMER_PRODUCTION_LINE
13342             , x_line_tbl(i).CUST_PRODUCTION_SEQ_NUM
13343             , x_line_tbl(i).CUSTOMER_TRX_LINE_ID
13344             , x_line_tbl(i).CUST_MODEL_SERIAL_NUMBER
13345             , x_line_tbl(i).CUST_PO_NUMBER
13346             , x_line_tbl(i).CUSTOMER_LINE_NUMBER
13347             , x_line_tbl(i).CUSTOMER_SHIPMENT_NUMBER
13348             , x_line_tbl(i).CUSTOMER_ITEM_NET_PRICE
13349             , x_line_tbl(i).DELIVERY_LEAD_TIME
13350             , x_line_tbl(i).DELIVER_TO_CONTACT_ID
13351             , x_line_tbl(i).DELIVER_TO_ORG_ID
13352             , x_line_tbl(i).DEMAND_BUCKET_TYPE_CODE
13353             , x_line_tbl(i).DEMAND_CLASS_CODE
13354             , x_line_tbl(i).DEP_PLAN_REQUIRED_FLAG
13355             , x_line_tbl(i).EARLIEST_ACCEPTABLE_DATE
13356             , x_line_tbl(i).END_ITEM_UNIT_NUMBER
13357             , x_line_tbl(i).EXPLOSION_DATE
13358             , x_line_tbl(i).FIRST_ACK_CODE
13359             , x_line_tbl(i).FIRST_ACK_DATE
13360             , x_line_tbl(i).FOB_POINT_CODE
13361             , x_line_tbl(i).FREIGHT_CARRIER_CODE
13362             , x_line_tbl(i).FREIGHT_TERMS_CODE
13363             , x_line_tbl(i).FULFILLED_QUANTITY
13364             , x_line_tbl(i).FULFILLED_FLAG
13365             , x_line_tbl(i).FULFILLMENT_METHOD_CODE
13366             , x_line_tbl(i).FULFILLMENT_DATE
13367             , x_line_tbl(i).GLOBAL_ATTRIBUTE1
13368             , x_line_tbl(i).GLOBAL_ATTRIBUTE10
13369             , x_line_tbl(i).GLOBAL_ATTRIBUTE11
13370             , x_line_tbl(i).GLOBAL_ATTRIBUTE12
13371             , x_line_tbl(i).GLOBAL_ATTRIBUTE13
13372             , x_line_tbl(i).GLOBAL_ATTRIBUTE14
13373             , x_line_tbl(i).GLOBAL_ATTRIBUTE15
13374             , x_line_tbl(i).GLOBAL_ATTRIBUTE16
13375             , x_line_tbl(i).GLOBAL_ATTRIBUTE17
13376             , x_line_tbl(i).GLOBAL_ATTRIBUTE18
13377             , x_line_tbl(i).GLOBAL_ATTRIBUTE19
13378             , x_line_tbl(i).GLOBAL_ATTRIBUTE2
13379             , x_line_tbl(i).GLOBAL_ATTRIBUTE20
13380             , x_line_tbl(i).GLOBAL_ATTRIBUTE3
13381             , x_line_tbl(i).GLOBAL_ATTRIBUTE4
13382             , x_line_tbl(i).GLOBAL_ATTRIBUTE5
13383             , x_line_tbl(i).GLOBAL_ATTRIBUTE6
13384             , x_line_tbl(i).GLOBAL_ATTRIBUTE7
13385             , x_line_tbl(i).GLOBAL_ATTRIBUTE8
13386             , x_line_tbl(i).GLOBAL_ATTRIBUTE9
13387             , x_line_tbl(i).GLOBAL_ATTRIBUTE_CATEGORY
13388             , x_line_tbl(i).HEADER_ID
13389             , x_line_tbl(i).INDUSTRY_ATTRIBUTE1
13390             , x_line_tbl(i).INDUSTRY_ATTRIBUTE10
13391             , x_line_tbl(i).INDUSTRY_ATTRIBUTE11
13392             , x_line_tbl(i).INDUSTRY_ATTRIBUTE12
13393             , x_line_tbl(i).INDUSTRY_ATTRIBUTE13
13394             , x_line_tbl(i).INDUSTRY_ATTRIBUTE14
13395             , x_line_tbl(i).INDUSTRY_ATTRIBUTE15
13396             , x_line_tbl(i).INDUSTRY_ATTRIBUTE16
13397             , x_line_tbl(i).INDUSTRY_ATTRIBUTE17
13398             , x_line_tbl(i).INDUSTRY_ATTRIBUTE18
13399             , x_line_tbl(i).INDUSTRY_ATTRIBUTE19
13400             , x_line_tbl(i).INDUSTRY_ATTRIBUTE20
13401             , x_line_tbl(i).INDUSTRY_ATTRIBUTE21
13402             , x_line_tbl(i).INDUSTRY_ATTRIBUTE22
13403             , x_line_tbl(i).INDUSTRY_ATTRIBUTE23
13404             , x_line_tbl(i).INDUSTRY_ATTRIBUTE24
13405             , x_line_tbl(i).INDUSTRY_ATTRIBUTE25
13406             , x_line_tbl(i).INDUSTRY_ATTRIBUTE26
13407             , x_line_tbl(i).INDUSTRY_ATTRIBUTE27
13408             , x_line_tbl(i).INDUSTRY_ATTRIBUTE28
13409             , x_line_tbl(i).INDUSTRY_ATTRIBUTE29
13410             , x_line_tbl(i).INDUSTRY_ATTRIBUTE30
13411             , x_line_tbl(i).INDUSTRY_ATTRIBUTE2
13412             , x_line_tbl(i).INDUSTRY_ATTRIBUTE3
13413             , x_line_tbl(i).INDUSTRY_ATTRIBUTE4
13414             , x_line_tbl(i).INDUSTRY_ATTRIBUTE5
13415             , x_line_tbl(i).INDUSTRY_ATTRIBUTE6
13416             , x_line_tbl(i).INDUSTRY_ATTRIBUTE7
13417             , x_line_tbl(i).INDUSTRY_ATTRIBUTE8
13418             , x_line_tbl(i).INDUSTRY_ATTRIBUTE9
13419             , x_line_tbl(i).INDUSTRY_CONTEXT
13420             , x_line_tbl(i).INTERMED_SHIP_TO_CONTACT_ID
13421             , x_line_tbl(i).INTERMED_SHIP_TO_ORG_ID
13422             , x_line_tbl(i).INVENTORY_ITEM_ID
13423             , x_line_tbl(i).INVOICE_INTERFACE_STATUS_CODE
13424             , x_line_tbl(i).INVOICE_TO_CONTACT_ID
13425             , x_line_tbl(i).INVOICE_TO_ORG_ID
13426             , x_line_tbl(i).INVOICED_QUANTITY
13427             , x_line_tbl(i).INVOICING_RULE_ID
13428             , x_line_tbl(i).ORDERED_ITEM_ID
13429             , x_line_tbl(i).ITEM_IDENTIFIER_TYPE
13430             , x_line_tbl(i).ORDERED_ITEM
13431             , x_line_tbl(i).ITEM_REVISION
13432             , x_line_tbl(i).ITEM_TYPE_CODE
13433             , x_line_tbl(i).LAST_ACK_CODE
13434             , x_line_tbl(i).LAST_ACK_DATE
13435             , x_line_tbl(i).LAST_UPDATED_BY
13436             , x_line_tbl(i).LAST_UPDATE_DATE
13437             , x_line_tbl(i).LAST_UPDATE_LOGIN
13438             , x_line_tbl(i).LATEST_ACCEPTABLE_DATE
13439             , x_line_tbl(i).LINE_CATEGORY_CODE
13440             , x_line_tbl(i).LINE_ID
13441             , x_line_tbl(i).LINE_NUMBER
13442             , x_line_tbl(i).LINE_TYPE_ID
13443             , x_line_tbl(i).LINK_TO_LINE_ID
13444             , x_line_tbl(i).MODEL_GROUP_NUMBER
13445             --  , x_line_tbl(i).MFG_COMPONENT_SEQUENCE_ID
13446             , x_line_tbl(i).MFG_LEAD_TIME
13447             , x_line_tbl(i).OPEN_FLAG
13448             , x_line_tbl(i).OPTION_FLAG
13449             , x_line_tbl(i).OPTION_NUMBER
13450             , x_line_tbl(i).ORDERED_QUANTITY
13451             , x_line_tbl(i).ORDERED_QUANTITY2              --OPM 02/JUN/00
13452             , x_line_tbl(i).ORDER_QUANTITY_UOM
13453             , x_line_tbl(i).ORDERED_QUANTITY_UOM2          --OPM 02/JUN/00
13454             , x_line_tbl(i).ORG_ID
13455             , x_line_tbl(i).ORIG_SYS_DOCUMENT_REF
13456             , x_line_tbl(i).ORIG_SYS_LINE_REF
13457             , x_line_tbl(i).ORIG_SYS_SHIPMENT_REF
13458             , x_line_tbl(i).OVER_SHIP_REASON_CODE
13459             , x_line_tbl(i).OVER_SHIP_RESOLVED_FLAG
13460             , x_line_tbl(i).PAYMENT_TERM_ID
13461             , x_line_tbl(i).PLANNING_PRIORITY
13462             , x_line_tbl(i).PREFERRED_GRADE                --OPM 02/JUN/00
13463             , x_line_tbl(i).PRICE_LIST_ID
13464             , x_line_tbl(i).PRICE_REQUEST_CODE             --PROMOTIONS MAY/01
13465             , x_line_tbl(i).PRICING_ATTRIBUTE1
13466             , x_line_tbl(i).PRICING_ATTRIBUTE10
13467             , x_line_tbl(i).PRICING_ATTRIBUTE2
13468             , x_line_tbl(i).PRICING_ATTRIBUTE3
13469             , x_line_tbl(i).PRICING_ATTRIBUTE4
13470             , x_line_tbl(i).PRICING_ATTRIBUTE5
13471             , x_line_tbl(i).PRICING_ATTRIBUTE6
13472             , x_line_tbl(i).PRICING_ATTRIBUTE7
13473             , x_line_tbl(i).PRICING_ATTRIBUTE8
13474             , x_line_tbl(i).PRICING_ATTRIBUTE9
13475             , x_line_tbl(i).PRICING_CONTEXT
13476             , x_line_tbl(i).PRICING_DATE
13477             , x_line_tbl(i).PRICING_QUANTITY
13478             , x_line_tbl(i).PRICING_QUANTITY_UOM
13479             , x_line_tbl(i).PROGRAM_APPLICATION_ID
13480             , x_line_tbl(i).PROGRAM_ID
13481             , x_line_tbl(i).PROGRAM_UPDATE_DATE
13482             , x_line_tbl(i).PROJECT_ID
13483             , x_line_tbl(i).PROMISE_DATE
13484             , x_line_tbl(i).RE_SOURCE_FLAG
13485             , x_line_tbl(i).REFERENCE_CUSTOMER_TRX_LINE_ID
13486             , x_line_tbl(i).REFERENCE_HEADER_ID
13487             , x_line_tbl(i).REFERENCE_LINE_ID
13488             , x_line_tbl(i).REFERENCE_TYPE
13489             , x_line_tbl(i).REQUEST_DATE
13490             , x_line_tbl(i).REQUEST_ID
13491             , x_line_tbl(i).RETURN_ATTRIBUTE1
13492             , x_line_tbl(i).RETURN_ATTRIBUTE10
13493             , x_line_tbl(i).RETURN_ATTRIBUTE11
13494             , x_line_tbl(i).RETURN_ATTRIBUTE12
13495             , x_line_tbl(i).RETURN_ATTRIBUTE13
13496             , x_line_tbl(i).RETURN_ATTRIBUTE14
13497             , x_line_tbl(i).RETURN_ATTRIBUTE15
13498             , x_line_tbl(i).RETURN_ATTRIBUTE2
13499             , x_line_tbl(i).RETURN_ATTRIBUTE3
13500             , x_line_tbl(i).RETURN_ATTRIBUTE4
13501             , x_line_tbl(i).RETURN_ATTRIBUTE5
13502             , x_line_tbl(i).RETURN_ATTRIBUTE6
13503             , x_line_tbl(i).RETURN_ATTRIBUTE7
13504             , x_line_tbl(i).RETURN_ATTRIBUTE8
13505             , x_line_tbl(i).RETURN_ATTRIBUTE9
13506             , x_line_tbl(i).RETURN_CONTEXT
13507             , x_line_tbl(i).RETURN_REASON_CODE
13508             , x_line_tbl(i).RLA_SCHEDULE_TYPE_CODE
13509             , x_line_tbl(i).SALESREP_ID
13510             , x_line_tbl(i).SCHEDULE_ARRIVAL_DATE
13511             , x_line_tbl(i).SCHEDULE_SHIP_DATE
13512             , x_line_tbl(i).SCHEDULE_STATUS_CODE
13513             , x_line_tbl(i).SHIPMENT_NUMBER
13514             , x_line_tbl(i).SHIPMENT_PRIORITY_CODE
13515             , x_line_tbl(i).SHIPPED_QUANTITY
13516             , x_line_tbl(i).SHIPPED_QUANTITY2 -- OPM B1661023 04/02/01
13517             , x_line_tbl(i).SHIPPING_METHOD_CODE
13518             , x_line_tbl(i).SHIPPING_QUANTITY
13519             , x_line_tbl(i).SHIPPING_QUANTITY2 -- OPM B1661023 04/02/01
13520             , x_line_tbl(i).SHIPPING_QUANTITY_UOM
13521             , x_line_tbl(i).SHIPPING_QUANTITY_UOM2
13522             , x_line_tbl(i).SHIP_FROM_ORG_ID
13523             , x_line_tbl(i).SUBINVENTORY
13524             , x_line_tbl(i).SHIP_SET_ID
13525             , x_line_tbl(i).SHIP_TOLERANCE_ABOVE
13526             , x_line_tbl(i).SHIP_TOLERANCE_BELOW
13527             , x_line_tbl(i).SHIPPABLE_FLAG
13528             , x_line_tbl(i).SHIPPING_INTERFACED_FLAG
13529             , x_line_tbl(i).SHIP_TO_CONTACT_ID
13530             , x_line_tbl(i).SHIP_TO_ORG_ID
13531             , x_line_tbl(i).SHIP_MODEL_COMPLETE_FLAG
13532             , x_line_tbl(i).SOLD_TO_ORG_ID
13533             , x_line_tbl(i).SOLD_FROM_ORG_ID
13534             , x_line_tbl(i).SORT_ORDER
13535             , x_line_tbl(i).SOURCE_DOCUMENT_ID
13536             , x_line_tbl(i).SOURCE_DOCUMENT_LINE_ID
13537             , x_line_tbl(i).SOURCE_DOCUMENT_TYPE_ID
13538             , x_line_tbl(i).SOURCE_TYPE_CODE
13539             , x_line_tbl(i).SPLIT_FROM_LINE_ID
13540             , x_line_tbl(i).LINE_SET_ID
13541             , x_line_tbl(i).SPLIT_BY
13542             , x_line_tbl(i).MODEL_REMNANT_FLAG
13543             , x_line_tbl(i).TASK_ID
13544             , x_line_tbl(i).TAX_CODE
13545             , x_line_tbl(i).TAX_DATE
13546             , x_line_tbl(i).TAX_EXEMPT_FLAG
13547             , x_line_tbl(i).TAX_EXEMPT_NUMBER
13548             , x_line_tbl(i).TAX_EXEMPT_REASON_CODE
13549             , x_line_tbl(i).TAX_POINT_CODE
13550             , x_line_tbl(i).TAX_RATE
13551             , x_line_tbl(i).TAX_VALUE
13552             , x_line_tbl(i).TOP_MODEL_LINE_ID
13553             , x_line_tbl(i).UNIT_LIST_PRICE
13554             , x_line_tbl(i).UNIT_LIST_PRICE_PER_PQTY
13555             , x_line_tbl(i).UNIT_SELLING_PRICE
13556             , x_line_tbl(i).UNIT_SELLING_PRICE_PER_PQTY
13557             , x_line_tbl(i).VISIBLE_DEMAND_FLAG
13558             , x_line_tbl(i).VEH_CUS_ITEM_CUM_KEY_ID
13559             , x_line_tbl(i).SHIPPING_INSTRUCTIONS
13560             , x_line_tbl(i).PACKING_INSTRUCTIONS
13561             , x_line_tbl(i).SERVICE_TXN_REASON_CODE
13562             , x_line_tbl(i).SERVICE_TXN_COMMENTS
13563             , x_line_tbl(i).SERVICE_DURATION
13564             , x_line_tbl(i).SERVICE_PERIOD
13565             , x_line_tbl(i).SERVICE_START_DATE
13566             , x_line_tbl(i).SERVICE_END_DATE
13567             , x_line_tbl(i).SERVICE_COTERMINATE_FLAG
13568             , x_line_tbl(i).UNIT_LIST_PERCENT
13569             , x_line_tbl(i).UNIT_SELLING_PERCENT
13570             , x_line_tbl(i).UNIT_PERCENT_BASE_PRICE
13571             , x_line_tbl(i).SERVICE_NUMBER
13572             , x_line_tbl(i).SERVICE_REFERENCE_TYPE_CODE
13573             , x_line_tbl(i).SERVICE_REFERENCE_LINE_ID
13574             , x_line_tbl(i).SERVICE_REFERENCE_SYSTEM_ID
13575             , x_line_tbl(i).TP_CONTEXT
13576             , x_line_tbl(i).TP_ATTRIBUTE1
13577             , x_line_tbl(i).TP_ATTRIBUTE2
13578             , x_line_tbl(i).TP_ATTRIBUTE3
13579             , x_line_tbl(i).TP_ATTRIBUTE4
13580             , x_line_tbl(i).TP_ATTRIBUTE5
13581             , x_line_tbl(i).TP_ATTRIBUTE6
13582             , x_line_tbl(i).TP_ATTRIBUTE7
13583             , x_line_tbl(i).TP_ATTRIBUTE8
13584             , x_line_tbl(i).TP_ATTRIBUTE9
13585             , x_line_tbl(i).TP_ATTRIBUTE10
13586             , x_line_tbl(i).TP_ATTRIBUTE11
13587             , x_line_tbl(i).TP_ATTRIBUTE12
13588             , x_line_tbl(i).TP_ATTRIBUTE13
13589             , x_line_tbl(i).TP_ATTRIBUTE14
13590             , x_line_tbl(i).TP_ATTRIBUTE15
13591             , x_line_tbl(i).FLOW_STATUS_CODE
13592             , x_line_tbl(i).MARKETING_SOURCE_CODE_ID
13593             , x_line_tbl(i).CALCULATE_PRICE_FLAG
13594             , x_line_tbl(i).COMMITMENT_ID
13595             , x_line_tbl(i).ORDER_SOURCE_ID        -- aksingh
13596             , x_line_tbl(i).UPGRADED_FLAG
13597             , x_line_tbl(i).ORIGINAL_INVENTORY_ITEM_ID
13598             , x_line_tbl(i).ORIGINAL_ITEM_IDENTIFIER_TYPE
13599             , x_line_tbl(i).ORIGINAL_ORDERED_ITEM_ID
13600             , x_line_tbl(i).ORIGINAL_ORDERED_ITEM
13601             , x_line_tbl(i).ITEM_RELATIONSHIP_TYPE
13602             , x_line_tbl(i).ITEM_SUBSTITUTION_TYPE_CODE
13603             , x_line_tbl(i).LATE_DEMAND_PENALTY_FACTOR
13604             , x_line_tbl(i).OVERRIDE_ATP_DATE_CODE
13605             , x_line_tbl(i).FIRM_DEMAND_FLAG
13606             , x_line_tbl(i).EARLIEST_SHIP_DATE
13607             , x_line_tbl(i).USER_ITEM_DESCRIPTION
13608             , x_line_tbl(i).BLANKET_NUMBER
13609             , x_line_tbl(i).BLANKET_LINE_NUMBER
13610             , x_line_tbl(i).BLANKET_VERSION_NUMBER
13611             , x_line_tbl(i).UNIT_COST
13612             , x_line_tbl(i).LOCK_CONTROL
13613             , l_opn    --OPN
13614             , l_cpn    --CPN
13615             , l_svn    --SVN
13616             , x_line_tbl(i).CHANGE_SEQUENCE
13617             , x_line_tbl(i).transaction_phase_code
13618             , x_line_tbl(i).source_document_version_number
13619             , x_line_tbl(i).MINISITE_ID
13620             , x_line_tbl(i).Ib_Owner
13621             , x_line_tbl(i).Ib_installed_at_location
13622             , x_line_tbl(i).Ib_current_location
13623             , x_line_tbl(i).End_customer_ID
13624             , x_line_tbl(i).End_customer_contact_ID
13625             , x_line_tbl(i).End_customer_site_use_ID
13626             , x_line_tbl(i).RETROBILL_REQUEST_ID
13627             , x_line_tbl(i).ORIGINAL_LIST_PRICE  -- Override List Price
13628             , x_line_tbl(i).order_firmed_date
13629             , x_line_tbl(i).actual_fulfillment_date
13630             , x_line_tbl(i).charge_periodicity_code
13631             , x_line_tbl(i).cancelled_quantity2
13632             , x_line_tbl(i).fulfilled_quantity2
13633             , x_line_tbl(i).CONTINGENCY_ID
13634             , x_line_tbl(i).REVREC_EVENT_CODE
13635             , x_line_tbl(i).REVREC_EXPIRATION_DAYS
13636             , x_line_tbl(i).ACCEPTED_QUANTITY
13637             , x_line_tbl(i).REVREC_COMMENTS
13638             , x_line_tbl(i).REVREC_SIGNATURE
13639             , x_line_tbl(i).REVREC_SIGNATURE_DATE
13640             , x_line_tbl(i).ACCEPTED_BY
13641             , x_line_tbl(i).REVREC_REFERENCE_DOCUMENT
13642             , x_line_tbl(i).REVREC_IMPLICIT_FLAG
13643 			-- sol_ord_er #16014165
13644 			, x_line_tbl(i).service_bill_profile_id
13645 			, x_line_tbl(i).service_cov_template_id
13646 			, x_line_tbl(i).service_subs_template_id
13647 			, x_line_tbl(i).service_bill_option_code
13648 			, x_line_tbl(i).subscription_enable_flag
13649 			, x_line_tbl(i).service_first_period_amount
13650 			, x_line_tbl(i).service_first_period_enddate
13651 			-- sol_ord_er #16014165
13652             , x_line_tbl(i).fulfillment_base ;----ER#14763609;
13653 
13654             EXIT WHEN l_line_csr_s%NOTFOUND;
13655 
13656         ELSE
13657           EXIT;
13658         END IF;
13659 
13660         IF NOT OE_FEATURES_PVT.Is_Margin_Avail Then
13661             x_line_tbl(i).unit_cost:= NULL;
13662         END IF;
13663 
13664 
13665 	   -- set values for non-DB fields
13666         x_line_tbl(i).db_flag 		:= FND_API.G_TRUE;
13667         x_line_tbl(i).operation 		:= FND_API.G_MISS_CHAR;
13668         x_line_tbl(i).return_status 	:= FND_API.G_MISS_CHAR;
13669         x_line_tbl(i).schedule_action_code 	:= FND_API.G_MISS_CHAR;
13670         x_line_tbl(i).reserved_quantity 	:= FND_API.G_MISS_NUM;
13671         x_line_tbl(i).reserved_quantity2 	:= FND_API.G_MISS_NUM; -- INVCONV
13672         x_line_tbl(i).change_reason 		:= FND_API.G_MISS_CHAR;
13673         x_line_tbl(i).change_comments 		:= FND_API.G_MISS_CHAR;
13674         x_line_tbl(i).arrival_set 		:= FND_API.G_MISS_CHAR;
13675         x_line_tbl(i).ship_set 			:= FND_API.G_MISS_CHAR;
13676         x_line_tbl(i).fulfillment_set 		:= FND_API.G_MISS_CHAR;
13677         x_line_tbl(i).split_action_code 	:= FND_API.G_MISS_CHAR;
13678 
13679         i := i + 1;
13680 
13681     END LOOP;
13682 
13683     IF l_entity = 2 THEN
13684         CLOSE l_line_csr_h;
13685     ELSIF l_entity = 3 THEN
13686         CLOSE l_line_csr_s;
13687     END IF;
13688 
13689     --  PK sent and no rows found
13690 
13691     IF
13692     (p_line_id IS NOT NULL
13693      AND
13694      p_line_id <> FND_API.G_MISS_NUM)
13695     AND
13696     (x_line_tbl.COUNT = 0)
13697     THEN
13698         RAISE NO_DATA_FOUND;
13699     END IF;
13700 
13701 
13702     --  Return fetched table
13703     IF l_debug_level  > 0 THEN
13704       oe_debug_pub.add('Exiting OE_LINE_UTIL.QUERY_ROWS', 1);
13705     END IF;
13706 
13707 EXCEPTION
13708 
13709     WHEN NO_DATA_FOUND THEN
13710         IF l_debug_level  > 0 THEN
13711            oe_debug_pub.add('Inside no data found ', 1);
13712         END IF;
13713 
13714 	   RAISE NO_DATA_FOUND;
13715 
13716     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
13717 
13718         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
13719         IF l_debug_level  > 0 THEN
13720            oe_debug_pub.add('Inside Unexpected error ', 1);
13721         END IF;
13722 
13723     WHEN OTHERS THEN
13724 
13725         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
13726         THEN
13727             OE_MSG_PUB.Add_Exc_Msg
13728             (   G_PKG_NAME
13729           ,   'Query_Rows'
13730             );
13731         END IF;
13732         IF l_debug_level  > 0 THEN
13733            oe_debug_pub.add('Inside Others Exception ', 1);
13734         END IF;
13735 
13736         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
13737 
13738 END Query_Rows;
13739 
13740 
13741 /*----------------------------------------------------------
13742  Procedure  lock_Row
13743 
13744  lock by ID or value will be decided by, if lock_control is
13745  passed or not. we are doing this so that other products, can
13746  still call lock_order API which does not take only primary
13747  key and takes only entire records. However if they do not
13748  set lokc_control on rec, we will still lock by ID that way
13749  they do not need to query up the records before sending them
13750  in. OM calls can directly fo to util.lock row, thus can send
13751  only line_id.
13752 -----------------------------------------------------------*/
13753 
13754 PROCEDURE Lock_Row
13755 (   x_return_status                 OUT NOCOPY /* file.sql.39 change */ VARCHAR2
13756 ,   p_x_line_rec                    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
13757 ,   p_line_id			           IN  NUMBER
13758 					               := FND_API.G_MISS_NUM
13759 )
13760 IS
13761 l_line_id		      NUMBER;
13762 l_top_model_line_id           NUMBER;
13763 l_dummy                       NUMBER;
13764 l_lock_control                NUMBER;
13765 l_db_lock_control             NUMBER;
13766 CAN_NOT_LOCK_MODEL            EXCEPTION;
13767 /* bug 4344310 */
13768 CURSOR C_Lock (c_top_model_line_id  NUMBER ,
13769 	        c_line_id  NUMBER ) IS
13770 SELECT line_id ,lock_control
13771 FROM oe_order_lines_all
13772 WHERE line_id IN (c_top_model_line_id, c_line_id)
13773 FOR UPDATE NOWAIT ;
13774 --
13775 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
13776 --
13777 BEGIN
13778 
13779     IF l_debug_level  > 0 THEN
13780       oe_debug_pub.add('Entering OE_LINE_UTIL.LOCK_ROW', 1);
13781     END IF;
13782 
13783     SAVEPOINT Lock_Row;
13784 
13785     l_lock_control := NULL;
13786 
13787     -- if l_lock_control is NULL, lock by ID.
13788     -- Retrieve the primary key.
13789 
13790     IF p_line_id <> FND_API.G_MISS_NUM THEN
13791 	l_line_id := p_line_id;
13792         IF (OE_GLOBALS.G_UI_FLAG) THEN  -- 3025978
13793             l_lock_control := p_x_line_rec.lock_control;
13794         END IF;
13795     ELSE
13796 	l_line_id := p_x_line_rec.line_id;
13797         l_lock_control := p_x_line_rec.lock_control;
13798         IF l_debug_level  > 0 THEN
13799            oe_debug_pub.add('in lock_control: '|| l_lock_control, 1);
13800         END IF;
13801     END IF;
13802 
13803     -- this code is for configurations. Whenever someone
13804     -- tries to modify an option line, we try to get a
13805     -- lock on the model line by ID.
13806     -- if we can get a lock on the model,
13807     -- this user can modify the configuration by
13808     -- changing any options. IF we can not get a
13809     -- lock on the model, that means some other person
13810     -- is already working on the configuration.
13811     -- in this case, we will give a message to the user
13812     -- to try his modifications later and that he should
13813     -- query lines to see latest changes.
13814 
13815     --changes for bug 4344310
13816    /* IF p_line_id <> FND_API.G_MISS_NUM THEN
13817 
13818       SELECT top_model_line_id
13819       INTO l_top_model_line_id
13820       FROM OE_ORDER_LINES_ALL  -- Fix for FP bug 3391622
13821       WHERE line_id = l_line_id;
13822     ELSE
13823       l_top_model_line_id := p_x_line_rec.top_model_line_id;
13824     END IF; */
13825       IF p_x_line_rec.top_model_line_id <> FND_API.G_MISS_NUM
13826 		AND
13827        p_x_line_rec.top_model_line_id is not null THEN
13828            l_top_model_line_id := p_x_line_rec.top_model_line_id;
13829 	   IF l_debug_level  > 0 THEN
13830 	     oe_debug_pub.add('get top_model_line_id from the record' );
13831 	   END IF ;
13832     ELSE
13833        SELECT top_model_line_id
13834        INTO l_top_model_line_id
13835        FROM OE_ORDER_LINES_ALL  -- Fix for FP bug 3391622
13836        WHERE line_id = l_line_id;
13837 
13838 	 IF l_debug_level  > 0 THEN
13839 	   oe_debug_pub.add('get top_model_line_id from the query' );
13840 	 END IF ;
13841    END IF;
13842   -- end bug 4344310
13843 
13844     IF l_debug_level  > 0 THEN
13845        oe_debug_pub.add('got top model line id', 1);
13846     END IF;
13847 
13848     BEGIN
13849 
13850       IF l_top_model_line_id IS NOT NULL AND
13851          l_top_model_line_id <> FND_API.G_MISS_NUM AND
13852          l_top_model_line_id <> l_line_id THEN
13853 
13854          IF l_debug_level  > 0 THEN
13855             oe_debug_pub.add('trying to lock model: '|| p_line_id, 1);
13856          END IF;
13857 
13858 	 -- changes for bug 4344310
13859         /* SELECT line_id
13860          INTO   l_dummy
13861          FROM   oe_order_lines_all
13862          WHERE  line_id = l_top_model_line_id
13863          FOR UPDATE NOWAIT; */
13864 
13865 	 FOR I IN c_lock(l_top_model_line_id ,l_line_id ) LOOP
13866            if I.line_id =l_line_id then
13867 		  l_line_id := I.line_id ;
13868                   l_db_lock_control := I.lock_control ;
13869            end if;
13870 	END LOOP ;
13871 
13872      ELSE
13873 	    SELECT line_id,lock_control
13874 	    INTO   l_line_id,l_db_lock_control
13875 	    FROM   oe_order_lines_all
13876 	    WHERE  line_id = l_line_id
13877 	    FOR UPDATE NOWAIT;
13878       END IF;
13879       --end bug 4344310
13880          IF l_debug_level  > 0 THEN
13881             oe_debug_pub.add('lock model successful ', 1);
13882          END IF;
13883 
13884     EXCEPTION
13885 
13886        WHEN APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION THEN
13887          -- some one else is currently working on this model
13888          IF l_debug_level  > 0 THEN
13889             oe_debug_pub.add('in lock model exception');
13890          END IF;
13891 
13892          FND_MESSAGE.Set_Name('ONT', 'OE_LINE_LOCKED');
13893          OE_MSG_PUB.Add;
13894 
13895          RAISE CAN_NOT_LOCK_MODEL;
13896 
13897        WHEN NO_DATA_FOUND THEN
13898            IF l_debug_level  > 0 THEN
13899               oe_debug_pub.add('no_data_found, model lock exception');
13900            END IF;
13901            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
13902 
13903        WHEN OTHERS THEN
13904            IF l_debug_level  > 0 THEN
13905               oe_debug_pub.add('model lock exception, others');
13906               oe_debug_pub.add('options: '|| l_line_id , 1);
13907               oe_debug_pub.add('lock model successful: '|| l_top_model_line_id, 1);
13908            END IF;
13909            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
13910     END;
13911 
13912 
13913     IF l_debug_level  > 0 THEN
13914        oe_debug_pub.add(' ', 1);
13915     END IF;
13916 
13917     --commented out for bug 4344310
13918     /*SELECT line_id,lock_control
13919     INTO   l_line_id,l_db_lock_control
13920     FROM   oe_order_lines_all
13921     WHERE  line_id = l_line_id
13922     FOR UPDATE NOWAIT; */
13923 
13924     IF l_debug_level  > 0 THEN
13925        oe_debug_pub.add('selected for update', 1);
13926        oe_debug_pub.add('queried lock_control: '|| l_db_lock_control, 1);
13927     END IF;
13928 
13929     IF l_lock_control IS NULL
13930     OR (l_lock_control <> l_db_lock_control)
13931     OR (OE_GLOBALS.G_UI_FLAG = TRUE ) THEN  -- 3025978
13932 
13933         oe_line_util.Query_Row
13934 	    (p_line_id  => l_line_id
13935 	    ,x_line_rec => p_x_line_rec
13936         );
13937 
13938    END IF;
13939 
13940     IF l_debug_level  > 0 THEN
13941        oe_debug_pub.add('queried lock_control: '|| p_x_line_rec.lock_control, 1);
13942     END IF;
13943 
13944     -- If lock_control is not passed(is null or missing), then return the locked record.
13945 
13946 
13947     IF l_lock_control is null OR
13948        l_lock_control = FND_API.G_MISS_NUM
13949     THEN
13950 
13951         --  Set return status
13952         x_return_status                := FND_API.G_RET_STS_SUCCESS;
13953         p_x_line_rec.return_status     := FND_API.G_RET_STS_SUCCESS;
13954 
13955         -- return for lock by ID.
13956 	RETURN;
13957 
13958     END IF;
13959 
13960     --  Row locked. If the whole record is passed, then
13961     --  Compare IN attributes to DB attributes.
13962 
13963     IF l_debug_level  > 0 THEN
13964        oe_debug_pub.add('compare ', 1);
13965     END IF;
13966 
13967 -- following constants are used to debug lock_order,
13968 -- please do not use them for any other purpose.
13969 -- set G_LOCK_TEST := 'Y', for debugging.
13970 
13971     OE_GLOBALS.G_LOCK_CONST := 0;
13972     --OE_GLOBALS.G_LOCK_TEST := 'Y';
13973     OE_GLOBALS.G_LOCK_TEST := 'N';
13974 
13975     IF      OE_GLOBALS.Equal(p_x_line_rec.lock_control,
13976                              l_lock_control)
13977    THEN
13978 
13979         --  Row has not changed. Set out parameter.
13980 
13981         IF l_debug_level  > 0 THEN
13982            oe_debug_pub.add('locked row', 1);
13983         END IF;
13984 
13985         --  Set return status
13986 
13987         x_return_status                := FND_API.G_RET_STS_SUCCESS;
13988         p_x_line_rec.return_status       := FND_API.G_RET_STS_SUCCESS;
13989 
13990     ELSE
13991 
13992         --  Row has changed by another user.
13993         IF l_debug_level  > 0 THEN
13994            oe_debug_pub.add('row changed by other user', 1);
13995         END IF;
13996 
13997         x_return_status                := FND_API.G_RET_STS_ERROR;
13998         p_x_line_rec.return_status       := FND_API.G_RET_STS_ERROR;
13999 
14000         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
14001         THEN
14002 
14003             -- Release the lock
14004             ROLLBACK TO Lock_Row;
14005 
14006             fnd_message.set_name('ONT','OE_LOCK_ROW_CHANGED');
14007             OE_MSG_PUB.Add;
14008 
14009         END IF;
14010 
14011     END IF;
14012 
14013     OE_GLOBALS.G_LOCK_TEST := 'N';
14014 
14015     IF l_debug_level  > 0 THEN
14016        oe_debug_pub.add('Exiting OE_LINE_UTIL.LOCK_ROW', 1);
14017        oe_debug_pub.add(' ', 1);
14018        oe_debug_pub.add('lock const: '|| oe_globals.g_lock_const, 1);
14019     END IF;
14020 
14021 EXCEPTION
14022 
14023     WHEN CAN_NOT_LOCK_MODEL THEN
14024         OE_GLOBALS.G_LOCK_TEST := 'N';
14025         IF l_debug_level  > 0 THEN
14026            oe_debug_pub.add('model locking exception', 1);
14027         END IF;
14028         x_return_status                := FND_API.G_RET_STS_ERROR;
14029         p_x_line_rec.return_status       := FND_API.G_RET_STS_ERROR;
14030 
14031 
14032     WHEN NO_DATA_FOUND THEN
14033         OE_GLOBALS.G_LOCK_TEST := 'N';
14034         x_return_status                := FND_API.G_RET_STS_ERROR;
14035         p_x_line_rec.return_status       := FND_API.G_RET_STS_ERROR;
14036 
14037         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
14038         THEN
14039 
14040             fnd_message.set_name('ONT','OE_LOCK_ROW_DELETED');
14041             OE_MSG_PUB.Add;
14042 
14043         END IF;
14044     WHEN APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION THEN
14045         OE_GLOBALS.G_LOCK_TEST := 'N';
14046         x_return_status                := FND_API.G_RET_STS_ERROR;
14047         p_x_line_rec.return_status       := FND_API.G_RET_STS_ERROR;
14048 
14049         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
14050         THEN
14051 
14052             fnd_message.set_name('ONT','OE_LOCK_ROW_ALREADY_LOCKED');
14053             OE_MSG_PUB.Add;
14054 
14055         END IF;
14056     WHEN OTHERS THEN
14057         OE_GLOBALS.G_LOCK_TEST := 'N';
14058         x_return_status                := FND_API.G_RET_STS_UNEXP_ERROR;
14059         p_x_line_rec.return_status       := FND_API.G_RET_STS_UNEXP_ERROR;
14060 
14061         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
14062         THEN
14063             OE_MSG_PUB.Add_Exc_Msg
14064             (   G_PKG_NAME
14065           ,   'Lock_Row'
14066             );
14067         END IF;
14068 
14069 END Lock_Row;
14070 
14071 
14072 /*----------------------------------------------------------
14073  Procedure  lock_Rows
14074 -----------------------------------------------------------*/
14075 
14076 PROCEDURE Lock_Rows
14077 (   p_line_id                       IN  NUMBER :=
14078                                         FND_API.G_MISS_NUM
14079 ,   p_header_id                     IN  NUMBER :=
14080                                         FND_API.G_MISS_NUM
14081 ,   x_line_tbl                      OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
14082 ,   x_return_status                 OUT NOCOPY /* file.sql.39 change */ VARCHAR2
14083  )
14084 IS
14085   CURSOR lock_lines(p_header_id  NUMBER) IS
14086   SELECT line_id
14087   FROM   oe_order_lines_all
14088   WHERE  header_id = p_header_id
14089     FOR  UPDATE NOWAIT;
14090 
14091 l_line_id    NUMBER;
14092 
14093 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
14094 BEGIN
14095 
14096     IF (p_line_id IS NOT NULL AND
14097         p_line_id <> FND_API.G_MISS_NUM) AND
14098        (p_header_id IS NOT NULL AND
14099         p_header_id <> FND_API.G_MISS_NUM)
14100     THEN
14101       IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
14102       THEN
14103         OE_MSG_PUB.Add_Exc_Msg
14104         (   G_PKG_NAME
14105         , 'Lock Rows'
14106         , 'Keys are mutually exclusive: line_id = '||
14107              p_line_id || ', header_id = '|| p_header_id );
14108       END IF;
14109 
14110       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
14111 
14112     END IF;
14113 
14114    IF p_line_id <> FND_API.G_MISS_NUM THEN
14115 
14116      SELECT line_id
14117      INTO   l_line_id
14118      FROM   OE_ORDER_LINES_ALL
14119      WHERE  line_id   = p_line_id
14120      FOR UPDATE NOWAIT;
14121 
14122    END IF;
14123 
14124    -- people should not pass in null header_id unnecessarily,
14125    -- if they already passed in line_id.
14126 
14127    BEGIN
14128 
14129      IF p_header_id <> FND_API.G_MISS_NUM THEN
14130 
14131        SAVEPOINT LOCK_ROWS;
14132 
14133        OPEN lock_lines(p_header_id);
14134        LOOP
14135          FETCH lock_lines INTO l_line_id;
14136          EXIT WHEN lock_lines%NOTFOUND;
14137        END LOOP;
14138        CLOSE lock_lines;
14139 
14140      END IF;
14141 
14142    EXCEPTION
14143      WHEN OTHERS THEN
14144        ROLLBACK TO LOCK_ROWS;
14145 
14146        IF lock_lines%ISOPEN THEN
14147          CLOSE lock_lines;
14148        END IF;
14149 
14150        RAISE;
14151    END;
14152 
14153    -- locked all lines
14154 
14155    oe_line_util.Query_Rows
14156      (p_line_id          => p_line_id
14157      ,p_header_id        => p_header_id
14158      ,x_line_tbl         => x_line_tbl
14159      );
14160 
14161   IF l_debug_level  > 0 THEN
14162    oe_debug_pub.add('Entering OE_LINE_UTIL.QUERY_ROWS', 1);
14163   END IF;
14164 
14165    x_return_status  := FND_API.G_RET_STS_SUCCESS;
14166 
14167 EXCEPTION
14168    WHEN NO_DATA_FOUND THEN
14169 
14170      x_return_status                := FND_API.G_RET_STS_ERROR;
14171 
14172      IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
14173      THEN
14174        fnd_message.set_name('ONT','OE_LOCK_ROW_DELETED');
14175        OE_MSG_PUB.Add;
14176      END IF;
14177 
14178     WHEN APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION THEN
14179 
14180       x_return_status                := FND_API.G_RET_STS_ERROR;
14181       IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
14182       THEN
14183         fnd_message.set_name('ONT','OE_LOCK_ROW_ALREADY_LOCKED');
14184         OE_MSG_PUB.Add;
14185       END IF;
14186 
14187     WHEN OTHERS THEN
14188 
14189         x_return_status                := FND_API.G_RET_STS_UNEXP_ERROR;
14190 
14191       IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
14192       THEN
14193         OE_MSG_PUB.Add_Exc_Msg
14194         (   G_PKG_NAME
14195        ,   'Lock_Row'
14196         );
14197       END IF;
14198 END Lock_Rows;
14199 
14200 
14201 /*----------------------------------------------------------
14202  Function Get_Values
14203 -----------------------------------------------------------*/
14204 
14205 FUNCTION Get_Values
14206 (   p_line_rec                      IN  OE_Order_PUB.Line_Rec_Type
14207 ,   p_old_line_rec                  IN  OE_Order_PUB.Line_Rec_Type :=
14208                                         OE_Order_PUB.G_MISS_LINE_REC
14209 ) RETURN OE_Order_PUB.Line_Val_Rec_Type
14210 IS
14211 l_customer_number         	VARCHAR2(30);
14212 l_line_val_rec                OE_Order_PUB.Line_Val_Rec_Type;
14213 l_organization_id NUMBER :=  OE_SYS_PARAMETERS.VALUE('MASTER_ORGANIZATION_ID');
14214 
14215 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
14216 BEGIN
14217 
14218   if l_debug_level > 0 then
14219     OE_DEBUG_PUB.add('Entering OE_LINE_UTIL.Get_Values');
14220   end if;
14221 
14222     IF (p_line_rec.calculate_price_flag IS NULL OR
14223         p_line_rec.calculate_price_flag <> FND_API.G_MISS_CHAR) AND
14224         NOT OE_GLOBALS.Equal(p_line_rec.calculate_price_flag,
14225         p_old_line_rec.calculate_price_flag)
14226     THEN
14227   l_line_val_rec.calculate_price_descr := OE_Id_To_Value.Calculate_price_Flag (   p_calculate_price_flag          => p_line_rec.calculate_price_flag
14228         );
14229 
14230           if l_debug_level > 0 then
14231 	   oe_debug_pub.add('Geresh ' || l_line_val_rec.calculate_price_descr );
14232           end if;
14233     END IF;
14234 
14235 
14236     IF (p_line_rec.accounting_rule_id IS NULL OR
14237         p_line_rec.accounting_rule_id <> FND_API.G_MISS_NUM) AND
14238         NOT OE_GLOBALS.Equal(p_line_rec.accounting_rule_id,
14239         p_old_line_rec.accounting_rule_id)
14240     THEN
14241         l_line_val_rec.accounting_rule := OE_Id_To_Value.Accounting_Rule
14242         (   p_accounting_rule_id          => p_line_rec.accounting_rule_id
14243         );
14244     END IF;
14245 
14246     IF (p_line_rec.agreement_id IS NULL OR
14247         p_line_rec.agreement_id <> FND_API.G_MISS_NUM) AND
14248         NOT OE_GLOBALS.Equal(p_line_rec.agreement_id,
14249         p_old_line_rec.agreement_id)
14250     THEN
14251         l_line_val_rec.agreement := OE_Id_To_Value.Agreement
14252         (   p_agreement_id                => p_line_rec.agreement_id
14253         );
14254     END IF;
14255 
14256     IF (p_line_rec.deliver_to_contact_id IS NULL OR
14257         p_line_rec.deliver_to_contact_id <> FND_API.G_MISS_NUM) AND
14258         NOT OE_GLOBALS.Equal(p_line_rec.deliver_to_contact_id,
14259         p_old_line_rec.deliver_to_contact_id)
14260     THEN
14261         l_line_val_rec.deliver_to_contact := OE_Id_To_Value.Deliver_To_Contact
14262         (   p_deliver_to_contact_id       => p_line_rec.deliver_to_contact_id
14263         );
14264     END IF;
14265 
14266     IF (p_line_rec.deliver_to_org_id IS NULL OR
14267         p_line_rec.deliver_to_org_id <> FND_API.G_MISS_NUM) AND
14268         NOT OE_GLOBALS.Equal(p_line_rec.deliver_to_org_id,
14269         p_old_line_rec.deliver_to_org_id)
14270     THEN
14271         get_customer_details
14272         (   p_org_id             => p_line_rec.deliver_to_org_id
14273       ,   p_site_use_code      =>'DELIVER_TO'
14274       ,   x_customer_name      => l_line_val_rec.deliver_to_customer_name
14275       ,   x_customer_number    => l_line_val_rec.deliver_to_customer_number
14276       ,   x_customer_id        => l_line_val_rec.deliver_to_customer_id
14277       ,   x_location        => l_line_val_rec.deliver_to_location
14278       ,   x_address1        => l_line_val_rec.deliver_to_address1
14279       ,   x_address2        => l_line_val_rec.deliver_to_address2
14280       ,   x_address3        => l_line_val_rec.deliver_to_address3
14281       ,   x_address4        => l_line_val_rec.deliver_to_address4
14282       ,   x_city        => l_line_val_rec.deliver_to_city
14283       ,   x_state        => l_line_val_rec.deliver_to_state
14284       ,   x_zip        => l_line_val_rec.deliver_to_zip
14285       ,   x_country        => l_line_val_rec.deliver_to_country
14286         );
14287         l_line_val_rec.deliver_to_org :=l_line_val_rec.deliver_to_location;
14288 
14289     END IF;
14290 
14291     IF (p_line_rec.demand_bucket_type_code IS NULL OR
14292         p_line_rec.demand_bucket_type_code <> FND_API.G_MISS_CHAR) AND
14293         NOT OE_GLOBALS.Equal(p_line_rec.demand_bucket_type_code,
14294         p_old_line_rec.demand_bucket_type_code)
14295     THEN
14296         l_line_val_rec.demand_bucket_type := OE_Id_To_Value.Demand_Bucket_Type
14297         (   p_demand_bucket_type_code     => p_line_rec.demand_bucket_type_code
14298         );
14299     END IF;
14300 
14301     IF (p_line_rec.fob_point_code IS NULL OR
14302         p_line_rec.fob_point_code <> FND_API.G_MISS_CHAR) AND
14303         NOT OE_GLOBALS.Equal(p_line_rec.fob_point_code,
14304         p_old_line_rec.fob_point_code)
14305     THEN
14306         l_line_val_rec.fob_point := OE_Id_To_Value.Fob_Point
14307         (   p_fob_point_code              => p_line_rec.fob_point_code
14308         );
14309     END IF;
14310 
14311     IF (p_line_rec.freight_terms_code IS NULL OR
14312         p_line_rec.freight_terms_code <> FND_API.G_MISS_CHAR) AND
14313         NOT OE_GLOBALS.Equal(p_line_rec.freight_terms_code,
14314         p_old_line_rec.freight_terms_code)
14315     THEN
14316         l_line_val_rec.freight_terms := OE_Id_To_Value.Freight_Terms
14317         (   p_freight_terms_code          => p_line_rec.freight_terms_code
14318         );
14319     END IF;
14320 
14321     IF (p_line_rec.freight_carrier_code IS NULL OR
14322         p_line_rec.freight_carrier_code <> FND_API.G_MISS_CHAR) AND
14323         NOT OE_GLOBALS.Equal(p_line_rec.freight_carrier_code,
14324         p_old_line_rec.freight_carrier_code)
14325     THEN
14326         l_line_val_rec.freight_carrier := OE_Id_To_Value.Freight_Carrier
14327         (   p_freight_carrier_code          => p_line_rec.freight_carrier_code
14328 	   ,   p_ship_from_org_id		    => p_line_rec.ship_from_org_id
14329         );
14330     END IF;
14331     IF (p_line_rec.shipping_method_code IS NULL OR
14332         p_line_rec.shipping_method_code <> FND_API.G_MISS_CHAR) AND
14333         NOT OE_GLOBALS.Equal(p_line_rec.shipping_method_code,
14334         p_old_line_rec.shipping_method_code)
14335     THEN
14336         l_line_val_rec.shipping_method := OE_Id_To_Value.ship_method
14337         (   p_ship_method_code      => p_line_rec.shipping_method_code
14338         );
14339     END IF;
14340 
14341     IF (p_line_rec.intermed_ship_to_contact_id IS NULL OR
14342         p_line_rec.intermed_ship_to_contact_id <> FND_API.G_MISS_NUM) AND
14343         NOT OE_GLOBALS.Equal(p_line_rec.intermed_ship_to_contact_id,
14344         p_old_line_rec.intermed_ship_to_contact_id)
14345     THEN
14346        l_line_val_rec.intermed_ship_to_contact := OE_Id_To_Value.Intermed_Ship_To_Contact
14347         (   p_intermed_ship_to_contact_id       => p_line_rec.intermed_ship_to_contact_id
14348         );
14349     END IF;
14350 
14351 /*1621182*/
14352     IF (p_line_rec.intermed_ship_to_org_id IS NULL OR
14353         p_line_rec.intermed_ship_to_org_id <> FND_API.G_MISS_NUM) AND
14354         NOT OE_GLOBALS.Equal(p_line_rec.intermed_ship_to_org_id,
14355         p_old_line_rec.intermed_ship_to_org_id)
14356     THEN
14357         OE_Id_To_Value.Intermed_Ship_To_Org
14358         (   p_intermed_ship_to_org_id      => p_line_rec.intermed_ship_to_org_id
14359       ,   x_intermed_ship_to_address1    => l_line_val_rec.intermed_ship_to_address1
14360       ,   x_intermed_ship_to_address2    => l_line_val_rec.intermed_ship_to_address2
14361       ,   x_intermed_ship_to_address3    => l_line_val_rec.intermed_ship_to_address3
14362       ,   x_intermed_ship_to_address4    => l_line_val_rec.intermed_ship_to_address4
14363       ,   x_intermed_ship_to_location    => l_line_val_rec.intermed_ship_to_location
14364       ,   x_intermed_ship_to_org         => l_line_val_rec.intermed_ship_to_org
14365       ,   x_intermed_ship_to_city        => l_line_val_rec.intermed_ship_to_city
14366       ,   x_intermed_ship_to_state       => l_line_val_rec.intermed_ship_to_state
14367       ,   x_intermed_ship_to_postal_code => l_line_val_rec.intermed_ship_to_zip
14368       ,   x_intermed_ship_to_country     => l_line_val_rec.intermed_ship_to_country
14369         );
14370     END IF;
14371 /*1621182*/
14372 
14373     IF (p_line_rec.inventory_item_id IS NULL OR
14374         p_line_rec.inventory_item_id <> FND_API.G_MISS_NUM) AND
14375         NOT OE_GLOBALS.Equal(p_line_rec.inventory_item_id,
14376         p_old_line_rec.inventory_item_id)
14377     THEN
14378         l_line_val_rec.inventory_item := OE_Id_To_Value.Inventory_Item
14379         (   p_inventory_item_id           => p_line_rec.inventory_item_id
14380         );
14381     END IF;
14382 
14383     IF (p_line_rec.invoice_to_contact_id IS NULL OR
14384         p_line_rec.invoice_to_contact_id <> FND_API.G_MISS_NUM) AND
14385         NOT OE_GLOBALS.Equal(p_line_rec.invoice_to_contact_id,
14386         p_old_line_rec.invoice_to_contact_id)
14387     THEN
14388         l_line_val_rec.invoice_to_contact := OE_Id_To_Value.Invoice_To_Contact
14389         (   p_invoice_to_contact_id       => p_line_rec.invoice_to_contact_id
14390         );
14391     END IF;
14392 
14393     IF (p_line_rec.invoice_to_org_id IS NULL OR
14394         p_line_rec.invoice_to_org_id <> FND_API.G_MISS_NUM) AND
14395         NOT OE_GLOBALS.Equal(p_line_rec.invoice_to_org_id,
14396         p_old_line_rec.invoice_to_org_id)
14397     THEN
14398 
14399         get_customer_details
14400         (   p_org_id             => p_line_rec.invoice_to_org_id
14401       ,   p_site_use_code      =>'BILL_TO'
14402       ,   x_customer_name      => l_line_val_rec.invoice_to_customer_name
14403       ,   x_customer_number    => l_line_val_rec.invoice_to_customer_number
14404       ,   x_customer_id        => l_line_val_rec.invoice_to_customer_id
14405       ,   x_location        => l_line_val_rec.invoice_to_location
14406       ,   x_address1        => l_line_val_rec.invoice_to_address1
14407       ,   x_address2        => l_line_val_rec.invoice_to_address2
14408       ,   x_address3        => l_line_val_rec.invoice_to_address3
14409       ,   x_address4        => l_line_val_rec.invoice_to_address4
14410       ,   x_city        => l_line_val_rec.invoice_to_city
14411       ,   x_state        => l_line_val_rec.invoice_to_state
14412       ,   x_zip        => l_line_val_rec.invoice_to_zip
14413       ,   x_country        => l_line_val_rec.invoice_to_country
14414         );
14415         l_line_val_rec.invoice_to_org :=l_line_val_rec.invoice_to_location;
14416 
14417     END IF;
14418 
14419     IF (p_line_rec.invoicing_rule_id IS NULL OR
14420         p_line_rec.invoicing_rule_id <> FND_API.G_MISS_NUM) AND
14421         NOT OE_GLOBALS.Equal(p_line_rec.invoicing_rule_id,
14422         p_old_line_rec.invoicing_rule_id)
14423     THEN
14424         l_line_val_rec.invoicing_rule := OE_Id_To_Value.Invoicing_Rule
14425         (   p_invoicing_rule_id           => p_line_rec.invoicing_rule_id
14426         );
14427     END IF;
14428 
14429     IF (p_line_rec.item_type_code IS NULL OR
14430         p_line_rec.item_type_code <> FND_API.G_MISS_CHAR) AND
14431         NOT OE_GLOBALS.Equal(p_line_rec.item_type_code,
14432         p_old_line_rec.item_type_code)
14433     THEN
14434         l_line_val_rec.item_type := OE_Id_To_Value.Item_Type
14435         (   p_item_type_code              => p_line_rec.item_type_code
14436         );
14437     END IF;
14438 
14439     IF (p_line_rec.line_type_id IS NULL OR
14440         p_line_rec.line_type_id <> FND_API.G_MISS_NUM) AND
14441         NOT OE_GLOBALS.Equal(p_line_rec.line_type_id,
14442         p_old_line_rec.line_type_id)
14443     THEN
14444         l_line_val_rec.line_type := OE_Id_To_Value.Line_Type
14445         (   p_line_type_id                => p_line_rec.line_type_id
14446         );
14447     END IF;
14448 
14449     IF (p_line_rec.over_ship_reason_code IS NULL OR
14450         p_line_rec.over_ship_reason_code <> FND_API.G_MISS_CHAR) AND
14451         NOT OE_GLOBALS.Equal(p_line_rec.over_ship_reason_code,
14452         p_old_line_rec.over_ship_reason_code)
14453     THEN
14454         l_line_val_rec.over_ship_reason := OE_Id_To_Value.over_ship_reason
14455         (   p_over_ship_reason_code  => p_line_rec.over_ship_reason_code
14456         );
14457     END IF;
14458 
14459     IF (p_line_rec.payment_term_id IS NULL OR
14460         p_line_rec.payment_term_id <> FND_API.G_MISS_NUM) AND
14461         NOT OE_GLOBALS.Equal(p_line_rec.payment_term_id,
14462         p_old_line_rec.payment_term_id)
14463     THEN
14464         l_line_val_rec.payment_term := OE_Id_To_Value.Payment_Term
14465         (   p_payment_term_id             => p_line_rec.payment_term_id
14466         );
14467     END IF;
14468 
14469     IF (p_line_rec.price_list_id IS NULL OR
14470         p_line_rec.price_list_id <> FND_API.G_MISS_NUM) AND
14471         NOT OE_GLOBALS.Equal(p_line_rec.price_list_id,
14472         p_old_line_rec.price_list_id)
14473     THEN
14474         l_line_val_rec.price_list := OE_Id_To_Value.Price_List
14475         (   p_price_list_id               => p_line_rec.price_list_id
14476         );
14477     END IF;
14478 
14479     IF (p_line_rec.project_id IS NULL OR
14480         p_line_rec.project_id <> FND_API.G_MISS_NUM) AND
14481         NOT OE_GLOBALS.Equal(p_line_rec.project_id,
14482         p_old_line_rec.project_id)
14483     THEN
14484         l_line_val_rec.project := OE_Id_To_Value.Project
14485         (   p_project_id                  => p_line_rec.project_id
14486         );
14487     END IF;
14488 
14489 
14490     IF (p_line_rec.source_type_code IS NULL OR
14491         p_line_rec.source_type_code <> FND_API.G_MISS_CHAR) AND
14492         NOT OE_GLOBALS.Equal(p_line_rec.source_type_code,
14493         p_old_line_rec.source_type_code)
14494     THEN
14495 
14496         l_line_val_rec.source_type := OE_Id_To_Value.source_type
14497         (   p_source_type_code  => p_line_rec.source_type_code
14498         );
14499     END IF;
14500 
14501 
14502     IF (p_line_rec.return_reason_code IS NULL OR
14503         p_line_rec.return_reason_code <> FND_API.G_MISS_CHAR) AND
14504         NOT OE_GLOBALS.Equal(p_line_rec.return_reason_code,
14505         p_old_line_rec.return_reason_code)
14506     THEN
14507 
14508         l_line_val_rec.return_reason := OE_Id_To_Value.return_reason
14509         (   p_return_reason_code  => p_line_rec.return_reason_code
14510         );
14511     END IF;
14512 
14513     IF (p_line_rec.reference_line_id IS NULL OR
14514         p_line_rec.reference_line_id <> FND_API.G_MISS_NUM) AND
14515         NOT OE_GLOBALS.Equal(p_line_rec.reference_line_id,
14516         p_old_line_rec.reference_line_id)
14517     THEN
14518         OE_Id_To_Value.reference_line
14519         (   p_reference_line_id   => p_line_rec.reference_line_id
14520        ,  x_ref_order_number    => l_line_val_rec.ref_order_number
14521        ,  x_ref_line_number     => l_line_val_rec.ref_line_number
14522        ,  x_ref_shipment_number => l_line_val_rec.ref_shipment_number
14523        ,  x_ref_option_number   => l_line_val_rec.ref_option_number
14524        ,  x_ref_component_number => l_line_val_rec.ref_component_number
14525         );
14526 
14527     END IF;
14528 
14529     IF (p_line_rec.reference_customer_trx_line_id IS NULL OR
14530         p_line_rec.reference_customer_trx_line_id <> FND_API.G_MISS_NUM) AND
14531         NOT OE_GLOBALS.Equal(p_line_rec.reference_customer_trx_line_id,
14532         p_old_line_rec.reference_customer_trx_line_id)
14533     THEN
14534         OE_Id_To_Value.Reference_Cust_Trx_Line
14535         (   p_reference_cust_trx_line_id => p_line_rec.reference_customer_trx_line_id
14536        ,  x_ref_invoice_number        => l_line_val_rec.ref_invoice_number
14537        ,  x_ref_invoice_line_number   => l_line_val_rec.ref_invoice_line_number
14538         );
14539     END IF;
14540 
14541     IF (p_line_rec.credit_invoice_line_id IS NULL OR
14542         p_line_rec.credit_invoice_line_id <> FND_API.G_MISS_NUM) AND
14543         NOT OE_GLOBALS.Equal(p_line_rec.credit_invoice_line_id,
14544         p_old_line_rec.credit_invoice_line_id)
14545     THEN
14546         l_line_val_rec.credit_invoice_number
14547             := OE_Id_To_Value.credit_invoice_line
14548         (   p_credit_invoice_line_id   => p_line_rec.credit_invoice_line_id
14549         );
14550     END IF;
14551 
14552     IF (p_line_rec.rla_schedule_type_code IS NULL OR
14553         p_line_rec.rla_schedule_type_code <> FND_API.G_MISS_CHAR) AND
14554         NOT OE_GLOBALS.Equal(p_line_rec.rla_schedule_type_code,
14555         p_old_line_rec.rla_schedule_type_code)
14556     THEN
14557         l_line_val_rec.rla_schedule_type := OE_Id_To_Value.Rla_Schedule_Type
14558         (   p_rla_schedule_type_code      => p_line_rec.rla_schedule_type_code
14559         );
14560     END IF;
14561 
14562     IF (p_line_rec.salesrep_id IS NULL OR
14563         p_line_rec.salesrep_id <> FND_API.G_MISS_NUM) AND
14564         NOT OE_GLOBALS.Equal(p_line_rec.salesrep_id,
14565         p_old_line_rec.salesrep_id)
14566     THEN
14567         l_line_val_rec.salesrep := OE_Id_To_Value.salesrep
14568         (   p_salesrep_id          => p_line_rec.salesrep_id
14569         );
14570     END IF;
14571 
14572     IF (p_line_rec.commitment_id IS NULL OR
14573         p_line_rec.commitment_id <> FND_API.G_MISS_NUM) AND
14574         NOT OE_GLOBALS.Equal(p_line_rec.commitment_id,
14575         p_old_line_rec.commitment_id)
14576     THEN
14577         l_line_val_rec.commitment := OE_Id_To_Value.Commitment
14578         (   p_commitment_id        => p_line_rec.commitment_id
14579         );
14580     END IF;
14581 
14582 
14583     IF (p_line_rec.shipment_priority_code IS NULL OR
14584         p_line_rec.shipment_priority_code <> FND_API.G_MISS_CHAR) AND
14585         NOT OE_GLOBALS.Equal(p_line_rec.shipment_priority_code,
14586         p_old_line_rec.shipment_priority_code)
14587     THEN
14588         l_line_val_rec.shipment_priority := OE_Id_To_Value.Shipment_Priority
14589         (   p_shipment_priority_code      => p_line_rec.shipment_priority_code
14590         );
14591     END IF;
14592 
14593     IF (p_line_rec.demand_class_code IS NULL OR
14594         p_line_rec.demand_class_code <> FND_API.G_MISS_CHAR) AND
14595         NOT OE_GLOBALS.Equal(p_line_rec.demand_class_code,
14596         p_old_line_rec.demand_class_code)
14597     THEN
14598         l_line_val_rec.demand_class := OE_Id_To_Value.Demand_Class
14599         (   p_demand_class_code      => p_line_rec.demand_class_code
14600         );
14601     END IF;
14602 
14603     IF (p_line_rec.ship_from_org_id IS NULL OR
14604         p_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM) AND
14605         NOT OE_GLOBALS.Equal(p_line_rec.ship_from_org_id,
14606         p_old_line_rec.ship_from_org_id)
14607     THEN
14608         OE_Id_To_Value.Ship_From_Org
14609         (   p_ship_from_org_id            => p_line_rec.ship_from_org_id
14610       ,   x_ship_from_address1          => l_line_val_rec.ship_from_address1
14611       ,   x_ship_from_address2          => l_line_val_rec.ship_from_address2
14612       ,   x_ship_from_address3          => l_line_val_rec.ship_from_address3
14613       ,   x_ship_from_address4          => l_line_val_rec.ship_from_address4
14614       ,   x_ship_from_location          => l_line_val_rec.ship_from_location
14615       ,   x_ship_from_org               => l_line_val_rec.ship_from_org
14616         );
14617     END IF;
14618 
14619     IF (p_line_rec.ship_to_contact_id IS NULL OR
14620         p_line_rec.ship_to_contact_id <> FND_API.G_MISS_NUM) AND
14621         NOT OE_GLOBALS.Equal(p_line_rec.ship_to_contact_id,
14622         p_old_line_rec.ship_to_contact_id)
14623     THEN
14624         l_line_val_rec.ship_to_contact := OE_Id_To_Value.Ship_To_Contact
14625         (   p_ship_to_contact_id          => p_line_rec.ship_to_contact_id
14626         );
14627     END IF;
14628 
14629     IF (p_line_rec.ship_to_org_id IS NULL OR
14630         p_line_rec.ship_to_org_id <> FND_API.G_MISS_NUM) AND
14631         NOT OE_GLOBALS.Equal(p_line_rec.ship_to_org_id,
14632         p_old_line_rec.ship_to_org_id)
14633     THEN
14634         get_customer_details
14635         (   p_org_id             => p_line_rec.ship_to_org_id
14636       ,   p_site_use_code      =>'SHIP_TO'
14637       ,   x_customer_name      => l_line_val_rec.ship_to_customer_name
14638       ,   x_customer_number    => l_line_val_rec.ship_to_customer_number
14639       ,   x_customer_id        => l_line_val_rec.ship_to_customer_id
14640       ,   x_location        => l_line_val_rec.ship_to_location
14641       ,   x_address1        => l_line_val_rec.ship_to_address1
14642       ,   x_address2        => l_line_val_rec.ship_to_address2
14643       ,   x_address3        => l_line_val_rec.ship_to_address3
14644       ,   x_address4        => l_line_val_rec.ship_to_address4
14645       ,   x_city        => l_line_val_rec.ship_to_city
14646       ,   x_state        => l_line_val_rec.ship_to_state
14647       ,   x_zip        => l_line_val_rec.ship_to_zip
14648       ,   x_country        => l_line_val_rec.ship_to_country
14649         );
14650         l_line_val_rec.ship_to_org :=l_line_val_rec.ship_to_location;
14651 
14652     END IF;
14653 
14654 
14655     IF (p_line_rec.sold_to_org_id IS NULL OR
14656         p_line_rec.sold_to_org_id <> FND_API.G_MISS_NUM) AND
14657         NOT OE_GLOBALS.Equal(p_line_rec.sold_to_org_id,
14658         p_old_line_rec.sold_to_org_id)
14659     THEN
14660         OE_Id_To_Value.Sold_To_Org
14661         (   p_sold_to_org_id              => p_line_rec.sold_to_org_id
14662       ,   x_org                         => l_line_val_rec.sold_to_org
14663       ,   x_customer_number             => l_customer_number
14664         );
14665     END IF;
14666 
14667     IF (p_line_rec.task_id IS NULL OR
14668         p_line_rec.task_id <> FND_API.G_MISS_NUM) AND
14669         NOT OE_GLOBALS.Equal(p_line_rec.task_id,
14670         p_old_line_rec.task_id)
14671     THEN
14672         l_line_val_rec.task := OE_Id_To_Value.Task
14673         (   p_task_id                     => p_line_rec.task_id
14674         );
14675     END IF;
14676 
14677     IF (p_line_rec.tax_exempt_flag IS NULL OR
14678         p_line_rec.tax_exempt_flag <> FND_API.G_MISS_CHAR) AND
14679         NOT OE_GLOBALS.Equal(p_line_rec.tax_exempt_flag,
14680         p_old_line_rec.tax_exempt_flag)
14681     THEN
14682         l_line_val_rec.tax_exempt := OE_Id_To_Value.Tax_Exempt
14683         (   p_tax_exempt_flag             => p_line_rec.tax_exempt_flag
14684         );
14685     END IF;
14686 
14687     IF (p_line_rec.tax_exempt_reason_code IS NULL OR
14688         p_line_rec.tax_exempt_reason_code <> FND_API.G_MISS_CHAR) AND
14689         NOT OE_GLOBALS.Equal(p_line_rec.tax_exempt_reason_code,
14690         p_old_line_rec.tax_exempt_reason_code)
14691     THEN
14692         l_line_val_rec.tax_exempt_reason := OE_Id_To_Value.Tax_Exempt_Reason
14693         (   p_tax_exempt_reason_code      => p_line_rec.tax_exempt_reason_code
14694         );
14695     END IF;
14696 
14697     IF (p_line_rec.tax_point_code IS NULL OR
14698         p_line_rec.tax_point_code <> FND_API.G_MISS_CHAR) AND
14699         NOT OE_GLOBALS.Equal(p_line_rec.tax_point_code,
14700         p_old_line_rec.tax_point_code)
14701     THEN
14702         l_line_val_rec.tax_point := OE_Id_To_Value.Tax_Point
14703         (   p_tax_point_code              => p_line_rec.tax_point_code
14704         );
14705     END IF;
14706 
14707     /*IF  (p_line_rec.tax_code IS NULL OR
14708         p_line_rec.tax_code <> FND_API.G_MISS_CHAR) AND
14709         NOT OE_GLOBALS.Equal(p_line_rec.tax_code,
14710         p_old_line_rec.tax_code)
14711     THEN
14712         l_line_val_rec.tax_group := OE_Id_To_Value.Tax_Group
14713         (   p_tax_code             => p_line_rec.tax_code
14714         );
14715     END IF;*/
14716 
14717     IF (p_line_rec.veh_cus_item_cum_key_id IS NULL OR
14718         p_line_rec.veh_cus_item_cum_key_id <> FND_API.G_MISS_NUM) AND
14719         NOT OE_GLOBALS.Equal(p_line_rec.veh_cus_item_cum_key_id,
14720         p_old_line_rec.veh_cus_item_cum_key_id)
14721     THEN
14722       l_line_val_rec.veh_cus_item_cum_key := OE_Id_To_Value.veh_cus_item_cum_key
14723         (   p_veh_cus_item_cum_key_id => p_line_rec.veh_cus_item_cum_key_id
14724         );
14725     END IF;
14726 
14727 
14728    IF (p_line_rec.Original_inventory_item_id IS NOT NULL  OR
14729         p_line_rec.original_inventory_item_id <> FND_API.G_MISS_NUM)
14730    THEN
14731     OE_ID_TO_VALUE.Ordered_Item
14732     (p_Item_Identifier_type    => p_line_rec.original_item_identifier_Type
14733     ,p_inventory_item_id       => p_line_rec.original_Inventory_Item_Id
14734     ,p_organization_id         => l_organization_id
14735     ,p_ordered_item_id         => p_line_rec.original_ordered_item_id
14736     ,p_sold_to_org_id          => p_line_rec.sold_to_org_id
14737     ,p_ordered_item            => p_line_rec.original_ordered_item
14738     ,x_ordered_item            => l_line_val_rec.original_ordered_item
14739     ,x_inventory_item          => l_line_val_rec.original_inventory_item);
14740    END IF;
14741 
14742    IF (p_line_rec.original_item_identifier_type IS NOT NULL  OR
14743         p_line_rec.original_item_identifier_type <> FND_API.G_MISS_CHAR)
14744    THEN
14745     OE_ID_TO_VALUE.item_identifier
14746          (p_Item_Identifier_type   => p_line_rec.Original_item_identifier_Type
14747          ,x_Item_Identifier        => l_line_val_rec.Original_item_identifier_type);
14748    END IF;
14749 
14750    IF (p_line_rec.item_relationship_type IS NOT NULL  OR
14751         p_line_rec.item_relationship_type <> FND_API.G_MISS_NUM)
14752    THEN
14753     OE_ID_TO_VALUE.item_relationship_type
14754          (p_Item_relationship_type     => p_line_rec.item_relationship_type
14755          ,x_Item_relationship_type_dsp => l_line_val_rec.item_relationship_type_dsp);
14756    END IF;
14757 
14758    IF (p_line_rec.end_customer_id IS NOT NULL  AND
14759         p_line_rec.end_customer_id <> FND_API.G_MISS_NUM)
14760    THEN
14761       OE_ID_TO_VALUE.End_Customer(
14762 				  p_end_customer_id     => p_line_rec.end_customer_id
14763 				  ,x_end_customer_name   => l_line_val_rec.end_customer_name
14764 				  ,x_end_customer_number => l_line_val_rec.end_customer_number);
14765    END IF;
14766 
14767    IF (p_line_rec.end_customer_contact_id IS NOT NULL   AND
14768         p_line_rec.end_customer_contact_id <> FND_API.G_MISS_NUM)
14769    THEN
14770     l_line_val_rec.end_customer_contact :=
14771 	 OE_ID_TO_VALUE.end_customer_Contact(p_end_customer_contact_id => p_line_rec.end_customer_contact_id);
14772    END IF;
14773 
14774    IF (p_line_rec.end_customer_site_use_id IS NOT NULL   AND
14775         p_line_rec.end_customer_site_use_id <> FND_API.G_MISS_NUM)
14776    THEN
14777     OE_ID_TO_VALUE.end_customer_site_use(
14778 					 p_end_customer_site_use_id => p_line_rec.end_customer_site_use_id
14779 					 ,x_end_customer_address1    => l_line_val_rec.end_customer_site_address1
14780 					 ,x_end_customer_address2    => l_line_val_rec.end_customer_site_address2
14781 					 ,x_end_customer_address3    => l_line_val_rec.end_customer_site_address3
14782 					 ,x_end_customer_address4    => l_line_val_rec.end_customer_site_address4
14783 					 ,x_end_customer_location    => l_line_val_rec.end_customer_site_location
14784 					 ,x_end_customer_city        => l_line_val_rec.end_customer_site_city
14785 					 ,x_end_customer_state       => l_line_val_rec.end_customer_site_state
14786 					 ,x_end_customer_postal_code => l_line_val_rec.end_customer_site_postal_code
14787 					 ,x_end_customer_country     => l_line_val_rec.end_customer_site_country    );
14788    END IF;
14789  -- Start BSA pricing
14790    IF (p_line_rec.blanket_number IS NOT NULL  OR
14791         p_line_rec.blanket_number <> FND_API.G_MISS_NUM)
14792    THEN
14793                 oe_blanket_util_misc.get_blanketAgrName
14794                               (p_blanket_number   => p_line_rec.blanket_number,
14795                                x_blanket_agr_name => l_line_val_rec.blanket_agreement_name);
14796    END if;
14797  -- END BSA pricing
14798 --Macd
14799    IF (p_line_rec.ib_owner IS NOT NULL   AND
14800         p_line_rec.ib_owner <> FND_API.G_MISS_CHAR)
14801    THEN
14802     l_line_val_rec.ib_owner_dsp :=
14803 	 OE_ID_TO_VALUE.ib_owner(p_ib_owner => p_line_rec.ib_owner);
14804    END IF;
14805 
14806    IF (p_line_rec.ib_current_location IS NOT NULL   AND
14807         p_line_rec.ib_current_location <> FND_API.G_MISS_CHAR)
14808    THEN
14809     l_line_val_rec.ib_current_location_dsp :=
14810 	 OE_ID_TO_VALUE.ib_current_location(p_ib_current_location => p_line_rec.ib_current_location);
14811    END IF;
14812 
14813    IF (p_line_rec.ib_installed_at_location IS NOT NULL   AND
14814         p_line_rec.ib_installed_at_location <> FND_API.G_MISS_CHAR)
14815    THEN
14816     l_line_val_rec.ib_installed_at_location_dsp :=
14817 	 OE_ID_TO_VALUE.ib_installed_at_location(p_ib_installed_at_location => p_line_rec.ib_installed_at_location);
14818    END IF;
14819 --Macd
14820  /*3605052*/
14821    IF (p_line_rec.service_period IS NOT NULL   AND
14822         p_line_rec.service_period <> FND_API.G_MISS_CHAR)
14823    THEN
14824    -- sol_ord_er #16014165
14825 	 If p_line_rec.subscription_enable_flag='Y' then
14826 		l_line_val_rec.service_period_dsp :=
14827 		OE_ID_TO_VALUE.subscription_period(p_service_period => p_line_rec.service_period);
14828      else
14829    -- sol_ord_er #16014165 end
14830 		l_line_val_rec.service_period_dsp :=
14831 		OE_ID_TO_VALUE.service_period(p_service_period => p_line_rec.service_period
14832 				       ,p_inventory_item_id => p_line_rec.inventory_item_id);
14833       End If;--sol_ord_er #16014165
14834    END IF;
14835    /*3605052*/
14836 
14837 
14838 -- 5701246 begin
14839    IF (p_line_rec.service_reference_type_code IS NOT NULL   AND
14840         p_line_rec.service_reference_type_code <> FND_API.G_MISS_CHAR)
14841    THEN
14842     l_line_val_rec.service_reference_type :=
14843 	OE_ID_TO_VALUE.service_reference_type(p_service_reference_type_code => p_line_rec.service_reference_type_code);
14844    END IF;
14845 -- 5701246 end
14846 
14847 --sol_ord_er #16014165 (used in Defaulting)
14848   IF (p_line_rec.service_bill_profile_id IS NOT NULL   AND
14849         p_line_rec.service_bill_profile_id <> FND_API.G_MISS_NUM)
14850    THEN
14851     l_line_val_rec.service_bill_profile :=
14852 	OE_ID_TO_VALUE.Billing_Profile(p_service_bill_profile_id => p_line_rec.service_bill_profile_id);
14853    END IF;
14854 
14855   IF (p_line_rec.service_bill_option_code IS NOT NULL   AND
14856         p_line_rec.service_bill_option_code <> FND_API.G_MISS_CHAR)
14857    THEN
14858     l_line_val_rec.service_bill_option :=
14859 	OE_ID_TO_VALUE.Billing_Option(p_service_bill_option_code => p_line_rec.service_bill_option_code);
14860    END IF;
14861 
14862    IF (p_line_rec.service_subs_template_id IS NOT NULL   AND
14863         p_line_rec.service_subs_template_id <> FND_API.G_MISS_NUM)
14864    THEN
14865     l_line_val_rec.service_subs_template :=
14866 	OE_ID_TO_VALUE.Subscription_Template(p_service_subs_template_id => p_line_rec.service_subs_template_id);
14867    END IF;
14868 
14869    IF (p_line_rec.service_cov_template_id IS NOT NULL   AND
14870         p_line_rec.service_cov_template_id <> FND_API.G_MISS_NUM)
14871    THEN
14872     l_line_val_rec.service_cov_template :=
14873 	OE_ID_TO_VALUE.Coverage_Template(p_service_cov_template_id => p_line_rec.service_cov_template_id);
14874    END IF;
14875 --sol_ord_er #16014165
14876   --Customer Acceptance
14877     IF (p_line_rec.contingency_id IS NOT NULL AND
14878         p_line_rec.contingency_id <> FND_API.G_MISS_NUM)
14879     THEN
14880        OE_ID_TO_VALUE.Get_Contingency_Attributes(
14881 				p_contingency_id  => p_line_rec.contingency_id
14882 			        , x_contingency_name =>  l_line_val_rec.contingency_name
14883                                 , x_contingency_description  =>  l_line_val_rec.contingency_description
14884                                 , x_expiration_event_attribute  =>  l_line_val_rec.expiration_event_attribute);
14885 
14886     END IF;
14887     IF (p_line_rec.revrec_event_code IS NOT NULL  AND
14888         p_line_rec.revrec_event_code <> FND_API.G_MISS_CHAR)
14889     THEN
14890      l_line_val_rec.Revrec_Event:=  OE_ID_TO_VALUE.Revrec_Event(
14891 				p_Revrec_Event_code  => p_line_rec.Revrec_Event_code);
14892 
14893     END IF;
14894 
14895     IF (p_line_rec.accepted_by IS NOT NULL  AND
14896         p_line_rec.accepted_by <> FND_API.G_MISS_NUM)
14897     THEN
14898      l_line_val_rec.accepted_by_dsp:=  OE_ID_TO_VALUE.accepted_by(
14899 				p_accepted_by  => p_line_rec.accepted_by);
14900 
14901     END IF;
14902  --
14903 
14904   if l_debug_level > 0 then
14905     oe_debug_pub.add('original item identifier type='||p_line_rec.original_item_identifier_type);
14906     oe_debug_pub.add('original ordered item ' ||p_line_rec.original_ordered_item);
14907     oe_debug_pub.add('original inventory item id ' ||p_line_rec.original_inventory_item_id);
14908     oe_debug_pub.add('original ordered_item id '||p_line_rec.original_ordered_item_id);
14909     oe_debug_pub.add('item relationship type '||p_line_rec.item_relationship_type);
14910     oe_debug_pub.add('original inventory item'||l_line_val_rec.original_inventory_item);
14911     oe_debug_pub.add('original ordered item'||l_line_val_rec.original_ordered_item);
14912     oe_debug_pub.add('original original item ident type'||l_line_val_rec.original_item_identifier_type);
14913     oe_debug_pub.add('item relationship type dsp='||l_line_val_rec.item_relationship_type_dsp);
14914     oe_debug_pub.add('the service_reference_type_code: '||p_line_rec.service_reference_type_code);
14915     oe_debug_pub.add('the service_reference_type: '||l_line_val_rec.service_reference_type);
14916   end if;
14917     RETURN l_line_val_rec;
14918 
14919 END Get_Values;
14920 
14921 
14922 /*----------------------------------------------------------
14923   Function Get_Ids
14924 -----------------------------------------------------------*/
14925 
14926 PROCEDURE Get_Ids
14927 (   p_x_line_rec                    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
14928 ,   p_line_val_rec                  IN  OE_Order_PUB.Line_Val_Rec_Type
14929 )
14930 IS
14931 l_sold_to_org_id           NUMBER;
14932 l_deliver_to_org_id        NUMBER;
14933 l_invoice_to_org_id        NUMBER;
14934 l_ship_to_org_id           NUMBER;
14935 BEGIN
14936 
14937     p_x_line_rec.return_status := FND_API.G_RET_STS_SUCCESS;
14938 
14939     IF  p_line_val_rec.accounting_rule <> FND_API.G_MISS_CHAR
14940     THEN
14941 
14942         IF p_x_line_rec.accounting_rule_id <> FND_API.G_MISS_NUM THEN
14943 
14944             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14945             THEN
14946 
14947                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14948                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','accounting_rule');
14949                 OE_MSG_PUB.Add;
14950 
14951             END IF;
14952 
14953         ELSE
14954 
14955             p_x_line_rec.accounting_rule_id := OE_Value_To_Id.accounting_rule
14956             (   p_accounting_rule             => p_line_val_rec.accounting_rule
14957             );
14958 
14959             IF p_x_line_rec.accounting_rule_id = FND_API.G_MISS_NUM THEN
14960                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14961             END IF;
14962 
14963         END IF;
14964 
14965     END IF;
14966 
14967     IF  p_line_val_rec.agreement <> FND_API.G_MISS_CHAR
14968     THEN
14969 
14970         IF p_x_line_rec.agreement_id <> FND_API.G_MISS_NUM THEN
14971 
14972             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14973             THEN
14974 
14975                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14976                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','agreement');
14977                 OE_MSG_PUB.Add;
14978 
14979             END IF;
14980 
14981         ELSE
14982 
14983             p_x_line_rec.agreement_id := OE_Value_To_Id.agreement
14984             (   p_agreement                   => p_line_val_rec.agreement
14985             );
14986 
14987             IF p_x_line_rec.agreement_id = FND_API.G_MISS_NUM THEN
14988                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14989             END IF;
14990 
14991         END IF;
14992 
14993     END IF;
14994 
14995     IF  p_line_val_rec.demand_bucket_type <> FND_API.G_MISS_CHAR
14996     THEN
14997 
14998         IF p_x_line_rec.demand_bucket_type_code <> FND_API.G_MISS_CHAR THEN
14999 
15000             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15001             THEN
15002 
15003                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15004                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','demand_bucket_type');
15005                 OE_MSG_PUB.Add;
15006 
15007             END IF;
15008 
15009         ELSE
15010 
15011             p_x_line_rec.demand_bucket_type_code := OE_Value_To_Id.demand_bucket_type
15012             (   p_demand_bucket_type          => p_line_val_rec.demand_bucket_type
15013             );
15014 
15015             IF p_x_line_rec.demand_bucket_type_code = FND_API.G_MISS_CHAR THEN
15016                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15017             END IF;
15018 
15019         END IF;
15020 
15021     END IF;
15022 
15023     IF  p_line_val_rec.fob_point <> FND_API.G_MISS_CHAR
15024     THEN
15025 
15026         IF p_x_line_rec.fob_point_code <> FND_API.G_MISS_CHAR THEN
15027 
15028             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15029             THEN
15030 
15031                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15032                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','fob_point');
15033                 OE_MSG_PUB.Add;
15034 
15035             END IF;
15036 
15037         ELSE
15038 
15039             p_x_line_rec.fob_point_code := OE_Value_To_Id.fob_point
15040             (   p_fob_point                   => p_line_val_rec.fob_point
15041             );
15042 
15043             IF p_x_line_rec.fob_point_code = FND_API.G_MISS_CHAR THEN
15044                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15045             END IF;
15046 
15047         END IF;
15048 
15049     END IF;
15050 
15051     IF  p_line_val_rec.freight_terms <> FND_API.G_MISS_CHAR
15052     THEN
15053 
15054         IF p_x_line_rec.freight_terms_code <> FND_API.G_MISS_CHAR THEN
15055 
15056             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15057             THEN
15058 
15059                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15060                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','freight_terms');
15061                 OE_MSG_PUB.Add;
15062 
15063             END IF;
15064 
15065         ELSE
15066 
15067             p_x_line_rec.freight_terms_code := OE_Value_To_Id.freight_terms
15068             (   p_freight_terms               => p_line_val_rec.freight_terms
15069             );
15070 
15071             IF p_x_line_rec.freight_terms_code = FND_API.G_MISS_CHAR THEN
15072                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15073             END IF;
15074 
15075         END IF;
15076 
15077     END IF;
15078 
15079     IF  p_line_val_rec.shipping_method <> FND_API.G_MISS_CHAR
15080     THEN
15081 
15082         IF p_x_line_rec.shipping_method_code <> FND_API.G_MISS_CHAR THEN
15083 
15084             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15085             THEN
15086 
15087                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15088                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','shipping_method');
15089                 OE_MSG_PUB.Add;
15090 
15091             END IF;
15092 
15093         ELSE
15094 
15095             p_x_line_rec.shipping_method_code := OE_Value_To_Id.ship_method
15096             (   p_ship_method           => p_line_val_rec.shipping_method
15097             );
15098 
15099             IF p_x_line_rec.shipping_method_code = FND_API.G_MISS_CHAR THEN
15100 		  oe_debug_pub.add('Ship Method Conversion Error');
15101                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15102             END IF;
15103 
15104         END IF;
15105 
15106     END IF;
15107 
15108 
15109     IF  p_line_val_rec.freight_carrier <> FND_API.G_MISS_CHAR
15110     THEN
15111 
15112         IF p_x_line_rec.freight_carrier_code <> FND_API.G_MISS_CHAR THEN
15113 
15114             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15115             THEN
15116 
15117                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15118                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','freight_carrier');
15119                 OE_MSG_PUB.Add;
15120 
15121             END IF;
15122 
15123         ELSE
15124 
15125             p_x_line_rec.freight_carrier_code := OE_Value_To_Id.freight_carrier
15126             (   p_freight_carrier               => p_line_val_rec.freight_carrier
15127 		  ,   p_ship_from_org_id			   => p_x_line_rec.ship_from_org_id
15128             );
15129 
15130             IF p_x_line_rec.freight_carrier_code = FND_API.G_MISS_CHAR THEN
15131                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15132             END IF;
15133 
15134         END IF;
15135 
15136     END IF;
15137 
15138     IF  p_line_val_rec.intermed_ship_to_contact <> FND_API.G_MISS_CHAR
15139     THEN
15140 
15141         IF p_x_line_rec.intermed_ship_to_contact_id <> FND_API.G_MISS_NUM THEN
15142 
15143             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15144             THEN
15145 
15146                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15147                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','intermed_ship_to_contact');
15148                 OE_MSG_PUB.Add;
15149 
15150             END IF;
15151 
15152         ELSE
15153 
15154             p_x_line_rec.intermed_ship_to_contact_id := OE_Value_To_Id.intermed_ship_to_contact
15155             (   p_intermed_ship_to_contact    => p_line_val_rec.intermed_ship_to_contact
15156 		  ,   p_intermed_ship_to_org_id     => p_x_line_rec.intermed_ship_to_org_id
15157             );
15158 
15159             IF p_x_line_rec.intermed_ship_to_contact_id = FND_API.G_MISS_NUM THEN
15160                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15161             END IF;
15162 
15163         END IF;
15164 
15165     END IF;
15166 
15167     IF  p_line_val_rec.intermed_ship_to_address1 <> FND_API.G_MISS_CHAR
15168     OR  p_line_val_rec.intermed_ship_to_address2 <> FND_API.G_MISS_CHAR
15169     OR  p_line_val_rec.intermed_ship_to_address3 <> FND_API.G_MISS_CHAR
15170     OR  p_line_val_rec.intermed_ship_to_address4 <> FND_API.G_MISS_CHAR
15171     OR  p_line_val_rec.intermed_ship_to_location <> FND_API.G_MISS_CHAR
15172     OR  p_line_val_rec.intermed_ship_to_org <> FND_API.G_MISS_CHAR
15173     THEN
15174 
15175         IF p_x_line_rec.intermed_ship_to_org_id <> FND_API.G_MISS_NUM THEN
15176 
15177             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15178             THEN
15179 
15180                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15181                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','intermed_ship_to_org');
15182                 OE_MSG_PUB.Add;
15183 
15184             END IF;
15185 
15186         ELSE
15187 
15188 /*1621182*/
15189             p_x_line_rec.intermed_ship_to_org_id := OE_Value_To_Id.intermed_ship_to_org
15190             (   p_intermed_ship_to_address1     => p_line_val_rec.intermed_ship_to_address1
15191           ,   p_intermed_ship_to_address2     => p_line_val_rec.intermed_ship_to_address2
15192           ,   p_intermed_ship_to_address3     => p_line_val_rec.intermed_ship_to_address3
15193           ,   p_intermed_ship_to_address4     => p_line_val_rec.intermed_ship_to_address4
15194           ,   p_intermed_ship_to_location     => p_line_val_rec.intermed_ship_to_location
15195           ,   p_intermed_ship_to_org          => p_line_val_rec.intermed_ship_to_org
15196           ,   p_intermed_ship_to_city         => p_line_val_rec.intermed_ship_to_city
15197           ,   p_intermed_ship_to_state        => p_line_val_rec.intermed_ship_to_state
15198           ,   p_intermed_ship_to_postal_code  => p_line_val_rec.intermed_ship_to_zip
15199           ,   p_intermed_ship_to_country      => p_line_val_rec.intermed_ship_to_country
15200 		  ,   p_sold_to_org_id          => p_x_line_rec.sold_to_org_id
15201             );
15202 /*1621182*/
15203             IF p_x_line_rec.intermed_ship_to_org_id = FND_API.G_MISS_NUM THEN
15204                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15205             END IF;
15206 
15207         END IF;
15208 
15209     END IF;
15210 
15211 
15212     IF  p_line_val_rec.inventory_item <> FND_API.G_MISS_CHAR
15213     THEN
15214 
15215         IF p_x_line_rec.inventory_item_id <> FND_API.G_MISS_NUM THEN
15216 
15217             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15218             THEN
15219 
15220                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15221                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','inventory_item');
15222                 OE_MSG_PUB.Add;
15223 
15224             END IF;
15225 
15226         ELSE
15227 
15228             p_x_line_rec.inventory_item_id := OE_Value_To_Id.inventory_item
15229             (   p_inventory_item              => p_line_val_rec.inventory_item
15230             );
15231 
15232             IF p_x_line_rec.inventory_item_id = FND_API.G_MISS_NUM THEN
15233                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15234             END IF;
15235 
15236         END IF;
15237 
15238     END IF;
15239 
15240     IF  p_line_val_rec.invoicing_rule <> FND_API.G_MISS_CHAR
15241     THEN
15242 
15243         IF p_x_line_rec.invoicing_rule_id <> FND_API.G_MISS_NUM THEN
15244 
15245             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15246             THEN
15247 
15248                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15249                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','invoicing_rule');
15250                 OE_MSG_PUB.Add;
15251 
15252             END IF;
15253 
15254         ELSE
15255 
15256             p_x_line_rec.invoicing_rule_id := OE_Value_To_Id.invoicing_rule
15257             (   p_invoicing_rule              => p_line_val_rec.invoicing_rule
15258             );
15259 
15260             IF p_x_line_rec.invoicing_rule_id = FND_API.G_MISS_NUM THEN
15261                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15262             END IF;
15263 
15264         END IF;
15265 
15266     END IF;
15267 
15268     IF  p_line_val_rec.item_type <> FND_API.G_MISS_CHAR
15269     THEN
15270 
15271         IF p_x_line_rec.item_type_code <> FND_API.G_MISS_CHAR THEN
15272 
15273             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15274             THEN
15275 
15276                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15277                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','item_type');
15278                 OE_MSG_PUB.Add;
15279 
15280             END IF;
15281 
15282         ELSE
15283 
15284             p_x_line_rec.item_type_code := OE_Value_To_Id.item_type
15285             (   p_item_type                   => p_line_val_rec.item_type
15286             );
15287 
15288             IF p_x_line_rec.item_type_code = FND_API.G_MISS_CHAR THEN
15289                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15290             END IF;
15291 
15292         END IF;
15293 
15294     END IF;
15295 
15296     IF  p_line_val_rec.line_type <> FND_API.G_MISS_CHAR
15297     THEN
15298 
15299         IF p_x_line_rec.line_type_id <> FND_API.G_MISS_NUM THEN
15300 
15301             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15302             THEN
15303 
15304                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15305                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','line_type');
15306                 OE_MSG_PUB.Add;
15307 
15308             END IF;
15309 
15310         ELSE
15311 
15312             p_x_line_rec.line_type_id := OE_Value_To_Id.line_type
15313             (   p_line_type                   => p_line_val_rec.line_type
15314             );
15315 
15316             IF p_x_line_rec.line_type_id = FND_API.G_MISS_NUM THEN
15317                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15318             END IF;
15319 
15320         END IF;
15321 
15322     END IF;
15323 
15324     IF  p_line_val_rec.over_ship_reason <> FND_API.G_MISS_CHAR
15325     THEN
15326 
15327         IF p_x_line_rec.over_ship_reason_code <> FND_API.G_MISS_CHAR THEN
15328 
15329             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15330             THEN
15331 
15332                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15333                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Over_shipo_reason');
15334                 OE_MSG_PUB.Add;
15335 
15336             END IF;
15337 
15338         ELSE
15339 
15340             p_x_line_rec.over_ship_reason_code := OE_Value_To_Id.over_ship_reason
15341             (   p_over_ship_reason  => p_line_val_rec.over_ship_reason
15342             );
15343 
15344             IF p_x_line_rec.over_ship_reason_code = FND_API.G_MISS_CHAR THEN
15345                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15346             END IF;
15347 
15348         END IF;
15349 
15350     END IF;
15351 
15352     IF  p_line_val_rec.payment_term <> FND_API.G_MISS_CHAR
15353     THEN
15354 
15355         IF p_x_line_rec.payment_term_id <> FND_API.G_MISS_NUM THEN
15356 
15357             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15358             THEN
15359 
15360                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15361                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','payment_term');
15362                 OE_MSG_PUB.Add;
15363 
15364             END IF;
15365 
15366         ELSE
15367 
15368             p_x_line_rec.payment_term_id := OE_Value_To_Id.payment_term
15369             (   p_payment_term                => p_line_val_rec.payment_term
15370             );
15371 
15372             IF p_x_line_rec.payment_term_id = FND_API.G_MISS_NUM THEN
15373                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15374             END IF;
15375 
15376         END IF;
15377 
15378     END IF;
15379 
15380     IF  p_line_val_rec.price_list <> FND_API.G_MISS_CHAR
15381     THEN
15382 
15383         IF p_x_line_rec.price_list_id <> FND_API.G_MISS_NUM THEN
15384 
15385             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15386             THEN
15387 
15388                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15389                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','price_list');
15390                 OE_MSG_PUB.Add;
15391 
15392             END IF;
15393 
15394         ELSE
15395 
15396             p_x_line_rec.price_list_id := OE_Value_To_Id.price_list
15397             (   p_price_list                  => p_line_val_rec.price_list
15398             );
15399 
15400             IF p_x_line_rec.price_list_id = FND_API.G_MISS_NUM THEN
15401                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15402             END IF;
15403 
15404         END IF;
15405 
15406     END IF;
15407 
15408     IF  p_line_val_rec.project <> FND_API.G_MISS_CHAR
15409     THEN
15410 
15411         IF p_x_line_rec.project_id <> FND_API.G_MISS_NUM THEN
15412 
15413             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15414             THEN
15415 
15416                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15417                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','project');
15418                 OE_MSG_PUB.Add;
15419 
15420             END IF;
15421 
15422         ELSE
15423 
15424             p_x_line_rec.project_id := OE_Value_To_Id.project
15425             (   p_project                     => p_line_val_rec.project
15426             );
15427 
15428             IF p_x_line_rec.project_id = FND_API.G_MISS_NUM THEN
15429                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15430             END IF;
15431 
15432         END IF;
15433 
15434     END IF;
15435 
15436     IF  p_line_val_rec.return_reason <> FND_API.G_MISS_CHAR
15437     THEN
15438 
15439         IF p_x_line_rec.return_reason_code <> FND_API.G_MISS_CHAR THEN
15440 
15441             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15442             THEN
15443 
15444                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15445                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','return_reason');
15446                 OE_MSG_PUB.Add;
15447 
15448             END IF;
15449 
15450         ELSE
15451 
15452             p_x_line_rec.return_reason_code := OE_Value_To_Id.return_reason
15453             (   p_return_reason  => p_line_val_rec.return_reason
15454             );
15455 
15456             IF p_x_line_rec.return_reason_code = FND_API.G_MISS_CHAR THEN
15457                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15458             END IF;
15459 
15460         END IF;
15461 
15462     END IF;
15463 
15464 
15465 
15466     IF  p_line_val_rec.rla_schedule_type <> FND_API.G_MISS_CHAR
15467     THEN
15468 
15469         IF p_x_line_rec.rla_schedule_type_code <> FND_API.G_MISS_CHAR THEN
15470 
15471             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15472             THEN
15473 
15474                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15475                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','rla_schedule_type');
15476                 OE_MSG_PUB.Add;
15477 
15478             END IF;
15479 
15480         ELSE
15481 
15482             p_x_line_rec.rla_schedule_type_code := OE_Value_To_Id.rla_schedule_type
15483             (   p_rla_schedule_type           => p_line_val_rec.rla_schedule_type
15484             );
15485 
15486             IF p_x_line_rec.rla_schedule_type_code = FND_API.G_MISS_CHAR THEN
15487                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15488             END IF;
15489 
15490         END IF;
15491 
15492     END IF;
15493 
15494     IF  p_line_val_rec.salesrep <> FND_API.G_MISS_CHAR
15495     THEN
15496 
15497         IF p_x_line_rec.salesrep_id <> FND_API.G_MISS_NUM THEN
15498 
15499             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15500             THEN
15501 
15502                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15503                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','salesrep');
15504                 OE_MSG_PUB.Add;
15505 
15506             END IF;
15507 
15508         ELSE
15509 
15510             p_x_line_rec.salesrep_id := OE_Value_To_Id.salesrep
15511             (   p_salesrep  => p_line_val_rec.salesrep
15512             );
15513 
15514             IF p_x_line_rec.salesrep_id = FND_API.G_MISS_NUM THEN
15515                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15516             END IF;
15517 
15518         END IF;
15519 
15520     END IF;
15521 
15522     IF  p_line_val_rec.shipment_priority <> FND_API.G_MISS_CHAR
15523     THEN
15524 
15525         IF p_x_line_rec.shipment_priority_code <> FND_API.G_MISS_CHAR THEN
15526 
15527             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15528             THEN
15529 
15530                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15531                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','shipment_priority');
15532                 OE_MSG_PUB.Add;
15533 
15534             END IF;
15535 
15536         ELSE
15537 
15538             p_x_line_rec.shipment_priority_code := OE_Value_To_Id.shipment_priority
15539             (   p_shipment_priority           => p_line_val_rec.shipment_priority
15540             );
15541 
15542             IF p_x_line_rec.shipment_priority_code = FND_API.G_MISS_CHAR THEN
15543                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15544             END IF;
15545 
15546         END IF;
15547 
15548     END IF;
15549 
15550     IF  p_line_val_rec.ship_from_address1 <> FND_API.G_MISS_CHAR
15551     OR p_line_val_rec.ship_from_address2 <> FND_API.G_MISS_CHAR
15552     OR p_line_val_rec.ship_from_address3 <> FND_API.G_MISS_CHAR
15553     OR p_line_val_rec.ship_from_address4 <> FND_API.G_MISS_CHAR
15554     OR p_line_val_rec.ship_from_location <> FND_API.G_MISS_CHAR
15555     OR p_line_val_rec.ship_from_org <> FND_API.G_MISS_CHAR
15556     THEN
15557 
15558         IF p_x_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM THEN
15559 
15560             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15561             THEN
15562 
15563                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15564                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','ship_from_org');
15565                 OE_MSG_PUB.Add;
15566 
15567             END IF;
15568 
15569         ELSE
15570 
15571             p_x_line_rec.ship_from_org_id := OE_Value_To_Id.ship_from_org
15572             (   p_ship_from_address1          => p_line_val_rec.ship_from_address1
15573           ,   p_ship_from_address2          => p_line_val_rec.ship_from_address2
15574           ,   p_ship_from_address3          => p_line_val_rec.ship_from_address3
15575           ,   p_ship_from_address4          => p_line_val_rec.ship_from_address4
15576           ,   p_ship_from_location          => p_line_val_rec.ship_from_location
15577           ,   p_ship_from_org               => p_line_val_rec.ship_from_org
15578             );
15579 
15580             IF p_x_line_rec.ship_from_org_id = FND_API.G_MISS_NUM THEN
15581                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15582             END IF;
15583 
15584         END IF;
15585 
15586     END IF;
15587 
15588     IF  p_line_val_rec.task <> FND_API.G_MISS_CHAR
15589     THEN
15590 
15591         IF p_x_line_rec.task_id <> FND_API.G_MISS_NUM THEN
15592 
15593             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15594             THEN
15595 
15596                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15597                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','task');
15598                 OE_MSG_PUB.Add;
15599 
15600             END IF;
15601 
15602         ELSE
15603 
15604             p_x_line_rec.task_id := OE_Value_To_Id.task
15605             (   p_task                        => p_line_val_rec.task
15606             );
15607 
15608             IF p_x_line_rec.task_id = FND_API.G_MISS_NUM THEN
15609                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15610             END IF;
15611 
15612         END IF;
15613 
15614     END IF;
15615 
15616     IF  p_line_val_rec.tax_exempt <> FND_API.G_MISS_CHAR
15617     THEN
15618 
15619         IF p_x_line_rec.tax_exempt_flag <> FND_API.G_MISS_CHAR THEN
15620 
15621             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15622             THEN
15623 
15624                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15625                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','tax_exempt');
15626                 OE_MSG_PUB.Add;
15627 
15628             END IF;
15629 
15630         ELSE
15631 
15632             p_x_line_rec.tax_exempt_flag := OE_Value_To_Id.tax_exempt
15633             (   p_tax_exempt                  => p_line_val_rec.tax_exempt
15634             );
15635 
15636             IF p_x_line_rec.tax_exempt_flag = FND_API.G_MISS_CHAR THEN
15637                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15638             END IF;
15639 
15640         END IF;
15641 
15642     END IF;
15643 
15644     IF  p_line_val_rec.tax_exempt_reason <> FND_API.G_MISS_CHAR
15645     THEN
15646 
15647         IF p_x_line_rec.tax_exempt_reason_code <> FND_API.G_MISS_CHAR THEN
15648 
15649             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15650             THEN
15651 
15652                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15653                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','tax_exempt_reason');
15654                 OE_MSG_PUB.Add;
15655 
15656             END IF;
15657 
15658         ELSE
15659 
15660             p_x_line_rec.tax_exempt_reason_code := OE_Value_To_Id.tax_exempt_reason
15661             (   p_tax_exempt_reason           => p_line_val_rec.tax_exempt_reason
15662             );
15663 
15664             IF p_x_line_rec.tax_exempt_reason_code = FND_API.G_MISS_CHAR THEN
15665                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15666             END IF;
15667 
15668         END IF;
15669 
15670     END IF;
15671 
15672     IF  p_line_val_rec.tax_point <> FND_API.G_MISS_CHAR
15673     THEN
15674 
15675         IF p_x_line_rec.tax_point_code <> FND_API.G_MISS_CHAR THEN
15676 
15677             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15678             THEN
15679 
15680                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15681                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','tax_point');
15682                 OE_MSG_PUB.Add;
15683 
15684             END IF;
15685 
15686         ELSE
15687 
15688             p_x_line_rec.tax_point_code := OE_Value_To_Id.tax_point
15689             (   p_tax_point                   => p_line_val_rec.tax_point
15690             );
15691 
15692             IF p_x_line_rec.tax_point_code = FND_API.G_MISS_CHAR THEN
15693                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15694             END IF;
15695 
15696         END IF;
15697 
15698     END IF;
15699 
15700 
15701     IF  p_line_val_rec.veh_cus_item_cum_key <> FND_API.G_MISS_CHAR
15702     THEN
15703 
15704         IF p_x_line_rec.veh_cus_item_cum_key_id <> FND_API.G_MISS_NUM THEN
15705 
15706             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15707             THEN
15708 
15709                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15710                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','veh_cus_item_cum_key');
15711                 OE_MSG_PUB.Add;
15712 
15713             END IF;
15714 
15715         ELSE
15716 
15717        p_x_line_rec.veh_cus_item_cum_key_id := OE_Value_To_Id.veh_cus_item_cum_key
15718             (   p_veh_cus_item_cum_key  => p_line_val_rec.veh_cus_item_cum_key
15719             );
15720 
15721             IF p_x_line_rec.veh_cus_item_cum_key_id = FND_API.G_MISS_NUM THEN
15722                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15723             END IF;
15724 
15725         END IF;
15726 
15727     END IF;
15728 
15729     ----------------------------------------------------------------------
15730     -- Retreiving ids for invoice_to_customer
15731     ----------------------------------------------------------------------
15732 
15733     oe_debug_pub.add('line Invoice_to_cust_id='||p_x_line_rec.invoice_to_customer_id);
15734     IF  p_line_val_rec.invoice_to_customer_name_oi <> FND_API.G_MISS_CHAR
15735     OR  p_line_val_rec.invoice_to_customer_number_oi <> FND_API.G_MISS_CHAR
15736     THEN
15737 
15738         IF p_x_line_rec.invoice_to_customer_id <> FND_API.G_MISS_NUM THEN
15739 
15740 
15741             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15742             THEN
15743 
15744                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15745                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','invoice_to_customer line');
15746                 OE_MSG_PUB.Add;
15747 
15748             END IF;
15749 
15750         ELSE
15751            IF p_x_line_rec.invoice_to_org_id = FND_API.G_MISS_NUM THEN -- bug 4231603
15752             p_x_line_rec.invoice_to_customer_id:=OE_Value_To_Id.site_customer
15753             ( p_site_customer       => p_line_val_rec.invoice_to_customer_name_oi
15754              ,p_site_customer_number=> p_line_val_rec.invoice_to_customer_number_oi
15755              ,p_type =>'INVOICE_TO'
15756             );
15757 
15758             IF p_x_line_rec.invoice_to_customer_id = FND_API.G_MISS_NUM THEN
15759                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15760             END IF;
15761           END IF;
15762         END IF;
15763 
15764     END IF;
15765 
15766     ----------------------------------------------------------------------
15767     -- Retreiving ids for ship_to_customer
15768     ----------------------------------------------------------------------
15769 
15770     IF  p_line_val_rec.ship_to_customer_name_oi <> FND_API.G_MISS_CHAR
15771     OR  p_line_val_rec.ship_to_customer_number_oi <> FND_API.G_MISS_CHAR
15772     THEN
15773 
15774         IF p_x_line_rec.ship_to_customer_id <> FND_API.G_MISS_NUM THEN
15775 
15776 
15777             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15778             THEN
15779 
15780                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15781                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','ship_to_customer line');
15782                 OE_MSG_PUB.Add;
15783 
15784             END IF;
15785 
15786         ELSE
15787            IF p_x_line_rec.ship_to_org_id = FND_API.G_MISS_NUM THEN --4231603
15788             p_x_line_rec.ship_to_customer_id:=OE_Value_To_Id.site_customer
15789             ( p_site_customer       => p_line_val_rec.ship_to_customer_name_oi
15790              ,p_site_customer_number=> p_line_val_rec.ship_to_customer_number_oi
15791              ,p_type =>'SHIP_TO'
15792             );
15793 
15794             IF p_x_line_rec.ship_to_customer_id = FND_API.G_MISS_NUM THEN
15795                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15796             END IF;
15797           END IF;
15798         END IF;
15799 
15800     END IF;
15801 
15802 
15803     ----------------------------------------------------------------------
15804     -- Retreiving ids for deliver_to_customer
15805     ----------------------------------------------------------------------
15806 
15807     IF  p_line_val_rec.deliver_to_customer_name_oi <> FND_API.G_MISS_CHAR
15808     OR  p_line_val_rec.deliver_to_customer_number_oi <> FND_API.G_MISS_CHAR
15809     THEN
15810 
15811         IF p_x_line_rec.deliver_to_customer_id <> FND_API.G_MISS_NUM THEN
15812 
15813 
15814             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15815             THEN
15816 
15817                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15818                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','deliver_to_customer line');
15819                 OE_MSG_PUB.Add;
15820 
15821             END IF;
15822 
15823         ELSE
15824            IF p_x_line_rec.deliver_to_org_id = FND_API.G_MISS_NUM THEN  -- 4231603
15825             p_x_line_rec.deliver_to_customer_id:=OE_Value_To_Id.site_customer
15826             ( p_site_customer       => p_line_val_rec.ship_to_customer_name_oi
15827              ,p_site_customer_number=> p_line_val_rec.ship_to_customer_number_oi
15828              ,p_type =>'DELIVER_TO'
15829             );
15830 
15831             IF p_x_line_rec.deliver_to_customer_id = FND_API.G_MISS_NUM THEN
15832                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15833             END IF;
15834           END IF;
15835         END IF;
15836 
15837     END IF;
15838 
15839 
15840     -------------------------------------------------------------------
15841     -- For customer related fields, IDs should be retrieved in the
15842     -- following order.
15843     -------------------------------------------------------------------
15844 
15845     -- Retrieve the sold_to_org_id if not passed on the line record. This
15846     -- will be needed by the value_to_id functions for related fields.
15847     -- For e.g. oe_value_to_id.ship_to_org_id requires sold_to_org_id
15848 
15849     IF  p_x_line_rec.sold_to_org_id = FND_API.G_MISS_NUM
15850     THEN
15851 
15852       IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
15853 
15854          -- bug 2411783
15855          -- for a newly created order, since the line is not posted,
15856          -- in Order import, there will be no Header record.
15857          --OE_Order_Cache.Load_Order_Header(p_x_line_rec.header_id);
15858          --l_sold_to_org_id := OE_Order_Cache.g_header_rec.sold_to_org_id;
15859          null;
15860 
15861       ELSIF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
15862 
15863 	   SELECT SOLD_TO_ORG_ID
15864 	   INTO l_sold_to_org_id
15865 	   FROM OE_ORDER_LINES
15866 	   WHERE LINE_ID = p_x_line_rec.line_id;
15867 
15868       END IF;
15869 
15870     ELSE
15871 
15872 	  l_sold_to_org_id := p_x_line_rec.sold_to_org_id;
15873 
15874     END IF;
15875 
15876     IF  p_line_val_rec.deliver_to_address1 <> FND_API.G_MISS_CHAR
15877     OR p_line_val_rec.deliver_to_address2 <> FND_API.G_MISS_CHAR
15878     OR p_line_val_rec.deliver_to_address3 <> FND_API.G_MISS_CHAR
15879     OR p_line_val_rec.deliver_to_address4 <> FND_API.G_MISS_CHAR
15880     OR p_line_val_rec.deliver_to_location <> FND_API.G_MISS_CHAR
15881     OR p_line_val_rec.deliver_to_org <> FND_API.G_MISS_CHAR
15882     THEN
15883 
15884         IF p_x_line_rec.deliver_to_org_id <> FND_API.G_MISS_NUM THEN
15885 
15886 
15887             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15888             THEN
15889 
15890                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15891                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','deliver_to_org');
15892                 OE_MSG_PUB.Add;
15893 
15894             END IF;
15895 
15896         ELSE
15897 
15898 /*1621182*/
15899             p_x_line_rec.deliver_to_org_id := OE_Value_To_Id.deliver_to_org
15900             (   p_deliver_to_address1         => p_line_val_rec.deliver_to_address1
15901           ,   p_deliver_to_address2         => p_line_val_rec.deliver_to_address2
15902           ,   p_deliver_to_address3         => p_line_val_rec.deliver_to_address3
15903           ,   p_deliver_to_address4         => p_line_val_rec.deliver_to_address4
15904           ,   p_deliver_to_location         => p_line_val_rec.deliver_to_location
15905           ,   p_deliver_to_org              => p_line_val_rec.deliver_to_org
15906           ,   p_deliver_to_city             => p_line_val_rec.deliver_to_city
15907           ,   p_deliver_to_state            => p_line_val_rec.deliver_to_state
15908           ,   p_deliver_to_postal_code      => p_line_val_rec.deliver_to_zip
15909           ,   p_deliver_to_country          => p_line_val_rec.deliver_to_country
15910 		  ,   p_sold_to_org_id        => l_sold_to_org_id
15911           , p_deliver_to_customer_id => p_x_line_rec.deliver_to_customer_id
15912             );
15913 /*1621182*/
15914             IF p_x_line_rec.deliver_to_org_id = FND_API.G_MISS_NUM THEN
15915                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15916             END IF;
15917 
15918         END IF;
15919 
15920     END IF;
15921 
15922     IF  p_line_val_rec.invoice_to_address1 <> FND_API.G_MISS_CHAR
15923     OR p_line_val_rec.invoice_to_address2 <> FND_API.G_MISS_CHAR
15924     OR p_line_val_rec.invoice_to_address3 <> FND_API.G_MISS_CHAR
15925     OR p_line_val_rec.invoice_to_address4 <> FND_API.G_MISS_CHAR
15926     OR p_line_val_rec.invoice_to_location <> FND_API.G_MISS_CHAR
15927     OR p_line_val_rec.invoice_to_org <> FND_API.G_MISS_CHAR
15928     THEN
15929 
15930         IF p_x_line_rec.invoice_to_org_id <> FND_API.G_MISS_NUM THEN
15931 
15932 
15933             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15934             THEN
15935 
15936                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15937                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','invoice_to_org');
15938                 OE_MSG_PUB.Add;
15939 
15940             END IF;
15941 
15942         ELSE
15943 
15944 /*1621182*/
15945             p_x_line_rec.invoice_to_org_id := OE_Value_To_Id.invoice_to_org
15946             (   p_invoice_to_address1         => p_line_val_rec.invoice_to_address1
15947           ,   p_invoice_to_address2         => p_line_val_rec.invoice_to_address2
15948           ,   p_invoice_to_address3         => p_line_val_rec.invoice_to_address3
15949           ,   p_invoice_to_address4         => p_line_val_rec.invoice_to_address4
15950           ,   p_invoice_to_location         => p_line_val_rec.invoice_to_location
15951           ,   p_invoice_to_org              => p_line_val_rec.invoice_to_org
15952           ,   p_invoice_to_city             => p_line_val_rec.invoice_to_city
15953           ,   p_invoice_to_state            => p_line_val_rec.invoice_to_state
15954           ,   p_invoice_to_postal_code      => p_line_val_rec.invoice_to_zip
15955           ,   p_invoice_to_country          => p_line_val_rec.invoice_to_country
15956 		  ,   p_sold_to_org_id        => l_sold_to_org_id
15957           , p_invoice_to_customer_id => p_x_line_rec.invoice_to_customer_id
15958             );
15959 /*1621182*/
15960             IF p_x_line_rec.invoice_to_org_id = FND_API.G_MISS_NUM THEN
15961                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
15962             END IF;
15963 
15964         END IF;
15965 
15966     END IF;
15967 
15968     IF  p_line_val_rec.ship_to_address1 <> FND_API.G_MISS_CHAR
15969     OR p_line_val_rec.ship_to_address2 <> FND_API.G_MISS_CHAR
15970     OR p_line_val_rec.ship_to_address3 <> FND_API.G_MISS_CHAR
15971     OR p_line_val_rec.ship_to_address4 <> FND_API.G_MISS_CHAR
15972     OR p_line_val_rec.ship_to_location <> FND_API.G_MISS_CHAR
15973     OR p_line_val_rec.ship_to_org <> FND_API.G_MISS_CHAR
15974     THEN
15975 
15976         IF p_x_line_rec.ship_to_org_id <> FND_API.G_MISS_NUM THEN
15977 
15978 
15979             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
15980             THEN
15981 
15982                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
15983                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','ship_to_org');
15984                 OE_MSG_PUB.Add;
15985 
15986             END IF;
15987 
15988         ELSE
15989 
15990 /*1621182*/
15991             p_x_line_rec.ship_to_org_id := OE_Value_To_Id.ship_to_org
15992             (   p_ship_to_address1            => p_line_val_rec.ship_to_address1
15993           ,   p_ship_to_address2            => p_line_val_rec.ship_to_address2
15994           ,   p_ship_to_address3            => p_line_val_rec.ship_to_address3
15995           ,   p_ship_to_address4            => p_line_val_rec.ship_to_address4
15996           ,   p_ship_to_location            => p_line_val_rec.ship_to_location
15997           ,   p_ship_to_org                 => p_line_val_rec.ship_to_org
15998           ,   p_ship_to_city                => p_line_val_rec.ship_to_city
15999           ,   p_ship_to_state               => p_line_val_rec.ship_to_state
16000           ,   p_ship_to_postal_code         => p_line_val_rec.ship_to_zip
16001           ,   p_ship_to_country             => p_line_val_rec.ship_to_country
16002 		  ,   p_sold_to_org_id        => l_sold_to_org_id
16003           , p_ship_to_customer_id => p_x_line_rec.ship_to_customer_id
16004             );
16005 
16006 /*1621182*/
16007             IF p_x_line_rec.ship_to_org_id = FND_API.G_MISS_NUM THEN
16008                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
16009             END IF;
16010 
16011         END IF;
16012 
16013     END IF;
16014 
16015     -- Retrieve the org_ids if not passed on the line record. These
16016     -- IDs will be needed by the value_to_id functions for CONTACT fields.
16017     -- For e.g. oe_value_to_id.ship_to_contact_id requires ship_to_org_id
16018 
16019     -- bug 3487597, added clause for line_id
16020 
16021     IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
16022 	  AND ( p_x_line_rec.ship_to_org_id = FND_API.G_MISS_NUM
16023 	       OR p_x_line_rec.invoice_to_org_id = FND_API.G_MISS_NUM
16024 	       OR p_x_line_rec.deliver_to_org_id = FND_API.G_MISS_NUM )
16025           AND p_x_line_rec.line_id <> FND_API.G_MISS_NUM
16026     THEN
16027 
16028 	  SELECT SHIP_TO_ORG_ID, INVOICE_TO_ORG_ID, DELIVER_TO_ORG_ID
16029 	  INTO l_sold_to_org_id, l_invoice_to_org_id, l_deliver_to_org_id
16030 	  FROM OE_ORDER_LINES
16031 	  WHERE LINE_ID = p_x_line_rec.line_id;
16032 
16033 	  IF p_x_line_rec.ship_to_org_id <> FND_API.G_MISS_NUM THEN
16034 		l_ship_to_org_id := p_x_line_rec.ship_to_org_id;
16035        END IF;
16036 
16037 	  IF p_x_line_rec.invoice_to_org_id <> FND_API.G_MISS_NUM THEN
16038 		l_invoice_to_org_id := p_x_line_rec.invoice_to_org_id;
16039        END IF;
16040 
16041 	  IF p_x_line_rec.deliver_to_org_id <> FND_API.G_MISS_NUM THEN
16042 		l_deliver_to_org_id := p_x_line_rec.deliver_to_org_id;
16043        END IF;
16044 
16045     ELSE
16046 
16047 	  l_sold_to_org_id := p_x_line_rec.sold_to_org_id;
16048 	  l_invoice_to_org_id := p_x_line_rec.invoice_to_org_id;
16049 	  l_deliver_to_org_id := p_x_line_rec.deliver_to_org_id;
16050 
16051     END IF;
16052 
16053     IF  p_line_val_rec.deliver_to_contact <> FND_API.G_MISS_CHAR
16054     THEN
16055 
16056         IF p_x_line_rec.deliver_to_contact_id <> FND_API.G_MISS_NUM THEN
16057 
16058 
16059             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
16060             THEN
16061 
16062                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
16063                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','deliver_to_contact');
16064                 OE_MSG_PUB.Add;
16065 
16066             END IF;
16067 
16068         ELSE
16069 
16070             p_x_line_rec.deliver_to_contact_id := OE_Value_To_Id.deliver_to_contact
16071             (   p_deliver_to_contact          => p_line_val_rec.deliver_to_contact
16072 		  ,   p_deliver_to_org_id           => l_deliver_to_org_id
16073             );
16074 
16075             IF p_x_line_rec.deliver_to_contact_id = FND_API.G_MISS_NUM THEN
16076                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
16077             END IF;
16078 
16079         END IF;
16080 
16081     END IF;
16082 
16083     IF  p_line_val_rec.invoice_to_contact <> FND_API.G_MISS_CHAR
16084     THEN
16085 
16086         IF p_x_line_rec.invoice_to_contact_id <> FND_API.G_MISS_NUM THEN
16087 
16088 
16089             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
16090             THEN
16091 
16092                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
16093                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','invoice_to_contact');
16094                 OE_MSG_PUB.Add;
16095 
16096             END IF;
16097 
16098         ELSE
16099 
16100             p_x_line_rec.invoice_to_contact_id := OE_Value_To_Id.invoice_to_contact
16101             (   p_invoice_to_contact          => p_line_val_rec.invoice_to_contact
16102 		  ,   p_invoice_to_org_id           => l_invoice_to_org_id
16103             );
16104 
16105             IF p_x_line_rec.invoice_to_contact_id = FND_API.G_MISS_NUM THEN
16106                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
16107             END IF;
16108 
16109         END IF;
16110 
16111     END IF;
16112 
16113     IF  p_line_val_rec.ship_to_contact <> FND_API.G_MISS_CHAR
16114     THEN
16115 
16116         IF p_x_line_rec.ship_to_contact_id <> FND_API.G_MISS_NUM THEN
16117 
16118 
16119             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
16120             THEN
16121 
16122                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
16123                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','ship_to_contact');
16124                 OE_MSG_PUB.Add;
16125 
16126             END IF;
16127 
16128         ELSE
16129 
16130             p_x_line_rec.ship_to_contact_id := OE_Value_To_Id.ship_to_contact
16131             (   p_ship_to_contact             => p_line_val_rec.ship_to_contact
16132 		  ,   p_ship_to_org_id              => l_ship_to_org_id
16133             );
16134 
16135             IF p_x_line_rec.ship_to_contact_id = FND_API.G_MISS_NUM THEN
16136                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
16137             END IF;
16138 
16139         END IF;
16140 
16141     END IF;
16142 
16143     -- added code for commitment for bug 1851006.
16144     IF  p_line_val_rec.commitment <> FND_API.G_MISS_CHAR
16145     THEN
16146 
16147         IF p_x_line_rec.commitment_id <> FND_API.G_MISS_NUM THEN
16148 
16149             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
16150             THEN
16151 
16152                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
16153                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','commitment');
16154                 OE_MSG_PUB.Add;
16155 
16156             END IF;
16157 
16158         ELSE
16159 
16160             p_x_line_rec.commitment_id := OE_Value_To_Id.commitment
16161             (   p_commitment                   => p_line_val_rec.commitment
16162             );
16163 
16164             IF p_x_line_rec.commitment_id = FND_API.G_MISS_NUM THEN
16165                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
16166             END IF;
16167 
16168         END IF;
16169       END IF;
16170 
16171       /* mvijayku */
16172     IF  p_line_val_rec.end_customer_name <> FND_API.G_MISS_CHAR
16173     OR  p_line_val_rec.end_customer_number <> FND_API.G_MISS_CHAR
16174     THEN
16175 
16176         IF p_x_line_rec.end_customer_id <> FND_API.G_MISS_NUM THEN
16177 
16178 
16179             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
16180             THEN
16181 
16182                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
16183                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','end_customer');
16184                 OE_MSG_PUB.Add;
16185 
16186             END IF;
16187 
16188         ELSE
16189           IF p_x_line_rec.end_customer_site_use_id = FND_API.G_MISS_NUM THEN -- 4231603
16190             p_x_line_rec.end_customer_id:=OE_Value_To_Id.end_customer
16191             ( p_end_customer       => p_line_val_rec.end_customer_name
16192              ,p_end_customer_number=> p_line_val_rec.end_customer_number
16193               );
16194 
16195             IF p_x_line_rec.end_customer_id = FND_API.G_MISS_NUM THEN
16196                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
16197             END IF;
16198           END IF;
16199         END IF;
16200 
16201     END IF;
16202 
16203     IF  p_line_val_rec.end_customer_contact <> FND_API.G_MISS_CHAR
16204     THEN
16205 
16206         IF p_x_line_rec.end_customer_id <>FND_API.G_MISS_NUM and
16207                 p_x_line_rec.end_customer_contact_id <> FND_API.G_MISS_NUM THEN
16208 
16209 
16210             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
16211             THEN
16212 
16213                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
16214                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','end_customer_contact');
16215                 OE_MSG_PUB.Add;
16216 
16217             END IF;
16218 
16219         ELSE
16220                 oe_debug_pub.add('before calling aend customer contact value to id');
16221             p_x_line_rec.end_customer_contact_id := OE_Value_To_Id.end_customer_contact
16222             (   p_end_customer_contact             => p_line_val_rec.end_customer_contact
16223 		  ,p_end_customer_id              =>p_x_line_rec.end_customer_id
16224             );
16225 	    oe_debug_pub.add('End customer contact id is '||p_x_line_rec.end_customer_contact_id);
16226 
16227             IF p_x_line_rec.end_customer_contact_id = FND_API.G_MISS_NUM THEN
16228                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
16229             END IF;
16230 
16231         END IF;
16232 
16233     END IF;
16234 
16235   IF (p_line_val_rec.end_customer_name <> FND_API.G_MISS_CHAR
16236       OR p_line_val_rec.end_customer_number <> FND_API.G_MISS_CHAR
16237       OR p_x_line_rec.end_customer_id <> FND_API.G_MISS_NUM)
16238 	 AND
16239      (p_line_val_rec.end_customer_site_address1 <> FND_API.G_MISS_CHAR
16240     OR p_line_val_rec.end_customer_site_address2 <> FND_API.G_MISS_CHAR
16241     OR p_line_val_rec.end_customer_site_address3 <> FND_API.G_MISS_CHAR
16242     OR p_line_val_rec.end_customer_site_address4 <> FND_API.G_MISS_CHAR
16243     OR p_line_val_rec.end_customer_site_location          <> FND_API.G_MISS_CHAR)
16244 
16245     THEN
16246 
16247         IF p_x_line_rec.end_customer_site_use_id <> FND_API.G_MISS_NUM THEN
16248 
16249 
16250             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
16251             THEN
16252 
16253                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
16254                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','end_Customer_Location');
16255                 OE_MSG_PUB.Add;
16256 
16257             END IF;
16258 
16259         ELSE
16260 	   oe_debug_pub.add('Before calling End custoemr site use value to id');
16261             p_x_line_rec.end_customer_site_use_id := OE_Value_To_Id.end_customer_site
16262             (   p_end_customer_site_address1            => p_line_val_rec.end_customer_site_address1
16263             ,   p_end_customer_site_address2            => p_line_val_rec.end_customer_site_address2
16264             ,   p_end_customer_site_address3            => p_line_val_rec.end_customer_site_address3
16265             ,   p_end_customer_site_address4            => p_line_val_rec.end_customer_site_address4
16266             ,   p_end_customer_site_location                     => p_line_val_rec.end_customer_site_location
16267 	    ,   p_end_customer_site_org                       => NULL
16268 		,   p_end_customer_id                         => p_x_line_rec.end_customer_id
16269             ,   p_end_customer_site_city                => p_line_val_rec.end_customer_site_city
16270             ,   p_end_customer_site_state               => p_line_val_rec.end_customer_site_state
16271             ,   p_end_customer_site_postalcode         => p_line_val_rec.end_customer_site_postal_code
16272             ,   p_end_customer_site_country             => p_line_val_rec.end_customer_site_country
16273             ,   p_end_customer_site_use_code           => NULL
16274             );
16275 
16276 
16277     oe_debug_pub.add('after hdr sold_to_site_use_id='||p_x_line_rec.end_customer_site_use_id);
16278 
16279             IF p_x_line_rec.end_customer_site_use_id = FND_API.G_MISS_NUM THEN
16280                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
16281             END IF;
16282 
16283         END IF;
16284 
16285     END IF;
16286 
16287     -- {added for bug 4240715
16288     IF  p_line_val_rec.ib_owner_dsp <> FND_API.G_MISS_CHAR
16289     THEN
16290         IF p_x_line_rec.ib_owner <> FND_API.G_MISS_CHAR THEN
16291 
16292             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
16293             THEN
16294 
16295                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
16296                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','IB_Owner');
16297                 OE_MSG_PUB.Add;
16298 
16299             END IF;
16300 
16301         ELSE
16302 
16303             p_x_line_rec.ib_owner:=OE_Value_To_Id.ib_owner
16304             ( p_ib_owner       => p_line_val_rec.ib_owner_dsp
16305               );
16306 
16307             IF p_x_line_rec.ib_owner = FND_API.G_MISS_CHAR THEN
16308                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
16309             END IF;
16310 
16311         END IF;
16312 
16313     END IF;
16314 
16315     IF  p_line_val_rec.ib_installed_at_location_dsp <> FND_API.G_MISS_CHAR
16316     THEN
16317         IF p_x_line_rec.ib_installed_at_location <> FND_API.G_MISS_CHAR THEN
16318 
16319             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
16320             THEN
16321 
16322                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
16323                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','IB_Installed_at_location');
16324                 OE_MSG_PUB.Add;
16325 
16326             END IF;
16327 
16328         ELSE
16329 
16330             p_x_line_rec.ib_installed_at_location:=OE_Value_To_Id.ib_installed_at_location
16331             ( p_ib_installed_at_location       => p_line_val_rec.ib_installed_at_location_dsp
16332               );
16333 
16334             IF p_x_line_rec.ib_installed_at_location = FND_API.G_MISS_CHAR THEN
16335                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
16336             END IF;
16337 
16338         END IF;
16339 
16340     END IF;
16341 
16342      IF  p_line_val_rec.ib_current_location_dsp <> FND_API.G_MISS_CHAR
16343     THEN
16344         IF p_x_line_rec.ib_current_location <> FND_API.G_MISS_CHAR THEN
16345 
16346             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
16347             THEN
16348 
16349                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
16350                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','IB_current_location');
16351                 OE_MSG_PUB.Add;
16352 
16353             END IF;
16354 
16355         ELSE
16356 
16357             p_x_line_rec.ib_current_location:=OE_Value_To_Id.ib_current_location
16358             ( p_ib_current_location       => p_line_val_rec.ib_current_location_dsp
16359               );
16360 
16361             IF p_x_line_rec.ib_current_location = FND_API.G_MISS_CHAR THEN
16362                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
16363             END IF;
16364 
16365         END IF;
16366 
16367     END IF;
16368     --bug 4240715}
16369 	--sol_ord_er #16014165 (Used in Order Import)
16370 	 IF  p_line_val_rec.service_bill_profile <> FND_API.G_MISS_CHAR
16371     THEN
16372         IF p_x_line_rec.service_bill_profile_id <> FND_API.G_MISS_NUM THEN
16373             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
16374             THEN
16375                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
16376                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','SERVICE_BILLING_PROFILE');
16377                 OE_MSG_PUB.Add;
16378             END IF;
16379         ELSE
16380             p_x_line_rec.service_bill_profile_id := OE_Value_To_Id.Billing_Profile
16381             (   p_service_bill_profile             => p_line_val_rec.service_bill_profile
16382             );
16383             IF p_x_line_rec.service_bill_profile_id = FND_API.G_MISS_NUM THEN
16384                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
16385             END IF;
16386         END IF;
16387     END IF;
16388 	-- Billing Option
16389 	IF  p_line_val_rec.service_bill_option <> FND_API.G_MISS_CHAR
16390     THEN
16391         IF p_x_line_rec.service_bill_option_code <> FND_API.G_MISS_CHAR THEN
16392             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
16393             THEN
16394                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
16395                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','SERVICE_BILLING_OPTION');
16396                 OE_MSG_PUB.Add;
16397             END IF;
16398         ELSE
16399             p_x_line_rec.service_bill_option_code := OE_Value_To_Id.Billing_Option
16400             (   p_service_bill_option             => p_line_val_rec.service_bill_option
16401             );
16402             IF p_x_line_rec.service_bill_option_code = FND_API.G_MISS_CHAR THEN
16403                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
16404             END IF;
16405         END IF;
16406     END IF;
16407 	--- Subscription Template
16408 	IF  p_line_val_rec.service_subs_template <> FND_API.G_MISS_CHAR
16409     THEN
16410         IF p_x_line_rec.service_subs_template_id <> FND_API.G_MISS_NUM THEN
16411             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
16412             THEN
16413                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
16414                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','SERVICE_SUBSCRIPTION_TEMPLATE');
16415                 OE_MSG_PUB.Add;
16416             END IF;
16417         ELSE
16418             p_x_line_rec.service_subs_template_id := OE_Value_To_Id.Subscription_Template
16419             (   p_service_subs_template              => p_line_val_rec.service_subs_template
16420             );
16421             IF p_x_line_rec.service_subs_template_id = FND_API.G_MISS_NUM THEN
16422                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
16423             END IF;
16424         END IF;
16425     END IF;
16426 	-- Coverage Template
16427 	IF  p_line_val_rec.service_cov_template <> FND_API.G_MISS_CHAR
16428     THEN
16429         IF p_x_line_rec.service_cov_template_id <> FND_API.G_MISS_NUM THEN
16430             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
16431             THEN
16432                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
16433                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','SERVICE_COVERAGE_TEMPLATE');
16434                 OE_MSG_PUB.Add;
16435             END IF;
16436         ELSE
16437             p_x_line_rec.service_cov_template_id := OE_Value_To_Id.Coverage_Template
16438             (   p_service_cov_template             => p_line_val_rec.service_cov_template
16439             );
16440             IF p_x_line_rec.service_cov_template_id = FND_API.G_MISS_NUM THEN
16441                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
16442             END IF;
16443         END IF;
16444     END IF;
16445 	--sol_ord_er #16014165 end
16446 
16447     -------------------------------------------------------------------
16448     -- End of get IDs for customer related fields
16449     -------------------------------------------------------------------
16450 
16451 
16452 END Get_Ids;
16453 
16454 
16455 
16456 /*----------------------------------------------------------
16457 Procedure Query_Header
16458 -----------------------------------------------------------*/
16459 
16460 Procedure Query_Header
16461 (   p_line_id                       IN  NUMBER :=
16462                                         FND_API.G_MISS_NUM
16463 ,   x_header_id                     OUT NOCOPY /* file.sql.39 change */ NUMBER
16464 )IS
16465 BEGIN
16466 
16467 	Select header_id into x_header_id
16468 	from oe_order_lines
16469 	where line_id = p_line_id;
16470 	IF sql%notfound then
16471         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
16472 	END IF;
16473 
16474 
16475 END Query_Header;
16476 
16477 -- INVCONV for SAO
16478 
16479 PROCEDURE get_reserved_quantities
16480 ( p_header_id                       IN NUMBER
16481  ,p_line_id                         IN NUMBER
16482  ,p_org_id                          IN NUMBER
16483  ,p_order_quantity_uom              IN VARCHAR2 DEFAULT NULL
16484  ,p_inventory_item_id		    				IN NUMBER DEFAULT NULL
16485  ,x_reserved_quantity               OUT NOCOPY NUMBER
16486  ,x_reserved_quantity2              OUT NOCOPY NUMBER )
16487 
16488 IS
16489 
16490 l_reserved_quantity     NUMBER := 0;
16491 l_reserved_quantity2    NUMBER := 0;
16492 l_return_status         VARCHAR2(1);
16493 l_msg_count             NUMBER;
16494 l_msg_data              VARCHAR2(240);
16495 
16496 l_rsv_rec               inv_reservation_global.mtl_reservation_rec_type;
16497 l_rsv_tbl               inv_reservation_global.mtl_reservation_tbl_type;
16498 l_count                 NUMBER;
16499 l_x_error_code          NUMBER;
16500 l_lock_records          VARCHAR2(1);
16501 l_sort_by_req_date      NUMBER;
16502 --- 2346233
16503 l_converted_qty         NUMBER;
16504 l_inventory_item_id     NUMBER;
16505 l_order_quantity_uom    VARCHAR2(30);
16506 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
16507 
16508 BEGIN
16509 	 if l_debug_level > 0 then -- INVCONV
16510           oe_debug_pub.add('in get_reserved_quantities' );
16511    end if;
16512    l_rsv_rec.demand_source_header_id  := p_header_id;
16513    l_rsv_rec.demand_source_line_id    := p_line_id;
16514 
16515    l_rsv_rec.organization_id           := p_org_id;
16516 
16517    inv_reservation_pub.query_reservation_om_hdr_line
16518    (  p_api_version_number        => 1.0
16519   , p_init_msg_lst              => fnd_api.g_true
16520   , x_return_status             => l_return_status
16521   , x_msg_count                 => l_msg_count
16522   , x_msg_data                  => l_msg_data
16523   , p_query_input               => l_rsv_rec
16524   , x_mtl_reservation_tbl       => l_rsv_tbl
16525   , x_mtl_reservation_tbl_count => l_count
16526   , x_error_code                => l_x_error_code
16527   , p_lock_records              => l_lock_records
16528   , p_sort_by_req_date          => l_sort_by_req_date
16529    );
16530 
16531 
16532    IF ((p_order_quantity_uom IS NULL ) AND (p_inventory_item_id IS NULL)) THEN 	   --added condition for 3745318
16533    -- Start 2346233
16534 	   BEGIN
16535 	      Select order_quantity_uom, inventory_item_id
16536 	      Into   l_order_quantity_uom, l_inventory_item_id
16537 	      From   oe_order_lines_all
16538 	      Where  line_id = p_line_id;
16539 
16540 	   EXCEPTION
16541 	      WHEN OTHERS THEN
16542 		  l_order_quantity_uom := Null;
16543 	   END;
16544 	   ---- End 2346233
16545    ELSE
16546       l_order_quantity_uom :=p_order_quantity_uom;
16547       l_inventory_item_id  :=p_inventory_item_id;
16548    END IF;
16549 
16550 
16551    FOR I IN 1..l_rsv_tbl.COUNT LOOP
16552 
16553       ----
16554       IF nvl(l_order_quantity_uom,l_rsv_tbl(I).reservation_uom_code)
16555                                 <> l_rsv_tbl(I).reservation_uom_code THEN
16556          l_converted_qty := INV_CONVERT.INV_UM_CONVERT(l_inventory_item_id -- INVCONV
16557                                                       ,9 --5 --NULL Bug 16614440 send as 9 and round later
16558                                                       ,l_rsv_tbl(I).reservation_quantity
16559                                                       ,l_rsv_tbl(I).reservation_uom_code
16560                                                       ,l_order_quantity_uom
16561                                                       ,NULL -- From uom name
16562                                                       ,NULL -- To uom name
16563                                                       );
16564 
16565 
16566         l_reserved_quantity := l_reserved_quantity + l_converted_qty;
16567      ELSE
16568      --- End 2346233
16569 
16570         l_reserved_quantity := l_reserved_quantity +
16571                                 l_rsv_tbl(I).reservation_quantity;
16572      END IF;
16573      l_reserved_quantity2 := l_reserved_quantity2 +
16574                                  l_rsv_tbl(I).secondary_reservation_quantity;
16575 
16576   END LOOP;
16577 
16578 	if l_debug_level > 0 then -- INVCONV
16579       oe_debug_pub.add('leaving get_reserved_quantities  qty = :' || l_reserved_quantity  );
16580       oe_debug_pub.add('leaving get_reserved_quantities  qty2 = :' || l_reserved_quantity2  );
16581  	end if;
16582 
16583   x_reserved_quantity  := ROUND(l_reserved_quantity,5); --Bug 16614440
16584   x_reserved_quantity2  := ROUND(l_reserved_quantity2,5); --Bug 16614440
16585 
16586 end get_reserved_quantities;
16587 -- INVCONV
16588 
16589 
16590 
16591 
16592 
16593 /*----------------------------------------------------------
16594 FUNCTION Get_Reserved_Quantity
16595 -- mpetrosi 02-Jun-2000 added org_id start change
16596 -----------------------------------------------------------*/
16597 
16598 FUNCTION Get_Reserved_Quantity
16599 ( p_header_id                       IN NUMBER
16600  ,p_line_id                         IN NUMBER
16601  ,p_org_id                          IN NUMBER
16602  ,p_order_quantity_uom                IN VARCHAR2 DEFAULT NULL	--3745318
16603  ,p_inventory_item_id		    IN NUMBER DEFAULT NULL	--3745318
16604 )RETURN NUMBER
16605 IS
16606 
16607 -- mpetrosi 02-Jun-2000 added org_id end change
16608 
16609 l_reserved_quantity     NUMBER := 0;
16610 l_return_status         VARCHAR2(1);
16611 l_msg_count             NUMBER;
16612 l_msg_data              VARCHAR2(240);
16613 
16614 l_rsv_rec               inv_reservation_global.mtl_reservation_rec_type;
16615 l_rsv_tbl               inv_reservation_global.mtl_reservation_tbl_type;
16616 l_count                 NUMBER;
16617 l_x_error_code          NUMBER;
16618 l_lock_records          VARCHAR2(1);
16619 l_sort_by_req_date      NUMBER;
16620 --- 2346233
16621 l_converted_qty         NUMBER;
16622 l_inventory_item_id     NUMBER;
16623 l_order_quantity_uom    VARCHAR2(30);
16624 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
16625 
16626 BEGIN
16627 		if l_debug_level > 0 then -- INVCONV
16628                 	oe_debug_pub.add('in get_reserved_quantity ' );
16629                  end if;
16630    l_rsv_rec.demand_source_header_id  := p_header_id;
16631    l_rsv_rec.demand_source_line_id    := p_line_id;
16632 
16633    -- mpetrosi OPM 02-jun-2000 added org_id start change
16634    l_rsv_rec.organization_id           := p_org_id;
16635    -- mpetrosi OPM 02-jun-2000 added org_id end change
16636 
16637    inv_reservation_pub.query_reservation_om_hdr_line
16638    (  p_api_version_number        => 1.0
16639   , p_init_msg_lst              => fnd_api.g_true
16640   , x_return_status             => l_return_status
16641   , x_msg_count                 => l_msg_count
16642   , x_msg_data                  => l_msg_data
16643   , p_query_input               => l_rsv_rec
16644   , x_mtl_reservation_tbl       => l_rsv_tbl
16645   , x_mtl_reservation_tbl_count => l_count
16646   , x_error_code                => l_x_error_code
16647   , p_lock_records              => l_lock_records
16648   , p_sort_by_req_date          => l_sort_by_req_date
16649    );
16650 
16651 
16652    IF ((p_order_quantity_uom IS NULL ) AND (p_inventory_item_id IS NULL)) THEN 	   --added condition for 3745318
16653    -- Start 2346233
16654 	   BEGIN
16655 	      Select order_quantity_uom, inventory_item_id
16656 	      Into   l_order_quantity_uom, l_inventory_item_id
16657 	      From   oe_order_lines_all
16658 	      Where  line_id = p_line_id;
16659 
16660 	   EXCEPTION
16661 	      WHEN OTHERS THEN
16662 		  l_order_quantity_uom := Null;
16663 	   END;
16664 	   ---- End 2346233
16665    ELSE
16666       l_order_quantity_uom :=p_order_quantity_uom;
16667       l_inventory_item_id  :=p_inventory_item_id;
16668    END IF;
16669 
16670 
16671    FOR I IN 1..l_rsv_tbl.COUNT LOOP
16672 
16673       l_rsv_rec := l_rsv_tbl(I);
16674       ---- Start 2346233
16675       IF nvl(l_order_quantity_uom,l_rsv_rec.reservation_uom_code)
16676                                 <> l_rsv_rec.reservation_uom_code THEN
16677          l_converted_qty := INV_CONVERT.INV_UM_CONVERT(l_inventory_item_id -- INVCONV
16678                                                       ,5 --NULL
16679                                                       ,l_rsv_rec.reservation_quantity
16680                                                       ,l_rsv_rec.reservation_uom_code
16681                                                       ,l_order_quantity_uom
16682                                                       ,NULL -- From uom name
16683                                                       ,NULL -- To uom name
16684                                                       );
16685 
16686 
16687         l_reserved_quantity := l_reserved_quantity + l_converted_qty;
16688      ELSE
16689      --- End 2346233
16690 
16691         l_reserved_quantity := l_reserved_quantity +
16692                                  l_rsv_rec.reservation_quantity;
16693      END IF; -- 2346233
16694 
16695    END LOOP;
16696 
16697 
16698 if l_debug_level > 0 then -- INVCONV
16699                 	oe_debug_pub.add('leaving get_reserved_quantity. qty = :' || l_reserved_quantity  );
16700 end if;
16701    return (l_reserved_quantity);
16702 
16703 END Get_Reserved_Quantity;
16704 
16705 /*----------------------------------------------------------
16706 FUNCTION Get_Reserved_Quantity2   INVCONV
16707 -----------------------------------------------------------*/
16708 
16709 FUNCTION Get_Reserved_Quantity2
16710 ( p_header_id                       IN NUMBER
16711  ,p_line_id                         IN NUMBER
16712  ,p_org_id                          IN NUMBER
16713 )RETURN NUMBER
16714 IS
16715 
16716 l_reserved_quantity2     NUMBER := 0;
16717 l_return_status         VARCHAR2(1);
16718 l_msg_count             NUMBER;
16719 l_msg_data              VARCHAR2(240);
16720 
16721 l_rsv_rec               inv_reservation_global.mtl_reservation_rec_type;
16722 l_rsv_tbl               inv_reservation_global.mtl_reservation_tbl_type;
16723 l_count                 NUMBER;
16724 l_x_error_code          NUMBER;
16725 l_lock_records          VARCHAR2(1);
16726 l_sort_by_req_date      NUMBER;
16727 --- 2346233
16728 l_converted_qty         NUMBER;
16729 l_inventory_item_id     NUMBER;
16730 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
16731 
16732 
16733 BEGIN
16734    if l_debug_level > 0 then -- INVCONV
16735                 	oe_debug_pub.add('in get_reserved_quantity ' );
16736     end if;
16737    l_rsv_rec.demand_source_header_id  := p_header_id;
16738    l_rsv_rec.demand_source_line_id    := p_line_id;
16739 
16740    l_rsv_rec.organization_id           := p_org_id;
16741 
16742    inv_reservation_pub.query_reservation_om_hdr_line
16743    (  p_api_version_number        => 1.0
16744   , p_init_msg_lst              => fnd_api.g_true
16745   , x_return_status             => l_return_status
16746   , x_msg_count                 => l_msg_count
16747   , x_msg_data                  => l_msg_data
16748   , p_query_input               => l_rsv_rec
16749   , x_mtl_reservation_tbl       => l_rsv_tbl
16750   , x_mtl_reservation_tbl_count => l_count
16751   , x_error_code                => l_x_error_code
16752   , p_lock_records              => l_lock_records
16753   , p_sort_by_req_date          => l_sort_by_req_date
16754    );
16755 
16756    FOR I IN 1..l_rsv_tbl.COUNT LOOP
16757 
16758       l_rsv_rec := l_rsv_tbl(I);
16759       l_reserved_quantity2 := l_reserved_quantity2 +
16760                                  l_rsv_rec.secondary_reservation_quantity;
16761 
16762    END LOOP;
16763 if l_debug_level > 0 then -- INVCONV
16764        oe_debug_pub.add('leaving get_reserved_quantity2. qty2 = :' || l_reserved_quantity2  );
16765 end if;
16766 
16767    return (l_reserved_quantity2);
16768 
16769 END Get_Reserved_Quantity2;
16770 
16771 
16772 
16773 
16774 /*----------------------------------------------------------
16775 FUNCTION Get_Open_Quantity
16776 -----------------------------------------------------------*/
16777 
16778 FUNCTION Get_Open_Quantity(p_header_id        IN NUMBER,
16779                            p_line_id          IN NUMBER,
16780                            p_ordered_quantity IN NUMBER,
16781                            p_shipped_quantity IN NUMBER)
16782 RETURN NUMBER
16783 IS
16784 l_open_quantity         NUMBER := 0;
16785 l_reserved_quantity     NUMBER := 0;
16786 l_mtl_sales_order_id    NUMBER;
16787 l_return_status         VARCHAR2(1);
16788 l_msg_count             NUMBER;
16789 l_msg_data              VARCHAR2(240);
16790 
16791 l_rsv_rec               inv_reservation_global.mtl_reservation_rec_type;
16792 l_rsv_tbl               inv_reservation_global.mtl_reservation_tbl_type;
16793 l_count                 NUMBER;
16794 l_x_error_code          NUMBER;
16795 l_lock_records          VARCHAR2(1);
16796 l_sort_by_req_date      NUMBER;
16797 l_converted_qty         NUMBER;
16798 l_inventory_item_id     NUMBER;
16799 l_order_quantity_uom    VARCHAR2(30);
16800 BEGIN
16801 
16802    l_mtl_sales_order_id := OE_HEADER_UTIL.Get_Mtl_Sales_Order_Id
16803                           (p_header_id=>p_header_id);
16804 
16805 
16806 /* This part is commented to fix the bug 2136256.
16807    Once we fix the uom conversion issue in Get_Reserved_Quantity
16808    we will revert the changes.
16809    l_reserved_quantity  := Get_Reserved_Quantity (l_mtl_sales_order_id,
16810                                                  p_line_id);
16811 */
16812 
16813 
16814 
16815    l_rsv_rec.demand_source_header_id  := l_mtl_sales_order_id;
16816    l_rsv_rec.demand_source_line_id    := p_line_id;
16817 
16818    -- mpetrosi OPM 02-jun-2000 added org_id start change
16819    l_rsv_rec.organization_id           := Null;
16820    -- mpetrosi OPM 02-jun-2000 added org_id end change
16821 
16822    inv_reservation_pub.query_reservation_om_hdr_line
16823    (  p_api_version_number        => 1.0
16824   , p_init_msg_lst              => fnd_api.g_true
16825   , x_return_status             => l_return_status
16826   , x_msg_count                 => l_msg_count
16827   , x_msg_data                  => l_msg_data
16828   , p_query_input               => l_rsv_rec
16829   , x_mtl_reservation_tbl       => l_rsv_tbl
16830   , x_mtl_reservation_tbl_count => l_count
16831   , x_error_code                => l_x_error_code
16832   , p_lock_records              => l_lock_records
16833   , p_sort_by_req_date          => l_sort_by_req_date
16834    );
16835 
16836    BEGIN
16837 
16838         Select order_quantity_uom, inventory_item_id
16839         Into   l_order_quantity_uom, l_inventory_item_id
16840         From   oe_order_lines_all
16841         Where  line_id = p_line_id;
16842 
16843    EXCEPTION
16844     WHEN OTHERS THEN
16845 
16846      l_order_quantity_uom := Null;
16847    END;
16848    FOR I IN 1..l_rsv_tbl.COUNT LOOP
16849 
16850       l_rsv_rec := l_rsv_tbl(I);
16851 
16852       IF nvl(l_order_quantity_uom,l_rsv_rec.reservation_uom_code)
16853                                 <> l_rsv_rec.reservation_uom_code THEN
16854 
16855         oe_debug_pub.add('reservation_uom_code :' ||
16856                               l_rsv_rec.reservation_uom_code,3);
16857         oe_debug_pub.add('l_order_quantity_uom :' ||
16858                               l_order_quantity_uom,3);
16859         oe_debug_pub.add('reservation_quantity :' ||
16860                               l_rsv_rec.reservation_quantity,3);
16861         l_converted_qty :=
16862         Oe_Order_Misc_Util.convert_uom( l_inventory_item_id,
16863 				     l_rsv_rec.reservation_uom_code,
16864 				     l_order_quantity_uom,
16865 			             l_rsv_rec.reservation_quantity);
16866 
16867         oe_debug_pub.add('l_converted_qty :' || l_converted_qty,3);
16868         l_reserved_quantity := l_reserved_quantity +
16869                                l_converted_qty;
16870       ELSE
16871 
16872         oe_debug_pub.add('2 reservation_quantity :' ||
16873                               l_rsv_rec.reservation_quantity);
16874         l_reserved_quantity := l_reserved_quantity +
16875                                  l_rsv_rec.reservation_quantity;
16876       END IF;
16877 
16878    END LOOP;
16879 
16880    l_open_quantity      := p_ordered_quantity -
16881                            nvl(p_shipped_quantity,0) -
16882                            l_reserved_quantity;
16883 
16884   RETURN l_open_quantity;
16885 
16886 EXCEPTION
16887 
16888 WHEN NO_DATA_FOUND THEN
16889 		RETURN NULL;
16890 
16891 END Get_Open_Quantity;
16892 
16893 
16894 
16895 /*----------------------------------------------------------
16896 FUNCTION Get_Primary_Uom_Quantity
16897 -----------------------------------------------------------*/
16898 
16899 FUNCTION Get_Primary_Uom_Quantity(p_ordered_quantity IN NUMBER,
16900                                   p_order_quantity_uom IN VARCHAR2)
16901 RETURN NUMBER
16902 IS
16903 BEGIN
16904     RETURN p_ordered_quantity;
16905 
16906 EXCEPTION
16907 
16908 WHEN NO_DATA_FOUND THEN
16909 		RETURN NULL;
16910 
16911 END Get_Primary_Uom_Quantity;
16912 
16913 
16914 -- check whether total returned quantity (this line plus all previous
16915 -- lines ) is more than ordered
16916 
16917 
16918 
16919 /*----------------------------------------------------------
16920 Function Is_Over_Return
16921 -----------------------------------------------------------*/
16922 
16923 Function Is_Over_Return
16924 (   p_line_rec                      IN OE_Order_PUB.Line_Rec_Type
16925 ) RETURN BOOLEAN
16926 IS
16927 l_total NUMBER;
16928 l_orig_quantity NUMBER;
16929 l_upgraded_flag varchar2(1);
16930 l_srl_num_count NUMBER;
16931 
16932 l_overship_invoice_basis    varchar2(30) := null;  --bug# 6617423
16933 
16934 CURSOR C_LOT_SERIAL(p_serial_num VARCHAR2) IS
16935     SELECT line_id,line_set_id,from_serial_number,to_serial_number
16936     FROM oe_lot_serial_numbers
16937     WHERE from_serial_number = p_serial_num
16938     OR to_serial_number = p_serial_num;
16939     l_ref_line_id NUMBER;
16940 
16941 BEGIN
16942 
16943  oe_debug_pub.ADD('Entering Over Return',1);
16944 
16945  /*
16946  ** Fix Bug # 2971412
16947  ** Since this validation used to get performed even in older
16948  ** releases. There is no need to suppress it for upgraded orders
16949  **
16950  IF p_line_rec.reference_line_id is not null THEN
16951 
16952 	select nvl(upgraded_flag,'-') into l_upgraded_flag
16953      from oe_order_lines
16954      where line_id = p_line_rec.reference_line_id;
16955 
16956      IF l_upgraded_flag in ('Y','P') THEN
16957           return FALSE;
16958      END IF;
16959 
16960   END IF;
16961   */
16962 
16963   oe_debug_pub.ADD('Return Context is: '||p_line_rec.return_context,1);
16964   oe_debug_pub.ADD('Line Id is: '||to_char(p_line_rec.line_id),1);
16965   oe_debug_pub.ADD('Reference Line Id is: '||to_char(p_line_rec.reference_line_id),1);
16966 
16967   -- Fix for Bug # 1613371
16968   IF p_line_rec.return_context = 'SERIAL' THEN
16969 
16970        FOR C2 IN C_LOT_SERIAL(p_line_rec.return_attribute2) LOOP
16971 
16972        -- If record exists in oe_lot_serial_numbers for the entered SN,
16973        -- check the line_set_id on it. There will be a value for line_set_id
16974        -- if the RMA line has got split. Get the reference line_id from the
16975        -- following queries.
16976 
16977             IF C2.line_set_id is not null THEN
16978                  select distinct reference_line_id
16979                  into l_ref_line_id
16980                  from oe_line_sets a,
16981                       oe_order_lines b
16982                  where a.set_id = C2.line_set_id
16983                  and a.line_id = b.line_id
16984                  and b.booked_flag = 'Y'
16985                  and b.line_id <> p_line_rec.line_id
16986                  and b.cancelled_flag <> 'Y';
16987             ELSE
16988                  select reference_line_id
16989                  into l_ref_line_id
16990                  from oe_order_lines
16991                  where line_id = C2.line_id
16992                  and line_id <> p_line_rec.line_id
16993                  and booked_flag = 'Y'
16994                  and cancelled_flag <> 'Y';
16995             END IF;
16996             IF l_ref_line_id = p_line_rec.reference_line_id THEN
16997                 RETURN TRUE;
16998             END IF;
16999        END LOOP;
17000   END IF;
17001 
17002   oe_debug_pub.ADD('Before checking the total for the Outbound line',1);
17003   SELECT sum(nvl(ordered_quantity, 0))
17004   INTO l_total
17005   FROM   oe_order_lines
17006   WHERE reference_line_id = p_line_rec.reference_line_id
17007   AND ((booked_flag = 'Y' and header_id <> p_line_rec.header_id)
17008     OR (header_id = p_line_rec.header_id))
17009   AND cancelled_flag <> 'Y'
17010   AND line_category_code = 'RETURN'
17011   AND line_id <> p_line_rec.line_id;
17012 
17013   oe_debug_pub.ADD('l_total : '||to_char(l_total),1);
17014 
17015 
17016     -- bug# 6617423 : Start  -----------
17017   /*
17018       SELECT nvl(ordered_quantity, 0)
17019       INTO l_orig_quantity
17020       FROM oe_order_lines
17021       WHERE line_id = p_line_rec.reference_line_id;
17022    */
17023 
17024     oe_debug_pub.add( ' <in Is_Over_Return >    p_line_rec.org_id = '|| p_line_rec.org_id, 5 ) ;
17025     IF p_line_rec.org_id = FND_API.G_MISS_NUM THEN   ---no need to handle null, automatically handled
17026        l_overship_invoice_basis := oe_sys_parameters.value('OE_OVERSHIP_INVOICE_BASIS',NULL);
17027     ELSE
17028        l_overship_invoice_basis := oe_sys_parameters.value('OE_OVERSHIP_INVOICE_BASIS',p_line_rec.org_id);
17029     END IF;
17030     oe_debug_pub.add(  ' <in Is_Over_Return >  l_overship_invoice_basis = '|| l_overship_invoice_basis , 5 ) ;
17031     oe_debug_pub.add(  ' <in Is_Over_Return >  p_line_rec.reference_line_id = '|| p_line_rec.reference_line_id , 5) ;
17032 
17033     IF l_overship_invoice_basis = 'SHIPPED' then
17034       SELECT nvl(shipped_quantity, ordered_quantity)  --- get from ord_qty if original line not shipped/invoiced....
17035       INTO l_orig_quantity
17036       FROM oe_order_lines
17037       WHERE line_id = p_line_rec.reference_line_id;
17038     ELSE
17039       SELECT nvl(ordered_quantity, 0)
17040       INTO l_orig_quantity
17041       FROM oe_order_lines
17042       WHERE line_id = p_line_rec.reference_line_id;
17043     end if;
17044     -- bug# 6617423: End -------
17045 
17046 
17047   oe_debug_pub.ADD('l_orig_quantity : '||to_char(l_orig_quantity),1);
17048 
17049   IF nvl(l_total,0) + p_line_rec.ordered_quantity > l_orig_quantity THEN
17050     RETURN TRUE;
17051   ELSE
17052     RETURN FALSE;
17053   END IF;
17054 
17055 EXCEPTION
17056   WHEN NO_DATA_FOUND THEN
17057    oe_debug_pub.ADD('In NO DATA FOUND ',1);
17058     RETURN FALSE;
17059 END Is_Over_Return;
17060 
17061 
17062 
17063 /*----------------------------------------------------------
17064 PROCEDURE Get_Inventory_Item
17065 -----------------------------------------------------------*/
17066 
17067 PROCEDURE Get_Inventory_Item
17068 (p_x_line_rec       IN OUT NOCOPY    OE_Order_Pub.Line_Rec_Type
17069 ,x_return_status  OUT NOCOPY /* file.sql.39 change */  VARCHAR2
17070 )
17071 IS
17072 /* Variables to call process order */
17073 l_line_tbl                         OE_ORDER_PUB.Line_Tbl_Type;
17074 l_old_line_tbl					OE_ORDER_PUB.Line_Tbl_Type;
17075 l_control_rec                 	OE_GLOBALS.Control_Rec_Type;
17076 
17077 l_attribute_value             VARCHAR2(2000);
17078 l_address_id                  VARCHAR2(2000):= NULL;
17079 l_cust_id                     NUMBER:= NULL;
17080 l_update_inventory_item       VARCHAR2(1) := FND_API.G_FALSE;
17081 l_inventory_item_id           NUMBER;
17082 l_error_code                  VARCHAR2(2000);
17083 l_error_flag                  VARCHAR2(2000);
17084 l_error_message               VARCHAR2(2000);
17085 BEGIN
17086 
17087         /*
17088          1.call  INV_CUSTOMER_ITEM_GRP.CI_Attribute_Value
17089            to get the inventory_item_id
17090            given the customer_item_id, and the new ship_from_org_id.
17091 
17092          2.check the value of the inventory_item_id returned:
17093            if internal item number return is not null, then
17094            assign the inventory_item_id to the out parameter
17095            otherwise
17096            post  message OE_INVALIDATES_CUSTOMER_ITEM
17097            set return status to error.
17098           */
17099 
17100     oe_debug_pub.add('Entering Get_Inventory_Item', 1);
17101     IF (p_x_line_rec.ship_to_org_id IS NOT NULL AND
17102         p_x_line_rec.ship_to_org_id <> FND_API.G_MISS_NUM) THEN
17103         /* Replaced with the following SELECT and IF statements
17104            to fix bug 2163988
17105         SELECT  cust_acct_site_id
17106         INTO  l_address_id
17107         FROM  HZ_CUST_SITE_USES
17108         WHERE  site_use_id = p_x_line_rec.ship_to_org_id
17109         AND  site_use_code = 'SHIP_TO';
17110         */
17111 
17112         SELECT  /*MOAC_SQL_CHANGES*/ u.cust_acct_site_id,
17113                 s.cust_account_id
17114         INTO  l_address_id,
17115               l_cust_id
17116         FROM  HZ_CUST_SITE_USES_ALL u,
17117               HZ_CUST_ACCT_SITES s
17118         WHERE  u.cust_acct_site_id = s.cust_acct_site_id
17119         AND    u.site_use_id = p_x_line_rec.ship_to_org_id
17120         AND    u.site_use_code = 'SHIP_TO';
17121         oe_debug_pub.add('ship to address:' || l_address_id||' - Customer:'||to_char(l_cust_id));
17122 
17123         IF l_cust_id <> p_x_line_rec.sold_to_org_id  THEN
17124           oe_debug_pub.add('Sold-To Customer:'||to_char(p_x_line_rec.sold_to_org_id));
17125           l_address_id := NULL;
17126         END IF;
17127 
17128     END IF;
17129 
17130     oe_debug_pub.add('INVENTORY_ITEM_ID Before calling CI_Attribute_Value '
17131 	||to_char(p_x_line_rec.inventory_item_id), 1);
17132 
17133     --Start of bug# 14352128
17134     oe_debug_pub.add('p_x_line_rec.line_category_code = '||p_x_line_rec.line_category_code);
17135     IF  p_x_line_rec.line_category_code = 'RETURN' THEN
17136         oe_debug_pub.add('Its a Return Order Line ');
17137 
17138     INV_CUSTOMER_ITEM_GRP.CI_Attribute_Value(
17139                        Z_Customer_Item_Id => p_x_line_rec.ordered_item_id
17140                    , Z_Customer_Id => p_x_line_rec.sold_to_org_id
17141                    , Z_Address_Id => l_address_id
17142                    , Z_Organization_Id => nvl(p_x_line_rec.ship_from_org_id, OE_Sys_Parameters.value('MASTER_ORGANIZATION_ID'))
17143     -- This change is required since we are dropping the profile OE_ORGANIZATION    -- _ID. Change made by Esha.
17144                    , Z_Inventory_Item_Id => p_x_line_rec.inventory_item_id
17145                    , Attribute_Name => 'INVENTORY_ITEM_ID'
17146                    , Error_Code => l_error_code
17147                    , Error_Flag => l_error_flag
17148                    , Error_Message => l_error_message
17149                    , Attribute_Value => l_attribute_value
17150 		   , Z_Line_Category_Code => 'RETURN'
17151                      );
17152     ELSE
17153 	OE_DEBUG_PUB.ADD('Its a Normal Order Line');
17154 
17155        INV_CUSTOMER_ITEM_GRP.CI_Attribute_Value(
17156                        Z_Customer_Item_Id => p_x_line_rec.ordered_item_id
17157                    , Z_Customer_Id => p_x_line_rec.sold_to_org_id
17158                    , Z_Address_Id => l_address_id
17159                    , Z_Organization_Id => nvl(p_x_line_rec.ship_from_org_id, OE_Sys_Parameters.value('MASTER_ORGANIZATION_ID'))
17160     -- This change is required since we are dropping the profile OE_ORGANIZATION    -- _ID. Change made by Esha.
17161                    , Z_Inventory_Item_Id => p_x_line_rec.inventory_item_id
17162                    , Attribute_Name => 'INVENTORY_ITEM_ID'
17163                    , Error_Code => l_error_code
17164                    , Error_Flag => l_error_flag
17165                    , Error_Message => l_error_message
17166                    , Attribute_Value => l_attribute_value
17167                    , Z_Line_Category_Code => 'ORDER'
17168                      );
17169    END IF;		--End of bug# 14352128
17170 
17171     oe_debug_pub.add('INVENTORY_ITEM_ID After call is '||l_attribute_value, 1);
17172     IF (l_attribute_value IS NOT NULL AND
17173        to_number(l_attribute_value) <> p_x_line_rec.inventory_item_id) THEN
17174        oe_debug_pub.add('Assigning new inventory_item_id', 1);
17175        l_update_inventory_item := FND_API.G_TRUE;
17176        l_inventory_item_id := TO_NUMBER(l_attribute_value);
17177     ELSIF to_number(l_attribute_value) = p_x_line_rec.inventory_item_id THEN
17178        NULL;
17179     ELSE
17180        oe_debug_pub.add('Issue error message', 1);
17181        oe_debug_pub.add('l_error_code: ' || l_error_code, 1);
17182        oe_debug_pub.add('l_error_flag: ' || l_error_flag, 1);
17183        oe_debug_pub.add('l_error_message: ' || l_error_message, 1);
17184        oe_debug_pub.add('p_x_line_rec.ordered_item_id:'||p_x_line_rec.ordered_item_id,1);
17185        fnd_message.set_name('ONT','OE_INVALIDATES_CUSTOMER_ITEM');
17186        OE_MSG_PUB.Add;
17187        x_return_status := FND_API.G_RET_STS_ERROR;
17188     END IF;
17189 
17190     oe_debug_pub.add('Return Status after calling CI_Attribute_Value '||x_return_status, 1);
17191     IF l_update_inventory_item = FND_API.G_TRUE THEN
17192 
17193      -- Call Process Order
17194 
17195      oe_debug_pub.add('Calling Process order to update inventory item', 1);
17196 	l_control_rec.controlled_operation := TRUE;
17197 	l_control_rec.check_security		:= TRUE;
17198     	l_control_rec.clear_dependents 	:= TRUE;
17199 	l_control_rec.default_attributes	:= TRUE;
17200 	l_control_rec.change_attributes	:= TRUE;
17201 	l_control_rec.validate_entity		:= TRUE;
17202     	l_control_rec.write_to_DB          := FALSE;
17203     	l_control_rec.process := FALSE;
17204 
17205 	l_old_line_tbl(1) 				:= p_x_line_rec;
17206      l_line_tbl(1) 					:= p_x_line_rec;
17207      l_line_tbl(1).inventory_item_id 	:= l_inventory_item_id;
17208 
17209 	Oe_Order_Pvt.Lines
17210 	(    p_validation_level			=> FND_API.G_VALID_LEVEL_NONE
17211 	,	p_control_rec				=> l_control_rec
17212 	,	p_x_line_tbl				=> l_line_tbl
17213 	,	p_x_old_line_tbl			=> l_old_line_tbl
17214 	,    x_return_status               => x_return_status
17215 	);
17216 
17217      oe_debug_pub.add('Return Status after calling Process order'||x_return_status, 1);
17218 
17219      p_x_line_rec := l_line_tbl(1);
17220 
17221    END IF;
17222 
17223    oe_debug_pub.add('Exiting Get_Inventory_Item', 1);
17224 
17225 END Get_Inventory_Item;
17226 
17227 
17228 
17229 /*----------------------------------------------------------
17230 PROCEDURE Clear_Shipping_Method
17231 -----------------------------------------------------------*/
17232 
17233 PROCEDURE Clear_Shipping_Method
17234 (p_x_line_rec				IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type)
17235 IS
17236 l_old_line_tbl				OE_Order_PUB.Line_Tbl_Type;
17237 l_line_tbl				OE_Order_PUB.Line_Tbl_Type;
17238 l_control_rec				OE_GLOBALS.Control_Rec_Type;
17239 l_return_status               VARCHAR2(30);
17240 BEGIN
17241 
17242 	l_control_rec.controlled_operation := TRUE;
17243 	l_control_rec.check_security		:= TRUE;
17244     	l_control_rec.clear_dependents 	:= FALSE;
17245 	l_control_rec.default_attributes	:= FALSE;
17246 	l_control_rec.change_attributes	:= TRUE;
17247 	l_control_rec.validate_entity		:= FALSE;
17248     	l_control_rec.write_to_DB          := FALSE;
17249     	l_control_rec.process := FALSE;
17250 
17251 	l_old_line_tbl(1) 				:= p_x_line_rec;
17252 	l_line_tbl(1) 					:= p_x_line_rec;
17253 	l_line_tbl(1).freight_carrier_code := NULL;
17254 	l_line_tbl(1).shipping_method_code := NULL;
17255 
17256 	Oe_Order_Pvt.Lines
17257 	(    p_validation_level			=> FND_API.G_VALID_LEVEL_NONE
17258 	,	p_control_rec			=> l_control_rec
17259 	,	p_x_line_tbl			=> l_line_tbl
17260 	,	p_x_old_line_tbl		=> l_old_line_tbl
17261 	,    x_return_status          => l_return_status
17262 	);
17263 
17264 	IF l_return_status = FND_API.G_RET_STS_ERROR THEN
17265 		RAISE FND_API.G_EXC_ERROR;
17266 	ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
17267 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
17268 	END IF;
17269 
17270 	p_x_line_rec := l_line_tbl(1);
17271 
17272 END Clear_Shipping_Method;
17273 
17274 
17275 
17276 /*----------------------------------------------------------
17277 PROCEDURE Clear_Commitment_Id
17278 -----------------------------------------------------------*/
17279 
17280 PROCEDURE Clear_Commitment_Id
17281       (p_x_line_rec                 IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type)
17282 IS
17283 l_old_line_tbl                OE_Order_PUB.Line_Tbl_Type;
17284 l_line_tbl                    OE_Order_PUB.Line_Tbl_Type;
17285 l_control_rec                 OE_GLOBALS.Control_Rec_Type;
17286 l_return_status               VARCHAR2(30);
17287 BEGIN
17288 
17289      l_control_rec.controlled_operation := TRUE;
17290      l_control_rec.check_security       := TRUE;
17291      l_control_rec.clear_dependents     := FALSE;
17292      l_control_rec.default_attributes   := FALSE;
17293      l_control_rec.change_attributes    := TRUE;
17294      l_control_rec.validate_entity      := FALSE;
17295      l_control_rec.write_to_DB          := FALSE;
17296      l_control_rec.process := FALSE;
17297 
17298      l_old_line_tbl(1)                  := p_x_line_rec;
17299      l_line_tbl(1)                      := p_x_line_rec;
17300      l_line_tbl(1).commitment_id        := NULL;
17301      --l_line_tbl(1).shipping_method_code := NULL;
17302 
17303      Oe_Order_Pvt.Lines
17304      (    p_validation_level            => FND_API.G_VALID_LEVEL_NONE
17305    ,    p_control_rec            => l_control_rec
17306    ,    p_x_line_tbl             => l_line_tbl
17307    ,    p_x_old_line_tbl         => l_old_line_tbl
17308    ,    x_return_status          => l_return_status
17309      );
17310 
17311      IF l_return_status = FND_API.G_RET_STS_ERROR THEN
17312           RAISE FND_API.G_EXC_ERROR;
17313      ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
17314           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
17315      END IF;
17316 
17317      p_x_line_rec := l_line_tbl(1);
17318 
17319 END Clear_Commitment_Id;
17320 
17321 --7688372 start
17322 PROCEDURE Load_attachment_rules_Line
17323 IS
17324    CURSOR line_attributes IS
17325    SELECT oare.ATTRIBUTE_CODE  attribute_code,Count(1) attachment_count
17326    FROM   oe_attachment_rule_elements oare, oe_attachment_rules  oar
17327    WHERE  oare.rule_id=oar.rule_id
17328    AND    oar.DATABASE_OBJECT_NAME='OE_AK_ORDER_LINES_V'
17329    GROUP BY oare.ATTRIBUTE_CODE;
17330 
17331 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
17332 
17333 BEGIN
17334  IF l_debug_level > 0 then
17335   oe_debug_pub.add('Entering Line Load_attachment_rules');
17336  End IF;
17337 
17338  IF g_attachrule_count_line_tab.count = 0 THEN
17339    FOR line_attributes_rec IN line_attributes LOOP
17340       g_attachrule_count_line_tab(line_attributes_rec.attribute_code) := line_attributes_rec.attachment_count;
17341    END LOOP;
17342  END IF;
17343 
17344  IF l_debug_level > 0 then
17345   oe_debug_pub.add('Exiting Line Load_attachment_rules');
17346  End IF;
17347 
17348 END Load_attachment_rules_Line;
17349 --7688372 end
17350 
17351 
17352 
17353 
17354 /*----------------------------------------------------------
17355  PROCEDURE Pre_Write_Process
17356 -----------------------------------------------------------*/
17357 
17358 PROCEDURE Pre_Write_Process
17359 (   p_x_line_rec                    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
17360 ,   p_old_line_rec                  IN  OE_Order_PUB.Line_Rec_Type :=
17361 								OE_Order_PUB.G_MISS_LINE_REC
17362 ) IS
17363 l_atp_tbl               OE_ATP.atp_tbl_type;
17364 l_return_status         varchar2(30);
17365 l_split_action_code     varchar2(30);
17366 l_param1                VARCHAR2(2000):= null;
17367 l_param2                VARCHAR2(240) := null;
17368 l_param3                VARCHAR2(240) := null;
17369 l_param4                VARCHAR2(240) := null;
17370 l_param5                VARCHAR2(240) := null;
17371 l_param6                VARCHAR2(240) := null;
17372 l_param9                VARCHAR2(240) := null;
17373 l_param10               VARCHAR2(240) := null;
17374 l_param11               VARCHAR2(240) := null;
17375 l_param12               VARCHAR2(240) := null;
17376 l_flag                  BOOLEAN;
17377 l_count			NUMBER;
17378 l_num                   NUMBER;
17379 l_msg_count                 NUMBER;
17380 l_msg_data                  VARCHAR2(2000);
17381 
17382 l_delta_qty                 NUMBER;
17383 l_delta_extended_amount     NUMBER;
17384 l_old_qty                   NUMBER;
17385 l_new_qty                   NUMBER;
17386 l_new_unit_selling_price    NUMBER;
17387 l_old_unit_selling_price    NUMBER;
17388 l_old_extended_amount       NUMBER;
17389 l_new_extended_amount       NUMBER;
17390 l_parent_document_type_id   NUMBER;
17391 l_pricing_event             VARCHAR2(30);
17392 l_require_reason            BOOLEAN ; -- 2921731
17393 l_promise_date_flag         VARCHAR2(2);
17394 --bug 4190357
17395 v_count                     NUMBER;
17396 l_meaning                   VARCHAR2(80);
17397 --bug 4190357
17398 l_modified_from             VARCHAR2(30);
17399 
17400 l_line_payment_type_code    VARCHAR2(30);
17401 
17402 
17403 --
17404 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
17405 --
17406 l_attr_attach_change         boolean := FALSE;  --6896311
17407 
17408 -- Bug 8940667,8947394 begin
17409 i number;
17410 l_G_Delayed_Requests OE_ORDER_PUB.Request_Tbl_Type;
17411 -- Bug 8940667,8947394 end
17412 
17413 l_ship_to_org_id           NUMBER;  --Bug# 13451157
17414 
17415 BEGIN
17416 
17417 if l_debug_level > 0 then
17418  oe_debug_pub.Add('Entering pre_write_process for line ID  : '||p_x_line_rec.line_id, 1);
17419 end if;
17420 
17421 -- bug fix 3350185:
17422 -- Audit Trail/Versioning moved to separate procedure below
17423    Version_Audit_Process( p_x_line_rec => p_x_line_rec,
17424                           p_old_line_rec => p_old_line_rec,
17425                           p_process_step => 1 );
17426 
17427 
17428 if l_debug_level > 0 then
17429    oe_debug_pub.Add('After Assign out rec', 1);
17430 end if;
17431 
17432    ------------------------------------------------------------------------
17433    -- Copy corresponding inventory item to the line if it is a CUST item
17434    ------------------------------------------------------------------------
17435 
17436    IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_from_org_id ,
17437                            p_old_line_rec.ship_from_org_id) OR
17438       NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_to_org_id ,
17439                         p_old_line_rec.ship_to_org_id) THEN
17440       if l_debug_level > 0 then
17441          oe_debug_pub.Add('RR:I1', 1);
17442       end if;
17443       IF p_x_line_rec.item_identifier_type = 'CUST' THEN
17444          if l_debug_level > 0 then
17445             oe_debug_pub.Add('RR:I2', 1);
17446          end if;
17447          IF (p_x_line_rec.ordered_item_id IS NOT NULL AND
17448              p_x_line_rec.ordered_item_id <> FND_API.G_MISS_NUM) THEN
17449             if l_debug_level > 0 then
17450                oe_debug_pub.add('return_status before calling Get_Inventory_Item '
17451 				||l_return_status, 1);
17452             end if;
17453             Get_Inventory_Item
17454 			( p_x_line_rec  	=> p_x_line_rec
17455             	, x_return_status	=> l_return_status);
17456 
17457             if l_debug_level > 0 then
17458                oe_debug_pub.add('return_status after calling Get_Inventory_Item '||l_return_status, 1);
17459             end if;
17460          END IF;
17461       END IF;
17462    if l_debug_level > 0 then
17463       oe_debug_pub.Add('RR:I2.5', 1);
17464    end if;
17465    END IF;
17466 
17467    if l_debug_level > 0 then
17468       oe_debug_pub.Add('RR:I3', 1);
17469    end if;
17470 
17471    IF l_return_status = FND_API.G_RET_STS_ERROR THEN
17472        RAISE FND_API.G_EXC_ERROR;
17473    END IF;
17474    IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
17475        RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
17476    END IF;
17477 
17478 
17479    ------------------------------------------------------------------------
17480    -- Populate ordered item field if item identifier type is INT or CUST
17481    /*Bug 2411113*/
17482    ------------------------------------------------------------------------
17483 
17484    IF (NOT OE_GLOBALS.EQUAL(p_x_line_rec.inventory_item_id ,
17485                            p_old_line_rec.inventory_item_id)
17486    AND p_x_line_rec.item_identifier_type in ('INT', 'CUST'))
17487 OR
17488    (p_x_line_rec.ordered_item =  FND_API.G_MISS_CHAR
17489    AND p_x_line_rec.item_identifier_type in ('INT', 'CUST')) THEN
17490 
17491       if l_debug_level > 0 then
17492          oe_debug_pub.Add('Before calling get_ordered_item', 1);
17493          oe_debug_pub.add('return_status before calling Get_ordered_Item '
17494 				||l_return_status, 1);
17495       end if;
17496          Oe_Oe_Form_Line.Get_Ordered_Item
17497             	 (x_return_status	=> l_return_status,
17498                   x_msg_count => l_msg_count,
17499                   x_msg_data => l_msg_data,
17500                   p_item_identifier_type =>p_x_line_rec.item_identifier_type,
17501                   p_inventory_item_id => p_x_line_rec.inventory_item_id,
17502                   p_ordered_item_id => p_x_line_rec.ordered_item_id,
17503                   p_sold_to_org_id => p_x_line_rec.sold_to_org_id,
17504                   x_ordered_item => p_x_line_rec.ordered_item);
17505 
17506       if l_debug_level > 0 then
17507          oe_debug_pub.add('return_status after calling Get_Ordered_Item '||l_return_status, 1);
17508       end if;
17509 
17510        --Fix for bug 3728638.
17511        IF p_x_line_rec.item_identifier_type='INT'
17512           and p_x_line_rec.ordered_item_id is NULL then
17513              p_x_line_rec.ordered_item_id:=p_x_line_rec.inventory_item_id;
17514        END IF;
17515 
17516    END IF;
17517 
17518 
17519    IF l_return_status = FND_API.G_RET_STS_ERROR THEN
17520        RAISE FND_API.G_EXC_ERROR;
17521    END IF;
17522    IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
17523        RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
17524    END IF;
17525 
17526 
17527    -------------------------------------------------------------------------
17528    -- lkxu: log a request to copy pricing attributes from top model line
17529    -- to the children lines
17530    --
17531    -- rlanka: changes made to fix bug 1730452
17532    -- rlanka: changes made to fix bug 1857538
17533    -------------------------------------------------------------------------
17534 
17535    IF (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION OR
17536        p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
17537       (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT and
17538        p_x_line_rec.line_id <> p_x_line_rec.top_model_line_id)) AND
17539        p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
17540 	  p_x_line_rec.split_from_line_id IS NULL THEN
17541 
17542 
17543 	/* Fix for bug 1730452 (May 1, 2001)
17544 	   if (model line has been copied from another order)
17545 	      Do NOT copy the pricing attributes of the model
17546 	      to its option/kit/class items.
17547 	   else
17548 	      Log a request to copy the pricing attributes of
17549 	      the top model line to its option/kit/class items.
17550 	   end if;
17551         */
17552 
17553       if l_debug_level > 0 then
17554        oe_debug_pub.add('Checking if it is a model line copied from another order');
17555       end if;
17556 
17557        begin
17558          select source_document_type_id
17559          into l_parent_document_type_id
17560          from oe_order_lines_all
17561          where line_id = p_x_line_rec.top_model_line_id;
17562 
17563 	 exception
17564 	    when NO_DATA_FOUND then NULL;
17565 
17566        end;
17567 
17568  	/* Note: Bug 1857538
17569 	  if source_document_type_id != 2 OR
17570 	     source_document_line_id = NULL, then
17571 		this line has newly been added as an option line (or)
17572 		this line has not been copied from another order
17573 		Log a request to copy pricing attributes from the top model line
17574 	  end if;
17575 
17576        */
17577 
17578       if l_debug_level > 0 then
17579        oe_debug_pub.add('parent source_document_type_id = ' || l_parent_document_type_id);
17580       end if;
17581 
17582       if ((nvl(l_parent_document_type_id,0) <> 2) OR
17583 	  (p_x_line_rec.source_document_line_id IS NULL) OR
17584 	  (p_x_line_rec.source_document_line_id = FND_API.G_MISS_NUM)) then
17585 
17586         if l_debug_level > 0 then
17587          oe_debug_pub.add('This class/kit/option line has not been copied');
17588 	 oe_debug_pub.add('from another order: So, log a delayed request');
17589 	 oe_debug_pub.add('to copy the model pricing attributes');
17590          oe_debug_pub.add('logging request for line  '||p_x_line_rec.line_id, 1);
17591         end if;
17592 
17593 	/* Fix for bug1857538
17594            - Log a delayed request to copy pricing attributes, using line_id
17595              as the entity id.  The corresponding change will be in
17596              OEXULPAB.pls
17597 	   - Idea is, copy_model_pattr for each option line.
17598         */
17599         OE_delayed_requests_Pvt.log_request(
17600 			p_entity_code 		=> OE_GLOBALS.G_ENTITY_LINE,
17601 			p_entity_id         	=> p_x_line_rec.line_id,
17602 			p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
17603 			p_requesting_entity_id   => p_x_line_rec.line_id,
17604                		p_param1                 => p_x_line_rec.line_id,
17605 	 		p_request_type           => OE_GLOBALS.G_COPY_MODEL_PATTR,
17606 	 		x_return_status          => l_return_status);
17607       end if;
17608 
17609    END IF;
17610 
17611    -- 2921731, storing and resetting the global cancel variable
17612    l_require_reason := OE_SALES_CAN_UTIL.G_REQUIRE_REASON;
17613    --1503357
17614    OE_LINE_ADJ_UTIL.Check_Canceled_PRG(p_old_line_rec => p_old_line_rec,
17615                                        p_new_line_rec => p_x_line_rec);
17616 
17617    OE_SALES_CAN_UTIL.G_REQUIRE_REASON := l_require_reason;
17618 
17619 /*sdatti*/
17620    IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_DELETE OR
17621        p_x_line_rec.ordered_quantity = 0)
17622        and OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110509' THEN
17623 
17624        IF Nvl(oe_globals.g_pricing_recursion,'N') = 'N'  THEN
17625           update_adjustment_flags(p_old_line_rec,p_x_line_rec);
17626        END IF;
17627     END IF;
17628 /*sdatti*/
17629 
17630    --Customer Acceptance
17631     IF NVL(OE_SYS_PARAMETERS.VALUE('ENABLE_FULFILLMENT_ACCEPTANCE'), 'N') = 'Y'
17632        AND p_x_line_rec.item_type_code= 'SERVICE' and p_x_line_rec.accepted_quantity is NULL THEN
17633        /*Default Parent acceptance details*/
17634          OE_ACCEPTANCE_UTIL.Default_Parent_Accept_Details(p_x_line_rec);
17635     END IF;
17636    --Customer Acceptance end
17637 
17638    ------------------------------------------------------------------------
17639    -- log a split payment request to cascade payment information from
17640    -- the parent line if the line is split
17641    ------------------------------------------------------------------------
17642 
17643    	IF  p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE
17644 	    AND p_x_line_rec.split_from_line_id is not null
17645             AND  OE_PREPAYMENT_UTIL.IS_MULTIPLE_PAYMENTS_ENABLED
17646 	   THEN
17647 
17648            BEGIN
17649              SELECT payment_type_code
17650              INTO   l_line_payment_type_code
17651              FROM   oe_payments
17652              WHERE  header_id = p_x_line_rec.header_id
17653              AND    line_id   = p_x_line_rec.split_from_line_id
17654              AND    payment_type_code IS NOT NULL
17655              AND    rownum = 1;
17656            EXCEPTION WHEN NO_DATA_FOUND THEN
17657              null;
17658            END;
17659 
17660            IF l_line_payment_type_code IS NOT NULL THEN
17661 	     oe_debug_pub.add('Log delayed request to cascade payment information for line: '||p_x_line_rec.line_id, 1);
17662 	     OE_Delayed_Requests_Pvt.Log_Request(
17663 	               p_entity_code            =>   OE_GLOBALS.G_ENTITY_LINE,
17664 	               p_entity_id             	=>   p_x_line_rec.line_id,
17665 	               p_requesting_entity_code	=>   OE_GLOBALS.G_ENTITY_LINE,
17666 	               p_requesting_entity_id  	=>   p_x_line_rec.line_id,
17667 	               p_request_type          	=>   OE_GLOBALS.G_SPLIT_PAYMENT,
17668 	               p_param1                 =>   p_x_line_rec.split_from_line_id,
17669 	               p_param2                 =>   p_x_line_rec.header_id,
17670 	               x_return_status          =>   l_return_status);
17671            END IF;
17672 	 END IF;
17673 
17674 
17675 
17676    ------------------------------------------------------------------------
17677    -- log a split hold request if the line is split
17678    ------------------------------------------------------------------------
17679 
17680    IF  p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
17681     p_x_line_rec.split_from_line_id is not null
17682    THEN
17683       if l_debug_level > 0 then
17684          oe_debug_pub.add('This is a new line after split', 1);
17685       end if;
17686          OE_Delayed_Requests_Pvt.Log_Request(
17687                p_entity_code             =>   OE_GLOBALS.G_ENTITY_LINE,
17688                p_entity_id               =>   p_x_line_rec.line_id,
17689                p_requesting_entity_code  =>   OE_GLOBALS.G_ENTITY_LINE,
17690                p_requesting_entity_id    =>   p_x_line_rec.line_id,
17691                p_request_type            =>   OE_GLOBALS.G_SPLIT_HOLD,
17692                p_param1                  =>   p_x_line_rec.split_from_line_id,
17693                x_return_status           =>   l_return_status);
17694    END IF;
17695 
17696 
17697    ------------------------------------------------------------------------
17698    -- Log the delayed request for Update Shipping if the line is deleted and
17699    -- it is interfaced with Shipping.
17700    ------------------------------------------------------------------------
17701 
17702    -- code fix for 3554622
17703    -- IF condition modified to log update_shipping delayed request when operations is UPDATE and ship set
17704    -- nulled out
17705    IF  l_debug_level > 0
17706    THEN
17707        oe_debug_pub.add('New Ship set Id :' || p_x_line_rec.ship_set_id,2);
17708        oe_debug_pub.add('Old Ship set Id :' || p_old_line_rec.ship_set_id,2);
17709        oe_debug_pub.add('Split Action:'||p_x_line_rec.split_Action_code,2);
17710    END IF;
17711    --8979782 : Logged request for change in warehouse while spliting
17712    --9366512 : Request to be logged for change of request date and ship_to
17713    --13444770: Group the attributes correctly in case of split
17714    -- Bug 12355310 : Replacing check on SI flag by new API
17715    -- IF	p_x_line_rec.shipping_interfaced_flag = 'Y'             AND
17716    IF (p_x_line_rec.shipping_interfaced_flag = 'Y' OR
17717       (p_x_line_rec.shippable_flag = 'Y' AND p_x_line_rec.booked_flag = 'Y'
17718        AND Shipping_Interfaced_Status(p_x_line_rec.line_id) = 'Y')) AND
17719      	(  (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE) OR
17720 	   (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
17721 	   (
17722            (p_x_line_rec.ship_set_id IS NULL                 AND
17723 	    p_old_line_rec.ship_set_id IS NOT NULL)           --AND
17724             OR (NOT OE_GLOBALS.Equal(p_x_line_rec.ship_from_org_id,
17725                           p_old_line_rec.ship_from_org_id))
17726             OR (NOT OE_GLOBALS.Equal(p_x_line_rec.request_date,
17727                           p_old_line_rec.request_date))
17728             OR (NOT OE_GLOBALS.Equal(p_x_line_rec.ship_to_org_id,
17729                           p_old_line_rec.ship_to_org_id))
17730             )  AND
17731 	    p_x_line_rec.split_action_code = 'SPLIT'
17732 	   )
17733 	)
17734    THEN
17735    -- code fix for 3554622
17736 
17737       if l_debug_level > 0 then
17738         oe_debug_pub.ADD('Update Shipping : '|| p_x_line_rec.line_id ,1);
17739       end if;
17740 		OE_Delayed_Requests_Pvt.Log_Request(
17741 		p_entity_code               => OE_GLOBALS.G_ENTITY_LINE,
17742 		p_entity_id                 => p_x_line_rec.line_id,
17743 		p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_LINE,
17744 		p_requesting_entity_id      => p_x_line_rec.line_id,
17745 		p_request_type              => OE_GLOBALS.G_UPDATE_SHIPPING,
17746 		p_request_unique_key1       => p_x_line_rec.operation,
17747 		p_param1                    => FND_API.G_TRUE,
17748 		p_param2                    => FND_API.G_FALSE,
17749 		x_return_status             => l_return_status);
17750 
17751    END IF;
17752    --bsadri call pricing for deleted lines
17753 
17754    IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_DELETE AND
17755       p_x_line_rec.order_quantity_uom IS NOT NULL AND
17756       p_x_line_rec.order_quantity_uom <> FND_API.G_MISS_CHAR AND
17757       NVL(p_x_line_rec.ordered_quantity,0) <> 0 AND
17758       p_x_line_rec.Ordered_Quantity <> FND_API.G_MISS_NUM   THEN
17759 
17760          IF (OE_GLOBALS.G_UI_FLAG) and
17761              OE_GLOBALS.G_DEFER_PRICING='N' and
17762           (nvl(Oe_Config_Pvt.oecfg_configuration_pricing,'N')='N') THEN
17763            if l_debug_level > 0 then
17764               oe_debug_pub.add('ui mode - delete');
17765            end if;
17766            IF p_x_line_rec.booked_flag='Y' THEN  --2442012
17767               l_pricing_event := 'BATCH,ORDER,BOOK';    --7494393
17768            ELSE
17769               l_pricing_event := 'ORDER';
17770            END IF;
17771            OE_delayed_requests_Pvt.log_request(
17772              p_entity_code                => OE_GLOBALS.G_ENTITY_ALL,
17773              p_entity_id                  => p_x_line_rec.Header_Id,
17774              p_requesting_entity_code     => OE_GLOBALS.G_ENTITY_ALL,
17775              p_requesting_entity_id       => p_x_line_rec.Header_Id,
17776              p_request_unique_key1        => l_pricing_event,
17777              p_param1                     => p_x_line_rec.header_id,
17778              p_param2                     => l_pricing_event,
17779              p_request_type               => OE_GLOBALS.G_PRICE_ORDER,
17780              x_return_status              => l_return_status);
17781 			 -- sol_ord_er #16014165
17782 			IF (p_x_line_rec.service_bill_option_code = 'FPOM') THEN
17783 			 oe_delayed_requests_pvt.log_request(
17784 								 p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
17785 								 p_entity_id              => p_x_line_rec.Header_Id,
17786 								 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
17787 								 p_requesting_entity_id   => p_x_line_rec.Header_Id,
17788 								 p_request_type           => OE_GLOBALS.G_SERVICE_FIRST_PERIOD_BILL,
17789 								 p_request_unique_key1    => 'ORDER',
17790 								 p_param1                 => p_x_line_rec.Header_Id,
17791 								 x_return_status          => l_return_status);
17792 			END IF;
17793 			-- sol_ord_er #16014165 end
17794          ELSE
17795            if l_debug_level > 0 then
17796               oe_debug_pub.add('batch mode - delete');
17797            end if;
17798            IF p_x_line_rec.booked_flag='Y' THEN
17799               l_pricing_event := 'BATCH,BOOK';
17800            ELSE
17801               l_pricing_event := 'BATCH';
17802            END IF;
17803           --bug 3018331
17804           if p_x_line_rec.source_document_type_id = 5 and
17805            nvl(fnd_profile.value('ONT_GRP_PRICE_FOR_DSP'),'N') = 'N' then
17806            null;
17807            if l_debug_level > 0 then
17808               oe_debug_pub.add('not logging price order - delete operation ');
17809            end if;
17810           else
17811            if l_debug_level > 0 then
17812               oe_debug_pub.add('logging price order - delete operation');
17813            end if;
17814            OE_delayed_requests_Pvt.log_request(
17815               p_entity_code               => OE_GLOBALS.G_ENTITY_ALL,
17816               p_entity_id                 => p_x_line_rec.Header_Id,
17817               p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_ALL,
17818               p_requesting_entity_id      => p_x_line_rec.Header_Id,
17819               p_request_unique_key1       => l_pricing_event,
17820               p_param1                    => p_x_line_rec.header_id,
17821               p_param2                    => l_pricing_event,
17822               p_request_type              => OE_GLOBALS.G_PRICE_ORDER,
17823               x_return_status             => l_return_status);
17824 			  -- sol_ord_er #16014165
17825 			IF (p_x_line_rec.service_bill_option_code = 'FPOM') THEN
17826 			 oe_delayed_requests_pvt.log_request(
17827 								 p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
17828 								 p_entity_id              => p_x_line_rec.Header_Id,
17829 								 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
17830 								 p_requesting_entity_id   => p_x_line_rec.Header_Id,
17831 								 p_request_type           => OE_GLOBALS.G_SERVICE_FIRST_PERIOD_BILL,
17832 								 p_request_unique_key1    => 'ORDER',
17833 								 p_param1                 => p_x_line_rec.Header_Id,
17834 								 x_return_status          => l_return_status);
17835 			END IF;
17836 			-- sol_ord_er #16014165 end
17837           end if;
17838          END IF;
17839          --
17840   /*       IF p_x_line_rec.booked_flag='Y' THEN
17841            if l_debug_level > 0 then
17842               oe_debug_pub.add('bokked - delete');
17843            end if;
17844            OE_delayed_requests_Pvt.log_request(
17845               p_entity_code               => OE_GLOBALS.G_ENTITY_ALL,
17846               p_entity_id                 => p_x_line_rec.Header_Id,
17847               p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_ALL,
17848               p_requesting_entity_id      => p_x_line_rec.Header_Id,
17849               p_request_unique_key1       => 'BOOK',
17850               p_param1                    => p_x_line_rec.header_id,
17851               p_param2                    => 'BOOK',
17852               p_request_type              => OE_GLOBALS.G_PRICE_ORDER,
17853               x_return_status             => l_return_status);
17854          END IF;   --2442012
17855  */
17856    END IF;
17857 
17858 
17859    --Bug# 9434723 - Start -
17860    -- Logging delayed request on DELETE Operation to delete header-level charges if there is no more qty on SO
17861     IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
17862         oe_debug_pub.add(' Logging delayed request to delete header-level charges ');
17863         oe_delayed_requests_pvt.log_request(
17864             p_entity_code                => OE_GLOBALS.G_ENTITY_ALL,
17865             p_entity_id                  => p_x_line_rec.header_id,
17866             p_requesting_entity_code     => OE_GLOBALS.G_ENTITY_ALL,
17867             p_requesting_entity_id       => p_x_line_rec.header_id,
17868             p_request_type               => OE_GLOBALS.G_DELETE_CHARGES,
17869             x_return_status              => l_return_status);
17870         oe_debug_pub.add('  After logging G_DELETE_CHARGES delayed request - l_return_status= '||l_return_status);
17871     END IF;
17872    --- Bug# 9434723  -- End
17873 
17874 
17875    if l_debug_level > 0 then
17876       oe_debug_pub.ADD('Raj:Split-Inside Request' ,1);
17877    end if;
17878 
17879    IF (p_x_line_rec.operation = oe_globals.g_opr_update) and
17880        NOT (p_x_line_rec.split_action_code IS NOT NULL AND
17881 	       p_x_line_rec.split_action_code <> FND_API.G_MISS_CHAR) AND
17882        (p_x_line_rec.line_set_id IS NOT NULL AND
17883         p_x_line_rec.line_set_id <> FND_API.G_MISS_NUM) THEN
17884 
17885      -- Addded project and task to fix bug #1229811
17886         if l_debug_level > 0 then
17887            oe_debug_pub.ADD('Raj:Split-Inside Request' ,1);
17888         end if;
17889 	IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.inventory_item_id ,
17890 				p_old_line_rec.inventory_item_id) OR
17891 	 NOT OE_GLOBALS.EQUAL(p_x_line_rec.order_quantity_uom ,
17892 				p_old_line_rec.order_quantity_uom) OR
17893 	 NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_tolerance_above ,
17894 				p_old_line_rec.ship_tolerance_above) OR
17895 	 NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_tolerance_below ,
17896 				p_old_line_rec.ship_tolerance_below) OR
17897 	 NOT OE_GLOBALS.EQUAL(p_x_line_rec.project_id ,
17898 				p_old_line_rec.project_id) OR
17899 	 NOT OE_GLOBALS.EQUAL(p_x_line_rec.task_id ,
17900 				p_old_line_rec.task_id) OR
17901 	 NOT OE_GLOBALS.EQUAL(Nvl (p_x_line_rec.fulfillment_base,'P') ,	     --ER#14763609
17902                               Nvl (p_old_line_rec.fulfillment_base,'P')) THEN
17903 		OE_Delayed_Requests_Pvt.Log_Request(
17904 		p_entity_code				=>	OE_GLOBALS.G_ENTITY_LINE,
17905 		p_entity_id                   =>   p_x_line_rec.line_set_id,
17906 		p_requesting_entity_code  	=>	OE_GLOBALS.G_ENTITY_LINE,
17907 		p_requesting_entity_id  	     =>	p_x_line_rec.line_id,
17908 		p_request_type				=>	OE_GLOBALS.G_VALIDATE_LINE_SET,
17909 		x_return_status			=>	l_return_status);
17910      END IF;
17911 
17912    END IF;
17913 
17914 
17915    ------------------------------------------------------------------------
17916    -- Perform Cancellation if necessary
17917    ------------------------------------------------------------------------
17918 
17919    -- QUOTING change
17920    IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,p_old_line_rec.ordered_quantity)
17921       AND nvl(p_x_line_rec.transaction_phase_code,'F') = 'F'
17922    THEN
17923       IF (p_x_line_rec.operation = oe_globals.G_OPR_UPDATE AND
17924        (p_old_line_rec.ordered_quantity <> FND_API.G_MISS_NUM OR
17925         p_old_line_rec.ordered_quantity IS NOT NULL)) then
17926 
17927           OE_SALES_CAN_UTIL.Perform_Line_change(p_x_line_rec,
17928                                    p_old_line_rec,
17929                                    l_return_status);
17930           IF l_return_status = FND_API.G_RET_STS_ERROR THEN
17931              RAISE FND_API.G_EXC_ERROR;
17932              --bug 6653192
17933           ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
17934 	     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
17935           END IF;
17936        END IF;
17937    END IF;
17938 
17939 
17940    ------------------------------------------------------------------------
17941     --Check over return
17942    ------------------------------------------------------------------------
17943 /*
17944   Moving this check to check_book_required_attributes in OEXLLINB
17945 */
17946 /*
17947   IF p_x_line_rec.line_category_code = 'RETURN' AND
17948      p_x_line_rec.reference_line_id is not NULL AND
17949      p_x_line_rec.booked_flag = 'Y' AND
17950      p_x_line_rec.cancelled_flag <> 'Y'
17951   THEN
17952    if l_debug_level > 0 then
17953       oe_debug_pub.ADD('Calling IS_OVER_RETURN ',1);
17954    end if;
17955       IF (OE_LINE_UTIL.Is_Over_Return(p_x_line_rec)) THEN
17956           FND_MESSAGE.Set_Name('ONT', 'OE_RETURN_INVALID_QUANTITY');
17957           OE_MSG_PUB.Add;
17958           RAISE FND_API.G_EXC_ERROR;
17959       END IF;
17960   END IF;
17961 */
17962 
17963    ------------------------------------------------------------------------
17964 	-- If ship from org has been changed validate the Shipping Method. If
17965 	-- Shipping Method is not a valid one for the ship from org clear the
17966 	-- Shipping Method field.
17967    ------------------------------------------------------------------------
17968 
17969    IF (p_x_line_rec.line_category_code <> 'RETURN') THEN
17970 
17971      IF (NOT OE_GLOBALS.Equal(p_x_line_rec.ship_from_org_id
17972 	,p_old_line_rec.ship_from_org_id) OR
17973 	NOT OE_GLOBALS.Equal(p_x_line_rec.shipping_method_code,
17974 	    p_old_line_rec.shipping_method_code))  THEN
17975 	    IF (p_x_line_rec.shipping_method_code IS NOT NULL AND
17976 		  p_x_line_rec.ship_from_org_id IS NOT NULL) THEN
17977 
17978                       IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110509' THEN
17979                          SELECT count(*)
17980                          INTO   l_count
17981                          FROM   wsh_carrier_services wsh,
17982                                 wsh_org_carrier_services wsh_org
17983                          WHERE  wsh_org.organization_id      = p_x_line_rec.ship_from_org_id
17984                            AND  wsh.carrier_service_id       = wsh_org.carrier_service_id
17985                            AND  wsh.ship_method_code         = p_x_line_rec.shipping_method_code
17986                            AND  wsh_org.enabled_flag         = 'Y';
17987                       ELSE
17988 
17989                          SELECT count(*)
17990                 	   INTO	l_count
17991                            FROM    wsh_carrier_ship_methods
17992                           WHERE   ship_method_code = p_x_line_rec.shipping_method_code
17993    	                    AND   organization_id = p_x_line_rec.ship_from_org_id;
17994                      END IF;
17995 	   	--  Valid Shipping Method Code.
17996 
17997                  if l_debug_level > 0 then
17998                     oe_debug_pub.add('Split By:'||p_x_line_rec.split_by);
17999                     oe_debug_pub.add('Split Action:'||p_x_line_rec.split_action_code);
18000                  end if;
18001 	   	IF	l_count  = 0 THEN
18002 
18003                   IF (nvl(p_x_line_rec.split_by,'X') <> 'SYSTEM' and
18004                                   NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT') THEN
18005 
18006                     --bug 4190357
18007                     select count(*) into v_count from oe_price_adjustments
18008                     where line_id = p_x_line_rec.line_id
18009                       and substitution_attribute = 'QUALIFIER_ATTRIBUTE11'
18010                       and list_line_type_code = 'TSN'
18011                       and modified_to = p_x_line_rec.shipping_method_code;
18012                     IF v_count > 0 THEN
18013                        IF l_debug_level > 0 THEN
18014                           oe_debug_pub.add('Deleting the tsn adjustments');
18015                        END IF;
18016                        DELETE FROM OE_PRICE_ADJUSTMENTS
18017                        WHERE LINE_ID = p_x_line_rec.line_id
18018                          AND LIST_LINE_TYPE_CODE = 'TSN'
18019                          AND SUBSTITUTION_ATTRIBUTE = 'QUALIFIER_ATTRIBUTE11'
18020                          AND MODIFIED_TO = p_x_line_rec.shipping_method_code
18021                        RETURNING MODIFIED_FROM into l_modified_from;
18022                     END IF;
18023                     --bug 4190357
18024 
18025 
18026                     if l_debug_level > 0 then
18027 	              oe_debug_pub.add('Calling process_order to clear the Shipping Method',2);
18028 	              oe_debug_pub.add('Value of shipping_method_code :'||p_x_line_rec.shipping_method_code,2);
18029                     end if;
18030                             --bug 4190357
18031                             select meaning into l_meaning from oe_ship_methods_v where lookup_type = 'SHIP_METHOD' and lookup_code=p_x_line_rec.shipping_method_code;
18032                             --bug 4190357
18033                             If v_count = 0 Then
18034                      	       Clear_Shipping_Method
18035 			  	 ( p_x_line_rec	=> p_x_line_rec);
18036                             Else
18037                                p_x_line_rec.shipping_method_code := l_modified_from;
18038                             End If;
18039                        ELSE
18040                             if l_debug_level > 0 then
18041                                oe_debug_pub.add('SYSTEM SPLIT Donot clear the Shipping Method',2);
18042                             end if;
18043                        END IF;
18044 
18045                OE_MSG_PUB.Update_Msg_Context(p_attribute_code => 'SHIPPING_METHOD');
18046 		     fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
18047                     --bug 4190357 added l_meaning to the token
18048 			FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
18049                         OE_Order_Util.Get_Attribute_Name('shipping_method_code') || ' ' || l_meaning);
18050 			OE_MSG_PUB.Add;
18051 			OE_MSG_PUB.Update_Msg_Context(p_attribute_code => null);
18052 
18053                if l_debug_level > 0 then
18054    	          oe_debug_pub.add('Value of freight_carrier after the call :'
18055 	         		||p_x_line_rec.shipping_method_code,2);
18056                end if;
18057 
18058 		END IF;
18059 
18060 	END IF;
18061 	END IF;
18062 
18063 	--14076417 start
18064 	 if l_debug_level > 0 then
18065    	    oe_debug_pub.add('OEXULINB1- SplitActionCode = ' ||p_x_line_rec.split_action_code
18066 		                            ||' -SplitLineID- '||p_x_line_rec.split_from_line_id);
18067 		oe_debug_pub.add('OEXULINB2- commitment_id = ' ||p_x_line_rec.commitment_id
18068 		                            ||' -OldCommitment- '||p_old_line_rec.commitment_id);
18069      end if;
18070     --14076417 end
18071 
18072      -- Also redo commitment if any the following attribute has changed.
18073 	-- and Commitment ID is not null
18074      -- QUOTING change
18075      IF (p_x_line_rec.commitment_id IS NOT NULL)
18076         AND nvl(p_x_line_rec.transaction_phase_code,'F') = 'F'
18077 		--14076417 start (to take care of parent 1.1 and new line 1.2 both conditions are required)
18078 		AND ( NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT' AND p_x_line_rec.split_from_line_id is NULL)
18079 		--14076417 end
18080      THEN
18081          IF
18082        ((
18083       OE_Quote_Util.G_COMPLETE_NEG = 'Y'
18084               AND
18085       NOT OE_GLOBALS.EQUAL(p_x_line_rec.transaction_phase_code
18086                       ,p_old_line_rec.transaction_phase_code)
18087               ) OR
18088           NOT OE_GLOBALS.Equal(p_x_line_rec.inventory_item_id,
18089                                 p_old_line_rec.inventory_item_id) OR
18090           NOT OE_GLOBALS.Equal(p_x_line_rec.sold_to_org_id,
18091                                 p_old_line_rec.sold_to_org_id) OR
18092           NOT OE_GLOBALS.Equal(p_x_line_rec.unit_selling_price,
18093                                 p_old_line_rec.unit_selling_price) OR
18094           NOT OE_GLOBALS.Equal(p_x_line_rec.commitment_id,
18095                                 p_old_line_rec.commitment_id) OR
18096           NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,p_old_line_rec.ordered_quantity)) And
18097           --fix bug 1669076
18098           NOT OE_GLOBALS.Equal(p_x_line_rec.commitment_id,
18099                                 p_old_line_rec.commitment_id)
18100           THEN
18101 
18102            IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,p_old_line_rec.ordered_quantity)
18103               OR NOT OE_GLOBALS.Equal(p_x_line_rec.unit_selling_price,p_old_line_rec.unit_selling_price)          --OR NOT OE_GLOBALS.Equal(p_x_
18104           Then
18105 
18106           If p_x_line_rec.ordered_quantity IS NULL OR
18107              p_x_line_rec.ordered_quantity = FND_API.G_MISS_NUM Then
18108              l_new_qty := 0;
18109           Else
18110              l_new_qty := p_x_line_rec.ordered_quantity;
18111           End If;
18112 
18113           If p_old_line_rec.ordered_quantity IS NULL OR
18114              p_old_line_rec.ordered_quantity = FND_API.G_MISS_NUM Then
18115              l_old_qty := 0;
18116           Else
18117              l_old_qty:= p_old_line_rec.ordered_quantity;
18118           End If;
18119 
18120           If p_x_line_rec.unit_selling_price Is NULL or
18121              p_x_line_rec.unit_selling_price = FND_API.G_MISS_NUM Then
18122              l_new_unit_selling_price := 0;
18123           Else
18124              l_new_unit_selling_price := p_x_line_rec.unit_selling_price;
18125           End If;
18126 
18127           If p_old_line_rec.unit_selling_price is NULL or
18128              p_old_line_rec.unit_selling_price = FND_API.G_MISS_NUM Then
18129 
18130              l_old_unit_selling_price :=0;
18131           Else
18132              l_old_unit_selling_price :=p_old_line_rec.unit_selling_price;
18133           End If;
18134 
18135 
18136          If NOT OE_GLOBALS.Equal(p_x_line_rec.commitment_id,
18137                                 p_old_line_rec.commitment_id) Then
18138            /* commtiment can change event quantity can change
18139               We always pass in the new, not the delta when commitment changes */
18140 
18141             l_delta_extended_amount := p_x_line_rec.ordered_quantity *
18142                                        p_x_line_rec.unit_selling_price;
18143 
18144          Else
18145           /* Only quantity or unit selling price change, therefore delta */
18146           l_new_extended_amount := l_new_unit_selling_price * l_new_qty;
18147           l_old_extended_amount := l_old_unit_selling_price * l_old_qty;
18148           l_delta_extended_amount := l_new_extended_amount - l_old_extended_amount;
18149 
18150          End If;
18151 
18152 
18153 
18154           Else
18155              /* commtiment can change but quantity will not change
18156                 We always pass in the new, not the delta when commitment changes*/
18157             l_delta_extended_amount := p_x_line_rec.ordered_quantity *
18158                                        p_x_line_rec.unit_selling_price;
18159           End If;
18160 
18161 
18162       -- commented out the IF condition for bug 1905467.
18163       -- IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
18164 
18165       -- retain the original commitment functionality
18166       IF Not Oe_Commitment_pvt.do_commitment_sequencing THEN
18167           if l_debug_level > 0 then
18168              oe_debug_pub.add('entering evaluate commitment!',1);
18169           end if;
18170           oe_commitment_pvt.evaluate_commitment(
18171                             p_commitment_id      => p_x_line_rec.commitment_id,
18172  		 	    p_header_id          => p_x_line_rec.header_id,
18173                             p_unit_selling_price => l_delta_extended_amount,
18174                             x_return_status      => l_return_status,
18175                             x_msg_count          => l_msg_count,
18176                             x_msg_data           => l_msg_data);
18177           IF l_return_status = FND_API.G_RET_STS_ERROR THEN
18178               if l_debug_level > 0 then
18179                  oe_debug_pub.add('Value of Commitment_Id B4 Clear_Commitment_Id:'
18180                                  ||p_x_line_rec.commitment_id,1);
18181               end if;
18182               Clear_Commitment_Id
18183                     ( p_x_line_rec => p_x_line_rec);
18184               if l_debug_level > 0 then
18185                  oe_debug_pub.add('Value of Commitment_Id after the call :'
18186                     ||p_x_line_rec.commitment_id,1);
18187               end if;
18188               Raise FND_API.G_EXC_ERROR;
18189 
18190           ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
18191               RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
18192           END IF;
18193        END IF;
18194        -- END IF;
18195 
18196 
18197        END IF;
18198      END IF; --(p_x_line_rec.commitment_id IS NOT NULL)
18199      --------------------------------
18200 
18201   END IF; -- IF (p_x_line_rec.line_category_code <> 'RETURN')
18202 
18203   -- QUOTING change - log request only for fulfillment phase
18204   --4504362 : Branch scheduling checks removed
18205 	-- If this is a split line then put this in fulfilment set if any.
18206 
18207 	IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
18208 	    p_x_line_rec.split_from_line_id IS NOT NULL ) THEN
18209 	    oe_split_util.Add_To_Fulfillment_Set(p_line_rec => p_x_line_rec);
18210 	END IF;
18211 
18212     ------------------------------------------------------------------------
18213      -- If line is being created by a split operation, then log request
18214      -- to copy attachments else log request to apply automatic attachments
18215     ------------------------------------------------------------------------
18216 
18217      IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE  THEN
18218 
18219         IF NVL(p_x_line_rec.split_from_line_id,FND_API.G_MISS_NUM)
18220             = FND_API.G_MISS_NUM
18221         THEN
18222 
18223             -- Performance Improvement Bug 1929163:
18224             -- Log request to apply automatic attachments based on profile
18225             IF G_APPLY_AUTOMATIC_ATCHMT = 'Y' THEN
18226                if l_debug_level > 0 then
18227                   oe_debug_pub.add('log request to apply atchmt',1);
18228                end if;
18229                OE_delayed_requests_Pvt.Log_Request
18230                     (p_entity_code       => OE_GLOBALS.G_ENTITY_LINE,
18231                      p_entity_id         => p_x_line_rec.line_id,
18232                      p_request_type      => OE_GLOBALS.G_APPLY_AUTOMATIC_ATCHMT,
18233                      p_requesting_entity_code     => OE_GLOBALS.G_ENTITY_LINE,
18234                      p_requesting_entity_id       => p_x_line_rec.line_id,
18235                      x_return_status              => l_return_status
18236                      );
18237             END IF;
18238 
18239         ELSE
18240 
18241             IF p_x_line_rec.split_by = 'SYSTEM' THEN
18242                if l_debug_level > 0 then
18243                   oe_debug_pub.add('log request to copy all atchmt',1);
18244                end if;
18245                OE_delayed_requests_Pvt.Log_Request
18246                     (p_entity_code       => OE_GLOBALS.G_ENTITY_LINE,
18247                      p_entity_id         => p_x_line_rec.line_id,
18248                      p_param1            => p_x_line_rec.split_from_line_id,
18249                      p_param2            => 'N', -- copy ALL attachments
18250                      p_request_type      => OE_GLOBALS.G_COPY_ATCHMT,
18251                      p_requesting_entity_code     => OE_GLOBALS.G_ENTITY_LINE,
18252                      p_requesting_entity_id       => p_x_line_rec.line_id,
18253                      x_return_status              => l_return_status
18254                      );
18255 
18256             ELSE
18257                --Start of bug# 13451157
18258                IF G_APPLY_AUTOMATIC_ATCHMT = 'Y' THEN
18259 
18260                   BEGIN
18261                     SELECT ship_to_org_id
18262                       INTO l_ship_to_org_id
18263                       FROM oe_order_lines
18264                      WHERE line_id = p_x_line_rec.split_from_line_id;
18265 
18266                   EXCEPTION
18267                       WHEN OTHERS THEN
18268                       	   IF l_debug_level > 0 THEN
18269                               oe_debug_pub.add('SQL error - '||sqlerrm);
18270                            END IF;
18271                   END;
18272 
18273 
18274                   IF nvl(l_ship_to_org_id,-1) = nvl(p_x_line_rec.ship_to_org_id,-1) THEN  --<Ship To is same as that of the original line_id i.e split_from_line_id>
18275                      IF l_debug_level > 0 THEN
18276                         oe_debug_pub.add('log request to copy all atchmt',1);
18277                      END IF;
18278                      OE_delayed_requests_Pvt.Log_Request
18279                      (p_entity_code       => OE_GLOBALS.G_ENTITY_LINE,
18280                       p_entity_id         => p_x_line_rec.line_id,
18281                       p_param1            => p_x_line_rec.split_from_line_id,
18282                       p_param2            => 'N', -- copy ALL attachments
18283                       p_request_type      => OE_GLOBALS.G_COPY_ATCHMT,
18284                       p_requesting_entity_code     =>OE_GLOBALS.G_ENTITY_LINE,
18285 	  	      p_requesting_entity_id       => p_x_line_rec.line_id,
18286 	  	      x_return_status              => l_return_status
18287                      );
18288 
18289                   ELSE --<Ship To is different>
18290                      IF l_debug_level > 0 THEN
18291                       oe_debug_pub.add('log request to apply atchmt',1);
18292                      END IF;
18293                      OE_delayed_requests_Pvt.Log_Request
18294                      (p_entity_code       => OE_GLOBALS.G_ENTITY_LINE,
18295                       p_entity_id         => p_x_line_rec.line_id,
18296                       p_request_type      =>OE_GLOBALS.G_APPLY_AUTOMATIC_ATCHMT,
18297                       p_requesting_entity_code     => OE_GLOBALS.G_ENTITY_LINE,
18298                       p_requesting_entity_id       => p_x_line_rec.line_id,
18299                       x_return_status              => l_return_status
18300                      );
18301                      IF l_debug_level > 0 THEN
18302                   	oe_debug_pub.add('log request to copy manual atchmt',1);
18303                	     END IF;
18304                      OE_delayed_requests_Pvt.Log_Request
18305                      (p_entity_code       => OE_GLOBALS.G_ENTITY_LINE,
18306                       p_entity_id         => p_x_line_rec.line_id,
18307                       p_param1            => p_x_line_rec.split_from_line_id,
18308                       p_param2            => 'Y', -- copy only manual attachments
18309                       p_request_type      => OE_GLOBALS.G_COPY_ATCHMT,
18310                       p_requesting_entity_code     => OE_GLOBALS.G_ENTITY_LINE,
18311                       p_requesting_entity_id       => p_x_line_rec.line_id,
18312                       x_return_status              => l_return_status
18313                      );
18314 
18315                   END IF;
18316                ELSE  -- G_APPLY_AUTOMATIC_ATCHMT <> 'Y'
18317                  if l_debug_level > 0 then
18318                     oe_debug_pub.add('log request to copy manual atchmt',1);
18319                  end if;
18320                  OE_delayed_requests_Pvt.Log_Request
18321                     (p_entity_code       => OE_GLOBALS.G_ENTITY_LINE,
18322                      p_entity_id         => p_x_line_rec.line_id,
18323                      p_param1            => p_x_line_rec.split_from_line_id,
18324                      p_param2            => 'Y', -- copy only manual attachments
18325                      p_request_type      => OE_GLOBALS.G_COPY_ATCHMT,
18326                      p_requesting_entity_code     => OE_GLOBALS.G_ENTITY_LINE,
18327                      p_requesting_entity_id       => p_x_line_rec.line_id,
18328                      x_return_status              => l_return_status
18329                      );
18330               END IF;  -- if  G_APPLY_AUTOMATIC_ATCHMT = 'Y' , --End of bug# 13451157
18331             END IF; --  if SYSTEM split else
18332 
18333         END IF; -- if split else
18334     ELSE  -- 5893276
18335        IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
18336             G_APPLY_AUTOMATIC_ATCHMT = 'Y' THEN
18337                if l_debug_level > 0 then
18338                   oe_debug_pub.add('log request to apply atchmt for UPDATE ',1);
18339                end if;
18340 
18341 --6896311
18342 
18343 --7688372 start
18344             Load_attachment_rules_Line;
18345 --7688372 end
18346 
18347             IF (NOT OE_GLOBALS.Equal(p_x_line_rec.INVOICE_TO_ORG_ID
18348                                     ,p_old_line_rec.INVOICE_TO_ORG_ID) AND g_attachrule_count_line_tab.exists('INVOICE_TO_ORG_ID'))  --7688372
18349             OR (NOT OE_GLOBALS.Equal(p_x_line_rec.SOLD_TO_ORG_ID
18350                                     ,p_old_line_rec.SOLD_TO_ORG_ID) AND g_attachrule_count_line_tab.exists('SOLD_TO_ORG_ID'))  --7688372
18351             OR (NOT OE_GLOBALS.Equal(p_x_line_rec.CUST_PO_NUMBER
18352                                     ,p_old_line_rec.CUST_PO_NUMBER) AND g_attachrule_count_line_tab.exists('CUST_PO_NUMBER'))  --7688372
18353             OR (NOT OE_GLOBALS.Equal(p_x_line_rec.INVENTORY_ITEM_ID
18354                                     ,p_old_line_rec.INVENTORY_ITEM_ID) AND g_attachrule_count_line_tab.exists('INVENTORY_ITEM_ID'))  --7688372
18355             OR (NOT OE_GLOBALS.Equal(p_x_line_rec.LINE_CATEGORY_CODE
18356                                     ,p_old_line_rec.LINE_CATEGORY_CODE) AND g_attachrule_count_line_tab.exists('LINE_CATEGORY_CODE'))  --7688372
18357             OR (NOT OE_GLOBALS.Equal(p_x_line_rec.LINE_TYPE_ID
18358                                     ,p_old_line_rec.LINE_TYPE_ID) AND g_attachrule_count_line_tab.exists('LINE_TYPE_ID'))  --7688372
18359             OR (NOT OE_GLOBALS.Equal(p_x_line_rec.SHIP_TO_ORG_ID
18360                                     ,p_old_line_rec.SHIP_TO_ORG_ID) AND g_attachrule_count_line_tab.exists('SHIP_TO_ORG_ID'))  --7688372
18361             THEN
18362 
18363                 l_attr_attach_change := TRUE;
18364 
18365             END IF;
18366 --6896311
18367              IF l_attr_attach_change THEN  --6896311
18368                OE_delayed_requests_Pvt.Log_Request
18369                     (p_entity_code       => OE_GLOBALS.G_ENTITY_LINE,
18370                      p_entity_id         => p_x_line_rec.line_id,
18371                      p_request_type      => OE_GLOBALS.G_APPLY_AUTOMATIC_ATCHMT,
18372                      p_requesting_entity_code     => OE_GLOBALS.G_ENTITY_LINE,
18373                      p_requesting_entity_id       => p_x_line_rec.line_id,
18374                      x_return_status              => l_return_status
18375                      );
18376              END IF;  --6896311
18377 
18378          END IF;
18379 
18380      END IF; -- if CREATE operation log request for attachments
18381 
18382 
18383    ------------------------------------------------------------------------
18384      -- Fix for bug1167537
18385      -- Clear the line record cached by defaulting APIs so that the
18386      -- default values on the child entities of line record are
18387      -- obtained from the updated line record
18388    ------------------------------------------------------------------------
18389 
18390      IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
18391           ONT_LINE_Def_Util.Clear_LINE_Cache;
18392      END IF;
18393 
18394 
18395    ------------------------------------------------------------------------
18396      -- if there is an update operation on model line,
18397      -- clear the cached model line record if any.
18398    ------------------------------------------------------------------------
18399 
18400      IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
18401         p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL THEN
18402         if l_debug_level > 0 then
18403            oe_debug_pub.add('clear the cached top model record', 1);
18404            oe_debug_pub.add('model line: '|| p_x_line_rec.line_id, 1);
18405         end if;
18406         OE_Order_Cache.Clear_Top_Model_Line(p_key => p_x_line_rec.line_id);
18407      END IF;
18408 
18409     -- Changes for Late Demand Penalty Factor
18410       if l_debug_level > 0 then
18411          oe_debug_pub.add('Late Demand Penalty Factor',1);
18412       end if;
18413      IF(p_x_line_rec.late_demand_penalty_factor IS NOT NULL AND
18414         p_x_line_rec.late_demand_penalty_factor  <>  FND_API.G_MISS_NUM AND
18415             p_x_line_rec.late_demand_penalty_factor < 0) THEN
18416 
18417                 FND_MESSAGE.SET_NAME('ONT','ONT_SCH_DEMAND_FACTOR_ZERO');
18418                 OE_MSG_PUB.Add;
18419         RAISE FND_API.G_EXC_ERROR;
18420      END IF;
18421    ------------------------------------------------------------------------
18422    -- Call Scheduling to perform any scheduling on the line, if needed
18423    ------------------------------------------------------------------------
18424 
18425     -- Added code in delete_dependency for delete operation.
18426     --4504362 : branch scheduling checks removed
18427       IF OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING = 'Y' THEN
18428         -- After the restructure post write code will call
18429         -- scheduling and scheduling may or may not require on the
18430         -- line. However, we need to set the resource flag.
18431 
18432         if l_debug_level > 0 then
18433            oe_debug_pub.add('Setting the resource ',1);
18434         end if;
18435         IF NOT OE_GLOBALS.Equal(p_old_line_rec.ship_from_org_id,
18436                               p_x_line_rec.ship_from_org_id)
18437         THEN
18438          IF p_x_line_rec.ship_from_org_id is not null
18439          THEN
18440              if l_debug_level > 0 then
18441                 oe_debug_pub.add('Setting re_source_flag to N',1);
18442              end if;
18443              p_x_line_rec.re_source_flag := 'N';
18444          ELSE
18445              if l_debug_level > 0 then
18446                 oe_debug_pub.add('1.Setting re_source_flag to null',1);
18447              end if;
18448              p_x_line_rec.re_source_flag := '';
18449          END IF;
18450         ELSIF p_x_line_rec.ship_from_org_id is null
18451         THEN
18452           if l_debug_level > 0 then
18453              oe_debug_pub.add('2.Setting re_source_flag to null',1);
18454           end if;
18455           p_x_line_rec.re_source_flag := '';
18456         END IF;
18457 
18458         -- If inventory item is changed on a unscheduled substituted
18459         -- item, clear the original item information.
18460         -- Scheduling code will take care of clearing original
18461         -- inventory information on scheduled line since if we
18462         -- place the clearing logic here for a scheduled line, some
18463         -- of the delayed request may clear the original item information
18464         -- after substitution.
18465 
18466         IF NOT OE_GLOBALS.Equal(p_x_line_rec.Inventory_Item_Id,
18467                                 p_old_line_rec.Inventory_Item_Id)
18468         AND p_x_line_rec.schedule_status_code is null
18469         AND p_x_line_rec.Original_Inventory_Item_Id IS NOT NULL
18470         AND p_x_line_rec.item_relationship_type IS NULL
18471         THEN
18472 
18473            if l_debug_level > 0 then
18474               oe_debug_pub.add('PWP: clearing out original item fields');
18475            end if;
18476            p_x_line_rec.Original_Inventory_Item_Id    := Null;
18477            p_x_line_rec.Original_item_identifier_Type := Null;
18478            p_x_line_rec.Original_ordered_item_id      := Null;
18479            p_x_line_rec.Original_ordered_item         := Null;
18480 
18481 
18482         END IF;
18483       END IF; -- perform scheduling.
18484 
18485 
18486     -- following 3 calls are mainly related to configuration lines.
18487     -- do not move Log_CTO_Requests above scheduling
18488     -- 4504362 :branch scheduling checks removed
18489 
18490     -- bug fix : 2307423, do not log if remnant.
18491     IF p_x_line_rec.top_model_line_id is NOT NULL THEN
18492 
18493       Log_Config_Requests( p_x_line_rec    => p_x_line_rec
18494                           ,p_old_line_rec  => p_old_line_rec
18495                           ,x_return_status => l_return_status);
18496 
18497       IF nvl(p_x_line_rec.model_remnant_flag, 'N') = 'N' THEN
18498         IF NOT((OE_GENESIS_UTIL.G_INCOMING_FROM_DOO)
18499 	   AND Nvl(p_x_line_rec.ordered_quantity,FND_API.G_MISS_NUM) <> 0) -- Bug 16266748
18500 	THEN -- DOO Pre Exploded Kit ER 9339742
18501          -- This Global is checked here and not inside the procedure
18502          -- Log_Cascade_Requests because we are currently considering
18503          -- only PTO and Kit, while ATO flow is not supported in DOO
18504 
18505          Log_Cascade_Requests( p_x_line_rec    => p_x_line_rec
18506                              ,p_old_line_rec  => p_old_line_rec
18507                              ,x_return_status => l_return_status);
18508         END IF;
18509       END IF;
18510     END IF;
18511 
18512 
18513 /* 7576948: Commenting for IR ISO CMS Project
18514 
18515   if l_debug_level > 0 then
18516      oe_debug_pub.add('Before checking for system split on int ord');
18517   end if;
18518   IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE) AND
18519 	  (p_x_line_rec.split_by = 'SYSTEM') AND
18520 	  (p_x_line_rec.order_source_id = 10) THEN
18521             FND_MESSAGE.SET_NAME('ONT','OE_CHG_CORR_REQ');
18522             -- { start fix for 2648277
18523 	    FND_MESSAGE.SET_TOKEN('CHG_ATTR',
18524                OE_Order_Util.Get_Attribute_Name('ordered_quantity'));
18525             -- end fix for 2648277}
18526 	 OE_MSG_PUB.ADD;
18527     END IF;
18528 
18529 */ -- Commented for IR ISO CMS project
18530 
18531 -- bug fix 3350185:
18532 -- Audit Trail/Versioning moved to separate procedure below
18533    Version_Audit_Process( p_x_line_rec => p_x_line_rec,
18534                           p_old_line_rec => p_old_line_rec,
18535                           p_process_step => 2 );
18536 
18537 -- Log Drop Ship CMS Delayed Request for Externally sources
18538 -- lines. Do not log for System Split Lines.
18539 
18540 IF p_x_line_rec.source_type_code  = 'EXTERNAL' AND
18541    p_x_line_rec.booked_flag       = 'Y'  AND
18542     NOT (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
18543         p_x_line_rec.split_by = 'SYSTEM' AND
18544           NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT') AND
18545    (PO_CODE_RELEASE_GRP.Current_Release >=
18546          PO_CODE_RELEASE_GRP.PRC_11i_Family_Pack_J) AND
18547              OE_CODE_CONTROL.Code_Release_Level  >= '110510' THEN
18548 
18549        Log_Dropship_CMS_Request
18550                       (p_x_line_rec    =>   p_x_line_rec
18551                       ,p_old_line_rec  =>   p_old_line_rec
18552                       );
18553 
18554        -- Bug 8940667,8947394 begin
18555        -- Processing the request logged above for CONFIG Lines
18556        -- since deletion of CONFIG Lines removes the Delayed Request
18557        -- For Dropship Change Management.
18558 
18559        IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_DELETE AND
18560            p_x_line_rec.item_type_code = 'CONFIG') THEN
18561 
18562           IF l_debug_level > 0 THEN
18563        	     oe_debug_pub.ADD('Processing DROPSHIP_CMS Request for CONFIG Line');
18564           END IF;
18565 
18566           i := oe_delayed_requests_pvt.G_Delayed_Requests.first;
18567 
18568           WHILE i IS NOT NULL LOOP
18569 
18570        	     IF (oe_delayed_requests_pvt.G_Delayed_Requests(i).request_type = OE_GLOBALS.G_DROPSHIP_CMS
18571                 AND oe_delayed_requests_pvt.G_Delayed_Requests(i).entity_code = OE_GLOBALS.G_ENTITY_ALL
18572                 AND oe_delayed_requests_pvt.G_Delayed_Requests(i).entity_id = p_x_line_rec.line_id) THEN
18573 
18574        	        IF l_debug_level > 0 THEN
18575                     oe_debug_pub.add('G_Delayed_Requests.entity_code/entity_id' ||
18576                     oe_delayed_requests_pvt.G_Delayed_Requests(i).entity_code || '/' ||
18577                     oe_delayed_requests_pvt.G_Delayed_Requests(i).entity_id);
18578                     oe_debug_pub.add('G_Delayed_Requests.request_type' ||
18579                     oe_delayed_requests_pvt.G_Delayed_Requests(i).request_type);
18580 
18581                 END IF;
18582 
18583                 l_G_Delayed_Requests(1) := oe_delayed_requests_pvt.G_Delayed_Requests(i);
18584 
18585                 oe_purchase_release_pvt.Process_DropShip_CMS_Requests
18586                   (p_request_tbl => l_G_Delayed_Requests
18587                   ,x_return_status => l_return_status);
18588 
18589              END IF;
18590 
18591              i := oe_delayed_requests_pvt.G_Delayed_Requests.Next(i);
18592 
18593           END LOOP;
18594 
18595        END IF;
18596 
18597        -- Bug 8940667,8947394 end
18598 
18599 END IF;
18600 
18601 -- If the ordered quantity on a line becoming Zero thatcan be a cancellation
18602 -- Or mere decrement of quantity the line is taken out of ship sets and
18603 -- ariival sets
18604 
18605                 IF p_x_line_rec.ordered_quantity = 0 THEN
18606                         p_x_line_rec.ship_set_id := null;
18607                         p_x_line_rec.arrival_set_id := null;
18608                 END IF;
18609     -- Pack J
18610     -- Promise Date setup with Request date
18611     -- 'FR' - With First Request date
18612     -- 'R'  -- For all change in Request date
18613     IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
18614        l_promise_date_flag := OE_SYS_PARAMETERS.value('PROMISE_DATE_FLAG');
18615 
18616        IF l_promise_date_flag = 'FR'
18617         AND (p_old_line_rec.request_date = FND_API.G_MISS_DATE
18618            OR p_old_line_rec.request_date IS NULL) THEN
18619          p_x_line_rec.promise_date := p_x_line_rec.request_date;
18620        ELSIF l_promise_date_flag = 'R' THEN
18621           p_x_line_rec.promise_date := p_x_line_rec.request_date;
18622        END IF;
18623     END IF;
18624 
18625 
18626    if l_debug_level > 0 then
18627       OE_DEBUG_PUB.add('Exiting from Lines Pre-Write process',1);
18628    end if;
18629 EXCEPTION
18630     WHEN FND_API.G_EXC_ERROR THEN
18631         RAISE;
18632     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
18633         RAISE;
18634     WHEN OTHERS THEN
18635         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
18636         THEN
18637             oe_msg_pub.Add_Exc_Msg
18638             (   G_PKG_NAME
18639           ,   'Pre_Write_Process'
18640             );
18641         END IF;
18642         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
18643 END Pre_Write_Process;
18644 
18645 PROCEDURE Version_Audit_Process
18646 (   p_x_line_rec                    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
18647 ,   p_old_line_rec                  IN  OE_Order_PUB.Line_Rec_Type :=
18648                                         OE_Order_PUB.G_MISS_LINE_REC
18649 ,   p_process_step                  IN NUMBER := 3
18650 )
18651 IS
18652 
18653 l_ind                       NUMBER;
18654 l_code_level                varchar2(6) := OE_CODE_CONTROL.GET_CODE_RELEASE_LEVEL;
18655 l_audit_trail_enabled       VARCHAR2(1) := OE_SYS_PARAMETERS.VALUE('AUDIT_TRAIL_ENABLE_FLAG');
18656 
18657 l_return_status                VARCHAR2(30);
18658 l_reason_code VARCHAR2(30);
18659 l_reason_comments VARCHAR2(2000);
18660 --
18661 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
18662 --
18663 BEGIN
18664 /*
18665 The p_process_step value passed in determines the processes run. The first time it is called
18666 from Pre_Write_Process, this procedure first performs process 1. Later in Pre_Write it is
18667 called with process 2. From Pricing we are calling with process 3 to perform both actions.
18668 */
18669 
18670 IF p_process_step IN (1,3) THEN
18671 
18672 /* Start AuditTrail */
18673 
18674 IF l_code_level >= '110508' and nvl(l_audit_trail_enabled,'D') <> 'D' THEN
18675    IF (p_x_line_rec.operation  = OE_GLOBALS.G_OPR_UPDATE) then
18676        IF OE_GLOBALS.OE_AUDIT_HISTORY_TBL.count > 0 THEN
18677           FOR l_ind in 1..OE_GLOBALS.oe_audit_history_tbl.last LOOP
18678               IF OE_GLOBALS.OE_AUDIT_HISTORY_TBL.exists(l_ind) THEN
18679                  IF OE_GLOBALS.oe_audit_history_tbl(l_ind).LINE_ID = p_x_line_rec.line_id AND
18680                     OE_GLOBALS.oe_audit_history_tbl(l_ind).HISTORY_TYPE = 'R' THEN   -- flag 'R' denotes requires reason
18681                     if l_debug_level > 0 then
18682                        OE_DEBUG_PUB.add('OEXULINB- Audit Reason Required', 5);
18683                     end if;
18684                     IF (p_x_line_rec.change_reason IS NULL OR
18685                         p_x_line_rec.change_reason = FND_API.G_MISS_CHAR OR
18686                         NOT OE_Validate.Change_Reason_Code(p_x_line_rec.change_reason)) THEN
18687 
18688                        IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
18689                          IF OE_Versioning_Util.Captured_Reason IS NULL THEN
18690                             OE_Versioning_Util.Get_Reason_Info(l_reason_code, l_reason_comments);
18691                             IF l_reason_code IS NULL THEN
18692                              -- bug 3636884, defaulting reason from group API
18693                              IF OE_GLOBALS.G_DEFAULT_REASON THEN
18694                                if l_debug_level > 0 then
18695                                  oe_debug_pub.add('Defaulting Audit Reason for Order Line', 1);
18696                                end if;
18697                                p_x_line_rec.change_reason := 'SYSTEM';
18698                              ELSE
18699                                OE_DEBUG_PUB.add('Reason code for change is missing or invalid', 1);
18700                                fnd_message.set_name('ONT','OE_AUDIT_REASON_RQD');
18701                                fnd_message.set_token('OBJECT','ORDER LINE');
18702                                oe_msg_pub.add;
18703                                RAISE FND_API.G_EXC_ERROR;
18704                              END IF;
18705                             END IF;
18706                          END IF;
18707                        ELSE
18708                             if l_debug_level > 0 then
18709                                OE_DEBUG_PUB.add('Reason code for change is missing or invalid', 1);
18710                             end if;
18711                             fnd_message.set_name('ONT','OE_AUDIT_REASON_RQD');
18712                             fnd_message.set_token('OBJECT','ORDER LINE');
18713                             oe_msg_pub.add;
18714                             raise FND_API.G_EXC_ERROR;
18715                        END IF;
18716                     END IF;
18717                  END IF;
18718              END IF;
18719           END LOOP;
18720        END IF;
18721   END IF;
18722 END IF;
18723 
18724 /* End Audit Trail */
18725 
18726 END IF;
18727 
18728 IF p_process_step IN (2,3) THEN
18729 
18730   IF (p_x_line_rec.operation=OE_GLOBALS.G_OPR_UPDATE) AND
18731      (p_x_line_rec.split_action_code = 'SPLIT') THEN
18732 
18733        --11.5.10 Versioning/Audit Trail updates
18734      IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
18735           OE_Versioning_Util.Capture_Audit_Info(p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
18736                                            p_entity_id => p_x_line_rec.line_id,
18737                                            p_hist_type_code =>  'SPLIT');
18738            --log delayed request
18739              OE_Delayed_Requests_Pvt.Log_Request(p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
18740                                    p_entity_id => p_x_line_rec.header_id,
18741                                    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
18742                                    p_requesting_entity_id => p_x_line_rec.line_id,
18743                                    p_request_type => OE_GLOBALS.G_VERSION_AUDIT,
18744                                    x_return_status => l_return_status);
18745           OE_GLOBALS.G_AUDIT_HISTORY_RQD_FLAG := 'N';
18746      ELSE
18747        OE_CHG_ORDER_PVT.RecordLineHist
18748           (p_line_id => p_x_line_rec.line_id,
18749            p_line_rec => null,
18750            p_hist_type_code => 'SPLIT',
18751            p_reason_code => NULL,
18752            p_comments => NULL,
18753            p_wf_activity_code => null,
18754            p_wf_result_code => null,
18755            x_return_status => l_return_status);
18756 
18757       if l_debug_level > 0 then
18758           OE_DEBUG_PUB.add('Return status after inserting split history : '||l_return_status,5);
18759       end if;
18760 
18761        IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
18762           if l_debug_level > 0 then
18763              oe_debug_pub.add('Error while inserting Line split History ',1);
18764           end if;
18765           IF l_return_status = FND_API.G_RET_STS_ERROR then
18766              raise FND_API.G_EXC_ERROR;
18767           ELSE
18768              raise FND_API.G_EXC_UNEXPECTED_ERROR;
18769           END IF;
18770        END IF;
18771      END IF;
18772 
18773   END IF;
18774 
18775        --11.5.10 Versioning/Audit Trail updates
18776      IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510'
18777       AND   OE_GLOBALS.G_ROLL_VERSION <> 'N'  THEN
18778        IF OE_GLOBALS.G_REASON_CODE IS NULL AND
18779        OE_GLOBALS.G_CAPTURED_REASON IN ('V','A') THEN
18780           IF p_x_line_rec.change_reason <> FND_API.G_MISS_CHAR THEN
18781               OE_GLOBALS.G_REASON_CODE := p_x_line_rec.change_reason;
18782               OE_GLOBALS.G_REASON_COMMENTS := p_x_line_rec.change_comments;
18783               OE_GLOBALS.G_CAPTURED_REASON := 'Y';
18784           ELSE
18785              if l_debug_level > 0 then
18786                 OE_DEBUG_PUB.add('Reason code for versioning is missing or invalid', 1);
18787              end if;
18788             -- if OE_GLOBALS.G_UI_FLAG then --bug5716140
18789                IF  OE_GLOBALS.G_UI_FLAG
18790                        OR ( p_x_line_rec.split_action_code = 'SPLIT'
18791                         AND nvl(p_x_line_rec.split_by,'SYSTEM') = 'USER' ) THEN  --bug5716140
18792                 raise FND_API.G_EXC_ERROR;
18793              end if;
18794           END IF;
18795        END IF;
18796 
18797        --log delayed request
18798        if l_debug_level > 0 then
18799           oe_debug_pub.add('log versioning request',1);
18800        end if;
18801           OE_Delayed_Requests_Pvt.Log_Request(p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
18802                                    p_entity_id => p_x_line_rec.header_id,
18803                                    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
18804                                    p_requesting_entity_id => p_x_line_rec.line_id,
18805                                    p_request_type => OE_GLOBALS.G_VERSION_AUDIT,
18806                                    x_return_status => l_return_status);
18807      END IF;
18808 
18809    /* Start Audit Trail - Insert Lines history */
18810 
18811 IF l_code_level >= '110508' and nvl(l_audit_trail_enabled,'D') <> 'D' THEN
18812    IF OE_GLOBALS.OE_AUDIT_HISTORY_TBL.count > 0 THEN
18813       FOR l_ind in 1..OE_GLOBALS.oe_audit_history_tbl.last LOOP
18814           IF OE_GLOBALS.OE_AUDIT_HISTORY_TBL.exists(l_ind) THEN
18815              IF OE_GLOBALS.oe_audit_history_tbl(l_ind).line_id = p_x_line_rec.line_id THEN
18816                 if l_debug_level > 0 then
18817                    OE_DEBUG_PUB.add('OEXULINB:calling oe_order_chg_pvt.recordlinehist', 5);
18818                 end if;
18819 
18820 	      /* Commenting the below code for bug#14387840
18821                 --11.5.10 Versioning/Audit Trail updates
18822               IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
18823                 OE_Versioning_Util.Capture_Audit_Info(p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
18824                                            p_entity_id => p_x_line_rec.line_id,
18825                                            p_hist_type_code =>  'UPDATE');
18826                  --log delayed request
18827                    OE_Delayed_Requests_Pvt.Log_Request(p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
18828                                    p_entity_id => p_x_line_rec.header_id,
18829                                    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
18830                                    p_requesting_entity_id => p_x_line_rec.line_id,
18831                                    p_request_type => OE_GLOBALS.G_VERSION_AUDIT,
18832                                    x_return_status => l_return_status);
18833                 OE_GLOBALS.G_AUDIT_HISTORY_RQD_FLAG := 'N';
18834               ELSE
18835 	      */
18836                 OE_CHG_ORDER_PVT.RecordLineHist
18837                   (p_line_id => p_x_line_rec.line_id,
18838                    p_line_rec => null,
18839                    p_hist_type_code => 'UPDATE',
18840                    p_reason_code => p_x_line_rec.change_reason,
18841                    p_comments => p_x_line_rec.change_comments,
18842                    p_wf_activity_code => null,
18843                    p_wf_result_code => null,
18844                    x_return_status => l_return_status);
18845                 if l_debug_level > 0 then
18846                    OE_DEBUG_PUB.add('IN OEXULINB:After'||l_return_status,5);
18847                 end if;
18848 
18849                 IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
18850                    if l_debug_level > 0 then
18851                       oe_debug_pub.add('Inserting Line Audit History error',1);
18852                    end if;
18853                    IF l_return_status = FND_API.G_RET_STS_ERROR then
18854                       raise FND_API.G_EXC_ERROR;
18855                    ELSE
18856                    raise FND_API.G_EXC_UNEXPECTED_ERROR;
18857                    END IF;
18858                 END IF;
18859 
18860                -- commenting out for bug#14387840
18861                -- END IF;
18862                 -- now the history is inserted successfully, remove the entry from pl/sql table
18863                 if l_debug_level > 0 then
18864                    oe_debug_pub.add('Deleting the history entry for line ID : '||OE_GLOBALS.oe_audit_history_tbl(l_ind).line_id,1);
18865                 end if;
18866                 OE_GLOBALS.oe_audit_history_tbl.delete(l_ind);
18867              END IF;
18868           END IF;
18869 
18870       END LOOP;
18871    END IF;
18872 END IF;
18873 /* End Audit Trail */
18874 
18875 END IF; --p_process_step in (2,3)
18876 
18877 END Version_Audit_Process;
18878 
18879 
18880 /*----------------------------------------------------------
18881 PROCEDURE Cascade_Line_Number
18882 
18883 -- Fixed bug 1914885: passing p_header_id and using it in the condition
18884 -- to select lines where the line number update is to be cascaded.
18885 -- This will result in using the header_id index instead of
18886 -- full table scans on lines tables.
18887 -----------------------------------------------------------*/
18888 
18889 PROCEDURE Cascade_Line_Number( p_header_id IN NUMBER,
18890                                             p_line_id IN NUMBER,
18891 					    p_line_set_id IN NUMBER,
18892 					    p_item_type_code IN VARCHAR2,
18893 					    p_line_number IN NUMBER)
18894 IS
18895 
18896 l_line_id NUMBER;
18897 l_header_id NUMBER;
18898 l_line_number NUMBER;
18899 l_shipment_number NUMBER;
18900 l_option_number NUMBER;
18901 l_service_number NUMBER;
18902 l_dummy NUMBER;
18903 
18904 -- Fetches Service lines pertaining to Standard
18905 --and related line set records.
18906 --lchen rewrite cursor standard_line_number to fix performance bug 1869179
18907 
18908 CURSOR STANDARD_LINE_NUMBER IS
18909 select /*MOAC_SQL_CHANGES*/ a.line_id, a.header_id, a.line_number, a.shipment_number, a.option_number, a.service_number
18910 from oe_order_lines a
18911 where a.service_reference_line_id= p_line_id
18912 UNION
18913 select a.line_id, a.header_id, a.line_number, a.shipment_number, a.option_number, a.service_number
18914 from oe_order_lines a
18915 where a.line_set_id = p_line_set_id
18916 UNION
18917 select a.line_id, a.header_id, a.line_number, a.shipment_number, a.option_number, a.service_number
18918 from oe_order_lines a
18919 where exists
18920       (select 'x'
18921        from oe_order_lines_all b
18922        where a.service_reference_line_id=b.line_id
18923        and b.line_set_id = p_line_set_id)
18924       and a.line_Id <> p_line_id;
18925 
18926 
18927 --Fetches Options/classes/services pertaining to Model/Kit
18928 --and related line set records.
18929 
18930 CURSOR MODEL_LINE_NUMBER IS
18931       SELECT /*MOAC_SQL_CHANGES*/ line_id, header_id,line_number,shipment_number,
18932 		   option_number,service_number
18933       FROM   oe_order_lines
18934       WHERE  (top_model_line_id = p_line_id
18935 	 OR      line_set_id = p_line_set_id
18936 	 OR     top_model_line_id in (SELECT line_id
18937 							FROM   oe_order_lines_all
18938 							WHERE header_id = p_header_id
18939                             AND line_set_id = p_line_set_id))
18940       AND     line_id <> p_line_id
18941       AND     header_id = p_header_id
18942       FOR UPDATE OF line_number NOWAIT;
18943 
18944 
18945 
18946 --Fetches services attached to options/model/classes to update
18947 --line_number.
18948 --lchen rewrite cursor service_line_number to fix performance bug 1869179
18949 
18950 CURSOR SERVICE_LINE_NUMBER IS
18951   select /*MOAC_SQL_CHANGES*/ a.line_id, a.header_id, a.line_number, a.shipment_number, a.option_number, a.service_number
18952   from oe_order_lines a, oe_order_lines_all b
18953   where a.service_reference_line_id=b.line_id
18954   and b.line_set_id = p_line_set_id
18955   UNION
18956   select a.line_id, a.header_id, a.line_number, a.shipment_number, a.option_number, a.service_number
18957   from oe_order_lines a, oe_order_lines_all b
18958   Where a.service_reference_line_id=b.line_id
18959   and  b.top_model_line_id= p_line_id
18960   UNION
18961   select a.line_id, a.header_id, a.line_number, a.shipment_number, a.option_number, a.service_number
18962   from oe_order_lines a, oe_order_lines_all b
18963   Where a.service_reference_line_id=b.line_id
18964   and  EXISTS (select 'X'
18965            from oe_order_lines_all c
18966            where line_set_id = p_line_set_id
18967            and c.line_id = b.top_model_line_id);
18968 
18969 
18970 l_line_rec      OE_Order_PUB.Line_Rec_Type;
18971 l_cursor_flag   VARCHAR2(1) := null;
18972 
18973 BEGIN
18974        oe_debug_pub.add('Entering OE_LINE_UTIL.CASCADE_LINE_NUMBER ');
18975               oe_debug_pub.add('AK line_id ' || p_line_id);
18976               oe_debug_pub.add('AK line_iset_d ' || p_line_set_id);
18977               oe_debug_pub.add('AK line_number' || p_line_number);
18978               oe_debug_pub.add('AK item_type_code' || p_item_type_code);
18979 
18980        IF p_item_type_code = OE_GLOBALS.G_ITEM_STANDARD THEN
18981 
18982               OPEN Standard_line_number;
18983                l_cursor_flag := 'S';
18984 
18985     -- Update  line number on the child service lines
18986  /*lchen rewrite the update statement to fix performance bug 1869179 */
18987       oe_debug_pub.add('l_cursor_flag= ' ||l_cursor_flag );
18988 
18989             LOOP
18990             FETCH standard_line_number
18991             INTO  l_line_id,
18992 	          l_header_id,
18993 	          l_line_number,
18994 	          l_shipment_number,
18995 	          l_option_number,
18996 	          l_service_number;
18997             EXIT when standard_line_number%NOTFOUND;
18998 
18999             BEGIN
19000             SELECT line_id
19001             INTO  l_dummy
19002             FROM   oe_order_lines
19003             WHERE  line_id=l_line_id
19004             FOR UPDATE OF line_number NOWAIT;
19005             EXCEPTION
19006             WHEN OTHERS THEN
19007             l_dummy := 0;
19008             END;
19009 
19010       oe_debug_pub.add('l_line_id= ' || l_line_id);
19011        oe_debug_pub.add('In the loop of standard_line_number, update child service line numbers');
19012 
19013         UPDATE oe_order_lines
19014           Set    line_number = p_line_number,
19015                  lock_control = lock_control + 1
19016          WHERE  line_id=l_line_id;
19017 
19018        END LOOP;
19019      CLOSE Standard_line_number;
19020 
19021      OPEN Standard_line_number;
19022           IF SQL%FOUND THEN
19023 	     OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
19024 
19025               		LOOP
19026 				 FETCH Standard_line_number
19027 				 INTO  l_line_rec.line_id,
19028 					  l_line_rec.header_id,
19029 				 	  l_line_rec.line_number,
19030 					  l_line_rec.shipment_number,
19031 					  l_line_rec.option_number,
19032 					  l_line_rec.service_number;
19033  			      EXIT WHEN Standard_line_number%NOTFOUND;
19034 
19035                oe_debug_pub.add(' before calling wf_util');
19036 	       oe_debug_pub.add('line_rec.line_id=' || l_line_rec.line_id);
19037 
19038                         oe_order_wf_util.set_line_user_key(l_line_rec);
19039 
19040                       END LOOP;
19041 
19042                END IF;
19043               CLOSE Standard_line_number;
19044 
19045          ELSIF p_item_type_code = OE_GLOBALS.G_ITEM_MODEL
19046          OR    p_item_type_code = OE_GLOBALS.G_ITEM_KIT
19047          THEN
19048 
19049 
19050                OPEN Model_line_number;
19051                 l_cursor_flag := 'M';
19052 
19053                 oe_debug_pub.add('l_cursor_flag= ' ||l_cursor_flag );
19054 	      -- Update line number on the child option/service/class lines
19055 
19056                UPDATE oe_order_lines
19057                Set    line_number = p_line_number,
19058                       lock_control = lock_control + 1
19059                WHERE  (top_model_line_id = p_line_id
19060 	          OR      line_set_id = p_line_set_id
19061 	          OR     top_model_line_id in (SELECT line_id
19062 				FROM   oe_order_lines
19063 				WHERE header_id = p_header_id
19064                 AND line_set_id = p_line_set_id))
19065                   AND    line_id <> p_line_id
19066                   AND    header_id = p_header_id;  -- 2508099
19067 
19068 		IF SQL%FOUND THEN
19069 			    OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
19070 
19071 			  LOOP
19072 				FETCH Model_line_number
19073 				INTO  l_line_rec.line_id,
19074 				 l_line_rec.header_id,
19075 				 l_line_rec.line_number,
19076 				 l_line_rec.shipment_number,
19077 				 l_line_rec.option_number,
19078 				 l_line_rec.service_number;
19079  			 	EXIT WHEN Model_Line_Number%NOTFOUND;
19080 
19081                 oe_debug_pub.add(' before calling wf_util');
19082 		oe_debug_pub.add('line_rec.line_id=' || l_line_rec.line_id);
19083 
19084                               oe_order_wf_util.set_line_user_key(l_line_rec);
19085 
19086 			  END LOOP;
19087                END IF;
19088                CLOSE Model_line_number;
19089 
19090 
19091       -- Update line numbers for service lines
19092 
19093       OPEN SERVICE_line_number;
19094       l_cursor_flag := 'O';
19095       oe_debug_pub.add('l_cursor_flag= ' ||l_cursor_flag );
19096 
19097 -- Update line number on the child option/service/class lines
19098  --lchen rewrite the update statement to fix performance bug 1869179
19099 
19100      LOOP
19101       FETCH service_line_number
19102   	INTO  l_line_id,
19103 	      l_header_id,
19104 	      l_line_number,
19105 	      l_shipment_number,
19106 	      l_option_number,
19107 	      l_service_number;
19108 
19109         EXIT when service_line_number%NOTFOUND;
19110 
19111       BEGIN
19112         SELECT line_id
19113         INTO  l_dummy
19114         FROM   oe_order_lines
19115         WHERE  line_id=l_line_id
19116       FOR UPDATE OF line_number NOWAIT;
19117         EXCEPTION
19118         WHEN OTHERS THEN
19119          l_dummy := 0;
19120      END;
19121 
19122    oe_debug_pub.add('l_line_id = ' ||l_dummy);
19123   oe_debug_pub.add('in service_line_number loop, update service line number');
19124 
19125       UPDATE oe_order_lines
19126       Set    line_number = p_line_number,
19127              lock_control = lock_control + 1
19128       WHERE  line_id=l_line_id;
19129     END LOOP;
19130    CLOSE service_line_number;
19131 
19132      OPEN service_line_number;
19133 	IF SQL%FOUND THEN
19134 	   OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
19135 
19136 			  LOOP
19137 				FETCH service_line_number
19138 				INTO  l_line_rec.line_id,
19139 				 l_line_rec.header_id,
19140 				 l_line_rec.line_number,
19141 				 l_line_rec.shipment_number,
19142 				 l_line_rec.option_number,
19143 				 l_line_rec.service_number;
19144  			 	EXIT WHEN service_Line_Number%NOTFOUND;
19145 
19146                 oe_debug_pub.add(' before calling wf_util');
19147 		oe_debug_pub.add('line_rec.line_id=' || l_line_rec.line_id);
19148 
19149                             oe_order_wf_util.set_line_user_key(l_line_rec);
19150 	                END LOOP;
19151            END IF;
19152         CLOSE Service_line_number;
19153 
19154        END IF;   /*p_item_type_code*/
19155 
19156      oe_debug_pub.add('Exiting OE_LINE_UTIL.CASCADE_LINE_NUMBER ');
19157 
19158 EXCEPTION
19159 
19160     WHEN NO_DATA_FOUND THEN
19161           IF l_cursor_flag = 'S' THEN
19162             CLOSE Standard_line_number;
19163           ELSIF l_cursor_flag = 'M' THEN
19164 		  CLOSE Model_Line_Number;
19165           ELSIF l_cursor_flag = 'O' THEN
19166                CLOSE Service_line_number;
19167           END IF;
19168 
19169     WHEN  APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION THEN
19170 
19171           IF p_item_type_code = OE_GLOBALS.G_ITEM_STANDARD THEN
19172             CLOSE Standard_line_number;
19173           ELSE
19174 		  CLOSE Model_Line_Number;
19175           END IF;
19176 
19177           IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
19178           THEN
19179 
19180        	   fnd_message.set_name('ONT','OE_LOCK_ROW_ALREADY_LOCKED');
19181         	   OE_MSG_PUB.Add;
19182 	        RAISE FND_API.G_EXC_ERROR;
19183 
19184         	END IF;
19185 
19186      WHEN OTHERS THEN
19187 
19188           IF l_cursor_flag = 'S' THEN
19189             CLOSE Standard_line_number;
19190           ELSIF l_cursor_flag = 'M' THEN
19191 		  CLOSE Model_Line_Number;
19192           ELSIF l_cursor_flag = 'O' THEN
19193                CLOSE Service_line_number;
19194           END IF;
19195 
19196         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
19197         THEN
19198             oe_msg_pub.Add_Exc_Msg
19199             (   G_PKG_NAME
19200           ,   'Cascade_line_number'
19201             );
19202         END IF;
19203 
19204         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
19205 
19206 END Cascade_Line_Number;
19207 
19208 
19209 /*----------------------------------------------------------
19210 PROCEDURE Post_Write_Process
19211 -----------------------------------------------------------*/
19212 
19213 PROCEDURE Post_Write_Process
19214 (   p_x_line_rec                    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
19215 ,   p_old_line_rec                  IN  OE_Order_PUB.Line_Rec_Type :=
19216                                         OE_Order_PUB.G_MISS_LINE_REC
19217 ) IS
19218 l_return_status    VARCHAR2(30):= FND_API.G_RET_STS_SUCCESS;
19219 I                  NUMBER;
19220 l_ship_authorize   VARCHAR2(1);
19221 l_operation        VARCHAR2(30);
19222 
19223 l_qty_to_reserve   NUMBER;
19224 l_qty2_to_reserve   NUMBER; -- INVCONV
19225 l_msg_count        NUMBER;
19226 l_msg_data         VARCHAR2(2000);
19227 l_line_id		    NUMBER;
19228 l_old_recursion_mode VARCHAR2(1);
19229 
19230 -- For reservations
19231 l_reservation_rec         inv_reservation_global.mtl_reservation_rec_type;
19232 l_dummy_sn                inv_reservation_global.serial_number_tbl_type;
19233 l_quantity_reserved       NUMBER;
19234 l_quantity2_reserved       NUMBER; -- INVCONV
19235 l_rsv_id                  NUMBER;
19236 l_reservable_type         NUMBER;
19237 
19238 l_atp_tbl      OE_ATP.atp_tbl_type;
19239 l_buffer                  VARCHAR2(2000);
19240 l_lock_control            NUMBER;
19241 
19242 -- subinventory
19243 l_revision_code    NUMBER;
19244 l_lot_code         NUMBER;
19245 
19246 /* Fix Bug # 3184597 */
19247 l_ctr              NUMBER;
19248 l_set_id	   NUMBER;
19249 
19250 CURSOR ship_authorize IS
19251     SELECT 'Y' from
19252     WF_ITEM_ACTIVITY_STATUSES WIAS
19253   , WF_PROCESS_ACTIVITIES WPA
19254     where WIAS.item_type = 'OEOL'
19255     AND WIAS.item_key = to_char(p_x_line_rec.line_id)
19256     AND WIAS.activity_status = 'NOTIFIED'
19257     AND WPA.activity_name = 'AUTHORIZE_TO_SHIP_WAIT'
19258     AND WPA.instance_id = WIAS.process_activity;
19259 
19260 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
19261 
19262 l_close_act_complete NUMBER := 0;
19263 
19264 BEGIN
19265 
19266  if l_debug_level > 0 then
19267   oe_debug_pub.add('Entering Post_Write_Process',1);
19268  end if;
19269 
19270    -- QUOTING change
19271    IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE
19272 	 AND p_x_line_rec.split_from_line_id IS NULL
19273          AND nvl(p_x_line_rec.transaction_phase_code,'F') = 'F'
19274       )
19275       OR (
19276   OE_Quote_Util.G_COMPLETE_NEG = 'Y'
19277           AND NOT OE_GLOBALS.EQUAL(p_x_line_rec.transaction_phase_code
19278                      ,p_old_line_rec.transaction_phase_code)
19279           )
19280    THEN
19281     if l_debug_level > 0 then
19282      oe_debug_pub.add('Call evaluate_holds_post_write for CREATE');
19283     end if;
19284      OE_Holds_PUB.evaluate_holds_post_write
19285       (p_entity_code => OE_GLOBALS.G_ENTITY_LINE
19286       ,p_entity_id => p_x_line_rec.line_id
19287       ,x_msg_count => l_msg_count
19288       ,x_msg_data => l_msg_data
19289       ,x_return_status => l_return_status
19290       );
19291 
19292          IF l_return_status = FND_API.G_RET_STS_ERROR THEN
19293             RAISE FND_API.G_EXC_ERROR;
19294          ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
19295             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
19296          END IF;
19297 
19298     if l_debug_level > 0 then
19299       oe_debug_pub.add('After evaluate_holds_post_write in LINE Post Write');
19300     end if;
19301   END IF;
19302   /* bug 8471521   --- Moved the code after scheduling ---
19303    --Call the delayed request for holds evaluation. This is needed for a
19304    --scheduling fix.
19305    IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
19306 
19307    if l_debug_level > 0 then
19308     oe_debug_pub.add('Calling DelayedReg for evaluate_holds in post_write for UPDATE');
19309    end if;
19310 
19311     OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
19312          (p_request_type   =>OE_GLOBALS.G_EVAL_HOLD_SOURCE
19313           ,p_delete        => FND_API.G_TRUE
19314           ,x_return_status => l_return_status
19315           );
19316     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
19317           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
19318     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
19319           RAISE FND_API.G_EXC_ERROR;
19320     END IF;
19321 
19322 
19323    END IF; --- Moved the code after scheduling --- bug 8471521  */
19324 
19325 
19326   -- Start the Line Workflow
19327   --------------------------------------------------------------------
19328 
19329   -- QUOTING change
19330   IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE
19331       OR (OE_Quote_Util.G_COMPLETE_NEG = 'Y'
19332            AND NOT OE_GLOBALS.EQUAL(p_x_line_rec.transaction_phase_code
19333                       ,p_old_line_rec.transaction_phase_code)
19334            )
19335       )
19336      AND nvl(p_x_line_rec.transaction_phase_code,'F') = 'F'
19337   THEN
19338       OE_Order_WF_Util.CreateStart_LineProcess(p_x_line_rec);
19339   END IF;
19340 
19341 
19342   --------------------------------------------------------------------
19343    -- If freeze_included_options profile value is ENTRY,
19344    -- we have populated a global pl/sql table,
19345    -- now call function to freeze included items.
19346    -- Since process included items cannot set recursion mode, caler needs to set
19347    -- the recursion mode.
19348   --------------------------------------------------------------------
19349 
19350    l_old_recursion_mode := OE_GLOBALS.G_RECURSION_MODE;
19351    --   OE_GLOBALS.G_RECURSION_MODE := 'Y';
19352 
19353    I := OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL.FIRST;
19354    WHILE I is not null
19355    LOOP
19356           if l_debug_level > 0 then
19357 	    oe_debug_pub.add(I || ' freeze inc items call looping '||p_x_line_rec.line_id, 4);
19358           end if;
19359 	    IF p_x_line_rec.line_id = OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL(I)
19360 	    THEN
19361 /* Start DOO Pre Exploded Kit ER 9339742 */
19362         IF   (OE_GENESIS_UTIL.G_INCOMING_FROM_DOO)
19363           -- p_x_line_rec.pre_exploded_flag = 'Y'
19364 /* Note: Here we are checking on the global G_Incoming_From_DOO and not the
19365 Pre_Exploded_Flag attribute because user can change a DOO created Sales Order in
19366 EBS OM Sales order pad or by directly calling the Process Order api without
19367 settting the above global. Since the trade off is: we should allow the user to
19368 successfully update the order, and the validation should be standard. The
19369 validation should NOT be of Pre Exploded Kit functionality. Hence, the below
19370 delayed request OE_GLOBALS.G_PRE_EXPLODED_KIT should get logged only if the above
19371 global is TRUE. It should be irrespective of the Pre_Exploded_Flag attribute value. */
19372 
19373         AND  p_x_line_rec.ato_line_id is NULL
19374         AND  ((p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT
19375            AND p_x_line_rec.line_id = p_x_line_rec.top_model_line_id)
19376             -- Bug 11928288 : Start
19377             OR (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL
19378             AND p_x_line_rec.line_id = p_x_line_rec.top_model_line_id)
19379             -- Bug 11928288 : End
19380             OR p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS )  THEN
19381           -- Importing Pre Exploded Kit.
19382           -- Log a delayed request for its execution after the whole Kit is
19383           -- imported and records are posted to OE_Order_Lines_All table
19384           -- This request will be logged for Kit model line
19385 
19386           oe_debug_pub.add(' Logging G_PRE_EXPLODED_KIT delayed requests');
19387           OE_delayed_requests_Pvt.log_request(
19388            p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
19389            p_entity_id              => p_x_line_rec.top_model_line_id, -- The top model line
19390            p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
19391            p_requesting_entity_id   => p_x_line_rec.line_id,
19392            p_date_param1            => p_x_line_rec.explosion_date,
19393            p_request_type           => OE_GLOBALS.G_PRE_EXPLODED_KIT,
19394            x_return_status          => l_return_status);
19395         ELSE
19396 /* End DOO Pre Exploded Kit ER 9339742 */
19397                   if l_debug_level > 0 then
19398 		    oe_debug_pub.add('PO: Calling freeze_inc_items call', 2);
19399                   end if;
19400 		    l_return_status :=
19401 		    OE_Config_Util.Process_Included_Items
19402 						   (p_line_rec => p_x_line_rec,
19403 		 				    p_freeze   => TRUE);
19404 
19405           if l_debug_level > 0 then
19406             oe_debug_pub.add('PO: After Calling Process_Included_Items call: ' ||
19407                            l_return_status, 2);
19408           end if;
19409 
19410        END IF; -- DOO Preexploded kit ER
19411 
19412             IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
19413 
19414                OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL.DELETE(I);
19415 
19416             ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
19417 
19418                 OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL.DELETE;
19419                 RAISE FND_API.G_EXC_ERROR;
19420 
19421             ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
19422 
19423                 OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL.DELETE;
19424                 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
19425 
19426             END IF;
19427 
19428         END IF;
19429 
19430       I := OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL.NEXT(I);
19431 
19432    END LOOP;
19433 
19434    ------------------------------------------------------------------------
19435    -- Call Scheduling to perform any scheduling on the line, if needed
19436    ------------------------------------------------------------------------
19437 
19438     -- Added code in delete_dependency for delete operation.
19439 
19440     --4504362: Branch scheduling check removed
19441 
19442       if l_debug_level > 0 then
19443        oe_debug_pub.add('OESCH_PERFORM_SCHEDULING :' ||
19444                            OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING,1);
19445       end if;
19446 
19447 /* 7576948: IR ISO Change Management project Start */
19448 --
19449 -- This check is performed to ensure if there is a line cancellation
19450 -- from Planning workbench or DRP user in ASCP then scheduling should be
19451 -- done to Unschedule/Undemand the order line. Other than this case,
19452 -- if Planning user updates the order line then scheduling action
19453 -- is not performed.
19454 -- The global OE_Schedule_GRP.G_ISO_Planning_Update is set to TRUE
19455 -- in package OE_Schedule_GRP.Process_Order
19456 -- This change is done as a very specific case for IR ISO CMS project
19457 -- when changes been done by Planning user
19458 --
19459 
19460     IF OE_Schedule_GRP.G_ISO_Planning_Update AND
19461      NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity, p_old_line_rec.ordered_quantity) THEN
19462 --     nvl(p_x_line_rec.ordered_quantity,0) = 0 THEN  -- Commented for bug 7611039
19463       OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING := 'Y';
19464 
19465       IF l_debug_level > 0 THEN
19466         oe_debug_pub.add(' Setting global OE_Schedule_GRP.G_ISO_Planning_Update to TRUE',5);
19467       END IF;
19468     END IF;
19469 
19470 /* ============================= */
19471 /* IR ISO Change Management Ends */
19472 
19473 
19474        IF  OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING = 'Y'
19475        AND p_x_line_rec.line_category_code <> 'RETURN'
19476        AND p_x_line_rec.operation <> OE_GLOBALS.G_OPR_DELETE
19477        THEN
19478 
19479         if l_debug_level > 0 then
19480          oe_debug_pub.add('PO: Calling new Schedule_line from post write',1);
19481         end if;
19482 
19483          oe_split_util.g_sch_recursion := 'TRUE';
19484 
19485         if l_debug_level > 0 then
19486          oe_debug_pub.add(' New Schedule Line',1);
19487         end if;
19488          OE_SCHEDULE_UTIL.Schedule_Line
19489          (p_x_line_rec    => p_x_line_rec
19490          ,p_old_line_rec  => p_old_line_rec
19491          ,x_return_status => l_return_status);
19492 
19493         IF OE_Schedule_GRP.G_ISO_Planning_Update THEN
19494            OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING := 'N';
19495         END IF; -- Added for bug 7611039
19496 	--  fix for bug 8217093 start
19497 
19498        elsIF OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING ='N'
19499        AND  (p_x_line_rec.ship_set_id is not null
19500 	    or p_x_line_rec.arrival_set_id is not null)
19501        AND (NOT oe_globals.equal(p_x_line_rec.schedule_ship_date,p_old_line_rec.schedule_ship_date) OR
19502                     NOT oe_globals.equal(p_x_line_rec.schedule_arrival_date,p_old_line_rec.schedule_arrival_date) OR
19503                     NOT oe_globals.equal(p_x_line_rec.ship_from_org_id,p_old_line_rec.ship_from_org_id) OR
19504                     NOT oe_globals.equal(p_x_line_rec.shipping_method_code,p_old_line_rec.shipping_method_code))
19505        then
19506 
19507 	 if p_x_line_rec.ship_set_id is not null then
19508 	   l_set_id:=p_x_line_rec.ship_set_id;
19509 	 elsif p_x_line_rec.arrival_set_id is not null then
19510 	   l_set_id:=p_x_line_rec.arrival_set_id;
19511 	 end if;
19512         if l_debug_level > 0 then
19513       	 oe_debug_pub.add(' Line has set information, update the sets');
19514         end if;
19515        OE_Set_Util.Update_Set
19516         (p_Set_Id                   =>l_set_id,
19517          p_Ship_From_Org_Id         =>p_x_line_rec.Ship_From_Org_Id,
19518          p_Ship_To_Org_Id           =>p_x_line_rec.Ship_To_Org_Id,
19519          p_Schedule_Ship_Date       =>p_x_line_rec.Schedule_Ship_Date,
19520          p_Schedule_Arrival_Date    =>p_x_line_rec.Schedule_Arrival_Date,
19521          p_Freight_Carrier_Code     =>p_x_line_rec.Freight_Carrier_Code,
19522          p_Shipping_Method_Code     =>p_x_line_rec.Shipping_Method_Code,
19523          p_shipment_priority_code   =>p_x_line_rec.shipment_priority_code,
19524          X_Return_Status            =>l_return_status,
19525          x_msg_count                =>l_msg_count,
19526          x_msg_data                 =>l_msg_data
19527         );
19528 
19529       -- changes for bug 8217093 end
19530 
19531        END IF;
19532 
19533        oe_split_util.g_sch_recursion := 'FALSE';
19534 
19535       if l_debug_level > 0 then
19536        oe_debug_pub.add('PO: After Calling Schedule_line: ' ||
19537                                  l_return_status,1);
19538        oe_debug_pub.add('SCH: p_x_line_rec.schedule_status_code '||
19539                  p_x_line_rec.schedule_status_code,1);
19540       end if;
19541 
19542        IF l_return_status = FND_API.G_RET_STS_ERROR THEN
19543           RAISE FND_API.G_EXC_ERROR;
19544        ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
19545           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
19546        END IF;
19547 
19548      -- do not move Log_CTO_Requests above scheduling
19549 
19550       IF (p_x_line_rec.top_model_line_id is NOT NULL OR
19551           p_x_line_rec.ato_line_id is NOT NULL) AND
19552           NOT  p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CONFIG
19553       THEN
19554 
19555         Log_CTO_Requests( p_x_line_rec    => p_x_line_rec
19556                          ,p_old_line_rec  => p_old_line_rec
19557                          ,x_return_status => l_return_status);
19558       END IF;
19559 
19560 
19561 
19562    -- re-set the old recursion mode after process included items call.
19563    -- OE_GLOBALS.G_RECURSION_MODE := l_old_recursion_mode;
19564 
19565     -- 4504362 :Branch scheduling check removed.
19566 -- This is moved from cancellations logic since closing the line is
19567 -- based on the cancellation flag and ordered quantity
19568 
19569      IF (oe_sales_can_util.G_REQUIRE_REASON) THEN
19570 
19571        IF Nvl(p_x_line_rec.split_action_code,'X') <> 'SPLIT' THEN
19572 
19573           If (p_x_line_rec.ordered_quantity = 0 AND
19574 		 p_x_line_rec.operation = oe_globals.G_OPR_UPDATE )then
19575 
19576           -- OE_GLOBALS.G_RECURSION_MODE := 'Y';
19577 /*
19578 -- Log a request to cancel the workflow.
19579 
19580 
19581         OE_delayed_requests_Pvt.log_request
19582         (p_entity_code                          => OE_GLOBALS.G_ENTITY_ALL,
19583         p_entity_id                             => p_x_line_rec.line_id,
19584         p_requesting_entity_code        => OE_GLOBALS.G_ENTITY_ALL,
19585         p_requesting_entity_id          => p_x_line_rec.line_id,
19586         p_request_type                  => OE_GLOBALS.G_CANCEL_WF,
19587 	p_param1                 => OE_GLOBALS.G_ENTITY_LINE,
19588         x_return_status                         => l_return_status);
19589 */
19590 
19591 -- commented the code to move the logic to delayed request
19592 -- reopened to revert the changes
19593           wf_engine.handleerror(OE_Globals.G_WFI_LIN
19594                     ,to_char(p_x_line_rec.line_id)
19595                     ,'CLOSE_LINE',
19596                     'RETRY','CANCEL');
19597                        if l_debug_level > 0 then
19598 			OE_DEBUG_PUB.ADD('After Calling Wf Handle Error ');
19599                        end if;
19600 
19601 -- Added for FP bug 6682329. The below query is added to fix the data corruption
19602 -- issues where both cancelled_flag and open_flag were getting set to 'Y'.
19603 
19604         IF nvl(p_x_line_rec.cancelled_flag,'N') = 'Y' THEN
19605            oe_debug_pub.add(' Line is cancelled, Close_Line WF act is ? ');
19606            select count(*) into l_close_act_complete
19607            from   wf_item_activity_statuses s,
19608                   wf_process_activities p
19609            where  s.process_activity = p.instance_id
19610            and    s.item_type = 'OEOL'
19611            and    s.item_key = to_char(p_x_line_rec.line_id)
19612            and    p.activity_name = 'CLOSE_LINE'
19613            and    activity_result_code in ('NOT_ELIGIBLE','COMPLETE')
19614            and    s.activity_status = 'COMPLETE';
19615            IF l_close_act_complete = 0 THEN
19616              oe_debug_pub.add(' Close_Line failed. Rollback the changes');
19617                 FND_MESSAGE.SET_NAME('ONT','OE_CLOSE_LINE_ERROR');
19618                 OE_MSG_PUB.ADD;
19619                 RAISE FND_API.G_EXC_ERROR;
19620            END IF;
19621         END IF;
19622 
19623           -- OE_GLOBALS.G_RECURSION_MODE := 'N';
19624 
19625 
19626             /*
19627             ** Fix Bug # 3184597 Start
19628             ** Check if the cancelled line is waiting on the flow to be
19629             ** started. If so, delete entry from G_START_LINE_FLOWS_TBL
19630             */
19631             IF (OE_GLOBALS.G_START_LINE_FLOWS_TBL.COUNT > 0) THEN
19632               l_ctr := OE_GLOBALS.G_START_LINE_FLOWS_TBL.FIRST;
19633               WHILE (l_ctr IS NOT NULL) LOOP
19634                 IF (OE_GLOBALS.G_START_LINE_FLOWS_TBL(l_ctr).LINE_ID =
19635                                              p_x_line_rec.line_id) THEN
19636                   oe_debug_pub.add('Cancellation:Deleting from OE_GLOBALS.G_START_LINE_FLOWS_TBL for lineID:' || p_x_line_rec.line_id);
19637                  OE_GLOBALS.G_START_LINE_FLOWS_TBL.DELETE(l_ctr);
19638                  EXIT;
19639                 END IF;
19640                 l_ctr := OE_GLOBALS.G_START_LINE_FLOWS_TBL.NEXT(l_ctr);
19641               END LOOP;
19642             END IF;
19643             /* Fix Bug # 3184597 End */
19644 	    -- Added below IF condition for FP bug 6628653 base bug 6513023
19645 	                IF NOT(OE_OE_FORM_CANCEL_LINE.g_ord_lvl_can) THEN
19646 	                   IF p_x_line_rec.top_model_line_id IS NOT NULL AND
19647 	                      p_x_line_rec.ato_line_id IS NULL AND
19648 	                      p_x_line_rec.item_type_code = 'INCLUDED' AND
19649 	                          nvl(p_x_line_rec.model_remnant_flag, 'N') = 'Y'
19650 	                   THEN
19651 	                        oe_debug_pub.add('In case of line level cancellation: calling Handle_RFR() ');
19652 	                         Handle_RFR(p_top_model_line_id => p_x_line_rec.top_model_line_id,
19653 	                                    p_line_id => p_x_line_rec.line_id,
19654 	                                    p_link_to_line_id => p_x_line_rec.link_to_line_id );
19655 	                   END IF;
19656 	                END IF;
19657 	                    -- End of FP bug 6628653 base bug 6513023
19658 
19659 		 OE_SALES_CAN_UTIL.G_REQUIRE_REASON := FALSE;
19660         end if;
19661        END IF;
19662 	END IF;
19663 
19664  if l_debug_level > 0 then
19665   oe_debug_pub.add('RQ: ' || p_x_line_rec.reserved_quantity,1);
19666  end if;
19667 
19668  -- bug 8471521 Moved the code after scheduling call to avoid the issue happens because of the ware house change..
19669     --Call the delayed request for holds evaluation. This is needed for a
19670     --scheduling fix.
19671     IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
19672 
19673     if l_debug_level > 0 then
19674      oe_debug_pub.add('Calling DelayedReg for evaluate_holds in post_write for UPDATE');
19675     end if;
19676 
19677      OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
19678           (p_request_type   =>OE_GLOBALS.G_EVAL_HOLD_SOURCE
19679            ,p_delete        => FND_API.G_TRUE
19680            ,x_return_status => l_return_status
19681            );
19682      IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
19683            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
19684      ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
19685            RAISE FND_API.G_EXC_ERROR;
19686      END IF;
19687 
19688 
19689     END IF; --- Moved the code after scheduling --- bug 8471521
19690 -- bug 8471521 Moved the code after scheduling call to avoid the issue happens because of the ware house change..
19691 
19692    -- Adding code to create reservation when item is changed on
19693    -- the line, since inventory expects the item to be stored on the line
19694    --before making any reservations. --1913263.
19695   -- 4504362 :Branch scheduling checks removed.
19696 
19697   --------------------------------------------------------------------
19698   -- Complete the block activity for Shipping Authorization based on the
19699   -- the value of the authorized_to_ship_flag in the lines table
19700   -- Check if the ship authorization activity is in a NOTIFIED state
19701   --------------------------------------------------------------------
19702 
19703   IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
19704    if l_debug_level > 0 then
19705     oe_debug_pub.add('Authorization flag is: ' ||
19706                                  p_x_line_rec.authorized_to_ship_flag);
19707    end if;
19708     IF p_x_line_rec.authorized_to_ship_flag = 'Y' AND
19709  	  NOT OE_GLOBALS.Equal(p_x_line_rec.authorized_to_ship_flag,
19710 					p_old_line_rec.authorized_to_ship_flag)
19711     THEN
19712       OPEN ship_authorize;
19713       FETCH ship_authorize INTO l_ship_authorize;
19714       CLOSE ship_authorize;
19715       IF (l_ship_authorize = 'Y')
19716       THEN
19717          WF_ENGINE.CompleteActivityInternalName('OEOL', p_x_line_rec.line_id,
19718                       'AUTHORIZE_TO_SHIP_WAIT', 'COMPLETE');
19719       END IF;
19720     END IF;
19721   END IF;
19722 
19723   --------------------------------------------------------------------
19724    -- Line Number update logic.
19725    -- Update/Cascade linenumber changes to it children.
19726    -- If the line number is updated at Standard line then update all
19727    -- its children (Service).
19728    -- If the line number is updated at Model/Kit then update all its
19729    -- children and sub children(like options,classes,services,service
19730    -- attached to children).
19731   --------------------------------------------------------------------
19732 
19733    IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
19734 
19735       IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.line_number ,
19736 	 					p_old_line_rec.line_number)
19737       THEN
19738 	   Cascade_Line_Number
19739 			( p_x_line_rec.header_id,
19740                         p_x_line_rec.line_id,
19741 	    		p_x_line_rec.line_set_id,
19742          		p_x_line_rec.item_type_code,
19743          		p_x_line_rec.line_number
19744 			);
19745       END IF; -- Equal.
19746 
19747    END IF; -- G_OPR_UPDATE.
19748 
19749 
19750   --------------------------------------------------------------------
19751    -- Create sales credits if sales rep on the line is different than header
19752    -- The reason to call procedure to evaluate this is to validate couple of
19753    -- other cases.
19754   --------------------------------------------------------------------
19755 
19756    IF  NOT (nvl(p_x_line_rec.split_action_code,'X') = 'SPLIT' and
19757                p_x_line_rec.operation = oe_globals.g_opr_update)
19758    THEN
19759 
19760      IF  NOT( (nvl(p_x_line_rec.split_from_line_id,FND_API.G_MISS_NUM)
19761 				<> FND_API.G_MISS_NUM)
19762                AND p_x_line_rec.operation = oe_globals.g_opr_create
19763              )
19764      THEN
19765 
19766         if l_debug_level > 0 then
19767 	 oe_debug_pub.add('Before Calling Create Credit');
19768         end if;
19769 
19770    -- Bug# 5726848 IF condition modified for allowing update of sales credit for copied orders.
19771    	 IF NOT (nvl(p_x_line_rec.source_document_type_id,-99) = 2 AND
19772 	         p_x_line_rec.operation = oe_globals.g_opr_create) THEN
19773    -- End of change Bug# 5726848
19774                  OE_Line_Scredit_Util.Create_Credit
19775 		(p_line_rec => p_x_line_rec,p_old_line_rec => p_old_line_rec);
19776       END IF;
19777 
19778      END IF;
19779 
19780    END IF;
19781 
19782    -- Executing the RMA child creation request here so that line numbers of
19783    -- child RMA lines are in sequence with the parent line. FOR ER:1480867
19784 
19785    IF p_x_line_rec.line_category_code = 'RETURN' AND
19786       p_x_line_rec.reference_line_id IS NOT NULL AND
19787       OE_GLOBALS.G_RETURN_CHILDREN_MODE = 'N' AND
19788       NOT OE_GLOBALS.EQUAL(p_x_line_rec.reference_line_id ,
19789                         p_old_line_rec.reference_line_id)
19790 
19791    THEN
19792        OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
19793          (p_request_type   =>OE_GLOBALS.G_INSERT_RMA
19794           ,p_delete        => FND_API.G_TRUE
19795           ,x_return_status => l_return_status
19796           );
19797    END IF;
19798 
19799    -- BLANKETS: Log requests to validate and update release qty/amount
19800    -- Not needed for returns, returned qty on blanket would
19801    -- be updated when return is fulfilled!
19802    -- Changed to enable to accept CONFIG and SERVICE items for Pack -J onwards.
19803    IF ((OE_CODE_CONTROL.Get_Code_Release_Level >= '110510'
19804         AND p_x_line_rec.item_type_code <> 'INCLUDED')
19805        -- Blanket reference can only be specified for standard items
19806        -- and kit items
19807       OR (OE_CODE_CONTROL.Get_Code_Release_Level >= '110509'
19808            AND p_x_line_rec.item_type_code IN ('STANDARD','KIT')))
19809       AND (p_x_line_rec.blanket_number IS NOT NULL
19810        OR p_old_line_rec.blanket_number IS NOT NULL)
19811       AND p_x_line_rec.line_category_code = 'ORDER'
19812       -- QUOTING change
19813       AND nvl(p_x_line_rec.transaction_phase_code,'F') = 'F'
19814    THEN
19815 
19816      -- Blanket Request should not be logged for system splits.
19817      IF (nvl(p_x_line_rec.split_action_code,'X') = 'SPLIT'
19818          AND p_x_line_rec.operation = oe_globals.g_opr_update
19819          AND nvl(p_x_line_rec.split_by,'USER') = 'SYSTEM'
19820          )
19821      OR (nvl(p_x_line_rec.split_from_line_id,FND_API.G_MISS_NUM)
19822 				<> FND_API.G_MISS_NUM
19823          AND p_x_line_rec.operation = oe_globals.g_opr_create
19824          AND nvl(p_x_line_rec.split_by,'USER') = 'SYSTEM'
19825          )
19826      THEN
19827         NULL;
19828      ELSE
19829         Log_Blanket_Request(p_x_line_rec,p_old_line_rec);
19830      END IF;
19831 
19832    END IF;
19833 
19834   if l_debug_level > 0 then
19835    oe_debug_pub.add('Exiting Post_Write_Process',1);
19836   end if;
19837 
19838 EXCEPTION
19839 
19840     WHEN FND_API.G_EXC_ERROR THEN
19841 
19842         RAISE;
19843 
19844     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
19845 
19846 
19847         RAISE;
19848 
19849     WHEN OTHERS THEN
19850 
19851         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
19852         THEN
19853             oe_msg_pub.Add_Exc_Msg
19854             (   G_PKG_NAME
19855           ,   'Post_Write_Process'
19856             );
19857         END IF;
19858 
19859         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
19860 
19861 END Post_Write_Process;
19862 
19863 
19864 
19865 /*----------------------------------------------------------
19866 PROCEDURE Post_Line_Process
19867 -----------------------------------------------------------*/
19868 
19869 PROCEDURE Post_Line_Process
19870 (   p_control_rec		    		IN  OE_GLOBALS.Control_Rec_Type
19871 ,   p_x_line_tbl                   IN OUT NOCOPY  OE_Order_PUB.Line_Tbl_Type
19872 )
19873 IS
19874 l_return_status    VARCHAR2(1);
19875 I                  NUMBER;
19876 l_count            NUMBER;
19877 l_valid_line_number VARCHAR2(1) := 'Y';
19878 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
19879 BEGIN
19880 
19881  if l_debug_level > 0 then
19882   oe_debug_pub.add('entering Post_Line_Process', 1);
19883  end if;
19884 
19885   -- Create Sets for lines and call group scheduling if any
19886   /*
19887   IF (p_control_rec.process AND
19888 	OE_GLOBALS.G_RECURSION_MODE <> 'Y')THEN
19889       OE_Set_Util.Process_Sets
19890 		(p_x_line_tbl => p_x_line_tbl);
19891   END IF;
19892   */
19893 
19894   IF (p_control_rec.process AND
19895 	OE_GLOBALS.G_RECURSION_MODE <> 'Y') THEN
19896 
19897       -- batch validation request is executed in post_lines
19898       -- so that it gets executed before any other delayed requests
19899       -- like pricing, scheduling for models.
19900 
19901       OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
19902          (p_request_type   =>OE_GLOBALS.G_VALIDATE_CONFIGURATION
19903           ,p_delete        => FND_API.G_TRUE
19904           ,x_return_status => l_return_status
19905           );
19906 
19907      if l_debug_level > 0 then
19908       oe_debug_pub.add('ret sts: '|| l_return_status, 4);
19909      end if;
19910 
19911       IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
19912           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
19913       ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
19914           RAISE FND_API.G_EXC_ERROR;
19915       END IF;
19916 
19917       -- cascading of changes from model to options
19918       -- is done before executing other requests.
19919 
19920       OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
19921          (p_request_type   =>OE_GLOBALS.G_CASCADE_CHANGES
19922           ,p_delete        => FND_API.G_TRUE
19923           ,x_return_status => l_return_status
19924           );
19925 
19926       IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
19927           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
19928       ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
19929           RAISE FND_API.G_EXC_ERROR;
19930       END IF;
19931 
19932       -- Making change to whole configuration is done before all
19933       -- other delayed requests are fired.
19934 
19935       OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
19936          (p_request_type   => OE_GLOBALS.G_CHANGE_CONFIGURATION
19937           ,p_delete        => FND_API.G_TRUE
19938           ,x_return_status => l_return_status
19939           );
19940       IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
19941           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
19942       ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
19943           RAISE FND_API.G_EXC_ERROR;
19944       END IF;
19945 
19946       -- handling split of models
19947 
19948       OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
19949          (p_request_type   => OE_GLOBALS.G_COPY_CONFIGURATION
19950           ,p_delete        => FND_API.G_TRUE
19951           ,x_return_status => l_return_status
19952           );
19953 
19954       IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
19955           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
19956       ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
19957           RAISE FND_API.G_EXC_ERROR;
19958       END IF;
19959 
19960 
19961       IF OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.COUNT > 0 THEN
19962         oe_debug_pub.add('calling modufy inc items', 3);
19963         OE_Config_Pvt.Modify_Included_Items
19964         (x_return_status => l_return_status);
19965         OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.DELETE;
19966 
19967         IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
19968           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
19969         ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
19970           RAISE FND_API.G_EXC_ERROR;
19971         END IF;
19972       END IF;
19973 
19974 
19975       OE_SERVICE_UTIL.Update_Service_Lines
19976                (p_x_line_tbl      => p_x_line_tbl,
19977                 x_return_status   => l_return_status);
19978 
19979       IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
19980          RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
19981       ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
19982          RAISE FND_API.G_EXC_ERROR;
19983       END IF;
19984 
19985 
19986     -- added for bug fix 2375829
19987 
19988   if l_debug_level > 0 then
19989     oe_debug_pub.add('line tbl count: '||p_x_line_tbl.COUNT, 3);
19990   end if;
19991 
19992     I := p_x_line_tbl.FIRST;
19993 
19994     WHILE I is NOT NULL
19995     LOOP
19996 
19997     IF nvl(p_x_line_tbl(I).booked_flag, 'N') = 'N' THEN
19998        if l_debug_level > 0 then
19999         oe_debug_pub.add('not booked ', 3);
20000        end if;
20001           --below two lines are commented for bug 14298754
20002       --  EXIT;
20003      -- END IF;
20004     ELSE       -- Added for bug 14298755
20005 
20006      if l_debug_level > 0 then
20007       oe_debug_pub.add(p_x_line_tbl(I).operation ||
20008       ' cancelled flag ' || p_x_line_tbl(I).cancelled_flag||
20009       ' shp interf '||p_x_line_tbl(I).shipping_interfaced_flag, 3);
20010      end if;
20011 
20012       IF (p_x_line_tbl(I).operation = 'DELETE' OR
20013          (p_x_line_tbl(I).operation = 'UPDATE' AND
20014           p_x_line_tbl(I).cancelled_flag = 'Y')) AND
20015           p_x_line_tbl(I).top_model_line_id is not NULL AND
20016           nvl(p_x_line_tbl(I).ship_model_complete_flag, 'N') = 'Y' AND
20017           nvl(p_x_line_tbl(I).shipping_interfaced_flag, 'N') = 'N' AND
20018           nvl(p_x_line_tbl(I).model_remnant_flag, 'N') = 'N'
20019       THEN
20020         oe_debug_pub.add('cancel or delete, call smc shipping', 1);
20021 
20022         SELECT count(*)
20023         INTO   l_count
20024         FROM   oe_order_lines
20025         WHERE  top_model_line_id = p_x_line_tbl(I).top_model_line_id
20026         AND    shipping_interfaced_flag = 'Y';
20027 
20028         IF l_count = 0 THEN
20029 
20030           oe_debug_pub.add('need to call smc shipping', 1);
20031 
20032           OE_Shipping_Integration_PVT.Process_SMC_Shipping
20033           (p_line_id           => p_x_line_tbl(I).line_id
20034           ,p_top_model_line_id => p_x_line_tbl(I).top_model_line_id
20035           ,x_return_status     => l_return_status);
20036 
20037           IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
20038             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
20039           ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
20040             RAISE FND_API.G_EXC_ERROR;
20041           END IF;
20042        END IF;
20043 
20044       END IF;
20045     END IF;  --Added for bug 14298755
20046 -- Validate line number for bug no 5493479 start
20047 
20048       IF  (p_x_line_tbl(I).item_type_code = 'STANDARD'
20049               --below line commented to handle bugs 14298755 ,6186920
20050            --OR (p_x_line_tbl(I).top_model_line_id <> p_x_line_tbl(I).line_id
20051              OR (p_x_line_tbl(I).top_model_line_id = p_x_line_tbl(I).line_id    --Added for bugs 14298755 ,6186920
20052              AND p_x_line_tbl(I).item_type_code = 'MODEL'))
20053              AND OE_ORDER_IMPORT_MAIN_PVT.G_CONTEXT_ID IS NOT NULL
20054         THEN
20055          IF p_x_line_tbl(I).line_set_id IS NULL OR p_x_line_tbl(I).line_set_id = FND_API.G_MISS_NUM THEN  --If part added for bug# 14298755
20056           BEGIN
20057 
20058            SELECT 'N'
20059            INTO   l_valid_line_number
20060            FROM   oe_order_lines L
20061            WHERE  L.line_number = p_x_line_tbl(I).line_number
20062            AND    L.header_id = p_x_line_tbl(I).header_id
20063            AND    L.line_id <> p_x_line_tbl(I).line_id
20064            AND    ( L.item_type_code = 'STANDARD'
20065            OR     ( L.top_model_line_id = L.line_id
20066            AND      L.item_type_code = 'MODEL'));
20067 
20068           EXCEPTION
20069                 WHEN no_data_found THEN
20070                    l_valid_line_number := 'Y';
20071              -- Too many rows exception would be raised if there are split
20072                 -- lines with the same line number
20073                 WHEN too_many_rows THEN
20074                    l_valid_line_number := 'N';
20075                 WHEN OTHERS THEN
20076                    l_valid_line_number := 'N';
20077           END;
20078          ELSE
20079 
20080 	  BEGIN
20081            SELECT 'N'
20082            INTO   l_valid_line_number
20083            FROM   oe_order_lines L
20084            WHERE  L.line_number = p_x_line_tbl(I).line_number
20085            AND    L.header_id = p_x_line_tbl(I).header_id
20086            AND    L.line_id <> p_x_line_tbl(I).line_id
20087            AND    nvl(L.line_set_id,-9999) <>nvl( p_x_line_tbl(I).line_set_id,-9999) -- bug 10414075
20088            AND    ( L.item_type_code = 'STANDARD'
20089            OR     ( L.top_model_line_id = L.line_id
20090            AND      L.item_type_code = 'MODEL'));
20091 
20092           EXCEPTION
20093                 WHEN no_data_found THEN
20094                    l_valid_line_number := 'Y';
20095              -- Too many rows exception would be raised if there are split
20096                 -- lines with the same line number
20097                 WHEN too_many_rows THEN
20098                    l_valid_line_number := 'N';
20099                 WHEN OTHERS THEN
20100                    l_valid_line_number := 'N';
20101           END;
20102          END IF;   --Added for bug 14298755
20103 
20104           IF l_valid_line_number = 'N' THEN
20105                 FND_MESSAGE.SET_NAME('ONT','OE_LINE_NUMBER_EXISTS');
20106                 OE_MSG_PUB.ADD;
20107                 l_return_status := FND_API.G_RET_STS_ERROR;
20108                 RAISE FND_API.G_EXC_ERROR; --added for bug 14298755
20109           END IF;
20110 
20111          END IF;
20112 -- Validate line number for bug no 5493479 end
20113       I := p_x_line_tbl.NEXT(I);
20114 
20115     END LOOP;
20116 
20117   END IF; -- if not recursion and process = true.
20118 
20119 
20120   -- Move the code below so that cascading will happen if any before
20121   -- scheduling. 2404695
20122 
20123   -- Create Sets for lines and call group scheduling if any
20124 
20125   IF (p_control_rec.process AND
20126     OE_GLOBALS.G_RECURSION_MODE <> 'Y')THEN
20127 
20128       OE_Set_Util.Process_Sets
20129         (p_x_line_tbl => p_x_line_tbl);
20130 
20131     IF OE_SPLIT_UTIL.G_SPLIT_ACTION = TRUE THEN
20132 
20133       -- We will call split_scheduling here for lines which got created
20134       -- thru splits.
20135 
20136      if l_debug_level > 0 then
20137       oe_debug_pub.add('Calling Split Scheduling',1);
20138      end if;
20139 
20140       -- 4504362 :Branch Scheduling checks removed.
20141      IF p_x_line_tbl.count > 0 THEN -- 10626432
20142 
20143         OE_SCHEDULE_UTIL.Split_Scheduling
20144           (p_x_line_tbl      => p_x_line_tbl,
20145            x_return_status   => l_return_status);
20146      END IF;
20147 
20148       OE_SPLIT_UTIL.G_SPLIT_ACTION := FALSE;
20149 
20150       if l_debug_level > 0 then
20151        oe_debug_pub.add('After Calling Split Scheduling: ' ||
20152                          l_return_status,1);
20153       end if;
20154 
20155        IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
20156          RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
20157        ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
20158          RAISE FND_API.G_EXC_ERROR;
20159        END IF;
20160 
20161     END IF; -- if split action
20162 
20163   END IF;
20164 
20165   IF OE_SPLIT_UTIL.G_SPLIT_ACTION = TRUE THEN
20166 
20167    if l_debug_level > 0 then
20168     oe_debug_pub.add('Logging g_split_action',2);
20169    end if;
20170 
20171     I := p_x_line_tbl.FIRST;
20172     WHILE I is NOT NULL
20173     LOOP
20174 
20175 
20176       IF  (NVL(p_x_line_tbl(I).split_by ,'USER') = 'SYSTEM' AND
20177           NVL(p_x_line_tbl(I).split_action_code,'X') = 'SPLIT' AND
20178           p_x_line_tbl(I).schedule_status_code IS NOT NULL)
20179       OR (NVL(p_x_line_tbl(I).split_by ,'USER') = 'SYSTEM' AND
20180           p_x_line_tbl(I).split_from_line_id is not null AND
20181           p_x_line_tbl(I).split_from_line_id <> FND_API.G_MISS_NUM AND
20182           p_x_line_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE) THEN
20183 
20184          if l_debug_level > 0 then
20185           oe_debug_pub.add('Logging G_SPLIT_SCHEDULE' ||
20186                             p_x_line_tbl(I).line_id, 2);
20187          end if;
20188 
20189           OE_delayed_requests_Pvt.log_request(
20190           p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
20191           p_entity_id              => p_x_line_tbl(I).line_id,
20192           p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
20193           p_requesting_entity_id   => p_x_line_tbl(I).line_id,
20194           p_request_type           => OE_GLOBALS.G_SPLIT_SCHEDULE,
20195           p_param1                 => p_x_line_tbl(I).schedule_status_code,
20196           p_param2                 => p_x_line_tbl(I).arrival_set_id,
20197           p_param3                 => p_x_line_tbl(I).ship_set_id,
20198           p_param4                 => p_x_line_tbl(I).ship_model_complete_flag,
20199           p_param5                 => p_x_line_tbl(I).model_remnant_flag,
20200           p_param6                 => p_x_line_tbl(I).top_model_line_id,
20201           p_param7                 => p_x_line_tbl(I).ato_line_id,
20202           p_param8                 => p_x_line_tbl(I).item_type_code,
20203           p_param9                 => p_x_line_tbl(I).source_type_code,  --added for bug 12757660
20204           x_return_status          => l_return_status);
20205 
20206 
20207            OE_SPLIT_UTIL.G_SPLIT_ACTION := FALSE;
20208 
20209       END IF;
20210 
20211       I := p_x_line_tbl.NEXT(I);
20212 
20213     END LOOP;
20214 
20215   END IF; -- if not recursion and process = true.
20216 
20217 
20218  if l_debug_level > 0 then
20219   oe_debug_pub.add('leaving Post_Line_Process', 1);
20220  end if;
20221 EXCEPTION
20222 
20223     WHEN FND_API.G_EXC_ERROR THEN
20224         oe_debug_pub.add('execution error', 1);
20225         RAISE;
20226 
20227     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
20228         oe_debug_pub.add('unexp error', 1);
20229         RAISE;
20230 
20231     WHEN OTHERS THEN
20232         oe_debug_pub.add('others error', 1);
20233         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
20234         THEN
20235             oe_msg_pub.Add_Exc_Msg
20236             (   G_PKG_NAME
20237           ,   'Pre_Line_Process'
20238             );
20239         END IF;
20240 
20241         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
20242 
20243 END Post_Line_Process;
20244 
20245 
20246 /*----------------------------------------------------------
20247 Function Get_Return_Item_Type_Code
20248 -----------------------------------------------------------*/
20249 Function Get_Return_Item_Type_Code
20250 (   p_line_rec                      IN OE_Order_PUB.Line_Rec_Type
20251 ) RETURN varchar2
20252 IS
20253 l_item_type_code varchar2(30);
20254 BEGIN
20255 
20256   IF p_line_rec.line_category_code = 'RETURN'
20257   and p_line_rec.reference_line_id is not null THEN
20258 
20259   	SELECT item_type_code
20260   	INTO l_item_type_code
20261   	FROM oe_order_lines
20262      WHERE line_id = p_line_rec.reference_line_id;
20263 
20264      RETURN l_item_type_code;
20265   ELSE
20266      RETURN p_line_rec.item_type_code;
20267   END IF;
20268 
20269   RETURN p_line_rec.item_type_code;
20270 
20271 EXCEPTION
20272   WHEN NO_DATA_FOUND THEN
20273     RETURN null;
20274   WHEN OTHERS THEN
20275     RETURN null;
20276 END Get_Return_Item_Type_Code;
20277 
20278 
20279 
20280 /*----------------------------------------------------------
20281 
20282 --  OPM 02/JUN/00  BEGIN
20283 --  ====================
20284 
20285 FUNCTION dual_uom_control renamed from process_characteristics
20286 -----------------------------------------------------------*/
20287 
20288 FUNCTION dual_uom_control -- INVCONV renamed from process_characteristics
20289 (
20290   p_inventory_item_id IN NUMBER
20291  ,p_ship_from_org_id  IN NUMBER
20292  ,x_item_rec          OUT NOCOPY OE_ORDER_CACHE.item_rec_type
20293 )
20294 RETURN BOOLEAN
20295 IS
20296 
20297 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
20298 
20299 BEGIN
20300 /*   INVCONV
20301 IF FND_PROFILE.VALUE ('ONT_PROCESS_INSTALLED_FLAG') = 'N' THEN
20302   RETURN FALSE;
20303 END IF;  */
20304 
20305 /* If item and warehouse are both present, assess if this is
20306    a dual controlled ine:
20307  ======================================================================*/
20308 IF (p_inventory_item_id IS NOT NULL AND
20309   p_inventory_item_id <> FND_API.G_MISS_NUM) AND
20310   (p_ship_from_org_id  IS NOT NULL AND
20311   p_ship_from_org_id <> FND_API.G_MISS_NUM) THEN
20312     x_item_rec :=
20313     	     OE_Order_Cache.Load_Item (p_inventory_item_id
20314                                     ,p_ship_from_org_id);
20315 --  IF x_item_rec.process_warehouse_flag = 'Y'  INVCONV
20316 -- AND INVCONV
20317   oe_debug_pub.add('in function Dual_uom_control - tracking_quantity_ind  = ' || x_item_rec.tracking_quantity_ind);
20318   IF x_item_rec.tracking_quantity_ind = 'PS' -- INVCONV
20319     THEN
20320 
20321     IF l_debug_level  > 0 THEN
20322     	oe_debug_pub.add('Dual_uom_control is TRUE ', 1);
20323     end if;
20324     RETURN TRUE;
20325   END IF;
20326 END IF;
20327 
20328 IF l_debug_level  > 0 THEN
20329     	oe_debug_pub.add('Dual_uom_control is FALSE ', 1);
20330 end if;
20331 
20332 RETURN FALSE;
20333 
20334 
20335 EXCEPTION
20336 WHEN NO_DATA_FOUND THEN
20337   RETURN NULL;
20338 WHEN OTHERS THEN
20339      IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
20340      THEN
20341          OE_MSG_PUB.Add_Exc_Msg
20342          (     G_PKG_NAME         ,
20343              'dual_uom_control'
20344          );
20345      END IF;
20346         oe_debug_pub.add('others in dual_uom_control', 1);
20347      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
20348 
20349 END dual_uom_control ;
20350 
20351 
20352 /*----------------------------------------------------------
20353 FUNCTION Get_Dual_Uom
20354 ----------------------------------------------------------- INVCONV REMOVEd to OE_Default_Line
20355 
20356 FUNCTION Get_Dual_Uom(p_line_rec OE_ORDER_PUB.Line_Rec_Type)
20357 RETURN VARCHAR2
20358 IS
20359 -- l_APPS_UOM2  VARCHAR2(3) := NULL; INVCONV
20360 l_status     VARCHAR2(1);
20361 l_msg_count  NUMBER;
20362 l_msg_data   VARCHAR2(2000);
20363 l_item_rec   OE_ORDER_CACHE.item_rec_type;
20364 
20365 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
20366 
20367 BEGIN
20368        if l_debug_level > 0 then
20369 	oe_debug_pub.add('Enter Get dual uom');
20370        end if;
20371 
20372 IF dual_uom_control   -- INVCONV  Process_Characteristics
20373   (p_line_rec.inventory_item_id,p_line_rec.ship_from_org_id,l_item_rec) THEN
20374   IF l_item_rec.tracking_quantity_ind = 'PS' THEN -- INVCONV
20375        if l_debug_level > 0 then
20376 					oe_debug_pub.add('Get dual uom - tracking in P and S ');
20377        end if;
20378       -- convert 4 digit apps OPM codes to equivalent 3 byte APPS codes
20379       -- Primary UM
20380       GMI_Reservation_Util.Get_AppsUOM_from_OPMUOM
20381 					 (p_OPM_UOM        => l_item_rec.opm_item_um2
20382 					 ,x_Apps_UOM       => l_APPS_UOM2
20383 					 ,x_return_status  => l_status
20384 					 ,x_msg_count      => l_msg_count
20385 					 ,x_msg_data       => l_msg_data);
20386 
20387 
20388 
20389        if l_debug_level > 0 then
20390 					oe_debug_pub.add('Get  Dual Uom returns dual UM of ' || l_item_rec.secondary_uom_code);
20391        end if;
20392   END IF;
20393 END IF;
20394 RETURN l_item_rec.secondary_uom_code; -- INVCONV
20395 
20396 EXCEPTION
20397 
20398 WHEN NO_DATA_FOUND THEN
20399 
20400        if l_debug_level > 0 then
20401 	oe_debug_pub.add('No Data Found Get Dual Uom' );
20402        end if;
20403 RETURN NULL;
20404 
20405 WHEN OTHERS THEN
20406      IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
20407      THEN
20408          OE_MSG_PUB.Add_Exc_Msg
20409          (     G_PKG_NAME         ,
20410              'Get_Dual_Uom'
20411          );
20412      END IF;
20413        if l_debug_level > 0 then
20414         oe_debug_pub.add('others in get_dual uom', 1);
20415        end if;
20416      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
20417 
20418 
20419 END Get_Dual_Uom;   */
20420 
20421 
20422 /*----------------------------------------------------------
20423 FUNCTION Get_Preferred_Grade
20424 -----------------------------------------------------------   INVCONV removed
20425 
20426 FUNCTION Get_Preferred_Grade(p_line_rec OE_ORDER_PUB.Line_Rec_Type,
20427 					    p_old_line_rec OE_ORDER_PUB.Line_Rec_Type)
20428 RETURN VARCHAR2
20429 IS
20430 l_grade_ctl       NUMBER(5):= NULL;
20431 l_preferred_grade VARCHAR2(4) := NULL;
20432 l_item_rec        OE_ORDER_CACHE.item_rec_type;
20433 
20434 CURSOR C_GRADE1 IS
20435 SELECT alot.prefqc_grade
20436 FROM op_alot_prm alot, ic_item_mst item, op_cust_mst cust
20437 WHERE item.item_id = l_item_rec.opm_item_id
20438           and alot.cust_id = cust.cust_id
20439 		  and item.alloc_class = alot.alloc_class
20440 		  and alot.delete_mark = 0
20441 		  and cust.of_ship_to_site_use_id = p_line_rec.ship_to_org_id;
20442 
20443 CURSOR C_GRADE2 IS
20444 SELECT alot.prefqc_grade
20445 FROM op_alot_prm alot, ic_item_mst item
20446 WHERE item.item_id = l_item_rec.opm_item_id
20447 	       and alot.cust_id IS NULL
20448 		  and item.alloc_class = alot.alloc_class
20449 		  and alot.delete_mark = 0;
20450 BEGIN
20451 
20452 IF oe_line_util.Process_Characteristics
20453   (p_line_rec.inventory_item_id,p_line_rec.ship_from_org_id,l_item_rec) AND
20454   ((NOT OE_GLOBALS.EQUAL(p_line_rec.ordered_item
20455                        ,p_old_line_rec.ordered_item)) OR
20456   (NOT OE_GLOBALS.EQUAL(p_line_rec.ship_from_org_id
20457                        ,p_old_line_rec.ship_from_org_id))) AND
20458   (p_line_rec.preferred_grade IS NULL OR
20459     p_line_rec.preferred_grade = FND_API.G_MISS_CHAR) THEN
20460   NULL;
20461 ELSE
20462   RETURN p_line_rec.preferred_grade;
20463 END IF;
20464 oe_debug_pub.add('OPM Test grade ctl for preferred grade');
20465 
20466 IF l_item_rec.grade_ctl = 1 THEN
20467   OPEN C_GRADE1;
20468   FETCH C_GRADE1 into l_preferred_grade;
20469   IF (C_GRADE1%NOTFOUND) THEN
20470     CLOSE C_GRADE1;
20471     OPEN C_GRADE2;
20472     FETCH C_GRADE2 into l_preferred_grade;
20473     IF (C_GRADE2%NOTFOUND) THEN
20474       CLOSE C_GRADE2;
20475 	 RETURN NULL;
20476     END IF;
20477   END IF;
20478 END IF;
20479 RETURN l_preferred_grade;
20480 
20481 EXCEPTION
20482 
20483 
20484 WHEN OTHERS THEN
20485      IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
20486      THEN
20487          OE_MSG_PUB.Add_Exc_Msg
20488          (     G_PKG_NAME         ,
20489              'Get_Preferred_Grade'
20490          );
20491      END IF;
20492         oe_debug_pub.add('others in get_preferred_grade', 1);
20493      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
20494 
20495 
20496 END Get_Preferred_Grade;   */
20497 
20498 -- Comment Label for procedure added as part of Inline Documentation Drive.
20499 ------------------------------------------------------------------------------------
20500 -- Procedure Name : Sync_Dual_Qty
20501 -- Input Params   : p_x_line_rec        : New Line Record for POAPI Processing.
20502 --                  p_old_line_rec      : Old Line Record for POAPI Processing.
20503 -- Output Params  : p_x_line_rec        : New Line Record for POAPI Processing.
20504 -- Description    : This procedure does a sync up of the dual quantity i.e.
20505 --                  syncs up the qrdered_quantity2 as per the ordered_quantity
20506 --                  on line getting processed, if it is needed, i.e. if its a
20507 --                  split line, or some update is happening on warehouse.
20508 --                  There are several conditions of Early Exit from the procedure
20509 --                  if processing/recalculation of Ordered_Quantity2 is not needed.
20510 --                  In the end, if there is no early exit, the ordered_quantity2 is
20511 --                  recalculated from ordered_quantity based on UOMs and conversion
20512 --                  setup.
20513 --                  This procedure is called only from this package and is useful
20514 --                  during creation of SPLIT Line in ITS and also during update
20515 --                  of Warehouse on the Order Line.
20516 --                  The conditions of early exit are like below:
20517 --                  a) Non Dual Control
20518 --                  b) Cancellation of Line.
20519 --                  c) If Secondary_Default_Index is not "Fixed" for OPM.
20520 --                  d) While Splitting during ITS,so as to directly populate data
20521 --                     from Shipping, rather than recalculating.
20522 --                  e) If neither qordered_quantity of ordered_quantity2 are present.
20523 --                  f) Early return if no Sync is required, due to no change.
20524 ------------------------------------------------------------------------------------
20525 /*----------------------------------------------------------
20526 PROCEDURE Sync_Dual_Qty
20527 -----------------------------------------------------------*/
20528 PROCEDURE Sync_Dual_Qty
20529 (
20530    P_X_LINE_REC        IN OUT NOCOPY OE_ORDER_PUB.Line_Rec_Type
20531   ,P_OLD_LINE_REC      IN OE_ORDER_PUB.Line_Rec_Type
20532 )
20533 IS
20534 
20535 l_converted_qty        NUMBER(19,9);          -- OPM 25/AUG/00
20536 l_item_rec             OE_ORDER_CACHE.item_rec_type;
20537 -- l_OPM_UOM              VARCHAR2(4); INVCONV
20538 l_return               NUMBER;
20539 l_status               VARCHAR2(1);
20540 l_msg_count            NUMBER;
20541 -- l_msg_data             VARCHAR2(2000); -- INVCONV
20542 UOM_CONVERSION_FAILED  EXCEPTION;             -- OPM B1478461
20543 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
20544 l_buffer                  VARCHAR2(2000); -- INVCONV
20545 
20546 --X_message VARCHAR2(1000);       -- INVCONV
20547 --X_temp NUMBER;
20548 
20549 
20550 
20551 BEGIN
20552 
20553 
20554 IF l_debug_level  > 0 THEN
20555  		oe_debug_pub.add('Entering Sync Dual Qty');
20556 END IF;
20557 
20558 
20559   /* Moved this code from below to here - 2999767 */
20560  /* If this is a dual_control item line, load the item details from cache
20561  ==============================================================*/
20562 IF dual_uom_control
20563  (p_x_line_rec.inventory_item_id,p_x_line_rec.ship_from_org_id,
20564  l_item_rec) THEN
20565 --   IF l_item_rec.dualum_ind not in (1,2,3) INVCONV
20566     IF l_item_rec.tracking_quantity_ind <> 'PS'
20567 
20568     THEN
20569       IF l_debug_level  > 0 THEN
20570  					oe_debug_pub.add('Sync Dual Qty not dual controlled  - return');   -- INVCONV
20571 			END IF;
20572       p_x_line_rec.ordered_quantity2 := NULL;
20573       RETURN;
20574    END IF;
20575 ELSE
20576 
20577   IF l_debug_level  > 0 THEN
20578  					oe_debug_pub.add('not dual controlled -  return');
20579 	END IF;
20580 
20581   --  p_x_line_rec.ordered_quantity2 := NULL;      OPM 2711743
20582   RETURN;
20583 END IF;
20584 
20585 IF (OE_OE_FORM_CANCEL_LINE.g_ord_lvl_can) THEN -- 5141545
20586 	       oe_debug_pub.add ('Sync Dual Qty - Cancellation so return ' );
20587 	       return;
20588 	 else
20589 	    oe_debug_pub.add ('Sync Dual Qty - NOT a cancellation ' );
20590 END IF;
20591 
20592 
20593 IF l_debug_level  > 0 THEN
20594 	oe_debug_pub.add ('In sync_dual_qty');
20595 	oe_debug_pub.add ('ordered_quantity = ' || p_x_line_rec.ordered_quantity );
20596 	oe_debug_pub.add ('ordered_quantity2 = ' || p_x_line_rec.ordered_quantity2 );
20597 
20598 	oe_debug_pub.add ('ordered_quantity_uom = ' || p_x_line_rec.order_quantity_uom );
20599 	oe_debug_pub.add ('ordered_quantity_uom2 = ' || p_x_line_rec.ordered_quantity_uom2 );
20600 	oe_debug_pub.add ('inventory_item_id = ' || p_x_line_rec.inventory_item_id );
20601 	oe_debug_pub.add ('ship_from_org_id = ' || p_x_line_rec.ship_from_org_id );
20602 	oe_debug_pub.add ('secondary_default_ind  =  ' || l_item_rec.secondary_default_ind   );
20603 	oe_debug_pub.add ('p_x_line_rec.source_document_type_id = ' || p_x_line_rec.source_document_type_id );
20604 
20605 	IF p_x_line_rec.ordered_quantity_uom2 = FND_API.G_MISS_CHAR THEN
20606 	 		oe_debug_pub.add ('ordered_quantity_uom2 = G_MISS_CHAR  ' );
20607 	ELSIF
20608 	  p_x_line_rec.ordered_quantity_uom2 is null THEN
20609 	   	oe_debug_pub.add ('ordered_quantity_uom2 = null' );
20610 	END IF;
20611 	IF p_x_line_rec.ordered_quantity2 = FND_API.G_MISS_NUM THEN
20612 	 		oe_debug_pub.add ('ordered_quantity2 = G_MISS_NUM  ' );
20613 	ELSIF
20614 	  p_x_line_rec.ordered_quantity2 is null THEN
20615 	   	oe_debug_pub.add ('ordered_quantity2 = null' );
20616 	END IF;
20617 
20618 
20619 END IF;
20620 
20621 
20622 
20623 
20624 -- secondary_default_ind value of ' ' = type 0
20625 -- secondary_default_ind value of F   = type 1
20626 -- secondary_default_ind value of D   = type 2
20627 -- secondary_default_ind value of N   = type 3
20628 
20629 -- bug 4053117 start  pal
20630  IF  OE_GLOBALS.Equal(p_x_line_rec.ship_from_org_id,p_old_line_rec.ship_from_org_id)
20631     and l_item_rec.secondary_default_ind <> 'F'
20632          and (
20633    				(p_x_line_rec.ordered_quantity IS NOT NULL and
20634  					 p_x_line_rec.ordered_quantity <> FND_API.G_MISS_NUM )  AND
20635   					(p_x_line_rec.ordered_quantity2 IS NOT NULL and
20636   					p_x_line_rec.ordered_quantity2 <> FND_API.G_MISS_NUM )
20637   					) THEN
20638     		 IF l_debug_level  > 0 THEN
20639  						oe_debug_pub.add('Sync_dual_qty IF (OE_GLOBALS.G_UI_FLAG) and ship froms = -   early exit ');
20640 				 END IF;
20641  				 RETURN;
20642 END IF;
20643 -- bug 4053117 end
20644 
20645 -- 5172701 pal
20646 IF NOT ( OE_GLOBALS.Equal(p_x_line_rec.ship_from_org_id,p_old_line_rec.ship_from_org_id) )
20647 and l_item_rec.secondary_uom_code is NOT NULL
20648   THEN
20649    p_x_line_rec.ordered_quantity_uom2 := l_item_rec.secondary_uom_code;
20650 END IF;
20651 
20652 
20653 
20654 
20655 IF ( (nvl(p_x_line_rec.shipping_quantity2,0) > 0)
20656      -- OPM B1661023 04/02/01 PARENT with a SYSTEM split from SHIPPING
20657      AND ((nvl(P_X_LINE_REC.ordered_quantity,0) =  nvl(P_OLD_LINE_REC.ordered_quantity,0)
20658          AND (nvl(P_X_LINE_REC.ordered_quantity2,0) =  nvl(P_OLD_LINE_REC.ordered_quantity2,0)))
20659      -- OPM B2169135 03/18/01  Qty 1 or 2 should default with item controls when one qty is changed.
20660          )
20661  OR
20662      (p_x_line_rec.split_from_line_id IS NOT NULL AND
20663       -- CHILD with a SYSTEM split from SHIPPING
20664       p_x_line_rec.split_by = 'SYSTEM' AND
20665       -- need to check if user or system  , early exit if system else sync
20666       p_x_line_rec.line_category_code <> 'RETURN'
20667       AND ((nvl(P_X_LINE_REC.ordered_quantity,0) =  nvl(P_OLD_LINE_REC.ordered_quantity,0)
20668            AND (nvl(P_X_LINE_REC.ordered_quantity2,0) =  nvl(P_OLD_LINE_REC.ordered_quantity2,0)))))
20669       -- OPM B2169135 03/18/01  Qty 1 or 2 should default with item controls when one qty is changed.
20670    )
20671 
20672  /* Begin 2999767 */
20673 -- OR   ( l_item_rec.dualum_ind = 1
20674    OR   ( l_item_rec.secondary_default_ind  = 'F' -- INVCONV
20675       AND (nvl(p_x_line_rec.shipping_quantity2,0) > 0) -- OPM  PARENT with a SYSTEM split from SHIPPING
20676       AND (nvl(P_X_LINE_REC.ordered_quantity,0) <> 0)
20677       AND (nvl(P_X_LINE_REC.ordered_quantity2,0) <> 0)
20678       )
20679  --OR   ( l_item_rec.dualum_ind = 1
20680  OR   ( l_item_rec.secondary_default_ind  = 'F' -- INVCONV
20681       AND p_x_line_rec.split_from_line_id IS NOT NULL  -- CHILD with a SYSTEM split from SHIPPING
20682       AND p_x_line_rec.split_by = 'SYSTEM'
20683       -- need to check if user or system  , early exit if system else sync
20684       AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE --13503975
20685       AND p_x_line_rec.line_category_code <> 'RETURN'
20686       AND ((nvl(P_X_LINE_REC.ordered_quantity,0) <> 0) )
20687       AND ((nvl(P_X_LINE_REC.ordered_quantity2,0) <> 0)) )  --added for bug 7418730
20688 -- Bug 7418730 is for secondary quantity getting cleared on change of warehouse
20689 -- on system split line.This part of code was causing early exit and not allowing
20690 -- the secondary quantity to be populated. Added extra condition to avoid the early exit.
20691  /* End Bug2999767 */
20692 THEN
20693 
20694 	 IF l_debug_level  > 0 THEN
20695  			oe_debug_pub.add('Sync_dual_qty -  early exit ');
20696 	 END IF;
20697 
20698    RETURN;
20699 END IF;  -- OPM B1661023 04/02/01
20700 
20701 
20702 /* If neither quantity is present, no sync is required
20703 ======================================================*/
20704 IF (p_x_line_rec.ordered_quantity IS NULL OR
20705   p_x_line_rec.ordered_quantity = FND_API.G_MISS_NUM ) AND
20706   (p_x_line_rec.ordered_quantity2 IS NULL OR
20707   p_x_line_rec.ordered_quantity2 = FND_API.G_MISS_NUM ) THEN
20708 
20709 	  IF l_debug_level  > 0 THEN
20710   		oe_debug_pub.add ('Sync_dual_qty -  both quantities empty so early return');
20711   	END IF;
20712 
20713     RETURN;
20714 END IF;
20715 
20716 IF l_debug_level  > 0 THEN
20717 	oe_debug_pub.add('Sync_dual_qty - Convert for dual Scenario',1); -- INVCONV
20718 END IF;
20719 
20720 /* -- Bug3052287  INVCONV
20721 -- When the primary UOM1 itself is not populated, derive it from l_item_rec.
20722   IF (p_x_line_rec.order_quantity_uom is NULL)
20723  or (p_x_line_rec.order_quantity_uom = FND_API.G_MISS_CHAR )
20724  THEN
20725    GMI_Reservation_Util.Get_AppsUOM_from_OPMUOM
20726 					 (p_OPM_UOM        => l_item_rec.opm_item_um
20727 					 ,x_Apps_UOM       => p_x_line_rec.order_quantity_uom
20728 					 ,x_return_status  => l_status
20729 					 ,x_msg_count      => l_msg_count
20730 					 ,x_msg_data       => l_msg_data);
20731 
20732  END IF; */
20733 -- End bug3052287
20734 
20735 /* If the ordered_quantity_um has changed, force recalculation of quantity2
20736 unless we have a no default process item where there is no
20737 automatic calculation
20738 ==========================================================================*/
20739 IF (NOT OE_GLOBALS.EQUAL(p_x_line_rec.order_quantity_uom
20740          			    ,p_old_line_rec.order_quantity_uom ))
20741   AND p_old_line_rec.order_quantity_uom is not NULL  -- OPM 24/OCT/00 B1458751
20742  -- AND l_item_rec.dualum_ind <> 3  -- INVCONV
20743   AND l_item_rec.secondary_default_ind <> 'N' -- INVCONV
20744  THEN
20745   p_x_line_rec.ordered_quantity2 := NULL;
20746 END IF;
20747 
20748 /* Has one of the two quantities changed */
20749 
20750 IF (NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity
20751          			    ,p_old_line_rec.ordered_quantity )) OR
20752    (NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity2
20753          			    ,p_old_line_rec.ordered_quantity2)) OR
20754    (p_x_line_rec.ordered_quantity  IS NULL) OR
20755    (p_x_line_rec.ordered_quantity2 IS NULL) THEN
20756 
20757       IF l_debug_level  > 0 THEN
20758       	oe_debug_pub.add('Sync_dual_qty - change detected ',1);
20759       END IF;
20760 
20761  --  IF l_item_rec.dualum_ind in (0,3)  INVCONV
20762      IF (l_item_rec.secondary_default_ind = 'N' or
20763         l_item_rec.secondary_default_ind is null )
20764         --and ( p_x_line_rec.source_type_code  <> 'INTERNAL' )  -- INVCONV internal orders fix for PO reqs
20765         and NOT (nvl(p_x_line_rec.source_document_type_id,-99) = 10 ) -- INVCONV DEC 23
20766 
20767   		THEN
20768 
20769 	/* NO UM Conversion required for types 3 so return here and not internal order line  -- INVCONV
20770 	============================================================*/
20771 	    IF l_debug_level  > 0 THEN
20772       	oe_debug_pub.add('Sync_dual_qty - default ind is N or null - early return ',1);
20773       END IF;
20774 
20775       RETURN;
20776     END IF;
20777 ELSE
20778    /* No sync required
20779    ==================*/
20780    IF l_debug_level  > 0 THEN
20781       	oe_debug_pub.add('Sync_dual_qty - no change detected so no sync',1);
20782     END IF;
20783 
20784    RETURN;
20785 END IF; -- IF (NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity
20786 
20787 oe_debug_pub.add('Sync_dual_qty - here 1 ',1);
20788 
20789 IF (NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity
20790          			    ,p_old_line_rec.ordered_quantity )) OR
20791 				     p_x_line_rec.ordered_quantity2 IS NULL THEN
20792   /* Primary quantity has changed so recalculate secondary */
20793 
20794 --  IF l_item_rec.dualum_ind = 2  INVCONV
20795     IF l_item_rec.secondary_default_ind  = 'D' and  -- INVCONV
20796     p_x_line_rec.ordered_quantity is NOT NULL AND
20797     p_x_line_rec.order_quantity_uom <> p_x_line_rec.ordered_quantity_uom2 AND -- B1390859
20798     /* Only do tolerance check if both quantities populated */
20799     p_x_line_rec.ordered_quantity2 is NOT NULL
20800     and   ( p_x_line_rec.ordered_quantity2 <> FND_API.G_MISS_NUM  and -- INVCONV for PO req
20801     NOT (nvl(p_x_line_rec.source_document_type_id,-99) = 10) )   -- INVCONV DEC 23 not for internal order line
20802      THEN
20803 
20804 	  IF l_debug_level  > 0 THEN
20805 	  	  oe_debug_pub.add('Check the deviation  ');
20806     END IF;
20807 
20808 
20809 
20810  /*   l_return := GMICVAL.dev_validation(l_item_rec.opm_item_id  INVCONV
20811                                       ,0
20812 					             ,p_x_line_rec.ordered_quantity
20813 					             ,l_OPM_UOM
20814 					             ,p_x_line_rec.ordered_quantity2
20815                                       ,l_item_rec.opm_item_um2
20816 					             ,0);    */
20817     -- if change is within of tolerance, no further action
20818 
20819      l_return := INV_CONVERT.Within_Deviation  -- INVCONV
20820                        ( p_organization_id   =>
20821                                  p_x_line_rec.ship_from_org_id
20822                        , p_inventory_item_id =>
20823                                  p_x_line_rec.inventory_item_id
20824                        , p_precision         => 5
20825                        , p_quantity          => abs(p_x_line_rec.ordered_quantity) -- 5128490
20826                        , p_uom_code1         => p_x_line_rec.order_quantity_uom
20827                        , p_quantity2         => abs(p_x_line_rec.ordered_quantity2) -- 5128490
20828                        , p_uom_code2         => l_item_rec.secondary_uom_code );
20829       IF l_return = 0
20830       	then
20831       	    IF l_debug_level  > 0 THEN
20832     	  			oe_debug_pub.add('Sync_dual_qty - tolerance error 1 ' ,1);
20833     			 END IF;
20834 
20835     			 l_buffer          := FND_MSG_PUB.GET(p_msg_index => FND_MSG_PUB.G_LAST, -- INVCONV
20836                                          p_encoded => 'F');
20837            oe_msg_pub.add_text(p_message_text => l_buffer);
20838            IF l_debug_level  > 0 THEN
20839               oe_debug_pub.add(l_buffer,1);
20840     			 END IF;
20841     			 RAISE fnd_api.g_exc_error;
20842 
20843    		else
20844       	IF l_debug_level  > 0 THEN
20845     	  		oe_debug_pub.add('Sync_dual_qty - No tolerance error so return ',1);
20846     		END IF;
20847      	RETURN;
20848      END IF; -- IF l_return = 0
20849 
20850 
20851 
20852   END IF;  --   IF l_item_rec.secondary_default_ind  = 'D'
20853 
20854 
20855   IF l_debug_level  > 0 THEN
20856   	oe_debug_pub.add('Sync_dual_qty  - uom conversion primary to secondary');
20857   END IF;
20858 
20859 -- OPM June 2003 3011880 begin - when converting qtys, if the p_x_line_rec.ordered_quantity_uom2 is not available yet,
20860 -- then convert the opm um2 to the apps um for the call to get_opm_converted_qty below which requires apps uoms
20861 --
20862 
20863 /*	 IF ( p_x_line_rec.ordered_quantity_uom2 is NULL  INVCONV
20864            or p_x_line_rec.ordered_quantity_uom2 = FND_API.G_MISS_CHAR )
20865 	  THEN
20866       	-- convert 4 digit apps OPM codes to equivalent 3 byte APPS codes
20867       	-- Primary UM
20868       		GMI_Reservation_Util.Get_AppsUOM_from_OPMUOM
20869 					 (p_OPM_UOM        => l_item_rec.opm_item_um2
20870 					 ,x_Apps_UOM       => p_x_line_rec.ordered_quantity_uom2
20871 					 ,x_return_status  => l_status
20872 					 ,x_msg_count      => l_msg_count
20873 					 ,x_msg_data       => l_msg_data);
20874 		oe_debug_pub.add('OPM in sync_dual - Get_AppsUOM_from_OPMUOM returns dual UM of ' || p_x_line_rec.ordered_quantity_uom2);
20875   	END IF;   */
20876 
20877 -- OPM June 2003 3011880 end
20878 
20879 
20880 
20881 -- OPM 25/AUG/00 - use precision of 19,9 to match OPM processing
20882 /*  l_converted_qty :=GMICUOM.uom_conversion
20883  	            (l_item_rec.opm_item_id,0
20884      	    	  ,p_x_line_rec.ordered_quantity
20885                  ,l_OPM_UOM
20886     	    	       ,l_item_rec.opm_item_um2,0);
20887 
20888 -- Feb 2003 2683316 - changed the call to GMI uom_conversion above to get_opm_converted_qty
20889 -- to resolve rounding issues
20890 
20891       l_converted_qty  := GMI_Reservation_Util.get_opm_converted_qty(
20892               p_apps_item_id    => p_x_line_rec.inventory_item_id,
20893               p_organization_id => p_x_line_rec.ship_from_org_id,
20894               p_apps_from_uom   => p_x_line_rec.order_quantity_uom,
20895               p_apps_to_uom     => p_x_line_rec.ordered_quantity_uom2,
20896               p_original_qty    => p_x_line_rec.ordered_quantity); */
20897     --start 8501046
20898       /*Bug#8947452 Modified the below condition so that the secondary
20899 quantity gets calculated for the fixed items. */
20900    If(p_x_line_rec.ordered_quantity2 is NULL OR l_item_rec.secondary_default_ind = 'F') then
20901       l_converted_qty := INV_CONVERT.INV_UM_CONVERT(p_x_line_rec.inventory_item_id -- INVCONV
20902       																									, NULL
20903       																								 ,p_x_line_rec.SHIP_FROM_ORG_id -- invconv
20904                                                       ,5 --NULL
20905                                                       ,p_x_line_rec.ordered_quantity
20906                                                       ,p_x_line_rec.order_quantity_uom
20907                                                       ,l_item_rec.secondary_uom_code
20908                                                       ,NULL -- From uom name
20909                                                       ,NULL -- To uom name
20910                                                       );
20911 
20912       IF l_debug_level  > 0 THEN
20913       	oe_debug_pub.add('Sync_dual_qty - secondary qty after conversion is  '||l_converted_qty);
20914  			END IF;
20915 -- Feb 2003 2683316 end
20916 
20917   IF (l_converted_qty < 0) THEN    -- OPM B1478461 Start
20918     raise UOM_CONVERSION_FAILED;
20919   END IF;                          -- OPM B1478461 End
20920   p_x_line_rec.ordered_quantity2 := l_converted_qty;      -- OPM 25/AUG/00
20921 
20922   end if;  --end 8501046
20923 
20924 
20925 ELSIF (NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity2
20926          			        ,p_old_line_rec.ordered_quantity2 )) THEN
20927   /* Secondary quantity has changed so recalculate primary
20928   =======================================================*/
20929 
20930 
20931   -- IF l_item_rec.dualum_ind = 2 and p_x_line_rec.ordered_quantity2 is NOT NULL AND   -- INVCONV
20932      IF l_item_rec.secondary_default_ind  = 'D' and  -- INVCONV
20933     p_x_line_rec.ordered_quantity2 is NOT NULL AND
20934     p_x_line_rec.order_quantity_uom <> p_x_line_rec.ordered_quantity_uom2 AND -- B1390859
20935     p_x_line_rec.ordered_quantity is NOT NULL THEN
20936     /* Only do tolerance check if both quantities populated */
20937 
20938     -- if change is within of tolerance, no further action
20939     l_return := INV_CONVERT.Within_Deviation  -- INVCONV
20940                        ( p_organization_id   =>
20941                                  p_x_line_rec.ship_from_org_id
20942                        , p_inventory_item_id =>
20943                                  p_x_line_rec.inventory_item_id
20944                        , p_precision         => 5
20945                        , p_quantity          => abs(p_x_line_rec.ordered_quantity) -- 5128490
20946                        , p_uom_code1         => p_x_line_rec.order_quantity_uom
20947                        , p_quantity2         => abs(p_x_line_rec.ordered_quantity2)  -- 5128490
20948                        , p_uom_code2         => l_item_rec.secondary_uom_code );
20949 
20950       IF l_return = 0
20951       	then
20952        	   IF l_debug_level  > 0 THEN
20953     	  			oe_debug_pub.add('Sync_dual_qty - tolerance error 2' ,1);
20954     			 END IF;
20955 
20956     			 l_buffer          := FND_MSG_PUB.GET(p_msg_index => FND_MSG_PUB.G_LAST, -- INVCONV
20957                                          p_encoded => 'F');
20958            oe_msg_pub.add_text(p_message_text => l_buffer);
20959            IF l_debug_level  > 0 THEN
20960               oe_debug_pub.add(l_buffer,1);
20961     			 END IF;
20962     			 RAISE fnd_api.g_exc_error;
20963 
20964 
20965    		else
20966       	IF l_debug_level  > 0 THEN
20967     	  		oe_debug_pub.add('Sync_dual_qty - No tolerance error so return ',1);
20968     		END IF;
20969      	RETURN;
20970      END IF; -- IF l_return = 0
20971 
20972 
20973 
20974   /*  l_return := GMICVAL.dev_validation(l_item_rec.opm_item_id
20975                                       ,0
20976 					             ,p_x_line_rec.ordered_quantity
20977 					             ,l_OPM_UOM
20978 					             ,p_x_line_rec.ordered_quantity2
20979                                       ,l_item_rec.opm_item_um2
20980 					             ,0);
20981     -- if change is within tolerance, no further action
20982     --===================================================
20983     IF (l_return NOT in (-68, -69)) THEN
20984        RETURN;
20985     END IF;   */
20986 
20987 
20988   END IF; --  IF l_item_rec.secondary_default_ind  = 'D' and  -- INVCONV
20989 
20990   /* Convert secondary quantity to derive primary
20991   ==============================================*/
20992 
20993   -- OPM 25/AUG/00
20994   -- use l_converted_qty with precision of 19,9 to match OPM processing
20995 
20996 
20997 -- Feb 2003 2683316 - changed the call to GMI uom_conversion above to get_opm_converted_qty
20998 -- to resolve rounding issues
20999 
21000       /*l_converted_qty  := GMI_Reservation_Util.get_opm_converted_qty(  -- INVCONV
21001               p_apps_item_id    => p_x_line_rec.inventory_item_id,
21002               p_organization_id => p_x_line_rec.ship_from_org_id,
21003               p_apps_from_uom   => p_x_line_rec.ordered_quantity_uom2,
21004               p_apps_to_uom     => p_x_line_rec.order_quantity_uom ,
21005               p_original_qty    => p_x_line_rec.ordered_quantity2);  */
21006     /*Bug#8433348 - code below is not to reconvert the secondary to primary when
21007  * it exists and secondary is the
21008  *        change from null to non null value */
21009 
21010       IF l_item_rec.secondary_default_ind  = 'F' and
21011          OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity2 ,NVL(p_old_line_rec.ordered_quantity2 ,p_x_line_rec.ordered_quantity2))
21012           and p_x_line_rec.ordered_quantity is not null THEN
21013 
21014           IF l_debug_level  > 0 THEN oe_debug_pub.add('Sync_dual_qty  - do not reconvert the secondary to primary when it exists and secondary is changed
21015 from null to non null - early return');
21016                           END IF;
21017          return;
21018       END IF;
21019       -- end of Bug#8433348
21020 
21021        l_converted_qty := INV_CONVERT.INV_UM_CONVERT(p_x_line_rec.inventory_item_id -- INVCONV
21022        																								, NULL
21023        																								,p_x_line_rec.ship_from_org_id -- INVCONV
21024                                                       ,5 --NULL
21025                                                       ,p_x_line_rec.ordered_quantity2
21026                                                       ,l_item_rec.secondary_uom_code
21027                                                       ,p_x_line_rec.order_quantity_uom
21028                                                       ,NULL -- From uom name
21029                                                       ,NULL -- To uom name
21030                                                       );
21031 
21032 
21033   		IF (l_converted_qty < 0) THEN    -- OPM B1478461 Start
21034    	 		raise UOM_CONVERSION_FAILED;
21035   		END IF;                          -- OPM B1478461 End
21036 
21037       IF l_debug_level  > 0 THEN
21038       	oe_debug_pub.add(' Sync_dual_qty - primary qty after conversion is  '||l_converted_qty);
21039       END IF;
21040 
21041       p_x_line_rec.ordered_quantity := l_converted_qty;
21042 
21043 END IF; -- IF (NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity
21044 
21045 
21046 EXCEPTION
21047 
21048 --OPM B1478461 Start
21049 WHEN UOM_CONVERSION_FAILED THEN
21050 
21051      --   FND_MESSAGE.SET_NAME('GMI','IC_API_UOM_CONVERSION_ERROR');     -- INVCONV
21052      --
21053      -- OPM BEGIN - BUG 2586841 - Added if condition for the message tokens to mask FND errors (why?)
21054      --
21055     /* IF ( p_x_line_rec.ordered_item is NULL  OR
21056           p_x_line_rec.ordered_item = FND_API.G_MISS_CHAR) THEN
21057          FND_MESSAGE.SET_TOKEN('ITEM_NO',to_char(nvl(p_x_line_rec.inventory_item_id, 0)));
21058      END IF;       */ -- INVCONV
21059     FND_MESSAGE.SET_NAME('INV','INV_NO_CONVERSION_ERR'); -- INVCONV
21060 
21061      --
21062      -- OPM END - BUG 2586841
21063      --
21064      OE_MSG_PUB.Add;
21065      RAISE FND_API.G_EXC_ERROR;
21066 --OPM B1478461 End
21067 
21068 WHEN fnd_api.g_exc_error THEN -- INVCONV
21069       RAISE FND_API.G_EXC_ERROR;
21070 
21071 WHEN OTHERS THEN
21072      IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
21073      THEN
21074          OE_MSG_PUB.Add_Exc_Msg
21075          (     G_PKG_NAME         ,
21076              'Sync_Dual_Qty'
21077          );
21078      END IF;
21079         oe_debug_pub.add('Exception handling: others in Sync_Dual_Qty', 1);
21080      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
21081 
21082 
21083 END Sync_Dual_Qty;
21084 
21085 /*-----------------------------------------------------------
21086 FUNCTION Calculate_Ordered_Quantity2
21087 ------------------------------------------------------------  -- INVCONV
21088 --   comment out this as it will not be used in the converged inventory code  replaced by calculate_dual_quantity
21089 
21090 FUNCTION Calculate_Ordered_Quantity2
21091 (
21092    P_LINE_REC          IN OE_ORDER_PUB.Line_Rec_Type
21093 )  RETURN NUMBER
21094 IS
21095 
21096 l_item_rec             OE_ORDER_CACHE.item_rec_type;
21097 -- OPM 25/AUG/00 - add precision of 19,9
21098 l_ordered_quantity2    NUMBER(19,9) := p_line_rec.ordered_quantity2;
21099 l_OPM_UOM              VARCHAR2(4);
21100 l_return               NUMBER;
21101 l_status               VARCHAR2(1);
21102 l_msg_count            NUMBER;
21103 l_msg_data             VARCHAR2(2000);
21104 
21105 BEGIN
21106 
21107 oe_debug_pub.add('OPM Enter Calculate_Ordered_Quantity2');
21108 
21109 
21110 -- If this is a process line, load the item details from cache
21111 --==============================================================
21112 IF oe_line_util.Process_Characteristics
21113   (p_line_rec.inventory_item_id,p_line_rec.ship_from_org_id,l_item_rec) THEN
21114    NULL;
21115 ELSE
21116   RETURN p_line_rec.ordered_quantity2;
21117 END IF;
21118 
21119 
21120 -- Usually ordered_quantity2 is not calculated for items where
21121 dualum_ind=3, but in a split scenario, the calc IS automated.
21122 --============================================================
21123 IF l_item_rec.dualum_ind in (1,2,3) THEN
21124   oe_debug_pub.add('OPM Dualum ind 3 is true');
21125 
21126 
21127  -- Feb 2003 2683316 - changed the call to GMI uom_conversion above to get_opm_converted_qty
21128 -- to resolve rounding issues
21129 
21130       l_ordered_quantity2 := GMI_Reservation_Util.get_opm_converted_qty(
21131               p_apps_item_id    => p_line_rec.inventory_item_id,
21132               p_organization_id => p_line_rec.ship_from_org_id,
21133               p_apps_from_uom   => p_line_rec.order_quantity_uom ,
21134               p_apps_to_uom     => p_line_rec.ordered_quantity_uom2,
21135               p_original_qty    => p_line_rec.ordered_quantity);
21136 
21137       oe_debug_pub.add('OPM secondary in Calculate_Ordered_Quantity2 after new get_opm_converted_qty is  '||l_ordered_quantity2);
21138 
21139 -- Feb 2003 2683316 end
21140 
21141 ELSE
21142   l_ordered_quantity2 := NULL;
21143 END IF;
21144 
21145   oe_debug_pub.add('OPM Return ordered_quantity2 set to '|| l_ordered_quantity2);
21146 RETURN l_ordered_quantity2;
21147 
21148 EXCEPTION
21149 
21150 WHEN OTHERS THEN
21151      IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
21152      THEN
21153          OE_MSG_PUB.Add_Exc_Msg
21154          (          G_PKG_NAME         ,
21155                     'Calculate Ordered Quantity2'
21156          );
21157      END IF;
21158      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
21159 
21160 
21161 END Calculate_Ordered_Quantity2;
21162 --   OPM 02/JUN/00 END of OPM added procedures
21163 
21164 */
21165 
21166 /*-----------------------------------------------------------
21167 PROCEDURE Pre_Attribute_Security
21168 ------------------------------------------------------------*/
21169 PROCEDURE Pre_Attribute_Security
21170 (   p_x_line_rec       IN OUT  NOCOPY OE_ORDER_PUB.Line_Rec_Type
21171 ,   p_old_line_rec        IN          OE_ORDER_PUB.Line_Rec_Type
21172 ,   p_index               IN          NUMBER
21173 ) IS
21174    l_return_status VARCHAR2(1);
21175     --Added for bug 14296662
21176    l_shipping_uom  VARCHAR2(3) := NULL;
21177 
21178    l_return_code           		NUMBER; -- INVCONV
21179    l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level; -- INVCONV
21180    l_qty number; -- INVCONV
21181    l_qty2 number; -- INVCONV
21182    l_ordered_qty number;  --nocopy impact changes
21183  BEGIN
21184 
21185 	if l_debug_level > 0 then -- INVCONV
21186   		oe_debug_pub.add('Entering Pre_Attribute_Security - reserved_quantity = ' || p_x_line_rec.reserved_quantity );
21187   end if;
21188 
21189       -- Added this code for Splits
21190       -- Need to send the rounded QTY for line if the
21191       -- Operations is Create and Split_From_Line_Id is not null or
21192       -- Operation is Update and action is split
21193       -- Bug #3705273
21194   IF (NVL(p_x_line_rec.shipping_quantity_uom,p_x_line_rec.order_quantity_uom)
21195          = p_x_line_rec.order_quantity_uom) THEN  -- added 14296662
21196 
21197 
21198       IF (p_x_line_rec.split_action_code = 'SPLIT'
21199          AND p_x_line_rec.operation = oe_globals.g_opr_update
21200          )
21201       OR (p_x_line_rec.split_from_line_id is not null
21202          AND p_x_line_rec.split_from_line_id <> fnd_api.g_miss_num
21203          AND p_x_line_rec.operation = oe_globals.g_opr_create
21204          )
21205       THEN
21206 
21207 	 --In case of create operation, line has shipping quantity uom 14296662
21208          IF p_x_line_rec.split_from_line_id is not null then
21209          --bug 6196000
21210            begin
21211            select shipping_quantity_uom INTO l_shipping_uom
21212              from oe_order_lines_all
21213             where line_id = p_x_line_rec.split_from_line_id;
21214 	   exception
21215 	   when no_data_found then
21216 	    oe_debug_pub.add('setting the uom to null');
21217 	    l_shipping_uom:=null;
21218 	   end;
21219          --bug 6196000
21220          END IF;
21221         IF l_shipping_uom is null then  --14296662
21222 
21223 
21224         --Then you need to call the Quantity rounding API to round off the qty on the line
21225         l_ordered_qty :=  p_x_line_rec.ordered_quantity;  --nocopy impact changes
21226 	OE_Validate_Line.Validate_Decimal_Quantity
21227   	(p_item_id	    => p_x_line_rec.inventory_item_id
21228 	,p_item_type_code   => p_x_line_rec.item_type_code
21229 	,p_input_quantity   => l_ordered_qty                                      --nocopy impact changes
21230 	,p_uom_code         => p_x_line_rec.order_quantity_uom
21231         ,p_ato_line_id      => p_x_line_rec.ato_line_id
21232         ,p_line_id          => p_x_line_rec.line_id
21233         ,p_line_num         => p_x_line_rec.line_number
21234 	,p_action_split     => 'Y'
21235         ,x_output_quantity  => p_x_line_rec.ordered_quantity
21236 	,x_return_status    => l_return_status);
21237 
21238 	IF l_return_status = FND_API.G_RET_STS_ERROR THEN
21239           RAISE FND_API.G_EXC_ERROR;
21240         END IF;
21241       END IF;-- ship uom is null 14296662
21242       END IF;
21243      END IF ; -- same UOM condition 14296662
21244       oe_debug_pub.add('PAS 2 Qty :'||p_x_line_rec.ordered_quantity);
21245 
21246       -- Populate Set Ids IF Set Names are given
21247       -- This will harcode the defaulting for schduling attributes
21248       -- THis is kept outside defaulting framework to handle cases
21249       -- Asd Default_attributes = FALSE
21250       -- Another call is for create time in defaulint to cover line_id
21251 
21252       -- As part of scheduling restructure. dependency will added with
21253       -- bug 2164440.
21254       --4504362 : Branch Scheduling check removed.
21255      -- OPM 02/JUN/00
21256 	   oe_line_util.Sync_Dual_Qty (p_x_line_rec => p_x_line_rec
21257 							 ,p_old_line_rec => p_old_line_rec);
21258      -- OPM 02/JUN/00 END
21259 -- INVCONV
21260  -- check this - why call here ??  need to know where to call in proper place - ask OM team
21261 
21262  --oe_debug_pub.add('reserved_quantity = ' || p_x_line_rec.reserved_quantity );
21263 -- oe_debug_pub.add('reserved_quantity2 = ' || p_x_line_rec.reserved_quantity2 );
21264              IF NOT(OE_GLOBALS.G_UI_FLAG) and -- 4958890
21265                p_x_line_rec.ordered_quantity <> FND_API.G_MISS_NUM And
21266                        p_x_line_rec.ordered_quantity IS NOT NULL and
21267                        p_x_line_rec.ordered_quantity2 <> FND_API.G_MISS_NUM And
21268                        p_x_line_rec.ordered_quantity2 IS NOT NULL and
21269                        p_x_line_rec.ordered_quantity_uom2 is not null  and
21270                        p_x_line_rec.ordered_quantity_uom2 <> FND_API.G_MISS_CHAR and
21271                       (  (  p_x_line_rec.reserved_quantity <> FND_API.G_MISS_NUM And
21272                        p_x_line_rec.reserved_quantity IS NOT NULL )
21273                       or (  p_x_line_rec.reserved_quantity2 <> FND_API.G_MISS_NUM And
21274                        p_x_line_rec.reserved_quantity2 IS NOT NULL ) )
21275                        Then
21276 
21277  		        							IF p_x_line_rec.reserved_quantity <> FND_API.G_MISS_NUM And
21278                             p_x_line_rec.reserved_quantity IS NOT NULL then
21279                                l_qty := p_x_line_rec.reserved_quantity;
21280 
21281                         	end if;
21282                         	IF p_x_line_rec.reserved_quantity2 <> FND_API.G_MISS_NUM And
21283                             p_x_line_rec.reserved_quantity2 IS NOT NULL then
21284                                l_qty2 := p_x_line_rec.reserved_quantity2;
21285 
21286                         	end if;
21287 
21288 
21289  					  							if l_debug_level > 0 then -- INVCONV
21290                 						oe_debug_pub.add('pre_attribute_security - about to call calculate_dual_quantity. l_qty = ' || l_qty);
21291                 						oe_debug_pub.add('pre_attribute_security - about to call calculate_dual_quantity. l_qty2 = ' || l_qty2);
21292                         	end if;
21293                         IF l_qty <>0 or
21294                            l_qty2 <> 0
21295                         then
21296 		 										oe_line_util.calculate_dual_quantity(
21297                          p_ordered_quantity => l_qty
21298                         ,p_old_ordered_quantity => NULL
21299                         ,p_ordered_quantity2 => l_qty2 -- p_x_line_rec.reserved_quantity2
21300                         ,p_old_ordered_quantity2 => NULL
21301                         ,p_ordered_quantity_uom  => p_x_line_rec.order_quantity_uom
21302                         ,p_ordered_quantity_uom2 => p_x_line_rec.ordered_quantity_uom2
21303                         ,p_inventory_item_id     => p_x_line_rec.inventory_item_id
21304                         ,p_ship_from_org_id      => p_x_line_rec.ship_from_org_id
21305                         ,x_ui_flag 		 => 0
21306                         ,x_return_status         => l_return_code
21307                         );
21308 
21309 
21310                         IF l_return_code <> 0 THEN -- INVCONV
21311 	     										 IF l_return_status = -1  or
21312 	     										    l_return_status = -99999
21313 	     										 THEN
21314 															p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
21315 															RAISE FND_API.G_EXC_ERROR;
21316 														else
21317 															p_x_line_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
21318 															RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
21319 
21320 														END IF;
21321 
21322 												ELSE
21323 												  p_x_line_rec.reserved_quantity2 := l_qty2;
21324 												  p_x_line_rec.reserved_quantity := l_qty;
21325 
21326 												END IF; --  IF l_return_code <> 0 THEN -- INVCONV
21327 
21328 
21329       									IF l_debug_level  > 0 THEN
21330        	  								oe_debug_pub.add('Pre_Attribute_Security after call to calculate_dual_quantity for reserved_quantities - return status = : ' || l_return_code);
21331 													oe_debug_pub.add('reserved_quantity =  : ' || p_x_line_rec.reserved_quantity);
21332 													oe_debug_pub.add('reserved_quantity2 = : ' || p_x_line_rec.reserved_quantity2);
21333 
21334    											END IF;
21335 
21336    											END IF;  -- IF l_qty <>0 then
21337 
21338     			END IF; -- INVCONV
21339 
21340 
21341 
21342 END Pre_Attribute_Security;
21343 
21344 
21345 /*---------------------------------------------------------------------
21346 Procedure Log_CTO_Requests
21347 
21348 This procedure is added only because code in pre_write is
21349 getting cluttered and there are many CTO chg order
21350 related requests which we will have in one place.
21351 We need to notify CTO
21352 1) for changes to ato model/options if config item exists.
21353 2) for ato item if it is scheduled.(both item_type = standard and option)
21354 3) in case of pto+ato, if new option is created and
21355    even 1 config item exist.
21356 ----------------------------------------------------------------------*/
21357 PROCEDURE Log_CTO_Requests
21358 (p_x_line_rec    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
21359 ,p_old_line_rec  IN             OE_Order_PUB.Line_Rec_Type :=
21360                                    OE_Order_PUB.G_MISS_LINE_REC
21361 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
21362 IS
21363   l_num                   NUMBER;
21364   l_flag                  BOOLEAN;
21365   l_notify_cto            BOOLEAN;
21366   l_ato_item_qty_change   BOOLEAN;
21367   l_pto_ato_create        BOOLEAN;
21368   l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
21369 BEGIN
21370  if l_debug_level > 0 then
21371   oe_debug_pub.add('entering Log_CTO_Requests', 1);
21372  end if;
21373 
21374   l_flag := FALSE;
21375 
21376   IF p_x_line_rec.ato_line_id is not NULL AND
21377      ((p_x_line_rec.schedule_status_code is NULL AND
21378        p_x_line_rec.operation = 'CREATE' ) OR
21379       (p_x_line_rec.schedule_ship_date is NOT NULL)) AND
21380      ((nvl(p_x_line_rec.split_action_code, 'X') <> 'SPLIT' OR
21381       (p_x_line_rec.split_action_code = FND_API.G_MISS_CHAR AND
21382        NOT (p_x_line_rec.split_from_line_id is NOT NULL))) OR
21383       OE_Code_Control.Code_Release_Level >= '110510')
21384   THEN
21385 
21386    if l_debug_level > 0 then
21387     oe_debug_pub.add('configuration scheduled', 5);
21388    end if;
21389 
21390     IF OE_Code_Control.Code_release_Level < '110510' THEN
21391 
21392       BEGIN
21393         SELECT line_id
21394         INTO   l_num
21395         FROM   oe_order_lines
21396         WHERE  ato_line_id = p_x_line_rec.ato_line_id
21397         AND    top_model_line_id = p_x_line_rec.top_model_line_id
21398         AND    item_type_code = OE_GLOBALS.G_ITEM_CONFIG;
21399 
21400         l_flag := TRUE;
21401       EXCEPTION
21402         WHEN NO_DATA_FOUND THEN
21403          if l_debug_level > 0 then
21404           oe_debug_pub.add('config item not yet created', 2);
21405          end if;
21406       END;
21407     ELSE
21408       l_flag := TRUE;
21409     END IF;
21410   ELSE
21411   if l_debug_level > 0 then
21412    oe_debug_pub.add('flag is false', 2);
21413   end if;
21414   END IF;
21415 
21416   l_ato_item_qty_change := FALSE;
21417 
21418   IF p_x_line_rec.ato_line_id = p_x_line_rec.line_id AND
21419      (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_STANDARD OR
21420       p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION OR --##1820608
21421       p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_INCLUDED) AND --9775352
21422      p_old_line_rec.schedule_status_code is NOT NULL AND
21423      p_x_line_rec.operation <> OE_GLOBALS.G_OPR_CREATE
21424   THEN
21425     if l_debug_level > 0 then
21426      oe_debug_pub.add('ato item, may need to notify cto', 4);
21427     end if;
21428      l_flag := TRUE;
21429 
21430      IF p_x_line_rec.ordered_quantity = 0 AND
21431         p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
21432 
21433        if l_debug_level > 0 then
21434         oe_debug_pub.add('ato item qty made to 0'|| p_x_line_rec.open_flag, 4);
21435        end if;
21436         l_ato_item_qty_change := TRUE;
21437 
21438      END IF;
21439 
21440   END IF;
21441 
21442  if l_debug_level > 0 then
21443   oe_debug_pub.add('split?     : ' || p_x_line_rec.split_action_code, 3);
21444   oe_debug_pub.add('split from : ' || p_x_line_rec.split_from_line_id, 3);
21445   oe_debug_pub.add('line id:     ' || p_x_line_rec.line_id, 3);
21446   oe_debug_pub.add('ato line id: ' || p_x_line_rec.ato_line_id , 3);
21447   oe_debug_pub.add('item type:   ' || p_x_line_rec.item_type_code, 3);
21448   oe_debug_pub.add('operation:   ' || p_x_line_rec.operation, 3);
21449   oe_debug_pub.add('old qty:     ' || p_old_line_rec.ordered_quantity, 3);
21450   oe_debug_pub.add('new qty:     ' || p_x_line_rec.ordered_quantity, 3);
21451   oe_debug_pub.add('old ssd:     ' || p_old_line_rec.schedule_ship_date, 3);
21452   oe_debug_pub.add('new ssd:     ' || p_x_line_rec.schedule_ship_date, 3);
21453   oe_debug_pub.add('old rd:      ' || p_old_line_rec.request_date, 3);
21454   oe_debug_pub.add('new rd:      ' || p_x_line_rec.request_date, 3);
21455   oe_debug_pub.add('old sad:     ' || p_old_line_rec.schedule_arrival_date,3);
21456   oe_debug_pub.add('new sad:     ' || p_x_line_rec.schedule_arrival_date,3);
21457   oe_debug_pub.add('new sch sts: ' || p_x_line_rec.schedule_status_code,3);
21458   oe_debug_pub.add('old sch sts: ' || p_old_line_rec.schedule_status_code,3);
21459   oe_debug_pub.add('open flag:   ' || p_x_line_rec.open_flag,3);
21460   oe_debug_pub.add('cascade:     ' || oe_config_util.CASCADE_CHANGES_FLAG, 3);
21461   oe_debug_pub.add('validate:    ' || OE_CONFIG_PVT.OECFG_VALIDATE_CONFIG, 3);
21462   oe_debug_pub.add('ui:          ' || OE_CONFIG_UTIL.G_CONFIG_UI_USED, 3);
21463 
21464   oe_debug_pub.add('old qty2:     ' || p_old_line_rec.ordered_quantity2, 3); -- INVCONV
21465   oe_debug_pub.add('new qty2:     ' || p_x_line_rec.ordered_quantity2, 3);
21466   oe_debug_pub.add('old uom2:     ' || p_old_line_rec.ordered_quantity_uom2, 3); -- INVCONV
21467   oe_debug_pub.add('new uom2:     ' || p_x_line_rec.ordered_quantity_uom2, 3);
21468   oe_debug_pub.add('old uom:     ' || p_old_line_rec.order_quantity_uom, 3); -- INVCONV
21469   oe_debug_pub.add('new uom:     ' || p_x_line_rec.order_quantity_uom, 3);
21470 
21471 
21472   oe_debug_pub.add('ssd old' ||
21473   to_char (new_time (p_old_line_rec.schedule_ship_date, 'PST', 'EST'),
21474                                  'DD-MON-YY HH24:MI:SS'), 3);
21475   oe_debug_pub.add('ssd new' ||
21476   to_char (new_time (p_x_line_rec.schedule_ship_date, 'PST', 'EST'),
21477                                  'DD-MON-YY HH24:MI:SS'), 3);
21478  end if;
21479 
21480   l_notify_cto := FALSE;
21481 
21482   -- only for ATO models and ATO under PTO, all are oprn = update
21483 
21484   IF p_x_line_rec.ato_line_id = p_x_line_rec.line_id AND
21485      l_flag AND
21486      NOT (p_x_line_rec.split_from_line_id IS NOT NULL  AND
21487           p_x_line_rec.split_from_line_id <> FND_API.G_MISS_NUM AND
21488           p_x_line_rec.operation = 'CREATE') THEN
21489 
21490    if l_debug_level > 0 then
21491     oe_debug_pub.add('compare for ato model now', 3);
21492    end if;
21493 
21494     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_from_org_id,
21495                            p_old_line_rec.ship_from_org_id) THEN
21496 
21497      if l_debug_level > 0 then
21498       oe_debug_pub.add('cto_change logged for warehouse change', 3);
21499      end if;
21500       l_notify_cto := TRUE;
21501 
21502       OE_delayed_requests_Pvt.log_request
21503       (p_entity_code            => OE_GLOBALS.G_ENTITY_LINE, --Bug 14375128
21504        p_entity_id              => p_x_line_rec.line_id,
21505        p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
21506        p_requesting_entity_id   => p_x_line_rec.line_id,
21507        p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
21508        p_request_unique_key1    => 'Warehouse',
21509        p_param1                 => p_old_line_rec.ship_from_org_id,
21510        p_param2                 => p_x_line_rec.ship_from_org_id,
21511        p_param3                 => p_x_line_rec.ato_line_id,
21512        x_return_status          => x_return_status);
21513 
21514     END IF;
21515 
21516     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,
21517                             p_old_line_rec.ordered_quantity) THEN
21518 
21519      if l_debug_level > 0 then
21520       oe_debug_pub.add('cto_change logged for qty change', 3);
21521      end if;
21522 
21523       l_notify_cto := TRUE;
21524 
21525       OE_delayed_requests_Pvt.log_request
21526       (p_entity_code            => OE_GLOBALS.G_ENTITY_LINE, --Bug 14375128
21527        p_entity_id              => p_x_line_rec.line_id,
21528        p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
21529        p_requesting_entity_id   => p_x_line_rec.line_id,
21530        p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
21531        p_request_unique_key1    => 'Quantity',
21532        p_param1                 => p_old_line_rec.ordered_quantity,
21533        p_param2                 => p_x_line_rec.ordered_quantity,
21534        p_param3                 => p_x_line_rec.ato_line_id,
21535        x_return_status          => x_return_status);
21536 
21537     END IF;
21538 
21539     IF NOT OE_GLOBALS.Equal(p_x_line_rec.request_date,
21540                             p_old_line_rec.request_date) THEN
21541 
21542      if l_debug_level > 0 then
21543       oe_debug_pub.add('cto_change logged for req date change', 3);
21544      end if;
21545       l_notify_cto := TRUE;
21546 
21547        OE_delayed_requests_Pvt.log_request
21548        (p_entity_code            => OE_GLOBALS.G_ENTITY_LINE, --Bug 14375128
21549         p_entity_id              => p_x_line_rec.line_id,
21550         p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
21551         p_requesting_entity_id   => p_x_line_rec.line_id,
21552         p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
21553         p_request_unique_key1    => 'Req Date',
21554         p_param1                 => p_old_line_rec.request_date,
21555         p_param2                 => p_x_line_rec.request_date,
21556         p_param3                 => p_x_line_rec.ato_line_id,
21557         x_return_status          => x_return_status);
21558 
21559     END IF;
21560 
21561     IF NOT OE_GLOBALS.Equal(p_x_line_rec.schedule_ship_date,
21562                             p_old_line_rec.schedule_ship_date) AND
21563        NOT l_ato_item_qty_change
21564     THEN
21565 
21566      if l_debug_level > 0 then
21567       oe_debug_pub.add('cto_change logged for sch ship date change', 3);
21568      end if;
21569       l_notify_cto := TRUE;
21570 
21571       OE_delayed_requests_Pvt.log_request
21572        (p_entity_code            => OE_GLOBALS.G_ENTITY_LINE, --Bug 14375128
21573         p_entity_id              => p_x_line_rec.line_id,
21574         p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
21575         p_requesting_entity_id   => p_x_line_rec.line_id,
21576         p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
21577         p_request_unique_key1    => 'Ship Date',
21578         p_param1                 => p_old_line_rec.schedule_ship_date,
21579         p_param2                 => p_x_line_rec.schedule_ship_date,
21580         p_param3                 => p_x_line_rec.ato_line_id,
21581         x_return_status          => x_return_status);
21582 
21583     END IF;
21584 
21585     IF NOT OE_GLOBALS.Equal(p_x_line_rec.schedule_arrival_date,
21586                             p_old_line_rec.schedule_arrival_date) AND
21587        NOT l_ato_item_qty_change THEN
21588 
21589      if l_debug_level > 0 then
21590       oe_debug_pub.add('cto_change logged for sch arr date change', 3);
21591      end if;
21592       l_notify_cto := TRUE;
21593 
21594       OE_delayed_requests_Pvt.log_request
21595        (p_entity_code            => OE_GLOBALS.G_ENTITY_LINE, --Bug 14375128
21596         p_entity_id              => p_x_line_rec.line_id,
21597         p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
21598         p_requesting_entity_id   => p_x_line_rec.line_id,
21599         p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
21600         p_request_unique_key1    => 'Arr Date',
21601         p_param1                 => p_old_line_rec.schedule_arrival_date,
21602         p_param2                 => p_x_line_rec.schedule_arrival_date,
21603         p_param3                 => p_x_line_rec.ato_line_id,
21604         x_return_status          => x_return_status);
21605 
21606     END IF;
21607 
21608    -- INVCONV
21609 
21610      IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity2,
21611                             p_old_line_rec.ordered_quantity2) THEN
21612 
21613      if l_debug_level > 0 then
21614       oe_debug_pub.add('cto_change logged for qty2 change', 3);
21615      end if;
21616 
21617       l_notify_cto := TRUE;
21618 
21619       OE_delayed_requests_Pvt.log_request
21620       (p_entity_code            => OE_GLOBALS.G_ENTITY_LINE, --Bug 14375128
21621        p_entity_id              => p_x_line_rec.line_id,
21622        p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
21623        p_requesting_entity_id   => p_x_line_rec.line_id,
21624        p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
21625        p_request_unique_key1    => 'Quantity2',
21626        p_param1                 => p_old_line_rec.ordered_quantity2,
21627        p_param2                 => p_x_line_rec.ordered_quantity2,
21628        p_param3                 => p_x_line_rec.ato_line_id,
21629        x_return_status          => x_return_status);
21630 
21631     END IF;
21632 
21633 		IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity_uom2,
21634                             p_old_line_rec.ordered_quantity_uom2) THEN
21635 
21636      if l_debug_level > 0 then
21637       oe_debug_pub.add('cto_change logged for Uom2 change', 3);
21638      end if;
21639 
21640       l_notify_cto := TRUE;
21641 
21642       OE_delayed_requests_Pvt.log_request
21643       (p_entity_code            => OE_GLOBALS.G_ENTITY_LINE, --Bug 14375128
21644        p_entity_id              => p_x_line_rec.line_id,
21645        p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
21646        p_requesting_entity_id   => p_x_line_rec.line_id,
21647        p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
21648        p_request_unique_key1    => 'Uom2',
21649        p_param1                 => p_old_line_rec.ordered_quantity_uom2,
21650        p_param2                 => p_x_line_rec.ordered_quantity_uom2,
21651        p_param3                 => p_x_line_rec.ato_line_id,
21652        x_return_status          => x_return_status);
21653 
21654     END IF;
21655 
21656     IF NOT OE_GLOBALS.Equal(p_x_line_rec.order_quantity_uom,
21657                             p_old_line_rec.order_quantity_uom) THEN
21658 
21659      if l_debug_level > 0 then
21660       oe_debug_pub.add('cto_change logged for Uom change', 3);
21661      end if;
21662 
21663       l_notify_cto := TRUE;
21664 
21665       OE_delayed_requests_Pvt.log_request
21666       (p_entity_code            => OE_GLOBALS.G_ENTITY_LINE, --Bug 14375128
21667        p_entity_id              => p_x_line_rec.line_id,
21668        p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
21669        p_requesting_entity_id   => p_x_line_rec.line_id,
21670        p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
21671        p_request_unique_key1    => 'Uom',
21672        p_param1                 => p_old_line_rec.order_quantity_uom,
21673        p_param2                 => p_x_line_rec.order_quantity_uom,
21674        p_param3                 => p_x_line_rec.ato_line_id,
21675        x_return_status          => x_return_status);
21676 
21677     END IF;
21678 -- INVCONV END
21679 
21680 
21681   ELSIF p_x_line_rec.ato_line_id = p_x_line_rec.line_id AND
21682         OE_Code_Control.Code_Release_Level >= '110510' AND
21683         p_x_line_rec.schedule_status_code is NULL AND
21684         p_x_line_rec.schedule_ship_date is NULL AND
21685         p_old_line_rec.schedule_ship_date is NOT NULL THEN
21686 
21687    if l_debug_level > 0 then
21688     oe_debug_pub.add('cto_change logged for unschedule', 3);
21689    end if;
21690 
21691     l_notify_cto := TRUE;
21692 
21693     OE_delayed_requests_Pvt.log_request
21694      (p_entity_code            => OE_GLOBALS.G_ENTITY_LINE, --Bug 14375128
21695       p_entity_id              => p_x_line_rec.line_id,
21696       p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
21697       p_requesting_entity_id   => p_x_line_rec.line_id,
21698       p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
21699       p_request_unique_key1    => 'Ship Date',
21700       p_param1                 => p_old_line_rec.schedule_ship_date,
21701       p_param2                 => p_x_line_rec.schedule_ship_date,
21702       p_param3                 => p_x_line_rec.ato_line_id,
21703       x_return_status          => x_return_status);
21704 
21705   END IF; -- update on model line logged
21706 
21707   IF p_x_line_rec.ato_line_id is NOT NULL AND
21708      p_x_line_rec.ato_line_id <> p_x_line_rec.line_id AND
21709      p_x_line_rec.item_type_code <> OE_GLOBALS.G_ITEM_CONFIG AND
21710      ((oe_config_util.CASCADE_CHANGES_FLAG = 'N' AND
21711        OE_CONFIG_PVT.OECFG_VALIDATE_CONFIG = 'Y') OR
21712        OE_CONFIG_UTIL.G_CONFIG_UI_USED = 'Y') AND
21713      l_flag AND
21714      nvl(p_x_line_rec.split_action_code, 'X') <> 'SPLIT' AND -- split update
21715      NOT (p_x_line_rec.split_from_line_id is NOT NULL AND
21716           p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE) -- split create
21717   THEN
21718    if l_debug_level > 0 then
21719     oe_debug_pub.add('part of ato', 3);
21720    end if;
21721 
21722     l_pto_ato_create := FALSE;
21723 
21724     BEGIN
21725       SELECT 1
21726       INTO   l_num
21727       FROM   oe_order_lines
21728       WHERE  line_id = p_x_line_rec.top_model_line_id
21729       AND    top_model_line_id = nvl(ato_line_id, -1);
21730 
21731     EXCEPTION
21732       WHEN NO_DATA_FOUND THEN
21733 
21734         IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
21735          if l_debug_level > 0 then
21736           oe_debug_pub.add('pto top model and opr create', 1);
21737          end if;
21738           l_pto_ato_create := TRUE;
21739         END IF;
21740     END;
21741 
21742 
21743     IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
21744         NOT l_pto_ato_create) OR
21745        p_x_line_rec.operation = OE_GLOBALS.G_OPR_DELETE OR
21746        (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
21747         NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,
21748                              p_old_line_rec.ordered_quantity))
21749 
21750     THEN
21751 
21752      if l_debug_level > 0 then
21753       oe_debug_pub.add('cto_change logged for config change', 3);
21754      end if;
21755 
21756       l_notify_cto := TRUE;
21757 
21758       OE_delayed_requests_Pvt.log_request
21759       (p_entity_code            => OE_GLOBALS.G_ENTITY_LINE, --Bug 14375128
21760        p_entity_id              => p_x_line_rec.ato_line_id,
21761        p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
21762        p_requesting_entity_id   => p_x_line_rec.line_id,
21763        p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
21764        p_request_unique_key1    => 'Config Chg',
21765        p_param3                 => p_x_line_rec.ato_line_id,
21766        x_return_status          => x_return_status);
21767 
21768       IF p_x_line_rec.operation <> OE_GLOBALS.G_OPR_DELETE AND
21769          OE_Code_Control.Code_Release_Level >= '110510' THEN
21770 
21771        if l_debug_level > 0 then
21772         oe_debug_pub.add('cto_change logged for decimal change', 3);
21773        end if;
21774 
21775         OE_delayed_requests_Pvt.log_request
21776         (p_entity_code            => OE_GLOBALS.G_ENTITY_LINE, --Bug 14375128
21777          p_entity_id              => p_x_line_rec.line_id,
21778          p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
21779          p_requesting_entity_id   => p_x_line_rec.line_id,
21780          p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
21781          p_request_unique_key1    => 'Decimal Chg',
21782          p_param1                 => p_x_line_rec.operation,
21783          p_param3                 => p_x_line_rec.ato_line_id,
21784          p_param4                 => p_x_line_rec.ordered_quantity,
21785          p_param5                 => p_old_line_rec.ordered_quantity,
21786          p_param6                 => p_x_line_rec.inventory_item_id,
21787          x_return_status          => x_return_status);
21788       END IF;
21789 
21790     END IF;
21791   ELSE
21792    if l_debug_level > 0 then
21793     oe_debug_pub.add('no need to log here', 3);
21794    end if;
21795   END IF;
21796 
21797   l_num := 0;
21798 
21799   IF p_x_line_rec.split_from_line_id is NOT NULL AND
21800      p_x_line_rec.operation = 'CREATE' AND
21801      OE_Code_Control.Code_Release_Level >= '110510' THEN
21802 
21803     IF p_x_line_rec.ato_line_id = p_x_line_rec.line_id AND
21804       (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
21805        p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_STANDARD OR
21806        p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION)THEN
21807        l_num := 1;
21808     END IF;
21809 
21810     IF p_x_line_rec.ato_line_id is NOT NULL AND
21811        p_x_line_rec.item_type_code = 'CLASS' THEN
21812 
21813       BEGIN
21814         SELECT 1
21815         INTO   l_num
21816         FROM   oe_order_lines
21817         WHERE  line_id = p_x_line_rec.split_from_line_id
21818         AND    ato_line_id = line_id
21819         AND    item_type_code = 'CLASS';
21820 
21821       EXCEPTION
21822         when no_data_found then
21823          if l_debug_level > 0 then
21824           oe_debug_pub.add('was not a ato model', 3);
21825          end if;
21826       END;
21827     END IF;
21828 
21829     IF l_num = 1 THEN
21830      if l_debug_level > 0 then
21831       oe_debug_pub.add('new split ato model '|| p_x_line_rec.line_id, 3);
21832      end if;
21833 
21834       OE_delayed_requests_Pvt.log_request
21835       (p_entity_code            => OE_GLOBALS.G_ENTITY_LINE, --Bug 14375128
21836        p_entity_id              => p_x_line_rec.ato_line_id,
21837        p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
21838        p_requesting_entity_id   => p_x_line_rec.line_id,
21839        p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
21840        p_request_unique_key1    => 'Split Create',
21841        p_param3                 => p_x_line_rec.split_from_line_id,
21842        p_param4                 => p_x_line_rec.line_id,
21843        x_return_status          => x_return_status);
21844     END IF;
21845 
21846   END IF;
21847 
21848   IF l_notify_cto THEN
21849 
21850    if l_debug_level > 0 then
21851     oe_debug_pub.add('notify_cto logged', 3);
21852    end if;
21853 
21854     OE_delayed_requests_Pvt.log_request
21855     (p_entity_code            => OE_GLOBALS.G_ENTITY_LINE, --Bug 14375128
21856      p_entity_id              => p_x_line_rec.ato_line_id,
21857      p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
21858      p_requesting_entity_id   => p_x_line_rec.ato_line_id,
21859      p_request_type           => OE_GLOBALS.G_CTO_NOTIFICATION,
21860      x_return_status          => x_return_status);
21861   END IF;
21862 
21863 
21864   -- for a pto-ato create case
21865   -- as per bug 1650811, we call cto for any new create if 1 config exists.
21866   -- now ato_line_id is set indefaulting, but may be incorrect
21867   -- for a class line till validate config
21868 
21869   l_flag := FALSE;
21870   IF l_pto_ato_create AND    --6873069
21871      ((p_x_line_rec.schedule_status_code is NULL AND
21872        p_x_line_rec.operation = 'CREATE' ) OR
21873       (p_x_line_rec.schedule_ship_date is NOT NULL)) THEN
21874 
21875     IF OE_Code_Control.Code_Release_Level < '110510' THEN
21876       BEGIN
21877         SELECT line_id
21878         INTO   l_num
21879         FROM   oe_order_lines
21880         WHERE  top_model_line_id = p_x_line_rec.top_model_line_id
21881         AND    item_type_code = OE_GLOBALS.G_ITEM_CONFIG;
21882 
21883         l_flag := TRUE;
21884       EXCEPTION
21885         WHEN NO_DATA_FOUND THEN
21886          if l_debug_level > 0 then
21887           oe_debug_pub.add('config item not yet created', 2);
21888          end if;
21889         WHEN TOO_MANY_ROWS THEN
21890          if l_debug_level > 0 then
21891           oe_debug_pub.add('many config items', 2);
21892          end if;
21893           l_flag := TRUE;
21894       END;
21895     ELSE
21896       l_flag := TRUE;
21897     END IF;
21898   ELSE
21899    if l_debug_level > 0 then
21900     oe_debug_pub.add('not pto/ato config create, flag false', 2);
21901    end if;
21902   END IF;
21903 
21904 
21905   IF l_flag THEN
21906    if l_debug_level > 0 then
21907     oe_debug_pub.add('pto ato and config exist'|| p_x_line_rec.line_id, 2);
21908    end if;
21909 
21910     OE_delayed_requests_Pvt.log_request
21911     (p_entity_code            => OE_GLOBALS.G_ENTITY_LINE, --Bug 14375128
21912      p_entity_id              => p_x_line_rec.line_id,
21913      p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
21914      p_requesting_entity_id   => p_x_line_rec.line_id,
21915      p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
21916      p_request_unique_key1    => 'Config Chg pto_ato',
21917      p_param3                 => p_x_line_rec.top_model_line_id,
21918      p_param2                 => 'Y',
21919      p_param4                 => p_x_line_rec.line_id,
21920      p_param5                 => p_x_line_rec.ato_line_id,
21921      x_return_status          => x_return_status);
21922 
21923     OE_delayed_requests_Pvt.log_request
21924     (p_entity_code            => OE_GLOBALS.G_ENTITY_LINE, --Bug 14375128
21925      p_entity_id              => p_x_line_rec.top_model_line_id,
21926      p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
21927      p_requesting_entity_id   => p_x_line_rec.top_model_line_id,
21928      p_request_type           => OE_GLOBALS.G_CTO_NOTIFICATION,
21929      x_return_status          => x_return_status);
21930 
21931   END IF;
21932 
21933  if l_debug_level > 0 then
21934   oe_debug_pub.add('leaving Log_CTO_Requests', 1);
21935  end if;
21936 EXCEPTION
21937   WHEN OTHERS THEN
21938    if l_debug_level > 0 then
21939     oe_debug_pub.add('exception in Log_CTO_Requests'|| sqlerrm, 1);
21940    end if;
21941     RAISE;
21942 END Log_CTO_Requests;
21943 
21944 
21945 /*---------------------------------------------------------------------
21946 Procedure Log_Config_Requests
21947 
21948 This procedure is added only because code in pre_write is
21949 getting cluttered and there are many Configurations
21950 related requests which we will have in one place.
21951 
21952 requests logged.
21953 1) validate configuration.
21954      Log the delayed request to Validate the Configuration
21955      if an option or class is deleted.
21956      no need not consider split in case of deletes.
21957 
21958      Log the delayed request to Validate the Configuration
21959      if an option or class is updated or created or model
21960      is created.
21961 
21962 2) copy configuration.
21963      Log a copy config request if model/kit is proportionally split.
21964 
21965 Change Record:
21966 bug 2075105: the delete_option request will be looged against
21967 top model line with request_unique_key of line_id.
21968 ----------------------------------------------------------------------*/
21969 
21970 PROCEDURE Log_Config_Requests
21971 (p_x_line_rec    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
21972 ,p_old_line_rec  IN             OE_Order_PUB.Line_Rec_Type :=
21973                                    OE_Order_PUB.G_MISS_LINE_REC
21974 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
21975 IS
21976   l_flag                  BOOLEAN;
21977   l_cancellation          VARCHAR2(1);
21978   l_config_header_id      NUMBER;
21979   l_config_rev_nbr        NUMBER;
21980   l_configuration_id      NUMBER;
21981   l_model_open_flag       VARCHAR2(1) := 'Y';
21982   l_fulfilled_flag        VARCHAR2(1) := 'N';
21983   l_model_item            VARCHAR2(2000);
21984   l_config_rev_change     VARCHAR2(1) := 'N';
21985   l_ord_item              VARCHAR2(2000);
21986   l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
21987 BEGIN
21988  if l_debug_level > 0 then
21989   oe_debug_pub.add('entering Log_Config_Requests', 1);
21990  end if;
21991 
21992 
21993   ------------------------ copy for model split -------------
21994 
21995   IF p_x_line_rec.top_model_line_id = p_x_line_rec.line_id AND
21996     p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
21997     p_x_line_rec.split_from_line_id is not null  -- split
21998   THEN
21999 
22000    if l_debug_level > 0 then
22001     oe_debug_pub.add
22002     ('split_from_line_id: '|| p_x_line_rec.split_from_line_id, 1);
22003     oe_debug_pub.add('new model: '|| p_x_line_rec.line_id, 1);
22004    end if;
22005 
22006     BEGIN
22007       SELECT config_header_id, config_rev_nbr, configuration_id
22008       INTO   l_config_header_id,l_config_rev_nbr, l_configuration_id
22009       FROM   oe_order_lines
22010       WHERE  line_id = p_x_line_rec.split_from_line_id;
22011     EXCEPTION
22012       WHEN no_data_found THEN
22013        if l_debug_level > 0 then
22014         oe_debug_pub.add('Parent model is not validated', 1);
22015        end if;
22016         -- should we raise exception??
22017     END;
22018 
22019    if l_debug_level > 0 then
22020     oe_debug_pub.add('Logging a request after spllit
22021                       to copy the configuration in SPC', 1);
22022    end if;
22023     OE_Delayed_Requests_Pvt.Log_Request(
22024                p_entity_code             =>   OE_GLOBALS.G_ENTITY_LINE,
22025                p_entity_id               =>   p_x_line_rec.line_id,
22026                p_requesting_entity_code  =>   OE_GLOBALS.G_ENTITY_LINE,
22027                p_requesting_entity_id    =>   p_x_line_rec.line_id,
22028                p_request_type            =>   OE_GLOBALS.G_COPY_CONFIGURATION,
22029                p_param1                  =>   l_config_header_id,
22030                p_param2                  =>   l_config_rev_nbr,
22031                p_param3                  =>   p_x_line_rec.model_remnant_flag,
22032                p_param4                  =>   l_configuration_id,
22033                x_return_status           =>   x_return_status);
22034 
22035   END IF;
22036 
22037   if l_debug_level > 0 then
22038    oe_debug_pub.add('after copy config request ', 3);
22039   end if;
22040 
22041   -------------------------- copy config done -----------------------
22042 
22043 
22044   IF nvl(p_x_line_rec.model_remnant_flag, 'N') = 'Y'  THEN
22045    if l_debug_level > 0 then
22046     oe_debug_pub.add('returning from log_config as remnant', 1);
22047    end if;
22048     RETURN;
22049   END IF;
22050 
22051   IF p_x_line_rec.line_id <> p_x_line_rec.top_model_line_id THEN
22052     SELECT open_flag, ordered_item, fulfilled_flag
22053     INTO   l_model_open_flag, l_model_item, l_fulfilled_flag
22054     FROM   oe_order_lines
22055     WHERE  line_id = p_x_line_rec.top_model_line_id;
22056   END IF;
22057 
22058   ---------------------- deletes ----------------------------------
22059 
22060   IF(p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION OR
22061      p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
22062     (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT AND
22063      p_x_line_rec.line_id <> p_x_line_rec.top_model_line_id)) AND
22064      p_x_line_rec.operation = OE_GLOBALS.G_OPR_DELETE AND
22065      OE_CONFIG_PVT.OECFG_VALIDATE_CONFIG = 'Y' THEN
22066 
22067      IF l_model_open_flag = 'N' THEN
22068        FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_MODEL_CLOSED');
22069        FND_MESSAGE.Set_Token('MODEL', l_model_item);
22070        OE_MSG_PUB.Add;
22071       if l_debug_level > 0 then
22072        oe_debug_pub.add('model line is closed', 1);
22073       end if;
22074        RAISE FND_API.G_EXC_ERROR;
22075      END IF;
22076 
22077      IF l_fulfilled_flag  = 'Y' THEN
22078        FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_MODEL_FULFILLED');
22079        FND_MESSAGE.Set_Token('MODEL', l_model_item);
22080        OE_MSG_PUB.Add;
22081       if l_debug_level > 0 then
22082        oe_debug_pub.add('model line is fulfilled', 1);
22083       end if;
22084        RAISE FND_API.G_EXC_ERROR;
22085      END IF;
22086 
22087     if l_debug_level > 0 then
22088      oe_debug_pub.add('Logging a request to validate configuration  ', 1);
22089     end if;
22090 
22091      OE_delayed_requests_Pvt.log_request(
22092             p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
22093             p_entity_id              => p_x_line_rec.top_model_line_id,
22094             p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
22095             p_requesting_entity_id   => p_x_line_rec.line_id,
22096             p_request_type           => OE_GLOBALS.G_VALIDATE_CONFIGURATION,
22097             x_return_status          => x_return_status);
22098 
22099     if l_debug_level > 0 then
22100      oe_debug_pub.add('Logging a request to delete option from oe/spc', 1);
22101     end if;
22102 
22103      OE_Delayed_Requests_Pvt.Log_Request(
22104             p_entity_code             =>   OE_GLOBALS.G_ENTITY_LINE,
22105             p_entity_id               =>   p_x_line_rec.top_model_line_id,
22106             p_requesting_entity_code  =>   OE_GLOBALS.G_ENTITY_LINE,
22107             p_requesting_entity_id    =>   p_x_line_rec.line_id,
22108             p_request_unique_key1     =>   p_x_line_rec.line_id,
22109             p_request_type            =>   OE_GLOBALS.G_DELETE_OPTION,
22110             p_param1                  =>   p_x_line_rec.top_model_line_id,
22111             p_param2                  =>   p_x_line_rec.component_code,
22112             p_param3                  =>   p_x_line_rec.item_type_code,
22113             p_param9                  =>   p_x_line_rec.configuration_id,
22114             p_param10                 =>   p_x_line_rec.ordered_item, -- 3563690
22115             x_return_status           =>   x_return_status);
22116 
22117   END IF;
22118 
22119 
22120 
22121   ---------------- update/create-------------------------------------
22122 
22123  if l_debug_level > 0 then
22124   oe_debug_pub.add('item_type_code: '||p_x_line_rec.item_type_code, 1);
22125   oe_debug_pub.add('validate flag: '||OE_CONFIG_PVT.OECFG_VALIDATE_CONFIG, 1);
22126  end if;
22127 
22128   l_flag := FALSE;
22129 
22130   IF p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL AND
22131      p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE      AND
22132      p_x_line_rec.booked_flag = 'Y' THEN
22133     if l_debug_level > 0 then
22134      oe_debug_pub.add('setting flag to true for model', 1);
22135     end if;
22136      l_flag := TRUE;
22137   END IF;
22138 
22139   IF (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION OR
22140       p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
22141      (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT AND
22142       p_x_line_rec.line_id <> p_x_line_rec.top_model_line_id)) AND
22143       NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,
22144                            p_old_line_rec.ordered_quantity )
22145   THEN
22146    if l_debug_level > 0 then
22147     oe_debug_pub.add('set flag to true'|| p_old_line_rec.ordered_quantity, 1);
22148     oe_debug_pub.add('new qty ' || p_x_line_rec.ordered_quantity, 1);
22149    end if;
22150     l_flag := TRUE;
22151   END IF;
22152 
22153    IF  p_x_line_rec.line_id = p_x_line_rec.top_model_line_id AND
22154        NOT OE_GLOBALS.Equal(p_x_line_rec.config_rev_nbr,
22155                             p_old_line_rec.config_rev_nbr)
22156   THEN
22157    if l_debug_level > 0 then
22158     oe_debug_pub.add('set flag to true, old rev '|| p_old_line_rec.config_rev_nbr, 1);
22159     oe_debug_pub.add('new rev ' || p_x_line_rec.config_rev_nbr, 1);
22160    end if;
22161     l_config_rev_change := 'Y';
22162     l_flag := TRUE;
22163   END IF;
22164 
22165   IF l_flag AND OE_CONFIG_PVT.OECFG_VALIDATE_CONFIG = 'Y' THEN
22166 
22167     if l_debug_level > 0 then
22168      oe_debug_pub.add('p_x_line_rec.operation' || p_x_line_rec.operation, 1);
22169      oe_debug_pub.add
22170      ('Split_from_line_id: '||p_x_line_rec.split_from_line_id ,3);
22171      oe_debug_pub.add
22172      ('Split_action_code: '|| p_x_line_rec.split_action_code ,3);
22173     end if;
22174 
22175 
22176      -- in case of splits, we dont want to batch validate
22177 
22178      IF  p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
22179          p_x_line_rec.split_from_line_id is not null
22180      THEN
22181         if l_debug_level > 0 then
22182          oe_debug_pub.add('This is a new model after split', 1);
22183         end if;
22184 
22185      ELSIF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
22186          nvl(p_x_line_rec.split_action_code, 'X') = 'SPLIT'
22187      THEN
22188         if l_debug_level > 0 then
22189          oe_debug_pub.add('This is a parent split model', 1);
22190         end if;
22191 
22192      ELSE
22193          -- If we got here, it means this isn't a split.
22194         if l_debug_level > 0 then
22195          oe_debug_pub.add('Logging a request to validate configuration',1);
22196         end if;
22197 
22198          IF l_model_open_flag = 'N' THEN
22199            FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_MODEL_CLOSED');
22200            FND_MESSAGE.Set_Token('MODEL', l_model_item);
22201            OE_MSG_PUB.Add;
22202           if l_debug_level > 0 then
22203            oe_debug_pub.add('model line is closed', 1);
22204           end if;
22205            RAISE FND_API.G_EXC_ERROR;
22206          END IF;
22207 
22208          IF l_fulfilled_flag  = 'Y' THEN
22209            FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_MODEL_FULFILLED');
22210            FND_MESSAGE.Set_Token('MODEL', l_model_item);
22211            OE_MSG_PUB.Add;
22212           if l_debug_level > 0 then
22213            oe_debug_pub.add('model line is fulfilled', 1);
22214           end if;
22215            RAISE FND_API.G_EXC_ERROR;
22216          END IF;
22217 
22218          -- 2917547 starts
22219          IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
22220             p_x_line_rec.ordered_quantity = 0 THEN
22221 
22222            IF p_x_line_rec.ordered_item IS NULL OR
22223               p_x_line_rec.ordered_item = fnd_api.g_miss_char THEN
22224              l_ord_item := p_x_line_rec.inventory_item_id;
22225            ELSE
22226              l_ord_item := p_x_line_rec.ordered_item;
22227            END IF;
22228 
22229            FND_MESSAGE.Set_Name('ONT', 'OE_ZERO_CHILD_QTY');
22230            FND_MESSAGE.Set_Token('ITEM', l_ord_item);
22231            OE_MSG_PUB.Add;
22232 
22233            IF l_debug_level > 0 THEN
22234              oe_debug_pub.add
22235              ('Child lines with zero qty can not be created', 1);
22236            END IF;
22237            RAISE FND_API.G_EXC_ERROR;
22238          END IF;
22239 
22240          OE_delayed_requests_Pvt.log_request(
22241             p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
22242             p_entity_id              => p_x_line_rec.top_model_line_id,
22243             p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
22244             p_requesting_entity_id   => p_x_line_rec.line_id,
22245             p_request_type           => OE_GLOBALS.G_VALIDATE_CONFIGURATION,
22246             x_return_status          => x_return_status);
22247 
22248          -- log only if operation is update and not for create
22249          IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
22250             l_config_rev_change = 'N'
22251 	    AND NOT(OE_GENESIS_UTIL.G_INCOMING_FROM_DOO) -- Bug 16491708
22252 	    THEN
22253 
22254            if l_debug_level > 0 then
22255             oe_debug_pub.add('Logging a request to update configuration', 1);
22256            end if;
22257 
22258             l_cancellation := 'N';
22259 
22260             IF OE_Sales_Can_Util.G_Require_Reason THEN
22261              if l_debug_level > 0 then
22262               oe_debug_pub.add('this is a cancellation', 1);
22263              end if;
22264               l_cancellation := 'Y';
22265             ELSE
22266              if l_debug_level > 0 then
22267               oe_debug_pub.add('this is not a cancellation', 1);
22268              end if;
22269             END IF;
22270 
22271            if l_debug_level > 0 then
22272             oe_debug_pub.add
22273             (p_x_line_rec.item_type_code || p_x_line_rec.ordered_quantity, 1);
22274            end if;
22275 
22276             OE_Delayed_Requests_Pvt.Log_Request(
22277                p_entity_code             =>   OE_GLOBALS.G_ENTITY_LINE,
22278                p_entity_id               =>   p_x_line_rec.line_id,
22279                p_requesting_entity_code  =>   OE_GLOBALS.G_ENTITY_LINE,
22280                p_requesting_entity_id    =>   p_x_line_rec.line_id,
22281                p_request_type            =>   OE_GLOBALS.G_UPDATE_OPTION,
22282                p_param1                  =>   p_x_line_rec.top_model_line_id,
22283                p_param2                  =>   p_x_line_rec.component_code,
22284                p_param3                  =>   p_x_line_rec.item_type_code,
22285                p_param4                  =>   p_old_line_rec.ordered_quantity,
22286                p_param5                  =>   p_x_line_rec.ordered_quantity,
22287                p_param6                  =>   p_x_line_rec.change_reason,
22288                p_param7                  =>   p_x_line_rec.change_comments,
22289                p_param8                  =>   l_cancellation,
22290                p_param9                  =>   p_x_line_rec.configuration_id,
22291                x_return_status           =>   x_return_status);
22292 
22293          END IF; -- end of update.
22294 
22295       END IF;  -- end of split check.
22296 
22297   END IF;
22298 
22299  if l_debug_level > 0 then
22300   oe_debug_pub.add('leaving Log_Config_Requests', 1);
22301  end if;
22302 EXCEPTION
22303   WHEN OTHERS THEN
22304    if l_debug_level > 0 then
22305     oe_debug_pub.add('exception in Log_Config_Requests'|| sqlerrm, 1);
22306    end if;
22307     RAISE;
22308 END Log_Config_Requests;
22309 
22310 
22311 /*----------------------------------------------------------------------
22312 Procedure Log_Cascade_Requests
22313 
22314 
22315 1) cascading.
22316      Log the delayed request to Cascade Changes if any of the cascading
22317      relevant attribute has changes on the model.
22318 
22319      only from the top model/ top kit
22320        ordered_quantity
22321 
22322      for top model / top kit / ato sub config
22323        project_id
22324        task_id
22325        ship_tolerance_above
22326        ship_tolerance_below
22327 
22328      for non smc pto top model / top kit
22329        ship_to_org_id
22330        request_date
22331 
22332      for top ato model only
22333        shipped_quantity
22334        actual_shipment_date (in ucfgb)
22335 
22336 2) change configuration.
22337      change in warehouse of an ato model, smc pto, or ato subconfig
22338      cascade only if configuration was not scheduled.
22339      If it was scheduled, scheduling will take care of cascading.
22340 
22341      only for non scheduled lines which are part of
22342      top ato and ato subconfig / smc
22343        ship_to_org_id
22344        ship_from_org_id
22345 
22346      lines which are part of top ato and ato subconfig / smc
22347        request_date
22348 
22349 3) modify included items.
22350      when a class/kit under a pto model, is odified, we need to modify
22351      the included items under it. We use a global table here to capture the
22352      old and new qty, operation, reason and commet. This table is used in the
22353      post_lines process to modify the included items. We did not use a delayed
22354      reuest because we need to capture the old and new qty per class and
22355      it needs 3 types of requests, ex: validate configuration req to do that.
22356 
22357 ----------------------------------------------------------------------*/
22358 
22359 PROCEDURE Log_Cascade_Requests
22360 (p_x_line_rec    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
22361 ,p_old_line_rec  IN             OE_Order_PUB.Line_Rec_Type :=
22362                                    OE_Order_PUB.G_MISS_LINE_REC
22363 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
22364 IS
22365   l_param1                VARCHAR2(2000):= FND_API.G_MISS_NUM;
22366   l_param2                VARCHAR2(240) := FND_API.G_MISS_NUM;
22367   l_param3                VARCHAR2(240) := null;
22368   l_param4                VARCHAR2(2000):= null;    --4495205
22369   l_param5                VARCHAR2(240) := FND_API.G_MISS_NUM;
22370   l_param6                VARCHAR2(240) := FND_API.G_MISS_NUM;
22371   l_param7                VARCHAR2(240) := FND_API.G_MISS_CHAR;
22372   l_param8                VARCHAR2(240) := FND_API.G_MISS_NUM;
22373   l_param9                VARCHAR2(240) := FND_API.G_MISS_NUM;
22374   l_param10               VARCHAR2(240) := null;
22375   l_param11               VARCHAR2(240) := FND_API.G_MISS_NUM;
22376   l_param12               VARCHAR2(240) := FND_API.G_MISS_NUM;
22377   l_param14               VARCHAR2(240) := FND_API.G_MISS_NUM;
22378 /* Added the following variable to fix the bug 2217336 */
22379   l_param16               VARCHAR2(240) := FND_API.G_MISS_CHAR;
22380   l_date_param1           DATE          := FND_API.G_MISS_DATE;
22381   l_date_param2           DATE          := FND_API.G_MISS_DATE;
22382   l_num                   NUMBER;
22383   l_cancellation          VARCHAR2(1);
22384   l_cascade_changes       BOOLEAN := FALSE;
22385   l_change_configuration  BOOLEAN := FALSE;
22386   l_modify_included_items BOOLEAN := FALSE;
22387   l_return_status         VARCHAR2(1);
22388   l_entity_id             NUMBER;
22389   l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
22390 BEGIN
22391  if l_debug_level > 0 then
22392   oe_debug_pub.add('entering Log_Cascade_Requests', 1);
22393  end if;
22394 
22395   -------- cascading from parent to child only -------------
22396 
22397 
22398   IF OE_CONFIG_UTIL.G_CONFIG_UI_USED = 'N' AND
22399      OE_CONFIG_UTIL.CASCADE_CHANGES_FLAG = 'N'  AND
22400      p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
22401      nvl(p_x_line_rec.split_action_code, 'X') <> 'SPLIT'
22402   THEN
22403     -- 1. change in ordered qty of model/kit
22404     --    at subconfig cascade qty is actually in validate_config
22405 
22406     IF p_x_line_rec.top_model_line_id = p_x_line_rec.line_id
22407     THEN
22408 
22409       IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,
22410                               p_old_line_rec.ordered_quantity) AND
22411          OE_Config_Util.G_Config_UI_Used = 'N'
22412       THEN
22413         l_param1 := p_old_line_rec.ordered_quantity;
22414         l_param2 := p_x_line_rec.ordered_quantity;
22415         l_param3 := p_x_line_rec.change_reason;
22416         l_param4 := p_x_line_rec.change_comments;
22417 
22418        if l_debug_level > 0 then
22419         oe_debug_pub.add('ordered qty of model/kit changed:' ||l_param2,1);
22420        end if;
22421 
22422         l_cascade_changes := TRUE;
22423 
22424       END IF;
22425 
22426     END IF;
22427 
22428 
22429     -- 2. change in project and task of model/ ato subconfig
22430 
22431     IF  p_x_line_rec.top_model_line_id = p_x_line_rec.line_id OR -- model/kit
22432        (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS AND
22433         p_x_line_rec.line_id = p_x_line_rec.ato_line_id) -- ato subconfig
22434     THEN
22435 
22436       IF NOT OE_GLOBALS.Equal(p_x_line_rec.project_id,
22437                               p_old_line_rec.project_id)
22438       THEN
22439         l_param5 := p_x_line_rec.project_id;
22440        if l_debug_level > 0 then
22441         oe_debug_pub.add('model/ATO sub,project_id changed: '||l_param5,1);
22442        end if;
22443         l_cascade_changes := TRUE;
22444       END IF;
22445 
22446       IF NOT OE_GLOBALS.Equal(p_x_line_rec.task_id,p_old_line_rec.task_id)
22447       THEN
22448         l_param6 := p_x_line_rec.task_id;
22449        if l_debug_level > 0 then
22450         oe_debug_pub.add('model /ATO sub,task_id changed: '||l_param6,1);
22451        end if;
22452         l_cascade_changes := TRUE;
22453       END IF;
22454 
22455 
22456       -- 3. cascade change in ship_tolerance_above and ship_tolerance_above
22457       -- at the model level to all the options.
22458 
22459       IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_tolerance_above,
22460                               p_old_line_rec.ship_tolerance_above)
22461       THEN
22462         l_param11 := p_x_line_rec.ship_tolerance_above;
22463         l_cascade_changes := TRUE;
22464       END IF;
22465 
22466       IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_tolerance_below,
22467                               p_old_line_rec.ship_tolerance_below)
22468       THEN
22469         l_param12 := p_x_line_rec.ship_tolerance_below;
22470         l_cascade_changes := TRUE;
22471       END IF;
22472     END IF;
22473 
22474 
22475     -- 4. cascade request_date and ship_to_org_id, this should be done
22476     --    only in case of nonsmc pto model/kit, rest is handled in
22477     --    change_configuration request.
22478 
22479     IF  p_x_line_rec.top_model_line_id = p_x_line_rec.line_id AND
22480         nvl(p_x_line_rec.ship_model_complete_flag, 'N') = 'N' AND
22481         p_x_line_rec.ato_line_id IS NULL
22482     THEN
22483       IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_to_org_id,
22484                               p_old_line_rec.ship_to_org_id)
22485       THEN
22486         l_param14 := p_x_line_rec.ship_to_org_id;
22487         l_cascade_changes := TRUE;
22488       END IF;
22489 
22490       IF NOT OE_GLOBALS.Equal(p_x_line_rec.request_date,
22491                               p_old_line_rec.request_date)
22492       THEN
22493         l_date_param1 := p_x_line_rec.request_date;
22494         l_cascade_changes := TRUE;
22495       END IF;
22496 
22497     END IF;
22498 
22499 
22500     -- 5. change in shipped qty of ato model, specifically for top most ato.
22501 
22502     IF  p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL AND
22503         p_x_line_rec.ato_line_id IS NOT NULL
22504     THEN
22505 
22506       IF NOT OE_GLOBALS.Equal(p_x_line_rec.shipped_quantity,
22507                              p_old_line_rec.shipped_quantity)
22508       THEN
22509         l_param9  := to_char(p_x_line_rec.shipped_quantity);
22510        if l_debug_level > 0 then
22511         oe_debug_pub.add
22512         ('model / ATO subconfig, shipped quantity changed: '||l_param9,1);
22513        end if;
22514 
22515         l_cascade_changes := TRUE;
22516       END IF;
22517 
22518     END IF;
22519 
22520 
22521     -- 6. cascade source_type for ATO configurations.
22522 
22523     IF  p_x_line_rec.line_id = p_x_line_rec.ato_line_id AND
22524        (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
22525         p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS )
22526     THEN
22527 
22528       IF NOT OE_GLOBALS.Equal(p_x_line_rec.source_type_code,
22529                               p_old_line_rec.source_type_code)
22530       THEN
22531         l_param7 := p_x_line_rec.source_type_code;
22532        if l_debug_level > 0 then
22533         oe_debug_pub.add('ATO cascade source type '|| l_param7,1);
22534        end if;
22535         l_cascade_changes := TRUE;
22536       END IF;
22537 
22538     END IF;
22539 
22540 
22541     -- 7. Cascade change in freight_term_code
22542     --    added this code to fix the bug 2217336
22543 
22544     IF (  p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL  OR
22545           p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT )
22546     THEN
22547 
22548       IF NOT OE_GLOBALS.Equal(p_x_line_rec.freight_terms_code,
22549                               p_old_line_rec.freight_terms_code)
22550       THEN
22551         l_param16  := p_x_line_rec.freight_terms_code;
22552 
22553        if l_debug_level > 0 then
22554         oe_debug_pub.add
22555         ('Freight term code changed: '||l_param16,1);
22556        end if;
22557 
22558         l_cascade_changes := TRUE;
22559       END IF;
22560 
22561     END IF;
22562 
22563      -- 8. Cascade change in promise date
22564 
22565     IF (  p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL  OR
22566           p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT )
22567     THEN
22568 
22569       IF NOT OE_GLOBALS.Equal(p_x_line_rec.promise_date,
22570                               p_old_line_rec.promise_date)
22571       THEN
22572         l_date_param2  := p_x_line_rec.promise_date;
22573 
22574        if l_debug_level > 0 then
22575         oe_debug_pub.add('Promise date changed: '||l_date_param2,1);
22576        end if;
22577 
22578         l_cascade_changes := TRUE;
22579       END IF;
22580 
22581     END IF;
22582 
22583 
22584     -- log a request only if not a split
22585 
22586    if l_debug_level > 0 then
22587     oe_debug_pub.add
22588     ('CASCADE_CHANGES_FLAG, N means cascade : '
22589      ||OE_CONFIG_UTIL.CASCADE_CHANGES_FLAG, 1);
22590    end if;
22591 
22592 
22593     IF l_cascade_changes THEN
22594      if l_debug_level > 0 then
22595       oe_debug_pub.add('Logging Request to Cascade changes',1);
22596       oe_debug_pub.add('Item Type is: ' || p_x_line_rec.item_type_code,3);
22597       oe_debug_pub.add('Comp Code is: ' || p_x_line_rec.component_code,3);
22598      end if;
22599 
22600       l_cancellation := 'N';
22601       IF OE_Sales_Can_Util.G_Require_Reason THEN
22602        if l_debug_level > 0 then
22603         oe_debug_pub.add('this is a cancellation', 1);
22604        end if;
22605         l_cancellation := 'Y';
22606       END IF;
22607 
22608       OE_delayed_requests_Pvt.log_request(
22609         p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
22610         p_entity_id              => p_x_line_rec.line_id,
22611         p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
22612         p_requesting_entity_id   => p_x_line_rec.line_id,
22613         p_request_type           => OE_GLOBALS.G_CASCADE_CHANGES,
22614         p_param1                 => l_param1,   -- old old qty
22615         p_param2                 => l_param2,   -- new ord qty
22616         p_param3                 => l_param3,   -- chg reason
22617         p_param4                 => l_param4,   -- chg comment
22618         p_param5                 => l_param5,   -- proj id
22619         p_param6                 => l_param6,   -- task id
22620         p_param7                 => p_x_line_rec.item_type_code,
22621         p_param9                 => l_param9,   -- ship qty
22622         p_param10                => l_param10,  -- warehouse
22623         p_param11                => l_param11,  -- Ship tol above
22624         p_param12                => l_param12,  -- Ship tol below
22625         p_param13                => l_cancellation,
22626         p_param14                => l_param14,  -- ship to org id
22627         p_param15                => l_param7,   -- source_type_code
22628         p_param16                => l_param16,   -- Freight_terms_code
22629         p_date_param1            => l_date_param1, -- request date
22630         p_date_param2            => l_date_param2, -- promise date
22631         x_return_status          => l_return_status);
22632 
22633     END IF;
22634 
22635   END IF; -- if the globals are set.
22636 
22637 
22638 
22639    ------------ changing from any line to all lines -------------
22640 
22641  if l_debug_level > 0 then
22642   oe_debug_pub.add('change configuration requests', 3);
22643  end if;
22644 
22645    --6717302:
22646    -- 5932543 - do not call process order if the split is happening through
22647    -- ITS partial shipment. split_by=system
22648    -- 6678897 - comparision of split_action_code and split_by WITH NVL
22649    -- if not done so, following if condition will always fail and cascading
22650    -- changed field values to child item lines will fail.
22651    -- (warehous field for 6678897)
22652 
22653    IF  OE_GLOBALS.G_CHANGE_CFG_FLAG = 'Y' AND
22654       ((p_x_line_rec.ato_line_id is not null AND
22655         p_x_line_rec.item_type_code <> OE_GLOBALS.G_ITEM_STANDARD) OR
22656        (nvl(p_x_line_rec.ship_model_complete_flag,'N')='Y')) AND
22657         p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
22658         AND nvl(p_x_line_rec.split_action_code,'N') <> 'SPLIT' --6717302
22659         AND nvl(p_x_line_rec.split_by,'N') <> 'SYSTEM' --6717302
22660    THEN
22661 
22662      IF  p_x_line_rec.schedule_status_code is null THEN
22663 
22664        -- 1.
22665        IF NOT OE_GLOBALS.Equal(p_x_line_rec.SHIP_FROM_ORG_ID,
22666                              p_old_line_rec.SHIP_FROM_ORG_ID)
22667        THEN
22668          l_change_configuration := TRUE;
22669        END IF;
22670 
22671        -- 2.
22672        IF NOT OE_GLOBALS.Equal(p_x_line_rec.SHIP_TO_ORG_ID,
22673                              p_old_line_rec.SHIP_TO_ORG_ID)
22674        THEN
22675          l_change_configuration := TRUE;
22676        END IF;
22677 
22678      END IF;
22679 
22680      -- 3. note that this is logged even if scheduled.
22681 
22682      IF NOT OE_GLOBALS.Equal(p_x_line_rec.REQUEST_DATE,
22683                            p_old_line_rec.REQUEST_DATE) AND
22684         OE_CONFIG_UTIL.CASCADE_CHANGES_FLAG = 'N'
22685      THEN
22686         l_change_configuration := TRUE;
22687      END IF;
22688 
22689      IF NOT OE_GLOBALS.Equal(p_x_line_rec.SHIPPING_METHOD_CODE,
22690                            p_old_line_rec.SHIPPING_METHOD_CODE)
22691      THEN
22692         l_change_configuration := TRUE;
22693      END IF;
22694 
22695      IF NOT OE_GLOBALS.Equal(p_x_line_rec.SHIPMENT_PRIORITY_CODE,
22696                            p_old_line_rec.SHIPMENT_PRIORITY_CODE)
22697      THEN
22698         l_change_configuration := TRUE;
22699      END IF;
22700 
22701      IF NOT OE_GLOBALS.Equal(p_x_line_rec.DEMAND_CLASS_CODE,
22702                            p_old_line_rec.DEMAND_CLASS_CODE)
22703      THEN
22704         l_change_configuration := TRUE;
22705      END IF;
22706 
22707 
22708      IF l_change_configuration THEN
22709 
22710        IF (nvl(p_x_line_rec.ship_model_complete_flag,'N')='Y') THEN
22711           l_entity_id := p_x_line_rec.top_model_line_id;
22712 
22713        ELSIF  (p_x_line_rec.ato_line_id is not null ) THEN
22714           l_entity_id := p_x_line_rec.ato_line_id;
22715 
22716        END IF;
22717 
22718       if l_debug_level > 0 then
22719        oe_debug_pub.add('logging a req. to chg config', 1);
22720       end if;
22721 
22722        OE_Delayed_Requests_Pvt.Log_Request(
22723         p_entity_code             =>   OE_GLOBALS.G_ENTITY_LINE,
22724         p_entity_id               =>   l_entity_id,
22725         p_requesting_entity_code  =>   OE_GLOBALS.G_ENTITY_LINE,
22726         p_requesting_entity_id    =>   p_x_line_rec.line_id,
22727         p_request_type            =>   OE_GLOBALS.G_CHANGE_CONFIGURATION,
22728         p_param1                  =>   p_x_line_rec.line_id,
22729         x_return_status           =>   l_return_status);
22730 
22731      END IF;
22732 
22733    END IF;
22734 
22735    ------ cascading from class/kitclass to included items only ---------
22736 
22737    l_num := 0;
22738 
22739 BEGIN
22740    SELECT 1
22741    INTO   l_num
22742    FROM   oe_order_lines
22743    WHERE  top_model_line_id = p_x_line_rec.top_model_line_id
22744    AND    link_to_line_id   = p_x_line_rec.line_id
22745    AND    item_type_code = OE_GLOBALS.G_ITEM_INCLUDED
22746    AND    rownum = 1;
22747 
22748 EXCEPTION
22749   WHEN NO_DATA_FOUND THEN
22750    if l_debug_level > 0 then
22751     oe_debug_pub.add('modify inc items requests NOT reqd', 3);
22752    end if;
22753     RETURN;
22754 END;
22755 
22756  if l_debug_level > 0 then
22757   oe_debug_pub.add('modify inc items request reqd', 3);
22758  end if;
22759 
22760   -- Modified for bug 8636027
22761   -- l_num := p_x_line_rec.line_id;
22762   l_num := mod(p_x_line_rec.line_id, G_BINARY_LIMIT);
22763 
22764   IF NOT OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.EXISTS(l_num) THEN
22765     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param1
22766                   := FND_API.G_MISS_NUM;
22767     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param2
22768                   := FND_API.G_MISS_NUM;
22769     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param3 := null;
22770     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param4 := null;
22771     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param5
22772                   := FND_API.G_MISS_NUM;
22773     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param6
22774                   := FND_API.G_MISS_NUM;
22775     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param7
22776                   := FND_API.G_MISS_NUM;
22777     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param8
22778                   := FND_API.G_MISS_NUM;
22779     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param9
22780                   := FND_API.G_MISS_NUM;
22781     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).date_param1
22782                   := FND_API.G_MISS_DATE;
22783   END IF;
22784 
22785   IF   p_x_line_rec.operation <> OE_GLOBALS.G_OPR_CREATE AND
22786        p_x_line_rec.ato_line_id is null AND
22787        p_x_line_rec.top_model_line_id <> p_x_line_rec.line_id AND
22788        (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
22789         p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT) AND
22790 	nvl(p_x_line_rec.split_action_code, 'X') <> 'SPLIT'  AND
22791         OE_CONFIG_UTIL.CASCADE_CHANGES_FLAG = 'N' -- not for  model change
22792   THEN
22793     if l_debug_level > 0 then
22794      oe_debug_pub.add('cascade class changes to included items', 1);
22795     end if;
22796 
22797      IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,
22798                              p_old_line_rec.ordered_quantity) THEN
22799 
22800        IF OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param1 =
22801           FND_API.G_MISS_NUM THEN
22802          OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param1
22803                        := p_old_line_rec.ordered_quantity;
22804         if l_debug_level > 0 then
22805          oe_debug_pub.add('qty changed 1st time ' || l_param1, 4);
22806         end if;
22807        END IF;
22808 
22809        OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param2
22810                        := p_x_line_rec.ordered_quantity;
22811        -- new qty
22812 
22813        OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param3
22814                        := p_x_line_rec.change_reason;
22815        -- change_reason
22816 
22817        OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param4
22818                        := p_x_line_rec.change_comments;
22819        --  change_comments
22820 
22821       if l_debug_level > 0 then
22822        oe_debug_pub.add
22823        ('ord qty of class changed:' || p_x_line_rec.ordered_quantity,1);
22824       end if;
22825 
22826        l_modify_included_items := TRUE;
22827 
22828      END IF;
22829 
22830      IF NOT OE_GLOBALS.Equal(p_x_line_rec.project_id,p_old_line_rec.project_id) THEN
22831       OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param5
22832                        := p_x_line_rec.project_id;
22833      if l_debug_level > 0 then
22834       oe_debug_pub.add('model/ATO subconfig,project changed: '||l_param5,1);
22835      end if;
22836       l_modify_included_items := TRUE;
22837      END IF;
22838 
22839 
22840      IF NOT OE_GLOBALS.Equal(p_x_line_rec.task_id,p_old_line_rec.task_id)
22841      THEN
22842        OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param6
22843                        := p_x_line_rec.task_id;
22844      if l_debug_level > 0 then
22845        oe_debug_pub.add('model /ATO subconfig,task changed: '||l_param6,1);
22846      end if;
22847        l_modify_included_items := TRUE;
22848      END IF;
22849 
22850 
22851      IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_tolerance_above,
22852                              p_old_line_rec.ship_tolerance_above)
22853       THEN
22854         OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param7
22855                        := p_x_line_rec.ship_tolerance_above;
22856         l_modify_included_items := TRUE;
22857       END IF;
22858 
22859       IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_tolerance_below,
22860                               p_old_line_rec.ship_tolerance_below)
22861       THEN
22862          OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param8
22863                        := p_x_line_rec.ship_tolerance_below;
22864          l_modify_included_items := TRUE;
22865       END IF;
22866 
22867       IF OE_GLOBALS.G_CHANGE_CFG_FLAG = 'Y' THEN
22868         IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_to_org_id,
22869                                 p_old_line_rec.ship_to_org_id)
22870         THEN
22871            OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param9
22872                        := p_x_line_rec.ship_to_org_id;
22873            l_modify_included_items := TRUE;
22874         END IF;
22875 
22876         IF NOT OE_GLOBALS.Equal(p_x_line_rec.request_date,
22877                               p_old_line_rec.request_date)
22878         THEN
22879            OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).date_param1
22880                        := p_x_line_rec.request_date;
22881            l_modify_included_items := TRUE;
22882         END IF;
22883       END IF;
22884 
22885       IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
22886         l_modify_included_items := TRUE;
22887       END IF;
22888 
22889    END IF;
22890 
22891 
22892    IF l_modify_included_items THEN
22893     if l_debug_level > 0 then
22894      oe_debug_pub.add('something changed'|| p_x_line_rec.operation, 2);
22895     end if;
22896 
22897      OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param10 :=
22898                       p_x_line_rec.operation;
22899 
22900      IF OE_Sales_Can_Util.G_Require_Reason THEN
22901        OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param11 := 'Y';
22902      ELSE
22903        OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param11 := 'N';
22904      END IF;
22905 
22906      OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param12 :=
22907                     p_x_line_rec.line_id;
22908 
22909      OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param13 :=
22910                     p_x_line_rec.top_model_line_id;
22911    END IF;
22912 
22913   x_return_status := l_return_status;
22914 
22915  if l_debug_level > 0 then
22916   oe_debug_pub.add('leaving Log_Config_Requests', 1);
22917  end if;
22918 EXCEPTION
22919   WHEN OTHERS THEN
22920    if l_debug_level > 0 then
22921     oe_debug_pub.add('exception in Log_Cascade_Requests'|| sqlerrm, 1);
22922    end if;
22923     RAISE;
22924 END Log_Cascade_Requests;
22925 
22926 
22927 
22928 /*-----------------------------------------------------------
22929 PROCEDURE get_customer_details
22930 ------------------------------------------------------------*/
22931 
22932 PROCEDURE get_customer_details
22933 (   p_org_id                IN  NUMBER
22934 ,   p_site_use_code         IN  VARCHAR2
22935 ,   x_customer_name         OUT NOCOPY /* file.sql.39 change */ VARCHAR2
22936 ,   x_customer_number       OUT NOCOPY /* file.sql.39 change */ VARCHAR2
22937 ,   x_customer_id           OUT NOCOPY /* file.sql.39 change */ number
22938 ,   x_location              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
22939 ,   x_address1              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
22940 ,   x_address2              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
22941 ,   x_address3              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
22942 ,   x_address4              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
22943 ,   x_city                  OUT NOCOPY /* file.sql.39 change */ VARCHAR2
22944 ,   x_state                 OUT NOCOPY /* file.sql.39 change */ VARCHAR2
22945 ,   x_zip                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
22946 ,   x_country               OUT NOCOPY /* file.sql.39 change */ VARCHAR2
22947 )
22948 
22949 IS
22950 BEGIN
22951 
22952     IF p_org_id is NOT NULL THEN
22953 
22954         SELECT  /*MOAC_SQL_CHANGES*/ cust.cust_account_id,
22955                 party.party_name,
22956                 cust.account_number,
22957                 site.location,
22958                 addr.address1,
22959                 addr.address2,
22960                 addr.address3,
22961                 addr.address4,
22962                 addr.city,
22963                 nvl(addr.state,addr.province), -- 3603600
22964 	        addr.postal_code,
22965 	        addr.country
22966         INTO    x_customer_id,
22967                 x_customer_name,
22968                 x_customer_number,
22969                 x_location,
22970 	        x_address1,
22971 	        x_address2,
22972 	        x_address3,
22973 	        x_address4,
22974 	        x_city,
22975                 x_state,
22976                 x_zip,
22977                 x_country
22978         FROM    HZ_CUST_SITE_USES_ALL site,
22979                 HZ_CUST_ACCT_SITES cas,
22980                 hz_cust_accounts cust,
22981                 hz_parties party,
22982                 hz_party_sites ps,
22983                 hz_locations addr
22984         WHERE   site.cust_acct_site_id=cas.cust_acct_site_id
22985         AND     site.site_use_code=p_site_use_code
22986         AND     site.site_use_id=p_org_id
22987         AND     cust.cust_account_id = cas.cust_account_id
22988         AND     cas.party_site_id = ps.party_site_id
22989         AND     ps.location_id = addr.location_id
22990         AND     party.party_id = cust.party_id;
22991 
22992     ELSE
22993 
22994         x_customer_name    :=  NULL    ;
22995         x_customer_number  :=  NULL    ;
22996         x_customer_id      :=  NULL    ;
22997         x_location         :=  NULL;
22998         x_address1         := nULL;
22999         x_address2         := nULL;
23000         x_address3         := nULL;
23001         x_address4         := nULL;
23002         x_city             := nULL;
23003         x_state            := nULL;
23004         x_zip              := nULL;
23005         x_country          := nULL;
23006 
23007     END IF;
23008 
23009 EXCEPTION
23010 
23011     WHEN NO_DATA_FOUND THEN
23012 
23013         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
23014         THEN
23015 
23016             fnd_message.set_name('ONT','OE_ID_TO_VALUE_ERROR');
23017             FND_MESSAGE.SET_TOKEN('ATTRIBUTE','get_customer_details');
23018             OE_MSG_PUB.Add;
23019 
23020         END IF;
23021 
23022 
23023     WHEN OTHERS THEN
23024 
23025         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
23026         THEN
23027             OE_MSG_PUB.Add_Exc_Msg
23028             (   G_PKG_NAME
23029           ,   'get_customer_details'
23030             );
23031         END IF;
23032 
23033         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
23034 
23035 END get_customer_details;
23036 
23037 
23038 /*-----------------------------------------------------------
23039 PROCEDURE Log_Scheduling_Requests
23040 ------------------------------------------------------------*/
23041 
23042 PROCEDURE Log_Scheduling_Requests
23043 (p_x_line_rec    IN  OUT NOCOPY OE_Order_PUB.Line_Rec_Type
23044 ,p_old_line_rec  IN  OE_Order_PUB.Line_Rec_Type
23045 ,p_caller        IN  VARCHAR2
23046 ,p_order_type_id IN  NUMBER
23047 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
23048 IS
23049 l_count NUMBER;
23050 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
23051 BEGIN
23052 
23053 if l_debug_level > 0 then
23054  oe_debug_pub.add('Entering Log_Scheduling_Requests',1);
23055  oe_debug_pub.add('p_caller' || p_caller,1);
23056 end if;
23057   IF NOT OE_GLOBALS.Equal(p_x_line_rec.schedule_ship_date,
23058                           p_old_line_rec.schedule_ship_date)
23059   THEN
23060     if l_debug_level > 0 then
23061      oe_debug_pub.add('Schedule shipdate  is changed',1);
23062     end if;
23063 
23064 /* 7576948: Commented for IR ISO CMS Project
23065 
23066      IF p_x_line_rec.order_source_id = 10 AND
23067         p_old_line_rec.schedule_ship_date IS NOT NULL
23068      THEN
23069 
23070         FND_MESSAGE.SET_NAME('ONT','OE_CHG_CORR_REQ');
23071         -- { start fix for 2648277
23072 	FND_MESSAGE.SET_TOKEN('CHG_ATTR',
23073             OE_Order_Util.Get_Attribute_Name('schedule_ship_date'));
23074         -- end fix for 2648277}
23075         OE_MSG_PUB.Add;
23076 
23077      END IF;
23078 
23079 */ -- COmmented for IR ISO CMS Project
23080     -- Bug 12355310 : Replacing check on SI flag by new API
23081     --	IF	p_x_line_rec.shipping_interfaced_flag = 'Y'
23082     IF (p_x_line_rec.shipping_interfaced_flag = 'Y' OR
23083        (p_x_line_rec.shippable_flag = 'Y' AND p_x_line_rec.booked_flag = 'Y'
23084         AND Shipping_Interfaced_Status(p_x_line_rec.line_id) = 'Y'))
23085     AND p_x_line_rec.ordered_quantity > 0  THEN
23086 
23087     -- Fix for bug 2347447
23088        if l_debug_level > 0 then
23089         oe_debug_pub.ADD('Update Shipping : logging delayed request for '
23090                                 || to_char(p_x_line_rec.line_id) ,1);
23091        end if;
23092 
23093 		OE_Delayed_Requests_Pvt.Log_Request(
23094 		p_entity_code				=>	OE_GLOBALS.G_ENTITY_LINE,
23095 		p_entity_id					=>	p_x_line_rec.line_id,
23096 		p_requesting_entity_code	=>	OE_GLOBALS.G_ENTITY_LINE,
23097 		p_requesting_entity_id  	=>	p_x_line_rec.line_id,
23098 		p_request_type				=>	OE_GLOBALS.G_UPDATE_SHIPPING,
23099 		p_request_unique_key1		=>  OE_GLOBALS.G_OPR_UPDATE,
23100 		p_param1             		=>	FND_API.G_TRUE,
23101 		x_return_status				=>	x_return_status);
23102 
23103 	END IF;
23104   END IF;
23105 
23106    -- End of apply attributes.
23107    -- Begin Pre write.
23108 
23109    -- Start AuditTrail
23110 
23111    IF  OE_GLOBALS.G_AUDIT_REASON_RQD_FLAG = 'Y'
23112    AND ( p_x_line_rec.change_reason IS NULL OR
23113          p_x_line_rec.change_reason = FND_API.G_MISS_CHAR)
23114    THEN
23115 
23116       -- bug 3636884, defaulting reason from group API
23117       IF OE_GLOBALS.G_DEFAULT_REASON THEN
23118         if l_debug_level > 0 then
23119          oe_debug_pub.add('Defaulting Audit Reason for Order Line', 1);
23120         end if;
23121          p_x_line_rec.change_reason := 'SYSTEM';
23122       ELSE
23123         if l_debug_level > 0 then
23124          oe_debug_pub.add('Audit Required Reason missing - error', 1);
23125         end if;
23126          fnd_message.set_name('ONT','OE_AUDIT_REASON_RQD');
23127          fnd_message.set_token('OBJECT','ORDER LINE');
23128          oe_msg_pub.add;
23129          RAISE FND_API.G_EXC_ERROR;
23130       END IF;
23131 
23132    END IF;
23133 
23134 
23135  -- If we move scheduling call to post write.
23136   IF p_caller = 'EXTERNAL' THEN
23137 
23138     IF ((p_x_line_rec.top_model_line_id is NOT NULL OR
23139         p_x_line_rec.ato_line_id is NOT NULL)) AND
23140         p_x_line_rec.item_type_code <> OE_GLOBALS.G_ITEM_CONFIG
23141     THEN
23142      if l_debug_level > 0 then
23143       oe_debug_pub.add('Before logging Log_CTO_Requests', 1);
23144      end if;
23145       Log_CTO_Requests( p_x_line_rec    => p_x_line_rec
23146                        ,p_old_line_rec  => p_old_line_rec
23147                        ,x_return_status => x_return_status);
23148     END IF;
23149 
23150 
23151   END IF; -- External
23152 --bug  3988559 modify sfadnavi  BEGIN
23153 
23154  if l_debug_level > 0 then
23155   oe_debug_pub.add('Before calling Version_Audit_Process',1);
23156  end if;
23157 
23158 --Adding code to log versioning/audit request
23159 OE_Line_Util.Version_Audit_Process(p_x_line_rec => p_x_line_rec,
23160                         p_old_line_rec => p_old_line_rec);
23161 
23162 --bug 3988559 modify sfadnavi  END
23163 
23164 
23165 
23166  if l_debug_level > 0 then
23167   oe_debug_pub.add('Exiting Log_Scheduling_Requests',1);
23168  end if;
23169 
23170 
23171 END Log_Scheduling_Requests;
23172 
23173 /* LG. May 03 changed all the calls to GMI uom_conversion to get_opm_converted_qty
23174  * to resolved rounding issues
23175  */
23176 
23177  PROCEDURE calculate_dual_quantity
23178 (
23179    p_ordered_quantity       IN OUT NOCOPY /* file.sql.39 change */ NUMBER
23180   ,p_old_ordered_quantity   IN NUMBER
23181   ,p_ordered_quantity2      IN OUT NOCOPY /* file.sql.39 change */ NUMBER
23182   ,p_old_ordered_quantity2  IN NUMBER
23183   ,p_ordered_quantity_uom   IN VARCHAR2
23184   ,p_ordered_quantity_uom2  IN VARCHAR2
23185   ,p_inventory_item_id      IN NUMBER
23186   ,p_ship_from_org_id       IN NUMBER
23187   ,x_ui_flag	            IN NUMBER
23188   ,x_return_status	    OUT NOCOPY /* file.sql.39 change */ NUMBER
23189  -- ,p_lot_id                 IN  NUMBER DEFAULT 0 -- OPM 2380194 added for RMA quantity2 OM pack J project
23190 	,p_lot_number             IN  VARCHAR2 DEFAULT NULL -- INVCONV for 2380194 added for RMA quantity2 OM pack J project
23191 )
23192 
23193 IS
23194 
23195 l_converted_qty        NUMBER(19,9);
23196 l_item_rec             OE_ORDER_CACHE.item_rec_type;
23197 --l_OPM_UOM              VARCHAR2(4);  -- INVCONV
23198 l_error_message        VARCHAR2(1000); -- INVCONV
23199 l_debug_level  CONSTANT NUMBER := oe_debug_pub.g_debug_level; -- INVCONV
23200 l_return               NUMBER;
23201 l_status               VARCHAR2(1);
23202 l_return_status        VARCHAR2(30);
23203 l_msg_count            NUMBER;
23204 -- l_msg_data             VARCHAR2(2000); INVCONV
23205 l_buffer                  VARCHAR2(2000); -- INVCONV
23206 UOM_CONVERSION_FAILED  EXCEPTION;             -- INVCONV
23207 TOLERANCE_ERROR EXCEPTION;             -- INVCONV
23208 
23209 BEGIN
23210 
23211 
23212 
23213 -- First of all, if this procedure is called from a source other then UI
23214 
23215 IF l_debug_level  > 0 THEN
23216 	oe_debug_pub.add ('Enter Calculate_dual_quantity');
23217 	oe_debug_pub.add ('p_ordered_quantity = ' || p_ordered_quantity );
23218 	oe_debug_pub.add ('p_old_ordered_quantity = ' || p_old_ordered_quantity );
23219 	oe_debug_pub.add ('p_ordered_quantity2 = ' || p_ordered_quantity2 );
23220 	oe_debug_pub.add ('p_old_ordered_quantity2 = ' || p_old_ordered_quantity2 );
23221 	oe_debug_pub.add ('p_ordered_quantity_uom = ' || p_ordered_quantity_uom );
23222 	oe_debug_pub.add ('p_ordered_quantity_uom2 = ' || p_ordered_quantity_uom2 );
23223 	oe_debug_pub.add ('p_inventory_item_id = ' || p_inventory_item_id );
23224 	oe_debug_pub.add ('p_ship_from_org_id = ' || p_ship_from_org_id );
23225 	oe_debug_pub.add ('p_lot_number = ' || p_lot_number );
23226   oe_debug_pub.add ('x_ui_flag = ' || x_ui_flag );
23227 END IF;
23228 
23229 -- First of all, if this procedure is called from a source other then UI
23230 /* If neither quantity is present, no calculation is required
23231 ======================================================*/
23232 
23233 IF p_ordered_quantity2 = fnd_api.g_miss_num THEN
23234    p_ordered_quantity2 := 0;
23235    IF l_debug_level  > 0 THEN
23236 	oe_debug_pub.add('Calculate_dual_quantity - p_ordered_quantity2 = fnd_api.g_miss_num' );
23237    END IF;
23238 
23239 END IF;
23240 
23241 IF( X_UI_FLAG = 1 ) THEN
23242   IF (p_ordered_quantity IS NULL OR
23243     p_ordered_quantity = FND_API.G_MISS_NUM ) AND
23244    (p_ordered_quantity2 IS NULL OR
23245     p_ordered_quantity2 = FND_API.G_MISS_NUM ) THEN
23246     IF l_debug_level  > 0 THEN
23247     		oe_debug_pub.add ('Calculate_dual_quantity - both quantities empty so early return');
23248     END IF;
23249     RETURN;
23250    END IF;
23251 END IF; -- IF( X_UI_FLAG = 1 ) THEN
23252 
23253 /* If this is a dual uom control line, load the item details from cache
23254 ==============================================================*/
23255 IF dual_uom_control
23256   (p_inventory_item_id,p_ship_from_org_id,l_item_rec) THEN
23257   -- IF l_item_rec.dualum_ind not in (1,2,3) THEN -- INVCONV
23258   IF l_item_rec.tracking_quantity_ind <> 'PS' then -- INVCONV
23259 
23260     p_ordered_quantity2 := NULL;
23261     RETURN;
23262   END IF;
23263 ELSE
23264   p_ordered_quantity2 := NULL;
23265   RETURN;
23266 END IF;
23267 
23268 IF l_debug_level  > 0 THEN
23269 	oe_debug_pub.add('Calculate_dual_quantity secondary_default_ind is ' || l_item_rec.secondary_default_ind);
23270 END IF;
23271 
23272 IF ( X_UI_FLAG = 0 ) THEN
23273    IF (NVL(p_ordered_quantity2,0) = 0
23274       OR l_item_rec.secondary_default_ind  = 'F' ) -- INVCONV
23275      THEN
23276 
23277       	IF l_debug_level  > 0 THEN
23278       			oe_debug_pub.add('Calculate_dual_quantity : quantity2 is null OR is type F - so calculate it');
23279       	END IF;
23280 
23281            /* p_ordered_quantity2 := GMI_Reservation_Util.get_opm_converted_qty( INVCONV
23282               p_apps_item_id    => p_inventory_item_id,
23283               p_organization_id => p_ship_from_org_id,
23284               p_apps_from_uom   => p_ordered_quantity_uom,
23285               p_apps_to_uom     => p_ordered_quantity_uom2,
23286               p_original_qty    => p_ordered_quantity,
23287               p_lot_id          => nvl(p_lot_id, 0) );  */-- OPM 2380194
23288 
23289 			  l_converted_qty := INV_CONVERT.INV_UM_CONVERT(p_inventory_item_id -- INVCONV
23290 			  																						  ,p_lot_number     -- INVCONV
23291 			  																							,p_ship_from_org_id -- INVCONV
23292 			  																						  ,5 --NULL
23293                                                       ,p_ordered_quantity
23294                                                       ,p_ordered_quantity_uom
23295                                                       ,p_ordered_quantity_uom2
23296                                                       ,NULL -- From uom name
23297                                                       ,NULL -- To uom name
23298                                                       );
23299        IF (l_converted_qty < 0) THEN    -- INVCONV
23300               raise UOM_CONVERSION_FAILED;
23301        END IF;
23302         p_ordered_quantity2 :=       l_converted_qty; -- INVCONV
23303       	IF l_debug_level  > 0 THEN
23304       			oe_debug_pub.add('Calculate_dual_quantity : calculated quantity2 is '||p_ordered_quantity2);
23305       	END IF;
23306 
23307    -- ELSIF (l_item_rec.dualum_ind in (2,3) ) THEN
23308    /* passed quantity is not null and secondary_default_ind in ('D','N (dualum_ind is 2 or 3) */
23309    ELSIF (l_item_rec.secondary_default_ind in ('D','N') )  tHEN -- INVCONV
23310 
23311        -- check the deviation and error out
23312        l_return := INV_CONVERT.Within_Deviation  -- INVCONV
23313                        ( p_organization_id   =>
23314                                  p_ship_from_org_id
23315                        , p_inventory_item_id =>
23316                                  p_inventory_item_id
23317                        , p_lot_number  => p_lot_number -- INVCONV
23318                        , p_precision         => 5
23319                        , p_quantity          => abs(p_ordered_quantity)   -- 5128490
23320                        , p_uom_code1         => p_ordered_quantity_uom -- INVCONV
23321                        , p_quantity2         => abs(p_ordered_quantity2)   -- 5128490
23322                        , p_uom_code2         => l_item_rec.secondary_uom_code );
23323 
23324       IF l_return = 0
23325       	then
23326       	    IF l_debug_level  > 0 THEN
23327     	  			oe_debug_pub.add('Calculate_dual_quantity - tolerance error 1' ,1);
23328     			 END IF;
23329 
23330     			 l_buffer          := FND_MSG_PUB.GET(p_msg_index => FND_MSG_PUB.G_LAST, -- INVCONV
23331                                          p_encoded => 'F');
23332            oe_msg_pub.add_text(p_message_text => l_buffer);
23333            IF l_debug_level  > 0 THEN
23334               oe_debug_pub.add(l_buffer,1);
23335     			 END IF;
23336     			 RAISE TOLERANCE_ERROR ;
23337 
23338    		else
23339       	IF l_debug_level  > 0 THEN
23340     	  		oe_debug_pub.add('Calculate_dual_quantity - No tolerance error so return ',1);
23341     		END IF;
23342     		x_return_status := 0;
23343      	RETURN;
23344      END IF; -- IF l_return = 0
23345 
23346 
23347       /* l_return := GMICVAL.dev_validation(l_item_rec.opm_item_id INVCONV
23348                                       ,nvl(p_lot_id, 0) --  2380194
23349                                       ,p_ordered_quantity
23350                                       ,l_OPM_UOM
23351                                       ,p_ordered_quantity2
23352                                       ,l_item_rec.opm_item_um2
23353                                       ,0);
23354       IF (l_return = -68 ) THEN
23355          x_return_status := -1;
23356          FND_MESSAGE.set_name('GMI','IC_DEVIATION_HI_ERR');
23357          OE_MSG_PUB.Add;
23358       ELSIF(l_return = -69 ) THEN
23359          x_return_status := -1;
23360          FND_MESSAGE.set_name('GMI','IC_DEVIATION_HI_ERR');
23361          OE_MSG_PUB.Add;
23362       END IF; */
23363 
23364 
23365    END IF;    -- IF (NVL(p_ordered_quantity2,0) = 0
23366 
23367    IF(x_return_status = -1 ) THEN
23368      RAISE FND_API.G_EXC_ERROR;
23369    END IF;
23370 
23371    RETURN;
23372 
23373 END IF; -- IF ( X_UI_FLAG = 0 ) THEN
23374 
23375 
23376 IF l_debug_level  > 0 THEN
23377 	oe_debug_pub.add('Calculate_dual_quantity  - Convert for dual controlled item Scenario',1);
23378 END IF;
23379 
23380 /* Has one of the two quantities changed
23381 =======================================*/
23382 IF (NOT OE_GLOBALS.EQUAL(p_ordered_quantity
23383          			    ,p_old_ordered_quantity )) OR
23384    (NOT OE_GLOBALS.EQUAL(p_ordered_quantity2
23385          			    ,p_old_ordered_quantity2)) OR
23386    (p_ordered_quantity  IS NULL) OR
23387    (p_ordered_quantity2 IS NULL) THEN
23388 
23389       IF l_debug_level  > 0 THEN
23390       	oe_debug_pub.add('Calculate_dual_quantity - change detected ',1);
23391       END IF;
23392 
23393    /*
23394    IF l_item_rec.dualum_ind = 1 THEN
23395      RETURN;
23396    END IF;
23397    */
23398 ELSE
23399    /* No calculation  required
23400    ==================*/
23401    RETURN;
23402 END IF; -- IF (NOT OE_GLOBALS.EQUAL(p_ordered_quantity
23403 
23404 
23405 
23406 
23407 /* Get the OPM equivalent code for order_quantity_uom
23408 =====================================================   INVCONV
23409 GMI_Reservation_Util.Get_OPMUOM_from_AppsUOM
23410 				 (p_Apps_UOM       => p_ordered_quantity_uom
23411 				 ,x_OPM_UOM        => l_OPM_UOM
23412 				 ,x_return_status  => l_status
23413 				 ,x_msg_count      => l_msg_count
23414 				 ,x_msg_data       => l_msg_data);
23415 
23416    IF (l_status <> FND_API.G_RET_STS_SUCCESS)
23417    THEN
23418       x_return_status := -1;
23419       oe_debug_pub.add('OPM After Get_OPMUOM_from_appsUOM -  failed : apps_uom =  ' || p_ordered_quantity_uom || 'opm_uom = ' || l_opm_uom );
23420    ELSE
23421       x_return_status := 1;
23422       oe_debug_pub.add('OPM After Get_OPMUOM_from_appsUOM : apps_uom =  ' || p_ordered_quantity_uom || 'opm_uom = ' || l_opm_uom );
23423    END IF;   */
23424 
23425 
23426 IF (NOT OE_GLOBALS.EQUAL(p_ordered_quantity
23427          			    ,p_old_ordered_quantity )) OR
23428 				     p_ordered_quantity2 IS NULL THEN
23429 
23430   /* Primary quantity has changed so recalculate secondary */
23431 
23432   -- IF l_item_rec.dualum_ind in (2,3)
23433      IF (l_item_rec.secondary_default_ind in ('D','N') ) -- INVCONV
23434     and p_ordered_quantity is NOT NULL AND
23435     p_ordered_quantity_uom <> p_ordered_quantity_uom2 AND
23436     p_ordered_quantity2 is NOT NULL THEN
23437 
23438     /* Only do tolerance check if both quantities populated */
23439 			IF l_debug_level  > 0 THEN
23440        		oe_debug_pub.add('Calculate_dual_quantity - Check the deviation  ');
23441       END IF;
23442 
23443       l_return := INV_CONVERT.Within_Deviation  -- INVCONV
23444                        ( p_organization_id   =>
23445                                  p_ship_from_org_id
23446                        , p_inventory_item_id =>
23447                                  p_inventory_item_id
23448                        , p_lot_number  => p_lot_number -- INVCONV
23449                        , p_precision         => 5
23450                        , p_quantity          => abs(p_ordered_quantity) -- 5128490
23451                        , p_uom_code1         => p_ordered_quantity_uom
23452                        , p_quantity2         => abs(p_ordered_quantity2)  -- 5128490
23453                        , p_uom_code2         => l_item_rec.secondary_uom_code);
23454 
23455       IF l_return = 0
23456       	then
23457       	   IF l_debug_level  > 0 THEN
23458     	  			oe_debug_pub.add('Calculate_dual_quantity - tolerance error 2' ,1);
23459     			 END IF;
23460      			 l_buffer := FND_MSG_PUB.GET(p_msg_index => FND_MSG_PUB.G_LAST, -- INVCONV
23461                                          p_encoded => 'F');
23462            oe_msg_pub.add_text(p_message_text => l_buffer);
23463            IF l_debug_level  > 0 THEN
23464               oe_debug_pub.add(l_buffer,1);
23465     			 END IF;
23466     			 RAISE TOLERANCE_ERROR ;
23467 
23468    		else
23469       	IF l_debug_level  > 0 THEN
23470     	  		oe_debug_pub.add('Calculate_dual_quantity - No tolerance error so return ',1);
23471     		END IF;
23472     	  x_return_status := 0;
23473      	  RETURN;
23474      END IF; -- IF l_return = 0
23475 
23476 
23477      /* l_return := GMICVAL.dev_validation(l_item_rec.opm_item_id
23478                                       ,nvl(p_lot_id, 0) --  2380194
23479 				      ,p_ordered_quantity
23480 				      ,l_OPM_UOM
23481 				      ,p_ordered_quantity2
23482                                       ,l_item_rec.opm_item_um2
23483 				      ,0);
23484     -- if change is within of tolerance, no further action
23485 
23486     IF (l_return NOT in (-68, -69)) THEN
23487        oe_debug_pub.add(' OPM : calculate_dual_qty .No tolerance error so return  ');
23488        RETURN;
23489     ELSE   ---  IF (l_item_rec.dualum_ind = 3 )THEN
23490        x_return_status := l_return;
23491        oe_debug_pub.add('Calculate_dual_quantity - deviation error so return  ');
23492        RETURN;
23493     END IF;    */
23494 
23495   END IF; -- IF (l_item_rec.secondary_default_ind in ('D','N')THEN
23496 
23497  -- IF (l_item_rec.dualum_ind in (1,2) )THEN    INVCONV
23498     IF (l_item_rec.secondary_default_ind in ('F','D') ) THEN -- INVCONV
23499  							IF l_debug_level  > 0 THEN
23500               		oe_debug_pub.add('Calculate_dual_qty - uom conversion primary to secondary');
23501               END IF;
23502      /*l_converted_qty :=GMICUOM.uom_conversion
23503  	            (l_item_rec.opm_item_id,0
23504      	    	     ,p_ordered_quantity
23505                      ,l_OPM_UOM
23506     	    	     ,l_item_rec.opm_item_um2
23507 	             ,0);
23508 
23509      IF (l_converted_qty < 0) THEN
23510         x_return_status := -11 ;
23511      END IF;
23512      p_ordered_quantity2 := l_converted_qty;    */
23513 
23514       /*p_ordered_quantity2 := GMI_Reservation_Util.get_opm_converted_qty( INVCONV
23515               p_apps_item_id    => p_inventory_item_id,
23516               p_organization_id => p_ship_from_org_id,
23517               p_apps_from_uom   => p_ordered_quantity_uom,
23518               p_apps_to_uom     => p_ordered_quantity_uom2,
23519               p_original_qty    => p_ordered_quantity,
23520               p_lot_id          => nvl(p_lot_id, 0) ); -- OPM 2380194  */
23521 
23522      p_ordered_quantity2 := INV_CONVERT.INV_UM_CONVERT(p_inventory_item_id -- INVCONV
23523      																									,p_lot_number     -- INVCONV
23524      																									,p_ship_from_org_id -- INVCONV
23525                                                       ,5 --NULL
23526                                                       ,p_ordered_quantity
23527                                                       ,p_ordered_quantity_uom
23528                                                       ,p_ordered_quantity_uom2
23529                                                       ,NULL -- From uom name
23530                                                       ,NULL -- To uom name
23531                                                       );
23532     IF (p_ordered_quantity2 < 0) THEN    -- INVCONV
23533               raise UOM_CONVERSION_FAILED;
23534     END IF;
23535 
23536 
23537       	IF l_debug_level  > 0 THEN
23538       			oe_debug_pub.add('Calculate_dual_quantity : calculated quantity2 is '||p_ordered_quantity2);
23539       	END IF;
23540 
23541 
23542 
23543 
23544  END IF; -- IF (l_item_rec.secondary_default_ind in ('F','D')THEN
23545 
23546 ELSIF (NOT OE_GLOBALS.EQUAL(p_ordered_quantity2
23547          			        ,p_old_ordered_quantity2 )) THEN
23548   /* Secondary quantity has changed so recalculate primary */
23549 
23550 
23551 
23552   -- IF l_item_rec.dualum_ind in (2,3) and  INVCONV
23553     IF (l_item_rec.secondary_default_ind in ('D','N')  )and  -- INVCONV
23554     p_ordered_quantity2 is NOT NULL AND
23555     p_ordered_quantity_uom <> p_ordered_quantity_uom2 AND
23556     p_ordered_quantity is NOT NULL THEN
23557 
23558     /* Only do tolerance check if both quantities populated */
23559    l_return := INV_CONVERT.Within_Deviation  -- INVCONV
23560                        ( p_organization_id   =>
23561                                  p_ship_from_org_id
23562                        , p_inventory_item_id =>
23563                                  p_inventory_item_id
23564                        , p_lot_number  => p_lot_number -- INVCONV
23565                        , p_precision         => 5
23566                        , p_quantity          => abs(p_ordered_quantity) -- 5128490
23567                        , p_uom_code1         => p_ordered_quantity_uom
23568                        , p_quantity2         => abs(p_ordered_quantity2) -- 5128490
23569                        , p_uom_code2         => l_item_rec.secondary_uom_code );
23570 
23571        IF l_return = 0
23572       	then
23573       	    IF l_debug_level  > 0 THEN
23574     	  			oe_debug_pub.add('Calculate_dual_quantity - tolerance error 3' ,1);
23575     			 END IF;
23576 
23577     			 l_buffer := FND_MSG_PUB.GET(p_msg_index => FND_MSG_PUB.G_LAST, -- INVCONV
23578                                          p_encoded => 'F');
23579            oe_msg_pub.add_text(p_message_text => l_buffer);
23580            IF l_debug_level  > 0 THEN
23581               oe_debug_pub.add(l_buffer,1);
23582     			 END IF;
23583     			 RAISE TOLERANCE_ERROR ;
23584 
23585    		else
23586       	IF l_debug_level  > 0 THEN
23587     	  		oe_debug_pub.add('Calculate_dual_quantity - No tolerance error so return ',1);
23588     		END IF;
23589      	RETURN;
23590      END IF; -- IF l_return = 0
23591 
23592 
23593      /* l_return := GMICVAL.dev_validation(l_item_rec.opm_item_id
23594                                       ,nvl(p_lot_id, 0) --  2380194
23595 	           	              ,p_ordered_quantity
23596 				      ,l_OPM_UOM
23597 				      ,p_ordered_quantity2
23598                                       ,l_item_rec.opm_item_um2
23599 				      ,0);
23600     --  if change is within tolerance, no further action
23601     IF (l_return NOT in (-68, -69)) THEN
23602        oe_debug_pub.add(' OPM : calculate_dual_qty .No tolerance error so return  ');
23603        RETURN;
23604     ELSE  -- IF (l_item_rec.dualum_ind = 3 )THEN
23605        x_return_status := l_return;
23606        oe_debug_pub.add('Calculate_dual_quantity .deviation error so return  ');
23607        RETURN;
23608     END IF;   */
23609 
23610   END IF;   -- IF (l_item_rec.secondary_default_ind in ('D','N')and  -- INVCONV
23611 
23612   --IF (l_item_rec.dualum_ind in (1,2) )THEN
23613     IF (l_item_rec.secondary_default_ind in ('F','D'))  then -- INVCONV
23614      /* Convert secondary quantity to derive primary */
23615     -- use l_converted_qty with precision of 19,9 to match OPM processing
23616     /*l_converted_qty  :=GMICUOM.uom_conversion
23617  	   	        (l_item_rec.opm_item_id,0
23618     	                ,p_ordered_quantity2
23619     	       	        ,l_item_rec.opm_item_um2
23620     	                ,l_OPM_UOM
23621 			,0);
23622 
23623     IF (l_converted_qty < 0) THEN
23624        x_return_status := -11;
23625     END IF;
23626 
23627     p_ordered_quantity := l_converted_qty;          */
23628     /* p_ordered_quantity := GMI_Reservation_Util.get_opm_converted_qty(
23629               p_apps_item_id    => p_inventory_item_id,
23630               p_organization_id => p_ship_from_org_id,
23631               p_apps_from_uom   => p_ordered_quantity_uom2,
23632               p_apps_to_uom     => p_ordered_quantity_uom,
23633               p_original_qty    => p_ordered_quantity2,
23634               p_lot_id          => nvl(p_lot_id, 0) ); -- OPM 2380194 */
23635 
23636     p_ordered_quantity := INV_CONVERT.INV_UM_CONVERT(p_inventory_item_id -- INVCONV
23637     																									,p_lot_number     -- INVCONV
23638     																									,p_ship_from_org_id -- INVCONV
23639                                                       ,5 --NULL
23640                                                       ,p_ordered_quantity2
23641                                                       ,p_ordered_quantity_uom2
23642                                                       ,p_ordered_quantity_uom
23643                                                       ,NULL -- From uom name
23644                                                       ,NULL -- To uom name
23645                                                       );
23646     IF (p_ordered_quantity < 0) THEN    -- INVCONV
23647               raise UOM_CONVERSION_FAILED;
23648     END IF;
23649 
23650     IF l_debug_level  > 0 THEN
23651        oe_debug_pub.add('Calculate_dual_quantity  - convert to ordered qty gives ' || p_ordered_quantity);
23652     END IF;
23653  END IF; --    IF (l_item_rec.secondary_default_ind in ('F','D')  -- INVCONV
23654 
23655 END IF; --  IF (NVL(p_ordered_quantity2,0) = 0
23656 
23657 IF l_debug_level  > 0 THEN
23658  			 oe_debug_pub.add('Calculate_dual_quantity  - exiting ordered qty = ' || p_ordered_quantity);
23659        oe_debug_pub.add('Calculate_dual_quantity  - exiting ordered qty2 = ' || p_ordered_quantity2);
23660     END IF;
23661 EXCEPTION
23662 
23663 WHEN UOM_CONVERSION_FAILED THEN
23664 				oe_debug_pub.add('Exception handling: UOM_CONVERSION_FAILED in calculate_dual_qty', 1);
23665     FND_MESSAGE.SET_NAME('INV','INV_NO_CONVERSION_ERR'); -- INVCONV
23666     OE_MSG_PUB.Add;
23667        x_return_status := -99999;
23668      --RAISE FND_API.G_EXC_ERROR;
23669 
23670 
23671 WHEN TOLERANCE_ERROR THEN -- INVCONV
23672 				oe_debug_pub.add('Exception handling: TOLERANCE_ERROR in calculate_dual_qty', 1);
23673  				 x_return_status := -1;
23674          --RAISE -- FND_API.G_EXC_ERROR; -- INVCONV
23675 
23676 WHEN OTHERS THEN
23677      IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
23678      THEN
23679          OE_MSG_PUB.Add_Exc_Msg
23680          (     G_PKG_NAME         ,
23681              'Calculate_dual_quantity'
23682          );
23683      END IF;
23684         oe_debug_pub.add('Exception handling: others in calculate_dual_qty', 1);
23685      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
23686 
23687 END calculate_dual_quantity;
23688 
23689 
23690 
23691 PROCEDURE Log_Blanket_Request
23692 (   p_x_line_rec                    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
23693 ,   p_old_line_rec                  IN OE_Order_PUB.Line_Rec_Type
23694 )
23695 IS
23696   l_return_status                VARCHAR2(30);
23697 --
23698 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
23699 --
23700 BEGIN
23701 
23702     if l_debug_level > 0 then
23703        oe_debug_pub.add('line id : '||p_x_line_rec.line_id);
23704        oe_debug_pub.add('new blanket number : '||p_x_line_rec.blanket_number);
23705        oe_debug_pub.add('old blanket number : '||p_old_line_rec.blanket_number);
23706        oe_debug_pub.add('fulfilled flag : '||p_x_line_rec.fulfilled_flag);
23707        oe_debug_pub.add('operation : '||p_x_line_rec.operation);
23708        oe_debug_pub.add('split from line ID : '||p_x_line_rec.split_from_line_id);
23709        oe_debug_pub.add('split action code : '||p_x_line_rec.split_action_code);
23710        oe_debug_pub.add('split by : '||p_x_line_rec.split_by);
23711     end if;
23712 
23713     -- BUG 2746595, send currency code as request_unique_key1 parameter to
23714     -- process release request. This is required as 2 distinct requests need to
23715     -- be logged for currency updates.
23716 
23717     IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_DELETE
23718     THEN
23719 
23720        OE_Order_Cache.Load_Order_Header(p_x_line_rec.header_id);
23721 
23722        -- For DELETES, log process releases request with new values as
23723        -- null or 0 so that quantity/amount cumulations see negative
23724        -- changes thus resulting in decrementing final released qty/amount
23725        OE_Delayed_Requests_Pvt.Log_Request
23726            (p_entity_code               => OE_GLOBALS.G_ENTITY_ALL
23727            ,p_entity_id                 => p_x_line_rec.line_id
23728            ,p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_LINE
23729            ,p_requesting_entity_id      => p_x_line_rec.line_id
23730            ,p_request_type              => OE_GLOBALS.G_PROCESS_RELEASE
23731            -- Old values
23732            ,p_param1                    => p_x_line_rec.blanket_number
23733            ,p_param2                    => p_x_line_rec.blanket_line_number
23734            ,p_param3                    => p_x_line_rec.ordered_quantity
23735            ,p_param4                    => p_x_line_rec.order_quantity_uom
23736            ,p_param5                    => p_x_line_rec.unit_selling_price
23737            ,p_param6                    => p_x_line_rec.inventory_item_id
23738            -- New values
23739            ,p_param11                   => null
23740            ,p_param12                   => null
23741            ,p_param13                   => 0
23742            ,p_param14                   => null
23743            ,p_param15                   => 0
23744            ,p_param16                   => null
23745            -- Other parameters
23746            ,p_param8                    => p_x_line_rec.fulfilled_flag
23747            ,p_param9                    => p_x_line_rec.line_set_id
23748            ,p_request_unique_key1       =>
23749                         OE_Order_Cache.g_header_rec.transactional_curr_code
23750 
23751            ,x_return_status             => l_return_status
23752           );
23753 
23754        -- If this is a shipment line, log request against the line set
23755        -- to validate that sum of quantities/amounts across all shipments
23756        -- in this line set are within the release min/max limits on blanket
23757        IF p_x_line_rec.line_set_id IS NOT NULL THEN
23758          OE_Delayed_Requests_Pvt.Log_Request
23759            (p_entity_code               => OE_GLOBALS.G_ENTITY_ALL
23760            ,p_entity_id                 => p_x_line_rec.line_set_id
23761            ,p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_LINE
23762            ,p_requesting_entity_id      => p_x_line_rec.line_id
23763            ,p_request_type              => OE_GLOBALS.G_VALIDATE_RELEASE_SHIPMENTS
23764            ,p_request_unique_key1       => p_x_line_rec.blanket_number
23765            ,p_request_unique_key2       => p_x_line_rec.blanket_line_number
23766            ,p_param1                    =>
23767                         OE_Order_Cache.g_header_rec.transactional_curr_code
23768            ,x_return_status             => l_return_status
23769            );
23770        END IF;
23771 
23772      ELSIF (
23773                OE_Quote_Util.G_COMPLETE_NEG = 'Y'
23774             AND
23775       NOT OE_GLOBALS.EQUAL(p_x_line_rec.transaction_phase_code
23776                       ,p_old_line_rec.transaction_phase_code)
23777            )
23778      THEN
23779 
23780        if l_debug_level > 0 then
23781           oe_debug_pub.add('log blanket requests for complete neg');
23782        end if;
23783 
23784        OE_Order_Cache.Load_Order_Header(p_x_line_rec.header_id);
23785 
23786        -- Qty/amount against the blanket should be incremented by
23787        -- total qty/amount of this line, as complete negotiation is
23788        -- running consumption logic for this order first time.
23789        -- Hence, send old parameter (param1-6) values as null.
23790        OE_Delayed_Requests_Pvt.Log_Request
23791            (p_entity_code               => OE_GLOBALS.G_ENTITY_ALL
23792            ,p_entity_id                 => p_x_line_rec.line_id
23793            ,p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_LINE
23794            ,p_requesting_entity_id      => p_x_line_rec.line_id
23795            ,p_request_type              => OE_GLOBALS.G_PROCESS_RELEASE
23796            -- Old values
23797            ,p_param1                    => null
23798            ,p_param2                    => null
23799            ,p_param3                    => null
23800            ,p_param4                    => null
23801            ,p_param5                    => null
23802            ,p_param6                    => null
23803            -- New values
23804            ,p_param11                   => p_x_line_rec.blanket_number
23805            ,p_param12                   => p_x_line_rec.blanket_line_number
23806            ,p_param13                   => p_x_line_rec.ordered_quantity
23807            ,p_param14                   => p_x_line_rec.order_quantity_uom
23808            ,p_param15                   => p_x_line_rec.unit_selling_price
23809            ,p_param16                   => p_x_line_rec.inventory_item_id
23810            -- Other parameters
23811            ,p_param8                    => p_x_line_rec.fulfilled_flag
23812            ,p_param9                    => p_x_line_rec.line_set_id
23813            ,p_request_unique_key1       =>
23814                         OE_Order_Cache.g_header_rec.transactional_curr_code
23815            ,x_return_status             => l_return_status
23816           );
23817 
23818        -- If this is a shipment line, log request against the line set
23819        -- to validate that sum of quantities/amounts across all shipments
23820        -- in this line set are within the release min/max limits on blanket
23821        IF p_x_line_rec.line_set_id IS NOT NULL THEN
23822 
23823           IF p_x_line_rec.blanket_number IS NOT NULL THEN
23824               OE_Delayed_Requests_Pvt.Log_Request
23825                (p_entity_code               => OE_GLOBALS.G_ENTITY_ALL
23826                 ,p_entity_id                 => p_x_line_rec.line_set_id
23827                 ,p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_LINE
23828                 ,p_requesting_entity_id      => p_x_line_rec.line_id
23829                 ,p_request_type              => OE_GLOBALS.G_VALIDATE_RELEASE_SHIPMENTS
23830                 ,p_request_unique_key1       => p_x_line_rec.blanket_number
23831                 ,p_request_unique_key2       => p_x_line_rec.blanket_line_number
23832                 ,p_param1                    =>
23833                         OE_Order_Cache.g_header_rec.transactional_curr_code
23834                 ,x_return_status             => l_return_status
23835                 );
23836           END IF;
23837 
23838        END IF; -- if line_set_id is not null
23839 
23840     ELSIF (NOT OE_GLOBALS.EQUAL(p_x_line_rec.blanket_number
23841                             ,p_old_line_rec.blanket_number)
23842          OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.blanket_line_number
23843                             ,p_old_line_rec.blanket_line_number)
23844          OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity
23845                             ,p_old_line_rec.ordered_quantity)
23846          OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.unit_selling_price
23847                             ,p_old_line_rec.unit_selling_price)
23848          OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.order_quantity_uom
23849                             ,p_old_line_rec.order_quantity_uom)
23850           )
23851     THEN
23852 
23853        -- For creates and updates, log request if any fields affecting
23854        -- quantities/amounts are changed
23855 
23856        OE_Order_Cache.Load_Order_Header(p_x_line_rec.header_id);
23857 
23858        OE_Delayed_Requests_Pvt.Log_Request
23859            (p_entity_code               => OE_GLOBALS.G_ENTITY_ALL
23860            ,p_entity_id                 => p_x_line_rec.line_id
23861            ,p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_LINE
23862            ,p_requesting_entity_id      => p_x_line_rec.line_id
23863            ,p_request_type              => OE_GLOBALS.G_PROCESS_RELEASE
23864            -- Old values
23865            ,p_param1                    => p_old_line_rec.blanket_number
23866            ,p_param2                    => p_old_line_rec.blanket_line_number
23867            ,p_param3                    => p_old_line_rec.ordered_quantity
23868            ,p_param4                    => p_old_line_rec.order_quantity_uom
23869            ,p_param5                    => p_old_line_rec.unit_selling_price
23870            ,p_param6                    => p_old_line_rec.inventory_item_id
23871            -- New values
23872            ,p_param11                   => p_x_line_rec.blanket_number
23873            ,p_param12                   => p_x_line_rec.blanket_line_number
23874            ,p_param13                   => p_x_line_rec.ordered_quantity
23875            ,p_param14                   => p_x_line_rec.order_quantity_uom
23876            ,p_param15                   => p_x_line_rec.unit_selling_price
23877            ,p_param16                   => p_x_line_rec.inventory_item_id
23878            -- Other parameters
23879            ,p_param8                    => p_x_line_rec.fulfilled_flag
23880            ,p_param9                    => p_x_line_rec.line_set_id
23881            ,p_request_unique_key1       =>
23882                         OE_Order_Cache.g_header_rec.transactional_curr_code
23883            ,x_return_status             => l_return_status
23884           );
23885 
23886        -- If this is a shipment line, log request against the line set
23887        -- to validate that sum of quantities/amounts across all shipments
23888        -- in this line set are within the release min/max limits on blanket
23889        IF p_x_line_rec.line_set_id IS NOT NULL THEN
23890 
23891           IF p_x_line_rec.blanket_number IS NOT NULL THEN
23892               OE_Delayed_Requests_Pvt.Log_Request
23893                (p_entity_code               => OE_GLOBALS.G_ENTITY_ALL
23894                 ,p_entity_id                 => p_x_line_rec.line_set_id
23895                 ,p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_LINE
23896                 ,p_requesting_entity_id      => p_x_line_rec.line_id
23897                 ,p_request_type              => OE_GLOBALS.G_VALIDATE_RELEASE_SHIPMENTS
23898                 ,p_request_unique_key1       => p_x_line_rec.blanket_number
23899                 ,p_request_unique_key2       => p_x_line_rec.blanket_line_number
23900                 ,p_param1                    =>
23901                         OE_Order_Cache.g_header_rec.transactional_curr_code
23902                 ,x_return_status             => l_return_status
23903                 );
23904           END IF;
23905 
23906           -- If blanket number is being updated on the shipment, also
23907           -- need to run shipment validation for the old blanket reference
23908           IF p_old_line_rec.blanket_number IS NOT NULL
23909              AND (NOT OE_GLOBALS.EQUAL(p_x_line_rec.blanket_number
23910                                     ,p_old_line_rec.blanket_number)
23911                   OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.blanket_line_number
23912                                      ,p_old_line_rec.blanket_line_number)
23913                   )
23914           THEN
23915               OE_Delayed_Requests_Pvt.Log_Request
23916                (p_entity_code               => OE_GLOBALS.G_ENTITY_ALL
23917                 ,p_entity_id                 => p_x_line_rec.line_set_id
23918                 ,p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_LINE
23919                 ,p_requesting_entity_id      => p_x_line_rec.line_id
23920                 ,p_request_type              => OE_GLOBALS.G_VALIDATE_RELEASE_SHIPMENTS
23921                 ,p_request_unique_key1       => p_old_line_rec.blanket_number
23922                 ,p_request_unique_key2       => p_old_line_rec.blanket_line_number
23923                 ,p_param1                    =>
23924                         OE_Order_Cache.g_header_rec.transactional_curr_code
23925                 ,x_return_status             => l_return_status
23926                 );
23927           END IF;
23928 
23929        END IF; -- if line_set_id is not null
23930 
23931     END IF; -- if operation is DELETE
23932 
23933     IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
23934       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
23935     END IF;
23936 
23937 EXCEPTION
23938    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
23939      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
23940    WHEN OTHERS THEN
23941      oe_debug_pub.add('Others error in Log_Blanket_Request');
23942      oe_debug_pub.add('Error :'||substr(sqlerrm,1,200));
23943      IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
23944      THEN
23945          OE_MSG_PUB.Add_Exc_Msg
23946          (     G_PKG_NAME         ,
23947              'Log_Blanket_Request'
23948          );
23949      END IF;
23950      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
23951 END Log_Blanket_Request;
23952 
23953 
23954 /*sdatti*/
23955 --procedure to update the adjustments of a line when the item is changed.
23956 --should handle deleting the IUE associations and the updating the
23957 --parent adjustments for free goods
23958 --see bug#2643552
23959 
23960 PROCEDURE  update_adjustment_flags
23961   ( p_old_line_rec IN OE_Order_PUB.line_rec_type,
23962     p_x_line_rec IN OE_Order_PUB.line_rec_type)
23963   IS
23964 
23965 --cursor to return the current line association id and the
23966 --parent line assocation id through the OE_PRICE_ADJ_ASSOCS table
23967 CURSOR C1 IS
23968    SELECT opa1.price_adjustment_id, opa2.price_adjustment_id, opa1.line_id
23969      FROM
23970       oe_price_adjustments opa1,
23971       oe_price_adj_assocs opaa,
23972       oe_price_adjustments opa2
23973      WHERE
23974      opa1.line_id = p_old_line_rec.line_id
23975      AND opa1.price_adjustment_id = opaa.rltd_price_adj_id
23976      AND opaa.price_adjustment_id = opa2.price_adjustment_id
23977      AND opa2.list_line_type_code = 'PRG';
23978 
23979 --cursor to find the IUE adjustments for this line
23980 CURSOR c2 IS
23981    SELECT price_adjustment_id
23982      FROM oe_price_adjustments
23983      where line_id=p_old_line_rec.line_id AND list_line_type_code='IUE';
23984 
23985 --variables to read the cursor C1 into
23986 parent_adj_id                oe_price_adjustments.price_adjustment_id%TYPE;
23987 child_adj_id                 oe_price_adjustments.price_adjustment_id%TYPE;
23988 child_line_id		     oe_price_adjustments.line_id%TYPE;
23989 
23990 iue_adj_id                   oe_price_adjustments.price_adjustment_id%TYPE;
23991 app_f			     oe_price_adjustments.applied_flag%TYPE;
23992 up_f			     oe_price_adjustments.updated_flag%TYPE;
23993 row_count                    NUMBER;
23994 
23995 BEGIN
23996    oe_debug_pub.ADD('Entering OE_LINE_UTIL.UPDATE_ADJUSTMENT_FLAGS',1);
23997 
23998    IF p_old_line_rec.inventory_item_id IS NULL THEN
23999       --new item, dont need to do anything
24000       oe_debug_pub.ADD('New Item, dont have to do anything',1);
24001       oe_debug_pub.ADD('Exiting OE_LINE_UTIL.UPDATE_ADJUSTMENT_FLAGS',1);
24002       RETURN;
24003    END IF;
24004 
24005    --deleting the IUE adjustment
24006    /*   DELETE FROM oe_price_adjustments
24007    where line_id=p_old_line_rec.line_id AND list_line_type_code='IUE';*/
24008 
24009    oe_debug_pub.ADD('trying to delete IUE adjustments...',1);
24010    OPEN c2;
24011    FETCH c2 INTO iue_adj_id;
24012    IF c2%found THEN
24013       oe_line_adj_util.delete_row(p_price_adjustment_id=>iue_adj_id);
24014       oe_debug_pub.ADD('deleted IUE association:'||SQL%rowcount||' row(s)',1);
24015       oe_debug_pub.ADD('looking for item parent lines...',1);
24016    END IF;
24017    CLOSE c2;
24018 
24019 
24020 
24021    OPEN c1;
24022 	     loop
24023 		--loop through all the parents
24024 		FETCH c1 INTO child_adj_id, parent_adj_id,child_line_id;
24025 		EXIT WHEN c1%notfound;
24026 
24027 		oe_debug_pub.ADD('found parent line:'||parent_adj_id||' for child line:'||child_adj_id,1);
24028 
24029 			--delete the adjustment if this is the child line.
24030 		IF child_line_id=p_old_line_rec.line_id then
24031 		   oe_debug_pub.ADD('trying to delete adjustments for line_id:'||p_old_line_rec.line_id,1);
24032 		   oe_line_adj_util.delete_row(p_line_id=>p_old_line_rec.line_id);
24033 		   oe_debug_pub.ADD('child adj id '||child_adj_id,1);
24034 	           OE_Line_Adj_Assocs_Util.delete_row(
24035 			p_price_adjustment_id=>child_adj_id);
24036 		END IF;
24037 
24038 		--Find out the number of free items adjustments associated with this parent
24039 		--(other then this item, we already deleted its adjustment)
24040 		SELECT COUNT(*) INTO row_count
24041 		  FROM oe_price_adj_assocs opaa,oe_price_adjustments opa
24042 		  WHERE opaa.price_adjustment_id=parent_adj_id
24043 		  AND opaa.rltd_price_adj_id=opa.price_adjustment_id;
24044 		oe_debug_pub.ADD('total '||row_count||' free child record(s)',1);
24045 
24046 		IF  row_count>0 THEN
24047 		   --not the only free item, this adjustment is applied _and_ updated = 'Y'
24048 		   UPDATE oe_price_adjustments
24049 		     SET applied_flag='Y',updated_flag='Y'
24050 		     WHERE price_adjustment_id=parent_adj_id;
24051 		   oe_debug_pub.ADD('updated parent adjustment: applied_flag=Y,updated_flag=Y:'||SQL%rowcount||' row(s)',1);
24052                    UPDATE oe_price_adjustments
24053                      SET updated_flag = 'Y' where price_adjustment_id in
24054                       (select rltd_price_adj_id from oe_price_adj_assocs
24055                        where price_adjustment_id = parent_adj_id);
24056 		 ELSE
24057 		   --the last (or only) free item, make parent adjustment applied='N'
24058 		   UPDATE oe_price_adjustments
24059 		     SET applied_flag='N',updated_flag='Y'
24060 		     WHERE price_adjustment_id=parent_adj_id;
24061 		   oe_debug_pub.ADD('updated parent adjustment: applied_flag=N,updated_flag=Y:'||SQL%rowcount||' rows',1);
24062 		END IF;
24063 		SELECT applied_flag,updated_flag INTO app_f,up_f
24064 		  FROM oe_price_adjustments
24065 		  WHERE price_adjustment_id=parent_adj_id;
24066 		oe_debug_pub.ADD('price_adjustment_id:'||parent_adj_id||' applied_flag='||app_f||' updated_flag='||up_f,1);
24067 
24068 
24069 	     END LOOP;
24070 	     CLOSE c1;
24071 	     oe_debug_pub.ADD('...done looking for item parent lines',1);
24072 	     oe_debug_pub.ADD('Exiting OE_LINE_UTIL.UPDATE_ADJUSTMENT_FLAGS',1);
24073 	     RETURN;
24074 
24075 END update_adjustment_flags;
24076 
24077 /*sdatti*/
24078 
24079 
24080 /* Procedure Get_Item_Info
24081 -------------------------------------------------------
24082 This procedure will return ordered_item, ordered_item_description and
24083 inventory_item based on passing in item_identifier_type */
24084 
24085 PROCEDURE GET_ITEM_INFO
24086 (   x_return_status         OUT NOCOPY VARCHAR2
24087 ,   x_msg_count             OUT NOCOPY NUMBER
24088 ,   x_msg_data              OUT NOCOPY VARCHAR2
24089 ,   p_item_identifier_type          IN VARCHAR2
24090 ,   p_inventory_item_id             IN Number
24091 ,   p_ordered_item_id               IN Number
24092 ,   p_sold_to_org_id                IN Number
24093 ,   p_ordered_item                  IN VARCHAR2
24094 ,   x_ordered_item          OUT NOCOPY VARCHAR2
24095 ,   x_ordered_item_desc     OUT NOCOPY VARCHAR2
24096 ,   x_inventory_item        OUT NOCOPY VARCHAR2
24097 ,   p_org_id                        IN Number DEFAULT NULL
24098 ) IS
24099 
24100 BEGIN
24101 
24102 -- Bug 5244726
24103 OE_ORDER_MISC_UTIL.GET_ITEM_INFO( x_return_status
24104 ,   x_msg_count
24105 ,   x_msg_data
24106 ,   p_item_identifier_type
24107 ,   p_inventory_item_id
24108 ,   p_ordered_item_id
24109 ,   p_sold_to_org_id
24110 ,   p_ordered_item
24111 ,   x_ordered_item
24112 ,   x_ordered_item_desc
24113 ,   x_inventory_item
24114 ,   p_org_id );
24115 
24116 EXCEPTION
24117 
24118     WHEN OTHERS THEN
24119 
24120         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
24121         THEN
24122             OE_MSG_PUB.Add_Exc_Msg (   G_PKG_NAME ,   'GET_ITEM_INFO');
24123         END IF;
24124 
24125         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
24126 
24127 END GET_ITEM_INFO;
24128 
24129 
24130 -----------------------------------------------------------------
24131 --      *** Enhanced Dropshipments ***
24132 -----------------------------------------------------------------
24133 /*--------------------------------------------------------------+
24134 Name          : Log_Dropship_CMS_Request
24135 Description   : This Procedure will log CMS Delayed Request when
24136                 ever there is a change in the CMS attributes
24137                 This procedure will be called from Pre Write
24138                 Process and delayed request will be executed at
24139                 the commit time.
24140 Change Record :
24141 +--------------------------------------------------------------*/
24142 Procedure Log_Dropship_CMS_Request
24143 ( p_x_line_rec            IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
24144 , p_old_line_rec          IN OE_Order_PUB.Line_Rec_Type
24145 )
24146 IS
24147  l_return_status         VARCHAR2(30);
24148  l_debug_level CONSTANT  NUMBER := oe_debug_pub.g_debug_level;
24149  l_operation             VARCHAR2(30) := p_x_line_rec.operation;
24150  l_count                 NUMBER;
24151  l_ref_data_elem_changed VARCHAR2(1) := 'N';
24152  l_cust_po_attr_change   BOOLEAN := FALSE ;
24153  l_rcv_count             NUMBER := 0;
24154  l_log_cust_po_change    boolean:=TRUE;
24155  l_ref_data_only         boolean:=FALSE;
24156 BEGIN
24157 
24158   IF l_debug_level >  0 THEN
24159      OE_DEBUG_PUB.Add('Entering Log_Dropship_CMS_Request...', 2);
24160   END IF;
24161 
24162   SELECT  count(*)
24163     INTO  l_count
24164     FROM  oe_drop_ship_sources
24165    WHERE  line_id   = p_x_line_rec.line_id
24166      AND  header_id = p_x_line_rec.header_id;
24167 
24168   IF l_count = 0 THEN
24169      IF l_debug_level > 0 THEN
24170         OE_DEBUG_PUB.Add('No Records in Drop Ship Sources,Returning...', 2);
24171      END IF;
24172      RETURN;
24173   END IF;
24174 
24175   IF OE_DS_PVT.Check_Req_PO_Cancelled
24176               (p_line_id    =>   p_x_line_rec.line_id
24177               ,p_header_id  =>   p_x_line_rec.header_id)  THEN
24178 
24179         FND_MESSAGE.Set_Name('ONT', 'ONT_DS_PO_CANCELLED');
24180         OE_MSG_PUB.Add;
24181         RAISE FND_API.G_EXC_ERROR;
24182   END IF;
24183 
24184 
24185   IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.shipping_instructions
24186                               ,p_old_line_rec.shipping_instructions)
24187      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.packing_instructions
24188                               ,p_old_line_rec.packing_instructions)
24189      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_to_contact_id
24190                               ,p_old_line_rec.ship_to_contact_id)
24191      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.deliver_to_org_id
24192                               ,p_old_line_rec.deliver_to_org_id)
24193      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.deliver_to_contact_id
24194                               ,p_old_line_rec.deliver_to_contact_id)
24195      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.user_item_description
24196                               ,p_old_line_rec.user_item_description)
24197     /* OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.cust_po_number
24198                               ,p_old_line_rec.cust_po_number)  	    --commented for ER 6072870
24199      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.customer_line_number
24200                               ,p_old_line_rec.customer_line_number)
24201      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.customer_shipment_number
24202                               ,p_old_line_rec.customer_shipment_number) */
24203      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.shipping_method_code
24204                               ,p_old_line_rec.shipping_method_code) THEN
24205 
24206      IF l_debug_level > 0 THEN
24207         OE_DEBUG_PUB.Add('Change in Reference Data Elements...', 2);
24208      END IF;
24209 
24210      l_ref_data_elem_changed   :=   'Y';
24211      l_ref_data_only := true;
24212 
24213   END IF;
24214 /* Added for ER 6072870*/
24215 
24216 if NOT OE_GLOBALS.EQUAL(p_x_line_rec.cust_po_number
24217                               ,p_old_line_rec.cust_po_number)
24218      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.customer_line_number
24219                               ,p_old_line_rec.customer_line_number)
24220      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.customer_shipment_number
24221                              ,p_old_line_rec.customer_shipment_number) THEN
24222     --{
24223 	IF l_debug_level > 0 THEN
24224 		OE_DEBUG_PUB.Add('Change in customer PO Reference Data Elements...', 2);
24225 	END IF;
24226 	l_ref_data_elem_changed   :=   'Y';
24227 	l_cust_po_attr_change:=true;
24228     --}
24229   end if;
24230 
24231   IF l_cust_po_attr_change THEN
24232   --{
24233    IF Nvl(p_x_line_rec.shipped_quantity,0)>0 THEN
24234    --{
24235     if l_debug_level > 0 then
24236          oe_debug_pub.add('Drop ship line is already received.So do not log CMS request', 1);
24237 	 l_log_cust_po_change:=FALSE;
24238     end if;
24239    --}
24240    ELSE
24241    --{
24242 	BEGIN
24243 		SELECT Count(1)
24244 		INTO l_rcv_count
24245 		FROM rcv_transactions rcv,
24246 		oe_drop_ship_sources odss,
24247 		po_line_locations_all pol
24248 		WHERE rcv.PO_LINE_ID=odss.po_line_id
24249 		AND pol.line_location_id=odss.line_location_id
24250 		AND odss.line_id=p_x_line_rec.line_id
24251 		AND RCV.PO_LINE_LOCATION_ID=pol.LINE_LOCATION_ID
24252 		AND TRANSACTION_TYPE='DELIVER'
24253 		AND Nvl(rcv.quantity,0)>0
24254 		AND INTERFACE_SOURCE_CODE='RCV'
24255 		AND SOURCE_DOCUMENT_CODE='PO';
24256 
24257 		if l_debug_level > 0 then
24258 		oe_debug_pub.add('line has been received either fully or partially do not log request', 1);
24259 		l_log_cust_po_change:=FALSE;
24260 		end if;
24261 
24262 	EXCEPTION
24263 	WHEN No_Data_Found THEN
24264 		if l_debug_level > 0 then
24265 		oe_debug_pub.add('line is not yet received can interface to PO', 1);
24266 		end if;
24267 	        l_log_cust_po_change:=TRUE;
24268         END;
24269    --}
24270    END IF;
24271   --}
24272   END IF;
24273 
24274  /* IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity2  - remove this as valid now for INVCONV
24275                               ,p_old_line_rec.ordered_quantity2) THEN
24276 
24277      FND_MESSAGE.Set_Name('ONT','ONT_DS_OPM_QTY_CHANGED');
24278      OE_MSG_PUB.Add;
24279 
24280      IF l_debug_level > 0 THEN
24281         OE_DEBUG_PUB.Add('Warning!! Secondary Qty Changed...', 2);
24282      END IF;
24283   END IF;
24284 
24285   IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity_uom2
24286                               ,p_old_line_rec.ordered_quantity_uom2) THEN
24287 
24288      FND_MESSAGE.Set_Name('ONT','ONT_DS_OPM_UOM_CHANGED');
24289      OE_MSG_PUB.Add;
24290 
24291      IF l_debug_level > 0 THEN
24292         OE_DEBUG_PUB.Add('Warning!! Secondary Qty UOM Changed...', 2);
24293      END IF;
24294   END IF;
24295 
24296   IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.preferred_grade
24297                               ,p_old_line_rec.preferred_grade) THEN
24298 
24299      FND_MESSAGE.Set_Name('ONT', 'ONT_DS_OPM_GRADE_CHANGED');
24300      OE_MSG_PUB.Add;
24301 
24302      IF l_debug_level > 0 THEN
24303         OE_DEBUG_PUB.Add('Warning!! OPM Grade Changed...', 2);
24304      END IF;
24305 
24306   END IF; */
24307 
24308 
24309   IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity
24310                              ,p_old_line_rec.ordered_quantity)
24311      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.order_quantity_uom
24312                               ,p_old_line_rec.order_quantity_uom)
24313      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity2
24314                               ,p_old_line_rec.ordered_quantity2)
24315      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity_uom2
24316                               ,p_old_line_rec.ordered_quantity_uom2)
24317      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.preferred_grade
24318                               ,p_old_line_rec.preferred_grade)
24319      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.schedule_ship_date
24320                               ,p_old_line_rec.schedule_ship_date)
24321      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_to_org_id
24322                               ,p_old_line_rec.ship_to_org_id)
24323      OR (l_ref_data_only )	 -- Added for ER 6072870
24324      OR (l_cust_po_attr_change and not l_ref_data_only and l_log_cust_po_change )
24325      OR p_x_line_rec.operation  ='DELETE'
24326 
24327      THEN
24328 
24329 
24330 
24331        IF (p_x_line_rec.ordered_quantity = 0 AND
24332              OE_SALES_CAN_UTIL.G_REQUIRE_REASON) OR
24333                    p_x_line_rec.operation = 'DELETE' THEN
24334           l_operation   :=  'CANCEL';
24335        END IF;
24336 
24337        IF l_debug_level >  0 THEN
24338         OE_DEBUG_PUB.Add('-----Logging Dropship_CMS_Request----for Entity:'||
24339                                                      p_x_line_rec.line_id, 2);
24340        END IF;
24341 
24342        OE_Delayed_Requests_Pvt.Log_Request
24343              (p_entity_code             =>   OE_GLOBALS.G_ENTITY_ALL
24344              ,p_entity_id               =>   p_x_line_rec.line_id
24345              ,p_requesting_entity_code  =>   OE_GLOBALS.G_ENTITY_LINE
24346              ,p_requesting_entity_id    =>   p_x_line_rec.line_id
24347              ,p_request_type            =>   OE_GLOBALS.G_DROPSHIP_CMS
24348              ,p_param1                  =>   p_old_line_rec.ordered_quantity
24349              ,p_param2                  =>   p_old_line_rec.order_quantity_uom
24350              ,p_param3                  =>   p_old_line_rec.ship_to_org_id
24351              ,p_param4                  =>   p_old_line_rec.ordered_quantity2
24352              ,p_param5                  =>   p_old_line_rec.ordered_quantity_uom2
24353              ,p_param6                  =>   p_old_line_rec.preferred_grade
24354   --         ,p_param7                  =>   p_old_line_rec.schedule_ship_date  --commented for bug#6918700
24355              ,p_param8                  =>   p_x_line_rec.ordered_quantity
24356              ,p_param9                  =>   p_x_line_rec.order_quantity_uom
24357              ,p_param10                 =>   p_x_line_rec.ship_to_org_id
24358              ,p_param11                 =>   p_x_line_rec.ordered_quantity2
24359              ,p_param12                 =>   p_x_line_rec.ordered_quantity_uom2
24360              ,p_param13                 =>   p_x_line_rec.preferred_grade
24361   --         ,p_param14                 =>   p_x_line_rec.schedule_ship_date    --commented for bug#6918700
24362              ,p_param15                 =>   l_operation
24363              ,p_param16                 =>   l_ref_data_elem_changed
24364 /*****Begin changes for bug#6918700*********/
24365 	     ,p_date_param1             =>   p_old_line_rec.schedule_ship_date
24366 	     ,p_date_param2             =>   p_x_line_rec.schedule_ship_date
24367 /*****End changes for bug#6918700*********/
24368              ,x_return_status           =>   l_return_status
24369             );
24370 
24371 END IF;
24372 
24373      IF l_debug_level >  0 THEN
24374         OE_DEBUG_PUB.Add('After Logging CMS_Request...'||l_return_status, 2);
24375      END IF;
24376 
24377      IF l_return_status <>  FND_API.G_RET_STS_SUCCESS THEN
24378         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
24379      END IF;
24380 
24381      IF l_debug_level >  0 THEN
24382         OE_DEBUG_PUB.Add('Exiting Log_Dropship_CMS_Request...', 2);
24383      END IF;
24384 
24385 
24386 EXCEPTION
24387 
24388     WHEN  FND_API.G_EXC_ERROR THEN
24389        IF l_debug_level >  0 THEN
24390           OE_DEBUG_PUB.Add('Execution Error in Log_Dropship_CMS_Request', 2);
24391        END IF;
24392        RAISE FND_API.G_EXC_ERROR;
24393 
24394     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
24395        IF l_debug_level >  0 THEN
24396           OE_DEBUG_PUB.Add('Unexpected Error in Log_Dropship_CMS_Request'||
24397                                  sqlerrm, 1);
24398        END IF;
24399        RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
24400 
24401     WHEN OTHERS THEN
24402 
24403       IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
24404       THEN
24405         OE_MSG_PUB.Add_Exc_Msg
24406         (   G_PKG_NAME,
24407           'Log_Dropship_CMS_Request');
24408       END IF;
24409 
24410 END Log_Dropship_CMS_Request;
24411 
24412 
24413 -- Added new API (HANDLE_RFR proc) for FP bug 6628653 base bug 6513023
24414 PROCEDURE HANDLE_RFR
24415 (
24416 p_line_id            IN NUMBER,
24417 p_top_model_line_id  IN NUMBER,
24418 p_link_to_line_id     IN NUMBER
24419 )
24420 IS
24421    l_is_rfr          NUMBER;
24422    l_open_rfr_lines  NUMBER;
24423    l_activity_status_code  VARCHAR2(30);
24424    l_result_out      VARCHAR2(30);
24425    l_return_status   VARCHAR2(30);
24426    l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
24427 
24428 BEGIN
24429    IF l_debug_level > 0 THEN
24430       oe_debug_pub.add('Entering HANDLE_RFR ... ', 1);
24431       oe_debug_pub.add(' with p_line_id  '|| p_line_id , 1);
24432       oe_debug_pub.add(' with p_top_model_line_id  '|| p_top_model_line_id , 1);
24433       oe_debug_pub.add(' with p_link_to_line_id  '|| p_link_to_line_id , 1);
24434    END IF;
24435 
24436        SELECT nvl(bic.required_for_revenue, 0)
24437        INTO   l_is_rfr
24438        FROM   oe_order_lines Line,
24439               bom_inventory_components bic
24440        WHERE  Line.line_id = p_line_id
24441        AND    Line.open_flag = 'N'
24442        AND    bic.component_sequence_id = Line.component_sequence_id
24443        AND    bic.component_item_id = Line.inventory_item_id;
24444 
24445        IF l_is_rfr = 1 THEN
24446           IF l_debug_level > 0 THEN
24447              oe_debug_pub.add('Component being cancelled is marked as RFR, checking if any other RFR Lines are open', 5);
24448           END IF;
24449 
24450           SELECT count(1)
24451           INTO   l_open_rfr_lines
24452           FROM   oe_order_lines Line,
24453                  bom_inventory_components bic
24454           WHERE  Line.line_id <> p_line_id
24455           AND    Line.top_model_line_id = p_top_model_line_id
24456           AND    Line.link_to_line_id = p_link_to_line_id
24457           AND    Line.open_flag = 'Y'
24458           AND    bic.component_sequence_id = Line.component_sequence_id
24459           AND    bic.component_item_id = Line.inventory_item_id
24460           AND    bic.required_for_revenue = 1;
24461 
24462           IF l_open_rfr_lines = 0 THEN
24463 
24464              IF l_debug_level > 0 THEN
24465                 oe_debug_pub.add('No more pending RFR lines under current parent, checking status of Parent Line', 5);
24466              END IF;
24467 
24468              BEGIN
24469                 SELECT ACTIVITY_STATUS
24470                 INTO   l_activity_status_code
24471                 FROM   wf_item_activity_statuses wias,
24472                        wf_process_activities wpa
24473                 WHERE  wias.item_type = 'OEOL'
24474                 AND    wias.item_key  = to_char(p_link_to_line_id)
24475                 AND    wias.process_activity = wpa.instance_id
24476                 AND    wpa.activity_item_type = 'OEOL'
24477                 AND    wpa.activity_name = 'INVOICING_WAIT_FOR_RFR'
24478                 AND    wias.activity_status = 'NOTIFIED';
24479 
24480                 EXCEPTION
24481                 WHEN OTHERS THEN
24482                    l_activity_status_code := null;
24483                    oe_debug_pub.add(' in exception block -  '||SQLERRM, 5);
24484              END;
24485 
24486              IF l_activity_status_code = 'NOTIFIED' THEN
24487                 IF l_debug_level > 0 THEN
24488                    oe_debug_pub.add('Parent Line waiting to be invoiced, calling API to Invoice Parent ', 5);
24489                 END IF;
24490 
24491                OE_Invoice_PUB.Interface_Line(  p_link_to_line_id
24492                                               ,OE_GLOBALS.G_WFI_LIN
24493                                               ,l_result_out
24494                                               ,l_return_status);
24495 
24496                 IF l_debug_level  > 0 THEN
24497                     oe_debug_pub.add(  ' after call to invoice api:   l_result_out: '||l_result_out ) ;
24498                     oe_debug_pub.add(  ' after call to invoice api:   l_return_status: '|| l_return_status ) ;
24499                 END IF;
24500 
24501                 /*
24502                   Need to check only l_return_status. If SUCCESS, do COMPLETE with default transition
24503                 */
24504                 IF l_return_status = FND_API.G_RET_STS_SUCCESS  THEN
24505                     IF l_debug_level  > 0 THEN
24506                          oe_debug_pub.add(  'Updating Line Flow Status and pushing WF ');
24507                     END IF;
24508                     Update oe_order_lines
24509                     Set flow_status_code = 'INVOICED'
24510                     Where line_id = p_link_to_line_id;
24511 
24512                     BEGIN
24513                         WF_ENGINE.CompleteActivityInternalName(OE_GLOBALS.G_WFI_LIN, p_link_to_line_id, 'INVOICING_WAIT_FOR_RFR', null);
24514                     EXCEPTION
24515                         WHEN OTHERS THEN
24516                            oe_debug_pub.add(' Error in completing activity; SQL Message -  '||SQLERRM, 5);
24517                     END;
24518                 ELSE
24519                    oe_debug_pub.add(' l_return_status is not equal to Success, do nothing  ', 5);
24520                 END IF; --checking l_return_status
24521 
24522              ELSE
24523                 IF l_debug_level > 0 THEN
24524                    oe_debug_pub.add('Parent Line is not waiting to be Invoiced, do nothing', 5);
24525                 END IF;
24526              END IF; -- activity_status=NOTIFIED
24527           ELSE
24528              IF l_debug_level > 0 THEN
24529                 oe_debug_pub.add('Other RFR lines are still open, no need to Invoice Parent Line', 5);
24530              END IF;
24531           END IF; -- IF l_open_rfr_lines ...
24532        ELSE
24533           IF l_debug_level > 0 THEN
24534             oe_debug_pub.add('Current line being cancelled is not RFR', 5);
24535           END IF;
24536        END IF; -- IF l_is_rfr ...
24537 
24538 
24539       IF l_debug_level > 0 THEN
24540           oe_debug_pub.add('Exiting HANDLE_RFR ...', 1);
24541       END IF;
24542 
24543 END HANDLE_RFR;
24544 
24545 
24546 --ER7675548
24547 Procedure Get_customer_info_ids
24548 ( p_line_customer_info_tbl IN OUT NOCOPY OE_Order_Pub.CUSTOMER_INFO_TABLE_TYPE,
24549   p_x_line_tbl       IN OUT NOCOPY OE_Order_Pub.Line_Tbl_Type,
24550   x_return_status OUT NOCOPY VARCHAR2,
24551   x_msg_count    OUT NOCOPY NUMBER,
24552   x_msg_data    OUT NOCOPY VARCHAR2
24553 ) IS
24554 
24555 x_sold_to_customer_id   NUMBER;
24556 x_ship_to_customer_id   NUMBER;
24557 x_bill_to_customer_id   NUMBER;
24558 x_deliver_to_customer_id  NUMBER;
24559 
24560 x_ship_to_org_id NUMBER;
24561 x_invoice_to_org_id NUMBER;
24562 x_deliver_to_org_id NUMBER;
24563 x_sold_to_site_use_id NUMBER;
24564 
24565 x_sold_to_contact_id  NUMBER;
24566 x_ship_to_contact_id  NUMBER;
24567 x_invoice_to_contact_id   NUMBER;
24568 x_deliver_to_contact_id   NUMBER;
24569 
24570 l_index NUMBER;
24571 l_sold_to_org_id NUMBER;
24572 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
24573 BEGIN
24574 
24575 x_return_status := FND_API.G_RET_STS_SUCCESS;
24576 
24577 IF l_debug_level >0 then
24578 	oe_debug_pub.add('Entering OE_LINE_UTIL.Get_customer_info_ids :'||p_line_customer_info_tbl.count);
24579 End IF;
24580 
24581     IF p_line_customer_info_tbl.count = 0 THEN
24582 	x_return_status := FND_API.G_RET_STS_SUCCESS;
24583 	RETURN;
24584     END IF;
24585 
24586     l_index := p_x_line_tbl.FIRST;
24587 
24588     WHILE l_index IS NOT NULL LOOP
24589 
24590 	OE_MSG_PUB.set_msg_context
24591         ( p_entity_code                 => 'LINE'
24592          ,p_entity_id                   => p_x_line_tbl(l_index).line_id
24593          ,p_header_id                   => p_x_line_tbl(l_index).header_id
24594          ,p_line_id                     => p_x_line_tbl(l_index).line_id
24595          ,p_orig_sys_document_ref       => p_x_line_tbl(l_index).orig_sys_document_ref
24596          ,p_orig_sys_document_line_ref  => p_x_line_tbl(l_index).orig_sys_line_ref
24597          ,p_orig_sys_shipment_ref       => p_x_line_tbl(l_index).orig_sys_shipment_ref
24598          ,p_change_sequence             => p_x_line_tbl(l_index).change_sequence
24599          ,p_source_document_id          => p_x_line_tbl(l_index).source_document_id
24600          ,p_source_document_line_id     => p_x_line_tbl(l_index).source_document_line_id
24601          ,p_order_source_id             => p_x_line_tbl(l_index).order_source_id
24602          ,p_source_document_type_id     => p_x_line_tbl(l_index).source_document_type_id);
24603 
24604 
24605 	 /* Below code is necessary to pass a value for the sold_to_org_id as value to id
24606 	    routines expects it */
24607 
24608 	 IF p_x_line_tbl(l_index).operation = OE_GLOBALS.G_OPR_UPDATE
24609 	     AND p_x_line_tbl(l_index).sold_to_org_id = FND_API.G_MISS_NUM THEN
24610 
24611 		l_sold_to_org_id := p_x_line_tbl(l_index).sold_to_org_id;
24612 
24613 		BEGIN
24614 			select NVL(sold_to_org_id,p_x_line_tbl(l_index).sold_to_org_id)
24615 			into   l_sold_to_org_id
24616 			from oe_order_lines_all
24617 			where line_id = p_x_line_tbl(l_index).line_id;
24618 
24619 		EXCEPTION
24620 			WHEN OTHERS THEN
24621 			NULL;
24622 		END;
24623 
24624 	  ELSIF p_x_line_tbl(l_index).operation = OE_GLOBALS.G_OPR_CREATE
24625 	        AND p_x_line_tbl(l_index).sold_to_org_id = FND_API.G_MISS_NUM THEN
24626 
24627 		IF OE_CUSTOMER_INFO_PVT.G_SOLD_TO_CUSTOMER_ID IS NOT NULL THEN
24628 			l_sold_to_org_id := OE_CUSTOMER_INFO_PVT.G_SOLD_TO_CUSTOMER_ID;
24629 		ELSE
24630 			l_sold_to_org_id := p_x_line_tbl(l_index).sold_to_org_id;
24631 		END IF;
24632 
24633 	  END IF;
24634 
24635 	  OE_CUSTOMER_INFO_PVT.get_customer_info_ids (
24636                           p_customer_info_tbl  => p_line_customer_info_tbl,
24637 		          p_operation_code     => p_x_line_tbl(l_index).operation,
24638 			  p_sold_to_customer_ref => p_x_line_tbl(l_index).sold_to_customer_ref,
24639 			  p_ship_to_customer_ref => p_x_line_tbl(l_index).ship_to_customer_ref,
24640 			  p_bill_to_customer_ref => p_x_line_tbl(l_index).invoice_to_customer_ref,
24641 			  p_deliver_to_customer_ref => p_x_line_tbl(l_index).deliver_to_customer_ref,
24642 
24643 			  p_ship_to_address_ref => p_x_line_tbl(l_index).ship_to_address_ref,
24644 			  p_bill_to_address_ref => p_x_line_tbl(l_index).invoice_to_address_ref,
24645 			  p_deliver_to_address_ref => p_x_line_tbl(l_index).deliver_to_address_ref,
24646 			  p_sold_to_address_ref => NULL, --Attribute not avaiable at line level
24647 
24648 			  p_sold_to_contact_ref => NULL,  --Attribute not avaiable at line level
24649 			  p_ship_to_contact_ref => p_x_line_tbl(l_index).ship_to_contact_ref,
24650 			  p_bill_to_contact_ref => p_x_line_tbl(l_index).invoice_to_contact_ref,
24651 			  p_deliver_to_contact_ref => p_x_line_tbl(l_index).deliver_to_contact_ref,
24652 
24653 			  p_sold_to_customer_id => l_sold_to_org_id,
24654 			  p_ship_to_customer_id => p_x_line_tbl(l_index).ship_to_customer_id,
24655 			  p_bill_to_customer_id  => p_x_line_tbl(l_index).invoice_to_customer_id,
24656 			  p_deliver_to_customer_id  => p_x_line_tbl(l_index).deliver_to_customer_id,
24657 
24658 			  p_ship_to_org_id     => p_x_line_tbl(l_index).ship_to_org_id,
24659 			  p_invoice_to_org_id  => p_x_line_tbl(l_index).invoice_to_org_id,
24660 			  p_deliver_to_org_id  => p_x_line_tbl(l_index).deliver_to_org_id,
24661 			  p_sold_to_site_use_id => NULL,  --Attribute not avaiable at line level
24662 
24663 			  p_sold_to_contact_id  => OE_CUSTOMER_INFO_PVT.G_SOLD_TO_CONTACT_ID,
24664 			  p_ship_to_contact_id  => p_x_line_tbl(l_index).ship_to_contact_id,
24665 			  p_invoice_to_contact_id => p_x_line_tbl(l_index).invoice_to_contact_id,
24666 			  p_deliver_to_contact_id => p_x_line_tbl(l_index).deliver_to_contact_id,
24667 
24668 
24669 			  x_sold_to_customer_id => x_sold_to_customer_id,
24670 			  x_ship_to_customer_id => x_ship_to_customer_id,
24671 			  x_bill_to_customer_id => x_bill_to_customer_id,
24672 			  x_deliver_to_customer_id => x_deliver_to_customer_id,
24673 
24674 
24675 			  x_ship_to_org_id => x_ship_to_org_id,
24676 			  x_invoice_to_org_id => x_invoice_to_org_id,
24677 			  x_deliver_to_org_id => x_deliver_to_org_id,
24678 			  x_sold_to_site_use_id => x_sold_to_site_use_id,
24679 
24680 			  x_sold_to_contact_id => x_sold_to_contact_id,
24681 			  x_ship_to_contact_id => x_ship_to_contact_id,
24682 			  x_invoice_to_contact_id => x_invoice_to_contact_id,
24683 			  x_deliver_to_contact_id => x_deliver_to_contact_id ,
24684 
24685 
24686 			  x_return_status   => x_return_status,
24687 			  x_msg_count       => x_msg_count,
24688 			  x_msg_data        => x_msg_data
24689 
24690 			 );
24691 
24692 p_x_line_tbl(l_index).sold_to_org_id := x_sold_to_customer_id;
24693 p_x_line_tbl(l_index).ship_to_customer_id := x_ship_to_customer_id;
24694 p_x_line_tbl(l_index).invoice_to_customer_id := x_bill_to_customer_id;
24695 p_x_line_tbl(l_index).deliver_to_customer_id := x_deliver_to_customer_id;
24696 
24697 p_x_line_tbl(l_index).ship_to_org_id := x_ship_to_org_id;
24698 p_x_line_tbl(l_index).invoice_to_org_id := x_invoice_to_org_id;
24699 p_x_line_tbl(l_index).deliver_to_org_id := x_deliver_to_org_id;
24700 
24701 
24702 p_x_line_tbl(l_index).ship_to_contact_id := x_ship_to_contact_id;
24703 p_x_line_tbl(l_index).invoice_to_contact_id := x_invoice_to_contact_id;
24704 p_x_line_tbl(l_index).deliver_to_contact_id := x_deliver_to_contact_id;
24705 
24706 IF l_debug_level > 0 THEN
24707 	oe_debug_pub.add('p_x_line_tbl('||l_index||').sold_to_org_id :'||p_x_line_tbl(l_index).sold_to_org_id);
24708 	oe_debug_pub.add('p_x_line_tbl('||l_index||').ship_to_customer_id :'||p_x_line_tbl(l_index).ship_to_customer_id);
24709 	oe_debug_pub.add('p_x_line_tbl('||l_index||').invoice_to_customer_id :'||p_x_line_tbl(l_index).invoice_to_customer_id);
24710 	oe_debug_pub.add('p_x_line_tbl('||l_index||').deliver_to_customer_id :'||p_x_line_tbl(l_index).deliver_to_customer_id);
24711 
24712 	oe_debug_pub.add('p_x_line_tbl('||l_index||').ship_to_org_id :'||p_x_line_tbl(l_index).ship_to_org_id);
24713 	oe_debug_pub.add('p_x_line_tbl('||l_index||').invoice_to_org_id :'||p_x_line_tbl(l_index).invoice_to_org_id);
24714 	oe_debug_pub.add('p_x_line_tbl('||l_index||').deliver_to_org_id :'||p_x_line_tbl(l_index).deliver_to_org_id);
24715 
24716 	oe_debug_pub.add('p_x_line_tbl('||l_index||').ship_to_contact_id :'||p_x_line_tbl(l_index).ship_to_contact_id);
24717 	oe_debug_pub.add('p_x_line_tbl('||l_index||').invoice_to_contact_id :'||p_x_line_tbl(l_index).invoice_to_contact_id);
24718 	oe_debug_pub.add('p_x_line_tbl('||l_index||').deliver_to_contact_id :'||p_x_line_tbl(l_index).deliver_to_contact_id);
24719 
24720 END IF;
24721 
24722 
24723 	IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
24724 	        OE_MSG_PUB.reset_msg_context('LINE');
24725 		RETURN;
24726         END IF;
24727 
24728         l_index := p_x_line_tbl.NEXT(l_index);
24729 
24730         OE_MSG_PUB.reset_msg_context('LINE');
24731 
24732 END LOOP;
24733 
24734 OE_CUSTOMER_INFO_PVT.G_SOLD_TO_CUSTOMER_ID := NULL;
24735 
24736 IF l_debug_level >0 then
24737 	oe_debug_pub.add('Entering OE_LINE_UTIL.Get_customer_info_ids :'||p_line_customer_info_tbl.count);
24738 End IF;
24739 
24740 
24741 
24742 EXCEPTION
24743 	WHEN OTHERS THEN
24744 	x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
24745 
24746         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
24747         THEN
24748             OE_MSG_PUB.Add_Exc_Msg
24749             (   G_PKG_NAME
24750             ,   'Get_customer_info_ids'
24751             );
24752         END IF;
24753 
24754 END Get_customer_info_ids;
24755 --ER7675548
24756 
24757 -- Added new API for 12355310
24758 FUNCTION Shipping_Interfaced_Status
24759 (
24760 p_line_id NUMBER
24761 ) RETURN VARCHAR2
24762 IS
24763 l_delivery_detail_count NUMBER;
24764 
24765 BEGIN
24766 
24767     SELECT count(1)
24768     INTO   l_delivery_detail_count
24769     FROM   wsh_delivery_details
24770     WHERE  source_code = 'OE'
24771     AND    source_line_id = p_line_id
24772     AND    released_status NOT IN ('C','D');
24773 
24774     IF l_delivery_detail_count > 0 THEN
24775         RETURN 'Y';
24776     ELSE
24777         RETURN 'N';
24778     END IF;
24779 
24780 END Shipping_Interfaced_Status;
24781 
24782 -- sol_ord_er #16014165 start
24783 /*---------------------------------------------
24784 Function : Is_Subscription_Service_Line
24785 ---------------------------------------------*/
24786 Function Is_Subscription_Service_Line (p_line_id IN NUMBER)
24787 RETURN BOOLEAN
24788 IS
24789 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
24790 l_subscription_enable_flag varchar2(10) := '';
24791 BEGIN
24792 	If l_debug_level > 0 THEN
24793 		oe_debug_pub.add('Entering Is_Subscription_Service_Line p_line_id = '||p_line_id);
24794 	End If;
24795 	select subscription_enable_flag
24796 	  into l_subscription_enable_flag
24797 	  from oe_order_lines_all
24798 	 where line_id = p_line_id;
24799 	If NVL(l_subscription_enable_flag,'N') = 'Y' THEN
24800 		-- Subscription Servcie Line
24801 		If l_debug_level > 0 THEN
24802 			oe_debug_pub.add('.. Is_Subscription_Service_Line TRUE ..',5);
24803 		End If;
24804 		RETURN TRUE;
24805 	Else
24806 		-- Not Subscription Service
24807 		If l_debug_level > 0 THEN
24808 			oe_debug_pub.add('.. Is_Subscription_Service_Line FALSE ..',5);
24809 		End If;
24810 		RETURN FALSE;
24811 	End If;
24812 EXCEPTION
24813 WHEN NO_DATA_FOUND THEN
24814    oe_debug_pub.ADD('In NO DATA FOUND of Is_Subscription_Service_Line',1);
24815     RETURN FALSE;
24816 END Is_Subscription_Service_Line;
24817 -- sol_ord_er #16014165 end
24818 
24819 -- Bug 16317238 start
24820 PROCEDURE copy_assoc(p_line_id IN NUMBER,
24821                      px_org_pr_adjustment_id OUT NOCOPY NUMBER,
24822                      px_or_rltd_padj_id      OUT NOCOPY NUMBER,
24823                      px_prg_list_line_id     OUT NOCOPY NUMBER,
24824                      px_assoc_list_line_id   OUT NOCOPY NUMBER,
24825                      px_prg_exist    OUT NOCOPY VARCHAR2)
24826 IS
24827 
24828 l_orig_pr_adjustment_id   NUMBER;
24829 l_or_rltd_padj_id        NUMBER;
24830 l_prg_list_line_id       NUMBER;
24831 l_assoc_list_line_id     NUMBER;
24832 BEGIN
24833 
24834 SELECT a.price_adjustment_id,a.rltd_price_adj_id,prg.list_line_id,p.list_line_id
24835     INTO l_orig_pr_adjustment_id,l_or_rltd_padj_id,l_prg_list_line_id,l_assoc_list_line_id
24836 FROM oe_price_adj_assocs a,
24837      oe_price_adjustments p,
24838      oe_order_lines_all l,
24839      oe_price_adjustments prg
24840  WHERE l.line_id = p.line_id AND p.price_adjustment_id = a.rltd_price_adj_id
24841  AND   l.item_type_code = 'SERVICE' AND l.SUBSCRIPTION_ENABLE_FLAG <> 'Y'
24842  AND l.line_id = p_line_id AND  prg.price_adjustment_id = a.price_adjustment_id
24843  AND prg.list_line_type_code = 'PRG'
24844  AND ROWNUM <2;
24845 
24846     oe_debug_pub.ADD('price_adjustment id of the original prg line '||l_orig_pr_adjustment_id,1);
24847     oe_debug_pub.ADD('rltd price_adjustment id of the original prg line '||l_or_rltd_padj_id,1);
24848     oe_debug_pub.ADD('list line id of the original prg line '||l_prg_list_line_id,1);
24849     oe_debug_pub.ADD('list line id of the assoc list line '||l_assoc_list_line_id,1);
24850 
24851 px_org_pr_adjustment_id := l_orig_pr_adjustment_id;
24852 px_or_rltd_padj_id    := l_or_rltd_padj_id;
24853 px_prg_list_line_id   := l_prg_list_line_id;
24854 px_assoc_list_line_id  := l_assoc_list_line_id;
24855 
24856 px_prg_exist := 'Y';
24857 
24858 
24859     oe_debug_pub.ADD('Dis is associated',1);
24860 
24861 
24862 EXCEPTION
24863 WHEN NO_DATA_FOUND THEN
24864    oe_debug_pub.ADD('In NO DATA FOUND of copy_assoc',1);
24865     px_prg_exist := 'N';
24866 
24867 END  copy_assoc;
24868 --bug 16317238 end
24869 
24870 END oe_line_util;