DBA Data[Home] [Help]

PACKAGE BODY: APPS.OE_LINE_UTIL

Source


1 PACKAGE BODY OE_LINE_UTIL AS
2 /* $Header: OEXULINB.pls 120.67.12010000.20 2008/12/26 07:37:31 vbkapoor 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 
11 -- Added new API for FP bug 6628653 base bug 6513023
12 PROCEDURE HANDLE_RFR
13 (
14 p_line_id            IN NUMBER,
15 p_top_model_line_id  IN NUMBER,
16 p_link_to_line_id     IN NUMBER
17 );
18 
19 --  Procedure Clear_Dependent_Attr: Moved to OE_LINE_UTIL_EXT (OEXULXTS/B.pls)
20 
21 -- Added 09-DEC-2002
22 -- Forward declaration of LOCAL PROCEDURE Log_Blanket_Request
23 PROCEDURE Log_Blanket_Request
24 (   p_x_line_rec      IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
25 ,   p_old_line_rec    IN OE_Order_PUB.Line_Rec_Type
26 );
27 
28 Procedure Log_Dropship_CMS_Request
29 ( p_x_line_rec            IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
30 , p_old_line_rec          IN OE_Order_PUB.Line_Rec_Type
31 );
32 
33 PROCEDURE get_customer_details
34 (   p_org_id                IN  NUMBER
35 ,   p_site_use_code         IN  VARCHAR2
36 ,   x_customer_name         OUT NOCOPY /* file.sql.39 change */ VARCHAR2
37 ,   x_customer_number       OUT NOCOPY /* file.sql.39 change */ VARCHAR2
38 ,   x_customer_id           OUT NOCOPY /* file.sql.39 change */ NUMBER
39 ,   x_location              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
40 ,   x_address1              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
41 ,   x_address2              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
42 ,   x_address3              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
43 ,   x_address4              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
44 ,   x_city                  OUT NOCOPY /* file.sql.39 change */ VARCHAR2
45 ,   x_state                 OUT NOCOPY /* file.sql.39 change */ VARCHAR2
46 ,   x_zip                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
47 ,   x_country               OUT NOCOPY /* file.sql.39 change */ VARCHAR2);
48 
49 ------------------------------------------------------------
50 PROCEDURE Log_CTO_Requests
51 (p_x_line_rec    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
52 ,p_old_line_rec  IN             OE_Order_PUB.Line_Rec_Type :=
53                                    OE_Order_PUB.G_MISS_LINE_REC
54 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2);
55 
56 PROCEDURE Log_Config_Requests
57 (p_x_line_rec    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
58 ,p_old_line_rec  IN             OE_Order_PUB.Line_Rec_Type :=
59                                    OE_Order_PUB.G_MISS_LINE_REC
60 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2);
61 
62 PROCEDURE Log_Cascade_Requests
63 (p_x_line_rec    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
64 ,p_old_line_rec  IN             OE_Order_PUB.Line_Rec_Type :=
65                                    OE_Order_PUB.G_MISS_LINE_REC
66 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2);
67 --------------------------------------------------------------
68 
69 
70 /*----------------------------------------------------------
71 Procedure Delete_Dependents
72 Delete dependents call out for line.
73 Keep your dependenceis on line here
74 bug fix 2127356: log update_shipping req here.
75 bug fix 2670775: Reverse Limits here.
76 -----------------------------------------------------------*/
77 
78 Procedure Delete_Dependents
79 ( p_line_id                  IN NUMBER
80  ,p_item_type_code           IN VARCHAR2
81  ,p_line_category_code       IN VARCHAR2
82  ,p_config_header_id         IN NUMBER
83  ,p_config_rev_nbr           IN NUMBER
84  ,p_schedule_status_code     IN VARCHAR2
85  ,p_shipping_interfaced_flag IN VARCHAR2
86  ,p_ordered_quantity         IN NUMBER         -- BUG 2670775 Reverse Limits
87  ,p_price_request_code       IN VARCHAR2       -- BUG 2670775 Reverse Limits
88  ,p_transaction_phase_code   IN VARCHAR2 default null       -- Bug 3315331
89 )IS
90 l_return_status varchar2(30);
91 l_set_tbl_count number;
92 l_header_id	number;
93 
94 l_debug_level  CONSTANT NUMBER := oe_debug_pub.g_debug_level;
95 l_delete_lines_tbl           OE_ORDER_PUB.Request_Tbl_Type; -- For bug 3754586
96 BEGIN
97   if l_debug_level > 0 then
98    oe_debug_pub.add('Entering in Delete Dependents');
99   end if;
100    /* set the set type in g_set_tbl to invalid if the line is being deleted */
101 
102 
103    IF  OE_SET_UTIL.g_set_tbl.count > 0 THEN
104 
105      if l_debug_level > 0 then
106        oe_debug_pub.add('Table Count : '||OE_SET_UTIL.g_set_tbl.count,3);
107      end if;
108 
109        l_set_tbl_count := OE_SET_UTIL.g_set_tbl.first;
110        WHILE l_set_tbl_count IS NOT NULL
111        LOOP
112 
113            IF  OE_SET_UTIL.g_set_tbl(l_set_tbl_count).line_id = p_line_id THEN
114 
115                OE_SET_UTIL.g_set_tbl(l_set_tbl_count).set_type := 'INVALID_SET';
116 
117              if l_debug_level > 0 then
118                oe_debug_pub.add('Set the set type as invalid ',3);
119              end if;
120            END IF;
121 
122            l_set_tbl_count := OE_SET_UTIL.g_set_tbl.next(l_set_tbl_count);
123 
124        END LOOP;
125 
126    END IF;
127 
128     OE_Atchmt_Util.Delete_Attachments
129                ( p_entity_code	=> OE_GLOBALS.G_ENTITY_LINE
130                , p_entity_id      	=> p_line_id
131                , x_return_status   => l_return_status
132                );
133     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
134           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
135     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
136           RAISE FND_API.G_EXC_ERROR;
137     END IF;
138 
139     -- BUG 2670775 Reverse Limits Begin
140     OE_DELAYED_REQUESTS_UTIL.REVERSE_LIMITS
141               ( x_return_status           => l_return_status
142               , p_action_code             => 'CANCEL'
143               , p_cons_price_request_code => p_price_request_code
144               , p_orig_ordered_qty        => p_ordered_quantity
145               , p_amended_qty             => NULL
146               , p_ret_price_request_code  => NULL
147               , p_returned_qty            => NULL
148               , p_line_id                 => p_line_id
149               );
150 
151     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
152           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
153     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
154           RAISE FND_API.G_EXC_ERROR;
155     END IF;
156     -- BUG 2670775 Reverse Limits End
157 
158     -- Scheduling restructure.
159     IF p_schedule_status_code IS NOT NULL
160     AND p_item_type_code <> OE_GLOBALS.G_ITEM_CONFIG THEN
161 
162       --4504362: Branch scheduling checs removed
163        OE_SCHEDULE_UTIL.Delete_row(p_line_id => p_line_id);
164 
165 
166     END IF;
167 
168     OE_Line_Adj_Util.delete_row(p_line_id => p_line_id);
169     OE_Line_PAttr_Util.delete_row(p_line_id => p_line_id);
170     OE_Line_Scredit_Util.delete_row(p_line_id => p_line_id);
171     OE_Lot_Serial_Util.delete_row(p_line_id => p_line_id);
172     -- Bug 3315531
173     -- Do not call WF delete for lines in negotiation phase as
174     -- line workflows are only started when order is in fulfillment phase.
175     IF nvl(p_transaction_phase_code,'F') = 'F' THEN
176        OE_Order_WF_Util.delete_row(p_type => 'LINE', p_id => p_line_id);
177     END IF;
178     OE_Holds_PUB.Delete_Holds(p_line_id => p_line_id );
179 
180     -- 1829201, commitment related changes.
181     -- OE_Payments_Util.delete_row(p_line_id => p_line_id);
182 
183     begin
184       select header_id
185       into   l_header_id
186       from   oe_order_lines_all
187       where  line_id = p_line_id;
188     exception when no_data_found then
189       null;
190     end;
191 
192     OE_Line_Payment_Util.delete_row
193                         (p_line_id => p_line_id
194                         ,p_header_id => l_header_id
195                         );
196 
197     oe_line_fullfill.cancel_line(p_line_id => p_line_id,
198 						  x_return_status => l_return_status);
199 
200     if l_return_status <> FND_API.G_RET_STS_SUCCESS then
201 
202 	 if l_return_status = FND_API.G_RET_STS_ERROR then
203 
204 	    raise FND_API.G_EXC_ERROR;
205       else
206 
207 	    raise FND_API.G_EXC_UNEXPECTED_ERROR;
208 	 end if;
209 
210     end if;
211 
212     OE_Set_Util.Remove_From_Fulfillment(p_line_id => p_line_id);
213 
214   /* Log and Execute the delayed request logged for update shipping
215        as they will get deleted in the next step */
216   if l_debug_level > 0 then
217    oe_debug_pub.ADD('p_shipping_interfaced_flag '|| p_shipping_interfaced_flag,1);
218   end if;
219 
220    IF	p_shipping_interfaced_flag = 'Y' THEN
221 
222     if l_debug_level > 0 then
223      oe_debug_pub.ADD('Update Shipping,Delete '|| p_line_id,1);
224     end if;
225 
226    /*
227    The code for logging and processing the delayed request for update shipping
228    was removed for bug 3754586 , instead we call update_shipping_from_oe
229    This was done for the following reason :
230    In case of multiple lines call to process order with some lines getting
231    deleted and others getting updated, we see that WSHcheck scripts api is called
232    even for DELETE case at the time of delayes request execution whereas we want
233    the call to be made at actually databse delete in delete_row api.
234    */
235    -- Preparing the table for calling Update_Shipping_From_OE for the deleted line
236 
237      l_delete_lines_tbl(1).entity_code            := OE_GLOBALS.G_ENTITY_LINE;
238      l_delete_lines_tbl(1).entity_id              := p_line_id;
239      l_delete_lines_tbl(1).param1                 := FND_API.G_TRUE;
240      l_delete_lines_tbl(1).param2                 := FND_API.G_FALSE;
241      l_delete_lines_tbl(1).request_unique_key1    := OE_GLOBALS.G_OPR_DELETE;
242 
243      OE_Shipping_Integration_PVT.Update_Shipping_From_OE
244         (p_update_lines_tbl      =>      l_delete_lines_tbl,
245          x_return_status         =>      l_return_status
246         );
247 
248    END IF;-- shipping interfaced = 'Y'
249    -- changes for bug 3754586 ends
250 
251      if l_debug_level > 0 then
252       oe_debug_pub.add('ret sts: '|| l_return_status, 4);
253      end if;
254 
255       IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
256 
257           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
258       ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
259           RAISE FND_API.G_EXC_ERROR;
260       END IF;
261 
262     OE_Delayed_Requests_Pvt.Delete_Reqs_for_deleted_entity(
263         p_entity_code  => OE_GLOBALS.G_ENTITY_LINE,
264         p_delete_against => FALSE, -- bug 5114189
265         p_entity_id     => p_line_id,
266         x_return_status => l_return_status
267         );
268 
269 
270 
271 EXCEPTION
272     WHEN NO_DATA_FOUND THEN
273 				NULL;
274     WHEN FND_API.G_EXC_ERROR THEN
275           RAISE FND_API.G_EXC_ERROR;
276     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
277           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
278     WHEN OTHERS THEN
279         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
280         THEN
281             OE_MSG_PUB.Add_Exc_Msg
282             (   G_PKG_NAME
283             ,   'Delete_Dependents'
284             );
285         END IF;
286         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
287 END Delete_Dependents;
288 
289 
290 Procedure Calc_Catchweight_Return_qty2
291 ( p_x_line_rec IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type
292 ,  p_old_line_rec                  IN  OE_Order_PUB.Line_Rec_Type) IS
293 x_item_rec  OE_ORDER_CACHE.item_rec_type;
294 l_debug_level  CONSTANT NUMBER := oe_debug_pub.g_debug_level;
295 
296 BEGIN
297    If l_debug_level > 0 Then
298       oe_debug_pub.add('Entering into Calc_Catchweight_Return_qty2',1);
299       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);
300       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);
301    End If;
302 
303    IF p_x_line_rec.line_category_code = 'RETURN' AND
304         p_x_line_rec.reference_line_id IS NOT NULL THEN  -- referenced return
305      IF (p_x_line_rec.inventory_item_id IS NOT NULL AND
306             p_x_line_rec.inventory_item_id <> FND_API.G_MISS_NUM) AND
307            (p_x_line_rec.ship_from_org_id  IS NOT NULL AND
308             p_x_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM) THEN
309             x_item_rec := OE_Order_Cache.Load_Item (p_x_line_rec.inventory_item_id
310                             ,p_x_line_rec.ship_from_org_id);
311             --IF  x_item_rec.ont_pricing_qty_source = 1  AND -- INVCONV
312             IF x_item_rec.ont_pricing_qty_source = 'S' AND -- INVCONV
313                    x_item_rec.tracking_quantity_ind = 'P'  THEN -- AND -- INVCONV -
314                   --x_item_rec.wms_enabled_flag = 'Y' THEN -- INVCONV - TAKE OUT AS OPENED UP TO ANY ORG
315                   IF l_debug_level  > 0 THEN
316                         oe_debug_pub.add(  'Discrete catchweight enabled. Prorating ordered_quantity2. p_old_line_rec.ordered_quantity2:'|| p_old_line_rec.ordered_quantity2||
317           ': p_old_line_rec.ordered_quantity:'|| p_old_line_rec.ordered_quantity||': p_x_line_rec.ordered_quantity:'|| p_x_line_rec.ordered_quantity);
318                          oe_debug_pub.add('p_x_line_rec.ordered_quantity2 : '||p_x_line_rec.ordered_quantity2,3);
319                   END IF;
320                   If p_old_line_rec.ordered_quantity2 Is NOT NULL AND
321                      p_old_line_rec.ordered_quantity2 <> FND_API.G_MISS_NUM AND
322                      p_old_line_rec.ordered_quantity Is NOT NULL AND
323                      p_old_line_rec.ordered_quantity <> FND_API.G_MISS_NUM Then
324                         p_x_line_rec.ordered_quantity2 := (p_old_line_rec.ordered_quantity2 / p_old_line_rec.ordered_quantity) * p_x_line_rec.ordered_quantity;
325                   END IF;
326                  -- Populate pricing quantity
327                   IF p_x_line_rec.ordered_quantity2 <> FND_API.G_MISS_NUM And
328                        p_x_line_rec.ordered_quantity2 IS NOT NULL and
329                        p_x_line_rec.pricing_quantity_uom is not null and
330                        p_x_line_rec.pricing_quantity_uom <> FND_API.G_MISS_CHAR
331 and
332                        p_x_line_rec.ordered_quantity_uom2 is not null  and
333                        p_x_line_rec.ordered_quantity_uom2 <> FND_API.G_MISS_CHAR Then
334                        IF p_x_line_rec.pricing_quantity_uom = p_x_line_rec.ordered_quantity_uom2 THEN
335                             IF l_debug_level  > 0 THEN
336                                   oe_debug_pub.add('pricing uom is same as ordered quantity2 uom');
337                             END IF;
338                             p_x_line_rec.Pricing_quantity := p_x_line_rec.ordered_quantity2;
339                        ELSE
340                              p_x_line_rec.Pricing_quantity :=
341                                         OE_Order_Misc_Util.convert_uom(
342                                                 p_x_line_rec.inventory_item_id,
343                                                 p_x_line_rec.order_quantity_uom,                                                p_x_line_rec.pricing_quantity_uom,
344                                                 p_x_line_rec.ordered_quantity
345                                                 );
346                               IF l_debug_level  > 0 THEN
347                                   oe_debug_pub.add('pricing uom is different than ordered quantity2 uom. p_x_line_rec.Pricing_quantity:'|| p_x_line_rec.Pricing_quantity);
348                             END IF;
349                          END IF; -- Pricing Quantity
350                    END IF; -- Check for existence of qty2, uom2 and pricing uom
351             END IF; -- end check for discrete catchweight
352       END IF; -- end check for item, warehouse existence
353    END IF; -- end check for referenced return
354 END Calc_Catchweight_Return_qty2;
355 
356 
357 
358 
359 /*----------------------------------------------------------
360 Procedure Apply_Attribute_Changes
361 -----------------------------------------------------------*/
362 
363 PROCEDURE Apply_Attribute_Changes
364 (   p_x_line_rec                    IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type
365 ,   p_old_line_rec                  IN  OE_Order_PUB.Line_Rec_Type :=
366                                         OE_Order_PUB.G_MISS_LINE_REC
367 )
368 IS
369 l_temp_pricing_quantity  NUMBER:=0;
370 L_RETURN_STATUS   		VARCHAR2(1);
371 L_IS_MODEL        		VARCHAR2(1);
372 -- The following variables have been declared for Shipping Integration
373 l_update_shipping			VARCHAR2(1) := FND_API.G_FALSE;
374 l_explosion_date_changed	VARCHAR2(1) := FND_API.G_FALSE;
375 l_ordered_quantity_changed	VARCHAR2(1) := FND_API.G_FALSE;
376 l_shipping_unique_key1		VARCHAR2(30);
377 l_shipping_param1			VARCHAR2(240);
378 l_x_line_Tbl                    OE_Order_PUB.Line_Tbl_Type;
379 l_temp_shipped_quantity		NUMBER;
380 l_validated_quantity		NUMBER;
381 l_primary_quantity			NUMBER;
382 l_qty_return_status			VARCHAR2(1);
383 --  End of Shipping Integration Variables
384 l_verify_payment_flag  	VARCHAR2(30) := 'N';
385 i					pls_integer;
386 l_Price_Control_Rec		QP_PREQ_GRP.control_record_type;
387 l_freeze_method   		VARCHAR2(30);
388 l_count           		NUMBER := 0;
389 l_copy_adjustments			boolean := FALSE;
390 l_copy_pricing_attributes	boolean := FALSE;
391 l_no_copy_adjustments		boolean := FALSE;
392 l_no_price_flag			boolean 	:= FALSE;
393 l_from_line_id				number;
394 l_from_Header_id			number;
395 l_return_code           		NUMBER;
396 l_error_buffer          		VARCHAR2(240);
397 l_x_result_out          		VARCHAR2(30);
398 l_turn_off_pricing      		VARCHAR2(30);
399 --OPM 06/SEP/00
400 l_item_rec                    OE_ORDER_CACHE.item_rec_type; -- INVCONV
401 -- l_OPM_shipped_quantity        NUMBER(19,9);  -- INVCONV
402 -- l_OPM_shipping_quantity_uom   VARCHAR2(4);   -- INVCONV
403 -- l_OPM_order_quantity_uom      VARCHAR2(4);   -- INVCONV
404 l_status                      VARCHAR2(1);
405 l_msg_count                   NUMBER;
406 l_msg_data                    VARCHAR2(2000);
407 --OPM 06/SEP/00 END
408 --OPM BUG 1491504 BEGIN
409 l_ordered_quantity            NUMBER := p_x_line_rec.ordered_quantity;
410 l_ordered_quantity2           NUMBER := p_x_line_rec.ordered_quantity2;
411 l_old_line_tbl	               OE_Order_PUB.Line_Tbl_Type;
412 l_line_tbl	               OE_Order_PUB.Line_Tbl_Type;
413 l_control_rec	               OE_GLOBALS.Control_Rec_Type;
414 --OPM BUG 1491504 END
415 /* csheu -- bug #1533658 start*/
416 l_copy_service_fields         boolean := FALSE;
417 /* csheu -- bug #1533658 end*/
418 l_zero_line_qty               boolean := FALSE;
419 /* lchen -- bug #1761154 start*/
420 l_serviceable_item   VARCHAR2(1);
421 l_serviced_model       VARCHAR2(1);
422 /* lchen -- bug #1761154 end*/
423 -- commitment bug 1829201
424 l_calculate_commitment_flag 	VARCHAR2(1) := 'N';
425 l_get_commitment_bal	 	VARCHAR2(1) := 'N';
426 l_update_commitment_flag 	VARCHAR2(1) := 'N';
427 l_update_commitment_applied 	VARCHAR2(1) := 'N';
428 l_class 			VARCHAR2(30);
429 l_so_source_code 		VARCHAR2(30);
430 l_oe_installed_flag 		VARCHAR2(30);
431 l_commitment_applied_amount	NUMBER := 0;
432 l_param1			VARCHAR2(30) := NULL;
433 l_item_chg_prof                 VARCHAR2(1);
434 --bug 1786835
435 l_charges_for_backorders     VARCHAR2(1):= G_CHARGES_FOR_BACKORDERS; /* Bug # 5036404 */
436 l_charges_for_included_item  VARCHAR2(1):= G_CHARGES_FOR_INCLUD_ITM; /* Bug # 5036404 */
437 -- bug 1406890
438 l_current_event number := 0;
439 l_tax_calculation_event_code number := 0; --renga's change
440 l_tax_calc_rec  OE_ORDER_CACHE.Tax_Calc_Rec_Type;
441 l_tax_calculation_flag varchar2(1) := NULL;  --end renga's change
442 l_tax_commt_flag varchar2(1) := 'N';   --bug 2505961
443 --B2037234  	EMC
444 --B2204216      EMC Assignment of IC$EPSILON profile value moved outside
445 --              declaration to OPM branch of code.
446 l_epsilon                       NUMBER;
447 n                       	NUMBER;
448 l_pricing_event                 VARCHAR2(30);
449 --RT{
450 l_retrobill_operation VARCHAR2(10);
451 --RT}
452 -- by default, pricing will be called for Freight Rating
453 -- after calling FTE.
454 l_get_FTE_freight_rate          VARCHAR2(1) := 'N';
455 l_3a7_attribute_change          VARCHAR2(1) := FND_API.G_FALSE;
456 l_wms_org_flag_new VARCHAR2(1) := 'X';
457 l_wms_org_flag_old  VARCHAR2(1) := 'X';
458 l_fte_count   NUMBER := 0;
459 l_call_pricing varchar2(1) := 'N';
460 
461 --Customer Acceptance
462 l_def_contingency_attributes VARCHAR2(1) := FND_API.G_FALSE;
463 --CC Encryption
464 l_delete_payment_count NUMBER;
465 --
466 -- bug 4378531
467 l_hold_result                   VARCHAR2(30);
468 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
469 --
470 --Bug#5026401
471 l_orig_line_calc_price_flag     VARCHAR2(1);
472 l_ship_inv_count NUMBER :=0;
473 
474 l_po_NeedByDate_Update   VARCHAR2(10); -- Adeed for IR ISO CMS project
475 --
476 
477 BEGIN
478 
479   if l_debug_level > 0 then
480     oe_debug_pub.add('Entering OE_LINE_UTIL.APPLY_ATTRIBUTE_CHANGES', 1);
481   end if;
482 
483     -- Query Header Record
484     -- Performance Improvement Bug 1929163
485     -- Use cached header rec instead of querying header rec into
486     -- a local variable
487     OE_Order_Cache.Load_Order_Header(p_x_line_rec.header_id);
488 
489     l_tax_calc_rec := oe_order_cache.get_tax_calculation_flag
490                                  (p_x_line_rec.line_type_id,
491                                   p_x_line_rec);
492 
493     l_tax_calculation_flag := l_tax_calc_rec.tax_calculation_flag;
494 
495 
496     IF NOT OE_GLOBALS.Equal(p_x_line_rec.accounting_rule_id,p_old_line_rec.accounting_rule_id)
497     THEN
498       --Customer Acceptance
499        l_def_contingency_attributes := FND_API.G_TRUE;
500     END IF;
501 
502     IF NOT OE_GLOBALS.Equal(p_x_line_rec.agreement_id,p_old_line_rec.agreement_id)
503     THEN
504          OE_GLOBALS.G_PRICE_FLAG := 'Y';
505 
506          -- bug 1829201, need to recalculate commitment.
507          IF p_x_line_rec.commitment_id is not null then
508            l_calculate_commitment_flag := 'Y';
509          END IF;
510     END IF;
511 
512     --bug3280378
513     --changes in the customer job field should be reflected in the
514     --shipping tables also
515     IF NOT
516 OE_GLOBALS.Equal(p_x_line_rec.customer_job,p_old_line_rec.customer_job) THEN
517 
518        l_update_shipping := FND_API.G_TRUE;
519 
520     END IF;
521     --bug3280378
522 
523     IF NOT OE_GLOBALS.Equal(p_x_line_rec.arrival_set_id,p_old_line_rec.arrival_set_id)
524     THEN
525 		-- Need to Call Shipping Update
526     		l_update_shipping	:= FND_API.G_TRUE;
527 
528     END IF;
529 
530     IF NOT OE_GLOBALS.Equal(p_x_line_rec.arrival_set,p_old_line_rec.arrival_set) THEN
531 
532 	NULL;
533 
534     END IF;
535 
536     -- CMS Date Changes
537 
538     IF NOT OE_GLOBALS.Equal(p_x_line_rec.schedule_arrival_date,p_old_line_rec.schedule_arrival_date)
539     THEN
540            -- Need to Call Shipping Update
541            l_update_shipping       := FND_API.G_TRUE;
542 
543     END IF;
544 
545     IF NOT OE_GLOBALS.Equal(p_x_line_rec.promise_date,p_old_line_rec.promise_date)
546     THEN
547            -- Need to Call Shipping Update
548            l_update_shipping       := FND_API.G_TRUE;
549 
550     END IF;
551 
552     IF NOT OE_GLOBALS.Equal(p_x_line_rec.earliest_acceptable_date,p_old_line_rec.earliest_acceptable_date)
553     THEN
554            -- Need to Call Shipping Update
555            l_update_shipping       := FND_API.G_TRUE;
556 
557     END IF;
558 
559     IF NOT OE_GLOBALS.Equal(p_x_line_rec.latest_acceptable_date,p_old_line_rec.latest_acceptable_date)
560     THEN
561            -- Need to Call Shipping Update
562            l_update_shipping       := FND_API.G_TRUE;
563 
564     END IF;
565 
566     IF NOT OE_GLOBALS.Equal(p_x_line_rec.earliest_ship_date,p_old_line_rec.earliest_ship_date)
567     THEN
568            -- Need to Call Shipping Update
569            l_update_shipping       := FND_API.G_TRUE;
570 
571     END IF;
572 
573 
574     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ato_line_id,p_old_line_rec.ato_line_id)
575     THEN
576 
577 		-- Need to Call Shipping Update
578     		l_update_shipping	:= FND_API.G_TRUE;
579 
580     END IF;
581 
582     IF NOT OE_GLOBALS.Equal(p_x_line_rec.cancelled_quantity,p_old_line_rec.cancelled_quantity)
583     THEN
584 
585 	-- Call Pricing
586         OE_GLOBALS.G_PRICE_FLAG := 'Y';
587 
588         -- bug 1829201, need to recalculate commitment.
589         IF p_x_line_rec.commitment_id is not null then
590           l_calculate_commitment_flag := 'Y';
591         END IF;
592 
593 	/* Additional task:
594 	Log delayed request for Verify Payment if the payment type
595 	is not CREDIT CARD and the Order line is Booked */
596 
597         IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
598 	    IF NVL(OE_Order_Cache.g_header_rec.payment_type_code,'NULL') <> 'CREDIT_CARD'
599 		AND p_x_line_rec.booked_flag ='Y'
600 	    THEN
601 		-- Log Delayed Request for Verify Payment
602                if l_debug_level > 0 then
603 		oe_debug_pub.ADD('log verify payment delayed request for change in Canceled Qty');
604                end if;
605 		l_verify_payment_flag := 'Y';
606 	     END IF;
607 	 END IF;
608 
609     --Should not include any code here for cancellation specific
610     END IF;
611 
612     IF NOT OE_GLOBALS.Equal(p_x_line_rec.customer_dock_code,p_old_line_rec.customer_dock_code)
613     THEN
614 
615 		-- Need to Call Shipping Update
616     		l_update_shipping	:= FND_API.G_TRUE;
617 
618     END IF;
619 
620     IF NOT OE_GLOBALS.Equal(p_x_line_rec.cust_production_seq_num,p_old_line_rec.cust_production_seq_num)
621     THEN
622 	-- Need to Call Shipping Update
623     	l_update_shipping	:= FND_API.G_TRUE;
624     END IF;
625 
626 IF NOT OE_GLOBALS.Equal(p_x_line_rec.cust_po_number,p_old_line_rec.cust_po_number)
627     THEN
628 	 /*Changes for ER 6072870 begin*/
629 
630       IF (Nvl(p_x_line_rec.shipped_quantity,0)>0 AND          --suneela
631       p_x_line_rec.LINE_CATEGORY_CODE='ORDER')
632       THEN
633         l_ship_inv_count:= -1;
634         if l_debug_level > 0 THEN
635                oe_debug_pub.add('Need not query shipping tables hence setting the counter to -1');
636                oe_debug_pub.add('Line is already shipped,will not update shipping', 1);
637                end if;
638          FND_MESSAGE.SET_NAME('ONT', 'OE_PO_SHIPPED');
639          OE_MSG_PUB.ADD;
640 
641      ELSIF p_x_line_rec.LINE_CATEGORY_CODE='ORDER' THEN
642 
643       BEGIN
644        IF Nvl(p_x_line_rec.shipping_interfaced_flag,'N')='Y' THEN
645 
646           SELECT Count(1)
647           INTO l_ship_inv_count
648           FROM wsh_delivery_details wdd
649           WHERE  wdd.source_code='OE'
650                  AND wdd.source_line_id=p_x_line_rec.line_id
651                  AND (wdd.released_status IN ('C','I')
652                  OR oe_interfaced_flag='Y');
653 
654        ELSE
655           l_ship_inv_count:=0;
656        END IF;
657 
658       EXCEPTION
659       WHEN No_Data_Found THEN
660         l_ship_inv_count:=0;
661         if l_debug_level > 0 then
662          oe_debug_pub.add('the line is neither picked, shipped or interfaced. can call update shipping', 1);
663         end if;
664       END ;
665      END IF;
666 
667 	 -- Need to Call Shipping Update
668      IF l_ship_inv_count>0
669 
670       THEN
671                if l_debug_level > 0 then
672                oe_debug_pub.add('Line is already shipped,will not update shipping', 1);
673                end if;
674          FND_MESSAGE.SET_NAME('ONT', 'OE_PO_SHIPPED');
675          OE_MSG_PUB.ADD;
676 
677      ELSIF l_ship_inv_count=0 THEN
678 
679     	 l_update_shipping	:= FND_API.G_TRUE;
680 
681      END IF ;
682 
683     /*Changes for ER 6072870 end */
684 	 -- Call Pricing
685          OE_GLOBALS.G_PRICE_FLAG := 'Y';
686 
687         IF p_x_line_rec.commitment_id IS NOT NULL THEN
688           l_get_commitment_bal := 'Y';
689         END IF;
690 END IF;
691 
692     IF NOT OE_GLOBALS.Equal(p_x_line_rec.deliver_to_contact_id,p_old_line_rec.deliver_to_contact_id)
693     THEN
694 	 -- Need to Call Shipping Update
695     	 l_update_shipping	:= FND_API.G_TRUE;
696 	 -- Call Pricing
697          -- OE_GLOBALS.G_PRICE_FLAG := 'Y';  Commented out for fix 1419204
698     END IF;
699 
700     IF NOT OE_GLOBALS.Equal(p_x_line_rec.deliver_to_org_id,p_old_line_rec.deliver_to_org_id)
701     THEN
702 	 -- Need to Call Shipping Update
703     	 l_update_shipping	:= FND_API.G_TRUE;
704 	 -- Call Pricing
705       -- OE_GLOBALS.G_PRICE_FLAG := 'Y'; Commented out for fix 1419204
706 
707 
708     END IF;
709 
710     IF NOT OE_GLOBALS.Equal(p_x_line_rec.explosion_date,p_old_line_rec.explosion_date)
711     THEN
712 	IF OE_GLOBALS.EQUAL(p_x_line_rec.ship_model_complete_flag,'Y') THEN
713     		l_explosion_date_changed	:= FND_API.G_TRUE;
714 	END IF;
715     END IF;
716 
717     IF NOT OE_GLOBALS.Equal(p_x_line_rec.fob_point_code,p_old_line_rec.fob_point_code)
718     THEN
719 		-- Need to Call Shipping Update
720     		l_update_shipping	:= FND_API.G_TRUE;
721     END IF;
722 
723     IF NOT OE_GLOBALS.Equal(p_x_line_rec.freight_terms_code,p_old_line_rec.freight_terms_code)
724     THEN
725 		-- Need to Call Shipping Update
726     		l_update_shipping	:= FND_API.G_TRUE;
727     END IF;
728 
729     IF NOT OE_GLOBALS.Equal(p_x_line_rec.calculate_price_flag,p_old_line_rec.calculate_price_flag)
730     THEN
731 
732 	   If p_x_line_rec.calculate_price_flag = 'Y' then
733 	   	Begin
734 
735 			OE_Order_Cache.Enforce_List_price(p_line_type_id => p_x_line_rec.Line_Type_id
736 										, p_header_id => p_x_line_rec.header_id);
737 
738 	     	exception when no_data_found then
739 				OE_Order_Cache.g_Enforce_list_price_rec.enforce_line_prices_flag := 'N';
740 	   	end ;
741 
742         	If  OE_Order_Cache.g_Enforce_list_price_rec.enforce_line_prices_flag = 'Y'  Then
743 			p_x_line_rec.calculate_price_flag := 'P';
744 	   	End If;
745 
746 		IF p_x_line_rec.open_flag = 'N' or
747 			p_x_line_rec.cancelled_flag = 'Y'
748 		THEN
749 
750 			 p_x_line_rec.calculate_price_flag := 'N';
751 
752 		End If;
753 
754 	   End If; -- For price_flag='Y'
755 
756       -- bug 3585862
757       if l_debug_level > 0 then
758          oe_debug_pub.add('old calculate price flag'||p_old_line_rec.calculate_price_flag, 3);
759          oe_debug_pub.add('new calculate price flag'||p_x_line_rec.calculate_price_flag, 3);
760       end if;
761       IF Nvl(oe_globals.g_pricing_recursion,'N') = 'N'
762         AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
763         AND ((p_old_line_rec.calculate_price_flag in ('N','P') and p_x_line_rec.calculate_price_flag = 'Y')
764              OR (p_old_line_rec.calculate_price_flag = 'N' and p_x_line_rec.calculate_price_flag = 'P'))
765       THEN
766         if l_debug_level > 0 then
767           oe_debug_pub.add('setting price flag because of calculate price flag change', 3);
768         end if;
769         IF nvl(OE_GLOBALS.G_PRICE_FLAG, 'N') <> 'Y' THEN
770   	  OE_GLOBALS.G_PRICE_FLAG := 'Y';
771           OE_LINE_ADJ_UTIL.Register_Changed_Lines
772           (p_line_id         => p_x_line_rec.line_id,
773            p_header_id       => p_x_line_rec.header_id,
774            p_operation       => p_x_line_rec.operation );
775         END IF;
776       END IF;
777       -- end bug 3585862
778     END IF;
779 
780     IF NOT OE_GLOBALS.Equal(p_x_line_rec.intermed_ship_to_org_id,p_old_line_rec.intermed_ship_to_org_id)
781     THEN
782 		-- Need to Call Shipping Update
783     		l_update_shipping	:= FND_API.G_TRUE;
784         /* may need to call pricing */
785         /*
786           OE_GLOBALS.G_PRICE_FLAG := 'Y';
787         */
788 
789     END IF;
790 
791     IF NOT OE_GLOBALS.Equal(p_x_line_rec.intermed_ship_to_contact_id,p_old_line_rec.intermed_ship_to_contact_id)
792     THEN
793 		-- Need to Call Shipping Update
794     		l_update_shipping	:= FND_API.G_TRUE;
795         /* may need to call pricing */
796         /*
797           OE_GLOBALS.G_PRICE_FLAG := 'Y';
798         */
799     END IF;
800 
801 
802     IF NOT OE_GLOBALS.Equal(p_x_line_rec.inventory_item_id,p_old_line_rec.inventory_item_id)
803     THEN
804 
805       -- QUOTING changes - log explosion request only for lines in
806       -- fulfillment phase
807       IF nvl(p_x_line_rec.transaction_phase_code,'F') = 'F' THEN
808 
809     -- log a delayed request to get included items for this item if any.
810 
811       l_freeze_method := G_FREEZE_METHOD; /* Bug # 5036404 */
812      if l_debug_level > 0 then
813       oe_debug_pub.ADD('Freeze method is :' || l_freeze_method,2);
814      end if;
815       --3286378 : Added check for operation= create
816       IF l_freeze_method = OE_GLOBALS.G_IIFM_ENTRY AND
817          (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE OR
818           (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
819            p_x_line_rec.split_from_line_id IS NULL)) AND
820          p_x_line_rec.ato_line_id is NULL AND
821          ( p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
822            (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT AND
823             p_x_line_rec.line_id = p_x_line_rec.top_model_line_id))
824       THEN
825            if l_debug_level > 0 then
826               oe_debug_pub.ADD('LINE ID : '||p_x_line_rec.line_id,2);
827            end if;
828            p_x_line_rec.explosion_date := null;
829            l_count := l_count + 1;
830            OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL(l_count):= p_x_line_rec.line_id;
831       END IF;
832 
833       END IF; -- End if phase is fulfillment
834       -- END QUOTING changes
835 
836       --Customer Acceptance
837        l_def_contingency_attributes := FND_API.G_TRUE;
838 
839       --  NULL;
840       -- Need to Call Shipping Update
841       l_update_shipping	:= FND_API.G_TRUE;
842 
843 	 IF ( p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
844 	    NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT' )
845             -- QUOTING change
846             AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
847          THEN
848      if l_debug_level > 0 then
849       oe_debug_pub.ADD('item update: logging request for eval_hold_source');
850          oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
851                    ' Entity ID: '|| to_char(p_x_line_rec.inventory_item_id));
852      end if;
853 
854          OE_delayed_requests_Pvt.log_request
855                  (p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
856                   p_entity_id         => p_x_line_rec.line_id,
857                   p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
858                   p_requesting_entity_id         => p_x_line_rec.line_id,
859                   p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
860                   p_request_unique_key1 => 'ITEM',
861                   p_param1		 => 'I',
862                   p_param2		 => p_x_line_rec.inventory_item_id,
863                   x_return_status     => l_return_status);
864        if l_debug_level > 0 then
865          oe_debug_pub.ADD('after call to log_request: l_return_status: '||
866 							   l_return_status , 1);
867        end if;
868 
869        END IF;
870        -- Item ID has changed. Need to redo balance checking
871        if p_x_line_rec.commitment_id is not null then
872          null;
873        end if;
874 
875        -- Redefault Globalization flexfield
876        -- Performance Improvement Bug 1929163
877        -- JG has provided a NOCOPY spec via bug 1950033
878      if l_debug_level > 0 then
879        oe_debug_pub.add('before calling jg');
880      end if;
881        JG_ZZ_OM_COMMON_PKG.default_gdf(
882                                 x_line_rec=>p_x_line_rec,
883 				x_return_code => l_return_code,
884 				x_error_buffer => l_error_buffer);
885      if l_debug_level > 0 then
886        oe_debug_pub.add('after calling jg');
887      end if;
888        --bug 2971066 Begin
889        l_item_chg_prof := fnd_profile.value('ONT_HONOR_ITEM_CHANGE');
890 if l_debug_level > 0 then
891  oe_debug_pub.add('value of ONT_HONOR_ITEM_CHANGE:'||l_item_chg_prof,5);
892  oe_debug_pub.add('p_x_line_rec.inventory_item_id : '||p_x_line_rec.inventory_item_id);
893  oe_debug_pub.add('p_old_line_rec.inventory_item_id : '||p_old_line_rec.inventory_item_id);
894 end if;
895        IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
896         /*if nvl(p_x_line_rec.inventory_item_id,FND_API.G_MISS_NUM)
897           <> FND_API.G_MISS_NUM
898         and nvl(p_old_line_rec.inventory_item_id,FND_API.G_MISS_NUM) <>
899              FND_API.G_MISS_NUM*/
900         IF (
901               (nvl(p_x_line_rec.inventory_item_id,FND_API.G_MISS_NUM)
902                <> FND_API.G_MISS_NUM
903                and nvl(p_old_line_rec.inventory_item_id,FND_API.G_MISS_NUM)
904                <> FND_API.G_MISS_NUM )
905            -- Bug# 3942402
906            -- For Case1:
907             or
908               (nvl(p_x_line_rec.inventory_item_id,FND_API.G_MISS_NUM)
909                = FND_API.G_MISS_NUM
910                and nvl(p_old_line_rec.inventory_item_id,FND_API.G_MISS_NUM)
911                <> FND_API.G_MISS_NUM )
912             )
913            -- Bug# 3942402 end
914         and p_x_line_rec.calculate_price_flag in ('N','P')
915         and nvl(l_item_chg_prof,'N') = 'N' then
916           if l_debug_level > 0 then
917             oe_debug_pub.add('Changing calculate price flag to Y');
918           end if;
919             p_x_line_rec.calculate_price_flag := 'Y';
920         end if;
921        -- bug 2971066 end
922        -- bug 1819133, need to recalculate price if item is updated
923        ELSIF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
924         --change made for bug 1998333      Begin
925           if nvl(l_item_chg_prof,'N') = 'N' then
926            --retaining the old behaviour
927             p_x_line_rec.calculate_price_flag := 'Y';
928           else
929            --we do not change anything
930             null;
931           end if;
932         --change made for bug 1998333      End
933        END IF;
934 
935        OE_GLOBALS.G_PRICE_FLAG := 'Y';
936 
937        -- bug 1829201, need to recalculate commitment.
938        IF p_x_line_rec.commitment_id is not null then
939          l_calculate_commitment_flag := 'Y';
940        END IF;
941 
942        IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
943           AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
944                                      (p_x_line_rec.header_id)
945               = 'OM_CALLED_FREIGHT_RATES' THEN
946           if l_debug_level > 0 then
947             oe_debug_pub.add('Log Freight Rating request for item change. ',3);
948           end if;
949             l_get_FTE_freight_rate := 'Y';
950        END IF;
951 
952 
953 /*sdatti*/
954      if l_debug_level > 0 then
955        oe_debug_pub.ADD('OE_GLOBALS.G_PRICING_RECURSION:'||oe_globals.g_pricing_recursion,1);
956      end if;
957        IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110509' THEN
958         IF Nvl(oe_globals.g_pricing_recursion,'N') = 'N'  THEN
959 	  update_adjustment_flags(p_old_line_rec,p_x_line_rec);
960         END IF;
961        END IF;
962 /*sdatti*/
963 
964     END IF;
965 
966 
967     IF NOT OE_GLOBALS.Equal(p_x_line_rec.invoice_to_org_id,p_old_line_rec.invoice_to_org_id)
968     THEN
969         /* may need to call pricing */
970 
971           OE_GLOBALS.G_PRICE_FLAG := 'Y';
972 	  --Customer Acceptance
973 	  l_def_contingency_attributes := FND_API.G_TRUE;
974 
975           IF p_x_line_rec.commitment_id IS NOT NULL THEN
976             l_get_commitment_bal := 'Y';
977           END IF;
978 
979 	   IF ( p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
980 	      NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT')
981                -- QUOTING change
982               AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
983            THEN
984                 if l_debug_level > 0 then
985                   oe_debug_pub.ADD('invoice site update: logging request for eval_hold_source');
986                   oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
987 		         ' Entity ID: '|| to_char(p_x_line_rec.invoice_to_org_id));
988                 end if;
989                   OE_delayed_requests_Pvt.log_request(
990                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
991                     p_entity_id         => p_x_line_rec.line_id,
992 			     p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
993 			     p_requesting_entity_id         => p_x_line_rec.line_id,
994                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
995                     p_request_unique_key1 => 'BILL_TO',
996                     p_param1		 => 'B',
997                     p_param2		 => p_x_line_rec.invoice_to_org_id,
998                     x_return_status     => l_return_status);
999         END IF;
1000 
1001 	IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
1002 		--R12 CC Encryption
1003 		select count(payment_type_code) into
1004 		l_delete_payment_count from oe_payments
1005 		where header_id = p_x_line_rec.header_id
1006 		and line_id = p_x_line_rec.line_id and
1007 		payment_type_code in ('ACH','DIRECT_DEBIT','CREDIT_CARD');
1008 
1009 		 --Delayed request for deleting the payments when
1010 		 --invoice to changes
1011 		 IF l_delete_payment_count > 0 THEN
1012 			OE_delayed_requests_Pvt.log_request
1013 			    (p_entity_code            	=> OE_GLOBALS.G_ENTITY_LINE_PAYMENT,
1014 			     p_entity_id              	=> p_x_line_rec.line_id,
1015 			     p_requesting_entity_code	=> OE_GLOBALS.G_ENTITY_LINE_PAYMENT,
1016 			     p_requesting_entity_id  	=> p_x_line_rec.line_id,
1017 			     p_request_type           	=> OE_GLOBALS.G_DELETE_PAYMENTS,
1018 			     p_param1			=> p_x_line_rec.header_id,
1019 			     p_param2			=> to_char(p_old_line_rec.invoice_to_org_id),
1020 			     x_return_status         	=> l_return_status);
1021 		  END IF;--Payment type code check
1022 		  --R12 CC Encryption
1023 		/* Additional Task : Log a delayed request for Verify payment
1024 		(Credit Checking) when the bill to site changes for a booked line */
1025 		IF NVL(OE_Order_Cache.g_header_rec.payment_type_code,'NULL') <>  'CREDIT_CARD'
1026 		AND  p_x_line_rec.booked_flag ='Y'
1027 		THEN
1028                       if l_debug_level > 0 then
1029 			oe_debug_pub.ADD('log verify payment delayed request for change in invoice to site');
1030                       end if;
1031 			l_verify_payment_flag := 'Y';
1032 		END IF;
1033 	END IF;
1034 
1035     END IF;
1036 
1037    -- Changes for Blanket Orders
1038 
1039    IF NOT OE_GLOBALS.Equal(p_x_line_rec.blanket_number,p_old_line_rec.blanket_number)  OR
1040       NOT OE_GLOBALS.Equal(p_x_line_rec.blanket_line_number,p_old_line_rec.blanket_line_number)
1041     THEN
1042         --for ER 2901219
1043         --To trigger Pricing event if Blanket Number or Line Number is Changed
1044         OE_GLOBALS.G_PRICE_FLAG := 'Y';
1045 
1046         IF ( p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
1047 	     NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT')
1048              -- QUOTING change
1049              AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
1050         THEN
1051                   OE_delayed_requests_Pvt.log_request(
1052                     p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
1053                     p_entity_id              => p_x_line_rec.line_id,
1054                     p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
1055                     p_requesting_entity_id   => p_x_line_rec.line_id,
1056                     p_request_type           => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
1057                     p_param1                 => 'H',
1058                     p_param2                 => p_x_line_rec.blanket_number,
1059                     x_return_status          => l_return_status);
1060         END IF;
1061     END IF;
1062 
1063     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_item_id,p_old_line_rec.ordered_item_id)
1064     THEN
1065         /*  need to reprice the line*/
1066 
1067         -- bug 1819133, need to recalculate price if item is updated
1068         IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
1069       if l_debug_level > 0 then
1070         oe_debug_pub.add('before checking profile ONT_HONOR_ITEM_CHANGE',5);
1071       end if;
1072         --change made for bug 1998333      Begin
1073           l_item_chg_prof := fnd_profile.value('ONT_HONOR_ITEM_CHANGE');
1074 if l_debug_level > 0 then
1075  oe_debug_pub.add('value of profile ONT_HONOR_ITEM_CHANGE:'||l_item_chg_prof,5);
1076 end if;
1077           if nvl(l_item_chg_prof,'N') = 'N' then
1078            --retaining the old behaviour
1079             p_x_line_rec.calculate_price_flag := 'Y';
1080           else
1081            --we do not change anything
1082             null;
1083           end if;
1084         --change made for bug 1998333      End
1085         END IF;
1086 
1087         OE_GLOBALS.G_PRICE_FLAG := 'Y';
1088 
1089         -- bug 1829201, need to recalculate commitment.
1090         IF p_x_line_rec.commitment_id is not null then
1091           l_calculate_commitment_flag := 'Y';
1092         END IF;
1093 
1094     END IF;
1095 
1096     IF NOT OE_GLOBALS.Equal(p_x_line_rec.item_identifier_type,p_old_line_rec.item_identifier_type)
1097     THEN
1098         /*  need to reprice the line*/
1099         -- OE_GLOBALS.G_PRICE_FLAG := 'Y'; Commented out for fix 1419204
1100            null;
1101 
1102     END IF;
1103 
1104     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_item,p_old_line_rec.ordered_item)
1105     THEN
1106 	    -- Call Pricing
1107        -- bug 1819133, need to recalculate price if item is updated
1108        IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
1109       if l_debug_level > 0 then
1110         oe_debug_pub.add('before checking profile ONT_HONOR_ITEM_CHANGE',5);
1111       end if;
1112         --change made for bug 1998333      Begin
1113           l_item_chg_prof := fnd_profile.value('ONT_HONOR_ITEM_CHANGE');
1114 if l_debug_level > 0 then
1115  oe_debug_pub.add('value of profile ONT_HONOR_ITEM_CHANGE:'||l_item_chg_prof,5);
1116 end if;
1117           if nvl(l_item_chg_prof,'N') = 'N' then
1118            --retaining the old behaviour
1119             p_x_line_rec.calculate_price_flag := 'Y';
1120           else
1121            --we do not change anything
1122             null;
1123           end if;
1124         --change made for bug 1998333      End
1125        END IF;
1126 
1127        OE_GLOBALS.G_PRICE_FLAG := 'Y';
1128 
1129        OE_GLOBALS.G_TAX_FLAG := 'Y';
1130 
1131        -- bug 1829201, need to recalculate commitment.
1132        IF p_x_line_rec.commitment_id is not null then
1133          l_calculate_commitment_flag := 'Y';
1134        END IF;
1135     END IF;
1136 
1137     IF NOT OE_GLOBALS.Equal(p_x_line_rec.item_revision,p_old_line_rec.item_revision)
1138     THEN
1139 		-- Need to Call Shipping Update
1140     		l_update_shipping	:= FND_API.G_TRUE;
1141     END IF;
1142 
1143     IF NOT OE_GLOBALS.Equal(p_x_line_rec.item_type_code,p_old_line_rec.item_type_code)
1144     THEN
1145 
1146       -- Need to Call Shipping Update
1147     	 l_update_shipping	:= FND_API.G_TRUE;
1148 
1149       -- QUOTING changes - log explosion request only for lines in
1150       -- fulfillment phase
1151       IF nvl(p_x_line_rec.transaction_phase_code,'F') = 'F' THEN
1152 
1153       -- log a delayed request to get included items for this item if any.
1154 
1155       l_freeze_method := G_FREEZE_METHOD; /* Bug # 5036404 */
1156     if l_debug_level > 0 then
1157       oe_debug_pub.ADD('Freeze method is :' || l_freeze_method,2);
1158     end if;
1159 
1160       IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
1161          p_x_line_rec.booked_flag = 'Y' AND
1162          l_freeze_method <> OE_GLOBALS.G_IIFM_PICK_RELEASE
1163       THEN
1164         l_freeze_method := OE_GLOBALS.G_IIFM_ENTRY;
1165       END IF;
1166 
1167       l_freeze_method := nvl(l_freeze_method, OE_GLOBALS.G_IIFM_ENTRY);
1168 
1169       IF l_freeze_method = OE_GLOBALS.G_IIFM_ENTRY AND
1170          p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
1171          p_x_line_rec.ato_line_id is NULL AND
1172          ( p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
1173            p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
1174            p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT )
1175       THEN
1176        if l_debug_level > 0 then
1177          oe_debug_pub.ADD('freeze inc items ' || l_freeze_method,2);
1178        end if;
1179            l_count := l_count + 1;
1180            OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL(l_count)
1181                                           := p_x_line_rec.line_id;
1182       END IF;
1183       END IF; -- End if phase is fulfillment
1184       -- END QUOTING changes
1185 
1186       -- Need to log Freight Rating request for configured item.
1187       IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
1188           AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
1189                (p_x_line_rec.header_id) = 'OM_CALLED_FREIGHT_RATES'
1190           AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE
1191           AND p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CONFIG THEN
1192            if l_debug_level > 0 then
1193             oe_debug_pub.add('Log Freight Rating request for CONFIG item. ',3);
1194            end if;
1195             l_get_FTE_freight_rate := 'Y';
1196       END IF;
1197 
1198       --Customer Acceptance
1199        l_def_contingency_attributes := FND_API.G_TRUE;
1200 
1201     END IF;
1202 
1203     IF NOT OE_GLOBALS.Equal(p_x_line_rec.line_category_code,p_old_line_rec.line_category_code)
1204     THEN
1205 
1206 	 -- Need to Call Shipping Update
1207     	 l_update_shipping	:= FND_API.G_TRUE;
1208 	 -- Call Pricing
1209          OE_GLOBALS.G_PRICE_FLAG := 'Y';
1210 
1211          IF p_x_line_rec.commitment_id IS NOT NULL THEN
1212            l_get_commitment_bal := 'Y';
1213          END IF;
1214 
1215      -- For bugfix 3426865
1216         IF p_old_line_rec.line_category_code = 'RETURN' THEN
1217             p_x_line_rec.return_reason_code := NULL;
1218         END IF;
1219 
1220       --Customer Acceptance
1221        l_def_contingency_attributes := FND_API.G_TRUE;
1222 
1223     END IF;
1224 
1225     IF NOT OE_GLOBALS.Equal(p_x_line_rec.line_type_id,p_old_line_rec.line_type_id)
1226     THEN
1227 
1228 	-- Need to Call Shipping Update
1229     	l_update_shipping	:= FND_API.G_TRUE;
1230 	-- Call Pricing
1231         OE_GLOBALS.G_PRICE_FLAG := 'Y';
1232         --Customer Acceptance
1233         l_def_contingency_attributes := FND_API.G_TRUE;
1234 
1235 
1236         IF p_x_line_rec.commitment_id IS NOT NULL THEN
1237           l_get_commitment_bal := 'Y';
1238         END IF;
1239 
1240     END IF;
1241 
1242        -- bug 2072014, need to recalculate price if uom is updated BEGIN
1243     IF NOT OE_GLOBALS.Equal(p_x_line_rec.order_quantity_uom,p_old_line_rec.order_quantity_uom)
1244     THEN
1245 /* Added the following if condition to fix the bug 2967630 */
1246        IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
1247         if (nvl(p_old_line_rec.order_quantity_uom,FND_API.G_MISS_CHAR)
1248            <> FND_API.G_MISS_CHAR)
1249           and (nvl(p_x_line_rec.order_quantity_uom,FND_API.G_MISS_CHAR)
1250              <> FND_API.G_MISS_CHAR) and
1251           p_x_line_rec.calculate_price_flag in ('P','N')
1252         then
1253           if l_debug_level > 0 then
1254             oe_debug_pub.add('operation is :'||p_x_line_rec.operation);
1255           end if;
1256             p_x_line_rec.calculate_price_flag := 'Y';
1257         end if;
1258 
1259        ELSIF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
1260        --bug 3942402
1261         IF NOT OE_GLOBALS.Equal(p_x_line_rec.inventory_item_id, p_old_line_rec.inventory_item_id) THEN
1262           IF (nvl(p_x_line_rec.inventory_item_id,FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM
1263              and nvl(p_old_line_rec.inventory_item_id,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM)
1264              and p_x_line_rec.calculate_price_flag in ('N','P')
1265              and nvl(l_item_chg_prof,'N') = 'N' then
1266                 if l_debug_level > 0 then
1267                   oe_debug_pub.add('Changing calculate price flag to Y');
1268                 end if;
1269                 p_x_line_rec.calculate_price_flag := 'Y';
1270           ELSE
1271              null;
1272           END IF;
1273         ELSE
1274                 p_x_line_rec.calculate_price_flag := 'Y';
1275         end if;
1276         --bug 3942402
1277 /* Added the following line to fix the bug 2917690 */
1278             OE_LINE_ADJ_UTIL.Change_adj_for_uom_change(p_x_line_rec);
1279        END IF;
1280        OE_GLOBALS.G_PRICE_FLAG := 'Y';
1281        l_3a7_attribute_change := FND_API.G_TRUE;
1282 
1283        -- Freight Rating.
1284        IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
1285           AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
1286                                     (p_x_line_rec.header_id)
1287              = 'OM_CALLED_FREIGHT_RATES' THEN
1288          if l_debug_level > 0 then
1289            oe_debug_pub.add('Log Freight Rating request for uom change. ',3);
1290          end if;
1291            l_get_FTE_freight_rate := 'Y';
1292        END IF;
1293     END IF;
1294        -- bug 2072014, need to recalculate price if uom is updated END
1295 
1296     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,p_old_line_rec.ordered_quantity)
1297     THEN
1298 
1299       if l_debug_level > 0 then
1300        oe_debug_pub.add('Ordered Qty has changed',1); -- PETER
1301        oe_debug_pub.add('New Ordered Qty : ' || p_x_line_rec.ordered_quantity, 1);
1302        oe_debug_pub.add('Old Ordered Qty : ' ||
1303                                 p_old_line_rec.ordered_quantity, 1);
1304       end if;
1305        l_3a7_attribute_change := FND_API.G_TRUE;
1306 
1307           /* Added the following code to fix the bug 3739180 */
1308           If p_x_line_rec.calculate_price_flag in ('N','P') and p_x_line_rec.reference_line_id IS NOT NULL THEN
1309             IF (OE_GLOBALS.G_UI_FLAG) THEN
1310              if l_debug_level > 0 then
1311               oe_debug_pub.add('Log REVERSE_LIMITS delayed request for ENTITY LINE return',1);
1312              end if;
1313               OE_delayed_requests_Pvt.log_request(
1314                                 p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
1315                                 p_entity_id              => p_x_line_rec.line_id,
1316                                 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
1317                                 p_requesting_entity_id   => p_x_line_rec.line_id,
1318                                 p_request_unique_key1    => 'LINE',
1319                                 p_param1                 => 'RETURN',
1320                                 p_param2                 => NULL,
1321                                 p_param3                 => NULL,
1322                                 p_param4                 => NULL,
1323                                 p_param5                 => NULL,
1324                                 p_param6                 => p_x_line_rec.ordered_quantity,
1325                                 p_request_type           => OE_GLOBALS.G_REVERSE_LIMITS,
1326                                 x_return_status          => l_return_status);
1327             ELSIF NOT (OE_GLOBALS.G_UI_FLAG) THEN
1328              if l_debug_level > 0 then
1329               oe_debug_pub.add('Log REVERSE_LIMITS delayed request for ENTITY ALL line return',1);
1330              end if;
1331               OE_delayed_requests_Pvt.log_request(
1332                                 p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
1333                                 p_entity_id              => p_x_line_rec.line_id,
1334                                 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
1335                                 p_requesting_entity_id   => p_x_line_rec.line_id,
1336                                 p_request_unique_key1    => 'LINE',
1337                                 p_param1                 => 'RETURN',
1338                                 p_param2                 => NULL,
1339                                 p_param3                 => NULL,
1340                                 p_param4                 => NULL,
1341                                 p_param5                 => NULL,
1342                                 p_param6                 => p_x_line_rec.ordered_quantity,
1343                                 p_request_type           => OE_GLOBALS.G_REVERSE_LIMITS,
1344                                 x_return_status          => l_return_status);
1345             END IF;
1346           END IF;
1347           /* End of the code added to fix the bug 3739180 */
1348 
1349        /* Fix for bug 2431953 / 2749740
1350        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'))
1351 
1352        THEN
1353           G_ORDERED_QTY_CHANGE := TRUE;
1354           OE_SERVICE_UTIL.Get_Service_Attribute
1355                           (x_return_status => l_return_status
1356                           , p_x_line_rec    => p_x_line_rec
1357                           );
1358 
1359           G_ORDERED_QTY_CHANGE := FALSE;
1360 
1361           IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1362             fnd_message.set_name('ONT', 'OE_CAN_SERV_AMT_NOT_ALLOWED');
1363             oe_msg_pub.add;
1364             RAISE FND_API.G_EXC_ERROR;
1365           END IF;
1366        END IF;
1367         Fix ends */
1368 
1369        IF (p_x_line_rec.order_source_id = 10) AND
1370 		(p_old_line_rec.ordered_quantity IS NOT NULL) THEN
1371 
1372 
1373 /* 7576948: IR ISO Change Management project Start */
1374 --
1375 -- This program unit will track the specific change in Ordered Quantity
1376 -- and/or Schedule Ship Date on an internal sales order line shipment,
1377 -- and in the event of any change in values, it will log a delayed request
1378 -- of type OE_Globals.G_UPDATE_REQUISITION.
1379 --
1380 -- This delayed request will be logged only if global OE_Internal_Requisi
1381 -- tion_Pvt.G_Update_ISO_From_Req set to FALSE. If this global is TRUE
1382 -- then it means, the change requests for quantity/date or cancellation
1383 -- request is initiated by internal requisition user, in which case, it is
1384 -- not required to log the delayed request for updating the change to the
1385 -- requesting organization. System will also check that global OE_SALES_CAN
1386 -- _UTIL.G_IR_ISO_HDR_CANCEL, and will log a delayed request only if it is
1387 -- FALSE. If this global is TRUE then signifies that it is a case of full
1388 -- internal sales order header cancellation. Thus, in the event of full
1389 -- order cancellation, we only need to inform Purchasing about the
1390 -- cancellation. There is no need to provide specific line level information.
1391 -- Additionally, while logging a delayed request specific to Schedule Ship
1392 -- Date change, system will ensure that it should be allowed via Purchasing
1393 -- profile 'POR: Sync Up Need By date on IR with OM'.
1394 --
1395 -- While logging the delayed request, we will log it for Order Header or
1396 -- Order Line entity, while Entity id will be the Header_id or Line_id
1397 -- respectively. In addition to this, we will even pass Unique_Params value
1398 -- to make this request very specific to Requisition Header or Requisition
1399 -- Line.
1400 --
1401 -- Please refer to following delayed request params with their meaning
1402 -- useful while logging the delayed request -
1403 --
1404 -- P_entity_code        Entity for which delayed request has to be logged.
1405 --                      In this project it can be OE_Globals.G_Entity_Line
1406 --                      or OE_Globals.G_Entity_Header
1407 -- P_entity_id          Primary key of the entity record. In this project,
1408 --                      it can be Order Line_id or Header_id
1409 -- P_requesting_entity_code Which entity has requested this delayed request to
1410 --                          be logged! In this project it will be OE_Globals.
1411 --                          G_Entity_Line or OE_Globals.G_Entity_Header
1412 -- P_requesting_entity_id       Primary key of the requesting entity. In this
1413 --                              project, it is Line_id or Header_id
1414 -- P_request_type       Indicates which business logic (or which procedure)
1415 --                      should be executed. In this project, it is OE_Global
1416 --                      s.G_UPDATE_REQUISITION
1417 -- P_request_unique_key1        Additional argument in form of parameters.
1418 --                              In this project, it will denote the Sales Order
1419 --                              Header id
1420 -- P_request_unique_key2        Additional argument in form of parameters.
1421 --                              In this project, it will denote the Requisition
1422 --                              Header id
1423 -- P_request_unique_key3        Additional argument in form of parameters. In
1424 --                              this project, it will denote the Requistion Line
1425 --                              id
1426 -- P_param1     Additional argument in form of parameters. In this project, it
1427 --              will denote net change in order quantity with respective single
1428 --              requisition line. If it is greater than 0 then it is an increment
1429 --              in the quantity, while if it is less than 0 then it is a decrement
1430 --              in the ordered quantity. If it is 0 then it indicates there is no
1431 --              change in ordered quantity value
1432 -- P_param2     Additional argument in form of parameters. In this project, it
1433 --              will denote whether internal sales order is cancelled or not. If
1434 --              it is cancelled then respective Purchasing api will be called to
1435 --              trigger the requisition header cancellation. It accepts a value of
1436 --              Y indicating requisition header has to be cancelled.
1437 -- P_param3     Additional argument in form of parameters. In this project, it
1438 --              will denote the number of sales order lines cancelled while order
1439 --              header is (Full/Partial) cancelled.
1440 -- p_date_param1        Additional date argument in form of parameters. In this
1441 --                      project, it will denote the change in Schedule Ship Date
1442 --                      with to respect to single requisition line.
1443 -- P_Long_param1        Additional argument in form of parameters. In this project,
1444 --                      it will store all the sales order line_ids, which are getting
1445 --                      cancelled while order header gets cancelled (Full/Partial).
1446 --                      These Line_ids will be separated by a delimiter comma ','
1447 --
1448 -- For details on IR ISO CMS project, please refer to FOL >
1449 -- OM Development > OM GM > 12.1.1 > TDD > IR_ISO_CMS_TDD.doc
1450 --
1451 
1452     IF NOT ((nvl(p_x_line_rec.split_by,'X') IN ('USER','SYSTEM'))
1453               AND (NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT')) THEN
1454 
1455       -- There is no need to update IR for System Split, as the net
1456       -- change in quantity during split operation is 0
1457 
1458       /* IR ISO Change Management : Comment this code Begins */
1459       /*
1460 	    FND_MESSAGE.SET_NAME('ONT','OE_CHG_CORR_REQ');
1461             -- { start fix for 2648277
1462 	    FND_MESSAGE.SET_TOKEN('CHG_ATTR',
1463                OE_Order_Util.Get_Attribute_Name('ordered_quantity'));
1464             -- end fix for 2648277}
1465 	    OE_MSG_PUB.Add;
1466 
1467       */
1468       /* IR ISO Change Management : Comment this code Ends */
1469 
1470       IF NOT OE_Internal_Requisition_Pvt.G_Update_ISO_From_Req THEN
1471         IF NOT OE_SALES_CAN_UTIL.G_IR_ISO_HDR_CANCEL THEN
1472           IF l_debug_level > 0 THEN
1473             oe_debug_pub.add(' Header Level Cancellation is FALSE',5);
1474           END IF;
1475 
1476           -- Log a delayed request to update the Internal Requisition. This delayed
1477           -- request will be logged only if the change is not initiated from Requesting
1478           -- Organization user, and it is not a Internal Sales Order Full Cancellation
1479 
1480           OE_delayed_requests_Pvt.log_request
1481           ( p_entity_code            => OE_GLOBALS.G_ENTITY_LINE
1482           , p_entity_id              => p_x_line_rec.line_id
1483           , p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE
1484           , p_requesting_entity_id   => p_x_line_rec.line_id
1485           , p_request_unique_key1    => p_x_line_rec.header_id  -- Order Hdr_id
1486           , p_request_unique_key2    => p_x_line_rec.source_document_id -- Req Hdr_id
1487           , p_request_unique_key3    => p_x_line_rec.source_document_line_id -- Req Line_id
1488           , p_param1                 => (p_x_line_rec.ordered_quantity - p_old_line_rec.ordered_quantity)
1489 --          , p_date_param1            => p_x_line_rec.schedule_ship_date
1490           , p_request_type           => OE_GLOBALS.G_UPDATE_REQUISITION
1491           , x_return_status          => l_return_status
1492           );
1493 
1494           IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1495             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1496           ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1497             RAISE FND_API.G_EXC_ERROR;
1498           END IF;
1499 
1500 /*        ELSIF OE_SALES_CAN_UTIL.G_IR_ISO_HDR_CANCEL THEN  -- Commented for IR ISO Tracking bug 7667702
1501           IF l_debug_level > 0 THEN
1502             oe_debug_pub.add(' Header Level Cancellation is TRUE',5);
1503           END IF;
1504 
1505           -- Log a delayed request to update the Internal Requisition. This delayed
1506           -- request will be logged only if the change is not initiated from Requesting
1507           -- Organization user, and it is not a Internal Sales Order Full Cancellation
1508 
1509           OE_delayed_requests_Pvt.log_request
1510           ( p_entity_code            => OE_GLOBALS.G_ENTITY_HEADER
1511           , p_entity_id              => p_x_line_rec.header_id
1512           , p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE
1513           , p_requesting_entity_id   => p_x_line_rec.line_id
1514           , p_request_unique_key2    => p_x_line_rec.source_document_id -- Req Hdr_id
1515           , p_param3                 => 1
1516           , p_long_param1            => p_x_line_rec.line_id
1517           , p_request_type           => OE_GLOBALS.G_UPDATE_REQUISITION
1518           , x_return_status          => l_return_status
1519           );
1520 
1521           IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1522             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1523           ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1524             RAISE FND_API.G_EXC_ERROR;
1525           END IF;
1526 */ -- Commented for IR ISO Tracking bug 7667702
1527 
1528         END IF;
1529       END IF;
1530     END IF; -- Split_by
1531 
1532 /* ============================= */
1533 /* IR ISO Change Management Ends */
1534 
1535 
1536        END IF;
1537 
1538       -- QUOTING changes - log explosion request only for lines in
1539       -- fulfillment phase
1540       IF nvl(p_x_line_rec.transaction_phase_code,'F') = 'F' THEN
1541 
1542       -- log a delayed request to get included items for this item if any.
1543 
1544       l_freeze_method := G_FREEZE_METHOD; /* Bug # 5036404 */
1545      if l_debug_level > 0 then
1546       oe_debug_pub.ADD('Freeze method is :' || l_freeze_method,2);
1547      end if;
1548       IF l_freeze_method = OE_GLOBALS.G_IIFM_ENTRY AND
1549          p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
1550          p_x_line_rec.ato_line_id is NULL AND
1551          p_old_line_rec.ordered_quantity = 0 AND
1552          ( p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
1553            (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT AND
1554             p_x_line_rec.line_id = p_x_line_rec.top_model_line_id))
1555       THEN
1556            p_x_line_rec.explosion_date := null;
1557            l_count := l_count + 1;
1558            OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL(l_count):= p_x_line_rec.line_id;
1559       END IF;
1560 
1561       END IF; -- End if phase is fulfillment
1562       -- END QUOTING changes
1563 
1564       -- Need to Call Shipping Update
1565       l_update_shipping	:= FND_API.G_TRUE;
1566 
1567       -- If the ordered quantity has been reduced then set the flag so
1568       -- that delayed request can check for shipment status.
1569       IF p_x_line_rec.ordered_quantity < p_old_line_rec.ordered_quantity THEN
1570     	   l_ordered_quantity_changed	:= FND_API.G_TRUE;
1571       END IF;
1572       --changes for bug 2315926  Begin
1573 
1574        IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE and
1575            p_x_line_rec.split_by = 'SYSTEM' and
1576            NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT')
1577            OR
1578            (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
1579             p_x_line_rec.split_from_line_id IS NOT NULL AND
1580             nvl(p_x_line_rec.split_by, 'USER') = 'SYSTEM') THEN
1581             -- don't call credit checking for system split when tax value changes.
1582            l_param1 := 'No_Credit_Checking';
1583          if l_debug_level > 0 then
1584            oe_debug_pub.add('System Split - l_param1 is: '||l_param1,1);
1585            oe_debug_pub.ADD('B2315926_1:',2);
1586               oe_debug_pub.add('In the split case, checking for catchweight item',3);
1587            end if;
1588            IF (p_x_line_rec.inventory_item_id IS NOT NULL AND
1589                p_x_line_rec.inventory_item_id <> FND_API.G_MISS_NUM) AND
1590               (p_x_line_rec.ship_from_org_id  IS NOT NULL AND
1591                p_x_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM) THEN
1592                    l_item_rec := OE_Order_Cache.Load_Item (p_x_line_rec.inventory_item_id
1593                             ,p_x_line_rec.ship_from_org_id);
1594                    -- IF  l_item_rec.ont_pricing_qty_source = 1   AND
1595                    IF l_item_rec.ont_pricing_qty_source = 'S' AND -- INVCONV
1596                        l_item_rec.tracking_quantity_ind = 'P' and
1597                        l_item_rec.wms_enabled_flag = 'Y' THEN
1598                        If l_debug_level > 0 Then
1599                           oe_debug_pub.add('Catchweight enabled item',3);
1600                           oe_debug_pub.add('Setting the price flag to Yes');
1601                        End If;
1602                        OE_GLOBALS.G_PRICE_FLAG := 'Y';
1603                    END IF;
1604            END IF;
1605        else
1606         OE_GLOBALS.G_PRICE_FLAG := 'Y';
1607         if l_debug_level > 0 then
1608          oe_debug_pub.ADD('B2315926_2:',2);
1609         end if;
1610        end if;
1611        --changes for bug 2315926 end
1612 
1613      --changes for bug#7491829
1614 
1615        IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE and
1616            p_x_line_rec.split_by = 'SYSTEM' and
1617            NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT') THEN
1618            IF l_debug_level > 0 THEN
1619               oe_debug_pub.add('Logging Reverse Limits delayed request for parent line');
1620               oe_debug_pub.add('Price request code for parent : ' || p_x_line_rec.price_request_code);
1621               oe_debug_pub.add('OLD Price request code for parent : ' || p_old_line_rec.price_request_code);
1622            END IF;
1623                          OE_delayed_requests_Pvt.log_request(
1624                                 p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
1625                                 p_entity_id              => p_x_line_rec.line_id,
1626                                 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
1627                                 p_requesting_entity_id   => p_x_line_rec.line_id,
1628                                 p_request_unique_key1    => 'LINE',
1629                                 p_param1                 => 'SPLIT_ORIG',
1630                                 p_param2                 => p_old_line_rec.price_request_code,
1631                                 p_param3                 => p_old_line_rec.ordered_quantity,
1632                                 p_param4                 => p_x_line_rec.ordered_quantity,
1633                                 p_param5                 => NULL,
1634                                 p_param6                 => NULL,
1635                                 p_request_type           => OE_GLOBALS.G_REVERSE_LIMITS,
1636                                 x_return_status          => l_return_status);
1637 
1638        END IF;
1639 
1640        IF   (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
1641             p_x_line_rec.split_from_line_id IS NOT NULL AND
1642             nvl(p_x_line_rec.split_by, 'USER') = 'SYSTEM') THEN
1643             IF l_debug_level > 0 THEN
1644               oe_debug_pub.add('Logging Reverse Limits delayed request for child line');
1645             END IF;
1646               OE_delayed_requests_Pvt.log_request(
1647                                 p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
1648                                 p_entity_id              => p_x_line_rec.line_id,
1649                                 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
1650                                 p_requesting_entity_id   => p_x_line_rec.line_id,
1651                                 p_request_unique_key1    => 'LINE',
1652                                 p_param1                 => 'SPLIT_NEW',
1653                                 p_param2                 => NULL,
1654                                 p_param3                 => NULL,
1655                                 p_param4                 => NULL,
1656                                 p_param5                 => NULL,
1657                                 p_param6                 => p_x_line_rec.ordered_quantity,
1658                                 p_request_type           => OE_GLOBALS.G_REVERSE_LIMITS,
1659                                 x_return_status          => l_return_status);
1660        END IF;
1661 
1662        --bug#7491829
1663 
1664       OE_GLOBALS.G_TAX_FLAG := 'Y';
1665 
1666       -- bug 1829201, need to recalculate commitment when quantity changes.
1667       IF p_x_line_rec.commitment_id is not null then
1668         l_calculate_commitment_flag := 'Y';
1669 
1670         -- lkxu, bug 1786533 for commitment during line split
1671         IF ( p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
1672              NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT' ) THEN
1673 
1674             l_update_commitment_flag := 'Y';
1675             OE_GLOBALS.g_original_commitment_applied
1676               := Oe_Commitment_Pvt.Get_Commitment_Applied_Amount
1677 		(p_header_id          => p_x_line_rec.header_id ,
1678                  p_line_id            => p_x_line_rec.line_id ,
1679                  p_commitment_id      => p_x_line_rec.commitment_id);
1680         END IF;
1681       END IF;
1682 
1683       -- Freight Rating.
1684       IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
1685          AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
1686                                     (p_x_line_rec.header_id)
1687              = 'OM_CALLED_FREIGHT_RATES' THEN
1688          if l_debug_level > 0 then
1689            oe_debug_pub.add('Log Freight Rating request for qty change. ',3);
1690          end if;
1691            l_get_FTE_freight_rate := 'Y';
1692       END IF;
1693 
1694             /* INVCONV ordered_quantity2 needs to be calculated for
1695       split line process items - CHILD
1696       ============================================================*/
1697       -- INVCONV
1698 
1699       IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
1700          p_x_line_rec.split_from_line_id IS NOT NULL AND
1701          nvl(p_x_line_rec.split_by, 'USER') = 'USER' AND
1702          p_x_line_rec.line_category_code <> 'RETURN'
1703          THEN
1704                 /*
1705           	p_x_line_rec.ordered_quantity2 :=
1706            		oe_line_util.Calculate_Ordered_Quantity2(p_x_line_rec);
1707            	*/
1708            	/* OPM - NC 3/8/02 Bug#2046641
1709            	   Commented the above call and added the call to calculate_dual_quantity */
1710                 IF (OE_CODE_CONTROL.CODE_RELEASE_LEVEL <= '110507') OR NOT(OE_GLOBALS.G_UI_FLAG) THEN
1711 
1712            						if l_debug_level > 0 then
1713                 				oe_debug_pub.add('about to call calculate_dual_quantity 1' );
1714                       end if;
1715                     oe_line_util.calculate_dual_quantity(
1716                          p_ordered_quantity => p_x_line_rec.ordered_quantity
1717                         ,p_old_ordered_quantity => NULL
1718                         ,p_ordered_quantity2 => p_x_line_rec.ordered_quantity2
1719                         ,p_old_ordered_quantity2 => NULL
1720                         ,p_ordered_quantity_uom  => p_x_line_rec.order_quantity_uom
1721                         ,p_ordered_quantity_uom2 => p_x_line_rec.ordered_quantity_uom2
1722                         ,p_inventory_item_id     => p_x_line_rec.inventory_item_id
1723                         ,p_ship_from_org_id      => p_x_line_rec.ship_from_org_id
1724                         ,x_ui_flag 		 => 0
1725                         ,x_return_status         => l_return_code
1726                         );
1727 
1728 
1729                         IF l_return_code <> 0 THEN -- INVCONV
1730 	     										 IF l_return_status = -1
1731 	     										 THEN
1732 															p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
1733 														else
1734 														p_x_line_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1735 														END IF;
1736 												END IF;
1737 
1738 
1739 
1740                 END IF;  -- Bug#2046641
1741            END IF;      -- INVCONV
1742 
1743       IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
1744        /* INVCONV 02/JUN/00 ordered_quantity2 needs to be calculated
1745         for split line process items  - PARENT
1746         =======================================================*/
1747         IF p_x_line_rec.split_action_code = 'SPLIT' AND
1748         p_x_line_rec.line_category_code <> 'RETURN' AND
1749         p_x_line_rec.split_by = 'USER'
1750         THEN
1751                 /*
1752             	p_x_line_rec.ordered_quantity2 :=
1753                      oe_line_util.Calculate_Ordered_Quantity2(p_x_line_rec);
1754                 */
1755                 /* OPM - NC 3/8/02 Bug#2046641
1756            	   Commented the above call and added the call to calculate_dual_quantity */
1757                 IF (OE_CODE_CONTROL.CODE_RELEASE_LEVEL <= '110507') OR NOT(OE_GLOBALS.G_UI_FLAG) THEN
1758                     if l_debug_level > 0 then
1759                 	oe_debug_pub.add('about to call calculate_dual_quantity 2' );
1760                       end if;
1761 
1762                     oe_line_util.calculate_dual_quantity(
1763                          p_ordered_quantity => p_x_line_rec.ordered_quantity
1764                         ,p_old_ordered_quantity => NULL
1765                         ,p_ordered_quantity2 => p_x_line_rec.ordered_quantity2
1766                         ,p_old_ordered_quantity2 => NULL
1767                         ,p_ordered_quantity_uom  => p_x_line_rec.order_quantity_uom
1768                         ,p_ordered_quantity_uom2 => p_x_line_rec.ordered_quantity_uom2
1769                         ,p_inventory_item_id     => p_x_line_rec.inventory_item_id
1770                         ,p_ship_from_org_id      => p_x_line_rec.ship_from_org_id
1771                         ,x_ui_flag 		 => 0
1772                         ,x_return_status         => l_return_code
1773                         );
1774 
1775 
1776                         IF l_return_code <> 0 THEN -- INVCONV
1777 	     										 IF l_return_status = -1
1778 	     										 THEN
1779 															p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
1780 														else
1781 														p_x_line_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1782 														END IF;
1783 												END IF;
1784 
1785 
1786 
1787 
1788 
1789                 END IF;  -- OPM Bug#2046641
1790 
1791         END IF;      -- OPM B1661023 04/02/01
1792 
1793         /* OPM END */
1794 
1795 	   oe_sales_can_util.check_constraints
1796 		      (p_x_line_rec	=> p_x_line_rec,
1797 		       p_old_line_rec	=> p_old_line_rec,
1798 		       x_return_status	=> l_return_status);
1799 	    IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1800 	      IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1801 	 		p_x_line_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1802               ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1803 			p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
1804               END IF;
1805 	    END IF;
1806 
1807 
1808 
1809 	    -- Additional task: Log the delayed request for verify payment
1810 	    -- when order quantity changes and the Payment Type Code
1811 	    -- is not CREDIT CARD and the Line is Booked.
1812 	    -- If the payment type is CREDIT CARD then the delayed req should be
1813 	    -- logged only if the quantity has increased.
1814 
1815 	    IF OE_Order_Cache.g_header_rec.payment_type_code = 'CREDIT_CARD' THEN
1816 	      IF  p_x_line_rec.ordered_quantity > p_old_line_rec.ordered_quantity
1817                 THEN
1818                 -- Log request here if commitment id is null
1819                 if p_x_line_rec.commitment_id is null then
1820                  if l_debug_level > 0 then
1821            	  oe_debug_pub.ADD('Log Verify Payment delayed request in Ord Qty');
1822                  end if;
1823 		  l_verify_payment_flag := 'Y';
1824 	        end if;
1825               END IF;
1826               -- if this is a prepaid order, also log delayed request if ordered
1827               -- quantity decreases, as refund may need to be issued.
1828               IF OE_PrePayment_UTIL.is_prepaid_order(p_x_line_rec.header_id)
1829                       = 'Y'  AND p_x_line_rec.booked_flag ='Y' THEN
1830                   if l_debug_level > 0 then
1831            	    oe_debug_pub.ADD('Log Verify Payment delayed request in Ord Qty for prepayment', 3);
1832                   end if;
1833 		    l_verify_payment_flag := 'Y';
1834               END IF;
1835 	    ELSE
1836 		  IF p_x_line_rec.booked_flag ='Y' THEN
1837                    if l_debug_level > 0 then
1838 	 	    oe_debug_pub.ADD('Log Verify Payment delayed request for change in Order Qty');
1839 
1840                    end if;
1841 
1842                    -- Start fix for bug# 4378531
1843                    IF l_debug_level  > 0 THEN
1844                     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 ) ) ;
1845                    END IF;
1846 
1847                    OE_HOLDS_PUB.Check_Holds
1848                       (  p_api_version    => 1.0
1849                        , p_header_id      => p_x_line_rec.header_id
1850                        , p_line_id        => p_x_line_rec.line_id
1851                        , p_hold_id        => 1
1852                        , p_entity_code    => 'O'
1853                        , p_entity_id      => p_x_line_rec.header_id
1854                        , x_result_out     => l_hold_result
1855                        , x_msg_count      => l_msg_count
1856                        , x_msg_data       => l_msg_data
1857                        , x_return_status  => l_return_status
1858                       );
1859 
1860                    IF l_debug_level  > 0 THEN
1861                     oe_debug_pub.add('CHECKING FOR CANCEL FLAG : ' || p_x_line_rec.cancelled_flag ) ;
1862                    END IF;
1863 
1864                    IF NOT( l_hold_result = FND_API.G_FALSE AND p_x_line_rec.cancelled_flag='Y') THEN
1865                     l_verify_payment_flag := 'Y';
1866                    END IF;
1867 
1868                    IF l_debug_level  > 0 THEN
1869                     oe_debug_pub.add('CHECKING FOR VERIFY PAYMENT FLAG : ' || l_verify_payment_flag ) ;
1870                    END IF;
1871                    -- End fix for bug# 4378531
1872 
1873 		  END IF;
1874          	END IF;
1875 
1876        END IF;
1877 
1878 
1879         -- Populate pricing quantity
1880     	IF p_x_line_rec.ordered_quantity <> FND_API.G_MISS_NUM And
1881 		p_x_line_rec.pricing_quantity_uom is not null and
1882 		p_x_line_rec.pricing_quantity_uom <> FND_API.G_MISS_CHAR and
1883 		p_x_line_rec.order_quantity_uom is not null  and
1884 		p_x_line_rec.order_quantity_uom <> FND_API.G_MISS_CHAR
1885 	Then
1886             l_temp_pricing_quantity :=
1887 		OE_Order_Misc_Util.convert_uom(
1888 		p_x_line_rec.inventory_item_id,
1889 		p_x_line_rec.order_quantity_uom,
1890 		p_x_line_rec.pricing_quantity_uom,
1891 		p_x_line_rec.ordered_quantity
1892 					);
1893 
1894 	    IF  l_temp_pricing_quantity >= 0 THEN
1895 	            p_x_line_rec.Pricing_quantity:=l_temp_pricing_quantity;
1896 		    oe_debug_pub.add('temp pricing quantity:'||l_temp_pricing_quantity);
1897 	    END IF;
1898 
1899 	End If; -- Pricing Quantity
1900       -- Pack J catchweight
1901        IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
1902        null; -- INVCONV COMMENTED OUT FOR NOW
1903           -- Calc_Catchweight_Return_qty2(p_x_line_rec => p_x_line_rec INVCONV COMMENTED OUT FOR NOW
1904           --                           , p_old_line_rec => p_old_line_rec); INVCONV COMMENTED OUT FOR NOW
1905        END IF;
1906     END IF;
1907 
1908     IF NOT OE_GLOBALS.Equal(p_x_line_rec.order_quantity_uom,p_old_line_rec.order_quantity_uom)
1909     THEN
1910 	-- Need to Call Shipping Update
1911     	l_update_shipping	:= FND_API.G_TRUE;
1912         OE_GLOBALS.G_PRICE_FLAG := 'Y';
1913         OE_GLOBALS.G_TAX_FLAG := 'Y';
1914     END IF;
1915 
1916     -- bug 1829201, need to recalculate commitment.
1917     --IF p_x_line_rec.commitment_id is not null then
1918     --  l_calculate_commitment_flag := 'Y';
1919     --END IF;
1920 
1921 -- INVCONV
1922     --OPM 02/JUN/00   Test for changes to process attributes
1923     --                (ordered_quantity2, preferred_grade)
1924     --------------------------------------------------------
1925     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity2,p_old_line_rec.ordered_quantity2) -- peter
1926     THEN
1927         if l_debug_level > 0 then
1928        			oe_debug_pub.add('Ordered Qty2 has changed',1); -- INVCONV
1929        			oe_debug_pub.add('New Ordered Qty2 : ' || p_x_line_rec.ordered_quantity2, 1);
1930        			oe_debug_pub.add('Old Ordered Qty2 : ' ||
1931                                 p_old_line_rec.ordered_quantity2, 1);
1932       	end if;
1933 
1934         l_update_shipping     := FND_API.G_TRUE;
1935         -- start 2046190
1936              IF dual_uom_control   --   INVCONV Process_Characteristics
1937                              (p_x_line_rec.inventory_item_id
1938                              ,p_x_line_rec.ship_from_org_id
1939                              ,l_item_rec) THEN
1940 
1941                 -- IF l_item_rec.ont_pricing_qty_source = 1 THEN INVCONV
1942                 IF l_item_rec.ont_pricing_qty_source = 'S' THEN -- INVCONV
1943                  -- need to call pricing
1944                       if l_debug_level > 0 then
1945                 				oe_debug_pub.add('dual uom  - ont_pricing_qty_source = ' || l_item_rec.ont_pricing_qty_source );
1946                       end if;
1947 								OE_GLOBALS.G_PRICE_FLAG := 'Y';
1948         				OE_GLOBALS.G_TAX_FLAG := 'Y';
1949 
1950         				END IF;
1951 
1952           oe_sales_can_util.check_constraints
1953 		      (p_x_line_rec	=> p_x_line_rec,
1954 		       p_old_line_rec	=> p_old_line_rec,
1955 		       x_return_status	=> l_return_status);
1956 	    		IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1957 	      		IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1958 	 							p_x_line_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1959             ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1960 								p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
1961             END IF;
1962 	    		END IF;
1963 
1964 
1965    			END IF; -- IF dual_uom_control   --   INVCONV Process_Characteristics
1966 -- end   2046190
1967 
1968 --      NULL;
1969     END IF; -- IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity2,p_old_line_rec.ordered_quantity2) -- peter
1970 
1971     IF NOT OE_GLOBALS.Equal(p_x_line_rec.preferred_grade,p_old_line_rec.preferred_grade
1972 )
1973     THEN
1974         -- Need to Call Shipping Update
1975         l_update_shipping     := FND_API.G_TRUE;
1976         OE_GLOBALS.G_PRICE_FLAG := 'Y';
1977         OE_GLOBALS.G_TAX_FLAG := 'Y';
1978 
1979         IF p_x_line_rec.commitment_id IS NOT NULL THEN
1980           l_get_commitment_bal := 'Y';
1981         END IF;
1982     END IF;
1983     --INVCONV  02/JUN/00 END
1984     --=================
1985 
1986     IF NOT OE_GLOBALS.Equal(p_x_line_rec.payment_term_id,p_old_line_rec.payment_term_id)
1987     THEN
1988 
1989         -- Need to Call Pricing: bug 1504821
1990         OE_GLOBALS.G_PRICE_FLAG := 'Y';
1991 
1992 	/* Additional task: If the payment type is not CREDIT CARD
1993 	then if the payment term changes for a line which is Booked
1994 	it should log a delayed request for Verify Payment */
1995 
1996 	IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
1997 
1998           if p_x_line_rec.booked_flag ='Y' then
1999 
2000             IF OE_PrePayment_UTIL.IS_MULTIPLE_PAYMENTS_ENABLED = TRUE THEN
2001 
2002               if l_debug_level > 0 then
2003                  oe_debug_pub.ADD('multpayments: logging delayed request for verify payment as payment term is changed');
2004               end if;
2005               l_verify_payment_flag := 'Y';
2006 
2007 
2008 	    ELSIF NVL(OE_Order_Cache.g_header_rec.payment_type_code, 'NULL') <> 'CREDIT_CARD'
2009 	    THEN
2010 
2011               if l_debug_level > 0 then
2012 	        oe_debug_pub.ADD('logging delayed request for verify payment as payment term is changed');
2013               end if;
2014 	      l_verify_payment_flag := 'Y';
2015 
2016 	    END IF;   -- if multiple_payments is enabled
2017 
2018           end if; -- if booked_flag is Y
2019 
2020         END IF; -- if operation is update
2021 
2022     END IF;  -- if payment_term_id has changed
2023 
2024     IF NOT OE_GLOBALS.Equal(p_x_line_rec.price_list_id,p_old_line_rec.price_list_id)
2025     THEN
2026         OE_GLOBALS.G_PRICE_FLAG := 'Y';
2027 
2028         IF p_x_line_rec.commitment_id IS NOT NULL THEN
2029           l_get_commitment_bal := 'Y';
2030         END IF;
2031     END IF;
2032 
2033     IF NOT OE_GLOBALS.Equal(p_x_line_rec.pricing_date,p_old_line_rec.pricing_date)
2034     THEN
2035         OE_GLOBALS.G_PRICE_FLAG := 'Y';
2036 
2037        -- bug 2072014, need to recalculate price if pricing_date is updated BEGIN
2038         IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
2039 	   OE_GLOBALS.Equal(p_x_line_rec.reference_line_id,p_old_line_rec.reference_line_id) THEN --bug 5260190
2040             p_x_line_rec.calculate_price_flag := 'Y';
2041         END IF;
2042        -- bug 2072014, need to recalculate price if pricing_date is updated END
2043 
2044         IF p_x_line_rec.commitment_id IS NOT NULL THEN
2045           l_get_commitment_bal := 'Y';
2046         END IF;
2047     END IF;
2048 
2049     IF NOT OE_GLOBALS.Equal(p_x_line_rec.pricing_quantity,p_old_line_rec.pricing_quantity)
2050     THEN
2051        --commenting the below line for bug 2315926
2052         --OE_GLOBALS.G_PRICE_FLAG := 'Y';
2053 
2054         -- bug 1829201, need to recalculate commitment.
2055         IF p_x_line_rec.commitment_id is not null then
2056           l_calculate_commitment_flag := 'Y';
2057         END IF;
2058     END IF;
2059 
2060     IF NOT OE_GLOBALS.Equal(p_x_line_rec.pricing_quantity_uom,p_old_line_rec.pricing_quantity_uom)
2061     THEN
2062        --commenting the below line for bug 2315926
2063         --OE_GLOBALS.G_PRICE_FLAG := 'Y';
2064 
2065         -- bug 1829201, need to recalculate commitment.
2066         IF p_x_line_rec.commitment_id is not null then
2067           l_calculate_commitment_flag := 'Y';
2068         END IF;
2069     END IF;
2070 
2071     IF NOT OE_GLOBALS.Equal(p_x_line_rec.reference_line_id,p_old_line_rec.reference_line_id)
2072     THEN
2073       IF OE_GLOBALS.G_RETURN_CHILDREN_MODE = 'N' THEN
2074        if l_debug_level > 0 then
2075         oe_debug_pub.ADD('RMA: logging delayed request ');
2076        end if;
2077         IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE OR
2078            p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
2079 
2080            IF p_x_line_rec.split_from_line_id is NULL THEN -- Bug 5676051
2081 
2082            OE_delayed_requests_Pvt.log_request(
2083 				p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
2084                 p_entity_id              => p_x_line_rec.line_id,
2085 			    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
2086 			    p_requesting_entity_id   => p_x_line_rec.line_id,
2087                 p_param1    => p_x_line_rec.operation,  --Bug 4651421
2088                 p_param2    => p_x_line_rec.split_by,
2089                 p_param3    => p_x_line_rec.split_action_code,
2090                 p_param4    => to_char(p_x_line_rec.split_from_line_id),
2091                 p_request_type      => OE_GLOBALS.G_INSERT_RMA,
2092                 x_return_status     => l_return_status);
2093            END IF; -- Bug 5676051
2094 
2095           /* BUG 2013611 and 2109230 */
2096           If p_x_line_rec.calculate_price_flag in ('N','P') THEN
2097             IF (OE_GLOBALS.G_UI_FLAG) THEN
2098              if l_debug_level > 0 then
2099               oe_debug_pub.add('Log REVERSE_LIMITS delayed request for ENTITY LINE return',1);
2100              end if;
2101               OE_delayed_requests_Pvt.log_request(
2102                                 p_entity_code 		 => OE_GLOBALS.G_ENTITY_LINE,
2103 				p_entity_id              => p_x_line_rec.line_id,
2104 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
2105 				p_requesting_entity_id   => p_x_line_rec.line_id,
2106 				p_request_unique_key1  	 => 'LINE',
2107 		 		p_param1                 => 'RETURN',
2108 		 		p_param2                 => NULL,
2109 		 		p_param3                 => NULL,
2110 		 		p_param4                 => NULL,
2111 		 		p_param5                 => NULL,
2112 		 		p_param6                 => p_x_line_rec.ordered_quantity,
2113 		 		p_request_type           => OE_GLOBALS.G_REVERSE_LIMITS,
2114 		 		x_return_status          => l_return_status);
2115             ELSIF NOT (OE_GLOBALS.G_UI_FLAG) THEN
2116              if l_debug_level > 0 then
2117               oe_debug_pub.add('Log REVERSE_LIMITS delayed request for ENTITY ALL line return',1);
2118              end if;
2119               OE_delayed_requests_Pvt.log_request(
2120                                 p_entity_code 		 => OE_GLOBALS.G_ENTITY_ALL,
2121 				p_entity_id              => p_x_line_rec.line_id,
2122 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
2123 				p_requesting_entity_id   => p_x_line_rec.line_id,
2124 				p_request_unique_key1  	 => 'LINE',
2125 		 		p_param1                 => 'RETURN',
2126 		 		p_param2                 => NULL,
2127 		 		p_param3                 => NULL,
2128 		 		p_param4                 => NULL,
2129 		 		p_param5                 => NULL,
2130 		 		p_param6                 => p_x_line_rec.ordered_quantity,
2131 		 		p_request_type           => OE_GLOBALS.G_REVERSE_LIMITS,
2132 		 		x_return_status          => l_return_status);
2133             END IF;
2134 	  END IF;
2135           /* BUG 2013611 and 2109230 END */
2136         END IF;
2137        END IF;
2138 
2139         -- bug 1917869
2140 	IF p_x_line_rec.calculate_price_flag in ('N','P') then
2141 	  l_copy_adjustments := TRUE;
2142         END IF;
2143 
2144 	l_copy_pricing_attributes := TRUE;
2145 	If p_x_line_rec.calculate_price_flag = 'N' then
2146 		p_x_line_rec.calculate_price_flag := 'P';
2147 	end if;
2148 
2149     END IF;
2150 
2151     IF NOT OE_GLOBALS.Equal(p_x_line_rec.request_date,p_old_line_rec.request_date)
2152     THEN
2153 
2154 	 -- Need to Call Shipping Update
2155     	 l_update_shipping	:= FND_API.G_TRUE;
2156 
2157 	 -- Call Pricing
2158          OE_GLOBALS.G_PRICE_FLAG := 'Y';
2159 
2160          IF p_x_line_rec.commitment_id IS NOT NULL THEN
2161            l_get_commitment_bal := 'Y';
2162          END IF;
2163 
2164        /*
2165        ** Commented as part of 1655720 after discussion with zbutt
2166        IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
2167           p_x_line_rec.booked_flag ='Y'
2168        THEN
2169           if l_debug_level > 0 then
2170             oe_debug_pub.ADD('logging delayed request for Verify Payment
2171                                     forchange in Request date');
2172           end if;
2173             l_verify_payment_flag := 'Y';
2174        END IF;
2175        */
2176 
2177     END IF;
2178 
2179     IF NOT OE_GLOBALS.Equal(p_x_line_rec.schedule_ship_date,p_old_line_rec.schedule_ship_date)
2180     THEN
2181 
2182 	  -- Need to Call Shipping Update
2183     	  l_update_shipping	:= FND_API.G_TRUE;
2184 	   --  Taking out this because the TAX request should get fired only
2185 	   --  when the tax_date changes. And tax_date will change if the
2186 	   --  schedule_ship_date changes.
2187         IF p_old_line_rec.schedule_ship_date IS NOT NULL THEN
2188            l_3a7_attribute_change := FND_API.G_TRUE;
2189         END IF;
2190         --  OE_GLOBALS.G_TAX_FLAG := 'Y';
2191 
2192 	 -- Call Pricing
2193          -- For performance bug 1351111, turning off Pricing for scheduling
2194 
2195          /* Commenting out for 1419204
2196          l_turn_off_pricing := FND_PROFILE.VALUE('ONT_NO_PRICING_AT_SCHEDULING');
2197          -- by default, turn off pricing at scheduling
2198          IF l_turn_off_pricing = 'N' THEN
2199            OE_GLOBALS.G_PRICE_FLAG := 'Y';
2200          End If;
2201          */
2202 
2203          IF p_x_line_rec.commitment_id IS NOT NULL THEN
2204            l_get_commitment_bal := 'Y';
2205          END IF;
2206 
2207         -- Freight Rating
2208         IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
2209            AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
2210                                       (p_x_line_rec.header_id)
2211                = 'OM_CALLED_FREIGHT_RATES' THEN
2212            if l_debug_level > 0 then
2213              oe_debug_pub.add('Log Freight Rating request for schedule ship date. ',3);
2214            end if;
2215              l_get_FTE_freight_rate := 'Y';
2216         END IF;
2217 
2218 	  /* Additional task : Log delayed request for verify payment
2219 	  when payment type is not CREDIT CARD and when schedule date
2220 	  has changed for a booked Line  and it is not a drop-ship line*/
2221 
2222     -- modified for bug 1655720 to not perform credit checking if
2223     -- schedule_ship_date changes.
2224     /***
2225     IF (p_x_line_rec.source_type_code <> OE_GLOBALS.G_SOURCE_EXTERNAL) THEN
2226 
2227 	  IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
2228 	  THEN
2229 	     IF NVL(OE_Order_Cache.g_header_rec.payment_type_code, 'NULL') <> 'CREDIT_CARD' AND
2230              p_x_line_rec.booked_flag ='Y' AND
2231              (to_date(p_x_line_rec.schedule_ship_date, 'DD/MM/YYYY') <>
2232               to_date(p_x_line_rec.request_date, 'DD/MM/YYYY'))
2233 	     THEN
2234                if l_debug_level > 0 then
2235 		  oe_debug_pub.ADD('logging delayed request for Verify Payment
2236                                      for change in Scheduled Ship date');
2237                end if;
2238 		  l_verify_payment_flag := 'Y';
2239 	     END IF;
2240 	  END IF;
2241 
2242      END IF;
2243      ***/
2244 
2245        if l_debug_level > 0 then
2246 	 oe_debug_pub.add('opr = '||p_x_line_rec.operation);
2247        end if;
2248 
2249 /* 7576948: IR ISO Change Management project Start */
2250 --
2251 -- This program unit will track the specific change in Ordered Quantity
2252 -- and/or Schedule Ship Date on an internal sales order line shipment,
2253 -- and in the event of any change in values, it will log a delayed request
2254 -- of type OE_Globals.G_UPDATE_REQUISITION.
2255 --
2256 -- This delayed request will be logged only if global OE_Internal_Requisi
2257 -- tion_Pvt.G_Update_ISO_From_Req set to FALSE. If this global is TRUE
2258 -- then it means, the change requests for quantity/date or cancellation
2259 -- request is initiated by internal requisition user, in which case, it is
2260 -- not required to log the delayed request for updating the change to the
2261 -- requesting organization. System will also check that global OE_SALES_CAN
2262 -- _UTIL.G_IR_ISO_HDR_CANCEL, and will log a delayed request only if it is
2263 -- FALSE. If this global is TRUE then signifies that it is a case of full
2264 -- internal sales order header cancellation. Thus, in the event of full
2265 -- order cancellation, we only need to inform Purchasing about the
2266 -- cancellation. There is no need to provide specific line level information.
2267 -- Additionally, while logging a delayed request specific to Schedule Ship
2268 -- Date change, system will ensure that it should be allowed via Purchasing
2269 -- profile 'POR: Sync Up Need By date on IR with OM'.
2270 --
2271 -- While logging the delayed request, we will log it for Order Header or
2272 -- Order Line entity, while Entity id will be the Header_id or Line_id
2273 -- respectively. In addition to this, we will even pass Unique_Params value
2274 -- to make this request very specific to Requisition Header or Requisition
2275 -- Line.
2276 --
2277 -- Please refer to following delayed request params with their meaning
2278 -- useful while logging the delayed request -
2279 --
2280 -- P_entity_code        Entity for which delayed request has to be logged.
2281 --                      In this project it can be OE_Globals.G_Entity_Line
2282 --                      or OE_Globals.G_Entity_Header
2283 -- P_entity_id          Primary key of the entity record. In this project,
2284 --                      it can be Order Line_id or Header_id
2285 -- P_requesting_entity_code Which entity has requested this delayed request to
2286 --                          be logged! In this project it will be OE_Globals.
2287 --                          G_Entity_Line or OE_Globals.G_Entity_Header
2288 -- P_requesting_entity_id       Primary key of the requesting entity. In this
2289 --                              project, it is Line_id or Header_id
2290 -- P_request_type       Indicates which business logic (or which procedure)
2291 --                      should be executed. In this project, it is OE_Global
2292 --                      s.G_UPDATE_REQUISITION
2293 -- P_request_unique_key1        Additional argument in form of parameters.
2294 --                              In this project, it will denote the Sales Order
2295 --                              Header id
2296 -- P_request_unique_key2        Additional argument in form of parameters.
2297 --                              In this project, it will denote the Requisition
2298 --                              Header id
2299 -- P_request_unique_key3        Additional argument in form of parameters. In
2300 --                              this project, it will denote the Requistion Line
2301 --                              id
2302 -- P_param1     Additional argument in form of parameters. In this project, it
2303 --              will denote net change in order quantity with respective single
2304 --              requisition line. If it is greater than 0 then it is an increment
2305 --              in the quantity, while if it is less than 0 then it is a decrement
2306 --              in the ordered quantity. If it is 0 then it indicates there is no
2307 --              change in ordered quantity value
2308 -- P_param2     Additional argument in form of parameters. In this project, it
2309 --              will denote whether internal sales order is cancelled or not. If
2310 --              it is cancelled then respective Purchasing api will be called to
2311 --              trigger the requisition header cancellation. It accepts a value of
2312 --              Y indicating requisition header has to be cancelled.
2313 -- P_param3     Additional argument in form of parameters. In this project, it
2314 --              will denote the number of sales order lines cancelled while order
2315 --              header is (Full/Partial) cancelled.
2316 -- p_date_param1        Additional date argument in form of parameters. In this
2317 --                      project, it will denote the change in Schedule Ship Date
2318 --                      with to respect to single requisition line.
2319 -- P_Long_param1        Additional argument in form of parameters. In this project,
2320 --                      it will store all the sales order line_ids, which are getting
2321 --                      cancelled while order header gets cancelled (Full/Partial).
2322 --                      These Line_ids will be separated by a delimiter comma ','
2323 --
2324 -- For details on IR ISO CMS project, please refer to FOL >
2325 -- OM Development > OM GM > 12.1.1 > TDD > IR_ISO_CMS_TDD.doc
2326 --
2327 
2328 /* -- Commented for IR ISO : Starts
2329 
2330 	 IF (p_x_line_rec.order_source_id = 10) AND
2331 	    (p_old_line_rec.schedule_ship_date IS NOT NULL) THEN
2332             FND_MESSAGE.SET_NAME('ONT','OE_CHG_CORR_REQ');
2333             -- { start fix for 2648277
2334 	    FND_MESSAGE.SET_TOKEN('CHG_ATTR',
2335                OE_Order_Util.Get_Attribute_Name('schedule_ship_date'));
2336             -- end fix for 2648277}
2337 	   OE_MSG_PUB.Add;
2338       END IF;
2339 
2340       END IF;
2341 */ -- Commented for IR ISO Ends.
2342 
2343 
2344 /* -- Commented for IR ISO Tracking bug 7667702
2345  *
2346    IF (p_x_line_rec.order_source_id = 10) THEN
2347      IF (p_old_line_rec.schedule_ship_date IS NOT NULL) OR
2348         (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
2349          p_x_line_rec.split_from_line_id IS NOT NULL AND
2350          nvl(p_x_line_rec.split_by, 'X') = 'SYSTEM') THEN
2351        -- The above new OR condition is needed to ensure that a data
2352        -- change can happen either as a direct Update operation, OR
2353        -- during split of order lines, where original record will be
2354        -- Updated while new record will be Created
2355 
2356        l_po_NeedByDate_Update := NVL(FND_PROFILE.VALUE('POR_SYNC_NEEDBYDATE_OM'),'NO');
2357 
2358        IF l_debug_level > 0 THEN
2359          oe_debug_pub.add(' Need By Date update is allowed ? '||l_po_NeedByDate_Update);
2360        END IF;
2361 
2362        IF NOT OE_Internal_Requisition_Pvt.G_Update_ISO_From_Req
2363          AND NOT OE_SALES_CAN_UTIL.G_IR_ISO_HDR_CANCEL AND
2364          l_po_NeedByDate_Update = 'YES' THEN
2365 
2366          -- Log a delayed request to update the change in Schedule Ship Date to
2367          -- Requisition Line. This request will be logged only if the change is
2368          -- not initiated from Requesting Organization, and it is not a case of
2369          -- Internal Sales Order Full Cancellation. It will even not be logged
2370          -- Purchasing profile option does not allow update of Need By Date when
2371          -- Schedule Ship Date changes on internal sales order line
2372 
2373          OE_delayed_requests_Pvt.log_request
2374          ( p_entity_code            => OE_GLOBALS.G_ENTITY_LINE
2375          , p_entity_id              => p_x_line_rec.line_id
2376          , p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE
2377          , p_requesting_entity_id   => p_x_line_rec.line_id
2378          , p_request_unique_key1    => p_x_line_rec.header_id  -- Order Hdr_id
2379          , p_request_unique_key2    => p_x_line_rec.source_document_id -- Req Hdr_id
2380          , p_request_unique_key3    => p_x_line_rec.source_document_line_id -- Req Line_id
2381          , p_date_param1            => p_x_line_rec.schedule_ship_date
2382          , p_request_type           => OE_GLOBALS.G_UPDATE_REQUISITION
2383          , x_return_status          => l_return_status
2384          );
2385 
2386         IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2387           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2388         ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2389           RAISE FND_API.G_EXC_ERROR;
2390         END IF;
2391 
2392        END IF;
2393      END IF; -- Split_by
2394    END IF;  -- Order Source is 10.
2395 */ -- Commented for IR ISO Tracking bug 7667702
2396 
2397 /* ============================= */
2398 /* IR ISO Change Management Ends */
2399 
2400 
2401     END IF;
2402 
2403     IF NOT OE_GLOBALS.Equal(p_x_line_rec.schedule_arrival_date,p_old_line_rec.schedule_arrival_date)
2404     THEN
2405 
2406         -- Freight Rating
2407         IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
2408            AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
2409                                       (p_x_line_rec.header_id)
2410                = 'OM_CALLED_FREIGHT_RATES' THEN
2411            if l_debug_level > 0 then
2412              oe_debug_pub.add('Log Freight Rating request for schedule arrivale date. ',3);
2413            end if;
2414              l_get_FTE_freight_rate := 'Y';
2415         END IF;
2416 
2417 /* 7576948: IR ISO Change Management project Start */
2418 --
2419 -- For details on IR ISO CMS project, please refer to FOL >
2420 -- OM Development > OM GM > 12.1.1 > TDD > IR_ISO_CMS_TDD.doc
2421 --
2422 
2423 
2424    IF (p_x_line_rec.order_source_id = 10) THEN
2425      IF (p_old_line_rec.schedule_arrival_date IS NOT NULL) OR
2426         (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
2427          p_x_line_rec.split_from_line_id IS NOT NULL AND
2428          nvl(p_x_line_rec.split_by, 'X') = 'SYSTEM') THEN
2429        -- The above new OR condition is needed to ensure that a data
2430        -- change can happen either as a direct Update operation, OR
2431        -- during split of order lines, where original record will be
2432        -- Updated while new record will be Created
2433 
2434        l_po_NeedByDate_Update := NVL(FND_PROFILE.VALUE('POR_SYNC_NEEDBYDATE_OM'),'NO');
2435 
2436        IF l_debug_level > 0 THEN
2437          oe_debug_pub.add(' Need By Date update is allowed ? '||l_po_NeedByDate_Update);
2438        END IF;
2439 
2440        IF NOT OE_Internal_Requisition_Pvt.G_Update_ISO_From_Req
2441          AND NOT OE_SALES_CAN_UTIL.G_IR_ISO_HDR_CANCEL AND
2442          OE_Schedule_GRP.G_ISO_Planning_Update THEN -- Added for IR ISO Tracking bug 7667702
2443          -- l_po_NeedByDate_Update = 'YES' THEN -- Commented for IR ISO Tracking bug 7667702
2444          IF l_po_NeedByDate_Update = 'YES' THEN -- Added for IR ISO Tracking bug 7667702
2445 
2446          -- Log a delayed request to update the change in Schedule Arrival Date to
2447          -- Requisition Line. This request will be logged only if the change is
2448          -- not initiated from Requesting Organization, and it is not a case of
2449          -- Internal Sales Order Full Cancellation. It will even not be logged
2450          -- Purchasing profile option does not allow update of Need By Date when
2451          -- Schedule Arrival Date changes on internal sales order line
2452 
2453          OE_delayed_requests_Pvt.log_request
2454          ( p_entity_code            => OE_GLOBALS.G_ENTITY_LINE
2455          , p_entity_id              => p_x_line_rec.line_id
2456          , p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE
2457          , p_requesting_entity_id   => p_x_line_rec.line_id
2458          , p_request_unique_key1    => p_x_line_rec.header_id  -- Order Hdr_id
2459          , p_request_unique_key2    => p_x_line_rec.source_document_id -- Req Hdr_id
2460          , p_request_unique_key3    => p_x_line_rec.source_document_line_id -- Req Line_id
2461          , p_date_param1            => p_x_line_rec.schedule_arrival_date
2462 -- Note: p_date_param1 is used for both Schedule_Ship_Date and
2463 -- Schedule_Arrival_Date, as while executing G_UPDATE_REQUISITION delayed
2464 -- request via OE_Process_Requisition_Pvt.Update_Internal_Requisition,
2465 -- it can expect change with respect to Ship or Arrival date. Thus, will
2466 -- not raise any issues.
2467          , p_request_type           => OE_GLOBALS.G_UPDATE_REQUISITION
2468          , x_return_status          => l_return_status
2469          );
2470 
2471          IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2472            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2473          ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2474            RAISE FND_API.G_EXC_ERROR;
2475          END IF;
2476 
2477          ELSE -- Added for IR ISO Tracking bug 7667702
2478            IF l_debug_level > 0 THEN
2479              oe_debug_pub.add(' Need By Date is not allowed to update. Updating MTL_Supply only',5);
2480            END IF;
2481 
2482            OE_SCHEDULE_UTIL.Update_PO(p_x_line_rec.schedule_arrival_date,
2483                 p_x_line_rec.source_document_id,
2484                 p_x_line_rec.source_document_line_id);
2485          END IF;
2486 
2487        END IF;
2488      END IF; -- Split_by
2489    END IF;  -- Order Source is 10.
2490 
2491 /* ============================= */
2492 /* IR ISO Change Management Ends */
2493 
2494 
2495     END IF;
2496 
2497     IF NOT OE_GLOBALS.Equal(p_x_line_rec.shipment_priority_code,p_old_line_rec.shipment_priority_code)
2498     THEN
2499 	-- Need to Call Shipping Update
2500     	l_update_shipping	:= FND_API.G_TRUE;
2501     END IF;
2502 
2503     IF NOT OE_GLOBALS.Equal(p_x_line_rec.shipped_quantity,p_old_line_rec.shipped_quantity)
2504     THEN
2505 		--IF (p_x_line_rec.ship_set_id IS NOT NULL ) THEN
2506           --OE_delayed_requests_Pvt.log_request(
2507 	     --p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
2508           --p_entity_id         => p_x_line_rec.ship_set_id,
2509 	     --p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
2510 	     --p_requesting_entity_id         => p_x_line_rec.line_id,
2511           -- p_request_type      => OE_GLOBALS.G_SPLIT_SET_CHK,
2512           --p_param1 => to_char(p_x_line_rec.actual_shipment_date,'DD-MON-RRRR'),
2513           --x_return_status     => l_return_status);
2514 		--END IF;
2515 
2516         NULL;
2517 
2518     END IF;
2519 
2520     IF NOT OE_GLOBALS.Equal(p_x_line_rec.shipping_method_code,p_old_line_rec.shipping_method_code)
2521     THEN
2522         -- Need to Call Pricing: bug 3344835
2523         OE_GLOBALS.G_PRICE_FLAG := 'Y';
2524 
2525 	-- Need to Call Shipping Update
2526     	l_update_shipping	:= FND_API.G_TRUE;
2527         IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
2528            AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
2529                                       (p_x_line_rec.header_id)
2530                = 'OM_CALLED_FREIGHT_RATES'
2531            AND oe_globals.g_freight_recursion = 'N' THEN
2532             if l_debug_level > 0 then
2533              oe_debug_pub.add('Log Freight Rating request for shipping method. ',3);
2534             end if;
2535              l_get_FTE_freight_rate := 'Y';
2536         END IF;
2537 
2538     END IF;
2539 
2540     -- Don't change the order for the following, flow_status_code depends on this
2541     -- order to update the appropriate flow_status_code
2542 
2543     IF NOT OE_GLOBALS.Equal(p_x_line_rec.booked_flag, p_old_line_rec.booked_flag)
2544     THEN
2545   	   IF p_x_line_rec.booked_flag = 'Y' AND p_x_line_rec.flow_status_code = 'ENTERED' THEN
2546 	   -- only set status to BOOKED if we were at ENTERED
2547 		 p_x_line_rec.flow_status_code := 'BOOKED';
2548                  -- For bug 1304916. Booking wil call price_line directly
2549         	 --OE_GLOBALS.G_PRICE_FLAG := 'Y';
2550                if l_debug_level > 0 then
2551 		 oe_debug_pub.add('sam: flow_status_code is ' || p_x_line_rec.flow_status_code);
2552                end if;
2553 	   END IF;
2554     END IF;
2555 
2556 
2557 
2558   /*  WARNING !!!! The following code will not get executed after patchset 'G'.
2559   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 */
2560 
2561     IF NOT OE_GLOBALS.Equal(p_x_line_rec.shipping_quantity,p_old_line_rec.shipping_quantity)
2562     THEN
2563 	   -- Convert the shipping quantity from shipping quantity UOM to
2564 	   -- Ordered quantity UOM and update the field shipped quantity
2565 
2566 	   -- Call API to convert the shipping quantity to shipped quantity from
2567 	   -- shipping quantity UOM to ordered quantity UOM and assign the returned
2568 	   -- quantity to shipped quantity of p_x_line_rec.
2569      if l_debug_level > 0 then
2570         oe_debug_pub.ADD('Order Quantity UOM : '|| p_x_line_rec.order_quantity_uom,2);
2571         oe_debug_pub.ADD('Shipping Quantity UOM : '|| p_x_line_rec.shipping_quantity_uom,2);
2572      end if;
2573 	   IF 	p_x_line_rec.shipping_quantity_uom <> p_x_line_rec.order_quantity_uom THEN
2574 
2575      /* --OPM 06/SEP/00 invoke process Uom Conversion for process line INVCONV
2576              --============================================================
2577              IF dual_uom_control  --   INVCONV Process_Characteristics
2578                              (p_x_line_rec.inventory_item_id
2579                              ,p_x_line_rec.ship_from_org_id
2580                              ,l_item_rec) THEN
2581 
2582              if l_debug_level > 0 then
2583                oe_debug_pub.ADD('OPM Process shipping update ',1);
2584              end if;
2585                 GMI_Reservation_Util.Get_OPMUOM_from_AppsUOM
2586                      (p_Apps_UOM       => p_x_line_rec.order_quantity_uom
2587                      ,x_OPM_UOM        => l_OPM_order_quantity_uom
2588                      ,x_return_status  => l_status
2589                      ,x_msg_count      => l_msg_count
2590                      ,x_msg_data       => l_msg_data);
2591 
2592 --             Get the OPM equivalent code for shipping_quantity_uom
2593 --               ========================================================
2594                GMI_Reservation_Util.Get_OPMUOM_from_AppsUOM
2595                      (p_Apps_UOM       => p_x_line_rec.shipping_quantity_uom
2596                      ,x_OPM_UOM        => l_OPM_shipping_quantity_uom
2597                      ,x_return_status  => l_status
2598                      ,x_msg_count      => l_msg_count
2599                      ,x_msg_data       => l_msg_data);
2600 
2601 --                Apply OPM unit of measure conversion
2602 --               ======================================
2603                l_OPM_shipped_quantity :=GMICUOM.uom_conversion
2604  	                     	(l_item_rec.opm_item_id,0
2605      	    	                ,p_x_line_rec.shipping_quantity
2606                                ,l_OPM_shipping_quantity_uom
2607     	    	                     ,l_OPM_order_quantity_uom,0);
2608 
2609 -- get_opm_converted_qty to resolve rounding issues
2610 
2611 
2612       l_OPM_shipped_quantity := GMI_Reservation_Util.get_opm_converted_qty(
2613               p_apps_item_id    => p_x_line_rec.inventory_item_id,
2614               p_organization_id => p_x_line_rec.ship_from_org_id,
2615               p_apps_from_uom   => p_x_line_rec.shipping_quantity_uom,
2616               p_apps_to_uom     => p_x_line_rec.order_quantity_uom,
2617               p_original_qty    => p_x_line_rec.shipping_quantity);
2618      if l_debug_level > 0 then
2619      end if;
2620 
2621 -- Feb 2003 2683316 end
2622 
2623 
2624 		-- B2037234 EMC  INVCONV
2625                 -- B2204216 EMC- Moved assignment of profile value out of
2626                 -- Declaration. Here, the profile value has the potential to
2627                 -- affect OPM customers only.
2628                 -- To accomodate for international date format and use of commas
2629 		-- instead of decimal points, introduced
2630                 -- fnd_number.canonical_to_number which converts the returned
2631                 -- VARCHAR value to a number.
2632 
2633 		l_epsilon :=fnd_number.canonical_to_number(NVL(FND_PROFILE.VALUE('IC$EPSILON'),0)) ;
2634  		n := (-1) * round(log(10,l_epsilon));
2635  		l_OPM_shipped_quantity:=round(l_OPM_shipped_quantity, n);
2636 
2637 
2638 
2639                -- Enforce precision of 19,9
2640                --===========================-
2641                l_temp_shipped_quantity := l_OPM_shipped_quantity;
2642              if l_debug_level > 0 then
2643                oe_debug_pub.ADD('OPM Process shipping update conversion gives shipped quantity of ' || l_temp_shipped_quantity,1);
2644              end if;
2645 
2646 
2647 
2648              ELSE */ --  INVCONV
2649 
2650 			l_temp_shipped_quantity := OE_Order_Misc_Util.Convert_Uom
2651 				  (
2652 				  p_x_line_rec.inventory_item_id,
2653 				  p_x_line_rec.shipping_quantity_uom,
2654 				  p_x_line_rec.order_quantity_uom,
2655 				  p_x_line_rec.shipping_quantity
2656 				  );
2657               if l_debug_level > 0 then
2658         	oe_debug_pub.ADD('Converted Shipped Quantity : '|| to_char(l_temp_shipped_quantity),1);
2659               end if;
2660             --   END IF; -- INVCONV
2661              --OPM 06/SEP/00 END
2662 
2663 
2664               if l_debug_level > 0 then
2665         	oe_debug_pub.ADD('Converted Shipped Quantity : '|| to_char(l_temp_shipped_quantity),1);
2666               end if;
2667 
2668 			IF	l_temp_shipped_quantity <> trunc(l_temp_shipped_quantity) THEN
2669 
2670 				Inv_Decimals_PUB.Validate_Quantity
2671 				(
2672 					p_item_id	=> p_x_line_rec.inventory_item_id,
2673 					p_organization_id => OE_Sys_Parameters.value('MASTER_ORGANIZATION_ID'),
2674 					p_input_quantity => l_temp_shipped_quantity,
2675 					p_uom_code		 => p_x_line_rec.order_quantity_uom,
2676 					x_output_quantity => l_validated_quantity,
2677 					x_primary_quantity => l_primary_quantity,
2678 					x_return_status		=> l_qty_return_status
2679 				);
2680 
2681                              if l_debug_level > 0 then
2682 				oe_debug_pub.add('Return status from INV API : '||l_qty_return_status,1);
2683                              end if;
2684 				IF	l_qty_return_status = 'W' THEN
2685 
2686 					p_x_line_rec.shipped_quantity := l_validated_quantity;
2687 				ELSE
2688 
2689 					p_x_line_rec.shipped_quantity := l_temp_shipped_quantity;
2690 
2691 				END IF;
2692 
2693 			ELSE
2694 				p_x_line_rec.shipped_quantity := l_temp_shipped_quantity;
2695 
2696 			END IF;
2697 
2698 		        p_x_line_rec.shipped_quantity2 := p_x_line_rec.shipping_quantity2; -- OPM B1873114 07/10/01
2699 	   ELSE
2700 
2701 			p_x_line_rec.shipped_quantity := p_x_line_rec.shipping_quantity;
2702 		        p_x_line_rec.shipped_quantity2 := p_x_line_rec.shipping_quantity2; -- OPM B1661023 04/02/01
2703 
2704 	   END IF;
2705 
2706       if l_debug_level > 0 then
2707         oe_debug_pub.ADD('Shipped Quantity : '|| to_char(p_x_line_rec.shipped_quantity),1);
2708       end if;
2709 	   -- The following line needs to assign the value of shipped quantity
2710 	   -- after the conversion of shipping quantity to ordered quantity UOM.
2711 
2712        -- Log the delayed request for Ship Confirmation if there is an update
2713        -- from Shipping for ship confirmation
2714        IF p_x_line_rec.line_category_code <> 'RETURN' THEN
2715          IF (p_x_line_rec.ship_set_id IS NOT NULL AND
2716              p_x_line_rec.ship_set_id <> FND_API.G_MISS_NUM) THEN
2717 
2718          l_shipping_unique_key1  :=  'SHIP_SET';
2719          l_shipping_param1       :=  p_x_line_rec.ship_set_id;
2720 
2721        ELSIF (p_x_line_rec.top_model_line_id  IS NOT NULL AND
2722               p_x_line_rec.top_model_line_id <> FND_API.G_MISS_NUM) AND
2723               nvl(p_x_line_rec.model_remnant_flag,'N') = 'N' THEN
2724 
2725          l_shipping_unique_key1  :=  'PTO_KIT';
2726          l_shipping_param1       :=  p_x_line_rec.top_model_line_id;
2727 
2728        ELSIF (p_x_line_rec.ato_line_id IS NOT NULL AND
2729               p_x_line_rec.ato_line_id <> FND_API.G_MISS_NUM) AND
2730               p_x_line_rec.item_type_code = Oe_Globals.G_ITEM_CONFIG AND
2731               nvl(p_x_line_rec.model_remnant_flag,'N') = 'N' THEN
2732          l_shipping_unique_key1  :=  'ATO';
2733          l_shipping_param1       :=  p_x_line_rec.line_id;
2734        ELSE
2735          l_shipping_unique_key1  :=  p_x_line_rec.item_type_code;
2736          l_shipping_param1       :=  p_x_line_rec.line_id;
2737        END IF;
2738 
2739 	   -- Log a delayed request for Ship Confirmation
2740       if l_debug_level > 0 then
2741         oe_debug_pub.ADD('Ship Confirmation : logging delayed request for '|| l_shipping_unique_key1 || l_shipping_param1,1);
2742       end if;
2743 
2744 		OE_Delayed_Requests_Pvt.Log_Request(
2745 		p_entity_code				=>	OE_GLOBALS.G_ENTITY_LINE,
2746 		p_entity_id					=>	p_x_line_rec.line_id,
2747 		p_requesting_entity_code	=>	OE_GLOBALS.G_ENTITY_LINE,
2748 		p_requesting_entity_id  	=>	p_x_line_rec.line_id,
2749 		p_request_type				=>	OE_GLOBALS.G_SHIP_CONFIRMATION,
2750 		p_request_unique_key1		=>	l_shipping_unique_key1,
2751 		p_param1             		=>	l_shipping_param1,
2752 		x_return_status				=>	l_return_status);
2753 
2754 		END IF;
2755 
2756     END IF;
2757 
2758 
2759 
2760     IF NOT OE_GLOBALS.Equal(p_x_line_rec.invoice_interface_status_code, p_old_line_rec.invoice_interface_status_code)
2761     THEN
2762         IF p_x_line_rec.invoice_interface_status_code = 'YES' THEN
2763            p_x_line_rec.flow_status_code := 'INVOICED';
2764          if l_debug_level > 0 then
2765            oe_debug_pub.add('sam: flow_status_code is ' || p_x_line_rec.flow_status_code);
2766          end if;
2767         ELSIF p_x_line_rec.invoice_interface_status_code = 'RFR-PENDING' THEN
2768            p_x_line_rec.flow_status_code := 'INVOICED_PARTIAL';
2769          if l_debug_level > 0 then
2770            oe_debug_pub.add('sam: flow_status_code is ' || p_x_line_rec.flow_status_code);
2771           end if;
2772         END IF;
2773 
2774     END IF;
2775 
2776 
2777     IF NOT OE_GLOBALS.Equal(p_x_line_rec.open_flag, p_old_line_rec.open_flag)
2778     THEN
2779 	IF p_x_line_rec.open_flag = 'N' THEN
2780 	 	p_x_line_rec.flow_status_code := 'CLOSED';
2781                 IF p_x_line_rec.cancelled_flag = 'Y' THEN
2782                    p_x_line_rec.flow_status_code := 'CANCELLED';
2783                 END IF;
2784               if l_debug_level > 0 then
2785 	 	oe_debug_pub.add('sam: flow_status_code is ' || p_x_line_rec.flow_status_code);
2786               end if;
2787 	 	p_x_line_rec.calculate_price_flag := 'N';
2788 	END IF;
2789 
2790     END IF;
2791 
2792     IF NOT OE_GLOBALS.Equal(p_x_line_rec.cancelled_flag, p_old_line_rec.cancelled_flag)
2793     THEN
2794 	IF p_x_line_rec.cancelled_flag = 'Y' THEN
2795 		 p_x_line_rec.flow_status_code := 'CANCELLED';
2796                if l_debug_level > 0 then
2797 		 oe_debug_pub.add('sam: flow_status_code is ' || p_x_line_rec.flow_status_code);
2798                end if;
2799 	 	 p_x_line_rec.calculate_price_flag := 'N';
2800 	END IF;
2801 
2802     END IF;
2803 
2804     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_from_org_id,p_old_line_rec.ship_from_org_id)
2805     THEN
2806 	   -- BUG 1491504 BEGIN -- INVCONV  stet
2807 	   -- Warehouse data CAN determine whether the line is treated as process or discrete OR SINGLE uom OR dUAL uom CONTROLLED .
2808 	   -- Warehouse data can impact quantity calculations, so check the quantites here
2809 	   -- pal
2810 	   OE_Line_Util.Sync_Dual_Qty (p_x_line_rec => p_x_line_rec
2811                                    ,p_old_line_rec => p_old_line_rec);
2812         -- Check to see if either the primary or secondary quantity has changed
2813 	   -- If there is a change, make a recursive call to OE_Order_Pvt.Lines
2814         IF p_x_line_rec.ordered_quantity <> l_ordered_quantity OR
2815           p_x_line_rec.ordered_quantity2 <> l_ordered_quantity2 THEN
2816           -- OE_GLOBALS.G_RECURSION_MODE           := 'Y';
2817 	     l_control_rec.controlled_operation    := TRUE;
2818 	     l_control_rec.check_security	        := TRUE;
2819     	     l_control_rec.clear_dependents 	   := FALSE;
2820 	     l_control_rec.default_attributes      := FALSE;
2821 	     l_control_rec.change_attributes	   := TRUE;
2822 	     l_control_rec.validate_entity	        := FALSE;
2823     	     l_control_rec.write_to_DB             := FALSE;
2824     	     l_control_rec.process                 := FALSE;
2825 	     l_old_line_tbl(1) 			        := p_old_line_rec;
2826           l_line_tbl(1)			             := p_x_line_rec;
2827 
2828           Oe_Order_Pvt.Lines
2829 	     ( p_validation_level	=> FND_API.G_VALID_LEVEL_NONE
2830           , p_control_rec		=> l_control_rec
2831           , p_x_line_tbl			=> l_line_tbl
2832           , p_x_old_line_tbl		=> l_old_line_tbl
2833 	     , x_return_status        => l_return_status
2834 	     );
2835 
2836           -- OE_GLOBALS.G_RECURSION_MODE           := 'N';
2837           IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2838             RAISE FND_API.G_EXC_ERROR;
2839           ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2840             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2841           END IF;
2842         END IF;
2843 	   -- BUG 1491504 END
2844         -- =======================================
2845         -- Log the request for Tax Calculation
2846         OE_GLOBALS.G_TAX_FLAG := 'Y';
2847           -- Need to Call Shipping Update
2848         l_update_shipping := FND_API.G_TRUE;
2849         /* may need to call pricing */
2850         -- For performance bug 1351111, turning off Pricing for scheduling
2851         /* commenting out for fix 1419204
2852         l_turn_off_pricing := FND_PROFILE.VALUE('ONT_NO_PRICING_AT_SCHEDULING');
2853         -- by default, turn off pricing at scheduling
2854         IF l_turn_off_pricing = 'N' THEN
2855           OE_GLOBALS.G_PRICE_FLAG := 'Y';
2856         End If;
2857         */
2858 
2859        IF ( p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
2860 	    NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT')
2861             -- QUOTING change
2862             AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
2863        THEN
2864          if l_debug_level > 0 then
2865           oe_debug_pub.ADD('ship from update: logging request for eval_hold_source', 1);
2866           oe_debug_pub.add('line ID: '|| to_char(p_x_line_rec.line_id) ||
2867                ' Entity ID :'|| to_char(p_x_line_rec.ship_from_org_id), 1);
2868          end if;
2869 
2870           OE_delayed_requests_Pvt.log_request(
2871             p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
2872             p_entity_id              => p_x_line_rec.line_id,
2873             p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
2874             p_requesting_entity_id   => p_x_line_rec.line_id,
2875             p_request_type           => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
2876             p_request_unique_key1    => 'SHIP_FROM',
2877             p_param1                 => 'W',
2878             p_param2                 => p_x_line_rec.ship_from_org_id,
2879             x_return_status          => l_return_status);
2880 
2881         if l_debug_level > 0 then
2882           oe_debug_pub.add('return status after logging delayed request '||
2883                  l_return_status, 1);
2884         end if;
2885         END IF;
2886 
2887         -- Freight Rating
2888         IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
2889            AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
2890                                       (p_x_line_rec.header_id)
2891                = 'OM_CALLED_FREIGHT_RATES' THEN
2892            if l_debug_level > 0 then
2893              oe_debug_pub.add('Log Freight Rating request for ship from org. ',3);
2894            end if;
2895              l_get_FTE_freight_rate := 'Y';
2896         END IF;
2897 
2898        -- Pack J catchweight
2899         IF l_debug_level  > 0 THEN
2900            oe_debug_pub.add('old ship_from_org_id:'|| p_old_line_rec.ship_from_org_id  );
2901            oe_debug_pub.add('New ship_from_org_id  :'|| p_x_line_rec.ship_from_org_id  );
2902         END IF;
2903 
2904         IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
2905            IF p_x_line_rec.ship_from_org_id  IS NOT NULL AND
2906               p_x_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM THEN
2907                 SELECT wms_enabled_flag
2908                 INTO l_wms_org_flag_new
2909                 FROM mtl_parameters
2910                 WHERE organization_id= p_x_line_rec.ship_from_org_id;
2911            END IF;
2912            IF p_old_line_rec.ship_from_org_id  IS NOT NULL AND
2913               p_old_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM THEN
2914                 SELECT wms_enabled_flag
2915                 INTO l_wms_org_flag_old
2916                 FROM mtl_parameters
2917                 WHERE organization_id= p_old_line_rec.ship_from_org_id;
2918            END IF;
2919            IF l_debug_level  > 0 THEN
2920               oe_debug_pub.add('l_wms_org_flag_new:'|| l_wms_org_flag_new);
2921               oe_debug_pub.add('l_wms_org_flag_old:'|| l_wms_org_flag_old);
2922            END IF;
2923            IF l_wms_org_flag_new <> l_wms_org_flag_old THEN
2924               OE_GLOBALS.G_PRICE_FLAG := 'Y';
2925            END IF;
2926         END IF;
2927        -- Pack J catchweight
2928 
2929 
2930     END IF;
2931 
2932     IF NOT OE_GLOBALS.Equal(p_x_line_rec.subinventory,p_old_line_rec.subinventory)
2933     THEN
2934        -- change of subinventory should not require tax or pricing calculation.
2935        -- or even hold evaluation
2936 	  l_update_shipping := FND_API.G_TRUE;
2937       if l_debug_level > 0 then
2938        oe_debug_pub.add('subinventory update',  1);
2939       end if;
2940     END IF;
2941 
2942 
2943     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_model_complete_flag,p_old_line_rec.ship_model_complete_flag)
2944     THEN
2945 	-- Need to Call Shipping Update
2946     	l_update_shipping	:= FND_API.G_TRUE;
2947     END IF;
2948 
2949     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_set_id,p_old_line_rec.ship_set_id)
2950     THEN
2951 	-- Need to Call Shipping Update
2952     	l_update_shipping	:= FND_API.G_TRUE;
2953 
2954     END IF;
2955 
2956     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_set,p_old_line_rec.ship_set)
2957     THEN
2958 
2959 	NULL;
2960 
2961     END IF;
2962 
2963 
2964     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_tolerance_above,p_old_line_rec.ship_tolerance_above)
2965     THEN
2966 	-- Need to Call Shipping Update
2967     	l_update_shipping	:= FND_API.G_TRUE;
2968     END IF;
2969 
2970     -- Changes for Bug-2579571
2971 
2972     IF NOT OE_GLOBALS.Equal(p_x_line_rec.line_set_id,p_old_line_rec.line_set_id)
2973     THEN
2974         -- Need to Call Shipping Update
2975         l_update_shipping       := FND_API.G_TRUE;
2976     END IF;
2977 
2978     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_tolerance_below,p_old_line_rec.ship_tolerance_below)
2979     THEN
2980 	-- Need to Call Shipping Update
2981     	l_update_shipping	:= FND_API.G_TRUE;
2982     END IF;
2983 
2984     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_to_contact_id,p_old_line_rec.ship_to_contact_id)
2985     THEN
2986 	-- Need to Call Shipping Update
2987     	l_update_shipping	:= FND_API.G_TRUE;
2988 	-- Call Pricing
2989      -- OE_GLOBALS.G_PRICE_FLAG := 'Y'; Commented out for fix 1419204
2990 
2991     END IF;
2992 
2993     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_to_org_id,p_old_line_rec.ship_to_org_id)
2994     THEN
2995 	-- Log the request for Tax Calculation
2996         OE_GLOBALS.G_TAX_FLAG := 'Y';
2997 	-- Need to Call Shipping Update
2998     	l_update_shipping	:= FND_API.G_TRUE;
2999         /* may need to call pricing */
3000           OE_GLOBALS.G_PRICE_FLAG := 'Y';
3001 
3002           IF p_x_line_rec.commitment_id IS NOT NULL THEN
3003             l_get_commitment_bal := 'Y';
3004           END IF;
3005 
3006           IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
3007              AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
3008                                         (p_x_line_rec.header_id)
3009                  = 'OM_CALLED_FREIGHT_RATES' THEN
3010              if l_debug_level > 0 then
3011                oe_debug_pub.add('Log Freight Rating request for ship to org. ',3);
3012              end if;
3013                l_get_FTE_freight_rate := 'Y';
3014           END IF;
3015 
3016      IF ( p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
3017 	   NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT')
3018            -- QUOTING change
3019            AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
3020      THEN
3021          if l_debug_level > 0 then
3022            oe_debug_pub.ADD('ship to update: logging request for eval_hold_source', 1);
3023            oe_debug_pub.add('line ID: '|| to_char(p_x_line_rec.line_id) ||
3024 	           ' Entity ID :'|| to_char(p_x_line_rec.ship_to_org_id), 1);
3025          end if;
3026          OE_delayed_requests_Pvt.log_request(
3027                   p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3028                   p_entity_id         => p_x_line_rec.line_id,
3029                   p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3030                   p_requesting_entity_id         => p_x_line_rec.line_id,
3031                   p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
3032                   p_request_unique_key1 => 'SHIP_TO',
3033                   p_param1		 => 'S',
3034                   p_param2		 => p_x_line_rec.ship_to_org_id,
3035                   x_return_status     => l_return_status);
3036 
3037          if l_debug_level > 0 then
3038           oe_debug_pub.add('return status after logging delayed request '||
3039                          p_x_line_rec.return_status, 1);
3040          end if;
3041      END IF;
3042 
3043     END IF;
3044 
3045 
3046 
3047     IF NOT OE_GLOBALS.Equal(p_x_line_rec.sold_to_org_id,p_old_line_rec.sold_to_org_id)
3048     THEN
3049 
3050 	-- Need to Call Shipping Update
3051     	l_update_shipping	:= FND_API.G_TRUE;
3052 	--Customer Acceptance
3053         l_def_contingency_attributes := FND_API.G_TRUE;
3054 
3055        if l_debug_level > 0 then
3056         oe_debug_pub.add('In Apply Atrributes:Sold To', 1);
3057         oe_debug_pub.add('Return Status before is : '||p_x_line_rec.return_status, 1);
3058        end if;
3059 
3060 	-- Call Pricing
3061         OE_GLOBALS.G_PRICE_FLAG := 'Y';
3062 
3063 
3064         -- bug 1829201, need to recalculate commitment.
3065         IF p_x_line_rec.commitment_id is not null then
3066          l_calculate_commitment_flag := 'Y';
3067         END IF;
3068 
3069         IF (p_old_line_rec.sold_to_org_id IS NOT NULL AND
3070             p_x_line_rec.sold_to_org_id <> FND_API.G_MISS_NUM) THEN
3071           IF p_x_line_rec.item_identifier_type = 'CUST' THEN
3072              IF (p_x_line_rec.ordered_item_id IS NOT NULL AND
3073                  p_x_line_rec.ordered_item_id <> FND_API.G_MISS_NUM) THEN
3074                if l_debug_level > 0 then
3075                 oe_debug_pub.add('old sold_to is' || to_char(p_old_line_rec.sold_to_org_id), 1);
3076                 oe_debug_pub.add('new sold_to is' || to_char(p_x_line_rec.sold_to_org_id), 1);
3077                end if;
3078                 fnd_message.set_name('ONT','OE_CUSTOMER_ITEM_EXIST');
3079                 OE_MSG_PUB.Add;
3080                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
3081              END IF;
3082           END IF;
3083         END IF;
3084        if l_debug_level > 0 then
3085         oe_debug_pub.add('Return Status after is : '||p_x_line_rec.return_status, 1);
3086        end if;
3087 
3088         if p_x_line_rec.commitment_id is not null then
3089           l_get_commitment_bal := 'Y';
3090         end if;
3091 
3092     END IF;
3093 
3094     IF NOT OE_GLOBALS.Equal(p_x_line_rec.source_document_type_id,p_old_line_rec.source_document_type_id)
3095     THEN
3096 
3097 	If p_x_line_rec.source_document_type_id = 2 Then
3098           --
3099         -- bug 1917869
3100 	IF p_x_line_rec.calculate_price_flag in ('N','P') then
3101   	  l_copy_adjustments := TRUE;
3102         END IF;
3103 
3104 	  l_copy_pricing_attributes := TRUE;
3105 
3106           -- commented out for 1819133
3107           /***
3108           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
3109             p_x_line_rec.calculate_price_flag := 'Y';
3110             OE_GLOBALS.G_PRICE_FLAG := 'Y';
3111           END IF;
3112           ***/
3113 
3114 	End If;
3115         --
3116       --Customer Acceptance
3117        l_def_contingency_attributes := FND_API.G_TRUE;
3118 
3119     END IF;
3120     --
3121 
3122     -- SAO
3123            IF p_x_line_rec.line_category_code <> 'RETURN'
3124                  and p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3125                  and p_x_line_rec.split_by = 'SYSTEM'
3126                  and NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT'
3127                  and p_x_line_rec.calculate_price_flag = 'Y' Then
3128                    p_x_line_rec.calculate_price_flag :='P';
3129            End IF;
3130 
3131 
3132     IF NOT OE_GLOBALS.Equal(p_x_line_rec.split_from_line_id,p_old_line_rec.split_from_line_id)
3133     THEN
3134 
3135 	   -- Do not attempt to copy the adjustments for the parent line
3136 	   IF p_x_line_rec.operation = oe_globals.g_opr_create THEN
3137 	      l_copy_adjustments := TRUE;
3138 	      l_copy_pricing_attributes := TRUE;
3139 
3140            IF p_x_line_rec.split_by = 'SYSTEM'
3141            THEN
3142                p_x_line_rec.calculate_price_flag := 'N';
3143 
3144                IF l_charges_for_backorders = 'Y' AND
3145                   p_x_line_rec.line_category_code <> 'RETURN'   /* For bug#2680291 */
3146 		   AND nvl(p_x_line_rec.order_source_id,-1) <>  10 --added for the FP bug 3709662
3147 
3148                THEN
3149 		   IF l_debug_level > 0 THEN
3150 		       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);
3151 		        --oe_debug_pub.add('pviprana: order_source_id is ' ||p_x_line_rec.order_source_id);
3152                    END IF;
3153 	     	       p_x_line_rec.calculate_price_flag := 'P';
3154                END IF;
3155 
3156                /*Bug#5026401 - For RMA split lines, set the flag to 'P', if the original line's
3157                  calculate_price_flag is 'P' or 'Y' and if the profile option OM: Charges for Back
3158                  orders is set to 'Yes'.
3159                */
3160                IF l_charges_for_backorders = 'Y' AND
3161                   p_x_line_rec.line_category_code = 'RETURN' AND
3162                   p_x_line_rec.split_from_line_id IS NOT NULL
3163                THEN
3164                   BEGIN
3165                      SELECT calculate_price_flag
3166                      INTO l_orig_line_calc_price_flag
3167                      FROM OE_ORDER_LINES_ALL
3168                      WHERE LINE_ID = p_x_line_rec.split_from_line_id;
3169                   EXCEPTION
3170                      WHEN OTHERS THEN
3171                         l_orig_line_calc_price_flag := NULL;
3172                   END;
3173                   oe_debug_pub.add('Bug#5026401 l_orig_line_calc_price_flag:'||l_orig_line_calc_price_flag);
3174                   IF NVL(l_orig_line_calc_price_flag,'N') IN ('Y','P')
3175                   THEN
3176                      p_x_line_rec.calculate_price_flag := 'P';
3177                   END IF;
3178                END IF;
3179                oe_debug_pub.add('Bug#5026401 p_x_line_rec.calculate_price_flag:'|| p_x_line_rec.calculate_price_flag);
3180                /* Bug#5026401 - End */
3181 
3182            END IF;
3183 	   END IF;
3184 
3185 	   If p_x_line_rec.split_by = 'SYSTEM' then
3186 	   -- Do not reprice the lines when the split is system
3187               --changes for bug 2315926 Begin
3188                     /*    If l_charges_for_backorders = 'N' Then
3189 			  l_no_price_flag := TRUE;
3190                         Else
3191                           l_no_price_flag := FALSE;
3192                         End If;
3193                        */
3194          	  l_no_price_flag := TRUE;
3195               --changes for bug 2315926  end
3196 	   --Elsif p_x_line_rec.split_by = 'USER' Then
3197                -- Bug 1313728
3198                -- User split should keep the original calculate_price_flag
3199 		--	p_x_line_rec.calculate_price_flag:='P';
3200 	   End If;
3201 
3202     END IF;
3203 
3204     IF NOT OE_GLOBALS.Equal(p_x_line_rec.tax_code,p_old_line_rec.tax_code)
3205     THEN
3206         OE_GLOBALS.G_TAX_FLAG := 'Y';
3207 
3208         IF p_x_line_rec.commitment_id IS NOT NULL THEN
3209           l_get_commitment_bal := 'Y';
3210         END IF;
3211     END IF;
3212 
3213     IF NOT OE_GLOBALS.Equal(p_x_line_rec.tax_date,p_old_line_rec.tax_date)
3214     THEN
3215         OE_GLOBALS.G_TAX_FLAG := 'Y';
3216 
3217         IF p_x_line_rec.commitment_id IS NOT NULL THEN
3218           l_get_commitment_bal := 'Y';
3219         END IF;
3220     END IF;
3221 
3222     IF NOT OE_GLOBALS.Equal(p_x_line_rec.tax_exempt_flag,p_old_line_rec.tax_exempt_flag)
3223     THEN
3224         OE_GLOBALS.G_TAX_FLAG := 'Y';
3225 
3226         IF p_x_line_rec.commitment_id IS NOT NULL THEN
3227           l_get_commitment_bal := 'Y';
3228         END IF;
3229     END IF;
3230 
3231     IF NOT OE_GLOBALS.Equal(p_x_line_rec.tax_exempt_number,p_old_line_rec.tax_exempt_number)
3232     THEN
3233 	   -- Log the request for Tax Calculation
3234         OE_GLOBALS.G_TAX_FLAG := 'Y';
3235 
3236         IF p_x_line_rec.commitment_id IS NOT NULL THEN
3237           l_get_commitment_bal := 'Y';
3238         END IF;
3239     END IF;
3240 
3241     IF NOT OE_GLOBALS.Equal(p_x_line_rec.tax_exempt_reason_code,p_old_line_rec.tax_exempt_reason_code)
3242     THEN
3243 	   -- Log the request for Tax Calculation
3244         OE_GLOBALS.G_TAX_FLAG := 'Y';
3245 
3246         IF p_x_line_rec.commitment_id IS NOT NULL THEN
3247           l_get_commitment_bal := 'Y';
3248         END IF;
3249     END IF;
3250 
3251     IF NOT OE_GLOBALS.Equal(p_x_line_rec.tax_value,p_old_line_rec.tax_value)
3252     THEN
3253 
3254 	IF p_x_line_rec.commitment_id is NOT NULL THEN
3255 	   l_calculate_commitment_flag := 'Y';
3256 
3257       	END IF;
3258 
3259         IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
3260 	  -- Log Verify Payment only if the Tax Value has
3261 	  -- Increased AND Payment Type Code is Credit Card.
3262 	  IF  p_x_line_rec.tax_value > p_old_line_rec.tax_value AND
3263               OE_Order_Cache.g_header_rec.payment_type_code = 'CREDIT_CARD' THEN
3264              -- Set flag to log Verify Payment Delayed Request
3265             if l_debug_level > 0 then
3266              oe_debug_pub.ADD('Log Verify Payment delayed request in Tax Value');
3267             end if;
3268 	     l_verify_payment_flag := 'Y';
3269 
3270            ELSIF OE_PrePayment_UTIL.is_prepaid_order(p_x_line_rec.header_id)
3271                       = 'Y' AND p_x_line_rec.booked_flag ='Y' THEN
3272              -- if this is a prepaid order, also log delayed request if ordered
3273              -- quantity decreases, as refund may need to be issued.
3274             if l_debug_level > 0 then
3275              oe_debug_pub.ADD('Log Verify Payment delayed request in Tax Value for prepayment', 3);
3276             end if;
3277 	     l_verify_payment_flag := 'Y';
3278            END IF;
3279          END IF;
3280 
3281     END IF;
3282 
3283     IF NOT OE_GLOBALS.Equal(p_x_line_rec.top_model_line_id,p_old_line_rec.top_model_line_id)
3284     THEN
3285 		-- Need to Call Shipping Update
3286     	l_update_shipping	:= FND_API.G_TRUE;
3287 
3288       --Customer Acceptance
3289        l_def_contingency_attributes := FND_API.G_TRUE;
3290 
3291     END IF;
3292     -- Bug 3418496
3293     IF NOT OE_GLOBALS.Equal(p_x_line_rec.unit_list_price,p_old_line_rec.unit_list_price) THEN
3294        IF( p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3295          AND p_x_line_rec.booked_flag ='Y') THEN
3296          -- Log Delayed Request for Verify Payment
3297         if l_debug_level > 0 then
3298          oe_debug_pub.ADD('log verify payment delayed request for change in List price');
3299         end if;
3300          l_verify_payment_flag := 'Y';
3301        END IF;
3302     END IF;
3303     /* Fixed bug 1889762
3304        If the new selling price is NULL AND old selling price is NOT NULL Then
3305 	 Reprice the line
3306        End if;
3307     */
3308     IF NOT OE_GLOBALS.Equal(p_x_line_rec.unit_selling_price,p_old_line_rec.unit_selling_price)
3309     THEN
3310 
3311         l_3a7_attribute_change := FND_API.G_TRUE;
3312         IF (p_x_line_rec.unit_selling_price is NULL And
3313            p_old_line_rec.unit_selling_price is NOT NULL) Then
3314            if l_debug_level > 0 then
3315 	    oe_debug_pub.add('User has cleared unit selling price');
3316 	    oe_debug_pub.add('Just Reprice');
3317            end if;
3318             --Oe_Line_Adj_Util.Delete_Row(p_line_id=>p_x_line_rec.line_id); 7363196
3319             OE_GLOBALS.G_PRICE_FLAG := 'Y';
3320 	    p_x_line_rec.unit_list_price := NULL;
3321 	    p_x_line_rec.unit_list_price_per_pqty := NULL;
3322         End if;
3323 
3324         OE_GLOBALS.G_TAX_FLAG := 'Y';
3325         IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
3326 	   -- Additional task : Log Verify Payment always when the payment Type
3327 	   -- code is not CREDIT CARD. For CREDIT CARD, log this request only if
3328 	   -- the Unit Selling Price has increased.
3329 
3330 	  IF OE_Order_Cache.g_header_rec.payment_type_code = 'CREDIT_CARD' THEN
3331 	    IF  p_x_line_rec.unit_selling_price > p_old_line_rec.unit_selling_price
3332 		then
3333                -- Log request here if commitment id is null
3334                IF p_x_line_rec.commitment_id is null THEN
3335                   -- if it is not a prepaid order, log Verify Payment delayed request.
3336                   -- if it is a prepaid order, check the shipped_quantity to make
3337                   -- sure to not collect fund again during repricing at shipment.
3338 
3339                   IF OE_PrePayment_UTIL.is_prepaid_order(p_x_line_rec.header_id) = 'N'
3340                      OR (OE_PrePayment_UTIL.is_prepaid_order(p_x_line_rec.header_id)
3341                          = 'Y' AND p_x_line_rec.booked_flag ='Y'
3342                          AND p_x_line_rec.shipped_quantity IS NULL) THEN
3343                    if l_debug_level > 0 then
3344             	    oe_debug_pub.ADD('Log Verify Payment delayed request in Selling Price');
3345                    end if;
3346 		    l_verify_payment_flag := 'Y';
3347                   END IF;
3348 	        END IF;
3349              ELSIF OE_PrePayment_UTIL.is_prepaid_order(p_x_line_rec.header_id)
3350                     = 'Y'  AND p_x_line_rec.booked_flag ='Y'
3351                     AND p_x_line_rec.shipped_quantity IS NULL THEN
3352                -- if this is a prepaid order, also log delayed request if selling
3353                -- price decreases, as refund may need to be issued.
3354               if l_debug_level > 0 then
3355 	       oe_debug_pub.ADD('Log Verify Payment delayed request for change in Selling Price for prepayment', 3);
3356               end if;
3357 	       l_verify_payment_flag := 'Y';
3358              END IF;
3359 	   ELSE
3360 	     IF p_x_line_rec.booked_flag ='Y' THEN
3361                if l_debug_level > 0 then
3362 	        oe_debug_pub.ADD('Log Verify Payment delayed request for change in Selling Price');
3363                end if;
3364 	        l_verify_payment_flag := 'Y';
3365 	   END IF;
3366          END IF;
3367 
3368         END IF;
3369 
3370         IF p_x_line_rec.commitment_id is not null then
3371 	  l_calculate_commitment_flag := 'Y';
3372         END IF;
3373 
3374     END IF;
3375 
3376 /* csheu -- bug #1533658 S*/
3377 
3378     IF NOT OE_GLOBALS.Equal(p_x_line_rec.service_start_date,p_old_line_rec.service_start_date)
3379 
3380     THEN
3381 	    -- Call Pricing
3382         if l_debug_level > 0 then
3383 	 oe_debug_pub.add('CSH- service start_date is changed');
3384         end if;
3385          OE_GLOBALS.G_PRICE_FLAG := 'Y';
3386 	 l_copy_service_fields := TRUE;
3387 
3388          IF p_x_line_rec.commitment_id IS NOT NULL THEN
3389            l_get_commitment_bal := 'Y';
3390          END IF;
3391 
3392     END IF;
3393 
3394 
3395     IF NOT OE_GLOBALS.Equal(p_x_line_rec.service_end_date,p_old_line_rec.service_end_date)
3396 
3397     THEN
3398         if l_debug_level > 0 then
3399 	 oe_debug_pub.add('CSH- service end_date is changed');
3400         end if;
3401 	 -- Call Pricing
3402          OE_GLOBALS.G_PRICE_FLAG := 'Y';
3403 	 l_copy_service_fields := TRUE;
3404 
3405          IF p_x_line_rec.commitment_id IS NOT NULL THEN
3406            l_get_commitment_bal := 'Y';
3407          END IF;
3408 
3409     END IF;
3410 
3411 /* csheu -- bug #1533658 E*/
3412 
3413     IF NOT OE_GLOBALS.Equal(p_x_line_rec.service_duration,p_old_line_rec.service_duration)
3414 
3415     THEN
3416 	    -- Call Pricing
3417          OE_GLOBALS.G_PRICE_FLAG := 'Y';
3418 /* csheu -- bug #1533658 s*/
3419         if l_debug_level > 0 then
3420          oe_debug_pub.add('CSH- service duration is changed');
3421         end if;
3422          l_copy_service_fields := TRUE;
3423 /* csheu -- bug #1533658 e*/
3424 
3425          IF p_x_line_rec.commitment_id IS NOT NULL THEN
3426            l_get_commitment_bal := 'Y';
3427          END IF;
3428 
3429     END IF;
3430 
3431     IF NOT OE_GLOBALS.Equal(p_x_line_rec.service_period,p_old_line_rec.service_period)
3432     THEN
3433         -- Reprice the Line
3434         OE_GLOBALS.G_PRICE_FLAG := 'Y';
3435 
3436         IF p_x_line_rec.commitment_id IS NOT NULL THEN
3437           l_get_commitment_bal := 'Y';
3438         END IF;
3439 
3440 /* csheu -- bug #1533658 s*/
3441        if l_debug_level > 0 then
3442         oe_debug_pub.add('CSH- service period is changed');
3443        end if;
3444         l_copy_service_fields := TRUE;
3445 /* csheu -- bug #1533658 e*/
3446     END IF;
3447 
3448     IF NOT OE_GLOBALS.Equal(p_x_line_rec.service_reference_line_id,p_old_line_rec.service_reference_line_id)
3449 
3450     THEN
3451        if l_debug_level > 0 then
3452 	 oe_debug_pub.add('JPN: line id is: ' || to_char(p_x_line_rec.line_id));
3453 	 oe_debug_pub.add('JPN: Serviced line id is: ' || to_char(p_x_line_rec.service_reference_line_id));
3454        end if;
3455 
3456 -- The IF condition on source_type_document_type_id is being
3457 -- commented for bug 2372098
3458 
3459 --      IF (p_x_line_rec.source_document_type_id = 2) THEN
3460 --	    NULL; /* do nothing for copy order */
3461 --      ELSE /* cascade the service line to options */
3462 
3463 	IF (nvl(p_x_line_rec.source_document_type_id,-99) <> 2) THEN  -- for bug 2494517, 2567242(nvl condition)
3464 
3465 	   /* Call to retrieve service reference information */
3466 
3467 	   IF (p_x_line_rec.item_type_code = 'SERVICE') THEN
3468 
3469 	     OE_SERVICE_UTIL.Get_Service_Attribute
3470                              (x_return_status => l_return_status
3471                              , p_x_line_rec    => p_x_line_rec
3472                              );
3473 
3474          if l_debug_level > 0 then
3475           oe_debug_pub.add('AKS: Service num is: ' || to_char(p_x_line_rec.service_number));
3476           oe_debug_pub.add('UTIL call: Line num is: ' || to_char(p_x_line_rec.line_number));
3477          end if;
3478 
3479           IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3480             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3481           ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3482             RAISE FND_API.G_EXC_ERROR;
3483           END IF;
3484 
3485           OE_SERVICE_UTIL.Get_Service_Duration
3486                         (x_return_status => l_return_status
3487                          , p_x_line_rec    => p_x_line_rec);
3488 
3489           IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3490             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3491           ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3492             RAISE FND_API.G_EXC_ERROR;
3493           END IF;
3494 
3495 	   END IF; /* End of item_type_code */
3496 
3497 	 END IF; /* source_document_type_id */
3498 
3499 /* hashraf bug # 2757859 */
3500 
3501     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,p_old_line_rec.ordered_quantity) THEN
3502          OE_GLOBALS.G_PRICE_FLAG := 'Y';
3503     END IF;
3504 
3505 /* end of 2757859 */
3506 
3507 
3508 
3509         IF p_x_line_rec.service_reference_type_code  = 'ORDER' THEN
3510 	     BEGIN
3511 
3512      	  Select 'Y'
3513      	  INTO   l_is_model
3514      	  FROM   oe_order_lines
3515      	  WHERE  line_id = p_x_line_rec.service_reference_line_id
3516      	  AND    item_type_code in ('INCLUDED', 'MODEL', 'CLASS', 'OPTION', 'KIT') ; -- Included KIT Item Type Code for bug 2938790
3517 
3518           EXCEPTION
3519           WHEN OTHERS THEN
3520             l_is_model := 'N';
3521           END;
3522 
3523 -- Added for bug 2372098. The IF condition below would set the flag
3524 -- l_is_model to Y, if the configuration has any serviceable
3525 -- INCLUDED items. This check is for copied service lines.
3526 
3527 	   IF (p_x_line_rec.source_document_type_id = 2 AND l_is_model = 'Y') THEN
3528             if l_debug_level > 0 then
3529               oe_debug_pub.add( 'This is a copied service line', 5 );
3530             end if;
3531 	      BEGIN
3532 		 Select 'Y'
3533 		   INTO   l_is_model
3534 		   FROM   oe_order_lines l
3535 		   WHERE  top_model_line_id = p_x_line_rec.service_reference_line_id
3536 		   AND    item_type_code = 'INCLUDED'
3537  		   AND    exists (select null from mtl_system_items mtl where
3538  				  mtl.inventory_item_id = l.inventory_item_id and
3539  				  mtl.serviceable_product_flag = 'Y' and
3540  				  mtl.organization_id=OE_SYS_PARAMETERS.VALUE('MASTER_ORGANIZATION_ID') )
3541 		   AND    ROWNUM = 1;
3542 
3543 	      EXCEPTION
3544 		 WHEN OTHERS THEN
3545 		    l_is_model := 'N';
3546 	      END;
3547 	   END IF; /* source_document_id = 2 and l_is_model = 'Y'*/
3548 
3549 -- end 2372098
3550 
3551 
3552             /* Log the service delayed request only if it is not a split. */
3553             /* Fix for Bug 1802612 */
3554 
3555            if l_debug_level > 0 then
3556 	     oe_debug_pub.ADD('SERVICE: Logging delayed request ');
3557 	     oe_debug_pub.ADD('JPN: What type of item: '|| l_is_model);
3558              oe_debug_pub.add('Split action code:' || p_x_line_rec.split_action_code);
3559              oe_debug_pub.add('Operation:' || p_x_line_rec.operation);
3560              oe_debug_pub.add('Split from line:' || p_x_line_rec.split_from_line_id);
3561            end if;
3562 
3563              IF NOT (( NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT' and
3564                            p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE) or
3565                           (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE and
3566                            p_x_line_rec.split_from_line_id is NOT NULL)) then
3567 
3568 
3569 	     IF p_x_line_rec.service_reference_type_code = 'ORDER' and
3570 		  p_x_line_rec.service_reference_line_id is NOT NULL and
3571 		  (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE or
3572 		  p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE) and
3573 		  l_is_model = 'Y' THEN
3574 		  OE_Delayed_Requests_Pvt.log_request(
3575 					p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3576 					p_entity_id   => p_x_line_rec.line_id,
3577 					p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3578 					p_requesting_entity_id   => p_x_line_rec.line_id,
3579 					p_request_type   => OE_GLOBALS.G_INSERT_SERVICE,
3580 					x_return_status  => l_return_status);
3581 	     END IF; /* delayed request */
3582         END IF; /* service_reference_type_code = ORDER */
3583        END IF;  /*  Check if not split */
3584 -- commented for bug 2372098
3585 --      END IF; /* not from copy order */
3586     END IF; /* service_reference_line_id not equal */
3587 
3588 /*lchen -- bug #1761154 start*/
3589 --For bug 2447402, added INCLUDED, KIT item_type_codes in the IF condition
3590 
3591     IF (p_x_line_rec.item_type_code = 'OPTION' OR
3592         p_x_line_rec.item_type_code = 'CLASS' OR
3593         p_x_line_rec.item_type_code = 'INCLUDED' OR
3594         p_x_line_rec.item_type_code = 'KIT' ) and p_x_line_rec.top_model_line_id is NOT NULL then
3595 
3596    IF NOT (( NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT' and
3597             p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE) or
3598             (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE and
3599             p_x_line_rec.split_from_line_id is NOT NULL)) then
3600 
3601      IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE
3602      THEN
3603     if l_debug_level > 0 then
3604      oe_debug_pub.ADD('operation : '|| p_x_line_rec.operation);
3605      oe_debug_pub.ADD('inventory_item_id : '|| p_x_line_rec.inventory_item_id);
3606     end if;
3607      BEGIN
3608        select distinct 'Y'
3609        into l_serviceable_item
3610        from mtl_system_items mtl
3611        where mtl.inventory_item_id = p_x_line_rec.inventory_item_id
3612       and mtl.organization_id=OE_SYS_PARAMETERS.VALUE('MASTER_ORGANIZATION_ID')
3613       and mtl.serviceable_product_flag='Y';
3614    -- lchen added check for organizations to fix bug 2039304
3615 
3616       EXCEPTION
3617       WHEN OTHERS THEN
3618          l_serviceable_item := 'N';
3619      END;
3620 
3621      if l_debug_level > 0 then
3622       oe_debug_pub.ADD('serviceable option :  '|| l_serviceable_item);
3623 
3624       oe_debug_pub.ADD('service_reference_line_id:  '|| p_x_line_rec.top_model_line_id);
3625      end if;
3626 
3627        IF l_serviceable_item = 'Y' THEN
3628          BEGIN
3629           select distinct 'Y'
3630           into l_serviced_model
3631           from oe_order_lines
3632           where item_type_code = 'SERVICE'
3633           and service_reference_line_id = p_x_line_rec.top_model_line_id
3634           and service_reference_type_code = 'ORDER';
3635 
3636           EXCEPTION
3637           WHEN OTHERS THEN
3638              l_serviced_model := 'N';
3639           END;
3640 
3641          if l_debug_level > 0 then
3642           oe_debug_pub.ADD('serviced model :  '|| l_serviced_model);
3643          end if;
3644 
3645           IF l_serviced_model = 'Y' THEN
3646             if l_debug_level > 0 then
3647               oe_debug_pub.add('Before log delayed request -- G_CASCADE_OPTIONS_SERVICE',1);
3648             end if;
3649               OE_Delayed_Requests_Pvt.log_request(
3650 					p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3651 					p_entity_id   => p_x_line_rec.line_id,
3652 					p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3653 					p_requesting_entity_id   => p_x_line_rec.line_id,
3654 					p_request_type   => OE_GLOBALS.G_CASCADE_OPTIONS_SERVICE,
3655 					x_return_status  => l_return_status);
3656 
3657 	   END IF; /* delayed request -- G_CASCADE_OPTIONS_SERVICE  */
3658        END IF; /*l_serviceable_item = 'Y' */
3659      END IF; /*operation = CREATE */
3660    END IF; /* check if not split */
3661  END IF; /* item_type_code='OPTION' or 'CLASS'*/
3662 
3663     -- oe_debug_pub.add(' out of cascade option condition',1);
3664 
3665 /*lchen -- bug #1761154 end*/
3666 
3667    /* End of service related columns */
3668 
3669     IF NOT OE_GLOBALS.Equal(p_x_line_rec.shipping_instructions,p_old_line_rec.shipping_instructions)
3670     THEN
3671 		-- Need to Call Shipping Update
3672     	l_update_shipping	:= FND_API.G_TRUE;
3673     END IF;
3674 
3675     IF NOT OE_GLOBALS.Equal(p_x_line_rec.packing_instructions,p_old_line_rec.packing_instructions)
3676     THEN
3677 		-- Need to Call Shipping Update
3678     	l_update_shipping	:= FND_API.G_TRUE;
3679     END IF;
3680 
3681    -- Added for the bug 2939731
3682 
3683    IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_item_id,p_old_line_rec.ordered_item_id)
3684     THEN
3685         -- Need to Call Shipping Update
3686         l_update_shipping       := FND_API.G_TRUE;
3687    END IF;
3688 
3689 
3690 -- adding check for changes in project/task
3691 
3692    IF NOT OE_GLOBALS.Equal(p_x_line_rec.project_id,p_old_line_rec.project_id)
3693     THEN
3694         -- Need to Call Shipping Update
3695         l_update_shipping       := FND_API.G_TRUE;
3696    END IF;
3697 
3698 
3699    IF NOT OE_GLOBALS.Equal(p_x_line_rec.task_id,p_old_line_rec.task_id)
3700     THEN
3701         -- Need to Call Shipping Update
3702         l_update_shipping       := FND_API.G_TRUE;
3703    END IF;
3704 
3705 
3706 --ER#7479609 start
3707     IF NOT OE_GLOBALS.Equal(p_x_line_rec.created_by,p_old_line_rec.created_by)
3708        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3709        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
3710        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
3711     THEN
3712           IF l_debug_level > 0 then
3713              oe_debug_pub.ADD('created By update: logging request for eval_hold_source');
3714              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
3715 		             ' Entity ID: '|| to_char(p_x_line_rec.created_by));
3716           END IF;
3717 
3718           OE_delayed_requests_Pvt.log_request(
3719                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3720                     p_entity_id         => p_x_line_rec.line_id,
3721 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3722 		    p_requesting_entity_id         => p_x_line_rec.line_id,
3723                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
3724                     p_request_unique_key1 => 'CREATED_BY',
3725                     p_param1		 => 'CB',
3726                     p_param2		 => p_x_line_rec.created_by,
3727                     x_return_status     => l_return_status);
3728    END IF;
3729 
3730     IF NOT OE_GLOBALS.Equal(p_x_line_rec.creation_date,p_old_line_rec.creation_date)
3731        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3732        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
3733        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
3734     THEN
3735           IF l_debug_level > 0 then
3736              oe_debug_pub.ADD('Creation date update: logging request for eval_hold_source');
3737              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
3738 		             ' Entity ID: '|| to_char(p_x_line_rec.creation_date));
3739           END IF;
3740 
3741           OE_delayed_requests_Pvt.log_request(
3742                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3743                     p_entity_id         => p_x_line_rec.line_id,
3744 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3745 		    p_requesting_entity_id         => p_x_line_rec.line_id,
3746                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
3747                     p_request_unique_key1 => 'CREATION_DATE',
3748                     p_param1		 => 'CD',
3749                     p_param2		 => p_x_line_rec.creation_date,
3750                     x_return_status     => l_return_status);
3751    END IF;
3752 
3753     IF NOT OE_GLOBALS.Equal(p_x_line_rec.sold_to_org_id,p_old_line_rec.sold_to_org_id)
3754        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3755        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
3756        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
3757     THEN
3758           IF l_debug_level > 0 then
3759              oe_debug_pub.ADD('Customer update: logging request for eval_hold_source');
3760              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
3761 		             ' Entity ID: '|| to_char(p_x_line_rec.sold_to_org_id));
3762           END IF;
3763 
3764           OE_delayed_requests_Pvt.log_request(
3765                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3766                     p_entity_id         => p_x_line_rec.line_id,
3767 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3768 		    p_requesting_entity_id         => p_x_line_rec.line_id,
3769                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
3770                     p_request_unique_key1 => 'CUSTOMER',
3771                     p_param1		 => 'C',
3772                     p_param2		 => p_x_line_rec.sold_to_org_id,
3773                     x_return_status     => l_return_status);
3774    END IF;
3775 
3776     IF NOT OE_GLOBALS.Equal(p_x_line_rec.deliver_to_org_id,p_old_line_rec.deliver_to_org_id)
3777        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3778        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
3779        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
3780     THEN
3781           IF l_debug_level > 0 then
3782              oe_debug_pub.ADD('Delver to site update: logging request for eval_hold_source');
3783              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
3784 		             ' Entity ID: '|| to_char(p_x_line_rec.deliver_to_org_id));
3785           END IF;
3786 
3787           OE_delayed_requests_Pvt.log_request(
3788                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3789                     p_entity_id         => p_x_line_rec.line_id,
3790 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3791 		    p_requesting_entity_id         => p_x_line_rec.line_id,
3792                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
3793                     p_request_unique_key1 => 'DELIVER_TO',
3794                     p_param1		 => 'D',
3795                     p_param2		 => p_x_line_rec.deliver_to_org_id,
3796                     x_return_status     => l_return_status);
3797    END IF;
3798 
3799     IF NOT OE_GLOBALS.Equal(p_x_line_rec.line_type_id,p_old_line_rec.line_type_id)
3800        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3801        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
3802        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
3803     THEN
3804           IF l_debug_level > 0 then
3805              oe_debug_pub.ADD('Line Type update: logging request for eval_hold_source');
3806              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
3807 		             ' Entity ID: '|| to_char(p_x_line_rec.line_type_id));
3808           END IF;
3809 
3810           OE_delayed_requests_Pvt.log_request(
3811                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3812                     p_entity_id         => p_x_line_rec.line_id,
3813 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3814 		    p_requesting_entity_id         => p_x_line_rec.line_id,
3815                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
3816                     p_request_unique_key1 => 'LINE_TYPE',
3817                     p_param1		 => 'LT',
3818                     p_param2		 => p_x_line_rec.line_type_id,
3819                     x_return_status     => l_return_status);
3820    END IF;
3821 
3822     IF NOT OE_GLOBALS.Equal(p_x_line_rec.payment_term_id,p_old_line_rec.payment_term_id)
3823        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3824        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
3825        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
3826     THEN
3827           IF l_debug_level > 0 then
3828              oe_debug_pub.ADD('Payment Term update: logging request for eval_hold_source');
3829              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
3830 		             ' Entity ID: '|| to_char(p_x_line_rec.payment_term_id));
3831           END IF;
3832 
3833           OE_delayed_requests_Pvt.log_request(
3834                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3835                     p_entity_id         => p_x_line_rec.line_id,
3836 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3837 		    p_requesting_entity_id         => p_x_line_rec.line_id,
3838                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
3839                     p_request_unique_key1 => 'TERM',
3840                     p_param1		 => 'PT',
3841                     p_param2		 => p_x_line_rec.payment_term_id,
3842                     x_return_status     => l_return_status);
3843    END IF;
3844 
3845     IF NOT OE_GLOBALS.Equal(p_x_line_rec.price_list_id,p_old_line_rec.price_list_id)
3846        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3847        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
3848        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
3849     THEN
3850           IF l_debug_level > 0 then
3851              oe_debug_pub.ADD('Price List update: logging request for eval_hold_source');
3852              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
3853 		             ' Entity ID: '|| to_char(p_x_line_rec.price_list_id));
3854           END IF;
3855 
3856           OE_delayed_requests_Pvt.log_request(
3857                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3858                     p_entity_id         => p_x_line_rec.line_id,
3859 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3860 		    p_requesting_entity_id         => p_x_line_rec.line_id,
3861                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
3862                     p_request_unique_key1 => 'PRICE_LIST',
3863                     p_param1		 => 'PL',
3864                     p_param2		 => p_x_line_rec.price_list_id,
3865                     x_return_status     => l_return_status);
3866    END IF;
3867 
3868     IF NOT OE_GLOBALS.Equal(p_x_line_rec.project_id,p_old_line_rec.project_id)
3869        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3870        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
3871        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
3872     THEN
3873           IF l_debug_level > 0 then
3874              oe_debug_pub.ADD('Project update: logging request for eval_hold_source');
3875              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
3876 		             ' Entity ID: '|| to_char(p_x_line_rec.project_id));
3877           END IF;
3878 
3879           OE_delayed_requests_Pvt.log_request(
3880                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3881                     p_entity_id         => p_x_line_rec.line_id,
3882 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3883 		    p_requesting_entity_id         => p_x_line_rec.line_id,
3884                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
3885                     p_request_unique_key1 => 'PROJECT',
3886                     p_param1		 => 'PR',
3887                     p_param2		 => p_x_line_rec.project_id,
3888                     x_return_status     => l_return_status);
3889    END IF;
3890 
3891     IF NOT OE_GLOBALS.Equal(p_x_line_rec.shipping_method_code,p_old_line_rec.shipping_method_code)
3892        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3893        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
3894        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
3895     THEN
3896           IF l_debug_level > 0 then
3897              oe_debug_pub.ADD('Shipping Method update: logging request for eval_hold_source');
3898              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
3899 		             ' Entity ID: '|| to_char(p_x_line_rec.shipping_method_code));
3900           END IF;
3901 
3902           OE_delayed_requests_Pvt.log_request(
3903                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3904                     p_entity_id         => p_x_line_rec.line_id,
3905 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3906 		    p_requesting_entity_id         => p_x_line_rec.line_id,
3907                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
3908                     p_request_unique_key1 => 'SHIP_METHOD',
3909                     p_param1		 => 'SM',
3910                     p_param2		 => p_x_line_rec.shipping_method_code,
3911                     x_return_status     => l_return_status);
3912    END IF;
3913 
3914     IF NOT OE_GLOBALS.Equal(p_x_line_rec.source_type_code,p_old_line_rec.source_type_code)
3915        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3916        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
3917        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
3918     THEN
3919           IF l_debug_level > 0 then
3920              oe_debug_pub.ADD('Source Type update: logging request for eval_hold_source');
3921              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
3922 		             ' Entity ID: '|| to_char(p_x_line_rec.source_type_code));
3923           END IF;
3924 
3925           OE_delayed_requests_Pvt.log_request(
3926                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3927                     p_entity_id         => p_x_line_rec.line_id,
3928 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3929 		    p_requesting_entity_id         => p_x_line_rec.line_id,
3930                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
3931                     p_request_unique_key1 => 'SOURCE_TYPE',
3932                     p_param1		 => 'ST',
3933                     p_param2		 => p_x_line_rec.source_type_code,
3934                     x_return_status     => l_return_status);
3935    END IF;
3936 
3937     IF NOT OE_GLOBALS.Equal(p_x_line_rec.task_id,p_old_line_rec.task_id)
3938        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3939        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
3940        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
3941     THEN
3942           IF l_debug_level > 0 then
3943              oe_debug_pub.ADD('task id update: logging request for eval_hold_source');
3944              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
3945 		             ' Entity ID: '|| to_char(p_x_line_rec.task_id));
3946           END IF;
3947 
3948           OE_delayed_requests_Pvt.log_request(
3949                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3950                     p_entity_id         => p_x_line_rec.line_id,
3951 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3952 		    p_requesting_entity_id         => p_x_line_rec.line_id,
3953                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
3954                     p_request_unique_key1 => 'TASK',
3955                     p_param1		 => 'T',
3956                     p_param2		 => p_x_line_rec.task_id,
3957                     x_return_status     => l_return_status);
3958    END IF;
3959 
3960     IF NOT OE_GLOBALS.Equal(p_x_line_rec.inventory_item_id,p_old_line_rec.inventory_item_id)
3961        AND p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
3962        AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT'
3963        AND NVL(p_x_line_rec.transaction_phase_code,'F') = 'F'
3964     THEN
3965           IF l_debug_level > 0 then
3966              oe_debug_pub.ADD('Top Model update: logging request for eval_hold_source');
3967              oe_debug_pub.ADD('line ID: '|| to_char(p_x_line_rec.line_id)||
3968 		             ' Entity ID: '|| to_char(p_x_line_rec.inventory_item_id));
3969           END IF;
3970 
3971           OE_delayed_requests_Pvt.log_request(
3972                     p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3973                     p_entity_id         => p_x_line_rec.line_id,
3974 		    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3975 		    p_requesting_entity_id         => p_x_line_rec.line_id,
3976                     p_request_type      => OE_GLOBALS.G_EVAL_HOLD_SOURCE,
3977                     p_request_unique_key1 => 'TOP_MODEL',
3978                     p_param1		 => 'TM',
3979                     p_param2		 => p_x_line_rec.inventory_item_id,
3980                     x_return_status     => l_return_status);
3981    END IF;
3982 
3983 
3984 --ER#7479609 end
3985 
3986     -- bug 1829201, commitment related change.
3987     IF NOT OE_GLOBALS.Equal(p_x_line_rec.commitment_id,p_old_line_rec.commitment_id)
3988     THEN
3989 
3990       l_calculate_commitment_flag := 'Y';
3991       OE_GLOBALS.G_TAX_FLAG := 'Y';
3992 
3993       -- log delayed request for Verify_Payment.
3994      if l_debug_level > 0 then
3995       oe_debug_pub.add('log verify payment delayed request for change in commitment_id', 3);
3996      end if;
3997       l_verify_payment_flag := 'Y';
3998     END IF;
3999 
4000     IF NOT OE_GLOBALS.Equal(p_x_line_rec.commitment_applied_amount,p_old_line_rec.commitment_applied_amount)
4001        AND OE_Commitment_Pvt.Do_Commitment_Sequencing
4002        AND oe_code_control.code_release_level >= '110510'
4003        AND p_x_line_rec.commitment_id IS NOT NULL
4004     THEN
4005      if l_debug_level > 0 then
4006       oe_debug_pub.add('Log verify payment delayed request for change in commitment_applied_amount.',3);
4007      end if;
4008       l_update_commitment_applied := 'Y';
4009 
4010     END IF;
4011 
4012     -- QUOTING changes - log fulfillment requests when transaction phase is
4013     -- updated during complete negotiation WF activity
4014     IF
4015     OE_Quote_Util.G_COMPLETE_NEG = 'Y'
4016        AND
4017       NOT OE_GLOBALS.Equal(p_x_line_rec.transaction_phase_code
4018                            ,p_old_line_rec.transaction_phase_code)
4019     THEN
4020 
4021       -- NOTE: Evaluate Hold Source Requests will be directly executed
4022       -- in post_write, no need to log it here.
4023 
4024       if l_debug_level > 0 then
4025          oe_debug_pub.add('Log Complete Neg Requests for Line');
4026       end if;
4027 
4028       -- log a delayed request to get included items for this item if any.
4029 
4030       l_freeze_method := G_FREEZE_METHOD; /* Bug # 5036404 */
4031      if l_debug_level > 0 then
4032       oe_debug_pub.ADD('Freeze method is :' || l_freeze_method,2);
4033      end if;
4034 
4035       IF l_freeze_method = OE_GLOBALS.G_IIFM_ENTRY AND
4036          p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
4037          p_x_line_rec.ato_line_id is NULL AND
4038          ( p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
4039            (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT AND
4040             p_x_line_rec.line_id = p_x_line_rec.top_model_line_id))
4041       THEN
4042            p_x_line_rec.explosion_date := null;
4043            l_count := l_count + 1;
4044            OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL(l_count):= p_x_line_rec.line_id;
4045       END IF;
4046 
4047       -- log request to calculate commitment
4048       IF p_x_line_rec.commitment_id IS NOT NULL THEN
4049          l_calculate_commitment_flag := 'Y';
4050       END IF;
4051 
4052        --Customer Acceptance
4053        l_def_contingency_attributes := FND_API.G_TRUE;
4054 
4055     END IF; -- End if phase is updated and complete neg is 'Y'
4056     -- QUOTING changes: END
4057 
4058     --Customer Acceptance:: Log delayed request to default contingency attributes
4059 
4060     IF NOT OE_GLOBALS.Equal(p_x_line_rec.contingency_id,p_old_line_rec.contingency_id)
4061     THEN
4062       --Customer Acceptance
4063        l_def_contingency_attributes := FND_API.G_TRUE;
4064     END IF;
4065 
4066       IF l_debug_level > 0 then
4067          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);
4068       END IF;
4069       IF NVL(OE_SYS_PARAMETERS.VALUE('ENABLE_FULFILLMENT_ACCEPTANCE'), 'N') = 'Y'
4070 	 AND (NVL( p_x_line_rec.booked_flag, 'N') = 'N' OR
4071                  p_x_line_rec.operation=OE_GLOBALS.G_OPR_CREATE)
4072          AND  l_def_contingency_attributes = FND_API.G_TRUE
4073          AND   p_x_line_rec.inventory_item_id IS NOT NULL
4074          AND   p_x_line_rec.inventory_item_id <> FND_API.G_MISS_NUM
4075          AND   p_x_line_rec.line_type_id IS NOT NULL
4076          AND   p_x_line_rec.line_type_id <> FND_API.G_MISS_NUM
4077         THEN
4078 
4079          IF ( p_x_line_rec.line_category_code = 'RETURN' OR
4080              p_x_line_rec.source_document_type_id = 10 OR
4081            (p_x_line_rec.order_source_id=27 AND p_x_line_rec.retrobill_request_id IS NOT NULL) OR
4082            (p_x_line_rec.item_type_code IN ('CONFIG', 'SERVICE', 'CLASS', 'OPTION', 'INCLUDED')) OR
4083            (p_x_line_rec.item_type_code='KIT' AND p_x_line_rec.top_model_line_id <> p_x_line_rec.line_id) OR
4084            (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
4085            (p_x_line_rec.operation=OE_GLOBALS.G_OPR_CREATE AND p_x_line_rec.split_from_line_id IS NOT NULL) OR
4086            (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
4087             NVL(p_x_line_rec.transaction_phase_code, 'F') = 'N') THEN
4088 	     IF l_debug_level  > 0 THEN
4089               oe_debug_pub.add('Item_type_code:'||p_x_line_rec.item_type_code||'-Do not default Contingency Attributes for this line' );
4090              END IF;
4091 
4092 	     OE_ACCEPTANCE_UTIL.Register_Changed_Lines(
4093                 p_line_id           => p_x_line_rec.line_id
4094               , p_header_id         => p_x_line_rec.header_id
4095               , p_line_type_id      => p_x_line_rec.line_type_id
4096               , p_sold_to_org_id    => p_x_line_rec.sold_to_org_id
4097               , p_invoice_to_org_id => p_x_line_rec.invoice_to_org_id
4098               , p_inventory_item_id => p_x_line_rec.inventory_item_id
4099               , p_shippable_flag    => p_x_line_rec.shippable_flag
4100               , p_org_id            => p_x_line_rec.org_id
4101               , p_accounting_rule_id  => p_x_line_rec.accounting_rule_id
4102               , p_operation         => OE_GLOBALS.G_OPR_DELETE);
4103 
4104          ELSE
4105 
4106 	     OE_ACCEPTANCE_UTIL.Register_Changed_Lines(
4107                 p_line_id           => p_x_line_rec.line_id
4108               , p_header_id         => p_x_line_rec.header_id
4109               , p_line_type_id      => p_x_line_rec.line_type_id
4110               , p_sold_to_org_id    => p_x_line_rec.sold_to_org_id
4111               , p_invoice_to_org_id => p_x_line_rec.invoice_to_org_id
4112               , p_inventory_item_id => p_x_line_rec.inventory_item_id
4113               , p_shippable_flag    => p_x_line_rec.shippable_flag
4114               , p_org_id            => p_x_line_rec.org_id
4115               , p_accounting_rule_id  => p_x_line_rec.accounting_rule_id
4116               , p_operation         => p_x_line_rec.operation);
4117 
4118 	    /** Logic to Default Contingency attributes**/
4119 	    oe_delayed_requests_pvt.log_request(
4120                      p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
4121                      p_entity_id              => p_x_line_rec.header_id,
4122                      p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
4123                      p_requesting_entity_id   => p_x_line_rec.header_id,
4124                      p_request_type           => OE_GLOBALS.G_DFLT_CONTINGENCY_ATTRIBUTES,
4125                      x_return_status          => l_return_status);
4126 
4127 	 END IF;
4128      END IF;
4129      -- Customer Acceptance Changes End
4130 
4131 	-- Log the delayed request for Update Shipping if any of the attributes in
4132 	-- which Shipping is interested has been changed and the line has been
4133 	-- interfaced with Shipping.
4134 
4135      IF (p_x_line_rec.shipping_interfaced_flag = 'Y' AND
4136         (l_update_shipping = FND_API.G_TRUE OR l_explosion_date_changed = FND_API.G_TRUE) AND
4137         (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT')) THEN
4138 
4139        if l_debug_level > 0 then
4140          oe_debug_pub.ADD('Logging update shipping delayed request for line ID :  '|| to_char(p_x_line_rec.line_id) ,1);
4141        end if;
4142 
4143        OE_Delayed_Requests_Pvt.Log_Request(
4144 		p_entity_code			=>	OE_GLOBALS.G_ENTITY_LINE,
4145 		p_entity_id			=>	p_x_line_rec.line_id,
4146 		p_requesting_entity_code	=>	OE_GLOBALS.G_ENTITY_LINE,
4147 		p_requesting_entity_id  	=>	p_x_line_rec.line_id,
4148 		p_request_type			=>	OE_GLOBALS.G_UPDATE_SHIPPING,
4149 		p_request_unique_key1		=>	p_x_line_rec.operation,
4150 		p_param1             		=>	l_update_shipping,
4151 		p_param2             		=>	l_explosion_date_changed,
4152 		p_param5             		=>	l_ordered_quantity_changed,
4153 		x_return_status			=>	l_return_status);
4154 
4155     END IF;
4156 
4157     If l_copy_adjustments and
4158 		not l_no_copy_adjustments THEN
4159 
4160                 -- commented out for bug 1917869
4161                 -- p_x_line_rec.calculate_price_flag in ('N','P') then
4162 
4163 	   If p_x_line_rec.split_from_line_id is not null and
4164 			p_x_line_rec.split_from_line_id <> fnd_api.g_miss_num then
4165 		l_from_line_id	:= p_x_line_rec.split_from_line_id ;
4166 		l_from_header_id := p_x_line_rec.header_id;
4167 	   elsif p_x_line_rec.reference_line_id is not null and
4168 			p_x_line_rec.reference_line_id <> fnd_api.g_miss_num then
4169 		l_from_line_id	:= p_x_line_rec.reference_line_id ;
4170 		l_from_header_id := p_x_line_rec.reference_Header_id;
4171 	   elsif p_x_line_rec.source_document_line_id is not null and
4172 			p_x_line_rec.source_document_line_id <> fnd_api.g_miss_num then
4173 		l_from_line_id	:= p_x_line_rec.source_document_line_id ;
4174 		l_from_header_id := p_x_line_rec.source_document_id;
4175 	   End If;
4176 
4177         OE_delayed_requests_Pvt.log_request(
4178 				p_entity_code 			=> OE_GLOBALS.G_ENTITY_LINE,
4179 				p_entity_id         	=> p_x_line_rec.line_id,
4180 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4181 				p_requesting_entity_id   => p_x_line_rec.line_id,
4182 		 		p_param1                 => p_x_line_rec.header_id,
4183                  	p_param2                 => l_from_line_id,
4184                  	p_param3                 => l_from_header_id,
4185 		 		p_param4                 => p_x_line_rec.line_category_code,
4186 		 		p_param5                 => p_x_line_rec.split_by,
4187 		 		p_param6                 => p_x_line_rec.booked_flag,
4188 		 		p_request_type           => OE_GLOBALS.G_COPY_ADJUSTMENTS,
4189 		 		x_return_status          => l_return_status);
4190 
4191     end if;
4192 
4193 
4194 /* csheu -- bug #1533658 S */
4195     IF l_copy_service_fields and
4196 	  p_x_line_rec.item_type_code = 'SERVICE' and
4197 	  p_x_line_rec.service_reference_type_code  = 'ORDER' and
4198        p_x_line_rec.service_reference_line_id is NOT NULL and
4199 	  p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
4200 	  BEGIN
4201 
4202             Select 'Y'
4203             INTO   l_is_model
4204             FROM   oe_order_lines
4205             WHERE  line_id = p_x_line_rec.service_reference_line_id
4206             AND    item_type_code in ('INCLUDED', 'MODEL', 'CLASS', 'OPTION') ;
4207 
4208        EXCEPTION
4209         WHEN OTHERS THEN
4210           l_is_model := 'N';
4211        END;
4212 
4213        IF l_is_model = 'Y' THEN
4214         if l_debug_level > 0 then
4215          oe_debug_pub.add('CSH Before log request --G_UPDATE_SERVICE', 1);
4216         end if;
4217          OE_Delayed_Requests_Pvt.log_request(
4218                          p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4219                          p_entity_id   => p_x_line_rec.line_id,
4220                          p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4221                          p_requesting_entity_id   => p_x_line_rec.line_id,
4222                          p_request_type   => OE_GLOBALS.G_UPDATE_SERVICE,
4223                          x_return_status  => l_return_status);
4224        END IF;
4225     END IF; /* IF l_copy_service_fields... = TRUE */
4226 
4227    if l_debug_level > 0 then
4228     oe_debug_pub.add('CSH --OUT of l_copy_service_field condition ', 1);
4229    end if;
4230 /* csheu -- bug #1533658 E */
4231     -- added by lkxu
4232     IF l_copy_pricing_attributes THEN
4233 	   IF p_x_line_rec.split_from_line_id is not null and
4234 		p_x_line_rec.split_from_line_id <> fnd_api.g_miss_num THEN
4235 		  l_from_line_id	:= p_x_line_rec.split_from_line_id ;
4236 		  l_from_header_id := p_x_line_rec.header_id;
4237 	   ELSIF p_x_line_rec.reference_line_id is not null and
4238 		p_x_line_rec.reference_line_id <> fnd_api.g_miss_num THEN
4239 		  l_from_line_id	:= p_x_line_rec.reference_line_id ;
4240 		  l_from_header_id := p_x_line_rec.reference_Header_id;
4241 	   ELSIF p_x_line_rec.source_document_line_id is not null and
4242 		p_x_line_rec.source_document_line_id <> fnd_api.g_miss_num THEN
4243 		  l_from_line_id	:= p_x_line_rec.source_document_line_id ;
4244 		  l_from_header_id := p_x_line_rec.source_document_id;
4245 	   End IF;
4246 
4247         OE_delayed_requests_Pvt.log_request(
4248 				p_entity_code 			=> OE_GLOBALS.G_ENTITY_LINE,
4249 				p_entity_id         	=> p_x_line_rec.line_id,
4250 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4251 				p_requesting_entity_id   => p_x_line_rec.line_id,
4252 		 		p_param1                 => p_x_line_rec.header_id,
4253                  	p_param2                 => l_from_line_id,
4254                  	p_param3                 => l_from_header_id,
4255 		 		p_request_type           => OE_GLOBALS.G_COPY_PRICING_ATTRIBUTES,
4256 		 		x_return_status          => l_return_status);
4257 
4258     END IF;
4259 
4260     -----------------------------------------------------------
4261     --Set included item to 0 since it is should not be priced
4262     --No pricing should be called bug 1620213
4263     -----------------------------------------------------------
4264     If p_x_line_rec.item_type_code In ('INCLUDED','CONFIG') Then
4265          P_x_line_rec.unit_selling_price := 0;
4266          p_x_line_rec.unit_list_price := 0;
4267          P_x_line_rec.unit_selling_price_per_pqty := 0;
4268          p_x_line_rec.unit_list_price_per_pqty := 0;
4269 
4270 /* Added the following two lines to fix the bug 2175029 */
4271          p_x_line_rec.pricing_quantity := p_x_line_rec.ordered_quantity;
4272          p_x_line_rec.pricing_quantity_uom := p_x_line_rec.order_quantity_uom;
4273 
4274 
4275          If p_x_line_rec.item_type_code = 'INCLUDED' and
4276             l_charges_for_included_item = 'Y' Then
4277            oe_globals.g_price_flag := 'Y';
4278          --Elsif p_x_line_rec.item_type_code = 'CONFIG' THEN
4279          --  oe_globals.g_price_flag := 'Y';
4280          Else
4281           if l_debug_level > 0 then
4282            oe_debug_pub.add('2207809: no price for config item', 3);
4283           end if;
4284            oe_globals.g_price_flag := 'N';
4285          End If;
4286     End If;
4287 
4288     -------------------------------------------------------------------
4289     --In the future all pricing related operations will be handled
4290     --by process_pricing.  The purpose of this is to reduce file locking
4291     --issue on OEXULINB.pls
4292     -------------------------------------------------------------------
4293     OE_LINE_ADJ_UTIL.Process_Pricing(p_x_new_line_rec => p_x_line_rec,
4294                                      p_old_line_rec   => p_old_line_rec,
4295                                      p_no_price_flag  => l_no_price_flag);
4296 
4297   if l_debug_level > 0 then
4298    oe_debug_pub.add('unit_list_price:'||p_x_line_rec.unit_list_price);
4299    oe_debug_pub.add('old unit_list_price:'||p_old_line_rec.unit_list_price);
4300    oe_debug_pub.add('original_list_price:'||p_x_line_rec.original_list_price);
4301   end if;
4302 -- Override List Price
4303     IF  ((p_x_line_rec.unit_list_price IS NOT NULL AND
4304          p_x_line_rec.unit_list_price <> FND_API.G_MISS_NUM AND
4305 --       p_x_line_rec.unit_list_price <> p_x_line_rec.original_list_price AND
4306          p_x_line_rec.unit_list_price <> p_old_line_rec.unit_list_price)
4307        OR
4308          (p_x_line_rec.unit_list_price IS NULL))
4309        AND
4310          p_old_line_rec.unit_list_price IS NOT NULL AND
4311          p_old_line_rec.unit_list_price <> FND_API.G_MISS_NUM AND
4312          p_x_line_rec.original_list_price  IS NOT NULL AND
4313          p_x_line_rec.original_list_price <> FND_API.G_MISS_NUM AND
4314          p_x_line_rec.Ordered_Quantity <> fnd_api.g_miss_num and
4315          p_x_line_rec.order_quantity_uom is not null and
4316          p_x_line_rec.order_quantity_uom <> fnd_api.g_miss_char
4317          AND oe_code_control.code_release_level >= '110510'
4318          -- bug 3491752
4319          --AND /*nvl(fnd_profile.value('ONT_LIST_PRICE_OVERRIDE_PRIV'), 'NONE')*/          --G_LIST_PRICE_OVERRIDE  = 'UNLIMITED' --bug4080363
4320          AND  OE_GLOBALS.G_UI_FLAG
4321          AND  OE_Globals.G_PRICING_RECURSION = 'N' THEN
4322 
4323             IF p_x_line_rec.unit_list_price IS NOT NULL AND
4324                p_x_line_rec.unit_list_price <> FND_API.G_MISS_NUM AND
4325                p_x_line_rec.original_list_price  IS NOT NULL AND
4326                p_x_line_rec.original_list_price <> FND_API.G_MISS_NUM THEN
4327        --      p_x_line_rec.unit_list_price <> p_x_line_rec.original_list_price THEN
4328 
4329                    -- setting unit_list_price_per_pqty appropriately
4330                    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;
4331                  if l_debug_level > 0 then
4332                    oe_debug_pub.add('setting unit_list_price_per_pqty to:'||p_x_line_rec.unit_list_price_per_pqty);
4333                  end if;
4334             END IF;
4335 
4336             IF p_old_line_rec.unit_list_price IS NOT NULL AND
4337                p_x_line_rec.unit_list_price IS NULL AND
4338                p_x_line_rec.original_list_price IS NOT NULL THEN
4339 
4340                    -- setting unit_list_price_per_pqt, original_list_price to null
4341                  if l_debug_level > 0 then
4342                    oe_debug_pub.add('setting original_list_price, unit_list_price_per_pqty to null');
4343                  end if;
4344                    p_x_line_rec.original_list_price := NULL;
4345                    p_x_line_rec.unit_list_price_per_pqty := NULL;
4346 
4347             END IF;
4348            if l_debug_level > 0 then
4349             oe_debug_pub.add('setting call_pricing for list price override');
4350            end if;
4351             L_Call_pricing := 'Y';
4352     End If;
4353 -- Override List Price
4354     IF 	oe_globals.g_price_flag = 'Y' and
4355 		not l_no_price_flag  and
4356 		nvl(oe_globals.g_pricing_recursion,'N') <> 'Y'  and
4357 	  	--bsadri nvl(p_x_line_rec.ordered_quantity,0) <> 0 and
4358                 --For bug 7115648
4359                 p_x_line_rec.inventory_item_id  is not null and
4360 	  	--End of 7115648
4361 		p_x_line_rec.Ordered_Quantity <> fnd_api.g_miss_num and
4362 		p_x_line_rec.order_quantity_uom is not null and
4363 		p_x_line_rec.order_quantity_uom <> fnd_api.g_miss_char
4364        or  l_call_pricing = 'Y' --Override List Price
4365 	THEN
4366                 --bsadri for cancelled lines l_zero_line_qty is true
4367 
4368                 IF nvl(p_x_line_rec.ordered_quantity,0) = 0 THEN
4369                     l_zero_line_qty := TRUE;
4370                     /* BUG 2013611 BEGIN */
4371                   if l_debug_level > 0 then
4372 	            oe_debug_pub.ADD('Logging REVERSE_LIMITS delayed request for LINE CANCEL ',1);
4373                   end if;
4374                     OE_delayed_requests_Pvt.log_request(
4375 				p_entity_code 		 => OE_GLOBALS.G_ENTITY_LINE,
4376 				p_entity_id              => p_x_line_rec.line_id,
4377 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4378 				p_requesting_entity_id   => p_x_line_rec.line_id,
4379 				p_request_unique_key1  	 => 'LINE',
4380 		 		p_param1                 => 'CANCEL',
4381 		 		p_param2                 => p_x_line_rec.price_request_code,
4382 		 		p_param3                 => NULL,
4383 		 		p_param4                 => NULL,
4384 		 		p_param5                 => NULL,
4385 		 		p_param6                 => NULL,
4386 		 		p_request_type           => OE_GLOBALS.G_REVERSE_LIMITS,
4387 		 		x_return_status          => l_return_status);
4388                   if l_debug_level > 0 then
4389 	            oe_debug_pub.ADD('REVERSE_LIMITS Delayed request has been logged',1);
4390                   end if;
4391                     /* BUG 2013611 END */
4392                 ELSE
4393                     l_zero_line_qty := FALSE;
4394                 END IF;
4395 		If
4396 		( (p_x_line_rec.unit_list_price is null or
4397 		  p_x_line_rec.Unit_List_Price = fnd_api.g_miss_num or
4398 		  NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,p_old_line_rec.ordered_quantity) or
4399 		  NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity2,p_old_line_rec.ordered_quantity2) or -- INVCONV 2317146 - INVCONV STET
4400 		  NOT OE_GLOBALS.Equal(p_x_line_rec.cancelled_Quantity,p_old_line_rec.cancelled_Quantity) or
4401 		   NOT OE_GLOBALS.Equal(p_x_line_rec.order_quantity_uom,p_old_line_rec.order_quantity_uom) or
4402 		   NOT OE_GLOBALS.Equal(p_x_line_rec.inventory_item_id,p_old_line_rec.inventory_item_id) or   --fix bug 1388503 btea
4403                    NOT OE_GLOBALS.Equal(p_x_line_rec.unit_list_price,p_old_line_rec.unit_list_price)  )
4404                   and p_x_line_rec.item_type_code <> OE_GLOBALS.G_ITEM_SERVICE
4405 		   )
4406            --RT{
4407                and nvl(p_x_line_rec.retrobill_request_id,FND_API.G_MISS_NUM)= FND_API.G_MISS_NUM
4408            --RT}
4409                or l_call_pricing = 'Y' -- Override List Price
4410 	   then
4411 
4412 
4413                IF ((OE_GLOBALS.G_UI_FLAG)
4414                 and OE_GLOBALS.G_DEFER_PRICING='N'
4415                 and (nvl(Oe_Config_Pvt.oecfg_configuration_pricing,'N')='N'))
4416                THEN
4417 
4418           	l_Price_Control_Rec.pricing_event := 'PRICE';
4419 			l_Price_Control_Rec.calculate_flag := QP_PREQ_GRP.G_SEARCH_N_CALCULATE;
4420 			l_Price_Control_Rec.Simulation_Flag := 'N';
4421 
4422 			l_x_line_tbl(1) := p_x_line_rec;
4423                         IF NOT l_zero_line_qty THEN
4424                          --bsadri call the Price_line for non-cancelled lines
4425                          if l_debug_level > 0 then
4426                           oe_debug_pub.add('list price before call to price_line:'||p_x_line_rec.unit_list_price);
4427                           oe_debug_pub.add('list price per pqty  before call to price_line:'||p_x_line_rec.unit_list_price_per_pqty);
4428                          end if;
4429 			  oe_order_adj_pvt.Price_line(
4430 				X_Return_Status     => l_Return_Status
4431 				,p_Line_id          => p_x_line_rec.line_id
4432 				,p_Request_Type_code=> 'ONT'
4433 				,p_Control_rec      => l_Price_Control_Rec
4434 				,p_Write_To_Db		=> FALSE
4435 				,x_Line_Tbl		=> l_x_Line_Tbl
4436 				);
4437 
4438 			   -- Populate Line_rec
4439 			   -- Fix for Bug 3374889. Commented the while loop and
4440                            -- and assigned l_x_Line_Tbl(1) to line_rec.
4441                            p_x_line_rec := l_x_Line_Tbl(1);
4442                            /*
4443                             i:= l_x_Line_Tbl.First;
4444 			    While i is not null loop
4445 				  p_x_line_rec := l_x_Line_Tbl(i);
4446 				  i:= l_x_Line_Tbl.Next(i);
4447 			    End Loop;
4448                            */
4449                         if l_debug_level > 0 then
4450                           oe_debug_pub.add('list price after call to price_line:'||p_x_line_rec.unit_list_price);
4451                           oe_debug_pub.add('list price per pqty  after call to price_line:'||p_x_line_rec.unit_list_price_per_pqty);
4452                         end if;
4453                   -- Bug 2757443.
4454                   -- Need to log delayed request for tax and commitment
4455                   -- when unit_selling_price changes from null to not null
4456                   -- during PRICE event.
4457                   IF NOT OE_GLOBALS.Equal(p_old_line_rec.unit_selling_price,
4458                          l_x_Line_Tbl(1).unit_selling_price) THEN
4459 
4460                      OE_GLOBALS.G_TAX_FLAG := 'Y';
4461                      IF l_x_Line_Tbl(1).commitment_id IS NOT NULL THEN
4462                        l_calculate_commitment_flag := 'Y';
4463                      END IF;
4464                   END IF;
4465 
4466                 if l_debug_level > 0 then
4467                   oe_debug_pub.add('outside margin code',1);
4468                 end if;
4469                             --MRG BGN
4470                           If OE_FEATURES_PVT.Is_Margin_Avail Then
4471                  if l_debug_level > 0 then
4472                   oe_debug_pub.add('inside margin code',1);
4473                  end if;
4474                             p_x_line_rec.unit_cost:=OE_MARGIN_PVT.GET_COST(p_x_line_rec);
4475                           End If;
4476                             --MRG END
4477 
4478                           END IF;
4479 	   End If;
4480         End If;  --end if for UI Flag Check
4481          if l_debug_level > 0 then
4482 	   oe_debug_pub.ADD('Logging delayed request for pricing');
4483          end if;
4484         IF ((OE_GLOBALS.G_UI_FLAG)
4485           and OE_GLOBALS.G_DEFER_PRICING='N'
4486           and (nvl(Oe_Config_Pvt.oecfg_configuration_pricing,'N')='N'))
4487           OR (p_x_line_rec.item_type_code = 'INCLUDED' and OE_GLOBALS.G_DEFER_PRICING='N')
4488           --RT
4489           and nvl(p_x_line_rec.retrobill_request_id,FND_API.G_MISS_NUM)=FND_API.G_MISS_NUM THEN
4490          if l_debug_level > 0 then
4491           oe_debug_pub.add('ui mode or config, included item'||p_x_line_rec.line_id);
4492          end if;
4493          IF NOT l_zero_line_qty THEN
4494              --bsadri don't call this for a cancelled line
4495 
4496            IF nvl(p_x_line_rec.item_type_code,'x') <> 'INCLUDED' THEN
4497              --bug 2855794
4498      if l_debug_level > 0 then
4499       oe_debug_pub.ADD('Calc price flag:'||p_x_line_rec.calculate_price_flag);
4500      end if;
4501              if (p_x_line_rec.calculate_price_flag <> 'N' OR
4502                  l_item_rec.ont_pricing_qty_source = 'S' ) THEN -- INVCONV
4503                 if l_debug_level > 0 then
4504                  oe_debug_pub.ADD('logging price line request');
4505                 end if;
4506 
4507                 OE_delayed_requests_Pvt.log_request(
4508 		p_entity_code 			=> OE_GLOBALS.G_ENTITY_LINE,
4509 		p_entity_id         	=> p_x_line_rec.line_id,
4510 		p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4511 		p_requesting_entity_id   => p_x_line_rec.line_id,
4512 		p_request_unique_key1  	=> 'LINE',
4513 		p_param1                 => p_x_line_rec.header_id,
4514                	p_param2                 => 'LINE',
4515 		p_request_type           => OE_GLOBALS.G_PRICE_LINE,
4516 		x_return_status          => l_return_status);
4517              end if; --bug 2855794
4518 
4519            ELSE
4520 
4521              IF OE_LINE_ADJ_UTIL.Is_Pricing_Related_Change(p_x_line_rec,p_old_line_rec)
4522 	     OR NOT OE_GLOBALS.Equal(p_x_line_rec.shipping_method_code,p_old_line_rec.shipping_method_code) THEN
4523                if l_debug_level > 0 then
4524                 oe_debug_pub.add('renga-logging delayed req freight_for_included',1);
4525                end if;
4526 
4527                OE_delayed_requests_Pvt.log_request(
4528 				p_entity_code 	=> OE_GLOBALS.G_ENTITY_ALL,
4529 				p_entity_id     => p_x_line_rec.header_id,
4530 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
4531 				p_requesting_entity_id   => p_x_line_rec.header_id,
4532 				p_request_unique_key1  	=> 'ORDER',
4533 		 		p_param1                 => p_x_line_rec.header_id,
4534                  		p_param2                 => 'ORDER',
4535 		 		p_request_type           => OE_GLOBALS.G_FREIGHT_FOR_INCLUDED,
4536 		 		x_return_status          => l_return_status);
4537 
4538                if l_debug_level > 0 then
4539                 oe_debug_pub.add('renga-after logging delayed req freight_for_included',1);
4540                end if;
4541              END IF;
4542 
4543            END IF;  -- if item type code is not included
4544 
4545          END IF;  -- if not l_zero_line_qty
4546           IF p_x_line_rec.item_type_code <> 'INCLUDED' THEN
4547              IF p_x_line_rec.booked_flag='Y' THEN  --2442012
4548                  l_pricing_event := 'BATCH,ORDER,BOOK';  --7494393
4549              ELSE
4550                  l_pricing_event := 'ORDER';
4551              END IF;
4552            OE_delayed_requests_Pvt.log_request(
4553 				p_entity_code 			=> OE_GLOBALS.G_ENTITY_ALL,
4554 				p_entity_id         	=> p_x_line_rec.Header_Id,
4555 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
4556 				p_requesting_entity_id   => p_x_line_rec.Header_Id,
4557 				p_request_unique_key1  	=> l_pricing_event,
4558 		 		p_param1                 => p_x_line_rec.header_id,
4559                  		p_param2                 => l_pricing_event,
4560 		 		p_request_type           => OE_GLOBALS.G_PRICE_ORDER,
4561 		 		x_return_status          => l_return_status);
4562           END IF;  -- item_type_code not included
4563         ELSE
4564          if l_debug_level > 0 then
4565           oe_debug_pub.add('batch mode or defer pricing');
4566          end if;
4567          --RT{
4568           IF nvl(p_x_line_rec.retrobill_request_id,FND_API.G_MISS_NUM)<>FND_API.G_MISS_NUM Then
4569               --call pricing for retrobilling lines in one shot (PRICE_ORDER)
4570              IF p_x_line_rec.operation=OE_GLOBALS.G_OPR_CREATE THEN
4571                l_retrobill_operation:='CREATE';
4572              ELSE
4573                l_retrobill_operation:='UPDATE';
4574              END IF;
4575 
4576 
4577               OE_delayed_requests_Pvt.log_request(
4578 				p_entity_code 			=> OE_GLOBALS.G_ENTITY_ALL,
4579 				p_entity_id         	=> p_x_line_rec.Header_Id,
4580 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
4581 				p_requesting_entity_id   => p_x_line_rec.Header_Id,
4582 				p_request_unique_key1  	=> 'RETROBILL',
4583 		 		p_param1                 => p_x_line_rec.header_id,
4584                  		p_param2                 => 'RETROBILL',
4585                                 p_param3                 => l_retrobill_operation,
4586 		 		p_request_type           => OE_GLOBALS.G_PRICE_ORDER,
4587 		 		x_return_status          => l_return_status);
4588 
4589               --copy the adjustments over to the new retrobilling line
4590               OE_delayed_requests_Pvt.log_request(
4591 				p_entity_code 		=> OE_GLOBALS.G_ENTITY_LINE,
4592 				p_entity_id         	 => p_x_line_rec.line_id,
4593 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4594 				p_requesting_entity_id   => p_x_line_rec.line_id,
4595 		 		p_param1                 => p_x_line_rec.header_id,
4596                                 --x_line_rec.orig_sys_line_ref stores orignial line_id
4597                                 --p_param2 is copy_line_line_id
4598                  	        p_param2                 => p_x_line_rec.orig_sys_line_ref,
4599                                 --orig_sys_document_ref stores original header_id
4600                                 --p_param3 is copy_from_header_id
4601                  	        p_param3                 => p_x_line_rec.orig_sys_document_ref,
4602 		 		p_param4                 => p_x_line_rec.line_category_code,
4603 		 		p_param5                 => p_x_line_rec.split_by,
4604 		 		p_param6                 => p_x_line_rec.booked_flag,
4605 		 		p_request_type           => OE_GLOBALS.G_COPY_ADJUSTMENTS,
4606                                 p_param7                   => 'RETROBILL',
4607                                 p_param8   => p_x_line_rec.retrobill_request_id,
4608 		 		x_return_status          => l_return_status);
4609           --RT}
4610           Else
4611            IF p_x_line_rec.booked_flag='Y' and p_x_line_rec.item_type_code <> 'INCLUDED' Then
4612                   l_pricing_event := 'BATCH,BOOK';
4613            ELSE
4614                   l_pricing_event := 'BATCH';
4615            END IF;
4616 
4617            IF OE_GLOBALS.G_DEFER_PRICING='Y' AND
4618               p_x_line_rec.booked_flag='Y'AND
4619               p_x_line_rec.item_type_code <>'INCLUDED' THEN  --2442012
4620                 l_pricing_event := 'PRICE,BATCH,BOOK';
4621            ELSIF OE_GLOBALS.G_DEFER_PRICING='Y' THEN
4622                 l_pricing_event := 'PRICE,BATCH';
4623            END IF;
4624 
4625            OE_delayed_requests_Pvt.log_request(
4626 				p_entity_code 			=> OE_GLOBALS.G_ENTITY_ALL,
4627 				p_entity_id         	=> p_x_line_rec.Header_Id,
4628 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
4629 				p_requesting_entity_id   => p_x_line_rec.Header_Id,
4630 				p_request_unique_key1  	=> l_pricing_event,
4631 		 		p_param1                 => p_x_line_rec.header_id,
4632                  		p_param2                 => l_pricing_event,
4633 		 		p_request_type           => OE_GLOBALS.G_PRICE_ORDER,
4634 		 		x_return_status          => l_return_status);
4635           END IF;   --RT
4636         END IF;     --2442012
4637 
4638   /*         If p_x_line_rec.booked_flag='Y' and p_x_line_rec.item_type_code <> 'INCLUDED' Then
4639            OE_delayed_requests_Pvt.log_request(
4640 				p_entity_code 			=> OE_GLOBALS.G_ENTITY_ALL,
4641 				p_entity_id         	=> p_x_line_rec.Header_Id,
4642 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
4643 				p_requesting_entity_id   => p_x_line_rec.Header_Id,
4644 				p_request_unique_key1  	=> 'BOOK',
4645 		 		p_param1                 => p_x_line_rec.header_id,
4646                  		p_param2                 => 'BOOK',
4647 		 		p_request_type           => OE_GLOBALS.G_PRICE_ORDER,
4648 		 		x_return_status          => l_return_status);
4649 	   End If;
4650   */
4651       --  fixed bug 1688064, move the following line out of IF block.
4652 	 --  Oe_Globals.g_price_flag := 'N';
4653      END IF;
4654 
4655 	/* rlanka: Fix for Bug 1729372
4656 
4657             For the new line that is created by Promotional modifier
4658             need to log a delayed request to PRICE_LINE again to apply
4659 	    freight charges.
4660 
4661          */
4662 
4663       if l_debug_level > 0 then
4664         oe_debug_pub.add('g_price_flag = ' || oe_globals.g_price_flag);
4665         --oe_debug_pub.add('l_no_price_flag = '|| l_no_price_flag);
4666         oe_debug_pub.add('g_pricing_recursion = ' || oe_globals.g_pricing_recursion);
4667         oe_debug_pub.add('Ordered quantity = '|| to_char(p_x_line_rec.ordered_quantity));
4668         oe_debug_pub.add('Ordered qty UOM = ' || p_x_line_rec.order_quantity_uom);
4669         oe_debug_pub.add('Calculate_price_flag = '|| p_x_line_rec.calculate_price_flag);
4670       end if;
4671 
4672 	 if (oe_globals.g_price_flag = 'Y' and
4673             not l_no_price_flag and
4674             oe_globals.g_pricing_recursion = 'Y' and
4675             nvl(p_x_line_rec.ordered_quantity,0) <> 0 and
4676             p_x_line_rec.Ordered_Quantity <> fnd_api.g_miss_num and
4677             p_x_line_rec.order_quantity_uom is not null and
4678             p_x_line_rec.order_quantity_uom <> fnd_api.g_miss_char and
4679             p_x_line_rec.calculate_price_flag = 'R')
4680            --RT{
4681             and nvl(p_x_line_rec.retrobill_request_id,FND_API.G_MISS_NUM)=FND_API.G_MISS_NUM
4682            --RT}
4683         then
4684 
4685           if l_debug_level > 0 then
4686            oe_debug_pub.add('New line created by Promotional Modifier');
4687 
4688             oe_debug_pub.add('Resetting calc. price. flag to P');
4689           end if;
4690             p_x_line_rec.calculate_price_flag := 'P';
4691            if l_debug_level > 0 then
4692             oe_debug_pub.add('Logging a request to PRICE_LINE in batch mode');
4693            end if;
4694             if (p_x_line_rec.booked_flag = 'Y')  --2442012
4695             then
4696               if l_debug_level > 0 then
4697                oe_debug_pub.add('Booked order -- log a request to Price Line');
4698               end if;
4699                l_pricing_event := 'BATCH,BOOK';
4700             Else
4701                l_pricing_event := 'BATCH';
4702             End If;
4703             OE_delayed_requests_Pvt.log_request(
4704 				p_entity_code           =>OE_GLOBALS.G_ENTITY_ALL,
4705                                 p_entity_id             => p_x_line_rec.line_Id,
4706                                 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
4707                                 p_requesting_entity_id   => p_x_line_rec.line_Id,
4708                                 p_request_unique_key1   => l_pricing_event,
4709                                 p_param1                 => p_x_line_rec.header_id,
4710                                 p_param2                 => l_pricing_event,
4711                                 p_request_type           => OE_GLOBALS.G_PRICE_LINE,
4712                                 x_return_status          => l_return_status);
4713 
4714   /*        if (p_x_line_rec.booked_flag = 'Y')
4715           then
4716              oe_debug_pub.add('Booked order -- log a request to Price Line');
4717              OE_delayed_requests_Pvt.log_request(
4718                                 p_entity_code           =>OE_GLOBALS.G_ENTITY_ALL,
4719                                 p_entity_id             => p_x_line_rec.line_Id,
4720                                 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
4721                                 p_requesting_entity_id   => p_x_line_rec.line_Id,
4722                                 p_request_unique_key1   => 'BOOK',
4723                                 p_param1                 => p_x_line_rec.header_id,
4724                                 p_param2                 => 'BOOK',
4725                                 p_request_type           => OE_GLOBALS.G_PRICE_LINE,
4726                                 x_return_status          => l_return_status);
4727           end if; -- if order is BOOKED
4728    */    --2442012
4729         end if; -- if new line created by Promotional modifier needs to be re-priced.
4730 
4731         -- end of fix for bug 1729372
4732 
4733      Oe_Globals.g_price_flag := 'N';
4734 
4735 	If NOT OE_GLOBALS.Equal(p_x_line_rec.Shipped_Quantity,p_old_line_rec.Shipped_Quantity)
4736            --RT{
4737              and nvl(p_x_line_rec.retrobill_request_id,FND_API.G_MISS_NUM)=FND_API.G_MISS_NUM
4738            --RT}
4739 	Then
4740            --btea
4741            IF p_x_line_rec.line_category_code <> 'RETURN' Then
4742               OE_Shipping_Integration_PVT.Check_Shipment_Line(
4743                  p_line_rec                => p_old_line_rec
4744               ,  p_shipped_quantity        => p_x_line_rec.Shipped_Quantity
4745               ,  x_result_out              => l_x_result_out
4746               );
4747 
4748               IF l_x_result_out = OE_GLOBALS.G_PARTIALLY_SHIPPED THEN
4749                -- This line will split, set the calculate_price_flag  to 'P' if 'Y'
4750                 IF (p_x_line_rec.calculate_price_flag = 'Y') THEN
4751                   p_x_line_rec.calculate_price_flag := 'P';
4752                 END IF;
4753 
4754 
4755               END IF;
4756 
4757            Elsif p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4758                  and p_x_line_rec.split_by = 'SYSTEM'
4759                  and NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT'
4760                  and p_x_line_rec.calculate_price_flag = 'Y' Then
4761                    p_x_line_rec.calculate_price_flag :='P';
4762            End If;
4763 
4764            OE_delayed_requests_Pvt.log_request(
4765 				p_entity_code 		=> OE_GLOBALS.G_ENTITY_ALL,
4766 				p_entity_id         	=> p_x_line_rec.line_id,
4767 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
4768 				p_requesting_entity_id   => p_x_line_rec.line_id,
4769 				p_request_unique_key1  	=> 'SHIP',
4770 		 		p_param1                 => p_x_line_rec.header_id,
4771                  		p_param2                 => 'SHIP',
4772 		 		p_request_type           => OE_GLOBALS.G_PRICE_LINE,
4773 		 		x_return_status          => l_return_status);
4774 	End If;
4775 
4776         -- change for bug 1406890
4777         -- Renga making changes for tax calculation event enhancement
4778         IF nvl(p_x_line_rec.booked_flag, 'N') = 'Y' THEN
4779             l_current_event := 1;  /* current event is booking or higher */
4780         END IF;
4781 
4782         IF (p_x_line_rec.shippable_flag = 'Y' and
4783             p_x_line_rec.shipped_quantity is not null ) THEN
4784            l_current_event := 2; /* current event is shipping or higher */
4785         END IF;
4786 
4787         BEGIN
4788 
4789          IF OE_Order_Cache.g_header_rec.order_type_id is not null THEN
4790 
4791               --use cache instead of SQL to fix bug 4200055
4792               if (OE_Order_Cache.g_order_type_rec.order_type_id = FND_API.G_MISS_NUM)
4793 		  OR (OE_Order_Cache.g_order_type_rec.order_type_id is null)
4794                   OR (OE_Order_Cache.g_order_type_rec.order_type_id <>
4795 OE_Order_Cache.g_header_rec.Order_Type_id) THEN
4796        	  		 OE_Order_Cache.Load_Order_type(OE_Order_CACHE.g_header_rec.Order_Type_id)
4797 ;
4798 	       END IF ;
4799 	       IF (OE_Order_Cache.g_order_type_rec.order_type_id =
4800 OE_Order_Cache.g_header_rec.Order_Type_id) THEN
4801 	  	        if (OE_Order_Cache.g_order_type_rec.tax_calculation_event_code =
4802 'ENTERING') then
4803 				l_tax_calculation_event_code := 0;
4804 			elsif (OE_Order_Cache.g_order_type_rec.tax_calculation_event_code =
4805 'BOOKING') then
4806 				l_tax_calculation_event_code := 1;
4807 			elsif (OE_Order_Cache.g_order_type_rec.tax_calculation_event_code =
4808 'SHIPPING') then
4809 				l_tax_calculation_event_code := 2;
4810 			elsif (OE_Order_Cache.g_order_type_rec.tax_calculation_event_code =
4811 'INVOICING') then
4812 				l_tax_calculation_event_code := 3;
4813 			else
4814 				l_tax_calculation_event_code := -1;
4815                         end if ;
4816 	       ELSE
4817 		      l_tax_calculation_event_code := 0 ;
4818 	       END IF ;
4819 
4820            /* SELECT DECODE( TAX_CALCULATION_EVENT_CODE, 'ENTERING',   0,
4821                                                   'BOOKING', 1,
4822                                                   'SHIPPING', 2,
4823                                                   'INVOICING', 3,
4824                                                   -1)
4825             into l_tax_calculation_event_code
4826             from oe_transaction_types_all
4827             where transaction_type_id = OE_Order_Cache.g_header_rec.order_type_id;
4828             */
4829             --end bug 4200055
4830 
4831          END IF;
4832 
4833         EXCEPTION
4834            when no_data_found then
4835                  l_tax_calculation_event_code := 0;
4836            when others then
4837             if l_debug_level > 0 then
4838              oe_debug_pub.add('Ren: failed while trying to query up tax_calcualtion_event for order_type_id ');
4839             end if;
4840              RAISE;
4841 
4842         END;
4843 
4844         -- all non-shippable lines need to get taxed at the time of entry
4845         -- itself - so we set the current event to same as
4846         --  tax_calculation_event
4847 
4848         IF ( l_tax_calculation_event_code = 2 and
4849              p_x_line_rec.shippable_flag = 'N' ) THEN
4850               l_current_event := l_tax_calculation_event_code;
4851         END IF;
4852 
4853         -- if current_event >= tax_calculation_event, then log
4854         -- the delayed request
4855         -- Renga end making changes for tax calculation event enhancement
4856 
4857         -- Modified the If condition as part of the fix for bug#2047434
4858         -- delayed request for taxing should not get logged for a line
4859         -- without an item thus added the condition to test the value of
4860         -- inventory item id .
4861 
4862         IF p_x_line_rec.item_type_code in ('INCLUDED', 'CONFIG') THEN
4863 
4864          if l_debug_level > 0 then
4865           oe_debug_pub.add('Ren: no tax delayed request for include and config',1);
4866          end if;
4867 
4868           oe_globals.g_tax_flag := 'N';
4869 
4870         END IF;
4871     --changes for bug 2505961  begin
4872 
4873     --commented the following for bug7306510 as the sql execution is no more required
4874     /*if p_x_line_rec.commitment_id is not null
4875        and p_x_line_rec.commitment_id <> FND_API.G_MISS_NUM
4876        and oe_globals.g_tax_flag = 'Y'
4877     then
4878      begin
4879       select  nvl(tax_calculation_flag,'N') into l_tax_commt_flag
4880       from ra_cust_trx_types ract where ract.cust_trx_type_id =
4881       (
4882       select nvl(cust_type.subsequent_trx_type_id,cust_type.cust_trx_type_id)
4883       from ra_cust_trx_types_all cust_type,ra_customer_trx_all cust_trx  where
4884       cust_type.cust_trx_type_id = cust_trx.cust_trx_type_id
4885       and cust_trx.customer_trx_id = p_x_line_rec.commitment_id
4886       );
4887      if l_debug_level > 0 then
4888       oe_debug_pub.add('OEXULINB:l_commit tax flag: '||l_tax_commt_flag,1);
4889      end if;
4890 
4891      exception
4892       when others then
4893      if l_debug_level > 0 then
4894       oe_debug_pub.add('OEXULINB: in exception commitment ',1);
4895      end if;
4896       l_tax_commt_flag := 'N';
4897      end;
4898     end if;*/
4899     --changes for bug 2505961  end
4900     --changes made in if condition below for bug 2573940
4901 
4902 
4903 
4904     -- commented portion of the following condition for bug7306510
4905        -- with ebtax upkae in R12 ,meaning of ra_cust_trx_types.tax_calculation_flag has changed
4906        -- now this flag will be checcked by customers only if they want the 11i migrated Tax Classification
4907        -- 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
4908        -- OM will depend on Tax_event alone ( specfied transaction type level) to automatically trigger
4909        -- tax calcualtion .ra_cust_trx_types.tax_calculation_flag is no more considered while logging delayed requests for tax
4910 
4911 
4912 
4913    IF ( oe_globals.g_tax_flag = 'Y'  and
4914           l_current_event >= l_tax_calculation_event_code and
4915        /*bug7306510 ( l_tax_calculation_flag = 'Y' or
4916           p_x_line_rec.tax_exempt_flag = 'R' or l_tax_commt_flag = 'Y'
4917          or (l_tax_calculation_flag = 'N' and
4918           nvl(p_x_line_rec.tax_value,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM
4919             )
4920         ) and */
4921   nvl(p_x_line_rec.inventory_item_id,fnd_api.g_miss_num) <> fnd_api.g_miss_num)
4922   THEN
4923          if l_debug_level > 0 then
4924 	    oe_debug_pub.ADD('Logging delayed request for taxing');
4925          end if;
4926 	    -- lkxu, make changes for bug 1581188
4927             l_tax_commt_flag := 'N'; --bug 2505961
4928 	  IF (OE_GLOBALS.G_UI_FLAG) THEN
4929 	    OE_delayed_requests_Pvt.log_request(
4930 		p_entity_code 		=> OE_GLOBALS.G_ENTITY_LINE,
4931 		p_entity_id   		=> p_x_line_rec.line_id,
4932 		p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4933 		p_requesting_entity_id   => p_x_line_rec.line_id,
4934                 p_request_type      	=> OE_GLOBALS.g_tax_line,
4935                 x_return_status     	=> l_return_status);
4936           ELSE
4937             -- added p_param1 for bug 1786533.
4938 	    OE_delayed_requests_Pvt.log_request(
4939 		p_entity_code		=> OE_GLOBALS.G_ENTITY_ALL,
4940 		p_entity_id   		=> p_x_line_rec.line_id,
4941 		p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4942 		p_requesting_entity_id   => p_x_line_rec.line_id,
4943                 p_request_type      	=> OE_GLOBALS.g_tax_line,
4944                 p_param1             	=> l_param1,
4945                 x_return_status     	=> l_return_status);
4946 	  END IF;
4947           oe_globals.g_tax_flag := 'N';
4948 	END IF;
4949 
4950 	/** commented out for bug 1581188
4951 	IF (oe_globals.g_tax_flag = 'Y') THEN
4952          if l_debug_level > 0 then
4953 	   oe_debug_pub.ADD('Logging delayed request for taxing');
4954          end if;
4955 	   OE_delayed_requests_Pvt.log_request(p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4956 				p_entity_id         => p_x_line_rec.line_id,
4957 				p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4958 				p_requesting_entity_id         => p_x_line_rec.line_id,
4959                                 p_request_type      => OE_GLOBALS.g_tax_line,
4960                                 x_return_status     => l_return_status);
4961           oe_globals.g_tax_flag := 'N';
4962 	END IF;
4963 	**/
4964 
4965     -- Log a verify payment request if the order is booked and a new line.
4966     -- Fix 1939779: Added condition to not log verify payment request for
4967     -- new config item lines being added to an order.
4968     IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
4969        p_x_line_rec.item_type_code <> OE_GLOBALS.G_ITEM_CONFIG AND
4970 	  p_x_line_rec.booked_flag = 'Y' THEN
4971       IF (NVL(OE_Order_Cache.g_header_rec.payment_type_code, 'NULL') <> 'CREDIT_CARD'
4972           AND OE_PrePayment_UTIL.is_prepaid_order(p_x_line_rec.header_id) = 'N')
4973          OR OE_PrePayment_UTIL.is_prepaid_order(p_x_line_rec.header_id) = 'Y'
4974           THEN
4975          if l_debug_level > 0 then
4976 	  oe_debug_pub.ADD('New line added to a booked order,'
4977 		 || 'Logging delayed request for Verify Payment', 1);
4978          end if;
4979        l_verify_payment_flag := 'Y';
4980       END IF;
4981     END IF;
4982 
4983     -- Suppress verify payment and credit checking if the line is split
4984     IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
4985 	   NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT' ) OR
4986        (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
4987 	    p_x_line_rec.split_from_line_id IS NOT NULL) THEN
4988          if l_debug_level > 0 then
4989 	  oe_debug_pub.ADD('Line is being Split, Suppress Verify Payment', 1);
4990          end if;
4991         l_verify_payment_flag := 'N';
4992     END IF;
4993 
4994      -- If verify payment flag set to 'Y' then log a request for verify payment
4995      IF (l_verify_payment_flag = 'Y') THEN
4996 	  -- Log request only if the Line is NOT a RETURN.
4997 	  IF	p_x_line_rec.line_category_code <> 'RETURN' THEN
4998 	  --
4999       if l_debug_level > 0 then
5000        oe_debug_pub.ADD('Logging delayed request for Verify Payment');
5001       end if;
5002 	  --
5003        OE_delayed_requests_Pvt.log_request
5004                   (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
5005                    p_entity_id              => p_x_line_rec.header_id,
5006                    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5007                    p_requesting_entity_id   => p_x_line_rec.line_id,
5008                    p_request_type           => OE_GLOBALS.G_VERIFY_PAYMENT,
5009                    x_return_status          => l_return_status);
5010           END IF;
5011      END IF;
5012 
5013      --bug 1829201, commitment related changes
5014      -- QUOTING change
5015      IF (l_calculate_commitment_flag = 'Y' OR l_get_commitment_bal = 'Y')
5016         AND nvl(p_x_line_rec.transaction_phase_code,'F') = 'F'
5017      THEN
5018 
5019          -- don't get the balance again, as this is the second call due to the change
5020          -- of unit_selling_price, and the returned value at this moment would be the
5021          -- balance after the current line is saved to database.
5022 
5023         IF NVL(OE_GLOBALS.g_pricing_recursion, 'N') <> 'Y'
5024            OR (NVL(OE_GLOBALS.g_pricing_recursion, 'N') = 'Y' AND
5025                oe_globals.g_commitment_balance IS NULL) THEN
5026   	   l_class := NULL;
5027            l_so_source_code := FND_PROFILE.VALUE('ONT_SOURCE_CODE');
5028            l_oe_installed_flag := 'I';
5029 
5030            -- get the available commitmenb balance before saving the line.
5031            IF NOT (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
5032 	         p_x_line_rec.split_from_line_id IS NOT NULL) THEN
5033               oe_globals.g_commitment_balance := ARP_BAL_UTIL.GET_COMMITMENT_BALANCE(
5034                         p_x_line_rec.commitment_id
5035                 	,l_class
5036                 	,l_so_source_code
5037                	 	,l_oe_installed_flag );
5038            END IF;
5039 
5040             -- if updating, then the applied commitment should become available
5041             IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
5042               l_commitment_applied_amount
5043                  := OE_Commitment_PVT.get_commitment_applied_amount
5044                      (p_header_id          => p_x_line_rec.header_id ,
5045                       p_line_id            => p_x_line_rec.line_id ,
5046                       p_commitment_id      => p_x_line_rec.commitment_id);
5047               /* Fix Bug # 2511389: This is now done in OE_Commitment_PVT.Calculate_Commitments
5048               oe_globals.g_commitment_balance
5049                  := oe_globals.g_commitment_balance + l_commitment_applied_amount;
5050               */
5051 
5052 
5053             END IF;
5054          END IF;
5055 
5056         IF l_calculate_commitment_flag = 'Y'
5057            AND OE_Commitment_Pvt.Do_Commitment_Sequencing
5058            AND l_update_commitment_applied <> 'Y' THEN
5059 
5060          if l_debug_level > 0 then
5061            oe_debug_pub.add('Logging delayed request for Commitment.', 2);
5062          end if;
5063 	   OE_Delayed_Requests_Pvt.Log_Request(
5064 	   p_entity_code		=>	OE_GLOBALS.G_ENTITY_LINE,
5065 	   p_entity_id			=>	p_x_line_rec.line_id,
5066 	   p_requesting_entity_code	=>	OE_GLOBALS.G_ENTITY_LINE,
5067 	   p_requesting_entity_id	=>	p_x_line_rec.line_id,
5068 	   p_request_type		=>	OE_GLOBALS.G_CALCULATE_COMMITMENT,
5069 	   x_return_status		=>	l_return_status);
5070 
5071         END IF;
5072 
5073     END IF;
5074 
5075     IF p_x_line_rec.commitment_id IS NOT NULL
5076        AND l_update_commitment_flag = 'Y'
5077        AND OE_Commitment_Pvt.Do_Commitment_Sequencing
5078        -- QUOTING change
5079        AND nvl(p_x_line_rec.transaction_phase_code,'F') = 'F'
5080     THEN
5081 
5082        -- lkxu, bug 1786533.
5083        IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
5084            NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT' ) THEN
5085 
5086          if l_debug_level > 0 then
5087            oe_debug_pub.add('Logging delayed request for updating commitment for line '||p_x_line_rec.line_id, 2);
5088          end if;
5089 
5090             -- should log as ENTITY_ALL, as SPLIT is a batch mode
5091 	   OE_Delayed_Requests_Pvt.Log_Request(
5092 		p_entity_code			=>OE_GLOBALS.G_ENTITY_ALL,
5093 		p_entity_id			=>p_x_line_rec.line_id,
5094 		p_requesting_entity_code	=>OE_GLOBALS.G_ENTITY_LINE,
5095 		p_requesting_entity_id 		=>p_x_line_rec.line_id,
5096 		p_request_type			=>OE_GLOBALS.G_UPDATE_COMMITMENT,
5097 		x_return_status			=>l_return_status);
5098          END IF;
5099     END IF;
5100 
5101     IF l_update_commitment_applied = 'Y'
5102        AND nvl(p_x_line_rec.transaction_phase_code,'F') = 'F' THEN
5103 
5104          if l_debug_level > 0 then
5105            oe_debug_pub.add('Logging delayed request for Commitment Applied Amount '|| p_x_line_rec.commitment_applied_amount, 3);
5106            oe_debug_pub.add('param2 is: '|| p_x_line_rec.header_id, 3);
5107            oe_debug_pub.add('param3 is: '|| p_x_line_rec.commitment_id, 3);
5108          end if;
5109 	   OE_Delayed_Requests_Pvt.Log_Request(
5110 	   p_entity_code		=>	OE_GLOBALS.G_ENTITY_LINE,
5111 	   p_entity_id			=>	p_x_line_rec.line_id,
5112 	   p_requesting_entity_code	=>	OE_GLOBALS.G_ENTITY_LINE,
5113 	   p_requesting_entity_id	=>	p_x_line_rec.line_id,
5114 	   p_request_type		=>	OE_GLOBALS.G_UPDATE_COMMITMENT_APPLIED,
5115            p_param1             	=>      p_x_line_rec.commitment_applied_amount,
5116            p_param2             	=>      p_x_line_rec.header_id,
5117            p_param3             	=>      p_x_line_rec.commitment_id,
5118 	   x_return_status		=>	l_return_status);
5119 
5120     END IF;
5121 
5122     -- bug 2668298, Freight Rating.
5123     IF l_get_FTE_freight_rate = 'Y' THEN
5124 
5125       if l_debug_level > 0 then
5126        oe_debug_pub.add('Logging delayed request for freight rate: '||p_x_line_rec.header_id, 2);
5127       end if;
5128 
5129        OE_delayed_requests_Pvt.log_request
5130                   (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
5131                    p_entity_id              => p_x_line_rec.header_id,
5132                    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
5133                    p_requesting_entity_id   => p_x_line_rec.line_id,
5134                    p_request_type           => OE_GLOBALS.G_FREIGHT_RATING,
5135                    x_return_status          => l_return_status);
5136 
5137         IF p_x_line_rec.booked_flag='Y' THEN
5138            l_pricing_event := 'BATCH,BOOK';
5139         ELSE
5140            l_pricing_event := 'BATCH';
5141         END IF;
5142 
5143         -- also log pricing request to calculate fregight rates.
5144         OE_delayed_requests_Pvt.log_request(
5145                    p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
5146                    p_entity_id              => p_x_line_rec.header_id,
5147                    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
5148                    p_requesting_entity_id   => p_x_line_rec.header_id,
5149                    p_request_unique_key1    => l_pricing_event,
5150                    p_request_unique_key2    => 'Y',  -- get freight flag
5151                    p_param1                 => p_x_line_rec.header_id,
5152                    p_param2                 => l_pricing_event,
5153                    p_request_type           => OE_GLOBALS.G_PRICE_ORDER,
5154                    x_return_status          => l_return_status);
5155     END IF;
5156     -- end of bug 2668298.
5157 
5158 
5159     -- Populate re_source_flag when project is not null, so that planning will
5160     -- not change Warehouse on the line.
5161     IF p_x_line_rec.project_id IS NOT NULL AND
5162 	p_x_line_rec.project_id <> FND_API.G_MISS_NUM THEN
5163 
5164 	p_x_line_rec.re_source_flag := 'N';
5165 
5166     END IF;
5167 
5168 
5169     /*
5170     ** Fix # 3147694 Start
5171     ** Following will be true only if the user is cancelling the
5172     ** order right after quantity on the lines was updated to 0.
5173     */
5174 
5175     IF p_x_line_rec.ordered_quantity = 0 AND
5176        p_old_line_rec.ordered_quantity = 0 AND
5177         OE_GLOBALS.g_recursion_mode = 'N' AND       -- Bug 3379121
5178        OE_OE_FORM_CANCEL_LINE.g_ord_lvl_can THEN
5179 
5180       IF l_debug_level > 0 THEN
5181         oe_debug_pub.add('Line Ord Qty already 0, Calling Check_Constraints based on Order Cancel Global');
5182       END IF;
5183 
5184       OE_SALES_CAN_UTIL.Check_Constraints
5185             (p_x_line_rec          => p_x_line_rec,
5186              p_old_line_rec  => p_old_line_rec,
5187              x_return_status => l_return_status
5188             );
5189       IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5190         p_x_line_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5191       ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5192         p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
5193       END IF;
5194 
5195     END IF;
5196     /* Fix # 3147694 End   */
5197 
5198 
5199   IF OE_CODE_CONTROL.GET_CODE_RELEASE_LEVEL >='110510' THEN
5200   IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE OR
5201     (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
5202      ( ( NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_from_org_id
5203                                                       ,p_old_line_rec.ship_from_org_id)
5204        AND p_old_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM) OR
5205      ( NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_to_org_id
5206                                                       ,p_old_line_rec.ship_to_org_id)
5207        AND p_old_line_rec.ship_to_org_id <> FND_API.G_MISS_NUM) OR
5208      ( NOT OE_GLOBALS.EQUAL(p_x_line_rec.inventory_item_id
5209                                                       ,p_old_line_rec.inventory_item_id)
5210        AND p_old_line_rec.inventory_item_id <> FND_API.G_MISS_NUM) OR
5211      ( NOT OE_GLOBALS.EQUAL(p_x_line_rec.order_quantity_uom
5212                                                       ,p_old_line_rec.order_quantity_uom)
5213        AND p_old_line_rec.order_quantity_uom <> FND_API.G_MISS_CHAR) OR
5214      ( NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity
5215                                                       ,p_old_line_rec.ordered_quantity)
5216        AND p_old_line_rec.ordered_quantity <> FND_API.G_MISS_NUM) OR
5217      ( NOT OE_GLOBALS.EQUAL(p_x_line_rec.schedule_ship_date
5218                                                       ,p_old_line_rec.schedule_ship_date)
5219        AND p_old_line_rec.schedule_ship_date <> FND_API.G_MISS_DATE) OR
5220      ( NOT OE_GLOBALS.EQUAL(p_x_line_rec.schedule_arrival_date
5221                                                       ,p_old_line_rec.schedule_arrival_date)
5222        AND p_old_line_rec.schedule_arrival_date <> FND_API.G_MISS_DATE) OR
5223      ( NOT OE_GLOBALS.EQUAL(p_x_line_rec.freight_terms_code
5224                                                       ,p_old_line_rec.freight_terms_code)
5225        AND p_old_line_rec.freight_terms_code <> FND_API.G_MISS_CHAR)))
5226        THEN
5227           IF OE_GLOBALS.G_FTE_REINVOKE IS NULL THEN
5228             Select Count(*) into l_fte_count
5229              from oe_price_adjustments where
5230              header_id = p_x_line_rec.header_id
5231              and LIST_LINE_TYPE_CODE = 'OM_CALLED_CHOOSE_SHIP_METHOD';
5232             if l_debug_level > 0 then
5233              oe_debug_pub.add( 'Value of fte count '||l_fte_count);
5234             end if;
5235             If l_fte_count > 0  Then
5236                   --fnd_message.set_name('ONT','MY_MESSAGE');
5237                   --OE_MSG_PUB.Add;
5238                     --NULL;
5239                      OE_GLOBALS.G_FTE_REINVOKE := 'Y';
5240             ELSE
5241 	             OE_GLOBALS.G_FTE_REINVOKE := 'N';
5242             End If;
5243 	  END IF;
5244   END IF;
5245   END IF;
5246 
5247     -- Moved to OE_ACKNOWLEDGMENT_PUB as part of 3417899 and 3412458
5248     /* IF l_3a7_attribute_change = FND_API.G_TRUE
5249        AND OE_Code_Control.code_release_level >= '110510'
5250        AND NVL(FND_PROFILE.VALUE('ONT_3A7_RESPONSE_REQUIRED'), 'N') = 'Y'
5251        AND p_x_line_rec.order_source_id= OE_Acknowledgment_Pub.G_XML_ORDER_SOURCE_ID
5252        AND nvl(p_x_line_rec.xml_transaction_type_code, OE_Acknowledgment_Pub.G_TRANSACTION_CSO) = OE_Acknowledgment_Pub.G_TRANSACTION_CSO
5253        AND p_x_line_rec.booked_flag = 'Y'
5254        AND p_x_line_rec.ordered_quantity <> 0 -- for bug 3421996
5255     THEN
5256            IF l_debug_level  > 0 THEN
5257               oe_debug_pub.add(  'Calling OE_Acknowlegment_PUB.Apply_3A7_Hold', 2 ) ;
5258            END IF;
5259            OE_Acknowledgment_PUB.Apply_3A7_Hold
5260                              ( p_header_id       =>  p_x_line_rec.header_id
5261                              , p_line_id         =>   p_x_line_rec.line_id
5262                              , p_sold_to_org_id  =>   p_x_line_rec.sold_to_org_id
5263                              , x_return_status   =>   l_return_status);
5264            IF l_debug_level  > 0 THEN
5265               oe_debug_pub.add(  'Return status after call to apply_3a7_hold:' || l_return_status, 2 ) ;
5266            END IF;
5267     END IF; */
5268 
5269    /*Bug2848734 */
5270    IF NOT OE_GLOBALS.Equal(p_x_line_rec.return_context, p_old_line_rec.return_context) THEN
5271     IF (p_x_line_rec.line_category_code = 'RETURN' and
5272        p_x_line_rec.OPERATION = OE_GLOBALS.G_OPR_UPDATE and
5273        p_x_line_rec.return_context IS NULL ) THEN
5274 
5275        p_x_line_rec.reference_customer_trx_line_id := NULL;
5276        p_x_line_rec.credit_invoice_line_id := NULL;
5277        p_x_line_rec.reference_line_id := NULL;
5278        p_x_line_rec.reference_header_id := NULL;
5279     END IF;
5280   END IF;
5281   /*Bug2848734*/
5282 
5283   if l_debug_level > 0 then
5284     oe_debug_pub.add('return status before exiting '|| p_x_line_rec.return_status, 1);
5285     oe_debug_pub.add('Exiting OE_LINE_UTIL.APPLY_ATTRIBUTE_CHANGES', 1);
5286   end if;
5287 
5288 END Apply_Attribute_Changes;
5289 
5290 
5291 
5292 /*----------------------------------------------------------
5293 PROCEDURE Complete_Record
5294 -----------------------------------------------------------*/
5295 
5296 PROCEDURE Complete_Record
5297 (   p_x_line_rec                    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
5298 ,   p_old_line_rec                  IN  OE_Order_PUB.Line_Rec_Type
5299 )
5300 IS
5301 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5302 BEGIN
5303 
5304   IF l_debug_level  > 0 THEN
5305     oe_debug_pub.add('Entering OE_LINE_UTIL.COMPLETE_RECORD', 1);
5306   END IF;
5307 
5308     IF p_x_line_rec.accounting_rule_id = FND_API.G_MISS_NUM THEN
5309         p_x_line_rec.accounting_rule_id := p_old_line_rec.accounting_rule_id;
5310     END IF;
5311 
5312     IF p_x_line_rec.accounting_rule_duration = FND_API.G_MISS_NUM THEN
5313         p_x_line_rec.accounting_rule_duration := p_old_line_rec.accounting_rule_duration;
5314     END IF;
5315 
5316     IF p_x_line_rec.actual_arrival_date = FND_API.G_MISS_DATE THEN
5317         p_x_line_rec.actual_arrival_date := p_old_line_rec.actual_arrival_date;
5318     END IF;
5319 
5320     IF p_x_line_rec.actual_shipment_date = FND_API.G_MISS_DATE THEN
5321         p_x_line_rec.actual_shipment_date := p_old_line_rec.actual_shipment_date;
5322     END IF;
5323 
5324     IF p_x_line_rec.agreement_id = FND_API.G_MISS_NUM THEN
5325         p_x_line_rec.agreement_id := p_old_line_rec.agreement_id;
5326     END IF;
5327 
5328     IF p_x_line_rec.arrival_set_id = FND_API.G_MISS_NUM THEN
5329         p_x_line_rec.arrival_Set_id := p_old_line_rec.arrival_set_id;
5330     END IF;
5331 
5332     IF p_x_line_rec.ato_line_id = FND_API.G_MISS_NUM THEN
5333         p_x_line_rec.ato_line_id := p_old_line_rec.ato_line_id;
5334     END IF;
5335     IF p_x_line_rec.upgraded_flag = FND_API.G_MISS_CHAR THEN
5336         p_x_line_rec.upgraded_flag := p_old_line_rec.upgraded_flag;
5337     END IF;
5338 
5339     IF p_x_line_rec.attribute1 = FND_API.G_MISS_CHAR THEN
5340         p_x_line_rec.attribute1 := p_old_line_rec.attribute1;
5341     END IF;
5342 
5343     IF p_x_line_rec.attribute10 = FND_API.G_MISS_CHAR THEN
5344         p_x_line_rec.attribute10 := p_old_line_rec.attribute10;
5345     END IF;
5346 
5347     IF p_x_line_rec.attribute11 = FND_API.G_MISS_CHAR THEN
5348         p_x_line_rec.attribute11 := p_old_line_rec.attribute11;
5349     END IF;
5350 
5351     IF p_x_line_rec.attribute12 = FND_API.G_MISS_CHAR THEN
5352         p_x_line_rec.attribute12 := p_old_line_rec.attribute12;
5353     END IF;
5354 
5355     IF p_x_line_rec.attribute13 = FND_API.G_MISS_CHAR THEN
5356         p_x_line_rec.attribute13 := p_old_line_rec.attribute13;
5357     END IF;
5358 
5359     IF p_x_line_rec.attribute14 = FND_API.G_MISS_CHAR THEN
5360         p_x_line_rec.attribute14 := p_old_line_rec.attribute14;
5361     END IF;
5362 
5363     IF p_x_line_rec.attribute15 = FND_API.G_MISS_CHAR THEN
5364         p_x_line_rec.attribute15 := p_old_line_rec.attribute15;
5365     END IF;
5366 
5367     IF p_x_line_rec.attribute16 = FND_API.G_MISS_CHAR THEN  --Bug 2184255
5368         p_x_line_rec.attribute16 := p_old_line_rec.attribute16;
5369     END IF;
5370 
5371     IF p_x_line_rec.attribute17 = FND_API.G_MISS_CHAR THEN
5372         p_x_line_rec.attribute17 := p_old_line_rec.attribute17;
5373     END IF;
5374 
5375     IF p_x_line_rec.attribute18 = FND_API.G_MISS_CHAR THEN
5376         p_x_line_rec.attribute18 := p_old_line_rec.attribute18;
5377     END IF;
5378 
5379     IF p_x_line_rec.attribute19 = FND_API.G_MISS_CHAR THEN
5380         p_x_line_rec.attribute19 := p_old_line_rec.attribute19;
5381     END IF;
5382 
5383     IF p_x_line_rec.attribute2 = FND_API.G_MISS_CHAR THEN
5384         p_x_line_rec.attribute2 := p_old_line_rec.attribute2;
5385     END IF;
5386 
5387     IF p_x_line_rec.attribute20 = FND_API.G_MISS_CHAR THEN  -- 2184255
5388         p_x_line_rec.attribute20 := p_old_line_rec.attribute20;
5389     END IF;
5390 
5391     IF p_x_line_rec.calculate_price_flag = FND_API.G_MISS_CHAR THEN
5392         p_x_line_rec.calculate_price_flag := p_old_line_rec.calculate_price_flag;
5393     END IF;
5394 
5395     IF p_x_line_rec.attribute3 = FND_API.G_MISS_CHAR THEN
5396         p_x_line_rec.attribute3 := p_old_line_rec.attribute3;
5397     END IF;
5398 
5399     IF p_x_line_rec.attribute4 = FND_API.G_MISS_CHAR THEN
5400         p_x_line_rec.attribute4 := p_old_line_rec.attribute4;
5401     END IF;
5402 
5403     IF p_x_line_rec.attribute5 = FND_API.G_MISS_CHAR THEN
5404         p_x_line_rec.attribute5 := p_old_line_rec.attribute5;
5405     END IF;
5406 
5407     IF p_x_line_rec.attribute6 = FND_API.G_MISS_CHAR THEN
5408         p_x_line_rec.attribute6 := p_old_line_rec.attribute6;
5409     END IF;
5410 
5411     IF p_x_line_rec.attribute7 = FND_API.G_MISS_CHAR THEN
5412         p_x_line_rec.attribute7 := p_old_line_rec.attribute7;
5413     END IF;
5414 
5415     IF p_x_line_rec.attribute8 = FND_API.G_MISS_CHAR THEN
5416         p_x_line_rec.attribute8 := p_old_line_rec.attribute8;
5417     END IF;
5418 
5419     IF p_x_line_rec.attribute9 = FND_API.G_MISS_CHAR THEN
5420         p_x_line_rec.attribute9 := p_old_line_rec.attribute9;
5421     END IF;
5422 
5423     IF p_x_line_rec.auto_selected_quantity = FND_API.G_MISS_NUM THEN
5424         p_x_line_rec.auto_selected_quantity := p_old_line_rec.auto_selected_quantity;
5425     END IF;
5426     IF p_x_line_rec.authorized_to_ship_flag = FND_API.G_MISS_CHAR THEN
5427         p_x_line_rec.authorized_to_ship_flag := p_old_line_rec.authorized_to_ship_flag;
5428     END IF;
5429 
5430     IF p_x_line_rec.booked_flag = FND_API.G_MISS_CHAR THEN
5431         p_x_line_rec.booked_flag := p_old_line_rec.booked_flag;
5432     END IF;
5433 
5434     IF p_x_line_rec.cancelled_flag = FND_API.G_MISS_CHAR THEN
5435         p_x_line_rec.cancelled_flag := p_old_line_rec.cancelled_flag;
5436     END IF;
5437 
5438     IF p_x_line_rec.cancelled_quantity = FND_API.G_MISS_NUM THEN
5439         p_x_line_rec.cancelled_quantity := p_old_line_rec.cancelled_quantity;
5440     END IF;
5441 
5442     IF p_x_line_rec.component_code = FND_API.G_MISS_CHAR THEN
5443         p_x_line_rec.component_code := p_old_line_rec.component_code;
5444     END IF;
5445 
5446     IF p_x_line_rec.component_number = FND_API.G_MISS_NUM THEN
5447         p_x_line_rec.component_number := p_old_line_rec.component_number;
5448     END IF;
5449 
5450     IF p_x_line_rec.component_sequence_id = FND_API.G_MISS_NUM THEN
5451         p_x_line_rec.component_sequence_id := p_old_line_rec.component_sequence_id;
5452     END IF;
5453 
5454     IF p_x_line_rec.config_header_id = FND_API.G_MISS_NUM THEN
5455         p_x_line_rec.config_header_id := p_old_line_rec.config_header_id;
5456     END IF;
5457 
5458     IF p_x_line_rec.config_rev_nbr = FND_API.G_MISS_NUM THEN
5459         p_x_line_rec.config_rev_nbr := p_old_line_rec.config_rev_nbr;
5460     END IF;
5461 
5462     IF p_x_line_rec.config_display_sequence = FND_API.G_MISS_NUM THEN
5463         p_x_line_rec.config_display_sequence := p_old_line_rec.config_display_sequence;
5464     END IF;
5465 
5466     IF p_x_line_rec.configuration_id = FND_API.G_MISS_NUM THEN
5467         p_x_line_rec.configuration_id := p_old_line_rec.configuration_id;
5468     END IF;
5469 
5470     IF p_x_line_rec.context = FND_API.G_MISS_CHAR THEN
5471         p_x_line_rec.context := p_old_line_rec.context;
5472     END IF;
5473 
5474     --recurring charges
5475     IF p_x_line_rec.charge_periodicity_code = FND_API.G_MISS_CHAR THEN
5476        p_x_line_rec.charge_periodicity_code :=
5477                          p_old_line_rec.charge_periodicity_code;
5478     END IF;
5479 
5480     --Customer Acceptance
5481      IF p_x_line_rec.CONTINGENCY_ID  = FND_API.G_MISS_NUM THEN
5482         p_x_line_rec.CONTINGENCY_ID  := p_old_line_rec.CONTINGENCY_ID  ;
5483     END IF;
5484      IF p_x_line_rec.REVREC_EVENT_CODE = FND_API.G_MISS_CHAR THEN
5485         p_x_line_rec.REVREC_EVENT_CODE:= p_old_line_rec.REVREC_EVENT_CODE  ;
5486     END IF;
5487      IF p_x_line_rec.REVREC_EXPIRATION_DAYS = FND_API.G_MISS_NUM THEN
5488         p_x_line_rec.REVREC_EXPIRATION_DAYS:= p_old_line_rec.REVREC_EXPIRATION_DAYS;
5489     END IF;
5490      IF p_x_line_rec.ACCEPTED_QUANTITY = FND_API.G_MISS_NUM THEN
5491         p_x_line_rec.ACCEPTED_QUANTITY:= p_old_line_rec.ACCEPTED_QUANTITY;
5492     END IF;
5493      IF p_x_line_rec.REVREC_COMMENTS = FND_API.G_MISS_CHAR THEN
5494         p_x_line_rec.REVREC_COMMENTS:= p_old_line_rec.REVREC_COMMENTS;
5495     END IF;
5496      IF p_x_line_rec.REVREC_SIGNATURE = FND_API.G_MISS_CHAR THEN
5497         p_x_line_rec.REVREC_SIGNATURE:= p_old_line_rec.REVREC_SIGNATURE;
5498     END IF;
5499      IF p_x_line_rec.REVREC_SIGNATURE_DATE = FND_API.G_MISS_DATE THEN
5500         p_x_line_rec.REVREC_SIGNATURE_DATE:= p_old_line_rec.REVREC_SIGNATURE_DATE;
5501     END IF;
5502      IF p_x_line_rec.ACCEPTED_BY = FND_API.G_MISS_NUM THEN
5503         p_x_line_rec.ACCEPTED_BY:= p_old_line_rec.ACCEPTED_BY;
5504     END IF;
5505      IF p_x_line_rec.REVREC_REFERENCE_DOCUMENT = FND_API.G_MISS_CHAR THEN
5506         p_x_line_rec.REVREC_REFERENCE_DOCUMENT:= p_old_line_rec.REVREC_REFERENCE_DOCUMENT;
5507     END IF;
5508      IF p_x_line_rec.REVREC_IMPLICIT_FLAG = FND_API.G_MISS_CHAR THEN
5509         p_x_line_rec.REVREC_IMPLICIT_FLAG:= p_old_line_rec.REVREC_IMPLICIT_FLAG;
5510     END IF;
5511     --Customer Acceptance end
5512 
5513     IF p_x_line_rec.created_by = FND_API.G_MISS_NUM THEN
5514         p_x_line_rec.created_by := p_old_line_rec.created_by;
5515     END IF;
5516 
5517     IF p_x_line_rec.creation_date = FND_API.G_MISS_DATE THEN
5518         p_x_line_rec.creation_date := p_old_line_rec.creation_date;
5519     END IF;
5520 
5521      IF p_x_line_rec.credit_invoice_line_id = FND_API.G_MISS_NUM THEN
5522         p_x_line_rec.credit_invoice_line_id := p_old_line_rec.credit_invoice_line_id;
5523      END IF;
5524 
5525     IF p_x_line_rec.customer_dock_code = FND_API.G_MISS_CHAR THEN
5526         p_x_line_rec.customer_dock_code := p_old_line_rec.customer_dock_code;
5527     END IF;
5528 
5529     IF p_x_line_rec.customer_job = FND_API.G_MISS_CHAR THEN
5530         p_x_line_rec.customer_job := p_old_line_rec.customer_job;
5531     END IF;
5532 
5533     IF p_x_line_rec.customer_production_line = FND_API.G_MISS_CHAR THEN
5534         p_x_line_rec.customer_production_line := p_old_line_rec.customer_production_line;
5535     END IF;
5536      IF p_x_line_rec.cust_production_seq_num = FND_API.G_MISS_CHAR THEN
5537         p_x_line_rec.cust_production_seq_num := p_old_line_rec.cust_production_seq_num;
5538     END IF;
5539     IF p_x_line_rec.customer_trx_line_id = FND_API.G_MISS_NUM THEN
5540         p_x_line_rec.customer_trx_line_id := p_old_line_rec.customer_trx_line_id;
5541     END IF;
5542 
5543     IF p_x_line_rec.cust_model_serial_number = FND_API.G_MISS_CHAR THEN
5544         p_x_line_rec.cust_model_serial_number := p_old_line_rec.cust_model_serial_number;
5545     END IF;
5546 
5547     IF p_x_line_rec.cust_po_number = FND_API.G_MISS_CHAR THEN
5548         p_x_line_rec.cust_po_number := p_old_line_rec.cust_po_number;
5549     END IF;
5550 
5551     IF p_x_line_rec.customer_line_number = FND_API.G_MISS_CHAR THEN
5552         p_x_line_rec.customer_line_number := p_old_line_rec.customer_line_number;
5553     END IF;
5554 
5555     IF p_x_line_rec.customer_shipment_number = FND_API.G_MISS_CHAR THEN
5556         p_x_line_rec.customer_shipment_number := p_old_line_rec.customer_shipment_number;
5557     END IF;
5558 
5559     IF p_x_line_rec.delivery_lead_time = FND_API.G_MISS_NUM THEN
5560         p_x_line_rec.delivery_lead_time := p_old_line_rec.delivery_lead_time;
5561     END IF;
5562     IF p_x_line_rec.deliver_to_contact_id = FND_API.G_MISS_NUM THEN
5563         p_x_line_rec.deliver_to_contact_id := p_old_line_rec.deliver_to_contact_id;
5564     END IF;
5565 
5566     IF p_x_line_rec.deliver_to_org_id = FND_API.G_MISS_NUM THEN
5567         p_x_line_rec.deliver_to_org_id := p_old_line_rec.deliver_to_org_id;
5568     END IF;
5569 
5570     IF p_x_line_rec.demand_bucket_type_code = FND_API.G_MISS_CHAR THEN
5571         p_x_line_rec.demand_bucket_type_code := p_old_line_rec.demand_bucket_type_code;
5572     END IF;
5573 
5574     IF p_x_line_rec.demand_class_code = FND_API.G_MISS_CHAR THEN
5575         p_x_line_rec.demand_class_code := p_old_line_rec.demand_class_code;
5576     END IF;
5577 
5578     IF p_x_line_rec.dep_plan_required_flag = FND_API.G_MISS_CHAR THEN
5579         p_x_line_rec.dep_plan_required_flag := p_old_line_rec.dep_plan_required_flag;
5580     END IF;
5581 
5582 
5583 
5584     IF p_x_line_rec.earliest_acceptable_date = FND_API.G_MISS_DATE THEN
5585         p_x_line_rec.earliest_acceptable_date := p_old_line_rec.earliest_acceptable_date;
5586     END IF;
5587 
5588     IF p_x_line_rec.explosion_date = FND_API.G_MISS_DATE THEN
5589         p_x_line_rec.explosion_date := p_old_line_rec.explosion_date;
5590     END IF;
5591 
5592     IF p_x_line_rec.fob_point_code = FND_API.G_MISS_CHAR THEN
5593         p_x_line_rec.fob_point_code := p_old_line_rec.fob_point_code;
5594     END IF;
5595 
5596     IF p_x_line_rec.freight_carrier_code = FND_API.G_MISS_CHAR THEN
5597         p_x_line_rec.freight_carrier_code := p_old_line_rec.freight_carrier_code;
5598     END IF;
5599 
5600     IF p_x_line_rec.freight_terms_code = FND_API.G_MISS_CHAR THEN
5601         p_x_line_rec.freight_terms_code := p_old_line_rec.freight_terms_code;
5602     END IF;
5603 
5604     IF p_x_line_rec.fulfilled_quantity = FND_API.G_MISS_NUM THEN
5605         p_x_line_rec.fulfilled_quantity := p_old_line_rec.fulfilled_quantity;
5606     END IF;
5607 
5608     IF p_x_line_rec.fulfilled_flag = FND_API.G_MISS_CHAR THEN
5609         p_x_line_rec.fulfilled_flag := p_old_line_rec.fulfilled_flag;
5610     END IF;
5611 
5612     IF p_x_line_rec.fulfillment_method_code = FND_API.G_MISS_CHAR THEN
5613         p_x_line_rec.fulfillment_method_code := p_old_line_rec.fulfillment_method_code;
5614     END IF;
5615 
5616     IF p_x_line_rec.fulfillment_date = FND_API.G_MISS_DATE THEN
5617         p_x_line_rec.fulfillment_date := p_old_line_rec.fulfillment_date;
5618     END IF;
5619 
5620     IF p_x_line_rec.global_attribute1 = FND_API.G_MISS_CHAR THEN
5621         p_x_line_rec.global_attribute1 := p_old_line_rec.global_attribute1;
5622     END IF;
5623 
5624     IF p_x_line_rec.global_attribute10 = FND_API.G_MISS_CHAR THEN
5625         p_x_line_rec.global_attribute10 := p_old_line_rec.global_attribute10;
5626     END IF;
5627 
5628     IF p_x_line_rec.global_attribute11 = FND_API.G_MISS_CHAR THEN
5629         p_x_line_rec.global_attribute11 := p_old_line_rec.global_attribute11;
5630     END IF;
5631 
5632     IF p_x_line_rec.global_attribute12 = FND_API.G_MISS_CHAR THEN
5633         p_x_line_rec.global_attribute12 := p_old_line_rec.global_attribute12;
5634     END IF;
5635 
5636     IF p_x_line_rec.global_attribute13 = FND_API.G_MISS_CHAR THEN
5637         p_x_line_rec.global_attribute13 := p_old_line_rec.global_attribute13;
5638     END IF;
5639 
5640     IF p_x_line_rec.global_attribute14 = FND_API.G_MISS_CHAR THEN
5641         p_x_line_rec.global_attribute14 := p_old_line_rec.global_attribute14;
5642     END IF;
5643 
5644     IF p_x_line_rec.global_attribute15 = FND_API.G_MISS_CHAR THEN
5645         p_x_line_rec.global_attribute15 := p_old_line_rec.global_attribute15;
5646     END IF;
5647 
5648     IF p_x_line_rec.global_attribute16 = FND_API.G_MISS_CHAR THEN
5649         p_x_line_rec.global_attribute16 := p_old_line_rec.global_attribute16;
5650     END IF;
5651 
5652     IF p_x_line_rec.global_attribute17 = FND_API.G_MISS_CHAR THEN
5653         p_x_line_rec.global_attribute17 := p_old_line_rec.global_attribute17;
5654     END IF;
5655 
5656     IF p_x_line_rec.global_attribute18 = FND_API.G_MISS_CHAR THEN
5657         p_x_line_rec.global_attribute18 := p_old_line_rec.global_attribute18;
5658     END IF;
5659 
5660     IF p_x_line_rec.global_attribute19 = FND_API.G_MISS_CHAR THEN
5661         p_x_line_rec.global_attribute19 := p_old_line_rec.global_attribute19;
5662     END IF;
5663 
5664     IF p_x_line_rec.global_attribute2 = FND_API.G_MISS_CHAR THEN
5665         p_x_line_rec.global_attribute2 := p_old_line_rec.global_attribute2;
5666     END IF;
5667 
5668     IF p_x_line_rec.global_attribute20 = FND_API.G_MISS_CHAR THEN
5669         p_x_line_rec.global_attribute20 := p_old_line_rec.global_attribute20;
5670     END IF;
5671 
5672     IF p_x_line_rec.global_attribute3 = FND_API.G_MISS_CHAR THEN
5673         p_x_line_rec.global_attribute3 := p_old_line_rec.global_attribute3;
5674     END IF;
5675 
5676     IF p_x_line_rec.global_attribute4 = FND_API.G_MISS_CHAR THEN
5677         p_x_line_rec.global_attribute4 := p_old_line_rec.global_attribute4;
5678     END IF;
5679 
5680     IF p_x_line_rec.global_attribute5 = FND_API.G_MISS_CHAR THEN
5681         p_x_line_rec.global_attribute5 := p_old_line_rec.global_attribute5;
5682     END IF;
5683 
5684     IF p_x_line_rec.global_attribute6 = FND_API.G_MISS_CHAR THEN
5685         p_x_line_rec.global_attribute6 := p_old_line_rec.global_attribute6;
5686     END IF;
5687 
5688     IF p_x_line_rec.global_attribute7 = FND_API.G_MISS_CHAR THEN
5689         p_x_line_rec.global_attribute7 := p_old_line_rec.global_attribute7;
5690     END IF;
5691 
5692     IF p_x_line_rec.global_attribute8 = FND_API.G_MISS_CHAR THEN
5693         p_x_line_rec.global_attribute8 := p_old_line_rec.global_attribute8;
5694     END IF;
5695 
5696     IF p_x_line_rec.global_attribute9 = FND_API.G_MISS_CHAR THEN
5697         p_x_line_rec.global_attribute9 := p_old_line_rec.global_attribute9;
5698     END IF;
5699 
5700     IF p_x_line_rec.global_attribute_category = FND_API.G_MISS_CHAR THEN
5701         p_x_line_rec.global_attribute_category := p_old_line_rec.global_attribute_category;
5702     END IF;
5703 
5704     IF p_x_line_rec.header_id = FND_API.G_MISS_NUM THEN
5705         p_x_line_rec.header_id := p_old_line_rec.header_id;
5706     END IF;
5707 
5708     IF p_x_line_rec.industry_attribute1 = FND_API.G_MISS_CHAR THEN
5709         p_x_line_rec.industry_attribute1 := p_old_line_rec.industry_attribute1;
5710     END IF;
5711 
5712     IF p_x_line_rec.industry_attribute10 = FND_API.G_MISS_CHAR THEN
5713         p_x_line_rec.industry_attribute10 := p_old_line_rec.industry_attribute10;
5714     END IF;
5715 
5716     IF p_x_line_rec.industry_attribute11 = FND_API.G_MISS_CHAR THEN
5717         p_x_line_rec.industry_attribute11 := p_old_line_rec.industry_attribute11;
5718     END IF;
5719 
5720     IF p_x_line_rec.industry_attribute12 = FND_API.G_MISS_CHAR THEN
5721         p_x_line_rec.industry_attribute12 := p_old_line_rec.industry_attribute12;
5722     END IF;
5723 
5724     IF p_x_line_rec.industry_attribute13 = FND_API.G_MISS_CHAR THEN
5725         p_x_line_rec.industry_attribute13 := p_old_line_rec.industry_attribute13;
5726     END IF;
5727 
5728     IF p_x_line_rec.industry_attribute14 = FND_API.G_MISS_CHAR THEN
5729         p_x_line_rec.industry_attribute14 := p_old_line_rec.industry_attribute14;
5730     END IF;
5731 
5732     IF p_x_line_rec.industry_attribute15 = FND_API.G_MISS_CHAR THEN
5733         p_x_line_rec.industry_attribute15 := p_old_line_rec.industry_attribute15;
5734     END IF;
5735 
5736     IF p_x_line_rec.industry_attribute16 = FND_API.G_MISS_CHAR THEN
5737         p_x_line_rec.industry_attribute16 := p_old_line_rec.industry_attribute16;
5738     END IF;
5739     IF p_x_line_rec.industry_attribute17 = FND_API.G_MISS_CHAR THEN
5740         p_x_line_rec.industry_attribute17 := p_old_line_rec.industry_attribute17;
5741     END IF;
5742     IF p_x_line_rec.industry_attribute18 = FND_API.G_MISS_CHAR THEN
5743         p_x_line_rec.industry_attribute18 := p_old_line_rec.industry_attribute18;
5744     END IF;
5745     IF p_x_line_rec.industry_attribute19 = FND_API.G_MISS_CHAR THEN
5746         p_x_line_rec.industry_attribute19 := p_old_line_rec.industry_attribute19;
5747     END IF;
5748     IF p_x_line_rec.industry_attribute20 = FND_API.G_MISS_CHAR THEN
5749         p_x_line_rec.industry_attribute20 := p_old_line_rec.industry_attribute20;
5750     END IF;
5751     IF p_x_line_rec.industry_attribute21 = FND_API.G_MISS_CHAR THEN
5752         p_x_line_rec.industry_attribute21 := p_old_line_rec.industry_attribute21;
5753     END IF;
5754     IF p_x_line_rec.industry_attribute22 = FND_API.G_MISS_CHAR THEN
5755         p_x_line_rec.industry_attribute22 := p_old_line_rec.industry_attribute22;
5756     END IF;
5757     IF p_x_line_rec.industry_attribute23 = FND_API.G_MISS_CHAR THEN
5758         p_x_line_rec.industry_attribute23 := p_old_line_rec.industry_attribute23;
5759     END IF;
5760     IF p_x_line_rec.industry_attribute24 = FND_API.G_MISS_CHAR THEN
5761         p_x_line_rec.industry_attribute24 := p_old_line_rec.industry_attribute24;
5762     END IF;
5763     IF p_x_line_rec.industry_attribute25 = FND_API.G_MISS_CHAR THEN
5764         p_x_line_rec.industry_attribute25 := p_old_line_rec.industry_attribute25;
5765     END IF;
5766     IF p_x_line_rec.industry_attribute26 = FND_API.G_MISS_CHAR THEN
5767         p_x_line_rec.industry_attribute26 := p_old_line_rec.industry_attribute26;
5768     END IF;
5769     IF p_x_line_rec.industry_attribute27 = FND_API.G_MISS_CHAR THEN
5770         p_x_line_rec.industry_attribute27 := p_old_line_rec.industry_attribute27;
5771     END IF;
5772     IF p_x_line_rec.industry_attribute28 = FND_API.G_MISS_CHAR THEN
5773         p_x_line_rec.industry_attribute28 := p_old_line_rec.industry_attribute28;
5774     END IF;
5775     IF p_x_line_rec.industry_attribute29 = FND_API.G_MISS_CHAR THEN
5776         p_x_line_rec.industry_attribute29 := p_old_line_rec.industry_attribute29;
5777     END IF;
5778     IF p_x_line_rec.industry_attribute30 = FND_API.G_MISS_CHAR THEN
5779         p_x_line_rec.industry_attribute30 := p_old_line_rec.industry_attribute30;
5780     END IF;
5781     IF p_x_line_rec.industry_attribute2 = FND_API.G_MISS_CHAR THEN
5782         p_x_line_rec.industry_attribute2 := p_old_line_rec.industry_attribute2;
5783     END IF;
5784 
5785     IF p_x_line_rec.industry_attribute3 = FND_API.G_MISS_CHAR THEN
5786         p_x_line_rec.industry_attribute3 := p_old_line_rec.industry_attribute3;
5787     END IF;
5788 
5789     IF p_x_line_rec.industry_attribute4 = FND_API.G_MISS_CHAR THEN
5790         p_x_line_rec.industry_attribute4 := p_old_line_rec.industry_attribute4;
5791     END IF;
5792 
5793     IF p_x_line_rec.industry_attribute5 = FND_API.G_MISS_CHAR THEN
5794         p_x_line_rec.industry_attribute5 := p_old_line_rec.industry_attribute5;
5795     END IF;
5796 
5797     IF p_x_line_rec.industry_attribute6 = FND_API.G_MISS_CHAR THEN
5798         p_x_line_rec.industry_attribute6 := p_old_line_rec.industry_attribute6;
5799     END IF;
5800 
5801     IF p_x_line_rec.industry_attribute7 = FND_API.G_MISS_CHAR THEN
5802         p_x_line_rec.industry_attribute7 := p_old_line_rec.industry_attribute7;
5803     END IF;
5804 
5805     IF p_x_line_rec.industry_attribute8 = FND_API.G_MISS_CHAR THEN
5806         p_x_line_rec.industry_attribute8 := p_old_line_rec.industry_attribute8;
5807     END IF;
5808 
5809     IF p_x_line_rec.industry_attribute9 = FND_API.G_MISS_CHAR THEN
5810         p_x_line_rec.industry_attribute9 := p_old_line_rec.industry_attribute9;
5811     END IF;
5812 
5813     IF p_x_line_rec.industry_context = FND_API.G_MISS_CHAR THEN
5814         p_x_line_rec.industry_context := p_old_line_rec.industry_context;
5815     END IF;
5816 
5817     /* TP_ATTRIBUTE */
5818     IF p_x_line_rec.tp_context = FND_API.G_MISS_CHAR THEN
5819         p_x_line_rec.tp_context := p_old_line_rec.tp_context;
5820     END IF;
5821 
5822     IF p_x_line_rec.tp_attribute1 = FND_API.G_MISS_CHAR THEN
5823         p_x_line_rec.tp_attribute1 := p_old_line_rec.tp_attribute1;
5824     END IF;
5825     IF p_x_line_rec.tp_attribute2 = FND_API.G_MISS_CHAR THEN
5826         p_x_line_rec.tp_attribute2 := p_old_line_rec.tp_attribute2;
5827     END IF;
5828     IF p_x_line_rec.tp_attribute3 = FND_API.G_MISS_CHAR THEN
5829         p_x_line_rec.tp_attribute3 := p_old_line_rec.tp_attribute3;
5830     END IF;
5831     IF p_x_line_rec.tp_attribute4 = FND_API.G_MISS_CHAR THEN
5832         p_x_line_rec.tp_attribute4 := p_old_line_rec.tp_attribute4;
5833     END IF;
5834     IF p_x_line_rec.tp_attribute5 = FND_API.G_MISS_CHAR THEN
5835         p_x_line_rec.tp_attribute5 := p_old_line_rec.tp_attribute5;
5836     END IF;
5837     IF p_x_line_rec.tp_attribute6 = FND_API.G_MISS_CHAR THEN
5838         p_x_line_rec.tp_attribute6 := p_old_line_rec.tp_attribute6;
5839     END IF;
5840     IF p_x_line_rec.tp_attribute7 = FND_API.G_MISS_CHAR THEN
5841         p_x_line_rec.tp_attribute7 := p_old_line_rec.tp_attribute7;
5842     END IF;
5843     IF p_x_line_rec.tp_attribute8 = FND_API.G_MISS_CHAR THEN
5844         p_x_line_rec.tp_attribute8 := p_old_line_rec.tp_attribute8;
5845     END IF;
5846     IF p_x_line_rec.tp_attribute9 = FND_API.G_MISS_CHAR THEN
5847         p_x_line_rec.tp_attribute9 := p_old_line_rec.tp_attribute9;
5848     END IF;
5849     IF p_x_line_rec.tp_attribute10 = FND_API.G_MISS_CHAR THEN
5850         p_x_line_rec.tp_attribute10 := p_old_line_rec.tp_attribute10;
5851     END IF;
5852     IF p_x_line_rec.tp_attribute11 = FND_API.G_MISS_CHAR THEN
5853         p_x_line_rec.tp_attribute11 := p_old_line_rec.tp_attribute11;
5854     END IF;
5855     IF p_x_line_rec.tp_attribute12 = FND_API.G_MISS_CHAR THEN
5856         p_x_line_rec.tp_attribute12 := p_old_line_rec.tp_attribute12;
5857     END IF;
5858     IF p_x_line_rec.tp_attribute13 = FND_API.G_MISS_CHAR THEN
5859         p_x_line_rec.tp_attribute13 := p_old_line_rec.tp_attribute13;
5860     END IF;
5861     IF p_x_line_rec.tp_attribute14 = FND_API.G_MISS_CHAR THEN
5862         p_x_line_rec.tp_attribute14 := p_old_line_rec.tp_attribute14;
5863     END IF;
5864     IF p_x_line_rec.tp_attribute15 = FND_API.G_MISS_CHAR THEN
5865         p_x_line_rec.tp_attribute15 := p_old_line_rec.tp_attribute15;
5866     END IF;
5867 
5868 
5869     IF p_x_line_rec.intermed_ship_to_contact_id = FND_API.G_MISS_NUM THEN
5870         p_x_line_rec.intermed_ship_to_contact_id := p_old_line_rec.intermed_ship_to_contact_id;
5871     END IF;
5872 
5873     IF p_x_line_rec.intermed_ship_to_org_id = FND_API.G_MISS_NUM THEN
5874         p_x_line_rec.intermed_ship_to_org_id := p_old_line_rec.intermed_ship_to_org_id;
5875     END IF;
5876 
5877     IF p_x_line_rec.inventory_item_id = FND_API.G_MISS_NUM THEN
5878         p_x_line_rec.inventory_item_id := p_old_line_rec.inventory_item_id;
5879     END IF;
5880 
5881     IF p_x_line_rec.invoice_interface_status_code = FND_API.G_MISS_CHAR THEN
5882         p_x_line_rec.invoice_interface_status_code := p_old_line_rec.invoice_interface_status_code;
5883     END IF;
5884 
5885 
5886 
5887     IF p_x_line_rec.invoice_to_contact_id = FND_API.G_MISS_NUM THEN
5888         p_x_line_rec.invoice_to_contact_id := p_old_line_rec.invoice_to_contact_id;
5889     END IF;
5890 
5891     IF p_x_line_rec.invoice_to_org_id = FND_API.G_MISS_NUM THEN
5892         p_x_line_rec.invoice_to_org_id := p_old_line_rec.invoice_to_org_id;
5893     END IF;
5894 
5895     IF p_x_line_rec.invoiced_quantity = FND_API.G_MISS_NUM THEN
5896         p_x_line_rec.invoiced_quantity := p_old_line_rec.invoiced_quantity;
5897     END IF;
5898 
5899     IF p_x_line_rec.invoicing_rule_id = FND_API.G_MISS_NUM THEN
5900         p_x_line_rec.invoicing_rule_id := p_old_line_rec.invoicing_rule_id;
5901     END IF;
5902 
5903     IF p_x_line_rec.ordered_item_id = FND_API.G_MISS_NUM THEN
5904         p_x_line_rec.ordered_item_id := p_old_line_rec.ordered_item_id;
5905     END IF;
5906 
5907     IF p_x_line_rec.item_identifier_type = FND_API.G_MISS_CHAR THEN
5908         p_x_line_rec.item_identifier_type := p_old_line_rec.item_identifier_type;
5909     END IF;
5910 
5911     IF p_x_line_rec.ordered_item = FND_API.G_MISS_CHAR THEN
5912         p_x_line_rec.ordered_item := p_old_line_rec.ordered_item;
5913     END IF;
5914 
5915     IF p_x_line_rec.item_revision = FND_API.G_MISS_CHAR THEN
5916         p_x_line_rec.item_revision := p_old_line_rec.item_revision;
5917     END IF;
5918 
5919     IF p_x_line_rec.item_type_code = FND_API.G_MISS_CHAR THEN
5920         p_x_line_rec.item_type_code := p_old_line_rec.item_type_code;
5921     END IF;
5922 
5923     IF p_x_line_rec.last_updated_by = FND_API.G_MISS_NUM THEN
5924         p_x_line_rec.last_updated_by := p_old_line_rec.last_updated_by;
5925     END IF;
5926 
5927     IF p_x_line_rec.last_update_date = FND_API.G_MISS_DATE THEN
5928         p_x_line_rec.last_update_date := p_old_line_rec.last_update_date;
5929     END IF;
5930 
5931     IF p_x_line_rec.last_update_login = FND_API.G_MISS_NUM THEN
5932         p_x_line_rec.last_update_login := p_old_line_rec.last_update_login;
5933     END IF;
5934 
5935     IF p_x_line_rec.latest_acceptable_date = FND_API.G_MISS_DATE THEN
5936         p_x_line_rec.latest_acceptable_date := p_old_line_rec.latest_acceptable_date;
5937     END IF;
5938 
5939     IF p_x_line_rec.line_category_code = FND_API.G_MISS_CHAR THEN
5940         p_x_line_rec.line_category_code := p_old_line_rec.line_category_code;
5941     END IF;
5942 
5943     IF p_x_line_rec.line_id = FND_API.G_MISS_NUM THEN
5944         p_x_line_rec.line_id := p_old_line_rec.line_id;
5945     END IF;
5946 
5947     IF p_x_line_rec.line_number = FND_API.G_MISS_NUM THEN
5948         p_x_line_rec.line_number := p_old_line_rec.line_number;
5949     END IF;
5950 
5951     IF p_x_line_rec.line_type_id = FND_API.G_MISS_NUM THEN
5952         p_x_line_rec.line_type_id := p_old_line_rec.line_type_id;
5953     END IF;
5954 
5955     IF p_x_line_rec.link_to_line_id = FND_API.G_MISS_NUM THEN
5956         p_x_line_rec.link_to_line_id := p_old_line_rec.link_to_line_id;
5957     END IF;
5958 
5959     IF p_x_line_rec.model_group_number = FND_API.G_MISS_NUM THEN
5960         p_x_line_rec.model_group_number := p_old_line_rec.model_group_number;
5961     END IF;
5962 
5963     IF p_x_line_rec.mfg_component_sequence_id = FND_API.G_MISS_NUM THEN
5964         p_x_line_rec.mfg_component_sequence_id := p_old_line_rec.mfg_component_sequence_id;
5965     END IF;
5966 
5967     IF p_x_line_rec.mfg_lead_time = FND_API.G_MISS_NUM THEN
5968         p_x_line_rec.mfg_lead_time := p_old_line_rec.mfg_lead_time;
5969     END IF;
5970 
5971     IF p_x_line_rec.open_flag = FND_API.G_MISS_CHAR THEN
5972         p_x_line_rec.open_flag := p_old_line_rec.open_flag;
5973     END IF;
5974 
5975     IF p_x_line_rec.option_flag = FND_API.G_MISS_CHAR THEN
5976         p_x_line_rec.option_flag := p_old_line_rec.option_flag;
5977     END IF;
5978 
5979     IF p_x_line_rec.option_number = FND_API.G_MISS_NUM THEN
5980         p_x_line_rec.option_number := p_old_line_rec.option_number;
5981     END IF;
5982 
5983     IF p_x_line_rec.ordered_quantity = FND_API.G_MISS_NUM THEN
5984         p_x_line_rec.ordered_quantity := p_old_line_rec.ordered_quantity;
5985     END IF;
5986 
5987     -- OPM 02/JUN/00 INVCONV
5988     IF p_x_line_rec.ordered_quantity2 = FND_API.G_MISS_NUM THEN
5989         p_x_line_rec.ordered_quantity2 := p_old_line_rec.ordered_quantity2;
5990     END IF;
5991     -- OPM 02/JUN/00 END
5992 
5993     IF p_x_line_rec.order_quantity_uom = FND_API.G_MISS_CHAR THEN
5994         p_x_line_rec.order_quantity_uom := p_old_line_rec.order_quantity_uom;
5995     END IF;
5996 
5997     -- OPM 02/JUN/00 INVCONV
5998 
5999     IF p_x_line_rec.ordered_quantity_uom2 = FND_API.G_MISS_CHAR THEN
6000         p_x_line_rec.ordered_quantity_uom2 :=p_old_line_rec.ordered_quantity_uom2;
6001     END IF;
6002     -- OPM 02/JUN/00 END
6003 
6004     IF p_x_line_rec.org_id = FND_API.G_MISS_NUM THEN
6005         p_x_line_rec.org_id := p_old_line_rec.org_id;
6006     END IF;
6007 
6008     IF p_x_line_rec.orig_sys_document_ref = FND_API.G_MISS_CHAR THEN
6009         p_x_line_rec.orig_sys_document_ref := p_old_line_rec.orig_sys_document_ref;
6010     END IF;
6011 
6012     IF p_x_line_rec.orig_sys_line_ref = FND_API.G_MISS_CHAR THEN
6013         p_x_line_rec.orig_sys_line_ref := p_old_line_rec.orig_sys_line_ref;
6014     END IF;
6015 
6016     IF p_x_line_rec.orig_sys_shipment_ref = FND_API.G_MISS_CHAR THEN
6017         p_x_line_rec.orig_sys_shipment_ref := p_old_line_rec.orig_sys_shipment_ref;
6018     END IF;
6019 
6020 -- Override List Price
6021     IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
6022        IF p_x_line_rec.original_list_price = FND_API.G_MISS_NUM THEN
6023           p_x_line_rec.original_list_price:= p_old_line_rec.original_list_price;
6024        END IF;
6025     END IF;
6026 -- Override List Price
6027 
6028    IF p_x_line_rec.over_ship_reason_code = FND_API.G_MISS_CHAR THEN
6029         p_x_line_rec.over_ship_reason_code := p_old_line_rec.over_ship_reason_code;
6030     END IF;
6031 
6032     IF p_x_line_rec.over_ship_resolved_flag = FND_API.G_MISS_CHAR THEN
6033         p_x_line_rec.over_ship_resolved_flag := p_old_line_rec.over_ship_resolved_flag;
6034     END IF;
6035 
6036     IF p_x_line_rec.payment_term_id = FND_API.G_MISS_NUM THEN
6037         p_x_line_rec.payment_term_id := p_old_line_rec.payment_term_id;
6038     END IF;
6039 
6040     IF p_x_line_rec.planning_priority = FND_API.G_MISS_NUM THEN
6041         p_x_line_rec.planning_priority := p_old_line_rec.planning_priority;
6042     END IF;
6043 
6044     -- OPM 02/JUN/00 INVCONV
6045     IF p_x_line_rec.preferred_grade = FND_API.G_MISS_CHAR THEN
6046         p_x_line_rec.preferred_grade :=p_old_line_rec.preferred_grade;
6047     END IF;
6048     -- OPM 02/JUN/00 END
6049 
6050     IF p_x_line_rec.price_list_id = FND_API.G_MISS_NUM THEN
6051         p_x_line_rec.price_list_id := p_old_line_rec.price_list_id;
6052     END IF;
6053 
6054     -- PROMOTIONS SEP/01 BEGIN
6055     IF p_x_line_rec.price_request_code = FND_API.G_MISS_CHAR THEN
6056         p_x_line_rec.price_request_code := p_old_line_rec.price_request_code;
6057     END IF;
6058     -- PROMOTIONS SEP/01 END
6059 
6060     IF p_x_line_rec.pricing_attribute1 = FND_API.G_MISS_CHAR THEN
6061         p_x_line_rec.pricing_attribute1 := p_old_line_rec.pricing_attribute1;
6062     END IF;
6063 
6064     IF p_x_line_rec.pricing_attribute10 = FND_API.G_MISS_CHAR THEN
6065         p_x_line_rec.pricing_attribute10 := p_old_line_rec.pricing_attribute10;
6066     END IF;
6067 
6068     IF p_x_line_rec.pricing_attribute2 = FND_API.G_MISS_CHAR THEN
6069         p_x_line_rec.pricing_attribute2 := p_old_line_rec.pricing_attribute2;
6070     END IF;
6071 
6072     IF p_x_line_rec.pricing_attribute3 = FND_API.G_MISS_CHAR THEN
6073         p_x_line_rec.pricing_attribute3 := p_old_line_rec.pricing_attribute3;
6074     END IF;
6075 
6076     IF p_x_line_rec.pricing_attribute4 = FND_API.G_MISS_CHAR THEN
6077         p_x_line_rec.pricing_attribute4 := p_old_line_rec.pricing_attribute4;
6078     END IF;
6079 
6080     IF p_x_line_rec.pricing_attribute5 = FND_API.G_MISS_CHAR THEN
6081         p_x_line_rec.pricing_attribute5 := p_old_line_rec.pricing_attribute5;
6082     END IF;
6083 
6084     IF p_x_line_rec.pricing_attribute6 = FND_API.G_MISS_CHAR THEN
6085         p_x_line_rec.pricing_attribute6 := p_old_line_rec.pricing_attribute6;
6086     END IF;
6087 
6088     IF p_x_line_rec.pricing_attribute7 = FND_API.G_MISS_CHAR THEN
6089         p_x_line_rec.pricing_attribute7 := p_old_line_rec.pricing_attribute7;
6090     END IF;
6091 
6092     IF p_x_line_rec.pricing_attribute8 = FND_API.G_MISS_CHAR THEN
6093         p_x_line_rec.pricing_attribute8 := p_old_line_rec.pricing_attribute8;
6094     END IF;
6095 
6096     IF p_x_line_rec.pricing_attribute9 = FND_API.G_MISS_CHAR THEN
6097         p_x_line_rec.pricing_attribute9 := p_old_line_rec.pricing_attribute9;
6098     END IF;
6099 
6100     IF p_x_line_rec.pricing_context = FND_API.G_MISS_CHAR THEN
6101         p_x_line_rec.pricing_context := p_old_line_rec.pricing_context;
6102     END IF;
6103 
6104     IF p_x_line_rec.pricing_date = FND_API.G_MISS_DATE THEN
6105         p_x_line_rec.pricing_date := p_old_line_rec.pricing_date;
6106     END IF;
6107 
6108     IF p_x_line_rec.pricing_quantity = FND_API.G_MISS_NUM THEN
6109         p_x_line_rec.pricing_quantity := p_old_line_rec.pricing_quantity;
6110     END IF;
6111 
6112     IF p_x_line_rec.pricing_quantity_uom = FND_API.G_MISS_CHAR THEN
6113         p_x_line_rec.pricing_quantity_uom := p_old_line_rec.pricing_quantity_uom;
6114     END IF;
6115 
6116     IF p_x_line_rec.program_application_id = FND_API.G_MISS_NUM THEN
6117         p_x_line_rec.program_application_id := p_old_line_rec.program_application_id;
6118     END IF;
6119 
6120     IF p_x_line_rec.program_id = FND_API.G_MISS_NUM THEN
6121         p_x_line_rec.program_id := p_old_line_rec.program_id;
6122     END IF;
6123 
6124     IF p_x_line_rec.program_update_date = FND_API.G_MISS_DATE THEN
6125         p_x_line_rec.program_update_date := p_old_line_rec.program_update_date;
6126     END IF;
6127 
6128     IF p_x_line_rec.project_id = FND_API.G_MISS_NUM THEN
6129         p_x_line_rec.project_id := p_old_line_rec.project_id;
6130     END IF;
6131 
6132     IF p_x_line_rec.promise_date = FND_API.G_MISS_DATE THEN
6133         p_x_line_rec.promise_date := p_old_line_rec.promise_date;
6134     END IF;
6135 
6136     IF p_x_line_rec.re_source_flag = FND_API.G_MISS_CHAR THEN
6137         p_x_line_rec.re_source_flag := p_old_line_rec.re_source_flag;
6138     END IF;
6139 
6140     IF p_x_line_rec.reference_customer_trx_line_id = FND_API.G_MISS_NUM THEN
6141         p_x_line_rec.reference_customer_trx_line_id := p_old_line_rec.reference_customer_trx_line_id;
6142     END IF;
6143 
6144     IF p_x_line_rec.reference_header_id = FND_API.G_MISS_NUM THEN
6145         p_x_line_rec.reference_header_id := p_old_line_rec.reference_header_id;
6146     END IF;
6147 
6148     IF p_x_line_rec.reference_line_id = FND_API.G_MISS_NUM THEN
6149         p_x_line_rec.reference_line_id := p_old_line_rec.reference_line_id;
6150     END IF;
6151 
6152     IF p_x_line_rec.reference_type = FND_API.G_MISS_CHAR THEN
6153         p_x_line_rec.reference_type := p_old_line_rec.reference_type;
6154     END IF;
6155 
6156 
6157 
6158     IF p_x_line_rec.request_date = FND_API.G_MISS_DATE THEN
6159         p_x_line_rec.request_date := p_old_line_rec.request_date;
6160     END IF;
6161 
6162     IF p_x_line_rec.request_id = FND_API.G_MISS_NUM THEN
6163         p_x_line_rec.request_id := p_old_line_rec.request_id;
6164     END IF;
6165 
6166     IF p_x_line_rec.reserved_quantity = FND_API.G_MISS_NUM THEN
6167         p_x_line_rec.reserved_quantity := p_old_line_rec.reserved_quantity;
6168     END IF;
6169 
6170 
6171 
6172     IF p_x_line_rec.return_attribute1 = FND_API.G_MISS_CHAR THEN
6173         p_x_line_rec.return_attribute1 := p_old_line_rec.return_attribute1;
6174     END IF;
6175 
6176     IF p_x_line_rec.return_attribute10 = FND_API.G_MISS_CHAR THEN
6177         p_x_line_rec.return_attribute10 := p_old_line_rec.return_attribute10;
6178     END IF;
6179 
6180     IF p_x_line_rec.return_attribute11 = FND_API.G_MISS_CHAR THEN
6181         p_x_line_rec.return_attribute11 := p_old_line_rec.return_attribute11;
6182     END IF;
6183 
6184     IF p_x_line_rec.return_attribute12 = FND_API.G_MISS_CHAR THEN
6185         p_x_line_rec.return_attribute12 := p_old_line_rec.return_attribute12;
6186     END IF;
6187 
6188     IF p_x_line_rec.return_attribute13 = FND_API.G_MISS_CHAR THEN
6189         p_x_line_rec.return_attribute13 := p_old_line_rec.return_attribute13;
6190     END IF;
6191 
6192     IF p_x_line_rec.return_attribute14 = FND_API.G_MISS_CHAR THEN
6193         p_x_line_rec.return_attribute14 := p_old_line_rec.return_attribute14;
6194     END IF;
6195 
6196     IF p_x_line_rec.return_attribute15 = FND_API.G_MISS_CHAR THEN
6197         p_x_line_rec.return_attribute15 := p_old_line_rec.return_attribute15;
6198     END IF;
6199 
6200     IF p_x_line_rec.return_attribute2 = FND_API.G_MISS_CHAR THEN
6201         p_x_line_rec.return_attribute2 := p_old_line_rec.return_attribute2;
6202     END IF;
6203 
6204     IF p_x_line_rec.return_attribute3 = FND_API.G_MISS_CHAR THEN
6205         p_x_line_rec.return_attribute3 := p_old_line_rec.return_attribute3;
6206     END IF;
6207 
6208     IF p_x_line_rec.return_attribute4 = FND_API.G_MISS_CHAR THEN
6209         p_x_line_rec.return_attribute4 := p_old_line_rec.return_attribute4;
6210     END IF;
6211 
6212     IF p_x_line_rec.return_attribute5 = FND_API.G_MISS_CHAR THEN
6213         p_x_line_rec.return_attribute5 := p_old_line_rec.return_attribute5;
6214     END IF;
6215 
6216     IF p_x_line_rec.return_attribute6 = FND_API.G_MISS_CHAR THEN
6217         p_x_line_rec.return_attribute6 := p_old_line_rec.return_attribute6;
6218     END IF;
6219 
6220     IF p_x_line_rec.return_attribute7 = FND_API.G_MISS_CHAR THEN
6221         p_x_line_rec.return_attribute7 := p_old_line_rec.return_attribute7;
6222     END IF;
6223 
6224     IF p_x_line_rec.return_attribute8 = FND_API.G_MISS_CHAR THEN
6225         p_x_line_rec.return_attribute8 := p_old_line_rec.return_attribute8;
6226     END IF;
6227 
6228     IF p_x_line_rec.return_attribute9 = FND_API.G_MISS_CHAR THEN
6229         p_x_line_rec.return_attribute9 := p_old_line_rec.return_attribute9;
6230     END IF;
6231 
6232     IF p_x_line_rec.return_context = FND_API.G_MISS_CHAR THEN
6233         p_x_line_rec.return_context := p_old_line_rec.return_context;
6234     END IF;
6235 
6236     IF p_x_line_rec.return_reason_code = FND_API.G_MISS_CHAR THEN
6237         p_x_line_rec.return_reason_code := p_old_line_rec.return_reason_code;
6238     END IF;
6239     IF p_x_line_rec.salesrep_id = FND_API.G_MISS_NUM THEN
6240         p_x_line_rec.salesrep_id := p_old_line_rec.salesrep_id;
6241     END IF;
6242 
6243     IF p_x_line_rec.rla_schedule_type_code = FND_API.G_MISS_CHAR THEN
6244         p_x_line_rec.rla_schedule_type_code := p_old_line_rec.rla_schedule_type_code;
6245     END IF;
6246 
6247     IF p_x_line_rec.schedule_arrival_date = FND_API.G_MISS_DATE THEN
6248         p_x_line_rec.schedule_arrival_date := p_old_line_rec.schedule_arrival_date;
6249     END IF;
6250 
6251     IF p_x_line_rec.schedule_ship_date = FND_API.G_MISS_DATE THEN
6252         p_x_line_rec.schedule_ship_date := p_old_line_rec.schedule_ship_date;
6253     END IF;
6254 
6255     IF p_x_line_rec.schedule_action_code = FND_API.G_MISS_CHAR THEN
6256         p_x_line_rec.schedule_action_code := p_old_line_rec.schedule_action_code;
6257     END IF;
6258 
6259     IF p_x_line_rec.schedule_status_code = FND_API.G_MISS_CHAR THEN
6260         p_x_line_rec.schedule_status_code := p_old_line_rec.schedule_status_code;
6261     END IF;
6262 
6263     IF p_x_line_rec.shipment_number = FND_API.G_MISS_NUM THEN
6264         p_x_line_rec.shipment_number := p_old_line_rec.shipment_number;
6265     END IF;
6266 
6267     IF p_x_line_rec.shipment_priority_code = FND_API.G_MISS_CHAR THEN
6268         p_x_line_rec.shipment_priority_code := p_old_line_rec.shipment_priority_code;
6269     END IF;
6270 
6271     IF p_x_line_rec.shipped_quantity = FND_API.G_MISS_NUM THEN
6272         p_x_line_rec.shipped_quantity := p_old_line_rec.shipped_quantity;
6273     END IF;
6274 
6275     IF p_x_line_rec.shipped_quantity2 = FND_API.G_MISS_NUM THEN -- OPM B1661023 04/02/01 INVCONV
6276         p_x_line_rec.shipped_quantity2 := p_old_line_rec.shipped_quantity2;
6277     END IF;
6278 
6279     IF p_x_line_rec.shipping_method_code = FND_API.G_MISS_CHAR THEN
6280         p_x_line_rec.shipping_method_code := p_old_line_rec.shipping_method_code;
6281     END IF;
6282 
6283     IF p_x_line_rec.shipping_quantity = FND_API.G_MISS_NUM THEN
6284         p_x_line_rec.shipping_quantity := p_old_line_rec.shipping_quantity;
6285     END IF;
6286 
6287     IF p_x_line_rec.shipping_quantity2 = FND_API.G_MISS_NUM THEN -- OPM B1661023 04/02/01 INVCONV
6288         p_x_line_rec.shipping_quantity2 := p_old_line_rec.shipping_quantity2;
6289     END IF;
6290 
6291     IF p_x_line_rec.shipping_quantity_uom = FND_API.G_MISS_CHAR THEN
6292         p_x_line_rec.shipping_quantity_uom := p_old_line_rec.shipping_quantity_uom;
6293     END IF;
6294 
6295     IF p_x_line_rec.ship_from_org_id = FND_API.G_MISS_NUM THEN
6296         p_x_line_rec.ship_from_org_id := p_old_line_rec.ship_from_org_id;
6297     END IF;
6298 
6299     IF p_x_line_rec.subinventory = FND_API.G_MISS_CHAR THEN
6300         p_x_line_rec.subinventory := p_old_line_rec.subinventory;
6301     END IF;
6302 
6303     IF p_x_line_rec.ship_model_complete_flag = FND_API.G_MISS_CHAR THEN
6304         p_x_line_rec.ship_model_complete_flag := p_old_line_rec.ship_model_complete_flag;
6305     END IF;
6306     IF p_x_line_rec.ship_set_id = FND_API.G_MISS_NUM THEN
6307         p_x_line_rec.ship_Set_id := p_old_line_rec.ship_set_id;
6308     END IF;
6309 
6310     IF p_x_line_rec.ship_tolerance_above = FND_API.G_MISS_NUM THEN
6311         p_x_line_rec.ship_tolerance_above := p_old_line_rec.ship_tolerance_above;
6312     END IF;
6313 
6314     IF p_x_line_rec.ship_tolerance_below = FND_API.G_MISS_NUM THEN
6315         p_x_line_rec.ship_tolerance_below := p_old_line_rec.ship_tolerance_below;
6316     END IF;
6317 
6318     IF p_x_line_rec.shippable_flag = FND_API.G_MISS_CHAR THEN
6319         p_x_line_rec.shippable_flag := p_old_line_rec.shippable_flag;
6320     END IF;
6321 
6322     IF p_x_line_rec.shipping_interfaced_flag = FND_API.G_MISS_CHAR THEN
6323         p_x_line_rec.shipping_interfaced_flag := p_old_line_rec.shipping_interfaced_flag;
6324     END IF;
6325 
6326     IF p_x_line_rec.ship_to_contact_id = FND_API.G_MISS_NUM THEN
6327         p_x_line_rec.ship_to_contact_id := p_old_line_rec.ship_to_contact_id;
6328     END IF;
6329 
6330     IF p_x_line_rec.ship_to_org_id = FND_API.G_MISS_NUM THEN
6331         p_x_line_rec.ship_to_org_id := p_old_line_rec.ship_to_org_id;
6332     END IF;
6333 
6334     IF p_x_line_rec.sold_from_org_id = FND_API.G_MISS_NUM THEN
6335         p_x_line_rec.sold_from_org_id := p_old_line_rec.sold_from_org_id;
6336     END IF;
6337 
6338     IF p_x_line_rec.sold_to_org_id = FND_API.G_MISS_NUM THEN
6339         p_x_line_rec.sold_to_org_id := p_old_line_rec.sold_to_org_id;
6340     END IF;
6341 
6342     IF p_x_line_rec.sort_order = FND_API.G_MISS_CHAR THEN
6343         p_x_line_rec.sort_order := p_old_line_rec.sort_order;
6344     END IF;
6345 
6346     IF p_x_line_rec.source_document_id = FND_API.G_MISS_NUM THEN
6347         p_x_line_rec.source_document_id := p_old_line_rec.source_document_id;
6348     END IF;
6349 
6350     IF p_x_line_rec.source_document_line_id = FND_API.G_MISS_NUM THEN
6351         p_x_line_rec.source_document_line_id := p_old_line_rec.source_document_line_id;
6352     END IF;
6353 
6354     IF p_x_line_rec.source_document_type_id = FND_API.G_MISS_NUM THEN
6355         p_x_line_rec.source_document_type_id := p_old_line_rec.source_document_type_id;
6356     END IF;
6357 
6358     IF p_x_line_rec.source_type_code = FND_API.G_MISS_CHAR THEN
6359         p_x_line_rec.source_type_code := p_old_line_rec.source_type_code;
6360     END IF;
6361     IF p_x_line_rec.split_from_line_id = FND_API.G_MISS_NUM THEN
6362         p_x_line_rec.split_from_line_id := p_old_line_rec.split_from_line_id;
6363     END IF;
6364 
6365     IF p_x_line_rec.line_set_id = FND_API.G_MISS_NUM THEN
6366         p_x_line_rec.line_set_id := p_old_line_rec.line_set_id;
6367     END IF;
6368     IF p_x_line_rec.split_by = FND_API.G_MISS_CHAR THEN
6369         p_x_line_rec.split_by := p_old_line_rec.split_by;
6370     END IF;
6371     IF p_x_line_rec.model_remnant_flag = FND_API.G_MISS_CHAR THEN
6372         p_x_line_rec.model_remnant_flag := p_old_line_rec.model_remnant_flag;
6373     END IF;
6374 
6375     IF p_x_line_rec.task_id = FND_API.G_MISS_NUM THEN
6376         p_x_line_rec.task_id := p_old_line_rec.task_id;
6377     END IF;
6378 
6379     IF p_x_line_rec.tax_code = FND_API.G_MISS_CHAR THEN
6380         p_x_line_rec.tax_code := p_old_line_rec.tax_code;
6381     END IF;
6382 
6383     IF p_x_line_rec.tax_date = FND_API.G_MISS_DATE THEN
6384         p_x_line_rec.tax_date := p_old_line_rec.tax_date;
6385     END IF;
6386 
6387     IF p_x_line_rec.tax_exempt_flag = FND_API.G_MISS_CHAR THEN
6388         p_x_line_rec.tax_exempt_flag := p_old_line_rec.tax_exempt_flag;
6389     END IF;
6390 
6391     IF p_x_line_rec.tax_exempt_number = FND_API.G_MISS_CHAR THEN
6392         p_x_line_rec.tax_exempt_number := p_old_line_rec.tax_exempt_number;
6393     END IF;
6394 
6395     IF p_x_line_rec.tax_exempt_reason_code = FND_API.G_MISS_CHAR THEN
6396         p_x_line_rec.tax_exempt_reason_code := p_old_line_rec.tax_exempt_reason_code;
6397     END IF;
6398 
6399     IF p_x_line_rec.tax_point_code = FND_API.G_MISS_CHAR THEN
6400         p_x_line_rec.tax_point_code := p_old_line_rec.tax_point_code;
6401     END IF;
6402 
6403     IF p_x_line_rec.tax_rate = FND_API.G_MISS_NUM THEN
6404         p_x_line_rec.tax_rate := p_old_line_rec.tax_rate;
6405     END IF;
6406 
6407     IF p_x_line_rec.tax_value = FND_API.G_MISS_NUM THEN
6408         p_x_line_rec.tax_value := p_old_line_rec.tax_value;
6409     END IF;
6410 
6411     IF p_x_line_rec.top_model_line_id = FND_API.G_MISS_NUM THEN
6412         p_x_line_rec.top_model_line_id := p_old_line_rec.top_model_line_id;
6413     END IF;
6414 
6415     IF p_x_line_rec.unit_list_price = FND_API.G_MISS_NUM THEN
6416         p_x_line_rec.unit_list_price := p_old_line_rec.unit_list_price;
6417     END IF;
6418 
6419     IF p_x_line_rec.unit_list_price_per_pqty = FND_API.G_MISS_NUM THEN
6420         p_x_line_rec.unit_list_price_per_pqty := p_old_line_rec.unit_list_price_per_pqty;
6421     END IF;
6422 
6423     IF p_x_line_rec.unit_selling_price = FND_API.G_MISS_NUM THEN
6424         p_x_line_rec.unit_selling_price := p_old_line_rec.unit_selling_price;
6425     END IF;
6426 
6427     IF p_x_line_rec.unit_selling_price_per_pqty = FND_API.G_MISS_NUM THEN
6428         p_x_line_rec.unit_selling_price_per_pqty := p_old_line_rec.unit_selling_price_per_pqty;
6429     END IF;
6430 
6431     IF p_x_line_rec.visible_demand_flag = FND_API.G_MISS_CHAR THEN
6432         p_x_line_rec.visible_demand_flag := p_old_line_rec.visible_demand_flag;
6433     END IF;
6434      IF p_x_line_rec.veh_cus_item_cum_key_id = FND_API.G_MISS_NUM THEN
6435         p_x_line_rec.veh_cus_item_cum_key_id := p_old_line_rec.veh_cus_item_cum_key_id;
6436     END IF;
6437 
6438     IF p_x_line_rec.first_ack_code = FND_API.G_MISS_CHAR THEN
6439         p_x_line_rec.first_ack_code := p_old_line_rec.first_ack_code;
6440     END IF;
6441 
6442     IF p_x_line_rec.first_ack_date = FND_API.G_MISS_DATE THEN
6443         p_x_line_rec.first_ack_date := p_old_line_rec.first_ack_date;
6444     END IF;
6445 
6446     IF p_x_line_rec.last_ack_code = FND_API.G_MISS_CHAR THEN
6447         p_x_line_rec.last_ack_code := p_old_line_rec.last_ack_code;
6448     END IF;
6449 
6450     IF p_x_line_rec.last_ack_date = FND_API.G_MISS_DATE THEN
6451         p_x_line_rec.last_ack_date := p_old_line_rec.last_ack_date;
6452     END IF;
6453 
6454     IF p_x_line_rec.end_item_unit_number = FND_API.G_MISS_CHAR THEN
6455         p_x_line_rec.end_item_unit_number := p_old_line_rec.end_item_unit_number;
6456     END IF;
6457 
6458     IF p_x_line_rec.shipping_instructions = FND_API.G_MISS_CHAR THEN
6459         p_x_line_rec.shipping_instructions := p_old_line_rec.shipping_instructions;
6460     END IF;
6461 
6462     IF p_x_line_rec.packing_instructions = FND_API.G_MISS_CHAR THEN
6463         p_x_line_rec.packing_instructions := p_old_line_rec.packing_instructions;
6464     END IF;
6465 
6466     -- Service Related
6467 
6468     IF p_x_line_rec.service_txn_reason_code = FND_API.G_MISS_CHAR THEN
6469         p_x_line_rec.service_txn_reason_code := p_old_line_rec.service_txn_reason_code;
6470     END IF;
6471 
6472     IF p_x_line_rec.service_txn_comments = FND_API.G_MISS_CHAR THEN
6473         p_x_line_rec.service_txn_comments := p_old_line_rec.service_txn_comments;
6474     END IF;
6475 
6476 
6477     IF p_x_line_rec.service_duration = FND_API.G_MISS_NUM THEN
6478         p_x_line_rec.service_duration := p_old_line_rec.service_duration;
6479     END IF;
6480 
6481     IF p_x_line_rec.service_period = FND_API.G_MISS_CHAR THEN
6482         p_x_line_rec.service_period := p_old_line_rec.service_period;
6483     END IF;
6484 
6485     IF p_x_line_rec.service_start_date = FND_API.G_MISS_DATE THEN
6486         p_x_line_rec.service_start_date := p_old_line_rec.service_start_date;
6487     END IF;
6488 
6489     IF p_x_line_rec.service_end_date = FND_API.G_MISS_DATE THEN
6490         p_x_line_rec.service_end_date := p_old_line_rec.service_end_date;
6491     END IF;
6492 
6493     IF p_x_line_rec.service_coterminate_flag = FND_API.G_MISS_CHAR THEN
6494         p_x_line_rec.service_coterminate_flag := p_old_line_rec.service_coterminate_flag;
6495     END IF;
6496 
6497     IF p_x_line_rec.unit_list_percent = FND_API.G_MISS_NUM THEN
6498         p_x_line_rec.unit_list_percent := p_old_line_rec.unit_list_percent;
6499     END IF;
6500 
6501     IF p_x_line_rec.unit_selling_percent = FND_API.G_MISS_NUM THEN
6502         p_x_line_rec.unit_selling_percent := p_old_line_rec.unit_selling_percent;
6503     END IF;
6504 
6505     IF p_x_line_rec.unit_percent_base_price = FND_API.G_MISS_NUM THEN
6506         p_x_line_rec.unit_percent_base_price := p_old_line_rec.unit_percent_base_price;
6507     END IF;
6508 
6509     IF p_x_line_rec.service_number = FND_API.G_MISS_NUM THEN
6510         p_x_line_rec.service_number := p_old_line_rec.service_number;
6511     END IF;
6512 
6513     IF p_x_line_rec.service_reference_type_code = FND_API.G_MISS_CHAR THEN
6514         p_x_line_rec.service_reference_type_code := p_old_line_rec.service_reference_type_code;
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 := NULL;
6519     END IF;
6520 
6521     IF p_x_line_rec.service_reference_line_id = FND_API.G_MISS_NUM THEN
6522         p_x_line_rec.service_reference_line_id := p_old_line_rec.service_reference_line_id;
6523     END IF;
6524 
6525     IF p_x_line_rec.service_reference_system_id = FND_API.G_MISS_NUM THEN
6526         p_x_line_rec.service_reference_system_id := p_old_line_rec.service_reference_system_id;
6527     END IF;
6528 
6529    -- End of Service related columns
6530 
6531    /* Marketing source code related */
6532 
6533     IF p_x_line_rec.marketing_source_code_id = FND_API.G_MISS_NUM THEN
6534         p_x_line_rec.marketing_source_code_id := p_old_line_rec.marketing_source_code_id;
6535     END IF;
6536 
6537   /* end of Marketing source code id */
6538 
6539     IF p_x_line_rec.flow_status_code = 'ENTERED' THEN
6540        -- flow_status_code is initilized to ENTERED
6541        -- QUOTING change - do not override ENTERED status with old
6542        -- value as status should be set to entered during complete
6543        -- negotiation call
6544        IF OE_Quote_Util.G_COMPLETE_NEG = 'N' THEN
6545           p_x_line_rec.flow_status_code := p_old_line_rec.flow_status_code;
6546        END IF;
6547     END IF;
6548 
6549     -- Commitment related
6550     IF p_x_line_rec.commitment_id = FND_API.G_MISS_NUM THEN
6551        p_x_line_rec.commitment_id := p_old_line_rec.commitment_id;
6552     END IF;
6553 
6554     IF p_x_line_rec.order_source_id = FND_API.G_MISS_NUM THEN
6555    if l_debug_level > 0 then
6556     oe_debug_pub.add('OEXULINB -aksingh complete_record - order_source_id');
6557    end if;
6558         p_x_line_rec.order_source_id := p_old_line_rec.order_source_id;
6559     END IF;
6560 
6561    -- Item Substitution changes.
6562    IF p_x_line_rec.Original_Inventory_Item_Id = FND_API.G_MISS_NUM THEN
6563        p_x_line_rec.Original_Inventory_Item_Id :=
6564                          p_old_line_rec.Original_Inventory_Item_Id;
6565    END IF;
6566 
6567    IF p_x_line_rec.Original_item_identifier_Type = FND_API.G_MISS_CHAR THEN
6568        p_x_line_rec.Original_item_identifier_Type :=
6569                          p_old_line_rec.Original_item_identifier_Type;
6570    END IF;
6571 
6572    IF p_x_line_rec.Original_ordered_item_id = FND_API.G_MISS_NUM THEN
6573        p_x_line_rec.Original_ordered_item_id :=
6574                          p_old_line_rec.Original_ordered_item_id;
6575    END IF;
6576 
6577    IF p_x_line_rec.Original_ordered_item = FND_API.G_MISS_CHAR THEN
6578        p_x_line_rec.Original_ordered_item :=
6579                          p_old_line_rec.Original_ordered_item;
6580    END IF;
6581 
6582    IF p_x_line_rec.item_relationship_type = FND_API.G_MISS_NUM THEN
6583        p_x_line_rec.item_relationship_type :=
6584                          p_old_line_rec.item_relationship_type;
6585    END IF;
6586 
6587    IF p_x_line_rec.Item_substitution_type_code = FND_API.G_MISS_CHAR THEN
6588        p_x_line_rec.Item_substitution_type_code :=
6589                          p_old_line_rec.Item_substitution_type_code;
6590    END IF;
6591 
6592    IF p_x_line_rec.Late_Demand_Penalty_Factor = FND_API.G_MISS_NUM THEN
6593        p_x_line_rec.Late_Demand_Penalty_Factor :=
6594                          p_old_line_rec.Late_Demand_Penalty_Factor;
6595    END IF;
6596 
6597    IF p_x_line_rec.Override_atp_date_code = FND_API.G_MISS_CHAR THEN
6598        p_x_line_rec.Override_atp_date_code :=
6599                          p_old_line_rec.Override_atp_date_code;
6600    END IF;
6601 
6602    -- Changes for Blanket Orders
6603 
6604    IF p_x_line_rec.Blanket_Number = FND_API.G_MISS_NUM THEN
6605       p_x_line_rec.Blanket_Number := p_old_line_rec.Blanket_Number;
6606    END IF;
6607 
6608    IF p_x_line_rec.Blanket_Line_Number = FND_API.G_MISS_NUM THEN
6609       p_x_line_rec.Blanket_Line_Number := p_old_line_rec.Blanket_Line_Number;
6610    END IF;
6611 
6612    IF p_x_line_rec.Blanket_Version_Number = FND_API.G_MISS_NUM THEN
6613       p_x_line_rec.Blanket_Version_Number := p_old_line_rec.Blanket_Version_Number;
6614    END IF;
6615 
6616    -- bug 2589332
6617    IF p_x_line_rec.User_Item_Description = FND_API.G_MISS_CHAR THEN
6618       p_x_line_rec.User_Item_Description := p_old_line_rec.User_Item_Description;
6619    END IF;
6620 
6621    -- QUOTING changes
6622    IF p_x_line_rec.transaction_phase_code = FND_API.G_MISS_CHAR THEN
6623        p_x_line_rec.transaction_phase_code :=
6624                          p_old_line_rec.transaction_phase_code;
6625    END IF;
6626 
6627    IF p_x_line_rec.source_document_version_number = FND_API.G_MISS_NUM THEN
6628        p_x_line_rec.source_document_version_number :=
6629                          p_old_line_rec.source_document_version_number;
6630    END IF;
6631    -- END QUOTING changes
6632     IF p_x_line_rec.Minisite_Id = FND_API.G_MISS_NUM THEN
6633         p_x_line_rec.Minisite_Id := p_old_line_rec.Minisite_Id;
6634     END IF;
6635 
6636     IF p_x_line_rec.End_customer_Id = FND_API.G_MISS_NUM THEN
6637         p_x_line_rec.End_customer_Id := p_old_line_rec.End_customer_Id;
6638     END IF;
6639 
6640     IF p_x_line_rec.End_customer_contact_Id = FND_API.G_MISS_NUM THEN
6641         p_x_line_rec.End_customer_contact_Id := p_old_line_rec.End_customer_contact_Id;
6642     END IF;
6643 
6644     IF p_x_line_rec.End_customer_site_use_Id = FND_API.G_MISS_NUM THEN
6645         p_x_line_rec.End_customer_site_use_Id := p_old_line_rec.End_customer_site_use_Id;
6646     END IF;
6647 
6648     IF p_x_line_rec.ib_owner = FND_API.G_MISS_CHAR THEN
6649         p_x_line_rec.ib_owner := p_old_line_rec.ib_owner;
6650     END IF;
6651 
6652     IF p_x_line_rec.ib_installed_at_location = FND_API.G_MISS_CHAR THEN
6653         p_x_line_rec.ib_installed_at_location := p_old_line_rec.ib_installed_at_location;
6654     END IF;
6655 
6656     IF p_x_line_rec.ib_current_location = FND_API.G_MISS_CHAR THEN
6657         p_x_line_rec.ib_current_location := p_old_line_rec.ib_current_location;
6658     END IF;
6659 
6660     IF p_x_line_rec.supplier_signature = FND_API.G_MISS_CHAR THEN
6661         p_x_line_rec.supplier_signature := p_old_line_rec.supplier_signature;
6662     END IF;
6663 
6664     --retro{
6665     IF p_x_line_rec.retrobill_request_id = FND_API.G_MISS_NUM THEN
6666         p_x_line_rec.retrobill_request_id :=
6667                          p_old_line_rec.retrobill_request_id;
6668     END IF;
6669 
6670     --retro}
6671 
6672     IF p_x_line_rec.firm_demand_flag = FND_API.G_MISS_CHAR THEN
6673         p_x_line_rec.firm_demand_flag := p_old_line_rec.firm_demand_flag;
6674     END IF;
6675 
6676 --key Transaction Dates Project
6677     IF p_x_line_rec.order_firmed_date = FND_API.G_MISS_DATE THEN
6678         p_x_line_rec.order_firmed_date := p_old_line_rec.order_firmed_date;
6679     END IF;
6680 
6681     IF p_x_line_rec.actual_fulfillment_date = FND_API.G_MISS_DATE THEN
6682         p_x_line_rec.actual_fulfillment_date := p_old_line_rec.actual_fulfillment_date;
6683     END IF;
6684 
6685 --end
6686 
6687 
6688 -- INVCONV OPM inventory convergence
6689 	  IF p_x_line_rec.fulfilled_quantity2 = FND_API.G_MISS_NUM THEN
6690         p_x_line_rec.fulfilled_quantity2 := p_old_line_rec.fulfilled_quantity2;
6691     END IF;
6692 		IF p_x_line_rec.cancelled_quantity2 = FND_API.G_MISS_NUM THEN
6693         p_x_line_rec.cancelled_quantity2 := p_old_line_rec.cancelled_quantity2;
6694     END IF;
6695  		IF p_x_line_rec.shipping_quantity_uom2 = FND_API.G_MISS_CHAR THEN
6696         p_x_line_rec.shipping_quantity_uom2 := p_old_line_rec.shipping_quantity_uom2;
6697     END IF;
6698 
6699 
6700     IF p_x_line_rec.reserved_quantity2 = FND_API.G_MISS_NUM THEN
6701            p_x_line_rec.reserved_quantity2 := p_old_line_rec.reserved_quantity2;  -- bug 4889860
6702     END IF;
6703 
6704 
6705 -- INVCONV end
6706 
6707 
6708 /*  IF p_x_line_rec.supplier_signature_date = FND_API.G_MISS_DATE THEN
6709         p_x_line_rec.supplier_signature_date := p_old_line_rec.supplier_signature_date;
6710     END IF;
6711 
6712   IF p_x_line_rec.customer_signature = FND_API.G_MISS_CHAR THEN
6713         p_x_line_rec.customer_signature := p_old_line_rec.customer_signature;
6714     END IF;
6715 
6716   IF p_x_line_rec.customer_signature_date = FND_API.G_MISS_DATE THEN
6717         p_x_line_rec.customer_signature_date := p_old_line_rec.customer_signature_date;
6718     END IF;
6719 
6720 */
6721 
6722  IF p_x_line_rec.customer_item_net_price = FND_API.G_MISS_NUM THEN
6723       p_x_line_rec.customer_item_net_price := p_old_line_rec.customer_item_net_price; -- 5465342
6724    END IF;
6725 
6726 
6727 if l_debug_level > 0 then
6728     oe_debug_pub.add('Exiting OE_LINE_UTIL.COMPLETE_RECORD', 1);
6729   end if;
6730 
6731 END Complete_Record;
6732 
6733 
6734 
6735 /*-----------------------------------------------------------
6736 PROCEDURE Convert_Miss_To_Null
6737 -----------------------------------------------------------*/
6738 
6739 PROCEDURE Convert_Miss_To_Null
6740 (   p_x_line_rec                    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
6741 )
6742 IS
6743 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6744 BEGIN
6745 
6746   if l_debug_level > 0 then
6747     oe_debug_pub.add('Entering OE_LINE_UTIL.CONVERT_MISS_TO_NULL', 1);
6748 
6749 oe_debug_pub.add('outside margin convert miss to null',1);
6750   end if;
6751 --MRG BGN
6752 IF OE_FEATURES_PVT.Is_Margin_Avail Then
6753   if l_debug_level > 0 then
6754    oe_debug_pub.add('inside margin convert miss to null',1);
6755   end if;
6756     IF p_x_line_rec.unit_cost = FND_API.G_MISS_NUM THEN
6757         p_x_line_rec.unit_cost := NULL;
6758     END IF;
6759 END IF;
6760 --MRG END
6761 
6762 
6763     IF p_x_line_rec.accounting_rule_id = FND_API.G_MISS_NUM THEN
6764         p_x_line_rec.accounting_rule_id := NULL;
6765     END IF;
6766 
6767     IF p_x_line_rec.accounting_rule_duration = FND_API.G_MISS_NUM THEN
6768         p_x_line_rec.accounting_rule_duration := NULL;
6769     END IF;
6770 
6771     IF p_x_line_rec.actual_arrival_date = FND_API.G_MISS_DATE THEN
6772         p_x_line_rec.actual_arrival_date := NULL;
6773     END IF;
6774 
6775     IF p_x_line_rec.actual_shipment_date = FND_API.G_MISS_DATE THEN
6776         p_x_line_rec.actual_shipment_date := NULL;
6777     END IF;
6778 
6779     IF p_x_line_rec.agreement_id = FND_API.G_MISS_NUM THEN
6780         p_x_line_rec.agreement_id := NULL;
6781     END IF;
6782     IF p_x_line_rec.arrival_set_id = FND_API.G_MISS_NUM THEN
6783         p_x_line_rec.arrival_set_id := NULL;
6784     END IF;
6785 
6786     IF p_x_line_rec.ato_line_id = FND_API.G_MISS_NUM THEN
6787         p_x_line_rec.ato_line_id := NULL;
6788     END IF;
6789     IF p_x_line_rec.upgraded_flag = FND_API.G_MISS_CHAR THEN
6790         p_x_line_rec.upgraded_flag := NULL;
6791     END IF;
6792 
6793     IF p_x_line_rec.attribute1 = FND_API.G_MISS_CHAR THEN
6794         p_x_line_rec.attribute1 := NULL;
6795     END IF;
6796 
6797     IF p_x_line_rec.attribute10 = FND_API.G_MISS_CHAR THEN
6798         p_x_line_rec.attribute10 := NULL;
6799     END IF;
6800 
6801     IF p_x_line_rec.attribute11 = FND_API.G_MISS_CHAR THEN
6802         p_x_line_rec.attribute11 := NULL;
6803     END IF;
6804 
6805     IF p_x_line_rec.attribute12 = FND_API.G_MISS_CHAR THEN
6806         p_x_line_rec.attribute12 := NULL;
6807     END IF;
6808 
6809     IF p_x_line_rec.attribute13 = FND_API.G_MISS_CHAR THEN
6810         p_x_line_rec.attribute13 := NULL;
6811     END IF;
6812 
6813     IF p_x_line_rec.attribute14 = FND_API.G_MISS_CHAR THEN
6814         p_x_line_rec.attribute14 := NULL;
6815     END IF;
6816 
6817     IF p_x_line_rec.attribute15 = FND_API.G_MISS_CHAR THEN
6818         p_x_line_rec.attribute15 := NULL;
6819     END IF;
6820 
6821     IF p_x_line_rec.attribute16 = FND_API.G_MISS_CHAR THEN    --For bug 2184255
6822         p_x_line_rec.attribute16 := NULL;
6823     END IF;
6824 
6825     IF p_x_line_rec.attribute17 = FND_API.G_MISS_CHAR THEN
6826         p_x_line_rec.attribute17 := NULL;
6827     END IF;
6828 
6829     IF p_x_line_rec.attribute18 = FND_API.G_MISS_CHAR THEN
6830         p_x_line_rec.attribute18 := NULL;
6831     END IF;
6832 
6833     IF p_x_line_rec.attribute19 = FND_API.G_MISS_CHAR THEN
6834         p_x_line_rec.attribute19 := NULL;
6835     END IF;
6836 
6837     IF p_x_line_rec.attribute2 = FND_API.G_MISS_CHAR THEN
6838         p_x_line_rec.attribute2 := NULL;
6839     END IF;
6840 
6841     IF p_x_line_rec.attribute20 = FND_API.G_MISS_CHAR THEN
6842         p_x_line_rec.attribute20 := NULL;
6843     END IF;
6844 
6845     IF p_x_line_rec.attribute3 = FND_API.G_MISS_CHAR THEN
6846         p_x_line_rec.attribute3 := NULL;
6847     END IF;
6848 
6849     IF p_x_line_rec.attribute4 = FND_API.G_MISS_CHAR THEN
6850         p_x_line_rec.attribute4 := NULL;
6851     END IF;
6852 
6853     IF p_x_line_rec.attribute5 = FND_API.G_MISS_CHAR THEN
6854         p_x_line_rec.attribute5 := NULL;
6855     END IF;
6856 
6857     IF p_x_line_rec.attribute6 = FND_API.G_MISS_CHAR THEN
6858         p_x_line_rec.attribute6 := NULL;
6859     END IF;
6860 
6861     IF p_x_line_rec.attribute7 = FND_API.G_MISS_CHAR THEN
6862         p_x_line_rec.attribute7 := NULL;
6863     END IF;
6864 
6865     IF p_x_line_rec.attribute8 = FND_API.G_MISS_CHAR THEN
6866         p_x_line_rec.attribute8 := NULL;
6867     END IF;
6868 
6869     IF p_x_line_rec.attribute9 = FND_API.G_MISS_CHAR THEN
6870         p_x_line_rec.attribute9 := NULL;
6871     END IF;
6872 
6873     IF p_x_line_rec.auto_selected_quantity = FND_API.G_MISS_NUM THEN
6874         p_x_line_rec.auto_selected_quantity := NULL;
6875     END IF;
6876      IF p_x_line_rec.authorized_to_ship_flag = FND_API.G_MISS_CHAR THEN
6877         p_x_line_rec.authorized_to_ship_flag := NULL;
6878     END IF;
6879 
6880     IF p_x_line_rec.booked_flag = FND_API.G_MISS_CHAR THEN
6881         p_x_line_rec.booked_flag := NULL;
6882     END IF;
6883 
6884     IF p_x_line_rec.cancelled_flag = FND_API.G_MISS_CHAR THEN
6885         p_x_line_rec.cancelled_flag := NULL;
6886     END IF;
6887 
6888     IF p_x_line_rec.cancelled_quantity = FND_API.G_MISS_NUM THEN
6889         p_x_line_rec.cancelled_quantity := NULL;
6890     END IF;
6891 
6892     IF p_x_line_rec.component_code = FND_API.G_MISS_CHAR THEN
6893         p_x_line_rec.component_code := NULL;
6894     END IF;
6895 
6896     IF p_x_line_rec.component_number = FND_API.G_MISS_NUM THEN
6897         p_x_line_rec.component_number := NULL;
6898     END IF;
6899 
6900     IF p_x_line_rec.component_sequence_id = FND_API.G_MISS_NUM THEN
6901         p_x_line_rec.component_sequence_id := NULL;
6902     END IF;
6903 
6904     IF p_x_line_rec.config_header_id = FND_API.G_MISS_NUM THEN
6905         p_x_line_rec.config_header_id := NULL;
6906     END IF;
6907 
6908     IF p_x_line_rec.config_rev_nbr = FND_API.G_MISS_NUM THEN
6909         p_x_line_rec.config_rev_nbr := NULL;
6910     END IF;
6911 
6912     IF p_x_line_rec.config_display_sequence = FND_API.G_MISS_NUM THEN
6913         p_x_line_rec.config_display_sequence := NULL;
6914     END IF;
6915 
6916     IF p_x_line_rec.configuration_id = FND_API.G_MISS_NUM THEN
6917         p_x_line_rec.configuration_id := NULL;
6918     END IF;
6919 
6920     IF p_x_line_rec.context = FND_API.G_MISS_CHAR THEN
6921         p_x_line_rec.context := NULL;
6922     END IF;
6923     --recurring charges
6924     IF p_x_line_rec.charge_periodicity_code = FND_API.G_MISS_CHAR THEN
6925        p_x_line_rec.charge_periodicity_code := NULL;
6926     END IF;
6927 
6928     --Customer Acceptance
6929      IF p_x_line_rec.CONTINGENCY_ID  = FND_API.G_MISS_NUM THEN
6930         p_x_line_rec.CONTINGENCY_ID  := NULL  ;
6931     END IF;
6932      IF p_x_line_rec.REVREC_EVENT_CODE = FND_API.G_MISS_CHAR THEN
6933         p_x_line_rec.REVREC_EVENT_CODE:= NULL  ;
6934     END IF;
6935      IF p_x_line_rec.REVREC_EXPIRATION_DAYS = FND_API.G_MISS_NUM THEN
6936         p_x_line_rec.REVREC_EXPIRATION_DAYS:= NULL  ;
6937     END IF;
6938      IF p_x_line_rec.ACCEPTED_QUANTITY = FND_API.G_MISS_NUM THEN
6939         p_x_line_rec.ACCEPTED_QUANTITY:= NULL  ;
6940     END IF;
6941      IF p_x_line_rec.REVREC_COMMENTS = FND_API.G_MISS_CHAR THEN
6942         p_x_line_rec.REVREC_COMMENTS:= NULL  ;
6943     END IF;
6944      IF p_x_line_rec.REVREC_SIGNATURE = FND_API.G_MISS_CHAR THEN
6945         p_x_line_rec.REVREC_SIGNATURE:= NULL  ;
6946     END IF;
6947      IF p_x_line_rec.REVREC_SIGNATURE_DATE = FND_API.G_MISS_DATE THEN
6948         p_x_line_rec.REVREC_SIGNATURE_DATE:= NULL  ;
6949     END IF;
6950      IF p_x_line_rec.ACCEPTED_BY = FND_API.G_MISS_NUM THEN
6951         p_x_line_rec.ACCEPTED_BY:= NULL  ;
6952     END IF;
6953      IF p_x_line_rec.REVREC_REFERENCE_DOCUMENT = FND_API.G_MISS_CHAR THEN
6954         p_x_line_rec.REVREC_REFERENCE_DOCUMENT:= NULL  ;
6955     END IF;
6956      IF p_x_line_rec.REVREC_IMPLICIT_FLAG = FND_API.G_MISS_CHAR THEN
6957         p_x_line_rec.REVREC_IMPLICIT_FLAG:= NULL  ;
6958     END IF;
6959    --Customer Acceptance Changes End
6960 
6961     IF p_x_line_rec.created_by = FND_API.G_MISS_NUM THEN
6962         p_x_line_rec.created_by := NULL;
6963     END IF;
6964 
6965     IF p_x_line_rec.creation_date = FND_API.G_MISS_DATE THEN
6966         p_x_line_rec.creation_date := NULL;
6967     END IF;
6968 
6969     IF p_x_line_rec.credit_invoice_line_id = FND_API.G_MISS_NUM THEN
6970         p_x_line_rec.credit_invoice_line_id := NULL;
6971     END IF;
6972 
6973     IF p_x_line_rec.customer_dock_code = FND_API.G_MISS_CHAR THEN
6974         p_x_line_rec.customer_dock_code := NULL;
6975     END IF;
6976 
6977     IF p_x_line_rec.customer_job = FND_API.G_MISS_CHAR THEN
6978         p_x_line_rec.customer_job := NULL;
6979     END IF;
6980 
6981     IF p_x_line_rec.customer_production_line = FND_API.G_MISS_CHAR THEN
6982         p_x_line_rec.customer_production_line := NULL;
6983     END IF;
6984 
6985     IF p_x_line_rec.cust_production_seq_num = FND_API.G_MISS_CHAR THEN
6986         p_x_line_rec.cust_production_seq_num := NULL;
6987     END IF;
6988 
6989     IF p_x_line_rec.customer_trx_line_id = FND_API.G_MISS_NUM THEN
6990         p_x_line_rec.customer_trx_line_id := NULL;
6991     END IF;
6992 
6993     IF p_x_line_rec.cust_model_serial_number = FND_API.G_MISS_CHAR THEN
6994         p_x_line_rec.cust_model_serial_number := NULL;
6995     END IF;
6996 
6997     IF p_x_line_rec.cust_po_number = FND_API.G_MISS_CHAR THEN
6998         p_x_line_rec.cust_po_number := NULL;
6999     END IF;
7000 
7001     IF p_x_line_rec.customer_line_number = FND_API.G_MISS_CHAR THEN
7002         p_x_line_rec.customer_line_number := NULL;
7003     END IF;
7004 
7005     IF p_x_line_rec.customer_shipment_number = FND_API.G_MISS_CHAR THEN
7006         p_x_line_rec.customer_shipment_number := NULL;
7007     END IF;
7008 
7009     IF p_x_line_rec.delivery_lead_time = FND_API.G_MISS_NUM THEN
7010         p_x_line_rec.delivery_lead_time := NULL;
7011     END IF;
7012 
7013     IF p_x_line_rec.deliver_to_contact_id = FND_API.G_MISS_NUM THEN
7014         p_x_line_rec.deliver_to_contact_id := NULL;
7015     END IF;
7016 
7017     IF p_x_line_rec.deliver_to_org_id = FND_API.G_MISS_NUM THEN
7018         p_x_line_rec.deliver_to_org_id := NULL;
7019     END IF;
7020 
7021     IF p_x_line_rec.demand_bucket_type_code = FND_API.G_MISS_CHAR THEN
7022         p_x_line_rec.demand_bucket_type_code := NULL;
7023     END IF;
7024 
7025     IF p_x_line_rec.demand_class_code = FND_API.G_MISS_CHAR THEN
7026         p_x_line_rec.demand_class_code := NULL;
7027     END IF;
7028 
7029     IF p_x_line_rec.dep_plan_required_flag = FND_API.G_MISS_CHAR THEN
7030         p_x_line_rec.dep_plan_required_flag := NULL;
7031     END IF;
7032 
7033 
7034     IF p_x_line_rec.earliest_acceptable_date = FND_API.G_MISS_DATE THEN
7035         p_x_line_rec.earliest_acceptable_date := NULL;
7036     END IF;
7037 
7038     IF p_x_line_rec.explosion_date = FND_API.G_MISS_DATE THEN
7039         p_x_line_rec.explosion_date := NULL;
7040     END IF;
7041 
7042     IF p_x_line_rec.fob_point_code = FND_API.G_MISS_CHAR THEN
7043         p_x_line_rec.fob_point_code := NULL;
7044     END IF;
7045 
7046     IF p_x_line_rec.freight_carrier_code = FND_API.G_MISS_CHAR THEN
7047         p_x_line_rec.freight_carrier_code := NULL;
7048     END IF;
7049 
7050     IF p_x_line_rec.freight_terms_code = FND_API.G_MISS_CHAR THEN
7051         p_x_line_rec.freight_terms_code := NULL;
7052     END IF;
7053 
7054     IF p_x_line_rec.fulfilled_quantity = FND_API.G_MISS_NUM THEN
7055         p_x_line_rec.fulfilled_quantity := NULL;
7056     END IF;
7057 
7058     IF p_x_line_rec.fulfilled_flag = FND_API.G_MISS_CHAR THEN
7059         p_x_line_rec.fulfilled_flag := NULL;
7060     END IF;
7061 
7062     IF p_x_line_rec.fulfillment_method_code = FND_API.G_MISS_CHAR THEN
7063         p_x_line_rec.fulfillment_method_code := NULL;
7064     END IF;
7065 
7066     IF p_x_line_rec.fulfillment_date = FND_API.G_MISS_DATE THEN
7067         p_x_line_rec.fulfillment_date := NULL;
7068     END IF;
7069 
7070     IF p_x_line_rec.global_attribute1 = FND_API.G_MISS_CHAR THEN
7071         p_x_line_rec.global_attribute1 := NULL;
7072     END IF;
7073 
7074     IF p_x_line_rec.global_attribute10 = FND_API.G_MISS_CHAR THEN
7075         p_x_line_rec.global_attribute10 := NULL;
7076     END IF;
7077 
7078     IF p_x_line_rec.global_attribute11 = FND_API.G_MISS_CHAR THEN
7079         p_x_line_rec.global_attribute11 := NULL;
7080     END IF;
7081 
7082     IF p_x_line_rec.global_attribute12 = FND_API.G_MISS_CHAR THEN
7083         p_x_line_rec.global_attribute12 := NULL;
7084     END IF;
7085 
7086     IF p_x_line_rec.global_attribute13 = FND_API.G_MISS_CHAR THEN
7087         p_x_line_rec.global_attribute13 := NULL;
7088     END IF;
7089 
7090     IF p_x_line_rec.global_attribute14 = FND_API.G_MISS_CHAR THEN
7091         p_x_line_rec.global_attribute14 := NULL;
7092     END IF;
7093 
7094     IF p_x_line_rec.global_attribute15 = FND_API.G_MISS_CHAR THEN
7095         p_x_line_rec.global_attribute15 := NULL;
7096     END IF;
7097 
7098     IF p_x_line_rec.global_attribute16 = FND_API.G_MISS_CHAR THEN
7099         p_x_line_rec.global_attribute16 := NULL;
7100     END IF;
7101 
7102     IF p_x_line_rec.global_attribute17 = FND_API.G_MISS_CHAR THEN
7103         p_x_line_rec.global_attribute17 := NULL;
7104     END IF;
7105 
7106     IF p_x_line_rec.global_attribute18 = FND_API.G_MISS_CHAR THEN
7107         p_x_line_rec.global_attribute18 := NULL;
7108     END IF;
7109 
7110     IF p_x_line_rec.global_attribute19 = FND_API.G_MISS_CHAR THEN
7111         p_x_line_rec.global_attribute19 := NULL;
7112     END IF;
7113 
7114     IF p_x_line_rec.global_attribute2 = FND_API.G_MISS_CHAR THEN
7115         p_x_line_rec.global_attribute2 := NULL;
7116     END IF;
7117 
7118     IF p_x_line_rec.global_attribute20 = FND_API.G_MISS_CHAR THEN
7119         p_x_line_rec.global_attribute20 := NULL;
7120     END IF;
7121 
7122     IF p_x_line_rec.global_attribute3 = FND_API.G_MISS_CHAR THEN
7123         p_x_line_rec.global_attribute3 := NULL;
7124     END IF;
7125 
7126     IF p_x_line_rec.global_attribute4 = FND_API.G_MISS_CHAR THEN
7127         p_x_line_rec.global_attribute4 := NULL;
7128     END IF;
7129 
7130     IF p_x_line_rec.global_attribute5 = FND_API.G_MISS_CHAR THEN
7131         p_x_line_rec.global_attribute5 := NULL;
7132     END IF;
7133 
7134     IF p_x_line_rec.global_attribute6 = FND_API.G_MISS_CHAR THEN
7135         p_x_line_rec.global_attribute6 := NULL;
7136     END IF;
7137 
7138     IF p_x_line_rec.global_attribute7 = FND_API.G_MISS_CHAR THEN
7139         p_x_line_rec.global_attribute7 := NULL;
7140     END IF;
7141 
7142     IF p_x_line_rec.global_attribute8 = FND_API.G_MISS_CHAR THEN
7143         p_x_line_rec.global_attribute8 := NULL;
7144     END IF;
7145 
7146     IF p_x_line_rec.global_attribute9 = FND_API.G_MISS_CHAR THEN
7147         p_x_line_rec.global_attribute9 := NULL;
7148     END IF;
7149 
7150     IF p_x_line_rec.global_attribute_category = FND_API.G_MISS_CHAR THEN
7151         p_x_line_rec.global_attribute_category := NULL;
7152     END IF;
7153 
7154     IF p_x_line_rec.header_id = FND_API.G_MISS_NUM THEN
7155         p_x_line_rec.header_id := NULL;
7156     END IF;
7157 
7158     IF p_x_line_rec.industry_attribute1 = FND_API.G_MISS_CHAR THEN
7159         p_x_line_rec.industry_attribute1 := NULL;
7160     END IF;
7161 
7162     IF p_x_line_rec.industry_attribute10 = FND_API.G_MISS_CHAR THEN
7163         p_x_line_rec.industry_attribute10 := NULL;
7164     END IF;
7165 
7166     IF p_x_line_rec.industry_attribute11 = FND_API.G_MISS_CHAR THEN
7167         p_x_line_rec.industry_attribute11 := NULL;
7168     END IF;
7169 
7170     IF p_x_line_rec.industry_attribute12 = FND_API.G_MISS_CHAR THEN
7171         p_x_line_rec.industry_attribute12 := NULL;
7172     END IF;
7173 
7174     IF p_x_line_rec.industry_attribute13 = FND_API.G_MISS_CHAR THEN
7175         p_x_line_rec.industry_attribute13 := NULL;
7176     END IF;
7177 
7178     IF p_x_line_rec.industry_attribute14 = FND_API.G_MISS_CHAR THEN
7179         p_x_line_rec.industry_attribute14 := NULL;
7180     END IF;
7181 
7182     IF p_x_line_rec.industry_attribute15 = FND_API.G_MISS_CHAR THEN
7183         p_x_line_rec.industry_attribute15 := NULL;
7184     END IF;
7185 
7186 IF p_x_line_rec.industry_attribute16 = FND_API.G_MISS_CHAR THEN
7187         p_x_line_rec.industry_attribute16 := NULL;
7188     END IF;
7189 IF p_x_line_rec.industry_attribute17 = FND_API.G_MISS_CHAR THEN
7190         p_x_line_rec.industry_attribute17 := NULL;
7191     END IF;
7192 IF p_x_line_rec.industry_attribute18 = FND_API.G_MISS_CHAR THEN
7193         p_x_line_rec.industry_attribute18 := NULL;
7194     END IF;
7195 IF p_x_line_rec.industry_attribute19 = FND_API.G_MISS_CHAR THEN
7196         p_x_line_rec.industry_attribute19 := NULL;
7197     END IF;
7198 IF p_x_line_rec.industry_attribute20 = FND_API.G_MISS_CHAR THEN
7199         p_x_line_rec.industry_attribute20 := NULL;
7200     END IF;
7201 IF p_x_line_rec.industry_attribute21 = FND_API.G_MISS_CHAR THEN
7202         p_x_line_rec.industry_attribute21 := NULL;
7203     END IF;
7204 IF p_x_line_rec.industry_attribute22 = FND_API.G_MISS_CHAR THEN
7205         p_x_line_rec.industry_attribute22 := NULL;
7206     END IF;
7207 IF p_x_line_rec.industry_attribute23 = FND_API.G_MISS_CHAR THEN
7208         p_x_line_rec.industry_attribute23 := NULL;
7209     END IF;
7210 IF p_x_line_rec.industry_attribute24 = FND_API.G_MISS_CHAR THEN
7211         p_x_line_rec.industry_attribute24 := NULL;
7212     END IF;
7213 IF p_x_line_rec.industry_attribute25 = FND_API.G_MISS_CHAR THEN
7214         p_x_line_rec.industry_attribute25 := NULL;
7215     END IF;
7216 IF p_x_line_rec.industry_attribute26 = FND_API.G_MISS_CHAR THEN
7217         p_x_line_rec.industry_attribute26 := NULL;
7218     END IF;
7219 IF p_x_line_rec.industry_attribute27 = FND_API.G_MISS_CHAR THEN
7220         p_x_line_rec.industry_attribute27 := NULL;
7221     END IF;
7222 IF p_x_line_rec.industry_attribute28 = FND_API.G_MISS_CHAR THEN
7223         p_x_line_rec.industry_attribute28 := NULL;
7224     END IF;
7225  IF p_x_line_rec.industry_attribute29 = FND_API.G_MISS_CHAR THEN
7226         p_x_line_rec.industry_attribute29 := NULL;
7227     END IF;
7228 IF p_x_line_rec.industry_attribute30 = FND_API.G_MISS_CHAR THEN
7229         p_x_line_rec.industry_attribute30 := NULL;
7230     END IF;
7231 
7232 
7233     IF p_x_line_rec.industry_attribute2 = FND_API.G_MISS_CHAR THEN
7234         p_x_line_rec.industry_attribute2 := NULL;
7235     END IF;
7236 
7237     IF p_x_line_rec.industry_attribute3 = FND_API.G_MISS_CHAR THEN
7238         p_x_line_rec.industry_attribute3 := NULL;
7239     END IF;
7240 
7241     IF p_x_line_rec.industry_attribute4 = FND_API.G_MISS_CHAR THEN
7242         p_x_line_rec.industry_attribute4 := NULL;
7243     END IF;
7244 
7245     IF p_x_line_rec.industry_attribute5 = FND_API.G_MISS_CHAR THEN
7246         p_x_line_rec.industry_attribute5 := NULL;
7247     END IF;
7248 
7249     IF p_x_line_rec.industry_attribute6 = FND_API.G_MISS_CHAR THEN
7250         p_x_line_rec.industry_attribute6 := NULL;
7251     END IF;
7252 
7253     IF p_x_line_rec.industry_attribute7 = FND_API.G_MISS_CHAR THEN
7254         p_x_line_rec.industry_attribute7 := NULL;
7255     END IF;
7256 
7257     IF p_x_line_rec.industry_attribute8 = FND_API.G_MISS_CHAR THEN
7258         p_x_line_rec.industry_attribute8 := NULL;
7259     END IF;
7260 
7261     IF p_x_line_rec.industry_attribute9 = FND_API.G_MISS_CHAR THEN
7262         p_x_line_rec.industry_attribute9 := NULL;
7263     END IF;
7264 
7265     IF p_x_line_rec.industry_context = FND_API.G_MISS_CHAR THEN
7266         p_x_line_rec.industry_context := NULL;
7267     END IF;
7268 
7269     /* TP_ATTRIBUTE */
7270     IF p_x_line_rec.tp_context = FND_API.G_MISS_CHAR THEN
7271         p_x_line_rec.tp_context := NULL;
7272     END IF;
7273     IF p_x_line_rec.tp_attribute1 = FND_API.G_MISS_CHAR THEN
7274         p_x_line_rec.tp_attribute1 := NULL;
7275     END IF;
7276     IF p_x_line_rec.tp_attribute2 = FND_API.G_MISS_CHAR THEN
7277         p_x_line_rec.tp_attribute2 := NULL;
7278     END IF;
7279     IF p_x_line_rec.tp_attribute3 = FND_API.G_MISS_CHAR THEN
7280         p_x_line_rec.tp_attribute3 := NULL;
7281     END IF;
7282     IF p_x_line_rec.tp_attribute4 = FND_API.G_MISS_CHAR THEN
7283         p_x_line_rec.tp_attribute4 := NULL;
7284     END IF;
7285     IF p_x_line_rec.tp_attribute5 = FND_API.G_MISS_CHAR THEN
7286         p_x_line_rec.tp_attribute5 := NULL;
7287     END IF;
7288     IF p_x_line_rec.tp_attribute6 = FND_API.G_MISS_CHAR THEN
7289         p_x_line_rec.tp_attribute6 := NULL;
7290     END IF;
7291     IF p_x_line_rec.tp_attribute7 = FND_API.G_MISS_CHAR THEN
7292         p_x_line_rec.tp_attribute7 := NULL;
7293     END IF;
7294     IF p_x_line_rec.tp_attribute8 = FND_API.G_MISS_CHAR THEN
7295         p_x_line_rec.tp_attribute8 := NULL;
7296     END IF;
7297     IF p_x_line_rec.tp_attribute9 = FND_API.G_MISS_CHAR THEN
7298         p_x_line_rec.tp_attribute9 := NULL;
7299     END IF;
7300     IF p_x_line_rec.tp_attribute10 = FND_API.G_MISS_CHAR THEN
7301         p_x_line_rec.tp_attribute10 := NULL;
7302     END IF;
7303     IF p_x_line_rec.tp_attribute11 = FND_API.G_MISS_CHAR THEN
7304         p_x_line_rec.tp_attribute11 := NULL;
7305     END IF;
7306     IF p_x_line_rec.tp_attribute12 = FND_API.G_MISS_CHAR THEN
7307         p_x_line_rec.tp_attribute12 := NULL;
7308     END IF;
7309     IF p_x_line_rec.tp_attribute13 = FND_API.G_MISS_CHAR THEN
7310         p_x_line_rec.tp_attribute13 := NULL;
7311     END IF;
7312     IF p_x_line_rec.tp_attribute14 = FND_API.G_MISS_CHAR THEN
7313         p_x_line_rec.tp_attribute14 := NULL;
7314     END IF;
7315     IF p_x_line_rec.tp_attribute15 = FND_API.G_MISS_CHAR THEN
7316         p_x_line_rec.tp_attribute15 := NULL;
7317     END IF;
7318 
7319 
7320     IF p_x_line_rec.intermed_ship_to_contact_id = FND_API.G_MISS_NUM THEN
7321         p_x_line_rec.intermed_ship_to_contact_id := NULL;
7322     END IF;
7323 
7324     IF p_x_line_rec.intermed_ship_to_org_id = FND_API.G_MISS_NUM THEN
7325         p_x_line_rec.intermed_ship_to_org_id := NULL;
7326     END IF;
7327 
7328     IF p_x_line_rec.inventory_item_id = FND_API.G_MISS_NUM THEN
7329         p_x_line_rec.inventory_item_id := NULL;
7330     END IF;
7331 
7332     IF p_x_line_rec.invoice_interface_status_code = FND_API.G_MISS_CHAR THEN
7333         p_x_line_rec.invoice_interface_status_code := NULL;
7334     END IF;
7335 
7336 
7337 
7338     IF p_x_line_rec.invoice_to_contact_id = FND_API.G_MISS_NUM THEN
7339         p_x_line_rec.invoice_to_contact_id := NULL;
7340     END IF;
7341 
7342     IF p_x_line_rec.invoiced_quantity = FND_API.G_MISS_NUM THEN
7343         p_x_line_rec.invoiced_quantity := NULL;
7344     END IF;
7345 
7346     IF p_x_line_rec.invoice_to_org_id = FND_API.G_MISS_NUM THEN
7347         p_x_line_rec.invoice_to_org_id := NULL;
7348     END IF;
7349 
7350     IF p_x_line_rec.invoicing_rule_id = FND_API.G_MISS_NUM THEN
7351         p_x_line_rec.invoicing_rule_id := NULL;
7352     END IF;
7353 
7354     IF p_x_line_rec.ordered_item_id = FND_API.G_MISS_NUM THEN
7355         p_x_line_rec.ordered_item_id := NULL;
7356     END IF;
7357 
7358     IF p_x_line_rec.item_identifier_type = FND_API.G_MISS_CHAR THEN
7359         p_x_line_rec.item_identifier_type := NULL;
7360     END IF;
7361 
7362     IF p_x_line_rec.ordered_item = FND_API.G_MISS_CHAR THEN
7363         p_x_line_rec.ordered_item := NULL;
7364     END IF;
7365 
7366     IF p_x_line_rec.item_revision = FND_API.G_MISS_CHAR THEN
7367         p_x_line_rec.item_revision := NULL;
7368     END IF;
7369 
7370     IF p_x_line_rec.item_type_code = FND_API.G_MISS_CHAR THEN
7371         p_x_line_rec.item_type_code := NULL;
7372     END IF;
7373 
7374     IF p_x_line_rec.last_updated_by = FND_API.G_MISS_NUM THEN
7375         p_x_line_rec.last_updated_by := NULL;
7376     END IF;
7377 
7378     IF p_x_line_rec.last_update_date = FND_API.G_MISS_DATE THEN
7379         p_x_line_rec.last_update_date := NULL;
7380     END IF;
7381 
7382     IF p_x_line_rec.last_update_login = FND_API.G_MISS_NUM THEN
7383         p_x_line_rec.last_update_login := NULL;
7384     END IF;
7385 
7386     IF p_x_line_rec.latest_acceptable_date = FND_API.G_MISS_DATE THEN
7387         p_x_line_rec.latest_acceptable_date := NULL;
7388     END IF;
7389 
7390     IF p_x_line_rec.line_category_code = FND_API.G_MISS_CHAR THEN
7391         p_x_line_rec.line_category_code := NULL;
7392     END IF;
7393 
7394     IF p_x_line_rec.line_id = FND_API.G_MISS_NUM THEN
7395         p_x_line_rec.line_id := NULL;
7396     END IF;
7397 
7398     IF p_x_line_rec.line_number = FND_API.G_MISS_NUM THEN
7399         p_x_line_rec.line_number := NULL;
7400     END IF;
7401 
7402     IF p_x_line_rec.line_type_id = FND_API.G_MISS_NUM THEN
7403         p_x_line_rec.line_type_id := NULL;
7404     END IF;
7405 
7406     IF p_x_line_rec.link_to_line_id = FND_API.G_MISS_NUM THEN
7407         p_x_line_rec.link_to_line_id := NULL;
7408     END IF;
7409 
7410     IF p_x_line_rec.model_group_number = FND_API.G_MISS_NUM THEN
7411         p_x_line_rec.model_group_number := NULL;
7412     END IF;
7413 
7414     IF p_x_line_rec.mfg_component_sequence_id = FND_API.G_MISS_NUM THEN
7415         p_x_line_rec.mfg_component_sequence_id := NULL;
7416     END IF;
7417 
7418     IF p_x_line_rec.mfg_lead_time = FND_API.G_MISS_NUM THEN
7419         p_x_line_rec.mfg_lead_time := NULL;
7420     END IF;
7421 
7422     IF p_x_line_rec.open_flag = FND_API.G_MISS_CHAR THEN
7423         p_x_line_rec.open_flag := NULL;
7424     END IF;
7425 
7426     IF p_x_line_rec.option_flag = FND_API.G_MISS_CHAR THEN
7427         p_x_line_rec.option_flag := NULL;
7428     END IF;
7429 
7430     IF p_x_line_rec.option_number = FND_API.G_MISS_NUM THEN
7431         p_x_line_rec.option_number := NULL;
7432     END IF;
7433 
7434     IF p_x_line_rec.ordered_quantity = FND_API.G_MISS_NUM THEN
7435         p_x_line_rec.ordered_quantity := NULL;
7436     END IF;
7437 
7438     IF p_x_line_rec.order_quantity_uom = FND_API.G_MISS_CHAR THEN
7439         p_x_line_rec.order_quantity_uom := NULL;
7440     END IF;
7441 
7442     -- OPM 02/JUN/00 - Deal with process attributes INVCONV
7443     -- ============================================
7444     IF p_x_line_rec.ordered_quantity2 = FND_API.G_MISS_NUM THEN
7445         p_x_line_rec.ordered_quantity2 := NULL;
7446     END IF;
7447 
7448     IF p_x_line_rec.ordered_quantity_uom2 = FND_API.G_MISS_CHAR THEN
7449         p_x_line_rec.ordered_quantity_uom2 := NULL;
7450     END IF;
7451     -- OPM 02/JUN/00 - END
7452     -- ===================
7453 
7454     IF p_x_line_rec.org_id = FND_API.G_MISS_NUM THEN
7455         p_x_line_rec.org_id := NULL;
7456     END IF;
7457 
7458     IF p_x_line_rec.orig_sys_document_ref = FND_API.G_MISS_CHAR THEN
7459         p_x_line_rec.orig_sys_document_ref := NULL;
7460     END IF;
7461 
7462     IF p_x_line_rec.orig_sys_line_ref = FND_API.G_MISS_CHAR THEN
7463         p_x_line_rec.orig_sys_line_ref := NULL;
7464     END IF;
7465 
7466     IF p_x_line_rec.orig_sys_shipment_ref = FND_API.G_MISS_CHAR THEN
7467         p_x_line_rec.orig_sys_shipment_ref := NULL;
7468     END IF;
7469 
7470 -- Override List Price
7471     IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
7472        IF p_x_line_rec.original_list_price = FND_API.G_MISS_NUM THEN
7473           p_x_line_rec.original_list_price:= NULL;
7474        END IF;
7475     END IF;
7476 -- Override List Price
7477 
7478     IF p_x_line_rec.over_ship_reason_code = FND_API.G_MISS_CHAR THEN
7479         p_x_line_rec.over_ship_reason_code := NULL;
7480     END IF;
7481     IF p_x_line_rec.over_ship_resolved_flag = FND_API.G_MISS_CHAR THEN
7482         p_x_line_rec.over_ship_resolved_flag := NULL;
7483     END IF;
7484 
7485     IF p_x_line_rec.payment_term_id = FND_API.G_MISS_NUM THEN
7486         p_x_line_rec.payment_term_id := NULL;
7487     END IF;
7488 
7489     IF p_x_line_rec.planning_priority = FND_API.G_MISS_NUM THEN
7490         p_x_line_rec.planning_priority := NULL;
7491     END IF;
7492 
7493     -- OPM 02/JUN/00 - Deal with process attributes INVCONV
7494     -- ============================================
7495     IF p_x_line_rec.preferred_grade = FND_API.G_MISS_CHAR THEN
7496         p_x_line_rec.preferred_grade := NULL;
7497     END IF;
7498     -- OPM 02/JUN/00 - END
7499     -- ===================
7500 
7501     IF p_x_line_rec.price_list_id = FND_API.G_MISS_NUM THEN
7502         p_x_line_rec.price_list_id := NULL;
7503     END IF;
7504 
7505      IF p_x_line_rec.price_request_code = FND_API.G_MISS_CHAR THEN -- PROMOTIONS SEP/01
7506         p_x_line_rec.price_request_code := NULL;
7507     END IF;
7508 
7509     IF p_x_line_rec.pricing_attribute1 = FND_API.G_MISS_CHAR THEN
7510         p_x_line_rec.pricing_attribute1 := NULL;
7511     END IF;
7512 
7513     IF p_x_line_rec.pricing_attribute10 = FND_API.G_MISS_CHAR THEN
7514         p_x_line_rec.pricing_attribute10 := NULL;
7515     END IF;
7516 
7517     IF p_x_line_rec.pricing_attribute2 = FND_API.G_MISS_CHAR THEN
7518         p_x_line_rec.pricing_attribute2 := NULL;
7519     END IF;
7520 
7521     IF p_x_line_rec.pricing_attribute3 = FND_API.G_MISS_CHAR THEN
7522         p_x_line_rec.pricing_attribute3 := NULL;
7523     END IF;
7524 
7525     IF p_x_line_rec.pricing_attribute4 = FND_API.G_MISS_CHAR THEN
7526         p_x_line_rec.pricing_attribute4 := NULL;
7527     END IF;
7528 
7529     IF p_x_line_rec.pricing_attribute5 = FND_API.G_MISS_CHAR THEN
7530         p_x_line_rec.pricing_attribute5 := NULL;
7531     END IF;
7532 
7533     IF p_x_line_rec.pricing_attribute6 = FND_API.G_MISS_CHAR THEN
7534         p_x_line_rec.pricing_attribute6 := NULL;
7535     END IF;
7536 
7537     IF p_x_line_rec.pricing_attribute7 = FND_API.G_MISS_CHAR THEN
7538         p_x_line_rec.pricing_attribute7 := NULL;
7539     END IF;
7540 
7541     IF p_x_line_rec.pricing_attribute8 = FND_API.G_MISS_CHAR THEN
7542         p_x_line_rec.pricing_attribute8 := NULL;
7543     END IF;
7544 
7545     IF p_x_line_rec.pricing_attribute9 = FND_API.G_MISS_CHAR THEN
7546         p_x_line_rec.pricing_attribute9 := NULL;
7547     END IF;
7548 
7549     IF p_x_line_rec.pricing_context = FND_API.G_MISS_CHAR THEN
7550         p_x_line_rec.pricing_context := NULL;
7551     END IF;
7552 
7553     IF p_x_line_rec.pricing_date = FND_API.G_MISS_DATE THEN
7554         p_x_line_rec.pricing_date := NULL;
7555     END IF;
7556 
7557     IF p_x_line_rec.pricing_quantity = FND_API.G_MISS_NUM THEN
7558         p_x_line_rec.pricing_quantity := NULL;
7559     END IF;
7560 
7561     IF p_x_line_rec.pricing_quantity_uom = FND_API.G_MISS_CHAR THEN
7562         p_x_line_rec.pricing_quantity_uom := NULL;
7563     END IF;
7564 
7565     IF p_x_line_rec.program_application_id = FND_API.G_MISS_NUM THEN
7566         p_x_line_rec.program_application_id := NULL;
7567     END IF;
7568 
7569     IF p_x_line_rec.program_id = FND_API.G_MISS_NUM THEN
7570         p_x_line_rec.program_id := NULL;
7571     END IF;
7572 
7573     IF p_x_line_rec.program_update_date = FND_API.G_MISS_DATE THEN
7574         p_x_line_rec.program_update_date := NULL;
7575     END IF;
7576 
7577     IF p_x_line_rec.project_id = FND_API.G_MISS_NUM THEN
7578         p_x_line_rec.project_id := NULL;
7579     END IF;
7580 
7581     IF p_x_line_rec.promise_date = FND_API.G_MISS_DATE THEN
7582         p_x_line_rec.promise_date := NULL;
7583     END IF;
7584 
7585     IF p_x_line_rec.re_source_flag = FND_API.G_MISS_CHAR THEN
7586         p_x_line_rec.re_source_flag := NULL;
7587     END IF;
7588 
7589     IF p_x_line_rec.reference_customer_trx_line_id = FND_API.G_MISS_NUM THEN
7590         p_x_line_rec.reference_customer_trx_line_id := NULL;
7591     END IF;
7592 
7593     IF p_x_line_rec.reference_header_id = FND_API.G_MISS_NUM THEN
7594         p_x_line_rec.reference_header_id := NULL;
7595     END IF;
7596 
7597     IF p_x_line_rec.reference_line_id = FND_API.G_MISS_NUM THEN
7598         p_x_line_rec.reference_line_id := NULL;
7599     END IF;
7600 
7601     IF p_x_line_rec.reference_type = FND_API.G_MISS_CHAR THEN
7602         p_x_line_rec.reference_type := NULL;
7603     END IF;
7604 
7605 
7606 
7607     IF p_x_line_rec.request_date = FND_API.G_MISS_DATE THEN
7608         p_x_line_rec.request_date := NULL;
7609     END IF;
7610 
7611     IF p_x_line_rec.request_id = FND_API.G_MISS_NUM THEN
7612         p_x_line_rec.request_id := NULL;
7613     END IF;
7614 
7615     IF p_x_line_rec.return_attribute1 = FND_API.G_MISS_CHAR THEN
7616         p_x_line_rec.return_attribute1 := NULL;
7617     END IF;
7618 
7619     IF p_x_line_rec.return_attribute10 = FND_API.G_MISS_CHAR THEN
7620         p_x_line_rec.return_attribute10 := NULL;
7621     END IF;
7622 
7623     IF p_x_line_rec.return_attribute11 = FND_API.G_MISS_CHAR THEN
7624         p_x_line_rec.return_attribute11 := NULL;
7625     END IF;
7626 
7627     IF p_x_line_rec.return_attribute12 = FND_API.G_MISS_CHAR THEN
7628         p_x_line_rec.return_attribute12 := NULL;
7629     END IF;
7630 
7631     IF p_x_line_rec.return_attribute13 = FND_API.G_MISS_CHAR THEN
7632         p_x_line_rec.return_attribute13 := NULL;
7633     END IF;
7634 
7635     IF p_x_line_rec.return_attribute14 = FND_API.G_MISS_CHAR THEN
7636         p_x_line_rec.return_attribute14 := NULL;
7637     END IF;
7638 
7639     IF p_x_line_rec.return_attribute15 = FND_API.G_MISS_CHAR THEN
7640         p_x_line_rec.return_attribute15 := NULL;
7641     END IF;
7642 
7643     IF p_x_line_rec.return_attribute2 = FND_API.G_MISS_CHAR THEN
7644         p_x_line_rec.return_attribute2 := NULL;
7645     END IF;
7646 
7647     IF p_x_line_rec.return_attribute3 = FND_API.G_MISS_CHAR THEN
7648         p_x_line_rec.return_attribute3 := NULL;
7649     END IF;
7650 
7651     IF p_x_line_rec.return_attribute4 = FND_API.G_MISS_CHAR THEN
7652         p_x_line_rec.return_attribute4 := NULL;
7653     END IF;
7654 
7655     IF p_x_line_rec.return_attribute5 = FND_API.G_MISS_CHAR THEN
7656         p_x_line_rec.return_attribute5 := NULL;
7657     END IF;
7658 
7659     IF p_x_line_rec.return_attribute6 = FND_API.G_MISS_CHAR THEN
7660         p_x_line_rec.return_attribute6 := NULL;
7661     END IF;
7662 
7663     IF p_x_line_rec.return_attribute7 = FND_API.G_MISS_CHAR THEN
7664         p_x_line_rec.return_attribute7 := NULL;
7665     END IF;
7666 
7667     IF p_x_line_rec.return_attribute8 = FND_API.G_MISS_CHAR THEN
7668         p_x_line_rec.return_attribute8 := NULL;
7669     END IF;
7670 
7671     IF p_x_line_rec.return_attribute9 = FND_API.G_MISS_CHAR THEN
7672         p_x_line_rec.return_attribute9 := NULL;
7673     END IF;
7674 
7675     IF p_x_line_rec.return_context = FND_API.G_MISS_CHAR THEN
7676         p_x_line_rec.return_context := NULL;
7677     END IF;
7678     IF p_x_line_rec.return_reason_code = FND_API.G_MISS_CHAR THEN
7679         p_x_line_rec.return_reason_code := NULL;
7680     END IF;
7681     IF p_x_line_rec.salesrep_id = FND_API.G_MISS_NUM THEN
7682         p_x_line_rec.salesrep_id := NULL;
7683     END IF;
7684 
7685     IF p_x_line_rec.rla_schedule_type_code = FND_API.G_MISS_CHAR THEN
7686         p_x_line_rec.rla_schedule_type_code := NULL;
7687     END IF;
7688 
7689     IF p_x_line_rec.schedule_arrival_date = FND_API.G_MISS_DATE THEN
7690         p_x_line_rec.schedule_arrival_date := NULL;
7691     END IF;
7692 
7693     IF p_x_line_rec.schedule_ship_date = FND_API.G_MISS_DATE THEN
7694         p_x_line_rec.schedule_ship_date := NULL;
7695     END IF;
7696 
7697     IF p_x_line_rec.schedule_action_code = FND_API.G_MISS_CHAR THEN
7698         p_x_line_rec.schedule_action_code := NULL;
7699     END IF;
7700 
7701     IF p_x_line_rec.schedule_status_code = FND_API.G_MISS_CHAR THEN
7702         p_x_line_rec.schedule_status_code := NULL;
7703     END IF;
7704 
7705     IF p_x_line_rec.shipment_number = FND_API.G_MISS_NUM THEN
7706         p_x_line_rec.shipment_number := NULL;
7707     END IF;
7708 
7709     IF p_x_line_rec.shipment_priority_code = FND_API.G_MISS_CHAR THEN
7710         p_x_line_rec.shipment_priority_code := NULL;
7711     END IF;
7712 
7713     IF p_x_line_rec.shipped_quantity = FND_API.G_MISS_NUM THEN
7714         p_x_line_rec.shipped_quantity := NULL;
7715     END IF;
7716 
7717     IF p_x_line_rec.shipped_quantity2 = FND_API.G_MISS_NUM THEN -- OPM B1661023 04/02/01 INVCONV
7718         p_x_line_rec.shipped_quantity2 := NULL;
7719     END IF;
7720 
7721     IF p_x_line_rec.shipping_method_code = FND_API.G_MISS_CHAR THEN
7722         p_x_line_rec.shipping_method_code := NULL;
7723     END IF;
7724 
7725     IF p_x_line_rec.shipping_quantity = FND_API.G_MISS_NUM THEN
7726         p_x_line_rec.shipping_quantity := NULL;
7727     END IF;
7728 
7729     IF p_x_line_rec.shipping_quantity2 = FND_API.G_MISS_NUM THEN -- OPM B1661023 04/02/01 INVCONV
7730         p_x_line_rec.shipping_quantity2 := NULL;
7731     END IF;
7732 
7733     IF p_x_line_rec.shipping_quantity_uom = FND_API.G_MISS_CHAR THEN
7734         p_x_line_rec.shipping_quantity_uom := NULL;
7735     END IF;
7736 
7737     IF p_x_line_rec.ship_from_org_id = FND_API.G_MISS_NUM THEN
7738         p_x_line_rec.ship_from_org_id := NULL;
7739     END IF;
7740 
7741     IF p_x_line_rec.subinventory = FND_API.G_MISS_CHAR THEN
7742         p_x_line_rec.subinventory := NULL;
7743     END IF;
7744 
7745     IF p_x_line_rec.ship_model_complete_flag = FND_API.G_MISS_CHAR THEN
7746         p_x_line_rec.ship_model_complete_flag := NULL;
7747     END IF;
7748     IF p_x_line_rec.ship_set_id = FND_API.G_MISS_NUM THEN
7749         p_x_line_rec.ship_set_id := NULL;
7750     END IF;
7751 
7752     IF p_x_line_rec.ship_tolerance_above = FND_API.G_MISS_NUM THEN
7753         p_x_line_rec.ship_tolerance_above := NULL;
7754     END IF;
7755 
7756     IF p_x_line_rec.ship_tolerance_below = FND_API.G_MISS_NUM THEN
7757         p_x_line_rec.ship_tolerance_below := NULL;
7758     END IF;
7759 
7760     IF p_x_line_rec.shippable_flag = FND_API.G_MISS_CHAR THEN
7761         p_x_line_rec.shippable_flag := NULL;
7762     END IF;
7763 
7764     IF p_x_line_rec.shipping_interfaced_flag = FND_API.G_MISS_CHAR THEN
7765         p_x_line_rec.shipping_interfaced_flag := NULL;
7766     END IF;
7767 
7768     IF p_x_line_rec.ship_to_contact_id = FND_API.G_MISS_NUM THEN
7769         p_x_line_rec.ship_to_contact_id := NULL;
7770     END IF;
7771 
7772     IF p_x_line_rec.ship_to_org_id = FND_API.G_MISS_NUM THEN
7773         p_x_line_rec.ship_to_org_id := NULL;
7774     END IF;
7775 
7776     IF p_x_line_rec.sold_from_org_id = FND_API.G_MISS_NUM THEN
7777         p_x_line_rec.sold_from_org_id := NULL;
7778     END IF;
7779 
7780     IF p_x_line_rec.sold_to_org_id = FND_API.G_MISS_NUM THEN
7781         p_x_line_rec.sold_to_org_id := NULL;
7782     END IF;
7783 
7784     IF p_x_line_rec.sort_order = FND_API.G_MISS_CHAR THEN
7785         p_x_line_rec.sort_order := NULL;
7786     END IF;
7787 
7788     IF p_x_line_rec.source_document_id = FND_API.G_MISS_NUM THEN
7789         p_x_line_rec.source_document_id := NULL;
7790     END IF;
7791 
7792     IF p_x_line_rec.source_document_line_id = FND_API.G_MISS_NUM THEN
7793         p_x_line_rec.source_document_line_id := NULL;
7794     END IF;
7795 
7796     IF p_x_line_rec.source_document_type_id = FND_API.G_MISS_NUM THEN
7797         p_x_line_rec.source_document_type_id := NULL;
7798     END IF;
7799 
7800     IF p_x_line_rec.source_type_code = FND_API.G_MISS_CHAR THEN
7801         p_x_line_rec.source_type_code := NULL;
7802     END IF;
7803     IF p_x_line_rec.split_from_line_id = FND_API.G_MISS_NUM THEN
7804         p_x_line_rec.split_from_line_id := NULL;
7805     END IF;
7806     IF p_x_line_rec.line_set_id = FND_API.G_MISS_NUM THEN
7807         p_x_line_rec.line_set_id := NULL;
7808     END IF;
7809 
7810     IF p_x_line_rec.split_by = FND_API.G_MISS_CHAR THEN
7811         p_x_line_rec.split_by := NULL;
7812     END IF;
7813     IF p_x_line_rec.model_remnant_flag = FND_API.G_MISS_CHAR THEN
7814         p_x_line_rec.model_remnant_flag := NULL;
7815     END IF;
7816     IF p_x_line_rec.task_id = FND_API.G_MISS_NUM THEN
7817         p_x_line_rec.task_id := NULL;
7818     END IF;
7819 
7820     IF p_x_line_rec.tax_code = FND_API.G_MISS_CHAR THEN
7821         p_x_line_rec.tax_code := NULL;
7822     END IF;
7823 
7824     IF p_x_line_rec.tax_date = FND_API.G_MISS_DATE THEN
7825         p_x_line_rec.tax_date := NULL;
7826     END IF;
7827 
7828     IF p_x_line_rec.tax_exempt_flag = FND_API.G_MISS_CHAR THEN
7829         p_x_line_rec.tax_exempt_flag := NULL;
7830     END IF;
7831 
7832     IF p_x_line_rec.tax_exempt_number = FND_API.G_MISS_CHAR THEN
7833         p_x_line_rec.tax_exempt_number := NULL;
7834     END IF;
7835 
7836     IF p_x_line_rec.tax_exempt_reason_code = FND_API.G_MISS_CHAR THEN
7837         p_x_line_rec.tax_exempt_reason_code := NULL;
7838     END IF;
7839 
7840     IF p_x_line_rec.tax_point_code = FND_API.G_MISS_CHAR THEN
7841         p_x_line_rec.tax_point_code := NULL;
7842     END IF;
7843 
7844     IF p_x_line_rec.tax_rate = FND_API.G_MISS_NUM THEN
7845         p_x_line_rec.tax_rate := NULL;
7846     END IF;
7847 
7848     IF p_x_line_rec.tax_value = FND_API.G_MISS_NUM THEN
7849         p_x_line_rec.tax_value := NULL;
7850     END IF;
7851 
7852     IF p_x_line_rec.top_model_line_id = FND_API.G_MISS_NUM THEN
7853         p_x_line_rec.top_model_line_id := NULL;
7854     END IF;
7855 
7856     IF p_x_line_rec.unit_list_price = FND_API.G_MISS_NUM THEN
7857         p_x_line_rec.unit_list_price := NULL;
7858     END IF;
7859 
7860     IF p_x_line_rec.unit_list_price_per_pqty = FND_API.G_MISS_NUM THEN
7861         p_x_line_rec.unit_list_price_per_pqty := NULL;
7862     END IF;
7863 
7864     IF p_x_line_rec.unit_selling_price = FND_API.G_MISS_NUM THEN
7865         p_x_line_rec.unit_selling_price := NULL;
7866     END IF;
7867 
7868     IF p_x_line_rec.unit_selling_price_per_pqty = FND_API.G_MISS_NUM THEN
7869         p_x_line_rec.unit_selling_price_per_pqty := NULL;
7870     END IF;
7871 
7872 
7873     IF p_x_line_rec.visible_demand_flag = FND_API.G_MISS_CHAR THEN
7874         p_x_line_rec.visible_demand_flag := NULL;
7875     END IF;
7876     IF p_x_line_rec.veh_cus_item_cum_key_id = FND_API.G_MISS_NUM THEN
7877         p_x_line_rec.veh_cus_item_cum_key_id := NULL;
7878     END IF;
7879 
7880     IF p_x_line_rec.first_ack_code = FND_API.G_MISS_CHAR THEN
7881         p_x_line_rec.first_ack_code := NULL;
7882     END IF;
7883 
7884     IF p_x_line_rec.first_ack_date = FND_API.G_MISS_DATE THEN
7885         p_x_line_rec.first_ack_date := NULL;
7886     END IF;
7887 
7888     IF p_x_line_rec.last_ack_code = FND_API.G_MISS_CHAR THEN
7889         p_x_line_rec.last_ack_code := NULL;
7890     END IF;
7891 
7892     IF p_x_line_rec.last_ack_date = FND_API.G_MISS_DATE THEN
7893         p_x_line_rec.last_ack_date := NULL;
7894     END IF;
7895 
7896 
7897     IF p_x_line_rec.end_item_unit_number = FND_API.G_MISS_CHAR THEN
7898         p_x_line_rec.end_item_unit_number := NULL;
7899     END IF;
7900 
7901     IF p_x_line_rec.shipping_instructions = FND_API.G_MISS_CHAR THEN
7902         p_x_line_rec.shipping_instructions := NULL;
7903     END IF;
7904 
7905     IF p_x_line_rec.packing_instructions = FND_API.G_MISS_CHAR THEN
7906         p_x_line_rec.packing_instructions := NULL;
7907     END IF;
7908 
7909     -- Service related columns
7910 
7911     IF p_x_line_rec.service_txn_reason_code = FND_API.G_MISS_CHAR THEN
7912         p_x_line_rec.service_txn_reason_code := NULL;
7913     END IF;
7914 
7915     IF p_x_line_rec.service_txn_comments = FND_API.G_MISS_CHAR THEN
7916         p_x_line_rec.service_txn_comments := NULL;
7917     END IF;
7918 
7919     IF p_x_line_rec.service_duration = FND_API.G_MISS_NUM THEN
7920         p_x_line_rec.service_duration := NULL;
7921     END IF;
7922 
7923     IF p_x_line_rec.service_period = FND_API.G_MISS_CHAR THEN
7924         p_x_line_rec.service_period := NULL;
7925     END IF;
7926 
7927     IF p_x_line_rec.service_start_date = FND_API.G_MISS_DATE THEN
7928         p_x_line_rec.service_start_date := NULL;
7929     END IF;
7930 
7931     IF p_x_line_rec.service_end_date = FND_API.G_MISS_DATE THEN
7932         p_x_line_rec.service_end_date := NULL;
7933     END IF;
7934 
7935     IF p_x_line_rec.service_coterminate_flag = FND_API.G_MISS_CHAR THEN
7936         p_x_line_rec.service_coterminate_flag := NULL;
7937     END IF;
7938 
7939 
7940     IF p_x_line_rec.unit_list_percent = FND_API.G_MISS_NUM THEN
7941         p_x_line_rec.unit_list_percent := NULL;
7942     END IF;
7943 
7944     IF p_x_line_rec.unit_selling_percent = FND_API.G_MISS_NUM THEN
7945         p_x_line_rec.unit_selling_percent := NULL;
7946     END IF;
7947 
7948     IF p_x_line_rec.unit_percent_base_price = FND_API.G_MISS_NUM THEN
7949         p_x_line_rec.unit_percent_base_price := NULL;
7950     END IF;
7951 
7952     IF p_x_line_rec.service_number = FND_API.G_MISS_NUM THEN
7953         p_x_line_rec.service_number := NULL;
7954     END IF;
7955 
7956     IF p_x_line_rec.service_reference_type_code = FND_API.G_MISS_CHAR THEN
7957         p_x_line_rec.service_reference_type_code := NULL;
7958     END IF;
7959 
7960     IF p_x_line_rec.service_reference_line_id = FND_API.G_MISS_NUM THEN
7961         p_x_line_rec.service_reference_line_id := NULL;
7962     END IF;
7963 
7964     IF p_x_line_rec.service_reference_system_id = FND_API.G_MISS_NUM THEN
7965         p_x_line_rec.service_reference_system_id := NULL;
7966     END IF;
7967 
7968     /* Marketing source code related */
7969 
7970     IF p_x_line_rec.marketing_source_code_id = FND_API.G_MISS_NUM THEN
7971         p_x_line_rec.marketing_source_code_id := NULL;
7972     END IF;
7973 
7974     /* End of Marketing source code related */
7975 
7976     IF p_x_line_rec.order_source_id = FND_API.G_MISS_NUM THEN
7977   if l_debug_level > 0 then
7978     oe_debug_pub.add('OEXULIN-aksingh convert_miss_to_null - order_source_id');
7979   end if;
7980         p_x_line_rec.order_source_id := NULL;
7981     END IF;
7982 
7983     IF p_x_line_rec.flow_status_code = FND_API.G_MISS_CHAR THEN
7984         p_x_line_rec.flow_status_code := NULL;
7985     END IF;
7986 
7987     -- Commitment related
7988     IF p_x_line_rec.commitment_id = FND_API.G_MISS_NUM THEN
7989        p_x_line_rec.commitment_id := NULL;
7990     END IF;
7991 
7992 
7993    -- Item Substitution changes.
7994    IF p_x_line_rec.Original_Inventory_Item_Id = FND_API.G_MISS_NUM THEN
7995        p_x_line_rec.Original_Inventory_Item_Id := Null;
7996    END IF;
7997 
7998    IF p_x_line_rec.Original_item_identifier_Type = FND_API.G_MISS_CHAR THEN
7999        p_x_line_rec.Original_item_identifier_Type := Null;
8000    END IF;
8001 
8002    IF p_x_line_rec.Original_ordered_item_id = FND_API.G_MISS_NUM THEN
8003        p_x_line_rec.Original_ordered_item_id := Null;
8004    END IF;
8005 
8006    IF p_x_line_rec.Original_ordered_item = FND_API.G_MISS_CHAR THEN
8007        p_x_line_rec.Original_ordered_item := Null;
8008    END IF;
8009 
8010    IF p_x_line_rec.item_relationship_type = FND_API.G_MISS_NUM THEN
8011        p_x_line_rec.item_relationship_type := Null;
8012    END IF;
8013 
8014    IF p_x_line_rec.Item_substitution_type_code = FND_API.G_MISS_CHAR THEN
8015        p_x_line_rec.Item_substitution_type_code := Null;
8016    END IF;
8017 
8018    IF p_x_line_rec.Late_Demand_Penalty_Factor = FND_API.G_MISS_NUM THEN
8019        p_x_line_rec.Late_Demand_Penalty_Factor := Null;
8020    END IF;
8021 
8022    IF p_x_line_rec.Override_atp_date_code = FND_API.G_MISS_CHAR THEN
8023        p_x_line_rec.Override_atp_date_code := Null;
8024    END IF;
8025 
8026    -- Changes for Blanket Orders
8027 
8028    IF p_x_line_rec.Blanket_Number = FND_API.G_MISS_NUM THEN
8029       p_x_line_rec.Blanket_Number := NULL;
8030    END IF;
8031 
8032    IF p_x_line_rec.Blanket_Line_Number = FND_API.G_MISS_NUM THEN
8033       p_x_line_rec.Blanket_Line_Number := NULL;
8034    END IF;
8035 
8036    IF p_x_line_rec.Blanket_Version_Number = FND_API.G_MISS_NUM THEN
8037       p_x_line_rec.Blanket_Version_Number := NULL;
8038    END IF;
8039 
8040    -- QUOTING changes
8041    IF p_x_line_rec.transaction_phase_code = FND_API.G_MISS_CHAR THEN
8042       p_x_line_rec.transaction_phase_code := NULL;
8043    END IF;
8044 
8045    IF p_x_line_rec.source_document_version_number = FND_API.G_MISS_NUM THEN
8046       p_x_line_rec.source_document_version_number := NULL;
8047    END IF;
8048    -- END QUOTING changes
8049     IF p_x_line_rec.Minisite_id = FND_API.G_MISS_NUM THEN
8050         p_x_line_rec.Minisite_id := NULL;
8051     END IF;
8052 
8053     IF p_x_line_rec.End_customer_id = FND_API.G_MISS_NUM THEN
8054         p_x_line_rec.End_customer_id := NULL;
8055     END IF;
8056 
8057     IF p_x_line_rec.End_customer_contact_id = FND_API.G_MISS_NUM THEN
8058         p_x_line_rec.End_customer_contact_id := NULL;
8059     END IF;
8060 
8061     IF p_x_line_rec.End_customer_site_use_id = FND_API.G_MISS_NUM THEN
8062         p_x_line_rec.End_customer_site_use_id := NULL;
8063     END IF;
8064 
8065     IF p_x_line_rec.ib_owner = FND_API.G_MISS_CHAR THEN
8066         p_x_line_rec.ib_owner := NULL;
8067     END IF;
8068 
8069     IF p_x_line_rec.ib_installed_at_location = FND_API.G_MISS_CHAR THEN
8070         p_x_line_rec.ib_installed_at_location := NULL;
8071     END IF;
8072 
8073     IF p_x_line_rec.ib_current_location = FND_API.G_MISS_CHAR THEN
8074         p_x_line_rec.ib_current_location := NULL;
8075     END IF;
8076 
8077     --retro{
8078     IF p_x_line_rec.retrobill_request_id = FND_API.G_MISS_NUM THEN
8079        p_x_line_rec.retrobill_request_id := Null;
8080     END IF;
8081     --retro}
8082 
8083     IF p_x_line_rec.firm_demand_flag = FND_API.G_MISS_CHAR THEN
8084         p_x_line_rec.firm_demand_flag := NULL;
8085     END IF;
8086 
8087 --key Transaction Dates
8088     IF p_x_line_rec.order_firmed_date = FND_API.G_MISS_DATE THEN
8089       	p_x_line_rec.order_firmed_date := NULL;
8090     END IF;
8091 
8092    IF p_x_line_rec.actual_fulfillment_date = FND_API.G_MISS_DATE THEN
8093 	p_x_line_rec.actual_fulfillment_date := NULL;
8094     END IF;
8095 --end
8096 
8097 -- INVCONV OPM inventory convergence
8098 
8099 	  IF p_x_line_rec.fulfilled_quantity2 = FND_API.G_MISS_NUM THEN
8100         p_x_line_rec.fulfilled_quantity2 := NULL;
8101     END IF;
8102 
8103 	  IF p_x_line_rec.cancelled_quantity2 = FND_API.G_MISS_NUM THEN
8104         p_x_line_rec.cancelled_quantity2 := NULL;
8105     END IF;
8106  		IF p_x_line_rec.shipping_quantity_uom2 = FND_API.G_MISS_CHAR THEN
8107         p_x_line_rec.shipping_quantity_uom2 := NULL;
8108     END IF;
8109 
8110 -- INVCONV end
8111 
8112 /*   IF p_x_line_rec.supplier_signature = FND_API.G_MISS_CHAR THEN
8113         p_x_line_rec.supplier_signature := NULL;
8114     END IF;
8115 
8116    IF p_x_line_rec.supplier_signature_date = FND_API.G_MISS_DATE THEN
8117         p_x_line_rec.supplier_signature_date := NULL;
8118     END IF;
8119 
8120    IF p_x_line_rec.customer_signature = FND_API.G_MISS_CHAR THEN
8121         p_x_line_rec.customer_signature := NULL;
8122     END IF;
8123 
8124    IF p_x_line_rec.customer_signature_date = FND_API.G_MISS_CHAR THEN
8125         p_x_line_rec.customer_signature_date := NULL;
8126     END IF;
8127 */
8128 
8129   if l_debug_level > 0 then
8130    oe_debug_pub.add('Exiting OE_LINE_UTIL.CONVERT_MISS_TO_NULL', 1);
8131   end if;
8132 END Convert_Miss_To_Null;
8133 
8134 
8135 
8136 /*-----------------------------------------------------------
8137 Procedure Update_Row
8138 -----------------------------------------------------------*/
8139 
8140 PROCEDURE Update_Row
8141 (   p_line_rec                      IN  OUT NOCOPY OE_Order_PUB.Line_Rec_Type
8142 )
8143 IS
8144 l_org_id NUMBER;
8145 l_lock_control NUMBER;
8146 l_index    NUMBER;
8147 l_return_status VARCHAR2(1);
8148 
8149 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
8150 BEGIN
8151 
8152   if l_debug_level > 0 then
8153     oe_debug_pub.add('Entering OE_LINE_UTIL.UPDATE_ROW', 1);
8154   end if;
8155             --Commented for MOAC start
8156 	    /*if l_org_id IS NULL THEN
8157 		    OE_GLOBALS.Set_Context;
8158 		    l_org_id := OE_GLOBALS.G_ORG_ID;
8159 	    end if;*/
8160             --Commented for MOAC end
8161 
8162     SELECT lock_control
8163     INTO   l_lock_control
8164     FROM   oe_order_lines
8165     WHERE  line_id = p_line_rec.line_id;
8166 
8167     l_lock_control :=   l_lock_control + 1;
8168 
8169   -- calling notification framework to update global picture
8170    --check code release level first. Notification framework is at Pack H level
8171     IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508' THEN
8172       OE_ORDER_UTIL.Update_Global_Picture(p_Upd_New_Rec_If_Exists => True,
8173                     p_Line_rec =>p_line_rec,
8174                     p_line_id => p_line_rec.line_id,
8175                     x_index => l_index,
8176                     x_return_status => l_return_status);
8177       if l_debug_level > 0 then
8178        OE_DEBUG_PUB.ADD('Update_Global Return Status from OE_LINE_UTIL.update_row is: ' || l_return_status);
8179        OE_DEBUG_PUB.ADD('JFC: Line Booked Status in OE_LINE_UTIL.update_row is: ' || p_line_rec.booked_flag);
8180        OE_DEBUG_PUB.ADD('JFC: Line Flow Status in OE_LINE_UTIL.update_row is: ' || p_line_rec.flow_status_code);
8181       end if;
8182        IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
8183          if l_debug_level > 0 then
8184           OE_DEBUG_PUB.ADD('EVENT NOTIFY - Unexpected Error');
8185           OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.Update_ROW', 1);
8186          end if;
8187        	  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8188        ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
8189         if l_debug_level > 0 then
8190           OE_DEBUG_PUB.ADD('Update_Global_Picture Error in OE_LINE_UTIL.Update_row');
8191         OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.Update_ROW', 1);
8192         end if;
8193 	RAISE FND_API.G_EXC_ERROR;
8194        END IF;
8195     END IF; /*code_release_level*/
8196   -- notification framework end
8197 
8198   if l_debug_level > 0 then
8199     -- oe_debug_pub.add('Entering update'||to_char(l_org_id), 1);
8200     oe_debug_pub.add('arrivalset-'||to_char(p_line_rec.arrival_set_id), 1);
8201     oe_debug_pub.add('shipset-'||to_char(p_line_rec.ship_set_id), 1);
8202   end if;
8203     -- OPM 02/JUN/00 - Include process columns
8204     --                (ordered_quantity2,ordered_quantity_uom2,preferred_grade)
8205     UPDATE  OE_ORDER_LINES
8206     SET     ACCOUNTING_RULE_ID             = p_line_rec.accounting_rule_id
8207     ,       ACCOUNTING_RULE_DURATION       = p_line_rec.accounting_rule_duration
8208     ,       CALCULATE_PRICE_FLAG            = p_line_rec.calculate_price_flag
8209     ,       ACTUAL_ARRIVAL_DATE            = p_line_rec.actual_arrival_date
8210     ,       ACTUAL_SHIPMENT_DATE           = p_line_rec.actual_shipment_date
8211     ,       AGREEMENT_ID                   = p_line_rec.agreement_id
8212     ,       ARRIVAL_SET_ID                 = p_line_rec.arrival_set_id
8213     ,       ATO_LINE_ID                    = p_line_rec.ato_line_id
8214     ,       ATTRIBUTE1                     = p_line_rec.attribute1
8215     ,       ATTRIBUTE10                    = p_line_rec.attribute10
8216     ,       ATTRIBUTE11                    = p_line_rec.attribute11
8217     ,       ATTRIBUTE12                    = p_line_rec.attribute12
8218     ,       ATTRIBUTE13                    = p_line_rec.attribute13
8219     ,       ATTRIBUTE14                    = p_line_rec.attribute14
8220     ,       ATTRIBUTE15                    = p_line_rec.attribute15
8221     ,       ATTRIBUTE16                    = p_line_rec.attribute16   --For bug 2184255
8222     ,       ATTRIBUTE17                    = p_line_rec.attribute17
8223     ,       ATTRIBUTE18                    = p_line_rec.attribute18
8224     ,       ATTRIBUTE19                    = p_line_rec.attribute19
8225     ,       ATTRIBUTE2                     = p_line_rec.attribute2
8226     ,       ATTRIBUTE20                    = p_line_rec.attribute20
8227     ,       ATTRIBUTE3                     = p_line_rec.attribute3
8228     ,       ATTRIBUTE4                     = p_line_rec.attribute4
8229     ,       ATTRIBUTE5                     = p_line_rec.attribute5
8230     ,       ATTRIBUTE6                     = p_line_rec.attribute6
8231     ,       ATTRIBUTE7                     = p_line_rec.attribute7
8232     ,       ATTRIBUTE8                     = p_line_rec.attribute8
8233     ,       ATTRIBUTE9                     = p_line_rec.attribute9
8234     ,       AUTO_SELECTED_QUANTITY         = p_line_rec.auto_selected_quantity
8235     ,       AUTHORIZED_TO_SHIP_FLAG        = p_line_rec.authorized_to_ship_flag
8236     ,       BOOKED_FLAG                    = p_line_rec.booked_flag
8237     ,       CANCELLED_FLAG                 = p_line_rec.cancelled_flag
8238     ,       CANCELLED_QUANTITY             = p_line_rec.cancelled_quantity
8239     ,       COMMITMENT_ID                  = p_line_rec.commitment_id
8240     ,       COMPONENT_CODE                 = p_line_rec.component_code
8241     ,       COMPONENT_SEQUENCE_ID          = p_line_rec.component_sequence_id
8242     ,       CONFIG_HEADER_ID               = p_line_rec.config_header_id
8243     ,       CONFIG_REV_NBR                 = p_line_rec.config_rev_nbr
8244     ,       CONFIG_DISPLAY_SEQUENCE        = p_line_rec.config_display_sequence
8245     ,       CONFIGURATION_ID               = p_line_rec.configuration_id
8246     ,       CONTEXT                        = p_line_rec.context
8247     ,       CREATED_BY                     = p_line_rec.created_by
8248     ,       CREATION_DATE                  = p_line_rec.creation_date
8249     ,       CREDIT_INVOICE_LINE_ID         = p_line_rec.credit_invoice_line_id
8250     ,       CUSTOMER_LINE_NUMBER	   = p_line_rec.customer_line_number
8251     ,       CUSTOMER_SHIPMENT_NUMBER       = p_line_rec.customer_shipment_number
8252     ,       CUSTOMER_ITEM_NET_PRICE        = p_line_rec.customer_item_net_price
8253     ,       CUSTOMER_PAYMENT_TERM_ID       = p_line_rec.customer_payment_term_id
8254     ,       CUSTOMER_DOCK_CODE             = p_line_rec.customer_dock_code
8255     ,       CUSTOMER_JOB                   = p_line_rec.customer_job
8256     ,       CUSTOMER_PRODUCTION_LINE       = p_line_rec.customer_production_line
8257     ,       CUST_PRODUCTION_SEQ_NUM        = p_line_rec.cust_production_seq_num
8258     ,       CUSTOMER_TRX_LINE_ID           = p_line_rec.customer_trx_line_id
8259     ,       CUST_MODEL_SERIAL_NUMBER       = p_line_rec.cust_model_serial_number
8260     ,       CUST_PO_NUMBER                 = p_line_rec.cust_po_number
8261     ,       DELIVERY_LEAD_TIME             = p_line_rec.delivery_lead_time
8262     ,       DELIVER_TO_CONTACT_ID          = p_line_rec.deliver_to_contact_id
8263     ,       DELIVER_TO_ORG_ID              = p_line_rec.deliver_to_org_id
8264     ,       DEMAND_BUCKET_TYPE_CODE        = p_line_rec.demand_bucket_type_code
8265     ,       DEMAND_CLASS_CODE              = p_line_rec.demand_class_code
8266     ,       DEP_PLAN_REQUIRED_FLAG         = p_line_rec.dep_plan_required_flag
8267     --,       DROP_SHIP_FLAG		   = p_line_rec.drop_ship_flag
8268     ,       EARLIEST_ACCEPTABLE_DATE       = p_line_rec.earliest_acceptable_date
8269     ,       END_ITEM_UNIT_NUMBER           = p_line_rec.end_item_unit_number
8270     ,       EXPLOSION_DATE                 = p_line_rec.explosion_date
8271     ,       FIRST_ACK_CODE                 = p_line_rec.first_ack_code
8272     ,       FIRST_ACK_DATE                 = p_line_rec.first_ack_date
8273     ,       FOB_POINT_CODE                 = p_line_rec.fob_point_code
8274     ,       FREIGHT_CARRIER_CODE           = p_line_rec.freight_carrier_code
8275     ,       FREIGHT_TERMS_CODE             = p_line_rec.freight_terms_code
8276     ,       FULFILLED_QUANTITY             = p_line_rec.fulfilled_quantity
8277     ,       FULFILLED_FLAG                 = p_line_rec.fulfilled_flag
8278     ,       FULFILLMENT_METHOD_CODE        = p_line_rec.fulfillment_method_code
8279     ,       FULFILLMENT_DATE               = p_line_rec.fulfillment_date
8280     ,       GLOBAL_ATTRIBUTE1              = p_line_rec.global_attribute1
8281     ,       GLOBAL_ATTRIBUTE10             = p_line_rec.global_attribute10
8282     ,       GLOBAL_ATTRIBUTE11             = p_line_rec.global_attribute11
8283     ,       GLOBAL_ATTRIBUTE12             = p_line_rec.global_attribute12
8284     ,       GLOBAL_ATTRIBUTE13             = p_line_rec.global_attribute13
8285     ,       GLOBAL_ATTRIBUTE14             = p_line_rec.global_attribute14
8286     ,       GLOBAL_ATTRIBUTE15             = p_line_rec.global_attribute15
8287     ,       GLOBAL_ATTRIBUTE16             = p_line_rec.global_attribute16
8288     ,       GLOBAL_ATTRIBUTE17             = p_line_rec.global_attribute17
8289     ,       GLOBAL_ATTRIBUTE18             = p_line_rec.global_attribute18
8290     ,       GLOBAL_ATTRIBUTE19             = p_line_rec.global_attribute19
8291     ,       GLOBAL_ATTRIBUTE2              = p_line_rec.global_attribute2
8292     ,       GLOBAL_ATTRIBUTE20             = p_line_rec.global_attribute20
8293     ,       GLOBAL_ATTRIBUTE3              = p_line_rec.global_attribute3
8294     ,       GLOBAL_ATTRIBUTE4              = p_line_rec.global_attribute4
8295     ,       GLOBAL_ATTRIBUTE5              = p_line_rec.global_attribute5
8296     ,       GLOBAL_ATTRIBUTE6              = p_line_rec.global_attribute6
8297     ,       GLOBAL_ATTRIBUTE7              = p_line_rec.global_attribute7
8298     ,       GLOBAL_ATTRIBUTE8              = p_line_rec.global_attribute8
8299     ,       GLOBAL_ATTRIBUTE9              = p_line_rec.global_attribute9
8300     ,       GLOBAL_ATTRIBUTE_CATEGORY      = p_line_rec.global_attribute_category
8301     ,       HEADER_ID                      = p_line_rec.header_id
8302     ,       INDUSTRY_ATTRIBUTE1            = p_line_rec.industry_attribute1
8303     ,       INDUSTRY_ATTRIBUTE10           = p_line_rec.industry_attribute10
8304     ,       INDUSTRY_ATTRIBUTE11           = p_line_rec.industry_attribute11
8305     ,       INDUSTRY_ATTRIBUTE12           = p_line_rec.industry_attribute12
8306     ,       INDUSTRY_ATTRIBUTE13           = p_line_rec.industry_attribute13
8307     ,       INDUSTRY_ATTRIBUTE14           = p_line_rec.industry_attribute14
8308     ,       INDUSTRY_ATTRIBUTE15           = p_line_rec.industry_attribute15
8309     ,       INDUSTRY_ATTRIBUTE16           = p_line_rec.industry_attribute16
8310     ,       INDUSTRY_ATTRIBUTE17           = p_line_rec.industry_attribute17
8311     ,       INDUSTRY_ATTRIBUTE18           = p_line_rec.industry_attribute18
8312     ,       INDUSTRY_ATTRIBUTE19           = p_line_rec.industry_attribute19
8313     ,       INDUSTRY_ATTRIBUTE20           = p_line_rec.industry_attribute20
8314     ,       INDUSTRY_ATTRIBUTE21           = p_line_rec.industry_attribute21
8315     ,       INDUSTRY_ATTRIBUTE22           = p_line_rec.industry_attribute22
8316     ,       INDUSTRY_ATTRIBUTE23           = p_line_rec.industry_attribute23
8317     ,       INDUSTRY_ATTRIBUTE24           = p_line_rec.industry_attribute24
8318     ,       INDUSTRY_ATTRIBUTE25           = p_line_rec.industry_attribute25
8319     ,       INDUSTRY_ATTRIBUTE26           = p_line_rec.industry_attribute26
8320     ,       INDUSTRY_ATTRIBUTE27           = p_line_rec.industry_attribute27
8321     ,       INDUSTRY_ATTRIBUTE28           = p_line_rec.industry_attribute28
8322     ,       INDUSTRY_ATTRIBUTE29           = p_line_rec.industry_attribute29
8323     ,       INDUSTRY_ATTRIBUTE30           = p_line_rec.industry_attribute30
8324     ,       INDUSTRY_ATTRIBUTE2            = p_line_rec.industry_attribute2
8325     ,       INDUSTRY_ATTRIBUTE3            = p_line_rec.industry_attribute3
8326     ,       INDUSTRY_ATTRIBUTE4            = p_line_rec.industry_attribute4
8327     ,       INDUSTRY_ATTRIBUTE5            = p_line_rec.industry_attribute5
8328     ,       INDUSTRY_ATTRIBUTE6            = p_line_rec.industry_attribute6
8329     ,       INDUSTRY_ATTRIBUTE7            = p_line_rec.industry_attribute7
8330     ,       INDUSTRY_ATTRIBUTE8            = p_line_rec.industry_attribute8
8331     ,       INDUSTRY_ATTRIBUTE9            = p_line_rec.industry_attribute9
8332     ,       INDUSTRY_CONTEXT               = p_line_rec.industry_context
8333     ,       INTMED_SHIP_TO_CONTACT_ID = p_line_rec.intermed_ship_to_contact_id
8334     ,       INTMED_SHIP_TO_ORG_ID     = p_line_rec.intermed_ship_to_org_id
8335     ,       INVENTORY_ITEM_ID              = p_line_rec.inventory_item_id
8336     ,       INVOICE_INTERFACE_STATUS_CODE          = p_line_rec.invoice_interface_status_code
8337     ,       INVOICE_TO_CONTACT_ID          = p_line_rec.invoice_to_contact_id
8338     ,       INVOICE_TO_ORG_ID              = p_line_rec.invoice_to_org_id
8339     ,       INVOICED_QUANTITY              = p_line_rec.invoiced_quantity
8340     ,       INVOICING_RULE_ID              = p_line_rec.invoicing_rule_id
8341     ,       ORDERED_ITEM_ID                        = p_line_rec.ordered_item_id
8342     ,       ITEM_IDENTIFIER_TYPE           = p_line_rec.item_identifier_type
8343     ,       ORDERED_ITEM                     = p_line_rec.ordered_item
8344     ,       ITEM_REVISION                  = p_line_rec.item_revision
8345     ,       ITEM_TYPE_CODE                 = p_line_rec.item_type_code
8346     ,       LAST_ACK_CODE                  = p_line_rec.last_ack_code
8347     ,       LAST_ACK_DATE                  = p_line_rec.last_ack_date --bug6448638
8348     ,       LAST_UPDATED_BY                = p_line_rec.last_updated_by
8349     ,       LATEST_ACCEPTABLE_DATE         = p_line_rec.latest_acceptable_date
8350     ,       LAST_UPDATE_DATE               = p_line_rec.last_update_date
8351     ,       LAST_UPDATE_LOGIN              = p_line_rec.last_update_login
8352     ,       LINE_CATEGORY_CODE             = p_line_rec.line_category_code
8353     ,       LINE_NUMBER                    = p_line_rec.line_number
8354     ,       LINE_TYPE_ID                   = p_line_rec.line_type_id
8355     ,       LINK_TO_LINE_ID                = p_line_rec.link_to_line_id
8356     ,       MODEL_GROUP_NUMBER             = p_line_rec.model_group_number
8357  --   ,       MFG_COMPONENT_SEQUENCE_ID      = p_line_rec.mfg_component_sequence_id
8358     ,       MFG_LEAD_TIME                  = p_line_rec.mfg_lead_time
8359     ,       OPEN_FLAG                      = p_line_rec.open_flag
8360     ,       OPTION_FLAG                    = p_line_rec.option_flag
8361     ,       OPTION_NUMBER                  = p_line_rec.option_number
8362     ,       ORDERED_QUANTITY               = p_line_rec.ordered_quantity
8363     ,       ORDERED_QUANTITY2              = p_line_rec.ordered_quantity2
8364     ,       ORDER_QUANTITY_UOM             = p_line_rec.order_quantity_uom
8365     ,       ORDERED_QUANTITY_UOM2          = p_line_rec.ordered_quantity_uom2
8366 --We should not allow to update org_id(operting unit)
8367 --  ,       ORG_ID                         = p_line_rec.org_id
8368     ,       ORDER_SOURCE_ID	           = p_line_rec.order_source_id
8369     ,       ORIG_SYS_DOCUMENT_REF          = p_line_rec.orig_sys_document_ref
8370     ,       ORIG_SYS_LINE_REF              = p_line_rec.orig_sys_line_ref
8371     ,       ORIG_SYS_SHIPMENT_REF          = p_line_rec.orig_sys_shipment_ref
8372     ,       CHANGE_SEQUENCE                = p_line_rec.change_sequence
8373     ,       OVER_SHIP_REASON_CODE          = p_line_rec.over_ship_reason_code
8374     ,       OVER_SHIP_RESOLVED_FLAG        = p_line_rec.over_ship_resolved_flag
8375     ,       PAYMENT_TERM_ID                = p_line_rec.payment_term_id
8376     ,       PLANNING_PRIORITY              = p_line_rec.planning_priority
8377     ,       PREFERRED_GRADE                = p_line_rec.preferred_grade
8378     ,       PRICE_LIST_ID                  = p_line_rec.price_list_id
8379     ,       PRICE_REQUEST_CODE             = p_line_rec.price_request_code  -- PROMOTIONS SEP/01
8380     ,       PRICING_ATTRIBUTE1             = p_line_rec.pricing_attribute1
8381     ,       PRICING_ATTRIBUTE10            = p_line_rec.pricing_attribute10
8382     ,       PRICING_ATTRIBUTE2             = p_line_rec.pricing_attribute2
8383     ,       PRICING_ATTRIBUTE3             = p_line_rec.pricing_attribute3
8384     ,       PRICING_ATTRIBUTE4             = p_line_rec.pricing_attribute4
8385     ,       PRICING_ATTRIBUTE5             = p_line_rec.pricing_attribute5
8386     ,       PRICING_ATTRIBUTE6             = p_line_rec.pricing_attribute6
8387     ,       PRICING_ATTRIBUTE7             = p_line_rec.pricing_attribute7
8388     ,       PRICING_ATTRIBUTE8             = p_line_rec.pricing_attribute8
8389     ,       PRICING_ATTRIBUTE9             = p_line_rec.pricing_attribute9
8390     ,       PRICING_CONTEXT                = p_line_rec.pricing_context
8391     ,       PRICING_DATE                   = p_line_rec.pricing_date
8392     ,       PRICING_QUANTITY               = p_line_rec.pricing_quantity
8393     ,       PRICING_QUANTITY_UOM           = p_line_rec.pricing_quantity_uom
8394     ,       PROGRAM_APPLICATION_ID         = p_line_rec.program_application_id
8395     ,       PROGRAM_ID                     = p_line_rec.program_id
8396     ,       PROGRAM_UPDATE_DATE            = p_line_rec.program_update_date
8397     ,       PROJECT_ID                     = p_line_rec.project_id
8398     ,       PROMISE_DATE                   = p_line_rec.promise_date
8399     ,       RE_SOURCE_FLAG                 = p_line_rec.re_source_flag
8400     ,       REFERENCE_CUSTOMER_TRX_LINE_ID = p_line_rec.reference_customer_trx_line_id
8401     ,       REFERENCE_HEADER_ID            = p_line_rec.reference_header_id
8402     ,       REFERENCE_LINE_ID              = p_line_rec.reference_line_id
8403     ,       REFERENCE_TYPE                 = p_line_rec.reference_type
8404     ,       REQUEST_DATE                   = p_line_rec.request_date
8405     ,       REQUEST_ID                     = p_line_rec.request_id
8406     ,       RETURN_ATTRIBUTE1              = p_line_rec.return_attribute1
8407     ,       RETURN_ATTRIBUTE10             = p_line_rec.return_attribute10
8408     ,       RETURN_ATTRIBUTE11             = p_line_rec.return_attribute11
8409     ,       RETURN_ATTRIBUTE12             = p_line_rec.return_attribute12
8410     ,       RETURN_ATTRIBUTE13             = p_line_rec.return_attribute13
8411     ,       RETURN_ATTRIBUTE14             = p_line_rec.return_attribute14
8412     ,       RETURN_ATTRIBUTE15             = p_line_rec.return_attribute15
8413     ,       RETURN_ATTRIBUTE2              = p_line_rec.return_attribute2
8414     ,       RETURN_ATTRIBUTE3              = p_line_rec.return_attribute3
8415     ,       RETURN_ATTRIBUTE4              = p_line_rec.return_attribute4
8416     ,       RETURN_ATTRIBUTE5              = p_line_rec.return_attribute5
8417     ,       RETURN_ATTRIBUTE6              = p_line_rec.return_attribute6
8418     ,       RETURN_ATTRIBUTE7              = p_line_rec.return_attribute7
8419     ,       RETURN_ATTRIBUTE8              = p_line_rec.return_attribute8
8420     ,       RETURN_ATTRIBUTE9              = p_line_rec.return_attribute9
8421     ,       RETURN_CONTEXT                 = p_line_rec.return_context
8422     ,       RETURN_REASON_CODE             = p_line_rec.return_reason_code
8423     ,       RLA_SCHEDULE_TYPE_CODE         = p_line_rec.rla_schedule_type_code
8424     ,       SALESREP_ID                    = p_line_rec.salesrep_id
8425     ,       SCHEDULE_ARRIVAL_DATE          = p_line_rec.schedule_arrival_date
8426     ,       SCHEDULE_SHIP_DATE             = p_line_rec.schedule_ship_date
8427     ,       SCHEDULE_STATUS_CODE           = p_line_rec.schedule_status_code
8428     ,       SHIPMENT_NUMBER                = p_line_rec.shipment_number
8429     ,       SHIPMENT_PRIORITY_CODE         = p_line_rec.shipment_priority_code
8430     ,       SHIPPED_QUANTITY               = p_line_rec.shipped_quantity
8431     ,       SHIPPED_QUANTITY2              = p_line_rec.shipped_quantity2  -- OPM B1661023 04/02/01
8432     ,       SHIPPING_METHOD_CODE           = p_line_rec.shipping_method_code
8433     ,       SHIPPING_QUANTITY              = p_line_rec.shipping_quantity
8434     ,       SHIPPING_QUANTITY2             = p_line_rec.shipping_quantity2 -- OPM B1661023 04/02/01
8435     ,       SHIPPING_QUANTITY_UOM          = p_line_rec.shipping_quantity_uom
8436     ,       SHIP_FROM_ORG_ID               = p_line_rec.ship_from_org_id
8437     ,       SUBINVENTORY                   = p_line_rec.subinventory
8438     ,       SHIP_TOLERANCE_ABOVE           = p_line_rec.ship_tolerance_above
8439     ,       SHIP_TOLERANCE_BELOW           = p_line_rec.ship_tolerance_below
8440     ,       SHIPPABLE_FLAG                 = p_line_rec.shippable_flag
8441     ,       SHIPPING_INTERFACED_FLAG       = p_line_rec.shipping_interfaced_flag
8442     ,       SHIP_TO_CONTACT_ID             = p_line_rec.ship_to_contact_id
8443     ,       SHIP_TO_ORG_ID                 = p_line_rec.ship_to_org_id
8444     ,       SHIP_MODEL_COMPLETE_FLAG       = p_line_rec.ship_model_complete_flag
8445     ,       SHIP_SET_ID                    = p_line_rec.ship_set_id
8446     ,       SOLD_TO_ORG_ID                 = p_line_rec.sold_to_org_id
8447     ,       SOLD_FROM_ORG_ID               = p_line_rec.sold_from_org_id
8448     ,       SORT_ORDER                     = p_line_rec.sort_order
8449     ,       SOURCE_DOCUMENT_ID             = p_line_rec.source_document_id
8450     ,       SOURCE_DOCUMENT_LINE_ID        = p_line_rec.source_document_line_id
8451     ,       SOURCE_DOCUMENT_TYPE_ID        = p_line_rec.source_document_type_id
8452     ,       SOURCE_TYPE_CODE               = p_line_rec.source_type_code
8453     ,       SPLIT_FROM_LINE_ID             = p_line_rec.split_from_line_id
8454     ,       LINE_SET_ID                    = p_line_rec.line_set_id
8455     ,       SPLIT_BY                       = p_line_rec.split_by
8456     ,       MODEL_REMNANT_FLAG             = p_line_rec.model_remnant_flag
8457     ,       TASK_ID                        = p_line_rec.task_id
8458     ,       TAX_CODE                       = p_line_rec.tax_code
8459     ,       TAX_DATE                       = p_line_rec.tax_date
8460     ,       TAX_EXEMPT_FLAG                = p_line_rec.tax_exempt_flag
8461     ,       TAX_EXEMPT_NUMBER              = p_line_rec.tax_exempt_number
8462     ,       TAX_EXEMPT_REASON_CODE         = p_line_rec.tax_exempt_reason_code
8463     ,       TAX_POINT_CODE                 = p_line_rec.tax_point_code
8464     ,       TAX_RATE                       = p_line_rec.tax_rate
8465     ,       TAX_VALUE                      = p_line_rec.tax_value
8466     ,       TOP_MODEL_LINE_ID              = p_line_rec.top_model_line_id
8467     ,       UNIT_LIST_PRICE                = p_line_rec.unit_list_price
8468     ,       UNIT_LIST_PRICE_PER_PQTY       = p_line_rec.unit_list_price_per_pqty
8469     ,       UNIT_SELLING_PRICE             = p_line_rec.unit_selling_price
8470     ,       UNIT_SELLING_PRICE_PER_PQTY    = p_line_rec.unit_selling_price_per_pqty
8471     ,       VISIBLE_DEMAND_FLAG            = p_line_rec.visible_demand_flag
8472     ,       VEH_CUS_ITEM_CUM_KEY_ID        = p_line_rec.veh_cus_item_cum_key_id
8473     ,       SHIPPING_INSTRUCTIONS          = p_line_rec.shipping_instructions
8474     ,       PACKING_INSTRUCTIONS           = p_line_rec.packing_instructions
8475     ,       SERVICE_TXN_REASON_CODE        = p_line_rec.service_txn_reason_code
8476     ,       SERVICE_TXN_COMMENTS           = p_line_rec.service_txn_comments
8477     ,       SERVICE_DURATION               = p_line_rec.service_duration
8478     ,       SERVICE_PERIOD                 = p_line_rec.service_period
8479     ,       SERVICE_START_DATE             = p_line_rec.service_start_date
8480     ,       SERVICE_END_DATE               = p_line_rec.service_end_date
8481     ,       SERVICE_COTERMINATE_FLAG       = p_line_rec.service_coterminate_flag
8482     ,       UNIT_LIST_PERCENT           = p_line_rec.unit_list_percent
8483     ,       UNIT_SELLING_PERCENT        = p_line_rec.unit_selling_percent
8484     ,       UNIT_PERCENT_BASE_PRICE     = p_line_rec.unit_percent_base_price
8485     ,       SERVICE_NUMBER              = p_line_rec.service_number
8486     ,       SERVICE_REFERENCE_TYPE_CODE = p_line_rec.service_reference_type_code
8487     ,       SERVICE_REFERENCE_LINE_ID   = p_line_rec.service_reference_line_id
8488     ,       SERVICE_REFERENCE_SYSTEM_ID = p_line_rec.service_reference_system_id
8489     ,       TP_CONTEXT                  = p_line_rec.tp_context
8490     ,       TP_ATTRIBUTE1               = p_line_rec.tp_attribute1
8491     ,       TP_ATTRIBUTE2               = p_line_rec.tp_attribute2
8492     ,       TP_ATTRIBUTE3               = p_line_rec.tp_attribute3
8493     ,       TP_ATTRIBUTE4               = p_line_rec.tp_attribute4
8494     ,       TP_ATTRIBUTE5               = p_line_rec.tp_attribute5
8495     ,       TP_ATTRIBUTE6               = p_line_rec.tp_attribute6
8496     ,       TP_ATTRIBUTE7               = p_line_rec.tp_attribute7
8497     ,       TP_ATTRIBUTE8               = p_line_rec.tp_attribute8
8498     ,       TP_ATTRIBUTE9               = p_line_rec.tp_attribute9
8499     ,       TP_ATTRIBUTE10              = p_line_rec.tp_attribute10
8500     ,       TP_ATTRIBUTE11              = p_line_rec.tp_attribute11
8501     ,       TP_ATTRIBUTE12              = p_line_rec.tp_attribute12
8502     ,       TP_ATTRIBUTE13              = p_line_rec.tp_attribute13
8503     ,       TP_ATTRIBUTE14              = p_line_rec.tp_attribute14
8504     ,       TP_ATTRIBUTE15              = p_line_rec.tp_attribute15
8505     ,       FLOW_STATUS_CODE		     = p_line_rec.flow_status_code
8506     ,       MARKETING_SOURCE_CODE_ID    = p_line_rec.marketing_source_code_id
8507     ,       ORIGINAL_INVENTORY_ITEM_ID  = p_line_rec.Original_Inventory_Item_Id
8508     ,       ORIGINAL_ITEM_IDENTIFIER_TYPE = p_line_rec.Original_item_identifier_Type
8509     ,       ORIGINAL_ORDERED_ITEM_ID    = p_line_rec.Original_ordered_item_id
8510     ,       ORIGINAL_ORDERED_ITEM       = p_line_rec.Original_ordered_item
8511     ,       ITEM_RELATIONSHIP_TYPE      = p_line_rec.item_relationship_type
8512     ,       ITEM_SUBSTITUTION_TYPE_CODE = p_line_rec.Item_substitution_type_code
8513     ,       LATE_DEMAND_PENALTY_FACTOR  = p_line_rec.Late_Demand_Penalty_Factor
8514     ,       OVERRIDE_ATP_DATE_CODE      = p_line_rec.Override_atp_date_code
8515     ,       FIRM_DEMAND_FLAG            = p_line_rec.firm_demand_flag
8516     ,       EARLIEST_SHIP_DATE          = p_line_rec.earliest_ship_date
8517     ,       USER_ITEM_DESCRIPTION       = p_line_rec.User_Item_Description
8518     ,       BLANKET_NUMBER              = p_line_rec.Blanket_Number
8519     ,       BLANKET_LINE_NUMBER         = p_line_rec.Blanket_Line_Number
8520     ,       BLANKET_VERSION_NUMBER      = p_line_rec.Blanket_Version_Number
8521     --MRG B
8522     ,       UNIT_COST                   = p_line_rec.unit_cost
8523     --MRG E
8524     ,       LOCK_CONTROL                = l_lock_control
8525 -- Changes for quoting
8526     ,	    transaction_phase_code      = p_line_rec.transaction_phase_code
8527      ,      source_document_version_number = p_line_rec.source_document_version_number
8528 -- end changes for quoting
8529     ,       MINISITE_ID                 = p_line_rec.Minisite_Id
8530     ,       IB_OWNER                    = p_line_rec.Ib_owner
8531     ,       IB_INSTALLED_AT_LOCATION    = p_line_rec.Ib_INSTALLED_AT_LOCATION
8532     ,       IB_CURRENT_LOCATION         = p_line_rec.Ib_current_location
8533     ,       END_CUSTOMER_ID             = p_line_rec.End_Customer_Id
8534     ,       END_CUSTOMER_CONTACT_ID     = p_line_rec.End_Customer_CONTACT_Id
8535     ,       END_CUSTOMER_SITE_USE_ID    = p_line_rec.End_Customer_site_use_Id
8536  /*   ,       SUPPLIER_SIGNATURE          = p_line_rec.SUPPLIER_SIGNATURE
8537     ,       SUPPLIER_SIGNATURE_DATE     = p_line_rec.SUPPLIER_SIGNATURE_DATE
8538     ,       CUSTOMER_SIGNATURE          = p_line_rec.CUSTOMER_SIGNATURE
8539     ,       CUSTOMER_SIGNATURE_DATE     = p_line_rec.CUSTOMER_SIGNATURE_DATE
8540 */
8541     --retro{
8542     ,       RETROBILL_REQUEST_ID        = p_line_rec.retrobill_request_id
8543     --retro
8544     -- Override List Price
8545     ,       ORIGINAL_LIST_PRICE         = p_line_rec.original_list_price
8546 --key Transaction Dates
8547     ,       ORDER_FIRMED_DATE           = p_line_rec.order_firmed_date
8548     ,       ACTUAL_FULFILLMENT_DATE     = p_line_rec.actual_fulfillment_date
8549     --recurring charges
8550     , CHARGE_PERIODICITY_CODE = p_line_rec.charge_periodicity_code
8551 -- INVCONV
8552     ,       CANCELLED_QUANTITY2         = p_line_rec.cancelled_quantity2
8553     ,       SHIPPING_QUANTITY_UOM2      = p_line_rec.shipping_quantity_uom2
8554     ,       FULFILLED_QUANTITY2         = p_line_rec.fulfilled_quantity2
8555 --Customer Acceptance
8556     ,       CONTINGENCY_ID	        = p_line_rec.CONTINGENCY_ID
8557     ,       REVREC_EVENT_CODE	        = p_line_rec.REVREC_EVENT_CODE
8558     ,       REVREC_EXPIRATION_DAYS	= p_line_rec.REVREC_EXPIRATION_DAYS
8559     ,       ACCEPTED_QUANTITY	        = p_line_rec.ACCEPTED_QUANTITY
8560     ,       REVREC_COMMENTS	        = p_line_rec.REVREC_COMMENTS
8561     ,       REVREC_SIGNATURE	        = p_line_rec.REVREC_SIGNATURE
8562     ,       REVREC_SIGNATURE_DATE	= p_line_rec.REVREC_SIGNATURE_DATE
8563     ,       ACCEPTED_BY           	= p_line_rec.ACCEPTED_BY
8564     ,       REVREC_REFERENCE_DOCUMENT	= p_line_rec.REVREC_REFERENCE_DOCUMENT
8565     ,       REVREC_IMPLICIT_FLAG	= p_line_rec.REVREC_IMPLICIT_FLAG
8566     WHERE   LINE_ID 			   = p_line_rec.line_id
8567       AND   HEADER_ID 			   = p_line_rec.header_id ;
8568 
8569 	IF SQL%NOTFOUND THEN
8570         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8571         END IF;
8572 
8573     p_line_rec.lock_control := l_lock_control;
8574 
8575   if l_debug_level > 0 then
8576     oe_debug_pub.add('Exiting OE_LINE_UTIL.UPDATE_ROW', 1);
8577   end if;
8578 
8579 EXCEPTION
8580 
8581 
8582     WHEN OTHERS THEN
8583 
8584         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
8585         THEN
8586             OE_MSG_PUB.Add_Exc_Msg
8587             (   G_PKG_NAME
8588             ,   'Update_Row'
8589             );
8590         END IF;
8591 
8592         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8593 
8594 
8595 END Update_Row;
8596 
8597 
8598 /*-----------------------------------------------------------
8599 Procedure Insert_Row
8600 -----------------------------------------------------------*/
8601 
8602 PROCEDURE Insert_Row
8603 (   p_line_rec                      IN  OUT  NOCOPY OE_Order_PUB.Line_Rec_Type
8604 )
8605 IS
8606 l_org_id 	NUMBER ;
8607 l_sold_from_org NUMBER;
8608 l_upgraded_flag varchar2(1);
8609 l_lock_control  NUMBER:= 1;
8610 l_index         NUMBER;
8611 l_return_status VARCHAR2(1);
8612 
8613 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
8614 --bug 4446805
8615 l_price_request_code VARCHAR2(240);
8616 BEGIN
8617 
8618   if l_debug_level > 0 then
8619     oe_debug_pub.add('Entering OE_LINE_UTIL.INSERT_ROW', 1);
8620   end if;
8621 
8622  --MOAC change
8623  OE_GLOBALS.Set_Context;
8624  l_org_id := OE_GLOBALS.G_ORG_ID;
8625  IF l_org_id IS NULL THEN
8626      -- org_id is null, don't do insert. raise an error.
8627      IF l_debug_level > 0 then
8628           oe_debug_pub.ADD('Org_Id is NULL',1);
8629      END IF;
8630      FND_MESSAGE.SET_NAME('FND','MO_ORG_REQUIRED');
8631      FND_MSG_PUB.ADD;
8632      RAISE FND_API.G_EXC_ERROR;
8633  END IF;
8634  /*
8635 	    if l_org_id IS NULL THEN
8636 		    OE_GLOBALS.Set_Context;
8637 		    l_org_id := OE_GLOBALS.G_ORG_ID;
8638 	    end if;
8639  */
8640  l_sold_from_org := l_org_id;
8641 
8642 -- For the split's issue Bug #3721385
8643    if p_line_rec.split_from_line_id is not null and  p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
8644       (p_line_rec.sold_from_org_id is not null OR p_line_rec.sold_from_org_id <> FND_API.G_MISS_NUM)
8645    then
8646 
8647       l_sold_from_org := p_line_rec.sold_from_org_id;
8648    end if;
8649 
8650 -- This change is to ensure the upgraded flag is not populated through any
8651 -- source other than upgrade and split. Upgrade uses direct insertion and
8652 -- split follows this path.
8653 
8654 		IF  p_line_rec.split_from_line_id is null
8655 		THEN
8656 		  l_upgraded_flag := null;
8657 	     ELSE
8658 				l_upgraded_flag := p_line_rec.upgraded_flag;
8659 	     END IF;
8660 --bug 4446805 set the price request code to NULL if operation is create during splitting
8661         IF p_line_rec.split_from_line_id is not null AND
8662             p_line_rec.split_from_line_id <> FND_API.G_MISS_NUM AND
8663              p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE
8664         THEN
8665              l_price_request_code := NULL;
8666         ELSE
8667              l_price_request_code := p_line_rec.price_request_code;
8668         END IF;
8669 --End bug 4446805
8670 
8671     -- OPM 02/JUN/00 - Include process columns
8672     --                (ordered_quantity2,ordered_quantity_uom2,preferred_grade)
8673     -- =======================================================================
8674     INSERT  INTO OE_ORDER_LINES
8675     (       ACCOUNTING_RULE_ID
8676     ,       ACCOUNTING_RULE_DURATION
8677     ,       ACTUAL_ARRIVAL_DATE
8678     ,       ACTUAL_SHIPMENT_DATE
8679     ,       AGREEMENT_ID
8680     ,       ARRIVAL_SET_ID
8681     ,       ATO_LINE_ID
8682     ,       ATTRIBUTE1
8683     ,       ATTRIBUTE10
8684     ,       ATTRIBUTE11
8685     ,       ATTRIBUTE12
8686     ,       ATTRIBUTE13
8687     ,       ATTRIBUTE14
8688     ,       ATTRIBUTE15
8689     ,       ATTRIBUTE16   --For bug 2184255
8690     ,       ATTRIBUTE17
8691     ,       ATTRIBUTE18
8692     ,       ATTRIBUTE19
8693     ,       ATTRIBUTE2
8694     ,       ATTRIBUTE20
8695     ,       ATTRIBUTE3
8696     ,       ATTRIBUTE4
8697     ,       ATTRIBUTE5
8698     ,       ATTRIBUTE6
8699     ,       ATTRIBUTE7
8700     ,       ATTRIBUTE8
8701     ,       ATTRIBUTE9
8702     ,       AUTO_SELECTED_QUANTITY
8703     ,       AUTHORIZED_TO_SHIP_FLAG
8704     ,       BOOKED_FLAG
8705     ,       CANCELLED_FLAG
8706     ,       CANCELLED_QUANTITY
8707     ,       COMPONENT_CODE
8708     ,       COMPONENT_NUMBER
8709     ,       COMPONENT_SEQUENCE_ID
8710     ,       CONFIG_HEADER_ID
8711     ,       CONFIG_REV_NBR
8712     ,       CONFIG_DISPLAY_SEQUENCE
8713     ,       CONFIGURATION_ID
8714     ,       CONTEXT
8715     ,       CREATED_BY
8716     ,       CREATION_DATE
8717     ,       CREDIT_INVOICE_LINE_ID
8718     ,       CUSTOMER_LINE_NUMBER
8719     ,       CUSTOMER_SHIPMENT_NUMBER
8720     ,       CUSTOMER_ITEM_NET_PRICE
8721     ,       CUSTOMER_PAYMENT_TERM_ID
8722     ,       CUSTOMER_DOCK_CODE
8723     ,       CUSTOMER_JOB
8724     ,       CUSTOMER_PRODUCTION_LINE
8725     ,       CUST_PRODUCTION_SEQ_NUM
8726     ,       CUSTOMER_TRX_LINE_ID
8727     ,       CUST_MODEL_SERIAL_NUMBER
8728     ,       CUST_PO_NUMBER
8729     ,       DELIVERY_LEAD_TIME
8730     ,       DELIVER_TO_CONTACT_ID
8731     ,       DELIVER_TO_ORG_ID
8732     ,       DEMAND_BUCKET_TYPE_CODE
8733     ,       DEMAND_CLASS_CODE
8734     ,       DEP_PLAN_REQUIRED_FLAG
8735     --,       DROP_SHIP_FLAG
8736     ,       EARLIEST_ACCEPTABLE_DATE
8737     ,       END_ITEM_UNIT_NUMBER
8738     ,       EXPLOSION_DATE
8739     ,       FIRST_ACK_CODE
8740     ,       FIRST_ACK_DATE
8741     ,       FOB_POINT_CODE
8742     ,       FREIGHT_CARRIER_CODE
8743     ,       FREIGHT_TERMS_CODE
8744     ,       FULFILLED_QUANTITY
8745     ,       FULFILLED_FLAG
8746     ,       FULFILLMENT_METHOD_CODE
8747     ,       FULFILLMENT_DATE
8748     ,       GLOBAL_ATTRIBUTE1
8749     ,       GLOBAL_ATTRIBUTE10
8750     ,       GLOBAL_ATTRIBUTE11
8751     ,       GLOBAL_ATTRIBUTE12
8752     ,       GLOBAL_ATTRIBUTE13
8753     ,       GLOBAL_ATTRIBUTE14
8754     ,       GLOBAL_ATTRIBUTE15
8755     ,       GLOBAL_ATTRIBUTE16
8756     ,       GLOBAL_ATTRIBUTE17
8757     ,       GLOBAL_ATTRIBUTE18
8758     ,       GLOBAL_ATTRIBUTE19
8759     ,       GLOBAL_ATTRIBUTE2
8760     ,       GLOBAL_ATTRIBUTE20
8761     ,       GLOBAL_ATTRIBUTE3
8762     ,       GLOBAL_ATTRIBUTE4
8763     ,       GLOBAL_ATTRIBUTE5
8764     ,       GLOBAL_ATTRIBUTE6
8765     ,       GLOBAL_ATTRIBUTE7
8766     ,       GLOBAL_ATTRIBUTE8
8767     ,       GLOBAL_ATTRIBUTE9
8768     ,       GLOBAL_ATTRIBUTE_CATEGORY
8769     ,       HEADER_ID
8770     ,       INDUSTRY_ATTRIBUTE1
8771     ,       INDUSTRY_ATTRIBUTE10
8772     ,       INDUSTRY_ATTRIBUTE11
8773     ,       INDUSTRY_ATTRIBUTE12
8774     ,       INDUSTRY_ATTRIBUTE13
8775     ,       INDUSTRY_ATTRIBUTE14
8776     ,       INDUSTRY_ATTRIBUTE15
8777     ,       INDUSTRY_ATTRIBUTE16
8778     ,       INDUSTRY_ATTRIBUTE17
8779     ,       INDUSTRY_ATTRIBUTE18
8780     ,       INDUSTRY_ATTRIBUTE19
8781     ,       INDUSTRY_ATTRIBUTE20
8782     ,       INDUSTRY_ATTRIBUTE21
8783     ,       INDUSTRY_ATTRIBUTE22
8784     ,       INDUSTRY_ATTRIBUTE23
8785     ,       INDUSTRY_ATTRIBUTE24
8786     ,       INDUSTRY_ATTRIBUTE25
8787     ,       INDUSTRY_ATTRIBUTE26
8788     ,       INDUSTRY_ATTRIBUTE27
8789     ,       INDUSTRY_ATTRIBUTE28
8790     ,       INDUSTRY_ATTRIBUTE29
8791     ,       INDUSTRY_ATTRIBUTE30
8792     ,       INDUSTRY_ATTRIBUTE2
8793     ,       INDUSTRY_ATTRIBUTE3
8794     ,       INDUSTRY_ATTRIBUTE4
8795     ,       INDUSTRY_ATTRIBUTE5
8796     ,       INDUSTRY_ATTRIBUTE6
8797     ,       INDUSTRY_ATTRIBUTE7
8798     ,       INDUSTRY_ATTRIBUTE8
8799     ,       INDUSTRY_ATTRIBUTE9
8800     ,       INDUSTRY_CONTEXT
8801     ,       INTMED_SHIP_TO_CONTACT_ID
8802     ,       INTMED_SHIP_TO_ORG_ID
8803     ,       INVENTORY_ITEM_ID
8804     ,       INVOICE_INTERFACE_STATUS_CODE
8805     ,       INVOICE_TO_CONTACT_ID
8806     ,       INVOICE_TO_ORG_ID
8807     ,       INVOICED_QUANTITY
8808     ,       INVOICING_RULE_ID
8809     ,       ORDERED_ITEM_ID
8810     ,       ITEM_IDENTIFIER_TYPE
8811     ,       ORDERED_ITEM
8812     ,       ITEM_REVISION
8813     ,       ITEM_TYPE_CODE
8814     ,       LAST_ACK_CODE
8815     ,       LAST_ACK_DATE
8816     ,       LAST_UPDATED_BY
8817     ,       LAST_UPDATE_DATE
8818     ,       LAST_UPDATE_LOGIN
8819     ,       LATEST_ACCEPTABLE_DATE
8820     ,       LINE_CATEGORY_CODE
8821     ,       LINE_ID
8822     ,       LINE_NUMBER
8823     ,       LINE_TYPE_ID
8824     ,       LINK_TO_LINE_ID
8825     ,       MODEL_GROUP_NUMBER
8826    -- ,       MFG_COMPONENT_SEQUENCE_ID
8827     ,       MFG_LEAD_TIME
8828     ,       OPEN_FLAG
8829     ,       OPTION_FLAG
8830     ,       OPTION_NUMBER
8831     ,       ORDERED_QUANTITY
8832     ,       ORDERED_QUANTITY2           --OPM Added 02/JUN/00
8833     ,       ORDER_QUANTITY_UOM
8834     ,       ORDERED_QUANTITY_UOM2       --OPM Added 02/JUN/00
8835     ,       ORG_ID                      -- MOAC change
8836     ,       ORDER_SOURCE_ID
8837     ,       ORIG_SYS_DOCUMENT_REF
8838     ,       ORIG_SYS_LINE_REF
8839     ,       ORIG_SYS_SHIPMENT_REF
8840     ,       CHANGE_SEQUENCE
8841     ,       OVER_SHIP_REASON_CODE
8842     ,       OVER_SHIP_RESOLVED_FLAG
8843     ,       PAYMENT_TERM_ID
8844     ,       PLANNING_PRIORITY
8845     ,       PREFERRED_GRADE             --OPM Added 02/JUN/00
8846     ,       PRICE_LIST_ID
8847     ,       PRICE_REQUEST_CODE          --PROMOTIONS SEP/01
8848     ,       PRICING_ATTRIBUTE1
8849     ,       PRICING_ATTRIBUTE10
8850     ,       PRICING_ATTRIBUTE2
8851     ,       PRICING_ATTRIBUTE3
8852     ,       PRICING_ATTRIBUTE4
8853     ,       PRICING_ATTRIBUTE5
8854     ,       PRICING_ATTRIBUTE6
8855     ,       PRICING_ATTRIBUTE7
8856     ,       PRICING_ATTRIBUTE8
8857     ,       PRICING_ATTRIBUTE9
8858     ,       PRICING_CONTEXT
8859     ,       PRICING_DATE
8860     ,       PRICING_QUANTITY
8861     ,       PRICING_QUANTITY_UOM
8862     ,       PROGRAM_APPLICATION_ID
8863     ,       PROGRAM_ID
8864     ,       PROGRAM_UPDATE_DATE
8865     ,       PROJECT_ID
8866     ,       PROMISE_DATE
8867     ,       RE_SOURCE_FLAG
8868     ,       REFERENCE_CUSTOMER_TRX_LINE_ID
8869     ,       REFERENCE_HEADER_ID
8870     ,       REFERENCE_LINE_ID
8871     ,       REFERENCE_TYPE
8872     ,       REQUEST_DATE
8873     ,       REQUEST_ID
8874     ,       RETURN_ATTRIBUTE1
8875     ,       RETURN_ATTRIBUTE10
8876     ,       RETURN_ATTRIBUTE11
8877     ,       RETURN_ATTRIBUTE12
8878     ,       RETURN_ATTRIBUTE13
8879     ,       RETURN_ATTRIBUTE14
8880     ,       RETURN_ATTRIBUTE15
8881     ,       RETURN_ATTRIBUTE2
8882     ,       RETURN_ATTRIBUTE3
8883     ,       RETURN_ATTRIBUTE4
8884     ,       RETURN_ATTRIBUTE5
8885     ,       RETURN_ATTRIBUTE6
8886     ,       RETURN_ATTRIBUTE7
8887     ,       RETURN_ATTRIBUTE8
8888     ,       RETURN_ATTRIBUTE9
8889     ,       RETURN_CONTEXT
8890     ,       RETURN_REASON_CODE
8891     ,       RLA_SCHEDULE_TYPE_CODE
8892     ,       SALESREP_ID
8893     ,       SCHEDULE_ARRIVAL_DATE
8894     ,       SCHEDULE_SHIP_DATE
8895     ,       SCHEDULE_STATUS_CODE
8896     ,       SHIPMENT_NUMBER
8897     ,       SHIPMENT_PRIORITY_CODE
8898     ,       SHIPPED_QUANTITY
8899     ,       SHIPPED_QUANTITY2 -- OPM B1661023 04/02/01
8900     ,       SHIPPING_METHOD_CODE
8901     ,       SHIPPING_QUANTITY
8902     ,       SHIPPING_QUANTITY2 -- OPM B1661023 04/02/01
8903     ,       SHIPPING_QUANTITY_UOM
8904     ,       SHIP_FROM_ORG_ID
8905     ,       SUBINVENTORY
8906     ,       SHIP_SET_ID
8907     ,       SHIP_TOLERANCE_ABOVE
8908     ,       SHIP_TOLERANCE_BELOW
8909     ,       SHIPPABLE_FLAG
8910     ,       SHIPPING_INTERFACED_FLAG
8911     ,       SHIP_TO_CONTACT_ID
8912     ,       SHIP_TO_ORG_ID
8913     ,       SHIP_MODEL_COMPLETE_FLAG
8914     ,       SOLD_TO_ORG_ID
8915     ,       SOLD_FROM_ORG_ID
8916     ,       SORT_ORDER
8917     ,       SOURCE_DOCUMENT_ID
8918     ,       SOURCE_DOCUMENT_LINE_ID
8919     ,       SOURCE_DOCUMENT_TYPE_ID
8920     ,       SOURCE_TYPE_CODE
8921     ,       SPLIT_FROM_LINE_ID
8922     ,       LINE_SET_ID
8923     ,       SPLIT_BY
8924     ,       model_remnant_flag
8925     ,       TASK_ID
8926     ,       TAX_CODE
8927     ,       TAX_DATE
8928     ,       TAX_EXEMPT_FLAG
8929     ,       TAX_EXEMPT_NUMBER
8930     ,       TAX_EXEMPT_REASON_CODE
8931     ,       TAX_POINT_CODE
8932     ,       TAX_RATE
8933     ,       TAX_VALUE
8934     ,       TOP_MODEL_LINE_ID
8935     ,       UNIT_LIST_PRICE
8936     ,       UNIT_LIST_PRICE_PER_PQTY
8937     ,       UNIT_SELLING_PRICE
8938     ,       UNIT_SELLING_PRICE_PER_PQTY
8939     ,       VISIBLE_DEMAND_FLAG
8940     ,       VEH_CUS_ITEM_CUM_KEY_ID
8941     ,       SHIPPING_INSTRUCTIONS
8942     ,       PACKING_INSTRUCTIONS
8943     ,       SERVICE_TXN_REASON_CODE
8944     ,       SERVICE_TXN_COMMENTS
8945     ,       SERVICE_DURATION
8946     ,       SERVICE_PERIOD
8947     ,       SERVICE_START_DATE
8948     ,       SERVICE_END_DATE
8949     ,       SERVICE_COTERMINATE_FLAG
8950     ,       UNIT_LIST_PERCENT
8951     ,       UNIT_SELLING_PERCENT
8952     ,       UNIT_PERCENT_BASE_PRICE
8953     ,       SERVICE_NUMBER
8954     ,       SERVICE_REFERENCE_TYPE_CODE
8955     ,       SERVICE_REFERENCE_LINE_ID
8956     ,       SERVICE_REFERENCE_SYSTEM_ID
8957     ,       TP_CONTEXT
8958     ,       TP_ATTRIBUTE1
8959     ,       TP_ATTRIBUTE2
8960     ,       TP_ATTRIBUTE3
8961     ,       TP_ATTRIBUTE4
8962     ,       TP_ATTRIBUTE5
8963     ,       TP_ATTRIBUTE6
8964     ,       TP_ATTRIBUTE7
8965     ,       TP_ATTRIBUTE8
8966     ,       TP_ATTRIBUTE9
8967     ,       TP_ATTRIBUTE10
8968     ,       TP_ATTRIBUTE11
8969     ,       TP_ATTRIBUTE12
8970     ,       TP_ATTRIBUTE13
8971     ,       TP_ATTRIBUTE14
8972     ,       TP_ATTRIBUTE15
8973     ,       FLOW_STATUS_CODE
8974     ,       MARKETING_SOURCE_CODE_ID
8975     ,       CALCULATE_PRICE_FLAG
8976     ,       COMMITMENT_ID
8977     ,       UPGRADED_FLAG
8978     ,       ORIGINAL_INVENTORY_ITEM_ID
8979     ,       ORIGINAL_ITEM_IDENTIFIER_TYPE
8980     ,       ORIGINAL_ORDERED_ITEM_ID
8981     ,       ORIGINAL_ORDERED_ITEM
8982     ,       ITEM_RELATIONSHIP_TYPE
8983     ,       ITEM_SUBSTITUTION_TYPE_CODE
8984     ,       LATE_DEMAND_PENALTY_FACTOR
8985     ,       OVERRIDE_ATP_DATE_CODE
8986     ,       FIRM_DEMAND_FLAG
8987     ,       EARLIEST_SHIP_DATE
8988     ,       USER_ITEM_DESCRIPTION
8989     ,       BLANKET_NUMBER
8990     ,       BLANKET_LINE_NUMBER
8991     ,       BLANKET_VERSION_NUMBER
8992 --MRG B
8993     ,       UNIT_COST
8994 --MRG E
8995     ,       LOCK_CONTROL
8996 -- Changes for quoting
8997     ,	    transaction_phase_code
8998     ,       source_document_version_number
8999 -- end changes for quoting
9000    ,        Minisite_ID
9001    ,        Ib_Owner
9002    ,        Ib_installed_at_location
9003    ,        Ib_current_location
9004    ,        End_customer_ID
9005    ,        End_customer_contact_ID
9006    ,        End_customer_site_use_ID
9007  /*  ,        Supplier_signature
9008    ,        Supplier_signature_date
9009    ,        Customer_signature
9010    ,        Customer_signature_date  */
9011 --retro{
9012     ,       RETROBILL_REQUEST_ID
9013 --retro}
9014     ,       ORIGINAL_LIST_PRICE  -- Override List Price
9015  -- Key Transaction Dates
9016     ,       order_firmed_date
9017     ,       actual_fulfillment_date
9018     --recurring charges
9019     ,       charge_periodicity_code
9020 -- INVCONV
9021     ,       CANCELLED_QUANTITY2
9022     ,       SHIPPING_QUANTITY_UOM2
9023     ,       FULFILLED_QUANTITY2
9024 --Customer Acceptance
9025     ,       CONTINGENCY_ID
9026     ,       REVREC_EVENT_CODE
9027     ,       REVREC_EXPIRATION_DAYS
9028     ,       ACCEPTED_QUANTITY
9029     ,       REVREC_COMMENTS
9030     ,       REVREC_SIGNATURE
9031     ,       REVREC_SIGNATURE_DATE
9032     ,       ACCEPTED_BY
9033     ,       REVREC_REFERENCE_DOCUMENT
9034     ,       REVREC_IMPLICIT_FLAG
9035 
9036     )
9037     VALUES
9038     (       p_line_rec.accounting_rule_id
9039     ,       p_line_rec.accounting_rule_duration
9040     ,       p_line_rec.actual_arrival_date
9041     ,       p_line_rec.actual_shipment_date
9042     ,       p_line_rec.agreement_id
9043     ,       p_line_rec.arrival_set_id
9044     ,       p_line_rec.ato_line_id
9045     ,       p_line_rec.attribute1
9046     ,       p_line_rec.attribute10
9047     ,       p_line_rec.attribute11
9048     ,       p_line_rec.attribute12
9049     ,       p_line_rec.attribute13
9050     ,       p_line_rec.attribute14
9051     ,       p_line_rec.attribute15
9052     ,       p_line_rec.attribute16   --For bug 2184255
9053     ,       p_line_rec.attribute17
9054     ,       p_line_rec.attribute18
9055     ,       p_line_rec.attribute19
9056     ,       p_line_rec.attribute2
9057     ,       p_line_rec.attribute20
9058     ,       p_line_rec.attribute3
9059     ,       p_line_rec.attribute4
9060     ,       p_line_rec.attribute5
9061     ,       p_line_rec.attribute6
9062     ,       p_line_rec.attribute7
9063     ,       p_line_rec.attribute8
9064     ,       p_line_rec.attribute9
9065     ,       p_line_rec.auto_selected_quantity
9066     ,       p_line_rec.authorized_to_ship_flag
9067     ,       p_line_rec.booked_flag
9068     ,       p_line_rec.cancelled_flag
9069     ,       p_line_rec.cancelled_quantity
9070     ,       p_line_rec.component_code
9071     ,       p_line_rec.component_number
9072     ,       p_line_rec.component_sequence_id
9073     ,       p_line_rec.config_header_id
9074     ,       p_line_rec.config_rev_nbr
9075     ,       p_line_rec.config_display_sequence
9076     ,       p_line_rec.configuration_id
9077     ,       p_line_rec.context
9078     ,       p_line_rec.created_by
9079     ,       p_line_rec.creation_date
9080     ,       p_line_rec.credit_invoice_line_id
9081     ,       p_line_rec.customer_line_number
9082     ,       p_line_rec.customer_shipment_number
9083     ,       p_line_rec.customer_item_net_price
9084     ,       p_line_rec.customer_payment_term_id
9085     ,       p_line_rec.customer_dock_code
9086     ,       p_line_rec.customer_job
9087     ,       p_line_rec.customer_production_line
9088     ,       p_line_rec.cust_production_seq_num
9089     ,       p_line_rec.customer_trx_line_id
9090     ,       p_line_rec.cust_model_serial_number
9091     ,       p_line_rec.cust_po_number
9092     ,       p_line_rec.delivery_lead_time
9093     ,       p_line_rec.deliver_to_contact_id
9094     ,       p_line_rec.deliver_to_org_id
9095     ,       p_line_rec.demand_bucket_type_code
9096     ,       p_line_rec.demand_class_code
9097     ,       p_line_rec.dep_plan_required_flag
9098     --,       p_line_rec.drop_ship_flag
9099     ,       p_line_rec.earliest_acceptable_date
9100     ,       p_line_rec.end_item_unit_number
9101     ,       p_line_rec.explosion_date
9102     ,       p_line_rec.first_ack_code
9103     ,       p_line_rec.first_ack_date
9104     ,       p_line_rec.fob_point_code
9105     ,       p_line_rec.freight_carrier_code
9106     ,       p_line_rec.freight_terms_code
9107     ,       p_line_rec.fulfilled_quantity
9108     ,       p_line_rec.fulfilled_flag
9109     ,       p_line_rec.fulfillment_method_code
9110     ,       p_line_rec.fulfillment_date
9111     ,       p_line_rec.global_attribute1
9112     ,       p_line_rec.global_attribute10
9113     ,       p_line_rec.global_attribute11
9114     ,       p_line_rec.global_attribute12
9115     ,       p_line_rec.global_attribute13
9116     ,       p_line_rec.global_attribute14
9117     ,       p_line_rec.global_attribute15
9118     ,       p_line_rec.global_attribute16
9119     ,       p_line_rec.global_attribute17
9120     ,       p_line_rec.global_attribute18
9121     ,       p_line_rec.global_attribute19
9122     ,       p_line_rec.global_attribute2
9123     ,       p_line_rec.global_attribute20
9124     ,       p_line_rec.global_attribute3
9125     ,       p_line_rec.global_attribute4
9126     ,       p_line_rec.global_attribute5
9127     ,       p_line_rec.global_attribute6
9128     ,       p_line_rec.global_attribute7
9129     ,       p_line_rec.global_attribute8
9130     ,       p_line_rec.global_attribute9
9131     ,       p_line_rec.global_attribute_category
9132     ,       p_line_rec.header_id
9133     ,       p_line_rec.industry_attribute1
9134     ,       p_line_rec.industry_attribute10
9135     ,       p_line_rec.industry_attribute11
9136     ,       p_line_rec.industry_attribute12
9137     ,       p_line_rec.industry_attribute13
9138     ,       p_line_rec.industry_attribute14
9139     ,       p_line_rec.industry_attribute15
9140     ,       p_line_rec.industry_attribute16
9141     ,       p_line_rec.industry_attribute17
9142     ,       p_line_rec.industry_attribute18
9143     ,       p_line_rec.industry_attribute19
9144     ,       p_line_rec.industry_attribute20
9145     ,       p_line_rec.industry_attribute21
9146     ,       p_line_rec.industry_attribute22
9147     ,       p_line_rec.industry_attribute23
9148     ,       p_line_rec.industry_attribute24
9149     ,       p_line_rec.industry_attribute25
9150     ,       p_line_rec.industry_attribute26
9151     ,       p_line_rec.industry_attribute27
9152     ,       p_line_rec.industry_attribute28
9153     ,       p_line_rec.industry_attribute29
9154     ,       p_line_rec.industry_attribute30
9155     ,       p_line_rec.industry_attribute2
9156     ,       p_line_rec.industry_attribute3
9157     ,       p_line_rec.industry_attribute4
9158     ,       p_line_rec.industry_attribute5
9159     ,       p_line_rec.industry_attribute6
9160     ,       p_line_rec.industry_attribute7
9161     ,       p_line_rec.industry_attribute8
9162     ,       p_line_rec.industry_attribute9
9163     ,       p_line_rec.industry_context
9164     ,       p_line_rec.intermed_ship_to_contact_id
9165     ,       p_line_rec.intermed_ship_to_org_id
9166     ,       p_line_rec.inventory_item_id
9167     ,       p_line_rec.invoice_interface_status_code
9168     ,       p_line_rec.invoice_to_contact_id
9169     ,       p_line_rec.invoice_to_org_id
9170     ,       p_line_rec.invoiced_quantity
9171     ,       p_line_rec.invoicing_rule_id
9172     ,       p_line_rec.ordered_item_id
9173     ,       p_line_rec.item_identifier_type
9174     ,       p_line_rec.ordered_item
9175     ,       p_line_rec.item_revision
9176     ,       p_line_rec.item_type_code
9177     ,       p_line_rec.last_ack_code
9178     ,       p_line_rec.last_ack_date
9179     ,       p_line_rec.last_updated_by
9180     ,       p_line_rec.last_update_date
9181     ,       p_line_rec.last_update_login
9182     ,       p_line_rec.latest_acceptable_date
9183     ,       p_line_rec.line_category_code
9184     ,       p_line_rec.line_id
9185     ,       p_line_rec.line_number
9186     ,       p_line_rec.line_type_id
9187     ,       p_line_rec.link_to_line_id
9188     ,       p_line_rec.model_group_number
9189     --,       p_line_rec.mfg_component_sequence_id
9190     ,       p_line_rec.mfg_lead_time
9191     ,       p_line_rec.open_flag
9192     ,       p_line_rec.option_flag
9193     ,       p_line_rec.option_number
9194     ,       p_line_rec.ordered_quantity
9195     ,       p_line_rec.ordered_quantity2          --OPM 02/JUN/00
9196     ,       p_line_rec.order_quantity_uom
9197     ,       p_line_rec.ordered_quantity_uom2      --OPM 02/JUN/00
9198     ,       l_org_id                              --MOAC change
9199     ,       p_line_rec.order_source_id
9200     ,       p_line_rec.orig_sys_document_ref
9201     ,       p_line_rec.orig_sys_line_ref
9202     ,       p_line_rec.orig_sys_shipment_ref
9203     ,       p_line_rec.change_sequence
9204     ,       p_line_rec.over_ship_reason_code
9205     ,       p_line_rec.over_ship_resolved_flag
9206     ,       p_line_rec.payment_term_id
9207     ,       p_line_rec.planning_priority
9208     ,       p_line_rec.preferred_grade            --OPM 02/JUN/00
9209     ,       p_line_rec.price_list_id
9210     ,       l_price_request_code         --PROMOTIONS SEP/01   --bug 4446805
9211     ,       p_line_rec.pricing_attribute1
9212     ,       p_line_rec.pricing_attribute10
9213     ,       p_line_rec.pricing_attribute2
9214     ,       p_line_rec.pricing_attribute3
9215     ,       p_line_rec.pricing_attribute4
9216     ,       p_line_rec.pricing_attribute5
9217     ,       p_line_rec.pricing_attribute6
9218     ,       p_line_rec.pricing_attribute7
9219     ,       p_line_rec.pricing_attribute8
9220     ,       p_line_rec.pricing_attribute9
9221     ,       p_line_rec.pricing_context
9222     ,       p_line_rec.pricing_date
9223     ,       p_line_rec.pricing_quantity
9224     ,       p_line_rec.pricing_quantity_uom
9225     ,       p_line_rec.program_application_id
9226     ,       p_line_rec.program_id
9227     ,       p_line_rec.program_update_date
9228     ,       p_line_rec.project_id
9229     ,       p_line_rec.promise_date
9230     ,       p_line_rec.re_source_flag
9231     ,       p_line_rec.reference_customer_trx_line_id
9232     ,       p_line_rec.reference_header_id
9233     ,       p_line_rec.reference_line_id
9234     ,       p_line_rec.reference_type
9235     ,       p_line_rec.request_date
9236     ,       p_line_rec.request_id
9237     ,       p_line_rec.return_attribute1
9238     ,       p_line_rec.return_attribute10
9239     ,       p_line_rec.return_attribute11
9240     ,       p_line_rec.return_attribute12
9241     ,       p_line_rec.return_attribute13
9242     ,       p_line_rec.return_attribute14
9243     ,       p_line_rec.return_attribute15
9244     ,       p_line_rec.return_attribute2
9245     ,       p_line_rec.return_attribute3
9246     ,       p_line_rec.return_attribute4
9247     ,       p_line_rec.return_attribute5
9248     ,       p_line_rec.return_attribute6
9249     ,       p_line_rec.return_attribute7
9250     ,       p_line_rec.return_attribute8
9251     ,       p_line_rec.return_attribute9
9252     ,       p_line_rec.return_context
9253     ,       p_line_rec.return_reason_code
9254     ,       p_line_rec.rla_schedule_type_code
9255     ,       p_line_rec.salesrep_id
9256     ,       p_line_rec.schedule_arrival_date
9257     ,       p_line_rec.schedule_ship_date
9258     ,       p_line_rec.schedule_status_code
9259     ,       p_line_rec.shipment_number
9260     ,       p_line_rec.shipment_priority_code
9261     ,       p_line_rec.shipped_quantity
9262     ,       p_line_rec.shipped_quantity2 -- OPM B1661023 04/02/01
9263     ,       p_line_rec.shipping_method_code
9264     ,       p_line_rec.shipping_quantity
9265     ,       p_line_rec.shipping_quantity2    -- OPM B1661023 04/02/01
9266     ,       p_line_rec.shipping_quantity_uom
9267     ,       p_line_rec.ship_from_org_id
9268     ,       p_line_Rec.subinventory
9269     ,       p_line_rec.ship_set_id
9270     ,       p_line_rec.ship_tolerance_above
9271     ,       p_line_rec.ship_tolerance_below
9272     ,       p_line_rec.shippable_flag
9273     ,       p_line_rec.shipping_interfaced_flag
9274     ,       p_line_rec.ship_to_contact_id
9275     ,       p_line_rec.ship_to_org_id
9276     ,       p_line_rec.ship_model_complete_flag
9277 
9278     ,       p_line_rec.sold_to_org_id
9279     ,       l_sold_from_org
9280     ,       p_line_rec.sort_order
9281     ,       p_line_rec.source_document_id
9282     ,       p_line_rec.source_document_line_id
9283     ,       p_line_rec.source_document_type_id
9284     ,       p_line_rec.source_type_code
9285     ,       p_line_rec.split_from_line_id
9286     ,       p_line_rec.line_set_id
9287     ,       p_line_rec.split_by
9288     ,       p_line_rec.model_remnant_flag
9289     ,       p_line_rec.task_id
9290     ,       p_line_rec.tax_code
9291     ,       p_line_rec.tax_date
9292     ,       p_line_rec.tax_exempt_flag
9293     ,       p_line_rec.tax_exempt_number
9294     ,       p_line_rec.tax_exempt_reason_code
9295     ,       p_line_rec.tax_point_code
9296     ,       p_line_rec.tax_rate
9297     ,       p_line_rec.tax_value
9298     ,       p_line_rec.top_model_line_id
9299     ,       p_line_rec.unit_list_price
9300     ,       p_line_rec.unit_list_price_per_pqty
9301     ,       p_line_rec.unit_selling_price
9302     ,       p_line_rec.unit_selling_price_per_pqty
9303     ,       p_line_rec.visible_demand_flag
9304     ,       p_line_rec.veh_cus_item_cum_key_id
9305     ,       p_line_rec.shipping_instructions
9306     ,       p_line_rec.packing_instructions
9307     ,       p_line_rec.service_txn_reason_code
9308     ,       p_line_rec.service_txn_comments
9309     ,       p_line_rec.service_duration
9310     ,       p_line_rec.service_period
9311     ,       p_line_rec.service_start_date
9312     ,       p_line_rec.service_end_date
9313     ,       p_line_rec.service_coterminate_flag
9314     ,       p_line_rec.unit_list_percent
9315     ,       p_line_rec.unit_selling_percent
9316     ,       p_line_rec.unit_percent_base_price
9317     ,       p_line_rec.service_number
9318     ,       p_line_rec.service_reference_type_code
9319     ,       p_line_rec.service_reference_line_id
9320     ,       p_line_rec.service_reference_system_id
9321     ,       p_line_rec.tp_context
9322     ,       p_line_rec.tp_attribute1
9323     ,       p_line_rec.tp_attribute2
9324     ,       p_line_rec.tp_attribute3
9325     ,       p_line_rec.tp_attribute4
9326     ,       p_line_rec.tp_attribute5
9327     ,       p_line_rec.tp_attribute6
9328     ,       p_line_rec.tp_attribute7
9329     ,       p_line_rec.tp_attribute8
9330     ,       p_line_rec.tp_attribute9
9331     ,       p_line_rec.tp_attribute10
9332     ,       p_line_rec.tp_attribute11
9333     ,       p_line_rec.tp_attribute12
9334     ,       p_line_rec.tp_attribute13
9335     ,       p_line_rec.tp_attribute14
9336     ,       p_line_rec.tp_attribute15
9337     ,       p_line_rec.flow_status_code
9338     ,       p_line_rec.marketing_source_code_id
9339     ,       p_line_rec.calculate_price_flag
9340     ,       p_line_rec.commitment_id
9341     ,       l_upgraded_flag
9342     ,       p_line_rec.original_inventory_item_id
9343     ,       p_line_rec.original_item_identifier_Type
9344     ,       p_line_rec.original_ordered_item_id
9345     ,       p_line_rec.original_ordered_item
9346     ,       p_line_rec.item_relationship_type
9347     ,       p_line_rec.item_substitution_type_code
9348     ,       p_line_rec.late_demand_penalty_factor
9349     ,       p_line_rec.Override_atp_date_code
9350     ,       p_line_rec.Firm_demand_flag
9351     ,       p_line_rec.Earliest_ship_date
9352     ,       p_line_rec.user_item_description
9353     ,       p_line_rec.Blanket_Number
9354     ,       p_line_rec.Blanket_Line_Number
9355     ,       p_line_rec.Blanket_Version_Number
9356 --MRG B
9357     ,       p_line_rec.unit_cost
9358 --MRG E
9359     ,       l_lock_control
9360 -- Changes for quoting
9361     ,	    p_line_rec.transaction_phase_code
9362     ,       p_line_rec.source_document_version_number
9363 -- end changes for quoting
9364    ,        p_line_rec.Minisite_Id
9365    ,        p_line_rec.Ib_owner
9366    ,        p_line_rec.Ib_installed_at_location
9367    ,        p_line_rec.Ib_current_location
9368    ,        p_line_rec.End_customer_Id
9369    ,        p_line_rec.End_customer_contact_Id
9370    ,        p_line_rec.End_customer_site_use_Id
9371  /*  ,        p_line_rec.Supplier_signature
9372    ,        p_line_rec.Supplier_signature_date
9373    ,        p_line_rec.customer_signature
9374    ,        p_line_rec.customer_signature_date */
9375 --retro{
9376    ,        p_line_rec.retrobill_request_id
9377 --retro}
9378    ,        p_line_rec.original_list_price -- Override List Price
9379 -- key Transaction Dates
9380    ,        p_line_rec.order_firmed_date
9381    ,        p_line_rec.actual_fulfillment_date
9382    --recurring charges
9383    ,        p_line_rec.charge_periodicity_code
9384 -- INVCONV
9385     ,       p_line_rec.cancelled_quantity2
9386     ,       p_line_rec.shipping_quantity_uom2
9387     ,       p_line_rec.fulfilled_quantity2
9388     ,       p_line_rec.CONTINGENCY_ID
9389     ,       p_line_rec.REVREC_EVENT_CODE
9390     ,       p_line_rec.REVREC_EXPIRATION_DAYS
9391     ,       p_line_rec.ACCEPTED_QUANTITY
9392     ,       p_line_rec.REVREC_COMMENTS
9393     ,       p_line_rec.REVREC_SIGNATURE
9394     ,       p_line_rec.REVREC_SIGNATURE_DATE
9395     ,       p_line_rec.ACCEPTED_BY
9396     ,       p_line_rec.REVREC_REFERENCE_DOCUMENT
9397     ,       p_line_rec.REVREC_IMPLICIT_FLAG
9398 
9399   );
9400 
9401     p_line_rec.lock_control := l_lock_control;
9402 
9403     -- calling notification framework to update global picture
9404  -- check code release level first. Notification framework is at Pack H level
9405   IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508' THEN
9406       OE_ORDER_UTIL.Update_Global_Picture(p_Upd_New_Rec_If_Exists => True,
9407                     p_Line_rec =>p_line_rec,
9408                     p_old_line_rec => NULL,
9409                     p_line_id => p_line_rec.line_id,
9410                     x_index => l_index,
9411                     x_return_status => l_return_status);
9412       if l_debug_level > 0 then
9413        OE_DEBUG_PUB.ADD('Update_Global Return Status from OE_LINE_UTIL.inset_row is: ' || l_return_status);
9414        OE_DEBUG_PUB.ADD('returned index is: ' || l_index ,1);
9415       end if;
9416        IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
9417          if l_debug_level > 0 then
9418           OE_DEBUG_PUB.ADD('EVENT NOTIFY - Unexpected Error');
9419           OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.insert_ROW', 1);
9420          end if;
9421 	  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9422         ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
9423           if l_debug_level > 0 then
9424            OE_DEBUG_PUB.ADD('Update_Global_Picture Error in OE_LINE_UTIL.insert_row');
9425            OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.insert_ROW', 1);
9426           end if;
9427 	  RAISE FND_API.G_EXC_ERROR;
9428         END IF;
9429     END IF; /*code_release_code*/
9430  -- notification framework end
9431 
9432   if l_debug_level > 0 then
9433     oe_debug_pub.add('Exiting OE_LINE_UTIL.INSERT_ROW', 1);
9434   end if;
9435 
9436 EXCEPTION
9437 
9438     WHEN OTHERS THEN
9439 
9440         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
9441         THEN
9442             OE_MSG_PUB.Add_Exc_Msg
9443             (   G_PKG_NAME
9444             ,   'Insert_Row'
9445             );
9446         END IF;
9447         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9448 
9449 END Insert_Row;
9450 
9451 
9452 /*-----------------------------------------------------------
9453 Procedure Delete_Row
9454 -----------------------------------------------------------*/
9455 
9456 PROCEDURE Delete_Row
9457 ( p_line_id       IN  NUMBER := FND_API.G_MISS_NUM
9458  ,p_header_id     IN  NUMBER := FND_API.G_MISS_NUM)
9459 IS
9460   l_return_status            VARCHAR2(30);
9461   l_org_id                   NUMBER;
9462   l_line_rec                 oe_order_pub.line_rec_type;
9463   lsqlstmt                   varchar2(4000) ;
9464   lvariable1                 varchar2(80);
9465   lvariable2                 number;
9466   TYPE llinecur IS REF       CURSOR;
9467   llinetbl                   llinecur;
9468   llinetbl_svc               llinecur; -- for bug 2408321
9469   l_tmp_line_id              NUMBER;   -- for bug 2408321
9470   l_line_id                  number;
9471   l_item_type_code           varchar2(30);
9472   l_line_category_code       varchar2(30);
9473   l_config_header_id         number;
9474   l_config_rev_nbr           number;
9475   l_in_line_id               number := p_line_id;
9476   l_column                   varchar2(30);
9477   l_line_tbl                 OE_Order_PUB.Line_Tbl_Type;
9478   l_schedule_status_code     VARCHAR2(30);
9479   l_shipping_interfaced_flag VARCHAR2(1);
9480   l_ordered_quantity         NUMBER;           -- BUG 2670775 Reverse Limits
9481   l_price_request_code       varchar2(240);    -- BUG 2670775 Reverse Limits
9482   l_transaction_phase_code   varchar2(30);
9483   l_header_id                NUMBER;
9484   l_data                     VARCHAR2(1);
9485   l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
9486 
9487   -- BUG 2670775 - Add ordered_quantity,price_request_code to select list
9488   CURSOR order_line IS
9489   SELECT line_id, item_type_code,
9490          config_header_id, config_rev_nbr,
9491          line_category_code, schedule_status_code,
9492          shipping_interfaced_flag,
9493          ordered_quantity, price_request_code
9494          ,transaction_phase_code
9495   FROM   OE_ORDER_LINES
9496   WHERE  HEADER_ID = p_header_id;
9497   /*AND  NVL(ORG_ID,NVL(l_org_id,0))= NVL(l_org_id,0);*/
9498 
9499 -- added for notification framework
9500   l_new_line_rec     OE_Order_PUB.Line_Rec_Type;
9501   l_index    NUMBER;
9502 CURSOR svc_line IS
9503 	SELECT line_id, item_type_code
9504      	FROM OE_ORDER_LINES
9505 	  WHERE   service_reference_line_id  = p_line_id
9506 	  AND     service_reference_type_code = 'ORDER';   --bug 3056313
9507 
9508 BEGIN
9509 
9510   oe_debug_pub.add('Entering OE_LINE_UTIL.DELETE_ROW', 1);
9511   --Commented for MOAC start
9512   /*l_org_id := OE_GLOBALS.G_ORG_ID;
9513 
9514   IF l_org_id IS NULL THEN
9515     OE_GLOBALS.Set_Context;
9516     l_org_id := OE_GLOBALS.G_ORG_ID;
9517   END IF;
9518 
9519   oe_debug_pub.add('Entering delete '||to_char(l_org_id), 1); */
9520   --Commented for MOAC end
9521   IF p_header_id <> FND_API.G_MISS_NUM THEN
9522     FOR l_line IN order_line
9523     LOOP
9524 
9525        --added for notification framework
9526    --check code release level first. Notification framework is at Pack H level
9527     IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508' THEN
9528        oe_debug_pub.add('JFC: in delete row, l_line_id'|| l_line.line_id , 1);
9529       /* Set the operation on the record so that globals are updated as well */
9530       l_new_line_rec.operation := OE_GLOBALS.G_OPR_DELETE;
9531       l_new_line_rec.line_id :=l_line.line_id;
9532       OE_ORDER_UTIL.Update_Global_Picture(p_Upd_New_Rec_If_Exists => True,
9533                     p_line_rec =>l_new_line_rec,
9534                     p_line_id =>l_line.line_id,
9535                     x_index => l_index,
9536                     x_return_status => l_return_status);
9537         OE_DEBUG_PUB.ADD('Update_Global Return Status from OE_LINE_UTIL.delete_row  is: ' || l_return_status);
9538        IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
9539           OE_DEBUG_PUB.ADD('EVENT NOTIFY - Unexpected Error');
9540           OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.DELETE_ROW', 1);
9541 	  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9542        ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
9543           OE_DEBUG_PUB.ADD('Update_Global_Picture Error in OE_LINE_UTIL.Delete_row');
9544           OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.DELETE_ROW', 1);
9545 	  RAISE FND_API.G_EXC_ERROR;
9546        END IF;
9547     END IF; /*code_release_level*/
9548     -- notification framework end
9549 
9550       -- Keep all your dependencies in Delete Dependents Procedure
9551       -- If model is deleted, delete from SPC tables
9552       IF l_line.item_type_code = OE_GLOBALS.G_ITEM_MODEL THEN
9553         OE_Config_Pvt.Delete_Config
9554         ( p_config_hdr_id     => l_line.config_header_id,
9555           p_config_rev_nbr    => l_line.config_rev_nbr,
9556           x_return_status     => l_return_status );
9557       END IF;
9558 
9559       l_line_id                  := l_line.line_id;
9560       l_item_type_code           := l_line.item_type_code;
9561       l_line_category_code       := l_line.line_category_code;
9562       l_config_header_id         := l_line.config_header_id;
9563       l_config_rev_nbr           := l_line.config_rev_nbr;
9564       l_schedule_status_code     := l_line.schedule_status_code;
9565       l_shipping_interfaced_flag := l_line.shipping_interfaced_flag;
9566       l_ordered_quantity         := l_line.ordered_quantity;   -- BUG 2670775 Reverse Limits
9567       l_price_request_code       := l_line.price_request_code; -- BUG 2670775 Reverse Limits
9568       l_transaction_phase_code   := l_line.transaction_phase_code;
9569 
9570       oe_debug_pub.add(' Header - Before delete dependent');
9571 
9572       Delete_Dependents
9573       ( p_line_id                  => l_line_id
9574        ,p_item_type_code           => l_item_type_code
9575        ,p_line_category_code       => l_line_category_code
9576        ,p_config_header_id         => l_config_header_id
9577        ,p_config_rev_nbr           => l_config_rev_nbr
9578        ,p_schedule_status_code     => l_schedule_status_code
9579        ,p_shipping_interfaced_flag => l_shipping_interfaced_flag
9580        ,p_ordered_quantity         => l_ordered_quantity          -- BUG 2670775 Reverse Limits
9581        ,p_price_request_code       => l_price_request_code      -- BUG 2670775 Reverse Limits
9582        ,p_transaction_phase_code   => l_transaction_phase_code -- Bug 3315331
9583        );
9584 
9585     END LOOP; -- all the lines in a header.
9586 
9587     /* Start Audit Trail */
9588     DELETE  FROM OE_ORDER_LINES_HISTORY
9589     WHERE   HEADER_ID = p_header_id;
9590     /* End Audit Trail */
9591 
9592     DELETE  FROM OE_ORDER_LINES
9593     WHERE   HEADER_ID = p_header_id;
9594    /* AND NVL(ORG_ID,NVL(l_org_id,0))= NVL(l_org_id,0);*/
9595 
9596   ELSE -- header_id is missing.
9597     oe_debug_pub.add('hdr missing delete_row,line_id: '||p_line_id, 1);
9598 
9599     oe_line_util.query_row
9600     (p_line_id   => p_line_id
9601     ,x_line_rec  => l_line_rec );
9602 
9603     lvariable2 := p_line_id;
9604 
9605     IF l_line_rec.ITEM_TYPE_CODE = 'MODEL' OR
9606        (l_line_rec.ITEM_TYPE_CODE = 'KIT' AND
9607         l_line_rec.top_model_line_id = l_line_rec.line_id) THEN
9608       oe_debug_pub.add('Entering - MODEL', 1);
9609 
9610       -- BUG 2670775 Reverse Limits - add ordered_quantity,price_request_code to select
9611       lsqlstmt := 'Select line_id, item_type_code, line_category_code,
9612                    config_header_id, config_rev_nbr,
9613                    schedule_status_code, shipping_interfaced_flag,
9614                    ordered_quantity, price_request_code
9615                    from oe_order_lines
9616                    where top_model_line_id = :x and
9617                          line_id <> :y';
9618 
9619 
9620       OPEN llinetbl
9621       FOR lsqlstmt
9622       USING
9623       p_line_id,
9624       l_in_line_id;
9625 
9626       lvariable1 := 'TOP_MODEL';
9627       oe_debug_pub.add('end of loop for OPEN MODEL', 1);
9628 
9629     END IF; -- if top level model.
9630 
9631 
9632     IF llinetbl%ISOPEN THEN
9633       LOOP
9634         oe_debug_pub.add('Entering model LOOP', 1);
9635 
9636         FETCH llinetbl INTO l_line_id,l_item_type_code,
9637             l_line_category_code,l_config_header_id,
9638             l_config_rev_nbr,l_schedule_status_code,
9639             l_shipping_interfaced_flag,
9640             l_ordered_quantity, l_price_request_code;  -- BUG 2670775 Reverse Limits
9641 
9642         EXIT WHEN llinetbl%NOTFOUND;
9643 
9644         oe_debug_pub.add('After Fetch -IN  LOOP', 1);
9645         -- Keep all your dependencies in Delete Dependents Procedure
9646 
9647         oe_debug_pub.add(' model - Before delete dependent' || l_line_id);
9648 
9649         Delete_Dependents
9650         ( p_line_id                  => l_line_id
9651          ,p_item_type_code           => l_item_type_code
9652          ,p_line_category_code       => l_line_category_code
9653          ,p_config_header_id         => l_config_header_id
9654          ,p_config_rev_nbr           => l_config_rev_nbr
9655          ,p_schedule_status_code     => l_schedule_status_code
9656          ,p_shipping_interfaced_flag => l_shipping_interfaced_flag
9657          ,p_ordered_quantity         => l_ordered_quantity     -- BUG 2670775 Reverse Limits
9658          ,p_price_request_code       => l_price_request_code); -- BUG 2670775 Reverse Limits
9659 
9660 	-- start bug  2408321
9661 	l_tmp_line_id := l_line_id;
9662 
9663         -- BUG 2670775 Reverse Limits - add ordered_quantity,price_request_code to select
9664 	lsqlstmt := 'Select line_id, item_type_code, line_category_code,
9665 	  config_header_id, config_rev_nbr,
9666 	  schedule_status_code, shipping_interfaced_flag,
9667           ordered_quantity, price_request_code
9668 	  from oe_order_lines
9669 	  where service_reference_type_code = ' || '''' || 'ORDER' || ''' ' ||
9670 	  'AND service_reference_line_id = :x';  --bug 3056313
9671 
9672 	  OPEN llinetbl_svc
9673 	  FOR lsqlstmt
9674 	  using l_line_id;
9675 
9676 	IF llinetbl_svc%ISOPEN THEN
9677 	   LOOP
9678 	      FETCH llinetbl_svc
9679 		INTO l_line_id,l_item_type_code,l_line_category_code
9680 		,l_config_header_id,l_config_rev_nbr
9681 		,l_schedule_status_code,l_shipping_interfaced_flag
9682                 ,l_ordered_quantity, l_price_request_code;  -- BUG 2670775 Reverse Limits
9683 
9684 	      EXIT WHEN llinetbl_svc%NOTFOUND;
9685 
9686 	      oe_debug_pub.add('Service - Before delete dependent' || l_line_id);
9687 
9688 	      Delete_Dependents
9689 		( p_line_id                  => l_line_id
9690 		  ,p_item_type_code           => l_item_type_code
9691 		  ,p_line_category_code       => l_line_category_code
9692 		  ,p_config_header_id         => l_config_header_id
9693 		  ,p_config_rev_nbr           => l_config_rev_nbr
9694 		  ,p_schedule_status_code     => l_schedule_status_code
9695 		  ,p_shipping_interfaced_flag => l_shipping_interfaced_flag
9696                   ,p_ordered_quantity         => l_ordered_quantity      -- BUG 2670775 Reverse Limits
9697                   ,p_price_request_code       => l_price_request_code ); -- BUG 2670775 Reverse Limits
9698 
9699 	   END LOOP; -- loop of the service lines.
9700 
9701 	   CLOSE llinetbl_svc;
9702 
9703 	   DELETE  FROM OE_ORDER_LINES
9704 	     WHERE   SERVICE_REFERENCE_LINE_ID = l_tmp_line_id
9705 	     AND   SERVICE_REFERENCE_TYPE_CODE = 'ORDER';  -- bug 3056313
9706 
9707 	END IF; -- if service lines exist, for bug 2408321
9708 
9709         OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
9710       END LOOP; -- loop for models
9711 
9712       CLOSE llinetbl;
9713 
9714       IF lvariable1 = 'TOP_MODEL' THEN
9715         EXECUTE IMMEDIATE
9716         'Delete oe_order_lines where top_model_line_id = :x
9717          and line_id <> :y'
9718          USING
9719          p_line_id,
9720          p_line_id;
9721       END IF;
9722 
9723     END IF; -- end if model
9724 
9725    /* Remove the Parent Line and sub entities Here */
9726    /* Keep all your dependencies in Delete Dependents Procedure */
9727 
9728     oe_debug_pub.add('calling delete dep for the line', 1);
9729     Delete_Dependents
9730     ( p_line_id                  => l_line_rec.line_id
9731      ,p_item_type_code           => l_line_rec.item_type_code
9732      ,p_line_category_code       => l_line_rec.line_category_code
9733      ,p_config_header_id         => l_line_rec.config_header_id
9734      ,p_config_rev_nbr           => l_line_rec.config_rev_nbr
9735      ,p_schedule_status_code     => l_line_rec.schedule_status_code
9736      ,p_shipping_interfaced_flag => l_line_rec.shipping_interfaced_flag
9737      ,p_ordered_quantity         => l_line_rec.ordered_quantity     -- BUG 2670775 Reverse Limits
9738      ,p_price_request_code       => l_line_rec.price_request_code); -- BUG 2670775 Reverse Limits
9739 
9740     -- if model, call spc's delete
9741     IF p_header_id = FND_API.G_MISS_NUM THEN
9742       -- we already have l_line_rec
9743 
9744       IF l_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL THEN
9745         OE_Config_Pvt.Delete_Config
9746         ( p_config_hdr_id     => l_line_rec.config_header_id,
9747           p_config_rev_nbr    => l_line_rec.config_rev_nbr,
9748           x_return_status     => l_return_status );
9749       END IF;
9750     END IF;
9751 
9752     /* Delete all the dependents for service line */
9753     oe_debug_pub.add('Item Type for delete: ' || l_line_rec.item_type_code);
9754 
9755     /* When a standard line is being deleted, check if it has any service */
9756     /* lines attached to it. If so, get the line_id of the service line and */
9757     /* use this to delete the dependents */
9758 
9759     -- 02/NOV Reverse Limits add ordered_quantity, price_request_code to select
9760     lsqlstmt := 'Select line_id, item_type_code, line_category_code,
9761                  config_header_id, config_rev_nbr,
9762                  schedule_status_code, shipping_interfaced_flag,
9763                  ordered_quantity,price_request_code
9764                  from oe_order_lines
9765                  where service_reference_type_code = ' || '''' || 'ORDER' || ''' ' ||
9766                 'and service_reference_line_id = :x';  -- bug 3056313
9767 
9768     OPEN llinetbl
9769     FOR lsqlstmt
9770     using p_line_id;
9771 
9772     IF llinetbl%ISOPEN THEN
9773       LOOP
9774         FETCH llinetbl
9775         INTO l_line_id,l_item_type_code,l_line_category_code
9776             ,l_config_header_id,l_config_rev_nbr
9777             ,l_schedule_status_code,l_shipping_interfaced_flag
9778             ,l_ordered_quantity    ,l_price_request_code      ; -- BUG 2670775 Reverse Limits
9779 
9780         EXIT WHEN llinetbl%NOTFOUND;
9781 
9782         oe_debug_pub.add('Service - Before delete dependent' || l_line_id);
9783 
9784         Delete_Dependents
9785         ( p_line_id                  => l_line_id
9786          ,p_item_type_code           => l_item_type_code
9787          ,p_line_category_code       => l_line_category_code
9788          ,p_config_header_id         => l_config_header_id
9789          ,p_config_rev_nbr           => l_config_rev_nbr
9790          ,p_schedule_status_code     => l_schedule_status_code
9791          ,p_shipping_interfaced_flag => l_shipping_interfaced_flag
9792          ,p_ordered_quantity         => l_ordered_quantity     -- BUG 2670775 Reverse Limits
9793          ,p_price_request_code       => l_price_request_code); -- BUG 2670775 Reverse Limits
9794 
9795         OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
9796       END LOOP; -- loop of the service lines.
9797 
9798       CLOSE llinetbl;
9799 
9800     END IF; -- if service lines exist
9801 
9802     /* Start Audit Trail (modified for 11.5.10) */
9803     DELETE  FROM OE_ORDER_LINES_HISTORY
9804     WHERE   LINE_ID = p_line_id
9805     AND     NVL(AUDIT_FLAG, 'Y') = 'Y'
9806     AND     NVL(VERSION_FLAG, 'N') = 'N'
9807     AND     NVL(PHASE_CHANGE_FLAG, 'N') = 'N';
9808 
9809     UPDATE OE_ORDER_LINES_HISTORY
9810     SET    AUDIT_FLAG = 'N'
9811     WHERE  LINE_ID = p_line_id
9812     AND    NVL(AUDIT_FLAG, 'Y') = 'Y'
9813     AND   (NVL(VERSION_FLAG, 'N') = 'Y'
9814     OR     NVL(PHASE_CHANGE_FLAG, 'N') = 'Y');
9815     /* End Audit Trail */
9816 
9817 
9818   --added for notification framework to update global picture for standard line
9819    --check code release level first. Notification framework is at Pack H level
9820       oe_debug_pub.add('JPN: Delete all lines now');
9821     IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508' THEN
9822       /* Set the operation on the record so that globals are updated as well */
9823      l_new_line_rec.operation := OE_GLOBALS.G_OPR_DELETE;
9824      l_new_line_rec.line_id :=l_line_rec.line_id;
9825      l_new_line_rec.last_update_date :=l_line_rec.last_update_date;
9826 
9827       OE_ORDER_UTIL.Update_Global_Picture(p_Upd_New_Rec_If_Exists => True,
9828                     p_line_rec =>l_new_line_rec,
9829                     p_line_id =>l_line_rec.line_id,
9830                     x_index => l_index,
9831                     x_return_status => l_return_status);
9832         OE_DEBUG_PUB.ADD('Update_Global Return Status from OE_LINE_UTIL.delete_row for deleting standard line is: ' || l_return_status);
9833         IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
9834           OE_DEBUG_PUB.ADD('EVENT NOTIFY - Unexpected Error');
9835           OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.DELETE_ROW', 1);
9836 	  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9837        ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
9838           OE_DEBUG_PUB.ADD('Update_Global_Picture Error in OE_LINE_UTIL.Delete_row');
9839           OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.DELETE_ROW', 1);
9840 	  RAISE FND_API.G_EXC_ERROR;
9841         END IF;
9842       END IF; /*code_release_level*/
9843     -- notification framework end
9844 
9845 
9846     DELETE  FROM OE_ORDER_LINES
9847     WHERE   LINE_ID = p_line_id;
9848     /* AND   NVL(ORG_ID,NVL(l_org_id,0))= NVL(l_org_id,0);*/
9849 
9850 
9851  --added for notification framework to update global picture for service line
9852   --check code release level first. Notification framework is at Pack H level
9853     IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508' THEN
9854       FOR l_svc IN svc_line
9855        LOOP
9856          oe_debug_pub.add('JFC: in delete row, service line_id= '|| l_svc.line_id , 1);
9857       /* Set the operation on the record so that globals are updated as well */
9858           l_new_line_rec.operation := OE_GLOBALS.G_OPR_DELETE;
9859           l_new_line_rec.line_id :=l_svc.line_id;
9860           OE_ORDER_UTIL.Update_Global_Picture(p_Upd_New_Rec_If_Exists => True,
9861                     p_line_rec =>l_new_line_rec,
9862                     p_line_id =>l_svc.line_id,
9863                     x_index => l_index,
9864                     x_return_status => l_return_status);
9865 
9866           OE_DEBUG_PUB.ADD('Update_Global Return Status from OE_LINE_UTIL.delete_row for deleting service line is: ' || l_return_status);
9867           IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
9868              OE_DEBUG_PUB.ADD('EVENT NOTIFY - Unexpected Error');
9869              OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.DELETE_ROW', 1);
9870 	     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9871          ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
9872              OE_DEBUG_PUB.ADD('Update_Global_Picture Error in OE_LINE_UTIL.Delete_row');
9873              OE_DEBUG_PUB.ADD('Exiting OE_LINE_UTIL.DELETE_ROW', 1);
9874 	     RAISE FND_API.G_EXC_ERROR;
9875          END IF;
9876        END LOOP;
9877      END IF; /*code_release_level*/
9878      -- notification framework end
9879 
9880     -- For the Multiple service for Standard Line
9881     DELETE  FROM OE_ORDER_LINES
9882       WHERE   SERVICE_REFERENCE_LINE_ID = p_line_id
9883       AND   SERVICE_REFERENCE_TYPE_CODE = 'ORDER';  -- bug 3056313
9884     /* AND NVL(ORG_ID,NVL(l_org_id,0))= NVL(l_org_id,0);*/
9885 
9886   END IF;
9887 
9888 
9889   IF (NVL(FND_PROFILE.VALUE('WSH_ENABLE_DCP'), -1)  = 1 OR
9890       NVL(FND_PROFILE.VALUE('WSH_ENABLE_DCP'), -1)  = 2) AND
9891       WSH_DCP_PVT.G_CALL_DCP_CHECK = 'Y' THEN
9892 
9893     WSH_DCP_PVT.G_INIT_MSG_COUNT := fnd_msg_pub.count_msg;
9894 
9895     BEGIN
9896       IF l_debug_level  > 0 THEN
9897         oe_debug_pub.add(p_header_id ||'-----' || l_line_rec.header_id, 1);
9898       END IF;
9899 
9900       WSH_DCP_PVT.g_dc_table.DELETE;
9901 
9902       IF p_header_id is NULL OR
9903          p_header_id = FND_API.G_MISS_NUM THEN
9904         l_header_id :=  l_line_rec.header_id;
9905       ELSE
9906         l_header_id :=  p_header_id;
9907       END IF;
9908 
9909       IF l_debug_level  > 0 THEN
9910         oe_debug_pub.add('CALLING WSH_DCP_PVT.Check_Scripts '
9911                          ||'from delete row-'|| l_header_id, 1);
9912       END IF;
9913 
9914       WSH_DCP_PVT.Check_Scripts
9915       ( p_source_header_id  => l_header_id
9916        ,x_data_inconsistent => l_data);
9917 
9918       IF l_debug_level  > 0 THEN
9919         oe_debug_pub.add
9920         ('CALLING WSH_DCP_PVT.Post_Process '|| l_data, 1);
9921        END IF;
9922 
9923       WSH_DCP_PVT.Post_Process
9924       ( p_action_code     => 'OM'
9925        ,p_raise_exception => 'Y');
9926 
9927     EXCEPTION
9928       WHEN WSH_DCP_PVT.dcp_caught THEN
9929         IF l_debug_level  > 0 THEN
9930           oe_debug_pub.add('OM call to WSH DCP Caught in delete', 1);
9931         END IF;
9932 
9933         WHEN others THEN
9934           IF l_debug_level  > 0 THEN
9935             oe_msg_pub.add_text
9936             ('Update_Shipping_From_OE, DCP post process'|| sqlerrm);
9937               oe_debug_pub.add('OM call to WSH DCP,others '|| sqlerrm, 1);
9938           END IF;
9939     END;
9940   END IF; -- profile is yes
9941 
9942   oe_debug_pub.add('Exiting OE_LINE_UTIL.DELETE_ROW', 1);
9943 
9944 EXCEPTION
9945   WHEN FND_API.G_EXC_ERROR THEN
9946     RAISE FND_API.G_EXC_ERROR ;
9947 
9948   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
9949     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9950 
9951   WHEN OTHERS THEN
9952     IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
9953     THEN
9954       OE_MSG_PUB.Add_Exc_Msg
9955       (   G_PKG_NAME
9956          ,'Delete_Row');
9957     END IF;
9958 
9959     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9960 END Delete_Row;
9961 
9962 
9963 /*----------------------------------------------------------
9964 -- FUNCTION Query_Row
9965 -- IMPORTANT: DO NOT CHANGE THE SPEC OF THIS FUNCTION
9966 -- IT IS PUBLIC AND BEING CALLED BY OTHER PRODUCTS
9967 -- Private OM callers should call the procedure query_row instead
9968 -- as it has the nocopy option which would improve the performance
9969 -----------------------------------------------------------*/
9970 
9971 FUNCTION Query_Row
9972 (   p_line_id                       IN  NUMBER
9973 ) RETURN OE_Order_PUB.Line_Rec_Type
9974 IS
9975 l_line_rec               OE_Order_PUB.Line_Rec_Type;
9976 BEGIN
9977 
9978     Query_Row
9979         (   p_line_id                     => p_line_id
9980 	    ,   x_line_rec                    => l_line_rec
9981         );
9982 
9983     RETURN l_line_rec;
9984 
9985 END Query_Row;
9986 
9987 
9988 /*----------------------------------------------------------
9989  Procedure Query_Row
9990 -----------------------------------------------------------*/
9991 
9992 PROCEDURE Query_Row
9993 (   p_line_id                       IN  NUMBER
9994 ,   x_line_rec                      IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type
9995 )
9996 IS
9997 
9998 CURSOR l_line_csr IS
9999     SELECT  ACCOUNTING_RULE_ID
10000   , ACCOUNTING_RULE_DURATION
10001   , ACTUAL_ARRIVAL_DATE
10002   , ACTUAL_SHIPMENT_DATE
10003   , AGREEMENT_ID
10004   , ARRIVAL_SET_ID
10005   , ATO_LINE_ID
10006   , ATTRIBUTE1
10007   , ATTRIBUTE10
10008   , ATTRIBUTE11
10009   , ATTRIBUTE12
10010   , ATTRIBUTE13
10011   , ATTRIBUTE14
10012   , ATTRIBUTE15
10013   , ATTRIBUTE16   --For bug 2184255
10014   , ATTRIBUTE17
10015   , ATTRIBUTE18
10016   , ATTRIBUTE19
10017   , ATTRIBUTE2
10018   , ATTRIBUTE20
10019   , ATTRIBUTE3
10020   , ATTRIBUTE4
10021   , ATTRIBUTE5
10022   , ATTRIBUTE6
10023   , ATTRIBUTE7
10024   , ATTRIBUTE8
10025   , ATTRIBUTE9
10026   , AUTO_SELECTED_QUANTITY
10027   , AUTHORIZED_TO_SHIP_FLAG
10028   , BOOKED_FLAG
10029   , CANCELLED_FLAG
10030   , CANCELLED_QUANTITY
10031   , COMPONENT_CODE
10032   , COMPONENT_NUMBER
10033   , COMPONENT_SEQUENCE_ID
10034   , CONFIG_HEADER_ID
10035   , CONFIG_REV_NBR
10036   , CONFIG_DISPLAY_SEQUENCE
10037   , CONFIGURATION_ID
10038   , CONTEXT
10039   , CREATED_BY
10040   , CREATION_DATE
10041   , CREDIT_INVOICE_LINE_ID
10042   , CUSTOMER_DOCK_CODE
10043   , CUSTOMER_JOB
10044   , CUSTOMER_PRODUCTION_LINE
10045   , CUST_PRODUCTION_SEQ_NUM
10046   , CUSTOMER_TRX_LINE_ID
10047   , CUST_MODEL_SERIAL_NUMBER
10048   , CUST_PO_NUMBER
10049   , CUSTOMER_LINE_NUMBER
10050   , CUSTOMER_SHIPMENT_NUMBER
10051   , CUSTOMER_ITEM_NET_PRICE
10052   , DELIVERY_LEAD_TIME
10053   , DELIVER_TO_CONTACT_ID
10054   , DELIVER_TO_ORG_ID
10055   , DEMAND_BUCKET_TYPE_CODE
10056   , DEMAND_CLASS_CODE
10057   , DEP_PLAN_REQUIRED_FLAG
10058   , EARLIEST_ACCEPTABLE_DATE
10059   , END_ITEM_UNIT_NUMBER
10060   , EXPLOSION_DATE
10061   , FIRST_ACK_CODE
10062   , FIRST_ACK_DATE
10063   , FOB_POINT_CODE
10064   , FREIGHT_CARRIER_CODE
10065   , FREIGHT_TERMS_CODE
10066   , FULFILLED_QUANTITY
10067   , FULFILLED_FLAG
10068   , FULFILLMENT_METHOD_CODE
10069   , FULFILLMENT_DATE
10070   , GLOBAL_ATTRIBUTE1
10071   , GLOBAL_ATTRIBUTE10
10072   , GLOBAL_ATTRIBUTE11
10073   , GLOBAL_ATTRIBUTE12
10074   , GLOBAL_ATTRIBUTE13
10075   , GLOBAL_ATTRIBUTE14
10076   , GLOBAL_ATTRIBUTE15
10077   , GLOBAL_ATTRIBUTE16
10078   , GLOBAL_ATTRIBUTE17
10079   , GLOBAL_ATTRIBUTE18
10080   , GLOBAL_ATTRIBUTE19
10081   , GLOBAL_ATTRIBUTE2
10082   , GLOBAL_ATTRIBUTE20
10083   , GLOBAL_ATTRIBUTE3
10084   , GLOBAL_ATTRIBUTE4
10085   , GLOBAL_ATTRIBUTE5
10086   , GLOBAL_ATTRIBUTE6
10087   , GLOBAL_ATTRIBUTE7
10088   , GLOBAL_ATTRIBUTE8
10089   , GLOBAL_ATTRIBUTE9
10090   , GLOBAL_ATTRIBUTE_CATEGORY
10091   , HEADER_ID
10092   , INDUSTRY_ATTRIBUTE1
10093   , INDUSTRY_ATTRIBUTE10
10094   , INDUSTRY_ATTRIBUTE11
10095   , INDUSTRY_ATTRIBUTE12
10096   , INDUSTRY_ATTRIBUTE13
10097   , INDUSTRY_ATTRIBUTE14
10098   , INDUSTRY_ATTRIBUTE15
10099   , INDUSTRY_ATTRIBUTE16
10100   , INDUSTRY_ATTRIBUTE17
10101   , INDUSTRY_ATTRIBUTE18
10102   , INDUSTRY_ATTRIBUTE19
10103   , INDUSTRY_ATTRIBUTE20
10104   , INDUSTRY_ATTRIBUTE21
10105   , INDUSTRY_ATTRIBUTE22
10106   , INDUSTRY_ATTRIBUTE23
10107   , INDUSTRY_ATTRIBUTE24
10108   , INDUSTRY_ATTRIBUTE25
10109   , INDUSTRY_ATTRIBUTE26
10110   , INDUSTRY_ATTRIBUTE27
10111   , INDUSTRY_ATTRIBUTE28
10112   , INDUSTRY_ATTRIBUTE29
10113   , INDUSTRY_ATTRIBUTE30
10114   , INDUSTRY_ATTRIBUTE2
10115   , INDUSTRY_ATTRIBUTE3
10116   , INDUSTRY_ATTRIBUTE4
10117   , INDUSTRY_ATTRIBUTE5
10118   , INDUSTRY_ATTRIBUTE6
10119   , INDUSTRY_ATTRIBUTE7
10120   , INDUSTRY_ATTRIBUTE8
10121   , INDUSTRY_ATTRIBUTE9
10122   , INDUSTRY_CONTEXT
10123   , INTMED_SHIP_TO_CONTACT_ID
10124   , INTMED_SHIP_TO_ORG_ID
10125   , INVENTORY_ITEM_ID
10126   , INVOICE_INTERFACE_STATUS_CODE
10127   , INVOICE_TO_CONTACT_ID
10128   , INVOICE_TO_ORG_ID
10129   , INVOICED_QUANTITY
10130   , INVOICING_RULE_ID
10131   , ORDERED_ITEM_ID
10132   , ITEM_IDENTIFIER_TYPE
10133   , ORDERED_ITEM
10134   , ITEM_REVISION
10135   , ITEM_TYPE_CODE
10136   , LAST_ACK_CODE
10137   , LAST_ACK_DATE
10138   , LAST_UPDATED_BY
10139   , LAST_UPDATE_DATE
10140   , LAST_UPDATE_LOGIN
10141   , LATEST_ACCEPTABLE_DATE
10142   , LINE_CATEGORY_CODE
10143   , LINE_ID
10144   , LINE_NUMBER
10145   , LINE_TYPE_ID
10146   , LINK_TO_LINE_ID
10147   , MODEL_GROUP_NUMBER
10148   --  , MFG_COMPONENT_SEQUENCE_ID
10149   , MFG_LEAD_TIME
10150   , OPEN_FLAG
10151   , OPTION_FLAG
10152   , OPTION_NUMBER
10153   , ORDERED_QUANTITY
10154   , ORDERED_QUANTITY2              --OPM 02/JUN/00
10155   , ORDER_QUANTITY_UOM
10156   , ORDERED_QUANTITY_UOM2          --OPM 02/JUN/00
10157   , ORG_ID
10158   , ORIG_SYS_DOCUMENT_REF
10159   , ORIG_SYS_LINE_REF
10160   , ORIG_SYS_SHIPMENT_REF
10161   , OVER_SHIP_REASON_CODE
10162   , OVER_SHIP_RESOLVED_FLAG
10163   , PAYMENT_TERM_ID
10164   , PLANNING_PRIORITY
10165   , PREFERRED_GRADE                --OPM 02/JUN/00
10166   , PRICE_LIST_ID
10167   , PRICE_REQUEST_CODE             --PROMOTIONS MAY/01
10168   , PRICING_ATTRIBUTE1
10169   , PRICING_ATTRIBUTE10
10170   , PRICING_ATTRIBUTE2
10171   , PRICING_ATTRIBUTE3
10172   , PRICING_ATTRIBUTE4
10173   , PRICING_ATTRIBUTE5
10174   , PRICING_ATTRIBUTE6
10175   , PRICING_ATTRIBUTE7
10176   , PRICING_ATTRIBUTE8
10177   , PRICING_ATTRIBUTE9
10178   , PRICING_CONTEXT
10179   , PRICING_DATE
10180   , PRICING_QUANTITY
10181   , PRICING_QUANTITY_UOM
10182   , PROGRAM_APPLICATION_ID
10183   , PROGRAM_ID
10184   , PROGRAM_UPDATE_DATE
10185   , PROJECT_ID
10186   , PROMISE_DATE
10187   , RE_SOURCE_FLAG
10188   , REFERENCE_CUSTOMER_TRX_LINE_ID
10189   , REFERENCE_HEADER_ID
10190   , REFERENCE_LINE_ID
10191   , REFERENCE_TYPE
10192   , REQUEST_DATE
10193   , REQUEST_ID
10194   , RETURN_ATTRIBUTE1
10195   , RETURN_ATTRIBUTE10
10196   , RETURN_ATTRIBUTE11
10197   , RETURN_ATTRIBUTE12
10198   , RETURN_ATTRIBUTE13
10199   , RETURN_ATTRIBUTE14
10200   , RETURN_ATTRIBUTE15
10201   , RETURN_ATTRIBUTE2
10202   , RETURN_ATTRIBUTE3
10203   , RETURN_ATTRIBUTE4
10204   , RETURN_ATTRIBUTE5
10205   , RETURN_ATTRIBUTE6
10206   , RETURN_ATTRIBUTE7
10207   , RETURN_ATTRIBUTE8
10208   , RETURN_ATTRIBUTE9
10209   , RETURN_CONTEXT
10210   , RETURN_REASON_CODE
10211   , RLA_SCHEDULE_TYPE_CODE
10212   , SALESREP_ID
10213   , SCHEDULE_ARRIVAL_DATE
10214   , SCHEDULE_SHIP_DATE
10215   , SCHEDULE_STATUS_CODE
10216   , SHIPMENT_NUMBER
10217   , SHIPMENT_PRIORITY_CODE
10218   , SHIPPED_QUANTITY
10219   , SHIPPED_QUANTITY2 -- OPM B1661023 04/02/01
10220   , SHIPPING_METHOD_CODE
10221   , SHIPPING_QUANTITY
10222   , SHIPPING_QUANTITY2 -- OPM B1661023 04/02/01
10223   , SHIPPING_QUANTITY_UOM
10224   , SHIPPING_QUANTITY_UOM2 -- INVCONV
10225   , SHIP_FROM_ORG_ID
10226   , SUBINVENTORY
10227   , SHIP_SET_ID
10228   , SHIP_TOLERANCE_ABOVE
10229   , SHIP_TOLERANCE_BELOW
10230   , SHIPPABLE_FLAG
10231   , SHIPPING_INTERFACED_FLAG
10232   , SHIP_TO_CONTACT_ID
10233   , SHIP_TO_ORG_ID
10234   , SHIP_MODEL_COMPLETE_FLAG
10235   , SOLD_TO_ORG_ID
10236   , SOLD_FROM_ORG_ID
10237   , SORT_ORDER
10238   , SOURCE_DOCUMENT_ID
10239   , SOURCE_DOCUMENT_LINE_ID
10240   , SOURCE_DOCUMENT_TYPE_ID
10241   , SOURCE_TYPE_CODE
10242   , SPLIT_FROM_LINE_ID
10243   , LINE_SET_ID
10244   , SPLIT_BY
10245   , MODEL_REMNANT_FLAG
10246   , TASK_ID
10247   , TAX_CODE
10248   , TAX_DATE
10249   , TAX_EXEMPT_FLAG
10250   , TAX_EXEMPT_NUMBER
10251   , TAX_EXEMPT_REASON_CODE
10252   , TAX_POINT_CODE
10253   , TAX_RATE
10254   , TAX_VALUE
10255   , TOP_MODEL_LINE_ID
10256   , UNIT_LIST_PRICE
10257   , UNIT_LIST_PRICE_PER_PQTY
10258   , UNIT_SELLING_PRICE
10259   , UNIT_SELLING_PRICE_PER_PQTY
10260   , VISIBLE_DEMAND_FLAG
10261   , VEH_CUS_ITEM_CUM_KEY_ID
10262   , SHIPPING_INSTRUCTIONS
10263   , PACKING_INSTRUCTIONS
10264   , SERVICE_TXN_REASON_CODE
10265   , SERVICE_TXN_COMMENTS
10266   , SERVICE_DURATION
10267   , SERVICE_PERIOD
10268   , SERVICE_START_DATE
10269   , SERVICE_END_DATE
10270   , SERVICE_COTERMINATE_FLAG
10271   , UNIT_LIST_PERCENT
10272   , UNIT_SELLING_PERCENT
10273   , UNIT_PERCENT_BASE_PRICE
10274   , SERVICE_NUMBER
10275   , SERVICE_REFERENCE_TYPE_CODE
10276   , SERVICE_REFERENCE_LINE_ID
10277   , SERVICE_REFERENCE_SYSTEM_ID
10278   , TP_CONTEXT
10279   , TP_ATTRIBUTE1
10280   , TP_ATTRIBUTE2
10281   , TP_ATTRIBUTE3
10282   , TP_ATTRIBUTE4
10283   , TP_ATTRIBUTE5
10284   , TP_ATTRIBUTE6
10285   , TP_ATTRIBUTE7
10286   , TP_ATTRIBUTE8
10287   , TP_ATTRIBUTE9
10288   , TP_ATTRIBUTE10
10289   , TP_ATTRIBUTE11
10290   , TP_ATTRIBUTE12
10291   , TP_ATTRIBUTE13
10292   , TP_ATTRIBUTE14
10293   , TP_ATTRIBUTE15
10294   , FLOW_STATUS_CODE
10295   , MARKETING_SOURCE_CODE_ID
10296   , CALCULATE_PRICE_FLAG
10297   , COMMITMENT_ID
10298   , ORDER_SOURCE_ID        -- aksingh
10299   , UPGRADED_FLAG
10300   , ORIGINAL_INVENTORY_ITEM_ID
10301   , ORIGINAL_ITEM_IDENTIFIER_TYPE
10302   , ORIGINAL_ORDERED_ITEM_ID
10303   , ORIGINAL_ORDERED_ITEM
10304   , ITEM_RELATIONSHIP_TYPE
10305   , ITEM_SUBSTITUTION_TYPE_CODE
10306   , LATE_DEMAND_PENALTY_FACTOR
10307   , OVERRIDE_ATP_DATE_CODE
10308   , FIRM_DEMAND_FLAG
10309   , EARLIEST_SHIP_DATE
10310   , USER_ITEM_DESCRIPTION
10311   , BLANKET_NUMBER
10312   , BLANKET_LINE_NUMBER
10313   , BLANKET_VERSION_NUMBER
10314   , UNIT_COST
10315   , LOCK_CONTROL
10316   , CHANGE_SEQUENCE
10317   , transaction_phase_code
10318   , source_document_version_number
10319   , MINISITE_ID
10320   , Ib_Owner
10321   , Ib_installed_at_location
10322   , Ib_current_location
10323   , End_customer_ID
10324   , End_customer_contact_ID
10325   , End_customer_site_use_ID
10326   , RETROBILL_REQUEST_ID
10327   , ORIGINAL_LIST_PRICE  -- Override List Price
10328   , order_firmed_date
10329   , actual_fulfillment_date
10330   , charge_periodicity_code
10331   , cancelled_quantity2
10332   , fulfilled_quantity2
10333   , CONTINGENCY_ID
10334   , REVREC_EVENT_CODE
10335   , REVREC_EXPIRATION_DAYS
10336   , ACCEPTED_QUANTITY
10337   , REVREC_COMMENTS
10338   , REVREC_SIGNATURE
10339   , REVREC_SIGNATURE_DATE
10340   , ACCEPTED_BY
10341   , REVREC_REFERENCE_DOCUMENT
10342   , REVREC_IMPLICIT_FLAG
10343    FROM    OE_ORDER_LINES_ALL  -- Fix for FP bug 3391622
10344     WHERE LINE_ID = p_line_id;
10345 
10346     l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
10347 
10348 BEGIN
10349 
10350     IF l_debug_level  > 0 THEN
10351       oe_debug_pub.add('Entering OE_LINE_UTIL.QUERY_ROW, line_id:'||p_line_id, 1);
10352     END IF;
10353 
10354 
10355     OPEN l_line_csr;
10356 
10357     --  Loop over fetched records
10358 
10359     FETCH l_line_csr INTO
10360     x_line_rec.ACCOUNTING_RULE_ID
10361   , x_line_rec.ACCOUNTING_RULE_DURATION
10362   , x_line_rec.ACTUAL_ARRIVAL_DATE
10363   , x_line_rec.ACTUAL_SHIPMENT_DATE
10364   , x_line_rec.AGREEMENT_ID
10365   , x_line_rec.ARRIVAL_SET_ID
10366   , x_line_rec.ATO_LINE_ID
10367   , x_line_rec.ATTRIBUTE1
10368   , x_line_rec.ATTRIBUTE10
10369   , x_line_rec.ATTRIBUTE11
10370   , x_line_rec.ATTRIBUTE12
10371   , x_line_rec.ATTRIBUTE13
10372   , x_line_rec.ATTRIBUTE14
10373   , x_line_rec.ATTRIBUTE15
10374   , x_line_rec.ATTRIBUTE16   --For bug 2184255
10375   , x_line_rec.ATTRIBUTE17
10376   , x_line_rec.ATTRIBUTE18
10377   , x_line_rec.ATTRIBUTE19
10378   , x_line_rec.ATTRIBUTE2
10379   , x_line_rec.ATTRIBUTE20
10380   , x_line_rec.ATTRIBUTE3
10381   , x_line_rec.ATTRIBUTE4
10382   , x_line_rec.ATTRIBUTE5
10383   , x_line_rec.ATTRIBUTE6
10384   , x_line_rec.ATTRIBUTE7
10385   , x_line_rec.ATTRIBUTE8
10386   , x_line_rec.ATTRIBUTE9
10387   , x_line_rec.AUTO_SELECTED_QUANTITY
10388   , x_line_rec.AUTHORIZED_TO_SHIP_FLAG
10389   , x_line_rec.BOOKED_FLAG
10390   , x_line_rec.CANCELLED_FLAG
10391   , x_line_rec.CANCELLED_QUANTITY
10392   , x_line_rec.COMPONENT_CODE
10393   , x_line_rec.COMPONENT_NUMBER
10394   , x_line_rec.COMPONENT_SEQUENCE_ID
10395   , x_line_rec.CONFIG_HEADER_ID
10396   , x_line_rec.CONFIG_REV_NBR
10397   , x_line_rec.CONFIG_DISPLAY_SEQUENCE
10398   , x_line_rec.CONFIGURATION_ID
10399   , x_line_rec.CONTEXT
10400   , x_line_rec.CREATED_BY
10401   , x_line_rec.CREATION_DATE
10402   , x_line_rec.CREDIT_INVOICE_LINE_ID
10403   , x_line_rec.CUSTOMER_DOCK_CODE
10404   , x_line_rec.CUSTOMER_JOB
10405   , x_line_rec.CUSTOMER_PRODUCTION_LINE
10406   , x_line_rec.CUST_PRODUCTION_SEQ_NUM
10407   , x_line_rec.CUSTOMER_TRX_LINE_ID
10408   , x_line_rec.CUST_MODEL_SERIAL_NUMBER
10409   , x_line_rec.CUST_PO_NUMBER
10410   , x_line_rec.CUSTOMER_LINE_NUMBER
10411   , x_line_rec.CUSTOMER_SHIPMENT_NUMBER
10412   , x_line_rec.CUSTOMER_ITEM_NET_PRICE
10413   , x_line_rec.DELIVERY_LEAD_TIME
10414   , x_line_rec.DELIVER_TO_CONTACT_ID
10415   , x_line_rec.DELIVER_TO_ORG_ID
10416   , x_line_rec.DEMAND_BUCKET_TYPE_CODE
10417   , x_line_rec.DEMAND_CLASS_CODE
10418   , x_line_rec.DEP_PLAN_REQUIRED_FLAG
10419   , x_line_rec.EARLIEST_ACCEPTABLE_DATE
10420   , x_line_rec.END_ITEM_UNIT_NUMBER
10421   , x_line_rec.EXPLOSION_DATE
10422   , x_line_rec.FIRST_ACK_CODE
10423   , x_line_rec.FIRST_ACK_DATE
10424   , x_line_rec.FOB_POINT_CODE
10425   , x_line_rec.FREIGHT_CARRIER_CODE
10426   , x_line_rec.FREIGHT_TERMS_CODE
10427   , x_line_rec.FULFILLED_QUANTITY
10428   , x_line_rec.FULFILLED_FLAG
10429   , x_line_rec.FULFILLMENT_METHOD_CODE
10430   , x_line_rec.FULFILLMENT_DATE
10431   , x_line_rec.GLOBAL_ATTRIBUTE1
10432   , x_line_rec.GLOBAL_ATTRIBUTE10
10433   , x_line_rec.GLOBAL_ATTRIBUTE11
10434   , x_line_rec.GLOBAL_ATTRIBUTE12
10435   , x_line_rec.GLOBAL_ATTRIBUTE13
10436   , x_line_rec.GLOBAL_ATTRIBUTE14
10437   , x_line_rec.GLOBAL_ATTRIBUTE15
10438   , x_line_rec.GLOBAL_ATTRIBUTE16
10439   , x_line_rec.GLOBAL_ATTRIBUTE17
10440   , x_line_rec.GLOBAL_ATTRIBUTE18
10441   , x_line_rec.GLOBAL_ATTRIBUTE19
10442   , x_line_rec.GLOBAL_ATTRIBUTE2
10443   , x_line_rec.GLOBAL_ATTRIBUTE20
10444   , x_line_rec.GLOBAL_ATTRIBUTE3
10445   , x_line_rec.GLOBAL_ATTRIBUTE4
10446   , x_line_rec.GLOBAL_ATTRIBUTE5
10447   , x_line_rec.GLOBAL_ATTRIBUTE6
10448   , x_line_rec.GLOBAL_ATTRIBUTE7
10449   , x_line_rec.GLOBAL_ATTRIBUTE8
10450   , x_line_rec.GLOBAL_ATTRIBUTE9
10451   , x_line_rec.GLOBAL_ATTRIBUTE_CATEGORY
10452   , x_line_rec.HEADER_ID
10453   , x_line_rec.INDUSTRY_ATTRIBUTE1
10454   , x_line_rec.INDUSTRY_ATTRIBUTE10
10455   , x_line_rec.INDUSTRY_ATTRIBUTE11
10456   , x_line_rec.INDUSTRY_ATTRIBUTE12
10457   , x_line_rec.INDUSTRY_ATTRIBUTE13
10458   , x_line_rec.INDUSTRY_ATTRIBUTE14
10459   , x_line_rec.INDUSTRY_ATTRIBUTE15
10460   , x_line_rec.INDUSTRY_ATTRIBUTE16
10461   , x_line_rec.INDUSTRY_ATTRIBUTE17
10462   , x_line_rec.INDUSTRY_ATTRIBUTE18
10463   , x_line_rec.INDUSTRY_ATTRIBUTE19
10464   , x_line_rec.INDUSTRY_ATTRIBUTE20
10465   , x_line_rec.INDUSTRY_ATTRIBUTE21
10466   , x_line_rec.INDUSTRY_ATTRIBUTE22
10467   , x_line_rec.INDUSTRY_ATTRIBUTE23
10468   , x_line_rec.INDUSTRY_ATTRIBUTE24
10469   , x_line_rec.INDUSTRY_ATTRIBUTE25
10470   , x_line_rec.INDUSTRY_ATTRIBUTE26
10471   , x_line_rec.INDUSTRY_ATTRIBUTE27
10472   , x_line_rec.INDUSTRY_ATTRIBUTE28
10473   , x_line_rec.INDUSTRY_ATTRIBUTE29
10474   , x_line_rec.INDUSTRY_ATTRIBUTE30
10475   , x_line_rec.INDUSTRY_ATTRIBUTE2
10476   , x_line_rec.INDUSTRY_ATTRIBUTE3
10477   , x_line_rec.INDUSTRY_ATTRIBUTE4
10478   , x_line_rec.INDUSTRY_ATTRIBUTE5
10479   , x_line_rec.INDUSTRY_ATTRIBUTE6
10480   , x_line_rec.INDUSTRY_ATTRIBUTE7
10481   , x_line_rec.INDUSTRY_ATTRIBUTE8
10482   , x_line_rec.INDUSTRY_ATTRIBUTE9
10483   , x_line_rec.INDUSTRY_CONTEXT
10484   , x_line_rec.INTERMED_SHIP_TO_CONTACT_ID
10485   , x_line_rec.INTERMED_SHIP_TO_ORG_ID
10486   , x_line_rec.INVENTORY_ITEM_ID
10487   , x_line_rec.INVOICE_INTERFACE_STATUS_CODE
10488   , x_line_rec.INVOICE_TO_CONTACT_ID
10489   , x_line_rec.INVOICE_TO_ORG_ID
10490   , x_line_rec.INVOICED_QUANTITY
10491   , x_line_rec.INVOICING_RULE_ID
10492   , x_line_rec.ORDERED_ITEM_ID
10493   , x_line_rec.ITEM_IDENTIFIER_TYPE
10494   , x_line_rec.ORDERED_ITEM
10495   , x_line_rec.ITEM_REVISION
10496   , x_line_rec.ITEM_TYPE_CODE
10497   , x_line_rec.LAST_ACK_CODE
10498   , x_line_rec.LAST_ACK_DATE
10499   , x_line_rec.LAST_UPDATED_BY
10500   , x_line_rec.LAST_UPDATE_DATE
10501   , x_line_rec.LAST_UPDATE_LOGIN
10502   , x_line_rec.LATEST_ACCEPTABLE_DATE
10503   , x_line_rec.LINE_CATEGORY_CODE
10504   , x_line_rec.LINE_ID
10505   , x_line_rec.LINE_NUMBER
10506   , x_line_rec.LINE_TYPE_ID
10507   , x_line_rec.LINK_TO_LINE_ID
10508   , x_line_rec.MODEL_GROUP_NUMBER
10509   --  , x_line_rec.MFG_COMPONENT_SEQUENCE_ID
10510   , x_line_rec.MFG_LEAD_TIME
10511   , x_line_rec.OPEN_FLAG
10512   , x_line_rec.OPTION_FLAG
10513   , x_line_rec.OPTION_NUMBER
10514   , x_line_rec.ORDERED_QUANTITY
10515   , x_line_rec.ORDERED_QUANTITY2              --OPM 02/JUN/00
10516   , x_line_rec.ORDER_QUANTITY_UOM
10517   , x_line_rec.ORDERED_QUANTITY_UOM2          --OPM 02/JUN/00
10518   , x_line_rec.ORG_ID
10519   , x_line_rec.ORIG_SYS_DOCUMENT_REF
10520   , x_line_rec.ORIG_SYS_LINE_REF
10521   , x_line_rec.ORIG_SYS_SHIPMENT_REF
10522   , x_line_rec.OVER_SHIP_REASON_CODE
10523   , x_line_rec.OVER_SHIP_RESOLVED_FLAG
10524   , x_line_rec.PAYMENT_TERM_ID
10525   , x_line_rec.PLANNING_PRIORITY
10526   , x_line_rec.PREFERRED_GRADE                --OPM 02/JUN/00
10527   , x_line_rec.PRICE_LIST_ID
10528   , x_line_rec.PRICE_REQUEST_CODE             --PROMOTIONS MAY/01
10529   , x_line_rec.PRICING_ATTRIBUTE1
10530   , x_line_rec.PRICING_ATTRIBUTE10
10531   , x_line_rec.PRICING_ATTRIBUTE2
10532   , x_line_rec.PRICING_ATTRIBUTE3
10533   , x_line_rec.PRICING_ATTRIBUTE4
10534   , x_line_rec.PRICING_ATTRIBUTE5
10535   , x_line_rec.PRICING_ATTRIBUTE6
10536   , x_line_rec.PRICING_ATTRIBUTE7
10537   , x_line_rec.PRICING_ATTRIBUTE8
10538   , x_line_rec.PRICING_ATTRIBUTE9
10539   , x_line_rec.PRICING_CONTEXT
10540   , x_line_rec.PRICING_DATE
10541   , x_line_rec.PRICING_QUANTITY
10542   , x_line_rec.PRICING_QUANTITY_UOM
10543   , x_line_rec.PROGRAM_APPLICATION_ID
10544   , x_line_rec.PROGRAM_ID
10545   , x_line_rec.PROGRAM_UPDATE_DATE
10546   , x_line_rec.PROJECT_ID
10547   , x_line_rec.PROMISE_DATE
10548   , x_line_rec.RE_SOURCE_FLAG
10549   , x_line_rec.REFERENCE_CUSTOMER_TRX_LINE_ID
10550   , x_line_rec.REFERENCE_HEADER_ID
10551   , x_line_rec.REFERENCE_LINE_ID
10552   , x_line_rec.REFERENCE_TYPE
10553   , x_line_rec.REQUEST_DATE
10554   , x_line_rec.REQUEST_ID
10555   , x_line_rec.RETURN_ATTRIBUTE1
10556   , x_line_rec.RETURN_ATTRIBUTE10
10557   , x_line_rec.RETURN_ATTRIBUTE11
10558   , x_line_rec.RETURN_ATTRIBUTE12
10559   , x_line_rec.RETURN_ATTRIBUTE13
10560   , x_line_rec.RETURN_ATTRIBUTE14
10561   , x_line_rec.RETURN_ATTRIBUTE15
10562   , x_line_rec.RETURN_ATTRIBUTE2
10563   , x_line_rec.RETURN_ATTRIBUTE3
10564   , x_line_rec.RETURN_ATTRIBUTE4
10565   , x_line_rec.RETURN_ATTRIBUTE5
10566   , x_line_rec.RETURN_ATTRIBUTE6
10567   , x_line_rec.RETURN_ATTRIBUTE7
10568   , x_line_rec.RETURN_ATTRIBUTE8
10569   , x_line_rec.RETURN_ATTRIBUTE9
10570   , x_line_rec.RETURN_CONTEXT
10571   , x_line_rec.RETURN_REASON_CODE
10572   , x_line_rec.RLA_SCHEDULE_TYPE_CODE
10573   , x_line_rec.SALESREP_ID
10574   , x_line_rec.SCHEDULE_ARRIVAL_DATE
10575   , x_line_rec.SCHEDULE_SHIP_DATE
10576   , x_line_rec.SCHEDULE_STATUS_CODE
10577   , x_line_rec.SHIPMENT_NUMBER
10578   , x_line_rec.SHIPMENT_PRIORITY_CODE
10579   , x_line_rec.SHIPPED_QUANTITY
10580   , x_line_rec.SHIPPED_QUANTITY2 -- OPM B1661023 04/02/01
10581   , x_line_rec.SHIPPING_METHOD_CODE
10582   , x_line_rec.SHIPPING_QUANTITY
10583   , x_line_rec.SHIPPING_QUANTITY2 -- OPM B1661023 04/02/01
10584   , x_line_rec.SHIPPING_QUANTITY_UOM
10585   , x_line_rec.SHIPPING_QUANTITY_UOM2
10586   , x_line_rec.SHIP_FROM_ORG_ID
10587   , x_line_rec.SUBINVENTORY
10588   , x_line_rec.SHIP_SET_ID
10589   , x_line_rec.SHIP_TOLERANCE_ABOVE
10590   , x_line_rec.SHIP_TOLERANCE_BELOW
10591   , x_line_rec.SHIPPABLE_FLAG
10592   , x_line_rec.SHIPPING_INTERFACED_FLAG
10593   , x_line_rec.SHIP_TO_CONTACT_ID
10594   , x_line_rec.SHIP_TO_ORG_ID
10595   , x_line_rec.SHIP_MODEL_COMPLETE_FLAG
10596   , x_line_rec.SOLD_TO_ORG_ID
10597   , x_line_rec.SOLD_FROM_ORG_ID
10598   , x_line_rec.SORT_ORDER
10599   , x_line_rec.SOURCE_DOCUMENT_ID
10600   , x_line_rec.SOURCE_DOCUMENT_LINE_ID
10601   , x_line_rec.SOURCE_DOCUMENT_TYPE_ID
10602   , x_line_rec.SOURCE_TYPE_CODE
10603   , x_line_rec.SPLIT_FROM_LINE_ID
10604   , x_line_rec.LINE_SET_ID
10605   , x_line_rec.SPLIT_BY
10606   , x_line_rec.MODEL_REMNANT_FLAG
10607   , x_line_rec.TASK_ID
10608   , x_line_rec.TAX_CODE
10609   , x_line_rec.TAX_DATE
10610   , x_line_rec.TAX_EXEMPT_FLAG
10611   , x_line_rec.TAX_EXEMPT_NUMBER
10612   , x_line_rec.TAX_EXEMPT_REASON_CODE
10613   , x_line_rec.TAX_POINT_CODE
10614   , x_line_rec.TAX_RATE
10615   , x_line_rec.TAX_VALUE
10616   , x_line_rec.TOP_MODEL_LINE_ID
10617   , x_line_rec.UNIT_LIST_PRICE
10618   , x_line_rec.UNIT_LIST_PRICE_PER_PQTY
10619   , x_line_rec.UNIT_SELLING_PRICE
10620   , x_line_rec.UNIT_SELLING_PRICE_PER_PQTY
10621   , x_line_rec.VISIBLE_DEMAND_FLAG
10622   , x_line_rec.VEH_CUS_ITEM_CUM_KEY_ID
10623   , x_line_rec.SHIPPING_INSTRUCTIONS
10624   , x_line_rec.PACKING_INSTRUCTIONS
10625   , x_line_rec.SERVICE_TXN_REASON_CODE
10626   , x_line_rec.SERVICE_TXN_COMMENTS
10627   , x_line_rec.SERVICE_DURATION
10628   , x_line_rec.SERVICE_PERIOD
10629   , x_line_rec.SERVICE_START_DATE
10630   , x_line_rec.SERVICE_END_DATE
10631   , x_line_rec.SERVICE_COTERMINATE_FLAG
10632   , x_line_rec.UNIT_LIST_PERCENT
10633   , x_line_rec.UNIT_SELLING_PERCENT
10634   , x_line_rec.UNIT_PERCENT_BASE_PRICE
10635   , x_line_rec.SERVICE_NUMBER
10636   , x_line_rec.SERVICE_REFERENCE_TYPE_CODE
10637   , x_line_rec.SERVICE_REFERENCE_LINE_ID
10638   , x_line_rec.SERVICE_REFERENCE_SYSTEM_ID
10639   , x_line_rec.TP_CONTEXT
10640   , x_line_rec.TP_ATTRIBUTE1
10641   , x_line_rec.TP_ATTRIBUTE2
10642   , x_line_rec.TP_ATTRIBUTE3
10643   , x_line_rec.TP_ATTRIBUTE4
10644   , x_line_rec.TP_ATTRIBUTE5
10645   , x_line_rec.TP_ATTRIBUTE6
10646   , x_line_rec.TP_ATTRIBUTE7
10647   , x_line_rec.TP_ATTRIBUTE8
10648   , x_line_rec.TP_ATTRIBUTE9
10649   , x_line_rec.TP_ATTRIBUTE10
10650   , x_line_rec.TP_ATTRIBUTE11
10651   , x_line_rec.TP_ATTRIBUTE12
10652   , x_line_rec.TP_ATTRIBUTE13
10653   , x_line_rec.TP_ATTRIBUTE14
10654   , x_line_rec.TP_ATTRIBUTE15
10655   , x_line_rec.FLOW_STATUS_CODE
10656   , x_line_rec.MARKETING_SOURCE_CODE_ID
10657   , x_line_rec.CALCULATE_PRICE_FLAG
10658   , x_line_rec.COMMITMENT_ID
10659   , x_line_rec.ORDER_SOURCE_ID        -- aksingh
10660   , x_line_rec.UPGRADED_FLAG
10661   , x_line_rec.ORIGINAL_INVENTORY_ITEM_ID
10662   , x_line_rec.ORIGINAL_ITEM_IDENTIFIER_TYPE
10663   , x_line_rec.ORIGINAL_ORDERED_ITEM_ID
10664   , x_line_rec.ORIGINAL_ORDERED_ITEM
10665   , x_line_rec.ITEM_RELATIONSHIP_TYPE
10666   , x_line_rec.ITEM_SUBSTITUTION_TYPE_CODE
10667   , x_line_rec.LATE_DEMAND_PENALTY_FACTOR
10668   , x_line_rec.OVERRIDE_ATP_DATE_CODE
10669   , x_line_rec.FIRM_DEMAND_FLAG
10670   , x_line_rec.EARLIEST_SHIP_DATE
10671   , x_line_rec.USER_ITEM_DESCRIPTION
10672   , x_line_rec.BLANKET_NUMBER
10673   , x_line_rec.BLANKET_LINE_NUMBER
10674   , x_line_rec.BLANKET_VERSION_NUMBER
10675   , x_line_rec.UNIT_COST
10676   , x_line_rec.LOCK_CONTROL
10677   , x_line_rec.CHANGE_SEQUENCE
10678   , x_line_rec.transaction_phase_code
10679   , x_line_rec.source_document_version_number
10680   , x_line_rec.MINISITE_ID
10681    , x_line_rec.Ib_Owner
10682    , x_line_rec.Ib_installed_at_location
10683    , x_line_rec.Ib_current_location
10684    , x_line_rec.End_customer_ID
10685    , x_line_rec.End_customer_contact_ID
10686    , x_line_rec.End_customer_site_use_ID
10687    , x_line_rec.RETROBILL_REQUEST_ID
10688    , x_line_rec.ORIGINAL_LIST_PRICE  -- Override List Price
10689    , x_line_rec.order_firmed_date
10690    , x_line_rec.actual_fulfillment_date
10691    , x_line_rec.charge_periodicity_code
10692    , x_line_rec.cancelled_quantity2
10693    , x_line_rec.fulfilled_quantity2
10694    , x_line_rec.CONTINGENCY_ID
10695    , x_line_rec.REVREC_EVENT_CODE
10696    , x_line_rec.REVREC_EXPIRATION_DAYS
10697    , x_line_rec.ACCEPTED_QUANTITY
10698    , x_line_rec.REVREC_COMMENTS
10699    , x_line_rec.REVREC_SIGNATURE
10700    , x_line_rec.REVREC_SIGNATURE_DATE
10701    , x_line_rec.ACCEPTED_BY
10702    , x_line_rec.REVREC_REFERENCE_DOCUMENT
10703    , x_line_rec.REVREC_IMPLICIT_FLAG;
10704 
10705   --Added for bug5068941 start
10706   if l_line_csr%notfound then
10707      raise NO_DATA_FOUND;
10708   end if;
10709   --Added for bug5068941 end
10710 
10711 If NOT OE_FEATURES_PVT.Is_Margin_Avail Then
10712    IF l_debug_level  > 0 THEN
10713      oe_debug_pub.add('inside margin ',1);
10714    END IF;
10715    x_line_rec.unit_cost:= NULL;
10716 End If;
10717 
10718 	   -- set values for non-DB fields
10719 	x_line_rec.db_flag 		:= FND_API.G_TRUE;
10720 	x_line_rec.operation 		:= FND_API.G_MISS_CHAR;
10721 	x_line_rec.return_status 	:= FND_API.G_MISS_CHAR;
10722 
10723 	x_line_rec.schedule_action_code 	:= FND_API.G_MISS_CHAR;
10724 	x_line_rec.reserved_quantity 	:= FND_API.G_MISS_NUM;
10725 	x_line_rec.reserved_quantity2 	:= FND_API.G_MISS_NUM; -- INVCONV
10726 	x_line_rec.change_reason 		:= FND_API.G_MISS_CHAR;
10727 	x_line_rec.change_comments 		:= FND_API.G_MISS_CHAR;
10728 	x_line_rec.arrival_set      	:= FND_API.G_MISS_CHAR;
10729 	x_line_rec.ship_set 			:= FND_API.G_MISS_CHAR;
10730 	x_line_rec.fulfillment_set 		:= FND_API.G_MISS_CHAR;
10731 	x_line_rec.split_action_code 	:= FND_API.G_MISS_CHAR;
10732 
10733 
10734     CLOSE l_line_csr;
10735 
10736    IF l_debug_level  > 0 THEN
10737       oe_debug_pub.add('Exiting OE_LINE_UTIL.QUERY_ROW', 1);
10738     END IF;
10739 
10740 
10741 EXCEPTION
10742 
10743     WHEN NO_DATA_FOUND THEN
10744 
10745        RAISE NO_DATA_FOUND;
10746 
10747     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
10748 
10749         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10750 
10751     WHEN OTHERS THEN
10752 
10753         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
10754         THEN
10755             OE_MSG_PUB.Add_Exc_Msg
10756             (   G_PKG_NAME
10757           ,   'Query_Row'
10758             );
10759         END IF;
10760 
10761         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10762 
10763 END Query_Row;
10764 
10765 
10766 /*----------------------------------------------------------
10767  PROCEDURE Query_Rows
10768 
10769  When you add/delete columns to query_rows function,
10770  Please do the same changes in OE_Config_Util package body
10771  Query_Config function.
10772 -----------------------------------------------------------*/
10773 
10774 PROCEDURE Query_Rows
10775 (   p_line_id                       IN  NUMBER :=
10776                                         FND_API.G_MISS_NUM
10777 ,   p_header_id                     IN  NUMBER :=
10778                                         FND_API.G_MISS_NUM
10779 ,   p_line_set_id                   IN  NUMBER :=
10780                                         FND_API.G_MISS_NUM
10781 ,   x_line_tbl                      IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
10782  )
10783 IS
10784 l_org_id 		      	NUMBER;
10785 i				NUMBER;
10786 l_entity                        NUMBER;
10787 
10788 -- OPM 02/JUN/00 - Include process columns
10789 --                (ordered_quantity2,ordered_quantity_uom2,preferred_grade)
10790 -- =======================================================================
10791 
10792 -- Fix bug 2868226: The SQL has been modified to use 3 separate cursors,
10793 -- allowing for a simpler explain plan and significantly reduced shared
10794 -- memory usage.
10795 
10796 CURSOR l_line_csr_h IS
10797     SELECT  ACCOUNTING_RULE_ID
10798   , ACCOUNTING_RULE_DURATION
10799   , ACTUAL_ARRIVAL_DATE
10800   , ACTUAL_SHIPMENT_DATE
10801   , AGREEMENT_ID
10802   , ARRIVAL_SET_ID
10803   , ATO_LINE_ID
10804   , ATTRIBUTE1
10805   , ATTRIBUTE10
10806   , ATTRIBUTE11
10807   , ATTRIBUTE12
10808   , ATTRIBUTE13
10809   , ATTRIBUTE14
10810   , ATTRIBUTE15
10811   , ATTRIBUTE16   --For bug 2184255
10812   , ATTRIBUTE17
10813   , ATTRIBUTE18
10814   , ATTRIBUTE19
10815   , ATTRIBUTE2
10816   , ATTRIBUTE20
10817   , ATTRIBUTE3
10818   , ATTRIBUTE4
10819   , ATTRIBUTE5
10820   , ATTRIBUTE6
10821   , ATTRIBUTE7
10822   , ATTRIBUTE8
10823   , ATTRIBUTE9
10824   , AUTO_SELECTED_QUANTITY
10825   , AUTHORIZED_TO_SHIP_FLAG
10826   , BOOKED_FLAG
10827   , CANCELLED_FLAG
10828   , CANCELLED_QUANTITY
10829   , COMPONENT_CODE
10830   , COMPONENT_NUMBER
10831   , COMPONENT_SEQUENCE_ID
10832   , CONFIG_HEADER_ID
10833   , CONFIG_REV_NBR
10834   , CONFIG_DISPLAY_SEQUENCE
10835   , CONFIGURATION_ID
10836   , CONTEXT
10837 
10838   , CREATED_BY
10839   , CREATION_DATE
10840   , CREDIT_INVOICE_LINE_ID
10841   , CUSTOMER_DOCK_CODE
10842   , CUSTOMER_JOB
10843   , CUSTOMER_PRODUCTION_LINE
10844   , CUST_PRODUCTION_SEQ_NUM
10845   , CUSTOMER_TRX_LINE_ID
10846   , CUST_MODEL_SERIAL_NUMBER
10847   , CUST_PO_NUMBER
10848   , CUSTOMER_LINE_NUMBER
10849   , CUSTOMER_SHIPMENT_NUMBER
10850   , CUSTOMER_ITEM_NET_PRICE
10851   , DELIVERY_LEAD_TIME
10852   , DELIVER_TO_CONTACT_ID
10853   , DELIVER_TO_ORG_ID
10854   , DEMAND_BUCKET_TYPE_CODE
10855   , DEMAND_CLASS_CODE
10856   , DEP_PLAN_REQUIRED_FLAG
10857 
10858   , EARLIEST_ACCEPTABLE_DATE
10859   , END_ITEM_UNIT_NUMBER
10860   , EXPLOSION_DATE
10861   , FIRST_ACK_CODE
10862   , FIRST_ACK_DATE
10863   , FOB_POINT_CODE
10864   , FREIGHT_CARRIER_CODE
10865   , FREIGHT_TERMS_CODE
10866   , FULFILLED_QUANTITY
10867   , FULFILLED_FLAG
10868   , FULFILLMENT_METHOD_CODE
10869   , FULFILLMENT_DATE
10870   , GLOBAL_ATTRIBUTE1
10871   , GLOBAL_ATTRIBUTE10
10872   , GLOBAL_ATTRIBUTE11
10873   , GLOBAL_ATTRIBUTE12
10874   , GLOBAL_ATTRIBUTE13
10875   , GLOBAL_ATTRIBUTE14
10876   , GLOBAL_ATTRIBUTE15
10877   , GLOBAL_ATTRIBUTE16
10878   , GLOBAL_ATTRIBUTE17
10879   , GLOBAL_ATTRIBUTE18
10880   , GLOBAL_ATTRIBUTE19
10881   , GLOBAL_ATTRIBUTE2
10882   , GLOBAL_ATTRIBUTE20
10883   , GLOBAL_ATTRIBUTE3
10884   , GLOBAL_ATTRIBUTE4
10885   , GLOBAL_ATTRIBUTE5
10886   , GLOBAL_ATTRIBUTE6
10887   , GLOBAL_ATTRIBUTE7
10888   , GLOBAL_ATTRIBUTE8
10889   , GLOBAL_ATTRIBUTE9
10890   , GLOBAL_ATTRIBUTE_CATEGORY
10891   , HEADER_ID
10892   , INDUSTRY_ATTRIBUTE1
10893   , INDUSTRY_ATTRIBUTE10
10894   , INDUSTRY_ATTRIBUTE11
10895   , INDUSTRY_ATTRIBUTE12
10896   , INDUSTRY_ATTRIBUTE13
10897   , INDUSTRY_ATTRIBUTE14
10898   , INDUSTRY_ATTRIBUTE15
10899   , INDUSTRY_ATTRIBUTE16
10900   , INDUSTRY_ATTRIBUTE17
10901   , INDUSTRY_ATTRIBUTE18
10902   , INDUSTRY_ATTRIBUTE19
10903   , INDUSTRY_ATTRIBUTE20
10904   , INDUSTRY_ATTRIBUTE21
10905   , INDUSTRY_ATTRIBUTE22
10906   , INDUSTRY_ATTRIBUTE23
10907   , INDUSTRY_ATTRIBUTE24
10908   , INDUSTRY_ATTRIBUTE25
10909   , INDUSTRY_ATTRIBUTE26
10910   , INDUSTRY_ATTRIBUTE27
10911   , INDUSTRY_ATTRIBUTE28
10912   , INDUSTRY_ATTRIBUTE29
10913   , INDUSTRY_ATTRIBUTE30
10914   , INDUSTRY_ATTRIBUTE2
10915   , INDUSTRY_ATTRIBUTE3
10916   , INDUSTRY_ATTRIBUTE4
10917   , INDUSTRY_ATTRIBUTE5
10918   , INDUSTRY_ATTRIBUTE6
10919   , INDUSTRY_ATTRIBUTE7
10920   , INDUSTRY_ATTRIBUTE8
10921   , INDUSTRY_ATTRIBUTE9
10922   , INDUSTRY_CONTEXT
10923   , INTMED_SHIP_TO_CONTACT_ID
10924   , INTMED_SHIP_TO_ORG_ID
10925   , INVENTORY_ITEM_ID
10926   , INVOICE_INTERFACE_STATUS_CODE
10927 
10928   , INVOICE_TO_CONTACT_ID
10929   , INVOICE_TO_ORG_ID
10930   , INVOICED_QUANTITY
10931   , INVOICING_RULE_ID
10932   , ORDERED_ITEM_ID
10933   , ITEM_IDENTIFIER_TYPE
10934   , ORDERED_ITEM
10935   , ITEM_REVISION
10936   , ITEM_TYPE_CODE
10937   , LAST_ACK_CODE
10938   , LAST_ACK_DATE
10939   , LAST_UPDATED_BY
10940   , LAST_UPDATE_DATE
10941   , LAST_UPDATE_LOGIN
10942   , LATEST_ACCEPTABLE_DATE
10943   , LINE_CATEGORY_CODE
10944   , LINE_ID
10945   , LINE_NUMBER
10946   , LINE_TYPE_ID
10947   , LINK_TO_LINE_ID
10948 
10949   , MODEL_GROUP_NUMBER
10950   --  , MFG_COMPONENT_SEQUENCE_ID
10951   , MFG_LEAD_TIME
10952   , OPEN_FLAG
10953   , OPTION_FLAG
10954   , OPTION_NUMBER
10955   , ORDERED_QUANTITY
10956   , ORDERED_QUANTITY2              --OPM 02/JUN/00
10957   , ORDER_QUANTITY_UOM
10958   , ORDERED_QUANTITY_UOM2          --OPM 02/JUN/00
10959   , ORG_ID
10960   , ORIG_SYS_DOCUMENT_REF
10961   , ORIG_SYS_LINE_REF
10962   , ORIG_SYS_SHIPMENT_REF
10963   , OVER_SHIP_REASON_CODE
10964   , OVER_SHIP_RESOLVED_FLAG
10965   , PAYMENT_TERM_ID
10966   , PLANNING_PRIORITY
10967   , PREFERRED_GRADE                --OPM 02/JUN/00
10968   , PRICE_LIST_ID
10969   , PRICE_REQUEST_CODE             --PROMOTIONS SEP/01
10970   , PRICING_ATTRIBUTE1
10971   , PRICING_ATTRIBUTE10
10972   , PRICING_ATTRIBUTE2
10973   , PRICING_ATTRIBUTE3
10974   , PRICING_ATTRIBUTE4
10975   , PRICING_ATTRIBUTE5
10976   , PRICING_ATTRIBUTE6
10977   , PRICING_ATTRIBUTE7
10978   , PRICING_ATTRIBUTE8
10979   , PRICING_ATTRIBUTE9
10980   , PRICING_CONTEXT
10981   , PRICING_DATE
10982   , PRICING_QUANTITY
10983   , PRICING_QUANTITY_UOM
10984   , PROGRAM_APPLICATION_ID
10985   , PROGRAM_ID
10986   , PROGRAM_UPDATE_DATE
10987   , PROJECT_ID
10988   , PROMISE_DATE
10989   , RE_SOURCE_FLAG
10990   , REFERENCE_CUSTOMER_TRX_LINE_ID
10991   , REFERENCE_HEADER_ID
10992   , REFERENCE_LINE_ID
10993   , REFERENCE_TYPE
10994 
10995   , REQUEST_DATE
10996   , REQUEST_ID
10997   , RETURN_ATTRIBUTE1
10998   , RETURN_ATTRIBUTE10
10999   , RETURN_ATTRIBUTE11
11000   , RETURN_ATTRIBUTE12
11001   , RETURN_ATTRIBUTE13
11002   , RETURN_ATTRIBUTE14
11003   , RETURN_ATTRIBUTE15
11004   , RETURN_ATTRIBUTE2
11005   , RETURN_ATTRIBUTE3
11006   , RETURN_ATTRIBUTE4
11007   , RETURN_ATTRIBUTE5
11008   , RETURN_ATTRIBUTE6
11009   , RETURN_ATTRIBUTE7
11010   , RETURN_ATTRIBUTE8
11011   , RETURN_ATTRIBUTE9
11012   , RETURN_CONTEXT
11013   , RETURN_REASON_CODE
11014   , RLA_SCHEDULE_TYPE_CODE
11015   , SALESREP_ID
11016   , SCHEDULE_ARRIVAL_DATE
11017   , SCHEDULE_SHIP_DATE
11018   , SCHEDULE_STATUS_CODE
11019   , SHIPMENT_NUMBER
11020   , SHIPMENT_PRIORITY_CODE
11021   , SHIPPED_QUANTITY
11022   , SHIPPED_QUANTITY2 -- OPM B1661023 04/02/01
11023   , SHIPPING_METHOD_CODE
11024   , SHIPPING_QUANTITY
11025   , SHIPPING_QUANTITY2 -- OPM B1661023 04/02/01
11026   , SHIPPING_QUANTITY_UOM
11027   , SHIPPING_QUANTITY_UOM2 -- INVCONV
11028   , SHIP_FROM_ORG_ID
11029   , SUBINVENTORY
11030   , SHIP_SET_ID
11031   , SHIP_TOLERANCE_ABOVE
11032   , SHIP_TOLERANCE_BELOW
11033   , SHIPPABLE_FLAG
11034   , SHIPPING_INTERFACED_FLAG
11035   , SHIP_TO_CONTACT_ID
11036   , SHIP_TO_ORG_ID
11037   , SHIP_MODEL_COMPLETE_FLAG
11038   , SOLD_TO_ORG_ID
11039   , SOLD_FROM_ORG_ID
11040   , SORT_ORDER
11041   , SOURCE_DOCUMENT_ID
11042   , SOURCE_DOCUMENT_LINE_ID
11043   , SOURCE_DOCUMENT_TYPE_ID
11044   , SOURCE_TYPE_CODE
11045   , SPLIT_FROM_LINE_ID
11046   , LINE_SET_ID
11047   , SPLIT_BY
11048   , MODEL_REMNANT_FLAG
11049   , TASK_ID
11050   , TAX_CODE
11051   , TAX_DATE
11052   , TAX_EXEMPT_FLAG
11053   , TAX_EXEMPT_NUMBER
11054   , TAX_EXEMPT_REASON_CODE
11055   , TAX_POINT_CODE
11056   , TAX_RATE
11057   , TAX_VALUE
11058   , TOP_MODEL_LINE_ID
11059   , UNIT_LIST_PRICE
11060   , UNIT_LIST_PRICE_PER_PQTY
11061   , UNIT_SELLING_PRICE
11062   , UNIT_SELLING_PRICE_PER_PQTY
11063   , VISIBLE_DEMAND_FLAG
11064   , VEH_CUS_ITEM_CUM_KEY_ID
11065   , SHIPPING_INSTRUCTIONS
11066   , PACKING_INSTRUCTIONS
11067   , SERVICE_TXN_REASON_CODE
11068   , SERVICE_TXN_COMMENTS
11069   , SERVICE_DURATION
11070   , SERVICE_PERIOD
11071   , SERVICE_START_DATE
11072   , SERVICE_END_DATE
11073   , SERVICE_COTERMINATE_FLAG
11074   , UNIT_LIST_PERCENT
11075   , UNIT_SELLING_PERCENT
11076   , UNIT_PERCENT_BASE_PRICE
11077   , SERVICE_NUMBER
11078   , SERVICE_REFERENCE_TYPE_CODE
11079   , SERVICE_REFERENCE_LINE_ID
11080   , SERVICE_REFERENCE_SYSTEM_ID
11081   , TP_CONTEXT
11082   , TP_ATTRIBUTE1
11083   , TP_ATTRIBUTE2
11084   , TP_ATTRIBUTE3
11085   , TP_ATTRIBUTE4
11086   , TP_ATTRIBUTE5
11087   , TP_ATTRIBUTE6
11088   , TP_ATTRIBUTE7
11089   , TP_ATTRIBUTE8
11090   , TP_ATTRIBUTE9
11091   , TP_ATTRIBUTE10
11092   , TP_ATTRIBUTE11
11093   , TP_ATTRIBUTE12
11094   , TP_ATTRIBUTE13
11095   , TP_ATTRIBUTE14
11096   , TP_ATTRIBUTE15
11097   , FLOW_STATUS_CODE
11098   , MARKETING_SOURCE_CODE_ID
11099   , CALCULATE_PRICE_FLAG
11100   , COMMITMENT_ID
11101   , ORDER_SOURCE_ID        -- aksingh
11102   , upgraded_flag
11103   , ORIGINAL_INVENTORY_ITEM_ID
11104   , ORIGINAL_ITEM_IDENTIFIER_TYPE
11105   , ORIGINAL_ORDERED_ITEM_ID
11106   , ORIGINAL_ORDERED_ITEM
11107   , ITEM_RELATIONSHIP_TYPE
11108   , ITEM_SUBSTITUTION_TYPE_CODE
11109   , LATE_DEMAND_PENALTY_FACTOR
11110   , OVERRIDE_ATP_DATE_CODE
11111   , FIRM_DEMAND_FLAG
11112   , EARLIEST_SHIP_DATE
11113   , USER_ITEM_DESCRIPTION
11114   , BLANKET_NUMBER
11115   , BLANKET_LINE_NUMBER
11116   , BLANKET_VERSION_NUMBER
11117     --MRG B
11118   , UNIT_COST
11119     --MRG E
11120   , LOCK_CONTROL
11121   , NVL(OPTION_NUMBER, -1)  OPN
11122   , NVL(COMPONENT_NUMBER, -1)  CPN
11123   , NVL(SERVICE_NUMBER, -1)  SVN
11124   , CHANGE_SEQUENCE
11125 	-- Changes to quoting
11126   , transaction_phase_code
11127    ,      source_document_version_number
11128 	-- End changes to quoting
11129   , MINISITE_ID
11130    ,  Ib_Owner
11131    ,  Ib_installed_at_location
11132    ,  Ib_current_location
11133    ,  End_customer_ID
11134    ,  End_customer_contact_ID
11135    ,  End_customer_site_use_ID
11136 /*   ,  Supplier_signature
11137    ,  Supplier_signature_date
11138    ,  Customer_signature
11139    ,  Customer_signature_date  */
11140    --retro{
11141    , RETROBILL_REQUEST_ID
11142    --retro}
11143    , ORIGINAL_LIST_PRICE  -- Override List Price
11144  -- key Transaction Dates
11145    , order_firmed_date
11146    , actual_fulfillment_date
11147 
11148    --recurring charges
11149    , charge_periodicity_code
11150 -- INVCONV
11151     , CANCELLED_QUANTITY2
11152     , FULFILLED_QUANTITY2
11153   --Customer Acceptance
11154    ,CONTINGENCY_ID
11155    ,REVREC_EVENT_CODE
11156    ,REVREC_EXPIRATION_DAYS
11157    ,ACCEPTED_QUANTITY
11158    ,REVREC_COMMENTS
11159    ,REVREC_SIGNATURE
11160    ,REVREC_SIGNATURE_DATE
11161    ,ACCEPTED_BY
11162    ,REVREC_REFERENCE_DOCUMENT
11163    ,REVREC_IMPLICIT_FLAG
11164     FROM    OE_ORDER_LINES_ALL  -- Fix for FP bug 3391622
11165     WHERE HEADER_ID = p_header_id
11166     ORDER BY LINE_NUMBER,SHIPMENT_NUMBER,OPN, CPN, SVN;
11167 
11168 
11169 CURSOR l_line_csr_s IS
11170     SELECT  ACCOUNTING_RULE_ID
11171   , ACCOUNTING_RULE_DURATION
11172   , ACTUAL_ARRIVAL_DATE
11173   , ACTUAL_SHIPMENT_DATE
11174   , AGREEMENT_ID
11175   , ARRIVAL_SET_ID
11176   , ATO_LINE_ID
11177   , ATTRIBUTE1
11178   , ATTRIBUTE10
11179   , ATTRIBUTE11
11180   , ATTRIBUTE12
11181   , ATTRIBUTE13
11182   , ATTRIBUTE14
11183   , ATTRIBUTE15
11184   , ATTRIBUTE16   --For bug 2184255
11185   , ATTRIBUTE17
11186   , ATTRIBUTE18
11187   , ATTRIBUTE19
11188   , ATTRIBUTE2
11189   , ATTRIBUTE20
11190   , ATTRIBUTE3
11191   , ATTRIBUTE4
11192   , ATTRIBUTE5
11193   , ATTRIBUTE6
11194   , ATTRIBUTE7
11195   , ATTRIBUTE8
11196   , ATTRIBUTE9
11197   , AUTO_SELECTED_QUANTITY
11198   , AUTHORIZED_TO_SHIP_FLAG
11199   , BOOKED_FLAG
11200   , CANCELLED_FLAG
11201   , CANCELLED_QUANTITY
11202   , COMPONENT_CODE
11203   , COMPONENT_NUMBER
11204   , COMPONENT_SEQUENCE_ID
11205   , CONFIG_HEADER_ID
11206   , CONFIG_REV_NBR
11207   , CONFIG_DISPLAY_SEQUENCE
11208   , CONFIGURATION_ID
11209   , CONTEXT
11210 
11211   , CREATED_BY
11212   , CREATION_DATE
11213   , CREDIT_INVOICE_LINE_ID
11214   , CUSTOMER_DOCK_CODE
11215   , CUSTOMER_JOB
11216   , CUSTOMER_PRODUCTION_LINE
11217   , CUST_PRODUCTION_SEQ_NUM
11218   , CUSTOMER_TRX_LINE_ID
11219   , CUST_MODEL_SERIAL_NUMBER
11220   , CUST_PO_NUMBER
11221   , CUSTOMER_LINE_NUMBER
11222   , CUSTOMER_SHIPMENT_NUMBER
11223   , CUSTOMER_ITEM_NET_PRICE
11224   , DELIVERY_LEAD_TIME
11225   , DELIVER_TO_CONTACT_ID
11226   , DELIVER_TO_ORG_ID
11227   , DEMAND_BUCKET_TYPE_CODE
11228   , DEMAND_CLASS_CODE
11229   , DEP_PLAN_REQUIRED_FLAG
11230 
11231   , EARLIEST_ACCEPTABLE_DATE
11232   , END_ITEM_UNIT_NUMBER
11233   , EXPLOSION_DATE
11234   , FIRST_ACK_CODE
11235   , FIRST_ACK_DATE
11236   , FOB_POINT_CODE
11237   , FREIGHT_CARRIER_CODE
11238   , FREIGHT_TERMS_CODE
11239   , FULFILLED_QUANTITY
11240   , FULFILLED_FLAG
11241   , FULFILLMENT_METHOD_CODE
11242   , FULFILLMENT_DATE
11243   , GLOBAL_ATTRIBUTE1
11244   , GLOBAL_ATTRIBUTE10
11245   , GLOBAL_ATTRIBUTE11
11246   , GLOBAL_ATTRIBUTE12
11247   , GLOBAL_ATTRIBUTE13
11248   , GLOBAL_ATTRIBUTE14
11249   , GLOBAL_ATTRIBUTE15
11250   , GLOBAL_ATTRIBUTE16
11251   , GLOBAL_ATTRIBUTE17
11252   , GLOBAL_ATTRIBUTE18
11253   , GLOBAL_ATTRIBUTE19
11254   , GLOBAL_ATTRIBUTE2
11255   , GLOBAL_ATTRIBUTE20
11256   , GLOBAL_ATTRIBUTE3
11257   , GLOBAL_ATTRIBUTE4
11258   , GLOBAL_ATTRIBUTE5
11259   , GLOBAL_ATTRIBUTE6
11260   , GLOBAL_ATTRIBUTE7
11261   , GLOBAL_ATTRIBUTE8
11262   , GLOBAL_ATTRIBUTE9
11263   , GLOBAL_ATTRIBUTE_CATEGORY
11264   , HEADER_ID
11265   , INDUSTRY_ATTRIBUTE1
11266   , INDUSTRY_ATTRIBUTE10
11267   , INDUSTRY_ATTRIBUTE11
11268   , INDUSTRY_ATTRIBUTE12
11269   , INDUSTRY_ATTRIBUTE13
11270   , INDUSTRY_ATTRIBUTE14
11271   , INDUSTRY_ATTRIBUTE15
11272   , INDUSTRY_ATTRIBUTE16
11273   , INDUSTRY_ATTRIBUTE17
11274   , INDUSTRY_ATTRIBUTE18
11275   , INDUSTRY_ATTRIBUTE19
11276   , INDUSTRY_ATTRIBUTE20
11277   , INDUSTRY_ATTRIBUTE21
11278   , INDUSTRY_ATTRIBUTE22
11279   , INDUSTRY_ATTRIBUTE23
11280   , INDUSTRY_ATTRIBUTE24
11281   , INDUSTRY_ATTRIBUTE25
11282   , INDUSTRY_ATTRIBUTE26
11283   , INDUSTRY_ATTRIBUTE27
11284   , INDUSTRY_ATTRIBUTE28
11285   , INDUSTRY_ATTRIBUTE29
11286   , INDUSTRY_ATTRIBUTE30
11287   , INDUSTRY_ATTRIBUTE2
11288   , INDUSTRY_ATTRIBUTE3
11289   , INDUSTRY_ATTRIBUTE4
11290   , INDUSTRY_ATTRIBUTE5
11291   , INDUSTRY_ATTRIBUTE6
11292   , INDUSTRY_ATTRIBUTE7
11293   , INDUSTRY_ATTRIBUTE8
11294   , INDUSTRY_ATTRIBUTE9
11295   , INDUSTRY_CONTEXT
11296   , INTMED_SHIP_TO_CONTACT_ID
11297   , INTMED_SHIP_TO_ORG_ID
11298   , INVENTORY_ITEM_ID
11299   , INVOICE_INTERFACE_STATUS_CODE
11300 
11301 
11302 
11303   , INVOICE_TO_CONTACT_ID
11304   , INVOICE_TO_ORG_ID
11305   , INVOICED_QUANTITY
11306   , INVOICING_RULE_ID
11307   , ORDERED_ITEM_ID
11308   , ITEM_IDENTIFIER_TYPE
11309   , ORDERED_ITEM
11310   , ITEM_REVISION
11311   , ITEM_TYPE_CODE
11312   , LAST_ACK_CODE
11313   , LAST_ACK_DATE
11314   , LAST_UPDATED_BY
11315   , LAST_UPDATE_DATE
11316   , LAST_UPDATE_LOGIN
11317   , LATEST_ACCEPTABLE_DATE
11318   , LINE_CATEGORY_CODE
11319   , LINE_ID
11320   , LINE_NUMBER
11321   , LINE_TYPE_ID
11322   , LINK_TO_LINE_ID
11323 
11324   , MODEL_GROUP_NUMBER
11325   --  , MFG_COMPONENT_SEQUENCE_ID
11326   , MFG_LEAD_TIME
11327   , OPEN_FLAG
11328   , OPTION_FLAG
11329   , OPTION_NUMBER
11330   , ORDERED_QUANTITY
11331   , ORDERED_QUANTITY2              --OPM 02/JUN/00
11332   , ORDER_QUANTITY_UOM
11333   , ORDERED_QUANTITY_UOM2          --OPM 02/JUN/00
11334   , ORG_ID
11335   , ORIG_SYS_DOCUMENT_REF
11336   , ORIG_SYS_LINE_REF
11337   , ORIG_SYS_SHIPMENT_REF
11338   , OVER_SHIP_REASON_CODE
11339   , OVER_SHIP_RESOLVED_FLAG
11340   , PAYMENT_TERM_ID
11341   , PLANNING_PRIORITY
11342   , PREFERRED_GRADE                --OPM 02/JUN/00
11343   , PRICE_LIST_ID
11344   , PRICE_REQUEST_CODE             --PROMOTIONS SEP/01
11345   , PRICING_ATTRIBUTE1
11346   , PRICING_ATTRIBUTE10
11347   , PRICING_ATTRIBUTE2
11348   , PRICING_ATTRIBUTE3
11349   , PRICING_ATTRIBUTE4
11350   , PRICING_ATTRIBUTE5
11351   , PRICING_ATTRIBUTE6
11352   , PRICING_ATTRIBUTE7
11353   , PRICING_ATTRIBUTE8
11354   , PRICING_ATTRIBUTE9
11355   , PRICING_CONTEXT
11356   , PRICING_DATE
11357   , PRICING_QUANTITY
11358   , PRICING_QUANTITY_UOM
11359   , PROGRAM_APPLICATION_ID
11360   , PROGRAM_ID
11361   , PROGRAM_UPDATE_DATE
11362   , PROJECT_ID
11363   , PROMISE_DATE
11364   , RE_SOURCE_FLAG
11365   , REFERENCE_CUSTOMER_TRX_LINE_ID
11366   , REFERENCE_HEADER_ID
11367   , REFERENCE_LINE_ID
11368   , REFERENCE_TYPE
11369 
11370   , REQUEST_DATE
11371   , REQUEST_ID
11372   , RETURN_ATTRIBUTE1
11373   , RETURN_ATTRIBUTE10
11374   , RETURN_ATTRIBUTE11
11375   , RETURN_ATTRIBUTE12
11376   , RETURN_ATTRIBUTE13
11377   , RETURN_ATTRIBUTE14
11378   , RETURN_ATTRIBUTE15
11379   , RETURN_ATTRIBUTE2
11380   , RETURN_ATTRIBUTE3
11381   , RETURN_ATTRIBUTE4
11382   , RETURN_ATTRIBUTE5
11383   , RETURN_ATTRIBUTE6
11384   , RETURN_ATTRIBUTE7
11385   , RETURN_ATTRIBUTE8
11386   , RETURN_ATTRIBUTE9
11387   , RETURN_CONTEXT
11388   , RETURN_REASON_CODE
11389   , RLA_SCHEDULE_TYPE_CODE
11390   , SALESREP_ID
11391   , SCHEDULE_ARRIVAL_DATE
11392   , SCHEDULE_SHIP_DATE
11393   , SCHEDULE_STATUS_CODE
11394   , SHIPMENT_NUMBER
11395   , SHIPMENT_PRIORITY_CODE
11396   , SHIPPED_QUANTITY
11397   , SHIPPED_QUANTITY2 -- OPM B1661023 04/02/01
11398   , SHIPPING_METHOD_CODE
11399   , SHIPPING_QUANTITY
11400   , SHIPPING_QUANTITY2 -- OPM B1661023 04/02/01
11401   , SHIPPING_QUANTITY_UOM
11402   , SHIPPING_QUANTITY_UOM2 -- INVCONV
11403   , SHIP_FROM_ORG_ID
11404   , SUBINVENTORY
11405   , SHIP_SET_ID
11406   , SHIP_TOLERANCE_ABOVE
11407   , SHIP_TOLERANCE_BELOW
11408   , SHIPPABLE_FLAG
11409   , SHIPPING_INTERFACED_FLAG
11410   , SHIP_TO_CONTACT_ID
11411   , SHIP_TO_ORG_ID
11412   , SHIP_MODEL_COMPLETE_FLAG
11413   , SOLD_TO_ORG_ID
11414   , SOLD_FROM_ORG_ID
11415   , SORT_ORDER
11416   , SOURCE_DOCUMENT_ID
11417   , SOURCE_DOCUMENT_LINE_ID
11418   , SOURCE_DOCUMENT_TYPE_ID
11419   , SOURCE_TYPE_CODE
11420   , SPLIT_FROM_LINE_ID
11421   , LINE_SET_ID
11422   , SPLIT_BY
11423   , MODEL_REMNANT_FLAG
11424   , TASK_ID
11425   , TAX_CODE
11426   , TAX_DATE
11427   , TAX_EXEMPT_FLAG
11428   , TAX_EXEMPT_NUMBER
11429   , TAX_EXEMPT_REASON_CODE
11430   , TAX_POINT_CODE
11431   , TAX_RATE
11432   , TAX_VALUE
11433   , TOP_MODEL_LINE_ID
11434   , UNIT_LIST_PRICE
11435   , UNIT_LIST_PRICE_PER_PQTY
11436   , UNIT_SELLING_PRICE
11437   , UNIT_SELLING_PRICE_PER_PQTY
11438   , VISIBLE_DEMAND_FLAG
11439   , VEH_CUS_ITEM_CUM_KEY_ID
11440   , SHIPPING_INSTRUCTIONS
11441   , PACKING_INSTRUCTIONS
11442   , SERVICE_TXN_REASON_CODE
11443   , SERVICE_TXN_COMMENTS
11444   , SERVICE_DURATION
11445   , SERVICE_PERIOD
11446   , SERVICE_START_DATE
11447   , SERVICE_END_DATE
11448   , SERVICE_COTERMINATE_FLAG
11449   , UNIT_LIST_PERCENT
11450   , UNIT_SELLING_PERCENT
11451   , UNIT_PERCENT_BASE_PRICE
11452   , SERVICE_NUMBER
11453   , SERVICE_REFERENCE_TYPE_CODE
11454   , SERVICE_REFERENCE_LINE_ID
11455   , SERVICE_REFERENCE_SYSTEM_ID
11456   , TP_CONTEXT
11457   , TP_ATTRIBUTE1
11458   , TP_ATTRIBUTE2
11459   , TP_ATTRIBUTE3
11460   , TP_ATTRIBUTE4
11461   , TP_ATTRIBUTE5
11462   , TP_ATTRIBUTE6
11463   , TP_ATTRIBUTE7
11464   , TP_ATTRIBUTE8
11465   , TP_ATTRIBUTE9
11466   , TP_ATTRIBUTE10
11467   , TP_ATTRIBUTE11
11468   , TP_ATTRIBUTE12
11469   , TP_ATTRIBUTE13
11470   , TP_ATTRIBUTE14
11471   , TP_ATTRIBUTE15
11472   , FLOW_STATUS_CODE
11473   , MARKETING_SOURCE_CODE_ID
11474   , CALCULATE_PRICE_FLAG
11475   , COMMITMENT_ID
11476   , ORDER_SOURCE_ID        -- aksingh
11477   , upgraded_flag
11478   , ORIGINAL_INVENTORY_ITEM_ID
11479   , ORIGINAL_ITEM_IDENTIFIER_TYPE
11480   , ORIGINAL_ORDERED_ITEM_ID
11481   , ORIGINAL_ORDERED_ITEM
11482   , ITEM_RELATIONSHIP_TYPE
11483   , ITEM_SUBSTITUTION_TYPE_CODE
11484   , LATE_DEMAND_PENALTY_FACTOR
11485   , OVERRIDE_ATP_DATE_CODE
11486   , FIRM_DEMAND_FLAG
11487   , EARLIEST_SHIP_DATE
11488   , USER_ITEM_DESCRIPTION
11489   , BLANKET_NUMBER
11490   , BLANKET_LINE_NUMBER
11491   , BLANKET_VERSION_NUMBER
11492 --MRG B
11493   , UNIT_COST
11494 --MRG E
11495   , LOCK_CONTROL
11496   , NVL(OPTION_NUMBER, -1)  OPN
11497   , NVL(COMPONENT_NUMBER, -1)  CPN
11498   , NVL(SERVICE_NUMBER, -1)  SVN
11499   , CHANGE_SEQUENCE
11500 	-- Changes to quoting
11501   , transaction_phase_code
11502    ,      source_document_version_number
11503 	-- End changes to quoting
11504   , MINISITE_ID
11505    ,  Ib_Owner
11506    ,  Ib_installed_at_location
11507    ,  Ib_current_location
11508    ,  End_customer_ID
11509    ,  End_customer_contact_ID
11510    ,  End_customer_site_use_ID
11511 /*   ,  Supplier_signature
11512    ,  Supplier_signature_date
11513    ,  Customer_signature
11514    ,  Customer_signature_date  */
11515    --retro{
11516    , RETROBILL_REQUEST_ID
11517    --retro}
11518    , ORIGINAL_LIST_PRICE  -- Override List Price
11519  -- key Transaction Dates
11520    , order_firmed_date
11521    , actual_fulfillment_date
11522    --recurring charges
11523    , charge_periodicity_code
11524    -- INVCONV
11525     , CANCELLED_QUANTITY2
11526     , FULFILLED_QUANTITY2
11527   --Customer Acceptance
11528    ,CONTINGENCY_ID
11529    ,REVREC_EVENT_CODE
11530    ,REVREC_EXPIRATION_DAYS
11531    ,ACCEPTED_QUANTITY
11532    ,REVREC_COMMENTS
11533    ,REVREC_SIGNATURE
11534    ,REVREC_SIGNATURE_DATE
11535    ,ACCEPTED_BY
11536    ,REVREC_REFERENCE_DOCUMENT
11537    ,REVREC_IMPLICIT_FLAG
11538     FROM    OE_ORDER_LINES_ALL  -- Fix for FP bug 3391622
11539     WHERE LINE_SET_ID = p_line_set_id
11540     ORDER BY LINE_NUMBER,SHIPMENT_NUMBER,OPN, CPN, SVN;
11541 
11542     l_OPN   NUMBER;
11543     l_CPN   NUMBER;
11544     l_SVN   NUMBER;
11545 
11546 
11547 --
11548 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
11549 --
11550 l_line_rec OE_ORDER_PUB.line_rec_type;
11551 BEGIN
11552 
11553     IF l_debug_level  > 0 THEN
11554       oe_debug_pub.add('Entering OE_LINE_UTIL.QUERY_ROWS, line_id:'||p_line_id, 1);
11555     END IF;
11556 
11557     IF
11558     (p_line_id IS NOT NULL
11559      AND
11560      p_line_id <> FND_API.G_MISS_NUM)
11561     AND
11562     (p_header_id IS NOT NULL
11563      AND
11564      p_header_id <> FND_API.G_MISS_NUM)
11565     THEN
11566             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
11567             THEN
11568                 OE_MSG_PUB.Add_Exc_Msg
11569                 (   G_PKG_NAME
11570               ,   'Query Rows'
11571               ,   'Keys are mutually exclusive: line_id = '|| p_line_id || ', header_id = '|| p_header_id
11572                 );
11573             END IF;
11574 
11575         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11576 
11577     END IF;
11578 
11579     -----------------------------------------------------------------
11580     -- Fix bug 1275972: Setup the l_entity variable based on the ID
11581     -- variable that is passed.
11582     -----------------------------------------------------------------
11583 
11584     IF nvl(p_line_id,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM THEN
11585 
11586 	   l_entity := 1;
11587         Query_Row(p_line_id => p_line_id,
11588                   x_line_rec => l_line_rec);
11589         x_line_tbl(1) := l_line_rec;
11590         RETURN;
11591     ELSIF nvl(p_header_id,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM THEN
11592 
11593 	   l_entity := 2;
11594            OPEN l_line_csr_h;
11595 
11596     ELSIF nvl(p_line_set_id,FND_API.G_MISS_NUM) <> FND_API.G_MISS_NUM THEN
11597 
11598 	   l_entity := 3;
11599            OPEN l_line_csr_s;
11600 
11601     END IF;
11602 
11603     --Commented for MOAC start
11604     /*l_org_id := OE_GLOBALS.G_ORG_ID;
11605     if l_org_id IS NULL THEN
11606        OE_GLOBALS.Set_Context;
11607        l_org_id := OE_GLOBALS.G_ORG_ID;
11608     end if;
11609     IF l_debug_level  > 0 THEN
11610       oe_debug_pub.add('Entering '||to_char(l_org_id), 1);
11611     END IF;*/
11612   --Commented for MOAC end
11613 
11614     --  Loop over fetched records
11615 
11616     i := 1;
11617 
11618     LOOP
11619 
11620         IF l_entity = 2 THEN
11621              FETCH l_line_csr_h INTO
11622               x_line_tbl(i).ACCOUNTING_RULE_ID
11623             , x_line_tbl(i).ACCOUNTING_RULE_DURATION
11624             , x_line_tbl(i).ACTUAL_ARRIVAL_DATE
11625             , x_line_tbl(i).ACTUAL_SHIPMENT_DATE
11626             , x_line_tbl(i).AGREEMENT_ID
11627             , x_line_tbl(i).ARRIVAL_SET_ID
11628             , x_line_tbl(i).ATO_LINE_ID
11629             , x_line_tbl(i).ATTRIBUTE1
11630             , x_line_tbl(i).ATTRIBUTE10
11631             , x_line_tbl(i).ATTRIBUTE11
11632             , x_line_tbl(i).ATTRIBUTE12
11633             , x_line_tbl(i).ATTRIBUTE13
11634             , x_line_tbl(i).ATTRIBUTE14
11635             , x_line_tbl(i).ATTRIBUTE15
11636             , x_line_tbl(i).ATTRIBUTE16   --For bug 2184255
11637             , x_line_tbl(i).ATTRIBUTE17
11638             , x_line_tbl(i).ATTRIBUTE18
11639             , x_line_tbl(i).ATTRIBUTE19
11640             , x_line_tbl(i).ATTRIBUTE2
11641             , x_line_tbl(i).ATTRIBUTE20
11642             , x_line_tbl(i).ATTRIBUTE3
11643             , x_line_tbl(i).ATTRIBUTE4
11644             , x_line_tbl(i).ATTRIBUTE5
11645             , x_line_tbl(i).ATTRIBUTE6
11646             , x_line_tbl(i).ATTRIBUTE7
11647             , x_line_tbl(i).ATTRIBUTE8
11648             , x_line_tbl(i).ATTRIBUTE9
11649             , x_line_tbl(i).AUTO_SELECTED_QUANTITY
11650             , x_line_tbl(i).AUTHORIZED_TO_SHIP_FLAG
11651             , x_line_tbl(i).BOOKED_FLAG
11652             , x_line_tbl(i).CANCELLED_FLAG
11653             , x_line_tbl(i).CANCELLED_QUANTITY
11654             , x_line_tbl(i).COMPONENT_CODE
11655             , x_line_tbl(i).COMPONENT_NUMBER
11656             , x_line_tbl(i).COMPONENT_SEQUENCE_ID
11657             , x_line_tbl(i).CONFIG_HEADER_ID
11658             , x_line_tbl(i).CONFIG_REV_NBR
11659             , x_line_tbl(i).CONFIG_DISPLAY_SEQUENCE
11660             , x_line_tbl(i).CONFIGURATION_ID
11661             , x_line_tbl(i).CONTEXT
11662             , x_line_tbl(i).CREATED_BY
11663             , x_line_tbl(i).CREATION_DATE
11664             , x_line_tbl(i).CREDIT_INVOICE_LINE_ID
11665             , x_line_tbl(i).CUSTOMER_DOCK_CODE
11666             , x_line_tbl(i).CUSTOMER_JOB
11667             , x_line_tbl(i).CUSTOMER_PRODUCTION_LINE
11668             , x_line_tbl(i).CUST_PRODUCTION_SEQ_NUM
11669             , x_line_tbl(i).CUSTOMER_TRX_LINE_ID
11670             , x_line_tbl(i).CUST_MODEL_SERIAL_NUMBER
11671             , x_line_tbl(i).CUST_PO_NUMBER
11672             , x_line_tbl(i).CUSTOMER_LINE_NUMBER
11673             , x_line_tbl(i).CUSTOMER_SHIPMENT_NUMBER
11674             , x_line_tbl(i).CUSTOMER_ITEM_NET_PRICE
11675             , x_line_tbl(i).DELIVERY_LEAD_TIME
11676             , x_line_tbl(i).DELIVER_TO_CONTACT_ID
11677             , x_line_tbl(i).DELIVER_TO_ORG_ID
11678             , x_line_tbl(i).DEMAND_BUCKET_TYPE_CODE
11679             , x_line_tbl(i).DEMAND_CLASS_CODE
11680             , x_line_tbl(i).DEP_PLAN_REQUIRED_FLAG
11681             , x_line_tbl(i).EARLIEST_ACCEPTABLE_DATE
11682             , x_line_tbl(i).END_ITEM_UNIT_NUMBER
11683             , x_line_tbl(i).EXPLOSION_DATE
11684             , x_line_tbl(i).FIRST_ACK_CODE
11685             , x_line_tbl(i).FIRST_ACK_DATE
11686             , x_line_tbl(i).FOB_POINT_CODE
11687             , x_line_tbl(i).FREIGHT_CARRIER_CODE
11688             , x_line_tbl(i).FREIGHT_TERMS_CODE
11689             , x_line_tbl(i).FULFILLED_QUANTITY
11690             , x_line_tbl(i).FULFILLED_FLAG
11691             , x_line_tbl(i).FULFILLMENT_METHOD_CODE
11692             , x_line_tbl(i).FULFILLMENT_DATE
11693             , x_line_tbl(i).GLOBAL_ATTRIBUTE1
11694             , x_line_tbl(i).GLOBAL_ATTRIBUTE10
11695             , x_line_tbl(i).GLOBAL_ATTRIBUTE11
11696             , x_line_tbl(i).GLOBAL_ATTRIBUTE12
11697             , x_line_tbl(i).GLOBAL_ATTRIBUTE13
11698             , x_line_tbl(i).GLOBAL_ATTRIBUTE14
11699             , x_line_tbl(i).GLOBAL_ATTRIBUTE15
11700             , x_line_tbl(i).GLOBAL_ATTRIBUTE16
11701             , x_line_tbl(i).GLOBAL_ATTRIBUTE17
11702             , x_line_tbl(i).GLOBAL_ATTRIBUTE18
11703             , x_line_tbl(i).GLOBAL_ATTRIBUTE19
11704             , x_line_tbl(i).GLOBAL_ATTRIBUTE2
11705             , x_line_tbl(i).GLOBAL_ATTRIBUTE20
11706             , x_line_tbl(i).GLOBAL_ATTRIBUTE3
11707             , x_line_tbl(i).GLOBAL_ATTRIBUTE4
11708             , x_line_tbl(i).GLOBAL_ATTRIBUTE5
11709             , x_line_tbl(i).GLOBAL_ATTRIBUTE6
11710             , x_line_tbl(i).GLOBAL_ATTRIBUTE7
11711             , x_line_tbl(i).GLOBAL_ATTRIBUTE8
11712             , x_line_tbl(i).GLOBAL_ATTRIBUTE9
11713             , x_line_tbl(i).GLOBAL_ATTRIBUTE_CATEGORY
11714             , x_line_tbl(i).HEADER_ID
11715             , x_line_tbl(i).INDUSTRY_ATTRIBUTE1
11716             , x_line_tbl(i).INDUSTRY_ATTRIBUTE10
11717             , x_line_tbl(i).INDUSTRY_ATTRIBUTE11
11718             , x_line_tbl(i).INDUSTRY_ATTRIBUTE12
11719             , x_line_tbl(i).INDUSTRY_ATTRIBUTE13
11720             , x_line_tbl(i).INDUSTRY_ATTRIBUTE14
11721             , x_line_tbl(i).INDUSTRY_ATTRIBUTE15
11722             , x_line_tbl(i).INDUSTRY_ATTRIBUTE16
11723             , x_line_tbl(i).INDUSTRY_ATTRIBUTE17
11724             , x_line_tbl(i).INDUSTRY_ATTRIBUTE18
11725             , x_line_tbl(i).INDUSTRY_ATTRIBUTE19
11726             , x_line_tbl(i).INDUSTRY_ATTRIBUTE20
11727             , x_line_tbl(i).INDUSTRY_ATTRIBUTE21
11728             , x_line_tbl(i).INDUSTRY_ATTRIBUTE22
11729             , x_line_tbl(i).INDUSTRY_ATTRIBUTE23
11730             , x_line_tbl(i).INDUSTRY_ATTRIBUTE24
11731             , x_line_tbl(i).INDUSTRY_ATTRIBUTE25
11732             , x_line_tbl(i).INDUSTRY_ATTRIBUTE26
11733             , x_line_tbl(i).INDUSTRY_ATTRIBUTE27
11734             , x_line_tbl(i).INDUSTRY_ATTRIBUTE28
11735             , x_line_tbl(i).INDUSTRY_ATTRIBUTE29
11736             , x_line_tbl(i).INDUSTRY_ATTRIBUTE30
11737             , x_line_tbl(i).INDUSTRY_ATTRIBUTE2
11738             , x_line_tbl(i).INDUSTRY_ATTRIBUTE3
11739             , x_line_tbl(i).INDUSTRY_ATTRIBUTE4
11740             , x_line_tbl(i).INDUSTRY_ATTRIBUTE5
11741             , x_line_tbl(i).INDUSTRY_ATTRIBUTE6
11742             , x_line_tbl(i).INDUSTRY_ATTRIBUTE7
11743             , x_line_tbl(i).INDUSTRY_ATTRIBUTE8
11744             , x_line_tbl(i).INDUSTRY_ATTRIBUTE9
11745             , x_line_tbl(i).INDUSTRY_CONTEXT
11746             , x_line_tbl(i).INTERMED_SHIP_TO_CONTACT_ID
11747             , x_line_tbl(i).INTERMED_SHIP_TO_ORG_ID
11748             , x_line_tbl(i).INVENTORY_ITEM_ID
11749             , x_line_tbl(i).INVOICE_INTERFACE_STATUS_CODE
11750             , x_line_tbl(i).INVOICE_TO_CONTACT_ID
11751             , x_line_tbl(i).INVOICE_TO_ORG_ID
11752             , x_line_tbl(i).INVOICED_QUANTITY
11753             , x_line_tbl(i).INVOICING_RULE_ID
11754             , x_line_tbl(i).ORDERED_ITEM_ID
11755             , x_line_tbl(i).ITEM_IDENTIFIER_TYPE
11756             , x_line_tbl(i).ORDERED_ITEM
11757             , x_line_tbl(i).ITEM_REVISION
11758             , x_line_tbl(i).ITEM_TYPE_CODE
11759             , x_line_tbl(i).LAST_ACK_CODE
11760             , x_line_tbl(i).LAST_ACK_DATE
11761             , x_line_tbl(i).LAST_UPDATED_BY
11762             , x_line_tbl(i).LAST_UPDATE_DATE
11763             , x_line_tbl(i).LAST_UPDATE_LOGIN
11764             , x_line_tbl(i).LATEST_ACCEPTABLE_DATE
11765             , x_line_tbl(i).LINE_CATEGORY_CODE
11766             , x_line_tbl(i).LINE_ID
11767             , x_line_tbl(i).LINE_NUMBER
11768             , x_line_tbl(i).LINE_TYPE_ID
11769             , x_line_tbl(i).LINK_TO_LINE_ID
11770             , x_line_tbl(i).MODEL_GROUP_NUMBER
11771             --  , x_line_tbl(i).MFG_COMPONENT_SEQUENCE_ID
11772             , x_line_tbl(i).MFG_LEAD_TIME
11773             , x_line_tbl(i).OPEN_FLAG
11774             , x_line_tbl(i).OPTION_FLAG
11775             , x_line_tbl(i).OPTION_NUMBER
11776             , x_line_tbl(i).ORDERED_QUANTITY
11777             , x_line_tbl(i).ORDERED_QUANTITY2              --OPM 02/JUN/00
11778             , x_line_tbl(i).ORDER_QUANTITY_UOM
11779             , x_line_tbl(i).ORDERED_QUANTITY_UOM2          --OPM 02/JUN/00
11780             , x_line_tbl(i).ORG_ID
11781             , x_line_tbl(i).ORIG_SYS_DOCUMENT_REF
11782             , x_line_tbl(i).ORIG_SYS_LINE_REF
11783             , x_line_tbl(i).ORIG_SYS_SHIPMENT_REF
11784             , x_line_tbl(i).OVER_SHIP_REASON_CODE
11785             , x_line_tbl(i).OVER_SHIP_RESOLVED_FLAG
11786             , x_line_tbl(i).PAYMENT_TERM_ID
11787             , x_line_tbl(i).PLANNING_PRIORITY
11788             , x_line_tbl(i).PREFERRED_GRADE                --OPM 02/JUN/00
11789             , x_line_tbl(i).PRICE_LIST_ID
11790             , x_line_tbl(i).PRICE_REQUEST_CODE             --PROMOTIONS MAY/01
11791             , x_line_tbl(i).PRICING_ATTRIBUTE1
11792             , x_line_tbl(i).PRICING_ATTRIBUTE10
11793             , x_line_tbl(i).PRICING_ATTRIBUTE2
11794             , x_line_tbl(i).PRICING_ATTRIBUTE3
11795             , x_line_tbl(i).PRICING_ATTRIBUTE4
11796             , x_line_tbl(i).PRICING_ATTRIBUTE5
11797             , x_line_tbl(i).PRICING_ATTRIBUTE6
11798             , x_line_tbl(i).PRICING_ATTRIBUTE7
11799             , x_line_tbl(i).PRICING_ATTRIBUTE8
11800             , x_line_tbl(i).PRICING_ATTRIBUTE9
11801             , x_line_tbl(i).PRICING_CONTEXT
11802             , x_line_tbl(i).PRICING_DATE
11803             , x_line_tbl(i).PRICING_QUANTITY
11804             , x_line_tbl(i).PRICING_QUANTITY_UOM
11805             , x_line_tbl(i).PROGRAM_APPLICATION_ID
11806             , x_line_tbl(i).PROGRAM_ID
11807             , x_line_tbl(i).PROGRAM_UPDATE_DATE
11808             , x_line_tbl(i).PROJECT_ID
11809             , x_line_tbl(i).PROMISE_DATE
11810             , x_line_tbl(i).RE_SOURCE_FLAG
11811             , x_line_tbl(i).REFERENCE_CUSTOMER_TRX_LINE_ID
11812             , x_line_tbl(i).REFERENCE_HEADER_ID
11813             , x_line_tbl(i).REFERENCE_LINE_ID
11814             , x_line_tbl(i).REFERENCE_TYPE
11815             , x_line_tbl(i).REQUEST_DATE
11816             , x_line_tbl(i).REQUEST_ID
11817             , x_line_tbl(i).RETURN_ATTRIBUTE1
11818             , x_line_tbl(i).RETURN_ATTRIBUTE10
11819             , x_line_tbl(i).RETURN_ATTRIBUTE11
11820             , x_line_tbl(i).RETURN_ATTRIBUTE12
11821             , x_line_tbl(i).RETURN_ATTRIBUTE13
11822             , x_line_tbl(i).RETURN_ATTRIBUTE14
11823             , x_line_tbl(i).RETURN_ATTRIBUTE15
11824             , x_line_tbl(i).RETURN_ATTRIBUTE2
11825             , x_line_tbl(i).RETURN_ATTRIBUTE3
11826             , x_line_tbl(i).RETURN_ATTRIBUTE4
11827             , x_line_tbl(i).RETURN_ATTRIBUTE5
11828             , x_line_tbl(i).RETURN_ATTRIBUTE6
11829             , x_line_tbl(i).RETURN_ATTRIBUTE7
11830             , x_line_tbl(i).RETURN_ATTRIBUTE8
11831             , x_line_tbl(i).RETURN_ATTRIBUTE9
11832             , x_line_tbl(i).RETURN_CONTEXT
11833             , x_line_tbl(i).RETURN_REASON_CODE
11834             , x_line_tbl(i).RLA_SCHEDULE_TYPE_CODE
11835             , x_line_tbl(i).SALESREP_ID
11836             , x_line_tbl(i).SCHEDULE_ARRIVAL_DATE
11837             , x_line_tbl(i).SCHEDULE_SHIP_DATE
11838             , x_line_tbl(i).SCHEDULE_STATUS_CODE
11839             , x_line_tbl(i).SHIPMENT_NUMBER
11840             , x_line_tbl(i).SHIPMENT_PRIORITY_CODE
11841             , x_line_tbl(i).SHIPPED_QUANTITY
11842             , x_line_tbl(i).SHIPPED_QUANTITY2 -- OPM B1661023 04/02/01
11843             , x_line_tbl(i).SHIPPING_METHOD_CODE
11844             , x_line_tbl(i).SHIPPING_QUANTITY
11845             , x_line_tbl(i).SHIPPING_QUANTITY2 -- OPM B1661023 04/02/01
11846             , x_line_tbl(i).SHIPPING_QUANTITY_UOM
11847             , x_line_tbl(i).SHIPPING_QUANTITY_UOM2
11848             , x_line_tbl(i).SHIP_FROM_ORG_ID
11849             , x_line_tbl(i).SUBINVENTORY
11850             , x_line_tbl(i).SHIP_SET_ID
11851             , x_line_tbl(i).SHIP_TOLERANCE_ABOVE
11852             , x_line_tbl(i).SHIP_TOLERANCE_BELOW
11853             , x_line_tbl(i).SHIPPABLE_FLAG
11854             , x_line_tbl(i).SHIPPING_INTERFACED_FLAG
11855             , x_line_tbl(i).SHIP_TO_CONTACT_ID
11856             , x_line_tbl(i).SHIP_TO_ORG_ID
11857             , x_line_tbl(i).SHIP_MODEL_COMPLETE_FLAG
11858             , x_line_tbl(i).SOLD_TO_ORG_ID
11859             , x_line_tbl(i).SOLD_FROM_ORG_ID
11860             , x_line_tbl(i).SORT_ORDER
11861             , x_line_tbl(i).SOURCE_DOCUMENT_ID
11862             , x_line_tbl(i).SOURCE_DOCUMENT_LINE_ID
11863             , x_line_tbl(i).SOURCE_DOCUMENT_TYPE_ID
11864             , x_line_tbl(i).SOURCE_TYPE_CODE
11865             , x_line_tbl(i).SPLIT_FROM_LINE_ID
11866             , x_line_tbl(i).LINE_SET_ID
11867             , x_line_tbl(i).SPLIT_BY
11868             , x_line_tbl(i).MODEL_REMNANT_FLAG
11869             , x_line_tbl(i).TASK_ID
11870             , x_line_tbl(i).TAX_CODE
11871             , x_line_tbl(i).TAX_DATE
11872             , x_line_tbl(i).TAX_EXEMPT_FLAG
11873             , x_line_tbl(i).TAX_EXEMPT_NUMBER
11874             , x_line_tbl(i).TAX_EXEMPT_REASON_CODE
11875             , x_line_tbl(i).TAX_POINT_CODE
11876             , x_line_tbl(i).TAX_RATE
11877             , x_line_tbl(i).TAX_VALUE
11878             , x_line_tbl(i).TOP_MODEL_LINE_ID
11879             , x_line_tbl(i).UNIT_LIST_PRICE
11880             , x_line_tbl(i).UNIT_LIST_PRICE_PER_PQTY
11881             , x_line_tbl(i).UNIT_SELLING_PRICE
11882             , x_line_tbl(i).UNIT_SELLING_PRICE_PER_PQTY
11883             , x_line_tbl(i).VISIBLE_DEMAND_FLAG
11884             , x_line_tbl(i).VEH_CUS_ITEM_CUM_KEY_ID
11885             , x_line_tbl(i).SHIPPING_INSTRUCTIONS
11886             , x_line_tbl(i).PACKING_INSTRUCTIONS
11887             , x_line_tbl(i).SERVICE_TXN_REASON_CODE
11888             , x_line_tbl(i).SERVICE_TXN_COMMENTS
11889             , x_line_tbl(i).SERVICE_DURATION
11890             , x_line_tbl(i).SERVICE_PERIOD
11891             , x_line_tbl(i).SERVICE_START_DATE
11892             , x_line_tbl(i).SERVICE_END_DATE
11893             , x_line_tbl(i).SERVICE_COTERMINATE_FLAG
11894             , x_line_tbl(i).UNIT_LIST_PERCENT
11895             , x_line_tbl(i).UNIT_SELLING_PERCENT
11896             , x_line_tbl(i).UNIT_PERCENT_BASE_PRICE
11897             , x_line_tbl(i).SERVICE_NUMBER
11898             , x_line_tbl(i).SERVICE_REFERENCE_TYPE_CODE
11899             , x_line_tbl(i).SERVICE_REFERENCE_LINE_ID
11900             , x_line_tbl(i).SERVICE_REFERENCE_SYSTEM_ID
11901             , x_line_tbl(i).TP_CONTEXT
11902             , x_line_tbl(i).TP_ATTRIBUTE1
11903             , x_line_tbl(i).TP_ATTRIBUTE2
11904             , x_line_tbl(i).TP_ATTRIBUTE3
11905             , x_line_tbl(i).TP_ATTRIBUTE4
11906             , x_line_tbl(i).TP_ATTRIBUTE5
11907             , x_line_tbl(i).TP_ATTRIBUTE6
11908             , x_line_tbl(i).TP_ATTRIBUTE7
11909             , x_line_tbl(i).TP_ATTRIBUTE8
11910             , x_line_tbl(i).TP_ATTRIBUTE9
11911             , x_line_tbl(i).TP_ATTRIBUTE10
11912             , x_line_tbl(i).TP_ATTRIBUTE11
11913             , x_line_tbl(i).TP_ATTRIBUTE12
11914             , x_line_tbl(i).TP_ATTRIBUTE13
11915             , x_line_tbl(i).TP_ATTRIBUTE14
11916             , x_line_tbl(i).TP_ATTRIBUTE15
11917             , x_line_tbl(i).FLOW_STATUS_CODE
11918             , x_line_tbl(i).MARKETING_SOURCE_CODE_ID
11919             , x_line_tbl(i).CALCULATE_PRICE_FLAG
11920             , x_line_tbl(i).COMMITMENT_ID
11921             , x_line_tbl(i).ORDER_SOURCE_ID        -- aksingh
11922             , x_line_tbl(i).UPGRADED_FLAG
11923             , x_line_tbl(i).ORIGINAL_INVENTORY_ITEM_ID
11924             , x_line_tbl(i).ORIGINAL_ITEM_IDENTIFIER_TYPE
11925             , x_line_tbl(i).ORIGINAL_ORDERED_ITEM_ID
11926             , x_line_tbl(i).ORIGINAL_ORDERED_ITEM
11927             , x_line_tbl(i).ITEM_RELATIONSHIP_TYPE
11928             , x_line_tbl(i).ITEM_SUBSTITUTION_TYPE_CODE
11929             , x_line_tbl(i).LATE_DEMAND_PENALTY_FACTOR
11930             , x_line_tbl(i).OVERRIDE_ATP_DATE_CODE
11931             , x_line_tbl(i).FIRM_DEMAND_FLAG
11932             , x_line_tbl(i).EARLIEST_SHIP_DATE
11933             , x_line_tbl(i).USER_ITEM_DESCRIPTION
11934             , x_line_tbl(i).BLANKET_NUMBER
11935             , x_line_tbl(i).BLANKET_LINE_NUMBER
11936             , x_line_tbl(i).BLANKET_VERSION_NUMBER
11937             , x_line_tbl(i).UNIT_COST
11938             , x_line_tbl(i).LOCK_CONTROL
11939             , l_opn    --OPN
11940             , l_cpn    --CPN
11941             , l_svn    --SVN
11942             , x_line_tbl(i).CHANGE_SEQUENCE
11943             , x_line_tbl(i).transaction_phase_code
11944             , x_line_tbl(i).source_document_version_number
11945             , x_line_tbl(i).MINISITE_ID
11946              , x_line_tbl(i).Ib_Owner
11947              , x_line_tbl(i).Ib_installed_at_location
11948              , x_line_tbl(i).Ib_current_location
11949              , x_line_tbl(i).End_customer_ID
11950              , x_line_tbl(i).End_customer_contact_ID
11951              , x_line_tbl(i).End_customer_site_use_ID
11952              , x_line_tbl(i).RETROBILL_REQUEST_ID
11953              , x_line_tbl(i).ORIGINAL_LIST_PRICE  -- Override List Price
11954              , x_line_tbl(i).order_firmed_date
11955              , x_line_tbl(i).actual_fulfillment_date
11956              , x_line_tbl(i).charge_periodicity_code
11957              , x_line_tbl(i).cancelled_quantity2
11958              , x_line_tbl(i).fulfilled_quantity2
11959              , x_line_tbl(i).CONTINGENCY_ID
11960              , x_line_tbl(i).REVREC_EVENT_CODE
11961              , x_line_tbl(i).REVREC_EXPIRATION_DAYS
11962              , x_line_tbl(i).ACCEPTED_QUANTITY
11963              , x_line_tbl(i).REVREC_COMMENTS
11964              , x_line_tbl(i).REVREC_SIGNATURE
11965              , x_line_tbl(i).REVREC_SIGNATURE_DATE
11966              , x_line_tbl(i).ACCEPTED_BY
11967              , x_line_tbl(i).REVREC_REFERENCE_DOCUMENT
11968              , x_line_tbl(i).REVREC_IMPLICIT_FLAG;
11969 
11970              EXIT WHEN l_line_csr_h%NOTFOUND;
11971 
11972         ELSIF l_entity = 3 THEN
11973              FETCH l_line_csr_s INTO
11974               x_line_tbl(i).ACCOUNTING_RULE_ID
11975             , x_line_tbl(i).ACCOUNTING_RULE_DURATION
11976             , x_line_tbl(i).ACTUAL_ARRIVAL_DATE
11977             , x_line_tbl(i).ACTUAL_SHIPMENT_DATE
11978             , x_line_tbl(i).AGREEMENT_ID
11979             , x_line_tbl(i).ARRIVAL_SET_ID
11980             , x_line_tbl(i).ATO_LINE_ID
11981             , x_line_tbl(i).ATTRIBUTE1
11982             , x_line_tbl(i).ATTRIBUTE10
11983             , x_line_tbl(i).ATTRIBUTE11
11984             , x_line_tbl(i).ATTRIBUTE12
11985             , x_line_tbl(i).ATTRIBUTE13
11986             , x_line_tbl(i).ATTRIBUTE14
11987             , x_line_tbl(i).ATTRIBUTE15
11988             , x_line_tbl(i).ATTRIBUTE16   --For bug 2184255
11989             , x_line_tbl(i).ATTRIBUTE17
11990             , x_line_tbl(i).ATTRIBUTE18
11991             , x_line_tbl(i).ATTRIBUTE19
11992             , x_line_tbl(i).ATTRIBUTE2
11993             , x_line_tbl(i).ATTRIBUTE20
11994             , x_line_tbl(i).ATTRIBUTE3
11995             , x_line_tbl(i).ATTRIBUTE4
11996             , x_line_tbl(i).ATTRIBUTE5
11997             , x_line_tbl(i).ATTRIBUTE6
11998             , x_line_tbl(i).ATTRIBUTE7
11999             , x_line_tbl(i).ATTRIBUTE8
12000             , x_line_tbl(i).ATTRIBUTE9
12001             , x_line_tbl(i).AUTO_SELECTED_QUANTITY
12002             , x_line_tbl(i).AUTHORIZED_TO_SHIP_FLAG
12003             , x_line_tbl(i).BOOKED_FLAG
12004             , x_line_tbl(i).CANCELLED_FLAG
12005             , x_line_tbl(i).CANCELLED_QUANTITY
12006             , x_line_tbl(i).COMPONENT_CODE
12007             , x_line_tbl(i).COMPONENT_NUMBER
12008             , x_line_tbl(i).COMPONENT_SEQUENCE_ID
12009             , x_line_tbl(i).CONFIG_HEADER_ID
12010             , x_line_tbl(i).CONFIG_REV_NBR
12011             , x_line_tbl(i).CONFIG_DISPLAY_SEQUENCE
12012             , x_line_tbl(i).CONFIGURATION_ID
12013             , x_line_tbl(i).CONTEXT
12014             , x_line_tbl(i).CREATED_BY
12015             , x_line_tbl(i).CREATION_DATE
12016             , x_line_tbl(i).CREDIT_INVOICE_LINE_ID
12017             , x_line_tbl(i).CUSTOMER_DOCK_CODE
12018             , x_line_tbl(i).CUSTOMER_JOB
12019             , x_line_tbl(i).CUSTOMER_PRODUCTION_LINE
12020             , x_line_tbl(i).CUST_PRODUCTION_SEQ_NUM
12021             , x_line_tbl(i).CUSTOMER_TRX_LINE_ID
12022             , x_line_tbl(i).CUST_MODEL_SERIAL_NUMBER
12023             , x_line_tbl(i).CUST_PO_NUMBER
12024             , x_line_tbl(i).CUSTOMER_LINE_NUMBER
12025             , x_line_tbl(i).CUSTOMER_SHIPMENT_NUMBER
12026             , x_line_tbl(i).CUSTOMER_ITEM_NET_PRICE
12027             , x_line_tbl(i).DELIVERY_LEAD_TIME
12028             , x_line_tbl(i).DELIVER_TO_CONTACT_ID
12029             , x_line_tbl(i).DELIVER_TO_ORG_ID
12030             , x_line_tbl(i).DEMAND_BUCKET_TYPE_CODE
12031             , x_line_tbl(i).DEMAND_CLASS_CODE
12032             , x_line_tbl(i).DEP_PLAN_REQUIRED_FLAG
12033             , x_line_tbl(i).EARLIEST_ACCEPTABLE_DATE
12034             , x_line_tbl(i).END_ITEM_UNIT_NUMBER
12035             , x_line_tbl(i).EXPLOSION_DATE
12036             , x_line_tbl(i).FIRST_ACK_CODE
12037             , x_line_tbl(i).FIRST_ACK_DATE
12038             , x_line_tbl(i).FOB_POINT_CODE
12039             , x_line_tbl(i).FREIGHT_CARRIER_CODE
12040             , x_line_tbl(i).FREIGHT_TERMS_CODE
12041             , x_line_tbl(i).FULFILLED_QUANTITY
12042             , x_line_tbl(i).FULFILLED_FLAG
12043             , x_line_tbl(i).FULFILLMENT_METHOD_CODE
12044             , x_line_tbl(i).FULFILLMENT_DATE
12045             , x_line_tbl(i).GLOBAL_ATTRIBUTE1
12046             , x_line_tbl(i).GLOBAL_ATTRIBUTE10
12047             , x_line_tbl(i).GLOBAL_ATTRIBUTE11
12048             , x_line_tbl(i).GLOBAL_ATTRIBUTE12
12049             , x_line_tbl(i).GLOBAL_ATTRIBUTE13
12050             , x_line_tbl(i).GLOBAL_ATTRIBUTE14
12051             , x_line_tbl(i).GLOBAL_ATTRIBUTE15
12052             , x_line_tbl(i).GLOBAL_ATTRIBUTE16
12053             , x_line_tbl(i).GLOBAL_ATTRIBUTE17
12054             , x_line_tbl(i).GLOBAL_ATTRIBUTE18
12055             , x_line_tbl(i).GLOBAL_ATTRIBUTE19
12056             , x_line_tbl(i).GLOBAL_ATTRIBUTE2
12057             , x_line_tbl(i).GLOBAL_ATTRIBUTE20
12058             , x_line_tbl(i).GLOBAL_ATTRIBUTE3
12059             , x_line_tbl(i).GLOBAL_ATTRIBUTE4
12060             , x_line_tbl(i).GLOBAL_ATTRIBUTE5
12061             , x_line_tbl(i).GLOBAL_ATTRIBUTE6
12062             , x_line_tbl(i).GLOBAL_ATTRIBUTE7
12063             , x_line_tbl(i).GLOBAL_ATTRIBUTE8
12064             , x_line_tbl(i).GLOBAL_ATTRIBUTE9
12065             , x_line_tbl(i).GLOBAL_ATTRIBUTE_CATEGORY
12066             , x_line_tbl(i).HEADER_ID
12067             , x_line_tbl(i).INDUSTRY_ATTRIBUTE1
12068             , x_line_tbl(i).INDUSTRY_ATTRIBUTE10
12069             , x_line_tbl(i).INDUSTRY_ATTRIBUTE11
12070             , x_line_tbl(i).INDUSTRY_ATTRIBUTE12
12071             , x_line_tbl(i).INDUSTRY_ATTRIBUTE13
12072             , x_line_tbl(i).INDUSTRY_ATTRIBUTE14
12073             , x_line_tbl(i).INDUSTRY_ATTRIBUTE15
12074             , x_line_tbl(i).INDUSTRY_ATTRIBUTE16
12075             , x_line_tbl(i).INDUSTRY_ATTRIBUTE17
12076             , x_line_tbl(i).INDUSTRY_ATTRIBUTE18
12077             , x_line_tbl(i).INDUSTRY_ATTRIBUTE19
12078             , x_line_tbl(i).INDUSTRY_ATTRIBUTE20
12079             , x_line_tbl(i).INDUSTRY_ATTRIBUTE21
12080             , x_line_tbl(i).INDUSTRY_ATTRIBUTE22
12081             , x_line_tbl(i).INDUSTRY_ATTRIBUTE23
12082             , x_line_tbl(i).INDUSTRY_ATTRIBUTE24
12083             , x_line_tbl(i).INDUSTRY_ATTRIBUTE25
12084             , x_line_tbl(i).INDUSTRY_ATTRIBUTE26
12085             , x_line_tbl(i).INDUSTRY_ATTRIBUTE27
12086             , x_line_tbl(i).INDUSTRY_ATTRIBUTE28
12087             , x_line_tbl(i).INDUSTRY_ATTRIBUTE29
12088             , x_line_tbl(i).INDUSTRY_ATTRIBUTE30
12089             , x_line_tbl(i).INDUSTRY_ATTRIBUTE2
12090             , x_line_tbl(i).INDUSTRY_ATTRIBUTE3
12091             , x_line_tbl(i).INDUSTRY_ATTRIBUTE4
12092             , x_line_tbl(i).INDUSTRY_ATTRIBUTE5
12093             , x_line_tbl(i).INDUSTRY_ATTRIBUTE6
12094             , x_line_tbl(i).INDUSTRY_ATTRIBUTE7
12095             , x_line_tbl(i).INDUSTRY_ATTRIBUTE8
12096             , x_line_tbl(i).INDUSTRY_ATTRIBUTE9
12097             , x_line_tbl(i).INDUSTRY_CONTEXT
12098             , x_line_tbl(i).INTERMED_SHIP_TO_CONTACT_ID
12099             , x_line_tbl(i).INTERMED_SHIP_TO_ORG_ID
12100             , x_line_tbl(i).INVENTORY_ITEM_ID
12101             , x_line_tbl(i).INVOICE_INTERFACE_STATUS_CODE
12102             , x_line_tbl(i).INVOICE_TO_CONTACT_ID
12103             , x_line_tbl(i).INVOICE_TO_ORG_ID
12104             , x_line_tbl(i).INVOICED_QUANTITY
12105             , x_line_tbl(i).INVOICING_RULE_ID
12106             , x_line_tbl(i).ORDERED_ITEM_ID
12107             , x_line_tbl(i).ITEM_IDENTIFIER_TYPE
12108             , x_line_tbl(i).ORDERED_ITEM
12109             , x_line_tbl(i).ITEM_REVISION
12110             , x_line_tbl(i).ITEM_TYPE_CODE
12111             , x_line_tbl(i).LAST_ACK_CODE
12112             , x_line_tbl(i).LAST_ACK_DATE
12113             , x_line_tbl(i).LAST_UPDATED_BY
12114             , x_line_tbl(i).LAST_UPDATE_DATE
12115             , x_line_tbl(i).LAST_UPDATE_LOGIN
12116             , x_line_tbl(i).LATEST_ACCEPTABLE_DATE
12117             , x_line_tbl(i).LINE_CATEGORY_CODE
12118             , x_line_tbl(i).LINE_ID
12119             , x_line_tbl(i).LINE_NUMBER
12120             , x_line_tbl(i).LINE_TYPE_ID
12121             , x_line_tbl(i).LINK_TO_LINE_ID
12122             , x_line_tbl(i).MODEL_GROUP_NUMBER
12123             --  , x_line_tbl(i).MFG_COMPONENT_SEQUENCE_ID
12124             , x_line_tbl(i).MFG_LEAD_TIME
12125             , x_line_tbl(i).OPEN_FLAG
12126             , x_line_tbl(i).OPTION_FLAG
12127             , x_line_tbl(i).OPTION_NUMBER
12128             , x_line_tbl(i).ORDERED_QUANTITY
12129             , x_line_tbl(i).ORDERED_QUANTITY2              --OPM 02/JUN/00
12130             , x_line_tbl(i).ORDER_QUANTITY_UOM
12131             , x_line_tbl(i).ORDERED_QUANTITY_UOM2          --OPM 02/JUN/00
12132             , x_line_tbl(i).ORG_ID
12133             , x_line_tbl(i).ORIG_SYS_DOCUMENT_REF
12134             , x_line_tbl(i).ORIG_SYS_LINE_REF
12135             , x_line_tbl(i).ORIG_SYS_SHIPMENT_REF
12136             , x_line_tbl(i).OVER_SHIP_REASON_CODE
12137             , x_line_tbl(i).OVER_SHIP_RESOLVED_FLAG
12138             , x_line_tbl(i).PAYMENT_TERM_ID
12139             , x_line_tbl(i).PLANNING_PRIORITY
12140             , x_line_tbl(i).PREFERRED_GRADE                --OPM 02/JUN/00
12141             , x_line_tbl(i).PRICE_LIST_ID
12142             , x_line_tbl(i).PRICE_REQUEST_CODE             --PROMOTIONS MAY/01
12143             , x_line_tbl(i).PRICING_ATTRIBUTE1
12144             , x_line_tbl(i).PRICING_ATTRIBUTE10
12145             , x_line_tbl(i).PRICING_ATTRIBUTE2
12146             , x_line_tbl(i).PRICING_ATTRIBUTE3
12147             , x_line_tbl(i).PRICING_ATTRIBUTE4
12148             , x_line_tbl(i).PRICING_ATTRIBUTE5
12149             , x_line_tbl(i).PRICING_ATTRIBUTE6
12150             , x_line_tbl(i).PRICING_ATTRIBUTE7
12151             , x_line_tbl(i).PRICING_ATTRIBUTE8
12152             , x_line_tbl(i).PRICING_ATTRIBUTE9
12153             , x_line_tbl(i).PRICING_CONTEXT
12154             , x_line_tbl(i).PRICING_DATE
12155             , x_line_tbl(i).PRICING_QUANTITY
12156             , x_line_tbl(i).PRICING_QUANTITY_UOM
12157             , x_line_tbl(i).PROGRAM_APPLICATION_ID
12158             , x_line_tbl(i).PROGRAM_ID
12159             , x_line_tbl(i).PROGRAM_UPDATE_DATE
12160             , x_line_tbl(i).PROJECT_ID
12161             , x_line_tbl(i).PROMISE_DATE
12162             , x_line_tbl(i).RE_SOURCE_FLAG
12163             , x_line_tbl(i).REFERENCE_CUSTOMER_TRX_LINE_ID
12164             , x_line_tbl(i).REFERENCE_HEADER_ID
12165             , x_line_tbl(i).REFERENCE_LINE_ID
12166             , x_line_tbl(i).REFERENCE_TYPE
12167             , x_line_tbl(i).REQUEST_DATE
12168             , x_line_tbl(i).REQUEST_ID
12169             , x_line_tbl(i).RETURN_ATTRIBUTE1
12170             , x_line_tbl(i).RETURN_ATTRIBUTE10
12171             , x_line_tbl(i).RETURN_ATTRIBUTE11
12172             , x_line_tbl(i).RETURN_ATTRIBUTE12
12173             , x_line_tbl(i).RETURN_ATTRIBUTE13
12174             , x_line_tbl(i).RETURN_ATTRIBUTE14
12175             , x_line_tbl(i).RETURN_ATTRIBUTE15
12176             , x_line_tbl(i).RETURN_ATTRIBUTE2
12177             , x_line_tbl(i).RETURN_ATTRIBUTE3
12178             , x_line_tbl(i).RETURN_ATTRIBUTE4
12179             , x_line_tbl(i).RETURN_ATTRIBUTE5
12180             , x_line_tbl(i).RETURN_ATTRIBUTE6
12181             , x_line_tbl(i).RETURN_ATTRIBUTE7
12182             , x_line_tbl(i).RETURN_ATTRIBUTE8
12183             , x_line_tbl(i).RETURN_ATTRIBUTE9
12184             , x_line_tbl(i).RETURN_CONTEXT
12185             , x_line_tbl(i).RETURN_REASON_CODE
12186             , x_line_tbl(i).RLA_SCHEDULE_TYPE_CODE
12187             , x_line_tbl(i).SALESREP_ID
12188             , x_line_tbl(i).SCHEDULE_ARRIVAL_DATE
12189             , x_line_tbl(i).SCHEDULE_SHIP_DATE
12190             , x_line_tbl(i).SCHEDULE_STATUS_CODE
12191             , x_line_tbl(i).SHIPMENT_NUMBER
12192             , x_line_tbl(i).SHIPMENT_PRIORITY_CODE
12193             , x_line_tbl(i).SHIPPED_QUANTITY
12194             , x_line_tbl(i).SHIPPED_QUANTITY2 -- OPM B1661023 04/02/01
12195             , x_line_tbl(i).SHIPPING_METHOD_CODE
12196             , x_line_tbl(i).SHIPPING_QUANTITY
12197             , x_line_tbl(i).SHIPPING_QUANTITY2 -- OPM B1661023 04/02/01
12198             , x_line_tbl(i).SHIPPING_QUANTITY_UOM
12199             , x_line_tbl(i).SHIPPING_QUANTITY_UOM2
12200             , x_line_tbl(i).SHIP_FROM_ORG_ID
12201             , x_line_tbl(i).SUBINVENTORY
12202             , x_line_tbl(i).SHIP_SET_ID
12203             , x_line_tbl(i).SHIP_TOLERANCE_ABOVE
12204             , x_line_tbl(i).SHIP_TOLERANCE_BELOW
12205             , x_line_tbl(i).SHIPPABLE_FLAG
12206             , x_line_tbl(i).SHIPPING_INTERFACED_FLAG
12207             , x_line_tbl(i).SHIP_TO_CONTACT_ID
12208             , x_line_tbl(i).SHIP_TO_ORG_ID
12209             , x_line_tbl(i).SHIP_MODEL_COMPLETE_FLAG
12210             , x_line_tbl(i).SOLD_TO_ORG_ID
12211             , x_line_tbl(i).SOLD_FROM_ORG_ID
12212             , x_line_tbl(i).SORT_ORDER
12213             , x_line_tbl(i).SOURCE_DOCUMENT_ID
12214             , x_line_tbl(i).SOURCE_DOCUMENT_LINE_ID
12215             , x_line_tbl(i).SOURCE_DOCUMENT_TYPE_ID
12216             , x_line_tbl(i).SOURCE_TYPE_CODE
12217             , x_line_tbl(i).SPLIT_FROM_LINE_ID
12218             , x_line_tbl(i).LINE_SET_ID
12219             , x_line_tbl(i).SPLIT_BY
12220             , x_line_tbl(i).MODEL_REMNANT_FLAG
12221             , x_line_tbl(i).TASK_ID
12222             , x_line_tbl(i).TAX_CODE
12223             , x_line_tbl(i).TAX_DATE
12224             , x_line_tbl(i).TAX_EXEMPT_FLAG
12225             , x_line_tbl(i).TAX_EXEMPT_NUMBER
12226             , x_line_tbl(i).TAX_EXEMPT_REASON_CODE
12227             , x_line_tbl(i).TAX_POINT_CODE
12228             , x_line_tbl(i).TAX_RATE
12229             , x_line_tbl(i).TAX_VALUE
12230             , x_line_tbl(i).TOP_MODEL_LINE_ID
12231             , x_line_tbl(i).UNIT_LIST_PRICE
12232             , x_line_tbl(i).UNIT_LIST_PRICE_PER_PQTY
12233             , x_line_tbl(i).UNIT_SELLING_PRICE
12234             , x_line_tbl(i).UNIT_SELLING_PRICE_PER_PQTY
12235             , x_line_tbl(i).VISIBLE_DEMAND_FLAG
12236             , x_line_tbl(i).VEH_CUS_ITEM_CUM_KEY_ID
12237             , x_line_tbl(i).SHIPPING_INSTRUCTIONS
12238             , x_line_tbl(i).PACKING_INSTRUCTIONS
12239             , x_line_tbl(i).SERVICE_TXN_REASON_CODE
12240             , x_line_tbl(i).SERVICE_TXN_COMMENTS
12241             , x_line_tbl(i).SERVICE_DURATION
12242             , x_line_tbl(i).SERVICE_PERIOD
12243             , x_line_tbl(i).SERVICE_START_DATE
12244             , x_line_tbl(i).SERVICE_END_DATE
12245             , x_line_tbl(i).SERVICE_COTERMINATE_FLAG
12246             , x_line_tbl(i).UNIT_LIST_PERCENT
12247             , x_line_tbl(i).UNIT_SELLING_PERCENT
12248             , x_line_tbl(i).UNIT_PERCENT_BASE_PRICE
12249             , x_line_tbl(i).SERVICE_NUMBER
12250             , x_line_tbl(i).SERVICE_REFERENCE_TYPE_CODE
12251             , x_line_tbl(i).SERVICE_REFERENCE_LINE_ID
12252             , x_line_tbl(i).SERVICE_REFERENCE_SYSTEM_ID
12253             , x_line_tbl(i).TP_CONTEXT
12254             , x_line_tbl(i).TP_ATTRIBUTE1
12255             , x_line_tbl(i).TP_ATTRIBUTE2
12256             , x_line_tbl(i).TP_ATTRIBUTE3
12257             , x_line_tbl(i).TP_ATTRIBUTE4
12258             , x_line_tbl(i).TP_ATTRIBUTE5
12259             , x_line_tbl(i).TP_ATTRIBUTE6
12260             , x_line_tbl(i).TP_ATTRIBUTE7
12261             , x_line_tbl(i).TP_ATTRIBUTE8
12262             , x_line_tbl(i).TP_ATTRIBUTE9
12263             , x_line_tbl(i).TP_ATTRIBUTE10
12264             , x_line_tbl(i).TP_ATTRIBUTE11
12265             , x_line_tbl(i).TP_ATTRIBUTE12
12266             , x_line_tbl(i).TP_ATTRIBUTE13
12267             , x_line_tbl(i).TP_ATTRIBUTE14
12268             , x_line_tbl(i).TP_ATTRIBUTE15
12269             , x_line_tbl(i).FLOW_STATUS_CODE
12270             , x_line_tbl(i).MARKETING_SOURCE_CODE_ID
12271             , x_line_tbl(i).CALCULATE_PRICE_FLAG
12272             , x_line_tbl(i).COMMITMENT_ID
12273             , x_line_tbl(i).ORDER_SOURCE_ID        -- aksingh
12274             , x_line_tbl(i).UPGRADED_FLAG
12275             , x_line_tbl(i).ORIGINAL_INVENTORY_ITEM_ID
12276             , x_line_tbl(i).ORIGINAL_ITEM_IDENTIFIER_TYPE
12277             , x_line_tbl(i).ORIGINAL_ORDERED_ITEM_ID
12278             , x_line_tbl(i).ORIGINAL_ORDERED_ITEM
12279             , x_line_tbl(i).ITEM_RELATIONSHIP_TYPE
12280             , x_line_tbl(i).ITEM_SUBSTITUTION_TYPE_CODE
12281             , x_line_tbl(i).LATE_DEMAND_PENALTY_FACTOR
12282             , x_line_tbl(i).OVERRIDE_ATP_DATE_CODE
12283             , x_line_tbl(i).FIRM_DEMAND_FLAG
12284             , x_line_tbl(i).EARLIEST_SHIP_DATE
12285             , x_line_tbl(i).USER_ITEM_DESCRIPTION
12286             , x_line_tbl(i).BLANKET_NUMBER
12287             , x_line_tbl(i).BLANKET_LINE_NUMBER
12288             , x_line_tbl(i).BLANKET_VERSION_NUMBER
12289             , x_line_tbl(i).UNIT_COST
12290             , x_line_tbl(i).LOCK_CONTROL
12291             , l_opn    --OPN
12292             , l_cpn    --CPN
12293             , l_svn    --SVN
12294             , x_line_tbl(i).CHANGE_SEQUENCE
12295             , x_line_tbl(i).transaction_phase_code
12296             , x_line_tbl(i).source_document_version_number
12297             , x_line_tbl(i).MINISITE_ID
12298             , x_line_tbl(i).Ib_Owner
12299             , x_line_tbl(i).Ib_installed_at_location
12300             , x_line_tbl(i).Ib_current_location
12301             , x_line_tbl(i).End_customer_ID
12302             , x_line_tbl(i).End_customer_contact_ID
12303             , x_line_tbl(i).End_customer_site_use_ID
12304             , x_line_tbl(i).RETROBILL_REQUEST_ID
12305             , x_line_tbl(i).ORIGINAL_LIST_PRICE  -- Override List Price
12306             , x_line_tbl(i).order_firmed_date
12307             , x_line_tbl(i).actual_fulfillment_date
12308             , x_line_tbl(i).charge_periodicity_code
12309             , x_line_tbl(i).cancelled_quantity2
12310             , x_line_tbl(i).fulfilled_quantity2
12311             , x_line_tbl(i).CONTINGENCY_ID
12312             , x_line_tbl(i).REVREC_EVENT_CODE
12313             , x_line_tbl(i).REVREC_EXPIRATION_DAYS
12314             , x_line_tbl(i).ACCEPTED_QUANTITY
12315             , x_line_tbl(i).REVREC_COMMENTS
12316             , x_line_tbl(i).REVREC_SIGNATURE
12317             , x_line_tbl(i).REVREC_SIGNATURE_DATE
12318             , x_line_tbl(i).ACCEPTED_BY
12319             , x_line_tbl(i).REVREC_REFERENCE_DOCUMENT
12320             , x_line_tbl(i).REVREC_IMPLICIT_FLAG;
12321 
12322             EXIT WHEN l_line_csr_s%NOTFOUND;
12323 
12324         ELSE
12325           EXIT;
12326         END IF;
12327 
12328         IF NOT OE_FEATURES_PVT.Is_Margin_Avail Then
12329             x_line_tbl(i).unit_cost:= NULL;
12330         END IF;
12331 
12332 
12333 	   -- set values for non-DB fields
12334         x_line_tbl(i).db_flag 		:= FND_API.G_TRUE;
12335         x_line_tbl(i).operation 		:= FND_API.G_MISS_CHAR;
12336         x_line_tbl(i).return_status 	:= FND_API.G_MISS_CHAR;
12337         x_line_tbl(i).schedule_action_code 	:= FND_API.G_MISS_CHAR;
12338         x_line_tbl(i).reserved_quantity 	:= FND_API.G_MISS_NUM;
12339         x_line_tbl(i).reserved_quantity2 	:= FND_API.G_MISS_NUM; -- INVCONV
12340         x_line_tbl(i).change_reason 		:= FND_API.G_MISS_CHAR;
12341         x_line_tbl(i).change_comments 		:= FND_API.G_MISS_CHAR;
12342         x_line_tbl(i).arrival_set 		:= FND_API.G_MISS_CHAR;
12343         x_line_tbl(i).ship_set 			:= FND_API.G_MISS_CHAR;
12344         x_line_tbl(i).fulfillment_set 		:= FND_API.G_MISS_CHAR;
12345         x_line_tbl(i).split_action_code 	:= FND_API.G_MISS_CHAR;
12346 
12347         i := i + 1;
12348 
12349     END LOOP;
12350 
12351     IF l_entity = 2 THEN
12352         CLOSE l_line_csr_h;
12353     ELSIF l_entity = 3 THEN
12354         CLOSE l_line_csr_s;
12355     END IF;
12356 
12357     --  PK sent and no rows found
12358 
12359     IF
12360     (p_line_id IS NOT NULL
12361      AND
12362      p_line_id <> FND_API.G_MISS_NUM)
12363     AND
12364     (x_line_tbl.COUNT = 0)
12365     THEN
12366         RAISE NO_DATA_FOUND;
12367     END IF;
12368 
12369 
12370     --  Return fetched table
12371     IF l_debug_level  > 0 THEN
12372       oe_debug_pub.add('Exiting OE_LINE_UTIL.QUERY_ROWS', 1);
12373     END IF;
12374 
12375 EXCEPTION
12376 
12377     WHEN NO_DATA_FOUND THEN
12378         IF l_debug_level  > 0 THEN
12379            oe_debug_pub.add('Inside no data found ', 1);
12380         END IF;
12381 
12382 	   RAISE NO_DATA_FOUND;
12383 
12384     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
12385 
12386         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
12387         IF l_debug_level  > 0 THEN
12388            oe_debug_pub.add('Inside Unexpected error ', 1);
12389         END IF;
12390 
12391     WHEN OTHERS THEN
12392 
12393         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
12394         THEN
12395             OE_MSG_PUB.Add_Exc_Msg
12396             (   G_PKG_NAME
12397           ,   'Query_Rows'
12398             );
12399         END IF;
12400         IF l_debug_level  > 0 THEN
12401            oe_debug_pub.add('Inside Others Exception ', 1);
12402         END IF;
12403 
12404         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
12405 
12406 END Query_Rows;
12407 
12408 
12409 /*----------------------------------------------------------
12410  Procedure  lock_Row
12411 
12412  lock by ID or value will be decided by, if lock_control is
12413  passed or not. we are doing this so that other products, can
12414  still call lock_order API which does not take only primary
12415  key and takes only entire records. However if they do not
12416  set lokc_control on rec, we will still lock by ID that way
12417  they do not need to query up the records before sending them
12418  in. OM calls can directly fo to util.lock row, thus can send
12419  only line_id.
12420 -----------------------------------------------------------*/
12421 
12422 PROCEDURE Lock_Row
12423 (   x_return_status                 OUT NOCOPY /* file.sql.39 change */ VARCHAR2
12424 ,   p_x_line_rec                    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
12425 ,   p_line_id			           IN  NUMBER
12426 					               := FND_API.G_MISS_NUM
12427 )
12428 IS
12429 l_line_id		      NUMBER;
12430 l_top_model_line_id           NUMBER;
12431 l_dummy                       NUMBER;
12432 l_lock_control                NUMBER;
12433 l_db_lock_control             NUMBER;
12434 CAN_NOT_LOCK_MODEL            EXCEPTION;
12435 /* bug 4344310 */
12436 CURSOR C_Lock (c_top_model_line_id  NUMBER ,
12437 	        c_line_id  NUMBER ) IS
12438 SELECT line_id ,lock_control
12439 FROM oe_order_lines_all
12440 WHERE line_id IN (c_top_model_line_id, c_line_id)
12441 FOR UPDATE NOWAIT ;
12442 --
12443 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
12444 --
12445 BEGIN
12446 
12447     IF l_debug_level  > 0 THEN
12448       oe_debug_pub.add('Entering OE_LINE_UTIL.LOCK_ROW', 1);
12449     END IF;
12450 
12451     SAVEPOINT Lock_Row;
12452 
12453     l_lock_control := NULL;
12454 
12455     -- if l_lock_control is NULL, lock by ID.
12456     -- Retrieve the primary key.
12457 
12458     IF p_line_id <> FND_API.G_MISS_NUM THEN
12459 	l_line_id := p_line_id;
12460         IF (OE_GLOBALS.G_UI_FLAG) THEN  -- 3025978
12461             l_lock_control := p_x_line_rec.lock_control;
12462         END IF;
12463     ELSE
12464 	l_line_id := p_x_line_rec.line_id;
12465         l_lock_control := p_x_line_rec.lock_control;
12466         IF l_debug_level  > 0 THEN
12467            oe_debug_pub.add('in lock_control: '|| l_lock_control, 1);
12468         END IF;
12469     END IF;
12470 
12471     -- this code is for configurations. Whenever someone
12472     -- tries to modify an option line, we try to get a
12473     -- lock on the model line by ID.
12474     -- if we can get a lock on the model,
12475     -- this user can modify the configuration by
12476     -- changing any options. IF we can not get a
12477     -- lock on the model, that means some other person
12478     -- is already working on the configuration.
12479     -- in this case, we will give a message to the user
12480     -- to try his modifications later and that he should
12481     -- query lines to see latest changes.
12482 
12483     --changes for bug 4344310
12484    /* IF p_line_id <> FND_API.G_MISS_NUM THEN
12485 
12486       SELECT top_model_line_id
12487       INTO l_top_model_line_id
12488       FROM OE_ORDER_LINES_ALL  -- Fix for FP bug 3391622
12489       WHERE line_id = l_line_id;
12490     ELSE
12491       l_top_model_line_id := p_x_line_rec.top_model_line_id;
12492     END IF; */
12493       IF p_x_line_rec.top_model_line_id <> FND_API.G_MISS_NUM
12494 		AND
12495        p_x_line_rec.top_model_line_id is not null THEN
12496            l_top_model_line_id := p_x_line_rec.top_model_line_id;
12497 	   IF l_debug_level  > 0 THEN
12498 	     oe_debug_pub.add('get top_model_line_id from the record' );
12499 	   END IF ;
12500     ELSE
12501        SELECT top_model_line_id
12502        INTO l_top_model_line_id
12503        FROM OE_ORDER_LINES_ALL  -- Fix for FP bug 3391622
12504        WHERE line_id = l_line_id;
12505 
12506 	 IF l_debug_level  > 0 THEN
12507 	   oe_debug_pub.add('get top_model_line_id from the query' );
12508 	 END IF ;
12509    END IF;
12510   -- end bug 4344310
12511 
12512     IF l_debug_level  > 0 THEN
12513        oe_debug_pub.add('got top model line id', 1);
12514     END IF;
12515 
12516     BEGIN
12517 
12518       IF l_top_model_line_id IS NOT NULL AND
12519          l_top_model_line_id <> FND_API.G_MISS_NUM AND
12520          l_top_model_line_id <> l_line_id THEN
12521 
12522          IF l_debug_level  > 0 THEN
12523             oe_debug_pub.add('trying to lock model: '|| p_line_id, 1);
12524          END IF;
12525 
12526 	 -- changes for bug 4344310
12527         /* SELECT line_id
12528          INTO   l_dummy
12529          FROM   oe_order_lines_all
12530          WHERE  line_id = l_top_model_line_id
12531          FOR UPDATE NOWAIT; */
12532 
12533 	 FOR I IN c_lock(l_top_model_line_id ,l_line_id ) LOOP
12534            if I.line_id =l_line_id then
12535 		  l_line_id := I.line_id ;
12536                   l_db_lock_control := I.lock_control ;
12537            end if;
12538 	END LOOP ;
12539 
12540      ELSE
12541 	    SELECT line_id,lock_control
12542 	    INTO   l_line_id,l_db_lock_control
12543 	    FROM   oe_order_lines_all
12544 	    WHERE  line_id = l_line_id
12545 	    FOR UPDATE NOWAIT;
12546       END IF;
12547       --end bug 4344310
12548          IF l_debug_level  > 0 THEN
12549             oe_debug_pub.add('lock model successful ', 1);
12550          END IF;
12551 
12552     EXCEPTION
12553 
12554        WHEN APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION THEN
12555          -- some one else is currently working on this model
12556          IF l_debug_level  > 0 THEN
12557             oe_debug_pub.add('in lock model exception');
12558          END IF;
12559 
12560          FND_MESSAGE.Set_Name('ONT', 'OE_LINE_LOCKED');
12561          OE_MSG_PUB.Add;
12562 
12563          RAISE CAN_NOT_LOCK_MODEL;
12564 
12565        WHEN NO_DATA_FOUND THEN
12566            IF l_debug_level  > 0 THEN
12567               oe_debug_pub.add('no_data_found, model lock exception');
12568            END IF;
12569            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
12570 
12571        WHEN OTHERS THEN
12572            IF l_debug_level  > 0 THEN
12573               oe_debug_pub.add('model lock exception, others');
12574               oe_debug_pub.add('options: '|| l_line_id , 1);
12575               oe_debug_pub.add('lock model successful: '|| l_top_model_line_id, 1);
12576            END IF;
12577            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
12578     END;
12579 
12580 
12581     IF l_debug_level  > 0 THEN
12582        oe_debug_pub.add(' ', 1);
12583     END IF;
12584 
12585     --commented out for bug 4344310
12586     /*SELECT line_id,lock_control
12587     INTO   l_line_id,l_db_lock_control
12588     FROM   oe_order_lines_all
12589     WHERE  line_id = l_line_id
12590     FOR UPDATE NOWAIT; */
12591 
12592     IF l_debug_level  > 0 THEN
12593        oe_debug_pub.add('selected for update', 1);
12594        oe_debug_pub.add('queried lock_control: '|| l_db_lock_control, 1);
12595     END IF;
12596 
12597     IF l_lock_control IS NULL
12598     OR (l_lock_control <> l_db_lock_control)
12599     OR (OE_GLOBALS.G_UI_FLAG = TRUE ) THEN  -- 3025978
12600 
12601         oe_line_util.Query_Row
12602 	    (p_line_id  => l_line_id
12603 	    ,x_line_rec => p_x_line_rec
12604         );
12605 
12606    END IF;
12607 
12608     IF l_debug_level  > 0 THEN
12609        oe_debug_pub.add('queried lock_control: '|| p_x_line_rec.lock_control, 1);
12610     END IF;
12611 
12612     -- If lock_control is not passed(is null or missing), then return the locked record.
12613 
12614 
12615     IF l_lock_control is null OR
12616        l_lock_control = FND_API.G_MISS_NUM
12617     THEN
12618 
12619         --  Set return status
12620         x_return_status                := FND_API.G_RET_STS_SUCCESS;
12621         p_x_line_rec.return_status     := FND_API.G_RET_STS_SUCCESS;
12622 
12623         -- return for lock by ID.
12624 	RETURN;
12625 
12626     END IF;
12627 
12628     --  Row locked. If the whole record is passed, then
12629     --  Compare IN attributes to DB attributes.
12630 
12631     IF l_debug_level  > 0 THEN
12632        oe_debug_pub.add('compare ', 1);
12633     END IF;
12634 
12635 -- following constants are used to debug lock_order,
12636 -- please do not use them for any other purpose.
12637 -- set G_LOCK_TEST := 'Y', for debugging.
12638 
12639     OE_GLOBALS.G_LOCK_CONST := 0;
12640     --OE_GLOBALS.G_LOCK_TEST := 'Y';
12641     OE_GLOBALS.G_LOCK_TEST := 'N';
12642 
12643     IF      OE_GLOBALS.Equal(p_x_line_rec.lock_control,
12644                              l_lock_control)
12645    THEN
12646 
12647         --  Row has not changed. Set out parameter.
12648 
12649         IF l_debug_level  > 0 THEN
12650            oe_debug_pub.add('locked row', 1);
12651         END IF;
12652 
12653         --  Set return status
12654 
12655         x_return_status                := FND_API.G_RET_STS_SUCCESS;
12656         p_x_line_rec.return_status       := FND_API.G_RET_STS_SUCCESS;
12657 
12658     ELSE
12659 
12660         --  Row has changed by another user.
12661         IF l_debug_level  > 0 THEN
12662            oe_debug_pub.add('row changed by other user', 1);
12663         END IF;
12664 
12665         x_return_status                := FND_API.G_RET_STS_ERROR;
12666         p_x_line_rec.return_status       := FND_API.G_RET_STS_ERROR;
12667 
12668         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
12669         THEN
12670 
12671             -- Release the lock
12672             ROLLBACK TO Lock_Row;
12673 
12674             fnd_message.set_name('ONT','OE_LOCK_ROW_CHANGED');
12675             OE_MSG_PUB.Add;
12676 
12677         END IF;
12678 
12679     END IF;
12680 
12681     OE_GLOBALS.G_LOCK_TEST := 'N';
12682 
12683     IF l_debug_level  > 0 THEN
12684        oe_debug_pub.add('Exiting OE_LINE_UTIL.LOCK_ROW', 1);
12685        oe_debug_pub.add(' ', 1);
12686        oe_debug_pub.add('lock const: '|| oe_globals.g_lock_const, 1);
12687     END IF;
12688 
12689 EXCEPTION
12690 
12691     WHEN CAN_NOT_LOCK_MODEL THEN
12692         OE_GLOBALS.G_LOCK_TEST := 'N';
12693         IF l_debug_level  > 0 THEN
12694            oe_debug_pub.add('model locking exception', 1);
12695         END IF;
12696         x_return_status                := FND_API.G_RET_STS_ERROR;
12697         p_x_line_rec.return_status       := FND_API.G_RET_STS_ERROR;
12698 
12699 
12700     WHEN NO_DATA_FOUND THEN
12701         OE_GLOBALS.G_LOCK_TEST := 'N';
12702         x_return_status                := FND_API.G_RET_STS_ERROR;
12703         p_x_line_rec.return_status       := FND_API.G_RET_STS_ERROR;
12704 
12705         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
12706         THEN
12707 
12708             fnd_message.set_name('ONT','OE_LOCK_ROW_DELETED');
12709             OE_MSG_PUB.Add;
12710 
12711         END IF;
12712     WHEN APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION THEN
12713         OE_GLOBALS.G_LOCK_TEST := 'N';
12714         x_return_status                := FND_API.G_RET_STS_ERROR;
12715         p_x_line_rec.return_status       := FND_API.G_RET_STS_ERROR;
12716 
12717         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
12718         THEN
12719 
12720             fnd_message.set_name('ONT','OE_LOCK_ROW_ALREADY_LOCKED');
12721             OE_MSG_PUB.Add;
12722 
12723         END IF;
12724     WHEN OTHERS THEN
12725         OE_GLOBALS.G_LOCK_TEST := 'N';
12726         x_return_status                := FND_API.G_RET_STS_UNEXP_ERROR;
12727         p_x_line_rec.return_status       := FND_API.G_RET_STS_UNEXP_ERROR;
12728 
12729         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
12730         THEN
12731             OE_MSG_PUB.Add_Exc_Msg
12732             (   G_PKG_NAME
12733           ,   'Lock_Row'
12734             );
12735         END IF;
12736 
12737 END Lock_Row;
12738 
12739 
12740 /*----------------------------------------------------------
12741  Procedure  lock_Rows
12742 -----------------------------------------------------------*/
12743 
12744 PROCEDURE Lock_Rows
12745 (   p_line_id                       IN  NUMBER :=
12746                                         FND_API.G_MISS_NUM
12747 ,   p_header_id                     IN  NUMBER :=
12748                                         FND_API.G_MISS_NUM
12749 ,   x_line_tbl                      OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
12750 ,   x_return_status                 OUT NOCOPY /* file.sql.39 change */ VARCHAR2
12751  )
12752 IS
12753   CURSOR lock_lines(p_header_id  NUMBER) IS
12754   SELECT line_id
12755   FROM   oe_order_lines_all
12756   WHERE  header_id = p_header_id
12757     FOR  UPDATE NOWAIT;
12758 
12759 l_line_id    NUMBER;
12760 
12761 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
12762 BEGIN
12763 
12764     IF (p_line_id IS NOT NULL AND
12765         p_line_id <> FND_API.G_MISS_NUM) AND
12766        (p_header_id IS NOT NULL AND
12767         p_header_id <> FND_API.G_MISS_NUM)
12768     THEN
12769       IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
12770       THEN
12771         OE_MSG_PUB.Add_Exc_Msg
12772         (   G_PKG_NAME
12773         , 'Lock Rows'
12774         , 'Keys are mutually exclusive: line_id = '||
12775              p_line_id || ', header_id = '|| p_header_id );
12776       END IF;
12777 
12778       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
12779 
12780     END IF;
12781 
12782    IF p_line_id <> FND_API.G_MISS_NUM THEN
12783 
12784      SELECT line_id
12785      INTO   l_line_id
12786      FROM   OE_ORDER_LINES_ALL
12787      WHERE  line_id   = p_line_id
12788      FOR UPDATE NOWAIT;
12789 
12790    END IF;
12791 
12792    -- people should not pass in null header_id unnecessarily,
12793    -- if they already passed in line_id.
12794 
12795    BEGIN
12796 
12797      IF p_header_id <> FND_API.G_MISS_NUM THEN
12798 
12799        SAVEPOINT LOCK_ROWS;
12800 
12801        OPEN lock_lines(p_header_id);
12802        LOOP
12803          FETCH lock_lines INTO l_line_id;
12804          EXIT WHEN lock_lines%NOTFOUND;
12805        END LOOP;
12806        CLOSE lock_lines;
12807 
12808      END IF;
12809 
12810    EXCEPTION
12811      WHEN OTHERS THEN
12812        ROLLBACK TO LOCK_ROWS;
12813 
12814        IF lock_lines%ISOPEN THEN
12815          CLOSE lock_lines;
12816        END IF;
12817 
12818        RAISE;
12819    END;
12820 
12821    -- locked all lines
12822 
12823    oe_line_util.Query_Rows
12824      (p_line_id          => p_line_id
12825      ,p_header_id        => p_header_id
12826      ,x_line_tbl         => x_line_tbl
12827      );
12828 
12829   IF l_debug_level  > 0 THEN
12830    oe_debug_pub.add('Entering OE_LINE_UTIL.QUERY_ROWS', 1);
12831   END IF;
12832 
12833    x_return_status  := FND_API.G_RET_STS_SUCCESS;
12834 
12835 EXCEPTION
12836    WHEN NO_DATA_FOUND THEN
12837 
12838      x_return_status                := FND_API.G_RET_STS_ERROR;
12839 
12840      IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
12841      THEN
12842        fnd_message.set_name('ONT','OE_LOCK_ROW_DELETED');
12843        OE_MSG_PUB.Add;
12844      END IF;
12845 
12846     WHEN APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION THEN
12847 
12848       x_return_status                := FND_API.G_RET_STS_ERROR;
12849       IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
12850       THEN
12851         fnd_message.set_name('ONT','OE_LOCK_ROW_ALREADY_LOCKED');
12852         OE_MSG_PUB.Add;
12853       END IF;
12854 
12855     WHEN OTHERS THEN
12856 
12857         x_return_status                := FND_API.G_RET_STS_UNEXP_ERROR;
12858 
12859       IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
12860       THEN
12861         OE_MSG_PUB.Add_Exc_Msg
12862         (   G_PKG_NAME
12863        ,   'Lock_Row'
12864         );
12865       END IF;
12866 END Lock_Rows;
12867 
12868 
12869 /*----------------------------------------------------------
12870  Function Get_Values
12871 -----------------------------------------------------------*/
12872 
12873 FUNCTION Get_Values
12874 (   p_line_rec                      IN  OE_Order_PUB.Line_Rec_Type
12875 ,   p_old_line_rec                  IN  OE_Order_PUB.Line_Rec_Type :=
12876                                         OE_Order_PUB.G_MISS_LINE_REC
12877 ) RETURN OE_Order_PUB.Line_Val_Rec_Type
12878 IS
12879 l_customer_number         	VARCHAR2(30);
12880 l_line_val_rec                OE_Order_PUB.Line_Val_Rec_Type;
12881 l_organization_id NUMBER :=  OE_SYS_PARAMETERS.VALUE('MASTER_ORGANIZATION_ID');
12882 
12883 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
12884 BEGIN
12885 
12886   if l_debug_level > 0 then
12887     OE_DEBUG_PUB.add('Entering OE_LINE_UTIL.Get_Values');
12888   end if;
12889 
12890     IF (p_line_rec.calculate_price_flag IS NULL OR
12891         p_line_rec.calculate_price_flag <> FND_API.G_MISS_CHAR) AND
12892         NOT OE_GLOBALS.Equal(p_line_rec.calculate_price_flag,
12893         p_old_line_rec.calculate_price_flag)
12894     THEN
12895   l_line_val_rec.calculate_price_descr := OE_Id_To_Value.Calculate_price_Flag (   p_calculate_price_flag          => p_line_rec.calculate_price_flag
12896         );
12897 
12898           if l_debug_level > 0 then
12899 	   oe_debug_pub.add('Geresh ' || l_line_val_rec.calculate_price_descr );
12900           end if;
12901     END IF;
12902 
12903 
12904     IF (p_line_rec.accounting_rule_id IS NULL OR
12905         p_line_rec.accounting_rule_id <> FND_API.G_MISS_NUM) AND
12906         NOT OE_GLOBALS.Equal(p_line_rec.accounting_rule_id,
12907         p_old_line_rec.accounting_rule_id)
12908     THEN
12909         l_line_val_rec.accounting_rule := OE_Id_To_Value.Accounting_Rule
12910         (   p_accounting_rule_id          => p_line_rec.accounting_rule_id
12911         );
12912     END IF;
12913 
12914     IF (p_line_rec.agreement_id IS NULL OR
12915         p_line_rec.agreement_id <> FND_API.G_MISS_NUM) AND
12916         NOT OE_GLOBALS.Equal(p_line_rec.agreement_id,
12917         p_old_line_rec.agreement_id)
12918     THEN
12919         l_line_val_rec.agreement := OE_Id_To_Value.Agreement
12920         (   p_agreement_id                => p_line_rec.agreement_id
12921         );
12922     END IF;
12923 
12924     IF (p_line_rec.deliver_to_contact_id IS NULL OR
12925         p_line_rec.deliver_to_contact_id <> FND_API.G_MISS_NUM) AND
12926         NOT OE_GLOBALS.Equal(p_line_rec.deliver_to_contact_id,
12927         p_old_line_rec.deliver_to_contact_id)
12928     THEN
12929         l_line_val_rec.deliver_to_contact := OE_Id_To_Value.Deliver_To_Contact
12930         (   p_deliver_to_contact_id       => p_line_rec.deliver_to_contact_id
12931         );
12932     END IF;
12933 
12934     IF (p_line_rec.deliver_to_org_id IS NULL OR
12935         p_line_rec.deliver_to_org_id <> FND_API.G_MISS_NUM) AND
12936         NOT OE_GLOBALS.Equal(p_line_rec.deliver_to_org_id,
12937         p_old_line_rec.deliver_to_org_id)
12938     THEN
12939         get_customer_details
12940         (   p_org_id             => p_line_rec.deliver_to_org_id
12941       ,   p_site_use_code      =>'DELIVER_TO'
12942       ,   x_customer_name      => l_line_val_rec.deliver_to_customer_name
12943       ,   x_customer_number    => l_line_val_rec.deliver_to_customer_number
12944       ,   x_customer_id        => l_line_val_rec.deliver_to_customer_id
12945       ,   x_location        => l_line_val_rec.deliver_to_location
12946       ,   x_address1        => l_line_val_rec.deliver_to_address1
12947       ,   x_address2        => l_line_val_rec.deliver_to_address2
12948       ,   x_address3        => l_line_val_rec.deliver_to_address3
12949       ,   x_address4        => l_line_val_rec.deliver_to_address4
12950       ,   x_city        => l_line_val_rec.deliver_to_city
12951       ,   x_state        => l_line_val_rec.deliver_to_state
12952       ,   x_zip        => l_line_val_rec.deliver_to_zip
12953       ,   x_country        => l_line_val_rec.deliver_to_country
12954         );
12955         l_line_val_rec.deliver_to_org :=l_line_val_rec.deliver_to_location;
12956 
12957     END IF;
12958 
12959     IF (p_line_rec.demand_bucket_type_code IS NULL OR
12960         p_line_rec.demand_bucket_type_code <> FND_API.G_MISS_CHAR) AND
12961         NOT OE_GLOBALS.Equal(p_line_rec.demand_bucket_type_code,
12962         p_old_line_rec.demand_bucket_type_code)
12963     THEN
12964         l_line_val_rec.demand_bucket_type := OE_Id_To_Value.Demand_Bucket_Type
12965         (   p_demand_bucket_type_code     => p_line_rec.demand_bucket_type_code
12966         );
12967     END IF;
12968 
12969     IF (p_line_rec.fob_point_code IS NULL OR
12970         p_line_rec.fob_point_code <> FND_API.G_MISS_CHAR) AND
12971         NOT OE_GLOBALS.Equal(p_line_rec.fob_point_code,
12972         p_old_line_rec.fob_point_code)
12973     THEN
12974         l_line_val_rec.fob_point := OE_Id_To_Value.Fob_Point
12975         (   p_fob_point_code              => p_line_rec.fob_point_code
12976         );
12977     END IF;
12978 
12979     IF (p_line_rec.freight_terms_code IS NULL OR
12980         p_line_rec.freight_terms_code <> FND_API.G_MISS_CHAR) AND
12981         NOT OE_GLOBALS.Equal(p_line_rec.freight_terms_code,
12982         p_old_line_rec.freight_terms_code)
12983     THEN
12984         l_line_val_rec.freight_terms := OE_Id_To_Value.Freight_Terms
12985         (   p_freight_terms_code          => p_line_rec.freight_terms_code
12986         );
12987     END IF;
12988 
12989     IF (p_line_rec.freight_carrier_code IS NULL OR
12990         p_line_rec.freight_carrier_code <> FND_API.G_MISS_CHAR) AND
12991         NOT OE_GLOBALS.Equal(p_line_rec.freight_carrier_code,
12992         p_old_line_rec.freight_carrier_code)
12993     THEN
12994         l_line_val_rec.freight_carrier := OE_Id_To_Value.Freight_Carrier
12995         (   p_freight_carrier_code          => p_line_rec.freight_carrier_code
12996 	   ,   p_ship_from_org_id		    => p_line_rec.ship_from_org_id
12997         );
12998     END IF;
12999     IF (p_line_rec.shipping_method_code IS NULL OR
13000         p_line_rec.shipping_method_code <> FND_API.G_MISS_CHAR) AND
13001         NOT OE_GLOBALS.Equal(p_line_rec.shipping_method_code,
13002         p_old_line_rec.shipping_method_code)
13003     THEN
13004         l_line_val_rec.shipping_method := OE_Id_To_Value.ship_method
13005         (   p_ship_method_code      => p_line_rec.shipping_method_code
13006         );
13007     END IF;
13008 
13009     IF (p_line_rec.intermed_ship_to_contact_id IS NULL OR
13010         p_line_rec.intermed_ship_to_contact_id <> FND_API.G_MISS_NUM) AND
13011         NOT OE_GLOBALS.Equal(p_line_rec.intermed_ship_to_contact_id,
13012         p_old_line_rec.intermed_ship_to_contact_id)
13013     THEN
13014        l_line_val_rec.intermed_ship_to_contact := OE_Id_To_Value.Intermed_Ship_To_Contact
13015         (   p_intermed_ship_to_contact_id       => p_line_rec.intermed_ship_to_contact_id
13016         );
13017     END IF;
13018 
13019 /*1621182*/
13020     IF (p_line_rec.intermed_ship_to_org_id IS NULL OR
13021         p_line_rec.intermed_ship_to_org_id <> FND_API.G_MISS_NUM) AND
13022         NOT OE_GLOBALS.Equal(p_line_rec.intermed_ship_to_org_id,
13023         p_old_line_rec.intermed_ship_to_org_id)
13024     THEN
13025         OE_Id_To_Value.Intermed_Ship_To_Org
13026         (   p_intermed_ship_to_org_id      => p_line_rec.intermed_ship_to_org_id
13027       ,   x_intermed_ship_to_address1    => l_line_val_rec.intermed_ship_to_address1
13028       ,   x_intermed_ship_to_address2    => l_line_val_rec.intermed_ship_to_address2
13029       ,   x_intermed_ship_to_address3    => l_line_val_rec.intermed_ship_to_address3
13030       ,   x_intermed_ship_to_address4    => l_line_val_rec.intermed_ship_to_address4
13031       ,   x_intermed_ship_to_location    => l_line_val_rec.intermed_ship_to_location
13032       ,   x_intermed_ship_to_org         => l_line_val_rec.intermed_ship_to_org
13033       ,   x_intermed_ship_to_city        => l_line_val_rec.intermed_ship_to_city
13034       ,   x_intermed_ship_to_state       => l_line_val_rec.intermed_ship_to_state
13035       ,   x_intermed_ship_to_postal_code => l_line_val_rec.intermed_ship_to_zip
13036       ,   x_intermed_ship_to_country     => l_line_val_rec.intermed_ship_to_country
13037         );
13038     END IF;
13039 /*1621182*/
13040 
13041     IF (p_line_rec.inventory_item_id IS NULL OR
13042         p_line_rec.inventory_item_id <> FND_API.G_MISS_NUM) AND
13043         NOT OE_GLOBALS.Equal(p_line_rec.inventory_item_id,
13044         p_old_line_rec.inventory_item_id)
13045     THEN
13046         l_line_val_rec.inventory_item := OE_Id_To_Value.Inventory_Item
13047         (   p_inventory_item_id           => p_line_rec.inventory_item_id
13048         );
13049     END IF;
13050 
13051     IF (p_line_rec.invoice_to_contact_id IS NULL OR
13052         p_line_rec.invoice_to_contact_id <> FND_API.G_MISS_NUM) AND
13053         NOT OE_GLOBALS.Equal(p_line_rec.invoice_to_contact_id,
13054         p_old_line_rec.invoice_to_contact_id)
13055     THEN
13056         l_line_val_rec.invoice_to_contact := OE_Id_To_Value.Invoice_To_Contact
13057         (   p_invoice_to_contact_id       => p_line_rec.invoice_to_contact_id
13058         );
13059     END IF;
13060 
13061     IF (p_line_rec.invoice_to_org_id IS NULL OR
13062         p_line_rec.invoice_to_org_id <> FND_API.G_MISS_NUM) AND
13063         NOT OE_GLOBALS.Equal(p_line_rec.invoice_to_org_id,
13064         p_old_line_rec.invoice_to_org_id)
13065     THEN
13066 
13067         get_customer_details
13068         (   p_org_id             => p_line_rec.invoice_to_org_id
13069       ,   p_site_use_code      =>'BILL_TO'
13070       ,   x_customer_name      => l_line_val_rec.invoice_to_customer_name
13071       ,   x_customer_number    => l_line_val_rec.invoice_to_customer_number
13072       ,   x_customer_id        => l_line_val_rec.invoice_to_customer_id
13073       ,   x_location        => l_line_val_rec.invoice_to_location
13074       ,   x_address1        => l_line_val_rec.invoice_to_address1
13075       ,   x_address2        => l_line_val_rec.invoice_to_address2
13076       ,   x_address3        => l_line_val_rec.invoice_to_address3
13077       ,   x_address4        => l_line_val_rec.invoice_to_address4
13078       ,   x_city        => l_line_val_rec.invoice_to_city
13079       ,   x_state        => l_line_val_rec.invoice_to_state
13080       ,   x_zip        => l_line_val_rec.invoice_to_zip
13081       ,   x_country        => l_line_val_rec.invoice_to_country
13082         );
13083         l_line_val_rec.invoice_to_org :=l_line_val_rec.invoice_to_location;
13084 
13085     END IF;
13086 
13087     IF (p_line_rec.invoicing_rule_id IS NULL OR
13088         p_line_rec.invoicing_rule_id <> FND_API.G_MISS_NUM) AND
13089         NOT OE_GLOBALS.Equal(p_line_rec.invoicing_rule_id,
13090         p_old_line_rec.invoicing_rule_id)
13091     THEN
13092         l_line_val_rec.invoicing_rule := OE_Id_To_Value.Invoicing_Rule
13093         (   p_invoicing_rule_id           => p_line_rec.invoicing_rule_id
13094         );
13095     END IF;
13096 
13097     IF (p_line_rec.item_type_code IS NULL OR
13098         p_line_rec.item_type_code <> FND_API.G_MISS_CHAR) AND
13099         NOT OE_GLOBALS.Equal(p_line_rec.item_type_code,
13100         p_old_line_rec.item_type_code)
13101     THEN
13102         l_line_val_rec.item_type := OE_Id_To_Value.Item_Type
13103         (   p_item_type_code              => p_line_rec.item_type_code
13104         );
13105     END IF;
13106 
13107     IF (p_line_rec.line_type_id IS NULL OR
13108         p_line_rec.line_type_id <> FND_API.G_MISS_NUM) AND
13109         NOT OE_GLOBALS.Equal(p_line_rec.line_type_id,
13110         p_old_line_rec.line_type_id)
13111     THEN
13112         l_line_val_rec.line_type := OE_Id_To_Value.Line_Type
13113         (   p_line_type_id                => p_line_rec.line_type_id
13114         );
13115     END IF;
13116 
13117     IF (p_line_rec.over_ship_reason_code IS NULL OR
13118         p_line_rec.over_ship_reason_code <> FND_API.G_MISS_CHAR) AND
13119         NOT OE_GLOBALS.Equal(p_line_rec.over_ship_reason_code,
13120         p_old_line_rec.over_ship_reason_code)
13121     THEN
13122         l_line_val_rec.over_ship_reason := OE_Id_To_Value.over_ship_reason
13123         (   p_over_ship_reason_code  => p_line_rec.over_ship_reason_code
13124         );
13125     END IF;
13126 
13127     IF (p_line_rec.payment_term_id IS NULL OR
13128         p_line_rec.payment_term_id <> FND_API.G_MISS_NUM) AND
13129         NOT OE_GLOBALS.Equal(p_line_rec.payment_term_id,
13130         p_old_line_rec.payment_term_id)
13131     THEN
13132         l_line_val_rec.payment_term := OE_Id_To_Value.Payment_Term
13133         (   p_payment_term_id             => p_line_rec.payment_term_id
13134         );
13135     END IF;
13136 
13137     IF (p_line_rec.price_list_id IS NULL OR
13138         p_line_rec.price_list_id <> FND_API.G_MISS_NUM) AND
13139         NOT OE_GLOBALS.Equal(p_line_rec.price_list_id,
13140         p_old_line_rec.price_list_id)
13141     THEN
13142         l_line_val_rec.price_list := OE_Id_To_Value.Price_List
13143         (   p_price_list_id               => p_line_rec.price_list_id
13144         );
13145     END IF;
13146 
13147     IF (p_line_rec.project_id IS NULL OR
13148         p_line_rec.project_id <> FND_API.G_MISS_NUM) AND
13149         NOT OE_GLOBALS.Equal(p_line_rec.project_id,
13150         p_old_line_rec.project_id)
13151     THEN
13152         l_line_val_rec.project := OE_Id_To_Value.Project
13153         (   p_project_id                  => p_line_rec.project_id
13154         );
13155     END IF;
13156 
13157 
13158     IF (p_line_rec.source_type_code IS NULL OR
13159         p_line_rec.source_type_code <> FND_API.G_MISS_CHAR) AND
13160         NOT OE_GLOBALS.Equal(p_line_rec.source_type_code,
13161         p_old_line_rec.source_type_code)
13162     THEN
13163 
13164         l_line_val_rec.source_type := OE_Id_To_Value.source_type
13165         (   p_source_type_code  => p_line_rec.source_type_code
13166         );
13167     END IF;
13168 
13169 
13170     IF (p_line_rec.return_reason_code IS NULL OR
13171         p_line_rec.return_reason_code <> FND_API.G_MISS_CHAR) AND
13172         NOT OE_GLOBALS.Equal(p_line_rec.return_reason_code,
13173         p_old_line_rec.return_reason_code)
13174     THEN
13175 
13176         l_line_val_rec.return_reason := OE_Id_To_Value.return_reason
13177         (   p_return_reason_code  => p_line_rec.return_reason_code
13178         );
13179     END IF;
13180 
13181     IF (p_line_rec.reference_line_id IS NULL OR
13182         p_line_rec.reference_line_id <> FND_API.G_MISS_NUM) AND
13183         NOT OE_GLOBALS.Equal(p_line_rec.reference_line_id,
13184         p_old_line_rec.reference_line_id)
13185     THEN
13186         OE_Id_To_Value.reference_line
13187         (   p_reference_line_id   => p_line_rec.reference_line_id
13188        ,  x_ref_order_number    => l_line_val_rec.ref_order_number
13189        ,  x_ref_line_number     => l_line_val_rec.ref_line_number
13190        ,  x_ref_shipment_number => l_line_val_rec.ref_shipment_number
13191        ,  x_ref_option_number   => l_line_val_rec.ref_option_number
13192        ,  x_ref_component_number => l_line_val_rec.ref_component_number
13193         );
13194 
13195     END IF;
13196 
13197     IF (p_line_rec.reference_customer_trx_line_id IS NULL OR
13198         p_line_rec.reference_customer_trx_line_id <> FND_API.G_MISS_NUM) AND
13199         NOT OE_GLOBALS.Equal(p_line_rec.reference_customer_trx_line_id,
13200         p_old_line_rec.reference_customer_trx_line_id)
13201     THEN
13202         OE_Id_To_Value.Reference_Cust_Trx_Line
13203         (   p_reference_cust_trx_line_id => p_line_rec.reference_customer_trx_line_id
13204        ,  x_ref_invoice_number        => l_line_val_rec.ref_invoice_number
13205        ,  x_ref_invoice_line_number   => l_line_val_rec.ref_invoice_line_number
13206         );
13207     END IF;
13208 
13209     IF (p_line_rec.credit_invoice_line_id IS NULL OR
13210         p_line_rec.credit_invoice_line_id <> FND_API.G_MISS_NUM) AND
13211         NOT OE_GLOBALS.Equal(p_line_rec.credit_invoice_line_id,
13212         p_old_line_rec.credit_invoice_line_id)
13213     THEN
13214         l_line_val_rec.credit_invoice_number
13215             := OE_Id_To_Value.credit_invoice_line
13216         (   p_credit_invoice_line_id   => p_line_rec.credit_invoice_line_id
13217         );
13218     END IF;
13219 
13220     IF (p_line_rec.rla_schedule_type_code IS NULL OR
13221         p_line_rec.rla_schedule_type_code <> FND_API.G_MISS_CHAR) AND
13222         NOT OE_GLOBALS.Equal(p_line_rec.rla_schedule_type_code,
13223         p_old_line_rec.rla_schedule_type_code)
13224     THEN
13225         l_line_val_rec.rla_schedule_type := OE_Id_To_Value.Rla_Schedule_Type
13226         (   p_rla_schedule_type_code      => p_line_rec.rla_schedule_type_code
13227         );
13228     END IF;
13229 
13230     IF (p_line_rec.salesrep_id IS NULL OR
13231         p_line_rec.salesrep_id <> FND_API.G_MISS_NUM) AND
13232         NOT OE_GLOBALS.Equal(p_line_rec.salesrep_id,
13233         p_old_line_rec.salesrep_id)
13234     THEN
13235         l_line_val_rec.salesrep := OE_Id_To_Value.salesrep
13236         (   p_salesrep_id          => p_line_rec.salesrep_id
13237         );
13238     END IF;
13239 
13240     IF (p_line_rec.commitment_id IS NULL OR
13241         p_line_rec.commitment_id <> FND_API.G_MISS_NUM) AND
13242         NOT OE_GLOBALS.Equal(p_line_rec.commitment_id,
13243         p_old_line_rec.commitment_id)
13244     THEN
13245         l_line_val_rec.commitment := OE_Id_To_Value.Commitment
13246         (   p_commitment_id        => p_line_rec.commitment_id
13247         );
13248     END IF;
13249 
13250 
13251     IF (p_line_rec.shipment_priority_code IS NULL OR
13252         p_line_rec.shipment_priority_code <> FND_API.G_MISS_CHAR) AND
13253         NOT OE_GLOBALS.Equal(p_line_rec.shipment_priority_code,
13254         p_old_line_rec.shipment_priority_code)
13255     THEN
13256         l_line_val_rec.shipment_priority := OE_Id_To_Value.Shipment_Priority
13257         (   p_shipment_priority_code      => p_line_rec.shipment_priority_code
13258         );
13259     END IF;
13260 
13261     IF (p_line_rec.demand_class_code IS NULL OR
13262         p_line_rec.demand_class_code <> FND_API.G_MISS_CHAR) AND
13263         NOT OE_GLOBALS.Equal(p_line_rec.demand_class_code,
13264         p_old_line_rec.demand_class_code)
13265     THEN
13266         l_line_val_rec.demand_class := OE_Id_To_Value.Demand_Class
13267         (   p_demand_class_code      => p_line_rec.demand_class_code
13268         );
13269     END IF;
13270 
13271     IF (p_line_rec.ship_from_org_id IS NULL OR
13272         p_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM) AND
13273         NOT OE_GLOBALS.Equal(p_line_rec.ship_from_org_id,
13274         p_old_line_rec.ship_from_org_id)
13275     THEN
13276         OE_Id_To_Value.Ship_From_Org
13277         (   p_ship_from_org_id            => p_line_rec.ship_from_org_id
13278       ,   x_ship_from_address1          => l_line_val_rec.ship_from_address1
13279       ,   x_ship_from_address2          => l_line_val_rec.ship_from_address2
13280       ,   x_ship_from_address3          => l_line_val_rec.ship_from_address3
13281       ,   x_ship_from_address4          => l_line_val_rec.ship_from_address4
13282       ,   x_ship_from_location          => l_line_val_rec.ship_from_location
13283       ,   x_ship_from_org               => l_line_val_rec.ship_from_org
13284         );
13285     END IF;
13286 
13287     IF (p_line_rec.ship_to_contact_id IS NULL OR
13288         p_line_rec.ship_to_contact_id <> FND_API.G_MISS_NUM) AND
13289         NOT OE_GLOBALS.Equal(p_line_rec.ship_to_contact_id,
13290         p_old_line_rec.ship_to_contact_id)
13291     THEN
13292         l_line_val_rec.ship_to_contact := OE_Id_To_Value.Ship_To_Contact
13293         (   p_ship_to_contact_id          => p_line_rec.ship_to_contact_id
13294         );
13295     END IF;
13296 
13297     IF (p_line_rec.ship_to_org_id IS NULL OR
13298         p_line_rec.ship_to_org_id <> FND_API.G_MISS_NUM) AND
13299         NOT OE_GLOBALS.Equal(p_line_rec.ship_to_org_id,
13300         p_old_line_rec.ship_to_org_id)
13301     THEN
13302         get_customer_details
13303         (   p_org_id             => p_line_rec.ship_to_org_id
13304       ,   p_site_use_code      =>'SHIP_TO'
13305       ,   x_customer_name      => l_line_val_rec.ship_to_customer_name
13306       ,   x_customer_number    => l_line_val_rec.ship_to_customer_number
13307       ,   x_customer_id        => l_line_val_rec.ship_to_customer_id
13308       ,   x_location        => l_line_val_rec.ship_to_location
13309       ,   x_address1        => l_line_val_rec.ship_to_address1
13310       ,   x_address2        => l_line_val_rec.ship_to_address2
13311       ,   x_address3        => l_line_val_rec.ship_to_address3
13312       ,   x_address4        => l_line_val_rec.ship_to_address4
13313       ,   x_city        => l_line_val_rec.ship_to_city
13314       ,   x_state        => l_line_val_rec.ship_to_state
13315       ,   x_zip        => l_line_val_rec.ship_to_zip
13316       ,   x_country        => l_line_val_rec.ship_to_country
13317         );
13318         l_line_val_rec.ship_to_org :=l_line_val_rec.ship_to_location;
13319 
13320     END IF;
13321 
13322 
13323     IF (p_line_rec.sold_to_org_id IS NULL OR
13324         p_line_rec.sold_to_org_id <> FND_API.G_MISS_NUM) AND
13325         NOT OE_GLOBALS.Equal(p_line_rec.sold_to_org_id,
13326         p_old_line_rec.sold_to_org_id)
13327     THEN
13328         OE_Id_To_Value.Sold_To_Org
13329         (   p_sold_to_org_id              => p_line_rec.sold_to_org_id
13330       ,   x_org                         => l_line_val_rec.sold_to_org
13331       ,   x_customer_number             => l_customer_number
13332         );
13333     END IF;
13334 
13335     IF (p_line_rec.task_id IS NULL OR
13336         p_line_rec.task_id <> FND_API.G_MISS_NUM) AND
13337         NOT OE_GLOBALS.Equal(p_line_rec.task_id,
13338         p_old_line_rec.task_id)
13339     THEN
13340         l_line_val_rec.task := OE_Id_To_Value.Task
13341         (   p_task_id                     => p_line_rec.task_id
13342         );
13343     END IF;
13344 
13345     IF (p_line_rec.tax_exempt_flag IS NULL OR
13346         p_line_rec.tax_exempt_flag <> FND_API.G_MISS_CHAR) AND
13347         NOT OE_GLOBALS.Equal(p_line_rec.tax_exempt_flag,
13348         p_old_line_rec.tax_exempt_flag)
13349     THEN
13350         l_line_val_rec.tax_exempt := OE_Id_To_Value.Tax_Exempt
13351         (   p_tax_exempt_flag             => p_line_rec.tax_exempt_flag
13352         );
13353     END IF;
13354 
13355     IF (p_line_rec.tax_exempt_reason_code IS NULL OR
13356         p_line_rec.tax_exempt_reason_code <> FND_API.G_MISS_CHAR) AND
13357         NOT OE_GLOBALS.Equal(p_line_rec.tax_exempt_reason_code,
13358         p_old_line_rec.tax_exempt_reason_code)
13359     THEN
13360         l_line_val_rec.tax_exempt_reason := OE_Id_To_Value.Tax_Exempt_Reason
13361         (   p_tax_exempt_reason_code      => p_line_rec.tax_exempt_reason_code
13362         );
13363     END IF;
13364 
13365     IF (p_line_rec.tax_point_code IS NULL OR
13366         p_line_rec.tax_point_code <> FND_API.G_MISS_CHAR) AND
13367         NOT OE_GLOBALS.Equal(p_line_rec.tax_point_code,
13368         p_old_line_rec.tax_point_code)
13369     THEN
13370         l_line_val_rec.tax_point := OE_Id_To_Value.Tax_Point
13371         (   p_tax_point_code              => p_line_rec.tax_point_code
13372         );
13373     END IF;
13374 
13375     /*IF  (p_line_rec.tax_code IS NULL OR
13376         p_line_rec.tax_code <> FND_API.G_MISS_CHAR) AND
13377         NOT OE_GLOBALS.Equal(p_line_rec.tax_code,
13378         p_old_line_rec.tax_code)
13379     THEN
13380         l_line_val_rec.tax_group := OE_Id_To_Value.Tax_Group
13381         (   p_tax_code             => p_line_rec.tax_code
13382         );
13383     END IF;*/
13384 
13385     IF (p_line_rec.veh_cus_item_cum_key_id IS NULL OR
13386         p_line_rec.veh_cus_item_cum_key_id <> FND_API.G_MISS_NUM) AND
13387         NOT OE_GLOBALS.Equal(p_line_rec.veh_cus_item_cum_key_id,
13388         p_old_line_rec.veh_cus_item_cum_key_id)
13389     THEN
13390       l_line_val_rec.veh_cus_item_cum_key := OE_Id_To_Value.veh_cus_item_cum_key
13391         (   p_veh_cus_item_cum_key_id => p_line_rec.veh_cus_item_cum_key_id
13392         );
13393     END IF;
13394 
13395 
13396    IF (p_line_rec.Original_inventory_item_id IS NOT NULL  OR
13397         p_line_rec.original_inventory_item_id <> FND_API.G_MISS_NUM)
13398    THEN
13399     OE_ID_TO_VALUE.Ordered_Item
13400     (p_Item_Identifier_type    => p_line_rec.original_item_identifier_Type
13401     ,p_inventory_item_id       => p_line_rec.original_Inventory_Item_Id
13402     ,p_organization_id         => l_organization_id
13403     ,p_ordered_item_id         => p_line_rec.original_ordered_item_id
13404     ,p_sold_to_org_id          => p_line_rec.sold_to_org_id
13405     ,p_ordered_item            => p_line_rec.original_ordered_item
13406     ,x_ordered_item            => l_line_val_rec.original_ordered_item
13407     ,x_inventory_item          => l_line_val_rec.original_inventory_item);
13408    END IF;
13409 
13410    IF (p_line_rec.original_item_identifier_type IS NOT NULL  OR
13411         p_line_rec.original_item_identifier_type <> FND_API.G_MISS_CHAR)
13412    THEN
13413     OE_ID_TO_VALUE.item_identifier
13414          (p_Item_Identifier_type   => p_line_rec.Original_item_identifier_Type
13415          ,x_Item_Identifier        => l_line_val_rec.Original_item_identifier_type);
13416    END IF;
13417 
13418    IF (p_line_rec.item_relationship_type IS NOT NULL  OR
13419         p_line_rec.item_relationship_type <> FND_API.G_MISS_NUM)
13420    THEN
13421     OE_ID_TO_VALUE.item_relationship_type
13422          (p_Item_relationship_type     => p_line_rec.item_relationship_type
13423          ,x_Item_relationship_type_dsp => l_line_val_rec.item_relationship_type_dsp);
13424    END IF;
13425 
13426    IF (p_line_rec.end_customer_id IS NOT NULL  AND
13427         p_line_rec.end_customer_id <> FND_API.G_MISS_NUM)
13428    THEN
13429       OE_ID_TO_VALUE.End_Customer(
13430 				  p_end_customer_id     => p_line_rec.end_customer_id
13431 				  ,x_end_customer_name   => l_line_val_rec.end_customer_name
13432 				  ,x_end_customer_number => l_line_val_rec.end_customer_number);
13433    END IF;
13434 
13435    IF (p_line_rec.end_customer_contact_id IS NOT NULL   AND
13436         p_line_rec.end_customer_contact_id <> FND_API.G_MISS_NUM)
13437    THEN
13438     l_line_val_rec.end_customer_contact :=
13439 	 OE_ID_TO_VALUE.end_customer_Contact(p_end_customer_contact_id => p_line_rec.end_customer_contact_id);
13440    END IF;
13441 
13442    IF (p_line_rec.end_customer_site_use_id IS NOT NULL   AND
13443         p_line_rec.end_customer_site_use_id <> FND_API.G_MISS_NUM)
13444    THEN
13445     OE_ID_TO_VALUE.end_customer_site_use(
13446 					 p_end_customer_site_use_id => p_line_rec.end_customer_site_use_id
13447 					 ,x_end_customer_address1    => l_line_val_rec.end_customer_site_address1
13448 					 ,x_end_customer_address2    => l_line_val_rec.end_customer_site_address2
13449 					 ,x_end_customer_address3    => l_line_val_rec.end_customer_site_address3
13450 					 ,x_end_customer_address4    => l_line_val_rec.end_customer_site_address4
13451 					 ,x_end_customer_location    => l_line_val_rec.end_customer_site_location
13452 					 ,x_end_customer_city        => l_line_val_rec.end_customer_site_city
13453 					 ,x_end_customer_state       => l_line_val_rec.end_customer_site_state
13454 					 ,x_end_customer_postal_code => l_line_val_rec.end_customer_site_postal_code
13455 					 ,x_end_customer_country     => l_line_val_rec.end_customer_site_country    );
13456    END IF;
13457  -- Start BSA pricing
13458    IF (p_line_rec.blanket_number IS NOT NULL  OR
13459         p_line_rec.blanket_number <> FND_API.G_MISS_NUM)
13460    THEN
13461                 oe_blanket_util_misc.get_blanketAgrName
13462                               (p_blanket_number   => p_line_rec.blanket_number,
13463                                x_blanket_agr_name => l_line_val_rec.blanket_agreement_name);
13464    END if;
13465  -- END BSA pricing
13466 --Macd
13467    IF (p_line_rec.ib_owner IS NOT NULL   AND
13468         p_line_rec.ib_owner <> FND_API.G_MISS_CHAR)
13469    THEN
13470     l_line_val_rec.ib_owner_dsp :=
13471 	 OE_ID_TO_VALUE.ib_owner(p_ib_owner => p_line_rec.ib_owner);
13472    END IF;
13473 
13474    IF (p_line_rec.ib_current_location IS NOT NULL   AND
13475         p_line_rec.ib_current_location <> FND_API.G_MISS_CHAR)
13476    THEN
13477     l_line_val_rec.ib_current_location_dsp :=
13478 	 OE_ID_TO_VALUE.ib_current_location(p_ib_current_location => p_line_rec.ib_current_location);
13479    END IF;
13480 
13481    IF (p_line_rec.ib_installed_at_location IS NOT NULL   AND
13482         p_line_rec.ib_installed_at_location <> FND_API.G_MISS_CHAR)
13483    THEN
13484     l_line_val_rec.ib_installed_at_location_dsp :=
13485 	 OE_ID_TO_VALUE.ib_installed_at_location(p_ib_installed_at_location => p_line_rec.ib_installed_at_location);
13486    END IF;
13487 --Macd
13488  /*3605052*/
13489    IF (p_line_rec.service_period IS NOT NULL   AND
13490         p_line_rec.service_period <> FND_API.G_MISS_CHAR)
13491    THEN
13492     l_line_val_rec.service_period_dsp :=
13493 	 OE_ID_TO_VALUE.service_period(p_service_period => p_line_rec.service_period
13494 				       ,p_inventory_item_id => p_line_rec.inventory_item_id);
13495    END IF;
13496    /*3605052*/
13497 
13498 
13499 -- 5701246 begin
13500    IF (p_line_rec.service_reference_type_code IS NOT NULL   AND
13501         p_line_rec.service_reference_type_code <> FND_API.G_MISS_CHAR)
13502    THEN
13503     l_line_val_rec.service_reference_type :=
13504 	OE_ID_TO_VALUE.service_reference_type(p_service_reference_type_code => p_line_rec.service_reference_type_code);
13505    END IF;
13506 -- 5701246 end
13507 
13508 
13509   --Customer Acceptance
13510     IF (p_line_rec.contingency_id IS NOT NULL AND
13511         p_line_rec.contingency_id <> FND_API.G_MISS_NUM)
13512     THEN
13513        OE_ID_TO_VALUE.Get_Contingency_Attributes(
13514 				p_contingency_id  => p_line_rec.contingency_id
13515 			        , x_contingency_name =>  l_line_val_rec.contingency_name
13516                                 , x_contingency_description  =>  l_line_val_rec.contingency_description
13517                                 , x_expiration_event_attribute  =>  l_line_val_rec.expiration_event_attribute);
13518 
13519     END IF;
13520     IF (p_line_rec.revrec_event_code IS NOT NULL  AND
13521         p_line_rec.revrec_event_code <> FND_API.G_MISS_CHAR)
13522     THEN
13523      l_line_val_rec.Revrec_Event:=  OE_ID_TO_VALUE.Revrec_Event(
13524 				p_Revrec_Event_code  => p_line_rec.Revrec_Event_code);
13525 
13526     END IF;
13527 
13528     IF (p_line_rec.accepted_by IS NOT NULL  AND
13529         p_line_rec.accepted_by <> FND_API.G_MISS_NUM)
13530     THEN
13531      l_line_val_rec.accepted_by_dsp:=  OE_ID_TO_VALUE.accepted_by(
13532 				p_accepted_by  => p_line_rec.accepted_by);
13533 
13534     END IF;
13535  --
13536 
13537   if l_debug_level > 0 then
13538     oe_debug_pub.add('original item identifier type='||p_line_rec.original_item_identifier_type);
13539     oe_debug_pub.add('original ordered item ' ||p_line_rec.original_ordered_item);
13540     oe_debug_pub.add('original inventory item id ' ||p_line_rec.original_inventory_item_id);
13541     oe_debug_pub.add('original ordered_item id '||p_line_rec.original_ordered_item_id);
13542     oe_debug_pub.add('item relationship type '||p_line_rec.item_relationship_type);
13543     oe_debug_pub.add('original inventory item'||l_line_val_rec.original_inventory_item);
13544     oe_debug_pub.add('original ordered item'||l_line_val_rec.original_ordered_item);
13545     oe_debug_pub.add('original original item ident type'||l_line_val_rec.original_item_identifier_type);
13546     oe_debug_pub.add('item relationship type dsp='||l_line_val_rec.item_relationship_type_dsp);
13547     oe_debug_pub.add('the service_reference_type_code: '||p_line_rec.service_reference_type_code);
13548     oe_debug_pub.add('the service_reference_type: '||l_line_val_rec.service_reference_type);
13549   end if;
13550     RETURN l_line_val_rec;
13551 
13552 END Get_Values;
13553 
13554 
13555 /*----------------------------------------------------------
13556   Function Get_Ids
13557 -----------------------------------------------------------*/
13558 
13559 PROCEDURE Get_Ids
13560 (   p_x_line_rec                    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
13561 ,   p_line_val_rec                  IN  OE_Order_PUB.Line_Val_Rec_Type
13562 )
13563 IS
13564 l_sold_to_org_id           NUMBER;
13565 l_deliver_to_org_id        NUMBER;
13566 l_invoice_to_org_id        NUMBER;
13567 l_ship_to_org_id           NUMBER;
13568 BEGIN
13569 
13570     p_x_line_rec.return_status := FND_API.G_RET_STS_SUCCESS;
13571 
13572     IF  p_line_val_rec.accounting_rule <> FND_API.G_MISS_CHAR
13573     THEN
13574 
13575         IF p_x_line_rec.accounting_rule_id <> FND_API.G_MISS_NUM THEN
13576 
13577             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
13578             THEN
13579 
13580                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
13581                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','accounting_rule');
13582                 OE_MSG_PUB.Add;
13583 
13584             END IF;
13585 
13586         ELSE
13587 
13588             p_x_line_rec.accounting_rule_id := OE_Value_To_Id.accounting_rule
13589             (   p_accounting_rule             => p_line_val_rec.accounting_rule
13590             );
13591 
13592             IF p_x_line_rec.accounting_rule_id = FND_API.G_MISS_NUM THEN
13593                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
13594             END IF;
13595 
13596         END IF;
13597 
13598     END IF;
13599 
13600     IF  p_line_val_rec.agreement <> FND_API.G_MISS_CHAR
13601     THEN
13602 
13603         IF p_x_line_rec.agreement_id <> FND_API.G_MISS_NUM THEN
13604 
13605             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
13606             THEN
13607 
13608                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
13609                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','agreement');
13610                 OE_MSG_PUB.Add;
13611 
13612             END IF;
13613 
13614         ELSE
13615 
13616             p_x_line_rec.agreement_id := OE_Value_To_Id.agreement
13617             (   p_agreement                   => p_line_val_rec.agreement
13618             );
13619 
13620             IF p_x_line_rec.agreement_id = FND_API.G_MISS_NUM THEN
13621                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
13622             END IF;
13623 
13624         END IF;
13625 
13626     END IF;
13627 
13628     IF  p_line_val_rec.demand_bucket_type <> FND_API.G_MISS_CHAR
13629     THEN
13630 
13631         IF p_x_line_rec.demand_bucket_type_code <> FND_API.G_MISS_CHAR THEN
13632 
13633             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
13634             THEN
13635 
13636                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
13637                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','demand_bucket_type');
13638                 OE_MSG_PUB.Add;
13639 
13640             END IF;
13641 
13642         ELSE
13643 
13644             p_x_line_rec.demand_bucket_type_code := OE_Value_To_Id.demand_bucket_type
13645             (   p_demand_bucket_type          => p_line_val_rec.demand_bucket_type
13646             );
13647 
13648             IF p_x_line_rec.demand_bucket_type_code = FND_API.G_MISS_CHAR THEN
13649                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
13650             END IF;
13651 
13652         END IF;
13653 
13654     END IF;
13655 
13656     IF  p_line_val_rec.fob_point <> FND_API.G_MISS_CHAR
13657     THEN
13658 
13659         IF p_x_line_rec.fob_point_code <> FND_API.G_MISS_CHAR THEN
13660 
13661             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
13662             THEN
13663 
13664                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
13665                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','fob_point');
13666                 OE_MSG_PUB.Add;
13667 
13668             END IF;
13669 
13670         ELSE
13671 
13672             p_x_line_rec.fob_point_code := OE_Value_To_Id.fob_point
13673             (   p_fob_point                   => p_line_val_rec.fob_point
13674             );
13675 
13676             IF p_x_line_rec.fob_point_code = FND_API.G_MISS_CHAR THEN
13677                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
13678             END IF;
13679 
13680         END IF;
13681 
13682     END IF;
13683 
13684     IF  p_line_val_rec.freight_terms <> FND_API.G_MISS_CHAR
13685     THEN
13686 
13687         IF p_x_line_rec.freight_terms_code <> FND_API.G_MISS_CHAR THEN
13688 
13689             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
13690             THEN
13691 
13692                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
13693                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','freight_terms');
13694                 OE_MSG_PUB.Add;
13695 
13696             END IF;
13697 
13698         ELSE
13699 
13700             p_x_line_rec.freight_terms_code := OE_Value_To_Id.freight_terms
13701             (   p_freight_terms               => p_line_val_rec.freight_terms
13702             );
13703 
13704             IF p_x_line_rec.freight_terms_code = FND_API.G_MISS_CHAR THEN
13705                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
13706             END IF;
13707 
13708         END IF;
13709 
13710     END IF;
13711 
13712     IF  p_line_val_rec.shipping_method <> FND_API.G_MISS_CHAR
13713     THEN
13714 
13715         IF p_x_line_rec.shipping_method_code <> FND_API.G_MISS_CHAR THEN
13716 
13717             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
13718             THEN
13719 
13720                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
13721                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','shipping_method');
13722                 OE_MSG_PUB.Add;
13723 
13724             END IF;
13725 
13726         ELSE
13727 
13728             p_x_line_rec.shipping_method_code := OE_Value_To_Id.ship_method
13729             (   p_ship_method           => p_line_val_rec.shipping_method
13730             );
13731 
13732             IF p_x_line_rec.shipping_method_code = FND_API.G_MISS_CHAR THEN
13733 		  oe_debug_pub.add('Ship Method Conversion Error');
13734                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
13735             END IF;
13736 
13737         END IF;
13738 
13739     END IF;
13740 
13741 
13742     IF  p_line_val_rec.freight_carrier <> FND_API.G_MISS_CHAR
13743     THEN
13744 
13745         IF p_x_line_rec.freight_carrier_code <> FND_API.G_MISS_CHAR THEN
13746 
13747             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
13748             THEN
13749 
13750                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
13751                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','freight_carrier');
13752                 OE_MSG_PUB.Add;
13753 
13754             END IF;
13755 
13756         ELSE
13757 
13758             p_x_line_rec.freight_carrier_code := OE_Value_To_Id.freight_carrier
13759             (   p_freight_carrier               => p_line_val_rec.freight_carrier
13760 		  ,   p_ship_from_org_id			   => p_x_line_rec.ship_from_org_id
13761             );
13762 
13763             IF p_x_line_rec.freight_carrier_code = FND_API.G_MISS_CHAR THEN
13764                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
13765             END IF;
13766 
13767         END IF;
13768 
13769     END IF;
13770 
13771     IF  p_line_val_rec.intermed_ship_to_contact <> FND_API.G_MISS_CHAR
13772     THEN
13773 
13774         IF p_x_line_rec.intermed_ship_to_contact_id <> FND_API.G_MISS_NUM THEN
13775 
13776             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
13777             THEN
13778 
13779                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
13780                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','intermed_ship_to_contact');
13781                 OE_MSG_PUB.Add;
13782 
13783             END IF;
13784 
13785         ELSE
13786 
13787             p_x_line_rec.intermed_ship_to_contact_id := OE_Value_To_Id.intermed_ship_to_contact
13788             (   p_intermed_ship_to_contact    => p_line_val_rec.intermed_ship_to_contact
13789 		  ,   p_intermed_ship_to_org_id     => p_x_line_rec.intermed_ship_to_org_id
13790             );
13791 
13792             IF p_x_line_rec.intermed_ship_to_contact_id = FND_API.G_MISS_NUM THEN
13793                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
13794             END IF;
13795 
13796         END IF;
13797 
13798     END IF;
13799 
13800     IF  p_line_val_rec.intermed_ship_to_address1 <> FND_API.G_MISS_CHAR
13801     OR  p_line_val_rec.intermed_ship_to_address2 <> FND_API.G_MISS_CHAR
13802     OR  p_line_val_rec.intermed_ship_to_address3 <> FND_API.G_MISS_CHAR
13803     OR  p_line_val_rec.intermed_ship_to_address4 <> FND_API.G_MISS_CHAR
13804     OR  p_line_val_rec.intermed_ship_to_location <> FND_API.G_MISS_CHAR
13805     OR  p_line_val_rec.intermed_ship_to_org <> FND_API.G_MISS_CHAR
13806     THEN
13807 
13808         IF p_x_line_rec.intermed_ship_to_org_id <> FND_API.G_MISS_NUM THEN
13809 
13810             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
13811             THEN
13812 
13813                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
13814                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','intermed_ship_to_org');
13815                 OE_MSG_PUB.Add;
13816 
13817             END IF;
13818 
13819         ELSE
13820 
13821 /*1621182*/
13822             p_x_line_rec.intermed_ship_to_org_id := OE_Value_To_Id.intermed_ship_to_org
13823             (   p_intermed_ship_to_address1     => p_line_val_rec.intermed_ship_to_address1
13824           ,   p_intermed_ship_to_address2     => p_line_val_rec.intermed_ship_to_address2
13825           ,   p_intermed_ship_to_address3     => p_line_val_rec.intermed_ship_to_address3
13826           ,   p_intermed_ship_to_address4     => p_line_val_rec.intermed_ship_to_address4
13827           ,   p_intermed_ship_to_location     => p_line_val_rec.intermed_ship_to_location
13828           ,   p_intermed_ship_to_org          => p_line_val_rec.intermed_ship_to_org
13829           ,   p_intermed_ship_to_city         => p_line_val_rec.intermed_ship_to_city
13830           ,   p_intermed_ship_to_state        => p_line_val_rec.intermed_ship_to_state
13831           ,   p_intermed_ship_to_postal_code  => p_line_val_rec.intermed_ship_to_zip
13832           ,   p_intermed_ship_to_country      => p_line_val_rec.intermed_ship_to_country
13833 		  ,   p_sold_to_org_id          => p_x_line_rec.sold_to_org_id
13834             );
13835 /*1621182*/
13836             IF p_x_line_rec.intermed_ship_to_org_id = FND_API.G_MISS_NUM THEN
13837                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
13838             END IF;
13839 
13840         END IF;
13841 
13842     END IF;
13843 
13844 
13845     IF  p_line_val_rec.inventory_item <> FND_API.G_MISS_CHAR
13846     THEN
13847 
13848         IF p_x_line_rec.inventory_item_id <> FND_API.G_MISS_NUM THEN
13849 
13850             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
13851             THEN
13852 
13853                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
13854                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','inventory_item');
13855                 OE_MSG_PUB.Add;
13856 
13857             END IF;
13858 
13859         ELSE
13860 
13861             p_x_line_rec.inventory_item_id := OE_Value_To_Id.inventory_item
13862             (   p_inventory_item              => p_line_val_rec.inventory_item
13863             );
13864 
13865             IF p_x_line_rec.inventory_item_id = FND_API.G_MISS_NUM THEN
13866                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
13867             END IF;
13868 
13869         END IF;
13870 
13871     END IF;
13872 
13873     IF  p_line_val_rec.invoicing_rule <> FND_API.G_MISS_CHAR
13874     THEN
13875 
13876         IF p_x_line_rec.invoicing_rule_id <> FND_API.G_MISS_NUM THEN
13877 
13878             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
13879             THEN
13880 
13881                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
13882                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','invoicing_rule');
13883                 OE_MSG_PUB.Add;
13884 
13885             END IF;
13886 
13887         ELSE
13888 
13889             p_x_line_rec.invoicing_rule_id := OE_Value_To_Id.invoicing_rule
13890             (   p_invoicing_rule              => p_line_val_rec.invoicing_rule
13891             );
13892 
13893             IF p_x_line_rec.invoicing_rule_id = FND_API.G_MISS_NUM THEN
13894                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
13895             END IF;
13896 
13897         END IF;
13898 
13899     END IF;
13900 
13901     IF  p_line_val_rec.item_type <> FND_API.G_MISS_CHAR
13902     THEN
13903 
13904         IF p_x_line_rec.item_type_code <> FND_API.G_MISS_CHAR THEN
13905 
13906             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
13907             THEN
13908 
13909                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
13910                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','item_type');
13911                 OE_MSG_PUB.Add;
13912 
13913             END IF;
13914 
13915         ELSE
13916 
13917             p_x_line_rec.item_type_code := OE_Value_To_Id.item_type
13918             (   p_item_type                   => p_line_val_rec.item_type
13919             );
13920 
13921             IF p_x_line_rec.item_type_code = FND_API.G_MISS_CHAR THEN
13922                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
13923             END IF;
13924 
13925         END IF;
13926 
13927     END IF;
13928 
13929     IF  p_line_val_rec.line_type <> FND_API.G_MISS_CHAR
13930     THEN
13931 
13932         IF p_x_line_rec.line_type_id <> FND_API.G_MISS_NUM THEN
13933 
13934             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
13935             THEN
13936 
13937                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
13938                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','line_type');
13939                 OE_MSG_PUB.Add;
13940 
13941             END IF;
13942 
13943         ELSE
13944 
13945             p_x_line_rec.line_type_id := OE_Value_To_Id.line_type
13946             (   p_line_type                   => p_line_val_rec.line_type
13947             );
13948 
13949             IF p_x_line_rec.line_type_id = FND_API.G_MISS_NUM THEN
13950                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
13951             END IF;
13952 
13953         END IF;
13954 
13955     END IF;
13956 
13957     IF  p_line_val_rec.over_ship_reason <> FND_API.G_MISS_CHAR
13958     THEN
13959 
13960         IF p_x_line_rec.over_ship_reason_code <> FND_API.G_MISS_CHAR THEN
13961 
13962             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
13963             THEN
13964 
13965                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
13966                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Over_shipo_reason');
13967                 OE_MSG_PUB.Add;
13968 
13969             END IF;
13970 
13971         ELSE
13972 
13973             p_x_line_rec.over_ship_reason_code := OE_Value_To_Id.over_ship_reason
13974             (   p_over_ship_reason  => p_line_val_rec.over_ship_reason
13975             );
13976 
13977             IF p_x_line_rec.over_ship_reason_code = FND_API.G_MISS_CHAR THEN
13978                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
13979             END IF;
13980 
13981         END IF;
13982 
13983     END IF;
13984 
13985     IF  p_line_val_rec.payment_term <> FND_API.G_MISS_CHAR
13986     THEN
13987 
13988         IF p_x_line_rec.payment_term_id <> FND_API.G_MISS_NUM THEN
13989 
13990             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
13991             THEN
13992 
13993                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
13994                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','payment_term');
13995                 OE_MSG_PUB.Add;
13996 
13997             END IF;
13998 
13999         ELSE
14000 
14001             p_x_line_rec.payment_term_id := OE_Value_To_Id.payment_term
14002             (   p_payment_term                => p_line_val_rec.payment_term
14003             );
14004 
14005             IF p_x_line_rec.payment_term_id = FND_API.G_MISS_NUM THEN
14006                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14007             END IF;
14008 
14009         END IF;
14010 
14011     END IF;
14012 
14013     IF  p_line_val_rec.price_list <> FND_API.G_MISS_CHAR
14014     THEN
14015 
14016         IF p_x_line_rec.price_list_id <> FND_API.G_MISS_NUM THEN
14017 
14018             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14019             THEN
14020 
14021                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14022                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','price_list');
14023                 OE_MSG_PUB.Add;
14024 
14025             END IF;
14026 
14027         ELSE
14028 
14029             p_x_line_rec.price_list_id := OE_Value_To_Id.price_list
14030             (   p_price_list                  => p_line_val_rec.price_list
14031             );
14032 
14033             IF p_x_line_rec.price_list_id = FND_API.G_MISS_NUM THEN
14034                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14035             END IF;
14036 
14037         END IF;
14038 
14039     END IF;
14040 
14041     IF  p_line_val_rec.project <> FND_API.G_MISS_CHAR
14042     THEN
14043 
14044         IF p_x_line_rec.project_id <> FND_API.G_MISS_NUM THEN
14045 
14046             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14047             THEN
14048 
14049                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14050                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','project');
14051                 OE_MSG_PUB.Add;
14052 
14053             END IF;
14054 
14055         ELSE
14056 
14057             p_x_line_rec.project_id := OE_Value_To_Id.project
14058             (   p_project                     => p_line_val_rec.project
14059             );
14060 
14061             IF p_x_line_rec.project_id = FND_API.G_MISS_NUM THEN
14062                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14063             END IF;
14064 
14065         END IF;
14066 
14067     END IF;
14068 
14069     IF  p_line_val_rec.return_reason <> FND_API.G_MISS_CHAR
14070     THEN
14071 
14072         IF p_x_line_rec.return_reason_code <> FND_API.G_MISS_CHAR THEN
14073 
14074             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14075             THEN
14076 
14077                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14078                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','return_reason');
14079                 OE_MSG_PUB.Add;
14080 
14081             END IF;
14082 
14083         ELSE
14084 
14085             p_x_line_rec.return_reason_code := OE_Value_To_Id.return_reason
14086             (   p_return_reason  => p_line_val_rec.return_reason
14087             );
14088 
14089             IF p_x_line_rec.return_reason_code = FND_API.G_MISS_CHAR THEN
14090                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14091             END IF;
14092 
14093         END IF;
14094 
14095     END IF;
14096 
14097 
14098 
14099     IF  p_line_val_rec.rla_schedule_type <> FND_API.G_MISS_CHAR
14100     THEN
14101 
14102         IF p_x_line_rec.rla_schedule_type_code <> FND_API.G_MISS_CHAR THEN
14103 
14104             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14105             THEN
14106 
14107                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14108                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','rla_schedule_type');
14109                 OE_MSG_PUB.Add;
14110 
14111             END IF;
14112 
14113         ELSE
14114 
14115             p_x_line_rec.rla_schedule_type_code := OE_Value_To_Id.rla_schedule_type
14116             (   p_rla_schedule_type           => p_line_val_rec.rla_schedule_type
14117             );
14118 
14119             IF p_x_line_rec.rla_schedule_type_code = FND_API.G_MISS_CHAR THEN
14120                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14121             END IF;
14122 
14123         END IF;
14124 
14125     END IF;
14126 
14127     IF  p_line_val_rec.salesrep <> FND_API.G_MISS_CHAR
14128     THEN
14129 
14130         IF p_x_line_rec.salesrep_id <> FND_API.G_MISS_NUM THEN
14131 
14132             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14133             THEN
14134 
14135                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14136                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','salesrep');
14137                 OE_MSG_PUB.Add;
14138 
14139             END IF;
14140 
14141         ELSE
14142 
14143             p_x_line_rec.salesrep_id := OE_Value_To_Id.salesrep
14144             (   p_salesrep  => p_line_val_rec.salesrep
14145             );
14146 
14147             IF p_x_line_rec.salesrep_id = FND_API.G_MISS_NUM THEN
14148                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14149             END IF;
14150 
14151         END IF;
14152 
14153     END IF;
14154 
14155     IF  p_line_val_rec.shipment_priority <> FND_API.G_MISS_CHAR
14156     THEN
14157 
14158         IF p_x_line_rec.shipment_priority_code <> FND_API.G_MISS_CHAR THEN
14159 
14160             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14161             THEN
14162 
14163                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14164                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','shipment_priority');
14165                 OE_MSG_PUB.Add;
14166 
14167             END IF;
14168 
14169         ELSE
14170 
14171             p_x_line_rec.shipment_priority_code := OE_Value_To_Id.shipment_priority
14172             (   p_shipment_priority           => p_line_val_rec.shipment_priority
14173             );
14174 
14175             IF p_x_line_rec.shipment_priority_code = FND_API.G_MISS_CHAR THEN
14176                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14177             END IF;
14178 
14179         END IF;
14180 
14181     END IF;
14182 
14183     IF  p_line_val_rec.ship_from_address1 <> FND_API.G_MISS_CHAR
14184     OR p_line_val_rec.ship_from_address2 <> FND_API.G_MISS_CHAR
14185     OR p_line_val_rec.ship_from_address3 <> FND_API.G_MISS_CHAR
14186     OR p_line_val_rec.ship_from_address4 <> FND_API.G_MISS_CHAR
14187     OR p_line_val_rec.ship_from_location <> FND_API.G_MISS_CHAR
14188     OR p_line_val_rec.ship_from_org <> FND_API.G_MISS_CHAR
14189     THEN
14190 
14191         IF p_x_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM THEN
14192 
14193             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14194             THEN
14195 
14196                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14197                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','ship_from_org');
14198                 OE_MSG_PUB.Add;
14199 
14200             END IF;
14201 
14202         ELSE
14203 
14204             p_x_line_rec.ship_from_org_id := OE_Value_To_Id.ship_from_org
14205             (   p_ship_from_address1          => p_line_val_rec.ship_from_address1
14206           ,   p_ship_from_address2          => p_line_val_rec.ship_from_address2
14207           ,   p_ship_from_address3          => p_line_val_rec.ship_from_address3
14208           ,   p_ship_from_address4          => p_line_val_rec.ship_from_address4
14209           ,   p_ship_from_location          => p_line_val_rec.ship_from_location
14210           ,   p_ship_from_org               => p_line_val_rec.ship_from_org
14211             );
14212 
14213             IF p_x_line_rec.ship_from_org_id = FND_API.G_MISS_NUM THEN
14214                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14215             END IF;
14216 
14217         END IF;
14218 
14219     END IF;
14220 
14221     IF  p_line_val_rec.task <> FND_API.G_MISS_CHAR
14222     THEN
14223 
14224         IF p_x_line_rec.task_id <> FND_API.G_MISS_NUM THEN
14225 
14226             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14227             THEN
14228 
14229                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14230                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','task');
14231                 OE_MSG_PUB.Add;
14232 
14233             END IF;
14234 
14235         ELSE
14236 
14237             p_x_line_rec.task_id := OE_Value_To_Id.task
14238             (   p_task                        => p_line_val_rec.task
14239             );
14240 
14241             IF p_x_line_rec.task_id = FND_API.G_MISS_NUM THEN
14242                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14243             END IF;
14244 
14245         END IF;
14246 
14247     END IF;
14248 
14249     IF  p_line_val_rec.tax_exempt <> FND_API.G_MISS_CHAR
14250     THEN
14251 
14252         IF p_x_line_rec.tax_exempt_flag <> FND_API.G_MISS_CHAR THEN
14253 
14254             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14255             THEN
14256 
14257                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14258                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','tax_exempt');
14259                 OE_MSG_PUB.Add;
14260 
14261             END IF;
14262 
14263         ELSE
14264 
14265             p_x_line_rec.tax_exempt_flag := OE_Value_To_Id.tax_exempt
14266             (   p_tax_exempt                  => p_line_val_rec.tax_exempt
14267             );
14268 
14269             IF p_x_line_rec.tax_exempt_flag = FND_API.G_MISS_CHAR THEN
14270                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14271             END IF;
14272 
14273         END IF;
14274 
14275     END IF;
14276 
14277     IF  p_line_val_rec.tax_exempt_reason <> FND_API.G_MISS_CHAR
14278     THEN
14279 
14280         IF p_x_line_rec.tax_exempt_reason_code <> FND_API.G_MISS_CHAR THEN
14281 
14282             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14283             THEN
14284 
14285                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14286                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','tax_exempt_reason');
14287                 OE_MSG_PUB.Add;
14288 
14289             END IF;
14290 
14291         ELSE
14292 
14293             p_x_line_rec.tax_exempt_reason_code := OE_Value_To_Id.tax_exempt_reason
14294             (   p_tax_exempt_reason           => p_line_val_rec.tax_exempt_reason
14295             );
14296 
14297             IF p_x_line_rec.tax_exempt_reason_code = FND_API.G_MISS_CHAR THEN
14298                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14299             END IF;
14300 
14301         END IF;
14302 
14303     END IF;
14304 
14305     IF  p_line_val_rec.tax_point <> FND_API.G_MISS_CHAR
14306     THEN
14307 
14308         IF p_x_line_rec.tax_point_code <> FND_API.G_MISS_CHAR THEN
14309 
14310             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14311             THEN
14312 
14313                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14314                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','tax_point');
14315                 OE_MSG_PUB.Add;
14316 
14317             END IF;
14318 
14319         ELSE
14320 
14321             p_x_line_rec.tax_point_code := OE_Value_To_Id.tax_point
14322             (   p_tax_point                   => p_line_val_rec.tax_point
14323             );
14324 
14325             IF p_x_line_rec.tax_point_code = FND_API.G_MISS_CHAR THEN
14326                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14327             END IF;
14328 
14329         END IF;
14330 
14331     END IF;
14332 
14333 
14334     IF  p_line_val_rec.veh_cus_item_cum_key <> FND_API.G_MISS_CHAR
14335     THEN
14336 
14337         IF p_x_line_rec.veh_cus_item_cum_key_id <> FND_API.G_MISS_NUM THEN
14338 
14339             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14340             THEN
14341 
14342                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14343                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','veh_cus_item_cum_key');
14344                 OE_MSG_PUB.Add;
14345 
14346             END IF;
14347 
14348         ELSE
14349 
14350        p_x_line_rec.veh_cus_item_cum_key_id := OE_Value_To_Id.veh_cus_item_cum_key
14351             (   p_veh_cus_item_cum_key  => p_line_val_rec.veh_cus_item_cum_key
14352             );
14353 
14354             IF p_x_line_rec.veh_cus_item_cum_key_id = FND_API.G_MISS_NUM THEN
14355                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14356             END IF;
14357 
14358         END IF;
14359 
14360     END IF;
14361 
14362     ----------------------------------------------------------------------
14363     -- Retreiving ids for invoice_to_customer
14364     ----------------------------------------------------------------------
14365 
14366     oe_debug_pub.add('line Invoice_to_cust_id='||p_x_line_rec.invoice_to_customer_id);
14367     IF  p_line_val_rec.invoice_to_customer_name_oi <> FND_API.G_MISS_CHAR
14368     OR  p_line_val_rec.invoice_to_customer_number_oi <> FND_API.G_MISS_CHAR
14369     THEN
14370 
14371         IF p_x_line_rec.invoice_to_customer_id <> FND_API.G_MISS_NUM THEN
14372 
14373 
14374             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14375             THEN
14376 
14377                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14378                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','invoice_to_customer line');
14379                 OE_MSG_PUB.Add;
14380 
14381             END IF;
14382 
14383         ELSE
14384            IF p_x_line_rec.invoice_to_org_id = FND_API.G_MISS_NUM THEN -- bug 4231603
14385             p_x_line_rec.invoice_to_customer_id:=OE_Value_To_Id.site_customer
14386             ( p_site_customer       => p_line_val_rec.invoice_to_customer_name_oi
14387              ,p_site_customer_number=> p_line_val_rec.invoice_to_customer_number_oi
14388              ,p_type =>'INVOICE_TO'
14389             );
14390 
14391             IF p_x_line_rec.invoice_to_customer_id = FND_API.G_MISS_NUM THEN
14392                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14393             END IF;
14394           END IF;
14395         END IF;
14396 
14397     END IF;
14398 
14399     ----------------------------------------------------------------------
14400     -- Retreiving ids for ship_to_customer
14401     ----------------------------------------------------------------------
14402 
14403     IF  p_line_val_rec.ship_to_customer_name_oi <> FND_API.G_MISS_CHAR
14404     OR  p_line_val_rec.ship_to_customer_number_oi <> FND_API.G_MISS_CHAR
14405     THEN
14406 
14407         IF p_x_line_rec.ship_to_customer_id <> FND_API.G_MISS_NUM THEN
14408 
14409 
14410             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14411             THEN
14412 
14413                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14414                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','ship_to_customer line');
14415                 OE_MSG_PUB.Add;
14416 
14417             END IF;
14418 
14419         ELSE
14420            IF p_x_line_rec.ship_to_org_id = FND_API.G_MISS_NUM THEN --4231603
14421             p_x_line_rec.ship_to_customer_id:=OE_Value_To_Id.site_customer
14422             ( p_site_customer       => p_line_val_rec.ship_to_customer_name_oi
14423              ,p_site_customer_number=> p_line_val_rec.ship_to_customer_number_oi
14424              ,p_type =>'SHIP_TO'
14425             );
14426 
14427             IF p_x_line_rec.ship_to_customer_id = FND_API.G_MISS_NUM THEN
14428                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14429             END IF;
14430           END IF;
14431         END IF;
14432 
14433     END IF;
14434 
14435 
14436     ----------------------------------------------------------------------
14437     -- Retreiving ids for deliver_to_customer
14438     ----------------------------------------------------------------------
14439 
14440     IF  p_line_val_rec.deliver_to_customer_name_oi <> FND_API.G_MISS_CHAR
14441     OR  p_line_val_rec.deliver_to_customer_number_oi <> FND_API.G_MISS_CHAR
14442     THEN
14443 
14444         IF p_x_line_rec.deliver_to_customer_id <> FND_API.G_MISS_NUM THEN
14445 
14446 
14447             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14448             THEN
14449 
14450                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14451                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','deliver_to_customer line');
14452                 OE_MSG_PUB.Add;
14453 
14454             END IF;
14455 
14456         ELSE
14457            IF p_x_line_rec.deliver_to_org_id = FND_API.G_MISS_NUM THEN  -- 4231603
14458             p_x_line_rec.deliver_to_customer_id:=OE_Value_To_Id.site_customer
14459             ( p_site_customer       => p_line_val_rec.ship_to_customer_name_oi
14460              ,p_site_customer_number=> p_line_val_rec.ship_to_customer_number_oi
14461              ,p_type =>'DELIVER_TO'
14462             );
14463 
14464             IF p_x_line_rec.deliver_to_customer_id = FND_API.G_MISS_NUM THEN
14465                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14466             END IF;
14467           END IF;
14468         END IF;
14469 
14470     END IF;
14471 
14472 
14473     -------------------------------------------------------------------
14474     -- For customer related fields, IDs should be retrieved in the
14475     -- following order.
14476     -------------------------------------------------------------------
14477 
14478     -- Retrieve the sold_to_org_id if not passed on the line record. This
14479     -- will be needed by the value_to_id functions for related fields.
14480     -- For e.g. oe_value_to_id.ship_to_org_id requires sold_to_org_id
14481 
14482     IF  p_x_line_rec.sold_to_org_id = FND_API.G_MISS_NUM
14483     THEN
14484 
14485       IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
14486 
14487          -- bug 2411783
14488          -- for a newly created order, since the line is not posted,
14489          -- in Order import, there will be no Header record.
14490          --OE_Order_Cache.Load_Order_Header(p_x_line_rec.header_id);
14491          --l_sold_to_org_id := OE_Order_Cache.g_header_rec.sold_to_org_id;
14492          null;
14493 
14494       ELSIF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
14495 
14496 	   SELECT SOLD_TO_ORG_ID
14497 	   INTO l_sold_to_org_id
14498 	   FROM OE_ORDER_LINES
14499 	   WHERE LINE_ID = p_x_line_rec.line_id;
14500 
14501       END IF;
14502 
14503     ELSE
14504 
14505 	  l_sold_to_org_id := p_x_line_rec.sold_to_org_id;
14506 
14507     END IF;
14508 
14509     IF  p_line_val_rec.deliver_to_address1 <> FND_API.G_MISS_CHAR
14510     OR p_line_val_rec.deliver_to_address2 <> FND_API.G_MISS_CHAR
14511     OR p_line_val_rec.deliver_to_address3 <> FND_API.G_MISS_CHAR
14512     OR p_line_val_rec.deliver_to_address4 <> FND_API.G_MISS_CHAR
14513     OR p_line_val_rec.deliver_to_location <> FND_API.G_MISS_CHAR
14514     OR p_line_val_rec.deliver_to_org <> FND_API.G_MISS_CHAR
14515     THEN
14516 
14517         IF p_x_line_rec.deliver_to_org_id <> FND_API.G_MISS_NUM THEN
14518 
14519 
14520             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14521             THEN
14522 
14523                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14524                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','deliver_to_org');
14525                 OE_MSG_PUB.Add;
14526 
14527             END IF;
14528 
14529         ELSE
14530 
14531 /*1621182*/
14532             p_x_line_rec.deliver_to_org_id := OE_Value_To_Id.deliver_to_org
14533             (   p_deliver_to_address1         => p_line_val_rec.deliver_to_address1
14534           ,   p_deliver_to_address2         => p_line_val_rec.deliver_to_address2
14535           ,   p_deliver_to_address3         => p_line_val_rec.deliver_to_address3
14536           ,   p_deliver_to_address4         => p_line_val_rec.deliver_to_address4
14537           ,   p_deliver_to_location         => p_line_val_rec.deliver_to_location
14538           ,   p_deliver_to_org              => p_line_val_rec.deliver_to_org
14539           ,   p_deliver_to_city             => p_line_val_rec.deliver_to_city
14540           ,   p_deliver_to_state            => p_line_val_rec.deliver_to_state
14541           ,   p_deliver_to_postal_code      => p_line_val_rec.deliver_to_zip
14542           ,   p_deliver_to_country          => p_line_val_rec.deliver_to_country
14543 		  ,   p_sold_to_org_id        => l_sold_to_org_id
14544           , p_deliver_to_customer_id => p_x_line_rec.deliver_to_customer_id
14545             );
14546 /*1621182*/
14547             IF p_x_line_rec.deliver_to_org_id = FND_API.G_MISS_NUM THEN
14548                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14549             END IF;
14550 
14551         END IF;
14552 
14553     END IF;
14554 
14555     IF  p_line_val_rec.invoice_to_address1 <> FND_API.G_MISS_CHAR
14556     OR p_line_val_rec.invoice_to_address2 <> FND_API.G_MISS_CHAR
14557     OR p_line_val_rec.invoice_to_address3 <> FND_API.G_MISS_CHAR
14558     OR p_line_val_rec.invoice_to_address4 <> FND_API.G_MISS_CHAR
14559     OR p_line_val_rec.invoice_to_location <> FND_API.G_MISS_CHAR
14560     OR p_line_val_rec.invoice_to_org <> FND_API.G_MISS_CHAR
14561     THEN
14562 
14563         IF p_x_line_rec.invoice_to_org_id <> FND_API.G_MISS_NUM THEN
14564 
14565 
14566             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14567             THEN
14568 
14569                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14570                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','invoice_to_org');
14571                 OE_MSG_PUB.Add;
14572 
14573             END IF;
14574 
14575         ELSE
14576 
14577 /*1621182*/
14578             p_x_line_rec.invoice_to_org_id := OE_Value_To_Id.invoice_to_org
14579             (   p_invoice_to_address1         => p_line_val_rec.invoice_to_address1
14580           ,   p_invoice_to_address2         => p_line_val_rec.invoice_to_address2
14581           ,   p_invoice_to_address3         => p_line_val_rec.invoice_to_address3
14582           ,   p_invoice_to_address4         => p_line_val_rec.invoice_to_address4
14583           ,   p_invoice_to_location         => p_line_val_rec.invoice_to_location
14584           ,   p_invoice_to_org              => p_line_val_rec.invoice_to_org
14585           ,   p_invoice_to_city             => p_line_val_rec.invoice_to_city
14586           ,   p_invoice_to_state            => p_line_val_rec.invoice_to_state
14587           ,   p_invoice_to_postal_code      => p_line_val_rec.invoice_to_zip
14588           ,   p_invoice_to_country          => p_line_val_rec.invoice_to_country
14589 		  ,   p_sold_to_org_id        => l_sold_to_org_id
14590           , p_invoice_to_customer_id => p_x_line_rec.invoice_to_customer_id
14591             );
14592 /*1621182*/
14593             IF p_x_line_rec.invoice_to_org_id = FND_API.G_MISS_NUM THEN
14594                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14595             END IF;
14596 
14597         END IF;
14598 
14599     END IF;
14600 
14601     IF  p_line_val_rec.ship_to_address1 <> FND_API.G_MISS_CHAR
14602     OR p_line_val_rec.ship_to_address2 <> FND_API.G_MISS_CHAR
14603     OR p_line_val_rec.ship_to_address3 <> FND_API.G_MISS_CHAR
14604     OR p_line_val_rec.ship_to_address4 <> FND_API.G_MISS_CHAR
14605     OR p_line_val_rec.ship_to_location <> FND_API.G_MISS_CHAR
14606     OR p_line_val_rec.ship_to_org <> FND_API.G_MISS_CHAR
14607     THEN
14608 
14609         IF p_x_line_rec.ship_to_org_id <> FND_API.G_MISS_NUM THEN
14610 
14611 
14612             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14613             THEN
14614 
14615                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14616                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','ship_to_org');
14617                 OE_MSG_PUB.Add;
14618 
14619             END IF;
14620 
14621         ELSE
14622 
14623 /*1621182*/
14624             p_x_line_rec.ship_to_org_id := OE_Value_To_Id.ship_to_org
14625             (   p_ship_to_address1            => p_line_val_rec.ship_to_address1
14626           ,   p_ship_to_address2            => p_line_val_rec.ship_to_address2
14627           ,   p_ship_to_address3            => p_line_val_rec.ship_to_address3
14628           ,   p_ship_to_address4            => p_line_val_rec.ship_to_address4
14629           ,   p_ship_to_location            => p_line_val_rec.ship_to_location
14630           ,   p_ship_to_org                 => p_line_val_rec.ship_to_org
14631           ,   p_ship_to_city                => p_line_val_rec.ship_to_city
14632           ,   p_ship_to_state               => p_line_val_rec.ship_to_state
14633           ,   p_ship_to_postal_code         => p_line_val_rec.ship_to_zip
14634           ,   p_ship_to_country             => p_line_val_rec.ship_to_country
14635 		  ,   p_sold_to_org_id        => l_sold_to_org_id
14636           , p_ship_to_customer_id => p_x_line_rec.ship_to_customer_id
14637             );
14638 
14639 /*1621182*/
14640             IF p_x_line_rec.ship_to_org_id = FND_API.G_MISS_NUM THEN
14641                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14642             END IF;
14643 
14644         END IF;
14645 
14646     END IF;
14647 
14648     -- Retrieve the org_ids if not passed on the line record. These
14649     -- IDs will be needed by the value_to_id functions for CONTACT fields.
14650     -- For e.g. oe_value_to_id.ship_to_contact_id requires ship_to_org_id
14651 
14652     -- bug 3487597, added clause for line_id
14653 
14654     IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
14655 	  AND ( p_x_line_rec.ship_to_org_id = FND_API.G_MISS_NUM
14656 	       OR p_x_line_rec.invoice_to_org_id = FND_API.G_MISS_NUM
14657 	       OR p_x_line_rec.deliver_to_org_id = FND_API.G_MISS_NUM )
14658           AND p_x_line_rec.line_id <> FND_API.G_MISS_NUM
14659     THEN
14660 
14661 	  SELECT SHIP_TO_ORG_ID, INVOICE_TO_ORG_ID, DELIVER_TO_ORG_ID
14662 	  INTO l_sold_to_org_id, l_invoice_to_org_id, l_deliver_to_org_id
14663 	  FROM OE_ORDER_LINES
14664 	  WHERE LINE_ID = p_x_line_rec.line_id;
14665 
14666 	  IF p_x_line_rec.ship_to_org_id <> FND_API.G_MISS_NUM THEN
14667 		l_ship_to_org_id := p_x_line_rec.ship_to_org_id;
14668        END IF;
14669 
14670 	  IF p_x_line_rec.invoice_to_org_id <> FND_API.G_MISS_NUM THEN
14671 		l_invoice_to_org_id := p_x_line_rec.invoice_to_org_id;
14672        END IF;
14673 
14674 	  IF p_x_line_rec.deliver_to_org_id <> FND_API.G_MISS_NUM THEN
14675 		l_deliver_to_org_id := p_x_line_rec.deliver_to_org_id;
14676        END IF;
14677 
14678     ELSE
14679 
14680 	  l_sold_to_org_id := p_x_line_rec.sold_to_org_id;
14681 	  l_invoice_to_org_id := p_x_line_rec.invoice_to_org_id;
14682 	  l_deliver_to_org_id := p_x_line_rec.deliver_to_org_id;
14683 
14684     END IF;
14685 
14686     IF  p_line_val_rec.deliver_to_contact <> FND_API.G_MISS_CHAR
14687     THEN
14688 
14689         IF p_x_line_rec.deliver_to_contact_id <> FND_API.G_MISS_NUM THEN
14690 
14691 
14692             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14693             THEN
14694 
14695                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14696                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','deliver_to_contact');
14697                 OE_MSG_PUB.Add;
14698 
14699             END IF;
14700 
14701         ELSE
14702 
14703             p_x_line_rec.deliver_to_contact_id := OE_Value_To_Id.deliver_to_contact
14704             (   p_deliver_to_contact          => p_line_val_rec.deliver_to_contact
14705 		  ,   p_deliver_to_org_id           => l_deliver_to_org_id
14706             );
14707 
14708             IF p_x_line_rec.deliver_to_contact_id = FND_API.G_MISS_NUM THEN
14709                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14710             END IF;
14711 
14712         END IF;
14713 
14714     END IF;
14715 
14716     IF  p_line_val_rec.invoice_to_contact <> FND_API.G_MISS_CHAR
14717     THEN
14718 
14719         IF p_x_line_rec.invoice_to_contact_id <> FND_API.G_MISS_NUM THEN
14720 
14721 
14722             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14723             THEN
14724 
14725                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14726                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','invoice_to_contact');
14727                 OE_MSG_PUB.Add;
14728 
14729             END IF;
14730 
14731         ELSE
14732 
14733             p_x_line_rec.invoice_to_contact_id := OE_Value_To_Id.invoice_to_contact
14734             (   p_invoice_to_contact          => p_line_val_rec.invoice_to_contact
14735 		  ,   p_invoice_to_org_id           => l_invoice_to_org_id
14736             );
14737 
14738             IF p_x_line_rec.invoice_to_contact_id = FND_API.G_MISS_NUM THEN
14739                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14740             END IF;
14741 
14742         END IF;
14743 
14744     END IF;
14745 
14746     IF  p_line_val_rec.ship_to_contact <> FND_API.G_MISS_CHAR
14747     THEN
14748 
14749         IF p_x_line_rec.ship_to_contact_id <> FND_API.G_MISS_NUM THEN
14750 
14751 
14752             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14753             THEN
14754 
14755                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14756                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','ship_to_contact');
14757                 OE_MSG_PUB.Add;
14758 
14759             END IF;
14760 
14761         ELSE
14762 
14763             p_x_line_rec.ship_to_contact_id := OE_Value_To_Id.ship_to_contact
14764             (   p_ship_to_contact             => p_line_val_rec.ship_to_contact
14765 		  ,   p_ship_to_org_id              => l_ship_to_org_id
14766             );
14767 
14768             IF p_x_line_rec.ship_to_contact_id = FND_API.G_MISS_NUM THEN
14769                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14770             END IF;
14771 
14772         END IF;
14773 
14774     END IF;
14775 
14776     -- added code for commitment for bug 1851006.
14777     IF  p_line_val_rec.commitment <> FND_API.G_MISS_CHAR
14778     THEN
14779 
14780         IF p_x_line_rec.commitment_id <> FND_API.G_MISS_NUM THEN
14781 
14782             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14783             THEN
14784 
14785                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14786                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','commitment');
14787                 OE_MSG_PUB.Add;
14788 
14789             END IF;
14790 
14791         ELSE
14792 
14793             p_x_line_rec.commitment_id := OE_Value_To_Id.commitment
14794             (   p_commitment                   => p_line_val_rec.commitment
14795             );
14796 
14797             IF p_x_line_rec.commitment_id = FND_API.G_MISS_NUM THEN
14798                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14799             END IF;
14800 
14801         END IF;
14802       END IF;
14803 
14804       /* mvijayku */
14805     IF  p_line_val_rec.end_customer_name <> FND_API.G_MISS_CHAR
14806     OR  p_line_val_rec.end_customer_number <> FND_API.G_MISS_CHAR
14807     THEN
14808 
14809         IF p_x_line_rec.end_customer_id <> FND_API.G_MISS_NUM THEN
14810 
14811 
14812             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14813             THEN
14814 
14815                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14816                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','end_customer');
14817                 OE_MSG_PUB.Add;
14818 
14819             END IF;
14820 
14821         ELSE
14822           IF p_x_line_rec.end_customer_site_use_id = FND_API.G_MISS_NUM THEN -- 4231603
14823             p_x_line_rec.end_customer_id:=OE_Value_To_Id.end_customer
14824             ( p_end_customer       => p_line_val_rec.end_customer_name
14825              ,p_end_customer_number=> p_line_val_rec.end_customer_number
14826               );
14827 
14828             IF p_x_line_rec.end_customer_id = FND_API.G_MISS_NUM THEN
14829                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14830             END IF;
14831           END IF;
14832         END IF;
14833 
14834     END IF;
14835 
14836     IF  p_line_val_rec.end_customer_contact <> FND_API.G_MISS_CHAR
14837     THEN
14838 
14839         IF p_x_line_rec.end_customer_id <>FND_API.G_MISS_NUM and
14840                 p_x_line_rec.end_customer_contact_id <> FND_API.G_MISS_NUM THEN
14841 
14842 
14843             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14844             THEN
14845 
14846                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14847                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','end_customer_contact');
14848                 OE_MSG_PUB.Add;
14849 
14850             END IF;
14851 
14852         ELSE
14853                 oe_debug_pub.add('before calling aend customer contact value to id');
14854             p_x_line_rec.end_customer_contact_id := OE_Value_To_Id.end_customer_contact
14855             (   p_end_customer_contact             => p_line_val_rec.end_customer_contact
14856 		  ,p_end_customer_id              =>p_x_line_rec.end_customer_id
14857             );
14858 	    oe_debug_pub.add('End customer contact id is '||p_x_line_rec.end_customer_contact_id);
14859 
14860             IF p_x_line_rec.end_customer_contact_id = FND_API.G_MISS_NUM THEN
14861                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14862             END IF;
14863 
14864         END IF;
14865 
14866     END IF;
14867 
14868   IF (p_line_val_rec.end_customer_name <> FND_API.G_MISS_CHAR
14869       OR p_line_val_rec.end_customer_number <> FND_API.G_MISS_CHAR
14870       OR p_x_line_rec.end_customer_id <> FND_API.G_MISS_NUM)
14871 	 AND
14872      (p_line_val_rec.end_customer_site_address1 <> FND_API.G_MISS_CHAR
14873     OR p_line_val_rec.end_customer_site_address2 <> FND_API.G_MISS_CHAR
14874     OR p_line_val_rec.end_customer_site_address3 <> FND_API.G_MISS_CHAR
14875     OR p_line_val_rec.end_customer_site_address4 <> FND_API.G_MISS_CHAR
14876     OR p_line_val_rec.end_customer_site_location          <> FND_API.G_MISS_CHAR)
14877 
14878     THEN
14879 
14880         IF p_x_line_rec.end_customer_site_use_id <> FND_API.G_MISS_NUM THEN
14881 
14882 
14883             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14884             THEN
14885 
14886                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14887                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','end_Customer_Location');
14888                 OE_MSG_PUB.Add;
14889 
14890             END IF;
14891 
14892         ELSE
14893 	   oe_debug_pub.add('Before calling End custoemr site use value to id');
14894             p_x_line_rec.end_customer_site_use_id := OE_Value_To_Id.end_customer_site
14895             (   p_end_customer_site_address1            => p_line_val_rec.end_customer_site_address1
14896             ,   p_end_customer_site_address2            => p_line_val_rec.end_customer_site_address2
14897             ,   p_end_customer_site_address3            => p_line_val_rec.end_customer_site_address3
14898             ,   p_end_customer_site_address4            => p_line_val_rec.end_customer_site_address4
14899             ,   p_end_customer_site_location                     => p_line_val_rec.end_customer_site_location
14900 	    ,   p_end_customer_site_org                       => NULL
14901 		,   p_end_customer_id                         => p_x_line_rec.end_customer_id
14902             ,   p_end_customer_site_city                => p_line_val_rec.end_customer_site_city
14903             ,   p_end_customer_site_state               => p_line_val_rec.end_customer_site_state
14904             ,   p_end_customer_site_postalcode         => p_line_val_rec.end_customer_site_postal_code
14905             ,   p_end_customer_site_country             => p_line_val_rec.end_customer_site_country
14906             ,   p_end_customer_site_use_code           => NULL
14907             );
14908 
14909 
14910     oe_debug_pub.add('after hdr sold_to_site_use_id='||p_x_line_rec.end_customer_site_use_id);
14911 
14912             IF p_x_line_rec.end_customer_site_use_id = FND_API.G_MISS_NUM THEN
14913                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14914             END IF;
14915 
14916         END IF;
14917 
14918     END IF;
14919 
14920     -- {added for bug 4240715
14921     IF  p_line_val_rec.ib_owner_dsp <> FND_API.G_MISS_CHAR
14922     THEN
14923         IF p_x_line_rec.ib_owner <> FND_API.G_MISS_CHAR THEN
14924 
14925             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14926             THEN
14927 
14928                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14929                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','IB_Owner');
14930                 OE_MSG_PUB.Add;
14931 
14932             END IF;
14933 
14934         ELSE
14935 
14936             p_x_line_rec.ib_owner:=OE_Value_To_Id.ib_owner
14937             ( p_ib_owner       => p_line_val_rec.ib_owner_dsp
14938               );
14939 
14940             IF p_x_line_rec.ib_owner = FND_API.G_MISS_CHAR THEN
14941                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14942             END IF;
14943 
14944         END IF;
14945 
14946     END IF;
14947 
14948     IF  p_line_val_rec.ib_installed_at_location_dsp <> FND_API.G_MISS_CHAR
14949     THEN
14950         IF p_x_line_rec.ib_installed_at_location <> FND_API.G_MISS_CHAR THEN
14951 
14952             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14953             THEN
14954 
14955                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14956                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','IB_Installed_at_location');
14957                 OE_MSG_PUB.Add;
14958 
14959             END IF;
14960 
14961         ELSE
14962 
14963             p_x_line_rec.ib_installed_at_location:=OE_Value_To_Id.ib_installed_at_location
14964             ( p_ib_installed_at_location       => p_line_val_rec.ib_installed_at_location_dsp
14965               );
14966 
14967             IF p_x_line_rec.ib_installed_at_location = FND_API.G_MISS_CHAR THEN
14968                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14969             END IF;
14970 
14971         END IF;
14972 
14973     END IF;
14974 
14975      IF  p_line_val_rec.ib_current_location_dsp <> FND_API.G_MISS_CHAR
14976     THEN
14977         IF p_x_line_rec.ib_current_location <> FND_API.G_MISS_CHAR THEN
14978 
14979             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
14980             THEN
14981 
14982                 fnd_message.set_name('ONT','OE_BOTH_VAL_AND_ID_EXIST');
14983                 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','IB_current_location');
14984                 OE_MSG_PUB.Add;
14985 
14986             END IF;
14987 
14988         ELSE
14989 
14990             p_x_line_rec.ib_current_location:=OE_Value_To_Id.ib_current_location
14991             ( p_ib_current_location       => p_line_val_rec.ib_current_location_dsp
14992               );
14993 
14994             IF p_x_line_rec.ib_current_location = FND_API.G_MISS_CHAR THEN
14995                 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
14996             END IF;
14997 
14998         END IF;
14999 
15000     END IF;
15001     --bug 4240715}
15002 
15003     -------------------------------------------------------------------
15004     -- End of get IDs for customer related fields
15005     -------------------------------------------------------------------
15006 
15007 
15008 END Get_Ids;
15009 
15010 
15011 
15012 /*----------------------------------------------------------
15013 Procedure Query_Header
15014 -----------------------------------------------------------*/
15015 
15016 Procedure Query_Header
15017 (   p_line_id                       IN  NUMBER :=
15018                                         FND_API.G_MISS_NUM
15019 ,   x_header_id                     OUT NOCOPY /* file.sql.39 change */ NUMBER
15020 )IS
15021 BEGIN
15022 
15023 	Select header_id into x_header_id
15024 	from oe_order_lines
15025 	where line_id = p_line_id;
15026 	IF sql%notfound then
15027         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
15028 	END IF;
15029 
15030 
15031 END Query_Header;
15032 
15033 -- INVCONV for SAO
15034 
15035 PROCEDURE get_reserved_quantities
15036 ( p_header_id                       IN NUMBER
15037  ,p_line_id                         IN NUMBER
15038  ,p_org_id                          IN NUMBER
15039  ,p_order_quantity_uom              IN VARCHAR2 DEFAULT NULL
15040  ,p_inventory_item_id		    				IN NUMBER DEFAULT NULL
15041  ,x_reserved_quantity               OUT NOCOPY NUMBER
15042  ,x_reserved_quantity2              OUT NOCOPY NUMBER )
15043 
15044 IS
15045 
15046 l_reserved_quantity     NUMBER := 0;
15047 l_reserved_quantity2    NUMBER := 0;
15048 l_return_status         VARCHAR2(1);
15049 l_msg_count             NUMBER;
15050 l_msg_data              VARCHAR2(240);
15051 
15052 l_rsv_rec               inv_reservation_global.mtl_reservation_rec_type;
15053 l_rsv_tbl               inv_reservation_global.mtl_reservation_tbl_type;
15054 l_count                 NUMBER;
15055 l_x_error_code          NUMBER;
15056 l_lock_records          VARCHAR2(1);
15057 l_sort_by_req_date      NUMBER;
15058 --- 2346233
15059 l_converted_qty         NUMBER;
15060 l_inventory_item_id     NUMBER;
15061 l_order_quantity_uom    VARCHAR2(30);
15062 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
15063 
15064 BEGIN
15065 	 if l_debug_level > 0 then -- INVCONV
15066           oe_debug_pub.add('in get_reserved_quantities' );
15067    end if;
15068    l_rsv_rec.demand_source_header_id  := p_header_id;
15069    l_rsv_rec.demand_source_line_id    := p_line_id;
15070 
15071    l_rsv_rec.organization_id           := p_org_id;
15072 
15073    inv_reservation_pub.query_reservation_om_hdr_line
15074    (  p_api_version_number        => 1.0
15075   , p_init_msg_lst              => fnd_api.g_true
15076   , x_return_status             => l_return_status
15077   , x_msg_count                 => l_msg_count
15078   , x_msg_data                  => l_msg_data
15079   , p_query_input               => l_rsv_rec
15080   , x_mtl_reservation_tbl       => l_rsv_tbl
15081   , x_mtl_reservation_tbl_count => l_count
15082   , x_error_code                => l_x_error_code
15083   , p_lock_records              => l_lock_records
15084   , p_sort_by_req_date          => l_sort_by_req_date
15085    );
15086 
15087 
15088    IF ((p_order_quantity_uom IS NULL ) AND (p_inventory_item_id IS NULL)) THEN 	   --added condition for 3745318
15089    -- Start 2346233
15090 	   BEGIN
15091 	      Select order_quantity_uom, inventory_item_id
15092 	      Into   l_order_quantity_uom, l_inventory_item_id
15093 	      From   oe_order_lines_all
15094 	      Where  line_id = p_line_id;
15095 
15096 	   EXCEPTION
15097 	      WHEN OTHERS THEN
15098 		  l_order_quantity_uom := Null;
15099 	   END;
15100 	   ---- End 2346233
15101    ELSE
15102       l_order_quantity_uom :=p_order_quantity_uom;
15103       l_inventory_item_id  :=p_inventory_item_id;
15104    END IF;
15105 
15106 
15107    FOR I IN 1..l_rsv_tbl.COUNT LOOP
15108 
15109       ----
15110       IF nvl(l_order_quantity_uom,l_rsv_tbl(I).reservation_uom_code)
15111                                 <> l_rsv_tbl(I).reservation_uom_code THEN
15112          l_converted_qty := INV_CONVERT.INV_UM_CONVERT(l_inventory_item_id -- INVCONV
15113                                                       ,5 --NULL
15114                                                       ,l_rsv_tbl(I).reservation_quantity
15115                                                       ,l_rsv_tbl(I).reservation_uom_code
15116                                                       ,l_order_quantity_uom
15117                                                       ,NULL -- From uom name
15118                                                       ,NULL -- To uom name
15119                                                       );
15120 
15121 
15122         l_reserved_quantity := l_reserved_quantity + l_converted_qty;
15123      ELSE
15124      --- End 2346233
15125 
15126         l_reserved_quantity := l_reserved_quantity +
15127                                 l_rsv_tbl(I).reservation_quantity;
15128      END IF;
15129      l_reserved_quantity2 := l_reserved_quantity2 +
15130                                  l_rsv_tbl(I).secondary_reservation_quantity;
15131 
15132   END LOOP;
15133 
15134 	if l_debug_level > 0 then -- INVCONV
15135       oe_debug_pub.add('leaving get_reserved_quantities  qty = :' || l_reserved_quantity  );
15136       oe_debug_pub.add('leaving get_reserved_quantities  qty2 = :' || l_reserved_quantity2  );
15137  	end if;
15138 
15139   x_reserved_quantity  := l_reserved_quantity;
15140   x_reserved_quantity2  := l_reserved_quantity2;
15141 
15142 end get_reserved_quantities;
15143 -- INVCONV
15144 
15145 
15146 
15147 
15148 
15149 /*----------------------------------------------------------
15150 FUNCTION Get_Reserved_Quantity
15151 -- mpetrosi 02-Jun-2000 added org_id start change
15152 -----------------------------------------------------------*/
15153 
15154 FUNCTION Get_Reserved_Quantity
15155 ( p_header_id                       IN NUMBER
15156  ,p_line_id                         IN NUMBER
15157  ,p_org_id                          IN NUMBER
15158  ,p_order_quantity_uom                IN VARCHAR2 DEFAULT NULL	--3745318
15159  ,p_inventory_item_id		    IN NUMBER DEFAULT NULL	--3745318
15160 )RETURN NUMBER
15161 IS
15162 
15163 -- mpetrosi 02-Jun-2000 added org_id end change
15164 
15165 l_reserved_quantity     NUMBER := 0;
15166 l_return_status         VARCHAR2(1);
15167 l_msg_count             NUMBER;
15168 l_msg_data              VARCHAR2(240);
15169 
15170 l_rsv_rec               inv_reservation_global.mtl_reservation_rec_type;
15171 l_rsv_tbl               inv_reservation_global.mtl_reservation_tbl_type;
15172 l_count                 NUMBER;
15173 l_x_error_code          NUMBER;
15174 l_lock_records          VARCHAR2(1);
15175 l_sort_by_req_date      NUMBER;
15176 --- 2346233
15177 l_converted_qty         NUMBER;
15178 l_inventory_item_id     NUMBER;
15179 l_order_quantity_uom    VARCHAR2(30);
15180 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
15181 
15182 BEGIN
15183 		if l_debug_level > 0 then -- INVCONV
15184                 	oe_debug_pub.add('in get_reserved_quantity ' );
15185                  end if;
15186    l_rsv_rec.demand_source_header_id  := p_header_id;
15187    l_rsv_rec.demand_source_line_id    := p_line_id;
15188 
15189    -- mpetrosi OPM 02-jun-2000 added org_id start change
15190    l_rsv_rec.organization_id           := p_org_id;
15191    -- mpetrosi OPM 02-jun-2000 added org_id end change
15192 
15193    inv_reservation_pub.query_reservation_om_hdr_line
15194    (  p_api_version_number        => 1.0
15195   , p_init_msg_lst              => fnd_api.g_true
15196   , x_return_status             => l_return_status
15197   , x_msg_count                 => l_msg_count
15198   , x_msg_data                  => l_msg_data
15199   , p_query_input               => l_rsv_rec
15200   , x_mtl_reservation_tbl       => l_rsv_tbl
15201   , x_mtl_reservation_tbl_count => l_count
15202   , x_error_code                => l_x_error_code
15203   , p_lock_records              => l_lock_records
15204   , p_sort_by_req_date          => l_sort_by_req_date
15205    );
15206 
15207 
15208    IF ((p_order_quantity_uom IS NULL ) AND (p_inventory_item_id IS NULL)) THEN 	   --added condition for 3745318
15209    -- Start 2346233
15210 	   BEGIN
15211 	      Select order_quantity_uom, inventory_item_id
15212 	      Into   l_order_quantity_uom, l_inventory_item_id
15213 	      From   oe_order_lines_all
15214 	      Where  line_id = p_line_id;
15215 
15216 	   EXCEPTION
15217 	      WHEN OTHERS THEN
15218 		  l_order_quantity_uom := Null;
15219 	   END;
15220 	   ---- End 2346233
15221    ELSE
15222       l_order_quantity_uom :=p_order_quantity_uom;
15223       l_inventory_item_id  :=p_inventory_item_id;
15224    END IF;
15225 
15226 
15227    FOR I IN 1..l_rsv_tbl.COUNT LOOP
15228 
15229       l_rsv_rec := l_rsv_tbl(I);
15230       ---- Start 2346233
15231       IF nvl(l_order_quantity_uom,l_rsv_rec.reservation_uom_code)
15232                                 <> l_rsv_rec.reservation_uom_code THEN
15233          l_converted_qty := INV_CONVERT.INV_UM_CONVERT(l_inventory_item_id -- INVCONV
15234                                                       ,5 --NULL
15235                                                       ,l_rsv_rec.reservation_quantity
15236                                                       ,l_rsv_rec.reservation_uom_code
15237                                                       ,l_order_quantity_uom
15238                                                       ,NULL -- From uom name
15239                                                       ,NULL -- To uom name
15240                                                       );
15241 
15242 
15243         l_reserved_quantity := l_reserved_quantity + l_converted_qty;
15244      ELSE
15245      --- End 2346233
15246 
15247         l_reserved_quantity := l_reserved_quantity +
15248                                  l_rsv_rec.reservation_quantity;
15249      END IF; -- 2346233
15250 
15251    END LOOP;
15252 
15253 
15254 if l_debug_level > 0 then -- INVCONV
15255                 	oe_debug_pub.add('leaving get_reserved_quantity. qty = :' || l_reserved_quantity  );
15256 end if;
15257    return (l_reserved_quantity);
15258 
15259 END Get_Reserved_Quantity;
15260 
15261 /*----------------------------------------------------------
15262 FUNCTION Get_Reserved_Quantity2   INVCONV
15263 -----------------------------------------------------------*/
15264 
15265 FUNCTION Get_Reserved_Quantity2
15266 ( p_header_id                       IN NUMBER
15267  ,p_line_id                         IN NUMBER
15268  ,p_org_id                          IN NUMBER
15269 )RETURN NUMBER
15270 IS
15271 
15272 l_reserved_quantity2     NUMBER := 0;
15273 l_return_status         VARCHAR2(1);
15274 l_msg_count             NUMBER;
15275 l_msg_data              VARCHAR2(240);
15276 
15277 l_rsv_rec               inv_reservation_global.mtl_reservation_rec_type;
15278 l_rsv_tbl               inv_reservation_global.mtl_reservation_tbl_type;
15279 l_count                 NUMBER;
15280 l_x_error_code          NUMBER;
15281 l_lock_records          VARCHAR2(1);
15282 l_sort_by_req_date      NUMBER;
15283 --- 2346233
15284 l_converted_qty         NUMBER;
15285 l_inventory_item_id     NUMBER;
15286 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
15287 
15288 
15289 BEGIN
15290    if l_debug_level > 0 then -- INVCONV
15291                 	oe_debug_pub.add('in get_reserved_quantity ' );
15292     end if;
15293    l_rsv_rec.demand_source_header_id  := p_header_id;
15294    l_rsv_rec.demand_source_line_id    := p_line_id;
15295 
15296    l_rsv_rec.organization_id           := p_org_id;
15297 
15298    inv_reservation_pub.query_reservation_om_hdr_line
15299    (  p_api_version_number        => 1.0
15300   , p_init_msg_lst              => fnd_api.g_true
15301   , x_return_status             => l_return_status
15302   , x_msg_count                 => l_msg_count
15303   , x_msg_data                  => l_msg_data
15304   , p_query_input               => l_rsv_rec
15305   , x_mtl_reservation_tbl       => l_rsv_tbl
15306   , x_mtl_reservation_tbl_count => l_count
15307   , x_error_code                => l_x_error_code
15308   , p_lock_records              => l_lock_records
15309   , p_sort_by_req_date          => l_sort_by_req_date
15310    );
15311 
15312    FOR I IN 1..l_rsv_tbl.COUNT LOOP
15313 
15314       l_rsv_rec := l_rsv_tbl(I);
15315       l_reserved_quantity2 := l_reserved_quantity2 +
15316                                  l_rsv_rec.secondary_reservation_quantity;
15317 
15318    END LOOP;
15319 if l_debug_level > 0 then -- INVCONV
15320        oe_debug_pub.add('leaving get_reserved_quantity2. qty2 = :' || l_reserved_quantity2  );
15321 end if;
15322 
15323    return (l_reserved_quantity2);
15324 
15325 END Get_Reserved_Quantity2;
15326 
15327 
15328 
15329 
15330 /*----------------------------------------------------------
15331 FUNCTION Get_Open_Quantity
15332 -----------------------------------------------------------*/
15333 
15334 FUNCTION Get_Open_Quantity(p_header_id        IN NUMBER,
15335                            p_line_id          IN NUMBER,
15336                            p_ordered_quantity IN NUMBER,
15337                            p_shipped_quantity IN NUMBER)
15338 RETURN NUMBER
15339 IS
15340 l_open_quantity         NUMBER := 0;
15341 l_reserved_quantity     NUMBER := 0;
15342 l_mtl_sales_order_id    NUMBER;
15343 l_return_status         VARCHAR2(1);
15344 l_msg_count             NUMBER;
15345 l_msg_data              VARCHAR2(240);
15346 
15347 l_rsv_rec               inv_reservation_global.mtl_reservation_rec_type;
15348 l_rsv_tbl               inv_reservation_global.mtl_reservation_tbl_type;
15349 l_count                 NUMBER;
15350 l_x_error_code          NUMBER;
15351 l_lock_records          VARCHAR2(1);
15352 l_sort_by_req_date      NUMBER;
15353 l_converted_qty         NUMBER;
15354 l_inventory_item_id     NUMBER;
15355 l_order_quantity_uom    VARCHAR2(30);
15356 BEGIN
15357 
15358    l_mtl_sales_order_id := OE_HEADER_UTIL.Get_Mtl_Sales_Order_Id
15359                           (p_header_id=>p_header_id);
15360 
15361 
15362 /* This part is commented to fix the bug 2136256.
15363    Once we fix the uom conversion issue in Get_Reserved_Quantity
15364    we will revert the changes.
15365    l_reserved_quantity  := Get_Reserved_Quantity (l_mtl_sales_order_id,
15366                                                  p_line_id);
15367 */
15368 
15369 
15370 
15371    l_rsv_rec.demand_source_header_id  := l_mtl_sales_order_id;
15372    l_rsv_rec.demand_source_line_id    := p_line_id;
15373 
15374    -- mpetrosi OPM 02-jun-2000 added org_id start change
15375    l_rsv_rec.organization_id           := Null;
15376    -- mpetrosi OPM 02-jun-2000 added org_id end change
15377 
15378    inv_reservation_pub.query_reservation_om_hdr_line
15379    (  p_api_version_number        => 1.0
15380   , p_init_msg_lst              => fnd_api.g_true
15381   , x_return_status             => l_return_status
15382   , x_msg_count                 => l_msg_count
15383   , x_msg_data                  => l_msg_data
15384   , p_query_input               => l_rsv_rec
15385   , x_mtl_reservation_tbl       => l_rsv_tbl
15386   , x_mtl_reservation_tbl_count => l_count
15387   , x_error_code                => l_x_error_code
15388   , p_lock_records              => l_lock_records
15389   , p_sort_by_req_date          => l_sort_by_req_date
15390    );
15391 
15392    BEGIN
15393 
15394         Select order_quantity_uom, inventory_item_id
15395         Into   l_order_quantity_uom, l_inventory_item_id
15396         From   oe_order_lines_all
15397         Where  line_id = p_line_id;
15398 
15399    EXCEPTION
15400     WHEN OTHERS THEN
15401 
15402      l_order_quantity_uom := Null;
15403    END;
15404    FOR I IN 1..l_rsv_tbl.COUNT LOOP
15405 
15406       l_rsv_rec := l_rsv_tbl(I);
15407 
15408       IF nvl(l_order_quantity_uom,l_rsv_rec.reservation_uom_code)
15409                                 <> l_rsv_rec.reservation_uom_code THEN
15410 
15411         oe_debug_pub.add('reservation_uom_code :' ||
15412                               l_rsv_rec.reservation_uom_code,3);
15413         oe_debug_pub.add('l_order_quantity_uom :' ||
15414                               l_order_quantity_uom,3);
15415         oe_debug_pub.add('reservation_quantity :' ||
15416                               l_rsv_rec.reservation_quantity,3);
15417         l_converted_qty :=
15418         Oe_Order_Misc_Util.convert_uom( l_inventory_item_id,
15419 				     l_rsv_rec.reservation_uom_code,
15420 				     l_order_quantity_uom,
15421 			             l_rsv_rec.reservation_quantity);
15422 
15423         oe_debug_pub.add('l_converted_qty :' || l_converted_qty,3);
15424         l_reserved_quantity := l_reserved_quantity +
15425                                l_converted_qty;
15426       ELSE
15427 
15428         oe_debug_pub.add('2 reservation_quantity :' ||
15429                               l_rsv_rec.reservation_quantity);
15430         l_reserved_quantity := l_reserved_quantity +
15431                                  l_rsv_rec.reservation_quantity;
15432       END IF;
15433 
15434    END LOOP;
15435 
15436    l_open_quantity      := p_ordered_quantity -
15437                            nvl(p_shipped_quantity,0) -
15438                            l_reserved_quantity;
15439 
15440   RETURN l_open_quantity;
15441 
15442 EXCEPTION
15443 
15444 WHEN NO_DATA_FOUND THEN
15445 		RETURN NULL;
15446 
15447 END Get_Open_Quantity;
15448 
15449 
15450 
15451 /*----------------------------------------------------------
15452 FUNCTION Get_Primary_Uom_Quantity
15453 -----------------------------------------------------------*/
15454 
15455 FUNCTION Get_Primary_Uom_Quantity(p_ordered_quantity IN NUMBER,
15456                                   p_order_quantity_uom IN VARCHAR2)
15457 RETURN NUMBER
15458 IS
15459 BEGIN
15460     RETURN p_ordered_quantity;
15461 
15462 EXCEPTION
15463 
15464 WHEN NO_DATA_FOUND THEN
15465 		RETURN NULL;
15466 
15467 END Get_Primary_Uom_Quantity;
15468 
15469 
15470 -- check whether total returned quantity (this line plus all previous
15471 -- lines ) is more than ordered
15472 
15473 
15474 
15475 /*----------------------------------------------------------
15476 Function Is_Over_Return
15477 -----------------------------------------------------------*/
15478 
15479 Function Is_Over_Return
15480 (   p_line_rec                      IN OE_Order_PUB.Line_Rec_Type
15481 ) RETURN BOOLEAN
15482 IS
15483 l_total NUMBER;
15484 l_orig_quantity NUMBER;
15485 l_upgraded_flag varchar2(1);
15486 l_srl_num_count NUMBER;
15487 
15488 l_overship_invoice_basis    varchar2(30) := null;  --bug# 6617423
15489 
15490 CURSOR C_LOT_SERIAL(p_serial_num VARCHAR2) IS
15491     SELECT line_id,line_set_id,from_serial_number,to_serial_number
15492     FROM oe_lot_serial_numbers
15493     WHERE from_serial_number = p_serial_num
15494     OR to_serial_number = p_serial_num;
15495     l_ref_line_id NUMBER;
15496 
15497 BEGIN
15498 
15499  oe_debug_pub.ADD('Entering Over Return',1);
15500 
15501  /*
15502  ** Fix Bug # 2971412
15503  ** Since this validation used to get performed even in older
15504  ** releases. There is no need to suppress it for upgraded orders
15505  **
15506  IF p_line_rec.reference_line_id is not null THEN
15507 
15508 	select nvl(upgraded_flag,'-') into l_upgraded_flag
15509      from oe_order_lines
15510      where line_id = p_line_rec.reference_line_id;
15511 
15512      IF l_upgraded_flag in ('Y','P') THEN
15513           return FALSE;
15514      END IF;
15515 
15516   END IF;
15517   */
15518 
15519   oe_debug_pub.ADD('Return Context is: '||p_line_rec.return_context,1);
15520   oe_debug_pub.ADD('Line Id is: '||to_char(p_line_rec.line_id),1);
15521   oe_debug_pub.ADD('Reference Line Id is: '||to_char(p_line_rec.reference_line_id),1);
15522 
15523   -- Fix for Bug # 1613371
15524   IF p_line_rec.return_context = 'SERIAL' THEN
15525 
15526        FOR C2 IN C_LOT_SERIAL(p_line_rec.return_attribute2) LOOP
15527 
15528        -- If record exists in oe_lot_serial_numbers for the entered SN,
15529        -- check the line_set_id on it. There will be a value for line_set_id
15530        -- if the RMA line has got split. Get the reference line_id from the
15531        -- following queries.
15532 
15533             IF C2.line_set_id is not null THEN
15534                  select distinct reference_line_id
15535                  into l_ref_line_id
15536                  from oe_line_sets a,
15537                       oe_order_lines b
15538                  where a.set_id = C2.line_set_id
15539                  and a.line_id = b.line_id
15540                  and b.booked_flag = 'Y'
15541                  and b.line_id <> p_line_rec.line_id
15542                  and b.cancelled_flag <> 'Y';
15543             ELSE
15544                  select reference_line_id
15545                  into l_ref_line_id
15546                  from oe_order_lines
15547                  where line_id = C2.line_id
15548                  and line_id <> p_line_rec.line_id
15549                  and booked_flag = 'Y'
15550                  and cancelled_flag <> 'Y';
15551             END IF;
15552             IF l_ref_line_id = p_line_rec.reference_line_id THEN
15553                 RETURN TRUE;
15554             END IF;
15555        END LOOP;
15556   END IF;
15557 
15558   oe_debug_pub.ADD('Before checking the total for the Outbound line',1);
15559   SELECT sum(nvl(ordered_quantity, 0))
15560   INTO l_total
15561   FROM   oe_order_lines
15562   WHERE reference_line_id = p_line_rec.reference_line_id
15563   AND ((booked_flag = 'Y' and header_id <> p_line_rec.header_id)
15564     OR (header_id = p_line_rec.header_id))
15565   AND cancelled_flag <> 'Y'
15566   AND line_category_code = 'RETURN'
15567   AND line_id <> p_line_rec.line_id;
15568 
15569   oe_debug_pub.ADD('l_total : '||to_char(l_total),1);
15570 
15571 
15572     -- bug# 6617423 : Start  -----------
15573   /*
15574       SELECT nvl(ordered_quantity, 0)
15575       INTO l_orig_quantity
15576       FROM oe_order_lines
15577       WHERE line_id = p_line_rec.reference_line_id;
15578    */
15579 
15580     oe_debug_pub.add( ' <in Is_Over_Return >    p_line_rec.org_id = '|| p_line_rec.org_id, 5 ) ;
15581     IF p_line_rec.org_id = FND_API.G_MISS_NUM THEN   ---no need to handle null, automatically handled
15582        l_overship_invoice_basis := oe_sys_parameters.value('OE_OVERSHIP_INVOICE_BASIS',NULL);
15583     ELSE
15584        l_overship_invoice_basis := oe_sys_parameters.value('OE_OVERSHIP_INVOICE_BASIS',p_line_rec.org_id);
15585     END IF;
15586     oe_debug_pub.add(  ' <in Is_Over_Return >  l_overship_invoice_basis = '|| l_overship_invoice_basis , 5 ) ;
15587     oe_debug_pub.add(  ' <in Is_Over_Return >  p_line_rec.reference_line_id = '|| p_line_rec.reference_line_id , 5) ;
15588 
15589     IF l_overship_invoice_basis = 'SHIPPED' then
15590       SELECT nvl(shipped_quantity, ordered_quantity)  --- get from ord_qty if original line not shipped/invoiced....
15591       INTO l_orig_quantity
15592       FROM oe_order_lines
15593       WHERE line_id = p_line_rec.reference_line_id;
15594     ELSE
15595       SELECT nvl(ordered_quantity, 0)
15596       INTO l_orig_quantity
15597       FROM oe_order_lines
15598       WHERE line_id = p_line_rec.reference_line_id;
15599     end if;
15600     -- bug# 6617423: End -------
15601 
15602 
15603   oe_debug_pub.ADD('l_orig_quantity : '||to_char(l_orig_quantity),1);
15604 
15605   IF nvl(l_total,0) + p_line_rec.ordered_quantity > l_orig_quantity THEN
15606     RETURN TRUE;
15607   ELSE
15608     RETURN FALSE;
15609   END IF;
15610 
15611 EXCEPTION
15612   WHEN NO_DATA_FOUND THEN
15613    oe_debug_pub.ADD('In NO DATA FOUND ',1);
15614     RETURN FALSE;
15615 END Is_Over_Return;
15616 
15617 
15618 
15619 /*----------------------------------------------------------
15620 PROCEDURE Get_Inventory_Item
15621 -----------------------------------------------------------*/
15622 
15623 PROCEDURE Get_Inventory_Item
15624 (p_x_line_rec       IN OUT NOCOPY    OE_Order_Pub.Line_Rec_Type
15625 ,x_return_status  OUT NOCOPY /* file.sql.39 change */  VARCHAR2
15626 )
15627 IS
15628 /* Variables to call process order */
15629 l_line_tbl                         OE_ORDER_PUB.Line_Tbl_Type;
15630 l_old_line_tbl					OE_ORDER_PUB.Line_Tbl_Type;
15631 l_control_rec                 	OE_GLOBALS.Control_Rec_Type;
15632 
15633 l_attribute_value             VARCHAR2(2000);
15634 l_address_id                  VARCHAR2(2000):= NULL;
15635 l_cust_id                     NUMBER:= NULL;
15636 l_update_inventory_item       VARCHAR2(1) := FND_API.G_FALSE;
15637 l_inventory_item_id           NUMBER;
15638 l_error_code                  VARCHAR2(2000);
15639 l_error_flag                  VARCHAR2(2000);
15640 l_error_message               VARCHAR2(2000);
15641 BEGIN
15642 
15643         /*
15644          1.call  INV_CUSTOMER_ITEM_GRP.CI_Attribute_Value
15645            to get the inventory_item_id
15646            given the customer_item_id, and the new ship_from_org_id.
15647 
15648          2.check the value of the inventory_item_id returned:
15649            if internal item number return is not null, then
15650            assign the inventory_item_id to the out parameter
15651            otherwise
15652            post  message OE_INVALIDATES_CUSTOMER_ITEM
15653            set return status to error.
15654           */
15655 
15656     oe_debug_pub.add('Entering Get_Inventory_Item', 1);
15657     IF (p_x_line_rec.ship_to_org_id IS NOT NULL AND
15658         p_x_line_rec.ship_to_org_id <> FND_API.G_MISS_NUM) THEN
15659         /* Replaced with the following SELECT and IF statements
15660            to fix bug 2163988
15661         SELECT  cust_acct_site_id
15662         INTO  l_address_id
15663         FROM  HZ_CUST_SITE_USES
15664         WHERE  site_use_id = p_x_line_rec.ship_to_org_id
15665         AND  site_use_code = 'SHIP_TO';
15666         */
15667 
15668         SELECT  /*MOAC_SQL_CHANGES*/ u.cust_acct_site_id,
15669                 s.cust_account_id
15670         INTO  l_address_id,
15671               l_cust_id
15672         FROM  HZ_CUST_SITE_USES_ALL u,
15673               HZ_CUST_ACCT_SITES s
15674         WHERE  u.cust_acct_site_id = s.cust_acct_site_id
15675         AND    u.site_use_id = p_x_line_rec.ship_to_org_id
15676         AND    u.site_use_code = 'SHIP_TO';
15677         oe_debug_pub.add('ship to address:' || l_address_id||' - Customer:'||to_char(l_cust_id));
15678 
15679         IF l_cust_id <> p_x_line_rec.sold_to_org_id  THEN
15680           oe_debug_pub.add('Sold-To Customer:'||to_char(p_x_line_rec.sold_to_org_id));
15681           l_address_id := NULL;
15682         END IF;
15683 
15684     END IF;
15685 
15686     oe_debug_pub.add('INVENTORY_ITEM_ID Before calling CI_Attribute_Value '
15687 	||to_char(p_x_line_rec.inventory_item_id), 1);
15688     INV_CUSTOMER_ITEM_GRP.CI_Attribute_Value(
15689                        Z_Customer_Item_Id => p_x_line_rec.ordered_item_id
15690                    , Z_Customer_Id => p_x_line_rec.sold_to_org_id
15691                    , Z_Address_Id => l_address_id
15692                    , Z_Organization_Id => nvl(p_x_line_rec.ship_from_org_id, OE_Sys_Parameters.value('MASTER_ORGANIZATION_ID'))
15693     -- This change is required since we are dropping the profile OE_ORGANIZATION    -- _ID. Change made by Esha.
15694                    , Z_Inventory_Item_Id => p_x_line_rec.inventory_item_id
15695                    , Attribute_Name => 'INVENTORY_ITEM_ID'
15696                    , Error_Code => l_error_code
15697                    , Error_Flag => l_error_flag
15698                    , Error_Message => l_error_message
15699                    , Attribute_Value => l_attribute_value
15700                      );
15701 
15702     oe_debug_pub.add('INVENTORY_ITEM_ID After call is '||l_attribute_value, 1);
15703     IF (l_attribute_value IS NOT NULL AND
15704        to_number(l_attribute_value) <> p_x_line_rec.inventory_item_id) THEN
15705        oe_debug_pub.add('Assigning new inventory_item_id', 1);
15706        l_update_inventory_item := FND_API.G_TRUE;
15707        l_inventory_item_id := TO_NUMBER(l_attribute_value);
15708     ELSIF to_number(l_attribute_value) = p_x_line_rec.inventory_item_id THEN
15709        NULL;
15710     ELSE
15711        oe_debug_pub.add('Issue error message', 1);
15712        fnd_message.set_name('ONT','OE_INVALIDATES_CUSTOMER_ITEM');
15713        OE_MSG_PUB.Add;
15714        x_return_status := FND_API.G_RET_STS_ERROR;
15715     END IF;
15716 
15717     oe_debug_pub.add('Return Status after calling CI_Attribute_Value '||x_return_status, 1);
15718     IF l_update_inventory_item = FND_API.G_TRUE THEN
15719 
15720      -- Call Process Order
15721 
15722      oe_debug_pub.add('Calling Process order to update inventory item', 1);
15723 	l_control_rec.controlled_operation := TRUE;
15724 	l_control_rec.check_security		:= TRUE;
15725     	l_control_rec.clear_dependents 	:= TRUE;
15726 	l_control_rec.default_attributes	:= TRUE;
15727 	l_control_rec.change_attributes	:= TRUE;
15728 	l_control_rec.validate_entity		:= TRUE;
15729     	l_control_rec.write_to_DB          := FALSE;
15730     	l_control_rec.process := FALSE;
15731 
15732 	l_old_line_tbl(1) 				:= p_x_line_rec;
15733      l_line_tbl(1) 					:= p_x_line_rec;
15734      l_line_tbl(1).inventory_item_id 	:= l_inventory_item_id;
15735 
15736 	Oe_Order_Pvt.Lines
15737 	(    p_validation_level			=> FND_API.G_VALID_LEVEL_NONE
15738 	,	p_control_rec				=> l_control_rec
15739 	,	p_x_line_tbl				=> l_line_tbl
15740 	,	p_x_old_line_tbl			=> l_old_line_tbl
15741 	,    x_return_status               => x_return_status
15742 	);
15743 
15744      oe_debug_pub.add('Return Status after calling Process order'||x_return_status, 1);
15745 
15746      p_x_line_rec := l_line_tbl(1);
15747 
15748    END IF;
15749 
15750    oe_debug_pub.add('Exiting Get_Inventory_Item', 1);
15751 
15752 END Get_Inventory_Item;
15753 
15754 
15755 
15756 /*----------------------------------------------------------
15757 PROCEDURE Clear_Shipping_Method
15758 -----------------------------------------------------------*/
15759 
15760 PROCEDURE Clear_Shipping_Method
15761 (p_x_line_rec				IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type)
15762 IS
15763 l_old_line_tbl				OE_Order_PUB.Line_Tbl_Type;
15764 l_line_tbl				OE_Order_PUB.Line_Tbl_Type;
15765 l_control_rec				OE_GLOBALS.Control_Rec_Type;
15766 l_return_status               VARCHAR2(30);
15767 BEGIN
15768 
15769 	l_control_rec.controlled_operation := TRUE;
15770 	l_control_rec.check_security		:= TRUE;
15771     	l_control_rec.clear_dependents 	:= FALSE;
15772 	l_control_rec.default_attributes	:= FALSE;
15773 	l_control_rec.change_attributes	:= TRUE;
15774 	l_control_rec.validate_entity		:= FALSE;
15775     	l_control_rec.write_to_DB          := FALSE;
15776     	l_control_rec.process := FALSE;
15777 
15778 	l_old_line_tbl(1) 				:= p_x_line_rec;
15779 	l_line_tbl(1) 					:= p_x_line_rec;
15780 	l_line_tbl(1).freight_carrier_code := NULL;
15781 	l_line_tbl(1).shipping_method_code := NULL;
15782 
15783 	Oe_Order_Pvt.Lines
15784 	(    p_validation_level			=> FND_API.G_VALID_LEVEL_NONE
15785 	,	p_control_rec			=> l_control_rec
15786 	,	p_x_line_tbl			=> l_line_tbl
15787 	,	p_x_old_line_tbl		=> l_old_line_tbl
15788 	,    x_return_status          => l_return_status
15789 	);
15790 
15791 	IF l_return_status = FND_API.G_RET_STS_ERROR THEN
15792 		RAISE FND_API.G_EXC_ERROR;
15793 	ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
15794 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
15795 	END IF;
15796 
15797 	p_x_line_rec := l_line_tbl(1);
15798 
15799 END Clear_Shipping_Method;
15800 
15801 
15802 
15803 /*----------------------------------------------------------
15804 PROCEDURE Clear_Commitment_Id
15805 -----------------------------------------------------------*/
15806 
15807 PROCEDURE Clear_Commitment_Id
15808       (p_x_line_rec                 IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type)
15809 IS
15810 l_old_line_tbl                OE_Order_PUB.Line_Tbl_Type;
15811 l_line_tbl                    OE_Order_PUB.Line_Tbl_Type;
15812 l_control_rec                 OE_GLOBALS.Control_Rec_Type;
15813 l_return_status               VARCHAR2(30);
15814 BEGIN
15815 
15816      l_control_rec.controlled_operation := TRUE;
15817      l_control_rec.check_security       := TRUE;
15818      l_control_rec.clear_dependents     := FALSE;
15819      l_control_rec.default_attributes   := FALSE;
15820      l_control_rec.change_attributes    := TRUE;
15821      l_control_rec.validate_entity      := FALSE;
15822      l_control_rec.write_to_DB          := FALSE;
15823      l_control_rec.process := FALSE;
15824 
15825      l_old_line_tbl(1)                  := p_x_line_rec;
15826      l_line_tbl(1)                      := p_x_line_rec;
15827      l_line_tbl(1).commitment_id        := NULL;
15828      --l_line_tbl(1).shipping_method_code := NULL;
15829 
15830      Oe_Order_Pvt.Lines
15831      (    p_validation_level            => FND_API.G_VALID_LEVEL_NONE
15832    ,    p_control_rec            => l_control_rec
15833    ,    p_x_line_tbl             => l_line_tbl
15834    ,    p_x_old_line_tbl         => l_old_line_tbl
15835    ,    x_return_status          => l_return_status
15836      );
15837 
15838      IF l_return_status = FND_API.G_RET_STS_ERROR THEN
15839           RAISE FND_API.G_EXC_ERROR;
15840      ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
15841           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
15842      END IF;
15843 
15844      p_x_line_rec := l_line_tbl(1);
15845 
15846 END Clear_Commitment_Id;
15847 
15848 
15849 
15850 /*----------------------------------------------------------
15851  PROCEDURE Pre_Write_Process
15852 -----------------------------------------------------------*/
15853 
15854 PROCEDURE Pre_Write_Process
15855 (   p_x_line_rec                    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
15856 ,   p_old_line_rec                  IN  OE_Order_PUB.Line_Rec_Type :=
15857 								OE_Order_PUB.G_MISS_LINE_REC
15858 ) IS
15859 l_atp_tbl               OE_ATP.atp_tbl_type;
15860 l_return_status         varchar2(30);
15861 l_split_action_code     varchar2(30);
15862 l_param1                VARCHAR2(2000):= null;
15863 l_param2                VARCHAR2(240) := null;
15864 l_param3                VARCHAR2(240) := null;
15865 l_param4                VARCHAR2(240) := null;
15866 l_param5                VARCHAR2(240) := null;
15867 l_param6                VARCHAR2(240) := null;
15868 l_param9                VARCHAR2(240) := null;
15869 l_param10               VARCHAR2(240) := null;
15870 l_param11               VARCHAR2(240) := null;
15871 l_param12               VARCHAR2(240) := null;
15872 l_flag                  BOOLEAN;
15873 l_count			NUMBER;
15874 l_num                   NUMBER;
15875 l_msg_count                 NUMBER;
15876 l_msg_data                  VARCHAR2(2000);
15877 
15878 l_delta_qty                 NUMBER;
15879 l_delta_extended_amount     NUMBER;
15880 l_old_qty                   NUMBER;
15881 l_new_qty                   NUMBER;
15882 l_new_unit_selling_price    NUMBER;
15883 l_old_unit_selling_price    NUMBER;
15884 l_old_extended_amount       NUMBER;
15885 l_new_extended_amount       NUMBER;
15886 l_parent_document_type_id   NUMBER;
15887 l_pricing_event             VARCHAR2(30);
15888 l_require_reason            BOOLEAN ; -- 2921731
15889 l_promise_date_flag         VARCHAR2(2);
15890 --bug 4190357
15891 v_count                     NUMBER;
15892 l_meaning                   VARCHAR2(80);
15893 --bug 4190357
15894 l_modified_from             VARCHAR2(30);
15895 
15896 l_line_payment_type_code    VARCHAR2(30);
15897 
15898 
15899 --
15900 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
15901 --
15902 l_attr_attach_change         boolean := FALSE;  --6896311
15903 BEGIN
15904 
15905 if l_debug_level > 0 then
15906  oe_debug_pub.Add('Entering pre_write_process for line ID  : '||p_x_line_rec.line_id, 1);
15907 end if;
15908 
15909 -- bug fix 3350185:
15910 -- Audit Trail/Versioning moved to separate procedure below
15911    Version_Audit_Process( p_x_line_rec => p_x_line_rec,
15912                           p_old_line_rec => p_old_line_rec,
15913                           p_process_step => 1 );
15914 
15915 
15916 if l_debug_level > 0 then
15917    oe_debug_pub.Add('After Assign out rec', 1);
15918 end if;
15919 
15920    ------------------------------------------------------------------------
15921    -- Copy corresponding inventory item to the line if it is a CUST item
15922    ------------------------------------------------------------------------
15923 
15924    IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_from_org_id ,
15925                            p_old_line_rec.ship_from_org_id) OR
15926       NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_to_org_id ,
15927                         p_old_line_rec.ship_to_org_id) THEN
15928       if l_debug_level > 0 then
15929          oe_debug_pub.Add('RR:I1', 1);
15930       end if;
15931       IF p_x_line_rec.item_identifier_type = 'CUST' THEN
15932          if l_debug_level > 0 then
15933             oe_debug_pub.Add('RR:I2', 1);
15934          end if;
15935          IF (p_x_line_rec.ordered_item_id IS NOT NULL AND
15936              p_x_line_rec.ordered_item_id <> FND_API.G_MISS_NUM) THEN
15937             if l_debug_level > 0 then
15938                oe_debug_pub.add('return_status before calling Get_Inventory_Item '
15939 				||l_return_status, 1);
15940             end if;
15941             Get_Inventory_Item
15942 			( p_x_line_rec  	=> p_x_line_rec
15943             	, x_return_status	=> l_return_status);
15944 
15945             if l_debug_level > 0 then
15946                oe_debug_pub.add('return_status after calling Get_Inventory_Item '||l_return_status, 1);
15947             end if;
15948          END IF;
15949       END IF;
15950    if l_debug_level > 0 then
15951       oe_debug_pub.Add('RR:I2.5', 1);
15952    end if;
15953    END IF;
15954 
15955    if l_debug_level > 0 then
15956       oe_debug_pub.Add('RR:I3', 1);
15957    end if;
15958 
15959    IF l_return_status = FND_API.G_RET_STS_ERROR THEN
15960        RAISE FND_API.G_EXC_ERROR;
15961    END IF;
15962    IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
15963        RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
15964    END IF;
15965 
15966 
15967    ------------------------------------------------------------------------
15968    -- Populate ordered item field if item identifier type is INT or CUST
15969    /*Bug 2411113*/
15970    ------------------------------------------------------------------------
15971 
15972    IF (NOT OE_GLOBALS.EQUAL(p_x_line_rec.inventory_item_id ,
15973                            p_old_line_rec.inventory_item_id)
15974    AND p_x_line_rec.item_identifier_type in ('INT', 'CUST'))
15975 OR
15976    (p_x_line_rec.ordered_item =  FND_API.G_MISS_CHAR
15977    AND p_x_line_rec.item_identifier_type in ('INT', 'CUST')) THEN
15978 
15979       if l_debug_level > 0 then
15980          oe_debug_pub.Add('Before calling get_ordered_item', 1);
15981          oe_debug_pub.add('return_status before calling Get_ordered_Item '
15982 				||l_return_status, 1);
15983       end if;
15984          Oe_Oe_Form_Line.Get_Ordered_Item
15985             	 (x_return_status	=> l_return_status,
15986                   x_msg_count => l_msg_count,
15987                   x_msg_data => l_msg_data,
15988                   p_item_identifier_type =>p_x_line_rec.item_identifier_type,
15989                   p_inventory_item_id => p_x_line_rec.inventory_item_id,
15990                   p_ordered_item_id => p_x_line_rec.ordered_item_id,
15991                   p_sold_to_org_id => p_x_line_rec.sold_to_org_id,
15992                   x_ordered_item => p_x_line_rec.ordered_item);
15993 
15994       if l_debug_level > 0 then
15995          oe_debug_pub.add('return_status after calling Get_Ordered_Item '||l_return_status, 1);
15996       end if;
15997 
15998        --Fix for bug 3728638.
15999        IF p_x_line_rec.item_identifier_type='INT'
16000           and p_x_line_rec.ordered_item_id is NULL then
16001              p_x_line_rec.ordered_item_id:=p_x_line_rec.inventory_item_id;
16002        END IF;
16003 
16004    END IF;
16005 
16006 
16007    IF l_return_status = FND_API.G_RET_STS_ERROR THEN
16008        RAISE FND_API.G_EXC_ERROR;
16009    END IF;
16010    IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
16011        RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
16012    END IF;
16013 
16014 
16015    -------------------------------------------------------------------------
16016    -- lkxu: log a request to copy pricing attributes from top model line
16017    -- to the children lines
16018    --
16019    -- rlanka: changes made to fix bug 1730452
16020    -- rlanka: changes made to fix bug 1857538
16021    -------------------------------------------------------------------------
16022 
16023    IF (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION OR
16024        p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
16025       (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT and
16026        p_x_line_rec.line_id <> p_x_line_rec.top_model_line_id)) AND
16027        p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
16028 	  p_x_line_rec.split_from_line_id IS NULL THEN
16029 
16030 
16031 	/* Fix for bug 1730452 (May 1, 2001)
16032 	   if (model line has been copied from another order)
16033 	      Do NOT copy the pricing attributes of the model
16034 	      to its option/kit/class items.
16035 	   else
16036 	      Log a request to copy the pricing attributes of
16037 	      the top model line to its option/kit/class items.
16038 	   end if;
16039         */
16040 
16041       if l_debug_level > 0 then
16042        oe_debug_pub.add('Checking if it is a model line copied from another order');
16043       end if;
16044 
16045        begin
16046          select source_document_type_id
16047          into l_parent_document_type_id
16048          from oe_order_lines_all
16049          where line_id = p_x_line_rec.top_model_line_id;
16050 
16051 	 exception
16052 	    when NO_DATA_FOUND then NULL;
16053 
16054        end;
16055 
16056  	/* Note: Bug 1857538
16057 	  if source_document_type_id != 2 OR
16058 	     source_document_line_id = NULL, then
16059 		this line has newly been added as an option line (or)
16060 		this line has not been copied from another order
16061 		Log a request to copy pricing attributes from the top model line
16062 	  end if;
16063 
16064        */
16065 
16066       if l_debug_level > 0 then
16067        oe_debug_pub.add('parent source_document_type_id = ' || l_parent_document_type_id);
16068       end if;
16069 
16070       if ((nvl(l_parent_document_type_id,0) <> 2) OR
16071 	  (p_x_line_rec.source_document_line_id IS NULL) OR
16072 	  (p_x_line_rec.source_document_line_id = FND_API.G_MISS_NUM)) then
16073 
16074         if l_debug_level > 0 then
16075          oe_debug_pub.add('This class/kit/option line has not been copied');
16076 	 oe_debug_pub.add('from another order: So, log a delayed request');
16077 	 oe_debug_pub.add('to copy the model pricing attributes');
16078          oe_debug_pub.add('logging request for line  '||p_x_line_rec.line_id, 1);
16079         end if;
16080 
16081 	/* Fix for bug1857538
16082            - Log a delayed request to copy pricing attributes, using line_id
16083              as the entity id.  The corresponding change will be in
16084              OEXULPAB.pls
16085 	   - Idea is, copy_model_pattr for each option line.
16086         */
16087         OE_delayed_requests_Pvt.log_request(
16088 			p_entity_code 		=> OE_GLOBALS.G_ENTITY_LINE,
16089 			p_entity_id         	=> p_x_line_rec.line_id,
16090 			p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
16091 			p_requesting_entity_id   => p_x_line_rec.line_id,
16092                		p_param1                 => p_x_line_rec.line_id,
16093 	 		p_request_type           => OE_GLOBALS.G_COPY_MODEL_PATTR,
16094 	 		x_return_status          => l_return_status);
16095       end if;
16096 
16097    END IF;
16098 
16099    -- 2921731, storing and resetting the global cancel variable
16100    l_require_reason := OE_SALES_CAN_UTIL.G_REQUIRE_REASON;
16101    --1503357
16102    OE_LINE_ADJ_UTIL.Check_Canceled_PRG(p_old_line_rec => p_old_line_rec,
16103                                        p_new_line_rec => p_x_line_rec);
16104 
16105    OE_SALES_CAN_UTIL.G_REQUIRE_REASON := l_require_reason;
16106 
16107 /*sdatti*/
16108    IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_DELETE OR
16109        p_x_line_rec.ordered_quantity = 0)
16110        and OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110509' THEN
16111 
16112        IF Nvl(oe_globals.g_pricing_recursion,'N') = 'N'  THEN
16113           update_adjustment_flags(p_old_line_rec,p_x_line_rec);
16114        END IF;
16115     END IF;
16116 /*sdatti*/
16117 
16118    --Customer Acceptance
16119     IF NVL(OE_SYS_PARAMETERS.VALUE('ENABLE_FULFILLMENT_ACCEPTANCE'), 'N') = 'Y'
16120        AND p_x_line_rec.item_type_code= 'SERVICE' and p_x_line_rec.accepted_quantity is NULL THEN
16121        /*Default Parent acceptance details*/
16122          OE_ACCEPTANCE_UTIL.Default_Parent_Accept_Details(p_x_line_rec);
16123     END IF;
16124    --Customer Acceptance end
16125 
16126    ------------------------------------------------------------------------
16127    -- log a split payment request to cascade payment information from
16128    -- the parent line if the line is split
16129    ------------------------------------------------------------------------
16130 
16131    	IF  p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE
16132 	    AND p_x_line_rec.split_from_line_id is not null
16133             AND  OE_PREPAYMENT_UTIL.IS_MULTIPLE_PAYMENTS_ENABLED
16134 	   THEN
16135 
16136            BEGIN
16137              SELECT payment_type_code
16138              INTO   l_line_payment_type_code
16139              FROM   oe_payments
16140              WHERE  header_id = p_x_line_rec.header_id
16141              AND    line_id   = p_x_line_rec.split_from_line_id
16142              AND    payment_type_code IS NOT NULL
16143              AND    rownum = 1;
16144            EXCEPTION WHEN NO_DATA_FOUND THEN
16145              null;
16146            END;
16147 
16148            IF l_line_payment_type_code IS NOT NULL THEN
16149 	     oe_debug_pub.add('Log delayed request to cascade payment information for line: '||p_x_line_rec.line_id, 1);
16150 	     OE_Delayed_Requests_Pvt.Log_Request(
16151 	               p_entity_code            =>   OE_GLOBALS.G_ENTITY_LINE,
16152 	               p_entity_id             	=>   p_x_line_rec.line_id,
16153 	               p_requesting_entity_code	=>   OE_GLOBALS.G_ENTITY_LINE,
16154 	               p_requesting_entity_id  	=>   p_x_line_rec.line_id,
16155 	               p_request_type          	=>   OE_GLOBALS.G_SPLIT_PAYMENT,
16156 	               p_param1                 =>   p_x_line_rec.split_from_line_id,
16157 	               p_param2                 =>   p_x_line_rec.header_id,
16158 	               x_return_status          =>   l_return_status);
16159            END IF;
16160 	 END IF;
16161 
16162 
16163 
16164    ------------------------------------------------------------------------
16165    -- log a split hold request if the line is split
16166    ------------------------------------------------------------------------
16167 
16168    IF  p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
16169     p_x_line_rec.split_from_line_id is not null
16170    THEN
16171       if l_debug_level > 0 then
16172          oe_debug_pub.add('This is a new line after split', 1);
16173       end if;
16174          OE_Delayed_Requests_Pvt.Log_Request(
16175                p_entity_code             =>   OE_GLOBALS.G_ENTITY_LINE,
16176                p_entity_id               =>   p_x_line_rec.line_id,
16177                p_requesting_entity_code  =>   OE_GLOBALS.G_ENTITY_LINE,
16178                p_requesting_entity_id    =>   p_x_line_rec.line_id,
16179                p_request_type            =>   OE_GLOBALS.G_SPLIT_HOLD,
16180                p_param1                  =>   p_x_line_rec.split_from_line_id,
16181                x_return_status           =>   l_return_status);
16182    END IF;
16183 
16184 
16185    ------------------------------------------------------------------------
16186    -- Log the delayed request for Update Shipping if the line is deleted and
16187    -- it is interfaced with Shipping.
16188    ------------------------------------------------------------------------
16189 
16190    -- code fix for 3554622
16191    -- IF condition modified to log update_shipping delayed request when operations is UPDATE and ship set
16192    -- nulled out
16193    IF  l_debug_level > 0
16194    THEN
16195        oe_debug_pub.add('New Ship set Id :' || p_x_line_rec.ship_set_id,2);
16196        oe_debug_pub.add('Old Ship set Id :' || p_old_line_rec.ship_set_id,2);
16197        oe_debug_pub.add('Split Action:'||p_x_line_rec.split_Action_code,2);
16198    END IF;
16199 
16200    IF	p_x_line_rec.shipping_interfaced_flag = 'Y'             AND
16201      	(  (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE) OR
16202 	   (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
16203 	    p_x_line_rec.ship_set_id IS NULL                 AND
16204 	    p_old_line_rec.ship_set_id IS NOT NULL           AND
16205 	    p_x_line_rec.split_action_code = 'SPLIT'
16206 	   )
16207 	)
16208    THEN
16209    -- code fix for 3554622
16210 
16211       if l_debug_level > 0 then
16212         oe_debug_pub.ADD('Update Shipping : '|| p_x_line_rec.line_id ,1);
16213       end if;
16214 		OE_Delayed_Requests_Pvt.Log_Request(
16215 		p_entity_code               => OE_GLOBALS.G_ENTITY_LINE,
16216 		p_entity_id                 => p_x_line_rec.line_id,
16217 		p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_LINE,
16218 		p_requesting_entity_id      => p_x_line_rec.line_id,
16219 		p_request_type              => OE_GLOBALS.G_UPDATE_SHIPPING,
16220 		p_request_unique_key1       => p_x_line_rec.operation,
16221 		p_param1                    => FND_API.G_TRUE,
16222 		p_param2                    => FND_API.G_FALSE,
16223 		x_return_status             => l_return_status);
16224 
16225    END IF;
16226    --bsadri call pricing for deleted lines
16227 
16228    IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_DELETE AND
16229       p_x_line_rec.order_quantity_uom IS NOT NULL AND
16230       p_x_line_rec.order_quantity_uom <> FND_API.G_MISS_CHAR AND
16231       NVL(p_x_line_rec.ordered_quantity,0) <> 0 AND
16232       p_x_line_rec.Ordered_Quantity <> FND_API.G_MISS_NUM   THEN
16233 
16234          IF (OE_GLOBALS.G_UI_FLAG) and
16235              OE_GLOBALS.G_DEFER_PRICING='N' and
16236           (nvl(Oe_Config_Pvt.oecfg_configuration_pricing,'N')='N') THEN
16237            if l_debug_level > 0 then
16238               oe_debug_pub.add('ui mode - delete');
16239            end if;
16240            IF p_x_line_rec.booked_flag='Y' THEN  --2442012
16241               l_pricing_event := 'BATCH,ORDER,BOOK';    --7494393
16242            ELSE
16243               l_pricing_event := 'ORDER';
16244            END IF;
16245            OE_delayed_requests_Pvt.log_request(
16246              p_entity_code                => OE_GLOBALS.G_ENTITY_ALL,
16247              p_entity_id                  => p_x_line_rec.Header_Id,
16248              p_requesting_entity_code     => OE_GLOBALS.G_ENTITY_ALL,
16249              p_requesting_entity_id       => p_x_line_rec.Header_Id,
16250              p_request_unique_key1        => l_pricing_event,
16251              p_param1                     => p_x_line_rec.header_id,
16252              p_param2                     => l_pricing_event,
16253              p_request_type               => OE_GLOBALS.G_PRICE_ORDER,
16254              x_return_status              => l_return_status);
16255          ELSE
16256            if l_debug_level > 0 then
16257               oe_debug_pub.add('batch mode - delete');
16258            end if;
16259            IF p_x_line_rec.booked_flag='Y' THEN
16260               l_pricing_event := 'BATCH,BOOK';
16261            ELSE
16262               l_pricing_event := 'BATCH';
16263            END IF;
16264           --bug 3018331
16265           if p_x_line_rec.source_document_type_id = 5 and
16266            nvl(fnd_profile.value('ONT_GRP_PRICE_FOR_DSP'),'N') = 'N' then
16267            null;
16268            if l_debug_level > 0 then
16269               oe_debug_pub.add('not logging price order - delete operation ');
16270            end if;
16271           else
16272            if l_debug_level > 0 then
16273               oe_debug_pub.add('logging price order - delete operation');
16274            end if;
16275            OE_delayed_requests_Pvt.log_request(
16276               p_entity_code               => OE_GLOBALS.G_ENTITY_ALL,
16277               p_entity_id                 => p_x_line_rec.Header_Id,
16278               p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_ALL,
16279               p_requesting_entity_id      => p_x_line_rec.Header_Id,
16280               p_request_unique_key1       => l_pricing_event,
16281               p_param1                    => p_x_line_rec.header_id,
16282               p_param2                    => l_pricing_event,
16283               p_request_type              => OE_GLOBALS.G_PRICE_ORDER,
16284               x_return_status             => l_return_status);
16285           end if;
16286          END IF;
16287          --
16288   /*       IF p_x_line_rec.booked_flag='Y' THEN
16289            if l_debug_level > 0 then
16290               oe_debug_pub.add('bokked - delete');
16291            end if;
16292            OE_delayed_requests_Pvt.log_request(
16293               p_entity_code               => OE_GLOBALS.G_ENTITY_ALL,
16294               p_entity_id                 => p_x_line_rec.Header_Id,
16295               p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_ALL,
16296               p_requesting_entity_id      => p_x_line_rec.Header_Id,
16297               p_request_unique_key1       => 'BOOK',
16298               p_param1                    => p_x_line_rec.header_id,
16299               p_param2                    => 'BOOK',
16300               p_request_type              => OE_GLOBALS.G_PRICE_ORDER,
16301               x_return_status             => l_return_status);
16302          END IF;   --2442012
16303  */
16304    END IF;
16305 
16306    if l_debug_level > 0 then
16307       oe_debug_pub.ADD('Raj:Split-Inside Request' ,1);
16308    end if;
16309    IF (p_x_line_rec.operation = oe_globals.g_opr_update) and
16310        NOT (p_x_line_rec.split_action_code IS NOT NULL AND
16311 	       p_x_line_rec.split_action_code <> FND_API.G_MISS_CHAR) AND
16312        (p_x_line_rec.line_set_id IS NOT NULL AND
16313         p_x_line_rec.line_set_id <> FND_API.G_MISS_NUM) THEN
16314 
16315      -- Addded project and task to fix bug #1229811
16316         if l_debug_level > 0 then
16317            oe_debug_pub.ADD('Raj:Split-Inside Request' ,1);
16318         end if;
16319 	IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.inventory_item_id ,
16320 				p_old_line_rec.inventory_item_id) OR
16321 	 NOT OE_GLOBALS.EQUAL(p_x_line_rec.order_quantity_uom ,
16322 				p_old_line_rec.order_quantity_uom) OR
16323 	 NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_tolerance_above ,
16324 				p_old_line_rec.ship_tolerance_above) OR
16325 	 NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_tolerance_below ,
16326 				p_old_line_rec.ship_tolerance_below) OR
16327 	 NOT OE_GLOBALS.EQUAL(p_x_line_rec.project_id ,
16328 				p_old_line_rec.project_id) OR
16329 	 NOT OE_GLOBALS.EQUAL(p_x_line_rec.task_id ,
16330 				p_old_line_rec.task_id) THEN
16331 		OE_Delayed_Requests_Pvt.Log_Request(
16332 		p_entity_code				=>	OE_GLOBALS.G_ENTITY_LINE,
16333 		p_entity_id                   =>   p_x_line_rec.line_set_id,
16334 		p_requesting_entity_code  	=>	OE_GLOBALS.G_ENTITY_LINE,
16335 		p_requesting_entity_id  	     =>	p_x_line_rec.line_id,
16336 		p_request_type				=>	OE_GLOBALS.G_VALIDATE_LINE_SET,
16337 		x_return_status			=>	l_return_status);
16338      END IF;
16339 
16340    END IF;
16341 
16342 
16343    ------------------------------------------------------------------------
16344    -- Perform Cancellation if necessary
16345    ------------------------------------------------------------------------
16346 
16347    -- QUOTING change
16348    IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,p_old_line_rec.ordered_quantity)
16349       AND nvl(p_x_line_rec.transaction_phase_code,'F') = 'F'
16350    THEN
16351       IF (p_x_line_rec.operation = oe_globals.G_OPR_UPDATE AND
16352        (p_old_line_rec.ordered_quantity <> FND_API.G_MISS_NUM OR
16353         p_old_line_rec.ordered_quantity IS NOT NULL)) then
16354 
16355           OE_SALES_CAN_UTIL.Perform_Line_change(p_x_line_rec,
16356                                    p_old_line_rec,
16357                                    l_return_status);
16358           IF l_return_status = FND_API.G_RET_STS_ERROR THEN
16359              RAISE FND_API.G_EXC_ERROR;
16360              --bug 6653192
16361           ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
16362 	     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
16363           END IF;
16364        END IF;
16365    END IF;
16366 
16367 
16368    ------------------------------------------------------------------------
16369     --Check over return
16370    ------------------------------------------------------------------------
16371 /*
16372   Moving this check to check_book_required_attributes in OEXLLINB
16373 */
16374 /*
16375   IF p_x_line_rec.line_category_code = 'RETURN' AND
16376      p_x_line_rec.reference_line_id is not NULL AND
16377      p_x_line_rec.booked_flag = 'Y' AND
16378      p_x_line_rec.cancelled_flag <> 'Y'
16379   THEN
16380    if l_debug_level > 0 then
16381       oe_debug_pub.ADD('Calling IS_OVER_RETURN ',1);
16382    end if;
16383       IF (OE_LINE_UTIL.Is_Over_Return(p_x_line_rec)) THEN
16384           FND_MESSAGE.Set_Name('ONT', 'OE_RETURN_INVALID_QUANTITY');
16385           OE_MSG_PUB.Add;
16386           RAISE FND_API.G_EXC_ERROR;
16387       END IF;
16388   END IF;
16389 */
16390 
16391    ------------------------------------------------------------------------
16392 	-- If ship from org has been changed validate the Shipping Method. If
16393 	-- Shipping Method is not a valid one for the ship from org clear the
16394 	-- Shipping Method field.
16395    ------------------------------------------------------------------------
16396 
16397    IF (p_x_line_rec.line_category_code <> 'RETURN') THEN
16398 
16399      IF (NOT OE_GLOBALS.Equal(p_x_line_rec.ship_from_org_id
16400 	,p_old_line_rec.ship_from_org_id) OR
16401 	NOT OE_GLOBALS.Equal(p_x_line_rec.shipping_method_code,
16402 	    p_old_line_rec.shipping_method_code))  THEN
16403 	    IF (p_x_line_rec.shipping_method_code IS NOT NULL AND
16404 		  p_x_line_rec.ship_from_org_id IS NOT NULL) THEN
16405 
16406                       IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110509' THEN
16407                          SELECT count(*)
16408                          INTO   l_count
16409                          FROM   wsh_carrier_services wsh,
16410                                 wsh_org_carrier_services wsh_org
16411                          WHERE  wsh_org.organization_id      = p_x_line_rec.ship_from_org_id
16412                            AND  wsh.carrier_service_id       = wsh_org.carrier_service_id
16413                            AND  wsh.ship_method_code         = p_x_line_rec.shipping_method_code
16414                            AND  wsh_org.enabled_flag         = 'Y';
16415                       ELSE
16416 
16417                          SELECT count(*)
16418                 	   INTO	l_count
16419                            FROM    wsh_carrier_ship_methods
16420                           WHERE   ship_method_code = p_x_line_rec.shipping_method_code
16421    	                    AND   organization_id = p_x_line_rec.ship_from_org_id;
16422                      END IF;
16423 	   	--  Valid Shipping Method Code.
16424 
16425                  if l_debug_level > 0 then
16426                     oe_debug_pub.add('Split By:'||p_x_line_rec.split_by);
16427                     oe_debug_pub.add('Split Action:'||p_x_line_rec.split_action_code);
16428                  end if;
16429 	   	IF	l_count  = 0 THEN
16430 
16431                   IF (nvl(p_x_line_rec.split_by,'X') <> 'SYSTEM' and
16432                                   NVL(p_x_line_rec.split_action_code,'X') <> 'SPLIT') THEN
16433 
16434                     --bug 4190357
16435                     select count(*) into v_count from oe_price_adjustments
16436                     where line_id = p_x_line_rec.line_id
16437                       and substitution_attribute = 'QUALIFIER_ATTRIBUTE11'
16438                       and list_line_type_code = 'TSN'
16439                       and modified_to = p_x_line_rec.shipping_method_code;
16440                     IF v_count > 0 THEN
16441                        IF l_debug_level > 0 THEN
16442                           oe_debug_pub.add('Deleting the tsn adjustments');
16443                        END IF;
16444                        DELETE FROM OE_PRICE_ADJUSTMENTS
16445                        WHERE LINE_ID = p_x_line_rec.line_id
16446                          AND LIST_LINE_TYPE_CODE = 'TSN'
16447                          AND SUBSTITUTION_ATTRIBUTE = 'QUALIFIER_ATTRIBUTE11'
16448                          AND MODIFIED_TO = p_x_line_rec.shipping_method_code
16449                        RETURNING MODIFIED_FROM into l_modified_from;
16450                     END IF;
16451                     --bug 4190357
16452 
16453 
16454                     if l_debug_level > 0 then
16455 	              oe_debug_pub.add('Calling process_order to clear the Shipping Method',2);
16456 	              oe_debug_pub.add('Value of shipping_method_code :'||p_x_line_rec.shipping_method_code,2);
16457                     end if;
16458                             --bug 4190357
16459                             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;
16460                             --bug 4190357
16461                             If v_count = 0 Then
16462                      	       Clear_Shipping_Method
16463 			  	 ( p_x_line_rec	=> p_x_line_rec);
16464                             Else
16465                                p_x_line_rec.shipping_method_code := l_modified_from;
16466                             End If;
16467                        ELSE
16468                             if l_debug_level > 0 then
16469                                oe_debug_pub.add('SYSTEM SPLIT Donot clear the Shipping Method',2);
16470                             end if;
16471                        END IF;
16472 
16473                OE_MSG_PUB.Update_Msg_Context(p_attribute_code => 'SHIPPING_METHOD');
16474 		     fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
16475                     --bug 4190357 added l_meaning to the token
16476 			FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
16477                         OE_Order_Util.Get_Attribute_Name('shipping_method_code') || ' ' || l_meaning);
16478 			OE_MSG_PUB.Add;
16479 			OE_MSG_PUB.Update_Msg_Context(p_attribute_code => null);
16480 
16481                if l_debug_level > 0 then
16482    	          oe_debug_pub.add('Value of freight_carrier after the call :'
16483 	         		||p_x_line_rec.shipping_method_code,2);
16484                end if;
16485 
16486 		END IF;
16487 
16488 	END IF;
16489 	END IF;
16490 
16491      -- Also redo commitment if any the following attribute has changed.
16492 	-- and Commitment ID is not null
16493      -- QUOTING change
16494      IF (p_x_line_rec.commitment_id IS NOT NULL)
16495         AND nvl(p_x_line_rec.transaction_phase_code,'F') = 'F'
16496      THEN
16497          IF
16498        ((
16499       OE_Quote_Util.G_COMPLETE_NEG = 'Y'
16500               AND
16501       NOT OE_GLOBALS.EQUAL(p_x_line_rec.transaction_phase_code
16502                       ,p_old_line_rec.transaction_phase_code)
16503               ) OR
16504           NOT OE_GLOBALS.Equal(p_x_line_rec.inventory_item_id,
16505                                 p_old_line_rec.inventory_item_id) OR
16506           NOT OE_GLOBALS.Equal(p_x_line_rec.sold_to_org_id,
16507                                 p_old_line_rec.sold_to_org_id) OR
16508           NOT OE_GLOBALS.Equal(p_x_line_rec.unit_selling_price,
16509                                 p_old_line_rec.unit_selling_price) OR
16510           NOT OE_GLOBALS.Equal(p_x_line_rec.commitment_id,
16511                                 p_old_line_rec.commitment_id) OR
16512           NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,p_old_line_rec.ordered_quantity)) And
16513           --fix bug 1669076
16514           NOT OE_GLOBALS.Equal(p_x_line_rec.commitment_id,
16515                                 p_old_line_rec.commitment_id)
16516           THEN
16517 
16518            IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,p_old_line_rec.ordered_quantity)
16519               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_
16520           Then
16521 
16522           If p_x_line_rec.ordered_quantity IS NULL OR
16523              p_x_line_rec.ordered_quantity = FND_API.G_MISS_NUM Then
16524              l_new_qty := 0;
16525           Else
16526              l_new_qty := p_x_line_rec.ordered_quantity;
16527           End If;
16528 
16529           If p_old_line_rec.ordered_quantity IS NULL OR
16530              p_old_line_rec.ordered_quantity = FND_API.G_MISS_NUM Then
16531              l_old_qty := 0;
16532           Else
16533              l_old_qty:= p_old_line_rec.ordered_quantity;
16534           End If;
16535 
16536           If p_x_line_rec.unit_selling_price Is NULL or
16537              p_x_line_rec.unit_selling_price = FND_API.G_MISS_NUM Then
16538              l_new_unit_selling_price := 0;
16539           Else
16540              l_new_unit_selling_price := p_x_line_rec.unit_selling_price;
16541           End If;
16542 
16543           If p_old_line_rec.unit_selling_price is NULL or
16544              p_old_line_rec.unit_selling_price = FND_API.G_MISS_NUM Then
16545 
16546              l_old_unit_selling_price :=0;
16547           Else
16548              l_old_unit_selling_price :=p_old_line_rec.unit_selling_price;
16549           End If;
16550 
16551 
16552          If NOT OE_GLOBALS.Equal(p_x_line_rec.commitment_id,
16553                                 p_old_line_rec.commitment_id) Then
16554            /* commtiment can change event quantity can change
16555               We always pass in the new, not the delta when commitment changes */
16556 
16557             l_delta_extended_amount := p_x_line_rec.ordered_quantity *
16558                                        p_x_line_rec.unit_selling_price;
16559 
16560          Else
16561           /* Only quantity or unit selling price change, therefore delta */
16562           l_new_extended_amount := l_new_unit_selling_price * l_new_qty;
16563           l_old_extended_amount := l_old_unit_selling_price * l_old_qty;
16564           l_delta_extended_amount := l_new_extended_amount - l_old_extended_amount;
16565 
16566          End If;
16567 
16568 
16569 
16570           Else
16571              /* commtiment can change but quantity will not change
16572                 We always pass in the new, not the delta when commitment changes*/
16573             l_delta_extended_amount := p_x_line_rec.ordered_quantity *
16574                                        p_x_line_rec.unit_selling_price;
16575           End If;
16576 
16577 
16578       -- commented out the IF condition for bug 1905467.
16579       -- IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
16580 
16581       -- retain the original commitment functionality
16582       IF Not Oe_Commitment_pvt.do_commitment_sequencing THEN
16583           if l_debug_level > 0 then
16584              oe_debug_pub.add('entering evaluate commitment!',1);
16585           end if;
16586           oe_commitment_pvt.evaluate_commitment(
16587                             p_commitment_id      => p_x_line_rec.commitment_id,
16588  		 	    p_header_id          => p_x_line_rec.header_id,
16589                             p_unit_selling_price => l_delta_extended_amount,
16590                             x_return_status      => l_return_status,
16591                             x_msg_count          => l_msg_count,
16592                             x_msg_data           => l_msg_data);
16593           IF l_return_status = FND_API.G_RET_STS_ERROR THEN
16594               if l_debug_level > 0 then
16595                  oe_debug_pub.add('Value of Commitment_Id B4 Clear_Commitment_Id:'
16596                                  ||p_x_line_rec.commitment_id,1);
16597               end if;
16598               Clear_Commitment_Id
16599                     ( p_x_line_rec => p_x_line_rec);
16600               if l_debug_level > 0 then
16601                  oe_debug_pub.add('Value of Commitment_Id after the call :'
16602                     ||p_x_line_rec.commitment_id,1);
16603               end if;
16604               Raise FND_API.G_EXC_ERROR;
16605 
16606           ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
16607               RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
16608           END IF;
16609        END IF;
16610        -- END IF;
16611 
16612 
16613        END IF;
16614      END IF; --(p_x_line_rec.commitment_id IS NOT NULL)
16615      --------------------------------
16616 
16617   END IF; -- IF (p_x_line_rec.line_category_code <> 'RETURN')
16618 
16619   -- QUOTING change - log request only for fulfillment phase
16620   --4504362 : Branch scheduling checks removed
16621 	-- If this is a split line then put this in fulfilment set if any.
16622 
16623 	IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
16624 	    p_x_line_rec.split_from_line_id IS NOT NULL ) THEN
16625 	    oe_split_util.Add_To_Fulfillment_Set(p_line_rec => p_x_line_rec);
16626 	END IF;
16627 
16628     ------------------------------------------------------------------------
16629      -- If line is being created by a split operation, then log request
16630      -- to copy attachments else log request to apply automatic attachments
16631     ------------------------------------------------------------------------
16632 
16633      IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE  THEN
16634 
16635         IF NVL(p_x_line_rec.split_from_line_id,FND_API.G_MISS_NUM)
16636             = FND_API.G_MISS_NUM
16637         THEN
16638 
16639             -- Performance Improvement Bug 1929163:
16640             -- Log request to apply automatic attachments based on profile
16641             IF G_APPLY_AUTOMATIC_ATCHMT = 'Y' THEN
16642                if l_debug_level > 0 then
16643                   oe_debug_pub.add('log request to apply atchmt',1);
16644                end if;
16645                OE_delayed_requests_Pvt.Log_Request
16646                     (p_entity_code       => OE_GLOBALS.G_ENTITY_LINE,
16647                      p_entity_id         => p_x_line_rec.line_id,
16648                      p_request_type      => OE_GLOBALS.G_APPLY_AUTOMATIC_ATCHMT,
16649                      p_requesting_entity_code     => OE_GLOBALS.G_ENTITY_LINE,
16650                      p_requesting_entity_id       => p_x_line_rec.line_id,
16651                      x_return_status              => l_return_status
16652                      );
16653             END IF;
16654 
16655         ELSE
16656 
16657             IF p_x_line_rec.split_by = 'SYSTEM' THEN
16658                if l_debug_level > 0 then
16659                   oe_debug_pub.add('log request to copy all atchmt',1);
16660                end if;
16661                OE_delayed_requests_Pvt.Log_Request
16662                     (p_entity_code       => OE_GLOBALS.G_ENTITY_LINE,
16663                      p_entity_id         => p_x_line_rec.line_id,
16664                      p_param1            => p_x_line_rec.split_from_line_id,
16665                      p_param2            => 'N', -- copy ALL attachments
16666                      p_request_type      => OE_GLOBALS.G_COPY_ATCHMT,
16667                      p_requesting_entity_code     => OE_GLOBALS.G_ENTITY_LINE,
16668                      p_requesting_entity_id       => p_x_line_rec.line_id,
16669                      x_return_status              => l_return_status
16670                      );
16671 
16672             ELSE
16673 
16674                if l_debug_level > 0 then
16675                   oe_debug_pub.add('log request to copy manual atchmt',1);
16676                end if;
16677                OE_delayed_requests_Pvt.Log_Request
16678                     (p_entity_code       => OE_GLOBALS.G_ENTITY_LINE,
16679                      p_entity_id         => p_x_line_rec.line_id,
16680                      p_param1            => p_x_line_rec.split_from_line_id,
16681                      p_param2            => 'Y', -- copy only manual attachments
16682                      p_request_type      => OE_GLOBALS.G_COPY_ATCHMT,
16683                      p_requesting_entity_code     => OE_GLOBALS.G_ENTITY_LINE,
16684                      p_requesting_entity_id       => p_x_line_rec.line_id,
16685                      x_return_status              => l_return_status
16686                      );
16687 
16688             END IF; --  if SYSTEM split else
16689 
16690         END IF; -- if split else
16691     ELSE  -- 5893276
16692        IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
16693             G_APPLY_AUTOMATIC_ATCHMT = 'Y' THEN
16694                if l_debug_level > 0 then
16695                   oe_debug_pub.add('log request to apply atchmt for UPDATE ',1);
16696                end if;
16697 
16698 --6896311
16699             IF NOT OE_GLOBALS.Equal(p_x_line_rec.INVOICE_TO_ORG_ID
16700                                     ,p_old_line_rec.INVOICE_TO_ORG_ID)
16701             OR NOT OE_GLOBALS.Equal(p_x_line_rec.SOLD_TO_ORG_ID
16702                                     ,p_old_line_rec.SOLD_TO_ORG_ID)
16703             OR NOT OE_GLOBALS.Equal(p_x_line_rec.CUST_PO_NUMBER
16704                                     ,p_old_line_rec.CUST_PO_NUMBER)
16705             OR NOT OE_GLOBALS.Equal(p_x_line_rec.INVENTORY_ITEM_ID
16706                                     ,p_old_line_rec.INVENTORY_ITEM_ID)
16707             OR NOT OE_GLOBALS.Equal(p_x_line_rec.LINE_CATEGORY_CODE
16708                                     ,p_old_line_rec.LINE_CATEGORY_CODE)
16709             OR NOT OE_GLOBALS.Equal(p_x_line_rec.LINE_TYPE_ID
16710                                     ,p_old_line_rec.LINE_TYPE_ID)
16711             OR NOT OE_GLOBALS.Equal(p_x_line_rec.SHIP_TO_ORG_ID
16712                                     ,p_old_line_rec.SHIP_TO_ORG_ID)
16713             THEN
16714 
16715                 l_attr_attach_change := TRUE;
16716 
16717             END IF;
16718 --6896311
16719              IF l_attr_attach_change THEN  --6896311
16720                OE_delayed_requests_Pvt.Log_Request
16721                     (p_entity_code       => OE_GLOBALS.G_ENTITY_LINE,
16722                      p_entity_id         => p_x_line_rec.line_id,
16723                      p_request_type      => OE_GLOBALS.G_APPLY_AUTOMATIC_ATCHMT,
16724                      p_requesting_entity_code     => OE_GLOBALS.G_ENTITY_LINE,
16725                      p_requesting_entity_id       => p_x_line_rec.line_id,
16726                      x_return_status              => l_return_status
16727                      );
16728              END IF;  --6896311
16729 
16730          END IF;
16731 
16732      END IF; -- if CREATE operation log request for attachments
16733 
16734 
16735    ------------------------------------------------------------------------
16736      -- Fix for bug1167537
16737      -- Clear the line record cached by defaulting APIs so that the
16738      -- default values on the child entities of line record are
16739      -- obtained from the updated line record
16740    ------------------------------------------------------------------------
16741 
16742      IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
16743           ONT_LINE_Def_Util.Clear_LINE_Cache;
16744      END IF;
16745 
16746 
16747    ------------------------------------------------------------------------
16748      -- if there is an update operation on model line,
16749      -- clear the cached model line record if any.
16750    ------------------------------------------------------------------------
16751 
16752      IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
16753         p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL THEN
16754         if l_debug_level > 0 then
16755            oe_debug_pub.add('clear the cached top model record', 1);
16756            oe_debug_pub.add('model line: '|| p_x_line_rec.line_id, 1);
16757         end if;
16758         OE_Order_Cache.Clear_Top_Model_Line(p_key => p_x_line_rec.line_id);
16759      END IF;
16760 
16761     -- Changes for Late Demand Penalty Factor
16762       if l_debug_level > 0 then
16763          oe_debug_pub.add('Late Demand Penalty Factor',1);
16764       end if;
16765      IF(p_x_line_rec.late_demand_penalty_factor IS NOT NULL AND
16766         p_x_line_rec.late_demand_penalty_factor  <>  FND_API.G_MISS_NUM AND
16767             p_x_line_rec.late_demand_penalty_factor < 0) THEN
16768 
16769                 FND_MESSAGE.SET_NAME('ONT','ONT_SCH_DEMAND_FACTOR_ZERO');
16770                 OE_MSG_PUB.Add;
16771         RAISE FND_API.G_EXC_ERROR;
16772      END IF;
16773    ------------------------------------------------------------------------
16774    -- Call Scheduling to perform any scheduling on the line, if needed
16775    ------------------------------------------------------------------------
16776 
16777     -- Added code in delete_dependency for delete operation.
16778     --4504362 : branch scheduling checks removed
16779       IF OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING = 'Y' THEN
16780         -- After the restructure post write code will call
16781         -- scheduling and scheduling may or may not require on the
16782         -- line. However, we need to set the resource flag.
16783 
16784         if l_debug_level > 0 then
16785            oe_debug_pub.add('Setting the resource ',1);
16786         end if;
16787         IF NOT OE_GLOBALS.Equal(p_old_line_rec.ship_from_org_id,
16788                               p_x_line_rec.ship_from_org_id)
16789         THEN
16790          IF p_x_line_rec.ship_from_org_id is not null
16791          THEN
16792              if l_debug_level > 0 then
16793                 oe_debug_pub.add('Setting re_source_flag to N',1);
16794              end if;
16795              p_x_line_rec.re_source_flag := 'N';
16796          ELSE
16797              if l_debug_level > 0 then
16798                 oe_debug_pub.add('1.Setting re_source_flag to null',1);
16799              end if;
16800              p_x_line_rec.re_source_flag := '';
16801          END IF;
16802         ELSIF p_x_line_rec.ship_from_org_id is null
16803         THEN
16804           if l_debug_level > 0 then
16805              oe_debug_pub.add('2.Setting re_source_flag to null',1);
16806           end if;
16807           p_x_line_rec.re_source_flag := '';
16808         END IF;
16809 
16810         -- If inventory item is changed on a unscheduled substituted
16811         -- item, clear the original item information.
16812         -- Scheduling code will take care of clearing original
16813         -- inventory information on scheduled line since if we
16814         -- place the clearing logic here for a scheduled line, some
16815         -- of the delayed request may clear the original item information
16816         -- after substitution.
16817 
16818         IF NOT OE_GLOBALS.Equal(p_x_line_rec.Inventory_Item_Id,
16819                                 p_old_line_rec.Inventory_Item_Id)
16820         AND p_x_line_rec.schedule_status_code is null
16821         AND p_x_line_rec.Original_Inventory_Item_Id IS NOT NULL
16822         AND p_x_line_rec.item_relationship_type IS NULL
16823         THEN
16824 
16825            if l_debug_level > 0 then
16826               oe_debug_pub.add('PWP: clearing out original item fields');
16827            end if;
16828            p_x_line_rec.Original_Inventory_Item_Id    := Null;
16829            p_x_line_rec.Original_item_identifier_Type := Null;
16830            p_x_line_rec.Original_ordered_item_id      := Null;
16831            p_x_line_rec.Original_ordered_item         := Null;
16832 
16833 
16834         END IF;
16835       END IF; -- perform scheduling.
16836 
16837 
16838     -- following 3 calls are mainly related to configuration lines.
16839     -- do not move Log_CTO_Requests above scheduling
16840     -- 4504362 :branch scheduling checks removed
16841 
16842     -- bug fix : 2307423, do not log if remnant.
16843     IF p_x_line_rec.top_model_line_id is NOT NULL THEN
16844 
16845       Log_Config_Requests( p_x_line_rec    => p_x_line_rec
16846                           ,p_old_line_rec  => p_old_line_rec
16847                           ,x_return_status => l_return_status);
16848 
16849       IF nvl(p_x_line_rec.model_remnant_flag, 'N') = 'N' THEN
16850         Log_Cascade_Requests( p_x_line_rec    => p_x_line_rec
16851                              ,p_old_line_rec  => p_old_line_rec
16852                              ,x_return_status => l_return_status);
16853       END IF;
16854     END IF;
16855 
16856 
16857 /* 7576948: Commenting for IR ISO CMS Project
16858 
16859   if l_debug_level > 0 then
16860      oe_debug_pub.add('Before checking for system split on int ord');
16861   end if;
16862   IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE) AND
16863 	  (p_x_line_rec.split_by = 'SYSTEM') AND
16864 	  (p_x_line_rec.order_source_id = 10) THEN
16865             FND_MESSAGE.SET_NAME('ONT','OE_CHG_CORR_REQ');
16866             -- { start fix for 2648277
16867 	    FND_MESSAGE.SET_TOKEN('CHG_ATTR',
16868                OE_Order_Util.Get_Attribute_Name('ordered_quantity'));
16869             -- end fix for 2648277}
16870 	 OE_MSG_PUB.ADD;
16871     END IF;
16872 
16873 */ -- Commented for IR ISO CMS project
16874 
16875 -- bug fix 3350185:
16876 -- Audit Trail/Versioning moved to separate procedure below
16877    Version_Audit_Process( p_x_line_rec => p_x_line_rec,
16878                           p_old_line_rec => p_old_line_rec,
16879                           p_process_step => 2 );
16880 
16881 -- Log Drop Ship CMS Delayed Request for Externally sources
16882 -- lines. Do not log for System Split Lines.
16883 
16884 IF p_x_line_rec.source_type_code  = 'EXTERNAL' AND
16885    p_x_line_rec.booked_flag       = 'Y'  AND
16886     NOT (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
16887         p_x_line_rec.split_by = 'SYSTEM' AND
16888           NVL(p_x_line_rec.split_action_code,'X') = 'SPLIT') AND
16889    (PO_CODE_RELEASE_GRP.Current_Release >=
16890          PO_CODE_RELEASE_GRP.PRC_11i_Family_Pack_J) AND
16891              OE_CODE_CONTROL.Code_Release_Level  >= '110510' THEN
16892 
16893        Log_Dropship_CMS_Request
16894                       (p_x_line_rec    =>   p_x_line_rec
16895                       ,p_old_line_rec  =>   p_old_line_rec
16896                       );
16897 END IF;
16898 
16899 -- If the ordered quantity on a line becoming Zero thatcan be a cancellation
16900 -- Or mere decrement of quantity the line is taken out of ship sets and
16901 -- ariival sets
16902 
16903                 IF p_x_line_rec.ordered_quantity = 0 THEN
16904                         p_x_line_rec.ship_set_id := null;
16905                         p_x_line_rec.arrival_set_id := null;
16906                 END IF;
16907     -- Pack J
16908     -- Promise Date setup with Request date
16909     -- 'FR' - With First Request date
16910     -- 'R'  -- For all change in Request date
16911     IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
16912        l_promise_date_flag := OE_SYS_PARAMETERS.value('PROMISE_DATE_FLAG');
16913 
16914        IF l_promise_date_flag = 'FR'
16915         AND (p_old_line_rec.request_date = FND_API.G_MISS_DATE
16916            OR p_old_line_rec.request_date IS NULL) THEN
16917          p_x_line_rec.promise_date := p_x_line_rec.request_date;
16918        ELSIF l_promise_date_flag = 'R' THEN
16919           p_x_line_rec.promise_date := p_x_line_rec.request_date;
16920        END IF;
16921     END IF;
16922 
16923 
16924    if l_debug_level > 0 then
16925       OE_DEBUG_PUB.add('Exiting from Lines Pre-Write process',1);
16926    end if;
16927 EXCEPTION
16928     WHEN FND_API.G_EXC_ERROR THEN
16929         RAISE;
16930     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
16931         RAISE;
16932     WHEN OTHERS THEN
16933         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
16934         THEN
16935             oe_msg_pub.Add_Exc_Msg
16936             (   G_PKG_NAME
16937           ,   'Pre_Write_Process'
16938             );
16939         END IF;
16940         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
16941 END Pre_Write_Process;
16942 
16943 PROCEDURE Version_Audit_Process
16944 (   p_x_line_rec                    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
16945 ,   p_old_line_rec                  IN  OE_Order_PUB.Line_Rec_Type :=
16946                                         OE_Order_PUB.G_MISS_LINE_REC
16947 ,   p_process_step                  IN NUMBER := 3
16948 )
16949 IS
16950 
16951 l_ind                       NUMBER;
16952 l_code_level                varchar2(6) := OE_CODE_CONTROL.GET_CODE_RELEASE_LEVEL;
16953 l_audit_trail_enabled       VARCHAR2(1) := OE_SYS_PARAMETERS.VALUE('AUDIT_TRAIL_ENABLE_FLAG');
16954 
16955 l_return_status                VARCHAR2(30);
16956 l_reason_code VARCHAR2(30);
16957 l_reason_comments VARCHAR2(2000);
16958 --
16959 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
16960 --
16961 BEGIN
16962 /*
16963 The p_process_step value passed in determines the processes run. The first time it is called
16964 from Pre_Write_Process, this procedure first performs process 1. Later in Pre_Write it is
16965 called with process 2. From Pricing we are calling with process 3 to perform both actions.
16966 */
16967 
16968 IF p_process_step IN (1,3) THEN
16969 
16970 /* Start AuditTrail */
16971 
16972 IF l_code_level >= '110508' and nvl(l_audit_trail_enabled,'D') <> 'D' THEN
16973    IF (p_x_line_rec.operation  = OE_GLOBALS.G_OPR_UPDATE) then
16974        IF OE_GLOBALS.OE_AUDIT_HISTORY_TBL.count > 0 THEN
16975           FOR l_ind in 1..OE_GLOBALS.oe_audit_history_tbl.last LOOP
16976               IF OE_GLOBALS.OE_AUDIT_HISTORY_TBL.exists(l_ind) THEN
16977                  IF OE_GLOBALS.oe_audit_history_tbl(l_ind).LINE_ID = p_x_line_rec.line_id AND
16978                     OE_GLOBALS.oe_audit_history_tbl(l_ind).HISTORY_TYPE = 'R' THEN   -- flag 'R' denotes requires reason
16979                     if l_debug_level > 0 then
16980                        OE_DEBUG_PUB.add('OEXULINB- Audit Reason Required', 5);
16981                     end if;
16982                     IF (p_x_line_rec.change_reason IS NULL OR
16983                         p_x_line_rec.change_reason = FND_API.G_MISS_CHAR OR
16984                         NOT OE_Validate.Change_Reason_Code(p_x_line_rec.change_reason)) THEN
16985 
16986                        IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
16987                          IF OE_Versioning_Util.Captured_Reason IS NULL THEN
16988                             OE_Versioning_Util.Get_Reason_Info(l_reason_code, l_reason_comments);
16989                             IF l_reason_code IS NULL THEN
16990                              -- bug 3636884, defaulting reason from group API
16991                              IF OE_GLOBALS.G_DEFAULT_REASON THEN
16992                                if l_debug_level > 0 then
16993                                  oe_debug_pub.add('Defaulting Audit Reason for Order Line', 1);
16994                                end if;
16995                                p_x_line_rec.change_reason := 'SYSTEM';
16996                              ELSE
16997                                OE_DEBUG_PUB.add('Reason code for change is missing or invalid', 1);
16998                                fnd_message.set_name('ONT','OE_AUDIT_REASON_RQD');
16999                                fnd_message.set_token('OBJECT','ORDER LINE');
17000                                oe_msg_pub.add;
17001                                RAISE FND_API.G_EXC_ERROR;
17002                              END IF;
17003                             END IF;
17004                          END IF;
17005                        ELSE
17006                             if l_debug_level > 0 then
17007                                OE_DEBUG_PUB.add('Reason code for change is missing or invalid', 1);
17008                             end if;
17009                             fnd_message.set_name('ONT','OE_AUDIT_REASON_RQD');
17010                             fnd_message.set_token('OBJECT','ORDER LINE');
17011                             oe_msg_pub.add;
17012                             raise FND_API.G_EXC_ERROR;
17013                        END IF;
17014                     END IF;
17015                  END IF;
17016              END IF;
17017           END LOOP;
17018        END IF;
17019   END IF;
17020 END IF;
17021 
17022 /* End Audit Trail */
17023 
17024 END IF;
17025 
17026 IF p_process_step IN (2,3) THEN
17027 
17028   IF (p_x_line_rec.operation=OE_GLOBALS.G_OPR_UPDATE) AND
17029      (p_x_line_rec.split_action_code = 'SPLIT') THEN
17030 
17031        --11.5.10 Versioning/Audit Trail updates
17032      IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
17033           OE_Versioning_Util.Capture_Audit_Info(p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
17034                                            p_entity_id => p_x_line_rec.line_id,
17035                                            p_hist_type_code =>  'SPLIT');
17036            --log delayed request
17037              OE_Delayed_Requests_Pvt.Log_Request(p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
17038                                    p_entity_id => p_x_line_rec.header_id,
17039                                    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
17040                                    p_requesting_entity_id => p_x_line_rec.line_id,
17041                                    p_request_type => OE_GLOBALS.G_VERSION_AUDIT,
17042                                    x_return_status => l_return_status);
17043           OE_GLOBALS.G_AUDIT_HISTORY_RQD_FLAG := 'N';
17044      ELSE
17045        OE_CHG_ORDER_PVT.RecordLineHist
17046           (p_line_id => p_x_line_rec.line_id,
17047            p_line_rec => null,
17048            p_hist_type_code => 'SPLIT',
17049            p_reason_code => NULL,
17050            p_comments => NULL,
17051            p_wf_activity_code => null,
17052            p_wf_result_code => null,
17053            x_return_status => l_return_status);
17054 
17055       if l_debug_level > 0 then
17056           OE_DEBUG_PUB.add('Return status after inserting split history : '||l_return_status,5);
17057       end if;
17058 
17059        IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
17060           if l_debug_level > 0 then
17061              oe_debug_pub.add('Error while inserting Line split History ',1);
17062           end if;
17063           IF l_return_status = FND_API.G_RET_STS_ERROR then
17064              raise FND_API.G_EXC_ERROR;
17065           ELSE
17066              raise FND_API.G_EXC_UNEXPECTED_ERROR;
17067           END IF;
17068        END IF;
17069      END IF;
17070 
17071   END IF;
17072 
17073        --11.5.10 Versioning/Audit Trail updates
17074      IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510'
17075       AND   OE_GLOBALS.G_ROLL_VERSION <> 'N'  THEN
17076        IF OE_GLOBALS.G_REASON_CODE IS NULL AND
17077        OE_GLOBALS.G_CAPTURED_REASON IN ('V','A') THEN
17078           IF p_x_line_rec.change_reason <> FND_API.G_MISS_CHAR THEN
17079               OE_GLOBALS.G_REASON_CODE := p_x_line_rec.change_reason;
17080               OE_GLOBALS.G_REASON_COMMENTS := p_x_line_rec.change_comments;
17081               OE_GLOBALS.G_CAPTURED_REASON := 'Y';
17082           ELSE
17083              if l_debug_level > 0 then
17084                 OE_DEBUG_PUB.add('Reason code for versioning is missing or invalid', 1);
17085              end if;
17086             -- if OE_GLOBALS.G_UI_FLAG then --bug5716140
17087                IF  OE_GLOBALS.G_UI_FLAG
17088                        OR ( p_x_line_rec.split_action_code = 'SPLIT'
17089                         AND nvl(p_x_line_rec.split_by,'SYSTEM') = 'USER' ) THEN  --bug5716140
17090                 raise FND_API.G_EXC_ERROR;
17091              end if;
17092           END IF;
17093        END IF;
17094 
17095        --log delayed request
17096        if l_debug_level > 0 then
17097           oe_debug_pub.add('log versioning request',1);
17098        end if;
17099           OE_Delayed_Requests_Pvt.Log_Request(p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
17100                                    p_entity_id => p_x_line_rec.header_id,
17101                                    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
17102                                    p_requesting_entity_id => p_x_line_rec.line_id,
17103                                    p_request_type => OE_GLOBALS.G_VERSION_AUDIT,
17104                                    x_return_status => l_return_status);
17105      END IF;
17106 
17107    /* Start Audit Trail - Insert Lines history */
17108 
17109 IF l_code_level >= '110508' and nvl(l_audit_trail_enabled,'D') <> 'D' THEN
17110    IF OE_GLOBALS.OE_AUDIT_HISTORY_TBL.count > 0 THEN
17111       FOR l_ind in 1..OE_GLOBALS.oe_audit_history_tbl.last LOOP
17112           IF OE_GLOBALS.OE_AUDIT_HISTORY_TBL.exists(l_ind) THEN
17113              IF OE_GLOBALS.oe_audit_history_tbl(l_ind).line_id = p_x_line_rec.line_id THEN
17114                 if l_debug_level > 0 then
17115                    OE_DEBUG_PUB.add('OEXULINB:calling oe_order_chg_pvt.recordlinehist', 5);
17116                 end if;
17117 
17118                 --11.5.10 Versioning/Audit Trail updates
17119               IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
17120                 OE_Versioning_Util.Capture_Audit_Info(p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
17121                                            p_entity_id => p_x_line_rec.line_id,
17122                                            p_hist_type_code =>  'UPDATE');
17123                  --log delayed request
17124                    OE_Delayed_Requests_Pvt.Log_Request(p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
17125                                    p_entity_id => p_x_line_rec.header_id,
17126                                    p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
17127                                    p_requesting_entity_id => p_x_line_rec.line_id,
17128                                    p_request_type => OE_GLOBALS.G_VERSION_AUDIT,
17129                                    x_return_status => l_return_status);
17130                 OE_GLOBALS.G_AUDIT_HISTORY_RQD_FLAG := 'N';
17131               ELSE
17132                 OE_CHG_ORDER_PVT.RecordLineHist
17133                   (p_line_id => p_x_line_rec.line_id,
17134                    p_line_rec => null,
17135                    p_hist_type_code => 'UPDATE',
17136                    p_reason_code => p_x_line_rec.change_reason,
17137                    p_comments => p_x_line_rec.change_comments,
17138                    p_wf_activity_code => null,
17139                    p_wf_result_code => null,
17140                    x_return_status => l_return_status);
17141                 if l_debug_level > 0 then
17142                    OE_DEBUG_PUB.add('IN OEXULINB:After'||l_return_status,5);
17143                 end if;
17144 
17145                 IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
17146                    if l_debug_level > 0 then
17147                       oe_debug_pub.add('Inserting Line Audit History error',1);
17148                    end if;
17149                    IF l_return_status = FND_API.G_RET_STS_ERROR then
17150                       raise FND_API.G_EXC_ERROR;
17151                    ELSE
17152                    raise FND_API.G_EXC_UNEXPECTED_ERROR;
17153                    END IF;
17154                 END IF;
17155 
17156               END IF;
17157                 -- now the history is inserted successfully, remove the entry from pl/sql table
17158                 if l_debug_level > 0 then
17159                    oe_debug_pub.add('Deleting the history entry for line ID : '||OE_GLOBALS.oe_audit_history_tbl(l_ind).line_id,1);
17160                 end if;
17161                 OE_GLOBALS.oe_audit_history_tbl.delete(l_ind);
17162              END IF;
17163           END IF;
17164 
17165       END LOOP;
17166    END IF;
17167 END IF;
17168 /* End Audit Trail */
17169 
17170 END IF; --p_process_step in (2,3)
17171 
17172 END Version_Audit_Process;
17173 
17174 
17175 /*----------------------------------------------------------
17176 PROCEDURE Cascade_Line_Number
17177 
17178 -- Fixed bug 1914885: passing p_header_id and using it in the condition
17179 -- to select lines where the line number update is to be cascaded.
17180 -- This will result in using the header_id index instead of
17181 -- full table scans on lines tables.
17182 -----------------------------------------------------------*/
17183 
17184 PROCEDURE Cascade_Line_Number( p_header_id IN NUMBER,
17185                                             p_line_id IN NUMBER,
17186 					    p_line_set_id IN NUMBER,
17187 					    p_item_type_code IN VARCHAR2,
17188 					    p_line_number IN NUMBER)
17189 IS
17190 
17191 l_line_id NUMBER;
17192 l_header_id NUMBER;
17193 l_line_number NUMBER;
17194 l_shipment_number NUMBER;
17195 l_option_number NUMBER;
17196 l_service_number NUMBER;
17197 l_dummy NUMBER;
17198 
17199 -- Fetches Service lines pertaining to Standard
17200 --and related line set records.
17201 --lchen rewrite cursor standard_line_number to fix performance bug 1869179
17202 
17203 CURSOR STANDARD_LINE_NUMBER IS
17204 select /*MOAC_SQL_CHANGES*/ a.line_id, a.header_id, a.line_number, a.shipment_number, a.option_number, a.service_number
17205 from oe_order_lines a
17206 where a.service_reference_line_id= p_line_id
17207 UNION
17208 select a.line_id, a.header_id, a.line_number, a.shipment_number, a.option_number, a.service_number
17209 from oe_order_lines a
17210 where a.line_set_id = p_line_set_id
17211 UNION
17212 select a.line_id, a.header_id, a.line_number, a.shipment_number, a.option_number, a.service_number
17213 from oe_order_lines a
17214 where exists
17215       (select 'x'
17216        from oe_order_lines_all b
17217        where a.service_reference_line_id=b.line_id
17218        and b.line_set_id = p_line_set_id)
17219       and a.line_Id <> p_line_id;
17220 
17221 
17222 --Fetches Options/classes/services pertaining to Model/Kit
17223 --and related line set records.
17224 
17225 CURSOR MODEL_LINE_NUMBER IS
17226       SELECT /*MOAC_SQL_CHANGES*/ line_id, header_id,line_number,shipment_number,
17227 		   option_number,service_number
17228       FROM   oe_order_lines
17229       WHERE  (top_model_line_id = p_line_id
17230 	 OR      line_set_id = p_line_set_id
17231 	 OR     top_model_line_id in (SELECT line_id
17232 							FROM   oe_order_lines_all
17233 							WHERE header_id = p_header_id
17234                             AND line_set_id = p_line_set_id))
17235       AND     line_id <> p_line_id
17236       AND     header_id = p_header_id
17237       FOR UPDATE OF line_number NOWAIT;
17238 
17239 
17240 
17241 --Fetches services attached to options/model/classes to update
17242 --line_number.
17243 --lchen rewrite cursor service_line_number to fix performance bug 1869179
17244 
17245 CURSOR SERVICE_LINE_NUMBER IS
17246   select /*MOAC_SQL_CHANGES*/ a.line_id, a.header_id, a.line_number, a.shipment_number, a.option_number, a.service_number
17247   from oe_order_lines a, oe_order_lines_all b
17248   where a.service_reference_line_id=b.line_id
17249   and b.line_set_id = p_line_set_id
17250   UNION
17251   select a.line_id, a.header_id, a.line_number, a.shipment_number, a.option_number, a.service_number
17252   from oe_order_lines a, oe_order_lines_all b
17253   Where a.service_reference_line_id=b.line_id
17254   and  b.top_model_line_id= p_line_id
17255   UNION
17256   select a.line_id, a.header_id, a.line_number, a.shipment_number, a.option_number, a.service_number
17257   from oe_order_lines a, oe_order_lines_all b
17258   Where a.service_reference_line_id=b.line_id
17259   and  EXISTS (select 'X'
17260            from oe_order_lines_all c
17261            where line_set_id = p_line_set_id
17262            and c.line_id = b.top_model_line_id);
17263 
17264 
17265 l_line_rec      OE_Order_PUB.Line_Rec_Type;
17266 l_cursor_flag   VARCHAR2(1) := null;
17267 
17268 BEGIN
17269        oe_debug_pub.add('Entering OE_LINE_UTIL.CASCADE_LINE_NUMBER ');
17270               oe_debug_pub.add('AK line_id ' || p_line_id);
17271               oe_debug_pub.add('AK line_iset_d ' || p_line_set_id);
17272               oe_debug_pub.add('AK line_number' || p_line_number);
17273               oe_debug_pub.add('AK item_type_code' || p_item_type_code);
17274 
17275        IF p_item_type_code = OE_GLOBALS.G_ITEM_STANDARD THEN
17276 
17277               OPEN Standard_line_number;
17278                l_cursor_flag := 'S';
17279 
17280     -- Update  line number on the child service lines
17281  /*lchen rewrite the update statement to fix performance bug 1869179 */
17282       oe_debug_pub.add('l_cursor_flag= ' ||l_cursor_flag );
17283 
17284             LOOP
17285             FETCH standard_line_number
17286             INTO  l_line_id,
17287 	          l_header_id,
17288 	          l_line_number,
17289 	          l_shipment_number,
17290 	          l_option_number,
17291 	          l_service_number;
17292             EXIT when standard_line_number%NOTFOUND;
17293 
17294             BEGIN
17295             SELECT line_id
17296             INTO  l_dummy
17297             FROM   oe_order_lines
17298             WHERE  line_id=l_line_id
17299             FOR UPDATE OF line_number NOWAIT;
17300             EXCEPTION
17301             WHEN OTHERS THEN
17302             l_dummy := 0;
17303             END;
17304 
17305       oe_debug_pub.add('l_line_id= ' || l_line_id);
17306        oe_debug_pub.add('In the loop of standard_line_number, update child service line numbers');
17307 
17308         UPDATE oe_order_lines
17309           Set    line_number = p_line_number,
17310                  lock_control = lock_control + 1
17311          WHERE  line_id=l_line_id;
17312 
17313        END LOOP;
17314      CLOSE Standard_line_number;
17315 
17316      OPEN Standard_line_number;
17317           IF SQL%FOUND THEN
17318 	     OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
17319 
17320               		LOOP
17321 				 FETCH Standard_line_number
17322 				 INTO  l_line_rec.line_id,
17323 					  l_line_rec.header_id,
17324 				 	  l_line_rec.line_number,
17325 					  l_line_rec.shipment_number,
17326 					  l_line_rec.option_number,
17327 					  l_line_rec.service_number;
17328  			      EXIT WHEN Standard_line_number%NOTFOUND;
17329 
17330                oe_debug_pub.add(' before calling wf_util');
17331 	       oe_debug_pub.add('line_rec.line_id=' || l_line_rec.line_id);
17332 
17333                         oe_order_wf_util.set_line_user_key(l_line_rec);
17334 
17335                       END LOOP;
17336 
17337                END IF;
17338               CLOSE Standard_line_number;
17339 
17340          ELSIF p_item_type_code = OE_GLOBALS.G_ITEM_MODEL
17341          OR    p_item_type_code = OE_GLOBALS.G_ITEM_KIT
17342          THEN
17343 
17344 
17345                OPEN Model_line_number;
17346                 l_cursor_flag := 'M';
17347 
17348                 oe_debug_pub.add('l_cursor_flag= ' ||l_cursor_flag );
17349 	      -- Update line number on the child option/service/class lines
17350 
17351                UPDATE oe_order_lines
17352                Set    line_number = p_line_number,
17353                       lock_control = lock_control + 1
17354                WHERE  (top_model_line_id = p_line_id
17355 	          OR      line_set_id = p_line_set_id
17356 	          OR     top_model_line_id in (SELECT line_id
17357 				FROM   oe_order_lines
17358 				WHERE header_id = p_header_id
17359                 AND line_set_id = p_line_set_id))
17360                   AND    line_id <> p_line_id
17361                   AND    header_id = p_header_id;  -- 2508099
17362 
17363 		IF SQL%FOUND THEN
17364 			    OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
17365 
17366 			  LOOP
17367 				FETCH Model_line_number
17368 				INTO  l_line_rec.line_id,
17369 				 l_line_rec.header_id,
17370 				 l_line_rec.line_number,
17371 				 l_line_rec.shipment_number,
17372 				 l_line_rec.option_number,
17373 				 l_line_rec.service_number;
17374  			 	EXIT WHEN Model_Line_Number%NOTFOUND;
17375 
17376                 oe_debug_pub.add(' before calling wf_util');
17377 		oe_debug_pub.add('line_rec.line_id=' || l_line_rec.line_id);
17378 
17379                               oe_order_wf_util.set_line_user_key(l_line_rec);
17380 
17381 			  END LOOP;
17382                END IF;
17383                CLOSE Model_line_number;
17384 
17385 
17386       -- Update line numbers for service lines
17387 
17388       OPEN SERVICE_line_number;
17389       l_cursor_flag := 'O';
17390       oe_debug_pub.add('l_cursor_flag= ' ||l_cursor_flag );
17391 
17392 -- Update line number on the child option/service/class lines
17393  --lchen rewrite the update statement to fix performance bug 1869179
17394 
17395      LOOP
17396       FETCH service_line_number
17397   	INTO  l_line_id,
17398 	      l_header_id,
17399 	      l_line_number,
17400 	      l_shipment_number,
17401 	      l_option_number,
17402 	      l_service_number;
17403 
17404         EXIT when service_line_number%NOTFOUND;
17405 
17406       BEGIN
17407         SELECT line_id
17408         INTO  l_dummy
17409         FROM   oe_order_lines
17410         WHERE  line_id=l_line_id
17411       FOR UPDATE OF line_number NOWAIT;
17412         EXCEPTION
17413         WHEN OTHERS THEN
17414          l_dummy := 0;
17415      END;
17416 
17417    oe_debug_pub.add('l_line_id = ' ||l_dummy);
17418   oe_debug_pub.add('in service_line_number loop, update service line number');
17419 
17420       UPDATE oe_order_lines
17421       Set    line_number = p_line_number,
17422              lock_control = lock_control + 1
17423       WHERE  line_id=l_line_id;
17424     END LOOP;
17425    CLOSE service_line_number;
17426 
17427      OPEN service_line_number;
17428 	IF SQL%FOUND THEN
17429 	   OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
17430 
17431 			  LOOP
17432 				FETCH service_line_number
17433 				INTO  l_line_rec.line_id,
17434 				 l_line_rec.header_id,
17435 				 l_line_rec.line_number,
17436 				 l_line_rec.shipment_number,
17437 				 l_line_rec.option_number,
17438 				 l_line_rec.service_number;
17439  			 	EXIT WHEN service_Line_Number%NOTFOUND;
17440 
17441                 oe_debug_pub.add(' before calling wf_util');
17442 		oe_debug_pub.add('line_rec.line_id=' || l_line_rec.line_id);
17443 
17444                             oe_order_wf_util.set_line_user_key(l_line_rec);
17445 	                END LOOP;
17446            END IF;
17447         CLOSE Service_line_number;
17448 
17449        END IF;   /*p_item_type_code*/
17450 
17451      oe_debug_pub.add('Exiting OE_LINE_UTIL.CASCADE_LINE_NUMBER ');
17452 
17453 EXCEPTION
17454 
17455     WHEN NO_DATA_FOUND THEN
17456           IF l_cursor_flag = 'S' THEN
17457             CLOSE Standard_line_number;
17458           ELSIF l_cursor_flag = 'M' THEN
17459 		  CLOSE Model_Line_Number;
17460           ELSIF l_cursor_flag = 'O' THEN
17461                CLOSE Service_line_number;
17462           END IF;
17463 
17464     WHEN  APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION THEN
17465 
17466           IF p_item_type_code = OE_GLOBALS.G_ITEM_STANDARD THEN
17467             CLOSE Standard_line_number;
17468           ELSE
17469 		  CLOSE Model_Line_Number;
17470           END IF;
17471 
17472           IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
17473           THEN
17474 
17475        	   fnd_message.set_name('ONT','OE_LOCK_ROW_ALREADY_LOCKED');
17476         	   OE_MSG_PUB.Add;
17477 	        RAISE FND_API.G_EXC_ERROR;
17478 
17479         	END IF;
17480 
17481      WHEN OTHERS THEN
17482 
17483           IF l_cursor_flag = 'S' THEN
17484             CLOSE Standard_line_number;
17485           ELSIF l_cursor_flag = 'M' THEN
17486 		  CLOSE Model_Line_Number;
17487           ELSIF l_cursor_flag = 'O' THEN
17488                CLOSE Service_line_number;
17489           END IF;
17490 
17491         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
17492         THEN
17493             oe_msg_pub.Add_Exc_Msg
17494             (   G_PKG_NAME
17495           ,   'Cascade_line_number'
17496             );
17497         END IF;
17498 
17499         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
17500 
17501 END Cascade_Line_Number;
17502 
17503 
17504 /*----------------------------------------------------------
17505 PROCEDURE Post_Write_Process
17506 -----------------------------------------------------------*/
17507 
17508 PROCEDURE Post_Write_Process
17509 (   p_x_line_rec                    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
17510 ,   p_old_line_rec                  IN  OE_Order_PUB.Line_Rec_Type :=
17511                                         OE_Order_PUB.G_MISS_LINE_REC
17512 ) IS
17513 l_return_status    VARCHAR2(30):= FND_API.G_RET_STS_SUCCESS;
17514 I                  NUMBER;
17515 l_ship_authorize   VARCHAR2(1);
17516 l_operation        VARCHAR2(30);
17517 
17518 l_qty_to_reserve   NUMBER;
17519 l_qty2_to_reserve   NUMBER; -- INVCONV
17520 l_msg_count        NUMBER;
17521 l_msg_data         VARCHAR2(2000);
17522 l_line_id		    NUMBER;
17523 l_old_recursion_mode VARCHAR2(1);
17524 
17525 -- For reservations
17526 l_reservation_rec         inv_reservation_global.mtl_reservation_rec_type;
17527 l_dummy_sn                inv_reservation_global.serial_number_tbl_type;
17528 l_quantity_reserved       NUMBER;
17529 l_quantity2_reserved       NUMBER; -- INVCONV
17530 l_rsv_id                  NUMBER;
17531 l_reservable_type         NUMBER;
17532 
17533 l_atp_tbl      OE_ATP.atp_tbl_type;
17534 l_buffer                  VARCHAR2(2000);
17535 l_lock_control            NUMBER;
17536 
17537 -- subinventory
17538 l_revision_code    NUMBER;
17539 l_lot_code         NUMBER;
17540 
17541 /* Fix Bug # 3184597 */
17542 l_ctr              NUMBER;
17543 
17544 CURSOR ship_authorize IS
17545     SELECT 'Y' from
17546     WF_ITEM_ACTIVITY_STATUSES WIAS
17547   , WF_PROCESS_ACTIVITIES WPA
17548     where WIAS.item_type = 'OEOL'
17549     AND WIAS.item_key = to_char(p_x_line_rec.line_id)
17550     AND WIAS.activity_status = 'NOTIFIED'
17551     AND WPA.activity_name = 'AUTHORIZE_TO_SHIP_WAIT'
17552     AND WPA.instance_id = WIAS.process_activity;
17553 
17554 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
17555 
17556 l_close_act_complete NUMBER := 0;
17557 
17558 BEGIN
17559 
17560  if l_debug_level > 0 then
17561   oe_debug_pub.add('Entering Post_Write_Process',1);
17562  end if;
17563 
17564    -- QUOTING change
17565    IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE
17566 	 AND p_x_line_rec.split_from_line_id IS NULL
17567          AND nvl(p_x_line_rec.transaction_phase_code,'F') = 'F'
17568       )
17569       OR (
17570   OE_Quote_Util.G_COMPLETE_NEG = 'Y'
17571           AND NOT OE_GLOBALS.EQUAL(p_x_line_rec.transaction_phase_code
17572                      ,p_old_line_rec.transaction_phase_code)
17573           )
17574    THEN
17575     if l_debug_level > 0 then
17576      oe_debug_pub.add('Call evaluate_holds_post_write for CREATE');
17577     end if;
17578      OE_Holds_PUB.evaluate_holds_post_write
17579       (p_entity_code => OE_GLOBALS.G_ENTITY_LINE
17580       ,p_entity_id => p_x_line_rec.line_id
17581       ,x_msg_count => l_msg_count
17582       ,x_msg_data => l_msg_data
17583       ,x_return_status => l_return_status
17584       );
17585 
17586          IF l_return_status = FND_API.G_RET_STS_ERROR THEN
17587             RAISE FND_API.G_EXC_ERROR;
17588          ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
17589             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
17590          END IF;
17591 
17592     if l_debug_level > 0 then
17593       oe_debug_pub.add('After evaluate_holds_post_write in LINE Post Write');
17594     end if;
17595   END IF;
17596 
17597    --Call the delayed request for holds evaluation. This is needed for a
17598    --scheduling fix.
17599    IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
17600 
17601    if l_debug_level > 0 then
17602     oe_debug_pub.add('Calling DelayedReg for evaluate_holds in post_write for UPDATE');
17603    end if;
17604 
17605     OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
17606          (p_request_type   =>OE_GLOBALS.G_EVAL_HOLD_SOURCE
17607           ,p_delete        => FND_API.G_TRUE
17608           ,x_return_status => l_return_status
17609           );
17610     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
17611           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
17612     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
17613           RAISE FND_API.G_EXC_ERROR;
17614     END IF;
17615 
17616 
17617    END IF;
17618 
17619 
17620   -- Start the Line Workflow
17621   --------------------------------------------------------------------
17622 
17623   -- QUOTING change
17624   IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE
17625       OR (OE_Quote_Util.G_COMPLETE_NEG = 'Y'
17626            AND NOT OE_GLOBALS.EQUAL(p_x_line_rec.transaction_phase_code
17627                       ,p_old_line_rec.transaction_phase_code)
17628            )
17629       )
17630      AND nvl(p_x_line_rec.transaction_phase_code,'F') = 'F'
17631   THEN
17632       OE_Order_WF_Util.CreateStart_LineProcess(p_x_line_rec);
17633   END IF;
17634 
17635 
17636   --------------------------------------------------------------------
17637    -- If freeze_included_options profile value is ENTRY,
17638    -- we have populated a global pl/sql table,
17639    -- now call function to freeze included items.
17640    -- Since process included items cannot set recursion mode, caler needs to set
17641    -- the recursion mode.
17642   --------------------------------------------------------------------
17643 
17644    l_old_recursion_mode := OE_GLOBALS.G_RECURSION_MODE;
17645    --   OE_GLOBALS.G_RECURSION_MODE := 'Y';
17646 
17647    I := OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL.FIRST;
17648    WHILE I is not null
17649    LOOP
17650           if l_debug_level > 0 then
17651 	    oe_debug_pub.add(I || ' freeze inc items call looping '||p_x_line_rec.line_id, 4);
17652           end if;
17653 	    IF p_x_line_rec.line_id = OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL(I)
17654 	    THEN
17655                   if l_debug_level > 0 then
17656 		    oe_debug_pub.add('PO: Calling freeze_inc_items call', 2);
17657                   end if;
17658 		    l_return_status :=
17659 		    OE_Config_Util.Process_Included_Items
17660 						   (p_line_rec => p_x_line_rec,
17661 		 				    p_freeze   => TRUE);
17662 
17663           if l_debug_level > 0 then
17664             oe_debug_pub.add('PO: After Calling Process_Included_Items call: ' ||
17665                            l_return_status, 2);
17666           end if;
17667 
17668             IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
17669 
17670                OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL.DELETE(I);
17671 
17672             ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
17673 
17674                 OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL.DELETE;
17675                 RAISE FND_API.G_EXC_ERROR;
17676 
17677             ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
17678 
17679                 OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL.DELETE;
17680                 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
17681 
17682             END IF;
17683 
17684         END IF;
17685 
17686       I := OE_Config_Pvt.OE_FREEZE_INC_ITEMS_TBL.NEXT(I);
17687 
17688    END LOOP;
17689 
17690    ------------------------------------------------------------------------
17691    -- Call Scheduling to perform any scheduling on the line, if needed
17692    ------------------------------------------------------------------------
17693 
17694     -- Added code in delete_dependency for delete operation.
17695 
17696     --4504362: Branch scheduling check removed
17697 
17698       if l_debug_level > 0 then
17699        oe_debug_pub.add('OESCH_PERFORM_SCHEDULING :' ||
17700                            OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING,1);
17701       end if;
17702 
17703 /* 7576948: IR ISO Change Management project Start */
17704 --
17705 -- This check is performed to ensure if there is a line cancellation
17706 -- from Planning workbench or DRP user in ASCP then scheduling should be
17707 -- done to Unschedule/Undemand the order line. Other than this case,
17708 -- if Planning user updates the order line then scheduling action
17709 -- is not performed.
17710 -- The global OE_Schedule_GRP.G_ISO_Planning_Update is set to TRUE
17711 -- in package OE_Schedule_GRP.Process_Order
17712 -- This change is done as a very specific case for IR ISO CMS project
17713 -- when changes been done by Planning user
17714 --
17715 
17716     IF OE_Schedule_GRP.G_ISO_Planning_Update AND
17717      NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity, p_old_line_rec.ordered_quantity) THEN
17718 --     nvl(p_x_line_rec.ordered_quantity,0) = 0 THEN  -- Commented for bug 7611039
17719       OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING := 'Y';
17720 
17721       IF l_debug_level > 0 THEN
17722         oe_debug_pub.add(' Setting global OE_Schedule_GRP.G_ISO_Planning_Update to TRUE',5);
17723       END IF;
17724     END IF;
17725 
17726 /* ============================= */
17727 /* IR ISO Change Management Ends */
17728 
17729 
17730        IF  OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING = 'Y'
17731        AND p_x_line_rec.line_category_code <> 'RETURN'
17732        AND p_x_line_rec.operation <> OE_GLOBALS.G_OPR_DELETE
17733        THEN
17734 
17735         if l_debug_level > 0 then
17736          oe_debug_pub.add('PO: Calling new Schedule_line from post write',1);
17737         end if;
17738 
17739          oe_split_util.g_sch_recursion := 'TRUE';
17740 
17741         if l_debug_level > 0 then
17742          oe_debug_pub.add(' New Schedule Line',1);
17743         end if;
17744          OE_SCHEDULE_UTIL.Schedule_Line
17745          (p_x_line_rec    => p_x_line_rec
17746          ,p_old_line_rec  => p_old_line_rec
17747          ,x_return_status => l_return_status);
17748 
17749         IF OE_Schedule_GRP.G_ISO_Planning_Update THEN
17750            OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING := 'N';
17751         END IF; -- Added for bug 7611039
17752 
17753        END IF;
17754 
17755        oe_split_util.g_sch_recursion := 'FALSE';
17756 
17757       if l_debug_level > 0 then
17758        oe_debug_pub.add('PO: After Calling Schedule_line: ' ||
17759                                  l_return_status,1);
17760        oe_debug_pub.add('SCH: p_x_line_rec.schedule_status_code '||
17761                  p_x_line_rec.schedule_status_code,1);
17762       end if;
17763 
17764        IF l_return_status = FND_API.G_RET_STS_ERROR THEN
17765           RAISE FND_API.G_EXC_ERROR;
17766        ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
17767           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
17768        END IF;
17769 
17770      -- do not move Log_CTO_Requests above scheduling
17771 
17772       IF (p_x_line_rec.top_model_line_id is NOT NULL OR
17773           p_x_line_rec.ato_line_id is NOT NULL) AND
17774           NOT  p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CONFIG
17775       THEN
17776 
17777         Log_CTO_Requests( p_x_line_rec    => p_x_line_rec
17778                          ,p_old_line_rec  => p_old_line_rec
17779                          ,x_return_status => l_return_status);
17780       END IF;
17781 
17782 
17783 
17784    -- re-set the old recursion mode after process included items call.
17785    -- OE_GLOBALS.G_RECURSION_MODE := l_old_recursion_mode;
17786 
17787     -- 4504362 :Branch scheduling check removed.
17788 -- This is moved from cancellations logic since closing the line is
17789 -- based on the cancellation flag and ordered quantity
17790 
17791      IF (oe_sales_can_util.G_REQUIRE_REASON) THEN
17792 
17793        IF Nvl(p_x_line_rec.split_action_code,'X') <> 'SPLIT' THEN
17794 
17795           If (p_x_line_rec.ordered_quantity = 0 AND
17796 		 p_x_line_rec.operation = oe_globals.G_OPR_UPDATE )then
17797 
17798           -- OE_GLOBALS.G_RECURSION_MODE := 'Y';
17799 /*
17800 -- Log a request to cancel the workflow.
17801 
17802 
17803         OE_delayed_requests_Pvt.log_request
17804         (p_entity_code                          => OE_GLOBALS.G_ENTITY_ALL,
17805         p_entity_id                             => p_x_line_rec.line_id,
17806         p_requesting_entity_code        => OE_GLOBALS.G_ENTITY_ALL,
17807         p_requesting_entity_id          => p_x_line_rec.line_id,
17808         p_request_type                  => OE_GLOBALS.G_CANCEL_WF,
17809 	p_param1                 => OE_GLOBALS.G_ENTITY_LINE,
17810         x_return_status                         => l_return_status);
17811 */
17812 
17813 -- commented the code to move the logic to delayed request
17814 -- reopened to revert the changes
17815           wf_engine.handleerror(OE_Globals.G_WFI_LIN
17816                     ,to_char(p_x_line_rec.line_id)
17817                     ,'CLOSE_LINE',
17818                     'RETRY','CANCEL');
17819                        if l_debug_level > 0 then
17820 			OE_DEBUG_PUB.ADD('After Calling Wf Handle Error ');
17821                        end if;
17822 
17823 -- Added for FP bug 6682329. The below query is added to fix the data corruption
17824 -- issues where both cancelled_flag and open_flag were getting set to 'Y'.
17825 
17826         IF nvl(p_x_line_rec.cancelled_flag,'N') = 'Y' THEN
17827            oe_debug_pub.add(' Line is cancelled, Close_Line WF act is ? ');
17828            select count(*) into l_close_act_complete
17829            from   wf_item_activity_statuses s,
17830                   wf_process_activities p
17831            where  s.process_activity = p.instance_id
17832            and    s.item_type = 'OEOL'
17833            and    s.item_key = to_char(p_x_line_rec.line_id)
17834            and    p.activity_name = 'CLOSE_LINE'
17835            and    activity_result_code in ('NOT_ELIGIBLE','COMPLETE')
17836            and    s.activity_status = 'COMPLETE';
17837            IF l_close_act_complete = 0 THEN
17838              oe_debug_pub.add(' Close_Line failed. Rollback the changes');
17839                 FND_MESSAGE.SET_NAME('ONT','OE_CLOSE_LINE_ERROR');
17840                 OE_MSG_PUB.ADD;
17841                 RAISE FND_API.G_EXC_ERROR;
17842            END IF;
17843         END IF;
17844 
17845           -- OE_GLOBALS.G_RECURSION_MODE := 'N';
17846 
17847 
17848             /*
17849             ** Fix Bug # 3184597 Start
17850             ** Check if the cancelled line is waiting on the flow to be
17851             ** started. If so, delete entry from G_START_LINE_FLOWS_TBL
17852             */
17853             IF (OE_GLOBALS.G_START_LINE_FLOWS_TBL.COUNT > 0) THEN
17854               l_ctr := OE_GLOBALS.G_START_LINE_FLOWS_TBL.FIRST;
17855               WHILE (l_ctr IS NOT NULL) LOOP
17856                 IF (OE_GLOBALS.G_START_LINE_FLOWS_TBL(l_ctr).LINE_ID =
17857                                              p_x_line_rec.line_id) THEN
17858                   oe_debug_pub.add('Cancellation:Deleting from OE_GLOBALS.G_START_LINE_FLOWS_TBL for lineID:' || p_x_line_rec.line_id);
17859                  OE_GLOBALS.G_START_LINE_FLOWS_TBL.DELETE(l_ctr);
17860                  EXIT;
17861                 END IF;
17862                 l_ctr := OE_GLOBALS.G_START_LINE_FLOWS_TBL.NEXT(l_ctr);
17863               END LOOP;
17864             END IF;
17865             /* Fix Bug # 3184597 End */
17866 	    -- Added below IF condition for FP bug 6628653 base bug 6513023
17867 	                IF NOT(OE_OE_FORM_CANCEL_LINE.g_ord_lvl_can) THEN
17868 	                   IF p_x_line_rec.top_model_line_id IS NOT NULL AND
17869 	                      p_x_line_rec.ato_line_id IS NULL AND
17870 	                      p_x_line_rec.item_type_code = 'INCLUDED' AND
17871 	                          nvl(p_x_line_rec.model_remnant_flag, 'N') = 'Y'
17872 	                   THEN
17873 	                        oe_debug_pub.add('In case of line level cancellation: calling Handle_RFR() ');
17874 	                         Handle_RFR(p_top_model_line_id => p_x_line_rec.top_model_line_id,
17875 	                                    p_line_id => p_x_line_rec.line_id,
17876 	                                    p_link_to_line_id => p_x_line_rec.link_to_line_id );
17877 	                   END IF;
17878 	                END IF;
17879 	                    -- End of FP bug 6628653 base bug 6513023
17880 
17881 		 OE_SALES_CAN_UTIL.G_REQUIRE_REASON := FALSE;
17882         end if;
17883        END IF;
17884 	END IF;
17885 
17886  if l_debug_level > 0 then
17887   oe_debug_pub.add('RQ: ' || p_x_line_rec.reserved_quantity,1);
17888  end if;
17889 
17890    -- Adding code to create reservation when item is changed on
17891    -- the line, since inventory expects the item to be stored on the line
17892    --before making any reservations. --1913263.
17893   -- 4504362 :Branch scheduling checks removed.
17894 
17895   --------------------------------------------------------------------
17896   -- Complete the block activity for Shipping Authorization based on the
17897   -- the value of the authorized_to_ship_flag in the lines table
17898   -- Check if the ship authorization activity is in a NOTIFIED state
17899   --------------------------------------------------------------------
17900 
17901   IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
17902    if l_debug_level > 0 then
17903     oe_debug_pub.add('Authorization flag is: ' ||
17904                                  p_x_line_rec.authorized_to_ship_flag);
17905    end if;
17906     IF p_x_line_rec.authorized_to_ship_flag = 'Y' AND
17907  	  NOT OE_GLOBALS.Equal(p_x_line_rec.authorized_to_ship_flag,
17908 					p_old_line_rec.authorized_to_ship_flag)
17909     THEN
17910       OPEN ship_authorize;
17911       FETCH ship_authorize INTO l_ship_authorize;
17912       CLOSE ship_authorize;
17913       IF (l_ship_authorize = 'Y')
17914       THEN
17915          WF_ENGINE.CompleteActivityInternalName('OEOL', p_x_line_rec.line_id,
17916                       'AUTHORIZE_TO_SHIP_WAIT', 'COMPLETE');
17917       END IF;
17918     END IF;
17919   END IF;
17920 
17921   --------------------------------------------------------------------
17922    -- Line Number update logic.
17923    -- Update/Cascade linenumber changes to it children.
17924    -- If the line number is updated at Standard line then update all
17925    -- its children (Service).
17926    -- If the line number is updated at Model/Kit then update all its
17927    -- children and sub children(like options,classes,services,service
17928    -- attached to children).
17929   --------------------------------------------------------------------
17930 
17931    IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
17932 
17933       IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.line_number ,
17934 	 					p_old_line_rec.line_number)
17935       THEN
17936 	   Cascade_Line_Number
17937 			( p_x_line_rec.header_id,
17938                         p_x_line_rec.line_id,
17939 	    		p_x_line_rec.line_set_id,
17940          		p_x_line_rec.item_type_code,
17941          		p_x_line_rec.line_number
17942 			);
17943       END IF; -- Equal.
17944 
17945    END IF; -- G_OPR_UPDATE.
17946 
17947 
17948   --------------------------------------------------------------------
17949    -- Create sales credits if sales rep on the line is different than header
17950    -- The reason to call procedure to evaluate this is to validate couple of
17951    -- other cases.
17952   --------------------------------------------------------------------
17953 
17954    IF  NOT (nvl(p_x_line_rec.split_action_code,'X') = 'SPLIT' and
17955                p_x_line_rec.operation = oe_globals.g_opr_update)
17956    THEN
17957 
17958      IF  NOT( (nvl(p_x_line_rec.split_from_line_id,FND_API.G_MISS_NUM)
17959 				<> FND_API.G_MISS_NUM)
17960                AND p_x_line_rec.operation = oe_globals.g_opr_create
17961              )
17962      THEN
17963 
17964         if l_debug_level > 0 then
17965 	 oe_debug_pub.add('Before Calling Create Credit');
17966         end if;
17967 
17968    -- Bug# 5726848 IF condition modified for allowing update of sales credit for copied orders.
17969    	 IF NOT (nvl(p_x_line_rec.source_document_type_id,-99) = 2 AND
17970 	         p_x_line_rec.operation = oe_globals.g_opr_create) THEN
17971    -- End of change Bug# 5726848
17972                  OE_Line_Scredit_Util.Create_Credit
17973 		(p_line_rec => p_x_line_rec,p_old_line_rec => p_old_line_rec);
17974       END IF;
17975 
17976      END IF;
17977 
17978    END IF;
17979 
17980    -- Executing the RMA child creation request here so that line numbers of
17981    -- child RMA lines are in sequence with the parent line. FOR ER:1480867
17982 
17983    IF p_x_line_rec.line_category_code = 'RETURN' AND
17984       p_x_line_rec.reference_line_id IS NOT NULL AND
17985       OE_GLOBALS.G_RETURN_CHILDREN_MODE = 'N' AND
17986       NOT OE_GLOBALS.EQUAL(p_x_line_rec.reference_line_id ,
17987                         p_old_line_rec.reference_line_id)
17988 
17989    THEN
17990        OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
17991          (p_request_type   =>OE_GLOBALS.G_INSERT_RMA
17992           ,p_delete        => FND_API.G_TRUE
17993           ,x_return_status => l_return_status
17994           );
17995    END IF;
17996 
17997    -- BLANKETS: Log requests to validate and update release qty/amount
17998    -- Not needed for returns, returned qty on blanket would
17999    -- be updated when return is fulfilled!
18000    -- Changed to enable to accept CONFIG and SERVICE items for Pack -J onwards.
18001    IF ((OE_CODE_CONTROL.Get_Code_Release_Level >= '110510'
18002         AND p_x_line_rec.item_type_code <> 'INCLUDED')
18003        -- Blanket reference can only be specified for standard items
18004        -- and kit items
18005       OR (OE_CODE_CONTROL.Get_Code_Release_Level >= '110509'
18006            AND p_x_line_rec.item_type_code IN ('STANDARD','KIT')))
18007       AND (p_x_line_rec.blanket_number IS NOT NULL
18008        OR p_old_line_rec.blanket_number IS NOT NULL)
18009       AND p_x_line_rec.line_category_code = 'ORDER'
18010       -- QUOTING change
18011       AND nvl(p_x_line_rec.transaction_phase_code,'F') = 'F'
18012    THEN
18013 
18014      -- Blanket Request should not be logged for system splits.
18015      IF (nvl(p_x_line_rec.split_action_code,'X') = 'SPLIT'
18016          AND p_x_line_rec.operation = oe_globals.g_opr_update
18017          AND nvl(p_x_line_rec.split_by,'USER') = 'SYSTEM'
18018          )
18019      OR (nvl(p_x_line_rec.split_from_line_id,FND_API.G_MISS_NUM)
18020 				<> FND_API.G_MISS_NUM
18021          AND p_x_line_rec.operation = oe_globals.g_opr_create
18022          AND nvl(p_x_line_rec.split_by,'USER') = 'SYSTEM'
18023          )
18024      THEN
18025         NULL;
18026      ELSE
18027         Log_Blanket_Request(p_x_line_rec,p_old_line_rec);
18028      END IF;
18029 
18030    END IF;
18031 
18032   if l_debug_level > 0 then
18033    oe_debug_pub.add('Exiting Post_Write_Process',1);
18034   end if;
18035 
18036 EXCEPTION
18037 
18038     WHEN FND_API.G_EXC_ERROR THEN
18039 
18040         RAISE;
18041 
18042     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
18043 
18044 
18045         RAISE;
18046 
18047     WHEN OTHERS THEN
18048 
18049         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
18050         THEN
18051             oe_msg_pub.Add_Exc_Msg
18052             (   G_PKG_NAME
18053           ,   'Post_Write_Process'
18054             );
18055         END IF;
18056 
18057         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
18058 
18059 END Post_Write_Process;
18060 
18061 
18062 
18063 /*----------------------------------------------------------
18064 PROCEDURE Post_Line_Process
18065 -----------------------------------------------------------*/
18066 
18067 PROCEDURE Post_Line_Process
18068 (   p_control_rec		    		IN  OE_GLOBALS.Control_Rec_Type
18069 ,   p_x_line_tbl                   IN OUT NOCOPY  OE_Order_PUB.Line_Tbl_Type
18070 )
18071 IS
18072 l_return_status    VARCHAR2(1);
18073 I                  NUMBER;
18074 l_count            NUMBER;
18075 l_valid_line_number VARCHAR2(1) := 'Y';
18076 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
18077 BEGIN
18078 
18079  if l_debug_level > 0 then
18080   oe_debug_pub.add('entering Post_Line_Process', 1);
18081  end if;
18082 
18083   -- Create Sets for lines and call group scheduling if any
18084   /*
18085   IF (p_control_rec.process AND
18086 	OE_GLOBALS.G_RECURSION_MODE <> 'Y')THEN
18087       OE_Set_Util.Process_Sets
18088 		(p_x_line_tbl => p_x_line_tbl);
18089   END IF;
18090   */
18091 
18092   IF (p_control_rec.process AND
18093 	OE_GLOBALS.G_RECURSION_MODE <> 'Y') THEN
18094 
18095       -- batch validation request is executed in post_lines
18096       -- so that it gets executed before any other delayed requests
18097       -- like pricing, scheduling for models.
18098 
18099       OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
18100          (p_request_type   =>OE_GLOBALS.G_VALIDATE_CONFIGURATION
18101           ,p_delete        => FND_API.G_TRUE
18102           ,x_return_status => l_return_status
18103           );
18104 
18105      if l_debug_level > 0 then
18106       oe_debug_pub.add('ret sts: '|| l_return_status, 4);
18107      end if;
18108 
18109       IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
18110           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
18111       ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
18112           RAISE FND_API.G_EXC_ERROR;
18113       END IF;
18114 
18115       -- cascading of changes from model to options
18116       -- is done before executing other requests.
18117 
18118       OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
18119          (p_request_type   =>OE_GLOBALS.G_CASCADE_CHANGES
18120           ,p_delete        => FND_API.G_TRUE
18121           ,x_return_status => l_return_status
18122           );
18123 
18124       IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
18125           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
18126       ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
18127           RAISE FND_API.G_EXC_ERROR;
18128       END IF;
18129 
18130       -- Making change to whole configuration is done before all
18131       -- other delayed requests are fired.
18132 
18133       OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
18134          (p_request_type   => OE_GLOBALS.G_CHANGE_CONFIGURATION
18135           ,p_delete        => FND_API.G_TRUE
18136           ,x_return_status => l_return_status
18137           );
18138       IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
18139           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
18140       ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
18141           RAISE FND_API.G_EXC_ERROR;
18142       END IF;
18143 
18144       -- handling split of models
18145 
18146       OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
18147          (p_request_type   => OE_GLOBALS.G_COPY_CONFIGURATION
18148           ,p_delete        => FND_API.G_TRUE
18149           ,x_return_status => l_return_status
18150           );
18151 
18152       IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
18153           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
18154       ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
18155           RAISE FND_API.G_EXC_ERROR;
18156       END IF;
18157 
18158 
18159       IF OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.COUNT > 0 THEN
18160         oe_debug_pub.add('calling modufy inc items', 3);
18161         OE_Config_Pvt.Modify_Included_Items
18162         (x_return_status => l_return_status);
18163         OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.DELETE;
18164 
18165         IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
18166           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
18167         ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
18168           RAISE FND_API.G_EXC_ERROR;
18169         END IF;
18170       END IF;
18171 
18172 
18173       OE_SERVICE_UTIL.Update_Service_Lines
18174                (p_x_line_tbl      => p_x_line_tbl,
18175                 x_return_status   => l_return_status);
18176 
18177       IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
18178          RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
18179       ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
18180          RAISE FND_API.G_EXC_ERROR;
18181       END IF;
18182 
18183 
18184     -- added for bug fix 2375829
18185 
18186   if l_debug_level > 0 then
18187     oe_debug_pub.add('line tbl count: '||p_x_line_tbl.COUNT, 3);
18188   end if;
18189 
18190     I := p_x_line_tbl.FIRST;
18191 
18192     WHILE I is NOT NULL
18193     LOOP
18194 
18195       IF nvl(p_x_line_tbl(I).booked_flag, 'N') = 'N' THEN
18196        if l_debug_level > 0 then
18197         oe_debug_pub.add('not booked ', 3);
18198        end if;
18199 
18200         EXIT;
18201       END IF;
18202 
18203      if l_debug_level > 0 then
18204       oe_debug_pub.add(p_x_line_tbl(I).operation ||
18205       ' cancelled flag ' || p_x_line_tbl(I).cancelled_flag||
18206       ' shp interf '||p_x_line_tbl(I).shipping_interfaced_flag, 3);
18207      end if;
18208 
18209       IF (p_x_line_tbl(I).operation = 'DELETE' OR
18210          (p_x_line_tbl(I).operation = 'UPDATE' AND
18211           p_x_line_tbl(I).cancelled_flag = 'Y')) AND
18212           p_x_line_tbl(I).top_model_line_id is not NULL AND
18213           nvl(p_x_line_tbl(I).ship_model_complete_flag, 'N') = 'Y' AND
18214           nvl(p_x_line_tbl(I).shipping_interfaced_flag, 'N') = 'N' AND
18215           nvl(p_x_line_tbl(I).model_remnant_flag, 'N') = 'N'
18216       THEN
18217         oe_debug_pub.add('cancel or delete, call smc shipping', 1);
18218 
18219         SELECT count(*)
18220         INTO   l_count
18221         FROM   oe_order_lines
18222         WHERE  top_model_line_id = p_x_line_tbl(I).top_model_line_id
18223         AND    shipping_interfaced_flag = 'Y';
18224 
18225         IF l_count = 0 THEN
18226 
18227           oe_debug_pub.add('need to call smc shipping', 1);
18228 
18229           OE_Shipping_Integration_PVT.Process_SMC_Shipping
18230           (p_line_id           => p_x_line_tbl(I).line_id
18231           ,p_top_model_line_id => p_x_line_tbl(I).top_model_line_id
18232           ,x_return_status     => l_return_status);
18233 
18234           IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
18235             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
18236           ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
18237             RAISE FND_API.G_EXC_ERROR;
18238           END IF;
18239         END IF;
18240 
18241       END IF;
18242 
18243 -- Validate line number for bug no 5493479 start
18244 
18245       IF  (p_x_line_tbl(I).item_type_code = 'STANDARD'
18246            OR (p_x_line_tbl(I).top_model_line_id <> p_x_line_tbl(I).line_id
18247               AND p_x_line_tbl(I).item_type_code = 'MODEL'))
18248          AND OE_ORDER_IMPORT_MAIN_PVT.G_CONTEXT_ID IS NOT NULL
18249         THEN
18250           BEGIN
18251 
18252            SELECT 'N'
18253            INTO   l_valid_line_number
18254            FROM   oe_order_lines L
18255            WHERE  L.line_number = p_x_line_tbl(I).line_number
18256            AND    L.header_id = p_x_line_tbl(I).header_id
18257            AND    L.line_id <> p_x_line_tbl(I).line_id
18258            AND    ( L.item_type_code = 'STANDARD'
18259            OR     ( L.top_model_line_id = L.line_id
18260            AND      L.item_type_code = 'MODEL'));
18261 
18262           EXCEPTION
18263                 WHEN no_data_found THEN
18264                    l_valid_line_number := 'Y';
18265              -- Too many rows exception would be raised if there are split
18266                 -- lines with the same line number
18267                 WHEN too_many_rows THEN
18268                    l_valid_line_number := 'N';
18269                 WHEN OTHERS THEN
18270                    l_valid_line_number := 'N';
18271           END;
18272 
18273           IF l_valid_line_number = 'N' THEN
18274                 FND_MESSAGE.SET_NAME('ONT','OE_LINE_NUMBER_EXISTS');
18275                 OE_MSG_PUB.ADD;
18276                 l_return_status := FND_API.G_RET_STS_ERROR;
18277           END IF;
18278 
18279          END IF;
18280 -- Validate line number for bug no 5493479 end
18281       I := p_x_line_tbl.NEXT(I);
18282 
18283     END LOOP;
18284 
18285   END IF; -- if not recursion and process = true.
18286 
18287 
18288   -- Move the code below so that cascading will happen if any before
18289   -- scheduling. 2404695
18290 
18291   -- Create Sets for lines and call group scheduling if any
18292 
18293   IF (p_control_rec.process AND
18294     OE_GLOBALS.G_RECURSION_MODE <> 'Y')THEN
18295 
18296       OE_Set_Util.Process_Sets
18297         (p_x_line_tbl => p_x_line_tbl);
18298 
18299     IF OE_SPLIT_UTIL.G_SPLIT_ACTION = TRUE THEN
18300 
18301       -- We will call split_scheduling here for lines which got created
18302       -- thru splits.
18303 
18304      if l_debug_level > 0 then
18305       oe_debug_pub.add('Calling Split Scheduling',1);
18306      end if;
18307 
18308       -- 4504362 :Branch Scheduling checks removed.
18309 
18310      OE_SCHEDULE_UTIL.Split_Scheduling
18311         (p_x_line_tbl      => p_x_line_tbl,
18312          x_return_status   => l_return_status);
18313 
18314 
18315       OE_SPLIT_UTIL.G_SPLIT_ACTION := FALSE;
18316 
18317       if l_debug_level > 0 then
18318        oe_debug_pub.add('After Calling Split Scheduling: ' ||
18319                          l_return_status,1);
18320       end if;
18321 
18322        IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
18323          RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
18324        ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
18325          RAISE FND_API.G_EXC_ERROR;
18326        END IF;
18327 
18328     END IF; -- if split action
18329 
18330   END IF;
18331 
18332   IF OE_SPLIT_UTIL.G_SPLIT_ACTION = TRUE THEN
18333 
18334    if l_debug_level > 0 then
18335     oe_debug_pub.add('Logging g_split_action',2);
18336    end if;
18337 
18338     I := p_x_line_tbl.FIRST;
18339     WHILE I is NOT NULL
18340     LOOP
18341 
18342 
18343       IF  (NVL(p_x_line_tbl(I).split_by ,'USER') = 'SYSTEM' AND
18344           NVL(p_x_line_tbl(I).split_action_code,'X') = 'SPLIT' AND
18345           p_x_line_tbl(I).schedule_status_code IS NOT NULL)
18346       OR (NVL(p_x_line_tbl(I).split_by ,'USER') = 'SYSTEM' AND
18347           p_x_line_tbl(I).split_from_line_id is not null AND
18348           p_x_line_tbl(I).split_from_line_id <> FND_API.G_MISS_NUM AND
18349           p_x_line_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE) THEN
18350 
18351          if l_debug_level > 0 then
18352           oe_debug_pub.add('Logging G_SPLIT_SCHEDULE' ||
18353                             p_x_line_tbl(I).line_id, 2);
18354          end if;
18355 
18356           OE_delayed_requests_Pvt.log_request(
18357           p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
18358           p_entity_id              => p_x_line_tbl(I).line_id,
18359           p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
18360           p_requesting_entity_id   => p_x_line_tbl(I).line_id,
18361           p_request_type           => OE_GLOBALS.G_SPLIT_SCHEDULE,
18362           p_param1                 => p_x_line_tbl(I).schedule_status_code,
18363           p_param2                 => p_x_line_tbl(I).arrival_set_id,
18364           p_param3                 => p_x_line_tbl(I).ship_set_id,
18365           p_param4                 => p_x_line_tbl(I).ship_model_complete_flag,
18366           p_param5                 => p_x_line_tbl(I).model_remnant_flag,
18367           p_param6                 => p_x_line_tbl(I).top_model_line_id,
18368           p_param7                 => p_x_line_tbl(I).ato_line_id,
18369           p_param8                 => p_x_line_tbl(I).item_type_code,
18370           x_return_status          => l_return_status);
18371 
18372 
18373            OE_SPLIT_UTIL.G_SPLIT_ACTION := FALSE;
18374 
18375       END IF;
18376 
18377       I := p_x_line_tbl.NEXT(I);
18378 
18379     END LOOP;
18380 
18381   END IF; -- if not recursion and process = true.
18382 
18383 
18384  if l_debug_level > 0 then
18385   oe_debug_pub.add('leaving Post_Line_Process', 1);
18386  end if;
18387 EXCEPTION
18388 
18389     WHEN FND_API.G_EXC_ERROR THEN
18390         oe_debug_pub.add('execution error', 1);
18391         RAISE;
18392 
18393     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
18394         oe_debug_pub.add('unexp error', 1);
18395         RAISE;
18396 
18397     WHEN OTHERS THEN
18398         oe_debug_pub.add('others error', 1);
18399         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
18400         THEN
18401             oe_msg_pub.Add_Exc_Msg
18402             (   G_PKG_NAME
18403           ,   'Pre_Line_Process'
18404             );
18405         END IF;
18406 
18407         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
18408 
18409 END Post_Line_Process;
18410 
18411 
18412 /*----------------------------------------------------------
18413 Function Get_Return_Item_Type_Code
18414 -----------------------------------------------------------*/
18415 Function Get_Return_Item_Type_Code
18416 (   p_line_rec                      IN OE_Order_PUB.Line_Rec_Type
18417 ) RETURN varchar2
18418 IS
18419 l_item_type_code varchar2(30);
18420 BEGIN
18421 
18422   IF p_line_rec.line_category_code = 'RETURN'
18423   and p_line_rec.reference_line_id is not null THEN
18424 
18425   	SELECT item_type_code
18426   	INTO l_item_type_code
18427   	FROM oe_order_lines
18428      WHERE line_id = p_line_rec.reference_line_id;
18429 
18430      RETURN l_item_type_code;
18431   ELSE
18432      RETURN p_line_rec.item_type_code;
18433   END IF;
18434 
18435   RETURN p_line_rec.item_type_code;
18436 
18437 EXCEPTION
18438   WHEN NO_DATA_FOUND THEN
18439     RETURN null;
18440   WHEN OTHERS THEN
18441     RETURN null;
18442 END Get_Return_Item_Type_Code;
18443 
18444 
18445 
18446 /*----------------------------------------------------------
18447 
18448 --  OPM 02/JUN/00  BEGIN
18449 --  ====================
18450 
18451 FUNCTION dual_uom_control renamed from process_characteristics
18452 -----------------------------------------------------------*/
18453 
18454 FUNCTION dual_uom_control -- INVCONV renamed from process_characteristics
18455 (
18456   p_inventory_item_id IN NUMBER
18457  ,p_ship_from_org_id  IN NUMBER
18458  ,x_item_rec          OUT NOCOPY OE_ORDER_CACHE.item_rec_type
18459 )
18460 RETURN BOOLEAN
18461 IS
18462 
18463 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
18464 
18465 BEGIN
18466 /*   INVCONV
18467 IF FND_PROFILE.VALUE ('ONT_PROCESS_INSTALLED_FLAG') = 'N' THEN
18468   RETURN FALSE;
18469 END IF;  */
18470 
18471 /* If item and warehouse are both present, assess if this is
18472    a dual controlled ine:
18473  ======================================================================*/
18474 IF (p_inventory_item_id IS NOT NULL AND
18475   p_inventory_item_id <> FND_API.G_MISS_NUM) AND
18476   (p_ship_from_org_id  IS NOT NULL AND
18477   p_ship_from_org_id <> FND_API.G_MISS_NUM) THEN
18478     x_item_rec :=
18479     	     OE_Order_Cache.Load_Item (p_inventory_item_id
18480                                     ,p_ship_from_org_id);
18481 --  IF x_item_rec.process_warehouse_flag = 'Y'  INVCONV
18482 -- AND INVCONV
18483   oe_debug_pub.add('in function Dual_uom_control - tracking_quantity_ind  = ' || x_item_rec.tracking_quantity_ind);
18484   IF x_item_rec.tracking_quantity_ind = 'PS' -- INVCONV
18485     THEN
18486 
18487     IF l_debug_level  > 0 THEN
18488     	oe_debug_pub.add('Dual_uom_control is TRUE ', 1);
18489     end if;
18490     RETURN TRUE;
18491   END IF;
18492 END IF;
18493 
18494 IF l_debug_level  > 0 THEN
18495     	oe_debug_pub.add('Dual_uom_control is FALSE ', 1);
18496 end if;
18497 
18498 RETURN FALSE;
18499 
18500 
18501 EXCEPTION
18502 WHEN NO_DATA_FOUND THEN
18503   RETURN NULL;
18504 WHEN OTHERS THEN
18505      IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
18506      THEN
18507          OE_MSG_PUB.Add_Exc_Msg
18508          (     G_PKG_NAME         ,
18509              'dual_uom_control'
18510          );
18511      END IF;
18512         oe_debug_pub.add('others in dual_uom_control', 1);
18513      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
18514 
18515 END dual_uom_control ;
18516 
18517 
18518 /*----------------------------------------------------------
18519 FUNCTION Get_Dual_Uom
18520 ----------------------------------------------------------- INVCONV REMOVEd to OE_Default_Line
18521 
18522 FUNCTION Get_Dual_Uom(p_line_rec OE_ORDER_PUB.Line_Rec_Type)
18523 RETURN VARCHAR2
18524 IS
18525 -- l_APPS_UOM2  VARCHAR2(3) := NULL; INVCONV
18526 l_status     VARCHAR2(1);
18527 l_msg_count  NUMBER;
18528 l_msg_data   VARCHAR2(2000);
18529 l_item_rec   OE_ORDER_CACHE.item_rec_type;
18530 
18531 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
18532 
18533 BEGIN
18534        if l_debug_level > 0 then
18535 	oe_debug_pub.add('Enter Get dual uom');
18536        end if;
18537 
18538 IF dual_uom_control   -- INVCONV  Process_Characteristics
18539   (p_line_rec.inventory_item_id,p_line_rec.ship_from_org_id,l_item_rec) THEN
18540   IF l_item_rec.tracking_quantity_ind = 'PS' THEN -- INVCONV
18541        if l_debug_level > 0 then
18542 					oe_debug_pub.add('Get dual uom - tracking in P and S ');
18543        end if;
18544       -- convert 4 digit apps OPM codes to equivalent 3 byte APPS codes
18545       -- Primary UM
18546       GMI_Reservation_Util.Get_AppsUOM_from_OPMUOM
18547 					 (p_OPM_UOM        => l_item_rec.opm_item_um2
18548 					 ,x_Apps_UOM       => l_APPS_UOM2
18549 					 ,x_return_status  => l_status
18550 					 ,x_msg_count      => l_msg_count
18551 					 ,x_msg_data       => l_msg_data);
18552 
18553 
18554 
18555        if l_debug_level > 0 then
18556 					oe_debug_pub.add('Get  Dual Uom returns dual UM of ' || l_item_rec.secondary_uom_code);
18557        end if;
18558   END IF;
18559 END IF;
18560 RETURN l_item_rec.secondary_uom_code; -- INVCONV
18561 
18562 EXCEPTION
18563 
18564 WHEN NO_DATA_FOUND THEN
18565 
18566        if l_debug_level > 0 then
18567 	oe_debug_pub.add('No Data Found Get Dual Uom' );
18568        end if;
18569 RETURN NULL;
18570 
18571 WHEN OTHERS THEN
18572      IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
18573      THEN
18574          OE_MSG_PUB.Add_Exc_Msg
18575          (     G_PKG_NAME         ,
18576              'Get_Dual_Uom'
18577          );
18578      END IF;
18579        if l_debug_level > 0 then
18580         oe_debug_pub.add('others in get_dual uom', 1);
18581        end if;
18582      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
18583 
18584 
18585 END Get_Dual_Uom;   */
18586 
18587 
18588 /*----------------------------------------------------------
18589 FUNCTION Get_Preferred_Grade
18590 -----------------------------------------------------------   INVCONV removed
18591 
18592 FUNCTION Get_Preferred_Grade(p_line_rec OE_ORDER_PUB.Line_Rec_Type,
18593 					    p_old_line_rec OE_ORDER_PUB.Line_Rec_Type)
18594 RETURN VARCHAR2
18595 IS
18596 l_grade_ctl       NUMBER(5):= NULL;
18597 l_preferred_grade VARCHAR2(4) := NULL;
18598 l_item_rec        OE_ORDER_CACHE.item_rec_type;
18599 
18600 CURSOR C_GRADE1 IS
18601 SELECT alot.prefqc_grade
18602 FROM op_alot_prm alot, ic_item_mst item, op_cust_mst cust
18603 WHERE item.item_id = l_item_rec.opm_item_id
18604           and alot.cust_id = cust.cust_id
18605 		  and item.alloc_class = alot.alloc_class
18606 		  and alot.delete_mark = 0
18607 		  and cust.of_ship_to_site_use_id = p_line_rec.ship_to_org_id;
18608 
18609 CURSOR C_GRADE2 IS
18610 SELECT alot.prefqc_grade
18611 FROM op_alot_prm alot, ic_item_mst item
18612 WHERE item.item_id = l_item_rec.opm_item_id
18613 	       and alot.cust_id IS NULL
18614 		  and item.alloc_class = alot.alloc_class
18615 		  and alot.delete_mark = 0;
18616 BEGIN
18617 
18618 IF oe_line_util.Process_Characteristics
18619   (p_line_rec.inventory_item_id,p_line_rec.ship_from_org_id,l_item_rec) AND
18620   ((NOT OE_GLOBALS.EQUAL(p_line_rec.ordered_item
18621                        ,p_old_line_rec.ordered_item)) OR
18622   (NOT OE_GLOBALS.EQUAL(p_line_rec.ship_from_org_id
18623                        ,p_old_line_rec.ship_from_org_id))) AND
18624   (p_line_rec.preferred_grade IS NULL OR
18625     p_line_rec.preferred_grade = FND_API.G_MISS_CHAR) THEN
18626   NULL;
18627 ELSE
18628   RETURN p_line_rec.preferred_grade;
18629 END IF;
18630 oe_debug_pub.add('OPM Test grade ctl for preferred grade');
18631 
18632 IF l_item_rec.grade_ctl = 1 THEN
18633   OPEN C_GRADE1;
18634   FETCH C_GRADE1 into l_preferred_grade;
18635   IF (C_GRADE1%NOTFOUND) THEN
18636     CLOSE C_GRADE1;
18637     OPEN C_GRADE2;
18638     FETCH C_GRADE2 into l_preferred_grade;
18639     IF (C_GRADE2%NOTFOUND) THEN
18640       CLOSE C_GRADE2;
18641 	 RETURN NULL;
18642     END IF;
18643   END IF;
18644 END IF;
18645 RETURN l_preferred_grade;
18646 
18647 EXCEPTION
18648 
18649 
18650 WHEN OTHERS THEN
18651      IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
18652      THEN
18653          OE_MSG_PUB.Add_Exc_Msg
18654          (     G_PKG_NAME         ,
18655              'Get_Preferred_Grade'
18656          );
18657      END IF;
18658         oe_debug_pub.add('others in get_preferred_grade', 1);
18659      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
18660 
18661 
18662 END Get_Preferred_Grade;   */
18663 
18664 -- Comment Label for procedure added as part of Inline Documentation Drive.
18665 ------------------------------------------------------------------------------------
18666 -- Procedure Name : Sync_Dual_Qty
18667 -- Input Params   : p_x_line_rec        : New Line Record for POAPI Processing.
18668 --                  p_old_line_rec      : Old Line Record for POAPI Processing.
18669 -- Output Params  : p_x_line_rec        : New Line Record for POAPI Processing.
18670 -- Description    : This procedure does a sync up of the dual quantity i.e.
18671 --                  syncs up the qrdered_quantity2 as per the ordered_quantity
18672 --                  on line getting processed, if it is needed, i.e. if its a
18673 --                  split line, or some update is happening on warehouse.
18674 --                  There are several conditions of Early Exit from the procedure
18675 --                  if processing/recalculation of Ordered_Quantity2 is not needed.
18676 --                  In the end, if there is no early exit, the ordered_quantity2 is
18677 --                  recalculated from ordered_quantity based on UOMs and conversion
18678 --                  setup.
18679 --                  This procedure is called only from this package and is useful
18680 --                  during creation of SPLIT Line in ITS and also during update
18681 --                  of Warehouse on the Order Line.
18682 --                  The conditions of early exit are like below:
18683 --                  a) Non Dual Control
18684 --                  b) Cancellation of Line.
18685 --                  c) If Secondary_Default_Index is not "Fixed" for OPM.
18686 --                  d) While Splitting during ITS,so as to directly populate data
18687 --                     from Shipping, rather than recalculating.
18688 --                  e) If neither qordered_quantity of ordered_quantity2 are present.
18689 --                  f) Early return if no Sync is required, due to no change.
18690 ------------------------------------------------------------------------------------
18691 /*----------------------------------------------------------
18692 PROCEDURE Sync_Dual_Qty
18693 -----------------------------------------------------------*/
18694 PROCEDURE Sync_Dual_Qty
18695 (
18696    P_X_LINE_REC        IN OUT NOCOPY OE_ORDER_PUB.Line_Rec_Type
18697   ,P_OLD_LINE_REC      IN OE_ORDER_PUB.Line_Rec_Type
18698 )
18699 IS
18700 
18701 l_converted_qty        NUMBER(19,9);          -- OPM 25/AUG/00
18702 l_item_rec             OE_ORDER_CACHE.item_rec_type;
18703 -- l_OPM_UOM              VARCHAR2(4); INVCONV
18704 l_return               NUMBER;
18705 l_status               VARCHAR2(1);
18706 l_msg_count            NUMBER;
18707 -- l_msg_data             VARCHAR2(2000); -- INVCONV
18708 UOM_CONVERSION_FAILED  EXCEPTION;             -- OPM B1478461
18709 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
18710 l_buffer                  VARCHAR2(2000); -- INVCONV
18711 
18712 --X_message VARCHAR2(1000);       -- INVCONV
18713 --X_temp NUMBER;
18714 
18715 
18716 
18717 BEGIN
18718 
18719 
18720 IF l_debug_level  > 0 THEN
18721  		oe_debug_pub.add('Entering Sync Dual Qty');
18722 END IF;
18723 
18724 
18725   /* Moved this code from below to here - 2999767 */
18726  /* If this is a dual_control item line, load the item details from cache
18727  ==============================================================*/
18728 IF dual_uom_control
18729  (p_x_line_rec.inventory_item_id,p_x_line_rec.ship_from_org_id,
18730  l_item_rec) THEN
18731 --   IF l_item_rec.dualum_ind not in (1,2,3) INVCONV
18732     IF l_item_rec.tracking_quantity_ind <> 'PS'
18733 
18734     THEN
18735       IF l_debug_level  > 0 THEN
18736  					oe_debug_pub.add('Sync Dual Qty not dual controlled  - return');   -- INVCONV
18737 			END IF;
18738       p_x_line_rec.ordered_quantity2 := NULL;
18739       RETURN;
18740    END IF;
18741 ELSE
18742 
18743   IF l_debug_level  > 0 THEN
18744  					oe_debug_pub.add('not dual controlled -  return');
18745 	END IF;
18746 
18747   --  p_x_line_rec.ordered_quantity2 := NULL;      OPM 2711743
18748   RETURN;
18749 END IF;
18750 
18751 IF (OE_OE_FORM_CANCEL_LINE.g_ord_lvl_can) THEN -- 5141545
18752 	       oe_debug_pub.add ('Sync Dual Qty - Cancellation so return ' );
18753 	       return;
18754 	 else
18755 	    oe_debug_pub.add ('Sync Dual Qty - NOT a cancellation ' );
18756 END IF;
18757 
18758 
18759 IF l_debug_level  > 0 THEN
18760 	oe_debug_pub.add ('In sync_dual_qty');
18761 	oe_debug_pub.add ('ordered_quantity = ' || p_x_line_rec.ordered_quantity );
18762 	oe_debug_pub.add ('ordered_quantity2 = ' || p_x_line_rec.ordered_quantity2 );
18763 
18764 	oe_debug_pub.add ('ordered_quantity_uom = ' || p_x_line_rec.order_quantity_uom );
18765 	oe_debug_pub.add ('ordered_quantity_uom2 = ' || p_x_line_rec.ordered_quantity_uom2 );
18766 	oe_debug_pub.add ('inventory_item_id = ' || p_x_line_rec.inventory_item_id );
18767 	oe_debug_pub.add ('ship_from_org_id = ' || p_x_line_rec.ship_from_org_id );
18768 	oe_debug_pub.add ('secondary_default_ind  =  ' || l_item_rec.secondary_default_ind   );
18769 	oe_debug_pub.add ('p_x_line_rec.source_document_type_id = ' || p_x_line_rec.source_document_type_id );
18770 
18771 	IF p_x_line_rec.ordered_quantity_uom2 = FND_API.G_MISS_CHAR THEN
18772 	 		oe_debug_pub.add ('ordered_quantity_uom2 = G_MISS_CHAR  ' );
18773 	ELSIF
18774 	  p_x_line_rec.ordered_quantity_uom2 is null THEN
18775 	   	oe_debug_pub.add ('ordered_quantity_uom2 = null' );
18776 	END IF;
18777 	IF p_x_line_rec.ordered_quantity2 = FND_API.G_MISS_NUM THEN
18778 	 		oe_debug_pub.add ('ordered_quantity2 = G_MISS_NUM  ' );
18779 	ELSIF
18780 	  p_x_line_rec.ordered_quantity2 is null THEN
18781 	   	oe_debug_pub.add ('ordered_quantity2 = null' );
18782 	END IF;
18783 
18784 
18785 END IF;
18786 
18787 
18788 
18789 
18790 -- secondary_default_ind value of ' ' = type 0
18791 -- secondary_default_ind value of F   = type 1
18792 -- secondary_default_ind value of D   = type 2
18793 -- secondary_default_ind value of N   = type 3
18794 
18795 -- bug 4053117 start  pal
18796  IF  OE_GLOBALS.Equal(p_x_line_rec.ship_from_org_id,p_old_line_rec.ship_from_org_id)
18797     and l_item_rec.secondary_default_ind <> 'F'
18798          and (
18799    				(p_x_line_rec.ordered_quantity IS NOT NULL and
18800  					 p_x_line_rec.ordered_quantity <> FND_API.G_MISS_NUM )  AND
18801   					(p_x_line_rec.ordered_quantity2 IS NOT NULL and
18802   					p_x_line_rec.ordered_quantity2 <> FND_API.G_MISS_NUM )
18803   					) THEN
18804     		 IF l_debug_level  > 0 THEN
18805  						oe_debug_pub.add('Sync_dual_qty IF (OE_GLOBALS.G_UI_FLAG) and ship froms = -   early exit ');
18806 				 END IF;
18807  				 RETURN;
18808 END IF;
18809 -- bug 4053117 end
18810 
18811 -- 5172701 pal
18812 IF NOT ( OE_GLOBALS.Equal(p_x_line_rec.ship_from_org_id,p_old_line_rec.ship_from_org_id) )
18813 and l_item_rec.secondary_uom_code is NOT NULL
18814   THEN
18815    p_x_line_rec.ordered_quantity_uom2 := l_item_rec.secondary_uom_code;
18816 END IF;
18817 
18818 
18819 
18820 
18821 IF ( (nvl(p_x_line_rec.shipping_quantity2,0) > 0)
18822      -- OPM B1661023 04/02/01 PARENT with a SYSTEM split from SHIPPING
18823      AND ((nvl(P_X_LINE_REC.ordered_quantity,0) =  nvl(P_OLD_LINE_REC.ordered_quantity,0)
18824          AND (nvl(P_X_LINE_REC.ordered_quantity2,0) =  nvl(P_OLD_LINE_REC.ordered_quantity2,0)))
18825      -- OPM B2169135 03/18/01  Qty 1 or 2 should default with item controls when one qty is changed.
18826          )
18827  OR
18828      (p_x_line_rec.split_from_line_id IS NOT NULL AND
18829       -- CHILD with a SYSTEM split from SHIPPING
18830       p_x_line_rec.split_by = 'SYSTEM' AND
18831       -- need to check if user or system  , early exit if system else sync
18832       p_x_line_rec.line_category_code <> 'RETURN'
18833       AND ((nvl(P_X_LINE_REC.ordered_quantity,0) =  nvl(P_OLD_LINE_REC.ordered_quantity,0)
18834            AND (nvl(P_X_LINE_REC.ordered_quantity2,0) =  nvl(P_OLD_LINE_REC.ordered_quantity2,0)))))
18835       -- OPM B2169135 03/18/01  Qty 1 or 2 should default with item controls when one qty is changed.
18836    )
18837 
18838  /* Begin 2999767 */
18839 -- OR   ( l_item_rec.dualum_ind = 1
18840    OR   ( l_item_rec.secondary_default_ind  = 'F' -- INVCONV
18841       AND (nvl(p_x_line_rec.shipping_quantity2,0) > 0) -- OPM  PARENT with a SYSTEM split from SHIPPING
18842       AND (nvl(P_X_LINE_REC.ordered_quantity,0) <> 0)
18843       AND (nvl(P_X_LINE_REC.ordered_quantity2,0) <> 0)
18844       )
18845  --OR   ( l_item_rec.dualum_ind = 1
18846  OR   ( l_item_rec.secondary_default_ind  = 'F' -- INVCONV
18847       AND p_x_line_rec.split_from_line_id IS NOT NULL  -- CHILD with a SYSTEM split from SHIPPING
18848       AND p_x_line_rec.split_by = 'SYSTEM'
18849       -- need to check if user or system  , early exit if system else sync
18850       AND p_x_line_rec.line_category_code <> 'RETURN'
18851       AND ((nvl(P_X_LINE_REC.ordered_quantity,0) <> 0) )
18852       AND ((nvl(P_X_LINE_REC.ordered_quantity2,0) <> 0)) )  --added for bug 7418730
18853 -- Bug 7418730 is for secondary quantity getting cleared on change of warehouse
18854 -- on system split line.This part of code was causing early exit and not allowing
18855 -- the secondary quantity to be populated. Added extra condition to avoid the early exit.
18856  /* End Bug2999767 */
18857 THEN
18858 
18859 	 IF l_debug_level  > 0 THEN
18860  			oe_debug_pub.add('Sync_dual_qty -  early exit ');
18861 	 END IF;
18862 
18863    RETURN;
18864 END IF;  -- OPM B1661023 04/02/01
18865 
18866 
18867 /* If neither quantity is present, no sync is required
18868 ======================================================*/
18869 IF (p_x_line_rec.ordered_quantity IS NULL OR
18870   p_x_line_rec.ordered_quantity = FND_API.G_MISS_NUM ) AND
18871   (p_x_line_rec.ordered_quantity2 IS NULL OR
18872   p_x_line_rec.ordered_quantity2 = FND_API.G_MISS_NUM ) THEN
18873 
18874 	  IF l_debug_level  > 0 THEN
18875   		oe_debug_pub.add ('Sync_dual_qty -  both quantities empty so early return');
18876   	END IF;
18877 
18878     RETURN;
18879 END IF;
18880 
18881 IF l_debug_level  > 0 THEN
18882 	oe_debug_pub.add('Sync_dual_qty - Convert for dual Scenario',1); -- INVCONV
18883 END IF;
18884 
18885 /* -- Bug3052287  INVCONV
18886 -- When the primary UOM1 itself is not populated, derive it from l_item_rec.
18887   IF (p_x_line_rec.order_quantity_uom is NULL)
18888  or (p_x_line_rec.order_quantity_uom = FND_API.G_MISS_CHAR )
18889  THEN
18890    GMI_Reservation_Util.Get_AppsUOM_from_OPMUOM
18891 					 (p_OPM_UOM        => l_item_rec.opm_item_um
18892 					 ,x_Apps_UOM       => p_x_line_rec.order_quantity_uom
18893 					 ,x_return_status  => l_status
18894 					 ,x_msg_count      => l_msg_count
18895 					 ,x_msg_data       => l_msg_data);
18896 
18897  END IF; */
18898 -- End bug3052287
18899 
18900 /* If the ordered_quantity_um has changed, force recalculation of quantity2
18901 unless we have a no default process item where there is no
18902 automatic calculation
18903 ==========================================================================*/
18904 IF (NOT OE_GLOBALS.EQUAL(p_x_line_rec.order_quantity_uom
18905          			    ,p_old_line_rec.order_quantity_uom ))
18906   AND p_old_line_rec.order_quantity_uom is not NULL  -- OPM 24/OCT/00 B1458751
18907  -- AND l_item_rec.dualum_ind <> 3  -- INVCONV
18908   AND l_item_rec.secondary_default_ind <> 'N' -- INVCONV
18909  THEN
18910   p_x_line_rec.ordered_quantity2 := NULL;
18911 END IF;
18912 
18913 /* Has one of the two quantities changed */
18914 
18915 IF (NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity
18916          			    ,p_old_line_rec.ordered_quantity )) OR
18917    (NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity2
18918          			    ,p_old_line_rec.ordered_quantity2)) OR
18919    (p_x_line_rec.ordered_quantity  IS NULL) OR
18920    (p_x_line_rec.ordered_quantity2 IS NULL) THEN
18921 
18922       IF l_debug_level  > 0 THEN
18923       	oe_debug_pub.add('Sync_dual_qty - change detected ',1);
18924       END IF;
18925 
18926  --  IF l_item_rec.dualum_ind in (0,3)  INVCONV
18927      IF (l_item_rec.secondary_default_ind = 'N' or
18928         l_item_rec.secondary_default_ind is null )
18929         --and ( p_x_line_rec.source_type_code  <> 'INTERNAL' )  -- INVCONV internal orders fix for PO reqs
18930         and NOT (nvl(p_x_line_rec.source_document_type_id,-99) = 10 ) -- INVCONV DEC 23
18931 
18932   		THEN
18933 
18934 	/* NO UM Conversion required for types 3 so return here and not internal order line  -- INVCONV
18935 	============================================================*/
18936 	    IF l_debug_level  > 0 THEN
18937       	oe_debug_pub.add('Sync_dual_qty - default ind is N or null - early return ',1);
18938       END IF;
18939 
18940       RETURN;
18941     END IF;
18942 ELSE
18943    /* No sync required
18944    ==================*/
18945    IF l_debug_level  > 0 THEN
18946       	oe_debug_pub.add('Sync_dual_qty - no change detected so no sync',1);
18947     END IF;
18948 
18949    RETURN;
18950 END IF; -- IF (NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity
18951 
18952 oe_debug_pub.add('Sync_dual_qty - here 1 ',1);
18953 
18954 IF (NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity
18955          			    ,p_old_line_rec.ordered_quantity )) OR
18956 				     p_x_line_rec.ordered_quantity2 IS NULL THEN
18957   /* Primary quantity has changed so recalculate secondary */
18958 
18959 --  IF l_item_rec.dualum_ind = 2  INVCONV
18960     IF l_item_rec.secondary_default_ind  = 'D' and  -- INVCONV
18961     p_x_line_rec.ordered_quantity is NOT NULL AND
18962     p_x_line_rec.order_quantity_uom <> p_x_line_rec.ordered_quantity_uom2 AND -- B1390859
18963     /* Only do tolerance check if both quantities populated */
18964     p_x_line_rec.ordered_quantity2 is NOT NULL
18965     and   ( p_x_line_rec.ordered_quantity2 <> FND_API.G_MISS_NUM  and -- INVCONV for PO req
18966     NOT (nvl(p_x_line_rec.source_document_type_id,-99) = 10) )   -- INVCONV DEC 23 not for internal order line
18967      THEN
18968 
18969 	  IF l_debug_level  > 0 THEN
18970 	  	  oe_debug_pub.add('Check the deviation  ');
18971     END IF;
18972 
18973 
18974 
18975  /*   l_return := GMICVAL.dev_validation(l_item_rec.opm_item_id  INVCONV
18976                                       ,0
18977 					             ,p_x_line_rec.ordered_quantity
18978 					             ,l_OPM_UOM
18979 					             ,p_x_line_rec.ordered_quantity2
18980                                       ,l_item_rec.opm_item_um2
18981 					             ,0);    */
18982     -- if change is within of tolerance, no further action
18983 
18984      l_return := INV_CONVERT.Within_Deviation  -- INVCONV
18985                        ( p_organization_id   =>
18986                                  p_x_line_rec.ship_from_org_id
18987                        , p_inventory_item_id =>
18988                                  p_x_line_rec.inventory_item_id
18989                        , p_precision         => 5
18990                        , p_quantity          => abs(p_x_line_rec.ordered_quantity) -- 5128490
18991                        , p_uom_code1         => p_x_line_rec.order_quantity_uom
18992                        , p_quantity2         => abs(p_x_line_rec.ordered_quantity2) -- 5128490
18993                        , p_uom_code2         => l_item_rec.secondary_uom_code );
18994       IF l_return = 0
18995       	then
18996       	    IF l_debug_level  > 0 THEN
18997     	  			oe_debug_pub.add('Sync_dual_qty - tolerance error 1 ' ,1);
18998     			 END IF;
18999 
19000     			 l_buffer          := FND_MSG_PUB.GET(p_msg_index => FND_MSG_PUB.G_LAST, -- INVCONV
19001                                          p_encoded => 'F');
19002            oe_msg_pub.add_text(p_message_text => l_buffer);
19003            IF l_debug_level  > 0 THEN
19004               oe_debug_pub.add(l_buffer,1);
19005     			 END IF;
19006     			 RAISE fnd_api.g_exc_error;
19007 
19008    		else
19009       	IF l_debug_level  > 0 THEN
19010     	  		oe_debug_pub.add('Sync_dual_qty - No tolerance error so return ',1);
19011     		END IF;
19012      	RETURN;
19013      END IF; -- IF l_return = 0
19014 
19015 
19016 
19017   END IF;  --   IF l_item_rec.secondary_default_ind  = 'D'
19018 
19019 
19020   IF l_debug_level  > 0 THEN
19021   	oe_debug_pub.add('Sync_dual_qty  - uom conversion primary to secondary');
19022   END IF;
19023 
19024 -- OPM June 2003 3011880 begin - when converting qtys, if the p_x_line_rec.ordered_quantity_uom2 is not available yet,
19025 -- then convert the opm um2 to the apps um for the call to get_opm_converted_qty below which requires apps uoms
19026 --
19027 
19028 /*	 IF ( p_x_line_rec.ordered_quantity_uom2 is NULL  INVCONV
19029            or p_x_line_rec.ordered_quantity_uom2 = FND_API.G_MISS_CHAR )
19030 	  THEN
19031       	-- convert 4 digit apps OPM codes to equivalent 3 byte APPS codes
19032       	-- Primary UM
19033       		GMI_Reservation_Util.Get_AppsUOM_from_OPMUOM
19034 					 (p_OPM_UOM        => l_item_rec.opm_item_um2
19035 					 ,x_Apps_UOM       => p_x_line_rec.ordered_quantity_uom2
19036 					 ,x_return_status  => l_status
19037 					 ,x_msg_count      => l_msg_count
19038 					 ,x_msg_data       => l_msg_data);
19039 		oe_debug_pub.add('OPM in sync_dual - Get_AppsUOM_from_OPMUOM returns dual UM of ' || p_x_line_rec.ordered_quantity_uom2);
19040   	END IF;   */
19041 
19042 -- OPM June 2003 3011880 end
19043 
19044 
19045 
19046 -- OPM 25/AUG/00 - use precision of 19,9 to match OPM processing
19047 /*  l_converted_qty :=GMICUOM.uom_conversion
19048  	            (l_item_rec.opm_item_id,0
19049      	    	  ,p_x_line_rec.ordered_quantity
19050                  ,l_OPM_UOM
19051     	    	       ,l_item_rec.opm_item_um2,0);
19052 
19053 -- Feb 2003 2683316 - changed the call to GMI uom_conversion above to get_opm_converted_qty
19054 -- to resolve rounding issues
19055 
19056       l_converted_qty  := GMI_Reservation_Util.get_opm_converted_qty(
19057               p_apps_item_id    => p_x_line_rec.inventory_item_id,
19058               p_organization_id => p_x_line_rec.ship_from_org_id,
19059               p_apps_from_uom   => p_x_line_rec.order_quantity_uom,
19060               p_apps_to_uom     => p_x_line_rec.ordered_quantity_uom2,
19061               p_original_qty    => p_x_line_rec.ordered_quantity); */
19062 
19063 
19064       l_converted_qty := INV_CONVERT.INV_UM_CONVERT(p_x_line_rec.inventory_item_id -- INVCONV
19065       																									, NULL
19066       																								 ,p_x_line_rec.SHIP_FROM_ORG_id -- invconv
19067                                                       ,5 --NULL
19068                                                       ,p_x_line_rec.ordered_quantity
19069                                                       ,p_x_line_rec.order_quantity_uom
19070                                                       ,l_item_rec.secondary_uom_code
19071                                                       ,NULL -- From uom name
19072                                                       ,NULL -- To uom name
19073                                                       );
19074 
19075       IF l_debug_level  > 0 THEN
19076       	oe_debug_pub.add('Sync_dual_qty - secondary qty after conversion is  '||l_converted_qty);
19077  			END IF;
19078 -- Feb 2003 2683316 end
19079 
19080   IF (l_converted_qty < 0) THEN    -- OPM B1478461 Start
19081     raise UOM_CONVERSION_FAILED;
19082   END IF;                          -- OPM B1478461 End
19083   p_x_line_rec.ordered_quantity2 := l_converted_qty;      -- OPM 25/AUG/00
19084 
19085 
19086 
19087 
19088 ELSIF (NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity2
19089          			        ,p_old_line_rec.ordered_quantity2 )) THEN
19090   /* Secondary quantity has changed so recalculate primary
19091   =======================================================*/
19092 
19093 
19094   -- IF l_item_rec.dualum_ind = 2 and p_x_line_rec.ordered_quantity2 is NOT NULL AND   -- INVCONV
19095      IF l_item_rec.secondary_default_ind  = 'D' and  -- INVCONV
19096     p_x_line_rec.ordered_quantity2 is NOT NULL AND
19097     p_x_line_rec.order_quantity_uom <> p_x_line_rec.ordered_quantity_uom2 AND -- B1390859
19098     p_x_line_rec.ordered_quantity is NOT NULL THEN
19099     /* Only do tolerance check if both quantities populated */
19100 
19101     -- if change is within of tolerance, no further action
19102     l_return := INV_CONVERT.Within_Deviation  -- INVCONV
19103                        ( p_organization_id   =>
19104                                  p_x_line_rec.ship_from_org_id
19105                        , p_inventory_item_id =>
19106                                  p_x_line_rec.inventory_item_id
19107                        , p_precision         => 5
19108                        , p_quantity          => abs(p_x_line_rec.ordered_quantity) -- 5128490
19109                        , p_uom_code1         => p_x_line_rec.order_quantity_uom
19110                        , p_quantity2         => abs(p_x_line_rec.ordered_quantity2)  -- 5128490
19111                        , p_uom_code2         => l_item_rec.secondary_uom_code );
19112 
19113       IF l_return = 0
19114       	then
19115        	   IF l_debug_level  > 0 THEN
19116     	  			oe_debug_pub.add('Sync_dual_qty - tolerance error 2' ,1);
19117     			 END IF;
19118 
19119     			 l_buffer          := FND_MSG_PUB.GET(p_msg_index => FND_MSG_PUB.G_LAST, -- INVCONV
19120                                          p_encoded => 'F');
19121            oe_msg_pub.add_text(p_message_text => l_buffer);
19122            IF l_debug_level  > 0 THEN
19123               oe_debug_pub.add(l_buffer,1);
19124     			 END IF;
19125     			 RAISE fnd_api.g_exc_error;
19126 
19127 
19128    		else
19129       	IF l_debug_level  > 0 THEN
19130     	  		oe_debug_pub.add('Sync_dual_qty - No tolerance error so return ',1);
19131     		END IF;
19132      	RETURN;
19133      END IF; -- IF l_return = 0
19134 
19135 
19136 
19137   /*  l_return := GMICVAL.dev_validation(l_item_rec.opm_item_id
19138                                       ,0
19139 					             ,p_x_line_rec.ordered_quantity
19140 					             ,l_OPM_UOM
19141 					             ,p_x_line_rec.ordered_quantity2
19142                                       ,l_item_rec.opm_item_um2
19143 					             ,0);
19144     -- if change is within tolerance, no further action
19145     --===================================================
19146     IF (l_return NOT in (-68, -69)) THEN
19147        RETURN;
19148     END IF;   */
19149 
19150 
19151   END IF; --  IF l_item_rec.secondary_default_ind  = 'D' and  -- INVCONV
19152 
19153   /* Convert secondary quantity to derive primary
19154   ==============================================*/
19155 
19156   -- OPM 25/AUG/00
19157   -- use l_converted_qty with precision of 19,9 to match OPM processing
19158 
19159 
19160 -- Feb 2003 2683316 - changed the call to GMI uom_conversion above to get_opm_converted_qty
19161 -- to resolve rounding issues
19162 
19163       /*l_converted_qty  := GMI_Reservation_Util.get_opm_converted_qty(  -- INVCONV
19164               p_apps_item_id    => p_x_line_rec.inventory_item_id,
19165               p_organization_id => p_x_line_rec.ship_from_org_id,
19166               p_apps_from_uom   => p_x_line_rec.ordered_quantity_uom2,
19167               p_apps_to_uom     => p_x_line_rec.order_quantity_uom ,
19168               p_original_qty    => p_x_line_rec.ordered_quantity2);  */
19169 
19170        l_converted_qty := INV_CONVERT.INV_UM_CONVERT(p_x_line_rec.inventory_item_id -- INVCONV
19171        																								, NULL
19172        																								,p_x_line_rec.ship_from_org_id -- INVCONV
19173                                                       ,5 --NULL
19174                                                       ,p_x_line_rec.ordered_quantity2
19175                                                       ,l_item_rec.secondary_uom_code
19176                                                       ,p_x_line_rec.order_quantity_uom
19177                                                       ,NULL -- From uom name
19178                                                       ,NULL -- To uom name
19179                                                       );
19180 
19181 
19182   		IF (l_converted_qty < 0) THEN    -- OPM B1478461 Start
19183    	 		raise UOM_CONVERSION_FAILED;
19184   		END IF;                          -- OPM B1478461 End
19185 
19186       IF l_debug_level  > 0 THEN
19187       	oe_debug_pub.add(' Sync_dual_qty - primary qty after conversion is  '||l_converted_qty);
19188       END IF;
19189 
19190       p_x_line_rec.ordered_quantity := l_converted_qty;
19191 
19192 END IF; -- IF (NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity
19193 
19194 
19195 EXCEPTION
19196 
19197 --OPM B1478461 Start
19198 WHEN UOM_CONVERSION_FAILED THEN
19199 
19200      --   FND_MESSAGE.SET_NAME('GMI','IC_API_UOM_CONVERSION_ERROR');     -- INVCONV
19201      --
19202      -- OPM BEGIN - BUG 2586841 - Added if condition for the message tokens to mask FND errors (why?)
19203      --
19204     /* IF ( p_x_line_rec.ordered_item is NULL  OR
19205           p_x_line_rec.ordered_item = FND_API.G_MISS_CHAR) THEN
19206          FND_MESSAGE.SET_TOKEN('ITEM_NO',to_char(nvl(p_x_line_rec.inventory_item_id, 0)));
19207      END IF;       */ -- INVCONV
19208     FND_MESSAGE.SET_NAME('INV','INV_NO_CONVERSION_ERR'); -- INVCONV
19209 
19210      --
19211      -- OPM END - BUG 2586841
19212      --
19213      OE_MSG_PUB.Add;
19214      RAISE FND_API.G_EXC_ERROR;
19215 --OPM B1478461 End
19216 
19217 WHEN fnd_api.g_exc_error THEN -- INVCONV
19218       RAISE FND_API.G_EXC_ERROR;
19219 
19220 WHEN OTHERS THEN
19221      IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
19222      THEN
19223          OE_MSG_PUB.Add_Exc_Msg
19224          (     G_PKG_NAME         ,
19225              'Sync_Dual_Qty'
19226          );
19227      END IF;
19228         oe_debug_pub.add('Exception handling: others in Sync_Dual_Qty', 1);
19229      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
19230 
19231 
19232 END Sync_Dual_Qty;
19233 
19234 /*-----------------------------------------------------------
19235 FUNCTION Calculate_Ordered_Quantity2
19236 ------------------------------------------------------------  -- INVCONV
19237 --   comment out this as it will not be used in the converged inventory code  replaced by calculate_dual_quantity
19238 
19239 FUNCTION Calculate_Ordered_Quantity2
19240 (
19241    P_LINE_REC          IN OE_ORDER_PUB.Line_Rec_Type
19242 )  RETURN NUMBER
19243 IS
19244 
19245 l_item_rec             OE_ORDER_CACHE.item_rec_type;
19246 -- OPM 25/AUG/00 - add precision of 19,9
19247 l_ordered_quantity2    NUMBER(19,9) := p_line_rec.ordered_quantity2;
19248 l_OPM_UOM              VARCHAR2(4);
19249 l_return               NUMBER;
19250 l_status               VARCHAR2(1);
19251 l_msg_count            NUMBER;
19252 l_msg_data             VARCHAR2(2000);
19253 
19254 BEGIN
19255 
19256 oe_debug_pub.add('OPM Enter Calculate_Ordered_Quantity2');
19257 
19258 
19259 -- If this is a process line, load the item details from cache
19260 --==============================================================
19261 IF oe_line_util.Process_Characteristics
19262   (p_line_rec.inventory_item_id,p_line_rec.ship_from_org_id,l_item_rec) THEN
19263    NULL;
19264 ELSE
19265   RETURN p_line_rec.ordered_quantity2;
19266 END IF;
19267 
19268 
19269 -- Usually ordered_quantity2 is not calculated for items where
19270 dualum_ind=3, but in a split scenario, the calc IS automated.
19271 --============================================================
19272 IF l_item_rec.dualum_ind in (1,2,3) THEN
19273   oe_debug_pub.add('OPM Dualum ind 3 is true');
19274 
19275 
19276  -- Feb 2003 2683316 - changed the call to GMI uom_conversion above to get_opm_converted_qty
19277 -- to resolve rounding issues
19278 
19279       l_ordered_quantity2 := GMI_Reservation_Util.get_opm_converted_qty(
19280               p_apps_item_id    => p_line_rec.inventory_item_id,
19281               p_organization_id => p_line_rec.ship_from_org_id,
19282               p_apps_from_uom   => p_line_rec.order_quantity_uom ,
19283               p_apps_to_uom     => p_line_rec.ordered_quantity_uom2,
19284               p_original_qty    => p_line_rec.ordered_quantity);
19285 
19286       oe_debug_pub.add('OPM secondary in Calculate_Ordered_Quantity2 after new get_opm_converted_qty is  '||l_ordered_quantity2);
19287 
19288 -- Feb 2003 2683316 end
19289 
19290 ELSE
19291   l_ordered_quantity2 := NULL;
19292 END IF;
19293 
19294   oe_debug_pub.add('OPM Return ordered_quantity2 set to '|| l_ordered_quantity2);
19295 RETURN l_ordered_quantity2;
19296 
19297 EXCEPTION
19298 
19299 WHEN OTHERS THEN
19300      IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
19301      THEN
19302          OE_MSG_PUB.Add_Exc_Msg
19303          (          G_PKG_NAME         ,
19304                     'Calculate Ordered Quantity2'
19305          );
19306      END IF;
19307      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
19308 
19309 
19310 END Calculate_Ordered_Quantity2;
19311 --   OPM 02/JUN/00 END of OPM added procedures
19312 
19313 */
19314 
19315 /*-----------------------------------------------------------
19316 PROCEDURE Pre_Attribute_Security
19317 ------------------------------------------------------------*/
19318 PROCEDURE Pre_Attribute_Security
19319 (   p_x_line_rec       IN OUT  NOCOPY OE_ORDER_PUB.Line_Rec_Type
19320 ,   p_old_line_rec        IN          OE_ORDER_PUB.Line_Rec_Type
19321 ,   p_index               IN          NUMBER
19322 ) IS
19323    l_return_status VARCHAR2(1);
19324 
19325    l_return_code           		NUMBER; -- INVCONV
19326    l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level; -- INVCONV
19327    l_qty number; -- INVCONV
19328    l_qty2 number; -- INVCONV
19329    l_ordered_qty number;  --nocopy impact changes
19330  BEGIN
19331 
19332 	if l_debug_level > 0 then -- INVCONV
19333   		oe_debug_pub.add('Entering Pre_Attribute_Security - reserved_quantity = ' || p_x_line_rec.reserved_quantity );
19334   end if;
19335 
19336       -- Added this code for Splits
19337       -- Need to send the rounded QTY for line if the
19338       -- Operations is Create and Split_From_Line_Id is not null or
19339       -- Operation is Update and action is split
19340       -- Bug #3705273
19341       IF (p_x_line_rec.split_action_code = 'SPLIT'
19342          AND p_x_line_rec.operation = oe_globals.g_opr_update
19343          )
19344       OR (p_x_line_rec.split_from_line_id is not null
19345          AND p_x_line_rec.split_from_line_id <> fnd_api.g_miss_num
19346          AND p_x_line_rec.operation = oe_globals.g_opr_create
19347          )
19348       THEN
19349         --Then you need to call the Quantity rounding API to round off the qty on the line
19350         l_ordered_qty :=  p_x_line_rec.ordered_quantity;  --nocopy impact changes
19351 	OE_Validate_Line.Validate_Decimal_Quantity
19352   	(p_item_id	    => p_x_line_rec.inventory_item_id
19353 	,p_item_type_code   => p_x_line_rec.item_type_code
19354 	,p_input_quantity   => l_ordered_qty                                      --nocopy impact changes
19355 	,p_uom_code         => p_x_line_rec.order_quantity_uom
19356         ,p_ato_line_id      => p_x_line_rec.ato_line_id
19357         ,p_line_id          => p_x_line_rec.line_id
19358         ,p_line_num         => p_x_line_rec.line_number
19359 	,p_action_split     => 'Y'
19360         ,x_output_quantity  => p_x_line_rec.ordered_quantity
19361 	,x_return_status    => l_return_status);
19362 
19363 	IF l_return_status = FND_API.G_RET_STS_ERROR THEN
19364           RAISE FND_API.G_EXC_ERROR;
19365         END IF;
19366       END IF;
19367       oe_debug_pub.add('PAS 2 Qty :'||p_x_line_rec.ordered_quantity);
19368 
19369       -- Populate Set Ids IF Set Names are given
19370       -- This will harcode the defaulting for schduling attributes
19371       -- THis is kept outside defaulting framework to handle cases
19372       -- Asd Default_attributes = FALSE
19373       -- Another call is for create time in defaulint to cover line_id
19374 
19375       -- As part of scheduling restructure. dependency will added with
19376       -- bug 2164440.
19377       --4504362 : Branch Scheduling check removed.
19378      -- OPM 02/JUN/00
19379 	   oe_line_util.Sync_Dual_Qty (p_x_line_rec => p_x_line_rec
19380 							 ,p_old_line_rec => p_old_line_rec);
19381      -- OPM 02/JUN/00 END
19382 -- INVCONV
19383  -- check this - why call here ??  need to know where to call in proper place - ask OM team
19384 
19385  --oe_debug_pub.add('reserved_quantity = ' || p_x_line_rec.reserved_quantity );
19386 -- oe_debug_pub.add('reserved_quantity2 = ' || p_x_line_rec.reserved_quantity2 );
19387              IF NOT(OE_GLOBALS.G_UI_FLAG) and -- 4958890
19388                p_x_line_rec.ordered_quantity <> FND_API.G_MISS_NUM And
19389                        p_x_line_rec.ordered_quantity IS NOT NULL and
19390                        p_x_line_rec.ordered_quantity2 <> FND_API.G_MISS_NUM And
19391                        p_x_line_rec.ordered_quantity2 IS NOT NULL and
19392                        p_x_line_rec.ordered_quantity_uom2 is not null  and
19393                        p_x_line_rec.ordered_quantity_uom2 <> FND_API.G_MISS_CHAR and
19394                       (  (  p_x_line_rec.reserved_quantity <> FND_API.G_MISS_NUM And
19395                        p_x_line_rec.reserved_quantity IS NOT NULL )
19396                       or (  p_x_line_rec.reserved_quantity2 <> FND_API.G_MISS_NUM And
19397                        p_x_line_rec.reserved_quantity2 IS NOT NULL ) )
19398                        Then
19399 
19400  		        							IF p_x_line_rec.reserved_quantity <> FND_API.G_MISS_NUM And
19401                             p_x_line_rec.reserved_quantity IS NOT NULL then
19402                                l_qty := p_x_line_rec.reserved_quantity;
19403 
19404                         	end if;
19405                         	IF p_x_line_rec.reserved_quantity2 <> FND_API.G_MISS_NUM And
19406                             p_x_line_rec.reserved_quantity2 IS NOT NULL then
19407                                l_qty2 := p_x_line_rec.reserved_quantity2;
19408 
19409                         	end if;
19410 
19411 
19412  					  							if l_debug_level > 0 then -- INVCONV
19413                 						oe_debug_pub.add('pre_attribute_security - about to call calculate_dual_quantity. l_qty = ' || l_qty);
19414                 						oe_debug_pub.add('pre_attribute_security - about to call calculate_dual_quantity. l_qty2 = ' || l_qty2);
19415                         	end if;
19416                         IF l_qty <>0 or
19417                            l_qty2 <> 0
19418                         then
19419 		 										oe_line_util.calculate_dual_quantity(
19420                          p_ordered_quantity => l_qty
19421                         ,p_old_ordered_quantity => NULL
19422                         ,p_ordered_quantity2 => l_qty2 -- p_x_line_rec.reserved_quantity2
19423                         ,p_old_ordered_quantity2 => NULL
19424                         ,p_ordered_quantity_uom  => p_x_line_rec.order_quantity_uom
19425                         ,p_ordered_quantity_uom2 => p_x_line_rec.ordered_quantity_uom2
19426                         ,p_inventory_item_id     => p_x_line_rec.inventory_item_id
19427                         ,p_ship_from_org_id      => p_x_line_rec.ship_from_org_id
19428                         ,x_ui_flag 		 => 0
19429                         ,x_return_status         => l_return_code
19430                         );
19431 
19432 
19433                         IF l_return_code <> 0 THEN -- INVCONV
19434 	     										 IF l_return_status = -1  or
19435 	     										    l_return_status = -99999
19436 	     										 THEN
19437 															p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
19438 															RAISE FND_API.G_EXC_ERROR;
19439 														else
19440 															p_x_line_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
19441 															RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
19442 
19443 														END IF;
19444 
19445 												ELSE
19446 												  p_x_line_rec.reserved_quantity2 := l_qty2;
19447 												  p_x_line_rec.reserved_quantity := l_qty;
19448 
19449 												END IF; --  IF l_return_code <> 0 THEN -- INVCONV
19450 
19451 
19452       									IF l_debug_level  > 0 THEN
19453        	  								oe_debug_pub.add('Pre_Attribute_Security after call to calculate_dual_quantity for reserved_quantities - return status = : ' || l_return_code);
19454 													oe_debug_pub.add('reserved_quantity =  : ' || p_x_line_rec.reserved_quantity);
19455 													oe_debug_pub.add('reserved_quantity2 = : ' || p_x_line_rec.reserved_quantity2);
19456 
19457    											END IF;
19458 
19459    											END IF;  -- IF l_qty <>0 then
19460 
19461     			END IF; -- INVCONV
19462 
19463 
19464 
19465 END Pre_Attribute_Security;
19466 
19467 
19468 /*---------------------------------------------------------------------
19469 Procedure Log_CTO_Requests
19470 
19471 This procedure is added only because code in pre_write is
19472 getting cluttered and there are many CTO chg order
19473 related requests which we will have in one place.
19474 We need to notify CTO
19475 1) for changes to ato model/options if config item exists.
19476 2) for ato item if it is scheduled.(both item_type = standard and option)
19477 3) in case of pto+ato, if new option is created and
19478    even 1 config item exist.
19479 ----------------------------------------------------------------------*/
19480 PROCEDURE Log_CTO_Requests
19481 (p_x_line_rec    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
19482 ,p_old_line_rec  IN             OE_Order_PUB.Line_Rec_Type :=
19483                                    OE_Order_PUB.G_MISS_LINE_REC
19484 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
19485 IS
19486   l_num                   NUMBER;
19487   l_flag                  BOOLEAN;
19488   l_notify_cto            BOOLEAN;
19489   l_ato_item_qty_change   BOOLEAN;
19490   l_pto_ato_create        BOOLEAN;
19491   l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
19492 BEGIN
19493  if l_debug_level > 0 then
19494   oe_debug_pub.add('entering Log_CTO_Requests', 1);
19495  end if;
19496 
19497   l_flag := FALSE;
19498 
19499   IF p_x_line_rec.ato_line_id is not NULL AND
19500      ((p_x_line_rec.schedule_status_code is NULL AND
19501        p_x_line_rec.operation = 'CREATE' ) OR
19502       (p_x_line_rec.schedule_ship_date is NOT NULL)) AND
19503      ((nvl(p_x_line_rec.split_action_code, 'X') <> 'SPLIT' OR
19504       (p_x_line_rec.split_action_code = FND_API.G_MISS_CHAR AND
19505        NOT (p_x_line_rec.split_from_line_id is NOT NULL))) OR
19506       OE_Code_Control.Code_Release_Level >= '110510')
19507   THEN
19508 
19509    if l_debug_level > 0 then
19510     oe_debug_pub.add('configuration scheduled', 5);
19511    end if;
19512 
19513     IF OE_Code_Control.Code_release_Level < '110510' THEN
19514 
19515       BEGIN
19516         SELECT line_id
19517         INTO   l_num
19518         FROM   oe_order_lines
19519         WHERE  ato_line_id = p_x_line_rec.ato_line_id
19520         AND    top_model_line_id = p_x_line_rec.top_model_line_id
19521         AND    item_type_code = OE_GLOBALS.G_ITEM_CONFIG;
19522 
19523         l_flag := TRUE;
19524       EXCEPTION
19525         WHEN NO_DATA_FOUND THEN
19526          if l_debug_level > 0 then
19527           oe_debug_pub.add('config item not yet created', 2);
19528          end if;
19529       END;
19530     ELSE
19531       l_flag := TRUE;
19532     END IF;
19533   ELSE
19534   if l_debug_level > 0 then
19535    oe_debug_pub.add('flag is false', 2);
19536   end if;
19537   END IF;
19538 
19539   l_ato_item_qty_change := FALSE;
19540 
19541   IF p_x_line_rec.ato_line_id = p_x_line_rec.line_id AND
19542      (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_STANDARD OR
19543       p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION) AND --##1820608
19544      p_old_line_rec.schedule_status_code is NOT NULL AND
19545      p_x_line_rec.operation <> OE_GLOBALS.G_OPR_CREATE
19546   THEN
19547     if l_debug_level > 0 then
19548      oe_debug_pub.add('ato item, may need to notify cto', 4);
19549     end if;
19550      l_flag := TRUE;
19551 
19552      IF p_x_line_rec.ordered_quantity = 0 AND
19553         p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
19554 
19555        if l_debug_level > 0 then
19556         oe_debug_pub.add('ato item qty made to 0'|| p_x_line_rec.open_flag, 4);
19557        end if;
19558         l_ato_item_qty_change := TRUE;
19559 
19560      END IF;
19561 
19562   END IF;
19563 
19564  if l_debug_level > 0 then
19565   oe_debug_pub.add('split?     : ' || p_x_line_rec.split_action_code, 3);
19566   oe_debug_pub.add('split from : ' || p_x_line_rec.split_from_line_id, 3);
19567   oe_debug_pub.add('line id:     ' || p_x_line_rec.line_id, 3);
19568   oe_debug_pub.add('ato line id: ' || p_x_line_rec.ato_line_id , 3);
19569   oe_debug_pub.add('item type:   ' || p_x_line_rec.item_type_code, 3);
19570   oe_debug_pub.add('operation:   ' || p_x_line_rec.operation, 3);
19571   oe_debug_pub.add('old qty:     ' || p_old_line_rec.ordered_quantity, 3);
19572   oe_debug_pub.add('new qty:     ' || p_x_line_rec.ordered_quantity, 3);
19573   oe_debug_pub.add('old ssd:     ' || p_old_line_rec.schedule_ship_date, 3);
19574   oe_debug_pub.add('new ssd:     ' || p_x_line_rec.schedule_ship_date, 3);
19575   oe_debug_pub.add('old rd:      ' || p_old_line_rec.request_date, 3);
19576   oe_debug_pub.add('new rd:      ' || p_x_line_rec.request_date, 3);
19577   oe_debug_pub.add('old sad:     ' || p_old_line_rec.schedule_arrival_date,3);
19578   oe_debug_pub.add('new sad:     ' || p_x_line_rec.schedule_arrival_date,3);
19579   oe_debug_pub.add('new sch sts: ' || p_x_line_rec.schedule_status_code,3);
19580   oe_debug_pub.add('old sch sts: ' || p_old_line_rec.schedule_status_code,3);
19581   oe_debug_pub.add('open flag:   ' || p_x_line_rec.open_flag,3);
19582   oe_debug_pub.add('cascade:     ' || oe_config_util.CASCADE_CHANGES_FLAG, 3);
19583   oe_debug_pub.add('validate:    ' || OE_CONFIG_PVT.OECFG_VALIDATE_CONFIG, 3);
19584   oe_debug_pub.add('ui:          ' || OE_CONFIG_UTIL.G_CONFIG_UI_USED, 3);
19585 
19586   oe_debug_pub.add('old qty2:     ' || p_old_line_rec.ordered_quantity2, 3); -- INVCONV
19587   oe_debug_pub.add('new qty2:     ' || p_x_line_rec.ordered_quantity2, 3);
19588   oe_debug_pub.add('old uom2:     ' || p_old_line_rec.ordered_quantity_uom2, 3); -- INVCONV
19589   oe_debug_pub.add('new uom2:     ' || p_x_line_rec.ordered_quantity_uom2, 3);
19590   oe_debug_pub.add('old uom:     ' || p_old_line_rec.order_quantity_uom, 3); -- INVCONV
19591   oe_debug_pub.add('new uom:     ' || p_x_line_rec.order_quantity_uom, 3);
19592 
19593 
19594   oe_debug_pub.add('ssd old' ||
19595   to_char (new_time (p_old_line_rec.schedule_ship_date, 'PST', 'EST'),
19596                                  'DD-MON-YY HH24:MI:SS'), 3);
19597   oe_debug_pub.add('ssd new' ||
19598   to_char (new_time (p_x_line_rec.schedule_ship_date, 'PST', 'EST'),
19599                                  'DD-MON-YY HH24:MI:SS'), 3);
19600  end if;
19601 
19602   l_notify_cto := FALSE;
19603 
19604   -- only for ATO models and ATO under PTO, all are oprn = update
19605 
19606   IF p_x_line_rec.ato_line_id = p_x_line_rec.line_id AND
19607      l_flag AND
19608      NOT (p_x_line_rec.split_from_line_id IS NOT NULL  AND
19609           p_x_line_rec.split_from_line_id <> FND_API.G_MISS_NUM AND
19610           p_x_line_rec.operation = 'CREATE') THEN
19611 
19612    if l_debug_level > 0 then
19613     oe_debug_pub.add('compare for ato model now', 3);
19614    end if;
19615 
19616     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_from_org_id,
19617                            p_old_line_rec.ship_from_org_id) THEN
19618 
19619      if l_debug_level > 0 then
19620       oe_debug_pub.add('cto_change logged for warehouse change', 3);
19621      end if;
19622       l_notify_cto := TRUE;
19623 
19624       OE_delayed_requests_Pvt.log_request
19625       (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
19626        p_entity_id              => p_x_line_rec.line_id,
19627        p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
19628        p_requesting_entity_id   => p_x_line_rec.line_id,
19629        p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
19630        p_request_unique_key1    => 'Warehouse',
19631        p_param1                 => p_old_line_rec.ship_from_org_id,
19632        p_param2                 => p_x_line_rec.ship_from_org_id,
19633        p_param3                 => p_x_line_rec.ato_line_id,
19634        x_return_status          => x_return_status);
19635 
19636     END IF;
19637 
19638     IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,
19639                             p_old_line_rec.ordered_quantity) THEN
19640 
19641      if l_debug_level > 0 then
19642       oe_debug_pub.add('cto_change logged for qty change', 3);
19643      end if;
19644 
19645       l_notify_cto := TRUE;
19646 
19647       OE_delayed_requests_Pvt.log_request
19648       (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
19649        p_entity_id              => p_x_line_rec.line_id,
19650        p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
19651        p_requesting_entity_id   => p_x_line_rec.line_id,
19652        p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
19653        p_request_unique_key1    => 'Quantity',
19654        p_param1                 => p_old_line_rec.ordered_quantity,
19655        p_param2                 => p_x_line_rec.ordered_quantity,
19656        p_param3                 => p_x_line_rec.ato_line_id,
19657        x_return_status          => x_return_status);
19658 
19659     END IF;
19660 
19661     IF NOT OE_GLOBALS.Equal(p_x_line_rec.request_date,
19662                             p_old_line_rec.request_date) THEN
19663 
19664      if l_debug_level > 0 then
19665       oe_debug_pub.add('cto_change logged for req date change', 3);
19666      end if;
19667       l_notify_cto := TRUE;
19668 
19669        OE_delayed_requests_Pvt.log_request
19670        (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
19671         p_entity_id              => p_x_line_rec.line_id,
19672         p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
19673         p_requesting_entity_id   => p_x_line_rec.line_id,
19674         p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
19675         p_request_unique_key1    => 'Req Date',
19676         p_param1                 => p_old_line_rec.request_date,
19677         p_param2                 => p_x_line_rec.request_date,
19678         p_param3                 => p_x_line_rec.ato_line_id,
19679         x_return_status          => x_return_status);
19680 
19681     END IF;
19682 
19683     IF NOT OE_GLOBALS.Equal(p_x_line_rec.schedule_ship_date,
19684                             p_old_line_rec.schedule_ship_date) AND
19685        NOT l_ato_item_qty_change
19686     THEN
19687 
19688      if l_debug_level > 0 then
19689       oe_debug_pub.add('cto_change logged for sch ship date change', 3);
19690      end if;
19691       l_notify_cto := TRUE;
19692 
19693       OE_delayed_requests_Pvt.log_request
19694        (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
19695         p_entity_id              => p_x_line_rec.line_id,
19696         p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
19697         p_requesting_entity_id   => p_x_line_rec.line_id,
19698         p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
19699         p_request_unique_key1    => 'Ship Date',
19700         p_param1                 => p_old_line_rec.schedule_ship_date,
19701         p_param2                 => p_x_line_rec.schedule_ship_date,
19702         p_param3                 => p_x_line_rec.ato_line_id,
19703         x_return_status          => x_return_status);
19704 
19705     END IF;
19706 
19707     IF NOT OE_GLOBALS.Equal(p_x_line_rec.schedule_arrival_date,
19708                             p_old_line_rec.schedule_arrival_date) AND
19709        NOT l_ato_item_qty_change THEN
19710 
19711      if l_debug_level > 0 then
19712       oe_debug_pub.add('cto_change logged for sch arr date change', 3);
19713      end if;
19714       l_notify_cto := TRUE;
19715 
19716       OE_delayed_requests_Pvt.log_request
19717        (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
19718         p_entity_id              => p_x_line_rec.line_id,
19719         p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
19720         p_requesting_entity_id   => p_x_line_rec.line_id,
19721         p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
19722         p_request_unique_key1    => 'Arr Date',
19723         p_param1                 => p_old_line_rec.schedule_arrival_date,
19724         p_param2                 => p_x_line_rec.schedule_arrival_date,
19725         p_param3                 => p_x_line_rec.ato_line_id,
19726         x_return_status          => x_return_status);
19727 
19728     END IF;
19729 
19730    -- INVCONV
19731 
19732      IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity2,
19733                             p_old_line_rec.ordered_quantity2) THEN
19734 
19735      if l_debug_level > 0 then
19736       oe_debug_pub.add('cto_change logged for qty2 change', 3);
19737      end if;
19738 
19739       l_notify_cto := TRUE;
19740 
19741       OE_delayed_requests_Pvt.log_request
19742       (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
19743        p_entity_id              => p_x_line_rec.line_id,
19744        p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
19745        p_requesting_entity_id   => p_x_line_rec.line_id,
19746        p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
19747        p_request_unique_key1    => 'Quantity2',
19748        p_param1                 => p_old_line_rec.ordered_quantity2,
19749        p_param2                 => p_x_line_rec.ordered_quantity2,
19750        p_param3                 => p_x_line_rec.ato_line_id,
19751        x_return_status          => x_return_status);
19752 
19753     END IF;
19754 
19755 		IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity_uom2,
19756                             p_old_line_rec.ordered_quantity_uom2) THEN
19757 
19758      if l_debug_level > 0 then
19759       oe_debug_pub.add('cto_change logged for Uom2 change', 3);
19760      end if;
19761 
19762       l_notify_cto := TRUE;
19763 
19764       OE_delayed_requests_Pvt.log_request
19765       (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
19766        p_entity_id              => p_x_line_rec.line_id,
19767        p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
19768        p_requesting_entity_id   => p_x_line_rec.line_id,
19769        p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
19770        p_request_unique_key1    => 'Uom2',
19771        p_param1                 => p_old_line_rec.ordered_quantity_uom2,
19772        p_param2                 => p_x_line_rec.ordered_quantity_uom2,
19773        p_param3                 => p_x_line_rec.ato_line_id,
19774        x_return_status          => x_return_status);
19775 
19776     END IF;
19777 
19778     IF NOT OE_GLOBALS.Equal(p_x_line_rec.order_quantity_uom,
19779                             p_old_line_rec.order_quantity_uom) THEN
19780 
19781      if l_debug_level > 0 then
19782       oe_debug_pub.add('cto_change logged for Uom change', 3);
19783      end if;
19784 
19785       l_notify_cto := TRUE;
19786 
19787       OE_delayed_requests_Pvt.log_request
19788       (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
19789        p_entity_id              => p_x_line_rec.line_id,
19790        p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
19791        p_requesting_entity_id   => p_x_line_rec.line_id,
19792        p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
19793        p_request_unique_key1    => 'Uom',
19794        p_param1                 => p_old_line_rec.order_quantity_uom,
19795        p_param2                 => p_x_line_rec.order_quantity_uom,
19796        p_param3                 => p_x_line_rec.ato_line_id,
19797        x_return_status          => x_return_status);
19798 
19799     END IF;
19800 -- INVCONV END
19801 
19802 
19803   ELSIF p_x_line_rec.ato_line_id = p_x_line_rec.line_id AND
19804         OE_Code_Control.Code_Release_Level >= '110510' AND
19805         p_x_line_rec.schedule_status_code is NULL AND
19806         p_x_line_rec.schedule_ship_date is NULL AND
19807         p_old_line_rec.schedule_ship_date is NOT NULL THEN
19808 
19809    if l_debug_level > 0 then
19810     oe_debug_pub.add('cto_change logged for unschedule', 3);
19811    end if;
19812 
19813     l_notify_cto := TRUE;
19814 
19815     OE_delayed_requests_Pvt.log_request
19816      (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
19817       p_entity_id              => p_x_line_rec.line_id,
19818       p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
19819       p_requesting_entity_id   => p_x_line_rec.line_id,
19820       p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
19821       p_request_unique_key1    => 'Ship Date',
19822       p_param1                 => p_old_line_rec.schedule_ship_date,
19823       p_param2                 => p_x_line_rec.schedule_ship_date,
19824       p_param3                 => p_x_line_rec.ato_line_id,
19825       x_return_status          => x_return_status);
19826 
19827   END IF; -- update on model line logged
19828 
19829   IF p_x_line_rec.ato_line_id is NOT NULL AND
19830      p_x_line_rec.ato_line_id <> p_x_line_rec.line_id AND
19831      p_x_line_rec.item_type_code <> OE_GLOBALS.G_ITEM_CONFIG AND
19832      ((oe_config_util.CASCADE_CHANGES_FLAG = 'N' AND
19833        OE_CONFIG_PVT.OECFG_VALIDATE_CONFIG = 'Y') OR
19834        OE_CONFIG_UTIL.G_CONFIG_UI_USED = 'Y') AND
19835      l_flag AND
19836      nvl(p_x_line_rec.split_action_code, 'X') <> 'SPLIT' AND -- split update
19837      NOT (p_x_line_rec.split_from_line_id is NOT NULL AND
19838           p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE) -- split create
19839   THEN
19840    if l_debug_level > 0 then
19841     oe_debug_pub.add('part of ato', 3);
19842    end if;
19843 
19844     l_pto_ato_create := FALSE;
19845 
19846     BEGIN
19847       SELECT 1
19848       INTO   l_num
19849       FROM   oe_order_lines
19850       WHERE  line_id = p_x_line_rec.top_model_line_id
19851       AND    top_model_line_id = nvl(ato_line_id, -1);
19852 
19853     EXCEPTION
19854       WHEN NO_DATA_FOUND THEN
19855 
19856         IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
19857          if l_debug_level > 0 then
19858           oe_debug_pub.add('pto top model and opr create', 1);
19859          end if;
19860           l_pto_ato_create := TRUE;
19861         END IF;
19862     END;
19863 
19864 
19865     IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
19866         NOT l_pto_ato_create) OR
19867        p_x_line_rec.operation = OE_GLOBALS.G_OPR_DELETE OR
19868        (p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
19869         NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,
19870                              p_old_line_rec.ordered_quantity))
19871 
19872     THEN
19873 
19874      if l_debug_level > 0 then
19875       oe_debug_pub.add('cto_change logged for config change', 3);
19876      end if;
19877 
19878       l_notify_cto := TRUE;
19879 
19880       OE_delayed_requests_Pvt.log_request
19881       (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
19882        p_entity_id              => p_x_line_rec.ato_line_id,
19883        p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
19884        p_requesting_entity_id   => p_x_line_rec.line_id,
19885        p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
19886        p_request_unique_key1    => 'Config Chg',
19887        p_param3                 => p_x_line_rec.ato_line_id,
19888        x_return_status          => x_return_status);
19889 
19890       IF p_x_line_rec.operation <> OE_GLOBALS.G_OPR_DELETE AND
19891          OE_Code_Control.Code_Release_Level >= '110510' THEN
19892 
19893        if l_debug_level > 0 then
19894         oe_debug_pub.add('cto_change logged for decimal change', 3);
19895        end if;
19896 
19897         OE_delayed_requests_Pvt.log_request
19898         (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
19899          p_entity_id              => p_x_line_rec.line_id,
19900          p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
19901          p_requesting_entity_id   => p_x_line_rec.line_id,
19902          p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
19903          p_request_unique_key1    => 'Decimal Chg',
19904          p_param1                 => p_x_line_rec.operation,
19905          p_param3                 => p_x_line_rec.ato_line_id,
19906          p_param4                 => p_x_line_rec.ordered_quantity,
19907          p_param5                 => p_old_line_rec.ordered_quantity,
19908          p_param6                 => p_x_line_rec.inventory_item_id,
19909          x_return_status          => x_return_status);
19910       END IF;
19911 
19912     END IF;
19913   ELSE
19914    if l_debug_level > 0 then
19915     oe_debug_pub.add('no need to log here', 3);
19916    end if;
19917   END IF;
19918 
19919   l_num := 0;
19920 
19921   IF p_x_line_rec.split_from_line_id is NOT NULL AND
19922      p_x_line_rec.operation = 'CREATE' AND
19923      OE_Code_Control.Code_Release_Level >= '110510' THEN
19924 
19925     IF p_x_line_rec.ato_line_id = p_x_line_rec.line_id AND
19926       (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
19927        p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_STANDARD OR
19928        p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION)THEN
19929        l_num := 1;
19930     END IF;
19931 
19932     IF p_x_line_rec.ato_line_id is NOT NULL AND
19933        p_x_line_rec.item_type_code = 'CLASS' THEN
19934 
19935       BEGIN
19936         SELECT 1
19937         INTO   l_num
19938         FROM   oe_order_lines
19939         WHERE  line_id = p_x_line_rec.split_from_line_id
19940         AND    ato_line_id = line_id
19941         AND    item_type_code = 'CLASS';
19942 
19943       EXCEPTION
19944         when no_data_found then
19945          if l_debug_level > 0 then
19946           oe_debug_pub.add('was not a ato model', 3);
19947          end if;
19948       END;
19949     END IF;
19950 
19951     IF l_num = 1 THEN
19952      if l_debug_level > 0 then
19953       oe_debug_pub.add('new split ato model '|| p_x_line_rec.line_id, 3);
19954      end if;
19955 
19956       OE_delayed_requests_Pvt.log_request
19957       (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
19958        p_entity_id              => p_x_line_rec.ato_line_id,
19959        p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
19960        p_requesting_entity_id   => p_x_line_rec.line_id,
19961        p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
19962        p_request_unique_key1    => 'Split Create',
19963        p_param3                 => p_x_line_rec.split_from_line_id,
19964        p_param4                 => p_x_line_rec.line_id,
19965        x_return_status          => x_return_status);
19966     END IF;
19967 
19968   END IF;
19969 
19970   IF l_notify_cto THEN
19971 
19972    if l_debug_level > 0 then
19973     oe_debug_pub.add('notify_cto logged', 3);
19974    end if;
19975 
19976     OE_delayed_requests_Pvt.log_request
19977     (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
19978      p_entity_id              => p_x_line_rec.ato_line_id,
19979      p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
19980      p_requesting_entity_id   => p_x_line_rec.ato_line_id,
19981      p_request_type           => OE_GLOBALS.G_CTO_NOTIFICATION,
19982      x_return_status          => x_return_status);
19983   END IF;
19984 
19985 
19986   -- for a pto-ato create case
19987   -- as per bug 1650811, we call cto for any new create if 1 config exists.
19988   -- now ato_line_id is set indefaulting, but may be incorrect
19989   -- for a class line till validate config
19990 
19991   l_flag := FALSE;
19992   IF l_pto_ato_create AND    --6873069
19993      ((p_x_line_rec.schedule_status_code is NULL AND
19994        p_x_line_rec.operation = 'CREATE' ) OR
19995       (p_x_line_rec.schedule_ship_date is NOT NULL)) THEN
19996 
19997     IF OE_Code_Control.Code_Release_Level < '110510' THEN
19998       BEGIN
19999         SELECT line_id
20000         INTO   l_num
20001         FROM   oe_order_lines
20002         WHERE  top_model_line_id = p_x_line_rec.top_model_line_id
20003         AND    item_type_code = OE_GLOBALS.G_ITEM_CONFIG;
20004 
20005         l_flag := TRUE;
20006       EXCEPTION
20007         WHEN NO_DATA_FOUND THEN
20008          if l_debug_level > 0 then
20009           oe_debug_pub.add('config item not yet created', 2);
20010          end if;
20011         WHEN TOO_MANY_ROWS THEN
20012          if l_debug_level > 0 then
20013           oe_debug_pub.add('many config items', 2);
20014          end if;
20015           l_flag := TRUE;
20016       END;
20017     ELSE
20018       l_flag := TRUE;
20019     END IF;
20020   ELSE
20021    if l_debug_level > 0 then
20022     oe_debug_pub.add('not pto/ato config create, flag false', 2);
20023    end if;
20024   END IF;
20025 
20026 
20027   IF l_flag THEN
20028    if l_debug_level > 0 then
20029     oe_debug_pub.add('pto ato and config exist'|| p_x_line_rec.line_id, 2);
20030    end if;
20031 
20032     OE_delayed_requests_Pvt.log_request
20033     (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
20034      p_entity_id              => p_x_line_rec.line_id,
20035      p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
20036      p_requesting_entity_id   => p_x_line_rec.line_id,
20037      p_request_type           => OE_GLOBALS.G_CTO_CHANGE,
20038      p_request_unique_key1    => 'Config Chg pto_ato',
20039      p_param3                 => p_x_line_rec.top_model_line_id,
20040      p_param2                 => 'Y',
20041      p_param4                 => p_x_line_rec.line_id,
20042      p_param5                 => p_x_line_rec.ato_line_id,
20043      x_return_status          => x_return_status);
20044 
20045     OE_delayed_requests_Pvt.log_request
20046     (p_entity_code            => OE_GLOBALS.G_ENTITY_ALL,
20047      p_entity_id              => p_x_line_rec.top_model_line_id,
20048      p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
20049      p_requesting_entity_id   => p_x_line_rec.top_model_line_id,
20050      p_request_type           => OE_GLOBALS.G_CTO_NOTIFICATION,
20051      x_return_status          => x_return_status);
20052 
20053   END IF;
20054 
20055  if l_debug_level > 0 then
20056   oe_debug_pub.add('leaving Log_CTO_Requests', 1);
20057  end if;
20058 EXCEPTION
20059   WHEN OTHERS THEN
20060    if l_debug_level > 0 then
20061     oe_debug_pub.add('exception in Log_CTO_Requests'|| sqlerrm, 1);
20062    end if;
20063     RAISE;
20064 END Log_CTO_Requests;
20065 
20066 
20067 /*---------------------------------------------------------------------
20068 Procedure Log_Config_Requests
20069 
20070 This procedure is added only because code in pre_write is
20071 getting cluttered and there are many Configurations
20072 related requests which we will have in one place.
20073 
20074 requests logged.
20075 1) validate configuration.
20076      Log the delayed request to Validate the Configuration
20077      if an option or class is deleted.
20078      no need not consider split in case of deletes.
20079 
20080      Log the delayed request to Validate the Configuration
20081      if an option or class is updated or created or model
20082      is created.
20083 
20084 2) copy configuration.
20085      Log a copy config request if model/kit is proportionally split.
20086 
20087 Change Record:
20088 bug 2075105: the delete_option request will be looged against
20089 top model line with request_unique_key of line_id.
20090 ----------------------------------------------------------------------*/
20091 
20092 PROCEDURE Log_Config_Requests
20093 (p_x_line_rec    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
20094 ,p_old_line_rec  IN             OE_Order_PUB.Line_Rec_Type :=
20095                                    OE_Order_PUB.G_MISS_LINE_REC
20096 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
20097 IS
20098   l_flag                  BOOLEAN;
20099   l_cancellation          VARCHAR2(1);
20100   l_config_header_id      NUMBER;
20101   l_config_rev_nbr        NUMBER;
20102   l_configuration_id      NUMBER;
20103   l_model_open_flag       VARCHAR2(1) := 'Y';
20104   l_fulfilled_flag        VARCHAR2(1) := 'N';
20105   l_model_item            VARCHAR2(2000);
20106   l_config_rev_change     VARCHAR2(1) := 'N';
20107   l_ord_item              VARCHAR2(2000);
20108   l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
20109 BEGIN
20110  if l_debug_level > 0 then
20111   oe_debug_pub.add('entering Log_Config_Requests', 1);
20112  end if;
20113 
20114 
20115   ------------------------ copy for model split -------------
20116 
20117   IF p_x_line_rec.top_model_line_id = p_x_line_rec.line_id AND
20118     p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
20119     p_x_line_rec.split_from_line_id is not null  -- split
20120   THEN
20121 
20122    if l_debug_level > 0 then
20123     oe_debug_pub.add
20124     ('split_from_line_id: '|| p_x_line_rec.split_from_line_id, 1);
20125     oe_debug_pub.add('new model: '|| p_x_line_rec.line_id, 1);
20126    end if;
20127 
20128     BEGIN
20129       SELECT config_header_id, config_rev_nbr, configuration_id
20130       INTO   l_config_header_id,l_config_rev_nbr, l_configuration_id
20131       FROM   oe_order_lines
20132       WHERE  line_id = p_x_line_rec.split_from_line_id;
20133     EXCEPTION
20134       WHEN no_data_found THEN
20135        if l_debug_level > 0 then
20136         oe_debug_pub.add('Parent model is not validated', 1);
20137        end if;
20138         -- should we raise exception??
20139     END;
20140 
20141    if l_debug_level > 0 then
20142     oe_debug_pub.add('Logging a request after spllit
20143                       to copy the configuration in SPC', 1);
20144    end if;
20145     OE_Delayed_Requests_Pvt.Log_Request(
20146                p_entity_code             =>   OE_GLOBALS.G_ENTITY_LINE,
20147                p_entity_id               =>   p_x_line_rec.line_id,
20148                p_requesting_entity_code  =>   OE_GLOBALS.G_ENTITY_LINE,
20149                p_requesting_entity_id    =>   p_x_line_rec.line_id,
20150                p_request_type            =>   OE_GLOBALS.G_COPY_CONFIGURATION,
20151                p_param1                  =>   l_config_header_id,
20152                p_param2                  =>   l_config_rev_nbr,
20153                p_param3                  =>   p_x_line_rec.model_remnant_flag,
20154                p_param4                  =>   l_configuration_id,
20155                x_return_status           =>   x_return_status);
20156 
20157   END IF;
20158 
20159   if l_debug_level > 0 then
20160    oe_debug_pub.add('after copy config request ', 3);
20161   end if;
20162 
20163   -------------------------- copy config done -----------------------
20164 
20165 
20166   IF nvl(p_x_line_rec.model_remnant_flag, 'N') = 'Y'  THEN
20167    if l_debug_level > 0 then
20168     oe_debug_pub.add('returning from log_config as remnant', 1);
20169    end if;
20170     RETURN;
20171   END IF;
20172 
20173   IF p_x_line_rec.line_id <> p_x_line_rec.top_model_line_id THEN
20174     SELECT open_flag, ordered_item, fulfilled_flag
20175     INTO   l_model_open_flag, l_model_item, l_fulfilled_flag
20176     FROM   oe_order_lines
20177     WHERE  line_id = p_x_line_rec.top_model_line_id;
20178   END IF;
20179 
20180   ---------------------- deletes ----------------------------------
20181 
20182   IF(p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION OR
20183      p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
20184     (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT AND
20185      p_x_line_rec.line_id <> p_x_line_rec.top_model_line_id)) AND
20186      p_x_line_rec.operation = OE_GLOBALS.G_OPR_DELETE AND
20187      OE_CONFIG_PVT.OECFG_VALIDATE_CONFIG = 'Y' THEN
20188 
20189      IF l_model_open_flag = 'N' THEN
20190        FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_MODEL_CLOSED');
20191        FND_MESSAGE.Set_Token('MODEL', l_model_item);
20192        OE_MSG_PUB.Add;
20193       if l_debug_level > 0 then
20194        oe_debug_pub.add('model line is closed', 1);
20195       end if;
20196        RAISE FND_API.G_EXC_ERROR;
20197      END IF;
20198 
20199      IF l_fulfilled_flag  = 'Y' THEN
20200        FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_MODEL_FULFILLED');
20201        FND_MESSAGE.Set_Token('MODEL', l_model_item);
20202        OE_MSG_PUB.Add;
20203       if l_debug_level > 0 then
20204        oe_debug_pub.add('model line is fulfilled', 1);
20205       end if;
20206        RAISE FND_API.G_EXC_ERROR;
20207      END IF;
20208 
20209     if l_debug_level > 0 then
20210      oe_debug_pub.add('Logging a request to validate configuration  ', 1);
20211     end if;
20212 
20213      OE_delayed_requests_Pvt.log_request(
20214             p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
20215             p_entity_id              => p_x_line_rec.top_model_line_id,
20216             p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
20217             p_requesting_entity_id   => p_x_line_rec.line_id,
20218             p_request_type           => OE_GLOBALS.G_VALIDATE_CONFIGURATION,
20219             x_return_status          => x_return_status);
20220 
20221     if l_debug_level > 0 then
20222      oe_debug_pub.add('Logging a request to delete option from oe/spc', 1);
20223     end if;
20224 
20225      OE_Delayed_Requests_Pvt.Log_Request(
20226             p_entity_code             =>   OE_GLOBALS.G_ENTITY_LINE,
20227             p_entity_id               =>   p_x_line_rec.top_model_line_id,
20228             p_requesting_entity_code  =>   OE_GLOBALS.G_ENTITY_LINE,
20229             p_requesting_entity_id    =>   p_x_line_rec.line_id,
20230             p_request_unique_key1     =>   p_x_line_rec.line_id,
20231             p_request_type            =>   OE_GLOBALS.G_DELETE_OPTION,
20232             p_param1                  =>   p_x_line_rec.top_model_line_id,
20233             p_param2                  =>   p_x_line_rec.component_code,
20234             p_param3                  =>   p_x_line_rec.item_type_code,
20235             p_param9                  =>   p_x_line_rec.configuration_id,
20236             p_param10                 =>   p_x_line_rec.ordered_item, -- 3563690
20237             x_return_status           =>   x_return_status);
20238 
20239   END IF;
20240 
20241 
20242 
20243   ---------------- update/create-------------------------------------
20244 
20245  if l_debug_level > 0 then
20246   oe_debug_pub.add('item_type_code: '||p_x_line_rec.item_type_code, 1);
20247   oe_debug_pub.add('validate flag: '||OE_CONFIG_PVT.OECFG_VALIDATE_CONFIG, 1);
20248  end if;
20249 
20250   l_flag := FALSE;
20251 
20252   IF p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL AND
20253      p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE      AND
20254      p_x_line_rec.booked_flag = 'Y' THEN
20255     if l_debug_level > 0 then
20256      oe_debug_pub.add('setting flag to true for model', 1);
20257     end if;
20258      l_flag := TRUE;
20259   END IF;
20260 
20261   IF (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION OR
20262       p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
20263      (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT AND
20264       p_x_line_rec.line_id <> p_x_line_rec.top_model_line_id)) AND
20265       NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,
20266                            p_old_line_rec.ordered_quantity )
20267   THEN
20268    if l_debug_level > 0 then
20269     oe_debug_pub.add('set flag to true'|| p_old_line_rec.ordered_quantity, 1);
20270     oe_debug_pub.add('new qty ' || p_x_line_rec.ordered_quantity, 1);
20271    end if;
20272     l_flag := TRUE;
20273   END IF;
20274 
20275    IF  p_x_line_rec.line_id = p_x_line_rec.top_model_line_id AND
20276        NOT OE_GLOBALS.Equal(p_x_line_rec.config_rev_nbr,
20277                             p_old_line_rec.config_rev_nbr)
20278   THEN
20279    if l_debug_level > 0 then
20280     oe_debug_pub.add('set flag to true, old rev '|| p_old_line_rec.config_rev_nbr, 1);
20281     oe_debug_pub.add('new rev ' || p_x_line_rec.config_rev_nbr, 1);
20282    end if;
20283     l_config_rev_change := 'Y';
20284     l_flag := TRUE;
20285   END IF;
20286 
20287   IF l_flag AND OE_CONFIG_PVT.OECFG_VALIDATE_CONFIG = 'Y' THEN
20288 
20289     if l_debug_level > 0 then
20290      oe_debug_pub.add('p_x_line_rec.operation' || p_x_line_rec.operation, 1);
20291      oe_debug_pub.add
20292      ('Split_from_line_id: '||p_x_line_rec.split_from_line_id ,3);
20293      oe_debug_pub.add
20294      ('Split_action_code: '|| p_x_line_rec.split_action_code ,3);
20295     end if;
20296 
20297 
20298      -- in case of splits, we dont want to batch validate
20299 
20300      IF  p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
20301          p_x_line_rec.split_from_line_id is not null
20302      THEN
20303         if l_debug_level > 0 then
20304          oe_debug_pub.add('This is a new model after split', 1);
20305         end if;
20306 
20307      ELSIF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
20308          nvl(p_x_line_rec.split_action_code, 'X') = 'SPLIT'
20309      THEN
20310         if l_debug_level > 0 then
20311          oe_debug_pub.add('This is a parent split model', 1);
20312         end if;
20313 
20314      ELSE
20315          -- If we got here, it means this isn't a split.
20316         if l_debug_level > 0 then
20317          oe_debug_pub.add('Logging a request to validate configuration',1);
20318         end if;
20319 
20320          IF l_model_open_flag = 'N' THEN
20321            FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_MODEL_CLOSED');
20322            FND_MESSAGE.Set_Token('MODEL', l_model_item);
20323            OE_MSG_PUB.Add;
20324           if l_debug_level > 0 then
20325            oe_debug_pub.add('model line is closed', 1);
20326           end if;
20327            RAISE FND_API.G_EXC_ERROR;
20328          END IF;
20329 
20330          IF l_fulfilled_flag  = 'Y' THEN
20331            FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_MODEL_FULFILLED');
20332            FND_MESSAGE.Set_Token('MODEL', l_model_item);
20333            OE_MSG_PUB.Add;
20334           if l_debug_level > 0 then
20335            oe_debug_pub.add('model line is fulfilled', 1);
20336           end if;
20337            RAISE FND_API.G_EXC_ERROR;
20338          END IF;
20339 
20340          -- 2917547 starts
20341          IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
20342             p_x_line_rec.ordered_quantity = 0 THEN
20343 
20344            IF p_x_line_rec.ordered_item IS NULL OR
20345               p_x_line_rec.ordered_item = fnd_api.g_miss_char THEN
20346              l_ord_item := p_x_line_rec.inventory_item_id;
20347            ELSE
20348              l_ord_item := p_x_line_rec.ordered_item;
20349            END IF;
20350 
20351            FND_MESSAGE.Set_Name('ONT', 'OE_ZERO_CHILD_QTY');
20352            FND_MESSAGE.Set_Token('ITEM', l_ord_item);
20353            OE_MSG_PUB.Add;
20354 
20355            IF l_debug_level > 0 THEN
20356              oe_debug_pub.add
20357              ('Child lines with zero qty can not be created', 1);
20358            END IF;
20359            RAISE FND_API.G_EXC_ERROR;
20360          END IF;
20361 
20362          OE_delayed_requests_Pvt.log_request(
20363             p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
20364             p_entity_id              => p_x_line_rec.top_model_line_id,
20365             p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
20366             p_requesting_entity_id   => p_x_line_rec.line_id,
20367             p_request_type           => OE_GLOBALS.G_VALIDATE_CONFIGURATION,
20368             x_return_status          => x_return_status);
20369 
20370          -- log only if operation is update and not for create
20371          IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
20372             l_config_rev_change = 'N' THEN
20373 
20374            if l_debug_level > 0 then
20375             oe_debug_pub.add('Logging a request to update configuration', 1);
20376            end if;
20377 
20378             l_cancellation := 'N';
20379 
20380             IF OE_Sales_Can_Util.G_Require_Reason THEN
20381              if l_debug_level > 0 then
20382               oe_debug_pub.add('this is a cancellation', 1);
20383              end if;
20384               l_cancellation := 'Y';
20385             ELSE
20386              if l_debug_level > 0 then
20387               oe_debug_pub.add('this is not a cancellation', 1);
20388              end if;
20389             END IF;
20390 
20391            if l_debug_level > 0 then
20392             oe_debug_pub.add
20393             (p_x_line_rec.item_type_code || p_x_line_rec.ordered_quantity, 1);
20394            end if;
20395 
20396             OE_Delayed_Requests_Pvt.Log_Request(
20397                p_entity_code             =>   OE_GLOBALS.G_ENTITY_LINE,
20398                p_entity_id               =>   p_x_line_rec.line_id,
20399                p_requesting_entity_code  =>   OE_GLOBALS.G_ENTITY_LINE,
20400                p_requesting_entity_id    =>   p_x_line_rec.line_id,
20401                p_request_type            =>   OE_GLOBALS.G_UPDATE_OPTION,
20402                p_param1                  =>   p_x_line_rec.top_model_line_id,
20403                p_param2                  =>   p_x_line_rec.component_code,
20404                p_param3                  =>   p_x_line_rec.item_type_code,
20405                p_param4                  =>   p_old_line_rec.ordered_quantity,
20406                p_param5                  =>   p_x_line_rec.ordered_quantity,
20407                p_param6                  =>   p_x_line_rec.change_reason,
20408                p_param7                  =>   p_x_line_rec.change_comments,
20409                p_param8                  =>   l_cancellation,
20410                p_param9                  =>   p_x_line_rec.configuration_id,
20411                x_return_status           =>   x_return_status);
20412 
20413          END IF; -- end of update.
20414 
20415       END IF;  -- end of split check.
20416 
20417   END IF;
20418 
20419  if l_debug_level > 0 then
20420   oe_debug_pub.add('leaving Log_Config_Requests', 1);
20421  end if;
20422 EXCEPTION
20423   WHEN OTHERS THEN
20424    if l_debug_level > 0 then
20425     oe_debug_pub.add('exception in Log_Config_Requests'|| sqlerrm, 1);
20426    end if;
20427     RAISE;
20428 END Log_Config_Requests;
20429 
20430 
20431 /*----------------------------------------------------------------------
20432 Procedure Log_Cascade_Requests
20433 
20434 
20435 1) cascading.
20436      Log the delayed request to Cascade Changes if any of the cascading
20437      relevant attribute has changes on the model.
20438 
20439      only from the top model/ top kit
20440        ordered_quantity
20441 
20442      for top model / top kit / ato sub config
20443        project_id
20444        task_id
20445        ship_tolerance_above
20446        ship_tolerance_below
20447 
20448      for non smc pto top model / top kit
20449        ship_to_org_id
20450        request_date
20451 
20452      for top ato model only
20453        shipped_quantity
20454        actual_shipment_date (in ucfgb)
20455 
20456 2) change configuration.
20457      change in warehouse of an ato model, smc pto, or ato subconfig
20458      cascade only if configuration was not scheduled.
20459      If it was scheduled, scheduling will take care of cascading.
20460 
20461      only for non scheduled lines which are part of
20462      top ato and ato subconfig / smc
20463        ship_to_org_id
20464        ship_from_org_id
20465 
20466      lines which are part of top ato and ato subconfig / smc
20467        request_date
20468 
20469 3) modify included items.
20470      when a class/kit under a pto model, is odified, we need to modify
20471      the included items under it. We use a global table here to capture the
20472      old and new qty, operation, reason and commet. This table is used in the
20473      post_lines process to modify the included items. We did not use a delayed
20474      reuest because we need to capture the old and new qty per class and
20475      it needs 3 types of requests, ex: validate configuration req to do that.
20476 
20477 ----------------------------------------------------------------------*/
20478 
20479 PROCEDURE Log_Cascade_Requests
20480 (p_x_line_rec    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
20481 ,p_old_line_rec  IN             OE_Order_PUB.Line_Rec_Type :=
20482                                    OE_Order_PUB.G_MISS_LINE_REC
20483 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
20484 IS
20485   l_param1                VARCHAR2(2000):= FND_API.G_MISS_NUM;
20486   l_param2                VARCHAR2(240) := FND_API.G_MISS_NUM;
20487   l_param3                VARCHAR2(240) := null;
20488   l_param4                VARCHAR2(2000):= null;    --4495205
20489   l_param5                VARCHAR2(240) := FND_API.G_MISS_NUM;
20490   l_param6                VARCHAR2(240) := FND_API.G_MISS_NUM;
20491   l_param7                VARCHAR2(240) := FND_API.G_MISS_CHAR;
20492   l_param8                VARCHAR2(240) := FND_API.G_MISS_NUM;
20493   l_param9                VARCHAR2(240) := FND_API.G_MISS_NUM;
20494   l_param10               VARCHAR2(240) := null;
20495   l_param11               VARCHAR2(240) := FND_API.G_MISS_NUM;
20496   l_param12               VARCHAR2(240) := FND_API.G_MISS_NUM;
20497   l_param14               VARCHAR2(240) := FND_API.G_MISS_NUM;
20498 /* Added the following variable to fix the bug 2217336 */
20499   l_param16               VARCHAR2(240) := FND_API.G_MISS_CHAR;
20500   l_date_param1           DATE          := FND_API.G_MISS_DATE;
20501   l_date_param2           DATE          := FND_API.G_MISS_DATE;
20502   l_num                   NUMBER;
20503   l_cancellation          VARCHAR2(1);
20504   l_cascade_changes       BOOLEAN := FALSE;
20505   l_change_configuration  BOOLEAN := FALSE;
20506   l_modify_included_items BOOLEAN := FALSE;
20507   l_return_status         VARCHAR2(1);
20508   l_entity_id             NUMBER;
20509   l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
20510 BEGIN
20511  if l_debug_level > 0 then
20512   oe_debug_pub.add('entering Log_Cascade_Requests', 1);
20513  end if;
20514 
20515   -------- cascading from parent to child only -------------
20516 
20517 
20518   IF OE_CONFIG_UTIL.G_CONFIG_UI_USED = 'N' AND
20519      OE_CONFIG_UTIL.CASCADE_CHANGES_FLAG = 'N'  AND
20520      p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
20521      nvl(p_x_line_rec.split_action_code, 'X') <> 'SPLIT'
20522   THEN
20523     -- 1. change in ordered qty of model/kit
20524     --    at subconfig cascade qty is actually in validate_config
20525 
20526     IF p_x_line_rec.top_model_line_id = p_x_line_rec.line_id
20527     THEN
20528 
20529       IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,
20530                               p_old_line_rec.ordered_quantity) AND
20531          OE_Config_Util.G_Config_UI_Used = 'N'
20532       THEN
20533         l_param1 := p_old_line_rec.ordered_quantity;
20534         l_param2 := p_x_line_rec.ordered_quantity;
20535         l_param3 := p_x_line_rec.change_reason;
20536         l_param4 := p_x_line_rec.change_comments;
20537 
20538        if l_debug_level > 0 then
20539         oe_debug_pub.add('ordered qty of model/kit changed:' ||l_param2,1);
20540        end if;
20541 
20542         l_cascade_changes := TRUE;
20543 
20544       END IF;
20545 
20546     END IF;
20547 
20548 
20549     -- 2. change in project and task of model/ ato subconfig
20550 
20551     IF  p_x_line_rec.top_model_line_id = p_x_line_rec.line_id OR -- model/kit
20552        (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS AND
20553         p_x_line_rec.line_id = p_x_line_rec.ato_line_id) -- ato subconfig
20554     THEN
20555 
20556       IF NOT OE_GLOBALS.Equal(p_x_line_rec.project_id,
20557                               p_old_line_rec.project_id)
20558       THEN
20559         l_param5 := p_x_line_rec.project_id;
20560        if l_debug_level > 0 then
20561         oe_debug_pub.add('model/ATO sub,project_id changed: '||l_param5,1);
20562        end if;
20563         l_cascade_changes := TRUE;
20564       END IF;
20565 
20566       IF NOT OE_GLOBALS.Equal(p_x_line_rec.task_id,p_old_line_rec.task_id)
20567       THEN
20568         l_param6 := p_x_line_rec.task_id;
20569        if l_debug_level > 0 then
20570         oe_debug_pub.add('model /ATO sub,task_id changed: '||l_param6,1);
20571        end if;
20572         l_cascade_changes := TRUE;
20573       END IF;
20574 
20575 
20576       -- 3. cascade change in ship_tolerance_above and ship_tolerance_above
20577       -- at the model level to all the options.
20578 
20579       IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_tolerance_above,
20580                               p_old_line_rec.ship_tolerance_above)
20581       THEN
20582         l_param11 := p_x_line_rec.ship_tolerance_above;
20583         l_cascade_changes := TRUE;
20584       END IF;
20585 
20586       IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_tolerance_below,
20587                               p_old_line_rec.ship_tolerance_below)
20588       THEN
20589         l_param12 := p_x_line_rec.ship_tolerance_below;
20590         l_cascade_changes := TRUE;
20591       END IF;
20592     END IF;
20593 
20594 
20595     -- 4. cascade request_date and ship_to_org_id, this should be done
20596     --    only in case of nonsmc pto model/kit, rest is handled in
20597     --    change_configuration request.
20598 
20599     IF  p_x_line_rec.top_model_line_id = p_x_line_rec.line_id AND
20600         nvl(p_x_line_rec.ship_model_complete_flag, 'N') = 'N' AND
20601         p_x_line_rec.ato_line_id IS NULL
20602     THEN
20603       IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_to_org_id,
20604                               p_old_line_rec.ship_to_org_id)
20605       THEN
20606         l_param14 := p_x_line_rec.ship_to_org_id;
20607         l_cascade_changes := TRUE;
20608       END IF;
20609 
20610       IF NOT OE_GLOBALS.Equal(p_x_line_rec.request_date,
20611                               p_old_line_rec.request_date)
20612       THEN
20613         l_date_param1 := p_x_line_rec.request_date;
20614         l_cascade_changes := TRUE;
20615       END IF;
20616 
20617     END IF;
20618 
20619 
20620     -- 5. change in shipped qty of ato model, specifically for top most ato.
20621 
20622     IF  p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL AND
20623         p_x_line_rec.ato_line_id IS NOT NULL
20624     THEN
20625 
20626       IF NOT OE_GLOBALS.Equal(p_x_line_rec.shipped_quantity,
20627                              p_old_line_rec.shipped_quantity)
20628       THEN
20629         l_param9  := to_char(p_x_line_rec.shipped_quantity);
20630        if l_debug_level > 0 then
20631         oe_debug_pub.add
20632         ('model / ATO subconfig, shipped quantity changed: '||l_param9,1);
20633        end if;
20634 
20635         l_cascade_changes := TRUE;
20636       END IF;
20637 
20638     END IF;
20639 
20640 
20641     -- 6. cascade source_type for ATO configurations.
20642 
20643     IF  p_x_line_rec.line_id = p_x_line_rec.ato_line_id AND
20644        (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
20645         p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS )
20646     THEN
20647 
20648       IF NOT OE_GLOBALS.Equal(p_x_line_rec.source_type_code,
20649                               p_old_line_rec.source_type_code)
20650       THEN
20651         l_param7 := p_x_line_rec.source_type_code;
20652        if l_debug_level > 0 then
20653         oe_debug_pub.add('ATO cascade source type '|| l_param7,1);
20654        end if;
20655         l_cascade_changes := TRUE;
20656       END IF;
20657 
20658     END IF;
20659 
20660 
20661     -- 7. Cascade change in freight_term_code
20662     --    added this code to fix the bug 2217336
20663 
20664     IF (  p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL  OR
20665           p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT )
20666     THEN
20667 
20668       IF NOT OE_GLOBALS.Equal(p_x_line_rec.freight_terms_code,
20669                               p_old_line_rec.freight_terms_code)
20670       THEN
20671         l_param16  := p_x_line_rec.freight_terms_code;
20672 
20673        if l_debug_level > 0 then
20674         oe_debug_pub.add
20675         ('Freight term code changed: '||l_param16,1);
20676        end if;
20677 
20678         l_cascade_changes := TRUE;
20679       END IF;
20680 
20681     END IF;
20682 
20683      -- 8. Cascade change in promise date
20684 
20685     IF (  p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL  OR
20686           p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT )
20687     THEN
20688 
20689       IF NOT OE_GLOBALS.Equal(p_x_line_rec.promise_date,
20690                               p_old_line_rec.promise_date)
20691       THEN
20692         l_date_param2  := p_x_line_rec.promise_date;
20693 
20694        if l_debug_level > 0 then
20695         oe_debug_pub.add('Promise date changed: '||l_date_param2,1);
20696        end if;
20697 
20698         l_cascade_changes := TRUE;
20699       END IF;
20700 
20701     END IF;
20702 
20703 
20704     -- log a request only if not a split
20705 
20706    if l_debug_level > 0 then
20707     oe_debug_pub.add
20708     ('CASCADE_CHANGES_FLAG, N means cascade : '
20709      ||OE_CONFIG_UTIL.CASCADE_CHANGES_FLAG, 1);
20710    end if;
20711 
20712 
20713     IF l_cascade_changes THEN
20714      if l_debug_level > 0 then
20715       oe_debug_pub.add('Logging Request to Cascade changes',1);
20716       oe_debug_pub.add('Item Type is: ' || p_x_line_rec.item_type_code,3);
20717       oe_debug_pub.add('Comp Code is: ' || p_x_line_rec.component_code,3);
20718      end if;
20719 
20720       l_cancellation := 'N';
20721       IF OE_Sales_Can_Util.G_Require_Reason THEN
20722        if l_debug_level > 0 then
20723         oe_debug_pub.add('this is a cancellation', 1);
20724        end if;
20725         l_cancellation := 'Y';
20726       END IF;
20727 
20728       OE_delayed_requests_Pvt.log_request(
20729         p_entity_code            => OE_GLOBALS.G_ENTITY_LINE,
20730         p_entity_id              => p_x_line_rec.line_id,
20731         p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
20732         p_requesting_entity_id   => p_x_line_rec.line_id,
20733         p_request_type           => OE_GLOBALS.G_CASCADE_CHANGES,
20734         p_param1                 => l_param1,   -- old old qty
20735         p_param2                 => l_param2,   -- new ord qty
20736         p_param3                 => l_param3,   -- chg reason
20737         p_param4                 => l_param4,   -- chg comment
20738         p_param5                 => l_param5,   -- proj id
20739         p_param6                 => l_param6,   -- task id
20740         p_param7                 => p_x_line_rec.item_type_code,
20741         p_param9                 => l_param9,   -- ship qty
20742         p_param10                => l_param10,  -- warehouse
20743         p_param11                => l_param11,  -- Ship tol above
20744         p_param12                => l_param12,  -- Ship tol below
20745         p_param13                => l_cancellation,
20746         p_param14                => l_param14,  -- ship to org id
20747         p_param15                => l_param7,   -- source_type_code
20748         p_param16                => l_param16,   -- Freight_terms_code
20749         p_date_param1            => l_date_param1, -- request date
20750         p_date_param2            => l_date_param2, -- promise date
20751         x_return_status          => l_return_status);
20752 
20753     END IF;
20754 
20755   END IF; -- if the globals are set.
20756 
20757 
20758 
20759    ------------ changing from any line to all lines -------------
20760 
20761  if l_debug_level > 0 then
20762   oe_debug_pub.add('change configuration requests', 3);
20763  end if;
20764 
20765    --6717302:
20766    -- 5932543 - do not call process order if the split is happening through
20767    -- ITS partial shipment. split_by=system
20768    -- 6678897 - comparision of split_action_code and split_by WITH NVL
20769    -- if not done so, following if condition will always fail and cascading
20770    -- changed field values to child item lines will fail.
20771    -- (warehous field for 6678897)
20772 
20773    IF  OE_GLOBALS.G_CHANGE_CFG_FLAG = 'Y' AND
20774       ((p_x_line_rec.ato_line_id is not null AND
20775         p_x_line_rec.item_type_code <> OE_GLOBALS.G_ITEM_STANDARD) OR
20776        (nvl(p_x_line_rec.ship_model_complete_flag,'N')='Y')) AND
20777         p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
20778         AND nvl(p_x_line_rec.split_action_code,'N') <> 'SPLIT' --6717302
20779         AND nvl(p_x_line_rec.split_by,'N') <> 'SYSTEM' --6717302
20780    THEN
20781 
20782      IF  p_x_line_rec.schedule_status_code is null THEN
20783 
20784        -- 1.
20785        IF NOT OE_GLOBALS.Equal(p_x_line_rec.SHIP_FROM_ORG_ID,
20786                              p_old_line_rec.SHIP_FROM_ORG_ID)
20787        THEN
20788          l_change_configuration := TRUE;
20789        END IF;
20790 
20791        -- 2.
20792        IF NOT OE_GLOBALS.Equal(p_x_line_rec.SHIP_TO_ORG_ID,
20793                              p_old_line_rec.SHIP_TO_ORG_ID)
20794        THEN
20795          l_change_configuration := TRUE;
20796        END IF;
20797 
20798      END IF;
20799 
20800      -- 3. note that this is logged even if scheduled.
20801 
20802      IF NOT OE_GLOBALS.Equal(p_x_line_rec.REQUEST_DATE,
20803                            p_old_line_rec.REQUEST_DATE) AND
20804         OE_CONFIG_UTIL.CASCADE_CHANGES_FLAG = 'N'
20805      THEN
20806         l_change_configuration := TRUE;
20807      END IF;
20808 
20809      IF NOT OE_GLOBALS.Equal(p_x_line_rec.SHIPPING_METHOD_CODE,
20810                            p_old_line_rec.SHIPPING_METHOD_CODE)
20811      THEN
20812         l_change_configuration := TRUE;
20813      END IF;
20814 
20815      IF NOT OE_GLOBALS.Equal(p_x_line_rec.SHIPMENT_PRIORITY_CODE,
20816                            p_old_line_rec.SHIPMENT_PRIORITY_CODE)
20817      THEN
20818         l_change_configuration := TRUE;
20819      END IF;
20820 
20821      IF NOT OE_GLOBALS.Equal(p_x_line_rec.DEMAND_CLASS_CODE,
20822                            p_old_line_rec.DEMAND_CLASS_CODE)
20823      THEN
20824         l_change_configuration := TRUE;
20825      END IF;
20826 
20827 
20828      IF l_change_configuration THEN
20829 
20830        IF (nvl(p_x_line_rec.ship_model_complete_flag,'N')='Y') THEN
20831           l_entity_id := p_x_line_rec.top_model_line_id;
20832 
20833        ELSIF  (p_x_line_rec.ato_line_id is not null ) THEN
20834           l_entity_id := p_x_line_rec.ato_line_id;
20835 
20836        END IF;
20837 
20838       if l_debug_level > 0 then
20839        oe_debug_pub.add('logging a req. to chg config', 1);
20840       end if;
20841 
20842        OE_Delayed_Requests_Pvt.Log_Request(
20843         p_entity_code             =>   OE_GLOBALS.G_ENTITY_LINE,
20844         p_entity_id               =>   l_entity_id,
20845         p_requesting_entity_code  =>   OE_GLOBALS.G_ENTITY_LINE,
20846         p_requesting_entity_id    =>   p_x_line_rec.line_id,
20847         p_request_type            =>   OE_GLOBALS.G_CHANGE_CONFIGURATION,
20848         p_param1                  =>   p_x_line_rec.line_id,
20849         x_return_status           =>   l_return_status);
20850 
20851      END IF;
20852 
20853    END IF;
20854 
20855    ------ cascading from class/kitclass to included items only ---------
20856 
20857    l_num := 0;
20858 
20859 BEGIN
20860    SELECT 1
20861    INTO   l_num
20862    FROM   oe_order_lines
20863    WHERE  top_model_line_id = p_x_line_rec.top_model_line_id
20864    AND    link_to_line_id   = p_x_line_rec.line_id
20865    AND    item_type_code = OE_GLOBALS.G_ITEM_INCLUDED
20866    AND    rownum = 1;
20867 
20868 EXCEPTION
20869   WHEN NO_DATA_FOUND THEN
20870    if l_debug_level > 0 then
20871     oe_debug_pub.add('modify inc items requests NOT reqd', 3);
20872    end if;
20873     RETURN;
20874 END;
20875 
20876  if l_debug_level > 0 then
20877   oe_debug_pub.add('modify inc items request reqd', 3);
20878  end if;
20879 
20880   l_num := p_x_line_rec.line_id;
20881 
20882   IF NOT OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.EXISTS(l_num) THEN
20883     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param1
20884                   := FND_API.G_MISS_NUM;
20885     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param2
20886                   := FND_API.G_MISS_NUM;
20887     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param3 := null;
20888     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param4 := null;
20889     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param5
20890                   := FND_API.G_MISS_NUM;
20891     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param6
20892                   := FND_API.G_MISS_NUM;
20893     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param7
20894                   := FND_API.G_MISS_NUM;
20895     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param8
20896                   := FND_API.G_MISS_NUM;
20897     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param9
20898                   := FND_API.G_MISS_NUM;
20899     OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).date_param1
20900                   := FND_API.G_MISS_DATE;
20901   END IF;
20902 
20903   IF   p_x_line_rec.operation <> OE_GLOBALS.G_OPR_CREATE AND
20904        p_x_line_rec.ato_line_id is null AND
20905        p_x_line_rec.top_model_line_id <> p_x_line_rec.line_id AND
20906        (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
20907         p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT) AND
20908 	nvl(p_x_line_rec.split_action_code, 'X') <> 'SPLIT'  AND
20909         OE_CONFIG_UTIL.CASCADE_CHANGES_FLAG = 'N' -- not for  model change
20910   THEN
20911     if l_debug_level > 0 then
20912      oe_debug_pub.add('cascade class changes to included items', 1);
20913     end if;
20914 
20915      IF NOT OE_GLOBALS.Equal(p_x_line_rec.ordered_quantity,
20916                              p_old_line_rec.ordered_quantity) THEN
20917 
20918        IF OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param1 =
20919           FND_API.G_MISS_NUM THEN
20920          OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param1
20921                        := p_old_line_rec.ordered_quantity;
20922         if l_debug_level > 0 then
20923          oe_debug_pub.add('qty changed 1st time ' || l_param1, 4);
20924         end if;
20925        END IF;
20926 
20927        OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param2
20928                        := p_x_line_rec.ordered_quantity;
20929        -- new qty
20930 
20931        OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param3
20932                        := p_x_line_rec.change_reason;
20933        -- change_reason
20934 
20935        OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param4
20936                        := p_x_line_rec.change_comments;
20937        --  change_comments
20938 
20939       if l_debug_level > 0 then
20940        oe_debug_pub.add
20941        ('ord qty of class changed:' || p_x_line_rec.ordered_quantity,1);
20942       end if;
20943 
20944        l_modify_included_items := TRUE;
20945 
20946      END IF;
20947 
20948      IF NOT OE_GLOBALS.Equal(p_x_line_rec.project_id,p_old_line_rec.project_id) THEN
20949       OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param5
20950                        := p_x_line_rec.project_id;
20951      if l_debug_level > 0 then
20952       oe_debug_pub.add('model/ATO subconfig,project changed: '||l_param5,1);
20953      end if;
20954       l_modify_included_items := TRUE;
20955      END IF;
20956 
20957 
20958      IF NOT OE_GLOBALS.Equal(p_x_line_rec.task_id,p_old_line_rec.task_id)
20959      THEN
20960        OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param6
20961                        := p_x_line_rec.task_id;
20962      if l_debug_level > 0 then
20963        oe_debug_pub.add('model /ATO subconfig,task changed: '||l_param6,1);
20964      end if;
20965        l_modify_included_items := TRUE;
20966      END IF;
20967 
20968 
20969      IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_tolerance_above,
20970                              p_old_line_rec.ship_tolerance_above)
20971       THEN
20972         OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param7
20973                        := p_x_line_rec.ship_tolerance_above;
20974         l_modify_included_items := TRUE;
20975       END IF;
20976 
20977       IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_tolerance_below,
20978                               p_old_line_rec.ship_tolerance_below)
20979       THEN
20980          OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param8
20981                        := p_x_line_rec.ship_tolerance_below;
20982          l_modify_included_items := TRUE;
20983       END IF;
20984 
20985       IF OE_GLOBALS.G_CHANGE_CFG_FLAG = 'Y' THEN
20986         IF NOT OE_GLOBALS.Equal(p_x_line_rec.ship_to_org_id,
20987                                 p_old_line_rec.ship_to_org_id)
20988         THEN
20989            OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param9
20990                        := p_x_line_rec.ship_to_org_id;
20991            l_modify_included_items := TRUE;
20992         END IF;
20993 
20994         IF NOT OE_GLOBALS.Equal(p_x_line_rec.request_date,
20995                               p_old_line_rec.request_date)
20996         THEN
20997            OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).date_param1
20998                        := p_x_line_rec.request_date;
20999            l_modify_included_items := TRUE;
21000         END IF;
21001       END IF;
21002 
21003       IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
21004         l_modify_included_items := TRUE;
21005       END IF;
21006 
21007    END IF;
21008 
21009 
21010    IF l_modify_included_items THEN
21011     if l_debug_level > 0 then
21012      oe_debug_pub.add('something changed'|| p_x_line_rec.operation, 2);
21013     end if;
21014 
21015      OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param10 :=
21016                       p_x_line_rec.operation;
21017 
21018      IF OE_Sales_Can_Util.G_Require_Reason THEN
21019        OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param11 := 'Y';
21020      ELSE
21021        OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param11 := 'N';
21022      END IF;
21023 
21024      OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param12 :=
21025                     p_x_line_rec.line_id;
21026 
21027      OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL(l_num).param13 :=
21028                     p_x_line_rec.top_model_line_id;
21029    END IF;
21030 
21031   x_return_status := l_return_status;
21032 
21033  if l_debug_level > 0 then
21034   oe_debug_pub.add('leaving Log_Config_Requests', 1);
21035  end if;
21036 EXCEPTION
21037   WHEN OTHERS THEN
21038    if l_debug_level > 0 then
21039     oe_debug_pub.add('exception in Log_Cascade_Requests'|| sqlerrm, 1);
21040    end if;
21041     RAISE;
21042 END Log_Cascade_Requests;
21043 
21044 
21045 
21046 /*-----------------------------------------------------------
21047 PROCEDURE get_customer_details
21048 ------------------------------------------------------------*/
21049 
21050 PROCEDURE get_customer_details
21051 (   p_org_id                IN  NUMBER
21052 ,   p_site_use_code         IN  VARCHAR2
21053 ,   x_customer_name         OUT NOCOPY /* file.sql.39 change */ VARCHAR2
21054 ,   x_customer_number       OUT NOCOPY /* file.sql.39 change */ VARCHAR2
21055 ,   x_customer_id           OUT NOCOPY /* file.sql.39 change */ number
21056 ,   x_location              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
21057 ,   x_address1              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
21058 ,   x_address2              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
21059 ,   x_address3              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
21060 ,   x_address4              OUT NOCOPY /* file.sql.39 change */ VARCHAR2
21061 ,   x_city                  OUT NOCOPY /* file.sql.39 change */ VARCHAR2
21062 ,   x_state                 OUT NOCOPY /* file.sql.39 change */ VARCHAR2
21063 ,   x_zip                   OUT NOCOPY /* file.sql.39 change */ VARCHAR2
21064 ,   x_country               OUT NOCOPY /* file.sql.39 change */ VARCHAR2
21065 )
21066 
21067 IS
21068 BEGIN
21069 
21070     IF p_org_id is NOT NULL THEN
21071 
21072         SELECT  /*MOAC_SQL_CHANGES*/ cust.cust_account_id,
21073                 party.party_name,
21074                 cust.account_number,
21075                 site.location,
21076                 addr.address1,
21077                 addr.address2,
21078                 addr.address3,
21079                 addr.address4,
21080                 addr.city,
21081                 nvl(addr.state,addr.province), -- 3603600
21082 	        addr.postal_code,
21083 	        addr.country
21084         INTO    x_customer_id,
21085                 x_customer_name,
21086                 x_customer_number,
21087                 x_location,
21088 	        x_address1,
21089 	        x_address2,
21090 	        x_address3,
21091 	        x_address4,
21092 	        x_city,
21093                 x_state,
21094                 x_zip,
21095                 x_country
21096         FROM    HZ_CUST_SITE_USES_ALL site,
21097                 HZ_CUST_ACCT_SITES cas,
21098                 hz_cust_accounts cust,
21099                 hz_parties party,
21100                 hz_party_sites ps,
21101                 hz_locations addr
21102         WHERE   site.cust_acct_site_id=cas.cust_acct_site_id
21103         AND     site.site_use_code=p_site_use_code
21104         AND     site.site_use_id=p_org_id
21105         AND     cust.cust_account_id = cas.cust_account_id
21106         AND     cas.party_site_id = ps.party_site_id
21107         AND     ps.location_id = addr.location_id
21108         AND     party.party_id = cust.party_id;
21109 
21110     ELSE
21111 
21112         x_customer_name    :=  NULL    ;
21113         x_customer_number  :=  NULL    ;
21114         x_customer_id      :=  NULL    ;
21115         x_location         :=  NULL;
21116         x_address1         := nULL;
21117         x_address2         := nULL;
21118         x_address3         := nULL;
21119         x_address4         := nULL;
21120         x_city             := nULL;
21121         x_state            := nULL;
21122         x_zip              := nULL;
21123         x_country          := nULL;
21124 
21125     END IF;
21126 
21127 EXCEPTION
21128 
21129     WHEN NO_DATA_FOUND THEN
21130 
21131         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
21132         THEN
21133 
21134             fnd_message.set_name('ONT','OE_ID_TO_VALUE_ERROR');
21135             FND_MESSAGE.SET_TOKEN('ATTRIBUTE','get_customer_details');
21136             OE_MSG_PUB.Add;
21137 
21138         END IF;
21139 
21140 
21141     WHEN OTHERS THEN
21142 
21143         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
21144         THEN
21145             OE_MSG_PUB.Add_Exc_Msg
21146             (   G_PKG_NAME
21147           ,   'get_customer_details'
21148             );
21149         END IF;
21150 
21151         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
21152 
21153 END get_customer_details;
21154 
21155 
21156 /*-----------------------------------------------------------
21157 PROCEDURE Log_Scheduling_Requests
21158 ------------------------------------------------------------*/
21159 
21160 PROCEDURE Log_Scheduling_Requests
21161 (p_x_line_rec    IN  OUT NOCOPY OE_Order_PUB.Line_Rec_Type
21162 ,p_old_line_rec  IN  OE_Order_PUB.Line_Rec_Type
21163 ,p_caller        IN  VARCHAR2
21164 ,p_order_type_id IN  NUMBER
21165 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
21166 IS
21167 l_count NUMBER;
21168 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
21169 BEGIN
21170 
21171 if l_debug_level > 0 then
21172  oe_debug_pub.add('Entering Log_Scheduling_Requests',1);
21173  oe_debug_pub.add('p_caller' || p_caller,1);
21174 end if;
21175 
21176   IF NOT OE_GLOBALS.Equal(p_x_line_rec.schedule_ship_date,
21177                           p_old_line_rec.schedule_ship_date)
21178   THEN
21179     if l_debug_level > 0 then
21180      oe_debug_pub.add('Schedule shipdate is changed',1);
21181     end if;
21182 
21183 /* 7576948: Commented for IR ISO CMS Project
21184 
21185      IF p_x_line_rec.order_source_id = 10 AND
21186         p_old_line_rec.schedule_ship_date IS NOT NULL
21187      THEN
21188 
21189         FND_MESSAGE.SET_NAME('ONT','OE_CHG_CORR_REQ');
21190         -- { start fix for 2648277
21191 	FND_MESSAGE.SET_TOKEN('CHG_ATTR',
21192             OE_Order_Util.Get_Attribute_Name('schedule_ship_date'));
21193         -- end fix for 2648277}
21194         OE_MSG_PUB.Add;
21195 
21196      END IF;
21197 
21198 */ -- COmmented for IR ISO CMS Project
21199 
21200 	IF	p_x_line_rec.shipping_interfaced_flag = 'Y'
21201     AND p_x_line_rec.ordered_quantity > 0  THEN
21202 
21203     -- Fix for bug 2347447
21204        if l_debug_level > 0 then
21205         oe_debug_pub.ADD('Update Shipping : logging delayed request for '
21206                                 || to_char(p_x_line_rec.line_id) ,1);
21207        end if;
21208 
21209 		OE_Delayed_Requests_Pvt.Log_Request(
21210 		p_entity_code				=>	OE_GLOBALS.G_ENTITY_LINE,
21211 		p_entity_id					=>	p_x_line_rec.line_id,
21212 		p_requesting_entity_code	=>	OE_GLOBALS.G_ENTITY_LINE,
21213 		p_requesting_entity_id  	=>	p_x_line_rec.line_id,
21214 		p_request_type				=>	OE_GLOBALS.G_UPDATE_SHIPPING,
21215 		p_request_unique_key1		=>  OE_GLOBALS.G_OPR_UPDATE,
21216 		p_param1             		=>	FND_API.G_TRUE,
21217 		x_return_status				=>	x_return_status);
21218 
21219 	END IF;
21220   END IF;
21221 
21222    -- End of apply attributes.
21223    -- Begin Pre write.
21224 
21225    -- Start AuditTrail
21226 
21227    IF  OE_GLOBALS.G_AUDIT_REASON_RQD_FLAG = 'Y'
21228    AND ( p_x_line_rec.change_reason IS NULL OR
21229          p_x_line_rec.change_reason = FND_API.G_MISS_CHAR)
21230    THEN
21231 
21232       -- bug 3636884, defaulting reason from group API
21233       IF OE_GLOBALS.G_DEFAULT_REASON THEN
21234         if l_debug_level > 0 then
21235          oe_debug_pub.add('Defaulting Audit Reason for Order Line', 1);
21236         end if;
21237          p_x_line_rec.change_reason := 'SYSTEM';
21238       ELSE
21239         if l_debug_level > 0 then
21240          oe_debug_pub.add('Audit Required Reason missing - error', 1);
21241         end if;
21242          fnd_message.set_name('ONT','OE_AUDIT_REASON_RQD');
21243          fnd_message.set_token('OBJECT','ORDER LINE');
21244          oe_msg_pub.add;
21245          RAISE FND_API.G_EXC_ERROR;
21246       END IF;
21247 
21248    END IF;
21249 
21250 
21251  -- If we move scheduling call to post write.
21252   IF p_caller = 'EXTERNAL' THEN
21253 
21254     IF ((p_x_line_rec.top_model_line_id is NOT NULL OR
21255         p_x_line_rec.ato_line_id is NOT NULL)) AND
21256         p_x_line_rec.item_type_code <> OE_GLOBALS.G_ITEM_CONFIG
21257     THEN
21258      if l_debug_level > 0 then
21259       oe_debug_pub.add('Before logging Log_CTO_Requests', 1);
21260      end if;
21261       Log_CTO_Requests( p_x_line_rec    => p_x_line_rec
21262                        ,p_old_line_rec  => p_old_line_rec
21263                        ,x_return_status => x_return_status);
21264     END IF;
21265 
21266 
21267   END IF; -- External
21268 --bug  3988559 modify sfadnavi  BEGIN
21269 
21270  if l_debug_level > 0 then
21271   oe_debug_pub.add('Before calling Version_Audit_Process',1);
21272  end if;
21273 
21274 --Adding code to log versioning/audit request
21275 OE_Line_Util.Version_Audit_Process(p_x_line_rec => p_x_line_rec,
21276                         p_old_line_rec => p_old_line_rec);
21277 
21278 --bug 3988559 modify sfadnavi  END
21279 
21280 
21281 
21282  if l_debug_level > 0 then
21283   oe_debug_pub.add('Exiting Log_Scheduling_Requests',1);
21284  end if;
21285 
21286 
21287 END Log_Scheduling_Requests;
21288 
21289 /* LG. May 03 changed all the calls to GMI uom_conversion to get_opm_converted_qty
21290  * to resolved rounding issues
21291  */
21292 
21293  PROCEDURE calculate_dual_quantity
21294 (
21295    p_ordered_quantity       IN OUT NOCOPY /* file.sql.39 change */ NUMBER
21296   ,p_old_ordered_quantity   IN NUMBER
21297   ,p_ordered_quantity2      IN OUT NOCOPY /* file.sql.39 change */ NUMBER
21298   ,p_old_ordered_quantity2  IN NUMBER
21299   ,p_ordered_quantity_uom   IN VARCHAR2
21300   ,p_ordered_quantity_uom2  IN VARCHAR2
21301   ,p_inventory_item_id      IN NUMBER
21302   ,p_ship_from_org_id       IN NUMBER
21303   ,x_ui_flag	            IN NUMBER
21304   ,x_return_status	    OUT NOCOPY /* file.sql.39 change */ NUMBER
21305  -- ,p_lot_id                 IN  NUMBER DEFAULT 0 -- OPM 2380194 added for RMA quantity2 OM pack J project
21306 	,p_lot_number             IN  VARCHAR2 DEFAULT NULL -- INVCONV for 2380194 added for RMA quantity2 OM pack J project
21307 )
21308 
21309 IS
21310 
21311 l_converted_qty        NUMBER(19,9);
21312 l_item_rec             OE_ORDER_CACHE.item_rec_type;
21313 --l_OPM_UOM              VARCHAR2(4);  -- INVCONV
21314 l_error_message        VARCHAR2(1000); -- INVCONV
21315 l_debug_level  CONSTANT NUMBER := oe_debug_pub.g_debug_level; -- INVCONV
21316 l_return               NUMBER;
21317 l_status               VARCHAR2(1);
21318 l_return_status        VARCHAR2(30);
21319 l_msg_count            NUMBER;
21320 -- l_msg_data             VARCHAR2(2000); INVCONV
21321 l_buffer                  VARCHAR2(2000); -- INVCONV
21322 UOM_CONVERSION_FAILED  EXCEPTION;             -- INVCONV
21323 TOLERANCE_ERROR EXCEPTION;             -- INVCONV
21324 
21325 BEGIN
21326 
21327 
21328 
21329 -- First of all, if this procedure is called from a source other then UI
21330 
21331 IF l_debug_level  > 0 THEN
21332 	oe_debug_pub.add ('Enter Calculate_dual_quantity');
21333 	oe_debug_pub.add ('p_ordered_quantity = ' || p_ordered_quantity );
21334 	oe_debug_pub.add ('p_old_ordered_quantity = ' || p_old_ordered_quantity );
21335 	oe_debug_pub.add ('p_ordered_quantity2 = ' || p_ordered_quantity2 );
21336 	oe_debug_pub.add ('p_old_ordered_quantity2 = ' || p_old_ordered_quantity2 );
21337 	oe_debug_pub.add ('p_ordered_quantity_uom = ' || p_ordered_quantity_uom );
21338 	oe_debug_pub.add ('p_ordered_quantity_uom2 = ' || p_ordered_quantity_uom2 );
21339 	oe_debug_pub.add ('p_inventory_item_id = ' || p_inventory_item_id );
21340 	oe_debug_pub.add ('p_ship_from_org_id = ' || p_ship_from_org_id );
21341 	oe_debug_pub.add ('p_lot_number = ' || p_lot_number );
21342   oe_debug_pub.add ('x_ui_flag = ' || x_ui_flag );
21343 END IF;
21344 
21345 -- First of all, if this procedure is called from a source other then UI
21346 /* If neither quantity is present, no calculation is required
21347 ======================================================*/
21348 
21349 IF p_ordered_quantity2 = fnd_api.g_miss_num THEN
21350    p_ordered_quantity2 := 0;
21351    IF l_debug_level  > 0 THEN
21352 	oe_debug_pub.add('Calculate_dual_quantity - p_ordered_quantity2 = fnd_api.g_miss_num' );
21353    END IF;
21354 
21355 END IF;
21356 
21357 IF( X_UI_FLAG = 1 ) THEN
21358   IF (p_ordered_quantity IS NULL OR
21359     p_ordered_quantity = FND_API.G_MISS_NUM ) AND
21360    (p_ordered_quantity2 IS NULL OR
21361     p_ordered_quantity2 = FND_API.G_MISS_NUM ) THEN
21362     IF l_debug_level  > 0 THEN
21363     		oe_debug_pub.add ('Calculate_dual_quantity - both quantities empty so early return');
21364     END IF;
21365     RETURN;
21366    END IF;
21367 END IF; -- IF( X_UI_FLAG = 1 ) THEN
21368 
21369 /* If this is a dual uom control line, load the item details from cache
21370 ==============================================================*/
21371 IF dual_uom_control
21372   (p_inventory_item_id,p_ship_from_org_id,l_item_rec) THEN
21373   -- IF l_item_rec.dualum_ind not in (1,2,3) THEN -- INVCONV
21374   IF l_item_rec.tracking_quantity_ind <> 'PS' then -- INVCONV
21375 
21376     p_ordered_quantity2 := NULL;
21377     RETURN;
21378   END IF;
21379 ELSE
21380   p_ordered_quantity2 := NULL;
21381   RETURN;
21382 END IF;
21383 
21384 IF l_debug_level  > 0 THEN
21385 	oe_debug_pub.add('Calculate_dual_quantity secondary_default_ind is ' || l_item_rec.secondary_default_ind);
21386 END IF;
21387 
21388 IF ( X_UI_FLAG = 0 ) THEN
21389    IF (NVL(p_ordered_quantity2,0) = 0
21390       OR l_item_rec.secondary_default_ind  = 'F' ) -- INVCONV
21391      THEN
21392 
21393       	IF l_debug_level  > 0 THEN
21394       			oe_debug_pub.add('Calculate_dual_quantity : quantity2 is null OR is type F - so calculate it');
21395       	END IF;
21396 
21397            /* p_ordered_quantity2 := GMI_Reservation_Util.get_opm_converted_qty( INVCONV
21398               p_apps_item_id    => p_inventory_item_id,
21399               p_organization_id => p_ship_from_org_id,
21400               p_apps_from_uom   => p_ordered_quantity_uom,
21401               p_apps_to_uom     => p_ordered_quantity_uom2,
21402               p_original_qty    => p_ordered_quantity,
21403               p_lot_id          => nvl(p_lot_id, 0) );  */-- OPM 2380194
21404 
21405 			  l_converted_qty := INV_CONVERT.INV_UM_CONVERT(p_inventory_item_id -- INVCONV
21406 			  																						  ,p_lot_number     -- INVCONV
21407 			  																							,p_ship_from_org_id -- INVCONV
21408 			  																						  ,5 --NULL
21409                                                       ,p_ordered_quantity
21410                                                       ,p_ordered_quantity_uom
21411                                                       ,p_ordered_quantity_uom2
21412                                                       ,NULL -- From uom name
21413                                                       ,NULL -- To uom name
21414                                                       );
21415        IF (l_converted_qty < 0) THEN    -- INVCONV
21416               raise UOM_CONVERSION_FAILED;
21417        END IF;
21418         p_ordered_quantity2 :=       l_converted_qty; -- INVCONV
21419       	IF l_debug_level  > 0 THEN
21420       			oe_debug_pub.add('Calculate_dual_quantity : calculated quantity2 is '||p_ordered_quantity2);
21421       	END IF;
21422 
21423    -- ELSIF (l_item_rec.dualum_ind in (2,3) ) THEN
21424    /* passed quantity is not null and secondary_default_ind in ('D','N (dualum_ind is 2 or 3) */
21425    ELSIF (l_item_rec.secondary_default_ind in ('D','N') )  tHEN -- INVCONV
21426 
21427        -- check the deviation and error out
21428        l_return := INV_CONVERT.Within_Deviation  -- INVCONV
21429                        ( p_organization_id   =>
21430                                  p_ship_from_org_id
21431                        , p_inventory_item_id =>
21432                                  p_inventory_item_id
21433                        , p_lot_number  => p_lot_number -- INVCONV
21434                        , p_precision         => 5
21435                        , p_quantity          => abs(p_ordered_quantity)   -- 5128490
21436                        , p_uom_code1         => p_ordered_quantity_uom -- INVCONV
21437                        , p_quantity2         => abs(p_ordered_quantity2)   -- 5128490
21438                        , p_uom_code2         => l_item_rec.secondary_uom_code );
21439 
21440       IF l_return = 0
21441       	then
21442       	    IF l_debug_level  > 0 THEN
21443     	  			oe_debug_pub.add('Calculate_dual_quantity - tolerance error 1' ,1);
21444     			 END IF;
21445 
21446     			 l_buffer          := FND_MSG_PUB.GET(p_msg_index => FND_MSG_PUB.G_LAST, -- INVCONV
21447                                          p_encoded => 'F');
21448            oe_msg_pub.add_text(p_message_text => l_buffer);
21449            IF l_debug_level  > 0 THEN
21450               oe_debug_pub.add(l_buffer,1);
21451     			 END IF;
21452     			 RAISE TOLERANCE_ERROR ;
21453 
21454    		else
21455       	IF l_debug_level  > 0 THEN
21456     	  		oe_debug_pub.add('Calculate_dual_quantity - No tolerance error so return ',1);
21457     		END IF;
21458     		x_return_status := 0;
21459      	RETURN;
21460      END IF; -- IF l_return = 0
21461 
21462 
21463       /* l_return := GMICVAL.dev_validation(l_item_rec.opm_item_id INVCONV
21464                                       ,nvl(p_lot_id, 0) --  2380194
21465                                       ,p_ordered_quantity
21466                                       ,l_OPM_UOM
21467                                       ,p_ordered_quantity2
21468                                       ,l_item_rec.opm_item_um2
21469                                       ,0);
21470       IF (l_return = -68 ) THEN
21471          x_return_status := -1;
21472          FND_MESSAGE.set_name('GMI','IC_DEVIATION_HI_ERR');
21473          OE_MSG_PUB.Add;
21474       ELSIF(l_return = -69 ) THEN
21475          x_return_status := -1;
21476          FND_MESSAGE.set_name('GMI','IC_DEVIATION_HI_ERR');
21477          OE_MSG_PUB.Add;
21478       END IF; */
21479 
21480 
21481    END IF;    -- IF (NVL(p_ordered_quantity2,0) = 0
21482 
21483    IF(x_return_status = -1 ) THEN
21484      RAISE FND_API.G_EXC_ERROR;
21485    END IF;
21486 
21487    RETURN;
21488 
21489 END IF; -- IF ( X_UI_FLAG = 0 ) THEN
21490 
21491 
21492 IF l_debug_level  > 0 THEN
21493 	oe_debug_pub.add('Calculate_dual_quantity  - Convert for dual controlled item Scenario',1);
21494 END IF;
21495 
21496 /* Has one of the two quantities changed
21497 =======================================*/
21498 IF (NOT OE_GLOBALS.EQUAL(p_ordered_quantity
21499          			    ,p_old_ordered_quantity )) OR
21500    (NOT OE_GLOBALS.EQUAL(p_ordered_quantity2
21501          			    ,p_old_ordered_quantity2)) OR
21502    (p_ordered_quantity  IS NULL) OR
21503    (p_ordered_quantity2 IS NULL) THEN
21504 
21505       IF l_debug_level  > 0 THEN
21506       	oe_debug_pub.add('Calculate_dual_quantity - change detected ',1);
21507       END IF;
21508 
21509    /*
21510    IF l_item_rec.dualum_ind = 1 THEN
21511      RETURN;
21512    END IF;
21513    */
21514 ELSE
21515    /* No calculation  required
21516    ==================*/
21517    RETURN;
21518 END IF; -- IF (NOT OE_GLOBALS.EQUAL(p_ordered_quantity
21519 
21520 
21521 
21522 
21523 /* Get the OPM equivalent code for order_quantity_uom
21524 =====================================================   INVCONV
21525 GMI_Reservation_Util.Get_OPMUOM_from_AppsUOM
21526 				 (p_Apps_UOM       => p_ordered_quantity_uom
21527 				 ,x_OPM_UOM        => l_OPM_UOM
21528 				 ,x_return_status  => l_status
21529 				 ,x_msg_count      => l_msg_count
21530 				 ,x_msg_data       => l_msg_data);
21531 
21532    IF (l_status <> FND_API.G_RET_STS_SUCCESS)
21533    THEN
21534       x_return_status := -1;
21535       oe_debug_pub.add('OPM After Get_OPMUOM_from_appsUOM -  failed : apps_uom =  ' || p_ordered_quantity_uom || 'opm_uom = ' || l_opm_uom );
21536    ELSE
21537       x_return_status := 1;
21538       oe_debug_pub.add('OPM After Get_OPMUOM_from_appsUOM : apps_uom =  ' || p_ordered_quantity_uom || 'opm_uom = ' || l_opm_uom );
21539    END IF;   */
21540 
21541 
21542 IF (NOT OE_GLOBALS.EQUAL(p_ordered_quantity
21543          			    ,p_old_ordered_quantity )) OR
21544 				     p_ordered_quantity2 IS NULL THEN
21545 
21546   /* Primary quantity has changed so recalculate secondary */
21547 
21548   -- IF l_item_rec.dualum_ind in (2,3)
21549      IF (l_item_rec.secondary_default_ind in ('D','N') ) -- INVCONV
21550     and p_ordered_quantity is NOT NULL AND
21551     p_ordered_quantity_uom <> p_ordered_quantity_uom2 AND
21552     p_ordered_quantity2 is NOT NULL THEN
21553 
21554     /* Only do tolerance check if both quantities populated */
21555 			IF l_debug_level  > 0 THEN
21556        		oe_debug_pub.add('Calculate_dual_quantity - Check the deviation  ');
21557       END IF;
21558 
21559       l_return := INV_CONVERT.Within_Deviation  -- INVCONV
21560                        ( p_organization_id   =>
21561                                  p_ship_from_org_id
21562                        , p_inventory_item_id =>
21563                                  p_inventory_item_id
21564                        , p_lot_number  => p_lot_number -- INVCONV
21565                        , p_precision         => 5
21566                        , p_quantity          => abs(p_ordered_quantity) -- 5128490
21567                        , p_uom_code1         => p_ordered_quantity_uom
21568                        , p_quantity2         => abs(p_ordered_quantity2)  -- 5128490
21569                        , p_uom_code2         => l_item_rec.secondary_uom_code);
21570 
21571       IF l_return = 0
21572       	then
21573       	   IF l_debug_level  > 0 THEN
21574     	  			oe_debug_pub.add('Calculate_dual_quantity - tolerance error 2' ,1);
21575     			 END IF;
21576      			 l_buffer := FND_MSG_PUB.GET(p_msg_index => FND_MSG_PUB.G_LAST, -- INVCONV
21577                                          p_encoded => 'F');
21578            oe_msg_pub.add_text(p_message_text => l_buffer);
21579            IF l_debug_level  > 0 THEN
21580               oe_debug_pub.add(l_buffer,1);
21581     			 END IF;
21582     			 RAISE TOLERANCE_ERROR ;
21583 
21584    		else
21585       	IF l_debug_level  > 0 THEN
21586     	  		oe_debug_pub.add('Calculate_dual_quantity - No tolerance error so return ',1);
21587     		END IF;
21588     	  x_return_status := 0;
21589      	  RETURN;
21590      END IF; -- IF l_return = 0
21591 
21592 
21593      /* l_return := GMICVAL.dev_validation(l_item_rec.opm_item_id
21594                                       ,nvl(p_lot_id, 0) --  2380194
21595 				      ,p_ordered_quantity
21596 				      ,l_OPM_UOM
21597 				      ,p_ordered_quantity2
21598                                       ,l_item_rec.opm_item_um2
21599 				      ,0);
21600     -- if change is within of tolerance, no further action
21601 
21602     IF (l_return NOT in (-68, -69)) THEN
21603        oe_debug_pub.add(' OPM : calculate_dual_qty .No tolerance error so return  ');
21604        RETURN;
21605     ELSE   ---  IF (l_item_rec.dualum_ind = 3 )THEN
21606        x_return_status := l_return;
21607        oe_debug_pub.add('Calculate_dual_quantity - deviation error so return  ');
21608        RETURN;
21609     END IF;    */
21610 
21611   END IF; -- IF (l_item_rec.secondary_default_ind in ('D','N')THEN
21612 
21613  -- IF (l_item_rec.dualum_ind in (1,2) )THEN    INVCONV
21614     IF (l_item_rec.secondary_default_ind in ('F','D') ) THEN -- INVCONV
21615  							IF l_debug_level  > 0 THEN
21616               		oe_debug_pub.add('Calculate_dual_qty - uom conversion primary to secondary');
21617               END IF;
21618      /*l_converted_qty :=GMICUOM.uom_conversion
21619  	            (l_item_rec.opm_item_id,0
21620      	    	     ,p_ordered_quantity
21621                      ,l_OPM_UOM
21622     	    	     ,l_item_rec.opm_item_um2
21623 	             ,0);
21624 
21625      IF (l_converted_qty < 0) THEN
21626         x_return_status := -11 ;
21627      END IF;
21628      p_ordered_quantity2 := l_converted_qty;    */
21629 
21630       /*p_ordered_quantity2 := GMI_Reservation_Util.get_opm_converted_qty( INVCONV
21631               p_apps_item_id    => p_inventory_item_id,
21632               p_organization_id => p_ship_from_org_id,
21633               p_apps_from_uom   => p_ordered_quantity_uom,
21634               p_apps_to_uom     => p_ordered_quantity_uom2,
21635               p_original_qty    => p_ordered_quantity,
21636               p_lot_id          => nvl(p_lot_id, 0) ); -- OPM 2380194  */
21637 
21638      p_ordered_quantity2 := INV_CONVERT.INV_UM_CONVERT(p_inventory_item_id -- INVCONV
21639      																									,p_lot_number     -- INVCONV
21640      																									,p_ship_from_org_id -- INVCONV
21641                                                       ,5 --NULL
21642                                                       ,p_ordered_quantity
21643                                                       ,p_ordered_quantity_uom
21644                                                       ,p_ordered_quantity_uom2
21645                                                       ,NULL -- From uom name
21646                                                       ,NULL -- To uom name
21647                                                       );
21648     IF (p_ordered_quantity2 < 0) THEN    -- INVCONV
21649               raise UOM_CONVERSION_FAILED;
21650     END IF;
21651 
21652 
21653       	IF l_debug_level  > 0 THEN
21654       			oe_debug_pub.add('Calculate_dual_quantity : calculated quantity2 is '||p_ordered_quantity2);
21655       	END IF;
21656 
21657 
21658 
21659 
21660  END IF; -- IF (l_item_rec.secondary_default_ind in ('F','D')THEN
21661 
21662 ELSIF (NOT OE_GLOBALS.EQUAL(p_ordered_quantity2
21663          			        ,p_old_ordered_quantity2 )) THEN
21664   /* Secondary quantity has changed so recalculate primary */
21665 
21666 
21667 
21668   -- IF l_item_rec.dualum_ind in (2,3) and  INVCONV
21669     IF (l_item_rec.secondary_default_ind in ('D','N')  )and  -- INVCONV
21670     p_ordered_quantity2 is NOT NULL AND
21671     p_ordered_quantity_uom <> p_ordered_quantity_uom2 AND
21672     p_ordered_quantity is NOT NULL THEN
21673 
21674     /* Only do tolerance check if both quantities populated */
21675    l_return := INV_CONVERT.Within_Deviation  -- INVCONV
21676                        ( p_organization_id   =>
21677                                  p_ship_from_org_id
21678                        , p_inventory_item_id =>
21679                                  p_inventory_item_id
21680                        , p_lot_number  => p_lot_number -- INVCONV
21681                        , p_precision         => 5
21682                        , p_quantity          => abs(p_ordered_quantity) -- 5128490
21683                        , p_uom_code1         => p_ordered_quantity_uom
21684                        , p_quantity2         => abs(p_ordered_quantity2) -- 5128490
21685                        , p_uom_code2         => l_item_rec.secondary_uom_code );
21686 
21687        IF l_return = 0
21688       	then
21689       	    IF l_debug_level  > 0 THEN
21690     	  			oe_debug_pub.add('Calculate_dual_quantity - tolerance error 3' ,1);
21691     			 END IF;
21692 
21693     			 l_buffer := FND_MSG_PUB.GET(p_msg_index => FND_MSG_PUB.G_LAST, -- INVCONV
21694                                          p_encoded => 'F');
21695            oe_msg_pub.add_text(p_message_text => l_buffer);
21696            IF l_debug_level  > 0 THEN
21697               oe_debug_pub.add(l_buffer,1);
21698     			 END IF;
21699     			 RAISE TOLERANCE_ERROR ;
21700 
21701    		else
21702       	IF l_debug_level  > 0 THEN
21703     	  		oe_debug_pub.add('Calculate_dual_quantity - No tolerance error so return ',1);
21704     		END IF;
21705      	RETURN;
21706      END IF; -- IF l_return = 0
21707 
21708 
21709      /* l_return := GMICVAL.dev_validation(l_item_rec.opm_item_id
21710                                       ,nvl(p_lot_id, 0) --  2380194
21711 	           	              ,p_ordered_quantity
21712 				      ,l_OPM_UOM
21713 				      ,p_ordered_quantity2
21714                                       ,l_item_rec.opm_item_um2
21715 				      ,0);
21716     --  if change is within tolerance, no further action
21717     IF (l_return NOT in (-68, -69)) THEN
21718        oe_debug_pub.add(' OPM : calculate_dual_qty .No tolerance error so return  ');
21719        RETURN;
21720     ELSE  -- IF (l_item_rec.dualum_ind = 3 )THEN
21721        x_return_status := l_return;
21722        oe_debug_pub.add('Calculate_dual_quantity .deviation error so return  ');
21723        RETURN;
21724     END IF;   */
21725 
21726   END IF;   -- IF (l_item_rec.secondary_default_ind in ('D','N')and  -- INVCONV
21727 
21728   --IF (l_item_rec.dualum_ind in (1,2) )THEN
21729     IF (l_item_rec.secondary_default_ind in ('F','D'))  then -- INVCONV
21730      /* Convert secondary quantity to derive primary */
21731     -- use l_converted_qty with precision of 19,9 to match OPM processing
21732     /*l_converted_qty  :=GMICUOM.uom_conversion
21733  	   	        (l_item_rec.opm_item_id,0
21734     	                ,p_ordered_quantity2
21735     	       	        ,l_item_rec.opm_item_um2
21736     	                ,l_OPM_UOM
21737 			,0);
21738 
21739     IF (l_converted_qty < 0) THEN
21740        x_return_status := -11;
21741     END IF;
21742 
21743     p_ordered_quantity := l_converted_qty;          */
21744     /* p_ordered_quantity := GMI_Reservation_Util.get_opm_converted_qty(
21745               p_apps_item_id    => p_inventory_item_id,
21746               p_organization_id => p_ship_from_org_id,
21747               p_apps_from_uom   => p_ordered_quantity_uom2,
21748               p_apps_to_uom     => p_ordered_quantity_uom,
21749               p_original_qty    => p_ordered_quantity2,
21750               p_lot_id          => nvl(p_lot_id, 0) ); -- OPM 2380194 */
21751 
21752     p_ordered_quantity := INV_CONVERT.INV_UM_CONVERT(p_inventory_item_id -- INVCONV
21753     																									,p_lot_number     -- INVCONV
21754     																									,p_ship_from_org_id -- INVCONV
21755                                                       ,5 --NULL
21756                                                       ,p_ordered_quantity2
21757                                                       ,p_ordered_quantity_uom2
21758                                                       ,p_ordered_quantity_uom
21759                                                       ,NULL -- From uom name
21760                                                       ,NULL -- To uom name
21761                                                       );
21762     IF (p_ordered_quantity < 0) THEN    -- INVCONV
21763               raise UOM_CONVERSION_FAILED;
21764     END IF;
21765 
21766     IF l_debug_level  > 0 THEN
21767        oe_debug_pub.add('Calculate_dual_quantity  - convert to ordered qty gives ' || p_ordered_quantity);
21768     END IF;
21769  END IF; --    IF (l_item_rec.secondary_default_ind in ('F','D')  -- INVCONV
21770 
21771 END IF; --  IF (NVL(p_ordered_quantity2,0) = 0
21772 
21773 IF l_debug_level  > 0 THEN
21774  			 oe_debug_pub.add('Calculate_dual_quantity  - exiting ordered qty = ' || p_ordered_quantity);
21775        oe_debug_pub.add('Calculate_dual_quantity  - exiting ordered qty2 = ' || p_ordered_quantity2);
21776     END IF;
21777 EXCEPTION
21778 
21779 WHEN UOM_CONVERSION_FAILED THEN
21780 				oe_debug_pub.add('Exception handling: UOM_CONVERSION_FAILED in calculate_dual_qty', 1);
21781     FND_MESSAGE.SET_NAME('INV','INV_NO_CONVERSION_ERR'); -- INVCONV
21782     OE_MSG_PUB.Add;
21783        x_return_status := -99999;
21784      --RAISE FND_API.G_EXC_ERROR;
21785 
21786 
21787 WHEN TOLERANCE_ERROR THEN -- INVCONV
21788 				oe_debug_pub.add('Exception handling: TOLERANCE_ERROR in calculate_dual_qty', 1);
21789  				 x_return_status := -1;
21790          --RAISE -- FND_API.G_EXC_ERROR; -- INVCONV
21791 
21792 WHEN OTHERS THEN
21793      IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
21794      THEN
21795          OE_MSG_PUB.Add_Exc_Msg
21796          (     G_PKG_NAME         ,
21797              'Calculate_dual_quantity'
21798          );
21799      END IF;
21800         oe_debug_pub.add('Exception handling: others in calculate_dual_qty', 1);
21801      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
21802 
21803 END calculate_dual_quantity;
21804 
21805 
21806 
21807 PROCEDURE Log_Blanket_Request
21808 (   p_x_line_rec                    IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
21809 ,   p_old_line_rec                  IN OE_Order_PUB.Line_Rec_Type
21810 )
21811 IS
21812   l_return_status                VARCHAR2(30);
21813 --
21814 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
21815 --
21816 BEGIN
21817 
21818     if l_debug_level > 0 then
21819        oe_debug_pub.add('line id : '||p_x_line_rec.line_id);
21820        oe_debug_pub.add('new blanket number : '||p_x_line_rec.blanket_number);
21821        oe_debug_pub.add('old blanket number : '||p_old_line_rec.blanket_number);
21822        oe_debug_pub.add('fulfilled flag : '||p_x_line_rec.fulfilled_flag);
21823        oe_debug_pub.add('operation : '||p_x_line_rec.operation);
21824        oe_debug_pub.add('split from line ID : '||p_x_line_rec.split_from_line_id);
21825        oe_debug_pub.add('split action code : '||p_x_line_rec.split_action_code);
21826        oe_debug_pub.add('split by : '||p_x_line_rec.split_by);
21827     end if;
21828 
21829     -- BUG 2746595, send currency code as request_unique_key1 parameter to
21830     -- process release request. This is required as 2 distinct requests need to
21831     -- be logged for currency updates.
21832 
21833     IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_DELETE
21834     THEN
21835 
21836        OE_Order_Cache.Load_Order_Header(p_x_line_rec.header_id);
21837 
21838        -- For DELETES, log process releases request with new values as
21839        -- null or 0 so that quantity/amount cumulations see negative
21840        -- changes thus resulting in decrementing final released qty/amount
21841        OE_Delayed_Requests_Pvt.Log_Request
21842            (p_entity_code               => OE_GLOBALS.G_ENTITY_ALL
21843            ,p_entity_id                 => p_x_line_rec.line_id
21844            ,p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_LINE
21845            ,p_requesting_entity_id      => p_x_line_rec.line_id
21846            ,p_request_type              => OE_GLOBALS.G_PROCESS_RELEASE
21847            -- Old values
21848            ,p_param1                    => p_x_line_rec.blanket_number
21849            ,p_param2                    => p_x_line_rec.blanket_line_number
21850            ,p_param3                    => p_x_line_rec.ordered_quantity
21851            ,p_param4                    => p_x_line_rec.order_quantity_uom
21852            ,p_param5                    => p_x_line_rec.unit_selling_price
21853            ,p_param6                    => p_x_line_rec.inventory_item_id
21854            -- New values
21855            ,p_param11                   => null
21856            ,p_param12                   => null
21857            ,p_param13                   => 0
21858            ,p_param14                   => null
21859            ,p_param15                   => 0
21860            ,p_param16                   => null
21861            -- Other parameters
21862            ,p_param8                    => p_x_line_rec.fulfilled_flag
21863            ,p_param9                    => p_x_line_rec.line_set_id
21864            ,p_request_unique_key1       =>
21865                         OE_Order_Cache.g_header_rec.transactional_curr_code
21866 
21867            ,x_return_status             => l_return_status
21868           );
21869 
21870        -- If this is a shipment line, log request against the line set
21871        -- to validate that sum of quantities/amounts across all shipments
21872        -- in this line set are within the release min/max limits on blanket
21873        IF p_x_line_rec.line_set_id IS NOT NULL THEN
21874          OE_Delayed_Requests_Pvt.Log_Request
21875            (p_entity_code               => OE_GLOBALS.G_ENTITY_ALL
21876            ,p_entity_id                 => p_x_line_rec.line_set_id
21877            ,p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_LINE
21878            ,p_requesting_entity_id      => p_x_line_rec.line_id
21879            ,p_request_type              => OE_GLOBALS.G_VALIDATE_RELEASE_SHIPMENTS
21880            ,p_request_unique_key1       => p_x_line_rec.blanket_number
21881            ,p_request_unique_key2       => p_x_line_rec.blanket_line_number
21882            ,p_param1                    =>
21883                         OE_Order_Cache.g_header_rec.transactional_curr_code
21884            ,x_return_status             => l_return_status
21885            );
21886        END IF;
21887 
21888      ELSIF (
21889                OE_Quote_Util.G_COMPLETE_NEG = 'Y'
21890             AND
21891       NOT OE_GLOBALS.EQUAL(p_x_line_rec.transaction_phase_code
21892                       ,p_old_line_rec.transaction_phase_code)
21893            )
21894      THEN
21895 
21896        if l_debug_level > 0 then
21897           oe_debug_pub.add('log blanket requests for complete neg');
21898        end if;
21899 
21900        OE_Order_Cache.Load_Order_Header(p_x_line_rec.header_id);
21901 
21902        -- Qty/amount against the blanket should be incremented by
21903        -- total qty/amount of this line, as complete negotiation is
21904        -- running consumption logic for this order first time.
21905        -- Hence, send old parameter (param1-6) values as null.
21906        OE_Delayed_Requests_Pvt.Log_Request
21907            (p_entity_code               => OE_GLOBALS.G_ENTITY_ALL
21908            ,p_entity_id                 => p_x_line_rec.line_id
21909            ,p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_LINE
21910            ,p_requesting_entity_id      => p_x_line_rec.line_id
21911            ,p_request_type              => OE_GLOBALS.G_PROCESS_RELEASE
21912            -- Old values
21913            ,p_param1                    => null
21914            ,p_param2                    => null
21915            ,p_param3                    => null
21916            ,p_param4                    => null
21917            ,p_param5                    => null
21918            ,p_param6                    => null
21919            -- New values
21920            ,p_param11                   => p_x_line_rec.blanket_number
21921            ,p_param12                   => p_x_line_rec.blanket_line_number
21922            ,p_param13                   => p_x_line_rec.ordered_quantity
21923            ,p_param14                   => p_x_line_rec.order_quantity_uom
21924            ,p_param15                   => p_x_line_rec.unit_selling_price
21925            ,p_param16                   => p_x_line_rec.inventory_item_id
21926            -- Other parameters
21927            ,p_param8                    => p_x_line_rec.fulfilled_flag
21928            ,p_param9                    => p_x_line_rec.line_set_id
21929            ,p_request_unique_key1       =>
21930                         OE_Order_Cache.g_header_rec.transactional_curr_code
21931            ,x_return_status             => l_return_status
21932           );
21933 
21934        -- If this is a shipment line, log request against the line set
21935        -- to validate that sum of quantities/amounts across all shipments
21936        -- in this line set are within the release min/max limits on blanket
21937        IF p_x_line_rec.line_set_id IS NOT NULL THEN
21938 
21939           IF p_x_line_rec.blanket_number IS NOT NULL THEN
21940               OE_Delayed_Requests_Pvt.Log_Request
21941                (p_entity_code               => OE_GLOBALS.G_ENTITY_ALL
21942                 ,p_entity_id                 => p_x_line_rec.line_set_id
21943                 ,p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_LINE
21944                 ,p_requesting_entity_id      => p_x_line_rec.line_id
21945                 ,p_request_type              => OE_GLOBALS.G_VALIDATE_RELEASE_SHIPMENTS
21946                 ,p_request_unique_key1       => p_x_line_rec.blanket_number
21947                 ,p_request_unique_key2       => p_x_line_rec.blanket_line_number
21948                 ,p_param1                    =>
21949                         OE_Order_Cache.g_header_rec.transactional_curr_code
21950                 ,x_return_status             => l_return_status
21951                 );
21952           END IF;
21953 
21954        END IF; -- if line_set_id is not null
21955 
21956     ELSIF (NOT OE_GLOBALS.EQUAL(p_x_line_rec.blanket_number
21957                             ,p_old_line_rec.blanket_number)
21958          OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.blanket_line_number
21959                             ,p_old_line_rec.blanket_line_number)
21960          OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity
21961                             ,p_old_line_rec.ordered_quantity)
21962          OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.unit_selling_price
21963                             ,p_old_line_rec.unit_selling_price)
21964          OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.order_quantity_uom
21965                             ,p_old_line_rec.order_quantity_uom)
21966           )
21967     THEN
21968 
21969        -- For creates and updates, log request if any fields affecting
21970        -- quantities/amounts are changed
21971 
21972        OE_Order_Cache.Load_Order_Header(p_x_line_rec.header_id);
21973 
21974        OE_Delayed_Requests_Pvt.Log_Request
21975            (p_entity_code               => OE_GLOBALS.G_ENTITY_ALL
21976            ,p_entity_id                 => p_x_line_rec.line_id
21977            ,p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_LINE
21978            ,p_requesting_entity_id      => p_x_line_rec.line_id
21979            ,p_request_type              => OE_GLOBALS.G_PROCESS_RELEASE
21980            -- Old values
21981            ,p_param1                    => p_old_line_rec.blanket_number
21982            ,p_param2                    => p_old_line_rec.blanket_line_number
21983            ,p_param3                    => p_old_line_rec.ordered_quantity
21984            ,p_param4                    => p_old_line_rec.order_quantity_uom
21985            ,p_param5                    => p_old_line_rec.unit_selling_price
21986            ,p_param6                    => p_old_line_rec.inventory_item_id
21987            -- New values
21988            ,p_param11                   => p_x_line_rec.blanket_number
21989            ,p_param12                   => p_x_line_rec.blanket_line_number
21990            ,p_param13                   => p_x_line_rec.ordered_quantity
21991            ,p_param14                   => p_x_line_rec.order_quantity_uom
21992            ,p_param15                   => p_x_line_rec.unit_selling_price
21993            ,p_param16                   => p_x_line_rec.inventory_item_id
21994            -- Other parameters
21995            ,p_param8                    => p_x_line_rec.fulfilled_flag
21996            ,p_param9                    => p_x_line_rec.line_set_id
21997            ,p_request_unique_key1       =>
21998                         OE_Order_Cache.g_header_rec.transactional_curr_code
21999            ,x_return_status             => l_return_status
22000           );
22001 
22002        -- If this is a shipment line, log request against the line set
22003        -- to validate that sum of quantities/amounts across all shipments
22004        -- in this line set are within the release min/max limits on blanket
22005        IF p_x_line_rec.line_set_id IS NOT NULL THEN
22006 
22007           IF p_x_line_rec.blanket_number IS NOT NULL THEN
22008               OE_Delayed_Requests_Pvt.Log_Request
22009                (p_entity_code               => OE_GLOBALS.G_ENTITY_ALL
22010                 ,p_entity_id                 => p_x_line_rec.line_set_id
22011                 ,p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_LINE
22012                 ,p_requesting_entity_id      => p_x_line_rec.line_id
22013                 ,p_request_type              => OE_GLOBALS.G_VALIDATE_RELEASE_SHIPMENTS
22014                 ,p_request_unique_key1       => p_x_line_rec.blanket_number
22015                 ,p_request_unique_key2       => p_x_line_rec.blanket_line_number
22016                 ,p_param1                    =>
22017                         OE_Order_Cache.g_header_rec.transactional_curr_code
22018                 ,x_return_status             => l_return_status
22019                 );
22020           END IF;
22021 
22022           -- If blanket number is being updated on the shipment, also
22023           -- need to run shipment validation for the old blanket reference
22024           IF p_old_line_rec.blanket_number IS NOT NULL
22025              AND (NOT OE_GLOBALS.EQUAL(p_x_line_rec.blanket_number
22026                                     ,p_old_line_rec.blanket_number)
22027                   OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.blanket_line_number
22028                                      ,p_old_line_rec.blanket_line_number)
22029                   )
22030           THEN
22031               OE_Delayed_Requests_Pvt.Log_Request
22032                (p_entity_code               => OE_GLOBALS.G_ENTITY_ALL
22033                 ,p_entity_id                 => p_x_line_rec.line_set_id
22034                 ,p_requesting_entity_code    => OE_GLOBALS.G_ENTITY_LINE
22035                 ,p_requesting_entity_id      => p_x_line_rec.line_id
22036                 ,p_request_type              => OE_GLOBALS.G_VALIDATE_RELEASE_SHIPMENTS
22037                 ,p_request_unique_key1       => p_old_line_rec.blanket_number
22038                 ,p_request_unique_key2       => p_old_line_rec.blanket_line_number
22039                 ,p_param1                    =>
22040                         OE_Order_Cache.g_header_rec.transactional_curr_code
22041                 ,x_return_status             => l_return_status
22042                 );
22043           END IF;
22044 
22045        END IF; -- if line_set_id is not null
22046 
22047     END IF; -- if operation is DELETE
22048 
22049     IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
22050       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
22051     END IF;
22052 
22053 EXCEPTION
22054    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
22055      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
22056    WHEN OTHERS THEN
22057      oe_debug_pub.add('Others error in Log_Blanket_Request');
22058      oe_debug_pub.add('Error :'||substr(sqlerrm,1,200));
22059      IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
22060      THEN
22061          OE_MSG_PUB.Add_Exc_Msg
22062          (     G_PKG_NAME         ,
22063              'Log_Blanket_Request'
22064          );
22065      END IF;
22066      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
22067 END Log_Blanket_Request;
22068 
22069 
22070 /*sdatti*/
22071 --procedure to update the adjustments of a line when the item is changed.
22072 --should handle deleting the IUE associations and the updating the
22073 --parent adjustments for free goods
22074 --see bug#2643552
22075 
22076 PROCEDURE  update_adjustment_flags
22077   ( p_old_line_rec IN OE_Order_PUB.line_rec_type,
22078     p_x_line_rec IN OE_Order_PUB.line_rec_type)
22079   IS
22080 
22081 --cursor to return the current line association id and the
22082 --parent line assocation id through the OE_PRICE_ADJ_ASSOCS table
22083 CURSOR C1 IS
22084    SELECT opa1.price_adjustment_id, opa2.price_adjustment_id, opa1.line_id
22085      FROM
22086       oe_price_adjustments opa1,
22087       oe_price_adj_assocs opaa,
22088       oe_price_adjustments opa2
22089      WHERE
22090      opa1.line_id = p_old_line_rec.line_id
22091      AND opa1.price_adjustment_id = opaa.rltd_price_adj_id
22092      AND opaa.price_adjustment_id = opa2.price_adjustment_id
22093      AND opa2.list_line_type_code = 'PRG';
22094 
22095 --cursor to find the IUE adjustments for this line
22096 CURSOR c2 IS
22097    SELECT price_adjustment_id
22098      FROM oe_price_adjustments
22099      where line_id=p_old_line_rec.line_id AND list_line_type_code='IUE';
22100 
22101 --variables to read the cursor C1 into
22102 parent_adj_id                oe_price_adjustments.price_adjustment_id%TYPE;
22103 child_adj_id                 oe_price_adjustments.price_adjustment_id%TYPE;
22104 child_line_id		     oe_price_adjustments.line_id%TYPE;
22105 
22106 iue_adj_id                   oe_price_adjustments.price_adjustment_id%TYPE;
22107 app_f			     oe_price_adjustments.applied_flag%TYPE;
22108 up_f			     oe_price_adjustments.updated_flag%TYPE;
22109 row_count                    NUMBER;
22110 
22111 BEGIN
22112    oe_debug_pub.ADD('Entering OE_LINE_UTIL.UPDATE_ADJUSTMENT_FLAGS',1);
22113 
22114    IF p_old_line_rec.inventory_item_id IS NULL THEN
22115       --new item, dont need to do anything
22116       oe_debug_pub.ADD('New Item, dont have to do anything',1);
22117       oe_debug_pub.ADD('Exiting OE_LINE_UTIL.UPDATE_ADJUSTMENT_FLAGS',1);
22118       RETURN;
22119    END IF;
22120 
22121    --deleting the IUE adjustment
22122    /*   DELETE FROM oe_price_adjustments
22123    where line_id=p_old_line_rec.line_id AND list_line_type_code='IUE';*/
22124 
22125    oe_debug_pub.ADD('trying to delete IUE adjustments...',1);
22126    OPEN c2;
22127    FETCH c2 INTO iue_adj_id;
22128    IF c2%found THEN
22129       oe_line_adj_util.delete_row(p_price_adjustment_id=>iue_adj_id);
22130       oe_debug_pub.ADD('deleted IUE association:'||SQL%rowcount||' row(s)',1);
22131       oe_debug_pub.ADD('looking for item parent lines...',1);
22132    END IF;
22133    CLOSE c2;
22134 
22135 
22136 
22137    OPEN c1;
22138 	     loop
22139 		--loop through all the parents
22140 		FETCH c1 INTO child_adj_id, parent_adj_id,child_line_id;
22141 		EXIT WHEN c1%notfound;
22142 
22143 		oe_debug_pub.ADD('found parent line:'||parent_adj_id||' for child line:'||child_adj_id,1);
22144 
22145 			--delete the adjustment if this is the child line.
22146 		IF child_line_id=p_old_line_rec.line_id then
22147 		   oe_debug_pub.ADD('trying to delete adjustments for line_id:'||p_old_line_rec.line_id,1);
22148 		   oe_line_adj_util.delete_row(p_line_id=>p_old_line_rec.line_id);
22149 		   oe_debug_pub.ADD('child adj id '||child_adj_id,1);
22150 	           OE_Line_Adj_Assocs_Util.delete_row(
22151 			p_price_adjustment_id=>child_adj_id);
22152 		END IF;
22153 
22154 		--Find out the number of free items adjustments associated with this parent
22155 		--(other then this item, we already deleted its adjustment)
22156 		SELECT COUNT(*) INTO row_count
22157 		  FROM oe_price_adj_assocs opaa,oe_price_adjustments opa
22158 		  WHERE opaa.price_adjustment_id=parent_adj_id
22159 		  AND opaa.rltd_price_adj_id=opa.price_adjustment_id;
22160 		oe_debug_pub.ADD('total '||row_count||' free child record(s)',1);
22161 
22162 		IF  row_count>0 THEN
22163 		   --not the only free item, this adjustment is applied _and_ updated = 'Y'
22164 		   UPDATE oe_price_adjustments
22165 		     SET applied_flag='Y',updated_flag='Y'
22166 		     WHERE price_adjustment_id=parent_adj_id;
22167 		   oe_debug_pub.ADD('updated parent adjustment: applied_flag=Y,updated_flag=Y:'||SQL%rowcount||' row(s)',1);
22168                    UPDATE oe_price_adjustments
22169                      SET updated_flag = 'Y' where price_adjustment_id in
22170                       (select rltd_price_adj_id from oe_price_adj_assocs
22171                        where price_adjustment_id = parent_adj_id);
22172 		 ELSE
22173 		   --the last (or only) free item, make parent adjustment applied='N'
22174 		   UPDATE oe_price_adjustments
22175 		     SET applied_flag='N',updated_flag='Y'
22176 		     WHERE price_adjustment_id=parent_adj_id;
22177 		   oe_debug_pub.ADD('updated parent adjustment: applied_flag=N,updated_flag=Y:'||SQL%rowcount||' rows',1);
22178 		END IF;
22179 		SELECT applied_flag,updated_flag INTO app_f,up_f
22180 		  FROM oe_price_adjustments
22181 		  WHERE price_adjustment_id=parent_adj_id;
22182 		oe_debug_pub.ADD('price_adjustment_id:'||parent_adj_id||' applied_flag='||app_f||' updated_flag='||up_f,1);
22183 
22184 
22185 	     END LOOP;
22186 	     CLOSE c1;
22187 	     oe_debug_pub.ADD('...done looking for item parent lines',1);
22188 	     oe_debug_pub.ADD('Exiting OE_LINE_UTIL.UPDATE_ADJUSTMENT_FLAGS',1);
22189 	     RETURN;
22190 
22191 END update_adjustment_flags;
22192 
22193 /*sdatti*/
22194 
22195 
22196 /* Procedure Get_Item_Info
22197 -------------------------------------------------------
22198 This procedure will return ordered_item, ordered_item_description and
22199 inventory_item based on passing in item_identifier_type */
22200 
22201 PROCEDURE GET_ITEM_INFO
22202 (   x_return_status         OUT NOCOPY VARCHAR2
22203 ,   x_msg_count             OUT NOCOPY NUMBER
22204 ,   x_msg_data              OUT NOCOPY VARCHAR2
22205 ,   p_item_identifier_type          IN VARCHAR2
22206 ,   p_inventory_item_id             IN Number
22207 ,   p_ordered_item_id               IN Number
22208 ,   p_sold_to_org_id                IN Number
22209 ,   p_ordered_item                  IN VARCHAR2
22210 ,   x_ordered_item          OUT NOCOPY VARCHAR2
22211 ,   x_ordered_item_desc     OUT NOCOPY VARCHAR2
22212 ,   x_inventory_item        OUT NOCOPY VARCHAR2
22213 ,   p_org_id                        IN Number DEFAULT NULL
22214 ) IS
22215 
22216 BEGIN
22217 
22218 -- Bug 5244726
22219 OE_ORDER_MISC_UTIL.GET_ITEM_INFO( x_return_status
22220 ,   x_msg_count
22221 ,   x_msg_data
22222 ,   p_item_identifier_type
22223 ,   p_inventory_item_id
22224 ,   p_ordered_item_id
22225 ,   p_sold_to_org_id
22226 ,   p_ordered_item
22227 ,   x_ordered_item
22228 ,   x_ordered_item_desc
22229 ,   x_inventory_item
22230 ,   p_org_id );
22231 
22232 EXCEPTION
22233 
22234     WHEN OTHERS THEN
22235 
22236         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
22237         THEN
22238             OE_MSG_PUB.Add_Exc_Msg (   G_PKG_NAME ,   'GET_ITEM_INFO');
22239         END IF;
22240 
22241         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
22242 
22243 END GET_ITEM_INFO;
22244 
22245 
22246 -----------------------------------------------------------------
22247 --      *** Enhanced Dropshipments ***
22248 -----------------------------------------------------------------
22249 /*--------------------------------------------------------------+
22250 Name          : Log_Dropship_CMS_Request
22251 Description   : This Procedure will log CMS Delayed Request when
22252                 ever there is a change in the CMS attributes
22253                 This procedure will be called from Pre Write
22254                 Process and delayed request will be executed at
22255                 the commit time.
22256 Change Record :
22257 +--------------------------------------------------------------*/
22258 Procedure Log_Dropship_CMS_Request
22259 ( p_x_line_rec            IN OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
22260 , p_old_line_rec          IN OE_Order_PUB.Line_Rec_Type
22261 )
22262 IS
22263  l_return_status         VARCHAR2(30);
22264  l_debug_level CONSTANT  NUMBER := oe_debug_pub.g_debug_level;
22265  l_operation             VARCHAR2(30) := p_x_line_rec.operation;
22266  l_count                 NUMBER;
22267  l_ref_data_elem_changed VARCHAR2(1) := 'N';
22268  l_cust_po_attr_change   BOOLEAN := FALSE ;
22269  l_rcv_count             NUMBER := 0;
22270  l_log_cust_po_change    boolean:=TRUE;
22271  l_ref_data_only         boolean:=FALSE;
22272 BEGIN
22273 
22274   IF l_debug_level >  0 THEN
22275      OE_DEBUG_PUB.Add('Entering Log_Dropship_CMS_Request...', 2);
22276   END IF;
22277 
22278   SELECT  count(*)
22279     INTO  l_count
22280     FROM  oe_drop_ship_sources
22281    WHERE  line_id   = p_x_line_rec.line_id
22282      AND  header_id = p_x_line_rec.header_id;
22283 
22284   IF l_count = 0 THEN
22285      IF l_debug_level > 0 THEN
22286         OE_DEBUG_PUB.Add('No Records in Drop Ship Sources,Returning...', 2);
22287      END IF;
22288      RETURN;
22289   END IF;
22290 
22291   IF OE_DS_PVT.Check_Req_PO_Cancelled
22292               (p_line_id    =>   p_x_line_rec.line_id
22293               ,p_header_id  =>   p_x_line_rec.header_id)  THEN
22294 
22295         FND_MESSAGE.Set_Name('ONT', 'ONT_DS_PO_CANCELLED');
22296         OE_MSG_PUB.Add;
22297         RAISE FND_API.G_EXC_ERROR;
22298   END IF;
22299 
22300 
22301   IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.shipping_instructions
22302                               ,p_old_line_rec.shipping_instructions)
22303      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.packing_instructions
22304                               ,p_old_line_rec.packing_instructions)
22305      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_to_contact_id
22306                               ,p_old_line_rec.ship_to_contact_id)
22307      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.deliver_to_org_id
22308                               ,p_old_line_rec.deliver_to_org_id)
22309      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.deliver_to_contact_id
22310                               ,p_old_line_rec.deliver_to_contact_id)
22311      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.user_item_description
22312                               ,p_old_line_rec.user_item_description)
22313     /* OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.cust_po_number
22314                               ,p_old_line_rec.cust_po_number)  	    --commented for ER 6072870
22315      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.customer_line_number
22316                               ,p_old_line_rec.customer_line_number)
22317      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.customer_shipment_number
22318                               ,p_old_line_rec.customer_shipment_number) */
22319      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.shipping_method_code
22320                               ,p_old_line_rec.shipping_method_code) THEN
22321 
22322      IF l_debug_level > 0 THEN
22323         OE_DEBUG_PUB.Add('Change in Reference Data Elements...', 2);
22324      END IF;
22325 
22326      l_ref_data_elem_changed   :=   'Y';
22327      l_ref_data_only := true;
22328 
22329   END IF;
22330 /* Added for ER 6072870*/
22331 
22332 if NOT OE_GLOBALS.EQUAL(p_x_line_rec.cust_po_number
22333                               ,p_old_line_rec.cust_po_number)
22334      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.customer_line_number
22335                               ,p_old_line_rec.customer_line_number)
22336      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.customer_shipment_number
22337                              ,p_old_line_rec.customer_shipment_number) THEN
22338     --{
22339 	IF l_debug_level > 0 THEN
22340 		OE_DEBUG_PUB.Add('Change in customer PO Reference Data Elements...', 2);
22341 	END IF;
22342 	l_ref_data_elem_changed   :=   'Y';
22343 	l_cust_po_attr_change:=true;
22344     --}
22345   end if;
22346 
22347   IF l_cust_po_attr_change THEN
22348   --{
22349    IF Nvl(p_x_line_rec.shipped_quantity,0)>0 THEN
22350    --{
22351     if l_debug_level > 0 then
22352          oe_debug_pub.add('Drop ship line is already received.So do not log CMS request', 1);
22353 	 l_log_cust_po_change:=FALSE;
22354     end if;
22355    --}
22356    ELSE
22357    --{
22358 	BEGIN
22359 		SELECT Count(1)
22360 		INTO l_rcv_count
22361 		FROM rcv_transactions rcv,
22362 		oe_drop_ship_sources odss,
22363 		po_line_locations_all pol
22364 		WHERE rcv.PO_LINE_ID=odss.po_line_id
22365 		AND pol.line_location_id=odss.line_location_id
22366 		AND odss.line_id=p_x_line_rec.line_id
22367 		AND RCV.PO_LINE_LOCATION_ID=pol.LINE_LOCATION_ID
22368 		AND TRANSACTION_TYPE='DELIVER'
22369 		AND Nvl(rcv.quantity,0)>0
22370 		AND INTERFACE_SOURCE_CODE='RCV'
22371 		AND SOURCE_DOCUMENT_CODE='PO';
22372 
22373 		if l_debug_level > 0 then
22374 		oe_debug_pub.add('line has been received either fully or partially do not log request', 1);
22375 		l_log_cust_po_change:=FALSE;
22376 		end if;
22377 
22378 	EXCEPTION
22379 	WHEN No_Data_Found THEN
22380 		if l_debug_level > 0 then
22381 		oe_debug_pub.add('line is not yet received can interface to PO', 1);
22382 		end if;
22383 	        l_log_cust_po_change:=TRUE;
22384         END;
22385    --}
22386    END IF;
22387   --}
22388   END IF;
22389 
22390  /* IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity2  - remove this as valid now for INVCONV
22391                               ,p_old_line_rec.ordered_quantity2) THEN
22392 
22393      FND_MESSAGE.Set_Name('ONT','ONT_DS_OPM_QTY_CHANGED');
22394      OE_MSG_PUB.Add;
22395 
22396      IF l_debug_level > 0 THEN
22397         OE_DEBUG_PUB.Add('Warning!! Secondary Qty Changed...', 2);
22398      END IF;
22399   END IF;
22400 
22401   IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity_uom2
22402                               ,p_old_line_rec.ordered_quantity_uom2) THEN
22403 
22404      FND_MESSAGE.Set_Name('ONT','ONT_DS_OPM_UOM_CHANGED');
22405      OE_MSG_PUB.Add;
22406 
22407      IF l_debug_level > 0 THEN
22408         OE_DEBUG_PUB.Add('Warning!! Secondary Qty UOM Changed...', 2);
22409      END IF;
22410   END IF;
22411 
22412   IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.preferred_grade
22413                               ,p_old_line_rec.preferred_grade) THEN
22414 
22415      FND_MESSAGE.Set_Name('ONT', 'ONT_DS_OPM_GRADE_CHANGED');
22416      OE_MSG_PUB.Add;
22417 
22418      IF l_debug_level > 0 THEN
22419         OE_DEBUG_PUB.Add('Warning!! OPM Grade Changed...', 2);
22420      END IF;
22421 
22422   END IF; */
22423 
22424 
22425   IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity
22426                              ,p_old_line_rec.ordered_quantity)
22427      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.order_quantity_uom
22428                               ,p_old_line_rec.order_quantity_uom)
22429      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity2
22430                               ,p_old_line_rec.ordered_quantity2)
22431      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.ordered_quantity_uom2
22432                               ,p_old_line_rec.ordered_quantity_uom2)
22433      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.preferred_grade
22434                               ,p_old_line_rec.preferred_grade)
22435      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.schedule_ship_date
22436                               ,p_old_line_rec.schedule_ship_date)
22437      OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_to_org_id
22438                               ,p_old_line_rec.ship_to_org_id)
22439      OR (l_ref_data_only )	 -- Added for ER 6072870
22440      OR (l_cust_po_attr_change and not l_ref_data_only and l_log_cust_po_change )
22441      OR p_x_line_rec.operation  ='DELETE'
22442 
22443      THEN
22444 
22445 
22446 
22447        IF (p_x_line_rec.ordered_quantity = 0 AND
22448              OE_SALES_CAN_UTIL.G_REQUIRE_REASON) OR
22449                    p_x_line_rec.operation = 'DELETE' THEN
22450           l_operation   :=  'CANCEL';
22451        END IF;
22452 
22453        IF l_debug_level >  0 THEN
22454         OE_DEBUG_PUB.Add('-----Logging Dropship_CMS_Request----for Entity:'||
22455                                                      p_x_line_rec.line_id, 2);
22456        END IF;
22457 
22458        OE_Delayed_Requests_Pvt.Log_Request
22459              (p_entity_code             =>   OE_GLOBALS.G_ENTITY_ALL
22460              ,p_entity_id               =>   p_x_line_rec.line_id
22461              ,p_requesting_entity_code  =>   OE_GLOBALS.G_ENTITY_LINE
22462              ,p_requesting_entity_id    =>   p_x_line_rec.line_id
22463              ,p_request_type            =>   OE_GLOBALS.G_DROPSHIP_CMS
22464              ,p_param1                  =>   p_old_line_rec.ordered_quantity
22465              ,p_param2                  =>   p_old_line_rec.order_quantity_uom
22466              ,p_param3                  =>   p_old_line_rec.ship_to_org_id
22467              ,p_param4                  =>   p_old_line_rec.ordered_quantity2
22468              ,p_param5                  =>   p_old_line_rec.ordered_quantity_uom2
22469              ,p_param6                  =>   p_old_line_rec.preferred_grade
22470   --         ,p_param7                  =>   p_old_line_rec.schedule_ship_date  --commented for bug#6918700
22471              ,p_param8                  =>   p_x_line_rec.ordered_quantity
22472              ,p_param9                  =>   p_x_line_rec.order_quantity_uom
22473              ,p_param10                 =>   p_x_line_rec.ship_to_org_id
22474              ,p_param11                 =>   p_x_line_rec.ordered_quantity2
22475              ,p_param12                 =>   p_x_line_rec.ordered_quantity_uom2
22476              ,p_param13                 =>   p_x_line_rec.preferred_grade
22477   --         ,p_param14                 =>   p_x_line_rec.schedule_ship_date    --commented for bug#6918700
22478              ,p_param15                 =>   l_operation
22479              ,p_param16                 =>   l_ref_data_elem_changed
22480 /*****Begin changes for bug#6918700*********/
22481 	     ,p_date_param1             =>   p_old_line_rec.schedule_ship_date
22482 	     ,p_date_param2             =>   p_x_line_rec.schedule_ship_date
22483 /*****End changes for bug#6918700*********/
22484              ,x_return_status           =>   l_return_status
22485             );
22486 
22487 END IF;
22488 
22489      IF l_debug_level >  0 THEN
22490         OE_DEBUG_PUB.Add('After Logging CMS_Request...'||l_return_status, 2);
22491      END IF;
22492 
22493      IF l_return_status <>  FND_API.G_RET_STS_SUCCESS THEN
22494         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
22495      END IF;
22496 
22497      IF l_debug_level >  0 THEN
22498         OE_DEBUG_PUB.Add('Exiting Log_Dropship_CMS_Request...', 2);
22499      END IF;
22500 
22501 
22502 EXCEPTION
22503 
22504     WHEN  FND_API.G_EXC_ERROR THEN
22505        IF l_debug_level >  0 THEN
22506           OE_DEBUG_PUB.Add('Execution Error in Log_Dropship_CMS_Request', 2);
22507        END IF;
22508        RAISE FND_API.G_EXC_ERROR;
22509 
22510     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
22511        IF l_debug_level >  0 THEN
22512           OE_DEBUG_PUB.Add('Unexpected Error in Log_Dropship_CMS_Request'||
22513                                  sqlerrm, 1);
22514        END IF;
22515        RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
22516 
22517     WHEN OTHERS THEN
22518 
22519       IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
22520       THEN
22521         OE_MSG_PUB.Add_Exc_Msg
22522         (   G_PKG_NAME,
22523           'Log_Dropship_CMS_Request');
22524       END IF;
22525 
22526 END Log_Dropship_CMS_Request;
22527 
22528 
22529 -- Added new API (HANDLE_RFR proc) for FP bug 6628653 base bug 6513023
22530 PROCEDURE HANDLE_RFR
22531 (
22532 p_line_id            IN NUMBER,
22533 p_top_model_line_id  IN NUMBER,
22534 p_link_to_line_id     IN NUMBER
22535 )
22536 IS
22537    l_is_rfr          NUMBER;
22538    l_open_rfr_lines  NUMBER;
22539    l_activity_status_code  VARCHAR2(30);
22540    l_result_out      VARCHAR2(30);
22541    l_return_status   VARCHAR2(30);
22542    l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
22543 
22544 BEGIN
22545    IF l_debug_level > 0 THEN
22546       oe_debug_pub.add('Entering HANDLE_RFR ... ', 1);
22547       oe_debug_pub.add(' with p_line_id  '|| p_line_id , 1);
22548       oe_debug_pub.add(' with p_top_model_line_id  '|| p_top_model_line_id , 1);
22549       oe_debug_pub.add(' with p_link_to_line_id  '|| p_link_to_line_id , 1);
22550    END IF;
22551 
22552        SELECT nvl(bic.required_for_revenue, 0)
22553        INTO   l_is_rfr
22554        FROM   oe_order_lines Line,
22555               bom_inventory_components bic
22556        WHERE  Line.line_id = p_line_id
22557        AND    Line.open_flag = 'N'
22558        AND    bic.component_sequence_id = Line.component_sequence_id
22559        AND    bic.component_item_id = Line.inventory_item_id;
22560 
22561        IF l_is_rfr = 1 THEN
22562           IF l_debug_level > 0 THEN
22563              oe_debug_pub.add('Component being cancelled is marked as RFR, checking if any other RFR Lines are open', 5);
22564           END IF;
22565 
22566           SELECT count(1)
22567           INTO   l_open_rfr_lines
22568           FROM   oe_order_lines Line,
22569                  bom_inventory_components bic
22570           WHERE  Line.line_id <> p_line_id
22571           AND    Line.top_model_line_id = p_top_model_line_id
22572           AND    Line.link_to_line_id = p_link_to_line_id
22573           AND    Line.open_flag = 'Y'
22574           AND    bic.component_sequence_id = Line.component_sequence_id
22575           AND    bic.component_item_id = Line.inventory_item_id
22576           AND    bic.required_for_revenue = 1;
22577 
22578           IF l_open_rfr_lines = 0 THEN
22579 
22580              IF l_debug_level > 0 THEN
22581                 oe_debug_pub.add('No more pending RFR lines under current parent, checking status of Parent Line', 5);
22582              END IF;
22583 
22584              BEGIN
22585                 SELECT ACTIVITY_STATUS
22586                 INTO   l_activity_status_code
22587                 FROM   wf_item_activity_statuses wias,
22588                        wf_process_activities wpa
22589                 WHERE  wias.item_type = 'OEOL'
22590                 AND    wias.item_key  = to_char(p_link_to_line_id)
22591                 AND    wias.process_activity = wpa.instance_id
22592                 AND    wpa.activity_item_type = 'OEOL'
22593                 AND    wpa.activity_name = 'INVOICING_WAIT_FOR_RFR'
22594                 AND    wias.activity_status = 'NOTIFIED';
22595 
22596                 EXCEPTION
22597                 WHEN OTHERS THEN
22598                    l_activity_status_code := null;
22599                    oe_debug_pub.add(' in exception block -  '||SQLERRM, 5);
22600              END;
22601 
22602              IF l_activity_status_code = 'NOTIFIED' THEN
22603                 IF l_debug_level > 0 THEN
22604                    oe_debug_pub.add('Parent Line waiting to be invoiced, calling API to Invoice Parent ', 5);
22605                 END IF;
22606 
22607                OE_Invoice_PUB.Interface_Line(  p_link_to_line_id
22608                                               ,OE_GLOBALS.G_WFI_LIN
22609                                               ,l_result_out
22610                                               ,l_return_status);
22611 
22612                 IF l_debug_level  > 0 THEN
22613                     oe_debug_pub.add(  ' after call to invoice api:   l_result_out: '||l_result_out ) ;
22614                     oe_debug_pub.add(  ' after call to invoice api:   l_return_status: '|| l_return_status ) ;
22615                 END IF;
22616 
22617                 /*
22618                   Need to check only l_return_status. If SUCCESS, do COMPLETE with default transition
22619                 */
22620                 IF l_return_status = FND_API.G_RET_STS_SUCCESS  THEN
22621                     IF l_debug_level  > 0 THEN
22622                          oe_debug_pub.add(  'Updating Line Flow Status and pushing WF ');
22623                     END IF;
22624                     Update oe_order_lines
22625                     Set flow_status_code = 'INVOICED'
22626                     Where line_id = p_link_to_line_id;
22627 
22628                     BEGIN
22629                         WF_ENGINE.CompleteActivityInternalName(OE_GLOBALS.G_WFI_LIN, p_link_to_line_id, 'INVOICING_WAIT_FOR_RFR', null);
22630                     EXCEPTION
22631                         WHEN OTHERS THEN
22632                            oe_debug_pub.add(' Error in completing activity; SQL Message -  '||SQLERRM, 5);
22633                     END;
22634                 ELSE
22635                    oe_debug_pub.add(' l_return_status is not equal to Success, do nothing  ', 5);
22636                 END IF; --checking l_return_status
22637 
22638              ELSE
22639                 IF l_debug_level > 0 THEN
22640                    oe_debug_pub.add('Parent Line is not waiting to be Invoiced, do nothing', 5);
22641                 END IF;
22642              END IF; -- activity_status=NOTIFIED
22643           ELSE
22644              IF l_debug_level > 0 THEN
22645                 oe_debug_pub.add('Other RFR lines are still open, no need to Invoice Parent Line', 5);
22646              END IF;
22647           END IF; -- IF l_open_rfr_lines ...
22648        ELSE
22649           IF l_debug_level > 0 THEN
22650             oe_debug_pub.add('Current line being cancelled is not RFR', 5);
22651           END IF;
22652        END IF; -- IF l_is_rfr ...
22653 
22654 
22655       IF l_debug_level > 0 THEN
22656           oe_debug_pub.add('Exiting HANDLE_RFR ...', 1);
22657       END IF;
22658 
22659 END HANDLE_RFR;
22660 
22661 
22662 END oe_line_util;