[Home] [Help]
PACKAGE BODY: APPS.OE_PORTAL_HEADER
Source
1 PACKAGE BODY OE_Portal_Header AS
2 /* $Header: OEXHPORB.pls 120.0 2005/06/01 01:56:56 appldev noship $ */
3
4 G_PKG_NAME CONSTANT VARCHAR2(30) := 'OE_Portal_Header';
5
6 Procedure Write_Header
7 ( p_header_rec IN OE_ORDER_PUB.Header_Rec_Type
8 , p_db_record IN BOOLEAN := FALSE
9 );
10
11
12 PROCEDURE Get_header
13 ( p_db_record IN BOOLEAN := FALSE
14 , p_header_id IN NUMBER
15 , x_header_rec OUT NOCOPY OE_Order_PUB.Header_Rec_Type
16 );
17
18 PROCEDURE Clear_header;
19
20
21
22 PROCEDURE Default_Header_Attributes
23 ( x_return_status OUT NOCOPY VARCHAR2
24
25 , x_msg_count OUT NOCOPY NUMBER
26
27 , x_msg_data OUT NOCOPY VARCHAR2
28
29 , p_sold_to_org_id IN NUMBER
30 , x_agreement_id OUT NOCOPY NUMBER
31
32 , x_freight_carrier_code OUT NOCOPY VARCHAR2
33
34 , x_freight_terms_code OUT NOCOPY VARCHAR2
35
36 --, x_header_id OUT NUMBER
37 , x_header_id OUT NOCOPY VARCHAR2
38
39 , x_invoice_to_org_id OUT NOCOPY NUMBER
40
41 , x_order_type_id OUT NOCOPY NUMBER
42
43 , x_org_id OUT NOCOPY NUMBER
44
45 , x_partial_shipments_allowed OUT NOCOPY VARCHAR2
46
47 , x_payment_term_id OUT NOCOPY NUMBER
48
49 , x_price_list_id OUT NOCOPY NUMBER
50
51 , x_shipment_priority_code OUT NOCOPY VARCHAR2
52
53 , x_shipping_method_code OUT NOCOPY VARCHAR2
54
55 , x_ship_to_org_id OUT NOCOPY NUMBER
56
57 , x_sold_to_org_id OUT NOCOPY NUMBER
58
59 , x_tax_exempt_flag OUT NOCOPY VARCHAR2
60
61 , x_tax_exempt_number OUT NOCOPY VARCHAR2
62
63 , x_tax_point_code OUT NOCOPY VARCHAR2
64
65 , x_transactional_curr_code OUT NOCOPY VARCHAR2
66
67 , x_payment_type_code OUT NOCOPY VARCHAR2
68
69 , x_shipping_instructions OUT NOCOPY VARCHAR2
70
71 , x_shipping_method OUT NOCOPY VARCHAR2
72
73 , x_freight_terms OUT NOCOPY VARCHAR2
74
75 , x_invoice_to_address1 OUT NOCOPY VARCHAR2
76
77 , x_invoice_to_address2 OUT NOCOPY VARCHAR2
78
79 , x_invoice_to_address3 OUT NOCOPY VARCHAR2
80
81 , x_invoice_to_address4 OUT NOCOPY VARCHAR2
82
83 , x_payment_term OUT NOCOPY VARCHAR2
84
85 , x_shipment_priority OUT NOCOPY varchar2
86
87 , x_ship_to_address1 OUT NOCOPY VARCHAR2
88
89 , x_ship_to_address2 OUT NOCOPY VARCHAR2
90
91 , x_ship_to_address3 OUT NOCOPY VARCHAR2
92
93 , x_ship_to_address4 OUT NOCOPY VARCHAR2
94
95 , x_sold_to_org OUT NOCOPY VARCHAR2
96
97 , x_tax_point OUT NOCOPY VARCHAR2
98
99 ,x_request_date OUT NOCOPY DATE
100
101 , x_tax_exempt OUT NOCOPY VARCHAR2
102
103 , x_partial_shipments OUT NOCOPY VARCHAR2
104
105 , x_order_type OUT NOCOPY VARCHAR2
106
107 , x_customer_number OUT NOCOPY VARCHAR2
108
109 ) IS
110 l_header_rec OE_Order_PUB.Header_Rec_Type;
111 l_header_val_rec OE_Order_PUB.Header_Val_Rec_Type;
112 l_old_header_rec OE_Order_PUB.Header_Rec_Type;
113 l_control_rec OE_GLOBALS.Control_Rec_Type;
114 l_return_status VARCHAR2(1);
115 --
116 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
117 --
118 BEGIN
119 IF l_debug_level > 0 THEN
120 oe_debug_pub.add( 'ENTERING OE_PORTAL_HEADER.DEFAULT_HEADER_ATTRIBUTES' , 1 ) ;
121 END IF;
122
123 IF l_debug_level > 0 THEN
124 oe_debug_pub.add( 'ESHAS TEST' ) ;
125 END IF;
126
127 -- Set the UI flag
128 OE_GLOBALS.G_UI_FLAG := TRUE;
129
130 -- Set control flags.
131
132 l_control_rec.controlled_operation := TRUE;
133 l_control_rec.check_security := TRUE;
134 l_control_rec.default_attributes := TRUE;
135 -- l_control_rec.change_attributes := TRUE;
136 l_control_rec.change_attributes := FALSE;
137
138 l_control_rec.clear_dependents := TRUE;
139 l_control_rec.validate_entity := FALSE;
140 l_control_rec.write_to_DB := FALSE;
141 l_control_rec.process := FALSE;
142
143 -- Instruct API to retain its caches
144
145 l_control_rec.clear_api_cache := FALSE;
146 l_control_rec.clear_api_requests := FALSE;
147
148 -- Load IN parameters if any exist
149
150 l_old_header_rec :=OE_ORDER_PUB.G_MISS_HEADER_REC;
151 l_header_rec :=OE_ORDER_PUB.G_MISS_HEADER_REC;
152 l_header_rec.sold_to_org_id := p_sold_to_org_id;
153 l_header_val_rec :=OE_ORDER_PUB.G_MISS_HEADER_VAL_REC;
154
155 -- Defaulting of flex values is currently done by the form.
156 -- Set flex attributes to NULL in order to avoid defaulting them.
157
158 l_header_rec.attribute1 := NULL;
159 l_header_rec.attribute10 := NULL;
160 l_header_rec.attribute11 := NULL;
161 l_header_rec.attribute12 := NULL;
162 l_header_rec.attribute13 := NULL;
163 l_header_rec.attribute14 := NULL;
164 l_header_rec.attribute15 := NULL;
165 l_header_rec.attribute2 := NULL;
166 l_header_rec.attribute3 := NULL;
167 l_header_rec.attribute4 := NULL;
168 l_header_rec.attribute5 := NULL;
169 l_header_rec.attribute6 := NULL;
170 l_header_rec.attribute7 := NULL;
171 l_header_rec.attribute8 := NULL;
172 l_header_rec.attribute9 := NULL;
173 l_header_rec.context := NULL;
174 l_header_rec.global_attribute1 := NULL;
175 l_header_rec.global_attribute10 := NULL;
176 l_header_rec.global_attribute11 := NULL;
177 l_header_rec.global_attribute12 := NULL;
178 l_header_rec.global_attribute13 := NULL;
179 l_header_rec.global_attribute14 := NULL;
180 l_header_rec.global_attribute15 := NULL;
181 l_header_rec.global_attribute16 := NULL;
182 l_header_rec.global_attribute17 := NULL;
183 l_header_rec.global_attribute18 := NULL;
184 l_header_rec.global_attribute19 := NULL;
185 l_header_rec.global_attribute2 := NULL;
186 l_header_rec.global_attribute20 := NULL;
187 l_header_rec.global_attribute3 := NULL;
188 l_header_rec.global_attribute4 := NULL;
189 l_header_rec.global_attribute5 := NULL;
190 l_header_rec.global_attribute6 := NULL;
191 l_header_rec.global_attribute7 := NULL;
192 l_header_rec.global_attribute8 := NULL;
193 l_header_rec.global_attribute9 := NULL;
194 l_header_rec.global_attribute_category := NULL;
195 l_header_rec.tp_context := NULL;
196 l_header_rec.tp_attribute1 := NULL;
197 l_header_rec.tp_attribute2 := NULL;
198 l_header_rec.tp_attribute3 := NULL;
199 l_header_rec.tp_attribute4 := NULL;
200 l_header_rec.tp_attribute5 := NULL;
201 l_header_rec.tp_attribute6 := NULL;
202 l_header_rec.tp_attribute7 := NULL;
203 l_header_rec.tp_attribute8 := NULL;
204 l_header_rec.tp_attribute9 := NULL;
205 l_header_rec.tp_attribute10 := NULL;
206 l_header_rec.tp_attribute11 := NULL;
207 l_header_rec.tp_attribute12 := NULL;
208 l_header_rec.tp_attribute13 := NULL;
209 l_header_rec.tp_attribute14 := NULL;
210 l_header_rec.tp_attribute15 := NULL;
211
212 -- Set Operation to Create
213
214 l_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;
215
216 -- Call Oe_Order_Pvt.Header
217
218 Oe_Order_Pvt.Header
219 ( p_validation_level =>FND_API.G_VALID_LEVEL_NONE
220 , p_init_msg_list => FND_API.G_TRUE
221 , p_control_rec =>l_control_rec
222 , p_x_header_rec =>l_header_rec
223 , p_x_old_header_rec =>l_old_header_rec
224 , x_return_status =>l_return_status
225 );
226
227 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
228 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
229 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
230 RAISE FND_API.G_EXC_ERROR;
231 END IF;
232
233 IF l_debug_level > 0 THEN
234 oe_debug_pub.add( 'L_HEADER_REC.TAX_EXEMPT_FLAG ' || L_HEADER_REC.TAX_EXEMPT_FLAG ) ;
235 END IF;
236 -- Load OUT parameters.
237
238 l_header_val_rec := OE_Header_Util.Get_Values
239 ( p_header_rec => l_header_rec
240 );
241
242 -- Write to cache.
243 -- Set db_flag to False before writing to cache
244
245 l_header_rec.db_flag := FND_API.G_FALSE;
246
247 Write_header
248 ( p_header_rec => l_header_rec
249 );
250
251
252 -- Re-set the UI flag to FALSE
253 OE_GLOBALS.G_UI_FLAG := FALSE;
254
255 -- Set return status.
256
257 x_return_status := FND_API.G_RET_STS_SUCCESS;
258
259 -- Get message count and data
260
261 OE_MSG_PUB.Count_And_Get
262 ( p_count => x_msg_count
263 , p_data => x_msg_data
264 );
265
266
267 x_request_date := l_header_rec.request_date;
268 x_agreement_id := l_header_rec.agreement_id;
269 x_freight_carrier_code := l_header_rec.freight_carrier_code;
270 x_freight_terms_code := l_header_rec.freight_terms_code;
271 x_header_id := l_header_rec.header_id;
272 x_invoice_to_org_id := l_header_rec.invoice_to_org_id;
273 x_order_type_id := l_header_rec.order_type_id;
274 x_org_id := l_header_rec.org_id;
275 x_partial_shipments_allowed := l_header_rec.partial_shipments_allowed;
276 x_payment_term_id := l_header_rec.payment_term_id;
277 x_price_list_id := l_header_rec.price_list_id;
278 x_shipment_priority_code := l_header_rec.shipment_priority_code;
279 x_shipping_method_code := l_header_rec.shipping_method_code;
280 x_ship_to_org_id := l_header_rec.ship_to_org_id;
281 x_sold_to_org_id := l_header_rec.sold_to_org_id;
282 x_tax_exempt_flag := l_header_rec.tax_exempt_flag;
283 x_tax_exempt_number := l_header_rec.tax_exempt_number;
284 x_tax_point_code := l_header_rec.tax_point_code;
285 x_transactional_curr_code := l_header_rec.transactional_curr_code;
286 x_payment_type_code := l_header_rec.payment_type_code;
287 x_shipping_instructions := l_header_rec.shipping_instructions;
288
289 x_freight_terms := l_header_val_rec.freight_terms;
290 x_invoice_to_address1 := l_header_val_rec.invoice_to_address1;
291 x_invoice_to_address2 := l_header_val_rec.invoice_to_address2;
292 x_invoice_to_address3 := l_header_val_rec.invoice_to_address3;
293 x_invoice_to_address4 := l_header_val_rec.invoice_to_address4;
294 x_payment_term := l_header_val_rec.payment_term;
295 x_shipment_priority := l_header_val_rec.shipment_priority;
296 x_ship_to_address1 := l_header_val_rec.ship_to_address1;
297 x_ship_to_address2 := l_header_val_rec.ship_to_address2;
298 x_ship_to_address3 := l_header_val_rec.ship_to_address3;
299 x_ship_to_address4 := l_header_val_rec.ship_to_address4;
300 x_sold_to_org := l_header_val_rec.sold_to_org;
301 x_tax_point := l_header_val_rec.tax_point;
302 x_shipping_method := l_header_val_rec.shipping_method;
303 x_tax_exempt := l_header_val_rec.tax_exempt;
304 x_order_type := l_header_val_rec.order_type;
305 x_customer_number := l_header_val_rec.customer_number;
306 if upper(x_partial_shipments_allowed) = 'Y' then
307 x_partial_shipments := 'Yes';
308 elsif upper(x_partial_shipments_allowed) = 'N' then
309 x_partial_shipments := 'No';
310 end if;
311
312 IF l_debug_level > 0 THEN
313 oe_debug_pub.add( 'EXITING OE_PORTAL_HEADER.DEFAULT_ATTRIBUTES' , 1 ) ;
314 END IF;
315 EXCEPTION
316
317 WHEN FND_API.G_EXC_ERROR THEN
318
319 OE_GLOBALS.G_UI_FLAG := FALSE;
320
321 x_return_status := FND_API.G_RET_STS_ERROR;
322
323 -- Get message count and data
324
325 OE_MSG_PUB.Count_And_Get
326 ( p_count => x_msg_count
327 , p_data => x_msg_data
328 );
329
330 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
331 OE_GLOBALS.G_UI_FLAG := FALSE;
332
333 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
334
335 -- Get message count and data
336
337 OE_MSG_PUB.Count_And_Get
338 ( p_count => x_msg_count
339 , p_data => x_msg_data
340 );
341
342 WHEN OTHERS THEN
343
344 OE_GLOBALS.G_UI_FLAG := FALSE;
345
346 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
347
348 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
349 THEN
350 OE_MSG_PUB.Add_Exc_Msg
351 ( G_PKG_NAME
352 , 'Default__Header_Attributes'
353 );
354 END IF;
355
356 -- Get message count and data
357
358 OE_MSG_PUB.Count_And_Get
359 ( p_count => x_msg_count
360 , p_data => x_msg_data
361 );
362
363
364
365
366 END;
367
368
369 PROCEDURE Validate_Write_Header
370 ( x_return_status OUT NOCOPY VARCHAR2
371
372 , x_msg_count OUT NOCOPY NUMBER
373
374 , x_msg_data OUT NOCOPY VARCHAR2
375
376 , p_header_id IN NUMBER
377 , p_db_record IN VARCHAR2
378 , p_freight_terms_code IN VARCHAR2
379 , p_invoice_to_org_id IN NUMBER
380 , p_partial_shipments_allowed IN VARCHAR2
381 , p_shipment_priority_code IN VARCHAR2
382 , p_shipping_method_code IN VARCHAR2
383 , p_ship_to_org_id IN NUMBER
384 , p_tax_exempt_flag IN VARCHAR2
385 , p_request_date IN VARCHAR2
386 , p_cust_po_number IN VARCHAR2
387 , p_shipping_instructions IN VARCHAR2
388 , p_sold_to_org_id IN NUMBER
389 , x_order_number OUT NOCOPY NUMBER
390
391 , x_agreement_id OUT NOCOPY NUMBER
392
393 , x_freight_carrier_code OUT NOCOPY VARCHAR2
394
395 , x_freight_terms_code OUT NOCOPY VARCHAR2
396
397 , x_header_id OUT NOCOPY NUMBER
398
399 , x_invoice_to_org_id OUT NOCOPY NUMBER
400
401 , x_order_type_id OUT NOCOPY NUMBER
402
403 , x_org_id OUT NOCOPY NUMBER
404
405 , x_partial_shipments_allowed OUT NOCOPY VARCHAR2
406
407 , x_payment_term_id OUT NOCOPY NUMBER
408
409 , x_price_list_id OUT NOCOPY NUMBER
410
411 , x_shipment_priority_code OUT NOCOPY VARCHAR2
412
413 , x_shipping_method_code OUT NOCOPY VARCHAR2
414
415 , x_ship_to_org_id OUT NOCOPY NUMBER
416
417 , x_sold_to_org_id OUT NOCOPY NUMBER
418
419 , x_tax_exempt_flag OUT NOCOPY VARCHAR2
420
421 , x_tax_exempt_number OUT NOCOPY VARCHAR2
422
423 , x_tax_point_code OUT NOCOPY VARCHAR2
424
425 , x_transactional_curr_code OUT NOCOPY VARCHAR2
426
427 , x_payment_type_code OUT NOCOPY VARCHAR2
428
429 , x_shipping_instructions OUT NOCOPY VARCHAR2
430
431 , x_shipping_method OUT NOCOPY VARCHAR2
432
433 , x_freight_terms OUT NOCOPY VARCHAR2
434
435 , x_invoice_to_address1 OUT NOCOPY VARCHAR2
436
437 , x_invoice_to_address2 OUT NOCOPY VARCHAR2
438
439 , x_invoice_to_address3 OUT NOCOPY VARCHAR2
440
441 , x_invoice_to_address4 OUT NOCOPY VARCHAR2
442
443 , x_payment_term OUT NOCOPY VARCHAR2
444
445 , x_shipment_priority OUT NOCOPY varchar2
446
447 , x_ship_to_address1 OUT NOCOPY VARCHAR2
448
449 , x_ship_to_address2 OUT NOCOPY VARCHAR2
450
451 , x_ship_to_address3 OUT NOCOPY VARCHAR2
452
453 , x_ship_to_address4 OUT NOCOPY VARCHAR2
454
455 , x_sold_to_org OUT NOCOPY VARCHAR2
456
457 , x_tax_point OUT NOCOPY VARCHAR2
458
459 , x_request_date OUT NOCOPY DATE
460
461 , x_cust_po_number OUT NOCOPY VARCHAR2
462
463 , x_tax_exempt OUT NOCOPY VARCHAR2
464
465 , x_partial_shipments OUT NOCOPY VARCHAR2
466
467 , x_order_type OUT NOCOPY VARCHAR2
468
469 , x_customer_number OUT NOCOPY VARCHAR2
470
471 /*, x_cascade_flag OUT NOCOPY VARCHAR2*/
472
473 )
474 IS
475 l_db_record BOOLEAN;
476 l_cascade_flag BOOLEAN;
477 l_lock_control NUMBER;
478 l_x_old_header_rec OE_Order_PUB.Header_Rec_Type;
479 l_control_rec OE_GLOBALS.Control_Rec_Type;
480 l_return_status VARCHAR2(1);
481 l_x_header_rec OE_Order_PUB.Header_Rec_Type;
482 l_header_val_rec OE_Order_Pub.Header_Val_Rec_Type;
483 --
484 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
485 --
486 BEGIN
487
488 SAVEPOINT Header_Validate_And_Write;
489
490 IF l_debug_level > 0 THEN
491 oe_debug_pub.add( 'ENTERING OE_PORTAL_HEADER.VALIDATE_WRITE_HEADER' , 1 ) ;
492 oe_debug_pub.add( 'HEADER ID' || P_HEADER_ID , 1 ) ;
493 oe_debug_pub.add( 'DB FLAG' || P_DB_RECORD , 1 ) ;
494 END IF;
495
496 if p_db_record = 'Y' THEN
497 l_db_record := TRUE;
498 else
499 l_db_record := FALSE;
500 END IF;
501
502 -- Set the UI flag
503 OE_GLOBALS.G_UI_FLAG := TRUE;
504
505 -- Set control flags.
506
507 l_control_rec.controlled_operation := TRUE;
508 l_control_rec.validate_entity := TRUE;
509 l_control_rec.write_to_DB := TRUE;
510
511 l_control_rec.check_security := TRUE;
512 l_control_rec.clear_dependents := TRUE;
513 l_control_rec.default_attributes := FALSE;
514 l_control_rec.change_attributes := TRUE;
515 l_control_rec.process := FALSE;
516
517 -- Instruct API to retain its caches
518
519 l_control_rec.clear_api_cache := FALSE;
520 l_control_rec.clear_api_requests := FALSE;
521
522 l_x_old_header_rec := OE_ORDER_PUB.G_MISS_HEADER_REC;
523
524 Get_header
525 ( p_db_record => l_db_record
526 , p_header_id => p_header_id
527 , x_header_rec => l_x_header_rec
528 );
529 IF l_debug_level > 0 THEN
530 oe_debug_pub.add( 'HEADER ID' || L_X_HEADER_REC.HEADER_ID , 1 ) ;
531 END IF;
532
533 if p_freight_terms_code is not null then
534 l_x_header_rec.freight_terms_code := p_freight_terms_code;
535 end if;
536 if p_invoice_to_org_id is not null then
537 l_x_header_rec.invoice_to_org_id := p_invoice_to_org_id;
538 end if;
539 if p_partial_shipments_allowed is not null then
540 l_x_header_rec.partial_shipments_allowed := p_partial_shipments_allowed;
541 end if;
542 if p_shipment_priority_code is not null then
543 l_x_header_rec.shipment_priority_code := p_shipment_priority_code;
544 end if;
545 if p_shipping_method_code is not null then
546 l_x_header_rec.shipping_method_code := p_shipping_method_code;
547 end if;
548 if p_ship_to_org_id is not null then
549 l_x_header_rec.ship_to_org_id := p_ship_to_org_id;
550 end if;
551 if p_tax_exempt_flag is not null then
552 l_x_header_rec.tax_exempt_flag := p_tax_exempt_flag;
553 end if;
554 if p_request_date is not null then
555 l_x_header_rec.request_date := fnd_date.canonical_to_date(p_request_date);
556 end if;
557 if p_cust_po_number is not null then
558 l_x_header_rec.cust_po_number := p_cust_po_number;
559 end if;
560 if p_shipping_instructions is not null then
561 l_x_header_rec.shipping_instructions := p_shipping_instructions;
562 end if;
563
564 if p_sold_to_org_id is not null then
565 l_x_header_rec.sold_to_org_id := p_sold_to_org_id;
566 end if;
567 -- Set Operation.
568
569 IF FND_API.To_Boolean(l_x_header_rec.db_flag) THEN
570 l_x_header_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
571
572 /* Start Audit Trail - if it is update, set reason,comments */
573 l_x_header_rec.change_reason := 'SYSTEM';
574 /* End Audit Trail */
575 ELSE
576 l_x_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;
577 END IF;
578
579 -- Call Oe_Order_Pvt.Header
580
581 Oe_Order_Pvt.Header
582 ( p_validation_level => FND_API.G_VALID_LEVEL_NONE
583 , p_init_msg_list => FND_API.G_TRUE
584 , p_control_rec => l_control_rec
585 , p_x_header_rec => l_x_header_rec
586 , p_x_old_header_rec => l_x_old_header_rec
587 , x_return_status => l_return_status
588 );
589
590 IF l_debug_level > 0 THEN
591 oe_debug_pub.add( 'L_X_HEADER_REC.TAX_EXEMPT_FLA_G ' || L_X_HEADER_REC.TAX_EXEMPT_FLAG ) ;
592 END IF;
593
594 IF l_debug_level > 0 THEN
595 oe_debug_pub.add( 'HEADER ID' || L_X_HEADER_REC.HEADER_ID , 1 ) ;
596 END IF;
597 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
598 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
599 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
600 RAISE FND_API.G_EXC_ERROR;
601 END IF;
602
603
604 Oe_Order_Pvt.Process_Requests_And_Notify
605 ( p_process_requests => FALSE
606 , p_init_msg_list => FND_API.G_FALSE
607 , p_notify => TRUE
608 , x_return_status => l_return_status
609 , p_header_rec => l_x_header_rec
610 , p_old_header_rec => l_x_old_header_rec
611 );
612 IF l_debug_level > 0 THEN
613 oe_debug_pub.add( 'L_HEADER_REC.TAX_EXEMPT_FLAG ' || L_X_HEADER_REC.TAX_EXEMPT_FLAG ) ;
614 END IF;
615
616 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
617 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
618 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
619 RAISE FND_API.G_EXC_ERROR;
620 END IF;
621
622 l_cascade_flag := OE_GLOBALS.G_CASCADING_REQUEST_LOGGED;
623
624
625 /* IF l_cascade_flag THEN
626 x_cascade_flag := 'Y';
627 ELSE
628 x_cascade_flag := 'N';
629 END IF;
630 */
631
632 -- Load OUT parameters.
633
634 IF l_debug_level > 0 THEN
635 oe_debug_pub.add( 'L_HEADER_REC.TAX_EXEMPT_FLAG ' || L_X_HEADER_REC.TAX_EXEMPT_FLAG ) ;
636 END IF;
637
638 x_order_number := l_x_header_rec.order_number;
639 l_lock_control := l_x_header_rec.lock_control;
640
641 IF l_cascade_flag then
642 Get_header
643 ( p_db_record => TRUE
644 , p_header_id => p_header_id
645 , x_header_rec => l_x_header_rec
646 );
647 END IF;
648 IF l_debug_level > 0 THEN
649 oe_debug_pub.add( 'HEADER ID' || L_X_HEADER_REC.HEADER_ID , 1 ) ;
650 END IF;
651
652 l_header_val_rec := OE_Header_Util.Get_Values
653 ( p_header_rec => l_x_header_rec
654 );
655
656 x_request_date := l_x_header_rec.request_date;
657 x_agreement_id := l_x_header_rec.agreement_id;
658 x_freight_carrier_code := l_x_header_rec.freight_carrier_code;
659 x_freight_terms_code := l_x_header_rec.freight_terms_code;
660 x_header_id := l_x_header_rec.header_id;
661 x_invoice_to_org_id := l_x_header_rec.invoice_to_org_id;
662 x_order_type_id := l_x_header_rec.order_type_id;
663 x_org_id := l_x_header_rec.org_id;
664 x_partial_shipments_allowed := l_x_header_rec.partial_shipments_allowed;
665 x_payment_term_id := l_x_header_rec.payment_term_id;
666 x_price_list_id := l_x_header_rec.price_list_id;
667 x_shipment_priority_code := l_x_header_rec.shipment_priority_code;
668 x_shipping_method_code := l_x_header_rec.shipping_method_code;
669 x_ship_to_org_id := l_x_header_rec.ship_to_org_id;
670 x_sold_to_org_id := l_x_header_rec.sold_to_org_id;
671 x_tax_exempt_flag := l_x_header_rec.tax_exempt_flag;
672 x_tax_exempt_number := l_x_header_rec.tax_exempt_number;
673 x_tax_point_code := l_x_header_rec.tax_point_code;
674 x_transactional_curr_code := l_x_header_rec.transactional_curr_code;
675 x_payment_type_code := l_x_header_rec.payment_type_code;
676 x_shipping_instructions := l_x_header_rec.shipping_instructions;
677
678 x_freight_terms := l_header_val_rec.freight_terms;
679 x_invoice_to_address1 := l_header_val_rec.invoice_to_address1;
680 x_invoice_to_address2 := l_header_val_rec.invoice_to_address2;
681 x_invoice_to_address3 := l_header_val_rec.invoice_to_address3;
682 x_invoice_to_address4 := l_header_val_rec.invoice_to_address4;
683 x_payment_term := l_header_val_rec.payment_term;
684 x_shipment_priority := l_header_val_rec.shipment_priority;
685 x_ship_to_address1 := l_header_val_rec.ship_to_address1;
686 x_ship_to_address2 := l_header_val_rec.ship_to_address2;
687 x_ship_to_address3 := l_header_val_rec.ship_to_address3;
688 x_ship_to_address4 := l_header_val_rec.ship_to_address4;
689 x_sold_to_org := l_header_val_rec.sold_to_org;
690 x_tax_point := l_header_val_rec.tax_point;
691 x_shipping_method := l_header_val_rec.shipping_method;
692 x_customer_number := l_header_val_rec.customer_number;
693 x_tax_exempt := l_header_val_rec.tax_exempt;
694 x_order_type := l_header_val_rec.order_type;
695
696 if upper(x_partial_shipments_allowed) = 'Y' then
697 x_partial_shipments := 'Yes';
698 elsif upper(x_partial_shipments_allowed) = 'N' then
699 x_partial_shipments := 'No';
700 end if;
701 -- Clear header record cache
702 Clear_Header;
703
704 -- Keep track of performed operations.
705 -- l_x_old_header_rec.operation := l_x_header_rec.operation;
706
707 -- Re-set the UI flag to FALSE
708 OE_GLOBALS.G_UI_FLAG := FALSE;
709
710 -- Set return status.
711
712 x_return_status := FND_API.G_RET_STS_SUCCESS;
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 IF l_debug_level > 0 THEN
722 oe_debug_pub.add( 'RETURN STATUS'|| X_RETURN_STATUS , 1 ) ;
723 oe_debug_pub.add( 'HEADER_ID'|| X_HEADER_ID , 1 ) ;
724 oe_debug_pub.add( 'EXITING OE_PORTAL_HEADER.VALIDATE_WRITE_HEADER' , 1 ) ;
725 END IF;
726
727 /*
728 oe_debug_pub.add('no. of OE messages :'||x_msg_count,1);
729 dbms_output.put_line('no. of OE messages :'||x_msg_count);
730 for k in 1 .. x_msg_count loop
731 x_msg_data := oe_msg_pub.get( p_msg_index => k,
732 p_encoded => 'F'
733 );
734 oe_debug_pub.add(substr(x_msg_data,1,255));
735 dbms_output.put_line('Error msg: '||substr(x_msg_data,1,2000));
736 end loop;
737
738 fnd_msg_pub.count_and_get( p_encoded => 'F'
739 , p_count => x_msg_count
740 , p_data => x_msg_data);
741 oe_debug_pub.add('no. of FND messages :'||x_msg_count,1);
742 dbms_output.put_line('no. of FND messages :'||x_msg_count);
743 for k in 1 .. x_msg_count loop
744 x_msg_data := fnd_msg_pub.get( p_msg_index => k,
745 p_encoded => 'F'
746 );
747 dbms_output.put_line('Error msg: '||substr(x_msg_data,1,200));
748 oe_debug_pub.add(substr(x_msg_data,1,255));
749
750 end loop;
751 */
752 EXCEPTION
753
754 WHEN FND_API.G_EXC_ERROR THEN
755
756 OE_GLOBALS.G_UI_FLAG := FALSE;
757
758 ROLLBACK TO SAVEPOINT Header_Validate_And_Write;
759
760 x_return_status := FND_API.G_RET_STS_ERROR;
761
762 -- Get message count and data
763
764 OE_MSG_PUB.Count_And_Get
765 ( p_count => x_msg_count
766 , p_data => x_msg_data
767 );
768
769 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
770
771 OE_GLOBALS.G_UI_FLAG := FALSE;
772
773 ROLLBACK TO SAVEPOINT Header_Validate_And_Write;
774
775 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
776
777 -- Get message count and data
778
779 OE_MSG_PUB.Count_And_Get
780 ( p_count => x_msg_count
781 , p_data => x_msg_data
782 );
783
784 WHEN OTHERS THEN
785
786 OE_GLOBALS.G_UI_FLAG := FALSE;
787
788 ROLLBACK TO SAVEPOINT Header_Validate_And_Write;
789
790 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
791
792 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
793 THEN
794 OE_MSG_PUB.Add_Exc_Msg
795 ( G_PKG_NAME
796 , 'Validate_And_Write'
797 );
798 END IF;
799
800 -- Get message count and data
801
802 OE_MSG_PUB.Count_And_Get
803 ( p_count => x_msg_count
804 , p_data => x_msg_data
805 );
806
807 END Validate_Write_Header;
808
809
810 PROCEDURE Delete_Row
811 ( x_return_status OUT NOCOPY VARCHAR2
812
813 , x_msg_count OUT NOCOPY NUMBER
814
815 , x_msg_data OUT NOCOPY VARCHAR2
816
817 , p_header_id IN NUMBER
818 )
819 IS
820 l_x_old_header_rec OE_Order_PUB.Header_Rec_Type;
821 l_control_rec OE_GLOBALS.Control_Rec_Type;
822 l_return_status VARCHAR2(1);
823 l_x_header_rec OE_Order_PUB.Header_Rec_Type;
824 --
825 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
826 --
827 BEGIN
828
829 IF l_debug_level > 0 THEN
830 oe_debug_pub.add( 'ENTERING OE_OE_FORM_HEADER.DELETE_ROW' , 1 ) ;
831 END IF;
832
833 -- Set the UI flag
834 OE_GLOBALS.G_UI_FLAG := TRUE;
835
836 -- Set control flags.
837
838 l_control_rec.controlled_operation := TRUE;
839 l_control_rec.check_security := TRUE;
840 l_control_rec.validate_entity := TRUE;
841 l_control_rec.write_to_DB := TRUE;
842
843 l_control_rec.clear_dependents := FALSE;
844 l_control_rec.default_attributes := FALSE;
845 l_control_rec.change_attributes := FALSE;
846 l_control_rec.process := FALSE;
847
848 -- Instruct API to retain its caches
849
850 l_control_rec.clear_api_cache := FALSE;
851 l_control_rec.clear_api_requests := FALSE;
852
853 -- Read DB record from cache
854
855 Get_header
856 ( p_db_record => TRUE
857 , p_header_id => p_header_id
858 , x_header_rec => l_x_header_rec
859 );
860
861 -- Set Operation.
862
863 l_x_header_rec.operation := OE_GLOBALS.G_OPR_DELETE;
864
865 -- Call Oe_Order_Pvt.Header
866
867 Oe_Order_Pvt.Header
868 ( p_validation_level => FND_API.G_VALID_LEVEL_NONE
869 , p_init_msg_list => FND_API.G_TRUE
870 , p_control_rec => l_control_rec
871 , p_x_header_rec => l_x_header_rec
872 , p_x_old_header_rec => l_x_old_header_rec
873 , x_return_status => l_return_status
874 );
875
876
877 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
878
879
880 -- Set the UI flag
881 OE_GLOBALS.G_UI_FLAG := TRUE;
882
883 -- Set control flags.
884
885 l_control_rec.controlled_operation := TRUE;
886 l_control_rec.check_security := TRUE;
887 l_control_rec.validate_entity := TRUE;
888 l_control_rec.write_to_DB := TRUE;
889
890 l_control_rec.clear_dependents := TRUE;
891 l_control_rec.default_attributes := FALSE;
892 l_control_rec.change_attributes := TRUE;
893 l_control_rec.process := FALSE;
894
895 -- Instruct API to retain its caches
896
897 l_control_rec.clear_api_cache := FALSE;
898 l_control_rec.clear_api_requests := FALSE;
899
900 l_x_old_header_rec := OE_ORDER_PUB.G_MISS_HEADER_REC;
901 l_x_header_rec.cancelled_flag := 'Y';
902 -- Set Operation.
903
904 l_x_header_rec.operation := OE_GLOBALS.G_OPR_UPDATE;
905
906 -- Call Oe_Order_Pvt.Header
907
908 Oe_Order_Pvt.Header
909 ( p_validation_level => FND_API.G_VALID_LEVEL_NONE
910 , p_init_msg_list => FND_API.G_TRUE
911 , p_control_rec => l_control_rec
912 , p_x_header_rec => l_x_header_rec
913 , p_x_old_header_rec => l_x_old_header_rec
914 , x_return_status => l_return_status
915 );
916
917 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
918 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
919 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
920 RAISE FND_API.G_EXC_ERROR;
921 END IF;
922
923
924
925 END IF;
926
927
928 -- Clear header record cache
929
930 Clear_header;
931
932 -- Re-set the UI flag to FALSE
933 OE_GLOBALS.G_UI_FLAG := FALSE;
934
935 -- Set return status.
936
937 x_return_status := FND_API.G_RET_STS_SUCCESS;
938
939 -- Get message count and data
940
941 OE_MSG_PUB.Count_And_Get
942 ( p_count => x_msg_count
943 , p_data => x_msg_data
944 );
945
946 IF l_debug_level > 0 THEN
947 oe_debug_pub.add( 'EXITING OE_OE_FORM_HEADER.DELETE_ROW' , 1 ) ;
948 END IF;
949
950 EXCEPTION
951
952 WHEN FND_API.G_EXC_ERROR THEN
953
954 OE_GLOBALS.G_UI_FLAG := FALSE;
955
956 x_return_status := FND_API.G_RET_STS_ERROR;
957
958 -- Get message count and data
959
960 OE_MSG_PUB.Count_And_Get
961 ( p_count => x_msg_count
962 , p_data => x_msg_data
963 );
964
965 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
966
967 OE_GLOBALS.G_UI_FLAG := FALSE;
968
969 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
970
971 -- Get message count and data
972
973 OE_MSG_PUB.Count_And_Get
974 ( p_count => x_msg_count
975 , p_data => x_msg_data
976 );
977
978 WHEN OTHERS THEN
979
980 OE_GLOBALS.G_UI_FLAG := FALSE;
981
982 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
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 , 'Delete_Row'
989 );
990 END IF;
991
992 -- Get message count and data
993
994 OE_MSG_PUB.Count_And_Get
995 ( p_count => x_msg_count
996 , p_data => x_msg_data
997 );
998
999 END Delete_Row;
1000
1001
1002
1003 PROCEDURE GET_HEADER_TOTALS
1004 ( x_return_status OUT NOCOPY VARCHAR2
1005
1006 , x_msg_count OUT NOCOPY NUMBER
1007
1008 , x_msg_data OUT NOCOPY VARCHAR2
1009
1010 , p_header_id IN NUMBER
1011 , x_line_total OUT NOCOPY NUMBER
1012
1013 , x_tax_total OUT NOCOPY NUMBER
1014
1015 , x_charge_total OUT NOCOPY NUMBER
1016
1017 , x_order_total OUT NOCOPY NUMBER
1018
1019 )
1020 IS
1021 --
1022 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1023 --
1024 BEGIN
1025
1026 IF p_header_id is NULL OR p_header_id = FND_API.G_MISS_NUM THEN
1027
1028 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
1029 THEN
1030
1031 fnd_message.set_name('ONT','OE_CONFIG_PARAMETER_REQUIRED');
1032 FND_MESSAGE.SET_TOKEN('PARAMETER','Header_Id');
1033 OE_MSG_PUB.Add;
1034
1035 END IF;
1036 RAISE FND_API.G_EXC_ERROR;
1037
1038 END IF;
1039
1040
1041 x_line_total := OE_Totals_Grp.Get_Order_Total(p_header_id,
1042 null,
1043 'LINES');
1044
1045 x_tax_total := OE_Totals_Grp.Get_Order_Total(p_header_id,
1046 null,
1047 'TAXES');
1048
1049 x_charge_total := OE_Totals_Grp.Get_Order_Total(p_header_id,
1050 null,
1051 'CHARGES');
1052
1053 x_order_total := OE_Totals_Grp.Get_Order_Total(p_header_id,
1054 null,
1055 'ALL');
1056
1057
1058 x_return_status := FND_API.G_RET_STS_SUCCESS;
1059
1060 -- Get message count and data
1061
1062 OE_MSG_PUB.Count_And_Get
1063 ( p_count => x_msg_count
1064 , p_data => x_msg_data
1065 );
1066
1067 IF l_debug_level > 0 THEN
1068 oe_debug_pub.add( 'EXITING OE_PORTAL_HEADER.GET_ORDER_TOTALS' , 1 ) ;
1069 END IF;
1070
1071 EXCEPTION
1072
1073 WHEN FND_API.G_EXC_ERROR THEN
1074
1075 OE_GLOBALS.G_UI_FLAG := FALSE;
1076
1077 x_return_status := FND_API.G_RET_STS_ERROR;
1078
1079 -- Get message count and data
1080
1081 OE_MSG_PUB.Count_And_Get
1082 ( p_count => x_msg_count
1083 , p_data => x_msg_data
1084 );
1085
1086 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1087
1088 OE_GLOBALS.G_UI_FLAG := FALSE;
1089
1090 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1091
1092 -- Get message count and data
1093
1094 OE_MSG_PUB.Count_And_Get
1095 ( p_count => x_msg_count
1096 , p_data => x_msg_data
1097 );
1098
1099 WHEN OTHERS THEN
1100
1101 OE_GLOBALS.G_UI_FLAG := FALSE;
1102
1103 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1104
1105 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1106 THEN
1107 OE_MSG_PUB.Add_Exc_Msg
1108 ( G_PKG_NAME
1109 , 'Delete_Row'
1110 );
1111 END IF;
1112
1113 -- Get message count and data
1114
1115 OE_MSG_PUB.Count_And_Get
1116 ( p_count => x_msg_count
1117 , p_data => x_msg_data
1118 );
1119
1120 END Get_Header_Totals;
1121
1122
1123 PROCEDURE Get_header
1124 ( p_db_record IN BOOLEAN := FALSE
1125 , p_header_id IN NUMBER
1126 , x_header_rec OUT NOCOPY OE_Order_PUB.Header_Rec_Type
1127 )
1128 IS
1129 --
1130 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1131 --
1132 BEGIN
1133
1134 IF l_debug_level > 0 THEN
1135 oe_debug_pub.add( 'ENTERING OE_PORTAL_HEADER.GET_HEADER' , 1 ) ;
1136 oe_debug_pub.add( 'CACHED HEADER ID ' || G_HEADER_REC.HEADER_ID , 1 ) ;
1137 END IF;
1138
1139 IF p_header_id <> NVL(g_header_rec.header_id,FND_API.G_MISS_NUM)
1140 THEN
1141
1142 -- Query row from DB
1143
1144 OE_Header_Util.Query_Row
1145 ( p_header_id => p_header_id,
1146 x_header_rec =>g_header_rec
1147 );
1148
1149 g_header_rec.db_flag := FND_API.G_TRUE;
1150
1151 -- Load DB record
1152
1153 g_db_header_rec := g_header_rec;
1154
1155 END IF;
1156
1157 IF p_db_record THEN
1158
1159 x_header_rec:= g_db_header_rec;
1160
1161 ELSE
1162
1163 x_header_rec:= g_header_rec;
1164
1165 END IF;
1166
1167 IF l_debug_level > 0 THEN
1168 oe_debug_pub.add( 'EXITING OE_PORTAL_HEADER.GET_HEADER' , 1 ) ;
1169 END IF;
1170
1171 END Get_Header;
1172
1173 PROCEDURE Clear_Header
1174 IS
1175 --
1176 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1177 --
1178 BEGIN
1179
1180 IF l_debug_level > 0 THEN
1181 oe_debug_pub.add( 'ENTERING OE_PORTAL_HEADER.CLEAR_HEADER' , 1 ) ;
1182 END IF;
1183
1184 g_header_rec := OE_Order_PUB.G_MISS_HEADER_REC;
1185 g_db_header_rec := OE_Order_PUB.G_MISS_HEADER_REC;
1186
1187 IF l_debug_level > 0 THEN
1188 oe_debug_pub.add( 'EXITING OE_PORTAL_HEADER.CLEAR_HEADER' , 1 ) ;
1189 END IF;
1190
1191 END Clear_Header;
1192
1193
1194
1195 PROCEDURE Write_header
1196 ( p_header_rec IN OE_Order_PUB.Header_Rec_Type
1197 , p_db_record IN BOOLEAN := FALSE
1198 )
1199 IS
1200 --
1201 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1202 --
1203 BEGIN
1204
1205 IF l_debug_level > 0 THEN
1206 oe_debug_pub.add( 'ENTERING OE_PORTAL_HEADER.WRITE_HEADER' , 1 ) ;
1207 END IF;
1208
1209 g_header_rec := p_header_rec;
1210
1211 IF p_db_record THEN
1212
1213 g_db_header_rec := p_header_rec;
1214
1215 END IF;
1216
1217 IF l_debug_level > 0 THEN
1218 oe_debug_pub.add( 'EXITING OE_PORTAL_HEADER.WRITE_HEADER' , 1 ) ;
1219 oe_debug_pub.add( 'G_HEADER_REC.HEADER_ID ' || G_HEADER_REC.HEADER_ID , 1 ) ;
1220 END IF;
1221 END Write_Header;
1222
1223
1224 END OE_Portal_Header;