[Home] [Help]
PACKAGE BODY: APPS.OE_ORDER_PVT
Source
1 PACKAGE BODY OE_Order_PVT AS
2 /* $Header: OEXVORDB.pls 120.29.12020000.3 2012/08/01 10:49:50 adandu ship $ */
3
4 -- Global constant holding the package name
5
6 G_PKG_NAME CONSTANT VARCHAR2(30) := 'OE_Order_PVT';
7 g_header_id NUMBER;
8 g_upgraded_flag VARCHAR2(1);
9 g_booked_flag VARCHAR2(1);
10
11 -- Header
12
13 -- Global Flags for setting Recursion
14 po_ctr number := 0;
15 hdr_ctr number := 0;
16 hdr_adj_ctr number := 0;
17 hdr_scredit_ctr number := 0;
18 line_ctr number := 0;
19 line_adj_ctr number := 0;
20 line_scredit_ctr number := 0;
21 prn_ctr number := 0;
22 pr_ctr number := 0;
23 prrt_ctr number := 0;
24 poa_ctr number := 0;
25
26 -- Set recursion Mode
27
28 -- SAM
29 TYPE OE_OPTION_INDEX_TBL_TYPE IS TABLE OF NUMBER
30 INDEX BY BINARY_INTEGER;
31 G_BINARY_LIMIT CONSTANT NUMBER := OE_GLOBALS.G_BINARY_LIMIT;
32 --SUN OIP ER
33 TYPE event_Tbl IS TABLE OF boolean
34 INDEX BY BINARY_INTEGER;
35 L_event_tbl event_Tbl;
36 --End of SUN OIP ER
37 Procedure Set_Recursion_Mode (p_Entity_Code number,
38 p_In_Out number := 1)
39 IS
40 --
41 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
42 --
43 Begin
44 IF l_debug_level > 0 THEN
45 oe_debug_pub.add( 'ENTER SET RECURSION MODE' , 1 ) ;
46 oe_debug_pub.add( 'ENTITY CODE-'||P_ENTITY_CODE , 1 ) ;
47 oe_debug_pub.add( 'ENTRY-EXIT MODE -'||P_IN_OUT , 1 ) ;
48 oe_debug_pub.add( 'RECURSION MODE AT ENTRY -' || OE_GLOBALS.G_RECURSION_MODE , 1 ) ;
49 oe_debug_pub.add( 'RECURSION MODE WITHOUT EXP AT ENTRY -' || OE_ORDER_UTIL.G_RECURSION_WITHOUT_EXCEPTION , 1 ) ;
50 END IF;
51
52 IF p_entity_code = 1 THEN
53 IF p_In_Out = 1 THEN
54 po_ctr := po_ctr + 1;
55 ELSIF p_In_Out = 0 THEN
56 po_ctr := po_ctr - 1;
57 END IF;
58 IF (line_ctr > 0 OR
59 Hdr_ctr > 0 OR
60 Hdr_adj_ctr > 0 OR
61 Hdr_scredit_ctr > 0 OR
62 line_adj_ctr > 0 OR
63 line_scredit_ctr > 0 OR
64 prn_ctr > 0 OR
65 pr_ctr > 0 ) THEN
66 --prrt_ctr > 0 ) THEN
67 oe_globals.g_recursion_mode := 'Y';
68 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'Y';
69 ELSE
70 oe_globals.g_recursion_mode := 'N';
71 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'N';
72 END IF;
73
74 /* This is added to control notification call to just one call out. */
75 IF po_ctr > 1 THEN
76 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'Y';
77 ELSE
78 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'N';
79 END IF;
80
81 NULL;
82 ELSIF p_entity_code = 2 THEN
83
84 IF p_In_Out = 1 THEN
85 hdr_ctr := hdr_ctr + 1;
86 ELSIF p_In_Out = 0 THEN
87 hdr_ctr := hdr_ctr - 1;
88 END IF;
89 IF hdr_ctr > 1 THEN
90 oe_globals.g_recursion_mode := 'Y';
91 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'Y';
92 ELSE
93 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'N';
94 null; /* SAM */
95 END IF;
96
97
98 NULL;
99 ELSIF p_entity_code = 3 THEN
100 IF p_In_Out = 1 THEN
101 hdr_adj_ctr := hdr_adj_ctr + 1;
102 ELSIF p_In_Out = 0 THEN
103 hdr_adj_ctr := hdr_adj_ctr - 1;
104 END IF;
105 IF hdr_adj_ctr > 1 THEN
106 oe_globals.g_recursion_mode := 'Y';
107 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'Y';
108 ELSE
109 oe_globals.g_recursion_mode := 'N';
110 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'N';
111 END IF;
112
113 NULL;
114
115 ELSIF p_entity_code = 4 THEN
116
117 IF p_In_Out = 1 THEN
118 hdr_scredit_ctr := hdr_scredit_ctr + 1;
119 ELSIF p_In_Out = 0 THEN
120 hdr_scredit_ctr := hdr_scredit_ctr - 1;
121 END IF;
122 IF hdr_scredit_ctr > 1 THEN
123 oe_globals.g_recursion_mode := 'Y';
124 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'Y';
125 ELSE
126 oe_globals.g_recursion_mode := 'N';
127 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'N';
128 END IF;
129
130 NULL;
131 ELSIF p_entity_code = 5 THEN
132 IF p_In_Out = 1 THEN
133 line_ctr := line_ctr + 1;
134 ELSIF p_In_Out = 0 THEN
135 line_ctr := line_ctr - 1;
136 END IF;
137 IF line_ctr > 1 THEN
138 oe_globals.g_recursion_mode := 'Y';
139 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'Y';
140 ELSE
141 oe_globals.g_recursion_mode := 'N';
142 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'N';
143 END IF;
144
145 NULL;
146 ELSIF p_entity_code = 6 THEN
147 IF p_In_Out = 1 THEN
148 line_adj_ctr := line_adj_ctr + 1;
149 ELSIF p_In_Out = 0 THEN
150 line_adj_ctr := line_adj_ctr - 1;
151 END IF;
152 IF line_adj_ctr > 1 THEN
153 oe_globals.g_recursion_mode := 'Y';
154 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'Y';
155 ELSE
156 oe_globals.g_recursion_mode := 'N';
157 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'N';
158 END IF;
159
160 NULL;
161 ELSIF p_entity_code = 7 THEN
162 IF p_In_Out = 1 THEN
163 line_scredit_ctr := line_scredit_ctr + 1;
164 ELSIF p_In_Out = 0 THEN
165 line_scredit_ctr := line_scredit_ctr - 1;
166 END IF;
167 IF line_scredit_ctr > 1 THEN
168 oe_globals.g_recursion_mode := 'Y';
169 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'Y';
170 ELSE
171 oe_globals.g_recursion_mode := 'N';
172 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'N';
173 END IF;
174
175 NULL;
176 ELSIF p_entity_code = 8 THEN
177 IF p_In_Out = 1 THEN
178 prn_ctr := prn_ctr + 1;
179 ELSIF p_In_Out = 0 THEN
180 prn_ctr := prn_ctr - 1;
181 END IF;
182
183 /* IF (prn_ctr > 1 AND
184 pr_ctr > 0) THEN
185 oe_globals.g_recursion_mode := 'Y';*/
186 IF prn_ctr > 0 AND
187 (line_ctr > 0 OR
188 Hdr_ctr > 0 OR
189 Hdr_adj_ctr > 0 OR
190 Hdr_scredit_ctr > 0 OR
191 line_adj_ctr > 0 OR
192 line_scredit_ctr > 0 OR
193 po_ctr > 1 OR
194 --prrt_ctr > 0 OR
195 pr_ctr > 0 ) THEN
196 oe_globals.g_recursion_mode := 'Y';
197 ELSIF prn_ctr > 1 THEN
198 oe_globals.g_recursion_mode := 'Y';
199 ELSIF
200 prn_ctr = 0 AND
201 (line_ctr > 1 OR
202 Hdr_ctr > 1 OR
203 Hdr_adj_ctr > 1 OR
204 Hdr_scredit_ctr > 1 OR
205 line_adj_ctr > 1 OR
206 line_scredit_ctr > 1 OR
207 po_ctr > 1 OR
208 pr_ctr > 1 ) THEN
209 oe_globals.g_recursion_mode := 'Y';
210
211 ELSE
212 oe_globals.g_recursion_mode := 'N';
213 END IF;
214
215 IF prn_ctr > 0 AND
216 (line_ctr > 0 OR
217 Hdr_ctr > 0 OR
218 Hdr_adj_ctr > 0 OR
219 Hdr_scredit_ctr > 0 OR
220 line_adj_ctr > 0 OR
221 line_scredit_ctr > 0 OR
222 po_ctr > 1 OR
223 pr_ctr > 0 OR
224 --prrt_ctr > 0 OR
225 poa_ctr > 0 ) THEN
226
227 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'Y';
228 ELSIF prn_ctr > 1 THEN
229 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'Y';
230 ELSE
231 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'N';
232
233 END IF;
234
235
236 NULL;
237 ELSIF p_entity_code = 9 THEN
238 IF p_In_Out = 1 THEN
239 pr_ctr := pr_ctr + 1;
240 ELSIF p_In_Out = 0 THEN
241 pr_ctr := pr_ctr - 1;
242 END IF;
243 IF pr_ctr > 1 THEN
244 oe_globals.g_recursion_mode := 'Y';
245 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'Y';
246 ELSE
247 oe_globals.g_recursion_mode := 'N';
248 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'N';
249 END IF;
250 NULL;
251
252 ELSIF p_entity_code = 10 THEN
253 IF p_In_Out = 1 THEN
254 poa_ctr := poa_ctr + 1;
255 ELSIF p_In_Out = 0 THEN
256 poa_ctr := poa_ctr - 1;
257 END IF;
258 IF poa_ctr > 1 THEN
259 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'Y';
260 ELSE
261 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'N';
262
263 END IF;
264 NULL;
265 ELSIF p_entity_code = 11 THEN
266 IF p_In_Out = 1 THEN
267 prrt_ctr := prrt_ctr + 1;
268 ELSIF p_In_Out = 0 THEN
269 prrt_ctr := prrt_ctr - 1;
270 END IF;
271 -- We stopped tracking recursion in request type since it was causing issues
272 -- around executing configuration related requests and update shipping.
273 -- Pricing is now going by ui flag to set the process as false while
274 -- executing request for req type in validate and write.
275
276 /*IF prrt_ctr > 1 THEN
277 oe_globals.g_recursion_mode := 'Y';
278 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'Y';
279 ELSE
280 oe_globals.g_recursion_mode := 'N';
281 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'N';
282 END IF; */
283 NULL;
284
285
286 ELSE
287 oe_globals.g_recursion_mode := 'N';
288 OE_ORDER_UTIL.G_Recursion_Without_Exception := 'N';
289 NULL;
290 END IF;
291 IF l_debug_level > 0 THEN
292 oe_debug_pub.add( 'RECURSION MODE AT EXIT -' || OE_GLOBALS.G_RECURSION_MODE , 1 ) ;
293 oe_debug_pub.add( 'RECURSION MODE WITHOUT EXP AT EXIT -' || OE_ORDER_UTIL.G_RECURSION_WITHOUT_EXCEPTION , 1 ) ;
294 END IF;
295 End Set_Recursion_Mode ;
296
297
298 /*---------------------------------------------------------------------
299 Forward Declarations related to configurations.
300 ----------------------------------------------------------------------*/
301 PROCEDURE Print_Time(p_msg IN VARCHAR2);
302
303
304 -- ##1828866 added p_process_partial.
305 PROCEDURE Complete_Config_line
306 ( p_x_line_rec IN OUT NOCOPY OE_ORDER_PUB.Line_Rec_Type
307 ,p_item_type IN NUMBER
308 ,p_x_line_tbl IN OE_ORDER_PUB.Line_Tbl_Type
309 ,p_process_partial IN BOOLEAN := FALSE);
310
311 PROCEDURE Get_Missing_Class_Lines
312 ( p_x_line_tbl IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type
313 ,p_options_index_tbl IN OE_OPTION_INDEX_TBL_TYPE
314 ,x_class_index OUT NOCOPY NUMBER
315
316 ,x_class_count OUT NOCOPY NUMBER);
317
318
319
320 /*-------------------------------------------------------------------
321 FUNCTION Valid_Upgraded_Order
322
323 --------------------------------------------------------------------*/
324 FUNCTION Valid_Upgraded_Order(p_header_id Number)
325 RETURN Boolean
326 IS
327 --
328 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
329 --
330 BEGIN
331
332 IF l_debug_level > 0 THEN
333 oe_debug_pub.add( 'ENTER VALID UPGRADED ORDER' ) ;
334 END IF;
335 IF (NOT OE_GLOBALS.EQUAL(p_header_id, g_header_id)) OR
336 -- aksingh perf removing OR part of below condition as not required
337 -- (g_header_id IS NULL OR g_upgraded_flag IS NULL)
338 (g_header_id IS NULL)
339 THEN
340 select UPGRADED_FLAG, booked_flag into
341 g_upgraded_flag, g_booked_flag
342 from oe_order_headers_all
343 where header_id = p_header_id;
344 g_header_id := p_header_id;
345 END IF;
346
347 IF g_upgraded_flag IN ('P','I') THEN
348 IF l_debug_level > 0 THEN
349 oe_debug_pub.add( 'ORDER PARTIALLY UPGRADED ' ) ;
350 END IF;
351 FND_MESSAGE.SET_NAME('ONT','OE_INVALID_UPG_ORDER');
352 OE_MSG_PUB.Add;
353 RETURN FALSE;
354 END IF;
355
356 IF l_debug_level > 0 THEN
357 oe_debug_pub.add( 'EXIT VALID UPGRADED ORDER ' ) ;
358 END IF;
359 RETURN TRUE;
360
361 EXCEPTION
362
363 WHEN NO_DATA_FOUND THEN
364
365 RETURN TRUE;
366
367 END Valid_Upgraded_Order;
368
369
370 /*----------------------------------------------------------------------
371 PROCEDURE Header
372 -----------------------------------------------------------------------*/
373
374 PROCEDURE Header
375 ( p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
376 , p_validation_level IN NUMBER
377 , p_control_rec IN OE_GLOBALS.Control_Rec_Type
378 , p_x_header_rec IN OUT NOCOPY OE_Order_PUB.Header_Rec_Type
379 , p_x_old_header_rec IN OUT NOCOPY OE_Order_PUB.Header_Rec_Type
380 , x_return_status OUT NOCOPY VARCHAR2
381
382 )
383 IS
384 l_return_status VARCHAR2(1);
385 l_control_rec OE_GLOBALS.Control_Rec_Type;
386 l_user_id NUMBER;
387 l_resp_id NUMBER;
388 l_application_id NUMBER;
389 l_hdr_process_name VARCHAR2(30);
390 -- local variables to store OUT parameters from security check procedures
391 l_sec_result NUMBER;
392 l_on_operation_action NUMBER;
393 x_msg_count NUMBER;
394 x_msg_data VARCHAR2(2000);
395 --
396 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
397 l_org_id number ;
398 --
399 BEGIN
400 --Moac changes start
401 l_org_id := MO_GLOBAL.get_current_org_id;
402 IF (l_org_id IS NULL OR l_org_id = FND_API.G_MISS_NUM) THEN
403 FND_MESSAGE.set_name('FND','MO_ORG_REQUIRED');
404 OE_MSG_PUB.Add;
405 RAISE FND_API.G_EXC_ERROR;
406 END IF;
407 --Moac changes end
408 -- Initialize message list.
409 set_recursion_mode(p_Entity_Code => 2,
410 p_In_out => 1);
411
412 IF FND_API.to_Boolean(p_init_msg_list) THEN
413 OE_MSG_PUB.initialize;
414 END IF;
415
416 x_return_status := FND_API.G_RET_STS_SUCCESS;
417
418 IF l_debug_level > 0 THEN
419 oe_debug_pub.add( 'ENTERING OE_ORDER_PVT.HEADER ' , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
420 END IF;
421
422 -- This is to check if the order is an upgraded order and is upgraded
423 -- correctly
424 IF p_x_header_rec.operation <> OE_GLOBALS.G_OPR_CREATE THEN
425
426 IF l_debug_level > 0 THEN
427 oe_debug_pub.add( 'BEFORE CALLING VALID UPGRADE ORDER' , 2 ) ;
428 END IF;
429 IF NOT Valid_Upgraded_Order(p_x_header_rec.header_id ) THEN
430 RAISE FND_API.G_EXC_ERROR;
431 END IF;
432
433 END IF;
434
435 IF p_x_old_header_rec.header_id = FND_API.G_MISS_NUM
436 OR p_x_old_header_rec.header_id IS NULL
437 THEN
438
439 OE_MSG_PUB.set_msg_context(
440 p_entity_code => 'HEADER'
441 ,p_entity_id => p_x_header_rec.header_id
442 ,p_header_id => p_x_header_rec.header_id
443 ,p_line_id => null
444 ,p_orig_sys_document_ref => p_x_header_rec.orig_sys_document_ref
445 ,p_orig_sys_document_line_ref => null
446 ,p_change_sequence => p_x_header_rec.change_sequence
447 ,p_source_document_id => p_x_header_rec.source_document_id
448 ,p_source_document_line_id => null
449 ,p_order_source_id => p_x_header_rec.order_source_id
450 ,p_source_document_type_id => p_x_header_rec.source_document_type_id);
451
452 ELSE
453
454 OE_MSG_PUB.set_msg_context(
455 p_entity_code => 'HEADER'
456 ,p_entity_id => p_x_old_header_rec.header_id
457 ,p_header_id => p_x_old_header_rec.header_id
458 ,p_line_id => null
459 ,p_orig_sys_document_ref => p_x_old_header_rec.orig_sys_document_ref
460 ,p_orig_sys_document_line_ref => null
461 ,p_change_sequence => p_x_header_rec.change_sequence
462 ,p_source_document_id => p_x_old_header_rec.source_document_id
463 ,p_source_document_line_id => null
464 ,p_order_source_id => p_x_old_header_rec.order_source_id
465 ,p_source_document_type_id => p_x_old_header_rec.source_document_type_id);
466
467 END IF;
468
469
470 -- Load API control record
471
472 l_control_rec := OE_GLOBALS.Init_Control_Rec
473 ( p_operation => p_x_header_rec.operation
474 , p_control_rec => p_control_rec
475 );
476
477 IF l_debug_level > 0 THEN
478 oe_debug_pub.add( 'OE_ORDER_PVT.HEADER AFTER INIT CONTROL REC' , 2 ) ;
479 END IF;
480
481 -- Set record return status.
482
483 p_x_header_rec.return_status := FND_API.G_RET_STS_SUCCESS;
484
485 -- Prepare record.
486
487 IF p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
488
489 IF l_debug_level > 0 THEN
490 oe_debug_pub.add( 'OPERATION = CREATE SO SET OLD TO NULL' , 2 ) ;
491 END IF;
492 p_x_header_rec.db_flag := FND_API.G_FALSE;
493
494 -- Set missing old record elements to NULL.
495
496 OE_Header_Util.Convert_Miss_To_Null (p_x_old_header_rec);
497
498 ELSIF p_x_header_rec.operation = OE_GLOBALS.G_OPR_UPDATE
499 OR p_x_header_rec.operation = OE_GLOBALS.G_OPR_DELETE
500 THEN
501
502 IF l_debug_level > 0 THEN
503 oe_debug_pub.add( 'OPERATION = UPDATE SO QUERY OLD' , 2 ) ;
504 END IF;
505
506 p_x_header_rec.db_flag := FND_API.G_TRUE;
507
508 -- Query Old if missing
509
510 IF p_x_old_header_rec.header_id = FND_API.G_MISS_NUM
511 OR p_x_old_header_rec.header_id IS NULL
512 THEN
513 IF l_debug_level > 0 THEN
514 oe_debug_pub.add( 'QUERYING OLD HEADER REC' ,0.5 ) ; --debug level 0.5 added for bug 13435459
515 END IF;
516
517 OE_Header_Util.Query_Row
518 ( p_header_id => p_x_header_rec.header_id
519 , x_header_rec => p_x_old_header_rec
520 );
521
522 IF l_debug_level > 0 THEN
523 oe_debug_pub.add( 'AFTER QUERYING OLD HEADER REC' ,0.5 ) ; --debug level 0.5 added for bug 13435459
524 END IF;
525
526 ELSE
527
528 -- Set missing old record elements to NULL.
529
530 OE_Header_Util.Convert_Miss_To_Null (p_x_old_header_rec);
531
532 END IF;
533
534 IF l_debug_level > 0 THEN
535 oe_debug_pub.add( 'CALLING COMPLETE RECORD' , 0.5 ) ; --debug level changed to 0.5 for bug 13435459
536 END IF;
537
538 -- Complete new record from old
539
540 OE_Header_Util.Complete_Record
541 ( p_x_header_rec => p_x_header_rec
542 , p_old_header_rec => p_x_old_header_rec
543 );
544
545 IF l_debug_level > 0 THEN
546 oe_debug_pub.add( 'AFTER CALLING COMPLETE RECORD' , 0.5 ) ; --debug level changed to 0.5 for bug 13435459
547 END IF;
548
549 OE_MSG_PUB.update_msg_context(
550 p_entity_code => 'HEADER'
551 ,p_entity_id => p_x_header_rec.header_id
552 ,p_header_id => p_x_header_rec.header_id
553 ,p_line_id => null
554 ,p_order_source_id => p_x_header_rec.order_source_id
555 ,p_orig_sys_document_ref => p_x_header_rec.orig_sys_document_ref
556 ,p_orig_sys_document_line_ref => null
557 ,p_source_document_id => p_x_header_rec.source_document_id
558 ,p_source_document_line_id => null );
559
560 END IF;
561
562 IF ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_UPDATE
563 OR p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
564 OR p_x_header_rec.operation = OE_GLOBALS.G_OPR_DELETE) THEN
565
566
567 -- Check security
568 IF l_control_rec.check_security
569 AND (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
570 OR p_x_header_rec.operation = OE_GLOBALS.G_OPR_UPDATE)
571 THEN
572
573 IF l_debug_level > 0 THEN
574 oe_debug_pub.add( 'CALLING CHECK ATTRIBUTES SECURITY',0.5 ) ; -- debug level 0.5 added for bug 13435459
575 END IF;
576 -- check if this operation is allowed
577 -- on all the changed attributes
578 OE_Header_Security.Attributes
579 (p_header_rec => p_x_header_rec
580 , p_old_header_rec => p_x_old_header_rec
581 , x_result => l_sec_result
582 , x_return_status => l_return_status
583 );
584
585 IF l_debug_level > 0 THEN
586 oe_debug_pub.add( 'AFTER CHECK ATTRIBUTES SECURITY',0.5 ) ; -- debug added for bug 13435459
587 END IF;
588
589 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
590 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
591 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
592 RAISE FND_API.G_EXC_ERROR;
593 END IF;
594
595 IF l_sec_result = OE_PC_GLOBALS.YES THEN
596 RAISE FND_API.G_EXC_ERROR;
597 END IF;
598
599 END IF;
600
601 -- Attribute level validation.
602
603 IF p_validation_level > FND_API.G_VALID_LEVEL_NONE THEN
604
605 IF l_debug_level > 0 THEN
606 oe_debug_pub.add( 'CALLING VALIDATE ATTRIBUTES' , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
607 END IF;
608
609 OE_Validate_Header.Attributes
610 ( x_return_status => l_return_status
611 , p_x_header_rec => p_x_header_rec
612 , p_old_header_rec => p_x_old_header_rec
613 , p_validation_level => p_validation_level
614 );
615
616 IF l_debug_level > 0 THEN
617 oe_debug_pub.add( 'AFTER VALIDATE ATTRIBUTES' , 0.5 ) ; -- debug added for bug 13435459
618 END IF;
619
620 IF p_validation_level <> OE_GLOBALS.G_VALID_LEVEL_PARTIAL THEN
621 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
622 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
623 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
624 RAISE FND_API.G_EXC_ERROR;
625 END IF;
626 END IF;
627 END IF;
628
629
630 -- Clear dependent attributes.
631
632 IF l_control_rec.clear_dependents THEN
633
634 IF l_debug_level > 0 THEN
635 oe_debug_pub.add( 'CLEAR DEPENDENT' , 0.5 ) ; -- debug level 0.5 added for bug 13435459
636 END IF;
637
638 OE_Header_Util.Clear_Dependent_Attr
639 ( p_x_header_rec => p_x_header_rec
640 , p_old_header_rec => p_x_old_header_rec
641 );
642
643 IF l_debug_level > 0 THEN
644 oe_debug_pub.add( 'AFTER CLEAR DEPENDENT' , 0.5 ) ; -- debug added for bug 13435459
645 END IF;
646 END IF;
647
648 -- Default missing attributes
649
650 IF l_control_rec.default_attributes
651 THEN
652
653 IF l_debug_level > 0 THEN
654 oe_debug_pub.add( 'DEFAULT MISSING' , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
655 END IF;
656
657 OE_Default_Header.Attributes
658 ( p_x_header_rec => p_x_header_rec
659 , p_old_header_rec => p_x_old_header_rec
660 );
661
662 END IF;
663
664 IF l_debug_level > 0 THEN
665 oe_debug_pub.add( 'AFTER DEFAULT MISSING' , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
666 END IF;
667
668 -- Apply attribute changes
669
670 IF l_control_rec.change_attributes
671 THEN
672
673 IF l_debug_level > 0 THEN
674 oe_debug_pub.add( 'APPLY ATTRIBUTE CHANGES' , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
675
676 END IF;
677
678 OE_Header_Util.Apply_Attribute_Changes
679 ( p_x_header_rec => p_x_header_rec
680 , p_old_header_rec => p_x_old_header_rec
681 );
682
683 IF l_debug_level > 0 THEN
684 oe_debug_pub.add( 'AFTER APPLY ATTRIBUTE CHANGES' , 0.5 ) ; -- debug added for bug 13435459
685 END IF;
686
687 END IF;
688
689 -- Entity level validation.
690
691 IF l_control_rec.validate_entity
692 and p_x_header_rec.cancelled_flag<>'Y' --added for bug 6494347
693 THEN
694
695 IF l_debug_level > 0 THEN
696 oe_debug_pub.add( 'VALIDATE ENTITY' , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
697 END IF;
698
699 IF p_x_header_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
700
701 OE_Validate_Header.Entity_Delete
702 ( x_return_status => l_return_status
703 , p_header_rec => p_x_header_rec
704 );
705
706 ELSE
707
708 OE_Validate_Header.Entity
709 ( x_return_status => l_return_status
710 , p_header_rec => p_x_header_rec
711 , p_old_header_rec => p_x_old_header_rec
712 , p_validation_level => p_validation_level
713 /* Added the above line to fix the bug 2824240 */
714 );
715
716 END IF;
717
718 IF l_debug_level > 0 THEN
719 oe_debug_pub.add( 'AFTER VALIDATE ENTITY' , 0.5 ) ; -- debug added for bug 13435459
720 END IF;
721
722 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
723 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
724 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
725 RAISE FND_API.G_EXC_ERROR;
726 END IF;
727
728 END IF;
729
730
731 -- Check entity level security again as some attributes
732 -- may have changed due to defaulting.
733 -- For UPDATE operations, entity security checks for constraints setup
734 -- with a NULL column i.e. the constraint restricts update on ANY of
735 -- the columns.
736 -- However, this check should NOT be done if user did not try to update
737 -- any of the constrainable attributes and also none of the defaulted
738 -- attributes was constrainable!. In such a case, the g_check_all_cols
739 -- _constraint flag would still be 'Y' as the flag is reset only
740 -- when checking for constraints.
741 IF NOT (p_x_header_rec.operation = OE_GLOBALS.G_OPR_UPDATE
742 AND OE_Header_Security.g_check_all_cols_constraint = 'Y')
743 AND l_control_rec.check_security
744 THEN
745 IF l_debug_level > 0 THEN
746 oe_debug_pub.add( 'CHECK ENTITY SECURITY' ,0.5 ) ; --debug level 0.5 added for bug 13435459
747 END IF;
748
749 OE_Header_Security.Entity
750 (p_header_rec => p_x_header_rec
751 , x_result => l_sec_result
752 , x_return_status => l_return_status
753 );
754
755 IF l_debug_level > 0 THEN
756 oe_debug_pub.add( 'AFTER CHECK ENTITY SECURITY' ,0.5 ) ; --debug added for bug 13435459
757 END IF;
758
759 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
760 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
761 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
762 RAISE FND_API.G_EXC_ERROR;
763 END IF;
764
765 IF l_sec_result = OE_PC_GLOBALS.YES THEN
766 RAISE FND_API.G_EXC_ERROR;
767 END IF;
768
769 END IF;
770
771 -- Step 4. Write to DB
772 IF l_control_rec.write_to_db THEN
773 Oe_Header_Util.Pre_Write_Process(p_x_header_rec => p_x_header_rec,
774 p_old_header_rec => p_x_old_header_rec);
775 END IF;
776
777 IF l_control_rec.write_to_db THEN
778
779 IF l_debug_level > 0 THEN
780 oe_debug_pub.add( 'WRITE TO DB' , 0.5 ) ; --debug level changed to 0.5 fro bug 13435459
781 END IF;
782
783 IF p_x_header_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
784
785 OE_Header_Util.Delete_Row
786 ( p_header_id => p_x_header_rec.header_id
787 );
788
789 ELSE
790
791 -- Get Who Information
792
793 p_x_header_rec.last_update_date := SYSDATE;
794 p_x_header_rec.last_updated_by := NVL(OE_STANDARD_WF.g_user_id, FND_GLOBAL.USER_ID); -- 3169637
795 p_x_header_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
796
797 IF p_x_header_rec.credit_card_approval_date = FND_API.G_MISS_DATE THEN
798 p_x_header_rec.credit_card_approval_date := NULL;
799 END IF;
800
801 IF p_x_header_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
802
803 IF l_debug_level > 0 THEN
804 oe_debug_pub.add( 'HEADER FLOW STATUS :'||P_X_HEADER_REC.FLOW_STATUS_CODE , 1 ) ;
805 END IF;
806 OE_Header_Util.Update_Row (p_x_header_rec);
807
808 ELSIF p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
809
810 p_x_header_rec.creation_date := SYSDATE;
811 p_x_header_rec.created_by := NVL(OE_STANDARD_WF.g_user_id, FND_GLOBAL.USER_ID); -- 3169637
812
813 l_user_id := NVL(OE_STANDARD_WF.g_user_id, FND_GLOBAL.USER_ID); -- 3169637
814 l_resp_id := FND_GLOBAL.RESP_ID;
815 l_application_id := FND_GLOBAL.RESP_APPL_ID;
816
817 IF l_debug_level > 0 THEN
818 oe_debug_pub.add( 'USER ID IS '|| L_USER_ID ) ;
819 oe_debug_pub.add( 'RESP ID IS '|| L_RESP_ID ) ;
820 oe_debug_pub.add( 'APPL ID IS '|| L_APPLICATION_ID ) ;
821 END IF;
822
823
824 OE_Header_Util.Insert_Row (p_x_header_rec);
825
826 END IF;
827
828 END IF;
829
830 END IF;
831
832 -- Step 4. Write to DB
833 IF l_control_rec.write_to_db THEN
834 OE_Header_Util.Post_Write_Process
835 ( p_x_header_rec => p_x_header_rec,
836 p_old_header_rec => p_x_old_header_rec
837 );
838 END IF;
839
840 END IF;
841
842 -- Load OUT parameters
843 p_x_header_rec.return_status := FND_API.G_RET_STS_SUCCESS;
844
845 OE_Header_Security.g_check_all_cols_constraint := 'Y';
846
847 IF l_debug_level > 0 THEN
848 oe_debug_pub.add( 'EXITING OE_ORDER_PVT.HEADER' , 0.5 ) ; --debug level 0.5 added for bug13435459
849 END IF;
850 OE_MSG_PUB.reset_msg_context('HEADER');
851
852 set_recursion_mode(p_Entity_Code => 2,
853 p_In_out => 0);
854
855 EXCEPTION
856
857 WHEN FND_API.G_EXC_ERROR THEN
858
859 set_recursion_mode(p_Entity_Code => 2,
860 p_In_out => 0);
861 p_x_header_rec.return_status := FND_API.G_RET_STS_ERROR;
862 x_return_status := FND_API.G_RET_STS_ERROR;
863 OE_Header_Security.g_check_all_cols_constraint := 'Y';
864 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
865 IF l_debug_level > 0 THEN
866 oe_debug_pub.add( 'DELETE REQUEST1' , 2 ) ;
867 END IF;
868 OE_Delayed_Requests_Pvt.Clear_Request
869 (x_return_status => l_return_status);
870 END IF;
871 OE_MSG_PUB.reset_msg_context('HEADER');
872
873 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
874
875 set_recursion_mode(p_Entity_Code => 2,
876 p_In_out => 0);
877 p_x_header_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
878 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
879 OE_Header_Security.g_check_all_cols_constraint := 'Y';
880 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
881 IF l_debug_level > 0 THEN
882 oe_debug_pub.add( 'DELETE REQUEST2' , 2 ) ;
883 END IF;
884 OE_Delayed_Requests_Pvt.Clear_Request
885 (x_return_status => l_return_status);
886 END IF;
887 OE_MSG_PUB.reset_msg_context('HEADER');
888
889 WHEN OTHERS THEN
890
891 set_recursion_mode(p_Entity_Code => 2,
892 p_In_out => 0);
893 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
894 THEN
895 OE_MSG_PUB.Add_Exc_Msg
896 ( G_PKG_NAME
897 , 'Header'
898 );
899 END IF;
900
901 p_x_header_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
902 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
903 OE_Header_Security.g_check_all_cols_constraint := 'Y';
904 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
905 IF l_debug_level > 0 THEN
906 oe_debug_pub.add( 'DELETE REQUEST3' , 2 ) ;
907 END IF;
908 OE_Delayed_Requests_Pvt.Clear_Request
909 (x_return_status => l_return_status);
910 END IF;
911 OE_MSG_PUB.reset_msg_context('HEADER');
912
913 END Header;
914
915
916
917 /*-------------------------------------------------------------------
918 PROCEDURE Header_Scredits
919 -------------------------------------------------------------------*/
920 PROCEDURE Header_Scredits
921 ( p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
922 , p_validation_level IN NUMBER
923 , p_control_rec IN OE_GLOBALS.Control_Rec_Type
924 , p_x_Header_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Header_Scredit_Tbl_Type
925 , p_x_old_Header_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Header_Scredit_Tbl_Type
926 , x_return_status OUT NOCOPY VARCHAR2
927
928 )
929 IS
930 l_del_ret_status VARCHAR2(1);
931 l_return_status VARCHAR2(1);
932 l_control_rec OE_GLOBALS.Control_Rec_Type;
933 l_Header_Scredit_rec OE_Order_PUB.Header_Scredit_Rec_Type;
934 l_old_Header_Scredit_rec OE_Order_PUB.Header_Scredit_Rec_Type;
935 -- local variables to store OUT parameters from security check procedures
936 l_sec_result NUMBER;
937 l_on_operation_action NUMBER;
938 l_order_source_id NUMBER;
939 l_orig_sys_document_ref VARCHAR2(50);
940 l_change_sequence VARCHAR2(50);
941 l_source_document_type_id NUMBER;
942 l_source_document_id NUMBER;
943
944 I NUMBER; -- Used as index for while loop
945 --bug 5049879
946 l_booked_flag VARCHAR2(1);
947 l_quota_flag VARCHAR2(1);
948 --bug 5049879
949 --
950 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
951 l_org_id number ;
952 --
953 BEGIN
954
955 --MOAC changes start
956 l_org_id := MO_GLOBAL.get_current_org_id;
957 IF (l_org_id IS NULL OR l_org_id = FND_API.G_MISS_NUM) THEN
958 FND_MESSAGE.set_name('FND','MO_ORG_REQUIRED');
959 OE_MSG_PUB.Add;
960 RAISE FND_API.G_EXC_ERROR;
961 END IF;
962 --MOAC changes end
963
964 set_recursion_mode(p_Entity_Code => 4,
965 p_In_out => 1);
966 x_return_status := FND_API.G_RET_STS_SUCCESS;
967
968 -- Initialize message list.
969
970 IF FND_API.to_Boolean(p_init_msg_list) THEN
971 OE_MSG_PUB.initialize;
972 END IF;
973
974 IF p_control_rec.Process_Partial THEN
975 SAVEPOINT Header_Scredits;
976 END IF;
977
978 -- Init local table variables.
979
980 IF l_debug_level > 0 THEN
981 oe_debug_pub.add( 'ENTERING OE_ORDER_PVT.HEADER_SCREDITS' , 1 ) ;
982 END IF;
983
984 -- FOR I IN 1..p_x_Header_Scredit_tbl.COUNT LOOP
985
986 I := p_x_Header_Scredit_tbl.FIRST;
987
988 WHILE I IS NOT NULL LOOP
989 BEGIN
990
991 -- Load local records.
992
993 l_Header_Scredit_rec := p_x_Header_Scredit_tbl(I);
994
995 IF p_x_old_Header_Scredit_tbl.EXISTS(I) THEN
996 l_old_Header_Scredit_rec := p_x_old_Header_Scredit_tbl(I);
997 ELSE
998 l_old_Header_Scredit_rec := OE_Order_PUB.G_MISS_HEADER_SCREDIT_REC;
999 END IF;
1000
1001 if l_old_header_Scredit_rec.sales_credit_id = FND_API.G_MISS_NUM
1002 OR l_old_header_Scredit_rec.sales_credit_id IS NULL
1003 Then
1004
1005 IF l_header_Scredit_rec.header_id IS NOT NULL AND
1006 l_header_Scredit_rec.header_id <> FND_API.G_MISS_NUM THEN
1007 BEGIN
1008 IF l_debug_level > 0 THEN
1009 oe_debug_pub.add('Getting reference data for header_id:'||l_header_Scredit_rec.header_id);
1010 END IF;
1011 SELECT order_source_id, orig_sys_document_ref, change_sequence,
1012 source_document_type_id, source_document_id
1013 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
1014 l_source_document_type_id, l_source_document_id
1015 FROM OE_ORDER_HEADERS_ALL
1016 WHERE header_id = l_header_Scredit_rec.header_id;
1017 EXCEPTION
1018 WHEN NO_DATA_FOUND THEN
1019 l_order_source_id := null;
1020 l_orig_sys_document_ref := null;
1021 l_change_sequence := null;
1022 l_source_document_type_id := null;
1023 l_source_document_id := null;
1024 WHEN OTHERS THEN
1025 l_order_source_id := null;
1026 l_orig_sys_document_ref := null;
1027 l_change_sequence := null;
1028 l_source_document_type_id := null;
1029 l_source_document_id := null;
1030 END;
1031 END IF;
1032
1033 OE_MSG_PUB.set_msg_context(
1034 p_entity_code => 'HEADER_SCREDIT'
1035 ,p_entity_id => l_header_Scredit_rec.sales_credit_id
1036 ,p_header_id => l_header_Scredit_rec.header_Id
1037 ,p_line_id => null
1038 ,p_order_source_id => l_order_source_id
1039 ,p_orig_sys_document_ref => l_orig_sys_document_ref
1040 ,p_orig_sys_document_line_ref => null
1041 ,p_change_sequence => l_change_sequence
1042 ,p_source_document_type_id => l_source_document_type_id
1043 ,p_source_document_id => l_source_document_id
1044 ,p_source_document_line_id => null );
1045
1046 else
1047 IF l_old_header_Scredit_rec.header_id IS NOT NULL AND
1048 l_old_header_Scredit_rec.header_id <> FND_API.G_MISS_NUM THEN
1049
1050 BEGIN
1051 IF l_debug_level > 0 THEN
1052 oe_debug_pub.add('Getting reference data for old header_id:'||l_old_header_Scredit_rec.header_id);
1053 END IF;
1054 SELECT order_source_id, orig_sys_document_ref, change_sequence,
1055 source_document_type_id, source_document_id
1056 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
1057 l_source_document_type_id, l_source_document_id
1058 FROM OE_ORDER_HEADERS_ALL
1059 WHERE header_id = l_old_header_Scredit_rec.header_id;
1060 EXCEPTION
1061 WHEN NO_DATA_FOUND THEN
1062 l_order_source_id := null;
1063 l_orig_sys_document_ref := null;
1064 l_change_sequence := null;
1065 l_source_document_type_id := null;
1066 l_source_document_id := null;
1067 WHEN OTHERS THEN
1068 l_order_source_id := null;
1069 l_orig_sys_document_ref := null;
1070 l_change_sequence := null;
1071 l_source_document_type_id := null;
1072 l_source_document_id := null;
1073 END;
1074 END IF;
1075
1076
1077 OE_MSG_PUB.set_msg_context(
1078 p_entity_code => 'HEADER_SCREDIT'
1079 ,p_entity_id => l_old_header_Scredit_rec.sales_credit_id
1080 ,p_header_id => l_old_header_Scredit_rec.header_Id
1081 ,p_line_id => null
1082 ,p_order_source_id => l_order_source_id
1083 ,p_orig_sys_document_ref => l_orig_sys_document_ref
1084 ,p_orig_sys_document_line_ref => null
1085 ,p_change_sequence => l_change_sequence
1086 ,p_source_document_type_id => l_source_document_type_id
1087 ,p_source_document_id => l_source_document_id
1088 ,p_source_document_line_id => null );
1089
1090 end if;
1091
1092 -- Load API control record
1093
1094 l_control_rec := OE_GLOBALS.Init_Control_Rec
1095 ( p_operation => l_Header_Scredit_rec.operation
1096 , p_control_rec => p_control_rec
1097 );
1098
1099 -- Set record return status.
1100
1101 l_Header_Scredit_rec.return_status := FND_API.G_RET_STS_SUCCESS;
1102
1103 -- Prepare record.
1104
1105 IF l_Header_Scredit_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
1106
1107 l_Header_Scredit_rec.db_flag := FND_API.G_FALSE;
1108
1109 -- Set missing old record elements to NULL.
1110
1111 OE_Header_Scredit_Util.Convert_Miss_To_Null (l_old_Header_Scredit_rec);
1112
1113 ELSIF l_Header_Scredit_rec.operation = OE_GLOBALS.G_OPR_UPDATE
1114 OR l_Header_Scredit_rec.operation = OE_GLOBALS.G_OPR_DELETE
1115 THEN
1116
1117 l_Header_Scredit_rec.db_flag := FND_API.G_TRUE;
1118
1119 -- Query Old if missing
1120
1121 IF l_old_Header_Scredit_rec.sales_credit_id = FND_API.G_MISS_NUM
1122 OR l_old_Header_Scredit_rec.sales_credit_id IS NULL
1123 THEN
1124
1125 OE_Header_Scredit_Util.Query_Row
1126 ( p_sales_credit_id => l_Header_Scredit_rec.sales_credit_id
1127 , x_header_scredit_rec => l_old_Header_Scredit_rec
1128 );
1129
1130 ELSE
1131
1132 -- Set missing old record elements to NULL.
1133
1134 OE_Header_Scredit_Util.Convert_Miss_To_Null (l_old_Header_Scredit_rec);
1135
1136 END IF;
1137
1138 -- Complete new record from old
1139
1140 OE_Header_Scredit_Util.Complete_Record
1141 ( p_x_Header_Scredit_rec => l_Header_Scredit_rec
1142 , p_old_Header_Scredit_rec => l_old_Header_Scredit_rec
1143 );
1144
1145 OE_MSG_PUB.update_msg_context(
1146 p_entity_code => 'HEADER_SCREDIT'
1147 ,p_entity_id => l_header_Scredit_rec.sales_credit_id
1148 ,p_header_id => l_header_Scredit_rec.header_Id);
1149
1150
1151 END IF;
1152
1153 IF I = p_x_header_scredit_tbl.FIRST THEN
1154 IF NOT Valid_Upgraded_Order(l_header_scredit_rec.header_id) THEN
1155 RAISE FND_API.G_EXC_ERROR;
1156 END IF;
1157 END IF;
1158
1159 -- Check security
1160 IF l_control_rec.check_security
1161 AND (l_header_scredit_rec.operation = OE_GLOBALS.G_OPR_CREATE
1162 OR l_header_scredit_rec.operation = OE_GLOBALS.G_OPR_UPDATE)
1163 THEN
1164
1165 IF l_debug_level > 0 THEN
1166 oe_debug_pub.add( 'CHECK ATTRIBUTES SECURITY' ) ;
1167 END IF;
1168 -- check if this operation is allowed
1169 -- on all the changed attributes
1170 OE_Header_Scredit_Security.Attributes
1171 (p_header_scredit_rec => l_header_scredit_rec
1172 , p_old_header_scredit_rec => l_old_header_scredit_rec
1173 , x_result => l_sec_result
1174 , x_return_status => l_return_status
1175 );
1176
1177 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1178 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1179 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1180 RAISE FND_API.G_EXC_ERROR;
1181 END IF;
1182
1183 IF l_sec_result = OE_PC_GLOBALS.YES THEN
1184 RAISE FND_API.G_EXC_ERROR;
1185 END IF;
1186
1187 END IF;
1188
1189 -- Attribute level validation.
1190
1191 IF p_validation_level > FND_API.G_VALID_LEVEL_NONE THEN
1192
1193 OE_Validate_Header_Scredit.Attributes
1194 ( x_return_status => l_return_status
1195 , p_Header_Scredit_rec => l_Header_Scredit_rec
1196 , p_old_Header_Scredit_rec => l_old_Header_Scredit_rec
1197 );
1198
1199 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1200 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1201 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1202 RAISE FND_API.G_EXC_ERROR;
1203 END IF;
1204
1205 END IF;
1206
1207
1208 -- Clear dependent attributes.
1209
1210 IF l_control_rec.clear_dependents THEN
1211
1212 OE_Header_Scredit_Util.Clear_Dependent_Attr
1213 ( p_x_Header_Scredit_rec => l_Header_Scredit_rec
1214 , p_old_Header_Scredit_rec => l_old_Header_Scredit_rec
1215 );
1216
1217 END IF;
1218
1219 -- Default missing attributes
1220
1221 IF l_control_rec.default_attributes
1222 THEN
1223
1224 OE_Default_Header_Scredit.Attributes
1225 ( p_x_Header_Scredit_rec => l_Header_Scredit_rec
1226 , p_old_header_scredit_rec => l_old_header_scredit_rec
1227 );
1228
1229 END IF;
1230
1231 -- Apply attribute changes
1232
1233 IF l_control_rec.change_attributes
1234 THEN
1235
1236 OE_Header_Scredit_Util.Apply_Attribute_Changes
1237 ( p_x_Header_Scredit_rec => l_Header_Scredit_rec
1238 , p_old_Header_Scredit_rec => l_old_Header_Scredit_rec
1239 );
1240
1241 END IF;
1242
1243 -- Entity level validation.
1244
1245 IF l_control_rec.validate_entity THEN
1246
1247 IF l_Header_Scredit_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
1248
1249 OE_Validate_Header_Scredit.Entity_Delete
1250 ( x_return_status => l_return_status
1251 , p_Header_Scredit_rec => l_Header_Scredit_rec
1252 );
1253
1254 ELSE
1255
1256 OE_Validate_Header_Scredit.Entity
1257 ( x_return_status => l_return_status
1258 , p_Header_Scredit_rec => l_Header_Scredit_rec
1259 , p_old_Header_Scredit_rec => l_old_Header_Scredit_rec
1260 );
1261
1262 END IF;
1263
1264 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1265 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1266 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1267 RAISE FND_API.G_EXC_ERROR;
1268 END IF;
1269
1270 END IF;
1271
1272 -- Check entity level security again as some attributes
1273 -- may have changed due to defaulting.
1274 -- For UPDATE operations, entity security checks for constraints setup
1275 -- with a NULL column i.e. the constraint restricts update on ANY of
1276 -- the columns.
1277 -- However, this check should NOT be done if user did not try to update
1278 -- any of the constrainable attributes and also none of the defaulted
1279 -- attributes was constrainable!. In such a case, the g_check_all_cols
1280 -- _constraint flag would still be 'Y' as the flag is reset only
1281 -- when checking for constraints.
1282 IF NOT (l_header_scredit_rec.operation = OE_GLOBALS.G_OPR_UPDATE
1283 AND OE_Header_Scredit_Security.g_check_all_cols_constraint = 'Y')
1284 AND l_control_rec.check_security
1285 THEN
1286 IF l_debug_level > 0 THEN
1287 oe_debug_pub.add( 'CHECK ENTITY SECURITY' ) ;
1288 END IF;
1289
1290 OE_Header_Scredit_Security.Entity
1291 (p_header_scredit_rec => l_header_scredit_rec
1292 , x_result => l_sec_result
1293 , x_return_status => l_return_status
1294 );
1295
1296 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1297 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1298 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1299 RAISE FND_API.G_EXC_ERROR;
1300 END IF;
1301
1302 IF l_sec_result = OE_PC_GLOBALS.YES THEN
1303 RAISE FND_API.G_EXC_ERROR;
1304 END IF;
1305
1306 END IF;
1307
1308 -- Step 4. Write to DB
1309
1310 IF l_control_rec.write_to_db THEN
1311 /* Start Audit Trail */
1312 Oe_Header_Scredit_Util.Pre_Write_Process
1313 (p_x_header_scredit_rec => l_header_scredit_rec,
1314 p_old_header_scredit_rec => l_old_header_scredit_rec);
1315 /* End AuditTrail */
1316
1317 IF l_Header_Scredit_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
1318 SAVEPOINT DELETE_SCREDIT_FAILED; --bug 5331854
1319 --bug 5049879
1320 select quota_flag into l_quota_flag from oe_sales_credit_types where sales_credit_type_id = l_header_scredit_rec.sales_credit_type_id;
1321 select booked_flag into l_booked_flag from oe_order_headers where header_id = l_header_scredit_rec.header_id;
1322 OE_Header_Scredit_Util.Delete_Row
1323 ( p_sales_credit_id => l_Header_Scredit_rec.sales_credit_id
1324 );
1325
1326 IF nvl(l_booked_flag, 'N') = 'Y' and nvl(l_quota_flag, 'N') = 'Y' THEN
1327 OE_Validate_Header_Scredit.Validate_HSC_TOTAL_FOR_BK(l_header_scredit_rec.return_status,
1328 l_header_scredit_rec.header_id);
1329 IF l_debug_level > 0 THEN
1330 oe_debug_pub.add('after delete_row and hdr validate_hsc_quota_total rt status : ' || l_header_scredit_rec.return_status);
1331 END IF;
1332 l_del_ret_status := l_header_scredit_rec.return_status; --bug 5331854
1333
1334 END IF;
1335 --bug 5049879
1336 ELSE
1337
1338 -- Get Who Information
1339
1340 l_Header_Scredit_rec.last_update_date := SYSDATE;
1341 l_Header_Scredit_rec.last_updated_by := NVL(OE_STANDARD_WF.g_user_id, FND_GLOBAL.USER_ID); -- 3169637
1342 l_Header_Scredit_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
1343
1344 IF l_Header_Scredit_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
1345
1346 OE_Header_Scredit_Util.Update_Row (l_Header_Scredit_rec);
1347
1348 ELSIF l_Header_Scredit_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
1349
1350 l_Header_Scredit_rec.creation_date := SYSDATE;
1351 l_Header_Scredit_rec.created_by := NVL(OE_STANDARD_WF.g_user_id, FND_GLOBAL.USER_ID); -- 3169637
1352
1353 OE_Header_Scredit_Util.Insert_Row (l_Header_Scredit_rec);
1354
1355 END IF;
1356
1357 END IF;
1358
1359 END IF;
1360
1361 OE_Header_Scredit_Security.g_check_all_cols_constraint := 'Y';
1362 OE_MSG_PUB.reset_msg_context('HEADER_SCREDIT');
1363
1364 -- loop exception handler.
1365 IF l_header_scredit_rec.return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1366 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1367 ELSIF l_header_scredit_rec.return_status = FND_API.G_RET_STS_ERROR THEN
1368 RAISE FND_API.G_EXC_ERROR;
1369 END IF;
1370
1371 -- Load tables.
1372
1373 l_Header_Scredit_rec.return_status := FND_API.G_RET_STS_SUCCESS;
1374 p_x_Header_Scredit_tbl(I) := l_Header_Scredit_rec;
1375 p_x_old_Header_Scredit_tbl(I) := l_old_Header_Scredit_rec;
1376
1377
1378 EXCEPTION
1379
1380 WHEN FND_API.G_EXC_ERROR THEN
1381
1382 l_Header_Scredit_rec.return_status := FND_API.G_RET_STS_ERROR;
1383 x_return_status := FND_API.G_RET_STS_ERROR;
1384 p_x_Header_Scredit_tbl(I) := l_Header_Scredit_rec;
1385 p_x_old_Header_Scredit_tbl(I) := l_old_Header_Scredit_rec;
1386
1387 OE_Header_Scredit_Security.g_check_all_cols_constraint := 'Y';
1388 OE_MSG_PUB.reset_msg_context('HEADER_SCREDIT');
1389
1390 IF l_control_Rec.Process_Partial THEN
1391 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
1392 IF l_debug_level > 0 THEN
1393 oe_debug_pub.add( 'DELETE REQUEST4' , 2 ) ;
1394 END IF;
1395 oe_delayed_requests_pvt.Delete_Reqs_for_Deleted_Entity
1396 (p_entity_code =>OE_GLOBALS.G_ENTITY_HEADER_SCREDIT,
1397 p_entity_id => l_header_scredit_rec.sales_credit_id,
1398 x_return_status => l_return_status);
1399 END IF;
1400 ROLLBACK TO SAVEPOINT Header_Scredits;
1401 ELSE
1402 --bug 5331854
1403 IF OE_GLOBALS.G_UI_FLAG AND
1404 l_del_ret_status = FND_API.G_RET_STS_ERROR THEN
1405 ROLLBACK TO SAVEPOINT DELETE_SCREDIT_FAILED;
1406 END IF;
1407 --bug 5331854
1408 RAISE FND_API.G_EXC_ERROR;
1409 END IF;
1410
1411 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1412
1413 l_Header_Scredit_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1414 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1415 p_x_Header_Scredit_tbl(I) := l_Header_Scredit_rec;
1416 p_x_old_Header_Scredit_tbl(I) := l_old_Header_Scredit_rec;
1417 OE_Header_Scredit_Security.g_check_all_cols_constraint := 'Y';
1418 OE_MSG_PUB.reset_msg_context('HEADER_SCREDIT');
1419 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1420
1421 WHEN OTHERS THEN
1422
1423 l_Header_Scredit_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1424 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1425 p_x_Header_Scredit_tbl(I) := l_Header_Scredit_rec;
1426 p_x_old_Header_Scredit_tbl(I) := l_old_Header_Scredit_rec;
1427
1428 OE_Header_Scredit_Security.g_check_all_cols_constraint := 'Y';
1429 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1430 THEN
1431 OE_MSG_PUB.Add_Exc_Msg
1432 ( G_PKG_NAME
1433 , 'Header_Scredits'
1434 );
1435 END IF;
1436
1437 OE_MSG_PUB.reset_msg_context('HEADER_SCREDIT');
1438 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1439
1440 END;
1441 I := p_x_Header_Scredit_tbl.NEXT(I);
1442 END LOOP;
1443
1444 IF l_debug_level > 0 THEN
1445 oe_debug_pub.add( 'EXITING OE_ORDER_PVT.HEADER_SCREDITS' , 1 ) ;
1446 END IF;
1447 OE_MSG_PUB.reset_msg_context('HEADER_SCREDIT');
1448
1449 set_recursion_mode(p_Entity_Code => 4,
1450 p_In_out => 0);
1451 EXCEPTION
1452
1453 WHEN FND_API.G_EXC_ERROR THEN
1454
1455 set_recursion_mode(p_Entity_Code => 4,
1456 p_In_out => 0);
1457 x_return_status := FND_API.G_RET_STS_ERROR;
1458 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
1459 IF l_debug_level > 0 THEN
1460 oe_debug_pub.add( 'DELETE REQUEST5' , 2 ) ;
1461 END IF;
1462 OE_Delayed_Requests_Pvt.Clear_Request
1463 (x_return_status => l_return_status);
1464 END IF;
1465 OE_MSG_PUB.reset_msg_context('HEADER_SCREDIT');
1466
1467 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1468
1469 set_recursion_mode(p_Entity_Code => 4,
1470 p_In_out => 0);
1471 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1472 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
1473 IF l_debug_level > 0 THEN
1474 oe_debug_pub.add( 'DELETE REQUEST6' , 2 ) ;
1475 END IF;
1476 OE_Delayed_Requests_Pvt.Clear_Request
1477 (x_return_status => l_return_status);
1478 END IF;
1479 OE_MSG_PUB.reset_msg_context('HEADER_SCREDIT');
1480
1481 WHEN OTHERS THEN
1482
1483 set_recursion_mode(p_Entity_Code => 4,
1484 p_In_out => 0);
1485 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1486 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
1487 IF l_debug_level > 0 THEN
1488 oe_debug_pub.add( 'DELETE REQUEST7' , 2 ) ;
1489 END IF;
1490 OE_Delayed_Requests_Pvt.Clear_Request
1491 (x_return_status => l_return_status);
1492 END IF;
1493 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1494 THEN
1495 OE_MSG_PUB.Add_Exc_Msg
1496 ( G_PKG_NAME
1497 , 'Header_Scredits'
1498 );
1499 END IF;
1500
1501
1502 OE_MSG_PUB.reset_msg_context('HEADER_SCREDIT');
1503
1504 END Header_Scredits;
1505
1506
1507 /*-------------------------------------------------------------------
1508 PROCEDURE Header_Payments
1509 -------------------------------------------------------------------*/
1510 PROCEDURE Header_Payments
1511 ( p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
1512 , p_validation_level IN NUMBER
1513 , p_control_rec IN OE_GLOBALS.Control_Rec_Type
1514 , p_x_Header_Payment_tbl IN OUT NOCOPY OE_Order_PUB.Header_Payment_Tbl_Type
1515 , p_x_old_Header_Payment_tbl IN OUT NOCOPY OE_Order_PUB.Header_Payment_Tbl_Type
1516 , x_return_status OUT NOCOPY VARCHAR2
1517
1518 )
1519 IS
1520 l_return_status VARCHAR2(1);
1521 l_control_rec OE_GLOBALS.Control_Rec_Type;
1522 l_Header_Payment_rec OE_Order_PUB.Header_Payment_Rec_Type;
1523 l_old_Header_Payment_rec OE_Order_PUB.Header_Payment_Rec_Type;
1524 -- local variables to store OUT parameters from security check procedures
1525 l_sec_result NUMBER;
1526 l_on_operation_action NUMBER;
1527 l_order_source_id NUMBER;
1528 l_orig_sys_document_ref VARCHAR2(50);
1529 l_change_sequence VARCHAR2(50);
1530 l_source_document_type_id NUMBER;
1531 l_source_document_id NUMBER;
1532
1533 I NUMBER; -- Used as index for while loop
1534 --
1535 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1536 l_org_id number ;
1537 --
1538 BEGIN
1539
1540 --MOAC changes start
1541 l_org_id := MO_GLOBAL.get_current_org_id;
1542 IF (l_org_id IS NULL OR l_org_id = FND_API.G_MISS_NUM) THEN
1543 FND_MESSAGE.set_name('FND','MO_ORG_REQUIRED');
1544 OE_MSG_PUB.Add;
1545 RAISE FND_API.G_EXC_ERROR;
1546 END IF;
1547 --MOAC changes end
1548
1549 x_return_status := FND_API.G_RET_STS_SUCCESS;
1550
1551 -- Initialize message list.
1552
1553 IF FND_API.to_Boolean(p_init_msg_list) THEN
1554 OE_MSG_PUB.initialize;
1555 END IF;
1556
1557 IF p_control_rec.Process_Partial THEN
1558 SAVEPOINT Header_Payments;
1559 END IF;
1560
1561 -- Init local table variables.
1562
1563 IF l_debug_level > 0 THEN
1564 oe_debug_pub.add( 'ENTERING OE_ORDER_PVT.HEADER_PAYMENTS' , 1 ) ;
1565 END IF;
1566
1567 -- FOR I IN 1..p_x_Header_Payment_tbl.COUNT LOOP
1568
1569 I := p_x_Header_Payment_tbl.FIRST;
1570
1571 WHILE I IS NOT NULL LOOP
1572 BEGIN
1573
1574 -- Load local records.
1575
1576 l_Header_Payment_rec := p_x_Header_Payment_tbl(I);
1577
1578 IF p_x_old_Header_Payment_tbl.EXISTS(I) THEN
1579 l_old_Header_Payment_rec := p_x_old_Header_Payment_tbl(I);
1580 ELSE
1581 l_old_Header_Payment_rec := OE_Order_PUB.G_MISS_HEADER_PAYMENT_REC;
1582 END IF;
1583
1584 if l_old_header_Payment_rec.payment_number = FND_API.G_MISS_NUM
1585 OR l_old_header_Payment_rec.payment_number IS NULL
1586 Then
1587
1588 IF l_header_Payment_rec.header_id IS NOT NULL AND
1589 l_header_Payment_rec.header_id <> FND_API.G_MISS_NUM THEN
1590 BEGIN
1591 IF l_debug_level > 0 THEN
1592 oe_debug_pub.add('Getting reference data for header_id:'||l_header_Payment_rec.header_id);
1593 END IF;
1594 SELECT order_source_id, orig_sys_document_ref, change_sequence,
1595 source_document_type_id, source_document_id
1596 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
1597 l_source_document_type_id, l_source_document_id
1598 FROM OE_ORDER_HEADERS_ALL
1599 WHERE header_id = l_header_Payment_rec.header_id;
1600 EXCEPTION
1601 WHEN NO_DATA_FOUND THEN
1602 l_order_source_id := null;
1603 l_orig_sys_document_ref := null;
1604 l_change_sequence := null;
1605 l_source_document_type_id := null;
1606 l_source_document_id := null;
1607 WHEN OTHERS THEN
1608 l_order_source_id := null;
1609 l_orig_sys_document_ref := null;
1610 l_change_sequence := null;
1611 l_source_document_type_id := null;
1612 l_source_document_id := null;
1613 END;
1614 END IF;
1615
1616 OE_MSG_PUB.set_msg_context(
1617 p_entity_code => 'HEADER_PAYMENT'
1618 ,p_entity_id => l_header_Payment_rec.payment_number
1619 ,p_header_id => l_header_Payment_rec.header_Id
1620 ,p_line_id => null
1621 ,p_order_source_id => l_order_source_id
1622 ,p_orig_sys_document_ref => l_orig_sys_document_ref
1623 ,p_orig_sys_document_line_ref => null
1624 ,p_change_sequence => l_change_sequence
1625 ,p_source_document_type_id => l_source_document_type_id
1626 ,p_source_document_id => l_source_document_id
1627 ,p_source_document_line_id => null );
1628
1629 else
1630 IF l_old_header_Payment_rec.header_id IS NOT NULL AND
1631 l_old_header_Payment_rec.header_id <> FND_API.G_MISS_NUM THEN
1632
1633 BEGIN
1634 IF l_debug_level > 0 THEN
1635 oe_debug_pub.add('Getting reference data for old header_id:'||l_old_header_Payment_rec.header_id);
1636 END IF;
1637 SELECT order_source_id, orig_sys_document_ref, change_sequence,
1638 source_document_type_id, source_document_id
1639 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
1640 l_source_document_type_id, l_source_document_id
1641 FROM OE_ORDER_HEADERS_ALL
1642 WHERE header_id = l_old_header_Payment_rec.header_id;
1643 EXCEPTION
1644 WHEN NO_DATA_FOUND THEN
1645 l_order_source_id := null;
1646 l_orig_sys_document_ref := null;
1647 l_change_sequence := null;
1648 l_source_document_type_id := null;
1649 l_source_document_id := null;
1650 WHEN OTHERS THEN
1651 l_order_source_id := null;
1652 l_orig_sys_document_ref := null;
1653 l_change_sequence := null;
1654 l_source_document_type_id := null;
1655 l_source_document_id := null;
1656 END;
1657 END IF;
1658
1659
1660 OE_MSG_PUB.set_msg_context(
1661 p_entity_code => 'HEADER_PAYMENT'
1662 ,p_entity_id => l_old_header_Payment_rec.payment_number
1663 ,p_header_id => l_old_header_Payment_rec.header_Id
1664 ,p_line_id => null
1665 ,p_order_source_id => l_order_source_id
1666 ,p_orig_sys_document_ref => l_orig_sys_document_ref
1667 ,p_orig_sys_document_line_ref => null
1668 ,p_change_sequence => l_change_sequence
1669 ,p_source_document_type_id => l_source_document_type_id
1670 ,p_source_document_id => l_source_document_id
1671 ,p_source_document_line_id => null );
1672
1673 end if;
1674
1675 -- Load API control record
1676
1677 l_control_rec := OE_GLOBALS.Init_Control_Rec
1678 ( p_operation => l_Header_Payment_rec.operation
1679 , p_control_rec => p_control_rec
1680 );
1681
1682 -- Set record return status.
1683
1684 l_Header_Payment_rec.return_status := FND_API.G_RET_STS_SUCCESS;
1685
1686 -- Prepare record.
1687
1688 IF l_Header_Payment_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
1689
1690 l_Header_Payment_rec.db_flag := FND_API.G_FALSE;
1691
1692 -- Set missing old record elements to NULL.
1693
1694 IF l_debug_level > 0 THEN
1695 oe_debug_pub.add('Payment:before OE_Header_Payment_Util.Convert_Miss_To_Null', 5);
1696 END IF;
1697 OE_Header_Payment_Util.Convert_Miss_To_Null (l_old_Header_Payment_rec);
1698 IF l_debug_level > 0 THEN
1699 oe_debug_pub.add('Payment:after OE_Header_Payment_Util.Convert_Miss_To_Null', 5);
1700 END IF;
1701
1702 ELSIF l_Header_Payment_rec.operation = OE_GLOBALS.G_OPR_UPDATE
1703 OR l_Header_Payment_rec.operation = OE_GLOBALS.G_OPR_DELETE
1704 THEN
1705
1706 l_Header_Payment_rec.db_flag := FND_API.G_TRUE;
1707
1708 -- Query Old if missing
1709
1710 IF l_old_Header_Payment_rec.payment_number = FND_API.G_MISS_NUM
1711 OR l_old_Header_Payment_rec.payment_number IS NULL
1712 THEN
1713
1714 IF l_debug_level > 0 THEN
1715 oe_debug_pub.add('Payment:before OE_Header_Payment_Util.Query_Row', 5);
1716 END IF;
1717 OE_Header_Payment_Util.Query_Row
1718 ( p_payment_number => l_Header_Payment_rec.payment_number
1719 , p_header_id => l_Header_Payment_rec.header_id
1720 , x_header_payment_rec => l_old_Header_Payment_rec
1721 );
1722 IF l_debug_level > 0 THEN
1723 oe_debug_pub.add('Payment:after OE_Header_Payment_Util.Query_Row', 5);
1724 END IF;
1725
1726 ELSE
1727
1728 -- Set missing old record elements to NULL.
1729
1730 IF l_debug_level > 0 THEN
1731 oe_debug_pub.add('Payment:before OE_Header_Payment_Util.Convert_Miss_To_Null', 5);
1732 END IF;
1733 OE_Header_Payment_Util.Convert_Miss_To_Null (l_old_Header_Payment_rec);
1734 IF l_debug_level > 0 THEN
1735 oe_debug_pub.add('Payment:after OE_Header_Payment_Util.Convert_Miss_To_Null', 5);
1736 END IF;
1737
1738 END IF;
1739
1740 -- Complete new record from old
1741
1742 IF l_debug_level > 0 THEN
1743 oe_debug_pub.add('Payment:before OE_Header_Payment_Util.Complete_Record', 5);
1744 END IF;
1745 OE_Header_Payment_Util.Complete_Record
1746 ( p_x_Header_Payment_rec => l_Header_Payment_rec
1747 , p_old_Header_Payment_rec => l_old_Header_Payment_rec
1748 );
1749 IF l_debug_level > 0 THEN
1750 oe_debug_pub.add('Payment:after OE_Header_Payment_Util.Complete_Record', 5);
1751 END IF;
1752
1753 OE_MSG_PUB.update_msg_context(
1754 p_entity_code => 'HEADER_PAYMENT'
1755 ,p_entity_id => l_header_Payment_rec.payment_number
1756 ,p_header_id => l_header_Payment_rec.header_Id);
1757
1758
1759 END IF;
1760
1761 IF I = p_x_header_Payment_tbl.FIRST THEN
1762 IF NOT Valid_Upgraded_Order(l_header_Payment_rec.header_id) THEN
1763 RAISE FND_API.G_EXC_ERROR;
1764 END IF;
1765 END IF;
1766
1767 -- Check security
1768 IF l_control_rec.check_security
1769 AND (l_header_payment_rec.operation = OE_GLOBALS.G_OPR_CREATE
1770 OR l_header_payment_rec.operation = OE_GLOBALS.G_OPR_UPDATE)
1771 THEN
1772
1773 IF l_debug_level > 0 THEN
1774 oe_debug_pub.add( 'CHECK ATTRIBUTES SECURITY' ) ;
1775 END IF;
1776 -- check if this operation is allowed
1777 -- on all the changed attributes
1778 IF l_debug_level > 0 THEN
1779 oe_debug_pub.add('Payment:before OE_Header_Payment_Security.Attributes', 5);
1780 END IF;
1781 OE_Header_Payment_Security.Attributes
1782 (p_header_payment_rec => l_header_payment_rec
1783 , p_old_header_payment_rec => l_old_header_payment_rec
1784 , x_result => l_sec_result
1785 , x_return_status => l_return_status
1786 );
1787 IF l_debug_level > 0 THEN
1788 oe_debug_pub.add('Payment:after OE_Header_Payment_Security.Attributes', 5);
1789 END IF;
1790
1791 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1792 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1793 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1794 RAISE FND_API.G_EXC_ERROR;
1795 END IF;
1796
1797 IF l_sec_result = OE_PC_GLOBALS.YES THEN
1798 RAISE FND_API.G_EXC_ERROR;
1799 END IF;
1800
1801 END IF;
1802
1803 -- Attribute level validation.
1804
1805 IF p_validation_level > FND_API.G_VALID_LEVEL_NONE THEN
1806 IF l_debug_level > 0 THEN
1807 oe_debug_pub.add('Payment:before OE_Validate_Header_Payment.Attributes', 5);
1808 END IF;
1809
1810 OE_Validate_Header_Payment.Attributes
1811 ( x_return_status => l_return_status
1812 , p_Header_Payment_rec => l_Header_Payment_rec
1813 , p_old_Header_Payment_rec => l_old_Header_Payment_rec
1814 );
1815 IF l_debug_level > 0 THEN
1816 oe_debug_pub.add('Payment:after OE_Validate_Header_Payment.Attributes',5);
1817 END IF;
1818
1819 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1820 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1821 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1822 RAISE FND_API.G_EXC_ERROR;
1823 END IF;
1824
1825 END IF;
1826
1827
1828 -- Clear dependent attributes.
1829
1830 IF l_control_rec.clear_dependents THEN
1831
1832 IF l_debug_level > 0 THEN
1833 oe_debug_pub.add('Payment:before OE_Header_Payment_Util.Clear_Dependent_Attr', 5);
1834 END IF;
1835 OE_Header_Payment_Util.Clear_Dependent_Attr
1836 ( p_x_Header_Payment_rec => l_Header_Payment_rec
1837 , p_old_Header_Payment_rec => l_old_Header_Payment_rec
1838 );
1839 IF l_debug_level > 0 THEN
1840 oe_debug_pub.add('Payment:after OE_Header_Payment_Util.Clear_Dependent_Attr', 5);
1841 END IF;
1842
1843 END IF;
1844
1845 -- Default missing attributes
1846
1847 IF l_control_rec.default_attributes
1848 THEN
1849 IF l_debug_level > 0 THEN
1850 oe_debug_pub.add('Payment:before OE_Default_Header_Payment.Attributes', 5);
1851 END IF;
1852
1853 OE_Default_Header_Payment.Attributes
1854 ( p_x_Header_Payment_rec => l_Header_Payment_rec
1855 , p_old_header_payment_rec => l_old_header_payment_rec
1856 );
1857 IF l_debug_level > 0 THEN
1858 oe_debug_pub.add('Payment:after OE_Default_Header_Payment.Attributes', 5);
1859 END IF;
1860
1861 END IF;
1862
1863 -- Apply attribute changes
1864
1865 IF l_control_rec.change_attributes
1866 THEN
1867
1868 IF l_debug_level > 0 THEN
1869 oe_debug_pub.add('Payment:before OE_Header_Payment_Util.Apply_Attribute_Changes', 5);
1870 END IF;
1871 OE_Header_Payment_Util.Apply_Attribute_Changes
1872 ( p_x_Header_Payment_rec => l_Header_Payment_rec
1873 , p_old_Header_Payment_rec => l_old_Header_Payment_rec
1874 );
1875 IF l_debug_level > 0 THEN
1876 oe_debug_pub.add('Payment:after OE_Header_Payment_Util.Apply_Attribute_Changes', 5);
1877 END IF;
1878
1879 END IF;
1880
1881 -- Entity level validation.
1882
1883 IF l_control_rec.validate_entity THEN
1884
1885 IF l_Header_Payment_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
1886
1887 IF l_debug_level > 0 THEN
1888 oe_debug_pub.add('Payment:before OE_Validate_Header_Payment.Entity_Delete', 5);
1889 END IF;
1890 OE_Validate_Header_Payment.Entity_Delete
1891 ( x_return_status => l_return_status
1892 , p_Header_Payment_rec => l_Header_Payment_rec
1893 );
1894 IF l_debug_level > 0 THEN
1895 oe_debug_pub.add('Payment:after OE_Validate_Header_Payment.Entity_Delete', 5);
1896 END IF;
1897
1898 ELSE
1899 IF l_debug_level > 0 THEN
1900 oe_debug_pub.add('Payment:before OE_Validate_Header_Payment.Entity',5);
1901 END IF;
1902
1903 OE_Validate_Header_Payment.Entity
1904 ( x_return_status => l_return_status
1905 , p_Header_Payment_rec => l_Header_Payment_rec
1906 , p_old_Header_Payment_rec => l_old_Header_Payment_rec
1907 );
1908 IF l_debug_level > 0 THEN
1909 oe_debug_pub.add('Payment:after OE_Validate_Header_Payment.Entity, 5');
1910 END IF;
1911
1912 END IF;
1913
1914 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1915 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1916 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1917 RAISE FND_API.G_EXC_ERROR;
1918 END IF;
1919
1920 END IF;
1921
1922 -- Check entity level security again as some attributes
1923 -- may have changed due to defaulting.
1924 -- For UPDATE operations, entity security checks for constraints setup
1925 -- with a NULL column i.e. the constraint restricts update on ANY of
1926 -- the columns.
1927 -- However, this check should NOT be done if user did not try to update
1928 -- any of the constrainable attributes and also none of the defaulted
1929 -- attributes was constrainable!. In such a case, the g_check_all_cols
1930 -- _constraint flag would still be 'Y' as the flag is reset only
1931 -- when checking for constraints.
1932 IF NOT (l_header_payment_rec.operation = OE_GLOBALS.G_OPR_UPDATE
1933 AND OE_Header_Payment_Security.g_check_all_cols_constraint = 'Y')
1934 AND l_control_rec.check_security
1935 THEN
1936 IF l_debug_level > 0 THEN
1937 oe_debug_pub.add( 'CHECK ENTITY SECURITY' ) ;
1938 END IF;
1939 IF l_debug_level > 0 THEN
1940 oe_debug_pub.add('Payment:before OE_Header_Payment_Security.Entity', 5);
1941 END IF;
1942
1943 OE_Header_Payment_Security.Entity
1944 (p_header_payment_rec => l_header_payment_rec
1945 , x_result => l_sec_result
1946 , x_return_status => l_return_status
1947 );
1948 IF l_debug_level > 0 THEN
1949 oe_debug_pub.add('Payment:after OE_Header_Payment_Security.Entity', 5);
1950 END IF;
1951
1952 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1953 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1954 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1955 RAISE FND_API.G_EXC_ERROR;
1956 END IF;
1957
1958 IF l_sec_result = OE_PC_GLOBALS.YES THEN
1959 RAISE FND_API.G_EXC_ERROR;
1960 END IF;
1961
1962 END IF;
1963
1964 -- Step 4. Write to DB
1965
1966 IF l_control_rec.write_to_db THEN
1967
1968 /* Start Audit Trail */
1969 IF l_debug_level > 0 THEN
1970 oe_debug_pub.add('Payment:before Oe_Header_Payment_Util.Pre_Write_Process', 5);
1971 END IF;
1972 Oe_Header_Payment_Util.Pre_Write_Process
1973 (p_x_header_Payment_rec => l_header_payment_rec,
1974 p_old_header_payment_rec => l_old_header_payment_rec);
1975 IF l_debug_level > 0 THEN
1976 oe_debug_pub.add('Payment:after Oe_Header_Payment_Util.Pre_Write_Process', 5);
1977 END IF;
1978 /* End AuditTrail */
1979
1980 IF l_Header_Payment_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
1981 IF l_debug_level > 0 THEN
1982 oe_debug_pub.add('Payment:before Oe_Header_Payment_Util.Delete_Row',5);
1983 END IF;
1984
1985 OE_Header_Payment_Util.Delete_Row
1986 ( p_payment_number => l_Header_Payment_rec.payment_number
1987 , p_header_id => l_Header_Payment_rec.header_id
1988 );
1989 IF l_debug_level > 0 THEN
1990 oe_debug_pub.add('Payment:after Oe_Header_Payment_Util.Delete_Row',5);
1991 END IF;
1992
1993 ELSE
1994
1995 -- Get Who Information
1996
1997 l_Header_Payment_rec.last_update_date := SYSDATE;
1998 l_Header_Payment_rec.last_updated_by := FND_GLOBAL.USER_ID;
1999 l_Header_Payment_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
2000
2001 IF l_Header_Payment_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
2002
2003 OE_Header_Payment_Util.Update_Row (l_Header_Payment_rec);
2004
2005 ELSIF l_Header_Payment_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
2006
2007 l_Header_Payment_rec.creation_date := SYSDATE;
2008 l_Header_Payment_rec.created_by := FND_GLOBAL.USER_ID;
2009
2010 IF l_debug_level > 0 THEN
2011 oe_debug_pub.add('Payment:before Oe_Header_Payment_Util.Insert_Row', 5);
2012 END IF;
2013 OE_Header_Payment_Util.Insert_Row (l_Header_Payment_rec);
2014 IF l_debug_level > 0 THEN
2015 oe_debug_pub.add('Payment:after Oe_Header_Payment_Util.Insert_Row', 5);
2016 END IF;
2017
2018 END IF;
2019
2020 END IF;
2021
2022 END IF;
2023
2024 OE_Header_Payment_Security.g_check_all_cols_constraint := 'Y';
2025 OE_MSG_PUB.reset_msg_context('HEADER_PAYMENT');
2026
2027 -- loop exception handler.
2028 IF l_header_payment_rec.return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2029 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2030 ELSIF l_header_payment_rec.return_status = FND_API.G_RET_STS_ERROR THEN
2031 RAISE FND_API.G_EXC_ERROR;
2032 END IF;
2033
2034 -- Load tables.
2035
2036 l_Header_Payment_rec.return_status := FND_API.G_RET_STS_SUCCESS;
2037 p_x_Header_Payment_tbl(I) := l_Header_Payment_rec;
2038 p_x_old_Header_Payment_tbl(I) := l_old_Header_Payment_rec;
2039
2040
2041 EXCEPTION
2042
2043 WHEN FND_API.G_EXC_ERROR THEN
2044
2045 l_Header_Payment_rec.return_status := FND_API.G_RET_STS_ERROR;
2046 x_return_status := FND_API.G_RET_STS_ERROR;
2047 p_x_Header_Payment_tbl(I) := l_Header_Payment_rec;
2048 p_x_old_Header_Payment_tbl(I) := l_old_Header_Payment_rec;
2049
2050 OE_Header_Payment_Security.g_check_all_cols_constraint := 'Y';
2051 OE_MSG_PUB.reset_msg_context('HEADER_PAYMENT');
2052 IF l_control_Rec.Process_Partial THEN
2053 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
2054 IF l_debug_level > 0 THEN
2055 oe_debug_pub.add( 'DELETE REQUEST4' , 2 ) ;
2056 END IF;
2057 oe_delayed_requests_pvt.Delete_Reqs_for_Deleted_Entity
2058 (p_entity_code =>OE_GLOBALS.G_ENTITY_HEADER_PAYMENT,
2059 p_entity_id => l_header_payment_rec.header_id,
2060 x_return_status => l_return_status);
2061 END IF;
2062 ROLLBACK TO SAVEPOINT Header_Payments;
2063 ELSE
2064 RAISE FND_API.G_EXC_ERROR;
2065 END IF;
2066
2067 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2068
2069 l_Header_Payment_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2070 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2071 p_x_Header_Payment_tbl(I) := l_Header_Payment_rec;
2072 p_x_old_Header_Payment_tbl(I) := l_old_Header_Payment_rec;
2073 OE_Header_Payment_Security.g_check_all_cols_constraint := 'Y';
2074 OE_MSG_PUB.reset_msg_context('HEADER_PAYMENT');
2075 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2076
2077 WHEN OTHERS THEN
2078
2079 l_Header_Payment_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2080 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2081 p_x_Header_Payment_tbl(I) := l_Header_Payment_rec;
2082 p_x_old_Header_Payment_tbl(I) := l_old_Header_Payment_rec;
2083
2084 OE_Header_Payment_Security.g_check_all_cols_constraint := 'Y';
2085 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2086 THEN
2087 OE_MSG_PUB.Add_Exc_Msg
2088 ( G_PKG_NAME
2089 , 'Header_Payments'
2090 );
2091 END IF;
2092
2093 OE_MSG_PUB.reset_msg_context('HEADER_PAYMENT');
2094 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2095
2096 END;
2097 I := p_x_Header_Payment_tbl.NEXT(I);
2098 END LOOP;
2099
2100 IF l_debug_level > 0 THEN
2101 oe_debug_pub.add( 'EXITING OE_ORDER_PVT.HEADER_PAYMENTS' , 1 ) ;
2102 END IF;
2103 OE_MSG_PUB.reset_msg_context('HEADER_PAYMENT');
2104
2105 EXCEPTION
2106
2107 WHEN FND_API.G_EXC_ERROR THEN
2108
2109 x_return_status := FND_API.G_RET_STS_ERROR;
2110 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
2111 IF l_debug_level > 0 THEN
2112 oe_debug_pub.add( 'DELETE REQUEST5' , 2 ) ;
2113 END IF;
2114 OE_Delayed_Requests_Pvt.Clear_Request
2115 (x_return_status => l_return_status);
2116 END IF;
2117 OE_MSG_PUB.reset_msg_context('HEADER_PAYMENT');
2118
2119 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2120
2121 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2122 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
2123 IF l_debug_level > 0 THEN
2124 oe_debug_pub.add( 'DELETE REQUEST6' , 2 ) ;
2125 END IF;
2126 OE_Delayed_Requests_Pvt.Clear_Request
2127 (x_return_status => l_return_status);
2128 END IF;
2129 OE_MSG_PUB.reset_msg_context('HEADER_PAYMENT');
2130
2131 WHEN OTHERS THEN
2132
2133 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2134 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
2135 IF l_debug_level > 0 THEN
2136 oe_debug_pub.add( 'DELETE REQUEST7' , 2 ) ;
2137 END IF;
2138 OE_Delayed_Requests_Pvt.Clear_Request
2139 (x_return_status => l_return_status);
2140 END IF;
2141 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2142 THEN
2143 OE_MSG_PUB.Add_Exc_Msg
2144 ( G_PKG_NAME
2145 , 'Header_Payments'
2146 );
2147 END IF;
2148
2149
2150 OE_MSG_PUB.reset_msg_context('HEADER_PAYMENT');
2151
2152 END Header_Payments;
2153
2154
2155 /*---------------------------------------------------------------------
2156 FUNCTION Check_Item_Type
2157
2158 -- LOCAL function called in procedure Lines
2159 -- Return value from this function indicates what should be the order in
2160 -- which this line is processed based on the type of item on
2161 -- this line. The logic is based on whether the top_model_line or
2162 -- service_line identifiers are populated on the record or not.
2163 -- (Item Type is NOT used to derive this information as item_type_code
2164 -- is available only after defaulting)
2165 -- Possible Return Values:
2166 -- 1: Standard/ Model Line
2167 -- 2: Option/Class Line
2168 -- 3: Service Line
2169 ----------------------------------------------------------------------*/
2170 FUNCTION Check_Item_Type
2171 ( p_line_rec IN OE_Order_PUB.Line_Rec_Type
2172 , p_line_index IN NUMBER
2173 )
2174 RETURN NUMBER
2175 IS
2176 --
2177 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2178 --
2179 BEGIN
2180
2181 -- SERVICE line if service line identifiers are populated
2182 IF ( NVL(p_line_rec.service_reference_line_id,FND_API.G_MISS_NUM)
2183 <> FND_API.G_MISS_NUM
2184 OR NVL(p_line_rec.service_line_index,FND_API.G_MISS_NUM)
2185 <> FND_API.G_MISS_NUM )
2186 THEN
2187
2188 IF l_debug_level > 0 THEN
2189 oe_debug_pub.add( 'SERVICE LINE' , 1 ) ;
2190 END IF;
2191 RETURN 3;
2192
2193 -- Top model line identifiers are populated
2194 ELSIF ( NVL(p_line_rec.top_model_line_id,FND_API.G_MISS_NUM)
2195 <> FND_API.G_MISS_NUM
2196 OR NVL(p_line_rec.top_model_line_index,FND_API.G_MISS_NUM)
2197 <> FND_API.G_MISS_NUM )
2198 THEN
2199
2200 -- MODEL line if top model line is same as the current line
2201 IF ( p_line_rec.top_model_line_id <> FND_API.G_MISS_NUM
2202 AND p_line_rec.top_model_line_id = p_line_rec.line_id )
2203 OR ( p_line_rec.top_model_line_index <> FND_API.G_MISS_NUM
2204 AND p_line_rec.top_model_line_index = p_line_index )
2205 THEN
2206 IF l_debug_level > 0 THEN
2207 oe_debug_pub.add( 'TOP MODEL LINE' , 1 ) ;
2208 END IF;
2209 RETURN 1;
2210 -- OPTION/CLASS line if line is NOT the model line
2211 ELSE
2212 IF l_debug_level > 0 THEN
2213 oe_debug_pub.add( 'OPTION/CLASS LINE' , 1 ) ;
2214 END IF;
2215 RETURN 2;
2216 END IF;
2217
2218 ELSE
2219
2220 -- STANDARD line if neither the top model line identifiers
2221 -- nor the service line identifiers are populated
2222 IF l_debug_level > 0 THEN
2223 oe_debug_pub.add( 'STANDARD LINE' , 1 ) ;
2224 END IF;
2225 RETURN 1;
2226
2227 END IF;
2228
2229
2230 END Check_Item_Type;
2231
2232
2233
2234 /*----------------------------------------------------------------------
2235 PROCEDURE Lines
2236
2237 changes to get ato_line_id in case of pto + ato case, bug 1654987.
2238
2239 WHEN:
2240
2241 1) Almost all the additional code should never get called if the
2242 configuration is created using options window or configurator,
2243 since we already do all the work in respective code.
2244
2245 2) Some of the additional stuff happens for copy order and split.
2246 3) All the additionsl work happens for order import and any other
2247 batch api callers.
2248
2249
2250 WHY:
2251 1) We need to process all the top level parents
2252 (MODEL, KIT, STANDARD) before we start processing any of the
2253 child lines. This is because all the child lines refer to the
2254 parent lines using top_model_line_index,
2255 service_reference_line_index etc. and the child lines
2256 processing assumes that all the parents are saved in database
2257 and now it can convert all the indexes to proper values.
2258 e.g. top_model_line_index to top_model_line_id.
2259
2260 2) Thus we process
2261 all the models and standrds lines first,
2262 then all the classes, options
2263 then all service lines.
2264 This is irrespective of the operation on the lines.
2265
2266 2) New stuff:
2267 For various reasons (2 bugs till now), we need to process
2268 the class lines before the option lines for the operation
2269 of create. The single most imp. reason is that in case pto+ato
2270 case, we can make sure that all the option lines
2271 will have ato_line_id correclty populated in defaulting code
2272 itself. This is necessary for schedluing and shipping to
2273 behave correctly.
2274
2275
2276
2277 HOW:
2278 Instead of coming up with another mode of CLASS, we now have
2279 a peudo mode of CLASS within the mode of OPTIONS. This means
2280 that we will loop twice within the mode of OPTIONS, in certain
2281 cases as explained below.
2282 The reason for pseudo mode,
2283 1) The check_item_type procedure can not distinguish between a
2284 class and option. We need the (new) complete_config_line
2285 procedure for that.
2286 2) most of the code in the 2 modes(CLASS and OPTION) is common,
2287 the uncommon portion is tightly bound to each other.
2288 3) I also have modified the lines loop to goto the end_of_lines_loop
2289 instead of beging_of_line_loop. This makes sure that switch mode
2290 happens at one place and my extra login will also go at that point.
2291 4) There is no change if the operation is UPDATE or DELETE on
2292 class/options lines.
2293 5) If the call is made from configurator code or options window
2294 code, on all the classl lines, item_type_code is passed.
2295
2296
2297 LOGIC:
2298 only the new stuff is explained here(at a high level), rest is same.
2299 ***: indiactes previous code.
2300
2301 if boolean COMPLETE_AND_CLASS_SAVE_MODE is TRUE, we create CLASSES
2302 if it is fales, we create OPTIONS.
2303
2304
2305 MODE = standard_and_models and check_item_type = 1
2306 l_process_this_line = TRUE;
2307 ***
2308 IF top model,
2309 IF not called by config UI,
2310 explode the model
2311 fill in bom related stuff
2312 END IF
2313 END IF;
2314
2315
2316 MODE = OPTIONS and check_item_type = 2
2317 IF the line is processed
2318 go to end_of_lines (e.g class during option create, or update of option)
2319 END IF;
2320
2321 ***
2322
2323 IF operation = create
2324
2325 IF COMPLETE_AND_CLASS_SAVE_MODE = TRUE and no config UI used.
2326 fill in bom related stuff(indicates IF class when you are done)
2327 END IF;
2328
2329 IF this is not a CLASS line
2330 note the index, go to end_of_lines(will process, when the mode is false)
2331 END IF
2332 END IF
2333 END IF;
2334
2335
2336 MODE = SERVICE and check_item_type = 3
2337 l_process_this_line = TRUE;
2338 ***
2339
2340
2341 IF l_process_this_line = FALSE
2342 go to end_of_line_loop
2343 END IF;
2344
2345 <<end_of_line_loop>> SWITCHING modes.
2346
2347 IF MODE = 'MODELS_AND_STANDARD' AND END of lines table(only models,std done)
2348 l_mode := 'OPTIONS';
2349 COMPLETE_AND_CLASS_SAVE_MODE := TRUE;
2350 start from the first record again.
2351
2352 IF mode = 'OPTIONS' AND END of lines table (classes create, upd/del done)
2353
2354 IF COMPLETE_AND_CLASS_SAVE_MODE
2355
2356 COMPLETE_AND_CLASS_SAVE_MODE = FALSE;
2357 -- false means, create OPTIONS, mode is still OPTIONS
2358
2359 IF not config UI Used AND
2360 some of the options were skipped in creation
2361
2362 fill in all missing classes, use componenet_code and the fact
2363 that all the classes are saved now.
2364
2365 IF some new classes added,
2366 set the mode back to classes, save all of them.
2367 thus set the COMPLETE_AND_CLASS_SAVE_MODE = TRUE
2368 END IF;
2369
2370 END IF;
2371
2372 ELSE
2373 MODE = 'SERVICE';
2374 END IF;
2375
2376 END IF;
2377
2378 -- Fixed bug# 1362872: Removed code to set return_status to SUCCESS on
2379 -- the records as it was overwriting error statuses.
2380 -- The return_status is set at the end of the loop and in the case
2381 -- of errors, it is set in the exception handlers.
2382
2383 Change Record:
2384
2385 1828866: to not raise error if some of the option/class items
2386 are not available in bom_explosions. Populate message and continue.
2387 related changes in : OEXUCFGB.pls, OEXUCPYB.pls
2388
2389 We will not call the complete_config_line for splits. This is
2390 because split already passes all the columns to be filled
2391 in the complete_config. Also the call the get_missing_classes
2392 is not required for the splits. The assumption is split code
2393 already populates/copies all the config related attributes.
2394
2395 2027611: call to complete_config_line when the mode is OPTION,
2396 will be done only if top_model_line_index is present.
2397 In future we should remove check for config_ui_used global
2398 and also top_model_line_id not null, not miss_num check
2399 while calling complete_config_line.
2400 -----------------------------------------------------------------------*/
2401
2402 PROCEDURE Lines
2403 (p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
2404 ,p_validation_level IN NUMBER
2405 ,p_control_rec IN OE_GLOBALS.Control_Rec_Type
2406 ,p_x_line_tbl IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
2407 ,p_x_old_line_tbl IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
2408 ,x_return_status OUT NOCOPY VARCHAR2)
2409
2410 IS
2411 l_return_status VARCHAR2(1);
2412 l_control_rec OE_GLOBALS.Control_Rec_Type;
2413 l_line_rec OE_Order_PUB.Line_Rec_Type;
2414 l_old_line_rec OE_Order_PUB.Line_Rec_Type;
2415 l_mode VARCHAR2(20);
2416 I NUMBER;
2417 l_top_model_line_index NUMBER;
2418 l_service_line_index NUMBER;
2419 l_user_id NUMBER;
2420 l_resp_id NUMBER;
2421 l_application_id NUMBER;
2422 l_line_process_name VARCHAR2(30);
2423
2424 -- local variables to store OUT parameters from security check procedures
2425 l_sec_result NUMBER;
2426 l_on_operation_action NUMBER;
2427 l_result Varchar2(30);
2428 l_request_ind NUMBER;
2429 l_check_item_type NUMBER;
2430 l_daemon_type VARCHAR2(1);
2431 l_is_ota_line BOOLEAN;
2432 l_order_quantity_uom VARCHAR2(3);
2433 l_header_locked VARCHAR2(1) := FND_API.G_MISS_CHAR;
2434 l_locked_header_rec OE_Order_PUB.Header_Rec_Type;
2435 l_process_this_line BOOLEAN;
2436 COMPLETE_AND_CLASS_SAVE_MODE BOOLEAN := TRUE;
2437 l_options_index_tbl OE_OPTION_INDEX_TBL_TYPE;
2438 l_class_index NUMBER;
2439 l_class_count NUMBER;
2440 J NUMBER := 0;
2441 l_num_lines NUMBER;
2442 l_bom_item_type NUMBER;
2443 --
2444 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2445 l_org_id number ;
2446 --
2447 BEGIN
2448
2449 --SUN OIP ER
2450 L_event_tbl.DELETE;
2451 --End of SUN OIP ER
2452
2453 --Moac changes start
2454 l_org_id := MO_GLOBAL.get_current_org_id;
2455 IF (l_org_id IS NULL OR l_org_id = FND_API.G_MISS_NUM) THEN
2456 FND_MESSAGE.set_name('FND','MO_ORG_REQUIRED');
2457 OE_MSG_PUB.Add;
2458 RAISE FND_API.G_EXC_ERROR;
2459 END IF;
2460 --Moac changes end
2461 set_recursion_mode(p_Entity_Code => 5,
2462 p_In_out => 1);
2463
2464 l_num_lines := p_x_line_tbl.COUNT;
2465
2466 Print_Time('Entering OE_ORDER_PVT.LINES ' || l_num_lines );
2467
2468 IF l_debug_level > 0 THEN
2469 oe_debug_pub.add('Entering OE_ORDER_PVT.LINES ' || l_num_lines, 0.5); --added for bug 13435459
2470 END IF;
2471
2472 x_return_status := FND_API.G_RET_STS_SUCCESS;
2473
2474 IF OE_GLOBALS.G_RECURSION_MODE <> 'Y' THEN
2475 SAVEPOINT Lines_Non_Partial;
2476 END IF;
2477
2478 -- Initialize message list.
2479
2480 IF FND_API.to_Boolean(p_init_msg_list) THEN
2481 OE_MSG_PUB.initialize;
2482 END IF;
2483
2484 -- Looping through the table to first process all the models and
2485 -- standard lines in the table. When models and options are processed in
2486 -- one Process Order Call (like in Copy Order) options do not have
2487 -- top_model_line_id
2488 -- and link_to_line_id populated. Thus the Parent line has to be
2489 -- processed before the
2490 -- options so that we can populate the option's top_model_line_id and
2491 -- link_to_line_id.
2492
2493 IF l_debug_level > 0 THEN
2494 oe_debug_pub.add( 'G_CONFIG_UI_USED '|| OE_CONFIG_UTIL.G_CONFIG_UI_USED , 5 ) ;
2495 END IF;
2496
2497 l_mode := 'MODELS_AND_STANDARD' ;
2498
2499 I := p_x_line_tbl.FIRST;
2500
2501 WHILE I IS NOT NULL AND l_num_lines > 0
2502 LOOP
2503 IF l_debug_level > 0 THEN
2504 oe_debug_pub.add( '---------LOOPING FOR NTH TIME N= '|| I , 1 ) ;
2505 END IF;
2506
2507 IF p_x_line_tbl(I).operation = OE_GLOBALS.G_OPR_NONE THEN
2508 IF l_debug_level > 0 THEN
2509 oe_debug_pub.add( 'OPERATION IS NONE ' , 1 ) ;
2510 END IF;
2511
2512 IF nvl(p_x_line_tbl(I).semi_processed_flag, FALSE) = FALSE THEN
2513 IF l_debug_level > 0 THEN
2514 oe_debug_pub.add( 'ALREADY CAME IN , OPR = NONE' , 5 ) ;
2515 END IF;
2516 p_x_line_tbl(I).semi_processed_flag := TRUE;
2517 l_num_lines := l_num_lines - 1;
2518 END IF;
2519
2520 GOTO end_of_lines_loop;
2521 END IF;
2522
2523 l_process_this_line := FALSE;
2524
2525 BEGIN
2526
2527 -- Added following logic to identify the RMA lines if user has sent in the
2528 -- ordered_quantity as negative. (bug2620749)
2529
2530 IF p_x_line_tbl(I).ordered_quantity < 0 AND
2531 ( p_x_line_tbl(I).line_category_code IS NULL OR
2532 p_x_line_tbl(I).line_category_code = FND_API.G_MISS_CHAR OR
2533 p_x_line_tbl(I).line_category_code = 'RETURN')
2534 THEN
2535 p_x_line_tbl(I).line_category_code := 'RETURN';
2536 p_x_line_tbl(I).ordered_quantity := (-1) *
2537 p_x_line_tbl(I).ordered_quantity;
2538 END IF;
2539
2540 -- Change the same on the OLD record.
2541 IF p_x_old_line_tbl.EXISTS(I) THEN
2542 IF p_x_old_line_tbl(I).ordered_quantity < 0 AND
2543 ( p_x_old_line_tbl(I).line_category_code IS NULL OR
2544 p_x_old_line_tbl(I).line_category_code = FND_API.G_MISS_CHAR OR
2545 p_x_old_line_tbl(I).line_category_code = 'RETURN')
2546 THEN
2547 p_x_old_line_tbl(I).line_category_code := 'RETURN';
2548 p_x_old_line_tbl(I).ordered_quantity := (-1) *
2549 p_x_old_line_tbl(I).ordered_quantity;
2550 END IF;
2551
2552 END IF;
2553
2554 --Added for bug 4937633 source type for Internal orders will be Internal
2555 IF p_x_line_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE THEN
2556
2557 IF p_x_line_tbl(I).source_document_type_id = 10
2558 OR oe_order_cache.g_header_rec.source_document_type_id = 10 THEN
2559 p_x_line_tbl(I).source_type_code := OE_GLOBALS.G_SOURCE_INTERNAL;
2560 END IF;
2561 END IF;
2562 --Added for bug 4937633 end
2563
2564 l_line_rec := p_x_line_tbl(I);
2565 IF l_debug_level > 0 THEN
2566 oe_debug_pub.add( 'SCH ARR DATE='||L_LINE_REC.SCHEDULE_ARRIVAL_DATE ) ;
2567 END IF;
2568
2569 -- Load old records
2570 IF p_x_old_line_tbl.EXISTS(I) THEN
2571 l_old_line_rec := p_x_old_line_tbl(I);
2572 ELSE
2573 l_old_line_rec := OE_Order_PUB.G_MISS_LINE_REC;
2574 END IF;
2575
2576 IF l_old_line_rec.line_id = FND_API.G_MISS_NUM OR
2577 l_old_line_rec.line_id IS NULL
2578 THEN
2579
2580 OE_MSG_PUB.set_msg_context
2581 ( p_entity_code => 'LINE'
2582 ,p_entity_id => l_line_rec.line_id
2583 ,p_header_id => l_line_rec.header_id
2584 ,p_line_id => l_line_rec.line_id
2585 ,p_orig_sys_document_ref => l_line_rec.orig_sys_document_ref
2586 ,p_orig_sys_document_line_ref => l_line_rec.orig_sys_line_ref
2587 ,p_orig_sys_shipment_ref => l_line_rec.orig_sys_shipment_ref
2588 ,p_change_sequence => l_line_rec.change_sequence
2589 ,p_source_document_id => l_line_rec.source_document_id
2590 ,p_source_document_line_id => l_line_rec.source_document_line_id
2591 ,p_order_source_id => l_line_rec.order_source_id
2592 ,p_source_document_type_id => l_line_rec.source_document_type_id);
2593
2594 ELSE
2595
2596 OE_MSG_PUB.set_msg_context
2597 ( p_entity_code => 'LINE'
2598 ,p_entity_id => l_old_line_rec.line_id
2599 ,p_header_id => l_old_line_rec.header_id
2600 ,p_line_id => l_old_line_rec.line_id
2601 ,p_orig_sys_document_ref => l_old_line_rec.orig_sys_document_ref
2602 ,p_orig_sys_document_line_ref => l_old_line_rec.orig_sys_line_ref
2603 ,p_orig_sys_shipment_ref => l_old_line_rec.orig_sys_shipment_ref
2604 ,p_change_sequence => l_old_line_rec.change_sequence
2605 ,p_source_document_id => l_old_line_rec.source_document_id
2606 ,p_source_document_line_id => l_old_line_rec.source_document_line_id
2607 ,p_order_source_id => l_old_line_rec.order_source_id
2608 ,p_source_document_type_id => l_old_line_rec.source_document_type_id);
2609
2610 END IF;
2611
2612
2613 -- Set Save Point
2614 IF p_control_rec.Process_Partial THEN
2615 SAVEPOINT Lines;
2616 END IF;
2617
2618 -- Fixed bug# 1362872: Removed code to set return_status to SUCCESS on
2619 -- the records as it was overwriting error statuses.
2620 -- The return_status is set at the end of the loop and in the case
2621 -- of errors, it is set in the exception handlers.
2622
2623 -- Prepare record.
2624
2625 IF l_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
2626
2627 IF l_debug_level > 0 THEN
2628 oe_debug_pub.add( 'OPERATION = CREATE SO SETTING OLD TO NULL' , 2 ) ;
2629 END IF;
2630
2631 l_line_rec.db_flag := FND_API.G_FALSE;
2632
2633 -- Set missing old record elements to NULL.
2634
2635 OE_Line_Util.Convert_Miss_To_Null (l_old_line_rec);
2636
2637 -- Lock the order header for unbooked orders: This would prevent order
2638 -- lines from being inserted on an order when it is being booked
2639 -- as the booking process also locks the order header.
2640
2641 /*******
2642 IF l_header_locked = FND_API.G_MISS_CHAR THEN
2643 oe_debug_pub.add('locking the header record');
2644
2645 SAVEPOINT Header_Lock;
2646
2647 OE_Header_Util.Lock_Row
2648 ( p_header_id => l_line_rec.header_id
2649 , x_return_status => l_return_status
2650 , p_x_header_rec => l_locked_header_rec);
2651
2652 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2653 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2654 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2655 RAISE FND_API.G_EXC_ERROR;
2656 END IF;
2657
2658 IF l_locked_header_rec.booked_flag = 'N' THEN
2659 l_header_locked := 'Y';
2660 ELSE
2661 l_header_locked := 'N';
2662 ROLLBACK TO Header_Lock;
2663 END IF;
2664
2665 END IF;
2666 *******/
2667
2668 ELSIF l_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE OR
2669 l_line_rec.operation = OE_GLOBALS.G_OPR_DELETE
2670 THEN
2671
2672 IF l_debug_level > 0 THEN
2673 oe_debug_pub.add( 'OPERATION = UPDATE SO QUERY OLD' , 1 ) ;
2674 END IF;
2675
2676 l_line_rec.db_flag := FND_API.G_TRUE;
2677
2678 -- Query Old if missing
2679
2680 IF l_old_line_rec.line_id = FND_API.G_MISS_NUM OR
2681 l_old_line_rec.line_id IS NULL
2682 THEN
2683
2684 IF l_debug_level > 0 THEN
2685 oe_debug_pub.add( 'QUERYING OLD LINE REC' ,0.5 ) ; --debug added for bug 13435459
2686 END IF;
2687
2688 OE_Line_Util.Query_Row
2689 ( p_line_id => l_line_rec.line_id
2690 , x_line_rec => l_old_line_rec );
2691
2692 IF l_debug_level > 0 THEN
2693 oe_debug_pub.add( 'AFTER QUERYING OLD LINE REC' ,0.5 ) ; --debug added for bug 13435459
2694 END IF;
2695
2696
2697 -- Only for lines we are reassiging queried line into old tbl
2698 -- to avoid requery.
2699 p_x_old_line_tbl(I) := l_old_line_rec;
2700
2701 ELSE
2702 IF l_debug_level > 0 THEN
2703 oe_debug_pub.add( 'Before convert_miss_to_null'||l_old_line_rec.reserved_quantity , 0.5 ) ; --debug level changed to 0.5 for bug 13435459
2704 END IF;
2705 -- Set missing old record elements to NULL.
2706 OE_Line_Util.Convert_Miss_To_Null (l_old_line_rec);
2707
2708 IF l_debug_level > 0 THEN
2709 oe_debug_pub.add( 'After convert_miss_to_null'||l_old_line_rec.reserved_quantity , 0.5 ) ; --debug level changed to 0.5 for bug 13435459
2710 END IF;
2711
2712 END IF;
2713 -- Reverting Changes(done for bug9654935) For bug 10207400
2714 /*Starting changes for bug 9654935 */
2715 -- IF l_old_line_rec.reserved_quantity = FND_API.G_MISS_NUM THEN
2716 -- l_old_line_rec.reserved_quantity := NULL;
2717 -- END IF;
2718 /*Ending changes for bug 9654935 */
2719 -- Complete new record from old
2720
2721 IF l_debug_level > 0 THEN
2722 oe_debug_pub.add( 'COMPLETE NEW RECORD FROM OLD' , 0.5 ) ; --debug level changed to 0.5 for 13435459
2723 END IF;
2724
2725 OE_Line_Util.Complete_Record
2726 ( p_x_line_rec => l_line_rec
2727 ,p_old_line_rec => l_old_line_rec);
2728
2729 IF l_debug_level > 0 THEN
2730 oe_debug_pub.add( 'AFTER COMPLETE NEW RECORD FROM OLD' , 0.5 ) ; --debug level changed to 0.5 for 13435459
2731 END IF;
2732
2733 OE_MSG_PUB.update_msg_context
2734 ( p_entity_code => 'LINE'
2735 ,p_entity_id => l_line_rec.line_id
2736 ,p_header_id => l_line_rec.header_id
2737 ,p_line_id => l_line_rec.line_id
2738 ,p_order_source_id => l_line_rec.order_source_id
2739 ,p_orig_sys_document_ref => l_line_rec.orig_sys_document_ref
2740 ,p_orig_sys_document_line_ref => l_line_rec.orig_sys_line_ref
2741 ,p_source_document_type_id => l_line_rec.source_document_type_id
2742 ,p_source_document_id => l_line_rec.source_document_id
2743 ,p_source_document_line_id => l_line_rec.source_document_line_id );
2744
2745 IF OE_Code_Control.code_release_level >= '110510'
2746 AND NVL(FND_PROFILE.VALUE('ONT_3A7_RESPONSE_REQUIRED'), 'N') = 'Y'
2747 -- Added this check because, holds will be applied only when this profile is set to 'YES'.
2748 AND l_line_rec.order_source_id = OE_Acknowledgment_Pub.G_XML_ORDER_SOURCE_ID
2749 AND nvl(l_line_rec.xml_transaction_type_code, FND_API.G_MISS_CHAR)
2750 IN (OE_Acknowledgment_Pub.G_TRANSACTION_CHO,OE_Acknowledgment_Pub.G_TRANSACTION_CPO) THEN -- 3A8/3A9
2751
2752 IF l_debug_level > 0 THEN --debug level changed to 0.5 for 13435459
2753 oe_debug_pub.add( 'Calling OE_Acknowledgment_PUB.Process_3A8 for transaction type: '|| l_line_rec.xml_transaction_type_code, 0.5 ) ;
2754 END IF;
2755 OE_Acknowledgment_PUB.Process_3A8
2756 ( p_x_line_rec => l_line_rec
2757 , p_old_line_rec => l_old_line_rec
2758 , x_return_status => l_return_status
2759 );
2760 IF l_debug_level > 0 THEN
2761 oe_debug_pub.add( 'Return status after call to Process_3A8:' || l_return_status, 0.5 ) ; --bug13435459
2762 END IF;
2763
2764 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2765 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2766 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2767 RAISE FND_API.G_EXC_ERROR;
2768 END IF;
2769 END IF;
2770
2771 END IF; -- if operation is create.
2772
2773 IF l_debug_level > 0 THEN
2774 oe_debug_pub.add( 'AT LINE LEVEL HEADER_ID' || L_LINE_REC.HEADER_ID , 2 ) ;
2775 END IF;
2776 IF I = p_x_line_tbl.FIRST THEN
2777 IF NOT Valid_Upgraded_Order(l_line_rec.header_id) THEN
2778 RAISE FND_API.G_EXC_ERROR;
2779 END IF;
2780 END IF;
2781
2782 -- Lock the order header for unbooked orders: This would prevent order
2783 -- lines from being inserted on an order when it is being booked
2784 -- as the booking process also locks the order header.
2785 -- The g_booked_flag should have been set by the call to
2786 -- Valid_Upgraded_Order before.
2787
2788 IF l_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
2789 -- QUOTING changes
2790 -- Comment out booked flag check, move header locked
2791 -- check inside this IF statement.
2792 IF l_header_locked = FND_API.G_MISS_CHAR THEN -- AND g_booked_flag = 'N' THEN #2940426
2793
2794 -- Lock only if the po is called by UI or
2795 -- with write_to_db flag , this way for validate_only
2796 -- don't lock.
2797
2798 IF (OE_GLOBALS.G_UI_FLAG AND
2799 NOT (OE_GLOBALS.G_HTML_FLAG)) OR
2800 p_control_rec.write_to_db THEN
2801
2802 IF l_debug_level > 0 THEN
2803 oe_debug_pub.add( 'LOCKING THE HEADER RECORD' ,0.5 ) ; -- debug level added for bug 13435459
2804 END IF;
2805
2806 OE_Header_Util.Lock_Row
2807 ( p_header_id => l_line_rec.header_id
2808 ,x_return_status => l_return_status
2809 ,p_x_header_rec => l_locked_header_rec);
2810
2811 IF l_debug_level > 0 THEN
2812 oe_debug_pub.add( 'AFTER LOCKING THE HEADER RECORD' ,0.5 ) ; -- debug added for bug 13435459
2813 END IF;
2814
2815
2816 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2817 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2818 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
2819 RAISE FND_API.G_EXC_ERROR;
2820 END IF;
2821
2822 l_header_locked := 'Y';
2823
2824 END IF; -- UI flag
2825
2826 END IF; -- if header locked check
2827 --Added the IF condition as part of the fix for bug 14167434
2828 IF l_line_rec.transaction_phase_code IS NULL OR l_line_rec.transaction_phase_code = FND_API.G_MISS_CHAR
2829 THEN
2830
2831 -- QUOTING changes
2832 -- Initialize line transaction phase from locked header rec
2833 l_line_rec.transaction_phase_code :=
2834 l_locked_header_rec.transaction_phase_code;
2835 END IF;
2836
2837 END IF; -- opr = create and hdr locked etc.
2838
2839
2840 ------------- lines loop starts ------------------------------
2841
2842 IF l_debug_level > 0 THEN
2843 oe_debug_pub.add( 'ITEM TYPE :'||P_X_LINE_TBL ( I ) .ITEM_TYPE_CODE ) ;
2844 END IF;
2845
2846 l_check_item_type := Check_Item_Type(l_line_rec,I);
2847
2848 IF l_debug_level > 0 THEN
2849 oe_debug_pub.add( 'CHECK_ITEM_TYPE RETURNS :'||L_CHECK_ITEM_TYPE ) ;
2850 END IF;
2851
2852
2853
2854 IF (l_mode = 'MODELS_AND_STANDARD') AND
2855 l_check_item_type = 1 THEN
2856
2857 IF l_debug_level > 0 THEN
2858 oe_debug_pub.add( 'L_MODE IS MODELS_AND_STANDARD' , 1 ) ;
2859 END IF;
2860
2861 IF OE_Config_Util.G_Config_UI_Used = 'N' AND
2862 l_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
2863 ((l_line_rec.top_model_line_index is NOT NULL AND
2864 l_line_rec.top_model_line_index <> FND_API.G_MISS_NUM) OR
2865 (l_line_rec.top_model_line_id is NOT NULL AND
2866 l_line_rec.top_model_line_id <> FND_API.G_MISS_NUM)) AND
2867 (l_line_rec.split_from_line_id is NULL OR
2868 l_line_rec.split_from_line_id = FND_API.G_MISS_NUM)
2869 THEN
2870 -- bug 3286378
2871 IF l_line_rec.inventory_item_id IS NULL THEN
2872 IF l_debug_level > 0 THEN
2873 oe_debug_pub.add( 'No Item at the line' , 1 ) ;
2874 END IF;
2875 p_x_line_tbl(I).component_code := null;
2876 p_x_line_tbl(I).component_sequence_id := null;
2877 p_x_line_tbl(I).sort_order := null;
2878 ELSIF NOT OE_GLOBALS.EQUAL(l_line_rec.inventory_item_id,
2879 l_old_line_rec.inventory_item_id) THEN
2880 IF l_debug_level > 0 THEN
2881 oe_debug_pub.add('Line Item is Changed '
2882 ||l_line_rec.inventory_item_id , 1 ) ;
2883 END IF;
2884
2885 BEGIN
2886 IF l_old_line_rec.inventory_item_id is NOT NULL THEN
2887 SELECT bom_item_type
2888 INTO l_bom_item_type
2889 FROM mtl_system_items
2890 WHERE inventory_item_id = l_line_rec.inventory_item_id
2891 AND organization_id
2892 = OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');
2893
2894 IF l_debug_level > 0 THEN
2895 oe_debug_pub.add('old Line Item exists '
2896 ||l_bom_item_type, 1);
2897 END IF;
2898
2899 ELSE
2900 l_bom_item_type := 1;
2901 END IF;
2902 IF l_debug_level > 0 THEN
2903 oe_debug_pub.add('BOM ITEM TYPE : '||l_bom_item_type, 1);
2904 END IF;
2905
2906 IF l_bom_item_type = 1 THEN
2907 IF l_debug_level > 0 THEN
2908 oe_debug_pub.add( 'CALLING Complete_Config_Line' ,0.5); --debug level changed to 0.5 for bug 13435459
2909 oe_debug_pub.add
2910 ('comp seq id '||l_line_rec.component_sequence_id,1);
2911 END IF;
2912
2913 l_line_rec.component_code := null;
2914 l_line_rec.component_sequence_id := null;
2915 l_line_rec.sort_order := null;
2916
2917 Complete_Config_Line
2918 ( p_x_line_rec => l_line_rec
2919 ,p_item_type => 1
2920 ,p_x_line_tbl => p_x_line_tbl);
2921
2922 IF l_debug_level > 0 THEN
2923 oe_debug_pub.add( 'AFTER CALLING Complete_Config_Line' ,0.5); --debug added for bug 13435459
2924 END IF;
2925
2926 p_x_line_tbl(I).component_code
2927 := l_line_rec.component_code;
2928 p_x_line_tbl(I).component_sequence_id
2929 := l_line_rec.component_sequence_id;
2930 p_x_line_tbl(I).sort_order := l_line_rec.sort_order;
2931 ELSE
2932 IF l_debug_level > 0 THEN
2933 oe_debug_pub.add( 'Setting Component code to Null',1);
2934 END IF;
2935 p_x_line_tbl(I).component_code := null;
2936 p_x_line_tbl(I).component_sequence_id := null;
2937 p_x_line_tbl(I).sort_order := null;
2938 END IF;
2939 EXCEPTION
2940 WHEN OTHERS THEN
2941 IF l_debug_level > 0 THEN
2942 oe_debug_pub.add( 'Did not get any bom item type',1);
2943 END IF;
2944 --RAISE FND_API.G_EXC_ERROR;
2945 RAISE;
2946 END;
2947 END IF;
2948 END IF;
2949
2950 l_process_this_line := TRUE;
2951
2952 END IF; -- mode is standard.
2953
2954
2955 ---------------------- mode is options ----------------------
2956 IF (l_mode = 'OPTIONS') AND
2957 l_check_item_type = 2 THEN
2958
2959 IF l_debug_level > 0 THEN
2960 oe_debug_pub.add( 'L_MODE IS OPTIONS' , 1 ) ;
2961 END IF;
2962
2963 IF nvl(l_line_rec.semi_processed_flag, FALSE) = TRUE THEN
2964 IF l_debug_level > 0 THEN
2965 oe_debug_pub.add( 'LINE IS ALREADY PROCESSED , GOTO END..' , 1 ) ;
2966 END IF;
2967 GOTO end_of_lines_loop;
2968 END IF;
2969
2970 l_process_this_line := TRUE;
2971
2972 -- If the line has top_model_line_index, populate it's
2973 -- top_model_line_id from p_x_line_tbl(top_model_line_index).line_id
2974 -- note that the top most model line will get its top_model_line_id in
2975 -- hardcoded defaulting and since we process models before options,
2976 -- model should already have the top model line id.
2977
2978 IF ((l_line_rec.top_model_line_index <> FND_API.G_MISS_NUM) AND
2979 (l_line_rec.top_model_line_index IS NOT NULL))
2980 THEN
2981 l_top_model_line_index := l_line_rec.top_model_line_index;
2982
2983 IF p_x_line_tbl.EXISTS(l_top_model_line_index) THEN
2984
2985 IF (l_line_rec.top_model_line_id = FND_API.G_MISS_NUM) OR
2986 (l_line_rec.top_model_line_id IS NULL) THEN
2987
2988 IF l_debug_level > 0 THEN
2989 oe_debug_pub.add( 'MODEL:'||P_X_LINE_TBL ( L_TOP_MODEL_LINE_INDEX ) .RETURN_STATUS ) ;
2990 END IF;
2991
2992
2993 IF p_x_line_tbl(l_top_model_line_index).return_status =
2994 FND_API.G_RET_STS_SUCCESS THEN
2995
2996 l_line_rec.top_model_line_id :=
2997 p_x_line_tbl(l_top_model_line_index).line_id;
2998
2999 p_x_line_tbl(I).top_model_line_id := l_line_rec.top_model_line_id;
3000
3001 ELSE
3002 IF p_x_line_tbl(l_top_model_line_index).return_status IS NULL
3003 THEN
3004 IF l_debug_level > 0 THEN
3005 oe_debug_pub.add( 'TOP MODEL RETURN STATUS IS NULL' , 1 ) ;
3006 END IF;
3007 END IF;
3008
3009 IF l_debug_level > 0 THEN
3010 oe_debug_pub.add( 'TOP MODEL LINE PROCESSED WITH ERRORS' , 1 ) ;
3011 END IF;
3012
3013 GOTO end_of_lines_loop;
3014 END IF; -- ret sts success
3015
3016 END IF;
3017
3018
3019 ELSE -- Invalid Index
3020 IF l_debug_level > 0 THEN
3021 oe_debug_pub.add( 'INVALID LINE INDEX ' , 2 ) ;
3022 END IF;
3023 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3024 END IF; -- if valid index, top model is not at the index
3025
3026 ELSE
3027 IF l_debug_level > 0 THEN
3028 oe_debug_pub.add( 'MODE IS OPTIONS BUT NO TOP MODEL LINE INDEX??' , 1 ) ;
3029 END IF;
3030 END IF; -- if top model line index is populated
3031
3032 -- if it comes here, everything was OK. ---------
3033
3034 IF l_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
3035 (nvl(l_line_rec.item_type_code, 'A') <> OE_GLOBALS.G_ITEM_INCLUDED
3036 AND
3037 nvl(l_line_rec.item_type_code, 'A') <> OE_GLOBALS.G_ITEM_CONFIG)
3038 THEN
3039
3040 IF COMPLETE_AND_CLASS_SAVE_MODE THEN
3041
3042 IF OE_Config_Util.G_Config_UI_Used = 'N' AND
3043 (l_line_rec.split_from_line_id is NULL OR
3044 l_line_rec.split_from_line_id = FND_API.G_MISS_NUM) AND
3045 (l_line_rec.top_model_line_index is NOT NULL AND
3046 l_line_rec.top_model_line_index <> FND_API.G_MISS_NUM)
3047 THEN
3048
3049 Complete_Config_Line
3050 ( p_x_line_rec => l_line_rec
3051 ,p_item_type => 2
3052 ,p_x_line_tbl => p_x_line_tbl
3053 ,p_process_partial => p_control_rec.process_partial);
3054
3055 p_x_line_tbl(I).component_code := l_line_rec.component_code;
3056 p_x_line_tbl(I).component_sequence_id
3057 := l_line_rec.component_sequence_id;
3058 p_x_line_tbl(I).sort_order := l_line_rec.sort_order;
3059 p_x_line_tbl(I).order_quantity_uom
3060 := l_line_rec.order_quantity_uom;
3061 p_x_line_tbl(I).operation := l_line_rec.operation;
3062 p_x_line_tbl(I).return_status := l_line_rec.return_status;
3063
3064 END IF;
3065
3066 IF nvl(l_line_rec.item_type_code, 'A') <> OE_GLOBALS.G_ITEM_CLASS
3067 THEN
3068 IF l_debug_level > 0 THEN
3069 oe_debug_pub.add( 'NOT A CLASS , SKIP' , 3 ) ;
3070 END IF;
3071
3072 IF l_line_rec.split_from_line_id is NULL THEN
3073 J := J + 1;
3074 l_options_index_tbl(J) := I;
3075 END IF;
3076
3077 l_process_this_line := FALSE;
3078 END IF;
3079
3080 ELSE -- now saving options -- may not req.
3081
3082 IF nvl(l_line_rec.item_type_code, 'A') = OE_GLOBALS.G_ITEM_CLASS
3083 THEN
3084 IF l_debug_level > 0 THEN
3085 oe_debug_pub.add( 'THIS CLASS IS ALREADY SAVED' , 3 ) ;
3086 END IF;
3087 l_process_this_line := FALSE;
3088 END IF;
3089
3090 END IF; -- complete mode check
3091
3092 END IF; -- operation = create
3093
3094 -- this is important in case of the recursive calls.
3095
3096 IF l_line_rec.top_model_line_id is NOT NULL THEN
3097 l_line_rec.top_model_line_index := NULL;
3098 p_x_line_tbl(I).top_model_line_index := NULL;
3099 END IF;
3100 END IF; -- if mode is option
3101
3102
3103 ---------------------- mode is service ----------------------
3104
3105 IF (l_mode = 'SERVICE') AND
3106 l_check_item_type = 3 THEN
3107
3108 IF l_debug_level > 0 THEN
3109 oe_debug_pub.add( 'JPN: MODE IS SERVICE' ) ;
3110 END IF;
3111 l_process_this_line := TRUE;
3112
3113 IF ((l_line_rec.service_line_index <> FND_API.G_MISS_NUM) AND
3114 (l_line_rec.service_line_index IS NOT NULL))
3115 THEN
3116 l_service_line_index := l_line_rec.service_line_index;
3117
3118 -- If the line has service_line_index, populate it's
3119 -- service_reference_line_id from the
3120 -- p_x_line_tbl(service_line_index).line_id
3121
3122 IF p_x_line_tbl.EXISTS(l_service_line_index) THEN
3123 IF (l_line_rec.service_reference_line_id = FND_API.G_MISS_NUM)
3124 OR (l_line_rec.service_reference_line_id IS NULL) THEN
3125
3126 IF p_x_line_tbl(l_service_line_index).return_status =
3127 FND_API.G_RET_STS_SUCCESS THEN
3128 -- lchen added to check parent line operation to fix bug 2017271
3129 IF p_x_line_tbl(l_service_line_index).operation = OE_GLOBALS.G_OPR_NONE
3130 THEN
3131 GOTO end_of_lines_loop;
3132 ELSE
3133 l_line_rec.service_reference_line_id :=
3134 p_x_line_tbl(l_service_line_index).line_id;
3135 END IF; /* operation = none */
3136
3137 ELSE
3138 GOTO end_of_lines_loop;
3139 END IF;
3140
3141 END IF;
3142 ELSE -- Invalid Index
3143 IF l_debug_level > 0 THEN
3144 oe_debug_pub.add( 'INVALID SERVICE LINE INDEX ' , 2 ) ;
3145 END IF;
3146 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3147 END IF; -- If Valid Line Index
3148
3149 END IF;
3150
3151 END IF; -- end of service.
3152
3153
3154
3155 IF l_process_this_line = FALSE THEN
3156
3157 IF l_debug_level > 0 THEN
3158 oe_debug_pub.add( 'MODE AND ITEM TYPE DOES NOT MATCH , GO TO END' , 1 ) ;
3159 END IF;
3160
3161 l_line_rec.semi_processed_flag := FALSE;
3162 p_x_line_tbl(I).semi_processed_flag := FALSE;
3163 GOTO end_of_lines_loop;
3164
3165 ELSE
3166
3167 l_line_rec.semi_processed_flag := TRUE;
3168 p_x_line_tbl(I).semi_processed_flag := TRUE;
3169 l_num_lines := l_num_lines - 1;
3170 IF l_debug_level > 0 THEN
3171 oe_debug_pub.add( L_NUM_LINES|| ' '||L_LINE_REC.ITEM_TYPE_CODE||L_LINE_REC.LINE_ID , 1 ) ;
3172 END IF;
3173
3174 END IF; -- to process the line or not
3175
3176
3177
3178 -- Load old records.
3179
3180 IF l_debug_level > 0 THEN
3181 oe_debug_pub.add( 'STARTING LINE LOOP. HEADER_ID = '|| TO_CHAR ( L_LINE_REC.HEADER_ID ) , 2 ) ;
3182 END IF;
3183
3184 -- Load API control record
3185
3186 l_control_rec := OE_GLOBALS.Init_Control_Rec
3187 ( p_operation => l_line_rec.operation
3188 ,p_control_rec => p_control_rec);
3189
3190
3191 OE_LINE_UTIL.Pre_Attribute_Security(p_x_line_rec => l_line_rec
3192 ,p_old_line_rec => l_old_line_rec
3193 ,p_index => I );
3194
3195 -- CHECK SECURITY
3196
3197 IF l_control_rec.check_security AND
3198 (l_line_rec.operation = OE_GLOBALS.G_OPR_CREATE OR
3199 l_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE)
3200 THEN
3201
3202 IF l_debug_level > 0 THEN
3203 oe_debug_pub.add( 'CHECK ATTRIBUTES SECURITY' , 0.5 ) ; -- debug level changed to 0.5 for bug 13435459
3204 END IF;
3205 -- check if this operation is allowed on all the changed attributes
3206 OE_Line_Security.Attributes
3207 ( p_line_rec => l_line_rec
3208 ,p_old_line_rec => l_old_line_rec
3209 ,x_result => l_sec_result
3210 ,x_return_status => l_return_status);
3211
3212 IF l_debug_level > 0 THEN
3213 oe_debug_pub.add( 'AFTER CHECK ATTRIBUTES SECURITY' , 0.5 ) ; --debug added for 13435459
3214 END IF;
3215
3216 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3217 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3218 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3219 RAISE FND_API.G_EXC_ERROR;
3220 END IF;
3221
3222 -- if operation on any attribute is constrained
3223 IF l_sec_result = OE_PC_GLOBALS.YES THEN
3224 RAISE FND_API.G_EXC_ERROR;
3225 END IF;
3226
3227 END IF; -- security
3228
3229
3230 -- ATTRIBUTE LEVEL VALIDATION
3231
3232 IF NOT (l_line_rec.operation = oe_globals.g_opr_create and
3233 (l_line_rec.split_from_line_id IS NOT NULL AND
3234 l_line_rec.split_from_line_id <> FND_API.G_MISS_NUM))
3235 THEN
3236
3237 IF l_debug_level > 0 THEN
3238 oe_debug_pub.add( 'ATTRIBUTE VALIDATION' , 0.5 ) ; --debug level changed to 0.5 for 13435459
3239 END IF;
3240
3241 IF p_validation_level > FND_API.G_VALID_LEVEL_NONE THEN
3242
3243 OE_Validate_Line.Attributes
3244 ( x_return_status => l_return_status
3245 ,p_x_line_rec => l_line_rec
3246 ,p_old_line_rec => l_old_line_rec
3247 ,p_validation_level => p_validation_level);
3248
3249 IF l_debug_level > 0 THEN
3250 oe_debug_pub.add( 'AFTER ATTRIBUTE VALIDATION' , 0.5 ) ; --debug changed to 0.5 for 13435459
3251 END IF;
3252
3253 IF p_validation_level <> OE_GLOBALS.G_VALID_LEVEL_PARTIAL THEN
3254 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3255 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3256 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3257 RAISE FND_API.G_EXC_ERROR;
3258 END IF;
3259 END IF;
3260
3261 END IF; -- end of check to see if validation level > NONE
3262
3263 END IF; -- validation
3264
3265
3266 -- CLEAR DEPENDENT ATTRIBUTES
3267
3268 IF l_control_rec.clear_dependents AND
3269 NOT (l_line_rec.operation = oe_globals.g_opr_create and
3270 (l_line_rec.split_from_line_id IS NOT NULL AND
3271 l_line_rec.split_from_line_id <> FND_API.G_MISS_NUM))
3272 THEN
3273
3274 IF l_debug_level > 0 THEN
3275 oe_debug_pub.add( 'CLEAR DEPENDENT ATTRIBUTES' , 0.5 ) ; --debug changed to 0.5 for 13435459
3276 END IF;
3277
3278 OE_Line_Util_Ext.Clear_Dependent_Attr
3279 ( p_x_line_rec => l_line_rec
3280 ,p_old_line_rec => l_old_line_rec );
3281
3282 IF l_debug_level > 0 THEN
3283 oe_debug_pub.add( 'AFTER CLEAR DEPENDENT ATTRIBUTES' , 0.5 ) ; --debug changed to 0.5 for 13435459
3284 END IF;
3285
3286
3287 END IF;
3288
3289
3290 -- DEFAULT MISSING ATTRIBUTES
3291
3292 IF (l_control_rec.default_attributes) THEN
3293 IF NOT (l_line_rec.operation = oe_globals.g_opr_create and
3294 (l_line_rec.split_from_line_id IS NOT NULL AND
3295 l_line_rec.split_from_line_id <> FND_API.G_MISS_NUM))
3296 THEN
3297
3298 IF l_debug_level > 0 THEN
3299 oe_debug_pub.add( 'DEFAULT MISSING' , 0.5 ) ; --debug changed to 0.5 for 13435459
3300 END IF;
3301
3302 OE_Default_Line.Attributes
3303 ( p_x_line_rec => l_line_rec
3304 ,p_old_line_rec => l_old_line_rec);
3305
3306 IF l_debug_level > 0 THEN
3307 oe_debug_pub.add( 'AFTER DEFAULT MISSING' , 0.5 ) ; --debug added for 13435459
3308 END IF;
3309
3310
3311 ELSE
3312
3313 IF l_debug_level > 0 THEN
3314 oe_debug_pub.add( 'SPLIT:DEFAULT ATTRIBUTES ' , 0.5 ) ; --debug changed to 0.5 for 13435459
3315 END IF;
3316 OE_Split_Util.Default_Attributes
3317 ( p_x_line_rec => l_line_rec
3318 ,p_old_line_rec => l_old_line_rec);
3319
3320 IF l_debug_level > 0 THEN
3321 oe_debug_pub.add( 'AFTER SPLIT:DEFAULT ATTRIBUTES ' , 0.5 ) ; --debug changed to 0.5 for 13435459
3322 END IF;
3323
3324 END IF;
3325
3326 END IF; -- default missing
3327
3328
3329 -- APPLY ATTRIBUTE CHANGES
3330
3331 IF (l_control_rec.change_attributes)
3332 -- AND NOT (l_line_rec.operation = oe_globals.g_opr_create and
3333 -- (l_line_rec.split_from_line_id IS NOT NULL AND
3334 -- l_line_rec.split_from_line_id <> FND_API.G_MISS_NUM))
3335 THEN
3336
3337 IF l_debug_level > 0 THEN
3338 oe_debug_pub.add( 'APPLY ATTRIBUTE CHANGES' , 0.5 ) ; --debug level changed to 0.5 for 13435459
3339 END IF;
3340
3341 OE_Line_Util.Apply_Attribute_Changes
3342 ( p_x_line_rec => l_line_rec
3343 ,p_old_line_rec => l_old_line_rec );
3344
3345 IF l_debug_level > 0 THEN
3346 oe_debug_pub.add( 'AFTER APPLY ATTRIBUTE CHANGES' , 0.5 ) ; --debug added for 13435459
3347 END IF;
3348
3349
3350 IF l_line_rec.return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3351 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3352 ELSIF l_line_rec.return_status = FND_API.G_RET_STS_ERROR THEN
3353 RAISE FND_API.G_EXC_ERROR;
3354 END IF;
3355 END IF;
3356
3357
3358 -- Entity level validation.
3359
3360 IF l_control_rec.validate_entity
3361 AND NOT (l_line_rec.operation = oe_globals.g_opr_create and
3362 (l_line_rec.split_from_line_id IS NOT NULL AND
3363 l_line_rec.split_from_line_id <> FND_API.G_MISS_NUM))
3364 and( nvl(l_line_rec.ordered_quantity,-1)<>0
3365 OR Nvl(l_line_rec.cancelled_flag,'N')='N' ) -- added for bug 6494347
3366 /*Added the cancelled flag check for bug 7691604*/
3367
3368 /*Added nvl condition in the above check for ordered_quantity for bug 7475111.
3369 If there is no nvl, if the ordered quantity is null, even then validation will not
3370 be performed on the line. */
3371
3372 THEN
3373
3374 IF l_debug_level > 0 THEN
3375 oe_debug_pub.add( 'VALIDATE ENTITY' ,0.5 ) ; ---debug level changed to 0.5 for 13435459
3376 END IF;
3377
3378 IF l_line_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
3379
3380 OE_Validate_Line.Entity_Delete
3381 ( x_return_status => l_return_status
3382 ,p_line_rec => l_line_rec );
3383
3384 ELSE
3385
3386 OE_Validate_Line.Entity
3387 ( x_return_status => l_return_status
3388 ,p_line_rec => l_line_rec
3389 ,p_old_line_rec => l_old_line_rec
3390 ,p_validation_level => p_validation_level);
3391
3392 END IF;
3393 IF l_debug_level > 0 THEN
3394 oe_debug_pub.add( 'AFTER VALIDATE ENTITY' ,0.5 ) ; ---debug level changed to 0.5 for 13435459
3395 END IF;
3396
3397 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3398 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3399 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3400 RAISE FND_API.G_EXC_ERROR;
3401 END IF;
3402
3403 END IF; -- entity validation
3404
3405
3406 -- Fixed bug 1647143: Entity security check should be before
3407 -- pre_write_process. This is important for DELETEs as the
3408 -- constraints check should fire before other events like
3409 -- unscheduling are fired in pre_write_process
3410
3411 -- Check entity level security as some attributes may have
3412 -- changed due to defaulting or scheduling
3413 -- For UPDATE operations, entity security checks for constraints setup
3414 -- with a NULL column i.e. the constraint restricts update on ANY of
3415 -- the columns.
3416 -- However, this check should NOT be done if user did not try to update
3417 -- any of the constrainable attributes and also none of the defaulted
3418 -- attributes was constrainable!. In such a case, the g_check_all_cols
3419 -- _constraint flag would still be 'Y' as the flag is reset only
3420 -- when checking for constraints.
3421
3422 IF NOT (l_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
3423 OE_Line_Security.g_check_all_cols_constraint = 'Y') AND
3424 l_control_rec.check_security THEN
3425
3426 IF l_debug_level > 0 THEN
3427 oe_debug_pub.add( 'CHECK ENTITY SECURITY' , 0.5 ) ; --13435459
3428 END IF;
3429
3430 OE_Line_Security.Entity
3431 ( p_line_rec => l_line_rec
3432 ,x_result => l_sec_result
3433 ,x_return_status => l_return_status );
3434
3435 IF l_debug_level > 0 THEN
3436 oe_debug_pub.add( 'AFTER CHECK ENTITY SECURITY' , 0.5 ) ; --13435459
3437 END IF;
3438
3439
3440 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3441 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3442 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3443 RAISE FND_API.G_EXC_ERROR;
3444 END IF;
3445
3446 -- if operation on any attribute is constrained
3447 IF l_sec_result = OE_PC_GLOBALS.YES THEN
3448 RAISE FND_API.G_EXC_ERROR;
3449 END IF;
3450
3451 END IF;
3452
3453
3454 IF l_debug_level > 0 THEN
3455 oe_debug_pub.add( 'STATUS' || L_LINE_REC.SCHEDULE_STATUS_CODE , 1 ) ;
3456 END IF;
3457
3458 -- Step 3.5. Perform action which need to be performed before
3459 -- writing to the DB (like Scheduling).
3460
3461 IF l_control_rec.write_to_db THEN
3462
3463 OE_LINE_UTIL.PRE_WRITE_PROCESS
3464 ( p_x_line_rec => l_line_rec
3465 , p_old_line_rec => l_old_line_rec);
3466 END IF;
3467
3468 -- Step 4. Write to DB
3469
3470 IF l_control_rec.write_to_db THEN
3471 IF l_debug_level > 0 THEN
3472 oe_debug_pub.add( 'WRITE TO DB' , 0.5 ) ; -- for bug 13435459
3473 END IF;
3474
3475 IF l_line_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
3476 OE_Line_Util.Delete_Row
3477 ( p_line_id => l_line_rec.line_id);
3478
3479 -- If an OTA line has been deleted, then call the OTA API
3480 -- to delete the event in the OTA tables
3481
3482 l_order_quantity_uom := l_line_rec.order_quantity_uom;
3483 l_is_ota_line := OE_OTA_UTIL.Is_OTA_Line(l_order_quantity_uom);
3484
3485 If (l_is_ota_line) THEN
3486 IF l_debug_level > 0 THEN
3487 oe_debug_pub.add( 'LINE IS OF OTA TYPE' , 0.5 ) ; --debug level changed to 0.5 for 13435459
3488 END IF;
3489 OE_OTA_UTIL.Notify_OTA
3490 ( p_line_id => l_line_rec.line_id
3491 ,p_org_id => l_line_rec.org_id
3492 ,p_order_quantity_uom => l_order_quantity_uom
3493 ,p_daemon_type => 'D'
3494 ,x_return_status => l_return_status );
3495
3496 IF l_debug_level > 0 THEN
3497 oe_debug_pub.add( 'AFTER NOTIFY_OTA API' , 0.5 ) ; --debug level changed to 13435459
3498 END IF;
3499 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3500 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3501 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
3502 RAISE FND_API.G_EXC_ERROR;
3503 END IF;
3504 END IF; --End of OTA processing
3505
3506 ELSE -- operation is update or create
3507
3508 -- Get Who Information
3509
3510 l_line_rec.last_update_date := SYSDATE;
3511 l_line_rec.last_updated_by := NVL(OE_STANDARD_WF.g_user_id, FND_GLOBAL.USER_ID); -- 3169637
3512 l_line_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
3513 l_user_id := NVL(OE_STANDARD_WF.g_user_id, FND_GLOBAL.USER_ID); -- 3169637
3514 l_resp_id := FND_GLOBAL.RESP_ID;
3515 l_application_id := FND_GLOBAL.RESP_APPL_ID;
3516
3517 IF l_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
3518 IF l_debug_level > 0 THEN
3519 oe_debug_pub.add( 'CALLING UPDATE ROW' , 0.5 ) ; --debug changed to 0.5 for 13435459
3520 END IF;
3521
3522 OE_Line_Util.Update_Row (l_line_rec);
3523 IF l_debug_level > 0 THEN
3524 oe_debug_pub.add( 'AFTER CALLING UPDATE ROW' , 0.5 ) ; --debug changed to 0.5 for 13435459
3525 END IF;
3526
3527
3528 ELSIF l_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
3529
3530 l_line_rec.creation_date := SYSDATE;
3531 l_line_rec.created_by := NVL(OE_STANDARD_WF.g_user_id, FND_GLOBAL.USER_ID); -- 3169637
3532
3533 IF l_debug_level > 0 THEN
3534 oe_debug_pub.add( '3.STATUS '||L_LINE_REC.SCHEDULE_STATUS_CODE , 1 ) ;
3535 END IF;
3536
3537 IF l_debug_level > 0 THEN
3538 oe_debug_pub.add( 'CALLING INSERT ROW' , 0.5 ) ; --debug added for 13435459
3539 END IF;
3540
3541 OE_Line_Util.Insert_Row (l_line_rec);
3542 IF l_debug_level > 0 THEN
3543 oe_debug_pub.add( 'AFTER CALLING INSERT ROW' , 0.5 ) ; --debug added for 13435459
3544 END IF;
3545
3546 END IF;
3547
3548 END IF; -- operation = delete
3549
3550 -- Post Db Processes
3551 Oe_Line_Util.Post_Write_Process
3552 (p_x_line_rec => l_line_rec,
3553 p_old_line_rec => l_old_line_rec );
3554
3555 END IF; -- write to db true
3556
3557 -- loop exception handler.
3558 IF l_line_rec.return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3559 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3560 ELSIF l_line_rec.return_status = FND_API.G_RET_STS_ERROR THEN
3561 RAISE FND_API.G_EXC_ERROR;
3562 END IF;
3563
3564 -- Load tables.
3565
3566 l_line_rec.return_status := FND_API.G_RET_STS_SUCCESS;
3567 p_x_line_tbl(I) := l_line_rec;
3568 p_x_old_line_tbl(I) := l_old_line_rec;
3569 p_x_line_tbl(I).semi_processed_flag := l_process_this_line;
3570
3571 IF p_x_line_tbl(I).semi_processed_flag THEN
3572 IF l_debug_level > 0 THEN
3573 oe_debug_pub.add( I || ' SEMI PROCESSED FLAG SET ' , 1 ) ;
3574 END IF;
3575 END IF;
3576
3577 IF l_debug_level > 0 THEN
3578 oe_debug_pub.add( 'BOTTOM OF LINE LOOP' , 2 ) ;
3579 END IF;
3580
3581 OE_Line_Security.g_check_all_cols_constraint := 'Y';
3582 OE_MSG_PUB.reset_msg_context('LINE');
3583
3584 IF l_debug_level > 0 THEN
3585 oe_debug_pub.add( 'SCH ARRIVAL_DATE='||L_LINE_REC.SCHEDULE_ARRIVAL_DATE ) ;
3586 END IF;
3587
3588 EXCEPTION
3589
3590 WHEN FND_API.G_EXC_ERROR THEN
3591
3592 x_return_status:= FND_API.G_RET_STS_ERROR;
3593 l_line_rec.return_status := FND_API.G_RET_STS_ERROR;
3594 p_x_line_tbl(I) := l_line_rec;
3595 p_x_line_tbl(I).semi_processed_flag := l_process_this_line;
3596 p_x_old_line_tbl(I) := l_old_line_rec;
3597
3598 OE_Line_Security.g_check_all_cols_constraint := 'Y';
3599
3600 -- if process partial flag is set to true this would
3601 -- continue processing else exit out of loop
3602
3603 IF l_control_rec.Process_Partial THEN
3604
3605 /* Starting the Fix for Bug 13348738*/
3606 ROLLBACK TO SAVEPOINT Lines;
3607 /* Ending the Fix for Bug 13348738*/
3608
3609 -- Raise error when one of the lines in a SET fails
3610 -- while copying.
3611 IF l_line_rec.source_document_type_id = 2 AND
3612 l_line_rec.line_set_id IS NOT NULL AND
3613 l_line_rec.OPERATION = OE_GLOBALS.G_OPR_CREATE
3614 /* Starting the Fix for Bug 13348738*/
3615 AND l_line_rec.blanket_number IS NOT NULL
3616 /* Ending the Fix for Bug 13348738*/
3617 THEN
3618 RAISE FND_API.G_EXC_ERROR;
3619 END IF;
3620
3621
3622 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
3623 IF l_debug_level > 0 THEN
3624 oe_debug_pub.add( 'DELETE REQUEST8' , 2 ) ;
3625 END IF;
3626
3627 oe_delayed_requests_pvt.Delete_Reqs_for_Deleted_Entity
3628 (p_entity_code => OE_GLOBALS.G_ENTITY_LINE,
3629 p_entity_id => l_line_rec.line_id,
3630 x_return_status => l_return_status);
3631 END IF;
3632
3633
3634 --ROLLBACK TO SAVEPOINT Lines; commented as part of fix for Bug 13348738
3635
3636 ELSE
3637 RAISE FND_API.G_EXC_ERROR ;
3638 END IF; -- process partial = true
3639
3640
3641 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3642
3643 x_return_status:= FND_API.G_RET_STS_UNEXP_ERROR;
3644 l_line_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3645 p_x_line_tbl(I) := l_line_rec;
3646 p_x_line_tbl(I).semi_processed_flag := l_process_this_line;
3647 p_x_old_line_tbl(I) := l_old_line_rec;
3648
3649
3650 OE_MSG_PUB.reset_msg_context('LINE');
3651 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3652
3653
3654 WHEN OTHERS THEN
3655
3656 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3657 l_line_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3658 p_x_line_tbl(I) := l_line_rec;
3659 p_x_line_tbl(I).semi_processed_flag := l_process_this_line;
3660 p_x_old_line_tbl(I) := l_old_line_rec;
3661
3662
3663 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3664 THEN
3665 OE_MSG_PUB.Add_Exc_Msg
3666 ( G_PKG_NAME
3667 ,'Lines' );
3668 END IF;
3669
3670 OE_Line_Security.g_check_all_cols_constraint := 'Y';
3671 OE_MSG_PUB.reset_msg_context('LINE');
3672 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3673
3674 END; -- of the big BEGIN with the WHILE
3675
3676
3677
3678 ---------------- switch modes ---------------------------
3679
3680 <<end_of_lines_loop>>
3681
3682 IF l_debug_level > 0 THEN
3683 oe_debug_pub.add( 'NO. OF LINES TO PROCESS ' || L_NUM_LINES , 1 ) ;
3684 END IF;
3685
3686 I := p_x_line_tbl.NEXT(I);
3687
3688 IF (l_mode = 'MODELS_AND_STANDARD') AND (I IS NULL)
3689 THEN
3690 I := p_x_line_tbl.FIRST;
3691 l_mode := 'OPTIONS';
3692 COMPLETE_AND_CLASS_SAVE_MODE := TRUE;
3693
3694 ELSIF (l_mode = 'OPTIONS')AND (I IS NULL)
3695 THEN
3696
3697 I := p_x_line_tbl.FIRST;
3698
3699 IF l_debug_level > 0 THEN
3700 oe_debug_pub.add( 'NO. OF SKIPPED OPTIONS ' || L_OPTIONS_INDEX_TBL.COUNT , 1 ) ;
3701 END IF;
3702
3703 IF COMPLETE_AND_CLASS_SAVE_MODE AND l_num_lines > 0 THEN
3704
3705 IF l_debug_level > 0 THEN
3706 oe_debug_pub.add( 'COMPLETE MODE WAS TRUE' , 3 ) ;
3707 END IF;
3708 COMPLETE_AND_CLASS_SAVE_MODE := FALSE;
3709
3710 IF OE_Config_Util.G_Config_UI_Used = 'N' AND
3711 l_options_index_tbl.COUNT > 0
3712 THEN
3713
3714 Get_Missing_Class_Lines
3715 ( p_x_line_tbl => p_x_line_tbl
3716 ,p_options_index_tbl => l_options_index_tbl
3717 ,x_class_index => l_class_index
3718 ,x_class_count => l_class_count);
3719
3720 l_options_index_tbl.DELETE;
3721
3722 IF l_class_index is NOT NULL THEN
3723 IF l_debug_level > 0 THEN
3724 oe_debug_pub.add( 'NEW CLASSES ADDED' , 3 ) ;
3725 END IF;
3726
3727 COMPLETE_AND_CLASS_SAVE_MODE := TRUE;
3728
3729 l_num_lines := l_num_lines + l_class_count;
3730 I := l_class_index;
3731 END IF;
3732
3733 END IF;
3734 ELSE
3735 IF l_debug_level > 0 THEN
3736 oe_debug_pub.add( 'MODE IS SERVICE NOW' , 3 ) ;
3737 END IF;
3738 l_mode := 'SERVICE';
3739 END IF;
3740
3741 END IF; -- end mode switch
3742
3743 END LOOP; -- end of the big WHILE LOOP
3744
3745
3746 -- New event has been created to handle post line loop issues.
3747
3748 OE_LINE_UTIL.Post_Line_Process
3749 (p_control_rec => l_control_rec,
3750 p_x_line_tbl => p_x_line_tbl);
3751
3752
3753 Print_Time('Exiting OE_ORDER_PVT.LINES');
3754
3755 IF l_debug_level > 0 THEN
3756 oe_debug_pub.add('Exiting OE_ORDER_PVT.LINES ',0.5); --added for bug 13435459
3757 END IF;
3758
3759
3760 OE_MSG_PUB.reset_msg_context('LINE');
3761
3762 set_recursion_mode(p_Entity_Code => 5,
3763 p_In_out => 0);
3764
3765 EXCEPTION
3766
3767 WHEN FND_API.G_EXC_ERROR THEN
3768 OE_SET_UTIL.G_SET_TBL.delete; --bug#2428456
3769 OE_SET_UTIL.G_SET_OPT_TBL.delete; -- bug#2428456
3770 x_return_status := FND_API.G_RET_STS_ERROR;
3771 set_recursion_mode(p_Entity_Code => 5,
3772 p_In_out => 0);
3773 OE_MSG_PUB.reset_msg_context('LINE');
3774
3775
3776 IF NOT (OE_GLOBALS.G_UI_FLAG) AND line_ctr = 1 THEN
3777 IF l_debug_level > 0 THEN
3778 oe_debug_pub.add( 'DELETE REQUEST9' , 2 ) ;
3779 END IF;
3780 oe_delayed_requests_pvt.Clear_Request
3781 (x_return_status => l_return_status);
3782
3783 IF OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.COUNT > 0 THEN -- for the bug 3726337
3784 OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.DELETE;
3785 END IF;
3786 ROLLBACK TO SAVEPOINT Lines_Non_Partial;
3787 -- Bug 2801876
3788 -- This condition would be true only when the process order
3789 -- is called with proecs partial flag and the error comes out
3790 -- of the post line process. This is same as an error coming
3791 -- out of delayed requests and hence we should raise and not continue.
3792
3793 IF l_control_rec.Process_Partial THEN
3794 RAISE FND_API.G_EXC_ERROR;
3795 END IF;
3796
3797 END IF;
3798
3799 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3800 OE_SET_UTIL.G_SET_TBL.delete; --bug#2428456
3801 OE_SET_UTIL.G_SET_OPT_TBL.delete; -- bug#2428456
3802 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3803 set_recursion_mode(p_Entity_Code => 5,
3804 p_In_out => 0);
3805
3806 OE_MSG_PUB.reset_msg_context('LINE');
3807
3808 IF NOT (OE_GLOBALS.G_UI_FLAG) and line_ctr = 1 THEN
3809 IF l_debug_level > 0 THEN
3810 oe_debug_pub.add( 'DELETE REQUEST10' , 2 ) ;
3811 END IF;
3812 oe_delayed_requests_pvt.Clear_Request
3813 (x_return_status => l_return_status);
3814
3815 IF OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.COUNT > 0 THEN -- for the bug 3726337
3816 OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.DELETE;
3817 END IF;
3818 ROLLBACK TO SAVEPOINT Lines_Non_Partial;
3819
3820 -- Same as comments give above for exc error
3821 -- Bug 2801876
3822
3823 IF l_control_rec.Process_Partial THEN
3824 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3825 END IF;
3826
3827 END IF;
3828
3829 WHEN OTHERS THEN
3830 OE_SET_UTIL.G_SET_TBL.delete; --bug#2428456
3831 OE_SET_UTIL.G_SET_OPT_TBL.delete; -- bug#2428456
3832 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3833
3834 IF NOT (OE_GLOBALS.G_UI_FLAG) and line_ctr = 1 THEN
3835 IF l_debug_level > 0 THEN
3836 oe_debug_pub.add( 'DELETE REQUEST11' , 2 ) ;
3837 END IF;
3838 oe_delayed_requests_pvt.Clear_Request
3839 (x_return_status => l_return_status);
3840
3841 IF OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.COUNT > 0 THEN -- for the bug 3726337
3842 OE_Config_Pvt.OE_MODIFY_INC_ITEMS_TBL.DELETE;
3843 END IF;
3844 ROLLBACK TO SAVEPOINT Lines_Non_Partial;
3845 END IF;
3846 set_recursion_mode(p_Entity_Code => 5,
3847 p_In_out => 0);
3848
3849 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3850 THEN
3851 OE_MSG_PUB.Add_Exc_Msg
3852 ( G_PKG_NAME
3853 ,'Lines');
3854 END IF;
3855
3856 OE_MSG_PUB.reset_msg_context('LINE');
3857 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3858
3859 END Lines;
3860
3861
3862 /*----------------------------------------------------------------------
3863 PROCEDURE Line_Scredits
3864 -----------------------------------------------------------------------*/
3865
3866 PROCEDURE Line_Scredits
3867 ( p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
3868 , p_validation_level IN NUMBER
3869 , p_control_rec IN OE_GLOBALS.Control_Rec_Type
3870 , p_x_Line_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Line_Scredit_Tbl_Type
3871 , p_x_old_Line_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Line_Scredit_Tbl_Type
3872 , x_return_status OUT NOCOPY VARCHAR2
3873
3874 )
3875 IS
3876 l_return_status VARCHAR2(1);
3877 l_control_rec OE_GLOBALS.Control_Rec_Type;
3878 l_Line_Scredit_rec OE_Order_PUB.Line_Scredit_Rec_Type;
3879 l_old_Line_Scredit_rec OE_Order_PUB.Line_Scredit_Rec_Type;
3880 -- local variables to store OUT parameters from security check procedures
3881 l_sec_result NUMBER;
3882 l_on_operation_action NUMBER;
3883 I NUMBER; -- Used as index.
3884 l_order_source_id NUMBER;
3885 l_orig_sys_document_ref VARCHAR2(50);
3886 l_orig_sys_line_ref VARCHAR2(50);
3887 l_orig_sys_shipment_ref VARCHAR2(50);
3888 l_change_sequence VARCHAR2(50);
3889 l_source_document_type_id NUMBER;
3890 l_source_document_id NUMBER;
3891 l_source_document_line_id NUMBER;
3892
3893 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3894 l_org_id number ;
3895 BEGIN
3896 --MOAC changes start
3897 l_org_id := MO_GLOBAL.get_current_org_id;
3898 IF (l_org_id IS NULL OR l_org_id = FND_API.G_MISS_NUM) THEN
3899 FND_MESSAGE.set_name('FND','MO_ORG_REQUIRED');
3900 OE_MSG_PUB.Add;
3901 RAISE FND_API.G_EXC_ERROR;
3902 END IF;
3903 --MOAC changes end
3904 set_recursion_mode(p_Entity_Code => 7,
3905 p_In_out => 1);
3906 x_return_status := FND_API.G_RET_STS_SUCCESS;
3907
3908 -- Initialize message list.
3909
3910 IF FND_API.to_Boolean(p_init_msg_list) THEN
3911 OE_MSG_PUB.initialize;
3912 END IF;
3913
3914 IF p_control_rec.Process_Partial THEN
3915 SAVEPOINT Line_Scredits;
3916 END IF;
3917
3918 IF l_debug_level > 0 THEN
3919 oe_debug_pub.add( 'ENTERING OE_ORDER_PVT.LINE_SCREDITS' , 1 ) ;
3920 END IF;
3921
3922 -- FOR I IN 1..p_x_Line_Scredit_tbl.COUNT LOOP
3923
3924 I := p_x_Line_Scredit_tbl.FIRST;
3925 WHILE I IS NOT NULL LOOP
3926 BEGIN
3927
3928 -- Load local records.
3929
3930 l_Line_Scredit_rec := p_x_Line_Scredit_tbl(I);
3931
3932 IF p_x_old_Line_Scredit_tbl.EXISTS(I) THEN
3933 l_old_Line_Scredit_rec := p_x_old_Line_Scredit_tbl(I);
3934 ELSE
3935 l_old_Line_Scredit_rec := OE_Order_PUB.G_MISS_LINE_SCREDIT_REC;
3936 END IF;
3937 if l_old_line_Scredit_rec.sales_credit_id = FND_API.G_MISS_NUM Then
3938 IF l_line_Scredit_rec.line_id IS NOT NULL AND
3939 l_line_Scredit_rec.line_id <> FND_API.G_MISS_NUM THEN
3940 BEGIN
3941 IF l_debug_level > 0 THEN
3942 oe_debug_pub.add('Getting reference data for line_id:'||l_line_Scredit_rec.line_id);
3943 END IF;
3944 SELECT order_source_id, orig_sys_document_ref, change_sequence,
3945 source_document_type_id, source_document_id, orig_sys_line_ref,
3946 source_document_line_id, orig_sys_shipment_ref
3947 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
3948 l_source_document_type_id, l_source_document_id, l_orig_sys_line_ref,
3949 l_source_document_line_id, l_orig_sys_shipment_ref
3950 FROM OE_ORDER_LINES_ALL
3951 WHERE line_id = l_line_Scredit_rec.line_id;
3952 EXCEPTION
3953 WHEN NO_DATA_FOUND THEN
3954 l_order_source_id := null;
3955 l_orig_sys_document_ref := null;
3956 l_change_sequence := null;
3957 l_source_document_type_id := null;
3958 l_source_document_id := null;
3959 l_orig_sys_line_ref := null;
3960 l_source_document_line_id := null;
3961 l_orig_sys_shipment_ref := null;
3962 WHEN OTHERS THEN
3963 l_order_source_id := null;
3964 l_orig_sys_document_ref := null;
3965 l_change_sequence := null;
3966 l_source_document_type_id := null;
3967 l_source_document_id := null;
3968 l_orig_sys_line_ref := null;
3969 l_source_document_line_id := null;
3970 l_orig_sys_shipment_ref := null;
3971 END;
3972 END IF;
3973
3974 OE_MSG_PUB.set_msg_context(
3975 p_entity_code => 'LINE_SCREDIT'
3976 ,p_entity_id => l_line_Scredit_rec.sales_credit_id
3977 ,p_header_id => l_line_Scredit_rec.header_id
3978 ,p_line_id => l_line_Scredit_rec.line_id
3979 ,p_order_source_id => l_order_source_id
3980 ,p_orig_sys_document_ref => l_orig_sys_document_ref
3981 ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
3982 ,p_orig_sys_shipment_ref => l_orig_sys_shipment_ref
3983 ,p_change_sequence => l_change_sequence
3984 ,p_source_document_type_id => l_source_document_type_id
3985 ,p_source_document_id => l_source_document_id
3986 ,p_source_document_line_id => l_source_document_line_id );
3987
3988 else
3989 IF l_old_line_Scredit_rec.line_id IS NOT NULL AND
3990 l_old_line_Scredit_rec.line_id <> FND_API.G_MISS_NUM THEN
3991 BEGIN
3992 IF l_debug_level > 0 THEN
3993 oe_debug_pub.add('Getting reference data for old line_id:'||l_old_line_Scredit_rec.line_id);
3994 END IF;
3995 SELECT order_source_id, orig_sys_document_ref, change_sequence,
3996 source_document_type_id, source_document_id, orig_sys_line_ref,
3997 source_document_line_id, orig_sys_shipment_ref
3998 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
3999 l_source_document_type_id, l_source_document_id, l_orig_sys_line_ref,
4000 l_source_document_line_id, l_orig_sys_shipment_ref
4001 FROM OE_ORDER_LINES_ALL
4002 WHERE line_id = l_old_line_Scredit_rec.line_id;
4003 EXCEPTION
4004 WHEN NO_DATA_FOUND THEN
4005 l_order_source_id := null;
4006 l_orig_sys_document_ref := null;
4007 l_change_sequence := null;
4008 l_source_document_type_id := null;
4009 l_source_document_id := null;
4010 l_orig_sys_line_ref := null;
4011 l_source_document_line_id := null;
4012 l_orig_sys_shipment_ref := null;
4013 WHEN OTHERS THEN
4014 l_order_source_id := null;
4015 l_orig_sys_document_ref := null;
4016 l_change_sequence := null;
4017 l_source_document_type_id := null;
4018 l_source_document_id := null;
4019 l_orig_sys_line_ref := null;
4020 l_source_document_line_id := null;
4021 l_orig_sys_shipment_ref := null;
4022 END;
4023 END IF;
4024
4025 OE_MSG_PUB.set_msg_context(
4026 p_entity_code => 'LINE_SCREDIT'
4027 ,p_entity_id => l_old_line_Scredit_rec.sales_credit_id
4028 ,p_header_id => l_old_line_Scredit_rec.header_id
4029 ,p_line_id => l_old_line_Scredit_rec.line_id
4030 ,p_order_source_id => l_order_source_id
4031 ,p_orig_sys_document_ref => l_orig_sys_document_ref
4032 ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
4033 ,p_orig_sys_shipment_ref => l_orig_sys_shipment_ref
4034 ,p_change_sequence => l_change_sequence
4035 ,p_source_document_type_id => l_source_document_type_id
4036 ,p_source_document_id => l_source_document_id
4037 ,p_source_document_line_id => l_source_document_line_id );
4038
4039 end if;
4040
4041
4042 -- Load API control record
4043
4044 l_control_rec := OE_GLOBALS.Init_Control_Rec
4045 ( p_operation => l_Line_Scredit_rec.operation
4046 , p_control_rec => p_control_rec
4047 );
4048
4049 -- Set record return status.
4050
4051 l_Line_Scredit_rec.return_status := FND_API.G_RET_STS_SUCCESS;
4052
4053 -- Prepare record.
4054
4055 IF l_Line_Scredit_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
4056
4057 l_Line_Scredit_rec.db_flag := FND_API.G_FALSE;
4058
4059 -- Set missing old record elements to NULL.
4060
4061 OE_Line_Scredit_Util.Convert_Miss_To_Null (l_old_Line_Scredit_rec);
4062
4063 ELSIF l_Line_Scredit_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4064 OR l_Line_Scredit_rec.operation = OE_GLOBALS.G_OPR_DELETE
4065 THEN
4066
4067 l_Line_Scredit_rec.db_flag := FND_API.G_TRUE;
4068
4069 -- Query Old if missing
4070
4071 IF l_old_Line_Scredit_rec.sales_credit_id = FND_API.G_MISS_NUM
4072 THEN
4073
4074 OE_Line_Scredit_Util.Query_Row
4075 ( p_sales_credit_id => l_Line_Scredit_rec.sales_credit_id
4076 , x_line_scredit_rec => l_old_Line_Scredit_rec
4077 );
4078
4079 ELSE
4080
4081 -- Set missing old record elements to NULL.
4082
4083 OE_Line_Scredit_Util.Convert_Miss_To_Null (l_old_Line_Scredit_rec);
4084
4085 END IF;
4086
4087 -- Complete new record from old
4088
4089 OE_Line_Scredit_Util.Complete_Record
4090 ( p_x_Line_Scredit_rec => l_Line_Scredit_rec
4091 , p_old_Line_Scredit_rec => l_old_Line_Scredit_rec
4092 );
4093
4094 OE_MSG_PUB.update_msg_context(
4095 p_entity_code => 'LINE_SCREDIT'
4096 ,p_entity_id => l_line_Scredit_rec.sales_credit_id
4097 ,p_header_id => l_line_Scredit_rec.header_id
4098 ,p_line_id => l_line_Scredit_rec.line_id);
4099
4100 END IF;
4101
4102 IF I = p_x_line_scredit_tbl.FIRST THEN
4103 IF NOT Valid_Upgraded_Order(l_line_scredit_rec.header_id) THEN
4104 RAISE FND_API.G_EXC_ERROR;
4105 END IF;
4106 END IF;
4107
4108 -- Check security
4109 IF l_control_rec.check_security
4110 AND (l_line_scredit_rec.operation = OE_GLOBALS.G_OPR_CREATE
4111 OR l_line_scredit_rec.operation = OE_GLOBALS.G_OPR_UPDATE)
4112 THEN
4113
4114 IF l_debug_level > 0 THEN
4115 oe_debug_pub.add( 'CHECK ATTRIBUTES SECURITY' ) ;
4116 END IF;
4117
4118 OE_Line_Scredit_Security.Attributes
4119 (p_line_scredit_rec => l_line_scredit_rec
4120 , p_old_line_scredit_rec => l_old_line_scredit_rec
4121 , x_result => l_sec_result
4122 , x_return_status => l_return_status
4123 );
4124
4125 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4126 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4127 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4128 RAISE FND_API.G_EXC_ERROR;
4129 END IF;
4130
4131 IF l_sec_result = OE_PC_GLOBALS.YES THEN
4132 RAISE FND_API.G_EXC_ERROR;
4133 END IF;
4134
4135 END IF;
4136
4137 -- Attribute level validation.
4138
4139 IF p_validation_level > FND_API.G_VALID_LEVEL_NONE THEN
4140
4141 OE_Validate_Line_Scredit.Attributes
4142 ( x_return_status => l_return_status
4143 , p_Line_Scredit_rec => l_Line_Scredit_rec
4144 , p_old_Line_Scredit_rec => l_old_Line_Scredit_rec
4145 );
4146
4147 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4148 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4149 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4150 RAISE FND_API.G_EXC_ERROR;
4151 END IF;
4152
4153 END IF;
4154
4155 -- Clear dependent attributes.
4156 IF l_debug_level > 0 THEN
4157 oe_debug_pub.add( ' CLEAR DEPENDENT' || L_LINE_SCREDIT_REC.HEADER_ID ) ;
4158 END IF;
4159
4160 IF l_control_rec.clear_dependents THEN
4161
4162 OE_Line_Scredit_Util.Clear_Dependent_Attr
4163 ( p_x_Line_Scredit_rec => l_Line_Scredit_rec
4164 , p_old_Line_Scredit_rec => l_old_Line_Scredit_rec
4165 );
4166
4167 END IF;
4168
4169 -- Default missing attributes
4170 IF l_debug_level > 0 THEN
4171 oe_debug_pub.add( ' DEFAULTING' || L_LINE_SCREDIT_REC.HEADER_ID ) ;
4172 END IF;
4173
4174 IF l_control_rec.default_attributes
4175 THEN
4176
4177 OE_Default_Line_Scredit.Attributes
4178 ( p_x_Line_Scredit_rec => l_Line_Scredit_rec
4179 , p_old_line_scredit_rec => l_old_line_Scredit_Rec
4180 );
4181
4182 END IF;
4183
4184 -- Apply attribute changes
4185 IF l_debug_level > 0 THEN
4186 oe_debug_pub.add( ' APPLY ATTRIBUTES' || L_LINE_SCREDIT_REC.HEADER_ID ) ;
4187 END IF;
4188
4189 IF l_control_rec.change_attributes
4190 THEN
4191
4192 OE_Line_Scredit_Util.Apply_Attribute_Changes
4193 ( p_x_Line_Scredit_rec => l_Line_Scredit_rec
4194 , p_old_Line_Scredit_rec => l_old_Line_Scredit_rec
4195 );
4196
4197 END IF;
4198
4199 -- Entity level validation.
4200 IF l_debug_level > 0 THEN
4201 oe_debug_pub.add( ' ENTITY VALIDATION ' || L_LINE_SCREDIT_REC.HEADER_ID ) ;
4202 END IF;
4203
4204 IF l_control_rec.validate_entity THEN
4205
4206 IF l_Line_Scredit_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
4207
4208 OE_Validate_Line_Scredit.Entity_Delete
4209 ( x_return_status => l_return_status
4210 , p_Line_Scredit_rec => l_Line_Scredit_rec
4211 );
4212
4213 ELSE
4214
4215 OE_Validate_Line_Scredit.Entity
4216 ( x_return_status => l_return_status
4217 , p_Line_Scredit_rec => l_Line_Scredit_rec
4218 , p_old_Line_Scredit_rec => l_old_Line_Scredit_rec
4219 );
4220
4221 END IF;
4222
4223 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4224 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4225 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4226 RAISE FND_API.G_EXC_ERROR;
4227 END IF;
4228
4229 END IF;
4230
4231 -- Check entity level security again as some attributes
4232 -- may have changed due to defaulting.
4233 -- For UPDATE operations, entity security checks for constraints setup
4234 -- with a NULL column i.e. the constraint restricts update on ANY of
4235 -- the columns.
4236 -- However, this check should NOT be done if user did not try to update
4237 -- any of the constrainable attributes and also none of the defaulted
4238 -- attributes was constrainable!. In such a case, the g_check_all_cols
4239 -- _constraint flag would still be 'Y' as the flag is reset only
4240 -- when checking for constraints.
4241 /* Bug fix 2020390, Removed the changes added for the bug 1696681 */
4242 IF NOT (l_line_scredit_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4243 AND OE_Line_Scredit_Security.g_check_all_cols_constraint = 'Y')
4244 AND l_control_rec.check_security
4245 THEN
4246
4247 IF l_debug_level > 0 THEN
4248 oe_debug_pub.add( 'CHECK ENTITY SECURITY' ) ;
4249 END IF;
4250
4251 OE_Line_Scredit_Security.Entity
4252 (p_line_scredit_rec => l_line_scredit_rec
4253 , x_result => l_sec_result
4254 , x_return_status => l_return_status
4255 );
4256
4257 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4258 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4259 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4260 RAISE FND_API.G_EXC_ERROR;
4261 END IF;
4262
4263 IF l_sec_result = OE_PC_GLOBALS.YES THEN
4264 RAISE FND_API.G_EXC_ERROR;
4265 END IF;
4266
4267 END IF;
4268
4269 -- Step 4. Write to DB
4270
4271 IF l_control_rec.write_to_db THEN
4272
4273 /* Start Audit Trail */
4274 Oe_line_Scredit_Util.Pre_Write_Process
4275 (p_x_line_scredit_rec => l_line_scredit_rec,
4276 p_old_line_scredit_rec => l_old_line_scredit_rec);
4277 /* End AuditTrail */
4278
4279 IF l_Line_Scredit_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
4280
4281 OE_Line_Scredit_Util.Delete_Row
4282 ( p_sales_credit_id => l_Line_Scredit_rec.sales_credit_id
4283 );
4284
4285 ELSE
4286
4287 -- Get Who Information
4288
4289 l_Line_Scredit_rec.last_update_date := SYSDATE;
4290 l_Line_Scredit_rec.last_updated_by := NVL(OE_STANDARD_WF.g_user_id, FND_GLOBAL.USER_ID); -- 3169637
4291 l_Line_Scredit_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
4292
4293 IF l_Line_Scredit_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
4294
4295 OE_Line_Scredit_Util.Update_Row (l_Line_Scredit_rec);
4296
4297 ELSIF l_Line_Scredit_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
4298
4299 l_Line_Scredit_rec.creation_date := SYSDATE;
4300 l_Line_Scredit_rec.created_by := NVL(OE_STANDARD_WF.g_user_id, FND_GLOBAL.USER_ID); -- 3169637
4301
4302 OE_Line_Scredit_Util.Insert_Row (l_Line_Scredit_rec);
4303
4304 END IF;
4305
4306 END IF;
4307
4308 END IF;
4309
4310 OE_Line_Scredit_Security.g_check_all_cols_constraint := 'Y';
4311 OE_MSG_PUB.reset_msg_context('LINE_SCREDIT');
4312
4313 -- loop exception handler.
4314 IF l_line_scredit_rec.return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4315 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4316 ELSIF l_line_scredit_rec.return_status = FND_API.G_RET_STS_ERROR THEN
4317 RAISE FND_API.G_EXC_ERROR;
4318 END IF;
4319
4320 -- Load tables.
4321
4322 l_Line_Scredit_rec.return_status := FND_API.G_RET_STS_SUCCESS;
4323 p_x_Line_Scredit_tbl(I) := l_Line_Scredit_rec;
4324 p_x_old_Line_Scredit_tbl(I) := l_old_Line_Scredit_rec;
4325
4326
4327 EXCEPTION
4328
4329 WHEN FND_API.G_EXC_ERROR THEN
4330
4331 x_return_status := FND_API.G_RET_STS_ERROR;
4332 l_Line_Scredit_rec.return_status := FND_API.G_RET_STS_ERROR;
4333 p_x_Line_Scredit_tbl(I) := l_Line_Scredit_rec;
4334 p_x_old_Line_Scredit_tbl(I) := l_old_Line_Scredit_rec;
4335
4336 OE_Line_Scredit_Security.g_check_all_cols_constraint := 'Y';
4337 OE_MSG_PUB.reset_msg_context('LINE_SCREDIT');
4338 IF l_control_rec.Process_Partial THEN
4339 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
4340 IF l_debug_level > 0 THEN
4341 oe_debug_pub.add( 'DELETE REQUEST12' , 2 ) ;
4342 END IF;
4343 oe_delayed_requests_pvt.Delete_Reqs_for_Deleted_Entity
4344 (p_entity_code =>OE_GLOBALS.G_ENTITY_LINE_SCREDIT,
4345 p_entity_id => l_line_scredit_rec.sales_credit_id,
4346 x_return_status => l_return_status);
4347 END IF;
4348 ROLLBACK TO SAVEPOINT Line_Scredits;
4349 ELSE
4350 RAISE FND_API.G_EXC_ERROR;
4351 END IF;
4352
4353 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4354
4355 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4356 l_Line_Scredit_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4357 p_x_Line_Scredit_tbl(I) := l_Line_Scredit_rec;
4358 p_x_old_Line_Scredit_tbl(I) := l_old_Line_Scredit_rec;
4359 OE_Line_Scredit_Security.g_check_all_cols_constraint := 'Y';
4360 OE_MSG_PUB.reset_msg_context('LINE_SCREDIT');
4361 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4362
4363 WHEN OTHERS THEN
4364
4365 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4366 l_Line_Scredit_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4367 p_x_Line_Scredit_tbl(I) := l_Line_Scredit_rec;
4368 p_x_old_Line_Scredit_tbl(I) := l_old_Line_Scredit_rec;
4369 OE_Line_Scredit_Security.g_check_all_cols_constraint := 'Y';
4370 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4371 THEN
4372 OE_MSG_PUB.Add_Exc_Msg
4373 ( G_PKG_NAME
4374 , 'Line_Scredits'
4375 );
4376 END IF;
4377
4378 OE_MSG_PUB.reset_msg_context('LINE_SCREDIT');
4379 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4380
4381 END;
4382 I := p_x_Line_Scredit_tbl.NEXT(I);
4383 END LOOP;
4384
4385
4386 IF l_debug_level > 0 THEN
4387 oe_debug_pub.add( 'EXITING OE_ORDER_PVT.LINE_SCREDITS' , 1 ) ;
4388 END IF;
4389 OE_MSG_PUB.reset_msg_context('LINE_SCREDIT');
4390 set_recursion_mode(p_Entity_Code => 7,
4391 p_In_out => 0);
4392 EXCEPTION
4393
4394 WHEN FND_API.G_EXC_ERROR THEN
4395
4396 set_recursion_mode(p_Entity_Code => 7,
4397 p_In_out => 0);
4398 x_return_status := FND_API.G_RET_STS_ERROR;
4399 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
4400 IF l_debug_level > 0 THEN
4401 oe_debug_pub.add( 'DELETE REQUEST13' , 2 ) ;
4402 END IF;
4403 OE_Delayed_Requests_Pvt.Clear_Request
4404 (x_return_status => l_return_status);
4405 END IF;
4406 OE_MSG_PUB.reset_msg_context('LINE_SCREDIT');
4407
4408 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4409
4410 set_recursion_mode(p_Entity_Code => 7,
4411 p_In_out => 0);
4412 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4413 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
4414 IF l_debug_level > 0 THEN
4415 oe_debug_pub.add( 'DELETE REQUEST14' , 2 ) ;
4416 END IF;
4417 OE_Delayed_Requests_Pvt.Clear_Request
4418 (x_return_status => l_return_status);
4419 END IF;
4420 OE_MSG_PUB.reset_msg_context('LINE_SCREDIT');
4421
4422 WHEN OTHERS THEN
4423
4424 set_recursion_mode(p_Entity_Code => 7,
4425 p_In_out => 0);
4426 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4427 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
4428 IF l_debug_level > 0 THEN
4429 oe_debug_pub.add( 'DELETE REQUEST15' , 2 ) ;
4430 END IF;
4431 OE_Delayed_Requests_Pvt.Clear_Request
4432 (x_return_status => l_return_status);
4433 END IF;
4434 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4435 THEN
4436 OE_MSG_PUB.Add_Exc_Msg
4437 ( G_PKG_NAME
4438 , 'Line_Scredits'
4439 );
4440 END IF;
4441 OE_MSG_PUB.reset_msg_context('LINE_SCREDIT');
4442
4443 END Line_Scredits;
4444
4445
4446 /*----------------------------------------------------------------------
4447 PROCEDURE Line_Payments
4448 -----------------------------------------------------------------------*/
4449
4450 PROCEDURE Line_Payments
4451 ( p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
4452 , p_validation_level IN NUMBER
4453 , p_control_rec IN OE_GLOBALS.Control_Rec_Type
4454 , p_x_Line_Payment_tbl IN OUT NOCOPY OE_Order_PUB.Line_Payment_Tbl_Type
4455 , p_x_old_Line_Payment_tbl IN OUT NOCOPY OE_Order_PUB.Line_Payment_Tbl_Type
4456 , x_return_status OUT NOCOPY VARCHAR2
4457
4458 )
4459 IS
4460 l_return_status VARCHAR2(1);
4461 l_control_rec OE_GLOBALS.Control_Rec_Type;
4462 l_Line_Payment_rec OE_Order_PUB.Line_Payment_Rec_Type;
4463 l_old_Line_Payment_rec OE_Order_PUB.Line_Payment_Rec_Type;
4464 -- local variables to store OUT parameters from security check procedures
4465 l_sec_result NUMBER;
4466 l_on_operation_action NUMBER;
4467 I NUMBER; -- Used as index.
4468 l_order_source_id NUMBER;
4469 l_orig_sys_document_ref VARCHAR2(50);
4470 l_orig_sys_line_ref VARCHAR2(50);
4471 l_orig_sys_shipment_ref VARCHAR2(50);
4472 l_change_sequence VARCHAR2(50);
4473 l_source_document_type_id NUMBER;
4474 l_source_document_id NUMBER;
4475 l_source_document_line_id NUMBER;
4476
4477 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
4478 l_org_id number ;
4479 BEGIN
4480 --MOAC changes start
4481 l_org_id := MO_GLOBAL.get_current_org_id;
4482 IF (l_org_id IS NULL OR l_org_id = FND_API.G_MISS_NUM) THEN
4483 FND_MESSAGE.set_name('FND','MO_ORG_REQUIRED');
4484 OE_MSG_PUB.Add;
4485 RAISE FND_API.G_EXC_ERROR;
4486 END IF;
4487 --MOAC changes end
4488 x_return_status := FND_API.G_RET_STS_SUCCESS;
4489
4490 -- Initialize message list.
4491
4492 IF FND_API.to_Boolean(p_init_msg_list) THEN
4493 OE_MSG_PUB.initialize;
4494 END IF;
4495
4496 IF p_control_rec.Process_Partial THEN
4497 SAVEPOINT Line_Payments;
4498 END IF;
4499
4500 IF l_debug_level > 0 THEN
4501 oe_debug_pub.add( 'ENTERING OE_ORDER_PVT.LINE_PAYMENTS' , 1 ) ;
4502 END IF;
4503
4504 -- FOR I IN 1..p_x_Line_Payment_tbl.COUNT LOOP
4505
4506 I := p_x_Line_Payment_tbl.FIRST;
4507 WHILE I IS NOT NULL LOOP
4508 BEGIN
4509
4510 -- Load local records.
4511
4512 l_Line_Payment_rec := p_x_Line_Payment_tbl(I);
4513
4514 IF p_x_old_Line_Payment_tbl.EXISTS(I) THEN
4515 l_old_Line_Payment_rec := p_x_old_Line_Payment_tbl(I);
4516 ELSE
4517 l_old_Line_Payment_rec := OE_Order_PUB.G_MISS_LINE_PAYMENT_REC;
4518 END IF;
4519 if l_old_line_Payment_rec.payment_number = FND_API.G_MISS_NUM Then
4520 IF l_line_Payment_rec.line_id IS NOT NULL AND
4521 l_line_Payment_rec.line_id <> FND_API.G_MISS_NUM THEN
4522 BEGIN
4523 IF l_debug_level > 0 THEN
4524 oe_debug_pub.add('Getting reference data for line_id:'||l_line_Payment_rec.line_id);
4525 END IF;
4526 SELECT order_source_id, orig_sys_document_ref, change_sequence,
4527 source_document_type_id, source_document_id, orig_sys_line_ref,
4528 source_document_line_id, orig_sys_shipment_ref
4529 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
4530 l_source_document_type_id, l_source_document_id, l_orig_sys_line_ref,
4531 l_source_document_line_id, l_orig_sys_shipment_ref
4532 FROM OE_ORDER_LINES_ALL
4533 WHERE line_id = l_line_Payment_rec.line_id;
4534 EXCEPTION
4535 WHEN NO_DATA_FOUND THEN
4536 l_order_source_id := null;
4537 l_orig_sys_document_ref := null;
4538 l_change_sequence := null;
4539 l_source_document_type_id := null;
4540 l_source_document_id := null;
4541 l_orig_sys_line_ref := null;
4542 l_source_document_line_id := null;
4543 l_orig_sys_shipment_ref := null;
4544 WHEN OTHERS THEN
4545 l_order_source_id := null;
4546 l_orig_sys_document_ref := null;
4547 l_change_sequence := null;
4548 l_source_document_type_id := null;
4549 l_source_document_id := null;
4550 l_orig_sys_line_ref := null;
4551 l_source_document_line_id := null;
4552 l_orig_sys_shipment_ref := null;
4553 END;
4554 END IF;
4555
4556 OE_MSG_PUB.set_msg_context(
4557 p_entity_code => 'LINE_PAYMENT'
4558 ,p_entity_id => l_line_Payment_rec.payment_number
4559 ,p_header_id => l_line_Payment_rec.header_id
4560 ,p_line_id => l_line_Payment_rec.line_id
4561 ,p_order_source_id => l_order_source_id
4562 ,p_orig_sys_document_ref => l_orig_sys_document_ref
4563 ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
4564 ,p_orig_sys_shipment_ref => l_orig_sys_shipment_ref
4565 ,p_change_sequence => l_change_sequence
4566 ,p_source_document_type_id => l_source_document_type_id
4567 ,p_source_document_id => l_source_document_id
4568 ,p_source_document_line_id => l_source_document_line_id );
4569
4570 else
4571 IF l_old_line_Payment_rec.line_id IS NOT NULL AND
4572 l_old_line_Payment_rec.line_id <> FND_API.G_MISS_NUM THEN
4573 BEGIN
4574 IF l_debug_level > 0 THEN
4575 oe_debug_pub.add('Getting reference data for old line_id:'||l_old_line_Payment_rec.line_id);
4576 END IF;
4577 SELECT order_source_id, orig_sys_document_ref, change_sequence,
4578 source_document_type_id, source_document_id, orig_sys_line_ref,
4579 source_document_line_id, orig_sys_shipment_ref
4580 INTO l_order_source_id, l_orig_sys_document_ref, l_change_sequence,
4581 l_source_document_type_id, l_source_document_id, l_orig_sys_line_ref,
4582 l_source_document_line_id, l_orig_sys_shipment_ref
4583 FROM OE_ORDER_LINES_ALL
4584 WHERE line_id = l_old_line_Payment_rec.line_id;
4585 EXCEPTION
4586 WHEN NO_DATA_FOUND THEN
4587 l_order_source_id := null;
4588 l_orig_sys_document_ref := null;
4589 l_change_sequence := null;
4590 l_source_document_type_id := null;
4591 l_source_document_id := null;
4592 l_orig_sys_line_ref := null;
4593 l_source_document_line_id := null;
4594 l_orig_sys_shipment_ref := null;
4595 WHEN OTHERS THEN
4596 l_order_source_id := null;
4597 l_orig_sys_document_ref := null;
4598 l_change_sequence := null;
4599 l_source_document_type_id := null;
4600 l_source_document_id := null;
4601 l_orig_sys_line_ref := null;
4602 l_source_document_line_id := null;
4603 l_orig_sys_shipment_ref := null;
4604 END;
4605 END IF;
4606
4607 OE_MSG_PUB.set_msg_context(
4608 p_entity_code => 'LINE_PAYMENT'
4609 ,p_entity_id => l_old_line_Payment_rec.payment_number
4610 ,p_header_id => l_old_line_Payment_rec.header_id
4611 ,p_line_id => l_old_line_Payment_rec.line_id
4612 ,p_order_source_id => l_order_source_id
4613 ,p_orig_sys_document_ref => l_orig_sys_document_ref
4614 ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
4615 ,p_orig_sys_shipment_ref => l_orig_sys_shipment_ref
4616 ,p_change_sequence => l_change_sequence
4617 ,p_source_document_type_id => l_source_document_type_id
4618 ,p_source_document_id => l_source_document_id
4619 ,p_source_document_line_id => l_source_document_line_id );
4620
4621 end if;
4622
4623
4624 -- Load API control record
4625
4626 l_control_rec := OE_GLOBALS.Init_Control_Rec
4627 ( p_operation => l_Line_Payment_rec.operation
4628 , p_control_rec => p_control_rec
4629 );
4630
4631 -- Set record return status.
4632
4633 l_Line_Payment_rec.return_status := FND_API.G_RET_STS_SUCCESS;
4634
4635 -- Prepare record.
4636
4637 IF l_Line_Payment_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
4638
4639 l_Line_Payment_rec.db_flag := FND_API.G_FALSE;
4640
4641 -- Set missing old record elements to NULL.
4642
4643 IF l_debug_level > 0 THEN
4644 oe_debug_pub.add('Payment:before OE_Line_Payment_Util.Convert_Miss_To_Null', 5);
4645 END IF;
4646 OE_Line_Payment_Util.Convert_Miss_To_Null (l_old_Line_Payment_rec);
4647 IF l_debug_level > 0 THEN
4648 oe_debug_pub.add('Payment:after OE_Line_Payment_Util.Convert_Miss_To_Null', 5);
4649 END IF;
4650
4651 ELSIF l_Line_Payment_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4652 OR l_Line_Payment_rec.operation = OE_GLOBALS.G_OPR_DELETE
4653 THEN
4654
4655 l_Line_Payment_rec.db_flag := FND_API.G_TRUE;
4656
4657 -- Query Old if missing
4658
4659 IF l_old_Line_Payment_rec.payment_number = FND_API.G_MISS_NUM
4660 THEN
4661
4662 IF l_debug_level > 0 THEN
4663 oe_debug_pub.add('Payment:before OE_Line_Payment_Util.Query_Row', 5);
4664 END IF;
4665 OE_Line_Payment_Util.Query_Row
4666 ( p_payment_number => l_Line_Payment_rec.payment_number
4667 , p_line_id => l_Line_Payment_rec.line_id
4668 , p_header_id => l_Line_Payment_rec.header_id
4669 , x_line_payment_rec => l_old_Line_Payment_rec
4670 );
4671 IF l_debug_level > 0 THEN
4672 oe_debug_pub.add('Payment:after OE_Line_Payment_Util.Query_Row', 5);
4673 END IF;
4674
4675 ELSE
4676
4677 -- Set missing old record elements to NULL.
4678
4679 OE_Line_Payment_Util.Convert_Miss_To_Null (l_old_Line_Payment_rec);
4680
4681 END IF;
4682
4683 -- Complete new record from old
4684
4685 IF l_debug_level > 0 THEN
4686 oe_debug_pub.add('Payment:before OE_Line_Payment_Util.Complete_Record', 5);
4687 END IF;
4688 OE_Line_Payment_Util.Complete_Record
4689 ( p_x_Line_Payment_rec => l_Line_Payment_rec
4690 , p_old_Line_Payment_rec => l_old_Line_Payment_rec
4691 );
4692 IF l_debug_level > 0 THEN
4693 oe_debug_pub.add('Payment:after OE_Line_Payment_Util.Complete_Record', 5);
4694 END IF;
4695
4696 OE_MSG_PUB.update_msg_context(
4697 p_entity_code => 'LINE_PAYMENT'
4698 ,p_entity_id => l_line_Payment_rec.payment_number
4699 ,p_header_id => l_line_Payment_rec.header_id
4700 ,p_line_id => l_line_Payment_rec.line_id);
4701
4702 END IF;
4703
4704 IF I = p_x_line_payment_tbl.FIRST THEN
4705 IF NOT Valid_Upgraded_Order(l_line_payment_rec.header_id) THEN
4706 RAISE FND_API.G_EXC_ERROR;
4707 END IF;
4708 END IF;
4709
4710 -- Check security
4711 IF l_control_rec.check_security
4712 AND (l_line_payment_rec.operation = OE_GLOBALS.G_OPR_CREATE
4713 OR l_line_payment_rec.operation = OE_GLOBALS.G_OPR_UPDATE)
4714 THEN
4715
4716 IF l_debug_level > 0 THEN
4717 oe_debug_pub.add('Payment:before OE_Line_Payment_Security.Attributes', 5);
4718 END IF;
4719 OE_Line_Payment_Security.Attributes
4720 (p_line_payment_rec => l_line_payment_rec
4721 , p_old_line_payment_rec => l_old_line_payment_rec
4722 , x_result => l_sec_result
4723 , x_return_status => l_return_status
4724 );
4725 IF l_debug_level > 0 THEN
4726 oe_debug_pub.add('Payment:after OE_Line_Payment_Security.Attributes', 5);
4727 END IF;
4728
4729 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4730 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4731 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4732 RAISE FND_API.G_EXC_ERROR;
4733 END IF;
4734
4735 IF l_sec_result = OE_PC_GLOBALS.YES THEN
4736 RAISE FND_API.G_EXC_ERROR;
4737 END IF;
4738
4739 END IF;
4740
4741 -- Attribute level validation.
4742
4743 IF p_validation_level > FND_API.G_VALID_LEVEL_NONE THEN
4744
4745 IF l_debug_level > 0 THEN
4746 oe_debug_pub.add('Payment:before OE_Validate_Line_Payment.Attributes', 5);
4747 END IF;
4748 OE_Validate_Line_Payment.Attributes
4749 ( x_return_status => l_return_status
4750 , p_Line_Payment_rec => l_Line_Payment_rec
4751 , p_old_Line_Payment_rec => l_old_Line_Payment_rec
4752 );
4753 IF l_debug_level > 0 THEN
4754 oe_debug_pub.add('Payment:after OE_Validate_Line_Payment.Attributes', 5);
4755 END IF;
4756
4757 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4758 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4759 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4760 RAISE FND_API.G_EXC_ERROR;
4761 END IF;
4762
4763 END IF;
4764
4765 -- Clear dependent attributes.
4766 IF l_debug_level > 0 THEN
4767 oe_debug_pub.add( ' CLEAR DEPENDENT' || L_LINE_PAYMENT_REC.HEADER_ID ) ;
4768 END IF;
4769
4770 IF l_control_rec.clear_dependents THEN
4771
4772 IF l_debug_level > 0 THEN
4773 oe_debug_pub.add('Payment:before OE_Line_Payment_Util.Clear_Dependent_Attr', 5);
4774 END IF;
4775 OE_Line_Payment_Util.Clear_Dependent_Attr
4776 ( p_x_Line_Payment_rec => l_Line_Payment_rec
4777 , p_old_Line_Payment_rec => l_old_Line_Payment_rec
4778 );
4779 IF l_debug_level > 0 THEN
4780 oe_debug_pub.add('Payment:after OE_Line_Payment_Util.Clear_Dependent_Attr', 5);
4781 END IF;
4782
4783 END IF;
4784
4785 -- Default missing attributes
4786 IF l_debug_level > 0 THEN
4787 oe_debug_pub.add( ' DEFAULTING' || L_LINE_PAYMENT_REC.HEADER_ID ) ;
4788 END IF;
4789
4790 IF l_control_rec.default_attributes
4791 THEN
4792
4793 IF l_debug_level > 0 THEN
4794 oe_debug_pub.add('Payment:before OE_Default_Line_Payment.Attributes', 5);
4795 END IF;
4796 OE_Default_Line_Payment.Attributes
4797 ( p_x_Line_Payment_rec => l_Line_Payment_rec
4798 , p_old_line_payment_rec => l_old_line_Payment_Rec
4799 );
4800 IF l_debug_level > 0 THEN
4801 oe_debug_pub.add('Payment:after OE_Default_Line_Payment.Attributes', 5);
4802 END IF;
4803
4804 END IF;
4805
4806 -- Apply attribute changes
4807 IF l_debug_level > 0 THEN
4808 oe_debug_pub.add( ' APPLY ATTRIBUTES' || L_LINE_PAYMENT_REC.HEADER_ID ) ;
4809 END IF;
4810
4811 IF l_control_rec.change_attributes
4812 THEN
4813
4814 IF l_debug_level > 0 THEN
4815 oe_debug_pub.add('Payment:before OE_Line_Payment_Util.Apply_Attribute_Changes', 5);
4816 END IF;
4817 OE_Line_Payment_Util.Apply_Attribute_Changes
4818 ( p_x_Line_Payment_rec => l_Line_Payment_rec
4819 , p_old_Line_Payment_rec => l_old_Line_Payment_rec
4820 );
4821 IF l_debug_level > 0 THEN
4822 oe_debug_pub.add('Payment:after OE_Line_Payment_Util.Apply_Attribute_Changes', 5);
4823 END IF;
4824
4825 END IF;
4826
4827 -- Entity level validation.
4828 IF l_debug_level > 0 THEN
4829 oe_debug_pub.add( ' ENTITY VALIDATION ' || L_LINE_PAYMENT_REC.HEADER_ID ) ;
4830 END IF;
4831
4832 IF l_control_rec.validate_entity THEN
4833
4834 IF l_Line_Payment_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
4835
4836 IF l_debug_level > 0 THEN
4837 oe_debug_pub.add('Payment:before OE_Validate_Line_Payment.Entity_Delete', 5);
4838 END IF;
4839 OE_Validate_Line_Payment.Entity_Delete
4840 ( x_return_status => l_return_status
4841 , p_Line_Payment_rec => l_Line_Payment_rec
4842 );
4843 IF l_debug_level > 0 THEN
4844 oe_debug_pub.add('Payment:after OE_Validate_Line_Payment.Entity_Delete', 5);
4845 END IF;
4846
4847 ELSE
4848
4849 IF l_debug_level > 0 THEN
4850 oe_debug_pub.add('Payment:before OE_Validate_Line_Payment.Entity', 5);
4851 END IF;
4852 OE_Validate_Line_Payment.Entity
4853 ( x_return_status => l_return_status
4854 , p_Line_Payment_rec => l_Line_Payment_rec
4855 , p_old_Line_Payment_rec => l_old_Line_Payment_rec
4856 );
4857 IF l_debug_level > 0 THEN
4858 oe_debug_pub.add('Payment:after OE_Validate_Line_Payment.Entity', 5);
4859 END IF;
4860
4861 END IF;
4862
4863 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4864 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4865 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4866 RAISE FND_API.G_EXC_ERROR;
4867 END IF;
4868
4869 END IF;
4870
4871 -- Check entity level security again as some attributes
4872 -- may have changed due to defaulting.
4873 -- For UPDATE operations, entity security checks for constraints setup
4874 -- with a NULL column i.e. the constraint restricts update on ANY of
4875 -- the columns.
4876 -- However, this check should NOT be done if user did not try to update
4877 -- any of the constrainable attributes and also none of the defaulted
4878 -- attributes was constrainable!. In such a case, the g_check_all_cols
4879 -- _constraint flag would still be 'Y' as the flag is reset only
4880 -- when checking for constraints.
4881 /* Bug fix 2020390, Removed the changes added for the bug 1696681 */
4882 IF NOT (l_line_payment_rec.operation = OE_GLOBALS.G_OPR_UPDATE
4883 AND OE_Line_Payment_Security.g_check_all_cols_constraint = 'Y')
4884 AND l_control_rec.check_security
4885 THEN
4886
4887 IF l_debug_level > 0 THEN
4888 oe_debug_pub.add('Payment:before OE_Line_Payment_Security.Entity', 5);
4889 END IF;
4890 OE_Line_Payment_Security.Entity
4891 (p_line_payment_rec => l_line_payment_rec
4892 , x_result => l_sec_result
4893 , x_return_status => l_return_status
4894 );
4895 IF l_debug_level > 0 THEN
4896 oe_debug_pub.add('Payment:after OE_Line_Payment_Security.Entity', 5);
4897 END IF;
4898
4899 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4900 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4901 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4902 RAISE FND_API.G_EXC_ERROR;
4903 END IF;
4904
4905 IF l_sec_result = OE_PC_GLOBALS.YES THEN
4906 RAISE FND_API.G_EXC_ERROR;
4907 END IF;
4908
4909 END IF;
4910
4911 -- Step 4. Write to DB
4912
4913 IF l_control_rec.write_to_db THEN
4914
4915 /* Start Audit Trail */
4916 IF l_debug_level > 0 THEN
4917 oe_debug_pub.add('Payment:before Oe_line_Payment_Util.Pre_Write_Process', 5);
4918 END IF;
4919 Oe_line_Payment_Util.Pre_Write_Process
4920 (p_x_line_payment_rec => l_line_payment_rec,
4921 p_old_line_payment_rec => l_old_line_payment_rec);
4922 IF l_debug_level > 0 THEN
4923 oe_debug_pub.add('Payment:after Oe_line_Payment_Util.Pre_Write_Process', 5);
4924 END IF;
4925 /* End AuditTrail */
4926
4927 IF l_Line_Payment_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
4928
4929 IF l_debug_level > 0 THEN
4930 oe_debug_pub.add('Payment:before OE_Line_Payment_Util.Delete_Row', 5);
4931 END IF;
4932 OE_Line_Payment_Util.Delete_Row
4933 ( p_payment_number => l_Line_Payment_rec.payment_number
4934 , p_line_id => l_Line_Payment_rec.line_id
4935 , p_header_id => l_Line_Payment_rec.header_id
4936 );
4937 IF l_debug_level > 0 THEN
4938 oe_debug_pub.add('Payment:after OE_Line_Payment_Util.Delete_Row', 5);
4939 END IF;
4940
4941 ELSE
4942
4943 -- Get Who Information
4944
4945 l_Line_Payment_rec.last_update_date := SYSDATE;
4946 l_Line_Payment_rec.last_updated_by := NVL(OE_STANDARD_WF.g_user_id, FND_GLOBAL.USER_ID); -- 3169637
4947 l_Line_Payment_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
4948
4949 IF l_Line_Payment_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
4950
4951 IF l_debug_level > 0 THEN
4952 oe_debug_pub.add('Payment:before OE_Line_Payment_Util.Update_Row', 5);
4953 END IF;
4954 OE_Line_Payment_Util.Update_Row (l_Line_Payment_rec);
4955 IF l_debug_level > 0 THEN
4956 oe_debug_pub.add('Payment:after OE_Line_Payment_Util.Update_Row', 5);
4957 END IF;
4958
4959 ELSIF l_Line_Payment_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
4960
4961 l_Line_Payment_rec.creation_date := SYSDATE;
4962 l_Line_Payment_rec.created_by := NVL(OE_STANDARD_WF.g_user_id, FND_GLOBAL.USER_ID); -- 3169637
4963
4964 IF l_debug_level > 0 THEN
4965 oe_debug_pub.add('Payment:before OE_Line_Payment_Util.Insert_Row', 5);
4966 END IF;
4967 OE_Line_Payment_Util.Insert_Row (l_Line_Payment_rec);
4968 IF l_debug_level > 0 THEN
4969 oe_debug_pub.add('Payment:after OE_Line_Payment_Util.Insert_Row', 5);
4970 END IF;
4971
4972 END IF;
4973
4974 END IF;
4975
4976 END IF;
4977
4978 OE_Line_Payment_Security.g_check_all_cols_constraint := 'Y';
4979 OE_MSG_PUB.reset_msg_context('LINE_PAYMENT');
4980
4981 -- loop exception handler.
4982 IF l_line_payment_rec.return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4983 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4984 ELSIF l_line_payment_rec.return_status = FND_API.G_RET_STS_ERROR THEN
4985 RAISE FND_API.G_EXC_ERROR;
4986 END IF;
4987
4988 -- Load tables.
4989
4990 l_Line_Payment_rec.return_status := FND_API.G_RET_STS_SUCCESS;
4991 p_x_Line_Payment_tbl(I) := l_Line_Payment_rec;
4992 p_x_old_Line_Payment_tbl(I) := l_old_Line_Payment_rec;
4993
4994
4995 EXCEPTION
4996
4997 WHEN FND_API.G_EXC_ERROR THEN
4998
4999 x_return_status := FND_API.G_RET_STS_ERROR;
5000 l_Line_Payment_rec.return_status := FND_API.G_RET_STS_ERROR;
5001 p_x_Line_Payment_tbl(I) := l_Line_Payment_rec;
5002 p_x_old_Line_Payment_tbl(I) := l_old_Line_Payment_rec;
5003
5004 OE_Line_Payment_Security.g_check_all_cols_constraint := 'Y';
5005 OE_MSG_PUB.reset_msg_context('LINE_PAYMENT');
5006 IF l_control_rec.Process_Partial THEN
5007 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
5008 IF l_debug_level > 0 THEN
5009 oe_debug_pub.add( 'DELETE REQUEST12' , 2 ) ;
5010 END IF;
5011 oe_delayed_requests_pvt.Delete_Reqs_for_Deleted_Entity
5012 (p_entity_code =>OE_GLOBALS.G_ENTITY_LINE_PAYMENT,
5013 p_entity_id => l_line_payment_rec.line_id,
5014 x_return_status => l_return_status);
5015 END IF;
5016 ROLLBACK TO SAVEPOINT Line_Payments;
5017 ELSE
5018 RAISE FND_API.G_EXC_ERROR;
5019 END IF;
5020
5021 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5022
5023 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5024 l_Line_Payment_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5025 p_x_Line_Payment_tbl(I) := l_Line_Payment_rec;
5026 p_x_old_Line_Payment_tbl(I) := l_old_Line_Payment_rec;
5027 OE_Line_Payment_Security.g_check_all_cols_constraint := 'Y';
5028 OE_MSG_PUB.reset_msg_context('LINE_PAYMENT');
5029 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5030
5031 WHEN OTHERS THEN
5032
5033 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5034 l_Line_Payment_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5035 p_x_Line_Payment_tbl(I) := l_Line_Payment_rec;
5036 p_x_old_Line_Payment_tbl(I) := l_old_Line_Payment_rec;
5037 OE_Line_Payment_Security.g_check_all_cols_constraint := 'Y';
5038 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5039 THEN
5040 OE_MSG_PUB.Add_Exc_Msg
5041 ( G_PKG_NAME
5042 , 'Line_Payments'
5043 );
5044 END IF;
5045
5046 OE_MSG_PUB.reset_msg_context('LINE_PAYMENT');
5047 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5048
5049 END;
5050 I := p_x_Line_Payment_tbl.NEXT(I);
5051 END LOOP;
5052
5053
5054 IF l_debug_level > 0 THEN
5055 oe_debug_pub.add( 'EXITING OE_ORDER_PVT.LINE_PAYMENTS' , 1 ) ;
5056 END IF;
5057 OE_MSG_PUB.reset_msg_context('LINE_PAYMENT');
5058 EXCEPTION
5059
5060 WHEN FND_API.G_EXC_ERROR THEN
5061
5062 x_return_status := FND_API.G_RET_STS_ERROR;
5063 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
5064 IF l_debug_level > 0 THEN
5065 oe_debug_pub.add( 'DELETE REQUEST13' , 2 ) ;
5066 END IF;
5067 OE_Delayed_Requests_Pvt.Clear_Request
5068 (x_return_status => l_return_status);
5069 END IF;
5070 OE_MSG_PUB.reset_msg_context('LINE_PAYMENT');
5071
5072 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5073
5074 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5075 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
5076 IF l_debug_level > 0 THEN
5077 oe_debug_pub.add( 'DELETE REQUEST14' , 2 ) ;
5078 END IF;
5079 OE_Delayed_Requests_Pvt.Clear_Request
5080 (x_return_status => l_return_status);
5081 END IF;
5082 OE_MSG_PUB.reset_msg_context('LINE_PAYMENT');
5083
5084 WHEN OTHERS THEN
5085
5086 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5087 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
5088 IF l_debug_level > 0 THEN
5089 oe_debug_pub.add( 'DELETE REQUEST15' , 2 ) ;
5090 END IF;
5091 OE_Delayed_Requests_Pvt.Clear_Request
5092 (x_return_status => l_return_status);
5093 END IF;
5094 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5095 THEN
5096 OE_MSG_PUB.Add_Exc_Msg
5097 ( G_PKG_NAME
5098 , 'Line_Payments'
5099 );
5100 END IF;
5101 OE_MSG_PUB.reset_msg_context('LINE_PAYMENT');
5102
5103 END Line_Payments;
5104
5105
5106 /*-------------------------------------------------------------------
5107 PROCEDURE Lot_Serials
5108 --------------------------------------------------------------------*/
5109
5110 PROCEDURE Lot_Serials
5111 ( p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
5112 , p_validation_level IN NUMBER
5113 , p_control_rec IN OE_GLOBALS.Control_Rec_Type
5114 , p_x_Lot_Serial_tbl IN OUT NOCOPY OE_Order_PUB.Lot_Serial_Tbl_Type
5115 , p_x_old_Lot_Serial_tbl IN OUT NOCOPY OE_Order_PUB.Lot_Serial_Tbl_Type
5116 , x_return_status OUT NOCOPY VARCHAR2
5117
5118 )
5119 IS
5120 l_return_status VARCHAR2(1);
5121 l_control_rec OE_GLOBALS.Control_Rec_Type;
5122 l_Lot_Serial_rec OE_Order_PUB.Lot_Serial_Rec_Type;
5123 l_old_Lot_Serial_rec OE_Order_PUB.Lot_Serial_Rec_Type;
5124 I NUMBER; -- Used as index.
5125 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5126 l_org_id number;
5127 BEGIN
5128 --MOAC changes start
5129 l_org_id := MO_GLOBAL.get_current_org_id;
5130 IF (l_org_id IS NULL OR l_org_id = FND_API.G_MISS_NUM) THEN
5131 FND_MESSAGE.set_name('FND','MO_ORG_REQUIRED');
5132 OE_MSG_PUB.Add;
5133 RAISE FND_API.G_EXC_ERROR;
5134 END IF;
5135 --MOAC changes end
5136 x_return_status := FND_API.G_RET_STS_SUCCESS;
5137
5138 -- Initialize message list.
5139
5140 IF FND_API.to_Boolean(p_init_msg_list) THEN
5141 OE_MSG_PUB.initialize;
5142 END IF;
5143
5144 -- FOR I IN 1..p_x_Lot_Serial_tbl.COUNT LOOP
5145
5146 I := p_x_Lot_Serial_tbl.FIRST;
5147
5148 WHILE I IS NOT NULL LOOP
5149 BEGIN
5150
5151 -- Load local records.
5152
5153 l_Lot_Serial_rec := p_x_Lot_Serial_tbl(I);
5154
5155 IF p_x_old_Lot_Serial_tbl.EXISTS(I) THEN
5156 l_old_Lot_Serial_rec := p_x_old_Lot_Serial_tbl(I);
5157 ELSE
5158 l_old_Lot_Serial_rec := OE_Order_PUB.G_MISS_LOT_SERIAL_REC;
5159 END IF;
5160
5161 -- Load API control record
5162
5163 l_control_rec := OE_GLOBALS.Init_Control_Rec
5164 ( p_operation => l_Lot_Serial_rec.operation
5165 , p_control_rec => p_control_rec
5166 );
5167
5168 -- Set record return status.
5169
5170 l_Lot_Serial_rec.return_status := FND_API.G_RET_STS_SUCCESS;
5171
5172 -- Prepare record.
5173
5174 IF l_Lot_Serial_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
5175
5176 l_Lot_Serial_rec.db_flag := FND_API.G_FALSE;
5177
5178 -- Set missing old record elements to NULL.
5179
5180 OE_Lot_Serial_Util.Convert_Miss_To_Null (l_old_Lot_Serial_rec);
5181
5182 ELSIF l_Lot_Serial_rec.operation = OE_GLOBALS.G_OPR_UPDATE
5183 OR l_Lot_Serial_rec.operation = OE_GLOBALS.G_OPR_DELETE
5184 THEN
5185
5186 l_Lot_Serial_rec.db_flag := FND_API.G_TRUE;
5187
5188 -- Query Old if missing
5189
5190 IF l_old_Lot_Serial_rec.lot_serial_id = FND_API.G_MISS_NUM
5191 THEN
5192
5193 OE_Lot_Serial_Util.Query_Row
5194 ( p_lot_serial_id => l_Lot_Serial_rec.lot_serial_id
5195 , x_Lot_Serial_rec => l_old_Lot_Serial_rec
5196 );
5197
5198 ELSE
5199
5200 -- Set missing old record elements to NULL.
5201
5202 OE_Lot_Serial_Util.Convert_Miss_To_Null (l_old_Lot_Serial_rec);
5203
5204 END IF;
5205
5206 -- Complete new record from old
5207
5208 OE_Lot_Serial_Util.Complete_Record
5209 ( p_x_Lot_Serial_rec => l_Lot_Serial_rec
5210 , p_old_Lot_Serial_rec => l_old_Lot_Serial_rec
5211 );
5212
5213 END IF;
5214
5215 -- Attribute level validation.
5216
5217 IF p_validation_level > FND_API.G_VALID_LEVEL_NONE THEN
5218
5219 OE_Validate_Lot_Serial.Attributes
5220 ( x_return_status => l_return_status
5221 , p_Lot_Serial_rec => l_Lot_Serial_rec
5222 , p_old_Lot_Serial_rec => l_old_Lot_Serial_rec
5223 );
5224
5225 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5226 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5227 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5228 RAISE FND_API.G_EXC_ERROR;
5229 END IF;
5230
5231 END IF;
5232
5233 -- Clear dependent attributes.
5234
5235 IF l_control_rec.clear_dependents THEN
5236
5237 OE_Lot_Serial_Util.Clear_Dependent_Attr
5238 ( p_x_Lot_Serial_rec => l_Lot_Serial_rec
5239 , p_old_Lot_Serial_rec => l_old_Lot_Serial_rec
5240 );
5241
5242 END IF;
5243
5244 -- Default missing attributes
5245
5246 IF l_control_rec.default_attributes
5247 THEN
5248
5249 OE_Default_Lot_Serial.Attributes
5250 ( p_x_Lot_Serial_rec => l_Lot_Serial_rec
5251 );
5252
5253 END IF;
5254
5255 -- Apply attribute changes
5256
5257 IF l_control_rec.change_attributes
5258 THEN
5259
5260 OE_Lot_Serial_Util.Apply_Attribute_Changes
5261 ( p_x_Lot_Serial_rec => l_Lot_Serial_rec
5262 , p_old_Lot_Serial_rec => l_old_Lot_Serial_rec
5263 );
5264
5265 END IF;
5266
5267 -- Entity level validation.
5268
5269 IF l_control_rec.validate_entity THEN
5270
5271 IF l_Lot_Serial_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
5272
5273 OE_Validate_Lot_Serial.Entity_Delete
5274 ( x_return_status => l_return_status
5275 , p_Lot_Serial_rec => l_Lot_Serial_rec
5276 );
5277
5278 ELSE
5279
5280 OE_Validate_Lot_Serial.Entity
5281 ( x_return_status => l_return_status
5282 , p_Lot_Serial_rec => l_Lot_Serial_rec
5283 , p_old_Lot_Serial_rec => l_old_Lot_Serial_rec
5284 );
5285
5286 END IF;
5287
5288 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5289 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5290 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5291 RAISE FND_API.G_EXC_ERROR;
5292 END IF;
5293
5294 END IF;
5295
5296 -- Step 4. Write to DB
5297
5298 IF l_control_rec.write_to_db THEN
5299
5300 IF l_Lot_Serial_rec.operation = OE_GLOBALS.G_OPR_DELETE THEN
5301
5302 OE_Lot_Serial_Util.Delete_Row
5303 ( p_lot_serial_id => l_Lot_Serial_rec.lot_serial_id
5304 );
5305
5306 ELSE
5307
5308 -- Get Who Information
5309
5310 l_Lot_Serial_rec.last_update_date := SYSDATE;
5311 l_Lot_Serial_rec.last_updated_by := NVL(OE_STANDARD_WF.g_user_id, FND_GLOBAL.USER_ID); -- 3169637
5312 l_Lot_Serial_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
5313
5314 IF l_Lot_Serial_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
5315
5316 OE_Lot_Serial_Util.Update_Row (l_Lot_Serial_rec);
5317
5318 ELSIF l_Lot_Serial_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
5319
5320 l_Lot_Serial_rec.creation_date := SYSDATE;
5321 l_Lot_Serial_rec.created_by := NVL(OE_STANDARD_WF.g_user_id, FND_GLOBAL.USER_ID); -- 3169637
5322
5323 OE_Lot_Serial_Util.Insert_Row (l_Lot_Serial_rec);
5324
5325 END IF;
5326
5327 END IF;
5328
5329 END IF;
5330
5331 -- Load tables.
5332
5333 p_x_Lot_Serial_tbl(I) := l_Lot_Serial_rec;
5334 p_x_old_Lot_Serial_tbl(I) := l_old_Lot_Serial_rec;
5335
5336 -- loop exception handler.
5337
5338
5339 EXCEPTION
5340
5341 WHEN FND_API.G_EXC_ERROR THEN
5342
5343 x_return_status := FND_API.G_RET_STS_ERROR;
5344 l_Lot_Serial_rec.return_status := FND_API.G_RET_STS_ERROR;
5345 p_x_Lot_Serial_tbl(I) := l_Lot_Serial_rec;
5346 p_x_old_Lot_Serial_tbl(I) := l_old_Lot_Serial_rec;
5347
5348 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5349
5350 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5351 l_Lot_Serial_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5352 p_x_Lot_Serial_tbl(I) := l_Lot_Serial_rec;
5353 p_x_old_Lot_Serial_tbl(I) := l_old_Lot_Serial_rec;
5354 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5355
5356 WHEN OTHERS THEN
5357
5358 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5359 l_Lot_Serial_rec.return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5360 p_x_Lot_Serial_tbl(I) := l_Lot_Serial_rec;
5361 p_x_old_Lot_Serial_tbl(I) := l_old_Lot_Serial_rec;
5362
5363 IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
5364 THEN
5365 oe_msg_pub.Add_Exc_Msg
5366 ( G_PKG_NAME
5367 , 'Lot_Serials'
5368 );
5369 END IF;
5370
5371 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5372
5373 END;
5374 I := p_x_Lot_Serial_tbl.NEXT(I);
5375 END LOOP;
5376
5377 EXCEPTION
5378
5379 WHEN FND_API.G_EXC_ERROR THEN
5380
5381 x_return_status := FND_API.G_RET_STS_ERROR;
5382 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
5383 IF l_debug_level > 0 THEN
5384 oe_debug_pub.add( 'DELETE REQUEST17' , 2 ) ;
5385 END IF;
5386 OE_Delayed_Requests_Pvt.Clear_Request
5387 (x_return_status => l_return_status);
5388 END IF;
5389
5390 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5391
5392 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5393 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
5394 IF l_debug_level > 0 THEN
5395 oe_debug_pub.add( 'DELETE REQUEST18' , 2 ) ;
5396 END IF;
5397 OE_Delayed_Requests_Pvt.Clear_Request
5398 (x_return_status => l_return_status);
5399 END IF;
5400
5401 WHEN OTHERS THEN
5402
5403 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5404 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
5405 IF l_debug_level > 0 THEN
5406 oe_debug_pub.add( 'DELETE REQUEST19' , 2 ) ;
5407 END IF;
5408 OE_Delayed_Requests_Pvt.Clear_Request
5409 (x_return_status => l_return_status);
5410 END IF;
5411 IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_UNEXP_ERROR)
5412 THEN
5413 oe_msg_pub.Add_Exc_Msg
5414 ( G_PKG_NAME
5415 , 'Lot_Serials'
5416 );
5417 END IF;
5418
5419 END Lot_Serials;
5420
5421
5422 /*-----------------------------------------------------------------
5423 PROCEDURE Process_Requests_And_Notify
5424 ------------------------------------------------------------------*/
5425
5426 PROCEDURE Process_Requests_And_Notify
5427 ( p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
5428 , p_process_requests IN BOOLEAN := TRUE
5429 , p_notify IN BOOLEAN := TRUE
5430 , p_process_ack IN BOOLEAN := TRUE
5431 , x_return_status OUT NOCOPY VARCHAR2
5432
5433 , p_header_rec IN OE_Order_PUB.Header_Rec_Type :=
5434 OE_Order_PUB.G_MISS_HEADER_REC
5435 , p_old_header_rec IN OE_Order_PUB.Header_Rec_Type :=
5436 OE_Order_PUB.G_MISS_HEADER_REC
5437 , p_Header_Adj_tbl IN OE_Order_PUB.Header_Adj_Tbl_Type :=
5438 OE_Order_PUB.G_MISS_HEADER_ADJ_TBL
5439 , p_old_Header_Adj_tbl IN OE_Order_PUB.Header_Adj_Tbl_Type :=
5440 OE_Order_PUB.G_MISS_HEADER_ADJ_TBL
5441 , p_Header_Price_Att_tbl IN OE_Order_PUB.Header_Price_Att_Tbl_Type :=
5442 OE_Order_PUB.G_MISS_HEADER_PRICE_ATT_TBL
5443 , p_old_Header_Price_Att_tbl IN OE_Order_PUB.Header_Price_Att_Tbl_Type :=
5444 OE_Order_PUB.G_MISS_HEADER_PRICE_ATT_TBL
5445 , p_Header_Adj_Att_tbl IN OE_Order_PUB.Header_Adj_Att_Tbl_Type :=
5446 OE_Order_PUB.G_MISS_HEADER_ADJ_ATT_TBL
5447 , p_old_Header_Adj_Att_tbl IN OE_Order_PUB.Header_Adj_Att_Tbl_Type :=
5448 OE_Order_PUB.G_MISS_HEADER_ADJ_ATT_TBL
5449 , p_Header_Adj_Assoc_tbl IN OE_Order_PUB.Header_Adj_Assoc_Tbl_Type :=
5450 OE_Order_PUB.G_MISS_HEADER_ADJ_ASSOC_TBL
5451 , p_old_Header_Adj_Assoc_tbl IN OE_Order_PUB.Header_Adj_Assoc_Tbl_Type :=
5452 OE_Order_PUB.G_MISS_HEADER_ADJ_ASSOC_TBL
5453 , p_Header_Scredit_tbl IN OE_Order_PUB.Header_Scredit_Tbl_Type :=
5454 OE_Order_PUB.G_MISS_HEADER_SCREDIT_TBL
5455 , p_old_Header_Scredit_tbl IN OE_Order_PUB.Header_Scredit_Tbl_Type :=
5456 OE_Order_PUB.G_MISS_HEADER_SCREDIT_TBL
5457 , p_Header_Payment_tbl IN OE_Order_PUB.Header_Payment_Tbl_Type :=
5458 OE_Order_PUB.G_MISS_HEADER_PAYMENT_TBL
5459 , p_old_Header_Payment_tbl IN OE_Order_PUB.Header_Payment_Tbl_Type :=
5460 OE_Order_PUB.G_MISS_HEADER_PAYMENT_TBL
5461 , p_line_tbl IN OE_Order_PUB.Line_Tbl_Type :=
5462 OE_Order_PUB.G_MISS_LINE_TBL
5463 , p_old_line_tbl IN OE_Order_PUB.Line_Tbl_Type :=
5464 OE_Order_PUB.G_MISS_LINE_TBL
5465 , p_Line_Adj_tbl IN OE_Order_PUB.Line_Adj_Tbl_Type :=
5466 OE_Order_PUB.G_MISS_LINE_ADJ_TBL
5467 , p_old_Line_Adj_tbl IN OE_Order_PUB.Line_Adj_Tbl_Type :=
5468 OE_Order_PUB.G_MISS_LINE_ADJ_TBL
5469 , p_Line_Price_Att_tbl IN OE_Order_PUB.Line_Price_Att_Tbl_Type :=
5470 OE_Order_PUB.G_MISS_LINE_PRICE_ATT_TBL
5471 , p_old_Line_Price_Att_tbl IN OE_Order_PUB.Line_Price_Att_Tbl_Type :=
5472 OE_Order_PUB.G_MISS_LINE_PRICE_ATT_TBL
5473 , p_Line_Adj_Att_tbl IN OE_Order_PUB.Line_Adj_Att_Tbl_Type :=
5474 OE_Order_PUB.G_MISS_LINE_ADJ_ATT_TBL
5475 , p_old_Line_Adj_Att_tbl IN OE_Order_PUB.Line_Adj_Att_Tbl_Type :=
5476 OE_Order_PUB.G_MISS_LINE_ADJ_ATT_TBL
5477 , p_Line_Adj_Assoc_tbl IN OE_Order_PUB.Line_Adj_Assoc_Tbl_Type :=
5478 OE_Order_PUB.G_MISS_LINE_ADJ_ASSOC_TBL
5479 , p_old_Line_Adj_Assoc_tbl IN OE_Order_PUB.Line_Adj_Assoc_Tbl_Type :=
5480 OE_Order_PUB.G_MISS_LINE_ADJ_ASSOC_TBL
5481 , p_Line_Scredit_tbl IN OE_Order_PUB.Line_Scredit_Tbl_Type :=
5482 OE_Order_PUB.G_MISS_LINE_SCREDIT_TBL
5483 , p_old_Line_Scredit_tbl IN OE_Order_PUB.Line_Scredit_Tbl_Type :=
5484 OE_Order_PUB.G_MISS_LINE_SCREDIT_TBL
5485 , p_Line_Payment_tbl IN OE_Order_PUB.Line_Payment_Tbl_Type :=
5486 OE_Order_PUB.G_MISS_LINE_PAYMENT_TBL
5487 , p_old_Line_Payment_tbl IN OE_Order_PUB.Line_Payment_Tbl_Type :=
5488 OE_Order_PUB.G_MISS_LINE_PAYMENT_TBL
5489 , p_Lot_Serial_tbl IN OE_Order_PUB.Lot_Serial_Tbl_Type :=
5490 OE_Order_PUB.G_MISS_LOT_SERIAL_TBL
5491 , p_old_Lot_Serial_tbl IN OE_Order_PUB.Lot_Serial_Tbl_Type :=
5492 OE_Order_PUB.G_MISS_LOT_SERIAL_TBL
5493 , p_Lot_Serial_val_tbl IN OE_Order_PUB.Lot_Serial_Val_Tbl_Type :=
5494 OE_Order_PUB.G_MISS_LOT_SERIAL_VAL_TBL
5495 , p_old_Lot_Serial_val_tbl IN OE_Order_PUB.Lot_Serial_Val_Tbl_Type :=
5496 OE_Order_PUB.G_MISS_LOT_SERIAL_VAL_TBL
5497 )
5498 IS
5499 l_return_status VARCHAR2(30);
5500 l_msg_count NUMBER;
5501 l_msg_data VARCHAR2(2000);
5502 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5503 l_header_id NUMBER; -- added for bug 2781468 hashraf
5504 l_index NUMBER;
5505 l_line_id NUMBER;
5506 l_edi_ack_pfile Varchar2(3);
5507 l_org_id number; --4241385
5508 l_auto_sch_flag VARCHAR2(1) :='Y'; --4241385
5509 --SUN OIP ER
5510 I NUMBER;
5511 j NUMBER;
5512 --End of SUN OIP ER
5513
5514 BEGIN
5515
5516 IF l_debug_level > 0 THEN
5517 oe_debug_pub.add( 'ENTER OE_ORDER_PVT.PROCESS_REQUESTS_AND_NOTIFY' , 1 ) ;
5518 END IF;
5519 x_return_status := FND_API.G_RET_STS_SUCCESS;
5520 IF NOT oe_globals.g_call_process_req THEN --9354229
5521 IF l_debug_level > 0 THEN
5522 oe_debug_pub.add( 'EXIT PROCESS_REQUESTS_AND_NOTIFY' , 1 ) ;
5523 END IF;
5524 RETURN;
5525 END IF;
5526 set_recursion_mode(p_Entity_Code => 8,
5527 p_In_out => 1);
5528
5529 fnd_profile.get('ONT_NEW_EDI_ACK_FWK', l_edi_ack_pfile);
5530 l_edi_ack_pfile := nvl(l_edi_ack_pfile, 'NO');
5531
5532 -- Initialize message list.
5533
5534 IF FND_API.to_Boolean(p_init_msg_list) THEN
5535 OE_MSG_PUB.initialize;
5536 END IF;
5537
5538 --4241385
5539 /* querying the org_id here to het the value of the system parameter ONT_AUTO_SCH_SETS*/
5540 IF p_line_tbl.count>0 THEN
5541 IF l_debug_level > 0 THEN
5542 oe_debug_pub.add( 'get org id' , 1 ) ;
5543 END IF;
5544 l_auto_sch_flag:= Nvl(oe_sys_parameters.Value('ONT_AUTO_SCH_SETS',p_line_tbl(1).org_id),'Y');
5545
5546 END IF ;
5547
5548 --4241385
5549
5550 -- IF p_process_requests, then process all delayed requests
5551
5552 IF ( OE_GLOBALS.G_RECURSION_MODE = 'N'
5553 AND p_process_requests
5554 AND OE_DELAYED_REQUESTS_PVT.Requests_Count > 0 )
5555 /* --commented for bug 10088102. This condition being worked out with bug 10064449
5556 OR --4241385
5557 (OE_DELAYED_REQUESTS_PVT.Requests_Count > 0
5558 AND p_process_requests
5559 AND l_auto_sch_flag='N'
5560 AND p_line_tbl.count>0)
5561 */
5562 THEN
5563
5564 /* added the or condition here to fix a scenario where if we add a new line to a
5565 booked order, by giving the set information, the line is going into awaiting shipping
5566 but it is not getting scheduled. This is becuase, the below code is not getting
5567 executed for group_schedule delayed reuqest, as it is coming in recurision mode, in the
5568 same session. checking for the p_line_tbl.count>0 to ensure that line table is passed.
5569 This is to avoid processing when the API is called for someother entity only*/
5570
5571 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
5572 (p_entity_code => OE_GLOBALS.G_ENTITY_HEADER_ADJ
5573 ,p_delete => FND_API.G_TRUE
5574 ,x_return_status => l_return_status
5575 );
5576 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5577 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5578 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5579 RAISE FND_API.G_EXC_ERROR;
5580 END IF;
5581
5582 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
5583 (p_entity_code => OE_GLOBALS.G_ENTITY_Header_Price_Att
5584 ,p_delete => FND_API.G_TRUE
5585 ,x_return_status => l_return_status
5586 );
5587 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5588 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5589 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5590 RAISE FND_API.G_EXC_ERROR;
5591 END IF;
5592
5593 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
5594 (p_entity_code => OE_GLOBALS.G_ENTITY_Header_Adj_Att
5595 ,p_delete => FND_API.G_TRUE
5596 ,x_return_status => l_return_status
5597 );
5598 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5599 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5600 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5601 RAISE FND_API.G_EXC_ERROR;
5602 END IF;
5603
5604 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
5605 (p_entity_code => OE_GLOBALS.G_ENTITY_Header_Adj_Assoc
5606 ,p_delete => FND_API.G_TRUE
5607 ,x_return_status => l_return_status
5608 );
5609 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5610 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5611 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5612 RAISE FND_API.G_EXC_ERROR;
5613 END IF;
5614
5615 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
5616 (p_entity_code => OE_GLOBALS.G_ENTITY_Header_Scredit
5617 ,p_delete => FND_API.G_TRUE
5618 ,x_return_status => l_return_status
5619 );
5620 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5621 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5622 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5623 RAISE FND_API.G_EXC_ERROR;
5624 END IF;
5625
5626 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
5627 (p_entity_code => OE_GLOBALS.G_ENTITY_HEADER_PAYMENT
5628 ,p_delete => FND_API.G_TRUE
5629 ,x_return_status => l_return_status
5630 );
5631 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5632 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5633 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5634 RAISE FND_API.G_EXC_ERROR;
5635 END IF;
5636
5637 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
5638 (p_entity_code => OE_GLOBALS.G_ENTITY_LINE
5639 ,p_delete => FND_API.G_TRUE
5640 ,x_return_status => l_return_status
5641 );
5642 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5643 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5644 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5645 RAISE FND_API.G_EXC_ERROR;
5646 END IF;
5647
5648 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
5649 (p_entity_code => OE_GLOBALS.G_ENTITY_LINE_ADJ
5650 ,p_delete => FND_API.G_TRUE
5651 ,x_return_status => l_return_status
5652 );
5653 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5654 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5655 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5656 RAISE FND_API.G_EXC_ERROR;
5657 END IF;
5658
5659 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
5660 (p_entity_code => OE_GLOBALS.G_ENTITY_Line_Scredit
5661 ,p_delete => FND_API.G_TRUE
5662 ,x_return_status => l_return_status
5663 );
5664 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5665 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5666 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5667 RAISE FND_API.G_EXC_ERROR;
5668 END IF;
5669
5670 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
5671 (p_entity_code => OE_GLOBALS.G_ENTITY_LINE_PAYMENT
5672 ,p_delete => FND_API.G_TRUE
5673 ,x_return_status => l_return_status
5674 );
5675 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5676 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5677 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5678 RAISE FND_API.G_EXC_ERROR;
5679 END IF;
5680
5681 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
5682 (p_entity_code => OE_GLOBALS.G_ENTITY_Line_Price_Att
5683 ,p_delete => FND_API.G_TRUE
5684 ,x_return_status => l_return_status
5685 );
5686 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5687 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5688 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5689 RAISE FND_API.G_EXC_ERROR;
5690 END IF;
5691
5692 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
5693 (p_entity_code => OE_GLOBALS.G_ENTITY_Line_Adj_Att
5694 ,p_delete => FND_API.G_TRUE
5695 ,x_return_status => l_return_status
5696 );
5697 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5698 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5699 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5700 RAISE FND_API.G_EXC_ERROR;
5701 END IF;
5702
5703 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
5704 (p_entity_code => OE_GLOBALS.G_ENTITY_Line_Adj_Assoc
5705 ,p_delete => FND_API.G_TRUE
5706 ,x_return_status => l_return_status
5707 );
5708 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5709 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5710 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5711 RAISE FND_API.G_EXC_ERROR;
5712 END IF;
5713
5714 -- Execute all remaining delayed requests. This would execute
5715 -- requests logged against entity G_ENTITY_HEADER and G_ENTITY_ALL
5716
5717 OE_DELAYED_REQUESTS_PVT.Process_Delayed_Requests(
5718 x_return_status => l_return_status
5719 );
5720
5721 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5722 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5723 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5724 RAISE FND_API.G_EXC_ERROR;
5725 END IF;
5726
5727
5728 END IF; --End of requests processing
5729
5730 -- Start flows for the Entity.
5731 IF (p_process_requests AND
5732 OE_GLOBALS.G_RECURSION_MODE = 'N') THEN
5733
5734 OE_ORDER_WF_UTIL.START_ALL_FLOWS;
5735 END IF;
5736
5737 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL < '110508'
5738 AND oe_order_cache.g_header_rec.booked_flag = 'Y' THEN
5739 -- If notify, then call service and acknowledgments notify APIs
5740
5741 IF p_notify THEN
5742 IF l_debug_level > 0 THEN
5743 oe_debug_pub.add( 'CALLING NOTIFY_OC API' , 1 ) ;
5744 END IF;
5745
5746 OE_SERVICE_UTIL.Notify_OC
5747 ( p_api_version_number => 1.0
5748 , p_init_msg_list => FND_API.G_FALSE
5749 , x_return_status => l_return_status
5750 , x_msg_count => l_msg_count
5751 , x_msg_data => l_msg_data
5752 , p_header_rec => p_header_rec
5753 , p_old_header_rec => p_old_header_rec
5754 , p_header_adj_tbl => p_header_adj_tbl
5755 , p_old_header_adj_tbl => p_old_header_adj_tbl
5756 , p_header_price_att_tbl => p_header_price_att_tbl
5757 , p_old_header_price_att_tbl => p_old_header_price_att_tbl
5758 , p_Header_Adj_Att_tbl => p_Header_Adj_Att_tbl
5759 , p_old_Header_Adj_Att_tbl => p_old_Header_Adj_Att_tbl
5760 , p_Header_Adj_Assoc_tbl => p_Header_Adj_Assoc_tbl
5761 , p_old_Header_Adj_Assoc_tbl => p_old_Header_Adj_Assoc_tbl
5762 , p_Header_Scredit_tbl => p_Header_Scredit_tbl
5763 , p_old_Header_Scredit_tbl => p_old_Header_Scredit_tbl
5764 -- , p_Header_Payment_tbl => p_Header_Payment_tbl
5765 -- , p_old_Header_Payment_tbl => p_old_Header_Payment_tbl
5766 , p_line_tbl => p_line_tbl
5767 , p_old_line_tbl => p_old_line_tbl
5768 , p_Line_Adj_tbl => p_Line_Adj_tbl
5769 , p_old_Line_Adj_tbl => p_old_Line_Adj_tbl
5770 , p_Line_Price_Att_tbl => p_Line_Price_Att_tbl
5771 , p_old_Line_Price_Att_tbl => p_old_Line_Price_Att_tbl
5772 , p_Line_Adj_Att_tbl => p_Line_Adj_Att_tbl
5773 , p_old_Line_Adj_Att_tbl => p_old_Line_Adj_Att_tbl
5774 , p_Line_Adj_Assoc_tbl => p_Line_Adj_Assoc_tbl
5775 , p_old_Line_Adj_Assoc_tbl => p_old_Line_Adj_Assoc_tbl
5776 , p_Line_Scredit_tbl => p_Line_Scredit_tbl
5777 , p_old_Line_Scredit_tbl => p_old_Line_Scredit_tbl
5778 -- , p_Line_Payment_tbl => p_Line_Payment_tbl
5779 -- , p_old_Line_Payment_tbl => p_old_Line_Payment_tbl
5780 , p_Lot_Serial_tbl => p_Lot_Serial_tbl
5781 , p_old_Lot_Serial_tbl => p_old_Lot_Serial_tbl
5782 , p_Lot_Serial_val_tbl => p_Lot_Serial_val_tbl
5783 , p_old_Lot_Serial_val_tbl => p_old_Lot_Serial_val_tbl
5784 );
5785
5786 IF l_debug_level > 0 THEN
5787 oe_debug_pub.add( 'AFTER NOTIFY_OC API' , 1 ) ;
5788 END IF;
5789 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5790 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5791 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5792 RAISE FND_API.G_EXC_ERROR;
5793 END IF;
5794 END IF; --p_notify
5795
5796 IF l_debug_level > 0 THEN
5797 oe_debug_pub.add( 'PROCESSING ACKS' , 1 ) ;
5798 END IF;
5799
5800 IF p_notify AND p_process_ack THEN
5801 IF l_debug_level > 0 THEN
5802 oe_debug_pub.add( 'CALLING ACKS API' , 1 ) ;
5803 END IF;
5804
5805 -- ediack changes
5806 If Oe_Code_Control.Code_Release_level >= '110510' And
5807 p_header_rec.order_source_id In (0,2,6) And
5808 l_edi_ack_pfile = 'YES' Then
5809
5810 OE_Acknowledgment_Pvt.Process_Acknowledgment
5811 (p_header_rec => p_header_rec,
5812 p_line_tbl => p_line_tbl,
5813 p_old_header_rec => p_old_header_rec,
5814 p_old_line_tbl => p_old_line_tbl,
5815 x_return_status => l_return_status);
5816
5817 Elsif l_edi_ack_pfile = 'NO' And
5818 p_header_rec.order_source_id In (0,2,6,20) Then
5819
5820 OE_Acknowledgment_Pvt.Process_Acknowledgment
5821 (p_api_version_number => 1
5822 ,p_init_msg_list => FND_API.G_FALSE
5823 ,p_header_rec => p_header_rec
5824 ,p_header_adj_tbl => p_header_adj_tbl
5825 ,p_header_Scredit_tbl => p_header_scredit_tbl
5826 ,p_line_tbl => p_line_tbl
5827 ,p_line_adj_tbl => p_line_adj_tbl
5828 ,p_line_scredit_tbl => p_line_scredit_tbl
5829 ,p_lot_serial_tbl => p_lot_serial_tbl
5830 ,p_old_header_rec => p_old_header_rec
5831 ,p_old_header_adj_tbl => p_old_header_adj_tbl
5832 ,p_old_header_Scredit_tbl => p_old_header_scredit_tbl
5833 ,p_old_line_tbl => p_old_line_tbl
5834 ,p_old_line_adj_tbl => p_old_line_adj_tbl
5835 ,p_old_line_scredit_tbl => p_old_line_scredit_tbl
5836 ,p_old_lot_serial_tbl => p_old_lot_serial_tbl
5837
5838 ,p_buyer_seller_flag => 'B'
5839 ,p_reject_order => 'N'
5840
5841 ,x_return_status => l_return_status
5842 );
5843
5844 End If;
5845
5846 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5847 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5848 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
5849 RAISE FND_API.G_EXC_ERROR;
5850 x_return_status := l_return_status;
5851 END IF;
5852 END IF; -- p_notify and p_process_ack
5853
5854 ELSE /*post pack H*/
5855 IF l_debug_level > 0 THEN
5856 oe_debug_pub.add( 'JPN: GLOBAL RECURSION WITHOUT EXCEPTION: ' || OE_ORDER_UTIL.G_RECURSION_WITHOUT_EXCEPTION ) ;
5857 oe_debug_pub.add( 'JPN: GLOBAL CACHE BOOKED FLAG' || OE_ORDER_CACHE.G_HEADER_REC.BOOKED_FLAG ) ;
5858 oe_debug_pub.add( 'JPN: GLOBAL PICTURE HEADER BOOKED FLAG' || OE_ORDER_UTIL.G_HEADER_REC.BOOKED_FLAG ) ;
5859 oe_debug_pub.add( 'JPN: COUNT OF NEW LINE TABLE= '|| OE_ORDER_UTIL.G_LINE_TBL.COUNT ) ;
5860 oe_debug_pub.add( 'JPN: COUNT OF OLD LINE TABLE= '|| OE_ORDER_UTIL.G_OLD_LINE_TBL.COUNT ) ;
5861 oe_debug_pub.add( 'JPN: COUNT OF NEW LINE ADJ TABLE= '|| OE_ORDER_UTIL.G_LINE_ADJ_TBL.COUNT ) ;
5862 oe_debug_pub.add( 'JPN: COUNT OF OLD LINE ADJ TABLE= '|| OE_ORDER_UTIL.G_OLD_LINE_ADJ_TBL.COUNT ) ;
5863 oe_debug_pub.add( 'JPN: COUNT OF NEW HDR ADJ TABLE= '|| OE_ORDER_UTIL.G_HEADER_ADJ_TBL.COUNT ) ;
5864 oe_debug_pub.add( 'JPN: COUNT OF OLD HDR ADJ TABLE= '|| OE_ORDER_UTIL.G_OLD_HEADER_ADJ_TBL.COUNT ) ;
5865 oe_debug_pub.add( 'JPN: COUNT OF NEW HDR SCREDIT TABLE= '|| OE_ORDER_UTIL.G_HEADER_SCREDIT_TBL.COUNT ) ;
5866 oe_debug_pub.add( 'JPN: COUNT OF OLD HDR SCREDIT TABLE= '|| OE_ORDER_UTIL.G_OLD_HEADER_SCREDIT_TBL.COUNT ) ;
5867 oe_debug_pub.add( 'JPN: COUNT OF NEW LINE SCREDIT TABLE= '|| OE_ORDER_UTIL.G_LINE_SCREDIT_TBL.COUNT ) ;
5868 oe_debug_pub.add( 'JPN: COUNT OF OLD LINE SCREDIT TABLE= '|| OE_ORDER_UTIL.G_OLD_LINE_SCREDIT_TBL.COUNT ) ;
5869 oe_debug_pub.add( 'JPN: COUNT OF NEW LOT SERIAL TABLE= '|| OE_ORDER_UTIL.G_LOT_SERIAL_TBL.COUNT ) ;
5870 oe_debug_pub.add( 'JPN: COUNT OF OLD LOT SERIAL TABLE= '|| OE_ORDER_UTIL.G_OLD_LOT_SERIAL_TBL.COUNT ) ;
5871 END IF;
5872
5873 /*check global pictures, to see if there's any record in the seven key entities*/
5874
5875 IF ( OE_ORDER_UTIL.g_header_rec.header_id is not null
5876 OR OE_ORDER_UTIL.g_header_rec.header_id <> FND_API.G_MISS_NUM
5877 OR OE_ORDER_UTIL.g_header_adj_tbl.count >0
5878 OR OE_ORDER_UTIL.g_Header_Scredit_tbl.count >0
5879 -- OR OE_ORDER_UTIL.g_Header_Payment_tbl.count >0
5880 OR OE_ORDER_UTIL.g_line_tbl.count >0
5881 OR OE_ORDER_UTIL.g_Line_Adj_tbl.count >0
5882 OR OE_ORDER_UTIL.g_Line_Scredit_tbl.count >0
5883 -- OR OE_ORDER_UTIL.g_Line_Payment_tbl.count >0
5884 OR OE_ORDER_UTIL.g_Lot_Serial_tbl.count >0 ) THEN
5885
5886 /* start of bug 2781468 hashraf */
5887
5888 /* need to get the header_id which will then be passed to load_order_header
5889 to refresh the record in cache
5890 */
5891
5892 l_index := 1;
5893
5894 IF ( OE_ORDER_UTIL.g_header_rec.header_id is not null
5895 AND OE_ORDER_UTIL.g_header_rec.header_id <> FND_API.G_MISS_NUM) THEN
5896 l_header_id := OE_ORDER_UTIL.g_header_rec.header_id;
5897
5898 IF l_debug_level > 0 THEN
5899 oe_debug_pub.add('header id in g_header_rec is: ' || l_header_id ) ;
5900 END IF;
5901
5902 ELSIF ( OE_ORDER_UTIL.g_header_adj_tbl.count >0 ) THEN
5903 IF l_debug_level > 0 THEN
5904 oe_debug_pub.add('Inside the header_adj_tbl loop');
5905 END IF;
5906 l_index := OE_ORDER_UTIL.g_header_adj_tbl.first;
5907 IF (l_index is not null) THEN
5908 l_header_id := OE_ORDER_UTIL.g_header_adj_tbl(l_index).header_id;
5909 IF l_debug_level > 0 THEN
5910 oe_debug_pub.add('header id in g_header_adj_tbl is: ' || l_header_id ) ;
5911 oe_debug_pub.add('l_index in g_header_adj_tbl is: ' || l_index ) ;
5912 END IF;
5913 END IF;
5914
5915 ELSIF ( OE_ORDER_UTIL.g_Header_Scredit_tbl.count >0 ) THEN
5916 IF l_debug_level > 0 THEN
5917 oe_debug_pub.add('Inside the header_Scredit_tbl loop');
5918 END IF;
5919 l_index := OE_ORDER_UTIL.g_header_Scredit_tbl.first;
5920 IF (l_index is not null) THEN
5921 l_header_id := OE_ORDER_UTIL.g_header_Scredit_tbl(l_index).header_id;
5922 IF l_debug_level > 0 THEN
5923 oe_debug_pub.add('header id in g_header_Scredit_tbl is: ' || l_header_id ) ;
5924 oe_debug_pub.add('l_index in g_header_Scredit_tbl is: ' || l_index ) ;
5925 END IF;
5926 END IF;
5927
5928 ELSIF ( OE_ORDER_UTIL.g_line_tbl.count >0 ) THEN
5929 IF l_debug_level > 0 THEN
5930 oe_debug_pub.add('Inside the line loop');
5931 END IF;
5932 l_index := OE_ORDER_UTIL.g_line_tbl.first;
5933 IF (l_index is not null) THEN
5934 l_header_id := OE_ORDER_UTIL.g_line_tbl(l_index).header_id;
5935 IF l_debug_level > 0 THEN
5936 oe_debug_pub.add('header id in g_line_tbl is: ' || l_header_id ) ;
5937 oe_debug_pub.add('l_index in g_line_tbl is: ' || l_index ) ;
5938 END IF;
5939 END IF;
5940
5941 ELSIF ( OE_ORDER_UTIL.g_line_adj_tbl.count >0 ) THEN
5942
5943 IF l_debug_level > 0 THEN
5944 oe_debug_pub.add('Inside the line_adj loop');
5945 END IF;
5946 l_index := OE_ORDER_UTIL.g_line_adj_tbl.first;
5947 IF (l_index is not null) THEN
5948
5949 l_header_id := OE_ORDER_UTIL.g_line_adj_tbl(l_index).header_id;
5950 IF l_debug_level > 0 THEN
5951 oe_debug_pub.add('header id in g_line_adj_tbl is: ' || l_header_id ) ;
5952 oe_debug_pub.add('l_index in g_line_adj_tbl is: ' || l_index ) ;
5953 END IF;
5954 END IF;
5955
5956 ELSIF ( OE_ORDER_UTIL.g_line_Scredit_tbl.count >0 ) THEN
5957
5958 IF l_debug_level > 0 THEN
5959 oe_debug_pub.add('Inside the line_Scredit loop');
5960 END IF;
5961 l_index := OE_ORDER_UTIL.g_line_Scredit_tbl.first;
5962 IF (l_index is not null) THEN
5963
5964 l_header_id := OE_ORDER_UTIL.g_line_Scredit_tbl(l_index).header_id;
5965 IF l_debug_level > 0 THEN
5966 oe_debug_pub.add('header id in g_line_Scredit_tbl is: ' || l_header_id );
5967 oe_debug_pub.add('l_index in g_line_Scredit_tbl is: ' || l_index ) ;
5968 END IF;
5969 END IF;
5970
5971 ELSIF ( OE_ORDER_UTIL.g_Lot_Serial_tbl.count >0 ) THEN
5972 IF l_debug_level > 0 THEN
5973 oe_debug_pub.add('Inside the group by_lot_serial loop');
5974 END IF;
5975 l_index := OE_ORDER_UTIL.g_Lot_Serial_tbl.first;
5976 IF (l_index is not null) THEN
5977 l_line_id := OE_ORDER_UTIL.g_Lot_Serial_tbl(l_index).line_id;
5978
5979 BEGIN
5980 SELECT header_id
5981 INTO l_header_id
5982 FROM OE_ORDER_LINES_ALL
5983 WHERE line_id = l_line_id;
5984 EXCEPTION
5985 WHEN NO_DATA_FOUND THEN
5986 null;
5987 END;
5988
5989 IF l_debug_level > 0 THEN
5990 oe_debug_pub.add('header id in g_Lot_Serial_tbl is: ' || l_header_id);
5991 oe_debug_pub.add('line id in g_Lot_Serial_tbl is: ' || l_line_id);
5992 oe_debug_pub.add('l_index in g_Lot_Serial_tbl is: ' || l_index);
5993 END IF;
5994 END IF; -- l_index is not null in g_lot
5995
5996 END IF; -- end if-elsif
5997
5998 IF l_debug_level > 0 THEN
5999 oe_debug_pub.add( 'header id is: ' || l_header_id ) ;
6000 END IF;
6001
6002 IF (l_header_id is not null AND l_header_id <> FND_API.G_MISS_NUM) THEN
6003
6004 IF l_debug_level > 0 THEN
6005 oe_debug_pub.add('Just before calling Load_Order_Header');
6006 END IF;
6007
6008 Oe_Order_Cache.Load_Order_Header(l_header_id);
6009 END IF;
6010
6011 IF l_debug_level > 0 THEN
6012 oe_debug_pub.add('Out of Load_Order_Header in PRN');
6013 END IF;
6014 /* end of bug 2781468*/
6015
6016 IF (OE_ORDER_UTIL.G_Recursion_Without_Exception = 'N' AND
6017 OE_ORDER_CACHE.g_header_rec.booked_flag = 'Y') THEN
6018
6019 IF l_debug_level > 0 THEN
6020 oe_debug_pub.add( 'POST PACK H. CALLING NOTIFY_OC API' , 1 ) ;
6021 END IF;
6022
6023 OE_SERVICE_UTIL.Notify_OC
6024 ( p_api_version_number => 1.0
6025 , p_init_msg_list => FND_API.G_FALSE
6026 , x_return_status => l_return_status
6027 , x_msg_count => l_msg_count
6028 , x_msg_data => l_msg_data
6029 , p_header_rec => OE_ORDER_UTIL.g_header_rec
6030 , p_old_header_rec => OE_ORDER_UTIL.g_old_header_rec
6031 , p_header_adj_tbl => OE_ORDER_UTIL.g_header_adj_tbl
6032 , p_old_header_adj_tbl => OE_ORDER_UTIL.g_old_header_adj_tbl
6033 , p_Header_Scredit_tbl => OE_ORDER_UTIL.g_Header_Scredit_tbl
6034 , p_old_Header_Scredit_tbl => OE_ORDER_UTIL.g_old_Header_Scredit_tbl
6035 -- , p_Header_Payment_tbl => OE_ORDER_UTIL.g_Header_Payment_tbl
6036 -- , p_old_Header_Payment_tbl => OE_ORDER_UTIL.g_old_Header_Payment_tbl
6037 , p_line_tbl => OE_ORDER_UTIL.g_line_tbl
6038 , p_old_line_tbl => OE_ORDER_UTIL.g_old_line_tbl
6039 , p_Line_Adj_tbl => OE_ORDER_UTIL.g_Line_Adj_tbl
6040 , p_old_Line_Adj_tbl => OE_ORDER_UTIL.g_old_Line_Adj_tbl
6041 , p_Line_Scredit_tbl => OE_ORDER_UTIL.g_Line_Scredit_tbl
6042 , p_old_Line_Scredit_tbl => OE_ORDER_UTIL.g_old_Line_Scredit_tbl
6043 -- , p_Line_Payment_tbl => OE_ORDER_UTIL.g_Line_Payment_tbl
6044 -- , p_old_Line_Payment_tbl => OE_ORDER_UTIL.g_old_Line_Payment_tbl
6045 , p_Lot_Serial_tbl => OE_ORDER_UTIL.g_Lot_Serial_tbl
6046 , p_old_Lot_Serial_tbl => OE_ORDER_UTIL.g_old_Lot_Serial_tbl
6047 );
6048
6049 IF l_debug_level > 0 THEN
6050 oe_debug_pub.add( 'AFTER NOTIFY_OC API' , 1 ) ;
6051 END IF;
6052 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6053 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6054 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6055 RAISE FND_API.G_EXC_ERROR;
6056 END IF;
6057
6058
6059 END IF;
6060
6061 IF l_debug_level > 0 THEN
6062 oe_debug_pub.add( 'PROCESSING ACKS' , 1 ) ;
6063 oe_debug_pub.add( 'PACKS ' || OE_ORDER_UTIL.G_RECURSION_WITHOUT_EXCEPTION , 1 ) ;
6064 oe_debug_pub.add( 'PACKS' || OE_ORDER_CACHE.G_HEADER_REC.BOOKED_FLAG , 1 ) ;
6065 END IF;
6066
6067 --SUN OIP ER
6068 If NVL (Fnd_Profile.Value('ONT_RAISE_STATUS_CHANGE_BUSINESS_EVENT'), 'N')='Y' THEN
6069 i := OE_ORDER_UTIL.g_line_tbl.first;
6070 while i is not null LOOP
6071 if OE_ORDER_UTIL.g_line_tbl(i).line_id = OE_ORDER_UTIL.g_old_line_tbl(i).line_id then
6072 j := i;
6073 else
6074 j := OE_Acknowledgment_Pub.get_line_index(OE_ORDER_UTIL.g_old_line_tbl, OE_ORDER_UTIL.g_line_tbl(i).line_id);
6075 end if;
6076
6077 if j<>0 THEN
6078
6079 IF NOT l_event_Tbl.exists(Mod(OE_ORDER_UTIL.g_line_tbl(i).line_id,G_BINARY_LIMIT)) THEN
6080 l_event_Tbl(Mod(OE_ORDER_UTIL.g_line_tbl(i).line_id,G_BINARY_LIMIT)) := FALSE;
6081 END IF;
6082
6083 if OE_ORDER_UTIL.g_old_line_tbl(i).schedule_ship_date IS NULL
6084 AND OE_ORDER_UTIL.g_line_tbl(i).schedule_ship_date IS NOT NULL AND
6085 NOT l_event_Tbl(Mod(OE_ORDER_UTIL.g_line_tbl(i).line_id,G_BINARY_LIMIT)) THEN
6086
6087 OE_ORDER_UTIL.RAISE_BUSINESS_EVENT(OE_ORDER_UTIL.g_line_tbl(i).header_id,
6088 OE_ORDER_UTIL.g_line_tbl(i).line_id,
6089 'SCHEDULED');
6090 l_event_Tbl(Mod(OE_ORDER_UTIL.g_line_tbl(i).line_id,G_BINARY_LIMIT)) := TRUE;
6091 ELSE
6092 IF nvl(OE_ORDER_UTIL.g_line_tbl(i).schedule_ship_date, trunc(sysdate)) <>
6093 nvl(OE_ORDER_UTIL.g_old_line_tbl(i).schedule_ship_date, trunc(sysdate)) AND
6094 NOT l_event_Tbl(Mod(OE_ORDER_UTIL.g_line_tbl(i).line_id,G_BINARY_LIMIT)) THEN
6095
6096 OE_ORDER_UTIL.RAISE_BUSINESS_EVENT(OE_ORDER_UTIL.g_line_tbl(i).header_id,
6097 OE_ORDER_UTIL.g_line_tbl(i).line_id,
6098 'SSD Change');
6099 l_event_Tbl(Mod(OE_ORDER_UTIL.g_line_tbl(i).line_id,G_BINARY_LIMIT)) := TRUE;
6100 END IF;
6101 END IF;
6102 END IF;
6103 i := OE_ORDER_UTIL.g_line_tbl.Next(i);
6104 end loop;
6105 end if;
6106 --End of SUN OIP ER
6107 IF (OE_ORDER_UTIL.G_Recursion_Without_Exception = 'N' AND
6108 OE_ORDER_CACHE.g_header_rec.booked_flag = 'Y' AND p_process_ack) THEN
6109
6110 IF l_debug_level > 0 THEN
6111 oe_debug_pub.add( 'POST PACK H.CALLING ACKS API' , 1 ) ;
6112 END IF;
6113
6114 -- { Start 3A6 changes, Design will still honor the Booking as
6115 -- the starting point of the triggering of the Show Sales Order
6116 -- collaboration. Later some point If we decided (by Cust requirment)
6117 -- that it should not wait till booking and workflow solution is not
6118 -- acceptable, we should review this code to removed the booking
6119 -- condition, i.e. write a new if for 3A6.
6120
6121 -- { Start of If order_source_id = 20
6122 -- The below condition will only executed for the the XML Xactions
6123 IF l_debug_level > 0 THEN
6124 oe_debug_pub.add( 'PACKS ' || OE_ORDER_CACHE.G_HEADER_REC.ORDER_SOURCE_ID , 1 ) ;
6125 oe_debug_pub.add( 'PACKS ' || OE_ORDER_CACHE.G_HEADER_REC.SOLD_TO_ORG_ID , 1 ) ;
6126 END IF;
6127
6128 If OE_ORDER_CACHE.g_header_rec.order_source_id in (20) OR
6129 NVL(Fnd_Profile.Value('ONT_RAISE_STATUS_CHANGE_BUSINESS_EVENT'), 'N')='Y' OR
6130 (OE_GENESIS_UTIL.source_aia_enabled(OE_ORDER_CACHE.g_header_rec.order_source_id)) THEN -- GENESIS
6131
6132
6133 OE_Acknowledgment_Pub.Process_SSO
6134 (p_api_version_number => 1
6135 ,p_init_msg_list => FND_API.G_FALSE
6136 ,p_header_rec => OE_ORDER_CACHE.g_header_rec
6137 ,p_line_tbl => OE_ORDER_UTIL.g_line_tbl
6138 ,p_old_header_rec => OE_ORDER_UTIL.g_old_header_rec
6139 ,p_old_line_tbl => OE_ORDER_UTIL.g_old_line_tbl
6140
6141 ,x_return_status => l_return_status
6142 );
6143
6144 -- The below condition to leave the existing flow to work as it is
6145 Elsif Oe_Code_Control.Code_Release_Level >= '110510' And
6146 OE_ORDER_CACHE.g_header_rec.order_source_id in (0,2,6) And
6147 l_edi_ack_pfile = 'YES' Then
6148 OE_Acknowledgment_Pvt.Process_Acknowledgment
6149 (p_header_rec => OE_ORDER_UTIL.g_header_rec,
6150 p_line_tbl => OE_ORDER_UTIL.g_line_tbl,
6151 p_old_header_rec => OE_ORDER_UTIL.g_old_header_rec,
6152 p_old_line_tbl => OE_ORDER_UTIL.g_old_line_tbl,
6153 x_return_status => l_return_status);
6154 Elsif l_edi_ack_pfile = 'NO' And
6155 OE_ORDER_CACHE.g_header_rec.order_source_id in (0,2,6) Then
6156 OE_Acknowledgment_Pvt.Process_Acknowledgment
6157 (p_api_version_number => 1
6158 ,p_init_msg_list => FND_API.G_FALSE
6159 ,p_header_rec => OE_ORDER_UTIL.g_header_rec
6160 ,p_header_adj_tbl => OE_ORDER_UTIL.g_header_adj_tbl
6161 ,p_header_Scredit_tbl => OE_ORDER_UTIL.g_header_scredit_tbl
6162 ,p_line_tbl => OE_ORDER_UTIL.g_line_tbl
6163 ,p_line_adj_tbl => OE_ORDER_UTIL.g_line_adj_tbl
6164 ,p_line_scredit_tbl => OE_ORDER_UTIL.g_line_scredit_tbl
6165 ,p_lot_serial_tbl => OE_ORDER_UTIL.g_lot_serial_tbl
6166 ,p_old_header_rec => OE_ORDER_UTIL.g_old_header_rec
6167 ,p_old_header_adj_tbl => OE_ORDER_UTIL.g_old_header_adj_tbl
6168 ,p_old_header_Scredit_tbl => OE_ORDER_UTIL.g_old_header_scredit_tbl
6169 ,p_old_line_tbl => OE_ORDER_UTIL.g_old_line_tbl
6170 ,p_old_line_adj_tbl => OE_ORDER_UTIL.g_old_line_adj_tbl
6171 ,p_old_line_scredit_tbl => OE_ORDER_UTIL.g_old_line_scredit_tbl
6172 ,p_old_lot_serial_tbl => OE_ORDER_UTIL.g_old_lot_serial_tbl
6173
6174 ,p_buyer_seller_flag => 'B'
6175 ,p_reject_order => 'N'
6176
6177 ,x_return_status => l_return_status
6178 );
6179
6180 End If;
6181 -- End of If order_source_id = 20 }
6182 -- End 3A6 changes}
6183
6184 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6185 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6186 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6187 RAISE FND_API.G_EXC_ERROR;
6188 x_return_status := l_return_status;
6189 END IF;
6190
6191 END IF;
6192
6193 -- DBI project changes start
6194 IF l_debug_level > 0 THEN
6195 oe_debug_pub.add( 'CALLING OE_DBI_UTIL' , 1 ) ;
6196 oe_debug_pub.add( 'CACHED VALUE' || OE_ORDER_CACHE.G_HEADER_REC.BOOKED_FLAG ) ;
6197 oe_debug_pub.add( 'RECURSION VALUE' || OE_ORDER_UTIL.G_RECURSION_WITHOUT_EXCEPTION ) ;
6198 oe_debug_pub.add( 'PROFILE VALUE' || FND_PROFILE.VALUE ( 'ONT_DBI_INSTALLED' ) ) ;
6199 END IF;
6200
6201 IF NVL(FND_PROFILE.VALUE('ONT_DBI_INSTALLED'), 'N') = 'Y' AND
6202 oe_order_cache.g_header_rec.booked_flag = 'Y' AND
6203 OE_ORDER_UTIL.G_Recursion_Without_Exception = 'N'
6204 -- AND p_header_rec.header_id IS NOT NULL AND
6205 --p_header_rec.header_id <> FND_API.G_MISS_NUM
6206 THEN
6207 OE_DBI_UTIL.Update_DBI_Log( x_return_status => l_return_status);
6208
6209 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6210 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6211 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6212 RAISE FND_API.G_EXC_ERROR;
6213 x_return_status := l_return_status;
6214 END IF;
6215 END IF;
6216 -- DBI project changes end
6217
6218
6219
6220 /* Now clear the global pl/sql tables */
6221 /* Also clear for >= 11i10 for versioning */
6222 IF (OE_ORDER_UTIL.G_Recursion_Without_Exception = 'N' AND
6223 (OE_ORDER_CACHE.g_header_rec.booked_flag = 'Y' OR
6224 OE_CODE_CONTROL.Code_Release_Level >= '110510' )) THEN
6225 OE_ORDER_UTIL.Clear_Global_Picture(l_return_status);
6226 END IF;
6227
6228 END IF; /*check for record in key entities*/
6229 END IF; /*code_release_level*/
6230
6231 /* Fix Bug # 3241831: Reset Global after all requests have been processed */
6232 IF OE_GLOBALS.G_RECURSION_MODE = 'N' AND OE_GLOBALS.G_UI_FLAG = FALSE THEN
6233 IF OE_OE_FORM_CANCEL_LINE.g_ord_lvl_can THEN
6234 IF l_debug_level > 0 THEN
6235 oe_debug_pub.add('SET G_ORD_LVL_CAN TO FALSE FOR NON UI ORDER CANCEL');
6236 END IF;
6237 OE_OE_FORM_CANCEL_LINE.g_ord_lvl_can := FALSE;
6238 END IF;
6239 END IF;
6240
6241 --resetting g_header_created flag
6242 IF OE_GLOBALS.G_RECURSION_MODE <> 'Y' AND
6243 OE_GLOBALS.G_PRICING_RECURSION <> 'Y' THEN
6244 OE_GLOBALS.G_HEADER_CREATED := FALSE;
6245 END IF;
6246
6247 IF l_debug_level > 0 THEN
6248 oe_debug_pub.add( 'EXIT OE_ORDER_PVT.PROCESS_REQUESTS_AND_NOTIFY' , 1 ) ;
6249 END IF;
6250 set_recursion_mode(p_Entity_Code => 8,
6251 p_In_out => 0);
6252 IF l_debug_level > 0 THEN
6253 oe_debug_pub.add( 'GLOBAL REQUEST TABLE COUNT- PRN'|| OE_DELAYED_REQUESTS_PVT.G_DELAYED_REQUESTS.COUNT , 1 ) ;
6254 END IF;
6255
6256
6257 EXCEPTION
6258
6259 WHEN FND_API.G_EXC_ERROR THEN
6260
6261 set_recursion_mode(p_Entity_Code => 8,
6262 p_In_out => 0);
6263 x_return_status := FND_API.G_RET_STS_ERROR;
6264 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
6265 OE_DELAYED_REQUESTS_PVT.Clear_Request(l_return_status);
6266 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508' THEN
6267 OE_ORDER_UTIL.Clear_Global_Picture(l_return_status);
6268 END IF;
6269 END IF;
6270
6271 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6272
6273 set_recursion_mode(p_Entity_Code => 8,
6274 p_In_out => 0);
6275 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6276 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
6277 OE_DELAYED_REQUESTS_PVT.Clear_Request(l_return_status);
6278 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508' THEN
6279 OE_ORDER_UTIL.Clear_Global_Picture(l_return_status);
6280 END IF;
6281 END IF;
6282
6283 WHEN OTHERS THEN
6284
6285 set_recursion_mode(p_Entity_Code => 8,
6286 p_In_out => 0);
6287 IF l_debug_level > 0 THEN
6288 oe_debug_pub.add( 'PO: EXITING PROCESS_REQUESTS_AND_NOTIFY WITH OTHERS ERROR' , 2 ) ;
6289 END IF;
6290 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6291 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
6292 OE_DELAYED_REQUESTS_PVT.Clear_Request(l_return_status);
6293 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508' THEN
6294 OE_ORDER_UTIL.Clear_Global_Picture(l_return_status);
6295 END IF;
6296 END IF;
6297 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6298 THEN
6299 OE_MSG_PUB.Add_Exc_Msg
6300 ( G_PKG_NAME
6301 , 'Process_Requests_And_Notify'
6302 );
6303 END IF;
6304
6305 END Process_Requests_And_Notify;
6306
6307 PROCEDURE Process_Order_AG
6308 ( p_api_version_number IN NUMBER
6309 , p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
6310 , p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL
6311 , p_control_rec IN OE_GLOBALS.Control_Rec_Type :=
6312 OE_GLOBALS.G_MISS_CONTROL_REC
6313 , x_return_status OUT NOCOPY VARCHAR2
6314
6315 , x_msg_count OUT NOCOPY NUMBER
6316
6317 , x_msg_data OUT NOCOPY VARCHAR2
6318
6319 , p_x_header_rec IN OUT NOCOPY OE_Order_PUB.Header_Rec_Type
6320 , p_old_header_rec IN OE_Order_PUB.Header_Rec_Type :=
6321 OE_Order_PUB.G_MISS_HEADER_REC
6322 , p_x_Header_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Tbl_Type
6323 , p_old_Header_Adj_tbl IN OE_Order_PUB.Header_Adj_Tbl_Type :=
6324 OE_Order_PUB.G_MISS_HEADER_ADJ_TBL
6325 , p_x_Header_Price_Att_tbl IN OUT NOCOPY OE_Order_PUB.Header_Price_Att_Tbl_Type
6326 , p_old_Header_Price_Att_tbl IN OE_Order_PUB.Header_Price_Att_Tbl_Type :=
6327 OE_Order_PUB.G_MISS_HEADER_PRICE_ATT_TBL
6328 , p_x_Header_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Att_Tbl_Type
6329 , p_old_Header_Adj_Att_tbl IN OE_Order_PUB.Header_Adj_Att_Tbl_Type :=
6330 OE_Order_PUB.G_MISS_HEADER_ADJ_ATT_TBL
6331 , p_x_Header_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Assoc_Tbl_Type
6332 , p_old_Header_Adj_Assoc_tbl IN OE_Order_PUB.Header_Adj_Assoc_Tbl_Type :=
6333 OE_Order_PUB.G_MISS_HEADER_ADJ_ASSOC_TBL
6334 , p_x_Header_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Header_Scredit_Tbl_Type
6335 , p_old_Header_Scredit_tbl IN OE_Order_PUB.Header_Scredit_Tbl_Type :=
6336 OE_Order_PUB.G_MISS_HEADER_SCREDIT_TBL
6337 , p_x_Header_Payment_tbl IN OUT NOCOPY OE_Order_PUB.Header_Payment_Tbl_Type
6338 , p_old_Header_Payment_tbl IN OE_Order_PUB.Header_Payment_Tbl_Type :=
6339 OE_Order_PUB.G_MISS_HEADER_PAYMENT_TBL
6340 , p_x_line_tbl IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
6341 , p_old_line_tbl IN OE_Order_PUB.Line_Tbl_Type :=
6342 OE_Order_PUB.G_MISS_LINE_TBL
6343 , p_x_Line_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Tbl_Type
6344 , p_old_Line_Adj_tbl IN OE_Order_PUB.Line_Adj_Tbl_Type :=
6345 OE_Order_PUB.G_MISS_LINE_ADJ_TBL
6346 , p_x_Line_Price_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Price_Att_Tbl_Type
6347 , p_old_Line_Price_Att_tbl IN OE_Order_PUB.Line_Price_Att_Tbl_Type :=
6348 OE_Order_PUB.G_MISS_LINE_PRICE_ATT_TBL
6349 , p_x_Line_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Att_Tbl_Type
6350 , p_old_Line_Adj_Att_tbl IN OE_Order_PUB.Line_Adj_Att_Tbl_Type :=
6351 OE_Order_PUB.G_MISS_LINE_ADJ_ATT_TBL
6352 , p_x_Line_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Assoc_Tbl_Type
6353 , p_old_Line_Adj_Assoc_tbl IN OE_Order_PUB.Line_Adj_Assoc_Tbl_Type :=
6354 OE_Order_PUB.G_MISS_LINE_ADJ_ASSOC_TBL
6355 , p_x_Line_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Line_Scredit_Tbl_Type
6356 , p_old_Line_Scredit_tbl IN OE_Order_PUB.Line_Scredit_Tbl_Type :=
6357 OE_Order_PUB.G_MISS_LINE_SCREDIT_TBL
6358 , p_x_Line_Payment_tbl IN OUT NOCOPY OE_Order_PUB.Line_Payment_Tbl_Type
6359 , p_old_Line_Payment_tbl IN OE_Order_PUB.Line_Payment_Tbl_Type :=
6360 OE_Order_PUB.G_MISS_LINE_PAYMENT_TBL
6361 , p_x_Lot_Serial_tbl IN OUT NOCOPY OE_Order_PUB.Lot_Serial_Tbl_Type
6362 , p_old_Lot_Serial_tbl IN OE_Order_PUB.Lot_Serial_Tbl_Type :=
6363 OE_Order_PUB.G_MISS_LOT_SERIAL_TBL
6364 , p_Lot_Serial_val_tbl IN OE_Order_PUB.Lot_Serial_Val_Tbl_Type :=
6365 OE_Order_PUB.G_MISS_LOT_SERIAL_VAL_TBL
6366 , p_old_Lot_Serial_val_tbl IN OE_Order_PUB.Lot_Serial_Val_Tbl_Type :=
6367 OE_Order_PUB.G_MISS_LOT_SERIAL_VAL_TBL
6368 , p_x_action_request_tbl IN OUT NOCOPY OE_Order_PUB.request_tbl_type
6369 , p_action_commit IN VARCHAR2 := FND_API.G_FALSE
6370 )
6371 IS
6372 l_api_version_number CONSTANT NUMBER := 1.0;
6373 l_control_rec OE_GLOBALS.Control_Rec_Type := p_control_rec;
6374 l_return_status VARCHAR2(1);
6375 I NUMBER;
6376 l_header_id NUMBER;
6377 l_call_split BOOLEAN := FALSE;
6378 l_line_index NUMBER;
6379 l_old_header_rec OE_Order_PUB.Header_Rec_Type ;
6380 l_old_Header_Adj_tbl OE_Order_PUB.Header_Adj_Tbl_Type;
6381 l_Old_Header_price_Att_Tbl OE_Order_PUB.Header_Price_Att_Tbl_Type ;
6382 l_Old_Header_Adj_Att_Tbl OE_Order_PUB.Header_Adj_Att_Tbl_Type ;
6383 l_old_Header_Adj_Assoc_tbl OE_Order_PUB.Header_Adj_Assoc_Tbl_Type ;
6384 l_old_Header_Scredit_tbl OE_Order_PUB.Header_Scredit_Tbl_Type;
6385 l_old_Header_Payment_tbl OE_Order_PUB.Header_Payment_Tbl_Type;
6386 l_old_line_tbl OE_Order_PUB.Line_Tbl_Type;
6387 l_old_Line_Adj_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
6388 l_Old_Line_price_Att_Tbl OE_Order_PUB.Line_Price_Att_Tbl_Type ;
6389 l_old_Line_Adj_Att_tbl OE_Order_PUB.Line_Adj_Att_Tbl_Type ;
6390 l_old_Line_Adj_Assoc_tbl OE_Order_PUB.Line_Adj_Assoc_Tbl_Type ;
6391 l_old_Line_Scredit_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
6392 l_old_Line_Payment_tbl OE_Order_PUB.Line_Payment_Tbl_Type;
6393 l_old_Lot_Serial_tbl OE_Order_PUB.Lot_Serial_Tbl_Type;
6394 l_old_Lot_Serial_val_tbl OE_Order_PUB.Lot_Serial_Val_Tbl_Type;
6395 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
6396 l_edi_ack_pfile Varchar2(3);
6397 l_transaction_phase_code VARCHAR2(1); -- Added for bug 4758902
6398 l_hdr_flow_status_refresh VARCHAR2(1); -- Added for bug 8435946
6399 BEGIN
6400 IF l_debug_level > 0 THEN
6401 oe_debug_pub.add( 'ENTER PROCESS_ORDER_AG' , 1 ) ;
6402 END IF;
6403
6404 -- Initialize x_return_status
6405 x_return_status := FND_API.G_RET_STS_SUCCESS;
6406 fnd_profile.get('ONT_NEW_EDI_ACK_FWK', l_edi_ack_pfile);
6407 l_edi_ack_pfile := nvl(l_edi_ack_pfile, 'NO');
6408
6409 -- Init local table variables for old tables as these are only
6410 -- IN params.
6411
6412 l_old_header_Rec := p_old_header_rec;
6413 l_old_Header_Adj_tbl := p_old_Header_Adj_tbl;
6414 l_old_Header_price_Att_tbl := p_old_Header_Price_Att_Tbl;
6415 l_old_Header_Adj_Att_tbl := p_old_Header_Adj_Att_Tbl;
6416 l_old_Header_Adj_Assoc_tbl := P_old_Header_Adj_Assoc_Tbl;
6417 l_old_Header_Scredit_tbl := p_old_Header_Scredit_tbl;
6418 l_old_Header_Payment_tbl := p_old_Header_Payment_tbl;
6419 l_old_line_tbl := p_old_line_tbl;
6420 l_old_Line_Adj_tbl := p_old_Line_Adj_tbl;
6421 l_old_Line_price_Att_tbl := p_old_Line_Price_Att_Tbl;
6422 l_old_Line_Adj_Att_tbl := p_old_Line_Adj_Att_Tbl;
6423 l_old_Line_Adj_Assoc_tbl := P_old_Line_Adj_Assoc_Tbl;
6424 l_old_Line_Scredit_tbl := p_old_Line_Scredit_tbl;
6425 l_old_Line_Payment_tbl := p_old_Line_Payment_tbl;
6426 l_old_Lot_Serial_tbl := p_old_Lot_Serial_tbl;
6427
6428
6429 IF l_debug_level > 0 THEN
6430 oe_debug_pub.add( 'BEFORE HEADER PROCESSING' , 2 ) ;
6431 oe_debug_pub.add( 'HEADER_ID' || P_X_HEADER_REC.HEADER_ID , 2 ) ;
6432 oe_debug_pub.add( 'OPERATION' || P_X_HEADER_REC.OPERATION , 2 ) ;
6433 END IF;
6434
6435 -------------------------------------------------------
6436 -- Process Header
6437 -------------------------------------------------------
6438
6439 --Bug 2790512: Prevent processing of header if operation is invalid
6440 --Bug 2878121: Ignore NULL operation code
6441 IF p_x_header_rec.header_id is NOT NULL AND
6442 p_x_header_rec.header_id <> FND_API.G_MISS_NUM THEN
6443 IF p_x_header_rec.operation IS NOT NULL AND
6444 p_x_header_rec.operation NOT IN (OE_GLOBALS.G_OPR_CREATE,
6445 OE_GLOBALS.G_OPR_DELETE, OE_GLOBALS.G_OPR_UPDATE,
6446 OE_GLOBALS.G_OPR_NONE) THEN
6447 FND_MESSAGE.SET_NAME('ONT','OE_OI_OPERATION_CODE');
6448 OE_MSG_PUB.Add;
6449 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6450 END IF;
6451 END IF;
6452
6453 IF p_x_header_rec.operation IS NOT NULL
6454 AND p_x_header_rec.operation <> OE_GLOBALS.G_OPR_NONE
6455 THEN
6456
6457 -- This if is add to honor users sales credits if they do not
6458 -- want the default sales credit for the salesrep on the order
6459
6460 IF p_x_header_scredit_tbl.COUNT > 0 and
6461 p_x_header_rec.operation = oe_globals.g_opr_create THEN
6462 OE_Validate_Header_Scredit.G_Create_Auto_Sales_Credit := 'N';
6463 END IF;
6464
6465 Header
6466 ( p_validation_level => p_validation_level
6467 , p_control_rec => p_control_rec
6468 , p_x_header_rec => p_x_header_rec
6469 , p_x_old_header_rec => l_old_header_rec
6470 , x_return_status => l_return_status
6471 );
6472
6473 OE_Validate_Header_Scredit.G_Create_Auto_Sales_Credit := 'Y';
6474
6475 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6476 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6477 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6478 RAISE FND_API.G_EXC_ERROR;
6479 END IF;
6480 END IF;
6481 IF l_debug_level > 0 THEN
6482 oe_debug_pub.add( 'AFTER HEADER PROCESSING HEADER_ID = '|| TO_CHAR ( P_X_HEADER_REC.HEADER_ID ) , 2 ) ;
6483 END IF;
6484
6485 -- Perform header group requests.
6486
6487 IF (p_control_rec.process AND
6488 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
6489 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
6490 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_HEADER)
6491 THEN
6492
6493 NULL;
6494
6495 END IF;
6496
6497
6498 -------------------------------------------------------
6499 -- Process Header Adjustments
6500 -------------------------------------------------------
6501
6502 -- Set Header Id on Hdr Adjustments
6503
6504 I := p_x_header_adj_tbl.FIRST;
6505 WHILE I IS NOT NULL LOOP
6506
6507 -- FOR I IN 1..p_x_header_adj_tbl.COUNT LOOP
6508
6509 IF l_debug_level > 0 THEN
6510 oe_debug_pub.add( 'SETTING HEADER ID ON HDR_ADJ_TBL' , 2 ) ;
6511 END IF;
6512
6513 IF p_x_header_adj_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE
6514 AND (p_x_header_adj_tbl(I).header_id IS NULL OR
6515 p_x_header_adj_tbl(I).header_id = FND_API.G_MISS_NUM)
6516 THEN
6517 IF p_x_header_rec.header_id IS NULL OR
6518 p_x_header_rec.header_id = FND_API.G_MISS_NUM THEN
6519 FND_MESSAGE.SET_NAME('ONT','OE_HEADER_MISSING');
6520 OE_MSG_PUB.Add;
6521 RAISE FND_API.G_EXC_ERROR;
6522 ELSE
6523 -- Copy parent_id.
6524 p_x_header_adj_tbl(I).header_id := p_x_header_rec.header_id;
6525 END IF;
6526 END IF;
6527
6528 -- This is added to prevent invalid upgraded orders
6529 IF I = p_x_header_adj_tbl.FIRST THEN
6530 IF (p_x_header_adj_tbl(I).header_id IS NOT NULL AND
6531 p_x_header_adj_tbl(I).header_id <> FND_API.G_MISS_NUM) THEN
6532 IF NOT Valid_Upgraded_Order(p_x_header_adj_tbl(I).header_id ) THEN
6533 RAISE FND_API.G_EXC_ERROR;
6534 END IF;
6535 END IF;
6536
6537 END IF;
6538
6539 I := p_x_header_adj_tbl.NEXT(I);
6540
6541 END LOOP;
6542
6543 -- Header_Adjs
6544
6545 IF p_x_header_adj_tbl.COUNT > 0 THEN
6546 IF l_debug_level > 0 THEN
6547 oe_debug_pub.add( 'BEFORE OE_ORDER_ADJ_PVT.HEADER_ADJS PROCESSING' , 2 ) ;
6548 END IF;
6549 oe_order_adj_pvt.Header_Adjs
6550 ( p_validation_level => p_validation_level
6551 , p_control_rec => p_control_rec
6552 , p_x_Header_Adj_tbl => p_x_header_adj_tbl
6553 , p_x_old_Header_Adj_tbl => l_old_header_Adj_tbl
6554 );
6555 END IF;
6556
6557 IF l_debug_level > 0 THEN
6558 oe_debug_pub.add( 'AFTER HEADER_ADJS PROCESSING' , 2 ) ;
6559 END IF;
6560 -- Perform Header_Adj group requests.
6561
6562 IF (p_control_rec.process AND
6563 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
6564 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
6565 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_HEADER_ADJ)
6566 THEN
6567
6568 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
6569 (p_entity_code => OE_GLOBALS.G_ENTITY_HEADER_ADJ
6570 ,p_delete => FND_API.G_TRUE
6571 ,x_return_status => l_return_status
6572 );
6573 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6574 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6575 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6576 RAISE FND_API.G_EXC_ERROR;
6577 END IF;
6578
6579
6580 END IF;
6581
6582
6583 -------------------------------------------------------
6584 -- Process Header Price Attributes
6585 -------------------------------------------------------
6586
6587 -- Set Header Id on Hdr Price Attributes
6588
6589 I := p_x_header_price_att_tbl.FIRST;
6590
6591 WHILE I IS NOT NULL LOOP
6592
6593 IF l_debug_level > 0 THEN
6594 oe_debug_pub.add( 'SETTING HEADER ID ON HDR_PRICE_ATT_TBL' , 2 ) ;
6595 END IF;
6596 IF p_x_header_price_att_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE
6597 AND (p_x_header_price_att_tbl(I).header_id IS NULL OR
6598 p_x_header_price_att_tbl(I).header_id = FND_API.G_MISS_NUM)
6599 THEN
6600 IF p_x_header_rec.header_id IS NULL OR
6601 p_x_header_rec.header_id = FND_API.G_MISS_NUM THEN
6602 FND_MESSAGE.SET_NAME('ONT','OE_HEADER_MISSING');
6603 OE_MSG_PUB.Add;
6604 RAISE FND_API.G_EXC_ERROR;
6605 ELSE
6606
6607 -- Copy parent_id.
6608
6609 p_x_header_price_Att_tbl(I).header_id := p_x_header_rec.header_id;
6610 END IF;
6611 END IF;
6612 I := p_x_header_price_Att_tbl.NEXT(I);
6613 END LOOP;
6614
6615 -- Header_Price_Atts
6616
6617 IF p_x_header_price_Att_tbl.COUNT > 0 THEN
6618 IF l_debug_level > 0 THEN
6619 oe_debug_pub.add( 'BEFORE OE_ORDER_ADJ_PVT.HEADER_PRICE_ATTS PROCESSING' , 2 ) ;
6620 END IF;
6621 oe_order_adj_pvt.Header_Price_Atts
6622 ( p_validation_level => p_validation_level
6623 , p_control_rec => p_control_rec
6624 , p_x_Header_Price_Att_tbl => p_x_header_price_Att_tbl
6625 , p_x_old_Header_Price_Att_tbl => l_old_header_Price_Att_tbl
6626 );
6627 END IF;
6628
6629 IF l_debug_level > 0 THEN
6630 oe_debug_pub.add( 'AFTER HEADER_PRICE_ATTS PROCESSING' , 2 ) ;
6631 END IF;
6632 -- Perform Header_Price_Att group requests.
6633
6634 IF (p_control_rec.process AND
6635 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
6636 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL
6637 OR
6638 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_Header_Price_Att
6639 )
6640 THEN
6641
6642 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
6643 (p_entity_code => OE_GLOBALS.G_ENTITY_Header_Price_Att
6644 ,p_delete => FND_API.G_TRUE
6645 ,x_return_status => l_return_status
6646 );
6647 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6648 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6649 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6650 RAISE FND_API.G_EXC_ERROR;
6651 END IF;
6652
6653
6654 END IF;
6655
6656
6657 -------------------------------------------------------
6658 -- Process Header Adj Attributes
6659 -------------------------------------------------------
6660
6661 -- Set Header Id on Hdr Adj. Attributes
6662
6663 I := p_x_header_adj_Att_tbl.FIRST;
6664
6665 WHILE I IS NOT NULL LOOP
6666
6667 IF l_debug_level > 0 THEN
6668 oe_debug_pub.add( 'SETTING PRICE ADJUSTMENT ID ON HDR_ADJ_ATTBS' , 2 ) ;
6669 END IF;
6670 IF p_x_header_adj_att_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE
6671 AND (p_x_header_adj_att_tbl(I).price_adjustment_id IS NULL OR
6672 p_x_header_adj_att_tbl(I).price_adjustment_id = FND_API.G_MISS_NUM)
6673 THEN
6674
6675 IF p_x_header_adj_Tbl.exists(p_x_header_adj_att_tbl(I).Adj_index)
6676 Then
6677 -- Copy parent_id.
6678
6679 p_x_header_adj_Att_tbl(I).price_adjustment_id :=
6680 p_x_header_adj_Tbl(p_x_header_adj_att_tbl(I).adj_index).price_adjustment_id;
6681 ELSE
6682 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
6683 THEN
6684 IF l_debug_level > 0 THEN
6685 oe_debug_pub.add( 'INVALID ADJ INDEX '|| TO_CHAR ( P_X_HEADER_ADJ_ATT_TBL ( I ) .ADJ_INDEX ) || 'ON HEADER ADJ ATTRIBUTES' , 2 ) ;
6686 END IF;
6687 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6688 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
6689 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Header_Adj_Attribs');
6690 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
6691 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',p_x_header_adj_att_tbl(I).adj_index);
6692 OE_MSG_PUB.Add;
6693 END IF;
6694 END IF;
6695
6696 END IF;
6697 I := p_x_header_adj_Att_tbl.NEXT(I);
6698 END LOOP;
6699
6700 -- Header_Adj_Atts
6701 IF p_x_header_adj_Att_tbl.COUNT > 0 THEN
6702
6703 IF l_debug_level > 0 THEN
6704 oe_debug_pub.add( 'BEFORE OE_ORDER_ADJ_PVT.HEADER_ADJ_ATTS PROCESSING' , 2 ) ;
6705 END IF;
6706 oe_order_adj_pvt.Header_Adj_Atts
6707 ( p_validation_level => p_validation_level
6708 , p_control_rec => p_control_rec
6709 , p_x_Header_Adj_Att_tbl => p_x_header_adj_Att_tbl
6710 , p_x_old_Header_Adj_Att_tbl => l_old_header_Adj_Att_tbl
6711 );
6712
6713 IF l_debug_level > 0 THEN
6714 oe_debug_pub.add( 'AFTER HEADER_ADJ_ATTS PROCESSING' , 2 ) ;
6715 END IF;
6716
6717 END IF;
6718
6719
6720 -------------------------------------------------------
6721 -- Process Header Adjustment Associations
6722 -------------------------------------------------------
6723
6724 -- Set Header Id on Hdr Adjustment Associations
6725
6726 I := p_x_header_adj_Assoc_tbl.FIRST;
6727
6728 WHILE I IS NOT NULL LOOP
6729
6730 IF l_debug_level > 0 THEN
6731 oe_debug_pub.add( 'SETTING HEADER ID ON HDR_ADJ_ASSOC_TBL' , 2 ) ;
6732 END IF;
6733 IF p_x_header_adj_assoc_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE
6734 AND (p_x_header_adj_assoc_tbl(I).Price_Adjustment_id IS NULL OR
6735 p_x_header_adj_assoc_tbl(I).Price_Adjustment_id = FND_API.G_MISS_NUM)
6736 THEN
6737
6738 IF p_x_header_adj_Tbl.exists(p_x_header_adj_assoc_tbl(I).Adj_Index) Then
6739 -- Copy parent_id.
6740
6741 p_x_header_adj_Assoc_tbl(I).price_adjustment_id :=
6742 p_x_header_adj_Tbl(p_x_header_adj_assoc_tbl(I).adj_index).price_adjustment_id;
6743 ELSE
6744 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
6745 THEN
6746 IF l_debug_level > 0 THEN
6747 oe_debug_pub.add( 'INVALID ADJ INDEX '|| TO_CHAR ( P_X_HEADER_ADJ_ASSOC_TBL ( I ) .ADJ_INDEX ) || 'ON HEADER ADJ ATTRIBUTES' , 2 ) ;
6748 END IF;
6749 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6750 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
6751 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Header_Adj_Assocs');
6752 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
6753 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',p_x_header_adj_assoc_tbl(I).adj_index);
6754 OE_MSG_PUB.Add;
6755 END IF;
6756 END IF;
6757
6758 END IF;
6759
6760 IF p_x_header_adj_assoc_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE
6761 AND (p_x_header_adj_assoc_tbl(I).rltd_Price_Adj_Id IS NULL OR
6762 p_x_header_adj_assoc_tbl(I).rltd_Price_Adj_Id = FND_API.G_MISS_NUM)
6763 THEN
6764
6765 IF p_x_header_adj_Tbl.exists(p_x_header_adj_assoc_tbl(I).Rltd_Adj_Index) Then
6766 -- Copy parent_id.
6767
6768 p_x_header_adj_Assoc_tbl(I).rltd_Price_Adj_Id :=
6769 p_x_header_adj_Tbl(p_x_header_adj_assoc_tbl(I).Rltd_Adj_Index).Price_adjustment_id;
6770 END IF;
6771
6772 END IF;
6773 I := p_x_header_adj_Assoc_tbl.NEXT(I);
6774 END LOOP;
6775
6776 -- Header_Adj_Assocs
6777
6778 IF p_x_header_adj_Assoc_tbl.COUNT > 0 THEN
6779
6780 IF l_debug_level > 0 THEN
6781 oe_debug_pub.add( 'BEFORE OE_ORDER_ADJ_PVT.HEADER_ADJ_ASSOCS PROCESSING' , 2 ) ;
6782 END IF;
6783 oe_order_adj_pvt.Header_Adj_Assocs
6784 ( p_validation_level => p_validation_level
6785 , p_control_rec => p_control_rec
6786 , p_x_Header_Adj_Assoc_tbl => p_x_header_adj_Assoc_tbl
6787 , p_x_old_Header_Adj_Assoc_tbl => l_old_header_Adj_Assoc_tbl
6788 );
6789
6790 IF l_debug_level > 0 THEN
6791 oe_debug_pub.add( 'AFTER HEADER_ADJ_ASSOCS PROCESSING' , 2 ) ;
6792 END IF;
6793 END IF;
6794
6795
6796 -------------------------------------------------------
6797 -- Process Header Sales Credits
6798 -------------------------------------------------------
6799
6800
6801 -- Set Header Id on Sales Credits
6802
6803 I := p_x_header_scredit_tbl.FIRST;
6804 WHILE I IS NOT NULL LOOP
6805
6806 IF l_debug_level > 0 THEN
6807 oe_debug_pub.add( 'SETTING HEADER_ID ON HEADER_SCREDIT_TBL' , 2 ) ;
6808 END IF;
6809 IF p_x_header_scredit_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE
6810 AND (p_x_header_scredit_tbl(I).header_id IS NULL OR
6811 p_x_header_scredit_tbl(I).header_id = FND_API.G_MISS_NUM)
6812 THEN
6813
6814 IF p_x_header_rec.header_id IS NULL OR
6815 p_x_header_rec.header_id = FND_API.G_MISS_NUM THEN
6816 FND_MESSAGE.SET_NAME('ONT','OE_HEADER_MISSING');
6817 OE_MSG_PUB.Add;
6818 RAISE FND_API.G_EXC_ERROR;
6819 ELSE
6820 -- Copy parent_id.
6821
6822 p_x_header_scredit_tbl(I).header_id := p_x_header_rec.header_id;
6823 END IF;
6824 END IF;
6825
6826 I := p_x_header_scredit_tbl.NEXT(I);
6827 END LOOP;
6828
6829 -- Header_Scredits
6830
6831 IF p_x_header_scredit_tbl.COUNT > 0 THEN
6832
6833 IF l_debug_level > 0 THEN
6834 oe_debug_pub.add( 'BEFORE HEADER_SCREDITS PROCESSING' , 2 ) ;
6835 END IF;
6836 Header_Scredits
6837 ( p_validation_level => p_validation_level
6838 , p_control_rec => p_control_rec
6839 , p_x_Header_Scredit_tbl => p_x_header_scredit_tbl
6840 , p_x_old_Header_Scredit_tbl => l_old_header_Scredit_tbl
6841 , x_return_status => l_return_status
6842 );
6843 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6844 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6845 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6846 IF p_control_rec.process_partial THEN
6847 x_return_status := FND_API.G_RET_STS_ERROR;
6848 ELSE
6849 RAISE FND_API.G_EXC_ERROR;
6850 END IF;
6851 END IF;
6852 IF l_debug_level > 0 THEN
6853 oe_debug_pub.add( 'AFTER HEADER_SCREDITS PROCESSING' , 2 ) ;
6854 END IF;
6855
6856 END IF;
6857
6858 -- Perform Header_Scredit group requests.
6859
6860 IF (p_control_rec.process AND
6861 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
6862 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
6863 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_HEADER_SCREDIT)
6864 THEN
6865
6866 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
6867 (p_entity_code => OE_GLOBALS.G_ENTITY_Header_Scredit
6868 ,p_delete => FND_API.G_TRUE
6869 ,x_return_status => l_return_status
6870 );
6871 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6872 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6873 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6874 RAISE FND_API.G_EXC_ERROR;
6875 END IF;
6876
6877 END IF;
6878
6879
6880 -- Get header_id from the header and put it on the line.
6881
6882 -- Kris = decide if
6883 -- Header id may not be passed on the header record if the operation is none
6884 -- I think we should pass header_id on the header rec all the time
6885
6886 /*
6887 IF p_x_line_tbl.COUNT > 0 THEN
6888
6889 For k in p_x_line_tbl.first .. p_x_line_tbl.last LOOP
6890
6891 IF (p_x_line_tbl(k).header_id = FND_API.G_MISS_NUM
6892 OR p_x_line_tbl(k).header_id is null ) THEN
6893
6894 -- Kris do not loop through the lines unless they have the right header_id
6895 -- If people pass in a header_id with a bogus value, the record should be ignored
6896
6897 p_x_line_tbl(k).header_id := p_x_header_rec.header_id;
6898
6899 END IF;
6900
6901 End Loop;
6902
6903 END IF;
6904 */
6905
6906
6907 -------------------------------------------------------
6908 -- Process Header Payments
6909 -------------------------------------------------------
6910
6911 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
6912 -- Set Header Id on Payments
6913
6914 I := p_x_header_payment_tbl.FIRST;
6915 WHILE I IS NOT NULL LOOP
6916
6917 IF l_debug_level > 0 THEN
6918 oe_debug_pub.add( 'SETTING HEADER_ID ON HEADER_PAYMENT_TBL' , 2 ) ;
6919 END IF;
6920 IF p_x_header_payment_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE
6921 AND (p_x_header_payment_tbl(I).header_id IS NULL OR
6922 p_x_header_payment_tbl(I).header_id = FND_API.G_MISS_NUM)
6923 THEN
6924
6925 IF p_x_header_rec.header_id IS NULL OR
6926 p_x_header_rec.header_id = FND_API.G_MISS_NUM THEN
6927 FND_MESSAGE.SET_NAME('ONT','OE_HEADER_MISSING');
6928 OE_MSG_PUB.Add;
6929 RAISE FND_API.G_EXC_ERROR;
6930 ELSE
6931 -- Copy parent_id.
6932
6933 p_x_header_payment_tbl(I).header_id := p_x_header_rec.header_id;
6934 END IF;
6935 END IF;
6936
6937 I := p_x_header_payment_tbl.NEXT(I);
6938 END LOOP;
6939
6940 -- Header_Payments
6941
6942 IF p_x_header_payment_tbl.COUNT > 0 THEN
6943
6944 IF l_debug_level > 0 THEN
6945 oe_debug_pub.add( 'BEFORE HEADER_PAYMENTS PROCESSING' , 2 ) ;
6946 END IF;
6947 Header_Payments
6948 ( p_validation_level => p_validation_level
6949 , p_control_rec => p_control_rec
6950 , p_x_Header_Payment_tbl => p_x_header_Payment_tbl
6951 , p_x_old_Header_Payment_tbl => l_old_header_Payment_tbl
6952 , x_return_status => l_return_status
6953 );
6954 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6955 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6956 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6957 IF p_control_rec.process_partial THEN
6958 x_return_status := FND_API.G_RET_STS_ERROR;
6959 ELSE
6960 RAISE FND_API.G_EXC_ERROR;
6961 END IF;
6962 END IF;
6963 IF l_debug_level > 0 THEN
6964 oe_debug_pub.add( 'AFTER HEADER_PAYMENTS PROCESSING' , 2 ) ;
6965 END IF;
6966
6967 END IF;
6968
6969 -- Perform Header_Payment group requests.
6970
6971 IF (p_control_rec.process AND
6972 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
6973 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
6974 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_HEADER_PAYMENT)
6975 THEN
6976
6977 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
6978 (p_entity_code => OE_GLOBALS.G_ENTITY_Header_Payment
6979 ,p_delete => FND_API.G_TRUE
6980 ,x_return_status => l_return_status
6981 );
6982 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6983 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6984 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6985 RAISE FND_API.G_EXC_ERROR;
6986 END IF;
6987
6988 END IF;
6989 END IF;
6990 -------------------------------------------------------
6991 -- Process Lines
6992 -------------------------------------------------------
6993
6994 I := p_x_line_tbl.FIRST;
6995
6996 WHILE I IS NOT NULL LOOP
6997
6998 --Bug 2790512: Prevent processing of line if operation is invalid
6999 --Bug 2878121: Ignore NULL operation code
7000 IF p_x_line_tbl(I).operation IS NOT NULL AND
7001 p_x_line_tbl(I).operation NOT IN (OE_GLOBALS.G_OPR_CREATE,
7002 OE_GLOBALS.G_OPR_DELETE, OE_GLOBALS.G_OPR_UPDATE,
7003 OE_GLOBALS.G_OPR_INSERT, OE_GLOBALS.G_OPR_NONE) THEN
7004 FND_MESSAGE.SET_NAME('ONT','OE_OI_OPERATION_CODE');
7005 OE_MSG_PUB.Add;
7006 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7007 END IF;
7008
7009 IF p_x_line_tbl(I).operation = oe_globals.g_opr_update
7010 AND p_x_line_tbl(I).split_action_code = 'SPLIT' THEN
7011
7012 -- Negotiation check has been added for bug 4758902
7013 BEGIN
7014 SELECT transaction_phase_code
7015 INTO l_transaction_phase_code
7016 FROM oe_order_lines_all
7017 WHERE line_id = p_x_line_tbl(I).line_id;
7018 EXCEPTION
7019 WHEN NO_DATA_FOUND THEN
7020 oe_debug_pub.add(' No Transaction Phase Code for parent split line.',1);
7021 NULL;
7022 WHEN OTHERS THEN
7023 oe_debug_pub.add(' OTHERS: No Transaction Phase Code for parent split line.',1);
7024 NULL;
7025 END;
7026
7027 IF NVL(l_transaction_phase_code,'F') = 'N' THEN
7028 oe_debug_pub.add(' Line Id : '||p_x_line_tbl(I).line_id||' cannot be split. It is in Negotiation Phase.');
7029 FND_MESSAGE.SET_NAME('ONT','OE_PC_SPLIT_VIOLATION');
7030 FND_MESSAGE.SET_TOKEN('OBJECT',p_x_line_tbl(I).line_id);
7031 FND_MESSAGE.SET_TOKEN('REASON','Line is in Negotiation Phase');
7032 OE_MSG_PUB.Add;
7033 RAISE FND_API.G_EXC_ERROR;
7034 ELSE
7035 l_call_split := TRUE;
7036 END IF;
7037 END IF;
7038
7039 -- START: CHECK IF ALL LINES BELONG TO THE SAME ORDER
7040
7041 -- Retrieve the header ID, either from the header record
7042 -- or from the first line
7043 IF (I = p_x_line_tbl.FIRST) THEN
7044 IF (p_x_header_rec.header_id IS NOT NULL AND
7045 p_x_header_rec.header_id <> FND_API.G_MISS_NUM) THEN
7046 l_header_id := p_x_header_rec.header_id;
7047 ELSIF (p_x_line_tbl(I).header_id IS NOT NULL AND
7048 p_x_line_tbl(I).header_id <> FND_API.G_MISS_NUM) THEN
7049 l_header_id := p_x_line_tbl(I).header_id;
7050 END IF;
7051 END IF;
7052
7053 IF p_x_line_tbl(I).operation <> OE_GLOBALS.G_OPR_CREATE
7054 AND (p_x_line_tbl(I).header_id IS NULL OR
7055 p_x_line_tbl(I).header_id = FND_API.G_MISS_NUM)
7056 THEN
7057 IF (l_header_id IS NOT NULL AND
7058 l_header_id <> FND_API.G_MISS_NUM) THEN
7059 p_x_line_tbl(I).header_id := l_header_id;
7060 ELSE
7061 oe_line_util.query_header
7062 (p_line_id => p_x_line_tbl(I).line_id,
7063 x_header_id => l_header_id);
7064 p_x_line_tbl(I).header_id := l_header_id;
7065 END IF;
7066 END IF;
7067
7068 -- Copy the parent ID (header ID), if not passed, on
7069 -- the record for CREATE operations
7070 IF p_x_line_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE THEN
7071 IF (p_x_line_tbl(I).header_id IS NULL OR
7072 p_x_line_tbl(I).header_id = FND_API.G_MISS_NUM)
7073 THEN
7074 -- Copy parent_id.
7075 p_x_line_tbl(I).header_id := l_header_id;
7076 END IF;
7077 END IF;
7078
7079 -- Raise error if the header ID for the line is different
7080 -- from header ID on the header record or other lines
7081 IF (l_header_id IS NOT NULL AND
7082 l_header_id <> FND_API.G_MISS_NUM) THEN
7083 IF p_x_line_tbl(I).header_id <> l_header_id THEN
7084 fnd_message.set_name('ONT', 'OE_HEADER_MISSING');
7085 oe_msg_pub.add;
7086 RAISE FND_API.G_EXC_ERROR;
7087 END IF;
7088 END IF;
7089
7090 -- END: CHECK IF ALL LINES BELONG TO THE SAME ORDER
7091
7092 I := p_x_line_tbl.NEXT(I);
7093
7094 END LOOP;
7095
7096
7097 -- Pre Split Process
7098 IF l_call_split THEN
7099 OE_Split_Util.Check_Split_Course
7100 ( p_x_line_tbl => p_x_line_tbl,
7101 p_x_line_adj_tbl => p_x_line_adj_tbl,
7102 p_x_line_scredit_tbl => p_x_line_scredit_tbl
7103 );
7104 END IF;
7105
7106 -- Lines
7107
7108 IF p_x_line_tbl.COUNT > 0 THEN
7109
7110 IF l_debug_level > 0 THEN
7111 oe_debug_pub.add( 'BEFORE LINES PROCESSING' , 2 ) ;
7112 END IF;
7113 Lines
7114 ( p_validation_level => p_validation_level
7115 , p_control_rec => p_control_rec
7116 , p_x_line_tbl => p_x_line_tbl
7117 , p_x_old_line_tbl => l_old_line_tbl
7118 , x_return_status => l_return_status
7119 );
7120 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7121 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7122 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
7123 IF p_control_rec.process_partial THEN
7124 x_return_status := FND_API.G_RET_STS_ERROR;
7125 ELSE
7126 RAISE FND_API.G_EXC_ERROR;
7127 END IF;
7128 END IF;
7129 IF l_debug_level > 0 THEN
7130 oe_debug_pub.add( 'AFTER LINES PROCESSING' , 2 ) ;
7131 END IF;
7132
7133 END IF;
7134
7135
7136 I := p_x_line_scredit_tbl.FIRST;
7137 WHILE I IS NOT NULL LOOP
7138
7139 IF l_debug_level > 0 THEN
7140 oe_debug_pub.add( 'SETTING HEADER/LINE IDS ON LINE SC TABLE' ) ;
7141 END IF;
7142 IF p_x_line_scredit_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE
7143 AND (p_x_line_scredit_tbl(I).line_id IS NULL OR
7144 p_x_line_scredit_tbl(I).line_id = FND_API.G_MISS_NUM)
7145 THEN
7146 IF l_debug_level > 0 THEN
7147 oe_debug_pub.add( 'SETTING LINE IDS ON LINE SC TABLE' , 2 ) ;
7148 END IF;
7149
7150 -- Check If parent exists.
7151
7152 IF p_x_line_tbl.EXISTS(p_x_line_scredit_tbl(I).line_index) THEN
7153
7154 -- Copy parent_id.
7155
7156 p_x_line_scredit_tbl(I).line_id := p_x_line_tbl(p_x_line_scredit_tbl(I).line_index).line_id;
7157 p_x_line_scredit_tbl(I).header_id := p_x_line_tbl(p_x_line_scredit_tbl(I).line_index).header_id;
7158
7159 -- Following procedure is called to fix bug 2482365
7160 -- If sales credit info is passed by the user we will honor it.
7161 -- Any sales credit record created for this line so far shall be deleted.
7162
7163 OE_Line_Scredit_Util.Delete_Row(p_line_id =>p_x_line_scredit_tbl(I).line_id);
7164 ELSE
7165
7166 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
7167 THEN
7168 IF l_debug_level > 0 THEN
7169 oe_debug_pub.add( 'INVALID LINE INDEX ' ||TO_CHAR ( L_LINE_INDEX ) ||'ON LINE SALES CREDITS' , 2 ) ;
7170 END IF;
7171 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7172 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
7173 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Line_Scredit');
7174 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
7175 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',p_x_line_scredit_tbl(I).line_index);
7176 OE_MSG_PUB.Add;
7177
7178 END IF;
7179 END IF;
7180 END IF;
7181
7182 I := p_x_line_scredit_tbl.NEXT(I);
7183 END LOOP;
7184
7185
7186 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
7187 I := p_x_line_payment_tbl.FIRST;
7188 WHILE I IS NOT NULL LOOP
7189
7190 IF l_debug_level > 0 THEN
7191 oe_debug_pub.add( 'SETTING HEADER/LINE IDS ON LINE SC TABLE' ) ;
7192 END IF;
7193 IF p_x_line_payment_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE
7194 AND (p_x_line_payment_tbl(I).line_id IS NULL OR
7195 p_x_line_payment_tbl(I).line_id = FND_API.G_MISS_NUM)
7196 THEN
7197 IF l_debug_level > 0 THEN
7198 oe_debug_pub.add( 'SETTING LINE IDS ON LINE PAYMENT TABLE' , 2 ) ;
7199 END IF;
7200
7201 -- Check If parent exists.
7202
7203 IF p_x_line_tbl.EXISTS(p_x_line_payment_tbl(I).line_index) THEN
7204
7205 -- Copy parent_id.
7206
7207 p_x_line_payment_tbl(I).line_id := p_x_line_tbl(p_x_line_payment_tbl(I).line_index).line_id;
7208 p_x_line_payment_tbl(I).header_id := p_x_line_tbl(p_x_line_payment_tbl(I).line_index).header_id;
7209
7210 ELSE
7211
7212 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
7213 THEN
7214 IF l_debug_level > 0 THEN
7215 oe_debug_pub.add( 'INVALID LINE INDEX ' ||TO_CHAR ( L_LINE_INDEX ) ||'ON LINE SALES CREDITS' , 2 ) ;
7216 END IF;
7217 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7218 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
7219 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Line_Payment');
7220 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
7221 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',p_x_line_payment_tbl(I).line_index);
7222 OE_MSG_PUB.Add;
7223
7224 END IF;
7225 END IF;
7226 END IF;
7227
7228 I := p_x_line_payment_tbl.NEXT(I);
7229 END LOOP;
7230 END IF;
7231
7232
7233 I := p_x_line_adj_tbl.FIRST;
7234 WHILE I IS NOT NULL LOOP
7235
7236 IF l_debug_level > 0 THEN
7237 oe_debug_pub.add( 'SETTING HEADER/LINE IDS ON LINE ADJ TABLE' , 2 ) ;
7238 END IF;
7239
7240 IF p_x_line_adj_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE
7241 AND (p_x_line_adj_tbl(I).line_id IS NULL OR
7242 p_x_line_adj_tbl(I).line_id = FND_API.G_MISS_NUM)
7243 THEN
7244
7245 IF l_debug_level > 0 THEN
7246 oe_debug_pub.add( 'SETTING LINE IDS ON LINE ADJ TABLE' , 2 ) ;
7247 END IF;
7248 -- Check If parent exists.
7249
7250 IF p_x_line_adj_tbl(I).line_index <> fnd_api.g_miss_num and
7251 p_x_line_tbl.EXISTS(p_x_line_adj_tbl(I).line_index) THEN
7252
7253 -- Copy parent_id.
7254
7255 p_x_line_adj_tbl(I).line_id := p_x_line_tbl(p_x_Line_adj_tbl(I).line_index).line_id;
7256 p_x_line_adj_tbl(I).header_id := p_x_line_tbl(p_x_Line_adj_tbl(I).line_index).header_id;
7257
7258 ELSIF p_x_line_adj_tbl(I).header_id is not null and
7259 p_x_line_adj_tbl(I).header_id <> FND_API.G_MISS_NUM Then
7260 -- Treat the adjustment record as a header_adjustment record
7261 IF l_debug_level > 0 THEN
7262 oe_debug_pub.add( 'TREATING THE RECORD AS HEADER_ADJUSTMENT' ) ;
7263 END IF;
7264 ELSE
7265
7266 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
7267 THEN
7268 IF l_debug_level > 0 THEN
7269 oe_debug_pub.add( 'INVALID LINE INDEX ' ||TO_CHAR ( L_LINE_INDEX ) ||'ON PRICE ADJUSTMENTS' , 2 ) ;
7270 END IF;
7271 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7272
7273 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
7274 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Line_Adj');
7275 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
7276 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',p_x_line_adj_tbl(I).line_index);
7277 OE_MSG_PUB.Add;
7278
7279 END IF;
7280 END IF;
7281 END IF;
7282
7283 I := p_x_line_adj_tbl.NEXT(I);
7284 END LOOP;
7285
7286 -- Perform line group requests.
7287
7288 IF (p_control_rec.process AND
7289 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
7290 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
7291 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_LINE)
7292 THEN
7293 IF l_debug_level > 0 THEN
7294 oe_debug_pub.add( 'PROCESS LINE REQUESTS' ) ;
7295 END IF;
7296
7297 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
7298 (p_entity_code => OE_GLOBALS.G_ENTITY_LINE
7299 ,p_delete => FND_API.G_TRUE
7300 ,x_return_status => l_return_status
7301 );
7302 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7303 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7304 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
7305 RAISE FND_API.G_EXC_ERROR;
7306 END IF;
7307
7308 END IF;
7309
7310
7311 -------------------------------------------------------
7312 -- Process Lines Adjustments
7313 -------------------------------------------------------
7314
7315 IF p_x_line_adj_tbl.COUNT > 0 THEN
7316
7317 -- Line_Adjs
7318
7319 oe_order_adj_pvt.Line_Adjs
7320 ( p_validation_level => p_validation_level
7321 , p_control_rec => p_control_rec
7322 , p_x_Line_Adj_tbl => p_x_line_adj_tbl
7323 , p_x_old_Line_Adj_tbl => l_old_line_Adj_tbl
7324 );
7325
7326 END IF;
7327
7328 -- Perform Line_Adj group requests.
7329
7330 IF (p_control_rec.process AND
7331 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
7332 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
7333 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_LINE_ADJ)
7334 THEN
7335
7336 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
7337 (p_entity_code => OE_GLOBALS.G_ENTITY_LINE_ADJ
7338 ,p_delete => FND_API.G_TRUE
7339 ,x_return_status => l_return_status
7340 );
7341 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7342 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7343 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
7344 RAISE FND_API.G_EXC_ERROR;
7345 END IF;
7346
7347 END IF;
7348
7349 -------------------------------------------------------
7350 -- Process Line Sales Credits
7351 -------------------------------------------------------
7352
7353 -- Line_Scredits
7354
7355 IF p_x_line_scredit_tbl.COUNT > 0 THEN
7356
7357 Line_Scredits
7358 ( p_validation_level => p_validation_level
7359 , p_control_rec => p_control_rec
7360 , p_x_Line_Scredit_tbl => p_x_line_scredit_tbl
7361 , p_x_old_Line_Scredit_tbl => l_old_line_Scredit_tbl
7362 , x_return_status => l_return_status
7363 );
7364 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7365 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7366 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
7367 IF p_control_rec.process_partial THEN
7368 x_return_status := FND_API.G_RET_STS_ERROR;
7369 ELSE
7370 RAISE FND_API.G_EXC_ERROR;
7371 END IF;
7372 END IF;
7373
7374 END IF;
7375
7376 -- Perform Line_Scredit group requests.
7377
7378 IF (p_control_rec.process AND
7379 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
7380 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
7381 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_LINE_SCREDIT)
7382 THEN
7383
7384 IF l_debug_level > 0 THEN
7385 oe_debug_pub.add( 'PROCESSING DELAYED REQUESTS FOR LINES' , 2 ) ;
7386 END IF;
7387
7388 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
7389 (p_entity_code => OE_GLOBALS.G_ENTITY_Line_Scredit
7390 ,p_delete => FND_API.G_TRUE
7391 ,x_return_status => l_return_status
7392 );
7393
7394 IF l_debug_level > 0 THEN
7395 oe_debug_pub.add( 'PROCESSED DELAYED REQUESTS FOR LINES' , 2 ) ;
7396 END IF;
7397
7398 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7399 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7400 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
7401 RAISE FND_API.G_EXC_ERROR;
7402 END IF;
7403
7404 END IF;
7405
7406
7407 -------------------------------------------------------
7408 -- Process Line Payments
7409 -------------------------------------------------------
7410
7411 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
7412 -- Line_Payments
7413
7414 IF p_x_line_payment_tbl.COUNT > 0 THEN
7415
7416 Line_Payments
7417 ( p_validation_level => p_validation_level
7418 , p_control_rec => p_control_rec
7419 , p_x_Line_Payment_tbl => p_x_line_Payment_tbl
7420 , p_x_old_Line_Payment_tbl => l_old_line_Payment_tbl
7421 , x_return_status => l_return_status
7422 );
7423 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7424 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7425 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
7426 IF p_control_rec.process_partial THEN
7427 x_return_status := FND_API.G_RET_STS_ERROR;
7428 ELSE
7429 RAISE FND_API.G_EXC_ERROR;
7430 END IF;
7431 END IF;
7432
7433 END IF;
7434
7435 -- Perform Line_Payment group requests.
7436
7437 IF (p_control_rec.process AND
7438 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
7439 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
7440 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_LINE_PAYMENT)
7441 THEN
7442
7443 IF l_debug_level > 0 THEN
7444 oe_debug_pub.add( 'PROCESSING DELAYED REQUESTS FOR LINES' , 2 ) ;
7445 END IF;
7446
7447 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
7448 (p_entity_code => OE_GLOBALS.G_ENTITY_LINE_PAYMENT
7449 ,p_delete => FND_API.G_TRUE
7450 ,x_return_status => l_return_status
7451 );
7452
7453 IF l_debug_level > 0 THEN
7454 oe_debug_pub.add( 'PROCESSED DELAYED REQUESTS FOR LINES' , 2 ) ;
7455 END IF;
7456
7457 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7458 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7459 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
7460 RAISE FND_API.G_EXC_ERROR;
7461 END IF;
7462
7463 END IF;
7464 END IF;
7465
7466 -------------------------------------------------------
7467 -- Process Lot Serials
7468 -------------------------------------------------------
7469
7470 IF p_x_lot_serial_tbl.COUNT > 0 THEN
7471
7472 -- Load parent key if missing and operation is create.
7473
7474 I := p_x_lot_serial_tbl.FIRST;
7475 WHILE I IS NOT NULL LOOP
7476
7477 IF p_x_lot_serial_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE
7478 AND (p_x_lot_serial_tbl(I).line_id IS NULL OR
7479 p_x_lot_serial_tbl(I).line_id = FND_API.G_MISS_NUM)
7480 THEN
7481
7482 -- Check If parent exists.
7483
7484 IF p_x_line_tbl.EXISTS(p_x_lot_serial_tbl(I).line_index) THEN
7485
7486 -- Copy parent_id.
7487
7488 p_x_lot_serial_tbl(I).line_id := p_x_line_tbl(p_x_Lot_serial_tbl(I).line_index).line_id;
7489
7490 ELSE
7491
7492 IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_ERROR)
7493 THEN
7494
7495 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
7496 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Lot_Serial');
7497 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
7498 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',p_x_lot_serial_tbl(I).line_index);
7499 oe_msg_pub.Add;
7500
7501 END IF;
7502 END IF;
7503 END IF;
7504 I := p_x_lot_serial_tbl.NEXT(I);
7505 END LOOP;
7506
7507 -- Lot_Serials
7508
7509 Lot_Serials
7510 ( p_validation_level => p_validation_level
7511 , p_control_rec => p_control_rec
7512 , p_x_Lot_Serial_tbl => p_x_lot_serial_tbl
7513 , p_x_old_Lot_Serial_tbl => l_old_lot_Serial_tbl
7514 , x_return_status => l_return_status
7515 );
7516 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7517 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7518 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
7519 IF p_control_rec.process_partial THEN
7520 x_return_status := FND_API.G_RET_STS_ERROR;
7521 ELSE
7522 RAISE FND_API.G_EXC_ERROR;
7523 END IF;
7524 END IF;
7525
7526 END IF;
7527
7528 -- Perform Lot_Serial group requests.
7529
7530 IF (p_control_rec.process AND
7531 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
7532 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
7533 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_LOT_SERIAL)
7534 THEN
7535
7536 NULL;
7537
7538 END IF;
7539
7540 -------------------------------------------------------
7541 -- Process Line Price Attributes
7542 -------------------------------------------------------
7543
7544 -- Process line Price Attributes
7545
7546 I := p_x_line_price_Att_tbl.FIRST;
7547 WHILE I IS NOT NULL LOOP
7548
7549 IF l_debug_level > 0 THEN
7550 oe_debug_pub.add( 'SETTING HEADER/LINE IDS ON LINE ATTRIBUTES TABLE' , 2 ) ;
7551 END IF;
7552 IF p_x_line_price_att_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE
7553 AND (p_x_line_price_att_tbl(I).line_id IS NULL OR
7554 p_x_line_price_att_tbl(I).line_id = FND_API.G_MISS_NUM)
7555 THEN
7556
7557 IF l_debug_level > 0 THEN
7558 oe_debug_pub.add( 'SETTING LINE IDS ON LINE ATTRIB TABLE' , 2 ) ;
7559 END IF;
7560 -- Check If parent exists.
7561
7562 IF p_x_line_tbl.EXISTS(p_x_line_price_att_tbl(I).line_index) THEN
7563
7564 -- Copy parent_id.
7565
7566 p_x_line_price_Att_tbl(I).line_id := p_x_line_tbl(p_x_line_price_att_tbl(I).line_index).line_id;
7567 p_x_line_price_Att_tbl(I).header_id := p_x_line_tbl(p_x_line_price_att_tbl(I).line_index).header_id;
7568
7569 ELSE
7570
7571 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
7572 THEN
7573 IF l_debug_level > 0 THEN
7574 oe_debug_pub.add( 'INVALID LINE INDEX ' ||TO_CHAR ( P_X_LINE_PRICE_ATT_TBL ( I ) .LINE_INDEX ) ||'ON PRICE ADJUSTMENTS' , 2 ) ;
7575 END IF;
7576 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7577
7578 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
7579 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Line_Price_Att');
7580 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
7581 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',p_x_line_price_att_tbl(I).line_index);
7582 OE_MSG_PUB.Add;
7583
7584 END IF;
7585 END IF;
7586 END IF;
7587 I := p_x_line_price_Att_tbl.NEXT(I);
7588 END LOOP;
7589
7590 -- Line_Attribs
7591
7592 IF p_x_line_price_Att_tbl.COUNT > 0 THEN
7593
7594 oe_order_adj_pvt.Line_Price_Atts
7595 ( p_validation_level => p_validation_level
7596 , p_control_rec => p_control_rec
7597 , p_x_Line_Price_Att_tbl => p_x_line_price_Att_tbl
7598 , p_x_old_Line_Price_Att_tbl => l_old_line_Price_Att_tbl
7599 );
7600
7601 END IF;
7602
7603 -- Perform Line_Price_Att group requests.
7604
7605 IF (p_control_rec.process AND
7606 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
7607 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
7608 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_Line_Price_Att)
7609 THEN
7610
7611 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
7612 (p_entity_code => OE_GLOBALS.G_ENTITY_Line_Price_Att
7613 ,p_delete => FND_API.G_TRUE
7614 ,x_return_status => l_return_status
7615 );
7616 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7617 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7618 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
7619 RAISE FND_API.G_EXC_ERROR;
7620 END IF;
7621
7622 END IF;
7623
7624
7625 -------------------------------------------------------
7626 -- Process Line Adjustment Attributes
7627 -------------------------------------------------------
7628
7629 -- Process line Adj Attributes
7630
7631 I := p_x_line_adj_Att_tbl.FIRST;
7632 WHILE I IS NOT NULL LOOP
7633
7634 IF l_debug_level > 0 THEN
7635 oe_debug_pub.add( 'SETTING PRICE_ADJUSTMENT_ID ON LINE ADJ ATTRIB TABLE' , 2 ) ;
7636 END IF;
7637
7638 IF p_x_line_adj_att_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE
7639 AND (p_x_line_adj_att_tbl(I).price_adjustment_id IS NULL OR
7640 p_x_line_adj_att_tbl(I).price_adjustment_id = FND_API.G_MISS_NUM)
7641 THEN
7642
7643 IF l_debug_level > 0 THEN
7644 oe_debug_pub.add( 'SETTING ADJ IDS ON LINE ADJ ATTRIB TABLE' , 2 ) ;
7645 END IF;
7646 -- Check If parent exists.
7647
7648 IF p_x_line_adj_tbl.EXISTS(p_x_Line_Adj_att_tbl(I).Adj_index) THEN
7649
7650 -- Copy parent_id.
7651
7652 p_x_line_adj_Att_tbl(I).price_adjustment_id := p_x_line_Adj_tbl(p_x_Line_Adj_att_tbl(I).Adj_index).price_adjustment_id;
7653
7654 ELSE
7655
7656 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
7657 THEN
7658 IF l_debug_level > 0 THEN
7659 oe_debug_pub.add( 'INVALID ADJ INDEX ' ||TO_CHAR ( P_X_LINE_ADJ_ATT_TBL ( I ) .ADJ_INDEX ) ||'ON ADJ ATTRIBS' , 2 ) ;
7660 END IF;
7661 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7662
7663 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
7664 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Line_Adj_Att');
7665 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
7666 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',p_x_line_adj_att_tbl(I).Adj_index);
7667 OE_MSG_PUB.Add;
7668
7669 END IF;
7670 END IF;
7671 END IF;
7672 I := p_x_line_adj_Att_tbl.NEXT(I);
7673 END LOOP;
7674
7675 -- Line_Attribs
7676
7677 IF p_x_line_adj_Att_tbl.COUNT > 0 THEN
7678
7679 oe_order_adj_pvt.Line_Adj_Atts
7680 ( p_validation_level => p_validation_level
7681 , p_control_rec => p_control_rec
7682 , p_x_Line_Adj_Att_tbl => p_x_line_adj_Att_tbl
7683 , p_x_old_Line_Adj_Att_tbl => l_old_line_Adj_Att_tbl
7684 );
7685
7686 END IF;
7687
7688 -------------------------------------------------------
7689 -- Process Line Adjustment Associations
7690 -------------------------------------------------------
7691
7692 -- Process line Adj Associations
7693
7694 I := p_x_line_adj_Assoc_tbl.FIRST;
7695 WHILE I IS NOT NULL LOOP
7696
7697 IF l_debug_level > 0 THEN
7698 oe_debug_pub.add( 'SETTING PRICE_ADJUSTMENT_ID ON LINE ADJ ASSOCS TABLE' , 2 ) ;
7699 END IF;
7700 IF p_x_line_adj_assoc_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE
7701 AND (p_x_line_adj_assoc_tbl(I).price_adjustment_id IS NULL OR
7702 p_x_line_adj_assoc_tbl(I).price_adjustment_id = FND_API.G_MISS_NUM)
7703 THEN
7704
7705 IF l_debug_level > 0 THEN
7706 oe_debug_pub.add( 'SETTING ADJ IDS ON LINE ADJ ASSOCS TABLE' , 2 ) ;
7707 END IF;
7708 -- Check If parent exists.
7709
7710 IF p_x_line_adj_tbl.EXISTS(p_x_Line_Adj_assoc_tbl(I).Adj_index) THEN
7711
7712 -- Copy parent_id.
7713
7714 p_x_line_adj_Assoc_tbl(I).price_adjustment_id := p_x_line_Adj_tbl(p_x_Line_Adj_assoc_tbl(I).Adj_index).price_adjustment_id;
7715
7716 ELSE
7717
7718 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
7719 THEN
7720 IF l_debug_level > 0 THEN
7721 oe_debug_pub.add( 'INVALID ADJ INDEX ' ||TO_CHAR ( P_X_LINE_ADJ_ASSOC_TBL ( I ) .ADJ_INDEX ) ||'ON ADJ ASSOCS' , 2 ) ;
7722 END IF;
7723 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7724
7725 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
7726 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Line_Adj_Assoc');
7727 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
7728 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',p_x_line_adj_assoc_tbl(I).Adj_index);
7729 OE_MSG_PUB.Add;
7730
7731 END IF;
7732 END IF;
7733 END IF;
7734
7735 IF p_x_line_adj_assoc_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE
7736 AND (p_x_line_adj_assoc_tbl(I).Line_id IS NULL OR
7737 p_x_line_adj_assoc_tbl(I).Line_id = FND_API.G_MISS_NUM)
7738 THEN
7739
7740 IF l_debug_level > 0 THEN
7741 oe_debug_pub.add( 'SETTING LINE IDS ON LINE ADJ ASSOCS TABLE' , 2 ) ;
7742 END IF;
7743 -- Check If parent exists.
7744
7745 IF p_x_line_tbl.EXISTS(p_x_line_adj_assoc_tbl(I).Line_Index) THEN
7746
7747 -- Copy parent_id.
7748
7749 p_x_line_adj_Assoc_tbl(I).Line_Id := p_x_line_tbl(p_x_Line_Adj_assoc_tbl(I).Line_index).Line_id;
7750 END IF;
7751 END IF;
7752
7753 IF p_x_line_adj_assoc_tbl(I).operation = OE_GLOBALS.G_OPR_CREATE
7754 AND (p_x_line_adj_assoc_tbl(I).rltd_Price_Adj_Id IS NULL OR
7755 p_x_line_adj_assoc_tbl(I).rltd_Price_Adj_Id = FND_API.G_MISS_NUM)
7756 THEN
7757
7758 IF p_x_line_adj_Tbl.exists(p_x_Line_Adj_assoc_tbl(I).Rltd_Adj_Index) Then
7759 -- Copy parent_id.
7760
7761 p_x_line_adj_Assoc_tbl(I).rltd_Price_Adj_Id :=
7762 p_x_line_adj_Tbl(p_x_Line_Adj_assoc_tbl(I).Rltd_Adj_Index).Price_adjustment_id;
7763 END IF;
7764
7765 END IF;
7766 I := p_x_line_adj_Assoc_tbl.NEXT(I);
7767 END LOOP;
7768
7769 -- Line_Attribs
7770
7771 IF p_x_line_adj_Assoc_tbl.COUNT > 0 THEN
7772
7773 oe_order_adj_pvt.Line_Adj_Assocs
7774 ( p_validation_level => p_validation_level
7775 , p_control_rec => p_control_rec
7776 , p_x_Line_Adj_Assoc_tbl => p_x_line_adj_Assoc_tbl
7777 , p_x_old_Line_Adj_Assoc_tbl => l_old_line_Adj_Assoc_tbl
7778 );
7779
7780 END IF;
7781
7782
7783 -- Step 6. Perform Delayed Requests
7784 -- Set entity_id on request table using the line index.
7785
7786 I := p_x_action_request_tbl.FIRST;
7787 WHILE I IS NOT NULL LOOP
7788
7789 IF l_debug_level > 0 THEN
7790 oe_debug_pub.add( 'SETTING HEADER/LINE IDS ON REQUEST TABLE' , 2 ) ;
7791 END IF;
7792
7793 IF (p_x_action_request_tbl(I).entity_code = OE_GLOBALS.G_ENTITY_HEADER) THEN
7794
7795 IF (p_x_action_request_tbl(I).entity_id IS NULL OR
7796 p_x_action_request_tbl(I).entity_id = FND_API.G_MISS_NUM)
7797 THEN
7798 IF l_debug_level > 0 THEN
7799 oe_debug_pub.add( 'SETTING HEADER IDS ON REQUEST TABLE FOR HEADER ENTITY' , 2 ) ;
7800 END IF;
7801 IF p_x_header_rec.header_id IS NULL OR
7802 p_x_header_rec.header_id = FND_API.G_MISS_NUM THEN
7803 FND_MESSAGE.SET_NAME('ONT','OE_HEADER_MISSING');
7804 OE_MSG_PUB.Add;
7805 RAISE FND_API.G_EXC_ERROR;
7806 ELSE
7807 p_x_action_request_tbl(I).entity_id := p_x_header_rec.header_id;
7808 l_hdr_flow_status_refresh := 'Y'; -- Bug 8435946
7809 END IF;
7810 END IF;
7811
7812 ELSIF (p_x_action_request_tbl(I).entity_code = OE_GLOBALS.G_ENTITY_LINE) THEN
7813
7814 IF (p_x_action_request_tbl(I).entity_id IS NULL OR
7815 p_x_action_request_tbl(I).entity_id = FND_API.G_MISS_NUM)
7816 THEN
7817 IF l_debug_level > 0 THEN
7818 oe_debug_pub.add( 'SETTING LINE IDS ON REQUEST TABLE FOR LINE ENTITY' , 2 ) ;
7819 END IF;
7820 -- Check If entity record exists.
7821
7822 IF p_x_line_tbl.EXISTS(p_x_action_request_tbl(I).entity_index) THEN
7823
7824 -- Copy entity_id.
7825
7826 p_x_action_request_tbl(I).entity_id := p_x_line_tbl(p_x_action_request_tbl(I).entity_index).line_id;
7827
7828 ELSE
7829
7830 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
7831 THEN
7832 IF l_debug_level > 0 THEN
7833 oe_debug_pub.add( 'INVALID ENTITY INDEX ' ||TO_CHAR ( p_x_action_request_tbl ( I ) .ENTITY_INDEX ) ||'ON REQUEST TABLE FOR LINE ENTITY' , 2 ) ;
7834 END IF;
7835 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7836 END IF;
7837 END IF;
7838 END IF;
7839
7840 ELSIF (p_x_action_request_tbl(I).request_type = OE_GLOBALS.G_VERIFY_PAYMENT) THEN
7841
7842 IF (p_x_action_request_tbl(I).entity_id IS NULL OR
7843 p_x_action_request_tbl(I).entity_id = FND_API.G_MISS_NUM)
7844 THEN
7845 IF l_debug_level > 0 THEN
7846 oe_debug_pub.add( 'SETTING HEADER IDS ON REQUEST TABLE FOR VERIFY_PAYMENT' , 2 ) ;
7847 END IF;
7848 IF p_x_header_rec.header_id IS NULL OR
7849 p_x_header_rec.header_id = FND_API.G_MISS_NUM THEN
7850 FND_MESSAGE.SET_NAME('ONT','OE_HEADER_MISSING');
7851 OE_MSG_PUB.Add;
7852 RAISE FND_API.G_EXC_ERROR;
7853 ELSE
7854 p_x_action_request_tbl(I).entity_id := p_x_header_rec.header_id;
7855 END IF;
7856 END IF;
7857 END IF;
7858 I := p_x_action_request_tbl.NEXT(I);
7859 END LOOP;
7860
7861 -------------------------------------------------------------------------------
7862
7863 -- Step 7. Perform Object group logic
7864
7865 -- Perform Delayed Requests for all the the entities
7866 IF l_debug_level > 0 THEN
7867 oe_debug_pub.add( 'OEXVORDB: BEFORE CALLING PROCESS_DELAYED_REQUESTS' , 2 ) ;
7868 END IF;
7869 IF (p_control_rec.process AND
7870 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
7871 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL
7872 THEN
7873
7874 OE_DELAYED_REQUESTS_PVT.Process_Delayed_Requests(
7875 x_return_status => l_return_status
7876 );
7877 IF l_debug_level > 0 THEN
7878 oe_debug_pub.add( 'OEXVORDB: COMPLETED PROCESS_DELAYED_REQUESTS ' || ' WITH RETURN STATUS' || L_RETURN_STATUS , 2 ) ;
7879 END IF;
7880 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7881 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7882 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
7883 RAISE FND_API.G_EXC_ERROR;
7884 END IF;
7885
7886 END IF;
7887
7888 -- Only do non-WF requests.
7889 IF p_x_action_request_tbl.COUNT > 0 THEN
7890
7891 -- Perform NON-WF Action Requests
7892 OE_Delayed_Requests_PVT.Process_Order_Actions
7893 (p_validation_level => p_validation_level,
7894 p_x_request_tbl => p_x_action_request_tbl,
7895 p_process_WF_Requests => FALSE);
7896
7897 END IF;
7898 /* comm rej
7899 --R12 CVV2
7900 IF l_debug_level > 0 THEN
7901 oe_debug_pub.add('after OE_Delayed_Requests_PVT.Process_Order_Actions cvv2');
7902 END IF;
7903 i := p_x_action_request_tbl.first;
7904 while i is not null loop
7905 IF l_debug_level > 0 THEN
7906 oe_debug_pub.add('return_status : ' || p_x_action_request_tbl(i).return_status);
7907 oe_debug_pub.add('request_type : ' || p_x_action_request_tbl(i).request_type);
7908 END IF;
7909 IF p_x_action_request_tbl(i).return_status = FND_API.G_RET_STS_ERROR
7910 AND p_x_action_request_tbl(i).request_type = OE_GLOBALS.G_VERIFY_PAYMENT THEN
7911 x_return_status := FND_API.G_RET_STS_ERROR;
7912 RAISE FND_API.G_EXC_ERROR;
7913 END IF;
7914 i := p_x_action_request_tbl.next(i);
7915 end loop;
7916 --R12 CVV2
7917 comm rej */
7918
7919 -- Start flows for the Entity.
7920 IF (p_control_rec.process AND
7921 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL AND
7922 OE_GLOBALS.G_RECURSION_MODE = 'N')
7923 THEN
7924 OE_ORDER_WF_UTIL.START_ALL_FLOWS;
7925 -- Process WF Action requests.
7926 IF p_x_action_request_tbl.COUNT > 0 THEN
7927
7928 OE_Delayed_Requests_PVT.Process_Order_Actions
7929
7930 (p_validation_level => p_validation_level,
7931 p_x_request_tbl => p_x_action_request_tbl,
7932 p_process_WF_Requests => TRUE);
7933
7934 -- Bug 8435946
7935 IF ( l_hdr_flow_status_refresh = 'Y' ) THEN
7936 SELECT flow_status_code into p_x_header_rec.flow_status_code
7937 FROM oe_order_headers_all
7938 WHERE header_id = p_x_header_rec.header_id;
7939 END IF;
7940
7941 END IF;
7942
7943 END IF;
7944
7945
7946 IF l_debug_level > 0 THEN
7947 oe_debug_pub.add( 'OEXVORDB: AFTER PROCESS_ORDER_ACTIONS' , 2 ) ;
7948 END IF;
7949
7950
7951 -- Clear API cache.
7952
7953 IF p_control_rec.clear_api_cache THEN
7954 NULL;
7955 END IF;
7956
7957 -- Clear API request tbl.
7958
7959 IF p_control_rec.clear_api_requests THEN
7960 NULL;
7961 END IF;
7962
7963 -- Derive return status
7964
7965 IF p_x_header_rec.return_status = FND_API.G_RET_STS_ERROR THEN
7966 x_return_status := FND_API.G_RET_STS_ERROR;
7967 END IF;
7968
7969 -- Do not need to loop through header_scredits, lines
7970 -- line_scredits or lot_serials as the x_return_status is set
7971 -- based on the x_return_status returned by the entity procedures
7972
7973 I := p_x_header_adj_tbl.FIRST;
7974 WHILE I IS NOT NULL LOOP
7975
7976 IF p_x_header_adj_tbl(I).return_status = FND_API.G_RET_STS_ERROR THEN
7977 x_return_status := FND_API.G_RET_STS_ERROR;
7978 END IF;
7979
7980 I := p_x_header_adj_tbl.NEXT(I);
7981 END LOOP;
7982
7983 I := p_x_header_price_Att_tbl.FIRST;
7984 WHILE I IS NOT NULL LOOP
7985
7986 IF p_x_header_price_Att_tbl(I).return_status = FND_API.G_RET_STS_ERROR THEN
7987 x_return_status := FND_API.G_RET_STS_ERROR;
7988 END IF;
7989
7990 I := p_x_header_price_Att_tbl.NEXT(I);
7991 END LOOP;
7992
7993 I := p_x_header_adj_Att_tbl.FIRST;
7994 WHILE I IS NOT NULL LOOP
7995
7996 IF p_x_header_adj_Att_tbl(I).return_status = FND_API.G_RET_STS_ERROR THEN
7997 x_return_status := FND_API.G_RET_STS_ERROR;
7998 END IF;
7999
8000 I := p_x_header_adj_Att_tbl.NEXT(I);
8001 END LOOP;
8002
8003 I := p_x_header_adj_Assoc_tbl.FIRST;
8004 WHILE I IS NOT NULL LOOP
8005
8006 IF p_x_header_adj_Assoc_tbl(I).return_status = FND_API.G_RET_STS_ERROR THEN
8007 x_return_status := FND_API.G_RET_STS_ERROR;
8008 END IF;
8009
8010 I := p_x_header_adj_Assoc_tbl.NEXT(I);
8011 END LOOP;
8012
8013 I := p_x_line_adj_tbl.FIRST;
8014 WHILE I IS NOT NULL LOOP
8015
8016 IF p_x_line_adj_tbl(I).return_status = FND_API.G_RET_STS_ERROR THEN
8017 x_return_status := FND_API.G_RET_STS_ERROR;
8018 END IF;
8019
8020 I := p_x_line_adj_tbl.NEXT(I);
8021 END LOOP;
8022
8023 I := p_x_line_price_Att_tbl.FIRST;
8024 WHILE I IS NOT NULL LOOP
8025
8026 IF p_x_line_price_Att_tbl(I).return_status = FND_API.G_RET_STS_ERROR THEN
8027 x_return_status := FND_API.G_RET_STS_ERROR;
8028 END IF;
8029
8030 I := p_x_line_price_Att_tbl.NEXT(I);
8031 END LOOP;
8032
8033 I := p_x_line_adj_Att_tbl.FIRST;
8034 WHILE I IS NOT NULL LOOP
8035
8036 IF p_x_line_adj_Att_tbl(I).return_status = FND_API.G_RET_STS_ERROR THEN
8037 x_return_status := FND_API.G_RET_STS_ERROR;
8038 END IF;
8039
8040 I := p_x_line_adj_Att_tbl.NEXT(I);
8041 END LOOP;
8042
8043 I := p_x_line_adj_Assoc_tbl.FIRST;
8044 WHILE I IS NOT NULL LOOP
8045
8046 IF p_x_line_adj_Assoc_tbl(I).return_status = FND_API.G_RET_STS_ERROR THEN
8047 x_return_status := FND_API.G_RET_STS_ERROR;
8048 END IF;
8049
8050 I := p_x_line_adj_Assoc_tbl.NEXT(I);
8051 END LOOP;
8052
8053 IF l_debug_level > 0 THEN
8054 oe_debug_pub.add( 'JPN: BEFORE CALLING NOTIFY , HEADER_ID IS: ' || P_X_HEADER_REC.HEADER_ID ) ;
8055 END IF;
8056 -- Calling Update Notice API - Provided by OC
8057 -- This API will notify OC about the changes happen in OM side for order
8058
8059 /* Notification Project changes */
8060 /* Call Process_Requests_and_Notify to inform all subscribers */
8061
8062 IF (OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508') then
8063 /* Call Process Requests and notify */
8064 IF l_debug_level > 0 THEN
8065 oe_debug_pub.add( 'CALLING PROCESS_REQUESTS_AND_NOTIFY FOR PACK H IN PROCESS_ORDER_AG' );
8066 END IF;
8067 Process_Requests_And_Notify(
8068 p_process_requests => FALSE,
8069 p_notify => TRUE,
8070 x_return_status => l_return_status,
8071 p_header_rec => p_x_header_rec,
8072 p_old_header_rec => l_old_header_rec,
8073 p_Header_Adj_tbl => p_x_Header_Adj_tbl,
8074 p_old_Header_Adj_tbl => l_old_Header_Adj_tbl,
8075 p_Header_Scredit_tbl => p_x_header_Scredit_tbl,
8076 p_old_Header_Scredit_tbl => l_old_Header_Scredit_tbl,
8077 p_Header_Payment_tbl => p_x_header_Payment_tbl,
8078 p_old_Header_Payment_tbl => l_old_Header_Payment_tbl,
8079 p_line_tbl =>p_x_line_tbl,
8080 p_old_line_tbl => l_old_line_tbl,
8081 p_Line_Adj_tbl => p_x_line_adj_tbl,
8082 p_old_line_adj_tbl => l_old_line_adj_tbl,
8083 p_Line_Scredit_tbl => p_x_Line_Scredit_tbl,
8084 p_old_Line_Scredit_tbl => l_old_line_Scredit_tbl,
8085 p_Line_Payment_tbl => p_x_Line_Payment_tbl,
8086 p_old_Line_Payment_tbl => l_old_line_Payment_tbl,
8087 p_Lot_Serial_tbl => p_x_lot_Serial_tbl,
8088 p_old_Lot_Serial_tbl => l_old_Lot_Serial_tbl);
8089
8090 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
8091 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8092 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
8093 RAISE FND_API.G_EXC_ERROR;
8094 END IF;
8095
8096 ELSE
8097 /* Pre Pack H processsing */
8098
8099
8100 IF l_debug_level > 0 THEN
8101 oe_debug_pub.add( 'CS BEFORE CALLING NOTIFY_OC API' , 1 ) ;
8102 END IF;
8103 IF x_return_status = FND_API.G_RET_STS_SUCCESS AND
8104 p_control_rec.write_to_db = TRUE
8105 AND oe_order_cache.g_header_rec.booked_flag = 'Y'
8106 THEN
8107 IF l_debug_level > 0 THEN
8108 oe_debug_pub.add( 'CS CALLING NOTIFY_OC API' , 1 ) ;
8109 END IF;
8110
8111 OE_SERVICE_UTIL.Notify_OC
8112 ( p_api_version_number => l_api_version_number
8113 , p_init_msg_list => FND_API.G_FALSE
8114 , p_validation_level => p_validation_level
8115 , p_control_rec => p_control_rec
8116 , x_return_status => l_return_status
8117 , x_msg_count => x_msg_count
8118 , x_msg_data => x_msg_data
8119 , p_header_rec => p_x_header_rec
8120 , p_old_header_rec => l_old_header_rec
8121 , p_header_adj_tbl => p_x_header_adj_tbl
8122 , p_old_header_adj_tbl => l_old_header_adj_tbl
8123 , p_header_price_att_tbl => p_x_header_price_att_tbl
8124 , p_old_header_price_att_tbl => l_old_header_price_att_tbl
8125 , p_Header_Adj_Att_tbl => p_x_header_adj_Att_tbl
8126 , p_old_Header_Adj_Att_tbl => l_old_header_Adj_Att_tbl
8127 , p_Header_Adj_Assoc_tbl => p_x_header_adj_Assoc_tbl
8128 , p_old_Header_Adj_Assoc_tbl => l_old_header_Adj_Assoc_tbl
8129 , p_Header_Scredit_tbl => p_x_header_scredit_tbl
8130 , p_old_Header_Scredit_tbl => l_old_header_Scredit_tbl
8131 -- , p_Header_Payment_tbl => p_x_header_Payment_tbl
8132 -- , p_old_Header_Payment_tbl => l_old_header_Payment_tbl
8133 , p_line_tbl => p_x_line_tbl
8134 , p_old_line_tbl => l_old_line_tbl
8135 , p_Line_Adj_tbl => p_x_line_adj_tbl
8136 , p_old_Line_Adj_tbl => l_old_line_Adj_tbl
8137 , p_Line_Price_Att_tbl => p_x_line_price_Att_tbl
8138 , p_old_Line_Price_Att_tbl => l_old_line_Price_Att_tbl
8139 , p_Line_Adj_Att_tbl => p_x_line_adj_Att_tbl
8140 , p_old_Line_Adj_Att_tbl => l_old_line_Adj_Att_tbl
8141 , p_Line_Adj_Assoc_tbl => p_x_line_adj_Assoc_tbl
8142 , p_old_Line_Adj_Assoc_tbl => l_old_line_Adj_Assoc_tbl
8143 , p_Line_Scredit_tbl => p_x_line_scredit_tbl
8144 , p_old_Line_Scredit_tbl => l_old_line_Scredit_tbl
8145 -- , p_Line_Payment_tbl => p_x_line_Payment_tbl
8146 -- , p_old_Line_Payment_tbl => l_old_line_Payment_tbl
8147 , p_Lot_Serial_tbl => p_x_lot_serial_tbl
8148 , p_old_Lot_Serial_tbl => l_old_lot_Serial_tbl
8149 , p_Lot_Serial_val_tbl => p_lot_serial_val_tbl
8150 , p_old_Lot_Serial_val_tbl => l_old_lot_Serial_val_tbl
8151 , p_action_request_tbl => p_x_action_request_tbl
8152 );
8153
8154
8155 IF l_debug_level > 0 THEN
8156 oe_debug_pub.add( 'AFTER NOTIFY_OC API' , 1 ) ;
8157 END IF;
8158 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
8159 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8160 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
8161 RAISE FND_API.G_EXC_ERROR;
8162 END IF;
8163
8164
8165 END IF;
8166
8167 IF l_debug_level > 0 THEN
8168 oe_debug_pub.add( 'PROCESSING ACKS' , 1 ) ;
8169 END IF;
8170
8171 IF OE_Globals.G_RECURSION_MODE <> 'Y' AND
8172 x_return_status = FND_API.G_RET_STS_SUCCESS AND
8173 l_control_rec.write_to_db = TRUE
8174 THEN
8175 IF l_debug_level > 0 THEN
8176 oe_debug_pub.add( 'CALLING ACKS API' , 1 ) ;
8177 END IF;
8178
8179 If Oe_Code_Control.Code_Release_Level >= '110510' And
8180 p_x_header_rec.order_source_id in (0,2,6) And
8181 l_edi_ack_pfile = 'YES' Then
8182 OE_Acknowledgment_Pvt.Process_Acknowledgment
8183 (p_header_rec => p_x_header_rec,
8184 p_line_tbl => p_x_line_tbl,
8185 p_old_header_rec => l_old_header_rec,
8186 p_old_line_tbl => l_old_line_tbl,
8187 x_return_status => l_return_status);
8188 Elsif l_edi_ack_pfile = 'NO' And
8189 p_x_header_rec.order_source_id in (0,2,6,20) Then
8190
8191 OE_Acknowledgment_Pvt.Process_Acknowledgment
8192 (p_api_version_number => 1
8193 ,p_init_msg_list => p_init_msg_list
8194
8195 ,p_header_rec => p_x_header_rec
8196 ,p_header_adj_tbl => p_x_header_adj_tbl
8197 ,p_header_Scredit_tbl => p_x_header_scredit_tbl
8198 ,p_line_tbl => p_x_line_tbl
8199 ,p_line_adj_tbl => p_x_line_adj_tbl
8200 ,p_line_scredit_tbl => p_x_line_scredit_tbl
8201 ,p_lot_serial_tbl => p_x_lot_serial_tbl
8202 ,p_action_request_tbl => p_x_action_request_tbl
8203
8204 ,p_old_header_rec => l_old_header_rec
8205 ,p_old_header_adj_tbl => l_old_header_adj_tbl
8206 ,p_old_header_Scredit_tbl => l_old_header_scredit_tbl
8207 ,p_old_line_tbl => l_old_line_tbl
8208 ,p_old_line_adj_tbl => l_old_line_adj_tbl
8209 ,p_old_line_scredit_tbl => l_old_line_scredit_tbl
8210 ,p_old_lot_serial_tbl => l_old_lot_serial_tbl
8211
8212 ,p_buyer_seller_flag => 'B'
8213 ,p_reject_order => 'N'
8214
8215 ,x_return_status => l_return_status
8216 );
8217
8218 End If;
8219
8220 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
8221 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8222 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
8223 RAISE FND_API.G_EXC_ERROR;
8224 x_return_status := l_return_status;
8225 END IF;
8226 END IF;
8227
8228 END IF; /* Code Level check */
8229
8230 -- Bug 2909598 - do not copy return status back from local
8231 -- variable. For errors, x_return_status is set after call to
8232 -- every procedure. Copying now may result in copying a success
8233 -- value back as the last procedure called returned success but
8234 -- a prior procedure could have returned error - in this case,
8235 -- error should be the overall return status.
8236
8237 -- x_return_status := l_return_status;
8238
8239 IF l_debug_level > 0 THEN
8240 oe_debug_pub.add( 'EXIT PROCESS_ORDER_AG' , 1 ) ;
8241 END IF;
8242 END Process_Order_AG;
8243
8244 /*----------------------------------------------------------------
8245 -- Start of Comments
8246 -- API name Process_Order
8247 -- Type Private
8248 --
8249 -- Pre-reqs
8250 --
8251 -- Parameters
8252 --
8253 -- Version Current version = 1.0
8254 -- Initial version = 1.0
8255 --
8256 -- Notes
8257 --
8258 -- End of Comments
8259 ----------------------------------------------------------------*/
8260 PROCEDURE Process_Order
8261 ( p_api_version_number IN NUMBER
8262 , p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
8263 , p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL
8264 , p_control_rec IN OE_GLOBALS.Control_Rec_Type :=
8265 OE_GLOBALS.G_MISS_CONTROL_REC
8266 , x_return_status OUT NOCOPY VARCHAR2
8267
8268 , x_msg_count OUT NOCOPY NUMBER
8269
8270 , x_msg_data OUT NOCOPY VARCHAR2
8271
8272 , p_x_header_rec IN OUT NOCOPY OE_Order_PUB.Header_Rec_Type
8273 , p_old_header_rec IN OE_Order_PUB.Header_Rec_Type :=
8274 OE_Order_PUB.G_MISS_HEADER_REC
8275 , p_x_Header_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Tbl_Type
8276 , p_old_Header_Adj_tbl IN OE_Order_PUB.Header_Adj_Tbl_Type :=
8277 OE_Order_PUB.G_MISS_HEADER_ADJ_TBL
8278 , p_x_Header_Price_Att_tbl IN OUT NOCOPY OE_Order_PUB.Header_Price_Att_Tbl_Type
8279 , p_old_Header_Price_Att_tbl IN OE_Order_PUB.Header_Price_Att_Tbl_Type :=
8280 OE_Order_PUB.G_MISS_HEADER_PRICE_ATT_TBL
8281 , p_x_Header_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Att_Tbl_Type
8282 , p_old_Header_Adj_Att_tbl IN OE_Order_PUB.Header_Adj_Att_Tbl_Type :=
8283 OE_Order_PUB.G_MISS_HEADER_ADJ_ATT_TBL
8284 , p_x_Header_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Assoc_Tbl_Type
8285 , p_old_Header_Adj_Assoc_tbl IN OE_Order_PUB.Header_Adj_Assoc_Tbl_Type :=
8286 OE_Order_PUB.G_MISS_HEADER_ADJ_ASSOC_TBL
8287 , p_x_Header_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Header_Scredit_Tbl_Type
8288 , p_old_Header_Scredit_tbl IN OE_Order_PUB.Header_Scredit_Tbl_Type :=
8289 OE_Order_PUB.G_MISS_HEADER_SCREDIT_TBL
8290 , p_x_line_tbl IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
8291 , p_old_line_tbl IN OE_Order_PUB.Line_Tbl_Type :=
8292 OE_Order_PUB.G_MISS_LINE_TBL
8293 , p_x_Line_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Tbl_Type
8294 , p_old_Line_Adj_tbl IN OE_Order_PUB.Line_Adj_Tbl_Type :=
8295 OE_Order_PUB.G_MISS_LINE_ADJ_TBL
8296 , p_x_Line_Price_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Price_Att_Tbl_Type
8297 , p_old_Line_Price_Att_tbl IN OE_Order_PUB.Line_Price_Att_Tbl_Type :=
8298 OE_Order_PUB.G_MISS_LINE_PRICE_ATT_TBL
8299 , p_x_Line_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Att_Tbl_Type
8300 , p_old_Line_Adj_Att_tbl IN OE_Order_PUB.Line_Adj_Att_Tbl_Type :=
8301 OE_Order_PUB.G_MISS_LINE_ADJ_ATT_TBL
8302 , p_x_Line_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Assoc_Tbl_Type
8303 , p_old_Line_Adj_Assoc_tbl IN OE_Order_PUB.Line_Adj_Assoc_Tbl_Type :=
8304 OE_Order_PUB.G_MISS_LINE_ADJ_ASSOC_TBL
8305 , p_x_Line_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Line_Scredit_Tbl_Type
8306 , p_old_Line_Scredit_tbl IN OE_Order_PUB.Line_Scredit_Tbl_Type :=
8307 OE_Order_PUB.G_MISS_LINE_SCREDIT_TBL
8308 , p_x_Lot_Serial_tbl IN OUT NOCOPY OE_Order_PUB.Lot_Serial_Tbl_Type
8309 , p_old_Lot_Serial_tbl IN OE_Order_PUB.Lot_Serial_Tbl_Type :=
8310 OE_Order_PUB.G_MISS_LOT_SERIAL_TBL
8311 , p_Lot_Serial_val_tbl IN OE_Order_PUB.Lot_Serial_Val_Tbl_Type :=
8312 OE_Order_PUB.G_MISS_LOT_SERIAL_VAL_TBL
8313 , p_old_Lot_Serial_val_tbl IN OE_Order_PUB.Lot_Serial_Val_Tbl_Type :=
8314 OE_Order_PUB.G_MISS_LOT_SERIAL_VAL_TBL
8315 , p_x_action_request_tbl IN OUT NOCOPY OE_Order_PUB.request_tbl_type
8316 , p_action_commit IN VARCHAR2 := FND_API.G_FALSE
8317 )
8318 IS
8319 l_x_Header_Payment_tbl OE_Order_PUB.Header_Payment_Tbl_Type;
8320 l_x_Line_Payment_tbl OE_Order_PUB.Line_Payment_Tbl_Type;
8321 BEGIN
8322
8323 Process_Order
8324 ( p_api_version_number => p_api_version_number
8325 , p_init_msg_list => p_init_msg_list
8326 , p_validation_level => p_validation_level
8327 , p_control_rec => p_control_rec
8328 , x_return_status => x_return_status
8329
8330 , x_msg_count => x_msg_count
8331
8332 , x_msg_data => x_msg_data
8333
8334 , p_x_header_rec => p_x_header_rec
8335 , p_old_header_rec => p_old_header_rec
8336 , p_x_Header_Adj_tbl => p_x_Header_Adj_tbl
8337 , p_old_Header_Adj_tbl => p_old_Header_Adj_tbl
8338 , p_x_Header_Price_Att_tbl => p_x_Header_Price_Att_tbl
8339 , p_old_Header_Price_Att_tbl => p_old_Header_Price_Att_tbl
8340 , p_x_Header_Adj_Att_tbl => p_x_Header_Adj_Att_tbl
8341 , p_old_Header_Adj_Att_tbl => p_old_Header_Adj_Att_tbl
8342 , p_x_Header_Adj_Assoc_tbl => p_x_Header_Adj_Assoc_tbl
8343 , p_old_Header_Adj_Assoc_tbl => p_old_Header_Adj_Assoc_tbl
8344 , p_x_Header_Scredit_tbl => p_x_Header_Scredit_tbl
8345 , p_old_Header_Scredit_tbl => p_old_Header_Scredit_tbl
8346 , p_x_Header_Payment_tbl => l_x_Header_Payment_tbl
8347 , p_x_line_tbl => p_x_line_tbl
8348 , p_old_line_tbl => p_old_line_tbl
8349 , p_x_Line_Adj_tbl => p_x_Line_Adj_tbl
8350 , p_old_Line_Adj_tbl => p_old_Line_Adj_tbl
8351 , p_x_Line_Price_Att_tbl => p_x_Line_Price_Att_tbl
8352 , p_old_Line_Price_Att_tbl => p_old_Line_Price_Att_tbl
8353 , p_x_Line_Adj_Att_tbl => p_x_Line_Adj_Att_tbl
8354 , p_old_Line_Adj_Att_tbl => p_old_Line_Adj_Att_tbl
8355 , p_x_Line_Adj_Assoc_tbl => p_x_Line_Adj_Assoc_tbl
8356 , p_old_Line_Adj_Assoc_tbl => p_old_Line_Adj_Assoc_tbl
8357 , p_x_Line_Scredit_tbl => p_x_Line_Scredit_tbl
8358 , p_old_Line_Scredit_tbl => p_old_Line_Scredit_tbl
8359 , p_x_Line_Payment_tbl => l_x_Line_Payment_tbl
8360 , p_x_Lot_Serial_tbl => p_x_Lot_Serial_tbl
8361 , p_old_Lot_Serial_tbl => p_old_Lot_Serial_tbl
8362 , p_Lot_Serial_val_tbl => p_Lot_Serial_val_tbl
8363 , p_old_Lot_Serial_val_tbl => p_old_Lot_Serial_val_tbl
8364 , p_x_action_request_tbl => p_x_action_request_tbl
8365 , p_action_commit => p_action_commit
8366 );
8367 END Process_Order;
8368
8369 -- overloaded for payments
8370 PROCEDURE Process_Order
8371 ( p_api_version_number IN NUMBER
8372 , p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
8373 , p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL
8374 , p_control_rec IN OE_GLOBALS.Control_Rec_Type :=
8375 OE_GLOBALS.G_MISS_CONTROL_REC
8376 , x_return_status OUT NOCOPY VARCHAR2
8377
8378 , x_msg_count OUT NOCOPY NUMBER
8379
8380 , x_msg_data OUT NOCOPY VARCHAR2
8381
8382 , p_x_header_rec IN OUT NOCOPY OE_Order_PUB.Header_Rec_Type
8383 , p_old_header_rec IN OE_Order_PUB.Header_Rec_Type :=
8384 OE_Order_PUB.G_MISS_HEADER_REC
8385 , p_x_Header_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Tbl_Type
8386 , p_old_Header_Adj_tbl IN OE_Order_PUB.Header_Adj_Tbl_Type :=
8387 OE_Order_PUB.G_MISS_HEADER_ADJ_TBL
8388 , p_x_Header_Price_Att_tbl IN OUT NOCOPY OE_Order_PUB.Header_Price_Att_Tbl_Type
8389 , p_old_Header_Price_Att_tbl IN OE_Order_PUB.Header_Price_Att_Tbl_Type :=
8390 OE_Order_PUB.G_MISS_HEADER_PRICE_ATT_TBL
8391 , p_x_Header_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Att_Tbl_Type
8392 , p_old_Header_Adj_Att_tbl IN OE_Order_PUB.Header_Adj_Att_Tbl_Type :=
8393 OE_Order_PUB.G_MISS_HEADER_ADJ_ATT_TBL
8394 , p_x_Header_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Assoc_Tbl_Type
8395 , p_old_Header_Adj_Assoc_tbl IN OE_Order_PUB.Header_Adj_Assoc_Tbl_Type :=
8396 OE_Order_PUB.G_MISS_HEADER_ADJ_ASSOC_TBL
8397 , p_x_Header_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Header_Scredit_Tbl_Type
8398 , p_old_Header_Scredit_tbl IN OE_Order_PUB.Header_Scredit_Tbl_Type :=
8399 OE_Order_PUB.G_MISS_HEADER_SCREDIT_TBL
8400 , p_x_Header_Payment_tbl IN OUT NOCOPY OE_Order_PUB.Header_Payment_Tbl_Type
8401 , p_old_Header_Payment_tbl IN OE_Order_PUB.Header_Payment_Tbl_Type :=
8402 OE_Order_PUB.G_MISS_HEADER_PAYMENT_TBL
8403 , p_x_line_tbl IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
8404 , p_old_line_tbl IN OE_Order_PUB.Line_Tbl_Type :=
8405 OE_Order_PUB.G_MISS_LINE_TBL
8406 , p_x_Line_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Tbl_Type
8407 , p_old_Line_Adj_tbl IN OE_Order_PUB.Line_Adj_Tbl_Type :=
8408 OE_Order_PUB.G_MISS_LINE_ADJ_TBL
8409 , p_x_Line_Price_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Price_Att_Tbl_Type
8410 , p_old_Line_Price_Att_tbl IN OE_Order_PUB.Line_Price_Att_Tbl_Type :=
8411 OE_Order_PUB.G_MISS_LINE_PRICE_ATT_TBL
8412 , p_x_Line_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Att_Tbl_Type
8413 , p_old_Line_Adj_Att_tbl IN OE_Order_PUB.Line_Adj_Att_Tbl_Type :=
8414 OE_Order_PUB.G_MISS_LINE_ADJ_ATT_TBL
8415 , p_x_Line_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Assoc_Tbl_Type
8416 , p_old_Line_Adj_Assoc_tbl IN OE_Order_PUB.Line_Adj_Assoc_Tbl_Type :=
8417 OE_Order_PUB.G_MISS_LINE_ADJ_ASSOC_TBL
8418 , p_x_Line_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Line_Scredit_Tbl_Type
8419 , p_old_Line_Scredit_tbl IN OE_Order_PUB.Line_Scredit_Tbl_Type :=
8420 OE_Order_PUB.G_MISS_LINE_SCREDIT_TBL
8421 , p_x_Line_Payment_tbl IN OUT NOCOPY OE_Order_PUB.Line_Payment_Tbl_Type
8422 , p_old_Line_Payment_tbl IN OE_Order_PUB.Line_Payment_Tbl_Type :=
8423 OE_Order_PUB.G_MISS_LINE_PAYMENT_TBL
8424 , p_x_Lot_Serial_tbl IN OUT NOCOPY OE_Order_PUB.Lot_Serial_Tbl_Type
8425 , p_old_Lot_Serial_tbl IN OE_Order_PUB.Lot_Serial_Tbl_Type :=
8426 OE_Order_PUB.G_MISS_LOT_SERIAL_TBL
8427 , p_Lot_Serial_val_tbl IN OE_Order_PUB.Lot_Serial_Val_Tbl_Type :=
8428 OE_Order_PUB.G_MISS_LOT_SERIAL_VAL_TBL
8429 , p_old_Lot_Serial_val_tbl IN OE_Order_PUB.Lot_Serial_Val_Tbl_Type :=
8430 OE_Order_PUB.G_MISS_LOT_SERIAL_VAL_TBL
8431 , p_x_action_request_tbl IN OUT NOCOPY OE_Order_PUB.request_tbl_type
8432 , p_action_commit IN VARCHAR2 := FND_API.G_FALSE
8433 )
8434 IS
8435 l_api_version_number CONSTANT NUMBER := 1.0;
8436 l_api_name CONSTANT VARCHAR2(30):= 'Process_Order';
8437 l_return_status VARCHAR2(1);
8438 l_control_rec OE_GLOBALS.Control_Rec_Type;
8439 l_header_rec OE_Order_PUB.Header_Rec_Type := p_x_header_rec;
8440 l_old_header_rec OE_Order_PUB.Header_Rec_Type := p_old_header_rec;
8441 l_Header_Adj_rec OE_Order_PUB.Header_Adj_Rec_Type;
8442 l_Header_Adj_tbl OE_Order_PUB.Header_Adj_Tbl_Type;
8443 l_old_Header_Adj_rec OE_Order_PUB.Header_Adj_Rec_Type;
8444 l_old_Header_Adj_tbl OE_Order_PUB.Header_Adj_Tbl_Type;
8445 l_Header_price_Att_rec OE_Order_PUB.Header_Price_Att_Rec_Type ;
8446 l_old_Header_price_Att_rec OE_Order_PUB.Header_Price_Att_Rec_Type ;
8447 l_Header_price_Att_Tbl OE_Order_PUB.Header_Price_Att_Tbl_Type ;
8448 l_Old_Header_price_Att_Tbl OE_Order_PUB.Header_Price_Att_Tbl_Type ;
8449 l_Header_Adj_Att_tbl OE_Order_PUB.Header_Adj_Att_Tbl_Type ;
8450 l_old_Header_Adj_Att_tbl OE_Order_PUB.Header_Adj_Att_Tbl_Type ;
8451 l_Header_Adj_Att_Rec OE_Order_PUB.Header_Adj_Att_Rec_Type ;
8452 l_old_Header_Adj_Att_Rec OE_Order_PUB.Header_Adj_Att_Rec_Type ;
8453 l_Header_Adj_Assoc_tbl OE_Order_PUB.Header_Adj_Assoc_Tbl_Type ;
8454 l_old_Header_Adj_Assoc_tbl OE_Order_PUB.Header_Adj_Assoc_Tbl_Type ;
8455 l_Header_Adj_Assoc_Rec OE_Order_PUB.Header_Adj_Assoc_Rec_Type ;
8456 l_old_Header_Adj_Assoc_Rec OE_Order_PUB.Header_Adj_Assoc_Rec_Type ;
8457 l_Header_Scredit_rec OE_Order_PUB.Header_Scredit_Rec_Type;
8458 l_Header_Scredit_tbl OE_Order_PUB.Header_Scredit_Tbl_Type;
8459 l_old_Header_Scredit_rec OE_Order_PUB.Header_Scredit_Rec_Type;
8460 l_old_Header_Scredit_tbl OE_Order_PUB.Header_Scredit_Tbl_Type;
8461 l_line_rec OE_Order_PUB.Line_Rec_Type;
8462 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
8463 l_old_line_rec OE_Order_PUB.Line_Rec_Type;
8464 l_old_line_tbl OE_Order_PUB.Line_Tbl_Type;
8465 l_Line_Adj_rec OE_Order_PUB.Line_Adj_Rec_Type;
8466 l_Line_Adj_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
8467 l_old_Line_Adj_rec OE_Order_PUB.Line_Adj_Rec_Type;
8468 l_old_Line_Adj_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
8469 l_Line_price_Att_rec OE_Order_PUB.Line_Price_Att_Rec_Type ;
8470 l_old_Line_price_Att_rec OE_Order_PUB.Line_Price_Att_Rec_Type ;
8471 l_Line_price_Att_Tbl OE_Order_PUB.Line_Price_Att_Tbl_Type ;
8472 l_Old_Line_price_Att_Tbl OE_Order_PUB.Line_Price_Att_Tbl_Type ;
8473 l_Line_Adj_Att_tbl OE_Order_PUB.Line_Adj_Att_Tbl_Type ;
8474 l_old_Line_Adj_Att_tbl OE_Order_PUB.Line_Adj_Att_Tbl_Type ;
8475 l_Line_Adj_Att_Rec OE_Order_PUB.Line_Adj_Att_Rec_Type ;
8476 l_old_Line_Adj_Att_Rec OE_Order_PUB.Line_Adj_Att_Rec_Type ;
8477 l_Line_Adj_Assoc_tbl OE_Order_PUB.Line_Adj_Assoc_Tbl_Type ;
8478 l_old_Line_Adj_Assoc_tbl OE_Order_PUB.Line_Adj_Assoc_Tbl_Type ;
8479 l_Line_Adj_Assoc_Rec OE_Order_PUB.Line_Adj_Assoc_Rec_Type ;
8480 l_old_Line_Adj_Assoc_Rec OE_Order_PUB.Line_Adj_Assoc_Rec_Type ;
8481 l_Line_Scredit_rec OE_Order_PUB.Line_Scredit_Rec_Type;
8482 l_Line_Scredit_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
8483 l_old_Line_Scredit_rec OE_Order_PUB.Line_Scredit_Rec_Type;
8484 l_old_Line_Scredit_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
8485 l_Lot_Serial_rec OE_Order_PUB.Lot_Serial_Rec_Type;
8486 l_Lot_Serial_tbl OE_Order_PUB.Lot_Serial_Tbl_Type;
8487 l_old_Lot_Serial_rec OE_Order_PUB.Lot_Serial_Rec_Type;
8488 l_old_Lot_Serial_tbl OE_Order_PUB.Lot_Serial_Tbl_Type;
8489 l_request_tbl OE_Order_PUB.REQUEST_TBL_TYPE :=
8490 p_x_action_request_tbl;
8491
8492 l_lot_serial_val_tbl OE_Order_Pub.Lot_Serial_Val_Tbl_Type;
8493 l_old_lot_serial_val_tbl OE_Order_Pub.Lot_Serial_Val_Tbl_Type;
8494 l_line_index NUMBER;
8495 l_header_id NUMBER;
8496 I NUMBER; -- Used for as table index.
8497 l_init_msg_list VARCHAR2(1) := p_init_msg_list;
8498 l_validation_level NUMBER := FND_API.G_VALID_LEVEL_FULL;
8499 l_Call_Split BOOLEAN := FALSE;
8500 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
8501 l_edi_ack_pfile Varchar2(3);
8502
8503 BEGIN
8504
8505 -- Track the recursion
8506
8507 set_recursion_mode(p_Entity_Code => 1,
8508 p_In_out => 1);
8509
8510 x_return_status := FND_API.G_RET_STS_SUCCESS;
8511 fnd_profile.get('ONT_NEW_EDI_ACK_FWK', l_edi_ack_pfile);
8512 l_edi_ack_pfile := nvl(l_edi_ack_pfile, 'NO');
8513
8514 IF OE_GLOBALS.G_RECURSION_MODE <> 'Y' THEN
8515
8516 SAVEPOINT Process_Order;
8517 END IF;
8518
8519
8520 IF l_debug_level > 0 THEN
8521 oe_debug_pub.add( 'ENTERING OE_ORDER_PUB.PROCESS_ORDER' , 1 ) ;
8522 END IF;
8523 -- Standard call to check for call compatibility
8524
8525 IF NOT FND_API.Compatible_API_Call
8526 ( l_api_version_number
8527 , p_api_version_number
8528 , l_api_name
8529 , G_PKG_NAME
8530 )
8531 THEN
8532 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8533 END IF;
8534
8535 -- Initialize message list.
8536
8537 IF FND_API.to_Boolean(p_init_msg_list) THEN
8538 OE_MSG_PUB.initialize;
8539 END IF;
8540
8541 -- Set Org Context
8542
8543 OE_GLOBALS.Set_Context;
8544
8545 -- Bug 1929163: improving performance by not copying in variables
8546 -- to local variables. Can directly work on the IN OUT variables
8547 -- IMPORTANT NOTE:
8548 -- Please add code both in process_order AND process_order_ag
8549 -- procedures when making further modifications. At some later point
8550 -- when QA has completely tested the new code path, process_order
8551 -- will be replaced with code in process_order_ag.
8552
8553 -- With OM Family Pack I or 11.5.9 onwards, new performance code
8554 -- will be activated.
8555
8556 IF OE_CODE_CONTROL.Code_Release_Level >= '110509' THEN
8557 Process_Order_AG
8558 ( p_api_version_number => p_api_version_number
8559 , p_init_msg_list => p_init_msg_list
8560 , p_validation_level => p_validation_level
8561 , p_control_rec => p_control_rec
8562 , x_return_status => x_return_status
8563 , x_msg_count => x_msg_count
8564 , x_msg_data => x_msg_data
8565 , p_x_header_rec => p_x_header_rec
8566 , p_old_header_rec => p_old_header_rec
8567 , p_x_header_adj_tbl => p_x_header_adj_tbl
8568 , p_old_header_adj_tbl => p_old_header_adj_tbl
8569 , p_x_header_price_att_tbl => p_x_header_price_att_tbl
8570 , p_old_header_price_att_tbl => p_old_header_price_att_tbl
8571 , p_x_Header_Adj_Att_tbl => p_x_header_adj_Att_tbl
8572 , p_old_Header_Adj_Att_tbl => p_old_header_Adj_Att_tbl
8573 , p_x_Header_Adj_Assoc_tbl => p_x_header_adj_Assoc_tbl
8574 , p_old_Header_Adj_Assoc_tbl => p_old_header_Adj_Assoc_tbl
8575 , p_x_Header_Scredit_tbl => p_x_header_scredit_tbl
8576 , p_old_Header_Scredit_tbl => p_old_header_Scredit_tbl
8577 , p_x_Header_Payment_tbl => p_x_header_Payment_tbl
8578 , p_old_Header_Payment_tbl => p_old_header_Payment_tbl
8579 , p_x_line_tbl => p_x_line_tbl
8580 , p_old_line_tbl => p_old_line_tbl
8581 , p_x_Line_Adj_tbl => p_x_line_adj_tbl
8582 , p_old_Line_Adj_tbl => p_old_line_Adj_tbl
8583 , p_x_Line_Price_Att_tbl => p_x_line_price_Att_tbl
8584 , p_old_Line_Price_Att_tbl => p_old_line_Price_Att_tbl
8585 , p_x_Line_Adj_Att_tbl => p_x_line_adj_Att_tbl
8586 , p_old_Line_Adj_Att_tbl => p_old_line_Adj_Att_tbl
8587 , p_x_Line_Adj_Assoc_tbl => p_x_line_adj_Assoc_tbl
8588 , p_old_Line_Adj_Assoc_tbl => p_old_line_Adj_Assoc_tbl
8589 , p_x_Line_Scredit_tbl => p_x_line_scredit_tbl
8590 , p_old_Line_Scredit_tbl => p_old_line_Scredit_tbl
8591 , p_x_Line_Payment_tbl => p_x_line_Payment_tbl
8592 , p_old_Line_Payment_tbl => p_old_line_Payment_tbl
8593 , p_x_Lot_Serial_tbl => p_x_lot_serial_tbl
8594 , p_old_Lot_Serial_tbl => p_old_lot_Serial_tbl
8595 , p_Lot_Serial_val_tbl => p_lot_serial_val_tbl
8596 , p_old_Lot_Serial_val_tbl => p_old_lot_Serial_val_tbl
8597 , p_x_action_request_tbl => p_x_action_request_tbl
8598 );
8599 GOTO END_OF_PROCESS_ORDER;
8600 END IF;
8601
8602 -- Init local table variables.
8603
8604 l_Header_Adj_tbl := p_x_Header_Adj_tbl;
8605 l_old_Header_Adj_tbl := p_old_Header_Adj_tbl;
8606
8607 l_Header_price_Att_tbl := p_x_Header_Price_Att_Tbl;
8608 l_old_Header_price_Att_tbl := p_old_Header_Price_Att_Tbl;
8609
8610 l_Header_Adj_Att_tbl := p_x_Header_Adj_Att_Tbl;
8611 l_old_Header_Adj_Att_tbl := p_old_Header_Adj_Att_Tbl;
8612
8613 l_Header_Adj_Assoc_tbl := P_x_Header_Adj_Assoc_Tbl;
8614 l_old_Header_Adj_Assoc_tbl := P_old_Header_Adj_Assoc_Tbl;
8615
8616 -- Init local table variables.
8617
8618 l_Header_Scredit_tbl := p_x_Header_Scredit_tbl;
8619 l_old_Header_Scredit_tbl := p_old_Header_Scredit_tbl;
8620
8621 -- Init local table variables.
8622
8623 l_line_tbl := p_x_line_tbl;
8624 l_old_line_tbl := p_old_line_tbl;
8625
8626 -- Init local table variables.
8627
8628 l_Line_Adj_tbl := p_x_Line_Adj_tbl;
8629 l_old_Line_Adj_tbl := p_old_Line_Adj_tbl;
8630
8631 l_Line_price_Att_tbl := p_x_Line_Price_Att_Tbl;
8632 l_old_Line_price_Att_tbl := p_old_Line_Price_Att_Tbl;
8633
8634 l_Line_Adj_Att_tbl := p_x_Line_Adj_Att_Tbl;
8635 l_old_Line_Adj_Att_tbl := p_old_Line_Adj_Att_Tbl;
8636
8637 l_Line_Adj_Assoc_tbl := P_x_Line_Adj_Assoc_Tbl;
8638 l_old_Line_Adj_Assoc_tbl := P_old_Line_Adj_Assoc_Tbl;
8639
8640 -- Init local table variables.
8641
8642 l_Line_Scredit_tbl := p_x_Line_Scredit_tbl;
8643 l_old_Line_Scredit_tbl := p_old_Line_Scredit_tbl;
8644
8645 -- Init local table variables.
8646
8647 l_Lot_Serial_tbl := p_x_Lot_Serial_tbl;
8648 l_old_Lot_Serial_tbl := p_old_Lot_Serial_tbl;
8649
8650 -- Header
8651
8652 IF l_debug_level > 0 THEN
8653 oe_debug_pub.add( 'BEFORE HEADER PROCESSING' , 2 ) ;
8654 oe_debug_pub.add( 'HEADER_ID' || L_HEADER_REC.HEADER_ID , 2 ) ;
8655 oe_debug_pub.add( 'OPERATION' || L_HEADER_REC.OPERATION , 2 ) ;
8656 END IF;
8657
8658 -------------------------------------------------------
8659 -- Process Header
8660 -------------------------------------------------------
8661
8662 --Bug 2790512: Prevent processing of header if operation is invalid
8663 --Bug 2878121: Ignore NULL operation code
8664 IF l_header_rec.header_id is NOT NULL AND
8665 l_header_rec.header_id <> FND_API.G_MISS_NUM THEN
8666 IF l_header_rec.operation IS NOT NULL AND
8667 l_header_rec.operation NOT IN (OE_GLOBALS.G_OPR_CREATE,
8668 OE_GLOBALS.G_OPR_DELETE, OE_GLOBALS.G_OPR_UPDATE,
8669 OE_GLOBALS.G_OPR_NONE) THEN
8670 FND_MESSAGE.SET_NAME('ONT','OE_OI_OPERATION_CODE');
8671 OE_MSG_PUB.Add;
8672 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8673 END IF;
8674 END IF;
8675
8676 IF l_header_rec.operation IS NOT NULL
8677 AND l_header_rec.operation <> OE_GLOBALS.G_OPR_NONE
8678 THEN
8679
8680 -- This if is add to honor users sales credits if they do not
8681 -- want the default sales credit for the salesrep on the order
8682
8683 IF l_Header_Scredit_tbl.COUNT > 0 and
8684 l_header_rec.operation = oe_globals.g_opr_create THEN
8685 OE_Validate_Header_Scredit.G_Create_Auto_Sales_Credit := 'N';
8686 END IF;
8687
8688 Header
8689 ( p_validation_level => p_validation_level
8690 , p_control_rec => p_control_rec
8691 , p_x_header_rec => l_header_rec
8692 , p_x_old_header_rec => l_old_header_rec
8693 , x_return_status => l_return_status
8694 );
8695
8696 OE_Validate_Header_Scredit.G_Create_Auto_Sales_Credit := 'Y';
8697
8698 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
8699 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8700 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
8701 RAISE FND_API.G_EXC_ERROR;
8702 END IF;
8703 END IF;
8704 IF l_debug_level > 0 THEN
8705 oe_debug_pub.add( 'AFTER HEADER PROCESSING HEADER_ID = '|| TO_CHAR ( L_HEADER_REC.HEADER_ID ) , 2 ) ;
8706 END IF;
8707
8708 -- Perform header group requests.
8709
8710 IF (p_control_rec.process AND
8711 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
8712 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
8713 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_HEADER)
8714 THEN
8715
8716 NULL;
8717
8718 END IF;
8719
8720
8721 -------------------------------------------------------
8722 -- Process Header Adjustments
8723 -------------------------------------------------------
8724
8725 -- Set Header Id on Hdr Adjustments
8726
8727 I := l_Header_Adj_tbl.FIRST;
8728 WHILE I IS NOT NULL LOOP
8729
8730 -- FOR I IN 1..l_Header_Adj_tbl.COUNT LOOP
8731
8732 IF l_debug_level > 0 THEN
8733 oe_debug_pub.add( 'SETTING HEADER ID ON HDR_ADJ_TBL' , 2 ) ;
8734 END IF;
8735 l_Header_Adj_rec := l_Header_Adj_tbl(I);
8736
8737 IF l_Header_Adj_rec.operation = OE_GLOBALS.G_OPR_CREATE
8738 AND (l_Header_Adj_rec.header_id IS NULL OR
8739 l_Header_Adj_rec.header_id = FND_API.G_MISS_NUM)
8740 THEN
8741 IF l_header_rec.header_id IS NULL OR
8742 l_header_rec.header_id = FND_API.G_MISS_NUM THEN
8743 FND_MESSAGE.SET_NAME('ONT','OE_HEADER_MISSING');
8744 OE_MSG_PUB.Add;
8745 RAISE FND_API.G_EXC_ERROR;
8746 ELSE
8747 -- Copy parent_id.
8748 l_Header_Adj_tbl(I).header_id := l_header_rec.header_id;
8749 END IF;
8750 END IF;
8751
8752 -- This is added to prevent invalid upgraded orders
8753 IF I = l_Header_Adj_tbl.FIRST THEN
8754 IF (l_header_adj_rec.header_id IS NOT NULL AND
8755 l_header_adj_rec.header_id <> FND_API.G_MISS_NUM) THEN
8756 IF NOT Valid_Upgraded_Order(l_header_adj_rec.header_id ) THEN
8757 RAISE FND_API.G_EXC_ERROR;
8758 END IF;
8759 END IF;
8760
8761 END IF;
8762
8763 I := l_Header_Adj_tbl.NEXT(I);
8764
8765 END LOOP;
8766
8767 -- Header_Adjs
8768
8769 IF l_Header_Adj_tbl.COUNT > 0 THEN
8770 IF l_debug_level > 0 THEN
8771 oe_debug_pub.add( 'BEFORE OE_ORDER_ADJ_PVT.HEADER_ADJS PROCESSING' , 2 ) ;
8772 END IF;
8773 oe_order_adj_pvt.Header_Adjs
8774 ( p_validation_level => p_validation_level
8775 , p_control_rec => p_control_rec
8776 , p_x_Header_Adj_tbl => l_Header_Adj_tbl
8777 , p_x_old_Header_Adj_tbl => l_old_Header_Adj_tbl
8778 );
8779 END IF;
8780
8781 IF l_debug_level > 0 THEN
8782 oe_debug_pub.add( 'AFTER HEADER_ADJS PROCESSING' , 2 ) ;
8783 END IF;
8784 -- Perform Header_Adj group requests.
8785
8786 IF (p_control_rec.process AND
8787 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
8788 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
8789 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_HEADER_ADJ)
8790 THEN
8791
8792 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
8793 (p_entity_code => OE_GLOBALS.G_ENTITY_HEADER_ADJ
8794 ,p_delete => FND_API.G_TRUE
8795 ,x_return_status => l_return_status
8796 );
8797 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
8798 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8799 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
8800 RAISE FND_API.G_EXC_ERROR;
8801 END IF;
8802
8803
8804 END IF;
8805
8806
8807 -------------------------------------------------------
8808 -- Process Header Price Attributes
8809 -------------------------------------------------------
8810
8811 -- Set Header Id on Hdr Price Attributes
8812
8813 I := l_Header_Price_att_tbl.FIRST;
8814
8815 WHILE I IS NOT NULL LOOP
8816
8817 IF l_debug_level > 0 THEN
8818 oe_debug_pub.add( 'SETTING HEADER ID ON HDR_PRICE_ATT_TBL' , 2 ) ;
8819 END IF;
8820 l_Header_Price_Att_Rec := l_Header_Price_att_tbl(I);
8821
8822 IF l_Header_Price_Att_rec.operation = OE_GLOBALS.G_OPR_CREATE
8823 AND (l_Header_Price_Att_rec.header_id IS NULL OR
8824 l_Header_Price_Att_rec.header_id = FND_API.G_MISS_NUM)
8825 THEN
8826 IF l_header_rec.header_id IS NULL OR
8827 l_header_rec.header_id = FND_API.G_MISS_NUM THEN
8828 FND_MESSAGE.SET_NAME('ONT','OE_HEADER_MISSING');
8829 OE_MSG_PUB.Add;
8830 RAISE FND_API.G_EXC_ERROR;
8831 ELSE
8832
8833 -- Copy parent_id.
8834
8835 l_Header_Price_Att_tbl(I).header_id := l_header_rec.header_id;
8836 END IF;
8837 END IF;
8838 I := l_Header_Price_Att_tbl.NEXT(I);
8839 END LOOP;
8840
8841 -- Header_Price_Atts
8842
8843 IF l_Header_Price_Att_tbl.COUNT > 0 THEN
8844 IF l_debug_level > 0 THEN
8845 oe_debug_pub.add( 'BEFORE OE_ORDER_ADJ_PVT.HEADER_PRICE_ATTS PROCESSING' , 2 ) ;
8846 END IF;
8847 oe_order_adj_pvt.Header_Price_Atts
8848 ( p_validation_level => p_validation_level
8849 , p_control_rec => p_control_rec
8850 , p_x_Header_Price_Att_tbl => l_Header_Price_Att_tbl
8851 , p_x_old_Header_Price_Att_tbl => l_old_Header_Price_Att_tbl
8852 );
8853 END IF;
8854
8855 IF l_debug_level > 0 THEN
8856 oe_debug_pub.add( 'AFTER HEADER_PRICE_ATTS PROCESSING' , 2 ) ;
8857 END IF;
8858 -- Perform Header_Price_Att group requests.
8859
8860 IF (p_control_rec.process AND
8861 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
8862 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL
8863 OR
8864 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_Header_Price_Att
8865 )
8866 THEN
8867
8868 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
8869 (p_entity_code => OE_GLOBALS.G_ENTITY_Header_Price_Att
8870 ,p_delete => FND_API.G_TRUE
8871 ,x_return_status => l_return_status
8872 );
8873 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
8874 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8875 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
8876 RAISE FND_API.G_EXC_ERROR;
8877 END IF;
8878
8879
8880 END IF;
8881
8882
8883 -------------------------------------------------------
8884 -- Process Header Adj Attributes
8885 -------------------------------------------------------
8886
8887 -- Set Header Id on Hdr Adj. Attributes
8888
8889 I := l_Header_Adj_Att_tbl.FIRST;
8890
8891 WHILE I IS NOT NULL LOOP
8892
8893 IF l_debug_level > 0 THEN
8894 oe_debug_pub.add( 'SETTING PRICE ADJUSTMENT ID ON HDR_ADJ_ATTBS' , 2 ) ;
8895 END IF;
8896 l_Header_Adj_Att_rec := l_Header_Adj_Att_tbl(I);
8897
8898 IF l_Header_Adj_Att_rec.operation = OE_GLOBALS.G_OPR_CREATE
8899 AND (l_Header_Adj_Att_rec.price_adjustment_id IS NULL OR
8900 l_Header_Adj_Att_rec.price_adjustment_id = FND_API.G_MISS_NUM)
8901 THEN
8902
8903 IF l_header_Adj_Tbl.exists(l_Header_Adj_Att_Rec.Adj_index)
8904 Then
8905 -- Copy parent_id.
8906
8907 l_Header_Adj_Att_tbl(I).price_adjustment_id :=
8908 l_header_Adj_Tbl(l_Header_Adj_Att_Rec.adj_index).price_adjustment_id;
8909 ELSE
8910 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
8911 THEN
8912 IF l_debug_level > 0 THEN
8913 oe_debug_pub.add( 'INVALID ADJ INDEX '|| TO_CHAR ( L_HEADER_ADJ_ATT_REC.ADJ_INDEX ) || 'ON HEADER ADJ ATTRIBUTES' , 2 ) ;
8914 END IF;
8915 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8916 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
8917 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Header_Adj_Attribs');
8918 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
8919 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',l_Header_Adj_Att_Rec.adj_index);
8920 OE_MSG_PUB.Add;
8921 END IF;
8922 END IF;
8923
8924 END IF;
8925 I := l_Header_Adj_Att_tbl.NEXT(I);
8926 END LOOP;
8927
8928 -- Header_Adj_Atts
8929 IF l_Header_Adj_Att_tbl.COUNT > 0 THEN
8930
8931 IF l_debug_level > 0 THEN
8932 oe_debug_pub.add( 'BEFORE OE_ORDER_ADJ_PVT.HEADER_ADJ_ATTS PROCESSING' , 2 ) ;
8933 END IF;
8934 oe_order_adj_pvt.Header_Adj_Atts
8935 ( p_validation_level => p_validation_level
8936 , p_control_rec => p_control_rec
8937 , p_x_Header_Adj_Att_tbl => l_Header_Adj_Att_tbl
8938 , p_x_old_Header_Adj_Att_tbl => l_old_Header_Adj_Att_tbl
8939 );
8940
8941 IF l_debug_level > 0 THEN
8942 oe_debug_pub.add( 'AFTER HEADER_ADJ_ATTS PROCESSING' , 2 ) ;
8943 END IF;
8944
8945 END IF;
8946
8947 -- Perform Header_Adj_Att group requests.
8948
8949 /*
8950 IF (p_control_rec.process AND
8951 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
8952 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL
8953 OR
8954 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_Header_Adj_Att
8955 )
8956 THEN
8957
8958 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
8959 (p_entity_code => OE_GLOBALS.G_ENTITY_Header_Adj_Att
8960 ,p_delete => FND_API.G_TRUE
8961 ,x_return_status => l_return_status
8962 );
8963 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
8964 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8965 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
8966 RAISE FND_API.G_EXC_ERROR;
8967 END IF;
8968
8969
8970 END IF;
8971 */
8972
8973
8974 -------------------------------------------------------
8975 -- Process Header Adjustment Associations
8976 -------------------------------------------------------
8977
8978 -- Set Header Id on Hdr Adjustment Associations
8979
8980 I := l_Header_Adj_Assoc_tbl.FIRST;
8981
8982 WHILE I IS NOT NULL LOOP
8983
8984 IF l_debug_level > 0 THEN
8985 oe_debug_pub.add( 'SETTING HEADER ID ON HDR_ADJ_ASSOC_TBL' , 2 ) ;
8986 END IF;
8987 l_Header_Adj_Assoc_rec := l_Header_Adj_Assoc_tbl(I);
8988
8989 IF l_Header_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_CREATE
8990 AND (l_Header_Adj_Assoc_rec.Price_Adjustment_id IS NULL OR
8991 l_Header_Adj_Assoc_rec.Price_Adjustment_id = FND_API.G_MISS_NUM)
8992 THEN
8993
8994 IF l_header_Adj_Tbl.exists(l_Header_Adj_Assoc_Rec.Adj_Index) Then
8995 -- Copy parent_id.
8996
8997 l_Header_Adj_Assoc_tbl(I).price_adjustment_id :=
8998 l_header_Adj_Tbl(l_Header_Adj_Assoc_Rec.adj_index).price_adjustment_id;
8999 ELSE
9000 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
9001 THEN
9002 IF l_debug_level > 0 THEN
9003 oe_debug_pub.add( 'INVALID ADJ INDEX '|| TO_CHAR ( L_HEADER_ADJ_ASSOC_REC.ADJ_INDEX ) || 'ON HEADER ADJ ATTRIBUTES' , 2 ) ;
9004 END IF;
9005 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9006 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
9007 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Header_Adj_Assocs');
9008 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
9009 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',l_Header_Adj_Assoc_Rec.adj_index);
9010 OE_MSG_PUB.Add;
9011 END IF;
9012 END IF;
9013
9014 END IF;
9015
9016 IF l_Header_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_CREATE
9017 AND (l_Header_Adj_Assoc_rec.rltd_Price_Adj_Id IS NULL OR
9018 l_Header_Adj_Assoc_rec.rltd_Price_Adj_Id = FND_API.G_MISS_NUM)
9019 THEN
9020
9021 IF l_header_Adj_Tbl.exists(l_Header_Adj_Assoc_Rec.Rltd_Adj_Index) Then
9022 -- Copy parent_id.
9023
9024 l_Header_Adj_Assoc_tbl(I).rltd_Price_Adj_Id :=
9025 l_header_Adj_Tbl(l_Header_Adj_Assoc_Rec.Rltd_Adj_Index).Price_adjustment_id;
9026 END IF;
9027
9028 END IF;
9029 I := l_Header_Adj_Assoc_tbl.NEXT(I);
9030 END LOOP;
9031
9032 -- Header_Adj_Assocs
9033
9034 IF l_Header_Adj_Assoc_tbl.COUNT > 0 THEN
9035
9036 IF l_debug_level > 0 THEN
9037 oe_debug_pub.add( 'BEFORE OE_ORDER_ADJ_PVT.HEADER_ADJ_ASSOCS PROCESSING' , 2 ) ;
9038 END IF;
9039 oe_order_adj_pvt.Header_Adj_Assocs
9040 ( p_validation_level => p_validation_level
9041 , p_control_rec => p_control_rec
9042 , p_x_Header_Adj_Assoc_tbl => l_Header_Adj_Assoc_tbl
9043 , p_x_old_Header_Adj_Assoc_tbl => l_old_Header_Adj_Assoc_tbl
9044 );
9045
9046 IF l_debug_level > 0 THEN
9047 oe_debug_pub.add( 'AFTER HEADER_ADJ_ASSOCS PROCESSING' , 2 ) ;
9048 END IF;
9049 END IF;
9050
9051 -- Perform Header_Adj_Assoc group requests.
9052
9053 /*
9054 IF (p_control_rec.process AND
9055 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
9056 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL
9057 OR
9058 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_Header_Adj_Assoc
9059 )
9060 THEN
9061
9062 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
9063 (p_entity_code => OE_GLOBALS.G_ENTITY_Header_Adj_Assoc
9064 ,p_delete => FND_API.G_TRUE
9065 ,x_return_status => l_return_status
9066 );
9067 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
9068 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9069 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
9070 RAISE FND_API.G_EXC_ERROR;
9071 END IF;
9072
9073
9074 END IF;
9075 */
9076
9077
9078 -------------------------------------------------------
9079 -- Process Header Sales Credits
9080 -------------------------------------------------------
9081
9082
9083 -- Set Header Id on Sales Credits
9084
9085 -- FOR I IN 1..l_Header_Scredit_tbl.COUNT LOOP
9086
9087 I := l_Header_Scredit_tbl.FIRST;
9088 WHILE I IS NOT NULL LOOP
9089
9090 IF l_debug_level > 0 THEN
9091 oe_debug_pub.add( 'SETTING HEADER_ID ON HEADER_SCREDIT_TBL:'||to_char(l_header_rec.header_id)||'.' , 2 ) ;
9092 END IF;
9093
9094 l_Header_Scredit_rec := l_Header_Scredit_tbl(I);
9095
9096 IF l_Header_Scredit_rec.operation = OE_GLOBALS.G_OPR_CREATE
9097 AND (l_Header_Scredit_rec.header_id IS NULL OR
9098 l_Header_Scredit_rec.header_id = FND_API.G_MISS_NUM)
9099 THEN
9100 IF l_header_rec.header_id IS NULL OR -- p_x_header_rec replaced with l_header_rec for 2896409
9101 l_header_rec.header_id = FND_API.G_MISS_NUM THEN
9102 FND_MESSAGE.SET_NAME('ONT','OE_HEADER_MISSING');
9103 OE_MSG_PUB.Add;
9104 RAISE FND_API.G_EXC_ERROR;
9105 ELSE
9106
9107 -- Copy parent_id.
9108
9109 l_Header_Scredit_tbl(I).header_id := l_header_rec.header_id;
9110 END IF;
9111 END IF;
9112
9113 I := l_Header_Scredit_tbl.NEXT(I);
9114 END LOOP;
9115
9116 -- Header_Scredits
9117
9118 IF l_Header_Scredit_tbl.COUNT > 0 THEN
9119
9120 IF l_debug_level > 0 THEN
9121 oe_debug_pub.add( 'BEFORE HEADER_SCREDITS PROCESSING' , 2 ) ;
9122 END IF;
9123 Header_Scredits
9124 ( p_validation_level => p_validation_level
9125 , p_control_rec => p_control_rec
9126 , p_x_Header_Scredit_tbl => l_Header_Scredit_tbl
9127 , p_x_old_Header_Scredit_tbl => l_old_Header_Scredit_tbl
9128 , x_return_status => l_return_status
9129 );
9130 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
9131 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9132 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
9133 IF p_control_rec.process_partial THEN
9134 x_return_status := FND_API.G_RET_STS_ERROR;
9135 ELSE
9136 RAISE FND_API.G_EXC_ERROR;
9137 END IF;
9138 END IF;
9139 IF l_debug_level > 0 THEN
9140 oe_debug_pub.add( 'AFTER HEADER_SCREDITS PROCESSING' , 2 ) ;
9141 END IF;
9142
9143 END IF;
9144
9145 -- Perform Header_Scredit group requests.
9146
9147 IF (p_control_rec.process AND
9148 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
9149 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
9150 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_HEADER_SCREDIT)
9151 THEN
9152
9153 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
9154 (p_entity_code => OE_GLOBALS.G_ENTITY_Header_Scredit
9155 ,p_delete => FND_API.G_TRUE
9156 ,x_return_status => l_return_status
9157 );
9158 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
9159 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9160 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
9161 RAISE FND_API.G_EXC_ERROR;
9162 END IF;
9163
9164 END IF;
9165
9166
9167 -- Get header_id from the header and put it on the line.
9168
9169 -- Kris = decide if
9170 -- Header id may not be passed on the header record if the operation is none
9171 -- I think we should pass header_id on the header rec all the time
9172
9173 /*
9174 IF l_line_tbl.COUNT > 0 THEN
9175
9176 For k in l_line_tbl.first .. l_line_tbl.last LOOP
9177
9178 IF (l_line_tbl(k).header_id = FND_API.G_MISS_NUM
9179 OR l_line_tbl(k).header_id is null ) THEN
9180
9181 -- Kris do not loop through the lines unless they have the right header_id
9182 -- If people pass in a header_id with a bogus value, the record should be ignored
9183
9184 l_line_tbl(k).header_id := l_header_rec.header_id;
9185
9186 END IF;
9187
9188 End Loop;
9189
9190 END IF;
9191 */
9192
9193
9194 -------------------------------------------------------
9195 -- Process Lines
9196 -------------------------------------------------------
9197
9198 -- FOR I IN 1..l_line_tbl.COUNT LOOP
9199
9200 I := l_line_tbl.FIRST;
9201
9202 WHILE I IS NOT NULL LOOP
9203
9204 l_line_rec := l_line_tbl(I);
9205
9206 --Bug 2790512: Prevent processing of line if operation is invalid
9207 --Bug 2878121: Ignore NULL operation code
9208 IF l_line_rec.operation IS NOT NULL AND
9209 l_line_rec.operation NOT IN (OE_GLOBALS.G_OPR_CREATE,
9210 OE_GLOBALS.G_OPR_DELETE, OE_GLOBALS.G_OPR_UPDATE,
9211 OE_GLOBALS.G_OPR_INSERT, OE_GLOBALS.G_OPR_NONE) THEN
9212 FND_MESSAGE.SET_NAME('ONT','OE_OI_OPERATION_CODE');
9213 OE_MSG_PUB.Add;
9214 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9215 END IF;
9216
9217 IF l_line_rec.operation = oe_globals.g_opr_update
9218 AND l_line_rec.split_action_code = 'SPLIT' THEN
9219 l_call_split := TRUE;
9220 END IF;
9221
9222 -- START: CHECK IF ALL LINES BELONG TO THE SAME ORDER
9223
9224 -- Retrieve the header ID, either from the header record
9225 -- or from the first line
9226 IF (I = l_line_tbl.FIRST) THEN
9227 IF (l_header_rec.header_id IS NOT NULL AND
9228 l_header_rec.header_id <> FND_API.G_MISS_NUM) THEN
9229 l_header_id := l_header_rec.header_id;
9230 ELSIF (l_line_rec.header_id IS NOT NULL AND
9231 l_line_rec.header_id <> FND_API.G_MISS_NUM) THEN
9232 l_header_id := l_line_tbl(I).header_id;
9233 END IF;
9234 END IF;
9235
9236 IF l_line_rec.operation <> OE_GLOBALS.G_OPR_CREATE
9237 AND (l_line_rec.header_id IS NULL OR
9238 l_line_rec.header_id = FND_API.G_MISS_NUM)
9239 THEN
9240 IF (l_header_id IS NOT NULL AND
9241 l_header_id <> FND_API.G_MISS_NUM) THEN
9242 l_line_tbl(I).header_id := l_header_id;
9243 ELSE
9244 oe_line_util.query_header
9245 (p_line_id => l_line_rec.line_id,
9246 x_header_id => l_header_id);
9247 l_line_tbl(I).header_id := l_header_id;
9248 END IF;
9249 END IF;
9250
9251 -- Copy the parent ID (header ID), if not passed, on
9252 -- the record for CREATE operations
9253 IF l_line_rec.operation = OE_GLOBALS.G_OPR_CREATE
9254 THEN
9255
9256 IF (l_line_rec.header_id IS NULL OR
9257 l_line_rec.header_id = FND_API.G_MISS_NUM)
9258 THEN
9259 -- Copy parent_id.
9260 l_line_tbl(I).header_id := l_header_id;
9261 END IF;
9262
9263 END IF;
9264
9265 -- Raise error if the header ID for the line is different
9266 -- from header ID on the header record or other lines
9267 IF (l_header_id IS NOT NULL AND
9268 l_header_id <> FND_API.G_MISS_NUM) THEN
9269 IF l_line_tbl(I).header_id <> l_header_id THEN
9270 fnd_message.set_name('ONT', 'OE_HEADER_MISSING');
9271 oe_msg_pub.add;
9272 RAISE FND_API.G_EXC_ERROR;
9273 END IF;
9274 END IF;
9275
9276 -- END: CHECK IF ALL LINES BELONG TO THE SAME ORDER
9277
9278
9279 I := l_line_tbl.NEXT(I);
9280
9281 END LOOP;
9282
9283
9284 -- Pre Split Process
9285 IF l_call_split THEN
9286 OE_Split_Util.Check_Split_Course
9287 ( p_x_line_tbl => l_line_tbl,
9288 p_x_line_adj_tbl => l_line_adj_tbl,
9289 p_x_line_scredit_tbl => l_line_scredit_tbl
9290 );
9291 END IF;
9292
9293 -- Lines
9294
9295 IF l_line_tbl.COUNT > 0 THEN
9296
9297 IF l_debug_level > 0 THEN
9298 oe_debug_pub.add( 'BEFORE LINES PROCESSING' , 2 ) ;
9299 END IF;
9300 Lines
9301 ( p_validation_level => p_validation_level
9302 , p_control_rec => p_control_rec
9303 , p_x_line_tbl => l_line_tbl
9304 , p_x_old_line_tbl => l_old_line_tbl
9305 , x_return_status => l_return_status
9306 );
9307 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
9308 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9309 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
9310 IF p_control_rec.process_partial THEN
9311 x_return_status := FND_API.G_RET_STS_ERROR;
9312 ELSE
9313 RAISE FND_API.G_EXC_ERROR;
9314 END IF;
9315 END IF;
9316 IF l_debug_level > 0 THEN
9317 oe_debug_pub.add( 'AFTER LINES PROCESSING' , 2 ) ;
9318 END IF;
9319
9320 END IF;
9321
9322 -- Set Header/Line_id on Line Sc and Line Pr Adj tables using the line index.
9323 -- We do this so that Lines and its children can be inserted in one call.
9324
9325 /* IF l_line_tbl.COUNT > 0 THEN
9326
9327 IF l_Line_Scredit_tbl.COUNT > 0 THEN
9328
9329 oe_debug_pub.add('Setting Header/Line Ids on Line SC table', 2);
9330
9331 FOR k in l_Line_Scredit_tbl.first .. l_line_Scredit_tbl.last LOOP
9332
9333 -- oe_debug_pub.add('Processing Line SC Record ' ||TO_CHAR(k), 2);
9334
9335 IF (l_line_Scredit_tbl(k).line_index <> FND_API.G_MISS_NUM)
9336 AND (l_line_Scredit_tbl(k).line_index IS NOT NULL) THEN
9337
9338 l_line_index := l_line_Scredit_tbl(k).line_index;
9339
9340 IF l_line_tbl.EXISTS(l_line_index) THEN
9341
9342 IF (l_line_Scredit_tbl(k).line_id = FND_API.G_MISS_NUM)
9343 OR (l_line_Scredit_tbl(k).line_id IS NULL) THEN
9344
9345 l_line_Scredit_tbl(k).line_id := l_line_tbl(l_line_index).line_id;
9346
9347 END IF; -- Line Id on Child is missing or is null
9348
9349
9350 IF (l_line_Scredit_tbl(k).header_id = FND_API.G_MISS_NUM)
9351 OR (l_line_Scredit_tbl(k).header_id IS NULL) THEN
9352
9353 l_line_Scredit_tbl(k).header_id := l_line_tbl(l_line_index).header_id;
9354
9355 END IF; -- Header Id on Child is missing or is null
9356
9357
9358 ELSE -- Invalid Index
9359
9360 oe_debug_pub.add('Invalid Line Index '
9361 ||TO_CHAR(l_line_index)
9362 ||' on Line Sales Credits', 2);
9363 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9364
9365 END IF; -- If Valid Line Index
9366 END IF; -- Line Index is not null and not missing
9367
9368 END LOOP;
9369 END IF; -- If Child table has rows
9370
9371
9372 IF l_Line_Adj_tbl.COUNT > 0 THEN
9373
9374 oe_debug_pub.add('Setting Header/Line Ids on Line Adj table', 2);
9375
9376 FOR k in l_Line_Adj_tbl.first .. l_line_Adj_tbl.last LOOP
9377
9378 -- oe_debug_pub.add('Processing Line Adj Record ' ||TO_CHAR(k), 2);
9379
9380 IF (l_line_Adj_tbl(k).line_index <> FND_API.G_MISS_NUM)
9381 AND (l_line_Adj_tbl(k).line_index IS NOT NULL) THEN
9382
9383 l_line_index := l_line_Adj_tbl(k).line_index;
9384 oe_debug_pub.add('Line Index is '||TO_CHAR(l_line_index), 2);
9385
9386 IF l_line_tbl.EXISTS(l_line_index) THEN
9387
9388 IF (l_line_Adj_tbl(k).line_id = FND_API.G_MISS_NUM)
9389 OR (l_line_Adj_tbl(k).line_id IS NULL) THEN
9390
9391 l_line_Adj_tbl(k).line_id := l_line_tbl(l_line_index).line_id;
9392
9393 END IF; -- Line Id on Child is missing or is null
9394
9395 IF (l_line_Adj_tbl(k).Header_id = FND_API.G_MISS_NUM)
9396 OR (l_line_Adj_tbl(k).Header_id IS NULL) THEN
9397
9398 l_line_Adj_tbl(k).Header_id := l_line_tbl(l_line_index).Header_id;
9399
9400 END IF; -- Header Id on Child is missing or is null
9401
9402 ELSE -- Invalid Index
9403
9404 oe_debug_pub.add('Invalid Line Index '
9405 ||TO_CHAR(l_line_index)
9406 ||'on Line Price Adjustments', 2);
9407 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9408
9409 END IF; -- If Valid Line Index
9410 END IF; -- Line Index is not null and not missing
9411
9412 END LOOP;
9413 END IF; -- If Child table has rows
9414 END IF; -- If Line Table has rows
9415 */
9416
9417
9418 -- FOR I IN 1..l_Line_Scredit_tbl.COUNT LOOP
9419
9420 I := l_Line_Scredit_tbl.FIRST;
9421 WHILE I IS NOT NULL LOOP
9422
9423 IF l_debug_level > 0 THEN
9424 oe_debug_pub.add( 'SETTING HEADER/LINE IDS ON LINE SC TABLE' ) ;
9425 END IF;
9426 l_Line_Scredit_rec := l_Line_Scredit_tbl(I);
9427
9428 IF l_Line_Scredit_rec.operation = OE_GLOBALS.G_OPR_CREATE
9429 AND (l_Line_Scredit_rec.line_id IS NULL OR
9430 l_Line_Scredit_rec.line_id = FND_API.G_MISS_NUM)
9431 THEN
9432 IF l_debug_level > 0 THEN
9433 oe_debug_pub.add( 'SETTING LINE IDS ON LINE SC TABLE' , 2 ) ;
9434 END IF;
9435
9436 -- Check If parent exists.
9437
9438 IF l_line_tbl.EXISTS(l_Line_Scredit_rec.line_index) THEN
9439
9440 -- Copy parent_id.
9441
9442 l_Line_Scredit_tbl(I).line_id := l_line_tbl(l_Line_Scredit_rec.line_index).line_id;
9443 l_Line_Scredit_tbl(I).header_id := l_line_tbl(l_Line_Scredit_rec.line_index).header_id;
9444
9445 -- Following procedure is called to fix bug 2482365
9446 -- If sales credit info is passed by the user we will honor it.
9447 -- Any sales credit record created for this line so far shall be deleted.
9448
9449 OE_Line_Scredit_Util.Delete_Row(p_line_id =>l_Line_Scredit_tbl(I).line_id);
9450 ELSE
9451
9452 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
9453 THEN
9454 IF l_debug_level > 0 THEN
9455 oe_debug_pub.add( 'INVALID LINE INDEX ' ||TO_CHAR ( L_LINE_INDEX ) ||'ON LINE SALES CREDITS' , 2 ) ;
9456 END IF;
9457 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9458 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
9459 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Line_Scredit');
9460 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
9461 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',l_Line_Scredit_rec.line_index);
9462 OE_MSG_PUB.Add;
9463
9464 END IF;
9465 END IF;
9466 END IF;
9467
9468 I := l_Line_Scredit_tbl.NEXT(I);
9469 END LOOP;
9470
9471
9472 -- FOR I IN 1..l_Line_Adj_tbl.COUNT LOOP
9473
9474 I := l_Line_Adj_tbl.FIRST;
9475 WHILE I IS NOT NULL LOOP
9476
9477 IF l_debug_level > 0 THEN
9478 oe_debug_pub.add( 'SETTING HEADER/LINE IDS ON LINE ADJ TABLE' , 2 ) ;
9479 END IF;
9480 l_Line_Adj_rec := l_Line_Adj_tbl(I);
9481
9482 IF l_Line_Adj_rec.operation = OE_GLOBALS.G_OPR_CREATE
9483 AND (l_Line_Adj_rec.line_id IS NULL OR
9484 l_Line_Adj_rec.line_id = FND_API.G_MISS_NUM)
9485 THEN
9486
9487 IF l_debug_level > 0 THEN
9488 oe_debug_pub.add( 'SETTING LINE IDS ON LINE ADJ TABLE' , 2 ) ;
9489 END IF;
9490 -- Check If parent exists.
9491
9492 IF l_Line_Adj_rec.line_index <> fnd_api.g_miss_num and
9493 l_line_tbl.EXISTS(l_Line_Adj_rec.line_index) THEN
9494
9495 -- Copy parent_id.
9496
9497 l_Line_Adj_tbl(I).line_id := l_line_tbl(l_Line_Adj_rec.line_index).line_id;
9498 l_Line_Adj_tbl(I).header_id := l_line_tbl(l_Line_Adj_rec.line_index).header_id;
9499
9500 ELSIF l_Line_Adj_tbl(I).header_id is not null and
9501 l_Line_Adj_tbl(I).header_id <> FND_API.G_MISS_NUM Then
9502 -- Treat the adjustment record as a header_adjustment record
9503 IF l_debug_level > 0 THEN
9504 oe_debug_pub.add( 'TREATING THE RECORD AS HEADER_ADJUSTMENT' ) ;
9505 END IF;
9506 ELSE
9507
9508 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
9509 THEN
9510 IF l_debug_level > 0 THEN
9511 oe_debug_pub.add( 'INVALID LINE INDEX ' ||TO_CHAR ( L_LINE_INDEX ) ||'ON PRICE ADJUSTMENTS' , 2 ) ;
9512 END IF;
9513 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9514
9515 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
9516 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Line_Adj');
9517 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
9518 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',l_Line_Adj_rec.line_index);
9519 OE_MSG_PUB.Add;
9520
9521 END IF;
9522 END IF;
9523 END IF;
9524
9525 I := l_Line_Adj_tbl.NEXT(I);
9526 END LOOP;
9527
9528 -- Perform line group requests.
9529
9530 IF (p_control_rec.process AND
9531 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
9532 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
9533 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_LINE)
9534 THEN
9535 IF l_debug_level > 0 THEN
9536 oe_debug_pub.add( 'PROCESS LINE REQUESTS' ) ;
9537 END IF;
9538
9539 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
9540 (p_entity_code => OE_GLOBALS.G_ENTITY_LINE
9541 ,p_delete => FND_API.G_TRUE
9542 ,x_return_status => l_return_status
9543 );
9544 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
9545 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9546 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
9547 RAISE FND_API.G_EXC_ERROR;
9548 END IF;
9549
9550 END IF;
9551
9552
9553 -------------------------------------------------------
9554 -- Process Lines Adjustments
9555 -------------------------------------------------------
9556
9557 IF l_Line_Adj_tbl.COUNT > 0 THEN
9558
9559 -- Line_Adjs
9560
9561 oe_order_adj_pvt.Line_Adjs
9562 ( p_validation_level => p_validation_level
9563 , p_control_rec => p_control_rec
9564 , p_x_Line_Adj_tbl => l_Line_Adj_tbl
9565 , p_x_old_Line_Adj_tbl => l_old_Line_Adj_tbl
9566 );
9567
9568 END IF;
9569
9570 -- Perform Line_Adj group requests.
9571
9572 IF (p_control_rec.process AND
9573 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
9574 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
9575 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_LINE_ADJ)
9576 THEN
9577
9578 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
9579 (p_entity_code => OE_GLOBALS.G_ENTITY_LINE_ADJ
9580 ,p_delete => FND_API.G_TRUE
9581 ,x_return_status => l_return_status
9582 );
9583 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
9584 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9585 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
9586 RAISE FND_API.G_EXC_ERROR;
9587 END IF;
9588
9589 END IF;
9590
9591 -------------------------------------------------------
9592 -- Process Line Sales Credits
9593 -------------------------------------------------------
9594
9595 -- Line_Scredits
9596
9597 IF l_Line_Scredit_tbl.COUNT > 0 THEN
9598
9599 Line_Scredits
9600 ( p_validation_level => p_validation_level
9601 , p_control_rec => p_control_rec
9602 , p_x_Line_Scredit_tbl => l_Line_Scredit_tbl
9603 , p_x_old_Line_Scredit_tbl => l_old_Line_Scredit_tbl
9604 , x_return_status => l_return_status
9605 );
9606 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
9607 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9608 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
9609 IF p_control_rec.process_partial THEN
9610 x_return_status := FND_API.G_RET_STS_ERROR;
9611 ELSE
9612 RAISE FND_API.G_EXC_ERROR;
9613 END IF;
9614 END IF;
9615
9616 END IF;
9617
9618 -- Perform Line_Scredit group requests.
9619
9620 IF (p_control_rec.process AND
9621 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
9622 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
9623 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_LINE_SCREDIT)
9624 THEN
9625
9626 IF l_debug_level > 0 THEN
9627 oe_debug_pub.add( 'PROCESSING DELAYED REQUESTS FOR LINES' , 2 ) ;
9628 END IF;
9629
9630 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
9631 (p_entity_code => OE_GLOBALS.G_ENTITY_Line_Scredit
9632 ,p_delete => FND_API.G_TRUE
9633 ,x_return_status => l_return_status
9634 );
9635
9636 IF l_debug_level > 0 THEN
9637 oe_debug_pub.add( 'PROCESSED DELAYED REQUESTS FOR LINES' , 2 ) ;
9638 END IF;
9639
9640 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
9641 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9642 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
9643 RAISE FND_API.G_EXC_ERROR;
9644 END IF;
9645
9646 END IF;
9647
9648
9649 -------------------------------------------------------
9650 -- Process Lot Serials
9651 -------------------------------------------------------
9652
9653 IF l_Lot_Serial_tbl.COUNT > 0 THEN
9654
9655 -- Load parent key if missing and operation is create.
9656
9657 -- FOR I IN 1..l_Lot_Serial_tbl.COUNT LOOP
9658
9659 I := l_Lot_Serial_tbl.FIRST;
9660 WHILE I IS NOT NULL LOOP
9661
9662 l_Lot_Serial_rec := l_Lot_Serial_tbl(I);
9663
9664 IF l_Lot_Serial_rec.operation = OE_GLOBALS.G_OPR_CREATE
9665 AND (l_Lot_Serial_rec.line_id IS NULL OR
9666 l_Lot_Serial_rec.line_id = FND_API.G_MISS_NUM)
9667 THEN
9668
9669 -- Check If parent exists.
9670
9671 IF l_line_tbl.EXISTS(l_Lot_Serial_rec.line_index) THEN
9672
9673 -- Copy parent_id.
9674
9675 l_Lot_Serial_tbl(I).line_id := l_line_tbl(l_Lot_Serial_rec.line_index).line_id;
9676
9677 ELSE
9678
9679 IF oe_msg_pub.Check_Msg_Level(oe_msg_pub.G_MSG_LVL_ERROR)
9680 THEN
9681
9682 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
9683 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Lot_Serial');
9684 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
9685 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',l_Lot_Serial_rec.line_index);
9686 oe_msg_pub.Add;
9687
9688 END IF;
9689 END IF;
9690 END IF;
9691 I := l_Lot_Serial_tbl.NEXT(I);
9692 END LOOP;
9693
9694 -- Lot_Serials
9695
9696 Lot_Serials
9697 ( p_validation_level => p_validation_level
9698 , p_control_rec => p_control_rec
9699 , p_x_Lot_Serial_tbl => l_Lot_Serial_tbl
9700 , p_x_old_Lot_Serial_tbl => l_old_Lot_Serial_tbl
9701 , x_return_status => l_return_status
9702 );
9703 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
9704 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9705 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
9706 IF p_control_rec.process_partial THEN
9707 x_return_status := FND_API.G_RET_STS_ERROR;
9708 ELSE
9709 RAISE FND_API.G_EXC_ERROR;
9710 END IF;
9711 END IF;
9712
9713 END IF;
9714
9715 -- Perform Lot_Serial group requests.
9716
9717 IF (p_control_rec.process AND
9718 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
9719 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
9720 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_LOT_SERIAL)
9721 THEN
9722
9723 NULL;
9724
9725 END IF;
9726
9727 -------------------------------------------------------
9728 -- Process Line Price Attributes
9729 -------------------------------------------------------
9730
9731 -- Process line Price Attributes
9732
9733 I := l_Line_Price_Att_tbl.FIRST;
9734 WHILE I IS NOT NULL LOOP
9735
9736 IF l_debug_level > 0 THEN
9737 oe_debug_pub.add( 'SETTING HEADER/LINE IDS ON LINE ATTRIBUTES TABLE' , 2 ) ;
9738 END IF;
9739 l_Line_Price_Att_rec := l_Line_Price_Att_tbl(I);
9740
9741 IF l_Line_Price_Att_rec.operation = OE_GLOBALS.G_OPR_CREATE
9742 AND (l_Line_Price_Att_rec.line_id IS NULL OR
9743 l_Line_Price_Att_rec.line_id = FND_API.G_MISS_NUM)
9744 THEN
9745
9746 IF l_debug_level > 0 THEN
9747 oe_debug_pub.add( 'SETTING LINE IDS ON LINE ATTRIB TABLE' , 2 ) ;
9748 END IF;
9749 -- Check If parent exists.
9750
9751 IF l_line_tbl.EXISTS(l_Line_Price_Att_rec.line_index) THEN
9752
9753 -- Copy parent_id.
9754
9755 l_Line_Price_Att_tbl(I).line_id := l_line_tbl(l_Line_Price_Att_rec.line_index).line_id;
9756 l_Line_Price_Att_tbl(I).header_id := l_line_tbl(l_Line_Price_Att_rec.line_index).header_id;
9757
9758 ELSE
9759
9760 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
9761 THEN
9762 IF l_debug_level > 0 THEN
9763 oe_debug_pub.add( 'INVALID LINE INDEX ' ||TO_CHAR ( L_LINE_PRICE_ATT_REC.LINE_INDEX ) ||'ON PRICE ADJUSTMENTS' , 2 ) ;
9764 END IF;
9765 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9766
9767 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
9768 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Line_Price_Att');
9769 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
9770 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',l_Line_Price_Att_rec.line_index);
9771 OE_MSG_PUB.Add;
9772
9773 END IF;
9774 END IF;
9775 END IF;
9776 I := l_Line_Price_Att_tbl.NEXT(I);
9777 END LOOP;
9778
9779 -- Line_Attribs
9780
9781 IF l_Line_Price_Att_tbl.COUNT > 0 THEN
9782
9783 oe_order_adj_pvt.Line_Price_Atts
9784 ( p_validation_level => p_validation_level
9785 , p_control_rec => p_control_rec
9786 , p_x_Line_Price_Att_tbl => l_Line_Price_Att_tbl
9787 , p_x_old_Line_Price_Att_tbl => l_old_Line_Price_Att_tbl
9788 );
9789
9790 END IF;
9791
9792 -- Perform Line_Price_Att group requests.
9793
9794 IF (p_control_rec.process AND
9795 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
9796 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
9797 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_Line_Price_Att)
9798 THEN
9799
9800 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
9801 (p_entity_code => OE_GLOBALS.G_ENTITY_Line_Price_Att
9802 ,p_delete => FND_API.G_TRUE
9803 ,x_return_status => l_return_status
9804 );
9805 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
9806 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9807 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
9808 RAISE FND_API.G_EXC_ERROR;
9809 END IF;
9810
9811 END IF;
9812
9813
9814 -------------------------------------------------------
9815 -- Process Line Adjustment Attributes
9816 -------------------------------------------------------
9817
9818 -- Process line Adj Attributes
9819
9820 I := l_Line_Adj_Att_tbl.FIRST;
9821 WHILE I IS NOT NULL LOOP
9822
9823 IF l_debug_level > 0 THEN
9824 oe_debug_pub.add( 'SETTING PRICE_ADJUSTMENT_ID ON LINE ADJ ATTRIB TABLE' , 2 ) ;
9825 END IF;
9826 l_Line_Adj_Att_rec := l_Line_Adj_Att_tbl(I);
9827
9828 IF l_Line_Adj_Att_rec.operation = OE_GLOBALS.G_OPR_CREATE
9829 AND (l_Line_Adj_Att_rec.price_adjustment_id IS NULL OR
9830 l_Line_Adj_Att_rec.price_adjustment_id = FND_API.G_MISS_NUM)
9831 THEN
9832
9833 IF l_debug_level > 0 THEN
9834 oe_debug_pub.add( 'SETTING ADJ IDS ON LINE ADJ ATTRIB TABLE' , 2 ) ;
9835 END IF;
9836 -- Check If parent exists.
9837
9838 IF l_line_Adj_tbl.EXISTS(l_Line_Adj_Att_rec.Adj_index) THEN
9839
9840 -- Copy parent_id.
9841
9842 l_Line_Adj_Att_tbl(I).price_adjustment_id := l_line_Adj_tbl(l_Line_Adj_Att_rec.Adj_index).price_adjustment_id;
9843
9844 ELSE
9845
9846 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
9847 THEN
9848 IF l_debug_level > 0 THEN
9849 oe_debug_pub.add( 'INVALID ADJ INDEX ' ||TO_CHAR ( L_LINE_ADJ_ATT_REC.ADJ_INDEX ) ||'ON ADJ ATTRIBS' , 2 ) ;
9850 END IF;
9851 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9852
9853 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
9854 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Line_Adj_Att');
9855 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
9856 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',l_Line_Adj_Att_rec.Adj_index);
9857 OE_MSG_PUB.Add;
9858
9859 END IF;
9860 END IF;
9861 END IF;
9862 I := l_Line_Adj_Att_tbl.NEXT(I);
9863 END LOOP;
9864
9865 -- Line_Attribs
9866
9867 IF l_Line_Adj_Att_tbl.COUNT > 0 THEN
9868
9869 oe_order_adj_pvt.Line_Adj_Atts
9870 ( p_validation_level => p_validation_level
9871 , p_control_rec => p_control_rec
9872 , p_x_Line_Adj_Att_tbl => l_Line_Adj_Att_tbl
9873 , p_x_old_Line_Adj_Att_tbl => l_old_Line_Adj_Att_tbl
9874 );
9875
9876 END IF;
9877
9878 -- Perform Line_Adj_Att group requests.
9879 /*
9880
9881 IF (p_control_rec.process AND
9882 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
9883 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
9884 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_Line_Adj_Att)
9885 THEN
9886
9887 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
9888 (p_entity_code => OE_GLOBALS.G_ENTITY_Line_Adj_Att
9889 ,p_delete => FND_API.G_TRUE
9890 ,x_return_status => l_return_status
9891 );
9892 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
9893 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9894 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
9895 RAISE FND_API.G_EXC_ERROR;
9896 END IF;
9897
9898 END IF;
9899 */
9900
9901 -------------------------------------------------------
9902 -- Process Line Adjustment Associations
9903 -------------------------------------------------------
9904
9905 -- Process line Adj Associations
9906
9907 I := l_Line_Adj_Assoc_tbl.FIRST;
9908 WHILE I IS NOT NULL LOOP
9909
9910 IF l_debug_level > 0 THEN
9911 oe_debug_pub.add( 'SETTING PRICE_ADJUSTMENT_ID ON LINE ADJ ASSOCS TABLE' , 2 ) ;
9912 END IF;
9913 l_Line_Adj_Assoc_rec := l_Line_Adj_Assoc_tbl(I);
9914
9915 IF l_Line_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_CREATE
9916 AND (l_Line_Adj_Assoc_rec.price_adjustment_id IS NULL OR
9917 l_Line_Adj_Assoc_rec.price_adjustment_id = FND_API.G_MISS_NUM)
9918 THEN
9919
9920 IF l_debug_level > 0 THEN
9921 oe_debug_pub.add( 'SETTING ADJ IDS ON LINE ADJ ASSOCS TABLE' , 2 ) ;
9922 END IF;
9923 -- Check If parent exists.
9924
9925 IF l_line_Adj_tbl.EXISTS(l_Line_Adj_Assoc_rec.Adj_index) THEN
9926
9927 -- Copy parent_id.
9928
9929 l_Line_Adj_Assoc_tbl(I).price_adjustment_id := l_line_Adj_tbl(l_Line_Adj_Assoc_rec.Adj_index).price_adjustment_id;
9930
9931 ELSE
9932
9933 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
9934 THEN
9935 IF l_debug_level > 0 THEN
9936 oe_debug_pub.add( 'INVALID ADJ INDEX ' ||TO_CHAR ( L_LINE_ADJ_ASSOC_REC.ADJ_INDEX ) ||'ON ADJ ASSOCS' , 2 ) ;
9937 END IF;
9938 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9939
9940 fnd_message.set_name('ONT','OE_API_INV_PARENT_INDEX');
9941 FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Line_Adj_Assoc');
9942 FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
9943 FND_MESSAGE.SET_TOKEN('PARENT_INDEX',l_Line_Adj_Assoc_rec.Adj_index);
9944 OE_MSG_PUB.Add;
9945
9946 END IF;
9947 END IF;
9948 END IF;
9949
9950 IF l_Line_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_CREATE
9951 AND (l_Line_Adj_Assoc_rec.Line_id IS NULL OR
9952 l_Line_Adj_Assoc_rec.Line_id = FND_API.G_MISS_NUM)
9953 THEN
9954
9955 IF l_debug_level > 0 THEN
9956 oe_debug_pub.add( 'SETTING LINE IDS ON LINE ADJ ASSOCS TABLE' , 2 ) ;
9957 END IF;
9958 -- Check If parent exists.
9959
9960 IF l_line_tbl.EXISTS(l_Line_Adj_Assoc_rec.Line_Index) THEN
9961
9962 -- Copy parent_id.
9963
9964 l_Line_Adj_Assoc_tbl(I).Line_Id := l_line_tbl(l_Line_Adj_Assoc_rec.Line_index).Line_id;
9965 END IF;
9966 END IF;
9967
9968 IF l_Line_Adj_Assoc_rec.operation = OE_GLOBALS.G_OPR_CREATE
9969 AND (l_Line_Adj_Assoc_rec.rltd_Price_Adj_Id IS NULL OR
9970 l_Line_Adj_Assoc_rec.rltd_Price_Adj_Id = FND_API.G_MISS_NUM)
9971 THEN
9972
9973 IF l_Line_Adj_Tbl.exists(l_Line_Adj_Assoc_Rec.Rltd_Adj_Index) Then
9974 -- Copy parent_id.
9975
9976 l_Line_Adj_Assoc_tbl(I).rltd_Price_Adj_Id :=
9977 l_Line_Adj_Tbl(l_Line_Adj_Assoc_Rec.Rltd_Adj_Index).Price_adjustment_id;
9978 END IF;
9979
9980 END IF;
9981 I := l_Line_Adj_Assoc_tbl.NEXT(I);
9982 END LOOP;
9983
9984 -- Line_Attribs
9985
9986 IF l_Line_Adj_Assoc_tbl.COUNT > 0 THEN
9987
9988 oe_order_adj_pvt.Line_Adj_Assocs
9989 ( p_validation_level => p_validation_level
9990 , p_control_rec => p_control_rec
9991 , p_x_Line_Adj_Assoc_tbl => l_Line_Adj_Assoc_tbl
9992 , p_x_old_Line_Adj_Assoc_tbl => l_old_Line_Adj_Assoc_tbl
9993 );
9994
9995 END IF;
9996
9997 -- Perform Line_Adj_Assoc group requests.
9998 /*
9999
10000 IF (p_control_rec.process AND
10001 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
10002 (p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL OR
10003 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_Line_Adj_Assoc)
10004 THEN
10005
10006 OE_DELAYED_REQUESTS_PVT.Process_Request_for_Entity
10007 (p_entity_code => OE_GLOBALS.G_ENTITY_Line_Adj_Assoc
10008 ,p_delete => FND_API.G_TRUE
10009 ,x_return_status => l_return_status
10010 );
10011 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10012 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10013 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10014 RAISE FND_API.G_EXC_ERROR;
10015 END IF;
10016
10017 END IF;
10018 */
10019
10020 -- Step 6. Perform Delayed Requests
10021 -- Set entity_id on request table using the line index.
10022 /*
10023 IF l_request_tbl.COUNT > 0 THEN
10024
10025 oe_debug_pub.add('Setting Header/Line Ids on Line Adj table', 2);
10026
10027 FOR k in l_request_tbl.first .. l_request_tbl.last LOOP
10028
10029 -- oe_debug_pub.add('Processing Line Requests ' ||TO_CHAR(k), 2);
10030 IF (l_request_tbl(k).entity_code IS NULL OR
10031 l_request_tbl(k).entity_code = Oe_Globals.G_ENTITY_HEADER) THEN
10032
10033 IF (l_request_tbl(k).entity_id = FND_API.G_MISS_NUM
10034 OR l_request_tbl(k).entity_id is null ) THEN
10035 IF l_header_rec.header_id IS NULL OR
10036 l_header_rec.header_id = FND_API.G_MISS_NUM THEN
10037 FND_MESSAGE.SET_NAME('ONT','OE_HEADER_MISSING');
10038 OE_MSG_PUB.Add;
10039 RAISE FND_API.G_EXC_ERROR;
10040 ELSE
10041
10042 l_request_tbl(k).entity_id := l_header_rec.header_id;
10043
10044 END IF;
10045 END IF;
10046 ELSIF (l_request_tbl(k).entity_code = Oe_Globals.G_ENTITY_LINE) THEN
10047
10048 IF (to_number(l_request_tbl(k).param1) <> FND_API.G_MISS_NUM)
10049 AND (l_request_tbl(k).param1 IS NOT NULL) THEN
10050
10051 l_line_index := to_number(l_request_tbl(k).param1) ;
10052 oe_debug_pub.add('Line Index is '||TO_CHAR(l_line_index), 2);
10053
10054 IF l_line_tbl.EXISTS(l_line_index) THEN
10055
10056 IF (l_request_tbl(k).entity_id = FND_API.G_MISS_NUM)
10057 OR (l_request_tbl(k).entity_id IS NULL) THEN
10058
10059 l_request_tbl(k).entity_id := l_line_tbl(l_line_index).line_id;
10060
10061 END IF; -- Line Id on Child is missing or is null
10062
10063 ELSE -- Invalid Index
10064
10065 oe_debug_pub.add('Invalid Line Index '
10066 ||TO_CHAR(l_line_index)
10067 ||'on Action Request', 2);
10068 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10069 END IF; -- If Valid Line Index
10070 END IF; -- Line Index is not null and not missing
10071 END IF;
10072 END LOOP;
10073 END IF; -- If Child table has rows
10074 */
10075 -------------------------------------------------------------------------------
10076
10077 -- FOR I IN 1..l_request_tbl.COUNT LOOP
10078
10079 I := l_request_tbl.FIRST;
10080 WHILE I IS NOT NULL LOOP
10081
10082 IF l_debug_level > 0 THEN
10083 oe_debug_pub.add( 'SETTING HEADER/LINE IDS ON REQUEST TABLE' , 2 ) ;
10084 END IF;
10085
10086 IF (l_request_tbl(I).entity_code = OE_GLOBALS.G_ENTITY_HEADER) THEN
10087
10088 IF (l_request_tbl(I).entity_id IS NULL OR
10089 l_request_tbl(I).entity_id = FND_API.G_MISS_NUM)
10090 THEN
10091 IF l_debug_level > 0 THEN
10092 oe_debug_pub.add( 'SETTING HEADER IDS ON REQUEST TABLE FOR HEADER ENTITY' , 2 ) ;
10093 END IF;
10094 IF l_header_rec.header_id IS NULL OR
10095 l_header_rec.header_id = FND_API.G_MISS_NUM THEN
10096 FND_MESSAGE.SET_NAME('ONT','OE_HEADER_MISSING');
10097 OE_MSG_PUB.Add;
10098 RAISE FND_API.G_EXC_ERROR;
10099 ELSE
10100 l_request_tbl(I).entity_id := l_header_rec.header_id;
10101 END IF;
10102 END IF;
10103
10104 ELSIF (l_request_tbl(I).entity_code = OE_GLOBALS.G_ENTITY_LINE) THEN
10105
10106 IF (l_request_tbl(I).entity_id IS NULL OR
10107 l_request_tbl(I).entity_id = FND_API.G_MISS_NUM)
10108 THEN
10109 IF l_debug_level > 0 THEN
10110 oe_debug_pub.add( 'SETTING LINE IDS ON REQUEST TABLE FOR LINE ENTITY' , 2 ) ;
10111 END IF;
10112 -- Check If entity record exists.
10113
10114 IF l_line_tbl.EXISTS(l_request_tbl(I).entity_index) THEN
10115
10116 -- Copy entity_id.
10117
10118 l_request_tbl(I).entity_id := l_line_tbl(l_request_tbl(I).entity_index).line_id;
10119
10120 ELSE
10121
10122 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
10123 THEN
10124 IF l_debug_level > 0 THEN
10125 oe_debug_pub.add( 'INVALID ENTITY INDEX ' ||TO_CHAR ( L_REQUEST_TBL ( I ) .ENTITY_INDEX ) ||'ON REQUEST TABLE FOR LINE ENTITY' , 2 ) ;
10126 END IF;
10127 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10128 END IF;
10129 END IF;
10130 END IF;
10131 END IF;
10132 I := l_request_tbl.NEXT(I);
10133 END LOOP;
10134
10135 -------------------------------------------------------------------------------
10136
10137 -- Step 7. Perform Object group logic
10138
10139 -- Perform Delayed Requests for all the the entities
10140 IF l_debug_level > 0 THEN
10141 oe_debug_pub.add( 'OEXVORDB: BEFORE CALLING PROCESS_DELAYED_REQUESTS' , 2 ) ;
10142 END IF;
10143 IF (p_control_rec.process AND
10144 OE_GLOBALS.G_RECURSION_MODE <> 'Y') AND
10145 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL
10146 THEN
10147
10148 OE_DELAYED_REQUESTS_PVT.Process_Delayed_Requests(
10149 x_return_status => l_return_status
10150 );
10151 IF l_debug_level > 0 THEN
10152 oe_debug_pub.add( 'OEXVORDB: COMPLETED PROCESS_DELAYED_REQUESTS ' || ' WITH RETURN STATUS' || L_RETURN_STATUS , 2 ) ;
10153 END IF;
10154 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10155 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10156 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10157 RAISE FND_API.G_EXC_ERROR;
10158 END IF;
10159
10160 END IF;
10161
10162 -- Only do non-WF requests.
10163 IF p_x_action_request_tbl.COUNT > 0 THEN
10164
10165 -- Perform NON-WF Action Requests
10166 OE_Delayed_Requests_PVT.Process_Order_Actions
10167 (p_validation_level => p_validation_level,
10168 p_x_request_tbl => l_request_tbl,
10169 p_process_WF_Requests => FALSE);
10170
10171 END IF;
10172
10173
10174 -- Start flows for the Entity.
10175 IF (p_control_rec.process AND
10176 p_control_rec.process_entity = OE_GLOBALS.G_ENTITY_ALL AND
10177 OE_GLOBALS.G_RECURSION_MODE = 'N')
10178 THEN
10179 OE_ORDER_WF_UTIL.START_ALL_FLOWS;
10180 -- Process WF Action requests.
10181 IF p_x_action_request_tbl.COUNT > 0 THEN
10182
10183 OE_Delayed_Requests_PVT.Process_Order_Actions
10184
10185 (p_validation_level => p_validation_level,
10186 p_x_request_tbl => l_request_tbl,
10187 p_process_WF_Requests => TRUE);
10188
10189 END IF;
10190
10191 END IF;
10192
10193
10194 IF l_debug_level > 0 THEN
10195 oe_debug_pub.add( 'OEXVORDB: AFTER PROCESS_ORDER_ACTIONS' , 2 ) ;
10196 END IF;
10197
10198
10199 -- Clear API cache.
10200
10201 IF p_control_rec.clear_api_cache THEN
10202 NULL;
10203 END IF;
10204
10205 -- Clear API request tbl.
10206
10207 IF p_control_rec.clear_api_requests THEN
10208 NULL;
10209 END IF;
10210
10211 -- Derive return status
10212
10213 IF l_header_rec.return_status = FND_API.G_RET_STS_ERROR THEN
10214 x_return_status := FND_API.G_RET_STS_ERROR;
10215 END IF;
10216
10217 -- Do not need to loop through header_scredits, lines
10218 -- line_scredits or lot_serials as the x_return_status is set
10219 -- based on the x_return_status returned by the entity procedures
10220
10221 -- FOR I IN 1..l_Header_Adj_tbl.COUNT LOOP
10222 I := l_Header_Adj_tbl.FIRST;
10223 WHILE I IS NOT NULL LOOP
10224
10225 IF l_Header_Adj_tbl(I).return_status = FND_API.G_RET_STS_ERROR THEN
10226 x_return_status := FND_API.G_RET_STS_ERROR;
10227 END IF;
10228
10229 I := l_Header_Adj_tbl.NEXT(I);
10230 END LOOP;
10231
10232 I := l_Header_Price_Att_tbl.FIRST;
10233 WHILE I IS NOT NULL LOOP
10234
10235 IF l_Header_Price_Att_tbl(I).return_status = FND_API.G_RET_STS_ERROR THEN
10236 x_return_status := FND_API.G_RET_STS_ERROR;
10237 END IF;
10238
10239 I := l_Header_Price_Att_tbl.NEXT(I);
10240 END LOOP;
10241
10242 I := l_Header_Adj_Att_tbl.FIRST;
10243 WHILE I IS NOT NULL LOOP
10244
10245 IF l_Header_Adj_Att_tbl(I).return_status = FND_API.G_RET_STS_ERROR THEN
10246 x_return_status := FND_API.G_RET_STS_ERROR;
10247 END IF;
10248
10249 I := l_Header_Adj_Att_tbl.NEXT(I);
10250 END LOOP;
10251
10252 I := l_Header_Adj_Assoc_tbl.FIRST;
10253 WHILE I IS NOT NULL LOOP
10254
10255 IF l_Header_Adj_Assoc_tbl(I).return_status = FND_API.G_RET_STS_ERROR THEN
10256 x_return_status := FND_API.G_RET_STS_ERROR;
10257 END IF;
10258
10259 I := l_Header_Adj_Assoc_tbl.NEXT(I);
10260 END LOOP;
10261
10262 -- FOR I IN 1..l_Line_Adj_tbl.COUNT LOOP
10263
10264 I := l_Line_Adj_tbl.FIRST;
10265 WHILE I IS NOT NULL LOOP
10266
10267 IF l_Line_Adj_tbl(I).return_status = FND_API.G_RET_STS_ERROR THEN
10268 x_return_status := FND_API.G_RET_STS_ERROR;
10269 END IF;
10270
10271 I := l_Line_Adj_tbl.NEXT(I);
10272 END LOOP;
10273
10274 I := l_Line_Price_Att_tbl.FIRST;
10275 WHILE I IS NOT NULL LOOP
10276
10277 IF l_Line_Price_Att_tbl(I).return_status = FND_API.G_RET_STS_ERROR THEN
10278 x_return_status := FND_API.G_RET_STS_ERROR;
10279 END IF;
10280
10281 I := l_Line_Price_Att_tbl.NEXT(I);
10282 END LOOP;
10283
10284 I := l_Line_Adj_Att_tbl.FIRST;
10285 WHILE I IS NOT NULL LOOP
10286
10287 IF l_Line_Adj_Att_tbl(I).return_status = FND_API.G_RET_STS_ERROR THEN
10288 x_return_status := FND_API.G_RET_STS_ERROR;
10289 END IF;
10290
10291 I := l_Line_Adj_Att_tbl.NEXT(I);
10292 END LOOP;
10293
10294 I := l_Line_Adj_Assoc_tbl.FIRST;
10295 WHILE I IS NOT NULL LOOP
10296
10297 IF l_Line_Adj_Assoc_tbl(I).return_status = FND_API.G_RET_STS_ERROR THEN
10298 x_return_status := FND_API.G_RET_STS_ERROR;
10299 END IF;
10300
10301 I := l_Line_Adj_Assoc_tbl.NEXT(I);
10302 END LOOP;
10303
10304 IF l_debug_level > 0 THEN
10305 oe_debug_pub.add( 'JPN: BEFORE CALLING NOTIFY , HEADER_ID IS: ' || L_HEADER_REC.HEADER_ID ) ;
10306 END IF;
10307 -- Calling Update Notice API - Provided by OC
10308 -- This API will notify OC about the changes happen in OM side for order
10309
10310 /* Notification Project changes */
10311 /* Call Process_Requests_and_Notify to inform all subscribers */
10312
10313 IF (OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508') then
10314 /* Call Process Requests and notify */
10315 IF l_debug_level > 0 THEN
10316 oe_debug_pub.add( 'CALLING PROCESS_REQUESTS_AND_NOTIFY FOR PACK H' ) ;
10317 END IF;
10318 Process_Requests_And_Notify(
10319 p_process_requests => FALSE,
10320 p_notify => TRUE,
10321 x_return_status => l_return_status,
10322 p_header_rec => l_header_rec,
10323 p_old_header_rec => l_old_header_rec,
10324 p_Header_Adj_tbl => l_Header_Adj_tbl,
10325 p_old_Header_Adj_tbl => l_old_Header_Adj_tbl,
10326 p_Header_Scredit_tbl => l_header_Scredit_tbl,
10327 p_old_Header_Scredit_tbl => l_old_Header_Scredit_tbl,
10328 p_line_tbl => l_line_tbl,
10329 p_old_line_tbl => l_old_line_tbl,
10330 p_Line_Adj_tbl => l_line_adj_tbl,
10331 p_old_line_adj_tbl => l_old_line_adj_tbl,
10332 p_Line_Scredit_tbl => l_Line_Scredit_tbl,
10333 p_old_Line_Scredit_tbl => l_old_line_Scredit_tbl,
10334 p_Lot_Serial_tbl => l_lot_Serial_tbl,
10335 p_old_Lot_Serial_tbl => l_old_Lot_Serial_tbl);
10336
10337 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10338 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10339 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10340 RAISE FND_API.G_EXC_ERROR;
10341 END IF;
10342
10343 ELSE
10344 /* Pre Pack H processsing */
10345
10346 IF l_debug_level > 0 THEN
10347 oe_debug_pub.add( 'CS BEFORE CALLING NOTIFY_OC API' , 1 ) ;
10348 END IF;
10349
10350 IF x_return_status = FND_API.G_RET_STS_SUCCESS AND
10351 p_control_rec.write_to_db = TRUE
10352 AND oe_order_cache.g_header_rec.booked_flag = 'Y'
10353 THEN
10354 IF l_debug_level > 0 THEN
10355 oe_debug_pub.add( 'CS CALLING NOTIFY_OC API' , 1 ) ;
10356 END IF;
10357
10358 OE_SERVICE_UTIL.Notify_OC
10359 ( p_api_version_number => l_api_version_number
10360 , p_init_msg_list => l_init_msg_list
10361 , p_validation_level => l_validation_level
10362 , p_control_rec => p_control_rec
10363 , x_return_status => l_return_status
10364 , x_msg_count => x_msg_count
10365 , x_msg_data => x_msg_data
10366 , p_header_rec => l_header_rec
10367 , p_old_header_rec => l_old_header_rec
10368 , p_header_adj_tbl => l_header_adj_tbl
10369 , p_old_header_adj_tbl => l_old_header_adj_tbl
10370 , p_header_price_att_tbl => l_header_price_att_tbl
10371 , p_old_header_price_att_tbl => l_old_header_price_att_tbl
10372 , p_Header_Adj_Att_tbl => l_Header_Adj_Att_tbl
10373 , p_old_Header_Adj_Att_tbl => l_old_Header_Adj_Att_tbl
10374 , p_Header_Adj_Assoc_tbl => l_Header_Adj_Assoc_tbl
10375 , p_old_Header_Adj_Assoc_tbl => l_old_Header_Adj_Assoc_tbl
10376 , p_Header_Scredit_tbl => l_Header_Scredit_tbl
10377 , p_old_Header_Scredit_tbl => l_old_Header_Scredit_tbl
10378 , p_line_tbl => l_line_tbl
10379 , p_old_line_tbl => l_old_line_tbl
10380 , p_Line_Adj_tbl => l_Line_Adj_tbl
10381 , p_old_Line_Adj_tbl => l_old_Line_Adj_tbl
10382 , p_Line_Price_Att_tbl => l_Line_Price_Att_tbl
10383 , p_old_Line_Price_Att_tbl => l_old_Line_Price_Att_tbl
10384 , p_Line_Adj_Att_tbl => l_Line_Adj_Att_tbl
10385 , p_old_Line_Adj_Att_tbl => l_old_Line_Adj_Att_tbl
10386 , p_Line_Adj_Assoc_tbl => l_Line_Adj_Assoc_tbl
10387 , p_old_Line_Adj_Assoc_tbl => l_old_Line_Adj_Assoc_tbl
10388 , p_Line_Scredit_tbl => l_Line_Scredit_tbl
10389 , p_old_Line_Scredit_tbl => l_old_Line_Scredit_tbl
10390 , p_Lot_Serial_tbl => l_Lot_Serial_tbl
10391 , p_old_Lot_Serial_tbl => l_old_Lot_Serial_tbl
10392 , p_Lot_Serial_val_tbl => l_Lot_Serial_val_tbl
10393 , p_old_Lot_Serial_val_tbl => l_old_Lot_Serial_val_tbl
10394 , p_action_request_tbl => l_request_tbl
10395 );
10396
10397
10398 IF l_debug_level > 0 THEN
10399 oe_debug_pub.add( 'AFTER NOTIFY_OC API' , 1 ) ;
10400 END IF;
10401 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10402 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10403 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10404 RAISE FND_API.G_EXC_ERROR;
10405 END IF;
10406
10407
10408 END IF;
10409
10410 IF l_debug_level > 0 THEN
10411 oe_debug_pub.add( 'PROCESSING ACKS' , 1 ) ;
10412 END IF;
10413 -- Following check is commented to fix 2380911
10414 IF -- OE_Globals.G_RECURSION_MODE <> 'Y' AND
10415 x_return_status = FND_API.G_RET_STS_SUCCESS AND
10416 l_control_rec.write_to_db = TRUE
10417 THEN
10418 IF l_debug_level > 0 THEN
10419 oe_debug_pub.add( 'CALLING ACKS API' , 1 ) ;
10420 END IF;
10421
10422 If Oe_Code_Control.Code_Release_Level >= '110510' And
10423 l_header_rec.order_source_id in (0,2,6) And
10424 l_edi_ack_pfile = 'YES' Then
10425 OE_Acknowledgment_Pvt.Process_Acknowledgment
10426 (p_header_rec => l_header_rec,
10427 p_line_tbl => l_line_tbl,
10428 p_old_header_rec => l_old_header_rec,
10429 p_old_line_tbl => l_old_line_tbl,
10430 x_return_status => l_return_status);
10431 Elsif l_edi_ack_pfile = 'NO' And
10432 p_x_header_rec.order_source_id in (0,2,6,20) Then
10433 OE_Acknowledgment_Pvt.Process_Acknowledgment
10434 (p_api_version_number => 1
10435 ,p_init_msg_list => p_init_msg_list
10436
10437 ,p_header_rec => l_header_rec
10438 ,p_header_adj_tbl => l_header_adj_tbl
10439 ,p_header_Scredit_tbl => l_header_scredit_tbl
10440 ,p_line_tbl => l_line_tbl
10441 ,p_line_adj_tbl => l_line_adj_tbl
10442 ,p_line_scredit_tbl => l_line_scredit_tbl
10443 ,p_lot_serial_tbl => l_lot_serial_tbl
10444 ,p_action_request_tbl => l_request_tbl
10445
10446 ,p_old_header_rec => l_old_header_rec
10447 ,p_old_header_adj_tbl => l_old_header_adj_tbl
10448 ,p_old_header_Scredit_tbl => l_old_header_scredit_tbl
10449 ,p_old_line_tbl => l_old_line_tbl
10450 ,p_old_line_adj_tbl => l_old_line_adj_tbl
10451 ,p_old_line_scredit_tbl => l_old_line_scredit_tbl
10452 ,p_old_lot_serial_tbl => l_old_lot_serial_tbl
10453
10454 ,p_buyer_seller_flag => 'B'
10455 ,p_reject_order => 'N'
10456
10457 ,x_return_status => l_return_status
10458 );
10459 End If;
10460
10461 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10462 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10463 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10464 RAISE FND_API.G_EXC_ERROR;
10465 x_return_status := l_return_status;
10466 END IF;
10467 END IF;
10468
10469 END IF; /* Code Level check */
10470
10471 -- Done processing, load OUT parameters.
10472
10473 p_x_header_rec := l_header_rec;
10474 p_x_Header_Adj_tbl := l_Header_Adj_tbl;
10475 p_x_Header_Price_Att_tbl := l_Header_Price_Att_tbl;
10476 p_x_Header_Adj_Att_tbl := l_Header_Adj_Att_tbl;
10477 p_x_Header_Adj_Assoc_tbl := l_Header_Adj_Assoc_tbl;
10478 p_x_Header_Scredit_tbl := l_Header_Scredit_tbl;
10479 p_x_line_tbl := l_line_tbl;
10480 p_x_Line_Adj_tbl := l_Line_Adj_tbl;
10481 p_x_Line_Price_Att_tbl := l_Line_Price_Att_tbl;
10482 p_x_Line_Adj_Att_tbl := l_Line_Adj_Att_tbl;
10483 p_x_Line_Adj_Assoc_tbl := l_Line_Adj_Assoc_tbl;
10484 p_x_Line_Scredit_tbl := l_Line_Scredit_tbl;
10485 p_x_Lot_Serial_tbl := l_Lot_Serial_tbl;
10486 p_x_action_request_tbl := l_request_tbl;
10487
10488 <<END_OF_PROCESS_ORDER>>
10489 -- Get message count and data
10490
10491 OE_MSG_PUB.Count_And_Get
10492 ( p_count => x_msg_count
10493 , p_data => x_msg_data
10494 );
10495
10496 set_recursion_mode(p_Entity_Code => 1,
10497 p_In_out => 0);
10498
10499 IF l_debug_level > 0 THEN
10500 oe_debug_pub.add( 'GLOBAL REQUEST TABLE COUNT- PO'|| OE_DELAYED_REQUESTS_PVT.G_DELAYED_REQUESTS.COUNT , 1 ) ;
10501 oe_debug_pub.add( 'EXITING OE_ORDER_PUB.PROCESS_ORDER' , 1 ) ;
10502 END IF;
10503
10504 EXCEPTION
10505
10506 WHEN FND_API.G_EXC_ERROR THEN
10507
10508 IF l_debug_level > 0 THEN
10509 oe_debug_pub.add( 'PO: EXITING PROCESS ORDER WITH ERROR' , 2 ) ;
10510 END IF;
10511 set_recursion_mode(p_Entity_Code => 1,
10512 p_In_out => 0);
10513 OE_SET_UTIL.G_SET_TBL.delete; --bug#2428456
10514 OE_SET_UTIL.G_SET_OPT_TBL.delete; -- bug#2428456
10515 x_return_status := FND_API.G_RET_STS_ERROR;
10516
10517 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
10518 IF l_debug_level > 0 THEN
10519 oe_debug_pub.add( 'DELETE REQUEST11' , 2 ) ;
10520 END IF;
10521
10522 OE_DELAYED_REQUESTS_PVT.Clear_Request(l_return_status);
10523 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508' THEN
10524 OE_ORDER_UTIL.Clear_Global_Picture(l_return_status);
10525 END IF;
10526 OE_ORDER_WF_UTIL.CLEAR_FLOWSTART_GLOBALS;
10527 ROLLBACK TO SAVEPOINT Process_Order;
10528
10529 END IF;
10530
10531 -- Get message count and data
10532
10533 OE_MSG_PUB.Count_And_Get
10534 ( p_count => x_msg_count
10535 , p_data => x_msg_data
10536 );
10537
10538 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
10539
10540 IF l_debug_level > 0 THEN
10541 oe_debug_pub.add( 'PO: EXITING PROCESS ORDER WITH UNEXPECTED ERROR' , 2 ) ;
10542 END IF;
10543 set_recursion_mode(p_Entity_Code => 1,
10544 p_In_out => 0);
10545 OE_SET_UTIL.G_SET_TBL.delete; --bug#2428456
10546 OE_SET_UTIL.G_SET_OPT_TBL.delete; -- bug#2428456
10547 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
10548
10549 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
10550 IF l_debug_level > 0 THEN
10551 oe_debug_pub.add( 'DELETE REQUEST12' , 2 ) ;
10552 END IF;
10553
10554 OE_DELAYED_REQUESTS_PVT.Clear_Request(l_return_status);
10555 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508' THEN
10556 OE_ORDER_UTIL.Clear_Global_Picture(l_return_status);
10557 END IF;
10558 OE_ORDER_WF_UTIL.CLEAR_FLOWSTART_GLOBALS;
10559 ROLLBACK TO SAVEPOINT Process_Order;
10560
10561
10562 END IF;
10563
10564 -- Get message count and data
10565
10566 OE_MSG_PUB.Count_And_Get
10567 ( p_count => x_msg_count
10568 , p_data => x_msg_data
10569 );
10570
10571 WHEN OTHERS THEN
10572
10573 IF l_debug_level > 0 THEN
10574 oe_debug_pub.add( 'PO: EXITING PROCESS ORDER WITH OTHERS ERROR' , 2 ) ;
10575 END IF;
10576 set_recursion_mode(p_Entity_Code => 1,
10577 p_In_out => 0);
10578 OE_SET_UTIL.G_SET_TBL.delete; --bug#2428456
10579 OE_SET_UTIL.G_SET_OPT_TBL.delete; -- bug#2428456
10580 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
10581
10582 IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
10583 IF l_debug_level > 0 THEN
10584 oe_debug_pub.add( 'DELETE REQUEST13' , 2 ) ;
10585 END IF;
10586
10587 OE_DELAYED_REQUESTS_PVT.Clear_Request(l_return_status);
10588 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110508' THEN
10589 OE_ORDER_UTIL.Clear_Global_Picture(l_return_status);
10590 END IF;
10591 OE_ORDER_WF_UTIL.CLEAR_FLOWSTART_GLOBALS;
10592 ROLLBACK TO SAVEPOINT Process_Order;
10593
10594 END IF;
10595
10596 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
10597 THEN
10598 OE_MSG_PUB.Add_Exc_Msg
10599 ( G_PKG_NAME
10600 , 'Process_Order'
10601 );
10602 END IF;
10603
10604 -- Get message count and data
10605
10606 OE_MSG_PUB.Count_And_Get
10607 ( p_count => x_msg_count
10608 , p_data => x_msg_data
10609 );
10610
10611 END Process_Order;
10612
10613
10614 /*---------------------------------------------------------------
10615 -- Start of Comments
10616 -- API name Lock_Order
10617 -- Type Private
10618 --
10619 -- Pre-reqs
10620 --
10621 -- Parameters
10622 --
10623 -- Version Current version = 1.0
10624 -- Initial version = 1.0
10625 --
10626 -- Notes
10627 --
10628 -- End of Comments
10629 ---------------------------------------------------------------*/
10630 PROCEDURE Lock_Order
10631 ( p_api_version_number IN NUMBER
10632 , p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
10633 , x_return_status OUT NOCOPY VARCHAR2
10634
10635 , x_msg_count OUT NOCOPY NUMBER
10636
10637 , x_msg_data OUT NOCOPY VARCHAR2
10638
10639 , p_x_header_rec IN OUT NOCOPY OE_Order_PUB.Header_Rec_Type
10640 , p_x_Header_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Tbl_Type
10641 , p_x_Header_Price_Att_tbl IN OUT NOCOPY OE_Order_PUB.Header_Price_Att_Tbl_Type
10642 , p_x_Header_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Att_Tbl_Type
10643 , p_x_Header_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Assoc_Tbl_Type
10644 , p_x_Header_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Header_Scredit_Tbl_Type
10645 , p_x_line_tbl IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
10646 , p_x_Line_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Tbl_Type
10647 , p_x_Line_Price_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Price_Att_Tbl_Type
10648 , p_x_Line_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Att_Tbl_Type
10649 , p_x_Line_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Assoc_Tbl_Type
10650 , p_x_Line_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Line_Scredit_Tbl_Type
10651 , p_x_Lot_Serial_tbl IN OUT NOCOPY OE_Order_PUB.Lot_Serial_Tbl_Type
10652 ) IS
10653 l_x_Header_Payment_tbl OE_Order_PUB.Header_Payment_Tbl_Type;
10654 l_x_Line_Payment_tbl OE_Order_PUB.Line_Payment_Tbl_Type;
10655 BEGIN
10656 Lock_Order
10657 ( p_api_version_number => p_api_version_number
10658 , p_init_msg_list => p_init_msg_list
10659 , x_return_status => x_return_status
10660 , x_msg_count => x_msg_count
10661 , x_msg_data => x_msg_data
10662 , p_x_header_rec => p_x_header_rec
10663 , p_x_Header_Adj_tbl => p_x_Header_Adj_tbl
10664 , p_x_Header_Price_Att_tbl => p_x_Header_Price_Att_tbl
10665 , p_x_Header_Adj_Att_tbl => p_x_Header_Adj_Att_tbl
10666 , p_x_Header_Adj_Assoc_tbl => p_x_Header_Adj_Assoc_tbl
10667 , p_x_Header_Scredit_tbl => p_x_Header_Scredit_tbl
10668 , p_x_Header_Payment_tbl => l_x_Header_Payment_tbl
10669 , p_x_line_tbl => p_x_line_tbl
10670 , p_x_Line_Adj_tbl => p_x_Line_Adj_tbl
10671 , p_x_Line_Price_Att_tbl => p_x_Line_Price_Att_tbl
10672 , p_x_Line_Adj_Att_tbl => p_x_Line_Adj_Att_tbl
10673 , p_x_Line_Adj_Assoc_tbl => p_x_Line_Adj_Assoc_tbl
10674 , p_x_Line_Scredit_tbl => p_x_Line_Scredit_tbl
10675 , p_x_Line_Payment_tbl => l_x_Line_Payment_tbl
10676 , p_x_Lot_Serial_tbl => p_x_Lot_Serial_tbl
10677 );
10678 END Lock_Order;
10679
10680 -- overloaded for payments parameters
10681 PROCEDURE Lock_Order
10682 ( p_api_version_number IN NUMBER
10683 , p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
10684 , x_return_status OUT NOCOPY VARCHAR2
10685
10686 , x_msg_count OUT NOCOPY NUMBER
10687
10688 , x_msg_data OUT NOCOPY VARCHAR2
10689
10690 , p_x_header_rec IN OUT NOCOPY OE_Order_PUB.Header_Rec_Type
10691 , p_x_Header_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Tbl_Type
10692 , p_x_Header_Price_Att_tbl IN OUT NOCOPY OE_Order_PUB.Header_Price_Att_Tbl_Type
10693 , p_x_Header_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Att_Tbl_Type
10694 , p_x_Header_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Assoc_Tbl_Type
10695 , p_x_Header_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Header_Scredit_Tbl_Type
10696 , p_x_Header_Payment_tbl IN OUT NOCOPY OE_Order_PUB.Header_Payment_Tbl_Type
10697 , p_x_line_tbl IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
10698 , p_x_Line_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Tbl_Type
10699 , p_x_Line_Price_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Price_Att_Tbl_Type
10700 , p_x_Line_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Att_Tbl_Type
10701 , p_x_Line_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Assoc_Tbl_Type
10702 , p_x_Line_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Line_Scredit_Tbl_Type
10703 , p_x_Line_Payment_tbl IN OUT NOCOPY OE_Order_PUB.Line_Payment_Tbl_Type
10704 , p_x_Lot_Serial_tbl IN OUT NOCOPY OE_Order_PUB.Lot_Serial_Tbl_Type
10705 )
10706 IS
10707 l_api_version_number CONSTANT NUMBER := 1.0;
10708 l_api_name CONSTANT VARCHAR2(30):= 'Lock_Order';
10709 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
10710 I NUMBER; -- Used for index.
10711 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
10712 BEGIN
10713
10714 IF l_debug_level > 0 THEN
10715 oe_debug_pub.add( 'ENTERING OE_ORDER_PVT.LOCK_ORDER' , 1 ) ;
10716 END IF;
10717 -- Standard call to check for call compatibility
10718
10719 IF NOT FND_API.Compatible_API_Call
10720 ( l_api_version_number
10721 , p_api_version_number
10722 , l_api_name
10723 , G_PKG_NAME
10724 )
10725 THEN
10726 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10727 END IF;
10728
10729 -- Initialize message list.
10730
10731 IF FND_API.to_Boolean(p_init_msg_list) THEN
10732 OE_MSG_PUB.initialize;
10733 END IF;
10734
10735 -- Set Savepoint
10736
10737 SAVEPOINT Lock_Order_PVT;
10738
10739 -- Lock header
10740
10741 IF p_x_header_rec.operation = OE_GLOBALS.G_OPR_LOCK THEN
10742
10743 OE_Header_Util.Lock_Row
10744 ( p_x_header_rec => p_x_header_rec
10745 , x_return_status => l_return_status
10746 );
10747
10748 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10749 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10750 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10751 RAISE FND_API.G_EXC_ERROR;
10752 END IF;
10753
10754
10755 END IF;
10756
10757 -- Lock Header_Adj
10758
10759 -- FOR I IN 1..p_Header_Adj_tbl.COUNT LOOP
10760
10761 I := p_x_Header_Adj_tbl.FIRST;
10762 WHILE I IS NOT NULL LOOP
10763
10764 IF p_x_Header_Adj_tbl(I).operation = OE_GLOBALS.G_OPR_LOCK THEN
10765
10766 OE_Header_Adj_Util.Lock_Row
10767 ( p_x_Header_Adj_rec => p_x_Header_Adj_tbl(I)
10768 , x_return_status => l_return_status
10769 );
10770
10771 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10772 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10773 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10774 RAISE FND_API.G_EXC_ERROR;
10775 END IF;
10776
10777 END IF;
10778
10779 I := p_x_Header_Adj_tbl.NEXT(I);
10780
10781 END LOOP;
10782
10783 -- Lock Header_Attribs
10784
10785 I := p_x_Header_Price_Att_tbl.FIRST;
10786 WHILE I IS NOT NULL LOOP
10787
10788 IF p_x_Header_Price_Att_tbl(I).operation = OE_GLOBALS.G_OPR_LOCK THEN
10789
10790 OE_Header_PAttr_Util.Lock_Row
10791 ( p_x_Header_Price_Att_rec => p_x_Header_Price_Att_tbl(I)
10792 , x_return_status => l_return_status
10793 );
10794
10795 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10796 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10797 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10798 RAISE FND_API.G_EXC_ERROR;
10799 END IF;
10800
10801 END IF;
10802
10803 I := p_x_Header_Price_Att_tbl.NEXT(I);
10804
10805 END LOOP;
10806
10807 -- Lock Header_Adj_Attribs
10808
10809 I := p_x_Header_Adj_Att_tbl.FIRST;
10810 WHILE I IS NOT NULL LOOP
10811
10812 IF p_x_Header_Adj_Att_tbl(I).operation = OE_GLOBALS.G_OPR_LOCK THEN
10813
10814 OE_Header_Price_Aattr_Util.Lock_Row
10815 ( p_x_Header_Adj_Att_rec => p_x_Header_Adj_Att_tbl(I)
10816 , x_return_status => l_return_status
10817 );
10818
10819 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10820 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10821 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10822 RAISE FND_API.G_EXC_ERROR;
10823 END IF;
10824
10825 END IF;
10826
10827 I := p_x_Header_Adj_Att_tbl.NEXT(I);
10828
10829 END LOOP;
10830
10831 -- Lock Header_Adj_Associations
10832
10833 I := p_x_Header_Adj_Assoc_tbl.FIRST;
10834 WHILE I IS NOT NULL LOOP
10835
10836 IF p_x_Header_Adj_Assoc_tbl(I).operation = OE_GLOBALS.G_OPR_LOCK THEN
10837
10838 OE_Header_Adj_Assocs_Util.Lock_Row
10839 ( p_x_Header_Adj_Assoc_rec => p_x_Header_Adj_Assoc_tbl(I)
10840 , x_return_status => l_return_status
10841 );
10842
10843 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10844 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10845 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10846 RAISE FND_API.G_EXC_ERROR;
10847 END IF;
10848
10849 END IF;
10850
10851 I := p_x_Header_Adj_Assoc_tbl.NEXT(I);
10852
10853 END LOOP;
10854
10855 -- Lock Header_Scredit
10856
10857 -- FOR I IN 1..p_Header_Scredit_tbl.COUNT LOOP
10858
10859 I := p_x_Header_Scredit_tbl.FIRST;
10860 WHILE I IS NOT NULL LOOP
10861
10862 IF p_x_Header_Scredit_tbl(I).operation = OE_GLOBALS.G_OPR_LOCK THEN
10863
10864 OE_Header_Scredit_Util.Lock_Row
10865 ( p_x_Header_Scredit_rec => p_x_Header_Scredit_tbl(I)
10866 , x_return_status => l_return_status
10867 );
10868
10869 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10870 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10871 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10872 RAISE FND_API.G_EXC_ERROR;
10873 END IF;
10874
10875 END IF;
10876
10877 I := p_x_Header_Scredit_tbl.NEXT(I);
10878
10879 END LOOP;
10880
10881 -- Lock Header_Payment
10882
10883 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
10884 I := p_x_Header_Payment_tbl.FIRST;
10885 WHILE I IS NOT NULL LOOP
10886
10887 IF p_x_Header_Payment_tbl(I).operation = OE_GLOBALS.G_OPR_LOCK THEN
10888
10889 OE_Header_Payment_Util.Lock_Row
10890 ( p_x_Header_Payment_rec => p_x_Header_Payment_tbl(I)
10891 , x_return_status => l_return_status
10892 );
10893
10894 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10895 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10896 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10897 RAISE FND_API.G_EXC_ERROR;
10898 END IF;
10899
10900 END IF;
10901
10902 I := p_x_Header_Payment_tbl.NEXT(I);
10903
10904 END LOOP;
10905 END IF;
10906
10907 -- Lock line
10908
10909 -- FOR I IN 1..p_line_tbl.COUNT LOOP
10910
10911 I := p_x_line_tbl.FIRST;
10912 WHILE I IS NOT NULL LOOP
10913
10914 IF p_x_line_tbl(I).operation = OE_GLOBALS.G_OPR_LOCK THEN
10915
10916 OE_Line_Util.Lock_Row
10917 ( p_x_line_rec => p_x_line_tbl(I)
10918 , x_return_status => l_return_status
10919 );
10920
10921 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10922 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10923 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10924 RAISE FND_API.G_EXC_ERROR;
10925 END IF;
10926
10927 END IF;
10928
10929 I := p_x_line_tbl.NEXT(I);
10930
10931 END LOOP;
10932
10933 -- Lock Line_Adj
10934
10935 -- FOR I IN 1..p_Line_Adj_tbl.COUNT LOOP
10936
10937 I := p_x_Line_Adj_tbl.FIRST;
10938 WHILE I IS NOT NULL LOOP
10939
10940 IF p_x_Line_Adj_tbl(I).operation = OE_GLOBALS.G_OPR_LOCK THEN
10941
10942 OE_Line_Adj_Util.Lock_Row
10943 ( p_x_Line_Adj_rec => p_x_Line_Adj_tbl(I)
10944 , x_return_status => l_return_status
10945 );
10946
10947 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10948 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10949 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10950 RAISE FND_API.G_EXC_ERROR;
10951 END IF;
10952
10953 END IF;
10954
10955 I := p_x_Line_Adj_tbl.NEXT(I);
10956
10957 END LOOP;
10958
10959 -- Lock Line_Attribs
10960
10961 I := p_x_Line_Price_Att_tbl.FIRST;
10962 WHILE I IS NOT NULL LOOP
10963
10964 IF p_x_Line_Price_Att_tbl(I).operation = OE_GLOBALS.G_OPR_LOCK THEN
10965
10966 OE_Line_PAttr_Util.Lock_Row
10967 ( p_x_Line_Price_Att_rec => p_x_Line_Price_Att_tbl(I)
10968 , x_return_status => l_return_status
10969 );
10970
10971 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10972 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10973 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10974 RAISE FND_API.G_EXC_ERROR;
10975 END IF;
10976
10977 END IF;
10978
10979 I := p_x_Line_Price_Att_tbl.NEXT(I);
10980
10981 END LOOP;
10982
10983 -- Lock Line_Adj_Attribs
10984
10985 I := p_x_Line_Adj_Att_tbl.FIRST;
10986 WHILE I IS NOT NULL LOOP
10987
10988 IF p_x_Line_Adj_Att_tbl(I).operation = OE_GLOBALS.G_OPR_LOCK THEN
10989
10990 OE_Line_Price_Aattr_Util.Lock_Row
10991 ( p_x_Line_Adj_Att_rec => p_x_Line_Adj_Att_tbl(I)
10992 , x_return_status => l_return_status
10993 );
10994
10995 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
10996 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10997 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
10998 RAISE FND_API.G_EXC_ERROR;
10999 END IF;
11000
11001 END IF;
11002
11003 I := p_x_Line_Adj_Att_tbl.NEXT(I);
11004
11005 END LOOP;
11006
11007 -- Lock Line_Adj_Associations
11008
11009 I := p_x_Line_Adj_Assoc_tbl.FIRST;
11010 WHILE I IS NOT NULL LOOP
11011
11012 IF p_x_Line_Adj_Assoc_tbl(I).operation = OE_GLOBALS.G_OPR_LOCK THEN
11013
11014 OE_Line_Adj_Assocs_Util.Lock_Row
11015 ( p_x_Line_Adj_Assoc_rec => p_x_Line_Adj_Assoc_tbl(I)
11016 , x_return_status => l_return_status
11017 );
11018
11019 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
11020 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11021 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
11022 RAISE FND_API.G_EXC_ERROR;
11023 END IF;
11024
11025 END IF;
11026
11027 I := p_x_Line_Adj_Assoc_tbl.NEXT(I);
11028
11029 END LOOP;
11030
11031 -- Lock Line_Scredit
11032
11033 -- FOR I IN 1..p_Line_Scredit_tbl.COUNT LOOP
11034 I := p_x_Line_Scredit_tbl.FIRST;
11035 WHILE I IS NOT NULL LOOP
11036
11037 IF p_x_Line_Scredit_tbl(I).operation = OE_GLOBALS.G_OPR_LOCK THEN
11038
11039 OE_Line_Scredit_Util.Lock_Row
11040 ( p_x_Line_Scredit_rec => p_x_Line_Scredit_tbl(I)
11041 , x_return_status => l_return_status
11042 );
11043
11044 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
11045 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11046 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
11047 RAISE FND_API.G_EXC_ERROR;
11048 END IF;
11049
11050 END IF;
11051
11052 I := p_x_Line_Scredit_tbl.NEXT(I);
11053
11054 END LOOP;
11055
11056 -- Lock Line_Payment
11057
11058 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
11059 I := p_x_Line_Payment_tbl.FIRST;
11060
11061 WHILE I IS NOT NULL LOOP
11062
11063 IF p_x_Line_Payment_tbl(I).operation = OE_GLOBALS.G_OPR_LOCK THEN
11064
11065 OE_Line_Payment_Util.Lock_Row
11066 ( p_x_Line_Payment_rec => p_x_Line_Payment_tbl(I)
11067 , x_return_status => l_return_status
11068 );
11069
11070 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
11071 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11072 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
11073 RAISE FND_API.G_EXC_ERROR;
11074 END IF;
11075
11076 END IF;
11077
11078 I := p_x_Line_Payment_tbl.NEXT(I);
11079
11080 END LOOP;
11081 END IF;
11082
11083 -- Lock Lot_Serial
11084
11085 -- FOR I IN 1..p_Lot_Serial_tbl.COUNT LOOP
11086
11087 I := p_x_Lot_Serial_tbl.FIRST;
11088 WHILE I IS NOT NULL LOOP
11089
11090 IF p_x_Lot_Serial_tbl(I).operation = OE_GLOBALS.G_OPR_LOCK THEN
11091
11092 OE_Lot_Serial_Util.Lock_Row
11093 ( p_x_Lot_Serial_rec => p_x_Lot_Serial_tbl(I)
11094 , x_return_status => l_return_status
11095 );
11096
11097 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
11098 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11099 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
11100 RAISE FND_API.G_EXC_ERROR;
11101 END IF;
11102
11103 END IF;
11104
11105 I := p_x_Lot_Serial_tbl.NEXT(I);
11106
11107 END LOOP;
11108
11109 -- Set return status
11110
11111 x_return_status := FND_API.G_RET_STS_SUCCESS;
11112
11113 -- Get message count and data
11114
11115 OE_MSG_PUB.Count_And_Get
11116 ( p_count => x_msg_count
11117 , p_data => x_msg_data
11118 );
11119
11120 if p_x_line_tbl.count > 0 then
11121 IF l_debug_level > 0 THEN
11122 oe_debug_pub.add( 'LINE ID:'||P_X_LINE_TBL ( 1 ) .LINE_ID ) ;
11123 END IF;
11124 end if;
11125 IF l_debug_level > 0 THEN
11126 oe_debug_pub.add( 'EXITING OE_ORDER_PUB.LOCK_ORDER' , 1 ) ;
11127 END IF;
11128
11129 EXCEPTION
11130
11131 WHEN FND_API.G_EXC_ERROR THEN
11132
11133 x_return_status := FND_API.G_RET_STS_ERROR;
11134
11135 -- Get message count and data
11136
11137 OE_MSG_PUB.Count_And_Get
11138 ( p_count => x_msg_count
11139 , p_data => x_msg_data
11140 );
11141
11142 -- Rollback
11143
11144 ROLLBACK TO Lock_Order_PVT;
11145
11146 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
11147
11148 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
11149
11150 -- Get message count and data
11151
11152 OE_MSG_PUB.Count_And_Get
11153 ( p_count => x_msg_count
11154 , p_data => x_msg_data
11155 );
11156
11157 -- Rollback
11158
11159 ROLLBACK TO Lock_Order_PVT;
11160
11161 WHEN OTHERS THEN
11162
11163 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
11164
11165 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
11166 THEN
11167 OE_MSG_PUB.Add_Exc_Msg
11168 ( G_PKG_NAME
11169 , 'Lock_Order'
11170 );
11171 END IF;
11172
11173 -- Get message count and data
11174
11175 OE_MSG_PUB.Count_And_Get
11176 ( p_count => x_msg_count
11177 , p_data => x_msg_data
11178 );
11179
11180 -- Rollback
11181
11182 ROLLBACK TO Lock_Order_PVT;
11183
11184 END Lock_Order;
11185
11186
11187 /*---------------------------------------------------------------
11188 -- Start of Comments
11189 -- API name Get_Order
11190 -- Type Private
11191 --
11192 -- Pre-reqs
11193 --
11194 -- Parameters
11195 --
11196 -- Version Current version = 1.0
11197 -- Initial version = 1.0
11198 --
11199 -- Notes
11200 --
11201 -- End of Comments
11202
11203 --------------------------------------------------------------*/
11204 PROCEDURE Get_Order
11205 ( p_api_version_number IN NUMBER
11206 , p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
11207 , x_return_status OUT NOCOPY VARCHAR2
11208
11209 , x_msg_count OUT NOCOPY NUMBER
11210
11211 , x_msg_data OUT NOCOPY VARCHAR2
11212
11213 , p_header_id IN NUMBER
11214 , x_header_rec IN OUT NOCOPY OE_Order_PUB.Header_Rec_Type
11215 , x_Header_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Tbl_Type
11216 , x_Header_price_Att_tbl IN OUT NOCOPY OE_Order_PUB.Header_Price_Att_Tbl_Type
11217 , x_Header_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Att_Tbl_Type
11218 , x_Header_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Assoc_Tbl_Type
11219 , x_Header_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Header_Scredit_Tbl_Type
11220 , x_line_tbl IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
11221 , x_Line_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Tbl_Type
11222 , x_Line_price_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Price_Att_Tbl_Type
11223 , x_Line_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Att_Tbl_Type
11224 , x_Line_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Assoc_Tbl_Type
11225 , x_Line_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Line_Scredit_Tbl_Type
11226 , x_Lot_Serial_tbl IN OUT NOCOPY OE_Order_PUB.Lot_Serial_Tbl_Type
11227 ) IS
11228 x_Header_Payment_tbl OE_Order_PUB.Header_Payment_Tbl_Type;
11229 x_Line_Payment_tbl OE_Order_PUB.Line_Payment_Tbl_Type;
11230 BEGIN
11231 Get_Order
11232 ( p_api_version_number => p_api_version_number
11233 , p_init_msg_list => p_init_msg_list
11234 , x_return_status => x_return_status
11235 , x_msg_count => x_msg_count
11236 , x_msg_data => x_msg_data
11237 , p_header_id => p_header_id
11238 , x_header_rec => x_header_rec
11239 , x_Header_Adj_tbl => x_Header_Adj_tbl
11240 , x_Header_price_Att_tbl => x_Header_price_Att_tbl
11241 , x_Header_Adj_Att_tbl => x_Header_Adj_Att_tbl
11242 , x_Header_Adj_Assoc_tbl => x_Header_Adj_Assoc_tbl
11243 , x_Header_Scredit_tbl => x_Header_Scredit_tbl
11244 , x_Header_Payment_tbl => x_Header_Payment_tbl
11245 , x_line_tbl => x_line_tbl
11246 , x_Line_Adj_tbl => x_Line_Adj_tbl
11247 , x_Line_price_Att_tbl => x_Line_price_Att_tbl
11248 , x_Line_Adj_Att_tbl => x_Line_Adj_Att_tbl
11249 , x_Line_Adj_Assoc_tbl => x_Line_Adj_Assoc_tbl
11250 , x_Line_Scredit_tbl => x_Line_Scredit_tbl
11251 , x_Line_Payment_tbl => x_Line_Payment_tbl
11252 , x_Lot_Serial_tbl => x_Lot_Serial_tbl
11253 );
11254 END Get_Order;
11255
11256 -- overloaded for payments parameters
11257 PROCEDURE Get_Order
11258 ( p_api_version_number IN NUMBER
11259 , p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
11260 , x_return_status OUT NOCOPY VARCHAR2
11261
11262 , x_msg_count OUT NOCOPY NUMBER
11263
11264 , x_msg_data OUT NOCOPY VARCHAR2
11265
11266 , p_header_id IN NUMBER
11267 , x_header_rec IN OUT NOCOPY OE_Order_PUB.Header_Rec_Type
11268 , x_Header_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Tbl_Type
11269 , x_Header_price_Att_tbl IN OUT NOCOPY OE_Order_PUB.Header_Price_Att_Tbl_Type
11270 , x_Header_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Att_Tbl_Type
11271 , x_Header_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Header_Adj_Assoc_Tbl_Type
11272 , x_Header_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Header_Scredit_Tbl_Type
11273 , x_Header_Payment_tbl IN OUT NOCOPY OE_Order_PUB.Header_Payment_Tbl_Type
11274 , x_line_tbl IN OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
11275 , x_Line_Adj_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Tbl_Type
11276 , x_Line_price_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Price_Att_Tbl_Type
11277 , x_Line_Adj_Att_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Att_Tbl_Type
11278 , x_Line_Adj_Assoc_tbl IN OUT NOCOPY OE_Order_PUB.Line_Adj_Assoc_Tbl_Type
11279 , x_Line_Scredit_tbl IN OUT NOCOPY OE_Order_PUB.Line_Scredit_Tbl_Type
11280 , x_Line_Payment_tbl IN OUT NOCOPY OE_Order_PUB.Line_Payment_Tbl_Type
11281 , x_Lot_Serial_tbl IN OUT NOCOPY OE_Order_PUB.Lot_Serial_Tbl_Type
11282 )
11283 IS
11284 l_api_version_number CONSTANT NUMBER := 1.0;
11285 l_api_name CONSTANT VARCHAR2(30):= 'Get_Order';
11286 l_Header_Adj_tbl OE_Order_PUB.Header_Adj_Tbl_Type;
11287 l_Header_Price_Att_tbl OE_Order_PUB.Header_Price_Att_Tbl_Type;
11288 l_Header_Adj_Att_tbl OE_Order_PUB.Header_Adj_Att_Tbl_Type;
11289 l_Header_Adj_Assoc_tbl OE_Order_PUB.Header_Adj_Assoc_Tbl_Type;
11290 l_Line_Adj_tbl OE_Order_PUB.Line_Adj_Tbl_Type;
11291 l_Line_Price_Att_tbl OE_Order_PUB.Line_Price_Att_Tbl_Type;
11292 l_Line_Adj_Att_tbl OE_Order_PUB.Line_Adj_Att_Tbl_Type;
11293 l_Line_Adj_Assoc_tbl OE_Order_PUB.Line_Adj_Assoc_Tbl_Type;
11294 l_Line_Scredit_tbl OE_Order_PUB.Line_Scredit_Tbl_Type;
11295 l_Line_Payment_tbl OE_Order_PUB.Line_Payment_Tbl_Type;
11296 l_Lot_Serial_tbl OE_Order_PUB.Lot_Serial_Tbl_Type;
11297 I2 NUMBER; --Used as index.
11298 I3 NUMBER; --Used as index.
11299 I4 NUMBER; --Used as index.
11300 I5 NUMBER; --Used as index.
11301 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
11302 BEGIN
11303
11304 -- Standard call to check for call compatibility
11305
11306 IF NOT FND_API.Compatible_API_Call
11307 ( l_api_version_number
11308 , p_api_version_number
11309 , l_api_name
11310 , G_PKG_NAME
11311 )
11312 THEN
11313 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11314 END IF;
11315
11316 -- Initialize message list.
11317
11318 IF FND_API.to_Boolean(p_init_msg_list) THEN
11319 OE_MSG_PUB.initialize;
11320 END IF;
11321
11322 -- Get header ( parent = header )
11323
11324 OE_Header_Util.Query_Row
11325 ( p_header_id => p_header_id
11326 , x_header_rec => x_header_rec
11327 );
11328
11329 -- Get Header_Adj ( parent = header )
11330
11331 OE_Header_Adj_Util.Query_Rows
11332 ( p_header_id => p_header_id
11333 , x_Header_Adj_Tbl => x_Header_Adj_Tbl
11334 );
11335
11336 -- Get Header_Attribs ( parent = header )
11337
11338 OE_Header_PAttr_Util.Query_Rows
11339 ( p_header_id => p_header_id
11340 , x_Header_Price_Att_tbl => x_Header_Price_Att_tbl
11341 );
11342
11343
11344 I2 := l_Header_Adj_tbl.FIRST;
11345 WHILE I2 IS NOT NULL LOOP
11346 -- Get Header_adj_attribs ( parent = Adjustments )
11347
11348 l_Header_Adj_Att_tbl.delete; --6052770
11349 Oe_Header_Price_Aattr_util.Query_Rows
11350 ( p_price_adjustment_id =>
11351 l_Header_Adj_tbl(I2).price_adjustment_id
11352 , x_Header_Adj_Att_tbl => l_Header_Adj_Att_tbl
11353 );
11354
11355 I3 := l_Header_Adj_Att_tbl.first;
11356
11357 While I3 is not Null Loop
11358
11359 l_Header_Adj_Att_tbl(I3).Adj_Index := I2;
11360 x_Header_Adj_Att_tbl(x_Header_Adj_Att_tbl.count+1) :=
11361 l_Header_Adj_Att_tbl(I3);
11362 I3 := l_Header_Adj_Att_tbl.Next(I3);
11363
11364 end loop;
11365
11366 -- Get Header_adj_Assocs ( parent = Adjutments )
11367
11368 l_Header_Adj_Assoc_Tbl.delete; --6052770
11369 Oe_Header_Adj_Assocs_util.Query_Rows
11370 ( p_price_adjustment_id =>
11371 l_header_Adj_tbl(I2).Price_Adjustment_id
11372 , x_Header_Adj_Assoc_Tbl => l_Header_Adj_Assoc_Tbl
11373 );
11374
11375 I3 := l_Header_Adj_Assoc_tbl.first;
11376
11377 While I3 is not Null Loop
11378
11379 l_Header_Adj_Assoc_tbl(I3).Adj_Index := I2;
11380 x_Header_Adj_Assoc_tbl(x_Header_Adj_Assoc_tbl.count+1) :=
11381 l_Header_Adj_Assoc_tbl(I3);
11382 I3 := l_Header_Adj_Assoc_tbl.Next(I3);
11383
11384 end loop;
11385 I2 := l_header_Adj_tbl.next(I2);
11386 end loop;
11387
11388 -- Get Header_Scredit ( parent = header )
11389
11390 OE_Header_Scredit_Util.Query_Rows
11391 ( p_header_id => p_header_id
11392 , x_Header_Scredit_tbl => x_Header_Scredit_tbl
11393 );
11394
11395 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
11396 -- Get Header_Payment ( parent = header )
11397
11398 OE_Header_Payment_Util.Query_Rows
11399 ( p_header_id => p_header_id
11400 , x_Header_Payment_tbl => x_Header_Payment_tbl
11401 );
11402 END IF;
11403
11404 -- Get line ( parent = header )
11405
11406 OE_Line_Util.Query_Rows
11407 ( p_header_id => p_header_id
11408 , x_line_tbl => x_line_tbl
11409 );
11410
11411
11412 -- Loop over line's children
11413
11414 -- FOR I2 IN 1..x_line_tbl.COUNT LOOP
11415 I2 := x_line_tbl.FIRST;
11416 WHILE I2 IS NOT NULL LOOP
11417
11418 -- Get Line_Adj ( parent = line )
11419
11420 l_Line_Adj_tbl.delete; --6052770
11421 OE_Line_Adj_Util.Query_Rows
11422 ( p_line_id => x_line_tbl(I2).line_id
11423 , x_Line_Adj_tbl => l_Line_Adj_tbl
11424 );
11425
11426 I3 := l_Line_Adj_tbl.FIRST;
11427 WHILE I3 IS NOT NULL LOOP
11428
11429 l_Line_Adj_tbl(I3).line_Index := I2;
11430 x_Line_Adj_tbl
11431 (x_Line_Adj_tbl.COUNT + 1) := l_Line_Adj_tbl(I3);
11432 I3 := l_Line_Adj_tbl.NEXT(I3);
11433
11434 END LOOP;
11435
11436
11437 -- Get Line_Attibs ( parent = Line )
11438
11439 l_Line_Price_Att_tbl.delete; --6052770
11440 OE_Line_Pattr_Util.Query_Rows
11441 ( P_Line_Id => x_line_tbl(I2).Line_id
11442 , x_Line_Price_Att_tbl => l_Line_Price_Att_tbl
11443 );
11444
11445 I3 := l_Line_Price_Att_tbl.FIRST;
11446 WHILE I3 IS NOT NULL LOOP
11447
11448 l_Line_Price_Att_tbl(I3).line_Index := I2;
11449 x_Line_Price_Att_tbl
11450 (x_Line_Price_Att_tbl.COUNT + 1) := l_Line_Price_Att_tbl(I3);
11451 I3 := l_Line_Price_Att_tbl.NEXT(I3);
11452
11453 END LOOP;
11454
11455 -- Get Line_Adj_Attribs ( parent = Adj )
11456
11457 I4 := l_line_Adj_tbl.FIRST;
11458 WHILE I4 IS NOT NULL LOOP
11459
11460 l_Line_Adj_Att_tbl.delete; --6052770
11461 Oe_Line_Price_Aattr_util.Query_Rows
11462 ( p_price_adjustment_id =>
11463 l_line_Adj_tbl(I4).price_Adjustment_id
11464 , x_Line_Adj_Att_tbl => l_Line_Adj_Att_tbl
11465 );
11466
11467 I5 := l_Line_Adj_Att_tbl.FIRST;
11468 WHILE I5 IS NOT NULL LOOP
11469
11470 l_Line_Adj_Att_tbl(I5).Adj_Index := I4;
11471 x_Line_Adj_Att_tbl
11472 (x_Line_Adj_Att_tbl.COUNT + 1) := l_Line_Adj_Att_tbl(I5);
11473 I5 := l_Line_Adj_Att_tbl.NEXT(I5);
11474
11475 END LOOP;
11476
11477 -- Get Line_Adj_Assocs ( parent = Adj )
11478
11479 l_Line_Adj_Assoc_tbl.delete; --6052770
11480 Oe_Line_Adj_Assocs_util.Query_Rows
11481 ( p_price_Adjustment_id =>
11482 l_line_Adj_tbl(I4).price_Adjustment_id
11483 , x_Line_Adj_Assoc_tbl => l_Line_Adj_Assoc_tbl
11484 );
11485
11486 I5 := l_Line_Adj_Assoc_tbl.FIRST;
11487 WHILE I5 IS NOT NULL LOOP
11488
11489 l_Line_Adj_Assoc_tbl(I5).Adj_Index := I4;
11490 x_Line_Adj_Assoc_tbl
11491 (x_Line_Adj_Assoc_tbl.COUNT + 1) :=
11492 l_Line_Adj_Assoc_tbl(I5);
11493 I5 := l_Line_Adj_Assoc_tbl.NEXT(I5);
11494
11495 END LOOP;
11496 I4 := l_line_Adj_tbl.next(I4);
11497 end loop;
11498
11499 -- Get Line_Scredit ( parent = line )
11500
11501 l_Line_Scredit_tbl.delete; --6052770
11502 OE_Line_Scredit_Util.Query_Rows
11503 ( p_line_id => x_line_tbl(I2).line_id
11504 , x_Line_Scredit_tbl => l_Line_Scredit_tbl
11505 );
11506
11507 -- FOR I3 IN 1..l_Line_Scredit_tbl.COUNT LOOP
11508
11509 I3 := l_Line_Scredit_tbl.FIRST;
11510 WHILE I3 IS NOT NULL LOOP
11511
11512 l_Line_Scredit_tbl(I3).line_Index := I2;
11513 x_Line_Scredit_tbl
11514 (x_Line_Scredit_tbl.COUNT + 1) := l_Line_Scredit_tbl(I3);
11515 I3 := l_Line_Scredit_tbl.NEXT(I3);
11516
11517 END LOOP;
11518
11519 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
11520 -- Get Line_Payment ( parent = line )
11521
11522 l_Line_Payment_tbl.delete; --6052770
11523 OE_Line_Payment_Util.Query_Rows
11524 ( p_line_id => x_line_tbl(I2).line_id
11525 , p_header_id => x_line_tbl(I2).header_id
11526 , x_Line_Payment_tbl => l_Line_Payment_tbl
11527 );
11528
11529 I3 := l_Line_Payment_tbl.FIRST;
11530 WHILE I3 IS NOT NULL LOOP
11531
11532 l_Line_Payment_tbl(I3).line_Index := I2;
11533 x_Line_Payment_tbl
11534 (x_Line_Payment_tbl.COUNT + 1) := l_Line_Payment_tbl(I3);
11535 I3 := l_Line_Payment_tbl.NEXT(I3);
11536
11537 END LOOP;
11538 END IF;
11539
11540 -- Get Lot_Serial ( parent = line )
11541
11542 l_Lot_Serial_tbl.delete; --6052770
11543 OE_Lot_Serial_Util.Query_Rows
11544 ( p_line_id => x_line_tbl(I2).line_id
11545 , x_Lot_Serial_tbl => l_Lot_Serial_tbl
11546 );
11547
11548 -- FOR I3 IN 1..l_Lot_Serial_tbl.COUNT LOOP
11549 I3 := l_Lot_Serial_tbl.FIRST;
11550 WHILE I3 IS NOT NULL LOOP
11551
11552 l_Lot_Serial_tbl(I3).line_Index := I2;
11553 x_Lot_Serial_tbl
11554 (x_Lot_Serial_tbl.COUNT + 1) := l_Lot_Serial_tbl(I3);
11555 I3 := l_Lot_Serial_tbl.NEXT(I3);
11556
11557 END LOOP;
11558
11559 I2 := x_line_tbl.NEXT(I2);
11560
11561 END LOOP;
11562
11563 -- Set return status
11564
11565 x_return_status := FND_API.G_RET_STS_SUCCESS;
11566
11567 -- Get message count and data
11568
11569 OE_MSG_PUB.Count_And_Get
11570 ( p_count => x_msg_count
11571 , p_data => x_msg_data
11572 );
11573
11574
11575 EXCEPTION
11576
11577 WHEN FND_API.G_EXC_ERROR THEN
11578
11579 x_return_status := FND_API.G_RET_STS_ERROR;
11580
11581 -- Get message count and data
11582
11583 OE_MSG_PUB.Count_And_Get
11584 ( p_count => x_msg_count
11585 , p_data => x_msg_data
11586 );
11587
11588 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
11589
11590 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
11591
11592 -- Get message count and data
11593
11594 OE_MSG_PUB.Count_And_Get
11595 ( p_count => x_msg_count
11596 , p_data => x_msg_data
11597 );
11598
11599 WHEN OTHERS THEN
11600
11601 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
11602
11603 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
11604 THEN
11605 OE_MSG_PUB.Add_Exc_Msg
11606 ( G_PKG_NAME
11607 , 'Get_Order'
11608 );
11609 END IF;
11610
11611 -- Get message count and data
11612
11613 OE_MSG_PUB.Count_And_Get
11614 ( p_count => x_msg_count
11615 , p_data => x_msg_data
11616 );
11617
11618 END Get_Order;
11619
11620
11621 /*---------------------------------------------------------------
11622 Procedure Cancel_Order
11623 --------------------------------------------------------------*/
11624
11625 Procedure Cancel_Order
11626 ( p_api_version_number IN NUMBER
11627 , p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
11628 , x_return_status OUT NOCOPY VARCHAR2
11629
11630 , x_msg_count OUT NOCOPY NUMBER
11631
11632 , x_msg_data OUT NOCOPY VARCHAR2
11633
11634 , x_can_req IN OUT
11635 OE_ORDER_PUB.Cancel_Line_Tbl_Type
11636 ) IS
11637 l_api_version_number number := 1.0;
11638 l_api_name Varchar2(30) := 'CANCEL_ORDER';
11639 l_return_status Varchar2(1);
11640 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
11641 Begin
11642 -- Standard call to check for call compatibility
11643
11644 IF l_debug_level > 0 THEN
11645 oe_debug_pub.add( 'ENTERING OE_ORDER_PUB.CANCEL_ORDER' , 1 ) ;
11646 END IF;
11647
11648 IF NOT FND_API.Compatible_API_Call
11649 ( l_api_version_number
11650 , p_api_version_number
11651 , l_api_name
11652 , G_PKG_NAME
11653 )
11654 THEN
11655 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11656 END IF;
11657
11658 -- Initialize message list if p_init_msg_list is set to TRUE.
11659 IF FND_API.to_Boolean( p_init_msg_list ) THEN
11660 OE_MSG_PUB.initialize;
11661 END IF;
11662
11663 -- Initialize API return status to success
11664 x_return_status := FND_API.G_RET_STS_SUCCESS;
11665
11666 IF l_debug_level > 0 THEN
11667 oe_debug_pub.add( 'CALLING OE_SALES_CAN_UTIL.CANCEL_LINE' , 2 ) ;
11668 END IF;
11669 /* OE_SALES_CAN_UTIL.Cancel_Line
11670 ( x_return_status => l_return_status
11671 ,x_msg_count => x_msg_count
11672 ,x_msg_data => x_msg_data
11673 ,x_can_req => x_can_req
11674 );*/
11675 IF l_debug_level > 0 THEN
11676 oe_debug_pub.add( 'COMPLETED OE_SALES_CAN_UTIL.CANCEL_LINE WITH STATUS ' || L_RETURN_STATUS , 2 ) ;
11677 END IF;
11678
11679 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
11680 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11681 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
11682 RAISE FND_API.G_EXC_ERROR;
11683 END IF;
11684
11685 IF l_debug_level > 0 THEN
11686 oe_debug_pub.add( 'EXITING OE_ORDER_PUB.CANCEL_ORDER' , 1 ) ;
11687 END IF;
11688
11689 EXCEPTION
11690
11691 WHEN FND_API.G_EXC_ERROR THEN
11692 x_return_status := FND_API.G_RET_STS_ERROR;
11693
11694 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
11695 IF OE_MSG_PUB.Check_MSg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
11696 OE_MSG_PUB.Add_Exc_Msg
11697 (G_PKG_NAME
11698 ,'Cancel_Order');
11699 END IF;
11700 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
11701
11702 WHEN OTHERS THEN
11703
11704 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
11705 THEN
11706 OE_MSG_PUB.Add_Exc_Msg
11707 ( G_PKG_NAME
11708 , 'Cancel_Order'
11709 );
11710 END IF;
11711
11712 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
11713
11714 END Cancel_Order;
11715
11716
11717 /*------------------------------------------------------------------------
11718 PROCEDURE Print_Time
11719
11720 -------------------------------------------------------------------------*/
11721
11722 PROCEDURE Print_Time(p_msg IN VARCHAR2)
11723 IS
11724 l_time VARCHAR2(100);
11725 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
11726 BEGIN
11727 l_time := to_char (new_time (sysdate, 'PST', 'EST'),
11728 'DD-MON-YY HH24:MI:SS');
11729 IF l_debug_level > 0 THEN
11730 oe_debug_pub.add( P_MSG || ': '|| L_TIME , 1 ) ;
11731 END IF;
11732 END Print_Time;
11733
11734
11735
11736 /*------------------------------------------------------------------------
11737 PROCEDURE Complete_Config_Line
11738
11739 This procedure should never get called f the configuration is
11740 created using options window or configurator, since we already
11741 do all the work in respective code.
11742
11743 if p_item_type = 1, we do work related to models
11744 if p_item_type = 2, we do work related to classes and options.
11745
11746 In all cases, we have a common work of loading the
11747 in rec with BOM values, viz.
11748 component_code
11749 component_sequence_id
11750 order_quantity_uom
11751 sort_order
11752
11753 For p_item_type = 2,
11754 When we come out nocopy of this procedure, all the class lines will have
11755
11756 item_type_code set and this plays imp role in the lines loop, when
11757 the mode = OPTIONS.
11758 Since any batch api caller can send in junk item_type_code, until
11759 this procedure is executed, the item_type_code on the line_rec
11760 should not be considered as a valid one.
11761
11762
11763 I do not have to handle return status of explode_bill api.
11764 It raises a exception if error by BOM api, check code in OEXVCFGB.pls
11765
11766 I guess we do not need oe_config_util.complete_configuration anymore.
11767
11768 Explode_Bill api will take care of the model line.
11769
11770 ASSUMPTION is classes are not shippable, hence we will not try to order
11771 the way class under a class is saved.
11772
11773 1828866: Even if all the required fields are populated on the line,
11774 we have to always do a select from bom_explosions. This is so that
11775 we can figure out nocopy if all the items are currenlty part of the Bill.
11776
11777
11778 Should not come here for split lines.
11779
11780 2221666 : order import sends option in already create model.
11781 2299910 : copy order, sort_order for MI.
11782 -------------------------------------------------------------------------*/
11783 PROCEDURE Complete_Config_Line
11784 ( p_x_line_rec IN OUT NOCOPY OE_ORDER_PUB.Line_Rec_Type
11785 ,p_item_type IN NUMBER
11786 ,p_x_line_tbl IN OE_ORDER_PUB.Line_Tbl_Type
11787 ,p_process_partial IN BOOLEAN := FALSE)
11788 IS
11789 l_model_seq_id NUMBER;
11790 l_rev_date DATE;
11791 l_validation_org NUMBER := OE_SYS_PARAMETERS.VALUE
11792 ('MASTER_ORGANIZATION_ID');
11793 l_model_ordered_item VARCHAR2(2000);
11794 l_bom_item_type NUMBER;
11795 l_line_rec OE_Order_Pub.Line_Rec_Type;
11796 l_return_status VARCHAR2(1);
11797 l_frozen_model_bill VARCHAR2(1);
11798 l_old_behavior VARCHAR2(1);
11799 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
11800 --bug4015696
11801 l_msg_count NUMBER;
11802 l_msg_data VARCHAR2(2000);
11803 l_item_identifier_type VARCHAR2(25);
11804 BEGIN
11805
11806 Print_Time('entering Complete_Config_Line');
11807
11808 IF p_item_type = 1 THEN
11809
11810 oe_config_pvt.Explode_Bill
11811 ( p_model_line_rec => p_x_line_rec
11812 ,p_do_update => FALSE
11813 ,p_check_effective_date => 'N'
11814 ,x_config_effective_date => l_rev_date
11815 ,x_frozen_model_bill => l_frozen_model_bill
11816 ,x_return_status => l_return_status);
11817
11818 RETURN;
11819 END IF;
11820
11821 l_model_seq_id :=
11822 p_x_line_tbl(p_x_line_rec.top_model_line_index).component_sequence_id;
11823
11824 l_model_ordered_item :=
11825 p_x_line_tbl(p_x_line_rec.top_model_line_index).ordered_item;
11826
11827 OE_Config_Util.Get_Config_Effective_Date
11828 ( p_model_line_rec => p_x_line_tbl(p_x_line_rec.top_model_line_index)
11829 ,x_old_behavior => l_old_behavior
11830 ,x_config_effective_date => l_rev_date
11831 ,x_frozen_model_bill => l_frozen_model_bill);
11832
11833 -- if only a class/options is created in exiting model,
11834 -- you need to explode the model, rare case.
11835
11836 IF p_x_line_rec.top_model_line_index is NOT NULL AND
11837 p_x_line_rec.top_model_line_index <> FND_API.G_MISS_NUM AND
11838 nvl(p_x_line_tbl(p_x_line_rec.top_model_line_index).operation, 'A') <>
11839 OE_GLOBALS.G_OPR_CREATE
11840 THEN
11841 l_line_rec := p_x_line_tbl(p_x_line_rec.top_model_line_index);
11842
11843 oe_config_pvt.Explode_Bill
11844 ( p_model_line_rec => l_line_rec
11845 ,p_do_update => FALSE
11846 ,x_config_effective_date => l_rev_date
11847 ,x_frozen_model_bill => l_frozen_model_bill
11848 ,x_return_status => l_return_status);
11849
11850 l_model_seq_id := l_line_rec.component_sequence_id;
11851 l_model_ordered_item := l_line_rec.ordered_item;
11852 END IF;
11853
11854
11855 IF l_debug_level > 0 THEN
11856 oe_debug_pub.add('COMP_SEQ_ID OF MODEL: ' || L_MODEL_SEQ_ID , 2 ) ;
11857 oe_debug_pub.add('COMPLETE ITEM: '|| P_X_LINE_REC.INVENTORY_ITEM_ID ,1);
11858 END IF;
11859
11860
11861 BEGIN
11862
11863 IF p_x_line_rec.config_header_id is not NULL AND
11864 p_x_line_rec.configuration_id is not NULL AND
11865 p_x_line_rec.config_header_id <> FND_API.G_MISS_NUM AND
11866 p_x_line_rec.configuration_id <> FND_API.G_MISS_NUM AND
11867 OE_CODE_CONTROL.Get_Code_Release_Level >= '110508' THEN
11868
11869 IF l_debug_level > 0 THEN
11870 oe_debug_pub.add( 'COMP_CONFIG VORDB: PACK H NEW LOGIC MI' , 1 ) ;
11871 oe_debug_pub.add( 'CFG_HDR '||P_X_LINE_REC.CONFIG_HEADER_ID , 3 ) ;
11872 oe_debug_pub.add( 'CFG_REV '||P_X_LINE_REC.CONFIG_REV_NBR , 3 ) ;
11873 oe_debug_pub.add( 'CFG_ID '||P_X_LINE_REC.CONFIGURATION_ID , 3 ) ;
11874 END IF;
11875
11876 SELECT component_code, component_sequence_id, bom_sort_order,
11877 uom_code, bom_item_type
11878 INTO p_x_line_rec.component_code, p_x_line_rec.component_sequence_id,
11879 p_x_line_rec.sort_order, p_x_line_rec.order_quantity_uom,
11880 l_bom_item_type
11881 FROM cz_config_details_v
11882 WHERE config_hdr_id = p_x_line_rec.config_header_id
11883 AND config_rev_nbr = p_x_line_rec.config_rev_nbr
11884 AND config_item_id = p_x_line_rec.configuration_id;
11885
11886 ELSE
11887 IF l_debug_level > 0 THEN
11888 oe_debug_pub.add( 'COMP_CONFIG VORDB: USING BOM_EXPLOSION' , 1 ) ;
11889 END IF;
11890
11891 IF p_x_line_rec.component_code is not NULL AND
11892 p_x_line_rec.component_code <> FND_API.G_MISS_CHAR
11893 THEN
11894 IF l_debug_level > 0 THEN
11895 oe_debug_pub.add( 'COMPONENT CODE PASSED , SOMETHING ELSE NULL' , 3 ) ;
11896 END IF;
11897
11898 SELECT component_code, component_sequence_id, sort_order,
11899 primary_uom_code, bom_item_type
11900 INTO p_x_line_rec.component_code, p_x_line_rec.component_sequence_id,
11901 p_x_line_rec.sort_order, p_x_line_rec.order_quantity_uom,
11902 l_bom_item_type
11903 FROM bom_explosions
11904 WHERE component_item_id = p_x_line_rec.inventory_item_id
11905 AND explosion_type = Oe_Config_Util.OE_BMX_OPTION_COMPS
11906 AND top_bill_sequence_id = l_model_seq_id
11907 AND effectivity_date <= l_rev_date
11908 AND disable_date > l_rev_date
11909 AND organization_id = l_validation_org
11910 AND component_code = p_x_line_rec.component_code;
11911
11912 ELSE
11913 IF l_debug_level > 0 THEN
11914 oe_debug_pub.add( 'COMPONENT CODE NOT PASSED' , 3 ) ;
11915 END IF;
11916
11917 SELECT component_code, component_sequence_id, sort_order,
11918 primary_uom_code, bom_item_type
11919 INTO p_x_line_rec.component_code, p_x_line_rec.component_sequence_id,
11920 p_x_line_rec.sort_order, p_x_line_rec.order_quantity_uom,
11921 l_bom_item_type
11922 FROM bom_explosions
11923 WHERE component_item_id = p_x_line_rec.inventory_item_id
11924 AND explosion_type = Oe_Config_Util.OE_BMX_OPTION_COMPS
11925 AND top_bill_sequence_id = l_model_seq_id
11926 AND effectivity_date <= l_rev_date
11927 AND disable_date > l_rev_date
11928 AND organization_id = l_validation_org;
11929 END IF;
11930 END IF; -- if configuration_id is passed.
11931
11932 EXCEPTION
11933 WHEN NO_DATA_FOUND THEN
11934 IF l_debug_level > 0 THEN
11935 oe_debug_pub.add( 'SELECT COMP_CODE FAILED , NO DATA FOUND ' , 1 ) ;
11936 oe_debug_pub.add( 'ITEM: '|| P_X_LINE_REC.INVENTORY_ITEM_ID , 1 ) ;
11937 END IF;
11938 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_ITEM_NOT_IN_BILL');
11939 --bug4015696
11940 IF p_x_line_rec.ordered_item IS NULL OR
11941 p_x_line_rec.ordered_item = FND_API.G_MISS_CHAR THEN
11942 IF p_x_line_rec.item_identifier_type = FND_API.G_MISS_CHAR THEN
11943 l_item_identifier_type := NULL;
11944 ELSE
11945 l_item_identifier_type := p_x_line_rec.item_identifier_type;
11946 END IF;
11947 OE_OE_FORM_LINE.Get_Ordered_Item
11948 ( x_return_status => l_return_status
11949 ,x_msg_count => l_msg_count
11950 ,x_msg_data => l_msg_data
11951 ,p_item_identifier_type => l_item_identifier_type
11952 ,p_inventory_item_id => p_x_line_rec.inventory_item_id
11953 ,p_ordered_item_id => p_x_line_rec.ordered_item_id
11954 ,p_sold_to_org_id => p_x_line_rec.sold_to_org_id
11955 ,x_ordered_item => p_x_line_rec.ordered_item );
11956 IF p_x_line_rec.ordered_item IS NULL OR
11957 p_x_line_rec.ordered_item = FND_API.G_MISS_CHAR THEN
11958 FND_MESSAGE.Set_Token('ITEM',p_x_line_rec.inventory_item_id);
11959 ELSE
11960 FND_MESSAGE.Set_Token('ITEM',p_x_line_rec.ordered_item);
11961 END IF;
11962 ELSE
11963 FND_MESSAGE.Set_Token('ITEM', p_x_line_rec.ordered_item);
11964 END IF;
11965 FND_MESSAGE.Set_Token('MODEL', nvl(l_model_ordered_item,l_line_rec.inventory_item_id));
11966 oe_msg_pub.add;
11967
11968 IF p_process_partial THEN
11969 IF l_debug_level > 0 THEN /* Bug # 4036765 */
11970 oe_debug_pub.add( 'PROCESS PARTIAL IS TRUE' , 3 ) ;
11971 END IF;
11972 p_x_line_rec.return_status := FND_API.G_RET_STS_ERROR;
11973 p_x_line_rec.operation := OE_GLOBALS.G_OPR_NONE;
11974 OE_GLOBALS.G_FAIL_ORDER_IMPORT := TRUE; /* Bug # 4036765 */
11975 ELSE
11976 IF l_debug_level > 0 THEN
11977 oe_debug_pub.add( 'PROCESS PARTIAL IS NOT TRUE' , 3 ) ;
11978 END IF;
11979 RAISE FND_API.G_EXC_ERROR;
11980 END IF;
11981
11982 WHEN TOO_MANY_ROWS THEN
11983 IF l_debug_level > 0 THEN
11984 oe_debug_pub.add( 'SELECT COMP_CODE FAILED , TOO_MANY ROWS ' , 1 ) ;
11985 oe_debug_pub.add( 'ITEM: '|| P_X_LINE_REC.INVENTORY_ITEM_ID , 1 ) ;
11986 END IF;
11987
11988 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_AMBIGUITY');
11989 FND_MESSAGE.Set_Token('COMPONENT', p_x_line_rec.ordered_item);
11990 FND_MESSAGE.Set_Token('MODEL', nvl(l_model_ordered_item,l_line_rec.inventory_item_id));
11991 oe_msg_pub.add;
11992 RAISE FND_API.G_EXC_ERROR;
11993
11994 WHEN OTHERS THEN
11995 IF l_debug_level > 0 THEN
11996 oe_debug_pub.add( 'SELECT COMP_CODE FAILED , OTHERS ' , 1 ) ;
11997 oe_debug_pub.add( 'ITEM: '|| P_X_LINE_REC.INVENTORY_ITEM_ID , 1 ) ;
11998 END IF;
11999 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
12000 END;
12001
12002
12003 IF l_bom_item_type = 2 OR
12004 l_bom_item_type = 1 THEN
12005 IF l_debug_level > 0 THEN
12006 oe_debug_pub.add( 'THIS IS A CLASS' , 5 ) ;
12007 END IF;
12008 p_x_line_rec.item_type_code := OE_GLOBALS.G_ITEM_CLASS;
12009
12010 ELSIF l_bom_item_type = 4 THEN
12011 IF l_debug_level > 0 THEN
12012 oe_debug_pub.add( 'THIS IS A OPTION/KIT' , 1 ) ;
12013 END IF;
12014 ELSE
12015 IF l_debug_level > 0 THEN
12016 oe_debug_pub.add( 'INVALID ITEM TYPE' , 1 ) ;
12017 END IF;
12018 END IF;
12019
12020 IF l_debug_level > 0 THEN
12021 oe_debug_pub.add( 'HDR/REV/ID '|| P_X_LINE_REC.CONFIG_HEADER_ID
12022 || P_X_LINE_REC.CONFIG_REV_NBR || P_X_LINE_REC.CONFIGURATION_ID ,1);
12023 END IF;
12024
12025 Print_Time('leaving Complete_Config_Line');
12026
12027 EXCEPTION
12028 WHEN OTHERS THEN
12029 IF l_debug_level > 0 THEN
12030 oe_debug_pub.add( 'COMPLETE_CONFIG_LINE EXCEPTIION '|| SQLERRM , 1 ) ;
12031 END IF;
12032 RAISE;
12033 END Complete_Config_Line;
12034
12035
12036 /*-------------------------------------------------------------------------
12037 PRODEDURE Get_Missing_Class_Lines
12038
12039 Do not call if p_option_lines does not have any lines.
12040 just put index in the p_options_tbl, get a rec at a time.
12041 p_options_tbl.line_id is actually the index of option lines.
12042
12043 In this procedure we will get all the missing classes, for all the
12044 options in one call.
12045 We decided to loop over the p_options_index_tbl instead of calling
12046 this procedure per option line because,
12047 1) v.imp: switching modes back and forth between the class save vs
12048 option save is complicated to code, debug and maintain.
12049 2) p_options_index_tbl is table of numbers, not expensive, also
12050
12051 we are making use of the fact that the class lines are already
12052 saved. This fact and the component_code field is used to decide
12053 if some of the parents are missing and add them to the lines table.
12054
12055 when we get out nocopy of the procedure, the x_class_index contains
12056
12057 the index of the first newly added class, we start looping through
12058 the lines table at thei index. if x_class_index is null, it means
12059 no new classes were added.
12060
12061 -------------------------------------------------------------------------*/
12062
12063 PROCEDURE Get_Missing_Class_Lines
12064 ( p_x_line_tbl IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type
12065 ,p_options_index_tbl IN OE_OPTION_INDEX_TBL_TYPE
12066 ,x_class_index OUT NOCOPY NUMBER
12067
12068 ,x_class_count OUT NOCOPY NUMBER)
12069
12070 IS
12071 I NUMBER;
12072 J NUMBER;
12073 l_add_parent BOOLEAN;
12074 l_index NUMBER;
12075 l_component_code VARCHAR2(1000);
12076 l_model_quantity NUMBER;
12077 l_model_seq_id NUMBER;
12078 l_rev_date DATE;
12079 l_validation_org NUMBER := OE_SYS_PARAMETERS.VALUE
12080 ('MASTER_ORGANIZATION_ID');
12081 l_ato_line_id NUMBER;
12082 l_option_index NUMBER;
12083 l_remember_index NUMBER;
12084 l_top_model_line_index NUMBER;
12085 l_bom_item_type NUMBER;
12086 l_frozen_model_bill VARCHAR2(1);
12087 l_old_behavior VARCHAR2(1);
12088 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
12089 BEGIN
12090 Print_Time('entering Get_Missing_Class_Lines');
12091
12092
12093 IF OE_Config_Util.G_Config_UI_Used = 'Y' THEN
12094 IF l_debug_level > 0 THEN
12095 oe_debug_pub.add( 'CONFIGURATOR/OW USED , SHOULD NOT COME HERE' , 1 ) ;
12096 END IF;
12097 RAISE FND_API.G_EXC_ERROR;
12098 END IF;
12099
12100
12101 l_index := p_x_line_tbl.LAST;
12102 l_remember_index := l_index;
12103 I := p_options_index_tbl.FIRST;
12104 J := l_index;
12105
12106 WHILE I is not NULL
12107 LOOP
12108 l_option_index := p_options_index_tbl(I);
12109
12110 IF l_debug_level > 0 THEN
12111 oe_debug_pub.add( 'I '|| I || ' '
12112 || P_X_LINE_TBL ( L_OPTION_INDEX ) .TOP_MODEL_LINE_ID , 3 ) ;
12113 oe_debug_pub.add( L_OPTION_INDEX || ' '
12114 || P_X_LINE_TBL ( L_OPTION_INDEX ) .COMPONENT_CODE , 3 ) ;
12115 END IF;
12116
12117 l_component_code := SUBSTR(p_x_line_tbl(l_option_index).component_code, 1,
12118 (INSTR(p_x_line_tbl(l_option_index).component_code, '-', -1) -1));
12119
12120 WHILE l_component_code is not NULL
12121 LOOP
12122
12123 IF l_debug_level > 0 THEN
12124 oe_debug_pub.add( 'CHECK IF EXIST: ' || L_COMPONENT_CODE , 1 ) ;
12125 END IF;
12126
12127 BEGIN
12128
12129 SELECT ato_line_id
12130 INTO l_ato_line_id
12131 FROM oe_order_lines
12132 WHERE top_model_line_id
12133 = p_x_line_tbl(l_option_index).top_model_line_id
12134 AND component_code = l_component_code
12135 AND open_flag = 'Y';
12136
12137 EXCEPTION
12138 WHEN no_data_found THEN
12139 IF l_debug_level > 0 THEN
12140 oe_debug_pub.add( 'NO DATA FOUND' , 3 ) ;
12141 END IF;
12142
12143 l_add_parent := TRUE;
12144
12145 IF l_remember_index <> l_index THEN
12146 J := l_remember_index + 1;
12147 WHILE J is NOT NULL
12148 LOOP
12149 IF p_x_line_tbl(J).component_code = l_component_code THEN
12150 IF l_debug_level > 0 THEN
12151 oe_debug_pub.add( 'DO NOT ADD' , 3 ) ;
12152 END IF;
12153 l_add_parent := FALSE;
12154 END IF;
12155 J := p_x_line_tbl.NEXT(J);
12156 END LOOP;
12157
12158 END IF;
12159
12160 IF l_add_parent THEN
12161 l_index := l_index + 1;
12162
12163 p_x_line_tbl(l_index) := OE_Order_Pub.G_Miss_Line_Rec;
12164
12165 p_x_line_tbl(l_index).operation := OE_GLOBALS.G_OPR_CREATE;
12166 p_x_line_tbl(l_index).component_code := l_component_code;
12167 p_x_line_tbl(l_index).top_model_line_id
12168 := p_x_line_tbl(l_option_index).top_model_line_id;
12169 p_x_line_tbl(l_index).header_id
12170 := p_x_line_tbl(l_option_index).header_id;
12171
12172
12173 IF p_x_line_tbl(l_option_index).config_header_id is not NULL AND
12174 p_x_line_tbl(l_option_index).configuration_id is not NULL AND
12175 p_x_line_tbl(l_option_index).config_header_id <>
12176 FND_API.G_MISS_NUM AND
12177 p_x_line_tbl(l_option_index).configuration_id <>
12178 FND_API.G_MISS_NUM AND
12179 OE_CODE_CONTROL.Get_Code_Release_Level >= '110508' THEN
12180
12181 IF l_debug_level > 0 THEN
12182 oe_debug_pub.add( 'VORDB: PACK H NEW LOGIC MI' , 1 ) ;
12183 END IF;
12184
12185 IF l_debug_level > 0 THEN
12186 oe_debug_pub.add('CFG_HDR '
12187 ||P_X_LINE_TBL ( L_OPTION_INDEX ) .CONFIG_HEADER_ID , 3 ) ;
12188 oe_debug_pub.add('CFG_REV '
12189 ||P_X_LINE_TBL ( L_OPTION_INDEX ) .CONFIG_REV_NBR , 3 ) ;
12190 oe_debug_pub.add('CFG_ID '
12191 ||P_X_LINE_TBL ( L_OPTION_INDEX ) .CONFIGURATION_ID , 3 ) ;
12192 END IF;
12193
12194 BEGIN
12195 SELECT component_sequence_id, inventory_item_id,
12196 bom_sort_order, uom_code, quantity, bom_item_type
12197 INTO p_x_line_tbl(l_index).component_sequence_id,
12198 p_x_line_tbl(l_index).inventory_item_id,
12199 p_x_line_tbl(l_index).sort_order,
12200 p_x_line_tbl(l_index).order_quantity_uom,
12201 p_x_line_tbl(l_index).ordered_quantity,
12202 l_bom_item_type
12203 FROM cz_config_details_v
12204 WHERE component_code = l_component_code
12205 AND config_hdr_id
12206 = p_x_line_tbl(l_option_index).config_header_id
12207 AND config_rev_nbr
12208 = p_x_line_tbl(l_option_index).config_rev_nbr
12209 AND config_item_id
12210 = p_x_line_tbl(l_option_index).configuration_id;
12211 EXCEPTION
12212 WHEN TOO_MANY_ROWS THEN
12213 IF l_debug_level > 0 THEN
12214 oe_debug_pub.add( 'CZ TOO_MANY_ROWS ' , 1 ) ;
12215 END IF;
12216 RAISE;
12217 WHEN NO_DATA_FOUND THEN
12218 IF l_debug_level > 0 THEN
12219 oe_debug_pub.add( 'CZ NO_DATA_FOUND' , 1 ) ;
12220 END IF;
12221 RAISE;
12222 WHEN OTHERS THEN
12223 IF l_debug_level > 0 THEN
12224 oe_debug_pub.add( 'CZ OTHERS' , 1 ) ;
12225 END IF;
12226 RAISE;
12227 END;
12228 ELSE
12229 IF l_debug_level > 0 THEN
12230 oe_debug_pub.add( 'VORDB: USE BOX_EXPLOSINS' , 3 ) ;
12231 END IF;
12232
12233 IF l_rev_date is NULL THEN
12234
12235 l_top_model_line_index
12236 := p_x_line_tbl(l_option_index).top_model_line_index;
12237
12238 IF l_top_model_line_index is NOT NULL THEN
12239 l_model_quantity
12240 := p_x_line_tbl(l_top_model_line_index).ordered_quantity;
12241 l_model_seq_id
12242 := p_x_line_tbl(l_top_model_line_index).component_sequence_id;
12243
12244 OE_Config_Util.Get_Config_Effective_Date
12245 ( p_model_line_rec => p_x_line_tbl(l_top_model_line_index)
12246 ,x_old_behavior => l_old_behavior
12247 ,x_config_effective_date => l_rev_date
12248 ,x_frozen_model_bill => l_frozen_model_bill);
12249
12250 ELSE
12251
12252 SELECT ordered_quantity, component_sequence_id
12253 INTO l_model_quantity, l_model_seq_id
12254 FROM oe_order_lines
12255 WHERE line_id =
12256 p_x_line_tbl(l_option_index).top_model_line_id;
12257
12258
12259 OE_Config_Util.Get_Config_Effective_Date
12260 ( p_model_line_id =>
12261 p_x_line_tbl(l_option_index).top_model_line_id
12262 ,x_old_behavior => l_old_behavior
12263 ,x_config_effective_date => l_rev_date
12264 ,x_frozen_model_bill => l_frozen_model_bill);
12265
12266 END IF;
12267
12268 END IF; -- if rev date null
12269
12270 SELECT component_sequence_id, component_item_id, sort_order,
12271 primary_uom_code, EXTENDED_QUANTITY * l_model_quantity,
12272 bom_item_type
12273 INTO p_x_line_tbl(l_index).component_sequence_id,
12274 p_x_line_tbl(l_index).inventory_item_id,
12275 p_x_line_tbl(l_index).sort_order,
12276 p_x_line_tbl(l_index).order_quantity_uom,
12277 p_x_line_tbl(l_index).ordered_quantity,
12278 l_bom_item_type
12279 FROM bom_explosions be
12280 WHERE be.explosion_type = OE_Config_Util.OE_BMX_OPTION_COMPS
12281 AND be.top_bill_sequence_id = l_model_seq_id
12282 AND be.plan_level > 0
12283 AND be.effectivity_date <= l_rev_date
12284 AND be.disable_date > l_rev_date
12285 AND be.component_code = l_component_code
12286 AND rownum = 1;
12287
12288 END IF; -- if pack H
12289
12290 IF l_bom_item_type = 2 OR
12291 l_bom_item_type = 1 THEN
12292 IF l_debug_level > 0 THEN
12293 oe_debug_pub.add( 'THIS IS A CLASS' , 5 ) ;
12294 END IF;
12295 p_x_line_tbl(l_index).item_type_code
12296 := OE_GLOBALS.G_ITEM_CLASS;
12297 END IF;
12298
12299 IF l_debug_level > 0 THEN
12300 oe_debug_pub.add( 'GET ORDERED ITEM NAME' , 3 ) ;
12301 END IF;
12302
12303 BEGIN
12304 SELECT concatenated_segments
12305 INTO p_x_line_tbl(l_index).ordered_item
12306 FROM MTL_SYSTEM_ITEMS_KFV
12307 WHERE inventory_item_id = p_x_line_tbl(I).inventory_item_id
12308 AND organization_id = l_validation_org;
12309 EXCEPTION
12310 WHEN NO_DATA_FOUND THEN
12311 IF l_debug_level > 0 THEN
12312 oe_debug_pub.add( 'NAME OF THE ITEM NOT FOUND' , 1 ) ;
12313 END IF;
12314 RAISE FND_API.G_EXC_ERROR;
12315 END;
12316
12317 IF l_debug_level > 0 THEN
12318 oe_debug_pub.add
12319 ('ADDED'||P_X_LINE_TBL(L_INDEX).INVENTORY_ITEM_ID,3);
12320 END IF;
12321
12322 END IF; -- if add_parent = true
12323
12324 WHEN TOO_MANY_ROWS THEN
12325 IF p_x_line_tbl(l_option_index).config_header_id is not NULL AND
12326 p_x_line_tbl(l_option_index).configuration_id is not NULL AND
12327 OE_CODE_CONTROL.Get_Code_Release_Level >= '110508' THEN
12328 IF l_debug_level > 0 THEN
12329 oe_debug_pub.add
12330 ('TOO MANY ROWS IN MISSING_CLASSES: PACK H NEW MI',1);
12331 END IF;
12332 ELSE
12333 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_MI_NOT_ALLOWED');
12334 FND_MESSAGE.SET_TOKEN
12335 ('MODEL', nvl(p_x_line_tbl(l_top_model_line_index).ordered_item,
12336 p_x_line_tbl(l_top_model_line_index).inventory_item_id));
12337 FND_MESSAGE.SET_TOKEN('LINE_NUMBER',
12338 p_x_line_tbl(l_top_model_line_index).line_number ||
12339 p_x_line_tbl(l_top_model_line_index).shipment_number);
12340 OE_MSG_PUB.Add;
12341 RAISE;
12342 END IF;
12343
12344 WHEN OTHERS THEN
12345 IF l_debug_level > 0 THEN
12346 oe_debug_pub.add( 'OTHERS IN MISSING_CLASSES '|| SQLERRM , 1 ) ;
12347 END IF;
12348 RAISE;
12349 END; -- to check if this comp exists
12350
12351 l_component_code := SUBSTR(l_component_code, 1,
12352 (INSTR(l_component_code, '-', -1) -1));
12353
12354 END LOOP;
12355
12356 I := p_options_index_tbl.NEXT(I);
12357
12358 END LOOP;
12359
12360 IF l_index <> l_remember_index THEN
12361 x_class_index := l_remember_index + 1;
12362 END IF;
12363
12364 x_class_count := l_index - l_remember_index;
12365
12366 Print_Time('leaving Get_Missing_Class_Lines '|| x_class_count);
12367
12368 EXCEPTION
12369 WHEN OTHERS THEN
12370 IF l_debug_level > 0 THEN
12371 oe_debug_pub.add('ERROR IN GET_MISSING_CLASS_LINES '|| SQLERRM,1);
12372 END IF;
12373 RAISE;
12374 END Get_Missing_Class_Lines;
12375
12376
12377 END OE_Order_PVT;