DBA Data[Home] [Help]

PACKAGE BODY: APPS.OE_OE_FORM_LINE

Source


1 PACKAGE BODY oe_oe_form_line AS
2 /* $Header: OEXFLINB.pls 120.31.12020000.5 2013/04/01 09:21:42 srpasuma ship $ */
3 
4 --  Global constant holding the package name
5 
6 G_PKG_NAME                    CONSTANT VARCHAR2(30) := 'Oe_Oe_Form_Line';
7 
8 --  Global variables holding cached record.
9 
10 g_line_rec                    OE_Order_PUB.Line_Rec_Type;
11 g_db_line_rec                 OE_Order_PUB.Line_Rec_Type;
12 g_current_header_id           NUMBER := 0;
13 --retro{Global variables for caching header_id and currency code
14 g_header_id                   NUMBER;
15 g_currency_code               VARCHAR2(15);
16 --retro}
17 
18 --  for 5331980 start
19 g_subtotal   NUMBER;
20 g_charges    NUMBER;
21 g_discount   NUMBER;
22 g_total_tax  NUMBER;
23 -- for 5331980 end
24 
25 --  Forward declaration of procedures maintaining entity record cache.
26 
27 PROCEDURE Write_line
28 (   p_line_rec                      IN  OE_Order_PUB.Line_Rec_Type
29 ,   p_db_record                     IN  BOOLEAN := FALSE
30 );
31 
32 -- Bug 1713035
33 -- Procedure Get_Line is now visible to other packages
34 /*
35 PROCEDURE Get_line
36 (   p_db_record                     IN  BOOLEAN := FALSE
37 ,   p_line_id                       IN  NUMBER
38 ,   x_line_rec                      OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
39 );
40 */
41 
42 PROCEDURE Clear_line;
43 
44 PROCEDURE get_customer_details ( p_site_use_id IN NUMBER,
45                                  p_site_use_code IN VARCHAR2,
46 x_customer_id OUT NOCOPY NUMBER,
47 x_customer_name OUT NOCOPY VARCHAR2,
48 x_customer_number OUT NOCOPY VARCHAR2
49                                    );
50 
51 --bug16574638
52 PROCEDURE Get_return_reference
53 ( p_line_id           IN NUMBER,
54   x_return_context    OUT NOCOPY VARCHAR2,
55   x_return_attribute1 OUT NOCOPY VARCHAR2,
56   x_return_attribute2 OUT NOCOPY VARCHAR2);
57 --bug16574638
58 
59 FUNCTION Get_Date_Type(p_header_id IN NUMBER)
60 RETURN VARCHAR2;
61 
62 --  Global variable holding performed operations.
63 
64 g_opr__tbl                    OE_Order_PUB.Line_Tbl_Type;
65 
66 --  Procedure : Default_Attributes
67 --
68 
69 PROCEDURE Default_Attributes
70 ( x_return_status OUT NOCOPY VARCHAR2
71 , x_msg_count OUT NOCOPY NUMBER
72 , x_msg_data OUT NOCOPY VARCHAR2
73 ,   p_header_id                     IN  NUMBER
74 ,   x_line_tbl                      IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type
75 ,   x_old_line_tbl                  IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type
76 ,   x_line_val_tbl                  IN OUT NOCOPY OE_ORDER_PUB.Line_Val_Tbl_Type
77 
78 )
79 IS
80 l_control_rec                 OE_GLOBALS.Control_Rec_Type;
81 l_return_status               VARCHAR2(1);
82 l_x_header_rec                OE_Order_PUB.Header_Rec_Type;
83 l_error NUMBER := 0;
84 --
85 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
86 --
87 BEGIN
88 
89     IF l_debug_level  > 0 THEN
90         oe_debug_pub.add(  'ENTERING OE_OE_FORM_LINE.DEFAULT_ATTRIBUTES' , 1 ) ;
91     END IF;
92 
93   l_error := 1;
94     -- Set UI flag to TRUE
95     OE_GLOBALS.G_UI_FLAG := TRUE;
96 
97     --  Set control flags.
98 
99     l_control_rec.controlled_operation := TRUE;
100     l_control_rec.check_security        := TRUE;
101     l_control_rec.default_attributes   := TRUE;
102     l_control_rec.change_attributes    := TRUE;
103 
104     l_control_rec.clear_dependents     := FALSE;
105     l_control_rec.validate_entity      := FALSE;
106     l_control_rec.write_to_DB          := FALSE;
107     l_control_rec.process              := FALSE;
108 
109     --  Instruct API to retain its caches
110 
111     l_control_rec.clear_api_cache      := FALSE;
112     l_control_rec.clear_api_requests   := FALSE;
113 
114     --  Load IN parameters if any exist
115     x_old_line_tbl(1)     :=OE_ORDER_PUB.G_MISS_LINE_REC;
116     x_line_tbl(1)         :=OE_ORDER_PUB.G_MISS_LINE_REC;
117     x_line_tbl(1).header_id                := p_header_id;
118 
119     --  Defaulting of flex values is currently done by the form.
120     --  Set flex attributes to NULL in order to avoid defaulting them.
121 
122     x_line_tbl(1).attribute1                         := NULL;
123     x_line_tbl(1).attribute10                        := NULL;
124     x_line_tbl(1).attribute11                        := NULL;
125     x_line_tbl(1).attribute12                        := NULL;
126     x_line_tbl(1).attribute13                        := NULL;
127     x_line_tbl(1).attribute14                        := NULL;
128     x_line_tbl(1).attribute15                        := NULL;
129     x_line_tbl(1).attribute2                         := NULL;
130     x_line_tbl(1).attribute3                         := NULL;
131     x_line_tbl(1).attribute4                         := NULL;
132     x_line_tbl(1).attribute5                         := NULL;
133     x_line_tbl(1).attribute6                         := NULL;
134     x_line_tbl(1).attribute7                         := NULL;
135     x_line_tbl(1).attribute8                         := NULL;
136     x_line_tbl(1).attribute9                         := NULL;
137     x_line_tbl(1).context                            := NULL;
138     x_line_tbl(1).global_attribute1                  := NULL;
139     x_line_tbl(1).global_attribute10                 := NULL;
140     x_line_tbl(1).global_attribute11                 := NULL;
141     x_line_tbl(1).global_attribute12                 := NULL;
142     x_line_tbl(1).global_attribute13                 := NULL;
143     x_line_tbl(1).global_attribute14                 := NULL;
144     x_line_tbl(1).global_attribute15                 := NULL;
145     x_line_tbl(1).global_attribute16                 := NULL;
146     x_line_tbl(1).global_attribute17                 := NULL;
147     x_line_tbl(1).global_attribute18                 := NULL;
148     x_line_tbl(1).global_attribute19                 := NULL;
149     x_line_tbl(1).global_attribute2                  := NULL;
150     x_line_tbl(1).global_attribute20                 := NULL;
151     x_line_tbl(1).global_attribute3                  := NULL;
152     x_line_tbl(1).global_attribute4                  := NULL;
153     x_line_tbl(1).global_attribute5                  := NULL;
154     x_line_tbl(1).global_attribute6                  := NULL;
155     x_line_tbl(1).global_attribute7                  := NULL;
156     x_line_tbl(1).global_attribute8                  := NULL;
157     x_line_tbl(1).global_attribute9                  := NULL;
158     x_line_tbl(1).global_attribute_category          := NULL;
159     x_line_tbl(1).industry_attribute1                := NULL;
160     x_line_tbl(1).industry_attribute10               := NULL;
161     x_line_tbl(1).industry_attribute11               := NULL;
162     x_line_tbl(1).industry_attribute12               := NULL;
163     x_line_tbl(1).industry_attribute13               := NULL;
164     x_line_tbl(1).industry_attribute14               := NULL;
165     x_line_tbl(1).industry_attribute15               := NULL;
166     x_line_tbl(1).industry_attribute16               := NULL;
167     x_line_tbl(1).industry_attribute17               := NULL;
168     x_line_tbl(1).industry_attribute18               := NULL;
169     x_line_tbl(1).industry_attribute19               := NULL;
170     x_line_tbl(1).industry_attribute2                := NULL;
171     x_line_tbl(1).industry_attribute20               := NULL;
172     x_line_tbl(1).industry_attribute21               := NULL;
173     x_line_tbl(1).industry_attribute22               := NULL;
174     x_line_tbl(1).industry_attribute23               := NULL;
175     x_line_tbl(1).industry_attribute24               := NULL;
176     x_line_tbl(1).industry_attribute25               := NULL;
177     x_line_tbl(1).industry_attribute26               := NULL;
178     x_line_tbl(1).industry_attribute27               := NULL;
179     x_line_tbl(1).industry_attribute28               := NULL;
180     x_line_tbl(1).industry_attribute29               := NULL;
181     x_line_tbl(1).industry_attribute3                := NULL;
182     x_line_tbl(1).industry_attribute30               := NULL;
183     x_line_tbl(1).industry_attribute4                := NULL;
184     x_line_tbl(1).industry_attribute5                := NULL;
185     x_line_tbl(1).industry_attribute6                := NULL;
186     x_line_tbl(1).industry_attribute7                := NULL;
187     x_line_tbl(1).industry_attribute8                := NULL;
188     x_line_tbl(1).industry_attribute9                := NULL;
189     x_line_tbl(1).industry_context                   := NULL;
190     x_line_tbl(1).pricing_attribute1                 := NULL;
191     x_line_tbl(1).pricing_attribute10                := NULL;
192     x_line_tbl(1).pricing_attribute2                 := NULL;
193     x_line_tbl(1).pricing_attribute3                 := NULL;
194     x_line_tbl(1).pricing_attribute4                 := NULL;
195     x_line_tbl(1).pricing_attribute5                 := NULL;
196     x_line_tbl(1).pricing_attribute6                 := NULL;
197     x_line_tbl(1).pricing_attribute7                 := NULL;
198     x_line_tbl(1).pricing_attribute8                 := NULL;
199     x_line_tbl(1).pricing_attribute9                 := NULL;
200     x_line_tbl(1).pricing_context                    := NULL;
201     x_line_tbl(1).return_attribute1                  := NULL;
202     x_line_tbl(1).return_attribute10                 := NULL;
203     x_line_tbl(1).return_attribute11                 := NULL;
204     x_line_tbl(1).return_attribute12                 := NULL;
205     x_line_tbl(1).return_attribute13                 := NULL;
206     x_line_tbl(1).return_attribute14                 := NULL;
207     x_line_tbl(1).return_attribute15                 := NULL;
208     x_line_tbl(1).return_attribute2                  := NULL;
209     x_line_tbl(1).return_attribute3                  := NULL;
210     x_line_tbl(1).return_attribute4                  := NULL;
211     x_line_tbl(1).return_attribute5                  := NULL;
212     x_line_tbl(1).return_attribute6                  := NULL;
213     x_line_tbl(1).return_attribute7                  := NULL;
214     x_line_tbl(1).return_attribute8                  := NULL;
215     x_line_tbl(1).return_attribute9                  := NULL;
216     x_line_tbl(1).return_context                     := NULL;
217     x_line_tbl(1).tp_attribute1                         := NULL;
218     x_line_tbl(1).tp_attribute10                        := NULL;
219     x_line_tbl(1).tp_attribute11                        := NULL;
220     x_line_tbl(1).tp_attribute12                        := NULL;
221     x_line_tbl(1).tp_attribute13                        := NULL;
222     x_line_tbl(1).tp_attribute14                        := NULL;
223     x_line_tbl(1).tp_attribute15                        := NULL;
224     x_line_tbl(1).tp_attribute2                         := NULL;
225     x_line_tbl(1).tp_attribute3                         := NULL;
226     x_line_tbl(1).tp_attribute4                         := NULL;
227     x_line_tbl(1).tp_attribute5                         := NULL;
228     x_line_tbl(1).tp_attribute6                         := NULL;
229     x_line_tbl(1).tp_attribute7                         := NULL;
230     x_line_tbl(1).tp_attribute8                         := NULL;
231     x_line_tbl(1).tp_attribute9                         := NULL;
232     x_line_tbl(1).tp_context                            := NULL;
233 
234     --  Set Operation to Create
235 
236   l_error := 2;
237     x_line_tbl(1).operation := OE_GLOBALS.G_OPR_CREATE;
238 
239     --  Populate line table
240 
241 
242     IF l_debug_level  > 0 THEN
243         oe_debug_pub.add(  'LINE CONTROLLER - DEFAULT ATTRIBUTES - CALLING PROCESS' , 2 ) ;
244     END IF;
245 
246     --  Call Oe_Order_Pvt.Process_order
247 
248   l_error := 3;
249 
250     Oe_Order_Pvt.Lines
251     (   p_validation_level            => FND_API.G_VALID_LEVEL_NONE
252     ,   p_init_msg_list               => FND_API.G_TRUE
253     ,   p_control_rec                 => l_control_rec
254     ,   p_x_line_tbl                  => x_line_tbl
255     ,   p_x_old_line_tbl              => x_old_line_tbl
256     ,   x_return_status               => l_return_status
257     );
258 
259   l_error := 3;
260     IF l_debug_level  > 0 THEN
261         oe_debug_pub.add(  'LINE CONTROLLER - DEFAULT ATTRIBUTES - AFTER PROCESS' , 2 ) ;
262     END IF;
263 
264     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
265         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
266     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
267         RAISE FND_API.G_EXC_ERROR;
268     END IF;
269 
270 
271     --  Unload OUT
272 
273 --    l_x_line_rec := x_line_tbl(1);
274 
275 
276     --  Load display OUT parameters if any
277      x_line_val_tbl(1):=OE_ORDER_PUB.G_MISS_LINE_VAL_REC;
278      x_line_val_tbl(1):=OE_Line_Util.Get_Values
279     (   p_line_rec                    => x_line_tbl(1)
280     );
281     --  Write to cache.
282     --  Set db_flag to False before writing to cache
283 
284     IF l_debug_level  > 0 THEN
285         oe_debug_pub.add(  'LINE CONTROLLER - DEFAULT ATTRIBUTES - CALLING WRITE LINE' , 2 ) ;
286     END IF;
287 
288     x_line_tbl(1).db_flag := FND_API.G_FALSE;
289 
290     Write_line
291     (   p_line_rec                    => x_line_tbl(1)
292     );
293 
294     -- Re-set the UI flag to FALSE
295     OE_GLOBALS.G_UI_FLAG := FALSE;
296 
297     --  Set return status.
298 
299     x_return_status := FND_API.G_RET_STS_SUCCESS;
300 
301     --  Get message count and data
302 
303     oe_msg_pub.count_and_get
304     (   p_count                       => x_msg_count
305     ,   p_data                        => x_msg_data
306     );
307 
308     IF l_debug_level  > 0 THEN
309         oe_debug_pub.add(  'EXITING OE_OE_FORM_LINE.DEFAULT_ATTRIBUTES' , 1 ) ;
310     END IF;
311 
312 EXCEPTION
313 
314     WHEN FND_API.G_EXC_ERROR THEN
315 
316        OE_GLOBALS.G_UI_FLAG := FALSE;
317 
318         x_return_status := FND_API.G_RET_STS_ERROR;
319 
320         --  Get message count and data
321 
322         oe_msg_pub.count_and_get
323         (   p_count                       => x_msg_count
324         ,   p_data                        => x_msg_data
325         );
326 
327     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
328 
329        OE_GLOBALS.G_UI_FLAG := FALSE;
330 
331         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
332 
333         --  Get message count and data
334 
335         oe_msg_pub.count_and_get
336         (   p_count                       => x_msg_count
337         ,   p_data                        => x_msg_data
338         );
339 
340     WHEN OTHERS THEN
341 
342        OE_GLOBALS.G_UI_FLAG := FALSE;
343 
344         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
345 
346         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
347         THEN
348             oe_msg_pub.Add_Exc_Msg
349             (   G_PKG_NAME
350             ,   'Default_Attributes' || l_error
351             );
352         END IF;
353 
354         --  Get message count and data
355 
356         oe_msg_pub.count_and_get
357         (   p_count                       => x_msg_count
358         ,   p_data                        => x_msg_data
359         );
360 
361 END Default_Attributes;
362 
363 PROCEDURE Copy_Attribute_To_Rec
364 (   p_attr_id                       IN  NUMBER
365 ,   p_attr_value                    IN  VARCHAR2
366 ,   p_line_dff_rec                  IN  OE_OE_FORM_LINE.line_dff_rec_type
367 ,   p_date_format_mask              IN  VARCHAR2 DEFAULT 'DD-MON-YYYY HH24:MI:SS'
368 ,   x_line_tbl                      IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
369 ,   x_old_line_tbl                  IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type
370 )
371 IS
372 l_date_format_mask            VARCHAR2(30) := p_date_format_mask;
373 --
374 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
375 --
376 BEGIN
377     IF l_debug_level  > 0 THEN
378        oe_debug_pub.add(  'ATTRIBUTE VALUE : '|| P_ATTR_VALUE ) ;   --bug 5179564
379     END IF;
380 
381     IF p_attr_id = OE_Line_Util.G_ACCOUNTING_RULE THEN
382         x_line_tbl(1).accounting_rule_id := TO_NUMBER(p_attr_value);
383     ELSIF p_attr_id = OE_Line_Util.G_ACCOUNTING_RULE_DURATION THEN
384         x_line_tbl(1).accounting_rule_duration := TO_NUMBER(p_attr_value);
385     ELSIF p_attr_id = OE_Line_Util.G_ACTUAL_ARRIVAL_DATE THEN
386       --  x_line_tbl(1).actual_arrival_date := TO_DATE(p_attr_value, l_date_format_mask);
387        x_line_tbl(1).actual_arrival_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
388     ELSIF p_attr_id = OE_Line_Util.G_ACTUAL_SHIPMENT_DATE THEN
389       --  x_line_tbl(1).actual_shipment_date := TO_DATE(p_attr_value, l_date_format_mask);
390       x_line_tbl(1).actual_shipment_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
391     ELSIF p_attr_id = OE_Line_Util.G_AGREEMENT THEN
392         x_line_tbl(1).agreement_id := TO_NUMBER(p_attr_value);
393    ELSIF p_attr_id = OE_Line_Util.G_IB_OWNER THEN
394           x_line_tbl(1).ib_owner := p_attr_value;
395     ELSIF p_attr_id = OE_Line_Util.G_IB_INSTALLED_AT_LOCATION THEN
396           x_line_tbl(1).ib_installed_at_location := p_attr_value;
397     ELSIF p_attr_id = OE_Line_Util.G_IB_CURRENT_LOCATION THEN
398           x_line_tbl(1).ib_current_location := p_attr_value;
399     ELSIF p_attr_id = OE_Line_Util.G_END_CUSTOMER_SITE_USE THEN
400           x_line_tbl(1).end_customer_site_use_id := TO_NUMBER(p_attr_value);
401     ELSIF p_attr_id = OE_Line_Util.G_END_CUSTOMER_CONTACT THEN
402           x_line_tbl(1).end_customer_contact_id := TO_NUMBER(p_attr_value);
403     ELSIF p_attr_id = OE_Line_Util.G_END_CUSTOMER THEN
404           x_line_tbl(1).end_customer_id := TO_NUMBER(p_attr_value);
405     ELSIF p_attr_id = OE_Line_Util.G_ATO_LINE THEN
406         x_line_tbl(1).ato_line_id := TO_NUMBER(p_attr_value);
407     ELSIF p_attr_id = OE_Line_Util.G_AUTO_SELECTED_QUANTITY THEN
408         x_line_tbl(1).auto_selected_quantity := TO_NUMBER(p_attr_value);
409     ELSIF p_attr_id = OE_Line_Util.G_BLANKET_NUMBER THEN
410           x_line_tbl(1).blanket_number := TO_NUMBER(p_attr_value);
411     ELSIF p_attr_id = OE_Line_Util.G_BLANKET_LINE_NUMBER THEN
412           x_line_tbl(1).blanket_line_number := TO_NUMBER(p_attr_value);
413     ELSIF p_attr_id = OE_Line_Util.G_BLANKET_VERSION_NUMBER THEN
414           x_line_tbl(1).blanket_version_number := TO_NUMBER(p_attr_value);
415     ELSIF p_attr_id = OE_Line_Util.G_BOOKED THEN
416         x_line_tbl(1).booked_flag := p_attr_value;
417     ELSIF p_attr_id = OE_Line_Util.G_CANCELLED THEN
418         x_line_tbl(1).cancelled_flag := p_attr_value;
419     ELSIF p_attr_id = OE_Line_Util.G_CANCELLED_QUANTITY THEN
420         x_line_tbl(1).cancelled_quantity := TO_NUMBER(p_attr_value);
421     ELSIF p_attr_id = OE_Line_Util.G_COMPONENT THEN
422         x_line_tbl(1).component_code := p_attr_value;
423     ELSIF p_attr_id = OE_Line_Util.G_COMPONENT_NUMBER THEN
424         x_line_tbl(1).component_number := p_attr_value;
425     ELSIF p_attr_id = OE_Line_Util.G_COMPONENT_SEQUENCE THEN
426         x_line_tbl(1).component_sequence_id := TO_NUMBER(p_attr_value);
427     ELSIF p_attr_id = OE_Line_Util.G_CONFIG_DISPLAY_SEQUENCE THEN
428         x_line_tbl(1).config_display_sequence := TO_NUMBER(p_attr_value);
429     ELSIF p_attr_id = OE_Line_Util.G_CONFIGURATION THEN
430         x_line_tbl(1).configuration_id := TO_NUMBER(p_attr_value);
431     ELSIF p_attr_id = OE_Line_Util.G_CONFIG_HEADER THEN
432         x_line_tbl(1).config_header_id := TO_NUMBER(p_attr_value);
433     ELSIF p_attr_id = OE_Line_Util.G_CONFIG_REV_NBR THEN
434         x_line_tbl(1).config_rev_nbr := TO_NUMBER(p_attr_value);
435     ELSIF p_attr_id = OE_Line_Util.G_CREDIT_INVOICE_LINE THEN
436         x_line_tbl(1).credit_invoice_line_id := TO_NUMBER(p_attr_value);
437     ELSIF p_attr_id = OE_Line_Util.G_CUSTOMER_DOCK THEN
438         x_line_tbl(1).customer_dock_code := p_attr_value;
439     ELSIF p_attr_id = OE_Line_Util.G_CUSTOMER_JOB THEN
440         x_line_tbl(1).customer_job := p_attr_value;
441     ELSIF p_attr_id = OE_Line_Util.G_CUSTOMER_PRODUCTION_LINE THEN
442         x_line_tbl(1).customer_production_line := p_attr_value;
443     ELSIF p_attr_id = OE_Line_Util.G_CUSTOMER_TRX_LINE THEN
444         x_line_tbl(1).customer_trx_line_id := TO_NUMBER(p_attr_value);
445     ELSIF p_attr_id = OE_Line_Util.G_CUST_MODEL_SERIAL_NUMBER THEN
446         x_line_tbl(1).cust_model_serial_number := p_attr_value;
447     ELSIF p_attr_id = OE_Line_Util.G_CUST_PO_NUMBER THEN
448         x_line_tbl(1).cust_po_number := p_attr_value;
449     ELSIF p_attr_id = OE_Line_Util.G_DELIVERY_LEAD_TIME THEN
450         x_line_tbl(1).delivery_lead_time := TO_NUMBER(p_attr_value);
451     ELSIF p_attr_id = OE_Line_Util.G_DELIVER_TO_CONTACT THEN
452         x_line_tbl(1).deliver_to_contact_id := TO_NUMBER(p_attr_value);
453     ELSIF p_attr_id = OE_Line_Util.G_DELIVER_TO_ORG THEN
454         x_line_tbl(1).deliver_to_org_id := TO_NUMBER(p_attr_value);
455     ELSIF p_attr_id = OE_Line_Util.G_DEMAND_BUCKET_TYPE THEN
456         x_line_tbl(1).demand_bucket_type_code := p_attr_value;
457     ELSIF p_attr_id = OE_Line_Util.G_DEMAND_CLASS THEN
458         x_line_tbl(1).demand_class_code := p_attr_value;
459     ELSIF p_attr_id = OE_Line_Util.G_DEP_PLAN_REQUIRED THEN
460         x_line_tbl(1).dep_plan_required_flag := p_attr_value;
461     ELSIF p_attr_id = OE_Line_Util.G_EARLIEST_ACCEPTABLE_DATE THEN
462        -- x_line_tbl(1).earliest_acceptable_date := TO_DATE(p_attr_value, l_date_format_mask);
463           x_line_tbl(1).earliest_acceptable_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
464     ELSIF p_attr_id = OE_Line_Util.G_EXPLOSION_DATE THEN
465        -- x_line_tbl(1).explosion_date := TO_DATE(p_attr_value, l_date_format_mask);
466        x_line_tbl(1).explosion_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
467     ELSIF p_attr_id = OE_Line_Util.G_FOB_POINT THEN
468         x_line_tbl(1).fob_point_code := p_attr_value;
469     ELSIF p_attr_id = OE_Line_Util.G_FREIGHT_CARRIER THEN
470         x_line_tbl(1).freight_carrier_code := p_attr_value;
471     ELSIF p_attr_id = OE_Line_Util.G_FREIGHT_TERMS THEN
472         x_line_tbl(1).freight_terms_code := p_attr_value;
473     ELSIF p_attr_id = OE_Line_Util.G_FULFILLED_QUANTITY THEN
474         x_line_tbl(1).fulfilled_quantity := TO_NUMBER(p_attr_value);
475     ELSIF p_attr_id = OE_Line_Util.G_HEADER THEN
476         x_line_tbl(1).header_id := TO_NUMBER(p_attr_value);
477     ELSIF p_attr_id = OE_Line_Util.G_INTERMED_SHIP_TO_CONTACT THEN
478         x_line_tbl(1).intermed_ship_to_contact_id := TO_NUMBER(p_attr_value);
479     ELSIF p_attr_id = OE_Line_Util.G_INTERMED_SHIP_TO_ORG THEN
480         x_line_tbl(1).intermed_ship_to_org_id := TO_NUMBER(p_attr_value);
481     ELSIF p_attr_id = OE_Line_Util.G_INVENTORY_ITEM THEN
482         x_line_tbl(1).inventory_item_id := TO_NUMBER(p_attr_value);
483     ELSIF p_attr_id = OE_Line_Util.G_INVOICE_INTERFACE_STATUS THEN
484         x_line_tbl(1).invoice_interface_status_code := p_attr_value;
485     ELSIF p_attr_id = OE_Line_Util.G_INVOICE_TO_CONTACT THEN
486         x_line_tbl(1).invoice_to_contact_id := TO_NUMBER(p_attr_value);
487     ELSIF p_attr_id = OE_Line_Util.G_INVOICE_TO_ORG THEN
488         x_line_tbl(1).invoice_to_org_id := TO_NUMBER(p_attr_value);
489     ELSIF p_attr_id = OE_Line_Util.G_INVOICED_QUANTITY THEN
490         x_line_tbl(1).invoiced_quantity := TO_NUMBER(p_attr_value);
491     ELSIF p_attr_id = OE_Line_Util.G_INVOICING_RULE THEN
492         x_line_tbl(1).invoicing_rule_id := TO_NUMBER(p_attr_value);
493     ELSIF p_attr_id = OE_Line_Util.G_ORDERED_ITEM_ID THEN
494         x_line_tbl(1).ordered_item_id := TO_NUMBER(p_attr_value);
495     ELSIF p_attr_id = OE_Line_Util.G_ITEM_IDENTIFIER_TYPE THEN
496         x_line_tbl(1).item_identifier_type := p_attr_value;
497     ELSIF p_attr_id = OE_Line_Util.G_ORDERED_ITEM THEN
498         x_line_tbl(1).ordered_item := p_attr_value;
499     ELSIF p_attr_id = OE_Line_Util.G_ITEM_REVISION THEN
500         x_line_tbl(1).item_revision := p_attr_value;
501     ELSIF p_attr_id = OE_Line_Util.G_ITEM_TYPE THEN
502         x_line_tbl(1).item_type_code := p_attr_value;
503     ELSIF p_attr_id = OE_Line_Util.G_LATEST_ACCEPTABLE_DATE THEN
504        -- x_line_tbl(1).latest_acceptable_date := TO_DATE(p_attr_value, l_date_format_mask);
505        x_line_tbl(1).latest_acceptable_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
506     ELSIF p_attr_id = OE_Line_Util.G_LATE_DEMAND_PENALTY_FACTOR THEN
507         x_line_tbl(1).late_demand_penalty_factor := TO_NUMBER(p_attr_value);
508     ELSIF p_attr_id = OE_Line_Util.G_LINE_CATEGORY THEN
509         x_line_tbl(1).line_category_code := p_attr_value;
510         x_line_tbl(1).line_type_id := FND_API.G_MISS_NUM;
511     ELSIF p_attr_id = OE_Line_Util.G_LINE THEN
512         x_line_tbl(1).line_id := TO_NUMBER(p_attr_value);
513     ELSIF p_attr_id = OE_Line_Util.G_LINE_NUMBER THEN
514         x_line_tbl(1).line_number := TO_NUMBER(p_attr_value);
515     ELSIF p_attr_id = OE_Line_Util.G_LINE_TYPE THEN
516         x_line_tbl(1).line_type_id := TO_NUMBER(p_attr_value);
517     ELSIF p_attr_id = OE_Line_Util.G_LINK_TO_LINE THEN
518         x_line_tbl(1).link_to_line_id := TO_NUMBER(p_attr_value);
519     ELSIF p_attr_id = OE_Line_Util.G_MODEL_GROUP_NUMBER THEN
520         x_line_tbl(1).model_group_number := TO_NUMBER(p_attr_value);
521     ELSIF p_attr_id = OE_Line_Util.G_OPEN THEN
522         x_line_tbl(1).open_flag := p_attr_value;
523     ELSIF p_attr_id = OE_Line_Util.G_OPTION_FLAG THEN
524         x_line_tbl(1).option_flag := p_attr_value;
525     ELSIF p_attr_id = OE_Line_Util.G_OPTION_NUMBER THEN
526         x_line_tbl(1).option_number := TO_NUMBER(p_attr_value);
527     ELSIF p_attr_id = OE_Line_Util.G_ORDERED_QUANTITY THEN
528         x_line_tbl(1).ordered_quantity := FND_NUMBER.CANONICAL_TO_NUMBER(p_attr_value); --bug 5179564
529     ELSIF p_attr_id = OE_Line_Util.G_ORDER_QUANTITY_UOM THEN
530         x_line_tbl(1).order_quantity_uom := p_attr_value;
531     ELSIF p_attr_id = OE_Line_Util.G_ORDERED_QUANTITY2 THEN       --OPM
532         x_line_tbl(1).ordered_quantity2 := FND_NUMBER.CANONICAL_TO_NUMBER(p_attr_value); --bug 5179564
533     ELSIF p_attr_id = OE_Line_Util.G_ORDERED_QUANTITY_UOM2 THEN   --OPM
534         x_line_tbl(1).ordered_quantity_uom2 := p_attr_value;
535 
536     ELSIF p_attr_id = OE_Line_Util.G_ORG THEN
537         x_line_tbl(1).org_id := TO_NUMBER(p_attr_value);
538     ELSIF p_attr_id = OE_Line_Util.G_ORIG_SYS_DOCUMENT_REF THEN
539         x_line_tbl(1).orig_sys_document_ref := p_attr_value;
540     ELSIF p_attr_id = OE_Line_Util.G_ORIG_SYS_LINE_REF THEN
541         x_line_tbl(1).orig_sys_line_ref := p_attr_value;
542     ELSIF p_attr_id = OE_Line_Util.G_ORIG_SYS_SHIPMENT_REF THEN
543         x_line_tbl(1).orig_sys_shipment_ref := p_attr_value;
544     ELSIF p_attr_id = OE_Line_Util.G_ORIGINAL_INVENTORY_ITEM THEN
545         x_line_tbl(1).original_inventory_item_id:= to_number(p_attr_value);
546     ELSIF p_attr_id = OE_Line_Util.G_ORIGINAL_ORDERED_ITEM THEN
547         x_line_tbl(1).original_ordered_item := p_attr_value;
548     ELSIF p_attr_id = OE_Line_Util.G_ORIGINAL_ORDERED_ITEM_ID THEN
549         x_line_tbl(1).original_ordered_item_id := to_number(p_attr_value);
550     ELSIF p_attr_id = OE_Line_Util.G_ORIGINAL_ITEM_IDEN_TYPE THEN
551         x_line_tbl(1).original_item_identifier_type := p_attr_value;
552     ELSIF p_attr_id = OE_Line_Util.G_ITEM_RELATIONSHIP_TYPE THEN
553         x_line_tbl(1).item_relationship_type := to_number(p_attr_value);
554     ELSIF p_attr_id = OE_Line_Util.G_PAYMENT_TERM THEN
555         x_line_tbl(1).payment_term_id := TO_NUMBER(p_attr_value);
556     ELSIF p_attr_id = OE_Line_Util.G_PLANNING_PRIORITY THEN
557         x_line_tbl(1).planning_priority := TO_NUMBER(p_attr_value);
558     ELSIF p_attr_id = OE_Line_Util.G_PREFERRED_GRADE THEN         --OPM
559         x_line_tbl(1).preferred_grade := p_attr_value;
560 
561     ELSIF p_attr_id = OE_Line_Util.G_PRICE_LIST THEN
562         x_line_tbl(1).price_list_id := TO_NUMBER(p_attr_value);
563     ELSIF p_attr_id = OE_Line_Util.G_PRICING_DATE THEN
564        -- x_line_tbl(1).pricing_date := TO_DATE(p_attr_value, l_date_format_mask);
565        x_line_tbl(1).pricing_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
566     ELSIF p_attr_id = OE_Line_Util.G_PRICING_QUANTITY THEN
567         x_line_tbl(1).pricing_quantity := TO_NUMBER(p_attr_value);
568     ELSIF p_attr_id = OE_Line_Util.G_PRICING_QUANTITY_UOM THEN
569         x_line_tbl(1).pricing_quantity_uom := p_attr_value;
570     ELSIF p_attr_id = OE_Line_Util.G_PROJECT THEN
571         x_line_tbl(1).project_id := TO_NUMBER(p_attr_value);
572     ELSIF p_attr_id = OE_Line_Util.G_PROMISE_DATE THEN
573       --  x_line_tbl(1).promise_date := TO_DATE(p_attr_value, l_date_format_mask);
574        x_line_tbl(1).promise_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
575     ELSIF p_attr_id = OE_Line_Util.G_REFERENCE_CUSTOMER_TRX_LINE THEN
576         x_line_tbl(1).reference_customer_trx_line_id := TO_NUMBER(p_attr_value);
577     ELSIF p_attr_id = OE_Line_Util.G_REFERENCE_HEADER THEN
578         x_line_tbl(1).reference_header_id := TO_NUMBER(p_attr_value);
579     ELSIF p_attr_id = OE_Line_Util.G_REFERENCE_LINE THEN
580         x_line_tbl(1).reference_line_id := TO_NUMBER(p_attr_value);
581     ELSIF p_attr_id = OE_Line_Util.G_REFERENCE_TYPE THEN
582         NULL;
583     ELSIF p_attr_id = OE_Line_Util.G_REQUEST_DATE THEN
584        -- x_line_tbl(1).request_date := TO_DATE(p_attr_value, l_date_format_mask);
585        x_line_tbl(1).request_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
586     ELSIF p_attr_id = OE_Line_Util.G_RESERVED_QUANTITY THEN
587         x_line_tbl(1).reserved_quantity := p_attr_value;
588     ELSIF p_attr_id = OE_Line_Util.G_RLA_SCHEDULE_TYPE THEN
589         x_line_tbl(1).rla_schedule_type_code := p_attr_value;
590     ELSIF p_attr_id = OE_Line_Util.G_SCHEDULE_ARRIVAL_DATE THEN
591        -- x_line_tbl(1).schedule_arrival_date := TO_DATE(p_attr_value, l_date_format_mask);
592        x_line_tbl(1).schedule_arrival_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
593     ELSIF p_attr_id = OE_Line_Util.G_SCHEDULE_SHIP_DATE THEN
594        /* x_line_tbl(1).schedule_ship_date :=
595                   TO_DATE(p_attr_value, l_date_format_mask);*/
596        x_line_tbl(1).schedule_ship_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
597     ELSIF p_attr_id = OE_Line_Util.G_EARLIEST_SHIP_DATE THEN
598       /*  x_line_tbl(1).earliest_ship_date :=
599                   TO_DATE(p_attr_value, l_date_format_mask);*/
600        x_line_tbl(1).earliest_ship_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
601     ELSIF p_attr_id = OE_Line_Util.G_FIRM_DEMAND THEN
602         x_line_tbl(1).firm_demand_flag := p_attr_value;
603     ELSIF p_attr_id = OE_Line_Util.G_SCHEDULE_ACTION THEN
604         x_line_tbl(1).schedule_action_code := p_attr_value;
605     ELSIF p_attr_id = OE_Line_Util.G_OVERRIDE_ATP_DATE THEN
606        x_line_tbl(1).override_atp_date_code := p_attr_value;
607     ELSIF p_attr_id = OE_Line_Util.G_SCHEDULE_STATUS THEN
608         x_line_tbl(1).schedule_status_code := p_attr_value;
609     ELSIF p_attr_id = OE_Line_Util.G_SHIPMENT_NUMBER THEN
610         x_line_tbl(1).shipment_number := TO_NUMBER(p_attr_value);
611     ELSIF p_attr_id = OE_Line_Util.G_SHIPMENT_PRIORITY THEN
612         x_line_tbl(1).shipment_priority_code := p_attr_value;
613     ELSIF p_attr_id = OE_Line_Util.G_SHIPPED_QUANTITY THEN
614         x_line_tbl(1).shipped_quantity := TO_NUMBER(p_attr_value);
615     ELSIF p_attr_id = OE_Line_Util.G_SHIPPING_METHOD THEN
616         x_line_tbl(1).shipping_method_code := p_attr_value;
617     ELSIF p_attr_id = OE_Line_Util.G_SHIPPING_QUANTITY THEN
618         x_line_tbl(1).shipping_quantity := TO_NUMBER(p_attr_value);
619     ELSIF p_attr_id = OE_Line_Util.G_SHIPPING_QUANTITY_UOM THEN
620         x_line_tbl(1).shipping_quantity_uom := p_attr_value;
621     ELSIF p_attr_id = OE_Line_Util.G_SHIP_FROM_ORG THEN
622         x_line_tbl(1).ship_from_org_id := TO_NUMBER(p_attr_value);
623     ELSIF p_attr_id = OE_Line_Util.G_SUBINVENTORY THEN
624         x_line_tbl(1).subinventory := p_attr_value;
625     ELSIF p_attr_id = OE_Line_Util.G_SHIP_TOLERANCE_ABOVE THEN
626         x_line_tbl(1).ship_tolerance_above := TO_NUMBER(p_attr_value);
627     ELSIF p_attr_id = OE_Line_Util.G_SHIP_TOLERANCE_BELOW THEN
628         x_line_tbl(1).ship_tolerance_below := TO_NUMBER(p_attr_value);
629     ELSIF p_attr_id = OE_Line_Util.G_SHIPPING_INTERFACED THEN
630         x_line_tbl(1).shipping_interfaced_flag := p_attr_value;
631     ELSIF p_attr_id = OE_Line_Util.G_SHIP_TO_CONTACT THEN
632         x_line_tbl(1).ship_to_contact_id := TO_NUMBER(p_attr_value);
633     IF l_debug_level  > 0 THEN
634         oe_debug_pub.add(  'SHIP TO CONTACT1'|| X_LINE_TBL ( 1 ) .SHIP_TO_CONTACT_ID , 1 ) ;
635     END IF;
636     ELSIF p_attr_id = OE_Line_Util.G_SHIP_TO_ORG THEN
637         x_line_tbl(1).ship_to_org_id := TO_NUMBER(p_attr_value);
638     ELSIF p_attr_id = OE_Line_Util.G_SHIP_MODEL_COMPLETE_FLAG THEN
639         x_line_tbl(1).ship_model_complete_flag := p_attr_value;
640     ELSIF p_attr_id = OE_Line_Util.G_SOLD_TO_ORG THEN
641         x_line_tbl(1).sold_to_org_id := TO_NUMBER(p_attr_value);
642     ELSIF p_attr_id = OE_Line_Util.G_SORT_ORDER THEN
643         x_line_tbl(1).sort_order := p_attr_value;
644     ELSIF p_attr_id = OE_Line_Util.G_SOURCE_DOCUMENT THEN
645         x_line_tbl(1).source_document_id := TO_NUMBER(p_attr_value);
646     ELSIF p_attr_id = OE_Line_Util.G_SOURCE_DOCUMENT_LINE THEN
647         x_line_tbl(1).source_document_line_id := TO_NUMBER(p_attr_value);
648     ELSIF p_attr_id = OE_Line_Util.G_SOURCE_DOCUMENT_TYPE THEN
649         x_line_tbl(1).source_document_type_id := TO_NUMBER(p_attr_value);
650     ELSIF p_attr_id = OE_Line_Util.G_SOURCE_TYPE THEN
651         x_line_tbl(1).source_type_code := p_attr_value;
652     ELSIF p_attr_id = OE_Line_Util.G_TASK THEN
653         x_line_tbl(1).task_id := TO_NUMBER(p_attr_value);
654     ELSIF p_attr_id = OE_Line_Util.G_TAX THEN
655         x_line_tbl(1).tax_code := p_attr_value;
656     ELSIF p_attr_id = OE_Line_Util.G_TAX_DATE THEN
657        -- x_line_tbl(1).tax_date := TO_DATE(p_attr_value, l_date_format_mask);
658         x_line_tbl(1).tax_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
659     ELSIF p_attr_id = OE_Line_Util.G_TAX_EXEMPT THEN
660         x_line_tbl(1).tax_exempt_flag := p_attr_value;
661     ELSIF p_attr_id = OE_Line_Util.G_TAX_EXEMPT_NUMBER THEN
662         x_line_tbl(1).tax_exempt_number := p_attr_value;
663     ELSIF p_attr_id = OE_Line_Util.G_TAX_EXEMPT_REASON THEN
664         x_line_tbl(1).tax_exempt_reason_code := p_attr_value;
665     ELSIF p_attr_id = OE_Line_Util.G_TAX_POINT THEN
666         x_line_tbl(1).tax_point_code := p_attr_value;
667     ELSIF p_attr_id = OE_Line_Util.G_TAX_RATE THEN
668         x_line_tbl(1).tax_rate := TO_NUMBER(p_attr_value);
669     ELSIF p_attr_id = OE_Line_Util.G_TAX_VALUE THEN
670         x_line_tbl(1).tax_value := TO_NUMBER(p_attr_value);
671     ELSIF p_attr_id = OE_Line_Util.G_TOP_MODEL_LINE THEN
672         x_line_tbl(1).top_model_line_id := TO_NUMBER(p_attr_value);
673     ELSIF p_attr_id = OE_Line_Util.G_UNIT_LIST_PRICE THEN
674         x_line_tbl(1).unit_list_price := TO_NUMBER(p_attr_value);
675     ELSIF p_attr_id = OE_Line_Util.G_UNIT_LIST_PRICE_PER_PQTY THEN
676         x_line_tbl(1).unit_list_price_per_pqty := TO_NUMBER(p_attr_value);
677     ELSIF p_attr_id = OE_Line_Util.G_UNIT_SELLING_PRICE THEN
678         x_line_tbl(1).unit_selling_price := FND_NUMBER.CANONICAL_TO_NUMBER(p_attr_value); -- bug 5179564
679     ELSIF p_attr_id = OE_Line_Util.G_UNIT_SELLING_PRICE_PER_PQTY THEN
680         x_line_tbl(1).unit_selling_price_per_pqty := FND_NUMBER.CANONICAL_TO_NUMBER(p_attr_value); -- bug 5179564
681     ELSIF p_attr_id = OE_Line_Util.G_VISIBLE_DEMAND THEN
682         x_line_tbl(1).visible_demand_flag := p_attr_value;
683     ELSIF p_attr_id = OE_Line_Util.G_SPLIT_FROM_LINE THEN
684         x_line_tbl(1).split_from_line_id := TO_NUMBER(p_attr_value);
685     ELSIF p_attr_id = OE_Line_Util.G_CUST_PRODUCTION_SEQ_NUM THEN
686         x_line_tbl(1).cust_production_seq_num := p_attr_value;
687     ELSIF p_attr_id = OE_Line_Util.G_AUTHORIZED_TO_SHIP THEN
688         x_line_tbl(1).authorized_to_ship_flag := p_attr_value;
689     ELSIF p_attr_id = OE_Line_Util.G_VEH_CUS_ITEM_CUM_KEY THEN
690         x_line_tbl(1).veh_cus_item_cum_key_id := TO_NUMBER(p_attr_value);
691     ELSIF p_attr_id = OE_Line_Util.G_SALESREP THEN
692         x_line_tbl(1).salesrep_id := TO_NUMBER(p_attr_value);
693     ELSIF p_attr_id = OE_Line_Util.G_RETURN_REASON THEN
694         x_line_tbl(1).return_reason_code := p_attr_value;
695     ELSIF p_attr_id = OE_Line_Util.G_ARRIVAL_SET THEN
696         x_line_tbl(1).arrival_set_id := TO_NUMBER(p_attr_value);
697     ELSIF p_attr_id = OE_Line_Util.G_ARRIVAL_SET_NAME THEN
698     IF l_debug_level  > 0 THEN
699         oe_debug_pub.add(  'RAJ CONTROLLER - ATTRIBUTE CHANGE'|| P_ATTR_VALUE ) ;
700     END IF;
701     IF p_attr_value IS NULL THEN
702         x_line_tbl(1).arrival_set_id := NULL;
703         x_line_tbl(1).arrival_set := p_attr_value;
704        x_old_line_tbl(1).arrival_set := null;
705     ELSE
706         x_line_tbl(1).arrival_set := p_attr_value;
707         x_line_tbl(1).arrival_set_id := NULL;
708     END IF;
709     ELSIF p_attr_id = OE_Line_Util.G_SHIP_SET THEN
710         x_line_tbl(1).ship_set_id := TO_NUMBER(p_attr_value);
711     ELSIF p_attr_id = OE_Line_Util.G_SHIP_SET_NAME THEN
712     IF p_attr_value IS NULL THEN
713         x_line_tbl(1).ship_set_id := NULL;
714         x_line_tbl(1).ship_set := p_attr_value;
715        x_old_line_tbl(1).ship_set := null;
716     ELSE
717         x_line_tbl(1).ship_set := p_attr_value;
718         x_line_tbl(1).ship_set_id := NULL;
719     END IF;
720     ELSIF p_attr_id = OE_Line_Util.G_FULFILLMENT_SET THEN
721         x_line_tbl(1).fulfillment_set := TO_NUMBER(p_attr_value);
722     ELSIF p_attr_id = OE_Line_Util.G_FULFILLMENT_SET_NAME THEN
723     IF p_attr_value IS NULL THEN
724         x_line_tbl(1).fulfillment_set_id := NULL;
725     ELSE
726         x_line_tbl(1).fulfillment_set := p_attr_value;
727         x_line_tbl(1).fulfillment_set_id := NULL;
728     END IF;
729     ELSIF p_attr_id = OE_Line_Util.G_OVER_SHIP_REASON THEN
730         x_line_tbl(1).over_ship_reason_code := p_attr_value;
731     ELSIF p_attr_id = OE_Line_Util.G_OVER_SHIP_RESOLVED THEN
732         x_line_tbl(1).over_ship_resolved_flag := p_attr_value;
733     ELSIF p_attr_id =    OE_Line_Util.G_FIRST_ACK THEN
734         x_line_tbl(1).first_ack_code := p_attr_value;
735     ELSIF p_attr_id =    OE_Line_Util.G_FIRST_ACK_DATE THEN
736        -- x_line_tbl(1).first_ack_date := TO_DATE(p_attr_value, l_date_format_mask);
737        x_line_tbl(1).first_ack_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
738     ELSIF p_attr_id =    OE_Line_Util.G_LAST_ACK THEN
739         x_line_tbl(1).last_ack_code := p_attr_value;
740     ELSIF p_attr_id =    OE_Line_Util.G_LAST_ACK_DATE THEN
741       --  x_line_tbl(1).last_ack_date := TO_DATE(p_attr_value, l_date_format_mask);
742       x_line_tbl(1).last_ack_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
743     ELSIF p_attr_id =    OE_Line_Util.G_END_ITEM_UNIT_NUMBER THEN
744         x_line_tbl(1).end_item_unit_number := p_attr_value;
745     ELSIF p_attr_id =    OE_Line_Util.G_SHIPPING_INSTRUCTIONS THEN
746         x_line_tbl(1).shipping_instructions := p_attr_value;
747     ELSIF p_attr_id =    OE_Line_Util.G_PACKING_INSTRUCTIONS THEN
748         x_line_tbl(1).packing_instructions := p_attr_value;
749     ELSIF p_attr_id =    OE_Line_Util.G_SERVICE_TXN_REASON THEN
750         x_line_tbl(1).service_txn_reason_code := p_attr_value;
751     ELSIF p_attr_id =    OE_Line_Util.G_SERVICE_TXN_COMMENTS THEN
752         x_line_tbl(1).service_txn_comments := p_attr_value;
753     ELSIF p_attr_id =    OE_Line_Util.G_SERVICE_DURATION THEN
754         x_line_tbl(1).service_duration := TO_NUMBER(p_attr_value);
755     ELSIF p_attr_id =    OE_Line_Util.G_SERVICE_PERIOD THEN
756         x_line_tbl(1).service_period := p_attr_value;
757     ELSIF p_attr_id =    OE_Line_Util.G_SERVICE_START_DATE THEN
758        -- x_line_tbl(1).service_start_date := TO_DATE(p_attr_value, l_date_format_mask);
759        x_line_tbl(1).service_start_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
760     ELSIF p_attr_id =    OE_Line_Util.G_SERVICE_END_DATE THEN
761        -- x_line_tbl(1).service_end_date := TO_DATE(p_attr_value, l_date_format_mask);
762        x_line_tbl(1).service_end_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
763     ELSIF p_attr_id =    OE_Line_Util.G_SERVICE_COTERMINATE_FLAG THEN
764         x_line_tbl(1).service_coterminate_flag := p_attr_value;
765     ELSIF p_attr_id =    OE_Line_Util.G_UNIT_SELLING_PERCENT THEN
766         x_line_tbl(1).unit_selling_percent := TO_NUMBER(p_attr_value);
767     ELSIF p_attr_id =    OE_Line_Util.G_UNIT_LIST_PERCENT THEN
768         x_line_tbl(1).unit_list_percent := TO_NUMBER(p_attr_value);
769     ELSIF p_attr_id =    OE_Line_Util.G_UNIT_PERCENT_BASE_PRICE THEN
770         x_line_tbl(1).unit_percent_base_price := TO_NUMBER(p_attr_value);
771     ELSIF p_attr_id =    OE_Line_Util.G_SERVICE_NUMBER THEN
772         x_line_tbl(1).service_number := TO_NUMBER(p_attr_value);
773     ELSIF p_attr_id = OE_Line_Util.G_Service_Reference_Type_Code THEN
774         x_line_tbl(1).service_reference_type_code := p_attr_value;
775     ELSIF p_attr_id = OE_Line_Util.G_Service_Reference_Line_Id THEN
776         x_line_tbl(1).service_reference_line_id := TO_NUMBER(p_attr_value);
777     ELSIF p_attr_id = OE_Line_Util.G_Service_Reference_System_Id THEN
778         x_line_tbl(1).service_reference_system_id := TO_NUMBER(p_attr_value);
779 	-- sol_ord_er #16014165
780 	ELSIF p_attr_id =	OE_Line_Util.G_SERVICE_BILL_PROFILE_ID THEN
781 		x_line_tbl(1).service_bill_profile_id := TO_NUMBER(p_attr_value);
782 	ELSIF p_attr_id =	OE_Line_Util.G_SERVICE_COV_TEMPLATE_ID THEN
783 		x_line_tbl(1).service_cov_template_id := TO_NUMBER(p_attr_value);
784 	ELSIF p_attr_id =	OE_Line_Util.G_SERVICE_SUBS_TEMPLATE_ID THEN
785 		x_line_tbl(1).service_subs_template_id := TO_NUMBER(p_attr_value);
786 	ELSIF p_attr_id =	OE_Line_Util.G_SERVICE_BILL_OPTION_CODE THEN
787 		x_line_tbl(1).service_bill_option_code := p_attr_value;
788 	ELSIF p_attr_id =	OE_Line_Util.G_SUBSCRIPTION_ENABLE_FLAG THEN
789 		x_line_tbl(1).subscription_enable_flag := p_attr_value;
790 	-- sol_ord_er #16014165	end
791     ELSIF p_attr_id = OE_Line_Util.G_CHANGE_REASON THEN
792         x_line_tbl(1).change_reason := p_attr_value;
793     ELSIF p_attr_id = OE_Line_Util.G_CHANGE_COMMENTS THEN
794         x_line_tbl(1).change_comments := p_attr_value;
795     ELSIF p_attr_id = OE_Line_Util.G_CALCULATE_PRICE_FLAG THEN
796         x_line_tbl(1).calculate_price_flag := p_attr_value;
797     ELSIF p_attr_id = OE_Line_Util.G_CUSTOMER_LINE_NUMBER THEN
798         x_line_tbl(1).customer_line_number := p_attr_value;
799     ELSIF p_attr_id = OE_Line_Util.G_CUSTOMER_SHIPMENT_NUMBER THEN
800         x_line_tbl(1).customer_shipment_number := p_attr_value;
801     ELSIF p_attr_id = OE_Line_Util.G_user_ITEM_DESCRIPTION THEN
802         x_line_tbl(1).user_item_description := p_attr_value;
803     --recurring charges
804     ELSIF p_attr_id = OE_LINE_UTIL.G_CHARGE_PERIODICITY THEN
805         x_line_tbl(1).charge_periodicity_code := p_attr_value;
806     --Customer Acceptance
807     ELSIF p_attr_id = OE_Line_Util.G_CONTINGENCY THEN
808         x_line_tbl(1).contingency_id  := TO_NUMBER(p_attr_value);
809     ELSIF p_attr_id = OE_Line_Util.G_REVREC_EVENT THEN
810         x_line_tbl(1).revrec_event_code := p_attr_value;
811     ELSIF p_attr_id = OE_Line_Util.G_REVREC_EXPIRATION_DAYS THEN
812         x_line_tbl(1).revrec_expiration_days := TO_NUMBER(p_attr_value);
813     ELSIF p_attr_id = OE_Line_Util.G_REVREC_COMMENTS THEN
814         x_line_tbl(1).revrec_comments := p_attr_value;
815     ELSIF p_attr_id = OE_Line_Util.G_REVREC_REFERENCE_DOCUMENT THEN
816         x_line_tbl(1).revrec_reference_document := p_attr_value;
817     ELSIF p_attr_id = OE_Line_Util.G_REVREC_SIGNATURE THEN
818         x_line_tbl(1).revrec_signature := p_attr_value;
819     ELSIF p_attr_id = OE_Line_Util.G_ATTRIBUTE1
820     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE10
821     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE11
822     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE12
823     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE13
824     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE14
825     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE15
826     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE16   --For bug 2184255
827     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE17
828     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE18
829     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE19
830     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE2
831     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE20
832     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE3
833     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE4
834     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE5
835     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE6
836     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE7
837     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE8
838     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE9
839     OR     p_attr_id = OE_Line_Util.G_CONTEXT
840     THEN
841 
842         x_line_tbl(1).attribute1          := p_line_dff_rec.attribute1;
843         x_line_tbl(1).attribute10         := p_line_dff_rec.attribute10;
844         x_line_tbl(1).attribute11         := p_line_dff_rec.attribute11;
845         x_line_tbl(1).attribute12         := p_line_dff_rec.attribute12;
846         x_line_tbl(1).attribute13         := p_line_dff_rec.attribute13;
847         x_line_tbl(1).attribute14         := p_line_dff_rec.attribute14;
848         x_line_tbl(1).attribute15         := p_line_dff_rec.attribute15;
849         x_line_tbl(1).attribute16         := p_line_dff_rec.attribute16;   --For bug 2184255
850         x_line_tbl(1).attribute17         := p_line_dff_rec.attribute17;
851         x_line_tbl(1).attribute18         := p_line_dff_rec.attribute18;
852         x_line_tbl(1).attribute19         := p_line_dff_rec.attribute19;
853         x_line_tbl(1).attribute2          := p_line_dff_rec.attribute2;
854         x_line_tbl(1).attribute20         := p_line_dff_rec.attribute20;
855         x_line_tbl(1).attribute3          := p_line_dff_rec.attribute3;
856         x_line_tbl(1).attribute4          := p_line_dff_rec.attribute4;
857         x_line_tbl(1).attribute5          := p_line_dff_rec.attribute5;
858         x_line_tbl(1).attribute6          := p_line_dff_rec.attribute6;
859         x_line_tbl(1).attribute7          := p_line_dff_rec.attribute7;
860         x_line_tbl(1).attribute8          := p_line_dff_rec.attribute8;
861         x_line_tbl(1).attribute9          := p_line_dff_rec.attribute9;
862         x_line_tbl(1).context             := p_line_dff_rec.context;
863 
864     ELSIF p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE1
865     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE10
866     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE11
867     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE12
868     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE13
869     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE14
870     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE15
871     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE16
872     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE17
873     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE18
874     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE19
875     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE2
876     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE20
877     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE3
878     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE4
879     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE5
880     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE6
881     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE7
882     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE8
883     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE9
884     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE_CATEGORY
885     THEN
886 
887         x_line_tbl(1).global_attribute1   := p_line_dff_rec.global_attribute1;
888         x_line_tbl(1).global_attribute10  := p_line_dff_rec.global_attribute10;
889         x_line_tbl(1).global_attribute11  := p_line_dff_rec.global_attribute11;
890         x_line_tbl(1).global_attribute12  := p_line_dff_rec.global_attribute12;
891         x_line_tbl(1).global_attribute13  := p_line_dff_rec.global_attribute13;
892         x_line_tbl(1).global_attribute14  := p_line_dff_rec.global_attribute14;
893         x_line_tbl(1).global_attribute15  := p_line_dff_rec.global_attribute15;
894         x_line_tbl(1).global_attribute16  := p_line_dff_rec.global_attribute16;
895         x_line_tbl(1).global_attribute17  := p_line_dff_rec.global_attribute17;
896         x_line_tbl(1).global_attribute18  := p_line_dff_rec.global_attribute18;
897         x_line_tbl(1).global_attribute19  := p_line_dff_rec.global_attribute19;
898         x_line_tbl(1).global_attribute2   := p_line_dff_rec.global_attribute2;
899         x_line_tbl(1).global_attribute20  := p_line_dff_rec.global_attribute20;
900         x_line_tbl(1).global_attribute3   := p_line_dff_rec.global_attribute3;
901         x_line_tbl(1).global_attribute4   := p_line_dff_rec.global_attribute4;
902         x_line_tbl(1).global_attribute5   := p_line_dff_rec.global_attribute5;
903         x_line_tbl(1).global_attribute6   := p_line_dff_rec.global_attribute6;
904         x_line_tbl(1).global_attribute7   := p_line_dff_rec.global_attribute7;
905         x_line_tbl(1).global_attribute8   := p_line_dff_rec.global_attribute8;
906         x_line_tbl(1).global_attribute9   := p_line_dff_rec.global_attribute9;
907         x_line_tbl(1).global_attribute_category := p_line_dff_rec.global_attribute_category;
908 
909     ELSIF p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE1
910     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE10
911     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE11
912     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE12
913     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE13
914     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE14
915     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE15
916     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE2
917     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE3
918     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE4
919     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE5
920     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE6
921     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE7
922     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE8
923     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE9
924     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE16
925     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE17
926     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE18
927     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE19
928     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE20
929     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE21
930     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE22
931     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE23
932     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE24
933     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE25
934     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE26
935     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE27
936     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE28
937     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE29
938     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE30
939     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_CONTEXT
940     THEN
941 
942         x_line_tbl(1).industry_attribute1 := p_line_dff_rec.industry_attribute1;
943         x_line_tbl(1).industry_attribute10 := p_line_dff_rec.industry_attribute10;
944         x_line_tbl(1).industry_attribute11 := p_line_dff_rec.industry_attribute11;
945         x_line_tbl(1).industry_attribute12 := p_line_dff_rec.industry_attribute12;
946         x_line_tbl(1).industry_attribute13 := p_line_dff_rec.industry_attribute13;
947         x_line_tbl(1).industry_attribute14 := p_line_dff_rec.industry_attribute14;
948         x_line_tbl(1).industry_attribute15 := p_line_dff_rec.industry_attribute15;
949         x_line_tbl(1).industry_attribute2 := p_line_dff_rec.industry_attribute2;
950         x_line_tbl(1).industry_attribute3 := p_line_dff_rec.industry_attribute3;
951         x_line_tbl(1).industry_attribute4 := p_line_dff_rec.industry_attribute4;
952         x_line_tbl(1).industry_attribute5 := p_line_dff_rec.industry_attribute5;
953         x_line_tbl(1).industry_attribute6 := p_line_dff_rec.industry_attribute6;
954         x_line_tbl(1).industry_attribute7 := p_line_dff_rec.industry_attribute7;
955         x_line_tbl(1).industry_attribute8 := p_line_dff_rec.industry_attribute8;
956         x_line_tbl(1).industry_attribute9 := p_line_dff_rec.industry_attribute9;
957         x_line_tbl(1).industry_attribute16 := p_line_dff_rec.industry_attribute16;
958         x_line_tbl(1).industry_attribute17 := p_line_dff_rec.industry_attribute17;
959         x_line_tbl(1).industry_attribute18 := p_line_dff_rec.industry_attribute18;
960         x_line_tbl(1).industry_attribute19 := p_line_dff_rec.industry_attribute19;
961         x_line_tbl(1).industry_attribute20 := p_line_dff_rec.industry_attribute20;
962         x_line_tbl(1).industry_attribute21 := p_line_dff_rec.industry_attribute21;
963         x_line_tbl(1).industry_attribute22 := p_line_dff_rec.industry_attribute22;
964         x_line_tbl(1).industry_attribute23 := p_line_dff_rec.industry_attribute23;
965         x_line_tbl(1).industry_attribute24 := p_line_dff_rec.industry_attribute24;
966         x_line_tbl(1).industry_attribute25 := p_line_dff_rec.industry_attribute25;
967         x_line_tbl(1).industry_attribute26 := p_line_dff_rec.industry_attribute26;
968         x_line_tbl(1).industry_attribute27 := p_line_dff_rec.industry_attribute27;
969         x_line_tbl(1).industry_attribute28 := p_line_dff_rec.industry_attribute28;
970         x_line_tbl(1).industry_attribute29 := p_line_dff_rec.industry_attribute29;
971         x_line_tbl(1).industry_attribute30 := p_line_dff_rec.industry_attribute30;
972         x_line_tbl(1).industry_context    := p_line_dff_rec.industry_context;
973 
974     ELSIF p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE1
975     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE10
976     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE2
977     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE3
978     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE4
979     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE5
980     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE6
981     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE7
982     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE8
983     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE9
984     OR     p_attr_id = OE_Line_Util.G_PRICING_CONTEXT
985     THEN
986 
987         x_line_tbl(1).pricing_attribute1  := p_line_dff_rec.pricing_attribute1;
988         x_line_tbl(1).pricing_attribute10 := p_line_dff_rec.pricing_attribute10;
989         x_line_tbl(1).pricing_attribute2  := p_line_dff_rec.pricing_attribute2;
990         x_line_tbl(1).pricing_attribute3  := p_line_dff_rec.pricing_attribute3;
991         x_line_tbl(1).pricing_attribute4  := p_line_dff_rec.pricing_attribute4;
992         x_line_tbl(1).pricing_attribute5  := p_line_dff_rec.pricing_attribute5;
993         x_line_tbl(1).pricing_attribute6  := p_line_dff_rec.pricing_attribute6;
994         x_line_tbl(1).pricing_attribute7  := p_line_dff_rec.pricing_attribute7;
995         x_line_tbl(1).pricing_attribute8  := p_line_dff_rec.pricing_attribute8;
996         x_line_tbl(1).pricing_attribute9  := p_line_dff_rec.pricing_attribute9;
997         x_line_tbl(1).pricing_context     := p_line_dff_rec.pricing_context;
998     /* Amy Return, enable return attributes  */
999     ELSIF p_attr_id = OE_Line_Util.G_RETURN_CONTEXT THEN
1000         x_line_tbl(1).return_context := p_attr_value;
1001         x_line_tbl(1).return_attribute1   := p_line_dff_rec.return_attribute1;
1002         x_line_tbl(1).return_attribute10  := p_line_dff_rec.return_attribute10;
1003         x_line_tbl(1).return_attribute11  := p_line_dff_rec.return_attribute11;
1004         x_line_tbl(1).return_attribute12  := p_line_dff_rec.return_attribute12;
1005         x_line_tbl(1).return_attribute13  := p_line_dff_rec.return_attribute13;
1006         x_line_tbl(1).return_attribute14  := p_line_dff_rec.return_attribute14;
1007         x_line_tbl(1).return_attribute15  := p_line_dff_rec.return_attribute15;
1008         x_line_tbl(1).return_attribute2  := p_line_dff_rec.return_attribute2;
1009         x_line_tbl(1).return_attribute3  := p_line_dff_rec.return_attribute3;
1010         x_line_tbl(1).return_attribute4  := p_line_dff_rec.return_attribute4;
1011         x_line_tbl(1).return_attribute5  := p_line_dff_rec.return_attribute5;
1012         x_line_tbl(1).return_attribute6  := p_line_dff_rec.return_attribute6;
1013         x_line_tbl(1).return_attribute7  := p_line_dff_rec.return_attribute7;
1014         x_line_tbl(1).return_attribute8  := p_line_dff_rec.return_attribute8;
1015         x_line_tbl(1).return_attribute9  := p_line_dff_rec.return_attribute9;
1016         x_line_tbl(1).line_category_code := OE_GLOBALS.G_RETURN_CATEGORY_CODE;
1017 
1018     ELSIF p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE1
1019     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE10
1020     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE11
1021     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE12
1022     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE13
1023     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE14
1024     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE15
1025     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE2
1026     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE3
1027     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE4
1028     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE5
1029     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE6
1030     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE7
1031     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE8
1032     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE9
1033     OR     p_attr_id = OE_Line_Util.G_TP_CONTEXT
1034     THEN
1035         IF l_debug_level  > 0 THEN
1036             oe_debug_pub.add(  'JYOTHI: I AM IN CHANGE ATTRIBUTE' ) ;
1037         END IF;
1038 
1039         x_line_tbl(1).tp_attribute1          := p_line_dff_rec.tp_attribute1;
1040         x_line_tbl(1).tp_attribute10         := p_line_dff_rec.tp_attribute10;
1041         x_line_tbl(1).tp_attribute11         := p_line_dff_rec.tp_attribute11;
1042         x_line_tbl(1).tp_attribute12         := p_line_dff_rec.tp_attribute12;
1043         x_line_tbl(1).tp_attribute13         := p_line_dff_rec.tp_attribute13;
1044         x_line_tbl(1).tp_attribute14         := p_line_dff_rec.tp_attribute14;
1045         x_line_tbl(1).tp_attribute15         := p_line_dff_rec.tp_attribute15;
1046         x_line_tbl(1).tp_attribute2          := p_line_dff_rec.tp_attribute2;
1047         x_line_tbl(1).tp_attribute3          := p_line_dff_rec.tp_attribute3;
1048         x_line_tbl(1).tp_attribute4          := p_line_dff_rec.tp_attribute4;
1049         x_line_tbl(1).tp_attribute5          := p_line_dff_rec.tp_attribute5;
1050         x_line_tbl(1).tp_attribute6          := p_line_dff_rec.tp_attribute6;
1051         x_line_tbl(1).tp_attribute7          := p_line_dff_rec.tp_attribute7;
1052         x_line_tbl(1).tp_attribute8          := p_line_dff_rec.tp_attribute8;
1053         x_line_tbl(1).tp_attribute9          := p_line_dff_rec.tp_attribute9;
1054         x_line_tbl(1).tp_context          := p_line_dff_rec.tp_context;
1055 
1056         IF l_debug_level  > 0 THEN
1057             oe_debug_pub.add(  'JYOTHI- TP ATTRIBUTE IS ' || X_LINE_TBL ( 1 ) .TP_ATTRIBUTE1 ) ;
1058         END IF;
1059     ELSIF p_attr_id = OE_Line_Util.G_COMMITMENT THEN
1060         x_line_tbl(1).commitment_id := TO_NUMBER(p_attr_value);
1061     ELSIF p_attr_id = OE_Line_Util.G_COMMITMENT_APPLIED_AMOUNT THEN
1062         x_line_tbl(1).commitment_applied_amount := TO_NUMBER(p_attr_value);
1063     --MRG BGN
1064     ELSIF p_attr_id = OE_LINE_UTIL.G_UNIT_COST Then
1065         IF l_debug_level  > 0 THEN
1066             oe_debug_pub.add(  'P_ATTR_VALUE='||P_ATTR_VALUE ) ;
1067         END IF;
1068         x_line_tbl(1).unit_cost := TO_NUMBER(p_attr_value);
1069         IF l_debug_level  > 0 THEN
1070             oe_debug_pub.add(  'FLINB:UNIT_COST:'||P_ATTR_VALUE ) ;
1071         END IF;
1072     --MRG END
1073     --retro{
1074     ELSIF p_attr_id = OE_Line_Util.G_RETROBILL_REQUEST THEN
1075         x_line_tbl(1).retrobill_request_id := TO_NUMBER(p_attr_value);
1076 
1077     --retro}
1078     -- Override Selling price
1079     ELSIF p_attr_id = OE_Line_Util.G_ORIGINAL_LIST_PRICE THEN
1080           x_line_tbl(1).original_list_price := TO_NUMBER(p_attr_value);
1081     ELSIF p_attr_id = OE_Line_Util.G_UNIT_LIST_PRICE_PER_PQTY THEN
1082           x_line_tbl(1).unit_list_price_per_pqty := TO_NUMBER(p_attr_value);
1083     ELSIF p_attr_id = OE_Line_Util.G_UNIT_SELLING_PRICE_PER_PQTY THEN
1084           x_line_tbl(1).unit_selling_price_per_pqty := TO_NUMBER(p_attr_value);
1085     -- Override Selling price
1086     -- INVCONV
1087     ELSIF p_attr_id = OE_Line_Util.G_CANCELLED_QUANTITY2 THEN
1088         x_line_tbl(1).cancelled_quantity2 := TO_NUMBER(p_attr_value);
1089     ELSIF p_attr_id = OE_Line_Util.G_FULFILLED_QUANTITY2 THEN
1090         x_line_tbl(1).fulfilled_quantity2 := TO_NUMBER(p_attr_value);
1091     ELSIF p_attr_id = OE_Line_Util.G_SHIPPED_QUANTITY2 THEN
1092         x_line_tbl(1).shipped_quantity2 := TO_NUMBER(p_attr_value);
1093     ELSIF p_attr_id = OE_Line_Util.G_SHIPPING_QUANTITY2 THEN
1094         x_line_tbl(1).shipping_quantity2 := TO_NUMBER(p_attr_value);
1095     ELSIF p_attr_id = OE_Line_Util.G_SHIPPING_QUANTITY_UOM2 THEN
1096         x_line_tbl(1).shipping_quantity_uom2 := p_attr_value;
1097     ELSIF p_attr_id = OE_Line_Util.G_RESERVED_QUANTITY2 THEN
1098         x_line_tbl(1).reserved_quantity2 := p_attr_value;
1099 
1100     ELSE
1101 
1102         IF l_debug_level  > 0 THEN
1103             oe_debug_pub.add(  'UNRECOGNIZED ATTRIBUTE EXCEPTION' , 2 ) ;
1104         END IF;
1105 
1106         --  Unexpected error, unrecognized attribute
1107 
1108         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
1109         THEN
1110             oe_msg_pub.Add_Exc_Msg
1111             (   G_PKG_NAME
1112             ,   'Change_Attribute'
1113             ,   'Unrecognized attribute'
1114             );
1115         END IF;
1116 
1117         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1118 
1119     END IF;
1120 
1121 
1122 EXCEPTION
1123     WHEN OTHERS THEN
1124         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
1125         THEN
1126             oe_msg_pub.Add_Exc_Msg
1127             (   G_PKG_NAME
1128             ,   'Copy_Attribute_To_Rec'
1129             );
1130         END IF;
1131         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1132 END Copy_Attribute_To_Rec;
1133 
1134 --  Procedure   :   Change_Attribute
1135 --
1136 -- Commenting OUT all flex attributes because
1137 -- we ran into an odd bug where the client(pld) does not recognize a package
1138 -- at all once it gets over a certain size (255 parameters per procedure)
1139 
1140 -- Commenting OUT the pricing attributes for now since the number of
1141 -- parameters increases beyond the 255 parameters.
1142 
1143 PROCEDURE Change_Attribute
1144 ( x_return_status OUT NOCOPY VARCHAR2
1145 , x_msg_count OUT NOCOPY NUMBER
1146 , x_msg_data OUT NOCOPY VARCHAR2
1147 ,   p_line_id                       IN  NUMBER
1148 ,   p_attr_id                       IN  NUMBER
1149 ,   p_attr_value                    IN  VARCHAR2
1150 ,   p_attr_id_tbl                   IN  Number_Tbl_Type
1151 ,   p_attr_value_tbl                IN  Varchar2_Tbl_Type
1152 ,   p_reason                IN  VARCHAR2
1153 ,   p_comments              IN  VARCHAR2
1154 ,   p_line_dff_rec                  IN OE_OE_FORM_LINE.line_dff_rec_type
1155 ,   p_default_cache_line_rec           IN  OE_ORDER_PUB.Line_Rec_Type
1156 ,   p_date_format_mask              IN  VARCHAR2 DEFAULT 'DD-MON-YYYY HH24:MI:SS'
1157 ,   x_line_tbl                      IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type
1158 ,   x_old_line_tbl                  IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type
1159 ,   x_line_val_tbl                  IN OUT NOCOPY OE_ORDER_PUB.Line_Val_Tbl_Type
1160 --, x_dualum_ind OUT NOCOPY NUMBER --OPM 02/JUN/00  INVCONV
1161 --, x_grade_ctl OUT NOCOPY NUMBER --OPM 02/JUN/00   INVCONV
1162 , x_process_warehouse_flag OUT NOCOPY VARCHAR2 --OPM 02/JUN/00
1163 --, x_ont_pricing_qty_source OUT NOCOPY NUMBER --OPM 2046190
1164 , x_ont_pricing_qty_source OUT NOCOPY VARCHAR2 -- INVCONV
1165 , x_grade_control_flag OUT NOCOPY VARCHAR2 -- INVCONV
1166 , x_tracking_quantity_ind   OUT NOCOPY VARCHAR2 -- INVCONV
1167 , x_secondary_default_ind OUT NOCOPY VARCHAR2 -- INVCONV
1168 , x_lot_divisible_flag OUT NOCOPY VARCHAR2 -- INVCONV
1169 , x_lot_control_code OUT NOCOPY /* file.sql.39 change */ NUMBER  -- 4172680 INVCONV
1170 
1171 )
1172 IS
1173 l_control_rec                 OE_GLOBALS.Control_Rec_Type;
1174 l_return_status               VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
1175 l_date_format_mask            VARCHAR2(30) := p_date_format_mask;
1176 l_order_date_type_code        VARCHAR2(30) := null;
1177 l_orig_ship_from_org_id       OE_Order_LINES.ship_from_org_id%TYPE;
1178 l_x_item_rec_type             OE_ORDER_CACHE.item_rec_type;    -- OPM 2/JUN/00
1179 file_name varchar2(100);
1180 i                       pls_Integer;
1181 L_PRICE_CONTROL_REC         QP_PREQ_GRP.control_record_type;
1182 --
1183 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1184 --
1185 --bug16574638
1186 l_return_context              VARCHAR2(30) := null;
1187 l_return_attrib1              VARCHAR2(240):= null;
1188 l_return_attrib2              VARCHAR2(240):= null;
1189 --bug16574638
1190 BEGIN
1191 
1192     IF l_debug_level  > 0 THEN
1193         oe_debug_pub.add(  'ENTERING OE_OE_FORM_LINE.CHANGE_ATTRIBUTES' , 1 ) ;
1194     END IF;
1195 
1196     -- Set UI flag to TRUE
1197     OE_GLOBALS.G_UI_FLAG := TRUE;
1198 
1199 
1200     --  Set control flags.
1201 
1202     l_control_rec.controlled_operation := TRUE;
1203     l_control_rec.change_attributes    := TRUE;
1204 
1205     l_control_rec.validate_entity      := FALSE;
1206     l_control_rec.write_to_DB          := FALSE;
1207     l_control_rec.process              := FALSE;
1208 
1209     --  Instruct API to retain its caches
1210 
1211     l_control_rec.clear_api_cache      := FALSE;
1212     l_control_rec.clear_api_requests   := FALSE;
1213 
1214     --  Read line from cache
1215 
1216     IF p_default_cache_line_rec.line_id IS NOT NULL THEN
1217       x_line_tbl(1):=p_default_cache_line_rec;
1218       x_line_tbl(1).db_flag := FND_API.G_FALSE;
1219        Write_line
1220        (   p_line_rec                    => x_line_tbl(1)
1221        );
1222 
1223     END IF;
1224 
1225 
1226     IF p_default_cache_line_rec.line_id IS NOT NULL THEN
1227       --x_old_line_tbl(1) := OE_ORDER_PUB.G_MISS_LINE_REC;
1228         x_old_line_tbl(1).line_id := null;
1229         x_line_tbl(1):=p_default_cache_line_rec;
1230         l_control_rec.default_attributes   := FALSE;
1231         l_control_rec.clear_dependents     := FALSE;
1232         l_control_rec.check_security       := FALSE;
1233 
1234         IF FND_API.To_Boolean(x_line_tbl(1).db_flag) THEN
1235           x_line_tbl(1).operation := OE_GLOBALS.G_OPR_UPDATE;
1236         ELSE
1237           x_line_tbl(1).operation := OE_GLOBALS.G_OPR_CREATE;
1238         END IF;
1239 
1240         Oe_Order_Pvt.Lines
1241         (
1242          p_validation_level            => FND_API.G_VALID_LEVEL_NONE
1243        , p_init_msg_list               => FND_API.G_TRUE
1244        , p_control_rec                 => l_control_rec
1245        , p_x_line_tbl                  => x_line_tbl
1246        , p_x_old_line_tbl              => x_old_line_tbl
1247        , x_return_status               => l_return_status
1248         );
1249        IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1250            IF l_debug_level  > 0 THEN
1251                oe_debug_pub.add(  'DATE TYPE RETURNED UNEXP_ERROR' , 2 ) ;
1252            END IF;
1253            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1254        ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1255            IF l_debug_level  > 0 THEN
1256                oe_debug_pub.add(  'DATE TYPE RETURN RET_STS_ERROR' , 2 ) ;
1257            END IF;
1258            RAISE FND_API.G_EXC_ERROR;
1259        END IF;
1260 
1261        x_old_line_tbl(1) := x_line_tbl(1);
1262     ELSE
1263 
1264       Get_line
1265       (   p_db_record                   => FALSE
1266        ,   p_line_id                     => p_line_id
1267        ,   x_line_rec                    => x_line_tbl(1)
1268        );
1269 
1270        IF l_debug_level  > 0 THEN
1271            oe_debug_pub.add(  'JPN:AFTER LINE QUERY : ' || X_LINE_TBL ( 1 ) .TP_ATTRIBUTE1 ) ;
1272        END IF;
1273 
1274        x_old_line_tbl(1) := x_line_tbl(1);
1275 
1276     END IF;
1277     l_control_rec.default_attributes   := TRUE;
1278     l_control_rec.clear_dependents     := TRUE;
1279     l_control_rec.check_security        := TRUE;
1280 
1281     IF OE_CODE_CONTROL.Code_Release_Level >= '110509' THEN
1282 
1283        IF l_debug_level  > 0 THEN
1284            oe_debug_pub.add(  'Code Release is >= 11.5.9') ;
1285        END IF;
1286 
1287        Copy_Attribute_To_Rec
1288                 (p_attr_id         => p_attr_id
1289                 ,p_attr_value      => p_attr_value
1290                 ,p_line_dff_rec    => p_line_dff_rec
1291                 ,p_date_format_mask  => p_date_format_mask
1292                 ,x_line_tbl        => x_line_tbl
1293                 ,x_old_line_tbl    => x_old_line_tbl
1294                 );
1295 
1296        FOR l_index IN 1..p_attr_id_tbl.COUNT LOOP
1297 
1298            Copy_Attribute_To_Rec
1299                 (p_attr_id         => p_attr_id_tbl(l_index)
1300                 ,p_attr_value      => p_attr_value_tbl(l_index)
1301                 ,p_line_dff_rec    => p_line_dff_rec
1302                 ,p_date_format_mask  => p_date_format_mask
1303                 ,x_line_tbl        => x_line_tbl
1304                 ,x_old_line_tbl    => x_old_line_tbl
1305                 );
1306 
1307        END LOOP;
1308 
1309     ELSE
1310 
1311        IF l_debug_level  > 0 THEN
1312            oe_debug_pub.add(  'Code Release is < 11.5.9') ;
1313        END IF;
1314 
1315     -- PLEASE ADD THIS IF LOGIC FOR NEW ATTRIBUTES TO THE PROCEDURE
1316     -- COPY_ATTRIBUTE_TO_REC ALSO. THIS NEW PROCEDURE WILL REPLACE
1317     -- THESE IF CALLS POST OM PACK I OR 11.5.9.
1318 
1319     IF p_attr_id = OE_Line_Util.G_ACCOUNTING_RULE THEN
1320         x_line_tbl(1).accounting_rule_id := TO_NUMBER(p_attr_value);
1321     ELSIF p_attr_id = OE_Line_Util.G_ACCOUNTING_RULE_DURATION THEN
1322         x_line_tbl(1).accounting_rule_duration := TO_NUMBER(p_attr_value);
1323     ELSIF p_attr_id = OE_Line_Util.G_ACTUAL_ARRIVAL_DATE THEN
1324       --  x_line_tbl(1).actual_arrival_date := TO_DATE(p_attr_value, l_date_format_mask);
1325       x_line_tbl(1).actual_arrival_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
1326     ELSIF p_attr_id = OE_Line_Util.G_ACTUAL_SHIPMENT_DATE THEN
1327       --  x_line_tbl(1).actual_shipment_date := TO_DATE(p_attr_value, l_date_format_mask);
1328        x_line_tbl(1).actual_shipment_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
1329     ELSIF p_attr_id = OE_Line_Util.G_AGREEMENT THEN
1330         x_line_tbl(1).agreement_id := TO_NUMBER(p_attr_value);
1331     ELSIF p_attr_id = OE_Line_Util.G_IB_OWNER THEN
1332           x_line_tbl(1).ib_owner := p_attr_value;
1333     ELSIF p_attr_id = OE_Line_Util.G_IB_INSTALLED_AT_LOCATION THEN
1334           x_line_tbl(1).ib_installed_at_location := p_attr_value;
1335     ELSIF p_attr_id = OE_Line_Util.G_IB_CURRENT_LOCATION THEN
1336           x_line_tbl(1).ib_current_location := p_attr_value;
1337     ELSIF p_attr_id = OE_Line_Util.G_END_CUSTOMER_SITE_USE THEN
1338           x_line_tbl(1).end_customer_site_use_id := TO_NUMBER(p_attr_value);
1339     ELSIF p_attr_id = OE_Line_Util.G_END_CUSTOMER_CONTACT THEN
1340           x_line_tbl(1).end_customer_contact_id := TO_NUMBER(p_attr_value);
1341     ELSIF p_attr_id = OE_Line_Util.G_END_CUSTOMER THEN
1342           x_line_tbl(1).end_customer_id := TO_NUMBER(p_attr_value);
1343     ELSIF p_attr_id = OE_Line_Util.G_ATO_LINE THEN
1344         x_line_tbl(1).ato_line_id := TO_NUMBER(p_attr_value);
1345     ELSIF p_attr_id = OE_Line_Util.G_AUTO_SELECTED_QUANTITY THEN
1346         x_line_tbl(1).auto_selected_quantity := TO_NUMBER(p_attr_value);
1347     ELSIF p_attr_id = OE_Line_Util.G_BLANKET_NUMBER THEN
1348           x_line_tbl(1).blanket_number := TO_NUMBER(p_attr_value);
1349     ELSIF p_attr_id = OE_Line_Util.G_BLANKET_LINE_NUMBER THEN
1350           x_line_tbl(1).blanket_line_number := TO_NUMBER(p_attr_value);
1351     ELSIF p_attr_id = OE_Line_Util.G_BLANKET_VERSION_NUMBER THEN
1352           x_line_tbl(1).blanket_version_number := TO_NUMBER(p_attr_value);
1353     ELSIF p_attr_id = OE_Line_Util.G_BOOKED THEN
1354         x_line_tbl(1).booked_flag := p_attr_value;
1355     ELSIF p_attr_id = OE_Line_Util.G_CANCELLED THEN
1356         x_line_tbl(1).cancelled_flag := p_attr_value;
1357     ELSIF p_attr_id = OE_Line_Util.G_CANCELLED_QUANTITY THEN
1358         x_line_tbl(1).cancelled_quantity := TO_NUMBER(p_attr_value);
1359     ELSIF p_attr_id = OE_Line_Util.G_COMPONENT THEN
1360         x_line_tbl(1).component_code := p_attr_value;
1361     ELSIF p_attr_id = OE_Line_Util.G_COMPONENT_NUMBER THEN
1362         x_line_tbl(1).component_number := p_attr_value;
1363     ELSIF p_attr_id = OE_Line_Util.G_COMPONENT_SEQUENCE THEN
1364         x_line_tbl(1).component_sequence_id := TO_NUMBER(p_attr_value);
1365     ELSIF p_attr_id = OE_Line_Util.G_CONFIG_DISPLAY_SEQUENCE THEN
1366         x_line_tbl(1).config_display_sequence := TO_NUMBER(p_attr_value);
1367     ELSIF p_attr_id = OE_Line_Util.G_CONFIGURATION THEN
1368         x_line_tbl(1).configuration_id := TO_NUMBER(p_attr_value);
1369     ELSIF p_attr_id = OE_Line_Util.G_CONFIG_HEADER THEN
1370         x_line_tbl(1).config_header_id := TO_NUMBER(p_attr_value);
1371     ELSIF p_attr_id = OE_Line_Util.G_CONFIG_REV_NBR THEN
1372         x_line_tbl(1).config_rev_nbr := TO_NUMBER(p_attr_value);
1373     ELSIF p_attr_id = OE_Line_Util.G_CREDIT_INVOICE_LINE THEN
1374         x_line_tbl(1).credit_invoice_line_id := TO_NUMBER(p_attr_value);
1375     ELSIF p_attr_id = OE_Line_Util.G_CUSTOMER_DOCK THEN
1376         x_line_tbl(1).customer_dock_code := p_attr_value;
1377     ELSIF p_attr_id = OE_Line_Util.G_CUSTOMER_JOB THEN
1378         x_line_tbl(1).customer_job := p_attr_value;
1379     ELSIF p_attr_id = OE_Line_Util.G_CUSTOMER_PRODUCTION_LINE THEN
1380         x_line_tbl(1).customer_production_line := p_attr_value;
1381     ELSIF p_attr_id = OE_Line_Util.G_CUSTOMER_TRX_LINE THEN
1382         x_line_tbl(1).customer_trx_line_id := TO_NUMBER(p_attr_value);
1383     ELSIF p_attr_id = OE_Line_Util.G_CUST_MODEL_SERIAL_NUMBER THEN
1384         x_line_tbl(1).cust_model_serial_number := p_attr_value;
1385     ELSIF p_attr_id = OE_Line_Util.G_CUST_PO_NUMBER THEN
1386         x_line_tbl(1).cust_po_number := p_attr_value;
1387     ELSIF p_attr_id = OE_Line_Util.G_DELIVERY_LEAD_TIME THEN
1388         x_line_tbl(1).delivery_lead_time := TO_NUMBER(p_attr_value);
1389     ELSIF p_attr_id = OE_Line_Util.G_DELIVER_TO_CONTACT THEN
1390         x_line_tbl(1).deliver_to_contact_id := TO_NUMBER(p_attr_value);
1391     ELSIF p_attr_id = OE_Line_Util.G_DELIVER_TO_ORG THEN
1392         x_line_tbl(1).deliver_to_org_id := TO_NUMBER(p_attr_value);
1393     ELSIF p_attr_id = OE_Line_Util.G_DEMAND_BUCKET_TYPE THEN
1394         x_line_tbl(1).demand_bucket_type_code := p_attr_value;
1395     ELSIF p_attr_id = OE_Line_Util.G_DEMAND_CLASS THEN
1396         x_line_tbl(1).demand_class_code := p_attr_value;
1397     ELSIF p_attr_id = OE_Line_Util.G_DEP_PLAN_REQUIRED THEN
1398         x_line_tbl(1).dep_plan_required_flag := p_attr_value;
1399     ELSIF p_attr_id = OE_Line_Util.G_EARLIEST_ACCEPTABLE_DATE THEN
1400       --  x_line_tbl(1).earliest_acceptable_date := TO_DATE(p_attr_value, l_date_format_mask);
1401        x_line_tbl(1).earliest_acceptable_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
1402     ELSIF p_attr_id = OE_Line_Util.G_EXPLOSION_DATE THEN
1403       --  x_line_tbl(1).explosion_date := TO_DATE(p_attr_value, l_date_format_mask);
1404        x_line_tbl(1).explosion_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
1405     ELSIF p_attr_id = OE_Line_Util.G_FOB_POINT THEN
1406         x_line_tbl(1).fob_point_code := p_attr_value;
1407     ELSIF p_attr_id = OE_Line_Util.G_FREIGHT_CARRIER THEN
1408         x_line_tbl(1).freight_carrier_code := p_attr_value;
1409     ELSIF p_attr_id = OE_Line_Util.G_FREIGHT_TERMS THEN
1410         x_line_tbl(1).freight_terms_code := p_attr_value;
1411     ELSIF p_attr_id = OE_Line_Util.G_FULFILLED_QUANTITY THEN
1412         x_line_tbl(1).fulfilled_quantity := TO_NUMBER(p_attr_value);
1413     ELSIF p_attr_id = OE_Line_Util.G_HEADER THEN
1414         x_line_tbl(1).header_id := TO_NUMBER(p_attr_value);
1415     ELSIF p_attr_id = OE_Line_Util.G_INTERMED_SHIP_TO_CONTACT THEN
1416         x_line_tbl(1).intermed_ship_to_contact_id := TO_NUMBER(p_attr_value);
1417     ELSIF p_attr_id = OE_Line_Util.G_INTERMED_SHIP_TO_ORG THEN
1418         x_line_tbl(1).intermed_ship_to_org_id := TO_NUMBER(p_attr_value);
1419     ELSIF p_attr_id = OE_Line_Util.G_INVENTORY_ITEM THEN
1420         x_line_tbl(1).inventory_item_id := TO_NUMBER(p_attr_value);
1421     ELSIF p_attr_id = OE_Line_Util.G_INVOICE_INTERFACE_STATUS THEN
1422         x_line_tbl(1).invoice_interface_status_code := p_attr_value;
1423     ELSIF p_attr_id = OE_Line_Util.G_INVOICE_TO_CONTACT THEN
1424         x_line_tbl(1).invoice_to_contact_id := TO_NUMBER(p_attr_value);
1425     ELSIF p_attr_id = OE_Line_Util.G_INVOICE_TO_ORG THEN
1426         x_line_tbl(1).invoice_to_org_id := TO_NUMBER(p_attr_value);
1427     ELSIF p_attr_id = OE_Line_Util.G_INVOICED_QUANTITY THEN
1428         x_line_tbl(1).invoiced_quantity := TO_NUMBER(p_attr_value);
1429     ELSIF p_attr_id = OE_Line_Util.G_INVOICING_RULE THEN
1430         x_line_tbl(1).invoicing_rule_id := TO_NUMBER(p_attr_value);
1431     ELSIF p_attr_id = OE_Line_Util.G_ORDERED_ITEM_ID THEN
1432         x_line_tbl(1).ordered_item_id := TO_NUMBER(p_attr_value);
1433     ELSIF p_attr_id = OE_Line_Util.G_ITEM_IDENTIFIER_TYPE THEN
1434         x_line_tbl(1).item_identifier_type := p_attr_value;
1435     ELSIF p_attr_id = OE_Line_Util.G_ORDERED_ITEM THEN
1436         x_line_tbl(1).ordered_item := p_attr_value;
1437     ELSIF p_attr_id = OE_Line_Util.G_ITEM_REVISION THEN
1438         x_line_tbl(1).item_revision := p_attr_value;
1439     ELSIF p_attr_id = OE_Line_Util.G_ITEM_TYPE THEN
1440         x_line_tbl(1).item_type_code := p_attr_value;
1441     ELSIF p_attr_id = OE_Line_Util.G_LATEST_ACCEPTABLE_DATE THEN
1442       --  x_line_tbl(1).latest_acceptable_date := TO_DATE(p_attr_value, l_date_format_mask);
1443        x_line_tbl(1).latest_acceptable_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
1444     ELSIF p_attr_id = OE_Line_Util.G_LATE_DEMAND_PENALTY_FACTOR THEN
1445         x_line_tbl(1).late_demand_penalty_factor := TO_NUMBER(p_attr_value);
1446     ELSIF p_attr_id = OE_Line_Util.G_LINE_CATEGORY THEN
1447         x_line_tbl(1).line_category_code := p_attr_value;
1448         x_line_tbl(1).line_type_id := FND_API.G_MISS_NUM;
1449     ELSIF p_attr_id = OE_Line_Util.G_LINE THEN
1450         x_line_tbl(1).line_id := TO_NUMBER(p_attr_value);
1451     ELSIF p_attr_id = OE_Line_Util.G_LINE_NUMBER THEN
1452         x_line_tbl(1).line_number := TO_NUMBER(p_attr_value);
1453     ELSIF p_attr_id = OE_Line_Util.G_LINE_TYPE THEN
1454         x_line_tbl(1).line_type_id := TO_NUMBER(p_attr_value);
1455     ELSIF p_attr_id = OE_Line_Util.G_LINK_TO_LINE THEN
1456         x_line_tbl(1).link_to_line_id := TO_NUMBER(p_attr_value);
1457     ELSIF p_attr_id = OE_Line_Util.G_MODEL_GROUP_NUMBER THEN
1458         x_line_tbl(1).model_group_number := TO_NUMBER(p_attr_value);
1459     ELSIF p_attr_id = OE_Line_Util.G_OPEN THEN
1460         x_line_tbl(1).open_flag := p_attr_value;
1461     ELSIF p_attr_id = OE_Line_Util.G_OPTION_FLAG THEN
1462         x_line_tbl(1).option_flag := p_attr_value;
1463     ELSIF p_attr_id = OE_Line_Util.G_OPTION_NUMBER THEN
1464         x_line_tbl(1).option_number := TO_NUMBER(p_attr_value);
1465     ELSIF p_attr_id = OE_Line_Util.G_ORDERED_QUANTITY THEN
1466         x_line_tbl(1).ordered_quantity := FND_NUMBER.CANONICAL_TO_NUMBER(p_attr_value); --bug 5179564
1467     ELSIF p_attr_id = OE_Line_Util.G_ORDER_QUANTITY_UOM THEN
1468         x_line_tbl(1).order_quantity_uom := p_attr_value;
1469     ELSIF p_attr_id = OE_Line_Util.G_ORDERED_QUANTITY2 THEN       --OPM
1470         x_line_tbl(1).ordered_quantity2 := FND_NUMBER.CANONICAL_TO_NUMBER(p_attr_value); --bug 5179564
1471     ELSIF p_attr_id = OE_Line_Util.G_ORDERED_QUANTITY_UOM2 THEN   --OPM
1472         x_line_tbl(1).ordered_quantity_uom2 := p_attr_value;
1473 
1474     ELSIF p_attr_id = OE_Line_Util.G_ORG THEN
1475         x_line_tbl(1).org_id := TO_NUMBER(p_attr_value);
1476     ELSIF p_attr_id = OE_Line_Util.G_ORIG_SYS_DOCUMENT_REF THEN
1477         x_line_tbl(1).orig_sys_document_ref := p_attr_value;
1478     ELSIF p_attr_id = OE_Line_Util.G_ORIG_SYS_LINE_REF THEN
1479         x_line_tbl(1).orig_sys_line_ref := p_attr_value;
1480     ELSIF p_attr_id = OE_Line_Util.G_ORIG_SYS_SHIPMENT_REF THEN
1481         x_line_tbl(1).orig_sys_shipment_ref := p_attr_value;
1482     ELSIF p_attr_id = OE_Line_Util.G_ORIGINAL_INVENTORY_ITEM THEN
1483         x_line_tbl(1).original_inventory_item_id:= to_number(p_attr_value);
1484     ELSIF p_attr_id = OE_Line_Util.G_ORIGINAL_ORDERED_ITEM THEN
1485         x_line_tbl(1).original_ordered_item := p_attr_value;
1486     ELSIF p_attr_id = OE_Line_Util.G_ORIGINAL_ORDERED_ITEM_ID THEN
1487         x_line_tbl(1).original_ordered_item_id := to_number(p_attr_value);
1488     ELSIF p_attr_id = OE_Line_Util.G_ORIGINAL_ITEM_IDEN_TYPE THEN
1489         x_line_tbl(1).original_item_identifier_type := p_attr_value;
1490     ELSIF p_attr_id = OE_Line_Util.G_ITEM_RELATIONSHIP_TYPE THEN
1491         x_line_tbl(1).item_relationship_type := to_number(p_attr_value);
1492     ELSIF p_attr_id = OE_Line_Util.G_PAYMENT_TERM THEN
1493         x_line_tbl(1).payment_term_id := TO_NUMBER(p_attr_value);
1494     ELSIF p_attr_id = OE_Line_Util.G_PLANNING_PRIORITY THEN
1495         x_line_tbl(1).planning_priority := TO_NUMBER(p_attr_value);
1496     ELSIF p_attr_id = OE_Line_Util.G_PREFERRED_GRADE THEN         --OPM
1497         x_line_tbl(1).preferred_grade := p_attr_value;
1498 
1499     ELSIF p_attr_id = OE_Line_Util.G_PRICE_LIST THEN
1500         x_line_tbl(1).price_list_id := TO_NUMBER(p_attr_value);
1501     ELSIF p_attr_id = OE_Line_Util.G_PRICING_DATE THEN
1502        -- x_line_tbl(1).pricing_date := TO_DATE(p_attr_value, l_date_format_mask);
1503         x_line_tbl(1).pricing_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
1504     ELSIF p_attr_id = OE_Line_Util.G_PRICING_QUANTITY THEN
1505         x_line_tbl(1).pricing_quantity := TO_NUMBER(p_attr_value);
1506     ELSIF p_attr_id = OE_Line_Util.G_PRICING_QUANTITY_UOM THEN
1507         x_line_tbl(1).pricing_quantity_uom := p_attr_value;
1508     ELSIF p_attr_id = OE_Line_Util.G_PROJECT THEN
1509         x_line_tbl(1).project_id := TO_NUMBER(p_attr_value);
1510     ELSIF p_attr_id = OE_Line_Util.G_PROMISE_DATE THEN
1511       --  x_line_tbl(1).promise_date := TO_DATE(p_attr_value, l_date_format_mask);
1512         x_line_tbl(1).promise_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
1513     ELSIF p_attr_id = OE_Line_Util.G_REFERENCE_CUSTOMER_TRX_LINE THEN
1514         x_line_tbl(1).reference_customer_trx_line_id := TO_NUMBER(p_attr_value);
1515     ELSIF p_attr_id = OE_Line_Util.G_REFERENCE_HEADER THEN
1516         x_line_tbl(1).reference_header_id := TO_NUMBER(p_attr_value);
1517     ELSIF p_attr_id = OE_Line_Util.G_REFERENCE_LINE THEN
1518         x_line_tbl(1).reference_line_id := TO_NUMBER(p_attr_value);
1519     ELSIF p_attr_id = OE_Line_Util.G_REFERENCE_TYPE THEN
1520         NULL;
1521     ELSIF p_attr_id = OE_Line_Util.G_REQUEST_DATE THEN
1522       --  x_line_tbl(1).request_date := TO_DATE(p_attr_value, l_date_format_mask);
1523        x_line_tbl(1).request_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
1524     ELSIF p_attr_id = OE_Line_Util.G_RESERVED_QUANTITY THEN
1525         x_line_tbl(1).reserved_quantity := p_attr_value;
1526     ELSIF p_attr_id = OE_Line_Util.G_RLA_SCHEDULE_TYPE THEN
1527         x_line_tbl(1).rla_schedule_type_code := p_attr_value;
1528     ELSIF p_attr_id = OE_Line_Util.G_SCHEDULE_ARRIVAL_DATE THEN
1529       --  x_line_tbl(1).schedule_arrival_date := TO_DATE(p_attr_value, l_date_format_mask);
1530         x_line_tbl(1).schedule_arrival_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
1531     ELSIF p_attr_id = OE_Line_Util.G_SCHEDULE_SHIP_DATE THEN
1532        /* x_line_tbl(1).schedule_ship_date :=
1533                   TO_DATE(p_attr_value, l_date_format_mask);*/
1534          x_line_tbl(1).schedule_ship_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
1535     ELSIF p_attr_id = OE_Line_Util.G_EARLIEST_SHIP_DATE THEN
1536       /*  x_line_tbl(1).earliest_ship_date :=
1537                   TO_DATE(p_attr_value, l_date_format_mask);*/
1538         x_line_tbl(1).earliest_ship_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
1539     ELSIF p_attr_id = OE_Line_Util.G_FIRM_DEMAND THEN
1540         x_line_tbl(1).firm_demand_flag := p_attr_value;
1541     ELSIF p_attr_id = OE_Line_Util.G_SCHEDULE_ACTION THEN
1542         x_line_tbl(1).schedule_action_code := p_attr_value;
1543     ELSIF p_attr_id = OE_Line_Util.G_OVERRIDE_ATP_DATE THEN
1544        x_line_tbl(1).override_atp_date_code := p_attr_value;
1545     ELSIF p_attr_id = OE_Line_Util.G_SCHEDULE_STATUS THEN
1546         x_line_tbl(1).schedule_status_code := p_attr_value;
1547     ELSIF p_attr_id = OE_Line_Util.G_SHIPMENT_NUMBER THEN
1548         x_line_tbl(1).shipment_number := TO_NUMBER(p_attr_value);
1549     ELSIF p_attr_id = OE_Line_Util.G_SHIPMENT_PRIORITY THEN
1550         x_line_tbl(1).shipment_priority_code := p_attr_value;
1551     ELSIF p_attr_id = OE_Line_Util.G_SHIPPED_QUANTITY THEN
1552         x_line_tbl(1).shipped_quantity := TO_NUMBER(p_attr_value);
1553     ELSIF p_attr_id = OE_Line_Util.G_SHIPPING_METHOD THEN
1554         x_line_tbl(1).shipping_method_code := p_attr_value;
1555     ELSIF p_attr_id = OE_Line_Util.G_SHIPPING_QUANTITY THEN
1556         x_line_tbl(1).shipping_quantity := TO_NUMBER(p_attr_value);
1557     ELSIF p_attr_id = OE_Line_Util.G_SHIPPING_QUANTITY_UOM THEN
1558         x_line_tbl(1).shipping_quantity_uom := p_attr_value;
1559     ELSIF p_attr_id = OE_Line_Util.G_SHIP_FROM_ORG THEN
1560         x_line_tbl(1).ship_from_org_id := TO_NUMBER(p_attr_value);
1561     ELSIF p_attr_id = OE_Line_Util.G_SUBINVENTORY THEN
1562         x_line_tbl(1).subinventory := p_attr_value;
1563     ELSIF p_attr_id = OE_Line_Util.G_SHIP_TOLERANCE_ABOVE THEN
1564         x_line_tbl(1).ship_tolerance_above := TO_NUMBER(p_attr_value);
1565     ELSIF p_attr_id = OE_Line_Util.G_SHIP_TOLERANCE_BELOW THEN
1566         x_line_tbl(1).ship_tolerance_below := TO_NUMBER(p_attr_value);
1567     ELSIF p_attr_id = OE_Line_Util.G_SHIPPING_INTERFACED THEN
1568         x_line_tbl(1).shipping_interfaced_flag := p_attr_value;
1569     ELSIF p_attr_id = OE_Line_Util.G_SHIP_TO_CONTACT THEN
1570         x_line_tbl(1).ship_to_contact_id := TO_NUMBER(p_attr_value);
1571     IF l_debug_level  > 0 THEN
1572         oe_debug_pub.add(  'SHIP TO CONTACT1'|| X_LINE_TBL ( 1 ) .SHIP_TO_CONTACT_ID , 1 ) ;
1573     END IF;
1574     ELSIF p_attr_id = OE_Line_Util.G_SHIP_TO_ORG THEN
1575         x_line_tbl(1).ship_to_org_id := TO_NUMBER(p_attr_value);
1576     ELSIF p_attr_id = OE_Line_Util.G_SHIP_MODEL_COMPLETE_FLAG THEN
1577         x_line_tbl(1).ship_model_complete_flag := p_attr_value;
1578     ELSIF p_attr_id = OE_Line_Util.G_SOLD_TO_ORG THEN
1579         x_line_tbl(1).sold_to_org_id := TO_NUMBER(p_attr_value);
1580     ELSIF p_attr_id = OE_Line_Util.G_SORT_ORDER THEN
1581         x_line_tbl(1).sort_order := p_attr_value;
1582     ELSIF p_attr_id = OE_Line_Util.G_SOURCE_DOCUMENT THEN
1583         x_line_tbl(1).source_document_id := TO_NUMBER(p_attr_value);
1584     ELSIF p_attr_id = OE_Line_Util.G_SOURCE_DOCUMENT_LINE THEN
1585         x_line_tbl(1).source_document_line_id := TO_NUMBER(p_attr_value);
1586     ELSIF p_attr_id = OE_Line_Util.G_SOURCE_DOCUMENT_TYPE THEN
1587         x_line_tbl(1).source_document_type_id := TO_NUMBER(p_attr_value);
1588     ELSIF p_attr_id = OE_Line_Util.G_SOURCE_TYPE THEN
1589         x_line_tbl(1).source_type_code := p_attr_value;
1590     ELSIF p_attr_id = OE_Line_Util.G_TASK THEN
1591         x_line_tbl(1).task_id := TO_NUMBER(p_attr_value);
1592     ELSIF p_attr_id = OE_Line_Util.G_TAX THEN
1593         x_line_tbl(1).tax_code := p_attr_value;
1594     ELSIF p_attr_id = OE_Line_Util.G_TAX_DATE THEN
1595       --  x_line_tbl(1).tax_date := TO_DATE(p_attr_value, l_date_format_mask);
1596          x_line_tbl(1).tax_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
1597     ELSIF p_attr_id = OE_Line_Util.G_TAX_EXEMPT THEN
1598         x_line_tbl(1).tax_exempt_flag := p_attr_value;
1599     ELSIF p_attr_id = OE_Line_Util.G_TAX_EXEMPT_NUMBER THEN
1600         x_line_tbl(1).tax_exempt_number := p_attr_value;
1601     ELSIF p_attr_id = OE_Line_Util.G_TAX_EXEMPT_REASON THEN
1602         x_line_tbl(1).tax_exempt_reason_code := p_attr_value;
1603     ELSIF p_attr_id = OE_Line_Util.G_TAX_POINT THEN
1604         x_line_tbl(1).tax_point_code := p_attr_value;
1605     ELSIF p_attr_id = OE_Line_Util.G_TAX_RATE THEN
1606         x_line_tbl(1).tax_rate := TO_NUMBER(p_attr_value);
1607     ELSIF p_attr_id = OE_Line_Util.G_TAX_VALUE THEN
1608         x_line_tbl(1).tax_value := TO_NUMBER(p_attr_value);
1609     ELSIF p_attr_id = OE_Line_Util.G_TOP_MODEL_LINE THEN
1610         x_line_tbl(1).top_model_line_id := TO_NUMBER(p_attr_value);
1611     ELSIF p_attr_id = OE_Line_Util.G_UNIT_LIST_PRICE THEN
1612         x_line_tbl(1).unit_list_price := TO_NUMBER(p_attr_value);
1613     ELSIF p_attr_id = OE_Line_Util.G_UNIT_LIST_PRICE_PER_PQTY THEN
1614         x_line_tbl(1).unit_list_price_per_pqty := TO_NUMBER(p_attr_value);
1615     ELSIF p_attr_id = OE_Line_Util.G_UNIT_SELLING_PRICE THEN
1616         x_line_tbl(1).unit_selling_price := FND_NUMBER.CANONICAL_TO_NUMBER(p_attr_value); -- bug 5179564
1617     ELSIF p_attr_id = OE_Line_Util.G_UNIT_SELLING_PRICE_PER_PQTY THEN
1618         x_line_tbl(1).unit_selling_price_per_pqty := FND_NUMBER.CANONICAL_TO_NUMBER(p_attr_value); -- bug 5179564
1619     ELSIF p_attr_id = OE_Line_Util.G_VISIBLE_DEMAND THEN
1620         x_line_tbl(1).visible_demand_flag := p_attr_value;
1621     ELSIF p_attr_id = OE_Line_Util.G_SPLIT_FROM_LINE THEN
1622         x_line_tbl(1).split_from_line_id := TO_NUMBER(p_attr_value);
1623     ELSIF p_attr_id = OE_Line_Util.G_CUST_PRODUCTION_SEQ_NUM THEN
1624         x_line_tbl(1).cust_production_seq_num := p_attr_value;
1625     ELSIF p_attr_id = OE_Line_Util.G_AUTHORIZED_TO_SHIP THEN
1626         x_line_tbl(1).authorized_to_ship_flag := p_attr_value;
1627     ELSIF p_attr_id = OE_Line_Util.G_VEH_CUS_ITEM_CUM_KEY THEN
1628         x_line_tbl(1).veh_cus_item_cum_key_id := TO_NUMBER(p_attr_value);
1629     ELSIF p_attr_id = OE_Line_Util.G_SALESREP THEN
1630         x_line_tbl(1).salesrep_id := TO_NUMBER(p_attr_value);
1631     ELSIF p_attr_id = OE_Line_Util.G_RETURN_REASON THEN
1632         x_line_tbl(1).return_reason_code := p_attr_value;
1633     ELSIF p_attr_id = OE_Line_Util.G_ARRIVAL_SET THEN
1634         x_line_tbl(1).arrival_set_id := TO_NUMBER(p_attr_value);
1635     --recurring charges
1636     ELSIF p_attr_id = OE_LINE_UTIL.G_CHARGE_PERIODICITY THEN
1637         x_line_tbl(1).charge_periodicity_code := p_attr_value;
1638     ELSIF p_attr_id = OE_Line_Util.G_ARRIVAL_SET_NAME THEN
1639     IF l_debug_level  > 0 THEN
1640         oe_debug_pub.add(  'RAJ CONTROLLER - ATTRIBUTE CHANGE'|| P_ATTR_VALUE ) ;
1641     END IF;
1642     IF p_attr_value IS NULL THEN
1643         x_line_tbl(1).arrival_set_id := NULL;
1644         x_line_tbl(1).arrival_set := p_attr_value;
1645        x_old_line_tbl(1).arrival_set := null;
1646     ELSE
1647         x_line_tbl(1).arrival_set := p_attr_value;
1648         x_line_tbl(1).arrival_set_id := NULL;
1649     END IF;
1650     ELSIF p_attr_id = OE_Line_Util.G_SHIP_SET THEN
1651         x_line_tbl(1).ship_set_id := TO_NUMBER(p_attr_value);
1652     ELSIF p_attr_id = OE_Line_Util.G_SHIP_SET_NAME THEN
1653     IF p_attr_value IS NULL THEN
1654         x_line_tbl(1).ship_set_id := NULL;
1655         x_line_tbl(1).ship_set := p_attr_value;
1656        x_old_line_tbl(1).ship_set := null;
1657     ELSE
1658         x_line_tbl(1).ship_set := p_attr_value;
1659         x_line_tbl(1).ship_set_id := NULL;
1660     END IF;
1661     ELSIF p_attr_id = OE_Line_Util.G_FULFILLMENT_SET THEN
1662         x_line_tbl(1).fulfillment_set := TO_NUMBER(p_attr_value);
1663     ELSIF p_attr_id = OE_Line_Util.G_FULFILLMENT_SET_NAME THEN
1664     IF p_attr_value IS NULL THEN
1665         x_line_tbl(1).fulfillment_set_id := NULL;
1666     ELSE
1667         x_line_tbl(1).fulfillment_set := p_attr_value;
1668         x_line_tbl(1).fulfillment_set_id := NULL;
1669     END IF;
1670     ELSIF p_attr_id = OE_Line_Util.G_OVER_SHIP_REASON THEN
1671         x_line_tbl(1).over_ship_reason_code := p_attr_value;
1672     ELSIF p_attr_id = OE_Line_Util.G_OVER_SHIP_RESOLVED THEN
1673         x_line_tbl(1).over_ship_resolved_flag := p_attr_value;
1674     ELSIF p_attr_id =    OE_Line_Util.G_FIRST_ACK THEN
1675         x_line_tbl(1).first_ack_code := p_attr_value;
1676     ELSIF p_attr_id =    OE_Line_Util.G_FIRST_ACK_DATE THEN
1677      --   x_line_tbl(1).first_ack_date := TO_DATE(p_attr_value, l_date_format_mask);
1678       x_line_tbl(1).first_ack_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
1679     ELSIF p_attr_id =    OE_Line_Util.G_LAST_ACK THEN
1680         x_line_tbl(1).last_ack_code := p_attr_value;
1681     ELSIF p_attr_id =    OE_Line_Util.G_LAST_ACK_DATE THEN
1682        -- x_line_tbl(1).last_ack_date := TO_DATE(p_attr_value, l_date_format_mask);
1683        x_line_tbl(1).last_ack_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
1684     ELSIF p_attr_id =    OE_Line_Util.G_END_ITEM_UNIT_NUMBER THEN
1685         x_line_tbl(1).end_item_unit_number := p_attr_value;
1686     ELSIF p_attr_id =    OE_Line_Util.G_SHIPPING_INSTRUCTIONS THEN
1687         x_line_tbl(1).shipping_instructions := p_attr_value;
1688     ELSIF p_attr_id =    OE_Line_Util.G_PACKING_INSTRUCTIONS THEN
1689         x_line_tbl(1).packing_instructions := p_attr_value;
1690     ELSIF p_attr_id =    OE_Line_Util.G_SERVICE_TXN_REASON THEN
1691         x_line_tbl(1).service_txn_reason_code := p_attr_value;
1692     ELSIF p_attr_id =    OE_Line_Util.G_SERVICE_TXN_COMMENTS THEN
1693         x_line_tbl(1).service_txn_comments := p_attr_value;
1694     ELSIF p_attr_id =    OE_Line_Util.G_SERVICE_DURATION THEN
1695         x_line_tbl(1).service_duration := TO_NUMBER(p_attr_value);
1696     ELSIF p_attr_id =    OE_Line_Util.G_SERVICE_PERIOD THEN
1697         x_line_tbl(1).service_period := p_attr_value;
1698     ELSIF p_attr_id =    OE_Line_Util.G_SERVICE_START_DATE THEN
1699       --  x_line_tbl(1).service_start_date := TO_DATE(p_attr_value, l_date_format_mask);
1700        x_line_tbl(1).service_start_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
1701     ELSIF p_attr_id =    OE_Line_Util.G_SERVICE_END_DATE THEN
1702       -- x_line_tbl(1).service_end_date := TO_DATE(p_attr_value, l_date_format_mask);
1703        x_line_tbl(1).service_end_date := fnd_date.string_TO_DATE(p_attr_value, l_date_format_mask); --bug5402396
1704     ELSIF p_attr_id =    OE_Line_Util.G_SERVICE_COTERMINATE_FLAG THEN
1705         x_line_tbl(1).service_coterminate_flag := p_attr_value;
1706     ELSIF p_attr_id =    OE_Line_Util.G_UNIT_SELLING_PERCENT THEN
1707         x_line_tbl(1).unit_selling_percent := TO_NUMBER(p_attr_value);
1708     ELSIF p_attr_id =    OE_Line_Util.G_UNIT_LIST_PERCENT THEN
1709         x_line_tbl(1).unit_list_percent := TO_NUMBER(p_attr_value);
1710     ELSIF p_attr_id =    OE_Line_Util.G_UNIT_PERCENT_BASE_PRICE THEN
1711         x_line_tbl(1).unit_percent_base_price := TO_NUMBER(p_attr_value);
1712     ELSIF p_attr_id =    OE_Line_Util.G_SERVICE_NUMBER THEN
1713         x_line_tbl(1).service_number := TO_NUMBER(p_attr_value);
1714     ELSIF p_attr_id = OE_Line_Util.G_Service_Reference_Type_Code THEN
1715         x_line_tbl(1).service_reference_type_code := p_attr_value;
1716     ELSIF p_attr_id = OE_Line_Util.G_Service_Reference_Line_Id THEN
1717         x_line_tbl(1).service_reference_line_id := TO_NUMBER(p_attr_value);
1718     ELSIF p_attr_id = OE_Line_Util.G_Service_Reference_System_Id THEN
1719         x_line_tbl(1).service_reference_system_id := TO_NUMBER(p_attr_value);
1720 	-- sol_ord_er #16014165
1721 	ELSIF p_attr_id =	OE_Line_Util.G_SERVICE_BILL_PROFILE_ID THEN
1722 		x_line_tbl(1).service_bill_profile_id := TO_NUMBER(p_attr_value);
1723 	ELSIF p_attr_id =	OE_Line_Util.G_SERVICE_COV_TEMPLATE_ID THEN
1724 		x_line_tbl(1).service_cov_template_id := TO_NUMBER(p_attr_value);
1725 	ELSIF p_attr_id =	OE_Line_Util.G_SERVICE_SUBS_TEMPLATE_ID THEN
1726 		x_line_tbl(1).service_subs_template_id := TO_NUMBER(p_attr_value);
1727 	ELSIF p_attr_id =	OE_Line_Util.G_SERVICE_BILL_OPTION_CODE THEN
1728 		x_line_tbl(1).service_bill_option_code := p_attr_value;
1729 	ELSIF p_attr_id =	OE_Line_Util.G_SUBSCRIPTION_ENABLE_FLAG THEN
1730 		x_line_tbl(1).subscription_enable_flag := p_attr_value;
1731 	-- sol_ord_er #16014165	end
1732     ELSIF p_attr_id = OE_Line_Util.G_CHANGE_REASON THEN
1733         x_line_tbl(1).change_reason := p_attr_value;
1734     ELSIF p_attr_id = OE_Line_Util.G_CHANGE_COMMENTS THEN
1735         x_line_tbl(1).change_comments := p_attr_value;
1736     ELSIF p_attr_id = OE_Line_Util.G_CALCULATE_PRICE_FLAG THEN
1737         x_line_tbl(1).calculate_price_flag := p_attr_value;
1738     ELSIF p_attr_id = OE_Line_Util.G_CUSTOMER_LINE_NUMBER THEN
1739         x_line_tbl(1).customer_line_number := p_attr_value;
1740     ELSIF p_attr_id = OE_Line_Util.G_CUSTOMER_SHIPMENT_NUMBER THEN
1741         x_line_tbl(1).customer_shipment_number := p_attr_value;
1742     ELSIF p_attr_id = OE_Line_Util.G_user_ITEM_DESCRIPTION THEN
1743         x_line_tbl(1).user_item_description := p_attr_value;
1744     ELSIF p_attr_id = OE_Line_Util.G_ATTRIBUTE1
1745     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE10
1746     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE11
1747     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE12
1748     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE13
1749     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE14
1750     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE15
1751     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE16   --For bug 2184255
1752     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE17
1753     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE18
1754     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE19
1755     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE2
1756     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE20
1757     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE3
1758     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE4
1759     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE5
1760     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE6
1761     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE7
1762     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE8
1763     OR     p_attr_id = OE_Line_Util.G_ATTRIBUTE9
1764     OR     p_attr_id = OE_Line_Util.G_CONTEXT
1765     THEN
1766 
1767         x_line_tbl(1).attribute1          := p_line_dff_rec.attribute1;
1768         x_line_tbl(1).attribute10         := p_line_dff_rec.attribute10;
1769         x_line_tbl(1).attribute11         := p_line_dff_rec.attribute11;
1770         x_line_tbl(1).attribute12         := p_line_dff_rec.attribute12;
1771         x_line_tbl(1).attribute13         := p_line_dff_rec.attribute13;
1772         x_line_tbl(1).attribute14         := p_line_dff_rec.attribute14;
1773         x_line_tbl(1).attribute15         := p_line_dff_rec.attribute15;
1774         x_line_tbl(1).attribute16         := p_line_dff_rec.attribute16;   --For bug 2184255
1775         x_line_tbl(1).attribute17         := p_line_dff_rec.attribute17;
1776         x_line_tbl(1).attribute18         := p_line_dff_rec.attribute18;
1777         x_line_tbl(1).attribute19         := p_line_dff_rec.attribute19;
1778         x_line_tbl(1).attribute2          := p_line_dff_rec.attribute2;
1779         x_line_tbl(1).attribute20         := p_line_dff_rec.attribute20;
1780         x_line_tbl(1).attribute3          := p_line_dff_rec.attribute3;
1781         x_line_tbl(1).attribute4          := p_line_dff_rec.attribute4;
1782         x_line_tbl(1).attribute5          := p_line_dff_rec.attribute5;
1783         x_line_tbl(1).attribute6          := p_line_dff_rec.attribute6;
1784         x_line_tbl(1).attribute7          := p_line_dff_rec.attribute7;
1785         x_line_tbl(1).attribute8          := p_line_dff_rec.attribute8;
1786         x_line_tbl(1).attribute9          := p_line_dff_rec.attribute9;
1787         x_line_tbl(1).context             := p_line_dff_rec.context;
1788 
1789     ELSIF p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE1
1790     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE10
1791     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE11
1792     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE12
1793     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE13
1794     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE14
1795     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE15
1796     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE16
1797     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE17
1798     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE18
1799     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE19
1800     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE2
1801     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE20
1802     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE3
1803     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE4
1804     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE5
1805     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE6
1806     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE7
1807     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE8
1808     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE9
1809     OR     p_attr_id = OE_Line_Util.G_GLOBAL_ATTRIBUTE_CATEGORY
1810     THEN
1811 
1812         x_line_tbl(1).global_attribute1   := p_line_dff_rec.global_attribute1;
1813         x_line_tbl(1).global_attribute10  := p_line_dff_rec.global_attribute10;
1814         x_line_tbl(1).global_attribute11  := p_line_dff_rec.global_attribute11;
1815         x_line_tbl(1).global_attribute12  := p_line_dff_rec.global_attribute12;
1816         x_line_tbl(1).global_attribute13  := p_line_dff_rec.global_attribute13;
1817         x_line_tbl(1).global_attribute14  := p_line_dff_rec.global_attribute14;
1818         x_line_tbl(1).global_attribute15  := p_line_dff_rec.global_attribute15;
1819         x_line_tbl(1).global_attribute16  := p_line_dff_rec.global_attribute16;
1820         x_line_tbl(1).global_attribute17  := p_line_dff_rec.global_attribute17;
1821         x_line_tbl(1).global_attribute18  := p_line_dff_rec.global_attribute18;
1822         x_line_tbl(1).global_attribute19  := p_line_dff_rec.global_attribute19;
1823         x_line_tbl(1).global_attribute2   := p_line_dff_rec.global_attribute2;
1824         x_line_tbl(1).global_attribute20  := p_line_dff_rec.global_attribute20;
1825         x_line_tbl(1).global_attribute3   := p_line_dff_rec.global_attribute3;
1826         x_line_tbl(1).global_attribute4   := p_line_dff_rec.global_attribute4;
1827         x_line_tbl(1).global_attribute5   := p_line_dff_rec.global_attribute5;
1828         x_line_tbl(1).global_attribute6   := p_line_dff_rec.global_attribute6;
1829         x_line_tbl(1).global_attribute7   := p_line_dff_rec.global_attribute7;
1830         x_line_tbl(1).global_attribute8   := p_line_dff_rec.global_attribute8;
1831         x_line_tbl(1).global_attribute9   := p_line_dff_rec.global_attribute9;
1832         x_line_tbl(1).global_attribute_category := p_line_dff_rec.global_attribute_category;
1833 
1834     ELSIF p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE1
1835     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE10
1836     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE11
1837     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE12
1838     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE13
1839     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE14
1840     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE15
1841     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE2
1842     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE3
1843     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE4
1844     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE5
1845     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE6
1846     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE7
1847     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE8
1848     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE9
1849     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE16
1850     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE17
1851     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE18
1852     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE19
1853     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE20
1854     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE21
1855     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE22
1856     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE23
1857     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE24
1858     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE25
1859     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE26
1860     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE27
1861     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE28
1862     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE29
1863     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_ATTRIBUTE30
1864     OR     p_attr_id = OE_Line_Util.G_INDUSTRY_CONTEXT
1865     THEN
1866 
1867         x_line_tbl(1).industry_attribute1 := p_line_dff_rec.industry_attribute1;
1868         x_line_tbl(1).industry_attribute10 := p_line_dff_rec.industry_attribute10;
1869         x_line_tbl(1).industry_attribute11 := p_line_dff_rec.industry_attribute11;
1870         x_line_tbl(1).industry_attribute12 := p_line_dff_rec.industry_attribute12;
1871         x_line_tbl(1).industry_attribute13 := p_line_dff_rec.industry_attribute13;
1872         x_line_tbl(1).industry_attribute14 := p_line_dff_rec.industry_attribute14;
1873         x_line_tbl(1).industry_attribute15 := p_line_dff_rec.industry_attribute15;
1874         x_line_tbl(1).industry_attribute2 := p_line_dff_rec.industry_attribute2;
1875         x_line_tbl(1).industry_attribute3 := p_line_dff_rec.industry_attribute3;
1876         x_line_tbl(1).industry_attribute4 := p_line_dff_rec.industry_attribute4;
1877         x_line_tbl(1).industry_attribute5 := p_line_dff_rec.industry_attribute5;
1878         x_line_tbl(1).industry_attribute6 := p_line_dff_rec.industry_attribute6;
1879         x_line_tbl(1).industry_attribute7 := p_line_dff_rec.industry_attribute7;
1880         x_line_tbl(1).industry_attribute8 := p_line_dff_rec.industry_attribute8;
1881         x_line_tbl(1).industry_attribute9 := p_line_dff_rec.industry_attribute9;
1882         x_line_tbl(1).industry_attribute16 := p_line_dff_rec.industry_attribute16;
1883         x_line_tbl(1).industry_attribute17 := p_line_dff_rec.industry_attribute17;
1884         x_line_tbl(1).industry_attribute18 := p_line_dff_rec.industry_attribute18;
1885         x_line_tbl(1).industry_attribute19 := p_line_dff_rec.industry_attribute19;
1886         x_line_tbl(1).industry_attribute20 := p_line_dff_rec.industry_attribute20;
1887         x_line_tbl(1).industry_attribute21 := p_line_dff_rec.industry_attribute21;
1888         x_line_tbl(1).industry_attribute22 := p_line_dff_rec.industry_attribute22;
1889         x_line_tbl(1).industry_attribute23 := p_line_dff_rec.industry_attribute23;
1890         x_line_tbl(1).industry_attribute24 := p_line_dff_rec.industry_attribute24;
1891         x_line_tbl(1).industry_attribute25 := p_line_dff_rec.industry_attribute25;
1892         x_line_tbl(1).industry_attribute26 := p_line_dff_rec.industry_attribute26;
1893         x_line_tbl(1).industry_attribute27 := p_line_dff_rec.industry_attribute27;
1894         x_line_tbl(1).industry_attribute28 := p_line_dff_rec.industry_attribute28;
1895         x_line_tbl(1).industry_attribute29 := p_line_dff_rec.industry_attribute29;
1896         x_line_tbl(1).industry_attribute30 := p_line_dff_rec.industry_attribute30;
1897         x_line_tbl(1).industry_context    := p_line_dff_rec.industry_context;
1898 
1899     ELSIF p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE1
1900     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE10
1901     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE2
1902     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE3
1903     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE4
1904     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE5
1905     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE6
1906     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE7
1907     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE8
1908     OR     p_attr_id = OE_Line_Util.G_PRICING_ATTRIBUTE9
1909     OR     p_attr_id = OE_Line_Util.G_PRICING_CONTEXT
1910     THEN
1911 
1912         x_line_tbl(1).pricing_attribute1  := p_line_dff_rec.pricing_attribute1;
1913         x_line_tbl(1).pricing_attribute10 := p_line_dff_rec.pricing_attribute10;
1914         x_line_tbl(1).pricing_attribute2  := p_line_dff_rec.pricing_attribute2;
1915         x_line_tbl(1).pricing_attribute3  := p_line_dff_rec.pricing_attribute3;
1916         x_line_tbl(1).pricing_attribute4  := p_line_dff_rec.pricing_attribute4;
1917         x_line_tbl(1).pricing_attribute5  := p_line_dff_rec.pricing_attribute5;
1918         x_line_tbl(1).pricing_attribute6  := p_line_dff_rec.pricing_attribute6;
1919         x_line_tbl(1).pricing_attribute7  := p_line_dff_rec.pricing_attribute7;
1920         x_line_tbl(1).pricing_attribute8  := p_line_dff_rec.pricing_attribute8;
1921         x_line_tbl(1).pricing_attribute9  := p_line_dff_rec.pricing_attribute9;
1922         x_line_tbl(1).pricing_context     := p_line_dff_rec.pricing_context;
1923     /* Amy Return, enable return attributes  */
1924     ELSIF p_attr_id = OE_Line_Util.G_RETURN_CONTEXT THEN
1925         x_line_tbl(1).return_context := p_attr_value;
1926         x_line_tbl(1).return_attribute1   := p_line_dff_rec.return_attribute1;
1927         x_line_tbl(1).return_attribute10  := p_line_dff_rec.return_attribute10;
1928         x_line_tbl(1).return_attribute11  := p_line_dff_rec.return_attribute11;
1929         x_line_tbl(1).return_attribute12  := p_line_dff_rec.return_attribute12;
1930         x_line_tbl(1).return_attribute13  := p_line_dff_rec.return_attribute13;
1931         x_line_tbl(1).return_attribute14  := p_line_dff_rec.return_attribute14;
1932         x_line_tbl(1).return_attribute15  := p_line_dff_rec.return_attribute15;
1933         x_line_tbl(1).return_attribute2  := p_line_dff_rec.return_attribute2;
1934         x_line_tbl(1).return_attribute3  := p_line_dff_rec.return_attribute3;
1935         x_line_tbl(1).return_attribute4  := p_line_dff_rec.return_attribute4;
1936         x_line_tbl(1).return_attribute5  := p_line_dff_rec.return_attribute5;
1937         x_line_tbl(1).return_attribute6  := p_line_dff_rec.return_attribute6;
1938         x_line_tbl(1).return_attribute7  := p_line_dff_rec.return_attribute7;
1939         x_line_tbl(1).return_attribute8  := p_line_dff_rec.return_attribute8;
1940         x_line_tbl(1).return_attribute9  := p_line_dff_rec.return_attribute9;
1941         x_line_tbl(1).line_category_code := OE_GLOBALS.G_RETURN_CATEGORY_CODE;
1942 
1943     ELSIF p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE1
1944     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE10
1945     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE11
1946     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE12
1947     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE13
1948     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE14
1949     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE15
1950     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE2
1951     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE3
1952     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE4
1953     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE5
1954     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE6
1955     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE7
1956     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE8
1957     OR     p_attr_id = OE_Line_Util.G_TP_ATTRIBUTE9
1958     OR     p_attr_id = OE_Line_Util.G_TP_CONTEXT
1959     THEN
1960         IF l_debug_level  > 0 THEN
1961             oe_debug_pub.add(  'JYOTHI: I AM IN CHANGE ATTRIBUTE' ) ;
1962         END IF;
1963 
1964         x_line_tbl(1).tp_attribute1          := p_line_dff_rec.tp_attribute1;
1965         x_line_tbl(1).tp_attribute10         := p_line_dff_rec.tp_attribute10;
1966         x_line_tbl(1).tp_attribute11         := p_line_dff_rec.tp_attribute11;
1967         x_line_tbl(1).tp_attribute12         := p_line_dff_rec.tp_attribute12;
1968         x_line_tbl(1).tp_attribute13         := p_line_dff_rec.tp_attribute13;
1969         x_line_tbl(1).tp_attribute14         := p_line_dff_rec.tp_attribute14;
1970         x_line_tbl(1).tp_attribute15         := p_line_dff_rec.tp_attribute15;
1971         x_line_tbl(1).tp_attribute2          := p_line_dff_rec.tp_attribute2;
1972         x_line_tbl(1).tp_attribute3          := p_line_dff_rec.tp_attribute3;
1973         x_line_tbl(1).tp_attribute4          := p_line_dff_rec.tp_attribute4;
1974         x_line_tbl(1).tp_attribute5          := p_line_dff_rec.tp_attribute5;
1975         x_line_tbl(1).tp_attribute6          := p_line_dff_rec.tp_attribute6;
1976         x_line_tbl(1).tp_attribute7          := p_line_dff_rec.tp_attribute7;
1977         x_line_tbl(1).tp_attribute8          := p_line_dff_rec.tp_attribute8;
1978         x_line_tbl(1).tp_attribute9          := p_line_dff_rec.tp_attribute9;
1979         x_line_tbl(1).tp_context          := p_line_dff_rec.tp_context;
1980 
1981         IF l_debug_level  > 0 THEN
1982             oe_debug_pub.add(  'JYOTHI- TP ATTRIBUTE IS ' || X_LINE_TBL ( 1 ) .TP_ATTRIBUTE1 ) ;
1983         END IF;
1984     ELSIF p_attr_id = OE_Line_Util.G_COMMITMENT THEN
1985         x_line_tbl(1).commitment_id := TO_NUMBER(p_attr_value);
1986     --MRG BGN
1987     ELSIF p_attr_id = OE_LINE_UTIL.G_UNIT_COST Then
1988         IF l_debug_level  > 0 THEN
1989             oe_debug_pub.add(  'P_ATTR_VALUE='||P_ATTR_VALUE ) ;
1990         END IF;
1991         x_line_tbl(1).unit_cost := TO_NUMBER(p_attr_value);
1992         IF l_debug_level  > 0 THEN
1993             oe_debug_pub.add(  'FLINB:UNIT_COST:'||P_ATTR_VALUE ) ;
1994         END IF;
1995     --MRG END
1996     -- INVCONV
1997      ELSIF p_attr_id = OE_Line_Util.G_CANCELLED_QUANTITY2 THEN
1998         x_line_tbl(1).cancelled_quantity2 := TO_NUMBER(p_attr_value);
1999     ELSIF p_attr_id = OE_Line_Util.G_FULFILLED_QUANTITY2 THEN
2000         x_line_tbl(1).fulfilled_quantity2 := TO_NUMBER(p_attr_value);
2001     ELSIF p_attr_id = OE_Line_Util.G_SHIPPED_QUANTITY2 THEN
2002         x_line_tbl(1).shipped_quantity2 := TO_NUMBER(p_attr_value);
2003     ELSIF p_attr_id = OE_Line_Util.G_SHIPPING_QUANTITY2 THEN
2004         x_line_tbl(1).shipping_quantity2 := TO_NUMBER(p_attr_value);
2005     ELSIF p_attr_id = OE_Line_Util.G_SHIPPING_QUANTITY_UOM2 THEN
2006         x_line_tbl(1).shipping_quantity_uom2 := p_attr_value;
2007     ELSIF p_attr_id = OE_Line_Util.G_RESERVED_QUANTITY2 THEN
2008         x_line_tbl(1).reserved_quantity2 := p_attr_value;
2009 
2010     -- INVCONV
2011     ELSE
2012 
2013         IF l_debug_level  > 0 THEN
2014             oe_debug_pub.add(  'UNRECOGNIZED ATTRIBUTE EXCEPTION' , 2 ) ;
2015         END IF;
2016 
2017         --  Unexpected error, unrecognized attribute
2018 
2019         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
2020         THEN
2021             oe_msg_pub.Add_Exc_Msg
2022             (   G_PKG_NAME
2023             ,   'Change_Attribute'
2024             ,   'Unrecognized attribute'
2025             );
2026         END IF;
2027 
2028         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2029 
2030     END IF;
2031 
2032     -- PLEASE ADD THE ABOVE IF LOGIC FOR NEW ATTRIBUTES TO THE PROCEDURE
2033     -- COPY_ATTRIBUTE_TO_REC ALSO. THIS NEW PROCEDURE WILL REPLACE
2034     -- THESE IF CALLS POST OM PACK I OR 11.5.9.
2035 
2036     END IF; -- End if code release >= 11.5.9
2037 
2038     --  Set Operation.
2039 
2040     IF l_debug_level  > 0 THEN
2041         oe_debug_pub.add(  'SETTING OPERATION' , 2 ) ;
2042     END IF;
2043 
2044     IF FND_API.To_Boolean(x_line_tbl(1).db_flag) THEN
2045         x_line_tbl(1).operation := OE_GLOBALS.G_OPR_UPDATE;
2046     ELSE
2047         x_line_tbl(1).operation := OE_GLOBALS.G_OPR_CREATE;
2048     END IF;
2049 
2050     --  Populate line table
2051     --  Validate Scheduling Dates Changes, if any.
2052 
2053     IF NVL(x_line_tbl(1).source_type_code,OE_GLOBALS.G_SOURCE_INTERNAL)
2054                = OE_GLOBALS.G_SOURCE_INTERNAL THEN
2055     IF NOT OE_GLOBALS.Equal(x_line_tbl(1).schedule_ship_date,
2056                             x_old_line_tbl(1).schedule_ship_date)
2057     THEN
2058        -- If the Order Type is ARRIVAL, the user is not
2059        -- allowed to change the schedule ship date
2060 
2061        l_order_date_type_code    := Get_Date_Type(x_line_tbl(1).header_id);
2062 
2063        IF nvl(l_order_date_type_code,'SHIP') = 'ARRIVAL' THEN
2064 
2065           FND_MESSAGE.SET_NAME('ONT','OE_SCH_INV_SHP_DATE');
2066           OE_MSG_PUB.Add;
2067 
2068           l_return_status := FND_API.G_RET_STS_ERROR;
2069 
2070        END IF;
2071 
2072        IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2073            IF l_debug_level  > 0 THEN
2074                oe_debug_pub.add(  'DATE TYPE RETURNED UNEXP_ERROR' , 2 ) ;
2075            END IF;
2076            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2077        ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2078            IF l_debug_level  > 0 THEN
2079                oe_debug_pub.add(  'DATE TYPE RETURN RET_STS_ERROR' , 2 ) ;
2080            END IF;
2081            RAISE FND_API.G_EXC_ERROR;
2082        END IF;
2083 
2084     END IF;
2085 
2086     IF NOT OE_GLOBALS.Equal(x_line_tbl(1).schedule_arrival_date,
2087                             x_old_line_tbl(1).schedule_arrival_date)
2088     THEN
2089 
2090        -- If the Order Type is SHIP (or null), the user is not
2091        -- allowed to change the schedule arrival date
2092 
2093        l_order_date_type_code    := Get_Date_Type(x_line_tbl(1).header_id);
2094 
2095        IF nvl(l_order_date_type_code,'SHIP') = 'SHIP' THEN
2096 
2097           FND_MESSAGE.SET_NAME('ONT','OE_SCH_INV_ARR_DATE');
2098           OE_MSG_PUB.Add;
2099 
2100           l_return_status := FND_API.G_RET_STS_ERROR;
2101 
2102        END IF;
2103 
2104        IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2105            IF l_debug_level  > 0 THEN
2106                oe_debug_pub.add(  'DATE TYPE RETURNED UNEXP_ERROR' , 2 ) ;
2107            END IF;
2108            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2109        ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2110            IF l_debug_level  > 0 THEN
2111                oe_debug_pub.add(  'DATE TYPE RETURN RET_STS_ERROR' , 2 ) ;
2112            END IF;
2113            RAISE FND_API.G_EXC_ERROR;
2114        END IF;
2115 
2116     END IF;
2117     END IF;
2118     -- start for 3998402
2119     IF (NVL(x_line_tbl(1).source_type_code,OE_GLOBALS.G_SOURCE_INTERNAL)
2120                                                       = OE_GLOBALS.G_SOURCE_EXTERNAL
2121        AND (x_line_tbl(1).ship_set_id is not null
2122             OR x_line_tbl(1).arrival_set_id is not null)) THEN
2123       IF l_debug_level  > 0 THEN
2124          oe_debug_pub.add('Cannot change source type',2);
2125       END IF;
2126       FND_MESSAGE.SET_NAME('ONT','ONT_CANT_CHG_SRC_TYPE');
2127       OE_MSG_PUB.Add;
2128       l_return_status := FND_API.G_RET_STS_ERROR;
2129       RAISE FND_API.G_EXC_ERROR;
2130     END IF;
2131     -- end for 3998402
2132 --Start for bug16574638
2133     IF x_line_tbl(1).line_category_code = OE_GLOBALS.G_RETURN_CATEGORY_CODE
2134     THEN
2135        IF NOT OE_GLOBALS.Equal(x_line_tbl(1).return_context, x_old_line_tbl(1).return_context) OR
2136           NOT OE_GLOBALS.Equal(x_line_tbl(1).return_attribute1, x_old_line_tbl(1).return_attribute1) OR
2137           NOT OE_GLOBALS.Equal(x_line_tbl(1).return_attribute2, x_old_line_tbl(1).return_attribute2)
2138        THEN
2139          Get_return_reference(x_line_tbl(1).line_id, l_return_context, l_return_attrib1, l_return_attrib2);
2140 
2141          IF (NOT OE_GLOBALS.Equal(x_line_tbl(1).return_context, l_return_context) OR
2142              NOT OE_GLOBALS.Equal(x_line_tbl(1).return_attribute1, l_return_attrib1) OR
2143              NOT OE_GLOBALS.Equal(x_line_tbl(1).return_attribute2, l_return_attrib2))
2144              AND  Nvl(x_line_tbl(1).shipped_quantity,0) > 0
2145          THEN
2146              IF l_debug_level  > 0 THEN
2147                 oe_debug_pub.add('Cannot change reference details',2);
2148               END IF;
2149              FND_MESSAGE.SET_NAME('ONT','OE_RMA_RECEIVED');
2150              OE_MSG_PUB.Add;
2151              l_return_status := FND_API.G_RET_STS_ERROR;
2152              RAISE FND_API.G_EXC_ERROR;
2153          END IF;
2154        END IF;
2155     END IF;
2156 --End for bug 16574638
2157     IF l_debug_level  > 0 THEN
2158         oe_debug_pub.add(  'CALLING PROCESS ORDER' , 2 ) ;
2159         oe_debug_pub.add(  'BEFORE CALLING PROCESS ORDER' , 1 ) ;
2160     END IF;
2161 
2162     --  Call Oe_Order_Pvt.Process_order
2163     Oe_Order_Pvt.Lines
2164     (
2165         p_validation_level            => FND_API.G_VALID_LEVEL_NONE
2166     ,   p_init_msg_list               => FND_API.G_TRUE
2167     ,   p_control_rec                 => l_control_rec
2168     ,   p_x_line_tbl                  => x_line_tbl
2169     ,   p_x_old_line_tbl              => x_old_line_tbl
2170     ,   x_return_status               => l_return_status
2171     );
2172 
2173     IF l_debug_level  > 0 THEN
2174         oe_debug_pub.add(  'AFTER CALLING PROCESS ORDER' , 1 ) ;
2175     END IF;
2176     --bug 2438466 begin
2177     IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN -- Fix for bug3546224
2178         IF p_attr_id = OE_Line_Util.G_RETURN_CONTEXT THEN
2179             OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
2180             (p_request_type   =>OE_GLOBALS.G_COPY_ADJUSTMENTS
2181             ,p_delete        => FND_API.G_TRUE
2182             ,x_return_status => l_return_status
2183             );
2184         END IF;
2185     END IF;
2186     --bug 2438466 end
2187 
2188     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2189         IF l_debug_level  > 0 THEN
2190             oe_debug_pub.add(  'PROCESS ORDER RETURN UNEXP_ERROR' , 2 ) ;
2191         END IF;
2192         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2193     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2194         IF l_debug_level  > 0 THEN
2195             oe_debug_pub.add(  'PROCESS ORDER RETURN RET_STS_ERROR' , 2 ) ;
2196         END IF;
2197         RAISE FND_API.G_EXC_ERROR;
2198     END IF;
2199 
2200 
2201     --  Unload OUT tbl
2202 
2203 
2204     --  Init OUT parameters to missing.
2205 
2206     --  Load display OUT parameters if any
2207 
2208      x_line_val_tbl(1):=OE_Line_Util.Get_Values
2209     (   p_line_rec                    => x_line_tbl(1)
2210     ,   p_old_line_rec                => x_old_line_tbl(1)
2211     );
2212 
2213 -- OPM 02/JUN/00 - Load process control attributes
2214     l_x_item_rec_type                   := OE_Order_Cache.Load_Item
2215                                          (x_line_tbl(1).inventory_item_id
2216                                          ,x_line_tbl(1).ship_from_org_id
2217                                          );
2218 
2219 --    x_dualum_ind              := l_x_item_rec_type.dualum_ind; INVCONV
2220 --    x_grade_ctl               := l_x_item_rec_type.grade_ctl;  INVCONV
2221     x_process_warehouse_flag  := l_x_item_rec_type.process_warehouse_flag;
2222     x_ont_pricing_qty_source  := l_x_item_rec_type.ont_pricing_qty_source; -- OPM 2046190
2223     x_grade_control_flag      := l_x_item_rec_type.grade_control_flag;  -- INVCONV
2224     x_tracking_quantity_ind  := l_x_item_rec_type.tracking_quantity_ind;  -- INVCONV
2225     x_secondary_default_ind := l_x_item_rec_type.secondary_default_ind; -- INVCONV
2226       x_lot_control_code      := l_x_item_rec_type.lot_control_code; -- 4172680 INVCONV
2227       x_lot_divisible_flag := l_x_item_rec_type.lot_divisible_flag; -- INVCONV
2228 
2229     --  Write to cache.
2230     IF l_debug_level  > 0 THEN
2231         oe_debug_pub.add(  'WRITING TO CACHE' , 2 ) ;
2232     END IF;
2233 
2234     Write_line
2235     (   p_line_rec                    => x_line_tbl(1)
2236     );
2237 
2238     -- Re-set the UI flag to FALSE
2239     OE_GLOBALS.G_UI_FLAG := FALSE;
2240 
2241     --  Set return status.
2242 
2243     x_return_status := FND_API.G_RET_STS_SUCCESS;
2244 
2245     --  Get message count and data
2246 
2247     oe_msg_pub.count_and_get
2248     (   p_count                       => x_msg_count
2249     ,   p_data                        => x_msg_data
2250     );
2251 
2252     IF l_debug_level  > 0 THEN
2253         oe_debug_pub.add(  'EXITING OE_OE_FORM_LINE.CHANGE_ATTRIBUTE' , 1 ) ;
2254     END IF;
2255 
2256 EXCEPTION
2257 
2258     WHEN FND_API.G_EXC_ERROR THEN
2259 
2260        OE_GLOBALS.G_UI_FLAG := FALSE;
2261 
2262         x_return_status := FND_API.G_RET_STS_ERROR;
2263 
2264         --  Get message count and data
2265 
2266         oe_msg_pub.count_and_get
2267         (   p_count                       => x_msg_count
2268         ,   p_data                        => x_msg_data
2269         );
2270 
2271     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2272 
2273        OE_GLOBALS.G_UI_FLAG := FALSE;
2274 
2275         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2276 
2277         --  Get message count and data
2278 
2279         oe_msg_pub.count_and_get
2280         (   p_count                       => x_msg_count
2281         ,   p_data                        => x_msg_data
2282         );
2283 
2284     WHEN OTHERS THEN
2285 
2286        OE_GLOBALS.G_UI_FLAG := FALSE;
2287 
2288         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2289 
2290         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
2291         THEN
2292             oe_msg_pub.Add_Exc_Msg
2293             (   G_PKG_NAME
2294             ,   'Change_Attribute'
2295             );
2296         END IF;
2297 
2298         --  Get message count and data
2299 
2300         oe_msg_pub.count_and_get
2301         (   p_count                       => x_msg_count
2302         ,   p_data                        => x_msg_data
2303         );
2304 
2305 END Change_Attribute;
2306 
2307 
2308 --  Procedure       Validate_And_Write
2309 --
2310 -- 2806483  All OUT parameters are replaced by validate_write_rec_type
2311 PROCEDURE Validate_And_Write
2312 (x_return_status                  OUT NOCOPY VARCHAR2
2313 , x_msg_count                     OUT NOCOPY NUMBER
2314 , x_msg_data                      OUT NOCOPY VARCHAR2
2315 , x_cascade_flag                  OUT NOCOPY BOOLEAN
2316 , p_line_id                       IN  NUMBER
2317 , p_change_reason_code            IN  VARCHAR2
2318 , p_change_comments               IN  VARCHAR2
2319 , x_line_val_rec                  OUT NOCOPY validate_write_rec_type
2320 )
2321 IS
2322 l_x_line_rec       OE_Order_PUB.Line_Rec_Type;
2323 l_x_line_tbl       OE_Order_PUB.Line_Tbl_Type;
2324 l_x_old_line_tbl   OE_Order_PUB.Line_Tbl_Type;
2325 l_control_rec      OE_GLOBALS.Control_Rec_Type;
2326 l_return_status    VARCHAR2(1);
2327 l_charge_amount    NUMBER := 0.0;
2328 l_last_index       NUMBER;
2329 l_organization_id  NUMBER:= OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');
2330 l_set_rec                     OE_ORDER_CACHE.set_rec_type; -- 2806483
2331 --
2332 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2333 --
2334 BEGIN
2335 
2336    SAVEPOINT Line_Validate_And_Write;
2337 
2338     IF l_debug_level  > 0 THEN
2339         oe_debug_pub.add(  'ENTERING OE_OE_FORM_LINE.VALIDATE_AND_WRITE' , 1 ) ;
2340     END IF;
2341 
2342     -- Set UI flag to TRUE
2343     OE_GLOBALS.G_UI_FLAG := TRUE;
2344 
2345     --  Set control flags.
2346 
2347     l_control_rec.controlled_operation := TRUE;
2348     l_control_rec.validate_entity      := TRUE;
2349     l_control_rec.write_to_DB          := TRUE;
2350 
2351     l_control_rec.check_security        := FALSE;
2352     l_control_rec.clear_dependents     := FALSE;
2353     l_control_rec.default_attributes   := FALSE;
2354     l_control_rec.change_attributes    := FALSE;
2355     l_control_rec.process              := FALSE;
2356 
2357     --  Instruct API to retain its caches
2358 
2359     l_control_rec.clear_api_cache      := FALSE;
2360     l_control_rec.clear_api_requests   := FALSE;
2361 
2362     --  Read line from cache
2363 
2364     Get_line
2365     (   p_db_record                   => TRUE
2366     ,   p_line_id                     => p_line_id
2367     ,   x_line_rec                    => l_x_old_line_tbl(1)
2368     );
2369 
2370     Get_line
2371     (   p_db_record                   => FALSE
2372     ,   p_line_id                     => p_line_id
2373     ,   x_line_rec                    => l_x_line_tbl(1)
2374     );
2375 
2376     /* Start Audit Trail -- pass change reason, comments */
2377 
2378     l_x_line_tbl(1).change_reason := p_change_reason_code;
2379     l_x_line_tbl(1).change_comments := p_change_comments;
2380 
2381     /* End Audit Trail */
2382 
2383     --  Set Operation.
2384 
2385     IF FND_API.To_Boolean(l_x_line_tbl(1).db_flag) THEN
2386         l_x_line_tbl(1).operation := OE_GLOBALS.G_OPR_UPDATE;
2387     ELSE
2388         l_x_line_tbl(1).operation := OE_GLOBALS.G_OPR_CREATE;
2389 
2390         /* We are passing the miss quantity for reserved filed
2391         since we are not converting this to null in OE_LINE_UTIL_EXT' */
2392         l_x_old_line_tbl(1).reserved_quantity := FND_API.G_MISS_NUM;
2393 
2394     END IF;
2395 
2396     --  Populate line table
2397 
2398 
2399 
2400     --  Call Oe_Order_Pvt.Process_order
2401 
2402     IF l_debug_level  > 0 THEN
2403         oe_debug_pub.add(  'IN VALIDATE_AND_WRITE' ) ;
2404     END IF;
2405         oe_debug_pub.add(  'IN VALIDATE_AND_WRITE Change Reason'||p_change_reason_code ) ;
2406     Oe_Order_Pvt.Lines
2407     (   p_validation_level              => FND_API.G_VALID_LEVEL_NONE
2408     ,   p_init_msg_list                 => FND_API.G_TRUE
2409     ,   p_control_rec                   =>   l_control_rec
2410     ,   p_x_line_tbl                    => l_x_line_tbl
2411     ,   p_x_old_line_tbl                => l_x_old_line_tbl
2412     ,   x_return_Status                 => l_return_status
2413     );
2414 
2415     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2416         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2417     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2418         RAISE FND_API.G_EXC_ERROR;
2419     END IF;
2420 
2421  /* The Process Requests and Notify should be invoked for */
2422  /* Pre-Pack H code level */
2423 
2424     IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL < '110508' THEN
2425     Oe_Order_Pvt.Process_Requests_And_Notify
2426     (   p_process_requests           => FALSE
2427     ,   p_init_msg_list              => FND_API.G_FALSE
2428     ,   p_notify                     => TRUE
2429     ,   x_return_status              => l_return_status
2430     ,   p_line_tbl                   => l_x_line_tbl
2431     ,   p_old_line_tbl               => l_x_old_line_tbl
2432     );
2433 
2434     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2435         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2436     ELSIF l_return_status  = FND_API.G_RET_STS_ERROR THEN
2437         RAISE FND_API.G_EXC_ERROR;
2438     END IF;
2439 
2440    END IF;
2441 
2442     -- bug 1834260, process delayed request for G_COPY_ADJUSTMENTS
2443     -- before processing for G_PRICE_LINE.
2444    IF OE_GLOBALS.G_DEFER_PRICING='N' THEN
2445     OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
2446          (p_request_type   =>OE_GLOBALS.G_COPY_ADJUSTMENTS
2447           ,p_delete        => FND_API.G_TRUE
2448           ,x_return_status => l_return_status
2449           );
2450     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2451           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2452     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2453           RAISE FND_API.G_EXC_ERROR;
2454     END IF;
2455    END IF;
2456 
2457    IF OE_GLOBALS.G_DEFER_PRICING='N' THEN
2458     OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
2459          (p_request_type   =>OE_GLOBALS.G_PRICE_LINE
2460           ,p_delete        => FND_API.G_TRUE
2461           ,x_return_status => l_return_status
2462           );
2463     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2464           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2465     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2466           RAISE FND_API.G_EXC_ERROR;
2467     END IF;
2468    END IF;
2469 
2470    IF OE_GLOBALS.G_DEFER_PRICING='N' THEN
2471 
2472     IF nvl(FND_PROFILE.VALUE('ONT_DELAY_TAX_CALC'), 'N') = 'N' THEN --TaxER
2473      OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
2474          (p_request_type   =>OE_GLOBALS.G_TAX_LINE
2475           ,p_delete        => FND_API.G_TRUE
2476           ,x_return_status => l_return_status
2477           );
2478     END IF; --TaxER
2479 
2480     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2481           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2482     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2483           RAISE FND_API.G_EXC_ERROR;
2484     END IF;
2485    END IF;
2486 
2487     -- lkxu, commitment enhancement
2488     IF l_debug_level  > 0 THEN
2489         oe_debug_pub.add(  'CALLING TO PROCESS DELAYED REQUEST FOR COMMITMENT!' , 1 ) ;
2490     END IF;
2491 
2492    IF OE_GLOBALS.G_DEFER_PRICING='N' THEN
2493     OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
2494          (p_request_type   =>OE_GLOBALS.G_CALCULATE_COMMITMENT
2495           ,p_delete        => FND_API.G_TRUE
2496           ,x_return_status => l_return_status
2497           );
2498     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2499           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2500     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2501           RAISE FND_API.G_EXC_ERROR;
2502     END IF;
2503 
2504     --bug 3560198
2505     OE_DELAYED_REQUESTS_PVT.Process_Request_for_Reqtype
2506          (p_request_type   =>OE_GLOBALS.G_UPDATE_COMMITMENT_APPLIED
2507           ,p_delete        => FND_API.G_TRUE
2508           ,x_return_status => l_return_status
2509           );
2510     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2511           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2512     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2513           RAISE FND_API.G_EXC_ERROR;
2514     END IF;
2515     --bug 3560198
2516    END IF;
2517 
2518     x_cascade_flag := OE_GLOBALS.G_CASCADING_REQUEST_LOGGED;
2519 
2520    --fix for bug 4102372
2521    -- x_line_val_rec.x_lock_control:=l_x_line_tbl(1).lock_control;
2522 
2523     --  Load OUT parameters.
2524 
2525       oe_line_util.query_row(
2526                                    p_line_id  =>l_x_line_tbl(1).line_id
2527                                    ,x_line_rec=>l_x_line_rec
2528                                            );
2529     x_line_val_rec.x_lock_control     :=l_x_line_rec.lock_control;
2530     x_line_val_rec.x_creation_date    := l_x_line_rec.creation_date;
2531     x_line_val_rec.x_created_by                   := l_x_line_rec.created_by;
2532     x_line_val_rec.x_last_update_date             := l_x_line_rec.last_update_date;
2533     x_line_val_rec.x_last_updated_by              := l_x_line_rec.last_updated_by;
2534     x_line_val_rec.x_last_update_login            := l_x_line_rec.last_update_login;
2535 
2536 --  Loading Scheduling attributes
2537 
2538     x_line_val_rec.x_schedule_ship_date           := l_x_line_rec.schedule_ship_date;
2539     x_line_val_rec.x_schedule_arrival_date        := l_x_line_rec.schedule_arrival_date;
2540     x_line_val_rec.x_schedule_status_code         := l_x_line_rec.schedule_status_code;
2541     x_line_val_rec.x_schedule_action_code         := l_x_line_rec.schedule_action_code;
2542     x_line_val_rec.x_earliest_ship_date           := l_x_line_rec.earliest_ship_date;
2543     x_line_val_rec.x_firm_demand_flag             := l_x_line_rec.firm_demand_flag;
2544 
2545 -- Loading Item substitution attributes.
2546 
2547     x_line_val_rec.x_original_inventory_item_id
2548                              := l_x_line_rec.original_inventory_item_id;
2549     x_line_val_rec.x_original_item_iden_type
2550                              := l_x_line_rec.original_item_identifier_type;
2551     x_line_val_rec.x_original_ordered_item_id
2552                              := l_x_line_rec.original_ordered_item_id;
2553 
2554     IF x_line_val_rec.x_original_inventory_item_id IS NOT NULL
2555     OR x_line_val_rec.x_original_ordered_item_id   IS NOT NULL THEN
2556       OE_ID_TO_VALUE.Ordered_Item
2557       (p_Item_Identifier_type    => x_line_val_rec.x_original_item_iden_type
2558       ,p_inventory_item_id       => x_line_val_rec.x_original_inventory_item_id
2559       ,p_organization_id         => l_organization_id
2560       ,p_ordered_item_id         => x_line_val_rec.x_original_ordered_item_id
2561       ,p_sold_to_org_id          => l_x_line_rec.sold_to_org_id
2562       ,p_ordered_item            => l_x_line_rec.original_ordered_item
2563       ,x_ordered_item            => x_line_val_rec.x_original_ordered_item
2564       ,x_inventory_item          => x_line_val_rec.x_original_inventory_item);
2565 
2566     END IF;
2567     IF x_line_val_rec.x_original_item_iden_type IS NOT NULL THEN
2568       OE_ID_TO_VALUE.item_identifier
2569       (p_Item_Identifier_type   => x_line_val_rec.x_original_item_iden_type
2570       ,x_Item_Identifier        => x_line_val_rec.x_original_item_type);
2571     END IF;
2572 
2573     -- Update Late Demand Penalty Factor Bug-2478107
2574     x_line_val_rec.x_late_demand_penalty_factor := l_x_line_rec.late_demand_penalty_factor;
2575 
2576      -- Update Override ATP Flag
2577     x_line_val_rec.x_override_atp_date_code := l_x_line_rec.override_atp_date_code;
2578 
2579 /* The following IF statement is commented to fix bug#1382357 */
2580 --    IF NVL(l_x_old_line_tbl(1).ship_from_org_id,-1) <>
2581 --               NVL(l_x_line_rec.ship_from_org_id,-1) THEN
2582 
2583        OE_ID_TO_VALUE.Ship_From_Org(
2584                     p_ship_from_org_id   => l_x_line_rec.ship_from_org_id
2585                    ,x_ship_from_address1 => x_line_val_rec.x_ship_from_address1
2586                    ,x_ship_from_address2 => x_line_val_rec.x_ship_from_address2
2587                    ,x_ship_from_address3 => x_line_val_rec.x_ship_from_address3
2588                    ,x_ship_from_address4 => x_line_val_rec.x_ship_from_address4
2589                    ,x_ship_from_location => x_line_val_rec.x_ship_from_location
2590                    ,x_ship_from_org      => x_line_val_rec.x_ship_from_org
2591                    );
2592 
2593  --   END IF;
2594 
2595     x_line_val_rec.x_ship_from_org_id := l_x_line_rec.ship_from_org_id;
2596     x_line_val_rec.x_subinventory     := l_x_line_rec.subinventory;
2597     x_line_val_rec.x_promise_date     := l_x_line_rec.promise_date;
2598     -- Start 2806483
2599     x_line_val_rec.x_shipping_method_code
2600                       := l_x_line_rec.shipping_method_code;
2601     IF x_line_val_rec.x_shipping_method_code IS NOT NULL THEN
2602        x_line_val_rec.x_shipping_method
2603           := OE_ID_TO_VALUE.Ship_Method(p_ship_method_code => x_line_val_rec.x_shipping_method_code);
2604     END IF;
2605     x_line_val_rec.x_freight_carrier_code
2606                       := l_x_line_rec.freight_carrier_code;
2607     IF x_line_val_rec.x_freight_carrier_code IS NOT NULL THEN
2608        x_line_val_rec.x_freight_carrier
2609           := OE_ID_TO_VALUE.Freight_Carrier
2610                        (p_freight_carrier_code =>x_line_val_rec.x_freight_carrier_code,
2611                         p_ship_from_org_id     =>x_line_val_rec.x_ship_from_org_id);
2612     END IF;
2613     -- End 2806483
2614     -- 2817915
2615     IF l_x_line_rec.ship_set_id IS NOT NULL THEN
2616        l_set_rec := OE_ORDER_CACHE.Load_Set(l_x_line_rec.ship_set_id);
2617        x_line_val_rec.x_ship_set_id := l_x_line_rec.ship_set_id;
2618        x_line_val_rec.x_ship_set    := l_set_rec.set_name;
2619     ELSIF l_x_line_rec.arrival_set_id IS NOT NULL THEN
2620        l_set_rec := OE_ORDER_CACHE.Load_Set(l_x_line_rec.arrival_set_id);
2621        x_line_val_rec.x_arrival_set_id := l_x_line_rec.arrival_set_id;
2622        x_line_val_rec.x_arrival_set    := l_set_rec.set_name;
2623     END IF;
2624     -- 2817915
2625 
2626     IF l_debug_level  > 0 THEN
2627         oe_debug_pub.add(  'ARRIVALSET-'|| TO_CHAR ( L_X_LINE_REC.ARRIVAL_SET_ID ) , 2 ) ;
2628     END IF;
2629    -- Calculate Tax
2630 
2631     x_line_val_rec.x_line_tax_value := l_x_line_rec.tax_value;
2632 
2633    IF l_debug_level  > 0 THEN
2634        oe_debug_pub.add(  'TAX VALUE IS'|| TO_CHAR ( L_X_LINE_REC.TAX_VALUE ) , 1 ) ;
2635        oe_debug_pub.add(  'CALLING ORDER TOTAL' , 2 ) ;
2636    END IF;
2637 
2638     -- Call the charges API to get the Line level charges.
2639    IF OE_GLOBALS.G_DEFER_PRICING='N' THEN
2640     OE_CHARGE_PVT.Get_Charge_Amount(
2641                            p_api_version_number => 1.1 ,
2642                            p_init_msg_list      => FND_API.G_FALSE ,
2643                            p_header_id          => l_x_line_rec.header_id ,
2644                            p_line_id            => l_x_line_rec.line_id ,
2645                            p_all_charges        => FND_API.G_FALSE ,
2646                            x_return_status      => l_return_status ,
2647                            x_msg_count          => x_msg_count ,
2648                            x_msg_data           => x_msg_data ,
2649                            x_charge_amount      => l_charge_amount );
2650 
2651      IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2652                  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2653      ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2654                  RAISE FND_API.G_EXC_ERROR;
2655      END IF;
2656      x_line_val_rec.x_charges := l_charge_amount;
2657    END IF;
2658 
2659     -- Update pricing details
2660     x_line_val_rec.x_unit_selling_price         := l_x_line_rec.unit_selling_price;
2661     x_line_val_rec.x_unit_list_price            := l_x_line_rec.unit_list_price;
2662     x_line_val_rec.x_list_percent               := l_x_line_rec.unit_list_percent;
2663     x_line_val_rec.x_selling_percent            := round(l_x_line_rec.unit_selling_percent,6);
2664     x_line_val_rec.x_pricing_quantity           := l_x_line_rec.pricing_quantity;
2665     x_line_val_rec.x_pricing_quantity_uom       := l_x_line_rec.pricing_quantity_uom;
2666     x_line_val_rec.x_calculate_price_flag       := l_x_line_rec.calculate_price_flag;
2667     x_line_val_rec.x_calculate_price_descr
2668                         := OE_Id_To_Value.Calculate_Price_Flag(x_line_val_rec.x_calculate_price_flag);
2669     x_line_val_rec.x_price_list_id              := l_x_line_rec.price_list_id;
2670     x_line_val_rec.x_price_list                 := OE_Id_To_Value.Price_List(x_line_val_rec.x_price_list_id);
2671     x_line_val_rec.x_payment_term_id            := l_x_line_rec.payment_term_id;
2672     x_line_val_rec.x_payment_term               := OE_Id_To_Value.Payment_Term(x_line_val_rec.x_payment_term_id);
2673 
2674     x_line_val_rec.x_shipment_priority_code     := l_x_line_rec.shipment_priority_code;
2675     x_line_val_rec.x_shipment_priority
2676                         := OE_Id_To_Value.Shipment_Priority(x_line_val_rec.x_shipment_priority_code);
2677     x_line_val_rec.x_freight_terms_code         := l_x_line_rec.freight_terms_code;
2678     x_line_val_rec.x_freight_terms              := OE_Id_To_Value.Freight_Terms(x_line_val_rec.x_freight_terms_code);
2679     x_line_val_rec.x_inventory_item_id          := l_x_line_rec.inventory_item_id;
2680     x_line_val_rec.x_ordered_item_id            := l_x_line_rec.ordered_item_id;
2681 
2682    IF OE_GLOBALS.G_DEFER_PRICING='N' THEN
2683     -- lkxu, commitment enhancement.
2684     IF UPPER(Nvl(Fnd_Profile.Value('OE_COMMITMENT_SEQUENCING'),'N')) = 'Y' THEN
2685       x_line_val_rec.x_commitment_applied_amount := OE_COMMITMENT_PVT.get_commitment_applied_amount
2686                           (p_header_id          => l_x_line_rec.header_id ,
2687                            p_line_id            => l_x_line_rec.line_id ,
2688                            p_commitment_id      => l_x_line_rec.commitment_id);
2689       IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2690                  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2691       ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2692                  RAISE FND_API.G_EXC_ERROR;
2693       END IF;
2694     END IF;
2695    END IF;
2696 -- Override List Price
2697    x_line_val_rec.x_original_list_price := l_x_line_rec.original_list_price;
2698    x_line_val_rec.x_unit_list_price_per_pqty := l_x_line_rec.unit_list_price_per_pqty;
2699    x_line_val_rec.x_unit_selling_price_per_pqty := l_x_line_rec.unit_selling_price_per_pqty;
2700 -- Override List Price
2701 
2702     --  Clear line record cache
2703 
2704     Clear_line;
2705 
2706 
2707 
2708     -- Re-set the UI flag to FALSE
2709     OE_GLOBALS.G_UI_FLAG := FALSE;
2710 
2711     --  Set return status.
2712 
2713     x_return_status := FND_API.G_RET_STS_SUCCESS;
2714 
2715     --  Get message count and data
2716 
2717     oe_msg_pub.count_and_get
2718     (   p_count                       => x_msg_count
2719     ,   p_data                        => x_msg_data
2720     );
2721 
2722     IF l_debug_level  > 0 THEN
2723         oe_debug_pub.add(  'EXITING OE_OE_FORM_LINE.VALIDATE_AND_WRITE' , 1 ) ;
2724     END IF;
2725 
2726 
2727 EXCEPTION
2728 
2729     WHEN FND_API.G_EXC_ERROR THEN
2730 
2731        OE_GLOBALS.G_UI_FLAG := FALSE;
2732 
2733         ROLLBACK TO SAVEPOINT Line_Validate_And_Write;
2734 /* From the UI, if we raise an exception here, user can
2735    make proper change and try to commit again, ended up with multiple
2736    records in the start flow global table. To avoid that, we
2737    are deleting the last entry in the global table upon exception.
2738 
2739    This change is only made here, assuming only UI has the
2740    ability to do something like that.
2741 */
2742 
2743         l_last_index := OE_GLOBALS.G_START_LINE_FLOWS_TBL.last;
2744         IF (l_x_line_tbl(1).operation = OE_GLOBALS.G_OPR_CREATE
2745                AND l_last_index IS NOT NULL    -- 2068070
2746                AND OE_GLOBALS.G_START_LINE_FLOWS_TBL(l_last_index).line_id = p_line_id) THEN --Bug 3000619
2747                OE_GLOBALS.G_START_LINE_FLOWS_TBL.delete(l_last_index);
2748         END IF;
2749     x_return_status := FND_API.G_RET_STS_ERROR;
2750 
2751         --  Get message count and data
2752 
2753         oe_msg_pub.count_and_get
2754         (   p_count                       => x_msg_count
2755         ,   p_data                        => x_msg_data
2756         );
2757 
2758     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2759 
2760        OE_GLOBALS.G_UI_FLAG := FALSE;
2761 
2762         ROLLBACK TO SAVEPOINT Line_Validate_And_Write;
2763         l_last_index := OE_GLOBALS.G_START_LINE_FLOWS_TBL.last;
2764         IF (l_x_line_tbl(1).operation = OE_GLOBALS.G_OPR_CREATE
2765                AND l_last_index IS NOT NULL    -- 2068070
2766                AND OE_GLOBALS.G_START_LINE_FLOWS_TBL(l_last_index).line_id = p_line_id) THEN --Bug 3000619
2767                OE_GLOBALS.G_START_LINE_FLOWS_TBL.delete(l_last_index);
2768         END IF;
2769         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2770 
2771         --  Get message count and data
2772 
2773         oe_msg_pub.count_and_get
2774         (   p_count                       => x_msg_count
2775         ,   p_data                        => x_msg_data
2776         );
2777 
2778     WHEN OTHERS THEN
2779 
2780        OE_GLOBALS.G_UI_FLAG := FALSE;
2781 
2782         ROLLBACK TO SAVEPOINT Line_Validate_And_Write;
2783         l_last_index := OE_GLOBALS.G_START_LINE_FLOWS_TBL.last;
2784         IF (l_x_line_tbl(1).operation = OE_GLOBALS.G_OPR_CREATE
2785                AND l_last_index IS NOT NULL    -- 2068070
2786                AND OE_GLOBALS.G_START_LINE_FLOWS_TBL(l_last_index).line_id = p_line_id) THEN --Bug 3000619
2787                OE_GLOBALS.G_START_LINE_FLOWS_TBL.delete(l_last_index);
2788         END IF;
2789         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2790 
2791         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
2792         THEN
2793             oe_msg_pub.Add_Exc_Msg
2794             (   G_PKG_NAME
2795             ,   'Validate_And_Write'
2796             );
2797         END IF;
2798 
2799         --  Get message count and data
2800 
2801         oe_msg_pub.count_and_get
2802         (   p_count                       => x_msg_count
2803         ,   p_data                        => x_msg_data
2804         );
2805 
2806 END Validate_And_Write;
2807 
2808 --  Procedure       Delete_Row
2809 --
2810 
2811 PROCEDURE Delete_Row
2812 ( x_return_status OUT NOCOPY VARCHAR2
2813 , x_msg_count OUT NOCOPY NUMBER
2814 , x_msg_data OUT NOCOPY VARCHAR2
2815 ,   p_line_id                       IN  NUMBER
2816 , p_change_reason_code            IN  VARCHAR2 Default Null
2817 , p_change_comments               IN  VARCHAR2 Default Null
2818 )
2819 IS
2820 l_x_line_rec                    OE_Order_PUB.Line_Rec_Type;
2821 l_x_line_tbl                    OE_Order_PUB.Line_Tbl_Type;
2822 l_x_old_line_tbl                    OE_Order_PUB.Line_Tbl_Type;
2823 l_control_rec                 OE_GLOBALS.Control_Rec_Type;
2824 l_return_status               VARCHAR2(1);
2825 --
2826 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2827 --
2828 BEGIN
2829     SAVEPOINT LINE_DELETE;
2830     IF l_debug_level  > 0 THEN
2831         oe_debug_pub.add(  'ENTERING OE_OE_FORM_LINE.DELETE_ROW' , 1 ) ;
2832     END IF;
2833 
2834     -- Set UI flag to TRUE
2835     OE_GLOBALS.G_UI_FLAG := TRUE;
2836 
2837     --  Set control flags.
2838 
2839     l_control_rec.controlled_operation := TRUE;
2840     l_control_rec.check_security        := TRUE;
2841     l_control_rec.validate_entity      := TRUE;
2842     l_control_rec.write_to_DB          := TRUE;
2843 
2844     l_control_rec.default_attributes   := FALSE;
2845     l_control_rec.change_attributes    := FALSE;
2846     l_control_rec.process              := FALSE;
2847 
2848     --  Instruct API to retain its caches
2849 
2850     l_control_rec.clear_api_cache      := FALSE;
2851     l_control_rec.clear_api_requests   := FALSE;
2852 
2853     --  Read DB record from cache
2854 
2855      Get_line
2856     (   p_db_record                   => TRUE
2857     ,   p_line_id                     => p_line_id
2858     ,   x_line_rec                    => l_x_line_rec
2859     );
2860 
2861     --  Set Operation.
2862 
2863     l_x_line_rec.operation := OE_GLOBALS.G_OPR_DELETE;
2864 
2865     --  Populate line table
2866 
2867     l_x_line_tbl(1) := l_x_line_rec;
2868     l_x_line_tbl(1).change_reason := p_change_reason_code;
2869     l_x_line_tbl(1).change_comments := p_change_comments;
2870 
2871     --  Call Oe_Order_Pvt.Process_order
2872 
2873     Oe_Order_Pvt.Lines
2874     (   p_validation_level            => FND_API.G_VALID_LEVEL_NONE
2875     ,   p_init_msg_list               => FND_API.G_TRUE
2876     ,   p_control_rec                 => l_control_rec
2877     ,   p_x_line_tbl                  => l_x_line_tbl
2878     ,   p_x_old_line_tbl              => l_x_old_line_tbl
2879     ,   x_return_status               => l_return_status
2880 
2881     );
2882 
2883 
2884     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2885         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2886     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2887         RAISE FND_API.G_EXC_ERROR;
2888     END IF;
2889 
2890     -- Re-set the UI flag to FALSE
2891     OE_GLOBALS.G_UI_FLAG := FALSE;
2892 
2893     --  Clear line record cache
2894 
2895     Clear_line;
2896 
2897     --  Set return status.
2898 
2899     x_return_status := FND_API.G_RET_STS_SUCCESS;
2900 
2901     --  Get message count and data
2902 
2903     oe_msg_pub.count_and_get
2904     (   p_count                       => x_msg_count
2905     ,   p_data                        => x_msg_data
2906     );
2907 
2908     IF l_debug_level  > 0 THEN
2909         oe_debug_pub.add(  'EXITING OE_OE_FORM_LINE.DELETE_ROW' , 1 ) ;
2910     END IF;
2911 
2912 EXCEPTION
2913 
2914     WHEN FND_API.G_EXC_ERROR THEN
2915        ROLLBACK TO SAVEPOINT Line_Delete;
2916        OE_GLOBALS.G_UI_FLAG := FALSE;
2917 
2918         x_return_status := FND_API.G_RET_STS_ERROR;
2919 
2920         --  Get message count and data
2921 
2922         oe_msg_pub.count_and_get
2923         (   p_count                       => x_msg_count
2924         ,   p_data                        => x_msg_data
2925         );
2926 
2927     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2928        ROLLBACK TO SAVEPOINT Line_Delete;
2929 
2930        OE_GLOBALS.G_UI_FLAG := FALSE;
2931 
2932         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2933 
2934         --  Get message count and data
2935 
2936         oe_msg_pub.count_and_get
2937         (   p_count                       => x_msg_count
2938         ,   p_data                        => x_msg_data
2939         );
2940 
2941     WHEN OTHERS THEN
2942        ROLLBACK TO SAVEPOINT Line_Delete;
2943 
2944        OE_GLOBALS.G_UI_FLAG := FALSE;
2945 
2946         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2947 
2948         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
2949         THEN
2950             oe_msg_pub.Add_Exc_Msg
2951             (   G_PKG_NAME
2952             ,   'Delete_Row'
2953             );
2954         END IF;
2955 
2956         --  Get message count and data
2957 
2958         oe_msg_pub.count_and_get
2959         (   p_count                       => x_msg_count
2960         ,   p_data                        => x_msg_data
2961         );
2962 
2963 END Delete_Row;
2964 
2965 --  Procedure       Process_Entity
2966 --
2967 
2968 PROCEDURE Process_Entity
2969 ( x_return_status OUT NOCOPY VARCHAR2
2970 , x_msg_count OUT NOCOPY NUMBER
2971 , x_msg_data OUT NOCOPY VARCHAR2
2972 )
2973 IS
2974 l_control_rec                 OE_GLOBALS.Control_Rec_Type;
2975 l_return_status               VARCHAR2(1);
2976 l_x_header_rec                OE_Order_PUB.Header_Rec_Type;
2977 l_x_Header_Adj_rec            OE_Order_PUB.Header_Adj_Rec_Type;
2978 l_x_Header_Adj_tbl            OE_Order_PUB.Header_Adj_Tbl_Type;
2979 l_x_Header_Scredit_rec        OE_Order_PUB.Header_Scredit_Rec_Type;
2980 l_x_Header_Scredit_tbl        OE_Order_PUB.Header_Scredit_Tbl_Type;
2981 l_x_line_rec                  OE_Order_PUB.Line_Rec_Type;
2982 l_x_line_tbl                  OE_Order_PUB.Line_Tbl_Type;
2983 l_x_Line_Adj_rec              OE_Order_PUB.Line_Adj_Rec_Type;
2984 l_x_Line_Adj_tbl              OE_Order_PUB.Line_Adj_Tbl_Type;
2985 l_x_Line_Scredit_rec          OE_Order_PUB.Line_Scredit_Rec_Type;
2986 l_x_Line_Scredit_tbl          OE_Order_PUB.Line_Scredit_Tbl_Type;
2987 l_x_Action_Request_tbl        OE_Order_PUB.Request_Tbl_Type;
2988 l_x_Lot_Serial_Tbl            OE_Order_PUB.Lot_Serial_Tbl_Type;
2989 l_x_Header_price_Att_tbl      OE_Order_PUB.Header_Price_Att_Tbl_Type;
2990 l_x_Header_Adj_Att_tbl        OE_Order_PUB.Header_Adj_Att_Tbl_Type;
2991 l_x_Header_Adj_Assoc_tbl      OE_Order_PUB.Header_Adj_Assoc_Tbl_Type;
2992 l_x_Line_price_Att_tbl        OE_Order_PUB.Line_Price_Att_Tbl_Type;
2993 l_x_Line_Adj_Att_tbl          OE_Order_PUB.Line_Adj_Att_Tbl_Type;
2994 l_x_Line_Adj_Assoc_tbl        OE_Order_PUB.Line_Adj_Assoc_Tbl_Type;
2995 --serla begin
2996 l_x_Header_Payment_tbl        OE_Order_PUB.Header_Payment_Tbl_Type;
2997 l_x_Line_Payment_tbl          OE_Order_PUB.Line_Payment_Tbl_Type;
2998 --serla end
2999 --
3000 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3001 --
3002 BEGIN
3003 
3004     IF l_debug_level  > 0 THEN
3005         oe_debug_pub.add(  'ENTERING OE_OE_FORM_LINE.PROCESS_ENTITY' , 1 ) ;
3006     END IF;
3007 
3008     -- Set UI flag to TRUE
3009     OE_GLOBALS.G_UI_FLAG := TRUE;
3010 
3011     --  Set control flags.
3012 
3013     l_control_rec.controlled_operation := TRUE;
3014     l_control_rec.process              := TRUE;
3015     l_control_rec.process_entity       := OE_GLOBALS.G_ENTITY_LINE;
3016 
3017     l_control_rec.check_security        := FALSE;
3018     l_control_rec.clear_dependents     := FALSE;
3019     l_control_rec.default_attributes   := FALSE;
3020     l_control_rec.change_attributes    := FALSE;
3021     l_control_rec.validate_entity      := FALSE;
3022     l_control_rec.write_to_DB          := FALSE;
3023 
3024     --  Instruct API to clear its request table
3025 
3026     l_control_rec.clear_api_cache      := FALSE;
3027     l_control_rec.clear_api_requests   := FALSE;
3028 
3029     --  Call Oe_Order_Pvt.Process_order
3030 
3031     Oe_Order_Pvt.Process_order
3032     (   p_api_version_number          => 1.0
3033     ,   p_init_msg_list               => FND_API.G_TRUE
3034     ,   x_return_status               => l_return_status
3035     ,   x_msg_count                   => x_msg_count
3036     ,   x_msg_data                    => x_msg_data
3037     ,   p_control_rec                 => l_control_rec
3038     ,   p_x_header_rec                  => l_x_header_rec
3039     ,   p_x_Header_Adj_tbl              => l_x_Header_Adj_tbl
3040     ,   p_x_header_price_att_tbl        => l_x_header_price_att_tbl
3041     ,   p_x_Header_Adj_att_tbl          => l_x_Header_Adj_att_tbl
3042     ,   p_x_Header_Adj_Assoc_tbl        => l_x_Header_Adj_Assoc_tbl
3043     ,   p_x_Header_Scredit_tbl          => l_x_Header_Scredit_tbl
3044 --serla begin
3045     ,   p_x_Header_Payment_tbl          => l_x_Header_Payment_tbl
3046 --serla end
3047     ,   p_x_line_tbl                    => l_x_line_tbl
3048     ,   p_x_Line_Adj_tbl                => l_x_Line_Adj_tbl
3049     ,   p_x_Line_Price_att_tbl          => l_x_Line_Price_att_tbl
3050     ,   p_x_Line_Adj_att_tbl            => l_x_Line_Adj_att_tbl
3051     ,   p_x_Line_Adj_Assoc_tbl          => l_x_Line_Adj_Assoc_tbl
3052     ,   p_x_Line_Scredit_tbl            => l_x_Line_Scredit_tbl
3053 --serla begin
3054     ,   p_x_Line_Payment_tbl            => l_x_Line_Payment_tbl
3055 --serla end
3056     ,   p_x_action_request_tbl          => l_x_Action_Request_tbl
3057     ,   p_x_lot_serial_tbl            => l_x_lot_serial_tbl
3058     );
3059 
3060     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3061         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3062     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3063         RAISE FND_API.G_EXC_ERROR;
3064     END IF;
3065 
3066     -- Re-set the UI flag to FALSE
3067     OE_GLOBALS.G_UI_FLAG := FALSE;
3068 
3069     --  Set return status.
3070 
3071     x_return_status := FND_API.G_RET_STS_SUCCESS;
3072 
3073     --  Get message count and data
3074 
3075     oe_msg_pub.count_and_get
3076     (   p_count                       => x_msg_count
3077     ,   p_data                        => x_msg_data
3078     );
3079 
3080     IF l_debug_level  > 0 THEN
3081         oe_debug_pub.add(  'EXITING OE_OE_FORM_LINE.PROCESS_ENTITY' , 1 ) ;
3082     END IF;
3083 
3084 EXCEPTION
3085 
3086     WHEN FND_API.G_EXC_ERROR THEN
3087 
3088        OE_GLOBALS.G_UI_FLAG := FALSE;
3089 
3090         x_return_status := FND_API.G_RET_STS_ERROR;
3091 
3092         --  Get message count and data
3093 
3094         oe_msg_pub.count_and_get
3095         (   p_count                       => x_msg_count
3096         ,   p_data                        => x_msg_data
3097         );
3098 
3099     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3100 
3101        OE_GLOBALS.G_UI_FLAG := FALSE;
3102 
3103         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
3104 
3105         --  Get message count and data
3106 
3107         oe_msg_pub.count_and_get
3108         (   p_count                       => x_msg_count
3109         ,   p_data                        => x_msg_data
3110         );
3111 
3112     WHEN OTHERS THEN
3113 
3114        OE_GLOBALS.G_UI_FLAG := FALSE;
3115 
3116         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
3117 
3118         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
3119         THEN
3120             oe_msg_pub.Add_Exc_Msg
3121             (   G_PKG_NAME
3122             ,   'Process_Entity'
3123             );
3124         END IF;
3125 
3126         --  Get message count and data
3127 
3128         oe_msg_pub.count_and_get
3129         (   p_count                       => x_msg_count
3130         ,   p_data                        => x_msg_data
3131         );
3132 
3133 END Process_Entity;
3134 
3135 --  Procedure       lock_Row
3136 --
3137 
3138 PROCEDURE Lock_Row
3139 ( x_return_status OUT NOCOPY VARCHAR2
3140 , x_msg_count OUT NOCOPY NUMBER
3141 , x_msg_data OUT NOCOPY VARCHAR2
3142 ,   p_line_id                       IN  NUMBER
3143 ,   p_lock_control                  IN  NUMBER
3144 )
3145 
3146 IS
3147 l_return_status               VARCHAR2(1);
3148 l_x_line_rec                  OE_Order_PUB.Line_Rec_Type;
3149 --
3150 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3151 --
3152 BEGIN
3153 
3154     IF l_debug_level  > 0 THEN
3155         oe_debug_pub.add(  'ENTERING OE_OE_FORM_LINE.LOCK_ROW' , 1 ) ;
3156     END IF;
3157 
3158     --  Load line record
3159 
3160     l_x_line_rec.lock_control        := p_lock_control;
3161     l_x_line_rec.line_id             := p_line_id;
3162     l_x_line_rec.operation           := OE_GLOBALS.G_OPR_LOCK; -- not req.
3163 
3164     --Bug 3025978
3165       OE_GLOBALS.G_UI_FLAG := TRUE;
3166 
3167     --  Call OE_Line_Util.Lock_Row instead of Oe_Order_Pvt.Lock_order
3168     OE_MSG_PUB.initialize;
3169     OE_Line_Util.Lock_Row
3170     ( x_return_status         => l_return_status
3171     , p_x_line_rec            => l_x_line_rec
3172     , p_line_id               => p_line_id);
3173 
3174     IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
3175 
3176         --  Set DB flag and write record to cache.
3177 
3178         l_x_line_rec.db_flag := FND_API.G_TRUE;
3179     IF l_debug_level  > 0 THEN
3180         oe_debug_pub.add(  'EXITING OE_OE_FORM_LINE.LOCK_ROW'||L_X_LINE_REC.LINE_ID , 1 ) ;
3181     END IF;
3182 
3183         Write_line
3184         (   p_line_rec                    => l_x_line_rec
3185         ,   p_db_record                   => TRUE
3186         );
3187 
3188     END IF;
3189 
3190     --  Set return status.
3191 
3192     x_return_status := l_return_status;
3193     IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3194         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3195     ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3196         RAISE FND_API.G_EXC_ERROR;
3197     END IF;
3198 
3199     --  Get message count and data
3200 
3201     oe_msg_pub.count_and_get
3202     (   p_count                       => x_msg_count
3203     ,   p_data                        => x_msg_data
3204     );
3205 
3206     IF l_debug_level  > 0 THEN
3207         oe_debug_pub.add(  'EXITING OE_OE_FORM_LINE.LOCK_ROW' , 1 ) ;
3208     END IF;
3209 
3210 EXCEPTION
3211     WHEN FND_API.G_EXC_ERROR THEN
3212 
3213         OE_GLOBALS.G_UI_FLAG := FALSE;
3214 
3215         x_return_status := FND_API.G_RET_STS_ERROR;
3216 
3217         --  Get message count and data
3218 
3219         oe_msg_pub.count_and_get
3220         (   p_count                       => x_msg_count
3221         ,   p_data                        => x_msg_data
3222         );
3223 
3224     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3225 
3226         OE_GLOBALS.G_UI_FLAG := FALSE;
3227 
3228         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
3229 
3230         --  Get message count and data
3231 
3232         oe_msg_pub.count_and_get
3233         (   p_count                       => x_msg_count
3234         ,   p_data                        => x_msg_data
3235         );
3236 
3237     WHEN OTHERS THEN
3238 
3239         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
3240         THEN
3241             oe_msg_pub.Add_Exc_Msg
3242             (   G_PKG_NAME
3243             ,   'Lock_Row'
3244             );
3245         END IF;
3246 
3247         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3248 
3249         --  Get message count and data
3250 
3251         oe_msg_pub.count_and_get
3252         (   p_count                       => x_msg_count
3253         ,   p_data                        => x_msg_data
3254         );
3255 
3256 
3257 
3258 END Lock_Row;
3259 
3260 --  Procedures maintaining line record cache.
3261 
3262 PROCEDURE Write_line
3263 (   p_line_rec                      IN  OE_Order_PUB.Line_Rec_Type
3264 ,   p_db_record                     IN  BOOLEAN := FALSE
3265 )
3266 IS
3267 --
3268 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3269 --
3270 BEGIN
3271 
3272     IF l_debug_level  > 0 THEN
3273         oe_debug_pub.add(  'ENTERING OE_OE_FORM_LINE.WRITE_LINE' , 1 ) ;
3274     END IF;
3275     g_line_rec := p_line_rec;
3276 
3277     IF p_db_record THEN
3278 
3279         g_db_line_rec := p_line_rec;
3280 
3281     END IF;
3282 
3283     IF l_debug_level  > 0 THEN
3284         oe_debug_pub.add(  'EXITING OE_OE_FORM_LINE.WRITE_LINE' , 1 ) ;
3285     END IF;
3286 
3287 END Write_Line;
3288 
3289 PROCEDURE Get_line
3290 (   p_db_record                     IN  BOOLEAN := FALSE
3291 ,   p_line_id                       IN  NUMBER
3292 ,   x_line_rec                      OUT NOCOPY  OE_Order_PUB.Line_Rec_Type
3293 )
3294 IS
3295 --
3296 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3297 --
3298 BEGIN
3299 
3300     IF l_debug_level  > 0 THEN
3301         oe_debug_pub.add(  'ENTERING OE_OE_FORM_LINE.GET_LINE'||P_LINE_ID , 1 ) ;
3302     END IF;
3303     --reverting back the fix made for bug 2103000 as the problem
3304     --is fixed in file OEXOEFRM.pld(version 115.251)
3305     --Fixes the issue reported in bug 2150247
3306     IF  p_line_id <> NVL(g_line_rec.line_id,FND_API.G_MISS_NUM)
3307     THEN
3308 
3309         --  Query row from DB
3310     IF l_debug_level  > 0 THEN
3311         oe_debug_pub.add(  'ENTERING OE_OE_FORM_LINE.GET_LINE QUERY '||P_LINE_ID , 1 ) ;
3312     END IF;
3313 
3314         OE_Line_Util.Query_Row
3315         (   p_line_id                     => p_line_id,
3316           x_line_rec                    =>g_line_rec
3317         );
3318 
3319         g_line_rec.db_flag             := FND_API.G_TRUE;
3320 
3321         --  Load DB record
3322 
3323         g_db_line_rec                  := g_line_rec;
3324 
3325     END IF;
3326 
3327     IF l_debug_level  > 0 THEN
3328         oe_debug_pub.add(  'EXITING OE_OE_FORM_LINE.GET_LINE' , 1 ) ;
3329     END IF;
3330 
3331     IF p_db_record THEN
3332       --Added for bug3911285
3333       IF p_line_id <> g_db_line_rec.line_id THEN
3334         g_db_line_rec := OE_Order_PUB.G_MISS_LINE_REC;
3335       END IF;
3336       --End of bug3911285
3337 
3338         x_line_rec:= g_db_line_rec;
3339 
3340     ELSE
3341 
3342         x_line_rec:= g_line_rec;
3343 
3344     END IF;
3345 
3346 END Get_Line;
3347 
3348 PROCEDURE Clear_Line
3349 IS
3350 --
3351 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3352 --
3353 BEGIN
3354 
3355     IF l_debug_level  > 0 THEN
3356         oe_debug_pub.add(  'ENTERING OE_OE_FORM_LINE.CLEAR_LINE' , 1 ) ;
3357     END IF;
3358 
3359     g_line_rec                     := OE_Order_PUB.G_MISS_LINE_REC;
3360     g_db_line_rec                  := OE_Order_PUB.G_MISS_LINE_REC;
3361 
3362     IF l_debug_level  > 0 THEN
3363         oe_debug_pub.add(  'EXITING OE_OE_FORM_LINE.CLEAR_LINE' , 1 ) ;
3364     END IF;
3365 
3366 END Clear_Line;
3367 
3368 PROCEDURE POPULATE_CONTROL_FIELDS
3369 ( p_line_rec        IN line_rec_type,
3370 x_line_val_rec OUT NOCOPY line_val_rec_type,
3371  p_calling_block   IN  VARCHAR2
3372 ) IS
3373   l_flow_meaning VARCHAR2(80);
3374   released_count NUMBER;
3375   total_count   NUMBER;
3376   l_status      VARCHAR2(80);
3377 /*1931163*/
3378   l_hold_exists        VARCHAR2(1);
3379   l_ato_line_id        NUMBER;
3380   l_top_model_line_id  NUMBER;
3381   l_smc_flag           VARCHAR2(1);
3382   l_item_type_code     VARCHAR2(30);
3383   l_link_to_line_id    NUMBER;
3384 --retro{
3385   l_retrobilled_price_diff NUMBER;
3386   l_unit_selling_price     NUMBER;
3387 --retro}
3388 --recurring charges
3389   l_charge_periodicity VARCHAR2(25);
3390   --bug 10047225
3391   l_concat_segs	varchar2(2000):='';
3392   l_valid_kff     boolean;
3393 
3394   CURSOR C1(tax_exempt_reason_code VARCHAR2,
3395           tax_exempt_flag        VARCHAR2,
3396             fob_point_code         VARCHAR2,
3397           return_reason_code     VARCHAR2)
3398   IS
3399      SELECT meaning,lookup_type
3400     FROM   AR_LOOKUPS
3401     WHERE (lookup_code=tax_exempt_reason_code
3402     AND    lookup_type='TAX_REASON')
3403     OR    (lookup_code=tax_exempt_flag
3404     AND    lookup_type='TAX_CONTROL_FLAG')
3405     OR    (lookup_code=fob_point_code
3406     AND    lookup_type='FOB')
3407     OR    (lookup_code=return_reason_code
3408     AND    lookup_type='CREDIT_MEMO_REASON');
3409   CURSOR c2(shipment_priority_code  VARCHAR2,
3410         freight_terms_code VARCHAR2)
3411   IS
3412      SELECT meaning,lookup_type
3413      FROM FND_LOOKUP_VALUES LV
3414      WHERE LANGUAGE = userenv('LANG')
3415      and VIEW_APPLICATION_ID = 660
3416      and((lookup_code= shipment_priority_code
3417      and lookup_type='SHIPMENT_PRIORITY')
3418      or (lookup_code=freight_terms_code
3419      and lookup_type='FREIGHT_TERMS'))
3420      and SECURITY_GROUP_ID =fnd_global.Lookup_Security_Group(lv.lookup_type,lv.view_application_id);
3421   /*l_organization_id  Number:=fnd_profile.value('OE_ORGANIZATION_ID');*/
3422     -- This change is required since we are dropping the profile OE_ORGANIZATION    -- _ID. Change made by Esha.
3423     l_organization_id Number;
3424   /* Need to Change Exception Handling- Not Sure whether we should continue
3425     to process other attribute when one of the attribute raises exception.
3426     Checked in 11i and  they are continuing processing of other attributes */
3427     l_address_id number;
3428         l_sales_order_id number;
3429         l_msg_count  number;
3430         l_msg_data   Varchar2(2000);
3431         l_return_status VARCHAR2(1);
3432 
3433   /* 1931163 */
3434   CURSOR line_on_hold(c_line_id NUMBER) IS
3435   SELECT 'Y' hold_exists
3436   FROM   oe_order_holds
3437   WHERE  line_id       = c_line_id
3438   AND    released_flag = 'N';
3439 
3440   CURSOR line_info(c_line_id NUMBER) IS
3441   SELECT
3442     ato_line_id
3443   , top_model_line_id
3444   , nvl(ship_model_complete_flag, 'N') smc_flag
3445   , item_type_code
3446   , link_to_line_id
3447   FROM   oe_order_lines
3448   WHERE  line_id = c_line_id;
3449 
3450  CURSOR ato_lines_on_hold(c_ato_line_id NUMBER, c_top_model_line_id NUMBER) IS
3451  SELECT 'Y' hold_exists
3452  FROM   oe_order_holds ooh, oe_order_lines ool
3453  where  ool.ato_line_id = c_ato_line_id
3454  and    ool.top_model_line_id = c_top_model_line_id
3455  and    ooh.line_id = ool.line_id
3456  and    ooh.released_flag = 'N';
3457 
3458  CURSOR smc_lines_on_hold(c_top_model_line_id NUMBER) IS
3459  SELECT 'Y' hold_exists
3460  FROM   oe_order_holds ooh, oe_order_lines ool
3461  where  ool.top_model_line_id = c_top_model_line_id
3462  and    ooh.line_id = ool.line_id
3463  and    ooh.released_flag = 'N';
3464 
3465  CURSOR link_to_line_hold(c_link_to_line_id NUMBER) IS
3466  SELECT 'Y' hold_exists
3467  FROM   oe_order_holds ooh, oe_hold_definitions ohd, oe_hold_sources ohs
3468  where  ooh.line_id = c_link_to_line_id
3469  and    ooh.released_flag = 'N'
3470  and    ohs.hold_source_id = ooh.hold_source_id
3471  and    ohs.hold_id = ohd.hold_id
3472  and    nvl(ohd.hold_included_items_flag, 'N') = 'Y';
3473 
3474  --MRG BGN
3475  l_order_margin_percent NUMBER;
3476  l_order_margin_amount  NUMBER;
3477  --MRG END
3478 
3479 --
3480 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3481 --
3482 --7832836  l_cascade_hold_non_smc VARCHAR2(1) := NVL(OE_SYS_PARAMETERS.VALUE('ONT_CASCADE_HOLD_NONSMC_PTO'),'N'); --ER#7479609
3483 l_cascade_hold_non_smc VARCHAR2(1);  -- 7832836
3484 BEGIN
3485     l_organization_id := OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID',
3486                                p_line_rec.org_id);
3487     l_cascade_hold_non_smc := NVL(OE_SYS_PARAMETERS.VALUE('ONT_CASCADE_HOLD_NONSMC_PTO',p_line_rec.org_id),'N'); --7832836
3488 	-- sol_ord_er #16014165, get Billing Profile Display
3489 	IF p_line_rec.service_bill_profile_id IS NOT NULL THEN
3490 		IF l_debug_level > 0 THEN
3491 			oe_debug_pub.add('SK OEXFLINB.pls 110 '||p_line_rec.service_bill_profile_id);
3492 		END IF;
3493 		x_line_val_rec.service_bill_profile := OE_Id_To_Value.Billing_Profile(p_line_rec.service_bill_profile_id);
3494 	END IF;
3495 	IF p_line_rec.service_cov_template_id IS NOT NULL THEN
3496 		IF l_debug_level > 0 THEN
3497 			oe_debug_pub.add('SK OEXFLINB.pls 111 '||p_line_rec.service_cov_template_id);
3498 		END IF;
3499 		x_line_val_rec.service_cov_template := OE_Id_To_Value.Coverage_Template(p_line_rec.service_cov_template_id);
3500 	END IF;
3501 	IF p_line_rec.service_subs_template_id IS NOT NULL THEN
3502 		IF l_debug_level > 0 THEN
3503 			oe_debug_pub.add('SK OEXFLINB.pls 112 '||p_line_rec.service_subs_template_id);
3504 		END IF;
3505 		x_line_val_rec.service_subs_template := OE_Id_To_Value.Subscription_Template(p_line_rec.service_subs_template_id);
3506 	END IF;
3507 	IF p_line_rec.service_bill_option_code IS NOT NULL THEN
3508 		IF l_debug_level > 0 THEN
3509 			oe_debug_pub.add('SK OEXFLINB.pls 114 '||p_line_rec.service_bill_option_code);
3510 		END IF;
3511 		x_line_val_rec.service_bill_option := OE_Id_To_Value.Billing_Option(p_line_rec.service_bill_option_code);
3512 	END IF;
3513 	-- sol_ord_er #16014165 end
3514 --   Populate Project Number and  Task Number
3515    IF p_line_rec.project_id is not Null then
3516     BEGIN
3517  /*      Select project_number
3518       into  x_line_val_rec.project_number
3519       from pjm_projects_org_v
3520       Where project_id=p_line_rec.project_id;*/
3521 
3522        x_line_val_rec.project_number := pjm_project.all_proj_idtonum(p_line_rec.project_id);
3523     EXCEPTION
3524       When no_data_found then
3525       Null;
3526        When too_many_rows then
3527       Null;
3528      END;
3529    END IF;
3530 
3531    IF p_line_rec.task_id is not null then
3532 /*  Select task_number
3533     Into x_line_val_rec.task_number
3534     From pjm_tasks_v
3535     Where task_id=p_line_rec.task_id;*/
3536 
3537       x_line_val_rec.task_number := pjm_project.all_task_idtonum(p_line_rec.task_id);
3538    END IF;
3539 --retro{Previously commented by VMALAPAT. Removed the comment for retrobilling
3540 --This query fires only once per order
3541  IF(g_header_id is NULL or  p_line_rec.header_id <> g_header_id) THEN
3542    IF p_line_rec.header_id is not null THEN
3543   BEGIN  -- Bug 8360952 handle exception
3544     select transactional_curr_code
3545      into x_line_val_rec.transactional_curr_code
3546      from oe_order_headers
3547     where header_id=p_line_rec.header_id;
3548      g_header_id := p_line_rec.header_id;
3549      g_currency_code :=x_line_val_rec. transactional_curr_code;
3550   EXCEPTION
3551   WHEN OTHERS THEN
3552    null;
3553   END;
3554 
3555    END IF;
3556  ELSE
3557      x_line_val_rec.transactional_curr_code := g_currency_code;
3558  END IF;
3559 --retro}
3560   IF p_line_rec.line_id IS NOT NULL THEN
3561 
3562     x_line_val_rec.hold_exists_flag := 'N';
3563     x_line_val_rec.cascaded_hold_exists_flag := 'N';
3564 
3565     /* 1931163: First check if there is ANY unreleased hold on the order/lines */
3566     BEGIN
3567       SELECT 'Y'
3568       INTO   l_hold_exists
3569       FROM   OE_ORDER_HOLDS
3570       WHERE  HEADER_ID = p_line_rec.header_id
3571       AND    RELEASED_FLAG = 'N';
3572       EXCEPTION
3573         WHEN TOO_MANY_ROWS THEN
3574           l_hold_exists := 'Y';
3575           null;
3576         WHEN OTHERS THEN
3577           l_hold_exists := 'N';
3578           null;
3579     END;
3580 
3581     IF l_hold_exists = 'Y' THEN
3582 
3583       /* 1931163: Check if Hold Exist on Line */
3584       FOR line_hold_rec in line_on_hold(p_line_rec.line_id) LOOP
3585 
3586         x_line_val_rec.hold_exists_flag := line_hold_rec.hold_exists;
3587         EXIT;
3588 
3589       END LOOP;
3590 
3591       /* 1931163: Check if Cascaded Hold Exist on Line */
3592       IF x_line_val_rec.hold_exists_flag = 'N' THEN
3593 
3594         OPEN line_info(p_line_rec.line_id);
3595 
3596         FETCH line_info
3597         INTO  l_ato_line_id, l_top_model_line_id, l_smc_flag,
3598               l_item_type_code, l_link_to_line_id;
3599 
3600         CLOSE line_info;
3601 
3602         /* 1931163: Check Cascaded Hold based on ATO Line(s) */
3603         IF l_ato_line_id IS NOT NULL AND
3604         NOT (l_ato_line_id = p_line_rec.line_id AND l_item_type_code = OE_GLOBALS.G_ITEM_OPTION) THEN
3605 
3606           FOR ato_hold_rec in ato_lines_on_hold(l_ato_line_id, l_top_model_line_id)
3607           LOOP
3608 
3609        IF p_line_rec.cancelled_flag = 'N' and p_line_rec.open_flag = 'Y'
3610        THEN
3611 
3612             x_line_val_rec.cascaded_hold_exists_flag := ato_hold_rec.hold_exists;
3613        END IF;
3614             EXIT;
3615 
3616           END LOOP;
3617         END IF; -- ATO
3618 
3619         /* 1931163: Check Cascaded Hold based on SMC Line(s) */
3620         IF l_smc_flag = 'Y' AND x_line_val_rec.cascaded_hold_exists_flag = 'N' THEN
3621 
3622           FOR smc_hold_rec in smc_lines_on_hold(l_top_model_line_id)
3623           LOOP
3624        IF p_line_rec.cancelled_flag = 'N' and p_line_rec.open_flag = 'Y'
3625        THEN
3626 
3627             x_line_val_rec.cascaded_hold_exists_flag := smc_hold_rec.hold_exists;
3628        END IF;
3629             EXIT;
3630 
3631           END LOOP;
3632         END IF; -- SMC
3633 
3634 
3635         --5737464
3636         IF l_smc_flag = 'N' AND x_line_val_rec.cascaded_hold_exists_flag = 'N'
3637         THEN
3638            IF l_debug_level > 0 THEN
3639               oe_debug_pub.add('GOING TO CHECK FOR CONFIG VALIDATION HOLD FOR '||l_top_model_line_id,1);
3640            END IF;
3641 
3642            BEGIN
3643               l_hold_exists := NULL;
3644 
3645             IF l_cascade_hold_non_smc <> 'Y' THEN
3646               SELECT 'Y' hold_exists
3647               INTO l_hold_exists
3648               FROM   oe_order_holds ooh, oe_hold_definitions ohd, oe_hold_sources ohs
3649               where  ooh.line_id = l_top_model_line_id
3650               and    ooh.released_flag = 'N'
3651               and    ohs.hold_source_id = ooh.hold_source_id
3652               and    ohs.hold_id = ohd.hold_id
3653               and    ohd.hold_id = 3;
3654             --ER#7479609 start
3655             ELSE
3656               SELECT 'Y' hold_exists
3657               INTO l_hold_exists
3658               FROM   oe_order_holds ooh, oe_hold_definitions ohd, oe_hold_sources ohs
3659               where  ooh.line_id = l_top_model_line_id
3660               and    ooh.released_flag = 'N'
3661               and    ohs.hold_source_id = ooh.hold_source_id
3662               and    ohs.hold_id = ohd.hold_id;
3663             END IF;
3664             --ER#7479609 end
3665            EXCEPTION
3666               WHEN OTHERS THEN
3667                  NULL;
3668            END;
3669            IF l_hold_exists = 'Y' THEN
3670 
3671               IF p_line_rec.cancelled_flag = 'N' and p_line_rec.open_flag = 'Y'
3672               THEN
3673                  IF l_debug_level > 0 THEN
3674                     oe_debug_pub.add('HOLD CASCADED TO LINE ID '||p_line_rec.line_id,1);
3675                  END IF;
3676                  x_line_val_rec.cascaded_hold_exists_flag := 'Y';
3677               END IF;
3678            END IF;
3679         END IF;
3680         --5737464
3681 
3682 
3683         /* 1931163: Check Cascaded Hold for Included Item */
3684         IF l_item_type_code = OE_GLOBALS.G_ITEM_INCLUDED AND x_line_val_rec.cascaded_hold_exists_flag = 'N' THEN
3685 
3686           FOR link_to_hold_rec in link_to_line_hold(l_link_to_line_id)
3687           LOOP
3688 
3689        IF p_line_rec.cancelled_flag = 'N' and p_line_rec.open_flag = 'Y'
3690        THEN
3691             x_line_val_rec.cascaded_hold_exists_flag := link_to_hold_rec.hold_exists;
3692       END IF;
3693             EXIT;
3694 
3695           END LOOP;
3696 
3697         END IF; -- Hold on Included Items
3698 
3699       END IF; -- No Real Holds on Line
3700 
3701     END IF; -- Any Hold on Order/Line
3702 
3703   END IF;
3704 
3705  -- Changes for Visibility to Process Messages datafix project begin
3706 
3707   x_line_val_rec.message_exists_flag := 'N';
3708 
3709   IF G_ENABLE_VISIBILITY_MSG = 'Y' AND
3710              p_line_rec.line_id is NOT NULL THEN
3711         BEGIN
3712              SELECT 'Y'
3713              INTO   x_line_val_rec.message_exists_flag
3714              FROM   OE_PROCESSING_MSGS
3715              WHERE  header_id = p_line_rec.header_id
3716              AND    line_id = p_line_rec.line_id
3717              AND NVL(message_status_code, '0') <> 'CLOSED'  --datafix_begin_end
3718              AND    rownum < 2;
3719         EXCEPTION
3720               WHEN TOO_MANY_ROWS THEN
3721                    x_line_val_rec.message_exists_flag  := 'Y';
3722               WHEN OTHERS THEN
3723                    x_line_val_rec.message_exists_flag := 'N';
3724         END;
3725   END IF;
3726 
3727    IF (p_line_rec.line_category_code = 'RETURN') THEN
3728     IF (p_line_rec.reference_line_id is not null) THEN
3729      BEGIN
3730       select  /* MOAC_SQL_CHANGE */  H.order_number,
3731              l.line_number,
3732              l.shipment_number,
3733              l.option_number,
3734              l.component_number
3735       into x_line_val_rec.ref_order_number,
3736            x_line_val_rec.ref_line_number,
3737            x_line_val_rec.ref_shipment_number,
3738            x_line_val_rec.ref_option_number,
3739            x_line_val_rec.ref_component_number
3740       from oe_order_headers_all h,
3741            oe_order_lines_all l
3742       where l.line_id=p_line_rec.reference_line_id
3743       and h.header_id=l.header_id;
3744      EXCEPTION
3745        WHEN NO_DATA_FOUND THEN
3746        Null;
3747       oe_debug_pub.add('In NO Data Found ');
3748        When too_many_rows then
3749        Null;
3750       When others then
3751       oe_debug_pub.add('In Others Found ');
3752       Null;
3753      END;
3754      END IF;
3755 
3756      IF (p_line_rec.reference_customer_trx_line_id is not null) THEN
3757      BEGIN
3758        select /* MOAC_SQL_CHANGE */ rct.trx_number,
3759               rctl.line_number
3760        into x_line_val_rec.ref_invoice_number,
3761             x_line_val_rec.ref_invoice_line_number
3762        from ra_customer_trx_all rct,
3763             ra_customer_trx_lines_all rctl
3764        where rctl.customer_trx_line_id = p_line_rec.reference_customer_trx_line_id
3765        and rctl.customer_trx_id = rct.customer_trx_id;
3766      EXCEPTION
3767        WHEN NO_DATA_FOUND THEN
3768        Null;
3769        When too_many_rows then
3770       Null;
3771       When others then
3772       Null;
3773      END;
3774      END IF;
3775 
3776      IF (p_line_rec.reference_customer_trx_line_id is not null) THEN
3777      BEGIN
3778        select /* MOAC_SQL_CHANGE */ rct.trx_number,
3779               rctl.line_number
3780        into x_line_val_rec.ref_invoice_number,
3781             x_line_val_rec.ref_invoice_line_number
3782        from ra_customer_trx_all rct,
3783             ra_customer_trx_lines_all rctl
3784        where rctl.customer_trx_line_id = p_line_rec.reference_customer_trx_line_id
3785        and rctl.customer_trx_id = rct.customer_trx_id;
3786      EXCEPTION
3787        WHEN NO_DATA_FOUND THEN
3788        Null;
3789        When too_many_rows then
3790       Null;
3791       When others then
3792       Null;
3793      END;
3794      END IF;
3795 
3796      IF (p_line_rec.credit_invoice_line_id is not null) THEN
3797      BEGIN
3798        select /* MOAC_SQL_CHANGE */ rct.trx_number
3799        into x_line_val_rec.credit_invoice_number
3800        from ra_customer_trx_all rct,
3801          ra_customer_trx_lines_all rctl
3802        where rctl.customer_trx_line_id = p_line_rec.credit_invoice_line_id
3803        and rctl.customer_trx_id = rct.customer_trx_id;
3804      EXCEPTION
3805        WHEN NO_DATA_FOUND THEN
3806        NULL;
3807        When too_many_rows then
3808       Null;
3809       When others then
3810       Null;
3811      END;
3812      END IF;
3813    END IF;
3814 
3815    IF (p_line_rec.salesrep_id is not null) then
3816    BEGIN
3817     Select Name
3818     INTO x_line_val_rec.salesrep
3819     FROM  RA_SALESREPS
3820     WHERE Salesrep_id=p_line_rec.salesrep_id
3821         AND org_id=p_line_rec.org_id;
3822    EXCEPTION
3823      WHEN NO_DATA_FOUND THEN
3824      NULL;
3825      When too_many_rows then
3826     Null;
3827    END;
3828    END IF;
3829 
3830    IF (p_line_rec.tax_exempt_reason_code is not null) or
3831       (p_line_rec.tax_exempt_flag is not null)or
3832       (p_line_rec.fob_point_code is not null) or
3833       (p_line_rec.return_reason_code is not null) then
3834      BEGIN
3835        FOR lookups in c1(p_line_rec.tax_exempt_reason_code,
3836                      p_line_rec.tax_exempt_flag,
3837                      p_line_rec.fob_point_code,
3838                      p_line_rec.return_reason_code)
3839         LOOP
3840         IF lookups.lookup_type='TAX_REASON'  then
3841           x_line_val_rec.tax_exempt_reason:=lookups.meaning;
3842           ELSIF lookups.lookup_type='TAX_CONTROL_FLAG' then
3843           x_line_val_rec.tax_exempt:=lookups.meaning;
3844         ELSIF lookups.lookup_type='FOB' then
3845           x_line_val_rec.fob:=lookups.meaning;
3846         ELSIF lookups.lookup_type='CREDIT_MEMO_REASON' then
3847           x_line_val_rec.return_reason:=lookups.meaning;
3848           END IF;
3849         END LOOP;
3850     END;
3851     END IF;
3852 
3853     IF (p_line_rec.shipment_priority_code is not null) or
3854        (p_Line_rec.freight_terms_code is not null) THEN
3855       BEGIN
3856       FOR oe_lookups in c2(p_line_rec.shipment_priority_code,
3857                         p_Line_rec.freight_terms_code)
3858       LOOP
3859        IF oe_lookups.lookup_type='SHIPMENT_PRIORITY'then
3860          x_line_val_rec.shipment_priority:=oe_lookups.meaning;
3861         ELSIF oe_lookups.lookup_type='FREIGHT_TERMS' then
3862          x_line_val_rec.freight_terms:=oe_lookups.meaning;
3863        END IF;
3864       END LOOP;
3865       END;
3866     END IF;
3867 
3868     -- Changes for 2748513
3869 
3870      IF p_line_rec.flow_status_code is not NULL THEN
3871 
3872       x_line_val_rec.status :=
3873             OE_LINE_STATUS_PUB.Get_Line_Status(
3874                  p_line_id          =>  p_line_rec.line_id
3875                 ,p_flow_status_code =>  p_line_rec.flow_status_code);
3876      END IF;
3877 
3878 /*    IF (p_line_rec.flow_status_code is not null) THEN
3879       BEGIN
3880        IF p_line_rec.flow_status_code <> 'AWAITING_SHIPPING' AND
3881       p_line_rec.flow_status_code <> 'PRODUCTION_COMPLETE' AND
3882       p_line_rec.flow_status_code <> 'PICKED' AND
3883       p_line_rec.flow_status_code <> 'PICKED_PARTIAL' AND
3884       p_line_rec.flow_status_code <> 'PO_RECEIVED'
3885        THEN
3886           SELECT meaning
3887           INTO l_flow_meaning
3888           FROM fnd_lookup_values lv
3889           WHERE lookup_type = 'LINE_FLOW_STATUS'
3890           AND lookup_code = p_line_rec.flow_status_code
3891           AND LANGUAGE = userenv('LANG')
3892           AND VIEW_APPLICATION_ID = 660
3893           AND SECURITY_GROUP_ID =
3894               fnd_global.Lookup_Security_Group(lv.lookup_type,
3895                                                lv.view_application_id);
3896 
3897         status is AWAITING_SHIPPING or PRODUCTION_COMPLETE etc.
3898           get value from shipping table
3899        ELSE
3900           l_status := p_line_rec.flow_status_code;
3901 
3902           SELECT sum(decode(released_status, 'Y', 1, 0)), sum(1)
3903           INTO released_count, total_count
3904           FROM wsh_delivery_details
3905           WHERE source_line_id   = p_line_rec.line_id
3906           AND   source_code      = 'OE'
3907           AND   released_status  <> 'D';
3908 
3909           IF released_count = total_count THEN
3910            SELECT meaning
3911            INTO l_flow_meaning
3912            FROM fnd_lookup_values lv
3913            WHERE lookup_type = 'LINE_FLOW_STATUS'
3914            AND lookup_code = 'PICKED'
3915            AND LANGUAGE = userenv('LANG')
3916            AND VIEW_APPLICATION_ID = 660
3917            AND SECURITY_GROUP_ID =
3918                 fnd_global.Lookup_Security_Group(lv.lookup_type,
3919                                                  lv.view_application_id);
3920 
3921           ELSIF released_count < total_count and released_count <> 0 THEN
3922            SELECT meaning
3923            INTO l_flow_meaning
3924            FROM fnd_lookup_values lv
3925            WHERE lookup_type = 'LINE_FLOW_STATUS'
3926            AND lookup_code = 'PICKED_PARTIAL'
3927            AND LANGUAGE = userenv('LANG')
3928            AND VIEW_APPLICATION_ID = 660
3929            AND SECURITY_GROUP_ID =
3930                 fnd_global.Lookup_Security_Group(lv.lookup_type,
3931                                                  lv.view_application_id);
3932           ELSE
3933            SELECT meaning
3934            INTO l_flow_meaning
3935            FROM fnd_lookup_values lv
3936            WHERE lookup_type = 'LINE_FLOW_STATUS'
3937            AND lookup_code = l_status
3938            AND LANGUAGE = userenv('LANG')
3939            AND VIEW_APPLICATION_ID = 660
3940            AND SECURITY_GROUP_ID =
3941                 fnd_global.Lookup_Security_Group(lv.lookup_type,
3942                                                  lv.view_application_id);
3943           END IF;
3944        END IF;
3945        x_line_val_rec.status:= l_flow_meaning;
3946       END;
3947      END IF;
3948 */
3949 
3950    IF NVL(p_line_rec.item_identifier_type, 'INT') = 'INT' THEN
3951       BEGIN
3952          IF l_debug_level  > 0 THEN
3953              oe_debug_pub.add(  'IN OEXFLINB. ITEM IDENTIFIER IS INT' ) ;
3954          END IF;
3955          SELECT description
3956          --,concatenated_segments
3957          --,concatenated_segments   /*Bug 1766327 chhung*/
3958          INTO  x_line_val_rec.item_description
3959           --,x_line_val_rec.ordered_item_dsp
3960           --,x_line_val_rec.inventory_item /*bug 1766327 chhung*/
3961          FROM  mtl_system_items_vl
3962          WHERE inventory_item_id = p_line_rec.inventory_item_id
3963          AND organization_id = l_organization_id;
3964 
3965          --bug 10047225
3966          l_valid_kff:= fnd_flex_keyval.validate_ccid(
3967 	               APPL_SHORT_NAME=>'INV',
3968 	               KEY_FLEX_CODE=>'MSTK',
3969 	               STRUCTURE_NUMBER=>101,
3970 	               COMBINATION_ID=>p_line_rec.inventory_item_id,
3971 	               DISPLAYABLE=>'ALL',
3972 	               DATA_SET=>l_organization_id,
3973 	               VRULE=>NULL,
3974 	               SECURITY=>'IGNORE',
3975 	               GET_COLUMNS=>NULL,
3976 	               RESP_APPL_ID=>NULL,
3977 	               RESP_ID=>NULL,
3978 	               USER_ID=>NULL
3979 	             );
3980 
3981 	 	if l_valid_kff then
3982 	 		x_line_val_rec.ordered_item_dsp:= fnd_flex_keyval.concatenated_values;
3983 	 		x_line_val_rec.inventory_item:= fnd_flex_keyval.concatenated_values;
3984 
3985 	        end if;
3986          --end of bug 10047225
3987          IF l_debug_level  > 0 THEN
3988              oe_debug_pub.add(  'DESCRIPTION: '||X_LINE_VAL_REC.ITEM_DESCRIPTION ) ;
3989              oe_debug_pub.add(  'ORDERED_ITEM_DSP: '||X_LINE_VAL_REC.ORDERED_ITEM_DSP ) ;
3990          oe_debug_pub.add(  'INVENTORY_ITEM: '|| X_LINE_VAL_REC.INVENTORY_ITEM ) ;
3991      END IF;
3992 
3993       EXCEPTION
3994         WHEN NO_DATA_FOUND THEN
3995         Null;
3996         When too_many_rows then
3997        Null;
3998        When others then
3999        Null;
4000       END;
4001     ELSIF NVL(p_line_rec.item_identifier_type, 'INT') = 'CUST' THEN
4002       BEGIN
4003          IF l_debug_level  > 0 THEN
4004              oe_debug_pub.add(  'IN OEXFLINB. ITEM IDENTIFIER IS CUST' ) ;
4005          END IF;
4006          SELECT nvl(citems.customer_item_desc, sitems.description)
4007                ,citems.customer_item_number
4008            --,sitems.concatenated_segments  /*Bug 1766327 chhung*/
4009          INTO  x_line_val_rec.item_description
4010           ,x_line_val_rec.ordered_item_dsp
4011           --,x_line_val_rec.inventory_item /*Bug 1766327 chhung*/
4012          FROM  mtl_customer_items citems
4013               ,mtl_customer_item_xrefs cxref
4014               ,mtl_system_items_vl sitems
4015           ,mtl_parameters mp  -- bug 3918771
4016          WHERE citems.customer_item_id = cxref.customer_item_id
4017            AND cxref.inventory_item_id = sitems.inventory_item_id
4018            AND sitems.inventory_item_id = p_line_rec.inventory_item_id
4019            AND sitems.organization_id = l_organization_id
4020            AND citems.customer_item_id = p_line_rec.ordered_item_id
4021            AND citems.customer_id = p_line_rec.sold_to_org_id
4022        AND cxref.master_organization_id = mp.master_organization_id
4023            AND mp.organization_id = sitems.organization_id ; -- bug 3918771
4024 
4025        --bug 10047225
4026        l_valid_kff:= fnd_flex_keyval.validate_ccid(
4027                      APPL_SHORT_NAME=>'INV',
4028                      KEY_FLEX_CODE=>'MSTK',
4029                      STRUCTURE_NUMBER=>101,
4030                      COMBINATION_ID=>p_line_rec.inventory_item_id,
4031                      DISPLAYABLE=>'ALL',
4032                      DATA_SET=>l_organization_id,
4033                      VRULE=>NULL,
4034                      SECURITY=>'IGNORE',
4035                      GET_COLUMNS=>NULL,
4036                      RESP_APPL_ID=>NULL,
4037                      RESP_ID=>NULL,
4038                      USER_ID=>NULL
4039                    );
4040 
4041        	if l_valid_kff then
4042        		x_line_val_rec.inventory_item := fnd_flex_keyval.concatenated_values;
4043 
4044        end if;
4045        --end of bug 10047225
4046          IF l_debug_level  > 0 THEN
4047              oe_debug_pub.add(  'DESCRIPTION: '||X_LINE_VAL_REC.ITEM_DESCRIPTION ) ;
4048              oe_debug_pub.add(  'ORDERED_ITEM_DSP: '||X_LINE_VAL_REC.ORDERED_ITEM_DSP ) ;
4049          oe_debug_pub.add(  'INVENTORY_ITEM: '|| X_LINE_VAL_REC.INVENTORY_ITEM ) ;
4050      END IF;
4051 
4052       EXCEPTION
4053         WHEN NO_DATA_FOUND THEN
4054           /* Customer Cross Reference relationship changed */
4055           /* ----------------------------------------------*/
4056           /* We still need to preserve old value of ordered_item_dsp
4057              from ordered_item */
4058           IF p_line_rec.ordered_item IS NOT NULL THEN
4059              SELECT description
4060                    ,p_line_rec.ordered_item
4061                    --,concatenated_segments
4062              INTO  x_line_val_rec.item_description
4063                   ,x_line_val_rec.ordered_item_dsp
4064                   --,x_line_val_rec.inventory_item
4065               FROM  mtl_system_items_vl
4066               WHERE inventory_item_id = p_line_rec.inventory_item_id
4067                 AND organization_id = l_organization_id;
4068 
4069            --bug 10047225
4070            l_valid_kff:= fnd_flex_keyval.validate_ccid(
4071 	                 APPL_SHORT_NAME=>'INV',
4072 	                 KEY_FLEX_CODE=>'MSTK',
4073 	                 STRUCTURE_NUMBER=>101,
4074 	                 COMBINATION_ID=>p_line_rec.inventory_item_id,
4075 	                 DISPLAYABLE=>'ALL',
4076 	                 DATA_SET=>l_organization_id,
4077 	                 VRULE=>NULL,
4078 	                 SECURITY=>'IGNORE',
4079 	                 GET_COLUMNS=>NULL,
4080 	                 RESP_APPL_ID=>NULL,
4081 	                 RESP_ID=>NULL,
4082 	                 USER_ID=>NULL
4083 	               );
4084 
4085 	   	if l_valid_kff then
4086 	   		x_line_val_rec.inventory_item := fnd_flex_keyval.concatenated_values;
4087 	        end if;
4088            --end of bug 10047225
4089 
4090               IF l_debug_level  > 0 THEN
4091                 oe_debug_pub.add('DESCRIPTION: '||X_LINE_VAL_REC.ITEM_DESCRIPTION ) ;
4092                 oe_debug_pub.add('ORDERED_ITEM_DSP: '||X_LINE_VAL_REC.ORDERED_ITEM_DSP ) ;
4093             oe_debug_pub.add('INVENTORY_ITEM: '|| X_LINE_VAL_REC.INVENTORY_ITEM ) ;
4094           END IF;
4095             END IF;
4096         When too_many_rows then
4097        Null;
4098        When others then
4099        Null;
4100       END;
4101     ELSE
4102       BEGIN
4103        IF l_debug_level  > 0 THEN
4104            oe_debug_pub.add(  'IN OEXFLINB. ITEM IDENTIFIER IS '||P_LINE_REC.ITEM_IDENTIFIER_TYPE ) ;
4105            oe_debug_pub.add(  'ORDERED_ITEM_ID: '||P_LINE_REC.ORDERED_ITEM_ID ) ;
4106        END IF;
4107        IF p_line_rec.ordered_item_id IS NULL THEN
4108          IF l_debug_level  > 0 THEN
4109              oe_debug_pub.add(  'ORDERED_ITEM_ID IS NULL ' ) ;
4110          oe_debug_pub.add(  'ORDERED_ITEM: '||P_LINE_REC.ORDERED_ITEM ) ;
4111      END IF;
4112          SELECT nvl(items.description, sitems.description)
4113                ,items.cross_reference
4114            --,sitems.concatenated_segments  /*Bug 1766327 chhung*/
4115          INTO x_line_val_rec.item_description
4116          ,x_line_val_rec.ordered_item_dsp
4117          --,x_line_val_rec.inventory_item /*Bug 1766327 chhung*/
4118          FROM  mtl_cross_reference_types types
4119              , mtl_cross_references items
4120              , mtl_system_items_vl sitems
4121          WHERE types.cross_reference_type = items.cross_reference_type
4122            AND items.inventory_item_id = sitems.inventory_item_id
4123            AND sitems.organization_id = l_organization_id
4124            AND sitems.inventory_item_id = p_line_rec.inventory_item_id
4125            AND items.cross_reference_type = p_line_rec.item_identifier_type
4126            AND items.cross_reference = p_line_rec.ordered_item;
4127 
4128         --bug 10047225
4129         l_valid_kff:= fnd_flex_keyval.validate_ccid(
4130 	              APPL_SHORT_NAME=>'INV',
4131 	              KEY_FLEX_CODE=>'MSTK',
4132 	              STRUCTURE_NUMBER=>101,
4133 	              COMBINATION_ID=>p_line_rec.inventory_item_id,
4134 	              DISPLAYABLE=>'ALL',
4135 	              DATA_SET=>l_organization_id,
4136 	              VRULE=>NULL,
4137 	              SECURITY=>'IGNORE',
4138 	              GET_COLUMNS=>NULL,
4139 	              RESP_APPL_ID=>NULL,
4140 	              RESP_ID=>NULL,
4141 	              USER_ID=>NULL
4142 	            );
4143 
4144 		if l_valid_kff then
4145 			x_line_val_rec.inventory_item := fnd_flex_keyval.concatenated_values;
4146 	        end if;
4147         --end of bug 10047225
4148         IF l_debug_level  > 0 THEN
4149             oe_debug_pub.add(  'DESCRIPTION: '||X_LINE_VAL_REC.ITEM_DESCRIPTION ) ;
4150             oe_debug_pub.add(  'ORDERED_ITEM_DSP: '||X_LINE_VAL_REC.ORDERED_ITEM_DSP ) ;
4151         oe_debug_pub.add(  'INVENTORY_ITEM: '|| X_LINE_VAL_REC.INVENTORY_ITEM ) ;
4152     END IF;
4153        END IF;
4154 
4155       EXCEPTION
4156         WHEN NO_DATA_FOUND THEN
4157            /* Cross Reference relationship changed */
4158            /* ----------------------------------------------*/
4159            /* We still need to preserve old value of ordered_item_dsp
4160              from ordered_item */
4161           IF p_line_rec.ordered_item IS NOT NULL THEN
4162             SELECT description
4163                   ,p_line_rec.ordered_item
4164                   --,concatenated_segments
4165              INTO  x_line_val_rec.item_description
4166                   ,x_line_val_rec.ordered_item_dsp
4167                   --,x_line_val_rec.inventory_item
4168             FROM  mtl_system_items_vl
4169             WHERE inventory_item_id = p_line_rec.inventory_item_id
4170               AND organization_id = l_organization_id;
4171 
4172            --bug 10047225
4173            l_valid_kff:= fnd_flex_keyval.validate_ccid(
4174 	                 APPL_SHORT_NAME=>'INV',
4175 	                 KEY_FLEX_CODE=>'MSTK',
4176 	                 STRUCTURE_NUMBER=>101,
4177 	                 COMBINATION_ID=>p_line_rec.inventory_item_id,
4178 	                 DISPLAYABLE=>'ALL',
4179 	                 DATA_SET=>l_organization_id,
4180 	                 VRULE=>NULL,
4181 	                 SECURITY=>'IGNORE',
4182 	                 GET_COLUMNS=>NULL,
4183 	                 RESP_APPL_ID=>NULL,
4184 	                 RESP_ID=>NULL,
4185 	                 USER_ID=>NULL
4186 	               );
4187 
4188 	   	if l_valid_kff then
4189 	   		x_line_val_rec.inventory_item := fnd_flex_keyval.concatenated_values;
4190 	        end if;
4191            --end of bug 10047225
4192 
4193             IF l_debug_level  > 0 THEN
4194               oe_debug_pub.add('DESCRIPTION: '||X_LINE_VAL_REC.ITEM_DESCRIPTION ) ;
4195               oe_debug_pub.add('ORDERED_ITEM_DSP: '||X_LINE_VAL_REC.ORDERED_ITEM_DSP ) ;
4196               oe_debug_pub.add('INVENTORY_ITEM: '|| X_LINE_VAL_REC.INVENTORY_ITEM ) ;
4197         END IF;
4198           END IF;
4199         When too_many_rows then
4200        --Null;
4201     --start bug 3918771
4202        BEGIN
4203                SELECT nvl(items.description, sitems.description)
4204                          ,items.cross_reference
4205                          --,sitems.concatenated_segments
4206                    INTO   x_line_val_rec.item_description
4207                      ,x_line_val_rec.ordered_item_dsp
4208                      --,x_line_val_rec.inventory_item
4209                    FROM  mtl_cross_reference_types types
4210                         ,mtl_cross_references items
4211                         ,mtl_system_items_vl sitems
4212           WHERE types.cross_reference_type = items.cross_reference_type
4213             AND items.inventory_item_id = sitems.inventory_item_id
4214             AND sitems.organization_id = l_organization_id
4215             AND sitems.inventory_item_id = p_line_rec.inventory_item_id
4216             AND items.cross_reference_type = p_line_rec.item_identifier_type
4217             AND items.cross_reference = p_line_rec.ordered_item
4218             AND items.org_independent_flag = 'Y' ;
4219 
4220         --bug 10047225
4221         l_valid_kff:= fnd_flex_keyval.validate_ccid(
4222 	              APPL_SHORT_NAME=>'INV',
4223 	              KEY_FLEX_CODE=>'MSTK',
4224 	              STRUCTURE_NUMBER=>101,
4225 	              COMBINATION_ID=>p_line_rec.inventory_item_id,
4226 	              DISPLAYABLE=>'ALL',
4227 	              DATA_SET=>l_organization_id,
4228 	              VRULE=>NULL,
4229 	              SECURITY=>'IGNORE',
4230 	              GET_COLUMNS=>NULL,
4231 	              RESP_APPL_ID=>NULL,
4232 	              RESP_ID=>NULL,
4233 	              USER_ID=>NULL
4234 	            );
4235 
4236 		if l_valid_kff then
4237 			x_line_val_rec.inventory_item := fnd_flex_keyval.concatenated_values;
4238 	        end if;
4239         --end of bug 10047225
4240        EXCEPTION
4241               WHEN No_Data_Found THEN
4242                BEGIN
4243                   SELECT nvl(items.description, sitems.description)
4244                                     ,items.cross_reference
4245                                     --,sitems.concatenated_segments
4246                               INTO   x_line_val_rec.item_description
4247                                 ,x_line_val_rec.ordered_item_dsp
4248                                 --,x_line_val_rec.inventory_item
4249                               FROM  mtl_cross_reference_types types
4250                                    ,mtl_cross_references items
4251                                    ,mtl_system_items_vl sitems
4252                       WHERE types.cross_reference_type = items.cross_reference_type
4253                     AND items.inventory_item_id = sitems.inventory_item_id
4254                     AND sitems.organization_id = l_organization_id
4255                     AND sitems.inventory_item_id = p_line_rec.inventory_item_id
4256                     AND items.cross_reference_type = p_line_rec.item_identifier_type
4257                     AND items.cross_reference = p_line_rec.ordered_item
4258                     AND items.organization_id = l_organization_id ;
4259 
4260                --bug 10047225
4261                l_valid_kff:= fnd_flex_keyval.validate_ccid(
4262 	                     APPL_SHORT_NAME=>'INV',
4263 	                     KEY_FLEX_CODE=>'MSTK',
4264 	                     STRUCTURE_NUMBER=>101,
4265 	                     COMBINATION_ID=>p_line_rec.inventory_item_id,
4266 	                     DISPLAYABLE=>'ALL',
4267 	                     DATA_SET=>l_organization_id,
4268 	                     VRULE=>NULL,
4269 	                     SECURITY=>'IGNORE',
4270 	                     GET_COLUMNS=>NULL,
4271 	                     RESP_APPL_ID=>NULL,
4272 	                     RESP_ID=>NULL,
4273 	                     USER_ID=>NULL
4274 	                   );
4275 
4276 	       	if l_valid_kff then
4277 	       		x_line_val_rec.inventory_item := fnd_flex_keyval.concatenated_values;
4278 	        end if;
4279                --end of bug 10047225
4280                EXCEPTION
4281                 WHEN No_Data_Found THEN
4282                        IF p_line_rec.ordered_item IS NOT NULL THEN
4283                       SELECT description
4284                      ,p_line_rec.ordered_item
4285                      --,concatenated_segments
4286                       INTO  x_line_val_rec.item_description
4287                      ,x_line_val_rec.ordered_item_dsp
4288                      --,x_line_val_rec.inventory_item
4289                       FROM  mtl_system_items_vl
4290                                       WHERE inventory_item_id = p_line_rec.inventory_item_id
4291                                         AND organization_id = l_organization_id;
4292                       --bug 10047225
4293                       l_valid_kff:= fnd_flex_keyval.validate_ccid(
4294 		      			APPL_SHORT_NAME=>'INV',
4295 		      			KEY_FLEX_CODE=>'MSTK',
4296 		      			STRUCTURE_NUMBER=>101,
4297 		      			COMBINATION_ID=>p_line_rec.inventory_item_id,
4298 		      			DISPLAYABLE=>'ALL',
4299 		      			DATA_SET=>l_organization_id,
4300 		      			VRULE=>NULL,
4301 		      			SECURITY=>'IGNORE',
4302 		      			GET_COLUMNS=>NULL,
4303 		      			RESP_APPL_ID=>NULL,
4304 		      			RESP_ID=>NULL,
4305 		      			USER_ID=>NULL
4306 		      			);
4307 
4308 		      			if l_valid_kff then
4309 		      				x_line_val_rec.inventory_item := fnd_flex_keyval.concatenated_values;
4310 			                end if;
4311                       --end of bug 10047225
4312                        END IF ;
4313                        When Others then
4314                                     Null ;
4315                END ;  -- end innermost exception block
4316        END ;
4317           -- end bug 3918771
4318     When others then
4319        Null;
4320       END;  -- end outermost exception block
4321     END IF;
4322 
4323    /*IF (p_line_rec.tax_code IS NOT NULL) THEN
4324        BEGIN
4325            x_line_val_rec.tax_group := OE_Id_To_Value.tax_group(
4326                              p_tax_code => p_line_rec.tax_code);
4327        EXCEPTION
4328          WHEN OTHERS THEN
4329              NULL;
4330        END;
4331    END IF; */
4332 
4333    IF (p_line_rec.ship_to_org_id IS NOT NULL) THEN
4334        BEGIN
4335          /*OE_Id_To_Value.Ship_To_Customer_Name
4336           (
4337            p_ship_to_org_id => p_line_rec.ship_to_org_id,
4338            x_ship_to_customer_name=>x_line_val_rec.ship_to_customer_name
4339            );*/
4340 
4341          get_customer_details(
4342            p_site_use_id => p_line_rec.ship_to_org_id,
4343            p_site_use_code => 'SHIP_TO',
4344            x_customer_id => x_line_val_rec.ship_To_customer_id,
4345            x_customer_name => x_line_val_rec.ship_To_customer_name,
4346            x_customer_number => x_line_val_rec.ship_To_customer_number
4347                                  );
4348 
4349        EXCEPTION
4350          WHEN OTHERS THEN
4351              NULL;
4352        END;
4353 
4354    END IF;
4355 IF (p_line_rec.end_customer_site_use_id IS NOT NULL) THEN
4356          OE_ID_TO_VALUE.END_CUSTOMER_SITE_USE
4357            (  p_end_customer_site_use_id       => p_line_rec.end_customer_site_use_id,
4358           x_end_customer_address1 => x_line_val_rec.END_CUSTOMER_SITE_ADDRESS1,
4359           x_end_customer_address2 => x_line_val_rec.END_CUSTOMER_SITE_ADDRESS2,
4360           x_end_customer_address3 => x_line_val_rec.END_CUSTOMER_SITE_ADDRESS3,
4361           x_end_customer_address4 => x_line_val_rec.END_CUSTOMER_SITE_ADDRESS4,
4362           x_end_customer_location     => x_line_val_rec.END_CUSTOMER_SITE_LOCATION,
4363           x_end_customer_city => x_line_val_rec.END_CUSTOMER_SITE_CITY,
4364           x_end_customer_state => x_line_val_rec.END_CUSTOMER_SITE_STATE,
4365           x_end_customer_postal_code => x_line_val_rec.END_CUSTOMER_SITE_POSTAL_CODE,
4366           x_end_customer_country => x_line_val_rec.END_CUSTOMER_SITE_COUNTRY
4367            );
4368 
4369  END IF;
4370 
4371   IF (p_line_rec.end_customer_id IS NOT NULL) THEN
4372         OE_ID_TO_VALUE.END_CUSTOMER
4373            (  p_end_customer_id       => p_line_rec.end_customer_id,
4374           x_end_customer_name => x_line_val_rec.END_CUSTOMER_NAME,
4375           x_end_customer_number => x_line_val_rec.END_CUSTOMER_NUMBER
4376           );
4377   END IF;
4378 
4379   IF (p_line_rec.end_customer_contact_id IS NOT NULL) THEN
4380         x_line_val_rec.END_CUSTOMER_CONTACT :=  OE_ID_TO_VALUE.END_CUSTOMER_CONTACT
4381                                (  p_end_customer_contact_id       => p_line_rec.end_customer_contact_id);
4382   END IF;
4383 
4384 
4385    IF (p_line_rec.invoice_to_org_id IS NOT NULL) THEN
4386        BEGIN
4387          /*OE_Id_To_Value.Invoice_To_Customer_Name
4388           (
4389            p_invoice_to_org_id => p_line_rec.invoice_to_org_id,
4390            x_invoice_to_customer_name=>x_line_val_rec.invoice_to_customer_name
4391            ); */
4392 
4393          get_customer_details(
4394              p_site_use_id => p_line_rec.invoice_to_org_id,
4395              p_site_use_code =>'BILL_TO',
4396          x_customer_id =>x_line_val_rec.invoice_To_customer_id,
4397          x_customer_name =>x_line_val_rec.invoice_To_customer_name,
4398          x_customer_number => x_line_val_rec.invoice_To_customer_number
4399                );
4400 
4401 
4402        EXCEPTION
4403          WHEN OTHERS THEN
4404              NULL;
4405        END;
4406 
4407    END IF;
4408 
4409    IF p_line_rec.shipping_method_code IS NOT NULL THEN
4410      BEGIN
4411          Select meaning
4412          INTO x_line_val_rec.shipping_method
4413          FROM   oe_ship_methods_v
4414          WHERE  lookup_code=p_line_rec.shipping_method_code;
4415       EXCEPTION
4416         WHEN NO_DATA_FOUND THEN
4417         Null;
4418         When too_many_rows then
4419        Null;
4420        When others then
4421        Null;
4422       END;
4423    END IF;
4424   --3557382
4425    IF p_line_rec.service_reference_type_code IS NOT NULL THEN
4426      BEGIN
4427          Select meaning
4428          INTO x_line_val_rec.service_reference_type
4429          FROM   oe_lookups
4430          WHERE  lookup_code=p_line_rec.service_Reference_type_code
4431                 and lookup_type = 'SERVICE_REFERENCE_TYPE_CODE';
4432       EXCEPTION
4433         WHEN NO_DATA_FOUND THEN
4434         Null;
4435         When too_many_rows then
4436        Null;
4437        When others then
4438        Null;
4439       END;
4440    END IF;
4441    --3557382
4442  --3605052
4443    IF p_line_rec.service_period IS NOT NULL THEN
4444      BEGIN
4445 	 -- sol_ord_er #16014165
4446 	     If p_line_rec.subscription_enable_flag='Y' THEN
4447 			SELECT unit_of_measure_tl description
4448 			  INTO x_line_val_rec.service_period_dsp
4449 			FROM OKX_UNITS_OF_MEASURE_V
4450 			WHERE uom_code = p_line_rec.service_period;
4451 	    Else
4452 		-- sol_ord_er #16014165 end
4453          Select description
4454          INTO x_line_val_rec.service_period_dsp
4455          FROM mtl_item_uoms_view
4456          WHERE uom_code  =p_line_rec.service_period
4457                 and inventory_item_id = p_line_rec.inventory_item_id
4458             and organization_id = l_organization_id;
4459 		End If; --sol_ord_er #16014165
4460       EXCEPTION
4461         WHEN NO_DATA_FOUND THEN
4462         Null;
4463         When too_many_rows then
4464        Null;
4465        When others then
4466        Null;
4467       END;
4468    END IF;
4469    --3605052
4470    IF p_line_rec.freight_carrier_code IS NOT NULL THEN
4471      BEGIN
4472          Select description
4473          INTO x_line_val_rec.freight_carrier
4474          FROM   org_freight
4475          WHERE  freight_code=p_line_rec.freight_carrier_code
4476         and organization_id = p_line_rec.ship_from_org_id;
4477       EXCEPTION
4478         WHEN NO_DATA_FOUND THEN
4479         Null;
4480         When too_many_rows then
4481        Null;
4482        When others then
4483        Null;
4484       END;
4485    END IF;
4486 
4487    IF (p_line_rec.source_type_code is not null) THEN
4488      BEGIN
4489       select meaning
4490       into x_line_val_rec.source_type
4491       from oe_lookups
4492       where lookup_code=p_line_rec.source_type_code
4493      AND   lookup_type='SOURCE_TYPE';
4494 
4495      EXCEPTION
4496        WHEN NO_DATA_FOUND THEN
4497        Null;
4498        When too_many_rows then
4499        Null;
4500       When others then
4501       Null;
4502      END;
4503    END IF;
4504 
4505    IF (p_line_rec.demand_class_code is not null) THEN
4506      BEGIN
4507       select meaning
4508       into x_line_val_rec.demand_class
4509       from oe_fnd_common_lookups_v
4510       where lookup_code=p_line_rec.demand_class_code
4511      and lookup_type='DEMAND_CLASS';
4512 
4513      EXCEPTION
4514        WHEN NO_DATA_FOUND THEN
4515        Null;
4516        When too_many_rows then
4517        Null;
4518       When others then
4519       Null;
4520      END;
4521    END IF;
4522 
4523 
4524 
4525    --   added by jmore
4526 
4527    IF (p_line_rec.intermed_ship_to_org_id is not null) THEN
4528      BEGIN
4529       select location,cust_acct_site_id
4530       into x_line_val_rec.intmed_ship_to,
4531          l_address_id
4532       from hz_cust_site_uses_all
4533       where site_use_id=p_line_rec.intermed_ship_to_org_id;
4534      x_line_val_rec.intmed_ship_to_location := x_line_val_rec.intmed_ship_to;
4535 /*1621182*/
4536      select loc.address1,loc.address2,loc.address3,loc.address4,
4537             DECODE(loc.city, NULL, NULL,loc.city || ', ') ||
4538             DECODE(loc.state, NULL, loc.province || ', ', loc.state || ', ') || -- 3603600
4539            DECODE(loc.postal_code, NULL, NULL,loc.postal_code || ', ') ||
4540            DECODE(loc.country, NULL, NULL,loc.country)
4541       into x_line_val_rec.intmed_ship_to_address1,
4542            x_line_val_rec.intmed_ship_to_address2,
4543            x_line_val_rec.intmed_ship_to_address3,
4544            x_line_val_rec.intmed_ship_to_address4,
4545            x_line_val_rec.intmed_ship_to_address5
4546        from hz_locations loc,
4547             hz_party_sites ps,
4548             hz_cust_acct_sites cas
4549       where cas.cust_acct_site_id = l_address_id
4550           and   cas.party_site_id = ps.party_site_id
4551           and   ps.location_id = loc.location_id;
4552 
4553 /*1621182*/
4554      EXCEPTION
4555        WHEN NO_DATA_FOUND THEN
4556        Null;
4557        When too_many_rows then
4558        Null;
4559       When others then
4560       Null;
4561      END;
4562    END IF;
4563 
4564 
4565    IF (p_line_rec.intermed_ship_to_contact_id is not null) THEN
4566      BEGIN
4567       select name
4568       into x_line_val_rec.intmed_ship_to_contact
4569       from oe_contacts_v
4570       where contact_id=p_line_rec.intermed_ship_to_contact_id;
4571 
4572 
4573      EXCEPTION
4574        WHEN NO_DATA_FOUND THEN
4575        Null;
4576        When too_many_rows then
4577        Null;
4578       When others then
4579       Null;
4580      END;
4581    END IF;
4582 
4583 
4584    IF (p_line_rec.deliver_to_org_id is not null) THEN
4585      BEGIN
4586       SELECT  /* MOAC_SQL_CHANGE */
4587        cust_acct.cust_account_id,
4588        party.party_name,
4589        cust_acct.account_number,
4590        cust_site.location,
4591        location.address1,
4592        location.address2,
4593        location.address3,
4594        location.address4,
4595        DECODE(location.city, NULL, NULL,location.city || ', ')
4596        || DECODE(location.state, NULL, location.province || ', ', location.state || ', ') --3603600
4597        || DECODE(location.postal_code, NULL, NULL,location.postal_code || ', ')
4598        || DECODE(location.country, NULL, NULL,location.country)
4599         INTO
4600        x_line_val_rec.deliver_to_customer_id,
4601        x_line_val_rec.deliver_to_customer_name,
4602        x_line_val_rec.deliver_to_customer_number,
4603        x_line_val_rec.deliver_to,
4604        x_line_val_rec.deliver_to_address1,
4605        x_line_val_rec.deliver_to_address2,
4606        x_line_val_rec.deliver_to_address3,
4607        x_line_val_rec.deliver_to_address4,
4608        x_line_val_rec.deliver_to_address5
4609         FROM
4610        hz_cust_site_uses_all cust_site,
4611        hz_cust_acct_sites_all cust_acct_site,
4612        hz_party_sites party_site,
4613        hz_parties party,
4614        hz_cust_accounts cust_acct,
4615        hz_locations location
4616        WHERE
4617        cust_site.site_use_id=p_line_rec.deliver_to_org_id
4618          and cust_site.site_use_code = 'DELIVER_TO'
4619          and cust_site.cust_acct_site_id = cust_acct_site.cust_acct_site_id
4620          and cust_acct_site.party_site_id = party_site.party_site_id
4621          and party_site.party_id = party.party_id
4622          and cust_acct.cust_account_id = cust_acct_site.cust_account_id
4623          and party_site.location_id = location.location_id;
4624 
4625     x_line_val_rec.deliver_to_location := x_line_val_rec.deliver_to;
4626 
4627      EXCEPTION
4628        WHEN NO_DATA_FOUND THEN
4629        Null;
4630        When too_many_rows then
4631        Null;
4632       When others then
4633       Null;
4634      END;
4635    END IF;
4636 
4637 
4638    IF (p_line_rec.deliver_to_contact_id is not null) THEN
4639      BEGIN
4640       select name
4641       into x_line_val_rec.deliver_to_contact
4642       from oe_contacts_v
4643       where contact_id=p_line_rec.deliver_to_contact_id;
4644 
4645 
4646      EXCEPTION
4647        WHEN NO_DATA_FOUND THEN
4648        Null;
4649        When too_many_rows then
4650        Null;
4651       When others then
4652       Null;
4653      END;
4654    END IF;
4655 
4656 -- Concatenated Revision with name for Bug-2249065
4657    IF (p_line_rec.agreement_id is not null) THEN
4658      BEGIN
4659       select name||' : '||revision
4660       into x_line_val_rec.agreement
4661       from oe_agreements
4662       where agreement_id=p_line_rec.agreement_id;
4663 
4664 
4665      EXCEPTION
4666        WHEN NO_DATA_FOUND THEN
4667        Null;
4668        When too_many_rows then
4669        Null;
4670       When others then
4671       Null;
4672      END;
4673    END IF;
4674 
4675 
4676    IF (p_line_rec.source_document_type_id is not null) THEN
4677      BEGIN
4678       select name
4679       into x_line_val_rec.source_document_type
4680       from oe_order_sources
4681       where order_source_id=p_line_rec.source_document_type_id;
4682 
4683 
4684      EXCEPTION
4685        WHEN NO_DATA_FOUND THEN
4686        Null;
4687        When too_many_rows then
4688        Null;
4689       When others then
4690       Null;
4691      END;
4692    END IF;
4693 
4694 
4695    IF (p_line_rec.arrival_set_id is not null) THEN
4696      BEGIN
4697       select set_name
4698       into x_line_val_rec.arrival_set
4699       from oe_sets
4700       where set_id=p_line_rec.arrival_set_id;
4701 
4702 
4703      EXCEPTION
4704        WHEN NO_DATA_FOUND THEN
4705        Null;
4706        When too_many_rows then
4707        Null;
4708       When others then
4709       Null;
4710      END;
4711    END IF;
4712 
4713 
4714 
4715    IF (p_line_rec.ship_set_id is not null) THEN
4716      BEGIN
4717       select set_name
4718       into x_line_val_rec.ship_set
4719       from oe_sets
4720       where set_id=p_line_rec.ship_set_id;
4721 
4722 
4723      EXCEPTION
4724        WHEN NO_DATA_FOUND THEN
4725        Null;
4726        When too_many_rows then
4727        Null;
4728       When others then
4729       Null;
4730      END;
4731    END IF;
4732 
4733 
4734    IF (p_line_rec.commitment_id is not null) THEN
4735      BEGIN
4736       select trx_number
4737       into x_line_val_rec.commitment
4738       from ra_customer_trx
4739       where customer_trx_id=p_line_rec.commitment_id;
4740 
4741 
4742      EXCEPTION
4743        WHEN NO_DATA_FOUND THEN
4744        Null;
4745        When too_many_rows then
4746        Null;
4747       When others then
4748       Null;
4749      END;
4750    END IF;
4751 
4752    -- lkxu, commitment
4753    IF (p_line_rec.payment_level_code is not null) THEN
4754      BEGIN
4755       -- lkxu, commitment enhancement.
4756      select commitment_applied_amount
4757          into x_line_val_rec.commitment_applied_amount
4758      from oe_payments
4759      where payment_trx_id = p_line_rec.payment_commitment_id
4760      and   ((line_id = p_line_rec.line_id
4761             and payment_level_code = 'LINE')
4762            OR (header_id = p_line_rec.header_id
4763               and payment_level_code = 'ORDER'));
4764 
4765 
4766      EXCEPTION
4767        WHEN NO_DATA_FOUND THEN
4768      x_line_val_rec.commitment_applied_amount := 0.0;
4769        When others then
4770       Null;
4771      END;
4772    END IF;
4773 
4774    IF p_line_rec.header_id IS NOT NULL AND
4775       p_line_rec.line_id IS NOT NULL THEN
4776      OE_CHARGE_PVT.Get_Charge_Amount(
4777                          p_api_version_number=>1.0
4778                      ,   p_init_msg_list=>'F'
4779                      ,   p_all_charges=>'F'
4780                      ,   p_header_id=> p_line_rec.header_id
4781                      ,   p_line_id=>p_line_rec.line_id
4782                      ,   x_return_status=>l_return_status
4783                      ,   x_msg_count=>l_msg_count
4784                      ,   x_msg_data=>l_msg_data
4785                      ,   x_charge_amount=>x_line_val_rec.line_charges
4786                      );
4787    END IF;
4788 
4789    IF p_line_rec.header_id IS NOT NULL THEN
4790 
4791        IF p_calling_block = 'LINES_SUMMARY' THEN  --FP 3351788
4792 
4793          IF g_current_header_id <> p_line_rec.header_id THEN
4794 
4795         OE_OE_TOTALS_SUMMARY.Order_Totals
4796                               (
4797                               p_header_id=>p_line_rec.header_id ,
4798                               p_subtotal =>x_line_val_rec.subtotal,
4799                               p_discount =>x_line_val_rec.discount,
4800                               p_charges  =>x_line_val_rec.charges,
4801                               p_tax      =>x_line_val_rec.tax
4802                               );
4803 
4804            --MRG BGN
4805             IF OE_FEATURES_PVT.IS_MARGIN_AVAIL THEN
4806                OE_MARGIN_PVT.Get_Order_Margin(p_header_id=>p_line_rec.header_id,
4807                                    p_org_id => p_line_rec.org_id,
4808                                    x_order_margin_percent=>l_order_margin_percent,
4809                                    x_order_margin_amount=>l_order_margin_amount);
4810 
4811                x_line_val_rec.margin := l_order_margin_amount;
4812                x_line_val_rec.margin_percent := l_order_margin_percent;
4813             END IF;
4814 
4815             --MRG END
4816          END IF;
4817  	    -- for 5331980 start*
4818      ELSIF p_calling_block = 'LINE' THEN
4819 
4820            IF  OE_GLOBALS.G_CALCULATE_LINE_TOTAL THEN
4821 
4822                OE_OE_TOTALS_SUMMARY.Order_Totals
4823                                   (
4824                                   p_header_id=>p_line_rec.header_id ,
4825                                   p_subtotal =>x_line_val_rec.subtotal,
4826                                   p_discount =>x_line_val_rec.discount,
4827                                   p_charges  =>x_line_val_rec.charges,
4828                                   p_tax      =>x_line_val_rec.tax
4829                                   );
4830 
4831                OE_GLOBALS.G_CALCULATE_LINE_TOTAL := FALSE;
4832 
4833                g_subtotal := x_line_val_rec.subtotal;
4834                g_discount := x_line_val_rec.discount;
4835                g_charges  := x_line_val_rec.charges;
4836                g_total_tax := x_line_val_rec.tax;
4837 
4838             ELSE
4839 
4840                 x_line_val_rec.subtotal := g_subtotal;
4841                 x_line_val_rec.discount := g_discount;
4842                 x_line_val_rec.charges  := g_charges;
4843                 x_line_val_rec.tax := g_total_tax;
4844 
4845             END IF;
4846 
4847             IF  OE_FEATURES_PVT.IS_MARGIN_AVAIL THEN
4848                 OE_MARGIN_PVT.Get_Order_Margin(p_header_id=>p_line_rec.header_id,
4849                                    x_order_margin_percent=>l_order_margin_percent,
4850                                    x_order_margin_amount=>l_order_margin_amount);
4851 
4852                 x_line_val_rec.margin := l_order_margin_amount;
4853                 x_line_val_rec.margin_percent := l_order_margin_percent;
4854             END IF;
4855 	    -- for 5331980 end*
4856     ELSE
4857 
4858 
4859              OE_OE_TOTALS_SUMMARY.Order_Totals
4860                                   (
4861                                   p_header_id=>p_line_rec.header_id ,
4862                                   p_subtotal =>x_line_val_rec.subtotal,
4863                                   p_discount =>x_line_val_rec.discount,
4864                                   p_charges  =>x_line_val_rec.charges,
4865                                   p_tax      =>x_line_val_rec.tax
4866                                   );
4867 
4868    --MRG BGN
4869     IF OE_FEATURES_PVT.IS_MARGIN_AVAIL THEN
4870       OE_MARGIN_PVT.Get_Order_Margin(p_header_id=>p_line_rec.header_id,
4871                                    p_org_id => p_line_rec.org_id,
4872                                    x_order_margin_percent=>l_order_margin_percent,
4873                                    x_order_margin_amount=>l_order_margin_amount);
4874 
4875       x_line_val_rec.margin := l_order_margin_amount;
4876       x_line_val_rec.margin_percent := l_order_margin_percent;
4877     END IF;
4878    --MRG END
4879   END IF;
4880    END IF;
4881 
4882    IF   p_line_rec.order_quantity_uom IS NOT NULL AND
4883         p_line_rec.order_quantity_uom='ENR' THEN
4884     BEGIN
4885      select tdb.booking_id, bst.name
4886      into   x_line_val_rec.booking_id,x_line_val_rec.ota_name
4887      from  ota_delegate_bookings tdb,
4888            ota_booking_status_types bst
4889      where tdb.line_id = p_line_rec.line_id
4890      and    bst.booking_status_type_id = tdb.booking_status_type_id;
4891     EXCEPTION
4892      When No_Data_Found THEN
4893       Null;
4894      When TOO_MANY_ROWS THEN
4895       Null;
4896      When Others THEN
4897       Null;
4898     END;
4899    END IF;
4900 
4901    g_current_header_id := p_line_rec.header_id;
4902 
4903     IF p_line_rec.schedule_status_code is not null THEN
4904 
4905         l_sales_order_id :=
4906            OE_ORDER_SCH_UTIL.Get_mtl_sales_order_id(p_line_rec.header_id);
4907         -- INVCONV - SAO MERGED CALLS    FOR OE_LINE_UTIL.Get_Reserved_Quantity and OE_LINE_UTIL.Get_Reserved_Quantity2
4908 
4909              OE_LINE_UTIL.Get_Reserved_Quantities(p_header_id => l_sales_order_id
4910                                               ,p_line_id   => p_line_rec.line_id
4911                                               ,p_org_id    => p_line_rec.ship_from_org_id
4912                                               ,x_reserved_quantity =>  x_line_val_rec.reserved_quantity
4913                                               ,x_reserved_quantity2 => x_line_val_rec.reserved_quantity2
4914                                                                                             );
4915 
4916         /*x_line_val_rec.reserved_quantity :=
4917               OE_LINE_UTIL.Get_Reserved_Quantity
4918                                 (p_header_id => l_sales_order_id
4919                                 ,p_line_id   => p_line_rec.line_id
4920                                , p_org_id => p_line_rec.ship_from_org_id);
4921         x_line_val_rec.reserved_quantity2 :=
4922               OE_LINE_UTIL.Get_Reserved_Quantity2  -- INVCONV
4923                                 (p_header_id => l_sales_order_id
4924                                 ,p_line_id   => p_line_rec.line_id
4925                                , p_org_id => p_line_rec.ship_from_org_id); */
4926 
4927 
4928     END IF;
4929 
4930     IF p_line_rec.line_id IS NOT NULL THEN
4931 
4932      x_line_val_rec.fulfillment_list :=
4933         oe_set_util.get_fulfillment_list(p_line_id => p_line_rec.line_id);
4934     END IF;
4935 
4936    IF p_line_rec.calculate_price_flag IS NOT NULL THEN
4937     BEGIN
4938         SELECT  MEANING
4939         INTO    x_line_val_rec.calculate_price_descr
4940         FROM    OE_LOOKUPS
4941         WHERE   LOOKUP_CODE = p_line_rec.calculate_price_flag
4942         AND     LOOKUP_TYPE = 'CALCULATE_PRICE_FLAG';
4943     EXCEPTION
4944        WHEN NO_DATA_FOUND THEN
4945        Null;
4946        When too_many_rows then
4947        Null;
4948        When others then
4949        Null;
4950     END;
4951    END IF;
4952 
4953    IF p_line_rec.svc_ref_order_number IS NOT NULL
4954    AND p_line_rec.svc_ref_order_type IS NOT NULL  THEN
4955     BEGIN
4956      select /* MOAC_SQL_CHANGE */ header_id  into x_line_val_rec.svc_header_id
4957      from oe_order_headers_all oh,oe_order_types_v ot
4958      where order_number=p_line_rec.svc_ref_order_number
4959      and oh.order_type_id=ot.order_type_id
4960      and ot.name=p_line_rec.svc_ref_order_type;
4961     EXCEPTION
4962      WHEN NO_DATA_FOUND THEN
4963       Null;
4964      WHEN TOO_MANY_ROWS THEN
4965       Null;
4966      WHEN OTHERS THEN
4967       Null;
4968     END;
4969    END IF;
4970 
4971    IF p_line_rec.order_source_id IS NOT NULL AND
4972      p_line_rec.source_document_type_id IS NULL THEN
4973   -- Order Import
4974     Begin
4975     Select name into x_line_val_rec.order_source
4976     from oe_order_sources
4977     where order_source_id=p_line_rec.order_source_id;
4978     Exception
4979     when no_data_found then
4980     null;
4981      when too_many_rows then
4982     null;
4983     when others then
4984      null;
4985     END;
4986    ELSIF p_line_rec.source_document_type_id=2 AND
4987 -- The following is commented for bug#1939079
4988 --  p_line_rec.order_source_id IS NULL AND
4989     p_line_rec.source_document_id IS NOT NULL THEN
4990 -- Copy Orders
4991     Begin
4992     Select name into x_line_val_rec.order_source
4993     from oe_order_sources
4994     where order_source_id=2;
4995 
4996     Select order_number into x_line_val_rec.order_source_ref
4997     from oe_order_headers
4998     where header_id=p_line_rec.source_document_id;
4999 
5000     Select line_number into x_line_val_rec.order_source_line_ref
5001     from oe_order_lines
5002     where line_id=p_line_rec.source_document_line_id;
5003     Exception
5004     when no_data_found then
5005     null;
5006      when too_many_rows then
5007     null;
5008     when others then
5009      null;
5010     END;
5011 
5012    ELSIF p_line_rec.source_document_type_id=10 AND
5013     p_line_rec.order_source_id=10  THEN
5014 -- Internal Orders
5015     Begin
5016     Select name into x_line_val_rec.order_source
5017     from oe_order_sources
5018     where order_source_id=10;
5019 
5020     Exception
5021     when no_data_found then
5022     null;
5023      when too_many_rows then
5024     null;
5025     when others then
5026      null;
5027     END;
5028    ELSIF p_line_rec.source_document_type_id IS NOT NULL
5029         AND p_line_rec.source_document_type_id<>2 THEN
5030 
5031     Begin
5032     Select name into x_line_val_rec.order_source
5033     from oe_order_sources
5034     where order_source_id=p_line_rec.source_document_type_id;
5035 
5036     Exception
5037     when no_data_found then
5038     null;
5039      when too_many_rows then
5040     null;
5041     when others then
5042     null;
5043 
5044     END;
5045    ELSE
5046     Null;
5047    END IF;
5048 
5049    IF p_line_rec.Original_inventory_item_id IS NOT NULL
5050    OR  p_line_rec.original_ordered_item_id  IS NOT NULL THEN
5051     OE_ID_TO_VALUE.Ordered_Item
5052     (p_Item_Identifier_type    => p_line_rec.original_item_identifier_Type
5053     ,p_inventory_item_id       => p_line_rec.original_Inventory_Item_Id
5054     ,p_organization_id         => l_organization_id
5055     ,p_ordered_item_id         => p_line_rec.original_ordered_item_id
5056     ,p_sold_to_org_id          => p_line_rec.sold_to_org_id
5057     ,p_ordered_item            => p_line_rec.original_ordered_item
5058     ,x_ordered_item            => x_line_val_rec.original_ordered_item
5059     ,x_inventory_item          => x_line_val_rec.original_inventory_item);
5060    END IF;
5061 
5062    IF p_line_rec.Original_item_identifier_Type IS NOT NULL THEN
5063     OE_ID_TO_VALUE.item_identifier
5064          (p_Item_Identifier_type   => p_line_rec.Original_item_identifier_Type
5065          ,x_Item_Identifier        => x_line_val_rec.Original_item_type);
5066    END IF;
5067 
5068    IF p_line_rec.item_relationship_type IS NOT NULL THEN
5069     OE_ID_TO_VALUE.item_relationship_type
5070          (p_Item_relationship_type     => p_line_rec.item_relationship_type
5071          ,x_Item_relationship_type_dsp => x_line_val_rec.item_relationship_type_dsp);
5072    END IF;
5073    --Spagadal
5074    IF p_line_rec.blanket_number is not null then
5075                 oe_blanket_util_misc.get_blanketAgrName
5076                               (p_blanket_number   => p_line_rec.blanket_number,
5077                                x_blanket_agr_name => x_line_val_rec.blanket_agreement_name);
5078    END If;
5079 --{ recurring charges
5080  /* IF p_line_rec.charge_periodicity_code IS NOT NULL AND
5081      p_line_rec.charge_periodicity_code <> FND_API.G_MISS_CHAR AND
5082      OE_SYS_PARAMETERS.Value('RECURRING_CHARGES',p_line_rec.org_id) = 'Y' THEN
5083 
5084      SELECT unit_of_measure
5085      INTO   l_charge_periodicity
5086      FROM   MTL_UNITS_OF_MEASURE_VL
5087      WHERE  uom_code = p_line_rec.charge_periodicity_code;
5088      --AND  uom_class = FND_PROFILE.Value('ONT_UOM_CLASS_CHARGE_PERIODICITY');
5089 
5090      x_line_val_rec.charge_periodicity := l_charge_periodicity;
5091 
5092      IF l_debug_level > 0 THEN
5093     OE_DEBUG_PUB.Add ('PCode:'||p_line_rec.charge_periodicity_code,5);
5094         OE_DEBUG_PUB.Add ('Populate value for Charge Periodicity',5);
5095     OE_DEBUG_PUB.Add ('Periodicity='||l_charge_periodicity,3);
5096      END IF;
5097   END IF;
5098  */
5099 -- recurring charges }
5100 
5101 --retro{
5102 
5103 /* Sql statements to get the vaues of Retrobilled price for original lines
5104 and Retrobilled order and Retrobilled line information for retrobill lines.    */
5105 
5106   IF(OE_CODE_CONTROL.Code_Release_Level >= 110510) THEN
5107    IF (p_line_rec.line_id IS NOT NULL AND oe_sys_parameters.value('ENABLE_RETROBILLING',p_line_rec.org_id) = 'Y') THEN
5108         BEGIN
5109            SELECT sum(decode(line_category_code,'RETURN',-1*nvl(unit_selling_price,0),nvl(unit_selling_price,0)))
5110        INTO  l_retrobilled_price_diff
5111        FROM oe_order_lines
5112        WHERE  order_source_id=27 AND
5113               orig_sys_document_ref=to_char(p_line_rec.header_id) AND
5114               orig_sys_line_ref = to_char(p_line_rec.line_id) AND
5115                     retrobill_request_id IS NOT NULL;
5116 
5117            SELECT unit_selling_price
5118            INTO l_unit_selling_price
5119            FROM oe_order_lines_all
5120            WHERE line_id=p_line_rec.line_id;
5121 
5122        IF(l_retrobilled_price_diff IS NOT NULL AND l_unit_selling_price IS NOT NULL) THEN
5123         x_line_val_rec.retrobilled_price := l_unit_selling_price+l_retrobilled_price_diff;
5124            ELSE
5125                 x_line_val_rec.retrobilled_price := null;
5126            END IF;
5127            oe_debug_pub.add( 'RETROBILLED_PRICE: '||x_line_val_rec.retrobilled_price) ;
5128 
5129        IF(p_line_rec.order_source_id=27) THEN
5130            SELECT orig_head.order_number,
5131                   orig_lin.line_number,
5132                   orig_lin.shipment_number,
5133                   orig_lin.option_number,
5134                   orig_lin.component_number,
5135                   orig_lin.service_number
5136            INTO x_line_val_rec.Retro_Order_Number,
5137                 x_line_val_rec.Retro_Line_Number,
5138                 x_line_val_rec.Retro_Shipment_Number,
5139                 x_line_val_rec.Retro_Option_Number,
5140                 x_line_val_rec.Retro_Component_Number,
5141                 x_line_val_rec.Retro_Service_Number
5142        FROM oe_order_headers_all orig_head,
5143                 oe_order_lines_all orig_lin
5144        WHERE line_id =
5145        (
5146             SELECT orig_sys_line_ref
5147             FROM oe_order_lines_all
5148             WHERE line_id=p_line_rec.line_id
5149             and order_source_id=27) AND
5150               orig_head.header_id=orig_lin.header_id;
5151        END IF;
5152 
5153 
5154         EXCEPTION
5155             WHEN NO_DATA_FOUND THEN
5156                 oe_debug_pub.add( 'IN EXCEPTION: ' ||SQLERRM);
5157             WHEN OTHERS THEN
5158                 oe_debug_pub.add( 'IN EXCEPTION: ' ||SQLERRM);
5159         END;
5160    END IF;
5161  END IF;
5162 --retro}
5163 --Macd
5164     IF l_debug_level  > 0 THEN
5165              oe_debug_pub.add(  'MACD configuration_id'||p_line_rec.configuration_id);
5166              oe_debug_pub.add(  'MACD config_rev_nbr'||p_line_rec.config_rev_nbr);
5167              oe_debug_pub.add(  'MACD config_header_id'||p_line_rec.config_header_id);
5168     END IF;
5169    IF  p_line_rec.configuration_id IS NOT NULL THEN
5170  BEGIN
5171   select cz.name
5172       into x_line_val_rec.instance_name
5173   from cz_config_details_v cz
5174   where  cz.config_hdr_id  = p_line_rec.config_header_id
5175   and    cz.config_rev_nbr = p_line_rec.config_rev_nbr
5176   and    cz.config_item_id = p_line_rec.configuration_id;
5177     IF l_debug_level  > 0 THEN
5178              oe_debug_pub.add(  'MACD instance name'||x_line_val_rec.instance_name);
5179     END IF;
5180 
5181  EXCEPTION
5182 
5183   WHEN NO_DATA_FOUND THEN
5184     null;
5185   WHEN TOO_MANY_ROWS THEN
5186     null;
5187   WHEN OTHERS THEN
5188     null;
5189 
5190   END;
5191 
5192  END IF;
5193 
5194   IF  p_line_rec.ib_owner  IS NOT NULL THEN
5195 
5196         BEGIN
5197            select meaning into x_line_val_rec.ib_owner_dsp
5198                from oe_lookups
5199               where
5200               ( lookup_type='ITEM_OWNER' OR lookup_type='ONT_INSTALL_BASE') and lookup_code=p_line_rec.ib_owner;
5201         EXCEPTION
5202 
5203          WHEN NO_DATA_FOUND THEN
5204             null;
5205          WHEN TOO_MANY_ROWS THEN
5206             null;
5207          WHEN OTHERS THEN
5208             null;
5209         END;
5210   END IF;
5211 
5212   IF  p_line_rec.ib_current_location  IS NOT NULL THEN
5213 
5214         BEGIN
5215            select meaning into x_line_val_rec.ib_current_location_dsp
5216                from oe_lookups
5217               where
5218               ( lookup_type='ITEM_CURRENT_LOCATION' OR lookup_type='ONT_INSTALL_BASE')and lookup_code=p_line_rec.ib_current_location;
5219         EXCEPTION
5220 
5221          WHEN NO_DATA_FOUND THEN
5222             null;
5223          WHEN TOO_MANY_ROWS THEN
5224             null;
5225          WHEN OTHERS THEN
5226             null;
5227         END;
5228    END IF;
5229 
5230   IF  p_line_rec.ib_installed_at_location  IS NOT NULL THEN
5231 
5232         BEGIN
5233            select meaning into x_line_val_rec.ib_installed_at_location_dsp
5234                from oe_lookups
5235               where
5236                (lookup_type='ITEM_INSTALL_LOCATION' OR lookup_type='ONT_INSTALL_BASE')and lookup_code=p_line_rec.ib_installed_at_location;
5237         EXCEPTION
5238 
5239          WHEN NO_DATA_FOUND THEN
5240             null;
5241          WHEN TOO_MANY_ROWS THEN
5242             null;
5243          WHEN OTHERS THEN
5244             null;
5245         END;
5246  END IF;
5247 --End OF Macd
5248 --Recurring CHarges
5249 -- Check if recurring Charges is Enabled or not
5250 
5251   IF OE_SYS_PARAMETERS.Value('RECURRING_CHARGES',p_line_rec.org_id)='Y' THEN
5252 
5253    BEGIN
5254 
5255      IF  p_line_rec.charge_periodicity_code  IS NOT NULL THEN
5256 
5257            x_line_val_rec.charge_periodicity_dsp:=OE_ID_TO_VALUE.Charge_periodicity(p_line_rec.charge_periodicity_code);
5258 
5259      END IF;
5260 
5261         EXCEPTION
5262 
5263          WHEN NO_DATA_FOUND THEN
5264             null;
5265          WHEN TOO_MANY_ROWS THEN
5266             null;
5267          WHEN OTHERS THEN
5268             null;
5269    END;
5270 
5271   END IF;
5272   --Customer Acceptance
5273   IF p_line_rec.contingency_id is not null then
5274        OE_ID_TO_VALUE.Get_Contingency_Attributes(
5275                                          p_contingency_id             => p_line_rec.contingency_id
5276                                        , x_contingency_name           => x_line_val_rec.contingency_name
5277                                        , x_contingency_description    => x_line_val_rec.contingency_description
5278                                        , x_expiration_event_attribute => x_line_val_rec.expiration_event_attribute
5279        );
5280        x_line_val_rec.revrec_event := OE_ID_TO_VALUE.Revrec_Event(p_line_rec.revrec_event_code);
5281 
5282   END IF;
5283 
5284   IF p_line_rec.accepted_by is not null THEN
5285        x_line_val_rec.accepted_by_dsp := OE_ID_TO_VALUE.Accepted_By(p_line_rec.accepted_by);
5286   END IF;
5287 
5288 
5289 END POPULATE_CONTROL_FIELDS;
5290 
5291 -- OPM 02/JUN/00 overloaded proc below
5292 
5293 PROCEDURE POPULATE_CONTROL_FIELDS
5294 ( p_line_rec                  IN line_rec_type,
5295 x_line_val_rec OUT NOCOPY line_val_rec_type,
5296    p_calling_block        IN  VARCHAR2,
5297 x_process_controls_rec OUT NOCOPY process_controls_rec_type
5298 
5299 ) IS
5300 
5301 
5302 l_item_rec           OE_Order_Cache.Item_Rec_Type;
5303 --
5304 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5305 --
5306 BEGIN
5307 
5308   POPULATE_CONTROL_FIELDS
5309                      (
5310                      p_line_rec => p_line_rec,
5311                      x_line_val_rec => x_line_val_rec,
5312               p_calling_block => 'LINE'
5313               );
5314 
5315  l_item_rec :=
5316           OE_Order_Cache.Load_Item (p_line_rec.inventory_item_id
5317                                     ,p_line_rec.ship_from_org_id
5318                                     ,p_line_rec.org_id); -- R12.MOAC
5319 
5320  -- x_process_controls_rec.dualum_ind := l_item_rec.dualum_ind; -- INVCONV
5321 -- x_process_controls_rec.grade_ctl  := l_item_rec.grade_ctl;  -- INVCONV
5322  x_process_controls_rec.process_warehouse_flag
5323                                    := l_item_rec.process_warehouse_flag;
5324 x_process_controls_rec.ont_pricing_qty_source := l_item_rec.ont_pricing_qty_source; -- OPM 2046190
5325 x_process_controls_rec.grade_control_flag := l_item_rec.grade_control_flag; -- INCONV
5326 x_process_controls_rec.tracking_quantity_ind := l_item_rec.tracking_quantity_ind; -- INCONV
5327 x_process_controls_rec.secondary_default_ind := l_item_rec.secondary_default_ind; -- INCONV
5328 x_process_controls_rec.lot_divisible_flag := l_item_rec.lot_divisible_flag; -- INCONV
5329 x_process_controls_rec.lot_control_code := l_item_rec.lot_control_code; -- INCONV 4172680
5330 
5331 END POPULATE_CONTROL_FIELDS;
5332 
5333 
5334 FUNCTION Is_Description_Matched
5335 (p_item_identifier_type  IN   VARCHAR2
5336 ,p_ordered_item_id       IN   NUMBER
5337 ,p_inventory_item_id     IN   NUMBER
5338 ,p_ordered_item          IN   VARCHAR2
5339 ,p_sold_to_org_id        IN   NUMBER
5340 ,p_description           IN   VARCHAR2
5341 ,p_org_id                IN   NUMBER DEFAULT NULL
5342 ) RETURN VARCHAR2 IS
5343 /*l_organization_id NUMBER := fnd_profile.value('OE_ORGANIZATION_ID');*/
5344     -- This change is required since we are dropping the profile OE_ORGANIZATION    -- _ID. Change made by Esha.
5345 l_organization_id Number;/*:= OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');*/
5346 l_count   NUMBER := 0;
5347 --
5348 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5349 --
5350 BEGIN
5351 --Bug 9684561
5352    l_organization_id := OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID',
5353                                p_org_id);
5354 
5355    IF l_debug_level  > 0 THEN
5356        oe_debug_pub.add(  'P_ITEM_IDENTIFIER_TYPE:'||P_ITEM_IDENTIFIER_TYPE ) ;
5357        oe_debug_pub.add(  'P_ORDERED_ITEM_ID: '||P_ORDERED_ITEM_ID ) ;
5358        oe_debug_pub.add(  'P_INVENTORY_ITEM_ID: '||P_INVENTORY_ITEM_ID ) ;
5359        oe_debug_pub.add(  'P_ORDERED_ITEM: '||P_ORDERED_ITEM ) ;
5360        oe_debug_pub.add(  'P_SOLD_TO_ORG_ID: '||P_SOLD_TO_ORG_ID ) ;
5361        oe_debug_pub.add(  'P_DESCRIPTION: '||P_DESCRIPTION ) ;
5362        oe_debug_pub.add(  'L_ORGANIZATION_ID: '||L_ORGANIZATION_ID ) ;
5363    END IF;
5364 
5365    IF NVL(p_item_identifier_type, 'INT') = 'INT' THEN
5366      IF (Instr(p_description, '%') = 0) THEN
5367      IF l_debug_level  > 0 THEN
5368          oe_debug_pub.add(  'ENTERING INT::EXACT MATCH' ) ;
5369      END IF;
5370          SELECT count(*)
5371          INTO  l_count
5372          FROM  mtl_system_items_vl
5373          WHERE inventory_item_id = p_inventory_item_id
5374          AND organization_id = l_organization_id
5375          AND description = p_description;
5376      ELSE
5377      IF l_debug_level  > 0 THEN
5378          oe_debug_pub.add(  'ENTERING INT::PARTIAL' ) ;
5379      END IF;
5380 
5381          SELECT count(*)
5382          INTO  l_count
5383          FROM  mtl_system_items_tl t --3751209
5384          WHERE inventory_item_id = p_inventory_item_id
5385          AND organization_id = l_organization_id
5386          AND description like p_description
5387      AND language= userenv('LANG');
5388      END IF;
5389 
5390    ELSIF NVL(p_item_identifier_type, 'INT') = 'CUST' THEN
5391      IF (Instr(p_description, '%') = 0) THEN
5392      IF l_debug_level  > 0 THEN
5393          oe_debug_pub.add(  'ENTERING CUST::EXACT MATCH' ) ;
5394      END IF;
5395          SELECT count(*)
5396          INTO  l_count
5397          FROM  mtl_customer_items citems
5398               ,mtl_customer_item_xrefs cxref
5399               ,mtl_system_items_vl sitems
5400          WHERE citems.customer_item_id = cxref.customer_item_id
5401            AND cxref.inventory_item_id = sitems.inventory_item_id
5402            AND sitems.inventory_item_id = p_inventory_item_id
5403            AND sitems.organization_id = l_organization_id
5404            AND citems.customer_item_id = p_ordered_item_id
5405            AND citems.customer_id = p_sold_to_org_id
5406            AND nvl(citems.customer_item_desc, sitems.description) = p_description;
5407      ELSE
5408      IF l_debug_level  > 0 THEN
5409          oe_debug_pub.add(  'ENTERING CUST::PARTIAL' ) ;
5410      END IF;
5411          SELECT count(*)
5412          INTO  l_count
5413          FROM  mtl_customer_items citems
5414               ,mtl_customer_item_xrefs cxref
5415               ,mtl_system_items_vl sitems
5416          WHERE citems.customer_item_id = cxref.customer_item_id
5417            AND cxref.inventory_item_id = sitems.inventory_item_id
5418            AND sitems.inventory_item_id = p_inventory_item_id
5419            AND sitems.organization_id = l_organization_id
5420            AND citems.customer_item_id = p_ordered_item_id
5421            AND citems.customer_id = p_sold_to_org_id
5422            AND nvl(citems.customer_item_desc, sitems.description) like p_description;
5423      END IF;
5424    ELSE
5425     IF p_ordered_item_id IS NULL THEN
5426      IF (Instr(p_description, '%') = 0) THEN
5427      IF l_debug_level  > 0 THEN
5428          oe_debug_pub.add(  'ENTERING GENERIC::EXACT MATCH' ) ;
5429      END IF;
5430          SELECT count(*)
5431          INTO  l_count
5432          FROM  mtl_cross_reference_types types
5433              , mtl_cross_references items
5434              , mtl_system_items_vl sitems
5435          WHERE types.cross_reference_type = items.cross_reference_type
5436            AND items.inventory_item_id = sitems.inventory_item_id
5437            AND sitems.inventory_item_id = p_inventory_item_id
5438            AND sitems.organization_id = l_organization_id
5439            AND items.cross_reference_type = p_item_identifier_type
5440            AND items.cross_reference = p_ordered_item
5441            AND nvl(items.description, sitems.description) = p_description;
5442      ELSE
5443      IF l_debug_level  > 0 THEN
5444          oe_debug_pub.add(  'ENTERING GENERIC::PARTIAL' ) ;
5445      END IF;
5446          SELECT count(*)
5447          INTO  l_count
5448          FROM  mtl_cross_reference_types types
5449              , mtl_cross_references items
5450              , mtl_system_items_vl sitems
5451          WHERE types.cross_reference_type = items.cross_reference_type
5452            AND items.inventory_item_id = sitems.inventory_item_id
5453            AND sitems.inventory_item_id = p_inventory_item_id
5454            AND sitems.organization_id = l_organization_id
5455            AND items.cross_reference_type = p_item_identifier_type
5456            AND items.cross_reference = p_ordered_item
5457            AND nvl(items.description, sitems.description) like p_description;
5458      END IF;
5459     END IF;
5460    END IF;
5461 
5462    IF l_count = 0 THEN
5463      IF l_debug_level  > 0 THEN
5464          oe_debug_pub.add(  'NO MATCHES' ) ;
5465      END IF;
5466       RETURN 'N';
5467    ELSE
5468      IF l_debug_level  > 0 THEN
5469          oe_debug_pub.add(  'THERE ARE MATCHES' ) ;
5470      END IF;
5471       RETURN 'Y';
5472    END IF;
5473 
5474 END Is_Description_Matched;
5475 
5476 /* 2913927 - 3348159 start */
5477 
5478 FUNCTION Is_Internal_Item_Matched
5479 (p_item_identifier_type  IN   VARCHAR2
5480 ,p_ordered_item_id       IN   NUMBER
5481 ,p_inventory_item_id     IN   NUMBER
5482 ,p_ordered_item          IN   VARCHAR2
5483 ,p_sold_to_org_id        IN   NUMBER
5484 ,p_inventory_item        IN   VARCHAR2
5485 ,p_org_id                IN   NUMBER DEFAULT NULL
5486 ) RETURN VARCHAR2 IS
5487 l_organization_id Number;/*:= OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');*/
5488 l_count   NUMBER := 0;
5489 --
5490 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5491 --
5492 BEGIN
5493 --Bug 9684561
5494    l_organization_id := OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID',
5495                                p_org_id);
5496 
5497    IF l_debug_level  > 0 THEN
5498 
5499        oe_debug_pub.add(  'P_ITEM_IDENTIFIER_TYPE: '||P_ITEM_IDENTIFIER_TYPE ) ;
5500        oe_debug_pub.add(  'P_ORDERED_ITEM_ID: '||P_ORDERED_ITEM_ID ) ;
5501        oe_debug_pub.add(  'P_INVENTORY_ITEM_ID: '||P_INVENTORY_ITEM_ID ) ;
5502        oe_debug_pub.add(  'P_ORDERED_ITEM: '||P_ORDERED_ITEM ) ;
5503        oe_debug_pub.add(  'P_SOLD_TO_ORG_ID: '||P_SOLD_TO_ORG_ID ) ;
5504        oe_debug_pub.add(  'p_inventory_item: '||p_inventory_item ) ;
5505        oe_debug_pub.add(  'L_ORGANIZATION_ID: '||L_ORGANIZATION_ID ) ;
5506    END IF;
5507 
5508    IF NVL(p_item_identifier_type, 'INT') = 'INT' THEN
5509      IF (Instr(p_inventory_item, '%') = 0) THEN
5510      IF l_debug_level  > 0 THEN
5511          oe_debug_pub.add(  'ENTERING INT::EXACT MATCH' ) ;
5512      END IF;
5513          SELECT count(*)
5514          INTO  l_count
5515          FROM  mtl_system_items_vl
5516          WHERE inventory_item_id = p_inventory_item_id
5517          AND organization_id = l_organization_id
5518          AND concatenated_segments = p_inventory_item;
5519      ELSE
5520      IF l_debug_level  > 0 THEN
5521          oe_debug_pub.add(  'ENTERING INT::PARTIAL' ) ;
5522      END IF;
5523          SELECT count(*)
5524          INTO  l_count
5525          FROM  mtl_system_items_vl
5526          WHERE inventory_item_id = p_inventory_item_id
5527          AND organization_id = l_organization_id
5528          AND concatenated_segments like p_inventory_item;
5529      END IF;
5530 
5531    ELSIF NVL(p_item_identifier_type, 'INT') = 'CUST' THEN
5532      IF (Instr(p_inventory_item, '%') = 0) THEN
5533      IF l_debug_level  > 0 THEN
5534          oe_debug_pub.add(  'ENTERING CUST::EXACT MATCH' ) ;
5535      END IF;
5536          SELECT count(*)
5537          INTO  l_count
5538          FROM  mtl_customer_items citems
5539               ,mtl_customer_item_xrefs cxref
5540               ,mtl_system_items_vl sitems
5541          WHERE citems.customer_item_id = cxref.customer_item_id
5542            AND cxref.inventory_item_id = sitems.inventory_item_id
5543            AND sitems.inventory_item_id = p_inventory_item_id
5544            AND sitems.organization_id = l_organization_id
5545            AND citems.customer_item_id = p_ordered_item_id
5546            AND citems.customer_id = p_sold_to_org_id
5547            AND sitems.concatenated_segments  = p_inventory_item;
5548      ELSE
5549      IF l_debug_level  > 0 THEN
5550          oe_debug_pub.add(  'ENTERING CUST::PARTIAL' ) ;
5551      END IF;
5552          SELECT count(*)
5553          INTO  l_count
5554          FROM  mtl_customer_items citems
5555               ,mtl_customer_item_xrefs cxref
5556               ,mtl_system_items_vl sitems
5557          WHERE citems.customer_item_id = cxref.customer_item_id
5558            AND cxref.inventory_item_id = sitems.inventory_item_id
5559            AND sitems.inventory_item_id = p_inventory_item_id
5560            AND sitems.organization_id = l_organization_id
5561            AND citems.customer_item_id = p_ordered_item_id
5562            AND citems.customer_id = p_sold_to_org_id
5563            AND sitems.concatenated_segments like p_inventory_item;
5564 
5565      END IF;
5566    ELSE
5567     IF p_ordered_item_id IS NULL THEN
5568      IF (Instr(p_inventory_item, '%') = 0) THEN
5569      IF l_debug_level  > 0 THEN
5570          oe_debug_pub.add(  'ENTERING GENERIC::EXACT MATCH' ) ;
5571      END IF;
5572          SELECT count(*)
5573          INTO  l_count
5574          FROM  mtl_cross_reference_types types
5575              , mtl_cross_references items
5576              , mtl_system_items_vl sitems
5577          WHERE types.cross_reference_type = items.cross_reference_type
5578            AND items.inventory_item_id = sitems.inventory_item_id
5579            AND sitems.inventory_item_id = p_inventory_item_id
5580            AND sitems.organization_id = l_organization_id
5581            AND items.cross_reference_type = p_item_identifier_type
5582            AND items.cross_reference = p_ordered_item
5583            AND sitems.concatenated_segments = p_inventory_item;
5584      ELSE
5585      IF l_debug_level  > 0 THEN
5586          oe_debug_pub.add(  'ENTERING GENERIC::PARTIAL' ) ;
5587      END IF;
5588          SELECT count(*)
5589          INTO  l_count
5590          FROM  mtl_cross_reference_types types
5591              , mtl_cross_references items
5592              , mtl_system_items_vl sitems
5593          WHERE types.cross_reference_type = items.cross_reference_type
5594            AND items.inventory_item_id = sitems.inventory_item_id
5595            AND sitems.inventory_item_id = p_inventory_item_id
5596            AND sitems.organization_id = l_organization_id
5597            AND items.cross_reference_type = p_item_identifier_type
5598            AND items.cross_reference = p_ordered_item
5599            AND sitems.concatenated_segments like p_inventory_item;
5600      END IF;
5601     END IF;
5602    END IF;
5603 
5604    IF l_count = 0 THEN
5605      IF l_debug_level  > 0 THEN
5606          oe_debug_pub.add(  'NO MATCHES' ) ;
5607      END IF;
5608       RETURN 'N';
5609    ELSE
5610      IF l_debug_level  > 0 THEN
5611          oe_debug_pub.add(  'THERE ARE MATCHES' ) ;
5612      END IF;
5613       RETURN 'Y';
5614    END IF;
5615 END Is_Internal_Item_Matched;
5616 
5617 /*  2913927 - 3348159 end */
5618 
5619 /*1477598*/
5620 FUNCTION Is_Item_Matched
5621 (p_item_identifier_type  IN   VARCHAR2
5622 ,p_ordered_item_id       IN   NUMBER
5623 ,p_inventory_item_id     IN   NUMBER
5624 ,p_ordered_item          IN   VARCHAR2
5625 ,p_sold_to_org_id        IN   NUMBER
5626 ,p_item                  IN   VARCHAR2
5627 ,p_org_id                IN   NUMBER DEFAULT NULL
5628 ) RETURN VARCHAR2 IS
5629 l_organization_id Number;/*= OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');*/
5630 l_count   NUMBER := 0;
5631 --
5632 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5633 --
5634 BEGIN
5635 --Bug 9684561
5636    l_organization_id := OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID',
5637                                p_org_id);
5638    IF l_debug_level  > 0 THEN
5639        oe_debug_pub.add(  'P_ITEM_IDENTIFIER_TYPE: '||P_ITEM_IDENTIFIER_TYPE ) ;
5640        oe_debug_pub.add(  'P_ORDERED_ITEM_ID: '||P_ORDERED_ITEM_ID ) ;
5641        oe_debug_pub.add(  'P_INVENTORY_ITEM_ID: '||P_INVENTORY_ITEM_ID ) ;
5642        oe_debug_pub.add(  'P_ORDERED_ITEM: '||P_ORDERED_ITEM ) ;
5643        oe_debug_pub.add(  'P_SOLD_TO_ORG_ID: '||P_SOLD_TO_ORG_ID ) ;
5644        oe_debug_pub.add(  'P_ITEM: '||P_ITEM ) ;
5645        oe_debug_pub.add(  'L_ORGANIZATION_ID: '||L_ORGANIZATION_ID ) ;
5646    END IF;
5647 
5648    IF NVL(p_item_identifier_type, 'INT') = 'INT' THEN
5649      IF (Instr(p_item, '%') = 0) THEN
5650      IF l_debug_level  > 0 THEN
5651          oe_debug_pub.add(  'ENTERING INT::EXACT MATCH' ) ;
5652      END IF;
5653          SELECT count(*)
5654          INTO  l_count
5655          FROM  mtl_system_items_vl
5656          WHERE inventory_item_id = p_inventory_item_id
5657          AND organization_id = l_organization_id
5658          AND concatenated_segments = p_item;
5659      ELSE
5660      IF l_debug_level  > 0 THEN
5661          oe_debug_pub.add(  'ENTERING INT::PARTIAL' ) ;
5662      END IF;
5663          SELECT count(*)
5664          INTO  l_count
5665          FROM  mtl_system_items_vl
5666          WHERE inventory_item_id = p_inventory_item_id
5667          AND organization_id = l_organization_id
5668          AND concatenated_segments like p_item;
5669      END IF;
5670 
5671    ELSIF NVL(p_item_identifier_type, 'INT') = 'CUST' THEN
5672      IF (Instr(p_item, '%') = 0) THEN
5673      IF l_debug_level  > 0 THEN
5674          oe_debug_pub.add(  'ENTERING CUST::EXACT MATCH' ) ;
5675      END IF;
5676          SELECT count(*)
5677          INTO  l_count
5678          FROM  mtl_customer_items citems
5679               ,mtl_customer_item_xrefs cxref
5680               ,mtl_system_items_vl sitems
5681          WHERE citems.customer_item_id = cxref.customer_item_id
5682            AND cxref.inventory_item_id = sitems.inventory_item_id
5683            AND sitems.inventory_item_id = p_inventory_item_id
5684            AND sitems.organization_id = l_organization_id
5685            AND citems.customer_item_id = p_ordered_item_id
5686            AND citems.customer_id = p_sold_to_org_id
5687            AND nvl(citems.customer_item_number, sitems.concatenated_segments) =p_item;
5688      ELSE
5689      IF l_debug_level  > 0 THEN
5690          oe_debug_pub.add(  'ENTERING CUST::PARTIAL' ) ;
5691      END IF;
5692          SELECT count(*)
5693          INTO  l_count
5694          FROM  mtl_customer_items citems
5695               ,mtl_customer_item_xrefs cxref
5696               ,mtl_system_items_vl sitems
5697          WHERE citems.customer_item_id = cxref.customer_item_id
5698            AND cxref.inventory_item_id = sitems.inventory_item_id
5699            AND sitems.inventory_item_id = p_inventory_item_id
5700            AND sitems.organization_id = l_organization_id
5701            AND citems.customer_item_id = p_ordered_item_id
5702            AND citems.customer_id = p_sold_to_org_id
5703            AND nvl(citems.customer_item_number, sitems.concatenated_segments) like  p_item;
5704      END IF;
5705    ELSE
5706     IF p_ordered_item_id IS NULL THEN
5707      IF (Instr(p_item, '%') = 0) THEN
5708      IF l_debug_level  > 0 THEN
5709          oe_debug_pub.add(  'ENTERING GENERIC::EXACT MATCH' ) ;
5710      END IF;
5711          SELECT count(*)
5712          INTO  l_count
5713          FROM  mtl_cross_reference_types types
5714              , mtl_cross_references items
5715              , mtl_system_items_vl sitems
5716          WHERE types.cross_reference_type = items.cross_reference_type
5717            AND items.inventory_item_id = sitems.inventory_item_id
5718            AND sitems.inventory_item_id = p_inventory_item_id
5719            AND sitems.organization_id = l_organization_id
5720            AND items.cross_reference_type = p_item_identifier_type
5721            AND items.cross_reference = p_ordered_item
5722            AND nvl(items.cross_reference, sitems.concatenated_segments) = p_item;
5723      ELSE
5724      IF l_debug_level  > 0 THEN
5725          oe_debug_pub.add(  'ENTERING GENERIC::PARTIAL' ) ;
5726      END IF;
5727          SELECT count(*)
5728          INTO  l_count
5729          FROM  mtl_cross_reference_types types
5730              , mtl_cross_references items
5731              , mtl_system_items_vl sitems
5732          WHERE types.cross_reference_type = items.cross_reference_type
5733            AND items.inventory_item_id = sitems.inventory_item_id
5734            AND sitems.inventory_item_id = p_inventory_item_id
5735            AND sitems.organization_id = l_organization_id
5736            AND items.cross_reference_type = p_item_identifier_type
5737            AND items.cross_reference = p_ordered_item
5738            AND nvl(items.cross_reference, sitems.concatenated_segments) like p_item;
5739      END IF;
5740     END IF;
5741    END IF;
5742 
5743    IF l_count = 0 THEN
5744      IF l_debug_level  > 0 THEN
5745          oe_debug_pub.add(  'NO MATCHES' ) ;
5746      END IF;
5747       RETURN 'N';
5748    ELSE
5749      IF l_debug_level  > 0 THEN
5750          oe_debug_pub.add(  'THERE ARE MATCHES' ) ;
5751      END IF;
5752       RETURN 'Y';
5753    END IF;
5754 END Is_Item_Matched;
5755 /*1477598*/
5756 
5757 PROCEDURE SPLIT_LINE
5758 (
5759 p_split_by      IN  VARCHAR2 DEFAULT null
5760 ,x_line_tbl_type IN  split_line_tbl_type
5761 ,p_change_reason_code IN VARCHAR2 DEFAULT NULL
5762 ,p_change_comments IN VARCHAR2 DEFAULT NULL
5763 ,x_return_status OUT NOCOPY VARCHAR2
5764 ,x_msg_count OUT NOCOPY NUMBER
5765 ,x_msg_data OUT NOCOPY VARCHAR2
5766  ) IS
5767 
5768  i                             NUMBER;
5769  l_line_tbl                  OE_Order_PUB.Line_Tbl_Type;
5770  l_x_line_tbl                  OE_Order_PUB.Line_Tbl_Type;
5771  l_line_rec                    OE_Order_PUB.Line_Rec_Type;
5772  l_x_header_rec                OE_Order_PUB.Header_Rec_Type;
5773  l_x_Header_Adj_tbl            OE_Order_PUB.Header_Adj_Tbl_Type;
5774  l_x_Header_Scredit_tbl        OE_Order_PUB.Header_Scredit_Tbl_Type;
5775  l_x_Line_Adj_tbl              OE_Order_PUB.Line_Adj_Tbl_Type;
5776  l_x_Line_Scredit_tbl          OE_Order_PUB.Line_Scredit_Tbl_Type;
5777  l_x_Action_Request_tbl        OE_Order_PUB.Request_Tbl_Type;
5778  l_x_Lot_Serial_Tbl            OE_Order_PUB.Lot_Serial_Tbl_Type;
5779  l_x_Header_price_Att_tbl      OE_Order_PUB.Header_Price_Att_Tbl_Type;
5780  l_x_Header_Adj_Att_tbl        OE_Order_PUB.Header_Adj_Att_Tbl_Type;
5781  l_x_Header_Adj_Assoc_tbl      OE_Order_PUB.Header_Adj_Assoc_Tbl_Type;
5782  l_x_Line_price_Att_tbl        OE_Order_PUB.Line_Price_Att_Tbl_Type;
5783  l_x_Line_Adj_Att_tbl          OE_Order_PUB.Line_Adj_Att_Tbl_Type;
5784  l_x_Line_Adj_Assoc_tbl        OE_Order_PUB.Line_Adj_Assoc_Tbl_Type;
5785  l_control_rec                 OE_GLOBALS.Control_Rec_Type;
5786  l_return_status               VARCHAR2(1);
5787  l_line_id                     NUMBER;
5788  l_process_add_attributes      Boolean :=FALSE;
5789  j                             NUMBER;    --   for bug 1988144
5790  k                             NUMBER;    --   for bug 1988144
5791  l_rec_count                   NUMBER;    --   for bug 1988144
5792 --serla begin
5793 l_x_Header_Payment_tbl        OE_Order_PUB.Header_Payment_Tbl_Type;
5794 l_x_Line_Payment_tbl          OE_Order_PUB.Line_Payment_Tbl_Type;
5795 --serla end
5796 --10278858
5797 l_org_request_date     DATE;
5798 l_org_ship_from_org_id NUMBER;
5799 l_org_ship_to_org_id NUMBER;
5800 l_ref_split_ship_from VARCHAR2(10);--14654985
5801 
5802 
5803 --
5804 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5805 --
5806 BEGIN
5807 
5808 IF l_debug_level  > 0 THEN
5809    oe_debug_pub.add(  'LINE CONTROLLER - IN SPLIT ' , 1 ) ;
5810 END IF;
5811 
5812 /*  l_control_rec.controlled_operation := TRUE;
5813   l_control_rec.validate_entity      := TRUE;
5814   l_control_rec.write_to_DB          := TRUE;
5815 
5816   l_control_rec.default_attributes   := FALSE;
5817   l_control_rec.change_attributes    := FALSE;
5818   l_control_rec.process              := FALSE;
5819 
5820   l_control_rec.clear_api_cache      := FALSE;
5821   l_control_rec.clear_api_requests   := FALSE;   */
5822 
5823 --  OE_GLOBALS.G_UI_FLAG := TRUE;  -- FP bug#6968460 (for bug#5727279): reverting the fix done in bug#4751632
5824 
5825 IF x_line_tbl_type.count>0 THEN
5826    for i in  x_line_tbl_type.first .. x_line_tbl_type.last loop
5827 
5828        IF i  =1 THEN
5829            IF x_line_tbl_type(i).line_id is not null THEN
5830            l_line_id:=x_line_tbl_type(i).line_id;
5831 	   IF l_debug_level  > 0 THEN
5832               oe_debug_pub.add(  'LINE CONTROLLER - BEFORE GET LINE'|| X_LINE_TBL_TYPE ( I ) .LINE_ID , 1 ) ;
5833            END IF;
5834                --    l_x_line_tbl(i):=OE_ORDER_PUB.G_MISS_LINE_REC;
5835                /*       Get_line
5836                (   p_db_record       => FALSE
5837                   ,p_line_id         => x_line_tbl_type(i).line_id
5838                  ,x_line_rec        => l_x_line_tbl(i));  */
5839                l_x_line_tbl(i).line_id:=x_line_tbl_type(i).line_id;
5840                OE_Line_Util.Lock_Row
5841                ( x_return_status         => l_return_status
5842                , p_x_line_rec            => l_x_line_tbl(i)
5843                , p_line_id               => x_line_tbl_type(i).line_id);
5844 
5845                IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5846                    RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5847                ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5848                    RAISE FND_API.G_EXC_ERROR;
5849                END IF;
5850 
5851                IF l_debug_level  > 0 THEN
5852                    oe_debug_pub.add(  'LINE CONTROLLER - AFTER GET LINE ' , 1 ) ;
5853                END IF;
5854 	       --10278858
5855 	       l_org_request_date  := l_x_line_tbl(i).request_date;
5856                l_org_ship_from_org_id  := l_x_line_tbl(i).ship_from_org_id;
5857                l_org_ship_to_org_id  := l_x_line_tbl(i).ship_to_org_id;
5858            END IF;
5859 
5860        l_x_line_tbl(i).line_id:=x_line_tbl_type(i).line_id;
5861        l_x_line_tbl(i).split_action_code:='SPLIT';
5862            --SAO
5863            IF p_split_by = 'SCHEDULER' THEN
5864               l_x_line_tbl(i).split_by:='SYSTEM';
5865            ELSE
5866               l_x_line_tbl(i).split_by:='USER';
5867            END IF;
5868        l_x_line_tbl(i).operation:= OE_GLOBALS.G_OPR_UPDATE;
5869            IF l_debug_level > 0 THEN
5870               OE_DEBUG_PUB.add('Audit Trail Reason Code being passed as '||p_change_reason_code,1);
5871            END IF;
5872            l_x_line_tbl(i).change_reason := p_change_reason_code;
5873            l_x_line_tbl(i).change_comments := p_change_comments;
5874            -- Bug# 4008409
5875            -- Pass ship_from_org_id for the update line since the Dual UOM control for the item can be different
5876           -- l_x_line_tbl(i).ship_from_org_id := x_line_tbl_type(i).ship_from_org_id;
5877       ELSE
5878           IF l_line_id is not null then
5879             l_x_line_tbl(i).split_from_line_id:=l_line_id;
5880           END IF;
5881 	  l_x_line_tbl(i).operation:= OE_GLOBALS.G_OPR_CREATE;
5882           --SAO
5883          IF p_split_by = 'SCHEDULER' THEN
5884            l_x_line_tbl(i).split_by:='SYSTEM';
5885          ELSE
5886            l_x_line_tbl(i).split_by := 'USER'; -- for bug 2211261
5887          END IF;
5888     END IF;
5889     l_x_line_tbl(i).ordered_quantity:= x_line_tbl_type(i).ordered_quantity;
5890     /* OPM - NC 3/8/02 Bug#2046641 */
5891     l_x_line_tbl(i).ordered_quantity2:= x_line_tbl_type(i).ordered_quantity2;
5892     --8706868
5893 
5894     IF x_line_tbl_type(i).ship_to_org_id is not null THEN
5895        IF nvl(l_x_line_tbl(i).ship_to_org_id,-1)<>nvl(x_line_tbl_type(i).ship_to_org_id,-1)  THEN
5896           l_x_line_tbl(i).ship_to_org_id:=x_line_tbl_type(i).ship_to_org_id;
5897           --10278858
5898 	  IF l_x_line_tbl(i).ship_to_org_id <> l_org_ship_to_org_id THEN
5899              l_x_line_tbl(i).SPLIT_SHIP_TO := 'Y';
5900           END IF;
5901        END IF;
5902     END IF;
5903 
5904     IF x_line_tbl_type(i).request_date is not null THEN
5905        IF nvl(l_x_line_tbl(i).request_date,sysdate)<> nvl(x_line_tbl_type(i).request_date,sysdate)  THEN
5906           l_x_line_tbl(i).request_date:=x_line_tbl_type(i).request_date;
5907           --10278858
5908 	  IF l_x_line_tbl(i).request_date <> l_org_request_date THEN
5909              l_x_line_tbl(i).SPLIT_REQUEST_DATE := 'Y';
5910           END IF;
5911        END IF;
5912     END IF;
5913 
5914     IF x_line_tbl_type(i).ship_from_org_id is not null THEN
5915        IF nvl(l_x_line_tbl(i).ship_from_org_id,-1)<>nvl(x_line_tbl_type(i).ship_from_org_id,-1)  THEN
5916           l_x_line_tbl(i).ship_from_org_id:=x_line_tbl_type(i).ship_from_org_id;
5917           -- ship_from_org_id is changed during split, null OUT subinventory
5918           l_x_line_tbl(i).subinventory:= fnd_api.g_miss_char; --Bug 13560415, do not use null
5919 
5920           --10278858
5921 	  IF l_x_line_tbl(i).ship_from_org_id <> l_org_ship_from_org_id THEN
5922              l_x_line_tbl(i).SPLIT_SHIP_FROM := 'Y';
5923           END IF;
5924        END IF;
5925     END IF;
5926     --8706868
5927    end loop;
5928 
5929     IF l_debug_level  > 0 THEN
5930         oe_debug_pub.add(  'LINE CONTROLLER - IN SPLIT - CALLING PROCESS' , 1 ) ;
5931     END IF;
5932 
5933    Oe_Order_Pvt.Process_order
5934     (   p_api_version_number          => 1.0
5935     ,   p_init_msg_list               => FND_API.G_TRUE
5936     ,   x_return_status               => l_return_status
5937     ,   x_msg_count                   => x_msg_count
5938     ,   x_msg_data                    => x_msg_data
5939     ,   p_control_rec                 => l_control_rec
5940     ,   p_x_header_rec                  => l_x_header_rec
5941     ,   p_x_Header_Adj_tbl              => l_x_Header_Adj_tbl
5942     ,   p_x_header_price_att_tbl        => l_x_header_price_att_tbl
5943     ,   p_x_Header_Adj_att_tbl          => l_x_Header_Adj_att_tbl
5944     ,   p_x_Header_Adj_Assoc_tbl        => l_x_Header_Adj_Assoc_tbl
5945     ,   p_x_Header_Scredit_tbl          => l_x_Header_Scredit_tbl
5946 --serla begin
5947     ,   p_x_Header_Payment_tbl          => l_x_Header_Payment_tbl
5948 --serla end
5949     ,   p_x_line_tbl                    => l_x_line_tbl
5950     ,   p_x_Line_Adj_tbl                => l_x_Line_Adj_tbl
5951     ,   p_x_Line_Price_att_tbl          => l_x_Line_Price_att_tbl
5952     ,   p_x_Line_Adj_att_tbl            => l_x_Line_Adj_att_tbl
5953     ,   p_x_Line_Adj_Assoc_tbl          => l_x_Line_Adj_Assoc_tbl
5954     ,   p_x_Line_Scredit_tbl            => l_x_Line_Scredit_tbl
5955 --serla begin
5956     ,   p_x_Line_Payment_tbl            => l_x_Line_Payment_tbl
5957 --serla end
5958     ,   p_x_action_request_tbl          => l_x_Action_Request_tbl
5959     ,   p_x_lot_serial_tbl              => l_x_lot_serial_tbl
5960 
5961     );
5962 
5963   END IF;
5964     IF l_debug_level  > 0 THEN
5965         oe_debug_pub.add(  'LINE CONTROLLER - IN SPLIT - AFTER CALLING PROCESS' , 1 ) ;
5966     END IF;
5967 
5968    IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5969      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5970    ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5971      RAISE FND_API.G_EXC_ERROR;
5972    END IF;
5973 
5974 
5975    IF l_x_line_tbl.count>0 THEN
5976     l_line_tbl.delete;
5977     /* -- 8706868: No need to call again. First call has updated this.
5978      FOR i in  x_line_tbl_type.first .. x_line_tbl_type.last LOOP
5979         l_line_tbl(i):=OE_ORDER_PUB.G_MISS_LINE_REC;
5980         IF x_line_tbl_type(i).ship_to_org_id is not null THEN
5981         IF nvl(l_x_line_tbl(i).ship_to_org_id,-1)<>nvl(x_line_tbl_type(i).ship_to_org_id,-1)  THEN
5982               l_line_tbl(i).ship_to_org_id:=x_line_tbl_type(i).ship_to_org_id;
5983               l_process_add_attributes:=TRUE;
5984             END IF;
5985         END IF;
5986 
5987         IF x_line_tbl_type(i).request_date is not null THEN
5988           IF nvl(l_x_line_tbl(i).request_date,sysdate)<> nvl(x_line_tbl_type(i).request_date,sysdate)  THEN
5989             l_line_tbl(i).request_date:=x_line_tbl_type(i).request_date;
5990             l_process_add_attributes:=TRUE;
5991            END IF;
5992         END IF;
5993 
5994      -- This is to fix a p1 bug on tst115. The second call should not
5995      -- come as split
5996       l_line_tbl(i).operation:= OE_GLOBALS.G_OPR_UPDATE;
5997       IF l_debug_level > 0 THEN
5998          OE_DEBUG_PUB.add('Reason code being passed : '||l_line_tbl(i).change_reason,1);
5999          OE_DEBUG_PUB.add('Warehouse: '||x_line_tbl_type(i).ship_from_org_id,1);
6000       END IF;
6001       l_line_tbl(i).change_reason := p_change_reason_code;
6002       l_line_tbl(i).change_comments := p_change_comments;
6003       l_line_tbl(i).split_action_code:=fnd_api.g_miss_char;
6004       l_line_tbl(i).line_id:=l_x_line_tbl(i).line_id;
6005       l_line_tbl(i).header_id:=l_x_line_tbl(i).header_id;
6006 
6007       IF x_line_tbl_type(i).ship_from_org_id is not null THEN
6008       IF nvl(l_x_line_tbl(i).ship_from_org_id,-1)<>nvl(x_line_tbl_type(i).ship_from_org_id,-1)  THEN
6009               l_line_tbl(i).ship_from_org_id:=x_line_tbl_type(i).ship_from_org_id;
6010               -- ship_from_org_id is changed during split, null OUT subinventory
6011               l_line_tbl(i).subinventory:= null;
6012               -- Bug# 4008409
6013               -- pass the ordered_quantity2 which is entered in the split window
6014               l_line_tbl(i).ordered_quantity2 := x_line_tbl_type(i).ordered_quantity2;
6015               l_process_add_attributes:=TRUE;
6016           END IF;
6017       END IF;
6018 
6019 --      l_line_tbl(i):=l_x_line_tbl(i);
6020      END LOOP;
6021 */ -- 8706868
6022 /* Extra loop being handled so as to deal with the service lines */
6023 /* for bug 1988144, added by dbuduru */
6024 
6025 -- At this point l_line_tbl contains the order line that was split as well as the
6026 -- the order lines that are  created as a result of the split. Prior to this modification
6027 -- only these records were being passed to the Process Order API ( second call ) and there
6028 -- is no code in the Process Order API that would update the service lines if split attributes
6029 -- are modified in the order lines to which they refer to.
6030 --
6031 -- In order to make the Process Order API handle the service lines, the service lines are
6032 -- explicitly being bundled with the order lines in the l_line_tbl. The Following loop
6033 -- takes care of that. The loop is coded taking Models, standard items and kits into consideration
6034 --
6035 -- Local variables j, k, l_rec_count have been added. The variables j, k
6036 -- are  used as a loop indices
6037 -- and l_rec_count is used to work on the l_line_tbl.
6038 --
6039 -- l_line_id would contain the line_id of the line to which the service line is attached
6040 -- to or the top_most_line_id if the line to which its attached to is a part of a Model.
6041 -- This is done because splitting happens at the top most level.
6042 
6043  -- l_rec_count := l_line_tbl.last + 1;
6044    l_rec_count :=  1; --8706868
6045   FOR i in  l_x_line_tbl.first .. l_x_line_tbl.last LOOP
6046     IF l_x_line_tbl(i).item_type_code = 'SERVICE' THEN
6047 
6048       l_line_tbl(l_rec_count) := OE_ORDER_PUB.G_MISS_LINE_REC;
6049 
6050       FOR j in  l_x_line_tbl.first .. l_x_line_tbl.last LOOP
6051         IF l_x_line_tbl(i).service_reference_line_id = l_x_line_tbl(j).line_id THEN
6052           l_line_id :=  nvl( l_x_line_tbl(j).top_model_line_id, l_x_line_tbl(j).line_id );
6053 	  l_ref_split_ship_from := l_x_line_tbl(j).split_ship_from; --14654985
6054           EXIT;
6055         END IF; -- service_Ref_line = line_id
6056       END LOOP;  -- loop on l_x_line_tbl
6057 
6058       FOR k in x_line_tbl_type.first .. x_line_tbl_type.last LOOP
6059         IF l_line_id = l_x_line_tbl(k).line_id THEN
6060           IF x_line_tbl_type(k).ship_to_org_id is not null THEN
6061             IF nvl(l_x_line_tbl(i).ship_to_org_id,-1)<>nvl(x_line_tbl_type(k).ship_to_org_id,-1)  THEN
6062               l_line_tbl(l_rec_count).ship_to_org_id := x_line_tbl_type(k).ship_to_org_id;
6063               l_process_add_attributes:=TRUE;
6064             END IF; -- if ship_to_changed
6065           END IF; -- ship_to not null
6066 
6067       -- Code added for bug 2216899
6068 
6069       IF x_line_tbl_type(k).ship_from_org_id is not null THEN
6070             IF nvl(l_x_line_tbl(i).ship_from_org_id,-1)<>nvl(x_line_tbl_type(k).ship_from_org_id,-1)  THEN
6071           IF l_ref_split_ship_from = 'Y' THEN --14654985
6072           l_line_tbl(l_rec_count).ship_from_org_id := x_line_tbl_type(k).ship_from_org_id;
6073           l_line_tbl(l_rec_count).subinventory := fnd_api.g_miss_char; --Added as a part of 14654985 for Bug 13560415, do not use nullnull;
6074 	 ELSE
6075               oe_debug_pub.ADD('Inside else Condition');
6076 		l_line_tbl(l_rec_count).ship_from_org_id := l_x_line_tbl(i).ship_from_org_id;
6077           	l_line_tbl(l_rec_count).subinventory := fnd_api.g_miss_char; --Added as a part of 14654985 for Bug 13560415, do not use nullnull;
6078               end if ; --14654985
6079 
6080               l_process_add_attributes:=TRUE;
6081             END IF; -- if ship_from_changed
6082           END IF; -- ship_from not null
6083 
6084       -- end 2216899
6085 
6086           IF x_line_tbl_type(k).request_date is not null THEN
6087             IF nvl(l_x_line_tbl(i).request_date,sysdate)<> nvl(x_line_tbl_type(k).request_date,sysdate) THEN
6088               l_line_tbl(l_rec_count).request_date := x_line_tbl_type(k).request_date;
6089               l_process_add_attributes:=TRUE;
6090             END IF;
6091           END IF;
6092 
6093           l_line_tbl(l_rec_count).operation := OE_GLOBALS.G_OPR_UPDATE;
6094           IF l_debug_level > 0 THEN
6095              OE_DEBUG_PUB.add('Reason code being passed : '||l_line_tbl(l_rec_count).change_reason,1);
6096              OE_DEBUG_PUB.add('Warehouse :'||l_line_tbl(l_rec_count).ship_from_org_id,1);
6097           END IF;
6098           l_line_tbl(l_rec_count).change_reason := p_change_reason_code;
6099           l_line_tbl(l_rec_count).change_comments := p_change_comments;
6100           l_line_tbl(l_rec_count).split_action_code := fnd_api.g_miss_char;
6101           l_line_tbl(l_rec_count).line_id := l_x_line_tbl(i).line_id;
6102           l_line_tbl(l_rec_count).header_id := l_x_line_tbl(i).header_id;
6103 
6104           l_rec_count := l_rec_count + 1;
6105           EXIT;
6106         END IF;  -- if l_line_id matches a line_id in x_line_tbl_type
6107       END LOOP;  -- loop on index k
6108     END IF;  -- If item_type_code = 'SERVICE'
6109   END LOOP; -- First For Loop
6110 
6111 /* end of 1988144 */
6112 /* this l_line_tbl is passed to the process Order API */
6113 
6114 
6115      l_x_Header_Adj_tbl.delete;
6116      l_x_header_price_att_tbl.delete;
6117      l_x_Header_Adj_att_tbl.delete;
6118      l_x_Header_Adj_Assoc_tbl.delete;
6119      l_x_Header_Scredit_tbl.delete;
6120      l_x_Line_Adj_tbl.delete;
6121      l_x_Line_Price_att_tbl.delete;
6122      l_x_Line_Adj_att_tbl.delete;
6123      l_x_Line_Adj_Assoc_tbl.delete;
6124      l_x_Line_Scredit_tbl.delete;
6125      l_x_lot_serial_tbl.delete;
6126 
6127 
6128      IF  l_process_add_attributes THEN
6129       Oe_Order_Pvt.Process_order
6130        (   p_api_version_number          => 1.0
6131         ,   p_init_msg_list               => FND_API.G_TRUE
6132         ,   x_return_status               => l_return_status
6133         ,   x_msg_count                   => x_msg_count
6134         ,   x_msg_data                    => x_msg_data
6135         ,   p_control_rec                 => l_control_rec
6136         ,   p_x_line_tbl                    => l_line_tbl
6137         ,   p_x_header_rec                  => l_x_header_rec
6138         ,   p_x_Header_Adj_tbl              => l_x_Header_Adj_tbl
6139         ,   p_x_header_price_att_tbl        => l_x_header_price_att_tbl
6140         ,   p_x_Header_Adj_att_tbl          => l_x_Header_Adj_att_tbl
6141         ,   p_x_Header_Adj_Assoc_tbl        => l_x_Header_Adj_Assoc_tbl
6142         ,   p_x_Header_Scredit_tbl          => l_x_Header_Scredit_tbl
6143 --serla begin
6144         ,   p_x_Header_Payment_tbl          => l_x_Header_Payment_tbl
6145 --serla end
6146         ,   p_x_Line_Adj_tbl                => l_x_Line_Adj_tbl
6147         ,   p_x_Line_Price_att_tbl          => l_x_Line_Price_att_tbl
6148         ,   p_x_Line_Adj_att_tbl            => l_x_Line_Adj_att_tbl
6149         ,   p_x_Line_Adj_Assoc_tbl          => l_x_Line_Adj_Assoc_tbl
6150         ,   p_x_Line_Scredit_tbl            => l_x_Line_Scredit_tbl
6151 --serla begin
6152         ,   p_x_Line_Payment_tbl            => l_x_Line_Payment_tbl
6153 --serla end
6154         ,   p_x_action_request_tbl          => l_x_Action_Request_tbl
6155         ,   p_x_lot_serial_tbl              => l_x_lot_serial_tbl
6156 
6157         );
6158 
6159 
6160      END IF;
6161 
6162      IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6163        RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6164      ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6165        RAISE FND_API.G_EXC_ERROR;
6166      END IF;
6167 
6168    END IF;
6169    x_return_status := FND_API.G_RET_STS_SUCCESS;
6170 
6171     --  Get message count and data
6172 
6173     oe_msg_pub.count_and_get
6174     (   p_count                       => x_msg_count
6175     ,   p_data                        => x_msg_data
6176     );
6177 
6178 EXCEPTION
6179 
6180     WHEN FND_API.G_EXC_ERROR THEN
6181 
6182         x_return_status := FND_API.G_RET_STS_ERROR;
6183 
6184         --  Get message count and data
6185 
6186         oe_msg_pub.count_and_get
6187         (   p_count                       => x_msg_count
6188         ,   p_data                        => x_msg_data
6189         );
6190 
6191     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6192 
6193         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6194 
6195         --  Get message count and data
6196 
6197         oe_msg_pub.count_and_get
6198         (   p_count                       => x_msg_count
6199         ,   p_data                        => x_msg_data
6200         );
6201 
6202     WHEN OTHERS THEN
6203 
6204         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6205 
6206         IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
6207         THEN
6208             oe_msg_pub.Add_Exc_Msg
6209             (   G_PKG_NAME
6210             ,   'Split Lines'
6211             );
6212         END IF;
6213 
6214         --  Get message count and data
6215 
6216         oe_msg_pub.count_and_get
6217         (   p_count                       => x_msg_count
6218         ,   p_data                        => x_msg_data
6219         );
6220 
6221 END SPLIT_LINE;
6222 
6223 -- This procedure will be called from the client when the user
6224 -- clears a record
6225 Procedure Clear_Record
6226 ( x_return_status OUT NOCOPY VARCHAR2
6227 , x_msg_count OUT NOCOPY NUMBER
6228 , x_msg_data OUT NOCOPY VARCHAR2
6229 ,   p_line_id                     IN  NUMBER
6230 )
6231 IS
6232 l_return_status                     Varchar2(30);
6233 l_count_to_keep			    NUMBER;
6234 --
6235 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6236 --
6237 /* l_new_line_rec     OE_Order_PUB.Line_Rec_Type; --3445778
6238  l_old_line_rec     OE_Order_PUB.Line_Rec_Type; --3445778
6239  l_index            NUMBER;  --3445778 */
6240  l_header_id        NUMBER;
6241 BEGIN
6242     OE_MSG_PUB.initialize;
6243     x_return_status := FND_API.G_RET_STS_SUCCESS;
6244 
6245      -- Bug 3800577
6246      -- Clear versioning globals if request was not logged. If request was
6247      -- logged, that indicates that a change on another record had logged the
6248      -- request and versioning should still fire.
6249 
6250      IF OE_GLOBALS.G_ROLL_VERSION <> 'N' THEN
6251 
6252         l_header_id := g_line_rec.header_id;
6253 
6254         if l_debug_level > 0 then
6255         oe_debug_pub.add('Roll version global is set');
6256         oe_debug_pub.add('Header ID: '||l_header_id);
6257         end if;
6258 
6259         IF NOT OE_Delayed_Requests_Pvt.Check_For_Request
6260                                 (p_entity_code => OE_GLOBALS.G_ENTITY_ALL
6261                                 ,p_entity_id => l_header_id
6262                                 ,p_request_type => OE_GLOBALS.G_VERSION_AUDIT
6263                                 )
6264         THEN
6265            oe_debug_pub.add('Request does not exist, reset versioning globals');
6266            IF (NOT OE_Versioning_Util.Reset_Globals) THEN
6267                l_return_status := FND_API.G_RET_STS_ERROR;
6268                RETURN;
6269            END IF;
6270         END IF;
6271 
6272      END IF;
6273 
6274     OE_DELAYED_REQUESTS_PVT.Delete_Reqs_for_Deleted_Entity(
6275                          p_entity_code  => OE_GLOBALS.G_ENTITY_LINE
6276                          ,p_entity_id    => p_line_id
6277                          -- Bug 3800577
6278                          -- Also delete requests logged by this entity
6279                          ,p_delete_against => FALSE
6280                          ,x_return_status => l_return_status);
6281 
6282 /*    -- Added for bug 3445778 --Commenting the code for 3575018
6283     oe_debug_pub.add('Executing code for updating global picture, line_id: ' || p_line_id, 1);
6284 
6285     -- Set the operation on the record so that globals are updated
6286      l_new_line_rec.operation := OE_GLOBALS.G_OPR_DELETE;
6287      l_new_line_rec.line_id := p_line_id;
6288      l_old_line_rec.line_id := p_line_id;
6289 
6290       OE_ORDER_UTIL.Update_Global_Picture(p_Upd_New_Rec_If_Exists => True,
6291                     p_line_rec => l_new_line_rec,
6292                     p_line_id => p_line_id,
6293                     p_old_line_rec => l_old_line_rec,
6294                     x_index => l_index,
6295                     x_return_status => l_return_status);
6296 
6297     -- End of 3445778 */
6298 
6299     --bug#3947584
6300    --Calling procedure to remove fulfillment set info for the record
6301 
6302 --bug # 6059554--
6303    --Before calling procedure OE_Set_Util.Remove_From_Fulfilment to remove the fulfillment information,
6304    --check whether Order line exists in oe_order_lines_all or not.If it does
6305    --not exists then only Call OE_Set_Util.Remove_From_Fulfilment to remove the fulfillment set information for the
6306    --line otherwise we will not remove the fulfillment information from line.
6307 
6308     select count(1) into l_count_to_keep
6309     from oe_order_lines_all
6310     where line_id=p_line_id;
6311 
6312     if l_count_to_keep = 0 then
6313 
6314          OE_Set_Util.Remove_From_Fulfillment(p_line_id => p_line_id);
6315 
6316     end if;
6317 
6318 --Close for bug #6059554--
6319 
6320 
6321     OE_MSG_PUB.Count_And_Get
6322       (   p_count                       => x_msg_count
6323         ,   p_data                        => x_msg_data
6324        );
6325 
6326 
6327    -- Clear the controller cache, so that it will not be used for
6328    -- next operation on same record
6329 
6330     Clear_line;
6331 
6332 EXCEPTION
6333     WHEN OTHERS THEN
6334         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6335         THEN
6336             OE_MSG_PUB.Add_Exc_Msg
6337             (   G_PKG_NAME
6338             ,   'Clear_Record'
6339             );
6340         END IF;
6341         --  Get message count and data
6342         OE_MSG_PUB.Count_And_Get
6343         (   p_count                       => x_msg_count
6344         ,   p_data                        => x_msg_data
6345         );
6346         x_return_status := FND_API.G_RET_STS_ERROR;
6347 
6348 END Clear_Record;
6349 
6350 FUNCTION Get_Date_Type
6351 ( p_header_id      IN NUMBER)
6352 RETURN VARCHAR2
6353 IS
6354 l_order_date_type_code   VARCHAR2(30) := null;
6355 --
6356 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6357 --
6358 BEGIN
6359 
6360   SELECT order_date_type_code
6361   INTO   l_order_date_type_code
6362   FROM   oe_order_headers
6363   WHERE  header_id = p_header_id;
6364 
6365   RETURN l_order_date_type_code;
6366 
6367 
6368 EXCEPTION
6369   WHEN NO_DATA_FOUND THEN
6370         RETURN NULL;
6371   WHEN OTHERS THEN
6372        RETURN null;
6373 END Get_Date_Type;
6374 
6375 --Start for bug 16574638
6376 PROCEDURE Get_return_reference
6377 ( p_line_id           IN NUMBER,
6378   x_return_context    OUT NOCOPY VARCHAR2,
6379   x_return_attribute1 OUT NOCOPY VARCHAR2,
6380   x_return_attribute2 OUT NOCOPY VARCHAR2)
6381 IS
6382 BEGIN
6383 
6384   SELECT return_context, return_attribute1, return_attribute2
6385   INTO   x_return_context, x_return_attribute1, x_return_attribute2
6386   FROM   oe_order_lines
6387   WHERE  line_id = p_line_id;
6388 
6389 EXCEPTION
6390   WHEN OTHERS THEN NULL;
6391 END Get_return_reference;
6392 --End for 16574638
6393 
6394 PROCEDURE Ship_To_Customer_Id(
6395                               p_ship_to_org_id IN Number,
6396 x_ship_to_Customer_id OUT NOCOPY Number
6397                               ) IS
6398 l_site_use_code VARCHAR2(30);
6399 
6400 --
6401 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6402 --
6403 BEGIN
6404     l_site_use_code := 'SHIP_TO';
6405 
6406            SELECT  /* MOAC_SQL_CHANGE */ cas.cust_account_id
6407         INTO    x_ship_to_customer_id
6408         FROM    HZ_CUST_SITE_USES_ALL site,
6409                 HZ_CUST_ACCT_SITES_ALL cas
6410         WHERE   site.cust_acct_site_id = cas.cust_acct_site_id
6411         AND     site.site_use_code=l_site_use_code
6412         AND     site.site_use_id=p_ship_to_org_id;
6413 
6414 EXCEPTION
6415 
6416         WHEN NO_DATA_FOUND THEN
6417          Null;
6418         When too_many_rows then
6419          Null;
6420         When others then
6421          Null;
6422 END Ship_To_Customer_Id;
6423 
6424 
6425 PROCEDURE Invoice_To_Customer_Id(
6426                               p_invoice_to_org_id IN Number,
6427 x_invoice_to_Customer_id OUT NOCOPY Number
6428                               ) IS
6429 
6430 l_site_use_code VARCHAR2(30);
6431 --
6432 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6433 --
6434 BEGIN
6435     l_site_use_code := 'BILL_TO';
6436 
6437            SELECT /* MOAC_SQL_CHANGE */  cas.cust_account_id
6438         INTO    x_invoice_to_customer_id
6439         FROM    HZ_CUST_SITE_USES_ALL site,
6440                 HZ_CUST_ACCT_SITES_ALL cas
6441         WHERE   site.cust_acct_site_id = cas.cust_acct_site_id
6442         AND     site.site_use_code=l_site_use_code
6443         AND     site.site_use_id=p_invoice_to_org_id;
6444 
6445 
6446 EXCEPTION
6447 
6448         WHEN NO_DATA_FOUND THEN
6449          Null;
6450         When too_many_rows then
6451          Null;
6452         When others then
6453          Null;
6454 END Invoice_To_Customer_Id;
6455 
6456 PROCEDURE GET_LINE_SHIPMENT_NUMBER(
6457 x_return_status OUT NOCOPY VARCHAR2
6458 , x_msg_count OUT NOCOPY NUMBER
6459 , x_msg_data OUT NOCOPY VARCHAR2
6460                                   ,   p_header_id                     IN  Number
6461 , x_line_id OUT NOCOPY Number
6462 , x_line_number OUT NOCOPY Number
6463 , x_shipment_number OUT NOCOPY Number
6464                                    )  IS
6465 l_line_number Number;
6466 --
6467 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6468 --
6469 BEGIN
6470     SELECT  OE_ORDER_LINES_S.NEXTVAL
6471     INTO    x_line_id
6472     FROM    DUAL;
6473 
6474     SELECT  NVL(MAX(LINE_NUMBER)+1,1)
6475     INTO    x_line_number
6476     FROM    OE_ORDER_LINES_ALL
6477     WHERE   HEADER_ID = p_header_id;
6478     l_line_number:=x_line_number;
6479   IF x_line_number IS NOT NULL THEN
6480     SELECT  NVL(MAX(SHIPMENT_NUMBER)+1,1)
6481     INTO    x_shipment_number
6482     FROM    OE_ORDER_LINES
6483     WHERE   HEADER_ID = p_header_id
6484     AND     LINE_NUMBER = l_line_number;
6485   END IF;
6486 
6487 EXCEPTION
6488 
6489     WHEN OTHERS THEN
6490 
6491         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6492         THEN
6493             OE_MSG_PUB.Add_Exc_Msg
6494             (   G_PKG_NAME
6495             ,   'Get_Line_Shipment_Number'
6496             );
6497         END IF;
6498 
6499         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6500 
6501 END GET_LINE_SHIPMENT_NUMBER;
6502 
6503 
6504 /*--- Bug 1823073 start----- */
6505 -- This Get_ORDERED_ITEM procedure is called from OEXOELIN.pld
6506 -- Added this procedure to provide ordered_item
6507 -- and fix the problem cauesd by null ordered_item
6508 PROCEDURE GET_ORDERED_ITEM ( x_return_status OUT NOCOPY VARCHAR2
6509 , x_msg_count OUT NOCOPY NUMBER
6510 , x_msg_data OUT NOCOPY VARCHAR2
6511                                  ,   p_item_identifier_type          IN VARCHAR2
6512                                  ,   p_inventory_item_id             IN Number
6513                                  ,   p_ordered_item_id               IN Number
6514                                  ,   p_sold_to_org_id                IN Number
6515 , x_ordered_item OUT NOCOPY VARCHAR2
6516                          ) IS
6517 
6518 l_organization_id             Number:= OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');
6519 --bug 10047225
6520 l_valid_kff	boolean;
6521 --
6522 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6523 --
6524 BEGIN
6525    IF l_debug_level  > 0 THEN
6526        oe_debug_pub.add(  'ENTER GET_ORDERED_ITEM PROCEDURE' ) ;
6527        oe_debug_pub.add(  'ITEM_IDENTIFIER_TYPE : '||P_ITEM_IDENTIFIER_TYPE ) ;
6528        oe_debug_pub.add(  'INVENTORY_ITEM_ID : '||P_INVENTORY_ITEM_ID ) ;
6529        oe_debug_pub.add(  'ORDERED_ITEM_ID : '||P_ORDERED_ITEM_ID ) ;
6530        oe_debug_pub.add(  'SOLD_TO_ORG_ID : '||P_SOLD_TO_ORG_ID ) ;
6531    END IF;
6532 
6533    IF NVL(p_item_identifier_type, 'INT') = 'INT' THEN
6534 
6535       BEGIN
6536       --bug 10047225
6537       l_valid_kff := fnd_flex_keyval.validate_ccid(
6538                     APPL_SHORT_NAME=>'INV',
6539                     KEY_FLEX_CODE=>'MSTK',
6540                     STRUCTURE_NUMBER=>101,
6541                     COMBINATION_ID=>p_inventory_item_id,
6542                     DISPLAYABLE=>'ALL',
6543                     DATA_SET=>l_organization_id,
6544                     VRULE=>NULL,
6545                     SECURITY=>'IGNORE',
6546                     GET_COLUMNS=>NULL,
6547                     RESP_APPL_ID=>NULL,
6548                     RESP_ID=>NULL,
6549                     USER_ID=>NULL
6550                   );
6551 
6552       	if l_valid_kff then
6553       		oe_debug_pub.add('10047225: Proc GET_ORDERED_ITEM:l_valid_kff: TRUE');
6554       		x_ordered_item:= fnd_flex_keyval.concatenated_values;
6555 
6556       	end if;
6557 	oe_debug_pub.add('10047225:Proc GET_ORDERED_ITEM: x_ordered_item:'||x_ordered_item);
6558       --end of bug 10047225
6559       /* Commented for Bug 10047225
6560          SELECT  concatenated_segments
6561          INTO x_ordered_item
6562          FROM  MTL_SYSTEM_ITEMS_KFV
6563          WHERE inventory_item_id = p_inventory_item_id
6564          AND organization_id = l_organization_id;
6565       */
6566       EXCEPTION
6567         WHEN NO_DATA_FOUND THEN
6568            Null;
6569         When too_many_rows then
6570        Null;
6571     When others then
6572        Null;
6573       END;
6574    ELSIF NVL(p_item_identifier_type, 'INT') = 'CUST' and p_ordered_item_id is not null and p_sold_to_org_id is not null  THEN
6575       BEGIN
6576          SELECT citems.customer_item_number
6577          INTO  x_ordered_item
6578          FROM  mtl_customer_items citems
6579               ,mtl_customer_item_xrefs cxref
6580               ,mtl_system_items_vl sitems
6581          WHERE citems.customer_item_id = cxref.customer_item_id
6582            AND cxref.inventory_item_id = sitems.inventory_item_id
6583            AND sitems.inventory_item_id = p_inventory_item_id
6584            AND sitems.organization_id = l_organization_id
6585            AND citems.customer_item_id = p_ordered_item_id
6586            AND citems.customer_id = p_sold_to_org_id;
6587 
6588       EXCEPTION
6589         WHEN NO_DATA_FOUND THEN
6590            Null;
6591         When too_many_rows then
6592        Null;
6593     When others then
6594        Null;
6595       END;
6596    END IF;
6597    IF l_debug_level  > 0 THEN
6598        oe_debug_pub.add(  'EXIT GET_ORDERED_ITEM PROCEDURE' ) ;
6599    END IF;
6600 
6601 EXCEPTION
6602 
6603     WHEN OTHERS THEN
6604 
6605         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6606         THEN
6607             OE_MSG_PUB.Add_Exc_Msg
6608             (   G_PKG_NAME
6609             ,   'GET_ORDERED_ITEM'
6610             );
6611         END IF;
6612 
6613         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6614 
6615 END GET_ORDERED_ITEM;
6616 /*--- Bug 1823073 end----- */
6617 
6618 -- Bug 1713035
6619 -- This procedure is called from OEXOELIN.pld
6620 -- to delete the current line and all associated
6621 -- adjustments.  This new procedure was added
6622 -- to reduce the number of calls to server side
6623 -- packages from the form.
6624 PROCEDURE Delete_Adjustments(x_line_id IN NUMBER) IS
6625 
6626 l_return_status Varchar2(1);
6627 
6628 --
6629 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6630 --
6631 BEGIN
6632    OE_LINE_ADJ_UTIL.Delete_Row(p_line_id=>x_line_id);
6633 
6634    /* 1905650
6635       This is no longer required, since G_PRICE_ADJ request
6636       is logged against LINE entity now
6637 
6638    oe_debug_pub.add('delete the request logged for this line too');
6639    oe_delayed_requests_pvt.delete_request(
6640                p_entity_code =>OE_GLOBALS.G_ENTITY_LINE_ADJ,
6641                p_entity_id => x_line_id,
6642                        p_request_type => OE_GLOBALS.G_PRICE_ADJ,
6643                        x_return_status => l_return_status);
6644    */
6645 
6646 END Delete_Adjustments;
6647 
6648 PROCEDURE get_customer_details( p_site_use_id IN NUMBER,
6649                                 p_site_use_code IN VARCHAR2,
6650 x_customer_id OUT NOCOPY NUMBER,
6651 x_customer_name OUT NOCOPY VARCHAR2,
6652 x_customer_number OUT NOCOPY VARCHAR2
6653                                      ) IS
6654 
6655 --
6656 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6657 --
6658 BEGIN
6659 
6660 /* 2172651*/
6661         select /* MOAC_SQL_CHANGE */ cust.cust_account_id,
6662                party.party_name,
6663                cust.account_number
6664             INTO   x_customer_id,
6665                        x_customer_name,
6666                        x_customer_number
6667         from
6668                hz_cust_site_uses_all site,
6669                hz_cust_acct_sites_all cas,
6670                        hz_cust_accounts cust,
6671                        hz_parties party
6672                 where site.site_use_code = p_site_use_code
6673         and site_use_id = p_site_use_id
6674         and site.cust_acct_site_id = cas.cust_acct_site_id
6675         and cas.cust_account_id = cust.cust_account_id
6676         and cust.party_id=party.party_id;
6677 /* 2172651*/
6678 
6679 EXCEPTION
6680 
6681         WHEN NO_DATA_FOUND THEN
6682          Null;
6683         When too_many_rows then
6684          Null;
6685        When others then
6686         Null;
6687 
6688 END get_customer_details;
6689 
6690 -- for 5331980 start**
6691 PROCEDURE Reset_calculate_line_total IS
6692 BEGIN
6693 OE_GLOBALS.G_CALCULATE_LINE_TOTAL := TRUE;
6694 END Reset_Calculate_line_Total;
6695 --for 5331980 end**
6696 
6697 END oe_oe_form_line;