1 PACKAGE BODY OE_GROUP_SCH_UTIL AS
2 /* $Header: OEXUGRPB.pls 120.33.12020000.3 2013/01/07 09:35:07 sujithku ship $ */
3
4 G_PKG_NAME CONSTANT VARCHAR2(30):='OE_GROUP_SCH_UTIL';
5 G_TOP_MODEL_LINE_ID NUMBER;
6 G_PART_OF_SET BOOLEAN;
7 G_BINARY_LIMIT CONSTANT NUMBER := OE_GLOBALS.G_BINARY_LIMIT; -- Added for bug 8636027
8
9 /*---------------------------------------------------------------------
10 Procedure Name : Validate_Item_Warehouse
11 Description : This API will be called to check valid Item and warehouse
12 combinition
13 --------------------------------------------------------------------- */
14 Procedure Validate_Item_Warehouse
15 (p_inventory_item_id IN NUMBER,
16 p_ship_from_org_id IN NUMBER,
17 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
18 IS
19 l_validate_combinition NUMBER;
20 --
21 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
22 --
23 BEGIN
24 IF l_debug_level > 0 THEN
25 oe_debug_pub.add( 'ENTERING OE_GROUP_SCH_UTIL.VALIDATE_ITEM_WAREHOUSE' , 2 ) ;
26 END IF;
27 -- bug 3594016
28 IF (p_inventory_item_id is NOT NULL
29 AND p_ship_from_org_id is NOT NULL)
30 THEN
31 SELECT 1
32 INTO l_validate_combinition
33 FROM mtl_system_items_b msi,
34 org_organization_definitions org
35 WHERE msi.inventory_item_id= p_inventory_item_id
36 AND org.organization_id=msi.organization_id
37 AND sysdate<=nvl(org.disable_date,sysdate)
38 AND org.organization_id=p_ship_from_org_id
39 AND rownum=1 ;
40 END IF;
41
42 x_return_status := FND_API.G_RET_STS_SUCCESS;
43 EXCEPTION
44 WHEN NO_DATA_FOUND THEN
45 IF l_debug_level > 0 THEN
46 oe_debug_pub.add('INVALID ITEM WAREHOUSE COMBINATION',3);
47 END IF;
48 FND_MESSAGE.SET_NAME('ONT','OE_INVALID_ITEM_WHSE');
49 OE_MSG_PUB.Add;
50 x_return_status := FND_API.G_RET_STS_ERROR;
51 END Validate_Item_Warehouse;
52
53 /*---------------------------------------------------------------------
54 Procedure Name : Validate_group_Line
55 Description : Validates a line before scheduling.
56 This API will be called only when line is getting
57 scheduled or reserved.
58 IF the profile OM:Schedule Line on Hold is set to 'Y'
59 we will perform scheduling on lines on hold. If it is
60 set to 'N', we will not perform scheduling.
61 --------------------------------------------------------------------- */
62 Procedure Validate_Group_Line
63 (p_line_rec IN OE_ORDER_PUB.Line_Rec_Type,
64 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
65 IS
66 l_msg_count NUMBER;
67 l_msg_data VARCHAR2(2000);
68 l_result VARCHAR2(30);
69 l_scheduling_level_code VARCHAR2(30) := NULL;
70 --
71 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
72 --
73 BEGIN
74
75 x_return_status := FND_API.G_RET_STS_SUCCESS;
76 IF l_debug_level > 0 THEN
77 oe_debug_pub.add( '..ENTERING OE_SCHEDULE_UTIL.VALIDATE_GROUP_LINE' , 6 ) ;
78 END IF;
79
80 -- If the line is shipped, scheduling is not allowed.
81
82 IF p_line_rec.shipped_quantity is not null AND
83 p_line_rec.shipped_quantity <> FND_API.G_MISS_NUM THEN
84
85 -- The line is cancelled. Cannot perform scheduling
86 -- on it.
87
88 FND_MESSAGE.SET_NAME('ONT','OE_SCH_LINE_SHIPPED');
89 OE_MSG_PUB.Add;
90
91 IF l_debug_level > 0 THEN
92 oe_debug_pub.add( ' SHIPPED LINE.' , 4 ) ;
93 END IF;
94 x_return_status := FND_API.G_RET_STS_ERROR;
95 RETURN;
96
97 END IF;
98
99 IF p_line_rec.schedule_status_code is NULL THEN
100
101 -- If the request_date on the line is missing or null and
102 -- if the user is trying to performing scheduling,
103 -- it is an error
104
105 IF l_debug_level > 0 THEN
106 oe_debug_pub.add( 'CHECKING THE REQUEST DATE....' , 1 ) ;
107 END IF;
108 IF (p_line_rec.request_date is null OR
109 p_line_rec.request_date = FND_API.G_MISS_DATE) THEN
110
111 FND_MESSAGE.SET_NAME('ONT','OE_SCH_MISSING_REQUEST_DATE');
112 OE_MSG_PUB.Add;
113 IF l_debug_level > 0 THEN
114 oe_debug_pub.add( 'REQUEST DATE IS MISSING' , 4 ) ;
115 END IF;
116 x_return_status := FND_API.G_RET_STS_ERROR;
117 RETURN;
118 END IF;
119
120 IF l_debug_level > 0 THEN
121 oe_debug_pub.add( 'CHECKING FOR HOLDS....' , 1 ) ;
122 END IF;
123 -- Call will be made to validate_group_line only when
124 -- line is getting scheduled due to action OESCH_ACT_SCHEDULE
125 -- or OESCH_ACT_RESERVE.
126
127 -- IF FND_PROFILE.VALUE('ONT_SCHEDULE_LINE_ON_HOLD') = 'N'
128 IF oe_sys_parameters.value ('ONT_SCHEDULE_LINE_ON_HOLD') = 'N' --moac
129 THEN
130 -- Since the profile is set to NO, we should not schedule
131 -- the line if the line is on hold.
132
133 IF l_debug_level > 0 THEN
134 oe_debug_pub.add( 'CALLING CHECK HOLDS' , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
135 END IF;
136
137 OE_Holds_PUB.Check_Holds
138 ( p_api_version => 1.0
139 , p_init_msg_list => FND_API.G_FALSE
140 , p_commit => FND_API.G_FALSE
141 , p_validation_level => FND_API.G_VALID_LEVEL_FULL
142 , x_return_status => x_return_status
143 , x_msg_count => l_msg_count
144 , x_msg_data => l_msg_data
145 , p_line_id => p_line_rec.line_id
146 , p_hold_id => NULL
147 , p_entity_code => NULL
148 , p_entity_id => NULL
149 , x_result_out => l_result);
150
151 IF l_debug_level > 0 THEN
152 oe_debug_pub.add( 'AFTER CALLING CHECK HOLDS: ' || X_RETURN_STATUS , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
153 END IF;
154
155
156 IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
157 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
158 RAISE FND_API.G_EXC_ERROR;
159 ELSE
160 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
161 END IF;
162 END IF;
163
164 IF (l_result = FND_API.G_TRUE) THEN
165 FND_MESSAGE.SET_NAME('ONT','OE_SCH_LINE_ON_HOLD');
166 OE_MSG_PUB.Add;
167 x_return_status := FND_API.G_RET_STS_ERROR;
168 IF l_debug_level > 0 THEN
169 oe_debug_pub.add( 'LINE IS ON HOLD' , 4 ) ;
170 END IF;
171 RETURN;
172 END IF;
173
174 END IF;
175 END IF;
176 -- Check to see what scheduling level is allowed to be performed
177 -- on this line. If the action requested is not allowed for the
178 -- scheduling action, error out.
179
180 IF l_debug_level > 0 THEN
181 oe_debug_pub.add( 'CHECKING SCHEDULING LEVEL...' , 1 ) ;
182 END IF;
183 l_scheduling_level_code :=
184 OE_SCHEDULE_UTIL.Get_Scheduling_Level(p_line_rec.header_id,
185 p_line_rec.line_type_id);
186
187 IF l_debug_level > 0 THEN
188 oe_debug_pub.add( 'L_SCHEDULING_LEVEL_CODE : ' || L_SCHEDULING_LEVEL_CODE , 1 ) ;
189 END IF;
190
191 IF l_scheduling_level_code is not null THEN
192 IF l_scheduling_level_code = OE_SCHEDULE_UTIL.SCH_LEVEL_ONE THEN
193
194 FND_MESSAGE.SET_NAME('ONT','OE_SCH_ACTION_NOT_ALLOWED');
195 FND_MESSAGE.SET_TOKEN('ACTION', p_line_rec.schedule_action_code);
196 FND_MESSAGE.SET_TOKEN('ORDER_TYPE',
197 nvl(OE_SCHEDULE_UTIL.sch_cached_line_type,
198 OE_SCHEDULE_UTIL.sch_cached_order_type));
199 OE_MSG_PUB.Add;
200 x_return_status := FND_API.G_RET_STS_ERROR;
201 IF l_debug_level > 0 THEN
202 oe_debug_pub.add( 'LINE TYPE IS ATP ONLY' , 4 ) ;
203 END IF;
204
205 ELSIF l_scheduling_level_code = OE_SCHEDULE_UTIL.SCH_LEVEL_TWO
206 AND p_line_rec.schedule_action_code =
207 OE_SCHEDULE_UTIL.OESCH_ACT_RESERVE
208 THEN
209
210 FND_MESSAGE.SET_NAME('ONT','OE_SCH_ACTION_NOT_ALLOWED');
211 FND_MESSAGE.SET_TOKEN('ACTION',
212 nvl(p_line_rec.schedule_action_code,
213 OE_SCHEDULE_UTIL.OESCH_ACT_RESERVE));
214 FND_MESSAGE.SET_TOKEN('ORDER_TYPE',
215 nvl(OE_SCHEDULE_UTIL.sch_cached_line_type,
216 OE_SCHEDULE_UTIL.sch_cached_order_type));
217 OE_MSG_PUB.Add;
218 x_return_status := FND_API.G_RET_STS_ERROR;
219 IF l_debug_level > 0 THEN
220 oe_debug_pub.add( 'LINE TYPE IS NOT ELIGIBLE FOR RESERVATION ' , 4 ) ;
221 END IF;
222
223 END IF;
224 END IF;
225
226 IF l_debug_level > 0 THEN
227 oe_debug_pub.add( '..EXITING OE_SCHEDULE_UTIL.VALIDATE_GROUP_LINE WITH ' || X_RETURN_STATUS , 1 ) ;
228 END IF;
229
230
231 EXCEPTION
232
233 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
234
235 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
236
237 WHEN OTHERS THEN
238
239 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
240 THEN
241 OE_MSG_PUB.Add_Exc_Msg
242 ( G_PKG_NAME
243 , 'Validate_Group_Line'
244 );
245 END IF;
246
247 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
248 END Validate_Group_Line;
249
250 /*---------------------------------------------------------------------
251 Procedure Name : Validate_Group
252 Description : Validate Group calls Validate Line and if the call is success
253 then and pass the record back to the caller. If it is a expected error, then ignore the record and if it is a unexpected error raise the error and stop the process.
254 --------------------------------------------------------------------- */
255 Procedure Validate_Group
256 (p_x_line_tbl IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type,
257 p_sch_action IN VARCHAR2,
258 p_validate_action IN VARCHAR2 DEFAULT 'PARTIAL', --for bug 3590437
259 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
260 IS
261 l_return_status VARCHAR2(30);
262 J NUMBER := 0;
263 l_line_tbl OE_ORDER_PUB.Line_Tbl_Type;
264 --
265 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
266 --
267 BEGIN
268 -- 3870895 : Revorted back the code modified for bug 3349770
269 IF l_debug_level > 0 THEN
270 oe_debug_pub.add( 'ENTERING VALIDATE GROUP' || P_X_LINE_TBL.COUNT , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
271 END IF;
272 x_return_status := FND_API.G_RET_STS_SUCCESS;
273 FOR I IN 1..p_x_line_tbl.count LOOP
274
275 OE_MSG_PUB.set_msg_context
276 ( p_entity_code => 'LINE'
277 ,p_entity_id => p_x_line_tbl(I).line_id
278 ,p_header_id => p_x_line_tbl(I).header_id
279 ,p_line_id => p_x_line_tbl(I).line_id
280 ,p_orig_sys_document_ref =>
281 p_x_line_tbl(I).orig_sys_document_ref
282 ,p_orig_sys_document_line_ref =>
283 p_x_line_tbl(I).orig_sys_line_ref
284 ,p_orig_sys_shipment_ref =>
285 p_x_line_tbl(I).orig_sys_shipment_ref
286 ,p_change_sequence => p_x_line_tbl(I).change_sequence
287 ,p_source_document_id =>
288 p_x_line_tbl(I).source_document_id
289 ,p_source_document_line_id =>
290 p_x_line_tbl(I).source_document_line_id
291 ,p_order_source_id =>
292 p_x_line_tbl(I).order_source_id
293 ,p_source_document_type_id =>
294 p_x_line_tbl(I).source_document_type_id);
295 --3564310
296 -- Checking for Warehouse Validation
297 Validate_Item_Warehouse
298 (p_inventory_item_id => p_x_line_tbl(I).inventory_item_id,
299 p_ship_from_org_id => p_x_line_tbl(I).ship_from_org_id,
300 x_return_status => l_return_status);
301 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
302 OE_SCHEDULE_UTIL.Validate_Line(p_line_rec => p_x_line_tbl(I),
303 p_old_line_rec => p_x_line_tbl(I),
304 p_sch_action => p_sch_action ,
305 x_return_status => l_return_status);
306
307 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
308
309 J := J + 1;
310 l_line_tbl(J) := p_x_line_tbl(I);
311
312 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
313
314 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
315 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
316 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN -- 3870895
317
318 x_return_status := FND_API.G_RET_STS_ERROR;
319 --5166476
320 IF OE_SCH_CONC_REQUESTS.g_conc_program = 'Y' THEN
321 IF p_x_line_tbl(I).ship_model_complete_flag = 'N' AND
322 p_x_line_tbl(I).top_model_line_id IS NOT NULL AND
323 (p_x_line_tbl(I).ato_line_id IS NULL OR
324 p_x_line_tbl(I).ato_line_id <> p_x_line_tbl(I).top_model_line_id) AND
325 p_x_line_tbl(I).item_type_code = OE_GLOBALS.G_ITEM_INCLUDED THEN
326 IF NOT OE_SCH_CONC_REQUESTS.included_processed(p_x_line_tbl(I).line_id) THEN
327 IF l_debug_level > 0 THEN
328 oe_debug_pub.add( 'INCLUDED PROCESSED : ' || p_x_line_tbl(I).line_id, 3 ) ;
329 END IF;
330 -- 5166476
331 OE_SCH_CONC_REQUESTS.OE_line_status_Tbl(p_x_line_tbl(I).line_id) := 'N';
332 END IF;
333 ELSE
334 --5166476
335 OE_SCH_CONC_REQUESTS.OE_line_status_Tbl(p_x_line_tbl(I).line_id) := 'N';
336 END IF;
337 END IF;
338 END IF;
339 ELSE -- 3564310
340 IF OE_SCH_CONC_REQUESTS.g_conc_program = 'Y' THEN
341 --5166476
342 OE_SCH_CONC_REQUESTS.OE_line_status_Tbl(p_x_line_tbl(I).line_id) := 'N';
343 END IF;
344 x_return_status := FND_API.G_RET_STS_ERROR;
345 END IF;
346
347 END LOOP;
348 IF x_return_status = FND_API.G_RET_STS_SUCCESS THEN -- 3870895
349 p_x_line_tbl := l_line_tbl;
350 --5166476
351 ELSIF x_return_status = FND_API.G_RET_STS_ERROR
352 AND l_line_tbl.count > 0 THEN
353 IF OE_SCH_CONC_REQUESTS.g_conc_program = 'Y' THEN
354 FOR I IN 1..l_line_tbl.count LOOP
355 OE_SCH_CONC_REQUESTS.OE_line_status_Tbl(l_line_tbl(I).line_id) := 'N';
356 END LOOP;
357 END IF;
358
359 END IF;
360 IF l_debug_level > 0 THEN
361 oe_debug_pub.add( 'EXITING VALIDATE GROUP' || P_X_LINE_TBL.COUNT , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
362 END IF;
363
364 EXCEPTION
365
366 WHEN OTHERS THEN
367 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
368 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
369 THEN
370 OE_MSG_PUB.Add_Exc_Msg
371 ( G_PKG_NAME
372 , 'Validate_Group');
373 END IF;
374
375 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
376
377 END Validate_Group;
378
379 Function Not_Part_of_set(p_top_model_line_id IN NUMBER)
380 RETURN BOOLEAN
381 IS
382 l_set_id NUMBER := Null;
383 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
384 BEGIN
385
386 IF l_debug_level > 0 THEN
387 oe_debug_pub.add( 'Entering Not_Part_of_set ' || p_top_model_line_id , 1 ) ;
388 oe_debug_pub.add( 'Value of the cached model ' || g_top_model_line_id,2);
389 END IF;
390 IF p_top_model_line_id = g_top_model_line_id
391 THEN
392 RETURN g_part_of_set;
393 Else
394
395 BEGIN
396
397 Select nvl(arrival_set_id,ship_set_id)
398 Into l_set_id
399 From oe_order_lines_all
400 Where line_id = p_top_model_line_id;
401
402 IF l_set_id is null THEN
403 g_part_of_set := TRUE;
404 ELSE
405 g_part_of_set := FALSE;
406 END IF;
407 g_top_model_line_id := p_top_model_line_id;
408 Return g_part_of_set;
409 EXCEPTION
410
411 WHEN OTHERS THEN
412 g_part_of_set := TRUE;
413 Return g_part_of_set;
414 END;
415
416 END IF;
417 END Not_Part_of_set;
418 /* ----------------------------------------------------------------
419 Procedure Check_Merge_Line:
420 This procedure checks if the Line Id that is going to be Merged
421 into the l_line_tbl is already existing in that plsql table.
422 If the Line_Id is not existing in the table it merges the Line_id
423 with the existing l_line_tbl plsql Table
424 Bug Number:2319608
425
426 Procedure Check_Merge_Line(
427 p_x_line_tbl IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type,
428 p_line_tbl IN OE_ORDER_PUB.Line_Tbl_Type
429 := OE_Order_PUB.G_MISS_LINE_TBL,
430 p_line_rec IN OE_ORDER_PUB.Line_rec_Type
431 := OE_Order_PUB.G_MISS_LINE_REC)
432 IS
433 J NUMBER;
434 l_option_exists VARCHAR2(1) := 'N';
435
436 BEGIN
437 IF l_debug_level > 0 THEN
438 oe_debug_pub.add('Entering Check_Merge_Line: ' || p_x_line_tbl.count,1);
439 oe_debug_pub.add('Size of the in table : ' || p_line_tbl.count,1);
440 END IF;
441 J := p_x_line_tbl.count;
442 IF p_line_rec.line_id is NOT NULL
443 AND p_line_rec.line_id <> FND_API.G_MISS_NUM THEN -- Main IF Start
444
445 FOR l_option_search in 1..J LOOP
446 IF p_line_rec.line_id = p_x_line_tbl(l_option_search).line_id THEN
447 IF l_debug_level > 0 THEN
448 OE_DEBUG_PUB.Add('Option already exists in the line table',1);
449 END IF;
450 l_option_exists := 'Y';
451 EXIT; -- Exit the Loop if a match is found
452 END IF;
453 END LOOP;
454
455 --If no matches are found then Merge the record.
456 IF l_option_exists = 'N' THEN
457 p_x_line_tbl(J+1) := p_line_rec;
458 END IF;
459
460 ELSE
461
462 FOR I in 1..p_line_tbl.count LOOP
463 l_option_exists := 'N';
464 FOR l_option_search in 1..p_x_line_tbl.count LOOP
465 IF p_line_tbl(I).line_id = p_x_line_tbl(l_option_search).line_id THEN
466 IF l_debug_level > 0 THEN
467 OE_DEBUG_PUB.Add('Option already exists in the line table',1);
468 END IF;
469 l_option_exists := 'Y';
470 EXIT; -- Exit the Inner Loop if a match is found
471 END IF;
472 END LOOP;
473
474 --If no matches are found then Merge the record.
475 IF l_option_exists = 'N' THEN
476 J := J + 1;
477 p_x_line_tbl(J) := p_line_tbl(I);
478 END IF;
479 END LOOP;
480
481 END IF; -- Main IF End
482 IF l_debug_level > 0 THEN
483 oe_debug_pub.add('Exiting Check_Merge_Line: ' || p_x_line_tbl.count,1);
484 END IF;
485
486 End Check_Merge_Line;
487 */
488
489 /*----------------------------------------------------------------
490 FUNCTION : Find_Line
491 Description : This Function returns TRUE if the line already
492 exist in the line table else FALSE
493 Added for Bug-2454163
494 ------------------------------------------------------------------*/
495
496 FUNCTION Find_line( p_x_line_tbl IN OE_ORDER_PUB.Line_Tbl_Type,
497 p_line_id IN NUMBER)
498 Return BOOLEAN
499 IS
500 --
501 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
502 --
503 BEGIN
504
505 IF l_debug_level > 0 THEN
506 oe_debug_pub.add( 'ENTERING FIND_LINE: ' || P_LINE_ID , 1 ) ;
507 END IF;
508
509 FOR J IN 1..p_x_line_tbl.count LOOP
510
511 IF p_line_id = p_x_line_tbl(J).line_id THEN
512
513 IF l_debug_level > 0 THEN
514 oe_debug_pub.add( ' LINE EXISTS IN THE TABLE' , 1 ) ;
515 END IF;
516
517 RETURN TRUE;
518 END IF;
519 END LOOP;
520
521 RETURN FALSE;
522
523 END Find_line;
524
525
526 /*----------------------------------------------------------------
527 PROCEDURE Query_Lines
528 Description:
529
530 This is a internal procedure. This procedure will be called when user
531 performs any scheduling action from header lever. Schedule Order API will
532 will call this procedure to query all valid lines for requested scheduling
533 operation.
534 This procedure will return all valid records to caller when action is
535 schedule/unschedule/atp check/unreserve. If the action is reserve and line is
536 scheduled, the line will not be passed to caller and it performs the reservati on action.
537
538 ---------------------------------------------------------------------*/
539 PROCEDURE Query_Lines
540 ( p_header_id IN NUMBER,
541 p_sch_action IN VARCHAR2,
542 x_line_tbl IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
543 )
544 IS
545 I NUMBER;
546 l_inc_tbl OE_Order_PUB.Line_Tbl_Type;
547 l_sales_order_id NUMBER := Null;
548 l_line_rec OE_Order_PUB.Line_Rec_type;
549 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
550 l_set_rec OE_ORDER_CACHE.set_rec_type;
551 l_quantity_to_reserve NUMBER;
552 l_quantity2_to_reserve NUMBER; -- INVCONV
553 l_rsv_update BOOLEAN := FALSE;
554
555 CURSOR Process_inc is
556 SELECT line_id
557 FROM oe_order_lines_all
558 WHERE header_id = p_header_id
559 AND open_flag = 'Y'
560 AND ato_line_id is NULL
561 AND item_type_code IN ('MODEL', 'CLASS', 'KIT')
562 AND schedule_status_code is NULL;
563
564
565 CURSOR l_line_csr IS
566 SELECT line_id,schedule_status_code,
567 shippable_flag
568 FROM oe_order_lines_all
569 WHERE header_id = p_header_id
570 AND open_flag = 'Y'
571 AND line_category_code <> 'RETURN'
572 AND item_type_code <> 'SERVICE'
573 AND NVL(subscription_enable_flag,'N') = 'N' --sol_ord_er #16014165
574 AND source_type_code <> OE_GLOBALS.G_SOURCE_EXTERNAL
575 ORDER BY arrival_set_id,ship_set_id,line_number,shipment_number,nvl(option_number,-1)
576 --added for bug 13537520
577 ,nvl(component_number,-1),nvl(service_number,-1);
578
579 CURSOR l_line_inc_csr IS
580 SELECT line_id,ship_set_id,arrival_set_id, shippable_flag,
581 shipping_interfaced_flag,orig_sys_document_ref, orig_sys_line_ref,
582 orig_sys_shipment_ref, change_sequence, source_document_type_id,
583 source_document_id, source_document_line_id, order_source_id
584 FROM oe_order_lines_all
585 WHERE header_id = p_header_id
586 AND open_flag = 'Y'
587 AND line_category_code <> 'RETURN'
588 AND schedule_status_code IS NOT NULL
589 ORDER BY arrival_set_id,ship_set_id,line_number,shipment_number,nvl(option_number,-1)
590 --added for bug 13537520
591 ,nvl(component_number,-1),nvl(service_number,-1);
592
593
594 --
595 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
596 --
597 BEGIN
598
599 IF l_debug_level > 0 THEN
600 oe_debug_pub.add( 'ENTERING QUERY LINES' , 1 ) ;
601 END IF;
602
603 -- Process Included Items if the action is schedule, atp_check
604 -- and reserve.
605
606 IF p_sch_action = OE_SCHEDULE_UTIL.OESCH_ACT_SCHEDULE OR
607 p_sch_action = OE_SCHEDULE_UTIL.OESCH_ACT_RESERVE OR
608 p_sch_action = OE_SCHEDULE_UTIL.OESCH_ACT_ATP_CHECK THEN
609
610 OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING := 'N';
611 OE_ORDER_SCH_UTIL.OESCH_PERFORM_SCHEDULING := 'N';
612
613 FOR I IN process_inc LOOP
614
615 IF l_debug_level > 0 THEN
616 oe_debug_pub.add( 'BEFORE CALLING INC'|| I.LINE_ID , 3 ) ;
617 END IF;
618 l_return_status := OE_CONFIG_UTIL.Process_Included_Items
619 (p_line_id => I.line_id,
620 p_freeze => FALSE);
621
622 IF l_debug_level > 0 THEN
623 oe_debug_pub.add( 'AFTER CALLING INC'|| L_RETURN_STATUS , 3 ) ;
624 END IF;
625
626 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
627 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
628 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
629 RAISE FND_API.G_EXC_ERROR;
630 END IF;
631
632 END LOOP;
633
634 OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING := 'Y';
635 OE_ORDER_SCH_UTIL.OESCH_PERFORM_SCHEDULING := 'Y';
636
637 END IF;
638
639
640
641 IF p_sch_action = OE_SCHEDULE_UTIL.OESCH_ACT_SCHEDULE
642 THEN
643
644 -- If the action is schedule,
645 -- then only query the lines that are not scheduled.
646 -- Re-scheduling should be allowed on the scheduled lines.
647 -- Prepare out table with the lines which are not scheduled.
648
649 I := 0;
650 FOR c1 IN l_line_csr LOOP
651
652
653 IF l_debug_level > 0 THEN
654 oe_debug_pub.add( 'PROCESSING LINE ' || C1.LINE_ID , 1 ) ;
655 END IF;
656
657 IF c1.schedule_status_code is null THEN
658
659 --4382036
660 /* OE_Line_Util.Query_Row( p_line_id => c1.line_id
661 ,x_line_rec => l_line_rec);
662 */
663
664 OE_Line_Util.Lock_Row(p_line_id => c1.line_id,
665 p_x_line_rec => l_line_rec,
666 x_return_status => l_return_status);
667
668
669 OE_MSG_PUB.set_msg_context
670 ( p_entity_code => 'LINE'
671 ,p_entity_id => l_line_rec.line_id
672 ,p_header_id => l_line_rec.header_id
673 ,p_line_id => l_line_rec.line_id
674 ,p_orig_sys_document_ref =>
675 l_line_rec.orig_sys_document_ref
676 ,p_orig_sys_document_line_ref =>
677 l_line_rec.orig_sys_line_ref
678 ,p_orig_sys_shipment_ref =>
679 l_line_rec.orig_sys_shipment_ref
680 ,p_change_sequence => l_line_rec.change_sequence
681 ,p_source_document_id =>
682 l_line_rec.source_document_id
683 ,p_source_document_line_id =>
684 l_line_rec.source_document_line_id
685 ,p_order_source_id =>
686 l_line_rec.order_source_id
687 ,p_source_document_type_id =>
688 l_line_rec.source_document_type_id);
689
690 l_line_rec.schedule_action_code := p_sch_action;
691 -- 2766876
692 l_line_rec.reserved_quantity := 0;
693
694 l_return_status := FND_API.G_RET_STS_SUCCESS;
695 OE_SCHEDULE_UTIL.Validate_Line(p_line_rec => l_line_rec,
696 p_old_line_rec => l_line_rec,
697 p_sch_action => p_sch_action,
698 x_return_status => l_return_status);
699
700
701 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
702
703 I := I + 1;
704 IF l_debug_level > 0 THEN
705 oe_debug_pub.add( 'LINE SELECTED FOR SCHEDULING **** : ' || L_LINE_REC.LINE_ID , 1 ) ;
706 END IF;
707 x_line_tbl(I) := l_line_rec;
708 x_line_tbl(I).operation := OE_GLOBALS.G_OPR_UPDATE;
709
710 IF (x_line_tbl(I).arrival_set_id is not null) THEN
711
712 l_set_rec := OE_ORDER_CACHE.Load_Set
713 ( x_line_tbl(I).arrival_set_id);
714 x_line_tbl(I).arrival_set := l_set_rec.set_name;
715
716 ELSIF (x_line_tbl(I).ship_set_id is not null) THEN
717
718 l_set_rec := OE_ORDER_CACHE.Load_Set
719 ( x_line_tbl(I).Ship_set_id);
720 x_line_tbl(I).ship_set := l_set_rec.set_name;
721
722 ELSIF (x_line_tbl(I).ship_model_complete_flag ='Y') THEN
723 x_line_tbl(I).ship_set := x_line_tbl(I).top_model_line_id;
724 ELSIF (x_line_tbl(I).ato_line_id is not null)
725 AND NOT(OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510'
726 AND MSC_ATP_GLOBAL.GET_APS_VERSION = 10) THEN
727 x_line_tbl(I).ship_set := x_line_tbl(I).ato_line_id;
728 END IF;
729
730
731 END IF;
732 END IF; -- schedule status code
733
734 END LOOP;
735
736 ELSIF p_sch_action = OE_SCHEDULE_UTIL.OESCH_ACT_RESERVE
737 THEN
738
739
740 --If the line is not scheduled,system should schedule and reserve the line.
741
742 I := 0;
743 FOR c1 IN l_line_csr LOOP
744
745 IF l_debug_level > 0 THEN
746 oe_debug_pub.add( 'LINE_ID :' || C1.LINE_ID , 1 ) ;
747 END IF;
748
749 -- 4382036
750 /* OE_Line_Util.Query_Row( p_line_id => c1.line_id
751 ,x_line_rec => l_line_rec);
752 */
753
754 OE_Line_Util.Lock_Row(p_line_id => c1.line_id,
755 p_x_line_rec => l_line_rec,
756 x_return_status => l_return_status);
757
758
759 OE_MSG_PUB.set_msg_context
760 ( p_entity_code => 'LINE'
761 ,p_entity_id => l_line_rec.line_id
762 ,p_header_id => l_line_rec.header_id
763 ,p_line_id => l_line_rec.line_id
764 ,p_orig_sys_document_ref =>
765 l_line_rec.orig_sys_document_ref
766 ,p_orig_sys_document_line_ref =>
767 l_line_rec.orig_sys_line_ref
768 ,p_orig_sys_shipment_ref =>
769 l_line_rec.orig_sys_shipment_ref
770 ,p_change_sequence => l_line_rec.change_sequence
771 ,p_source_document_id =>
772 l_line_rec.source_document_id
773 ,p_source_document_line_id =>
774 l_line_rec.source_document_line_id
775 ,p_order_source_id =>
776 l_line_rec.order_source_id
777 ,p_source_document_type_id =>
778 l_line_rec.source_document_type_id);
779
780 l_line_rec.schedule_action_code := p_sch_action;
781
782 IF l_line_rec.schedule_status_code is not null THEN
783
784 IF nvl(l_line_rec.shippable_flag,'N') = 'Y' THEN
785
786 IF l_sales_order_id is null THEN
787 l_sales_order_id :=
788 OE_SCHEDULE_UTIL.Get_mtl_sales_order_id(p_header_id);
789 END IF;
790
791 -- INVCONV - MERGED CALLS FOR OE_LINE_UTIL.Get_Reserved_Quantity and OE_LINE_UTIL.Get_Reserved_Quantity2
792
793 OE_LINE_UTIL.Get_Reserved_Quantities(p_header_id => l_sales_order_id
794 ,p_line_id => l_line_rec.line_id
795 ,p_org_id => l_line_rec.ship_from_org_id
796 ,x_reserved_quantity => l_line_rec.reserved_quantity
797 ,x_reserved_quantity2 => l_line_rec.reserved_quantity2
798 );
799
800
801 /*l_line_rec.reserved_quantity :=
802 OE_LINE_UTIL.Get_Reserved_Quantity
803 (p_header_id => l_sales_order_id,
804 p_line_id => l_line_rec.line_id,
805 p_org_id => l_line_rec.ship_from_org_id); */
806
807 IF l_line_rec.reserved_quantity IS NULL
808 OR l_line_rec.reserved_quantity = FND_API.G_MISS_NUM THEN
809 l_line_rec.reserved_quantity := 0;
810 END IF;
811
812 /*l_line_rec.reserved_quantity2 := -- INVCONV
813 OE_LINE_UTIL.Get_Reserved_Quantity2
814 (p_header_id => l_sales_order_id,
815 p_line_id => l_line_rec.line_id,
816 p_org_id => l_line_rec.ship_from_org_id);*/
817
818 /*IF l_line_rec.reserved_quantity2 IS NULL
819 OR l_line_rec.reserved_quantity2 = FND_API.G_MISS_NUM THEN
820 l_line_rec.reserved_quantity2 := 0;
821 END IF; */ -- INVCONV PAL
822
823
824 -- Pack J
825 IF l_line_rec.reserved_quantity = 0
826 OR ( OE_CODE_CONTROL.Get_Code_Release_Level >= '110510'
827 --AND OE_SYS_PARAMETERS.value('PARTIAL_RESERVATION_FLAG')= 'Y'
828 AND l_line_rec.ordered_quantity >
829 l_line_rec.reserved_quantity) THEN
830
831
832 IF l_debug_level > 0 THEN
833 oe_debug_pub.add( 'NEED TO RESERVE THE LINE' , 2 ) ;
834 END IF;
835
836 -- Check if the line is eligible for reservation.
837 l_return_status := FND_API.G_RET_STS_SUCCESS;
838 OE_SCHEDULE_UTIL.Validate_Line(p_line_rec => l_line_rec,
839 p_old_line_rec => l_line_rec,
840 p_sch_action => p_sch_action,
841 x_return_status => l_return_status);
842
843 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
844 --Pack J
845 -- To calculate the remaining quantity to be reserved
846 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510'
847 --AND OE_SYS_PARAMETERS.value('PARTIAL_RESERVATION_FLAG')= 'Y'
848 AND l_line_rec.ordered_quantity >
849 l_line_rec.reserved_quantity THEN
850 l_quantity_to_reserve := l_line_rec.ordered_quantity - l_line_rec.reserved_quantity;
851 ELSE
852 l_quantity_to_reserve := l_line_rec.ordered_quantity;
853 END IF;
854
855 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' -- INVCONV
856 AND l_line_rec.ordered_quantity2 >
857 l_line_rec.reserved_quantity2 THEN
858 l_quantity2_to_reserve := nvl(l_line_rec.ordered_quantity2, 0) - nvl(l_line_rec.reserved_quantity2,0);
859 ELSE
860 l_quantity2_to_reserve := l_line_rec.ordered_quantity2;
861 END IF;
862
863 IF l_quantity2_to_reserve = 0 -- INVCONV
864 THEN
865 l_quantity2_to_reserve := NULL;
866 END IF;
867
868 IF l_debug_level > 0 THEN
869 oe_debug_pub.add( 'QUANTITY TO RESERVE '||l_quantity_to_reserve , 2 ) ;
870 oe_debug_pub.add( 'QUANTITY2 TO RESERVE '||l_quantity2_to_reserve , 2 ) ;
871 oe_debug_pub.add( 'LINE SELECTED FOR RESERVE **** : '|| L_LINE_REC.LINE_ID , 1 ) ;
872 END IF;
873 --partial reservation exists
874 IF nvl(l_line_rec.reserved_quantity,0) > 0 THEN
875 l_rsv_update := TRUE;
876 END IF;
877 OE_SCHEDULE_UTIL.Reserve_Line
878 (p_line_rec => l_line_rec
879 ,p_quantity_to_reserve => l_quantity_to_reserve --l_line_rec.ordered_quantity
880 ,p_quantity2_to_reserve => l_quantity2_to_reserve --l_line_rec.ordered_quantity2
881 ,p_rsv_update => l_rsv_update
882 ,x_return_status => l_return_status);
883
884 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
885 IF l_debug_level > 0 THEN
886 oe_debug_pub.add( 'RAISING UNEXPECTED ERROR' , 1 ) ;
887 END IF;
888 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
889 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
890 IF l_debug_level > 0 THEN
891 oe_debug_pub.add( 'WILL IGNORE THE LINE AND PROCEED' , 1 ) ;
892 END IF;
893 l_return_status := FND_API.G_RET_STS_SUCCESS;
894 END IF;
895
896 END IF;
897 ELSE -- reservation exists
898
899 FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_ACTION_DONE_NO_EXP');
900 OE_MSG_PUB.Add;
901 IF l_debug_level > 0 THEN
902 oe_debug_pub.add( 'LINE IS ALREADY RESERVED , DO NOT NEED RESERVATION :' || L_LINE_REC.RESERVED_QUANTITY ) ;
903 END IF;
904
905 END IF; -- Reserve.
906 ELSE
907
908 l_line_rec.reserved_quantity := 0;
909 l_line_rec.reserved_quantity2 := 0; -- INVCONV
910 IF l_debug_level > 0 THEN
911 oe_debug_pub.add( 'LINE IS NON SHIPPABLE ' , 2 ) ;
912 END IF;
913 -- code fix for 3300528
914 --FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_ACTION_DONE_NO_EXP');
915 IF l_line_rec.ato_line_id IS NOT NULL AND
916 NOT ( l_line_rec.ato_line_id = l_line_rec.line_id AND
917 l_line_rec.item_type_code IN ( OE_GLOBALS.G_ITEM_OPTION,
918 OE_GLOBALS.G_ITEM_STANDARD,OE_GLOBALS.G_ITEM_INCLUDED)) --9775352
919 THEN
920 FND_MESSAGE.SET_NAME('ONT','OE_SCH_RES_NO_CONFIG');
921 ELSE
922 FND_MESSAGE.SET_NAME('ONT','ONT_SCH_NOT_RESERVABLE');
923 END IF;
924 -- code fix for 3300528
925 OE_MSG_PUB.Add;
926
927 END IF;
928 ELSE -- Line is not scheduled yet.
929
930 l_line_rec.reserved_quantity := 0;
931 l_line_rec.reserved_quantity2 := 0; -- INCONV
932 l_return_status := FND_API.G_RET_STS_SUCCESS;
933 OE_SCHEDULE_UTIL.Validate_Line(p_line_rec => l_line_rec,
934 p_old_line_rec => l_line_rec,
935 p_sch_action => p_sch_action,
936 x_return_status => l_return_status);
937
938 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
939 IF l_debug_level > 0 THEN
940 oe_debug_pub.add( 'LINE SELECTED FOR RESERVE **** : '|| L_LINE_REC.LINE_ID , 1 ) ;
941 END IF;
942 I := I + 1;
943 x_line_tbl(I) := l_line_rec;
944 x_line_tbl(I).operation := OE_GLOBALS.G_OPR_UPDATE;
945
946 IF (x_line_tbl(I).arrival_set_id is not null) THEN
947 l_set_rec := OE_ORDER_CACHE.Load_Set
948 ( x_line_tbl(I).arrival_set_id);
949 x_line_tbl(I).arrival_set := l_set_rec.set_name;
950 ELSIF (x_line_tbl(I).ship_set_id is not null) THEN
951 l_set_rec := OE_ORDER_CACHE.Load_Set
952 ( x_line_tbl(I).ship_set_id);
953 x_line_tbl(I).ship_set := l_set_rec.set_name;
954 ELSIF (x_line_tbl(I).ship_model_complete_flag ='Y') THEN
955 x_line_tbl(I).ship_set := x_line_tbl(I).top_model_line_id;
956 ELSIF (x_line_tbl(I).ato_line_id is not null)
957 AND NOT(OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510'
958 AND MSC_ATP_GLOBAL.GET_APS_VERSION = 10) THEN
959 x_line_tbl(I).ship_set := x_line_tbl(I).ato_line_id;
960 END IF;
961
962 x_line_tbl(I).reserved_quantity := 0;
963 x_line_tbl(I).reserved_quantity2 := 0; -- INVCONV
964
965 END IF; -- return status.
966 END IF; -- scheduled line.
967 END LOOP;
968
969 ELSIF p_sch_action = OE_SCHEDULE_UTIL.OESCH_ACT_ATP_CHECK
970 THEN
971
972 -- Load line table with scheduled and unscheduled lines.
973
974 I := 0;
975 FOR c1 IN l_line_csr LOOP
976 /*
977 I := I + 1;
978
979 IF I = 1 THEN */ -- 2327783
980 IF l_sales_order_id IS NULL THEN
981 l_sales_order_id :=OE_SCHEDULE_UTIL.Get_mtl_sales_order_id(p_header_id);
982 END IF;
983
984 IF l_debug_level > 0 THEN
985 oe_debug_pub.add( 'LINE SELECTED FOR ATP **** : ' || C1.LINE_ID , 1 ) ;
986 END IF;
987 OE_Line_Util.Query_Row( p_line_id => c1.line_id
988 ,x_line_rec => l_line_rec);
989
990
991 OE_MSG_PUB.set_msg_context
992 ( p_entity_code => 'LINE'
993 ,p_entity_id => l_line_rec.line_id
994 ,p_header_id => l_line_rec.header_id
995 ,p_line_id => l_line_rec.line_id
996 ,p_orig_sys_document_ref =>
997 l_line_rec.orig_sys_document_ref
998 ,p_orig_sys_document_line_ref =>
999 l_line_rec.orig_sys_line_ref
1000 ,p_orig_sys_shipment_ref =>
1001 l_line_rec.orig_sys_shipment_ref
1002 ,p_change_sequence => l_line_rec.change_sequence
1003 ,p_source_document_id =>
1004 l_line_rec.source_document_id
1005 ,p_source_document_line_id =>
1006 l_line_rec.source_document_line_id
1007 ,p_order_source_id =>
1008 l_line_rec.order_source_id
1009 ,p_source_document_type_id =>
1010 l_line_rec.source_document_type_id);
1011 l_line_rec.schedule_action_code := p_sch_action;
1012
1013
1014 l_return_status := FND_API.G_RET_STS_SUCCESS;
1015 OE_SCHEDULE_UTIL.Validate_Line(p_line_rec => l_line_rec,
1016 p_old_line_rec => l_line_rec,
1017 p_sch_action => p_sch_action,
1018 x_return_status => l_return_status);
1019
1020
1021 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
1022 I := I +1; -- 2327783
1023 x_line_tbl(I) := l_line_rec;
1024 -- x_line_tbl(I).operation := OE_GLOBALS.G_OPR_UPDATE;
1025
1026 IF (x_line_tbl(I).arrival_set_id is not null) THEN
1027 l_set_rec := OE_ORDER_CACHE.Load_Set
1028 ( x_line_tbl(I).arrival_set_id);
1029 x_line_tbl(I).arrival_set := l_set_rec.set_name;
1030 ELSIF (x_line_tbl(I).ship_set_id is not null) THEN
1031 l_set_rec := OE_ORDER_CACHE.Load_Set
1032 ( x_line_tbl(I).ship_set_id);
1033 x_line_tbl(I).ship_set := l_set_rec.set_name;
1034 ELSIF (x_line_tbl(I).ship_model_complete_flag ='Y') THEN
1035 x_line_tbl(I).ship_set := x_line_tbl(I).top_model_line_id;
1036 ELSIF (x_line_tbl(I).ato_line_id is not null)
1037 AND NOT(OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510'
1038 AND MSC_ATP_GLOBAL.GET_APS_VERSION = 10) THEN
1039 x_line_tbl(I).ship_set := x_line_tbl(I).ato_line_id;
1040 END IF;
1041
1042 IF x_line_tbl(I).schedule_status_code is not null
1043 AND nvl(x_line_tbl(I).shippable_flag,'N') = 'Y' THEN
1044
1045 -- INVCONV - MERGED CALLS FOR OE_LINE_UTIL.Get_Reserved_Quantity and OE_LINE_UTIL.Get_Reserved_Quantity2
1046
1047 OE_LINE_UTIL.Get_Reserved_Quantities(p_header_id => l_sales_order_id
1048 ,p_line_id => x_line_tbl(I).line_id
1049 ,p_org_id => x_line_tbl(I).ship_from_org_id
1050 ,x_reserved_quantity => x_line_tbl(I).reserved_quantity
1051 ,x_reserved_quantity2 => x_line_tbl(I).reserved_quantity2
1052 );
1053
1054
1055 /*x_line_tbl(I).reserved_quantity :=
1056 OE_LINE_UTIL.Get_Reserved_Quantity
1057 (p_header_id => l_sales_order_id,
1058 p_line_id => x_line_tbl(I).line_id,
1059 p_org_id => x_line_tbl(I).ship_from_org_id);
1060 x_line_tbl(I).reserved_quantity2 := -- INVCONV
1061 OE_LINE_UTIL.Get_Reserved_Quantity2
1062 (p_header_id => l_sales_order_id,
1063 p_line_id => x_line_tbl(I).line_id,
1064 p_org_id => x_line_tbl(I).ship_from_org_id); */
1065
1066 END IF;
1067
1068 IF x_line_tbl(I).reserved_quantity IS NULL
1069 OR x_line_tbl(I).reserved_quantity = FND_API.G_MISS_NUM THEN
1070 x_line_tbl(I).reserved_quantity := 0;
1071 END IF;
1072
1073 /* IF x_line_tbl(I).reserved_quantity2 IS NULL -- INVCONV
1074 OR x_line_tbl(I).reserved_quantity2 = FND_API.G_MISS_NUM THEN
1075 x_line_tbl(I).reserved_quantity2 := 0;
1076 END IF; */
1077
1078 END IF; -- Validation success
1079 END LOOP;
1080
1081
1082 ELSIF p_sch_action = OE_SCHEDULE_UTIL.OESCH_ACT_UNRESERVE THEN
1083
1084 -- Lines are already scheduled. We no need to explode the included items.
1085
1086 I := 0;
1087
1088 FOR c2 IN l_line_inc_csr LOOP
1089
1090
1091 OE_MSG_PUB.set_msg_context
1092 ( p_entity_code => 'LINE'
1093 ,p_entity_id => C2.line_id
1094 ,p_header_id => p_header_id
1095 ,p_line_id => C2.line_id
1096 ,p_orig_sys_document_ref => C2.orig_sys_document_ref
1097 ,p_orig_sys_document_line_ref => C2.orig_sys_line_ref
1098 ,p_orig_sys_shipment_ref => C2.orig_sys_shipment_ref
1099 ,p_change_sequence => C2.change_sequence
1100 ,p_source_document_id => C2.source_document_id
1101 ,p_source_document_line_id => C2.source_document_line_id
1102 ,p_order_source_id => C2.order_source_id
1103 ,p_source_document_type_id => C2.source_document_type_id);
1104
1105 -- If the line belong to set, and action is unschedule,
1106 -- ignore the line.
1107 IF nvl(c2.shippable_flag,'N') = 'Y' THEN
1108
1109 IF (nvl(c2.shipping_interfaced_flag,'N') = 'Y'
1110 AND oe_schedule_util.Get_Pick_Status(c2.line_id)) THEN -- 2595661
1111
1112
1113 FND_MESSAGE.SET_NAME('ONT','OE_SCH_UNRSV_NOT_ALLOWED');
1114 OE_MSG_PUB.Add;
1115 IF l_debug_level > 0 THEN
1116 oe_debug_pub.add( 'LINE IS SHIPPING INTERFACED ' || C2.LINE_ID , 1 ) ;
1117 END IF;
1118
1119 ELSE
1120
1121 -- 4382036
1122 /* OE_Line_Util.Query_Row( p_line_id => c2.line_id
1123 ,x_line_rec => l_line_rec);
1124 */
1125
1126 OE_Line_Util.Lock_Row(p_line_id => c2.line_id,
1127 p_x_line_rec => l_line_rec,
1128 x_return_status => l_return_status);
1129
1130 OE_MSG_PUB.set_msg_context
1131 ( p_entity_code => 'LINE'
1132 ,p_entity_id => l_line_rec.line_id
1133 ,p_header_id => l_line_rec.header_id
1134 ,p_line_id => l_line_rec.line_id
1135 ,p_orig_sys_document_ref =>
1136 l_line_rec.orig_sys_document_ref
1137 ,p_orig_sys_document_line_ref =>
1138 l_line_rec.orig_sys_line_ref
1139 ,p_orig_sys_shipment_ref =>
1140 l_line_rec.orig_sys_shipment_ref
1141 ,p_change_sequence => l_line_rec.change_sequence
1142 ,p_source_document_id =>
1143 l_line_rec.source_document_id
1144 ,p_source_document_line_id =>
1145 l_line_rec.source_document_line_id
1146 ,p_order_source_id =>
1147 l_line_rec.order_source_id
1148 ,p_source_document_type_id =>
1149 l_line_rec.source_document_type_id);
1150
1151 IF l_sales_order_id is null THEN
1152 l_sales_order_id :=
1153 OE_SCHEDULE_UTIL.Get_mtl_sales_order_id(p_header_id);
1154 END IF;
1155
1156
1157 -- INVCONV - MERGED CALLS FOR OE_LINE_UTIL.Get_Reserved_Quantity and OE_LINE_UTIL.Get_Reserved_Quantity2
1158
1159 OE_LINE_UTIL.Get_Reserved_Quantities(p_header_id => l_sales_order_id
1160 ,p_line_id => l_line_rec.line_id
1161 ,p_org_id => l_line_rec.ship_from_org_id
1162 ,x_reserved_quantity => l_line_rec.reserved_quantity
1163 ,x_reserved_quantity2 => l_line_rec.reserved_quantity2
1164 );
1165
1166
1167 /*l_line_rec.reserved_quantity :=
1168 OE_LINE_UTIL.Get_Reserved_Quantity
1169 (p_header_id => l_sales_order_id,
1170 p_line_id => l_line_rec.line_id,
1171 p_org_id => l_line_rec.ship_from_org_id); */
1172
1173 IF l_line_rec.reserved_quantity IS NULL
1174 OR l_line_rec.reserved_quantity = FND_API.G_MISS_NUM THEN
1175 l_line_rec.reserved_quantity := 0;
1176 END IF;
1177
1178
1179 /*l_line_rec.reserved_quantity2 := -- INVCONV
1180 OE_LINE_UTIL.Get_Reserved_Quantity2
1181 (p_header_id => l_sales_order_id,
1182 p_line_id => l_line_rec.line_id,
1183 p_org_id => l_line_rec.ship_from_org_id); */
1184
1185 /*IF l_line_rec.reserved_quantity2 IS NULL -- INVCONV - why was this commented out
1186 OR l_line_rec.reserved_quantity2 = FND_API.G_MISS_NUM THEN
1187 l_line_rec.reserved_quantity2 := 0;
1188 END IF; */
1189
1190
1191
1192 IF l_line_rec.reserved_quantity > 0 THEN
1193
1194 -- I := I + 1; 2327783
1195 IF l_sales_order_id is null THEN
1196
1197 l_sales_order_id :=OE_SCHEDULE_UTIL.
1198 Get_mtl_sales_order_id(p_header_id);
1199
1200 END IF;
1201
1202 IF l_debug_level > 0 THEN
1203 oe_debug_pub.add( 'LINE SELECTED FOR UNRES **** : ' || L_LINE_REC.LINE_ID , 1 ) ;
1204 END IF;
1205
1206
1207 l_line_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
1208 l_line_rec.schedule_action_code := p_sch_action;
1209 l_return_status := FND_API.G_RET_STS_SUCCESS;
1210
1211 OE_SCHEDULE_UTIL.Validate_Line(p_line_rec => l_line_rec,
1212 p_old_line_rec => l_line_rec,
1213 p_sch_action => p_sch_action,
1214 x_return_status => l_return_status);
1215
1216
1217 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
1218 I := I + 1; --2327783
1219 x_line_tbl(I) := l_line_rec;
1220 END IF;
1221 END IF; -- reservation qty.
1222 END IF; -- Shipping interfaced flag.
1223
1224 ELSE -- not shippable
1225 l_line_rec.reserved_quantity := 0;
1226 END IF; -- Line is not shippable line.
1227
1228 END LOOP;
1229 ELSIF p_sch_action = OE_SCHEDULE_UTIL.OESCH_ACT_UNSCHEDULE
1230 THEN
1231
1232 -- Lines are already scheduled. We no need to explode the included items.
1233
1234 I := 0;
1235
1236 FOR c2 IN l_line_inc_csr LOOP
1237 -- If the line belong to set, and action is unschedule,
1238 -- ignore the line.
1239
1240 OE_MSG_PUB.set_msg_context
1241 ( p_entity_code => 'LINE'
1242 ,p_entity_id => C2.line_id
1243 ,p_header_id => p_header_id
1244 ,p_line_id => C2.line_id
1245 ,p_orig_sys_document_ref => C2.orig_sys_document_ref
1246 ,p_orig_sys_document_line_ref => C2.orig_sys_line_ref
1247 ,p_orig_sys_shipment_ref => C2.orig_sys_shipment_ref
1248 ,p_change_sequence => C2.change_sequence
1249 ,p_source_document_id => C2.source_document_id
1250 ,p_source_document_line_id => C2.source_document_line_id
1251 ,p_order_source_id => C2.order_source_id
1252 ,p_source_document_type_id => C2.source_document_type_id);
1253
1254 IF c2.ship_set_id is null
1255 AND c2.arrival_set_id is null
1256 THEN
1257 /*
1258 I := I + 1;
1259 IF I = 1 THEN */ -- 2327783
1260
1261 IF l_sales_order_id IS NULL THEN
1262 l_sales_order_id :=OE_SCHEDULE_UTIL.
1263 Get_mtl_sales_order_id(p_header_id);
1264 END IF;
1265
1266
1267 IF l_debug_level > 0 THEN
1268 oe_debug_pub.add( 'LINE SELECTED FOR UNSCH **** : ' || C2.LINE_ID , 1 ) ;
1269 END IF;
1270
1271 -- 4382036
1272 /* OE_Line_Util.Query_Row( p_line_id => c2.line_id
1273 ,x_line_rec => l_line_rec);
1274 */
1275
1276 OE_Line_Util.Lock_Row(p_line_id => c2.line_id,
1277 p_x_line_rec => l_line_rec,
1278 x_return_status => l_return_status);
1279
1280 OE_MSG_PUB.set_msg_context
1281 ( p_entity_code => 'LINE'
1282 ,p_entity_id => l_line_rec.line_id
1283 ,p_header_id => l_line_rec.header_id
1284 ,p_line_id => l_line_rec.line_id
1285 ,p_orig_sys_document_ref =>
1286 l_line_rec.orig_sys_document_ref
1287 ,p_orig_sys_document_line_ref =>
1288 l_line_rec.orig_sys_line_ref
1289 ,p_orig_sys_shipment_ref =>
1290 l_line_rec.orig_sys_shipment_ref
1291 ,p_change_sequence => l_line_rec.change_sequence
1292 ,p_source_document_id =>
1293 l_line_rec.source_document_id
1294 ,p_source_document_line_id =>
1295 l_line_rec.source_document_line_id
1296 ,p_order_source_id =>
1297 l_line_rec.order_source_id
1298 ,p_source_document_type_id =>
1299 l_line_rec.source_document_type_id);
1300
1301
1302 l_line_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
1303 l_line_rec.schedule_action_code := p_sch_action;
1304
1305 l_return_status := FND_API.G_RET_STS_SUCCESS;
1306 OE_SCHEDULE_UTIL.Validate_Line(p_line_rec => l_line_rec,
1307 p_old_line_rec => l_line_rec,
1308 p_sch_action => p_sch_action,
1309 x_return_status => l_return_status);
1310
1311 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
1312 I := I + 1; --2327783
1313 x_line_tbl(I) := l_line_rec;
1314
1315 IF (x_line_tbl(I).ship_model_complete_flag ='Y') THEN
1316 x_line_tbl(I).ship_set := x_line_tbl(I).top_model_line_id;
1317 ELSIF (x_line_tbl(I).ato_line_id is not null)
1318 AND NOT(OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510'
1319 AND MSC_ATP_GLOBAL.GET_APS_VERSION = 10) THEN
1320 x_line_tbl(I).ship_set := x_line_tbl(I).ato_line_id;
1321 END IF;
1322
1323 IF nvl(x_line_tbl(I).shippable_flag,'N') = 'Y' THEN
1324 -- INVCONV - MERGED CALLS FOR OE_LINE_UTIL.Get_Reserved_Quantity and OE_LINE_UTIL.Get_Reserved_Quantity2
1325
1326 OE_LINE_UTIL.Get_Reserved_Quantities(p_header_id => l_sales_order_id
1327 ,p_line_id => x_line_tbl(I).line_id
1328 ,p_org_id => x_line_tbl(I).ship_from_org_id
1329 ,x_reserved_quantity => x_line_tbl(I).reserved_quantity
1330 ,x_reserved_quantity2 => x_line_tbl(I).reserved_quantity2
1331 );
1332
1333 /*x_line_tbl(I).reserved_quantity :=
1334 OE_LINE_UTIL.Get_Reserved_Quantity
1335 (p_header_id => l_sales_order_id,
1336 p_line_id => x_line_tbl(I).line_id,
1337 p_org_id => x_line_tbl(I).ship_from_org_id);
1338 x_line_tbl(I).reserved_quantity2 := -- INVCONV
1339 OE_LINE_UTIL.Get_Reserved_Quantity2
1340 (p_header_id => l_sales_order_id,
1341 p_line_id => x_line_tbl(I).line_id,
1342 p_org_id => x_line_tbl(I).ship_from_org_id);*/
1343
1344 END IF;
1345
1346 IF x_line_tbl(I).reserved_quantity IS NULL
1347 OR x_line_tbl(I).reserved_quantity = FND_API.G_MISS_NUM THEN
1348 x_line_tbl(I).reserved_quantity := 0;
1349 END IF;
1350 IF x_line_tbl(I).reserved_quantity2 IS NULL -- INVCONV
1351 OR x_line_tbl(I).reserved_quantity2 = FND_API.G_MISS_NUM THEN
1352 x_line_tbl(I).reserved_quantity2 := 0;
1353 END IF;
1354
1355 END IF; -- Success.
1356 ELSE -- part of set
1357 FND_MESSAGE.SET_NAME('ONT','OE_SCH_CANNOT_UNSCH_SET');
1358 OE_MSG_PUB.Add;
1359 IF l_debug_level > 0 THEN
1360 oe_debug_pub.add( 'LINE IS PART OF SET ' , 1 ) ;
1361 END IF;
1362
1363 END IF; -- do not unschedule if line is part of set.
1364
1365 END LOOP;
1366
1367 END IF; -- Main.
1368
1369
1370 IF l_debug_level > 0 THEN
1371 oe_debug_pub.add( 'EXITING OE_GROUP_SCH_UTIL.QUERY_LINES ' || X_LINE_TBL.COUNT , 1 ) ;
1372 END IF;
1373
1374
1375 EXCEPTION
1376
1377 WHEN FND_API.G_EXC_ERROR THEN
1378 IF l_debug_level > 0 THEN
1379 oe_debug_pub.add( 'EXPECTED ERROR IN QUERY LINES ' , 1 ) ;
1380 END IF;
1381 OE_ORDER_SCH_UTIL.OESCH_PERFORM_SCHEDULING := 'Y';
1382 OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING := 'Y';
1383 RAISE FND_API.G_EXC_ERROR;
1384
1385 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1386
1387 IF l_debug_level > 0 THEN
1388 oe_debug_pub.add( 'UNEXPECTED ERROR IN QUERY LINES ' , 1 ) ;
1389 END IF;
1390 OE_ORDER_SCH_UTIL.OESCH_PERFORM_SCHEDULING := 'Y';
1391 OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING := 'Y';
1392 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1393
1394 WHEN OTHERS THEN
1395
1396 IF l_debug_level > 0 THEN
1397 oe_debug_pub.add( 'WHEN OTHERS ERROR IN QUERY LINES ' , 1 ) ;
1398 END IF;
1399 OE_ORDER_SCH_UTIL.OESCH_PERFORM_SCHEDULING := 'Y';
1400 OE_SCHEDULE_UTIL.OESCH_PERFORM_SCHEDULING := 'Y';
1401 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1402 THEN
1403 OE_MSG_PUB.Add_Exc_Msg
1404 ( G_PKG_NAME
1405 , 'Query_lines'
1406 );
1407 END IF;
1408
1409 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1410
1411 END Query_Lines;
1412 /*----------------------------------------------------------------
1413 PROCEDURE Query_Schedule_Lines
1414 Description : This api will be called from schedule_multi_line API when
1415 action requested by user is schedule.
1416 System has to perform little validations before passing record back to the user.
1417 Initially system selects few scheduling related attributes to see whether the
1418 line has to be selected for scheduling or not. If it has to be selected then
1419 checks if it is part of non smc and model is also selected by user. If Model is selected by user we will ignore the line or else we will select the line for
1420 processing. If the line selected is Included item and No SMC, make sure not only
1421 it's modle is selected, also check for its immediate parent. If its immediate
1422 parent is selected then ignore the included item, since included item will be
1423 selected by it's parent.
1424
1425 If a line is part of SMC or ATO or if it is a TOP MODEL, selected whole model for processing. If it is a non smc class or kit, select its included items if any.
1426 ----------------------------------------------------------------- */
1427 PROCEDURE Query_Schedule_Lines
1428 ( p_selected_tbl IN OE_GLOBALS.Selected_record_Tbl, --R12.MOAC
1429 p_sch_action IN VARCHAR2,
1430 x_line_tbl IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
1431 )
1432 IS
1433 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
1434 l_line_rec OE_Order_PUB.Line_rec_Type;
1435 l_line_id NUMBER;
1436 l_arrival_set_id NUMBER;
1437 l_ship_set_id NUMBER;
1438 l_top_model_line_id NUMBER;
1439 l_ato_line_id NUMBER;
1440 l_smc_flag VARCHAR2(1);
1441 l_item_type_code VARCHAR2(30);
1442 l_schedule_status_code VARCHAR2(30);
1443 l_line_category_code VARCHAR2(30);
1444 l_source_type_code VARCHAR2(30);
1445 l_link_to_line_id NUMBER;
1446 l_query VARCHAR2(1);
1447 l_found VARCHAR2(1);
1448 J NUMBER;
1449 l_header_id NUMBER;
1450 l_open_flag VARCHAR2(1);
1451
1452 --
1453 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1454 --
1455 l_orig_sys_document_ref VARCHAR2(50);
1456 l_orig_sys_line_ref VARCHAR2(50);
1457 l_orig_sys_shipment_ref VARCHAR2(50);
1458 l_source_document_type_id NUMBER;
1459 l_change_sequence VARCHAR2(50);
1460 l_source_document_id NUMBER;
1461 l_source_document_line_id NUMBER;
1462 l_order_source_id NUMBER;
1463 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
1464 l_set_line_rec OE_Order_PUB.Line_rec_Type; --4241385
1465 -- sol_ord_er #16014165
1466 l_subscription_enable_flag varchar2(10) := '';
1467 BEGIN
1468
1469 IF l_debug_level > 0 THEN
1470 oe_debug_pub.add( 'ENTERING INTO QUERY SCHEDULE LINES ' , 1 ) ;
1471 END IF;
1472 FOR L IN 1..p_selected_tbl.count LOOP --R12.MOAC
1473
1474 IF l_debug_level > 0 THEN
1475 oe_debug_pub.add( 'PROCESSING LINE_ID' || P_SELECTED_TBL(L).ID1 , 2 ) ;
1476 END IF;
1477
1478 l_line_id := p_selected_tbl(L).id1;
1479 -- Query required attributes and check does any action is required
1480 -- on the line.
1481 BEGIN
1482
1483 Select Arrival_set_id, Ship_set_id,top_model_line_id,
1484 Ship_model_complete_flag, ato_line_id,item_type_code,
1485 Schedule_status_code,line_category_code,header_id,open_flag,
1486 source_type_code,link_to_line_id,
1487 orig_sys_document_ref, orig_sys_line_ref, orig_sys_shipment_ref,
1488 source_document_type_id, change_sequence, source_document_id,
1489 source_document_line_id, order_source_id,
1490 subscription_enable_flag --sol_ord_er #16014165
1491 Into l_arrival_set_id, l_ship_set_id, l_top_model_line_id,
1492 l_smc_flag, l_ato_line_id, l_item_type_code,
1493 l_schedule_status_code,l_line_category_code,l_header_id,l_open_flag,
1494 l_source_type_code,l_link_to_line_id,
1495 l_orig_sys_document_ref, l_orig_sys_line_ref, l_orig_sys_shipment_ref,
1496 l_source_document_type_id, l_change_sequence, l_source_document_id,
1497 l_source_document_line_id, l_order_source_id,
1498 l_subscription_enable_flag --sol_ord_er #16014165
1499 From oe_order_lines_all
1500 Where line_id = l_line_id;
1501
1502 EXCEPTION
1503 WHEN OTHERS THEN
1504 Null;
1505 END;
1506
1507 OE_MSG_PUB.set_msg_context
1508 ( p_entity_code => 'LINE'
1509 ,p_entity_id => l_line_id
1510 ,p_header_id => l_header_id
1511 ,p_line_id => l_line_id
1512 ,p_orig_sys_document_ref => l_orig_sys_document_ref
1513 ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
1514 ,p_orig_sys_shipment_ref => l_orig_sys_shipment_ref
1515 ,p_change_sequence => l_change_sequence
1516 ,p_source_document_id => l_source_document_id
1517 ,p_source_document_line_id => l_source_document_line_id
1518 ,p_order_source_id => l_order_source_id
1519 ,p_source_document_type_id => l_source_document_type_id);
1520
1521 -- If the line is part of set then avoid selecting them ,
1522 -- since scheduling is prerequisite for sets.
1523 -- Also avoid selecting any line if they are part of ato model
1524 -- or smc and they are scheduled.
1525
1526 IF ((l_arrival_set_id is not null
1527 OR l_ship_set_id is not null
1528 OR l_ato_line_id is not null
1529 OR l_smc_flag = 'Y') AND
1530 l_schedule_status_code is NOT NULL)
1531 OR l_line_category_code = 'RETURN'
1532 OR l_item_type_code = 'SERVICE'
1533 OR l_source_type_code = OE_GLOBALS.G_SOURCE_EXTERNAL
1534 OR nvl(l_open_flag,'Y') = 'N'
1535 OR NVL(l_subscription_enable_flag,'N') = 'Y' --sol_ord_er #16014165
1536 THEN
1537 -- Schedule action is not required for the line.
1538 -- Populate the message on the stack.
1539
1540 FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_ACTION_DONE_NO_EXP');
1541 OE_MSG_PUB.Add;
1542 IF l_debug_level > 0 THEN
1543 oe_debug_pub.add( 'LINE IS A SCHEDULED LINE' || L_LINE_ID , 2 ) ;
1544 END IF;
1545
1546 --4241385
1547 /* Added the below elsif condition, so that all the lines in a set
1548 should be scheduled together, if we multi select lines from sales
1549 order form and do tools->scheduling->schedule*/
1550
1551 ELSIF (l_arrival_set_id is not null
1552 OR l_ship_set_id is not null)
1553 AND l_schedule_status_code IS NULL THEN
1554
1555 IF l_debug_level > 0 THEN
1556 oe_debug_pub.add( 'log schedule set delayed request');
1557 END IF;
1558
1559
1560 OE_Line_Util.Query_Row
1561 (p_line_id => l_line_id,
1562 x_line_rec => l_set_line_rec);
1563
1564 oe_schedule_util.Log_Set_Request
1565 ( l_set_line_rec,
1566 l_set_line_rec,
1567 'SCHEDULE',
1568 'SCH_INTERNAL',
1569 l_return_status );
1570
1571 --4241385
1572
1573 ELSE -- line not scheduled, please select the line to schedule.
1574
1575 l_query := 'Y';
1576
1577 -- If user slectes the non smc model and option,
1578 -- then avoid selecting the
1579 -- option, since model will select the option.
1580
1581 IF l_top_model_line_id IS NOT NULL
1582 AND l_smc_flag = 'N'
1583 AND l_top_model_line_id <> l_line_id
1584 THEN
1585
1586 -- Check if model is selected by user.
1587 -- If model is selected then ignore the line for query, since
1588 -- model will query the line.
1589
1590 FOR K IN 1..p_selected_tbl.count LOOP -- R12.MOAC
1591 IF l_top_model_line_id = p_selected_tbl(K).id1
1592 OR (l_item_type_code = OE_GLOBALS.G_ITEM_INCLUDED AND
1593 l_link_to_line_id = p_selected_tbl(K).id1) THEN
1594 IF l_debug_level > 0 THEN
1595 oe_debug_pub.add( 'PARENT LINE IS PART OF TABLE' || P_SELECTED_TBL(K).ID1 , 2 ) ;
1596 END IF;
1597 l_query := 'N';
1598 exit;
1599 END IF;
1600 END LOOP;
1601
1602
1603
1604 ELSIF x_line_tbl.count > 0 THEN
1605 -- If the line is not a non smc option or class, then
1606 -- check if the line is present in the table.
1607 -- Check if the line is already present. If line exists then
1608 -- ignore the line.
1609
1610 FOR I IN 1..x_line_tbl.count LOOP
1611 IF l_line_id = x_line_tbl(I).line_id
1612 THEN
1613 l_query := 'N';
1614 IF l_debug_level > 0 THEN
1615 oe_debug_pub.add( '2 LINE IS PART OF TABLE' , 2 ) ;
1616 END IF;
1617 Exit;
1618 END IF;
1619 END LOOP;
1620
1621 END IF;
1622
1623 IF l_query = 'Y' THEN
1624
1625 -- Decided to query the line. See what to pass to query sets.
1626 IF l_smc_flag = 'Y'
1627 THEN
1628
1629 Oe_Config_Schedule_Pvt.Query_Set_Lines
1630 (p_header_id => l_header_id,
1631 p_model_line_id => l_top_model_line_id,
1632 p_sch_action => p_sch_action,
1633 x_line_tbl => l_line_tbl,
1634 x_return_status => l_return_status);
1635
1636 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1637 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1638 END IF;
1639
1640 IF x_line_tbl.count = 0 THEN
1641
1642 x_line_tbl := l_line_tbl;
1643
1644 ELSE
1645 /* Check_Merge_Line(p_x_line_tbl => x_line_tbl
1646 ,p_line_tbl => l_line_tbl); */ -- Bug-2454163
1647
1648 J := x_line_tbl.count;
1649 FOR I IN 1..l_line_tbl.count LOOP
1650 IF NOT Find_Line(x_line_tbl,l_line_tbl(I).line_id) THEN
1651 x_line_tbl(J + I) := l_line_tbl(I);
1652 END IF;
1653 END LOOP;
1654 END IF;
1655
1656 ELSIF (l_ato_line_id is not null AND
1657 NOT (l_line_id = l_ato_line_id AND
1658 l_item_type_code IN(OE_GLOBALS.G_ITEM_STANDARD,
1659 OE_GLOBALS.G_ITEM_OPTION,
1660 OE_GLOBALS.G_ITEM_INCLUDED))) --9775352
1661 THEN
1662
1663
1664 -- Query ato model.
1665 OE_Config_Util.Query_ATO_Options
1666 (p_ato_line_id => l_ato_line_id,
1667 x_line_tbl => l_line_tbl);
1668
1669
1670 IF x_line_tbl.count = 0 THEN
1671
1672 x_line_tbl := l_line_tbl;
1673
1674 ELSE
1675 /*Check_Merge_Line(p_x_line_tbl => x_line_tbl
1676 ,p_line_tbl => l_line_tbl); */ -- Bug-2454163
1677
1678 J := x_line_tbl.count;
1679 FOR I IN 1..l_line_tbl.count LOOP
1680 IF NOT Find_Line(x_line_tbl,l_line_tbl(I).line_id) THEN
1681 x_line_tbl(J + I) := l_line_tbl(I);
1682 END IF;
1683 END LOOP;
1684 END IF;
1685
1686 ELSIF l_line_id = l_top_model_line_id THEN
1687
1688 -- This is a non smc top model. User might have selected model
1689 -- and its options If the model is selected query whole
1690 -- model and try to place them in the
1691 -- out table if they are not present already.
1692
1693 Oe_Config_Schedule_Pvt.Query_Set_Lines
1694 (p_header_id => l_header_id,
1695 p_model_line_id => l_top_model_line_id,
1696 p_sch_action => p_sch_action,
1697 x_line_tbl => l_line_tbl,
1698 x_return_status => l_return_status);
1699
1700 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1701 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1702 END IF;
1703
1704 IF x_line_tbl.count = 0 THEN
1705 -- Added for Bug 2454163
1706 J := x_line_tbl.count;
1707 FOR I IN 1..l_line_tbl.count LOOP
1708 IF l_line_tbl(I).schedule_status_code is NULL THEN
1709 J := J + 1;
1710 x_line_tbl(J) := l_line_tbl(I);
1711 END IF;
1712 END LOOP;
1713
1714 ELSE
1715 /* Check_Merge_Line(p_x_line_tbl => x_line_tbl
1716 ,p_line_tbl => l_line_tbl); */ --Bug-2454163
1717 J := x_line_tbl.count;
1718 FOR I IN 1..l_line_tbl.count LOOP
1719 IF l_line_tbl(I).schedule_status_code is NULL AND
1720 NOT Find_Line(x_line_tbl,l_line_tbl(I).line_id) THEN
1721 J := J + 1;
1722 x_line_tbl(J) := l_line_tbl(I);
1723 END IF;
1724 END LOOP;
1725 END IF;
1726 ELSE
1727
1728 IF l_schedule_status_code IS NULL THEN
1729 /*
1730 OE_Line_Util.Query_Row
1731 (p_line_id => l_line_id,
1732 x_line_rec => l_line_rec);
1733 */
1734 --4382036
1735 OE_LINE_UTIL.Lock_Row(p_line_id => l_line_id,
1736 p_x_line_rec => l_line_rec,
1737 x_return_status => l_return_status);
1738
1739 l_line_rec.reserved_quantity := 0;
1740 /*Check_Merge_Line(p_line_rec => l_line_rec
1741 ,p_x_line_tbl => x_line_tbl); */ --Bug-2454163
1742 --8731703
1743 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
1744 IF NOT Find_Line(x_line_tbl,l_line_rec.line_id) THEN
1745 x_line_tbl(x_line_tbl.count + 1) := l_line_rec;
1746 END IF;
1747
1748 IF l_item_type_code = 'CLASS'
1749 OR l_item_type_code = 'KIT'
1750 THEN
1751
1752 Oe_Config_Schedule_Pvt.Query_Set_Lines
1753 (p_header_id => l_header_id,
1754 p_link_to_line_id => l_line_id,
1755 p_sch_action => p_sch_action,
1756 x_line_tbl => l_line_tbl,
1757 x_return_status => l_return_status);
1758
1759 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1760 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1761 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1762 x_line_tbl.delete(x_line_tbl.count);
1763 END IF;
1764
1765 J := x_line_tbl.count;
1766 FOR I IN 1..l_line_tbl.count LOOP
1767 IF l_line_tbl(I).schedule_status_code is NULL
1768 AND NOT Find_Line(x_line_tbl,l_line_tbl(I).line_id) THEN
1769 J := J + 1;
1770 x_line_tbl(J) := l_line_tbl(I);
1771 END IF;
1772 END LOOP;
1773 END IF; -- Class or Kit.
1774 END IF; -- 8731703
1775 END IF; -- Schedule status code.
1776
1777 END IF; -- group query or single query.
1778
1779 END IF; -- l_query.
1780
1781 END IF; -- Ignore and do not ignore.
1782
1783 END LOOP;
1784
1785 IF l_debug_level > 0 THEN
1786 oe_debug_pub.add( 'EXITING QUERY_SCHEDULE_LINES' || X_LINE_TBL.COUNT , 1 ) ;
1787 END IF;
1788
1789
1790 EXCEPTION
1791
1792 WHEN FND_API.G_EXC_ERROR THEN
1793 IF l_debug_level > 0 THEN
1794 oe_debug_pub.add( 'EXPECTED ERROR IN QUERY_SCHEDULE_LINES ' , 1 ) ;
1795 END IF;
1796 RAISE FND_API.G_EXC_ERROR;
1797
1798 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1799
1800 IF l_debug_level > 0 THEN
1801 oe_debug_pub.add( 'UNEXPECTED ERROR IN QUERY_SCHEDULE_LINES ' , 1 ) ;
1802 END IF;
1803 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1804 -- Start 2742982 --
1805 WHEN NO_DATA_FOUND THEN
1806 FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_ACTION_DONE_NO_EXP');
1807 OE_MSG_PUB.Add;
1808 RAISE FND_API.G_EXC_ERROR;
1809 -- End 2742982 --
1810
1811 WHEN OTHERS THEN
1812
1813 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1814 THEN
1815 OE_MSG_PUB.Add_Exc_Msg
1816 ( G_PKG_NAME
1817 , 'Query_Schedule_Lines'
1818 );
1819 END IF;
1820
1821 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1822 END Query_Schedule_Lines;
1823
1824 /*----------------------------------------------------------------
1825 PROCEDURE Query_Unschedule_Lines
1826 Description : This api will be called from schedule_multi_line API when
1827 action requested by user is Unschedule.
1828 System has to perform little validations before passing record back to the user.
1829 Initially system selects few scheduling related attributes to see whether the
1830 line has to be selected for scheduling or not. If it has to be selected then
1831 check if it is part of non smc and model is also selected by user. If Model is selected by user we will ignore the line or else we will select the line for
1832 processing. If the line selected is Included item and No SMC, make sure not only
1833 it's modle is selected, also check for its immediate parent. If its immediate
1834 parent is selected then ignore the included item, since included item will be
1835 selected by it's parent.
1836
1837 If a line is part of SMC or ATO or if it is a TOP MODEL, selected whole model
1838 for processing. If it is a non smc class or kit, select its included items if any.
1839 ----------------------------------------------------------------- */
1840 PROCEDURE Query_Unschedule_Lines
1841 ( p_selected_tbl IN OE_GLOBALS.Selected_record_Tbl, --R12.MOAC
1842 p_sch_action IN VARCHAR2,
1843 x_line_tbl IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
1844 )
1845 IS
1846 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
1847 l_line_rec OE_Order_PUB.Line_rec_Type;
1848 l_line_id NUMBER;
1849 l_arrival_set_id NUMBER;
1850 l_ship_set_id NUMBER;
1851 l_top_model_line_id NUMBER;
1852 l_ato_line_id NUMBER;
1853 l_smc_flag VARCHAR2(1);
1854 l_item_type_code VARCHAR2(30);
1855 l_schedule_status_code VARCHAR2(30);
1856 l_line_category_code VARCHAR2(30);
1857 l_source_type_code VARCHAR2(30);
1858 l_link_to_line_id NUMBER;
1859 l_query VARCHAR2(1);
1860 l_found VARCHAR2(1);
1861 J NUMBER;
1862 l_header_id NUMBER;
1863 l_sales_order_id NUMBER;
1864 l_open_flag VARCHAR2(1);
1865
1866 --
1867 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1868 --
1869 l_orig_sys_document_ref VARCHAR2(50);
1870 l_orig_sys_line_ref VARCHAR2(50);
1871 l_orig_sys_shipment_ref VARCHAR2(50);
1872 l_source_document_type_id NUMBER;
1873 l_change_sequence VARCHAR2(50);
1874 l_source_document_id NUMBER;
1875 l_source_document_line_id NUMBER;
1876 l_order_source_id NUMBER;
1877 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
1878 l_subscription_enable_flag varchar2(10):= ''; --sol_ord_er #16014165
1879 BEGIN
1880
1881 IF l_debug_level > 0 THEN
1882 oe_debug_pub.add( 'ENTERING INTO QUERY UNSCHEDULE LINES ' , 1 ) ;
1883 END IF;
1884 FOR L IN 1..p_selected_tbl.count LOOP --R12.MOAC
1885
1886 IF l_debug_level > 0 THEN
1887 oe_debug_pub.add( 'PROCESSING LINE_ID' || p_selected_tbl(L).id1 , 2 ) ;
1888 END IF;
1889
1890 --l_line_id := p_line_id_tbl(L);
1891 l_line_id := p_selected_tbl(L).id1;
1892 -- Query required attributes and check does any action is required
1893 -- on the line.
1894 Select Arrival_set_id, Ship_set_id,top_model_line_id,
1895 Ship_model_complete_flag, ato_line_id,item_type_code,
1896 Schedule_status_code,line_category_code,header_id,open_flag,
1897 source_type_code,link_to_line_id,
1898 orig_sys_document_ref, orig_sys_line_ref, orig_sys_shipment_ref,
1899 source_document_type_id, change_sequence, source_document_id,
1900 source_document_line_id, order_source_id,
1901 subscription_enable_flag --sol_ord_er #16014165
1902 Into l_arrival_set_id, l_ship_set_id, l_top_model_line_id,
1903 l_smc_flag, l_ato_line_id, l_item_type_code,
1904 l_schedule_status_code,l_line_category_code,l_header_id,l_open_flag,
1905 l_source_type_code,l_link_to_line_id,
1906 l_orig_sys_document_ref, l_orig_sys_line_ref, l_orig_sys_shipment_ref,
1907 l_source_document_type_id, l_change_sequence, l_source_document_id,
1908 l_source_document_line_id, l_order_source_id,
1909 l_subscription_enable_flag --sol_ord_er #16014165
1910 From oe_order_lines_all
1911 Where line_id = l_line_id;
1912
1913 OE_MSG_PUB.set_msg_context
1914 ( p_entity_code => 'LINE'
1915 ,p_entity_id => l_line_id
1916 ,p_header_id => l_header_id
1917 ,p_line_id => l_line_id
1918 ,p_orig_sys_document_ref => l_orig_sys_document_ref
1919 ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
1920 ,p_orig_sys_shipment_ref => l_orig_sys_shipment_ref
1921 ,p_change_sequence => l_change_sequence
1922 ,p_source_document_id => l_source_document_id
1923 ,p_source_document_line_id => l_source_document_line_id
1924 ,p_order_source_id => l_order_source_id
1925 ,p_source_document_type_id => l_source_document_type_id);
1926
1927
1928 -- If the line selected is not scheduled. Ignore the line, since
1929 -- no action is required here.
1930
1931 IF l_arrival_set_id is not null
1932 OR l_ship_set_id is not null THEN
1933
1934 IF l_debug_level > 0 THEN
1935 oe_debug_pub.add( 'LINE CANNOT BE UNSCHEDULED IF IT IS PART OF SET' , 1 ) ;
1936 END IF;
1937 FND_MESSAGE.SET_NAME('ONT','OE_SCH_CANNOT_UNSCH_SET');
1938 OE_MSG_PUB.Add;
1939 ELSIF (l_schedule_status_code IS NULL AND
1940 (l_smc_flag = 'Y' OR
1941 l_ato_line_id is not null OR
1942 l_item_type_code = OE_GLOBALS.G_ITEM_INCLUDED OR
1943 l_item_type_code = OE_GLOBALS.G_ITEM_OPTION OR
1944 l_item_type_code = OE_GLOBALS.G_ITEM_STANDARD))
1945 OR l_line_category_code = 'RETURN'
1946 OR l_item_type_code = OE_GLOBALS.G_ITEM_SERVICE
1947 OR nvl(l_open_flag,'Y') = 'N'
1948 OR NVL(l_subscription_enable_flag,'N') = 'Y' --sol_ord_er #16014165
1949 THEN
1950 -- line is part of ATO/SMC Model or an ato item which is
1951 -- not scheduled. Bipass these lines.
1952 FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_ACTION_DONE_NO_EXP');
1953 OE_MSG_PUB.Add;
1954 IF l_debug_level > 0 THEN
1955 oe_debug_pub.add( 'NOT A VALID LINE' || L_LINE_ID , 2 ) ;
1956 END IF;
1957 ELSE -- line not scheduled, please select the line to schedule.
1958
1959 l_query := 'Y';
1960
1961 -- If user slectes the non smc model and option, then avoid
1962 -- selecting the option, since model will select the option.
1963
1964 IF l_top_model_line_id IS NOT NULL
1965 AND l_smc_flag = 'N'
1966 AND l_top_model_line_id <> l_line_id THEN
1967
1968 -- Check if model is selected by user.
1969 -- If model is selected then ignore the line for query, since
1970 -- model will query the line.
1971
1972 --R12.MOAC
1973 FOR K IN 1..p_selected_tbl.count LOOP
1974 IF l_top_model_line_id =p_selected_tbl(K).id1
1975 OR (l_item_type_code = OE_GLOBALS.G_ITEM_INCLUDED AND
1976 l_link_to_line_id = p_selected_tbl(K).id1) THEN
1977 l_query := 'N';
1978 exit;
1979 END IF;
1980 END LOOP;
1981
1982 ELSIF x_line_tbl.count > 0 THEN
1983 -- if the line is not a non smc option or class, then check if the
1984 -- line is present in the table.
1985 -- Check if the line is already present. If line exists then
1986 -- ignore the line.
1987
1988 FOR I IN 1..x_line_tbl.count LOOP
1989 IF l_line_id = x_line_tbl(I).line_id
1990 THEN
1991 l_query := 'N';
1992 Exit;
1993 END IF;
1994 END LOOP;
1995 END IF;
1996
1997 IF l_query = 'Y' THEN
1998
1999 -- Decided to query the line. See what to pass to query sets.
2000 IF l_smc_flag = 'Y'
2001 OR (l_ato_line_id is not null AND
2002 NOT (l_line_id = l_ato_line_id AND
2003 l_item_type_code IN(OE_GLOBALS.G_ITEM_STANDARD,
2004 OE_GLOBALS.G_ITEM_OPTION,
2005 OE_GLOBALS.G_ITEM_INCLUDED))) --9775352
2006 THEN
2007
2008 -- query using top_model_line_id / ato line id
2009
2010
2011 IF l_smc_flag = 'Y' THEN
2012 Oe_Config_Schedule_Pvt.Query_Set_Lines
2013 (p_header_id => l_header_id,
2014 p_model_line_id => l_top_model_line_id,
2015 p_sch_action => p_sch_action,
2016 x_line_tbl => l_line_tbl,
2017 x_return_status => l_return_status);
2018
2019 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2020 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2021 END IF;
2022 ELSE
2023
2024 -- Query ato model.
2025 OE_Config_Util.Query_ATO_Options
2026 ( p_ato_line_id => l_ato_line_id,
2027 x_line_tbl => l_line_tbl);
2028
2029 END IF;
2030
2031 IF x_line_tbl.count = 0 THEN
2032
2033 x_line_tbl := l_line_tbl;
2034
2035 ELSE
2036 /* Check_Merge_Line(p_x_line_tbl => x_line_tbl
2037 ,p_line_tbl => l_line_tbl); */ --Bug-2454163
2038
2039 J := x_line_tbl.count;
2040 FOR I IN 1..l_line_tbl.count LOOP
2041 IF NOT Find_Line(x_line_tbl,l_line_tbl(I).line_id) THEN
2042 J := J +1;
2043 x_line_tbl(J) := l_line_tbl(I);
2044 END IF;
2045 END LOOP;
2046 END IF;
2047
2048 ELSIF l_line_id = l_top_model_line_id THEN
2049
2050 -- This is a non smc top model. User might have selected model
2051 -- and its options If the model is selected query
2052 -- whole model and try to place them in the
2053 -- out table if they are not present already.
2054
2055 Oe_Config_Schedule_Pvt.Query_Set_Lines
2056 (p_header_id => l_header_id,
2057 p_model_line_id => l_top_model_line_id,
2058 p_sch_action => p_sch_action,
2059 x_line_tbl => l_line_tbl,
2060 x_return_status => l_return_status);
2061
2062 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2063 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2064 END IF;
2065
2066 IF x_line_tbl.count = 0 THEN
2067 J := x_line_tbl.count;
2068 FOR I IN 1..l_line_tbl.count LOOP
2069 IF l_line_tbl(I).schedule_status_code is NOT NULL THEN
2070 J := J + 1;
2071 x_line_tbl(J) := l_line_tbl(I);
2072 END IF;
2073 END LOOP;
2074
2075 ELSE
2076
2077 /* Check_Merge_Line(p_x_line_tbl => x_line_tbl
2078 ,p_line_tbl => l_line_tbl); */
2079
2080
2081 J := x_line_tbl.count;
2082 FOR I IN 1..l_line_tbl.count LOOP
2083 IF l_line_tbl(I).schedule_status_code is NOT NULL
2084 AND NOT Find_Line(x_line_tbl,l_line_tbl(I).line_id) THEN
2085 J := J + 1;
2086 x_line_tbl(J) := l_line_tbl(I);
2087 END IF;
2088 END LOOP;
2089
2090 END IF;
2091 ELSE
2092 -- 4382036
2093 OE_Line_Util.Lock_Row(p_line_id => l_line_id,
2094 p_x_line_rec => l_line_rec,
2095 x_return_status => l_return_status);
2096
2097 /* OE_Line_Util.Query_Row
2098 (p_line_id => l_line_id,
2099 x_line_rec => l_line_rec);
2100 */
2101
2102 IF nvl(l_line_rec.shippable_flag,'N') = 'Y' THEN
2103
2104 IF l_sales_order_id is null THEN
2105 l_sales_order_id :=
2106 OE_SCHEDULE_UTIL.Get_mtl_sales_order_id
2107 (l_line_rec.header_id);
2108 END IF;
2109
2110
2111 -- INVCONV - MERGED CALLS FOR OE_LINE_UTIL.Get_Reserved_Quantity and OE_LINE_UTIL.Get_Reserved_Quantity2
2112
2113 OE_LINE_UTIL.Get_Reserved_Quantities(p_header_id => l_sales_order_id
2114 ,p_line_id => l_line_rec.line_id
2115 ,p_org_id => l_line_rec.ship_from_org_id
2116 ,x_reserved_quantity => l_line_rec.reserved_quantity
2117 ,x_reserved_quantity2 => l_line_rec.reserved_quantity2
2118 );
2119
2120
2121 /*l_line_rec.reserved_quantity :=
2122 OE_LINE_UTIL.Get_Reserved_Quantity
2123 (p_header_id => l_sales_order_id,
2124 p_line_id => l_line_rec.line_id,
2125 p_org_id => l_line_rec.ship_from_org_id);
2126 l_line_rec.reserved_quantity2 := -- INVCONV
2127 OE_LINE_UTIL.Get_Reserved_Quantity2
2128 (p_header_id => l_sales_order_id,
2129 p_line_id => l_line_rec.line_id,
2130 p_org_id => l_line_rec.ship_from_org_id); */
2131
2132
2133 END IF;
2134 IF l_line_rec.reserved_quantity IS NULL
2135 OR l_line_rec.reserved_quantity = FND_API.G_MISS_NUM
2136 THEN
2137 l_line_rec.reserved_quantity := 0;
2138 END IF;
2139 IF l_line_rec.reserved_quantity2 IS NULL -- INVCONV
2140 OR l_line_rec.reserved_quantity2 = FND_API.G_MISS_NUM
2141 THEN
2142 l_line_rec.reserved_quantity2 := 0;
2143 END IF;
2144
2145
2146
2147 /* Check_Merge_Line(p_x_line_tbl => x_line_tbl
2148 ,p_line_rec => l_line_rec); */ -- Bug-2454163
2149
2150 IF NOT Find_Line(x_line_tbl,l_line_rec.line_id) THEN
2151 x_line_tbl(x_line_tbl.count + 1) := l_line_rec;
2152 END IF;
2153
2154 IF l_item_type_code = 'CLASS'
2155 OR l_item_type_code = 'KIT'
2156 THEN
2157
2158 Oe_Config_Schedule_Pvt.Query_Set_Lines
2159 (p_header_id => l_header_id,
2160 p_link_to_line_id => l_line_id,
2161 p_sch_action => p_sch_action,
2162 x_line_tbl => l_line_tbl,
2163 x_return_status => l_return_status);
2164
2165 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2166 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2167 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2168 x_line_tbl.delete(x_line_tbl.count);
2169 END IF;
2170
2171
2172 /* Check_Merge_Line(p_x_line_tbl => x_line_tbl
2173 ,p_line_tbl => l_line_tbl); */ --Bug-2454163
2174
2175 J := x_line_tbl.count;
2176 FOR I IN 1..l_line_tbl.count LOOP
2177 IF l_line_tbl(I).schedule_status_code is NOT NULL
2178 AND NOT Find_Line(x_line_tbl,l_line_tbl(I).line_id) THEN
2179 J := J + 1;
2180 x_line_tbl(J) := l_line_tbl(I);
2181 END IF;
2182 END LOOP;
2183
2184 END IF; -- Class or Kit.
2185 END IF; -- group query or single query.
2186
2187 END IF; -- l_query.
2188
2189 END IF; -- Ignore and do not ignore.
2190
2191
2192 END LOOP;
2193
2194
2195 EXCEPTION
2196
2197 WHEN FND_API.G_EXC_ERROR THEN
2198 IF l_debug_level > 0 THEN
2199 oe_debug_pub.add( 'EXPECTED ERROR IN QUERY_UNSCHEDULE_LINES ' , 1 ) ;
2200 END IF;
2201 RAISE FND_API.G_EXC_ERROR;
2202
2203 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2204
2205 IF l_debug_level > 0 THEN
2206 oe_debug_pub.add( 'UNEXPECTED ERROR IN QUERY_UNSCHEDULE_LINES ' , 1 ) ;
2207 END IF;
2208 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2209
2210 -- Start 2742982 --
2211 WHEN NO_DATA_FOUND THEN
2212 FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_ACTION_DONE_NO_EXP');
2213 OE_MSG_PUB.Add;
2214 RAISE FND_API.G_EXC_ERROR;
2215 -- End 2742982 --
2216
2217 WHEN OTHERS THEN
2218
2219 IF l_debug_level > 0 THEN
2220 oe_debug_pub.add( ' WHEN OTHERS ERROR IN QUERY_UNSCHEDULE_LINES ' , 1 ) ;
2221 END IF;
2222 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2223 THEN
2224 OE_MSG_PUB.Add_Exc_Msg
2225 ( G_PKG_NAME
2226 , 'Query_Unschedule_Lines'
2227 );
2228 END IF;
2229
2230 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2231
2232 END Query_Unschedule_Lines;
2233
2234 /*----------------------------------------------------------------
2235 PROCEDURE Query_Unreserve_Lines
2236 Description : This api will be called from schedule_multi_line API when
2237 action requested by user is Unreserve.
2238 System has to perform little validations before passing record back to the user.
2239 Initially system selects few scheduling related attributes to see whether the
2240 line has to be selected for Unreserve or not. If it has to be selected then
2241 check if it is part of model and parent is also selected by user. If Model is selected by user we will ignore the line or else we will select the line for
2242 processing. If the line selected is Included item, make sure not only it's modle is selected, also check for its immediate parent. If its immediate parent is selected then ignore the included item, since included item will be selected by it's parent.
2243
2244 If line is a top model selected all its children that are scheduled and it is a class or kit select its included items as well or else select by itself.
2245
2246 ----------------------------------------------------------------- */
2247 PROCEDURE Query_Unreserve_Lines
2248 ( p_selected_tbl IN OE_GLOBALS.Selected_record_Tbl, --R12.MOAC
2249 p_sch_action IN VARCHAR2,
2250 x_line_tbl IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
2251 )
2252 IS
2253 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
2254 l_line_rec OE_Order_PUB.Line_rec_Type;
2255 l_line_id NUMBER;
2256 l_arrival_set_id NUMBER;
2257 l_ship_set_id NUMBER;
2258 l_top_model_line_id NUMBER;
2259 l_ato_line_id NUMBER;
2260 l_smc_flag VARCHAR2(1);
2261 l_shipping_interfaced_flag VARCHAR2(1);
2262 l_item_type_code VARCHAR2(30);
2263 l_schedule_status_code VARCHAR2(30);
2264 l_line_category_code VARCHAR2(30);
2265 l_source_type_code VARCHAR2(30);
2266 l_link_to_line_id NUMBER;
2267 l_query VARCHAR2(1);
2268 l_found VARCHAR2(1);
2269 J NUMBER;
2270 l_header_id NUMBER;
2271 l_sales_order_id NUMBER;
2272 l_open_flag VARCHAR2(1);
2273
2274 --
2275 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2276 --
2277 l_orig_sys_document_ref VARCHAR2(50);
2278 l_orig_sys_line_ref VARCHAR2(50);
2279 l_orig_sys_shipment_ref VARCHAR2(50);
2280 l_source_document_type_id NUMBER;
2281 l_change_sequence VARCHAR2(50);
2282 l_source_document_id NUMBER;
2283 l_source_document_line_id NUMBER;
2284 l_order_source_id NUMBER;
2285 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
2286 BEGIN
2287
2288 FOR L IN 1..p_selected_tbl.count LOOP --R12.MOAC
2289
2290
2291 IF l_debug_level > 0 THEN
2292 oe_debug_pub.add( 'PROCESSING LINE_ID' || P_SELECTED_TBL(L).ID1 , 2 ) ;
2293 END IF;
2294
2295 l_line_id := p_selected_tbl(L).id1;
2296 -- Query required attributes and check does any action is required
2297 -- on the line.
2298 Select Arrival_set_id, Ship_set_id,top_model_line_id,
2299 Ship_model_complete_flag, ato_line_id,item_type_code,
2300 Schedule_status_code,line_category_code,header_id,open_flag,
2301 nvl(shipping_interfaced_flag,'N'),source_type_code,link_to_line_id,
2302 orig_sys_document_ref, orig_sys_line_ref, orig_sys_shipment_ref,
2303 source_document_type_id, change_sequence, source_document_id,
2304 source_document_line_id, order_source_id
2305 Into l_arrival_set_id, l_ship_set_id, l_top_model_line_id,
2306 l_smc_flag, l_ato_line_id, l_item_type_code,
2307 l_schedule_status_code,l_line_category_code,l_header_id,l_open_flag,
2308 l_shipping_interfaced_flag,l_source_type_code,l_link_to_line_id,
2309 l_orig_sys_document_ref, l_orig_sys_line_ref, l_orig_sys_shipment_ref,
2310 l_source_document_type_id, l_change_sequence, l_source_document_id,
2311 l_source_document_line_id, l_order_source_id
2312 From oe_order_lines_all
2313 Where line_id = l_line_id;
2314
2315 OE_MSG_PUB.set_msg_context
2316 ( p_entity_code => 'LINE'
2317 ,p_entity_id => l_line_id
2318 ,p_header_id => l_header_id
2319 ,p_line_id => l_line_id
2320 ,p_orig_sys_document_ref => l_orig_sys_document_ref
2321 ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
2322 ,p_orig_sys_shipment_ref => l_orig_sys_shipment_ref
2323 ,p_change_sequence => l_change_sequence
2324 ,p_source_document_id => l_source_document_id
2325 ,p_source_document_line_id => l_source_document_line_id
2326 ,p_order_source_id => l_order_source_id
2327 ,p_source_document_type_id => l_source_document_type_id);
2328
2329 -- If the line selected is not scheduled. Ignore the line, since
2330 -- no action is required here.
2331
2332 IF l_schedule_status_code IS NULL
2333 OR nvl(l_open_flag,'Y') = 'N'
2334 OR (l_shipping_interfaced_flag = 'Y'
2335 AND oe_schedule_util.Get_Pick_Status(l_line_id))
2336 THEN -- 2595661
2337 -- Go inside only if they are scheduled.
2338 -- and not part of set.
2339 IF l_shipping_interfaced_flag = 'Y' THEN
2340
2341 FND_MESSAGE.SET_NAME('ONT','OE_SCH_UNRSV_NOT_ALLOWED');
2342 OE_MSG_PUB.Add;
2343 IF l_debug_level > 0 THEN
2344 oe_debug_pub.add( 'LINE IS SHIPPING INTERFACED' || L_LINE_ID , 1 ) ;
2345 END IF;
2346
2347 END IF;
2348 ELSE -- line not scheduled, please select the line to schedule.
2349
2350 l_query := 'Y';
2351
2352 -- If user slectes the model and option, then avoid selecting the
2353 -- option, since model will select the option.
2354
2355 IF l_top_model_line_id IS NOT NULL
2356 AND l_top_model_line_id <> l_line_id THEN
2357
2358 -- Check if model is selected by user.
2359 -- If model is selected then ignore the line for query, since
2360 -- model will query the line.
2361
2362 --R12.MOAC
2363 FOR K IN 1..p_selected_tbl.count LOOP
2364 IF l_top_model_line_id = p_selected_tbl(K).id1
2365 OR (l_item_type_code = OE_GLOBALS.G_ITEM_INCLUDED AND
2366 l_link_to_line_id = p_selected_tbl(K).id1) THEN
2367 l_query := 'N';
2368 exit;
2369 END IF;
2370 END LOOP;
2371 END IF;
2372
2373 IF l_query = 'Y' THEN
2374
2375 -- Decided to query the line. See what to pass to query sets.
2376 IF l_line_id = l_top_model_line_id THEN
2377
2378 -- This is a non smc top model. User might have selected model
2379 -- and its options. If the model is selected query
2380 -- whole model and try to place them in the
2381 -- out table if they are not present already.
2382
2383 Oe_Config_Schedule_Pvt.Query_Set_Lines
2384 (p_header_id => l_header_id,
2385 p_model_line_id => l_top_model_line_id,
2386 p_sch_action => p_sch_action,
2387 x_line_tbl => l_line_tbl,
2388 x_return_status => l_return_status);
2389
2390 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2391 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2392 END IF;
2393
2394
2395 IF x_line_tbl.count = 0 THEN
2396 J := x_line_tbl.count;
2397 FOR I IN 1..l_line_tbl.count LOOP
2398 IF l_line_tbl(I).schedule_status_code is NOT NULL THEN
2399 J := J + 1;
2400 x_line_tbl(J) := l_line_tbl(I);
2401 END IF;
2402 END LOOP;
2403 ELSE
2404 /* Check_Merge_Line(p_x_line_tbl => x_line_tbl
2405 ,p_line_tbl => l_line_tbl); */ --Bug-2454163
2406
2407 J := x_line_tbl.count;
2408 FOR I IN 1..l_line_tbl.count LOOP
2409 IF l_line_tbl(I).schedule_status_code is NOT NULL
2410 AND NOT Find_Line(x_line_tbl,l_line_tbl(I).line_id) THEN
2411 J := J + 1;
2412 x_line_tbl(J) := l_line_tbl(I);
2413 END IF;
2414 END LOOP;
2415
2416 END IF;
2417 ELSE
2418
2419 -- 4382036
2420 OE_Line_Util.Lock_Row(p_line_id => l_line_id,
2421 p_x_line_rec => l_line_rec,
2422 x_return_status => l_return_status);
2423
2424 /* OE_Line_Util.Query_Row
2425 (p_line_id => l_line_id,
2426 x_line_rec => l_line_rec);
2427 */
2428
2429 IF nvl(l_line_rec.shippable_flag,'N') = 'Y' THEN
2430
2431 IF l_sales_order_id is null THEN
2432 l_sales_order_id :=
2433 OE_SCHEDULE_UTIL.Get_mtl_sales_order_id
2434 (l_line_rec.header_id);
2435 END IF;
2436
2437 -- INVCONV - MERGED CALLS FOR OE_LINE_UTIL.Get_Reserved_Quantity and OE_LINE_UTIL.Get_Reserved_Quantity2
2438
2439 OE_LINE_UTIL.Get_Reserved_Quantities(p_header_id => l_sales_order_id
2440 ,p_line_id => l_line_rec.line_id
2441 ,p_org_id => l_line_rec.ship_from_org_id
2442 ,x_reserved_quantity => l_line_rec.reserved_quantity
2443 ,x_reserved_quantity2 => l_line_rec.reserved_quantity2
2444 );
2445
2446 /*l_line_rec.reserved_quantity :=
2447 OE_LINE_UTIL.Get_Reserved_Quantity
2448 (p_header_id => l_sales_order_id,
2449 p_line_id => l_line_rec.line_id,
2450 p_org_id => l_line_rec.ship_from_org_id);
2451 l_line_rec.reserved_quantity2 := -- INVCONV
2452 OE_LINE_UTIL.Get_Reserved_Quantity2
2453 (p_header_id => l_sales_order_id,
2454 p_line_id => l_line_rec.line_id,
2455 p_org_id => l_line_rec.ship_from_org_id); */
2456 END IF;
2457
2458 IF l_line_rec.reserved_quantity IS NULL
2459 OR l_line_rec.reserved_quantity = FND_API.G_MISS_NUM
2460 THEN
2461 l_line_rec.reserved_quantity := 0;
2462 END IF;
2463 /*IF l_line_rec.reserved_quantity2 IS NULL -- INVCONV
2464 OR l_line_rec.reserved_quantity2 = FND_API.G_MISS_NUM
2465 THEN
2466 l_line_rec.reserved_quantity2 := 0;
2467 END IF; */
2468
2469
2470 /* Check_Merge_Line(p_x_line_tbl => x_line_tbl
2471 ,p_line_rec => l_line_rec); */ --Bug-2454163
2472
2473 IF NOT Find_Line(x_line_tbl,l_line_rec.line_id) THEN
2474 x_line_tbl(x_line_tbl.count + 1) := l_line_rec;
2475 END IF;
2476
2477 IF l_item_type_code = 'CLASS'
2478 OR l_item_type_code = 'KIT'
2479 THEN
2480
2481 Oe_Config_Schedule_Pvt.Query_Set_Lines
2482 (p_header_id => l_header_id,
2483 p_link_to_line_id => l_line_id,
2484 p_sch_action => p_sch_action,
2485 x_line_tbl => l_line_tbl,
2486 x_return_status => l_return_status);
2487
2488 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2489 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2490 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2491 x_line_tbl.delete(x_line_tbl.count);
2492 END IF;
2493
2494 /* Check_Merge_Line(p_x_line_tbl => x_line_tbl
2495 ,p_line_tbl => l_line_tbl); */ --Bug-2454163
2496
2497
2498 J := x_line_tbl.count;
2499 FOR I IN 1..l_line_tbl.count LOOP
2500 IF NOT Find_Line(x_line_tbl,l_line_tbl(I).line_id)
2501 AND l_line_tbl(I).schedule_status_code IS NOT NULL THEN
2502 J := J + 1;
2503 x_line_tbl(J) := l_line_tbl(I);
2504 END IF;
2505 END LOOP;
2506 END IF; -- Class or Kit.
2507 END IF; -- group query or single query.
2508
2509 END IF; -- l_query.
2510
2511 END IF; -- Ignore and do not ignore.
2512
2513
2514 END LOOP;
2515
2516
2517
2518 EXCEPTION
2519
2520
2521 WHEN FND_API.G_EXC_ERROR THEN
2522 IF l_debug_level > 0 THEN
2523 oe_debug_pub.add( 'EXPECTED ERROR IN QUERY_UNRESERVE_LINES ' , 1 ) ;
2524 END IF;
2525 RAISE FND_API.G_EXC_ERROR;
2526
2527 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2528
2529 IF l_debug_level > 0 THEN
2530 oe_debug_pub.add( 'EXPECTED ERROR IN QUERY_UNRESERVE_LINES ' , 1 ) ;
2531 END IF;
2532 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2533
2534 -- Start 2742982 --
2535 WHEN NO_DATA_FOUND THEN
2536 FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_ACTION_DONE_NO_EXP');
2537 OE_MSG_PUB.Add;
2538 RAISE FND_API.G_EXC_ERROR;
2539 -- End 2742982 --
2540
2541 WHEN OTHERS THEN
2542
2543 IF l_debug_level > 0 THEN
2544 oe_debug_pub.add( ' WHEN OTHERS ERROR IN QUERY_UNRESERVE_LINES ' , 1 ) ;
2545 END IF;
2546 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2547 THEN
2548 OE_MSG_PUB.Add_Exc_Msg
2549 ( G_PKG_NAME
2550 , 'Query_Unreserve_Lines'
2551 );
2552 END IF;
2553
2554 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2555 END Query_Unreserve_Lines;
2556
2557 /*----------------------------------------------------------------
2558 PROCEDURE Query_Reserve_Lines
2559 Description : This api will be called from schedule_multi_line API when
2560 action requested by user is reserve.
2561 System has to perform little validations before passing record back to the user.
2562 Initially system selects few scheduling related attributes to see whether the
2563 line has to be selected for reserve or not. If it has to be selected then
2564 check if it is part of model and parent is also selected by user. If Model is selected by user we will ignore the line or else we will select the line for
2565 processing. If the line selected is Included item, make sure not only it's
2566 modle is selected, also check for its immediate parent. If its immediate parent
2567 is selected then ignore the included item, since included item will be selected
2568 by it's parent.
2569
2570 If top model is selected for processing then query whole model. If a line
2571 selected is part of smc or ATO model and if it is not scheduled, then select
2572 whole model or else select only the line for reservation. If class or kit is
2573 selected then select its included items as well.
2574
2575 ------------------------------------------------------------------*/
2576 PROCEDURE Query_Reserve_Lines
2577 ( p_selected_tbl IN OE_GLOBALS.Selected_record_Tbl, --R12.MOAC
2578 p_sch_action IN VARCHAR2,
2579 x_line_tbl IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
2580 )
2581 IS
2582 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
2583 l_line_rec OE_Order_PUB.Line_rec_Type;
2584 l_line_id NUMBER;
2585 l_arrival_set_id NUMBER;
2586 l_ship_set_id NUMBER;
2587 l_top_model_line_id NUMBER;
2588 l_ato_line_id NUMBER;
2589 l_smc_flag VARCHAR2(1);
2590 l_item_type_code VARCHAR2(30);
2591 l_schedule_status_code VARCHAR2(30);
2592 l_line_category_code VARCHAR2(30);
2593 l_link_to_line_id NUMBER;
2594 l_source_type_code VARCHAR2(30);
2595 l_query VARCHAR2(1);
2596 l_found VARCHAR2(1);
2597 J NUMBER;
2598 l_header_id NUMBER;
2599 l_config_id NUMBER;
2600 l_sales_order_id NUMBER := Null;
2601 l_return_status VARCHAR2(30) := FND_API.G_RET_STS_SUCCESS;
2602 l_open_flag VARCHAR2(1);
2603 --
2604 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2605 --
2606 l_orig_sys_document_ref VARCHAR2(50);
2607 l_orig_sys_line_ref VARCHAR2(50);
2608 l_orig_sys_shipment_ref VARCHAR2(50);
2609 l_source_document_type_id NUMBER;
2610 l_change_sequence VARCHAR2(50);
2611 l_source_document_id NUMBER;
2612 l_source_document_line_id NUMBER;
2613 l_order_source_id NUMBER;
2614 l_quantity_to_reserve NUMBER;
2615 l_quantity2_to_reserve NUMBER; -- INVCONV
2616 l_rsv_update BOOLEAN :=FALSE;
2617 l_set_line_rec OE_Order_PUB.Line_rec_Type; --4241385
2618 l_subscription_enable_flag varchar2(10) := ''; --sol_ord_er #16014165
2619 BEGIN
2620
2621 IF l_debug_level > 0 THEN
2622 oe_debug_pub.add( 'ENTERING QUERY RESERVE LINES' , 1 ) ;
2623 END IF;
2624 FOR L IN 1..p_selected_tbl.count LOOP --R12.MOAC
2625
2626 IF l_debug_level > 0 THEN
2627 oe_debug_pub.add( 'PROCESSING LINE_ID' || P_SELECTED_TBL(L).ID1 , 2 ) ;
2628 END IF;
2629
2630 l_line_id := p_selected_tbl(L).id1;
2631 -- Query required attributes and check does any action is required
2632 -- on the line.
2633 Select Arrival_set_id, Ship_set_id,top_model_line_id,
2634 Ship_model_complete_flag, ato_line_id,item_type_code,
2635 Schedule_status_code,line_category_code,header_id,open_flag,
2636 source_type_code,link_to_line_id,
2637 orig_sys_document_ref, orig_sys_line_ref, orig_sys_shipment_ref,
2638 source_document_type_id, change_sequence, source_document_id,
2639 source_document_line_id, order_source_id,
2640 subscription_enable_flag --sol_ord_er #16014165
2641 Into l_arrival_set_id, l_ship_set_id, l_top_model_line_id,
2642 l_smc_flag, l_ato_line_id, l_item_type_code,
2643 l_schedule_status_code,l_line_category_code,l_header_id,l_open_flag,
2644 l_source_type_code,l_link_to_line_id,
2645 l_orig_sys_document_ref, l_orig_sys_line_ref, l_orig_sys_shipment_ref,
2646 l_source_document_type_id, l_change_sequence, l_source_document_id,
2647 l_source_document_line_id, l_order_source_id,
2648 l_subscription_enable_flag --sol_ord_er #16014165
2649 From oe_order_lines_all
2650 Where line_id = l_line_id;
2651
2652 OE_MSG_PUB.set_msg_context
2653 ( p_entity_code => 'LINE'
2654 ,p_entity_id => l_line_id
2655 ,p_header_id => l_header_id
2656 ,p_line_id => l_line_id
2657 ,p_orig_sys_document_ref => l_orig_sys_document_ref
2658 ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
2659 ,p_orig_sys_shipment_ref => l_orig_sys_shipment_ref
2660 ,p_change_sequence => l_change_sequence
2661 ,p_source_document_id => l_source_document_id
2662 ,p_source_document_line_id => l_source_document_line_id
2663 ,p_order_source_id => l_order_source_id
2664 ,p_source_document_type_id => l_source_document_type_id);
2665
2666
2667 IF l_line_category_code = 'RETURN'
2668 OR l_item_type_code = 'SERVICE'
2669 OR NVL(l_subscription_enable_flag,'N') = 'Y' --sol_ord_er #16014165
2670 OR l_source_type_code = OE_GLOBALS.G_SOURCE_EXTERNAL
2671 OR nvl(l_open_flag,'Y') = 'N' THEN
2672
2673 -- populate the error message and skip the line.
2674 FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_ACTION_DONE_NO_EXP');
2675 OE_MSG_PUB.Add;
2676 IF l_debug_level > 0 THEN
2677 oe_debug_pub.add( 'NOT A VALIDE LINE' || L_LINE_ID , 2 ) ;
2678 END IF;
2679
2680 --4241385
2681 /* Added the below elsif condition, so that all the lines in a set
2682 should be scheduled/reserved together, if we multi select lines from
2683 sales order form and do tools->scheduling->reserve*/
2684
2685 ELSIF (l_arrival_set_id is not null
2686 OR l_ship_set_id is not null)
2687 AND l_schedule_status_code IS NULL THEN
2688 -- AND l_auto_schedule_sets='N') THEN
2689 IF l_debug_level > 0 THEN
2690 oe_debug_pub.add( 'log schedule set delayed request');
2691 END IF;
2692
2693
2694 OE_Line_Util.Query_Row
2695 (p_line_id => l_line_id,
2696 x_line_rec => l_set_line_rec);
2697
2698 oe_schedule_util.Log_Set_Request
2699 ( l_set_line_rec,
2700 l_set_line_rec,
2701 'SCHEDULE',
2702 'SCH_INTERNAL',
2703 l_return_status );
2704 --4241385
2705 ELSE
2706 l_query := 'Y';
2707
2708 --If user slectes the non smc model and option, then avoid selecting the
2709 --option, since model will select the option.
2710
2711 IF l_top_model_line_id IS NOT NULL
2712 AND l_smc_flag = 'N'
2713 AND l_top_model_line_id <> l_line_id THEN
2714
2715 -- Check if model is selected by user.
2716 -- If model is selected then ignore the line for query, since
2717 -- model will query the line.
2718 --R12.MOAC
2719 FOR K IN 1..p_selected_tbl.count LOOP
2720 IF l_top_model_line_id = p_selected_tbl(K).id1
2721 OR (l_item_type_code = OE_GLOBALS.G_ITEM_INCLUDED AND
2722 l_link_to_line_id = p_selected_tbl(K).id1) THEN
2723 l_query := 'N';
2724 exit;
2725 END IF;
2726 END LOOP;
2727
2728 ELSIF l_line_tbl.count > 0 THEN
2729 -- if the line is not a non smc option or class, then check if the
2730 -- line is present in the table.
2731 -- Check if the line is already present. If line exists then
2732 -- ignore the line.
2733
2734 FOR I IN 1..l_line_tbl.count LOOP
2735 IF l_line_id = l_line_tbl(I).line_id
2736 THEN
2737 l_query := 'N';
2738 Exit;
2739 END IF;
2740 END LOOP;
2741 END IF;
2742
2743 IF l_query = 'Y' THEN
2744
2745 -- Decided to query the line. See what to pass to query sets.
2746 -- If line is part of smc or ATO if it is not scheduled , then select
2747 -- whole model or else select only that line to reserve.
2748
2749 IF (l_smc_flag = 'Y'
2750 AND l_schedule_status_code is null)
2751 OR (l_line_id = l_top_model_line_id
2752 AND l_ato_line_id is null) THEN
2753
2754 -- This is a non smc top model. User might have selected model
2755 -- and its options.If the model is selected query whole
2756 -- model and try to place them in the
2757 -- out table if they are not present already.
2758
2759 Oe_Config_Schedule_Pvt.Query_Set_Lines
2760 (p_header_id => l_header_id,
2761 p_model_line_id => l_top_model_line_id,
2762 p_sch_action => p_sch_action,
2763 x_line_tbl => x_line_tbl,
2764 x_return_status => l_return_status);
2765
2766 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2767 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2768 END IF;
2769
2770 /* Check_Merge_Line(p_x_line_tbl => x_line_tbl
2771 ,p_line_tbl => l_line_tbl); */ -- Bug-2454163
2772
2773 IF l_line_tbl.count = 0 THEN
2774 l_line_tbl := x_line_tbl;
2775 ELSE
2776
2777 J := l_line_tbl.count;
2778 FOR I IN 1..x_line_tbl.count LOOP
2779 IF NOT Find_Line(l_line_tbl,x_line_tbl(I).line_id) THEN
2780 J := J + 1;
2781 l_line_tbl(J) := x_line_tbl(I);
2782 END IF;
2783 END LOOP;
2784
2785 END IF;
2786
2787
2788 ELSIF (l_ato_line_id is not null AND
2789 NOT (l_line_id = l_ato_line_id AND
2790 l_item_type_code IN(OE_GLOBALS.G_ITEM_STANDARD,
2791 OE_GLOBALS.G_ITEM_OPTION,
2792 OE_GLOBALS.G_ITEM_INCLUDED))) -- 9775352
2793 AND l_schedule_status_code is null
2794 THEN
2795
2796 -- Query ato model.
2797 OE_Config_Util.Query_ATO_Options
2798 (p_ato_line_id => l_ato_line_id,
2799 x_line_tbl => x_line_tbl);
2800
2801 IF l_line_tbl.count = 0 THEN
2802 l_line_tbl := x_line_tbl;
2803 ELSE
2804
2805 /* Check_Merge_Line(p_x_line_tbl => x_line_tbl
2806 ,p_line_tbl => l_line_tbl); */
2807
2808
2809 J := l_line_tbl.count;
2810 FOR I IN 1..x_line_tbl.count LOOP
2811 IF NOT Find_Line(l_line_tbl,x_line_tbl(I).line_id) THEN
2812 J := J + 1;
2813 l_line_tbl(J) := x_line_tbl(I);
2814 END IF;
2815 END LOOP;
2816
2817
2818 END IF;
2819
2820 -- 2746802
2821 ELSIF l_ato_line_id = l_line_id
2822 AND l_item_type_code = OE_GLOBALS.G_ITEM_MODEL
2823 AND l_schedule_status_code is not null THEN
2824
2825 l_config_id := Null;
2826
2827 BEGIN
2828
2829 SELECT line_id
2830 INTO l_config_id
2831 FROM oe_order_lines_all
2832 WHERE header_id = l_header_id
2833 AND ato_line_id = l_ato_line_id
2834 AND item_type_code = 'CONFIG';
2835
2836 EXCEPTION
2837 When Others Then
2838
2839 l_config_id := Null;
2840 END;
2841
2842 IF l_config_id IS NOT NULL THEN
2843
2844 IF l_debug_level > 0 THEN
2845 oe_debug_pub.add( 'NEED TO RESERVE THE LINE' , 2 ) ;
2846 END IF;
2847
2848 OE_Line_Util.Query_Row
2849 (p_line_id => l_config_id,
2850 x_line_rec => l_line_rec);
2851
2852 IF nvl(l_line_rec.shippable_flag,'N') = 'Y' THEN
2853
2854 IF l_sales_order_id is null THEN
2855 l_sales_order_id :=
2856 OE_SCHEDULE_UTIL.Get_mtl_sales_order_id
2857 (l_line_rec.header_id);
2858 END IF;
2859
2860 -- INVCONV - MERGED CALLS FOR OE_LINE_UTIL.Get_Reserved_Quantity and OE_LINE_UTIL.Get_Reserved_Quantity2
2861
2862 OE_LINE_UTIL.Get_Reserved_Quantities(p_header_id => l_sales_order_id
2863 ,p_line_id => l_line_rec.line_id
2864 ,p_org_id => l_line_rec.ship_from_org_id
2865 ,x_reserved_quantity => l_line_rec.reserved_quantity
2866 ,x_reserved_quantity2 => l_line_rec.reserved_quantity2
2867 );
2868
2869 /*l_line_rec.reserved_quantity :=
2870 OE_LINE_UTIL.Get_Reserved_Quantity
2871 (p_header_id => l_sales_order_id,
2872 p_line_id => l_line_rec.line_id,
2873 p_org_id => l_line_rec.ship_from_org_id);
2874 l_line_rec.reserved_quantity2 := -- INVCONV
2875 OE_LINE_UTIL.Get_Reserved_Quantity2
2876 (p_header_id => l_sales_order_id,
2877 p_line_id => l_line_rec.line_id,
2878 p_org_id => l_line_rec.ship_from_org_id); */
2879
2880
2881 END IF;
2882 IF l_line_rec.reserved_quantity IS NULL
2883 OR l_line_rec.reserved_quantity = FND_API.G_MISS_NUM
2884 THEN
2885 l_line_rec.reserved_quantity := 0;
2886 END IF;
2887 /*IF l_line_rec.reserved_quantity2 IS NULL -- INVCONV
2888 OR l_line_rec.reserved_quantity2 = FND_API.G_MISS_NUM
2889 THEN
2890 l_line_rec.reserved_quantity2 := 0;
2891 END IF; */
2892
2893
2894
2895 IF NOT Find_Line(l_line_tbl,l_line_rec.line_id) THEN
2896 l_line_tbl(l_line_tbl.count + 1) := l_line_rec;
2897 END IF;
2898
2899 END IF;
2900 ELSE
2901
2902 -- 4382036
2903 OE_Line_Util.Lock_Row(p_line_id => l_line_id,
2904 p_x_line_rec => l_line_rec,
2905 x_return_status => l_return_status);
2906
2907 /* OE_Line_Util.Query_Row
2908 (p_line_id => l_line_id,
2909 x_line_rec => l_line_rec);
2910 */
2911
2912 IF nvl(l_line_rec.shippable_flag,'N') = 'Y' THEN
2913
2914 IF l_sales_order_id is null THEN
2915 l_sales_order_id :=
2916 OE_SCHEDULE_UTIL.Get_mtl_sales_order_id
2917 (l_line_rec.header_id);
2918 END IF;
2919
2920 -- INVCONV - MERGED CALLS FOR OE_LINE_UTIL.Get_Reserved_Quantity and OE_LINE_UTIL.Get_Reserved_Quantity2
2921
2922 OE_LINE_UTIL.Get_Reserved_Quantities(p_header_id => l_sales_order_id
2923 ,p_line_id => l_line_rec.line_id
2924 ,p_org_id => l_line_rec.ship_from_org_id
2925 ,x_reserved_quantity => l_line_rec.reserved_quantity
2926 ,x_reserved_quantity2 => l_line_rec.reserved_quantity2
2927 );
2928
2929 /* l_line_rec.reserved_quantity :=
2930 OE_LINE_UTIL.Get_Reserved_Quantity
2931 (p_header_id => l_sales_order_id,
2932 p_line_id => l_line_rec.line_id,
2933 p_org_id => l_line_rec.ship_from_org_id);
2934 l_line_rec.reserved_quantity2 :=
2935 OE_LINE_UTIL.Get_Reserved_Quantity2
2936 (p_header_id => l_sales_order_id,
2937 p_line_id => l_line_rec.line_id,
2938 p_org_id => l_line_rec.ship_from_org_id); */
2939
2940 END IF;
2941 IF l_line_rec.reserved_quantity IS NULL
2942 OR l_line_rec.reserved_quantity = FND_API.G_MISS_NUM
2943 THEN
2944 l_line_rec.reserved_quantity := 0;
2945 END IF;
2946 /* IF l_line_rec.reserved_quantity2 IS NULL -- INVCONV
2947 OR l_line_rec.reserved_quantity2 = FND_API.G_MISS_NUM
2948 THEN
2949 l_line_rec.reserved_quantity2 := 0;
2950 END IF; */
2951
2952
2953 /* Check_Merge_Line(p_x_line_tbl => x_line_tbl
2954 , p_line_rec => l_line_rec ); */ -- Bug-2454163
2955
2956 IF NOT Find_Line(l_line_tbl,l_line_rec.line_id) THEN
2957 l_line_tbl(l_line_tbl.count + 1) := l_line_rec;
2958 END IF;
2959
2960 IF l_item_type_code = 'CLASS'
2961 OR l_item_type_code = 'KIT'
2962 THEN
2963
2964 Oe_Config_Schedule_Pvt.Query_Set_Lines
2965 (p_header_id => l_header_id,
2966 p_link_to_line_id => l_line_id,
2967 p_sch_action => p_sch_action,
2968 x_line_tbl => x_line_tbl,
2969 x_return_status => l_return_status);
2970
2971 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2972 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2973 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2974 l_line_tbl.delete(l_line_tbl.count);
2975 END IF;
2976
2977
2978 /* Check_Merge_Line(p_x_line_tbl => x_line_tbl
2979 ,p_line_tbl => l_line_tbl); */ --Bug-2454163
2980
2981 J := l_line_tbl.count;
2982 FOR I IN 1..x_line_tbl.count LOOP
2983 IF NOT Find_Line(l_line_tbl,x_line_tbl(I).line_id) THEN
2984 J := J + 1;
2985 l_line_tbl(J) := x_line_tbl(I);
2986 END IF;
2987 END LOOP;
2988
2989
2990 END IF; -- Class or Kit.
2991
2992 END IF; -- group query or single query.
2993
2994 END IF; -- l_query.
2995
2996
2997 END IF; -- do or do not.
2998
2999 END LOOP;
3000
3001 /* Bug 2319608
3002 FOR k IN 1..x_line_tbl.COUNT LOOP
3003 l_line_tbl(k) := x_line_tbl(k);
3004 END LOOP;
3005 */
3006 x_line_tbl.delete;
3007 J := 0;
3008 FOR I IN 1..l_line_tbl.count LOOP
3009
3010 OE_MSG_PUB.set_msg_context
3011 ( p_entity_code => 'LINE'
3012 ,p_entity_id => l_line_tbl(I).line_id
3013 ,p_header_id => l_line_tbl(I).header_id
3014 ,p_line_id => l_line_tbl(I).line_id
3015 ,p_orig_sys_document_ref => l_line_tbl(I).orig_sys_document_ref
3016 ,p_orig_sys_document_line_ref => l_line_tbl(I).orig_sys_line_ref
3017 ,p_orig_sys_shipment_ref => l_line_tbl(I).orig_sys_shipment_ref
3018 ,p_change_sequence => l_line_tbl(I).change_sequence
3019 ,p_source_document_id => l_line_tbl(I).source_document_id
3020 ,p_source_document_line_id => l_line_tbl(I).source_document_line_id
3021 ,p_order_source_id => l_line_tbl(I).order_source_id
3022 ,p_source_document_type_id => l_line_tbl(I).source_document_type_id);
3023
3024
3025 IF l_line_tbl(I).schedule_status_code is not null THEN
3026
3027 -- Pack J
3028 -- Check for Partial reservation flag when the line is partially reserved
3029 IF nvl(l_line_tbl(I).shippable_flag,'N') = 'Y'
3030 AND ((l_line_tbl(I).reserved_quantity = 0)
3031 OR ( OE_CODE_CONTROL.Get_Code_Release_Level >= '110510'
3032 --AND OE_SYS_PARAMETERS.value('PARTIAL_RESERVATION_FLAG')= 'Y'
3033 AND l_line_tbl(I).ordered_quantity >
3034 l_line_tbl(I).reserved_quantity)) THEN
3035
3036 IF l_debug_level > 0 THEN
3037 oe_debug_pub.add( 'NEED TO RESERVE THE LINE' , 2 ) ;
3038 END IF;
3039
3040 -- Check if the line is eligible for reservation.
3041 l_return_status := FND_API.G_RET_STS_SUCCESS;
3042 OE_SCHEDULE_UTIL.Validate_Line(p_line_rec => l_line_tbl(I),
3043 p_old_line_rec => l_line_tbl(I),
3044 p_sch_action => p_sch_action,
3045 x_return_status => l_return_status);
3046
3047 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
3048 --Pack J
3049 -- To calculate the remaining quantity to be reserved
3050 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510'
3051 --AND OE_SYS_PARAMETERS.value('PARTIAL_RESERVATION_FLAG')= 'Y'
3052 AND l_line_tbl(I).ordered_quantity >
3053 l_line_tbl(I).reserved_quantity THEN
3054 l_quantity_to_reserve := l_line_tbl(I).ordered_quantity - l_line_tbl(I).reserved_quantity;
3055 ELSE
3056 l_quantity_to_reserve := l_line_tbl(I).ordered_quantity;
3057 END IF;
3058
3059 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' -- INVCONV
3060 --AND OE_SYS_PARAMETERS.value('PARTIAL_RESERVATION_FLAG')= 'Y'
3061 AND l_line_tbl(I).ordered_quantity2 >
3062 l_line_tbl(I).reserved_quantity2 THEN
3063 l_quantity2_to_reserve := l_line_tbl(I).ordered_quantity2 - l_line_tbl(I).reserved_quantity2;
3064 ELSE
3065 l_quantity2_to_reserve := l_line_tbl(I).ordered_quantity2;
3066 END IF;
3067
3068 IF l_quantity2_to_reserve = 0 -- INVCONV
3069 THEN
3070 l_quantity2_to_reserve := NULL;
3071 END IF;
3072
3073 IF l_debug_level > 0 THEN
3074 oe_debug_pub.add( 'QUANTITY TO RESERVE '||l_quantity_to_reserve , 2 ) ;
3075 oe_debug_pub.add( 'QUANTITY2 TO RESERVE '||l_quantity2_to_reserve , 2 ) ;
3076 END IF;
3077 IF nvl(l_line_tbl(I).reserved_quantity,0) > 0 THEN
3078 l_rsv_update := TRUE;
3079 END IF;
3080
3081 OE_SCHEDULE_UTIL.Reserve_Line
3082 (p_line_rec => l_line_tbl(I)
3083 ,p_quantity_to_reserve => l_quantity_to_reserve --l_line_tbl(I).ordered_quantity
3084 ,p_quantity2_to_reserve => l_quantity2_to_reserve --l_line_tbl(I).ordered_quantity2 -- INVCONV
3085 ,p_rsv_update => l_rsv_update
3086 ,x_return_status => l_return_status);
3087
3088 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3089 IF l_debug_level > 0 THEN
3090 oe_debug_pub.add( 'RAISING UNEXPECTED ERROR' , 1 ) ;
3091 END IF;
3092 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3093 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3094 IF l_debug_level > 0 THEN
3095 oe_debug_pub.add( 'WILL IGNORE THE LINE AND PROCEED' , 1 ) ;
3096 END IF;
3097 l_return_status := FND_API.G_RET_STS_SUCCESS;
3098 END IF;
3099
3100 END IF; -- Return status
3101 ELSE
3102 -- code fix for 3300528
3103 IF nvl(l_line_tbl(I).shippable_flag,'N') = 'N'
3104 THEN
3105 IF l_line_tbl(I).ato_line_id IS NOT NULL AND
3106 NOT ( l_line_tbl(I).ato_line_id = l_line_tbl(I).line_id AND
3107 l_line_tbl(I).item_type_code IN ( OE_GLOBALS.G_ITEM_OPTION,
3108 OE_GLOBALS.G_ITEM_STANDARD,OE_GLOBALS.G_ITEM_INCLUDED)) -- 9775352
3109 THEN -- check for ato
3110 FND_MESSAGE.SET_NAME('ONT','OE_SCH_RES_NO_CONFIG');
3111 IF l_debug_level > 0 THEN
3112 oe_debug_pub.add( 'NON SHIPPABLE ATO LINE' , 2 ) ;
3113 END IF;
3114 ELSE
3115 FND_MESSAGE.SET_NAME('ONT','ONT_SCH_NOT_RESERVABLE');
3116 END IF;-- end check for ato
3117 ELSE
3118 FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_ACTION_DONE_NO_EXP');
3119 IF l_debug_level > 0 THEN
3120 oe_debug_pub.add( 'ALREADY RESERVED' , 2 ) ;
3121 END IF;
3122 END IF; -- shippable flag
3123 OE_MSG_PUB.Add;
3124 -- code fix for 3300528
3125 END IF; -- shippable flag and reserved quantity
3126 ELSE
3127
3128 J := J +1;
3129 x_line_tbl(J) := l_line_tbl(I);
3130
3131 END IF;
3132 END LOOP;
3133
3134 IF l_debug_level > 0 THEN
3135 oe_debug_pub.add( 'EXITING QUERY RESERVE LINES' , 1 ) ;
3136 END IF;
3137
3138
3139 EXCEPTION
3140
3141
3142 WHEN FND_API.G_EXC_ERROR THEN
3143 IF l_debug_level > 0 THEN
3144 oe_debug_pub.add( 'EXPECTED ERROR IN QUERY_RESERVE_LINES ' , 1 ) ;
3145 END IF;
3146 RAISE FND_API.G_EXC_ERROR;
3147
3148 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3149
3150 IF l_debug_level > 0 THEN
3151 oe_debug_pub.add( 'UNEXPECTED ERROR IN QUERY_RESERVE_LINES ' , 1 ) ;
3152 END IF;
3153 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3154
3155 -- Start 2742982 --
3156 WHEN NO_DATA_FOUND THEN
3157 FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_ACTION_DONE_NO_EXP');
3158 OE_MSG_PUB.Add;
3159 RAISE FND_API.G_EXC_ERROR;
3160 -- End 2742982 --
3161
3162 WHEN OTHERS THEN
3163
3164 IF l_debug_level > 0 THEN
3165 oe_debug_pub.add( 'WHEN OTHERS ERROR IN QUERY_RESERVE_LINES ' , 1 ) ;
3166 END IF;
3167 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3168 THEN
3169 OE_MSG_PUB.Add_Exc_Msg
3170 ( G_PKG_NAME
3171 , 'Validate_Group_Line'
3172 );
3173 END IF;
3174
3175 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3176 END Query_Reserve_Lines;
3177
3178 /*----------------------------------------------------------------
3179 PROCEDURE Query_ATP_CHECK_Lines
3180 Description : This api will be called from schedule_multi_line API when
3181 action requested by user is reserve.
3182 System has to perform little validations before passing record back to the user.
3183 Initially system selects few scheduling related attributes to see whether the
3184 line has to be selected for atp_check or not. If it has to be selected then
3185 check if it is part of model and parent is also selected by user. If Model is selected by user we will ignore the line or else we will select the line for
3186 processing. If the line selected is Included item, make sure not only it's modle is selected, also check for its immediate parent. If its immediate parent is selected then ignore the included item, since included item will be selected by it's parent.
3187
3188 If top model is selected for processing or line part of smc or ato then query whole model. If class or kit is selected then select its included items as well.If line is selected which is part of set then select whole set for processing
3189
3190 ------------------------------------------------------------------*/
3191 PROCEDURE Query_ATP_CHECK_Lines
3192 ( p_selected_tbl IN OE_GLOBALS.Selected_record_Tbl, --R12.MOAC
3193 p_sch_action IN VARCHAR2,
3194 x_line_tbl IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
3195 )
3196 IS
3197 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
3198 l_line_rec OE_Order_PUB.Line_rec_Type;
3199 l_line_id NUMBER;
3200 l_arrival_set_id NUMBER;
3201 l_ship_set_id NUMBER;
3202 l_top_model_line_id NUMBER;
3203 l_ato_line_id NUMBER;
3204 l_smc_flag VARCHAR2(1);
3205 l_item_type_code VARCHAR2(30);
3206 l_schedule_status_code VARCHAR2(30);
3207 l_line_category_code VARCHAR2(30);
3208 l_source_type_code VARCHAR2(30);
3209 l_link_to_line_id NUMBER;
3210 l_query VARCHAR2(1);
3211 l_found VARCHAR2(1);
3212 J NUMBER;
3213 l_header_id NUMBER;
3214 l_sales_order_id NUMBER := Null;
3215 l_open_flag VARCHAR2(1);
3216
3217 --
3218 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3219 --
3220 l_orig_sys_document_ref VARCHAR2(50);
3221 l_orig_sys_line_ref VARCHAR2(50);
3222 l_orig_sys_shipment_ref VARCHAR2(50);
3223 l_source_document_type_id NUMBER;
3224 l_change_sequence VARCHAR2(50);
3225 l_source_document_id NUMBER;
3226 l_source_document_line_id NUMBER;
3227 l_order_source_id NUMBER;
3228 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
3229 l_subscription_enable_flag varchar2(10) := ''; --sol_ord_er #16014165
3230 BEGIN
3231
3232
3233 FOR L IN 1..p_selected_tbl.count LOOP --R12.MOAC
3234 IF l_debug_level > 0 THEN
3235 oe_debug_pub.add( 'PROCESSING LINE_ID ' || P_SELECTED_TBL(L).ID1 , 2 ) ;
3236 END IF;
3237
3238 l_line_id := p_selected_tbl(L).id1;
3239 -- Query required attributes and check does any action is required
3240 -- on the line.
3241 Select Arrival_set_id, Ship_set_id,top_model_line_id,
3242 Ship_model_complete_flag, ato_line_id,item_type_code,
3243 Schedule_status_code,line_category_code,header_id,open_flag,
3244 source_type_code,link_to_line_id,
3245 orig_sys_document_ref, orig_sys_line_ref, orig_sys_shipment_ref,
3246 source_document_type_id, change_sequence, source_document_id,
3247 source_document_line_id, order_source_id,
3248 subscription_enable_flag --sol_ord_er #16014165
3249 Into l_arrival_set_id, l_ship_set_id, l_top_model_line_id,
3250 l_smc_flag, l_ato_line_id, l_item_type_code,
3251 l_schedule_status_code,l_line_category_code,l_header_id,l_open_flag,
3252 l_source_type_code,l_link_to_line_id,
3253 l_orig_sys_document_ref, l_orig_sys_line_ref, l_orig_sys_shipment_ref,
3254 l_source_document_type_id, l_change_sequence, l_source_document_id,
3255 l_source_document_line_id, l_order_source_id,
3256 l_subscription_enable_flag --sol_ord_er #16014165
3257 From oe_order_lines_all
3258 Where line_id = l_line_id;
3259
3260 OE_MSG_PUB.set_msg_context
3261 ( p_entity_code => 'LINE'
3262 ,p_entity_id => l_line_id
3263 ,p_header_id => l_header_id
3264 ,p_line_id => l_line_id
3265 ,p_orig_sys_document_ref => l_orig_sys_document_ref
3266 ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
3267 ,p_orig_sys_shipment_ref => l_orig_sys_shipment_ref
3268 ,p_change_sequence => l_change_sequence
3269 ,p_source_document_id => l_source_document_id
3270 ,p_source_document_line_id => l_source_document_line_id
3271 ,p_order_source_id => l_order_source_id
3272 ,p_source_document_type_id => l_source_document_type_id);
3273
3274 IF l_line_category_code = 'RETURN'
3275 OR l_item_type_code = 'SERVICE'
3276 OR NVL(l_subscription_enable_flag,'N') = 'Y' --sol_ord_er #16014165
3277 OR l_source_type_code = OE_GLOBALS.G_SOURCE_EXTERNAL
3278 OR nvl(l_open_flag,'Y') = 'N' THEN
3279
3280 -- populate the error message and skip the line.
3281 FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_ACTION_DONE_NO_EXP');
3282 OE_MSG_PUB.Add;
3283 ELSE
3284
3285
3286 -- If the line is part of set then avoid selecting them ,
3287 -- since scheduling is prerequisite for sets.
3288 -- Also avoid selecting any line if they are part of ato model or
3289 -- smc and they are scheduled.
3290
3291
3292 l_query := 'Y';
3293
3294 -- If user slectes the non smc model and option,
3295 -- then avoid selecting the
3296 -- option, since model will select the option.
3297
3298 IF l_top_model_line_id IS NOT NULL
3299 AND l_smc_flag = 'N'
3300 AND l_top_model_line_id <> l_line_id THEN
3301
3302 -- Check if model is selected by user.
3303 -- If model is selected then ignore the line for query, since
3304 -- model will query the line.
3305 --R12.MOAC
3306 FOR K IN 1..p_selected_tbl.count LOOP
3307 IF l_top_model_line_id = p_selected_tbl(K).id1
3308 OR (l_item_type_code = OE_GLOBALS.G_ITEM_INCLUDED AND
3309 l_link_to_line_id = p_selected_tbl(K).id1) THEN
3310 l_query := 'N';
3311 exit;
3312 END IF;
3313 END LOOP;
3314
3315 ELSIF x_line_tbl.count > 0 THEN
3316 -- If the line is not a non smc option or class, then check if the
3317 -- line is present in the table.
3318 -- Check if the line is already present. If line exists then
3319 -- ignore the line.
3320
3321 FOR I IN 1..x_line_tbl.count LOOP
3322 IF l_line_id = x_line_tbl(I).line_id
3323 THEN
3324 l_query := 'N';
3325 Exit;
3326 END IF;
3327 END LOOP;
3328 END IF;
3329
3330 IF l_query = 'Y' THEN
3331
3332 -- Decided to query the line. See what to pass to query sets.
3333 IF l_arrival_set_id is not null
3334 OR l_ship_set_id is not null
3335 OR l_smc_flag = 'Y'
3336 OR (l_ato_line_id is not null AND
3337 NOT (l_line_id = l_ato_line_id AND
3338 l_item_type_code IN(OE_GLOBALS.G_ITEM_STANDARD,
3339 OE_GLOBALS.G_ITEM_OPTION,
3340 OE_GLOBALS.G_ITEM_INCLUDED))) --9775352
3341 THEN
3342
3343 IF l_arrival_set_id is not null
3344 OR l_ship_set_id is not null
3345 OR l_smc_flag = 'Y'
3346 THEN
3347
3348 Oe_Config_Schedule_Pvt.Query_Set_Lines
3349 (p_header_id => l_header_id,
3350 p_arrival_set_id => l_arrival_set_id,
3351 p_ship_set_id => l_ship_set_id,
3352 p_model_line_id => l_top_model_line_id,
3353 p_sch_action => p_sch_action,
3354 x_line_tbl => l_line_tbl,
3355 x_return_status => l_return_status);
3356
3357 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3358 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3359 END IF;
3360
3361 ELSE
3362
3363 -- Query ato model.
3364 OE_Config_Util.Query_ATO_Options
3365 ( p_ato_line_id => l_ato_line_id,
3366 x_line_tbl => l_line_tbl);
3367
3368 END IF;
3369
3370 -- query using top_model_line_id / ato line id
3371
3372
3373 IF x_line_tbl.count = 0 THEN
3374
3375 x_line_tbl := l_line_tbl;
3376
3377 ELSE
3378 /* Check_Merge_Line(p_x_line_tbl => x_line_tbl
3379 ,p_line_tbl => l_line_tbl); */ --Bug-2454163
3380
3381 J := x_line_tbl.count;
3382 FOR I IN 1..l_line_tbl.count LOOP
3383 IF NOT Find_Line(x_line_tbl,l_line_tbl(I).line_id) THEN
3384 x_line_tbl(J + I) := l_line_tbl(I);
3385 END IF;
3386 END LOOP;
3387
3388 END IF;
3389
3390 ELSIF l_line_id = l_top_model_line_id THEN
3391
3392 -- This is a non smc top model. User might have selected model
3393 -- and its options. If the model is selected query whole model
3394 -- and try to place them in the
3395 -- out table if they are not present already.
3396
3397 Oe_Config_Schedule_Pvt.Query_Set_Lines
3398 (p_header_id => l_header_id,
3399 p_model_line_id => l_top_model_line_id,
3400 p_sch_action => p_sch_action,
3401 x_line_tbl => l_line_tbl,
3402 x_return_status => l_return_status);
3403
3404 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3405 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3406 END IF;
3407
3408 IF x_line_tbl.count = 0 THEN
3409 x_line_tbl := l_line_tbl;
3410 ELSE
3411
3412 /* Check_Merge_Line(p_x_line_tbl => x_line_tbl
3413 ,p_line_tbl => l_line_tbl); */
3414
3415 J := x_line_tbl.count;
3416 FOR I IN 1..l_line_tbl.count LOOP
3417
3418 IF NOT Find_Line(x_line_tbl,l_line_tbl(I).line_id) THEN
3419 J := J + 1;
3420 x_line_tbl(J) := l_line_tbl(I);
3421 END IF;
3422 END LOOP;
3423
3424 END IF;
3425 ELSE
3426
3427
3428 OE_Line_Util.Query_Row
3429 (p_line_id => l_line_id,
3430 x_line_rec => l_line_rec);
3431
3432 IF nvl(l_line_rec.shippable_flag,'N') = 'Y' THEN
3433
3434 IF l_sales_order_id is null THEN
3435 l_sales_order_id :=
3436 OE_SCHEDULE_UTIL.Get_mtl_sales_order_id
3437 (l_line_rec.header_id);
3438 END IF;
3439
3440 l_line_rec.reserved_quantity :=
3441 OE_LINE_UTIL.Get_Reserved_Quantity
3442 (p_header_id => l_sales_order_id,
3443 p_line_id => l_line_rec.line_id,
3444 p_org_id => l_line_rec.ship_from_org_id);
3445 l_line_rec.reserved_quantity2 := -- INVCONV
3446 OE_LINE_UTIL.Get_Reserved_Quantity
3447 (p_header_id => l_sales_order_id,
3448 p_line_id => l_line_rec.line_id,
3449 p_org_id => l_line_rec.ship_from_org_id);
3450 END IF;
3451 IF l_line_rec.reserved_quantity IS NULL
3452 OR l_line_rec.reserved_quantity = FND_API.G_MISS_NUM
3453 THEN
3454 l_line_rec.reserved_quantity := 0;
3455 END IF;
3456
3457 /*IF l_line_rec.reserved_quantity2 IS NULL -- INVCONV
3458 OR l_line_rec.reserved_quantity2 = FND_API.G_MISS_NUM
3459 THEN
3460 l_line_rec.reserved_quantity2 := 0;
3461 END IF; */
3462 /* Check_Merge_Line(p_line_rec => l_line_rec
3463 ,p_x_line_tbl => x_line_tbl); */ --Bug-2454163
3464
3465 IF NOT Find_Line(x_line_tbl,l_line_rec.line_id) THEN
3466 x_line_tbl(x_line_tbl.count + 1) := l_line_rec;
3467 END IF;
3468
3469 IF l_item_type_code = 'CLASS'
3470 OR l_item_type_code = 'KIT'
3471 THEN
3472
3473 Oe_Config_Schedule_Pvt.Query_Set_Lines
3474 (p_header_id => l_header_id,
3475 p_link_to_line_id => l_line_id,
3476 p_sch_action => p_sch_action,
3477 x_line_tbl => l_line_tbl,
3478 x_return_status => l_return_status);
3479
3480 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3481 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3482 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3483 x_line_tbl.delete(x_line_tbl.count);
3484
3485 END IF;
3486
3487 /* Check_Merge_Line(p_x_line_tbl => x_line_tbl
3488 ,p_line_tbl => l_line_tbl); */ -- Bug-2454163
3489
3490 J := x_line_tbl.count;
3491 FOR I IN 1..l_line_tbl.count LOOP
3492 IF NOT Find_Line(x_line_tbl,l_line_tbl(I).line_id) THEN
3493 J := J + 1;
3494 x_line_tbl(J) := l_line_tbl(I);
3495 END IF;
3496 END LOOP;
3497
3498 END IF; -- Class or Kit.
3499 END IF; -- group query or single query.
3500
3501 END IF; -- l_query.
3502
3503 END IF; -- do or do not.
3504 END LOOP;
3505
3506
3507 EXCEPTION
3508
3509
3510 WHEN FND_API.G_EXC_ERROR THEN
3511 IF l_debug_level > 0 THEN
3512 oe_debug_pub.add( 'EXPECTED ERROR IN QUERY_ATP_CHECK_LINES ' , 1 ) ;
3513 END IF;
3514 RAISE FND_API.G_EXC_ERROR;
3515
3516 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3517
3518 IF l_debug_level > 0 THEN
3519 oe_debug_pub.add( 'UNEXPECTED ERROR IN QUERY_ATP_CHECK_LINES ' , 1 ) ;
3520 END IF;
3521 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3522
3523 -- Start 2742982 --
3524 WHEN NO_DATA_FOUND THEN
3525 FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_ACTION_DONE_NO_EXP');
3526 OE_MSG_PUB.Add;
3527 -- End 2742982 --
3528
3529 WHEN OTHERS THEN
3530
3531 IF l_debug_level > 0 THEN
3532 oe_debug_pub.add( 'WHEN OTHERS ERROR IN QUERY_ATP_CHECK_LINES ' , 1 ) ;
3533 END IF;
3534 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3535 THEN
3536 OE_MSG_PUB.Add_Exc_Msg
3537 ( G_PKG_NAME
3538 , 'Query_ATP_CHECK_Lines'
3539 );
3540 END IF;
3541
3542 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3543 END Query_ATP_CHECK_Lines;
3544
3545
3546 /* ---------------------------------------------------------------
3547 Procedure Schedule_Order
3548 This procedure will be called from pld when user performs any scheduling
3549 activity from header level.
3550 An order can consists of many lines and each line can be within a group.
3551 Call MRP for all lines at once. After calling the MRP for scheduling action
3552 loop through the table and ignore all lines that failed the scheduling and
3553 call process order for the lines that successfuly passed scheduling.
3554 ---------------------------------------------------------------*/
3555 Procedure Schedule_Order(p_header_id IN NUMBER,
3556 p_sch_action IN VARCHAR2,
3557 x_atp_tbl OUT NOCOPY /* file.sql.39 change */ OE_ATP.Atp_Tbl_Type,
3558 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
3559 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
3560 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
3561 IS
3562
3563 l_line_tbl OE_ORDER_PUB.Line_tbl_type;
3564 l_old_line_tbl OE_ORDER_PUB.Line_tbl_type;
3565 l_return_status VARCHAR2(1);
3566 l_msg_count NUMBER;
3567 l_msg_data VARCHAR2(2000);
3568
3569 -- Need to remove this.
3570 l_atp_tbl OE_ATP.atp_tbl_type;
3571 --
3572 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3573 --
3574 BEGIN
3575
3576 x_return_status := FND_API.G_RET_STS_SUCCESS;
3577 IF l_debug_level > 0 THEN
3578 oe_debug_pub.add( 'ENTERING OE_GROUP_SCH_UTIL.SCHEDULE_ORDER' , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
3579 END IF;
3580
3581 IF l_debug_level > 0 THEN
3582 oe_debug_pub.add( 'P_HEADER_ID : ' || P_HEADER_ID , 1 ) ;
3583 END IF;
3584 IF l_debug_level > 0 THEN
3585 oe_debug_pub.add( 'P_SCH_ACTION: ' || P_SCH_ACTION , 1 ) ;
3586 END IF;
3587
3588 -- Start 2434807 -
3589 -- Added to clear existing records from g_atp_tbl
3590 -- before starting scheduling event
3591 IF p_sch_action <> OE_SCHEDULE_UTIL.OESCH_ACT_ATP_CHECK THEN
3592 Oe_Schedule_Util.g_atp_tbl.delete;
3593 END IF;
3594 -- End 2434807 -
3595
3596
3597 Query_Lines(p_header_id => p_header_id,
3598 p_sch_action => p_sch_action,
3599 x_line_tbl => l_line_tbl);
3600
3601 l_old_line_tbl := l_line_tbl;
3602
3603 IF p_sch_action = OE_SCHEDULE_UTIL.OESCH_ACT_ATP_CHECK THEN
3604 IF l_debug_level > 0 THEN
3605 oe_debug_pub.add( 'BEFORE CALLING MULTI_ATP_CHECK ' ) ;
3606 END IF;
3607 IF l_debug_level > 0 THEN
3608 oe_debug_pub.add( 'COUNT ' || L_LINE_TBL.COUNT ) ;
3609 END IF;
3610
3611 IF l_line_tbl.count > 0 THEN
3612
3613 OE_SCHEDULE_UTIL.Multi_ATP_CHECK
3614 (p_old_line_tbl => l_old_line_tbl,
3615 p_x_line_tbl => l_line_tbl,
3616 x_atp_tbl => x_atp_tbl,
3617 x_return_status => x_return_status);
3618
3619 ELSE
3620
3621 FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_ACTION_DONE_NO_EXP');
3622 OE_MSG_PUB.Add;
3623 END IF;
3624
3625 ELSE
3626
3627 IF l_debug_level > 0 THEN
3628 oe_debug_pub.add( 'BEFORE CALLING PROCESS SCHEDULING GROUP ' ) ;
3629 END IF;
3630 IF l_debug_level > 0 THEN
3631 oe_debug_pub.add( 'COUNT ' || L_LINE_TBL.COUNT ) ;
3632 END IF;
3633 IF l_debug_level > 0 THEN
3634 oe_debug_pub.add( 'FIRST ' || L_LINE_TBL.FIRST ) ;
3635 END IF;
3636 IF l_debug_level > 0 THEN
3637 oe_debug_pub.add( 'LAST ' || L_LINE_TBL.LAST ) ;
3638 END IF;
3639
3640 IF l_line_tbl.count > 0 THEN
3641
3642 Oe_Config_Schedule_Pvt.Process_Group
3643 (p_x_line_tbl => l_line_tbl
3644 ,p_old_line_tbl => l_old_line_tbl
3645 ,p_caller => 'UI_ACTION'
3646 ,p_sch_action => p_sch_action
3647 ,p_partial => TRUE
3648 ,x_return_status => x_return_status);
3649 ELSE
3650
3651 IF p_sch_action <> OE_SCHEDULE_UTIL.OESCH_ACT_RESERVE THEN
3652 FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_ACTION_DONE_NO_EXP');
3653 OE_MSG_PUB.Add;
3654 END IF;
3655 END IF;
3656
3657 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3658 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3659 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
3660 RAISE FND_API.G_EXC_ERROR;
3661 END IF;
3662
3663 END IF;
3664
3665 oe_msg_pub.count_and_get
3666 (p_count => x_msg_count
3667 ,p_data => x_msg_data);
3668
3669 IF l_debug_level > 0 THEN
3670 oe_debug_pub.add( 'COUNT IS ' || X_MSG_COUNT , 1 ) ;
3671 END IF;
3672 IF l_debug_level > 0 THEN
3673 oe_debug_pub.add( 'EXITING OE_GROUP_SCH_UTIL.SCHEDULE_ORDER' , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
3674 END IF;
3675 x_return_status := FND_API.G_RET_STS_SUCCESS;
3676
3677 EXCEPTION
3678
3679 WHEN FND_API.G_EXC_ERROR THEN
3680
3681 x_return_status := FND_API.G_RET_STS_ERROR;
3682
3683 oe_msg_pub.count_and_get
3684 ( p_count => x_msg_count
3685 ,p_data => x_msg_data
3686 );
3687
3688 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3689
3690 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3691
3692 oe_msg_pub.count_and_get
3693 ( p_count => x_msg_count
3694 ,p_data => x_msg_data
3695 );
3696
3697 WHEN OTHERS THEN
3698
3699 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3700
3701 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3702 THEN
3703 OE_MSG_PUB.Add_Exc_Msg
3704 ( G_PKG_NAME
3705 , 'Schedule_Order'
3706 );
3707 END IF;
3708
3709 oe_msg_pub.count_and_get
3710 ( p_count => x_msg_count
3711 ,p_data => x_msg_data
3712 );
3713 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3714 END Schedule_Order;
3715 /*---------------------------------------------------------------
3716 Procedure :Schedule_Multi_lines
3717 This procedure is called when lines are multi-selected and
3718 scheduling action is performed.
3719 Based on the requested action this API will call appropriate
3720 query api's which will get all approprite a lines. Based on the
3721 action call process group or multi atp check.
3722 ---------------------------------------------------------------*/
3723 Procedure Schedule_Multi_lines
3724 (p_selected_line_tbl IN OE_GLOBALS.Selected_Record_Tbl, --R12.MOAC
3725 p_line_count IN NUMBER,
3726 p_sch_action IN VARCHAR2,
3727 x_atp_tbl OUT NOCOPY /* file.sql.39 change */ OE_ATP.Atp_Tbl_Type,
3728 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
3729 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
3730 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
3731 IS
3732 j Integer;
3733 initial Integer;
3734 nextpos Integer;
3735 --3751812
3736 --l_record_ids VARCHAR2(2000) := p_line_list || ',';
3737 --l_record_ids VARCHAR2(32000) := p_line_list || ',';
3738
3739 l_line_id NUMBER;
3740
3741 l_line_tbl OE_ORDER_PUB.line_tbl_type;
3742 l_old_line_tbl OE_ORDER_PUB.line_tbl_type;
3743 l_line_id_tbl number_arr;
3744 l_set_rec OE_ORDER_CACHE.set_rec_type;
3745
3746 --
3747 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3748 --
3749 BEGIN
3750 IF l_debug_level > 0 THEN
3751 oe_debug_pub.add( 'ENTERING SCHEDULE_MULTI_LINES' , 1 ) ;
3752 oe_debug_pub.add( 'LINE COUNT IS: ' || P_LINE_COUNT , 1 ) ;
3753 oe_debug_pub.add( 'ACTION IS: ' || P_SCH_ACTION , 1 ) ;
3754 END IF;
3755
3756 -- Start 2434807 -
3757 -- Added to clear existing records from g_atp_tbl
3758 -- before starting scheduling event
3759 IF p_sch_action <> OE_SCHEDULE_UTIL.OESCH_ACT_ATP_CHECK THEN
3760 Oe_Schedule_Util.g_atp_tbl.delete;
3761 END IF;
3762 -- End 2434807 -
3763
3764 x_return_status := FND_API.G_RET_STS_SUCCESS;
3765 --R12.MOAC
3766 /*
3767 j := 1;
3768 initial := 1;
3769 nextpos := INSTR(l_record_ids,',',1,j) ;
3770
3771 FOR I IN 1..p_line_count LOOP
3772
3773 l_line_id := to_number(substr(l_record_ids,initial, nextpos-initial));
3774 l_line_id_tbl(j) := l_line_id;
3775
3776 IF l_debug_level > 0 THEN
3777 oe_debug_pub.add( 'LINE_ID : ' || L_LINE_ID , 1 ) ;
3778 END IF;
3779
3780 initial := nextpos + 1.0;
3781 j := j + 1.0;
3782 nextpos := INSTR(l_record_ids,',',1,j) ;
3783
3784 END LOOP;
3785 */
3786 IF p_sch_action = OE_SCHEDULE_UTIL.OESCH_ACT_SCHEDULE THEN
3787
3788 Query_Schedule_lines(p_sch_action => p_sch_action,
3789 p_selected_tbl => p_selected_line_tbl, --R12.MOAC
3790 x_line_tbl => l_line_tbl);
3791
3792 ELSIF p_sch_action = OE_SCHEDULE_UTIL.OESCH_ACT_UNSCHEDULE THEN
3793
3794 Query_Unschedule_lines(p_sch_action => p_sch_action,
3795 p_selected_tbl => p_selected_line_tbl, --R12.MOAC
3796 x_line_tbl => l_line_tbl);
3797
3798 ELSIF p_sch_action = OE_SCHEDULE_UTIL.OESCH_ACT_UNRESERVE THEN
3799
3800 Query_Unreserve_lines(p_sch_action => p_sch_action,
3801 p_selected_tbl => p_selected_line_tbl, --R12.MOAC
3802 x_line_tbl => l_line_tbl);
3803
3804 ELSIF p_sch_action = OE_SCHEDULE_UTIL.OESCH_ACT_RESERVE THEN
3805
3806 Query_Reserve_lines(p_sch_action => p_sch_action,
3807 p_selected_tbl => p_selected_line_tbl, --R12.MOAC
3808 x_line_tbl => l_line_tbl);
3809
3810 ELSIF p_sch_action = OE_SCHEDULE_UTIL.OESCH_ACT_ATP_CHECK THEN
3811 --Bug 5881611
3812 --Creating a savepoint, so that it can be be rolled for ATP Checks.
3813 --This is to rollback updates to database made by Availability window, which
3814 --calls process_included_items to explode included items and oe_order_pvt.lines
3815 --which updates the database tables.
3816 oe_debug_pub.add('Creating a savepoint for ATP Check activity.');
3817 SAVEPOINT SP_ONLY_ATP_CHECK;
3818 Query_ATP_CHECK_lines(p_sch_action => p_sch_action,
3819 p_selected_tbl => p_selected_line_tbl, --R12.MOAC
3820 x_line_tbl => l_line_tbl);
3821 END IF;
3822
3823 IF l_line_tbl.count > 0 THEN
3824
3825 IF l_debug_level > 0 THEN
3826 oe_debug_pub.add('No lines to process : '||l_line_tbl.count,1);
3827 END IF;
3828
3829 Validate_Group
3830 (p_x_line_tbl => l_line_tbl,
3831 p_sch_action => p_sch_action,
3832 p_validate_action => 'COMPLETE', --added for bug 3590437
3833 x_return_status => x_return_status);
3834
3835 --3990887
3836 --END IF;
3837
3838 IF l_debug_level > 0 THEN
3839 oe_debug_pub.add( ' AFTER VALIDATE_GROUP : '||x_return_status,1);
3840 END IF;
3841
3842 -- 3990887
3843 IF x_return_status = FND_API.G_RET_STS_SUCCESS THEN
3844
3845 ----------- set up the tables -------------------------
3846 l_old_line_tbl := l_line_tbl;
3847
3848 FOR I IN 1..l_line_tbl.count LOOP
3849
3850 IF l_debug_level > 0 THEN
3851 oe_debug_pub.add( ' LINE ID : ' || L_LINE_TBL ( I ) .LINE_ID , 4 ) ;
3852 END IF;
3853 l_line_tbl(I).operation := OE_GLOBALS.G_OPR_UPDATE;
3854 l_line_tbl(I).schedule_action_code := p_sch_action;
3855
3856 IF (l_line_tbl(I).arrival_set_id is not null) THEN
3857 l_set_rec := OE_ORDER_CACHE.Load_Set
3858 (l_line_tbl(I).arrival_set_id);
3859 l_line_tbl(I).arrival_set := l_set_rec.set_name;
3860 ELSIF (l_line_tbl(I).ship_set_id is not null) THEN
3861 l_set_rec := OE_ORDER_CACHE.Load_Set
3862 (l_line_tbl(I).ship_set_id);
3863 l_line_tbl(I).ship_set := l_set_rec.set_name;
3864 ELSIF (l_line_tbl(I).ship_model_complete_flag ='Y') THEN
3865 l_line_tbl(I).ship_set := l_line_tbl(I).top_model_line_id;
3866 ELSIF (l_line_tbl(I).ato_line_id is not null)
3867 AND NOT(OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510'
3868 AND MSC_ATP_GLOBAL.GET_APS_VERSION = 10)
3869 THEN
3870 l_line_tbl(I).ship_set := l_line_tbl(I).ato_line_id;
3871 END IF;
3872
3873 END LOOP;
3874
3875 ------- Action Specific processing -----------------------
3876 -- 3990887
3877 IF p_sch_action = OE_SCHEDULE_UTIL.OESCH_ACT_ATP_CHECK
3878 THEN
3879 --Bug 5881611
3880 --Rolling back
3881 oe_debug_pub.add('Rollback for only atp check');
3882 oe_delayed_requests_pvt.Clear_Request(
3883 x_return_status => x_return_status);
3884 ROLLBACK TO SAVEPOINT SP_ONLY_ATP_CHECK;
3885
3886 IF l_debug_level > 0 THEN
3887 oe_debug_pub.add( 'BEFORE CALLING MULTI_ATP_CHECK ' ) ;
3888 END IF;
3889 IF l_debug_level > 0 THEN
3890 oe_debug_pub.add( 'LINE COUNT ' || L_LINE_TBL.COUNT , 1 ) ;
3891 END IF;
3892
3893 OE_SCHEDULE_UTIL.Multi_ATP_CHECK
3894 (p_old_line_tbl => l_old_line_tbl,
3895 p_x_line_tbl => l_line_tbl,
3896 x_atp_tbl => x_atp_tbl,
3897 x_return_status => x_return_status);
3898
3899 ELSE
3900
3901 IF l_debug_level > 0 THEN
3902 oe_debug_pub.add( 'BEFORE CALLING PROCESS SCHEDULING GROUP ' ) ;
3903 oe_debug_pub.add( 'LINE COUNT ' || L_LINE_TBL.COUNT , 1 ) ;
3904 END IF;
3905
3906 -- 3870895 : call process_group only when coun > 0 and return status is success
3907 IF l_line_tbl.count > 0
3908 AND x_return_status = FND_API.G_RET_STS_SUCCESS
3909 THEN
3910
3911 Oe_Config_Schedule_Pvt.Process_Group
3912 (p_x_line_tbl => l_line_tbl
3913 ,p_old_line_tbl => l_old_line_tbl
3914 ,p_caller => 'UI_ACTION'
3915 ,p_sch_action => p_sch_action
3916 ,p_partial => TRUE
3917 ,x_return_status => x_return_status);
3918
3919 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3920 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3921 -- ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
3922 -- RAISE FND_API.G_EXC_ERROR;
3923 END IF;
3924
3925 ELSE
3926 IF p_sch_action <> OE_SCHEDULE_UTIL.OESCH_ACT_RESERVE
3927 AND p_sch_action <> OE_SCHEDULE_UTIL.OESCH_ACT_ATP_CHECK
3928 THEN
3929 FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_ACTION_DONE_NO_EXP');
3930 OE_MSG_PUB.Add;
3931 END IF;
3932 END IF;
3933
3934 IF l_debug_level > 0 THEN
3935 oe_debug_pub.add( 'AFTER PROCESS GROUP' || X_RETURN_STATUS , 1 ) ;
3936 END IF;
3937 END IF;
3938 -- Set return status.
3939
3940 END IF;
3941 END IF; -- 3990887
3942
3943 oe_msg_pub.count_and_get
3944 ( p_count => x_msg_count
3945 , p_data => x_msg_data);
3946
3947 IF l_debug_level > 0 THEN
3948 oe_debug_pub.add( ' MESSAGE COUNT: ' || X_MSG_COUNT , 1 ) ;
3949 END IF;
3950 -- Set return status.
3951
3952 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3953 RAISE FND_API.G_EXC_ERROR;
3954
3955 END IF;
3956
3957
3958 -- Returning success, even if there were errors (unexpected errors will
3959 -- be raised and taken care of). This is because we do not want to rollback
3960 -- since the successful lines should get committed.
3961
3962 x_return_status := FND_API.G_RET_STS_SUCCESS;
3963
3964 /* -- Get message count and data
3965
3966 oe_msg_pub.count_and_get
3967 ( p_count => x_msg_count
3968 , p_data => x_msg_data
3969 );
3970
3971 */
3972 IF l_debug_level > 0 THEN
3973 oe_debug_pub.add( 'EXITING SCHEDULE_MULTI_LINES WITH: ' || X_RETURN_STATUS , 1 ) ;
3974 END IF;
3975
3976 EXCEPTION
3977
3978 WHEN FND_API.G_EXC_ERROR THEN
3979
3980 x_return_status := FND_API.G_RET_STS_ERROR;
3981
3982 -- Get message count and data
3983
3984 oe_msg_pub.count_and_get
3985 ( p_count => x_msg_count
3986 , p_data => x_msg_data
3987 );
3988
3989 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3990
3991 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
3992
3993 -- Get message count and data
3994
3995 oe_msg_pub.count_and_get
3996 ( p_count => x_msg_count
3997 , p_data => x_msg_data
3998 );
3999
4000 WHEN OTHERS THEN
4001
4002 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4003
4004 IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
4005 THEN
4006 oe_msg_pub.Add_Exc_Msg
4007 ( G_PKG_NAME,
4008 'Schedule_Multi_lines'
4009 );
4010 END IF;
4011
4012 -- Get message count and data
4013
4014 oe_msg_pub.count_and_get
4015 ( p_count => x_msg_count
4016 , p_data => x_msg_data
4017 );
4018
4019 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4020 END Schedule_Multi_lines;
4021 /* ------------------------------------------------------------
4022 Procedure schedule_set_lines
4023 (p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4024 p_entity_id => p_line_rec.line_id,
4025 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4026 p_requesting_entity_id => p_line_rec.line_id,
4027 p_request_type => OE_GLOBALS.G_SCHEDULE_LINE,
4028 p_param1 => l_param1,
4029 p_param2 => p_line_rec.header_id,
4030 p_param3 => l_action,
4031 p_param4 => p_old_line_rec.ship_from_org_id,
4032 p_param5 => p_old_line_rec.ship_to_org_id,
4033 p_param6 => p_old_line_rec.ship_set_id,
4034 p_param7 => p_old_line_rec.arrival_set_id,
4035 p_param8 => l_entity_type,
4036 p_param9 => l_ship_to_org_id -- ship to from sets table.
4037 p_param10 => l_ship_to_org_id -- ship to from sets table.
4038 p_param11 => l_shipping_method_code
4039 p_date_param1 => p_old_line_rec.schedule_ship_date,
4040 p_date_param2 => p_old_line_rec.schedule_arrival_date,
4041 p_date_param3 => p_old_line_rec.request_date,
4042 p_date_param4 => l_schedule_ship_date,
4043 p_date_param5 => l_schedule_arrival_date,
4044 x_return_status => x_return_status);
4045
4046 Description: This procedure will be called when the delayed request
4047 SCHEDULE_LINE is logged. This delayed request is logged
4048 when new lines are inserted to a SCHEDULE SET. A set being
4049 a user defined ship or arrival set.When multiple lines are
4050 iserted to the same set, this procedure is called once for
4051 all the lines of the set.
4052 If the included item is part of request table, check for the
4053 parent. If parent exists in the table, assume that parent will
4054 fetch the included items and remove included items from the list.
4055
4056 Changes have been made to copy override_atp flag from model/class/
4057 kit to it's included items when the flag is set.
4058 -------------------------------------------------------------------*/
4059 Procedure Schedule_set_lines
4060 ( p_sch_set_tbl IN OE_ORDER_PUB.request_tbl_type
4061 , x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
4062 IS
4063 l_line_rec OE_ORDER_PUB.line_rec_type;
4064 l_line_tbl OE_ORDER_PUB.line_Tbl_type;
4065 l_old_line_tbl OE_ORDER_PUB.line_Tbl_type;
4066 l_request_rec OE_ORDER_PUB.request_rec_type;
4067 l_old_set_tbl set_tbl_type;
4068 l_sales_order_id NUMBER;
4069 l_line_exists VARCHAR2(1) := 'N';
4070 l_iline_tbl OE_ORDER_PUB.line_Tbl_type;
4071 l_item_type_code VARCHAR2(30);
4072 l_link_to_line_id NUMBER;
4073 l_top_model_line_id NUMBER;
4074 l_ato_line_id NUMBER;
4075 l_header_id NUMBER;
4076 K NUMBER;
4077 l_param12 VARCHAR2(1) := 'N'; --3384975
4078 l_type_code VARCHAR2(30);-- 3564302(issue#1)
4079 --3564310
4080 l_ship_set_id NUMBER;
4081 l_arrival_set_id NUMBER;
4082 l_set_rec OE_ORDER_CACHE.set_rec_type;
4083 l_log_error BOOLEAN := FALSE;
4084 l_part_of_set VARCHAR2(1) :='Y'; --4405004
4085
4086 -- 3870895
4087 CURSOR C5 IS
4088 Select line_id, shipping_interfaced_flag
4089 from oe_order_lines_all
4090 where top_model_line_id = l_top_model_line_id
4091 and open_flag = 'Y'
4092 and shipping_interfaced_flag = 'Y';
4093 --
4094 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4095 --
4096 BEGIN
4097
4098 x_return_status := FND_API.G_RET_STS_SUCCESS;
4099 IF l_debug_level > 0 THEN
4100 oe_debug_pub.add( 'ENTERING OE_GROUP_SCH_UTIL.SCHEDULE_SET_LINES' , 1 ) ;
4101 END IF;
4102
4103 K := 0;
4104 FOR I in 1..p_sch_set_tbl.count LOOP
4105
4106 IF l_debug_level > 0 THEN
4107 oe_debug_pub.add( 'PROCESSING LINE' || P_SCH_SET_TBL ( I ) .ENTITY_ID , 1 ) ;
4108 END IF;
4109
4110 -- For the included item, check if the parent is present the in table.
4111 -- That means parent will explode the line or else add the line to
4112 -- line tbl.
4113
4114 -- 3384975
4115 IF p_sch_set_tbl(I).param12 = 'Y' THEN
4116 l_param12 := p_sch_set_tbl(I).param12;
4117 END IF;
4118
4119 l_line_exists := 'N';
4120 -- 3564310 set ids selected
4121 BEGIN
4122 Select item_type_code,
4123 link_to_line_id,
4124 top_model_line_id,
4125 ato_line_id,
4126 header_id,
4127 ship_set_id,
4128 arrival_set_id
4129 Into l_item_type_code,
4130 l_link_to_line_id,
4131 l_top_model_line_id,
4132 l_ato_line_id,
4133 l_header_id,
4134 l_ship_set_id,
4135 l_arrival_set_id
4136 From oe_order_lines_all
4137 Where line_id = p_sch_set_tbl(I).entity_id;
4138 EXCEPTION
4139 WHEN OTHERS THEN
4140 IF l_debug_level > 0 THEN
4141 oe_debug_pub.add( 'ERROR WHILE SELECTING DATA' , 5 ) ;
4142 END IF;
4143 l_line_exists := 'Y';
4144 END;
4145
4146 --{bug3885953: If the ship/arrival set has changed, do not use old delayed
4147 --request, but just go to the end of processing
4148 IF (p_sch_set_tbl(I).param8 = OE_SCHEDULE_UTIL.OESCH_ENTITY_SHIP_SET AND
4149 l_ship_set_id <> p_sch_set_tbl(I).param1) OR
4150 (p_sch_set_tbl(I).param8 = OE_SCHEDULE_UTIL.OESCH_ENTITY_ARRIVAL_SET AND
4151 l_arrival_set_id <> p_sch_set_tbl(I).param1) THEN
4152 IF l_debug_level > 0 THEN
4153 OE_DEBUG_PUB.Add('Sets differs, goto END OF PROCESS',2);
4154 END IF;
4155 GOTO END_OF_PROCESS;
4156 END IF;
4157 -- end of bug3885953 }
4158
4159
4160
4161 IF l_ship_set_id is null
4162 AND l_arrival_set_id is null THEN
4163 -- 3870895
4164 IF l_top_model_line_id is not null
4165 AND l_top_model_line_id = p_sch_set_tbl(I).entity_id THEN
4166
4167 Update oe_order_lines_all l
4168 Set arrival_set_id = Null,
4169 ship_set_id = Null
4170 Where top_model_line_id = l_top_model_line_id
4171 And open_flag = 'Y';
4172
4173 END IF;
4174
4175 FOR optionrec in C5
4176 LOOP
4177
4178 IF l_debug_level > 0 THEN
4179 oe_debug_pub.add( 'UPDATE SHIPPING : CHILDREN OF MODEL ' || TO_CHAR ( OPTIONREC.LINE_ID ) , 1 ) ;
4180 END IF;
4181
4182 OE_Delayed_Requests_Pvt.Log_Request(
4183 p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4184 p_entity_id => optionrec.line_id,
4185 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4186 p_requesting_entity_id => optionrec.line_id,
4187 p_request_type => OE_GLOBALS.G_UPDATE_SHIPPING,
4188 p_request_unique_key1 => OE_GLOBALS.G_OPR_UPDATE,
4189 p_param1 => FND_API.G_TRUE,
4190 x_return_status => x_return_status);
4191
4192 End loop;
4193
4194 oe_debug_pub.add('Set does not exist on line ' || p_sch_set_tbl(I).entity_id,2);
4195
4196 goto END_OF_PROCESS;
4197
4198 END IF;
4199 IF (OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510'
4200 AND MSC_ATP_GLOBAL.GET_APS_VERSION = 10) THEN
4201
4202 IF l_top_model_line_id <> p_sch_set_tbl(I).entity_id
4203 AND l_top_model_line_id is not null
4204 THEN
4205 FOR J IN 1..p_sch_set_tbl.count LOOP
4206 IF (l_link_to_line_id = p_sch_set_tbl(J).entity_id
4207 AND l_item_type_code = OE_GLOBALS.G_ITEM_INCLUDED)
4208 OR l_top_model_line_id = p_sch_set_tbl(J).entity_id
4209 THEN
4210 --Parent exists.
4211 IF l_debug_level > 0 THEN
4212 oe_debug_pub.add( 'PARENT EXISTS: ' || P_SCH_SET_TBL ( J).ENTITY_ID , 1 ) ;
4213 END IF;
4214 l_line_exists := 'Y';
4215 EXIT;
4216 END IF;
4217 END LOOP;
4218 END IF; -- Not top
4219
4220 ELSE -- GOP Code
4221 -- If the line is present in the table ignore the line.
4222 IF l_item_type_code = OE_GLOBALS.G_ITEM_INCLUDED
4223 THEN
4224 FOR J IN 1..p_sch_set_tbl.count LOOP
4225 IF l_link_to_line_id = p_sch_set_tbl(J).entity_id THEN
4226 --Parent exists.
4227 IF l_debug_level > 0 THEN
4228 oe_debug_pub.add( 'PARENT EXISTS: ' || P_SCH_SET_TBL ( J ) .ENTITY_ID , 1 ) ;
4229 END IF;
4230 l_line_exists := 'Y';
4231 EXIT;
4232 END IF;
4233 END LOOP;
4234 END IF; -- Included
4235
4236 END IF; -- GOP code
4237
4238 -- Do not go in to this code, if the line is a top model or
4239 -- an ato model
4240
4241 oe_debug_pub.add(' l_line_exists :' || l_line_exists,1);
4242 oe_debug_pub.add(' l_ato_line_id :' || l_ato_line_id,1);
4243 oe_debug_pub.add(' l_item_type_code :'|| l_item_type_code,1);
4244 IF l_line_exists = 'N'
4245 AND nvl(l_top_model_line_id,0) <> p_sch_set_tbl(I).entity_id
4246 AND NOT (l_item_type_code = OE_GLOBALS.G_ITEM_CLASS
4247 AND nvl(l_ato_line_id,-99) = p_sch_set_tbl(I).entity_id) THEN
4248
4249
4250 IF l_debug_level > 0 THEN
4251 oe_debug_pub.add( 'LINE IS SELECTED FOR PROCESSING ' || P_SCH_SET_TBL ( I ) .ENTITY_ID , 1 ) ;
4252 END IF;
4253 l_line_rec := OE_ORDER_PUB.G_MISS_LINE_REC;
4254 OE_LINE_UTIL.Lock_Row(p_line_id => p_sch_set_tbl(I).entity_id,
4255 p_x_line_rec => l_line_rec,
4256 x_return_status => x_return_status);
4257
4258 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4259 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4260 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
4261 RAISE FND_API.G_EXC_ERROR;
4262 END IF;
4263
4264
4265 IF nvl(l_line_rec.shippable_flag,'N') = 'Y'
4266 AND l_line_rec.schedule_status_code is not null THEN
4267
4268 IF l_sales_order_id is null THEN
4269 l_sales_order_id :=
4270 OE_SCHEDULE_UTIL.Get_mtl_sales_order_id(l_line_rec.header_id);
4271 END IF;
4272
4273 -- INVCONV - MERGED CALLS FOR OE_LINE_UTIL.Get_Reserved_Quantity and OE_LINE_UTIL.Get_Reserved_Quantity2
4274
4275 OE_LINE_UTIL.Get_Reserved_Quantities(p_header_id => l_sales_order_id
4276 ,p_line_id => l_line_rec.line_id
4277 ,p_org_id => l_line_rec.ship_from_org_id
4278 ,x_reserved_quantity => l_line_rec.reserved_quantity
4279 ,x_reserved_quantity2 => l_line_rec.reserved_quantity2
4280 );
4281
4282 /*l_line_rec.reserved_quantity :=
4283 OE_LINE_UTIL.Get_Reserved_Quantity
4284 (p_header_id => l_sales_order_id,
4285 p_line_id => l_line_rec.line_id,
4286 p_org_id => l_line_rec.ship_from_org_id);
4287
4288 l_line_rec.reserved_quantity2 := -- INVCONV
4289 OE_LINE_UTIL.Get_Reserved_Quantity2
4290 (p_header_id => l_sales_order_id,
4291 p_line_id => l_line_rec.line_id,
4292 p_org_id => l_line_rec.ship_from_org_id); */
4293 END IF;
4294
4295 IF l_line_rec.reserved_quantity IS NULL
4296 OR l_line_rec.reserved_quantity = FND_API.G_MISS_NUM THEN
4297 l_line_rec.reserved_quantity := 0;
4298 END IF;
4299 /* IF l_line_rec.reserved_quantity2 IS NULL -- INVCONV -- why was this commented out
4300 OR l_line_rec.reserved_quantity2 = FND_API.G_MISS_NUM THEN
4301 l_line_rec.reserved_quantity2 := 0;
4302 END IF; */
4303
4304
4305 -- Check if the line is part of Model and it is already scheduled.
4306 -- by its parent ??????????????????????????/
4307
4308 K := K + 1;
4309
4310 l_old_line_tbl(K) := l_line_rec;
4311 l_line_tbl(K) := l_line_rec;
4312
4313 l_old_line_tbl(K).schedule_ship_date := null;
4314 l_old_line_tbl(K).schedule_arrival_date:= null;
4315 l_old_line_tbl(K).schedule_ship_date := p_sch_set_tbl(I).date_param1;
4316 l_old_line_tbl(K).schedule_arrival_date:= p_sch_set_tbl(I).date_param2;
4317 l_old_line_tbl(K).request_date := p_sch_set_tbl(I).date_param3;
4318 -- bug 3850293; FP - added the IF condition
4319 IF p_sch_set_tbl(I).param4 IS NOT NULL THEN
4320 l_old_line_tbl(K).ship_from_org_id := p_sch_set_tbl(I).param4;
4321 END IF;
4322 l_old_line_tbl(K).ship_to_org_id := p_sch_set_tbl(I).param5;
4323
4324 -- l_old_line_tbl(K).ship_set_id := p_sch_set_tbl(I).param6;
4325 -- l_old_line_tbl(K).arrival_set_id := p_sch_set_tbl(I).param7;
4326
4327 l_old_set_tbl(k).ship_set_id := p_sch_set_tbl(I).param6;
4328 l_old_set_tbl(k).arrival_set_id := p_sch_set_tbl(I).param7;
4329
4330 /* Start Audit Trail */
4331 l_line_tbl(K).change_reason := 'SYSTEM';
4332 l_line_tbl(K).change_comments := 'Delayed Request , Scheduling';
4333 /* End Audit Trail */
4334
4335 l_line_tbl(K).operation := OE_GLOBALS.G_OPR_UPDATE;
4336
4337 /* Commented the above line to fix the bug 2916814 */
4338 --3564302 (#1)
4339 -- Get the order date type code
4340 l_type_code := oe_schedule_util.Get_Date_Type(l_line_tbl(K).header_id);
4341
4342 IF p_sch_set_tbl(I).param8 = OE_SCHEDULE_UTIL.OESCH_ENTITY_SHIP_SET
4343 THEN
4344 -- Ship set date.
4345 l_line_tbl(K).Schedule_ship_date := p_sch_set_tbl(I).date_param4;
4346 -- 3564302
4347 IF l_type_code = 'ARRIVAL' THEN
4348 l_line_tbl(K).Schedule_arrival_date := p_sch_set_tbl(I).date_param5;
4349 END IF;
4350 IF p_sch_set_tbl(I).param10 is not null THEN
4351 l_line_tbl(K).ship_from_org_id := p_sch_set_tbl(I).param10;
4352 l_line_tbl(k).re_source_flag := 'N';
4353 END IF;
4354 IF fnd_profile.value('ONT_SHIP_METHOD_FOR_SHIP_SET') = 'Y' THEN
4355 oe_debug_pub.add('ONT_SHIP_METHOD_FOR_SHIP_SET' || p_sch_set_tbl(I).param11,2);
4356 l_line_tbl(K).shipping_method_code := p_sch_set_tbl(I).param11;
4357 END IF;
4358 END IF;
4359
4360 IF p_sch_set_tbl(I).param8 = OE_SCHEDULE_UTIL.OESCH_ENTITY_ARRIVAL_SET
4361 THEN
4362 l_line_tbl(K).Schedule_arrival_date := p_sch_set_tbl(I).date_param5;
4363 -- 3564302(issue 1)
4364 IF l_type_code = 'SHIP' THEN
4365 l_line_tbl(K).Schedule_ship_date := p_sch_set_tbl(I).date_param4;
4366 END IF;
4367 END IF;
4368
4369 -- Assign the value from the sets table. That way we are
4370 -- enforcing all the lines to have a same ship to.
4371
4372 IF p_sch_set_tbl(I).param9 is not null THEN
4373 l_line_tbl(K).ship_to_org_id := p_sch_set_tbl(I).param9;
4374 END IF;
4375
4376 l_line_tbl(K).schedule_action_code :=
4377 OE_SCHEDULE_UTIL.OESCH_ACT_RESCHEDULE;
4378
4379
4380 IF l_line_tbl(K).arrival_set_id is not null THEN
4381 l_line_tbl(K).arrival_set := l_line_tbl(K).arrival_set_id;
4382 ELSE
4383 l_line_tbl(K).ship_set := l_line_tbl(K).ship_set_id;
4384 END IF;
4385 END IF; -- Line Exists.
4386
4387
4388 IF l_item_type_code = 'CLASS'
4389 OR l_item_type_code = 'KIT'
4390 OR l_item_type_code = 'MODEL'
4391 THEN
4392
4393 oe_debug_pub.add('line_id ' || p_sch_set_tbl(I).entity_id,3);
4394 oe_debug_pub.add(' top line ' || l_top_model_line_id,3);
4395 oe_debug_pub.add(' ato line ' || l_ato_line_id,3);
4396 oe_debug_pub.add(' item type ' || l_item_type_code,3);
4397 oe_debug_pub.add(' header_id ' || l_header_id,3);
4398
4399 IF p_sch_set_tbl(I).entity_id = nvl(l_top_model_line_id,0) THEN
4400 Oe_Config_Schedule_Pvt.Query_Set_Lines
4401 (p_header_id => l_header_id,
4402 p_model_line_id => l_top_model_line_id,
4403 p_sch_action => 'SCHEDULE',
4404 x_line_tbl => l_iline_tbl,
4405 x_return_status => x_return_status);
4406
4407 ELSIF (l_ato_line_id is not null AND
4408 NOT (l_ato_line_id = p_sch_set_tbl(I).entity_id AND
4409 l_item_type_code IN (OE_GLOBALS.G_ITEM_STANDARD,
4410 OE_GLOBALS.G_ITEM_OPTION,
4411 OE_GLOBALS.G_ITEM_INCLUDED))) --9775352
4412 THEN
4413
4414 OE_Config_Util.Query_ATO_Options
4415 ( p_ato_line_id => l_ato_line_id
4416 ,p_send_cancel_lines => 'Y'
4417 ,p_source_type => OE_Globals.G_SOURCE_INTERNAL
4418 ,x_line_tbl => l_iline_tbl);
4419
4420
4421 ELSE
4422
4423 Oe_Config_Schedule_Pvt.Query_Set_Lines
4424 (p_header_id => l_header_id,
4425 p_link_to_line_id => p_sch_set_tbl(I).entity_id,
4426 p_sch_action => 'SCHEDULE',
4427 x_line_tbl => l_iline_tbl,
4428 x_return_status => x_return_status);
4429
4430 END IF;
4431
4432 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4433 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4434 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
4435 RAISE FND_API.G_EXC_ERROR;
4436 END IF;
4437 -- 3564310
4438 -- Line is no longer with the set
4439 -- rollback the changes.
4440 IF l_ship_set_id is null
4441 AND l_arrival_set_id IS null THEN
4442 FOR I IN 1..l_iline_tbl.count LOOP
4443 IF l_iline_tbl(I).schedule_status_code IS NULL THEN
4444
4445 UPDATE OE_ORDER_LINES_ALL
4446 SET SCHEDULE_SHIP_DATE = Null,
4447 SCHEDULE_ARRIVAL_DATE = Null,
4448 SHIP_FROM_ORG_ID = decode(re_source_flag,'N',ship_from_org_id,null),
4449 SHIP_SET_ID = Null,
4450 ARRIVAL_SET_ID = Null,
4451 override_atp_date_code = Null
4452 WHERE line_id = l_iline_tbl(I).line_id;
4453
4454 ELSE
4455 UPDATE OE_ORDER_LINES_ALL
4456 SET
4457 SCHEDULE_SHIP_DATE = p_sch_set_tbl(I).date_param1,
4458 SCHEDULE_ARRIVAL_DATE = p_sch_set_tbl(I).date_param2,
4459 SHIP_FROM_ORG_ID = p_sch_set_tbl(I).param4,
4460 SHIP_SET_ID = p_sch_set_tbl(I).param6,
4461 ARRIVAL_SET_ID = p_sch_set_tbl(I).param7
4462 WHERE line_id = l_iline_tbl(I).line_id;
4463 END IF;
4464 -- 4026758
4465 IF l_iline_tbl(I).ship_set_id IS NOT NULL
4466 OR l_iline_tbl(I).arrival_set_id IS NOT NULL THEN
4467 oe_schedule_util.Log_Delete_Set_Request
4468 (p_header_id => l_iline_tbl(I).header_id,
4469 p_line_id => l_iline_tbl(I).line_id,
4470 p_set_id => nvl(l_iline_tbl(I).ship_set_id,
4471 l_iline_tbl(I).arrival_set_id),
4472 x_return_status => x_return_status);
4473 IF l_debug_level > 0 THEN
4474 oe_debug_pub.add( 'AFTER LOGGING DELETE SETS DELAYED REQUEST '
4475 || X_RETURN_STATUS , 1 ) ;
4476 END IF;
4477 END IF;
4478
4479 IF l_iline_tbl(I).shipping_interfaced_flag = 'Y' THEN
4480
4481 oe_debug_pub.add('Line is interfaced ',2);
4482
4483 OE_Delayed_Requests_Pvt.Log_Request(
4484 p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4485 p_entity_id => l_iline_tbl(I).line_id,
4486 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4487 p_requesting_entity_id => l_iline_tbl(I).line_id,
4488 p_request_type => OE_GLOBALS.G_UPDATE_SHIPPING,
4489 p_request_unique_key1 => OE_GLOBALS.G_OPR_UPDATE,
4490 p_param1 => FND_API.G_TRUE,
4491 x_return_status => x_return_status);
4492
4493 END IF;
4494 END LOOP;
4495 EXIT;
4496 END IF;
4497
4498 IF l_debug_level > 0 THEN
4499 oe_debug_pub.add( 'INCLUDED ITEM COUNT ' || L_ILINE_TBL.COUNT,2);
4500 END IF;
4501
4502 -- Start 2716220 --
4503 -- To check schedule dates with override flag
4504
4505 l_type_code := oe_schedule_util.Get_Date_Type(l_header_id);
4506
4507 IF l_arrival_set_id is not null THEN
4508
4509 l_set_rec := OE_ORDER_CACHE.Load_Set
4510 (l_arrival_set_id);
4511
4512 ELSIF l_ship_set_id is not null THEN
4513
4514 l_set_rec := OE_ORDER_CACHE.Load_Set
4515 (l_Ship_set_id);
4516 END IF;
4517
4518 l_log_error := FALSE;
4519
4520 FOR O IN 1..l_iline_tbl.count LOOP
4521 IF NVL(l_iline_tbl(O).override_atp_date_code,'N') = 'Y'
4522 THEN
4523
4524 IF l_type_code = 'ARRIVAL' THEN
4525 IF l_iline_tbl(O).schedule_arrival_date IS NOT NULL
4526 AND l_set_rec.schedule_arrival_date IS NOT NULL
4527 AND l_iline_tbl(O).schedule_arrival_date <> l_set_rec.schedule_arrival_date
4528 THEN
4529 oe_debug_pub.add('Arr date does not match with set date' || l_iline_tbl(O).line_id,2);
4530 l_log_error := TRUE;
4531 END IF;
4532
4533 ELSE
4534
4535 IF l_iline_tbl(O).schedule_ship_date IS NOT NULL
4536 AND l_set_rec.schedule_ship_date IS NOT NULL
4537 AND l_iline_tbl(O).schedule_ship_date <> l_set_rec.schedule_ship_date
4538 THEN
4539 oe_debug_pub.add('Sch date does not match with set date' || l_iline_tbl(O).line_id,2);
4540 l_log_error := TRUE;
4541 END IF;
4542 END IF;
4543 END IF;
4544 END LOOP;
4545
4546 IF l_log_error THEN
4547 FND_MESSAGE.SET_NAME('ONT','OE_SCH_OVER_ATP_SET_NO_MATCH');
4548 OE_MSG_PUB.Add;
4549 x_return_status := FND_API.G_RET_STS_ERROR;
4550 RAISE FND_API.G_EXC_ERROR;
4551 END IF;
4552
4553 FOR M IN 1..l_iline_tbl.count LOOP
4554 IF l_debug_level > 0 THEN
4555 oe_debug_pub.add('LINE_ID: ' || l_iline_tbl(M).LINE_ID, 1);
4556 END IF;
4557
4558 K := K + 1;
4559
4560 -- BUG 1282873
4561 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
4562 IF l_line_rec.override_atp_date_code = 'Y' THEN
4563 l_iline_tbl(M).override_atp_date_code := l_line_rec.override_atp_date_code;
4564 IF l_debug_level > 0 THEN
4565 oe_debug_pub.add( 'OVERRIDE_ATP :' || L_ILINE_TBL(M).OVERRIDE_ATP_DATE_CODE , 3 ) ;
4566 END IF;
4567 END IF;
4568 END IF;
4569 -- END 1282873
4570
4571 l_line_tbl(K) := l_iline_tbl(M);
4572 l_old_line_tbl(K) := l_iline_tbl(M);
4573 l_old_line_tbl(K).schedule_ship_date := null;
4574 l_old_line_tbl(K).schedule_arrival_date := null;
4575 l_old_line_tbl(K).schedule_ship_date := p_sch_set_tbl(I).date_param1;
4576 l_old_line_tbl(K).schedule_arrival_date:= p_sch_set_tbl(I).date_param2;
4577 l_old_line_tbl(K).request_date := p_sch_set_tbl(I).date_param3;
4578 --bug 3850293; FP - added IF condition
4579 IF p_sch_set_tbl(I).param4 IS NOT NULL THEN
4580 l_old_line_tbl(K).ship_from_org_id := p_sch_set_tbl(I).param4;
4581 END IF;
4582 l_old_line_tbl(K).ship_to_org_id := p_sch_set_tbl(I).param5;
4583
4584 -- l_old_line_tbl(K).ship_set_id := p_sch_set_tbl(I).param6;
4585 -- l_old_line_tbl(K).arrival_set_id := p_sch_set_tbl(I).param7;
4586
4587
4588 l_old_set_tbl(k).ship_set_id := p_sch_set_tbl(I).param6;
4589 l_old_set_tbl(k).arrival_set_id := p_sch_set_tbl(I).param7;
4590
4591 /* Start Audit Trail */
4592 l_line_tbl(K).change_reason := 'SYSTEM';
4593 l_line_tbl(K).change_comments := 'Delayed Request , Scheduling';
4594 /* End Audit Trail */
4595
4596 l_line_tbl(K).operation := OE_GLOBALS.G_OPR_UPDATE;
4597
4598 IF p_sch_set_tbl(I).param8 = OE_SCHEDULE_UTIL.OESCH_ENTITY_SHIP_SET
4599 THEN
4600 -- Ship set date.
4601 l_line_tbl(K).Schedule_ship_date := p_sch_set_tbl(I).date_param4;
4602 -- 3564302
4603 IF l_type_code = 'ARRIVAL' THEN
4604 l_line_tbl(K).Schedule_arrival_date := p_sch_set_tbl(I).date_param5;
4605 END IF;
4606 IF p_sch_set_tbl(I).param10 is not null THEN
4607 l_line_tbl(K).ship_from_org_id := p_sch_set_tbl(I).param10;
4608 l_line_tbl(k).re_source_flag := 'N';
4609 END IF;
4610 IF fnd_profile.value('ONT_SHIP_METHOD_FOR_SHIP_SET') = 'Y' THEN
4611 oe_debug_pub.add('ONT_SHIP_METHOD_FOR_SHIP_SET Model:' || p_sch_set_tbl(I).param11,1);
4612 l_line_tbl(K).shipping_method_code := p_sch_set_tbl(I).param11;
4613 END IF;
4614 END IF;
4615
4616 IF p_sch_set_tbl(I).param8
4617 = OE_SCHEDULE_UTIL.OESCH_ENTITY_ARRIVAL_SET
4618 THEN
4619 l_line_tbl(K).Schedule_arrival_date
4620 := p_sch_set_tbl(I).date_param5;
4621 -- 3564302
4622 IF l_type_code = 'SHIP' THEN
4623 l_line_tbl(K).Schedule_ship_date := p_sch_set_tbl(I).date_param4;
4624 END IF;
4625 END IF;
4626
4627 -- Assign the value from the sets table. That way we are
4628 -- enforcing all the lines to have a same ship to.
4629
4630 IF p_sch_set_tbl(I).param9 is not null THEN
4631 l_line_tbl(K).ship_to_org_id := p_sch_set_tbl(I).param9;
4632 END IF;
4633
4634 l_line_tbl(K).schedule_action_code :=
4635 OE_SCHEDULE_UTIL.OESCH_ACT_RESCHEDULE;
4636
4637 IF l_line_tbl(K).arrival_set_id is not null THEN
4638 l_line_tbl(K).arrival_set := l_line_tbl(K).arrival_set_id;
4639 ELSE
4640 l_line_tbl(K).ship_set := l_line_tbl(K).ship_set_id;
4641 END IF;
4642 END LOOP; -- End of included item
4643 END IF; -- Class or KIT
4644
4645 <<END_OF_PROCESS>>
4646 Null;
4647 END LOOP; -- Main loop.
4648
4649 IF l_debug_level > 0 THEN
4650 oe_debug_pub.add('Line Count :' || l_line_tbl.count,1);
4651 END IF;
4652 --3564310
4653 -- Validate the lines befor calling process_group
4654 IF l_line_tbl.count > 0 THEN
4655
4656
4657 Validate_Group
4658 (p_x_line_tbl => l_line_tbl,
4659 p_sch_action => 'SCHEDULE',
4660 x_return_status => x_return_status);
4661
4662 END IF;
4663
4664 IF l_debug_level > 0 THEN
4665 oe_debug_pub.add( 'AFTER CALLING Validate Group ' || X_RETURN_STATUS
4666 || l_line_tbl.count , 1 ) ;
4667 END IF;
4668 -- 3564310
4669 IF l_line_tbl.count > 0
4670 AND x_return_status = FND_API.G_RET_STS_SUCCESS THEN
4671 Oe_Config_Schedule_Pvt.Process_Group
4672 (p_x_line_tbl => l_line_tbl
4673 ,p_old_line_tbl => l_old_line_tbl
4674 ,p_caller => 'SET'
4675 ,p_sch_action => OE_SCHEDULE_UTIL.OESCH_ACT_RESCHEDULE
4676 ,p_partial_set => TRUE
4677 ,p_part_of_set => l_part_of_set --4405004
4678 ,x_return_status => x_return_status);
4679
4680 IF l_debug_level > 0 THEN
4681 oe_debug_pub.add('After call to Process Group :' || x_return_status ,1);
4682 END IF;
4683 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4684 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4685 END IF;
4686 END IF;
4687
4688 -- Additional process we are doing to fix bug 2232950.
4689 IF x_return_status = FND_API.G_RET_STS_SUCCESS THEN
4690
4691 IF l_debug_level > 0 THEN
4692 oe_debug_pub.add('Compare output with requested values',1);
4693 END IF;
4694
4695 FOR I IN 1..l_line_tbl.count LOOP
4696
4697 IF p_sch_set_tbl(1).param8 = OE_SCHEDULE_UTIL.OESCH_ENTITY_SHIP_SET
4698 AND trunc(l_line_tbl(I).Schedule_ship_date) <> trunc(p_sch_set_tbl(1).date_param4)
4699 THEN
4700 IF l_debug_level > 0 THEN
4701 oe_debug_pub.add('Not received correct values for ship set',1);
4702 END IF;
4703 x_return_status := FND_API.G_RET_STS_ERROR;
4704 EXIT;
4705 ELSIF p_sch_set_tbl(1).param8 = OE_SCHEDULE_UTIL.OESCH_ENTITY_ARRIVAL_SET
4706 AND trunc(l_line_tbl(I).Schedule_arrival_date) <> trunc(p_sch_set_tbl(1).date_param5)
4707 THEN
4708 IF l_debug_level > 0 THEN
4709 oe_debug_pub.add('Not received correct values for arrival set',1);
4710 END IF;
4711 x_return_status := FND_API.G_RET_STS_ERROR;
4712 EXIT;
4713 END IF;
4714
4715 END LOOP;
4716 END IF; -- Success.
4717
4718 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
4719
4720 IF l_debug_level > 0 THEN
4721 oe_debug_pub.add('Line Id error out : ' || l_line_rec.line_id,2);
4722 END IF;
4723
4724 -- Could not schedule the line on the set date. Let's schedule
4725 -- the whole set to see if we get another date got the whole
4726 -- set.
4727
4728 IF fnd_profile.value('ONT_AUTO_PUSH_GRP_DATE') = 'Y' THEN
4729
4730 IF l_debug_level > 0 THEN
4731 oe_debug_pub.add('Auto Push Group Date is Yes',2);
4732 END IF;
4733
4734 -- Added this stmt to fix big 1899651.
4735 l_request_rec := p_sch_set_tbl(1);
4736 l_request_rec.param3 := OE_SCHEDULE_UTIL.OESCH_ACT_RESCHEDULE;
4737 -- 3384975
4738 l_request_rec.param12 := l_param12;
4739
4740 IF l_debug_level > 0 THEN
4741 oe_debug_pub.add('Stng G_CASCADING_REQUEST_LOGGED to TRUE',2);
4742 END IF;
4743 OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
4744
4745 Schedule_Set(p_request_rec => l_request_rec,
4746 x_return_status => x_return_status);
4747
4748 ELSE
4749
4750 IF l_debug_level > 0 THEN
4751 oe_debug_pub.add('Before setting message for group failure',2);
4752 END IF;
4753
4754 FND_MESSAGE.SET_NAME('ONT','OE_SCH_GROUP_MEMBER_FAILED');
4755 OE_MSG_PUB.Add;
4756
4757 END IF; -- If Auto Push Group Date is Yes
4758
4759 -- Scheduling Failed. If the line belongs to a Ship Set or Arrival
4760 -- Set, then just clear out the scheduling attributes and return a
4761 -- message that the line schedule failed. We will return a success
4762 -- since we do not want to fail the line insert due to this.
4763
4764 IF l_debug_level > 0 THEN
4765 oe_debug_pub.add('Calling Update Set');
4766 END IF;
4767
4768 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
4769
4770 IF l_debug_level > 0 THEN
4771 oe_debug_pub.add('Unable to schedule the line for set date');
4772 END IF;
4773
4774 FOR I IN 1..l_line_tbl.count LOOP
4775 IF l_line_tbl(I).top_model_line_id IS NOT NULL
4776 AND l_line_tbl(I).top_model_line_id <> l_line_tbl(I).line_id THEN
4777
4778 -- Scheduling Failed. If the line belongs to a ATO Model or SMC
4779 -- PTO, then return an error, since the option cannot be inserted
4780 -- to a scheduled ATO or SMC PTO if it cannot be scheduled on
4781 -- the same date as that of the model.
4782
4783 IF l_debug_level > 0 THEN
4784 oe_debug_pub.add('Line belong to model');
4785 END IF;
4786 fnd_message.set_name('ONT','OE_SCH_SET_INS_FAILED');
4787 OE_MSG_PUB.Add;
4788 RAISE FND_API.G_EXC_ERROR;
4789
4790 ELSE
4791 -- If the line is being added to set is a standard line
4792 -- save the line without scheduling attributes.
4793 IF l_debug_level > 0 THEN
4794 oe_debug_pub.add('Standard line is failed');
4795 END IF;
4796 fnd_message.set_name('ONT','OE_SCH_SET_INS_FAILED');
4797 OE_MSG_PUB.Add;
4798
4799 IF l_line_tbl(I).schedule_status_code IS NULL
4800 THEN
4801
4802 UPDATE OE_ORDER_LINES_ALL
4803 SET SCHEDULE_SHIP_DATE = Null,
4804 SCHEDULE_ARRIVAL_DATE = Null,
4805 SHIP_FROM_ORG_ID = decode(re_source_flag,'N',ship_from_org_id,null),
4806 SHIP_SET_ID = Null,
4807 ARRIVAL_SET_ID = Null,
4808 override_atp_date_code = Null
4809 WHERE line_id = l_line_tbl(I).line_id;
4810
4811 ELSE
4812 -- fix for 3557779
4813 -- update schedule_status_code and visible_demand_flag fields in
4814 -- addition to previously updated fields
4815 UPDATE OE_ORDER_LINES_ALL
4816 SET
4817 SCHEDULE_STATUS_CODE = l_old_line_tbl(I).schedule_status_code,
4818 VISIBLE_DEMAND_FLAG = l_old_line_tbl(I).visible_demand_flag,
4819 SCHEDULE_SHIP_DATE = l_old_line_tbl(I).schedule_ship_date,
4820 SCHEDULE_ARRIVAL_DATE = l_old_line_tbl(I).schedule_arrival_date,
4821 SHIP_FROM_ORG_ID = l_old_line_tbl(I).ship_from_org_id,
4822 SHIP_SET_ID = l_old_set_tbl(I).ship_set_id,
4823 ARRIVAL_SET_ID = l_old_set_tbl(I).arrival_set_id
4824 WHERE line_id = l_line_tbl(I).line_id;
4825 END IF;
4826 -- 4026758
4827 IF l_line_tbl(I).ship_set_id IS NOT NULL
4828 OR l_line_tbl(I).arrival_set_id IS NOT NULL THEN
4829 oe_schedule_util.Log_Delete_Set_Request
4830 (p_header_id => l_line_tbl(I).header_id,
4831 p_line_id => l_line_tbl(I).line_id,
4832 p_set_id => nvl(l_line_tbl(I).ship_set_id,l_line_tbl(I).arrival_set_id),
4833 x_return_status => x_return_status);
4834 IF l_debug_level > 0 THEN
4835 oe_debug_pub.add( 'AFTER LOGGING DELETE SETS DELAYED REQUEST '
4836 || X_RETURN_STATUS , 1 ) ;
4837 END IF;
4838 END IF;
4839
4840 IF l_line_tbl(I).shipping_interfaced_flag = 'Y'
4841 AND l_line_tbl(I).Ordered_quantity > 0 THEN
4842 OE_Delayed_Requests_Pvt.Log_Request(
4843 p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4844 p_entity_id => l_line_tbl(I).line_id,
4845 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4846 p_requesting_entity_id => l_line_tbl(I).line_id,
4847 p_request_type => OE_GLOBALS.G_UPDATE_SHIPPING,
4848 p_request_unique_key1 => OE_GLOBALS.G_OPR_UPDATE,
4849 p_param1 => FND_API.G_TRUE,
4850 x_return_status => x_return_status);
4851 END IF;
4852 END IF; -- Part of Model.
4853 END LOOP;
4854 -- 3384975
4855 IF l_param12 = 'N' THEN
4856 x_return_status := FND_API.G_RET_STS_SUCCESS;
4857 END IF;
4858
4859 END IF; -- x_return_status = succ/error
4860
4861 END IF; -- If g_ret_status is error
4862
4863 l_old_set_tbl.delete;
4864 IF l_debug_level > 0 THEN
4865 oe_debug_pub.add('Exiting OE_Delayed_Requests_UTIL.Schedule_set_lines');
4866 END IF;
4867 EXCEPTION
4868
4869 WHEN FND_API.G_EXC_ERROR THEN
4870 x_return_status := FND_API.G_RET_STS_ERROR;
4871 l_old_set_tbl.delete;
4872 IF l_debug_level > 0 THEN
4873 oe_debug_pub.add('No data from expected error',1);
4874 END IF;
4875 RAISE FND_API.G_EXC_ERROR;
4876
4877 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4878
4879 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4880 THEN
4881 OE_MSG_PUB.Add_Exc_Msg
4882 ( G_PKG_NAME
4883 , 'Schedule_set_lines'
4884 );
4885 END IF;
4886 IF l_debug_level > 0 THEN
4887 oe_debug_pub.add('No data from unexpected error',1);
4888 END IF;
4889
4890 l_old_set_tbl.delete;
4891 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4892
4893 WHEN OTHERS THEN
4894
4895
4896 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4897 THEN
4898 OE_MSG_PUB.Add_Exc_Msg
4899 ( G_PKG_NAME
4900 , 'Schedule_set_lines'
4901 );
4902 END IF;
4903 IF l_debug_level > 0 THEN
4904 oe_debug_pub.add('No data from unexpected error',1);
4905 END IF;
4906 l_old_set_tbl.delete;
4907 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4908
4909 END Schedule_set_lines;
4910
4911 /* ---------------------------------------------------------------
4912 Procedure : Schedule_Set
4913 Description:
4914 p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4915 p_entity_id => p_line_rec.line_id,
4916 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
4917 p_requesting_entity_id => p_line_rec.line_id,
4918 p_request_type => OE_GLOBALS.G_GROUP_SCHEDULE,
4919 p_param1 => l_param1,ship_set_id/arrival_set_id
4920 p_param2 => p_line_rec.header_id,
4921 p_param3 => l_action,
4922 p_param4 => p_old_line_rec.ship_from_org_id,
4923 p_param5 => p_old_line_rec.ship_to_org_id,
4924 p_date_param1 => p_old_line_rec.schedule_ship_date,
4925 p_date_param2 => p_old_line_rec.schedule_arrival_date,
4926 p_date_param3 => p_old_line_rec.request_date,
4927 p_param6 => p_old_line_rec.ship_set_id,
4928 p_param7 => p_old_line_rec.arrival_set_id,
4929 p_param8 => l_entity_type,
4930 p_param11 => l_shipping_method_code
4931
4932 Changes have been made to copy override_atp flag from model/class/
4933 kit to it's included items when the flag is set. Code has been added to
4934 cascade the override_atp flag to all the line in an ato model.
4935 ---------------------------------------------------------------*/
4936 Procedure Schedule_Set(p_request_rec IN OE_ORDER_PUB.request_rec_type,
4937 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
4938 IS
4939 l_line_tbl OE_ORDER_PUB.line_tbl_type;
4940 l_old_line_tbl OE_ORDER_PUB.line_tbl_type;
4941 l_line_rec OE_ORDER_PUB.line_rec_type;
4942 l_old_line_rec OE_ORDER_PUB.line_rec_type;
4943 l_msg_count NUMBER;
4944 l_msg_data VARCHAR2(2000);
4945 l_set_rec OE_ORDER_CACHE.set_rec_type;
4946 l_set_name VARCHAR2(30);
4947 l_set_id NUMBER := null;
4948 l_ship_set_id NUMBER := null;
4949 l_arrival_set_id NUMBER := null;
4950
4951 l_entity_type VARCHAR2(30);
4952 l_action VARCHAR2(30);
4953 l_line_id NUMBER;
4954 l_header_id NUMBER;
4955 l_old_schedule_ship_date DATE := Null;
4956 l_old_schedule_arrival_date DATE := Null;
4957 l_old_request_date DATE := Null;
4958 l_old_ship_from_org_id NUMBER := Null;
4959 l_old_ship_set_id NUMBER := Null;
4960 l_old_arrival_set_id NUMBER := Null;
4961
4962 l_set_Schedule_ship_date DATE := Null;
4963 l_set_Schedule_arrival_date DATE := Null;
4964 l_set_ship_to_org_id NUMBER := Null;
4965 l_set_ship_from_org_id NUMBER := Null;
4966
4967 l_ship_to_org_id NUMBER := NULL;
4968 l_schedule_ship_date DATE := NULL;
4969 l_schedule_arrival_date DATE := NULL;
4970 l_ship_from_org_id NUMBER := NULL;
4971 l_request_date DATE := NULL;
4972 l_shipping_method_code VARCHAR2(30);
4973 l_Freight_Carrier_Code VARCHAR2(30);
4974 l_shipment_priority_code VARCHAR2(30);
4975 l_can_bypass BOOLEAN := FALSE;
4976 l_set_overridden BOOLEAN := FALSE;
4977 -- Start 2716220 --
4978 l_override_ship_date DATE := NULL;
4979 l_override_arrival_date DATE := NULL;
4980 l_log_error BOOLEAN := FALSE;
4981 l_operation VARCHAR2(30) := 'UPDATE';
4982 --
4983 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4984 --
4985 /* Added the following 2 line to fix the bug 2740480 */
4986 l_push_logic VARCHAR2(1) := 'N';
4987 l_date_changed VARCHAR2(1) := 'N';
4988
4989 l_index NUMBER;
4990 l_count NUMBER := 0; -- 5043206
4991 l_org_id NUMBER ; --4241385
4992 BEGIN
4993 IF l_debug_level > 0 THEN
4994 oe_debug_pub.add( 'ENTERING SCHEDULE_SET' , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
4995 END IF;
4996
4997 l_entity_type := p_request_rec.param8;
4998 l_action := p_request_rec.param3;
4999 l_line_id := p_request_rec.entity_id;
5000 l_header_id := p_request_rec.param2;
5001 l_old_schedule_ship_date := p_request_rec.date_param1;
5002 l_old_schedule_arrival_date := p_request_rec.date_param2;
5003 l_old_request_date := p_request_rec.date_param3;
5004 l_old_ship_from_org_id := p_request_rec.param4;
5005 l_old_ship_set_id := p_request_rec.param6;
5006 l_old_arrival_set_id := p_request_rec.param7;
5007 l_set_ship_to_org_id := p_request_rec.param9;
5008 l_set_ship_from_org_id := p_request_rec.param10;
5009 /* Added the following 1 line to fix the bug 2740480 */
5010 l_push_logic := nvl(p_request_rec.param13,'N');
5011 l_operation := p_request_rec.param14;
5012 l_set_schedule_ship_date := p_request_rec.date_param4;
5013 l_set_schedule_arrival_date := p_request_rec.date_param5;
5014
5015 IF l_debug_level > 0 THEN
5016 oe_debug_pub.add( 'L_OLD_SCHEDULE_SHIP_DATE :'
5017 || L_OLD_SCHEDULE_SHIP_DATE , 1 ) ;
5018 oe_debug_pub.add( 'L_OLD_REQUEST_DATE :' || L_OLD_REQUEST_DATE , 1 ) ;
5019 oe_debug_pub.add( 'L_LINE_ID :' || L_LINE_ID , 1 ) ;
5020 oe_debug_pub.add( 'L_OLD_SHIP_SET_ID :' || L_OLD_SHIP_SET_ID , 1 ) ;
5021 oe_debug_pub.add( 'l_set_ship_from_org_id :' || l_set_ship_from_org_id , 1 ) ;
5022 END IF;
5023
5024 Select Schedule_ship_date, Schedule_arrival_date,
5025 ship_to_org_id, ship_from_org_id, request_date,
5026 Ship_set_id,arrival_Set_id, org_id --4241385
5027 Into l_Schedule_ship_date, l_Schedule_arrival_date,
5028 l_ship_to_org_id, l_ship_from_org_id, l_request_date,
5029 l_ship_set_id,l_arrival_set_id,l_org_id
5030 From OE_ORDER_LINES_ALL
5031 Where line_id = l_line_id;
5032
5033 -- Schedule set lines is called it will have param4 as
5034 -- set date, use the same to schedule the line.
5035
5036 IF l_ship_set_id is null
5037 AND l_arrival_set_id is null
5038 THEN
5039
5040 -- 5043206
5041 BEGIN
5042
5043 IF p_request_rec.param8 = OE_SCHEDULE_UTIL.OESCH_ENTITY_ARRIVAL_SET THEN
5044
5045 Select 1 into l_count from OE_ORDER_LINES_ALL
5046 WHERE header_id = l_header_id and arrival_Set_id = p_request_rec.param1
5047 AND rownum = 1;
5048
5049 ELSIF p_request_rec.param8 = OE_SCHEDULE_UTIL.OESCH_ENTITY_SHIP_SET THEN
5050
5051 Select 1 into l_count from OE_ORDER_LINES_ALL
5052 WHERE header_id = l_header_id and ship_set_id = p_request_rec.param1
5053 AND rownum = 1;
5054
5055 END IF;
5056
5057 EXCEPTION
5058 WHEN OTHERS THEN
5059
5060 IF l_debug_level > 0 THEN
5061 oe_debug_pub.add( 'No Records found after checking For Lines in set' , 1 ) ;
5062 END IF;
5063
5064 END ;
5065
5066 IF l_count = 0 THEN
5067
5068 -- Delalyed request is logged for set id and the same
5069 -- is not available any more in the db. Do not process
5070 -- the request.
5071 goto END_OF_PROCESS;
5072
5073 END IF ;
5074
5075 END IF;
5076 /*
5077 IF p_request_rec.date_param4 IS NOT NULL
5078 AND p_request_rec.date_param4 <> FND_API.G_MISS_DATE THEN
5079 l_Schedule_ship_date := p_request_rec.date_param4;
5080 END IF;
5081 */
5082 IF l_debug_level > 0 THEN
5083 oe_debug_pub.add( 'L_SCHEDULE_SHIP_DATE :' || L_SCHEDULE_SHIP_DATE , 1 ) ;
5084 oe_debug_pub.add( 'L_REQUEST_DATE :' || L_REQUEST_DATE , 1 ) ;
5085 oe_debug_pub.add( 'L_LINE_ID :' || L_LINE_ID , 1 ) ;
5086 oe_debug_pub.add( 'L_SET_ID :' || L_SET_ID , 1 ) ;
5087 oe_debug_pub.add( 'L_SCHEDULE_ARRIVAL_DATE :' ||l_schedule_arrival_date,1);
5088 oe_debug_pub.add( 'l_ship_from_org_id :' ||l_ship_from_org_id,1);
5089 END IF;
5090
5091 l_set_id := p_request_rec.param1;
5092 IF l_debug_level > 0 THEN
5093 oe_debug_pub.add( 'CALLING QUERY_SET_LINES' , 1 ) ;
5094 END IF;
5095 BEGIN
5096
5097 IF p_request_rec.param8 = OE_SCHEDULE_UTIL.OESCH_ENTITY_ARRIVAL_SET THEN
5098
5099 Oe_Config_Schedule_Pvt.Query_Set_Lines
5100 (p_header_id => l_header_id,
5101 p_arrival_set_id => l_set_id,
5102 p_sch_action => l_action,
5103 x_line_tbl => l_line_tbl,
5104 x_return_status => x_return_status);
5105
5106 ELSIF p_request_rec.param8 = OE_SCHEDULE_UTIL.OESCH_ENTITY_SHIP_SET THEN
5107
5108 Oe_Config_Schedule_Pvt.Query_Set_Lines
5109 (p_header_id => l_header_id,
5110 p_ship_set_id => l_set_id,
5111 p_sch_action => l_action,
5112 x_line_tbl => l_line_tbl,
5113 x_return_status => x_return_status);
5114
5115 END IF;
5116
5117 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5118 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5119 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
5120 RAISE FND_API.G_EXC_ERROR;
5121 END IF;
5122
5123 EXCEPTION
5124 WHEN OTHERS THEN
5125 IF l_debug_level > 0 THEN
5126 oe_debug_pub.add( 'ERROR AFTER CALLING QUERY_SET_LINES' , 1 ) ;
5127 END IF;
5128 goto END_OF_PROCESS;
5129 END;
5130
5131 IF l_debug_level > 0 THEN
5132 oe_debug_pub.add( 'AFTER CALLING QUERY_SET_LINES' , 1 ) ;
5133 oe_debug_pub.add( 'COUNT IS ' || L_LINE_TBL.COUNT , 1 ) ;
5134 END IF;
5135
5136 -- Start 2716220 --
5137 -- To check schedule dates with override flag
5138 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
5139 FOR I IN 1..l_line_tbl.count LOOP
5140 IF NVL(l_line_tbl(I).override_atp_date_code,'N') = 'Y'
5141 AND l_line_tbl(I).schedule_status_code is NULL
5142 THEN
5143 IF l_override_ship_date IS NULL THEN
5144 l_override_ship_date := l_line_tbl(I).schedule_ship_date;
5145 ELSIF l_line_tbl(I).schedule_ship_date <> l_override_ship_date THEN
5146 -- Dates are different,log the error
5147 l_log_error := TRUE;
5148 EXIT;
5149 END IF;
5150 IF l_override_arrival_date IS NULL THEN
5151 l_override_arrival_date := l_line_tbl(I).schedule_arrival_date;
5152 ELSIF l_line_tbl(I).schedule_arrival_date <> l_override_arrival_date THEN
5153 -- log the error
5154 l_log_error := TRUE;
5155 EXIT;
5156 END IF;
5157 END IF;
5158 IF NVL(l_line_tbl(I).override_atp_date_code,'N') = 'Y'
5159 AND NOT l_set_overridden THEN
5160 l_set_overridden := TRUE;
5161 END IF;
5162 END LOOP;
5163
5164 IF l_log_error THEN
5165 FND_MESSAGE.SET_NAME('ONT','OE_SCH_OVER_ATP_SET_NO_MATCH');
5166 OE_MSG_PUB.Add;
5167 x_return_status := FND_API.G_RET_STS_ERROR;
5168 goto END_OF_PROCESS;
5169 END IF;
5170 END IF; -- code level.
5171
5172 -- End 2716220 -
5173
5174 -- Bypass if required.
5175
5176 IF nvl(p_request_rec.param12,'N') = 'N' THEN
5177 l_set_rec := OE_ORDER_CACHE.Load_Set(l_set_id); --3878494
5178
5179 FOR I IN 1..l_line_tbl.count LOOP
5180
5181 IF l_line_tbl(I).schedule_status_code IS NULL OR
5182 (l_line_tbl(I).item_type_code <> OE_GLOBALS.G_ITEM_STANDARD AND
5183 nvl(l_line_tbl(I).model_remnant_flag,'N') = 'N') THEN
5184
5185 IF l_debug_level > 0 THEN
5186 oe_debug_pub.add( 'UNABLE TO BYPASS' , 2 ) ;
5187 END IF;
5188 l_can_bypass := FALSE;
5189 EXIT;
5190
5191 END IF;
5192 -- following code commented for bug 3878494
5193 /*
5194 IF OE_SCHEDULE_UTIL.Set_Attr_Matched
5195 (p_set_ship_from_org_id => l_line_tbl(1).ship_from_org_id ,
5196 p_line_ship_from_org_id => l_line_tbl(I).ship_from_org_id,
5197 p_set_ship_to_org_id => l_line_tbl(1).ship_to_org_id ,
5198 p_line_ship_to_org_id => l_line_tbl(I).ship_to_org_id ,
5199 p_set_schedule_ship_date => l_line_tbl(1).schedule_ship_date ,
5200 p_line_schedule_ship_date => l_line_tbl(I).schedule_ship_date,
5201 p_set_arrival_date => l_line_tbl(1).schedule_arrival_date,
5202 p_line_arrival_date => l_line_tbl(I).schedule_arrival_date,
5203 p_set_shipping_method_code => l_line_tbl(1).shipping_method_code,
5204 p_line_shipping_method_code => l_line_tbl(I).shipping_method_code,
5205 p_set_type => p_request_rec.param8) THEN
5206 */
5207
5208 -- Bug 6363297 starts
5209 -- Modified below logic for
5210 -- 1) If l_set_rec is blank it means all the lines are being added to a new Set.
5211 -- If all the Lines are already Scheduled and have the same attributes then no need to call MRP again.
5212 -- We can directly put the lines into the same Set.
5213 -- 2) If l_set_rec has values, it means lines are being added to an existing set or scheduling attributes
5214 -- of the lines that are part of the set are being changed.
5215 -- In that case compare the line attributes with that of Set attributes. If any change is found call MRP.
5216 IF l_set_rec.schedule_ship_date IS NULL THEN
5217 IF l_debug_level > 0 THEN
5218 oe_debug_pub.add('New Set is being created, comparing scheduling attributes with first line', 5);
5219 END IF;
5220
5221 IF OE_SCHEDULE_UTIL.Set_Attr_Matched
5222 (p_set_ship_from_org_id => l_line_tbl(1).ship_from_org_id ,
5223 p_line_ship_from_org_id => l_line_tbl(I).ship_from_org_id,
5224 p_set_ship_to_org_id => l_line_tbl(1).ship_to_org_id ,
5225 p_line_ship_to_org_id => l_line_tbl(I).ship_to_org_id ,
5226 p_set_schedule_ship_date => l_line_tbl(1).schedule_ship_date ,
5227 p_line_schedule_ship_date => l_line_tbl(I).schedule_ship_date,
5228 p_set_arrival_date => l_line_tbl(1).schedule_arrival_date,
5229 p_line_arrival_date => l_line_tbl(I).schedule_arrival_date,
5230 p_set_shipping_method_code => l_line_tbl(1).shipping_method_code,
5231 p_line_shipping_method_code => l_line_tbl(I).shipping_method_code,
5232 p_set_type => p_request_rec.param8)
5233 THEN
5234 l_can_bypass := TRUE;
5235 ELSE
5236 l_can_bypass := FALSE;
5237 EXIT;
5238 END IF;
5239 ELSE
5240 IF l_debug_level > 0 THEN
5241 oe_debug_pub.add('Set already exists, comparing scheduling attributes with set', 5);
5242 END IF;
5243
5244 -- following code added for bug 3878494
5245 IF OE_SCHEDULE_UTIL.Set_Attr_Matched
5246 (p_set_ship_from_org_id => l_set_rec.ship_from_org_id ,
5247 p_line_ship_from_org_id => l_line_tbl(I).ship_from_org_id,
5248 p_set_ship_to_org_id => l_set_rec.ship_to_org_id ,
5249 p_line_ship_to_org_id => l_line_tbl(I).ship_to_org_id ,
5250 p_set_schedule_ship_date => l_set_rec.schedule_ship_date ,
5251 p_line_schedule_ship_date => l_line_tbl(I).schedule_ship_date,
5252 p_set_arrival_date => l_set_rec.schedule_arrival_date,
5253 p_line_arrival_date => l_line_tbl(I).schedule_arrival_date,
5254 p_set_shipping_method_code => l_set_rec.shipping_method_code,
5255 p_line_shipping_method_code => l_line_tbl(I).shipping_method_code,
5256 p_set_type => p_request_rec.param8) THEN
5257 l_can_bypass := TRUE;
5258
5259 ELSE
5260 IF l_debug_level > 0 THEN
5261 oe_debug_pub.add( 'LINES DID NOT MATCH' , 2 ) ;
5262 END IF;
5263 l_can_bypass := FALSE;
5264 EXIT;
5265 END IF;
5266 END IF;
5267 --Bug 6363297 ends
5268 END LOOP;
5269
5270
5271 IF l_can_bypass THEN
5272
5273 IF l_debug_level > 0 THEN
5274 oe_debug_pub.add( 'ALL LINES MATCH WITH SET DATES , BYPASS MRP CALL' , 2 ) ;
5275 END IF;
5276 GOTO BYPASS_PROCESS;
5277
5278 END IF;
5279
5280 END IF; -- param12.
5281
5282 -- End of bypass
5283
5284 l_old_line_tbl := l_line_tbl;
5285
5286 FOR I IN 1..l_old_line_tbl.count LOOP
5287
5288 IF l_old_line_tbl(1).schedule_status_code is null THEN
5289
5290 l_old_line_tbl(I).schedule_ship_date := null;
5291 l_old_line_tbl(I).schedule_arrival_date := null;
5292 -- l_old_line_tbl(I).ship_set_id := null;
5293 -- l_old_line_tbl(I).arrival_set_id := null;
5294
5295 ELSE
5296 IF l_old_line_tbl(I).line_id = l_line_id THEN
5297 /* l_old_line_tbl(I).ship_set_id :=
5298 l_old_ship_set_id;
5299 l_old_line_tbl(I).arrival_set_id :=
5300 l_old_arrival_set_id;
5301 */
5302 IF l_old_schedule_ship_date is not null THEN
5303 l_old_line_tbl(I).schedule_ship_date :=
5304 l_old_schedule_ship_date;
5305 END IF;
5306 IF l_old_schedule_arrival_date is not null THEN
5307 l_old_line_tbl(I).schedule_arrival_date :=
5308 l_old_schedule_arrival_date;
5309 END IF;
5310
5311 IF l_old_ship_from_org_id is not null THEN
5312
5313 l_old_line_tbl(I).ship_from_org_id :=
5314 l_old_ship_from_org_id;
5315 END IF;
5316 END IF;
5317 END IF;
5318
5319
5320 -- BUG 1282873 (Override Atp)
5321 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509'
5322 AND nvl(l_line_tbl(I).override_atp_date_code,'N') = 'N' THEN
5323
5324 IF (l_line_tbl(I).ato_line_id is not null AND
5325 NOT (l_line_tbl(I).ato_line_id = l_line_tbl(I).line_id AND
5326 l_line_tbl(I).item_type_code IN (OE_GLOBALS.G_ITEM_STANDARD,
5327 OE_GLOBALS.G_ITEM_OPTION,
5328 OE_GLOBALS.G_ITEM_INCLUDED))) --9775352
5329 THEN
5330
5331 BEGIN
5332
5333 Select override_atp_date_code
5334 Into l_line_tbl(I).override_atp_date_code
5335 From oe_order_lines_all
5336 Where header_id = l_line_tbl(I).header_id
5337 And ato_line_id = l_line_tbl(I).ato_line_id
5338 And override_atp_date_code = 'Y'
5339 And rownum < 2;
5340
5341 IF l_debug_level > 0 THEN
5342 oe_debug_pub.add( 'ato override flag :' || l_line_tbl ( I ) .override_atp_date_code , 3 ) ;
5343 END IF;
5344 EXCEPTION
5345 WHEN OTHERS THEN
5346 Null;
5347
5348 END;
5349 IF l_debug_level > 0 THEN
5350 oe_debug_pub.add( 'override_atp for ato :' || L_LINE_TBL ( I ) .OVERRIDE_ATP_DATE_CODE || L_LINE_TBL ( I ) .LINE_ID , 3 ) ;
5351 END IF;
5352 ELSIF l_line_tbl(I).item_type_code = OE_GLOBALS.G_ITEM_INCLUDED THEN
5353
5354
5355 BEGIN
5356
5357
5358 Select override_atp_date_code
5359 Into l_line_tbl(I).override_atp_date_code
5360 From oe_order_lines_all
5361 Where header_id = l_line_tbl(I).header_id
5362 And line_id = l_line_tbl(I).link_to_line_id;
5363
5364 IF l_debug_level > 0 THEN
5365 oe_debug_pub.add( 'INC OVERRIDE FLAG :' || L_LINE_TBL ( I ) .OVERRIDE_ATP_DATE_CODE , 3 ) ;
5366 END IF;
5367 EXCEPTION
5368 WHEN OTHERS THEN
5369 Null;
5370
5371 END;
5372 IF l_debug_level > 0 THEN
5373 oe_debug_pub.add( 'override_atp for inc :' || L_LINE_TBL ( I ) .OVERRIDE_ATP_DATE_CODE || L_LINE_TBL ( I ) .LINE_ID , 3 ) ;
5374 END IF;
5375 END IF; -- Ato/included.
5376 END IF; -- Check for pack I
5377 -- END 1282873
5378 END LOOP;
5379 IF l_entity_type = OE_SCHEDULE_UTIL.OESCH_ENTITY_SHIP_SET THEN
5380
5381 l_set_rec := OE_ORDER_CACHE.Load_Set(l_set_id);
5382 l_set_name := l_set_rec.set_name;
5383
5384 FOR I IN 1..l_line_tbl.count LOOP
5385
5386 l_line_tbl(I).ship_set := l_set_name;
5387 l_line_tbl(I).schedule_action_code := l_action;
5388
5389 /* Added for Bug 6250075 */
5390 l_line_tbl(I).change_reason := 'SYSTEM';
5391 l_line_tbl(I).change_comments := 'Delayed Request , Scheduling';
5392 /* End of Bug 6250075 */
5393
5394 IF fnd_profile.value('ONT_SHIP_METHOD_FOR_SHIP_SET') = 'Y' THEN
5395 oe_debug_pub.add('ONT_SHIP_METHOD_FOR_SHIP_SET: ' || p_request_rec.param11,2);
5396 l_line_tbl(I).shipping_method_code := p_request_rec.param11;
5397 END IF;
5398 -- l_line_tbl(I).shipping_method_code := p_request_rec.param11;
5399 /* Commented the above line to fix the bug 2916814 */
5400 /* -- 2716220
5401 IF l_line_tbl(I).override_atp_date_code = 'Y' AND
5402 l_line_tbl(I).schedule_status_code is NULL THEN
5403 -- Donot cascade the scheduling attributes since it is overridden line .
5404 null;
5405 ELSE
5406 */
5407 IF l_set_ship_to_org_id is not null THEN
5408 l_line_tbl(I).ship_to_org_id := l_set_ship_to_org_id;
5409 ELSIF (l_ship_to_org_id is not null) THEN
5410 l_line_tbl(I).ship_to_org_id := l_ship_to_org_id;
5411 END IF;
5412
5413 IF l_set_ship_from_org_id is not null THEN
5414 l_line_tbl(I).ship_from_org_id :=
5415 l_set_ship_from_org_id;
5416 END IF; --12642790
5417 IF (l_ship_from_org_id is not null)
5418 AND NOT OE_GLOBALS.Equal( l_ship_from_org_id,
5419 l_old_ship_from_org_id) THEN -- 12642790
5420 l_line_tbl(I).ship_from_org_id :=
5421 l_ship_from_org_id;
5422 END IF;
5423
5424 IF l_line_tbl(I).ship_from_org_id IS NOT NULL THEN
5425
5426 l_line_tbl(I).re_source_flag := 'N';
5427 END IF;
5428
5429 IF l_debug_level > 0 THEN
5430 oe_debug_pub.add( 'REQUEST DATE :' || L_REQUEST_DATE , 1 ) ;
5431 END IF;
5432
5433 -- Start 2787962
5434 IF l_line_tbl(I).top_model_line_id is not null
5435 AND oe_schedule_util.OE_sch_Attrb_Tbl.EXISTS(mod(l_line_tbl(I).top_model_line_id, G_BINARY_LIMIT) )
5436 AND oe_schedule_util.OE_sch_Attrb_Tbl(mod(l_line_tbl(I).top_model_line_id, G_BINARY_LIMIT)).date_attribute1 is not null
5437 THEN
5438 l_line_tbl(I).request_date := oe_schedule_util.OE_sch_Attrb_Tbl(mod(l_line_tbl(I).top_model_line_id, G_BINARY_LIMIT)).date_attribute1;
5439 ELSIF l_line_tbl(I).ato_line_id is not null
5440 AND NOT(l_line_tbl(I).ato_line_id = l_line_tbl(I).line_id
5441 AND l_line_tbl(I).item_type_code IN (OE_GLOBALS.G_ITEM_STANDARD, OE_GLOBALS.G_ITEM_OPTION,OE_GLOBALS.G_ITEM_INCLUDED)) --9775352
5442 AND oe_schedule_util.OE_sch_Attrb_Tbl.EXISTS(mod(l_line_tbl(I).ato_line_id, G_BINARY_LIMIT) )
5443 AND oe_schedule_util.OE_sch_Attrb_Tbl(mod(l_line_tbl(I).ato_line_id, G_BINARY_LIMIT)).date_attribute1 is not null
5444 THEN
5445 l_line_tbl(I).request_date := oe_schedule_util.OE_sch_Attrb_Tbl(mod(l_line_tbl(I).ato_line_id, G_BINARY_LIMIT)).date_attribute1;
5446 ELSIF l_line_tbl(I).item_type_code = OE_GLOBALS.G_ITEM_INCLUDED
5447 AND oe_schedule_util.OE_sch_Attrb_Tbl.EXISTS(mod(l_line_tbl(I).link_to_line_id, G_BINARY_LIMIT) )
5448 AND oe_schedule_util.OE_sch_Attrb_Tbl(mod(l_line_tbl(I).link_to_line_id, G_BINARY_LIMIT)).date_attribute1 is not null
5449 THEN
5450 l_line_tbl(I).request_date := oe_schedule_util.OE_sch_Attrb_Tbl(mod(l_line_tbl(I).link_to_line_id, G_BINARY_LIMIT)).date_attribute1;
5451
5452 END IF;
5453 -- End 2787962
5454
5455 IF (l_request_date is not null
5456 AND NOT OE_GLOBALS.Equal( l_request_date,
5457 l_old_request_date)) THEN
5458
5459 IF NOT l_set_overridden THEN
5460 --4483035
5461 --l_line_tbl(I).schedule_ship_date := l_request_date;
5462 --4929511
5463 IF l_line_tbl(I).schedule_status_code is NULL
5464 AND l_line_tbl(I).schedule_ship_date IS NULL THEN
5465 l_line_tbl(I).schedule_ship_date := l_line_tbl(I).request_date;
5466 END IF;
5467 END IF;
5468
5469 -- l_line_tbl(I).request_date := l_request_date; 2787962
5470
5471 END IF;
5472
5473 IF l_set_schedule_ship_date is not null THEN
5474 l_line_tbl(I).schedule_ship_date :=
5475 l_set_schedule_ship_date;
5476 -- 4929511 :Commented
5477 -- 12602958 Uncommented
5478 ELSIF (l_schedule_ship_date is not null
5479 AND NVL(l_line_tbl(I).OVERRIDE_ATP_DATE_CODE,'N') ='Y'
5480 AND NOT OE_GLOBALS.Equal( l_schedule_ship_date,
5481 l_old_schedule_ship_date)) THEN
5482 l_line_tbl(I).schedule_ship_date :=
5483 l_schedule_ship_date;
5484
5485 END IF;
5486
5487 IF l_line_tbl(I).schedule_ship_date is null THEN
5488 l_line_tbl(I).schedule_ship_date := l_line_tbl(I).request_date;
5489 END IF;
5490
5491 IF l_debug_level > 0 THEN
5492 oe_debug_pub.add( 'request ship date :' || L_LINE_TBL ( I ) .SCHEDULE_SHIP_DATE , 1 ) ;
5493 END IF;
5494
5495
5496 IF l_set_schedule_arrival_date is not null THEN
5497 l_line_tbl(I).schedule_arrival_date :=
5498 l_set_schedule_arrival_date;
5499 -- 4929511 :Commented
5500 -- 12602958 Uncommented
5501 ELSIF (l_schedule_arrival_date is not null
5502 AND NVL(l_line_tbl(I).OVERRIDE_ATP_DATE_CODE,'N') ='Y'
5503 AND NOT OE_GLOBALS.Equal( l_schedule_arrival_date,
5504 l_old_schedule_arrival_date)) THEN
5505 l_line_tbl(I).schedule_arrival_date :=
5506 l_schedule_arrival_date;
5507 END IF;
5508 -- END IF; -- 2716220
5509
5510 l_line_tbl(I).operation := OE_GLOBALS.G_OPR_UPDATE;
5511 IF l_debug_level > 0 THEN
5512 oe_debug_pub.add('request date :' || l_line_tbl(i).request_date , 1 ) ;
5513 oe_debug_pub.add('schedule_ship_date :' || l_line_tbl(I).schedule_ship_date , 1 ) ;
5514 oe_debug_pub.add('schedule_arrival_date :' || l_line_tbl(I).schedule_arrival_date , 1 ) ;
5515 oe_debug_pub.add('ship_from_org_id :' || l_line_tbl(I).ship_from_org_id , 1 ) ;
5516 END IF;
5517 END LOOP;
5518 END IF; -- Ship Set
5519
5520 IF l_entity_type =
5521 OE_SCHEDULE_UTIL.OESCH_ENTITY_ARRIVAL_SET THEN
5522
5523 l_set_rec := OE_ORDER_CACHE.Load_Set(l_set_id);
5524 l_set_name := l_set_rec.set_name;
5525
5526 /* Added for Bug 6250075 */
5527 /*
5528 Bug 6309823
5529 Moved this piece of code added through bug 6250075 into the below FOR loop
5530 l_line_tbl(I).change_reason := 'SYSTEM';
5531 l_line_tbl(I).change_comments := 'Delayed Request , Scheduling';
5532 */
5533 /* End of Bug 6250075 */
5534
5535 FOR I IN 1..l_line_tbl.count LOOP
5536
5537 l_line_tbl(I).arrival_set := l_set_name;
5538 l_line_tbl(I).schedule_action_code := l_action;
5539
5540 --Bug 6309823
5541 l_line_tbl(I).change_reason := 'SYSTEM';
5542 l_line_tbl(I).change_comments := 'Delayed Request , Scheduling';
5543
5544 -- 2716220
5545 /* IF l_line_tbl(I).override_atp_date_code = 'Y' AND
5546 l_line_tbl(I).schedule_status_code is NULL THEN
5547 -- Donot cascade the scheduling attributes since it is overridden line .
5548 null;
5549 ELSE
5550 */
5551
5552 IF l_set_ship_to_org_id is not null THEN
5553 l_line_tbl(I).ship_to_org_id := l_set_ship_to_org_id;
5554 ELSIF l_ship_to_org_id is not null THEN
5555 l_line_tbl(I).ship_to_org_id := l_ship_to_org_id;
5556 END IF;
5557
5558 -- Start 2787962
5559 IF l_line_tbl(I).top_model_line_id is not null
5560 AND oe_schedule_util.OE_sch_Attrb_Tbl.EXISTS(mod(l_line_tbl(I).top_model_line_id, G_BINARY_LIMIT) )
5561 AND oe_schedule_util.OE_sch_Attrb_Tbl(mod(l_line_tbl(I).top_model_line_id, G_BINARY_LIMIT)).date_attribute1 is not null
5562 THEN
5563 l_line_tbl(I).request_date := oe_schedule_util.OE_sch_Attrb_Tbl(mod(l_line_tbl(I).top_model_line_id, G_BINARY_LIMIT)).date_attribute1;
5564 ELSIF l_line_tbl(I).ato_line_id is not null
5565 AND NOT(l_line_tbl(I).ato_line_id = l_line_tbl(I).line_id
5566 AND l_line_tbl(I).item_type_code IN (OE_GLOBALS.G_ITEM_STANDARD, OE_GLOBALS.G_ITEM_OPTION, OE_GLOBALS.G_ITEM_INCLUDED)) --9775352
5567 AND oe_schedule_util.OE_sch_Attrb_Tbl.EXISTS(mod(l_line_tbl(I).ato_line_id, G_BINARY_LIMIT) )
5568 AND oe_schedule_util.OE_sch_Attrb_Tbl (mod(l_line_tbl(I).ato_line_id, G_BINARY_LIMIT)).date_attribute1 is not null
5569 THEN
5570 l_line_tbl(I).request_date := oe_schedule_util.OE_sch_Attrb_Tbl(mod(l_line_tbl(I).ato_line_id, G_BINARY_LIMIT)).date_attribute1;
5571 ELSIF l_line_tbl(I).item_type_code = OE_GLOBALS.G_ITEM_INCLUDED
5572 AND oe_schedule_util.OE_sch_Attrb_Tbl.EXISTS(mod(l_line_tbl(I).link_to_line_id, G_BINARY_LIMIT) )
5573 AND oe_schedule_util.OE_sch_Attrb_Tbl(mod(l_line_tbl(I).link_to_line_id, G_BINARY_LIMIT)).date_attribute1 is not null
5574 THEN
5575 l_line_tbl(I).request_date := oe_schedule_util.OE_sch_Attrb_Tbl(mod(l_line_tbl(I).link_to_line_id, G_BINARY_LIMIT)).date_attribute1;
5576
5577 END IF;
5578 -- End 2787962
5579
5580 -- Start 2391781
5581 IF NVL(l_line_tbl(I).Ship_model_complete_flag,'N') = 'Y'
5582 AND oe_schedule_util.OE_sch_Attrb_Tbl.EXISTS(mod(l_line_tbl(I).top_model_line_id, G_BINARY_LIMIT) )
5583 AND oe_schedule_util.OE_sch_Attrb_Tbl(mod(l_line_tbl(I).top_model_line_id, G_BINARY_LIMIT)).attribute1 is not null
5584 THEN
5585 l_line_tbl(I).Ship_from_org_id := oe_schedule_util.OE_sch_Attrb_Tbl(mod(l_line_tbl(I).top_model_line_id, G_BINARY_LIMIT)).attribute1;
5586 ELSIF l_line_tbl(I).ato_line_id is not null
5587 AND NOT(l_line_tbl(I).ato_line_id = l_line_tbl(I).line_id
5588 AND l_line_tbl(I).item_type_code IN (OE_GLOBALS.G_ITEM_STANDARD,
5589 OE_GLOBALS.G_ITEM_OPTION,
5590 OE_GLOBALS.G_ITEM_INCLUDED)) --9775352
5591 AND oe_schedule_util.OE_sch_Attrb_Tbl.EXISTS(mod(l_line_tbl(I).ato_line_id, G_BINARY_LIMIT) )
5592 AND oe_schedule_util.OE_sch_Attrb_Tbl(mod(l_line_tbl(I).ato_line_id, G_BINARY_LIMIT)).attribute1 is not null
5593 THEN
5594 l_line_tbl(I).Ship_from_org_id := oe_schedule_util.OE_sch_Attrb_Tbl(mod(l_line_tbl(I).ato_line_id, G_BINARY_LIMIT)).attribute1;
5595 END IF;
5596
5597 -- 2391781
5598
5599 IF (l_request_date is not null
5600 AND NOT OE_GLOBALS.Equal( l_request_date,
5601 l_old_request_date)) THEN
5602 IF NOT l_set_overridden THEN
5603 --4483035
5604 --l_line_tbl(I).schedule_arrival_date := l_request_date;
5605 --4929511
5606 IF l_line_tbl(I).schedule_status_code is NULL
5607 AND l_line_tbl(I).schedule_arrival_date IS NULL THEN
5608 l_line_tbl(I).schedule_arrival_date := l_line_tbl(I).request_date;
5609 END IF;
5610 END IF;
5611 -- l_line_tbl(I).request_date := l_request_date; 2787962
5612 END IF;
5613
5614 IF l_set_schedule_arrival_date is not null THEN
5615 l_line_tbl(I).schedule_arrival_date :=
5616 l_set_schedule_arrival_date;
5617 --4929511 : Commented
5618 --12602958 Uncommented
5619 ELSIF (l_schedule_arrival_date is not null
5620 AND NVL(l_line_tbl(I).OVERRIDE_ATP_DATE_CODE,'N') ='Y'
5621 AND NOT OE_GLOBALS.Equal( l_schedule_arrival_date,
5622 l_old_schedule_arrival_date)) THEN
5623 l_line_tbl(I).schedule_arrival_date := l_schedule_arrival_date;
5624
5625 END IF;
5626
5627 IF l_line_tbl(I).schedule_arrival_date is null THEN
5628 l_line_tbl(I).schedule_arrival_date :=
5629 l_line_tbl(I).request_date;
5630 END IF;
5631 IF l_set_schedule_ship_date is not null THEN -- 3281742
5632 l_line_tbl(I).schedule_ship_date :=
5633 l_set_schedule_ship_date;
5634 --4929511 : Commented
5635 ----12602958 Uncommented
5636 ELSIF (l_schedule_ship_date is not null
5637 AND NVL(l_line_tbl(I).OVERRIDE_ATP_DATE_CODE,'N') ='Y'
5638 AND NOT OE_GLOBALS.Equal( l_schedule_ship_date,
5639 l_old_schedule_ship_date)) THEN
5640 l_line_tbl(I).schedule_ship_date :=
5641 l_schedule_ship_date;
5642 END IF;
5643 -- END IF; -- 2716220
5644
5645 IF l_debug_level > 0 THEN
5646 oe_debug_pub.add( 'REQUEST ARRIVAL DATE :' || L_LINE_TBL ( I ) .SCHEDULE_ARRIVAL_DATE , 1 ) ;
5647 END IF;
5648
5649
5650 l_line_tbl(I).operation := OE_GLOBALS.G_OPR_UPDATE;
5651
5652 END LOOP;
5653 END IF;
5654
5655 -- Start 2391781
5656 --- Deleteing delayed request of type cascade_warehous
5657 l_index := oe_schedule_util.OE_sch_Attrb_Tbl.FIRST;
5658 WHILE l_index is not null
5659 LOOP
5660 IF oe_schedule_util.OE_sch_Attrb_Tbl(l_index).set_id =l_set_id
5661 THEN
5662 oe_schedule_util.OE_sch_Attrb_Tbl.delete(l_index);
5663 END IF;
5664 l_index := oe_schedule_util.OE_sch_Attrb_Tbl.NEXT(l_index);
5665 END LOOP;
5666
5667 -- End 2391781
5668
5669 IF OE_SCHEDULE_UTIL.OE_Override_Tbl.count > 0 THEN
5670 FOR I IN 1..l_line_tbl.count LOOP
5671
5672 IF OE_SCHEDULE_UTIL.OE_Override_Tbl.EXISTS
5673 (l_line_tbl(I).line_id) THEN
5674
5675 OE_SCHEDULE_UTIL.OE_Override_Tbl.delete
5676 (l_line_tbl(I).line_id);
5677
5678 END IF;
5679
5680 END LOOP;
5681 END IF;
5682 IF l_debug_level > 0 THEN
5683 oe_debug_pub.add( 'CALLING PROCESS_GROUP' , 1 ) ;
5684 END IF;
5685
5686 IF l_line_tbl.count > 0 THEN
5687
5688
5689 Validate_Group
5690 (p_x_line_tbl => l_line_tbl,
5691 p_sch_action => l_action,
5692 x_return_status => x_return_status);
5693
5694 END IF;
5695
5696 IF l_debug_level > 0 THEN
5697 oe_debug_pub.add( 'AFTER CALLING Validate Group ' || X_RETURN_STATUS
5698 || l_line_tbl.count || ':' || l_old_line_tbl.count , 1 ) ;
5699 END IF;
5700
5701 IF l_line_tbl.count <> l_old_line_tbl.count THEN
5702 x_return_status := FND_API.G_RET_STS_ERROR;
5703 RAISE FND_API.G_EXC_ERROR;
5704 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5705 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5706 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
5707 RAISE FND_API.G_EXC_ERROR;
5708 END IF;
5709
5710 /*
5711 Oe_Config_Schedule_Pvt.Process_Group
5712 (p_x_line_tbl => l_line_tbl
5713 ,p_old_line_tbl => l_old_line_tbl
5714 ,p_caller => 'SET'
5715 ,p_sch_action => l_action
5716 ,x_return_status => x_return_status);
5717 */
5718 /* Commented the above code and added the following code to fix the bug 2740480 */
5719 IF l_push_logic = 'Y' THEN
5720
5721 oe_debug_pub.add('2740480: Push logic is set to Y ',2);
5722 Oe_Config_Schedule_Pvt.Process_Group
5723 (p_x_line_tbl => l_line_tbl
5724 ,p_old_line_tbl => l_old_line_tbl
5725 ,p_caller => 'SET'
5726 ,p_sch_action => l_action
5727 ,p_partial_set => TRUE
5728 ,x_return_status => x_return_status);
5729
5730 IF l_debug_level > 0 THEN
5731 oe_debug_pub.add('2740480: After call to Process Group :' || x_return_status ,1);
5732 END IF;
5733 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5734 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5735 END IF;
5736 IF x_return_status = FND_API.G_RET_STS_SUCCESS THEN
5737
5738 IF l_debug_level > 0 THEN
5739 oe_debug_pub.add('2740480: Compare output with requested values',1);
5740 END IF;
5741
5742 FOR I IN 1..l_line_tbl.count LOOP
5743 oe_debug_pub.add('2740480: Entity type : '|| l_entity_type);
5744 oe_debug_pub.add('2740480: line schedule ship date : '|| l_line_tbl(I).Schedule_ship_date);
5745 oe_debug_pub.add('2740480: set schedule ship date : '|| l_set_rec.Schedule_ship_date );
5746 IF l_entity_type = OE_SCHEDULE_UTIL.OESCH_ENTITY_SHIP_SET
5747 AND trunc(l_line_tbl(I).Schedule_ship_date) <> trunc(l_set_rec.Schedule_ship_date)
5748 THEN
5749 IF l_debug_level > 0 THEN
5750 oe_debug_pub.add('2740480: Not received correct values for ship set',1);
5751 END IF;
5752 l_date_changed := 'Y' ;
5753 EXIT;
5754 ELSIF l_entity_type = OE_SCHEDULE_UTIL.OESCH_ENTITY_ARRIVAL_SET
5755 AND trunc(l_line_tbl(I).Schedule_arrival_date) <> trunc(l_set_rec.Schedule_arrival_date)
5756 THEN
5757 IF l_debug_level > 0 THEN
5758 oe_debug_pub.add('2740480: Not received correct values for arrival set',1);
5759 END IF;
5760 l_date_changed := 'Y' ;
5761 EXIT;
5762 END IF;
5763
5764 END LOOP;
5765 IF l_date_changed = 'N' THEN
5766 GOTO BYPASS_PROCESS;
5767 END IF;
5768
5769 END IF; -- Success.
5770
5771 IF fnd_profile.value('ONT_AUTO_PUSH_GRP_DATE') = 'Y' THEN
5772
5773 IF l_debug_level > 0 THEN
5774 oe_debug_pub.add('2740480: Auto Push Group Date is Yes',2);
5775 END IF;
5776 goto Push;
5777 ELSE
5778
5779 IF l_debug_level > 0 THEN
5780 oe_debug_pub.add('Before setting message for group failure',2);
5781 END IF;
5782
5783 x_return_status := FND_API.G_RET_STS_ERROR;
5784 FND_MESSAGE.SET_NAME('ONT','OE_SCH_GROUP_MEMBER_FAILED');
5785 OE_MSG_PUB.Add;
5786 RAISE FND_API.G_EXC_ERROR;
5787
5788 END IF;
5789
5790 END IF; -- Push logic ends here.
5791
5792 <<PUSH>>
5793
5794 oe_debug_pub.add('2740480: Push logic is set to N ',2);
5795 Oe_Config_Schedule_Pvt.Process_Group
5796 (p_x_line_tbl => l_line_tbl
5797 ,p_old_line_tbl => l_old_line_tbl
5798 ,p_caller => 'SET'
5799 ,p_sch_action => l_action
5800 ,x_return_status => x_return_status);
5801
5802 /* End of code for the bug fix 2740480 */
5803
5804
5805 IF l_debug_level > 0 THEN
5806 oe_debug_pub.add( 'AFTER CALLING PROCESS_GROUP' || X_RETURN_STATUS , 1 ) ;
5807 END IF;
5808
5809 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5810 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5811 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
5812 -- RAISE FND_API.G_EXC_ERROR;
5813
5814 -- Code added for bug 2812346
5815
5816 IF l_debug_level > 0 THEN
5817 oe_debug_pub.add('l_operation :' || l_operation,2);
5818 oe_debug_pub.add('l_set_rec.set_status :' || l_set_rec.set_status,2);
5819 END IF;
5820 IF l_operation = OE_GLOBALS.G_OPR_CREATE
5821 AND l_set_rec.set_status = 'T' THEN
5822 -- Could not schedule the line on the set date. Let's schedule
5823 -- the whole set to see if we get another date got the whole
5824 -- set.
5825 --4241385
5826 /* checking the if condition, so that lines will not be removed from the set,
5827 if scheduling fails, in case auto scheduling is turned on.*/
5828 IF NVL(oe_sys_parameters.Value('ONT_AUTO_SCH_SETS',l_org_id),'Y')='Y' THEN
5829 FOR I IN 1..l_line_tbl.count LOOP
5830
5831 -- IF l_line_tbl(I).schedule_status_code IS NULL --commented for bug3986288
5832 -- THEN
5833 -- uncommented for bug 4188166
5834 IF l_line_tbl(I).schedule_status_code IS NULL OR
5835 l_old_line_tbl(I).schedule_status_code IS NULL
5836 THEN
5837
5838 IF l_line_tbl(I).top_model_line_id is null
5839 OR l_line_tbl(I).top_model_line_id =
5840 l_line_tbl(I).line_id
5841 OR (l_line_tbl(I).top_model_line_id is not null
5842 AND l_line_tbl(I).top_model_line_id <> l_line_tbl(I).line_id
5843 AND Not_part_of_set(l_line_tbl(I).top_model_line_id))
5844 THEN
5845
5846 UPDATE OE_ORDER_LINES_ALL
5847 SET SCHEDULE_SHIP_DATE = Null,
5848 SCHEDULE_ARRIVAL_DATE = Null,
5849 SHIP_FROM_ORG_ID = decode(re_source_flag,'N',ship_from_org_id,null),
5850 SHIP_SET_ID = Null,
5851 ARRIVAL_SET_ID = Null,
5852 override_atp_date_code = Null
5853 WHERE line_id = l_line_tbl(I).line_id;
5854
5855 -- 4026758
5856 IF l_line_tbl(I).ship_set_id IS NOT NULL
5857 OR l_line_tbl(I).arrival_set_id IS NOT NULL THEN
5858 oe_schedule_util.Log_Delete_Set_Request
5859 (p_header_id => l_line_tbl(I).header_id,
5860 p_line_id => l_line_tbl(I).line_id,
5861 p_set_id => nvl(l_line_tbl(I).ship_set_id,l_line_tbl(I).arrival_set_id),
5862 x_return_status => x_return_status);
5863 IF l_debug_level > 0 THEN
5864 oe_debug_pub.add( 'AFTER LOGGING DELETE SETS DELAYED REQUEST ' || X_RETURN_STATUS , 1 ) ;
5865 END IF;
5866 END IF;
5867
5868 ELSE
5869
5870 IF l_debug_level > 0 THEN
5871 oe_debug_pub.add('Model is part of a set cannot save ' ,2);
5872 END IF;
5873
5874 RAISE FND_API.G_EXC_ERROR;
5875 END IF;
5876 END IF; -- bug 4188166
5877 -- END IF; --commented for bug3986288
5878 END LOOP;
5879 ELSE
5880 l_set_rec.set_status := 'A'; --4241385
5881 END IF ; --4241385
5882
5883 IF l_debug_level > 0 THEN
5884 oe_debug_pub.add('It is a create operation ' ,2);
5885 END IF;
5886 fnd_message.set_name('ONT','OE_SCH_SET_INS_FAILED');
5887 OE_MSG_PUB.Add;
5888 x_return_status := FND_API.G_RET_STS_SUCCESS;
5889 IF l_debug_level > 0 THEN
5890 oe_debug_pub.add('x_return_status ' || x_return_status,2);
5891 END IF;
5892 GOTO END_OF_PROCESS;
5893 ELSE -- Create
5894 IF l_debug_level > 0 THEN
5895 oe_debug_pub.add('It is not a create operation ' ,2);
5896 END IF;
5897
5898 RAISE FND_API.G_EXC_ERROR;
5899 END IF; -- Create.
5900 END IF;
5901
5902 -- If scheduling set suceeded, then the result of scheduling
5903 -- have been updated to the database. Will query one of the lines
5904 -- of the set to see the change is set attributes so that we can
5905 -- update the set itself.
5906 /*
5907 l_old_line_rec := l_old_line_tbl(1);
5908 OE_Line_Util.Query_Row( p_line_id => l_old_line_rec.line_id,
5909 x_line_rec => l_line_rec);
5910
5911 -- Update the set attributes.
5912
5913 l_ship_from_org_id := l_line_rec.ship_from_org_id;
5914 l_ship_to_org_id := l_line_rec.ship_to_org_id;
5915 l_schedule_ship_date := l_line_rec.schedule_ship_date;
5916 l_schedule_arrival_date := l_line_rec.schedule_arrival_date;
5917 l_shipping_method_code := l_line_rec.shipping_method_code;
5918 */
5919
5920 <<BYPASS_PROCESS>>
5921 BEGIN
5922 /* Removed the shipping_method_code from the following select to fix the bug 2916814 */
5923 Select ship_from_org_id, ship_to_org_id, schedule_ship_date,
5924 schedule_arrival_date,Shipping_Method_Code,
5925 Freight_Carrier_Code,shipment_priority_code
5926 INTO l_ship_from_org_id,l_ship_to_org_id,l_schedule_ship_date,
5927 l_schedule_arrival_date,l_Shipping_Method_Code,
5928 l_Freight_Carrier_Code,l_shipment_priority_code
5929 From oe_order_lines_all
5930 Where line_id = l_line_tbl(1).line_id;
5931
5932 IF l_debug_level > 0 THEN
5933 oe_debug_pub.add( 'CALLING UPDATE SET' ) ;
5934 END IF;
5935
5936 OE_Set_Util.Update_Set
5937 (p_Set_Id => l_set_id,
5938 p_Ship_From_Org_Id => l_Ship_From_Org_Id,
5939 p_Ship_To_Org_Id => l_Ship_To_Org_Id,
5940 p_Schedule_Ship_Date => l_Schedule_Ship_Date,
5941 p_Schedule_Arrival_Date => l_Schedule_Arrival_Date,
5942 p_Freight_Carrier_Code => l_Freight_Carrier_Code,
5943 p_Shipping_Method_Code => l_Shipping_Method_Code,
5944 p_shipment_priority_code => l_shipment_priority_code,
5945 X_Return_Status => x_return_status,
5946 x_msg_count => l_msg_count,
5947 x_msg_data => l_msg_data
5948 );
5949
5950 IF l_debug_level > 0 THEN
5951 oe_debug_pub.add( 'AFTER CALLING UPDATE SET' ) ;
5952 END IF;
5953
5954 EXCEPTION
5955 WHEN OTHERS THEN
5956 Null;
5957 END;
5958 <<END_OF_PROCESS>>
5959 G_TOP_MODEL_LINE_ID := Null;
5960 G_PART_OF_SET := Null;
5961
5962 IF l_debug_level > 0 THEN
5963 oe_debug_pub.add('Exiting Schedule_Set',0.5); -- debug level changed to 0.5 for bug 13435459
5964 END IF;
5965 EXCEPTION
5966 WHEN FND_API.G_EXC_ERROR THEN
5967 --3543774 If new set show the error message
5968 IF p_request_rec.request_type = OE_GLOBALS.G_GROUP_SCHEDULE
5969 AND ((l_entity_type =
5970 OE_SCHEDULE_UTIL.OESCH_ENTITY_SHIP_SET
5971 AND NOT OE_GLOBALS.equal(l_ship_set_id,l_old_ship_set_id))
5972 OR (l_entity_type =
5973 OE_SCHEDULE_UTIL.OESCH_ENTITY_ARRIVAL_SET
5974 AND NOT OE_GLOBALS.equal(l_arrival_set_id,l_old_arrival_set_id)))
5975 THEN
5976 fnd_message.set_name('ONT','OE_SCH_SET_INS_FAILED');
5977 OE_MSG_PUB.Add;
5978 END IF;
5979 G_TOP_MODEL_LINE_ID := Null;
5980 G_PART_OF_SET := Null;
5981 x_return_status := FND_API.G_RET_STS_ERROR;
5982
5983 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5984
5985 G_TOP_MODEL_LINE_ID := Null;
5986 G_PART_OF_SET := Null;
5987 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5988
5989 WHEN OTHERS THEN
5990
5991 G_TOP_MODEL_LINE_ID := Null;
5992 G_PART_OF_SET := Null;
5993 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5994
5995 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5996 THEN
5997 OE_MSG_PUB.Add_Exc_Msg
5998 ( G_PKG_NAME
5999 , 'Schedule_Set'
6000 );
6001 END IF;
6002 END Schedule_Set;
6003 /***************************************************
6004 Procedure Group_Schedule_sets has been written to take care
6005 of set_for_each_line project.
6006
6007 p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
6008 p_entity_id => nvl(p_line_rec.ship_set_id,p_line_rec.arrival_set_
6009 id),
6010 p_requesting_entity_code => OE_GLOBALS.G_ENTITY_LINE,
6011 p_requesting_entity_id => p_line_rec.line_id,
6012 p_request_type => OE_GLOBALS.G_GROUP_SET,
6013 p_param1 => l_set_type,
6014 p_param2 => p_line_rec.header_id,
6015 p_param3 => p_line_rec.line_id,
6016 p_param4 => p_line_rec.top_model_line_id,
6017 p_param5 => p_line_rec.ship_to_org_id, -- added for bug 4188166
6018 p_param6 => p_line_rec.ship_from_org_id, -- added for bug 4188166
6019 x_return_status => x_return_status);
6020
6021
6022 ****************************************************/
6023
6024 Procedure Group_Schedule_sets
6025 ( p_sch_set_tbl IN OE_ORDER_PUB.request_tbl_type
6026 , x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
6027 IS
6028 l_line_tbl OE_ORDER_PUB.line_Tbl_type;
6029 l_old_line_tbl OE_ORDER_PUB.line_Tbl_type;
6030 l_sch_line_tbl OE_ORDER_PUB.line_Tbl_type;
6031 l_count NUMBER := 0;
6032 l_set_rec OE_ORDER_CACHE.set_rec_type;
6033 l_msg_count NUMBER;
6034 l_msg_data VARCHAR2(2000);
6035 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
6036 l_set_exists VARCHAR2(1);
6037
6038 --
6039 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6040 --
6041 BEGIN
6042
6043 x_return_status := FND_API.G_RET_STS_SUCCESS;
6044
6045 IF l_debug_level > 0 THEN
6046 oe_debug_pub.add( 'ENTERING Group_Schedule_sets' , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
6047 END IF;
6048
6049 FOR I in 1..p_sch_set_tbl.count LOOP
6050 l_set_exists := 'Y';
6051
6052 IF l_debug_level > 0 THEN
6053 oe_debug_pub.add( 'Processing Line' || P_SCH_SET_TBL(I).ENTITY_ID, 1);
6054 END IF;
6055
6056 l_return_status := FND_API.G_RET_STS_SUCCESS;
6057
6058 BEGIN
6059
6060 Select 'Y'
6061 Into l_set_exists
6062 From oe_order_lines_all
6063 Where header_id = p_sch_set_tbl(I).param2
6064 And (ship_set_id = p_sch_set_tbl(I).entity_id
6065 Or arrival_set_id = p_sch_set_tbl(I).entity_id)
6066 And open_flag = 'Y'
6067 And rownum = 1;
6068
6069 IF l_debug_level > 0 THEN
6070 oe_debug_pub.add( 'Lines exists in the set', 2);
6071 END IF;
6072
6073 EXCEPTION
6074 WHEN NO_DATA_FOUND THEN
6075
6076 l_set_exists := 'N';
6077 WHEN OTHERS THEN
6078 l_set_exists := 'Y';
6079 END;
6080
6081 IF l_debug_level > 0 THEN
6082 oe_debug_pub.add( 'Before quering the date ' || l_set_exists, 2);
6083 END IF;
6084 IF l_set_exists = 'N' THEN
6085 GOTO END_PROCESS;
6086 END IF;
6087 IF p_sch_set_tbl(I).param1 = OE_SCHEDULE_UTIL.OESCH_ENTITY_ARRIVAL_SET
6088 THEN
6089 Oe_Config_Schedule_Pvt.Query_Set_Lines
6090 (p_header_id => p_sch_set_tbl(I).param2,
6091 p_arrival_set_id => p_sch_set_tbl(I).entity_id,
6092 p_sch_action => 'SCHEDULE',
6093 x_line_tbl => l_line_tbl,
6094 x_return_status => l_return_status);
6095
6096
6097 ELSIF p_sch_set_tbl(I).param1 = OE_SCHEDULE_UTIL.OESCH_ENTITY_SHIP_SET
6098 THEN
6099
6100 Oe_Config_Schedule_Pvt.Query_Set_Lines
6101 (p_header_id => p_sch_set_tbl(I).param2,
6102 p_ship_set_id => p_sch_set_tbl(I).entity_id,
6103 p_sch_action => 'SCHEDULE',
6104 x_line_tbl => l_line_tbl,
6105 x_return_status => l_return_status);
6106
6107 END IF;
6108
6109 IF l_debug_level > 0 THEN
6110 oe_debug_pub.add(' L_return_status :' || l_return_status,1);
6111 END IF;
6112
6113 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6114 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6115 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6116 IF l_debug_level > 0 THEN
6117 oe_debug_pub.add(' Goto End due to error',1);
6118 END IF;
6119 GOTO END_PROCESS;
6120 END IF;
6121
6122 FOR J IN 1..l_line_tbl.count LOOP
6123
6124 OE_SCHEDULE_UTIL.Validate_Line(p_line_rec => l_line_tbl(J),
6125 p_old_line_rec => l_line_tbl(J),
6126 p_sch_action => 'SCHEDULE' ,
6127 x_return_status => l_return_status);
6128
6129 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6130
6131 IF l_debug_level > 0 THEN
6132 oe_debug_pub.add(' Error in validation ',1);
6133 END IF;
6134 GOTO END_PROCESS;
6135 END IF;
6136
6137 END LOOP;
6138
6139 l_count := l_sch_line_tbl.count;
6140 FOR J IN 1..l_line_tbl.count LOOP
6141
6142 l_count := l_count + 1;
6143
6144 l_sch_line_tbl(l_count) := l_line_tbl(J);
6145 l_old_line_tbl(l_count) := l_line_tbl(J);
6146
6147 l_sch_line_tbl(l_count).schedule_action_code := 'SCHEDULE';
6148 l_sch_line_tbl(l_count).operation := 'UPDATE';
6149
6150 /* Added for Bug 6250075 */
6151 l_sch_line_tbl(l_count).change_reason := 'SYSTEM';
6152 l_sch_line_tbl(l_count).change_comments := 'Delayed Request , Scheduling';
6153 /* End of Bug 6250075 */
6154
6155 IF nvl(l_line_tbl(J).override_atp_date_code,'N') = 'N'
6156 AND (l_line_tbl(J).ato_line_id is not null AND
6157 NOT (l_line_tbl(J).ato_line_id = l_line_tbl(J).line_id AND
6158 l_line_tbl(J).item_type_code IN (OE_GLOBALS.G_ITEM_STANDARD,
6159 OE_GLOBALS.G_ITEM_OPTION,
6160 OE_GLOBALS.G_ITEM_INCLUDED))) --9775352
6161 THEN
6162
6163 BEGIN
6164
6165 Select override_atp_date_code,
6166 schedule_ship_date,
6167 schedule_arrival_date
6168 Into l_sch_line_tbl(l_count).override_atp_date_code,
6169 l_sch_line_tbl(l_count).schedule_ship_date,
6170 l_sch_line_tbl(l_count).schedule_arrival_date
6171 From oe_order_lines_all
6172 Where header_id = l_line_tbl(J).header_id
6173 And ato_line_id = l_line_tbl(J).ato_line_id
6174 And override_atp_date_code = 'Y'
6175 And rownum < 2;
6176
6177 EXCEPTION
6178 WHEN OTHERS THEN
6179 Null;
6180
6181 END;
6182 END IF;
6183
6184
6185 IF (l_line_tbl(J).arrival_set_id is not null) THEN
6186
6187 l_set_rec := OE_ORDER_CACHE.Load_Set
6188 ( l_line_tbl(J).arrival_set_id);
6189 l_sch_line_tbl(l_count).arrival_set := l_set_rec.set_name;
6190 -- 4188166
6191 IF p_sch_set_tbl(I).param5 IS NOT NULL THEN --5151954
6192 l_sch_line_tbl(l_count).ship_to_org_id := p_sch_set_tbl(I).param5;
6193 END IF;
6194
6195 ELSIF (l_line_tbl(J).ship_set_id is not null) THEN
6196
6197 l_set_rec := OE_ORDER_CACHE.Load_Set
6198 ( l_line_tbl(J).Ship_set_id);
6199 l_sch_line_tbl(l_count).ship_set := l_set_rec.set_name;
6200 -- 4188166
6201 IF p_sch_set_tbl(I).param5 IS NOT NULL THEN --5151954
6202 l_sch_line_tbl(l_count).ship_to_org_id := p_sch_set_tbl(I).param5;
6203 END IF;
6204
6205 IF p_sch_set_tbl(I).param6 IS NOT NULL THEN --5151954
6206 l_sch_line_tbl(l_count).ship_from_org_id := p_sch_set_tbl(I).param6;
6207 END IF;
6208 END IF;
6209
6210
6211 END LOOP; -- lsch_tbl
6212
6213 <<END_PROCESS>>
6214
6215 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6216
6217 IF l_debug_level > 0 THEN
6218 oe_debug_pub.add(' Error in ' || p_sch_set_tbl(I).param1,2);
6219 END IF;
6220
6221 IF p_sch_set_tbl(I).param4 is null
6222 THEN
6223 UPDATE OE_ORDER_LINES_ALL
6224 SET SCHEDULE_SHIP_DATE = Null,
6225 SCHEDULE_ARRIVAL_DATE = Null,
6226 SHIP_FROM_ORG_ID = decode(re_source_flag,'N',ship_from_org_id,null),
6227 SHIP_SET_ID = Null,
6228 ARRIVAL_SET_ID = Null,
6229 OVERRIDE_ATP_DATE_CODE = Null
6230 WHERE line_id = p_sch_set_tbl(I).param3;
6231 ELSE
6232
6233 UPDATE OE_ORDER_LINES_ALL
6234 SET SCHEDULE_SHIP_DATE = Null,
6235 SCHEDULE_ARRIVAL_DATE = Null,
6236 SHIP_FROM_ORG_ID = decode(re_source_flag,'N',ship_from_org_id,null),
6237 SHIP_SET_ID = Null,
6238 ARRIVAL_SET_ID = Null,
6239 OVERRIDE_ATP_DATE_CODE = Null
6240 WHERE top_model_line_id = p_sch_set_tbl(I).param4;
6241 END IF;
6242 -- 4026758
6243 IF l_sch_line_tbl(I).ship_set_id IS NOT NULL
6244 OR l_sch_line_tbl(I).arrival_set_id IS NOT NULL THEN
6245 oe_schedule_util.Log_Delete_Set_Request
6246 (p_header_id => l_sch_line_tbl(I).header_id,
6247 p_line_id => l_sch_line_tbl(I).line_id,
6248 p_set_id => nvl(l_sch_line_tbl(I).ship_set_id,l_sch_line_tbl(I).arrival_set_id),
6249 x_return_status => x_return_status);
6250 IF l_debug_level > 0 THEN
6251 oe_debug_pub.add( 'AFTER LOGGING DELETE SETS DELAYED REQUEST '
6252 || X_RETURN_STATUS , 1 ) ;
6253 END IF;
6254 END IF;
6255 END IF;
6256 IF l_debug_level > 0 THEN
6257 oe_debug_pub.add(' Process next set :' || l_sch_line_tbl.count,1);
6258 END IF;
6259
6260 END LOOP; -- Main loop.
6261
6262 IF l_debug_level > 0 THEN
6263 oe_debug_pub.add('Line Count :' || l_sch_line_tbl.count,1);
6264 END IF;
6265
6266 IF l_sch_line_tbl.count > 0 THEN
6267
6268 Oe_Config_Schedule_Pvt.Process_Group
6269 (p_x_line_tbl => l_sch_line_tbl
6270 ,p_old_line_tbl => l_old_line_tbl
6271 ,p_caller => 'SET'
6272 ,p_sch_action => OE_SCHEDULE_UTIL.OESCH_ACT_SCHEDULE
6273 ,p_partial => TRUE
6274 ,x_return_status => x_return_status);
6275
6276 IF l_debug_level > 0 THEN
6277 oe_debug_pub.add('After call to Process Group :' || x_return_status ,1);
6278 END IF;
6279 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6280 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6281 END IF;
6282 END IF;
6283
6284
6285 FOR I IN 1..l_sch_line_tbl.count LOOP
6286
6287 oe_debug_pub.add('line id :' || l_sch_line_tbl(I).line_id ,1);
6288 oe_debug_pub.add('Schedule status code :' || l_sch_line_tbl(I).schedule_status_code ,1);
6289
6290 -- 4188166
6291 IF x_return_status = FND_API.G_RET_STS_SUCCESS AND
6292 l_sch_line_tbl(I).schedule_status_code IS NOT NULL
6293 THEN
6294
6295 /*
6296 IF l_sch_line_tbl(I).schedule_status_code IS NULL
6297 THEN
6298
6299 IF l_sch_line_tbl(I).top_model_line_id is NULL THEN
6300 UPDATE OE_ORDER_LINES_ALL
6301 SET SCHEDULE_SHIP_DATE = Null,
6302 SCHEDULE_ARRIVAL_DATE = Null,
6303 SHIP_FROM_ORG_ID = decode(re_source_flag,'N',ship_from_org_id,null),
6304 SHIP_SET_ID = Null,
6305 ARRIVAL_SET_ID = Null,
6306 OVERRIDE_ATP_DATE_CODE = Null
6307 WHERE line_id = l_sch_line_tbl(I).line_id;
6308 ELSE
6309 UPDATE OE_ORDER_LINES_ALL
6310 SET SCHEDULE_SHIP_DATE = Null,
6311 SCHEDULE_ARRIVAL_DATE = Null,
6312 SHIP_FROM_ORG_ID = decode(re_source_flag,'N',ship_from_org_id,null),
6313 SHIP_SET_ID = Null,
6314 ARRIVAL_SET_ID = Null,
6315 OVERRIDE_ATP_DATE_CODE = Null
6316 WHERE top_model_line_id = l_sch_line_tbl(I).top_model_line_id;
6317 END IF;
6318
6319 ELSIF l_sch_line_tbl(I).line_id = l_sch_line_tbl(I).top_model_line_id
6320 OR l_sch_line_tbl(I).top_model_line_id is NULL THEN
6321 */
6322
6323 IF l_sch_line_tbl(I).line_id = l_sch_line_tbl(I).top_model_line_id
6324 OR l_sch_line_tbl(I).top_model_line_id is NULL THEN
6325
6326 OE_Set_Util.Update_Set
6327 (p_Set_Id => Nvl(l_sch_line_tbl(I).arrival_Set_id,
6328 l_sch_line_tbl(I).ship_Set_id),
6329 p_Ship_From_Org_Id => l_sch_line_tbl(I).Ship_From_Org_Id,
6330 p_Ship_To_Org_Id => l_sch_line_tbl(I).Ship_To_Org_Id,
6331 p_Schedule_Ship_Date => l_sch_line_tbl(I).Schedule_Ship_Date,
6332 p_Schedule_Arrival_Date => l_sch_line_tbl(I).Schedule_Arrival_Date,
6333 p_Freight_Carrier_Code => l_sch_line_tbl(I).Freight_Carrier_Code,
6334 p_Shipping_Method_Code => l_sch_line_tbl(I).Shipping_Method_Code,
6335 p_shipment_priority_code => l_sch_line_tbl(I).shipment_priority_code,
6336 X_Return_Status => x_return_status,
6337 x_msg_count => l_msg_count,
6338 x_msg_data => l_msg_data
6339 );
6340
6341 END IF;
6342 ELSE -- Return status has error (4188166)
6343
6344 IF l_sch_line_tbl(I).top_model_line_id is null
6345 OR l_sch_line_tbl(I).top_model_line_id = l_sch_line_tbl(I).line_id
6346 OR (l_sch_line_tbl(I).top_model_line_id is not null
6347 AND l_sch_line_tbl(I).top_model_line_id <> l_sch_line_tbl(I).line_id
6348 AND Not_part_of_set(l_sch_line_tbl(I).top_model_line_id))
6349 THEN
6350
6351 UPDATE OE_ORDER_LINES_ALL
6352 SET SCHEDULE_SHIP_DATE = Null,
6353 SCHEDULE_ARRIVAL_DATE = Null,
6354 SHIP_FROM_ORG_ID = decode(re_source_flag,'N',ship_from_org_id,null),
6355 SHIP_SET_ID = Null,
6356 ARRIVAL_SET_ID = Null,
6357 override_atp_date_code = Null
6358 --Bug 5654321
6359 --Modified the record from l_line_tbl to l_sch_line_tbl
6360 --WHERE line_id = l_line_tbl(I).line_id;
6361 WHERE line_id = l_sch_line_tbl(I).line_id;
6362 END IF;
6363
6364 -- Begin 4026758
6365 IF l_sch_line_tbl(I).ship_set_id IS NOT NULL
6366 OR l_sch_line_tbl(I).arrival_set_id IS NOT NULL THEN
6367
6368 oe_schedule_util.Log_Delete_Set_Request
6369 (p_header_id => l_sch_line_tbl(I).header_id,
6370 p_line_id => l_sch_line_tbl(I).line_id,
6371 p_set_id => nvl(l_sch_line_tbl(I).ship_set_id,l_sch_line_tbl(I).arrival_set_id),
6372 x_return_status => l_return_status);
6373
6374 IF l_debug_level > 0 THEN
6375 oe_debug_pub.add('AFTER LOGGING DELETE SETS DELAYED REQUEST ' || L_RETURN_STATUS,1) ;
6376 END IF;
6377
6378 END IF;
6379 -- End 4026758
6380
6381 END IF;
6382 END LOOP;
6383
6384 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
6385 fnd_message.set_name('ONT','OE_SCH_SET_INS_FAILED');
6386 OE_MSG_PUB.Add;
6387 x_return_status := FND_API.G_RET_STS_SUCCESS;
6388 IF l_debug_level > 0 THEN
6389 oe_debug_pub.add('x_return_status ' || x_return_status,2);
6390 END IF;
6391 END IF;
6392 -- End 4188166
6393
6394 IF l_debug_level > 0 THEN
6395 oe_debug_pub.add('Exiting Group_Schedule_sets' || x_return_status,0.5); -- debug level changed to 0.5 for bug 13435459
6396 END IF;
6397
6398 EXCEPTION
6399
6400 WHEN FND_API.G_EXC_ERROR THEN
6401 x_return_status := FND_API.G_RET_STS_ERROR;
6402 IF l_debug_level > 0 THEN
6403 oe_debug_pub.add('No data from expected error',1);
6404 END IF;
6405 RAISE FND_API.G_EXC_ERROR;
6406
6407 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6408
6409 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6410 THEN
6411 OE_MSG_PUB.Add_Exc_Msg
6412 ( G_PKG_NAME
6413 , 'Group_Schedule_sets'
6414 );
6415 END IF;
6416 IF l_debug_level > 0 THEN
6417 oe_debug_pub.add('No data from unexpected error',1);
6418 END IF;
6419
6420 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6421
6422 WHEN OTHERS THEN
6423
6424
6425 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6426 THEN
6427 OE_MSG_PUB.Add_Exc_Msg
6428 ( G_PKG_NAME
6429 , 'Group_Schedule_sets'
6430 );
6431 END IF;
6432 IF l_debug_level > 0 THEN
6433 oe_debug_pub.add('No data from unexpected error',1);
6434 END IF;
6435 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6436 END Group_Schedule_sets;
6437 END OE_GROUP_SCH_UTIL;
6438