[Home] [Help]
PACKAGE BODY: APPS.OE_CONFIG_UTIL
Source
1 PACKAGE BODY OE_CONFIG_UTIL AS
2 /* $Header: OEXUCFGB.pls 120.33.12010000.3 2008/11/14 11:27:34 smanian ship $ */
3
4 -- Global constant holding the package name
5 G_PKG_NAME CONSTANT VARCHAR2(30):='Oe_Config_Util';
6
7 /*-----------------------------------------------------------------
8 forward declarations
9 ------------------------------------------------------------------*/
10 PROCEDURE Query_Config
11 ( p_link_to_line_id IN NUMBER := FND_API.G_MISS_NUM
12 , p_top_model_line_id IN NUMBER := FND_API.G_MISS_NUM
13 , p_ato_line_id IN NUMBER := FND_API.G_MISS_NUM
14 , x_line_tbl OUT NOCOPY OE_ORDER_PUB.line_tbl_type);
15
16 Procedure get_transaction_id(p_caller IN VARCHAR2);
17
18 PROCEDURE Print_Time(p_msg IN VARCHAR2);
19
20 PROCEDURE Log_Included_Item_Requests
21 ( p_line_tbl IN OE_Order_Pub.Line_Tbl_Type
22 ,p_booked_flag IN VARCHAR2);
23
24 PROCEDURE Unlock_Config
25 (p_line_rec IN OE_ORDER_PUB.line_rec_type,
26 x_return_status OUT NOCOPY VARCHAR2);
27
28 /*-------------------------------------------------------------------------
29 Procedure Name : Config_Exists
30 Description :
31 --------------------------------------------------------------------------*/
32
33 FUNCTION Config_Exists(p_line_rec IN OE_ORDER_PUB.line_rec_type)
34 RETURN BOOLEAN
35 IS
36 --
37 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
38 --
39 BEGIN
40 RETURN TRUE;
41 END Config_Exists;
42
43 /*------------------------------------------------------------------------
44 Procedure Name : Complete_Config
45 Description : This procedure will cascade the quantity change from the
46 parent to all it's children. Currently, implementing it
47 as a single update statement.
48 ------------------------------------------------------------------------ */
49 Procedure Complete_Config
50 ( p_top_model_line_id IN NUMBER
51 , x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
52 IS
53 --
54 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
55 --
56 BEGIN
57 -- Complete Config Config Using the BOM_EXPLOSIONS
58 -- Populate link_to_line_id
59 -- Populate ato_line_id
60 NULL;
61 END;
62
63
64 /*------------------------------------------------------------------------
65 Procedure Name : Cascade_Changes
66 Description : This procedure will cascade the attribute changes from the
67 top most parent to all it's children, including the
68 included items, even if they are under a class of the
69 top parent. If a parameter is passed with
70 value other than null(te default of the params is null),
71 it indicate that the colums has changed on top parent
72 and needs to be cascaded.
73
74 Change Record:
75 2031256: To populated shipped_quantity and actual_shipment_date
76 on ato child lines.
77
78 Dropship fro config : cascade source type for ato: param15
79 ------------------------------------------------------------------------ */
80
81
82 Procedure Cascade_Changes
83 ( p_parent_line_id IN NUMBER,
84 p_request_rec IN OE_Order_Pub.Request_Rec_Type,
85 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
86 )
87
88 IS
89 -- params sent in request rec.
90 l_item_type_code VARCHAR2(30) := p_request_rec.param7;
91 l_child_item_type VARCHAR2(30);
92 l_old_quantity NUMBER := to_number(p_request_rec.param1);
93 l_new_quantity NUMBER := to_number(p_request_rec.param2);
94 l_change_reason VARCHAR2(100) := p_request_rec.param3;
95 l_change_comments VARCHAR2(2000) := p_request_rec.param4; -- 4495205
96 l_project_id NUMBER := to_number(p_request_rec.param5);
97 l_task_id NUMBER := to_number(p_request_rec.param6);
98 l_ship_tolerance_above NUMBER := to_number(p_request_rec.param11);
99 l_ship_tolerance_below NUMBER := to_number(p_request_rec.param12);
100 l_ship_quantity NUMBER := to_number(p_request_rec.param9);
101 l_set_zero VARCHAR2(1) := 'N';
102 l_ship_to_org_id NUMBER := to_number(p_request_rec.param14);
103 l_request_date DATE := p_request_rec.date_param1;
104 l_promise_date DATE := p_request_rec.date_param2;
105 /* Added the following parameter to fix the bug 2217336 */
106 l_freight_terms_code VARCHAR2(100) := p_request_rec.param16;
107 l_ratio NUMBER;
108 child_line_id NUMBER;
109 l_inv_item_id NUMBER;
110 l_ordered_qty NUMBER;
111 l_shipped_qty NUMBER;
112 l_model_line_id NUMBER;
113 l_model_qty NUMBER;
114 l_model_actual_ship_date DATE;
115 l_parent_line_rec OE_ORDER_PUB.Line_Rec_Type;
116 l_header_id NUMBER := 0;
117
118
119 -- process_order in variables
120 l_control_rec OE_GLOBALS.Control_Rec_Type;
121 l_header_rec OE_Order_PUB.Header_Rec_Type;
122 l_line_rec OE_ORDER_PUB.Line_Rec_Type
123 := OE_ORDER_PUB.G_MISS_LINE_REC;
124 l_old_line_tbl OE_Order_PUB.Line_Tbl_Type;
125 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
126 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
127 l_line_count NUMBER;
128 l_queried_quantity NUMBER;
129
130 CURSOR children is
131 SELECT line_id, inventory_item_id, ordered_quantity, item_type_code,
132 shipped_quantity
133 FROM oe_order_lines
134 WHERE header_id = l_header_id
135 AND open_flag = 'Y'
136 AND ((top_model_line_id = p_parent_line_id
137 and line_id <> p_parent_line_id)
138 OR
139 (l_item_type_code = OE_GLOBALS.G_ITEM_CLASS
140 and ato_line_id = p_parent_line_id
141 and line_id <> p_parent_line_id ));
142
143 -- parent_line_id is either top_model_line_id for models and kits
144 -- or it can be class only for ato sub configs
145 -- in 2nd case we will get children using ato_line_id as a link.
146
147 --
148 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
149 --
150 BEGIN
151
152 IF l_debug_level > 0 THEN
153 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.CASCADE_CHANGES' , 1);
154 oe_debug_pub.add('MODEL OLD QTY: ' ||L_OLD_QUANTITY , 2 );
155 oe_debug_pub.add('MODEL NEW QTY: ' ||L_NEW_QUANTITY , 2 );
156 END IF;
157
158 IF l_old_quantity = 0 THEN
159 IF l_debug_level > 0 THEN
160 oe_debug_pub.add('CASCADE_CHANGES RETURNING , SINCE OLD QTY = 0' , 1);
161 END IF;
162 x_return_status := l_return_status;
163 RETURN;
164 END IF;
165
166 -- insted of modifying cursor, querying the line,
167 -- so that code remains clean.
168
169 OE_Line_Util.Lock_Row( p_line_id => p_parent_line_id
170 ,p_x_line_rec => l_parent_line_rec
171 ,x_return_status => l_return_status);
172
173 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
174 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
175 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
176 RAISE FND_API.G_EXC_ERROR;
177 END IF;
178
179 IF l_item_type_code = OE_GLOBALS.G_ITEM_MODEL THEN
180 l_model_actual_ship_date := l_parent_line_rec.actual_shipment_date;
181 l_model_qty := l_parent_line_rec.ordered_quantity;
182 END IF;
183
184 -- 3603308
185 -- Query to get header_id and order_qty is removed
186 l_header_id := l_parent_line_rec.header_id;
187 l_queried_quantity := l_parent_line_rec.ordered_quantity;
188
189 IF l_new_quantity <> FND_API.G_MISS_NUM THEN
190 IF l_debug_level > 0 THEN
191 OE_DEBUG_PUB.Add('New Quantity is not missing');
192 END IF;
193 l_new_quantity := l_queried_quantity;
194 END IF;
195
196 IF l_debug_level > 0 THEN
197 oe_debug_pub.add('Before opening cursor...',3);
198 oe_debug_pub.add('Hdr ID:'||l_header_id,3);
199 oe_debug_pub.add('Proj:'||l_project_id||' Task Id:'||l_task_id,3);
200 oe_debug_pub.add('New Qty:'||l_new_quantity,3);
201 oe_debug_pub.add('Parent Line:'||p_parent_line_id,3);
202 END IF;
203
204 -- actual processing starts.
205
206 l_line_count := 0;
207 OPEN children ;
208 LOOP
209 FETCH children into child_line_id, l_inv_item_id,
210 l_ordered_qty, l_child_item_type, l_shipped_qty;
211 EXIT when children%NOTFOUND;
212
213 l_line_count := l_line_count + 1;
214 l_line_rec := OE_ORDER_PUB.G_MISS_LINE_REC;
215 l_line_rec.line_id := child_line_id;
216 l_line_rec.inventory_item_id := l_inv_item_id;
217 l_line_rec.ordered_quantity := l_ordered_qty;
218 l_line_rec.shipped_quantity := l_shipped_qty;
219 l_line_rec.item_type_code := l_child_item_type;
220 l_line_tbl(l_line_count) := l_line_rec;
221 END LOOP;
222
223 IF l_line_count = 0 THEN
224 IF l_debug_level > 0 THEN
225 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.CASCADE_CHANGES' , 1);
226 oe_debug_pub.add('NO ROWS TO CASCADE' , 2 );
227 END IF;
228 RETURN;
229 END IF;
230
231 IF l_debug_level > 0 THEN
232 oe_debug_pub.add('NO OF LINES TO CASCADE: '
233 || L_LINE_TBL.COUNT || P_REQUEST_REC.PARAM13 , 2 );
234 oe_debug_pub.add(L_NEW_QUANTITY || ' ' || L_ITEM_TYPE_CODE , 1);
235 END IF;
236
237 IF l_new_quantity = 0 AND
238 (l_item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
239 l_item_type_code = OE_GLOBALS.G_ITEM_KIT)
240 THEN
241 IF l_debug_level > 0 THEN
242 oe_debug_pub.add('DO NOT SUPRESS SCHEDULING' , 3 );
243 END IF;
244 l_set_zero := 'Y';
245 END IF;
246
247 FOR I IN 1..l_line_tbl.count LOOP
248
249 -- 1. ordered quantity
250
251 IF l_new_quantity = 0 AND
252 p_request_rec.param13 = 'N' AND
253 (l_item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
254 l_item_type_code = OE_GLOBALS.G_ITEM_KIT)
255 THEN
256 IF l_line_tbl(I).item_type_code <> OE_GLOBALS.G_ITEM_CONFIG THEN
257 IF l_debug_level > 0 THEN
258 oe_debug_pub.add('NEW QTY 0 ,NOT CANCELLATION ,SO DELETE',1);
259 END IF;
260 l_line_tbl(I).operation := OE_GLOBALS.G_OPR_DELETE;
261 ELSE
262 l_line_tbl(I).operation := OE_GLOBALS.G_OPR_NONE;
263 END IF;
264
265 ELSE -- cancellation
266
267 l_line_tbl(I).OPERATION := OE_GLOBALS.G_OPR_UPDATE;
268
269 -- if qty becomes 0, the options will get cancelled eventually.
270 IF l_debug_level > 0 THEN
271 oe_debug_pub.add('REGULAR CODE , BIG ELSE' , 1);
272 END IF;
273
274 IF (l_line_tbl(I).item_type_code = OE_GLOBALS.G_ITEM_CONFIG AND
275 l_new_quantity = 0)
276 THEN
277 IF l_debug_level > 0 THEN
278 oe_debug_pub.add('DO NOT CASCADE' , 3 );
279 END IF;
280 l_line_tbl(I).operation := OE_GLOBALS.G_OPR_NONE;
281 ELSE
282
283 IF l_old_quantity <> l_new_quantity AND
284 (l_item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
285 l_item_type_code = OE_GLOBALS.G_ITEM_KIT)
286 THEN
287 IF l_debug_level > 0 THEN
288 oe_debug_pub.add('CASCADE_CHANGES , OLD_ORD_QTY: '
289 ||L_LINE_TBL (I).ORDERED_QUANTITY , 2 );
290 END IF;
291
292 l_line_tbl(I).ordered_quantity :=
293 (l_line_tbl(I).ordered_quantity/l_old_quantity) * l_new_quantity;
294
295 /* Start Audit Trail */
296 l_line_tbl(I).change_reason := 'SYSTEM';
297 /* End Audit Trail */
298
299 IF l_debug_level > 0 THEN
300 oe_debug_pub.add(L_LINE_TBL (I).LINE_ID||':'
301 ||L_LINE_TBL (I).INVENTORY_ITEM_ID , 2 );
302 oe_debug_pub.add('NEW_ORD_QTY: '
303 ||L_LINE_TBL (I).ORDERED_QUANTITY , 2 );
304 END IF;
305 END IF;
306
307 END IF; -- qry cancellation cascade
308
309
310 -- 2. project and task.
311
312 IF nvl(l_project_id, -1) <> FND_API.G_MISS_NUM THEN
313 l_line_tbl(I).project_id := l_project_id;
314 IF l_debug_level > 0 THEN
315 oe_debug_pub.add('PROJECT_ID CASCADED, L_LINE_TBL (I).LINE_ID: '
316 || L_PROJECT_ID , 2 );
317 END IF;
318 END IF;
319
320 IF nvl(l_task_id, -1) <> FND_API.G_MISS_NUM THEN
321 l_line_tbl(I).task_id := l_task_id;
322 IF l_debug_level > 0 THEN
323 oe_debug_pub.add('TASK_ID CASCADED FOR,L_LINE_TBL (I).LINE_ID: '
324 || L_TASK_ID , 2 );
325 END IF;
326 END IF;
327
328
329 -- 3. ship_tolerance_above and below
330
331 IF nvl(l_ship_tolerance_above, -1) <> FND_API.G_MISS_NUM THEN
332 l_line_tbl(I).ship_tolerance_above := l_ship_tolerance_above;
333 END IF;
334
335 IF nvl(l_ship_tolerance_below, -1) <> FND_API.G_MISS_NUM THEN
336 l_line_tbl(I).ship_tolerance_below := l_ship_tolerance_below;
337 END IF;
338
339
340 -- 4. shipped_quantity and actual_shipment_date
341
342 IF nvl(l_ship_quantity, -1) <> FND_API.G_MISS_NUM THEN
343 IF l_line_tbl(I).shipped_quantity is null THEN
344 l_line_tbl(I).shipped_quantity :=
345 (l_line_tbl(I).ordered_quantity / l_model_qty) * l_ship_quantity;
346 l_line_tbl(I).actual_shipment_date := l_model_actual_ship_date;
347
348 IF l_debug_level > 0 THEN
349 oe_debug_pub.add('CASCADED SHIPPED QTY , L_LINE_TBL (I).LINE_ID: '
350 || L_LINE_TBL (I).SHIPPED_QUANTITY , 2 );
351 oe_debug_pub.add('CASCADED ACT_SHIP_DATE '
352 || L_LINE_TBL (I).ACTUAL_SHIPMENT_DATE , 2 );
353 END IF;
354 END IF;
355 END IF;
356
357
358 -- 5. ship_to_org_id and request_date
359
360 IF nvl(l_ship_to_org_id, -1)<> FND_API.G_MISS_NUM THEN
361 l_line_tbl(I).ship_to_org_id := l_ship_to_org_id;
362 IF l_debug_level > 0 THEN
363 oe_debug_pub.add('SHIP TO CASCADED , LINE_ID: '
364 || L_SHIP_TO_ORG_ID , 2 );
365 END IF;
366 END IF;
367
368 IF nvl(l_request_date, sysdate) <> FND_API.G_MISS_DATE THEN
369 l_line_tbl(I).request_date := l_request_date;
370 IF l_debug_level > 0 THEN
371 oe_debug_pub.add('REQUEST_DATE CASCADED , REQUEST_DATE: '
372 || L_REQUEST_DATE , 2 );
373 END IF;
374 END IF;
375
376 -- 6. source_type_code for ato configurations.
377
378 IF nvl(p_request_rec.param15, 'X')<> FND_API.G_MISS_CHAR THEN
379 l_line_tbl(I).source_type_code := p_request_rec.param15;
380 IF l_debug_level > 0 THEN
381 oe_debug_pub.add('SOURCE_TYPE CASCADED: '
382 || P_REQUEST_REC.PARAM15 , 2 );
383 END IF;
384 END IF;
385
386
387 /* Added the following logic to fix the bug 2217336 */
388 -- 7. freight_terms_code for ato configurations.
389
390 IF nvl(l_freight_terms_code, 'X')<> FND_API.G_MISS_CHAR THEN
391 l_line_tbl(I).freight_terms_code := l_freight_terms_code ;
392 IF l_debug_level > 0 THEN
393 oe_debug_pub.add('FREIGHT_TERMS_CODE CASCADED: '
394 || L_FREIGHT_TERMS_CODE , 2 );
395 END IF;
396 END IF;
397
398 -- 8. Promise date
399
400 IF nvl(l_promise_date, sysdate) <> FND_API.G_MISS_DATE THEN
401 l_line_tbl(I).promise_date := l_promise_date;
402 IF l_debug_level > 0 THEN
403 oe_debug_pub.add('PROMISE DATE OCASCADED , PROMISE_DATE: '
404 || L_PROMISE_DATE , 2 );
405 END IF;
406 END IF;
407
408 END IF; -- if cancellation.
409
410 END LOOP;
411
412
413 -- Call Process Order to update the record.
414
415 -- Set control flags.
416
417 l_control_rec.controlled_operation := TRUE;
418 l_control_rec.change_attributes := TRUE;
419 l_control_rec.default_attributes := TRUE;
420 l_control_rec.validate_entity := TRUE;
421 l_control_rec.check_security := TRUE;
422 l_control_rec.write_to_DB := TRUE;
423 l_control_rec.validate_entity := TRUE;
424 l_control_rec.process := FALSE;
425 l_control_rec.clear_dependents := TRUE;
426
427 -- Instruct API to retain its caches
428
429 l_control_rec.clear_api_cache := FALSE;
430 l_control_rec.clear_api_requests := FALSE;
431
432 l_header_rec.operation := OE_GLOBALS.G_OPR_NONE;
433
434 -- Set the Recursive Call Constant to 'Y' to avoid the recursive
435 -- call to cascading while making this call to process order
436
437 OE_CONFIG_UTIL.CASCADE_CHANGES_FLAG := 'Y';
438
439 -- Set the Validate_config Call Constant to 'N' to avoid the validation
440
441 OE_CONFIG_PVT.OECFG_VALIDATE_CONFIG := 'N';
442
443 -- Set the scheduling flag to 'N', do not schedule in a recursive call.
444
445 -- bug fix 1607036
446 IF l_set_zero = 'N' AND
447 nvl(l_parent_line_rec.ship_model_complete_flag, 'Y') <> 'N'
448 THEN
449 IF l_debug_level > 0 THEN
450 oe_debug_pub.add('SCHEDULE FLAG SET TO N' , 5 );
451 END IF;
452 -- 4504362
453 OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING := 'N';
454 OE_ORDER_SCH_UTIL.OESCH_PERFORM_SCHEDULING := 'N';
455 END IF;
456
457 IF l_debug_level > 0 THEN
458 oe_debug_pub.add('CALLING PROCESS ORDER' , 2 );
459 END IF;
460
461 -- Call OE_Order_PVT.Process_order
462
463 OE_ORDER_PVT.Lines
464 (p_validation_level => FND_API.G_VALID_LEVEL_NONE
465 ,p_control_rec => l_control_rec
466 ,p_x_line_tbl => l_line_tbl
467 ,p_x_old_line_tbl => l_old_line_tbl
468 ,x_return_status => l_return_status);
469
470
471 IF l_debug_level > 0 THEN
472 oe_debug_pub.add('IN CASCADE CHANGES AFTER CALLING PROCESS ORDER' , 2 );
473 oe_debug_pub.add('L_RETURN_STATUS IS ' || L_RETURN_STATUS , 1);
474 END IF;
475
476 -- Resetting the Recursive Call Constant to 'N'
477 OE_CONFIG_UTIL.CASCADE_CHANGES_FLAG := 'N';
478
479 -- Resetting the Validation Constant to 'Y'
480 OE_CONFIG_PVT.OECFG_VALIDATE_CONFIG := 'Y';
481
482 -- Set it back to 'Y'
483 -- 4504362
484 OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING := 'Y';
485 OE_ORDER_SCH_UTIL.OESCH_PERFORM_SCHEDULING := 'Y';
486
487 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
488 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
489 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
490 RAISE FND_API.G_EXC_ERROR;
491 END IF;
492
493 -- process_order call successful, and this was decrement to 0.
494 IF l_set_zero = 'Y' THEN
495
496 -- Instance Unlocking.
497
498 IF l_debug_level > 0 THEN
499 oe_debug_pub.add('Before calling Unlock_Config for parent line.' , 3 );
500 END IF;
501 IF l_parent_line_rec.item_type_code = 'MODEL'
502 AND l_parent_line_rec.Booked_flag = 'Y' THEN
503
504 Unlock_Config(p_line_rec => l_parent_line_rec,
505 x_return_status => l_return_status);
506
507 oe_debug_pub.add('After calling Unlock_Config for parent line ' || l_return_status , 3 );
508 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
509 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
510 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
511 RAISE FND_API.G_EXC_ERROR;
512 END IF;
513 END IF;
514 -- Instance Unlocking
515
516 UPDATE oe_order_lines
517 SET config_header_id = null,
518 config_rev_nbr = null,
519 configuration_id = null,
520 lock_control = lock_control + 1
521 WHERE top_model_line_id = p_parent_line_id;
522
523 IF SQL%FOUND THEN
524 IF l_debug_level > 0 THEN
525 oe_debug_pub.add('CONFIG IDS SET TO NULL' , 3 );
526 END IF;
527 END IF;
528
529 -- delete the SPC configuration data.
530 OE_Config_Pvt.Delete_Config
531 ( p_config_hdr_id => l_parent_line_rec.config_header_id
532 ,p_config_rev_nbr => l_parent_line_rec.config_rev_nbr
533 ,x_return_status => l_return_status);
534
535 END IF;
536
537 OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
538
539 /* added for 2653505 */
540 IF OE_CODE_CONTROL.get_code_release_level < '110508' THEN
541 OE_ORDER_PVT.Process_Requests_And_notify
542 ( p_process_requests => FALSE
543 ,p_notify => TRUE
544 ,x_return_status => l_return_status
545 ,p_line_tbl => l_line_tbl
546 ,p_old_line_tbl => l_old_line_tbl);
547
548 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
549 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
550 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
551 RAISE FND_API.G_EXC_ERROR;
552 END IF;
553 END IF;
554
555 x_return_status := l_return_status;
556
557 IF l_debug_level > 0 THEN
558 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.CASCADE_CHANGES' , 1);
559 END IF;
560
561 EXCEPTION
562 WHEN OTHERS THEN
563 IF l_debug_level > 0 THEN
564 oe_debug_pub.add('CASCADE_CHANGES ERROR '|| SQLERRM , 1);
565 END IF;
566 RAISE;
567 END;
568
569
570 /*----------------------------------------------------------------------
571 Procedure Name : Query_Config_Line
572 Description :
573 -----------------------------------------------------------------------*/
574
575 PROCEDURE Query_Config_Line
576 (p_parent_line_id IN NUMBER
577 ,x_line_rec OUT NOCOPY OE_ORDER_PUB.line_rec_type)
578 IS
579 l_line_rec OE_ORDER_PUB.line_rec_type;
580 --
581 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
582 --
583 BEGIN
584 x_line_rec := l_line_rec;
585 END;
586
587 /*------------------------------------------------------------------------
588 Procedure Name : Change_Configuration
589 Description : This procedure will change certain attributes across
590 the whole configuration, when the attribute is changed
591 even on one line of the configuration.
592 E.g.: If the warehouse changes on a ATO option, all the
593 lines of the ATO model should reflect the same
594 warehouse. Same is true if the change took place
595 on an option of a Ship model complete PTO.
596 The attributes which we currently maintain same
597 across an ATO or a SMC PTO are:
598 1. Ship From Org
599 2. Ship To Org
600 3. Request Date
601 4. Schedule Ship Date
602 This procedure will be called only if the line is not
603 scheduled. If the line is scheduled and any of the above
604 attributes change, then scheduling code will take
605 care of change across the configuration.
606 ------------------------------------------------------------------------ */
607
608 Procedure Change_Configuration
609 ( p_request_rec IN OE_Order_Pub.Request_Rec_Type,
610 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
611 )
612
613 IS
614 -- params sent in request rec.
615 l_changed_line_rec OE_ORDER_PUB.Line_Rec_Type;
616 l_top_model_line_id NUMBER;
617 l_ato_line_id NUMBER;
618 l_line_id NUMBER;
619 l_count NUMBER:=0;
620 l_header_id NUMBER := 0;
621
622 -- Process Order Variables
623 l_control_rec OE_GLOBALS.Control_Rec_Type;
624 l_header_rec OE_Order_PUB.Header_Rec_Type;
625 l_line_rec OE_ORDER_PUB.Line_Rec_Type
626 := OE_ORDER_PUB.G_MISS_LINE_REC;
627 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
628 l_old_line_tbl OE_Order_PUB.Line_Tbl_Type;
629
630 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
631
632 CURSOR configuration_line(p_header_id IN NUMBER,
633 p_top_model_line_id IN NUMBER,
634 p_ato_line_id IN NUMBER,
635 p_line_id IN NUMBER)
636 IS
637 SELECT line_id
638 FROM oe_order_lines
639 WHERE((top_model_line_id = p_top_model_line_id
640 and line_id <> p_line_id)
641 OR (ato_line_id = p_ato_line_id and
642 line_id <> p_line_id ))
643 AND open_flag = 'Y';
644
645 -- parent_line_id is either top_model_line_id for models and kits
646 -- or it can be class only for ato sub configs
647 -- in 2nd case we will get children using ato_line_id as a link.
648
649 --
650 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
651 --
652 BEGIN
653
654 IF l_debug_level > 0 THEN
655 oe_debug_pub.add('ENTERING OE_CONGIG_UTIL.CHANGE_CONFIGURATION' , 1);
656 END IF;
657
658 -- insted of modifying cursor, querying the line,
659 -- so that code remains clean.
660
661 OE_LINE_UTIL.Lock_Row(p_line_id => p_request_rec.param1,
662 p_x_line_rec => l_changed_line_rec,
663 x_return_status => l_return_status);
664
665 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
666 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
667 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
668 RAISE FND_API.G_EXC_ERROR;
669 END IF;
670
671 l_line_id := l_changed_line_rec.line_id;
672 l_header_id := l_changed_line_rec.header_id;
673
674 IF nvl(l_changed_line_rec.ship_model_complete_flag,'N') = 'N' THEN
675 l_ato_line_id := l_changed_line_rec.ato_line_id;
676 l_top_model_line_id := null;
677 ELSE
678 l_top_model_line_id := l_changed_line_rec.top_model_line_id;
679 l_ato_line_id := null;
680 END IF;
681
682 OPEN configuration_line(l_header_id,
683 l_top_model_line_id,
684 l_ato_line_id,
685 l_line_id);
686 LOOP
687 FETCH configuration_line into l_line_id;
688 EXIT when configuration_line%NOTFOUND;
689 l_line_rec := OE_ORDER_PUB.G_MISS_LINE_REC;
690 l_line_rec.line_id := l_line_id;
691 l_line_rec.ship_from_org_id := l_changed_line_rec.ship_from_org_id;
692 l_line_rec.ship_to_org_id := l_changed_line_rec.ship_to_org_id;
693 l_line_rec.request_date := l_changed_line_rec.request_date;
694 l_line_rec.shipping_method_code
695 := l_changed_line_rec.shipping_method_code;
696 l_line_rec.freight_carrier_code
697 := l_changed_line_rec.freight_carrier_code;
698 l_line_rec.shipment_priority_code
699 := l_changed_line_rec.shipment_priority_code;
700 l_line_rec.demand_class_code := l_changed_line_rec.demand_class_code;
701
702 -- Start Audit Trail
703 l_line_rec.change_reason := 'SYSTEM';
704 -- End Audit Trail
705
706 l_line_rec.OPERATION := OE_GLOBALS.G_OPR_UPDATE;
707 l_count := l_count + 1;
708 l_line_tbl(l_count) := l_line_rec;
709 END LOOP;
710
711 IF l_count = 0 THEN
712 IF l_debug_level > 0 THEN
713 oe_debug_pub.add('EXITING OE_CONGIG_UTIL.CHANGE_CONFIGURATION' , 1);
714 oe_debug_pub.add('NO ROWS TO PASS TO PROCESS_ORDER' , 2 );
715 END IF;
716 RETURN;
717 END IF;
718
719 -- Call Process Order to update the record.
720
721 -- Set control flags.
722
723 l_control_rec.controlled_operation := TRUE;
724 l_control_rec.change_attributes := TRUE;
725 l_control_rec.default_attributes := TRUE;
726 l_control_rec.validate_entity := TRUE;
727 l_control_rec.check_security := TRUE; --FALSE;
728 l_control_rec.write_to_DB := TRUE;
729 l_control_rec.validate_entity := TRUE;
730 l_control_rec.process := FALSE;
731 l_control_rec.clear_dependents := TRUE;
732
733 -- Instruct API to retain its caches
734
735 l_control_rec.clear_api_cache := FALSE;
736 l_control_rec.clear_api_requests := FALSE;
737
738 l_header_rec.operation := OE_GLOBALS.G_OPR_NONE;
739
740 -- Set the Change Configuration flag 'N' to avoid the recursive
741 -- call to changin configuration while making this call to process order
742 OE_GLOBALS.G_CHANGE_CFG_FLAG := 'N';
743
744 -- Set recursion mode.
745 -- OE_GLOBALS.G_RECURSION_MODE := 'Y';
746
747 -- Set the scheduling flag to 'N', do not schedule in a recursive call.
748 -- 4504362
749 OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING := 'N';
750 OE_ORDER_SCH_UTIL.OESCH_PERFORM_SCHEDULING := 'N';
751
752 IF l_debug_level > 0 THEN
753 oe_debug_pub.add('CALLING PROCESS ORDER WITH LINES: '
754 || L_LINE_TBL.COUNT , 2 );
755 END IF;
756
757 OE_ORDER_PVT.Lines
758 (p_validation_level => FND_API.G_VALID_LEVEL_NONE
759 ,p_control_rec => l_control_rec
760 ,p_x_line_tbl => l_line_tbl
761 ,p_x_old_line_tbl => l_old_line_tbl
762 ,x_return_status => l_return_status);
763
764
765 -- Set it back to 'Y'
766 -- 4504362
767 OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING := 'Y';
768 OE_ORDER_SCH_UTIL.OESCH_PERFORM_SCHEDULING := 'Y';
769
770 -- Resetting the Change Configuration flag 'Y'
771 OE_GLOBALS.G_CHANGE_CFG_FLAG := 'Y';
772
773 -- Resetting the Recursive Call Constant to 'N'
774 OE_CONFIG_UTIL.CASCADE_CHANGES_FLAG := 'N';
775
776 -- ReSet recursion mode.
777 --OE_GLOBALS.G_RECURSION_MODE := 'N';
778
779 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
780 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
781 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
782 RAISE FND_API.G_EXC_ERROR;
783 END IF;
784
785 -- added for 2653505
786 IF OE_CODE_CONTROL.get_code_release_level < '110508' THEN
787 OE_ORDER_PVT.Process_Requests_And_notify
788 ( p_process_requests => FALSE
789 ,p_notify => TRUE
790 ,x_return_status => l_return_status
791 ,p_line_tbl => l_line_tbl
792 ,p_old_line_tbl => l_old_line_tbl);
793
794 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
795 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
796 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
797 RAISE FND_API.G_EXC_ERROR;
798 END IF;
799 END IF;
800
801 -- Setting G_CASCADING_REQUEST_LOGGED to requery the lines in the form
802 -- not reqd, done in vreqb.
803 OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
804
805 x_return_status := l_return_status;
806
807 IF l_debug_level > 0 THEN
808 oe_debug_pub.add('EXITING OE_CONGIG_UTIL.CHANGE_CONFIGURATION' , 1);
809 END IF;
810
811 END Change_Configuration;
812
813 /*----------------------------------------------------------------------
814 Procedure Name : Delink_Config
815 Description :
816 -----------------------------------------------------------------------*/
817 Procedure Delink_Config
818 ( p_line_id IN NUMBER
819 , x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
820 IS
821
822 -- process_order in variables
823 l_control_rec OE_GLOBALS.Control_Rec_Type;
824 l_header_rec OE_Order_PUB.Header_Rec_Type;
825 l_line_rec OE_ORDER_PUB.Line_Rec_Type
826 := OE_ORDER_PUB.G_MISS_LINE_REC;
827 l_old_line_tbl OE_Order_PUB.Line_Tbl_Type;
828 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
829
830 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
831 l_msg_count NUMBER;
832 l_msg_data VARCHAR2(2000);
833
834 l_line_num VARCHAR2(20);
835 l_po_header_id NUMBER;
836 --bug 4411054
837 --l_po_status VARCHAR2(4100);
838 l_po_status_rec PO_STATUS_REC_TYPE;
839 l_autorization_status VARCHAR2(30);
840
841 --
842 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
843 --
844 BEGIN
845 OE_LINE_UTIL.Lock_Row(p_line_id => p_line_id
846 ,p_x_line_rec => l_line_rec
847 ,x_return_status => l_return_status);
848
849 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
850 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
851 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
852 RAISE FND_API.G_EXC_ERROR;
853 END IF;
854
855 IF l_debug_level > 0 THEN
856 oe_debug_pub.add('ENTERING OE_CONGIG_UTIL.DELINK_CONFIG' , 1);
857 END IF;
858
859 -- Changes for Enhanced DropShipments. Prevent Delink
860 -- if the PO associated with config item is Approved.
861
862 -- #5252929, the following PO-APPROVED check is now disabled. Now the
863 -- check is done only when user chooses Action->Delink from the SO pad
864 -- and that check is done in OEXOECFG.pld.
865 -- Here we donot want to check becuase the constraint check is already
866 -- done at the Model level. If the user disables that constarint then
867 -- the delink should take place. Please see bug for further details.
868
869 /* IF PO_CODE_RELEASE_GRP.Current_Release >=
870 PO_CODE_RELEASE_GRP.PRC_11i_Family_Pack_J AND
871 OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' AND
872 l_line_rec.source_type_code = 'EXTERNAL' THEN
873
874 BEGIN
875 SELECT po_header_id
876 INTO l_po_header_id
877 FROM oe_drop_ship_sources
878 WHERE line_id = l_line_rec.line_id
879 AND header_id = l_line_rec.header_id;
880 EXCEPTION
881 WHEN NO_DATA_FOUND THEN
882 IF l_debug_level > 0 THEN
883 OE_DEBUG_PUB.Add('PO Not Created for Config.:'||
884 l_line_rec.line_id , 2 );
885 END IF;
886 END;
887
888 IF l_po_header_id is not null THEN
889
890 PO_DOCUMENT_CHECKS_GRP.po_status_check
891 (p_api_version => 1.0
892 , p_header_id => l_po_header_id
893 , p_mode => 'GET_STATUS'
894 , x_po_status_rec => l_po_status_rec
895 , x_return_status => l_return_status);
896
897 IF(l_return_status = FND_API.G_RET_STS_SUCCESS) THEN
898 l_autorization_status := l_po_status_rec.authorization_status(1);
899
900 IF l_debug_level > 0 THEN
901 OE_DEBUG_PUB.Add('Sucess call from PO_DOCUMENT_CHECKS_GRP.po_status_check',2);
902 OE_DEBUG_PUB.Add('Check PO Status : '|| l_autorization_status, 2);
903 END IF;
904 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
905 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
906 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
907 RAISE FND_API.G_EXC_ERROR;
908 END IF;
909
910 END IF;
911
912 --IF (INSTR(nvl(l_po_status,'z'), 'APPROVED') <> 0 ) THEN
913 IF (nvl(l_autorization_status,'z')= 'APPROVED') THEN
914 l_line_num := RTRIM(l_line_rec.line_number||'.'||
915 l_line_rec.shipment_number||'.'||
916 l_line_rec.option_number||'.'||
917 l_line_rec.component_number||'.'||
918 l_line_rec.service_number,'.');
919 FND_MESSAGE.Set_Name('ONT', 'ONT_DELINK_NOT_ALLOWED');
920 FND_MESSAGE.Set_Token('LINE_NUM', l_line_num);
921 FND_MESSAGE.Set_Token('MODEL', l_line_rec.ordered_item);
922 OE_MSG_PUB.Add;
923 RETURN;
924 END IF;
925
926 END IF; */
927
928 l_line_rec := OE_ORDER_PUB.G_MISS_LINE_REC;
929 l_line_rec.line_id := p_line_id;
930 l_line_rec.operation := OE_GLOBALS.G_OPR_DELETE;
931 l_line_tbl(1) := l_line_rec;
932
933 -- check_security is made false so that
934 -- we can delete the config line overriding the constraint.
935
936 l_control_rec.controlled_operation := TRUE;
937 l_control_rec.change_attributes := TRUE;
938 l_control_rec.default_attributes := TRUE;
939 l_control_rec.validate_entity := TRUE;
940 l_control_rec.check_security := FALSE;
941 l_control_rec.write_to_DB := TRUE;
942 l_control_rec.process := TRUE;
943 l_control_rec.clear_dependents := TRUE;
944
945 -- Instruct API to retain its caches
946
947 l_control_rec.clear_api_cache := FALSE;
948 l_control_rec.clear_api_requests := FALSE;
949
950 l_header_rec.operation := OE_GLOBALS.G_OPR_NONE;
951
952 IF l_debug_level > 0 THEN
953 oe_debug_pub.add(' ' , 3 );
954 oe_debug_pub.add('IN DELINK_CONFIG CALLING PROCESS ORDER' , 3 );
955 oe_debug_pub.add('IN DELINK_CONFIG AFTER CALL TO PROCESS ORDER' , 3 );
956 oe_debug_pub.add('L_RETURN_STATUS IS: ' || L_RETURN_STATUS , 2 );
957 END IF;
958
959 OE_ORDER_PVT.Lines
960 (p_validation_level => FND_API.G_VALID_LEVEL_NONE
961 ,p_control_rec => l_control_rec
962 ,p_x_line_tbl => l_line_tbl
963 ,p_x_old_line_tbl => l_old_line_tbl
964 ,x_return_status => l_return_status);
965
966
967 -- count and get
968 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
969 IF l_debug_level > 0 THEN
970 oe_debug_pub.add('STATUS:' || L_RETURN_STATUS , 3 );
971 END IF;
972 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
973 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
974 IF l_debug_level > 0 THEN
975 oe_debug_pub.add('STATUS:' || L_RETURN_STATUS , 3 );
976 END IF;
977 RAISE FND_API.G_EXC_ERROR;
978 END IF;
979
980 -- Call Notify OC, required ****************************
981
982 OE_ORDER_PVT.Process_Requests_And_notify
983 (p_process_requests => TRUE
984 ,p_notify => TRUE
985 ,x_return_status => l_return_status
986 ,p_line_tbl => l_line_tbl
987 ,p_old_line_tbl => l_old_line_tbl);
988
989 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
990 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
991 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
992 RAISE FND_API.G_EXC_ERROR;
993 END IF;
994
995 oe_msg_pub.count_and_get
996 ( p_count => l_msg_count
997 ,p_data => l_msg_data );
998
999 -- if everything is OK.
1000 x_return_status := FND_API.G_RET_STS_SUCCESS;
1001
1002 IF l_debug_level > 0 THEN
1003 oe_debug_pub.add('IN OE_CONFIG_UTI.DELINK , X_RETURN_STATUS'
1004 ||X_RETURN_STATUS , 2 );
1005 oe_debug_pub.add('EXITING OE_CONGIG_UTIL.DELINK_CONFIG' , 1);
1006 END IF;
1007
1008 EXCEPTION
1009 WHEN FND_API.G_EXC_ERROR THEN
1010
1011 x_return_status := FND_API.G_RET_STS_ERROR;
1012 -- Get message count and data
1013 oe_msg_pub.count_and_get
1014 ( p_count => l_msg_count
1015 , p_data => l_msg_data
1016 );
1017
1018 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1019
1020 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1021 -- Get message count and data
1022 oe_msg_pub.count_and_get
1023 ( p_count => l_msg_count
1024 , p_data => l_msg_data
1025 );
1026
1027 WHEN OTHERS THEN
1028 IF l_debug_level > 0 THEN
1029 oe_debug_pub.add('ERROR: ' || SUBSTR ( SQLERRM , 1 , 100 ) , 1);
1030 END IF;
1031
1032 IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
1033 THEN
1034 oe_msg_pub.Add_Exc_Msg
1035 ( G_PKG_NAME
1036 , 'Oe_Config_Util'
1037 );
1038 END IF;
1039
1040 -- Get message count and data
1041 oe_msg_pub.count_and_get
1042 ( p_count => l_msg_count
1043 , p_data => l_msg_data
1044 );
1045 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1046
1047 END Delink_Config;
1048
1049
1050
1051 /*----------------------------------------------------------------------
1052 Procedure Name : Validate_Cfgs_In_Order
1053 Description : checks if the models in the order
1054 are complete and valid
1055 -----------------------------------------------------------------------*/
1056 FUNCTION Validate_Cfgs_In_Order(p_header_id IN NUMBER)
1057 RETURN VARCHAR2
1058 IS
1059 l_line_id number := null;
1060 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
1061 l_valid_config VARCHAR2(10);
1062 l_complete_config VARCHAR2(10);
1063
1064 -- Instance locking changes
1065
1066 l_booked_flag VARCHAR2(1);
1067 l_config_header_id NUMBER;
1068 l_config_rev_nbr NUMBER;
1069 l_configuration_id NUMBER;
1070 l_top_container VARCHAR2(1);
1071 l_part_of_container VARCHAR2(1);
1072 l_locking_key NUMBER;
1073 l_msg_count NUMBER;
1074 l_msg_data VARCHAR2(4000);
1075 l_order_number NUMBER;
1076
1077 -- Instance locking changes.
1078
1079 CURSOR models is
1080 SELECT line_id,config_header_id,config_rev_nbr,
1081 configuration_id,booked_flag
1082 FROM oe_order_lines
1083 WHERE item_type_code = OE_GLOBALS.G_ITEM_MODEL
1084 AND header_id = p_header_id
1085 AND open_flag = 'Y';
1086
1087 --
1088 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1089 --
1090 BEGIN
1091
1092 IF l_debug_level > 0 THEN
1093 oe_debug_pub.add('ENTERING OE_CONGIG_UTIL.VALIDATE_CFGS_IN_ORDER' , 1);
1094 END IF;
1095 --get_transaction_id(p_caller => 'before validate_cfgs');
1096
1097 OPEN models;
1098
1099 LOOP
1100 FETCH models
1101 into l_line_id,l_config_header_id,l_config_rev_nbr,
1102 l_configuration_id,l_booked_flag;
1103
1104 EXIT WHEN MODELS%NOTFOUND;
1105
1106 Oe_Config_Util.validate_configuration
1107 ( p_model_line_id => l_line_id,
1108 p_validate_flag => 'Y',
1109 p_complete_flag => 'Y',
1110 p_caller => 'BOOKING',
1111 x_valid_config => l_valid_config,
1112 x_complete_config => l_complete_config,
1113 x_return_status => l_return_status);
1114
1115 -- if the valid or complete flag is false, we error out.
1116
1117 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1118 --get_transaction_id(p_caller => 'after call to validate_cfgs');
1119 RETURN l_return_status ;
1120 ELSE
1121 IF LOWER(l_valid_config) = 'false' OR
1122 LOWER(l_complete_config) = 'false' THEN
1123 IF l_debug_level > 0 THEN
1124 oe_debug_pub.add('RETURN_STATUS SUCCESS,BUT INVALID/INCOMPLETE',2);
1125 END IF;
1126 RETURN FND_API.G_RET_STS_ERROR;
1127 END IF;
1128 END IF;
1129
1130 -- Instance locking
1131 IF l_booked_flag = 'Y' THEN
1132
1133 IF l_debug_level > 0 THEN
1134
1135 oe_debug_pub.add(' Before calling Is part of container model ' || l_line_id, 2);
1136
1137 END IF;
1138
1139 OE_CONFIG_TSO_PVT.Is_Part_Of_Container_Model
1140 ( p_line_id => l_line_id
1141 ,p_top_model_line_id => l_line_id
1142 ,x_top_container_model => l_top_container
1143 ,x_part_of_container => l_part_of_container );
1144
1145 IF l_top_container = 'Y' THEN
1146
1147 -- BV code must have changed the rev number. Therefore we have to
1148 -- re-fetch the value to pass it to lock api.
1149 BEGIN
1150 Select config_rev_nbr
1151 Into l_config_rev_nbr
1152 From oe_order_lines_all
1153 Where line_id = l_line_id;
1154 END;
1155
1156 l_order_number := OE_SCHEDULE_UTIL.Get_Order_Number(p_header_id);
1157
1158 IF l_debug_level > 0 THEN
1159
1160 oe_debug_pub.add(' Calling lock_Config' || l_config_header_id, 2);
1161 oe_debug_pub.add(' Config rev nbr' || l_config_rev_nbr, 2);
1162 oe_debug_pub.add(' Configuration_id ' || l_configuration_id, 2);
1163 oe_debug_pub.add(' Order Number ' || l_order_number, 2);
1164
1165 END IF;
1166
1167 CZ_IB_LOCKING.Lock_Config
1168 ( p_api_version => 1.0,
1169 p_config_session_hdr_id => l_config_header_id,
1170 p_config_session_rev_nbr => l_config_rev_nbr,
1171 p_config_session_item_id => Null,
1172 p_source_application_id => fnd_profile.value('RESP_APPL_ID'),
1173 p_source_header_ref => l_order_number,
1174 p_source_line_ref1 => Null,
1175 p_source_line_ref2 => Null,
1176 p_source_line_ref3 => Null,
1177 p_commit => 'N',
1178 p_init_msg_list => FND_API.G_TRUE,
1179 p_validation_level => Null,
1180 x_locking_key => l_locking_key,
1181 x_return_status => l_return_status,
1182 x_msg_count => l_msg_count,
1183 x_msg_data => l_msg_data);
1184
1185 IF l_debug_level > 0 THEN
1186 oe_debug_pub.add(' After calling CZ lock API ' || l_return_status || l_msg_data,2);
1187 END IF;
1188 IF l_msg_count > 0 THEN
1189 OE_MSG_PUB.Transfer_Msg_stack;
1190
1191 END IF;
1192 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1193 RETURN l_return_status;
1194 END IF;
1195
1196 END IF; -- Container
1197 END IF; -- Booked Flag
1198 -- Instance locking.
1199 END LOOP;
1200
1201 CLOSE models;
1202
1203 IF l_debug_level > 0 THEN
1204 oe_debug_pub.add('LEAVING VALIDATE_CFGS_IN_ORDER:' || L_RETURN_STATUS ,2);
1205 oe_debug_pub.add('EXITING OE_CONGIG_UTIL.VALIDATE_CFGS_IN_ORDER' , 1);
1206 END IF;
1207 --get_transaction_id(p_caller => 'leaving validate_cfgs');
1208
1209 RETURN l_return_status;
1210 END Validate_Cfgs_In_Order;
1211
1212 /*----------------------------------------------------------------------
1213 Procedure Name : Freeze_Inc_Items_For_Order
1214 Description :
1215
1216 Change Record:
1217 Calling process_included_items directly w/o call to
1218 freeze_included_items.
1219 -----------------------------------------------------------------------*/
1220 FUNCTION Freeze_Inc_Items_for_Order(p_header_id IN NUMBER)
1221 RETURN VARCHAR2
1222 IS
1223 l_line_id NUMBER;
1224 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
1225
1226 CURSOR order_lines is
1227 SELECT line_id
1228 FROM oe_order_lines
1229 WHERE item_type_code in (OE_GLOBALS.G_ITEM_MODEL,
1230 OE_GLOBALS.G_ITEM_CLASS,
1231 OE_GLOBALS.G_ITEM_KIT)
1232 AND open_flag = 'Y'
1233 AND header_id = p_header_id;
1234
1235 --
1236 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1237 --
1238 BEGIN
1239
1240 IF l_debug_level > 0 THEN
1241 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.FREEZE_INC_ITEMS_FOR_ORDER' , 1);
1242 END IF;
1243
1244 OPEN order_lines;
1245
1246 LOOP
1247 FETCH order_lines
1248 into l_line_id;
1249 EXIT WHEN ORDER_LINES%NOTFOUND;
1250
1251 l_return_status := Oe_Config_Util.Process_included_items
1252 ( p_line_id => l_line_id
1253 ,p_freeze => TRUE);
1254
1255 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1256 RETURN l_return_status ;
1257 END IF;
1258 END LOOP;
1259
1260 CLOSE order_lines;
1261
1262 IF l_debug_level > 0 THEN
1263 oe_debug_pub.add('LEAVING FREEZE_INC_ITEMS_FOR_ORDER:'
1264 || L_RETURN_STATUS , 2 );
1265 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.FREEZE_INC_ITEMS_FOR_ORDER' , 1);
1266 END IF;
1267 RETURN l_return_status;
1268 END Freeze_Inc_Items_for_Order;
1269
1270 /*----------------------------------------------------------------------
1271 Procedure Name : Validate_Configuration_upg
1272
1273 ----------------------------------------------------------------------*/
1274
1275 PROCEDURE Validate_Configuration_upg
1276 (p_model_line_id IN NUMBER,
1277 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
1278
1279 IS
1280 l_valid_config VARCHAR2(10);
1281 l_complete_config VARCHAR2(10);
1282 l_return_status VARCHAR2(1);
1283 --
1284 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1285 --
1286 BEGIN
1287 Oe_Config_Util.Validate_Configuration
1288 (p_model_line_id => p_model_line_id,
1289 x_valid_config => l_valid_config,
1290 x_complete_config => l_complete_config,
1291 x_return_status => l_return_status);
1292
1293 x_return_status := l_return_status;
1294 END;
1295
1296
1297 /*----------------------------------------------------------------------
1298 forward declarations
1299 ----------------------------------------------------------------------*/
1300
1301 PROCEDURE Complete_Configuration
1302 (p_top_model_line_id IN NUMBER,
1303 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2);
1304
1305
1306 PROCEDURE Cascade_Qty
1307 ( p_x_options_tbl IN OUT NOCOPY Oe_Process_Options_Pvt.Selected_Options_Tbl_Type
1308 ,p_component_code IN VARCHAR2
1309 ,p_ratio IN NUMBER
1310 -- 4211654
1311 ,p_new_qty in number
1312 ,p_old_qty in number
1313 ,p_change_reason IN VARCHAR2
1314 ,p_change_comments IN VARCHAR2);
1315
1316
1317 PROCEDURE Delete_Children
1318 (p_x_options_tbl IN OUT NOCOPY Oe_Process_Options_Pvt.Selected_Options_Tbl_Type
1319 ,p_component_code IN VARCHAR2
1320 ,p_parent_item IN VARCHAR2);
1321
1322
1323 PROCEDURE Delete_Parent
1324 (p_x_options_tbl IN OUT NOCOPY Oe_Process_Options_Pvt.Selected_Options_Tbl_Type
1325 ,p_component_code IN VARCHAR2
1326 ,p_top_model_line_id IN NUMBER
1327 ,p_model_component IN VARCHAR2
1328 ,p_ui_flag IN VARCHAR2 := 'N');
1329
1330
1331 FUNCTION No_More_Children_Left
1332 (p_x_options_tbl IN Oe_Process_Options_Pvt.Selected_Options_Tbl_Type
1333 ,p_component_code IN VARCHAR2
1334 ,p_top_model_line_id IN NUMBER
1335 ,p_model_component IN VARCHAR2
1336 ,p_ui_flag IN VARCHAR2 := 'N')
1337 RETURN BOOLEAN;
1338
1339
1340 PROCEDURE Propogate_Change_To_Parent
1341 (p_x_options_tbl IN OUT NOCOPY Oe_Process_Options_Pvt.Selected_Options_Tbl_Type
1342 ,p_component_code IN VARCHAR2
1343 ,p_top_model_line_id IN NUMBER
1344 ,p_model_component IN VARCHAR2
1345 ,p_ui_flag IN VARCHAR2 := 'N');
1346
1347
1348 PROCEDURE Message_From_Cz
1349 (p_line_id IN NUMBER
1350 ,p_valid_config IN VARCHAR2
1351 ,p_complete_config IN VARCHAR2
1352 ,p_config_header_id IN NUMBER
1353 ,p_config_rev_nbr IN NUMBER);
1354
1355 /*----------------------------------------------------------------------
1356 PROCEDURE: Configurator_Validation
1357 Description : checks if the configuration is complete/valid
1358 returns success/error as status. It calls
1359 send_input_xml : to send the configuration coptions to SPC
1360 parse_output_xml : parse output of SPC to see if
1361 configuration is valid/complete
1362 process_config : to save options in oe_order_lines
1363
1364 now that we have decided that we will treat invalid
1365 configuration in the same way as incomplete configuration,
1366 the arguments p_validate_flag and p_complete_flag do not
1367 have a lot of meaning. We might remove them for the procedure.
1368 We will save invali as well as incomplete configurations
1369 in oe_order_lines before booking.
1370 After booking we will put model on hold if configuraion
1371 becomes invalid/incomplete.
1372 -----------------------------------------------------------------------*/
1373 PROCEDURE Configurator_Validation
1374 (p_model_line_id IN NUMBER,
1375 p_deleted_options_tbl IN OE_Order_PUB.request_tbl_type
1376 := OE_Order_Pub.G_MISS_REQUEST_TBL,
1377 p_updated_options_tbl IN OE_Order_PUB.request_tbl_type
1378 := OE_Order_Pub.G_MISS_REQUEST_TBL,
1379 p_caller IN VARCHAR2 := '',
1380 x_valid_config OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
1381 x_complete_config OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
1382 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
1383 IS
1384 l_header_id NUMBER := NULL;
1385 l_model_line_id NUMBER := p_model_line_id;
1386 l_model_line_rec OE_ORDER_PUB.line_rec_type;
1387
1388 l_updated_options_tbl OE_Order_PUB.request_tbl_type
1389 := p_updated_options_tbl;
1390 l_deleted_options_tbl OE_Order_PUB.request_tbl_type
1391 :=p_deleted_options_tbl;
1392
1393 l_config_header_id NUMBER;
1394 l_config_rev_nbr NUMBER;
1395 l_valid_config VARCHAR2(10):= 'true';
1396 l_complete_config VARCHAR2(10):= 'true';
1397 l_change_flag VARCHAR2(1) := 'N';
1398 l_booked_flag VARCHAR2(1) := 'N';
1399 l_model_qty NUMBER;
1400 l_msg_count NUMBER;
1401 l_msg_data VARCHAR2(2000);
1402 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
1403 l_result_out VARCHAR2(30);
1404 l_options_tbl
1405 Oe_Process_Options_Pvt.Selected_Options_Tbl_Type;
1406 -- input xml message
1407 l_xml_message LONG := NULL;
1408 l_xml_hdr VARCHAR2(2000);
1409
1410 -- upgrade stuff
1411 l_upgraded_flag VARCHAR2(1);
1412 l_source_document_type_id NUMBER;
1413 l_order_source_id NUMBER;
1414
1415 -- cz's delete return value
1416 l_return_status_del VARCHAR2(1);
1417
1418 -- cz_verify output
1419 l_any_insert NUMBER := 0;
1420 l_exists_flag VARCHAR2(1) := FND_API.G_TRUE;
1421 l_complete_flag VARCHAR2(1) := FND_API.G_TRUE;
1422 l_valid_flag VARCHAR2(1) := FND_API.G_TRUE;
1423 --
1424 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1425 --
1426 BEGIN
1427 IF l_debug_level > 0 THEN
1428 oe_debug_pub.add('ENTERING CONFIGURATOR_VALIDATION' , 1);
1429 oe_debug_pub.add('QUERYING MODEL LINE' , 3 );
1430 END IF;
1431
1432 BEGIN
1433 SELECT header_id, ordered_quantity, booked_flag,
1434 upgraded_flag, config_header_id, config_rev_nbr,
1435 source_document_type_id,order_source_id
1436 INTO l_header_id, l_model_qty, l_booked_flag,
1437 l_upgraded_flag ,l_config_header_id, l_config_rev_nbr,
1438 l_source_document_type_id, l_order_source_id
1439 FROM OE_ORDER_LINES
1440 WHERE line_id = p_model_line_id;
1441 EXCEPTION
1442 WHEN OTHERS THEN
1443 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1444 END;
1445
1446 l_booked_flag := nvl(l_booked_flag, 'N');
1447 l_upgraded_flag := nvl(l_upgraded_flag, 'N');
1448
1449 ------------- upgrade stuff ---------------
1450
1451 BEGIN
1452 IF ( l_upgraded_flag = 'Y' OR
1453 l_upgraded_flag = 'P' ) AND
1454 (l_config_header_id is null AND
1455 l_config_rev_nbr is null) AND
1456 Oe_Config_Util.G_Upgraded_Flag = 'N'
1457 THEN
1458 IF l_debug_level > 0 THEN
1459 oe_debug_pub.add('UPGRADE THE CONFIGURAION' , 2 );
1460 END IF;
1461
1462 Oe_Config_Util.G_Upgraded_Flag := 'Y';
1463
1464 Configurator_Validation
1465 (p_model_line_id => p_model_line_id,
1466 x_valid_config => l_valid_config,
1467 x_complete_config => l_complete_config,
1468 x_return_status => l_return_status);
1469
1470 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1471 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_UPGARDE_ERROR');
1472 OE_Msg_Pub.Add;
1473 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1474 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1475 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_UPGARDE_ERROR');
1476 OE_Msg_Pub.Add;
1477 RAISE FND_API.G_EXC_ERROR;
1478 END IF;
1479
1480 IF l_debug_level > 0 THEN
1481 oe_debug_pub.add('CONFIGURAION GOT UPGRADED' , 2 );
1482 END IF;
1483 END IF;
1484 END;
1485
1486
1487 IF l_debug_level > 0 THEN
1488 oe_debug_pub.add('REV NBR ' ||L_CONFIG_REV_NBR );
1489 oe_debug_pub.add('CONF HDR ID' ||L_CONFIG_HEADER_ID );
1490 oe_debug_pub.add('BOOKED FLAG ' || L_BOOKED_FLAG );
1491 END IF;
1492
1493 -- Check if there is any INSERT option operation being
1494 -- performed on an existing Model
1495
1496 IF l_booked_flag = 'N' THEN
1497
1498 SELECT count (*)
1499 INTO l_any_insert
1500 FROM OE_ORDER_LINES
1501 WHERE top_model_line_id = p_model_line_id
1502 AND line_id <> p_model_line_id
1503 AND config_header_id IS NULL
1504 AND config_rev_nbr IS NULL;
1505
1506 IF l_debug_level > 0 THEN
1507 OE_Debug_Pub.Add('lines w/o cfg hdr '|| l_any_insert, 3);
1508 OE_Debug_Pub.Add('Order Level Copy '||OE_ORDER_COPY_UTIL.G_ORDER_LEVEL_COPY, 3);
1509 END IF;
1510
1511 IF l_any_insert = 0 THEN
1512
1513 BEGIN
1514 SELECT 1
1515 INTO l_any_insert
1516 FROM cz_config_details_v cz, oe_order_lines oe
1517 WHERE oe.line_id = p_model_line_id
1518 AND oe.ordered_quantity <> cz.quantity
1519 AND oe.config_header_id = cz.config_hdr_id
1520 AND oe.config_rev_nbr = cz.config_rev_nbr
1521 AND oe.component_code = cz.component_code;
1522
1523 IF l_debug_level > 0 THEN
1524 OE_Debug_Pub.Add('yes, need to call batch val for model qty',3);
1525 END IF;
1526
1527 EXCEPTION
1528 WHEN NO_DATA_FOUND THEN
1529 IF l_debug_level > 0 THEN
1530 OE_Debug_Pub.Add('no need to call batch val for model qty',3);
1531 END IF;
1532 WHEN OTHERS THEN
1533 IF l_debug_level > 0 THEN
1534 oe_debug_pub.add( 'QTY SELECT: '|| SQLERRM , 1 ) ;
1535 END IF;
1536 RAISE;
1537 END;
1538 END IF; -- model qty check
1539
1540 END IF; -- booked flag and new inserts check.
1541
1542 IF l_booked_flag = 'N' AND
1543 l_updated_options_tbl.COUNT = 0 AND
1544 l_deleted_options_tbl.COUNT = 0 AND
1545 l_any_insert = 0 AND
1546 OE_ORDER_COPY_UTIL.G_ORDER_LEVEL_COPY <> 1 AND
1547 l_config_rev_nbr is not null AND
1548 l_config_header_id is not null
1549 THEN
1550 IF l_debug_level > 0 THEN
1551 OE_Debug_Pub.Add('Skip Batch Validation ');
1552 END IF;
1553
1554 CZ_CONFIG_API_PUB.verify_configuration
1555 ( p_api_version => 1.0,
1556 p_config_hdr_id => l_config_header_id,
1557 p_config_rev_nbr => l_config_rev_nbr,
1558 x_exists_flag => l_exists_flag,
1559 x_valid_flag => l_valid_flag,
1560 x_complete_flag => l_complete_flag,
1561 x_return_status => l_return_status,
1562 x_msg_count => l_msg_count,
1563 x_msg_data => l_msg_data );
1564
1565 IF l_debug_level > 0 THEN
1566 oe_debug_pub.add (' Exists Flag :' ||l_exists_flag,2);
1567 oe_debug_pub.add (' Valid Flag :'|| l_valid_flag,2);
1568 oe_debug_pub.add (' Complete Flag :'|| l_complete_flag,2);
1569 oe_debug_pub.add (' Return Status :'|| l_return_status,2);
1570 oe_debug_pub.add (' Message Count :'|| l_msg_count,2);
1571 oe_debug_pub.add (' Message Data :'|| l_msg_data,2);
1572 END IF;
1573
1574 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1575 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1576 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1577 RAISE FND_API.G_EXC_ERROR;
1578 ELSIF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
1579
1580 IF l_exists_flag = FND_API.G_FALSE THEN
1581 IF l_debug_level > 0 THEN
1582 oe_debug_pub.add('Configuration Does not Exist '|| l_msg_data,2);
1583 END IF;
1584 RAISE FND_API.G_EXC_ERROR;
1585
1586 ELSE
1587 IF l_debug_level > 0 THEN
1588 oe_debug_pub.add (' Configuration Exists ',2);
1589 END IF;
1590
1591 IF l_valid_flag = FND_API.G_FALSE THEN
1592 l_valid_config := 'FALSE';
1593 ELSE
1594 l_valid_config := 'TRUE';
1595 END IF;
1596
1597 IF l_complete_flag = FND_API.G_FALSE THEN
1598 l_complete_config := 'FALSE';
1599 ELSE
1600 IF l_debug_level > 0 THEN
1601 oe_debug_pub.add('Configuration Exists, valid and Complete ',2);
1602 END IF;
1603 l_complete_config := 'TRUE';
1604 END IF;
1605 END IF; -- if exist flag = false
1606 END IF; -- if success
1607
1608 Message_From_Cz
1609 ( p_line_id => l_model_line_id,
1610 p_valid_config => l_valid_config,
1611 p_complete_config => l_complete_config,
1612 p_config_header_id => l_config_header_id,
1613 p_config_rev_nbr => l_config_rev_nbr);
1614
1615 ELSE -- call batch val
1616
1617 -- create xml initialization message,
1618 -- then we send it along with options to SPC
1619 -- then we parse the o/p xml from SPC to get
1620 -- batch validation results
1621 -- Check if the user has already performed configurator validation
1622 -- If the call is from Order Import and not BOOKING then skip the
1623 -- Configurator BATCH Validation (bug 2560933)
1624
1625 IF l_debug_level > 0 THEN
1626 oe_debug_pub.add('CALLING CREATE_HDR_XML' , 2 );
1627 oe_debug_pub.add('--------INITIALIZATION MESSAGE------------' , 2 );
1628 END IF;
1629
1630 Create_hdr_xml
1631 ( p_model_line_id => p_model_line_id ,
1632 x_xml_hdr => l_xml_hdr);
1633
1634 IF l_debug_level > 0 THEN
1635 oe_debug_pub.add('------AFTER CREATE INITIALIZATION MESSAGE----' , 2 );
1636 oe_debug_pub.add('CALLING SEND_INPUT_XML' , 2 );
1637 END IF;
1638
1639 Send_Input_xml
1640 ( p_model_line_id => l_model_line_id,
1641 p_deleted_options_tbl => l_deleted_options_tbl,
1642 p_updated_options_tbl => l_updated_options_tbl,
1643 p_model_qty => l_model_qty,
1644 p_xml_hdr => l_xml_hdr,
1645 x_out_xml_msg => l_xml_message,
1646 x_return_status => l_return_status );
1647
1648 IF l_debug_level > 0 THEN
1649 oe_debug_pub.add
1650 ('AFTER CALLING SEND_INPUT_XML: '||L_RETURN_STATUS , 2 );
1651 END IF;
1652 --get_transaction_id(p_caller => 'after send_xml');
1653
1654 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1655 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1656
1657 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1658 RAISE FND_API.G_EXC_ERROR;
1659
1660 END IF;
1661
1662
1663 l_xml_message := UPPER(l_xml_message);
1664
1665 -- extract data from xml message.
1666
1667 IF l_debug_level > 0 THEN
1668 oe_debug_pub.add('CALLING PARSE_OUTPUT_XML' , 2 );
1669 END IF;
1670
1671 Parse_Output_xml
1672 ( p_xml => l_xml_message,
1673 p_line_id => l_model_line_id,
1674 x_valid_config => l_valid_config,
1675 x_complete_config => l_complete_config,
1676 x_config_header_id => l_config_header_id,
1677 x_config_rev_nbr => l_config_rev_nbr,
1678 x_return_status => l_return_status );
1679
1680 IF l_debug_level > 0 THEN
1681 oe_debug_pub.add('AFTER CALLING PARSE_XML: '||L_RETURN_STATUS , 2 );
1682 END IF;
1683
1684 x_valid_config := l_valid_config;
1685 x_complete_config := l_complete_config;
1686
1687 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1688 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1689 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1690 RAISE FND_API.G_EXC_ERROR;
1691 END IF;
1692
1693 END IF; -- if skip batch val
1694
1695 x_valid_config := l_valid_config;
1696 x_complete_config := l_complete_config;
1697
1698 IF p_caller = 'BOOKING' AND
1699 (l_valid_config = 'FALSE' OR
1700 l_complete_config = 'FALSE') THEN
1701
1702 IF l_debug_level > 0 THEN
1703 oe_debug_pub.add('CALLER IS BOOKING AND ERRORED OUT' , 2 );
1704 END IF;
1705
1706 x_return_status := l_return_status;
1707 RETURN;
1708 END IF;
1709
1710
1711 -- if the order id booked, we want to put hold on the model line
1712 -- if the configuration is invalid or incomplete. Also we want
1713 -- to release the hold, if the configuration becomes valid and complete
1714 -- after this particular change.
1715
1716 IF l_debug_level > 0 THEN
1717 oe_debug_pub.add('IS THIS IS A BOOKED ORDER , IF SO PUT HOLD: '
1718 ||L_BOOKED_FLAG , 2 );
1719 END IF;
1720
1721 IF l_booked_flag = 'Y' THEN
1722
1723 OE_Config_Pvt.put_hold_and_release_hold
1724 (p_header_id => l_header_id,
1725 p_line_id => l_model_line_id,
1726 p_valid_config => l_valid_config,
1727 p_complete_config => l_complete_config,
1728 x_msg_count => l_msg_count,
1729 x_msg_data => l_msg_data,
1730 x_return_status => l_return_status);
1731
1732 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR
1733 THEN
1734 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1735 ELSIF l_return_status = FND_API.G_RET_STS_ERROR
1736 THEN
1737 RAISE FND_API.G_EXC_ERROR;
1738 END IF;
1739 END IF;
1740
1741
1742 -- call to process_config to insert new valid and complete confiuration
1743
1744 IF l_debug_level > 0 THEN
1745 oe_debug_pub.add('------- CALLING PROCESS_CONFIG -----------' , 2 );
1746 END IF;
1747
1748 OE_Config_Pvt.Process_Config
1749 ( p_header_id => l_header_id
1750 ,p_config_hdr_id => l_config_header_id
1751 ,p_config_rev_nbr => l_config_rev_nbr
1752 ,p_top_model_line_id => l_model_line_id
1753 ,p_ui_flag => 'N'
1754 ,x_change_flag => l_change_flag
1755 ,x_msg_count => l_msg_count
1756 ,x_msg_data => l_msg_data
1757 ,x_return_status => l_return_status );
1758
1759 IF l_debug_level > 0 THEN
1760 oe_debug_pub.add('AFTER CALL TO PROCESS_CONFIG: '
1761 ||L_RETURN_STATUS , 2 );
1762 END IF;
1763
1764 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1765 IF l_debug_level > 0 THEN
1766 oe_debug_pub.add('PROCESS CONFIG UNEXPECTED ERROR' , 2 );
1767 END IF;
1768 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1769
1770 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1771 IF l_debug_level > 0 THEN
1772 oe_debug_pub.add('PROCESS CONFIG EXEC ERROR' , 2 );
1773 END IF;
1774 RAISE FND_API.G_EXC_ERROR;
1775
1776 END IF;
1777
1778 -- If you are here, things went off OK ! So return success
1779 x_return_status := l_return_status;
1780
1781 IF l_debug_level > 0 THEN
1782 oe_debug_pub.add('LEAVING CONFIGURATOR_VALIDATION' , 1);
1783 END IF;
1784 EXCEPTION
1785 WHEN OTHERS THEN
1786 IF l_debug_level > 0 THEN
1787 oe_debug_pub.add('ECXEPTION IN CONFIGURATOR_VALIDATION'|| SQLERRM , 1);
1788 END IF;
1789 RAISE;
1790 END Configurator_Validation;
1791
1792 /*----------------------------------------------------------------------
1793 PROCEDURE: Bom_Config_Validation
1794 If Use_Configurator function returns false.
1795
1796 Change Record:
1797 ER 2625376 : date effectivity - call to prepare_cascade_tables.
1798
1799 MACD: No MACD functionality should be available in the options window
1800 -----------------------------------------------------------------------*/
1801 PROCEDURE Bom_Config_Validation
1802 (p_model_line_id IN NUMBER,
1803 p_header_id IN NUMBER,
1804 p_model_qty IN NUMBER,
1805 p_deleted_options_tbl IN OE_Order_PUB.request_tbl_type
1806 := OE_Order_Pub.G_MISS_REQUEST_TBL,
1807 p_updated_options_tbl IN OE_Order_PUB.request_tbl_type
1808 := OE_Order_Pub.G_MISS_REQUEST_TBL,
1809 p_caller IN VARCHAR2 := '',
1810 x_valid_config OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
1811 x_complete_config OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
1812 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
1813 IS
1814 l_options_tbl Oe_Process_Options_Pvt.Selected_Options_Tbl_Type;
1815 l_updated_options_tbl OE_Order_PUB.request_tbl_type;
1816 l_deleted_options_tbl OE_Order_PUB.request_tbl_type;
1817 I NUMBER;
1818 l_change_flag VARCHAR2(1);
1819 l_item_type_code VARCHAR2(30);
1820 l_model_component VARCHAR2(1000);
1821 l_req_rec OE_Order_Pub.Request_Rec_Type;
1822 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
1823 l_msg_count NUMBER;
1824 l_msg_data VARCHAR2(2000);
1825
1826 --
1827 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1828 --
1829 BEGIN
1830 IF l_debug_level > 0 THEN
1831 oe_debug_pub.add('ENTERING BOM_CONFIG_VALIDATION' , 1);
1832 oe_debug_pub.add('GETTING PREVIOUSLY SAVED OPTIONS FROM DB' , 2 );
1833 END IF;
1834
1835 IF OE_CODE_CONTROL.GET_CODE_RELEASE_LEVEL >= '110510' THEN
1836
1837 OE_CONFIG_TSO_PVT.Is_Part_Of_Container_Model
1838 ( p_line_id => p_model_line_id
1839 ,x_top_container_model => l_change_flag
1840 ,x_part_of_container => l_return_status );
1841
1842 IF l_change_flag = 'Y' THEN
1843 IF l_debug_level > 0 THEN
1844 OE_DEBUG_PUB.Add('Line is top container, hence not allowed',3);
1845 END IF;
1846
1847 x_return_status := FND_API.G_RET_STS_ERROR;
1848 FND_MESSAGE.SET_NAME('ONT','ONT_TSO_NOT_IN_OPTIONS_WINDOW');
1849 OE_MSG_PUB.Add;
1850 RETURN;
1851 END IF;
1852
1853 END IF;
1854
1855
1856 l_return_status := FND_API.G_RET_STS_SUCCESS;
1857
1858 OE_Process_Options_Pvt.Get_Options_From_DB
1859 ( p_top_model_line_id => p_model_line_id
1860 ,p_get_model_line => TRUE
1861 ,p_caller => 'OPTIONS WINDOW BATCH'
1862 ,p_query_criteria => 4
1863 ,x_disabled_options => l_msg_data
1864 ,x_options_tbl => l_options_tbl);
1865
1866 IF p_deleted_options_tbl.COUNT > 0 OR
1867 p_updated_options_tbl.COUNT > 0 OR
1868 l_msg_data = 'Y' THEN
1869
1870 SELECT component_code
1871 INTO l_model_component
1872 FROM oe_order_lines
1873 WHERE line_id = p_model_line_id;
1874
1875 l_updated_options_tbl := p_updated_options_tbl;
1876 l_deleted_options_tbl := p_deleted_options_tbl;
1877
1878 IF l_msg_data = 'Y' THEN
1879
1880 OE_Process_Options_Pvt.Prepare_Cascade_Tables
1881 ( p_options_tbl => l_options_tbl
1882 ,p_top_model_line_id => p_model_line_id
1883 ,p_x_updated_options_tbl => l_updated_options_tbl
1884 ,p_x_deleted_options_tbl => l_deleted_options_tbl);
1885
1886 END IF;
1887
1888 IF l_debug_level > 0 THEN
1889 oe_debug_pub.add('CALLING CASCADE_UPDATES_DELETES '||
1890 l_deleted_options_tbl.COUNT || '-' ||
1891 l_updated_options_tbl.COUNT, 3);
1892 END IF;
1893
1894 Cascade_Updates_Deletes
1895 ( p_model_line_id => p_model_line_id
1896 ,p_model_component => l_model_component
1897 ,p_x_options_tbl => l_options_tbl
1898 ,p_deleted_options_tbl => l_deleted_options_tbl
1899 ,p_updated_options_tbl => l_updated_options_tbl
1900 ,x_return_status => l_return_status);
1901
1902 END IF; -- if we need to cascade
1903
1904 IF l_debug_level > 0 THEN
1905 oe_debug_pub.add('CALLING PROCESS_CONFIG_OPTIONS' , 1);
1906 END IF;
1907
1908 OE_Process_Options_Pvt.Process_Config_Options
1909 (p_options_tbl => l_options_tbl,
1910 p_header_id => p_header_id,
1911 p_top_model_line_id => p_model_line_id,
1912 p_ui_flag => 'N',
1913 p_caller => p_caller, -- bug 4636208
1914 x_valid_config => x_valid_config,
1915 x_complete_config => x_complete_config,
1916 x_change_flag => l_change_flag,
1917 x_msg_count => l_msg_count,
1918 x_msg_data => l_msg_data,
1919 x_return_status => x_return_status);
1920
1921 OE_Process_Options_Pvt.Handle_Ret_Status
1922 (p_return_Status => x_return_status);
1923
1924 IF l_debug_level > 0 THEN
1925 oe_debug_pub.add('LEAVING BOM_CONFIG_VALIDATION' , 1);
1926 END IF;
1927 EXCEPTION
1928 WHEN OTHERS THEN
1929 IF l_debug_level > 0 THEN
1930 oe_debug_pub.add('ECXEPTION IN BOM_CONFIG_VALIDATION'|| SQLERRM , 1);
1931 END IF;
1932 RAISE;
1933 END Bom_Config_Validation;
1934
1935
1936 /*----------------------------------------------------------------------
1937 Procedure Name : Cascade_Updates_Deletes
1938 Description : This API will be used when there are updates and deletes
1939 to option/class of a configuration and we want to cascade the operation to
1940 either upwards or downwards.
1941 -- handle updates
1942 -- if any class is updated, modify the l_options-tbl so that, options
1943 -- qty cascades, set operation of update on the updated once, and none
1944 -- on the others
1945
1946 -- handle deletes
1947 -- if any class deleted, delete all options underit.
1948 -- if a option is deleted, i.e. the only option in a class
1949 -- delete the class from l_options_tbl
1950
1951 Note:
1952 If a kit under a model is updated/deleted, since its included items
1953 are not present in l_options_tbl, so we can not use cascade_qty
1954 or delete_options for it.
1955 We handle this seperately, before call to process_order in
1956 handle_dml in OEXVOPTB.pls. We also handle the case of included
1957 items under a PTO class in handle_dml.
1958
1959 As part of pack J ato options decimal quantity project
1960 decimal_ratio_check is moved to OE_VALIDATE_LINE
1961 for Decimal quantities for ATO Options Project
1962 the decimal ratio check will be part of line entity
1963 validation
1964 -----------------------------------------------------------------------*/
1965
1966 PROCEDURE Cascade_Updates_Deletes
1967 ( p_model_line_id IN NUMBER
1968 ,p_model_component IN VARCHAR2
1969 ,p_x_options_tbl IN OUT NOCOPY
1970 Oe_Process_Options_Pvt.Selected_Options_Tbl_Type
1971 ,p_deleted_options_tbl IN OE_Order_PUB.request_tbl_type
1972 := OE_Order_Pub.G_MISS_REQUEST_TBL
1973 ,p_updated_options_tbl IN OE_Order_PUB.request_tbl_type
1974 := OE_Order_Pub.G_MISS_REQUEST_TBL
1975 ,p_ui_flag IN VARCHAR2 := 'N'
1976 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
1977 IS
1978 I NUMBER;
1979 l_index NUMBER;
1980 l_ratio NUMBER;
1981 l_req_rec OE_Order_Pub.Request_Rec_Type;
1982 l_deleted_options_tbl OE_Order_PUB.request_tbl_type
1983 := p_deleted_options_tbl;
1984 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
1985 l_qty NUMBER := 1;
1986 --
1987 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1988 --
1989 BEGIN
1990 IF l_debug_level > 0 THEN
1991 oe_debug_pub.add('ENTERING CASCADE_UPDATES_DELETES' , 1);
1992 oe_debug_pub.add('FIRST UPDATES' , 2 );
1993 END IF;
1994
1995 IF p_updated_options_tbl.COUNT > 0 THEN
1996 SELECT ordered_quantity
1997 INTO l_qty
1998 FROM oe_order_lines
1999 WHERE line_id = p_model_line_id;
2000 END IF;
2001
2002 I :=p_updated_options_tbl.FIRST;
2003 WHILE I is not NULL
2004 LOOP
2005 l_req_rec := p_updated_options_tbl(I);
2006
2007 IF l_debug_level > 0 THEN
2008 oe_debug_pub.add('OPTIONS UPDATED ' , 4 );
2009 END IF;
2010
2011 IF l_debug_level > 0 THEN
2012 oe_debug_pub.add('QTY '|| L_REQ_REC.PARAM5||'CANCEL: '
2013 ||L_REQ_REC.PARAM8 , 2 );
2014 END IF;
2015
2016 IF l_req_rec.param5 = 0 AND l_req_rec.param8 = 'N' THEN
2017 IF l_debug_level > 0 THEN
2018 oe_debug_pub.add('QTY = 0 AND NO CANCELLATION , SO DELETE' , 1);
2019 END IF;
2020
2021 BEGIN
2022 -- set operation to delete
2023 l_index := OE_Process_Options_Pvt.Find_Matching_comp_index
2024 ( p_options_tbl => p_x_options_tbl
2025 ,p_comp_code => l_req_rec.param2);
2026
2027 IF l_debug_level > 0 THEN
2028 oe_debug_pub.add('INDEX: '|| L_INDEX , 2 );
2029 END IF;
2030 p_x_options_tbl(l_index).operation := OE_GLOBALS.G_OPR_DELETE;
2031
2032 EXCEPTION
2033 WHEN FND_API.G_EXC_ERROR THEN
2034 IF l_debug_level > 0 THEN
2035 oe_debug_pub.add('COMPONENT NOT PRESENT' , 1);
2036 END IF;
2037 RAISE;
2038 END;
2039
2040 l_deleted_options_tbl(nvl(l_deleted_options_tbl.LAST, 0) + 1) :=
2041 l_req_rec; -- ok, since params match
2042
2043 ELSE -- regular code
2044 IF l_debug_level > 0 THEN
2045 oe_debug_pub.add('REGULAR CODE OF UPDATES'|| L_REQ_REC.PARAM3 , 1);
2046 END IF;
2047
2048 IF l_req_rec.param3 = OE_GLOBALS.G_ITEM_CLASS THEN
2049
2050 IF l_req_rec.param5 = 0 THEN
2051 l_ratio := 0;
2052 ELSE
2053 l_ratio := l_req_rec.param5/l_req_rec.param4;
2054 END IF;
2055
2056 IF l_debug_level > 0 THEN
2057 -- 4211654
2058 oe_debug_pub.add(L_REQ_REC.PARAM2||' OLD QTY (l_req_rec.param4) = '
2059 ||L_REQ_REC.PARAM4||' New Qty (l_req_rec.param5) = '
2060 ||l_req_rec.param5 , 1);
2061 END IF;
2062
2063 Cascade_Qty( p_x_options_tbl => p_x_options_tbl
2064 ,p_component_code => l_req_rec.param2
2065 ,p_ratio => l_ratio
2066 -- 4211654
2067 ,p_new_qty => l_req_rec.param5
2068 ,p_old_qty => l_req_rec.param4
2069 ,p_change_reason => l_req_rec.param6
2070 ,p_change_comments => l_req_rec.param7);
2071 END IF;
2072
2073 IF l_req_rec.param8 = 'Y' AND
2074 l_req_rec.param5 = 0
2075 THEN
2076 IF l_debug_level > 0 THEN
2077 oe_debug_pub.add('CALLING PROPOGATE CHANGE , CANCEL FLAG Y' , 1);
2078 END IF;
2079
2080 Propogate_change_To_parent
2081 (p_x_options_tbl => p_x_options_tbl
2082 ,p_component_code => l_req_rec.param2
2083 ,p_top_model_line_id => p_model_line_id
2084 ,p_model_component => p_model_component
2085 ,p_ui_flag => p_ui_flag);
2086 END IF;
2087
2088 END IF; -- qty 0 and cancel = 'N'
2089
2090 I := p_updated_options_tbl.NEXT(I);
2091 END LOOP;
2092
2093 IF l_debug_level > 0 THEN
2094 oe_debug_pub.add('NOW DELETES' , 1);
2095 END IF;
2096
2097 I :=l_deleted_options_tbl.FIRST;
2098 WHILE I is not NULL
2099 LOOP
2100 IF l_debug_level > 0 THEN
2101 oe_debug_pub.add('THERE ARE ITEMS DELETED'|| L_REQ_REC.PARAM2 , 1);
2102 END IF;
2103
2104 l_req_rec := l_deleted_options_tbl(I);
2105
2106 IF l_req_rec.param3 = OE_GLOBALS.G_ITEM_CLASS THEN
2107 IF l_debug_level > 0 THEN
2108 oe_debug_pub.add('CLASS IS DELETED'|| L_REQ_REC.PARAM2 , 1);
2109 END IF;
2110
2111 Delete_Children( p_x_options_tbl => p_x_options_tbl
2112 ,p_component_code => l_req_rec.param2
2113 ,p_parent_item => l_req_rec.param10 ); -- 3563690
2114 END IF;
2115
2116 -- why a KIT and a Class are considered here.
2117 -- if user saves a configuration with a class or kit w/o any
2118 -- options/inc items and then deletes this class/kit, we
2119 -- should see if the parent needs to be deleted, rare case.
2120
2121 IF p_model_component is NULL THEN
2122 IF l_debug_level > 0 THEN
2123 oe_debug_pub.add('MODEL COMPONENT IS NULL' , 1);
2124 END IF;
2125 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2126 END IF;
2127
2128 IF l_debug_level > 0 THEN
2129 oe_debug_pub.add('OPTION/CLASS/KIT IS DELETED' , 1);
2130 END IF;
2131
2132 Delete_Parent(p_x_options_tbl => p_x_options_tbl
2133 ,p_component_code => l_req_rec.param2
2134 ,p_top_model_line_id => p_model_line_id
2135 ,p_model_component => p_model_component
2136 ,p_ui_flag => p_ui_flag);
2137
2138 I := l_deleted_options_tbl.NEXT(I);
2139 END LOOP;
2140
2141 x_return_status := l_return_status;
2142 IF l_debug_level > 0 THEN
2143 oe_debug_pub.add('LEAVING CASCADE_UPDATES_DELETES' , 1);
2144 END IF;
2145
2146 EXCEPTION
2147 WHEN OTHERS THEN
2148 IF l_debug_level > 0 THEN
2149 oe_debug_pub.add('EXCEPTION IN CASCADE_UPDATES_DELETES'|| SQLERRM , 1);
2150 END IF;
2151 RAISE;
2152 END Cascade_Updates_Deletes;
2153
2154 /*---------------------------------------------------------------------
2155 PROCEDURE: Cascade_Qty
2156 bug fixed: Make sure to pass req. reason and comment, while cascading.
2157 bug fixed: only one level cascade will happen.
2158 ----------------------------------------------------------------------*/
2159
2160 PROCEDURE Cascade_Qty
2161 ( p_x_options_tbl IN OUT NOCOPY Oe_Process_Options_Pvt.Selected_Options_Tbl_Type
2162 ,p_component_code IN VARCHAR2
2163 ,p_ratio IN NUMBER
2164 -- 4211654
2165 ,p_new_qty IN number
2166 ,p_old_qty IN number
2167 ,p_change_reason IN VARCHAR2
2168 ,p_change_comments IN VARCHAR2)
2169 IS
2170 I NUMBER;
2171 l_length NUMBER;
2172 --
2173 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2174 --
2175 BEGIN
2176 IF l_debug_level > 0 THEN
2177 oe_debug_pub.add('ENTERING CASCADE_QTY '|| P_RATIO , 1);
2178 END IF;
2179
2180 l_length := LENGTH(p_component_code);
2181
2182 I := p_x_options_tbl.FIRST;
2183 WHILE I is not NULL
2184 LOOP
2185 IF SUBSTR(p_x_options_tbl(I).component_code, 1, l_length )
2186 = p_component_code
2187 AND p_x_options_tbl(I).component_code <> p_component_code
2188 AND p_x_options_tbl(I).operation <> OE_GLOBALS.G_OPR_DELETE
2189 THEN
2190 IF l_debug_level > 0 THEN
2191 oe_debug_pub.add('OPTION TO BE UPDATED '
2192 || P_X_OPTIONS_TBL (I).COMPONENT_CODE , 3 );
2193 oe_debug_pub.add('CHANGE REASON '|| P_CHANGE_REASON , 3 );
2194 END IF;
2195 /* 4211654 - instead of using p_ratio, used p_old_qty and p_new_qty to
2196 * calculate p_x_options_tbl(I).ordered_quantity
2197 */
2198 p_x_options_tbl(I).ordered_quantity :=
2199 (p_x_options_tbl(I).ordered_quantity / p_old_qty) * p_new_qty;
2200 IF l_debug_level > 0 THEN
2201 oe_debug_pub.add('NEW QTY '||P_X_OPTIONS_TBL (I).ORDERED_QUANTITY ,1);
2202 END IF;
2203 p_x_options_tbl(I).change_reason := p_change_reason;
2204 p_x_options_tbl(I).change_comments := p_change_comments;
2205
2206 --added IF condition for bug# 4116813
2207 IF p_x_options_tbl(I).operation <> OE_GLOBALS.G_OPR_INSERT THEN
2208 p_x_options_tbl(I).operation := OE_GLOBALS.G_OPR_UPDATE;
2209 END IF;
2210
2211
2212 END IF;
2213 I := p_x_options_tbl.NEXT(I);
2214 END LOOP;
2215
2216 IF l_debug_level > 0 THEN
2217 oe_debug_pub.add('LEAVING CASCADE_QTY' , 1);
2218 END IF;
2219 EXCEPTION
2220 WHEN OTHERS THEN
2221 IF l_debug_level > 0 THEN
2222 oe_debug_pub.add('ECXEPTION IN CASCADE_QTY'|| SQLERRM , 1);
2223 END IF;
2224 RAISE;
2225 END Cascade_Qty;
2226
2227
2228 /*----------------------------------------------------------------------
2229 PROCEDURE: Delete_Children
2230 3563690 => If operation is insert for a child line, do not set the
2231 operation to delete. Instead, raise an exception
2232 Changed the signature of the procedure to accept the name
2233 of the class.
2234 ----------------------------------------------------------------------*/
2235 PROCEDURE Delete_Children
2236 ( p_x_options_tbl IN OUT NOCOPY Oe_Process_Options_Pvt.Selected_Options_Tbl_Type
2237 ,p_component_code IN VARCHAR2
2238 ,p_parent_item IN VARCHAR2)
2239 IS
2240 I NUMBER;
2241 l_length NUMBER;
2242 --
2243 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2244 --
2245 BEGIN
2246 IF l_debug_level > 0 THEN
2247 oe_debug_pub.add('ENTERING DELETE_CHILDREN' , 1);
2248 END IF;
2249
2250 l_length := LENGTH(p_component_code);
2251
2252 I := p_x_options_tbl.FIRST;
2253 WHILE I is not NULL
2254 LOOP
2255 IF SUBSTR(p_x_options_tbl(I).component_code, 1, l_length )
2256 = p_component_code
2257 AND p_x_options_tbl(I).component_code <> p_component_code
2258 THEN
2259 IF l_debug_level > 0 THEN
2260 oe_debug_pub.add('OPTION TO BE DELETED '
2261 || P_X_OPTIONS_TBL (I).COMPONENT_CODE , 3 );
2262 END IF;
2263 IF p_x_options_tbl(I).operation <> OE_GLOBALS.G_OPR_INSERT
2264 THEN
2265 p_x_options_tbl(I).operation := OE_GLOBALS.G_OPR_DELETE;
2266 ELSE
2267 FND_MESSAGE.SET_NAME('ONT','ONT_CONFIG_INSERT_DELETE');
2268 FND_MESSAGE.Set_Token('CLASS',p_parent_item);
2269 FND_MESSAGE.Set_Token('ITEM',p_x_options_tbl(I).ordered_item);
2270 Oe_Msg_Pub.Add;
2271 IF l_debug_level > 0 THEN
2272 oe_debug_pub.add('OPERATION IS INSERT IN PROCEDURE DELETE_CHILDREN');
2273 oe_debug_pub.add('parent class : ' || p_parent_item);
2274 oe_debug_pub.add('child item : ' || p_x_options_tbl(I).ordered_item);
2275 END IF;
2276 RAISE FND_API.G_EXC_ERROR;
2277 END IF;
2278 END IF;
2279 I := p_x_options_tbl.NEXT(I);
2280 END LOOP;
2281
2282 IF l_debug_level > 0 THEN
2283 oe_debug_pub.add('LEAVING DELETE_CHILDREN' , 1);
2284 END IF;
2285 EXCEPTION
2286 WHEN OTHERS THEN
2287 IF l_debug_level > 0 THEN
2288 oe_debug_pub.add('ECXEPTION IN DELETE_CHILDREN'|| SQLERRM , 1);
2289 END IF;
2290 RAISE;
2291 END Delete_Children;
2292
2293
2294 /*----------------------------------------------------------------------
2295 PROCEDURE Delete_Parent
2296 delete the parent only if the only option under it is getting deleted.
2297 Never delete the model line.
2298 ----------------------------------------------------------------------*/
2299 PROCEDURE Delete_Parent
2300 (p_x_options_tbl IN OUT NOCOPY Oe_Process_Options_Pvt.Selected_Options_Tbl_Type
2301 ,p_component_code IN VARCHAR2
2302 ,p_top_model_line_id IN NUMBER
2303 ,p_model_component IN VARCHAR2
2304 ,p_ui_flag IN VARCHAR2 := 'N')
2305 IS
2306 I NUMBER;
2307 l_count NUMBER;
2308 l_link_to_line_id NUMBER;
2309 l_parent VARCHAR2(1000);
2310 --
2311 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2312 --
2313 BEGIN
2314 IF l_debug_level > 0 THEN
2315 oe_debug_pub.add('ENTERING DELETE_PARENT' , 1);
2316 END IF;
2317
2318 IF p_model_component is NULL THEN
2319 RAISE FND_API.G_EXC_ERROR;
2320 END IF;
2321
2322
2323 IF p_component_code = p_model_component THEN
2324 IF l_debug_level > 0 THEN
2325 oe_debug_pub.add('MODEL REACHED' , 1);
2326 END IF;
2327 RETURN;
2328 END IF;
2329
2330 IF l_debug_level > 0 THEN
2331 oe_debug_pub.add('COMP SENT IN: '|| P_COMPONENT_CODE , 2 );
2332 END IF;
2333
2334
2335 IF no_more_children_left
2336 (p_x_options_tbl => p_x_options_tbl
2337 ,p_component_code => p_component_code
2338 ,p_top_model_line_id => p_top_model_line_id
2339 ,p_model_component => p_model_component
2340 ,p_ui_flag => p_ui_flag)
2341 THEN
2342
2343 -- make a recursive call, because parent can be the
2344 -- only child to its parent.
2345
2346 I := p_x_options_tbl.FIRST;
2347 WHILE I is not NULL
2348
2349 LOOP
2350 IF l_debug_level > 0 THEN
2351 oe_debug_pub.add(I || ': '|| P_X_OPTIONS_TBL (I).COMPONENT_CODE , 2 );
2352 END IF;
2353 l_parent :=
2354 SUBSTR(p_component_code, 1, INSTR(p_component_code, '-', -1) - 1);
2355
2356 IF l_parent = p_x_options_tbl(I).component_code AND
2357 p_x_options_tbl(I).component_code <> p_model_component
2358 THEN
2359 IF l_debug_level > 0 THEN
2360 oe_debug_pub.add('PARENT TO BE DELETED '
2361 || P_X_OPTIONS_TBL (I).COMPONENT_CODE , 3 );
2362 END IF;
2363
2364 p_x_options_tbl(I).operation := OE_GLOBALS.G_OPR_DELETE;
2365
2366 -- recursive call.
2367
2368 IF l_debug_level > 0 THEN
2369 oe_debug_pub.add('RECURSIVE CALL'|| P_MODEL_COMPONENT , 1);
2370 END IF;
2371 Delete_Parent(p_x_options_tbl => p_x_options_tbl
2372 ,p_component_code => l_parent
2373 ,p_top_model_line_id => p_top_model_line_id
2374 ,p_model_component => p_model_component
2375 ,p_ui_flag => p_ui_flag);
2376
2377 IF l_debug_level > 0 THEN
2378 oe_debug_pub.add('MY CALL WORK DONE' , 1);
2379 END IF;
2380 RETURN;
2381 END IF;
2382 I := p_x_options_tbl.NEXT(I);
2383 END LOOP;
2384
2385 IF l_debug_level > 0 THEN
2386 oe_debug_pub.add('PARENT NOT FOUND??' , 1);
2387 END IF;
2388
2389 END IF;
2390
2391 IF l_debug_level > 0 THEN
2392 oe_debug_pub.add('LEAVING DELETE_PARENT'|| P_COMPONENT_CODE , 1);
2393 END IF;
2394 EXCEPTION
2395 WHEN OTHERS THEN
2396 IF l_debug_level > 0 THEN
2397 oe_debug_pub.add('ECXEPTION IN DELETE_PARENT'|| SQLERRM , 1);
2398 END IF;
2399 RAISE;
2400 END Delete_Parent;
2401
2402
2403 /*----------------------------------------------------------------------
2404 PROCEDURE Propogate_Change_To_Parent
2405 propogate change to the parent only if the only option under
2406 it is changed.
2407 ----------------------------------------------------------------------*/
2408 PROCEDURE Propogate_Change_To_Parent
2409 (p_x_options_tbl IN OUT NOCOPY Oe_Process_Options_Pvt.Selected_Options_Tbl_Type
2410 ,p_component_code IN VARCHAR2
2411 ,p_top_model_line_id IN NUMBER
2412 ,p_model_component IN VARCHAR2
2413 ,p_ui_flag IN VARCHAR2 := 'N')
2414 IS
2415 I NUMBER;
2416 l_count NUMBER;
2417 l_link_to_line_id NUMBER;
2418 l_parent VARCHAR2(1000);
2419 --
2420 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2421 --
2422 BEGIN
2423 IF l_debug_level > 0 THEN
2424 oe_debug_pub.add('ENTERING PROPOGATE_CHANGE_TO_PARENT' , 1);
2425 END IF;
2426
2427 IF p_model_component is NULL THEN
2428 RAISE FND_API.G_EXC_ERROR;
2429 END IF;
2430
2431
2432 IF p_component_code = p_model_component THEN
2433 IF l_debug_level > 0 THEN
2434 oe_debug_pub.add('MODEL REACHED' , 1);
2435 END IF;
2436 RETURN;
2437 END IF;
2438
2439 IF l_debug_level > 0 THEN
2440 oe_debug_pub.add('COMP SENT IN: '|| P_COMPONENT_CODE , 2 );
2441 END IF;
2442
2443
2444 IF no_more_children_left
2445 (p_x_options_tbl => p_x_options_tbl
2446 ,p_component_code => p_component_code
2447 ,p_top_model_line_id => p_top_model_line_id
2448 ,p_model_component => p_model_component
2449 ,p_ui_flag => p_ui_flag)
2450 THEN
2451
2452 -- make a recursive call, because parent can be the
2453 -- only child to its parent.
2454
2455 I := p_x_options_tbl.FIRST;
2456 WHILE I is not NULL
2457
2458 LOOP
2459 IF l_debug_level > 0 THEN
2460 oe_debug_pub.add(I || ': '|| P_X_OPTIONS_TBL (I).COMPONENT_CODE , 2 );
2461 END IF;
2462
2463 l_parent :=
2464 SUBSTR(p_component_code, 1, INSTR(p_component_code, '-', -1) - 1);
2465
2466 IF l_parent = p_x_options_tbl(I).component_code AND
2467 p_x_options_tbl(I).component_code <> p_model_component
2468 THEN
2469 IF l_debug_level > 0 THEN
2470 oe_debug_pub.add('PARENT TO BE MODIFIED '
2471 || P_X_OPTIONS_TBL (I).COMPONENT_CODE , 3 );
2472 END IF;
2473
2474
2475 p_x_options_tbl(I).operation := OE_GLOBALS.G_OPR_UPDATE;
2476 p_x_options_tbl(I).ordered_quantity := 0;
2477 p_x_options_tbl(I).change_reason := 'SYSTEM';
2478
2479 -- recursive call.
2480
2481 IF l_debug_level > 0 THEN
2482 oe_debug_pub.add('RECURSIVE CALL'|| P_MODEL_COMPONENT , 1);
2483 END IF;
2484
2485 Propogate_Change_To_Parent
2486 (p_x_options_tbl => p_x_options_tbl
2487 ,p_component_code => l_parent
2488 ,p_top_model_line_id => p_top_model_line_id
2489 ,p_model_component => p_model_component
2490 ,p_ui_flag => p_ui_flag);
2491
2492 IF l_debug_level > 0 THEN
2493 oe_debug_pub.add('MY CALL WORK DONE' , 1);
2494 END IF;
2495 RETURN;
2496 END IF;
2497 I := p_x_options_tbl.NEXT(I);
2498 END LOOP;
2499
2500 IF l_debug_level > 0 THEN
2501 oe_debug_pub.add('PARENT NOT FOUND??' , 1);
2502 END IF;
2503
2504 END IF;
2505
2506 IF l_debug_level > 0 THEN
2507 oe_debug_pub.add('LEAVING PROPOGATE_CHANGE_TO_PARENT'
2508 || P_COMPONENT_CODE , 1);
2509 END IF;
2510 EXCEPTION
2511 WHEN OTHERS THEN
2512 IF l_debug_level > 0 THEN
2513 oe_debug_pub.add('ECXEPTION IN PROPOGATE_CHANGE_TO_PARENT'
2514 || SQLERRM , 1);
2515 END IF;
2516 RAISE;
2517 END Propogate_Change_To_Parent;
2518
2519
2520 /*----------------------------------------------------------------------
2521 PROCEDURE No_More_Children_Left
2522 delete the parent only if the only option under it is getting deleted.
2523 Never delete the model line.
2524 p_component_code is the component_code of the child, for which
2525 we are trying tofind out if this is the only child to its parent.
2526 ----------------------------------------------------------------------*/
2527 FUNCTION No_More_Children_Left
2528 (p_x_options_tbl IN Oe_Process_Options_Pvt.Selected_Options_Tbl_Type
2529 ,p_component_code IN VARCHAR2
2530 ,p_top_model_line_id IN NUMBER
2531 ,p_model_component IN VARCHAR2
2532 ,p_ui_flag IN VARCHAR2 := 'N')
2533 RETURN BOOLEAN
2534 IS
2535 l_parent VARCHAR2(1000);
2536 l_count NUMBER;
2537 I NUMBER;
2538 --
2539 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2540 --
2541 BEGIN
2542 IF l_debug_level > 0 THEN
2543 oe_debug_pub.add('ENTERING NO_MORE_CHILDREN_LEFT'|| P_UI_FLAG , 1);
2544 END IF;
2545
2546 l_parent :=
2547 SUBSTR(p_component_code, 1, INSTR(p_component_code, '-', -1) - 1);
2548
2549 IF l_debug_level > 0 THEN
2550 oe_debug_pub.add('PARENT: '|| L_PARENT , 3 );
2551 END IF;
2552
2553 IF l_parent = p_model_component THEN
2554 IF l_debug_level > 0 THEN
2555 oe_debug_pub.add('PARENT IS A MODEL' , 1);
2556 END IF;
2557 RETURN FALSE;
2558 END IF;
2559
2560 I := p_x_options_tbl.FIRST;
2561
2562 WHILE I is not NULL
2563 LOOP
2564 IF SUBSTR(p_x_options_tbl(I).component_code, 1,
2565 INSTR(p_component_code, '-', -1) - 1)
2566 = SUBSTR(p_component_code, 1,
2567 INSTR(p_component_code, '-', -1) - 1) -- same parent
2568 AND p_x_options_tbl(I).component_code <> l_parent
2569 AND p_x_options_tbl(I).component_code <> p_component_code
2570 AND p_x_options_tbl(I).operation <> OE_GLOBALS.G_OPR_DELETE
2571 AND NOT(p_x_options_tbl(I).operation = OE_GLOBALS.G_OPR_UPDATE AND
2572 p_x_options_tbl(I).ordered_quantity = 0) -- cancel
2573
2574 THEN
2575 IF l_debug_level > 0 THEN
2576 oe_debug_pub.add('OPTION UNDER SAME PARENT EXISTS' , 3 );
2577 END IF;
2578 RETURN FALSE;
2579 END IF;
2580
2581 I := p_x_options_tbl.NEXT(I);
2582 END LOOP;
2583
2584 IF l_debug_level > 0 THEN
2585 oe_debug_pub.add('CAME OUT OF LOOP' , 3 );
2586 END IF;
2587
2588 -- use sql, may be included item exist.
2589 l_count := 0;
2590
2591 SELECT /* MOAC_SQL_CHANGE */ count(*)
2592 INTO l_count
2593 FROM oe_order_lines_all
2594 WHERE top_model_line_id = p_top_model_line_id
2595 AND item_type_code = OE_GLOBALS.G_ITEM_INCLUDED
2596 AND open_flag = 'Y'
2597 AND link_to_line_id =
2598 (SELECT line_id
2599 FROM oe_order_lines_all
2600 WHERE top_model_line_id = p_top_model_line_id
2601 AND component_code = l_parent
2602 AND open_flag = 'Y' );
2603
2604 IF l_count > 0 THEN
2605 IF l_debug_level > 0 THEN
2606 oe_debug_pub.add('SOME MORE OPTIONS EXIST' , 1);
2607 END IF;
2608 RETURN FALSE;
2609 END IF;
2610
2611 IF l_debug_level > 0 THEN
2612 oe_debug_pub.add('LEAVING NO_MORE_CHILDREN_LEFT' , 1);
2613 END IF;
2614
2615 RETURN TRUE;
2616 EXCEPTION
2617 WHEN OTHERS THEN
2618 IF l_debug_level > 0 THEN
2619 oe_debug_pub.add('ECXEPTION IN NO_MORE_CHILDREN_LEFT'|| SQLERRM , 1);
2620 END IF;
2621 RAISE;
2622 END No_More_Children_Left;
2623
2624
2625 /*----------------------------------------------------------------------
2626 Procedure Name : Validate_Configuration
2627 wrapper API to decide which validation API should be used.
2628
2629 Change Record:
2630
2631 We do not need to call the apt complete_configuration anymore,
2632 because all the code is put in OEXVORDB.pls in the lines loop.
2633 -----------------------------------------------------------------------*/
2634 PROCEDURE Validate_Configuration
2635 (p_model_line_id IN NUMBER,
2636 p_deleted_options_tbl IN OE_Order_PUB.request_tbl_type
2637 := OE_Order_Pub.G_MISS_REQUEST_TBL,
2638 p_updated_options_tbl IN OE_Order_PUB.request_tbl_type
2639 := OE_Order_Pub.G_MISS_REQUEST_TBL,
2640 p_validate_flag IN VARCHAR2 := 'Y',
2641 p_complete_flag IN VARCHAR2 := 'Y',
2642 p_caller IN VARCHAR2 := '',
2643 x_valid_config OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
2644 x_complete_config OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
2645 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
2646
2647 IS
2648 l_header_id NUMBER;
2649 l_config_hdr_id NUMBER;
2650 l_config_rev_nbr NUMBER;
2651 l_configuration_id NUMBER;
2652 l_model_qty NUMBER;
2653 l_use_configurator BOOLEAN;
2654 l_configurator_was_used NUMBER;
2655 l_msg_count NUMBER;
2656 l_msg_data VARCHAR2(2000);
2657 l_return_status VARCHAR2(1):= FND_API.G_RET_STS_SUCCESS;
2658 l_order_source_id NUMBER;
2659 l_orig_sys_document_ref VARCHAR2(50);
2660 l_orig_sys_line_ref VARCHAR2(50);
2661 l_orig_sys_shipment_ref VARCHAR2(50);
2662 l_change_sequence VARCHAR2(50);
2663 l_source_document_type_id NUMBER;
2664 l_source_document_id NUMBER;
2665 l_source_document_line_id NUMBER;
2666 --
2667 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2668 --
2669 BEGIN
2670
2671 IF l_debug_level > 0 THEN
2672 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.VALIDATE_CONFIGURATION' , 1);
2673 END IF;
2674
2675
2676 -- No Copy Changes. Initialized return status to success
2677 x_return_status := FND_API.G_RET_STS_SUCCESS;
2678
2679
2680 --get_transaction_id(p_caller => 'inside validate_config');
2681
2682 BEGIN
2683 SELECT header_id, config_header_id, config_rev_nbr, ordered_quantity,
2684 configuration_id, order_source_id, orig_sys_document_ref,
2685 orig_sys_line_ref, orig_sys_shipment_ref, change_sequence,
2686 source_document_type_id, source_document_id, source_document_line_id
2687 INTO l_header_id, l_config_hdr_id, l_config_rev_nbr, l_model_qty,
2688 l_configuration_id, l_order_source_id, l_orig_sys_document_ref,
2689 l_orig_sys_line_ref, l_orig_sys_shipment_ref, l_change_sequence,
2690 l_source_document_type_id, l_source_document_id, l_source_document_line_id
2691 FROM OE_ORDER_LINES_ALL
2692 WHERE line_id = p_model_line_id;
2693 EXCEPTION
2694 WHEN OTHERS THEN
2695 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2696 END;
2697
2698 OE_Msg_Pub.Set_Msg_Context
2699 (p_entity_code => OE_GLOBALS.G_ENTITY_LINE
2700 ,p_entity_id => p_model_line_id
2701 ,p_header_id => l_header_id
2702 ,p_line_id => p_model_line_id
2703 ,p_order_source_id => l_order_source_id
2704 ,p_orig_sys_document_ref => l_orig_sys_document_ref
2705 ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
2706 ,p_orig_sys_shipment_ref => l_orig_sys_shipment_ref
2707 ,p_change_sequence => l_change_sequence
2708 ,p_source_document_type_id => l_source_document_type_id
2709 ,p_source_document_id => l_source_document_id
2710 ,p_source_document_line_id => l_source_document_line_id);
2711
2712 l_use_configurator := OE_Process_Options_Pvt.Use_Configurator;
2713
2714 IF l_use_configurator THEN
2715 IF l_debug_level > 0 THEN
2716 oe_debug_pub.add('USE CONFIGURATOR IS TRUE' , 1);
2717 END IF;
2718 END IF;
2719
2720 IF l_config_hdr_id is NOT NULL AND
2721 l_config_rev_nbr is NOT NULL THEN
2722 IF l_debug_level > 0 THEN
2723 oe_debug_pub.add('CONFIGURATOR WAS USED' , 1);
2724 END IF;
2725 l_configurator_was_used := 0;
2726 ELSIF
2727 l_configuration_id is NOT NULL THEN
2728 IF l_debug_level > 0 THEN
2729 oe_debug_pub.add('OPTIONS WINDOW WAS USED' , 1);
2730 END IF;
2731 l_configurator_was_used := 1;
2732 ELSE
2733 IF l_debug_level > 0 THEN
2734 oe_debug_pub.add('NEW CONFIGURATION BEING CREATED' , 1);
2735 END IF;
2736 l_configurator_was_used := 2;
2737 END IF;
2738
2739 IF l_use_configurator AND
2740 (l_configurator_was_used = 0 OR
2741 l_configurator_was_used = 2)
2742 THEN
2743 Configurator_Validation
2744 (p_model_line_id => p_model_line_id,
2745 p_deleted_options_tbl => p_deleted_options_tbl,
2746 p_updated_options_tbl => p_updated_options_tbl,
2747 p_caller => p_caller,
2748 x_valid_config => x_valid_config,
2749 x_complete_config => x_complete_config,
2750 x_return_status => x_return_status);
2751
2752 IF l_debug_level > 0 THEN
2753 oe_debug_pub.add('RETURNING AFTER CONFIGURATOR_VALIDATION'
2754 || X_RETURN_STATUS , 2 );
2755 END IF;
2756 RETURN;
2757 END IF;
2758
2759
2760 IF NOT(l_use_configurator) AND
2761 (l_configurator_was_used = 1 OR
2762 l_configurator_was_used = 2)
2763 THEN
2764
2765 Bom_Config_Validation
2766 (p_model_line_id => p_model_line_id,
2767 p_header_id => l_header_id,
2768 p_model_qty => l_model_qty,
2769 p_deleted_options_tbl => p_deleted_options_tbl,
2770 p_updated_options_tbl => p_updated_options_tbl,
2771 p_caller => p_caller,
2772 x_valid_config => x_valid_config,
2773 x_complete_config => x_complete_config,
2774 x_return_status => x_return_status);
2775
2776 IF l_debug_level > 0 THEN
2777 oe_debug_pub.add('RETURNING AFTER BOM_CONFIG_VALIDATION'
2778 || X_RETURN_STATUS , 2 );
2779 END IF;
2780 RETURN;
2781 END IF;
2782
2783 IF l_configurator_was_used <> 0 AND l_use_configurator THEN
2784 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_USE_OPTIONS_WINDOW');
2785 OE_Msg_Pub.Add;
2786 x_return_status:= FND_API.G_RET_STS_ERROR;
2787 END IF;
2788
2789 IF l_configurator_was_used <> 1 AND NOT (l_use_configurator) THEN
2790 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_USE_CONFIGURATOR');
2791 OE_Msg_Pub.Add;
2792 x_return_status:= FND_API.G_RET_STS_ERROR;
2793 END IF;
2794
2795 --get_transaction_id(p_caller => ' leaving validate_config');
2796
2797 oe_msg_pub.count_and_get
2798 ( p_count => l_msg_count
2799 , p_data => l_msg_data );
2800
2801
2802 OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
2803
2804 IF l_debug_level > 0 THEN
2805 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.VALIDATE_CONFIGURATION' , 1);
2806 END IF;
2807 EXCEPTION
2808
2809 WHEN FND_API.G_EXC_ERROR THEN
2810 x_return_status := FND_API.G_RET_STS_ERROR;
2811 --get_transaction_id(p_caller => 'exc error in validate_config');
2812
2813
2814 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2815 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2816 --get_transaction_id(p_caller => 'unxp error in validate_config');
2817
2818
2819 WHEN OTHERS THEN
2820 IF l_debug_level > 0 THEN
2821 oe_debug_pub.add('ERROR IN VALIDATE_CONFIGURATION : '
2822 || SUBSTR ( SQLERRM , 1 , 100 ) , 1);
2823 END IF;
2824 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2825
2826 END Validate_Configuration;
2827
2828
2829 -- create xml message, send it to ui manager
2830 -- get back pieces of xml message
2831 -- process them and generate a long output xml message
2832 -- hardcoded :url,user, passwd, gwyuid,fndnam,two_task
2833
2834 /*-------------------------------------------------------------------
2835 Procedure Name : Send_input_xml
2836 Description : sends the xml batch validation message to SPC that has
2837 options that are newly inserted/updated/deleted
2838 from the model.
2839
2840 SPC validation_status :
2841 CONFIG_PROCESSED constant NUMBER :=0;
2842 CONFIG_PROCESSED_NO_TERMINATE constant NUMBER :=1;
2843 INIT_TOO_LONG constant NUMBER :=2;
2844 INVALID_OPTION_REQUEST constant NUMBER :=3;
2845 CONFIG_EXCEPTION constant NUMBER :=4;
2846 DATABASE_ERROR constant NUMBER :=5;
2847 UTL_HTTP_INIT_FAILED constant NUMBER :=6;
2848 UTL_HTTP_REQUEST_FAILED constant NUMBER :=7;
2849
2850 Change Record:
2851
2852 Decimal ratio check is is moved to OE_VALIDATE_LINE
2853 for Decimal quantities for ATO Options Project
2854 the decimal ratio check will be part of line entity
2855 validation
2856
2857 ---------------------------------------------------------------------*/
2858
2859 PROCEDURE Send_input_xml
2860 ( p_model_line_id IN NUMBER ,
2861 p_deleted_options_tbl IN OE_Order_PUB.request_tbl_type
2862 := OE_Order_Pub.G_MISS_REQUEST_TBL,
2863 p_updated_options_tbl IN OE_Order_PUB.request_tbl_type
2864 := OE_Order_Pub.G_MISS_REQUEST_TBL,
2865 p_model_qty IN NUMBER,
2866 p_xml_hdr IN VARCHAR2,
2867 x_out_xml_msg OUT NOCOPY /* file.sql.39 change */ LONG ,
2868 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2 )
2869 IS
2870 l_html_pieces CZ_BATCH_VALIDATE.CFG_OUTPUT_PIECES;
2871 l_option CZ_BATCH_VALIDATE.INPUT_SELECTION;
2872 l_batch_val_tbl CZ_BATCH_VALIDATE.CFG_INPUT_LIST;
2873 l_db_options_tbl OE_Process_Options_Pvt.SELECTED_OPTIONS_TBL_TYPE;
2874 -- update / delete options
2875 l_req_rec OE_Order_Pub.Request_Rec_Type;
2876 l_flag VARCHAR2(30) := '0';
2877
2878 --variable to fetch from cursor Get_Options
2879 l_component_code VARCHAR2(1000);
2880 l_configuration_id NUMBER;
2881 l_send_model_flag VARCHAR2(1);
2882 -- message related
2883 l_validation_status NUMBER;
2884 l_sequence NUMBER := 0;
2885 l_url VARCHAR2(500):=
2886 FND_PROFILE.Value('CZ_UIMGR_URL');
2887 l_rec_index BINARY_INTEGER;
2888 l_xml_hdr VARCHAR2(2000);
2889 l_long_xml LONG := NULL;
2890 l_return_status VARCHAR2(1) :=
2891 FND_API.G_RET_STS_SUCCESS;
2892 I NUMBER;
2893 --
2894 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2895 --
2896 BEGIN
2897
2898 IF l_debug_level > 0 THEN
2899 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.SEND_INPUT_XML' , 1);
2900 oe_debug_pub.add('UIMANAGER URL: ' || L_URL , 2 );
2901 END IF;
2902
2903
2904 l_xml_hdr := p_xml_hdr;
2905 IF l_debug_level > 0 THEN
2906 oe_debug_pub.add('LENGTH OF INI MSG: ' || LENGTH ( L_XML_HDR ) , 2 );
2907 END IF;
2908
2909
2910 -- if there is change in model qty and we have cascaded it
2911 -- to all options, w/o communicating this to SPC
2912 -- send the new model qty in batch validation.
2913
2914 l_send_model_flag := 'Y';
2915
2916 BEGIN
2917 SELECT ol.component_code, ol.configuration_id
2918 INTO l_component_code, l_configuration_id
2919 FROM oe_order_lines ol, cz_config_details_v cz
2920 WHERE ol.line_id = p_model_line_id
2921 AND cz.component_code = ol.component_code
2922 AND cz.config_hdr_id = ol.config_header_id
2923 AND cz.config_rev_nbr = ol.config_rev_nbr
2924 AND cz.quantity <> ol.ordered_quantity;
2925
2926 EXCEPTION
2927 WHEN NO_DATA_FOUND THEN
2928 l_send_model_flag := 'N';
2929
2930 WHEN OTHERS THEN
2931 RAISE FND_API.G_EXC_ERROR;
2932 END;
2933
2934
2935 IF l_send_model_flag = 'Y' THEN
2936 l_sequence := l_sequence + 1;
2937 l_option.component_code := l_component_code;
2938 l_option.quantity := p_model_qty;
2939 l_option.input_seq := l_sequence;
2940
2941 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110508' THEN
2942 IF l_debug_level > 0 THEN
2943 oe_debug_pub.add('SEND XML UCFGB MI , PACK H NEW LOGIC' , 3 );
2944 END IF;
2945 l_option.config_item_id := l_configuration_id;
2946 END IF;
2947
2948 l_batch_val_tbl(l_sequence) := l_option;
2949
2950 IF l_debug_level > 0 THEN
2951 oe_debug_pub.add('NEW MODEL QTY: '|| P_MODEL_QTY , 2 );
2952 END IF;
2953
2954 END IF;
2955
2956 -- get the options from the from databse.
2957 IF l_debug_level > 0 THEN
2958 oe_debug_pub.add('GETTING PREVIOUSLY SAVED OPTIONS FROM DB' , 2 );
2959 END IF;
2960
2961 OE_Process_Options_Pvt.Get_Options_From_DB
2962 ( p_top_model_line_id => p_model_line_id
2963 ,x_disabled_options => l_flag
2964 ,x_options_tbl => l_db_options_tbl);
2965
2966 IF l_debug_level > 0 THEN
2967 oe_debug_pub.add('cursor GET NEWLY INSERTED OPTIONS '|| l_flag , 2 );
2968 END IF;
2969
2970 I := l_db_options_tbl.FIRST;
2971 WHILE I is not NULL
2972 LOOP
2973 IF l_debug_level > 0 THEN
2974 oe_debug_pub.add('GET_OPTION : '
2975 || L_DB_OPTIONS_TBL (I).COMPONENT_CODE , 2 );
2976 END IF;
2977
2978 l_sequence := l_sequence + 1;
2979
2980 l_option.component_code := l_db_options_tbl(I).component_code;
2981 l_option.input_seq := l_sequence;
2982
2983 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110508' THEN
2984 IF l_debug_level > 0 THEN
2985 oe_debug_pub.add('SEND XML UCFGB MI , PACK H NEW LOGIC' , 3 );
2986 END IF;
2987 l_option.config_item_id
2988 := l_db_options_tbl(I).configuration_id;
2989 END IF;
2990
2991 IF l_debug_level > 0 THEN
2992 oe_debug_pub.add('QTY RATIO : '
2993 || L_DB_OPTIONS_TBL (I).ORDERED_QUANTITY/P_MODEL_QTY , 2 );
2994 oe_debug_pub.add('OE QTY: '
2995 || L_DB_OPTIONS_TBL (I).ORDERED_QUANTITY , 2 );
2996 END IF;
2997
2998 l_option.quantity := l_db_options_tbl(I).ordered_quantity;
2999
3000 l_batch_val_tbl(l_sequence) := l_option;
3001
3002 IF l_debug_level > 0 THEN
3003 oe_debug_pub.add(L_SEQUENCE||' '
3004 ||L_DB_OPTIONS_TBL (I).CONFIGURATION_ID , 2 );
3005 END IF;
3006
3007 I := l_db_options_tbl.NEXT(I);
3008 END LOOP;
3009
3010 IF l_debug_level > 0 THEN
3011 oe_debug_pub.add('OUT OF NEWLY INSERTED OPTIONS LOOP' , 2 );
3012 END IF;
3013
3014
3015 --------------- send updated options/classes----------------
3016
3017
3018 IF l_debug_level > 0 THEN
3019 oe_debug_pub.add('NO. OF UPDATED OPTIONS: '
3020 ||P_UPDATED_OPTIONS_TBL.COUNT , 2 );
3021 oe_debug_pub.add('ENTERING LOOP TO PASS UPDATED OPTIONS' , 2 );
3022 END IF;
3023
3024
3025 l_rec_index := 1;
3026
3027 FOR I IN 1..p_updated_options_tbl.COUNT
3028 LOOP
3029 IF l_debug_level > 0 THEN
3030 oe_debug_pub.add('WITHIN THE LOOP OF P_UPDATED_OPTIONS_TBL' , 2 );
3031 oe_debug_pub.add('L_REC_INDEX: ' || L_REC_INDEX , 2 );
3032 END IF;
3033
3034 l_req_rec := p_updated_options_tbl(l_rec_index);
3035
3036 IF l_debug_level > 0 THEN
3037 oe_debug_pub.add('UPDATE LINE_ID: ' || L_REQ_REC.ENTITY_ID , 2 );
3038 oe_debug_pub.add('COMPONENT_CODE: ' || L_REQ_REC.PARAM2 , 2 );
3039 END IF;
3040
3041 l_sequence := l_sequence + 1;
3042
3043 l_option.component_code := l_req_rec.param2;
3044 l_option.input_seq := l_sequence;
3045
3046 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110508' THEN
3047 IF l_debug_level > 0 THEN
3048 oe_debug_pub.add('UPD , SEND XML MI , PACK H NEW LOGIC' , 3 );
3049 END IF;
3050 l_option.config_item_id := l_req_rec.param9;
3051 END IF;
3052
3053 -- check if integer
3054
3055 IF l_debug_level > 0 THEN
3056 oe_debug_pub.add(L_REQ_REC.PARAM2
3057 || ' OPTION UPDATED TO A QTY OF: ' || L_REQ_REC.PARAM5 , 3 );
3058 END IF;
3059
3060 l_option.quantity := l_req_rec.param5;
3061
3062 l_batch_val_tbl(l_sequence) := l_option;
3063 l_rec_index := l_rec_index + 1;
3064
3065 IF l_debug_level > 0 THEN
3066 oe_debug_pub.add(L_SEQUENCE||' SEQ '||L_REQ_REC.PARAM9 , 2 );
3067 END IF;
3068
3069 END LOOP;
3070
3071 IF l_debug_level > 0 THEN
3072 oe_debug_pub.add('LEAVING LOOP TO PASS UPDATED OPTIONS' , 2 );
3073 END IF;
3074
3075
3076
3077 ------------ send deleted options/classes-------------------
3078
3079 IF l_debug_level > 0 THEN
3080 oe_debug_pub.add('NO. OF DELETED OPTIONS: '
3081 ||P_DELETED_OPTIONS_TBL.COUNT , 2 );
3082 oe_debug_pub.add('ENTERING LOOP TO PASS DELETED OPTIONS' , 2 );
3083 END IF;
3084
3085 l_rec_index := 1;
3086 FOR I IN 1..p_deleted_options_tbl.COUNT
3087 LOOP
3088
3089 IF l_debug_level > 0 THEN
3090 oe_debug_pub.add('WITHIN THE LOOP OF P_DELETED_OPTIONS_TBL' , 2 );
3091 oe_debug_pub.add('L_REC_INDEX: ' || L_REC_INDEX , 2 );
3092 END IF;
3093
3094
3095 l_req_rec := p_deleted_options_tbl(l_rec_index);
3096 IF l_debug_level > 0 THEN
3097 oe_debug_pub.add('ENTITY ID: ' || L_REQ_REC.ENTITY_ID , 2 );
3098 oe_debug_pub.add('COMPONENT_CODE: ' || L_REQ_REC.PARAM2 , 2 );
3099 END IF;
3100
3101 l_sequence := l_sequence + 1;
3102
3103 l_option.component_code := l_req_rec.param2;
3104 l_option.input_seq := l_sequence;
3105 l_option.quantity := 0;
3106
3107
3108 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110508' THEN
3109 IF l_debug_level > 0 THEN
3110 oe_debug_pub.add('DEL , SEND XML MI , PACK H NEW LOGIC' , 3 );
3111 END IF;
3112 l_option.config_item_id
3113 := l_req_rec.param9;
3114 END IF;
3115
3116 l_batch_val_tbl(l_sequence) := l_option;
3117 l_rec_index := l_rec_index + 1;
3118
3119 IF l_debug_level > 0 THEN
3120 oe_debug_pub.add(L_SEQUENCE||' SEQ '||L_REQ_REC.PARAM9 , 2 );
3121 END IF;
3122 END LOOP;
3123
3124 IF l_debug_level > 0 THEN
3125 oe_debug_pub.add('OUT OF INSERT/UPDATE/DELETE OPTIONS LOOPS ' , 1);
3126 END IF;
3127
3128
3129 -- delete previous data.
3130 IF (l_html_pieces.COUNT <> 0) THEN
3131 l_html_pieces.DELETE;
3132 END IF;
3133
3134
3135 --get_transaction_id
3136 --(p_caller => 'inside send_xml, before call to SPC validate');
3137
3138 CZ_BATCH_VALIDATE.Validate
3139 ( config_input_list => l_batch_val_tbl ,
3140 init_message => l_xml_hdr ,
3141 config_messages => l_html_pieces ,
3142 validation_status => l_validation_status ,
3143 URL => l_url );
3144
3145
3146 --get_transaction_id
3147 --(p_caller => 'inside send_xml, after call to SPC validate');
3148
3149 IF l_debug_level > 0 THEN
3150 oe_debug_pub.add('AFTER CALL TO SPC , STATUS : '
3151 ||L_VALIDATION_STATUS , 1);
3152 END IF;
3153
3154 IF l_validation_status <> 0 THEN
3155 IF l_debug_level > 0 THEN
3156 oe_debug_pub.add('DO NOT PROCESS RESULTS , ERROR ',1);
3157 END IF;
3158 RAISE FND_API.G_EXC_ERROR;
3159 END IF;
3160
3161 IF (l_html_pieces.COUNT <= 0) THEN
3162 IF l_debug_level > 0 THEN
3163 oe_debug_pub.add('HTML_PIECES COUNT IS <= 0' , 2 );
3164 END IF;
3165 RAISE FND_API.G_EXC_ERROR;
3166 END IF;
3167
3168
3169 l_rec_index := l_html_pieces.FIRST;
3170 LOOP
3171 IF l_debug_level > 0 THEN
3172 oe_debug_pub.add(L_REC_INDEX ||': PART OF OUTPUT_MESSAGE: '
3173 || SUBSTR ( L_HTML_PIECES ( L_REC_INDEX ) , 1 , 100 ) , 2 );
3174 END IF;
3175
3176 l_long_xml := l_long_xml || l_html_pieces(l_rec_index);
3177
3178 EXIT WHEN l_rec_index = l_html_pieces.LAST;
3179 l_rec_index := l_html_pieces.NEXT(l_rec_index);
3180
3181 END LOOP;
3182
3183 -- if everything ok, set out NOCOPY values
3184 x_out_xml_msg := l_long_xml;
3185 x_return_status := l_return_status;
3186
3187 IF l_debug_level > 0 THEN
3188 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.SEND_INPUT_XML' , 1);
3189 END IF;
3190
3191 EXCEPTION
3192 WHEN FND_API.G_EXC_ERROR THEN
3193 --get_transaction_id
3194 --(p_caller => 'send_xml exc error, before call to SPC validate');
3195
3196 x_return_status := FND_API.G_RET_STS_ERROR;
3197 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_VALIDATION_FAILURE');
3198 OE_Msg_Pub.Add;
3199
3200 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3201 --get_transaction_id
3202 --(p_caller => 'send_xml unxp, before call to SPC validate');
3203 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3204 IF l_debug_level > 0 THEN
3205 oe_debug_pub.add('AN UNEXP ERROR RAISED' , 1);
3206 END IF;
3207
3208 IF l_debug_level > 0 THEN
3209 oe_debug_pub.add('SEND_INPUT_XML ERROR: '
3210 || SUBSTR ( SQLERRM , 1 , 100 ) , 1);
3211 END IF;
3212
3213
3214 WHEN OTHERS THEN
3215 --get_transaction_id
3216 --(p_caller=> 'send_xml others error, before call to SPC validate');
3217
3218 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3219
3220 IF l_debug_level > 0 THEN
3221 oe_debug_pub.add
3222 ('SEND_INPUT_XML ERROR: ' || SUBSTR ( SQLERRM , 1 , 100 ) , 1);
3223 END IF;
3224
3225 END Send_input_xml;
3226
3227
3228 /*-------------------------------------------------------------------------
3229 Procedure Name : Create_hdr_xml
3230 Description : creates a batch validation header message.
3231 --------------------------------------------------------------------------*/
3232
3233 PROCEDURE Create_hdr_xml
3234 ( p_model_line_id IN NUMBER
3235 , p_ui_flag IN VARCHAR2 := 'N'
3236 , x_xml_hdr OUT NOCOPY /* file.sql.39 change */ VARCHAR2 )
3237 IS
3238
3239 TYPE param_name_type IS TABLE OF VARCHAR2(30)
3240 INDEX BY BINARY_INTEGER;
3241
3242 TYPE param_value_type IS TABLE OF VARCHAR2(200)
3243 INDEX BY BINARY_INTEGER;
3244
3245 param_name param_name_type;
3246 param_value param_value_type;
3247
3248 l_rec_index BINARY_INTEGER;
3249
3250 l_model_line_rec OE_Order_Pub.Line_Rec_Type;
3251
3252 -- SPC specific params
3253 l_database_id VARCHAR2(100);
3254 l_save_config_behavior VARCHAR2(30):= 'new_revision';
3255 l_ui_type VARCHAR2(30):= null;
3256 l_msg_behavior VARCHAR2(30):= 'brief';
3257
3258 --ont parameters
3259 l_context_org_id VARCHAR2(80);
3260 l_inventory_item_id VARCHAR2(80);
3261 l_config_header_id VARCHAR2(80);
3262 l_config_rev_nbr VARCHAR2(80);
3263 l_model_quantity VARCHAR2(80);
3264 l_pricing_package_name VARCHAR2(100)
3265 := 'OE_Config_Price_Util';
3266 l_price_items_proc VARCHAR2(100)
3267 := 'OE_Config_Price_Items';
3268 l_configurator_session_key VARCHAR2(100):= NULL;
3269 l_session_id VARCHAR2(80)
3270 := FND_PROFILE.Value('DB_SESSION_ID');
3271 l_count NUMBER;
3272 -- message related
3273 l_xml_hdr VARCHAR2(2000):=
3274 '<initialize>';
3275 l_dummy VARCHAR2(500) := NULL;
3276 l_return_status VARCHAR2(1)
3277 := FND_API.G_RET_STS_SUCCESS;
3278
3279 l_config_effective_date DATE;
3280 l_old_behavior VARCHAR2(1);
3281 l_frozen_model_bill VARCHAR2(1);
3282 --
3283 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3284 --
3285 BEGIN
3286
3287 IF l_debug_level > 0 THEN
3288 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.CREATE_HDR_XML' , 1);
3289 END IF;
3290
3291 OE_LINE_UTIL.Query_Row(p_line_id => p_model_line_id
3292 ,x_line_rec => l_model_line_rec);
3293
3294 -- now set the values from model_rec and org_id
3295 l_context_org_id :=
3296 OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');
3297 l_inventory_item_id := to_char(l_model_line_rec.inventory_item_id);
3298 l_config_header_id := to_char(l_model_line_rec.config_header_id);
3299 l_config_rev_nbr := to_char(l_model_line_rec.config_rev_nbr);
3300
3301
3302 l_model_quantity := to_char(l_model_line_rec.ordered_quantity);
3303
3304
3305 IF l_debug_level > 0 THEN
3306 oe_debug_pub.add('QUERIED FROM OE_LINES: ' || ' QTY: '
3307 || L_MODEL_QUANTITY || ' CONFIG-HDR: '
3308 || L_CONFIG_HEADER_ID || ' CONFIG-REV: '
3309 || L_CONFIG_REV_NBR || ' ORG-ID: '
3310 || L_CONTEXT_ORG_ID || ' ITEM-ID: '
3311 || L_INVENTORY_ITEM_ID , 2 );
3312 END IF;
3313
3314 -- profiles and env. variables.
3315 l_database_id := fnd_web_config.database_id;
3316 IF l_debug_level > 0 THEN
3317 oe_debug_pub.add('DATABASE_ID: '|| L_DATABASE_ID , 2 );
3318 END IF;
3319
3320 -- set param_names
3321
3322 param_name(1) := 'database_id';
3323 param_name(2) := 'context_org_id';
3324 param_name(3) := 'config_creation_date';
3325 param_name(4) := 'calling_application_id';
3326 param_name(5) := 'responsibility_id';
3327 param_name(6) := 'model_id';
3328 param_name(7) := 'config_header_id';
3329 param_name(8) := 'config_rev_nbr';
3330 param_name(9) := 'read_only';
3331 param_name(10) := 'save_config_behavior';
3332 param_name(11) := 'ui_type';
3333 param_name(12) := 'validation_org_id';
3334 param_name(13) := 'terminate_msg_behavior';
3335 param_name(14) := 'model_quantity';
3336 param_name(15) := 'icx_session_ticket';
3337 param_name(16) := 'client_header';
3338 param_name(17) := 'client_line';
3339 param_name(18) := 'sbm_flag';
3340 param_name(19) := 'config_effective_date';
3341 param_name(20) := 'config_model_lookup_date';
3342 l_count := 20;
3343
3344 IF p_ui_flag = 'Y' THEN
3345 param_name(21) := 'pricing_package_name';
3346 param_name(22) := 'price_mult_items_proc';
3347 param_name(23) := 'configurator_session_key';
3348 l_count := 23;
3349 END IF;
3350 -- set param values
3351
3352 param_value(1) := l_database_id;
3353 param_value(2) := l_context_org_id;
3354 param_value(3) := to_char(l_model_line_rec.creation_date,
3355 'MM-DD-YYYY-HH24-MI-SS');
3356 --5249719: hardcoding application id
3357 param_value(4) := 660; --fnd_profile.value('RESP_APPL_ID');
3358 param_value(5) := fnd_profile.value('RESP_ID');
3359 param_value(6) := l_inventory_item_id;
3360 param_value(7) := l_config_header_id;
3361 param_value(8) := l_config_rev_nbr;
3362 param_value(9) := null;
3363 param_value(10) := l_save_config_behavior;
3364 param_value(11) := l_ui_type;
3365 param_value(12) := null;
3366 param_value(13) := l_msg_behavior;
3367 param_value(14) := l_model_quantity;
3368 param_value(15) := cz_cf_api.icx_session_ticket;
3369 param_value(16) := to_char(l_model_line_rec.header_id);
3370 param_value(17) := to_char(l_model_line_rec.line_id);
3371
3372 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110508' THEN
3373 IF l_debug_level > 0 THEN
3374 oe_debug_pub.add('UCFGB MI , PACK H NEW LOGIC' , 1);
3375 END IF;
3376 param_value(18) := 'TRUE';
3377 ELSE
3378 param_value(18) := 'FALSE';
3379 END IF;
3380
3381 OE_Config_Util.Get_Config_Effective_Date
3382 ( p_model_line_rec => l_model_line_rec
3383 ,x_old_behavior => l_old_behavior
3384 ,x_config_effective_date => l_config_effective_date
3385 ,x_frozen_model_bill => l_frozen_model_bill);
3386
3387 IF l_old_behavior = 'N' THEN
3388 param_value(19) := to_char(l_config_effective_date,
3389 'MM-DD-YYYY-HH24-MI-SS');
3390 param_value(20) := param_value(19);
3391 ELSE
3392 param_value(19) := null;
3393 param_value(20) := null;
3394
3395 IF l_debug_level > 0 THEN
3396 oe_debug_pub.add('old behavior no dates', 2 );
3397 END IF;
3398 END IF;
3399
3400
3401 IF p_ui_flag = 'Y' THEN
3402 param_value(21) := l_pricing_package_name;
3403 param_value(22) := l_price_items_proc;
3404
3405 l_configurator_session_key
3406 := ( p_model_line_id || '#' || l_session_id);
3407
3408 IF l_debug_level > 0 THEN
3409 oe_debug_pub.add('CONFIG SESSION KEY : '
3410 || L_CONFIGURATOR_SESSION_KEY , 2 );
3411 END IF;
3412
3413 param_value(23) := l_configurator_session_key;
3414 END IF;
3415
3416 IF l_debug_level > 0 THEN
3417 oe_debug_pub.add('INSIDE CREATE_HDR_XML , PARAMETERS ARE SET' , 2 );
3418 END IF;
3419
3420
3421 l_rec_index := 1;
3422
3423 LOOP
3424 -- ex : <param name="config_header_id">1890</param>
3425
3426 IF (param_value(l_rec_index) IS NOT NULL) THEN
3427
3428 l_dummy := '<param name=' ||
3429 '"' || param_name(l_rec_index) || '"'
3430 ||'>'|| param_value(l_rec_index) ||
3431 '</param>';
3432
3433 l_xml_hdr := l_xml_hdr || l_dummy;
3434
3435 END IF;
3436
3437 l_dummy := NULL;
3438
3439 l_rec_index := l_rec_index + 1;
3440 EXIT WHEN l_rec_index > l_count;
3441
3442 END LOOP;
3443
3444
3445 -- add termination tags
3446
3447 l_xml_hdr := l_xml_hdr || '</initialize>';
3448 l_xml_hdr := REPLACE(l_xml_hdr, ' ' , '+');
3449
3450 IF l_debug_level > 0 THEN
3451 oe_debug_pub.add('1ST PART OF CREATE_HDR_XML IS : '
3452 ||SUBSTR ( L_XML_HDR , 1 , 200 ) , 3 );
3453 oe_debug_pub.add('2ND PART OF CREATE_HDR_XML IS : '
3454 ||SUBSTR ( L_XML_HDR , 201 , 200 ) , 3 );
3455 oe_debug_pub.add('3RD PART OF CREATE_HDR_XML IS : '
3456 ||SUBSTR ( L_XML_HDR , 401 , 200 ) , 3 );
3457 oe_debug_pub.add('4TH PART OF CREATE_HDR_XML IS : '
3458 ||SUBSTR ( L_XML_HDR , 601 , 200 ) , 3 );
3459 END IF;
3460
3461 x_xml_hdr := l_xml_hdr;
3462 IF l_debug_level > 0 THEN
3463 oe_debug_pub.add('LENGTH OF INI MSG:' || LENGTH ( L_XML_HDR ) , 3 );
3464 oe_debug_pub.add('LEAVING CREATE_HDR_XML' , 3 );
3465 END IF;
3466 EXCEPTION
3467 when others then
3468 IF l_debug_level > 0 THEN
3469 oe_debug_pub.add('EXCEPTION IN CREATE_HDR_XML '|| SQLERRM , 3 );
3470 END IF;
3471 RAISE;
3472 END Create_hdr_xml;
3473
3474
3475
3476 /*-------------------------------------------------------------------------
3477 Procedure Name : Parse_output_xml
3478 Description : Parses the output of SPC to get the valid and complete flag
3479 populates messages from SPC in oe's message stack.
3480
3481 Change Record :
3482 Bug 2292308 : Display different messages for Incomplete and
3483 Invalid Configurations.
3484 --------------------------------------------------------------------------*/
3485
3486 PROCEDURE Parse_output_xml
3487 (p_xml IN LONG,
3488 p_line_id IN NUMBER,
3489 x_valid_config OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
3490 x_complete_config OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
3491 x_config_header_id OUT NOCOPY /* file.sql.39 change */ NUMBER,
3492 x_config_rev_nbr OUT NOCOPY /* file.sql.39 change */ NUMBER,
3493 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2 )
3494 IS
3495
3496 l_exit_start_tag VARCHAR2(20) := '<EXIT>';
3497 l_exit_end_tag VARCHAR2(20) := '</EXIT>';
3498 l_exit_start_pos NUMBER;
3499 l_exit_end_pos NUMBER;
3500
3501 l_valid_config_start_tag VARCHAR2(30) := '<VALID_CONFIGURATION>';
3502 l_valid_config_end_tag VARCHAR2(30) := '</VALID_CONFIGURATION>';
3503 l_valid_config_start_pos NUMBER;
3504 l_valid_config_end_pos NUMBER;
3505
3506 l_complete_config_start_tag VARCHAR2(30) := '<COMPLETE_CONFIGURATION>';
3507 l_complete_config_end_tag VARCHAR2(30) := '</COMPLETE_CONFIGURATION>';
3508 l_complete_config_start_pos NUMBER;
3509 l_complete_config_end_pos NUMBER;
3510
3511 l_config_header_id_start_tag VARCHAR2(20) := '<CONFIG_HEADER_ID>';
3512 l_config_header_id_end_tag VARCHAR2(20) := '</CONFIG_HEADER_ID>';
3513 l_config_header_id_start_pos NUMBER;
3514 l_config_header_id_end_pos NUMBER;
3515
3516 l_config_rev_nbr_start_tag VARCHAR2(20) := '<CONFIG_REV_NBR>';
3517 l_config_rev_nbr_end_tag VARCHAR2(20) := '</CONFIG_REV_NBR>';
3518 l_config_rev_nbr_start_pos NUMBER;
3519 l_config_rev_nbr_end_pos NUMBER;
3520
3521 l_message_text_start_tag VARCHAR2(20) := '<MESSAGE_TEXT>';
3522 l_message_text_end_tag VARCHAR2(20) := '</MESSAGE_TEXT>';
3523 l_message_text_start_pos NUMBER;
3524 l_message_text_end_pos NUMBER;
3525
3526 l_message_type_start_tag VARCHAR2(20) := '<MESSAGE_TYPE>';
3527 l_message_type_end_tag VARCHAR2(20) := '</MESSAGE_TYPE>';
3528 l_message_type_start_pos NUMBER;
3529 l_message_type_end_pos NUMBER;
3530
3531 l_exit VARCHAR(20);
3532 l_config_header_id NUMBER;
3533 l_config_rev_nbr NUMBER;
3534 l_message_text VARCHAR2(2000);
3535 l_message_type VARCHAR2(200);
3536 l_list_price NUMBER;
3537 l_selection_line_id NUMBER;
3538 l_valid_config VARCHAR2(10);
3539 l_complete_config VARCHAR2(10);
3540 l_header_id NUMBER;
3541 l_return_status VARCHAR2(1) :=
3542 FND_API.G_RET_STS_SUCCESS;
3543 l_return_status_del VARCHAR2(1);
3544 l_msg VARCHAR2(2000);
3545 l_constraint VARCHAR2(16);
3546 l_flag VARCHAR2(1) := 'N';
3547
3548 --
3549 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3550 --
3551 BEGIN
3552
3553 IF l_debug_level > 0 THEN
3554 oe_debug_pub.add('ENTERING OE_CONGIG_UTIL.PARSE_OUTPUT_XML' , 1);
3555 END IF;
3556
3557
3558 l_exit_start_pos :=
3559 INSTR(p_xml, l_exit_start_tag,1, 1) +
3560 length(l_exit_start_tag);
3561
3562 l_exit_end_pos :=
3563 INSTR(p_xml, l_exit_end_tag,1, 1) - 1;
3564
3565 l_exit := SUBSTR (p_xml, l_exit_start_pos,
3566 l_exit_end_pos - l_exit_start_pos + 1);
3567
3568 IF l_debug_level > 0 THEN
3569 oe_debug_pub.add('L_EXIT: ' || L_EXIT , 3 );
3570 END IF;
3571
3572 -- if error go to msg etc.
3573 IF nvl(l_exit,'ERROR') <> 'ERROR' THEN
3574
3575 l_valid_config_start_pos :=
3576 INSTR(p_xml, l_valid_config_start_tag,1, 1) +
3577 length(l_valid_config_start_tag);
3578
3579 l_valid_config_end_pos :=
3580 INSTR(p_xml, l_valid_config_end_tag,1, 1) - 1;
3581
3582 l_valid_config := SUBSTR( p_xml, l_valid_config_start_pos,
3583 l_valid_config_end_pos -
3584 l_valid_config_start_pos + 1);
3585
3586 IF l_debug_level > 0 THEN
3587 oe_debug_pub.add('GG1: '|| L_VALID_CONFIG , 3 );
3588 END IF;
3589
3590 /* ex :- <VALID_CONFIGURATION>abc</VALID_CONFIGURATION>
3591 1st instr : posin of a(22), 2nd instr gives posn of c(24)
3592 substr gives string starting from
3593 posn a to posn c - posn a + 1(3)*/
3594
3595 l_complete_config_start_pos :=
3596 INSTR(p_xml, l_complete_config_start_tag,1, 1) +
3597 length(l_complete_config_start_tag);
3598 l_complete_config_end_pos :=
3599 INSTR(p_xml, l_complete_config_end_tag,1, 1) - 1;
3600
3601 l_complete_config := SUBSTR( p_xml, l_complete_config_start_pos,
3602 l_complete_config_end_pos -
3603 l_complete_config_start_pos + 1);
3604
3605 IF l_debug_level > 0 THEN
3606 oe_debug_pub.add('GG2: '|| L_COMPLETE_CONFIG , 3 );
3607 END IF;
3608
3609
3610 IF (nvl(l_valid_config, 'N') <> 'TRUE') THEN
3611 IF l_debug_level > 0 THEN
3612 oe_debug_pub.add('SPC RETURNED VALID_FLAG AS NULL/FALSE' , 2 );
3613 END IF;
3614 l_flag := 'Y';
3615 END IF ;
3616
3617
3618 IF (nvl(l_complete_config, 'N') <> 'TRUE' ) THEN
3619 IF l_debug_level > 0 THEN
3620 oe_debug_pub.add('COMPLETE_FLAG AS NULL/FALSE' , 2 );
3621 END IF;
3622 l_flag := 'Y';
3623 END IF;
3624
3625 IF l_debug_level > 0 THEN
3626 oe_debug_pub.add('SPC VALID_CONFIG FLAG: ' || L_VALID_CONFIG , 2 );
3627 oe_debug_pub.add('COMPLETE_CONFIG FLAG: ' || L_COMPLETE_CONFIG , 2 );
3628 END IF;
3629
3630 END IF; /* if not error */
3631
3632
3633 -- parsing message_text and type is not req. I use it for debugging.
3634
3635 l_message_text_start_pos :=
3636 INSTR(p_xml, l_message_text_start_tag,1, 1) +
3637 length(l_message_text_start_tag);
3638 l_message_text_end_pos :=
3639 INSTR(p_xml, l_message_text_end_tag,1, 1) - 1;
3640
3641 l_message_text := SUBSTR( p_xml, l_message_text_start_pos,
3642 l_message_text_end_pos -
3643 l_message_text_start_pos + 1);
3644
3645 IF l_debug_level > 0 THEN
3646 oe_debug_pub.add('GG3: '|| L_MESSAGE_TEXT , 3 );
3647 END IF;
3648
3649 l_message_type_start_pos :=
3650 INSTR(p_xml, l_message_type_start_tag,1, 1) +
3651 length(l_message_type_start_tag);
3652 l_message_type_end_pos :=
3653 INSTR(p_xml, l_message_type_end_tag,1, 1) - 1;
3654
3655 l_message_type := SUBSTR( p_xml, l_message_type_start_pos,
3656 l_message_type_end_pos -
3657 l_message_type_start_pos + 1);
3658
3659
3660 -- get the latest config_header_id, and rev_nbr to get
3661 -- messages if any.
3662
3663 IF l_debug_level > 0 THEN
3664 oe_debug_pub.add('SPC RETURNED MESSAGE_TEXT: '|| L_MESSAGE_TEXT , 2 );
3665 oe_debug_pub.add('SPC RETURNED MESSAGE_TYPE: '|| L_MESSAGE_TYPE , 2 );
3666 END IF;
3667
3668
3669 l_config_header_id_start_pos :=
3670 INSTR(p_xml, l_config_header_id_start_tag, 1, 1)+
3671 length(l_config_header_id_start_tag);
3672
3673 l_config_header_id_end_pos :=
3674 INSTR(p_xml, l_config_header_id_end_tag, 1, 1) - 1;
3675
3676 l_config_header_id :=
3677 to_number(SUBSTR( p_xml,l_config_header_id_start_pos,
3678 l_config_header_id_end_pos -
3679 l_config_header_id_start_pos + 1));
3680
3681
3682 l_config_rev_nbr_start_pos :=
3683 INSTR(p_xml, l_config_rev_nbr_start_tag, 1, 1)+
3684 length(l_config_rev_nbr_start_tag);
3685
3686 l_config_rev_nbr_end_pos :=
3687 INSTR(p_xml, l_config_rev_nbr_end_tag, 1, 1) - 1;
3688
3689 l_config_rev_nbr :=
3690 to_number(SUBSTR( p_xml,l_config_rev_nbr_start_pos,
3691 l_config_rev_nbr_end_pos -
3692 l_config_rev_nbr_start_pos + 1));
3693
3694 IF l_debug_level > 0 THEN
3695 oe_debug_pub.add('CONFIG_HEADER_ID AS:' || L_CONFIG_HEADER_ID , 2 );
3696 oe_debug_pub.add('CONFIG_REV_NBR AS:' || L_CONFIG_REV_NBR , 2 );
3697 END IF;
3698
3699
3700 IF (l_flag = 'Y' ) OR
3701 l_exit is NULL OR
3702 l_exit = 'ERROR' THEN
3703
3704 IF l_debug_level > 0 THEN
3705 oe_debug_pub.add('GETTING MESSAGES FROM CZ_CONFIG_MESSAGES' , 2 );
3706 END IF;
3707
3708 Message_From_Cz
3709 ( p_line_id => p_line_id,
3710 p_valid_config => l_valid_config,
3711 p_complete_config => l_complete_config,
3712 p_config_header_id => l_config_header_id,
3713 p_config_rev_nbr => l_config_rev_nbr);
3714
3715 END IF;
3716
3717 IF L_MESSAGE_TEXT IS NOT NULL THEN
3718 oe_msg_pub.add_text(L_MESSAGE_TEXT);
3719 END IF;
3720
3721 IF l_exit is NULL OR
3722 l_exit = 'ERROR' THEN
3723
3724 IF l_debug_level > 0 THEN
3725 oe_debug_pub.add('SPC RETURNED ERROR , FAIL TRANSACTION' , 2 );
3726 END IF;
3727
3728 -- delete the SPC configuration in error
3729 OE_Config_Pvt.Delete_Config
3730 ( p_config_hdr_id => l_config_header_id
3731 ,p_config_rev_nbr => l_config_rev_nbr
3732 ,x_return_status => l_return_status_del);
3733
3734 RAISE FND_API.G_EXC_ERROR;
3735 END IF;
3736
3737
3738 -- if everything ok, set return values
3739 x_return_status := l_return_status;
3740 x_config_header_id := l_config_header_id;
3741 x_config_rev_nbr := l_config_rev_nbr;
3742 x_complete_config := nvl(l_complete_config, 'FALSE');
3743 x_valid_config := nvl(l_valid_config, 'FALSE');
3744
3745
3746 IF l_debug_level > 0 THEN
3747 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.PARSE_OUTPUT_XML' , 1);
3748 END IF;
3749
3750 EXCEPTION
3751 WHEN FND_API.G_EXC_ERROR THEN
3752 x_return_status := FND_API.G_RET_STS_ERROR;
3753 IF l_debug_level > 0 THEN
3754 oe_debug_pub.add('SPC EXIT TAG IS ERROR' , 1);
3755 END IF;
3756
3757 WHEN OTHERS THEN
3758 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3759 IF l_debug_level > 0 THEN
3760 oe_debug_pub.add('PARSE_OUTPUT_XML ERROR: '
3761 || SUBSTR ( SQLERRM , 1 , 100 ) , 1);
3762 END IF;
3763
3764 END Parse_output_xml;
3765
3766
3767 /*----------------------------------------------------------------------
3768 Procedure Name : Query_Options
3769 Description :
3770 -----------------------------------------------------------------------*/
3771 PROCEDURE Query_Options
3772 (p_top_model_line_id IN NUMBER
3773 ,p_send_cancel_lines IN VARCHAR2 := 'N'
3774 ,p_source_type IN VARCHAR2 := ''
3775 ,x_line_tbl OUT NOCOPY OE_ORDER_PUB.line_tbl_type)
3776 IS
3777 l_header_id NUMBER := 0;
3778 l_line_rec OE_Order_PUB.Line_Rec_Type
3779 := OE_Order_PUB.G_MISS_LINE_REC;
3780
3781 /* adding component number in this cursor to fix bug 2733667 */
3782
3783 CURSOR c1 IS
3784 SELECT line_id
3785 FROM OE_ORDER_LINES_ALL
3786 WHERE HEADER_ID = l_header_id AND
3787 TOP_MODEL_LINE_ID = p_top_model_line_id
3788 ORDER BY line_number,shipment_number,nvl(option_number,-1),nvl(component_number,-1);
3789
3790 --
3791 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3792 --
3793 BEGIN
3794
3795 IF l_debug_level > 0 THEN
3796 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.QUERY_OPTIONS' , 1);
3797 oe_debug_pub.add('SEND_CANCEL_LINES: '|| P_SEND_CANCEL_LINES , 3 );
3798 END IF;
3799
3800 BEGIN
3801 SELECT header_id
3802 INTO l_header_id
3803 FROM oe_order_lines_all
3804 WHERE line_id = p_top_model_line_id;
3805 EXCEPTION
3806 WHEN NO_DATA_FOUND THEN
3807 l_header_id := 0;
3808 END;
3809
3810 -- Loop over fetched records
3811 FOR op in C1 LOOP
3812
3813 OE_Line_Util.Query_Row( p_line_id => op.line_id
3814 ,x_line_rec => l_line_rec );
3815
3816 IF (l_line_rec.open_flag = 'Y' OR
3817 p_send_cancel_lines = 'Y') AND
3818 l_line_rec.source_type_code =
3819 nvl(p_source_type, l_line_rec.source_type_code) THEN
3820
3821 IF l_debug_level > 0 THEN
3822 oe_debug_pub.add(L_LINE_REC.SOURCE_TYPE_CODE||' ADDING '
3823 ||L_LINE_REC.OPEN_FLAG , 3 );
3824 END IF;
3825
3826 x_line_tbl(x_line_tbl.COUNT + 1) := l_line_rec;
3827 END IF;
3828 END LOOP;
3829
3830 IF l_debug_level > 0 THEN
3831 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.QUERY_OPTIONS' , 1);
3832 END IF;
3833
3834 END;
3835
3836
3837 /*----------------------------------------------------------------------
3838 Procedure Name : Query_ATO_Options
3839 Description :
3840 -----------------------------------------------------------------------*/
3841 PROCEDURE Query_ATO_Options
3842 ( p_ato_line_id IN NUMBER
3843 ,p_send_cancel_lines IN VARCHAR2 := 'N'
3844 ,p_source_type IN VARCHAR2 := ''
3845 ,x_line_tbl OUT NOCOPY OE_ORDER_PUB.line_tbl_type)
3846 IS
3847 l_top_model_line_id NUMBER := 0;
3848 l_header_id NUMBER := 0;
3849 l_line_rec OE_Order_PUB.Line_Rec_Type
3850 := OE_Order_PUB.G_MISS_LINE_REC;
3851
3852
3853 CURSOR c1 IS
3854 SELECT line_id
3855 FROM OE_ORDER_LINES_ALL
3856 WHERE HEADER_ID = l_header_id AND
3857 TOP_MODEL_LINE_ID = l_top_model_line_id AND
3858 ATO_LINE_ID = p_ato_line_id
3859 ORDER BY line_number,shipment_number,nvl(option_number,-1);
3860 --
3861 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3862 --
3863 BEGIN
3864
3865 IF l_debug_level > 0 THEN
3866 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.QUERY_ATO_OPTIONS' , 1);
3867 oe_debug_pub.add('SEND_CANCEL_LINES: '|| P_SEND_CANCEL_LINES , 3 );
3868 END IF;
3869
3870 BEGIN
3871 SELECT top_model_line_id ,header_id
3872 INTO l_top_model_line_id,l_header_id
3873 FROM oe_order_lines_all
3874 WHERE line_id = p_ato_line_id;
3875 EXCEPTION
3876 WHEN NO_DATA_FOUND THEN
3877 l_top_model_line_id := 0;
3878 l_header_id := 0;
3879 END;
3880
3881 -- Loop over fetched records
3882 FOR ato_option in C1 LOOP
3883
3884 OE_Line_Util.Query_Row( p_line_id => ato_option.line_id
3885 ,x_line_rec => l_line_rec );
3886
3887 IF (l_line_rec.open_flag = 'Y' OR
3888 p_send_cancel_lines = 'Y') AND
3889 l_line_rec.source_type_code =
3890 nvl(p_source_type, l_line_rec.source_type_code) THEN
3891
3892 IF l_debug_level > 0 THEN
3893 oe_debug_pub.add(L_LINE_REC.SOURCE_TYPE_CODE||' ADDING '
3894 ||L_LINE_REC.OPEN_FLAG , 3 );
3895 END IF;
3896 l_line_rec.reserved_quantity := Null;
3897 x_line_tbl(x_line_tbl.COUNT + 1) := l_line_rec;
3898 END IF;
3899
3900 END LOOP;
3901
3902 IF l_debug_level > 0 THEN
3903 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.QUERY_ATO_OPTIONS' , 1);
3904 END IF;
3905
3906 EXCEPTION
3907 WHEN OTHERS THEN
3908 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3909 END;
3910
3911
3912 /*----------------------------------------------------------------------
3913 Procedure Name : Explode
3914 Description :
3915 -----------------------------------------------------------------------*/
3916 Procedure Explode
3917 ( p_validation_org IN NUMBER
3918 , p_group_id IN NUMBER := NULL
3919 , p_session_id IN NUMBER := NULL
3920 , p_levels IN NUMBER := 60
3921 , p_stdcompflag IN VARCHAR2
3922 , p_exp_quantity IN NUMBER := NULL
3923 , p_top_item_id IN NUMBER
3924 , p_revdate IN DATE
3925 , p_component_code IN VARCHAR2 := NULL
3926 , x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
3927 , x_error_code OUT NOCOPY /* file.sql.39 change */ NUMBER
3928 , x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
3929 IS
3930 l_group_id NUMBER; -- bom out NOCOPY param
3931 --
3932 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3933 --
3934 BEGIN
3935
3936 IF l_debug_level > 0 THEN
3937 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.EXPLODE' , 1);
3938 oe_debug_pub.add(' EXPLOSION TYPE ' || P_STDCOMPFLAG , 2 );
3939 END IF;
3940
3941 BOMPNORD.Bmxporder_Explode_For_Order(
3942 org_id => p_validation_org,
3943 copy_flag => 2,
3944 expl_type => p_stdcompflag,
3945 order_by => 2,
3946 grp_id => l_group_id,
3947 session_id => p_session_id,
3948 levels_to_explode => 60,
3949 item_id => p_top_item_id,
3950 rev_date => to_char(p_revdate,'YYYY/MM/DD HH24:MI'),
3951 user_id => 0,
3952 commit_flag => 'N',
3953 err_msg => x_msg_data,
3954 error_code => x_error_code);
3955
3956 IF l_debug_level > 0 THEN
3957 oe_debug_pub.add('AFTER CALLING BOM EXPLODE API' , 2 );
3958 END IF;
3959
3960 IF x_error_code <> 0 THEN
3961 IF l_debug_level > 0 THEN
3962 oe_debug_pub.add('ERROR IN BOM EXPLOSION' , 2 );
3963 oe_debug_pub.add('ERROR CODE IS ' || X_ERROR_CODE , 2 );
3964 END IF;
3965
3966 IF x_msg_data is not null THEN
3967 IF l_debug_level > 0 THEN
3968 oe_debug_pub.add('BOM MSG NAME: '
3969 || SUBSTR ( X_MSG_DATA , 1 , 250 ) , 2 );
3970 END IF;
3971
3972 -- girish from bom team told err_msg is msg name, track bug 1623728
3973 -- FND_MESSAGE.Set_Name('BOM', x_msg_data);
3974 -- oe_msg_pub.add;
3975 -- After BOM ER 2700606, BOM is sending a complete message
3976 oe_msg_pub.add_text(p_message_text => x_msg_data);
3977
3978 END IF;
3979
3980 RAISE FND_API.G_EXC_ERROR;
3981 END IF;
3982
3983
3984 x_return_status := FND_API.G_RET_STS_SUCCESS;
3985 IF l_debug_level > 0 THEN
3986 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.EXPLODE' , 1);
3987 END IF;
3988
3989 EXCEPTION
3990 WHEN FND_API.G_EXC_ERROR THEN
3991 x_return_status := FND_API.G_RET_STS_ERROR;
3992 END Explode;
3993
3994 /*----------------------------------------------------------------------
3995 Procedure Name : Query_Included_Item
3996 Description : CURRENTLY NOT USED.
3997 -----------------------------------------------------------------------*/
3998 PROCEDURE Query_Included_Item
3999 ( p_top_model_line_id IN NUMBER
4000 , p_component_seqeunce_id IN NUMBER
4001 , p_component_code OUT NOCOPY /* file.sql.39 change */ VARCHAR2
4002 , x_line_rec OUT NOCOPY OE_ORDER_PUB.line_rec_type)
4003 IS
4004 l_line_rec OE_ORDER_PUB.line_rec_type;
4005 --
4006 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4007 --
4008 BEGIN
4009 x_line_rec := l_line_rec;
4010 END Query_Included_Item;
4011
4012 /*----------------------------------------------------------------------
4013 Procedure Name : Query_Included_Items
4014 Description : Queries all the included items for a particular
4015 parent line.
4016 -----------------------------------------------------------------------*/
4017 PROCEDURE Query_Included_Items
4018 ( p_line_id IN NUMBER
4019 , p_header_id IN NUMBER := FND_API.G_MISS_NUM
4020 , p_top_model_line_id IN NUMBER := FND_API.G_MISS_NUM
4021 , p_send_cancel_lines IN VARCHAR2 := 'N'
4022 , p_source_type IN VARCHAR2 := ''
4023 , x_line_tbl OUT NOCOPY OE_ORDER_PUB.line_tbl_type)
4024 IS
4025 l_top_model_line_id NUMBER := 0;
4026 l_header_id NUMBER := 0;
4027 l_line_rec OE_Order_PUB.Line_Rec_Type
4028 := OE_Order_PUB.G_MISS_LINE_REC;
4029
4030
4031 CURSOR c1 IS
4032 SELECT line_id
4033 FROM OE_ORDER_LINES_ALL
4034 WHERE HEADER_ID = l_header_id AND
4035 TOP_MODEL_LINE_ID = l_top_model_line_id AND
4036 LINK_TO_LINE_ID = p_line_id AND
4037 ITEM_TYPE_CODE = OE_GLOBALS.G_ITEM_INCLUDED
4038 ORDER BY line_number,shipment_number,nvl(option_number,-1);
4039
4040 --
4041 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4042 --
4043 BEGIN
4044
4045 IF l_debug_level > 0 THEN
4046 oe_debug_pub.add('SEND_CANCEL_LINES: '|| P_SEND_CANCEL_LINES , 3 );
4047 END IF;
4048
4049 IF p_header_id = FND_API.G_MISS_NUM AND
4050 p_top_model_line_id = FND_API.G_MISS_NUM THEN
4051
4052 BEGIN
4053 SELECT top_model_line_id ,header_id
4054 INTO l_top_model_line_id,l_header_id
4055 FROM oe_order_lines_all
4056 WHERE line_id = p_line_id;
4057 EXCEPTION
4058 WHEN NO_DATA_FOUND THEN
4059 l_top_model_line_id := 0;
4060 l_header_id := 0;
4061 END;
4062
4063 ELSE
4064
4065 l_top_model_line_id := p_top_model_line_id;
4066 l_header_id := p_header_id;
4067
4068 END IF;
4069
4070 IF l_debug_level > 0 THEN
4071 oe_debug_pub.add('HEADER ID , TOP MODEL LINE ID '
4072 ||L_HEADER_ID||'/'||L_TOP_MODEL_LINE_ID , 3 );
4073 END IF;
4074
4075 -- Loop over fetched records
4076 FOR inc_item in C1 LOOP
4077
4078 OE_Line_Util.Query_Row( p_line_id => inc_item.line_id
4079 ,x_line_rec => l_line_rec );
4080
4081 IF (l_line_rec.open_flag = 'Y' OR
4082 p_send_cancel_lines = 'Y') AND
4083 l_line_rec.source_type_code =
4084 nvl(p_source_type, l_line_rec.source_type_code) THEN
4085
4086 IF l_debug_level > 0 THEN
4087 oe_debug_pub.add(L_LINE_REC.SOURCE_TYPE_CODE||' ADDING '
4088 ||L_LINE_REC.OPEN_FLAG , 3 );
4089 END IF;
4090
4091 x_line_tbl(x_line_tbl.COUNT + 1) := l_line_rec;
4092 END IF;
4093
4094 END LOOP;
4095
4096 IF l_debug_level > 0 THEN
4097 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.QUERY_INCLUDED_ITEMS' , 1);
4098 END IF;
4099
4100 EXCEPTION
4101 WHEN OTHERS THEN
4102 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4103 END Query_Included_Items;
4104
4105 -- forward declaration
4106
4107 PROCEDURE update_component_number
4108 (p_line_id IN NUMBER ,
4109 p_top_model_line_id IN NUMBER ,
4110 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2);
4111
4112 /*----------------------------------------------------------------------
4113 Procedure Name : Process_Included_Items
4114 Description :
4115 This procedure is used to explode the included items for a
4116 PTO model/class or a kit. This procedure is called from
4117 oe_line_util if,
4118 the included items freeze method profile options is ENTRY or NULL.
4119 a new line is created in a booked order.
4120 a line with included items is schduled.
4121
4122 Lastly if the profile is set to PICK RELEASE OR BOOKING, the
4123 wrapper procedures finally call this method.
4124
4125 Check whether the included items need to be processed
4126 If the line's explosion date is not NULL;
4127 or the line is ATO; or the item type is not a model, kit
4128 or class, then do not process included items
4129
4130 included items will have same
4131 line + ship + option number combination as the parent line.
4132 However we will populate component_number for them.
4133
4134 To improve performance, we will explicitly log delayed
4135 requests using procedure log_included_items_requests.
4136 We will set the control_rec.change_attributes to FALSE.
4137 However execution of the delayed requests logged in that
4138 procedure is up to the caller of this API.
4139
4140 Change Record:
4141 2002550
4142 the pricing attributes need to be set to 0, since we are not
4143 calling apply_attribute_changes as per perf changes.
4144
4145 Assign pricing_quantity = ordered_quantity and
4146 pricing_quantity_uom = order_quantity_uom.
4147
4148 2115192
4149 setting the ordered item field on included items.
4150 Also, insert_into_set call removed, moved to generic
4151 model_option_defaulting API.
4152 2508632
4153 Copy Calculate Price Flag of included items from Parent Line.
4154
4155 Bug 2869052 :
4156 Default_Child_Line procedure would be called only if there are
4157 any new included items to be created. If the call returns an
4158 error an exception would be raised. New variable l_default_child_line
4159 has been created.
4160 -----------------------------------------------------------------------*/
4161 FUNCTION Process_Included_Items
4162 (p_line_rec IN OE_ORDER_PUB.line_rec_type
4163 := OE_ORDER_PUB.G_MISS_LINE_REC,
4164 p_line_id IN NUMBER := FND_API.G_MISS_NUM,
4165 p_freeze IN BOOLEAN,
4166 p_process_requests IN BOOLEAN DEFAULT FALSE)
4167 RETURN VARCHAR2
4168 IS
4169
4170 -- process_order in variables
4171 l_control_rec OE_GLOBALS.Control_Rec_Type;
4172 l_header_rec OE_Order_PUB.Header_Rec_Type;
4173 l_line_rec OE_ORDER_PUB.Line_Rec_Type;
4174 l_old_line_tbl OE_Order_PUB.Line_Tbl_Type;
4175 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
4176
4177 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
4178 l_msg_count NUMBER;
4179 l_msg_data VARCHAR2(2000);
4180
4181 -- procedure variables
4182 l_parent_line_rec OE_Order_PUB.Line_Rec_Type;
4183 l_line_count NUMBER := 0;
4184 l_line_id NUMBER;
4185 l_component_number NUMBER;
4186 l_adjust_comp_no_flag VARCHAR2(1) := 'N';
4187 l_parent_component_sequence_id NUMBER := 0;
4188 l_option_number NUMBER;
4189 l_top_model_quantity NUMBER := 0;
4190 l_freeze_method VARCHAR2(30);
4191 l_explosion_date DATE;
4192 l_validation_org NUMBER;
4193 l_error_code NUMBER;
4194 l_default_child_line BOOLEAN := TRUE;
4195 l_freeze_macd_kit BOOLEAN := FALSE;
4196
4197 --bug3269648
4198 l_return_code NUMBER;
4199 l_error_buffer VARCHAR2(240);
4200 --bug3269648
4201 -- tso with equipment
4202 l_top_container_model VARCHAR2(1);
4203 l_part_of_container VARCHAR2(1);
4204 l_config_mode NUMBER;
4205 l_cz_config_mode NUMBER;
4206 l_x_return_status VARCHAR2(1);
4207
4208 CURSOR new_included_items(p_top_bill_sequence_id IN NUMBER,
4209 p_top_model_line_id IN NUMBER,
4210 p_std_comp_freeze_date IN DATE)
4211 IS
4212 SELECT
4213 component_item_id,
4214 component_sequence_id,
4215 extended_quantity,
4216 component_code,
4217 PRIMARY_UOM_CODE,
4218 sort_order
4219 FROM bom_explosions be
4220 WHERE
4221 be.explosion_type = 'INCLUDED'
4222 AND be.plan_level >= 0
4223 AND be.extended_quantity > 0
4224 AND be.TOP_BILL_SEQUENCE_ID = p_top_bill_sequence_id
4225 AND be.EFFECTIVITY_DATE <= p_std_comp_freeze_date
4226 AND be.DISABLE_DATE > p_std_comp_freeze_date
4227 AND be.COMPONENT_ITEM_ID <> be.TOP_ITEM_ID
4228 AND NOT EXISTS
4229 ( SELECT 'X'
4230 FROM oe_order_lines l
4231 WHERE l.top_model_line_id = p_top_model_line_id
4232 AND l.link_to_line_id = l_parent_line_rec.line_id
4233 AND l.component_code = be.component_code
4234 AND l.open_flag = 'Y')
4235 ORDER BY sort_order;
4236 --ORDER BY COMPONENT_ITEM_ID, COMPONENT_CODE ;
4237
4238
4239 CURSOR update_included_items(p_top_bill_sequence_id IN NUMBER,
4240 p_top_model_line_id IN NUMBER,
4241 p_top_model_quantity IN NUMBER,
4242 p_std_comp_freeze_date IN DATE)
4243 IS
4244 SELECT
4245 oel.line_id, be.extended_quantity * p_top_model_quantity
4246 FROM oe_order_lines oel, bom_explosions be
4247 WHERE oel.top_model_line_id = p_top_model_line_id
4248 AND oel.link_to_line_id = l_parent_line_rec.line_id
4249 AND oel.item_type_code = 'INCLUDED'
4250 AND be.explosion_type = 'INCLUDED'
4251 AND be.plan_level >= 0
4252 AND be.TOP_BILL_SEQUENCE_ID = p_top_bill_sequence_id
4253 AND be.EFFECTIVITY_DATE <= p_std_comp_freeze_date
4254 AND be.DISABLE_DATE > p_std_comp_freeze_date
4255 AND be.COMPONENT_ITEM_ID <> be.TOP_ITEM_ID
4256 AND be.component_code = oel.component_code
4257 AND oel.ordered_quantity/p_top_model_quantity <> be.extended_quantity
4258 AND oel.open_flag = 'Y';
4259
4260
4261 CURSOR outdated_included_items(p_top_bill_sequence_id IN NUMBER,
4262 p_top_model_line_id IN NUMBER,
4263 p_std_comp_freeze_date IN DATE)
4264 IS
4265 SELECT
4266 l.line_id
4267 FROM oe_order_lines l
4268 WHERE l.link_to_line_id = l_parent_line_rec.line_id
4269 AND l.top_model_line_id = p_top_model_line_id
4270 AND l.item_type_code = 'INCLUDED'
4271 AND l.open_flag = 'Y'
4272 AND NOT EXISTS
4273 ( SELECT 'X'
4274 FROM bom_explosions be
4275 WHERE be.component_code = l.component_code
4276 AND be.explosion_type = 'INCLUDED'
4277 AND be.plan_level >= 0
4278 AND be.TOP_BILL_SEQUENCE_ID = p_top_bill_sequence_id
4279 AND be.EFFECTIVITY_DATE <= p_std_comp_freeze_date
4280 AND be.DISABLE_DATE > p_std_comp_freeze_date);
4281
4282 --
4283 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4284 --
4285 BEGIN
4286
4287 Print_Time('Entering oe_config_util.process_included_items');
4288
4289 l_parent_line_rec := p_line_rec;
4290
4291 IF p_line_rec.line_id <> FND_API.G_MISS_NUM AND
4292 p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
4293 IF l_debug_level > 0 THEN
4294 oe_debug_pub.add('DO NOT LOCK' , 3 );
4295 END IF;
4296 ELSE
4297 IF p_line_id = FND_API.G_MISS_NUM THEN
4298 OE_LINE_UTIL.Lock_Row
4299 (p_line_id => p_line_rec.line_id
4300 ,p_x_line_rec => l_parent_line_rec
4301 ,x_return_status => l_return_status);
4302 -- Parent Line has been passed
4303 l_parent_line_rec := p_line_rec;
4304
4305 IF l_debug_level > 0 THEN
4306 oe_debug_pub.add('P_LINE_ID IS MISS_NUM' , 3 );
4307 END IF;
4308 ELSE
4309 -- Query the Parent Line
4310 IF l_debug_level > 0 THEN
4311 oe_debug_pub.add('PARENT LINE_ID: '|| P_LINE_ID , 2 );
4312 END IF;
4313
4314 OE_LINE_UTIL.Lock_Row
4315 (p_line_id => p_line_id
4316 ,p_x_line_rec => l_parent_line_rec
4317 ,x_return_status => l_return_status);
4318 END IF;
4319
4320 IF l_debug_level > 0 THEN
4321 oe_debug_pub.add('ROW LOCKED' , 3 );
4322 END IF;
4323 END IF;
4324
4325
4326 IF l_parent_line_rec.explosion_date is not null OR
4327 l_parent_line_rec.ato_line_id is not null OR
4328 l_parent_line_rec.item_type_code not in
4329 ('MODEL', 'KIT', 'CLASS') OR
4330 l_parent_line_rec.ordered_quantity = 0
4331 THEN
4332 IF l_debug_level > 0 THEN
4333 oe_debug_pub.add('RETURNING FROM PROC_INC_ITEMS' , 3 );
4334 END IF;
4335 RETURN l_return_status;
4336 END IF;
4337
4338 -- TSO with Equipment starts
4339 IF l_parent_line_rec.line_id <> l_parent_line_rec.top_model_line_id AND
4340 l_parent_line_rec.item_type_code = 'KIT' THEN
4341
4342 OE_CONFIG_TSO_PVT.Is_Part_Of_Container_Model
4343 (p_line_id => l_parent_line_rec.line_id ,
4344 x_top_container_model => l_top_container_model,
4345 x_part_of_container => l_part_of_container);
4346
4347 -- The line is part of container
4348 IF l_part_of_container = 'Y' THEN
4349
4350 OE_CONFIG_TSO_PVT.Get_MACD_Action_Mode
4351 ( p_line_id => l_parent_line_rec.line_id
4352 ,x_config_mode => l_config_mode
4353 ,x_return_status => l_x_return_status );
4354
4355 IF l_config_mode <> 1 THEN
4356 IF l_debug_level > 0 THEN
4357 oe_debug_pub.add('Returning from Process_included_items for Kit in TSO configuration' , 3 );
4358 END IF;
4359
4360 l_cz_config_mode :=
4361 CZ_NETWORK_API_PUB.is_item_added (p_config_hdr_id => l_parent_line_rec.config_header_id
4362 ,p_config_rev_nbr => l_parent_line_rec.config_rev_nbr
4363 ,p_config_item_id => l_parent_line_rec.configuration_id);
4364 IF l_debug_level > 0 THEN
4365 oe_debug_pub.add('After calling CZ_NETWORK_API_PUB.is_item_added: ' || l_cz_config_mode );
4366 END IF;
4367 IF l_cz_config_mode = 0 THEN
4368 --RETURN l_return_status;
4369 l_freeze_macd_kit := TRUE;
4370 END IF;
4371 END IF; -- Mode
4372 END IF; -- Container
4373 END IF; -- KIT
4374 -- TSO with Equipment ends
4375
4376 l_freeze_method := G_FREEZE_METHOD; /* Bug # 5036404 */
4377
4378 IF l_debug_level > 0 THEN
4379 oe_debug_pub.add('METHOD: '|| L_FREEZE_METHOD , 4 );
4380 END IF;
4381 -- 4359339
4382 l_freeze_method := nvl(l_freeze_method, OE_GLOBALS.G_IIFM_ENTRY);
4383
4384 IF l_parent_line_rec.creation_date is null OR
4385 l_freeze_method <> OE_GLOBALS.G_IIFM_ENTRY
4386 THEN
4387 l_explosion_date := sysdate;
4388 ELSE
4389 l_explosion_date := l_parent_line_rec.creation_date;
4390 END IF;
4391
4392 IF l_freeze_macd_kit THEN
4393
4394 l_explosion_date := sysdate;
4395 l_return_status := FND_API.G_RET_STS_SUCCESS;
4396 GOTO UPDATE_EXP_DATE;
4397
4398 END IF;
4399 l_validation_org := OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');
4400
4401 IF l_debug_level > 0 THEN
4402 oe_debug_pub.add('EXPLOSION_DATE: ' || L_EXPLOSION_DATE , 2 );
4403 oe_debug_pub.add('P_TOP_ITEM_ID: '
4404 || L_PARENT_LINE_REC.INVENTORY_ITEM_ID , 2 );
4405 oe_debug_pub.add('EXPLODING WITH ORG : ' || L_VALIDATION_ORG , 2 );
4406 END IF;
4407
4408 Explode(p_validation_org => l_validation_org,
4409 p_levels => 6, --??
4410 p_stdcompflag => OE_BMX_STD_COMPS_ONLY,
4411 p_top_item_id => l_parent_line_rec.inventory_item_id,
4412 p_revdate => l_explosion_date,
4413 x_msg_data => l_msg_data,
4414 x_error_code => l_error_code,
4415 x_return_status => l_return_status);
4416
4417 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4418 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4419 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4420 RAISE FND_API.G_EXC_ERROR;
4421 END IF;
4422
4423
4424 BEGIN
4425 SELECT bill_sequence_id
4426 INTO l_parent_component_sequence_id
4427 FROM bom_bill_of_materials
4428 WHERE ASSEMBLY_ITEM_ID = l_parent_line_rec.inventory_item_id
4429 AND ORGANIZATION_ID = l_validation_org
4430 AND ALTERNATE_BOM_DESIGNATOR IS NULL;
4431
4432 IF l_debug_level > 0 THEN
4433 oe_debug_pub.add('BILL SEQ ID '||L_PARENT_COMPONENT_SEQUENCE_ID , 1);
4434 END IF;
4435
4436 EXCEPTION
4437 WHEN NO_DATA_FOUND THEN
4438 IF l_debug_level > 0 THEN
4439 oe_debug_pub.add('BILL DOES NOT EXIST FOR THIS ITEM' , 3 );
4440 END IF;
4441 l_parent_component_sequence_id := 0;
4442 WHEN OTHERS THEN
4443 IF l_debug_level > 0 THEN
4444 oe_debug_pub.add
4445 ('UNEXPECTED ERROR WHILE GETTING BILL SEQUENCE ID' , 3 );
4446 END IF;
4447 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4448 END;
4449
4450 BEGIN
4451 SELECT max(component_number)
4452 INTO l_component_number
4453 FROM oe_order_lines
4454 WHERE link_to_line_id = p_line_id
4455 AND top_model_line_id = l_parent_line_rec.top_model_line_id;
4456 EXCEPTION
4457 WHEN OTHERS THEN
4458 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4459 END;
4460
4461 l_line_rec := OE_Order_PUB.G_MISS_LINE_REC;
4462
4463 OPEN new_included_items
4464 (p_top_bill_sequence_id => l_parent_component_sequence_id,
4465 p_top_model_line_id => l_parent_line_rec.top_model_line_id,
4466 p_std_comp_freeze_date => l_explosion_date);
4467
4468 LOOP
4469 FETCH new_included_items
4470 INTO l_line_rec.inventory_item_id, l_line_rec.component_sequence_id,
4471 l_line_rec.ordered_quantity, l_line_rec.component_code,
4472 l_line_rec.order_quantity_uom, l_line_rec.sort_order;
4473 EXIT WHEN new_included_items%NOTFOUND;
4474
4475 IF l_default_child_line THEN
4476
4477 ------ 1. Insert new included items
4478 l_component_number := nvl(l_component_number, 0);
4479 l_line_rec.operation := OE_GLOBALS.G_OPR_CREATE;
4480 l_line_rec.item_identifier_type := 'INT';
4481 l_line_rec.option_number := l_parent_line_rec.option_number;
4482 l_line_rec.item_type_code := OE_GLOBALS.G_ITEM_INCLUDED;
4483 l_line_rec.top_model_line_id := l_parent_line_rec.top_model_line_id;
4484 l_line_rec.link_to_line_id := l_parent_line_rec.line_id;
4485 l_line_rec.model_remnant_flag:= l_parent_line_rec.model_remnant_flag;
4486 l_line_rec.header_id := l_parent_line_rec.header_id;
4487 l_line_rec.unit_list_price := 0;
4488 l_line_rec.unit_selling_price :=0;
4489 l_line_rec.unit_list_price_per_pqty :=0;
4490 l_line_rec.unit_selling_price_per_pqty :=0;
4491 l_line_rec.calculate_price_flag :=
4492 l_parent_line_rec.calculate_price_flag;
4493
4494
4495 IF l_parent_line_rec.booked_flag = 'Y' THEN
4496 l_line_rec.flow_status_code := 'BOOKED';
4497 ELSE
4498 l_line_rec.flow_status_code := 'ENTERED';
4499 END IF;
4500
4501 IF l_debug_level > 0 THEN
4502 oe_debug_pub.add('CALLING DEFAULT CHILD' , 2 );
4503 END IF;
4504
4505 default_child_line
4506 (p_parent_line_rec => l_parent_line_rec,
4507 p_x_child_line_rec => l_line_rec,
4508 x_return_status => l_return_status);
4509
4510 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4511 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4512 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4513 RAISE FND_API.G_EXC_ERROR;
4514 END IF;
4515
4516 l_default_child_line := FALSE;
4517
4518 END IF;
4519
4520 -- Get the concatanted segment value to be stored in
4521 -- order lines at ordered_item
4522
4523 BEGIN
4524 SELECT concatenated_segments
4525 INTO l_line_rec.ordered_item
4526 FROM MTL_SYSTEM_ITEMS_KFV
4527 WHERE inventory_item_id = l_line_rec.inventory_item_id
4528 AND organization_id = l_validation_org;
4529 EXCEPTION
4530 WHEN NO_DATA_FOUND THEN
4531 IF l_debug_level > 0 THEN
4532 oe_debug_pub.add('CANCAT SEG FETCH ERROR' , 3 );
4533 END IF;
4534 RAISE FND_API.G_EXC_ERROR;
4535 END;
4536
4537 IF l_debug_level > 0 THEN
4538 oe_debug_pub.add('ORD ITEM IS: ' || L_LINE_REC.ORDERED_ITEM , 5 );
4539 oe_debug_pub.add('INSERTING....'|| L_LINE_REC.COMPONENT_CODE , 2 );
4540 END IF;
4541
4542 -- Adding this flag for fulfillment purpose.
4543
4544 SELECT OE_ORDER_LINES_S.NEXTVAL
4545 INTO l_line_rec.line_id
4546 FROM dual;
4547
4548 l_component_number := l_component_number + 1;
4549 l_line_rec.component_number := l_component_number;
4550 l_line_rec.ordered_quantity := l_parent_line_rec.ordered_quantity
4551 * l_line_rec.ordered_quantity;
4552 l_line_rec.pricing_quantity := l_line_rec.ordered_quantity;
4553 l_line_rec.pricing_quantity_uom := l_line_rec.order_quantity_uom;
4554 l_line_rec.line_type_id := l_parent_line_rec.line_type_id;
4555 l_line_rec.org_id := l_parent_line_rec.org_id; -- Bug 6058501
4556 --Bug 4153518: Intialized Global DFF values to NULL
4557 l_line_rec.global_attribute1 := NULL;
4558 l_line_rec.global_attribute2 := NULL;
4559 l_line_rec.global_attribute3 := NULL;
4560 l_line_rec.global_attribute4 := NULL;
4561 l_line_rec.global_attribute5 := NULL;
4562 l_line_rec.global_attribute6 := NULL;
4563 l_line_rec.global_attribute7 := NULL;
4564 l_line_rec.global_attribute8 := NULL;
4565 l_line_rec.global_attribute9 := NULL;
4566 l_line_rec.global_attribute10 := NULL;
4567 l_line_rec.global_attribute11 := NULL;
4568 l_line_rec.global_attribute12 := NULL;
4569 l_line_rec.global_attribute13 := NULL;
4570 l_line_rec.global_attribute14 := NULL;
4571 l_line_rec.global_attribute15 := NULL;
4572 l_line_rec.global_attribute16 := NULL;
4573 l_line_rec.global_attribute17 := NULL;
4574 l_line_rec.global_attribute18 := NULL;
4575 l_line_rec.global_attribute19 := NULL;
4576 l_line_rec.global_attribute20 := NULL;
4577 l_line_rec.global_attribute_category := NULL;
4578
4579 --bug3269648 start
4580 IF l_debug_level > 0 THEN
4581 OE_DEBUG_PUB.Add('Before calling JG ',2);
4582 END IF;
4583
4584 JG_ZZ_OM_COMMON_PKG.default_gdf
4585 ( x_line_rec => l_line_rec
4586 ,x_return_code => l_return_code
4587 ,x_error_buffer => l_error_buffer );
4588
4589 IF l_debug_level > 0 THEN
4590 OE_DEBUG_PUB.Add('After JG Call:'|| l_return_code || l_error_buffer,2);
4591 END IF;
4592 --bug3269648 ends
4593
4594 l_line_count := l_line_count + 1;
4595 l_line_tbl(l_line_count) := l_line_rec;
4596
4597 END LOOP;
4598 CLOSE new_included_items;
4599
4600
4601 -- open cursors only if some records exist to upd/del
4602 SELECT count(*)
4603 INTO l_top_model_quantity
4604 FROM oe_order_lines
4605 WHERE item_type_code = 'INCLUDED'
4606 AND top_model_line_id = l_parent_line_rec.top_model_line_id
4607 AND link_to_line_id = l_parent_line_rec.line_id;
4608
4609 IF l_top_model_quantity > 0 THEN
4610
4611 ----- 2. Update existing included items which needs to be updated
4612
4613 IF l_parent_line_rec.ordered_quantity is null THEN
4614 l_top_model_quantity := 1;
4615 ELSE
4616 l_top_model_quantity := l_parent_line_rec.ordered_quantity;
4617 END IF;
4618
4619 IF l_debug_level > 0 THEN
4620 oe_debug_pub.add('MODEL ORDERED QUANTITY IS'
4621 || L_TOP_MODEL_QUANTITY , 2 );
4622 END IF;
4623
4624 l_line_rec := OE_Order_PUB.G_MISS_LINE_REC;
4625 l_line_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
4626 l_line_rec.header_id := l_parent_line_rec.header_id;
4627
4628 OPEN update_included_items
4629 (p_top_bill_sequence_id => l_parent_component_sequence_id,
4630 p_top_model_line_id => l_parent_line_rec.top_model_line_id,
4631 p_top_model_quantity => l_top_model_quantity,
4632 p_std_comp_freeze_date => l_explosion_date);
4633 LOOP
4634
4635 FETCH update_included_items
4636 INTO l_line_rec.line_id, l_line_rec.ordered_quantity;
4637 EXIT WHEN update_included_items%NOTFOUND;
4638
4639 IF l_debug_level > 0 THEN
4640 oe_debug_pub.add('UPDATING....'|| L_LINE_REC.COMPONENT_CODE , 2 );
4641 END IF;
4642
4643 -- Audit Trail
4644 l_line_rec.change_reason := 'SYSTEM';
4645 l_line_count := l_line_count + 1;
4646 l_line_tbl(l_line_count) := l_line_rec;
4647
4648 END LOOP;
4649 CLOSE update_included_items;
4650
4651
4652 ----- 3. Delete and included items that are not valid anymore
4653
4654 IF l_debug_level > 0 THEN
4655 oe_debug_pub.add('TOP MODEL LINE:' || L_PARENT_LINE_REC.LINE_ID , 2 );
4656 END IF;
4657
4658 l_line_rec := OE_Order_PUB.G_MISS_LINE_REC;
4659 l_line_rec.operation := OE_GLOBALS.G_OPR_DELETE;
4660 l_line_rec.header_id := l_parent_line_rec.header_id;
4661
4662 OPEN outdated_included_items
4663 (p_top_bill_sequence_id => l_parent_component_sequence_id,
4664 p_top_model_line_id => l_parent_line_rec.top_model_line_id,
4665 p_std_comp_freeze_date => l_explosion_date);
4666 LOOP
4667 FETCH outdated_included_items
4668 INTO l_line_rec.line_id;
4669 EXIT WHEN outdated_included_items%NOTFOUND;
4670
4671 l_adjust_comp_no_flag := 'Y';
4672
4673 IF l_debug_level > 0 THEN
4674 oe_debug_pub.add('DELETING....'|| L_LINE_REC.LINE_ID , 2 );
4675 END IF;
4676
4677 l_line_count := l_line_count + 1;
4678 l_line_tbl(l_line_count) := l_line_rec;
4679
4680 END LOOP;
4681 CLOSE outdated_included_items;
4682
4683 END IF; -- no need to open cursors
4684
4685 IF l_debug_level > 0 THEN
4686 oe_debug_pub.add('NO. OF LINES ' || TO_CHAR ( L_LINE_COUNT ) , 2 );
4687 END IF;
4688
4689 IF l_line_count > 0 THEN
4690 l_header_rec.operation := OE_GLOBALS.G_OPR_NONE;
4691 l_header_rec.header_id := l_parent_line_rec.header_id;
4692
4693 IF l_debug_level > 0 THEN
4694 oe_debug_pub.add('CALLING PROCESS_ORDER' , 2 );
4695 END IF;
4696
4697 l_control_rec.controlled_operation := TRUE;
4698 l_control_rec.check_security := FALSE;
4699 l_control_rec.change_attributes := FALSE;
4700
4701 OE_ORDER_PVT.Lines
4702 (p_validation_level => FND_API.G_VALID_LEVEL_NONE
4703 ,p_control_rec => l_control_rec
4704 ,p_x_line_tbl => l_line_tbl
4705 ,p_x_old_line_tbl => l_old_line_tbl
4706 ,x_return_status => l_return_status);
4707
4708 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4709 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4710 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4711 RAISE FND_API.G_EXC_ERROR;
4712 END IF;
4713
4714
4715 Log_Included_Item_Requests
4716 ( p_line_tbl => l_line_tbl
4717 ,p_booked_flag => l_parent_line_rec.booked_flag);
4718
4719
4720 OE_ORDER_PVT.Process_Requests_And_notify
4721 (p_process_requests => p_process_requests
4722 ,p_notify => TRUE
4723 ,x_return_status => l_return_status
4724 ,p_line_tbl => l_line_tbl
4725 ,p_old_line_tbl => l_old_line_tbl);
4726
4727
4728 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4729 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4730 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4731 RAISE FND_API.G_EXC_ERROR;
4732 END IF;
4733
4734
4735 IF l_adjust_comp_no_flag = 'Y' THEN
4736 IF l_debug_level > 0 THEN
4737 oe_debug_pub.add('INCLUDED ITEMS GOT DELETED' , 1);
4738 END IF;
4739
4740 update_component_number
4741 (p_line_id => p_line_id,
4742 p_top_model_line_id => l_parent_line_rec.top_model_line_id,
4743 x_return_status => l_return_status);
4744 END IF;
4745
4746 oe_msg_pub.count_and_get
4747 ( p_count => l_msg_count
4748 ,p_data => l_msg_data );
4749
4750 END IF; -- count > 0
4751
4752 -- now populate the explosion date on parent line, if p_freeze id TRUE.
4753 <<UPDATE_EXP_DATE>>
4754 IF nvl(p_freeze, FALSE) = TRUE OR
4755 l_freeze_macd_kit THEN
4756 -- Update the explosion date on the model line.
4757 BEGIN
4758 UPDATE OE_ORDER_LINES_ALL
4759 set explosion_date = l_explosion_date,
4760 lock_control = lock_control + 1
4761 WHERE line_id = l_parent_line_rec.line_id;
4762 EXCEPTION
4763 WHEN OTHERS THEN
4764 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4765 END;
4766 END IF;
4767
4768
4769 Print_Time('Exiting process_included_items: ' || l_return_status);
4770
4771 RETURN l_return_status;
4772
4773 EXCEPTION
4774 WHEN FND_API.G_EXC_ERROR THEN
4775 -- bug 4683857
4776 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
4777 OE_MSG_PUB.Add_Exc_Msg (G_PKG_NAME, 'Process_Included_Items');
4778 END IF;
4779 RETURN FND_API.G_RET_STS_ERROR;
4780
4781 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4782 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4783 THEN
4784 OE_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,'Process_Included_Items');
4785 END IF;
4786 RETURN FND_API.G_RET_STS_UNEXP_ERROR;
4787 WHEN OTHERS THEN
4788 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4789 THEN
4790 OE_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,'Process_Included_Items');
4791 END IF;
4792 RETURN FND_API.G_RET_STS_UNEXP_ERROR;
4793 END Process_Included_Items;
4794
4795
4796 /*----------------------------------------------------------------------
4797 Procedure Name : update_component_number
4798 Description : This procedure is written to update the
4799 component_number on the included items,
4800 if any of them is deleted.
4801
4802 -----------------------------------------------------------------------*/
4803
4804 PROCEDURE update_component_number(p_line_id IN NUMBER ,
4805 p_top_model_line_id IN NUMBER ,
4806 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
4807 IS
4808
4809 CURSOR comp_number IS
4810 SELECT line_id
4811 FROM oe_order_lines
4812 WHERE link_to_line_id = p_line_id
4813 AND top_model_line_id = p_top_model_line_id;
4814
4815 l_component_number NUMBER := 0;
4816 l_line_id NUMBER;
4817 --
4818 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4819 --
4820 BEGIN
4821 IF l_debug_level > 0 THEN
4822 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.UPDATE_COMPONENT_NUMBER' , 1);
4823 END IF;
4824
4825 OPEN comp_number;
4826 LOOP
4827 FETCH comp_number INTO l_line_id;
4828 EXIT WHEN comp_number%NOTFOUND;
4829
4830 l_component_number := l_component_number + 1;
4831
4832 UPDATE oe_order_lines
4833 SET component_number = l_component_number,
4834 lock_control = lock_control + 1
4835 WHERE line_id = l_line_id;
4836
4837 END LOOP;
4838
4839 x_return_status := FND_API.G_RET_STS_SUCCESS;
4840
4841 IF l_debug_level > 0 THEN
4842 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.UPDATE_COMPONENT_NUMBER' , 1);
4843 END IF;
4844
4845 EXCEPTION
4846 WHEN OTHERS THEN
4847 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4848 END update_component_number;
4849
4850 /*----------------------------------------------------------------------
4851 Procedure Name : Supply_Reserved
4852 Description : This procedure is written for the validation
4853 template Supply Reserved. It will return 1 if the
4854 line is line has supply reserved and 0 otherwise.
4855
4856 -----------------------------------------------------------------------*/
4857 PROCEDURE Supply_Reserved (
4858 p_application_id in number,
4859 p_entity_short_name in varchar2,
4860 p_validation_entity_short_name in varchar2,
4861 p_validation_tmplt_short_name in varchar2,
4862 p_record_set_short_name in varchar2,
4863 p_scope in varchar2,
4864 x_result out NOCOPY /* file.sql.39 change */ number)
4865 IS
4866 --
4867 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4868 --
4869 BEGIN
4870 x_result := 0;
4871 END;
4872
4873 /*----------------------------------------------------------------------
4874 Procedure Name : Freeze_Included_Items
4875 Description :
4876 -----------------------------------------------------------------------*/
4877 FUNCTION Freeze_Included_Items(p_line_id IN NUMBER)
4878 RETURN VARCHAR2
4879 IS
4880 --
4881 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4882 --
4883 BEGIN
4884 RETURN Process_Included_Items(p_line_id => p_line_id,
4885 p_freeze => TRUE);
4886 END Freeze_Included_Items;
4887
4888
4889
4890 /*----------------------------------------------------------------------
4891 Procedure Name : Is_ATO_Model
4892 Description :
4893 -----------------------------------------------------------------------*/
4894 FUNCTION Is_ATO_Model
4895 (p_line_id IN NUMBER
4896 := FND_API.G_MISS_NUM ,
4897 p_line_rec IN OE_Order_PUB.LINE_REC_TYPE
4898 := OE_ORDER_PUB.G_MISS_LINE_REC)
4899 RETURN BOOLEAN
4900 IS
4901 l_line_rec OE_Order_PUB.LINE_REC_TYPE;
4902 --
4903 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4904 --
4905 BEGIN
4906
4907 IF l_debug_level > 0 THEN
4908 oe_debug_pub.add('ENTERING IS_ATO_MODEL FUNCTION ' , 1);
4909 END IF;
4910
4911 -- if p_line_rec.line_id is missing, query row
4912 -- if p_line_id and and p_line_rec both missing, RAISE FND_API.G_EXC_ERROR
4913 -- if p_line_rec is not missing, use it as line_rec insted of querying.
4914
4915 IF p_line_rec.line_id = FND_API.G_MISS_NUM THEN
4916 IF p_line_id <> FND_API.G_MISS_NUM THEN
4917 OE_Line_Util.Query_Row(p_line_id => p_line_id
4918 ,x_line_rec => l_line_rec);
4919 ELSE
4920 RAISE FND_API.G_EXC_ERROR;
4921 END IF;
4922 ELSE
4923 l_line_rec := p_line_rec;
4924 END IF;
4925
4926 IF l_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL AND
4927 l_line_rec.ato_line_id = l_line_rec.line_id AND
4928 l_line_rec.top_model_line_id = l_line_rec.line_id -- redundent
4929 THEN
4930 IF l_debug_level > 0 THEN
4931 oe_debug_pub.add('LEAVING IS_ATO_MODEL FUNCTION ' , 1);
4932 END IF;
4933 RETURN TRUE;
4934 ELSE
4935 IF l_debug_level > 0 THEN
4936 oe_debug_pub.add('LEAVING IS_ATO_MODEL FUNCTION ' , 1);
4937 END IF;
4938 RETURN FALSE;
4939 END IF;
4940
4941 IF l_debug_level > 0 THEN
4942 oe_debug_pub.add('LEAVING IS_ATO_MODEL FUNCTION ' , 1);
4943 END IF;
4944
4945 EXCEPTION
4946 when others then
4947 IF l_debug_level > 0 THEN
4948 oe_debug_pub.add('EXCEPTION IN IS_ATO_MODEL FUNCTION ' , 1);
4949 END IF;
4950 RETURN FALSE;
4951 END Is_ATO_Model;
4952
4953
4954
4955 /*----------------------------------------------------------------------
4956 Procedure Name : Is_PTO_Model
4957 Description :
4958 -----------------------------------------------------------------------*/
4959 FUNCTION Is_PTO_Model
4960 (p_line_id IN NUMBER
4961 := FND_API.G_MISS_NUM ,
4962 p_line_rec IN OE_Order_PUB.LINE_REC_TYPE
4963 := OE_ORDER_PUB.G_MISS_LINE_REC)
4964 RETURN BOOLEAN
4965 IS
4966 l_line_rec OE_Order_PUB.LINE_REC_TYPE;
4967
4968 --
4969 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4970 --
4971 BEGIN
4972
4973 IF l_debug_level > 0 THEN
4974 oe_debug_pub.add('ENTERING IS_PTO_MODEL FUNCTION ' , 1);
4975 END IF;
4976
4977 -- if p_line_rec.line_id is missing, query row
4978 -- if p_line_id and and p_line_rec both missing, RAISE FND_API.G_EXC_ERROR
4979 -- if p_line_rec is not missing, use it as line_rec insted of querying.
4980
4981 IF p_line_rec.line_id = FND_API.G_MISS_NUM THEN
4982 IF p_line_id <> FND_API.G_MISS_NUM THEN
4983 OE_Line_Util.Query_Row(p_line_id => p_line_id
4984 ,x_line_rec => l_line_rec);
4985 ELSE
4986 RAISE FND_API.G_EXC_ERROR;
4987 END IF;
4988 ELSE
4989 l_line_rec := p_line_rec;
4990 END IF;
4991
4992 IF l_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL AND
4993 l_line_rec.ato_line_id IS NULL AND
4994 l_line_rec.top_model_line_id = l_line_rec.line_id -- redundent
4995 THEN
4996 IF l_debug_level > 0 THEN
4997 oe_debug_pub.add('LEAVING IS_PTO_MODEL FUNCTION ' , 1);
4998 END IF;
4999 RETURN TRUE;
5000 ELSE
5001 IF l_debug_level > 0 THEN
5002 oe_debug_pub.add('LEAVING IS_PTO_MODEL FUNCTION ' , 1);
5003 END IF;
5004 RETURN FALSE;
5005 END IF;
5006
5007 IF l_debug_level > 0 THEN
5008 oe_debug_pub.add('LEAVING IS_PTO_MODEL FUNCTION ' , 1);
5009 END IF;
5010
5011 EXCEPTION
5012 when others then
5013 IF l_debug_level > 0 THEN
5014 oe_debug_pub.add('EXCEPTION IN IS_PTO_MODEL FUNCTION ' , 1);
5015 END IF;
5016 RETURN FALSE;
5017 END Is_PTO_Model;
5018
5019 /*----------------------------------------------------------------------
5020 Procedure Name : Is_Included_Option
5021 Description :
5022 -----------------------------------------------------------------------*/
5023
5024 FUNCTION Is_Included_Option
5025 (p_line_id IN NUMBER
5026 := FND_API.G_MISS_NUM ,
5027 p_line_rec IN OE_Order_PUB.LINE_REC_TYPE
5028 := OE_ORDER_PUB.G_MISS_LINE_REC)
5029 RETURN BOOLEAN
5030 IS
5031 l_line_rec OE_Order_PUB.LINE_REC_TYPE;
5032
5033 --
5034 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5035 --
5036 BEGIN
5037
5038 IF l_debug_level > 0 THEN
5039 oe_debug_pub.add('ENTERING IS_INCLUDED_OPTION FUNCTION ' , 1);
5040 END IF;
5041
5042 -- if p_line_rec.line_id is missing, query row
5043 -- if p_line_id and and p_line_rec both missing, RAISE FND_API.G_EXC_ERROR
5044 -- if p_line_rec is not missing, use it as line_rec insted of querying.
5045
5046 IF p_line_rec.line_id = FND_API.G_MISS_NUM THEN
5047 IF p_line_id <> FND_API.G_MISS_NUM THEN
5048 OE_Line_Util.Query_Row(p_line_id => p_line_id
5049 ,x_line_rec => l_line_rec);
5050 ELSE
5051 RAISE FND_API.G_EXC_ERROR;
5052 END IF;
5053 ELSE
5054 l_line_rec := p_line_rec;
5055 END IF;
5056
5057 IF l_line_rec.item_type_code = OE_GLOBALS.G_ITEM_INCLUDED
5058 THEN
5059 IF l_debug_level > 0 THEN
5060 oe_debug_pub.add('LEAVING IS_INCLUDED_OPTION FUNCTION ' , 1);
5061 END IF;
5062 RETURN TRUE;
5063 ELSE
5064 IF l_debug_level > 0 THEN
5065 oe_debug_pub.add('LEAVING IS_INCLUDED_OPTION FUNCTION ' , 1);
5066 END IF;
5067 RETURN FALSE;
5068 END IF;
5069
5070 IF l_debug_level > 0 THEN
5071 oe_debug_pub.add('LEAVING IS_INCLUDED_OPTION FUNCTION ' , 1);
5072 END IF;
5073
5074 EXCEPTION
5075 when others then
5076 IF l_debug_level > 0 THEN
5077 oe_debug_pub.add('EXCEPTION IN IS_INCLUDED_OPTION FUNCTION ' , 1);
5078 END IF;
5079 RETURN FALSE;
5080 END Is_Included_Option;
5081
5082
5083 /*----------------------------------------------------------------------
5084 Procedure Name : Is_Config_Item
5085 Description :
5086 -----------------------------------------------------------------------*/
5087 FUNCTION Is_Config_Item
5088 (p_line_id IN NUMBER
5089 := FND_API.G_MISS_NUM ,
5090 p_line_rec IN OE_Order_PUB.LINE_REC_TYPE
5091 := OE_ORDER_PUB.G_MISS_LINE_REC)
5092 RETURN BOOLEAN
5093 IS
5094 l_line_rec OE_Order_PUB.LINE_REC_TYPE;
5095
5096 --
5097 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5098 --
5099 BEGIN
5100
5101 IF l_debug_level > 0 THEN
5102 oe_debug_pub.add('ENTERING IS_CONFIG_ITEM FUNCTION ' , 1);
5103 END IF;
5104
5105 -- if p_line_rec.line_id is missing, query row
5106 -- if p_line_id and and p_line_rec both missing, RAISE FND_API.G_EXC_ERROR
5107 -- if p_line_rec is not missing, use it as line_rec insted of querying.
5108
5109 IF p_line_rec.line_id = FND_API.G_MISS_NUM THEN
5110 IF p_line_id <> FND_API.G_MISS_NUM THEN
5111 OE_Line_Util.Query_Row(p_line_id => p_line_id
5112 ,x_line_rec => l_line_rec);
5113 ELSE
5114 RAISE FND_API.G_EXC_ERROR;
5115 END IF;
5116 ELSE
5117 l_line_rec := p_line_rec;
5118 END IF;
5119
5120
5121 IF l_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CONFIG
5122 THEN
5123 IF l_debug_level > 0 THEN
5124 oe_debug_pub.add('LEAVING IS_CONFIG_ITEM FUNCTION ' , 1);
5125 END IF;
5126 RETURN TRUE;
5127 ELSE
5128 IF l_debug_level > 0 THEN
5129 oe_debug_pub.add('LEAVING IS_CONFIG_ITEM FUNCTION ' , 1);
5130 END IF;
5131 RETURN FALSE;
5132 END IF;
5133
5134 IF l_debug_level > 0 THEN
5135 oe_debug_pub.add('LEAVING IS_CONFIG_ITEM FUNCTION ' , 1);
5136 END IF;
5137
5138 EXCEPTION
5139 when others then
5140 IF l_debug_level > 0 THEN
5141 oe_debug_pub.add('EXCEPTION IN IS_CONFIG_ITEM FUNCTION ' , 1);
5142 END IF;
5143 RETURN FALSE;
5144 END Is_Config_item;
5145
5146 /*----------------------------------------------------------------------
5147 Procedure Name : Is_ATO_Option
5148 Description :
5149 -----------------------------------------------------------------------*/
5150 FUNCTION Is_ATO_Option
5151 (p_line_id IN NUMBER
5152 := FND_API.G_MISS_NUM ,
5153 p_line_rec IN OE_Order_PUB.LINE_REC_TYPE
5154 := OE_ORDER_PUB.G_MISS_LINE_REC)
5155 RETURN BOOLEAN
5156 IS
5157 l_line_rec OE_Order_PUB.LINE_REC_TYPE;
5158
5159 --
5160 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5161 --
5162 BEGIN
5163
5164 IF l_debug_level > 0 THEN
5165 oe_debug_pub.add('ENTERING IS_ATO_OPTION FUNCTION ' , 1);
5166 END IF;
5167
5168 -- if p_line_rec.line_id is missing, query row
5169 -- if p_line_id and and p_line_rec both missing, RAISE FND_API.G_EXC_ERROR
5170 -- if p_line_rec is not missing, use it as line_rec insted of querying.
5171
5172 IF p_line_rec.line_id = FND_API.G_MISS_NUM THEN
5173 IF p_line_id <> FND_API.G_MISS_NUM THEN
5174 OE_Line_Util.Query_Row(p_line_id => p_line_id
5175 ,x_line_rec => l_line_rec);
5176 ELSE
5177 RAISE FND_API.G_EXC_ERROR;
5178 END IF;
5179 ELSE
5180 l_line_rec := p_line_rec;
5181 END IF;
5182
5183
5184 IF l_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION AND
5185 l_line_rec.ato_line_id is not null AND
5186 l_line_rec.top_model_line_id = l_line_rec.ato_line_id
5187 -- not an ato under pto
5188 THEN
5189 IF l_debug_level > 0 THEN
5190 oe_debug_pub.add('LEAVING IS_ATO_OPTION FUNCTION ' , 1);
5191 END IF;
5192 RETURN TRUE;
5193 ELSE
5194 IF l_debug_level > 0 THEN
5195 oe_debug_pub.add('LEAVING IS_ATO_OPTION FUNCTION ' , 1);
5196 END IF;
5197 RETURN FALSE;
5198 END IF;
5199
5200 IF l_debug_level > 0 THEN
5201 oe_debug_pub.add('LEAVING IS_ATO_OPTION FUNCTION ' , 1);
5202 END IF;
5203
5204 EXCEPTION
5205 when others then
5206 IF l_debug_level > 0 THEN
5207 oe_debug_pub.add('EXCEPTION IN IS_ATO_OPTION FUNCTION ' , 1);
5208 END IF;
5209 RETURN FALSE;
5210 END Is_ATO_Option;
5211
5212
5213 /*----------------------------------------------------------------------
5214 Procedure Name : Is_PTO_Option
5215 Description :
5216 -----------------------------------------------------------------------*/
5217 FUNCTION Is_PTO_Option
5218 (p_line_id IN NUMBER
5219 := FND_API.G_MISS_NUM ,
5220 p_line_rec IN OE_Order_PUB.LINE_REC_TYPE
5221 := OE_ORDER_PUB.G_MISS_LINE_REC)
5222 RETURN BOOLEAN
5223 IS
5224 l_line_rec OE_Order_PUB.LINE_REC_TYPE;
5225
5226 --
5227 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5228 --
5229 BEGIN
5230
5231 IF l_debug_level > 0 THEN
5232 oe_debug_pub.add('ENTERING IS_PTO_OPTION FUNCTION ' , 1);
5233 END IF;
5234
5235 -- if p_line_rec.line_id is missing, query row
5236 -- if p_line_id and and p_line_rec both missing, RAISE FND_API.G_EXC_ERROR
5237 -- if p_line_rec is not missing, use it as line_rec insted of querying.
5238
5239 IF p_line_rec.line_id = FND_API.G_MISS_NUM THEN
5240 IF p_line_id <> FND_API.G_MISS_NUM THEN
5241 OE_Line_Util.Query_Row(p_line_id => p_line_id
5242 ,x_line_rec => l_line_rec);
5243 ELSE
5244 RAISE FND_API.G_EXC_ERROR;
5245 END IF;
5246 ELSE
5247 l_line_rec := p_line_rec;
5248 END IF;
5249
5250 IF l_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION AND
5251 l_line_rec.ato_line_id is null
5252 THEN
5253 IF l_debug_level > 0 THEN
5254 oe_debug_pub.add('LEAVING IS_PTO_OPTION FUNCTION ' , 1);
5255 END IF;
5256 RETURN TRUE;
5257 ELSE
5258 IF l_debug_level > 0 THEN
5259 oe_debug_pub.add('LEAVING IS_PTO_OPTION FUNCTION ' , 1);
5260 END IF;
5261 RETURN FALSE;
5262 END IF;
5263
5264 IF l_debug_level > 0 THEN
5265 oe_debug_pub.add('LEAVING IS_PTO_OPTION FUNCTION ' , 1);
5266 END IF;
5267
5268 EXCEPTION
5269 when others then
5270 IF l_debug_level > 0 THEN
5271 oe_debug_pub.add('EXCEPTION IN IS_PTO_OPTION FUNCTION ' , 1);
5272 END IF;
5273 RETURN FALSE;
5274 END Is_PTO_Option;
5275
5276 /*----------------------------------------------------------------------
5277 Procedure Name : Is_ATO_Class
5278 Description :
5279 -----------------------------------------------------------------------*/
5280 FUNCTION Is_ATO_Class
5281 (p_line_id IN NUMBER
5282 := FND_API.G_MISS_NUM ,
5283 p_line_rec IN OE_Order_PUB.LINE_REC_TYPE
5284 := OE_ORDER_PUB.G_MISS_LINE_REC)
5285 RETURN BOOLEAN
5286 IS
5287 l_line_rec OE_Order_PUB.LINE_REC_TYPE;
5288
5289 --
5290 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5291 --
5292 BEGIN
5293
5294 IF l_debug_level > 0 THEN
5295 oe_debug_pub.add('ENTERING IS_ATO_CLASS FUNCTION ' , 1);
5296 END IF;
5297
5298 -- if p_line_rec.line_id is missing, query row
5299 -- if p_line_id and and p_line_rec both missing, RAISE FND_API.G_EXC_ERROR
5300 -- if p_line_rec is not missing, use it as line_rec insted of querying.
5301
5302 IF p_line_rec.line_id = FND_API.G_MISS_NUM THEN
5303 IF p_line_id <> FND_API.G_MISS_NUM THEN
5304 OE_Line_Util.Query_Row(p_line_id => p_line_id
5305 ,x_line_rec => l_line_rec);
5306 ELSE
5307 RAISE FND_API.G_EXC_ERROR;
5308 END IF;
5309 ELSE
5310 l_line_rec := p_line_rec;
5311 END IF;
5312
5313 IF l_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS AND
5314 l_line_rec.ato_line_id is not null AND
5315 l_line_rec.top_model_line_id = l_line_rec.ato_line_id
5316 -- not an ato under pto
5317 THEN
5318 IF l_debug_level > 0 THEN
5319 oe_debug_pub.add('LEAVING IS_ATO_CLASS FUNCTION ' , 1);
5320 END IF;
5321 RETURN TRUE;
5322 ELSE
5323 IF l_debug_level > 0 THEN
5324 oe_debug_pub.add('LEAVING IS_ATO_CLASS FUNCTION ' , 1);
5325 END IF;
5326 RETURN FALSE;
5327 END IF;
5328
5329 IF l_debug_level > 0 THEN
5330 oe_debug_pub.add('LEAVING IS_ATO_CLASS FUNCTION ' , 1);
5331 END IF;
5332
5333 EXCEPTION
5334 when others then
5335 IF l_debug_level > 0 THEN
5336 oe_debug_pub.add('EXCEPTION IN IS_ATO_CLASS FUNCTION ' , 1);
5337 END IF;
5338 RETURN FALSE;
5339 END Is_ATO_Class;
5340
5341
5342 /*----------------------------------------------------------------------
5343 Procedure Name : Is_PTO_Class
5344 Description :
5345 -----------------------------------------------------------------------*/
5346 FUNCTION Is_PTO_Class
5347 (p_line_id IN NUMBER
5348 := FND_API.G_MISS_NUM ,
5349 p_line_rec IN OE_Order_PUB.LINE_REC_TYPE
5350 := OE_ORDER_PUB.G_MISS_LINE_REC)
5351 RETURN BOOLEAN
5352 IS
5353 l_line_rec OE_Order_PUB.LINE_REC_TYPE;
5354
5355 --
5356 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5357 --
5358 BEGIN
5359
5360 IF l_debug_level > 0 THEN
5361 oe_debug_pub.add('ENTERING IS_PTO_CLASS FUNCTION ' , 1);
5362 END IF;
5363
5364 -- if p_line_rec.line_id is missing, query row
5365 -- if p_line_id and and p_line_rec both missing, RAISE FND_API.G_EXC_ERROR
5366 -- if p_line_rec is not missing, use it as line_rec insted of querying.
5367
5368 IF p_line_rec.line_id = FND_API.G_MISS_NUM THEN
5369 IF p_line_id <> FND_API.G_MISS_NUM THEN
5370 OE_Line_Util.Query_Row(p_line_id => p_line_id
5371 ,x_line_rec => l_line_rec);
5372 ELSE
5373 RAISE FND_API.G_EXC_ERROR;
5374 END IF;
5375 ELSE
5376 l_line_rec := p_line_rec;
5377 END IF;
5378
5379 IF l_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS AND
5380 l_line_rec.ato_line_id is not null
5381 THEN
5382 IF l_debug_level > 0 THEN
5383 oe_debug_pub.add('LEAVING IS_PTO_CLASS FUNCTION ' , 1);
5384 END IF;
5385 RETURN TRUE;
5386 ELSE
5387 IF l_debug_level > 0 THEN
5388 oe_debug_pub.add('LEAVING IS_PTO_CLASS FUNCTION ' , 1);
5389 END IF;
5390 RETURN FALSE;
5391 END IF;
5392
5393 IF l_debug_level > 0 THEN
5394 oe_debug_pub.add('LEAVING IS_PTO_CLASS FUNCTION ' , 1);
5395 END IF;
5396
5397 EXCEPTION
5398 when others then
5399 IF l_debug_level > 0 THEN
5400 oe_debug_pub.add('EXCEPTION IN IS_PTO_CLASS FUNCTION ' , 1);
5401 END IF;
5402 RETURN FALSE;
5403 END Is_PTO_Class;
5404
5405
5406 /*----------------------------------------------------------------------
5407 Procedure Name : Is_ATO_Subconfig
5408 Description :
5409 -----------------------------------------------------------------------*/
5410 FUNCTION Is_ATO_Subconfig
5411 (p_line_id IN NUMBER
5412 := FND_API.G_MISS_NUM ,
5413 p_line_rec IN OE_Order_PUB.LINE_REC_TYPE
5414 := OE_ORDER_PUB.G_MISS_LINE_REC)
5415 RETURN BOOLEAN
5416 IS
5417 l_line_rec OE_Order_PUB.LINE_REC_TYPE;
5418
5419 --
5420 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5421 --
5422 BEGIN
5423
5424 IF l_debug_level > 0 THEN
5425 oe_debug_pub.add('ENTERING IS_ATO_SUBCONFIG FUNCTION ' , 1);
5426 END IF;
5427
5428 -- if p_line_rec.line_id is missing, query row
5429 -- if p_line_id and and p_line_rec both missing, RAISE FND_API.G_EXC_ERROR
5430 -- if p_line_rec is not missing, use it as line_rec insted of querying.
5431
5432 IF p_line_rec.line_id = FND_API.G_MISS_NUM THEN
5433 IF p_line_id <> FND_API.G_MISS_NUM THEN
5434 OE_Line_Util.Query_Row(p_line_id => p_line_id
5435 ,x_line_rec => l_line_rec);
5436 ELSE
5437 RAISE FND_API.G_EXC_ERROR;
5438 END IF;
5439 ELSE
5440 l_line_rec := p_line_rec;
5441 END IF;
5442
5443 -- what about subconfig options
5444 IF l_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS AND
5445 l_line_rec.ato_line_id is not null AND
5446 l_line_rec.top_model_line_id <> l_line_rec.ato_line_id
5447 -- ato under pto
5448 THEN
5449 IF l_debug_level > 0 THEN
5450 oe_debug_pub.add('LEAVING IS_ATO_SUBCONFIG FUNCTION ' , 1);
5451 END IF;
5452 RETURN TRUE;
5453 ELSE
5454 IF l_debug_level > 0 THEN
5455 oe_debug_pub.add('LEAVING IS_ATO_SUBCONFIG FUNCTION ' , 1);
5456 END IF;
5457 RETURN FALSE;
5458 END IF;
5459
5460 IF l_debug_level > 0 THEN
5461 oe_debug_pub.add('LEAVING IS_ATO_SUBCONFIG FUNCTION ' , 1);
5462 END IF;
5463
5464 EXCEPTION
5465 when others then
5466 IF l_debug_level > 0 THEN
5467 oe_debug_pub.add('EXCEPTION IN IS_ATO_SUBCONFIG FUNCTION ' , 1);
5468 END IF;
5469 RETURN FALSE;
5470 END Is_ATO_Subconfig;
5471
5472 /*----------------------------------------------------------------------
5473 Procedure Name : Is_Kit
5474 Description :
5475 -----------------------------------------------------------------------*/
5476 FUNCTION Is_Kit
5477 (p_line_id IN NUMBER
5478 := FND_API.G_MISS_NUM ,
5479 p_line_rec IN OE_Order_PUB.LINE_REC_TYPE
5480 := OE_ORDER_PUB.G_MISS_LINE_REC)
5481 RETURN BOOLEAN
5482 IS
5483 l_line_rec OE_Order_PUB.LINE_REC_TYPE;
5484
5485 --
5486 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5487 --
5488 BEGIN
5489
5490 IF l_debug_level > 0 THEN
5491 oe_debug_pub.add('ENTERING IS_KIT FUNCTION ' , 1);
5492 END IF;
5493
5494 -- if p_line_rec.line_id is missing, query row
5495 -- if p_line_id and and p_line_rec both missing, RAISE FND_API.G_EXC_ERROR
5496 -- if p_line_rec is not missing, use it as line_rec insted of querying.
5497
5498 IF p_line_rec.line_id = FND_API.G_MISS_NUM THEN
5499 IF p_line_id <> FND_API.G_MISS_NUM THEN
5500 OE_Line_Util.Query_Row(p_line_id => p_line_id
5501 ,x_line_rec => l_line_rec);
5502 ELSE
5503 RAISE FND_API.G_EXC_ERROR;
5504 END IF;
5505 ELSE
5506 l_line_rec := p_line_rec;
5507 END IF;
5508
5509 IF l_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT
5510 THEN
5511 IF l_debug_level > 0 THEN
5512 oe_debug_pub.add('LEAVING IS_KIT FUNCTION ' , 1);
5513 END IF;
5514 RETURN TRUE;
5515 ELSE
5516 IF l_debug_level > 0 THEN
5517 oe_debug_pub.add('LEAVING IS_KIT FUNCTION ' , 1);
5518 END IF;
5519 RETURN FALSE;
5520 END IF;
5521
5522 IF l_debug_level > 0 THEN
5523 oe_debug_pub.add('LEAVING IS_KIT FUNCTION ' , 1);
5524 END IF;
5525
5526 EXCEPTION
5527 when others then
5528 IF l_debug_level > 0 THEN
5529 oe_debug_pub.add('EXCEPTION IN IS_KIT FUNCTION ' , 1);
5530 END IF;
5531 RETURN FALSE;
5532 END Is_Kit;
5533
5534 /*----------------------------------------------------------------------
5535 Procedure Name : Is_Ato_Item
5536 Description :
5537 -----------------------------------------------------------------------*/
5538 FUNCTION Is_Ato_Item
5539 (p_line_id IN NUMBER
5540 := FND_API.G_MISS_NUM ,
5541 p_line_rec IN OE_Order_PUB.LINE_REC_TYPE
5542 := OE_ORDER_PUB.G_MISS_LINE_REC)
5543 RETURN BOOLEAN
5544 IS
5545 l_line_rec OE_Order_PUB.LINE_REC_TYPE;
5546
5547 --
5548 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5549 --
5550 BEGIN
5551
5552 IF l_debug_level > 0 THEN
5553 oe_debug_pub.add('ENTERING IS_ATO_ITEM FUNCTION ' , 1);
5554 END IF;
5555
5556 -- if p_line_rec.line_id is missing, query row
5557 -- if p_line_id and and p_line_rec both missing, RAISE FND_API.G_EXC_ERROR
5558 -- if p_line_rec is not missing, use it as line_rec insted of querying.
5559
5560 IF p_line_rec.line_id = FND_API.G_MISS_NUM THEN
5561 IF p_line_id <> FND_API.G_MISS_NUM THEN
5562 OE_Line_Util.Query_Row(p_line_id => p_line_id
5563 ,x_line_rec => l_line_rec);
5564 ELSE
5565 RAISE FND_API.G_EXC_ERROR;
5566 END IF;
5567 ELSE
5568 l_line_rec := p_line_rec;
5569 END IF;
5570
5571 IF (l_line_rec.item_type_code = OE_GLOBALS.G_ITEM_STANDARD OR
5572 l_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION ) AND
5573 l_line_rec.ato_line_id = l_line_rec.line_id
5574 THEN
5575 IF l_debug_level > 0 THEN
5576 oe_debug_pub.add('LEAVING IS_ATO_ITEM FUNCTION ' , 1);
5577 END IF;
5578 RETURN TRUE;
5579 ELSE
5580 IF l_debug_level > 0 THEN
5581 oe_debug_pub.add('LEAVING IS_ATO_ITEM FUNCTION ' , 1);
5582 END IF;
5583 RETURN FALSE;
5584 END IF;
5585
5586 IF l_debug_level > 0 THEN
5587 oe_debug_pub.add('LEAVING IS_ATO_ITEM FUNCTION ' , 1);
5588 END IF;
5589
5590 EXCEPTION
5591 when others then
5592 IF l_debug_level > 0 THEN
5593 oe_debug_pub.add('EXCEPTION IN IS_ATO_ITEM FUNCTION ' , 1);
5594 END IF;
5595 RETURN FALSE;
5596 END Is_Ato_Item;
5597
5598
5599 /*-------------------------------------------------------------------
5600 PROCEDURE Query_Config:
5601 This function is called by query_options and query_included_items
5602 and query_ato_options. For query_ato and query_included, we make
5603 l_top_model_line_id as null, so that we do not return all the lines
5604 in that configuration bu only ato options/included items of that line
5605 ---------------------------------------------------------------------*/
5606
5607 PROCEDURE Query_Config
5608 ( p_link_to_line_id IN NUMBER := FND_API.G_MISS_NUM
5609 , p_top_model_line_id IN NUMBER := FND_API.G_MISS_NUM
5610 , p_ato_line_id IN NUMBER := FND_API.G_MISS_NUM
5611 , x_line_tbl OUT NOCOPY OE_ORDER_PUB.line_tbl_type)
5612 IS
5613 l_line_rec OE_Order_PUB.Line_Rec_Type
5614 := OE_Order_PUB.G_MISS_LINE_REC;
5615 l_top_model_line_id NUMBER;
5616 l_line_id NUMBER := 0;
5617 ll_line_id NUMBER := 0;
5618 l_header_id NUMBER := 0;
5619
5620 CURSOR l_line_csr(l_top_model_line_id NUMBER) IS
5621 SELECT line_id
5622 FROM OE_ORDER_LINES_ALL
5623 WHERE HEADER_ID = l_header_id
5624 AND (TOP_MODEL_LINE_ID = l_top_model_line_id OR
5625 ( LINK_TO_LINE_ID = p_link_to_line_id AND
5626 ITEM_TYPE_CODE = OE_GLOBALS.G_ITEM_INCLUDED AND
5627 TOP_MODEL_LINE_ID = p_top_model_line_id) OR
5628 ( ATO_LINE_ID = p_ato_line_id AND
5629 TOP_MODEL_LINE_ID = p_top_model_line_id))
5630 ORDER BY line_number,shipment_number,nvl(option_number,-1);
5631
5632 --
5633 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5634 --
5635 BEGIN
5636 IF l_debug_level > 0 THEN
5637 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.QUERY_CONFIG' , 1);
5638 END IF;
5639
5640 l_top_model_line_id := p_top_model_line_id;
5641
5642 BEGIN
5643 IF (p_link_to_line_id is not null and
5644 p_link_to_line_id <> FND_API.G_MISS_NUM) THEN
5645 ll_line_id := p_link_to_line_id;
5646 ELSIF (p_top_model_line_id is not null and
5647 p_top_model_line_id <> FND_API.G_MISS_NUM) THEN
5648 ll_line_id := p_top_model_line_id;
5649 ELSIF (p_ato_line_id is not null and
5650 p_ato_line_id <> FND_API.G_MISS_NUM) THEN
5651 ll_line_id := p_ato_line_id;
5652 ELSE
5653 ll_line_id := 0;
5654 END IF;
5655
5656 SELECT header_id
5657 INTO l_header_id
5658 FROM oe_order_lines_all
5659 WHERE line_id=ll_line_id;
5660
5661 EXCEPTION
5662 WHEN OTHERS THEN
5663 l_header_id:=0;
5664 END;
5665
5666 IF p_ato_line_id <> FND_API.G_MISS_NUM OR
5667 p_link_to_line_id <> FND_API.G_MISS_NUM THEN
5668 l_top_model_line_id := NULL;
5669 END IF;
5670
5671 IF l_debug_level > 0 THEN
5672 oe_debug_pub.add('HEADER_ID: ' || L_HEADER_ID , 3 );
5673 END IF;
5674
5675 -- Loop over fetched records
5676 OPEN l_line_csr(l_top_model_line_id);
5677
5678 LOOP
5679 FETCH l_line_csr into l_line_id;
5680 EXIT WHEN l_line_csr%NOTFOUND;
5681
5682 OE_Line_Util.Query_Row( p_line_id => l_line_id
5683 ,x_line_rec => l_line_rec );
5684
5685 x_line_tbl(x_line_tbl.COUNT + 1) := l_line_rec;
5686
5687 END LOOP;
5688
5689 IF l_debug_level > 0 THEN
5690 oe_debug_pub.add('LEAVING QUERY CONFIG' , 1);
5691 END IF;
5692
5693 EXCEPTION
5694 WHEN NO_DATA_FOUND THEN
5695 IF l_debug_level > 0 THEN
5696 oe_debug_pub.add('NO_DATA_FOUND IN QUERY_CONFIG' , 1);
5697 END IF;
5698 RAISE NO_DATA_FOUND;
5699
5700 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5701 IF l_debug_level > 0 THEN
5702 oe_debug_pub.add('EXC_UNXP IN QUERY_CONFIG' , 1);
5703 END IF;
5704 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5705
5706 WHEN OTHERS THEN
5707
5708 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5709 THEN
5710 IF l_debug_level > 0 THEN
5711 oe_debug_pub.add('OTHERS IN QUERY_CONFIG' , 1);
5712 END IF;
5713 OE_MSG_PUB.Add_Exc_Msg
5714 ( G_PKG_NAME
5715 , 'Query_Config'
5716 );
5717 END IF;
5718
5719 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5720 END Query_Config;
5721
5722
5723 /*------------------------------------------------------------
5724 helper to see who commits
5725 -------------------------------------------------------------*/
5726
5727 Procedure get_transaction_id(p_caller IN VARCHAR2)
5728 IS
5729 l_tran_id VARCHAR2(1000);
5730 --
5731 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5732 --
5733 BEGIN
5734 --insert into values(1);
5735 --uncomment when you want to see tran id
5736 --should not go in tst115
5737 l_tran_id := dbms_transaction.local_transaction_id();
5738 IF l_debug_level > 0 THEN
5739 oe_debug_pub.add(P_CALLER ||' , TRANSACTION_ID: '|| L_TRAN_ID , 1);
5740 END IF;
5741 END get_transaction_id;
5742
5743
5744
5745
5746 /*-----------------------------------------------------------
5747 PROCEDURE: Complete_Configuration
5748
5749 Description: if there is any ambiguity, exception here
5750 will indicate it. component_code should be
5751 passed in case of ambiguities. sort_order
5752 and comp_seq_id, I will get it through upd_cur
5753 in process_config. Component_code can also be
5754 derived there but we do not want any ambiuities
5755 to be passedd to SPC. This procedure will also
5756 populate the component_sequence_id, sort_order
5757 and uom on the records if they are null.
5758 ------------------------------------------------------------*/
5759
5760 PROCEDURE Complete_Configuration
5761 (p_top_model_line_id IN NUMBER,
5762 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
5763 IS
5764 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
5765 l_sort_order VARCHAR2(2000); -- 4336446
5766 l_uom_code VARCHAR2(3);
5767 l_model_seq_id NUMBER;
5768 l_model_comp_seq_id NUMBER;
5769 l_component_code VARCHAR2(1000);
5770 l_component_item_id NUMBER;
5771 l_component_seq_id NUMBER;
5772 l_rev_date DATE;
5773 l_validation_org NUMBER := OE_SYS_PARAMETERS.VALUE
5774 ('MASTER_ORGANIZATION_ID');
5775 l_group_id NUMBER := null;
5776 l_session_id NUMBER := 0;
5777 l_levels NUMBER := 60;
5778 l_stdcompflag VARCHAR2(10) := Oe_Config_Util.OE_BMX_ALL_COMPS;
5779 l_exp_quantity NUMBER;
5780 l_top_item_id NUMBER;
5781 l_num_lines NUMBER := 0;
5782 l_model_ordered_item VARCHAR2(2000);
5783 l_msg_data VARCHAR2(2000);
5784 l_error_code NUMBER;
5785
5786 CURSOR comp_code_upd IS
5787 SELECT line_id, inventory_item_id, ordered_item, component_code
5788 FROM oe_order_lines
5789 WHERE top_model_line_id = p_top_model_line_id
5790 AND item_type_code <> OE_GLOBALS.G_ITEM_CONFIG
5791 AND open_flag = 'Y'
5792 AND (component_code is null OR
5793 component_sequence_id is null OR
5794 sort_order is null OR
5795 order_quantity_uom is null
5796 );
5797
5798 --
5799 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5800 --
5801 BEGIN
5802
5803 IF l_debug_level > 0 THEN
5804 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.COMPLETE_CONFIGURATION' , 1);
5805 END IF;
5806
5807 BEGIN
5808
5809 SELECT creation_date, component_code, component_sequence_id,
5810 inventory_item_id, ordered_quantity, ordered_item
5811 INTO l_rev_date, l_component_code, l_model_seq_id,
5812 l_top_item_id, l_exp_quantity, l_model_ordered_item
5813 FROM oe_order_lines
5814 WHERE line_id = p_top_model_line_id;
5815
5816 EXCEPTION
5817 WHEN OTHERS THEN
5818 IF l_debug_level > 0 THEN
5819 oe_debug_pub.add('EXCEPTION IN SELECT' , 1);
5820 END IF;
5821 RAISE FND_API.G_EXC_ERROR;
5822 END;
5823
5824
5825 -- Explode the options in Bom_Explosions
5826 IF l_debug_level > 0 THEN
5827 oe_debug_pub.add('CALL TO EXPLOSION' , 2 );
5828 oe_debug_pub.add('ORG ID: '|| L_VALIDATION_ORG , 2 );
5829 END IF;
5830
5831
5832 OE_CONFIG_UTIL.Explode
5833 ( p_validation_org => l_validation_org
5834 , p_group_id => l_group_id
5835 , p_session_id => l_session_id
5836 , p_levels => l_levels
5837 , p_stdcompflag => l_stdcompflag
5838 , p_exp_quantity => l_exp_quantity
5839 , p_top_item_id => l_top_item_id
5840 , p_revdate => l_rev_date
5841 , p_component_code => l_component_code
5842 , x_msg_data => l_msg_data
5843 , x_error_code => l_error_code
5844 , x_return_status => l_return_status );
5845
5846
5847 IF l_debug_level > 0 THEN
5848 oe_debug_pub.add('AFTER CALL TO EXPLODE: '|| L_RETURN_STATUS , 2 );
5849 END IF;
5850
5851 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5852 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5853 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5854 RAISE FND_API.G_EXC_ERROR;
5855 END IF;
5856
5857 IF l_model_seq_id is null THEN
5858
5859 BEGIN
5860 SELECT bill_sequence_id
5861 into l_model_seq_id
5862 FROM bom_explosions
5863 WHERE COMPONENT_ITEM_ID = l_top_item_id
5864 AND ORGANIZATION_ID = l_validation_org
5865 AND PLAN_LEVEL = 0
5866 AND effectivity_date <= l_rev_date
5867 AND disable_date > l_rev_date
5868 AND explosion_type = l_stdcompflag ;
5869
5870 EXCEPTION
5871 WHEN NO_DATA_FOUND THEN
5872 IF l_debug_level > 0 THEN
5873 oe_debug_pub.add('COMPONENT_SEQUENCE_ID QUERY FAILED' , 1);
5874 END IF;
5875 RAISE FND_API.G_EXC_ERROR;
5876 END;
5877
5878 END IF;
5879
5880 IF l_debug_level > 0 THEN
5881 oe_debug_pub.add('COMP_SEQ_ID OF MODEL: ' || L_MODEL_SEQ_ID , 2 );
5882 END IF;
5883
5884 FOR line_rec in comp_code_upd
5885 LOOP
5886 IF l_debug_level > 0 THEN
5887 oe_debug_pub.add('COMPLETE ITEM: '|| LINE_REC.INVENTORY_ITEM_ID , 1);
5888 END IF;
5889
5890 -- 1st obtain component_code using bom_explosions, if the select
5891 -- statement fetches more than one row, there is ambiguity in the bill
5892 -- we can not set the component_code for that item.
5893 BEGIN
5894
5895 IF line_rec.component_code is not NULL THEN
5896 IF l_debug_level > 0 THEN
5897 oe_debug_pub.add('COMPONENT CODE PASSED , SOMETHING ELSE NULL' , 3 );
5898 END IF;
5899
5900 SELECT component_code, component_sequence_id, sort_order,
5901 primary_uom_code
5902 INTO l_component_code, l_component_seq_id, l_sort_order,
5903 l_uom_code
5904 FROM bom_explosions
5905 WHERE component_item_id = line_rec.inventory_item_id
5906 AND explosion_type = Oe_Config_Util.OE_BMX_ALL_COMPS
5907 AND top_bill_sequence_id = l_model_seq_id
5908 AND effectivity_date <= l_rev_date
5909 AND disable_date > l_rev_date
5910 AND organization_id = l_validation_org
5911 AND component_code = line_rec.component_code;
5912
5913 ELSE
5914 IF l_debug_level > 0 THEN
5915 oe_debug_pub.add('COMPONENT CODE NOT PASSED' , 3 );
5916 END IF;
5917
5918 SELECT component_code, component_sequence_id, sort_order,
5919 primary_uom_code
5920 INTO l_component_code, l_component_seq_id, l_sort_order,
5921 l_uom_code
5922 FROM bom_explosions
5923 WHERE component_item_id = line_rec.inventory_item_id
5924 AND explosion_type = Oe_Config_Util.OE_BMX_ALL_COMPS
5925 AND top_bill_sequence_id = l_model_seq_id
5926 AND effectivity_date <= l_rev_date
5927 AND disable_date > l_rev_date
5928 AND organization_id = l_validation_org;
5929 END IF;
5930
5931 EXCEPTION
5932 WHEN NO_DATA_FOUND THEN
5933 IF l_debug_level > 0 THEN
5934 oe_debug_pub.add('SELECT COMP_CODE FAILED , NO DATA FOUND ' , 1);
5935 oe_debug_pub.add('ITEM: '|| LINE_REC.INVENTORY_ITEM_ID , 1);
5936 END IF;
5937
5938 x_return_status := FND_API.G_RET_STS_ERROR;
5939
5940 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_ITEM_NOT_IN_BILL');
5941 FND_MESSAGE.Set_Token('COMPONENT', nvl(line_rec.ordered_item,line_rec.inventory_item_id));
5942 FND_MESSAGE.Set_Token('MODEL', nvl(l_model_ordered_item,l_top_item_id));
5943 oe_msg_pub.add;
5944 RETURN;
5945
5946 WHEN TOO_MANY_ROWS THEN
5947 IF l_debug_level > 0 THEN
5948 oe_debug_pub.add('SELECT COMP_CODE FAILED , TOO_MANY ROWS ' , 1);
5949 oe_debug_pub.add('ITEM: '|| LINE_REC.INVENTORY_ITEM_ID , 1);
5950 END IF;
5951
5952 x_return_status := FND_API.G_RET_STS_ERROR;
5953
5954 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_AMBIGUITY');
5955 FND_MESSAGE.Set_Token('COMPONENT', nvl(line_rec.ordered_item,line_rec.inventory_item_id));
5956 FND_MESSAGE.Set_Token('MODEL', nvl(l_model_ordered_item,l_top_item_id));
5957 oe_msg_pub.add;
5958 RETURN;
5959
5960 WHEN OTHERS THEN
5961 IF l_debug_level > 0 THEN
5962 oe_debug_pub.add('SELECT COMP_CODE FAILED , OTHERS ' , 1);
5963 oe_debug_pub.add('ITEM: '|| LINE_REC.INVENTORY_ITEM_ID , 1);
5964 END IF;
5965 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5966 END;
5967
5968 -- now update the oe table
5969 UPDATE oe_order_lines
5970 SET component_code = l_component_code,
5971 component_sequence_id = l_component_seq_id,
5972 sort_order = l_sort_order,
5973 order_quantity_uom = l_uom_code,
5974 lock_control = lock_control + 1
5975 WHERE line_id = line_rec.line_id;
5976
5977 END LOOP;
5978
5979 x_return_status := FND_API.G_RET_STS_SUCCESS;
5980 IF l_debug_level > 0 THEN
5981 oe_debug_pub.add('LEAVING COMPLETE CONFIGURATION' , 1);
5982 END IF;
5983
5984 EXCEPTION
5985 WHEN OTHERS THEN
5986 IF l_debug_level > 0 THEN
5987 oe_debug_pub.add('AMBIGUITY IN BILL'|| SUBSTR ( SQLERRM , 1 , 150 ) , 1);
5988 END IF;
5989 x_return_status := FND_API.G_RET_STS_ERROR;
5990 END Complete_Configuration;
5991
5992
5993 /*----------------------------------------------------------------------
5994 Procedure Name : Match_and_Reserve
5995 Description :
5996 -- The Match and Reserve first matches the ordered configuration
5997 -- against existing configurations. If a match is found,
5998 -- it will determine the available quantity to reserve.
5999 -- If the quantity available to reserve is less than the ordered
6000 -- quantity, the matching configuration item and available quantity are
6001 -- displayed for informational purposes. Reservation should not be an
6002 -- option to the user.
6003
6004 -- If sufficient quantity is available (greater than or equal to the
6005 -- quantity ordered), than this information is also displayed to the
6006 -- user who should then have the option to reserve. No partial
6007 -- reservations are allowed at this time.
6008
6009 -- no match : message.
6010 -- match with no qty, no message.
6011 -- match with qty : disply resv. question.
6012 -- comment completing w/f , when user said no.
6013 -----------------------------------------------------------------------*/
6014
6015 PROCEDURE Match_and_Reserve
6016 ( p_line_id IN NUMBER
6017 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
6018 IS
6019 l_line_rec OE_Order_Pub.line_rec_type;
6020 l_top_model_line_id NUMBER;
6021 l_ordered_quantity NUMBER;
6022 l_order_quantity_uom VARCHAR2(3);
6023 l_config_id NUMBER;
6024 l_available_qty NUMBER;
6025 l_quantity_to_reserve NUMBER;
6026 l_quantity_reserved NUMBER;
6027 l_message_name VARCHAR2(30);
6028 l_error_message VARCHAR2(2000);
6029 l_result BOOLEAN;
6030 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
6031 --
6032 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6033 --
6034 BEGIN
6035 IF l_debug_level > 0 THEN
6036 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.MATCH_AND_RESERVE' , 1);
6037 END IF;
6038 BEGIN
6039 SELECT top_model_line_id, ordered_quantity, order_quantity_uom
6040 INTO l_top_model_line_id, l_ordered_quantity, l_order_quantity_uom
6041 FROM oe_order_lines
6042 WHERE line_id = p_line_id;
6043 EXCEPTION
6044 WHEN OTHERS THEN
6045 IF l_debug_level > 0 THEN
6046 oe_debug_pub.add('OTHERS IN MATCH AND RESERVE' , 1);
6047 END IF;
6048 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6049 END;
6050
6051
6052 IF CTO_MATCH_AND_RESERVE.match_inquiry
6053 (p_model_line_id => l_top_model_line_id,
6054 p_automatic_reservation => FALSE,
6055 p_quantity_to_reserve => l_ordered_quantity,
6056 p_reservation_uom_code => l_order_quantity_uom,
6057 x_config_id => l_config_id,
6058 x_available_qty => l_available_qty,
6059 x_quantity_reserved => l_quantity_reserved,
6060 x_error_message => l_error_message,
6061 x_message_name => l_message_name)
6062 THEN
6063 IF l_config_id is NOT NULL THEN
6064
6065 IF l_available_qty > 0 THEN
6066
6067 IF l_available_qty < l_ordered_quantity THEN
6068 l_quantity_to_reserve := l_available_qty;
6069 ELSE
6070 l_quantity_to_reserve := l_ordered_quantity;
6071 END IF;
6072
6073 l_result := CTO_MATCH_AND_RESERVE.create_config_reservation
6074 (p_model_line_id => l_top_model_line_id,
6075 p_config_item_id => l_config_id,
6076 p_quantity_to_reserve => l_quantity_to_reserve,
6077 p_reservation_uom_code => l_order_quantity_uom,
6078 x_quantity_reserved => l_quantity_reserved,
6079 x_error_msg => l_error_message,
6080 x_error_msg_name => l_message_name);
6081
6082 IF l_message_name IS NOT NULL THEN
6083 FND_MESSAGE.Set_Name('BOM', l_message_name);
6084 OE_Msg_Pub.Add;
6085 END IF;
6086 END IF;
6087 ELSE -- if config_id null
6088 FND_MESSAGE.Set_Name('BOM', l_message_name);
6089 OE_Msg_Pub.Add; -- config_id is null
6090 END IF;
6091
6092 ELSE -- if cto return true for match
6093 FND_MESSAGE.Set_Name('BOM', l_message_name);
6094 OE_Msg_Pub.Add;
6095 END IF; -- if match found
6096
6097 x_return_status := l_return_status;
6098 IF l_debug_level > 0 THEN
6099 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.MATCH_AND_RESERVE' , 1);
6100 END IF;
6101
6102 EXCEPTION
6103 WHEN NO_DATA_FOUND THEN
6104 IF l_debug_level > 0 THEN
6105 oe_debug_pub.add('NO DATA FOUND IN MATCH AND RESERVE' , 1);
6106 END IF;
6107 x_return_status := FND_API.G_RET_STS_ERROR;
6108
6109 WHEN OTHERS THEN
6110 IF l_debug_level > 0 THEN
6111 oe_debug_pub.add('EXCEPTION IN MATCH AND RESERVE' , 1);
6112 END IF;
6113 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6114 END Match_and_Reserve;
6115
6116
6117 /*----------------------------------------------------------------------
6118 Procedure Name : Delink_Config_batch
6119 Description : Action supported for Order Import.
6120 Input Parameter: p_line_id : ATO Model Line Id(i.e. immediate parent of CONFIG line)
6121 -----------------------------------------------------------------------*/
6122
6123 PROCEDURE Delink_Config_batch
6124 ( p_line_id IN NUMBER
6125 , x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
6126 )
6127 IS
6128 l_config_id NUMBER ;
6129 l_item_type_code VARCHAR2(30);
6130 l_ato_line_id NUMBER;
6131 l_inv_item_id NUMBER;
6132 l_message_name VARCHAR2(30);
6133 l_error_message VARCHAR2(2000);
6134 l_table_name VARCHAR2(30);
6135 l_cto_result NUMBER;
6136 l_result BOOLEAN;
6137 l_ordered_item VARCHAR2(2000);
6138 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
6139
6140 l_config_header_id NUMBER;
6141 l_config_line_id NUMBER;
6142 l_source_type VARCHAR2(10);
6143 l_line_num VARCHAR2(20);
6144 l_po_header_id NUMBER;
6145 --bug 4411054
6146 --l_po_status VARCHAR2(4100);
6147 l_po_status_rec PO_STATUS_REC_TYPE;
6148 l_autorization_status VARCHAR2(30);
6149
6150 --
6151 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6152 --
6153 BEGIN
6154 IF l_debug_level > 0 THEN
6155 oe_debug_pub.add('ENTERING DELINK_CONFIG with :'||p_line_id);
6156 END IF;
6157
6158 BEGIN
6159 SELECT item_type_code, ato_line_id, ordered_item,inventory_item_id
6160 INTO l_item_type_code, l_ato_line_id, l_ordered_item,l_inv_item_id
6161 FROM oe_order_lines
6162 WHERE line_id = p_line_id;
6163 EXCEPTION
6164 WHEN OTHERS THEN
6165 IF l_debug_level > 0 THEN
6166 oe_debug_pub.add('DELINK BATCH ERROR' , 1);
6167 END IF;
6168 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6169 END;
6170
6171 IF (l_item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
6172 l_item_type_code = OE_GLOBALS.G_ITEM_CLASS ) AND
6173 l_ato_line_id = p_line_id THEN
6174
6175 SELECT inventory_item_id,line_id,header_id,
6176 RTRIM(line_number||'.'||shipment_number||'.'||
6177 option_number||'.'||component_number||'.'||
6178 service_number,'.'),source_type_code
6179 INTO l_config_id,l_config_line_id,l_config_header_id,
6180 l_line_num,l_source_type
6181 FROM oe_order_lines
6182 -- Bug#5026787: Start:- ato_line_id should be used instead of top_model_line_id.
6183 -- WHERE top_model_line_id = p_line_id
6184 WHERE ato_line_id = p_line_id
6185 -- Bug#5026787: End
6186 AND item_type_code = 'CONFIG';
6187
6188 -- Changes for Enhanced DropShipments. Prevent Delink
6189 -- if the PO associated with config item is Approved.
6190
6191 IF PO_CODE_RELEASE_GRP.Current_Release >=
6192 PO_CODE_RELEASE_GRP.PRC_11i_Family_Pack_J AND
6193 OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' AND
6194 l_source_type = 'EXTERNAL' THEN
6195
6196 BEGIN
6197 SELECT po_header_id
6198 INTO l_po_header_id
6199 FROM oe_drop_ship_sources
6200 WHERE line_id = l_config_line_id
6201 AND header_id = l_config_header_id;
6202 EXCEPTION
6203 WHEN NO_DATA_FOUND THEN
6204 IF l_debug_level > 0 THEN
6205 OE_DEBUG_PUB.Add('PO Not Created for Config.' , 2 );
6206 END IF;
6207 END;
6208
6209 IF l_po_header_id is not null THEN
6210
6211 -- comment out for bug 4411054
6212 /*l_po_status := UPPER(PO_HEADERS_SV3.Get_PO_Status
6213 (x_po_header_id => l_po_header_id
6214 ));
6215 */
6216 PO_DOCUMENT_CHECKS_GRP.po_status_check
6217 (p_api_version => 1.0
6218 , p_header_id => l_po_header_id
6219 , p_mode => 'GET_STATUS'
6220 , x_po_status_rec => l_po_status_rec
6221 , x_return_status => l_return_status);
6222
6223 IF(l_return_status = FND_API.G_RET_STS_SUCCESS) THEN
6224 l_autorization_status := l_po_status_rec.authorization_status(1);
6225
6226 IF l_debug_level > 0 THEN
6227 OE_DEBUG_PUB.Add('Sucess call from PO_DOCUMENT_CHECKS_GRP.po_status_check',2);
6228 OE_DEBUG_PUB.Add('Check PO Status : '|| l_autorization_status, 2);
6229 END IF;
6230 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6231 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6232 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6233 RAISE FND_API.G_EXC_ERROR;
6234 END IF;
6235
6236 END IF;
6237
6238 --IF (INSTR(nvl(l_po_status,'z'), 'APPROVED') <> 0 ) THEN
6239 IF(nvl(l_autorization_status,'z')= 'APPROVED') THEN
6240 FND_MESSAGE.Set_Name('ONT', 'ONT_DELINK_NOT_ALLOWED');
6241 FND_MESSAGE.Set_Token('LINE_NUM', l_line_num);
6242 FND_MESSAGE.Set_Token('MODEL', l_ordered_item);
6243 OE_MSG_PUB.Add;
6244 RETURN;
6245 END IF;
6246
6247 END IF;
6248
6249 IF l_debug_level > 0 THEN
6250 oe_debug_pub.add('AFTER SELECT STMT.' , 2 );
6251 END IF;
6252
6253 l_cto_result := CTO_CONFIG_ITEM_PK.Delink_Item
6254 ( pModelLineId => p_line_id,
6255 pConfigId => l_config_id,
6256 xErrorMessage => l_error_message,
6257 xMessageName => l_message_name,
6258 xTableName => l_table_name);
6259
6260 --returns 1 in case of successful completion, 0 in case of error
6261
6262 IF l_debug_level > 0 THEN
6263 oe_debug_pub.add('AFTER CALL TO CTO_CONFIG_ITEM_PK.DELINK_ITEM ',2);
6264 oe_debug_pub.add('L_CTO_RESULT:'|| L_CTO_RESULT , 2 );
6265 END IF;
6266
6267 IF (l_cto_result = 1) THEN
6268 IF l_debug_level > 0 THEN
6269 oe_debug_pub.add('DELINKED CONFIG ITEM' , 2 );
6270 END IF;
6271 ELSE
6272 IF l_debug_level > 0 THEN
6273 oe_debug_pub.add('CTO RESULT NOT 1' , 2 );
6274 END IF;
6275 IF l_message_name IS NOT NULL THEN
6276 FND_MESSAGE.Set_Name('BOM', l_message_name);
6277 oe_msg_pub.add;
6278 ELSE
6279 IF l_debug_level > 0 THEN
6280 oe_debug_pub.add('CTO MESSAGE NAME NULL' , 2 );
6281 END IF;
6282 END IF;
6283 END IF;
6284 ELSE
6285 IF l_debug_level > 0 THEN
6286 oe_debug_pub.add('DELINK_CONFIG_ITEM ALLOWED ONLY FROM ATO MODEL',1);
6287 END IF;
6288 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_INVALID_ACTION');
6289 FND_MESSAGE.Set_Token('ACTION', 'Delink Config');
6290 oe_msg_pub.add;
6291 END IF;
6292
6293 IF l_debug_level > 0 THEN
6294 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.DELINK_CONFIG' , 1);
6295 END IF;
6296
6297 x_return_status := l_return_status;
6298
6299 EXCEPTION
6300 WHEN NO_DATA_FOUND THEN
6301 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_NO_ITEM_TO_DELINK');
6302 FND_MESSAGE.Set_Token('MODEL', nvl(l_ordered_item,l_inv_item_id));
6303 oe_msg_pub.add;
6304 x_return_status := FND_API.G_RET_STS_ERROR;
6305
6306 WHEN OTHERS THEN
6307 IF l_debug_level > 0 THEN
6308 oe_debug_pub.add('EXCEPTION IN DELINK_CONFIG' , 1);
6309 END IF;
6310 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6311 END Delink_Config_batch;
6312
6313
6314 /*----------------------------------------------------------------------
6315 Procedure Name : Part_of_Configuration
6316 Description : API used for constraint evaluation.
6317 Result of 1 means operation is constrained.
6318 -----------------------------------------------------------------------*/
6319
6320 PROCEDURE Part_of_Configuration
6321 ( p_application_id IN NUMBER,
6322 p_entity_short_name IN VARCHAR2,
6323 p_validation_entity_short_name IN VARCHAR2,
6324 p_validation_tmplt_short_name IN VARCHAR2,
6325 p_record_set_short_name IN VARCHAR2,
6326 p_scope IN VARCHAR2,
6327 x_result OUT NOCOPY /* file.sql.39 change */ NUMBER )
6328 IS
6329 l_item_type_code VARCHAR2(30);
6330 l_header_id NUMBER;
6331 l_top_model_line_id NUMBER;
6332 l_line_id NUMBER;
6333 l_count NUMBER;
6334 --
6335 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6336 --
6337 BEGIN
6338 IF l_debug_level > 0 THEN
6339 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.PART_OF_CONFIGURATION' , 1);
6340 END IF;
6341
6342 SELECT item_type_code,header_id, top_model_line_id, line_id
6343 INTO l_item_type_code,l_header_id, l_top_model_line_id, l_line_id
6344 FROM oe_order_lines
6345 WHERE line_id = oe_line_security.g_record.line_id;
6346
6347 IF l_item_type_code = OE_GLOBALS.G_ITEM_STANDARD OR
6348 l_item_type_code = OE_GLOBALS.G_ITEM_SERVICE OR
6349 l_item_type_code = OE_GLOBALS.G_ITEM_INCLUDED
6350 THEN
6351 x_result := 0;
6352 RETURN;
6353 END IF;
6354
6355 IF l_item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
6356 l_item_type_code = OE_GLOBALS.G_ITEM_OPTION OR
6357 l_item_type_code = OE_GLOBALS.G_ITEM_CONFIG OR
6358 ( l_item_type_code = OE_GLOBALS.G_ITEM_KIT AND
6359 l_top_model_line_id <> l_line_id)
6360 THEN
6361 x_result := 1;
6362 RETURN;
6363 END IF;
6364
6365 l_count := 0;
6366
6367 IF l_item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
6368 ( l_item_type_code = OE_GLOBALS.G_ITEM_KIT AND
6369 l_top_model_line_id = l_line_id)
6370 THEN
6371 SELECT count(*)
6372 INTO l_count
6373 FROM OE_ORDER_LINES
6374 WHERE top_model_line_id = oe_line_security.g_record.line_id
6375 AND line_id <> oe_line_security.g_record.line_id
6376 AND header_id = l_header_id;
6377
6378 IF l_count > 0 THEN
6379 x_result := 1;
6380 RETURN;
6381 ELSE
6382 x_result := 0;
6383 RETURN;
6384 END IF;
6385 END IF;
6386
6387 x_result := 0;
6388 IF l_debug_level > 0 THEN
6389 oe_debug_pub.add('EXITING PART_OF_CONFIGURATION, UNKNOWN ITEM_TYPE', 1);
6390 END IF;
6391
6392 END Part_of_Configuration;
6393
6394 /*----------------------------------------------------------------------
6395 Procedure Name : Link_Config
6396 Description : Action supported for Order Import.
6397
6398 -----------------------------------------------------------------------*/
6399
6400 PROCEDURE Link_Config
6401 ( p_line_id IN NUMBER
6402 , p_config_item_id IN NUMBER
6403 , x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
6404 )
6405 IS
6406 l_item_type_code VARCHAR2(30);
6407 l_ato_line_id NUMBER;
6408 l_message_name VARCHAR2(30);
6409 l_error_message VARCHAR2(2000);
6410 l_table_name VARCHAR2(30);
6411 l_result BOOLEAN;
6412 l_cto_result NUMBER(38) := 0;
6413 l_ordered_item VARCHAR2(2000);
6414 l_valid NUMBER;
6415 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
6416
6417 --
6418 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6419 --
6420 BEGIN
6421 IF l_debug_level > 0 THEN
6422 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.LINK_CONFIG' , 1);
6423 END IF;
6424
6425 BEGIN
6426 SELECT item_type_code, ato_line_id, ordered_item
6427 INTO l_item_type_code, l_ato_line_id, l_ordered_item
6428 FROM oe_order_lines
6429 WHERE line_id = p_line_id;
6430 EXCEPTION
6431 WHEN OTHERS THEN
6432 IF l_debug_level > 0 THEN
6433 oe_debug_pub.add('LINK CONFIG ERROR' , 2 );
6434 END IF;
6435 l_valid := 1;
6436 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6437 END;
6438
6439 IF (l_item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
6440 l_item_type_code = OE_GLOBALS.G_ITEM_CLASS ) AND
6441 l_ato_line_id = p_line_id THEN
6442
6443 l_valid := 0;
6444
6445 SELECT distinct 1
6446 INTO l_valid
6447 FROM oe_order_lines_all oel,
6448 mtl_system_items msi
6449 WHERE oel.line_id = p_line_id
6450 AND oel.inventory_item_id = msi.base_item_id
6451 AND msi.inventory_item_id = p_config_item_id;
6452
6453 l_result := CTO_MANUAL_LINK_CONFIG.link_config
6454 ( p_model_line_id => p_line_id,
6455 p_config_item_id => p_config_item_id,
6456 x_error_message => l_error_message,
6457 x_message_name => l_message_name );
6458
6459 IF NOT (l_result) THEN
6460 FND_MESSAGE.Set_Name('BOM', l_message_name);
6461 oe_msg_pub.add();
6462 END IF;
6463
6464 ELSE
6465 IF l_debug_level > 0 THEN
6466 oe_debug_pub.add('LINK_CONFIG_ITEM ALLOWED ONLY FROM ATO MODEL', 2 );
6467 END IF;
6468 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_INVALID_ACTION');
6469 FND_MESSAGE.Set_Token('ACTION', 'Link Config');
6470 oe_msg_pub.add;
6471 END IF;
6472
6473 IF l_debug_level > 0 THEN
6474 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.LINK_CONFIG' , 1);
6475 END IF;
6476
6477 x_return_status := l_return_status;
6478
6479 EXCEPTION
6480 WHEN OTHERS THEN
6481 IF l_debug_level > 0 THEN
6482 oe_debug_pub.add('EXCEPTION IN LINK_CONFIG' , 1);
6483 END IF;
6484
6485 IF l_valid = 0 THEN
6486 FND_MESSAGE.Set_Name('BOM', 'CTO_INVALID_LINK_ERROR');
6487 OE_Msg_Pub.add;
6488 END IF;
6489
6490 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6491 END Link_Config;
6492
6493
6494 /*----------------------------------------------------------------------
6495 Procedure Name : Update_Comp_Seq_Id
6496 Description : API for CTO to do a direct update on
6497 oe_order_lines w/o calling process_order.
6498 -----------------------------------------------------------------------*/
6499
6500 PROCEDURE Update_Comp_Seq_Id
6501 ( p_line_id IN NUMBER
6502 ,p_comp_seq_id IN NUMBER
6503 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2 )
6504 IS
6505 --
6506 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6507 --
6508 BEGIN
6509 IF l_debug_level > 0 THEN
6510 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.UPDATE_COMP_SEQ_ID' , 1);
6511 END IF;
6512
6513 UPDATE oe_order_lines
6514 SET component_sequence_id = p_comp_seq_id
6515 ,last_update_date = sysdate
6516 ,last_updated_by = FND_Global.User_Id
6517 ,last_update_login = FND_Global.Login_Id
6518 ,lock_control = lock_control + 1
6519 where line_id = p_line_id;
6520
6521 x_return_status := FND_API.G_RET_STS_SUCCESS;
6522
6523 IF l_debug_level > 0 THEN
6524 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.UPDATE_COMP_SEQ_ID' , 1);
6525 END IF;
6526
6527 EXCEPTION
6528 WHEN no_data_found THEN
6529 IF l_debug_level > 0 THEN
6530 oe_debug_pub.add('NO_DATA_FOUND IN UPDATE_COMP_SEQ_ID' , 1);
6531 END IF;
6532 x_return_status := FND_API.G_RET_STS_ERROR;
6533
6534 WHEN others THEN
6535 IF l_debug_level > 0 THEN
6536 oe_debug_pub.add('OTHERS EXCEPTION IN UPDATE_COMP_SEQ_ID' , 1);
6537 END IF;
6538 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6539 END Update_Comp_Seq_Id;
6540
6541
6542 /*----------------------------------------------------------------------
6543 Procedure Name : Update_Visible_Demand_Flag
6544 Description : API for CTO to do a direct update on
6545 oe_order_lines w/o calling process_order.
6546 -----------------------------------------------------------------------*/
6547
6548 PROCEDURE Update_Visible_Demand_Flag
6549 ( p_ato_line_id IN NUMBER
6550 ,p_visible_demand_flag IN VARCHAR2 := 'N'
6551 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2 )
6552 IS
6553 --
6554 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6555 --
6556 BEGIN
6557 IF l_debug_level > 0 THEN
6558 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.UPDATE_VISIBLE_DEMAND_FLAG' , 1);
6559 END IF;
6560
6561 UPDATE oe_order_lines
6562 SET visible_demand_flag = p_visible_demand_flag
6563 ,last_update_date = sysdate
6564 ,last_updated_by = FND_Global.User_Id
6565 ,last_update_login = FND_Global.Login_Id
6566 ,lock_control = lock_control + 1
6567 where ato_line_id = p_ato_line_id;
6568
6569 x_return_status := FND_API.G_RET_STS_SUCCESS;
6570
6571 IF l_debug_level > 0 THEN
6572 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.UPDATE_VISIBLE_DEMAND_FLAG' , 1);
6573 END IF;
6574
6575 EXCEPTION
6576 WHEN no_data_found THEN
6577 IF l_debug_level > 0 THEN
6578 oe_debug_pub.add('NO_DATA_FOUND IN UPDATE_VISIBLE_DEMAND_FLAG' , 1);
6579 END IF;
6580 x_return_status := FND_API.G_RET_STS_ERROR;
6581
6582 WHEN others THEN
6583 IF l_debug_level > 0 THEN
6584 oe_debug_pub.add('OTHERS EXCEPTION IN UPDATE_VISIBLE_DEMAND_FLAG' , 1);
6585 END IF;
6586 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6587 END Update_Visible_Demand_Flag;
6588
6589
6590 /*----------------------------------------------------------------------
6591 Procedure Name : Update_Mfg_Comp_Seq_Id
6592 Description : API for CTO to do a direct update on
6593 oe_order_lines w/o calling process_order.
6594 -----------------------------------------------------------------------*/
6595
6596 PROCEDURE Update_Mfg_Comp_Seq_Id
6597 ( p_ato_line_id IN NUMBER
6598 ,p_mfg_comp_seq_id IN NUMBER
6599 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2 )
6600 IS
6601 --
6602 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6603 --
6604 BEGIN
6605 IF l_debug_level > 0 THEN
6606 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.UPDATE_MFG_COMP_SEQ_ID' , 1);
6607 END IF;
6608
6609 UPDATE oe_order_lines_all
6610 SET mfg_component_sequence_id = p_mfg_comp_seq_id
6611 ,last_update_date = sysdate
6612 ,last_updated_by = FND_Global.User_Id
6613 ,last_update_login = FND_Global.Login_Id
6614 ,lock_control = lock_control + 1
6615 where ato_line_id = p_ato_line_id;
6616
6617 x_return_status := FND_API.G_RET_STS_SUCCESS;
6618
6619 IF l_debug_level > 0 THEN
6620 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.UPDATE_MFG_COMP_SEQ_ID' , 1);
6621 END IF;
6622
6623 EXCEPTION
6624 WHEN no_data_found THEN
6625 IF l_debug_level > 0 THEN
6626 oe_debug_pub.add('NO_DATA_FOUND IN UPDATE_MFG_COMP_SEQ_ID' , 1);
6627 END IF;
6628 x_return_status := FND_API.G_RET_STS_ERROR;
6629
6630 WHEN others THEN
6631 IF l_debug_level > 0 THEN
6632 oe_debug_pub.add('OTHERS EXCEPTION IN UPDATE_MFG_COMP_SEQ_ID' , 1);
6633 END IF;
6634 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6635 END Update_Mfg_Comp_Seq_Id;
6636
6637
6638 /*----------------------------------------------------------------------
6639 Procedure Name : Update_Model_Group_Number
6640 Description : API for CTO to do a direct update on
6641 oe_order_lines w/o calling process_order.
6642 -----------------------------------------------------------------------*/
6643
6644 PROCEDURE Update_Model_Group_Number
6645 ( p_ato_line_id IN NUMBER
6646 ,p_model_group_number IN NUMBER
6647 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2 )
6648 IS
6649 --
6650 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6651 --
6652 BEGIN
6653 IF l_debug_level > 0 THEN
6654 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.UPDATE_MODEL_GROUP_NUMBER' , 1);
6655 END IF;
6656
6657 UPDATE oe_order_lines
6658 SET model_group_number = p_model_group_number
6659 ,last_update_date = sysdate
6660 ,last_updated_by = FND_Global.User_Id
6661 ,last_update_login = FND_Global.Login_Id
6662 ,lock_control = lock_control + 1
6663 where ato_line_id = p_ato_line_id;
6664
6665 x_return_status := FND_API.G_RET_STS_SUCCESS;
6666
6667 IF l_debug_level > 0 THEN
6668 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.UPDATE_MODEL_GROUP_NUMBER' , 1);
6669 END IF;
6670
6671 EXCEPTION
6672 WHEN no_data_found THEN
6673 IF l_debug_level > 0 THEN
6674 oe_debug_pub.add('NO_DATA_FOUND IN UPDATE_MODEL_GROUP_NUMBER' , 1);
6675 END IF;
6676 x_return_status := FND_API.G_RET_STS_ERROR;
6677
6678 WHEN others THEN
6679 IF l_debug_level > 0 THEN
6680 oe_debug_pub.add('OTHERS EXCEPTION IN UPDATE_MODEL_GROUP_NUMBER' , 1);
6681 END IF;
6682 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6683 END Update_Model_Group_Number;
6684
6685
6686 /*----------------------------------------------------------------------
6687 Procedure Name : Update_Cto_Columns
6688 Description : API for CTO to do a direct update on
6689 oe_order_lines w/o calling process_order.
6690 -----------------------------------------------------------------------*/
6691
6692 PROCEDURE Update_Cto_Columns
6693 ( p_ato_line_id IN NUMBER
6694 ,p_request_id IN NUMBER
6695 ,p_program_id IN NUMBER
6696 ,p_prog_update_date IN DATE
6697 ,p_prog_appl_id IN NUMBER
6698 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2 )
6699 IS
6700 --
6701 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6702 --
6703 BEGIN
6704 IF l_debug_level > 0 THEN
6705 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.UPDATE_CTO_COLUMNS' , 1);
6706 END IF;
6707
6708 UPDATE oe_order_lines
6709 SET request_id = p_request_id
6710 ,program_id = p_program_id
6711 ,program_update_date = p_prog_update_date
6712 ,program_application_id = p_prog_appl_id
6713 ,last_update_date = sysdate
6714 ,last_updated_by = FND_Global.User_Id
6715 ,last_update_login = FND_Global.Login_Id
6716 ,lock_control = lock_control + 1
6717 where ato_line_id = p_ato_line_id;
6718
6719 x_return_status := FND_API.G_RET_STS_SUCCESS;
6720
6721 IF l_debug_level > 0 THEN
6722 oe_debug_pub.add('EXITING OE_CONFIG_UTIL.UPDATE_CTO_COLUMNS' , 1);
6723 END IF;
6724
6725 EXCEPTION
6726 WHEN no_data_found THEN
6727 IF l_debug_level > 0 THEN
6728 oe_debug_pub.add('NO_DATA_FOUND IN UPDATE_CTO_COLUMNS' , 1);
6729 END IF;
6730 x_return_status := FND_API.G_RET_STS_ERROR;
6731
6732 WHEN others THEN
6733 IF l_debug_level > 0 THEN
6734 oe_debug_pub.add('OTHERS EXCEPTION IN UPDATE_CTO_COLUMNS' , 1);
6735 END IF;
6736 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6737 END Update_Cto_Columns;
6738
6739
6740 /*------------------------------------------------------------------
6741 PROCEDURE Notify_CTO
6742 for cto change order notification.
6743 The IN parameters p_request_rec and p_request_tbl are mutually
6744 exclusive.
6745 -------------------------------------------------------------------*/
6746
6747 PROCEDURE Notify_CTO
6748 ( p_ato_line_id IN NUMBER
6749 ,p_request_rec IN OE_Order_Pub.Request_Rec_Type
6750 := OE_Order_Pub.G_MISS_REQUEST_REC
6751 ,p_request_tbl IN OE_Order_PUB.request_tbl_type
6752 := OE_Order_Pub.G_MISS_REQUEST_TBL
6753 ,p_split_tbl IN OE_Order_PUB.request_tbl_type
6754 := OE_Order_Pub.G_MISS_REQUEST_TBL
6755 ,p_decimal_tbl IN OE_Order_PUB.request_tbl_type
6756 := OE_Order_Pub.G_MISS_REQUEST_TBL
6757 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2 )
6758 IS
6759 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
6760 l_msg_count NUMBER;
6761 l_msg_data VARCHAR2(2000);
6762 l_cto_change_tbl CTO_CHANGE_ORDER_PK.CHANGE_TABLE_TYPE;
6763 l_ato_line_id NUMBER := p_ato_line_id;
6764 I NUMBER;
6765 l_split_tbl CTO_CHANGE_ORDER_PK.SPLIT_CHG_TABLE_TYPE;
6766 l_decimal_tbl CTO_CHANGE_ORDER_PK.OPTION_CHG_TABLE_TYPE;
6767
6768 --
6769 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6770 --
6771 BEGIN
6772 IF l_debug_level > 0 THEN
6773 oe_debug_pub.add('ENTERING NOTIFY_CTO' , 1);
6774 END IF;
6775
6776 I := 0;
6777
6778 IF p_request_rec.param1 is not NULL THEN
6779 I := I + 1;
6780 l_cto_change_tbl(I).change_type := CTO_CHANGE_ORDER_PK.QTY_CHANGE;
6781 l_cto_change_tbl(I).old_value := p_request_rec.param1;
6782 l_cto_change_tbl(I).new_value := p_request_rec.param2;
6783 END IF;
6784
6785 IF p_request_rec.param3 is not NULL THEN
6786 I := I + 1;
6787 l_cto_change_tbl(I).change_type := CTO_CHANGE_ORDER_PK.RD_CHANGE;
6788 l_cto_change_tbl(I).old_value := p_request_rec.param3;
6789 l_cto_change_tbl(I).new_value := p_request_rec.param4;
6790 END IF;
6791
6792 IF p_request_rec.param5 is not NULL THEN
6793 I := I + 1;
6794 l_cto_change_tbl(I).change_type := CTO_CHANGE_ORDER_PK.SSD_CHANGE;
6795 l_cto_change_tbl(I).old_value := p_request_rec.param5;
6796 l_cto_change_tbl(I).new_value := p_request_rec.param6;
6797 END IF;
6798
6799 IF p_request_rec.param7 is not NULL THEN
6800 I := I + 1;
6801 l_cto_change_tbl(I).change_type := CTO_CHANGE_ORDER_PK.SAD_CHANGE;
6802 l_cto_change_tbl(I).old_value := p_request_rec.param7;
6803 l_cto_change_tbl(I).new_value := p_request_rec.param8;
6804 END IF;
6805
6806 IF p_request_rec.param9 is not NULL THEN
6807 I := I + 1;
6808 l_cto_change_tbl(I).change_type := CTO_CHANGE_ORDER_PK.CONFIG_CHANGE;
6809 END IF;
6810
6811 IF p_request_rec.param10 is not NULL THEN
6812 I := I + 1;
6813 l_cto_change_tbl(I).change_type := CTO_CHANGE_ORDER_PK.WAREHOUSE_CHANGE;
6814 l_cto_change_tbl(I).old_value := p_request_rec.param10;
6815 l_cto_change_tbl(I).new_value := p_request_rec.param11;
6816 END IF;
6817 -- INVCONV start
6818
6819 IF p_request_rec.param12 is not NULL THEN
6820 I := I + 1;
6821 l_cto_change_tbl(I).change_type := CTO_CHANGE_ORDER_PK.QTY2_CHANGE;
6822 l_cto_change_tbl(I).old_value := p_request_rec.param12;
6823 l_cto_change_tbl(I).new_value := p_request_rec.param13;
6824 END IF;
6825 IF l_debug_level > 0 THEN
6826 oe_debug_pub.add('NOTIFY_CTO 3 ' , 1);
6827 END IF;
6828 IF p_request_rec.param14 is not NULL THEN
6829 I := I + 1;
6830 l_cto_change_tbl(I).change_type := CTO_CHANGE_ORDER_PK.QTY2_UOM_CHANGE;
6831 l_cto_change_tbl(I).old_value := p_request_rec.param14;
6832 l_cto_change_tbl(I).new_value := p_request_rec.param15;
6833 END IF;
6834 IF l_debug_level > 0 THEN
6835 oe_debug_pub.add('NOTIFY_CTO 4 ' , 1);
6836 END IF;
6837 IF p_request_rec.param16 is not NULL THEN
6838 I := I + 1;
6839 l_cto_change_tbl(I).change_type := CTO_CHANGE_ORDER_PK.QTY_UOM_CHANGE;
6840 l_cto_change_tbl(I).old_value := p_request_rec.param16;
6841 l_cto_change_tbl(I).new_value := p_request_rec.param17;
6842 END IF;
6843
6844 -- INVCONV end
6845
6846 I := p_request_tbl.FIRST;
6847 WHILE I is NOT NULL
6848 LOOP
6849 IF l_debug_level > 0 THEN
6850 oe_debug_pub.add('PTO ATO CREATE'|| P_REQUEST_TBL (I).PARAM1 , 3 );
6851 END IF;
6852
6853 SELECT ato_line_id
6854 INTO l_ato_line_id
6855 FROM oe_order_lines
6856 WHERE line_id = p_request_tbl(I).param1;
6857
6858 IF l_ato_line_id = p_request_tbl(I).param2 THEN
6859
6860 IF l_debug_level > 0 THEN
6861 oe_debug_pub.add('part of PTO, but correct ato_line_id ', 3 );
6862 END IF;
6863
6864 l_cto_change_tbl(I).change_type := CTO_CHANGE_ORDER_PK.CONFIG_CHANGE;
6865 l_cto_change_tbl(I).old_value := p_request_tbl(I).param1;
6866 l_cto_change_tbl(I).new_value := 'PTO_ATO_CREATE';
6867 l_ato_line_id := null;
6868 END IF;
6869
6870 I := p_request_tbl.NEXT(I);
6871 END LOOP;
6872
6873 I := p_decimal_tbl.FIRST;
6874 WHILE I is NOT NULL
6875 LOOP
6876 IF l_debug_level > 0 THEN
6877 oe_debug_pub.add('new qty '|| P_decimal_TBL (I).PARAM4 , 3 );
6878 oe_debug_pub.add('old qty '|| P_decimal_TBL (I).PARAM5 , 3 );
6879 END IF;
6880
6881 l_decimal_tbl(I).line_id := p_decimal_tbl(I).entity_id;
6882 l_decimal_tbl(I).old_Qty := p_decimal_tbl(I).param5;
6883 l_decimal_tbl(I).new_Qty := p_decimal_tbl(I).param4;
6884 l_decimal_tbl(I).action := p_decimal_tbl(I).param1;
6885 l_decimal_tbl(I).inventory_item_id := p_decimal_tbl(I).param6;
6886
6887 I := p_decimal_tbl.NEXT(I);
6888 END LOOP;
6889
6890 I := p_split_tbl.FIRST;
6891 WHILE I is NOT NULL
6892 LOOP
6893 IF l_debug_level > 0 THEN
6894 oe_debug_pub.add('split from '|| p_split_tbl (I).PARAM3 , 3 );
6895 oe_debug_pub.add('split to '|| p_split_tbl (I).PARAM4 , 3 );
6896 END IF;
6897
6898 l_split_tbl(I).line_id := p_split_tbl(I).PARAM4;
6899
6900 I := p_split_tbl.NEXT(I);
6901 END LOOP;
6902
6903 IF l_debug_level > 0 THEN
6904 oe_debug_pub.add('OLD QTY' || P_REQUEST_REC.PARAM1 , 3 );
6905 oe_debug_pub.add('NEW QTY' || P_REQUEST_REC.PARAM2 , 3 );
6906 oe_debug_pub.add('OLD RD' || P_REQUEST_REC.PARAM3 , 3 );
6907 oe_debug_pub.add('NEW RD' || P_REQUEST_REC.PARAM4 , 3 );
6908 oe_debug_pub.add('OLD SSD' || P_REQUEST_REC.PARAM5 , 3 );
6909 oe_debug_pub.add('NEW SSD' || P_REQUEST_REC.PARAM6 , 3 );
6910 oe_debug_pub.add('OLD SAD' || P_REQUEST_REC.PARAM7 , 3 );
6911 oe_debug_pub.add('NEW SAD' || P_REQUEST_REC.PARAM8 , 3 );
6912 oe_debug_pub.add('CONFIG ' || P_REQUEST_REC.PARAM9 , 3 );
6913 oe_debug_pub.add('OLD QTY2' || P_REQUEST_REC.PARAM12 , 3 );
6914 oe_debug_pub.add('NEW QTY2' || P_REQUEST_REC.PARAM3 , 3 );
6915 oe_debug_pub.add('PTOATO ' || P_REQUEST_TBL.COUNT , 3 );
6916 oe_debug_pub.add('PLINEID '|| L_ATO_LINE_ID , 3 );
6917 oe_debug_pub.add('CALLING CTO PACKAGE '|| I , 3 );
6918 END IF;
6919
6920 IF l_cto_change_tbl.COUNT > 0 THEN
6921
6922 CTO_CHANGE_ORDER_PK.CHANGE_NOTIFY
6923 ( plineid => l_ato_line_id
6924 ,pchgtype => l_cto_change_tbl
6925 ,poptionchgdtls => l_decimal_tbl
6926 ,psplitdtls => l_split_tbl
6927 ,x_return_status => l_return_status
6928 ,x_msg_count => l_msg_count
6929 ,x_msg_data => l_msg_data );
6930
6931 END IF;
6932
6933 x_return_status := l_return_status;
6934
6935 IF l_debug_level > 0 THEN
6936 oe_debug_pub.add('LEAVING NOTIFY_CTO'|| X_RETURN_STATUS , 1);
6937 END IF;
6938 EXCEPTION
6939 WHEN OTHERS THEN
6940 IF l_debug_level > 0 THEN
6941 oe_debug_pub.add('EXCEPTION NOTIFY_CTO'|| SQLERRM , 1);
6942 END IF;
6943 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6944 END;
6945
6946
6947 /*------------------------------------------------------------------
6948 PROCEDURE Decimal_Ratio_Check
6949 helper to populate a decimal ratio message.
6950 no return status since caller does not need to check.
6951 ====================================================================
6952 This procedure is moved to OE_VALIDATE_LINE
6953 for Decimal quantities for ATO Options Project
6954 the decimal ratio check will be part of line entity
6955 validation
6956 -------------------------------------------------------------------*/
6957
6958 PROCEDURE Decimal_Ratio_Check
6959 ( p_top_model_line_id IN NUMBER
6960 ,p_component_code IN VARCHAR2
6961 ,p_ratio IN NUMBER)
6962 IS
6963 l_ordered_item VARCHAR2(2000);
6964 l_item_type_code VARCHAR2(30);
6965 l_inv_item_id NUMBER;
6966 --
6967 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6968 --
6969 BEGIN
6970
6971 IF l_debug_level > 0 THEN
6972 oe_debug_pub.add('ENTERING DECIMAL_RATIO_CHECK '|| P_COMPONENT_CODE , 1);
6973 END IF;
6974
6975 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_DECIMAL_RATIO');
6976
6977 SELECT ordered_item, item_type_code,inventory_item_id
6978 INTO l_ordered_item, l_item_type_code,l_inv_item_id
6979 FROM oe_order_lines
6980 WHERE top_model_line_id = p_top_model_line_id
6981 AND component_code = p_component_code
6982 AND rownum = 1;
6983
6984 FND_MESSAGE.Set_TOKEN('ITEM', nvl(l_ordered_item,l_inv_item_id));
6985 FND_MESSAGE.Set_TOKEN('TYPECODE', l_item_type_code);
6986 FND_MESSAGE.Set_TOKEN('VALUE',to_char(p_ratio));
6987
6988 SELECT ordered_item, item_type_code,inventory_item_id
6989 INTO l_ordered_item, l_item_type_code,l_inv_item_id
6990 FROM oe_order_lines
6991 WHERE line_id = p_top_model_line_id;
6992
6993 FND_MESSAGE.Set_TOKEN('MODEL', nvl(l_ordered_item,l_inv_item_id));
6994 FND_MESSAGE.Set_TOKEN('PTYPECODE', l_item_type_code);
6995
6996 OE_Msg_Pub.Add;
6997
6998 IF l_debug_level > 0 THEN
6999 oe_debug_pub.add('LEAVING DECIMAL_RATIO_CHECK' , 3 );
7000 END IF;
7001
7002 EXCEPTION
7003 WHEN OTHERS THEN
7004 IF l_debug_level > 0 THEN
7005 oe_debug_pub.add('DECIMAL_RATIO_CHECK '|| SQLERRM , 1);
7006 END IF;
7007
7008 END Decimal_Ratio_Check;
7009
7010 /*------------------------------------------------------------------
7011 PROCEDURE Default_Child_Line
7012 This procedure will default certain attributes from model to
7013 children instead of getting values from header.
7014
7015 This procedure will be called from,
7016 OEXDLINB.pls: Model_Option_Defaulting
7017 OEXUCFGB.pls: Process_Included_Items
7018 Since we are calling from process_included_items for the reason
7019 if class has an included item we cannot default in OEXDLINB.pls
7020 In DLINB.pls, code assumes that parent is created in db.
7021
7022 Also, top_model_line_id, item_type_code, ato_line_id and
7023 ship_model_complete_flag should be set before calling this api
7024 from defauling.
7025
7026 Donot add any inventory item dependent(OEXUDEPB.pls) attributes
7027 in this procedure.
7028
7029 We have to default some columns for options under PTO and under
7030 top level ATO Model. For options under ATO subassembly, we will
7031 get the attributes from the ATO subassembly in Process_Config.
7032 Until the call to Process_Config, options and classes under ATO
7033 subassembly will get their attributes from the PTO parent.
7034
7035 Change Record:
7036
7037 bug 1950510: The inventory_item dependent fields should
7038 not be defaulted from the parent line to child lines,
7039 commenting out NOCOPY those fields from this procedure.
7040
7041 bug 1963589: added p_direct_save parameter to default some
7042 additional columns from parent in case of direct insert of
7043 class line.
7044
7045 bug 2015511:
7046 added cancelled_flag := 'N' in direct_save defaulting.
7047
7048 2150536 : moved the ato/smc/set specific defaulting to
7049 here in default_child_line.
7050
7051 bug 2208039: copy dff from parent to child.
7052
7053 Dropship for config: populate the source_type from parent if
7054 ato_line_id not null.
7055
7056 bug 2311690: get all reqd. attributes for ato under pto
7057 from the parent ato.
7058
7059 Bug 2454658: Raise Error if Top Model line id or
7060 header id are NULL.
7061
7062 Bug 1282873: Assign override_atp_date_code from the parent to child
7063 for ato model.
7064
7065 Bug 2511313: For flexfield defaulting.
7066 The call to OE_Validate_Line.Validate_Flex is not for validation
7067 but to default the flex field segments, this call should be made
7068 after the ont_copy_model_dff logic.
7069
7070 Bug 2703023: Setting calculate price flag to Y when direct save
7071 related profile is set to Yes
7072
7073 Bug 2869052: copy dff from model to child has been extended to all
7074 callers and the validate_flex is called with validation level FULL
7075 and we raise an exception if it returns an error.
7076
7077 Bug 3060043: Enabling the code to default blanket number,blanket
7078 version number and blanket line number for Config Items.
7079 Blanket Line number and Version Number for the Child lines will be
7080 defaulted only when blanket number is defined on the parent line.
7081 Otherwise it should not.
7082 This code was added by Srini to support CONFIG ITEMS for PACK-J.
7083
7084 bug fix 3056512: ship to, bill to and request date not cascaded for
7085 non SMC models if caller provides a value.
7086
7087 MACD: Different components of a container model should be allowed to
7088 have different line types when order is received from upstream
7089 sales application
7090 -------------------------------------------------------------------*/
7091 PROCEDURE Default_Child_Line
7092 ( p_parent_line_rec IN OE_Order_Pub.Line_Rec_Type
7093 ,p_x_child_line_rec IN OUT NOCOPY OE_Order_Pub.Line_Rec_Type
7094 ,p_direct_save IN BOOLEAN := FALSE
7095 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
7096 IS
7097 --
7098 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
7099 l_blanket_line_number NUMBER;
7100 l_blanket_version_number NUMBER;
7101 l_blanket_number NUMBER;
7102 l_blanket_req_date date;
7103 l_top_container_model VARCHAR2(1);
7104 l_part_of_container VARCHAR2(1);
7105 l_return_status VARCHAR2(1);
7106
7107 BEGIN
7108 IF l_debug_level > 0 THEN
7109 oe_debug_pub.add('ENTERING DEFAULT_CHILD_LINE' , 1);
7110 END IF;
7111 x_return_status := FND_API.G_RET_STS_SUCCESS;
7112
7113 IF p_parent_line_rec.header_id is NULL OR
7114 p_parent_line_rec.top_model_line_id is NULL THEN
7115
7116 IF l_debug_level > 0 THEN
7117 oe_debug_pub.add('CORRUPT DATA' , 3 );
7118 END IF;
7119 FND_Message.Set_Name('ONT', 'OE_CONFIG_WRONG_MODEL_LINK');
7120 FND_MESSAGE.Set_TOKEN('ITEM', nvl(p_x_child_line_rec.ordered_item
7121 ,p_x_child_line_rec.inventory_item_id));
7122 OE_Msg_Pub.add();
7123 x_return_status := FND_API.G_RET_STS_ERROR;
7124 RAISE FND_API.G_EXC_ERROR;
7125 END IF;
7126
7127 p_x_child_line_rec.shipment_number := p_parent_line_rec.shipment_number;
7128 p_x_child_line_rec.line_number := p_parent_line_rec.line_number;
7129 p_x_child_line_rec.project_id := p_parent_line_rec.project_id;
7130 p_x_child_line_rec.task_id := p_parent_line_rec.task_id;
7131 p_x_child_line_rec.ship_tolerance_above
7132 := p_parent_line_rec.ship_tolerance_above;
7133 p_x_child_line_rec.ship_tolerance_below
7134 := p_parent_line_rec.ship_tolerance_below;
7135 p_x_child_line_rec.ship_from_org_id := p_parent_line_rec.ship_from_org_id;
7136
7137 IF p_x_child_line_rec.ship_from_org_id IS NOT NULL THEN
7138 p_x_child_line_rec.re_source_flag := 'N';
7139 END IF;
7140
7141 p_x_child_line_rec.shipping_method_code
7142 := p_parent_line_rec.shipping_method_code;
7143 p_x_child_line_rec.ship_model_complete_flag
7144 := p_parent_line_rec.ship_model_complete_flag;
7145 p_x_child_line_rec.freight_terms_code
7146 := p_parent_line_rec.freight_terms_code;
7147 p_x_child_line_rec.cust_po_number := p_parent_line_rec.cust_po_number;
7148 --{ Start fix for bug 2652187
7149 p_x_child_line_rec.customer_line_number := p_parent_line_rec.customer_line_number;
7150 -- End fix for bug 2652187 }
7151 p_x_child_line_rec.salesrep_id := p_parent_line_rec.salesrep_id;
7152 p_x_child_line_rec.pricing_date := p_parent_line_rec.pricing_date;
7153 p_x_child_line_rec.agreement_id := p_parent_line_rec.agreement_id;
7154 p_x_child_line_rec.tax_date := p_parent_line_rec.tax_date;
7155 p_x_child_line_rec.tax_exempt_number := p_parent_line_rec.tax_exempt_number;
7156 p_x_child_line_rec.tax_exempt_reason_code
7157 := p_parent_line_rec.tax_exempt_reason_code;
7158 p_x_child_line_rec.tax_exempt_flag := p_parent_line_rec.tax_exempt_flag;
7159 p_x_child_line_rec.planning_priority := p_parent_line_rec.planning_priority;
7160 p_x_child_line_rec.ship_set_id := p_parent_line_rec.ship_set_id;
7161 p_x_child_line_rec.arrival_set_id := p_parent_line_rec.arrival_set_id;
7162 p_x_child_line_rec.shipment_priority_code
7163 := p_parent_line_rec.shipment_priority_code;
7164 p_x_child_line_rec.fob_point_code := p_parent_line_rec.fob_point_code;
7165 p_x_child_line_rec.subinventory := p_parent_line_rec.subinventory;
7166 p_x_child_line_rec.demand_class_code := p_parent_line_rec.demand_class_code;
7167 p_x_child_line_rec.deliver_to_org_id := p_parent_line_rec.deliver_to_org_id;
7168 p_x_child_line_rec.earliest_acceptable_date
7169 := p_parent_line_rec.earliest_acceptable_date;
7170 p_x_child_line_rec.latest_acceptable_date
7171 := p_parent_line_rec.latest_acceptable_date;
7172 p_x_child_line_rec.first_ack_date := p_parent_line_rec.first_ack_date;
7173 p_x_child_line_rec.last_ack_date := p_parent_line_rec.last_ack_date;
7174 p_x_child_line_rec.first_ack_code := p_parent_line_rec.first_ack_code;
7175 p_x_child_line_rec.last_ack_code := p_parent_line_rec.last_ack_code;
7176
7177 p_x_child_line_rec.promise_date := p_parent_line_rec.promise_date;
7178 p_x_child_line_rec.shipping_instructions
7179 := p_parent_line_rec.shipping_instructions;
7180 p_x_child_line_rec.packing_instructions
7181 := p_parent_line_rec.packing_instructions;
7182 p_x_child_line_rec.model_remnant_flag := p_parent_line_rec.model_remnant_flag;
7183
7184 -- MACD ---------------------------------------------------------------
7185 IF p_x_child_line_rec.line_type_id IS NOT NULL OR
7186 p_x_child_line_rec.line_type_id <> FND_API.G_MISS_NUM THEN
7187
7188 IF l_debug_level > 0 THEN
7189 OE_DEBUG_PUB.Add('LineTypeID:'||p_x_child_line_rec.line_type_id,3);
7190 OE_DEBUG_PUB.Add('Inventory Item ID (from Parent Line):'
7191 ||p_parent_line_rec.inventory_item_id,3);
7192 END IF;
7193
7194 OE_CONFIG_TSO_PVT.Is_Part_Of_Container_Model
7195 ( p_inventory_item_id => p_parent_line_rec.inventory_item_id
7196 ,x_top_container_model => l_top_container_model
7197 ,x_part_of_container => l_part_of_container );
7198
7199 IF l_part_of_container = 'N' THEN
7200 p_x_child_line_rec.line_type_id := p_parent_line_rec.line_type_id;
7201
7202 IF l_debug_level > 0 THEN
7203 OE_DEBUG_PUB.Add
7204 ('Line_type from parent: '||p_x_child_line_rec.line_type_id,3);
7205 END IF;
7206 ELSE
7207 IF l_debug_level > 0 THEN
7208 OE_DEBUG_PUB.Add
7209 ('Keeping Line_type: '||p_x_child_line_rec.line_type_id,3);
7210 END IF;
7211 END IF;
7212 ELSE
7213 p_x_child_line_rec.line_type_id := p_parent_line_rec.line_type_id;
7214 IF l_debug_level > 0 THEN
7215 oe_debug_pub.add('COPY it: '|| P_X_CHILD_LINE_REC.line_type_id, 4 );
7216 END IF;
7217 END IF;
7218
7219
7220 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
7221
7222 IF p_parent_line_rec.blanket_number IS NOT NULL and
7223 p_parent_line_rec.item_type_code <> 'INCLUDED' THEN
7224
7225 IF l_debug_level > 0 THEN
7226 oe_debug_pub.add('Blanket No:'
7227 ||p_parent_line_rec.blanket_number);
7228 oe_debug_pub.add('Top Model Inventory Item ID:'
7229 ||p_parent_line_rec.inventory_item_id );
7230 oe_debug_pub.add('Child Inventory Item ID:'
7231 ||p_x_child_line_rec.inventory_item_id );
7232 oe_debug_pub.add('Child Item Type Code:'
7233 ||p_x_child_line_rec.item_type_code );
7234 END IF;
7235
7236 -- For the bug fix #3579240
7237 IF p_x_child_line_rec.item_type_code <> 'INCLUDED'
7238 THEN
7239
7240
7241 -- Call Blanket Procedure for the Child Items
7242
7243 oe_default_line.default_Blanket_Values ( p_blanket_number => p_parent_line_rec.blanket_number,
7244 p_cust_po_number => p_parent_line_rec.cust_po_number,
7245 p_ordered_item_id => p_x_child_line_rec.ordered_item_id, --bug6826787
7246 p_ordered_item => p_x_child_line_rec.ordered_item,
7247 p_inventory_item_id => p_x_child_line_rec.inventory_item_id,
7248 p_item_identifier_type => p_x_child_line_rec.item_type_code,
7249 p_request_date => p_x_child_line_rec.request_date,
7250 p_sold_to_org_id => p_x_child_line_rec.sold_to_org_id,
7251 x_blanket_number => p_x_child_line_rec.blanket_number,
7252 x_blanket_line_number => p_x_child_line_rec.blanket_line_number,
7253 x_blanket_version_number => p_x_child_line_rec.blanket_version_number,
7254 x_blanket_request_date => l_blanket_req_date
7255 );
7256
7257 END IF;
7258
7259 END IF;
7260
7261 END IF;
7262
7263
7264 ---------------- dff -------------------------------------------
7265
7266 IF G_COPY_MODEL_DFF = 'Y' /* Bug # 5036404 */
7267 -- OE_CONFIG_UTIL.G_CONFIG_UI_USED = 'Y'
7268 THEN
7269
7270 IF l_debug_level > 0 THEN
7271 oe_debug_pub.add('COPYING DFF TO CHILD' , 1);
7272 END IF;
7273
7274 IF p_x_child_line_rec.attribute1 is null OR
7275 p_x_child_line_rec.attribute1 = FND_API.G_MISS_CHAR THEN
7276 p_x_child_line_rec.attribute1 := p_parent_line_rec.attribute1;
7277 END IF;
7278
7279 IF p_x_child_line_rec.attribute2 is null OR
7280 p_x_child_line_rec.attribute2 = FND_API.G_MISS_CHAR THEN
7281 p_x_child_line_rec.attribute2 := p_parent_line_rec.attribute2;
7282 END IF;
7283
7284 IF p_x_child_line_rec.attribute3 is null OR
7285 p_x_child_line_rec.attribute3 = FND_API.G_MISS_CHAR THEN
7286 p_x_child_line_rec.attribute3 := p_parent_line_rec.attribute3;
7287 END IF;
7288
7289 IF p_x_child_line_rec.attribute4 is null OR
7290 p_x_child_line_rec.attribute4 = FND_API.G_MISS_CHAR THEN
7291 p_x_child_line_rec.attribute4 := p_parent_line_rec.attribute4;
7292 END IF;
7293
7294 IF p_x_child_line_rec.attribute5 is null OR
7295 p_x_child_line_rec.attribute5 = FND_API.G_MISS_CHAR THEN
7296 p_x_child_line_rec.attribute5 := p_parent_line_rec.attribute5;
7297 END IF;
7298
7299 IF p_x_child_line_rec.attribute6 is null OR
7300 p_x_child_line_rec.attribute6 = FND_API.G_MISS_CHAR THEN
7301 p_x_child_line_rec.attribute6 := p_parent_line_rec.attribute6;
7302 END IF;
7303
7304 IF p_x_child_line_rec.attribute7 is null OR
7305 p_x_child_line_rec.attribute7 = FND_API.G_MISS_CHAR THEN
7306 p_x_child_line_rec.attribute7 := p_parent_line_rec.attribute7;
7307 END IF;
7308
7309 IF p_x_child_line_rec.attribute8 is null OR
7310 p_x_child_line_rec.attribute8 = FND_API.G_MISS_CHAR THEN
7311 p_x_child_line_rec.attribute8 := p_parent_line_rec.attribute8;
7312 END IF;
7313
7314 IF p_x_child_line_rec.attribute9 is null OR
7315 p_x_child_line_rec.attribute9 = FND_API.G_MISS_CHAR THEN
7316 p_x_child_line_rec.attribute9 := p_parent_line_rec.attribute9;
7317 END IF;
7318
7319 IF p_x_child_line_rec.attribute10 is null OR
7320 p_x_child_line_rec.attribute10 = FND_API.G_MISS_CHAR THEN
7321 p_x_child_line_rec.attribute10 := p_parent_line_rec.attribute10;
7322 END IF;
7323
7324 IF p_x_child_line_rec.attribute11 is null OR
7325 p_x_child_line_rec.attribute11 = FND_API.G_MISS_CHAR THEN
7326 p_x_child_line_rec.attribute11 := p_parent_line_rec.attribute11;
7327 END IF;
7328
7329 IF p_x_child_line_rec.attribute12 is null OR
7330 p_x_child_line_rec.attribute12 = FND_API.G_MISS_CHAR THEN
7331 p_x_child_line_rec.attribute12 := p_parent_line_rec.attribute12;
7332 END IF;
7333
7334 IF p_x_child_line_rec.attribute13 is null OR
7335 p_x_child_line_rec.attribute13 = FND_API.G_MISS_CHAR THEN
7336 p_x_child_line_rec.attribute13 := p_parent_line_rec.attribute13;
7337 END IF;
7338
7339 IF p_x_child_line_rec.attribute14 is null OR
7340 p_x_child_line_rec.attribute14 = FND_API.G_MISS_CHAR THEN
7341 p_x_child_line_rec.attribute14 := p_parent_line_rec.attribute14;
7342 END IF;
7343
7344 IF p_x_child_line_rec.attribute15 is null OR
7345 p_x_child_line_rec.attribute15 = FND_API.G_MISS_CHAR THEN
7346 p_x_child_line_rec.attribute15 := p_parent_line_rec.attribute15;
7347 END IF;
7348
7349 IF p_x_child_line_rec.attribute16 is null OR -- for bug 2184255
7350 p_x_child_line_rec.attribute16 = FND_API.G_MISS_CHAR THEN
7351 p_x_child_line_rec.attribute16 := p_parent_line_rec.attribute16;
7352 END IF;
7353
7354 IF p_x_child_line_rec.attribute17 is null OR
7355 p_x_child_line_rec.attribute17 = FND_API.G_MISS_CHAR THEN
7356 p_x_child_line_rec.attribute17 := p_parent_line_rec.attribute17;
7357 END IF;
7358
7359 IF p_x_child_line_rec.attribute18 is null OR
7360 p_x_child_line_rec.attribute18 = FND_API.G_MISS_CHAR THEN
7361 p_x_child_line_rec.attribute18 := p_parent_line_rec.attribute18;
7362 END IF;
7363
7364 IF p_x_child_line_rec.attribute19 is null OR
7365 p_x_child_line_rec.attribute19 = FND_API.G_MISS_CHAR THEN
7366 p_x_child_line_rec.attribute19 := p_parent_line_rec.attribute19;
7367 END IF;
7368
7369 IF p_x_child_line_rec.attribute20 is null OR -- for bug 2184255
7370 p_x_child_line_rec.attribute20 = FND_API.G_MISS_CHAR THEN
7371 p_x_child_line_rec.attribute20 := p_parent_line_rec.attribute20;
7372 END IF;
7373
7374 IF p_x_child_line_rec.context is null OR
7375 p_x_child_line_rec.context = FND_API.G_MISS_CHAR THEN
7376 p_x_child_line_rec.context := p_parent_line_rec.context;
7377 END IF;
7378
7379 IF p_x_child_line_rec.industry_attribute1 is null OR
7380 p_x_child_line_rec.industry_attribute1 = FND_API.G_MISS_CHAR THEN
7381 p_x_child_line_rec.industry_attribute1 := p_parent_line_rec.industry_attribute1;
7382 END IF;
7383
7384 IF p_x_child_line_rec.industry_attribute2 is null OR
7385 p_x_child_line_rec.industry_attribute2 = FND_API.G_MISS_CHAR THEN
7386 p_x_child_line_rec.industry_attribute2 := p_parent_line_rec.industry_attribute2;
7387 END IF;
7388
7389 IF p_x_child_line_rec.industry_attribute3 is null OR
7390 p_x_child_line_rec.industry_attribute3 = FND_API.G_MISS_CHAR THEN
7391 p_x_child_line_rec.industry_attribute3 := p_parent_line_rec.industry_attribute3;
7392 END IF;
7393
7394 IF p_x_child_line_rec.industry_attribute4 is null OR
7395 p_x_child_line_rec.industry_attribute4 = FND_API.G_MISS_CHAR THEN
7396 p_x_child_line_rec.industry_attribute4 := p_parent_line_rec.industry_attribute4;
7397 END IF;
7398
7399 IF p_x_child_line_rec.industry_attribute5 is null OR
7400 p_x_child_line_rec.industry_attribute5 = FND_API.G_MISS_CHAR THEN
7401 p_x_child_line_rec.industry_attribute5 := p_parent_line_rec.industry_attribute5;
7402 END IF;
7403
7404 IF p_x_child_line_rec.industry_attribute6 is null OR
7405 p_x_child_line_rec.industry_attribute6 = FND_API.G_MISS_CHAR THEN
7406 p_x_child_line_rec.industry_attribute6 := p_parent_line_rec.industry_attribute6;
7407 END IF;
7408
7409 IF p_x_child_line_rec.industry_attribute7 is null OR
7410 p_x_child_line_rec.industry_attribute7 = FND_API.G_MISS_CHAR THEN
7411 p_x_child_line_rec.industry_attribute7 := p_parent_line_rec.industry_attribute7;
7412 END IF;
7413
7414 IF p_x_child_line_rec.industry_attribute8 is null OR
7415 p_x_child_line_rec.industry_attribute8 = FND_API.G_MISS_CHAR THEN
7416 p_x_child_line_rec.industry_attribute8 := p_parent_line_rec.industry_attribute8;
7417 END IF;
7418
7419 IF p_x_child_line_rec.industry_attribute9 is null OR
7420 p_x_child_line_rec.industry_attribute9 = FND_API.G_MISS_CHAR THEN
7421 p_x_child_line_rec.industry_attribute9 := p_parent_line_rec.industry_attribute9;
7422 END IF;
7423
7424 IF p_x_child_line_rec.industry_attribute10 is null OR
7425 p_x_child_line_rec.industry_attribute10 = FND_API.G_MISS_CHAR THEN
7426 p_x_child_line_rec.industry_attribute10 := p_parent_line_rec.industry_attribute10;
7427 END IF;
7428
7429 IF p_x_child_line_rec.industry_attribute11 is null OR
7430 p_x_child_line_rec.industry_attribute11 = FND_API.G_MISS_CHAR THEN
7431 p_x_child_line_rec.industry_attribute11 := p_parent_line_rec.industry_attribute11;
7432 END IF;
7433
7434 IF p_x_child_line_rec.industry_attribute12 is null OR
7435 p_x_child_line_rec.industry_attribute12 = FND_API.G_MISS_CHAR THEN
7436 p_x_child_line_rec.industry_attribute12 := p_parent_line_rec.industry_attribute12;
7437 END IF;
7438
7439 IF p_x_child_line_rec.industry_attribute13 is null OR
7440 p_x_child_line_rec.industry_attribute13 = FND_API.G_MISS_CHAR THEN
7441 p_x_child_line_rec.industry_attribute13 := p_parent_line_rec.industry_attribute13;
7442 END IF;
7443
7444 IF p_x_child_line_rec.industry_attribute14 is null OR
7445 p_x_child_line_rec.industry_attribute14 = FND_API.G_MISS_CHAR THEN
7446 p_x_child_line_rec.industry_attribute14 := p_parent_line_rec.industry_attribute14;
7447 END IF;
7448
7449 IF p_x_child_line_rec.industry_attribute15 is null OR
7450 p_x_child_line_rec.industry_attribute15 = FND_API.G_MISS_CHAR THEN
7451 p_x_child_line_rec.industry_attribute15 := p_parent_line_rec.industry_attribute15;
7452 END IF;
7453
7454 IF p_x_child_line_rec.industry_attribute16 is null OR
7455 p_x_child_line_rec.industry_attribute16 = FND_API.G_MISS_CHAR THEN
7456 p_x_child_line_rec.industry_attribute16 := p_parent_line_rec.industry_attribute16;
7457 END IF;
7458 IF p_x_child_line_rec.industry_attribute17 is null OR
7459 p_x_child_line_rec.industry_attribute17 = FND_API.G_MISS_CHAR THEN
7460 p_x_child_line_rec.industry_attribute17 := p_parent_line_rec.industry_attribute17;
7461 END IF;
7462
7463 IF p_x_child_line_rec.industry_attribute18 is null OR
7464 p_x_child_line_rec.industry_attribute18 = FND_API.G_MISS_CHAR THEN
7465 p_x_child_line_rec.industry_attribute18 := p_parent_line_rec.industry_attribute18;
7466 END IF;
7467
7468 IF p_x_child_line_rec.industry_attribute19 is null OR
7469 p_x_child_line_rec.industry_attribute19 = FND_API.G_MISS_CHAR THEN
7470 p_x_child_line_rec.industry_attribute19 := p_parent_line_rec.industry_attribute19;
7471 END IF;
7472
7473 IF p_x_child_line_rec.industry_attribute20 is null OR
7474 p_x_child_line_rec.industry_attribute20 = FND_API.G_MISS_CHAR THEN
7475 p_x_child_line_rec.industry_attribute20 := p_parent_line_rec.industry_attribute20;
7476 END IF;
7477
7478 IF p_x_child_line_rec.industry_attribute21 is null OR
7479 p_x_child_line_rec.industry_attribute21 = FND_API.G_MISS_CHAR THEN
7480 p_x_child_line_rec.industry_attribute21 := p_parent_line_rec.industry_attribute21;
7481 END IF;
7482
7483 IF p_x_child_line_rec.industry_attribute22 is null OR
7484 p_x_child_line_rec.industry_attribute22 = FND_API.G_MISS_CHAR THEN
7485 p_x_child_line_rec.industry_attribute22 := p_parent_line_rec.industry_attribute22;
7486 END IF;
7487
7488 IF p_x_child_line_rec.industry_attribute23 is null OR
7489 p_x_child_line_rec.industry_attribute23 = FND_API.G_MISS_CHAR THEN
7490 p_x_child_line_rec.industry_attribute23 := p_parent_line_rec.industry_attribute23;
7491 END IF;
7492
7493 IF p_x_child_line_rec.industry_attribute24 is null OR
7494 p_x_child_line_rec.industry_attribute24 = FND_API.G_MISS_CHAR THEN
7495 p_x_child_line_rec.industry_attribute24 := p_parent_line_rec.industry_attribute24;
7496 END IF;
7497
7498 IF p_x_child_line_rec.industry_attribute25 is null OR
7499 p_x_child_line_rec.industry_attribute25 = FND_API.G_MISS_CHAR THEN
7500 p_x_child_line_rec.industry_attribute25 := p_parent_line_rec.industry_attribute25;
7501 END IF;
7502
7503 IF p_x_child_line_rec.industry_attribute26 is null OR
7504 p_x_child_line_rec.industry_attribute26 = FND_API.G_MISS_CHAR THEN
7505 p_x_child_line_rec.industry_attribute26 := p_parent_line_rec.industry_attribute26;
7506 END IF;
7507 IF p_x_child_line_rec.industry_attribute27 is null OR
7508 p_x_child_line_rec.industry_attribute27 = FND_API.G_MISS_CHAR THEN
7509 p_x_child_line_rec.industry_attribute27 := p_parent_line_rec.industry_attribute27;
7510 END IF;
7511
7512 IF p_x_child_line_rec.industry_attribute28 is null OR
7513 p_x_child_line_rec.industry_attribute28 = FND_API.G_MISS_CHAR THEN
7514 p_x_child_line_rec.industry_attribute28 := p_parent_line_rec.industry_attribute28;
7515 END IF;
7516
7517 IF p_x_child_line_rec.industry_attribute29 is null OR
7518 p_x_child_line_rec.industry_attribute29 = FND_API.G_MISS_CHAR THEN
7519 p_x_child_line_rec.industry_attribute29 := p_parent_line_rec.industry_attribute29;
7520 END IF;
7521
7522 IF p_x_child_line_rec.industry_attribute30 is null OR
7523 p_x_child_line_rec.industry_attribute30 = FND_API.G_MISS_CHAR THEN
7524 p_x_child_line_rec.industry_attribute30 := p_parent_line_rec.industry_attribute30;
7525 END IF;
7526
7527 IF p_x_child_line_rec.industry_context is null OR
7528 p_x_child_line_rec.industry_context = FND_API.G_MISS_CHAR THEN
7529 p_x_child_line_rec.industry_context := p_parent_line_rec.industry_context;
7530 END IF;
7531
7532
7533 END IF;
7534
7535
7536 OE_Validate_Line.Validate_Flex
7537 ( p_x_line_rec => p_x_child_line_rec
7538 ,p_validation_level => FND_API.G_VALID_LEVEL_FULL
7539 ,x_return_status => x_return_status);
7540
7541 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN -- For bug 2869052
7542 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7543 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
7544 RAISE FND_API.G_EXC_ERROR;
7545 END IF;
7546
7547 ---------------- for direct save only ------------------------
7548
7549 IF p_direct_save THEN
7550
7551 p_x_child_line_rec.operation := OE_GLOBALS.G_OPR_CREATE;
7552 p_x_child_line_rec.header_id := p_parent_line_rec.header_id;
7553 p_x_child_line_rec.top_model_line_id := p_parent_line_rec.line_id;
7554 p_x_child_line_rec.item_identifier_type := 'INT';
7555 p_x_child_line_rec.item_type_code := OE_GLOBALS.G_ITEM_CLASS;
7556 p_x_child_line_rec.line_category_code
7557 := p_parent_line_rec.line_category_code;
7558 p_x_child_line_rec.creation_date := sysdate;
7559 p_x_child_line_rec.created_by := p_parent_line_rec.created_by;
7560 p_x_child_line_rec.last_update_date := p_parent_line_rec.last_update_date;
7561 p_x_child_line_rec.last_updated_by := p_parent_line_rec.last_updated_by;
7562 p_x_child_line_rec.unit_list_price := 0;
7563 p_x_child_line_rec.unit_selling_price := 0;
7564 p_x_child_line_rec.price_list_id := p_parent_line_rec.price_list_id;
7565 p_x_child_line_rec.sold_to_org_id := p_parent_line_rec.sold_to_org_id;
7566 p_x_child_line_rec.tax_code := p_parent_line_rec.tax_code;
7567 p_x_child_line_rec.shippable_flag := 'N';
7568 p_x_child_line_rec.shipping_interfaced_flag := 'N';
7569 p_x_child_line_rec.booked_flag := 'N';
7570 p_x_child_line_rec.open_flag := 'Y';
7571 p_x_child_line_rec.cancelled_flag := 'N';
7572 p_x_child_line_rec.cancelled_quantity := 0;
7573 p_x_child_line_rec.source_type_code := p_parent_line_rec.source_type_code;
7574 p_x_child_line_rec.org_id := p_parent_line_rec.org_id;
7575 -- Bug 5912216: start
7576 -- p_x_child_line_rec.flow_status_code := 'ENTERED'; (Commented out)
7577 p_x_child_line_rec.flow_status_code := p_parent_line_rec.flow_status_code;
7578 p_x_child_line_rec.transaction_phase_code := p_parent_line_rec.transaction_phase_code;
7579 -- Bug 5912216: end
7580 p_x_child_line_rec.payment_term_id := p_parent_line_rec.payment_term_id;
7581 p_x_child_line_rec.calculate_price_flag := 'Y';
7582
7583 -- this is for pure ato, pto+ato will get in change_columns.
7584 p_x_child_line_rec.ato_line_id := p_parent_line_rec.ato_line_id;
7585
7586 END IF;
7587
7588
7589 ---------- conditional defaulting here onwards----------
7590
7591
7592 ---------- SMC/ATO/SHIP and Arrival Set-----------------
7593
7594 IF p_parent_line_rec.ship_model_complete_flag = 'Y' OR
7595 p_parent_line_rec.ato_line_id = p_parent_line_rec.top_model_line_id OR
7596 (p_parent_line_rec.ship_set_id is NOT NULL AND
7597 p_parent_line_rec.ship_set_id <> FND_API.G_MISS_NUM) OR
7598 (p_parent_line_rec.arrival_set_id is NOT NULL AND
7599 p_parent_line_rec.arrival_set_id <> FND_API.G_MISS_NUM)
7600 THEN
7601 IF l_debug_level > 0 THEN
7602 oe_debug_pub.add('**PARENT IS ATO OR SMC PTO OR IN SET' , 1);
7603 END IF;
7604
7605 p_x_child_line_rec.schedule_ship_date :=
7606 p_parent_line_rec.schedule_ship_date;
7607 p_x_child_line_rec.schedule_arrival_date :=
7608 p_parent_line_rec.schedule_arrival_date;
7609 p_x_child_line_rec.freight_carrier_code :=
7610 p_parent_line_rec.freight_carrier_code;
7611
7612
7613 /* Added the following 3 lines to fix the bug 3056512 */
7614
7615 p_x_child_line_rec.ship_to_org_id := p_parent_line_rec.ship_to_org_id;
7616 p_x_child_line_rec.request_date := p_parent_line_rec.request_date;
7617 p_x_child_line_rec.invoice_to_org_id := p_parent_line_rec.invoice_to_org_id;
7618
7619 /*Begin bug 7041018,7175458*/
7620 p_x_child_line_rec.intermed_ship_to_org_id := p_parent_line_rec.intermed_ship_to_org_id;
7621 p_x_child_line_rec.ship_to_contact_id := p_parent_line_rec.ship_to_contact_id;
7622 /*end bug 7041018, 7175458*/
7623 ------------- IF SMC ----------------------------------
7624
7625 IF p_parent_line_rec.ship_model_complete_flag = 'Y' THEN
7626
7627 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
7628 p_x_child_line_rec.firm_demand_flag :=
7629 p_parent_line_rec.firm_demand_flag;
7630 END IF;
7631 END IF;
7632
7633 ------------- IF ATO ----------------------------------
7634 IF p_parent_line_rec.ato_line_id is not NULL THEN
7635 IF l_debug_level > 0 THEN
7636 oe_debug_pub.add('1 **SOURCE TYPE ATO '
7637 || P_PARENT_LINE_REC.SOURCE_TYPE_CODE , 4 );
7638 END IF;
7639
7640 p_x_child_line_rec.source_type_code :=
7641 p_parent_line_rec.source_type_code;
7642
7643 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
7644 p_x_child_line_rec.override_atp_date_code :=
7645 p_parent_line_rec.override_atp_date_code;
7646 END IF;
7647
7648 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510' THEN
7649 p_x_child_line_rec.firm_demand_flag :=
7650 p_parent_line_rec.firm_demand_flag;
7651 END IF;
7652 END IF;
7653
7654 ------------- IF NON SMC, use this branch -----------------
7655 ELSE -- Added the else to fix the bug 3056512
7656
7657 IF l_debug_level > 0 THEN
7658 oe_debug_pub.add('**PARENT IS NON SMC PTO ' , 1);
7659 END IF;
7660
7661 IF p_x_child_line_rec.ship_to_org_id = FND_API.G_MISS_NUM OR
7662 p_x_child_line_rec.ship_to_org_id IS NULL THEN
7663 p_x_child_line_rec.ship_to_org_id
7664 := p_parent_line_rec.ship_to_org_id;
7665 END IF;
7666
7667 IF p_x_child_line_rec.request_date = FND_API.G_MISS_DATE OR
7668 p_x_child_line_rec.request_date IS NULL THEN
7669 p_x_child_line_rec.request_date
7670 := p_parent_line_rec.request_date;
7671 END IF;
7672
7673 IF p_x_child_line_rec.invoice_to_org_id = FND_API.G_MISS_NUM OR
7674 p_x_child_line_rec.invoice_to_org_id IS NULL THEN
7675 p_x_child_line_rec.invoice_to_org_id
7676 := p_parent_line_rec.invoice_to_org_id;
7677 END IF;
7678
7679 /*Start bug7041018,7175458*/
7680 IF p_x_child_line_rec.intermed_ship_to_org_id = FND_API.G_MISS_NUM OR
7681 p_x_child_line_rec.intermed_ship_to_org_id IS NULL THEN
7682 p_x_child_line_rec.intermed_ship_to_org_id
7683 := p_parent_line_rec.intermed_ship_to_org_id;
7684 END IF;
7685
7686 IF p_x_child_line_rec.ship_to_contact_id = FND_API.G_MISS_NUM OR
7687 p_x_child_line_rec.ship_to_contact_id IS NULL THEN
7688 p_x_child_line_rec.ship_to_contact_id
7689 := p_parent_line_rec.ship_to_contact_id;
7690 END IF;
7691
7692 /*ENd bug 7041018,71754588*/
7693
7694 END IF; ------ if part of ato/smc/ship or arr set.
7695
7696
7697
7698 --Begin- code to get user_item_description from the parent for the child
7699
7700 IF p_x_child_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CONFIG AND
7701 p_x_child_line_rec.ato_line_id is not NULL AND
7702 p_x_child_line_rec.line_id <> p_x_child_line_rec.ato_line_id THEN
7703
7704 IF l_debug_level > 0 THEN
7705 oe_debug_pub.add('DEFAULTING USER_ITEM_DESCRIPTION
7706 FROM ATO FOR CONFIG ITEMS ', 1);
7707 END IF;
7708
7709 SELECT user_item_description
7710 INTO p_x_child_line_rec.user_item_description
7711 FROM oe_order_lines
7712 WHERE line_id = p_x_child_line_rec.ato_line_id;
7713
7714 --no need to handle exception here as exception is handled outside
7715
7716 IF l_debug_level > 0 THEN
7717 oe_debug_pub.add('USER_ITEM_DESCRIPTION on child line is: '
7718 || p_x_child_line_rec.user_item_description, 1);
7719 END IF;
7720
7721 -- Populate delivery lead time from the parent.
7722 p_x_child_line_rec.delivery_lead_time := p_parent_line_rec.delivery_lead_time;
7723 END IF;
7724
7725
7726 ------------------ ATO within PTO -------------------------------
7727 IF p_x_child_line_rec.ato_line_id is not NULL AND
7728 p_x_child_line_rec.line_id <> p_x_child_line_rec.ato_line_id AND
7729 p_x_child_line_rec.top_model_line_id <> p_x_child_line_rec.ato_line_id
7730 THEN
7731
7732 IF l_debug_level > 0 THEN
7733 oe_debug_pub.add('ATO IN PTO '||P_X_CHILD_LINE_REC.ATO_LINE_ID , 2 );
7734 END IF;
7735
7736 SELECT source_type_code, project_id, task_id,
7737 ship_from_org_id, ship_to_org_id,
7738 schedule_ship_date, schedule_arrival_date,
7739 request_date, shipping_method_code,
7740 freight_carrier_code, invoice_to_org_id,
7741 firm_demand_flag, override_atp_date_code,
7742 ship_to_contact_id,intmed_ship_to_org_id --bug 7041018,7175458
7743 INTO p_x_child_line_rec.source_type_code,
7744 p_x_child_line_rec.project_id,
7745 p_x_child_line_rec.task_id,
7746 p_x_child_line_rec.ship_from_org_id,
7747 p_x_child_line_rec.ship_to_org_id,
7748 p_x_child_line_rec.schedule_ship_date,
7749 p_x_child_line_rec.schedule_arrival_date,
7750 p_x_child_line_rec.request_date,
7751 p_x_child_line_rec.shipping_method_code,
7752 p_x_child_line_rec.freight_carrier_code,
7753 p_x_child_line_rec.invoice_to_org_id,
7754 p_x_child_line_rec.firm_demand_flag,
7755 p_x_child_line_rec.override_atp_date_code,
7756 p_x_child_line_rec.ship_to_contact_id, --bug7041018,7175458
7757 p_x_child_line_rec.intermed_ship_to_org_id --bug 7041018,7175458
7758 FROM oe_order_lines
7759 WHERE line_id = p_x_child_line_rec.ato_line_id;
7760
7761 IF l_debug_level > 0 THEN
7762 oe_debug_pub.add('2 **SOURCE TYPE ATO '
7763 || P_X_CHILD_LINE_REC.SOURCE_TYPE_CODE , 4 );
7764 END IF;
7765
7766 END IF;
7767
7768
7769 -------------------- any other conditions -------------------
7770 --IF
7771 -- put logic here
7772 --END IF;
7773
7774
7775 x_return_status := FND_API.G_RET_STS_SUCCESS;
7776 IF l_debug_level > 0 THEN
7777 oe_debug_pub.add('LEAVING DEFAULT_CHILD_LINE' , 1);
7778 END IF;
7779
7780 EXCEPTION
7781
7782 WHEN FND_API.G_EXC_ERROR THEN
7783 IF l_debug_level > 0 THEN
7784 oe_debug_pub.add('DEFAULT_CHILD_LINE, exc error '|| SQLERRM , 1);
7785 END IF;
7786 x_return_status := FND_API.G_RET_STS_ERROR;
7787
7788 WHEN OTHERS THEN
7789 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7790 IF l_debug_level > 0 THEN
7791 oe_debug_pub.add('others in DEFAULT_CHILD_LINE '|| SQLERRM , 1);
7792 END IF;
7793
7794 END Default_Child_Line;
7795
7796
7797 /*---------------------------------------------------------------------
7798 PROCEDURE: Is_Included_Item_Constrained
7799
7800 This API will check if the delete and update quantity operation
7801 performed on a Included item should be allowed or not.
7802 We will not allow any user delete/update quantity.
7803 We will allow system changes ex: cascading.
7804
7805 We have to write a pl/sql api because we want the system to be able to
7806 do the operations.
7807
7808 result of 1 means constrained.
7809
7810 Process_Included_Items procedure will set the security_check to
7811 false, before calling process_order.
7812
7813 --##1922440 bug fix.
7814 ----------------------------------------------------------------------*/
7815 PROCEDURE Is_Included_Item_Constrained
7816 ( p_application_id IN NUMBER,
7817 p_entity_short_name IN VARCHAR2,
7818 p_validation_entity_short_name IN VARCHAR2,
7819 p_validation_tmplt_short_name IN VARCHAR2,
7820 p_record_set_short_name IN VARCHAR2,
7821 p_scope IN VARCHAR2,
7822 x_result OUT NOCOPY /* file.sql.39 change */ NUMBER )
7823 IS
7824 l_item_type_code VARCHAR2(30);
7825 l_model_remnant_flag VARCHAR2(1);
7826 --
7827 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
7828 --
7829 BEGIN
7830
7831 IF l_debug_level > 0 THEN
7832 oe_debug_pub.add('ENTERING IS_INCLUDED_ITEM_CONSTRAINED' , 1);
7833 oe_debug_pub.add('OPERATION '|| OE_LINE_SECURITY.G_RECORD.OPERATION , 4 );
7834 oe_debug_pub.add('ITEM TYPE '||OE_LINE_SECURITY.G_RECORD.ITEM_TYPE_CODE,4);
7835 END IF;
7836
7837 SELECT item_type_code, model_remnant_flag
7838 INTO l_item_type_code, l_model_remnant_flag
7839 FROM oe_order_lines
7840 WHERE line_id = oe_line_security.g_record.line_id;
7841
7842 IF nvl(l_item_type_code, 'A') <> 'INCLUDED' THEN
7843 x_result := 0;
7844 RETURN;
7845 END IF;
7846
7847 IF OE_CONFIG_UTIL.CASCADE_CHANGES_FLAG = 'Y' OR
7848 OE_CONFIG_PVT.OECFG_VALIDATE_CONFIG = 'N' OR
7849 l_model_remnant_flag = 'Y'
7850 THEN
7851 x_result := 0;
7852 ELSE
7853 x_result := 1;
7854 END IF;
7855
7856 IF l_debug_level > 0 THEN
7857 oe_debug_pub.add('LEAVING IS_INCLUDED_ITEM_CONSTRAINED '|| X_RESULT , 1);
7858 END IF;
7859
7860 EXCEPTION
7861 WHEN OTHERS THEN
7862 IF l_debug_level > 0 THEN
7863 oe_debug_pub.add('IS_INCLUDED_ITEM_CONSTRAINED ERROR '|| SQLERRM , 1);
7864 END IF;
7865 RAISE;
7866 END Is_Included_Item_Constrained;
7867
7868
7869 /*--------------------------------------------------------
7870 PROCEDURE: Log_Included_Item_Requests
7871
7872 This procedure will be used to log delayed requests
7873 for included items. To improce performance of
7874 saving included items, we will set the
7875 control_rec.change_attributes parameter to FALSE.
7876 Hence all the delayed requests logged in
7877 oe_line_util.apply_attribute_changes procedure for
7878 included_items will be logged here.
7879 --------------------------------------------------------*/
7880 PROCEDURE Log_Included_Item_Requests
7881 ( p_line_tbl IN OE_Order_Pub.Line_Tbl_Type
7882 ,p_booked_flag IN VARCHAR2)
7883 IS
7884 I NUMBER;
7885 l_return_status VARCHAR2(1);
7886 --
7887 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
7888 --
7889 l_serviceable_item VARCHAR2(1); -- Added for bug 5925600
7890 l_serviced_model VARCHAR2(1); -- Added for bug 5925600
7891
7892 BEGIN
7893 IF l_debug_level > 0 THEN
7894 oe_debug_pub.add('ENTERING LOG_INCLUDED_ITEM_REQUESTS'
7895 || P_LINE_TBL.COUNT , 1);
7896 END IF;
7897
7898 I := p_line_tbl.FIRST;
7899 FOR I in p_line_tbl.FIRST..p_line_tbl.LAST
7900 LOOP
7901
7902 IF nvl(FND_PROFILE.VALUE('ONT_CHARGES_FOR_INCLUDED_ITEM'),'N') = 'Y'
7903 THEN
7904
7905 IF l_debug_level > 0 THEN
7906 oe_debug_pub.add('RENGA-LOGGING REQ TO CHARGES FOR INCLUDED ' , 3 );
7907 oe_debug_pub.add('RENGA-LINE OPERATION IS : '
7908 || P_LINE_TBL (I).OPERATION , 3 );
7909 END IF;
7910
7911 OE_LINE_ADJ_UTIL.Register_Changed_Lines
7912 (p_line_id => p_line_tbl(I).line_id,
7913 p_header_id => p_line_tbl(I).header_id,
7914 p_operation => p_line_tbl(I).operation );
7915
7916 IF l_debug_level > 0 THEN
7917 oe_debug_pub.add('RENGA-AFTER REGISTER_CHANGED_LINES Booked Flag=' || p_booked_flag , 3 );
7918 END IF;
7919
7920 --Added the if clause for bug 6892989/6903859
7921 IF ( nvl(p_booked_flag,'N') = 'Y' ) THEN
7922 OE_delayed_requests_Pvt.log_request
7923 (p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
7924 p_entity_id => p_line_tbl(I).header_id,
7925 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
7926 p_requesting_entity_id => p_line_tbl(I).header_id,
7927 p_request_unique_key1 => 'BATCH,BOOK',
7928 p_param1 => p_line_tbl(I).header_id,
7929 p_param2 => 'BATCH,BOOK',
7930 p_request_type => OE_GLOBALS.G_FREIGHT_FOR_INCLUDED,
7931 x_return_status => l_return_status);
7932 ELSE
7933 OE_delayed_requests_Pvt.log_request
7934 (p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
7935 p_entity_id => p_line_tbl(I).header_id,
7936 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_ALL,
7937 p_requesting_entity_id => p_line_tbl(I).header_id,
7938 p_request_unique_key1 => 'BATCH',
7939 p_param1 => p_line_tbl(I).header_id,
7940 p_param2 => 'BATCH',
7941 p_request_type => OE_GLOBALS.G_FREIGHT_FOR_INCLUDED,
7942 x_return_status => l_return_status);
7943 END IF;
7944
7945
7946 IF l_debug_level > 0 THEN
7947 oe_debug_pub.add
7948 ('RENGA-AFTER LOGGING DELAYED REQ FREIGHT_FOR_INCLUDED-2' , 3 );
7949 END IF;
7950
7951 END IF;
7952
7953 IF l_debug_level > 0 THEN
7954 oe_debug_pub.add('LOGGING REQ TO TAX_LINE ' , 3 );
7955 oe_debug_pub.add('REN: ITEM TYPE CODE IS: '
7956 || P_LINE_TBL (I).ITEM_TYPE_CODE , 1);
7957 END IF;
7958
7959 IF p_line_tbl(I).item_type_code not in ('INCLUDED', 'CONFIG') THEN
7960
7961 IF l_debug_level > 0 THEN
7962 oe_debug_pub.add('REN: ITEM TYPE CODE IS NOT INCLUDED OR CONFIG' , 1);
7963 END IF;
7964
7965 OE_delayed_requests_Pvt.log_request
7966 (p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
7967 p_entity_id => p_line_tbl(I).line_id,
7968 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
7969 p_requesting_entity_id => p_line_tbl(I).line_id,
7970 p_request_type => OE_GLOBALS.g_tax_line,
7971 x_return_status => l_return_status);
7972
7973 END IF;
7974
7975 IF OE_Commitment_Pvt.Do_Commitment_Sequencing AND
7976 p_line_tbl(I).commitment_id is not null
7977 THEN
7978 IF l_debug_level > 0 THEN
7979 oe_debug_pub.add('LOGGING REQ TO CALC COMMITMENT' , 3 );
7980 END IF;
7981
7982 OE_Delayed_Requests_Pvt.Log_Request
7983 (p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
7984 p_entity_id => p_line_tbl(I).line_id,
7985 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
7986 p_requesting_entity_id => p_line_tbl(I).line_id,
7987 p_request_type => OE_GLOBALS.G_CALCULATE_COMMITMENT,
7988 x_return_status => l_return_status);
7989 END IF;
7990
7991 IF p_booked_flag = 'Y' AND
7992 p_line_tbl(I).operation = 'UPDATE' THEN
7993
7994 IF l_debug_level > 0 THEN
7995 oe_debug_pub.add('LOGGING REQ TO VERIFY_PAYMENT' , 3 );
7996 END IF;
7997 OE_delayed_requests_Pvt.log_request
7998 (p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
7999 p_entity_id => p_line_tbl(I).header_id,
8000 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
8001 p_requesting_entity_id => p_line_tbl(I).line_id,
8002 p_request_type => OE_GLOBALS.G_VERIFY_PAYMENT,
8003 x_return_status => l_return_status);
8004
8005 END IF;
8006
8007 -- Log delayed request for Freight Rating.
8008 IF OE_Freight_Rating_Util.IS_FREIGHT_RATING_AVAILABLE
8009 AND OE_Freight_Rating_Util.Get_List_Line_Type_Code
8010 (p_line_tbl(I).header_id)
8011 = 'OM_CALLED_FREIGHT_RATES' THEN
8012 IF l_debug_level > 0 THEN
8013 oe_debug_pub.add
8014 ('LOGGING DELAYED REQUEST FOR FREIGHT RATE FOR INCLUDED ITEM: '
8015 ||P_LINE_TBL (I).HEADER_ID , 2 );
8016 END IF;
8017
8018 OE_delayed_requests_Pvt.log_request
8019 (p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
8020 p_entity_id => p_line_tbl(I).header_id,
8021 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
8022 p_requesting_entity_id => p_line_tbl(I).line_id,
8023 p_request_type => OE_GLOBALS.G_FREIGHT_RATING,
8024 p_param1 => 'Y',
8025 x_return_status => l_return_status);
8026 END IF;
8027
8028 /* Below code has been added for bug 5925600 */
8029 IF p_line_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE THEN
8030
8031 if l_debug_level > 0 then
8032 oe_debug_pub.add('Before checking if we need to log delayed request for G_CASCADE_OPTIONS_SERVICE', 5);
8033 oe_debug_pub.ADD('operation : '|| p_line_tbl(I).operation);
8034 oe_debug_pub.ADD('inventory_item_id : '|| p_line_tbl(I).inventory_item_id);
8035 end if;
8036
8037 BEGIN
8038 select 'Y'
8039 into l_serviceable_item
8040 from mtl_system_items mtl
8041 where mtl.inventory_item_id = p_line_tbl(I).inventory_item_id
8042 and mtl.organization_id = OE_SYS_PARAMETERS.VALUE('MASTER_ORGANIZATION_ID')
8043 and mtl.serviceable_product_flag='Y'
8044 and rownum = 1;
8045
8046 EXCEPTION
8047 WHEN OTHERS THEN
8048 l_serviceable_item := 'N';
8049 END;
8050
8051 if l_debug_level > 0 then
8052 oe_debug_pub.ADD('serviceable option : '|| l_serviceable_item);
8053 oe_debug_pub.ADD('service_reference_line_id: '|| p_line_tbl(I).top_model_line_id);
8054 end if;
8055
8056 IF l_serviceable_item = 'Y' THEN
8057
8058 BEGIN
8059 select 'Y'
8060 into l_serviced_model
8061 from oe_order_lines
8062 where item_type_code = 'SERVICE'
8063 and service_reference_line_id = p_line_tbl(I).top_model_line_id
8064 and service_reference_type_code = 'ORDER'
8065 and rownum = 1;
8066
8067 EXCEPTION
8068 WHEN OTHERS THEN
8069 l_serviced_model := 'N';
8070 END;
8071
8072 if l_debug_level > 0 then
8073 oe_debug_pub.ADD('serviced model : '|| l_serviced_model);
8074 end if;
8075
8076 IF l_serviced_model = 'Y' THEN
8077
8078 if l_debug_level > 0 then
8079 oe_debug_pub.add('Before log delayed request -- G_CASCADE_OPTIONS_SERVICE',1);
8080 end if;
8081
8082 OE_Delayed_Requests_Pvt.log_request
8083 (
8084 p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
8085 p_entity_id => p_line_tbl(I).line_id,
8086 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
8087 p_requesting_entity_id => p_line_tbl(I).line_id,
8088 p_request_type => OE_GLOBALS.G_CASCADE_OPTIONS_SERVICE,
8089 x_return_status => l_return_status
8090 );
8091
8092 END IF; /* l_serviced_model = 'Y' */
8093 END IF; /* l_serviceable_item = 'Y' */
8094 END IF; /* operation = CREATE */
8095 /* End of changes done for bug 5925600 */
8096
8097 END LOOP;
8098
8099 IF l_debug_level > 0 THEN
8100 oe_debug_pub.add('LEAVING LOG_INCLUDED_ITEM_REQUESTS' , 1);
8101 END IF;
8102 EXCEPTION
8103 WHEN OTHERS THEN
8104 IF l_debug_level > 0 THEN
8105 oe_debug_pub.add('LOG_INCLUDED_ITEM_REQUESTS '|| SQLERRM , 1);
8106 END IF;
8107 RAISE;
8108 END;
8109
8110
8111 /*--------------------------------------------------------
8112 PROCEDURE ATO_Remnant_Check
8113 Constraint API to not let some changes to remnant
8114 ATOs.
8115 --------------------------------------------------------*/
8116
8117 PROCEDURE ATO_Remnant_Check
8118 ( p_application_id IN NUMBER,
8119 p_entity_short_name IN VARCHAR2,
8120 p_validation_entity_short_name IN VARCHAR2,
8121 p_validation_tmplt_short_name IN VARCHAR2,
8122 p_record_set_short_name IN VARCHAR2,
8123 p_scope IN VARCHAR2,
8124 x_result OUT NOCOPY /* file.sql.39 change */ NUMBER )
8125 IS
8126 --
8127 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
8128 --
8129 BEGIN
8130
8131 x_result := 0;
8132
8133 IF nvl(oe_line_security.g_record.model_remnant_flag, 'N') = 'N' THEN
8134 RETURN;
8135 END IF;
8136
8137 IF oe_line_security.g_record.ato_line_id is NULL THEN
8138 RETURN;
8139 END IF;
8140
8141 --IF oe_line_security.g_record.item_type_code = 'STANDARD' OR
8142 -- (oe_line_security.g_record.item_type_code = 'OPTION' AND
8143 --Begin Bug fix for bug#6153528
8144 IF oe_line_security.g_record.item_type_code IN ( 'STANDARD', 'OPTION', 'CONFIG', 'CLASS' ) OR
8145 (oe_line_security.g_record.item_type_code in ( 'OPTION', 'CLASS' ) AND
8146 --End Bug fix for bug#6153528
8147 oe_line_security.g_record.line_id =
8148 oe_line_security.g_record.ato_line_id) THEN
8149 RETURN;
8150 END IF;
8151
8152 IF l_debug_level > 0 THEN
8153 oe_debug_pub.add('REMNANT ATO CHECK CONSTRAINED' , 3 );
8154 END IF;
8155
8156 x_result := 1;
8157
8158 EXCEPTION
8159 WHEN OTHERS THEN
8160 IF l_debug_level > 0 THEN
8161 oe_debug_pub.add('ATO_REMNANT_CHECK ERROR '|| SQLERRM , 1);
8162 END IF;
8163 RAISE;
8164 END ATO_Remnant_Check;
8165
8166 /*--------------------------------------------------------
8167 PROCEDURE Launch_Supply_Workbench
8168
8169 This procedure is used to perform some checks on line/
8170 header before launching the supply to order wb.
8171 It also derives a wb item type and sends it as out NOCOPY param.
8172 This functionality is only available from pack I onwards.
8173
8174 p_header_id is populated when the action is performed
8175 from header block and not when call is made from line block.
8176 rest of the params are populated when it is performed from
8177 line block.
8178
8179 This action is only UI action not for batch call.
8180
8181 This API will be called only if the order is booked.
8182 --------------------------------------------------------*/
8183 PROCEDURE Launch_Supply_Workbench
8184 ( p_header_id IN NUMBER
8185 ,p_top_model_line_id IN NUMBER
8186 ,p_ato_line_id IN NUMBER
8187 ,p_line_id IN NUMBER
8188 ,p_item_type_code IN VARCHAR2
8189 ,x_wb_item_type OUT NOCOPY /* file.sql.39 change */ VARCHAR2
8190 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
8191 IS
8192 l_count NUMBER;
8193 --
8194 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
8195 --
8196 BEGIN
8197
8198 Print_Time('entering Launch_Supply_Workbench');
8199
8200 IF l_debug_level > 0 THEN
8201 oe_debug_pub.add('-'|| P_HEADER_ID || '-' || P_TOP_MODEL_LINE_ID
8202 || '-' || P_ATO_LINE_ID || '-' || P_LINE_ID
8203 || '-' || P_ITEM_TYPE_CODE , 3 );
8204 END IF;
8205
8206 IF p_header_id is not NULL AND
8207 p_line_id is not NULL THEN
8208 IF l_debug_level > 0 THEN
8209 oe_debug_pub.add('WRONG PARAMTERS' , 1);
8210 END IF;
8211 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8212 END IF;
8213
8214 x_return_status := FND_API.G_RET_STS_SUCCESS;
8215 x_wb_item_type := null;
8216
8217 SELECT count(*)
8218 INTO l_count
8219 FROM oe_order_lines
8220 WHERE line_category_code <> 'RETURN'
8221 -- the condition below is commented for bug 3441504
8222 -- AND booked_flag = 'Y'
8223 AND (header_id = p_header_id OR
8224 (top_model_line_id = p_top_model_line_id AND
8225 p_line_id = p_top_model_line_id) OR
8226 (ato_line_id = p_ato_line_id AND
8227 top_model_line_id = p_top_model_line_id AND
8228 p_line_id = p_ato_line_id AND
8229 p_item_type_code in ('MODEL', 'CLASS')) OR
8230 line_id = p_line_id)
8231 AND ((source_type_code = 'EXTERNAL' AND
8232 shippable_flag = 'Y') OR
8233 (ato_line_id = line_id AND
8234 item_type_code in ('STANDARD', 'OPTION')) OR
8235 item_type_code = 'CONFIG')
8236 AND OPEN_FLAG = 'Y';
8237
8238
8239 IF l_count > 0 THEN
8240 IF l_debug_level > 0 THEN
8241 oe_debug_pub.add('ELIGIBLE LINES EXIST '|| L_COUNT , 1);
8242 END IF;
8243 ELSE
8244 IF l_debug_level > 0 THEN
8245 oe_debug_pub.add('NO ELIGIBLE LINES ' , 1);
8246 END IF;
8247 x_return_status := FND_API.G_RET_STS_ERROR;
8248 RETURN;
8249 END IF;
8250
8251 IF p_header_id is not null AND
8252 p_line_id is null THEN
8253
8254 IF l_debug_level > 0 THEN
8255 oe_debug_pub.add('WB ITEM TYPE IS HEADER '|| P_HEADER_ID , 3 );
8256 END IF;
8257 x_wb_item_type := 'HEAD';
8258
8259 ElSIF p_top_model_line_id is not null AND
8260 p_ato_line_id is null AND
8261 p_item_type_code = 'MODEL' THEN
8262
8263 IF l_debug_level > 0 THEN
8264 oe_debug_pub.add('WB ITEM TYPE IS PTO MODEL '
8265 || P_TOP_MODEL_LINE_ID , 3 );
8266 END IF;
8267 x_wb_item_type := 'PTO';
8268
8269 ElSIF p_ato_line_id = p_line_id AND
8270 (p_item_type_code = 'MODEL' OR
8271 p_item_type_code = 'CLASS') THEN
8272
8273 IF l_debug_level > 0 THEN
8274 oe_debug_pub.add('WB ITEM TYPE IS ATO MODEL ' || P_ATO_LINE_ID , 3 );
8275 END IF;
8276 x_wb_item_type := 'MDL';
8277
8278 ELSE
8279
8280 IF p_ato_line_id = p_line_id AND
8281 (p_item_type_code = 'STANDARD' OR
8282 p_item_type_code = 'OPTION') THEN
8283
8284 IF l_debug_level > 0 THEN
8285 oe_debug_pub.add('WB ITEM TYPE IS ATO ITEM ' || P_LINE_ID , 3 );
8286 END IF;
8287 x_wb_item_type := 'ATO';
8288
8289 ELSIF p_item_type_code = 'CONFIG' THEN
8290 IF l_debug_level > 0 THEN
8291 oe_debug_pub.add('WB ITEM TYPE IS CONFIG ITEM ' || P_LINE_ID , 3 );
8292 END IF;
8293 x_wb_item_type := 'CFG';
8294
8295 ELSE
8296 IF l_debug_level > 0 THEN
8297 oe_debug_pub.add('WB ITEM TYPE IS STD DROPSHIP ITEM '
8298 || P_LINE_ID , 3 );
8299 END IF;
8300 x_wb_item_type := 'STD';
8301 END IF;
8302
8303 END IF; -- if l_count > 0
8304
8305 Print_Time('leaving Launch_Supply_Workbench '|| x_wb_item_type);
8306
8307 EXCEPTION
8308 WHEN OTHERS THEN
8309 IF l_debug_level > 0 THEN
8310 oe_debug_pub.add('ERROR IN LAUNCH_SUPPLY_WORKBENCH'|| SQLERRM , 1);
8311 END IF;
8312 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8313 END Launch_Supply_Workbench;
8314
8315 /* -----------------------------------------------------------
8316 PROCEDURE Message_From_Cz
8317 Called to copy the messages from the CZ schema to
8318 the OM tables
8319 --------------------------------------------------------------*/
8320
8321 PROCEDURE Message_From_Cz
8322 ( p_line_id IN NUMBER,
8323 p_valid_config IN VARCHAR2,
8324 p_complete_config IN VARCHAR2,
8325 p_config_header_id IN NUMBER,
8326 p_config_rev_nbr IN NUMBER )
8327 IS
8328
8329 l_config_header_id NUMBER := p_config_header_id;
8330 l_config_rev_nbr NUMBER := p_config_rev_nbr;
8331 l_message_text VARCHAR2(2000);
8332 l_msg VARCHAR2(2000);
8333 l_constraint VARCHAR2(16);
8334
8335 CURSOR messages(p_config_hdr_id NUMBER, p_config_rev_nbr NUMBER) is
8336 SELECT constraint_type , message
8337 FROM cz_config_messages
8338 WHERE config_hdr_id = p_config_hdr_id
8339 AND config_rev_nbr = p_config_rev_nbr;
8340
8341
8342 BEGIN
8343 oe_debug_pub.add(' Entering Message_From_Cz');
8344
8345 OPEN messages(l_config_header_id, l_config_rev_nbr);
8346
8347 LOOP
8348 FETCH messages into l_constraint,l_msg;
8349 EXIT when messages%notfound;
8350
8351 OE_Msg_Pub.Add_Text(l_msg);
8352 oe_debug_pub.add('msg from spc: '||messages%rowcount , 2);
8353 oe_debug_pub.add('msg from spc: '|| substr(l_msg, 1, 250) , 3);
8354
8355 END LOOP;
8356
8357 IF nvl(p_valid_config, 'FALSE') = 'FALSE' THEN
8358
8359 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_VALIDATION_FAILURE');
8360 OE_Msg_Pub.Add;
8361 END IF;
8362
8363 IF nvl(p_complete_config, 'FALSE') = 'FALSE' THEN
8364
8365 BEGIN
8366
8367 SELECT nvl(ordered_item,inventory_item_id )
8368 INTO l_message_text
8369 FROM oe_order_lines
8370 WHERE line_id = p_line_id;
8371
8372 EXCEPTION
8373 WHEN OTHERS THEN
8374 null;
8375 END;
8376
8377 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_INCOMPLETE_MODEL');
8378 FND_MESSAGE.SET_TOKEN('MODEL',l_message_text);
8379 OE_Msg_Pub.Add;
8380
8381 END IF;
8382
8383 EXCEPTION
8384 WHEN OTHERS THEN
8385 OE_Debug_Pub.Add('Error in Message_From_Cz '|| sqlerrm, 2);
8386 END Message_From_Cz;
8387
8388 /*--------------------------------------------------------
8389 PROCEDURE Get_Config_Effective_Date
8390
8391 one of the i/p params p_model_line_rec or p_model_line_id
8392 should have a valid value - from caller.
8393
8394 callers:
8395 cz ui call and batch val.
8396 process order
8397 options window ui and batch val.
8398
8399 profile value,
8400 1 - old behavior
8401 2 - creation date of model
8402 3 - sysdate till booking.
8403 4 - sysdate till pick release -- #6187663
8404 --------------------------------------------------------*/
8405 PROCEDURE Get_Config_Effective_Date
8406 ( p_model_line_rec IN OE_Order_Pub.Line_Rec_Type := null
8407 ,p_model_line_id IN NUMBER := null
8408 ,x_old_behavior OUT NOCOPY VARCHAR2
8409 ,x_config_effective_date OUT NOCOPY DATE
8410 ,x_frozen_model_bill OUT NOCOPY VARCHAR2)
8411 IS
8412
8413 l_header_id NUMBER;
8414 l_creation_date DATE;
8415 l_profile VARCHAR2(1);
8416 l_line_set_id NUMBER;
8417 l_split_from_line_id NUMBER;
8418 --
8419 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
8420 --
8421 BEGIN
8422
8423 IF l_debug_level > 0 THEN
8424 OE_Debug_Pub.Add
8425 ('entering Get_Config_Effective_Date '|| p_model_line_id, 3);
8426 END IF;
8427
8428 IF p_model_line_rec.header_id is not NULL THEN
8429
8430 l_header_id := p_model_line_rec.header_id;
8431
8432 OE_Debug_Pub.Add('model header id '|| p_model_line_rec.header_id, 3);
8433 OE_Debug_Pub.Add('split id '|| p_model_line_rec.split_from_line_id, 3);
8434 OE_Debug_Pub.Add('line id '|| p_model_line_rec.line_id, 3);
8435
8436 IF p_model_line_rec.split_from_line_id is NOT NULL THEN
8437
8438 SELECT creation_date
8439 INTO l_creation_date
8440 FROM oe_order_lines
8441 WHERE header_id = l_header_id
8442 AND line_set_id = p_model_line_rec.line_set_id
8443 AND split_from_line_id is NULL;
8444
8445 IF l_debug_level > 0 THEN
8446 OE_Debug_Pub.Add
8447 ('split '||p_model_line_rec.split_from_line_id||l_creation_date,3);
8448 END IF;
8449
8450 ELSE
8451
8452 IF p_model_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
8453
8454 l_creation_date := sysdate;
8455 IF l_debug_level > 0 THEN
8456 OE_Debug_Pub.Add('model is getting created today', 3);
8457 END IF;
8458
8459 ELSE
8460 l_creation_date := p_model_line_rec.creation_date;
8461 END IF;
8462
8463 END IF; -- split model or not
8464
8465 ELSIF p_model_line_id is not NULL THEN
8466
8467 IF l_debug_level > 0 THEN
8468 OE_Debug_Pub.Add('using model line id '|| p_model_line_id, 3);
8469 END IF;
8470
8471 SELECT header_id, creation_date,
8472 line_set_id, split_from_line_id
8473 INTO l_header_id, l_creation_date,
8474 l_line_set_id, l_split_from_line_id
8475 FROM oe_order_lines
8476 WHERE line_id = p_model_line_id;
8477
8478 IF l_split_from_line_id is NOT NULL THEN
8479
8480 SELECT creation_date
8481 INTO l_creation_date
8482 FROM oe_order_lines
8483 WHERE header_id = l_header_id
8484 AND line_set_id = l_line_set_id
8485 AND split_from_line_id is NULL;
8486
8487 IF l_debug_level > 0 THEN
8488 OE_Debug_Pub.Add
8489 ('split case '|| l_split_from_line_id || l_creation_date, 3);
8490 END IF;
8491 END IF;
8492
8493 ELSE
8494
8495 IF l_debug_level > 0 THEN
8496 OE_Debug_Pub.Add('something wrong in i/p'|| p_model_line_id, 3);
8497 END IF;
8498
8499 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8500
8501 END IF; -- if model rec was sent in
8502
8503
8504 IF OE_CODE_CONTROL.get_code_release_level >= '110510' THEN
8505
8506 l_profile := nvl(OE_Sys_Parameters.VALUE('ONT_CONFIG_EFFECTIVITY_DATE'),
8507 '1');
8508
8509 IF l_debug_level > 0 THEN
8510 oe_debug_pub.add('pack J code '||l_profile, 1);
8511 END IF;
8512
8513 ELSE
8514
8515 l_profile := nvl(FND_PROFILE.Value('ONT_CONFIG_EFFECTIVITY_DATE'), '1');
8516
8517 IF l_profile > 1 THEN
8518
8519 IF OE_Process_Options_Pvt.Use_Configurator THEN
8520 IF l_debug_level > 0 THEN
8521 oe_debug_pub.add('USE CONFIGURATOR, ct fix' , 1);
8522 END IF;
8523 ELSE
8524 l_profile := 1;
8525
8526 END IF;
8527
8528 END IF;
8529 END IF; -- decide l_profile value
8530
8531
8532 IF l_profile = '1' THEN
8533 x_old_behavior := 'Y';
8534 x_config_effective_date := l_creation_date;
8535 x_frozen_model_bill := 'Y';
8536
8537 ELSIF l_profile = '2' THEN
8538 x_old_behavior := 'N';
8539 x_config_effective_date := l_creation_date;
8540 x_frozen_model_bill := 'Y';
8541
8542 IF l_debug_level > 0 THEN
8543 OE_Debug_Pub.Add('creation date is effective date', 3);
8544 END IF;
8545
8546 ELSIF l_profile = '3' THEN
8547
8548 x_old_behavior := 'N';
8549
8550 SELECT nvl(booked_flag, 'N'), booked_date
8551 INTO x_frozen_model_bill, x_config_effective_date
8552 FROM oe_order_headers
8553 WHERE header_id = l_header_id;
8554
8555 IF l_debug_level > 0 THEN
8556 OE_Debug_Pub.Add('booked, frozen: ' || x_frozen_model_bill, 3);
8557 END IF;
8558
8559 IF x_frozen_model_bill = 'Y' THEN
8560 IF l_creation_date > x_config_effective_date THEN --bug5969409
8561 x_config_effective_date := l_creation_date;
8562 ELSE
8563 l_header_id := sysdate - x_config_effective_date;
8564
8565 IF l_header_id < 0.007 THEN -- some 10 min right now***
8566 IF l_debug_level > 0 THEN
8567 OE_Debug_Pub.Add('not frozen, as booked now? '||l_header_id , 3);
8568 END IF;
8569 x_frozen_model_bill := 'N';
8570 END IF;
8571 END IF;
8572 ELSE
8573
8574 IF l_debug_level > 0 THEN
8575 OE_Debug_Pub.Add('not frozen, not booked', 3);
8576 END IF;
8577 x_config_effective_date := sysdate;
8578 END IF;
8579 -- Added for ER#6187663 Start
8580 ELSIF l_profile = '4' THEN --ER#6187663: for OM:Configuration Effective Date='System Date till Pick Release'
8581 x_old_behavior := 'N';
8582 x_config_effective_date := sysdate;
8583 /* x_frozen_model_bill='Y' if SO Booked eles N*/
8584 SELECT nvl(booked_flag, 'N') INTO x_frozen_model_bill
8585 FROM oe_order_headers
8586 WHERE header_id = l_header_id;
8587
8588 -- Added for ER#6187663 Start
8589
8590 ELSE
8591 IF l_debug_level > 0 THEN
8592 OE_Debug_Pub.Add('something wrong???', 3);
8593 END IF;
8594 END IF;
8595
8596 IF l_debug_level > 0 THEN
8597 OE_Debug_Pub.Add
8598 ('leaving Get_Config_Effective_Date '||
8599 to_char(x_config_effective_date, 'DD-MON-YY HH24:MI:SS'), 3);
8600 OE_Debug_Pub.Add('sysdate '||to_char(sysdate, 'DD-MON-YY HH24:MI:SS'),3);
8601 OE_Debug_Pub.Add(x_frozen_model_bill || '-'|| x_old_behavior, 3);
8602 END IF;
8603
8604 EXCEPTION
8605 WHEN OTHERS THEN
8606 IF l_debug_level > 0 THEN
8607 OE_Debug_Pub.Add('Get_Config_Effective_Date '|| sqlerrm, 1);
8608 END IF;
8609
8610 x_config_effective_date := null;
8611 x_frozen_model_bill := null;
8612 x_old_behavior := null;
8613
8614 RAISE;
8615
8616 END Get_Config_Effective_Date;
8617
8618
8619 /*--------------------------------------------------------
8620 PROCEDURE Print_Time
8621
8622 --------------------------------------------------------*/
8623
8624 PROCEDURE Print_Time(p_msg IN VARCHAR2)
8625 IS
8626 l_time VARCHAR2(100);
8627 --
8628 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
8629 --
8630 BEGIN
8631 l_time := to_char (new_time (sysdate, 'PST', 'EST'),
8632 'DD-MON-YY HH24:MI:SS');
8633 IF l_debug_level > 0 THEN
8634 oe_debug_pub.add(P_MSG || ': '|| L_TIME , 1);
8635 END IF;
8636 END Print_Time;
8637
8638 /*--------------------------------------------------------
8639 PROCEDURE Unlock_Config
8640
8641 This API will be called before deleting or cacelling booked macd model.
8642 --------------------------------------------------------*/
8643
8644 PROCEDURE Unlock_Config(p_line_rec IN OE_ORDER_PUB.line_rec_type,
8645 x_return_status OUT NOCOPY VARCHAR2 )
8646 IS
8647
8648 l_top_container VARCHAR2(1);
8649 l_part_of_container VARCHAR2(1);
8650 l_locking_key NUMBER;
8651 l_msg_count NUMBER;
8652 l_msg_data VARCHAR2(4000);
8653 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
8654 l_order_number NUMBER;
8655
8656 --
8657 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
8658 --
8659 BEGIN
8660
8661 IF l_debug_level > 0 THEN
8662 oe_debug_pub.add('ENTERING OE_CONFIG_UTIL.Unlock_Config' , 1);
8663 END IF;
8664
8665
8666 OE_CONFIG_TSO_PVT.Is_Part_Of_Container_Model
8667 ( p_line_id => p_line_rec.line_id
8668 ,p_top_model_line_id => p_line_rec.line_id
8669 ,x_top_container_model => l_top_container
8670 ,x_part_of_container => l_part_of_container );
8671 IF l_top_container = 'Y' THEN
8672
8673 l_order_number := OE_SCHEDULE_UTIL.get_order_number(p_line_rec.header_id);
8674
8675 IF l_debug_level > 0 THEN
8676
8677 oe_debug_pub.add(' Calling Unlock_Config' || p_line_rec.config_header_id, 2);
8678 oe_debug_pub.add(' Config rev nbr' || p_line_rec.config_rev_nbr, 2);
8679 oe_debug_pub.add(' Configuration_id ' || p_line_rec.configuration_id, 2);
8680 oe_debug_pub.add(' order_number ' || l_order_number, 2);
8681
8682 END IF;
8683
8684 CZ_IB_LOCKING.Unlock_Config
8685 ( p_api_version => 1.0,
8686 p_config_session_hdr_id => p_line_rec.config_header_id,
8687 p_config_session_rev_nbr => p_line_rec.config_rev_nbr,
8688 p_config_session_item_id => null,
8689 p_source_application_id => fnd_profile.value('RESP_APPL_ID'),
8690 p_source_header_ref => l_order_number,
8691 p_source_line_ref1 => Null,
8692 p_source_line_ref2 => Null,
8693 p_source_line_ref3 => Null,
8694 p_commit => 'N',
8695 p_init_msg_list => FND_API.G_TRUE,
8696 p_validation_level => Null,
8697 p_locking_key => Null,
8698 x_return_status => x_return_status,
8699 x_msg_count => l_msg_count,
8700 x_msg_data => l_msg_data);
8701
8702 IF l_debug_level > 0 THEN
8703
8704 oe_debug_pub.add(' After calling CZ Unlock_Config ' || x_return_status,2);
8705 END IF;
8706
8707 IF l_msg_count > 0 THEN
8708
8709 OE_MSG_PUB.Transfer_Msg_Stack;
8710
8711 END IF;
8712
8713
8714 END IF;
8715
8716 IF l_debug_level > 0 THEN
8717 oe_debug_pub.add('Exiting OE_CONFIG_UTIL.Unlock_Config' || x_return_status, 1);
8718 END IF;
8719
8720 EXCEPTION
8721
8722 WHEN OTHERS THEN
8723 IF l_debug_level > 0 THEN
8724 oe_debug_pub.add('ERROR IN OE_CONFIG_UTIL.Unlock_Config'|| SQLERRM , 1);
8725 END IF;
8726 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8727 END Unlock_Config;
8728
8729
8730 END OE_CONFIG_UTIL;