1 PACKAGE BODY OE_Validate_Header AS
2 /* $Header: OEXLHDRB.pls 120.25.12020000.3 2013/01/25 20:23:42 suthumma ship $ */
3
4 -- Global constant holding the package name
5
6 G_PKG_NAME CONSTANT VARCHAR2(30) := 'OE_Validate_Header';
7
8
9 /* LOCAL PROCEDURES */
10
11 -- QUOTING changes
12 /*-------------------------------------------------------
13 PROCEDURE: Check_Negotiation_Attributes
14 Description: This procedures validates the order attributes
15 against transaction phase (Negotiation vs Fulfillment).
16 --------------------------------------------------------*/
17
18 PROCEDURE Check_Negotiation_Attributes
19 ( p_header_rec IN OE_Order_PUB.Header_Rec_Type
20 , p_old_header_rec IN OE_Order_PUB.Header_Rec_Type
21 , x_return_status IN OUT NOCOPY VARCHAR2
22 )
23 IS
24 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
25 BEGIN
26
27 if l_debug_level > 0 then
28 oe_debug_pub.add('Enter OE_VALIDATE_HEADER.Check_Negotiation_Attributes',1);
29 end if;
30
31 x_return_status := FND_API.G_RET_STS_SUCCESS;
32
33
34 IF p_header_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
35
36 -- Transaction phase cannot be updated on a saved transaction.
37
38 IF OE_Quote_Util.G_COMPLETE_NEG = 'N' AND
39 NOT OE_GLOBALS.EQUAL(p_header_rec.transaction_phase_code
40 ,p_old_header_rec.transaction_phase_code)
41 THEN
42 FND_MESSAGE.SET_NAME('ONT','OE_PHASE_UPDATE_NOT_ALLOWED');
43 OE_MSG_PUB.ADD;
44 RAISE FND_API.G_EXC_ERROR;
45 END IF;
46
47 -- New version number cannot be lower than previous version
48
49 IF nvl(p_header_rec.version_number,-1) < p_old_header_rec.version_number
50 THEN
51 FND_MESSAGE.SET_NAME('ONT','OE_VERSION_NUM_ERROR');
52 OE_MSG_PUB.ADD;
53 x_return_status := FND_API.G_RET_STS_ERROR;
54 END IF;
55
56 END IF; -- End of check for UPDATE operation
57
58
59 -- Start checks specific to the transaction phase
60
61 IF nvl(p_header_rec.transaction_phase_code,'F') = 'F' THEN
62
63 -- Cannot update following quote attributes in fulfillment phase
64
65 IF (NOT OE_GLOBALS.EQUAL(p_header_rec.quote_number
66 ,p_old_header_rec.quote_number)) OR
67 (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
68 p_header_rec.quote_number IS NOT NULL )
69 --OR cnd added for Bug 5060064
70 THEN
71 FND_MESSAGE.SET_NAME('ONT','OE_CANT_UPDATE_QUOTE_ATTR');
72 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
73 OE_Order_UTIL.Get_Attribute_Name('QUOTE_NUMBER'));
74 OE_MSG_PUB.ADD;
75 x_return_status := FND_API.G_RET_STS_ERROR;
76 END IF;
77
78 IF (NOT OE_GLOBALS.EQUAL(p_header_rec.quote_date
79 ,p_old_header_rec.quote_date)) OR
80 (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
81 p_header_rec.quote_date IS NOT NULL )
82 --OR cnd added for Bug 5060064
83 THEN
84 FND_MESSAGE.SET_NAME('ONT','OE_CANT_UPDATE_QUOTE_ATTR');
85 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
86 OE_Order_UTIL.Get_Attribute_Name('QUOTE_DATE'));
87 OE_MSG_PUB.ADD;
88 x_return_status := FND_API.G_RET_STS_ERROR;
89 END IF;
90
91 IF (NOT OE_GLOBALS.EQUAL(p_header_rec.expiration_date
92 ,p_old_header_rec.expiration_date)) OR
93 (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
94 p_header_rec.expiration_date IS NOT NULL )
95 --OR cnd added for Bug 5060064
96 THEN
97 FND_MESSAGE.SET_NAME('ONT','OE_CANT_UPDATE_QUOTE_ATTR');
98 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
99 OE_Order_UTIL.Get_Attribute_Name('EXPIRATION_DATE'));
100 OE_MSG_PUB.ADD;
101 x_return_status := FND_API.G_RET_STS_ERROR;
102 END IF;
103
104 -- Bug 3189579
105 -- Sales document name is supported on both sales orders and
106 -- quoted orders. Check is not needed here.
107
108 -- Checks if order is in negotiation phase
109
110 ELSIF p_header_rec.transaction_phase_code = 'N' THEN
111
112 -- Cannot update following order attributes in negotiation phase
113
114 IF (NOT OE_GLOBALS.EQUAL(p_header_rec.order_number
115 ,p_old_header_rec.order_number)) OR
116 (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
117 p_header_rec.order_number IS NOT NULL)
118 --OR cnd added for Bug 5060064
119 THEN
120 FND_MESSAGE.SET_NAME('ONT','OE_CANT_UPDATE_ORDER_ATTR');
121 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
122 OE_Order_UTIL.Get_Attribute_Name('ORDER_NUMBER'));
123 OE_MSG_PUB.ADD;
124 x_return_status := FND_API.G_RET_STS_ERROR;
125 END IF;
126
127 IF (NOT OE_GLOBALS.EQUAL(p_header_rec.ordered_date
128 ,p_old_header_rec.ordered_date)) OR
129 (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
130 p_header_rec.ordered_date IS NOT NULL )
131 --OR cnd added for Bug 5060064
132 THEN
133 FND_MESSAGE.SET_NAME('ONT','OE_CANT_UPDATE_ORDER_ATTR');
134 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
135 OE_Order_UTIL.Get_Attribute_Name('ORDERED_DATE'));
136 OE_MSG_PUB.ADD;
137 x_return_status := FND_API.G_RET_STS_ERROR;
138 END IF;
139
140 -- Return orders not supported
141 IF p_header_rec.order_category_code = 'RETURN' THEN
142 FND_MESSAGE.SET_NAME('ONT','OE_QUOTE_RETURN_NOT_SUPP');
143 OE_MSG_PUB.ADD;
144 x_return_status := FND_API.G_RET_STS_ERROR;
145 END IF;
146
147 -- Internal sales orders not allowed
148 IF p_header_rec.order_source_id = 10 THEN
149 FND_MESSAGE.SET_NAME('ONT','OE_QUOTE_INT_ORD_NOT_SUPP');
150 OE_MSG_PUB.ADD;
151 x_return_status := FND_API.G_RET_STS_ERROR;
152 END IF;
153
154 -- Cancellation operation not supported for quotes
155 IF p_header_rec.cancelled_flag = 'Y' THEN
156 FND_MESSAGE.SET_NAME('ONT','OE_QUOTE_CANCEL_NOT_SUPP');
157 OE_MSG_PUB.ADD;
158 x_return_status := FND_API.G_RET_STS_ERROR;
159 END IF;
160
161 END IF; -- End of check if phase = F/N
162
163 oe_debug_pub.add('Exiting OE_VALIDATE_HEADER.Check_Negotiation_Attributes',1);
164
165 EXCEPTION
166 WHEN FND_API.G_EXC_ERROR THEN
167 x_return_status := FND_API.G_RET_STS_ERROR;
168 WHEN OTHERS THEN
169 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
170
171 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
172 THEN
173 OE_MSG_PUB.Add_Exc_Msg
174 ( G_PKG_NAME ,
175 'Check_Negotiation_Attributes'
176 );
177 END IF;
178
179 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
180 END Check_Negotiation_Attributes;
181
182 /*-------------------------------------------------------
183 PROCEDURE: Check_Book_Reqd_Attributes
184 Description:
185 --------------------------------------------------------*/
186
187 PROCEDURE Check_Book_Reqd_Attributes
188 ( p_header_rec IN OE_Order_PUB.Header_Rec_Type
189 , x_return_status IN OUT NOCOPY /* file.sql.39 change */ VARCHAR2
190 )
191 IS
192 l_order_type_rec OE_Order_Cache.Order_Type_Rec_Type;
193 l_set_of_books_rec OE_Order_Cache.Set_Of_Books_Rec_Type;
194 BEGIN
195
196 oe_debug_pub.add('Enter OE_VALIDATE_HEADER.CHECK_BOOK_REQD',1);
197
198 -- Check for the following required fields on a booked order:
199 -- Order Number, Sold To Org, Invoice To Org,
200 -- Price List, Tax Exempt Flag, Sales Person, Order Date
201
202 IF p_header_rec.sold_to_org_id IS NULL
203 THEN
204 x_return_status := FND_API.G_RET_STS_ERROR;
205 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQUIRED_ATTRIBUTE');
206 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
207 OE_Order_UTIL.Get_Attribute_Name('SOLD_TO_ORG_ID'));
208 OE_MSG_PUB.ADD;
209 END IF;
210
211 IF p_header_rec.salesrep_id IS NULL
212 THEN
213 x_return_status := FND_API.G_RET_STS_ERROR;
214 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQUIRED_ATTRIBUTE');
215 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
216 OE_Order_UTIL.Get_Attribute_Name('SALESREP_ID'));
217 OE_MSG_PUB.ADD;
218 END IF;
219
220 IF p_header_rec.ordered_date IS NULL
221 THEN
222 x_return_status := FND_API.G_RET_STS_ERROR;
223 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQUIRED_ATTRIBUTE');
224 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
225 OE_Order_UTIL.Get_Attribute_Name('ORDERED_DATE'));
226 OE_MSG_PUB.ADD;
227 END IF;
228
229 IF p_header_rec.invoice_to_org_id IS NULL
230 THEN
231 x_return_status := FND_API.G_RET_STS_ERROR;
232 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQUIRED_ATTRIBUTE');
233 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
234 OE_Order_UTIL.Get_Attribute_Name('INVOICE_TO_ORG_ID'));
235 OE_MSG_PUB.ADD;
236 END IF;
237
238 IF p_header_rec.tax_exempt_flag IS NULL
239 THEN
240 x_return_status := FND_API.G_RET_STS_ERROR;
241 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQUIRED_ATTRIBUTE');
242 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
243 OE_Order_UTIL.Get_Attribute_Name('TAX_EXEMPT_FLAG'));
244 OE_MSG_PUB.ADD;
245 END IF;
246
247
248 -- Fix bug 1262790
249 -- Ship To Org and Payment Term are required only on regular or
250 -- MIXED orders, NOT on RETURN orders
251
252 IF p_header_rec.order_category_code <>
253 OE_GLOBALS.G_RETURN_CATEGORY_CODE THEN
254
255 IF p_header_rec.ship_to_org_id IS NULL
256 THEN
257 x_return_status := FND_API.G_RET_STS_ERROR;
258 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQUIRED_ATTRIBUTE');
259 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
260 OE_Order_UTIL.Get_Attribute_Name('SHIP_TO_ORG_ID'));
261 OE_MSG_PUB.ADD;
262 END IF;
263
264 IF p_header_rec.payment_term_id IS NULL
265 THEN
266 x_return_status := FND_API.G_RET_STS_ERROR;
267 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQUIRED_ATTRIBUTE');
268 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
269 OE_Order_UTIL.Get_Attribute_Name('PAYMENT_TERM_ID'));
270 OE_MSG_PUB.ADD;
271 END IF;
272
273 END IF;
274
275 --key transaction dates
276 IF (OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110509' and p_header_rec.order_firmed_date > p_header_rec.booked_date) THEN
277 x_return_status := FND_API.G_RET_STS_ERROR;
278 FND_MESSAGE.SET_NAME('ONT','ONT_ORDER_FIRMED_DATE_INVALID');
279 OE_MSG_PUB.ADD;
280 END IF;
281 --end
282
283 -- Check for additional required fields based on flags set
284 -- at the order type: agreement, customer po number
285
286 l_order_type_rec := OE_Order_Cache.Load_Order_Type
287 (p_header_rec.order_type_id);
288
289 IF ( l_order_type_rec.agreement_required_flag = 'Y' AND
290 p_header_rec.agreement_id IS NULL)
291 THEN
292 x_return_status := FND_API.G_RET_STS_ERROR;
293 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQUIRED_ATTRIBUTE');
294 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
295 OE_Order_UTIL.Get_Attribute_Name('AGREEMENT_ID'));
296 OE_MSG_PUB.ADD;
297 END IF;
298
299 IF ( l_order_type_rec.require_po_flag = 'Y' AND
300 p_header_rec.cust_po_number IS NULL)
301 THEN
302 x_return_status := FND_API.G_RET_STS_ERROR;
303 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQUIRED_ATTRIBUTE');
304 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
305 OE_Order_UTIL.Get_Attribute_Name('CUST_PO_NUMBER'));
306 OE_MSG_PUB.ADD;
307 END IF;
308
309
310 -- Conversion Type Related Checks
311
312 -- IF SOB currency is dIFferent from order currency,
313 -- conversion type is required
314
315 IF p_header_rec.conversion_type_code IS NULL
316 THEN
317 l_set_of_books_rec := OE_Order_Cache.Load_Set_Of_Books;
318
319 IF ( l_set_of_books_rec.currency_code <>
320 p_header_rec.transactional_curr_code) THEN
321 x_return_status := FND_API.G_RET_STS_ERROR;
322 FND_MESSAGE.SET_NAME('ONT','OE_VAL_REQ_NON_BASE_CURRENCY');
323 FND_MESSAGE.SET_TOKEN
324 ('ORDER_CURRENCY',p_header_rec.transactional_curr_code);
325 FND_MESSAGE.SET_TOKEN('SOB_CURRENCY',l_set_of_books_rec.currency_code);
326 OE_MSG_PUB.ADD;
327 END IF;
328
329 -- IF conversion type is 'User', conversion rate AND conversion rate date
330 -- required.
331
332 ELSIF p_header_rec.conversion_type_code = 'User'
333 THEN
334
335 IF p_header_rec.conversion_rate IS NULL OR
336 p_header_rec.conversion_rate_date IS NULL
337 THEN
338 x_return_status := FND_API.G_RET_STS_ERROR;
339 FND_MESSAGE.SET_NAME('ONT','OE_VAL_USER_CONVERSION_TYPE');
340 OE_MSG_PUB.ADD;
341 END IF;
342 END IF; -- END of checks based on conversion type
343
344
345 -- Checks based on payment type attached to the order
346
347 IF p_header_rec.payment_type_code IS NOT NULL THEN
348
349 -- payment amount should be specIFied
350
351 IF OE_PREPAYMENT_UTIL.IS_MULTIPLE_PAYMENTS_ENABLED = FALSE
352 AND p_header_rec.payment_type_code <> 'CREDIT_CARD'
353 AND p_header_rec.payment_amount IS NULL
354 THEN
355 x_return_status := FND_API.G_RET_STS_ERROR;
356 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQUIRED_ATTRIBUTE');
357 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
358 OE_Order_UTIL.Get_Attribute_Name('PAYMENT_AMOUNT'));
359 OE_MSG_PUB.ADD;
360 END IF;
361
362 -- check number required IF payment type is Check
363
364 IF (p_header_rec.payment_type_code = 'CHECK' AND
365 p_header_rec.check_number IS NULL )
366 THEN
367 x_return_status := FND_API.G_RET_STS_ERROR;
368 FND_MESSAGE.SET_NAME('ONT','OE_VAL_CHECK_NUM_REQD');
369 OE_MSG_PUB.ADD;
370 END IF;
371
372 -- credit card holder name, number AND expiration date
373 -- required for payment type of Credit Card
374
375 /*
376 ** Following Validation Moved to Authorize Credit Card
377 ** Payment Routine. Not required anymore at BOOKING.
378 IF p_header_rec.payment_type_code = 'CREDIT_CARD' THEN
379 IF p_header_rec.credit_card_holder_name IS NULL
380 OR p_header_rec.credit_card_number IS NULL
381 OR p_header_rec.credit_card_expiration_date IS NULL
382 THEN
383 x_return_status := FND_API.G_RET_STS_ERROR;
384 FND_MESSAGE.SET_NAME('ONT','OE_VAL_CREDIT_CARD_REQD');
385 OE_MSG_PUB.ADD;
386 END IF;
387 END IF;
388 */
389
390 END IF; -- END of checks related to payment type
391
392 oe_debug_pub.add('Exiting OE_VALIDATE_HEADER.CHECK_BOOK_REQD',1);
393 EXCEPTION
394 WHEN OTHERS THEN
395 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
396
397 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
398 THEN
399 OE_MSG_PUB.Add_Exc_Msg
400 ( G_PKG_NAME ,
401 'Check_Book_Reqd_Attributes'
402 );
403 END IF;
404
405 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
406 END Check_Book_Reqd_Attributes;
407
408
409
410 /*-------------------------------------------------------
411 PROCEDURE: Validate_Order_Type
412 Description:
413 --------------------------------------------------------*/
414
415 Procedure Validate_Order_Type(p_order_type_id IN NUMBER,
416 p_old_order_type_id IN NUMBER,
417 p_header_id IN NUMBER,
418 p_operation IN VARCHAR2)
419 IS
420 lexists varchar2(30);
421 lprocessname varchar2(80);
422 BEGIN
423
424 oe_debug_pub.add('Entering OE_VALIDATE_HEADER.Validate_Order_Type',1);
425 IF p_operation = OE_GLOBALS.G_OPR_UPDATE
426 THEN
427 IF NOT OE_GLOBALS.EQUAL(p_order_type_id
428 ,p_old_Order_type_id)
429 THEN
430 SELECT root_activity
431 into lprocessname
432 from wf_items_v
433 where item_key = to_char(p_header_id)
434 AND item_type = 'OEOH'
435 AND rownum = 1;
436
437 SELECT 'EXISTS'
438 INTO lexists
439 FROM oe_workflow_assignments a
440 WHERE a.order_type_id = p_order_type_id
441 AND a.process_name = lprocessname
442 AND a.line_type_id IS NULL
443 AND a.end_date_active is null
444 AND rownum = 1;
445 END IF;
446 END IF;
447
448 oe_debug_pub.add('Exiting OE_VALIDATE_HEADER.Validate_Order_Type',1);
449 EXCEPTION
450 WHEN NO_DATA_FOUND THEN
451 FND_MESSAGE.SET_NAME('ONT','OE_FLOW_CNT_CHANGE');
452 OE_MSG_PUB.ADD;
453 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
454
455 WHEN OTHERS THEN
456 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
457 THEN
458 OE_MSG_PUB.Add_Exc_Msg
459 ( G_PKG_NAME ,
460 'Validate_Order_Type'
461 );
462 END IF;
463 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
464 END Validate_Order_type;
465
466 -- bug 1618229.
467 -- Procedure to validate if the currency matches the currency for
468 -- the commitment on order line if there is any.
469 Procedure Validate_Commitment_Currency(p_header_id IN NUMBER
470 ,p_transactional_curr_code IN VARCHAR2
471 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
472 IS
473
474 l_commitment_id NUMBER;
475 L_COMMITMENT_CURR_CODE VARCHAR2(15);
476
477 CURSOR l_line_csr IS
478 SELECT commitment_id
479 FROM oe_order_lines
480 WHERE header_id = p_header_id
481 AND commitment_id is not null;
482
483 BEGIN
484
485 oe_debug_pub.add('Entering OE_VALIDATE_HEADER.Validate_Commitment_Currency',1);
486 OPEN l_line_csr;
487 LOOP
488 FETCH l_line_csr INTO l_commitment_id;
489 EXIT WHEN l_line_csr%NOTFOUND;
490
491 -- get the currency code associated with the commitment.
492 IF l_commitment_id IS NOT NULL THEN
493 BEGIN
494 SELECT invoice_currency_code
495 INTO l_commitment_curr_code
496 FROM ra_customer_trx
497 WHERE customer_trx_id = l_commitment_id;
498
499 EXCEPTION WHEN NO_DATA_FOUND THEN
500 null;
501 END;
502
503 oe_debug_pub.add('OEXLHDRB: commitment currency is: '||l_commitment_curr_code, 3);
504 oe_debug_pub.add('OEXLHDRB: order currency is: '||p_transactional_curr_code, 3);
505
506 IF NOT OE_GLOBALS.EQUAL(l_commitment_curr_code, p_transactional_curr_code) THEN
507 x_return_status := FND_API.G_RET_STS_ERROR;
508 EXIT;
509 END IF;
510 END IF;
511
512 END LOOP;
513 CLOSE l_line_csr;
514
515 oe_debug_pub.add('Exiting OE_VALIDATE_HEADER.Validate_Commitment_Currency',1);
516
517 EXCEPTION
518 WHEN NO_DATA_FOUND THEN
519 FND_MESSAGE.SET_NAME('ONT','OE_FLOW_CNT_CHANGE');
520 OE_MSG_PUB.ADD;
521 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
522
523 WHEN OTHERS THEN
524 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
525 THEN
526 OE_MSG_PUB.Add_Exc_Msg
527 ( G_PKG_NAME ,
528 'Validate_Commitment_Currency'
529 );
530 END IF;
531 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
532 END Validate_Commitment_Currency;
533
534 -- bug 1618229.
535 -- Procedure to validate if the the customer on order header matches
536 -- the customer for the commitment on order line if there is any.
537 Procedure Validate_Commitment_Customer(p_header_id IN NUMBER
538 ,p_sold_to_org_id IN NUMBER
539 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
540 IS
541
542 l_commitment_id NUMBER;
543 l_exists VARCHAR2(1) := 'N';
544
545 CURSOR l_line_csr IS
546 SELECT commitment_id
547 FROM oe_order_lines
548 WHERE header_id = p_header_id
549 AND commitment_id is not null;
550
551 Cursor cur_customer_relations (p_commitment_id IN NUMBER) is
552 select 'Y'
553 from ra_customer_trx ratrx
554 where ratrx.customer_trx_id = p_commitment_id
555 and ratrx.bill_to_customer_id = p_sold_to_org_id
556
557 union all
558
559 select 'Y'
560 from ra_customer_trx ratrx
561 where ratrx.customer_trx_id = p_commitment_id
562 and exists (SELECT 1
563 FROM hz_cust_acct_relate_all hcar
564 WHERE hcar.cust_account_id = ratrx.bill_to_customer_id
565 and hcar.related_cust_account_id = p_sold_to_org_id
566 AND hcar.status = 'A'
567 and hcar.org_id = ratrx.org_id
568 AND hcar.bill_to_flag = 'Y');
569
570 BEGIN
571
572 oe_debug_pub.add('Entering OE_VALIDATE_HEADER.Validate_Commitment_Customer',1);
573 OPEN l_line_csr;
574 LOOP
575 FETCH l_line_csr INTO l_commitment_id;
576 EXIT WHEN l_line_csr%NOTFOUND;
577
578 -- validate the sold_to_org_id of order against the customer for commitment.
579 oe_debug_pub.add('OEXLHDRB: l_commitment_id in validation is: '||l_commitment_id, 3);
580 IF l_commitment_id IS NOT NULL THEN
581 BEGIN
582 /*SELECT MOAC_SQL_CHANGE 'Y'
583 INTO l_exists
584 FROM ra_customer_trx ratrx
585 WHERE ratrx.bill_to_customer_id
586 IN (SELECT p_sold_to_org_id
587 FROM sys.dual
588 UNION
589 SELECT cust_account_id customer_id
590 FROM hz_cust_acct_relate_all h
591 WHERE related_cust_account_id = p_sold_to_org_id
592 AND status = 'A'
593 and h.org_id = ratrx.org_id
594 AND bill_to_flag = 'Y')
595
596 AND ratrx.customer_trx_id = l_commitment_id;*/
597 --bug 4729536
598 OPEN cur_customer_relations(l_commitment_id);
599 Fetch cur_customer_relations into l_exists;
600 Close cur_customer_relations;
601 --bug 4729536
602
603
604 EXCEPTION WHEN NO_DATA_FOUND THEN
605 null;
606 END;
607
608 oe_debug_pub.add('OEXLHDRB: l_exists in validate_commitment_customer is: '||l_exists, 3);
609
610 IF l_exists = 'N' THEN
611 x_return_status := FND_API.G_RET_STS_ERROR;
612 EXIT;
613 END IF;
614 END IF;
615
616 END LOOP;
617 CLOSE l_line_csr;
618
619 oe_debug_pub.add('Exiting OE_VALIDATE_HEADER.Validate_Commitment_Customer',1);
620
621 EXCEPTION
622 WHEN NO_DATA_FOUND THEN
623 FND_MESSAGE.SET_NAME('ONT','OE_FLOW_CNT_CHANGE');
624 OE_MSG_PUB.ADD;
625 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
626
627 WHEN OTHERS THEN
628 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
629 THEN
630 OE_MSG_PUB.Add_Exc_Msg
631 ( G_PKG_NAME ,
632 'Validate_Commitment_Customer'
633 );
634 END IF;
635 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
636 END Validate_Commitment_Customer;
637
638 ---------------------------------------------------------------
639 -- FUNCTION Is_Duplicate_PO_Number
640 -- Added to fix bug 1162304
641 -- Returns TRUE if the PO number is referenced on another order
642 -- for the same customer
643 ---------------------------------------------------------------
644
645 FUNCTION Is_Duplicate_PO_Number
646 ( p_cust_po_number IN VARCHAR2
647 , p_sold_to_org_id IN NUMBER
648 , p_header_id IN NUMBER
649 ) RETURN BOOLEAN
650 IS
651 l_duplicate_exists varchar2(1);
652 l_check_duplicate varchar2(1) :='Y'; --Added for 5053933
653 BEGIN
654 --Added for 5053933 start
655 l_check_duplicate :=nvl(FND_PROFILE.VALUE('ONT_ENFORCE_DUP_PO'),'Y');
656 if l_check_duplicate='Y' then
657 --Added for ER 4760436 end
658
659 -- commented for bug#9852199
660 -- SELECT /* MOAC_SQL_NO_CHANGE */ 'Y'
661 /* INTO l_duplicate_exists
662 FROM DUAL
663 WHERE EXISTS (SELECT 'Y'
664 FROM OE_ORDER_HEADERS
665 WHERE HEADER_ID <> p_header_id
666 AND SOLD_TO_ORG_ID = p_sold_to_org_id
667 AND CUST_PO_NUMBER = p_cust_po_number )
668 OR EXISTS (SELECT 'Y'
669 FROM OE_ORDER_LINES
670 WHERE HEADER_ID <> p_header_id
671 AND SOLD_TO_ORG_ID = p_sold_to_org_id
672 AND CUST_PO_NUMBER = p_cust_po_number ); */
673
674
675
676 -- Added for Bug 9852199
677 BEGIN
678 SELECT 'Y'
679 INTO l_duplicate_exists
680 FROM DUAL
681 WHERE EXISTS (SELECT 'Y'
682 FROM OE_ORDER_HEADERS
683 WHERE HEADER_ID <> p_header_id
684 AND SOLD_TO_ORG_ID = p_sold_to_org_id
685 AND CUST_PO_NUMBER = p_cust_po_number );
686 EXCEPTION
687 WHEN NO_DATA_FOUND THEN
688 l_duplicate_exists := 'N';
689 END;
690
691 IF l_duplicate_exists <> 'Y' THEN
692 SELECT 'Y'
693 INTO l_duplicate_exists
694 FROM DUAL
695 WHERE EXISTS (SELECT 'Y'
696 FROM OE_ORDER_LINES
697 WHERE HEADER_ID <> p_header_id
698 AND SOLD_TO_ORG_ID = p_sold_to_org_id
699 AND CUST_PO_NUMBER = p_cust_po_number );
700 END IF;
701
702 else
703 RETURN FALSE;
704 end if ; --l_check_duplicate
705 RETURN TRUE;
706
707 EXCEPTION
708 WHEN NO_DATA_FOUND THEN
709 RETURN FALSE;
710
711 END Is_Duplicate_PO_Number;
712
713 ----------------------------------------------------------------------------
714 -- Procedure Validate_Blanket_Values
715 ----------------------------------------------------------------------------
716
717 Procedure Validate_Blanket_Values
718 ( p_header_rec IN OE_Order_PUB.Header_Rec_Type,
719 p_old_header_rec IN OE_Order_PUB.Header_Rec_Type,
720 x_return_status OUT NOCOPY VARCHAR2
721 )
722
723 IS
724 l_sold_to_org_id NUMBER;
725 l_agreement_id NUMBER;
726 l_on_hold_flag VARCHAR2(1);
727 l_start_date_active DATE;
728 l_end_date_active DATE;
729 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
730 --FOR BUG 3192386
731 l_flow_status_code VARCHAR2(30);
732 -- Bug 3232544
733 lcustomer_relations varchar2(1) :=
734 OE_Sys_Parameters.VALUE('CUSTOMER_RELATIONSHIPS_FLAG');
735 l_exists varchar2(1);
736 --For Bug 3257240
737 l_customer_name VARCHAR2(240);
738 l_customer_number NUMBER;
739 BEGIN
740 if l_debug_level > 0 then
741 OE_DEBUG_PUB.Add('Entering OE_VALIDATE_HEADER.Validate_Blanket_Values',1);
742 OE_DEBUG_PUB.Add('Blanket Number :'||p_header_rec.blanket_number,1);
743 end if;
744
745 IF p_header_rec.blanket_number IS NULL THEN
746 FND_MESSAGE.SET_NAME('ONT', 'OE_BLKT_NO_BLANKET_LINE_NUM');
747 OE_MSG_PUB.Add;
748 x_return_status := FND_API.G_RET_STS_ERROR;
749 RETURN;
750 END IF;
751
752 BEGIN
753 --Altered the sql for bug 3192386. Blankets in Negotiation or with Draft submitted as 'N' will not be selected.
754 SELECT BH.AGREEMENT_ID,
755 BH.SOLD_TO_ORG_ID,
756 BHE.on_hold_flag,
757 BHE.START_DATE_ACTIVE,
758 BHE.END_DATE_ACTIVE,
759 NVL(BH.FLOW_STATUS_CODE,'ACTIVE')
760 INTO l_agreement_id,
761 l_sold_to_org_id,
762 l_on_hold_flag,
763 l_start_date_active,
764 l_end_date_active,
765 l_flow_status_code
766 FROM OE_BLANKET_HEADERS BH,OE_BLANKET_HEADERS_EXT BHE
767 WHERE BH.ORDER_NUMBER = p_header_rec.blanket_number
768 AND BH.ORDER_NUMBER = BHE.ORDER_NUMBER
769 AND BH.SALES_DOCUMENT_TYPE_CODE = 'B'
770 AND NVL(BH.TRANSACTION_PHASE_CODE,'F')='F'
771 AND NVL(BH.DRAFT_SUBMITTED_FLAG,'Y') = 'Y';
772
773 EXCEPTION
774
775 WHEN NO_DATA_FOUND THEN
776 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ATTRIBUTE');
777 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
778 OE_Order_Util.Get_Attribute_Name('BLANKET_NUMBER'));
779 OE_MSG_PUB.Add;
780 if l_debug_level > 0 then
781 OE_DEBUG_PUB.Add('No Data Found when Validating Blanket',3);
782 end if;
783 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
784 WHEN OTHERS THEN
785 if l_debug_level > 0 then
786 OE_DEBUG_PUB.Add('When Others when Validating Blanket',3);
787 end if;
788 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
789 END;
790
791 IF ( p_header_rec.sold_to_org_id <> l_sold_to_org_id) AND
792 (NOT OE_GLOBALS.EQUAL(p_header_rec.sold_to_org_id
793 ,p_old_header_rec.sold_to_org_id) OR
794 NOT OE_GLOBALS.EQUAL(p_header_rec.blanket_number
795 ,p_old_header_rec.blanket_number) ) THEN
796 If l_debug_level > 0 then
797 oe_debug_pub.add('Customer on release does not match blanket customer');
798 End if;
799 if lcustomer_relations = 'Y' then
800 begin
801 SELECT 'Y'
802 INTO l_exists
803 FROM HZ_CUST_ACCT_RELATE
804 WHERE RELATED_CUST_ACCOUNT_ID = p_header_rec.sold_to_org_id
805 AND CUST_ACCOUNT_ID = l_sold_to_org_id
806 AND STATUS = 'A'
807 AND ROWNUM = 1;
808 exception
809 when no_data_found then
810 FND_MESSAGE.SET_NAME('ONT','OE_BLKT_INVALID_ATTRIBUTE');
811 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_Util.Get_Attribute_Name
812 ('SOLD_TO_ORG_ID'));
813 --for bug 3257240
814 OE_Id_To_Value.Sold_To_Org
815 ( p_sold_to_org_id => l_sold_to_org_id
816 , x_org => l_customer_name
817 , x_customer_number => l_customer_number
818 );
819 FND_MESSAGE.SET_TOKEN('BLANKET_VALUE',l_customer_name);
820 OE_MSG_PUB.Add;
821 x_return_status := FND_API.G_RET_STS_ERROR;
822 end;
823 else
824 FND_MESSAGE.SET_NAME('ONT','OE_BLKT_INVALID_ATTRIBUTE');
825 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_Util.Get_Attribute_Name
826 ('SOLD_TO_ORG_ID'));
827 --for bug 3257240
828 OE_Id_To_Value.Sold_To_Org
829 ( p_sold_to_org_id => l_sold_to_org_id
830 , x_org => l_customer_name
831 , x_customer_number => l_customer_number
832 );
833 FND_MESSAGE.SET_TOKEN('BLANKET_VALUE',l_customer_name);
834 OE_MSG_PUB.Add;
835 x_return_status := FND_API.G_RET_STS_ERROR;
836 end if;
837 END IF;
838
839 IF (p_header_rec.order_category_code = 'ORDER') AND ( l_on_hold_flag <> 'N') AND
840 (NOT OE_GLOBALS.EQUAL(p_header_rec.blanket_number
841 ,p_old_header_rec.blanket_number) ) THEN
842 if l_debug_level > 0 then
843 OE_DEBUG_PUB.Add('Blanket order is currently on hold', 1);
844 end if;
845 FND_MESSAGE.SET_NAME('ONT', 'OE_BLKT_ON_HOLD');
846 OE_MSG_PUB.Add;
847 x_return_status := FND_API.G_RET_STS_ERROR;
848 END IF;
849
850 IF p_header_rec.order_category_code = 'ORDER' AND
851 (NOT OE_GLOBALS.EQUAL(p_header_rec.request_date
852 ,p_old_header_rec.request_date) OR
853 NOT OE_GLOBALS.EQUAL(p_header_rec.blanket_number
854 ,p_old_header_rec.blanket_number)) AND
855 NOT (trunc(nvl(p_header_rec.request_date,sysdate))
856 BETWEEN trunc(l_start_date_active)
857 AND trunc(nvl(l_end_date_active, nvl(p_header_rec.request_date,sysdate)))) THEN
858 if l_debug_level > 0 then
859 oe_debug_pub.add('Request date is not within active blanket dates', 1);
860 end if;
861 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ATTRIBUTE');
862 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
863 OE_Order_Util.Get_Attribute_Name('BLANKET_NUMBER'));
864 OE_MSG_PUB.Add;
865 x_return_status := FND_API.G_RET_STS_ERROR;
866 END IF;
867
868 --For Bug 3192386
869 IF p_header_rec.order_category_code = 'ORDER' AND
870 l_flow_status_code <> 'ACTIVE'
871 THEN
872 if l_debug_level > 0 then
873 oe_debug_pub.add('Not an active Blanket for Release', 1);
874 end if;
875 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ATTRIBUTE');
876 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
877 OE_Order_Util.Get_Attribute_Name('BLANKET_NUMBER'));
878 OE_MSG_PUB.Add;
879 x_return_status := FND_API.G_RET_STS_ERROR;
880 END IF;
881
882 IF p_header_rec.agreement_id IS NOT NULL THEN
883 FND_MESSAGE.SET_NAME('ONT', 'OE_BLKT_AGREEMENT_EXISTS');
884 OE_MSG_PUB.Add;
885 x_return_status := FND_API.G_RET_STS_ERROR;
886 END IF;
887 if l_debug_level > 0 then
888 OE_DEBUG_PUB.Add('Exiting OE_VALIDATE_HEADER.Validate_Blanket_Values',1);
889 end if;
890 EXCEPTION
891
892 WHEN FND_API.G_EXC_ERROR THEN
893 if l_debug_level > 0 then
894 OE_DEBUG_PUB.Add('Expected Error in Validate Blanket Values',2);
895 End if;
896
897 x_return_status := FND_API.G_RET_STS_ERROR;
898
899 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
900 if l_debug_level > 0 then
901 OE_DEBUG_PUB.Add('Unexpected Error in Validate Blanket Values:'||SqlErrm, 1);
902 End if;
903 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
904
905
906 WHEN OTHERS THEN
907
908 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
909
910 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
911 THEN
912 OE_MSG_PUB.Add_Exc_Msg
913 ( 'OE_VALIDATE_LINE',
914 'Validate_Blanket_Values');
915 END IF;
916
917 End Validate_Blanket_Values;
918
919
920 /*-------------------------------------------------------
921 PROCEDURE: Entity
922 Description:
923 --------------------------------------------------------*/
924
925 PROCEDURE Entity
926 ( x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
927 , p_header_rec IN OUT NOCOPY /* file.sql.39 change */ OE_Order_PUB.Header_Rec_Type
928 /* modified the above line to fix the bug 2824240 */
929 , p_old_header_rec IN OE_Order_PUB.Header_Rec_Type :=
930 OE_Order_PUB.G_MISS_HEADER_REC
931 , p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL
932 /* added the above line to fix the bug 2824240 */
933 )
934 IS
935 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
936 l_dummy VARCHAR2(10);
937 l_price_list_rec OE_Order_Cache.Price_List_Rec_Type;
938 -- l_order_type_rec OE_Order_Cache.Order_Type_Rec_Type;
939 -- L_agreement_rec OE_Order_Cache.Agreement_Rec_Type;
940
941 l_agreement_name varchar2(240);
942 l_agreement_revision varchar2(50);
943 l_sold_to_org number;
944 l_price_list_id number;
945 lcustomer_relations varchar2(1);
946 l_list_type_code VARCHAR2(30);
947 --MC Bgn
948 l_validate_result Varchar2(1):='N';
949 --MC End
950 L_COMMITMENT_CURR_CODE VARCHAR2(15);
951 l_creation_status VARCHAR2(30);
952 l_receipt_method_id NUMBER;
953 l_cc_only BOOLEAN := TRUE ;
954 l_customer_name VARCHAR2(360);
955 l_temp pls_integer;
956 l_comt_cust_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
957 l_comt_curr_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
958 l_blanket_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
959
960 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
961 l_control_rec OE_GLOBALS.Control_Rec_Type;
962 l_header_rec OE_Order_PUB.Header_Rec_Type := p_header_rec;
963 l_old_header_rec OE_Order_PUB.Header_Rec_Type := p_old_header_rec;
964 /* Added the above 3 line to fix the bug 2824240 */
965
966 -- eBTax Changes
967 l_ship_to_cust_Acct_id hz_cust_Accounts.cust_Account_id%type;
968 l_ship_to_party_id hz_cust_accounts.party_id%type;
969 l_ship_to_party_site_id hz_party_sites.party_site_id%type;
970 l_bill_to_cust_Acct_id hz_cust_Accounts.cust_Account_id%type;
971 l_bill_to_party_id hz_cust_accounts.party_id%type;
972 l_bill_to_party_site_id hz_party_sites.party_site_id%type;
973 l_org_id NUMBER;
974
975 cursor partyinfo(p_site_org_id HZ_CUST_SITE_USES_ALL.SITE_USE_ID%type) is
976 SELECT cust_acct.cust_account_id,
977 cust_Acct.party_id,
978 acct_site.party_site_id,
979 site_use.org_id
980 FROM
981 HZ_CUST_SITE_USES_ALL site_use,
982 HZ_CUST_ACCT_SITES_ALL acct_site,
983 HZ_CUST_ACCOUNTS_ALL cust_Acct
984 WHERE site_use.site_use_id = p_site_org_id
985 AND site_use.cust_acct_site_id = acct_site.cust_acct_site_id
986 and acct_site.cust_account_id = cust_acct.cust_account_id;
987
988 l_payment_count number;
989
990 -- required for IN line level validation, a corner case
991 CURSOR ib_lines IS
992 SELECT l.line_id,
993 l.ib_current_location,
994 l.ib_installed_at_location
995 FROM oe_order_lines_all l
996 WHERE l.header_id=p_old_header_rec.header_id;
997 --added for bug 3739650
998 l_site_use_code VARCHAR2(30);
999 BEGIN
1000 oe_debug_pub.add('Enter OE_VALIDATE_HEADER.ENTITY',1);
1001
1002 -- Check required attributes.
1003 --lcustomer_relations := FND_PROFILE.VALUE('ONT_CUSTOMER_RELATIONSHIPS');
1004 lcustomer_relations := OE_Sys_Parameters.VALUE('CUSTOMER_RELATIONSHIPS_FLAG');
1005
1006 IF p_header_rec.header_id IS NULL
1007 THEN
1008 l_return_status := FND_API.G_RET_STS_ERROR;
1009
1010 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
1011 THEN
1012 fnd_message.set_name('ONT','OE_ATTRIBUTE_REQUIRED');
1013 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
1014 OE_Order_UTIL.Get_Attribute_Name('HEADER_ID'));
1015 OE_MSG_PUB.Add;
1016 END IF;
1017
1018 END IF;
1019
1020 -- QUOTING changes
1021 IF oe_code_control.code_release_level >= '110510'
1022 AND p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
1023 AND p_header_rec.transaction_phase_code IS NULL
1024 THEN
1025 l_return_status := FND_API.G_RET_STS_ERROR;
1026
1027 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
1028 THEN
1029 fnd_message.set_name('ONT','OE_ATTRIBUTE_REQUIRED');
1030 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
1031 OE_Order_UTIL.Get_Attribute_Name('TRANSACTION_PHASE_CODE'));
1032 OE_MSG_PUB.Add;
1033 END IF;
1034
1035 END IF;
1036
1037
1038 ----------------------------------------------------------
1039 -- Check rest of required attributes here.
1040 ----------------------------------------------------------
1041
1042 IF p_header_rec.order_type_id IS NULL
1043 THEN
1044 l_return_status := FND_API.G_RET_STS_ERROR;
1045
1046 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_ERROR)
1047 THEN
1048 fnd_message.set_name('ONT','OE_ATTRIBUTE_REQUIRED');
1049 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
1050 OE_Order_UTIL.Get_Attribute_Name('ORDER_TYPE_ID'));
1051 OE_MSG_PUB.Add;
1052 END IF;
1053 ELSE
1054 Validate_Order_Type
1055 (p_order_type_id => p_header_rec.order_type_id,
1056 p_old_order_type_id => p_old_header_rec.order_type_id,
1057 p_header_id => p_header_rec.header_id,
1058 p_operation => p_header_rec.operation);
1059 END IF;
1060
1061
1062 IF p_header_rec.transactional_curr_code IS NULL
1063 THEN
1064 l_return_status := FND_API.G_RET_STS_ERROR;
1065
1066 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_ERROR)
1067 THEN
1068 fnd_message.set_name('ONT','OE_ATTRIBUTE_REQUIRED');
1069 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
1070 OE_Order_UTIL.Get_Attribute_Name('TRANSACTIONAL_CURR_CODE'));
1071 OE_MSG_PUB.Add;
1072 END IF;
1073
1074 END IF;
1075
1076
1077 -- Return Error IF a required attribute is missing.
1078 IF l_return_status = FND_API.G_RET_STS_ERROR
1079 THEN
1080 if l_debug_level > 0 then
1081 oe_debug_pub.add('reqd attribute missing');
1082 end if;
1083 RAISE FND_API.G_EXC_ERROR;
1084 END IF;
1085
1086 ----------------------------------------------------------
1087 -- Check conditionally required attributes here.
1088 ----------------------------------------------------------
1089
1090 -- QUOTING changes
1091 IF oe_code_control.code_release_level >= '110510' THEN
1092
1093 Check_Negotiation_Attributes(p_header_rec
1094 ,p_old_header_rec
1095 ,l_return_status
1096 );
1097
1098 ELSE
1099
1100 -- Feature not supported prior to 11i10, raise error
1101 IF p_header_rec.transaction_phase_code = 'N' THEN
1102 FND_MESSAGE.SET_NAME('ONT','OE_QUOTE_INVALID_RELEASE');
1103 OE_MSG_PUB.ADD;
1104 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1105 END IF;
1106
1107 END IF;
1108 -- QUOTING changes END
1109
1110
1111 -- Check attributes required for booked header
1112 IF p_header_rec.booked_flag = 'Y' THEN
1113
1114 Check_Book_Reqd_Attributes
1115 ( p_header_rec => p_header_rec
1116 , x_return_status => l_return_status
1117 );
1118
1119 END IF;
1120
1121
1122
1123
1124 --bug6441512
1125 IF p_header_rec.tax_exempt_flag ='S' THEN
1126
1127 -- Check for Tax exempt number/Tax exempt reason.
1128
1129 IF (p_header_rec.tax_exempt_number IS NOT NULL AND
1130 p_header_rec.tax_exempt_number <> FND_API.G_MISS_CHAR)
1131 OR
1132 (p_header_rec.tax_exempt_reason_code IS NOT NULL AND
1133 p_header_rec.tax_exempt_reason_code <> FND_API.G_MISS_CHAR) THEN
1134 l_return_status := FND_API.G_RET_STS_ERROR;
1135
1136 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_ERROR)
1137 THEN
1138 fnd_message.set_name('ONT','OE_NO_TAX_EXEMPTION');
1139 OE_MSG_PUB.Add;
1140 END IF;
1141 END IF;
1142
1143 END IF;
1144
1145
1146 --bug6441512
1147 IF p_header_rec.tax_exempt_flag = 'E' THEN
1148
1149 --bug6732513
1150 /* IF p_header_rec.tax_exempt_number IS NULL OR
1151 p_header_rec.tax_exempt_number = FND_API.G_MISS_CHAR
1152 THEN
1153
1154 l_return_status := FND_API.G_RET_STS_ERROR;
1155
1156 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_ERROR)
1157 THEN
1158 fnd_message.set_name('ONT','OE_TAX_EXEMPTION_REQUIRED');
1159 OE_MSG_PUB.Add;
1160 END IF;
1161
1162 END IF; */
1163
1164
1165
1166 IF p_header_rec.tax_exempt_reason_code IS NULL OR
1167 p_header_rec.tax_exempt_reason_code = FND_API.G_MISS_CHAR
1168 THEN
1169 l_return_status := FND_API.G_RET_STS_ERROR;
1170
1171 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_ERROR)
1172 THEN
1173 fnd_message.set_name('ONT','OE_ATTRIBUTE_REQUIRED');
1174 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
1175 OE_Order_UTIL.Get_Attribute_Name('TAX_EXEMPT_REASON_CODE'));
1176 OE_MSG_PUB.Add;
1177 END IF;
1178
1179 END IF;
1180
1181 END IF; -- IF Tax handling is exempt
1182
1183
1184 --bug6441512
1185 IF p_header_rec.tax_exempt_flag ='R' THEN
1186
1187 IF (p_header_rec.tax_exempt_number IS NOT NULL AND
1188 p_header_rec.tax_exempt_number <> FND_API.G_MISS_CHAR)
1189 OR
1190 (p_header_rec.tax_exempt_reason_code IS NOT NULL AND
1191 p_header_rec.tax_exempt_reason_code <> FND_API.G_MISS_CHAR)
1192 THEN
1193 l_return_status := FND_API.G_RET_STS_ERROR;
1194
1195 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_ERROR)
1196 THEN
1197 fnd_message.set_name('ONT','OE_TAX_EXEMPTION_NOT_ALLOWED');
1198 OE_MSG_PUB.Add;
1199 END IF;
1200 END IF;
1201
1202 END IF;
1203
1204 -- Return Error IF a conditionally required attribute is missing.
1205
1206 IF l_return_status = FND_API.G_RET_STS_ERROR
1207 THEN
1208 RAISE FND_API.G_EXC_ERROR;
1209 END IF;
1210
1211 --BUG#9366518
1212 oe_debug_pub.add('Checking for Payment Type and its Related Required Attributes');
1213 oe_debug_pub.add('PAYMENT_TYPE_CODE = '|| p_header_rec.PAYMENT_TYPE_CODE);
1214 oe_debug_pub.add('CREDIT_CARD_CODE = '|| p_header_rec.CREDIT_CARD_CODE);
1215 oe_debug_pub.add('CREDIT_CARD_NUMBER = '|| p_header_rec.CREDIT_CARD_NUMBER);
1216 oe_debug_pub.add('CREDIT_CARD_HOLDER_NAME = '|| p_header_rec.CREDIT_CARD_HOLDER_NAME);
1217 oe_debug_pub.add('CREDIT_CARD_EXPIRATION_DATE = '|| p_header_rec.CREDIT_CARD_EXPIRATION_DATE);
1218 oe_debug_pub.add('CHECK_NUMBER = '|| p_header_rec.CHECK_NUMBER);
1219
1220 IF p_header_rec.PAYMENT_TYPE_CODE = 'CHECK' THEN
1221 IF p_header_rec.CHECK_NUMBER IS NULL
1222 THEN
1223 l_return_status := FND_API.G_RET_STS_ERROR;
1224
1225 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_ERROR)
1226 THEN
1227 fnd_message.set_name('ONT','OE_ATTRIBUTE_REQUIRED');
1228 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_Attribute_Name('CHECK_NUMBER'));
1229 OE_MSG_PUB.Add;
1230 END IF;
1231 END IF;
1232 END IF;
1233
1234 IF p_header_rec.PAYMENT_TYPE_CODE = 'CREDIT_CARD' THEN
1235 IF (p_header_rec.CREDIT_CARD_NUMBER IS NULL) or (p_header_rec.CREDIT_CARD_HOLDER_NAME IS NULL)
1236 --or (p_header_rec.CREDIT_CARD_EXPIRATION_DATE IS NULL) --commented for BUG#9436914
1237 THEN
1238 l_return_status := FND_API.G_RET_STS_ERROR;
1239 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_ERROR)
1240 THEN
1241 fnd_message.set_name('ONT','OE_VAL_CREDIT_CARD_REQD');
1242 --FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_Attribute_Name('CREDIT_CARD_CODE'));
1243 OE_MSG_PUB.Add;
1244 END IF;
1245 END IF;
1246 END IF;
1247 --BUG#9366518
1248
1249 ----------------------------------------------------------------
1250 -- VALIDATE ATTRIBUTE DEPENDENCIES
1251 ----------------------------------------------------------------
1252
1253 oe_debug_pub.add('old price ' || p_old_header_rec.price_list_id,2);
1254 oe_debug_pub.add('New price ' || p_header_rec.price_list_id,2);
1255 oe_debug_pub.add('old curr ' || p_old_header_rec.transactional_curr_code,2);
1256 oe_debug_pub.add('New curr ' || p_header_rec.transactional_curr_code,2);
1257 -- Validate currency
1258
1259 l_price_list_rec :=OE_Order_Cache.Load_Price_List (p_header_rec.price_list_id );
1260
1261 --Added OR condition for CREATE Operation for bug 5060064
1262
1263 IF (p_header_rec.price_list_id <>
1264 Nvl(p_old_header_rec.price_list_id,FND_API.G_MISS_NUM) OR
1265 p_header_rec.transactional_curr_code <>
1266 p_old_header_rec.transactional_curr_code OR
1267 p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) AND
1268 p_header_rec.price_list_id IS NOT NULL
1269 THEN
1270 Begin
1271 QP_UTIL_PUB.Validate_Price_list_Curr_code(p_header_rec.price_list_id,
1272 p_header_rec.transactional_curr_code,
1273 p_header_rec.pricing_date,
1274 l_validate_result);
1275 Exception when others then
1276 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1277 THEN
1278
1279 OE_MSG_PUB.Add_Exc_Msg
1280 ( G_PKG_NAME ,
1281 'OE_VALIDATE_HEADER-QP_UTIL_PUB'
1282 );
1283 END IF;
1284 Oe_Debug_Pub.Add('Error when calling QP_UTIL_PUB.Validate_Price_list_Curr_code:'||SQLERRM);
1285 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1286
1287 End;
1288
1289 Oe_Debug_Pub.add(' M Currency:'||l_validate_result);
1290 IF l_validate_result = 'N' THEN
1291 Begin
1292 Select 1
1293 into l_temp
1294 From Oe_Order_Lines_All
1295 Where header_id = p_header_rec.header_id
1296 and calculate_price_flag in ('P','N')
1297 and rownum = 1;
1298
1299 Exception when no_data_found then
1300 --retro{
1301 /* Added the following if condition to fix the bug 2824240 */
1302 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
1303 p_header_rec.operation = 'CREATE'
1304 THEN
1305 IF(p_header_rec.order_source_id=27) THEN
1306 p_header_rec.price_list_id := OE_RETROBILL_PVT.Get_First_Line_Price_List_Id;
1307 ELSE
1308 p_header_rec.price_list_id := NULL;
1309 END IF;
1310 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
1311 p_header_rec.operation = 'CREATE'
1312 THEN
1313 IF(p_header_rec.order_source_id=27) THEN
1314 p_header_rec.price_list_id := OE_RETROBILL_PVT.Get_First_Line_Price_List_Id;
1315 ELSE
1316 p_header_rec.price_list_id := FND_API.G_MISS_NUM;
1317 END IF;
1318 --retro}
1319 l_header_rec := p_header_rec;
1320 l_old_header_rec := p_old_header_rec;
1321 l_control_rec.controlled_operation := TRUE;
1322 l_control_rec.write_to_DB := FALSE ;
1323 l_control_rec.process := FALSE ;
1324 Oe_Order_Pvt.Header
1325 ( p_validation_level => FND_API.G_VALID_LEVEL_NONE
1326 , p_control_rec =>l_control_rec
1327 , p_x_header_rec =>l_header_rec
1328 , p_x_old_header_rec =>l_old_header_rec
1329 , x_return_status =>l_return_status
1330 );
1331 p_header_rec := l_header_rec;
1332 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1333 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1334 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1335 RAISE FND_API.G_EXC_ERROR;
1336 END IF;
1337
1338 /* End of code added to fix the bug 2824240 */
1339
1340 ELSE
1341 --no frozen lines, error condition
1342 l_return_status := FND_API.G_RET_STS_ERROR;
1343 fnd_message.set_name('ONT','OE_VAL_ORD_CURRENCY_MISMATCH');
1344 FND_MESSAGE.SET_TOKEN('ORDER_CURRENCY',p_header_rec.transactional_curr_code);
1345 FND_MESSAGE.SET_TOKEN('PRICE_LIST_CURRENCY',l_price_list_rec.currency_code);
1346 OE_MSG_PUB.Add;
1347 END IF;
1348 End;
1349 END IF;
1350 END IF; -- Price list or currency changed.
1351
1352 -- bug 1618229, if the currency changed, also needs to revalidate commitment
1353 -- on the order line.
1354 IF NOT OE_GLOBALS.EQUAL(p_header_rec.transactional_curr_code,
1355 p_old_header_rec.transactional_curr_code) THEN
1356
1357 oe_debug_pub.add('OEXLHDRB: before validating currency for commitment.', 3);
1358 Validate_Commitment_Currency
1359 (p_header_id => p_header_rec.header_id
1360 ,p_transactional_curr_code => p_header_rec.transactional_curr_code
1361 ,x_return_status => l_comt_curr_status);
1362
1363 IF l_comt_curr_status = FND_API.G_RET_STS_ERROR THEN
1364 l_return_status := FND_API.G_RET_STS_ERROR;
1365 Fnd_Message.Set_Name('ONT','ONT_INVALID_CURR_CHANGE');
1366 Fnd_message.set_token('REASON','ONT_COMMITMENT_ON_LINE',TRUE);
1367 OE_MSG_PUB.Add;
1368 oe_debug_pub.add('Error: currency code does not match the currency for the commitment.', 3);
1369 RAISE FND_API.G_EXC_ERROR;
1370 END IF;
1371 END IF;
1372
1373 -- Currency_date, currency_rate should be null when type is null.
1374
1375 IF p_header_rec.Conversion_type_code IS NULL
1376 THEN
1377 IF Nvl(p_header_rec.conversion_rate, FND_API.G_MISS_NUM)
1378 <> FND_API.G_MISS_NUM OR
1379 Nvl(p_header_rec.conversion_rate_date, FND_API.G_MISS_DATE)
1380 <> FND_API.G_MISS_DATE
1381 THEN
1382 l_return_status := FND_API.G_RET_STS_ERROR;
1383 fnd_message.set_name('ONT','OE_VAL_CONVERSION_TYPE');
1384 OE_MSG_PUB.Add;
1385 END IF;
1386
1387 END IF;
1388
1389 --bug 3220059 for other conversion types, conversion rate should be NULL, not conversion rate date
1390 IF p_header_rec.conversion_type_code <> 'User' AND
1391 p_header_rec.conversion_rate IS NOT NULL
1392 THEN
1393 l_return_status := FND_API.G_RET_STS_ERROR;
1394 FND_MESSAGE.SET_NAME('ONT','OE_VALIDATION_CONV_TYPE');
1395 OE_MSG_PUB.ADD;
1396
1397 END IF; -- END of checks based on conversion type
1398
1399
1400 -- Order Type has to be valid on the date ordered.
1401 IF (p_header_rec.order_type_id <>
1402 NVL(p_old_header_rec.order_type_id,FND_API.G_MISS_NUM)) OR
1403 (p_header_rec.ordered_date <>
1404 NVL(p_old_header_rec.ordered_date,FND_API.G_MISS_DATE))
1405 THEN
1406
1407 IF p_header_rec.ordered_date IS NOT NULL THEN
1408
1409 BEGIN
1410 -- Bug 3942415
1411 SELECT 'VALID'
1412 INTO l_dummy
1413 FROM OE_ORDER_TYPES_V
1414 WHERE ORDER_TYPE_ID = p_header_rec.order_type_id
1415 AND TRUNC(p_header_rec.ordered_date)
1416 BETWEEN NVL(START_DATE_ACTIVE,TRUNC(p_header_rec.ordered_date))
1417 AND NVL( END_DATE_ACTIVE,TRUNC(p_header_rec.ordered_date));
1418 -- Valid Order Type.
1419
1420 EXCEPTION
1421 WHEN NO_DATA_FOUND THEN
1422 l_return_status := FND_API.G_RET_STS_ERROR;
1423 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
1424 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
1425 OE_Order_Util.Get_Attribute_Name('ORDER_TYPE_ID'));
1426 OE_MSG_PUB.Add;
1427
1428 WHEN OTHERS THEN
1429
1430 IF OE_MSG_PUB.Check_Msg_Level
1431 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1432 THEN
1433
1434 OE_MSG_PUB.Add_Exc_Msg
1435 ( G_PKG_NAME ,
1436 'Record - Order Type'
1437 );
1438 END IF;
1439
1440 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1441 END;
1442
1443 END IF; -- date ordered is not null.
1444
1445 END IF; -- Order Type or date has changed.
1446
1447
1448 -- Agreement depends on Order Type AND Sold To Org
1449 -- Added OR condition for CREATE Operation. Bug 5060064
1450
1451 IF (NOT OE_GLOBALS.EQUAL(p_header_rec.order_type_id
1452 ,p_old_header_rec.order_type_id)) OR
1453 (NOT OE_GLOBALS.EQUAL(p_header_rec.agreement_id
1454 ,p_old_header_rec.agreement_id)) OR
1455 (NOT OE_GLOBALS.EQUAL(p_header_rec.sold_to_org_id
1456 ,p_old_header_rec.sold_to_org_id)) OR
1457 (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE)
1458 THEN
1459
1460 IF p_header_rec.agreement_id IS NOT NULL THEN
1461 -- commented by Geresh
1462 -- l_agreement_rec :=
1463 -- OE_Order_Cache.Load_Agreement (p_header_rec.agreement_id);
1464
1465 BEGIN
1466 BEGIN
1467 select list_type_code
1468 into l_list_type_code
1469 from qp_list_headers_vl
1470 where list_header_id = p_header_rec.price_list_id;
1471 EXCEPTION WHEN NO_DATA_FOUND THEN
1472 null;
1473 END;
1474
1475 /* Added the following code to fix the bug 2124912 */
1476
1477 BEGIN
1478 --bug 5206956 added sold_to_org_id in the next 2 selects
1479 select name,revision, sold_to_org_id
1480 into l_agreement_name,l_agreement_revision, l_sold_to_org
1481 from oe_agreements_vl
1482 where agreement_id = p_header_rec.agreement_id;
1483
1484 select name,revision, sold_to_org_id
1485 into l_agreement_name,l_agreement_revision, l_sold_to_org
1486 from oe_agreements_vl
1487 where agreement_id = p_header_rec.agreement_id
1488 AND trunc(nvl(p_header_rec.pricing_date,sysdate)) between
1489 trunc(nvl(START_DATE_ACTIVE,add_months(sysdate,-10000)))
1490 AND trunc(nvl(END_DATE_ACTIVE,add_months(sysdate,+10000)));
1491
1492 EXCEPTION
1493 WHEN NO_DATA_FOUND THEN
1494 /* Added the following if condition to fix the bug 2824240 */
1495 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
1496 p_header_rec.operation = 'CREATE'
1497 THEN
1498 p_header_rec.agreement_id := NULL;
1499 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
1500 p_header_rec.operation = 'CREATE'
1501 THEN
1502 p_header_rec.agreement_id := FND_API.G_MISS_NUM;
1503 l_header_rec := p_header_rec;
1504 l_old_header_rec := p_old_header_rec;
1505 l_control_rec.controlled_operation := TRUE;
1506 l_control_rec.write_to_DB := FALSE ;
1507 l_control_rec.process := FALSE ;
1508 Oe_Order_Pvt.Header
1509 ( p_validation_level => FND_API.G_VALID_LEVEL_NONE
1510 , p_control_rec =>l_control_rec
1511 , p_x_header_rec =>l_header_rec
1512 , p_x_old_header_rec =>l_old_header_rec
1513 , x_return_status =>l_return_status
1514 );
1515 p_header_rec := l_header_rec;
1516 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1517 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1518 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1519 RAISE FND_API.G_EXC_ERROR;
1520 END IF;
1521
1522 /* End of code added to fix the bug 2824240 */
1523 ELSE
1524 fnd_message.set_name('ONT', 'ONT_INVALID_AGREEMENT');
1525 fnd_message.set_Token('AGREEMENT_NAME',l_agreement_name);
1526 fnd_message.set_Token('REVISION',l_agreement_revision);
1527 OE_MSG_PUB.Add;
1528 oe_debug_pub.add('Invalid Agreement ',1);
1529 raise FND_API.G_EXC_ERROR;
1530 END IF;
1531 END;
1532
1533 /* End of code added to fix the bug 2124912 */
1534
1535 IF NOT OE_GLOBALS.EQUAL(l_list_type_code,'PRL') THEN
1536 -- any price list with 'PRL' type should be allowed to
1537 -- be associated with any agreement according to bug 1386406.
1538
1539 select name ,sold_to_org_id , price_list_id
1540 into l_agreement_name,l_sold_to_org,l_price_list_id
1541 from oe_agreements_v
1542 where agreement_id = p_header_rec.agreement_id
1543 AND trunc(nvl(p_header_rec.pricing_date,sysdate)) between
1544 trunc(nvl(START_DATE_ACTIVE,add_months(sysdate,-10000)))
1545 AND trunc(nvl(END_DATE_ACTIVE,add_months(sysdate,+10000)));
1546
1547 -- Geresh added
1548 IF l_price_list_id <> p_Header_rec.price_list_id
1549 THEN
1550 fnd_message.set_name('ONT', 'OE_INVALID_AGREEMENT_PLIST');
1551 fnd_message.set_Token
1552 ('AGREEMENT_NAME', l_agreement_name || sqlerrm);
1553 fnd_message.set_Token('PRICE_LIST1', p_Header_rec.price_list_id);
1554 fnd_message.set_Token('PRICE_LIST2', l_price_list_id);
1555 OE_MSG_PUB.Add;
1556 oe_debug_pub.add('Invalid Agreement +price_list_id combination',2);
1557 raise FND_API.G_EXC_ERROR;
1558 END IF;
1559 END IF;
1560
1561 --bug 5206956 to check for customer relationships
1562 IF l_sold_to_org IS NOT NULL AND l_sold_to_org <> -1
1563 AND NOT OE_GLOBALS.EQUAL(l_sold_to_org,p_header_rec.sold_to_org_id) THEN
1564 IF nvl(lcustomer_relations,'N') = 'N' THEN
1565 fnd_message.set_name('ONT', 'OE_INVALID_AGREEMENT');
1566 fnd_message.set_Token('AGREEMENT_ID', p_header_rec.agreement_id);
1567 fnd_message.set_Token('AGREEMENT_NAME', l_agreement_name);
1568 fnd_message.set_Token('CUSTOMER_ID', p_header_rec.sold_to_org_id);
1569 OE_MSG_PUB.Add;
1570 IF l_debug_level > 0 then
1571 oe_debug_pub.add('Invalid Agreement +sold_org_id combination',2);
1572 END IF;
1573 RAISE FND_API.G_EXC_ERROR;
1574 ELSIF lcustomer_relations = 'Y' THEN
1575
1576 BEGIN
1577 SELECT 'VALID'
1578 INTO l_dummy
1579 FROM dual
1580 WHERE exists(
1581 select 'x' from
1582 hz_cust_acct_relate where
1583 related_cust_account_id = p_header_rec.sold_to_org_id
1584 and status = 'A'
1585 AND cust_account_id = l_sold_to_org
1586 );
1587
1588 EXCEPTION
1589 WHEN NO_DATA_FOUND THEN
1590 fnd_message.set_name('ONT', 'OE_INVALID_AGREEMENT');
1591 fnd_message.set_Token('AGREEMENT_ID', p_header_rec.agreement_id);
1592 fnd_message.set_Token('AGREEMENT_NAME', l_agreement_name);
1593 fnd_message.set_Token('CUSTOMER_ID', p_header_rec.sold_to_org_id);
1594 OE_MSG_PUB.Add;
1595 IF l_debug_level > 0 then
1596 oe_debug_pub.add('Invalid Agreement +sold_org_id combination',2);
1597 END IF;
1598 RAISE FND_API.G_EXC_ERROR;
1599 END;
1600 END IF;
1601 END IF;
1602 --bug 5206956
1603
1604
1605
1606 EXCEPTION
1607 WHEN NO_DATA_FOUND THEN
1608 fnd_message.set_name('ONT', 'OE_INVALID_AGREEMENT_PLIST');
1609 fnd_message.set_Token('AGREEMENT_NAME', l_agreement_name);
1610 fnd_message.set_Token('PRICE_LIST1', p_Header_rec.price_list_id);
1611 fnd_message.set_Token('PRICE_LIST2', l_price_list_id || sqlerrm);
1612 OE_MSG_PUB.Add;
1613 oe_debug_pub.add
1614 ('No Data Found Agreement+price_list_id combination',2);
1615 raise FND_API.G_EXC_ERROR;
1616 END;
1617
1618 -- l_order_type_rec :=
1619 -- OE_Order_Cache.Load_Order_Type (p_header_rec.order_type_id);
1620
1621 /***
1622 IF (l_agreement_rec.sold_to_org_id IS NOT NULL AND
1623 l_agreement_rec.sold_to_org_id <>
1624 p_header_rec.sold_to_org_id ) OR
1625 (l_order_type_rec.agreement_type_code IS NOT NULL AND
1626 l_agreement_rec.agreement_type_code <>
1627 l_order_type_rec.agreement_type_code ) THEN
1628 l_return_status := FND_API.G_RET_STS_ERROR;
1629 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
1630 THEN
1631 fnd_message.set_name('ONT','OE_INVALID_AGREEMENT');
1632 OE_MSG_PUB.Add;
1633 END IF;
1634 END IF;
1635 ***/
1636
1637 END IF; -- Agreement is not null
1638
1639 END IF; -- Agreement needed validation.
1640
1641
1642 -- Ship to Org id depends on sold to org.
1643 -- Added OR condition for CREATE Operation. Bug 5060064
1644 IF p_header_rec.ship_to_org_id IS NOT NULL AND
1645 ( NOT OE_GLOBALS.EQUAL(p_header_rec.ship_to_org_id
1646 ,p_old_header_rec.ship_to_org_id)
1647 OR
1648 NOT OE_GLOBALS.EQUAL(p_header_rec.sold_to_org_id
1649 ,p_old_header_rec.sold_to_org_id)
1650 OR (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE))
1651 THEN
1652
1653 BEGIN
1654 oe_debug_pub.add
1655 ('ship_to_org_id :'||to_char(p_header_rec.ship_to_org_id),2);
1656 oe_debug_pub.add
1657 ('Customer Relation :'||lcustomer_relations,2);
1658
1659 --lcustomer_relations := FND_PROFILE.VALUE('ONT_CUSTOMER_RELATIONSHIPS');
1660
1661 IF nvl(lcustomer_relations,'N') = 'N' THEN
1662 oe_debug_pub.add
1663 ('Cr: No',2);
1664
1665 SELECT 'VALID'
1666 INTO l_dummy
1667 FROM oe_ship_to_orgs_v
1668 WHERE customer_id = p_header_rec.sold_to_org_id
1669 AND site_use_id = p_header_rec.ship_to_org_id
1670 AND status = 'A'
1671 AND address_status ='A'; --bug 2752321
1672
1673 ELSIF lcustomer_relations = 'Y' THEN
1674 oe_debug_pub.add
1675 ('Cr: Yes Ship',2);
1676 --variable added for bug 3739650
1677 l_site_use_code := 'SHIP_TO' ;
1678 SELECT /* MOAC_SQL_CHANGE */ 'VALID'
1679 Into l_dummy
1680 FROM HZ_CUST_SITE_USES_ALL SITE,
1681 HZ_CUST_ACCT_SITES ACCT_SITE
1682 WHERE SITE.SITE_USE_ID = p_header_rec.ship_to_org_id
1683 AND SITE.SITE_USE_CODE = l_site_use_code
1684 AND SITE.CUST_ACCT_SITE_ID = ACCT_SITE.CUST_ACCT_SITE_ID
1685 AND SITE.STATUS = 'A'
1686 AND ACCT_SITE.STATUS ='A' AND --bug 2752321
1687 ACCT_SITE.CUST_ACCOUNT_ID in (
1688 SELECT p_header_rec.sold_to_org_id FROM DUAL
1689 UNION
1690 SELECT CUST_ACCOUNT_ID FROM
1691 HZ_CUST_ACCT_RELATE_ALL h WHERE
1692 RELATED_CUST_ACCOUNT_ID = p_header_rec.sold_to_org_id
1693 and h.org_id =acct_site.org_id
1694 and ship_to_flag = 'Y' and status = 'A')
1695 --bug 4205113
1696 AND EXISTS(SELECT 1 FROM HZ_CUST_ACCOUNTS WHERE CUST_ACCOUNT_ID = ACCT_SITE.CUST_ACCOUNT_ID AND STATUS='A')
1697 AND ROWNUM = 1;
1698 oe_debug_pub.add
1699 ('Cr: Yes- After the select',2);
1700 ELSIF lcustomer_relations = 'A' THEN
1701 SELECT 'VALID'
1702 INTO l_dummy
1703 FROM OE_SHIP_TO_ORGS_V SHP
1704 WHERE SHP.ORGANIZATION_ID =p_header_rec.ship_to_org_id
1705 AND SHP.STATUS = 'A'
1706 AND SHP.ADDRESS_STATUS ='A' --bug 2752321
1707 AND SYSDATE BETWEEN NVL(SHP.START_DATE_ACTIVE, SYSDATE)
1708 AND NVL(SHP.END_DATE_ACTIVE, SYSDATE);
1709
1710
1711 END IF;
1712
1713
1714 -- Valid Ship To Org Id.
1715
1716 EXCEPTION
1717
1718 WHEN NO_DATA_FOUND THEN
1719 oe_debug_pub.add
1720 ('In: No data found',2);
1721 l_return_status := FND_API.G_RET_STS_ERROR;
1722 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
1723 FND_MESSAGE.SET_TOKEN('ATTRIBUTE', OE_Order_Util.Get_Attribute_Name
1724 ('ship_to_org_id'));
1725 OE_MSG_PUB.Add;
1726
1727 WHEN OTHERS THEN
1728
1729 IF OE_MSG_PUB.Check_Msg_Level
1730 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1731 THEN
1732 OE_MSG_PUB.Add_Exc_Msg
1733 ( G_PKG_NAME ,
1734 'Record - Ship To'
1735 );
1736 END IF;
1737 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1738
1739 END;
1740
1741 END IF; -- Ship To needed validation.
1742
1743 -- Deliver to Org id depends on sold to org.
1744 IF p_header_rec.deliver_to_org_id IS NOT NULL AND
1745 ( NOT OE_GLOBALS.EQUAL(p_header_rec.deliver_to_org_id
1746 ,p_old_header_rec.deliver_to_org_id)
1747 OR
1748 NOT OE_GLOBALS.EQUAL(p_header_rec.sold_to_org_id
1749 ,p_old_header_rec.sold_to_org_id)
1750 OR (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE))
1751 THEN
1752 BEGIN
1753
1754 oe_debug_pub.add('deliver_to_org_id :'||to_char(p_header_rec.deliver_to_org_id),2);
1755 oe_debug_pub.add('Customer Relation :'||lcustomer_relations,2);
1756
1757 IF nvl(lcustomer_relations,'N') = 'N' THEN
1758
1759 oe_debug_pub.add('Cr: No',2);
1760
1761 SELECT 'VALID'
1762 INTO l_dummy
1763 FROM oe_deliver_to_orgs_v
1764 WHERE customer_id = p_header_rec.sold_to_org_id
1765 AND site_use_id = p_header_rec.deliver_to_org_id
1766 AND status = 'A'
1767 AND address_status ='A'; --bug 2752321
1768 -- Valid Deliver To Org Id.
1769
1770 ELSIF lcustomer_relations = 'Y' THEN
1771 oe_debug_pub.add('Cr: Yes deliver',2);
1772 --variable added for bug 3739650
1773 l_site_use_code := 'DELIVER_TO' ;
1774 SELECT /* MOAC_SQL_CHANGE */ 'VALID'
1775 Into l_dummy
1776 FROM HZ_CUST_SITE_USES_ALL SITE,
1777 HZ_CUST_ACCT_SITES ACCT_SITE
1778 WHERE SITE.SITE_USE_ID = p_header_rec.deliver_to_org_id
1779 AND SITE.SITE_USE_CODE = l_site_use_code
1780 AND SITE.CUST_ACCT_SITE_ID = ACCT_SITE.CUST_ACCT_SITE_ID
1781 AND SITE.STATUS = 'A'
1782 AND ACCT_SITE.STATUS = 'A' AND --bug 2752321
1783 ACCT_SITE.CUST_ACCOUNT_ID in (
1784 SELECT p_header_rec.sold_to_org_id FROM DUAL
1785 UNION
1786 SELECT CUST_ACCOUNT_ID FROM
1787 HZ_CUST_ACCT_RELATE_ALL h WHERE
1788 RELATED_CUST_ACCOUNT_ID = p_header_rec.sold_to_org_id
1789 and h.org_id =acct_site.org_id
1790 and ship_to_flag = 'Y' and status='A')
1791 --bug 4205113
1792 AND EXISTS(SELECT 1 FROM HZ_CUST_ACCOUNTS WHERE CUST_ACCOUNT_ID = ACCT_SITE.CUST_ACCOUNT_ID AND STATUS='A')
1793 AND ROWNUM = 1;
1794 oe_debug_pub.add('Cr: Yes- After the select',2);
1795
1796 ELSIF lcustomer_relations = 'A' THEN
1797
1798 SELECT 'VALID'
1799 INTO l_dummy
1800 FROM OE_DELIVER_TO_ORGS_V DEL
1801 WHERE DEL.ORGANIZATION_ID =p_header_rec.deliver_to_org_id
1802 AND DEL.STATUS = 'A'
1803 AND DEL.ADDRESS_STATUS ='A' --bug 2752321
1804 AND SYSDATE BETWEEN NVL(DEL.START_DATE_ACTIVE, SYSDATE)
1805 AND NVL(DEL.END_DATE_ACTIVE, SYSDATE);
1806
1807
1808 END IF;
1809
1810
1811 EXCEPTION
1812
1813 WHEN NO_DATA_FOUND THEN
1814 l_return_status := FND_API.G_RET_STS_ERROR;
1815 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
1816 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
1817 OE_Order_Util.Get_Attribute_Name('deliver_to_org_id'));
1818 OE_MSG_PUB.Add;
1819
1820 WHEN OTHERS THEN
1821
1822 IF OE_MSG_PUB.Check_Msg_Level
1823 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1824 THEN
1825
1826 OE_MSG_PUB.Add_Exc_Msg
1827 ( G_PKG_NAME ,
1828 'Record - Deliver To'
1829 );
1830 END IF;
1831
1832 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1833
1834 END;
1835
1836 END IF; -- Deliver To needed validation.
1837
1838
1839
1840 -- Invoice to Org id depends on sold to org.
1841
1842 IF p_header_rec.invoice_to_org_id IS NOT NULL AND
1843 ( NOT OE_GLOBALS.EQUAL(p_header_rec.invoice_to_org_id
1844 ,p_old_header_rec.invoice_to_org_id) OR
1845 NOT OE_GLOBALS.EQUAL(p_header_rec.sold_to_org_id
1846 ,p_old_header_rec.sold_to_org_id)
1847 OR (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE))
1848 THEN
1849 BEGIN
1850 oe_debug_pub.add
1851 ('invoice_to_org_id :'||to_char(p_header_rec.invoice_to_org_id),2);
1852
1853 IF nvl(lcustomer_relations,'N') = 'N' THEN
1854
1855 Select 'VALID'
1856 Into l_dummy
1857 From oe_invoice_to_orgs_v
1858 Where customer_id = p_header_rec.sold_to_org_id
1859 AND site_use_id = p_header_rec.invoice_to_org_id
1860 and status = 'A'
1861 and address_status ='A'; --bug 2752321
1862 -- validation for lcustomer_relations=A is done at the attribute level.
1863 -- for Order entered in the Sales Order form , it is assumed that the
1864 -- invoice to org passed is the correct one
1865 ELSIF lcustomer_relations = 'Y' THEN
1866
1867 oe_debug_pub.add
1868 ('Cr: Yes Inv',2);
1869 --variable added for bug 3739650
1870 l_site_use_code := 'BILL_TO' ;
1871 SELECT 'VALID'
1872 Into l_dummy
1873 FROM HZ_CUST_SITE_USES_ALL SITE,
1874 HZ_CUST_ACCT_SITES ACCT_SITE
1875 WHERE SITE.SITE_USE_ID = p_header_rec.invoice_to_org_id
1876 AND SITE.SITE_USE_CODE = l_site_use_code
1877 AND SITE.CUST_ACCT_SITE_ID = ACCT_SITE.CUST_ACCT_SITE_ID
1878 AND SITE.STATUS = 'A'
1879 AND ACCT_SITE.ORG_ID=SITE.ORG_ID
1880 AND ACCT_SITE.STATUS = 'A' AND
1881 ACCT_SITE.CUST_ACCOUNT_ID in (
1882 SELECT p_header_rec.sold_to_org_id FROM DUAL
1883 UNION
1884 SELECT CUST_ACCOUNT_ID FROM
1885 HZ_CUST_ACCT_RELATE_ALL h WHERE
1886 RELATED_CUST_ACCOUNT_ID = p_header_rec.sold_to_org_id
1887 and h.org_id =site.org_id
1888 and bill_to_flag = 'Y' and status='A' )
1889 --bug 4205113
1890 AND EXISTS(SELECT 1 FROM HZ_CUST_ACCOUNTS WHERE CUST_ACCOUNT_ID = ACCT_SITE.CUST_ACCOUNT_ID AND STATUS='A')
1891 AND ROWNUM = 1;
1892 END IF;
1893
1894
1895 EXCEPTION
1896
1897 WHEN NO_DATA_FOUND THEN
1898 l_return_status := FND_API.G_RET_STS_ERROR;
1899 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
1900 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
1901 OE_Order_Util.Get_Attribute_Name('invoice_to_org_id'));
1902 OE_MSG_PUB.Add;
1903
1904 WHEN OTHERS THEN
1905
1906 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1907 THEN
1908 OE_MSG_PUB.Add_Exc_Msg
1909 ( G_PKG_NAME ,
1910 'Record - Invoice To'
1911 );
1912 END IF;
1913
1914 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1915 END;
1916
1917 END IF; -- Invoice to org needed validation.
1918
1919
1920 -- QUOTING changes
1921 -- Customer Location depends on Sold To Org
1922
1923 IF p_header_rec.sold_to_site_use_id IS NOT NULL AND
1924 ( NOT OE_GLOBALS.EQUAL(p_header_rec.sold_to_site_use_id
1925 ,p_old_header_rec.sold_to_site_use_id) OR
1926 NOT OE_GLOBALS.EQUAL(p_header_rec.sold_to_org_id
1927 ,p_old_header_rec.sold_to_org_id)
1928 OR (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE))
1929 THEN
1930
1931 BEGIN
1932
1933 SELECT /* MOAC_SQL_CHANGE */ 'VALID'
1934 INTO l_dummy
1935 FROM
1936 HZ_CUST_SITE_USES_ALL SITE,
1937 HZ_CUST_ACCT_SITES ACCT_SITE
1938 WHERE
1939 SITE.SITE_USE_ID = p_header_rec.sold_to_site_use_id
1940 AND SITE.SITE_USE_CODE = 'SOLD_TO'
1941 AND SITE.CUST_ACCT_SITE_ID = ACCT_SITE.CUST_ACCT_SITE_ID
1942 AND ACCT_SITE.CUST_ACCOUNT_ID = p_header_rec.sold_to_org_id
1943 AND SITE.STATUS = 'A'
1944 AND ACCT_SITE.STATUS='A';
1945
1946 -- Valid Customer Location
1947
1948
1949
1950 EXCEPTION
1951
1952 WHEN NO_DATA_FOUND THEN
1953 l_return_status := FND_API.G_RET_STS_ERROR;
1954 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
1955 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
1956 OE_Order_Util.Get_Attribute_Name('SOLD_TO_SITE_USE_ID'));
1957 OE_MSG_PUB.Add;
1958
1959 WHEN OTHERS THEN
1960
1961 IF OE_MSG_PUB.Check_Msg_Level
1962 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1963 THEN
1964
1965 OE_MSG_PUB.Add_Exc_Msg
1966 ( G_PKG_NAME ,
1967 'Record - Customer Location'
1968 );
1969 END IF;
1970
1971 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1972
1973 END;
1974
1975 END IF;
1976 -- QUOTING changes
1977
1978 -- end customer contact id depends on end customer id
1979 IF p_header_rec.end_customer_contact_id IS NOT NULL AND
1980 ( NOT OE_GLOBALS.EQUAL(p_header_rec.end_customer_contact_id
1981 ,p_old_header_rec.end_customer_contact_id) OR
1982 NOT OE_GLOBALS.EQUAL(p_header_rec.end_customer_id
1983 ,p_old_header_rec.end_customer_id)
1984 OR (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE))
1985 THEN
1986
1987 BEGIN
1988
1989 SELECT 'VALID'
1990 INTO l_dummy
1991 FROM
1992 HZ_CUST_ACCOUNT_ROLES ACCT_ROLE
1993 WHERE
1994 ACCT_ROLE.CUST_ACCOUNT_ROLE_ID = p_header_rec.end_customer_contact_id
1995 AND ACCT_ROLE.CUST_ACCOUNT_ID = p_header_rec.end_customer_id
1996 AND ROWNUM = 1
1997 AND ACCT_ROLE.ROLE_TYPE = 'CONTACT'
1998 AND STATUS= 'A';
1999
2000 -- Valid Sold To Contact
2001
2002 EXCEPTION
2003
2004 WHEN NO_DATA_FOUND THEN
2005 l_return_status := FND_API.G_RET_STS_ERROR;
2006 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2007 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
2008 OE_Order_Util.Get_Attribute_Name('END_CUSTOMER_CONTACT_ID'));
2009 OE_MSG_PUB.Add;
2010
2011 WHEN OTHERS THEN
2012 IF OE_MSG_PUB.Check_Msg_Level
2013 ( OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2014 THEN
2015 OE_MSG_PUB.Add_Exc_Msg
2016 ( G_PKG_NAME ,
2017 'Record - End Customer Contact'
2018 );
2019 END IF;
2020
2021 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2022
2023 END; -- BEGIN
2024
2025 END IF; -- End Customer contact needed validation.
2026
2027
2028 IF p_header_rec.end_customer_site_use_id IS NOT NULL AND
2029 ( NOT OE_GLOBALS.EQUAL(p_header_rec.end_customer_site_use_id
2030 ,p_old_header_rec.end_customer_id) OR
2031 NOT OE_GLOBALS.EQUAL(p_header_rec.end_customer_id
2032 ,p_old_header_rec.end_customer_id)
2033 OR (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE))
2034 THEN
2035
2036 BEGIN
2037
2038 SELECT /* MOAC_SQL_CHANGE */ 'VALID'
2039 INTO
2040 l_dummy
2041 FROM
2042 hz_cust_site_uses_all site_use,
2043 hz_cust_acct_sites acct_site
2044 WHERE
2045 site_use.site_use_id=p_header_rec.end_customer_site_use_id
2046 and site_use.cust_acct_site_id=acct_site.cust_acct_site_id
2047 and acct_site.cust_account_id=p_header_rec.end_customer_id;
2048 -- Valid End customer site
2049
2050 EXCEPTION
2051
2052 WHEN NO_DATA_FOUND THEN
2053 l_return_status := FND_API.G_RET_STS_ERROR;
2054 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2055 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
2056 OE_Order_Util.Get_Attribute_Name('END_CUSTOMER_SITE_USE_ID'));
2057 OE_MSG_PUB.Add;
2058
2059 WHEN OTHERS THEN
2060 IF OE_MSG_PUB.Check_Msg_Level
2061 ( OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2062 THEN
2063 OE_MSG_PUB.Add_Exc_Msg
2064 ( G_PKG_NAME ,
2065 'Record - End Customer Site'
2066 );
2067 END IF;
2068
2069 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2070
2071 END; -- BEGIN
2072
2073 END IF; -- End Customer site needed validation.
2074
2075 -- Sold to contact depends on Sold To Org
2076
2077 IF p_header_rec.sold_to_contact_id IS NOT NULL AND
2078 ( NOT OE_GLOBALS.EQUAL(p_header_rec.sold_to_contact_id
2079 ,p_old_header_rec.sold_to_contact_id) OR
2080 NOT OE_GLOBALS.EQUAL(p_header_rec.sold_to_org_id
2081 ,p_old_header_rec.sold_to_org_id)
2082 OR (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE))
2083 THEN
2084
2085 BEGIN
2086
2087 SELECT 'VALID'
2088 INTO l_dummy
2089 FROM
2090 HZ_CUST_ACCOUNT_ROLES ACCT_ROLE
2091 WHERE
2092 ACCT_ROLE.CUST_ACCOUNT_ROLE_ID = p_header_rec.sold_to_contact_id
2093 AND ACCT_ROLE.CUST_ACCOUNT_ID = p_header_rec.sold_to_org_id
2094 AND ROWNUM = 1
2095 AND ACCT_ROLE.ROLE_TYPE = 'CONTACT'
2096 AND STATUS= 'A';
2097
2098 -- Valid Sold To Contact
2099
2100 EXCEPTION
2101
2102 WHEN NO_DATA_FOUND THEN
2103 l_return_status := FND_API.G_RET_STS_ERROR;
2104 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2105 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
2106 OE_Order_Util.Get_Attribute_Name('SOLD_TO_CONTACT_ID'));
2107 OE_MSG_PUB.Add;
2108
2109 WHEN OTHERS THEN
2110 IF OE_MSG_PUB.Check_Msg_Level
2111 ( OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2112 THEN
2113 OE_MSG_PUB.Add_Exc_Msg
2114 ( G_PKG_NAME ,
2115 'Record - Sold To Contact'
2116 );
2117 END IF;
2118
2119 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2120
2121 END; -- BEGIN
2122
2123 END IF; -- Sold to contact needed validation.
2124
2125
2126 -- Invoice to contact depends on Invoice To Org
2127
2128 IF p_header_rec.invoice_to_contact_id IS NOT NULL AND
2129 ( NOT OE_GLOBALS.EQUAL(p_header_rec.invoice_to_contact_id
2130 ,p_old_header_rec.invoice_to_contact_id) OR
2131 NOT OE_GLOBALS.EQUAL(p_header_rec.invoice_to_org_id
2132 ,p_old_header_rec.invoice_to_org_id)
2133 OR (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE))
2134 THEN
2135 BEGIN
2136 oe_debug_pub.add
2137 ('inv_to_contact :'||to_char(p_header_rec.invoice_to_contact_id),2);
2138
2139 SELECT /* MOAC_SQL_CHANGE */ 'VALID'
2140 INTO l_dummy
2141 FROM
2142 HZ_CUST_ACCOUNT_ROLES ACCT_ROLE,
2143 HZ_CUST_SITE_USES_ALL SITE_USE, --changed INV to SITE_USE for bug 3739650
2144 HZ_CUST_ACCT_SITES ADDR
2145 WHERE
2146 ACCT_ROLE.CUST_ACCOUNT_ROLE_ID = p_header_rec.invoice_to_contact_id
2147 AND ACCT_ROLE.CUST_ACCOUNT_ID = ADDR.CUST_ACCOUNT_ID
2148 AND ACCT_ROLE.ROLE_TYPE = 'CONTACT'
2149 AND ADDR.CUST_ACCT_SITE_ID = SITE_USE.CUST_ACCT_SITE_ID
2150 AND SITE_USE.SITE_USE_ID = p_header_rec.invoice_to_org_id
2151 AND SITE_USE.STATUS = 'A'
2152 AND ADDR.STATUS ='A' --bug 2752321
2153 AND ACCT_ROLE.STATUS = 'A'
2154 AND ROWNUM = 1;
2155
2156 EXCEPTION
2157
2158 WHEN NO_DATA_FOUND THEN
2159
2160 l_return_status := FND_API.G_RET_STS_ERROR;
2161 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2162 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
2163 OE_Order_Util.Get_Attribute_Name('INVOICE_TO_CONTACT_ID'));
2164 OE_MSG_PUB.Add;
2165
2166
2167 WHEN OTHERS THEN
2168
2169 IF OE_MSG_PUB.Check_Msg_Level
2170 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2171 THEN
2172
2173 OE_MSG_PUB.Add_Exc_Msg
2174 ( G_PKG_NAME ,
2175 'Record - Invoice To Contact'
2176 );
2177 END IF;
2178
2179 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2180
2181 END;
2182
2183 END IF; -- Invoice to contact needed validation.
2184
2185
2186 -- Ship to contact depends on Ship To Org
2187
2188 IF p_header_rec.ship_to_contact_id IS NOT NULL AND
2189 ( NOT OE_GLOBALS.EQUAL(p_header_rec.ship_to_contact_id
2190 ,p_old_header_rec.ship_to_contact_id) OR
2191 NOT OE_GLOBALS.EQUAL(p_header_rec.ship_to_org_id
2192 ,p_old_header_rec.ship_to_org_id)
2193 OR (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE))
2194 THEN
2195
2196 BEGIN
2197
2198 SELECT /* MOAC_SQL_CHANGE */ 'VALID'
2199 INTO l_dummy
2200 FROM
2201 HZ_CUST_ACCOUNT_ROLES ACCT_ROLE,
2202 HZ_CUST_SITE_USES_ALL SITE_USE, --changed SHIP to SITE_USE for bug 3739650
2203 HZ_CUST_ACCT_SITES ADDR
2204 WHERE
2205 ACCT_ROLE.CUST_ACCOUNT_ROLE_ID = p_header_rec.ship_to_contact_id
2206 AND ACCT_ROLE.CUST_ACCOUNT_ID = ADDR.CUST_ACCOUNT_ID
2207 AND ACCT_ROLE.ROLE_TYPE = 'CONTACT'
2208 AND ADDR.CUST_ACCT_SITE_ID = SITE_USE.CUST_ACCT_SITE_ID
2209 AND SITE_USE.SITE_USE_ID = p_header_rec.ship_to_org_id
2210 AND SITE_USE.STATUS = 'A'
2211 AND ADDR.STATUS ='A' --bug 2752321
2212 AND ACCT_ROLE.STATUS = 'A'
2213 AND ROWNUM = 1;
2214
2215 -- Valid Ship To Contact
2216
2217 EXCEPTION
2218
2219 WHEN NO_DATA_FOUND THEN
2220 l_return_status := FND_API.G_RET_STS_ERROR;
2221 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2222 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
2223 OE_Order_Util.Get_Attribute_Name('SHIP_TO_CONTACT_ID'));
2224 OE_MSG_PUB.Add;
2225
2226
2227 WHEN OTHERS THEN
2228
2229 IF OE_MSG_PUB.Check_Msg_Level
2230 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2231 THEN
2232
2233 OE_MSG_PUB.Add_Exc_Msg
2234 ( G_PKG_NAME ,
2235 'Record - Ship To Contact'
2236 );
2237 END IF;
2238
2239 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2240
2241 END; -- BEGIN
2242
2243 END IF; -- Ship to contact needed validation.
2244
2245
2246 -- Deliver to contact depends on Deliver To Org
2247
2248 IF p_header_rec.deliver_to_contact_id IS NOT NULL AND
2249 ( NOT OE_GLOBALS.EQUAL(p_header_rec.deliver_to_contact_id
2250 ,p_old_header_rec.deliver_to_contact_id) OR
2251 NOT OE_GLOBALS.EQUAL(p_header_rec.deliver_to_org_id
2252 ,p_old_header_rec.deliver_to_org_id)
2253 OR (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE))
2254 THEN
2255
2256 BEGIN
2257
2258 SELECT /* MOAC_SQL_CHANGE */ 'VALID'
2259 INTO l_dummy
2260 FROM
2261 HZ_CUST_ACCOUNT_ROLES ACCT_ROLE,
2262 HZ_CUST_SITE_USES_ALL SITE_USE, --changed DELIVER to SITE_USE for bug 3739650
2263 HZ_CUST_ACCT_SITES ADDR
2264 WHERE
2265 ACCT_ROLE.CUST_ACCOUNT_ROLE_ID = p_header_rec.deliver_to_contact_id
2266 AND ACCT_ROLE.CUST_ACCOUNT_ID = ADDR.CUST_ACCOUNT_ID
2267 AND ACCT_ROLE.ROLE_TYPE = 'CONTACT'
2268 AND ADDR.CUST_ACCT_SITE_ID = SITE_USE.CUST_ACCT_SITE_ID
2269 AND SITE_USE.SITE_USE_ID = p_header_rec.deliver_to_org_id
2270 AND SITE_USE.STATUS = 'A'
2271 AND ADDR.STATUS ='A' --bug 2752321
2272 AND ACCT_ROLE.STATUS = 'A'
2273 AND ROWNUM = 1;
2274
2275 -- Valid Deliver To Org.
2276
2277 EXCEPTION
2278
2279 WHEN NO_DATA_FOUND THEN
2280 l_return_status := FND_API.G_RET_STS_ERROR;
2281 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2282 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
2283 OE_Order_Util.Get_Attribute_Name('DELIVER_TO_CONTACT_ID'));
2284 OE_MSG_PUB.Add;
2285
2286 WHEN OTHERS THEN
2287
2288 IF OE_MSG_PUB.Check_Msg_Level (
2289 OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2290 THEN
2291 OE_MSG_PUB.Add_Exc_Msg
2292 ( G_PKG_NAME ,
2293 'Record - Deliver To Contact'
2294 );
2295 END IF;
2296
2297 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2298
2299 END; -- BEGIN
2300
2301 END IF; -- Deliver to contact needed validation.
2302
2303
2304
2305 --Following validation for Tax Exemption Number is removed for bug 6441512
2306 -- Check for Tax Exempt number/Tax exempt reason code IF the Tax exempt
2307 -- flag is 'S' (StANDard).
2308
2309
2310 /* IF p_header_rec.tax_exempt_flag IS NOT NULL
2311 AND ( NOT OE_GLOBALS.EQUAL(p_header_rec.tax_exempt_number
2312 ,p_old_header_rec.tax_exempt_number)
2313 OR NOT OE_GLOBALS.EQUAL(p_header_rec.tax_exempt_reason_code
2314 ,p_old_header_rec.tax_exempt_reason_code)
2315 OR NOT OE_GLOBALS.EQUAL(p_header_rec.ship_to_org_id
2316 ,p_old_header_rec.ship_to_org_id)
2317 OR NOT OE_GLOBALS.EQUAL(p_header_rec.invoice_to_org_id
2318 ,p_old_header_rec.invoice_to_org_id)
2319 OR NOT OE_GLOBALS.EQUAL(p_header_rec.sold_to_org_id
2320 ,p_old_header_rec.sold_to_org_id)
2321 OR (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE)
2322 )
2323 THEN
2324
2325 BEGIN
2326 -- 6118092
2327 IF ( p_header_rec.tax_exempt_flag = 'S' OR p_header_rec.tax_exempt_flag = 'E' ) AND
2328 p_header_rec.tax_exempt_number IS NOT NULL AND
2329 p_header_rec.tax_exempt_reason_code IS NOT NULL
2330 THEN
2331
2332 -- EBTax Changes
2333
2334 open partyinfo(p_header_rec.invoice_to_org_id);
2335 fetch partyinfo into l_bill_to_cust_Acct_id,
2336 l_bill_to_party_id,
2337 l_bill_to_party_site_id,
2338 l_org_id;
2339 close partyinfo;
2340
2341 if p_header_rec.ship_to_org_id = p_header_rec.invoice_to_org_id then
2342 l_ship_to_cust_Acct_id := l_bill_to_cust_Acct_id;
2343 l_ship_to_party_id := l_bill_to_party_id;
2344 l_ship_to_party_site_id := l_bill_to_party_site_id ;
2345 else
2346 open partyinfo(p_header_rec.ship_to_org_id);
2347 fetch partyinfo into l_ship_to_cust_Acct_id,
2348 l_ship_to_party_id,
2349 l_ship_to_party_site_id,
2350 l_org_id;
2351 close partyinfo;
2352 end if;
2353
2354 -- Modified below code to validate Tax Exempt Number based on Tax Handling for Bug 6378168
2355 IF ( p_header_rec.tax_exempt_flag = 'S' ) THEN
2356 SELECT 'VALID'
2357 INTO l_dummy
2358 FROM ZX_EXEMPTIONS_V
2359 WHERE EXEMPT_CERTIFICATE_NUMBER = p_header_rec.tax_exempt_number
2360 AND EXEMPT_REASON_CODE=p_header_rec.tax_exempt_reason_code
2361 AND nvl(site_use_id,nvl(p_header_rec.ship_to_org_id,p_header_rec.invoice_to_org_id)) =
2362 nvl(p_header_rec.ship_to_org_id,p_header_rec.invoice_to_org_id)
2363 AND nvl(cust_account_id, l_bill_to_cust_acct_id) = l_bill_to_cust_acct_id
2364 AND nvl(PARTY_SITE_ID,nvl(l_ship_to_party_site_id, l_bill_to_party_site_id))=
2365 nvl(l_ship_to_party_site_id, l_bill_to_party_site_id)
2366 and org_id = p_header_rec.org_id
2367 and party_id = l_bill_to_party_id
2368 AND EXEMPTION_STATUS_CODE = 'PRIMARY'
2369 AND TRUNC(NVL(p_header_rec.request_date,sysdate)) BETWEEN
2370 TRUNC(EFFECTIVE_FROM) AND
2371 TRUNC(NVL(EFFECTIVE_TO,NVL(p_header_rec.request_date,sysdate)))
2372 AND ROWNUM = 1;
2373 ELSIF ( p_header_rec.tax_exempt_flag = 'E' ) THEN
2374 SELECT 'VALID'
2375 INTO l_dummy
2376 FROM ZX_EXEMPTIONS_V
2377 WHERE EXEMPT_CERTIFICATE_NUMBER = p_header_rec.tax_exempt_number
2378 AND EXEMPT_REASON_CODE=p_header_rec.tax_exempt_reason_code
2379 AND nvl(site_use_id,nvl(p_header_rec.ship_to_org_id,p_header_rec.invoice_to_org_id)) =
2380 nvl(p_header_rec.ship_to_org_id,p_header_rec.invoice_to_org_id)
2381 AND nvl(cust_account_id, l_bill_to_cust_acct_id) = l_bill_to_cust_acct_id
2382 AND nvl(PARTY_SITE_ID,nvl(l_ship_to_party_site_id, l_bill_to_party_site_id))=
2383 nvl(l_ship_to_party_site_id, l_bill_to_party_site_id)
2384 and org_id = p_header_rec.org_id
2385 and party_id = l_bill_to_party_id
2386 AND EXEMPTION_STATUS_CODE IN ('PRIMARY','MANUAL','UNAPPROVED')
2387 AND TRUNC(NVL(p_header_rec.request_date,sysdate)) BETWEEN
2388 TRUNC(EFFECTIVE_FROM) AND
2389 TRUNC(NVL(EFFECTIVE_TO,NVL(p_header_rec.request_date,sysdate)))
2390 AND ROWNUM = 1;
2391 END IF;
2392
2393 END IF;
2394
2395 oe_debug_pub.Add(' Valid Tax Exempt Number',1);
2396
2397 EXCEPTION
2398
2399 WHEN NO_DATA_FOUND THEN
2400
2401 -- Bug 6118092 Redefault as it may be no more valid
2402 IF p_header_rec.order_category_code = 'RETURN' THEN -- 6430711
2403 null;
2404 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
2405 p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
2406 p_header_rec.tax_exempt_number := FND_API.G_MISS_CHAR;
2407 p_header_rec.tax_exempt_reason_code := FND_API.G_MISS_CHAR;
2408 p_header_rec.tax_exempt_flag :=FND_API.G_MISS_CHAR;
2409
2410 oe_debug_pub.Add('Redefault the tax_exempt_number',1);
2411 ELSE
2412 l_return_status := FND_API.G_RET_STS_ERROR;
2413 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2414 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
2415 OE_Order_Util.Get_Attribute_Name('TAX_EXEMPT_NUMBER'));
2416 OE_MSG_PUB.Add;
2417 END IF;
2418
2419 WHEN OTHERS THEN
2420
2421 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2422 THEN
2423
2424 OE_MSG_PUB.Add_Exc_Msg
2425 ( G_PKG_NAME ,
2426 'Record - Tax Exempt Number'
2427 );
2428 END IF;
2429
2430 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2431
2432 END; -- BEGIN
2433
2434 END IF; -- Tax exempton info validation.
2435
2436 */
2437
2438 oe_debug_pub.Add('p_header_rec.cust_po_number'|| p_header_rec.cust_po_number);-- Bug# 6603714
2439 IF p_header_rec.order_source_id <> 27 THEN-- Bug# 6603714
2440
2441 -- Fix bug 1162304: issue a warning message if the PO number
2442 -- is being referenced by another order
2443 IF p_header_rec.cust_po_number IS NOT NULL
2444 AND ( NOT OE_GLOBALS.EQUAL(p_header_rec.sold_to_org_id
2445 ,p_old_header_rec.sold_to_org_id)
2446 OR NOT OE_GLOBALS.EQUAL(p_header_rec.cust_po_number
2447 ,p_old_header_rec.cust_po_number)
2448 OR (p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE)
2449 )
2450 THEN
2451
2452 IF OE_Validate_Header.Is_Duplicate_PO_Number
2453 (p_header_rec.cust_po_number
2454 ,p_header_rec.sold_to_org_id
2455 ,p_header_rec.header_id )
2456 THEN
2457 FND_MESSAGE.SET_NAME('ONT','OE_VAL_DUP_PO_NUMBER');
2458 OE_MSG_PUB.ADD;
2459 END IF;
2460
2461 END IF;
2462 -- End of check for duplicate PO number
2463 END IF;-- Bug# 6603714
2464
2465
2466 -- bug 1618229, validation for sold_to_org_id on order against
2467 -- the customer for commitment when commitment is used.
2468 /*
2469 ** Fix Bug # 3015881
2470 ** No need to validate here as this will be validated anyway
2471 ** when the sold to org id changes are cascaded to the line.
2472
2473 IF (NOT OE_GLOBALS.EQUAL(p_header_rec.sold_to_org_id
2474 ,p_old_header_rec.sold_to_org_id)) THEN
2475
2476 oe_debug_pub.add('OEXLHDRB: before validating customer for commitment.', 3);
2477 Validate_Commitment_Customer
2478 (p_header_id => p_header_rec.header_id
2479 ,p_sold_to_org_id => p_header_rec.sold_to_org_id
2480 ,x_return_status => l_comt_cust_status);
2481
2482 IF l_comt_cust_status = FND_API.G_RET_STS_ERROR THEN
2483
2484 l_return_status := FND_API.G_RET_STS_ERROR;
2485
2486 -- to get the customer name of the order.
2487 BEGIN
2488 SELECT party.party_name
2489 INTO l_customer_name
2490 FROM hz_parties party,
2491 hz_cust_accounts cust_acct
2492 WHERE cust_acct.cust_account_id = p_header_rec.sold_to_org_id
2493 AND cust_acct.party_id = party.party_id;
2494
2495 EXCEPTION WHEN NO_DATA_FOUND THEN
2496 null;
2497 END;
2498
2499 Fnd_Message.Set_Name('ONT','ONT_COM_CUSTOMER_MISMATCH');
2500 Fnd_message.set_token('CUSTOMER',l_customer_name);
2501 OE_MSG_PUB.Add;
2502 oe_debug_pub.add('Error: customer of the order does not match the customer for the commitment.', 3);
2503 RAISE FND_API.G_EXC_ERROR;
2504 END IF;
2505 END IF;
2506 */
2507
2508 -------------------------------------------------------------------
2509 -- Validating Blankets
2510 -------------------------------------------------------------------
2511
2512 IF OE_CODE_CONTROL.Get_Code_Release_Level < '110509' AND
2513 p_header_rec.blanket_number IS NOT NULL THEN
2514 If l_debug_level > 0 THEN
2515 OE_DEBUG_PUB.Add('Blankets are only available in Pack I or greater',1);
2516 End if;
2517 l_return_status := FND_API.G_RET_STS_ERROR;
2518 FND_MESSAGE.Set_Name('ONT','OE_BLANKET_INVALID_VERSION');
2519 OE_MSG_PUB.Add;
2520 ELSE
2521 IF p_header_rec.blanket_number IS NOT NULL THEN
2522 Validate_Blanket_Values
2523 (p_header_rec => p_header_rec,
2524 p_old_header_rec => p_old_header_rec,
2525 x_return_status => l_blanket_status);
2526 IF l_blanket_status = FND_API.G_RET_STS_ERROR THEN
2527 x_return_status := l_blanket_status;
2528 ELSIF l_blanket_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2529 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2530 END IF;
2531 END IF;
2532 END IF;
2533
2534 --Commenting the following for bug 3733877
2535 /*
2536 IF OE_PREPAYMENT_UTIL.IS_MULTIPLE_PAYMENTS_ENABLED = TRUE THEN
2537
2538 IF (NOT OE_GLOBALS.EQUAL(p_header_rec.payment_type_code
2539 ,p_old_header_rec.payment_type_code))
2540 or
2541 (NOT OE_GLOBALS.EQUAL(p_header_rec.credit_card_code
2542 ,p_old_header_rec.credit_card_code))
2543 or
2544 (NOT OE_GLOBALS.EQUAL(p_header_rec.credit_card_number
2545 ,p_old_header_rec.credit_card_number))
2546 or
2547 (NOT OE_GLOBALS.EQUAL(p_header_rec.credit_card_holder_name
2548 ,p_old_header_rec.credit_card_holder_name))
2549 or
2550 (NOT OE_GLOBALS.EQUAL(p_header_rec.credit_card_expiration_date
2551 ,p_old_header_rec.credit_card_expiration_date))
2552 or
2553 (NOT OE_GLOBALS.EQUAL(p_header_rec.check_number
2554 ,p_old_header_rec.check_number))
2555 or
2556 (NOT OE_GLOBALS.EQUAL(p_header_rec.payment_amount
2557 ,p_old_header_rec.payment_amount))
2558
2559 THEN
2560
2561 select count(payment_type_code) into l_payment_count
2562 from oe_payments
2563 where header_id = p_header_rec.header_id
2564 and line_id is null;
2565
2566 if l_payment_count > 1 then
2567 l_return_status := FND_API.G_RET_STS_ERROR;
2568
2569 fnd_message.Set_Name('ONT','ONT_MULTIPLE_PAYMENTS_EXIST');
2570 OE_MSG_PUB.Add;
2571 oe_debug_pub.add('Error: multiple payments exist. cannot update order header',3);
2572
2573 end if;
2574
2575 END IF; -- if not oe_globals.equal...
2576
2577 END IF; -- if multiple_payments is enabled
2578 */
2579 --distributed orders @
2580 oe_debug_pub.ADD('ib_owner: '||p_header_rec.ib_owner);
2581 IF p_header_rec.ib_owner IS NOT NULL AND
2582 ( NOT OE_GLOBALS.EQUAL(p_header_rec.ib_owner ,p_old_header_rec.ib_owner)
2583 OR p_old_header_rec.ib_owner is null
2584 OR NOT OE_GLOBALS.EQUAL(p_header_rec.sold_to_org_id, p_old_header_rec.sold_to_org_id)
2585 OR NOT OE_GLOBALS.EQUAL(p_header_rec.end_customer_id, p_old_header_rec.end_customer_id)
2586 OR p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE)
2587 THEN
2588 IF (p_header_rec.ib_owner = 'SOLD_TO' AND
2589 p_header_rec.sold_to_org_id is null)
2590 THEN
2591 l_return_status := FND_API.G_RET_STS_ERROR;
2592 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2593 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_OWNER'));
2594 OE_MSG_PUB.Add;
2595 ELSIF p_header_rec.ib_owner = 'END_CUSTOMER' AND
2596 p_header_rec.end_customer_id is null
2597 THEN
2598 l_return_status := FND_API.G_RET_STS_ERROR;
2599 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2600 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_OWNER'));
2601 OE_MSG_PUB.Add;
2602 END IF;
2603 END IF;
2604 oe_debug_pub.ADD('ib_installed_at_location: '||p_header_rec.ib_installed_at_location);
2605
2606 IF p_header_rec.ib_installed_at_location IS NOT NULL AND
2607 ( NOT OE_GLOBALS.EQUAL(p_header_rec.ib_installed_at_location ,p_old_header_rec.ib_installed_at_location)
2608 OR p_old_header_rec.ib_installed_at_location is null
2609 OR NOT OE_GLOBALS.EQUAL(p_header_rec.invoice_to_org_id ,p_old_header_rec.invoice_to_org_id)
2610 OR NOT OE_GLOBALS.EQUAL(p_header_rec.ship_to_org_id ,p_old_header_rec.ship_to_org_id)
2611 OR NOT OE_GLOBALS.EQUAL(p_header_rec.deliver_to_org_id ,p_old_header_rec.deliver_to_org_id)
2612 OR NOT OE_GLOBALS.EQUAL(p_header_rec.end_customer_site_use_id ,p_old_header_rec.end_customer_site_use_id)
2613 OR NOT OE_GLOBALS.EQUAL(p_header_rec.sold_to_site_use_id ,p_old_header_rec.sold_to_site_use_id)
2614 OR p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE)
2615 THEN
2616 IF (p_header_rec.ib_installed_at_location = 'BILL_TO' AND
2617 p_header_rec.invoice_to_org_id is null)
2618 THEN
2619 l_return_status := FND_API.G_RET_STS_ERROR;
2620 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2621 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_INSTALLED_AT_LOCATION'));
2622 OE_MSG_PUB.Add;
2623 ELSIF p_header_rec.ib_installed_at_location = 'SHIP_TO' AND
2624 p_header_rec.ship_to_org_id is null
2625 THEN
2626 l_return_status := FND_API.G_RET_STS_ERROR;
2627 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2628 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_INSTALLED_AT_LOCATION'));
2629 OE_MSG_PUB.Add;
2630 ELSIF p_header_rec.ib_installed_at_location = 'DELIVER_TO' AND
2631 p_header_rec.deliver_to_org_id is null
2632 THEN
2633 l_return_status := FND_API.G_RET_STS_ERROR;
2634 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2635 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_INSTALLED_AT_LOCATION'));
2636 OE_MSG_PUB.Add;
2637 ELSIF p_header_rec.ib_installed_at_location = 'END_CUSTOMER' AND
2638 p_header_rec.end_customer_site_use_id is null
2639 THEN
2640 l_return_status := FND_API.G_RET_STS_ERROR;
2641 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2642 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_INSTALLED_AT_LOCATION'));
2643 OE_MSG_PUB.Add;
2644 ELSIF p_header_rec.ib_installed_at_location = 'SOLD_TO' AND
2645 p_header_rec.sold_to_site_use_id is null
2646 THEN
2647 l_return_status := FND_API.G_RET_STS_ERROR;
2648 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2649 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_INSTALLED_AT_LOCATION'));
2650 OE_MSG_PUB.Add;
2651 END IF;
2652 END IF;
2653 oe_debug_pub.ADD('ib_current_location: '||p_header_rec.ib_current_location);
2654
2655 IF p_header_rec.ib_current_location IS NOT NULL AND
2656 ( NOT OE_GLOBALS.EQUAL(p_header_rec.ib_current_location ,p_old_header_rec.ib_current_location)
2657 OR NOT OE_GLOBALS.EQUAL(p_header_rec.invoice_to_org_id ,p_old_header_rec.invoice_to_org_id)
2658 OR NOT OE_GLOBALS.EQUAL(p_header_rec.ship_to_org_id ,p_old_header_rec.ship_to_org_id)
2659 OR NOT OE_GLOBALS.EQUAL(p_header_rec.deliver_to_org_id ,p_old_header_rec.deliver_to_org_id)
2660 OR NOT OE_GLOBALS.EQUAL(p_header_rec.end_customer_site_use_id ,p_old_header_rec.end_customer_site_use_id)
2661 OR NOT OE_GLOBALS.EQUAL(p_header_rec.sold_to_site_use_id ,p_old_header_rec.sold_to_site_use_id)
2662 OR p_old_header_rec.ib_current_location is null
2663 OR p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE )
2664 THEN
2665 IF (p_header_rec.ib_current_location = 'BILL_TO' AND
2666 p_header_rec.invoice_to_org_id is null)
2667 THEN
2668 l_return_status := FND_API.G_RET_STS_ERROR;
2669 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2670 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_CURRENT_LOCATION'));
2671 OE_MSG_PUB.Add;
2672 ELSIF p_header_rec.ib_current_location = 'SHIP_TO' AND
2673 p_header_rec.ship_to_org_id is null
2674 THEN
2675 l_return_status := FND_API.G_RET_STS_ERROR;
2676 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2677 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_CURRENT_LOCATION'));
2678 OE_MSG_PUB.Add;
2679 ELSIF p_header_rec.ib_current_location = 'DELIVER_TO' AND
2680 p_header_rec.deliver_to_org_id is null
2681 THEN
2682 l_return_status := FND_API.G_RET_STS_ERROR;
2683 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2684 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_CURRENT_LOCATION'));
2685 OE_MSG_PUB.Add;
2686 ELSIF p_header_rec.ib_current_location = 'END_CUSTOMER' AND
2687 p_header_rec.end_customer_site_use_id is null
2688 THEN
2689 l_return_status := FND_API.G_RET_STS_ERROR;
2690 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2691 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_CURRENT_LOCATION'));
2692 OE_MSG_PUB.Add;
2693 ELSIF p_header_rec.ib_current_location = 'SOLD_TO' AND
2694 p_header_rec.sold_to_site_use_id is null
2695 THEN
2696 l_return_status := FND_API.G_RET_STS_ERROR;
2697 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2698 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_CURRENT_LOCATION'));
2699 OE_MSG_PUB.Add;
2700 END IF;
2701 END IF;
2702
2703 -- IB Validation START
2704 -- for validating line level ib_installed_at_location
2705 -- and ib_current_location for all lines
2706 -- This should be a CORNER CASE, hence not much perf impact
2707 IF p_old_header_rec.sold_to_site_use_id IS NOT NULL
2708 and p_header_rec.sold_to_site_use_id IS NULL
2709 and p_old_header_rec.header_id is not null
2710 then
2711 -- okay, loop for all lines
2712 If l_debug_level > 0 THEN
2713 oe_debug_pub.add('>sold_to_site_use_id has changed to null,');
2714 oe_debug_pub.add('>checking all lines for IB validation');
2715 end if;
2716
2717 for l in ib_lines loop
2718 if l.ib_current_location='SOLD_TO'
2719 then
2720 If l_debug_level > 0 THEN
2721 oe_debug_pub.add('>line_id:'||l.line_id||' has ib_current_location as SOLD_TO');
2722 end if;
2723 l_return_status := FND_API.G_RET_STS_ERROR;
2724 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2725 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_CURRENT_LOCATION'));
2726 OE_MSG_PUB.Add;
2727 elsif l.ib_installed_at_location='SOLD_TO'
2728 then
2729 If l_debug_level > 0 THEN
2730 oe_debug_pub.add('>line_id:'||l.line_id||' has ib_installed_at_location as SOLD_TO');
2731 end if;
2732 l_return_status := FND_API.G_RET_STS_ERROR;
2733 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2734 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_INSTALLED_AT_LOCATION'));
2735 OE_MSG_PUB.Add;
2736 end if;
2737 end loop;
2738 end if;
2739 If l_debug_level > 0 THEN
2740 oe_debug_pub.add('>IB Line validation done');
2741 end if;
2742 -- IB Validation ENDS
2743
2744 --R12 CC Encryption
2745 IF p_header_rec.payment_type_code = 'CREDIT_CARD' THEN
2746 IF p_header_rec.invoice_to_org_id is NULL THEN
2747 l_return_status := FND_API.G_RET_STS_ERROR;
2748 FND_MESSAGE.SET_NAME('ONT','OE_VPM_INV_TO_REQUIRED');
2749 OE_MSG_PUB.ADD;
2750 END IF;
2751 END IF;
2752 --R12 CC Encryption
2753 /*
2754 OE_MSG_PUB.ADD;
2755 ELSIF p_header_rec.credit_card_number is NULL THEN
2756 l_return_status := FND_API.G_RET_STS_ERROR;
2757 FND_MESSAGE.SET_NAME('ONT','OE_VPM_CC_NUM_REQUIRED');
2758 OE_MSG_PUB.ADD;
2759 ELSIF p_header_rec.credit_card_expiration_date is NULL THEN
2760 l_return_status := FND_API.G_RET_STS_ERROR;
2761 FND_MESSAGE.SET_NAME('ONT','OE_VPM_CC_EXP_DT_REQUIRED');
2762 OE_MSG_PUB.ADD;
2763 ELSIF p_header_rec.credit_card_holder_name is NULL THEN
2764 l_return_status := FND_API.G_RET_STS_ERROR;
2765 FND_MESSAGE.SET_NAME('ONT','OE_VPM_CC_HOLDER_REQUIRED');
2766 OE_MSG_PUB.ADD;
2767 END IF;
2768 END IF;*/
2769
2770 -- Done validating entity
2771 x_return_status := l_return_status;
2772
2773 oe_debug_pub.add('Exit OE_VALIDATE_HEADER.ENTITY',1);
2774
2775 EXCEPTION
2776
2777 WHEN FND_API.G_EXC_ERROR THEN
2778 x_return_status := FND_API.G_RET_STS_ERROR;
2779
2780 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2781 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2782
2783 WHEN OTHERS THEN
2784 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2785
2786 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2787 THEN
2788 OE_MSG_PUB.Add_Exc_Msg
2789 ( G_PKG_NAME
2790 , 'Entity'
2791 );
2792 END IF;
2793
2794 END Entity;
2795
2796
2797
2798 /*-------------------------------------------------------
2799 PROCEDURE: Attributes
2800 Description:
2801 --------------------------------------------------------*/
2802
2803 PROCEDURE Attributes
2804 ( x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
2805 , p_x_header_rec IN OUT NOCOPY OE_Order_PUB.Header_Rec_Type
2806 , p_old_header_rec IN OE_Order_PUB.Header_Rec_Type :=
2807 OE_Order_PUB.G_MISS_HEADER_REC
2808 , p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL
2809 )
2810 IS
2811 l_cc_security_code_use Varchar2(20);
2812 l_auth_exist varchar2(10); --Bug# 16099743
2813 BEGIN
2814
2815 oe_debug_pub.add('Entering OE_VALIDATE_HEADER.ATTRIBUTES',1);
2816
2817 x_return_status := FND_API.G_RET_STS_SUCCESS;
2818
2819 -- Validate header attributes
2820 /* Bug 5060064 - PC firing inappropriately for Order Import.
2821 To fix the issue we are now passing in old header rec same
2822 as new header rec, before calling process_order. B'cas of this
2823 old rec and new rec may have the same values. To make sure that
2824 validation is done for the attributes during CREATE added an
2825 additional check of
2826 OR
2827 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
2828 in all the conditions.
2829 */
2830
2831 IF p_x_header_rec.accounting_rule_id IS NOT NULL AND
2832 ( ( p_x_header_rec.accounting_rule_id <>
2833 p_old_header_rec.accounting_rule_id OR
2834 p_old_header_rec.accounting_rule_id IS NULL ) OR
2835 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
2836 --bug 5060064
2837 THEN
2838
2839 IF NOT OE_Validate.Accounting_Rule(p_x_header_rec.accounting_rule_id)
2840 THEN
2841
2842 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
2843 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
2844 THEN
2845 p_x_header_rec.accounting_rule_id := NULL;
2846 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
2847 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
2848 THEN
2849 p_x_header_rec.accounting_rule_id := FND_API.G_MISS_NUM;
2850 ELSE
2851 x_return_status := FND_API.G_RET_STS_ERROR;
2852 END IF;
2853
2854 END IF;
2855
2856 END IF;
2857
2858 IF p_x_header_rec.accounting_rule_duration IS NOT NULL AND
2859 ( (p_x_header_rec.accounting_rule_duration <>
2860 p_old_header_rec.accounting_rule_duration OR
2861 p_old_header_rec.accounting_rule_duration IS NULL ) OR
2862 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
2863 --bug 5060064
2864 THEN
2865
2866 IF NOT OE_Validate.Accounting_Rule_Duration(p_x_header_rec.accounting_rule_duration)
2867 THEN
2868
2869 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
2870 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
2871 THEN
2872 p_x_header_rec.accounting_rule_duration := NULL;
2873 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
2874 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
2875 THEN
2876 p_x_header_rec.accounting_rule_duration := FND_API.G_MISS_NUM;
2877 ELSE
2878 x_return_status := FND_API.G_RET_STS_ERROR;
2879 END IF;
2880
2881 END IF;
2882
2883 END IF;
2884
2885 IF p_x_header_rec.agreement_id IS NOT NULL AND
2886 ( ( p_x_header_rec.agreement_id <>
2887 p_old_header_rec.agreement_id OR
2888 p_old_header_rec.agreement_id IS NULL ) OR
2889 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
2890 --bug 5060064
2891 THEN
2892
2893 IF NOT OE_Validate.Agreement(p_x_header_rec.agreement_id)
2894 THEN
2895 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
2896 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
2897 THEN
2898 p_x_header_rec.agreement_id := NULL;
2899 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
2900 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
2901 THEN
2902 p_x_header_rec.agreement_id := FND_API.G_MISS_NUM;
2903 ELSE
2904 x_return_status := FND_API.G_RET_STS_ERROR;
2905 END IF;
2906 END IF;
2907
2908 END IF;
2909
2910 oe_debug_pub.add('sarita:p_x_header_rec.booked_flag :'||
2911 p_x_header_rec.booked_flag);
2912
2913 IF p_x_header_rec.booked_flag IS NOT NULL AND
2914 ( ( p_x_header_rec.booked_flag <>
2915 p_old_header_rec.booked_flag OR
2916 p_old_header_rec.booked_flag IS NULL ) OR
2917 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
2918 --bug 5060064
2919 THEN
2920 oe_debug_pub.add('sarita:before validate booked flag');
2921
2922 IF NOT OE_Validate.Booked(p_x_header_rec.booked_flag)
2923 THEN
2924 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
2925 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
2926 THEN
2927 p_x_header_rec.booked_flag := NULL;
2928 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
2929 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
2930 THEN
2931 p_x_header_rec.booked_flag := FND_API.G_MISS_CHAR;
2932 ELSE
2933 x_return_status := FND_API.G_RET_STS_ERROR;
2934 END IF;
2935 END IF;
2936
2937 END IF;
2938
2939 IF p_x_header_rec.cancelled_flag IS NOT NULL AND
2940 ( (p_x_header_rec.cancelled_flag <>
2941 p_old_header_rec.cancelled_flag OR
2942 p_old_header_rec.cancelled_flag IS NULL ) OR
2943 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
2944 --bug 5060064
2945 THEN
2946
2947 IF NOT OE_Validate.Cancelled(p_x_header_rec.cancelled_flag)
2948 THEN
2949 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
2950 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
2951 THEN
2952 p_x_header_rec.cancelled_flag := NULL;
2953 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
2954 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
2955 THEN
2956 p_x_header_rec.cancelled_flag := FND_API.G_MISS_CHAR;
2957 ELSE
2958 x_return_status := FND_API.G_RET_STS_ERROR;
2959 END IF;
2960 END IF;
2961
2962 END IF;
2963
2964 IF p_x_header_rec.conversion_type_code IS NOT NULL AND
2965 ( (p_x_header_rec.conversion_type_code <>
2966 p_old_header_rec.conversion_type_code OR
2967 p_old_header_rec.conversion_type_code IS NULL ) OR
2968 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
2969 --bug 5060064
2970 THEN
2971
2972 IF NOT OE_Validate.Conversion_Type(p_x_header_rec.conversion_type_code)
2973 THEN
2974 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
2975 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
2976 THEN
2977 p_x_header_rec.conversion_type_code := NULL;
2978 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
2979 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
2980 THEN
2981 p_x_header_rec.conversion_type_code := FND_API.G_MISS_CHAR;
2982 ELSE
2983 x_return_status := FND_API.G_RET_STS_ERROR;
2984 END IF;
2985 END IF;
2986
2987 END IF;
2988
2989 IF p_x_header_rec.deliver_to_contact_id IS NOT NULL AND
2990 ( (p_x_header_rec.deliver_to_contact_id <>
2991 p_old_header_rec.deliver_to_contact_id OR
2992 p_old_header_rec.deliver_to_contact_id IS NULL ) OR
2993 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
2994 --bug 5060064
2995 THEN
2996
2997 IF NOT OE_Validate.Deliver_To_Contact(p_x_header_rec.deliver_to_contact_id) THEN
2998 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
2999 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3000 THEN
3001 p_x_header_rec.deliver_to_contact_id := NULL;
3002 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3003 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3004 THEN
3005 p_x_header_rec.deliver_to_contact_id := FND_API.G_MISS_NUM;
3006 ELSE
3007 x_return_status := FND_API.G_RET_STS_ERROR;
3008 END IF;
3009 END IF;
3010
3011 END IF;
3012
3013 IF p_x_header_rec.deliver_to_org_id IS NOT NULL AND
3014 ( ( p_x_header_rec.deliver_to_org_id <>
3015 p_old_header_rec.deliver_to_org_id OR
3016 p_old_header_rec.deliver_to_org_id IS NULL ) OR
3017 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3018 --bug 5060064
3019 THEN
3020
3021 IF NOT OE_Validate.Deliver_To_Org(p_x_header_rec.deliver_to_org_id)
3022 THEN
3023 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3024 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3025 THEN
3026 p_x_header_rec.deliver_to_org_id := NULL;
3027 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3028 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3029 THEN
3030 p_x_header_rec.deliver_to_org_id := FND_API.G_MISS_NUM;
3031 ELSE
3032 x_return_status := FND_API.G_RET_STS_ERROR;
3033 END IF;
3034 END IF;
3035
3036 END IF;
3037
3038 IF p_x_header_rec.demAND_class_code IS NOT NULL AND
3039 ( (p_x_header_rec.demAND_class_code <>
3040 p_old_header_rec.demAND_class_code OR
3041 p_old_header_rec.demAND_class_code IS NULL ) OR
3042 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3043 --bug 5060064
3044 THEN
3045
3046 IF NOT OE_Validate.DemAND_Class(p_x_header_rec.demAND_class_code)
3047 THEN
3048 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3049 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3050 THEN
3051 p_x_header_rec.demAND_class_code := NULL;
3052 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3053 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3054 THEN
3055 p_x_header_rec.demAND_class_code := FND_API.G_MISS_CHAR;
3056 ELSE
3057 x_return_status := FND_API.G_RET_STS_ERROR;
3058 END IF;
3059 END IF;
3060
3061 END IF;
3062
3063 IF p_x_header_rec.fob_point_code IS NOT NULL AND
3064 ( ( p_x_header_rec.fob_point_code <>
3065 p_old_header_rec.fob_point_code OR
3066 p_old_header_rec.fob_point_code IS NULL ) OR
3067 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3068 --bug 5060064
3069 THEN
3070
3071 IF NOT OE_Validate.Fob_Point(p_x_header_rec.fob_point_code)
3072 THEN
3073 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3074 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3075 THEN
3076 p_x_header_rec.fob_point_code := NULL;
3077 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3078 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3079 THEN
3080 p_x_header_rec.fob_point_code := FND_API.G_MISS_CHAR;
3081 ELSE
3082 x_return_status := FND_API.G_RET_STS_ERROR;
3083 END IF;
3084 END IF;
3085
3086 END IF;
3087
3088 IF p_x_header_rec.freight_terms_code IS NOT NULL AND
3089 ( (p_x_header_rec.freight_terms_code <>
3090 p_old_header_rec.freight_terms_code OR
3091 p_old_header_rec.freight_terms_code IS NULL ) OR
3092 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3093 --bug 5060064
3094 THEN
3095
3096 IF NOT OE_Validate.Freight_Terms(p_x_header_rec.freight_terms_code)
3097 THEN
3098 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3099 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3100 THEN
3101 p_x_header_rec.freight_terms_code := NULL;
3102 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3103 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3104 THEN
3105 p_x_header_rec.freight_terms_code := FND_API.G_MISS_CHAR;
3106 ELSE
3107 x_return_status := FND_API.G_RET_STS_ERROR;
3108 END IF;
3109 END IF;
3110
3111 END IF;
3112
3113 IF p_x_header_rec.invoice_to_contact_id IS NOT NULL AND
3114 ( (p_x_header_rec.invoice_to_contact_id <>
3115 p_old_header_rec.invoice_to_contact_id OR
3116 p_old_header_rec.invoice_to_contact_id IS NULL ) OR
3117 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3118 --bug 5060064
3119 THEN
3120
3121 IF NOT OE_Validate.Invoice_To_Contact(p_x_header_rec.invoice_to_contact_id) THEN
3122 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3123 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3124 THEN
3125 p_x_header_rec.invoice_to_contact_id := NULL;
3126 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3127 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3128 THEN
3129 p_x_header_rec.invoice_to_contact_id := FND_API.G_MISS_NUM;
3130 ELSE
3131 x_return_status := FND_API.G_RET_STS_ERROR;
3132 END IF;
3133 END IF;
3134
3135 END IF;
3136
3137 IF p_x_header_rec.invoice_to_org_id IS NOT NULL AND
3138 ( (p_x_header_rec.invoice_to_org_id <>
3139 p_old_header_rec.invoice_to_org_id OR
3140 p_old_header_rec.invoice_to_org_id IS NULL ) OR
3141 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3142 --bug 5060064
3143 THEN
3144
3145 IF NOT OE_Validate.Invoice_To_Org(p_x_header_rec.invoice_to_org_id)
3146 THEN
3147 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3148 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3149 THEN
3150 p_x_header_rec.invoice_to_org_id := NULL;
3151 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3152 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3153 THEN
3154 p_x_header_rec.invoice_to_org_id := FND_API.G_MISS_NUM;
3155 ELSE
3156 x_return_status := FND_API.G_RET_STS_ERROR;
3157 END IF;
3158 END IF;
3159
3160 END IF;
3161
3162 IF p_x_header_rec.invoicing_rule_id IS NOT NULL AND
3163 ( ( p_x_header_rec.invoicing_rule_id <>
3164 p_old_header_rec.invoicing_rule_id OR
3165 p_old_header_rec.invoicing_rule_id IS NULL ) OR
3166 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3167 --bug 5060064
3168 THEN
3169
3170 IF NOT OE_Validate.Invoicing_Rule(p_x_header_rec.invoicing_rule_id)
3171 THEN
3172 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3173 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3174 THEN
3175 p_x_header_rec.invoicing_rule_id := NULL;
3176 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3177 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3178 THEN
3179 p_x_header_rec.invoicing_rule_id := FND_API.G_MISS_NUM;
3180 ELSE
3181 x_return_status := FND_API.G_RET_STS_ERROR;
3182 END IF;
3183 END IF;
3184
3185 END IF;
3186
3187 IF p_x_header_rec.open_flag IS NOT NULL AND
3188 ( (p_x_header_rec.open_flag <>
3189 p_old_header_rec.open_flag OR
3190 p_old_header_rec.open_flag IS NULL ) OR
3191 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3192 --bug 5060064
3193 THEN
3194
3195 IF NOT OE_Validate.Open(p_x_header_rec.open_flag)
3196 THEN
3197 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3198 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3199 THEN
3200 p_x_header_rec.open_flag := NULL;
3201 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3202 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3203 THEN
3204 p_x_header_rec.open_flag := FND_API.G_MISS_CHAR;
3205 ELSE
3206 x_return_status := FND_API.G_RET_STS_ERROR;
3207 END IF;
3208 END IF;
3209
3210 END IF;
3211
3212 IF p_x_header_rec.order_date_type_code IS NOT NULL AND
3213 ( (p_x_header_rec.order_date_type_code <>
3214 p_old_header_rec.order_date_type_code OR
3215 p_old_header_rec.order_date_type_code IS NULL ) OR
3216 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3217 --bug 5060064
3218 THEN
3219
3220 IF NOT OE_Validate.Order_Date_Type_Code
3221 (p_x_header_rec.order_date_type_code)
3222 THEN
3223 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3224 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3225 THEN
3226 p_x_header_rec.order_date_type_code := NULL;
3227 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3228 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3229 THEN
3230 p_x_header_rec.order_date_type_code := FND_API.G_MISS_CHAR;
3231 ELSE
3232 x_return_status := FND_API.G_RET_STS_ERROR;
3233 END IF;
3234 END IF;
3235
3236 END IF;
3237
3238 oe_debug_pub.add('sarita: p_x_header_rec.order_type_id:'||
3239 p_x_header_rec.order_type_id);
3240 oe_debug_pub.add('sarita: p_old_header_rec.order_type_id:'||
3241 p_old_header_rec.order_type_id);
3242
3243 IF p_x_header_rec.order_type_id IS NOT NULL AND
3244 ( (p_x_header_rec.order_type_id <>
3245 p_old_header_rec.order_type_id OR
3246 p_old_header_rec.order_type_id IS NULL ) OR
3247 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3248 --bug 5060064
3249 THEN
3250 oe_debug_pub.add('Before OE_Validate.Order_Type');
3251
3252 IF NOT OE_Validate.Order_Type(p_x_header_rec.order_type_id)
3253 THEN
3254 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3255 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3256 THEN
3257 p_x_header_rec.order_type_id := NULL;
3258 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3259 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3260 THEN
3261 p_x_header_rec.order_type_id := FND_API.G_MISS_NUM;
3262 ELSE
3263 x_return_status := FND_API.G_RET_STS_ERROR;
3264 END IF;
3265 END IF;
3266
3267 END IF;
3268
3269 IF p_x_header_rec.payment_term_id IS NOT NULL AND
3270 ( (p_x_header_rec.payment_term_id <>
3271 p_old_header_rec.payment_term_id OR
3272 p_old_header_rec.payment_term_id IS NULL ) OR
3273 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3274 --bug 5060064
3275 THEN
3276
3277 IF NOT OE_Validate.Payment_Term(p_x_header_rec.payment_term_id)
3278 THEN
3279 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3280 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3281 THEN
3282 p_x_header_rec.payment_term_id := NULL;
3283 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3284 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3285 THEN
3286 p_x_header_rec.payment_term_id := FND_API.G_MISS_NUM;
3287 ELSE
3288 x_return_status := FND_API.G_RET_STS_ERROR;
3289 END IF;
3290 END IF;
3291
3292 END IF;
3293
3294 IF p_x_header_rec.price_list_id IS NOT NULL AND
3295 ( (p_x_header_rec.price_list_id <>
3296 p_old_header_rec.price_list_id OR
3297 p_old_header_rec.price_list_id IS NULL ) OR
3298 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3299 --bug 5060064
3300 THEN
3301
3302 IF NOT OE_Validate.Price_List(p_x_header_rec.price_list_id)
3303 THEN
3304 -- Bug 3572931 Commented the code below.
3305 -- p_x_header_rec.price_list_id := NULL;
3306 -- ELSE
3307 -- IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3308 -- p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3309 -- THEN
3310 -- x_return_status := FND_API.G_RET_STS_ERROR;
3311 -- END IF;
3312 -- Bug 3572931 if the validation level is partial set to NULL,
3313 -- if partial with defaulting set to G_MISS_NUM.
3314 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3315 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3316 THEN
3317 p_x_header_rec.price_list_id := NULL;
3318 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3319 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3320 THEN
3321 p_x_header_rec.price_list_id := FND_API.G_MISS_NUM;
3322 ELSE
3323 x_return_status := FND_API.G_RET_STS_ERROR;
3324 END IF;
3325 END IF;
3326
3327 END IF;
3328
3329 IF p_x_header_rec.shipment_priority_code IS NOT NULL AND
3330 ( (p_x_header_rec.shipment_priority_code <>
3331 p_old_header_rec.shipment_priority_code OR
3332 p_old_header_rec.shipment_priority_code IS NULL ) OR
3333 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3334 --bug 5060064
3335 THEN
3336
3337 IF NOT OE_Validate.Shipment_Priority(p_x_header_rec.shipment_priority_code) THEN
3338 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3339 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3340 THEN
3341 p_x_header_rec.shipment_priority_code := NULL;
3342 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3343 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3344 THEN
3345 p_x_header_rec.shipment_priority_code := FND_API.G_MISS_CHAR;
3346 ELSE
3347 x_return_status := FND_API.G_RET_STS_ERROR;
3348 END IF;
3349 END IF;
3350
3351 END IF;
3352
3353 IF p_x_header_rec.shipping_method_code IS NOT NULL AND
3354 ( (p_x_header_rec.shipping_method_code <>
3355 p_old_header_rec.shipping_method_code OR
3356 p_old_header_rec.shipping_method_code IS NULL ) OR
3357 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3358 --bug 5060064
3359 THEN
3360
3361 IF NOT OE_Validate.Shipping_Method(p_x_header_rec.shipping_method_code)
3362 THEN
3363 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3364 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3365 THEN
3366 p_x_header_rec.shipping_method_code := NULL;
3367 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3368 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3369 THEN
3370 p_x_header_rec.shipping_method_code := FND_API.G_MISS_CHAR;
3371 ELSE
3372 x_return_status := FND_API.G_RET_STS_ERROR;
3373 END IF;
3374 END IF;
3375
3376 END IF;
3377
3378 IF p_x_header_rec.ship_from_org_id IS NOT NULL AND
3379 ( (p_x_header_rec.ship_from_org_id <>
3380 p_old_header_rec.ship_from_org_id OR
3381 p_old_header_rec.ship_from_org_id IS NULL ) OR
3382 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3383 --bug 5060064
3384 THEN
3385
3386 IF NOT OE_Validate.Ship_From_Org(p_x_header_rec.ship_from_org_id)
3387 THEN
3388 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3389 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3390 THEN
3391 p_x_header_rec.ship_from_org_id := NULL;
3392 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3393 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3394 THEN
3395 p_x_header_rec.ship_from_org_id := FND_API.G_MISS_NUM;
3396 ELSE
3397 x_return_status := FND_API.G_RET_STS_ERROR;
3398 END IF;
3399 END IF;
3400
3401 END IF;
3402
3403 IF p_x_header_rec.ship_to_contact_id IS NOT NULL AND
3404 ( (p_x_header_rec.ship_to_contact_id <>
3405 p_old_header_rec.ship_to_contact_id OR
3406 p_old_header_rec.ship_to_contact_id IS NULL ) OR
3407 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3408 --bug 5060064
3409 THEN
3410
3411 IF NOT OE_Validate.Ship_To_Contact(p_x_header_rec.ship_to_contact_id)
3412 THEN
3413 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3414 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3415 THEN
3416 p_x_header_rec.ship_to_contact_id := NULL;
3417 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3418 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3419 THEN
3420 p_x_header_rec.ship_to_contact_id := FND_API.G_MISS_NUM;
3421 ELSE
3422 x_return_status := FND_API.G_RET_STS_ERROR;
3423 END IF;
3424 END IF;
3425
3426 END IF;
3427
3428 IF p_x_header_rec.ship_to_org_id IS NOT NULL AND
3429 ( (p_x_header_rec.ship_to_org_id <>
3430 p_old_header_rec.ship_to_org_id OR
3431 p_old_header_rec.ship_to_org_id IS NULL ) OR
3432 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3433 --bug 5060064
3434 THEN
3435
3436 IF NOT OE_Validate.Ship_To_Org(p_x_header_rec.ship_to_org_id)
3437 THEN
3438 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3439 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3440 THEN
3441 p_x_header_rec.ship_to_org_id := NULL;
3442 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3443 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3444 THEN
3445 p_x_header_rec.ship_to_org_id := FND_API.G_MISS_NUM;
3446 ELSE
3447 x_return_status := FND_API.G_RET_STS_ERROR;
3448 END IF;
3449 END IF;
3450
3451 END IF;
3452
3453
3454 IF p_x_header_rec.sold_to_contact_id IS NOT NULL AND
3455 ( (p_x_header_rec.sold_to_contact_id <>
3456 p_old_header_rec.sold_to_contact_id OR
3457 p_old_header_rec.sold_to_contact_id IS NULL ) OR
3458 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3459 --bug 5060064
3460 THEN
3461
3462 IF NOT OE_Validate.Sold_To_Contact(p_x_header_rec.sold_to_contact_id)
3463 THEN
3464 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3465 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3466 THEN
3467 p_x_header_rec.sold_to_contact_id := NULL;
3468 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3469 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3470 THEN
3471 p_x_header_rec.sold_to_contact_id := FND_API.G_MISS_NUM;
3472 ELSE
3473 x_return_status := FND_API.G_RET_STS_ERROR;
3474 END IF;
3475 END IF;
3476
3477 END IF;
3478
3479 IF p_x_header_rec.sold_to_org_id IS NOT NULL AND
3480 ( (p_x_header_rec.sold_to_org_id <>
3481 p_old_header_rec.sold_to_org_id OR
3482 p_old_header_rec.sold_to_org_id IS NULL ) OR
3483 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3484 --bug 5060064
3485 THEN
3486
3487 IF NOT OE_Validate.Sold_To_Org(p_x_header_rec.sold_to_org_id)
3488 THEN
3489 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3490 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3491 THEN
3492 p_x_header_rec.sold_to_org_id := NULL;
3493 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3494 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3495 THEN
3496 p_x_header_rec.sold_to_org_id := FND_API.G_MISS_NUM;
3497 ELSE
3498 x_return_status := FND_API.G_RET_STS_ERROR;
3499 END IF;
3500 END IF;
3501
3502 END IF;
3503
3504 IF p_x_header_rec.sold_to_phone_id IS NOT NULL AND
3505 ( (p_x_header_rec.sold_to_phone_id <>
3506 p_old_header_rec.sold_to_phone_id OR
3507 p_old_header_rec.sold_to_phone_id IS NULL ) OR
3508 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3509 --bug 5060064
3510 THEN
3511
3512 IF NOT OE_Validate.Sold_To_Phone(p_x_header_rec.sold_to_phone_id)
3513 THEN
3514 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3515 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3516 THEN
3517 p_x_header_rec.sold_to_phone_id := NULL;
3518 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3519 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3520 THEN
3521 p_x_header_rec.sold_to_phone_id := FND_API.G_MISS_NUM;
3522 ELSE
3523 x_return_status := FND_API.G_RET_STS_ERROR;
3524 END IF;
3525 END IF;
3526
3527 END IF;
3528
3529 IF p_x_header_rec.source_document_type_id IS NOT NULL AND
3530 ( (p_x_header_rec.source_document_type_id <>
3531 p_old_header_rec.source_document_type_id OR
3532 p_old_header_rec.source_document_type_id IS NULL ) OR
3533 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3534 --bug 5060064
3535 THEN
3536
3537 IF NOT OE_Validate.Source_Document_Type
3538 (p_x_header_rec.source_document_type_id)
3539 THEN
3540 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3541 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3542 THEN
3543 p_x_header_rec.source_document_type_id := NULL;
3544 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3545 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3546 THEN
3547 p_x_header_rec.source_document_type_id := FND_API.G_MISS_NUM;
3548 ELSE
3549 x_return_status := FND_API.G_RET_STS_ERROR;
3550 END IF;
3551 END IF;
3552
3553 END IF;
3554
3555 IF p_x_header_rec.tax_exempt_flag IS NOT NULL AND
3556 ( (p_x_header_rec.tax_exempt_flag <>
3557 p_old_header_rec.tax_exempt_flag OR
3558 p_old_header_rec.tax_exempt_flag IS NULL ) OR
3559 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3560 --bug 5060064
3561 THEN
3562 IF NOT OE_Validate.Tax_Exempt(p_x_header_rec.tax_exempt_flag)
3563 THEN
3564 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3565 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3566 THEN
3567 p_x_header_rec.tax_exempt_flag := NULL;
3568 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3569 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3570 THEN
3571 p_x_header_rec.tax_exempt_flag := FND_API.G_MISS_CHAR;
3572 ELSE
3573 x_return_status := FND_API.G_RET_STS_ERROR;
3574 END IF;
3575 END IF;
3576
3577 END IF;
3578
3579 IF p_x_header_rec.tax_exempt_reason_code IS NOT NULL AND
3580 ( (p_x_header_rec.tax_exempt_reason_code <>
3581 p_old_header_rec.tax_exempt_reason_code OR
3582 p_old_header_rec.tax_exempt_reason_code IS NULL ) OR
3583 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3584 --bug 5060064
3585 THEN
3586
3587 IF NOT OE_Validate.Tax_Exempt_Reason
3588 (p_x_header_rec.tax_exempt_reason_code)
3589 THEN
3590 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3591 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3592 THEN
3593 p_x_header_rec.tax_exempt_reason_code := NULL;
3594 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3595 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3596 THEN
3597 p_x_header_rec.tax_exempt_reason_code := FND_API.G_MISS_CHAR;
3598 ELSE
3599 x_return_status := FND_API.G_RET_STS_ERROR;
3600 END IF;
3601 END IF;
3602
3603 END IF;
3604
3605 IF p_x_header_rec.tax_point_code IS NOT NULL AND
3606 ( ( p_x_header_rec.tax_point_code <>
3607 p_old_header_rec.tax_point_code OR
3608 p_old_header_rec.tax_point_code IS NULL ) OR
3609 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3610 --bug 5060064
3611 THEN
3612
3613 IF NOT OE_Validate.Tax_Point(p_x_header_rec.tax_point_code)
3614 THEN
3615 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3616 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3617 THEN
3618 p_x_header_rec.tax_point_code := NULL;
3619 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3620 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3621 THEN
3622 p_x_header_rec.tax_point_code := FND_API.G_MISS_CHAR;
3623 ELSE
3624 x_return_status := FND_API.G_RET_STS_ERROR;
3625 END IF;
3626 END IF;
3627
3628 END IF;
3629
3630 IF p_x_header_rec.transactional_curr_code IS NOT NULL AND
3631 ( (p_x_header_rec.transactional_curr_code <>
3632 p_old_header_rec.transactional_curr_code OR
3633 p_old_header_rec.transactional_curr_code IS NULL ) OR
3634 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3635 --bug 5060064
3636 THEN
3637
3638 IF NOT OE_Validate.Transactional_Curr
3639 (p_x_header_rec.transactional_curr_code)
3640 THEN
3641 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3642 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3643 THEN
3644 p_x_header_rec.transactional_curr_code := NULL;
3645 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3646 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3647 THEN
3648 p_x_header_rec.transactional_curr_code := FND_API.G_MISS_CHAR;
3649 ELSE
3650 x_return_status := FND_API.G_RET_STS_ERROR;
3651 END IF;
3652 END IF;
3653
3654 END IF;
3655
3656 IF p_x_header_rec.payment_type_code IS NOT NULL AND
3657 ( (p_x_header_rec.payment_type_code <>
3658 p_old_header_rec.payment_type_code OR
3659 p_old_header_rec.payment_type_code IS NULL ) OR
3660 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3661 --bug 5060064
3662 THEN
3663
3664 IF NOT OE_Validate.Payment_Type(p_x_header_rec.payment_type_code)
3665 THEN
3666 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3667 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3668 THEN
3669 p_x_header_rec.payment_type_code := NULL;
3670 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3671 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3672 THEN
3673 p_x_header_rec.payment_type_code := FND_API.G_MISS_CHAR;
3674 ELSE
3675 x_return_status := FND_API.G_RET_STS_ERROR;
3676 END IF;
3677 END IF;
3678
3679 END IF;
3680
3681 oe_debug_pub.add('after payment_type_code');
3682
3683 IF p_x_header_rec.credit_card_code IS NOT NULL AND
3684 ( ( p_x_header_rec.credit_card_code <>
3685 p_old_header_rec.credit_card_code OR
3686 p_old_header_rec.credit_card_code IS NULL ) OR
3687 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3688 --bug 5060064
3689 THEN
3690 IF NOT OE_Validate.Credit_Card(p_x_header_rec.credit_card_code)
3691 THEN
3692 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3693 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3694 THEN
3695 p_x_header_rec.credit_card_code := NULL;
3696 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3697 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3698 THEN
3699 p_x_header_rec.credit_card_code := FND_API.G_MISS_CHAR;
3700 ELSE
3701 x_return_status := FND_API.G_RET_STS_ERROR;
3702 END IF;
3703 END IF;
3704
3705 END IF;
3706
3707 oe_debug_pub.add('after credit_card_code');
3708
3709 --R12 CVV2
3710 IF p_x_header_rec.credit_card_number IS NOT NULL AND p_x_header_rec.credit_card_number <> FND_API.G_MISS_CHAR THEN
3711 l_cc_security_code_use := OE_Payment_Trxn_Util.Get_CC_Security_Code_Use;
3712 IF l_cc_security_code_use = 'REQUIRED' THEN
3713 IF p_x_header_rec.instrument_security_code IS NULL OR p_x_header_rec.instrument_security_code = FND_API.G_MISS_CHAR THEN --bug 4613168, issue 22
3714 --Bug# 16099743 Start
3715 BEGIN
3716 SELECT 'Y'
3717 INTO l_auth_exist
3718 FROM iby_trxn_ext_auths_v iby_auth ,
3719 oe_payments op
3720 WHERE iby_auth.trxn_extension_id = op.trxn_extension_id
3721 AND NVL(iby_auth.authorization_amount,0) > 0
3722 AND iby_auth.authorization_status =0
3723 AND op.payment_level_code ='ORDER'
3724 AND op.payment_type_code ='CREDIT_CARD'
3725 AND op.PAYMENT_COLLECTION_EVENT ='INVOICE'
3726 AND op.header_id =p_x_header_rec.header_id;
3727 EXCEPTION
3728 WHEN OTHERS THEN
3729 l_auth_exist := 'N';
3730 END;
3731 IF nvl(l_auth_exist,'N') = 'N' THEN
3732 --Bug# 16099743 End
3733 FND_MESSAGE.SET_NAME('ONT','OE_CC_SECURITY_CODE_REQD');
3734 OE_MSG_PUB.ADD;
3735 x_return_status := FND_API.G_RET_STS_ERROR;
3736 END IF; --Bug# 16099743
3737 END IF;
3738 END IF;
3739 END IF;
3740 --R12 CVV2
3741
3742 oe_debug_pub.add('after security code');
3743
3744 IF p_x_header_rec.flow_status_code IS NOT NULL AND
3745 ( (p_x_header_rec.flow_status_code <>
3746 p_old_header_rec.flow_status_code OR
3747 p_old_header_rec.flow_status_code IS NULL ) OR
3748 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ))
3749 --bug 5060064
3750 THEN
3751
3752 IF NOT OE_Validate.Flow_Status(p_x_header_rec.flow_status_code)
3753 THEN
3754 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3755 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3756 THEN
3757 p_x_header_rec.flow_status_code := NULL;
3758 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3759 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3760 THEN
3761 p_x_header_rec.flow_status_code := FND_API.G_MISS_CHAR;
3762 ELSE
3763 x_return_status := FND_API.G_RET_STS_ERROR;
3764 END IF;
3765 END IF;
3766
3767 END IF;
3768
3769 oe_Debug_pub.add('after flow_status_code');
3770 if OE_GLOBALS.g_validate_desc_flex ='Y' then -- bug4343612
3771 oe_debug_pub.add('Validation of desc flex is set to Y in OE_Validate_Header.attributes ',1);
3772 IF p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE OR
3773
3774 ( p_x_header_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
3775 (p_x_header_rec.attribute1 IS NOT NULL AND
3776 ( p_x_header_rec.attribute1 <>
3777 p_old_header_rec.attribute1 OR
3778 p_old_header_rec.attribute1 IS NULL ))
3779 OR (p_x_header_rec.attribute10 IS NOT NULL AND
3780 ( p_x_header_rec.attribute10 <>
3781 p_old_header_rec.attribute10 OR
3782 p_old_header_rec.attribute10 IS NULL ))
3783 OR (p_x_header_rec.attribute11 IS NOT NULL AND
3784 ( p_x_header_rec.attribute11 <>
3785 p_old_header_rec.attribute11 OR
3786 p_old_header_rec.attribute11 IS NULL ))
3787 OR (p_x_header_rec.attribute12 IS NOT NULL AND
3788 ( p_x_header_rec.attribute12 <>
3789 p_old_header_rec.attribute12 OR
3790 p_old_header_rec.attribute12 IS NULL ))
3791 OR (p_x_header_rec.attribute13 IS NOT NULL AND
3792 ( p_x_header_rec.attribute13 <>
3793 p_old_header_rec.attribute13 OR
3794 p_old_header_rec.attribute13 IS NULL ))
3795 OR (p_x_header_rec.attribute14 IS NOT NULL AND
3796 ( p_x_header_rec.attribute14 <>
3797 p_old_header_rec.attribute14 OR
3798 p_old_header_rec.attribute14 IS NULL ))
3799 OR (p_x_header_rec.attribute15 IS NOT NULL AND
3800 ( p_x_header_rec.attribute15 <>
3801 p_old_header_rec.attribute15 OR
3802 p_old_header_rec.attribute15 IS NULL ))
3803 OR (p_x_header_rec.attribute16 IS NOT NULL AND --For bug 2184255
3804 ( p_x_header_rec.attribute16 <>
3805 p_old_header_rec.attribute16 OR
3806 p_old_header_rec.attribute16 IS NULL ))
3807 OR (p_x_header_rec.attribute17 IS NOT NULL AND
3808 ( p_x_header_rec.attribute17 <>
3809 p_old_header_rec.attribute17 OR
3810 p_old_header_rec.attribute17 IS NULL ))
3811 OR (p_x_header_rec.attribute18 IS NOT NULL AND
3812 ( p_x_header_rec.attribute18 <>
3813 p_old_header_rec.attribute18 OR
3814 p_old_header_rec.attribute18 IS NULL ))
3815 OR (p_x_header_rec.attribute19 IS NOT NULL AND
3816 ( p_x_header_rec.attribute19 <>
3817 p_old_header_rec.attribute19 OR
3818 p_old_header_rec.attribute19 IS NULL ))
3819 OR (p_x_header_rec.attribute2 IS NOT NULL AND
3820 ( p_x_header_rec.attribute2 <>
3821 p_old_header_rec.attribute2 OR
3822 p_old_header_rec.attribute2 IS NULL ))
3823 OR (p_x_header_rec.attribute20 IS NOT NULL AND -- for bug 2184255
3824 ( p_x_header_rec.attribute20 <>
3825 p_old_header_rec.attribute20 OR
3826 p_old_header_rec.attribute20 IS NULL ))
3827 OR (p_x_header_rec.attribute3 IS NOT NULL AND
3828 ( p_x_header_rec.attribute3 <>
3829 p_old_header_rec.attribute3 OR
3830 p_old_header_rec.attribute3 IS NULL ))
3831 OR (p_x_header_rec.attribute4 IS NOT NULL AND
3832 ( p_x_header_rec.attribute4 <>
3833 p_old_header_rec.attribute4 OR
3834 p_old_header_rec.attribute4 IS NULL ))
3835 OR (p_x_header_rec.attribute5 IS NOT NULL AND
3836 ( p_x_header_rec.attribute5 <>
3837 p_old_header_rec.attribute5 OR
3838 p_old_header_rec.attribute5 IS NULL ))
3839 OR (p_x_header_rec.attribute6 IS NOT NULL AND
3840 ( p_x_header_rec.attribute6 <>
3841 p_old_header_rec.attribute6 OR
3842 p_old_header_rec.attribute6 IS NULL ))
3843 OR (p_x_header_rec.attribute7 IS NOT NULL AND
3844 ( p_x_header_rec.attribute7 <>
3845 p_old_header_rec.attribute7 OR
3846 p_old_header_rec.attribute7 IS NULL ))
3847 OR (p_x_header_rec.attribute8 IS NOT NULL AND
3848 ( p_x_header_rec.attribute8 <>
3849 p_old_header_rec.attribute8 OR
3850 p_old_header_rec.attribute8 IS NULL ))
3851 OR (p_x_header_rec.attribute9 IS NOT NULL AND
3852 ( p_x_header_rec.attribute9 <>
3853 p_old_header_rec.attribute9 OR
3854 p_old_header_rec.attribute9 IS NULL ))
3855 OR (p_x_header_rec.context IS NOT NULL AND
3856 ( p_x_header_rec.context <>
3857 p_old_header_rec.context OR
3858 p_old_header_rec.context IS NULL )))
3859 THEN
3860
3861
3862 oe_debug_pub.add('Before calling header_desc_flex',2);
3863 oe_debug_pub.add('source doc type:'||to_char(p_x_header_rec.source_document_type_id),5);
3864 /* Fixing 2375476 to skip the Flex field validation in case of
3865 Internal Orders. This condition will be removed once process Order
3866 starts defaulting the FF */
3867 /* Fixing 2611912 to skip the Flex field validation in case of
3868 orders coming from CRM. This condition can be removed once process Order
3869 starts defaulting the FF */
3870 IF OE_ORDER_CACHE.IS_FLEX_ENABLED('OE_HEADER_ATTRIBUTES') = 'Y' THEN
3871 -- AND p_x_header_rec.order_source_id <> 10 AND -- added for 2611912
3872 -- (p_x_header_rec.source_document_type_id IS NULL OR
3873 -- p_x_header_rec.source_document_type_id = FND_API.G_MISS_NUM OR
3874 -- p_x_header_rec.source_document_type_id = 2) THEN
3875 -- commented above, bug 2511313
3876
3877 IF NOT OE_VALIDATE.Header_Desc_Flex
3878 (p_context => p_x_header_rec.context
3879 ,p_attribute1 => p_x_header_rec.attribute1
3880 ,p_attribute2 => p_x_header_rec.attribute2
3881 ,p_attribute3 => p_x_header_rec.attribute3
3882 ,p_attribute4 => p_x_header_rec.attribute4
3883 ,p_attribute5 => p_x_header_rec.attribute5
3884 ,p_attribute6 => p_x_header_rec.attribute6
3885 ,p_attribute7 => p_x_header_rec.attribute7
3886 ,p_attribute8 => p_x_header_rec.attribute8
3887 ,p_attribute9 => p_x_header_rec.attribute9
3888 ,p_attribute10 => p_x_header_rec.attribute10
3889 ,p_attribute11 => p_x_header_rec.attribute11
3890 ,p_attribute12 => p_x_header_rec.attribute12
3891 ,p_attribute13 => p_x_header_rec.attribute13
3892 ,p_attribute14 => p_x_header_rec.attribute14
3893 ,p_attribute15 => p_x_header_rec.attribute15
3894 ,p_attribute16 => p_x_header_rec.attribute16 -- for bug 2184255
3895 ,p_attribute17 => p_x_header_rec.attribute17
3896 ,p_attribute18 => p_x_header_rec.attribute18
3897 ,p_attribute19 => p_x_header_rec.attribute19
3898 ,p_attribute20 => p_x_header_rec.attribute20)
3899 THEN
3900
3901 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
3902 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3903 THEN
3904 p_x_header_rec.context := null;
3905 p_x_header_rec.attribute1 := null;
3906 p_x_header_rec.attribute2 := null;
3907 p_x_header_rec.attribute3 := null;
3908 p_x_header_rec.attribute4 := null;
3909 p_x_header_rec.attribute5 := null;
3910 p_x_header_rec.attribute6 := null;
3911 p_x_header_rec.attribute7 := null;
3912 p_x_header_rec.attribute8 := null;
3913 p_x_header_rec.attribute9 := null;
3914 p_x_header_rec.attribute10 := null;
3915 p_x_header_rec.attribute11 := null;
3916 p_x_header_rec.attribute12 := null;
3917 p_x_header_rec.attribute13 := null;
3918 p_x_header_rec.attribute14 := null;
3919 p_x_header_rec.attribute15 := null;
3920 p_x_header_rec.attribute16 := null; -- for bug 2184255
3921 p_x_header_rec.attribute17 := null;
3922 p_x_header_rec.attribute18 := null;
3923 p_x_header_rec.attribute19 := null;
3924 p_x_header_rec.attribute20 := null;
3925
3926
3927 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
3928 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
3929 THEN
3930 p_x_header_rec.context := FND_API.G_MISS_CHAR;
3931 p_x_header_rec.attribute1 := FND_API.G_MISS_CHAR;
3932 p_x_header_rec.attribute2 := FND_API.G_MISS_CHAR;
3933 p_x_header_rec.attribute3 := FND_API.G_MISS_CHAR;
3934 p_x_header_rec.attribute4 := FND_API.G_MISS_CHAR;
3935 p_x_header_rec.attribute5 := FND_API.G_MISS_CHAR;
3936 p_x_header_rec.attribute6 := FND_API.G_MISS_CHAR;
3937 p_x_header_rec.attribute7 := FND_API.G_MISS_CHAR;
3938 p_x_header_rec.attribute8 := FND_API.G_MISS_CHAR;
3939 p_x_header_rec.attribute9 := FND_API.G_MISS_CHAR;
3940 p_x_header_rec.attribute10 := FND_API.G_MISS_CHAR;
3941 p_x_header_rec.attribute11 := FND_API.G_MISS_CHAR;
3942 p_x_header_rec.attribute12 := FND_API.G_MISS_CHAR;
3943 p_x_header_rec.attribute13 := FND_API.G_MISS_CHAR;
3944 p_x_header_rec.attribute14 := FND_API.G_MISS_CHAR;
3945 p_x_header_rec.attribute15 := FND_API.G_MISS_CHAR;
3946 p_x_header_rec.attribute16 := FND_API.G_MISS_CHAR; -- for bug 2184255
3947 p_x_header_rec.attribute17 := FND_API.G_MISS_CHAR;
3948 p_x_header_rec.attribute18 := FND_API.G_MISS_CHAR;
3949 p_x_header_rec.attribute19 := FND_API.G_MISS_CHAR;
3950 p_x_header_rec.attribute20 := FND_API.G_MISS_CHAR;
3951
3952
3953 ELSE
3954 x_return_status := FND_API.G_RET_STS_ERROR;
3955 END IF;
3956 ELSE -- if the flex validation is successfull
3957 -- For bug 2511313
3958 IF p_x_header_rec.context IS NULL
3959 OR p_x_header_rec.context = FND_API.G_MISS_CHAR THEN
3960 p_x_header_rec.context := oe_validate.g_context;
3961 END IF;
3962
3963 IF p_x_header_rec.attribute1 IS NULL
3964 OR p_x_header_rec.attribute1 = FND_API.G_MISS_CHAR THEN
3965 p_x_header_rec.attribute1 := oe_validate.g_attribute1;
3966 END IF;
3967
3968 IF p_x_header_rec.attribute2 IS NULL
3969 OR p_x_header_rec.attribute2 = FND_API.G_MISS_CHAR THEN
3970 p_x_header_rec.attribute2 := oe_validate.g_attribute2;
3971 END IF;
3972
3973 IF p_x_header_rec.attribute3 IS NULL
3974 OR p_x_header_rec.attribute3 = FND_API.G_MISS_CHAR THEN
3975 p_x_header_rec.attribute3 := oe_validate.g_attribute3;
3976 END IF;
3977
3978 IF p_x_header_rec.attribute4 IS NULL
3979 OR p_x_header_rec.attribute4 = FND_API.G_MISS_CHAR THEN
3980 p_x_header_rec.attribute4 := oe_validate.g_attribute4;
3981 END IF;
3982
3983 IF p_x_header_rec.attribute5 IS NULL
3984 OR p_x_header_rec.attribute5 = FND_API.G_MISS_CHAR THEN
3985 p_x_header_rec.attribute5 := oe_validate.g_attribute5;
3986 END IF;
3987
3988 IF p_x_header_rec.attribute6 IS NULL
3989 OR p_x_header_rec.attribute6 = FND_API.G_MISS_CHAR THEN
3990 p_x_header_rec.attribute6 := oe_validate.g_attribute6;
3991 END IF;
3992
3993 IF p_x_header_rec.attribute7 IS NULL
3994 OR p_x_header_rec.attribute7 = FND_API.G_MISS_CHAR THEN
3995 p_x_header_rec.attribute7 := oe_validate.g_attribute7;
3996 END IF;
3997
3998 IF p_x_header_rec.attribute8 IS NULL
3999 OR p_x_header_rec.attribute8 = FND_API.G_MISS_CHAR THEN
4000 p_x_header_rec.attribute8 := oe_validate.g_attribute8;
4001 END IF;
4002
4003 IF p_x_header_rec.attribute9 IS NULL
4004 OR p_x_header_rec.attribute9 = FND_API.G_MISS_CHAR THEN
4005 p_x_header_rec.attribute9 := oe_validate.g_attribute9;
4006 END IF;
4007
4008 IF p_x_header_rec.attribute10 IS NULL
4009 OR p_x_header_rec.attribute10 = FND_API.G_MISS_CHAR THEN
4010 p_x_header_rec.attribute10 := Oe_validate.G_attribute10;
4011 End IF;
4012
4013 IF p_x_header_rec.attribute11 IS NULL
4014 OR p_x_header_rec.attribute11 = FND_API.G_MISS_CHAR THEN
4015 p_x_header_rec.attribute11 := oe_validate.g_attribute11;
4016 END IF;
4017
4018 IF p_x_header_rec.attribute12 IS NULL
4019 OR p_x_header_rec.attribute12 = FND_API.G_MISS_CHAR THEN
4020 p_x_header_rec.attribute12 := oe_validate.g_attribute12;
4021 END IF;
4022
4023 IF p_x_header_rec.attribute13 IS NULL
4024 OR p_x_header_rec.attribute13 = FND_API.G_MISS_CHAR THEN
4025 p_x_header_rec.attribute13 := oe_validate.g_attribute13;
4026 END IF;
4027
4028 IF p_x_header_rec.attribute14 IS NULL
4029 OR p_x_header_rec.attribute14 = FND_API.G_MISS_CHAR THEN
4030 p_x_header_rec.attribute14 := oe_validate.g_attribute14;
4031 END IF;
4032
4033 IF p_x_header_rec.attribute15 IS NULL
4034 OR p_x_header_rec.attribute15 = FND_API.G_MISS_CHAR THEN
4035 p_x_header_rec.attribute15 := oe_validate.g_attribute15;
4036 END IF;
4037
4038 IF p_x_header_rec.attribute16 IS NULL -- for bug 2184255
4039 OR p_x_header_rec.attribute16 = FND_API.G_MISS_CHAR THEN
4040 p_x_header_rec.attribute16 := oe_validate.g_attribute16;
4041 END IF;
4042
4043 IF p_x_header_rec.attribute17 IS NULL
4044 OR p_x_header_rec.attribute17 = FND_API.G_MISS_CHAR THEN
4045 p_x_header_rec.attribute17 := oe_validate.g_attribute17;
4046 END IF;
4047
4048 IF p_x_header_rec.attribute18 IS NULL
4049 OR p_x_header_rec.attribute18 = FND_API.G_MISS_CHAR THEN
4050 p_x_header_rec.attribute18 := oe_validate.g_attribute18;
4051 END IF;
4052
4053 IF p_x_header_rec.attribute19 IS NULL
4054 OR p_x_header_rec.attribute19 = FND_API.G_MISS_CHAR THEN
4055 p_x_header_rec.attribute19 := oe_validate.g_attribute19;
4056 END IF;
4057
4058 IF p_x_header_rec.attribute20 IS NULL
4059 OR p_x_header_rec.attribute20 = FND_API.G_MISS_CHAR THEN
4060 p_x_header_rec.attribute20 := oe_validate.g_attribute20;
4061 END IF;
4062
4063 -- end of assignments, bug 2511313
4064 END IF;
4065 END IF ; -- If flex enabled
4066 END IF;
4067
4068 oe_debug_pub.add('After header_desc_flex ' || x_return_status,2);
4069 IF p_x_header_rec.operation = oe_globals.g_opr_create OR
4070 ( p_x_header_rec.operation = oe_globals.g_opr_update AND
4071 (p_x_header_rec.global_attribute1 IS NOT NULL AND
4072 ( p_x_header_rec.global_attribute1 <>
4073 p_old_header_rec.global_attribute1 OR
4074 p_old_header_rec.global_attribute1 IS NULL ))
4075 OR (p_x_header_rec.global_attribute10 IS NOT NULL AND
4076 ( p_x_header_rec.global_attribute10 <>
4077 p_old_header_rec.global_attribute10 OR
4078 p_old_header_rec.global_attribute10 IS NULL ))
4079 OR (p_x_header_rec.global_attribute11 IS NOT NULL AND
4080 ( p_x_header_rec.global_attribute11 <>
4081 p_old_header_rec.global_attribute11 OR
4082 p_old_header_rec.global_attribute11 IS NULL ))
4083 OR (p_x_header_rec.global_attribute12 IS NOT NULL AND
4084 ( p_x_header_rec.global_attribute12 <>
4085 p_old_header_rec.global_attribute12 OR
4086 p_old_header_rec.global_attribute12 IS NULL ))
4087 OR (p_x_header_rec.global_attribute13 IS NOT NULL AND
4088 ( p_x_header_rec.global_attribute13 <>
4089 p_old_header_rec.global_attribute13 OR
4090 p_old_header_rec.global_attribute13 IS NULL ))
4091 OR (p_x_header_rec.global_attribute14 IS NOT NULL AND
4092 ( p_x_header_rec.global_attribute14 <>
4093 p_old_header_rec.global_attribute14 OR
4094 p_old_header_rec.global_attribute14 IS NULL ))
4095 OR (p_x_header_rec.global_attribute15 IS NOT NULL AND
4096 ( p_x_header_rec.global_attribute15 <>
4097 p_old_header_rec.global_attribute15 OR
4098 p_old_header_rec.global_attribute15 IS NULL ))
4099 OR (p_x_header_rec.global_attribute16 IS NOT NULL AND
4100 ( p_x_header_rec.global_attribute16 <>
4101 p_old_header_rec.global_attribute16 OR
4102 p_old_header_rec.global_attribute16 IS NULL ))
4103 OR (p_x_header_rec.global_attribute17 IS NOT NULL AND
4104 ( p_x_header_rec.global_attribute17 <>
4105 p_old_header_rec.global_attribute17 OR
4106 p_old_header_rec.global_attribute17 IS NULL ))
4107 OR (p_x_header_rec.global_attribute18 IS NOT NULL AND
4108 ( p_x_header_rec.global_attribute18 <>
4109 p_old_header_rec.global_attribute18 OR
4110 p_old_header_rec.global_attribute18 IS NULL ))
4111 OR (p_x_header_rec.global_attribute19 IS NOT NULL AND
4112 ( p_x_header_rec.global_attribute19 <>
4113 p_old_header_rec.global_attribute19 OR
4114 p_old_header_rec.global_attribute19 IS NULL ))
4115 OR (p_x_header_rec.global_attribute2 IS NOT NULL AND
4116 ( p_x_header_rec.global_attribute2 <>
4117 p_old_header_rec.global_attribute2 OR
4118 p_old_header_rec.global_attribute2 IS NULL ))
4119 OR (p_x_header_rec.global_attribute20 IS NOT NULL AND
4120 ( p_x_header_rec.global_attribute20 <>
4121 p_old_header_rec.global_attribute20 OR
4122 p_old_header_rec.global_attribute20 IS NULL ))
4123 OR (p_x_header_rec.global_attribute3 IS NOT NULL AND
4124 ( p_x_header_rec.global_attribute3 <>
4125 p_old_header_rec.global_attribute3 OR
4126 p_old_header_rec.global_attribute3 IS NULL ))
4127 OR (p_x_header_rec.global_attribute4 IS NOT NULL AND
4128 ( p_x_header_rec.global_attribute4 <>
4129 p_old_header_rec.global_attribute4 OR
4130 p_old_header_rec.global_attribute4 IS NULL ))
4131 OR (p_x_header_rec.global_attribute5 IS NOT NULL AND
4132 ( p_x_header_rec.global_attribute5 <>
4133 p_old_header_rec.global_attribute5 OR
4134 p_old_header_rec.global_attribute5 IS NULL ))
4135 OR (p_x_header_rec.global_attribute6 IS NOT NULL AND
4136 ( p_x_header_rec.global_attribute6 <>
4137 p_old_header_rec.global_attribute6 OR
4138 p_old_header_rec.global_attribute6 IS NULL ))
4139 OR (p_x_header_rec.global_attribute7 IS NOT NULL AND
4140 ( p_x_header_rec.global_attribute7 <>
4141 p_old_header_rec.global_attribute7 OR
4142 p_old_header_rec.global_attribute7 IS NULL ))
4143 OR (p_x_header_rec.global_attribute8 IS NOT NULL AND
4144 ( p_x_header_rec.global_attribute8 <>
4145 p_old_header_rec.global_attribute8 OR
4146 p_old_header_rec.global_attribute8 IS NULL ))
4147 OR (p_x_header_rec.global_attribute9 IS NOT NULL AND
4148 ( p_x_header_rec.global_attribute9 <>
4149 p_old_header_rec.global_attribute9 OR
4150 p_old_header_rec.global_attribute9 IS NULL ))
4151 OR (p_x_header_rec.global_attribute_category IS NOT NULL AND
4152 ( p_x_header_rec.global_attribute_category <>
4153 p_old_header_rec.global_attribute_category OR
4154 p_old_header_rec.global_attribute_category IS NULL )))
4155 THEN
4156
4157
4158
4159 OE_DEBUG_PUB.ADD('Before G_header_desc_flex',2);
4160 /* Fixing 2375476 to skip the Flex field validation in case of
4161 Internal Orders. This condition will be removed once process Order
4162 starts defaulting the FF */
4163 IF OE_ORDER_CACHE.IS_FLEX_ENABLED('OE_HEADER_GLOBAL_ATTRIBUTE') = 'Y' THEN
4164 -- AND p_x_header_rec.order_source_id <> 10 THEN
4165 IF NOT OE_VALIDATE.G_Header_Desc_Flex
4166 (p_context => p_x_header_rec.global_attribute_category
4167 ,p_attribute1 => p_x_header_rec.global_attribute1
4168 ,p_attribute2 => p_x_header_rec.global_attribute2
4169 ,p_attribute3 => p_x_header_rec.global_attribute3
4170 ,p_attribute4 => p_x_header_rec.global_attribute4
4171 ,p_attribute5 => p_x_header_rec.global_attribute5
4172 ,p_attribute6 => p_x_header_rec.global_attribute6
4173 ,p_attribute7 => p_x_header_rec.global_attribute7
4174 ,p_attribute8 => p_x_header_rec.global_attribute8
4175 ,p_attribute9 => p_x_header_rec.global_attribute9
4176 ,p_attribute10 => p_x_header_rec.global_attribute10
4177 ,p_attribute11 => p_x_header_rec.global_attribute11
4178 ,p_attribute12 => p_x_header_rec.global_attribute12
4179 ,p_attribute13 => p_x_header_rec.global_attribute13
4180 ,p_attribute14 => p_x_header_rec.global_attribute13
4181 ,p_attribute15 => p_x_header_rec.global_attribute14
4182 ,p_attribute16 => p_x_header_rec.global_attribute16
4183 ,p_attribute17 => p_x_header_rec.global_attribute17
4184 ,p_attribute18 => p_x_header_rec.global_attribute18
4185 ,p_attribute19 => p_x_header_rec.global_attribute19
4186 ,p_attribute20 => p_x_header_rec.global_attribute20)
4187 THEN
4188
4189 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4190 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4191 THEN
4192
4193 p_x_header_rec.global_attribute_category := null;
4194 p_x_header_rec.global_attribute1 := null;
4195 p_x_header_rec.global_attribute2 := null;
4196 p_x_header_rec.global_attribute3 := null;
4197 p_x_header_rec.global_attribute4 := null;
4198 p_x_header_rec.global_attribute5 := null;
4199 p_x_header_rec.global_attribute6 := null;
4200 p_x_header_rec.global_attribute7 := null;
4201 p_x_header_rec.global_attribute8 := null;
4202 p_x_header_rec.global_attribute9 := null;
4203 p_x_header_rec.global_attribute11 := null;
4204 p_x_header_rec.global_attribute12 := null;
4205 p_x_header_rec.global_attribute13 := null;
4206 p_x_header_rec.global_attribute14 := null;
4207 p_x_header_rec.global_attribute15 := null;
4208 p_x_header_rec.global_attribute16 := null;
4209 p_x_header_rec.global_attribute17 := null;
4210 p_x_header_rec.global_attribute18 := null;
4211 p_x_header_rec.global_attribute19 := null;
4212 p_x_header_rec.global_attribute20 := null;
4213
4214 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4215 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4216 THEN
4217
4218 p_x_header_rec.global_attribute_category
4219 := FND_API.G_MISS_CHAR;
4220 p_x_header_rec.global_attribute1 := FND_API.G_MISS_CHAR;
4221 p_x_header_rec.global_attribute2 := FND_API.G_MISS_CHAR;
4222 p_x_header_rec.global_attribute3 := FND_API.G_MISS_CHAR;
4223 p_x_header_rec.global_attribute4 := FND_API.G_MISS_CHAR;
4224 p_x_header_rec.global_attribute5 := FND_API.G_MISS_CHAR;
4225 p_x_header_rec.global_attribute6 := FND_API.G_MISS_CHAR;
4226 p_x_header_rec.global_attribute7 := FND_API.G_MISS_CHAR;
4227 p_x_header_rec.global_attribute8 := FND_API.G_MISS_CHAR;
4228 p_x_header_rec.global_attribute9 := FND_API.G_MISS_CHAR;
4229 p_x_header_rec.global_attribute11 := FND_API.G_MISS_CHAR;
4230 p_x_header_rec.global_attribute12 := FND_API.G_MISS_CHAR;
4231 p_x_header_rec.global_attribute13 := FND_API.G_MISS_CHAR;
4232 p_x_header_rec.global_attribute14 := FND_API.G_MISS_CHAR;
4233 p_x_header_rec.global_attribute15 := FND_API.G_MISS_CHAR;
4234 p_x_header_rec.global_attribute16 := FND_API.G_MISS_CHAR;
4235 p_x_header_rec.global_attribute17 := FND_API.G_MISS_CHAR;
4236 p_x_header_rec.global_attribute18 := FND_API.G_MISS_CHAR;
4237 p_x_header_rec.global_attribute19 := FND_API.G_MISS_CHAR;
4238 p_x_header_rec.global_attribute20 := FND_API.G_MISS_CHAR;
4239
4240 ELSE
4241 x_return_status := FND_API.G_RET_STS_ERROR;
4242 END IF;
4243 ELSE -- for bug 2511313
4244 IF p_x_header_rec.global_attribute_category IS NULL
4245 OR p_x_header_rec.global_attribute_category = FND_API.G_MISS_CHAR THEN
4246 p_x_header_rec.global_attribute_category := oe_validate.g_context;
4247 END IF;
4248
4249 IF p_x_header_rec.global_attribute1 IS NULL
4250 OR p_x_header_rec.global_attribute1 = FND_API.G_MISS_CHAR THEN
4251 p_x_header_rec.global_attribute1 := oe_validate.g_attribute1;
4252 END IF;
4253
4254 IF p_x_header_rec.global_attribute2 IS NULL
4255 OR p_x_header_rec.global_attribute2 = FND_API.G_MISS_CHAR THEN
4256 p_x_header_rec.global_attribute2 := oe_validate.g_attribute2;
4257 END IF;
4258
4259 IF p_x_header_rec.global_attribute3 IS NULL
4260 OR p_x_header_rec.global_attribute3 = FND_API.G_MISS_CHAR THEN
4261 p_x_header_rec.global_attribute3 := oe_validate.g_attribute3;
4262 END IF;
4263
4264 IF p_x_header_rec.global_attribute4 IS NULL
4265 OR p_x_header_rec.global_attribute4 = FND_API.G_MISS_CHAR THEN
4266 p_x_header_rec.global_attribute4 := oe_validate.g_attribute4;
4267 END IF;
4268
4269 IF p_x_header_rec.global_attribute5 IS NULL
4270 OR p_x_header_rec.global_attribute5 = FND_API.G_MISS_CHAR THEN
4271 p_x_header_rec.global_attribute5 := oe_validate.g_attribute5;
4272 END IF;
4273
4274 IF p_x_header_rec.global_attribute6 IS NULL
4275 OR p_x_header_rec.global_attribute6 = FND_API.G_MISS_CHAR THEN
4276 p_x_header_rec.global_attribute6 := oe_validate.g_attribute6;
4277 END IF;
4278
4279 IF p_x_header_rec.global_attribute7 IS NULL
4280 OR p_x_header_rec.global_attribute7 = FND_API.G_MISS_CHAR THEN
4281 p_x_header_rec.global_attribute7 := oe_validate.g_attribute7;
4282 END IF;
4283
4284 IF p_x_header_rec.global_attribute8 IS NULL
4285 OR p_x_header_rec.global_attribute8 = FND_API.G_MISS_CHAR THEN
4286 p_x_header_rec.global_attribute8 := oe_validate.g_attribute8;
4287 END IF;
4288
4289 IF p_x_header_rec.global_attribute9 IS NULL
4290 OR p_x_header_rec.global_attribute9 = FND_API.G_MISS_CHAR THEN
4291 p_x_header_rec.global_attribute9 := oe_validate.g_attribute9;
4292 END IF;
4293
4294 IF p_x_header_rec.global_attribute11 IS NULL
4295 OR p_x_header_rec.global_attribute11 = FND_API.G_MISS_CHAR THEN
4296 p_x_header_rec.global_attribute11 := oe_validate.g_attribute11;
4297 END IF;
4298
4299 IF p_x_header_rec.global_attribute12 IS NULL
4300 OR p_x_header_rec.global_attribute12 = FND_API.G_MISS_CHAR THEN
4301 p_x_header_rec.global_attribute12 := oe_validate.g_attribute12;
4302 END IF;
4303
4304 IF p_x_header_rec.global_attribute13 IS NULL
4305 OR p_x_header_rec.global_attribute13 = FND_API.G_MISS_CHAR THEN
4306 p_x_header_rec.global_attribute13 := oe_validate.g_attribute13;
4307 END IF;
4308
4309 IF p_x_header_rec.global_attribute14 IS NULL
4310 OR p_x_header_rec.global_attribute14 = FND_API.G_MISS_CHAR THEN
4311 p_x_header_rec.global_attribute14 := oe_validate.g_attribute14;
4312 END IF;
4313
4314 IF p_x_header_rec.global_attribute15 IS NULL
4315 OR p_x_header_rec.global_attribute15 = FND_API.G_MISS_CHAR THEN
4316 p_x_header_rec.global_attribute15 := oe_validate.g_attribute15;
4317 END IF;
4318
4319 IF p_x_header_rec.global_attribute16 IS NULL
4320 OR p_x_header_rec.global_attribute16 = FND_API.G_MISS_CHAR THEN
4321 p_x_header_rec.global_attribute16 := oe_validate.g_attribute16;
4322 END IF;
4323
4324 IF p_x_header_rec.global_attribute17 IS NULL
4325 OR p_x_header_rec.global_attribute17 = FND_API.G_MISS_CHAR THEN
4326 p_x_header_rec.global_attribute17 := oe_validate.g_attribute17;
4327 END IF;
4328
4329 IF p_x_header_rec.global_attribute18 IS NULL
4330 OR p_x_header_rec.global_attribute18 = FND_API.G_MISS_CHAR THEN
4331 p_x_header_rec.global_attribute18 := oe_validate.g_attribute18;
4332 END IF;
4333
4334 IF p_x_header_rec.global_attribute19 IS NULL
4335 OR p_x_header_rec.global_attribute19 = FND_API.G_MISS_CHAR THEN
4336 p_x_header_rec.global_attribute19 := oe_validate.g_attribute19;
4337 END IF;
4338
4339 IF p_x_header_rec.global_attribute20 IS NULL
4340 OR p_x_header_rec.global_attribute20 = FND_API.G_MISS_CHAR THEN
4341 p_x_header_rec.global_attribute20 := oe_validate.g_attribute20;
4342 END IF;
4343
4344 IF p_x_header_rec.global_attribute10 IS NULL
4345 OR p_x_header_rec.global_attribute10 = FND_API.G_MISS_CHAR THEN
4346 p_x_header_rec.global_attribute10 := oe_validate.g_attribute10;
4347 END IF;
4348 -- end of bug 2511313
4349 END IF;
4350 END IF; -- Enabled
4351 END IF;
4352
4353 OE_DEBUG_PUB.ADD('After G_header_desc_flex ' || x_return_status,2);
4354
4355 -- Added the Trading Partner Flex Validation and also the changes for defaulting
4356 -- for bug 2511313
4357
4358 IF p_x_header_rec.operation = oe_globals.g_opr_create OR
4359 ( p_x_header_rec.operation = oe_globals.g_opr_update AND
4360 (p_x_header_rec.tp_attribute1 IS NOT NULL AND
4361 ( p_x_header_rec.tp_attribute1 <>
4362 p_old_header_rec.tp_attribute1 OR
4363 p_old_header_rec.tp_attribute1 IS NULL ))
4364 OR (p_x_header_rec.tp_attribute2 IS NOT NULL AND
4365 ( p_x_header_rec.tp_attribute2 <>
4366 p_old_header_rec.tp_attribute2 OR
4367 p_old_header_rec.tp_attribute2 IS NULL ))
4368 OR (p_x_header_rec.tp_attribute3 IS NOT NULL AND
4369 ( p_x_header_rec.tp_attribute3 <>
4370 p_old_header_rec.tp_attribute3 OR
4371 p_old_header_rec.tp_attribute3 IS NULL ))
4372 OR (p_x_header_rec.tp_attribute4 IS NOT NULL AND
4373 ( p_x_header_rec.tp_attribute4 <>
4374 p_old_header_rec.tp_attribute4 OR
4375 p_old_header_rec.tp_attribute4 IS NULL ))
4376 OR (p_x_header_rec.tp_attribute5 IS NOT NULL AND
4377 ( p_x_header_rec.tp_attribute5 <>
4378 p_old_header_rec.tp_attribute5 OR
4379 p_old_header_rec.tp_attribute5 IS NULL ))
4380 OR (p_x_header_rec.tp_attribute6 IS NOT NULL AND
4381 ( p_x_header_rec.tp_attribute6 <>
4382 p_old_header_rec.tp_attribute6 OR
4383 p_old_header_rec.tp_attribute6 IS NULL ))
4384 OR (p_x_header_rec.tp_attribute7 IS NOT NULL AND
4385 ( p_x_header_rec.tp_attribute7 <>
4386 p_old_header_rec.tp_attribute7 OR
4387 p_old_header_rec.tp_attribute7 IS NULL ))
4388 OR (p_x_header_rec.tp_attribute8 IS NOT NULL AND
4389 ( p_x_header_rec.tp_attribute8 <>
4390 p_old_header_rec.tp_attribute8 OR
4391 p_old_header_rec.tp_attribute8 IS NULL ))
4392 OR (p_x_header_rec.tp_attribute9 IS NOT NULL AND
4393 ( p_x_header_rec.tp_attribute9 <>
4394 p_old_header_rec.tp_attribute9 OR
4395 p_old_header_rec.tp_attribute9 IS NULL ))
4396 OR (p_x_header_rec.tp_attribute10 IS NOT NULL AND
4397 ( p_x_header_rec.tp_attribute10 <>
4398 p_old_header_rec.tp_attribute10 OR
4399 p_old_header_rec.tp_attribute10 IS NULL ))
4400 OR (p_x_header_rec.tp_attribute11 IS NOT NULL AND
4401 ( p_x_header_rec.tp_attribute11 <>
4402 p_old_header_rec.tp_attribute11 OR
4403 p_old_header_rec.tp_attribute11 IS NULL ))
4404 OR (p_x_header_rec.tp_attribute12 IS NOT NULL AND
4405 ( p_x_header_rec.tp_attribute12 <>
4406 p_old_header_rec.tp_attribute12 OR
4407 p_old_header_rec.tp_attribute12 IS NULL ))
4408 OR (p_x_header_rec.tp_attribute13 IS NOT NULL AND
4409 ( p_x_header_rec.tp_attribute13 <>
4410 p_old_header_rec.tp_attribute13 OR
4411 p_old_header_rec.tp_attribute13 IS NULL ))
4412 OR (p_x_header_rec.tp_attribute14 IS NOT NULL AND
4413 ( p_x_header_rec.tp_attribute14 <>
4414 p_old_header_rec.tp_attribute14 OR
4415 p_old_header_rec.tp_attribute14 IS NULL ))
4416 OR (p_x_header_rec.tp_attribute15 IS NOT NULL AND
4417 ( p_x_header_rec.tp_attribute15 <>
4418 p_old_header_rec.tp_attribute15 OR
4419 p_old_header_rec.tp_attribute15 IS NULL )))
4420
4421 THEN
4422
4423 IF Oe_Order_Cache.IS_FLEX_ENABLED('OE_HEADER_TP_ATTRIBUTES') = 'Y' THEN
4424 IF NOT OE_VALIDATE.TP_Header_Desc_Flex
4425 (p_context => p_x_header_rec.tp_context
4426 ,p_attribute1 => p_x_header_rec.tp_attribute1
4427 ,p_attribute2 => p_x_header_rec.tp_attribute2
4428 ,p_attribute3 => p_x_header_rec.tp_attribute3
4429 ,p_attribute4 => p_x_header_rec.tp_attribute4
4430 ,p_attribute5 => p_x_header_rec.tp_attribute5
4431 ,p_attribute6 => p_x_header_rec.tp_attribute6
4432 ,p_attribute7 => p_x_header_rec.tp_attribute7
4433 ,p_attribute8 => p_x_header_rec.tp_attribute8
4434 ,p_attribute9 => p_x_header_rec.tp_attribute9
4435 ,p_attribute10 => p_x_header_rec.tp_attribute10
4436 ,p_attribute11 => p_x_header_rec.tp_attribute11
4437 ,p_attribute12 => p_x_header_rec.tp_attribute12
4438 ,p_attribute13 => p_x_header_rec.tp_attribute13
4439 ,p_attribute14 => p_x_header_rec.tp_attribute14
4440 ,p_attribute15 => p_x_header_rec.tp_attribute15) THEN
4441
4442 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4443 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
4444
4445
4446 p_x_header_rec.tp_context := null;
4447 p_x_header_rec.tp_attribute1 := null;
4448 p_x_header_rec.tp_attribute2 := null;
4449 p_x_header_rec.tp_attribute3 := null;
4450 p_x_header_rec.tp_attribute4 := null;
4451 p_x_header_rec.tp_attribute5 := null;
4452 p_x_header_rec.tp_attribute6 := null;
4453 p_x_header_rec.tp_attribute7 := null;
4454 p_x_header_rec.tp_attribute8 := null;
4455 p_x_header_rec.tp_attribute9 := null;
4456 p_x_header_rec.tp_attribute10 := null;
4457 p_x_header_rec.tp_attribute11 := null;
4458 p_x_header_rec.tp_attribute12 := null;
4459 p_x_header_rec.tp_attribute13 := null;
4460 p_x_header_rec.tp_attribute14 := null;
4461 p_x_header_rec.tp_attribute15 := null;
4462
4463 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4464 p_x_header_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
4465
4466 p_x_header_rec.tp_context := FND_API.G_MISS_CHAR;
4467 p_x_header_rec.tp_attribute1 := FND_API.G_MISS_CHAR;
4468 p_x_header_rec.tp_attribute2 := FND_API.G_MISS_CHAR;
4469 p_x_header_rec.tp_attribute3 := FND_API.G_MISS_CHAR;
4470 p_x_header_rec.tp_attribute4 := FND_API.G_MISS_CHAR;
4471 p_x_header_rec.tp_attribute5 := FND_API.G_MISS_CHAR;
4472 p_x_header_rec.tp_attribute6 := FND_API.G_MISS_CHAR;
4473 p_x_header_rec.tp_attribute7 := FND_API.G_MISS_CHAR;
4474 p_x_header_rec.tp_attribute8 := FND_API.G_MISS_CHAR;
4475 p_x_header_rec.tp_attribute9 := FND_API.G_MISS_CHAR;
4476 p_x_header_rec.tp_attribute10 := FND_API.G_MISS_CHAR;
4477 p_x_header_rec.tp_attribute11 := FND_API.G_MISS_CHAR;
4478 p_x_header_rec.tp_attribute12 := FND_API.G_MISS_CHAR;
4479 p_x_header_rec.tp_attribute13 := FND_API.G_MISS_CHAR;
4480 p_x_header_rec.tp_attribute14 := FND_API.G_MISS_CHAR;
4481 p_x_header_rec.tp_attribute15 := FND_API.G_MISS_CHAR;
4482 ELSE
4483 x_return_status := FND_API.G_RET_STS_ERROR;
4484 END IF;
4485
4486 ELSE
4487
4488 IF p_x_header_rec.tp_context IS NULL
4489 OR p_x_header_rec.tp_context = FND_API.G_MISS_CHAR THEN
4490 p_x_header_rec.tp_context := oe_validate.g_context;
4491 END IF;
4492
4493 IF p_x_header_rec.tp_attribute1 IS NULL
4494 OR p_x_header_rec.tp_attribute1 = FND_API.G_MISS_CHAR THEN
4495 p_x_header_rec.tp_attribute1 := oe_validate.g_attribute1;
4496 END IF;
4497
4498 IF p_x_header_rec.tp_attribute2 IS NULL
4499 OR p_x_header_rec.tp_attribute2 = FND_API.G_MISS_CHAR THEN
4500 p_x_header_rec.tp_attribute2 := oe_validate.g_attribute2;
4501 END IF;
4502
4503 IF p_x_header_rec.tp_attribute3 IS NULL
4504 OR p_x_header_rec.tp_attribute3 = FND_API.G_MISS_CHAR THEN
4505 p_x_header_rec.tp_attribute3 := oe_validate.g_attribute3;
4506 END IF;
4507
4508 IF p_x_header_rec.tp_attribute4 IS NULL
4509 OR p_x_header_rec.tp_attribute4 = FND_API.G_MISS_CHAR THEN
4510 p_x_header_rec.tp_attribute4 := oe_validate.g_attribute4;
4511 END IF;
4512
4513 IF p_x_header_rec.tp_attribute5 IS NULL
4514 OR p_x_header_rec.tp_attribute5 = FND_API.G_MISS_CHAR THEN
4515 p_x_header_rec.tp_attribute5 := oe_validate.g_attribute5;
4516 END IF;
4517
4518 IF p_x_header_rec.tp_attribute6 IS NULL
4519 OR p_x_header_rec.tp_attribute6 = FND_API.G_MISS_CHAR THEN
4520 p_x_header_rec.tp_attribute6 := oe_validate.g_attribute6;
4521 END IF;
4522
4523 IF p_x_header_rec.tp_attribute7 IS NULL
4524 OR p_x_header_rec.tp_attribute7 = FND_API.G_MISS_CHAR THEN
4525 p_x_header_rec.tp_attribute7 := oe_validate.g_attribute7;
4526 END IF;
4527
4528 IF p_x_header_rec.tp_attribute8 IS NULL
4529 OR p_x_header_rec.tp_attribute8 = FND_API.G_MISS_CHAR THEN
4530 p_x_header_rec.tp_attribute8 := oe_validate.g_attribute8;
4531 END IF;
4532
4533 IF p_x_header_rec.tp_attribute9 IS NULL
4534 OR p_x_header_rec.tp_attribute9 = FND_API.G_MISS_CHAR THEN
4535 p_x_header_rec.tp_attribute9 := oe_validate.g_attribute9;
4536 END IF;
4537
4538 IF p_x_header_rec.tp_attribute10 IS NULL
4539 OR p_x_header_rec.tp_attribute10 = FND_API.G_MISS_CHAR THEN
4540 p_x_header_rec.tp_attribute10 := Oe_validate.G_attribute10;
4541 End IF;
4542
4543 IF p_x_header_rec.tp_attribute11 IS NULL
4544 OR p_x_header_rec.tp_attribute11 = FND_API.G_MISS_CHAR THEN
4545 p_x_header_rec.tp_attribute11 := oe_validate.g_attribute11;
4546 END IF;
4547
4548 IF p_x_header_rec.tp_attribute12 IS NULL
4549 OR p_x_header_rec.tp_attribute12 = FND_API.G_MISS_CHAR THEN
4550 p_x_header_rec.tp_attribute12 := oe_validate.g_attribute12;
4551 END IF;
4552
4553 IF p_x_header_rec.tp_attribute13 IS NULL
4554 OR p_x_header_rec.tp_attribute13 = FND_API.G_MISS_CHAR THEN
4555 p_x_header_rec.tp_attribute13 := oe_validate.g_attribute13;
4556 END IF;
4557
4558 IF p_x_header_rec.tp_attribute14 IS NULL
4559 OR p_x_header_rec.tp_attribute14 = FND_API.G_MISS_CHAR THEN
4560 p_x_header_rec.tp_attribute14 := oe_validate.g_attribute14;
4561 END IF;
4562
4563 IF p_x_header_rec.tp_attribute15 IS NULL
4564 OR p_x_header_rec.tp_attribute15 = FND_API.G_MISS_CHAR THEN
4565 p_x_header_rec.tp_attribute15 := oe_validate.g_attribute15;
4566 END IF;
4567
4568 END IF;
4569 END IF; -- Is flex enabled
4570
4571 --oe_debug_pub.add('After TP_header_desc_flex ' || x_return_status);
4572
4573 END IF;
4574 /* Trading Partner */
4575 end if; --for bug4343612
4576 -- Done validating attributes
4577
4578 -- Salesrep_id
4579 IF p_x_header_rec.salesrep_id IS NOT NULL AND
4580 ( (p_x_header_rec.salesrep_id <>
4581 p_old_header_rec.salesrep_id OR
4582 p_old_header_rec.salesrep_id IS NULL ) OR
4583 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
4584 --bug 5060064
4585 THEN
4586
4587 IF NOT OE_Validate.salesrep(p_x_header_rec.salesrep_id)
4588 THEN
4589 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4590 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4591 THEN
4592 p_x_header_rec.salesrep_id := NULL;
4593 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4594 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4595 THEN
4596 p_x_header_rec.salesrep_id := FND_API.G_MISS_NUM;
4597 ELSE
4598 x_return_status := FND_API.G_RET_STS_ERROR;
4599 END IF;
4600 END IF;
4601
4602 END IF;
4603
4604 oe_debug_pub.add('after salesrep_id');
4605
4606 IF p_x_header_rec.sales_channel_code IS NOT NULL AND
4607 ( (p_x_header_rec.sales_channel_code <>
4608 p_old_header_rec.sales_channel_code OR
4609 p_old_header_rec.sales_channel_code IS NULL ) OR
4610 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
4611 --bug 5060064
4612 THEN
4613
4614 IF NOT OE_Validate.sales_channel(p_x_header_rec.sales_channel_code)
4615 THEN
4616 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4617 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4618 THEN
4619 p_x_header_rec.sales_channel_code := NULL;
4620 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4621 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4622 THEN
4623 p_x_header_rec.sales_channel_code := FND_API.G_MISS_CHAR;
4624 ELSE
4625 x_return_status := FND_API.G_RET_STS_ERROR;
4626 END IF;
4627 END IF;
4628
4629 END IF;
4630
4631 -- Return_reason_code
4632
4633 IF p_x_header_rec.return_reason_code IS NOT NULL AND
4634 ( (p_x_header_rec.return_reason_code <>
4635 p_old_header_rec.return_reason_code OR
4636 p_old_header_rec.return_reason_code IS NULL ) OR
4637 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
4638 --bug 5060064
4639 THEN
4640
4641 IF NOT OE_Validate.return_reason(p_x_header_rec.return_reason_code) THEN
4642 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4643 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4644 THEN
4645 p_x_header_rec.return_reason_code := NULL;
4646 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4647 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4648 THEN
4649 p_x_header_rec.return_reason_code := FND_API.G_MISS_CHAR;
4650 ELSE
4651 x_return_status := FND_API.G_RET_STS_ERROR;
4652 END IF;
4653 END IF;
4654
4655 END IF;
4656
4657 -- Changes for Line Set Enhancements
4658
4659 IF p_x_header_rec.Default_fulfillment_set IS NOT NULL AND
4660 ( (p_x_header_rec.default_fulfillment_set <>
4661 p_old_header_rec.default_fulfillment_set OR
4662 p_old_header_rec.default_fulfillment_set IS NULL ) OR
4663 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
4664 --bug 5060064
4665 THEN
4666
4667 IF NOT OE_Validate.Default_fulfillment_set(p_x_header_rec.default_fulfillment_set)
4668 THEN
4669 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4670 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4671 THEN
4672 p_x_header_rec.default_fulfillment_set := NULL;
4673 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4674 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4675 THEN
4676 p_x_header_rec.default_fulfillment_set := FND_API.G_MISS_CHAR;
4677 ELSE
4678 x_return_status := FND_API.G_RET_STS_ERROR;
4679 END IF;
4680
4681 END IF;
4682
4683 END IF;
4684
4685 IF p_x_header_rec.fulfillment_set_name IS NOT NULL AND
4686 ( (p_x_header_rec.fulfillment_set_name <>
4687 p_old_header_rec.fulfillment_set_name OR
4688 p_old_header_rec.fulfillment_set_name IS NULL ) OR
4689 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
4690 --bug 5060064
4691 THEN
4692
4693 IF NOT OE_Validate.Fulfillment_Set_name (p_x_header_rec.fulfillment_set_name)
4694 THEN
4695 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4696 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4697 THEN
4698 p_x_header_rec.fulfillment_set_name := NULL;
4699 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4700 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4701 THEN
4702 p_x_header_rec.fulfillment_set_name := FND_API.G_MISS_CHAR;
4703 ELSE
4704 x_return_status := FND_API.G_RET_STS_ERROR;
4705 END IF;
4706
4707 END IF;
4708
4709 END IF;
4710
4711 IF p_x_header_rec.Line_set_name IS NOT NULL AND
4712 ( (p_x_header_rec.Line_set_name <>
4713 p_old_header_rec.Line_set_name OR
4714 p_old_header_rec.Line_set_name IS NULL ) OR
4715 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
4716 --bug 5060064
4717 THEN
4718
4719 IF NOT OE_Validate.Line_set_name (p_x_header_rec.line_set_name)
4720 THEN
4721 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4722 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4723 THEN
4724 p_x_header_rec.line_set_name := NULL;
4725 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4726 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4727 THEN
4728 p_x_header_rec.line_set_name := FND_API.G_MISS_CHAR;
4729 ELSE
4730 x_return_status := FND_API.G_RET_STS_ERROR;
4731 END IF;
4732
4733 END IF;
4734
4735 END IF;
4736
4737
4738 -- QUOTING changes
4739
4740 IF p_x_header_rec.user_status_code IS NOT NULL AND
4741 ( (p_x_header_rec.user_status_code <>
4742 p_old_header_rec.user_status_code OR
4743 p_old_header_rec.user_status_code IS NULL ) OR
4744 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
4745 --bug 5060064
4746 THEN
4747
4748 IF NOT OE_Validate.User_Status (p_x_header_rec.user_status_code)
4749 THEN
4750 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4751 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4752 THEN
4753 p_x_header_rec.user_status_code := NULL;
4754 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4755 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4756 THEN
4757 p_x_header_rec.user_status_code := FND_API.G_MISS_CHAR;
4758 ELSE
4759 x_return_status := FND_API.G_RET_STS_ERROR;
4760 END IF;
4761
4762 END IF;
4763
4764 END IF;
4765
4766
4767 IF p_x_header_rec.version_number IS NOT NULL AND
4768 ( (p_x_header_rec.version_number <>
4769 p_old_header_rec.version_number OR
4770 p_old_header_rec.version_number IS NULL ) OR
4771 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
4772 --bug 5060064
4773 THEN
4774
4775 IF NOT OE_Validate.Version_Number (p_x_header_rec.version_number)
4776 THEN
4777 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4778 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4779 THEN
4780 p_x_header_rec.version_number := NULL;
4781 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4782 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4783 THEN
4784 p_x_header_rec.version_number := FND_API.G_MISS_CHAR;
4785 ELSE
4786 x_return_status := FND_API.G_RET_STS_ERROR;
4787 END IF;
4788
4789 END IF;
4790
4791 END IF;
4792
4793 IF p_x_header_rec.expiration_date IS NOT NULL AND
4794 ( (p_x_header_rec.expiration_date <>
4795 p_old_header_rec.expiration_date OR
4796 p_old_header_rec.expiration_date IS NULL ) OR
4797 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
4798 --bug 5060064
4799 THEN
4800
4801 IF NOT OE_Validate.Expiration_Date (p_x_header_rec.expiration_date)
4802 THEN
4803 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4804 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4805 THEN
4806 p_x_header_rec.expiration_date := NULL;
4807 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4808 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4809 THEN
4810 -- Bug 3222419
4811 -- Copy was failing with numeric/value error if expiration date
4812 -- supplied was < sysdate
4813 p_x_header_rec.expiration_date := FND_API.G_MISS_DATE;
4814 ELSE
4815 x_return_status := FND_API.G_RET_STS_ERROR;
4816 END IF;
4817
4818 END IF;
4819
4820 END IF;
4821
4822 IF p_x_header_rec.sold_to_site_use_id IS NOT NULL AND
4823 ( (p_x_header_rec.sold_to_site_use_id <>
4824 p_old_header_rec.sold_to_site_use_id OR
4825 p_old_header_rec.sold_to_site_use_id IS NULL ) OR
4826 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
4827 --bug 5060064
4828 THEN
4829 IF NOT OE_Validate.Customer_Location(p_x_header_rec.sold_to_site_use_id)
4830 THEN
4831 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4832 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4833 THEN
4834 p_x_header_rec.sold_to_site_use_id := NULL;
4835 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4836 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4837 THEN
4838 p_x_header_rec.sold_to_site_use_id := FND_API.G_MISS_NUM;
4839 ELSE
4840 x_return_status := FND_API.G_RET_STS_ERROR;
4841 END IF;
4842 END IF;
4843
4844 END IF;
4845
4846 -- QUOTING changes END
4847
4848
4849 IF p_x_header_rec.Minisite_Id IS NOT NULL AND
4850 ( (p_x_header_rec.Minisite_Id <>
4851 p_old_header_rec.Minisite_Id OR
4852 p_old_header_rec.Minisite_Id IS NULL ) OR
4853 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
4854 --bug 5060064
4855 THEN
4856
4857 IF NOT OE_Validate.Minisite (p_x_header_rec.Minisite_Id)
4858 THEN
4859 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4860 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4861 THEN
4862 p_x_header_rec.Minisite_Id := NULL;
4863 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4864 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4865 THEN
4866 p_x_header_rec.Minisite_Id := FND_API.G_MISS_NUM;
4867 ELSE
4868 x_return_status := FND_API.G_RET_STS_ERROR;
4869 END IF;
4870
4871 END IF;
4872
4873 END IF;
4874
4875 IF p_x_header_rec.Ib_owner IS NOT NULL AND
4876 ( (p_x_header_rec.Ib_owner <>
4877 p_old_header_rec.Ib_owner OR
4878 p_old_header_rec.Ib_owner IS NULL ) OR
4879 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
4880 --bug 5060064
4881 THEN
4882
4883 IF NOT OE_Validate.IB_OWNER (p_x_header_rec.Ib_owner)
4884 THEN
4885 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4886 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4887 THEN
4888 p_x_header_rec.Ib_owner := NULL;
4889 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4890 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4891 THEN
4892 p_x_header_rec.Ib_owner := FND_API.G_MISS_CHAR;
4893 ELSE
4894 x_return_status := FND_API.G_RET_STS_ERROR;
4895 END IF;
4896
4897 END IF;
4898
4899 END IF;
4900
4901 IF p_x_header_rec.Ib_installed_at_location IS NOT NULL AND
4902 ( (p_x_header_rec.Ib_installed_at_location <>
4903 p_old_header_rec.Ib_installed_at_location OR
4904 p_old_header_rec.Ib_installed_at_location IS NULL ) OR
4905 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
4906 --bug 5060064
4907 THEN
4908
4909 IF NOT OE_Validate.IB_INSTALLED_AT_LOCATION (p_x_header_rec.Ib_installed_at_location)
4910 THEN
4911 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4912 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4913 THEN
4914 p_x_header_rec.Ib_installed_at_location := NULL;
4915 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4916 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4917 THEN
4918 p_x_header_rec.Ib_installed_at_location := FND_API.G_MISS_CHAR;
4919 ELSE
4920 x_return_status := FND_API.G_RET_STS_ERROR;
4921 END IF;
4922
4923 END IF;
4924
4925 END IF;
4926
4927 IF p_x_header_rec.Ib_current_location IS NOT NULL AND
4928 ( (p_x_header_rec.Ib_current_location <>
4929 p_old_header_rec.Ib_current_location OR
4930 p_old_header_rec.Ib_current_location IS NULL ) OR
4931 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
4932 --bug 5060064
4933 THEN
4934
4935 IF NOT OE_Validate.IB_CURRENT_LOCATION (p_x_header_rec.Ib_current_location)
4936 THEN
4937 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4938 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4939 THEN
4940 p_x_header_rec.Ib_current_location := NULL;
4941 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4942 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4943 THEN
4944 p_x_header_rec.Ib_current_location := FND_API.G_MISS_CHAR;
4945 ELSE
4946 x_return_status := FND_API.G_RET_STS_ERROR;
4947 END IF;
4948
4949 END IF;
4950
4951 END IF;
4952
4953 IF p_x_header_rec.End_customer_id IS NOT NULL AND
4954 ( (p_x_header_rec.End_customer_id <>
4955 p_old_header_rec.End_customer_id OR
4956 p_old_header_rec.End_customer_id IS NULL ) OR
4957 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
4958 --bug 5060064
4959 THEN
4960
4961 IF NOT OE_Validate.END_CUSTOMER (p_x_header_rec.End_customer_id)
4962 THEN
4963 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4964 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4965 THEN
4966 p_x_header_rec.End_customer_id := NULL;
4967 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4968 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4969 THEN
4970 p_x_header_rec.End_customer_id := FND_API.G_MISS_NUM;
4971 ELSE
4972 x_return_status := FND_API.G_RET_STS_ERROR;
4973 END IF;
4974
4975 END IF;
4976
4977 END IF;
4978
4979 IF p_x_header_rec.End_customer_contact_id IS NOT NULL AND
4980 ( (p_x_header_rec.End_customer_contact_id <>
4981 p_old_header_rec.End_customer_contact_id OR
4982 p_old_header_rec.End_customer_contact_id IS NULL ) OR
4983 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
4984 --bug 5060064
4985 THEN
4986
4987 IF NOT OE_Validate.END_CUSTOMER_CONTACT (p_x_header_rec.End_customer_contact_id)
4988 THEN
4989 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
4990 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4991 THEN
4992 p_x_header_rec.End_customer_contact_id := NULL;
4993 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
4994 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
4995 THEN
4996 p_x_header_rec.End_customer_contact_id := FND_API.G_MISS_NUM;
4997 ELSE
4998 x_return_status := FND_API.G_RET_STS_ERROR;
4999 END IF;
5000
5001 END IF;
5002
5003 END IF;
5004
5005 IF p_x_header_rec.End_customer_site_use_id IS NOT NULL AND
5006 ( (p_x_header_rec.End_customer_site_use_id <>
5007 p_old_header_rec.End_customer_site_use_id OR
5008 p_old_header_rec.End_customer_site_use_id IS NULL ) OR
5009 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
5010 --bug 5060064
5011 THEN
5012
5013 IF NOT OE_Validate.END_CUSTOMER_SITE_USE (p_x_header_rec.End_customer_site_use_id)
5014 THEN
5015 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
5016 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
5017 THEN
5018 p_x_header_rec.End_customer_site_use_id := NULL;
5019 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
5020 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
5021 THEN
5022 p_x_header_rec.End_customer_site_use_id := FND_API.G_MISS_NUM;
5023 ELSE
5024 x_return_status := FND_API.G_RET_STS_ERROR;
5025 END IF;
5026
5027 END IF;
5028
5029 END IF;
5030
5031 IF p_x_header_rec.supplier_signature IS NOT NULL AND
5032 ( (p_x_header_rec.supplier_signature <>
5033 p_old_header_rec.supplier_signature OR
5034 p_old_header_rec.supplier_signature IS NULL ) OR
5035 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
5036 --bug 5060064
5037 THEN
5038
5039 IF NOT OE_Validate.SUPPLIER_SIGNATURE (p_x_header_rec.supplier_signature)
5040 THEN
5041 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
5042 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
5043 THEN
5044 p_x_header_rec.supplier_signature := NULL;
5045 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
5046 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
5047 THEN
5048 p_x_header_rec.supplier_signature := FND_API.G_MISS_CHAR;
5049 ELSE
5050 x_return_status := FND_API.G_RET_STS_ERROR;
5051 END IF;
5052
5053 END IF;
5054
5055 END IF;
5056
5057 IF p_x_header_rec.supplier_signature_date IS NOT NULL AND
5058 ( (p_x_header_rec.supplier_signature_date <>
5059 p_old_header_rec.supplier_signature_date OR
5060 p_old_header_rec.supplier_signature_date IS NULL ) OR
5061 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
5062 --bug 5060064
5063 THEN
5064
5065 IF NOT OE_Validate.SUPPLIER_SIGNATURE_DATE (p_x_header_rec.supplier_signature_date)
5066 THEN
5067 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
5068 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
5069 THEN
5070 p_x_header_rec.supplier_signature_date := NULL;
5071 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
5072 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
5073 THEN
5074 p_x_header_rec.supplier_signature_date := FND_API.G_MISS_DATE;
5075 ELSE
5076 x_return_status := FND_API.G_RET_STS_ERROR;
5077 END IF;
5078
5079 END IF;
5080
5081 END IF;
5082
5083 IF p_x_header_rec.customer_signature IS NOT NULL AND
5084 ( (p_x_header_rec.customer_signature <>
5085 p_old_header_rec.customer_signature OR
5086 p_old_header_rec.customer_signature IS NULL ) OR
5087 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
5088 --bug 5060064
5089 THEN
5090
5091 IF NOT OE_Validate.CUSTOMER_SIGNATURE (p_x_header_rec.customer_signature)
5092 THEN
5093 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
5094 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
5095 THEN
5096 p_x_header_rec.customer_signature := NULL;
5097 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
5098 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
5099 THEN
5100 p_x_header_rec.customer_signature := FND_API.G_MISS_CHAR;
5101 ELSE
5102 x_return_status := FND_API.G_RET_STS_ERROR;
5103 END IF;
5104
5105 END IF;
5106
5107 END IF;
5108
5109 IF p_x_header_rec.customer_signature_date IS NOT NULL AND
5110 ( (p_x_header_rec.customer_signature_date <>
5111 p_old_header_rec.customer_signature_date OR
5112 p_old_header_rec.customer_signature_date IS NULL ) OR
5113 (p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE ) )
5114 --bug 5060064
5115 THEN
5116
5117 IF NOT OE_Validate.CUSTOMER_SIGNATURE_DATE (p_x_header_rec.customer_signature_date)
5118 THEN
5119 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
5120 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
5121 THEN
5122 p_x_header_rec.customer_signature_date := NULL;
5123 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
5124 p_x_header_rec.operation = OE_GLOBALS.G_OPR_CREATE
5125 THEN
5126 p_x_header_rec.customer_signature_date := FND_API.G_MISS_DATE;
5127 ELSE
5128 x_return_status := FND_API.G_RET_STS_ERROR;
5129 END IF;
5130
5131 END IF;
5132
5133 END IF;
5134
5135
5136
5137
5138 --End Of Addition
5139 --End Of Addition
5140 oe_debug_pub.add('Exiting OE_VALIDATE_HEADER.ATTRIBUTES',1);
5141
5142 EXCEPTION
5143
5144 WHEN FND_API.G_EXC_ERROR THEN
5145 x_return_status := FND_API.G_RET_STS_ERROR;
5146
5147 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5148 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5149
5150 WHEN OTHERS THEN
5151 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5152
5153 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5154 THEN
5155 OE_MSG_PUB.Add_Exc_Msg
5156 ( G_PKG_NAME
5157 ,'Attributes'
5158 );
5159 END IF;
5160
5161 END Attributes;
5162
5163
5164
5165 /*-----------------------------------------------------
5166 PROCEDURE: Entity_Delete
5167 Description:
5168 -------------------------------------------------------*/
5169
5170 PROCEDURE Entity_Delete
5171 ( x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
5172 , p_header_rec IN OE_Order_PUB.Header_Rec_Type
5173 )
5174 IS
5175 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
5176 BEGIN
5177
5178 -- Validate entity delete.
5179 NULL;
5180 -- Done.
5181
5182 x_return_status := l_return_status;
5183
5184 EXCEPTION
5185
5186 WHEN FND_API.G_EXC_ERROR THEN
5187 x_return_status := FND_API.G_RET_STS_ERROR;
5188
5189 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5190 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5191
5192 WHEN OTHERS THEN
5193 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5194
5195 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5196 THEN
5197 OE_MSG_PUB.Add_Exc_Msg
5198 ( G_PKG_NAME
5199 ,'Entity_Delete'
5200 );
5201 END IF;
5202
5203 END Entity_Delete;
5204
5205 END OE_Validate_Header;