1 PACKAGE BODY OE_Default_Line AS
2 /* $Header: OEXDLINB.pls 120.24.12010000.6 2008/11/26 16:01:37 vmachett ship $ */
3
4 -- Global constant holding the package name
5
6 G_PKG_NAME CONSTANT VARCHAR2(30) := 'OE_Default_Line';
7
8
9 g_line_rec OE_Order_PUB.Line_Rec_Type;
10
11 FUNCTION Get_Def_Invoice_Line_Int
12 (p_return_context IN VARCHAR2,
13 p_return_attribute1 IN VARCHAR2,
14 p_return_attribute2 IN VARCHAR2,
15 p_sold_to_org_id IN NUMBER,
16 p_curr_code IN VARCHAR2,
17 p_ref_line_id OUT NOCOPY NUMBER
18
19 ) RETURN NUMBER;
20
21 /* Added procedure default_active_agr_revision for Bug 2154960 */
22
23 procedure Default_Active_Agr_Revision
24 ( p_x_line_rec IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type,
25 p_old_line_rec IN OE_Order_PUB.Line_Rec_Type :=
26 OE_Order_PUB.G_MISS_LINE_REC
27 );
28
29 /* Added blanket values defaulting
30 --Made this procedure public
31 --By Srini
32
33
34 PROCEDURE Default_Blanket_Values
35 ( p_blanket_number IN NUMBER,
36 p_cust_po_number IN VARCHAR2,
37 p_ordered_item IN VARCHAR2,
38 p_inventory_item_id IN NUMBER,
39 p_item_identifier_type IN VARCHAR2,
40 p_request_date IN DATE,
41 p_sold_to_org_id IN NUMBER,
42 x_blanket_number OUT NOCOPY NUMBER,
43 x_blanket_line_number OUT NOCOPY NUMBER,
44 x_blanket_version_number OUT NOCOPY NUMBER,
45 x_blanket_request_date OUT NOCOPY DATE
46 );
47 */
48
49 -- bug 4668200
50 PROCEDURE Set_Header_Def_Hdlr_Rec (p_header_id IN NUMBER) ;
51
52 FUNCTION Get_Sold_To
53 RETURN NUMBER
54 IS
55 --
56 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
57 --
58 BEGIN
59
60 OE_ORDER_CACHE.Load_Order_Header(g_line_rec.header_id);
61 RETURN (OE_ORDER_CACHE.g_header_rec.SOLD_TO_ORG_ID);
62
63 EXCEPTION
64 WHEN OTHERS THEN
65 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
66 THEN
67 OE_MSG_PUB.Add_Exc_Msg
68 ( G_PKG_NAME,
69 'Get_Sold_To'
70 );
71 END IF;
72 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
73 END Get_Sold_To;
74
75 FUNCTION Get_Order_Source_Id
76 RETURN NUMBER
77 IS
78 --
79 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
80 --
81 BEGIN
82 --For Bug#7592137
83 IF OE_GLOBALS.G_UI_FLAG then
84 RETURN 0;
85 ELSE
86 OE_ORDER_CACHE.Load_Order_Header(g_line_rec.header_id);
87 IF l_debug_level > 0 THEN
88 oe_debug_pub.add( 'SOURCE ID ='||OE_ORDER_CACHE.G_HEADER_REC.ORDER_SOURCE_ID ) ;
89 END IF;
90 RETURN (OE_ORDER_CACHE.g_header_rec.order_source_id);
91 END IF; --End of Bug#7592137
92
93 EXCEPTION
94 WHEN OTHERS THEN
95 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
96 THEN
97 OE_MSG_PUB.Add_Exc_Msg
98 ( G_PKG_NAME,
99 'Get_Order_Source_Id'
100 );
101 END IF;
102 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
103
104 END Get_Order_Source_Id;
105
106 FUNCTION GET_FREIGHT_CARRIER(p_line_rec OE_ORDER_PUB.Line_Rec_Type,
107 p_old_line_rec OE_ORDER_PUB.Line_Rec_Type)
108 RETURN VARCHAR2
109 IS
110 l_freight_code VARCHAR2(80);
111 --
112 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
113 --
114 begin
115 IF l_debug_level > 0 THEN
116 oe_debug_pub.add( 'ENTER GET FREIGHT CARRIER' ) ;
117 END IF;
118
119
120 IF (p_line_rec.shipping_method_code IS NOT NULL AND
121 p_line_rec.shipping_method_code <> FND_API.G_MISS_CHAR) AND
122 (p_line_rec.ship_from_org_id IS NOT NULL AND
123 p_line_rec.ship_from_org_id<> FND_API.G_MISS_NUM) THEN
124
125 -- 3610480 : Validate freight_carrier_code if shipping_method_code or ship_from_org_id is not null
126 IF (NOT OE_GLOBALS.EQUAL(p_line_rec.shipping_method_code
127 ,p_old_line_rec.shipping_method_code) OR
128 NOT OE_GLOBALS.EQUAL(p_line_rec.ship_from_org_id
129 ,p_old_line_rec.ship_from_org_id) OR
130 NOT OE_GLOBALS.EQUAL(p_line_rec.freight_carrier_code
131 ,p_old_line_rec.freight_carrier_code)) THEN
132
133 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110509' THEN
134
135 SELECT freight_code
136 INTO l_freight_code
137 FROM wsh_carriers wsh_ca,wsh_carrier_services wsh,
138 wsh_org_carrier_services wsh_org
139 WHERE wsh_org.organization_id = p_line_rec.ship_from_org_id
140 AND wsh.carrier_service_id = wsh_org.carrier_service_id
141 AND wsh_ca.carrier_id = wsh.carrier_id
142 AND wsh.ship_method_code = p_line_rec.shipping_method_code
143 AND wsh_org.enabled_flag = 'Y';
144 ELSE
145 Select freight_code
146 into l_freight_code
147 from wsh_carrier_ship_methods
148 where ship_method_code = p_line_rec.shipping_method_code
149 and ORGANIZATION_ID = p_line_rec.ship_from_org_id;
150 END IF;
151
152 IF l_debug_level > 0 THEN
153 oe_debug_pub.add( 'EXIT GET FREIGHT CARRIER' || L_FREIGHT_CODE ) ;
154 END IF;
155 RETURN l_freight_code;
156
157 ELSE
158 IF l_debug_level > 0 THEN
159 oe_debug_pub.add( 'INTO NULL CONDITION' || P_LINE_REC.SHIP_FROM_ORG_ID ) ;
160 END IF;
161 RETURN p_line_rec.freight_carrier_code;
162
163 END IF;
164 ELSE
165 IF l_debug_level > 0 THEN
166 oe_debug_pub.add( 'SHIP FROM OR SHIP METHOD IS NULL/MISSING',1 ) ;
167 END IF;
168 RETURN NULL;
169 END IF;
170
171 IF (p_line_rec.shipping_method_code IS NULL OR
172 p_line_rec.shipping_method_code = FND_API.G_MISS_CHAR) THEN
173 RETURN NULL;
174 END IF;
175
176
177 RETURN p_line_rec.freight_carrier_code;
178
179 EXCEPTION
180
181 WHEN NO_DATA_FOUND THEN
182
183 IF l_debug_level > 0 THEN
184 oe_debug_pub.add( 'NO DATA FOUND GET FREIGHT CARRIER' ) ;
185 END IF;
186 RETURN NULL;
187
188 WHEN OTHERS THEN
189 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
190 THEN
191 OE_MSG_PUB.Add_Exc_Msg
192 ( G_PKG_NAME ,
193 'Get_freight_carrier'
194 );
195 END IF;
196 IF l_debug_level > 0 THEN
197 oe_debug_pub.add( 'OTHERS IN GET_FREIGHT_CARRIER' , 1 ) ;
198 END IF;
199 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
200
201
202 END GET_FREIGHT_CARRIER;
203
204 FUNCTION Get_Booked
205 RETURN VARCHAR2
206 IS
207 l_booked_flag VARCHAR2(1);
208 --
209 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
210 --
211 BEGIN
212
213 IF NOT oe_globals.G_HTML_FLAG THEN
214
215 -- use order_header cache instead of sql : bug 4200055
216 if ( OE_Order_Cache.g_header_rec.header_id <> FND_API.G_MISS_NUM
217 and OE_Order_Cache.g_header_rec.header_id IS NOT NULL
218 and OE_Order_Cache.g_header_rec.header_id = g_line_rec.header_id ) then
219 l_booked_flag := OE_Order_Cache.g_header_rec.booked_flag ;
220 else
221 OE_ORDER_CACHE.Load_Order_Header(g_line_rec.header_id);
222 l_booked_flag := OE_Order_Cache.g_header_rec.booked_flag ;
223 end if ;
224
225 /*SELECT booked_flag
226 INTO l_booked_flag
227 FROM oe_order_headers_all
228 WHERE header_id = g_line_rec.header_id; */
229 ELSE
230 l_booked_flag := 'N';
231 END IF;
232
233 RETURN l_booked_flag;
234
235 END Get_Booked;
236
237 FUNCTION Get_Cancelled
238 RETURN VARCHAR2
239 IS
240 --
241 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
242 --
243 BEGIN
244
245 RETURN 'N';
246
247 END Get_Cancelled;
248
249 FUNCTION Get_Open
250 RETURN VARCHAR2
251 IS
252 --
253 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
254 --
255 BEGIN
256
257 RETURN 'Y';
258
259 END Get_Open;
260
261 FUNCTION Get_Cancelled_Quantity
262 RETURN NUMBER
263 IS
264 --
265 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
266 --
267 BEGIN
268
269 RETURN 0;
270
271 END Get_Cancelled_Quantity;
272
273
274 /*---------------------------------------------------------
275 Following procedures are mainly related to lines which are
276 model/class/option/config/ato_item/kit/included/
277
278 1) get_component
279 2) get_top_model_line
280 3) model_option_defaulting
281 4) get_ato_line
282 ----------------------------------------------------------*/
283 FUNCTION Get_Component
284 RETURN VARCHAR2
285 IS
286 --
287 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
288 --
289 BEGIN
290
291 IF l_debug_level > 0 THEN
292 oe_debug_pub.add( ' COMP_CODE , ITEM_TYPE_CODE ' || G_LINE_REC.ITEM_TYPE_CODE ) ;
293 END IF;
294 IF (g_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL) OR
295 (g_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT AND
296 g_line_rec.line_id = g_line_rec.top_model_line_id)
297 THEN
298 g_line_rec.component_code := to_char(g_line_rec.inventory_item_id);
299 RETURN g_line_rec.component_code;
300 END IF;
301
302 RETURN NULL;
303
304 END Get_Component;
305
306
307 /*----------------------------------------------------------------
308 FUNCTION Get_Top_Model_Line
309 -----------------------------------------------------------------*/
310
311 FUNCTION Get_Top_Model_Line
312 RETURN NUMBER
313 IS
314 l_top_model_line_id NUMBER;
315 l_pick_components_flag VARCHAR2(1);
316 l_item_type NUMBER;
317 --
318 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
319 --
320 BEGIN
321
322 -- If top_model_line_id is not null, you do not want to clear it
323 IF l_debug_level > 0 THEN
324 oe_debug_pub.add( 'IN PKG OE_DEFAULT_LINE : PROCEDURE GET_TOP_MODEL_LINE' ) ;
325 END IF;
326
327 IF ( g_line_rec.inventory_item_id is NULL OR
328 g_line_rec.inventory_item_id = FND_API.G_MISS_NUM)
329 THEN
330 RETURN NULL;
331 END IF;
332
333 IF g_line_rec.line_category_code = OE_GLOBALS.G_RETURN_CATEGORY_CODE THEN
334 RETURN NULL;
335 ELSE
336 -- class/option, avoid setting value to null by the last return.
337 IF g_line_rec.top_model_line_id <> FND_API.G_MISS_NUM THEN
338 RETURN g_line_rec.top_model_line_id;
339 END IF;
340
341 END IF;
342
343 OE_ORDER_CACHE.Load_Item
344 (p_key1 => g_line_rec.inventory_item_id
345 ,p_key2 => g_line_rec.ship_from_org_id);
346 l_item_type := OE_ORDER_CACHE.g_item_rec.bom_item_type;
347 l_pick_components_flag := OE_ORDER_CACHE.g_item_rec.pick_components_flag;
348
349 IF (l_item_type = 4 AND
350 l_pick_components_flag = 'Y') OR -- KIT
351 l_item_type = 1 -- MODEL
352 THEN
353 IF (g_line_rec.line_id is NOT NULL AND
354 g_line_rec.line_id <> FND_API.G_MISS_NUM)
355 THEN
356 l_top_model_line_id := g_line_rec.line_id;
357 RETURN (l_top_model_line_id);
358 ELSE
359 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
360 END IF;
361 ELSE
362 RETURN NULL;
363 END IF;
364
365 EXCEPTION
366 WHEN NO_DATA_FOUND THEN
367 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_ITEM_NOT_FOUND');
368 IF ( g_line_rec.ordered_item is NULL OR -- This IF added for 1722670
369 g_line_rec.ordered_item = FND_API.G_MISS_CHAR) THEN
370 FND_MESSAGE.Set_TOKEN('ITEM',
371 'Item with inventory_item_id='||to_char(g_line_rec.inventory_item_id));
372 ELSE
373 FND_MESSAGE.Set_TOKEN('ITEM', nvl(g_line_rec.ordered_item,g_line_rec.inventory_item_id));
374 END IF;
375 -- FND_MESSAGE.Set_TOKEN('ITEM', g_line_rec.ordered_item); Replaced with the above IF for 1722670
376 FND_MESSAGE.Set_TOKEN
377 ('ORG',OE_SYS_PARAMETERS.VALUE('MASTER_ORGANIZATION_ID'));
378 -- oe_organization_id is drpped,
379 -- hence need to call OE_SYS_PARAMETERS.Value('MASTER_ORGANIZATION_ID');
380
381 OE_Msg_Pub.Add;
382
383 IF l_debug_level > 0 THEN
384 oe_debug_pub.add( 'NO DATA FOUND IN GET_TOP_MODEL IN DEFAULTING' , 1 ) ;
385 END IF;
386
387 RAISE FND_API.G_EXC_ERROR;
388
389 WHEN OTHERS THEN
390
391 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
392 THEN
393 OE_MSG_PUB.Add_Exc_Msg
394 ( G_PKG_NAME ,
395 'Get_Top_Model_Line'
396 );
397 END IF;
398 IF l_debug_level > 0 THEN
399 oe_debug_pub.add( 'OTHERS IN GET_TOP_MODEL IN DEFAULTING' , 1 ) ;
400 END IF;
401 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
402
403 END Get_Top_Model_Line;
404
405 -- forward declaration
406 FUNCTION GET_ATO_LINE
407 RETURN NUMBER;
408
409 /* This procedure defaults Active Agreement Revision and
410 calls process order again to default Dependent Attributes based
411 on new Agreement_Id - Bug 2154960 */
412
413 procedure Default_Active_Agr_Revision
414 ( p_x_line_rec IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type,
415 p_old_line_rec IN OE_Order_PUB.Line_Rec_Type :=
416 OE_Order_PUB.G_MISS_LINE_REC
417 )
418 IS
419 L_RETURN_STATUS VARCHAR2(1);
420
421 l_x_line_Tbl OE_Order_PUB.Line_Tbl_Type;
422
423 l_old_line_tbl OE_Order_PUB.Line_Tbl_Type;
424 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
425 l_control_rec OE_GLOBALS.Control_Rec_Type;
426 l_agreement_name varchar2(240);
427 l_agreement_id number;
428
429 --
430 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
431 --
432 Begin
433
434 IF l_debug_level > 0 THEN
435 oe_debug_pub.add( 'INSIDE DEFAULT_ACTIVE_AGR_REVISION' , 3 ) ;
436 oe_debug_pub.add( 'AGREEMENT_ID '||P_X_LINE_REC.AGREEMENT_ID , 3 ) ;
437 END IF;
438
439 SELECT agreement_id
440 INTO l_agreement_id
441 FROM oe_agreements_vl
442 WHERE name = (select name from oe_agreements_vl
443 where
444 agreement_id = p_x_line_rec.agreement_id)
445 AND trunc(nvl(p_x_line_rec.pricing_date,sysdate)) BETWEEN
446 trunc(nvl(START_DATE_ACTIVE,add_months(sysdate,-10000)))
447 AND trunc(nvl(END_DATE_ACTIVE,add_months(sysdate,+10000)));
448
449 IF l_debug_level > 0 THEN
450 oe_debug_pub.add( 'ACTIVE AGREEMENT REVISION :'||L_AGREEMENT_ID , 3 ) ;
451 END IF;
452
453 If p_x_line_rec.agreement_id <> l_agreement_id Then
454 IF l_debug_level > 0 THEN
455 oe_debug_pub.add( 'ACTIVE AGREEMENT REVISION IS FOUND - CALLING PROCESS ORDER TO DEFAULT DEPENDENT ATTRIBUTES' , 3 ) ;
456 END IF;
457
458 l_control_rec.controlled_operation := TRUE;
459 l_control_rec.check_security := TRUE;
460 l_control_rec.clear_dependents := TRUE;
461 l_control_rec.default_attributes := TRUE;
462 l_control_rec.change_attributes := FALSE;
463 l_control_rec.validate_entity := FALSE;
464 l_control_rec.write_to_DB := FALSE;
465 l_control_rec.process := FALSE;
466
467
468 l_old_line_tbl(1) := p_x_line_rec;
469 p_x_line_rec.agreement_id := l_agreement_id;
470 l_line_tbl(1) := p_x_line_rec;
471
472 Oe_Order_Pvt.Lines
473 ( p_validation_level => FND_API.G_VALID_LEVEL_NONE
474 , p_control_rec => l_control_rec
475 , p_x_line_tbl => l_line_tbl
476 , p_x_old_line_tbl => l_old_line_tbl
477 , x_return_status => l_return_status
478 );
479
480 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
481 RAISE FND_API.G_EXC_ERROR;
482 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
483 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
484 END IF;
485
486 p_x_line_rec := l_line_tbl(1);
487
488 End If;
489
490 EXCEPTION
491 WHEN NO_DATA_FOUND THEN
492 IF l_debug_level > 0 THEN
493 oe_debug_pub.add( 'NO ACTIVE REVISION EXISTS FOR THE AGREEMENT ID :'||P_X_LINE_REC.AGREEMENT_ID , 2 ) ;
494 oe_debug_pub.add( 'ERROR WILL BE RAISED IN ENTITY LEVEL VALIDATION' , 3 ) ;
495 END IF;
496
497 WHEN FND_API.G_EXC_ERROR THEN
498 RAISE FND_API.G_EXC_ERROR;
499
500 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
501 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
502
503 WHEN OTHERS THEN
504 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
505 THEN
506 OE_MSG_PUB.Add_Exc_Msg
507 ( G_PKG_NAME ,
508 'Default_Active_Agr_Revision'
509 );
510 END IF;
511
512 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
513
514 End Default_Active_Agr_Revision;
515 /* End of Bug-2154960 */
516
517 -- BEGIN: Blankets Code Merge
518
519 PROCEDURE Clear_And_Re_Default
520 (p_blanket_number IN NUMBER
521 ,p_blanket_line_number IN NUMBER
522 ,p_blanket_version_number IN NUMBER
523 ,p_x_line_rec IN OUT NOCOPY OE_AK_ORDER_LINES_V%ROWTYPE
524 ,p_old_line_rec IN OE_AK_ORDER_LINES_V%ROWTYPE
525 ,p_default_record IN VARCHAR2
526 )
527 IS
528 l_line_rec OE_AK_ORDER_LINES_V%ROWTYPE;
529 --
530 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
531 --
532 BEGIN
533
534 IF l_debug_level > 0 THEN
535 oe_debug_pub.add('ENTER Clear_And_Re_Default') ;
536 oe_debug_pub.add('Old blanket num :'
537 ||p_x_line_rec.blanket_number) ;
538 oe_debug_pub.add('Old blanket line num :'
539 ||p_x_line_rec.blanket_line_number) ;
540 oe_debug_pub.add('Old blanket version num :'
541 ||p_x_line_rec.blanket_version_number) ;
542 oe_debug_pub.add('New blanket num : '||p_blanket_number) ;
543 oe_debug_pub.add('New blanket line num : '||p_blanket_line_number);
544 oe_debug_pub.add('New blanket version num : '||p_blanket_version_number);
545 END IF;
546
547 -- Copy source attribute values from IN parameters
548 -- to the new record
549 IF p_blanket_number IS NOT NULL
550 THEN
551 IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.blanket_number
552 ,p_blanket_number)
553 THEN
554 p_x_line_rec.blanket_number := p_blanket_number;
555 l_line_rec := p_x_line_rec;
556 -- Clear dependents based on blanket number
557 OE_Line_Util_Ext.Clear_Dependent_Attr
558 (p_attr_id => OE_LINE_UTIL.G_BLANKET_NUMBER
559 ,p_x_line_rec => p_x_line_rec
560 ,p_initial_line_rec => l_line_rec
561 ,p_old_line_rec => p_old_line_rec
562 );
563 END IF;
564 END IF;
565
566 IF p_blanket_line_number IS NOT NULL
567 THEN
568 IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.blanket_line_number
569 ,p_blanket_line_number)
570 THEN
571 p_x_line_rec.blanket_line_number := p_blanket_line_number;
572 l_line_rec := p_x_line_rec;
573 -- Clear dependents based on blanket number
574 OE_Line_Util_Ext.Clear_Dependent_Attr
575 (p_attr_id => OE_LINE_UTIL.G_BLANKET_LINE_NUMBER
576 ,p_x_line_rec => p_x_line_rec
577 ,p_initial_line_rec => l_line_rec
578 ,p_old_line_rec => p_old_line_rec
579 );
580 END IF;
581 END IF;
582
583 IF p_blanket_version_number IS NOT NULL
584 THEN
585 IF NOT OE_GLOBALS.EQUAL(p_x_line_rec.blanket_version_number
586 ,p_blanket_version_number)
587 THEN
588 p_x_line_rec.blanket_version_number := p_blanket_version_number;
589 -- No dependent attributes exist for blanket version number
590 END IF;
591 END IF;
592
593 IF l_debug_level > 0 THEN
594 oe_debug_pub.add('Final blanket num :'
595 ||p_x_line_rec.blanket_number) ;
596 oe_debug_pub.add('Final blanket line num :'
597 ||p_x_line_rec.blanket_line_number) ;
598 oe_debug_pub.add('Final blanket version num :'
599 ||p_x_line_rec.blanket_version_number) ;
600 END IF;
601
602 IF p_default_record = 'Y' THEN
603 IF l_debug_level > 0 THEN
604 oe_debug_pub.add('RE-CALLING ONT_LINE_DEF_HDLR.DEFAULT_RECORD') ;
605 END IF;
606 ONT_LINE_Def_Hdlr.Default_Record
607 (p_x_rec => p_x_line_rec
608 ,p_initial_rec => l_line_rec
609 ,p_in_old_rec => p_old_line_rec
610 );
611 END IF;
612
613 IF l_debug_level > 0 THEN
614 oe_debug_pub.add('EXIT Clear_And_Re_Default') ;
615 END IF;
616
617 END Clear_And_Re_Default;
618
619 PROCEDURE Default_Blanket_Values
620 ( p_blanket_number IN NUMBER,
621 p_cust_po_number IN VARCHAR2,
622 p_ordered_item_id IN NUMBER DEFAULT NULL,--bug6826787
623 p_ordered_item IN VARCHAR2,
624 p_inventory_item_id IN NUMBER,
625 p_item_identifier_type IN VARCHAR2,
626 p_request_date IN DATE,
627 p_sold_to_org_id IN NUMBER,
628 x_blanket_number OUT NOCOPY NUMBER,
629 x_blanket_line_number OUT NOCOPY NUMBER,
630 x_blanket_version_number OUT NOCOPY NUMBER,
631 x_blanket_request_date OUT NOCOPY DATE
632 )
633 IS
634 --
635 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
636 l_blanket_number NUMBER;
637 --
638 l_item_validation_org NUMBER :=
639 OE_Sys_Parameters.Value('MASTER_ORGANIZATION_ID');
640 BEGIN
641
642 IF p_request_date IS NOT NULL AND
643 p_request_date <> FND_API.G_MISS_DATE THEN
644 x_blanket_request_date := p_request_date;
645 ELSE
646 x_blanket_request_date := sysdate;
647 END IF;
648
649 IF p_blanket_number = FND_API.G_MISS_NUM THEN
650 l_blanket_number := NULL;
651 ELSE
652 l_blanket_number := p_blanket_number;
653 END IF;
654
655 if l_debug_level > 0 then
656 oe_debug_pub.add('Enter Default_Blanket_Values');
657 oe_debug_pub.add('Request Date :'||x_blanket_request_date);
658 end if;
659
660 --derive bl line # and bl revis #
661 --first sorts by inventory_item_id, then by ordered_item_id (category)
662 --to select most specific of effective blanket lines
663
664 -- added for bug 4246913
665 if l_blanket_number is null AND
666 (p_cust_po_number = FND_API.G_MISS_CHAR OR
667 p_cust_po_number IS NULL) then
668
669 if l_debug_level > 0 then
670 oe_debug_pub.add('No blanket or customer po number on line, returning');
671 end if;
672
673 RETURN;
674 end if;
675
676 --bug6826787 First look for an exact match (inventory_item_id,item_identifier_type,ordered_item_id)
677 --If not found then look for atleast inventory_item_id match,if not found then look for category level match,
678 --if not found look for ALL Items level
679
680 BEGIN --bug6826787 Exact match
681 IF l_blanket_number is null THEN
682
683 SELECT /* MOAC_SQL_CHANGE */ BH.ORDER_NUMBER, BH.VERSION_NUMBER, BL.LINE_NUMBER
684 INTO x_blanket_number,
685 x_blanket_version_number,
686 x_blanket_line_number
687 FROM OE_BLANKET_HEADERS_ALL BH, OE_BLANKET_LINES BL,
688 OE_BLANKET_HEADERS_EXT BHE,OE_BLANKET_LINES_EXT BLE
689 WHERE BH.HEADER_ID = BL.HEADER_ID
690 AND BL.CUST_PO_NUMBER = p_cust_po_number
691 AND BH.SOLD_TO_ORG_ID = p_sold_to_org_id
692 AND BHE.ON_HOLD_FLAG = 'N'
693 AND trunc(x_blanket_request_date)
694 BETWEEN trunc(BLE.START_DATE_ACTIVE)
695 AND trunc(nvl(BLE.END_DATE_ACTIVE, x_blanket_request_date))
696 AND BL.INVENTORY_ITEM_ID = p_inventory_item_id
697 AND BL.item_identifier_type = p_item_identifier_type
698 AND decode(BL.item_identifier_type,'INT',to_char(BL.inventory_item_id),
699 'CUST',to_char(ordered_item_id),
700 NVL(BL.ordered_item,'XXXX') )= decode ( p_item_identifier_type,'INT', to_char(p_inventory_item_id)
701 , 'CUST', to_char(p_ordered_item_id)
702 , NVL(p_ordered_item,'XXXX') )
703 AND BL.ITEM_IDENTIFIER_TYPE NOT IN ('CAT','ALL')
704 AND BH.ORDER_NUMBER = BHE.ORDER_NUMBER
705 AND BL.LINE_ID = BLE.LINE_ID
706 AND BH.SALES_DOCUMENT_TYPE_CODE ='B';
707
708 ELSE
709
710 SELECT /* MOAC_SQL_CHANGE */ BH.ORDER_NUMBER, BH.VERSION_NUMBER, BL.LINE_NUMBER
711 INTO x_blanket_number,
712 x_blanket_version_number,
713 x_blanket_line_number
714 FROM OE_BLANKET_HEADERS_ALL BH, OE_BLANKET_LINES BL,
715 OE_BLANKET_HEADERS_EXT BHE,OE_BLANKET_LINES_EXT BLE
716 WHERE BH.HEADER_ID = BL.HEADER_ID
717 AND BH.ORDER_NUMBER = l_blanket_number
718 -- Do not match customer if blanket number is supplied
719 -- With 11.5.10, customer on blanket could be
720 -- related customer or it could be a null customer
721 -- AND BH.SOLD_TO_ORG_ID = p_sold_to_org_id
722 AND BHE.ON_HOLD_FLAG = 'N'
723 AND trunc(x_blanket_request_date)
724 BETWEEN trunc(BLE.START_DATE_ACTIVE)
725 AND trunc(nvl(BLE.END_DATE_ACTIVE, x_blanket_request_date))
726 AND BL.INVENTORY_ITEM_ID = p_inventory_item_id
727 AND BL.item_identifier_type = p_item_identifier_type
728 AND decode(BL.item_identifier_type,'INT',to_char(BL.inventory_item_id),
729 'CUST',to_char(ordered_item_id),
730 NVL(BL.ordered_item,'XXXX') )= decode ( p_item_identifier_type,'INT', to_char(p_inventory_item_id)
731 , 'CUST', to_char(p_ordered_item_id)
732 , NVL(p_ordered_item,'XXXX') )
733 AND BL.ITEM_IDENTIFIER_TYPE NOT IN ('CAT','ALL')
734 AND BH.ORDER_NUMBER = BHE.ORDER_NUMBER
735 AND BL.LINE_ID = BLE.LINE_ID
736 AND BH.SALES_DOCUMENT_TYPE_CODE ='B';
737
738 END IF;
739
740 Exception
741
742 WHEN TOO_MANY_ROWS THEN
743
744 x_blanket_number := p_blanket_number;
745 x_blanket_version_number := NULL;
746 x_blanket_line_number := NULL;
747
748 IF l_debug_level > 0 THEN
749 oe_debug_pub.add('Multiple blankets exist for customer po number--no defaulting of blanket values');
750 END IF;
751 RETURN;
752
753 WHEN NO_DATA_FOUND THEN
754
755 BEGIN --internal items
756 IF l_blanket_number is null THEN
757
758 SELECT /* MOAC_SQL_CHANGE */ BH.ORDER_NUMBER, BH.VERSION_NUMBER, BL.LINE_NUMBER
759 INTO x_blanket_number,
760 x_blanket_version_number,
761 x_blanket_line_number
762 FROM OE_BLANKET_HEADERS_ALL BH, OE_BLANKET_LINES BL,
763 OE_BLANKET_HEADERS_EXT BHE,OE_BLANKET_LINES_EXT BLE
764 WHERE BH.HEADER_ID = BL.HEADER_ID
765 AND BL.CUST_PO_NUMBER = p_cust_po_number
766 AND BH.SOLD_TO_ORG_ID = p_sold_to_org_id
767 AND BHE.ON_HOLD_FLAG = 'N'
768 AND trunc(x_blanket_request_date)
769 BETWEEN trunc(BLE.START_DATE_ACTIVE)
770 AND trunc(nvl(BLE.END_DATE_ACTIVE, x_blanket_request_date))
771 AND BL.INVENTORY_ITEM_ID = p_inventory_item_id
772 AND BL.ITEM_IDENTIFIER_TYPE ='INT' --bug6826787
773 AND BH.ORDER_NUMBER = BHE.ORDER_NUMBER
774 AND BL.LINE_ID = BLE.LINE_ID
775 AND BH.SALES_DOCUMENT_TYPE_CODE ='B';
776
777 ELSE
778
779 SELECT /* MOAC_SQL_CHANGE */ BH.ORDER_NUMBER, BH.VERSION_NUMBER, BL.LINE_NUMBER
780 INTO x_blanket_number,
781 x_blanket_version_number,
782 x_blanket_line_number
783 FROM OE_BLANKET_HEADERS_ALL BH, OE_BLANKET_LINES BL,
784 OE_BLANKET_HEADERS_EXT BHE,OE_BLANKET_LINES_EXT BLE
785 WHERE BH.HEADER_ID = BL.HEADER_ID
786 AND BH.ORDER_NUMBER = l_blanket_number
787 -- Do not match customer if blanket number is supplied
788 -- With 11.5.10, customer on blanket could be
789 -- related customer or it could be a null customer
790 -- AND BH.SOLD_TO_ORG_ID = p_sold_to_org_id
791 AND BHE.ON_HOLD_FLAG = 'N'
792 AND trunc(x_blanket_request_date)
793 BETWEEN trunc(BLE.START_DATE_ACTIVE)
794 AND trunc(nvl(BLE.END_DATE_ACTIVE, x_blanket_request_date))
795 AND BL.INVENTORY_ITEM_ID = p_inventory_item_id
796 AND BL.ITEM_IDENTIFIER_TYPE ='INT' --bug6826787
797 AND BH.ORDER_NUMBER = BHE.ORDER_NUMBER
798 AND BL.LINE_ID = BLE.LINE_ID
799 AND BH.SALES_DOCUMENT_TYPE_CODE ='B';
800
801 END IF;
802
803 EXCEPTION
804 WHEN TOO_MANY_ROWS THEN
805
806 x_blanket_number := p_blanket_number;
807 x_blanket_version_number := NULL;
808 x_blanket_line_number := NULL;
809
810 IF l_debug_level > 0 THEN
811 oe_debug_pub.add('Multiple blankets exist for customer po number--no defaulting of blanket values');
812 END IF;
813 RETURN;
814
815 WHEN NO_DATA_FOUND THEN
816
817 BEGIN --item categories
818
819 IF l_blanket_number is null THEN
820
821 SELECT /* MOAC_SQL_CHANGE */ BH.ORDER_NUMBER, BH.VERSION_NUMBER, BL.LINE_NUMBER
822 INTO x_blanket_number,
823 x_blanket_version_number,
824 x_blanket_line_number
825 FROM OE_BLANKET_HEADERS_ALL BH, OE_BLANKET_LINES BL, MTL_ITEM_CATEGORIES IC,
826 OE_BLANKET_HEADERS_EXT BHE,OE_BLANKET_LINES_EXT BLE
827 WHERE BH.HEADER_ID = BL.HEADER_ID
828 AND BL.CUST_PO_NUMBER = p_cust_po_number
829 AND BH.SOLD_TO_ORG_ID = p_sold_to_org_id
830 AND BHE.ON_HOLD_FLAG = 'N'
831 AND trunc(x_blanket_request_date)
832 BETWEEN trunc(BLE.START_DATE_ACTIVE)
833 AND trunc(nvl(BLE.END_DATE_ACTIVE, x_blanket_request_date))
834 AND BL.ITEM_IDENTIFIER_TYPE = 'CAT'
835 AND IC.ORGANIZATION_ID = l_item_validation_org
836 AND IC.INVENTORY_ITEM_ID = p_inventory_item_id
837 AND BL.INVENTORY_ITEM_ID = IC.CATEGORY_ID
838 AND BH.ORDER_NUMBER = BHE.ORDER_NUMBER
839 AND BL.LINE_ID = BLE.LINE_ID
840 AND BH.SALES_DOCUMENT_TYPE_CODE ='B';
841
842 ELSE
843
844 SELECT /* MOAC_SQL_CHANGE */ BH.ORDER_NUMBER, BH.VERSION_NUMBER, BL.LINE_NUMBER
845 INTO x_blanket_number,
846 x_blanket_version_number,
847 x_blanket_line_number
848 FROM OE_BLANKET_HEADERS_ALL BH, OE_BLANKET_LINES BL, MTL_ITEM_CATEGORIES IC
849 ,OE_BLANKET_HEADERS_EXT BHE,OE_BLANKET_LINES_EXT BLE
850 WHERE BH.HEADER_ID = BL.HEADER_ID
851 AND BH.ORDER_NUMBER = l_blanket_number
852 -- Do not match customer if blanket number is supplied
853 -- With 11.5.10, customer on blanket could be
854 -- related customer or it could be a null customer
855 -- AND BH.SOLD_TO_ORG_ID = p_sold_to_org_id
856 AND BHE.ON_HOLD_FLAG = 'N'
857 AND trunc(x_blanket_request_date)
858 BETWEEN trunc(BLE.START_DATE_ACTIVE)
859 AND trunc(nvl(BLE.END_DATE_ACTIVE, x_blanket_request_date))
860 AND BL.ITEM_IDENTIFIER_TYPE = 'CAT'
861 AND IC.ORGANIZATION_ID = l_item_validation_org
862 AND IC.INVENTORY_ITEM_ID = p_inventory_item_id
863 AND BL.INVENTORY_ITEM_ID = IC.CATEGORY_ID
864 AND BH.ORDER_NUMBER = BHE.ORDER_NUMBER
865 AND BL.LINE_ID = BLE.LINE_ID
866 AND BH.SALES_DOCUMENT_TYPE_CODE ='B';
867
868 END IF;
869
870 EXCEPTION
871 WHEN TOO_MANY_ROWS THEN
872 x_blanket_number := p_blanket_number;
873 x_blanket_version_number := NULL;
874 x_blanket_line_number := NULL;
875
876 IF l_debug_level > 0 THEN
877 oe_debug_pub.add('Multiple blankets exist for customer po number--no defaulting of blanket values');
878 END IF;
879 RETURN;
880
881 WHEN NO_DATA_FOUND THEN
882
883 BEGIN --all items
884
885 IF l_blanket_number is null THEN
886
887 SELECT /* MOAC_SQL_CHANGE */ BH.ORDER_NUMBER, BH.VERSION_NUMBER, BL.LINE_NUMBER
888 INTO x_blanket_number,
889 x_blanket_version_number,
890 x_blanket_line_number
891 FROM OE_BLANKET_HEADERS BH, OE_BLANKET_LINES_ALL BL,
892 OE_BLANKET_HEADERS_EXT BHE,OE_BLANKET_LINES_EXT BLE
893 WHERE BH.HEADER_ID = BL.HEADER_ID
894 AND BL.CUST_PO_NUMBER = p_cust_po_number
895 AND BH.SOLD_TO_ORG_ID = p_sold_to_org_id
896 AND BHE.ON_HOLD_FLAG = 'N'
897 AND trunc(x_blanket_request_date)
898 BETWEEN trunc(BLE.START_DATE_ACTIVE)
899 AND trunc(nvl(BLE.END_DATE_ACTIVE, x_blanket_request_date))
900 AND BL.ITEM_IDENTIFIER_TYPE = 'ALL'
901 AND BH.ORDER_NUMBER = BHE.ORDER_NUMBER
902 AND BL.LINE_ID = BLE.LINE_ID
903 AND BH.SALES_DOCUMENT_TYPE_CODE ='B';
904
905 ELSE
906
907 SELECT /* MOAC_SQL_CHANGE */ BH.ORDER_NUMBER, BH.VERSION_NUMBER, BL.LINE_NUMBER
908 INTO x_blanket_number,
909 x_blanket_version_number,
910 x_blanket_line_number
911 FROM OE_BLANKET_HEADERS_ALL BH, OE_BLANKET_LINES BL,
912 OE_BLANKET_HEADERS_EXT BHE,OE_BLANKET_LINES_EXT BLE
913 WHERE BH.HEADER_ID = BL.HEADER_ID
914 AND BH.ORDER_NUMBER = l_blanket_number
915 -- Do not match customer if blanket number is supplied
916 -- With 11.5.10, customer on blanket could be
917 -- related customer or it could be a null customer
918 -- AND BH.SOLD_TO_ORG_ID = p_sold_to_org_id
919 AND BHE.ON_HOLD_FLAG = 'N'
920 AND trunc(x_blanket_request_date)
921 BETWEEN trunc(BLE.START_DATE_ACTIVE)
922 AND trunc(nvl(BLE.END_DATE_ACTIVE, x_blanket_request_date))
923 AND BL.ITEM_IDENTIFIER_TYPE = 'ALL'
924 AND BH.ORDER_NUMBER = BHE.ORDER_NUMBER
925 AND BL.LINE_ID = BLE.LINE_ID
926 AND BH.SALES_DOCUMENT_TYPE_CODE ='B';
927
928 END IF;
929
930 EXCEPTION
931 WHEN TOO_MANY_ROWS THEN
932 x_blanket_number := p_blanket_number;
933 x_blanket_version_number := NULL;
934 x_blanket_line_number := NULL;
935
936 IF l_debug_level > 0 THEN
937 oe_debug_pub.add('Multiple blankets exist for customer po number--no defaulting of blanket values');
938 END IF;
939 RETURN;
940 WHEN NO_DATA_FOUND THEN
941 IF l_debug_level > 0 THEN
942 oe_debug_pub.add('No Blanket Number exists for this customer,item :'||p_sold_to_org_id,2);
943 oe_debug_pub.add('Error will be raised in Entity level validation',3);
944 END IF;
945 END; --all items
946 END; --item categories
947 END; --internal, customer, generic items
948 END; --bug6826787 Exact match
949
950 EXCEPTION
951 WHEN OTHERS THEN
952 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
953 THEN
954 OE_MSG_PUB.Add_Exc_Msg
955 ( G_PKG_NAME ,
956 'Default_Blanket_Values'
957 );
958 END IF;
959 IF l_debug_level > 0 THEN
960 oe_debug_pub.add('others in default_blanket_values', 1);
961 END IF;
962 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
963
964 End Default_Blanket_Values;
965
966
967 PROCEDURE Perform_Blanket_Functions
968 (p_x_line_rec IN OUT NOCOPY OE_AK_ORDER_LINES_V%ROWTYPE
969 ,p_old_line_rec IN OE_AK_ORDER_LINES_V%ROWTYPE
970 ,p_default_record IN VARCHAR2 DEFAULT 'N'
971 ,x_blanket_request_date OUT NOCOPY /* file.sql.39 change */ DATE
972 )
973 IS
974 l_blanket_number NUMBER;
975 l_blanket_line_number NUMBER;
976 l_blanket_version_number NUMBER;
977 l_blanket_request_date DATE;
978 --
979 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
980 --
981 BEGIN
982
983 IF (p_x_line_rec.blanket_number IS NOT NULL
984 AND p_x_line_rec.blanket_number <> FND_API.G_MISS_NUM)
985 OR ( p_x_line_rec.cust_po_number IS NOT NULL
986 AND p_x_line_rec.cust_po_number <> FND_API.G_MISS_CHAR
987 -- Bug 2818494
988 -- Default blanket from customer PO only if either
989 -- customer PO or item is updated on order line.
990 AND (NOT OE_GLOBALS.EQUAL(p_x_line_rec.cust_po_number
991 ,p_old_line_rec.cust_po_number)
992 OR NOT OE_GLOBALS.EQUAL(p_x_line_rec.inventory_item_id
993 ,p_old_line_rec.inventory_item_id)
994 )
995 )
996 THEN
997
998 if l_debug_level > 0 then
999 oe_debug_pub.add('ENTER Perform_Blanket_Functions');
1000 oe_debug_pub.add('Blanket Num :'||
1001 p_x_line_rec.blanket_number);
1002 oe_debug_pub.add('Blanket Line Num :'||
1003 p_x_line_rec.blanket_line_number);
1004 oe_debug_pub.add('Cust PO :'||
1005 p_x_line_rec.cust_po_number);
1006 oe_debug_pub.add('Old Blanket Num :'||
1007 p_old_line_rec.blanket_number);
1008 oe_debug_pub.add('Old Blanket Line Num :'||
1009 p_old_line_rec.blanket_line_number);
1010 oe_debug_pub.add('Old Cust PO :'||
1011 p_old_line_rec.cust_po_number);
1012 end if;
1013
1014 -- Bug 2737082 => If blanket line number exists, removed the
1015 -- AND clause for operation and version number check and moved
1016 -- it inside the IF.
1017 -- Otherwise, the ELSE part of this IF statement was being
1018 -- executed for all release lines even if there was a blanket
1019 -- line number which could result in over-riding an existing
1020 -- blanket line number value.
1021 IF p_x_line_rec.blanket_line_number IS NOT NULL
1022 AND p_x_line_rec.blanket_line_number <> FND_API.G_MISS_NUM
1023 THEN
1024
1025 IF (p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE
1026 OR p_x_line_rec.blanket_version_number = FND_API.G_MISS_NUM)
1027 THEN
1028
1029 if l_debug_level > 0 then
1030 oe_debug_pub.add('Default Blanket Version Number');
1031 end if;
1032
1033 -- Derive blanket_version_number if blanket number
1034 -- ,line number are provided
1035
1036 BEGIN
1037
1038 SELECT /* MOAC_SQL_CHANGE */ BH.VERSION_NUMBER
1039 INTO l_blanket_version_number
1040 FROM OE_BLANKET_LINES_ALL BL,OE_BLANKET_LINES_EXT BLE,
1041 OE_BLANKET_HEADERS BH
1042 WHERE BLE.ORDER_NUMBER = p_x_line_rec.blanket_number
1043 AND BLE.LINE_NUMBER = p_x_line_rec.blanket_line_number
1044 AND BL.LINE_ID = BLE.LINE_ID
1045 AND BH.HEADER_ID = BL.HEADER_ID
1046 AND BL.SALES_DOCUMENT_TYPE_CODE = 'B';
1047
1048 p_x_line_rec.blanket_version_number := l_blanket_version_number;
1049
1050 EXCEPTION
1051 WHEN NO_DATA_FOUND THEN
1052 oe_debug_pub.add('Blanket Values combination is not valid: Blanket #:'||p_x_line_rec.blanket_number || ', Blanket Line #:'||p_x_line_rec.blanket_line_number, 2);
1053 FND_MESSAGE.SET_NAME('ONT', 'OE_BLKT_INVALID_BLANKET');
1054 fnd_message.set_token('BLANKET_NUMBER',p_x_line_rec.blanket_number);
1055 fnd_message.set_token('BLANKET_LINE_NUMBER',p_x_line_rec.blanket_line_number);
1056 OE_MSG_PUB.Add;
1057 END;
1058
1059 END IF; -- default version number
1060
1061 -- Bug 2737082 => Only if blanket line number is null or missing,
1062 -- then default if required fields are available.
1063 ELSIF (p_x_line_rec.sold_to_org_id IS NOT NULL
1064 AND p_x_line_rec.sold_to_org_id <> FND_API.G_MISS_NUM
1065 AND p_x_line_rec.inventory_item_id IS NOT NULL
1066 AND p_x_line_rec.inventory_item_id <> FND_API.G_MISS_NUM
1067 AND (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_STANDARD
1068 OR (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT
1069 AND p_x_line_rec.top_model_line_id = p_x_line_rec.line_id)
1070 )
1071 -- Bug 2769562 => If blanket line number is being cleared by user
1072 -- (value for blanket line number existed in old rec), blanket
1073 -- fields should NOT be re-defaulted.
1074 AND (p_old_line_rec.blanket_line_number IS NULL
1075 OR p_old_line_rec.blanket_line_number = FND_API.G_MISS_NUM
1076 )) OR (p_x_line_rec.sold_to_org_id IS NOT NULL
1077 --Bug 3228828
1078 --Defaulting of the Blanket Line Number for Config and Service Items.
1079 AND p_x_line_rec.sold_to_org_id <> FND_API.G_MISS_NUM
1080 AND p_x_line_rec.inventory_item_id IS NOT NULL
1081 AND p_x_line_rec.inventory_item_id <> FND_API.G_MISS_NUM
1082 AND oe_code_control.get_code_release_level >= '110510'
1083 -- Bug 2769562 => If blanket line number is being cleared by user
1084 -- (value for blanket line number existed in old rec), blanket
1085 -- fields should NOT be re-defaulted.
1086 AND (p_old_line_rec.blanket_line_number IS NULL
1087 OR p_old_line_rec.blanket_line_number = FND_API.G_MISS_NUM
1088 ) OR p_x_line_rec.blanket_line_number <> p_old_line_rec.blanket_line_number
1089 OR (p_x_line_rec.blanket_line_number IS NOT NULL --6368131
1090 AND trunc(p_x_line_rec.request_date) <>
1091 trunc(p_old_line_rec.request_date))
1092 )--bug6497015
1093 THEN
1094
1095 if l_debug_level > 0 then
1096 oe_debug_pub.add('Blkt Number : '||p_x_line_rec.blanket_number);
1097 oe_debug_pub.add('Cust PO : '||p_x_line_rec.cust_po_number);
1098 oe_debug_pub.add('Item : '||p_x_line_rec.inventory_item_id);
1099 oe_debug_pub.add('Item Type : '||p_x_line_rec.item_type_code);
1100 end if;
1101
1102 -- Default Blanket Fields
1103 Default_Blanket_Values
1104 ( p_blanket_number => p_x_line_rec.blanket_number,
1105 p_cust_po_number => p_x_line_rec.cust_po_number,
1106 p_ordered_item =>p_x_line_rec.ordered_item,
1107 p_inventory_item_id => p_x_line_rec.inventory_item_id,
1108 p_item_identifier_type => p_x_line_rec.item_identifier_type,
1109 p_request_date => p_x_line_rec.request_date,
1110 p_sold_to_org_id => p_x_line_rec.sold_to_org_id,
1111 x_blanket_number => l_blanket_number,
1112 x_blanket_line_number => l_blanket_line_number,
1113 x_blanket_version_number => l_blanket_version_number,
1114 x_blanket_request_date => x_blanket_request_date
1115 );
1116
1117 IF (l_blanket_number IS NOT NULL
1118 AND NOT OE_GLOBALS.EQUAL(l_blanket_number
1119 ,p_x_line_rec.blanket_number))
1120 OR (l_blanket_line_number IS NOT NULL
1121 AND NOT OE_GLOBALS.EQUAL(l_blanket_line_number
1122 ,p_x_line_rec.blanket_line_number))
1123 THEN
1124 Clear_And_Re_Default
1125 (p_blanket_number => l_blanket_number
1126 ,p_blanket_line_number => l_blanket_line_number
1127 ,p_blanket_version_number => l_blanket_version_number
1128 ,p_x_line_rec => p_x_line_rec
1129 ,p_old_line_rec => p_old_line_rec
1130 ,p_default_record => p_default_record
1131 );
1132 END IF;
1133
1134 END IF;
1135
1136 if l_debug_level > 0 then
1137 oe_debug_pub.add('EXIT Perform_Blanket_Functions');
1138 end if;
1139
1140 END IF; -- if blanket number or cust po exists
1141
1142 EXCEPTION
1143 WHEN FND_API.G_EXC_ERROR THEN
1144 RAISE FND_API.G_EXC_ERROR;
1145 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1146 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1147 WHEN OTHERS THEN
1148 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1149 THEN
1150 OE_MSG_PUB.Add_Exc_Msg
1151 ( G_PKG_NAME ,
1152 'Perform_Blanket_Functions'
1153 );
1154 END IF;
1155 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1156 END Perform_Blanket_Functions;
1157
1158 --- Added for 11510 pack J to get the BSA Line Number and Version Number
1159 --- For given CONFIG and SERVICE items. srini
1160 Procedure Get_Blanket_number_svc_config
1161 ( p_blanket_number IN OUT NOCOPY /* file.sql.39 change */ NUMBER
1162 ,p_inventory_item_id IN NUMBER
1163 ,x_blanket_line_number OUT NOCOPY NUMBER
1164 ,x_blanket_version_number OUT NOCOPY NUMBER
1165 ) is
1166 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1167 BEGIN
1168
1169 IF l_debug_level > 0 THEN
1170 oe_debug_pub.add( 'BSA: ENTERING Get_Blanket_Number API' ) ;
1171 oe_debug_pub.add( 'BSA: Blanket Number in Get_Blanket_Number: '||p_blanket_number ) ;
1172 oe_debug_pub.add( 'BSA: Inventory Item Id in Get_Blanket_Number : '||p_INVENTORY_ITEM_ID ) ;
1173 END IF;
1174
1175 SELECT /* MOAC_SQL_CHANGE */
1176 BL.LINE_NUMBER,
1177 BH.VERSION_NUMBER
1178 INTO
1179 x_blanket_line_number,
1180 x_blanket_version_number
1181
1182 FROM OE_BLANKET_LINES BL,
1183 OE_BLANKET_HEADERS_ALL BH,
1184 OE_BLANKET_HEADERS_EXT BHE,
1185 OE_BLANKET_LINES_EXT BLE
1186 WHERE BH.ORDER_NUMBER = p_blanket_number
1187 AND BL.INVENTORY_ITEM_ID = p_INVENTORY_ITEM_ID
1188 AND BH.HEADER_ID = BL.HEADER_ID
1189 AND BH.ORDER_NUMBER = BHE.ORDER_NUMBER
1190 AND BL.LINE_ID = BLE.LINE_ID
1191 AND BHE.ON_HOLD_FLAG = 'N'
1192 AND trunc(sysdate) BETWEEN trunc(BLE.START_DATE_ACTIVE)
1193 AND trunc(nvl(BLE.END_DATE_ACTIVE, sysdate))
1194 AND BL.ITEM_IDENTIFIER_TYPE NOT IN ('ALL')
1195 AND p_blanket_number is not null
1196 AND BL.SALES_DOCUMENT_TYPE_CODE = 'B';
1197
1198
1199 IF (x_blanket_line_number is null and x_blanket_version_number is null) then
1200
1201 SELECT /* MOAC_SQL_CHANGE */
1202 BL.LINE_NUMBER,
1203 BH.VERSION_NUMBER
1204 INTO
1205 x_blanket_line_number,
1206 x_blanket_version_number
1207
1208 FROM OE_BLANKET_LINES BL,
1209 OE_BLANKET_HEADERS_ALL BH,
1210 OE_BLANKET_HEADERS_EXT BHE,
1211 OE_BLANKET_LINES_EXT BLE
1212 WHERE BH.ORDER_NUMBER = p_blanket_number
1213 AND BH.HEADER_ID = BL.HEADER_ID
1214 AND BH.ORDER_NUMBER = BHE.ORDER_NUMBER
1215 AND BL.LINE_ID = BLE.LINE_ID
1216 AND BHE.ON_HOLD_FLAG = 'N'
1217 AND trunc(sysdate) BETWEEN trunc(BLE.START_DATE_ACTIVE)
1218 AND trunc(nvl(BLE.END_DATE_ACTIVE, sysdate))
1219 AND BL.ITEM_IDENTIFIER_TYPE = 'ALL'
1220 AND p_blanket_number is not null
1221 AND BL.SALES_DOCUMENT_TYPE_CODE = 'B';
1222
1223
1224 END IF;
1225
1226 IF l_debug_level > 0 THEN
1227 oe_debug_pub.add( 'BSA: LEAVING Get_Blanket_Number API' ) ;
1228 oe_debug_pub.add( 'BSA: Blanket line Number in Get_Blanket_Number: '||p_blanket_number ) ;
1229 oe_debug_pub.add( 'BSA: Blanket line Number in Get_Blanket_Number: '||x_blanket_line_number ) ;
1230 oe_debug_pub.add( 'BSA: Blanket Version Number in Get_Blanket_Number : '||x_blanket_version_number
1231 ) ;
1232 END IF;
1233
1234 EXCEPTION
1235
1236 WHEN NO_DATA_FOUND THEN
1237 x_blanket_line_number := null;
1238 x_blanket_version_number := null;
1239 p_blanket_number := null;
1240 IF l_debug_level > 0 THEN
1241 oe_debug_pub.add( 'BSA:LEAVING Get_Blanket_Number API: NO_DATA_FOUND' ) ;
1242 END IF;
1243 WHEN TOO_MANY_ROWS THEN
1244 x_blanket_line_number := null;
1245 x_blanket_version_number := null;
1246 p_blanket_number := null;
1247 IF l_debug_level > 0 THEN
1248 oe_debug_pub.add( 'BSA:LEAVING Get_Blanket_Number API: TOO_MANY_ROWS' ) ;
1249 END IF;
1250 WHEN OTHERS THEN
1251 x_blanket_line_number := null;
1252 x_blanket_version_number := null;
1253 p_blanket_number := null;
1254 IF l_debug_level > 0 THEN
1255 oe_debug_pub.add( 'BSA:LEAVING Get_Blanket_Number API: OTEHRS' ) ;
1256 END IF;
1257
1258 End Get_Blanket_number_svc_config;
1259
1260 -- END: Blankets Code Merge
1261
1262 /*----------------------------------------------------------------
1263 This procedure is used to default certain columns of children of
1264 top level model i.e ATO model, PTO model, SMC-PTO Model. and
1265 ato_line_id for top parent as well as oprion/class/config etc.
1266 shippable_flag??
1267 Before the control comes here, g_line_rec should have following
1268 attributes :
1269
1270 1) line_id,
1271 2) top_model_line_id,
1272 3) item_type_code,
1273 4) ship_model_complete_flag of top parent
1274
1275 ONT's item_type_code of ato under pto or ato under ato is 'CLASS'
1276 even though its bom_item_type is 1.
1277
1278 Change Record:
1279 2150536 : moved the ato/smc/set specific defaulting to
1280 default_child_line.
1281 -----------------------------------------------------------------*/
1282 PROCEDURE Model_Option_Defaulting
1283 IS
1284 l_top_model_line_rec OE_ORDER_PUB.line_rec_type;
1285 l_parent_line_id NUMBER;
1286 l_return_status VARCHAR2(1);
1287 --
1288 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1289 --
1290 l_top_container VARCHAR2(1);
1291 l_part_of_container VARCHAR2(1);
1292 BEGIN
1293
1294 IF l_debug_level > 0 THEN
1295 oe_debug_pub.add( 'ENTERING MODEL_OPTION_DEFAULTING' , 1 ) ;
1296 oe_debug_pub.add( 'LINE_ID TO DEFAULT: '|| G_LINE_REC.LINE_ID , 1 ) ;
1297 END IF;
1298
1299 /* If the top model is in a fulfillment set then we must push all its
1300 children into same fulfillment set. We exclude service item and the
1301 top model itself*/
1302 -- 4118431
1303 IF (g_line_rec.line_id <> g_line_rec.top_model_line_id AND
1304 g_line_rec.item_type_code <> OE_GLOBALS.G_ITEM_SERVICE AND
1305 g_line_rec.top_modeL_line_id IS NOT NULL AND
1306 g_line_rec.line_id > 0 ) THEN
1307
1308 Insert_into_set
1309 (p_line_id => g_line_rec.top_model_line_id,
1310 p_child_line_id => g_line_rec.line_id,
1311 x_return_status => l_return_status);
1312
1313 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1314 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1315 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1316 RAISE FND_API.G_EXC_ERROR;
1317 END IF;
1318 END IF;
1319
1320
1321 /* We do not do any defaulting for service items and kits.
1322 * We also do not default anything special for included items,
1323 * since user dose not enter them.They are created in the
1324 * process_included_items procedure and all the fields to be populated
1325 * from the parent line, are populated there. */
1326
1327 IF g_line_rec.item_type_code = OE_GLOBALS.G_ITEM_SERVICE OR
1328 g_line_rec.item_type_code = OE_GLOBALS.G_ITEM_INCLUDED OR
1329 (g_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT AND
1330 g_line_rec.line_id = g_line_rec.top_modeL_line_id)
1331 THEN
1332 IF l_debug_level > 0 THEN
1333 oe_debug_pub.add( 'RETURNING FOR SERVICE , INCLUDED , TOP LEVEL KITS' , 1 ) ;
1334 END IF;
1335 RETURN;
1336 END IF;
1337
1338
1339 IF g_line_rec.ato_line_id = FND_API.G_MISS_NUM THEN
1340 g_line_rec.ato_line_id := Get_ATO_Line;
1341 IF l_debug_level > 0 THEN
1342 oe_debug_pub.add( 'GET_ATO_LINE SUCCESSFUL' , 1 ) ;
1343 END IF;
1344 END IF;
1345
1346
1347 /* After getting ato_line_id, for top level parents and ato items,
1348 * we don't default any other columns for lines with item_type MODEL
1349 * and STANDARD */
1350
1351 IF g_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
1352 g_line_rec.item_type_code = OE_GLOBALS.G_ITEM_STANDARD
1353 THEN
1354 --{ bug3601544 starts
1355 IF l_debug_level > 0 THEN
1356 OE_DEBUG_PUB.Add('IB Owner: '||g_line_rec.ib_owner,3);
1357 OE_DEBUG_PUB.Add('IB Install: '||g_line_rec.ib_installed_at_location,3);
1358 OE_DEBUG_PUB.Add('IB Current: '||g_line_rec.ib_current_location,3);
1359 END IF;
1360
1361 OE_CONFIG_TSO_PVT.Is_Part_Of_Container_Model
1362 ( p_line_id => g_line_rec.line_id
1363 ,p_top_model_line_id => g_line_rec.top_model_line_id
1364 ,p_ato_line_id => g_line_rec.ato_line_id
1365 ,p_inventory_item_id => g_line_rec.inventory_item_id
1366 ,x_top_container_model => l_top_container
1367 ,x_part_of_container => l_part_of_container );
1368
1369 IF l_top_container = 'Y' THEN
1370 g_line_rec.ib_owner := NULL;
1371 g_line_rec.ib_installed_at_location := NULL;
1372 g_line_rec.ib_current_location := NULL;
1373
1374 IF l_debug_level > 0 THEN
1375 OE_DEBUG_PUB.Add('IB Fields set to NULL for Top Container Line',3);
1376 END IF;
1377 END IF;
1378 -- bug3601544 ends }
1379
1380 IF l_debug_level > 0 THEN
1381 oe_debug_pub.add( 'RETURNING FOR ITEM TYPE MODEL AND STANDARD' , 1 ) ;
1382 END IF;
1383 RETURN;
1384 END IF;
1385
1386
1387
1388 /* If we are here, it means item_type_code is CLASS, OPTION, KIT under
1389 * a model,or CONFIG. Load top parent, so that we know if it is ato,
1390 * smc pto or nonsmc pto */
1391
1392 IF g_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CONFIG THEN
1393 l_parent_line_id := g_line_rec.ato_line_id;
1394 ELSE
1395 l_parent_line_id := g_line_rec.top_model_line_id;
1396 END IF;
1397 --2605065 : commented. This has been added in procedure Attributes.
1398 --OE_Order_Cache.clear_top_model_line(l_parent_line_id);
1399
1400 l_top_model_line_rec := OE_Order_Cache.Load_Top_Model_Line
1401 (l_parent_line_id );
1402
1403
1404 /* We are introducing a new procedure Default_Child_Line in oe_config_util
1405 * to default all appropriate values from top model to its children.
1406 * In future if you need to copy anything from parent to children,
1407 * add code in oe_config_util */
1408
1409 oe_config_util.default_child_line
1410 (p_parent_line_rec => l_top_model_line_rec,
1411 p_x_child_line_rec => g_line_rec,
1412 x_return_status => l_return_status);
1413
1414 IF l_debug_level > 0 THEN
1415 oe_debug_pub.add( 'RETURN STATUS || ' || L_RETURN_STATUS , 3 ) ;
1416 END IF;
1417
1418 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1419 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1420 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1421 RAISE FND_API.G_EXC_ERROR;
1422 END IF;
1423
1424 IF l_debug_level > 0 THEN
1425 oe_debug_pub.add( 'EXITING MODEL_OPTION_DEFAULTING' , 1 ) ;
1426 END IF;
1427
1428 EXCEPTION
1429
1430 WHEN NO_DATA_FOUND THEN
1431 IF l_debug_level > 0 THEN
1432 oe_debug_pub.add( 'NO DATA FOUND IN MODEL_OPTION_DEFAULTING' , 1 ) ;
1433 END IF;
1434 RAISE FND_API.G_EXC_ERROR;
1435
1436 WHEN OTHERS THEN
1437 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1438 THEN
1439 OE_MSG_PUB.Add_Exc_Msg
1440 ( G_PKG_NAME ,
1441 'Model_Option_Defaulting'
1442 );
1443 END IF;
1444 IF l_debug_level > 0 THEN
1445 oe_debug_pub.add( 'OTHERS IN MODEL_OPTION_DEFAULTING' , 1 ) ;
1446 END IF;
1447 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1448
1449 END Model_Option_Defaulting;
1450
1451
1452 /* -------------------------------------------------------------
1453 This procedure will be used to default data from their model
1454 in case of updates
1455 ----------------------------------------------------------------*/
1456
1457 PROCEDURE Model_Option_update
1458 (p_x_line_rec IN OUT NOCOPY OE_ORDER_PUB.line_rec_type)
1459 IS
1460 l_top_model_line_rec OE_ORDER_PUB.line_rec_type;
1461 l_parent_line_id NUMBER;
1462 l_return_status VARCHAR2(1);
1463 --
1464 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1465 --
1466 BEGIN
1467
1468 IF l_debug_level > 0 THEN
1469 oe_debug_pub.add( 'ENTERING MODEL_OPTION_UPDATE' , 1 ) ;
1470 oe_debug_pub.add( 'LINE_ID TO DEFAULT: '|| P_X_LINE_REC.LINE_ID , 1 ) ;
1471 END IF;
1472
1473 /* These updates are valid only for Options/clasees/included items */
1474
1475 IF p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_SERVICE OR
1476 p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
1477 p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_STANDARD OR
1478 (p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT AND
1479 p_x_line_rec.line_id = p_x_line_rec.top_modeL_line_id)
1480 THEN
1481
1482 IF l_debug_level > 0 THEN
1483 oe_debug_pub.add( 'RETURNING FOR ITEM TYPE SERVICE , MODEL , STANDARD AND TOP LEVEL KITS' , 1 ) ;
1484 END IF;
1485
1486 RETURN;
1487 END IF;
1488
1489 IF p_x_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CONFIG THEN
1490 l_parent_line_id := p_x_line_rec.ato_line_id;
1491 ELSE
1492 l_parent_line_id := p_x_line_rec.top_model_line_id;
1493 END IF;
1494
1495 IF l_debug_level > 0 THEN
1496 oe_debug_pub.add( 'TOP MODEL LINE ID FOR TOP MODEL' || L_PARENT_LINE_ID , 1 ) ;
1497 END IF;
1498 -- 2605065 : Commented. This has been done in procedure Attributes.
1499 --OE_Order_Cache.clear_top_model_line(l_parent_line_id);
1500 l_top_model_line_rec := OE_Order_Cache.Load_Top_Model_Line
1501 (l_parent_line_id );
1502
1503 p_x_line_rec.ship_tolerance_above := l_top_model_line_rec.ship_tolerance_above;
1504 p_x_line_rec.ship_tolerance_below := l_top_model_line_rec.ship_tolerance_below;
1505
1506 IF l_debug_level > 0 THEN
1507 oe_debug_pub.add( 'EXITING MODEL_OPTION_UPDATE' , 1 ) ;
1508 END IF;
1509
1510 EXCEPTION
1511
1512 WHEN NO_DATA_FOUND THEN
1513 IF l_debug_level > 0 THEN
1514 oe_debug_pub.add( 'NO DATA FOUND IN MODEL_OPTION_UPDATE' , 1 ) ;
1515 END IF;
1516
1517 RAISE FND_API.G_EXC_ERROR;
1518
1519 WHEN OTHERS THEN
1520
1521 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1522 THEN
1523 OE_MSG_PUB.Add_Exc_Msg
1524 ( G_PKG_NAME ,
1525 'Model_Option_update'
1526 );
1527 END IF;
1528 IF l_debug_level > 0 THEN
1529 oe_debug_pub.add( 'OTHERS IN MODEL_OPTION_UPDATE' , 1 ) ;
1530 END IF;
1531 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1532
1533 END Model_Option_Update;
1534
1535 /*-------------------------------------------------------------
1536 this procedure gets ato_line_id for top level ato model,
1537 ato_item and all children top ato model. It requires
1538 1) item_type_code
1539 2) line_id
1540 3) top_model_line_id
1541
1542 Change Record:
1543 bug 1894331
1544 the select statement for getting ato_line_id in case of
1545 pto+ato case is modified. look at the bug for more details.
1546 also made same change in OEXVCFGB.pls:update_ato_line_attribs.
1547 Bug 2513840
1548 Added Code to handle TOO_MANY_ROWS in Exception
1549 --------------------------------------------------------------*/
1550 FUNCTION Get_ATO_Line
1551 RETURN NUMBER
1552 IS
1553 l_ato_line_id NUMBER;
1554 l_temp_ato_line_id NUMBER;
1555 l_replenish_to_order_flag VARCHAR2(1);
1556 l_build_in_wip_flag VARCHAR2(1);
1557 l_bom_item_type NUMBER;
1558 l_ato_config_item_id NUMBER;
1559 --
1560 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1561 --
1562 BEGIN
1563
1564 IF l_debug_level > 0 THEN
1565 oe_debug_pub.add( 'IN GET_ATO_LINE , ITEM_TYPE_CODE :' || G_LINE_REC.ITEM_TYPE_CODE , 1 ) ;
1566 END IF;
1567
1568 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110508' AND
1569 g_line_rec.item_type_code = 'CONFIG' THEN
1570 IF l_debug_level > 0 THEN
1571 oe_debug_pub.add( 'PACK H MI , CONFIG LINE '|| G_LINE_REC.ATO_LINE_ID ) ;
1572 END IF;
1573 RETURN g_line_rec.ato_line_id;
1574 END IF;
1575
1576 IF ( g_line_rec.inventory_item_id is NULL OR
1577 g_line_rec.inventory_item_id = FND_API.G_MISS_NUM)
1578 THEN
1579 RETURN NULL;
1580 END IF;
1581
1582 IF g_line_rec.line_category_code =
1583 OE_GLOBALS.G_RETURN_CATEGORY_CODE THEN
1584 RETURN NULL;
1585 END IF;
1586
1587 OE_ORDER_CACHE.Load_Item
1588 (p_key1 => g_line_rec.inventory_item_id
1589 ,p_key2 => g_line_rec.ship_from_org_id);
1590
1591 l_replenish_to_order_flag :=
1592 OE_ORDER_CACHE.g_item_rec.replenish_to_order_flag;
1593 l_build_in_wip_flag := OE_ORDER_CACHE.g_item_rec.build_in_wip_flag;
1594 l_bom_item_type := OE_ORDER_CACHE.g_item_rec.bom_item_type;
1595
1596 IF l_debug_level > 0 THEN
1597 oe_debug_pub.add( 'GET_ATO_LINE: '||L_REPLENISH_TO_ORDER_FLAG||L_BUILD_IN_WIP_FLAG , 1 ) ;
1598 END IF;
1599
1600 -- top level ATO model and ato item.
1601 -- build in wip flag, see if req?
1602
1603 IF (g_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL AND
1604 l_replenish_to_order_flag = 'Y') OR
1605 (g_line_rec.item_type_code = OE_GLOBALS.G_ITEM_STANDARD AND
1606 l_replenish_to_order_flag = 'Y' AND
1607 l_build_in_wip_flag = 'Y')
1608 THEN
1609 IF l_debug_level > 0 THEN
1610 oe_debug_pub.add( '1. ATO_LINE_ID: '||G_LINE_REC.LINE_ID , 1 ) ;
1611 END IF;
1612 l_ato_line_id := g_line_rec.line_id;
1613 RETURN (l_ato_line_id);
1614
1615 ELSE
1616 /* we have to set ato_line_id for all options
1617 * classes, config item which are under top ato model
1618 * ato model (ont: item_type_code is CLASS, bom_item_type = 1)
1619 * under top ato model will have ato_line_id = line_id
1620 * of top ato parent. kit can not be under an ATO */
1621
1622 IF g_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
1623 g_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION OR
1624 g_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CONFIG THEN
1625
1626 OE_Order_Cache.Load_Top_Model_Line
1627 (g_line_rec.top_model_line_id );
1628 l_ato_line_id := OE_Order_Cache.g_top_model_line_rec.ato_line_id;
1629
1630 IF l_ato_line_id is NULL THEN
1631
1632 IF l_debug_level > 0 THEN
1633 oe_debug_pub.add( 'TOP MODEL IS PTO' , 3 ) ;
1634 END IF;
1635
1636 IF (g_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS AND
1637 l_replenish_to_order_flag = 'Y' AND
1638 l_bom_item_type = 1) THEN
1639
1640 IF l_debug_level > 0 THEN
1641 oe_debug_pub.add( 'MAYBE ATO LINE '||G_LINE_REC.LINE_ID , 3 ) ;
1642 END IF;
1643 l_temp_ato_line_id := g_line_rec.line_id;
1644 END IF;
1645
1646
1647 BEGIN
1648
1649 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110508' AND
1650 g_line_rec.config_header_id is not NULL AND
1651 g_line_rec.config_header_id <> FND_API.G_MISS_NUM AND
1652 g_line_rec.configuration_id is not NULL AND
1653 g_line_rec.configuration_id <> FND_API.G_MISS_NUM
1654 THEN
1655 IF l_debug_level > 0 THEN
1656 oe_debug_pub.add( 'GET_ATO: PACK H NEW LOGIC MI ' || G_LINE_REC.CONFIG_HEADER_ID , 1 ) ;
1657 oe_debug_pub.add( 'CONFIGN ID ' || G_LINE_REC.CONFIGURATION_ID , 1 ) ;
1658 END IF;
1659
1660 SELECT ato_config_item_id
1661 INTO l_ato_config_item_id
1662 FROM cz_config_details_v
1663 WHERE config_hdr_id = g_line_rec.config_header_id
1664 AND config_rev_nbr = g_line_rec.config_rev_nbr
1665 AND config_item_id = g_line_rec.configuration_id
1666 AND inventory_item_id = g_line_rec.inventory_item_id;
1667 IF l_debug_level > 0 THEN
1668 oe_debug_pub.add( 'GET_ATO: MI ' || L_ATO_CONFIG_ITEM_ID , 1 ) ;
1669 END IF;
1670
1671 IF l_ato_config_item_id is NOT NULL THEN
1672 SELECT line_id
1673 INTO l_ato_line_id
1674 FROM OE_ORDER_LINES_ALL OEOPT
1675 WHERE line_id =
1676 (SELECT line_id
1677 FROM oe_order_lines OEATO
1678 WHERE OEOPT.top_model_line_id = OEATO.top_model_line_id
1679 AND OEATO.configuration_id = l_ato_config_item_id
1680 AND OEATO.open_flag = 'Y')
1681 AND top_model_line_id = g_line_rec.top_model_line_id;
1682
1683 ELSE
1684 IF l_debug_level > 0 THEN
1685 oe_debug_pub.add('CONFIG_ITEM_ID NOT RETURNED FROM CZ');
1686 END IF;
1687 IF g_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION
1688 AND
1689 l_replenish_to_order_flag = 'Y' AND
1690 l_build_in_wip_flag = 'Y'
1691 THEN
1692 IF l_debug_level > 0 THEN
1693 oe_debug_pub.add( 'ATO ITEM UNDER PTO MODEL' , 1 ) ;
1694 END IF;
1695 RETURN g_line_rec.line_id;
1696 END IF;
1697 END IF;
1698
1699 IF l_debug_level > 0 THEN
1700 oe_debug_pub.add( 'PTO+ATO SELECT '||L_ATO_LINE_ID , 1 ) ;
1701 END IF;
1702
1703 ELSE
1704
1705 IF l_debug_level > 0 THEN
1706 oe_debug_pub.add( 'USE OE_ORDER_LINES' , 3 ) ;
1707 END IF;
1708
1709 SELECT line_id
1710 INTO l_ato_line_id
1711 FROM OE_ORDER_LINES_ALL
1712 WHERE top_model_line_id = g_line_rec.top_model_line_id
1713 AND item_type_code = 'CLASS'
1714 AND component_code =
1715 SUBSTR( g_line_rec.component_code, 1,
1716 LENGTH(component_code))
1717 AND ato_line_id is not null
1718 AND open_flag = 'Y'
1719 AND component_code =
1720 ( SELECT MIN(OEMIN.component_code)
1721 FROM OE_ORDER_LINES_ALL OEMIN
1722 WHERE OEMIN.top_model_line_id
1723 = g_line_rec.top_model_line_id
1724 AND OEMIN.component_code =
1725 SUBSTR( g_line_rec.component_code, 1,
1726 LENGTH( OEMIN.component_code))
1727 AND OEMIN.ato_line_id is not null
1728 AND OEMIN.open_flag = 'Y')
1729 AND (SUBSTR(g_line_rec.component_code,
1730 LENGTH(component_code) + 1, 1) = '-' OR
1731 SUBSTR(g_line_rec.component_code,
1732 LENGTH(component_code) + 1, 1) is NULL);
1733
1734
1735 IF l_debug_level > 0 THEN
1736 oe_debug_pub.add( 'PTO+ATO SELECT '||L_ATO_LINE_ID , 1 ) ;
1737 END IF;
1738 END IF;
1739
1740 EXCEPTION
1741 WHEN no_data_found THEN
1742 IF l_debug_level > 0 THEN
1743 oe_debug_pub.add( 'NO DATA FOUND PTO CASE '|| L_TEMP_ATO_LINE_ID , 3 ) ;
1744 END IF;
1745
1746 -- ## 1820608 ato item under a top pto model
1747 -- should have line_id = ato_line_id, if ato_item is
1748 -- under a ato sub config, its ato_line_id = line_id
1749 -- of the ato sub config.
1750
1751 IF g_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION
1752 AND
1753 l_replenish_to_order_flag = 'Y' AND
1754 l_build_in_wip_flag = 'Y'
1755 THEN
1756 IF l_debug_level > 0 THEN
1757 oe_debug_pub.add( 'ATO ITEM UNDER PTO MODEL' , 1 ) ;
1758 END IF;
1759 RETURN g_line_rec.line_id;
1760 ELSE
1761 RETURN l_temp_ato_line_id;
1762 END IF;
1763
1764 WHEN too_many_rows THEN
1765 -- Added for Bug-2367800
1766 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_DUPLICATE_COMPONENT');
1767 FND_MESSAGE.Set_Token('ITEM', nvl(g_line_rec.ordered_item,g_line_rec.inventory_item_id));
1768 OE_Msg_Pub.Add;
1769 IF l_debug_level > 0 THEN
1770 oe_debug_pub.add( 'TOO MANY ROWS CASE '|| G_LINE_REC.INVENTORY_ITEM_ID , 1 ) ;
1771 END IF;
1772 RAISE;
1773
1774 WHEN OTHERS THEN
1775 IF l_debug_level > 0 THEN
1776 oe_debug_pub.add( 'ATO LINE EXCEPTION ' , 3 ) ;
1777 END IF;
1778 RAISE;
1779 END;
1780 END IF;
1781
1782 IF l_debug_level > 0 THEN
1783 oe_debug_pub.add( '2. ATO LINE ID : '|| L_ATO_LINE_ID , 3 ) ;
1784 END IF;
1785
1786 RETURN l_ato_line_id;
1787
1788 ELSE
1789 IF l_debug_level > 0 THEN
1790 oe_debug_pub.add( 'RETURN ATO_LINE_ID AS NULL' , 1 ) ;
1791 END IF;
1792 RETURN null;
1793 END IF;
1794 END IF;
1795
1796 IF l_debug_level > 0 THEN
1797 oe_debug_pub.add( 'GG:LINE_ID : ' || G_LINE_REC.LINE_ID , 1 ) ;
1798 oe_debug_pub.add( 'GG:ATO LINE ID : ' || G_LINE_REC.ATO_LINE_ID , 1 ) ;
1799 END IF;
1800
1801 EXCEPTION
1802
1803 WHEN TOO_MANY_ROWS THEN
1804 RAISE FND_API.G_EXC_ERROR;
1805
1806 WHEN OTHERS THEN
1807
1808 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1809 THEN
1810 OE_MSG_PUB.Add_Exc_Msg
1811 ( G_PKG_NAME ,
1812 'Get_ATO_Line'
1813 );
1814 END IF;
1815
1816 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1817
1818
1819 END Get_ATO_line;
1820
1821 /*---------------------------------------------------------------------
1822 PROCEDURE Insert_into_set
1823 This procedure will insert children of model into fulfillment
1824 set id if the parent is part of a set.
1825 Parent might exists in multiple fulfillment sets,
1826 so get all the set_id's that
1827 parent belong to and insert the children in all sets.
1828 ---------------------------------------------------------------------*/
1829 PROCEDURE Insert_Into_set
1830 ( p_line_id IN NUMBER
1831 ,p_child_line_id IN NUMBER
1832 ,x_return_status OUT NOCOPY VARCHAR2)
1833
1834 IS
1835
1836 CURSOR parent_sets IS
1837 Select set_id
1838 From oe_line_sets
1839 Where line_id = p_line_id;
1840 --
1841 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1842 --
1843 BEGIN
1844
1845 IF l_debug_level > 0 THEN
1846 oe_debug_pub.add( 'ENTERING INTO INSERT_INTO_SET' , 1 ) ;
1847 oe_debug_pub.add( 'TOP MODEL IS ' || P_LINE_ID , 1 ) ;
1848 oe_debug_pub.add( 'CHILD LINE IS ' || P_CHILD_LINE_ID , 1 ) ;
1849 END IF;
1850 FOR i IN parent_sets LOOP
1851 IF l_debug_level > 0 THEN
1852 oe_debug_pub.add( 'ENTERING INTO LOOP -SET' ||I.SET_ID , 1 ) ;
1853 END IF;
1854
1855
1856
1857 OE_SET_UTIL.Create_Fulfillment_set
1858 (p_line_id => p_child_line_id,
1859 p_set_id => i.set_id);
1860
1861
1862
1863 END LOOP;
1864
1865 x_return_status := FND_API.G_RET_STS_SUCCESS;
1866 IF l_debug_level > 0 THEN
1867 oe_debug_pub.add( 'EXITING FROM INSERT_INTO_SET' , 1 ) ;
1868 END IF;
1869
1870 EXCEPTION
1871
1872 WHEN OTHERS THEN
1873 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1874
1875 END Insert_Into_set;
1876
1877
1878 FUNCTION Get_Fulfilled_Quantity
1879 RETURN NUMBER
1880 IS
1881 --
1882 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1883 --
1884 BEGIN
1885
1886 RETURN NULL;
1887
1888 END Get_Fulfilled_Quantity;
1889
1890 --Procedure to check change in item_type_code
1891 PROCEDURE Check_Item_Type(p_line_rec OE_ORDER_PUB.Line_Rec_Type,
1892 p_old_line_rec OE_ORDER_PUB.Line_Rec_Type,
1893 p_item_type_code VARCHAR2)
1894 IS
1895 --
1896 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1897 --
1898 BEGIN
1899 IF l_debug_level > 0 THEN
1900 oe_debug_pub.add( 'ENTERING CHECK ITEM TYPE' ) ;
1901 oe_debug_pub.add( 'ITEM TYPE '|| P_ITEM_TYPE_CODE ) ;
1902 END IF;
1903 IF p_line_rec.operation = oe_globals.g_opr_update THEN
1904 IF (p_old_line_rec.item_type_code <> FND_API.G_MISS_CHAR AND
1905 p_old_line_rec.item_type_code IS NOT NULL) THEN
1906
1907 IF NOT OE_GLOBALS.EQUAL(p_old_line_rec.item_type_code,
1908 p_item_type_code) THEN
1909
1910 FND_MESSAGE.SET_NAME('ONT','OE_ITEM_TYPE_CONST');
1911 OE_MSG_PUB.ADD;
1912 IF l_debug_level > 0 THEN
1913 oe_debug_pub.add( 'ITEM_TYPE_CODE CONSTRAINED' ) ;
1914 END IF;
1915 RAISE FND_API.G_EXC_ERROR;
1916
1917 END IF;
1918 END IF;
1919 END IF;
1920
1921 IF l_debug_level > 0 THEN
1922 oe_debug_pub.add( 'ITEM_TYPE_CODE : OPERATION IS CREATE ' ) ;
1923 END IF;
1924
1925 END Check_Item_Type;
1926
1927 FUNCTION Get_Item_Type(p_line_rec OE_ORDER_PUB.Line_Rec_Type,
1928 p_old_line_rec OE_ORDER_PUB.Line_Rec_Type)
1929 RETURN VARCHAR2
1930 IS
1931 l_item_type_code VARCHAR2(30) := NULL;
1932 l_bom_item_type VARCHAR2(30);
1933 l_service_item_flag VARCHAR2(1);
1934 l_pick_components_flag VARCHAR2(1);
1935 --
1936 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1937 --
1938 BEGIN
1939
1940 IF l_debug_level > 0 THEN
1941 oe_debug_pub.add( 'IN DEFAULTING: FUNCTION GET_ITEM_TYPE' , 1 ) ;
1942 oe_debug_pub.add( 'THE INV ITEM IS'||TO_CHAR ( G_LINE_REC.INVENTORY_ITEM_ID ) , 1 ) ;
1943 --6933507
1944 oe_debug_pub.add( ' line_category_code = '|| p_line_rec.line_category_code , 1 ) ;
1945 oe_debug_pub.add( ' retrobill_request_id = '|| p_line_rec.retrobill_request_id , 1 ) ;
1946 oe_debug_pub.add( ' item_type_code = '|| p_line_rec.item_type_code , 1 ) ;
1947 --6933507
1948 END IF;
1949
1950 IF ( g_line_rec.inventory_item_id is NULL OR
1951 g_line_rec.inventory_item_id = FND_API.G_MISS_NUM )
1952 THEN
1953 -- Bug 4721305 condition added to ignore when inventory item is nulled
1954 IF p_line_rec.ITEM_TYPE_CODE IS NOT NULL AND
1955 p_line_rec.ITEM_TYPE_CODE <> FND_API.G_MISS_CHAR THEN
1956 Check_Item_Type(p_line_rec,
1957 p_old_line_rec,
1958 NULL);
1959 END IF;
1960 RETURN NULL;
1961 END IF;
1962
1963
1964 IF p_line_rec.line_category_code = OE_GLOBALS.G_RETURN_CATEGORY_CODE THEN
1965 RETURN OE_GLOBALS.G_ITEM_STANDARD;
1966 --- BUG#6933507 : retrun STANDARD in case of retrobill SO (type = ORDER)
1967 ELSIF p_line_rec.line_category_code = 'ORDER'
1968 and p_line_rec.retrobill_request_id is NOT NULL
1969 and p_line_rec.retrobill_request_id <> FND_API.G_MISS_NUM THEN
1970
1971 RETURN OE_GLOBALS.G_ITEM_STANDARD;
1972 --- BUG#6933507
1973 ELSIF p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CONFIG OR
1974 p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_INCLUDED THEN
1975 RETURN p_line_rec.item_type_code;
1976 END IF;
1977
1978
1979 OE_Order_Cache.Load_Item (g_line_rec.inventory_item_id
1980 ,g_line_rec.ship_from_org_id);
1981 l_bom_item_type := OE_ORDER_CACHE.g_item_rec.bom_item_type;
1982 l_service_item_flag := OE_ORDER_CACHE.g_item_rec.service_item_flag;
1983 l_pick_components_flag := OE_ORDER_CACHE.g_item_rec.pick_components_flag;
1984
1985 IF l_debug_level > 0 THEN
1986 oe_debug_pub.add( 'BOM ITEM TYPE IS ' || L_BOM_ITEM_TYPE ) ;
1987 END IF;
1988
1989 IF l_bom_item_type = 1
1990 -- MODEL items and ato's under pto have bom_item_type = 1
1991 THEN
1992
1993 IF nvl(g_line_rec.top_model_line_id, 0) <> nvl(g_line_rec.line_id, 0)
1994 -- OR
1995 -- nvl(g_line_rec.top_model_line_index, 0) <> nvl(g_line_rec.line_index,0)
1996 -- line_rec dose not have line_index
1997 THEN
1998 IF l_debug_level > 0 THEN
1999 oe_debug_pub.add( 'RETURNING CLASS AS THE ITEM TYPE FOR ATO SUBCONFIG' , 1 ) ;
2000 END IF;
2001 --Procedure to check change in item_type_code
2002 Check_Item_Type(p_line_rec,
2003 p_old_line_rec,
2004 OE_GLOBALS.G_ITEM_CLASS);
2005 RETURN OE_GLOBALS.G_ITEM_CLASS;
2006 END IF;
2007
2008 IF l_debug_level > 0 THEN
2009 oe_debug_pub.add( 'RETURNING MODEL AS THE ITEM TYPE' , 1 ) ;
2010 END IF;
2011 --Procedure to check change in item_type_code
2012 Check_Item_Type(p_line_rec,
2013 p_old_line_rec,
2014 OE_GLOBALS.G_ITEM_MODEL);
2015 RETURN OE_GLOBALS.G_ITEM_MODEL;
2016
2017 ELSIF l_bom_item_type = 2
2018 THEN
2019 IF l_debug_level > 0 THEN
2020 oe_debug_pub.add( 'RETURNING CLASS AS THE ITEM TYPE' , 1 ) ;
2021 END IF;
2022 -- Only CLASS items have bom_item_type = 2
2023 --Procedure to check change in item_type_code
2024 Check_Item_Type(p_line_rec,
2025 p_old_line_rec,
2026 OE_GLOBALS.G_ITEM_CLASS);
2027 RETURN OE_GLOBALS.G_ITEM_CLASS;
2028
2029 ELSIF l_bom_item_type = 4 and
2030 l_service_item_flag = 'N'
2031 THEN
2032
2033 IF l_debug_level > 0 THEN
2034 oe_debug_pub.add( 'BOM 4 AND FLAG = N' ) ;
2035 END IF;
2036 -- Following 3 items can have bom_item_type = 4 :
2037 -- STANDARD item, OPTION item and a KIT
2038 -- We will distinguish an item to be a kit by seeing if
2039 -- it has a record in bom_bill_of_materials.
2040 -- All options MUST have the top_model_line_id populated
2041 -- before they come to defaulting. Thus we use it to distinguish
2042 -- between a standard and an option item.
2043 -- ato_item's item_type_code will be standard
2044
2045 IF l_pick_components_flag = 'Y' THEN
2046 l_item_type_code := OE_GLOBALS.G_ITEM_KIT;
2047 ELSIF (g_line_rec.top_model_line_id is not null AND
2048 g_line_rec.top_model_line_id <> FND_API.G_MISS_NUM)
2049 THEN
2050 IF l_debug_level > 0 THEN
2051 oe_debug_pub.add( 'GET_ITEM_TYPE NO DATA FOUND , BOM_ITEM_TYPE : 4' , 1 ) ;
2052 END IF;
2053 l_item_type_code := OE_GLOBALS.G_ITEM_OPTION;
2054 ELSE
2055 l_item_type_code := OE_GLOBALS.G_ITEM_STANDARD;
2056 END IF;
2057
2058 IF l_debug_level > 0 THEN
2059 oe_debug_pub.add( ' BEFORE CALLING CHECK 1' ) ;
2060 END IF;
2061 --Procedure to check change in item_type_code
2062 Check_Item_Type(p_line_rec,
2063 p_old_line_rec,
2064 l_item_type_code);
2065 RETURN l_item_type_code;
2066
2067 ELSIF l_service_item_flag = 'Y' and
2068 l_bom_item_type = 4
2069 THEN
2070 IF l_debug_level > 0 THEN
2071 oe_debug_pub.add( 'SERVICE ITEM FLAG IS: ' || L_SERVICE_ITEM_FLAG ) ;
2072 END IF;
2073 --Procedure to check change in item_type_code
2074 Check_Item_Type(p_line_rec,
2075 p_old_line_rec,
2076 OE_GLOBALS.G_ITEM_SERVICE);
2077 RETURN OE_GLOBALS.G_ITEM_SERVICE;
2078
2079 END IF;
2080
2081 RETURN null;
2082
2083 IF l_debug_level > 0 THEN
2084 oe_debug_pub.add( 'EXITING DEFAULTING: FUNCTION GET_ITEM_TYPE' ) ;
2085 END IF;
2086
2087 EXCEPTION
2088
2089 WHEN NO_DATA_FOUND THEN
2090 IF l_debug_level > 0 THEN
2091 oe_debug_pub.add( ' BEFORE CALLING CHECK 4' ) ;
2092 END IF;
2093 l_item_type_code := OE_GLOBALS.G_ITEM_STANDARD;
2094 --Procedure to check change in item_type_code
2095 Check_Item_Type(p_line_rec,
2096 p_old_line_rec,
2097 l_item_type_code);
2098 RETURN l_item_type_code;
2099
2100 WHEN OTHERS THEN
2101
2102 -- 4594675
2103 /*
2104 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2105 THEN
2106 OE_MSG_PUB.Add_Exc_Msg
2107 ( G_PKG_NAME ,
2108 'Get_Item_Type'
2109 );
2110 END IF;
2111 */
2112
2113 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2114
2115 END Get_Item_Type;
2116
2117
2118 FUNCTION Get_Line
2119 RETURN NUMBER
2120 IS
2121 l_line_id NUMBER := NULL;
2122 --
2123 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2124 --
2125 BEGIN
2126
2127 SELECT OE_ORDER_LINES_S.NEXTVAL
2128 INTO l_line_id
2129 FROM DUAL;
2130
2131 RETURN l_line_id;
2132
2133 END Get_Line;
2134
2135 FUNCTION Get_Orig_Sys_Doc_Ref
2136 RETURN VARCHAR2
2137 IS
2138 --
2139 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2140 --
2141 BEGIN
2142
2143 OE_ORDER_CACHE.Load_Order_Header(g_line_rec.header_id);
2144 RETURN (OE_ORDER_CACHE.g_header_rec.Orig_Sys_Document_Ref);
2145
2146 END Get_Orig_Sys_Doc_Ref;
2147
2148
2149 FUNCTION Get_Org
2150 RETURN NUMBER
2151 IS
2152 l_Org_id NUMBER := NULL;
2153 --
2154 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2155 --
2156 BEGIN
2157
2158 OE_GLOBALS.Set_Context;
2159 l_org_id := OE_GLOBALS.G_ORG_ID;
2160
2161 RETURN l_Org_Id;
2162
2163 END Get_Org;
2164
2165 FUNCTION Get_Line_Category(p_line_rec OE_ORDER_PUB.Line_Rec_Type,
2166 p_old_line_rec OE_ORDER_PUB.Line_Rec_Type)
2167 RETURN VARCHAR2
2168 IS
2169 l_order_category varchar2(30);
2170 l_category varchar2(30) := NULL;
2171 --
2172 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2173 --
2174 BEGIN
2175 IF l_debug_level > 0 THEN
2176 oe_debug_pub.add( 'IN DEFAULTING: FUNCTION GET_LINE_CATEGORY' , 1 ) ;
2177 END IF;
2178
2179 /* replaced with the following IF for 2421909
2180 IF (p_line_rec.operation = oe_globals.g_opr_create) and
2181 (p_line_rec.line_type_id IS NULL OR
2182 p_line_rec.line_type_id = FND_API.G_MISS_NUM) THEN
2183 */
2184
2185 IF (p_line_rec.line_type_id IS NULL OR -- 2421909
2186 p_line_rec.line_type_id = FND_API.G_MISS_NUM) THEN
2187
2188 IF l_debug_level > 0 THEN
2189 oe_debug_pub.add( 'AK IN DEFAULTING: WHEN LINE_TYPE_ID IS NULL' , 1 ) ;
2190 oe_debug_pub.add( 'AK IN DEFAULTING:' || P_LINE_REC.HEADER_ID , 1 ) ;
2191 END IF;
2192
2193 /* Replaced with the following IF statement for 2421909
2194 OE_ORDER_CACHE.Load_Order_Header(p_line_rec.header_id);
2195 l_order_category := OE_ORDER_CACHE.g_header_rec.ORDER_CATEGORY_CODE;
2196 */
2197
2198 IF (p_line_rec.operation = oe_globals.g_opr_create)
2199 THEN -- 2421909ND
2200
2201 IF l_debug_level > 0 THEN
2202 oe_debug_pub.add( 'AK IN DEFAULTING: OPERATION IS CREATE' , 1 ) ;
2203 END IF;
2204 OE_ORDER_CACHE.Load_Order_Header(p_line_rec.header_id);
2205 l_order_category := OE_ORDER_CACHE.g_header_rec.ORDER_CATEGORY_CODE;
2206 ELSE
2207 l_order_category := p_old_line_rec.line_category_code;
2208 END IF;
2209
2210 ELSE
2211
2212 IF l_debug_level > 0 THEN
2213 oe_debug_pub.add( 'AK IN DEFAULTING: WHEN LINE_TYPE_ID IS NOT NULL' , 1 ) ;
2214 END IF;
2215 OE_ORDER_CACHE.Load_Line_Type(p_line_rec.line_type_id);
2216 l_order_category := OE_ORDER_CACHE.g_line_type_rec.ORDER_CATEGORY_CODE;
2217
2218 END IF;
2219
2220 IF l_order_category = 'RETURN' THEN
2221 l_category := 'RETURN';
2222 ELSE
2223 l_category := 'ORDER';
2224 END IF;
2225 --retro{In the case of price increase for original line, the initial
2226 --retrobill line will be created with line_category return and has to be
2227 --updated to order
2228 IF (p_line_rec.operation = oe_globals.g_opr_update AND
2229 p_old_line_rec.line_category_code = 'RETURN' AND
2230 p_line_rec.line_category_code = 'ORDER' AND
2231 p_line_rec.order_source_id = 27 ) THEN
2232 l_category := 'ORDER';
2233 IF l_debug_level > 0 THEN
2234 oe_debug_pub.add( 'Retrobill price increase Line Category ' || L_CATEGORY ) ;
2235 END IF;
2236 END IF;
2237 --retro}
2238 IF l_debug_level > 0 THEN
2239 oe_debug_pub.add( 'LINE CATEGORY: ' || L_CATEGORY ) ;
2240 END IF;
2241
2242 IF p_line_rec.operation = oe_globals.g_opr_update THEN
2243
2244 IF (p_old_line_rec.line_category_code <> FND_API.G_MISS_CHAR AND
2245 p_old_line_rec.line_category_code IS NOT NULL) THEN
2246
2247 IF NOT OE_GLOBALS.EQUAL(p_old_line_rec.line_category_code,
2248 l_category) THEN
2249 --retro{In the case of price increase for original line, the initial
2250 --retrobill line will be created with line_category return and has to be
2251 --updated to order.The original flow doesn't allow and raises exception,To
2252 --prevent the exception a if loop is added in the case of retrobilling
2253 IF (p_line_rec.operation = oe_globals.g_opr_update AND
2254 p_old_line_rec.line_category_code = 'RETURN' AND
2255 p_line_rec.line_category_code = 'ORDER' AND
2256 p_line_rec.order_source_id = 27 AND
2257 p_line_rec.retrobill_request_id is not null) THEN
2258 null;
2259 else
2260 FND_MESSAGE.SET_NAME('ONT', 'OE_LINE_CAT_CONST');
2261 OE_MSG_PUB.ADD;
2262 IF l_debug_level > 0 THEN
2263 oe_debug_pub.add( 'LINE CATEGORY CONSTRINED' ) ;
2264 END IF;
2265 RAISE FND_API.G_EXC_ERROR;
2266 END IF;
2267 END IF;
2268
2269 END IF;
2270
2271 END IF;
2272
2273
2274 IF l_debug_level > 0 THEN
2275 oe_debug_pub.add( 'IN DEFAULTING: RETURNLINECATEROY' , 1 ) ;
2276 END IF;
2277 RETURN l_category;
2278
2279 EXCEPTION
2280
2281 WHEN NO_DATA_FOUND THEN
2282 IF l_debug_level > 0 THEN
2283 oe_debug_pub.add( 'IN DEFAULTING: NO DATAFOUND' , 1 ) ;
2284 END IF;
2285 l_category := 'ORDER';
2286 IF p_line_rec.operation = oe_globals.g_opr_update THEN
2287
2288 IF (p_old_line_rec.line_category_code <> FND_API.G_MISS_CHAR AND
2289 p_old_line_rec.line_category_code IS NOT NULL) THEN
2290
2291 IF NOT OE_GLOBALS.EQUAL(p_old_line_rec.line_category_code,
2292 l_category) THEN
2293 FND_MESSAGE.SET_NAME('ONT', 'OE_LINE_CAT_CONST');
2294 OE_MSG_PUB.ADD;
2295 IF l_debug_level > 0 THEN
2296 oe_debug_pub.add( 'LINE CATEGORY CONSTRINED' ) ;
2297 END IF;
2298 RAISE FND_API.G_EXC_ERROR;
2299 END IF;
2300
2301 END IF;
2302 END IF;
2303 RETURN l_category;
2304
2305 WHEN OTHERS THEN
2306
2307 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2308 THEN
2309 OE_MSG_PUB.Add_Exc_Msg
2310 ( G_PKG_NAME ,
2311 'Line_Category'
2312 );
2313 END IF;
2314
2315 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2316
2317
2318 END Get_Line_Category;
2319
2320
2321
2322 FUNCTION Get_Line_Number
2323 RETURN NUMBER
2324 IS
2325 l_line_number NUMBER := NULL;
2326 --
2327 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2328 --
2329 BEGIN
2330
2331 IF l_debug_level > 0 THEN
2332 oe_debug_pub.add( 'IN PKG OE_DEFAULT_LINE: FUNCTION GET_LINE_NUMBER' ) ;
2333 END IF;
2334
2335 IF g_line_rec.top_model_line_id IS NULL
2336 OR g_line_rec.top_model_line_id = FND_API.G_MISS_NUM
2337 OR g_line_rec.line_id = g_line_rec.top_model_line_id
2338 THEN
2339
2340 SELECT NVL(MAX(LINE_NUMBER)+1,1)
2341 INTO l_line_number
2342 FROM OE_ORDER_LINES_ALL
2343 WHERE HEADER_ID = g_line_rec.header_id;
2344
2345 RETURN (l_line_number);
2346
2347 ELSE
2348
2349 IF l_debug_level > 0 THEN
2350 oe_debug_pub.add( 'LOADING TOP_MODEL_LINE_ID: ' || G_LINE_REC.TOP_MODEL_LINE_ID ) ;
2351 END IF;
2352 OE_Order_Cache.Load_top_model_line
2353 (g_line_rec.top_model_line_id );
2354 l_line_number := OE_Order_Cache.g_top_model_line_rec.line_number;
2355
2356 RETURN (l_line_number);
2357
2358 IF l_debug_level > 0 THEN
2359 oe_debug_pub.add( 'LOADDED TOP_MODEL_LINE_ID ' ) ;
2360 END IF;
2361
2362 END IF;
2363
2364 EXCEPTION
2365
2366 WHEN OTHERS THEN
2367
2368 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2369 THEN
2370 OE_MSG_PUB.Add_Exc_Msg
2371 ( G_PKG_NAME ,
2372 'Get_Line_Number'
2373 );
2374 END IF;
2375
2376 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2377
2378 END Get_Line_Number;
2379
2380 FUNCTION Get_Latest_Acceptable_Date(p_request_date IN DATE)
2381 RETURN DATE
2382 IS
2383 l_latest_acceptable_date DATE;
2384 --
2385 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2386 --
2387 BEGIN
2388
2389 OE_ORDER_CACHE.Load_Order_Header(g_line_rec.header_id);
2390
2391 l_latest_acceptable_date := p_request_date +
2392 OE_ORDER_CACHE.g_header_rec.latest_schedule_limit;
2393
2394 RETURN l_latest_acceptable_date;
2395
2396 EXCEPTION
2397 WHEN OTHERS THEN
2398 l_latest_acceptable_date := null;
2399 RETURN l_latest_acceptable_date;
2400 END Get_Latest_Acceptable_Date;
2401
2402 FUNCTION Get_Pricing_Quantity
2403 RETURN NUMBER
2404 IS
2405 --
2406 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2407 --
2408 BEGIN
2409
2410 IF g_line_rec.ordered_quantity = FND_API.G_MISS_NUM then
2411 RETURN NULL;
2412 ELSE
2413 IF g_line_rec.pricing_quantity_uom is not null
2414 AND g_line_rec.pricing_quantity_uom <> FND_API.G_MISS_CHAR
2415 THEN
2416 RETURN (OE_Order_Misc_Util.convert_uom(g_line_rec.inventory_item_id,
2417 g_line_rec.order_quantity_uom,
2418 g_line_rec.pricing_quantity_uom,
2419 g_line_rec.ordered_quantity));
2420 ELSE
2421 RETURN NULL;
2422 END IF;
2423 END IF;
2424
2425 EXCEPTION
2426
2427 WHEN OTHERS THEN
2428
2429 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2430 THEN
2431 OE_MSG_PUB.Add_Exc_Msg
2432 ( G_PKG_NAME ,
2433 'Get_Pricing_Quantity'
2434 );
2435 END IF;
2436
2437 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2438
2439 END Get_Pricing_Quantity;
2440
2441 FUNCTION Get_Shipment_Number
2442 RETURN NUMBER
2443 IS
2444 l_ship_number NUMBER := NULL;
2445 --
2446 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2447 --
2448 BEGIN
2449
2450 IF l_debug_level > 0 THEN
2451 oe_debug_pub.add( 'IN PKG OE_DEFAULT_LINE: FUNCTION GET_SHIPMENT_NUMBER' ) ;
2452 END IF;
2453
2454 IF g_line_rec.top_model_line_id IS NULL
2455 OR g_line_rec.top_model_line_id = FND_API.G_MISS_NUM
2456 OR g_line_rec.line_id = g_line_rec.top_model_line_id
2457 THEN
2458
2459 -- Bug 1929163: shipment number is 1 for non-split lines
2460 IF g_line_rec.split_from_line_id IS NULL
2461 OR g_line_rec.split_from_line_id = FND_API.G_MISS_NUM THEN
2462
2463 l_ship_number := 1;
2464
2465 ELSE
2466
2467 SELECT NVL(MAX(SHIPMENT_NUMBER)+1,1)
2468 INTO l_ship_number
2469 FROM OE_ORDER_LINES
2470 WHERE HEADER_ID = g_line_rec.header_id
2471 AND LINE_NUMBER = g_line_rec.line_number;
2472
2473 END IF;
2474
2475 RETURN l_ship_number;
2476
2477 ELSE
2478
2479 OE_Order_Cache.Load_Top_Model_Line(g_line_rec.top_model_line_id );
2480 l_ship_number := OE_ORDER_CACHE.g_top_model_line_rec.shipment_number;
2481 RETURN l_ship_number;
2482
2483 END IF;
2484
2485 EXCEPTION
2486
2487 WHEN OTHERS THEN
2488
2489 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2490 THEN
2491 OE_MSG_PUB.Add_Exc_Msg
2492 ( G_PKG_NAME ,
2493 'Get_Shipment_Number'
2494 );
2495 END IF;
2496
2497 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2498
2499 END Get_Shipment_Number;
2500
2501 FUNCTION Get_Shipping_Interfaced
2502 RETURN VARCHAR2
2503 IS
2504 --
2505 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2506 --
2507 BEGIN
2508
2509 RETURN 'N';
2510
2511 END Get_Shipping_Interfaced;
2512
2513 FUNCTION Get_Source_Type(p_source_type IN VARCHAR2,
2514 p_line_type_id IN NUMBER)
2515 RETURN VARCHAR2
2516 IS
2517 l_source_type VARCHAR2(30) := OE_GLOBALS.G_SOURCE_INTERNAL;
2518 --
2519 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2520 --
2521 BEGIN
2522
2523 IF l_debug_level > 0 THEN
2524 oe_debug_pub.add( 'DEFAULTING SOURCE TYPE' ) ;
2525 END IF;
2526
2527 IF p_line_type_id is not null AND
2528 p_line_type_id <> FND_API.G_MISS_NUM THEN
2529
2530 BEGIN
2531
2532 OE_ORDER_CACHE.Load_Line_Type(p_line_type_id);
2533 l_source_type := OE_ORDER_CACHE.g_line_type_rec.ship_source_type_code;
2534
2535 IF l_source_type is null THEN
2536 RETURN p_source_type;
2537 END IF;
2538
2539 IF l_source_type <> OE_GLOBALS.G_SOURCE_EXTERNAL AND
2540 l_source_type <> OE_GLOBALS.G_SOURCE_INTERNAL THEN
2541 l_source_type := p_source_type;
2542 END IF;
2543
2544 EXCEPTION
2545 WHEN OTHERS THEN
2546 l_source_type := p_source_type;
2547 END;
2548 END IF;
2549
2550
2551 IF l_debug_level > 0 THEN
2552 oe_debug_pub.add( 'DEFAULTING SOURCE TYPE AS || L_SOURCE_TYPE' ) ;
2553 END IF;
2554
2555 IF l_source_type <> p_source_type THEN
2556 RETURN l_source_type;
2557 ELSE
2558 RETURN p_source_type;
2559 END IF;
2560
2561 END Get_Source_Type;
2562
2563
2564 FUNCTION Get_Shippable
2565 ( p_line_id IN NUMBER
2566 ,p_inventory_item_id IN NUMBER
2567 ,p_ship_from_org_id IN NUMBER
2568 ,p_ato_line_id IN NUMBER
2569 ,p_item_type_code IN VARCHAR2)
2570 RETURN VARCHAR2
2571 IS
2572 --
2573 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2574 --
2575 BEGIN
2576
2577 IF ( p_inventory_item_id is NULL OR
2578 p_inventory_item_id = FND_API.G_MISS_NUM )
2579 THEN
2580 RETURN NULL;
2581 END IF;
2582
2583 IF (p_item_type_code = OE_GLOBALS.G_ITEM_CONFIG) THEN
2584 RETURN 'Y';
2585 END IF;
2586
2587 IF l_debug_level > 0 THEN
2588 oe_debug_pub.add( '1 , ATO_LINE_ID: '|| P_ATO_LINE_ID , 1 ) ;
2589 END IF;
2590
2591
2592 IF (p_ato_line_id is not null) AND
2593 (p_ato_line_id <> FND_API.G_MISS_NUM)
2594 THEN
2595
2596 -- ##1820608, ato_item can be under a pto model.
2597 IF NOT OE_GLOBALS.Equal(p_item_type_code,
2598 OE_GLOBALS.G_ITEM_STANDARD) AND
2599 NOT (p_item_type_code = OE_GLOBALS.G_ITEM_OPTION AND
2600 p_line_id = p_ato_line_id )
2601 THEN
2602
2603 IF l_debug_level > 0 THEN
2604 oe_debug_pub.add( 'ATO MODEL OR OPTION' , 1 ) ;
2605 END IF;
2606 RETURN 'N';
2607
2608 END IF;
2609
2610 END IF;
2611
2612
2613 OE_Order_Cache.Load_Item (p_inventory_item_id
2614 ,p_ship_from_org_id);
2615
2616 IF l_debug_level > 0 THEN
2617 oe_debug_pub.add( 'SHIPPABLE FLAG: ' || OE_ORDER_CACHE.G_ITEM_REC.SHIPPABLE_ITEM_FLAG , 1 ) ;
2618 END IF;
2619
2620 RETURN OE_ORDER_CACHE.g_item_rec.shippable_item_flag;
2621
2622 END Get_Shippable;
2623
2624
2625
2626 FUNCTION Get_SMC_Flag
2627 RETURN VARCHAR2
2628 IS
2629 --
2630 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2631 --
2632 BEGIN
2633
2634 IF l_debug_level > 0 THEN
2635 oe_debug_pub.add( 'DEFAULTING SMC FLAG ' , 1 ) ;
2636 END IF;
2637
2638 IF ( g_line_rec.inventory_item_id is NULL OR
2639 g_line_rec.inventory_item_id = FND_API.G_MISS_NUM )
2640 THEN
2641 RETURN NULL;
2642 IF l_debug_level > 0 THEN
2643 oe_debug_pub.add( 'SMC1 FLAG VALUE IS NULL' , 1 ) ;
2644 END IF;
2645 END IF;
2646
2647 IF l_debug_level > 0 THEN
2648 oe_debug_pub.add( 'GET SMC: TOP MODEL LINE ID :' || G_LINE_REC.TOP_MODEL_LINE_ID , 1 ) ;
2649 END IF;
2650
2651 -- SMC PTO flag is only for PTO's and Kits
2652
2653 IF (g_line_rec.top_model_line_id = g_line_rec.line_id) AND
2654 (g_line_rec.top_model_line_id <> nvl(g_line_rec.ato_line_id,0)) THEN
2655 OE_Order_Cache.Load_Item (g_line_rec.inventory_item_id
2656 ,g_line_rec.ship_from_org_id);
2657
2658 IF l_debug_level > 0 THEN
2659 oe_debug_pub.add( 'SMC FLAG ' || OE_ORDER_CACHE.G_ITEM_REC.SHIP_MODEL_COMPLETE_FLAG , 3 ) ;
2660 END IF;
2661 RETURN OE_ORDER_CACHE.g_item_rec.ship_model_complete_flag;
2662
2663 ELSIF
2664 g_line_rec.ship_model_complete_flag is not null AND
2665 g_line_rec.ship_model_complete_flag <> FND_API.G_MISS_CHAR AND
2666 g_line_rec.top_model_line_id is not NULL
2667 THEN
2668 IF l_debug_level > 0 THEN
2669 oe_debug_pub.add( 'SMC4 FLAG ' || G_LINE_REC.SHIP_MODEL_COMPLETE_FLAG , 3 ) ;
2670 END IF;
2671 return g_line_rec.ship_model_complete_flag;
2672 ELSE
2673 RETURN null;
2674 IF l_debug_level > 0 THEN
2675 oe_debug_pub.add( 'SMC5 FLAG VALUE IS NULL' , 3 ) ;
2676 END IF;
2677 END IF;
2678
2679 END Get_SMC_Flag;
2680
2681
2682
2683 FUNCTION Get_Defaulting_Invoice_Line
2684 (p_return_context IN VARCHAR2,
2685 p_return_attribute1 IN VARCHAR2,
2686 p_return_attribute2 IN VARCHAR2
2687 ) RETURN NUMBER
2688 IS
2689 l_invoice_line_id NUMBER := NULL;
2690 l_order_line_id NUMBER := NULL;
2691 --
2692 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2693 --
2694 BEGIN
2695
2696 IF (p_return_context = 'INVOICE') THEN
2697
2698 RETURN to_number(p_return_attribute2);
2699
2700 ELSIF p_return_context in ('SERIAL') THEN
2701
2702 IF l_debug_level > 0 THEN
2703 oe_debug_pub.add( 'ATTR1 ' || P_RETURN_ATTRIBUTE1 , 1 ) ;
2704 oe_debug_pub.add( 'ATTR2 ' || P_RETURN_ATTRIBUTE2 , 1 ) ;
2705 END IF;
2706 BEGIN
2707
2708 SELECT l.line_id
2709 INTO l_order_line_id
2710 FROM oe_order_lines l,
2711 mtl_unit_transactions_all_v u,
2712 mtl_material_transactions m
2713 WHERE l.Inventory_item_id = to_number(p_return_attribute1)
2714 AND m.transaction_source_type_id=2
2715 AND m.trx_source_line_id=l.line_id
2716 AND m.transaction_id = u.transaction_id
2717 AND u.serial_number = p_return_attribute2
2718 AND u.inventory_item_id = to_number(p_return_attribute1)
2719 AND rownum = 1;
2720
2721 IF l_debug_level > 0 THEN
2722 oe_debug_pub.add( 'LINE ' || TO_CHAR ( L_ORDER_LINE_ID ) , 1 ) ;
2723 END IF;
2724
2725 IF l_order_line_id IS NOT NULL THEN
2726 SELECT /* MOAC_SQL_CHANGE */ rctl.customer_trx_line_id
2727 INTO l_invoice_line_id
2728 FROM ra_customer_trx_lines_all rctl,
2729 ra_customer_trx rct,
2730 ar_lookups arlup
2731 WHERE rct.status_trx = arlup.lookup_code
2732 AND arlup.lookup_type = 'INVOICE_TRX_STATUS'
2733 AND rct.customer_trx_id = rctl.customer_trx_id
2734 AND rctl.interface_line_context='ORDER ENTRY'
2735 AND rctl.interface_line_attribute6 = to_char(l_order_line_id)
2736 AND rctl.line_type = 'LINE'
2737 AND rctl.interface_line_attribute11 = '0' --Bug2721441
2738 AND rctl.org_id=rct.org_id
2739 AND rownum = 1;
2740 IF l_debug_level > 0 THEN
2741 oe_debug_pub.add( 'INV LINE ' || TO_CHAR ( L_INVOICE_LINE_ID ) , 1 ) ;
2742 END IF;
2743 END IF;
2744 RETURN l_invoice_line_id;
2745 EXCEPTION
2746 WHEN NO_DATA_FOUND THEN
2747 -- not invoiced yet, return NULL
2748 IF l_debug_level > 0 THEN
2749 oe_debug_pub.add( 'IN NO DATA ' , 1 ) ;
2750 END IF;
2751 RETURN NULL;
2752 END;
2753
2754 ELSIF p_return_context in ('PO','ORDER') THEN
2755
2756 BEGIN
2757 SELECT /* MOAC_SQL_CHANGE */ rctl.customer_trx_line_id
2758 INTO l_invoice_line_id
2759 FROM ra_customer_trx_lines_all rctl,
2760 ra_customer_trx rct,
2761 ar_lookups arlup
2762 WHERE rct.status_trx = arlup.lookup_code
2763 AND arlup.lookup_type = 'INVOICE_TRX_STATUS'
2764 AND rct.customer_trx_id = rctl.customer_trx_id
2765 AND rctl.interface_line_context='ORDER ENTRY'
2766 AND rctl.interface_line_attribute6 = p_return_attribute2
2767 AND rctl.line_type = 'LINE'
2768 AND rctl.interface_line_attribute11 = '0' --Bug2721441
2769 AND rctl.org_id=rct.org_id
2770 AND rownum = 1;
2771 RETURN l_invoice_line_id;
2772 EXCEPTION
2773 WHEN NO_DATA_FOUND THEN
2774 -- not invoiced yet, return NULL
2775 RETURN NULL;
2776 END;
2777
2778 END IF;
2779 RETURN NULL;
2780 END Get_Defaulting_Invoice_Line;
2781
2782 FUNCTION Get_Def_Invoice_Line_Int
2783 (p_return_context IN VARCHAR2,
2784 p_return_attribute1 IN VARCHAR2,
2785 p_return_attribute2 IN VARCHAR2,
2786 p_sold_to_org_id IN NUMBER,
2787 p_curr_code IN VARCHAR2,
2788 p_ref_line_id OUT NOCOPY NUMBER
2789
2790 ) RETURN NUMBER
2791 IS
2792 l_invoice_line_id NUMBER := NULL;
2793 l_order_line_id NUMBER := NULL;
2794 l_order_number NUMBER;
2795 l_trxn_type_name VARCHAR2(30);
2796 l_lot_control_flag VARCHAR2(1);
2797 l_inventory_item_id NUMBER := TO_NUMBER(p_return_attribute1);
2798
2799 CURSOR C_REF_LINE(attr1 VARCHAR2, attr2 VARCHAR2) IS
2800 SELECT /* MOAC_SQL_CHANGE */ DISTINCT l.line_id line_id
2801 FROM oe_order_lines_all l,
2802 mtl_unit_transactions_all_v u,
2803 mtl_material_transactions m,
2804 oe_order_headers h
2805 WHERE l.Inventory_item_id = to_number(attr1)
2806 AND m.transaction_source_type_id=2
2807 AND m.trx_source_line_id=l.line_id
2808 AND m.transaction_id = u.transaction_id
2809 AND m.transaction_type_id IN (33,34,50,62)
2810 AND u.serial_number = attr2
2811 AND u.inventory_item_id = to_number(attr1)
2812 AND l.ship_from_org_id = m.organization_id
2813 AND l.inventory_item_id = m.inventory_item_id
2814 AND l.header_id = h.header_id
2815 AND h.sold_to_org_id = p_sold_to_org_id
2816 -- 6916542 AND h.transactional_curr_code = p_curr_code
2817 AND l.cancelled_flag <> 'Y'
2818 order by l.line_id;
2819
2820 CURSOR C_LOT_REF_LINE(attr1 VARCHAR2, attr2 VARCHAR2) IS
2821 SELECT /* MOAC_SQL_CHANGE */ DISTINCT l.line_id line_id
2822 FROM mtl_material_transactions m,
2823 mtl_transaction_lot_val_v t,
2824 mtl_unit_transactions_all_v u,
2825 oe_order_lines_all l,
2826 oe_order_headers h
2827 WHERE u.Inventory_item_id = to_number(attr1)
2828 AND u.ORGANIZATION_ID = t.ORGANIZATION_ID
2829 AND u.serial_number = attr2
2830 AND t.serial_transaction_id = u.transaction_id
2831 AND m.transaction_id = t.transaction_id
2832 AND t.ORGANIZATION_ID = u.ORGANIZATION_ID
2833 AND t.inventory_item_id = u.inventory_item_id
2834 AND m.INVENTORY_ITEM_ID = l.inventory_item_id
2835 AND m.ORGANIZATION_ID = l.ship_from_org_id
2836 AND m.trx_source_line_id=l.line_id
2837 AND m.transaction_source_type_id = 2
2838 AND m.transaction_type_id IN (33,34,50,62)
2839 AND l.cancelled_flag <> 'Y'
2840 AND l.header_id = h.header_id
2841 AND h.sold_to_org_id = p_sold_to_org_id
2842 -- 6916542 AND h.transactional_curr_code = p_curr_code
2843 order by l.line_id;
2844
2845 -- bug#5452691:
2846 -- Adding cancelled_flag condition to filter out all the cancelled lines.
2847 -- otherwise no-data-found error will be thrown when the cursor is iterated
2848 -- and removed it from query when cursor is opened.
2849
2850 CURSOR C_LOT_SERIAL(p_serial_num VARCHAR2) IS
2851 SELECT ls.line_id,ls.line_set_id,ls.from_serial_number,ls.to_serial_number
2852 FROM oe_lot_serial_numbers ls, oe_order_lines ol
2853 WHERE ls.line_id = ol.line_id
2854 AND nvl(ol.cancelled_flag,'N') <> 'Y'
2855 AND (ls.from_serial_number = p_serial_num OR ls.to_serial_number = p_serial_num );
2856 /*
2857 CURSOR C_LOT_SERIAL(p_serial_num VARCHAR2) IS
2858 SELECT line_id,line_set_id,from_serial_number,to_serial_number
2859 FROM oe_lot_serial_numbers
2860 WHERE from_serial_number = p_serial_num
2861 OR to_serial_number = p_serial_num;
2862 */
2863 -- bug#5452691
2864
2865 CURSOR C_ORDER_INFO(ord_line_id NUMBER) IS
2866 SELECT /* MOAC_SQL_CHANGE */ ooh.order_number, ott.name
2867 FROM oe_order_lines_all ool,
2868 oe_order_headers ooh,
2869 oe_transaction_types_tl ott
2870 WHERE ool.line_id = ord_line_id
2871 AND ooh.header_id = ool.header_id
2872 AND ott.transaction_type_id = ooh.order_type_id
2873 -- 6916542 AND ooh.transactional_curr_code = p_curr_code
2874 AND ooh.sold_to_org_id = p_sold_to_org_id
2875 AND ott.language =
2876 (select language_code
2877 from fnd_languages
2878 where installed_flag = 'B');
2879
2880 -- With the addition of logic to support lot-serial controlled item
2881 -- we are adding this new code to figure out the line_id for the
2882 -- specified item and serial number combination.
2883
2884 CURSOR control_codes IS
2885 SELECT decode(msi.lot_control_code,2,'Y','N')
2886 FROM mtl_system_items msi
2887 WHERE msi.inventory_item_id = l_inventory_item_id
2888 AND msi.organization_id =
2889 OE_Sys_Parameters.VALUE_WNPS('MASTER_ORGANIZATION_ID');
2890
2891 TYPE line_tbl_type IS TABLE OF NUMBER
2892 INDEX BY BINARY_INTEGER;
2893 l_line_tbl line_tbl_type;
2894 l_ref_line_tbl line_tbl_type;
2895 l_index1 NUMBER;
2896 l_index2 NUMBER;
2897 l_match VARCHAR2(1);
2898
2899 --
2900 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2901 --
2902 BEGIN
2903 IF l_debug_level > 0 THEN
2904 oe_debug_pub.add( 'ATTR1 ' || P_RETURN_ATTRIBUTE1 , 1 ) ;
2905 oe_debug_pub.add( 'ATTR2 ' || P_RETURN_ATTRIBUTE2 , 1 ) ;
2906 END IF;
2907
2908 IF (p_return_context = 'INVOICE') THEN
2909 BEGIN
2910 /* Modified the following query to put the ivoice currency check for the bug 6916542 */
2911
2912 SELECT /* MOAC_SQL_CHANGE */ to_number(rctl.interface_line_attribute6)
2913 INTO p_ref_line_id
2914 FROM ra_customer_trx_lines_all rctl,
2915 ra_customer_trx_all rct,
2916 oe_order_lines_all l,
2917 oe_order_headers h
2918 WHERE to_number(p_return_attribute2) = rctl.customer_trx_line_id
2919 and rctl.customer_trx_id = rct.customer_trx_id
2920 AND l.line_id = rctl.interface_line_attribute6
2921 AND l.header_id = h.header_id
2922 AND p_curr_code = rct.invoice_currency_code
2923 AND h.sold_to_org_id = p_sold_to_org_id
2924 -- 6916542 AND h.transactional_curr_code = p_curr_code
2925 and rctl.org_id=h.org_id;
2926
2927 EXCEPTION
2928
2929 WHEN OTHERS THEN
2930 -- this should not be possible
2931 IF l_debug_level > 0 THEN
2932 oe_debug_pub.add( 'ERROR WHILE GETTING THE REFERENCE LINE FOR THE INVOICE LINE' , 2 ) ;
2933 END IF;
2934 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2935 THEN
2936 OE_MSG_PUB.Add_Exc_Msg
2937 ( G_PKG_NAME ,
2938 'Get_Def_Invoice_Line_Int'
2939 );
2940 END IF;
2941
2942 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2943
2944 END;
2945
2946 RETURN to_number(p_return_attribute2);
2947
2948 ELSIF p_return_context in ('SERIAL') THEN
2949
2950 IF l_debug_level > 0 THEN
2951 oe_debug_pub.add( 'IN SERIAL ' ) ;
2952 END IF;
2953 -- Check to find whether the item is LOT-SERIAL controlled
2954
2955 OPEN control_codes;
2956 FETCH control_codes INTO l_lot_control_flag;
2957 IF control_codes%notfound THEN
2958 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2959 END IF;
2960 CLOSE control_codes;
2961
2962 BEGIN
2963 IF l_lot_control_flag = 'Y' THEN
2964 IF l_debug_level > 0 THEN
2965 oe_debug_pub.add( 'IN LOT-SERIAL ' ) ;
2966 END IF;
2967
2968 -- If the item is LOT-SERIAL Controlled
2969
2970 l_index2:=1;
2971 FOR C_LINE IN C_LOT_REF_LINE(p_return_attribute1,
2972 p_return_attribute2)
2973 LOOP
2974 l_line_tbl(l_index2) := C_LINE.line_id;
2975 l_index2:= l_index2+1;
2976 IF l_debug_level > 0 THEN
2977 oe_debug_pub.add( 'IN LOT-SERIAL12 ' ) ;
2978 END IF;
2979
2980 -- Check to see if any referenced return exists for the line.
2981 l_index1 := 0;
2982 SELECT count(*)
2983 INTO l_index1
2984 FROM OE_ORDER_LINES
2985 WHERE reference_line_id = C_LINE.line_id
2986 AND line_category_code = 'RETURN'
2987 AND cancelled_flag <> 'Y';
2988
2989 IF l_debug_level > 0 THEN
2990 oe_debug_pub.add( 'IN LOT-SERIAL2 '||TO_CHAR ( L_INDEX1 ) ) ;
2991 END IF;
2992 -- If there is no referenced return for this line then return
2993 -- this line as a referenced_line_id.
2994
2995 IF l_index1 = 0 THEN
2996 IF l_debug_level > 0 THEN
2997 oe_debug_pub.add( 'IN SERIAL3 '||TO_CHAR ( L_INDEX1 ) ) ;
2998 END IF;
2999 l_order_line_id := C_LINE.line_id;
3000 GOTO GET_INVOICE_LINE;
3001 END IF;
3002 END LOOP;
3003
3004 ELSE
3005 -- If the item is LOT Controlled
3006 l_index2:=1;
3007 FOR C_LINE IN C_REF_LINE(p_return_attribute1, p_return_attribute2)LOOP
3008 IF l_debug_level > 0 THEN
3009 oe_debug_pub.add( 'IN SERIAL1 ' ) ;
3010 END IF;
3011 l_line_tbl(l_index2) := C_LINE.line_id;
3012 l_index2:= l_index2+1;
3013 IF l_debug_level > 0 THEN
3014 oe_debug_pub.add( 'IN SERIAL12 ' ) ;
3015 END IF;
3016
3017 -- Check to see if any referenced return exists for the line.
3018 l_index1 := 0;
3019 SELECT count(*)
3020 INTO l_index1
3021 FROM OE_ORDER_LINES
3022 WHERE reference_line_id = C_LINE.line_id
3023 AND line_category_code = 'RETURN'
3024 AND cancelled_flag <> 'Y';
3025
3026 IF l_debug_level > 0 THEN
3027 oe_debug_pub.add( 'IN SERIAL2 '||TO_CHAR ( L_INDEX1 ) ) ;
3028 END IF;
3029 -- If there is no referenced return for this line then return
3030 -- this line as a referenced_line_id.
3031
3032 IF l_index1 = 0 THEN
3033 IF l_debug_level > 0 THEN
3034 oe_debug_pub.add( 'IN SERIAL3 '||TO_CHAR ( L_INDEX1 ) ) ;
3035 END IF;
3036 l_order_line_id := C_LINE.line_id;
3037 GOTO GET_INVOICE_LINE;
3038 END IF;
3039 END LOOP;
3040 END IF; -- IF item is LOT-SERIAL controlled.
3041
3042 -- If there are no outbound lines which refers the entered Serial
3043 -- Number then raise error with message.
3044
3045 IF l_debug_level > 0 THEN
3046 oe_debug_pub.add( 'IN SERIAL4 '||TO_CHAR ( L_LINE_TBL.COUNT ) ) ;
3047 END IF;
3048 IF l_line_tbl.count = 0 THEN
3049 FND_Message.Set_Name('ONT', 'OE_NO_LINES_FOR_SERIAL_NUMBER');
3050 oe_msg_pub.add;
3051 RAISE FND_API.G_EXC_ERROR;
3052 END IF;
3053
3054 -- For all outbound lines which are referring to this serial number,
3055 -- one or more referenced RMA exists.
3056
3057 l_index2 := 1;
3058
3059 -- Check the OE_LOT_SERIAL_NUMBERS table for the entered Serial Number.
3060
3061 IF l_debug_level > 0 THEN
3062 oe_debug_pub.add( 'IN SERIAL5 ' ) ;
3063 END IF;
3064 FOR C2 IN C_LOT_SERIAL(p_return_attribute2) LOOP
3065
3066 -- If record exists in oe_lot_serial_numbers for the entered SN,
3067 -- check the line_set_id on it. There will be a value for line_set_id
3068 -- if the RMA line has got split. Get the reference line_id from the
3069 -- following queries.
3070
3071 IF C2.line_set_id is not null THEN
3072 select distinct reference_line_id
3073 into l_ref_line_tbl(l_index2)
3074 from oe_line_sets a,
3075 oe_order_lines b
3076 where a.set_id = C2.line_set_id
3077 and a.line_id = b.line_id
3078 and b.cancelled_flag <> 'Y';
3079 ELSE
3080 select reference_line_id
3081 into l_ref_line_tbl(l_index2)
3082 from oe_order_lines
3083 where line_id = C2.line_id;
3084 -- bug#5452691
3085 -- and cancelled_flag <> 'Y';
3086 END IF;
3087 IF l_debug_level > 0 THEN
3088 oe_debug_pub.add( 'IN SERIAL6 THE REF LINE IS '|| TO_CHAR ( L_REF_LINE_TBL ( L_INDEX2 ) ) ) ;
3089 END IF;
3090 l_index2 := l_index2+1;
3091 END LOOP;
3092
3093 -- There can not be more than one outbound line referring the entered
3094 -- SN and no RMA referring it.
3095
3096 IF l_debug_level > 0 THEN
3097 oe_debug_pub.add( 'IN SERIAL7 ' ) ;
3098 END IF;
3099 IF l_ref_line_tbl.COUNT = 0 AND
3100 l_line_tbl.count > 1 THEN
3101 IF l_debug_level > 0 THEN
3102 oe_debug_pub.add( 'IN SERIAL71 ' ) ;
3103 END IF;
3104 FND_Message.Set_Name('ONT', 'OE_DUPLICATE_LINES_FOR_SAME_SN');
3105 oe_msg_pub.add;
3106 RAISE FND_API.G_EXC_ERROR;
3107 END IF;
3108
3109 IF l_debug_level > 0 THEN
3110 oe_debug_pub.add( 'IN SERIAL8 ' ) ;
3111 END IF;
3112 IF l_ref_line_tbl.COUNT = 0 AND
3113 l_line_tbl.count = 1 THEN
3114 IF l_debug_level > 0 THEN
3115 oe_debug_pub.add( 'IN SERIAL81 ' ) ;
3116 END IF;
3117 l_order_line_id := l_line_tbl(1);
3118 END IF;
3119
3120 -- Check for the outbound line referring the entered SN and
3121 -- which is not returned yet
3122
3123 l_index1 := 0;
3124 l_index2 := 0;
3125
3126 IF l_ref_line_tbl.COUNT > 0 THEN
3127 l_index1 := l_line_tbl.FIRST;
3128 WHILE l_index1 IS NOT NULL LOOP
3129 l_match := 'N';
3130 l_index2 := l_ref_line_tbl.FIRST;
3131 WHILE l_index2 IS NOT NULL LOOP
3132 IF l_line_tbl(l_index1) = l_ref_line_tbl(l_index2)
3133 THEN
3134 l_match := 'Y';
3135 IF l_debug_level > 0 THEN
3136 oe_debug_pub.add( 'MATCH FOUND ' ) ;
3137 END IF;
3138 GOTO END_OF_INDEX1_LOOP;
3139 END IF;
3140 l_index2 := l_ref_line_tbl.NEXT(l_index2);
3141 END LOOP;
3142 IF l_match = 'N' THEN
3143 l_order_line_id := l_line_tbl(l_index1);
3144 GOTO GET_INVOICE_LINE;
3145 END IF;
3146 << END_OF_INDEX1_LOOP >>
3147 l_index1 := l_line_tbl.NEXT(l_index1);
3148 END LOOP;
3149 END IF;
3150
3151 << GET_INVOICE_LINE >>
3152 -- oe_debug_pub.add('Line ' || to_char(l_order_line_id),1);
3153
3154 -- If there is no valid outbound line to be referenced for the entered
3155 -- SN then raise error.
3156
3157 IF l_order_line_id IS NULL THEN
3158 IF l_debug_level > 0 THEN
3159 oe_debug_pub.add( 'NO LINES AVAILABLE FOR RETURN' ) ;
3160 END IF;
3161 FND_Message.Set_Name('ONT', 'OE_NO_LINES_FOR_SERIAL_NUMBER');
3162 oe_msg_pub.add;
3163 RAISE FND_API.G_EXC_ERROR;
3164 ELSE
3165 IF l_debug_level > 0 THEN
3166 oe_debug_pub.add('LINE ' || TO_CHAR(L_ORDER_LINE_ID),1);
3167 END IF;
3168 END IF;
3169
3170 FOR c_info_rec1 in C_ORDER_INFO(l_order_line_id) LOOP
3171 l_order_number := c_info_rec1.order_number;
3172 l_trxn_type_name:= c_info_rec1.name;
3173 END LOOP;
3174
3175 p_ref_line_id := l_order_line_id;
3176 IF l_debug_level > 0 THEN
3177 oe_debug_pub.add( 'IN SERIAL9 ' ) ;
3178 END IF;
3179 BEGIN
3180 SELECT /* MOAC_SQL_CHANGE */ rctl.customer_trx_line_id
3181 INTO l_invoice_line_id
3182 FROM ra_customer_trx_lines_all rctl,
3183 ra_customer_trx rct,
3184 ar_lookups arlup
3185 WHERE rct.status_trx = arlup.lookup_code
3186 AND arlup.lookup_type = 'INVOICE_TRX_STATUS'
3187 AND rct.customer_trx_id = rctl.customer_trx_id
3188 AND rctl.interface_line_context = 'ORDER ENTRY'
3189 AND rctl.interface_line_attribute1 = to_char(l_order_number)
3190 AND rctl.interface_line_attribute2 = l_trxn_type_name
3191 AND rctl.interface_line_attribute6 = to_char(l_order_line_id)
3192 AND rctl.line_type = 'LINE'
3193 AND rctl.interface_line_attribute11 = '0' --Bug2721441
3194 AND rctl.org_id=rct.org_id
3195 AND rownum = 1;
3196 IF l_debug_level > 0 THEN
3197 oe_debug_pub.add( 'INVOICE LINE ' || TO_CHAR ( L_INVOICE_LINE_ID ) , 1 ) ;
3198 END IF;
3199
3200 EXCEPTION
3201
3202 WHEN OTHERS THEN
3203 -- not invoiced yet, return NULL
3204 IF l_debug_level > 0 THEN
3205 oe_debug_pub.add( 'NOT INVOICED YET' , 1 ) ;
3206 END IF;
3207 RETURN NULL;
3208
3209 END;
3210 RETURN l_invoice_line_id;
3211 IF l_debug_level > 0 THEN
3212 oe_debug_pub.add( 'IN SERIAL10' ) ;
3213 END IF;
3214
3215 EXCEPTION
3216 WHEN FND_API.G_EXC_ERROR THEN
3217 RAISE FND_API.G_EXC_ERROR;
3218 WHEN OTHERS THEN
3219 IF l_debug_level > 0 THEN
3220 oe_debug_pub.add( 'IN OTHERS EXCEPTION FOR SERIAL' , 2 ) ;
3221 END IF;
3222 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3223 THEN
3224 OE_MSG_PUB.Add_Exc_Msg
3225 ( G_PKG_NAME ,
3226 'OE_Default_Line.Get_Def_Invoice_Line_Int'
3227 );
3228 END IF;
3229 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3230
3231 END;
3232
3233 ELSIF p_return_context in ('PO','ORDER') THEN
3234
3235 FOR c_info_rec2 in C_ORDER_INFO(p_return_attribute2) LOOP
3236 l_order_number := c_info_rec2.order_number;
3237 l_trxn_type_name:= c_info_rec2.name;
3238 END LOOP;
3239
3240 IF l_order_number IS NULL THEN
3241 oe_debug_pub.add('Invalid Return Reference',1);
3242 fnd_message.set_name('ONT', 'OE_RETURN_INVALID_SO_LINE');
3243 OE_MSG_PUB.Add;
3244 RAISE FND_API.G_EXC_ERROR;
3245 END IF;
3246
3247 BEGIN
3248
3249 SELECT /* MOAC_SQL_CHANGE */ rctl.customer_trx_line_id
3250 INTO l_invoice_line_id
3251 FROM ra_customer_trx_lines_all rctl,
3252 ra_customer_trx rct,
3253 ar_lookups arlup
3254 WHERE rct.status_trx = arlup.lookup_code
3255 AND arlup.lookup_type = 'INVOICE_TRX_STATUS'
3256 AND rct.customer_trx_id = rctl.customer_trx_id
3257 AND p_return_attribute2 = rctl.interface_line_attribute6
3258 AND rctl.interface_line_context = 'ORDER ENTRY'
3259 AND rctl.interface_line_attribute1 = to_char(l_order_number)
3260 AND rctl.interface_line_attribute2 = l_trxn_type_name
3261 AND rctl.line_type = 'LINE'
3262 AND rctl.interface_line_attribute11 = '0' --Bug2721441
3263 and rctl.org_id=rct.org_id
3264 AND rownum = 1;
3265
3266 p_ref_line_id := p_return_attribute2;
3267 RETURN l_invoice_line_id;
3268
3269 EXCEPTION
3270
3271 WHEN OTHERS THEN
3272 IF l_debug_level > 0 THEN
3273 oe_debug_pub.add( 'IN OTHERS EXCEPTION FOR CONTEXT OF PO/ORDER' , 2 ) ;
3274 END IF;
3275 -- not invoiced yet, return NULL
3276 p_ref_line_id := p_return_attribute2;
3277 RETURN NULL;
3278
3279 END;
3280
3281 END IF;
3282 p_ref_line_id := p_return_attribute2;
3283 RETURN NULL;
3284 END Get_Def_Invoice_Line_Int;
3285
3286
3287 FUNCTION Get_Defaulting_Order_Line
3288 (p_return_context VARCHAR2,
3289 p_return_attribute1 VARCHAR2,
3290 p_return_attribute2 VARCHAR2
3291 ) RETURN NUMBER
3292 IS
3293 l_order_line_id NUMBER := NULL;
3294 --
3295 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3296 --
3297 BEGIN
3298
3299 IF l_debug_level > 0 THEN
3300 oe_debug_pub.add( 'ENTERING GET_DEFAULTING_ORDER_LINE' ) ;
3301 END IF;
3302
3303 IF (p_return_context = 'ORDER') THEN
3304
3305 RETURN to_number(p_return_attribute2);
3306
3307 ELSIF (p_return_context = 'PO') THEN
3308
3309 RETURN to_number(p_return_attribute2);
3310
3311 ELSIF (p_return_context = 'SERIAL') THEN
3312
3313 BEGIN
3314
3315 SELECT l.line_id
3316 INTO l_order_line_id
3317 FROM oe_order_lines l,
3318 mtl_unit_transactions_all_v u,
3319 mtl_material_transactions m
3320 WHERE L.Inventory_item_id = to_number(p_return_attribute1)
3321 AND m.transaction_id = u.transaction_id
3322 AND l.line_category_code = 'ORDER'
3323 AND m.transaction_source_type_id=2
3324 AND m.trx_source_line_id=l.line_id
3325 AND u.serial_number = p_return_attribute2
3326 AND u.inventory_item_id = to_number(p_return_attribute1)
3327 AND rownum = 1;
3328
3329 RETURN l_order_line_id;
3330
3331 EXCEPTION
3332
3333
3334 WHEN NO_DATA_FOUND THEN
3335
3336 -- this should not be possible
3337 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3338 THEN
3339 OE_MSG_PUB.Add_Exc_Msg
3340 ( G_PKG_NAME ,
3341 'Get_Defaulting_Order_Line'
3342 );
3343 END IF;
3344
3345 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3346
3347 END;
3348
3349 ELSE
3350
3351 BEGIN
3352
3353 SELECT to_number(rctl.interface_line_attribute6)
3354 INTO l_order_line_id
3355 FROM ra_customer_trx_lines rctl
3356 WHERE to_number(p_return_attribute2) = rctl.customer_trx_line_id;
3357
3358 RETURN l_order_line_id;
3359
3360 EXCEPTION
3361
3362 WHEN NO_DATA_FOUND THEN
3363 -- this should not be possible
3364 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3365 THEN
3366 OE_MSG_PUB.Add_Exc_Msg
3367 ( G_PKG_NAME ,
3368 'Get_Defaulting_Order_Line'
3369 );
3370 END IF;
3371
3372 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3373
3374 END;
3375
3376 END IF;-- return context
3377
3378 END Get_Defaulting_Order_Line;
3379
3380 Procedure Attributes_From_Invoice_Line
3381 ( p_invoice_line_id IN NUMBER
3382 , p_x_line_rec IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type
3383 )
3384 IS
3385 l_quantity NUMBER;
3386 l_uom_code VARCHAR2(3);
3387 l_tax_exempt_flag VARCHAR2(1);
3388 l_tax_exempt_reason_code VARCHAR2(30);
3389 l_tax_exempt_number VARCHAR2(80);
3390 --
3391 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3392 --
3393 BEGIN
3394
3395 IF (p_invoice_line_id IS NOT NULL) THEN
3396 -- get attributes from invoice line
3397 BEGIN
3398 SELECT /* MOAC_SQL_CHANGE */ rctl.quantity_invoiced,
3399 rctl.tax_exempt_flag,
3400 rctl.tax_exempt_reason_code,
3401 rctl.tax_exempt_number,
3402 rctl.uom_code
3403 INTO l_quantity,
3404 l_tax_exempt_flag,
3405 l_tax_exempt_reason_code,
3406 l_tax_exempt_number,
3407 l_uom_code
3408 FROM ra_customer_trx_lines_all rctl,
3409 oe_order_lines l
3410 WHERE rctl.customer_trx_line_id = p_invoice_line_id
3411 AND to_number(rctl.interface_line_attribute6) = l.line_id;
3412 EXCEPTION
3413 WHEN NO_DATA_FOUND THEN
3414 -- this should not be possible
3415 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3416 THEN
3417 OE_MSG_PUB.Add_Exc_Msg
3418 ( G_PKG_NAME ,
3419 'Attributes_From_Invoice_Line'
3420 );
3421 END IF;
3422
3423 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3424 END;
3425
3426 -- use this attributes as default if not overriden
3427 /* We can not copy the invoiced_quantity to ordered_quantity */
3428 /*
3429 IF (p_x_line_rec.ordered_quantity IS NULL OR
3430 p_x_line_rec.ordered_quantity = FND_API.G_MISS_NUM) THEN
3431 p_x_line_rec.ordered_quantity := l_quantity;
3432 p_x_line_rec.order_quantity_uom := l_uom_code;
3433 ELSE
3434 NULL;
3435 END IF;
3436 */
3437
3438
3439 IF (p_x_line_rec.tax_exempt_flag IS NULL OR
3440 p_x_line_rec.tax_exempt_flag = FND_API.G_MISS_CHAR) THEN
3441 p_x_line_rec.tax_exempt_flag := l_tax_exempt_flag;
3442 END IF;
3443
3444 IF (p_x_line_rec.tax_exempt_reason_code IS NULL OR
3445 p_x_line_rec.tax_exempt_reason_code = FND_API.G_MISS_CHAR) THEN
3446 p_x_line_rec.tax_exempt_reason_code := l_tax_exempt_reason_code;
3447 END IF;
3448
3449 IF (p_x_line_rec.tax_exempt_number IS NULL OR
3450 p_x_line_rec.tax_exempt_number = FND_API.G_MISS_CHAR) THEN
3451 p_x_line_rec.tax_exempt_number := l_tax_exempt_number;
3452 END IF;
3453
3454 IF (p_x_line_rec.reference_customer_trx_line_id IS NULL OR
3455 p_x_line_rec.reference_customer_trx_line_id = FND_API.G_MISS_NUM) THEN
3456 p_x_line_rec.reference_customer_trx_line_id := p_invoice_line_id;
3457 END IF;
3458
3459 IF (p_x_line_rec.credit_invoice_line_id IS NULL OR
3460 p_x_line_rec.credit_invoice_line_id = FND_API.G_MISS_NUM) THEN
3461 p_x_line_rec.credit_invoice_line_id := p_invoice_line_id;
3462 END IF;
3463
3464 END IF; -- exists invoice line
3465
3466 IF l_debug_level > 0 THEN
3467 oe_debug_pub.add( 'EXITING ATTRIBUTES_FROM_INVOICE_LINE' , 1 ) ;
3468 END IF;
3469
3470 END Attributes_From_Invoice_Line;
3471
3472 Procedure Attributes_From_Order_Line
3473 ( p_order_line_id IN NUMBER
3474 , p_x_line_rec IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type
3475 )
3476 IS
3477 l_ref_line_rec OE_ORDER_PUB.Line_Rec_Type;
3478 l_revision_controlled VARCHAR2(1);
3479 x_item_rec OE_Order_Cache.Item_Rec_Type;
3480 --
3481 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3482 --
3483 l_overship_invoice_basis varchar2(30) := null; --- bug# 6617423
3484
3485 BEGIN
3486
3487 IF l_debug_level > 0 THEN
3488 oe_debug_pub.add( 'ENTERING ATTRIBUTES_FROM_ORDER_LINE with p_order_line_id = ' ||p_order_line_id , 1 ) ;
3489 END IF;
3490
3491 IF (p_order_line_id IS NOT NULL AND
3492 p_order_line_id<>FND_API.G_MISS_NUM) THEN
3493
3494 oe_line_util.query_row
3495 (p_line_id => p_order_line_id
3496 ,x_line_rec => l_ref_line_rec
3497 );
3498
3499 /* assign the referenced fields */
3500 IF ((p_x_line_rec.ordered_item IS NULL OR
3501 p_x_line_rec.ordered_item = FND_API.G_MISS_CHAR)
3502 AND (p_x_line_rec.inventory_item_id IS NULL OR
3503 p_x_line_rec.inventory_item_id = FND_API.G_MISS_NUM)
3504 AND (p_x_line_rec.ordered_item_id IS NULL OR
3505 p_x_line_rec.ordered_item_id = FND_API.G_MISS_NUM)) THEN
3506 p_x_line_rec.ordered_item := l_ref_line_rec.ordered_item ;
3507 p_x_line_rec.inventory_item_id := l_ref_line_rec.inventory_item_id;
3508 p_x_line_rec.item_identifier_type := l_ref_line_rec.item_identifier_type;
3509 p_x_line_rec.ordered_item_id := l_ref_line_rec.ordered_item_id;
3510 p_x_line_rec.item_type_code := OE_GLOBALS.G_ITEM_STANDARD;
3511 ELSE
3512 NULL;
3513 END IF;
3514
3515 IF (p_x_line_rec.return_context = 'SERIAL') THEN
3516 p_x_line_rec.ordered_quantity := 1;
3517 p_x_line_rec.order_quantity_uom := l_ref_line_rec.order_quantity_uom;
3518 END IF;
3519
3520 IF (p_x_line_rec.ordered_quantity IS NULL OR
3521 p_x_line_rec.ordered_quantity = fnd_api.g_miss_num) THEN
3522
3523 -- p_x_line_rec.ordered_quantity := l_ref_line_rec.ordered_quantity; -- bug# 6617423
3524 -- bug# 6617423 : Start ---------
3525 oe_debug_pub.add( ' p_x_line_rec.org_id = '||p_x_line_rec.org_id ,5);
3526 IF p_x_line_rec.org_id = FND_API.G_MISS_NUM THEN
3527 l_overship_invoice_basis := oe_sys_parameters.value('OE_OVERSHIP_INVOICE_BASIS',NULL);
3528 ELSE
3529 l_overship_invoice_basis := oe_sys_parameters.value('OE_OVERSHIP_INVOICE_BASIS',p_x_line_rec.org_id);
3530 END IF;
3531 oe_debug_pub.add( ' l_overship_invoice_basis = '|| l_overship_invoice_basis ,5 ) ;
3532 oe_debug_pub.add( ' l_ref_line_rec.invoiced_quantity = '|| l_ref_line_rec.invoiced_quantity ,5 ) ;
3533 oe_debug_pub.add( ' l_ref_line_rec.ordered_quantity = '|| l_ref_line_rec.ordered_quantity,5 ) ;
3534
3535 IF l_overship_invoice_basis = 'SHIPPED' then
3536 p_x_line_rec.ordered_quantity := nvl(l_ref_line_rec.shipped_quantity, l_ref_line_rec.ordered_quantity);
3537 ELSE
3538 p_x_line_rec.ordered_quantity := l_ref_line_rec.ordered_quantity;
3539 end if;
3540 oe_debug_pub.add( ' p_x_line_rec.ordered_quantity = '|| p_x_line_rec.ordered_quantity, 5 ) ;
3541 -- bug# 6617423 : End
3542
3543 p_x_line_rec.order_quantity_uom := l_ref_line_rec.order_quantity_uom;
3544
3545 ELSE
3546 NULL;
3547 END IF;
3548
3549
3550 IF (p_x_line_rec.unit_cost IS NULL OR
3551 p_x_line_rec.unit_cost = fnd_api.g_miss_num) THEN
3552 p_x_line_rec.unit_cost := l_ref_line_rec.unit_cost;
3553 END IF;
3554
3555 IF (p_x_line_rec.order_quantity_uom IS NULL OR
3556 p_x_line_rec.order_quantity_uom = fnd_api.g_miss_char) THEN
3557 p_x_line_rec.order_quantity_uom := l_ref_line_rec.order_quantity_uom;
3558 END IF;
3559
3560 -- 09/07/2001 OPM BEGIN - Default process attributes as appropriate from an order line ref
3561 -- ===============================================================
3562 IF (p_x_line_rec.ordered_quantity_uom2 = FND_API.G_MISS_CHAR)
3563 OR (p_x_line_rec.ordered_quantity_uom2 IS NULL) THEN
3564 p_x_line_rec.ordered_quantity_uom2 :=
3565 l_ref_line_rec.ordered_quantity_uom2 ;
3566 END IF;
3567
3568 IF (p_x_line_rec.preferred_grade = FND_API.G_MISS_CHAR)
3569 OR (p_x_line_rec.preferred_grade IS NULL) THEN
3570 p_x_line_rec.preferred_grade :=
3571 l_ref_line_rec.preferred_grade ;
3572 END IF;
3573
3574 IF (p_x_line_rec.ordered_quantity2 = FND_API.G_MISS_NUM) THEN
3575 p_x_line_rec.ordered_quantity2 := l_ref_line_rec.ordered_quantity2;
3576 END IF;
3577
3578 -- 09/07/2001 OPM END
3579 -- =====================
3580
3581 IF (p_x_line_rec.reference_line_id IS NULL OR
3582 p_x_line_rec.reference_line_id = FND_API.G_MISS_NUM) THEN
3583 p_x_line_rec.reference_header_id := l_ref_line_rec.header_id;
3584 p_x_line_rec.reference_line_id := l_ref_line_rec.line_id;
3585 END IF;
3586
3587 /* Start : Tax Reference Info */
3588 IF (p_x_line_rec.tax_code IS NULL OR
3589 p_x_line_rec.tax_code = FND_API.G_MISS_CHAR)
3590 THEN
3591 p_x_line_rec.tax_code := l_ref_line_rec.tax_code;
3592 p_x_line_rec.tax_date := l_ref_line_rec.tax_date;
3593 END IF;
3594
3595 IF (p_x_line_rec.tax_exempt_flag IS NULL OR
3596 p_x_line_rec.tax_exempt_flag = FND_API.G_MISS_CHAR)
3597 THEN
3598 p_x_line_rec.tax_exempt_flag := l_ref_line_rec.tax_exempt_flag;
3599 END IF;
3600
3601 IF (p_x_line_rec.tax_exempt_number IS NULL OR
3602 p_x_line_rec.tax_exempt_number = FND_API.G_MISS_CHAR)
3603 THEN
3604 p_x_line_rec.tax_exempt_number := l_ref_line_rec.tax_exempt_number;
3605 END IF;
3606
3607 IF (p_x_line_rec.tax_exempt_reason_code IS NULL OR
3608 p_x_line_rec.tax_exempt_reason_code = FND_API.G_MISS_CHAR)
3609 THEN
3610 p_x_line_rec.tax_exempt_reason_code :=
3611 l_ref_line_rec.tax_exempt_reason_code;
3612 END IF;
3613
3614 /* End: Tax Reference Info */
3615
3616 IF (p_x_line_rec.pricing_quantity IS NULL OR
3617 p_x_line_rec.pricing_quantity = FND_API.G_MISS_NUM) THEN
3618 IF p_x_line_rec.return_context = 'SERIAL' OR
3619 OE_GLOBALS.G_RETURN_CHILDREN_MODE = 'Y' THEN
3620 p_x_line_rec.pricing_quantity_uom :=
3621 l_ref_line_rec.pricing_quantity_uom;
3622 p_x_line_rec.pricing_quantity := OE_Order_Misc_Util.convert_uom(
3623 p_x_line_rec.inventory_item_id,
3624 p_x_line_rec.order_quantity_uom,
3625 p_x_line_rec.pricing_quantity_uom,
3626 p_x_line_rec.ordered_quantity
3627 );
3628 ELSE
3629 p_x_line_rec.pricing_quantity := l_ref_line_rec.pricing_quantity;
3630 p_x_line_rec.pricing_quantity_uom :=
3631 l_ref_line_rec.pricing_quantity_uom;
3632 END IF;
3633 ELSE
3634 NULL;
3635 END IF;
3636
3637 IF (p_x_line_rec.pricing_date IS NULL OR
3638 p_x_line_rec.pricing_date = fnd_api.g_miss_date) THEN
3639 p_x_line_rec.pricing_date := l_ref_line_rec.pricing_date ;
3640 ELSE
3641 NULL;
3642 END IF;
3643
3644 IF (p_x_line_rec.unit_selling_price IS NULL OR
3645 p_x_line_rec.unit_selling_price = FND_API.G_MISS_NUM) THEN
3646 p_x_line_rec.unit_selling_price := l_ref_line_rec.unit_selling_price ;
3647 IF (l_ref_line_rec.pricing_context IS NOT NULL) THEN
3648 p_x_line_rec.pricing_context := l_ref_line_rec.pricing_context;
3649 p_x_line_rec.pricing_attribute1 := l_ref_line_rec.pricing_attribute1;
3650 p_x_line_rec.pricing_attribute2 := l_ref_line_rec.pricing_attribute2;
3651 p_x_line_rec.pricing_attribute3 := l_ref_line_rec.pricing_attribute3;
3652 p_x_line_rec.pricing_attribute4 := l_ref_line_rec.pricing_attribute4;
3653 p_x_line_rec.pricing_attribute5 := l_ref_line_rec.pricing_attribute5;
3654 p_x_line_rec.pricing_attribute6 := l_ref_line_rec.pricing_attribute6;
3655 p_x_line_rec.pricing_attribute7 := l_ref_line_rec.pricing_attribute7;
3656 p_x_line_rec.pricing_attribute8 := l_ref_line_rec.pricing_attribute8;
3657 p_x_line_rec.pricing_attribute9 := l_ref_line_rec.pricing_attribute9;
3658 p_x_line_rec.pricing_attribute10 := l_ref_line_rec.pricing_attribute10;
3659 END IF;
3660 ELSE
3661 NULL;
3662 END IF;
3663
3664 IF (p_x_line_rec.unit_percent_base_price IS NULL OR
3665 p_x_line_rec.unit_percent_base_price = FND_API.G_MISS_NUM) THEN
3666 p_x_line_rec.unit_percent_base_price := l_ref_line_rec.unit_percent_base_price ;
3667 ELSE
3668 NULL;
3669 END IF;
3670
3671 IF (p_x_line_rec.unit_list_price IS NULL OR
3672 p_x_line_rec.unit_list_price = FND_API.G_MISS_NUM) THEN
3673 p_x_line_rec.unit_list_price := l_ref_line_rec.unit_list_price ;
3674 END IF;
3675
3676 --RT{
3677 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
3678 oe_debug_pub.add('Retro:ref_head_id:'||l_ref_line_rec.header_id||' line_id:'||l_ref_line_rec.line_id);
3679 Oe_Retrobill_Pvt.Get_Return_Price(p_header_id=> l_ref_line_rec.header_id,
3680 p_line_id => l_ref_line_rec.line_id,
3681 p_ordered_qty => p_x_line_rec.ordered_quantity, --bug3540728
3682 p_pricing_qty => p_x_line_rec.pricing_quantity, --bug3540728
3683 p_usp => l_ref_line_rec.unit_selling_price,
3684 p_ulp => l_ref_line_rec.unit_list_price,
3685 x_usp => p_x_line_rec.unit_selling_price,
3686 x_ulp => p_x_line_rec.unit_list_price,
3687 x_ulp_ppqty => p_x_line_rec.unit_list_price_per_pqty, --bug3540728
3688 x_usp_ppqty => p_x_line_rec.unit_selling_price_per_pqty); --bug3540728
3689 p_x_line_rec.retrobill_request_id:=NULL;
3690 END IF;
3691 --RT}
3692
3693 -- Start: bug 1769612
3694 IF (p_x_line_rec.unit_list_price_per_pqty IS NULL OR
3695 p_x_line_rec.unit_list_price_per_pqty = FND_API.G_MISS_NUM) THEN
3696 p_x_line_rec.unit_list_price_per_pqty := l_ref_line_rec.unit_list_price_per_pqty ;
3697 END IF;
3698
3699 IF (p_x_line_rec.unit_selling_price_per_pqty IS NULL OR
3700 p_x_line_rec.unit_selling_price_per_pqty = FND_API.G_MISS_NUM) THEN
3701
3702 p_x_line_rec.unit_selling_price_per_pqty := l_ref_line_rec.unit_selling_price_per_pqty;
3703 END IF;
3704 -- end of bug 1769612
3705
3706 IF (p_x_line_rec.price_list_id IS NULL OR
3707 p_x_line_rec.price_list_id = FND_API.G_MISS_NUM) THEN
3708 p_x_line_rec.price_list_id := l_ref_line_rec.price_list_id ;
3709 ELSE
3710 NULL;
3711 END IF;
3712
3713 IF (p_x_line_rec.invoice_to_org_id IS NULL OR
3714 p_x_line_rec.invoice_to_org_id = FND_API.G_MISS_NUM) THEN
3715 p_x_line_rec.invoice_to_org_id := l_ref_line_rec.invoice_to_org_id ;
3716 END IF;
3717
3718 IF (p_x_line_rec.ship_to_contact_id IS NULL OR
3719 p_x_line_rec.ship_to_contact_id = FND_API.G_MISS_NUM) THEN
3720 p_x_line_rec.ship_to_contact_id := l_ref_line_rec.ship_to_contact_id ;
3721 END IF;
3722
3723 IF (p_x_line_rec.intermed_ship_to_org_id IS NULL OR
3724 p_x_line_rec.intermed_ship_to_org_id = FND_API.G_MISS_NUM) THEN
3725 p_x_line_rec.intermed_ship_to_org_id := l_ref_line_rec.intermed_ship_to_org_id ;
3726 END IF;
3727
3728 IF (p_x_line_rec.intermed_ship_to_contact_id IS NULL OR
3729 p_x_line_rec.intermed_ship_to_contact_id = FND_API.G_MISS_NUM) THEN
3730 p_x_line_rec.intermed_ship_to_contact_id
3731 := l_ref_line_rec.intermed_ship_to_contact_id ;
3732 END IF;
3733
3734 IF (p_x_line_rec.deliver_to_contact_id IS NULL OR
3735 p_x_line_rec.deliver_to_contact_id = FND_API.G_MISS_NUM) THEN
3736 p_x_line_rec.deliver_to_contact_id
3737 := l_ref_line_rec.deliver_to_contact_id ;
3738 END IF;
3739
3740 IF (p_x_line_rec.invoice_to_contact_id IS NULL OR
3741 p_x_line_rec.invoice_to_contact_id = FND_API.G_MISS_NUM) THEN
3742 p_x_line_rec.invoice_to_contact_id := l_ref_line_rec.invoice_to_contact_id ;
3743 END IF;
3744
3745 IF (p_x_line_rec.sold_to_org_id IS NULL OR
3746 p_x_line_rec.sold_to_org_id = FND_API.G_MISS_NUM) THEN
3747 p_x_line_rec.sold_to_org_id := l_ref_line_rec.sold_to_org_id ;
3748 ELSE
3749 NULL;
3750 END IF;
3751
3752 IF (p_x_line_rec.ship_from_org_id IS NULL OR
3753 p_x_line_rec.ship_from_org_id = FND_API.G_MISS_NUM) THEN
3754 p_x_line_rec.ship_from_org_id := l_ref_line_rec.ship_from_org_id ;
3755 ELSE
3756 NULL;
3757 END IF;
3758
3759 -- Pack J catchweight
3760 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' AND
3761 --bug3420941
3762 (l_ref_line_rec.source_type_code <> 'EXTERNAL') AND
3763 (p_x_line_rec. ordered_quantity2 IS NULL OR
3764 p_x_line_rec. ordered_quantity2 = FND_API.G_MISS_NUM) AND
3765 (p_x_line_rec. ordered_quantity_uom2 IS NULL OR
3766 --p_x_line_rec. ordered_quantity_uom2 = FND_API.G_MISS_NUM) THEN -- Deleted for Bug# 6521073
3767 p_x_line_rec. ordered_quantity_uom2 = FND_API.G_MISS_CHAR) THEN -- Added for Bug# 6521073
3768
3769 IF (p_x_line_rec.inventory_item_id IS NOT NULL AND
3770 p_x_line_rec.inventory_item_id <> FND_API.G_MISS_NUM) AND
3771 (p_x_line_rec.ship_from_org_id IS NOT NULL AND
3772 p_x_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM) THEN
3773 x_item_rec := OE_Order_Cache.Load_Item (p_x_line_rec.inventory_item_id
3774 ,p_x_line_rec.ship_from_org_id);
3775 -- IF x_item_rec.ont_pricing_qty_source = 1 THEN INVCONV
3776 IF x_item_rec.ont_pricing_qty_source = 'S' THEN -- INVCONV
3777 -- x_item_rec.tracking_quantity_ind = 'P' AND -- INVCONV - TAKE OUT AS OPENED UP TO ANY ITEM AND ORG
3778 -- x_item_rec.wms_enabled_flag = 'Y' THEN
3779 IF l_debug_level > 0 THEN
3780 oe_debug_pub.add( 'Discrete Catchweight enabled. l_ref_line_rec.shipped_quantity2: '|| l_ref_line_rec.shipped_quantity2||
3781 ': l_ref_line_rec.ordered_quantity:'|| l_ref_line_rec.ordered_quantity||': l_ref_line_rec.pricing_quantity_uom:'|| l_ref_line_rec.pricing_quantity_uom);
3782 END IF;
3783 p_x_line_rec.ordered_quantity2 := l_ref_line_rec.shipped_quantity2/ l_ref_line_rec.ordered_quantity * p_x_line_rec.ordered_quantity;
3784 p_x_line_rec.ordered_quantity_uom2 := x_item_rec.secondary_uom_code;
3785 IF l_ref_line_rec.pricing_quantity_uom = l_ref_line_rec.ordered_quantity_uom2 THEN
3786 p_x_line_rec.pricing_quantity := p_x_line_rec.ordered_quantity2;
3787 ELSE
3788 p_x_line_rec.pricing_quantity := OE_Order_Misc_Util.convert_uom(
3789 p_x_line_rec.inventory_item_id,
3790 p_x_line_rec.ordered_quantity_uom2,
3791 p_x_line_rec.pricing_quantity_uom,
3792 p_x_line_rec.ordered_quantity2
3793 );
3794 IF l_debug_level > 0 THEN
3795 oe_debug_pub.add( 'p_x_line_rec.pricing_quantity:'|| p_x_line_rec.pricing_quantity);
3796 END IF;
3797 END IF; -- end check for pricing uom, shipping uom2
3798 END IF; -- check for discrete catchweight
3799 END IF; -- end checks for item org existence
3800 END IF; -- end checks for qty2/uom2 existence
3801 -- Pack J catchweight
3802
3803 IF (p_x_line_rec.ship_to_org_id IS NULL OR
3804 p_x_line_rec.ship_to_org_id = FND_API.G_MISS_NUM) THEN
3805 p_x_line_rec.ship_to_org_id := l_ref_line_rec.ship_to_org_id ;
3806 ELSE
3807 NULL;
3808 END IF;
3809
3810 IF (p_x_line_rec.deliver_to_org_id IS NULL OR
3811 p_x_line_rec.deliver_to_org_id = FND_API.G_MISS_NUM) THEN
3812 p_x_line_rec.deliver_to_org_id := l_ref_line_rec.deliver_to_org_id;
3813 ELSE
3814 NULL;
3815 END IF;
3816
3817
3818 IF (p_x_line_rec.project_id IS NULL OR
3819 p_x_line_rec.project_id = FND_API.G_MISS_NUM) THEN
3820 p_x_line_rec.project_id := l_ref_line_rec.project_id;
3821 END IF;
3822
3823 IF (p_x_line_rec.task_id IS NULL OR
3824 p_x_line_rec.task_id = FND_API.G_MISS_NUM) THEN
3825 p_x_line_rec.task_id := l_ref_line_rec.task_id;
3826 END IF;
3827
3828 IF (p_x_line_rec.end_item_unit_number IS NULL OR
3829 p_x_line_rec.end_item_unit_number = FND_API.G_MISS_CHAR) THEN
3830 p_x_line_rec.end_item_unit_number := l_ref_line_rec.end_item_unit_number;
3831 END IF;
3832
3833 /* Added for the bug fix 1720066 */
3834 IF (p_x_line_rec.shippable_flag IS NULL OR
3835 p_x_line_rec.shippable_flag = FND_API.G_MISS_CHAR)
3836 THEN
3837 p_x_line_rec.shippable_flag := l_ref_line_rec.shippable_flag;
3838 END IF;
3839
3840 -- bug 2509121
3841 IF (p_x_line_rec.user_item_description IS NULL OR
3842 p_x_line_rec.user_item_description = FND_API.G_MISS_CHAR)
3843 THEN
3844 p_x_line_rec.user_item_description := l_ref_line_rec.user_item_description;
3845 END IF;
3846
3847
3848 /* Fix Bug 2429989: Returning Revision Controlled Items */
3849
3850 IF p_x_line_rec.inventory_item_id IS NOT NULL AND
3851 p_x_line_rec.inventory_item_id <> FND_API.G_MISS_NUM THEN
3852
3853 Begin
3854 select decode(revision_qty_control_code, 2, 'Y', 'N')
3855 into l_revision_controlled
3856 from mtl_system_items
3857 where inventory_item_id = p_x_line_rec.inventory_item_id
3858 and organization_id = OE_Sys_Parameters.VALUE_WNPS('MASTER_ORGANIZATION_ID');
3859 Exception
3860 When NO_DATA_FOUND Then
3861 l_revision_controlled := 'N';
3862 End;
3863
3864 IF l_revision_controlled = 'Y' THEN
3865
3866 IF l_debug_level > 0 THEN
3867 oe_debug_pub.add( 'THE ITEM IS REVISION CONTROLLED' ) ;
3868 END IF;
3869
3870 Begin
3871 select distinct revision
3872 into p_x_line_rec.item_revision
3873 from mtl_material_transactions
3874 where transaction_source_type_id = 2
3875 and transaction_type_id = 33
3876 and trx_source_line_id = p_x_line_rec.reference_line_id
3877 and inventory_item_id = p_x_line_rec.inventory_item_id
3878 and organization_id = (select ship_from_org_id
3879 from oe_order_lines_all
3880 where line_id = p_x_line_rec.reference_line_id);
3881 Exception
3882 When No_Data_Found Then
3883 Null;
3884 When Too_Many_Rows Then
3885 p_x_line_rec.item_revision := NULL;
3886 End;
3887 IF l_debug_level > 0 THEN
3888 oe_debug_pub.add( 'THE ITEM REVISION IS: '|| P_X_LINE_REC.ITEM_REVISION ) ;
3889 END IF;
3890 END IF;
3891
3892 END IF;
3893
3894 END IF;
3895
3896 -- Bug 2849656 => Copy blanket fields from referenced order line
3897 -- to RMA line.
3898
3899 IF (p_x_line_rec.blanket_number IS NULL OR
3900 p_x_line_rec.blanket_number = FND_API.G_MISS_NUM) THEN
3901 p_x_line_rec.blanket_number := l_ref_line_rec.blanket_number;
3902 END IF;
3903
3904 IF (p_x_line_rec.blanket_line_number IS NULL OR
3905 p_x_line_rec.blanket_line_number = FND_API.G_MISS_NUM) THEN
3906 p_x_line_rec.blanket_line_number := l_ref_line_rec.blanket_line_number;
3907 END IF;
3908
3909 -- End fix for Bug 2849656
3910
3911 -- Override List Price
3912 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
3913 IF OE_ORDER_COPY_UTIL.G_LINE_PRICE_MODE = OE_ORDER_COPY_UTIL.G_CPY_REPRICE THEN
3914 p_x_line_rec.original_list_price := NULL;
3915 ELSE
3916 IF (p_x_line_rec.original_list_price IS NULL OR
3917 p_x_line_rec.original_list_price = FND_API.G_MISS_NUM) THEN
3918 p_x_line_rec.original_list_price := l_ref_line_rec.original_list_price;
3919 END IF;
3920 END IF;
3921
3922 END IF;
3923 -- Override List Price
3924
3925 IF l_debug_level > 0 THEN
3926 oe_debug_pub.add( 'EXITING ATTRIBUTES_FROM_ORDER_LINE' , 1 ) ;
3927 END IF;
3928
3929 END Attributes_From_Order_Line;
3930
3931 Procedure Return_Attributes
3932 ( p_x_line_rec IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type
3933 , p_old_line_rec IN OE_Order_PUB.Line_Rec_Type
3934 )
3935 IS
3936 l_defaulting_invoice_line_id NUMBER := NULL;
3937 l_defaulting_order_line_id NUMBER := NULL;
3938 l_line_rec oe_order_pub.line_rec_type;
3939 --
3940 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3941 l_return_status VARCHAR2(1);
3942 l_sold_to_org_id NUMBER;
3943 l_currency_code VARCHAR2(15);
3944
3945 l_overship_invoice_basis VARCHAR2(30):= NULL; -- bug#6617423
3946
3947 BEGIN
3948
3949 IF l_debug_level > 0 THEN
3950 oe_debug_pub.add( 'INSIDE DEFAULTING RMA' , 1 ) ;
3951 oe_debug_pub.add( 'RMA OPERATION IS'||P_X_LINE_REC.OPERATION , 1 ) ;
3952 END IF;
3953 IF NOT OE_GLOBALS.Equal(p_x_line_rec.return_attribute2,
3954 p_old_line_rec.return_attribute2)
3955 THEN
3956 IF l_debug_level > 0 THEN
3957 oe_debug_pub.add( 'CLEARING RMA_ATTRIBUTES' , 1 ) ;
3958 oe_debug_pub.add( ' OLD P_OLD_LINE_REC.RETURN_CONTEXT = '||P_OLD_LINE_REC.RETURN_CONTEXT , 1 ) ;
3959 oe_debug_pub.add( ' OLD P_OLD_LINE_REC.RETURN_ATTRIBUTE1 = '||P_OLD_LINE_REC.RETURN_ATTRIBUTE1 , 1 ) ;
3960 oe_debug_pub.add( ' OLD P_OLD_LINE_REC.RETURN_ATTRIBUTE2 = '||P_OLD_LINE_REC.RETURN_ATTRIBUTE2 , 1 ) ;
3961 oe_debug_pub.add( ' OLD P_OLD_LINE_REC.RETURN_ATTRIBUTE3 = '||P_OLD_LINE_REC.RETURN_ATTRIBUTE3 , 1 ) ;
3962
3963 oe_debug_pub.add( ' NEW P_X_LINE_REC.RETURN_CONTEXT = '||P_X_LINE_REC.RETURN_CONTEXT , 1 ) ;
3964 oe_debug_pub.add( ' NEW P_X_LINE_REC.RETURN_ATTRIBUTE1 = '||P_X_LINE_REC.RETURN_ATTRIBUTE1 , 1 ) ;
3965 oe_debug_pub.add( ' NEW P_X_LINE_REC.RETURN_ATTRIBUTE2 = '||P_X_LINE_REC.RETURN_ATTRIBUTE2 , 1 ) ;
3966 oe_debug_pub.add( ' NEW P_X_LINE_REC.RETURN_ATTRIBUTE2 = '||P_X_LINE_REC.RETURN_ATTRIBUTE3 , 1 ) ;
3967
3968 oe_debug_pub.add( ' NEW p_x_line_rec.source_document_id = '|| p_x_line_rec.source_document_id , 1 ) ;
3969 oe_debug_pub.add( ' NEW p_x_line_rec.source_document_line_id = '|| p_x_line_rec.source_document_line_id , 1 ) ;
3970 oe_debug_pub.add( ' NEW p_x_line_rec.orig_sys_document_ref = '|| p_x_line_rec.orig_sys_document_ref , 1 ) ;
3971 oe_debug_pub.add( ' NEW p_x_line_rec.orig_sys_line_ref = '||p_x_line_rec.orig_sys_line_ref , 1 ) ;
3972 END IF;
3973
3974 -- Backup the passed in record.
3975 l_line_rec := p_x_line_rec;
3976
3977 -- Set the line rec to MISSING so that all attributes are redefaulted
3978 p_x_line_rec := OE_Order_PUB.G_MISS_LINE_REC;
3979
3980 -- Reset the pre-defaulted values from backup
3981 p_x_line_rec.line_id := l_line_rec.line_id;
3982 p_x_line_rec.customer_line_number :=l_line_rec.customer_line_number; --added for bug 5569557
3983 p_x_line_rec.ship_from_org_id := l_line_rec.ship_from_org_id; --Added for bug 5649747
3984 p_x_line_rec.line_number := l_line_rec.line_number;
3985 p_x_line_rec.header_id := l_line_rec.header_id;
3986 p_x_line_rec.item_type_code := l_line_rec.item_type_code;
3987 p_x_line_rec.line_type_id := l_line_rec.line_type_id;
3988 p_x_line_rec.line_category_code := l_line_rec.line_category_code;
3989 p_x_line_rec.return_reason_code := l_line_rec.return_reason_code;
3990 p_x_line_rec.org_id := l_line_rec.org_id;
3991 p_x_line_rec.sold_to_org_id := l_line_rec.sold_to_org_id;
3992 p_x_line_rec.CUST_PO_NUMBER := l_line_rec.CUST_PO_NUMBER;
3993 p_x_line_rec.return_context := l_line_rec.return_context;
3994 p_x_line_rec.return_attribute1 := l_line_rec.return_attribute1;
3995 p_x_line_rec.return_attribute2 := l_line_rec.return_attribute2;
3996 p_x_line_rec.shipment_number := l_line_rec.shipment_number;
3997 p_x_line_rec.creation_date := l_line_rec.creation_date;
3998 p_x_line_rec.created_by := l_line_rec.created_by;
3999 p_x_line_rec.operation := l_line_rec.operation;
4000 p_x_line_rec.db_flag := l_line_rec.db_flag;
4001 p_x_line_rec.source_document_type_id :=
4002 l_line_rec.source_document_type_id;
4003 p_x_line_rec.context := l_line_rec.context; --Bug#7380336
4004 /*Bug2816576*/
4005 p_x_line_rec.source_document_id := l_line_rec.source_document_id;
4006 p_x_line_rec.source_document_line_id := l_line_rec.source_document_line_id;
4007 /*Bug2816576*/
4008 p_x_line_rec.orig_sys_document_ref := l_line_rec.orig_sys_document_ref;
4009 p_x_line_rec.orig_sys_line_ref := l_line_rec.orig_sys_line_ref;
4010 p_x_line_rec.orig_sys_shipment_ref := l_line_rec.orig_sys_shipment_ref;
4011 p_x_line_rec.change_sequence := l_line_rec.change_sequence;
4012
4013 /* Fix Bug # 2605825:
4014 ** Need to preserve Booked Flag and Flow Status Code, which might have
4015 ** already been defaulted based on the header level booking status.
4016 */
4017 p_x_line_rec.booked_flag := l_line_rec.booked_flag;
4018 p_x_line_rec.flow_status_code := l_line_rec.flow_status_code;
4019
4020 /* Bug # 2834750 : Need to preserve Fulfillment Set */
4021 p_x_line_rec.fulfillment_set := l_line_rec.fulfillment_set;
4022
4023 /* Need to preserve the sold_from_org_id */
4024 p_x_line_rec.sold_from_org_id := l_line_rec.sold_from_org_id;
4025 /* Need to preserve request_date */
4026 p_x_line_rec.request_date := l_line_rec.request_date;
4027
4028 -- Quoting Changes Start
4029 -- Copy transaction phase from order header to return line
4030 OE_Order_Cache.Load_Order_Header(p_x_line_rec.header_id);
4031 p_x_line_rec.transaction_phase_code :=
4032 OE_Order_Cache.g_header_rec.transaction_phase_code;
4033 -- Quoting Changes End
4034
4035 /* Fix for the bug 1777243
4036 ** Copy the Ordered Quantity from the set value in
4037 ** Insert_Rma_Options_Included and derive the pricing quantity
4038 */
4039
4040
4041 IF l_debug_level > 0 THEN
4042 oe_debug_pub.add( ' l_line_rec.ordered_quantity = '||l_line_rec.ordered_quantity,5 ) ;
4043 oe_debug_pub.add( ' l_line_rec.invoiced_quantity = '||l_line_rec.invoiced_quantity,5 ) ;
4044 oe_debug_pub.add( ' p_x_line_rec.org_id = '||p_x_line_rec.org_id ,5) ;
4045 oe_debug_pub.add( ' p_x_line_rec.ordered_quantity = '|| p_x_line_rec.ordered_quantity,5 ) ;
4046 END IF;
4047
4048
4049 IF OE_GLOBALS.G_RETURN_CHILDREN_MODE = 'Y' OR NOT (OE_GLOBALS.G_UI_FLAG) THEN
4050 --p_x_line_rec.ordered_quantity := l_line_rec.ordered_quantity; -- bug# 6617423
4051
4052 -- bug# 6617423 : start
4053 oe_debug_pub.add( ' <in Return_Attributes> p_x_line_rec.org_id = '|| p_x_line_rec.org_id , 5 ) ;
4054 IF p_x_line_rec.org_id = FND_API.G_MISS_NUM THEN
4055 l_overship_invoice_basis := oe_sys_parameters.value('OE_OVERSHIP_INVOICE_BASIS',NULL);
4056 ELSE
4057 l_overship_invoice_basis := oe_sys_parameters.value('OE_OVERSHIP_INVOICE_BASIS',p_x_line_rec.org_id);
4058 END IF;
4059 oe_debug_pub.add( ' <in Return_Attributes> l_overship_invoice_basis = '|| l_overship_invoice_basis ,5) ;
4060
4061 IF l_overship_invoice_basis = 'SHIPPED' then
4062 p_x_line_rec.ordered_quantity := nvl(l_line_rec.shipped_quantity, l_line_rec.ordered_quantity);
4063 ELSE
4064 p_x_line_rec.ordered_quantity := l_line_rec.ordered_quantity;
4065 end if;
4066 oe_debug_pub.add( ' p_x_line_rec.ordered_quantity = '|| p_x_line_rec.ordered_quantity , 5 ) ;
4067 -- bug# 6617423 : End
4068
4069 p_x_line_rec.order_quantity_uom := l_line_rec.order_quantity_uom;
4070 p_x_line_rec.pricing_quantity := l_line_rec.pricing_quantity;
4071 p_x_line_rec.pricing_quantity_uom := l_line_rec.pricing_quantity_uom;
4072 IF l_debug_level > 0 THEN
4073 oe_debug_pub.add( 'THE ORDERED QTY IS SET' ) ;
4074 END IF;
4075 END IF;
4076
4077 IF p_x_line_rec.source_document_type_id = 2
4078 THEN
4079 p_x_line_rec.order_source_id := 2;
4080 END IF;
4081
4082 IF p_x_line_rec.source_document_type_id = 2 OR
4083 OE_GLOBALS.G_RETURN_CHILDREN_MODE = 'Y'
4084 THEN
4085 p_x_line_rec.calculate_price_flag := l_line_rec.calculate_price_flag;
4086 p_x_line_rec.pricing_date := l_line_rec.pricing_date;
4087 IF l_debug_level > 0 THEN
4088 oe_debug_pub.add( 'CALCULATE PRICE FLAG : '||P_X_LINE_REC.CALCULATE_PRICE_FLAG ) ;
4089 oe_debug_pub.add( 'PRICING DATE : '||P_X_LINE_REC.PRICING_DATE ) ;
4090 END IF;
4091
4092 END IF;
4093
4094 -- Fix for the issue 2347377. Retain the flex values if sent in
4095 -- by NON-UI call like (OrderImport) / COPY.
4096
4097 IF NOT (OE_GLOBALS.G_UI_FLAG)
4098 THEN
4099 IF l_debug_level > 0 THEN
4100 oe_debug_pub.add('Context is' ||P_X_LINE_REC.context);
4101 oe_debug_pub.add('Attribute 1 is : '||P_X_LINE_REC.attribute1);
4102 END IF;
4103
4104 -- Retain the Line DFF info
4105 p_x_line_rec.context := l_line_rec.context;
4106 p_x_line_rec.attribute1 := l_line_rec.attribute1;
4107 p_x_line_rec.attribute2 := l_line_rec.attribute2;
4108 p_x_line_rec.attribute3 := l_line_rec.attribute3;
4109 p_x_line_rec.attribute4 := l_line_rec.attribute4;
4110 p_x_line_rec.attribute5 := l_line_rec.attribute5;
4111 p_x_line_rec.attribute6 := l_line_rec.attribute6;
4112 p_x_line_rec.attribute7 := l_line_rec.attribute7;
4113 p_x_line_rec.attribute8 := l_line_rec.attribute8;
4114 p_x_line_rec.attribute9 := l_line_rec.attribute9;
4115 p_x_line_rec.attribute10 := l_line_rec.attribute10;
4116 p_x_line_rec.attribute11 := l_line_rec.attribute11;
4117 p_x_line_rec.attribute12 := l_line_rec.attribute12;
4118 p_x_line_rec.attribute13 := l_line_rec.attribute13;
4119 p_x_line_rec.attribute14 := l_line_rec.attribute14;
4120 p_x_line_rec.attribute15 := l_line_rec.attribute15;
4121 p_x_line_rec.attribute16 := l_line_rec.attribute16;
4122 p_x_line_rec.attribute17 := l_line_rec.attribute17;
4123 p_x_line_rec.attribute18 := l_line_rec.attribute18;
4124 p_x_line_rec.attribute19 := l_line_rec.attribute19;
4125 p_x_line_rec.attribute20 := l_line_rec.attribute20;
4126
4127 -- Retain the Global DFF Info
4128 p_x_line_rec.global_attribute_category
4129 := l_line_rec.global_attribute_category;
4130 p_x_line_rec.global_attribute1 := l_line_rec.global_attribute1;
4131 p_x_line_rec.global_attribute2 := l_line_rec.global_attribute2;
4132 p_x_line_rec.global_attribute3 := l_line_rec.global_attribute3;
4133 p_x_line_rec.global_attribute4 := l_line_rec.global_attribute4;
4134 p_x_line_rec.global_attribute5 := l_line_rec.global_attribute5;
4135 p_x_line_rec.global_attribute6 := l_line_rec.global_attribute6;
4136 p_x_line_rec.global_attribute7 := l_line_rec.global_attribute7;
4137 p_x_line_rec.global_attribute8 := l_line_rec.global_attribute8;
4138 p_x_line_rec.global_attribute9 := l_line_rec.global_attribute9;
4139 p_x_line_rec.global_attribute10 := l_line_rec.global_attribute10;
4140 p_x_line_rec.global_attribute11 := l_line_rec.global_attribute11;
4141 p_x_line_rec.global_attribute12 := l_line_rec.global_attribute12;
4142 p_x_line_rec.global_attribute13 := l_line_rec.global_attribute13;
4143 p_x_line_rec.global_attribute14 := l_line_rec.global_attribute14;
4144 p_x_line_rec.global_attribute15 := l_line_rec.global_attribute15;
4145 p_x_line_rec.global_attribute16 := l_line_rec.global_attribute16;
4146 p_x_line_rec.global_attribute17 := l_line_rec.global_attribute17;
4147 p_x_line_rec.global_attribute18 := l_line_rec.global_attribute18;
4148 p_x_line_rec.global_attribute19 := l_line_rec.global_attribute19;
4149 p_x_line_rec.global_attribute20 := l_line_rec.global_attribute20;
4150
4151 -- Retain the Industry DFF Info
4152 p_x_line_rec.industry_context := l_line_rec.industry_context;
4153 p_x_line_rec.industry_attribute1 := l_line_rec.industry_attribute1;
4154 p_x_line_rec.industry_attribute2 := l_line_rec.industry_attribute2;
4155 p_x_line_rec.industry_attribute3 := l_line_rec.industry_attribute3;
4156 p_x_line_rec.industry_attribute4 := l_line_rec.industry_attribute4;
4157 p_x_line_rec.industry_attribute5 := l_line_rec.industry_attribute5;
4158 p_x_line_rec.industry_attribute6 := l_line_rec.industry_attribute6;
4159 p_x_line_rec.industry_attribute7 := l_line_rec.industry_attribute7;
4160 p_x_line_rec.industry_attribute8 := l_line_rec.industry_attribute8;
4161 p_x_line_rec.industry_attribute9 := l_line_rec.industry_attribute9;
4162 p_x_line_rec.industry_attribute10 := l_line_rec.industry_attribute10;
4163 --Begin of Bug Fix 6626305
4164 p_x_line_rec.industry_attribute11 := l_line_rec.industry_attribute11;
4165 p_x_line_rec.industry_attribute12 := l_line_rec.industry_attribute12;
4166 p_x_line_rec.industry_attribute13 := l_line_rec.industry_attribute13;
4167 p_x_line_rec.industry_attribute14 := l_line_rec.industry_attribute14;
4168 p_x_line_rec.industry_attribute15 := l_line_rec.industry_attribute15;
4169 p_x_line_rec.industry_attribute16 := l_line_rec.industry_attribute16;
4170 p_x_line_rec.industry_attribute17 := l_line_rec.industry_attribute17;
4171 p_x_line_rec.industry_attribute18 := l_line_rec.industry_attribute18;
4172 p_x_line_rec.industry_attribute19 := l_line_rec.industry_attribute19;
4173 p_x_line_rec.industry_attribute20 := l_line_rec.industry_attribute20;
4174 p_x_line_rec.industry_attribute21 := l_line_rec.industry_attribute21;
4175 p_x_line_rec.industry_attribute22 := l_line_rec.industry_attribute22;
4176 p_x_line_rec.industry_attribute23 := l_line_rec.industry_attribute23;
4177 p_x_line_rec.industry_attribute24 := l_line_rec.industry_attribute24;
4178 p_x_line_rec.industry_attribute25 := l_line_rec.industry_attribute25;
4179 p_x_line_rec.industry_attribute26 := l_line_rec.industry_attribute26;
4180 p_x_line_rec.industry_attribute27 := l_line_rec.industry_attribute27;
4181 p_x_line_rec.industry_attribute28 := l_line_rec.industry_attribute28;
4182 p_x_line_rec.industry_attribute29 := l_line_rec.industry_attribute29;
4183 p_x_line_rec.industry_attribute30 := l_line_rec.industry_attribute30;
4184
4185
4186 p_x_line_rec.return_attribute3 := l_line_rec.return_attribute3;
4187 p_x_line_rec.return_attribute4 := l_line_rec.return_attribute4;
4188 p_x_line_rec.return_attribute5 := l_line_rec.return_attribute5;
4189 p_x_line_rec.return_attribute6 := l_line_rec.return_attribute6;
4190 p_x_line_rec.return_attribute7 := l_line_rec.return_attribute7;
4191 p_x_line_rec.return_attribute8 := l_line_rec.return_attribute8;
4192 p_x_line_rec.return_attribute9 := l_line_rec.return_attribute9;
4193 p_x_line_rec.return_attribute10 := l_line_rec.return_attribute10;
4194 p_x_line_rec.return_attribute11 := l_line_rec.return_attribute11;
4195 p_x_line_rec.return_attribute12 := l_line_rec.return_attribute12;
4196 p_x_line_rec.return_attribute13 := l_line_rec.return_attribute13;
4197 p_x_line_rec.return_attribute14 := l_line_rec.return_attribute14;
4198 p_x_line_rec.return_attribute15 := l_line_rec.return_attribute15;
4199 --End of Bug Fix 6626305
4200
4201
4202 -- Retain the Trading Partner DFF Info
4203 p_x_line_rec.tp_context := l_line_rec.tp_context;
4204 p_x_line_rec.tp_attribute1 := l_line_rec.tp_attribute1;
4205 p_x_line_rec.tp_attribute2 := l_line_rec.tp_attribute2;
4206 p_x_line_rec.tp_attribute3 := l_line_rec.tp_attribute3;
4207 p_x_line_rec.tp_attribute4 := l_line_rec.tp_attribute4;
4208 p_x_line_rec.tp_attribute5 := l_line_rec.tp_attribute5;
4209 p_x_line_rec.tp_attribute6 := l_line_rec.tp_attribute6;
4210 p_x_line_rec.tp_attribute7 := l_line_rec.tp_attribute7;
4211 p_x_line_rec.tp_attribute8 := l_line_rec.tp_attribute8;
4212 p_x_line_rec.tp_attribute9 := l_line_rec.tp_attribute9;
4213 p_x_line_rec.tp_attribute10 := l_line_rec.tp_attribute10;
4214 p_x_line_rec.tp_attribute11 := l_line_rec.tp_attribute11;
4215 p_x_line_rec.tp_attribute12 := l_line_rec.tp_attribute12;
4216 p_x_line_rec.tp_attribute13 := l_line_rec.tp_attribute13;
4217 p_x_line_rec.tp_attribute14 := l_line_rec.tp_attribute14;
4218 p_x_line_rec.tp_attribute15 := l_line_rec.tp_attribute15;
4219
4220 END IF;
4221
4222 END IF;
4223
4224 IF p_x_line_rec.return_attribute2 is NOT NULL AND
4225 p_x_line_rec.return_attribute2 <> FND_API.G_MISS_CHAR
4226 THEN
4227
4228 IF l_debug_level > 0 THEN
4229 oe_debug_pub.add( 'IN DEFAULT RETURN ATTRIBUTES' , 1 ) ;
4230 END IF;
4231
4232 -- reprice when pricing attributes change
4233 -- also if the flag is passed in, keep the original flag
4234 IF (p_x_line_rec.calculate_price_flag IS NULL OR
4235 p_x_line_rec.calculate_price_flag = FND_API.G_MISS_CHAR)
4236 THEN
4237 IF l_debug_level > 0 THEN
4238 oe_debug_pub.add( 'SETTING CALCULATE PRICE FLAG' , 1 ) ;
4239 END IF;
4240 p_x_line_rec.calculate_price_flag := 'N';
4241
4242 END IF;
4243
4244 IF l_debug_level > 0 THEN
4245 oe_debug_pub.add( 'IN DEFAULT RETURN ATTRIBUTES -1' , 1 ) ;
4246 END IF;
4247 IF NOT OE_GLOBALS.Equal(p_x_line_rec.return_attribute2,
4248 p_old_line_rec.return_attribute2)
4249 THEN
4250
4251 -- Get the values of l_currency_code and l_sold_to_org_id
4252 OE_ORDER_CACHE.Load_Order_Header(p_x_line_rec.header_id);
4253 l_sold_to_org_id := OE_ORDER_CACHE.g_header_rec.SOLD_TO_ORG_ID;
4254 l_currency_code := OE_ORDER_CACHE.g_header_rec.transactional_curr_code;
4255
4256 IF l_debug_level > 0 THEN
4257 oe_debug_pub.add( 'IN DEFAULT RETURN ATTRIBUTES 0' , 1 ) ;
4258 oe_debug_pub.add('Sold To Org Id IS '|| l_sold_to_org_id , 1 ) ;
4259 oe_debug_pub.add('Header Currency IS '||l_currency_code , 1 ) ;
4260 END IF;
4261 -- default attributes from invoice line
4262 l_defaulting_invoice_line_id := Get_Def_Invoice_Line_Int
4263 (p_x_line_rec.return_context,
4264 p_x_line_rec.return_attribute1,
4265 p_x_line_rec.return_attribute2,
4266 l_sold_to_org_id,
4267 l_currency_code,
4268 l_defaulting_order_line_id);
4269 IF l_debug_level > 0 THEN
4270 oe_debug_pub.add( 'IN DEFAULT RETURN ATTRIBUTES 1' , 1 ) ;
4271 END IF;
4272
4273 -- Since only one serial number can be entered from the reference
4274 -- set the Ordered_quantity to 1.
4275
4276 /*
4277 ** Fix for Bug # 1686920
4278 ** Commented following as it's being taken care of at a later stage.
4279 IF p_x_line_rec.return_context = 'SERIAL' THEN
4280 p_x_line_rec.ordered_quantity := 1;
4281 END IF;
4282 */
4283
4284 IF l_defaulting_invoice_line_id IS NOT NULL THEN
4285 Attributes_From_Invoice_Line
4286 (p_invoice_line_id => l_defaulting_invoice_line_id,
4287 p_x_line_rec => p_x_line_rec);
4288 END IF;
4289
4290 IF l_debug_level > 0 THEN
4291 oe_debug_pub.add( 'IN DEFAULT RETURN ATTRIBUTES 2' , 1 ) ;
4292 END IF;
4293
4294 Attributes_From_Order_Line
4295 (p_order_line_id => l_defaulting_order_line_id,
4296 p_x_line_rec => p_x_line_rec);
4297
4298 IF l_debug_level > 0 THEN
4299 oe_debug_pub.add( 'IN DEFAULT RETURN ATTRIBUTES 4' , 1 ) ;
4300 END IF;
4301
4302 -- Clear attributes that do not make sense to returns
4303 p_x_line_rec.shipped_quantity := NULL;
4304 p_x_line_rec.reserved_quantity := NULL;
4305 p_x_line_rec.shipping_quantity := NULL;
4306 p_x_line_rec.shipping_quantity_uom := NULL;
4307
4308 -- INVCONV
4309 p_x_line_rec.shipped_quantity2 := NULL;
4310 p_x_line_rec.reserved_quantity2 := NULL;
4311 p_x_line_rec.shipping_quantity2 := NULL;
4312 p_x_line_rec.shipping_quantity_uom2 := NULL;
4313 p_x_line_rec.fulfilled_quantity2 := NULL;
4314
4315 /* Need to copy shippable_flag from the reference line */
4316 --p_x_line_rec.shippable_flag := NULL;
4317 p_x_line_rec.actual_shipment_date := NULL;
4318 -- source type code for RMA lines will always be set to internal. If
4319 -- in future we plan to change the design then please comment out the
4320 -- following code.
4321 p_x_line_rec.source_type_code := OE_GLOBALS.G_SOURCE_INTERNAL;
4322
4323 p_x_line_rec.over_ship_reason_code := NULL;
4324 p_x_line_rec.over_ship_resolved_flag := NULL;
4325 p_x_line_rec.shipping_interfaced_flag := NULL;
4326 p_x_line_rec.top_model_line_id := NULL;
4327 -- Commented following stmt to fix Bug # 1580182.
4328 -- p_x_line_rec.booked_flag := 'N';
4329 p_x_line_rec.fulfilled_quantity := NULL;
4330 p_x_line_rec.option_number := NULL;
4331
4332 -- For bug3327250
4333 -- CAll OE_Validate_Line.Attributes
4334 OE_Validate_Line.Attributes(
4335 x_return_status => l_return_status
4336 , p_x_line_rec => p_x_line_rec
4337 , p_validation_level => OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF);
4338
4339 IF l_debug_level > 0 THEN
4340 oe_debug_pub.add( 'THE ORDERED QTY IS '||P_X_LINE_REC.ORDERED_QUANTITY ) ;
4341 oe_debug_pub.add( 'THE PRICING QTY IS '||P_X_LINE_REC.PRICING_QUANTITY ) ;
4342 END IF;
4343 END IF;
4344
4345 END IF;
4346
4347 END Return_Attributes;
4348
4349 -- Procedure Attributes
4350
4351 PROCEDURE Attributes
4352 ( p_x_Line_rec IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type
4353 , p_old_Line_rec IN OE_Order_PUB.Line_Rec_Type
4354 , p_iteration IN NUMBER := 1
4355 )
4356
4357 IS
4358 l_in_old_rec OE_AK_ORDER_LINES_V%ROWTYPE;
4359 l_in_rec OE_AK_ORDER_LINES_V%ROWTYPE;
4360 l_rec OE_AK_ORDER_LINES_V%ROWTYPE;
4361 g_multiple_shipments VARCHAR2(3);
4362 l_set_tolerance_below VARCHAR2(1) := 'N';
4363 l_set_tolerance_above VARCHAR2(1) := 'N';
4364
4365 l_blanket_number NUMBER := NULL;
4366 l_blanket_version_number NUMBER := NULL;
4367 l_blanket_line_number NUMBER := NULL;
4368 l_blanket_request_date DATE;
4369
4370 l_exists VARCHAR2(1);
4371 l_party_type VARCHAR2(30);
4372 --
4373 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4374 --
4375 BEGIN
4376
4377 IF l_debug_level > 0 THEN
4378 oe_debug_pub.add( 'ENTER OE_DEFAULT_LINE.ATTRIBUTES' , 1 ) ;
4379 END IF;
4380 fnd_profile.get('ONT_IMP_MULTIPLE_SHIPMENTS', g_multiple_shipments);
4381 g_multiple_shipments := nvl(g_multiple_shipments, 'NO');
4382
4383 /* IF (p_x_line_rec.operation = oe_globals.g_opr_create and */
4384 IF p_x_line_rec.return_context is NOT NULL AND
4385 p_x_line_rec.return_context <> FND_API.G_MISS_CHAR THEN
4386 Return_Attributes
4387 ( p_x_line_rec => p_x_line_rec
4388 , p_old_line_rec => p_old_line_rec
4389 );
4390 END IF;
4391 g_line_rec := p_x_line_rec;
4392
4393 -- bug 4668200
4394 IF (g_line_rec.header_id IS NOT NULL AND
4395 g_line_rec.header_id <> FND_API.G_MISS_NUM) THEN
4396 Set_Header_Def_Hdlr_Rec (g_line_rec.header_id);
4397 END IF ;
4398 -- end
4399
4400 IF p_x_line_rec.unit_cost = FND_API.G_MISS_NUM THEN
4401 p_x_line_rec.unit_cost := p_old_line_rec.unit_cost;
4402 END IF;
4403
4404 -- For some fields, get hardcoded defaults
4405
4406 -- IMPORTANT: For defaulting to work correctly, these fields should
4407 -- A) Not be dependent on any other field (Refer OEXUDEPB.pls for the
4408 -- list of dependencies)
4409 -- B) Not be enabled for security constraints as there is no security
4410 -- check for these fields from here.
4411
4412 -- ***************IMPORTANT ********************
4413 -- get item_type is dependent on get_top_model
4414 -- get ato_line , get_shippbale etc are dependent on get_item_type
4415 -- please do not changes their sequence.
4416
4417 IF g_line_rec.operation = oe_globals.g_opr_create THEN
4418 g_line_rec.org_id := Get_Org;
4419
4420 -- QUOTING change
4421 -- Initialize flow status to DRAFT for lines in negotiation phase
4422 IF g_line_rec.transaction_phase_code = 'N' THEN
4423 g_line_rec.flow_status_code := 'DRAFT';
4424 END IF;
4425
4426 END IF;
4427
4428 IF g_line_rec.created_by = FND_API.G_MISS_NUM THEN
4429 g_line_rec.created_by := FND_GLOBAL.USER_ID;
4430 END IF;
4431
4432 --key Transaction Dates
4433 IF g_line_rec.creation_date = FND_API.G_MISS_DATE THEN
4434 g_line_rec.creation_date := sysdate;
4435 END IF;
4436 --end
4437
4438 IF g_line_rec.line_id = FND_API.G_MISS_NUM THEN
4439 g_line_rec.line_id := Get_Line;
4440 END IF;
4441 -- Fix for 2362210
4442 IF l_debug_level > 0 THEN
4443 oe_debug_pub.add( 'LINE ID = '||G_LINE_REC.LINE_ID ) ;
4444 oe_debug_pub.add( 'LINE SYS = '||G_LINE_REC.ORIG_SYS_LINE_REF ) ;
4445 oe_debug_pub.add( 'SOURCE_DOCUMENT_ID = '|| G_LINE_REC.SOURCE_DOCUMENT_ID ) ;
4446 END IF;
4447 IF ((g_line_rec.orig_sys_line_ref = FND_API.G_MISS_CHAR
4448 OR g_line_rec.orig_sys_line_ref IS NULL)
4449 AND
4450 nvl(g_line_rec.source_document_id,-999) <> 10) THEN
4451 g_line_rec.orig_sys_line_ref := 'OE_ORDER_LINES_ALL'||g_line_rec.line_id;
4452 END IF;
4453
4454 --{ bug3664313 FP start: added NULL check
4455 IF (g_line_rec.orig_sys_document_ref = FND_API.G_MISS_CHAR OR
4456 g_line_rec.orig_sys_document_ref IS NULL) THEN
4457 g_line_rec.orig_sys_document_ref := Get_Orig_Sys_Doc_Ref;
4458 END IF;
4459
4460 IF g_line_rec.line_category_code = FND_API.G_MISS_CHAR THEN
4461 g_line_rec.line_category_code :=
4462 Get_line_category(g_line_rec,p_old_line_rec);
4463 IF l_debug_level > 0 THEN
4464 oe_debug_pub.add( 'AFTER CALLING LINE CATEGORY1' || G_LINE_REC.LINE_CATEGORY_CODE ) ;
4465 END IF;
4466
4467 /* Added for the BUG #3257965.
4468 For update operation need to raise an error for line_category_code. */
4469
4470 ELSIF g_line_rec.operation = oe_globals.g_opr_update
4471 AND NOT OE_GLOBALS.EQUAL(g_line_rec.line_category_code
4472 ,p_old_line_rec.line_category_code)
4473 THEN
4474 --3365705For retrobill we change the order type from return to order
4475 -- and the exception shouldn't be raised
4476
4477 IF (
4478 g_line_rec.order_source_id = 27 AND
4479 g_line_rec.retrobill_request_id is NOT NULL ) THEN
4480 null;
4481 ELSE
4482 FND_MESSAGE.SET_NAME('ONT', 'OE_LINE_CAT_CONST');
4483 OE_MSG_PUB.ADD;
4484 IF l_debug_level > 0 THEN
4485 oe_debug_pub.add( 'LINE CATEGORY CONSTRINED' ) ;
4486 END IF;
4487 RAISE FND_API.G_EXC_ERROR;
4488 END IF;
4489 END IF;
4490
4491 -- BUG 3646340: Return_reason is a defaultable field and it needs to be
4492 -- defaulted if the line category changes to RETURN.
4493
4494 IF g_line_rec.operation = oe_globals.g_opr_create AND
4495 g_line_rec.line_category_code = 'RETURN' AND
4496 g_line_rec.return_reason_code IS NULL AND
4497 NOT OE_GLOBALS.Equal(g_line_rec.line_category_code,
4498 p_old_line_rec.line_category_code)
4499 THEN
4500 IF l_debug_level > 0 THEN
4501 oe_debug_pub.add('LINE CATEGORY CHANGED - REASON set to miss') ;
4502 END IF;
4503 g_line_rec.return_reason_code := FND_API.G_MISS_CHAR;
4504 END IF;
4505
4506 IF g_line_rec.top_model_line_id = FND_API.G_MISS_NUM OR
4507 NOT OE_GLOBALS.Equal(g_line_rec.line_category_code,
4508 p_old_line_rec.line_category_code)
4509 THEN
4510 g_line_rec.top_model_line_id := Get_Top_Model_Line;
4511 END IF;
4512 -- 2605065
4513 IF g_line_rec.top_model_line_id IS NOT NULL THEN
4514 OE_Order_Cache.clear_top_model_line(g_line_rec.top_model_line_id);
4515 END IF;
4516
4517 IF l_debug_level > 0 THEN
4518 oe_debug_pub.add( 'BEFORE ITEM_TYPE' ) ;
4519 END IF;
4520 IF g_line_rec.item_type_code = FND_API.G_MISS_CHAR
4521 or NOT OE_GLOBALS.Equal(g_line_rec.line_category_code,
4522 p_old_line_rec.line_category_code)
4523 THEN
4524 g_line_rec.item_type_code :=
4525 Get_Item_Type(g_line_rec, p_old_line_rec);
4526 END IF;
4527
4528 -- smc flag defaulting is dependent on get_item_type.
4529 -- we are not checking for miss_char, because there is
4530 -- no clear_dep for smc_flag. and we don ot want to
4531 -- do that because of the way options defaulting work.
4532
4533 IF NOT OE_GLOBALS.Equal(p_old_line_rec.inventory_item_id,
4534 g_line_rec.inventory_item_id) THEN
4535 IF l_debug_level > 0 THEN
4536 oe_debug_pub.add( 'CALLING GET_SMC' , 3 ) ;
4537 END IF;
4538 g_line_rec.ship_model_complete_flag := Get_SMC_Flag;
4539 IF l_debug_level > 0 THEN
4540 oe_debug_pub.add( 'CALLING GET_ATO' , 3 ) ;
4541 END IF;
4542 g_line_rec.ato_line_id := Get_Ato_Line;
4543 END IF;
4544
4545 IF g_line_rec.ship_model_complete_flag = FND_API.G_MISS_CHAR THEN
4546 g_line_rec.ship_model_complete_flag := Get_SMC_Flag;
4547 END IF;
4548
4549 -- model_option_defaulting is dependent on get_top_model_line
4550 -- get_item_type and get_smc_flag
4551
4552 IF (g_line_rec.item_type_code <> FND_API.G_MISS_CHAR OR
4553 g_line_rec.item_type_code is not null) AND
4554 g_line_rec.operation = OE_GLOBALS.G_OPR_CREATE
4555 THEN
4556 model_option_defaulting;
4557 END IF;
4558
4559 IF (g_line_rec.line_id = FND_API.G_MISS_NUM) OR
4560 (g_line_rec.line_id IS NULL) THEN
4561 g_line_rec.org_id := OE_GLOBALS.G_ORG_ID;
4562 END IF;
4563
4564 IF g_line_rec.booked_flag = FND_API.G_MISS_CHAR THEN
4565 g_line_rec.booked_flag := Get_Booked;
4566 END IF;
4567
4568 IF g_line_rec.model_remnant_flag = FND_API.G_MISS_CHAR THEN
4569 g_line_rec.model_remnant_flag := NULL;
4570 END IF;
4571
4572 IF g_line_rec.cancelled_flag = FND_API.G_MISS_CHAR THEN
4573 g_line_rec.cancelled_flag := Get_Cancelled;
4574 END IF;
4575
4576 IF g_line_rec.cancelled_quantity = FND_API.G_MISS_NUM THEN
4577 g_line_rec.cancelled_quantity := Get_Cancelled_Quantity;
4578 END IF;
4579
4580 IF g_line_rec.component_code = FND_API.G_MISS_CHAR THEN
4581 g_line_rec.component_code := Get_Component;
4582 END IF;
4583
4584 IF g_line_rec.fulfilled_quantity = FND_API.G_MISS_NUM THEN
4585 g_line_rec.fulfilled_quantity := Get_Fulfilled_Quantity;
4586 END IF;
4587
4588 IF g_line_rec.line_number = FND_API.G_MISS_NUM THEN
4589 g_line_rec.line_number := Get_Line_Number;
4590 END IF;
4591
4592 IF g_line_rec.open_flag = FND_API.G_MISS_CHAR THEN
4593 g_line_rec.open_flag := Get_Open;
4594 END IF;
4595
4596 /* Added the following lines to fix the bug 2823553 */
4597
4598 IF g_line_rec.unit_list_price_per_pqty = FND_API.G_MISS_NUM THEN
4599 g_line_rec.unit_list_price_per_pqty := NULL;
4600 END IF;
4601
4602 IF g_line_rec.unit_selling_price_per_pqty = FND_API.G_MISS_NUM THEN
4603 g_line_rec.unit_selling_price_per_pqty := NULL;
4604 END IF;
4605
4606 -- Bug 3737773
4607 -- Moved the below code after call to defaulting FrameWork.
4608 -- Start of Code change for Bug 3671715
4609
4610 --IF g_line_rec.pricing_quantity = FND_API.G_MISS_NUM THEN
4611 -- g_line_rec.pricing_quantity := Get_Pricing_Quantity;
4612 --END IF;
4613
4614 IF g_line_rec.shipment_number = FND_API.G_MISS_NUM THEN
4615 g_line_rec.shipment_number := Get_Shipment_Number;
4616 END IF;
4617
4618 IF g_line_rec.shipping_interfaced_flag = FND_API.G_MISS_CHAR THEN
4619 g_line_rec.shipping_interfaced_flag := Get_Shipping_Interfaced;
4620 END IF;
4621
4622 IF l_debug_level > 0 THEN
4623 oe_debug_pub.add( 'AK BEFORE LINE CATEGORY1' ) ;
4624 END IF;
4625
4626 /* IF g_line_rec.line_category_code = FND_API.G_MISS_CHAR THEN
4627 g_line_rec.line_category_code :=
4628 Get_line_category(g_line_rec,p_old_line_rec);
4629 END IF;*/
4630
4631 /* btea begin This code is commented out to fix bug 1821024 Value should not get
4632 set before
4633 calling defaulting frame work. This value will be set after the defaulting f
4634 ramework
4635
4636 IF g_line_rec.calculate_price_flag = FND_API.G_MISS_CHAR THEN
4637 g_line_rec.calculate_price_flag := 'Y';
4638 END IF;
4639 btea end
4640 */
4641
4642
4643 -- Fixed bug 1206047: if user provides a value for the customer (sold_to)
4644 -- then override it with the value of sold_to from the header
4645 -- For the initial release, customer should be common on all lines of
4646 -- an order.
4647 IF NOT OE_GLOBALS.EQUAL( g_line_rec.sold_to_org_id
4648 ,p_old_line_rec.sold_to_org_id )
4649 THEN
4650 g_line_rec.sold_to_org_id := Get_Sold_To;
4651 END IF;
4652
4653 /* Start Fix for 2420456*/
4654
4655 IF l_debug_level > 0 THEN
4656 oe_debug_pub.add( 'TOLERANCE BELOW : '||G_LINE_REC.SHIP_TOLERANCE_BELOW , 3 ) ;
4657 oe_debug_pub.add( 'TOLERANCE BELOW : '||P_OLD_LINE_REC.SHIP_TOLERANCE_BELOW , 3 ) ;
4658 END IF;
4659
4660 IF nvl(g_line_rec.top_model_line_id,0) <> nvl(g_line_rec.ato_line_id,0) AND
4661 g_line_rec.top_model_line_id IS NOT NULL THEN
4662
4663 /* Change for bug 2276993 */
4664 --p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
4665
4666 IF g_line_rec.ship_tolerance_below IS NULL OR
4667 g_line_rec.ship_tolerance_below = FND_API.G_MISS_NUM OR
4668 g_line_rec.ship_tolerance_below = p_old_Line_rec.ship_tolerance_below THEN
4669 g_line_rec.ship_tolerance_below := 0;
4670 l_set_tolerance_below := 'Y';
4671 IF l_debug_level > 0 THEN
4672 oe_debug_pub.add( 'SET THE TOLERANCES BELOW TO 0 ' , 3 ) ;
4673 END IF;
4674
4675 END IF;
4676
4677 IF g_line_rec.ship_tolerance_above IS NULL OR
4678 g_line_rec.ship_tolerance_above = FND_API.G_MISS_NUM OR
4679 g_line_rec.ship_tolerance_above = p_old_Line_rec.ship_tolerance_above THEN
4680 g_line_rec.ship_tolerance_above := 0;
4681 l_set_tolerance_above := 'Y';
4682 IF l_debug_level > 0 THEN
4683 oe_debug_pub.add( 'SET THE TOLERANCES ABOVE TO 0 ' , 3 ) ;
4684 END IF;
4685
4686 END IF;
4687
4688 END IF;
4689
4690 IF (nvl(g_line_rec.top_model_line_id,-1) <> nvl(g_line_rec.ato_line_id,-1) AND
4691 g_line_rec.top_model_line_id IS NOT NULL) AND
4692 (nvl(g_line_rec.ship_tolerance_below,0) <> 0 OR
4693 nvl(g_line_rec.ship_tolerance_above,0) <> 0 )THEN
4694
4695 IF l_debug_level > 0 THEN
4696 oe_debug_pub.add( 'SHIP TOLERANCES CAN NOT BE SPECIFIED ON PTOS' , 3 ) ;
4697 END IF;
4698 fnd_message.set_name('ONT','OE_NO_TOL_FOR_PTO');
4699 OE_MSG_PUB.Add;
4700 RAISE FND_API.G_EXC_ERROR;
4701
4702 END IF;
4703
4704 /* END Fix for 2420456*/
4705
4706 -- Due to incompatibilities in the record type structure
4707 -- copy the data to a rowtype record format
4708
4709 OE_LINE_UTIL_EXT.API_Rec_To_Rowtype_Rec
4710 (p_line_rec => g_line_rec
4711 ,x_rowtype_rec => l_in_rec);
4712 OE_LINE_UTIL_EXT.API_Rec_To_Rowtype_Rec
4713 (p_line_rec => p_old_line_rec
4714 ,x_rowtype_rec => l_in_old_rec);
4715
4716 --Perform blanket defaulting
4717 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
4718
4719 IF ( l_in_rec.operation = OE_GLOBALS.G_OPR_CREATE -- 7152122
4720 AND trunc( l_in_rec.request_date ) <> trunc(l_in_old_rec.request_date)
4721 AND l_in_rec.blanket_line_number IS NOT NULL )THEN
4722 l_in_rec.blanket_line_number := FND_API.G_MISS_NUM;
4723 END IF;
4724
4725 Perform_Blanket_Functions
4726 (p_x_line_rec => l_in_rec
4727 ,p_old_line_rec => l_in_old_rec
4728 ,p_default_record => 'N'
4729 ,x_blanket_request_date => l_blanket_request_date
4730 );
4731
4732 END IF; --pack i
4733
4734 -- Call the default handler framework to default the missing attributes
4735
4736 IF l_debug_level > 0 THEN
4737 oe_debug_pub.add( 'IN2 LINE NUMBER :'||L_IN_REC.LINE_NUMBER ) ;
4738 END IF;
4739
4740 l_rec := l_in_rec;
4741
4742 -- add the code below to populate party_type if pay now is enabled and
4743 -- there exists any defaulting condition template using party_type.
4744 -- the check here is to avoid performace overhead, so that party_type
4745 -- information is only loaded when needed.
4746 IF OE_Prepayment_Util.Get_Installment_Options = 'ENABLE_PAY_NOW'
4747 AND l_in_rec.sold_to_org_id IS NOT NULL
4748 AND l_in_rec.sold_to_org_id <> FND_API.G_MISS_NUM
4749 THEN
4750 BEGIN
4751 SELECT 'Y'
4752 INTO l_exists
4753 FROM oe_def_condn_elems
4754 WHERE value_string = 'ORGANIZATION'
4755 AND attribute_code = 'PARTY_TYPE'
4756 AND rownum = 1;
4757 EXCEPTION WHEN NO_DATA_FOUND THEN
4758 null;
4759 END;
4760
4761 IF l_exists = 'Y' THEN
4762 BEGIN
4763 SELECT party.party_type
4764 INTO l_party_type
4765 FROM hz_cust_accounts cust_acct,
4766 hz_parties party
4767 WHERE party.party_id = cust_acct.party_id
4768 AND cust_acct.cust_account_id = l_in_rec.sold_to_org_id;
4769 EXCEPTION WHEN NO_DATA_FOUND THEN
4770 null;
4771 END;
4772
4773 l_rec.party_type := l_party_type;
4774
4775 IF l_debug_level > 0 then
4776 oe_debug_pub.add('party type in defaulting is: '||l_party_type, 3);
4777 END IF;
4778 END IF;
4779 END IF;
4780
4781
4782 ONT_LINE_Def_Hdlr.Default_Record
4783 (p_x_rec => l_rec
4784 , p_initial_rec => l_in_rec
4785 , p_in_old_rec => l_in_old_rec
4786 );
4787
4788 -- More blanket defaulting
4789 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
4790
4791 IF l_rec.blanket_number IS NOT NULL
4792 AND (NOT OE_GLOBALS.EQUAL(l_in_rec.blanket_number,l_rec.blanket_number)
4793 OR trunc(l_blanket_request_date) <> trunc(l_rec.request_date)
4794 )
4795 THEN
4796
4797 if l_debug_level > 0 then
4798 oe_debug_pub.add('Blkt Num or Request Date changed');
4799 end if;
4800
4801 Perform_Blanket_Functions
4802 (p_x_line_rec => l_rec
4803 ,p_old_line_rec => l_in_old_rec
4804 ,p_default_record => 'Y'
4805 ,x_blanket_request_date => l_blanket_request_date
4806 );
4807
4808 END IF; --If Blanket Number is not null and changed after defaulting
4809
4810 END IF; --pack I or greater
4811
4812 -- copy the data back to a format that is compatible with the API architecture
4813
4814 OE_LINE_UTIL_EXT.RowType_Rec_to_API_Rec
4815 (p_record => l_rec
4816 ,x_api_rec => p_x_line_rec);
4817
4818 -- 2707939 --
4819 IF g_line_rec.override_atp_date_code <> FND_API.G_MISS_CHAR THEN
4820 p_x_line_rec.override_atp_date_code := g_line_rec.override_atp_date_code;
4821 END IF;
4822 IF g_line_rec.firm_demand_flag <> FND_API.G_MISS_CHAR THEN
4823 p_x_line_rec.firm_demand_flag := g_line_rec.firm_demand_flag;
4824 END IF;
4825
4826 /* Bug 2154960 Added call to default_active_agr_revision() to default
4827 active Agreement Revision. This API will call process order for Line entity
4828 again after defaulting Active Agreement Revision to default dependent attributes. */
4829
4830 IF p_x_line_rec.agreement_id IS NOT NULL AND
4831 p_x_line_rec.agreement_id <> FND_API.G_MISS_NUM THEN
4832
4833 IF NOT oe_globals.equal(p_x_line_rec.pricing_date,
4834 p_old_line_rec.pricing_date)
4835 OR
4836 not oe_globals.equal(p_x_line_rec.agreement_id,
4837 p_old_line_rec.agreement_id) THEN
4838
4839 IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
4840 Default_Active_Agr_Revision
4841 ( p_x_line_rec => p_x_line_rec,
4842 p_old_line_rec => p_old_line_rec);
4843 END IF;
4844
4845 End If;
4846 End If;
4847
4848
4849 IF l_debug_level > 0 THEN
4850 oe_debug_pub.add( 'AFTER DEFAULTING LINE CATEGORY1' || P_X_LINE_REC.LINE_CATEGORY_CODE ) ;
4851 END IF;
4852
4853 IF p_x_line_rec.line_category_code = FND_API.G_MISS_CHAR OR -- added for 2421909
4854 p_x_line_rec.line_category_code IS NULL THEN
4855 p_x_line_rec.line_category_code := Get_line_category(p_x_line_rec,p_old_line_rec);
4856 IF l_debug_level > 0 THEN
4857 oe_debug_pub.add( 'AFTER CALLING LINE CATEGORY2' || P_X_LINE_REC.LINE_CATEGORY_CODE , 1 ) ;
4858 END IF;
4859 END IF;
4860
4861 -- Copy the value back to the out record for marketing source code.
4862 -- These columns are not enabled in the AK tables
4863
4864 if (p_x_line_rec.marketing_source_code_id = FND_API.G_MISS_NUM) then
4865 p_x_line_rec.marketing_source_code_id := NULL;
4866 else
4867 p_x_line_rec.marketing_source_code_id := p_x_line_rec.marketing_source_code_id;
4868 end if;
4869
4870
4871 --Code moved for bug 3737773 -starts here
4872 IF l_debug_level > 0 THEN
4873 oe_debug_pub.add( ' Before Defaulting P_Qty and P_Qty_Uom Values:' , 1 ) ;
4874 oe_debug_pub.add(' Pricing Qty: '|| p_x_line_rec.pricing_quantity ,1);
4875 oe_debug_pub.add(' Pricing UOM: '|| p_x_line_rec.pricing_quantity_uom,1 );
4876 oe_debug_pub.add(' Ordered Qty: '|| p_x_line_rec.ordered_quantity ,1);
4877 oe_debug_pub.add(' Ordered UOM: '|| p_x_line_rec.order_quantity_uom,1);
4878 END IF;
4879
4880 IF (p_x_line_rec.pricing_quantity = FND_API.G_MISS_NUM
4881 OR p_x_line_rec.pricing_quantity is NULL
4882 OR p_x_line_rec.pricing_quantity = -99999) THEN
4883 IF (p_x_line_rec.pricing_quantity_uom = FND_API.G_MISS_CHAR
4884 OR p_x_line_rec.pricing_quantity_uom is NULL) THEN
4885 p_x_line_rec.pricing_quantity := p_x_line_rec.ordered_quantity;
4886 p_x_line_rec.pricing_quantity_uom := p_x_line_rec.order_quantity_uom;
4887 ELSE --Pricing UOM has value but P_QTY is not populated
4888 p_x_line_rec.pricing_quantity := Get_Pricing_Quantity;
4889 --Added the message after review. May be value -99999 is returned when no conversion exists.
4890 if(p_x_line_rec.pricing_quantity = -99999) Then
4891 IF l_debug_level > 0 THEN
4892 oe_debug_pub.add(' Pricing Qty '|| p_x_line_rec.pricing_quantity ,1);
4893 oe_debug_pub.add(' Pricing UOM '|| p_x_line_rec.pricing_quantity_uom,1 );
4894 oe_debug_pub.add(' Ordered Qty '|| p_x_line_rec.ordered_quantity ,1);
4895 oe_debug_pub.add(' Ordered UOM '|| p_x_line_rec.order_quantity_uom,1);
4896 oe_debug_pub.add( ' Conversion does not exists' , 1 ) ;
4897 END IF;
4898
4899 FND_MESSAGE.SET_NAME('ONT', 'ONT_PRC_INVALID_UOM_CONVERSION');
4900 fnd_message.set_token('UOM_TEXT',p_x_line_rec.pricing_quantity_uom);
4901 OE_MSG_PUB.Add;
4902 RAISE FND_API.G_EXC_ERROR;
4903 END IF;
4904 -- End of code addition after review.
4905 END IF; -- End of Pricing UOM check
4906 ELSE -- Pricing Quantity has a valid Value
4907 IF (p_x_line_rec.pricing_quantity_uom = FND_API.G_MISS_CHAR
4908 OR p_x_line_rec.pricing_quantity_uom is NULL) THEN
4909 IF (p_x_line_rec.pricing_quantity = p_x_line_rec.ordered_quantity) THEN
4910 p_x_line_rec.pricing_quantity_uom := p_x_line_rec.order_quantity_uom;
4911 ELSE --P_QTY is not equal to O_QTY and P_UOM is Not Populated
4912 --RAISE ERROR
4913 IF l_debug_level > 0 THEN
4914 oe_debug_pub.add(' Pricing Qty '|| p_x_line_rec.pricing_quantity ,1);
4915 oe_debug_pub.add(' Pricing UOM '|| p_x_line_rec.pricing_quantity_uom,1 );
4916 oe_debug_pub.add(' Ordered Qty '|| p_x_line_rec.ordered_quantity ,1);
4917 oe_debug_pub.add(' Ordered UOM '|| p_x_line_rec.order_quantity_uom,1);
4918 oe_debug_pub.add( ' Pricing Qty is not equal to Ord Qty and P_UOM is not populated' , 1 ) ;
4919 END IF;
4920
4921 IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
4922 --Added the message after review.
4923 FND_MESSAGE.SET_NAME('ONT', 'ONT_INVALID_ORD_QTY_PRC_QTY');
4924 OE_MSG_PUB.Add;
4925 RAISE FND_API.G_EXC_ERROR;
4926 ELSE --BUG 4135361
4927 p_x_line_rec.pricing_quantity := p_x_line_rec.ordered_quantity;
4928 p_x_line_rec.pricing_quantity_uom := p_x_line_rec.order_quantity_uom;
4929 END IF;
4930 END IF;
4931 ELSE -- BOTH P_UOM and P_QTY has valid values Do Nothing
4932 NULL;
4933 END IF;
4934 END IF;
4935 -- end bug fix 3737773
4936
4937 --Btea begin fix bug 1821024,
4938 if (p_x_line_rec.calculate_price_flag = FND_API.G_MISS_CHAR or
4939 p_x_line_rec.calculate_price_flag is Null) Then
4940 p_x_line_rec.calculate_price_flag := 'Y';
4941 End If;
4942 --Btea end
4943
4944 -- Copy the value back to the out record for order source id.
4945 if (p_x_line_rec.order_source_id = FND_API.G_MISS_NUM) then
4946 IF l_debug_level > 0 THEN
4947 oe_debug_pub.add( 'OEXDLINB - AKSINGH - CHECK FOR G_MISS_NUM' ) ;
4948 END IF;
4949 p_x_line_rec.order_source_id := Get_Order_Source_Id;
4950 else
4951 IF l_debug_level > 0 THEN
4952 oe_debug_pub.add( 'OEXDLINB - AKSINGH - CHECK FOR ELSE' ) ;
4953 END IF;
4954 p_x_line_rec.order_source_id := p_x_line_rec.order_source_id;
4955 end if;
4956
4957 -- Copy the value back to the out record for Commitment_Id.
4958 if (p_x_line_rec.commitment_id = FND_API.G_MISS_NUM) then
4959 IF l_debug_level > 0 THEN
4960 oe_debug_pub.add( 'OEXDLINB - COMMITMENT_ID - CHECK FOR G_MISS_NUM' ) ;
4961 END IF;
4962 p_x_line_rec.commitment_id := NULL;
4963 else
4964 IF l_debug_level > 0 THEN
4965 oe_debug_pub.add( 'OEXDLINB - COMMITMENT_ID - CHECK FOR ELSE' ) ;
4966 END IF;
4967 p_x_line_rec.commitment_id := p_x_line_rec.commitment_id;
4968 end if;
4969
4970 /* 1581620 start */
4971
4972 IF (p_x_line_rec.tp_context = FND_API.G_MISS_CHAR) THEN
4973 p_x_line_rec.tp_context := NULL;
4974 END IF;
4975 IF (p_x_line_rec.tp_attribute1 = FND_API.G_MISS_CHAR) THEN
4976 p_x_line_rec.tp_attribute1 := NULL;
4977 END IF;
4978
4979 IF (p_x_line_rec.tp_attribute2 = FND_API.G_MISS_CHAR) THEN
4980 p_x_line_rec.tp_attribute2 := NULL;
4981 END IF;
4982
4983 IF (p_x_line_rec.tp_attribute3 = FND_API.G_MISS_CHAR) THEN
4984 p_x_line_rec.tp_attribute3 := NULL;
4985 END IF;
4986
4987 IF (p_x_line_rec.tp_attribute4 = FND_API.G_MISS_CHAR) THEN
4988 p_x_line_rec.tp_attribute4 := NULL;
4989 END IF;
4990
4991 IF (p_x_line_rec.tp_attribute5 = FND_API.G_MISS_CHAR) THEN
4992 p_x_line_rec.tp_attribute5 := NULL;
4993 END IF;
4994
4995 IF (p_x_line_rec.tp_attribute6 = FND_API.G_MISS_CHAR) THEN
4996 p_x_line_rec.tp_attribute6 := NULL;
4997 END IF;
4998
4999 IF (p_x_line_rec.tp_attribute7 = FND_API.G_MISS_CHAR) THEN
5000 p_x_line_rec.tp_attribute7 := NULL;
5001 END IF;
5002
5003 IF (p_x_line_rec.tp_attribute8 = FND_API.G_MISS_CHAR) THEN
5004 p_x_line_rec.tp_attribute8 := NULL;
5005 END IF;
5006
5007 IF (p_x_line_rec.tp_attribute9 = FND_API.G_MISS_CHAR) THEN
5008 p_x_line_rec.tp_attribute9 := NULL;
5009 END IF;
5010
5011 IF (p_x_line_rec.tp_attribute10 = FND_API.G_MISS_CHAR) THEN
5012 p_x_line_rec.tp_attribute10 := NULL;
5013 END IF;
5014
5015 IF (p_x_line_rec.tp_attribute11 = FND_API.G_MISS_CHAR) THEN
5016 p_x_line_rec.tp_attribute11 := NULL;
5017 END IF;
5018
5019 IF (p_x_line_rec.tp_attribute12 = FND_API.G_MISS_CHAR) THEN
5020 p_x_line_rec.tp_attribute12 := NULL;
5021 END IF;
5022
5023 IF (p_x_line_rec.tp_attribute13 = FND_API.G_MISS_CHAR) THEN
5024 p_x_line_rec.tp_attribute13 := NULL;
5025 END IF;
5026
5027 IF (p_x_line_rec.tp_attribute14 = FND_API.G_MISS_CHAR) THEN
5028 p_x_line_rec.tp_attribute14 := NULL;
5029 END IF;
5030
5031 IF (p_x_line_rec.tp_attribute15 = FND_API.G_MISS_CHAR) THEN
5032 p_x_line_rec.tp_attribute15 := NULL;
5033 END IF;
5034
5035 IF (p_x_line_rec.flow_status_code = FND_API.G_MISS_CHAR) THEN
5036 p_x_line_rec.flow_status_code := NULL;
5037 END IF;
5038
5039 IF (p_x_line_rec.drop_ship_flag = FND_API.G_MISS_CHAR) THEN
5040 p_x_line_rec.drop_ship_flag := NULL;
5041 END IF;
5042
5043 -- OR condition added for 3200019 so orig_sys_shipment_ref
5044 -- would not get defaulted incorrectly when entering multiple
5045 -- lines due to caching in SO UI like bug 2362210
5046 IF (p_x_line_rec.orig_sys_shipment_ref = FND_API.G_MISS_CHAR
5047 OR p_x_line_rec.orig_sys_shipment_ref IS NULL) AND
5048 (nvl(p_x_line_rec.source_document_id,0) <> 10) THEN
5049 IF (OE_CODE_CONTROL.Get_Code_Release_Level >= '110508') AND
5050 (g_multiple_shipments = 'YES') THEN
5051 p_x_line_rec.orig_sys_shipment_ref := 'OE_ORDER_LINES_ALL'||p_x_line_rec.line_id||'.'||'1';
5052 IF l_debug_level > 0 THEN
5053 oe_debug_pub.add( 'SHIP SYS = '||P_X_LINE_REC.ORIG_SYS_SHIPMENT_REF ) ;
5054 END IF;
5055 ELSE
5056 p_x_line_rec.orig_sys_shipment_ref := NULL;
5057 END IF;
5058 END IF;
5059
5060 if (p_x_line_rec.change_sequence = FND_API.G_MISS_CHAR) then
5061 p_x_line_rec.change_sequence := NULL;
5062 end if;
5063
5064 if (p_x_line_rec.customer_line_number = FND_API.G_MISS_CHAR) then
5065 p_x_line_rec.customer_line_number := NULL;
5066 end if;
5067
5068 if (p_x_line_rec.customer_shipment_number = FND_API.G_MISS_CHAR) then
5069 p_x_line_rec.customer_shipment_number := NULL;
5070 end if;
5071
5072 if (p_x_line_rec.customer_item_net_price = FND_API.G_MISS_NUM) then
5073 p_x_line_rec.customer_item_net_price := NULL;
5074 end if;
5075
5076 if (p_x_line_rec.customer_payment_term_id = FND_API.G_MISS_NUM) then
5077 p_x_line_rec.customer_payment_term_id := NULL;
5078 end if;
5079
5080 if (p_x_line_rec.reference_customer_trx_line_id = FND_API.G_MISS_NUM) then
5081 p_x_line_rec.reference_customer_trx_line_id := NULL;
5082 end if;
5083
5084 if (p_x_line_rec.sold_from_org_id = FND_API.G_MISS_NUM) then
5085 p_x_line_rec.sold_from_org_id := NULL;
5086 end if;
5087
5088 if (p_x_line_rec.mfg_lead_time = FND_API.G_MISS_NUM) then
5089 p_x_line_rec.mfg_lead_time := NULL;
5090 end if;
5091
5092 if (p_x_line_rec.lock_control = FND_API.G_MISS_NUM) then
5093 p_x_line_rec.lock_control := NULL;
5094 end if;
5095
5096 if (p_x_line_rec.re_source_flag = FND_API.G_MISS_CHAR) then
5097 p_x_line_rec.re_source_flag := NULL;
5098 end if;
5099
5100 if (p_x_line_rec.model_remnant_flag = FND_API.G_MISS_CHAR) then
5101 p_x_line_rec.model_remnant_flag := NULL;
5102 end if;
5103
5104 if (p_x_line_rec.shippable_flag = FND_API.G_MISS_CHAR) then
5105 p_x_line_rec.shippable_flag := NULL;
5106 end if;
5107
5108 /* 1581620 end */
5109
5110 -- Bug # 5490345
5111
5112 if (p_x_line_rec.minisite_id = FND_API.G_MISS_NUM) then
5113 p_x_line_rec.minisite_id := NULL;
5114 end if;
5115
5116
5117 --Distributor Orders
5118 if (p_x_line_rec.End_Customer_ID = FND_API.G_MISS_NUM) then
5119 p_x_line_rec.End_Customer_id := NULL;
5120 end if;
5121 if (p_x_line_rec.End_Customer_Contact_ID = FND_API.G_MISS_NUM) then
5122 p_x_line_rec.End_Customer_Contact_id := NULL;
5123 end if;
5124 if (p_x_line_rec.End_Customer_Site_Use_ID = FND_API.G_MISS_NUM) then
5125 p_x_line_rec.End_Customer_site_use_id := NULL;
5126 end if;
5127 if (p_x_line_rec.IB_OWNER = FND_API.G_MISS_CHAR) then
5128 p_x_line_rec.IB_OWNER := NULL;
5129 end if;
5130 if (p_x_line_rec.IB_CURRENT_LOCATION = FND_API.G_MISS_CHAR) then
5131 p_x_line_rec.IB_CURRENT_LOCATION := NULL;
5132 end if;
5133 if (p_x_line_rec.IB_INSTALLED_AT_LOCATION = FND_API.G_MISS_CHAR) then
5134 p_x_line_rec.IB_INSTALLED_AT_LOCATION := NULL;
5135 end if;
5136 --
5137 if (p_x_line_rec.blanket_number = FND_API.G_MISS_NUM) then
5138 p_x_line_rec.blanket_number := NULL;
5139 end if;
5140
5141 if (p_x_line_rec.blanket_line_number = FND_API.G_MISS_NUM) then
5142 p_x_line_rec.blanket_line_number := NULL;
5143 end if;
5144
5145 if (p_x_line_rec.blanket_version_number = FND_API.G_MISS_NUM) then
5146 p_x_line_rec.blanket_version_number := NULL;
5147 end if;
5148
5149 /* 1783766 start */
5150
5151 if (p_x_line_rec.fulfillment_set = FND_API.G_MISS_CHAR) then
5152 p_x_line_rec.fulfillment_set := NULL;
5153 end if;
5154
5155 if (p_x_line_rec.fulfillment_set_id = FND_API.G_MISS_NUM) then
5156 p_x_line_rec.fulfillment_set_id := NULL;
5157 end if;
5158
5159 /* 1783766 end */
5160
5161 -- OPM 02/JUN/00 BEGIN - Default process attributes as appropriate
5162 -- ===============================================================
5163 IF (p_x_line_rec.ordered_quantity_uom2 = FND_API.G_MISS_CHAR)
5164 OR (p_x_line_rec.ordered_quantity_uom2 IS NULL) THEN
5165 p_x_line_rec.ordered_quantity_uom2 :=
5166 Get_Dual_Uom(p_line_rec => p_x_line_rec); -- INVCONV
5167 END IF;
5168 -- INVCONV -- NORMAL DEFAULTING IS USED NOW SO TAKE OUT
5169 /* -- OPM bug 2553805 do not re-default the preferred_grade if this is a copied order
5170 IF ( (p_x_line_rec.preferred_grade = FND_API.G_MISS_CHAR)
5171 OR (p_x_line_rec.preferred_grade IS NULL) )
5172 and
5173 (nvl( p_x_line_rec.source_document_type_id, 0 ) <> 2 ) -- added line for 2553805
5174 THEN
5175 p_x_line_rec.preferred_grade :=
5176 OE_Line_Util.Get_Preferred_Grade(p_line_rec => p_x_line_rec,
5177 p_old_line_rec => p_old_line_rec);
5178 END IF; */
5179
5180 IF (p_x_line_rec.ordered_quantity2 = FND_API.G_MISS_NUM) THEN
5181 p_x_line_rec.ordered_quantity2 := NULL;
5182 END IF;
5183
5184 -- OPM 03/MAY/00 END
5185 -- =================
5186
5187 -- Since we are moving to ship method we allways default freight carrier
5188 -- from ship method and make sure to overide whatever user sends in
5189
5190 p_x_line_rec.freight_carrier_code :=
5191 Get_Freight_Carrier(p_line_rec => p_x_line_rec,
5192 p_old_line_rec => p_old_line_rec);
5193
5194 -- when order import do not pass item_identifier_type, default to INT
5195
5196 IF ((p_x_line_rec.item_identifier_type = FND_API.G_MISS_CHAR
5197 OR p_x_line_rec.item_identifier_type is null) AND
5198 p_x_line_rec.inventory_item_id is not null AND
5199 p_x_line_rec.inventory_item_id <> FND_API.G_MISS_NUM)
5200 THEN
5201 -- Re-default to INT only if item_identifier_type was previously null
5202 -- otherwise retain the old value. For example: If item identifier was
5203 -- CUST and now became null due to dependency on sold_to we should keep the
5204 -- value as CUST (should not over-write to INT)
5205
5206 IF p_old_line_rec.item_identifier_type IS NULL THEN
5207 IF l_debug_level > 0 THEN
5208 oe_debug_pub.add( 'ITEM_IDENTIFIER_TYPE IS NULL , DEFAULT TO INT' ) ;
5209 END IF;
5210 p_x_line_rec.item_identifier_type := 'INT';
5211 ELSE
5212 IF l_debug_level > 0 THEN
5213 oe_debug_pub.add( 'ASSIGNING ITEM_IDENTIFIER_TYPE FROM P_OLD_LINE_REC: '||P_OLD_LINE_REC.ITEM_IDENTIFIER_TYPE ) ;
5214 END IF;
5215 p_x_line_rec.item_identifier_type := p_old_line_rec.item_identifier_type;
5216 END IF;
5217 END IF;
5218
5219 IF p_x_line_rec.source_type_code is null OR
5220 p_x_line_rec.source_type_code = FND_API.G_MISS_CHAR THEN
5221 p_x_line_rec.source_type_code := OE_GLOBALS.G_SOURCE_INTERNAL;
5222 END IF;
5223
5224 -- Bug 5708174
5225 IF p_x_line_rec.source_type_code = OE_GLOBALS.G_SOURCE_EXTERNAL THEN
5226 p_x_line_rec.subinventory := NULL;
5227 END IF;
5228 -- Added to fix the issue in bug 2894486
5229 IF p_x_line_rec.line_category_code = 'RETURN' THEN
5230 p_x_line_rec.source_type_code := OE_GLOBALS.G_SOURCE_INTERNAL;
5231 p_x_line_rec.ato_line_id := NULL;
5232 END IF;
5233
5234 -- Bug 5331971, internal orders shall not be externally sourced
5235 IF p_x_line_rec.order_source_id = 10 THEN
5236 p_x_line_rec.source_type_code := OE_GLOBALS.G_SOURCE_INTERNAL;
5237 END IF;
5238
5239 -- This is the new condition aksingh changed on 04/22/01
5240 IF NOT OE_GLOBALS.Equal(p_x_line_rec.request_date,
5241 p_old_line_rec.request_date)
5242 THEN
5243 IF l_debug_level > 0 THEN
5244 oe_debug_pub.add( 'OEXDLINB -1- CHECK FOR G_MISS_DATE FOR REQUEST ' ) ;
5245 END IF;
5246 IF p_x_line_rec.request_date <> FND_API.G_MISS_DATE THEN
5247 -- aksingh added this if for the bug 1745501
5248 IF l_debug_level > 0 THEN
5249 oe_debug_pub.add( 'OEXDLINB -2- CHECK FOR G_MISS_DATE FOR LATEST ' ) ;
5250 END IF;
5251 IF OE_GLOBALS.Equal(p_x_line_rec.latest_acceptable_date,
5252 p_old_line_rec.latest_acceptable_date)
5253 OR p_x_line_rec.latest_acceptable_date = FND_API.G_MISS_DATE
5254 THEN
5255 IF l_debug_level > 0 THEN
5256 oe_debug_pub.add( 'OEXDLINB -3- AFTER CHECK FOR G_MISS_DATE FOR LATEST ' ) ;
5257 END IF;
5258 p_x_line_rec.latest_acceptable_date :=
5259 Get_Latest_Acceptable_Date(p_x_line_rec.request_date);
5260 END IF;
5261 END IF;
5262 END IF;
5263
5264 -- Item Substitution
5265 IF p_x_line_rec.Original_Inventory_Item_Id = FND_API.G_MISS_NUM THEN
5266 p_x_line_rec.Original_Inventory_Item_Id := Null;
5267 END IF;
5268
5269 IF p_x_line_rec.Original_item_identifier_Type = FND_API.G_MISS_CHAR THEN
5270 p_x_line_rec.Original_item_identifier_Type := Null;
5271 END IF;
5272
5273 IF p_x_line_rec.Original_ordered_item_id = FND_API.G_MISS_NUM THEN
5274 p_x_line_rec.Original_ordered_item_id := Null;
5275 END IF;
5276
5277 IF p_x_line_rec.Original_ordered_item = FND_API.G_MISS_CHAR THEN
5278 p_x_line_rec.Original_ordered_item := Null;
5279 END IF;
5280
5281 IF p_x_line_rec.Item_relationship_type = FND_API.G_MISS_NUM THEN
5282 p_x_line_rec.Item_relationship_type := Null;
5283 END IF;
5284
5285 IF p_x_line_rec.Item_substitution_type_code = FND_API.G_MISS_CHAR THEN
5286 p_x_line_rec.Item_substitution_type_code := Null;
5287 END IF;
5288
5289 IF p_x_line_rec.Late_Demand_Penalty_Factor = FND_API.G_MISS_NUM THEN
5290 p_x_line_rec.Late_Demand_Penalty_Factor := Null;
5291 END IF;
5292
5293 IF p_x_line_rec.Override_atp_date_code = FND_API.G_MISS_CHAR THEN
5294 p_x_line_rec.Override_atp_date_code := Null;
5295 END IF;
5296
5297 IF p_x_line_rec.firm_demand_flag = FND_API.G_MISS_CHAR THEN
5298 p_x_line_rec.firm_demand_flag := Null;
5299 END IF;
5300 --retro{
5301 IF (p_x_line_rec.retrobill_request_id = FND_API.G_MISS_NUM) THEN
5302 p_x_line_rec.retrobill_request_id := NULL;
5303 END IF;
5304 --retro}
5305
5306 --Customer Acceptance
5307 IF p_x_line_rec.CONTINGENCY_ID = FND_API.G_MISS_NUM THEN
5308 p_x_line_rec.CONTINGENCY_ID := NULL ;
5309 END IF;
5310 IF p_x_line_rec.REVREC_EVENT_CODE = FND_API.G_MISS_CHAR THEN
5311 p_x_line_rec.REVREC_EVENT_CODE:= NULL ;
5312 END IF;
5313 IF p_x_line_rec.REVREC_EXPIRATION_DAYS = FND_API.G_MISS_NUM THEN
5314 p_x_line_rec.REVREC_EXPIRATION_DAYS:= NULL ;
5315 END IF;
5316 IF p_x_line_rec.ACCEPTED_QUANTITY = FND_API.G_MISS_NUM THEN
5317 p_x_line_rec.ACCEPTED_QUANTITY:= NULL ;
5318 END IF;
5319 IF p_x_line_rec.REVREC_COMMENTS = FND_API.G_MISS_CHAR THEN
5320 p_x_line_rec.REVREC_COMMENTS:= NULL ;
5321 END IF;
5322 IF p_x_line_rec.REVREC_SIGNATURE = FND_API.G_MISS_CHAR THEN
5323 p_x_line_rec.REVREC_SIGNATURE:= NULL ;
5324 END IF;
5325 IF p_x_line_rec.REVREC_SIGNATURE_DATE = FND_API.G_MISS_DATE THEN
5326 p_x_line_rec.REVREC_SIGNATURE_DATE:= NULL ;
5327 END IF;
5328 IF p_x_line_rec.ACCEPTED_BY = FND_API.G_MISS_NUM THEN
5329 p_x_line_rec.ACCEPTED_BY:= NULL ;
5330 END IF;
5331 IF p_x_line_rec.REVREC_REFERENCE_DOCUMENT = FND_API.G_MISS_CHAR THEN
5332 p_x_line_rec.REVREC_REFERENCE_DOCUMENT:= NULL ;
5333 END IF;
5334 IF p_x_line_rec.REVREC_IMPLICIT_FLAG = FND_API.G_MISS_CHAR THEN
5335 p_x_line_rec.REVREC_IMPLICIT_FLAG := NULL ;
5336 END IF;
5337 --Customer Acceptance
5338 -- bug 4203691 recurring charges
5339 IF p_x_line_rec.charge_periodicity_code = FND_API.G_MISS_CHAR THEN
5340 p_x_line_rec.charge_periodicity_code := NULL ;
5341 END IF;
5342
5343 /* The following lines are commented to fix the bug 1409036 */
5344 /*
5345 IF NOT OE_GLOBALS.Equal(p_x_line_rec.line_type_id,
5346 p_old_line_rec.line_type_id)
5347 THEN
5348 p_x_line_rec.source_type_code :=
5349 Get_Source_Type(p_source_type => p_x_line_rec.source_type_code,
5350 p_line_type_id => p_x_line_rec.line_type_id);
5351 END IF;
5352 */
5353
5354 -- get shippable is dependent on model_option_defaulting.
5355 -- ## bug fix: 1609895, shippable flag from warehouse
5356
5357 IF p_x_line_rec.shippable_flag is NULL OR
5358 p_x_line_rec.shippable_flag = FND_API.G_MISS_CHAR THEN
5359 IF l_debug_level > 0 THEN
5360 oe_debug_pub.add( 'CALLING GET SHIPPABLE_FLAG ' , 1 ) ;
5361 END IF;
5362
5363 p_x_line_rec.shippable_flag :=
5364 Get_Shippable( p_line_id => p_x_line_rec.line_id
5365 ,p_inventory_item_id => p_x_line_rec.inventory_item_id
5366 ,p_ship_from_org_id => p_x_line_rec.ship_from_org_id
5367 ,p_ato_line_id => p_x_line_rec.ato_line_id
5368 ,p_item_type_code => p_x_line_rec.item_type_code );
5369 END IF;
5370
5371 IF p_x_line_rec.schedule_status_code is null
5372 AND NOT OE_GLOBALS.Equal(p_old_line_rec.ship_from_org_id,
5373 p_x_line_rec.ship_from_org_id) THEN
5374 IF p_x_line_rec.ship_from_org_id is not null
5375 THEN
5376 IF l_debug_level > 0 THEN
5377 oe_debug_pub.add( 'SETTING RE_SOURCE_FLAG TO N' , 1 ) ;
5378 END IF;
5379 p_x_line_rec.re_source_flag := 'N';
5380 ELSE
5381 IF l_debug_level > 0 THEN
5382 oe_debug_pub.add( '1.SETTING RE_SOURCE_FLAG TO NULL' , 1 ) ;
5383 END IF;
5384 p_x_line_rec.re_source_flag := '';
5385 END IF;
5386 END IF;
5387
5388 /* With the new set and scheduling functionality the set id is created when a
5389 line is requested into a set and also gets cascaded if the operation is update
5390 and the children of the model has been already created
5391 this logic fires only when the scheduling branch profiel is set to Yes */
5392 -- 4118431
5393
5394 --IF NVL(FND_PROFILE.VALUE('ONT_BRANCH_SCHEDULING'),'N') = 'Y'--Bug4504362
5395 IF p_x_line_rec.line_id > 0 THEN
5396
5397 oe_Set_util.Default_line_set
5398 (p_x_line_rec => p_x_line_rec,
5399 p_old_line_rec => p_old_line_rec);
5400
5401 IF p_x_line_rec.line_category_code = 'RETURN'
5402 OR p_x_line_rec.source_type_code = 'EXTERNAL' THEN
5403
5404 p_x_line_rec.ship_set_id := NULL;
5405 p_x_line_rec.ship_set := NULL;
5406 p_x_line_rec.arrival_set_id := NULL;
5407 p_x_line_rec.arrival_set := NULL;
5408
5409 END IF;
5410 END IF;
5411
5412
5413 IF p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
5414 THEN
5415 model_option_update (p_x_line_rec => p_x_line_rec);
5416 END IF;
5417
5418 /* Please do not put any code after the following IF fix for 2116098*/
5419
5420 IF nvl(p_x_line_rec.top_model_line_id,0) <> nvl(p_x_line_rec.ato_line_id,0) AND
5421 p_x_line_rec.top_model_line_id IS NOT NULL THEN
5422
5423 /* Change for bug 2276993 */
5424 --p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
5425
5426 /* Fix for bug 2420456 */
5427 IF l_set_tolerance_below = 'Y' THEN
5428
5429 IF l_debug_level > 0 THEN
5430 oe_debug_pub.add( 'TOLERANCE BELOW : '||P_X_LINE_REC.SHIP_TOLERANCE_BELOW , 3 ) ;
5431 END IF;
5432 p_x_line_rec.ship_tolerance_below := 0;
5433 l_set_tolerance_below := 'N';
5434 IF l_debug_level > 0 THEN
5435 oe_debug_pub.add( 'SET THE TOLERANCES BELOW TO 0 ' , 3 ) ;
5436 END IF;
5437
5438 END IF;
5439
5440 IF l_set_tolerance_above = 'Y' THEN
5441
5442 IF l_debug_level > 0 THEN
5443 oe_debug_pub.add( 'TOLERANCE BELOW : '||P_X_LINE_REC.SHIP_TOLERANCE_ABOVE , 3 ) ;
5444 END IF;
5445 p_x_line_rec.ship_tolerance_above := 0;
5446 l_set_tolerance_above := 'N';
5447 IF l_debug_level > 0 THEN
5448 oe_debug_pub.add( 'SET THE TOLERANCES ABOVE TO 0 ' , 3 ) ;
5449 END IF;
5450
5451 END IF;
5452
5453 END IF;
5454
5455 IF p_x_line_rec.user_item_description = FND_API.G_MISS_CHAR THEN
5456 p_x_line_rec.user_item_description := Null;
5457 END IF;
5458
5459 -- to clear out user_item_description if item changes
5460 -- and user_item_description is not changing.
5461 IF NOT OE_GLOBALS.Equal(p_x_line_rec.inventory_item_id,
5462 p_old_line_rec.inventory_item_id)
5463 AND OE_GLOBALS.Equal(p_x_line_rec.user_item_description,
5464 p_old_line_rec.user_item_description)
5465 AND p_old_line_rec.user_item_description IS NOT NULL THEN
5466
5467 p_x_line_rec.user_item_description := NULL;
5468 FND_MESSAGE.Set_Name('ONT', 'ONT_USER_ITEM_DESC_CLEARED');
5469 IF l_debug_level > 0 THEN
5470 oe_debug_pub.add( 'CLEAR OUT USER_ITEM_DESCRIPTION WHEN ITEM CHANGES.' , 3 ) ;
5471 END IF;
5472
5473 END IF;
5474
5475 -- Override List Price
5476 IF (OE_CODE_CONTROL.Get_Code_Release_Level >= '110510') THEN
5477 IF p_x_line_rec.original_list_price = FND_API.G_MISS_NUM THEN
5478 p_x_line_rec.original_list_price := NULL;
5479 END IF;
5480 END IF;
5481 -- Override List Price
5482
5483 IF l_debug_level > 0 THEN
5484 oe_debug_pub.add( 'EXIT OE_DEFAULT_LINE.ATTRIBUTES' , 1 ) ;
5485 END IF;
5486 EXCEPTION
5487
5488 WHEN FND_API.G_EXC_ERROR THEN
5489
5490 RAISE FND_API.G_EXC_ERROR;
5491
5492 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5493
5494 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5495
5496 WHEN OTHERS THEN
5497
5498 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5499 THEN
5500 OE_MSG_PUB.Add_Exc_Msg
5501 ( G_PKG_NAME ,
5502 'Attributes'
5503 );
5504 END IF;
5505
5506 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5507
5508 END Attributes;
5509
5510 /*----------------------------------------------------------
5511 FUNCTION Get_Dual_Uom
5512 ----------------------------------------------------------- INVCONV REMOVEd from OE_line_util
5513 */
5514
5515 FUNCTION Get_Dual_Uom(p_line_rec OE_ORDER_PUB.Line_Rec_Type)
5516 RETURN VARCHAR2
5517 IS
5518 -- l_APPS_UOM2 VARCHAR2(3) := NULL; INVCONV
5519 l_status VARCHAR2(1);
5520 l_msg_count NUMBER;
5521 l_msg_data VARCHAR2(2000);
5522 l_item_rec OE_ORDER_CACHE.item_rec_type;
5523
5524 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5525
5526 BEGIN
5527 if l_debug_level > 0 then
5528 oe_debug_pub.add('Enter Get dual uom');
5529 end if;
5530
5531 IF oe_line_util.dual_uom_control -- INVCONV Process_Characteristics
5532 (p_line_rec.inventory_item_id,p_line_rec.ship_from_org_id,l_item_rec) THEN
5533 IF l_item_rec.tracking_quantity_ind = 'PS' THEN -- INVCONV
5534 if l_debug_level > 0 then
5535 oe_debug_pub.add('Get dual uom - tracking in P and S ');
5536 end if;
5537 /* convert 4 digit apps OPM codes to equivalent 3 byte APPS codes */
5538 /* Primary UM
5539 GMI_Reservation_Util.Get_AppsUOM_from_OPMUOM
5540 (p_OPM_UOM => l_item_rec.opm_item_um2
5541 ,x_Apps_UOM => l_APPS_UOM2
5542 ,x_return_status => l_status
5543 ,x_msg_count => l_msg_count
5544 ,x_msg_data => l_msg_data); */
5545 RETURN l_item_rec.secondary_uom_code;
5546
5547
5548
5549 else -- INVCONV
5550 return NULL;
5551 END IF; -- IF l_item_rec.tracking_quantity_ind = 'PS' THEN -- INVCONV
5552
5553
5554 else
5555
5556 return null;
5557
5558 END IF; -- IF oe_line_util.dual_uom_control -- INVCONV Process_Characteristics
5559
5560
5561 if l_debug_level > 0 then
5562 oe_debug_pub.add('Get Dual Uom returns dual UM of ' || l_item_rec.secondary_uom_code);
5563 end if;
5564
5565 EXCEPTION
5566
5567 WHEN NO_DATA_FOUND THEN
5568
5569 if l_debug_level > 0 then
5570 oe_debug_pub.add('No Data Found Get Dual Uom' );
5571 end if;
5572 RETURN NULL;
5573
5574 WHEN OTHERS THEN
5575 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5576 THEN
5577 OE_MSG_PUB.Add_Exc_Msg
5578 ( G_PKG_NAME ,
5579 'Get_Dual_Uom'
5580 );
5581 END IF;
5582 if l_debug_level > 0 then
5583 oe_debug_pub.add('others in get_dual uom', 1);
5584 end if;
5585 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5586
5587
5588 END Get_Dual_Uom;
5589
5590 -- Added Set_Header_Def_Hdlr_rec for bug 4668200
5591 -- This procedure will set the ONT_Header_Def_Hdlr.g_record with the information in header record.
5592 -- An attribute on line can be defaulted based on a PL/SQL API
5593 -- The API can also refer to ONT_Header_Def_Hdlr.g_record
5594 PROCEDURE Set_Header_Def_Hdlr_Rec (p_header_id IN NUMBER)
5595 IS
5596 l_header_rec OE_Order_PUB.Header_Rec_Type ;
5597 l_rowtype_header_rec OE_AK_ORDER_HEADERS_V%ROWTYPE;
5598 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5599 BEGIN
5600
5601 if l_debug_level >0 then
5602 oe_debug_pub.add(' Entering in OE_Default_Test.Set_Header_Def_Hdlr_Rec with Header Id: '|| p_header_id);
5603 end if ;
5604
5605 IF ( ONT_Header_Def_Hdlr.g_record.header_id IS NULL OR
5606 ONT_Header_Def_Hdlr.g_record.header_id <> p_header_id)
5607 THEN
5608 if OE_ORDER_CACHE.g_header_rec.header_id = p_header_id then
5609 l_header_rec := OE_ORDER_CACHE.g_header_rec ;
5610 else
5611 OE_Header_Util.Query_Row
5612 ( p_header_id => p_header_id
5613 , x_header_rec => l_header_rec );
5614 end if ;
5615
5616 OE_Header_UTIL.API_Rec_To_Rowtype_Rec
5617 ( p_header_rec => l_header_rec
5618 ,x_rowtype_rec => l_rowtype_header_rec);
5619
5620 ONT_Header_Def_Hdlr.g_record := l_rowtype_header_rec ;
5621
5622 if l_debug_level >0 then
5623 oe_debug_pub.add('ONT_Header_Def_Hdlr.g_record.Header_id: '||ONT_Header_Def_Hdlr.g_record.Header_id);
5624 end if ;
5625
5626 END IF ;
5627
5628 if l_debug_level >0 then
5629 oe_debug_pub.add(' Exiting OE_Default_Test.Set_Header_Def_Hdlr_Rec ');
5630 end if ;
5631 EXCEPTION
5632 When Others Then
5633 if l_debug_level >0 then
5634 oe_debug_pub.add(' Exception in OE_Default_Test.Set_Header_Def_Hdlr_Rec ');
5635 end if ;
5636 END Set_Header_Def_Hdlr_Rec ;
5637
5638 END OE_Default_Line;