[Home] [Help]
PACKAGE BODY: APPS.OE_OE_HTML_HEADER
Source
1 PACKAGE BODY Oe_Oe_Html_Header AS
2 /* $Header: ONTHHDRB.pls 120.1 2005/06/13 18:28:27 appldev $ */
3
4 -- Global constant holding the package name
5
6 G_PKG_NAME CONSTANT VARCHAR2(30) := 'Oe_Oe_Html_Header';
7
8 -- Global variables holding cached record.
9
10 g_header_rec OE_Order_PUB.Header_Rec_Type;
11 g_db_header_rec OE_Order_PUB.Header_Rec_Type;
12
13 -- Forward declaration of procedures maintaining entity record cache.
14
15 -- Procedure : Default_Attributes
16 --
17
18 PROCEDURE Default_Attributes
19 ( x_return_status OUT NOCOPY VARCHAR2
20 , x_msg_count OUT NOCOPY NUMBER
21 , x_msg_data OUT NOCOPY VARCHAR2
22 , x_header_rec IN OUT NOCOPY OE_ORDER_PUB.Header_Rec_Type
23 , x_header_val_rec IN OUT NOCOPY OE_ORDER_PUB.Header_Val_Rec_Type
24 , p_transaction_phase_code IN VARCHAR2
25 )
26 IS
27 l_control_rec OE_GLOBALS.Control_Rec_Type;
28 l_return_status VARCHAR2(1);
29 l_old_header_rec OE_ORDER_PUB.Header_Rec_Type;
30 l_fname Varchar2(1000);
31 BEGIN
32 oe_debug_pub.g_debug_level := FND_PROFILE.VALUE('ONT_DEBUG_LEVEL');
33 l_fname := oe_Debug_pub.set_debug_mode('FILE');
34 oe_debug_pub.debug_on;
35 oe_debug_pub.add('Entering Oe_Oe_Html_Header.DEFAULT_ATTRIBUTES', 1);
36
37
38
39 -- Set the UI flag
40 OE_GLOBALS.G_UI_FLAG := TRUE;
41
42 -- Set control flags.
43
44 l_control_rec.controlled_operation := TRUE;
45 l_control_rec.check_security := TRUE;
46 l_control_rec.default_attributes := TRUE;
47 l_control_rec.change_attributes := FALSE;
48
49 l_control_rec.clear_dependents := FALSE;
50 l_control_rec.validate_entity := FALSE;
51 l_control_rec.write_to_DB := FALSE;
52 l_control_rec.process := FALSE;
53
54 -- Instruct API to retain its caches
55
56 l_control_rec.clear_api_cache := TRUE;
57 l_control_rec.clear_api_requests := TRUE;
58
59 -- Load IN parameters if any exist
60
61 l_old_header_rec :=OE_ORDER_PUB.G_MISS_HEADER_REC;
62 x_header_val_rec :=OE_ORDER_PUB.G_MISS_HEADER_VAL_REC;
63
64 IF p_transaction_phase_code = 'N' THEN
65 x_header_rec.transaction_phase_code := p_transaction_phase_code;
66 END IF;
67
68 -- Defaulting of flex values is currently done by the form.
69 -- Set flex attributes to NULL in order to avoid defaulting them.
70
71 x_header_rec.attribute1 := NULL;
72 x_header_rec.attribute10 := NULL;
73 x_header_rec.attribute11 := NULL;
74 x_header_rec.attribute12 := NULL;
75 x_header_rec.attribute13 := NULL;
76 x_header_rec.attribute14 := NULL;
77 x_header_rec.attribute15 := NULL;
78 x_header_rec.attribute2 := NULL;
79 x_header_rec.attribute3 := NULL;
80 x_header_rec.attribute4 := NULL;
81 x_header_rec.attribute5 := NULL;
82 x_header_rec.attribute6 := NULL;
83 x_header_rec.attribute7 := NULL;
84 x_header_rec.attribute8 := NULL;
85 x_header_rec.attribute9 := NULL;
86 x_header_rec.context := NULL;
87 x_header_rec.global_attribute1 := NULL;
88 x_header_rec.global_attribute10 := NULL;
89 x_header_rec.global_attribute11 := NULL;
90 x_header_rec.global_attribute12 := NULL;
91 x_header_rec.global_attribute13 := NULL;
92 x_header_rec.global_attribute14 := NULL;
93 x_header_rec.global_attribute15 := NULL;
94 x_header_rec.global_attribute16 := NULL;
95 x_header_rec.global_attribute17 := NULL;
96 x_header_rec.global_attribute18 := NULL;
97 x_header_rec.global_attribute19 := NULL;
98 x_header_rec.global_attribute2 := NULL;
99 x_header_rec.global_attribute20 := NULL;
100 x_header_rec.global_attribute3 := NULL;
101 x_header_rec.global_attribute4 := NULL;
102 x_header_rec.global_attribute5 := NULL;
103 x_header_rec.global_attribute6 := NULL;
104 x_header_rec.global_attribute7 := NULL;
105 x_header_rec.global_attribute8 := NULL;
106 x_header_rec.global_attribute9 := NULL;
107 x_header_rec.global_attribute_category := NULL;
108 x_header_rec.tp_context := NULL;
109 x_header_rec.tp_attribute1 := NULL;
110 x_header_rec.tp_attribute2 := NULL;
111 x_header_rec.tp_attribute3 := NULL;
112 x_header_rec.tp_attribute4 := NULL;
113 x_header_rec.tp_attribute5 := NULL;
114 x_header_rec.tp_attribute6 := NULL;
115 x_header_rec.tp_attribute7 := NULL;
116 x_header_rec.tp_attribute8 := NULL;
117 x_header_rec.tp_attribute9 := NULL;
118 x_header_rec.tp_attribute10 := NULL;
119 x_header_rec.tp_attribute11 := NULL;
120 x_header_rec.tp_attribute12 := NULL;
121 x_header_rec.tp_attribute13 := NULL;
122 x_header_rec.tp_attribute14 := NULL;
123 x_header_rec.tp_attribute15 := NULL;
124
125 -- Set Operation to Create
126
127 x_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;
128
129 -- Call Oe_Order_Pvt.Header
130
131 Oe_Order_Pvt.Header
132 ( p_validation_level =>FND_API.G_VALID_LEVEL_NONE
133 , p_init_msg_list => FND_API.G_TRUE
134 , p_control_rec =>l_control_rec
135 , p_x_header_rec =>x_header_rec
136 , p_x_old_header_rec =>l_old_header_rec
137 , x_return_status =>l_return_status
138
139 );
140
141 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
142 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
143 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
144 RAISE FND_API.G_EXC_ERROR;
145 END IF;
146
147
148 -- Load OUT parameters.
149
150 x_header_val_rec := OE_Header_Util.Get_Values
151 ( p_header_rec => x_header_rec
152 );
153
154 -- Write to cache.
155 -- Set db_flag to False before writing to cache
156
157 x_header_rec.db_flag := FND_API.G_FALSE;
158
159 -- Re-set the UI flag to FALSE
160 OE_GLOBALS.G_UI_FLAG := FALSE;
161
162 -- Set return status.
163
164 x_return_status := FND_API.G_RET_STS_SUCCESS;
165
166 -- Get message count and data
167
168 OE_MSG_PUB.Count_And_Get
169 ( p_count => x_msg_count
170 , p_data => x_msg_data
171 );
172
173 oe_debug_pub.add('Exiting Oe_Oe_Html_Header.DEFAULT_ATTRIBUTES', 1);
174
175 EXCEPTION
176
177 WHEN FND_API.G_EXC_ERROR THEN
178
179 OE_GLOBALS.G_UI_FLAG := FALSE;
180
181 x_return_status := FND_API.G_RET_STS_ERROR;
182
183 -- Get message count and data
184
185 OE_MSG_PUB.Count_And_Get
186 ( p_count => x_msg_count
187 , p_data => x_msg_data
188 );
189
190 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
191
192 OE_GLOBALS.G_UI_FLAG := FALSE;
193
194 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
195
196 -- Get message count and data
197
198 OE_MSG_PUB.Count_And_Get
199 ( p_count => x_msg_count
200 , p_data => x_msg_data
201 );
202
203 WHEN OTHERS THEN
204
205 OE_GLOBALS.G_UI_FLAG := FALSE;
206
207 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
208
209 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
210 THEN
211 OE_MSG_PUB.Add_Exc_Msg
212 ( G_PKG_NAME
213 , 'Default_Attributes'
214 );
215 END IF;
216
217 -- Get message count and data
218
219 OE_MSG_PUB.Count_And_Get
220 ( p_count => x_msg_count
221 , p_data => x_msg_data
222 );
223
224 END Default_Attributes;
225
226 -- Procedure : Change_Attribute
227 --
228
229
230 PROCEDURE Change_Attribute
231 ( x_return_status OUT NOCOPY VARCHAR2
232 , x_msg_count OUT NOCOPY NUMBER
233 , x_msg_data OUT NOCOPY VARCHAR2
234 , p_header_id IN NUMBER
235 , p_attr_id IN NUMBER
236 , p_attr_value IN VARCHAR2
237 , p_attr_id_tbl IN Number_Tbl_Type
238 , p_attr_value_tbl IN Varchar2_Tbl_Type
239 , x_header_rec IN OUT NOCOPY OE_ORDER_PUB.Header_Rec_Type
240 , x_header_val_rec IN OUT NOCOPY OE_ORDER_PUB.Header_Val_Rec_Type
241 , x_old_header_rec IN OUT NOCOPY OE_ORDER_PUB.Header_Rec_Type
242
243 )
244 IS
245 l_control_rec OE_GLOBALS.Control_Rec_Type;
246 l_return_status VARCHAR2(1);
247 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
248 BEGIN
249
250 oe_debug_pub.add('Entering Oe_Oe_Html_Header.CHANGE_ATTRIBUTES', 1);
251 -- Set the UI flag
252 OE_GLOBALS.G_UI_FLAG := TRUE;
253
254 -- Set control flags.
255
256 l_control_rec.controlled_operation := TRUE;
257 l_control_rec.check_security := TRUE;
258 l_control_rec.clear_dependents := TRUE;
259 l_control_rec.default_attributes := TRUE;
260 l_control_rec.change_attributes := FALSE;
261
262 l_control_rec.validate_entity := FALSE;
263 l_control_rec.write_to_DB := FALSE;
264 l_control_rec.process := FALSE;
265
266 -- Instruct API to retain its caches
267
268 l_control_rec.clear_api_cache := FALSE;
269 l_control_rec.clear_api_requests := FALSE;
270
271 -- Set Operation.
272
273 IF FND_API.To_Boolean(x_header_rec.db_flag) THEN
274 x_header_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
275 ELSE
276 x_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;
277 END IF;
278 oe_debug_pub.add('DB Operation'|| x_header_rec.operation);
279
280 -- Call Oe_Order_Pvt.Header
281
282 Oe_Order_Pvt.Header
283 (
284 p_validation_level => FND_API.G_VALID_LEVEL_NONE
285 , p_init_msg_list => FND_API.G_TRUE
286 , p_control_rec => l_control_rec
287 , p_x_header_rec => x_header_rec
288 , p_x_old_header_rec => x_old_header_rec
289 , x_return_status => l_return_status
290 );
291 oe_debug_pub.add('Exiting invoice'||x_header_rec.invoice_to_org_id, 1);
292 oe_debug_pub.add('Exiting invoice'||x_old_header_rec.invoice_to_org_id, 1);
293
294 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
295 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
296 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
297 RAISE FND_API.G_EXC_ERROR;
298 END IF;
299
300
301 -- Init OUT parameters to missing.
302
303
304 -- Load display out parameters if any
305
306 x_header_val_rec := OE_Header_Util.Get_Values
307 ( p_header_rec => x_header_rec
308 , p_old_header_rec => x_old_header_rec
309 );
310
311 -- Return changed attributes.
312
313
314
315 -- Re-set the UI flag to FALSE
316 OE_GLOBALS.G_UI_FLAG := FALSE;
317
318 -- Set return status.
319
320 x_return_status := FND_API.G_RET_STS_SUCCESS;
321
322 -- Get message count and data
323
324 OE_MSG_PUB.Count_And_Get
325 ( p_count => x_msg_count
326 , p_data => x_msg_data
327 );
328
329 oe_debug_pub.add('Exiting Oe_Oe_Html_Header.CHANGE_ATTRIBUTES', 1);
330
331 EXCEPTION
332
333 WHEN FND_API.G_EXC_ERROR THEN
334
335 OE_GLOBALS.G_UI_FLAG := FALSE;
336
337 x_return_status := FND_API.G_RET_STS_ERROR;
338
339 -- Get message count and data
340
341 OE_MSG_PUB.Count_And_Get
342 ( p_count => x_msg_count
343 , p_data => x_msg_data
344 );
345
346 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
347
348 OE_GLOBALS.G_UI_FLAG := FALSE;
349
350 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
351
352 -- Get message count and data
353
354 OE_MSG_PUB.Count_And_Get
355 ( p_count => x_msg_count
356 , p_data => x_msg_data
357 );
358
359 WHEN OTHERS THEN
360
361 OE_GLOBALS.G_UI_FLAG := FALSE;
362
363 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
364
365 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
366 THEN
367 OE_MSG_PUB.Add_Exc_Msg
368 ( G_PKG_NAME
369 , 'Change_Attribute'
370 );
371 END IF;
372
373 -- Get message count and data
374
375 OE_MSG_PUB.Count_And_Get
376 ( p_count => x_msg_count
377 , p_data => x_msg_data
378 );
379
380 END Change_Attribute;
381
382 -- Procedure Validate_And_Write
383 --
384
385 PROCEDURE Save_Header
386 ( x_return_status OUT NOCOPY VARCHAR2
387 , x_msg_count OUT NOCOPY NUMBER
388 , x_msg_data OUT NOCOPY VARCHAR2
389 , p_header_id IN NUMBER
390 , p_process IN BOOLEAN DEFAULT FALSE
391 , x_header_rec IN OUT NOCOPY OE_ORDER_PUB.Header_Rec_Type
392 , x_header_val_rec IN OUT NOCOPY OE_ORDER_PUB.Header_Val_Rec_Type
393 , x_old_header_rec IN OUT NOCOPY OE_ORDER_PUB.Header_Rec_Type
394
395 )
396 IS
397 l_x_old_header_rec OE_Order_PUB.Header_Rec_Type;
398 l_control_rec OE_GLOBALS.Control_Rec_Type;
399 l_return_status VARCHAR2(1);
400 l_x_header_rec OE_Order_PUB.Header_Rec_Type;
401 L_CASCADE_FLAG BOOLEAN;
402 l_dir VARCHAR2(2000);
403 l_fname VARCHAR2(2000);
404 BEGIN
405
406 -- Framework may rollback if there is an exception. So we mayn't need
407 -- explicit rollback. Pls check this out.
408
409 SAVEPOINT Header_Validate_And_Write;
410
411 oe_debug_pub.add('Entering Oe_Oe_Html_Header.Save_Header', 1);
412
413 -- Set the UI flag
414 OE_GLOBALS.G_UI_FLAG := TRUE;
415
416 -- Set control flags.
417
418 l_control_rec.controlled_operation := TRUE;
419 l_control_rec.validate_entity := FALSE;
420 l_control_rec.write_to_DB := FALSE;
421
422 l_control_rec.check_security := TRUE;
423 l_control_rec.clear_dependents := TRUE;
424 l_control_rec.default_attributes := TRUE;
425 l_control_rec.change_attributes := FALSE; -- lchen
426 l_control_rec.process := FALSE;
427
428 -- Instruct API to retain its caches
429
430 l_control_rec.clear_api_cache := FALSE;
431 l_control_rec.clear_api_requests := FALSE;
432
433 -- Read header from cache
434
435
436
437 -- Set Operation.
438
439 IF FND_API.To_Boolean(x_header_rec.db_flag) THEN
440 x_header_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
441 ELSE
442 x_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;
443 END IF;
444
445
446 -- Call Oe_Order_Pvt.Header
447
448 Oe_Order_Pvt.Header
449 ( p_validation_level => FND_API.G_VALID_LEVEL_NONE
450 , p_init_msg_list => FND_API.G_TRUE
451 , p_control_rec => l_control_rec
452 , p_x_header_rec => x_header_rec
453 , p_x_old_header_rec => x_old_header_rec
454 , x_return_status => l_return_status
455 );
456
457
458 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
459 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
460 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
461 RAISE FND_API.G_EXC_ERROR;
462 END IF;
463
464 oe_debug_pub.add('Exiting Oe_Oe_Html_Header.Save_Header- First PO Call'||
465 l_return_status, 1);
466
467
468
469 -- Load OUT parameters.
470
471 l_control_rec.controlled_operation := TRUE;
472 l_control_rec.validate_entity := TRUE;
473 l_control_rec.write_to_DB := TRUE;
474
475 l_control_rec.check_security := FALSE;
476 l_control_rec.clear_dependents := FALSE;
477 l_control_rec.default_attributes := FALSE;
478 l_control_rec.change_attributes := TRUE; --lchen
479 l_control_rec.process := FALSE;
480
481 -- Instruct API to retain its caches
482
483 l_control_rec.clear_api_cache := FALSE;
484 l_control_rec.clear_api_requests := FALSE;
485
486 -- Read header from cache
487
488
489
490 -- Set Operation.
491
492 IF FND_API.To_Boolean(x_header_rec.db_flag) THEN
493 x_header_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
494 OE_Header_Util.Query_Row
495 ( p_header_id => x_header_rec.header_id
496 , x_header_rec => l_x_old_header_rec
497 );
498 -- l_x_old_header_rec:=x_old_header_rec;
499 ELSE
500 x_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;
501 END IF;
502
503 -- Call Oe_Order_Pvt.Header
504
505 oe_debug_pub.add('Entering Oe_Oe_Html_Header.Save_Header-Second Call', 1);
506
507 Oe_Order_Pvt.Header
508 ( p_validation_level => FND_API.G_VALID_LEVEL_NONE
509 , p_init_msg_list => FND_API.G_FALSE
510 , p_control_rec => l_control_rec
511 , p_x_header_rec => x_header_rec
512 , p_x_old_header_rec => l_x_old_header_rec
513 , x_return_status => l_return_status
514 );
515
516
517 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
518 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
519 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
520 RAISE FND_API.G_EXC_ERROR;
521 END IF;
522
523 IF p_process THEN
524 Process_Object
525 ( x_return_status =>l_return_status
526 , x_msg_count => x_msg_count
527 , x_msg_data => x_msg_data
528 , x_cascade_flag => l_cascade_flag
529 );
530
531 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
532 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
533 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
534 RAISE FND_API.G_EXC_ERROR;
535 END IF;
536 END IF;
537 oe_debug_pub.add('Exiting Oe_Oe_Html_Header.Save_Header-After Second PO'||
538 l_return_status, 1);
539 -- Re-set the UI flag to FALSE
540 OE_GLOBALS.G_UI_FLAG := FALSE;
541
542 -- Set return status.
543
544 x_return_status := FND_API.G_RET_STS_SUCCESS;
545
546 -- Get message count and data
547
548 OE_MSG_PUB.Count_And_Get
549 ( p_count => x_msg_count
550 , p_data => x_msg_data
551 );
552
553 oe_debug_pub.add('Exiting Oe_Oe_Html_Header.Save_Header', 1);
554
555 EXCEPTION
556
557 WHEN FND_API.G_EXC_ERROR THEN
558
559 OE_GLOBALS.G_UI_FLAG := FALSE;
560
561 ROLLBACK TO SAVEPOINT Header_Validate_And_Write;
562
563 x_return_status := FND_API.G_RET_STS_ERROR;
564
565 -- Get message count and data
566
567 OE_MSG_PUB.Count_And_Get
568 ( p_count => x_msg_count
569 , p_data => x_msg_data
570 );
571
572 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
573
574 OE_GLOBALS.G_UI_FLAG := FALSE;
575
576 ROLLBACK TO SAVEPOINT Header_Validate_And_Write;
577
578 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
579
580 -- Get message count and data
581
582 OE_MSG_PUB.Count_And_Get
583 ( p_count => x_msg_count
584 , p_data => x_msg_data
585 );
586
587 WHEN OTHERS THEN
588
589 OE_GLOBALS.G_UI_FLAG := FALSE;
590
591 ROLLBACK TO SAVEPOINT Header_Validate_And_Write;
592
593 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
594
595 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
596 THEN
597 OE_MSG_PUB.Add_Exc_Msg
598 ( G_PKG_NAME
599 , 'Validate_And_Write'
600 );
601 END IF;
602
603 -- Get message count and data
604
605 OE_MSG_PUB.Count_And_Get
606 ( p_count => x_msg_count
607 , p_data => x_msg_data
608 );
609
610 END Save_Header;
611
612 -- Procedure Delete_Row
613 --
614
615 PROCEDURE Delete_Row
616 ( x_return_status OUT NOCOPY VARCHAR2
617 , x_msg_count OUT NOCOPY NUMBER
618 , x_msg_data OUT NOCOPY VARCHAR2
619 , p_header_id IN NUMBER
620 )
621 IS
622 l_x_old_header_rec OE_Order_PUB.Header_Rec_Type;
623 l_control_rec OE_GLOBALS.Control_Rec_Type;
624 l_return_status VARCHAR2(1);
625 l_x_header_rec OE_Order_PUB.Header_Rec_Type;
626 BEGIN
627 SAVEPOINT Header_Delete;
628 oe_debug_pub.add('Entering Oe_Oe_Html_Header.DELETE_ROW', 1);
629
630 -- Set the UI flag
631 OE_GLOBALS.G_UI_FLAG := TRUE;
632
633 -- Set control flags.
634
635 l_control_rec.controlled_operation := TRUE;
636 l_control_rec.check_security := TRUE;
637 l_control_rec.validate_entity := TRUE;
638 l_control_rec.write_to_DB := TRUE;
639
640 l_control_rec.clear_dependents := FALSE;
641 l_control_rec.default_attributes := FALSE;
642 l_control_rec.change_attributes := FALSE;
643 l_control_rec.process := FALSE;
644
645 -- Instruct API to retain its caches
646
647 l_control_rec.clear_api_cache := FALSE;
648 l_control_rec.clear_api_requests := FALSE;
649
650 -- Read DB record from cache
651
652 -- Set Operation.
653
654 l_x_header_rec.operation := OE_GLOBALS.G_OPR_DELETE;
655
656 -- Call Oe_Order_Pvt.Header
657
658 Oe_Order_Pvt.Header
659 ( p_validation_level => FND_API.G_VALID_LEVEL_NONE
660 , p_init_msg_list => FND_API.G_TRUE
661 , p_control_rec => l_control_rec
662 , p_x_header_rec => l_x_header_rec
663 , p_x_old_header_rec => l_x_old_header_rec
664 , x_return_status => l_return_status
665 );
666
667 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
668 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
669 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
670 RAISE FND_API.G_EXC_ERROR;
671 END IF;
672
673
674
675
676 -- Re-set the UI flag to FALSE
677 OE_GLOBALS.G_UI_FLAG := FALSE;
678
679 -- Set return status.
680
681 x_return_status := FND_API.G_RET_STS_SUCCESS;
682
683 -- Get message count and data
684
685 OE_MSG_PUB.Count_And_Get
686 ( p_count => x_msg_count
687 , p_data => x_msg_data
688 );
689
690 oe_debug_pub.add('Exiting Oe_Oe_Html_Header.DELETE_ROW', 1);
691
692 EXCEPTION
693
694 WHEN FND_API.G_EXC_ERROR THEN
695 ROLLBACK TO SAVEPOINT Header_Delete ;
696 OE_GLOBALS.G_UI_FLAG := FALSE;
697
698 x_return_status := FND_API.G_RET_STS_ERROR;
699
700 -- Get message count and data
701
702 OE_MSG_PUB.Count_And_Get
703 ( p_count => x_msg_count
704 , p_data => x_msg_data
705 );
706
707 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
708 ROLLBACK TO SAVEPOINT Header_Delete ;
709
710 OE_GLOBALS.G_UI_FLAG := FALSE;
711
712 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
713
714 -- Get message count and data
715
716 OE_MSG_PUB.Count_And_Get
717 ( p_count => x_msg_count
718 , p_data => x_msg_data
719 );
720
721 WHEN OTHERS THEN
722 ROLLBACK TO SAVEPOINT Header_Delete ;
723
724 OE_GLOBALS.G_UI_FLAG := FALSE;
725
726 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
727
728 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
729 THEN
730 OE_MSG_PUB.Add_Exc_Msg
731 ( G_PKG_NAME
732 , 'Delete_Row'
733 );
734 END IF;
735
736 -- Get message count and data
737
738 OE_MSG_PUB.Count_And_Get
739 ( p_count => x_msg_count
740 , p_data => x_msg_data
741 );
742
743 END Delete_Row;
744
745
746 -- Procedure Process_Object
747 --
748
749 PROCEDURE Process_Object
750
751 (
752 p_init_msg_list IN VARCHAR2:=FND_API.G_FALSE
753 , x_return_status OUT NOCOPY VARCHAR2
754 , x_msg_count OUT NOCOPY NUMBER
755 , x_msg_data OUT NOCOPY VARCHAR2
756 , x_cascade_flag OUT NOCOPY BOOLEAN
757 )
758 IS
759 l_return_status VARCHAR2(1);
760 l_control_rec OE_GLOBALS.Control_Rec_Type;
761 l_line_tbl oe_order_pub.line_tbl_type;
762 BEGIN
763 oe_debug_pub.add('Entering Oe_Oe_Html_Header.PROCESS_OBJECT', 1);
764
765 OE_MSG_PUB.initialize;
766
767 IF OE_CODE_CONTROL.GET_CODE_RELEASE_LEVEL >='110510' THEN
768 If OE_GLOBALS.G_FTE_REINVOKE = 'Y' Then
769 fnd_message.set_name('ONT','ONT_LINE_ATTRIB_CHANGED');
770 OE_MSG_PUB.Add;
771 OE_GLOBALS.G_FTE_REINVOKE := 'N';
772 End If;
773 End If;
774
775 -- we are using this flag to selectively requery the block,
776 -- if any of the delayed req. get executed changing rows.
777 -- currently all the work done in post line process will
778 -- eventually set the global cascading flag to TRUE.
779 -- if some one adds code to post lines, whcih does not
780 -- set cascadinf flga to TURE and still modifes records,
781 -- that will be incorrect.
782 -- this flag helps to requery the block if any thing changed
783 -- after validate and write.
784
785 OE_GLOBALS.G_PROCESS_OBJECTS_FLAG := TRUE;
786
787 l_control_rec.controlled_operation := TRUE;
788 l_control_rec.process := TRUE;
789 l_control_rec.process_entity := OE_GLOBALS.G_ENTITY_ALL;
790
791 l_control_rec.check_security := FALSE;
792 l_control_rec.clear_dependents := FALSE;
793 l_control_rec.default_attributes := FALSE;
794 l_control_rec.change_attributes := FALSE;
795 l_control_rec.validate_entity := FALSE;
796 l_control_rec.write_to_DB := FALSE;
797
798 -- Instruct API to clear its request table
799
800 l_control_rec.clear_api_cache := FALSE;
801 l_control_rec.clear_api_requests := TRUE;
802
803 -- Set the UI flag
804 OE_GLOBALS.G_UI_FLAG := TRUE;
805
806 oe_line_util.Post_Line_Process
807 ( p_control_rec => l_control_rec
808 , p_x_line_tbl => l_line_tbl );
809
810 Oe_Order_Pvt.Process_Requests_And_Notify
811 ( p_process_requests => TRUE
812 , p_init_msg_list => FND_API.G_FALSE
813 , p_notify => TRUE
814 , x_return_status => l_return_status
815 );
816
817
818 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
819 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
820 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
821 RAISE FND_API.G_EXC_ERROR;
822 END IF;
823
824 x_cascade_flag := OE_GLOBALS.G_CASCADING_REQUEST_LOGGED;
825 -- Re-set the UI flag to FALSE
826 OE_GLOBALS.G_UI_FLAG := FALSE;
827
828 -- Set return status.
829
830 x_return_status := FND_API.G_RET_STS_SUCCESS;
831
832 -- Get message count and data
833
834 OE_MSG_PUB.Count_And_Get
835 ( p_count => x_msg_count
836 , p_data => x_msg_data
837 );
838
839 OE_GLOBALS.G_UI_FLAG := FALSE;
840 OE_GLOBALS.G_PROCESS_OBJECTS_FLAG := FALSE;
841
842 oe_debug_pub.add('Exiting Oe_Oe_Html_Header.PROCESS_OBJECT', 1);
843
844 EXCEPTION
845
846 WHEN FND_API.G_EXC_ERROR THEN
847 OE_GLOBALS.G_PROCESS_OBJECTS_FLAG := FALSE;
848 OE_GLOBALS.G_UI_FLAG := FALSE;
849
850 x_return_status := FND_API.G_RET_STS_ERROR;
851
852 -- Get message count and data
853
854 OE_MSG_PUB.Count_And_Get
855 ( p_count => x_msg_count
856 , p_data => x_msg_data
857 );
858
859 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
860 OE_GLOBALS.G_PROCESS_OBJECTS_FLAG := FALSE;
861 OE_GLOBALS.G_UI_FLAG := FALSE;
862
863 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
864
865 -- Get message count and data
866
867 OE_MSG_PUB.Count_And_Get
868 ( p_count => x_msg_count
869 , p_data => x_msg_data
870 );
871
872 WHEN OTHERS THEN
873 OE_GLOBALS.G_PROCESS_OBJECTS_FLAG := FALSE;
874 OE_GLOBALS.G_UI_FLAG := FALSE;
875
876 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
877
878 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
879 THEN
880 OE_MSG_PUB.Add_Exc_Msg
881 ( G_PKG_NAME
882 , 'Process_Object'
883 );
884 END IF;
885
886 -- Get message count and data
887
888 OE_MSG_PUB.Count_And_Get
889 ( p_count => x_msg_count
890 , p_data => x_msg_data
891 );
892
893 END Process_Object;
894
895 -- Procedure lock_Row
896 --
897
898 PROCEDURE Lock_Row
899 ( x_return_status OUT NOCOPY VARCHAR2
900 , x_msg_count OUT NOCOPY NUMBER
901 , x_msg_data OUT NOCOPY VARCHAR2
902 , p_header_id IN NUMBER
903 , p_lock_control IN NUMBER
904 )
905
906 IS
907 l_return_status VARCHAR2(1);
908 l_x_header_rec OE_Order_PUB.Header_Rec_Type;
909 BEGIN
910
911 oe_debug_pub.add('Entering Oe_Oe_Html_Header.LOCK_ROW', 1);
912
913 -- Load header record
914
915 l_x_header_rec.lock_control := p_lock_control;
916 l_x_header_rec.header_id := p_header_id;
917 l_x_header_rec.operation := OE_GLOBALS.G_OPR_LOCK; -- not req.
918
919 -- Call OE_Header_Util.Lock_Row instead of Oe_Order_Pvt.Lock_order
920
921 oe_debug_pub.add('header_id'|| l_x_header_rec.header_id, 1);
922
923 OE_MSG_PUB.initialize;
924 OE_Header_Util.Lock_Row
925 ( x_return_status => l_return_status
926 , p_x_header_rec => l_x_header_rec );
927
928 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
929
930 -- Set DB flag and write record to cache.
931
932 l_x_header_rec.db_flag := FND_API.G_TRUE;
933
934
935 END IF;
936
937 -- Set return status.
938
939 x_return_status := l_return_status;
940 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
941 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
942 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
943 RAISE FND_API.G_EXC_ERROR;
944 END IF;
945
946
947 -- Get message count and data
948
949 OE_MSG_PUB.Count_And_Get
950 ( p_count => x_msg_count
951 , p_data => x_msg_data
952 );
953
954 oe_debug_pub.add('Exiting Oe_Oe_Html_Header.LOCK_ROW', 1);
955
956 EXCEPTION
957 WHEN FND_API.G_EXC_ERROR THEN
958
959 OE_GLOBALS.G_UI_FLAG := FALSE;
960
961 x_return_status := FND_API.G_RET_STS_ERROR;
962
963 -- Get message count and data
964
965 oe_msg_pub.count_and_get
966 ( p_count => x_msg_count
967 , p_data => x_msg_data
968 );
969
970 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
971
972 OE_GLOBALS.G_UI_FLAG := FALSE;
973
974 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
975
976 -- Get message count and data
977
978 oe_msg_pub.count_and_get
979 ( p_count => x_msg_count
980 , p_data => x_msg_data
981 );
982 WHEN OTHERS THEN
983
984 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
985 THEN
986 OE_MSG_PUB.Add_Exc_Msg
987 ( G_PKG_NAME
988 , 'Lock_Row'
989 );
990 END IF;
991
992 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
993
994 -- Get message count and data
995
996 OE_MSG_PUB.Count_And_Get
997 ( p_count => x_msg_count
998 , p_data => x_msg_data
999 );
1000
1001 END Lock_Row;
1002
1003 PROCEDURE Clear_Header
1004 IS
1005 BEGIN
1006
1007 oe_debug_pub.add('Entering Oe_Oe_Html_Header.CLEAR_HEADER', 1);
1008
1009 g_header_rec := OE_Order_PUB.G_MISS_HEADER_REC;
1010 g_db_header_rec := OE_Order_PUB.G_MISS_HEADER_REC;
1011
1012 oe_debug_pub.add('Exiting Oe_Oe_Html_Header.CLEAR_HEADER', 1);
1013
1014 END Clear_Header;
1015
1016
1017 -- This procedure will be called from the client when the user
1018 -- clears a record
1019 Procedure Clear_Record
1020 ( x_return_status OUT NOCOPY VARCHAR2
1021 , x_msg_count OUT NOCOPY NUMBER
1022 , x_msg_data OUT NOCOPY VARCHAR2
1023 , p_header_id IN NUMBER
1024 )
1025 IS
1026 l_return_status Varchar2(30);
1027 BEGIN
1028 OE_MSG_PUB.initialize;
1029 x_return_status := FND_API.G_RET_STS_SUCCESS;
1030
1031 OE_ORDER_CACHE.g_header_rec:=null;
1032 OE_DELAYED_REQUESTS_PVT.Delete_Reqs_for_Deleted_Entity(
1033 p_entity_code => OE_GLOBALS.G_ENTITY_HEADER
1034 ,p_entity_id => p_header_id
1035 ,x_return_status => l_return_status);
1036
1037 OE_MSG_PUB.Count_And_Get
1038 ( p_count => x_msg_count
1039 , p_data => x_msg_data
1040 );
1041
1042 -- Clear the controller cache
1043 Clear_Header;
1044
1045 EXCEPTION
1046 WHEN OTHERS THEN
1047 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1048 THEN
1049 OE_MSG_PUB.Add_Exc_Msg
1050 ( G_PKG_NAME
1051 , 'Clear_Record'
1052 );
1053 END IF;
1054 -- Get message count and data
1055 OE_MSG_PUB.Count_And_Get
1056 ( p_count => x_msg_count
1057 , p_data => x_msg_data
1058 );
1059 x_return_status := FND_API.G_RET_STS_ERROR;
1060
1061 END Clear_Record;
1062
1063
1064 -- This procedure will be called from the client when the user
1065 -- clears a block or Form
1066
1067 Procedure Delete_All_Requests
1068 ( x_return_status OUT NOCOPY VARCHAR2
1069 , x_msg_count OUT NOCOPY NUMBER
1070 , x_msg_data OUT NOCOPY VARCHAR2
1071 )
1072 IS
1073 l_return_status Varchar2(30);
1074 BEGIN
1075 OE_MSG_PUB.initialize;
1076 x_return_status := FND_API.G_RET_STS_SUCCESS;
1077 OE_DELAYED_REQUESTS_PVT.Clear_Request(
1078 x_return_status => l_return_status);
1079
1080 EXCEPTION
1081 WHEN OTHERS THEN
1082 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1083 THEN
1084 OE_MSG_PUB.Add_Exc_Msg
1085 ( G_PKG_NAME
1086 , 'Delete_All_Requests'
1087 );
1088 END IF;
1089 -- Get message count and data
1090 OE_MSG_PUB.Count_And_Get
1091 ( p_count => x_msg_count
1092 , p_data => x_msg_data
1093 );
1094 x_return_status := FND_API.G_RET_STS_ERROR;
1095
1096 END Delete_All_Requests;
1097
1098 PROCEDURE get_customer_details ( p_site_use_id IN NUMBER,
1099 p_site_use_code IN VARCHAR2,
1100 x_customer_id OUT NOCOPY NUMBER,
1101 x_customer_name OUT NOCOPY VARCHAR2,
1102 x_customer_number OUT NOCOPY VARCHAR2
1103 );
1104
1105 PROCEDURE get_customer_details( p_site_use_id IN NUMBER,
1106 p_site_use_code IN VARCHAR2,
1107 x_customer_id OUT NOCOPY NUMBER,
1108 x_customer_name OUT NOCOPY VARCHAR2,
1109 x_customer_number OUT NOCOPY VARCHAR2
1110 ) IS
1111
1112 BEGIN
1113
1114 select /* MOAC_SQL_CHANGE */ cust.cust_account_id,
1115 party.party_name,
1116 cust.account_number
1117 INTO x_customer_id,
1118 x_customer_name,
1119 x_customer_number
1120 from
1121 hz_cust_site_uses_all site,
1122 hz_cust_acct_sites_all cas,
1123 hz_cust_accounts cust,
1124 hz_parties party
1125 where site.site_use_code = p_site_use_code
1126 and site_use_id = p_site_use_id
1127 and site.cust_acct_site_id = cas.cust_acct_site_id
1128 and cas.cust_account_id = cust.cust_account_id
1129 and cust.party_id=party.party_id;
1130 EXCEPTION
1131
1132 WHEN NO_DATA_FOUND THEN
1133 Null;
1134 When too_many_rows then
1135 Null;
1136 When others then
1137 Null;
1138
1139 END get_customer_details;
1140 Procedure Populate_Transient_Attributes
1141 (
1142 p_header_rec IN OE_Order_PUB.Header_Rec_Type
1143 , x_header_val_rec OUT NOCOPY /* file.sql.39 change */ OE_Order_PUB.Header_Val_Rec_Type
1144 , x_return_status OUT NOCOPY VARCHAR2
1145 , x_msg_count OUT NOCOPY NUMBER
1146 , x_msg_data OUT NOCOPY VARCHAR2
1147 )
1148 IS
1149
1150 l_fname VARCHAR2(1000);
1151 order_total NUMBER;
1152
1153 BEGIN
1154 oe_debug_pub.g_debug_level := FND_PROFILE.VALUE('ONT_DEBUG_LEVEL');
1155 l_fname := oe_Debug_pub.set_debug_mode('FILE');
1156 oe_debug_pub.debug_on;
1157
1158 oe_debug_pub.add('Entering Oe_Oe_Html_Header.Get_Values', 1);
1159
1160 /* OE_Header_Util.Query_Row
1161 ( p_header_id => p_header_id
1162 , x_header_rec => l_x_header_rec
1163 );
1164 oe_debug_pub.add('Entering Oe_Oe_Html_Header.Get_Values-Salesrep'||l_x_header_rec.salesrep_id, 1);
1165
1166 x_header_val_rec := OE_Header_Util.Get_Values
1167 ( p_header_rec => l_x_header_rec
1168 );
1169 */
1170
1171 --lchen added
1172 IF (p_header_rec.flow_status_code is not null) THEN
1173 BEGIN
1174 select meaning
1175 into x_header_val_rec.status
1176 from oe_lookups
1177 where lookup_type = 'FLOW_STATUS'
1178 AND lookup_code = p_header_rec.flow_status_code;
1179
1180 EXCEPTION
1181 WHEN NO_DATA_FOUND THEN
1182 Null;
1183 When too_many_rows then
1184 Null;
1185 When others then
1186 Null;
1187 END;
1188 END IF;
1189
1190 IF (p_header_rec.salesrep_id is not null) THEN
1191 BEGIN
1192 SELECT Name
1193 INTO x_header_val_rec.salesrep
1194 FROM ra_salesreps
1195 WHERE salesrep_id=p_header_rec.salesrep_id;
1196 EXCEPTION
1197 WHEN NO_DATA_FOUND THEN
1198 Null;
1199 When too_many_rows then
1200 Null;
1201 When others then
1202 Null;
1203 END;
1204 END IF;
1205
1206 /* IF p_header_rec_type.header_id IS NOT NULL THEN
1207 order_total := OE_OE_TOTALS_SUMMARY.PRT_ORDER_TOTAL
1208 ( p_header_id => p_header_rec.header_id
1209 );
1210 END IF;
1211 */
1212 IF (p_header_rec.ship_to_org_id IS NOT NULL) THEN
1213 BEGIN
1214 get_customer_details(
1215 p_site_use_id => p_header_rec.ship_to_org_id,
1216 p_site_use_code => 'SHIP_TO',
1217 x_customer_id => x_header_val_rec.ship_To_customer_id,
1218 x_customer_name => x_header_val_rec.ship_To_customer_name,
1219 x_customer_number => x_header_val_rec.ship_To_customer_number
1220 );
1221 EXCEPTION
1222 WHEN OTHERS THEN
1223 NULL;
1224 END;
1225 END IF;
1226 IF (p_header_rec.invoice_to_org_id IS NOT NULL) THEN
1227 BEGIN
1228 get_customer_details(
1229 p_site_use_id => p_header_rec.invoice_to_org_id,
1230 p_site_use_code =>'BILL_TO',
1231 x_customer_id =>x_header_val_rec.invoice_To_customer_id,
1232 x_customer_name =>x_header_val_rec.invoice_To_customer_name,
1233 x_customer_number => x_header_val_rec.invoice_To_customer_number
1234 );
1235
1236 EXCEPTION
1237 WHEN OTHERS THEN
1238 NULL;
1239 END;
1240
1241 END IF;
1242
1243
1244 x_return_status := FND_API.G_RET_STS_SUCCESS;
1245 oe_debug_pub.add('Entering Oe_Oe_Html_Header.Get_Values'||x_header_val_rec.salesrep, 1);
1246 oe_debug_pub.add('Exiting Oe_Oe_Html_Header.Get_Values', 1);
1247
1248
1249 EXCEPTION
1250 WHEN OTHERS THEN
1251 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1252 THEN
1253 OE_MSG_PUB.Add_Exc_Msg
1254 ( G_PKG_NAME
1255 , 'Populate_Transient_Attributes'
1256 );
1257 END IF;
1258 -- Get message count and data
1259 OE_MSG_PUB.Count_And_Get
1260 ( p_count => x_msg_count
1261 , p_data => x_msg_data
1262 );
1263 x_return_status := FND_API.G_RET_STS_ERROR;
1264 END Populate_Transient_Attributes;
1265
1266 END Oe_Oe_Html_Header;