1 PACKAGE BODY OE_Validate_Line AS
2 /* $Header: OEXLLINB.pls 120.52.12010000.7 2008/12/11 11:47:50 nitagarw ship $ */
3
4 -- Global constant holding the package name
5
6 G_PKG_NAME CONSTANT VARCHAR2(30) := 'OE_Validate_Line';
7 --var added for bug 4171642
8 g_master_org_id NUMBER := OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID') ;
9 --g_cust_ord_enabled_flag varchar2(1):=nvl(FND_PROFILE.Value('ONT_VAL_CUST_ORD_ENABLED_FLAG'),'N'); --bug4343544
10 -- LOCAL PROCEDURES
11
12 -- QUOTING changes
13 /*-------------------------------------------------------
14 PROCEDURE: Check_Negotiation_Attributes
15 Description: This procedures validates the order line attributes
16 against transaction phase (Negotiation vs Fulfillment).
17 --------------------------------------------------------*/
18
19 PROCEDURE Check_Negotiation_Attributes
20 ( p_line_rec IN OE_Order_PUB.Line_Rec_Type
21 , p_old_line_rec IN OE_Order_PUB.Line_Rec_Type
22 , x_return_status IN OUT NOCOPY VARCHAR2
23 )
24 IS
25 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
26 BEGIN
27
28 if l_debug_level > 0 then
29 oe_debug_pub.add('Enter OE_VALIDATE_LINE.Check_Negotiation_Attributes',1);
30 oe_debug_pub.add('Phase: '||p_line_rec.transaction_phase_code,1);
31 end if;
32
33 x_return_status := FND_API.G_RET_STS_SUCCESS;
34
35 IF p_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
36
37 -- Transaction phase cannot be updated on a saved transaction.
38
39 IF OE_Quote_Util.G_COMPLETE_NEG = 'N' AND
40 NOT OE_GLOBALS.EQUAL(p_line_rec.transaction_phase_code
41 ,p_old_line_rec.transaction_phase_code)
42 THEN
43 FND_MESSAGE.SET_NAME('ONT','OE_PHASE_UPDATE_NOT_ALLOWED');
44 OE_MSG_PUB.ADD;
45 RAISE FND_API.G_EXC_ERROR;
46 END IF;
47
48 END IF; -- End of check for UPDATE operation
49
50
51 -- Start checks specific to the transaction phase
52
53 IF p_line_rec.transaction_phase_code = 'N' THEN
54
55 -- Cannot update following order attributes in negotiation phase
56
57 IF NVL(p_line_rec.arrival_set,fnd_api.g_miss_char)
58 <> fnd_api.g_miss_char
59 OR NOT OE_GLOBALS.EQUAL(p_line_rec.arrival_set_id
60 ,p_old_line_rec.arrival_set_id)
61 THEN
62 if l_debug_level > 0 then
63 oe_debug_pub.add('arrival set :'||p_line_rec.arrival_set);
64 oe_debug_pub.add('arrival set id :'||p_line_rec.arrival_set_id);
65 oe_debug_pub.add('old arrival set id :'||p_old_line_rec.arrival_set_id);
66 end if;
67 FND_MESSAGE.SET_NAME('ONT','OE_CANT_UPDATE_ORDER_ATTR');
68 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
69 OE_Order_UTIL.Get_Attribute_Name('ARRIVAL_SET_ID'));
70 OE_MSG_PUB.ADD;
71 x_return_status := FND_API.G_RET_STS_ERROR;
72 END IF;
73
74 IF NVL(p_line_rec.ship_set,fnd_api.g_miss_char)
75 <> fnd_api.g_miss_char
76 OR NOT OE_GLOBALS.EQUAL(p_line_rec.ship_set_id
77 ,p_old_line_rec.ship_set_id)
78 THEN
79 if l_debug_level > 0 then
80 oe_debug_pub.add('ship set :'||p_line_rec.ship_set);
81 oe_debug_pub.add('ship set id :'||p_line_rec.ship_set_id);
82 oe_debug_pub.add('old ship set id :'||p_old_line_rec.ship_set_id);
83 end if;
84 FND_MESSAGE.SET_NAME('ONT','OE_CANT_UPDATE_ORDER_ATTR');
85 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
86 OE_Order_UTIL.Get_Attribute_Name('SHIP_SET_ID'));
87 OE_MSG_PUB.ADD;
88 x_return_status := FND_API.G_RET_STS_ERROR;
89 END IF;
90 --for bug 3450282. Added NVL condition to consider g_miss_char during comparision
91 IF NOT OE_GLOBALS.EQUAL(NVL(p_line_rec.schedule_ship_date,FND_API.G_MISS_DATE)
92 ,NVL(p_old_line_rec.schedule_ship_date,FND_API.G_MISS_DATE))
93 THEN
94 FND_MESSAGE.SET_NAME('ONT','OE_CANT_UPDATE_ORDER_ATTR');
95 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
96 OE_Order_UTIL.Get_Attribute_Name('SCHEDULE_SHIP_DATE'));
97 OE_MSG_PUB.ADD;
98 x_return_status := FND_API.G_RET_STS_ERROR;
99 END IF;
100 --for bug 3450282. Added NVL condition to consider g_miss_char during comparision
101 IF NOT OE_GLOBALS.EQUAL(NVL(p_line_rec.schedule_arrival_date,FND_API.G_MISS_DATE)
102 ,NVL(p_old_line_rec.schedule_arrival_date,FND_API.G_MISS_DATE))
103 THEN
104 FND_MESSAGE.SET_NAME('ONT','OE_CANT_UPDATE_ORDER_ATTR');
105 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
106 OE_Order_UTIL.Get_Attribute_Name('SCHEDULE_ARRIVAL_DATE'));
107 OE_MSG_PUB.ADD;
108 x_return_status := FND_API.G_RET_STS_ERROR;
109 END IF;
110
111 --for bug 3450282. Added NVL condition to consider g_miss_char during comparision
112 IF NOT OE_GLOBALS.EQUAL(NVL(p_line_rec.override_atp_date_code,FND_API.G_MISS_CHAR)
113 ,NVL(p_old_line_rec.override_atp_date_code,FND_API.G_MISS_CHAR))
114 THEN
115 FND_MESSAGE.SET_NAME('ONT','OE_CANT_UPDATE_ORDER_ATTR');
116 --The following line was modified for bug 3153680
117 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Override ATP');
118 OE_MSG_PUB.ADD;
119 x_return_status := FND_API.G_RET_STS_ERROR;
120 END IF;
121
122 IF NOT OE_GLOBALS.EQUAL(p_line_rec.reserved_quantity
123 ,p_old_line_rec.reserved_quantity)
124 THEN
125 --Added for bug 3158444
126 IF NOT (( p_old_line_rec.reserved_quantity=FND_API.G_MISS_NUM AND
127 p_line_rec.reserved_quantity IS NULL)
128 OR (p_line_rec.reserved_quantity=FND_API.G_MISS_NUM AND
129 p_old_line_rec.reserved_quantity IS NULL))
130 THEN
131 FND_MESSAGE.SET_NAME('ONT','OE_CANT_UPDATE_ORDER_ATTR');
132 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
133 OE_Order_UTIL.Get_Attribute_Name('RESERVED_QUANTITY'));
134 OE_MSG_PUB.ADD;
135 x_return_status := FND_API.G_RET_STS_ERROR;
136 END IF;
137 END IF;
138
139 -- INVCONV OPM Inventory Convergence as above
140 IF NOT OE_GLOBALS.EQUAL(p_line_rec.reserved_quantity2
141 ,p_old_line_rec.reserved_quantity2)
142 THEN
143
144 IF NOT (( p_old_line_rec.reserved_quantity2=FND_API.G_MISS_NUM AND
145 p_line_rec.reserved_quantity2 IS NULL)
146 OR (p_line_rec.reserved_quantity2=FND_API.G_MISS_NUM AND
147 p_old_line_rec.reserved_quantity2 IS NULL))
148 THEN
149 FND_MESSAGE.SET_NAME('ONT','OE_CANT_UPDATE_ORDER_ATTR');
150 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
151 OE_Order_UTIL.Get_Attribute_Name('RESERVED_QUANTITY2'));
152 OE_MSG_PUB.ADD;
153 x_return_status := FND_API.G_RET_STS_ERROR;
154 END IF;
155 END IF;
156
157
158
159 --for bug 3450282. Added NVL condition to consider g_miss_char during comparision
160 IF NOT OE_GLOBALS.EQUAL(NVL(p_line_rec.firm_demand_flag,FND_API.G_MISS_CHAR)
161 ,NVL(p_old_line_rec.firm_demand_flag,FND_API.G_MISS_CHAR))
162 THEN
163 FND_MESSAGE.SET_NAME('ONT','OE_CANT_UPDATE_ORDER_ATTR');
164 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Firm Demand');
165 OE_MSG_PUB.ADD;
166 x_return_status := FND_API.G_RET_STS_ERROR;
167 END IF;
168 --for bug 3450282. Added NVL condition to consider g_miss_num during comparision
169 IF NOT OE_GLOBALS.EQUAL(NVL(p_line_rec.late_demand_penalty_factor,FND_API.G_MISS_NUM)
170 ,NVL(p_old_line_rec.late_demand_penalty_factor,FND_API.G_MISS_NUM))
171 THEN
172 FND_MESSAGE.SET_NAME('ONT','OE_CANT_UPDATE_ORDER_ATTR');
173 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Late Demand Penalty');
174 OE_MSG_PUB.ADD;
175 x_return_status := FND_API.G_RET_STS_ERROR;
176 END IF;
177
178 -- schedule action is not a DB field so check for not null only
179 IF p_line_rec.schedule_action_code IS NOT NULL
180 THEN
181 FND_MESSAGE.SET_NAME('ONT','OE_CANT_UPDATE_ORDER_ATTR');
182 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
183 OE_Order_UTIL.Get_Attribute_Name('SCHEDULE_ACTION_CODE'));
184 OE_MSG_PUB.ADD;
185 x_return_status := FND_API.G_RET_STS_ERROR;
186 END IF;
187
188 -- Return orders not supported
189 IF p_line_rec.line_category_code = 'RETURN' THEN
190 FND_MESSAGE.SET_NAME('ONT','OE_QUOTE_RETURN_NOT_SUPP');
191 OE_MSG_PUB.ADD;
192 x_return_status := FND_API.G_RET_STS_ERROR;
193 END IF;
194
195 -- Internal sales orders not allowed
196 IF p_line_rec.order_source_id = 10 THEN
197 FND_MESSAGE.SET_NAME('ONT','OE_QUOTE_INT_ORD_NOT_SUPP');
198 OE_MSG_PUB.ADD;
199 x_return_status := FND_API.G_RET_STS_ERROR;
200 END IF;
201
202 -- Cancellation operation not supported for quotes
203 IF p_line_rec.cancelled_flag = 'Y' THEN
204 FND_MESSAGE.SET_NAME('ONT','OE_QUOTE_CANCEL_NOT_SUPP');
205 OE_MSG_PUB.ADD;
206 x_return_status := FND_API.G_RET_STS_ERROR;
207 END IF;
208
209 END IF; -- End of check if phase = F/N
210
211 if l_debug_level > 0 then
212 oe_debug_pub.add('Exit OE_VALIDATE_LINE.Check_Negotiation_Attributes',1);
213 end if;
214
215 EXCEPTION
216 WHEN FND_API.G_EXC_ERROR THEN
217 x_return_status := FND_API.G_RET_STS_ERROR;
218 WHEN OTHERS THEN
219 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
220
221 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
222 THEN
223 OE_MSG_PUB.Add_Exc_Msg
224 ( G_PKG_NAME ,
225 'Check_Negotiation_Attributes'
226 );
227 END IF;
228
229 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
230 END Check_Negotiation_Attributes;
231
232 -- Check_Book_Reqd_Attributes
233 -- This procedure checks for all the attributes that are required
234 -- on booked order lines.
235 -- IMPORTANT:
236 -- 1) With the fix for bug 1785143, booking would query
237 -- only the attributes that are being checked for in this
238 -- procedure if ASO and EDI products are not installed on the instance.
239 -- Therefore, if you add checks for/based on attributes that
240 -- were not being accessed before your change in this procedure,
241 -- please add it to the query_lines cursor and in the fetch
242 -- from the cursor in OEXUBOKB.pls - procedure update_booked_flag.
243 -- 2) Anytime you add new validation in this procedure, please add
244 -- the same to Check_Book_Reqd_Attributes procedure in OEXVCLNB.pls.
245 -- OEXVCLNB.pls is used to validate attributes when importing closed
246 -- orders.
247
248
249 PROCEDURE Check_Book_Reqd_Attributes
250 ( p_line_rec IN OE_Order_PUB.Line_Rec_Type
251 , p_old_line_rec IN OE_Order_PUB.Line_Rec_Type
252 , x_return_status IN OUT NOCOPY VARCHAR2
253 )
254 IS
255 l_proj_ref_enabled NUMBER;
256 l_proj_control_level NUMBER;
257 l_calculate_tax_flag VARCHAR2(1) := 'N';
258 --l_line_type_rec OE_Order_Cache.Line_Type_Rec_Type;
259 l_item_type_code VARCHAR2(30);
260 l_revision_controlled VARCHAR2(1);
261 l_rule_type VARCHAR2(10);
262 l_tax_calculation_event_code VARCHAR2(30);
263 --key Transaction Dates
264 l_hdr_booked_date DATE ;
265 l_cust_trx_type_id NUMBER := 0;
266 l_cust_trx_rec_type OE_ORDER_CACHE.cust_trx_rec_type;
267 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
268 BEGIN
269
270 IF l_debug_level > 0 then
271 OE_DEBUG_PUB.Add('Entering OE_VALIDATE_LINE.Check_Book_Reqd_Attributes',1);
272 END IF;
273 -- Check for fields required on a booked order line
274
275 IF p_line_rec.sold_to_org_id IS NULL THEN
276 x_return_status := FND_API.G_RET_STS_ERROR;
277 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
278 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
279 OE_Order_UTIL.Get_Attribute_Name('SOLD_TO_ORG_ID'));
280 OE_MSG_PUB.ADD;
281 END IF;
282
283 IF p_line_rec.invoice_to_org_id IS NULL THEN
284 x_return_status := FND_API.G_RET_STS_ERROR;
285 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
286 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
287 OE_Order_UTIL.Get_Attribute_Name('INVOICE_TO_ORG_ID'));
288 OE_MSG_PUB.ADD;
289 END IF;
290
291 IF p_line_rec.tax_exempt_flag IS NULL THEN
292 x_return_status := FND_API.G_RET_STS_ERROR;
293 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
294 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
295 OE_Order_UTIL.Get_Attribute_Name('TAX_EXEMPT_FLAG'));
296 OE_MSG_PUB.ADD;
297 END IF;
298
299
300 -- Item, Quantity and UOM Required
301 IF p_line_rec.inventory_item_id IS NULL THEN
302 x_return_status := FND_API.G_RET_STS_ERROR;
303 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
304 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
305 OE_Order_UTIL.Get_Attribute_Name('INVENTORY_ITEM_ID'));
306 OE_MSG_PUB.ADD;
307 END IF;
308
309 IF p_line_rec.order_quantity_uom IS NULL THEN
310 x_return_status := FND_API.G_RET_STS_ERROR;
311 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
312 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
313 OE_Order_UTIL.Get_Attribute_Name('ORDER_QUANTITY_UOM'));
314 OE_MSG_PUB.ADD;
315 END IF;
316
317 -- Fix bug 1277092: ordered quantity should not be = 0 on a booked line
318 IF p_line_rec.ordered_quantity IS NULL
319 OR p_line_rec.ordered_quantity = 0 THEN
320 x_return_status := FND_API.G_RET_STS_ERROR;
321 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
322 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
323 OE_Order_UTIL.Get_Attribute_Name('ORDERED_QUANTITY'));
324 OE_MSG_PUB.ADD;
325 END IF;
326
327 -- For all items that are NOT included items OR config items,
328 -- price list, unit selling price and unit list price are required.
329
330 IF p_line_rec.line_category_code = 'RETURN' THEN
331 l_item_type_code := OE_Line_Util.Get_Return_Item_Type_Code
332 (p_line_rec);
333 ELSE
334 l_item_type_code := p_line_rec.item_type_code;
335 END IF;
336
337 /*
338 If p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE Then
339 --Fix bug 1759025
340 --Move this validation to pricing integration OEXVADJB.pls. Fix bug 1650652
341 Null;
342 Else
343 */
344 IF (l_item_type_code <> 'INCLUDED'
345 AND l_item_type_code <> 'CONFIG')
346 THEN
347
348 -- Move this validation to pricing integration OEXVADJB.pls. Fix bug 1650652
349 -- Except in Cases 1 and 2 below when pricing will not be called
350
351 -- Case 1: If user is explicitly updating the value of selling price to
352 -- null, then raise error if selling price is null
353 IF p_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
354 AND NOT OE_GLOBALS.EQUAL(p_line_rec.unit_selling_price
355 ,p_old_line_rec.unit_selling_price) THEN
356
357 IF p_line_rec.unit_selling_price IS NULL THEN
358 x_return_status := FND_API.G_RET_STS_ERROR;
359 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
360 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
361 OE_Order_UTIL.Get_Attribute_Name('UNIT_SELLING_PRICE'));
362 OE_MSG_PUB.ADD;
363 END IF;
364
365 END IF;
366
367
368 -- Case 2: If booking is calling this procedure, then do the check for all
369 -- 3 pricing attributes
370 IF p_line_rec.operation <> OE_GLOBALS.G_OPR_CREATE
371 AND NOT OE_GLOBALS.EQUAL(p_line_rec.booked_flag
372 ,p_old_line_rec.booked_flag) THEN
373
374 IF p_line_rec.price_list_id IS NULL THEN
375 x_return_status := FND_API.G_RET_STS_ERROR;
376 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
377 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
378 OE_Order_UTIL.Get_Attribute_Name('PRICE_LIST_ID'));
379 OE_MSG_PUB.ADD;
380 END IF;
381
382
383 IF p_line_rec.unit_list_price IS NULL THEN
384 x_return_status := FND_API.G_RET_STS_ERROR;
385 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
386 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
387 OE_Order_UTIL.Get_Attribute_Name('UNIT_LIST_PRICE'));
388 OE_MSG_PUB.ADD;
389 END IF;
390
391 IF p_line_rec.unit_selling_price IS NULL THEN
392 x_return_status := FND_API.G_RET_STS_ERROR;
393 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
394 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
395 OE_Order_UTIL.Get_Attribute_Name('UNIT_SELLING_PRICE'));
396 OE_MSG_PUB.ADD;
397 END IF;
398
399
400 END IF;
401
402 END IF; -- End of check for pricing attributes
403
404 -- Fix bug 1262790
405 -- Ship To and Payment Term required on ORDER lines,
406 -- NOT on RETURN lines
407
408 IF p_line_rec.line_category_code <> OE_GLOBALS.G_RETURN_CATEGORY_CODE THEN
409
410 IF p_line_rec.ship_to_org_id IS NULL THEN
411 x_return_status := FND_API.G_RET_STS_ERROR;
412 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
413 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
414 OE_Order_UTIL.Get_Attribute_Name('SHIP_TO_ORG_ID'));
415 OE_MSG_PUB.ADD;
416 END IF;
417
418 IF p_line_rec.payment_term_id IS NULL THEN
419 x_return_status := FND_API.G_RET_STS_ERROR;
420 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
421 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
422 OE_Order_UTIL.Get_Attribute_Name('PAYMENT_TERM_ID'));
423 OE_MSG_PUB.ADD;
424 END IF;
425
426 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
427 IF p_line_rec.item_type_code <> 'SERVICE' THEN
428 IF p_line_rec.accounting_rule_id IS NOT NULL AND
429 p_line_rec.accounting_rule_id <> FND_API.G_MISS_NUM THEN
430 IF l_debug_level > 0 then
431 oe_debug_pub.add('Getting accounting rule type');
432 END IF;
433 SELECT type
434 INTO l_rule_type
435 FROM ra_rules
436 WHERE rule_id = p_line_rec.accounting_rule_id;
437 IF l_debug_level > 0 then
438 oe_debug_pub.add('Rule_Type is :'||l_rule_type||': accounting rule duration is: '||p_line_rec.accounting_rule_duration);
439 END IF;
440 IF l_rule_type = 'ACC_DUR' THEN
441 IF p_line_rec.accounting_rule_duration IS NULL THEN
442 x_return_status := FND_API.G_RET_STS_ERROR;
443 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
444 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
445 OE_Order_UTIL.Get_Attribute_Name('ACCOUNTING_RULE_DURATION'));
446 OE_MSG_PUB.ADD;
447 END IF; -- end of accounting_rule_duration null
448 END IF; -- end of variable accounting rule type
449
450 -- WEBROOT ER bug 6826344 start
451 oe_debug_pub.add(' before new rule validations');
452
453 IF l_rule_type = 'PP_DR_PP' OR l_rule_type = 'PP_DR_ALL' THEN
454 oe_debug_pub.add('inside new rule validation conditions');
455
456 IF p_line_rec.service_start_date IS NULL THEN
457 oe_debug_pub.add(' inside new rule validation conditions service start date');
458 x_return_status := FND_API.G_RET_STS_ERROR;
459 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
460 FND_MESSAGE.SET_TOKEN('ATTRIBUTE', 'Accounting Rule Start Date' );
461 OE_MSG_PUB.ADD;
462 END IF;
463 IF p_line_rec.service_end_date IS NULL THEN
464 x_return_status := FND_API.G_RET_STS_ERROR;
465 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
466 FND_MESSAGE.SET_TOKEN('ATTRIBUTE', 'Accounting Rule End Date' );
467 OE_MSG_PUB.ADD;
468 END IF;
469
470 END IF;
471
472 -- WEBROOT ER bug 6826344 end
473
474 END IF; -- end of accounting_rule_id not null
475 END IF; -- end of non-service line
476 END IF; -- end of code release level
477
478 END IF;
479
480
481 -- Warehouse and schedule date required on RETURN lines
482
483 IF p_line_rec.line_category_code = OE_GLOBALS.G_RETURN_CATEGORY_CODE THEN
484
485 IF p_line_rec.ship_from_org_id IS NULL THEN
486 x_return_status := FND_API.G_RET_STS_ERROR;
487 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_RETURN_ATTRIBUTE');
488 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
489 OE_Order_UTIL.Get_Attribute_Name('SHIP_FROM_ORG_ID'));
490 OE_MSG_PUB.ADD;
491 END IF;
492
493 IF p_line_rec.request_date IS NULL THEN
494 x_return_status := FND_API.G_RET_STS_ERROR;
495 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_RETURN_ATTRIBUTE');
496 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
497 OE_Order_UTIL.Get_Attribute_Name('REQUEST_DATE'));
498 OE_MSG_PUB.ADD;
499 END IF;
500
501 END IF;
502
503 /* Added by Manish */
504
505 IF p_line_rec.tax_date IS NULL
506 THEN
507 x_return_status := FND_API.G_RET_STS_ERROR;
508 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_RETURN_ATTRIBUTE');
509 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
510 OE_Order_UTIL.Get_Attribute_Name('TAX_DATE'));
511 OE_MSG_PUB.ADD;
512 END IF;
513
514 -- Tax code is required under following conditions.
515 -- 1. The tax hadnling is required at line level.
516 -- (i.e. Tax_exempt_flag = 'R'-Required.)
517 -- 2. The calculate tax flag on customer transaction type for this line
518 -- type is set to Yes.
519
520 --7306510
521 --Following booking validation that requires 'Tax Classification Code' when the AR trx type has
522 -- 'Default tax Classfication' checked will no more be done.This is to follow what AR has done (AR has
523 --- completly removed this validation )
524
525 /*
526 IF p_line_rec.tax_code IS NULL THEN
527
528
529 IF p_line_rec.commitment_id IS NOT NULL AND
530 p_line_rec.commitment_id <> FND_API.G_MISS_NUM THEN
531 BEGIN
532 SELECT NVL(cust_type.subsequent_trx_type_id,cust_type.cust_trx_type_id)
533 INTO l_cust_trx_type_id
534 FROM ra_cust_trx_types cust_type,ra_customer_trx cust_trx
535 WHERE cust_type.cust_trx_type_id = cust_trx.cust_trx_type_id
536 AND cust_trx.customer_trx_id = p_line_rec.commitment_id;
537
538 IF l_debug_level > 0 THEN
539 oe_debug_pub.add( 'value of commitment customer trx type id '||l_cust_trx_type_id,1);
540 END IF;
541
542 EXCEPTION
543 WHEN NO_DATA_FOUND THEN
544 l_cust_trx_type_id := 0;
545 WHEN OTHERS THEN
546 null;
547 END;
548 ELSE
549 l_cust_trx_type_id := OE_Invoice_PUB.Get_Customer_Transaction_Type(p_line_rec);
550 END IF;
551 IF l_debug_level > 0 THEN
552 oe_debug_pub.add( 'value of customer trx type id '||l_cust_trx_type_id,1);
553 END IF;
554
555 IF l_cust_trx_type_id IS NOT NULL AND l_cust_trx_type_id <> 0 THEN
556 l_cust_trx_rec_type := OE_ORDER_CACHE.Load_Cust_Trx_Type(l_cust_Trx_type_id);
557 l_calculate_tax_flag := l_cust_trx_rec_type.tax_calculation_flag;
558 END IF;
559
560 IF l_debug_level > 0 THEN
561 oe_debug_pub.add( 'value of tax_calculation_flag '||l_calculate_tax_flag,1);
562 END IF;
563
564 -- end bug#5462464
565
566 -- l_line_type_rec := OE_Order_Cache.Load_Line_Type(p_line_rec.line_type_id);
567
568 -- fix for bug 1701388 - commented the following code
569 -- Fix bug#1098412: check for calculate tax flag ONLY if receivable
570 -- transaction type EXISTS on the line type
571 IF l_line_type_rec.cust_trx_type_id IS NOT NULL
572 THEN
573
574 SELECT tax_calculation_flag
575 INTO l_calculate_tax_flag
576 FROM RA_CUST_TRX_TYPES
577 WHERE CUST_TRX_TYPE_ID = l_line_type_rec.cust_trx_type_id;
578
579 END IF;
580
581
582
583 IF (l_calculate_tax_flag = 'Y' OR p_line_rec.tax_exempt_flag = 'R')
584 THEN
585
586 SELECT TAX_CALCULATION_EVENT_CODE
587 INTO l_tax_calculation_event_code
588 FROM oe_transaction_types_all
589 WHERE transaction_type_id
590 = OE_Order_Cache.g_header_rec.order_type_id;
591
592 IF nvl(l_tax_calculation_event_code, 'ENTERING') IN ('ENTERING', 'BOOKING') THEN
593
594 x_return_status := FND_API.G_RET_STS_ERROR;
595 FND_MESSAGE.SET_NAME('ONT','OE_VAL_TAX_CODE_REQD');
596 OE_MSG_PUB.ADD;
597 END IF;
598 END IF;
599
600 END IF;
601
602 --This block has been repleaced by the following for 1888018
603 -- Service Duration is required on SERVICE lines
604 IF l_item_type_code = 'SERVICE' THEN
605 IF p_line_rec.service_duration IS NULL THEN
606 x_return_status := FND_API.G_RET_STS_ERROR;
607 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_SERVICE_DURATION');
608 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
609 OE_Order_UTIL.Get_Attribute_Name('SERVICE_DURATION'));
610 OE_MSG_PUB.ADD;
611 END IF;
612 END IF;
613 */
614
615
616 IF l_item_type_code = 'SERVICE' THEN
617 IF p_line_rec.service_coterminate_flag = 'Y' OR
618 p_line_rec.service_reference_type_code = 'CUSTOMER_PRODUCT' THEN
619 IF p_line_rec.service_start_date IS NULL THEN
620 x_return_status := FND_API.G_RET_STS_ERROR;
621 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
622 FND_MESSAGE.SET_TOKEN('ATTRIBUTE', OE_Order_UTIL.Get_Attribute_Name('SERVICE_START_DATE'));
623 OE_MSG_PUB.ADD;
624 END IF;
625 IF p_line_rec.service_end_date IS NULL THEN
626 x_return_status := FND_API.G_RET_STS_ERROR;
627 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
628 FND_MESSAGE.SET_TOKEN('ATTRIBUTE', OE_Order_UTIL.Get_Attribute_Name('SERVICE_END_DATE'));
629 OE_MSG_PUB.ADD;
630 END IF;
631 END IF;
632
633 IF p_line_rec.service_duration IS NULL THEN
634 x_return_status := FND_API.G_RET_STS_ERROR;
635 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
636 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
637 OE_Order_UTIL.Get_Attribute_Name('SERVICE_DURATION'));
638 OE_MSG_PUB.ADD;
639 END IF;
640 IF p_line_rec.service_period IS NULL THEN
641 x_return_status := FND_API.G_RET_STS_ERROR;
642 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_LINE_ATTRIBUTE');
643 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
644 OE_Order_UTIL.Get_Attribute_Name('SERVICE_PERIOD'));
645 OE_MSG_PUB.ADD;
646 END IF;
647 END IF;
648 /* End of 1888018 change */
649
650 ------------------------------------------------------------------------
651 --Check over return
652 ------------------------------------------------------------------------
653
654 IF p_line_rec.line_category_code = 'RETURN' AND
655 p_line_rec.reference_line_id is not NULL AND
656 p_line_rec.cancelled_flag <> 'Y'
657 THEN
658 IF (OE_LINE_UTIL.Is_Over_Return(p_line_rec)) THEN
659 x_return_status := FND_API.G_RET_STS_ERROR;
660 FND_MESSAGE.Set_Name('ONT', 'OE_RETURN_INVALID_QUANTITY');
661 OE_MSG_PUB.ADD;
662 END IF;
663
664 END IF;
665
666 --key Transaction dates
667 l_hdr_booked_date := oe_order_cache.g_header_rec.booked_date ;
668 IF l_hdr_booked_date = FND_API.G_MISS_DATE or l_hdr_booked_date IS NULL THEN
669 l_hdr_booked_date := sysdate ;
670 END IF ;
671
672 IF (OE_CODE_CONTROL.Code_Release_Level >= '110509' and p_line_rec.order_firmed_date > l_hdr_booked_date
673 and p_line_rec.creation_date <= l_hdr_booked_date) THEN
674 x_return_status := FND_API.G_RET_STS_ERROR;
675 FND_MESSAGE.Set_Name('ONT','ONT_ORDER_FIRMED_DATE_INVALID');
676 OE_MSG_PUB.Add;
677 END IF;
678 --end
679
680 /* Fix Bug 2429989: Returning Revision Controlled Items */
681
682 /* Need to take out this validation as a fix for 3230755 */
683
684 --- commented out-----
685 /*
686 IF p_line_rec.line_category_code = OE_GLOBALS.G_RETURN_CATEGORY_CODE THEN
687 IF p_line_rec.item_revision = FND_API.G_MISS_CHAR OR
688 p_line_rec.item_revision IS NULL THEN
689 Begin
690 select decode(revision_qty_control_code, 2, 'Y', 'N')
691 into l_revision_controlled
692 from mtl_system_items
693 where inventory_item_id = p_line_rec.inventory_item_id
694 and organization_id = OE_Sys_Parameters.VALUE_WNPS('MASTER_ORGANIZATION_ID');
695 Exception
696 When NO_DATA_FOUND Then
697 l_revision_controlled := 'N';
698 End;
699 IF l_revision_controlled = 'Y' THEN
700 x_return_status := FND_API.G_RET_STS_ERROR;
701 FND_MESSAGE.SET_NAME('ONT','OE_BOOK_REQD_RETURN_ATTRIBUTE');
702 FND_MESSAGE.SET_TOKEN('ATTRIBUTE', OE_Order_UTIL.Get_Attribute_Name('ITEM_REVISION'));
703 OE_MSG_PUB.ADD;
704 END IF;
705 END IF;
706 END IF;
707 */
708 IF l_debug_level > 0 then
709 OE_DEBUG_PUB.Add('Exiting OE_VALIDATE_LINE.Check_Book_Reqd_Attributes',1);
710 END IF;
711
712 EXCEPTION
713 WHEN OTHERS THEN
714 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
715 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
716 THEN
717 OE_MSG_PUB.Add_Exc_Msg
718 ( G_PKG_NAME
719 , 'Check_Book_Reqd_Attributes'
720 );
721 END IF;
722 END Check_Book_Reqd_Attributes;
723
724
725
726 ----------------------------------------------------
727 -- Local Procedures for ER 2502504
728 -- This Procedure validates Ship Sets and SMC Models.
729 -- Validation is done when lines are being added to Pick
730 -- Released Ship Sets and SMC Models. This is called from
731 -- procedure Entity.
732 -----------------------------------------------------------
733
734 Procedure Validate_ShipSet_SMC
735 ( p_line_rec IN OE_Order_PUB.Line_Rec_Type
736 ,p_old_line_rec IN OE_Order_PUB.Line_Rec_Type
737 ,x_return_status OUT NOCOPY VARCHAR2
738 )
739 IS
740 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
741 l_shipset_enforce VARCHAR2(1);
742 l_set_name VARCHAR2(30);
743 l_model_name VARCHAR2(30);
744 l_model_item_id NUMBER;
745 l_smc_model NUMBER := 0;
746 l_ship_set NUMBER := 0;
747 BEGIN
748
749 x_return_status := FND_API.G_RET_STS_SUCCESS;
750
751 IF l_debug_level > 0 then
752 OE_DEBUG_PUB.Add('Entering OE_VALIDATE_LINE.Validate_Shipset_SMC',1);
753 END IF;
754
755 -- Select statement to check the Ship Set Enforce Parameter.
756 BEGIN
757 SELECT Enforce_Ship_Set_And_Smc
758 INTO l_shipset_enforce
759 FROM Wsh_Shipping_Parameters
760 WHERE Organization_Id = p_line_rec.ship_from_org_Id;
761 EXCEPTION
762 WHEN NO_DATA_FOUND THEN
763 NULL;
764 WHEN OTHERS THEN
765 NULL;
766 END;
767
768
769 IF NOT OE_GLOBALS.Equal(p_line_rec.ship_set_id,
770 p_old_line_rec.ship_set_id) THEN
771
772 -- Select statement to check whether the set is pick released.
773 /*
774 SELECT count(*)
775 INTO l_ship_set
776 FROM Wsh_Delivery_Details
777 WHERE Ship_Set_Id = p_line_rec.ship_set_id
778 AND Source_Code = 'OE'
779 AND Source_Header_Id = p_line_rec.header_id
780 AND Released_Status In ('S','Y','C')
781 AND ROWNUM = 1; -- 3229707 Removed 'B' from Released_Status check
782 */
783 SELECT count(*)
784 INTO l_ship_set
785 FROM wsh_delivery_details wdd
786 WHERE wdd.ship_set_id = p_line_rec.ship_set_id
787 AND wdd.source_code = 'OE'
788 AND wdd.source_header_id = p_line_rec.header_id
789 AND ((wdd.released_status = 'C')
790 OR EXISTS (select wda.delivery_detail_id
791 FROM wsh_delivery_assignments wda, wsh_new_deliveries wnd
792 WHERE wda.delivery_detail_id = wdd.delivery_detail_id
793 AND wda.delivery_id = wnd.delivery_id
794 AND wnd.status_code in ('CO', 'IT', 'CL', 'SA')))
795 AND rownum = 1;
796
797 IF l_ship_set > 0 AND l_shipset_enforce = 'Y' THEN
798 FND_MESSAGE.Set_Name ('ONT','ONT_SET_PICK_RELEASED');
799 BEGIN
800 SELECT SET_NAME
801 INTO l_set_name
802 FROM OE_SETS
803 WHERE set_id = p_line_rec.ship_set_id;
804 EXCEPTION
805 WHEN NO_DATA_FOUND THEN
806 l_set_name := null;
807 END;
808 FND_MESSAGE.Set_Token('SHIP_SET',l_set_name);
809 OE_MSG_PUB.Add;
810 x_return_status := FND_API.G_RET_STS_ERROR;
811 END IF;
812
813 END IF;
814
815
816 IF p_line_rec.top_model_line_id IS NOT NULL AND
817 p_line_rec.top_model_line_id <> p_line_rec.line_id AND
818 p_line_rec.ship_model_complete_flag = 'Y' THEN
819
820 -- Select statement to check whether the SMC is pick released.
821
822 -- Bug 4766576, removed B from Released_Status
823
824 SELECT count(*)
825 INTO l_smc_model
826 FROM Wsh_Delivery_Details
827 WHERE Ship_Model_Complete_Flag = 'Y'
828 AND Top_Model_Line_Id = p_line_rec.top_model_line_id
829 AND Source_Header_Id = p_line_rec.header_id
830 AND Source_Code = 'OE'
831 AND Released_Status In ('S','Y','C')
832 AND ROWNUM = 1;
833
834 IF l_smc_model > 0 AND l_shipset_enforce = 'Y' THEN
835 FND_MESSAGE.Set_Name ('ONT','ONT_SMC_PICK_RELEASED');
836 BEGIN
837 SELECT ORDERED_ITEM,inventory_item_id
838 INTO l_model_name,l_model_item_id
839 FROM OE_ORDER_LINES
840 WHERE line_id = p_line_rec.top_model_line_id;
841 EXCEPTION
842 WHEN NO_DATA_FOUND THEN
843 l_model_name := null;
844 END;
845 FND_MESSAGE.Set_Token('MODEL',nvl(l_model_name,l_model_item_id));
846 OE_MSG_PUB.Add;
847 x_return_status := FND_API.G_RET_STS_ERROR;
848 END IF;
849 END IF;
850
851
852 IF l_debug_level > 0 then
853 OE_DEBUG_PUB.Add('Exiting OE_VALIDATE_LINE.Validate_Shipset_SMC:'
854 ||x_return_status,1);
855 END IF;
856
857 EXCEPTION
858 WHEN FND_API.G_EXC_ERROR THEN
859 if l_debug_level > 0 then
860 OE_DEBUG_PUB.Add('Expected Error in Validate_Shipset_SMC ',2);
861 End if;
862
863 x_return_status := FND_API.G_RET_STS_ERROR;
864
865 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
866 if l_debug_level > 0 then
867 OE_DEBUG_PUB.Add('Unexpected Error in Validate_Shipset_SMC:'||SqlErrm, 1);
868 End if;
869
870 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
871
872 WHEN OTHERS THEN
873 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
874 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
875 THEN
876 OE_MSG_PUB.Add_Exc_Msg
877 ( 'OE_VALIDATE_LINE',
878 'Validate_Shipset_SMC');
879 END IF;
880 END Validate_Shipset_SMC;
881
882
883 FUNCTION Get_Date_Type
884 ( p_header_id IN NUMBER)
885 RETURN VARCHAR2
886 IS
887 l_order_date_type_code VARCHAR2(30) := null;
888 BEGIN
889
890 SELECT order_date_type_code
891 INTO l_order_date_type_code
892 FROM oe_order_headers
893 WHERE header_id = p_header_id;
894
895 RETURN l_order_date_type_code;
896
897
898 EXCEPTION
899 WHEN NO_DATA_FOUND THEN
900 RETURN NULL;
901 WHEN OTHERS THEN
902 RETURN null;
903 END Get_Date_Type;
904
905 PROCEDURE Validate_Decimal_Quantity
906 ( p_item_id IN NUMBER
907 , p_item_type_code IN VARCHAR2
908 , p_input_quantity IN NUMBER
909 , p_uom_code IN VARCHAR2
910 , p_ato_line_id IN NUMBER
911 , p_line_id IN NUMBER
912 , p_line_num IN VARCHAR2
913 -- 3705273
914 , p_action_split IN VARCHAR2 := 'N'
915 , x_output_quantity OUT NOCOPY NUMBER
916 , x_return_status IN OUT NOCOPY VARCHAR2
917 ) IS
918 l_validated_quantity NUMBER;
919 l_primary_quantity NUMBER;
920 l_qty_return_status VARCHAR2(1);
921 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
922 BEGIN
923 IF l_debug_level > 0 then
924 OE_DEBUG_PUB.Add('Entering OE_VALIDATE_LINE.Validate_Decimal_Quantity',1);
925 END IF;
926 -- validate input quantity
927 -- Changes for Decimal ATO's
928
929 IF (p_input_quantity is not null AND
930 p_input_quantity <> FND_API.G_MISS_NUM) THEN
931
932 IF trunc(p_input_quantity) <> p_input_quantity THEN
933 IF l_debug_level > 0 then
934 oe_debug_pub.add('input quantity is decimal',2);
935 END IF;
936
937 IF p_item_type_code is not NULL THEN
938
939 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
940
941 IF p_item_type_code IN ('MODEL', 'KIT','CLASS','INCLUDED', 'CONFIG') OR
942 (p_item_type_code = 'OPTION' AND
943 (p_ato_line_id is NULL OR
944 p_ato_line_id = p_line_id)) THEN
945 IF l_debug_level > 0 then
946 OE_DEBUG_PUB.Add('item is config related with decimal qty',2);
947 END IF;
948 FND_MESSAGE.SET_NAME('ONT', 'OE_CONFIG_NO_DECIMALS');
949 FND_MESSAGE.SET_TOKEN('ITEM', nvl(OE_Id_To_Value.Inventory_Item(p_item_id),p_item_id));
950 FND_Message.Set_Token('LINE_NUM', p_line_num);
951 OE_MSG_PUB.Add;
952 x_return_status := FND_API.G_RET_STS_ERROR;
953 END IF;
954
955 ELSE
956
957 IF p_item_type_code IN ('MODEL', 'KIT','CLASS','INCLUDED','OPTION', 'CONFIG') THEN
958 IF l_debug_level > 0 then
959 OE_DEBUG_PUB.Add('item is config related with decimal qty',2);
960 END IF;
961 FND_MESSAGE.SET_NAME('ONT', 'OE_CONFIG_NO_DECIMALS');
962 FND_MESSAGE.SET_TOKEN('ITEM', nvl(OE_Id_To_Value.Inventory_Item(p_item_id),p_item_id));
963 FND_Message.Set_Token('LINE_NUM', p_line_num);
964 OE_MSG_PUB.Add;
965 x_return_status := FND_API.G_RET_STS_ERROR;
966 END IF;
967
968 END IF;
969
970 END IF; -- item_type_code is null
971 END IF; -- if not decimal qty
972
973 /* Moved this code out nocopy of the input_quantity IF statement for bug 2253207 */
974 IF l_debug_level > 0 then
975 oe_debug_pub.add('before calling inv decimals api',2);
976 END IF;
977 inv_decimals_pub.validate_quantity(
978 p_item_id => p_item_id,
979 p_organization_id =>
980 OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID'),
981 p_input_quantity => p_input_quantity,
982 p_uom_code => p_uom_code,
983 x_output_quantity => l_validated_quantity,
984 x_primary_quantity => l_primary_quantity,
985 x_return_status => l_qty_return_status);
986
987 IF l_qty_return_status = 'W' OR l_qty_return_status = 'E' THEN
988 IF l_debug_level > 0 then
989 oe_debug_pub.add('inv decimal api return ' || l_qty_return_status,2);
990 oe_debug_pub.add('input_qty ' || p_input_quantity,2);
991 oe_debug_pub.add('l_pri_qty ' || l_primary_quantity,2);
992 oe_debug_pub.add('l_val_qty ' || l_validated_quantity,2);
993 END IF;
994 x_output_quantity := l_validated_quantity;
995
996 /* bug 2926436 */
997 -- bug 3705273 condition added for split lines.
998 IF l_qty_return_status = 'W' THEN
999 IF OE_CONFIG_UTIL.CASCADE_CHANGES_FLAG = 'Y' OR
1000 OE_CONFIG_PVT.OECFG_VALIDATE_CONFIG = 'N' OR
1001 p_action_split = 'Y' THEN
1002 IF l_debug_level > 0 then
1003 OE_DEBUG_PUB.Add('do not error out,cascading',1);
1004 END IF;
1005 x_return_status := FND_API.G_RET_STS_SUCCESS;
1006 ELSE
1007 fnd_message.set_name('ONT', 'OE_DECIMAL_MAX_PRECISION');
1008 -- move INV error message to OE message stack
1009 oe_msg_pub.add;
1010 x_return_status := FND_API.G_RET_STS_ERROR;
1011 END IF;
1012 ELSIF l_qty_return_status = 'E' THEN
1013 oe_msg_pub.add;
1014 x_return_status := FND_API.G_RET_STS_ERROR;
1015 END IF;
1016
1017 ELSIF l_qty_return_status = 'S' THEN
1018 x_output_quantity := p_input_quantity;
1019 END IF;
1020
1021 END IF; -- quantity is null
1022 IF l_debug_level > 0 then
1023 OE_DEBUG_PUB.Add('Exiting OE_VALIDATE_LINE.Validate_Decimal_Quantity',1);
1024 END IF;
1025 END Validate_Decimal_Quantity;
1026
1027 /*---------------------------------------------------------------------
1028 PROCEDURE Decimal_Ratio_Check
1029 Description: This procedure was initially part of package OE_CONFIG_UTIL
1030 This is has been moved here becuase this code is common for all both cz
1031 and bill validation. This checks whether there is any decimal ratio exists
1032 between model and children and raises an error. After pack J decimal ratios
1033 for ATO options are allowed.
1034 -----------------------------------------------------------------------*/
1035
1036 PROCEDURE Decimal_Ratio_Check
1037 (p_line_rec IN OE_ORDER_PUB.Line_rec_type
1038 ,x_return_status OUT NOCOPY VARCHAR2)
1039 IS
1040 l_ordered_item VARCHAR2(2000);
1041 l_item_type_code VARCHAR2(30);
1042 l_inv_item_id NUMBER;
1043 l_ordered_quantity NUMBER;
1044 l_indivisible_flag VARCHAR2(1);
1045 --
1046 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1047 --
1048 BEGIN
1049
1050 x_return_status := FND_API.G_RET_STS_SUCCESS;
1051
1052 IF l_debug_level > 0 THEN
1053 OE_DEBUG_PUB.ADD('Entering Decimal_ratio_check '||p_line_rec.line_id, 1);
1054 OE_DEBUG_PUB.ADD('Item Type:'||p_line_rec.item_type_code, 1);
1055 END IF;
1056
1057 SELECT ordered_item, item_type_code,inventory_item_id,ordered_quantity
1058 INTO l_ordered_item, l_item_type_code,l_inv_item_id,l_ordered_quantity
1059 FROM oe_order_lines
1060 WHERE line_id = p_line_rec.top_model_line_id;
1061
1062 IF MOD(p_line_rec.ordered_quantity,l_ordered_quantity) <> 0 THEN
1063
1064 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
1065
1066 -- No Checks will be done for ATO Options.
1067
1068 IF p_line_rec.ato_line_id is not null AND
1069 p_line_rec.item_type_code = 'OPTION' AND
1070 p_line_rec.ato_line_id <> p_line_rec.line_id THEN
1071 IF l_debug_level > 0 THEN
1072 OE_DEBUG_PUB.ADD('ATO Option:'||p_line_rec.line_id, 1);
1073 END IF;
1074
1075 SELECT INDIVISIBLE_FLAG
1076 INTO l_indivisible_flag
1077 FROM mtl_system_items
1078 WHERE inventory_item_id = p_line_rec.inventory_item_id
1079 AND organization_id =
1080 OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID');
1081
1082 IF nvl(l_indivisible_flag, 'N') = 'N' THEN
1083 IF l_debug_level > 0 THEN
1084 OE_DEBUG_PUB.ADD('this Option can have decimal ratio', 1);
1085 END IF;
1086 RETURN;
1087 ELSE
1088 IF FLOOR(p_line_rec.ordered_quantity) <>
1089 p_line_rec.ordered_quantity THEN
1090 IF l_debug_level > 0 THEN
1091 OE_DEBUG_PUB.ADD
1092 ('this Option has decimal qty no need to check ratio', 1);
1093 END IF;
1094 RETURN;
1095 END IF;
1096 END IF;
1097 END IF;
1098 END IF;
1099
1100 FND_MESSAGE.Set_Name('ONT', 'OE_CONFIG_DECIMAL_RATIO');
1101
1102 FND_MESSAGE.Set_TOKEN('ITEM', nvl(p_line_rec.ordered_item,
1103 p_line_rec.inventory_item_id));
1104 FND_MESSAGE.Set_TOKEN('TYPECODE', p_line_rec.item_type_code);
1105 FND_MESSAGE.Set_TOKEN('VALUE',
1106 to_char(l_ordered_quantity/p_line_rec.ordered_quantity));
1107
1108 FND_MESSAGE.Set_TOKEN('MODEL', nvl(l_ordered_item,l_inv_item_id));
1109 FND_MESSAGE.Set_TOKEN('PTYPECODE', l_item_type_code);
1110
1111 OE_MSG_PUB.Add;
1112
1113 x_return_status := FND_API.G_RET_STS_ERROR;
1114
1115 END IF;
1116
1117 IF l_debug_level > 0 THEN
1118 oe_debug_pub.add('Leaving decimal_ratio_check' , 3 );
1119 END IF;
1120
1121 EXCEPTION
1122 WHEN OTHERS THEN
1123 IF l_debug_level > 0 THEN
1124 oe_debug_pub.add('Decimal_ratio_check '|| sqlerrm , 1);
1125 END IF;
1126
1127 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1128
1129 END Decimal_Ratio_Check;
1130
1131
1132
1133 Procedure Validate_Line_Type(p_line_rec IN oe_order_pub.line_rec_type,
1134 p_old_line_rec IN oe_order_pub.line_rec_type)
1135 IS
1136
1137 lorder_type_id NUMBER;
1138 lexists VARCHAR2(30);
1139 lprocessname VARCHAR2(80);
1140 l_new_wf_item_type VARCHAR2(30);
1141 l_old_wf_item_type VARCHAR2(30);
1142 lline_category_code VARCHAR2(30);
1143
1144 CURSOR find_LineProcessname IS
1145 SELECT 'EXISTS'
1146 FROM oe_workflow_assignments a
1147 WHERE a.line_type_id = p_line_rec.line_type_id
1148 AND nvl(a.item_type_code,nvl(l_new_wf_item_type,'-99')) = nvl(l_new_wf_item_type,'-99')
1149 AND a.process_name = lprocessname
1150 AND a.order_type_id = lorder_type_id
1151 AND sysdate BETWEEN A.START_DATE_ACTIVE
1152 AND nvl( A.END_DATE_ACTIVE, sysdate + 1 )
1153 ORDER BY a.item_type_code ;
1154
1155 CURSOR Get_Order_Type IS
1156 SELECT order_type_id
1157 FROM oe_order_headers
1158 WHERE header_id = p_line_rec.header_id ;
1159
1160 Cursor find_config_assign is
1161 SELECT 'EXISTS'
1162 FROM oe_workflow_assignments a
1163 WHERE a.line_type_id = p_line_rec.line_type_id
1164 AND a.item_type_code = l_new_wf_item_type
1165 AND a.order_type_id = lorder_type_id
1166 AND sysdate between A.START_DATE_ACTIVE
1167 AND nvl( A.END_DATE_ACTIVE, sysdate + 1 );
1168
1169 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1170 BEGIN
1171 IF l_debug_level > 0 then
1172 OE_DEBUG_PUB.Add('Entering OE_VALIDATE_LINE.Validate_Line_Type',1);
1173 END IF;
1174
1175 /* Added for the bug #3257965.
1176 Validation for Line Type and Line Category.
1177 */
1178 IF (NOT OE_GLOBALS.EQUAL(p_line_rec.line_category_code,p_old_line_rec.line_category_code))
1179 OR (NOT OE_GLOBALS.EQUAL(p_line_rec.line_type_id,p_old_line_rec.line_type_id))
1180 THEN
1181 IF l_debug_level > 0 then
1182 OE_DEBUG_PUB.Add('IN OE_VALIDATE_LINE.Validate_Line_Type old line cate: '||p_old_line_rec.line_category_code);
1183 OE_DEBUG_PUB.Add('IN OE_VALIDATE_LINE.Validate_Line_Type new line cate: '||p_line_rec.line_category_code);
1184 OE_DEBUG_PUB.Add('IN OE_VALIDATE_LINE.Validate_Line_Type old line type Id: '||p_old_line_rec.line_type_id);
1185 OE_DEBUG_PUB.Add('IN OE_VALIDATE_LINE.Validate_Line_Type new line type Id: '||p_line_rec.line_type_id);
1186 END IF;
1187 select ORDER_CATEGORY_CODE
1188 into lline_category_code from oe_transaction_types_all
1189 where transaction_type_id = p_line_rec.line_type_id;
1190
1191 if p_line_rec.line_category_code <> lline_category_code then
1192 IF l_debug_level > 0 then
1193 oe_debug_pub.add(' Validate Line Type Line Cat Code from the OE_TRXT_ALL table: '||lline_category_code);
1194 oe_debug_pub.add(' Validate Line Type Line Cat Code from the UI: '||p_line_rec.line_category_code);
1195 END IF;
1196 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
1197 fnd_message.set_token('ATTRIBUTE', OE_Order_Util.Get_Attribute_Name('Line_type_id'));
1198 OE_MSG_PUB.Add;
1199 RAISE FND_API.G_EXC_ERROR;
1200 end if;
1201 END IF;
1202
1203
1204 IF p_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
1205
1206 l_new_wf_item_type := OE_Order_WF_Util.get_wf_item_type(p_line_rec);
1207 l_old_wf_item_type := OE_Order_WF_Util.get_wf_item_type(p_old_line_rec);
1208
1209 IF NOT OE_Globals.Equal(l_new_wf_item_type, l_old_wf_item_type)
1210 THEN
1211 oe_debug_pub.add('workflow item type changed', 1);
1212
1213 -- FND_Message.Set_Name('ONT', 'OE_WF_ITEM_TYPE_CHANGED');
1214 FND_Message.Set_Name('ONT', 'OE_ITEM_TYPE_CONST');
1215 oe_msg_pub.add;
1216 RAISE FND_API.G_EXC_ERROR;
1217 END IF;
1218
1219 IF (NOT OE_GLOBALS.EQUAL(p_line_rec.line_type_id,p_old_line_rec.line_type_id))
1220 OR (NOT OE_GLOBALS.EQUAL(p_line_rec.item_type_code,p_old_line_rec.item_type_code))
1221 THEN
1222
1223 -- Get Wf itme type
1224 -- litemtype := OE_Order_WF_Util.get_wf_item_type(p_line_rec);
1225
1226 OPEN Get_Order_Type;
1227 FETCH Get_Order_Type
1228 INTO lorder_type_id;
1229 CLOSE Get_Order_Type;
1230
1231 Select root_activity
1232 Into lprocessname
1233 From wf_items_v
1234 Where item_type = 'OEOL'
1235 And item_key = to_char(p_line_rec.line_id) -- 2212128
1236 And rownum = 1;
1237
1238
1239 OPEN find_LineProcessname;
1240 FETCH find_LineProcessname
1241 INTO lexists;
1242 CLOSE find_LineProcessname;
1243
1244 IF lexists IS NULL THEN
1245 IF l_debug_level > 0 then
1246 oe_debug_pub.add('Flow is different',1);
1247 END IF;
1248 RAISE NO_DATA_FOUND;
1249 END IF;
1250
1251 END IF;
1252 ELSIF p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
1253
1254 IF p_line_rec.ITEM_TYPE_CODE = OE_GLOBALS.G_ITEM_CONFIG THEN
1255 l_new_wf_item_type := OE_Order_WF_Util.get_wf_item_type(p_line_rec);
1256
1257 OPEN Get_Order_Type;
1258 FETCH Get_Order_Type
1259 INTO lorder_type_id;
1260 CLOSE Get_Order_Type;
1261
1262 OPEN find_config_assign;
1263 FETCH find_config_assign
1264 INTO lexists;
1265 CLOSE find_config_assign;
1266
1267 IF lexists IS NULL THEN
1268 IF l_debug_level > 0 then
1269 oe_debug_pub.add('No explicit assignment exists',2);
1270 END IF;
1271 FND_MESSAGE.SET_NAME('ONT','OE_EXP_ASSIGN_REQ');
1272 OE_MSG_PUB.ADD;
1273 RAISE FND_API.G_EXC_ERROR;
1274 END IF;
1275
1276 END IF;
1277
1278 END IF; -- Operation
1279 IF l_debug_level > 0 then
1280 OE_DEBUG_PUB.Add('Exiting OE_VALIDATE_LINE.Validate_Line_Type',1);
1281 END IF;
1282 EXCEPTION
1283 WHEN NO_DATA_FOUND THEN
1284 FND_MESSAGE.SET_NAME('ONT','OE_FLOW_CNT_CHANGE');
1285 OE_MSG_PUB.ADD;
1286 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1287 WHEN FND_API.G_EXC_ERROR THEN
1288 RAISE FND_API.G_EXC_ERROR;
1289
1290 WHEN OTHERS THEN
1291 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1292 THEN
1293 OE_MSG_PUB.Add_Exc_Msg
1294 ( G_PKG_NAME ,
1295 'Validate_Line_Type'
1296 );
1297 END IF;
1298 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1299 END Validate_line_type;
1300
1301
1302 FUNCTION Validate_Receiving_Org
1303 ( p_inventory_item_id IN NUMBER
1304 , p_ship_from_org_id IN NUMBER)
1305 RETURN BOOLEAN
1306 IS
1307 l_validate VARCHAR2(1) := 'Y';
1308 l_dummy VARCHAR2(10);
1309 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1310 BEGIN
1311 IF l_debug_level > 0 then
1312 OE_DEBUG_PUB.Add('Entering OE_VALIDATE_LINE.Validate_Receiving_Org',1);
1313 END IF;
1314
1315 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510'
1316 -- AND INVCONV
1317 -- NOT INV_GMI_RSV_BRANCH.Process_Branch(p_ship_from_org_id) INVCONV
1318 THEN
1319
1320 SELECT null
1321 INTO l_dummy
1322 FROM mtl_system_items_b msi,
1323 org_organization_definitions org
1324 WHERE msi.inventory_item_id = p_inventory_item_id
1325 AND org.organization_id= msi.organization_id
1326 AND msi.customer_order_enabled_flag =
1327 DECODE(l_validate, 'Y', 'Y',
1328 msi.customer_order_enabled_flag)
1329 AND sysdate <= nvl( org.disable_date, sysdate)
1330 AND org.organization_id= p_ship_from_org_id;
1331 ELSE
1332 SELECT null
1333 INTO l_dummy
1334 FROM mtl_system_items_b msi,
1335 org_organization_definitions org
1336 WHERE msi.inventory_item_id = p_inventory_item_id
1337 AND org.organization_id= msi.organization_id
1338 AND msi.customer_order_enabled_flag =
1339 DECODE(l_validate, 'Y', 'Y',
1340 msi.customer_order_enabled_flag)
1341 AND sysdate <= nvl( org.disable_date, sysdate)
1342 AND org.organization_id= p_ship_from_org_id
1343 AND org.set_of_books_id= ( SELECT fsp.set_of_books_id
1344 FROM financials_system_parameters fsp);
1345
1346 END IF;
1347 IF l_debug_level > 0 then
1348 OE_DEBUG_PUB.Add('Exiting OE_VALIDATE_LINE.Validate_Receiving_Org',1);
1349 END IF;
1350
1351 RETURN TRUE;
1352 EXCEPTION
1353 WHEN NO_DATA_FOUND THEN
1354 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ITEM_WHSE');
1355 OE_MSG_PUB.add;
1356 RETURN FALSE;
1357 WHEN OTHERS THEN
1358 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ITEM_WHSE');
1359 OE_MSG_PUB.add;
1360 RETURN FALSE;
1361 END Validate_Receiving_Org;
1362
1363 -- bug 6647169 begin
1364 FUNCTION Validate_Warehouse_Change
1365 ( p_line_rec IN OE_ORDER_PUB.Line_Rec_Type
1366 , p_old_line_rec IN OE_ORDER_PUB.Line_Rec_Type
1367 ) RETURN BOOLEAN
1368 IS
1369 l_result BOOLEAN;
1370 l_shipable_flag_new VARCHAR2(1);
1371 l_shipable_flag_old VARCHAR2(1);
1372 BEGIN
1373 IF(Nvl(p_line_rec.shipping_interfaced_flag,'N') = 'Y') THEN
1374 BEGIN
1375 SELECT a.shippable_item_flag, b.shippable_item_flag
1376 INTO l_shipable_flag_old,l_shipable_flag_new
1377 FROM mtl_system_items_b a,mtl_system_items_b b
1378 WHERE a.inventory_item_id = p_line_rec.inventory_item_id
1379 AND b.inventory_item_id = a.inventory_item_id
1380 AND a.organization_id = p_old_line_rec.ship_from_org_id
1381 AND b.organization_id = p_line_rec.ship_from_org_id;
1382
1383 oe_debug_pub.add('Old Shipable flag, New shipable flag : '||l_shipable_flag_old||l_shipable_flag_new);
1384 IF (l_shipable_flag_old <> l_shipable_flag_new AND l_shipable_flag_new = 'N') THEN
1385 l_result := FALSE;
1386 FND_MESSAGE.SET_NAME('ONT','OE_INVLD_CHG_SHP_FROM_ORG');
1387 oe_msg_pub.add;
1388 ELSE
1389 l_result := TRUE;
1390 END IF;
1391 EXCEPTION when others then
1392 l_result := TRUE;
1393 END;
1394 ELSE
1395 l_result := TRUE;
1396 END IF;
1397 RETURN(l_result);
1398 END Validate_Warehouse_Change;
1399 -- bug 6647169 end
1400
1401
1402 FUNCTION Validate_Item_Warehouse
1403 ( p_inventory_item_id IN NUMBER
1404 , p_ship_from_org_id IN NUMBER
1405 , p_item_type_code IN VARCHAR2
1406 , p_line_id IN NUMBER
1407 , p_top_model_line_id IN NUMBER
1408 , p_source_document_type_id IN NUMBER /*Bug 1741158- chhung */
1409 , p_line_category_code IN VARCHAR2)/*Bug 1741158- chhung */
1410 RETURN BOOLEAN
1411 IS
1412 --l_validate VARCHAR2(1) := 'Y'; /*chhung comment out :bug 1741158*/
1413 l_dummy VARCHAR2(10);
1414 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1415 BEGIN
1416 IF l_debug_level > 0 then
1417 oe_debug_pub.add('Entering Validate_Item_Warehouse',1);
1418 oe_debug_pub.add('p_inventory_item_id: '||p_inventory_item_id);
1419 oe_debug_pub.add('p_ship_from_org_id: '||p_ship_from_org_id);
1420 oe_debug_pub.add('p_item_type_code: '||p_item_type_code);
1421 oe_debug_pub.add('p_line_id: '||p_line_id);
1422 oe_debug_pub.add('p_top_model_line_id: '||p_top_model_line_id);
1423 oe_debug_pub.add('p_source_document_type_id: '||p_source_document_type_id);
1424 oe_debug_pub.add('p_line_category_code: '||p_line_category_code);
1425 END IF;
1426 -- The customer_order_enabled_flag for config item
1427 -- is set to 'N'
1428
1429 /* Bug 1741158 chhung modify BEGIN */
1430 IF p_line_category_code ='ORDER' THEN
1431 IF p_source_document_type_id = 10
1432 /* for Internal Orders */
1433 /* Internal Orders only support standard item */
1434 THEN
1435 SELECT null
1436 INTO l_dummy
1437 FROM mtl_system_items_b msi,
1438 org_organization_definitions org
1439 WHERE msi.inventory_item_id = p_inventory_item_id
1440 AND org.organization_id= msi.organization_id
1441 AND msi.internal_order_enabled_flag = 'Y'
1442 AND sysdate <= nvl( org.disable_date, sysdate)
1443 AND org.organization_id= p_ship_from_org_id
1444 AND rownum=1;
1445 ELSE /* other orders except Internal*/
1446 IF p_item_type_code = OE_GLOBALS.G_ITEM_INCLUDED OR
1447 p_item_type_code = OE_GLOBALS.G_ITEM_CONFIG
1448 THEN
1449 SELECT null
1450 INTO l_dummy
1451 FROM mtl_system_items_b msi,
1452 org_organization_definitions org
1453 WHERE msi.inventory_item_id = p_inventory_item_id
1454 AND org.organization_id= msi.organization_id
1455 AND sysdate <= nvl( org.disable_date, sysdate)
1456 AND org.organization_id= p_ship_from_org_id
1457 AND rownum=1;
1458
1459 ELSIF p_item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
1460 p_item_type_code = OE_GLOBALS.G_ITEM_OPTION OR
1461 (p_item_type_code = OE_GLOBALS.G_ITEM_KIT AND
1462 nvl(p_top_model_line_id, -1) <> p_line_id)
1463 THEN
1464 --Commented for bug 4343544 start
1465 /*SELECT null
1466 INTO l_dummy
1467 FROM mtl_system_items_b msi,
1468 org_organization_definitions org
1469 WHERE msi.inventory_item_id = p_inventory_item_id
1470 AND org.organization_id= msi.organization_id
1471 AND sysdate <= nvl( org.disable_date, sysdate)
1472 AND org.organization_id= p_ship_from_org_id
1473 AND msi.customer_order_enabled_flag =
1474 Decode(g_cust_ord_enabled_flag, 'Y'
1475 ,'Y','N',msi.customer_order_enabled_flag)
1476 AND rownum=1;*/
1477 --Commented for bug 4343544 end
1478 --Added for bug 4343544 start changed decode for better performance
1479 if g_cust_ord_enabled_flag='Y' then
1480 SELECT null
1481 INTO l_dummy
1482 FROM mtl_system_items_b msi,
1483 org_organization_definitions org
1484 WHERE msi.inventory_item_id = p_inventory_item_id
1485 AND org.organization_id= msi.organization_id
1486 AND sysdate <= nvl( org.disable_date, sysdate)
1487 AND org.organization_id= p_ship_from_org_id
1488 AND msi.customer_order_enabled_flag = g_cust_ord_enabled_flag
1489 AND rownum=1;
1490 else
1491 SELECT null
1492 INTO l_dummy
1493 FROM mtl_system_items_b msi,
1494 org_organization_definitions org
1495 WHERE msi.inventory_item_id = p_inventory_item_id
1496 AND org.organization_id= msi.organization_id
1497 AND sysdate <= nvl( org.disable_date, sysdate)
1498 AND org.organization_id= p_ship_from_org_id
1499 AND rownum =1;
1500 end if;
1501 --Added for bug 4343544 end
1502 ELSE /* item type is MODEL,STANDARD,SERVICE,KIT in top most level*/
1503 SELECT null
1504 INTO l_dummy
1505 FROM mtl_system_items_b msi,
1506 org_organization_definitions org
1507 WHERE msi.inventory_item_id = p_inventory_item_id
1508 AND org.organization_id= msi.organization_id
1509 AND msi.customer_order_enabled_flag = 'Y'
1510 AND sysdate <= nvl( org.disable_date, sysdate)
1511 AND org.organization_id= p_ship_from_org_id
1512 AND rownum=1;
1513 END IF;
1514 END IF;
1515 /* Bug 1741158 chhung modify END */
1516 ELSE /* p_line_category_code is 'RETURN */
1517 -- It's for Return group!!
1518 null;
1519 END IF;
1520 IF l_debug_level > 0 then
1521 oe_debug_pub.add('Exiting Validate_Item_Warehouse',1);
1522 END IF;
1523 RETURN TRUE;
1524
1525 EXCEPTION
1526 WHEN NO_DATA_FOUND THEN
1527 IF l_debug_level > 0 then
1528 oe_debug_pub.add('RR: No data found',1);
1529 END IF;
1530
1531 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ITEM_WHSE');
1532 OE_MSG_PUB.add;
1533 RETURN FALSE;
1534
1535 WHEN OTHERS THEN
1536 IF l_debug_level > 0 then
1537 oe_debug_pub.add('RR: OTHERS',1);
1538 END IF;
1539 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ITEM_WHSE');
1540 OE_MSG_PUB.add;
1541 RETURN FALSE;
1542
1543 END Validate_Item_Warehouse;
1544
1545 FUNCTION Validate_task
1546 ( p_project_id IN NUMBER
1547 , p_task_id IN NUMBER)
1548 RETURN BOOLEAN
1549 IS
1550 l_dummy VARCHAR2(10);
1551 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1552 BEGIN
1553 IF l_debug_level > 0 then
1554 oe_debug_pub.add('Entering Validate_Task',1);
1555 END IF;
1556 SELECT 'VALID'
1557 INTO l_dummy
1558 FROM mtl_task_v
1559 WHERE project_id = p_project_id
1560 AND task_id = p_task_id;
1561
1562 IF l_debug_level > 0 then
1563 oe_debug_pub.add('Exiting Validate_Task',1);
1564 END IF;
1565 RETURN TRUE;
1566
1567 EXCEPTION
1568
1569 WHEN OTHERS THEN
1570 RETURN FALSE;
1571
1572 END Validate_task;
1573
1574 FUNCTION Validate_task_reqd
1575 ( p_project_id IN NUMBER
1576 ,p_ship_from_org_id IN NUMBER)
1577 RETURN BOOLEAN
1578 IS
1579 l_project_control_level NUMBER;
1580 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1581 BEGIN
1582 IF l_debug_level > 0 then
1583 oe_debug_pub.add('Entering Validate_task_reqd',1);
1584 END IF;
1585
1586 -- If project control level in MTL_PARAMETERS for the warehouse
1587 -- is set to 'Task', then project references on the order must
1588 -- consist of both Project and Task.
1589
1590 SELECT NVL(PROJECT_CONTROL_LEVEL,0)
1591 INTO l_project_control_level
1592 FROM MTL_PARAMETERS
1593 WHERE ORGANIZATION_ID = p_ship_from_org_id;
1594
1595 IF l_project_control_level = 2 -- control level is 'Task'
1596 THEN
1597 IF l_debug_level > 0 then
1598 oe_debug_pub.add('Exiting Validate_task_reqd',1);
1599 END IF;
1600 RETURN TRUE;
1601 ELSE
1602 IF l_debug_level > 0 then
1603 oe_debug_pub.add('Exiting Validate_task_reqd',1);
1604 END IF;
1605 RETURN FALSE;
1606 END IF;
1607
1608 EXCEPTION
1609
1610 WHEN OTHERS THEN
1611 RETURN FALSE;
1612
1613 END Validate_task_reqd;
1614
1615 FUNCTION Validate_Item_Fields
1616 ( p_inventory_item_id IN NUMBER
1617 , p_ordered_item_id IN NUMBER
1618 , p_item_identifier_type IN VARCHAR2
1619 , p_ordered_item IN VARCHAR2
1620 , p_sold_to_org_id IN NUMBER
1621 , p_line_category_code IN VARCHAR2 /*Bug 1678296- chhung adds*/
1622 , p_item_type_code IN VARCHAR2 /*Bug 1741158- chhung adds */
1623 , p_line_id IN NUMBER /*Bug 1741158- chhung adds */
1624 , p_top_model_line_id IN NUMBER /*Bug 1741158- chhung adds */
1625 , p_source_document_type_id IN NUMBER /*Bug 1741158- chhung adds */
1626 , p_operation IN VARCHAR2 /* Bug 1805985 add*/
1627 )
1628 RETURN BOOLEAN
1629 IS
1630 l_dummy VARCHAR2(10);
1631
1632 /* added for 2219230 */
1633 l_org_flag NUMBER := 2;
1634 item_val_org NUMBER := to_number(OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID'));
1635 CURSOR xref IS
1636 SELECT DECODE(items.org_independent_flag, 'Y', 1,
1637 DECODE(items.organization_id, item_val_org, 1, 2))
1638 FROM mtl_cross_reference_types types
1639 , mtl_cross_references items
1640 , mtl_system_items_vl sitems
1641 WHERE types.cross_reference_type = items.cross_reference_type
1642 AND items.inventory_item_id = sitems.inventory_item_id
1643 AND sitems.organization_id = item_val_org
1644 AND sitems.inventory_item_id = p_inventory_item_id
1645 AND items.cross_reference_type = p_item_identifier_type
1646 AND items.cross_reference = p_ordered_item
1647 AND (types.disable_date is NULL or types.disable_date > sysdate) --And condition added for bug 3844345 shewgupt
1648 AND sitems.customer_order_enabled_flag = 'Y' --And condition added for bug 3844345 shewgupt
1649 ORDER BY 1;
1650
1651 --cursor added for bug 3844345
1652 CURSOR xref_return IS
1653 SELECT DECODE(items.org_independent_flag, 'Y', 1,
1654 DECODE(items.organization_id, item_val_org, 1, 2))
1655 FROM mtl_cross_reference_types types
1656 , mtl_cross_references items
1657 , mtl_system_items_vl sitems
1658 WHERE types.cross_reference_type = items.cross_reference_type
1659 AND items.inventory_item_id = sitems.inventory_item_id
1660 AND sitems.organization_id = item_val_org
1661 AND sitems.inventory_item_id = p_inventory_item_id
1662 AND items.cross_reference_type = p_item_identifier_type
1663 AND items.cross_reference = p_ordered_item
1664 ORDER BY 1;
1665 /* end of code added for 2219230 */
1666 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1667 BEGIN
1668 IF l_debug_level > 0 then
1669 oe_debug_pub.add('Entering Validate_Item_Fields',1);
1670 oe_debug_pub.add('p_inventory_item_id: '||p_inventory_item_id);
1671 oe_debug_pub.add('p_ordered_item_id: '||p_ordered_item_id);
1672 oe_debug_pub.add('p_item_identifier_type: '||p_item_identifier_type);
1673 oe_debug_pub.add('p_ordered_item: '||p_ordered_item);
1674 oe_debug_pub.add('p_sold_to_org_id: '||p_sold_to_org_id);
1675 oe_debug_pub.add('p_line_category_code: '||p_line_category_code);
1676 oe_debug_pub.add('p_item_type_code: '||p_item_type_code);
1677 oe_debug_pub.add('p_line_id: '||p_line_id);
1678 oe_debug_pub.add('p_top_model_line_id: '||p_top_model_line_id);
1679 oe_debug_pub.add('p_source_document_type_id: '||p_source_document_type_id);
1680 oe_debug_pub.add('p_operation: '||p_operation);
1681 oe_debug_pub.add('pricing_recursion : '||OE_GLOBALS.g_pricing_recursion);
1682
1683 -- Bug 1805985 start
1684 IF(OE_GLOBALS.G_UI_FLAG) THEN
1685 oe_debug_pub.add('G_UI_FLAG = TRUE');
1686 ELSE
1687 oe_debug_pub.add('G_UI_FLAG = FALSE');
1688 END IF;
1689 -- Bug 1805985 end
1690 END IF;
1691
1692 IF nvl(p_item_identifier_type, 'INT') = 'INT' THEN
1693 /* Bug 1741158 chhung modify BEGIN */
1694 IF p_line_category_code ='ORDER' THEN
1695 IF p_source_document_type_id = 10
1696 /* for Internal Orders */
1697 /* Internal Orders only support standard item */
1698 THEN
1699 SELECT 'valid'
1700 INTO l_dummy
1701 FROM mtl_system_items_b
1702 WHERE inventory_item_id = p_inventory_item_id
1703 AND organization_id = OE_Sys_Parameters.VALUE_WNPS('MASTER_ORGANIZATION_ID')
1704 AND internal_order_enabled_flag = 'Y';
1705 ELSE /* other orders except Internal*/
1706 IF p_item_type_code = OE_GLOBALS.G_ITEM_INCLUDED OR
1707 p_item_type_code = OE_GLOBALS.G_ITEM_CONFIG OR
1708 p_item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
1709 p_item_type_code = OE_GLOBALS.G_ITEM_OPTION OR
1710 (p_item_type_code = OE_GLOBALS.G_ITEM_KIT AND
1711 nvl(p_top_model_line_id, -1) <> p_line_id)
1712 THEN
1713 SELECT 'valid'
1714 INTO l_dummy
1715 FROM mtl_system_items_b
1716 WHERE inventory_item_id = p_inventory_item_id
1717 AND organization_id = OE_Sys_Parameters.VALUE_WNPS('MASTER_ORGANIZATION_ID');
1718 ELSE /* item type is MODEL,STANDARD,SERVICE,KIT in top most level*/
1719
1720 /* Change for bug 1805985
1721 -------------------------------------------------------
1722 To avoid duplicated item validation for
1723 customer_order_enabled flag and item validation org in client and server side
1724 Logic :
1725 If item is buy item and G_UI_FLAG is 'FALSE', then we do server validation.
1726 If item is get/free item, then we always do server validation.
1727 */
1728
1729 IF (NOT (OE_GLOBALS.g_pricing_recursion='Y' AND p_operation= OE_GLOBALS.G_OPR_CREATE )) THEN
1730 -- Item is BUY item
1731 IF(NOT OE_GLOBALS.G_UI_FLAG) THEN
1732
1733 --changes for bug 4171642
1734 IF ( OE_ORDER_CACHE.g_item_rec.master_org_id <> FND_API.G_MISS_NUM ) AND
1735 ( OE_ORDER_CACHE.g_item_rec.master_org_id = g_master_org_id) AND
1736 ( OE_ORDER_CACHE.g_item_rec.inventory_item_id = p_inventory_item_id)
1737 THEN
1738 if OE_ORDER_CACHE.g_item_rec.customer_order_enabled_flag = 'Y' then
1739 l_dummy := 'VALID';
1740 else
1741 RAISE NO_DATA_FOUND ;
1742 end if;
1743 ELSE
1744 OE_ORDER_CACHE.Load_Item( p_key1 => p_inventory_item_id ) ;
1745 if (OE_ORDER_CACHE.g_item_rec.customer_order_enabled_flag = 'Y') then
1746 l_dummy := 'VALID';
1747 else
1748 Raise No_Data_Found ;
1749 end if ;
1750 END IF ;
1751
1752 /*SELECT 'valid'
1753 INTO l_dummy
1754 FROM mtl_system_items_b
1755 WHERE inventory_item_id = p_inventory_item_id
1756 AND organization_id = OE_Sys_Parameters.VALUE_WNPS('MASTER_ORGANIZATION_ID')
1757 AND customer_order_enabled_flag = 'Y'; */
1758 -- end bug 4171642
1759
1760 END IF;
1761 ELSE /* Item is get or free item */
1762
1763 --changes for bug 3975762
1764 IF ( OE_ORDER_CACHE.g_item_rec.master_org_id <> FND_API.G_MISS_NUM ) AND
1765 ( OE_ORDER_CACHE.g_item_rec.master_org_id = g_master_org_id) AND
1766 (OE_ORDER_CACHE.g_item_rec.inventory_item_id = p_inventory_item_id)
1767 THEN
1768 if OE_ORDER_CACHE.g_item_rec.customer_order_enabled_flag = 'Y' then
1769 l_dummy := 'VALID';
1770 else
1771 RAISE NO_DATA_FOUND ;
1772 end if ;
1773 ELSE
1774 OE_ORDER_CACHE.Load_Item( p_key1 => p_inventory_item_id ) ;
1775 if (OE_ORDER_CACHE.g_item_rec.customer_order_enabled_flag = 'Y') then
1776 l_dummy := 'VALID';
1777 else
1778 Raise No_Data_Found ;
1779 end if ;
1780 END IF ;
1781 -- bug 4171642
1782
1783 /*SELECT 'valid'
1784 INTO l_dummy
1785 FROM mtl_system_items_b
1786 WHERE inventory_item_id = p_inventory_item_id
1787 AND organization_id = OE_Sys_Parameters.VALUE_WNPS('MASTER_ORGANIZATION_ID')
1788 AND customer_order_enabled_flag = 'Y'; */
1789 -- End bug 4171642
1790 END IF;
1791 END IF;
1792 END IF;
1793 /* Bug 1741158 chhung modify END */
1794 ELSE /* p_line_category_code is 'RETURN */
1795 -- It's for Return group!!
1796 null;
1797 END IF;
1798 ELSIF nvl(p_item_identifier_type, 'INT') = 'CUST' THEN
1799 --Bug 1678296 chhung modify BEGIN
1800 IF p_line_category_code ='ORDER' THEN
1801
1802 SELECT 'valid'
1803 INTO l_dummy
1804 FROM mtl_customer_items citems
1805 ,mtl_customer_item_xrefs cxref
1806 ,mtl_system_items_vl sitems
1807 ,mtl_parameters mp -- 4402603
1808 WHERE citems.customer_item_id = cxref.customer_item_id
1809 AND cxref.inventory_item_id = sitems.inventory_item_id
1810 AND sitems.inventory_item_id = p_inventory_item_id
1811 AND sitems.organization_id =
1812 OE_Sys_Parameters.VALUE_WNPS('MASTER_ORGANIZATION_ID')
1813 AND sitems.customer_order_enabled_flag = 'Y' -- bug 3835602
1814 AND citems.customer_item_id = p_ordered_item_id
1815 AND citems.customer_id = p_sold_to_org_id
1816 AND citems.inactive_flag = 'N'
1817 AND cxref.inactive_flag = 'N'
1818 AND mp.organization_id = sitems.organization_id -- 4402603
1819 AND cxref.master_organization_id = mp.master_organization_id ; -- 4402603
1820
1821 ELSE /* line_category_code is 'RETURN'*/
1822
1823 SELECT 'valid'
1824 INTO l_dummy
1825 FROM mtl_customer_items citems
1826 ,mtl_customer_item_xrefs cxref
1827 ,mtl_system_items_vl sitems
1828 ,mtl_parameters mp -- 4402603
1829 WHERE citems.customer_item_id = cxref.customer_item_id
1830 AND cxref.inventory_item_id = sitems.inventory_item_id
1831 AND sitems.inventory_item_id = p_inventory_item_id
1832 AND sitems.organization_id =
1833 OE_Sys_Parameters.VALUE_WNPS('MASTER_ORGANIZATION_ID')
1834 AND citems.customer_item_id = p_ordered_item_id
1835 AND citems.customer_id = p_sold_to_org_id
1836 AND mp.organization_id = sitems.organization_id -- 4402603
1837 AND cxref.master_organization_id = mp.master_organization_id ; -- 4402603
1838
1839 END IF;
1840 --Bug 1678296 chhung modify END
1841 ELSE
1842 IF p_ordered_item_id IS NOT NULL THEN
1843 RETURN FALSE;
1844 ELSIF p_line_category_code ='ORDER' THEN /* SELECT replaced for with the following for 2219230 */
1845 IF l_debug_level > 0 then
1846 oe_debug_pub.add('Validating generic item when category code is ORDER , item_val_org:'||to_char(item_val_org),5);
1847 END IF;
1848 OPEN xref;
1849 FETCH xref INTO l_org_flag;
1850 IF xref%NOTFOUND OR l_org_flag <> 1 THEN
1851 IF l_debug_level > 0 then
1852 oe_debug_pub.add('Invalid Generic Item', 1);
1853 END IF;
1854 CLOSE xref;
1855 RETURN FALSE;
1856 END IF;
1857 CLOSE xref;
1858 ELSIF p_line_category_code = 'RETURN' then /* elsif condition added for bug 3844345 */
1859 IF l_debug_level > 0 then
1860 oe_debug_pub.add('Validating generic item when category code is RETURN , item_val_org:'||to_char(item_val_org),5);
1861 END IF;
1862 OPEN xref_return;
1863 FETCH xref_return INTO l_org_flag;
1864 IF xref_return%NOTFOUND OR l_org_flag <> 1 THEN
1865 IF l_debug_level > 0 then
1866 oe_debug_pub.add('Invalid Generic Item', 1);
1867 END IF;
1868 CLOSE xref_return;
1869 RETURN FALSE;
1870 END IF;
1871 CLOSE xref_return;
1872 END IF;
1873 END IF;
1874 IF l_debug_level > 0 then
1875 oe_debug_pub.add('Exiting Validate_Item_Fields',1);
1876 END IF;
1877 RETURN TRUE;
1878
1879 EXCEPTION
1880 WHEN NO_DATA_FOUND THEN
1881 IF l_debug_level > 0 then
1882 oe_debug_pub.add('Validate_Item_Fields: No data found',1);
1883 IF nvl(p_item_identifier_type, 'INT') = 'INT' THEN
1884 oe_debug_pub.add('Invalid internal item');
1885 ELSIF nvl(p_item_identifier_type, 'INT') = 'CUST' THEN
1886 oe_debug_pub.add('Invalid Customer Item');
1887 ELSE
1888 oe_debug_pub.add('Invalid Generic Item');
1889 END IF;
1890 END IF;
1891 RETURN FALSE;
1892 WHEN OTHERS THEN
1893 IF l_debug_level > 0 then
1894 oe_debug_pub.add('Validate_Item_Fields: When Others',1);
1895 END IF;
1896 RETURN FALSE;
1897 END Validate_Item_Fields;
1898
1899 FUNCTION Validate_Return_Item_Mismatch
1900 ( p_reference_line_id IN NUMBER
1901 , p_inventory_item_id IN NUMBER)
1902 RETURN BOOLEAN
1903 IS
1904 l_ref_inventory_item_id NUMBER;
1905 l_profile VARCHAR2(1);
1906 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1907 BEGIN
1908 IF l_debug_level > 0 then
1909 oe_debug_pub.add('Entering Validate_Return_Item_Mismatch',1);
1910 END IF;
1911
1912 IF (p_reference_line_id IS NULL) THEN
1913 RETURN TRUE;
1914 END IF;
1915
1916 -- Check Profile Option to see if allow item mismatch
1917 l_profile := FND_PROFILE.value('ONT_RETURN_ITEM_MISMATCH_ACTION');
1918
1919 IF (l_profile is NULL OR l_profile = 'A') THEN
1920 RETURN TRUE;
1921 ELSE
1922
1923 SELECT inventory_item_id
1924 INTO l_ref_inventory_item_id
1925 FROM oe_order_lines
1926 WHERE line_id = p_reference_line_id;
1927
1928 IF (l_ref_inventory_item_id = p_inventory_item_id) THEN
1929 RETURN TRUE;
1930 ELSIF (l_profile = 'R') THEN
1931 RETURN FALSE;
1932 ELSE -- warning
1933 FND_MESSAGE.SET_NAME('ONT','OE_RETURN_ITEM_MISMATCH_WARNIN');
1934 OE_MSG_PUB.ADD;
1935 END IF;
1936
1937 END IF;
1938 IF l_debug_level > 0 then
1939 oe_debug_pub.add('Exiting Validate_Return_Item_Mismatch',1);
1940 END IF;
1941 RETURN TRUE;
1942
1943 EXCEPTION
1944 WHEN NO_DATA_FOUND THEN
1945 IF l_debug_level > 0 then
1946 oe_debug_pub.add('Validate_Return_Item_Mismatch: No data found',1);
1947 END IF;
1948 RETURN FALSE;
1949 WHEN OTHERS THEN
1950 IF l_debug_level > 0 then
1951 oe_debug_pub.add('Validate_Return_Item_Mismatch: When Others',1);
1952 END IF;
1953 RETURN FALSE;
1954 END Validate_Return_Item_Mismatch;
1955
1956 FUNCTION Validate_Return_Fulfilled_Line
1957 (p_reference_line_id IN NUMBER
1958 ) RETURN BOOLEAN
1959 IS
1960 l_ref_fulfilled_quantity NUMBER;
1961 l_ref_shippable_flag VARCHAR2(1);
1962 l_ref_shipped_quantity NUMBER;
1963 l_ref_inv_iface_status VARCHAR2(30);
1964 l_profile VARCHAR2(1);
1965 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1966 BEGIN
1967 IF l_debug_level > 0 then
1968 oe_debug_pub.add('Entering Validate return fulfilled line',1);
1969 END IF;
1970
1971 IF (p_reference_line_id IS NULL) THEN
1972 RETURN TRUE;
1973 END IF;
1974
1975 -- Check Profile Option to see if allow item mismatch
1976 l_profile := FND_PROFILE.value('ONT_RETURN_FULFILLED_LINE_ACTION');
1977
1978 IF (l_profile is NULL OR l_profile = 'A') THEN
1979 RETURN TRUE;
1980
1981 /*
1982 ** As per the fix for Bug # 1541972, modified the following ELSE
1983 ** clause to return a success even if Fulfilled Quantity is null
1984 ** and some other conditions are met.
1985 */
1986 ELSE
1987
1988
1989 SELECT nvl(fulfilled_quantity, 0)
1990 , nvl(shippable_flag, 'N')
1991 , invoice_interface_status_code
1992 , nvl(shipped_quantity, 0)
1993 INTO l_ref_fulfilled_quantity
1994 , l_ref_shippable_flag
1995 , l_ref_inv_iface_status
1996 , l_ref_shipped_quantity
1997 FROM oe_order_lines
1998 WHERE line_id = p_reference_line_id;
1999
2000 IF (l_ref_shippable_flag = 'N' AND l_ref_inv_iface_status = 'NOT_ELIGIBLE') THEN
2001 RETURN TRUE;
2002 ELSIF l_ref_inv_iface_status in ('YES', 'RFR-PENDING', 'MANUAL-PENDING') THEN
2003 RETURN TRUE;
2004 ELSIF l_ref_fulfilled_quantity > 0 THEN
2005 RETURN TRUE;
2006 ELSIF l_ref_shipped_quantity > 0 THEN
2007 RETURN TRUE;
2008 ELSIF (l_profile = 'R') THEN
2009 RETURN FALSE;
2010 ELSE -- warning
2011 FND_MESSAGE.SET_NAME('ONT','OE_UNFULFILLED_LINE_WARNING');
2012 OE_MSG_PUB.ADD;
2013 END IF;
2014
2015 END IF;
2016 IF l_debug_level > 0 then
2017 oe_debug_pub.add('Exiting Validate return fulfilled line',1);
2018 END IF;
2019 RETURN TRUE;
2020
2021 EXCEPTION
2022 WHEN NO_DATA_FOUND THEN
2023 IF l_debug_level > 0 then
2024 oe_debug_pub.add('Validate_Return_Fulfilled_Line: No data found',1);
2025 END IF;
2026 RETURN FALSE;
2027 WHEN OTHERS THEN
2028 IF l_debug_level > 0 then
2029 oe_debug_pub.add('Validate_Return_Fulfilled_Line: When Others',1);
2030 END IF;
2031 RETURN FALSE;
2032 END Validate_Return_Fulfilled_Line;
2033
2034 PROCEDURE Validate_Return_Item
2035 (p_inventory_item_id IN NUMBER,
2036 p_ship_from_org_id IN NUMBER,
2037 x_return_status IN OUT NOCOPY VARCHAR2)
2038 IS
2039 l_returnable_flag Varchar2(1);
2040 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2041 BEGIN
2042 IF l_debug_level > 0 then
2043 oe_debug_pub.add('Entering Validate_Return_Item',1);
2044 END IF;
2045 -- bug 4171642
2046 IF ( OE_ORDER_CACHE.g_item_rec.master_org_id <> FND_API.G_MISS_NUM ) AND
2047 (g_master_org_id = OE_ORDER_CACHE.g_item_rec.master_org_id) AND
2048 (OE_ORDER_CACHE.g_item_rec.inventory_item_id = p_inventory_item_id)
2049 THEN
2050 l_returnable_flag := nvl(OE_ORDER_CACHE.g_item_rec.returnable_flag , 'Y');
2051 ELSE
2052 OE_ORDER_CACHE.Load_Item( p_key1 => p_inventory_item_id ,
2053 p_key2 => p_ship_from_org_id );
2054 l_returnable_flag := nvl(OE_ORDER_CACHE.g_item_rec.returnable_flag , 'Y');
2055 END IF ;
2056 /*
2057 SELECT nvl(returnable_flag,'Y')
2058 INTO l_returnable_flag
2059 FROM mtl_system_items_b
2060 WHERE inventory_item_id = p_inventory_item_id
2061 and organization_id = nvl(p_ship_from_org_id,
2062 oe_sys_parameters.value_wnps('MASTER_ORGANIZATION_ID')); */
2063
2064 -- bug 4171642
2065
2066 IF l_returnable_flag = 'Y' THEN
2067 x_return_status := FND_API.G_RET_STS_SUCCESS;
2068 ELSE
2069 fnd_message.set_name('ONT', 'OE_ITEM_NOT_RETURNABLE');
2070 OE_MSG_PUB.add;
2071 x_return_status := FND_API.G_RET_STS_ERROR;
2072 END IF;
2073
2074 EXCEPTION
2075 WHEN NO_DATA_FOUND THEN
2076 IF l_debug_level > 0 then
2077 oe_debug_pub.add('Validate_Return_Item: No data found',1);
2078 END IF;
2079 x_return_status := FND_API.G_RET_STS_ERROR;
2080 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ITEM_WHSE');
2081 OE_MSG_PUB.add;
2082 WHEN OTHERS THEN
2083 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2084 IF l_debug_level > 0 then
2085 oe_debug_pub.add('Validate_Return_Item: When Others',1);
2086 END IF;
2087 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2088 END Validate_Return_Item;
2089
2090 --bug 5898152
2091 FUNCTION Validate_Return_Reference_Tax
2092 (p_reference_line_id IN NUMBER,
2093 p_tax_code IN VARCHAR2)
2094 RETURN BOOLEAN
2095 IS
2096
2097 l_tax_code Varchar2(50);
2098 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2099 BEGIN
2100 if l_debug_level > 0 then
2101 oe_debug_pub.add('Enter Validate_Return_Reference_tax',1);
2102 oe_debug_pub.add('The TAX '||p_tax_code,1);
2103 end if;
2104
2105 SELECT tax_code
2106 INTO l_tax_code
2107 FROM oe_order_lines
2108 WHERE line_id = p_reference_line_id
2109 and line_category_code = 'ORDER';
2110
2111 IF NOT OE_GLOBALS.EQUAL(l_tax_code,p_tax_code) THEN
2112 fnd_message.set_name('ONT','OE_RETURN_ATTR_CANNOT_CHANGE');
2113 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Tax Code');
2114 OE_MSG_PUB.Add;
2115 RETURN FALSE;
2116 END IF;
2117
2118 if l_debug_level > 0 then
2119 oe_debug_pub.add('Exit Validate_Return_Reference_tax',1);
2120 end if;
2121 RETURN TRUE;
2122
2123 EXCEPTION
2124 WHEN NO_DATA_FOUND THEN
2125 if l_debug_level > 0 then
2126 oe_debug_pub.add('Validate_Return_Reference: No data found',1);
2127 end if;
2128 fnd_message.set_name('ONT', 'OE_RETURN_INVALID_SO_LINE');
2129 OE_MSG_PUB.Add;
2130 RETURN FALSE;
2131 WHEN OTHERS THEN
2132 if l_debug_level > 0 then
2133 oe_debug_pub.add('Validate_Return_Reference: When Others',1);
2134 end if;
2135 fnd_message.set_name('ONT', 'OE_RETURN_INVALID_SO_LINE');
2136 OE_MSG_PUB.Add;
2137 RETURN FALSE;
2138 END Validate_Return_Reference_Tax;
2139
2140 FUNCTION Validate_Return_Reference
2141 (p_reference_line_id IN NUMBER,
2142 p_uom_code IN VARCHAR2)
2143 RETURN BOOLEAN
2144 IS
2145 l_booked_flag Varchar2(1);
2146 l_uom_code Varchar2(3);
2147 l_source_document_type_id NUMBER;
2148 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2149 BEGIN
2150 IF l_debug_level > 0 then
2151 oe_debug_pub.add('Enter Validate_Return_Reference',1);
2152 oe_debug_pub.add('The UOM '||p_uom_code,1);
2153 END IF;
2154
2155 SELECT nvl(booked_flag,'N'),
2156 nvl(ORDER_QUANTITY_UOM,' '),
2157 source_document_type_id
2158 INTO l_booked_flag,
2159 l_uom_code,
2160 l_source_document_type_id
2161 FROM oe_order_lines
2162 WHERE line_id = p_reference_line_id
2163 and line_category_code = 'ORDER';
2164
2165 IF l_source_document_type_id = 10 THEN
2166 fnd_message.set_name('ONT','OE_NO_RMA_FOR_INTERNAL_ORDER');
2167 OE_MSG_PUB.Add;
2168 RETURN FALSE;
2169 END IF;
2170
2171 IF NOT OE_GLOBALS.EQUAL(l_uom_code,p_uom_code) THEN
2172 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2173 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Unit Of Measure');
2174 OE_MSG_PUB.Add;
2175 RETURN FALSE;
2176 END IF;
2177
2178 IF l_booked_flag = 'Y' THEN
2179 RETURN TRUE;
2180 ELSE
2181 fnd_message.set_name('ONT', 'OE_RETURN_UNBOOKED_ORDER');
2182 OE_MSG_PUB.Add;
2183 END IF;
2184 IF l_debug_level > 0 then
2185 oe_debug_pub.add('Exit Validate_Return_Reference',1);
2186 END IF;
2187 RETURN FALSE;
2188
2189 EXCEPTION
2190 WHEN NO_DATA_FOUND THEN
2191 IF l_debug_level > 0 then
2192 oe_debug_pub.add('Validate_Return_Reference: No data found',1);
2193 END IF;
2194 fnd_message.set_name('ONT', 'OE_RETURN_INVALID_SO_LINE');
2195 OE_MSG_PUB.Add;
2196 RETURN FALSE;
2197 WHEN OTHERS THEN
2198 IF l_debug_level > 0 then
2199 oe_debug_pub.add('Validate_Return_Reference: When Others',1);
2200 END IF;
2201 fnd_message.set_name('ONT', 'OE_RETURN_INVALID_SO_LINE');
2202 OE_MSG_PUB.Add;
2203 RETURN FALSE;
2204 END Validate_Return_Reference;
2205
2206 /*
2207 ** Fix Bug # 2791253:
2208 ** New Procedure to Validate existence of Return for sales order
2209 ** lines that are being cancelled.
2210 */
2211 FUNCTION Validate_Return_Existence
2212 (p_line_id IN NUMBER,
2213 p_ord_qty IN NUMBER)
2214 RETURN BOOLEAN
2215 IS
2216 l_ord_qty number;
2217 --
2218 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2219 --
2220 BEGIN
2221 IF l_debug_level > 0 THEN
2222 oe_debug_pub.add('Enter Validate_Return_Existence',1);
2223 END IF;
2224
2225 SELECT NVL(SUM(ordered_quantity),0)
2226 INTO l_ord_qty
2227 FROM oe_order_lines
2228 WHERE line_category_code= 'RETURN'
2229 and reference_line_id = p_line_id;
2230
2231 IF l_debug_level > 0 THEN
2232 oe_debug_pub.add('Quantity Referenced on RMAs: '||l_ord_qty);
2233 END IF;
2234
2235 IF l_ord_qty > 0 THEN
2236 IF p_ord_qty <= 0 THEN
2237 fnd_message.set_name('ONT','OE_LINE_HAS_RMA_CANNOT_CANCEL');
2238 OE_MSG_PUB.Add;
2239 RETURN FALSE;
2240 ELSE
2241 IF p_ord_qty < l_ord_qty THEN
2242 fnd_message.set_name('ONT','OE_LINE_HAS_RMA_HIGHER_QTY');
2243 OE_MSG_PUB.Add;
2244 RETURN FALSE;
2245 END IF;
2246 END IF;
2247 END IF;
2248
2249 IF l_debug_level > 0 THEN
2250 oe_debug_pub.add('Exit Validate_Return_Existence',1);
2251 END IF;
2252
2253 RETURN TRUE;
2254
2255 EXCEPTION
2256 WHEN OTHERS THEN
2257 IF l_debug_level > 0 THEN
2258 oe_debug_pub.add('Validate_Return_Existence: When Others',1);
2259 END IF;
2260
2261 RETURN FALSE;
2262 END Validate_Return_Existence;
2263
2264
2265 FUNCTION Validate_Ship_to_Org
2266 ( p_ship_to_org_id IN NUMBER
2267 , p_sold_to_org_id IN NUMBER)
2268 RETURN BOOLEAN
2269 IS
2270 l_dummy VARCHAR2(10);
2271 lcustomer_relations varchar2(1);
2272 --added for bug 3739650
2273 l_site_use_code VARCHAR2(30);
2274 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2275 BEGIN
2276 IF l_debug_level > 0 then
2277 oe_debug_pub.add('Entering Validate_ship_to_org',1);
2278 oe_debug_pub.add('ship_to_org_id :'||to_char(p_ship_to_org_id),2);
2279 END IF;
2280
2281 lcustomer_relations := OE_Sys_Parameters.VALUE('CUSTOMER_RELATIONSHIPS_FLAG');
2282
2283 IF nvl(lcustomer_relations,'N') = 'N' THEN
2284
2285 Select 'VALID'
2286 Into l_dummy
2287 From oe_ship_to_orgs_v
2288 Where customer_id = p_sold_to_org_id
2289 AND site_use_id = p_ship_to_org_id
2290 AND status = 'A'
2291 AND address_status ='A'; --bug 2752321
2292 IF l_debug_level > 0 then
2293 oe_debug_pub.add('Exiting Validate_ship_to_org',1);
2294 END IF;
2295 RETURN TRUE;
2296 ELSIF lcustomer_relations = 'Y' THEN
2297 IF l_debug_level > 0 then
2298 oe_debug_pub.add ('Cr: Yes Line Ship',2);
2299 END IF;
2300
2301 --variable added for bug 3739650
2302 l_site_use_code := 'SHIP_TO' ;
2303 SELECT /* MOAC_SQL_CHANGE */ 'VALID'
2304 Into l_dummy
2305 FROM HZ_CUST_SITE_USES_ALL SITE,
2306 HZ_CUST_ACCT_SITES ACCT_SITE
2307 WHERE SITE.SITE_USE_ID = p_ship_to_org_id
2308 AND SITE.SITE_USE_CODE = l_site_use_code
2309 AND SITE.CUST_ACCT_SITE_ID = ACCT_SITE.CUST_ACCT_SITE_ID
2310 AND SITE.STATUS = 'A'
2311 AND ACCT_SITE.STATUS ='A' AND --bug 2752321
2312 ACCT_SITE.CUST_ACCOUNT_ID in (
2313 SELECT p_sold_to_org_id FROM DUAL
2314 UNION
2315 SELECT CUST_ACCOUNT_ID FROM
2316 HZ_CUST_ACCT_RELATE_ALL h WHERE
2317 RELATED_CUST_ACCOUNT_ID = p_sold_to_org_id
2318 and h.org_id=acct_site.org_id
2319 and ship_to_flag = 'Y' and status = 'A')
2320 --bug 4205113
2321 AND EXISTS(SELECT 1 FROM HZ_CUST_ACCOUNTS WHERE CUST_ACCOUNT_ID = ACCT_SITE.CUST_ACCOUNT_ID AND STATUS='A')
2322 AND ROWNUM = 1;
2323 RETURN TRUE;
2324 ELSIF lcustomer_relations = 'A' THEN
2325 SELECT 'VALID'
2326 INTO l_dummy
2327 FROM OE_SHIP_TO_ORGS_V SHP
2328 WHERE SHP.ORGANIZATION_ID =p_ship_to_org_id
2329 AND SHP.STATUS = 'A'
2330 AND SHP.ADDRESS_STATUS ='A' --bug 2752321
2331 AND SYSDATE BETWEEN NVL(SHP.START_DATE_ACTIVE, SYSDATE)
2332 AND NVL(SHP.END_DATE_ACTIVE, SYSDATE);
2333
2334 RETURN TRUE;
2335
2336
2337 END IF;
2338 RETURN TRUE;
2339
2340
2341 EXCEPTION
2342
2343 WHEN OTHERS THEN
2344 RETURN FALSE;
2345
2346 END Validate_Ship_To_Org;
2347
2348 FUNCTION Validate_Deliver_To_Org
2349 ( p_deliver_to_org_id IN NUMBER
2350 , p_sold_to_org_id IN NUMBER)
2351 RETURN BOOLEAN
2352 IS
2353 l_dummy VARCHAR2(10);
2354 lcustomer_relations varchar2(1);
2355 --added for bug 3739650
2356 l_site_use_code VARCHAR2(30);
2357 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2358 BEGIN
2359 IF l_debug_level > 0 then
2360 oe_debug_pub.add('Entering OE_VALIDATE_LINE.Validate_Deliver_To_Org',1);
2361 oe_debug_pub.add('deliver_to_org_id :'||to_char(p_deliver_to_org_id),2);
2362 END IF;
2363
2364 lcustomer_relations := OE_Sys_Parameters.VALUE('CUSTOMER_RELATIONSHIPS_FLAG');
2365
2366 IF nvl(lcustomer_relations,'N') = 'N' THEN
2367 SELECT 'VALID'
2368 INTO l_dummy
2369 FROM oe_deliver_to_orgs_v
2370 WHERE customer_id = p_sold_to_org_id
2371 AND site_use_id = p_deliver_to_org_id
2372 AND status = 'A'
2373 AND address_status ='A';--bug 2752321
2374 IF l_debug_level > 0 then
2375 oe_debug_pub.add('Exiting OE_VALIDATE_LINE.Validate_Deliver_To_Org',1);
2376 END IF;
2377 RETURN TRUE;
2378
2379 ELSIF lcustomer_relations = 'Y' THEN
2380 IF l_debug_level > 0 then
2381 oe_debug_pub.add('Cr: Yes Line Deliver',2);
2382 END IF;
2383 --variable added for bug 3739650
2384 l_site_use_code := 'DELIVER_TO' ;
2385 SELECT /* MOAC_SQL_CHANGE */ 'VALID'
2386 Into l_dummy
2387 FROM HZ_CUST_SITE_USES_ALL SITE,
2388 HZ_CUST_ACCT_SITES ACCT_SITE
2389 WHERE SITE.SITE_USE_ID = p_deliver_to_org_id
2390 AND SITE.SITE_USE_CODE = l_site_use_code
2391 AND SITE.CUST_ACCT_SITE_ID = ACCT_SITE.CUST_ACCT_SITE_ID
2392 AND SITE.STATUS = 'A'
2393 AND ACCT_SITE.STATUS ='A' AND --bug 2752321
2394 ACCT_SITE.CUST_ACCOUNT_ID in (
2395 SELECT p_sold_to_org_id FROM DUAL
2396 UNION
2397 SELECT CUST_ACCOUNT_ID FROM
2398 HZ_CUST_ACCT_RELATE_ALL h WHERE
2399 RELATED_CUST_ACCOUNT_ID = p_sold_to_org_id
2400 and h.org_id=acct_site.org_id
2401 and ship_to_flag = 'Y' and status='A')
2402 -- bug 4205113
2403 AND EXISTS(SELECT 1 FROM HZ_CUST_ACCOUNTS WHERE CUST_ACCOUNT_ID = ACCT_SITE.CUST_ACCOUNT_ID AND STATUS='A')
2404 AND ROWNUM = 1;
2405 IF l_debug_level > 0 then
2406 oe_debug_pub.add('Exiting OE_VALIDATE_LINE.Validate_Deliver_To_Org',1);
2407 END IF;
2408 RETURN TRUE;
2409
2410 ELSIF lcustomer_relations = 'A' THEN
2411
2412 SELECT 'VALID'
2413 INTO l_dummy
2414 FROM OE_DELIVER_TO_ORGS_V DEL
2415 WHERE DEL.ORGANIZATION_ID =p_deliver_to_org_id
2416 AND DEL.STATUS = 'A'
2417 AND DEL.ADDRESS_STATUS ='A' --bug 2752321
2418 AND SYSDATE BETWEEN NVL(DEL.START_DATE_ACTIVE, SYSDATE)
2419 AND NVL(DEL.END_DATE_ACTIVE, SYSDATE);
2420 IF l_debug_level > 0 then
2421 oe_debug_pub.add('Exiting OE_VALIDATE_LINE.Validate_Deliver_To_Org',1);
2422 END IF;
2423 RETURN TRUE;
2424
2425
2426 END IF;
2427 IF l_debug_level > 0 then
2428 oe_debug_pub.add('Exiting OE_VALIDATE_LINE.Validate_Deliver_To_Org',1);
2429 END IF;
2430 RETURN TRUE;
2431
2432 EXCEPTION
2433
2434 WHEN OTHERS THEN
2435 RETURN FALSE;
2436
2437 END Validate_Deliver_To_Org;
2438
2439
2440 ---------------------------------------------------
2441 -- Procedure Name: Validate_Commitment
2442 -- Abstract: to validate a commitment number on an order line for the
2443 -- given sold_to_org_id, and against OTA course end date.
2444 ---------------------------------------------------
2445
2446 PROCEDURE Validate_Commitment
2447 ( p_line_rec IN OE_Order_PUB.Line_Rec_Type
2448 , p_hdr_currency_code IN VARCHAR2
2449 , p_ota_line IN BOOLEAN := FALSE
2450 , x_return_status OUT NOCOPY VARCHAR2
2451 ) IS
2452
2453 l_event_end_date DATE := NULL;
2454 l_comm_end_date DATE := NULL;
2455 l_commitment_number VARCHAR2(20);
2456 l_inventory_item_id NUMBER;
2457 l_agreement_id NUMBER;
2458
2459 l_commitment_bal NUMBER;
2460 l_class VARCHAR2(30);
2461 l_oe_source_code VARCHAR2(30);
2462 l_oe_installed_flag VARCHAR2(30);
2463
2464 l_exists VARCHAR2(1) := 'N';
2465 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2466
2467 BEGIN
2468
2469 x_return_status := FND_API.G_RET_STS_SUCCESS;
2470
2471 if l_debug_level > 0 then
2472 OE_DEBUG_PUB.Add('Entering OE_VALIDATE_LINE.Validate_Commitment',1);
2473 OE_DEBUG_PUB.Add('Commitment ID: '||p_line_rec.commitment_id||' Sold To Cust: '||p_line_rec.sold_to_org_id||
2474 ' Invoice To Cust: '||p_line_rec.invoice_to_customer_id||' Curr Code: '||p_hdr_currency_code);
2475 end if;
2476
2477 -- commented out the following SQL to replace it with new SQL.
2478 /***
2479 select ratrx.end_date_commitment, ratrx.trx_number
2480 into l_comm_end_date, l_commitment_number
2481 from ra_customer_trx ratrx
2482 where ratrx.customer_trx_id = p_line_rec.commitment_id
2483 and exists
2484 ( Select 1
2485 From ra_cust_trx_types ractt
2486 Where ractt.type in ('DEP','GUAR')
2487 and ratrx.cust_trx_type_id = ractt.cust_trx_type_id
2488 and ractt.org_id = p_line_rec.org_id)
2489 and ratrx.bill_to_customer_id
2490 in (select to_number(p_line_rec.sold_to_org_id )
2491 from sys.dual
2492 union
2493 select cust_account_id customer_id
2494 from hz_cust_acct_relate
2495 where related_cust_account_id = p_line_rec.sold_to_org_id
2496 and status = 'A')
2497
2498 and ratrx.invoice_currency_code = p_hdr_currency_code
2499 and trunc(sysdate) between trunc(nvl( ratrx.start_date_commitment, sysdate))
2500 and trunc(nvl( ratrx.end_date_commitment, sysdate ))
2501 and ratrx.complete_flag = 'Y' ;
2502 ***/
2503
2504 /*
2505 ** Fix Bug # 3015881 Start
2506 ** Commitment Needs to be validated against Line Level Sold To or Invoice To
2507 */
2508 begin
2509 select /* MOAC_SQL_CHANGE */ 'Y'
2510 into l_exists
2511 from ra_customer_trx ratrx
2512 where ratrx.bill_to_customer_id in
2513 (select p_line_rec.sold_to_org_id
2514 from sys.dual
2515 union
2516 select cust_account_id customer_id
2517 from hz_cust_acct_relate_all h
2518 where related_cust_account_id = p_line_rec.sold_to_org_id
2519 and status = 'A'
2520 and bill_to_flag = 'Y'
2521 and h.org_id =ratrx.org_id
2522 union
2523 select cas.cust_account_id customer_id
2524 from hz_cust_site_uses_all su,
2525 hz_cust_acct_sites_all cas
2526 where cas.cust_acct_site_id = su.cust_acct_site_id
2527 and su.site_use_id = p_line_rec.invoice_to_org_id
2528 and cas.org_id=ratrx.org_id
2529 union
2530 select c.cust_account_id customer_id
2531 from hz_cust_acct_relate_all c,
2532 hz_cust_site_uses_all su,
2533 hz_cust_acct_sites_all cas
2534 where cas.cust_acct_site_id = su.cust_acct_site_id
2535 and su.site_use_id = p_line_rec.invoice_to_org_id
2536 and c.related_cust_account_id = cas.cust_account_id
2537 and c.status = 'A'
2538 and c.org_id =ratrx.org_id
2539 and cas.org_id=ratrx.org_id
2540 and c.bill_to_flag = 'Y')
2541 and ratrx.customer_trx_id = p_line_rec.commitment_id;
2542
2543 EXCEPTION WHEN NO_DATA_FOUND THEN
2544 null;
2545 end;
2546
2547 if l_exists = 'N' then
2548 if l_debug_level > 0 then
2549 oe_debug_pub.add('Error: Commitment NOT related to Sold To/Invoice To at the line level');
2550 end if;
2551
2552 x_return_status := FND_API.G_RET_STS_ERROR;
2553 FND_MESSAGE.SET_NAME('ONT','ONT_COM_CUSTOMER_MISMATCH');
2554 FND_MESSAGE.SET_TOKEN('CUSTOMER','');
2555 OE_MSG_PUB.ADD;
2556 end if;
2557
2558 /* Fix Bug # 3015881 End */
2559
2560 -- fix bug 1618229
2561 select /* MOAC_SQL_CHANGE */ ratrx.end_date_commitment, ratrx.trx_number,
2562 ratrx.agreement_id, ratrl.inventory_item_id
2563 INTO l_comm_end_date, l_commitment_number,
2564 l_agreement_id, l_inventory_item_id
2565 from ra_customer_trx_all ratrx,
2566 ra_cust_trx_types_all ractt,
2567 ra_customer_trx_lines ratrl
2568 where ractt.type in ('DEP','GUAR')
2569 AND ratrx.cust_trx_type_id = ractt.cust_trx_type_id
2570 AND ractt.org_id = p_line_rec.org_id
2571 AND ratrl.org_id =ratrx.org_id
2572 AND ratrl.customer_trx_id = ratrx.customer_trx_id
2573 and ratrx.invoice_currency_code = p_hdr_currency_code
2574 and trunc(sysdate) between trunc(nvl( ratrx.start_date_commitment, sysdate))
2575 and trunc(nvl( ratrx.end_date_commitment, sysdate ))
2576 and ratrx.complete_flag = 'Y'
2577 AND ratrx.customer_trx_id = p_line_rec.commitment_id;
2578
2579
2580 IF NOT OE_GLOBALS.EQUAL(nvl(l_agreement_id, p_line_rec.agreement_id), p_line_rec.agreement_id)
2581 AND p_line_rec.agreement_id IS NOT NULL THEN
2582 x_return_status := FND_API.G_RET_STS_ERROR;
2583 fnd_message.set_name('ONT','ONT_COM_AGREEMENT_MISMATCH');
2584 FND_MESSAGE.SET_TOKEN('AGREEMENT',OE_Id_To_Value.Agreement(p_line_rec.agreement_id));
2585 OE_MSG_PUB.Add;
2586 END IF;
2587
2588 IF NOT OE_GLOBALS.EQUAL(nvl(l_inventory_item_id, p_line_rec.inventory_item_id), p_line_rec.inventory_item_id) THEN
2589 x_return_status := FND_API.G_RET_STS_ERROR;
2590 fnd_message.set_name('ONT','ONT_COM_ITEM_MISMATCH');
2591 FND_MESSAGE.SET_TOKEN('ITEM', OE_Id_To_Value.Inventory_Item(p_line_rec.inventory_item_id));
2592 OE_MSG_PUB.Add;
2593 END IF;
2594 IF l_debug_level > 0 then
2595 oe_debug_pub.add('OEXLLINB: commitment end date is: '||l_comm_end_date, 3);
2596 END IF;
2597
2598 -- validating commitment against event end date for OTA line.
2599 IF p_ota_line THEN
2600
2601 l_event_end_date := OE_OTA_UTIL.Get_OTA_Event_End_Date(
2602 p_line_id => p_line_rec.line_id,
2603 p_UOM => p_line_rec.order_quantity_uom);
2604 IF l_debug_level > 0 then
2605 oe_debug_pub.add('Ota line- l_event_end_date: '||l_event_end_date||' l_comm_end_date: '||l_comm_end_date);
2606 END IF;
2607
2608 IF l_event_end_date is NOT NULL AND
2609 l_comm_end_date is NOT NULL THEN
2610 IF trunc(l_comm_end_date)< trunc(l_event_end_date)
2611 THEN
2612 x_return_status := FND_API.G_RET_STS_ERROR;
2613 fnd_message.set_name('ONT','ONT_COM_END_DATE');
2614 FND_MESSAGE.SET_TOKEN('COMMITMENT',l_commitment_number);
2615 OE_MSG_PUB.Add;
2616 END IF;
2617 END IF;
2618 END IF;
2619
2620 /* Start: Fix Bug # 2507479 - Validate Commitment Balance */
2621
2622 IF p_line_rec.commitment_id IS NOT NULL AND
2623 p_line_rec.commitment_id <> FND_API.G_MISS_NUM THEN
2624
2625 l_class := NULL;
2626 l_oe_source_code := FND_PROFILE.VALUE('ONT_SOURCE_CODE');
2627 l_oe_installed_flag := 'I';
2628 IF l_debug_level > 0 then
2629 OE_DEBUG_PUB.Add('Before calling ARP_BAL_UTIL.GET_COMMITMENT_BALANCE');
2630 END IF;
2631
2632 l_commitment_bal := ARP_BAL_UTIL.GET_COMMITMENT_BALANCE(
2633 p_line_rec.commitment_id
2634 , l_class
2635 , l_oe_source_code
2636 , l_oe_installed_flag );
2637 IF l_debug_level > 0 then
2638 OE_DEBUG_PUB.Add('After calling ARP_BAL_UTIL.GET_COMMITMENT_BALANCE');
2639 OE_DEBUG_PUB.Add('Commitment Balance is '||l_commitment_bal);
2640 END IF;
2641
2642 IF l_commitment_bal <= 0 THEN
2643 x_return_status := FND_API.G_RET_STS_ERROR;
2644 FND_MESSAGE.SET_NAME('ONT','OE_COM_ZERO_BALANCE');
2645 FND_MESSAGE.SET_TOKEN('COMMITMENT',l_commitment_number);
2646 OE_MSG_PUB.Add;
2647 END IF;
2648
2649 END IF;
2650
2651 /* End: Fix Bug # 2507479 */
2652 IF l_debug_level > 0 then
2653 OE_DEBUG_PUB.Add('Exiting OE_VALIDATE_LINE.Validate_Commitment',1);
2654 END IF;
2655 EXCEPTION
2656 WHEN NO_DATA_FOUND THEN
2657
2658 x_return_status := FND_API.G_RET_STS_ERROR;
2659 IF l_debug_level > 0 then
2660 OE_DEBUG_PUB.Add('Validate_Commitment: When no data found');
2661 END IF;
2662 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
2663 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Commitment Number');
2664 OE_MSG_PUB.Add;
2665
2666 WHEN OTHERS THEN
2667
2668 x_return_status := FND_API.G_RET_STS_ERROR;
2669 IF l_debug_level > 0 then
2670 OE_DEBUG_PUB.Add('Validate_Commitment: When others');
2671 END IF;
2672 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2673 THEN
2674 FND_MSG_PUB.Add_Exc_Msg
2675 ( G_PKG_NAME
2676 , 'Validate_Commitment'
2677 );
2678 END IF;
2679
2680 END Validate_Commitment;
2681
2682
2683 /*-------------------------------------------------------------
2684 PROCEDURE Validate_Source_Type
2685
2686 We use this procedure to add validations related to source_type
2687 = EXTERNAL.
2688 --------------------------------------------------------------*/
2689 PROCEDURE Validate_Source_Type
2690 ( p_line_rec IN OE_Order_PUB.Line_Rec_Type
2691 ,p_old_line_rec IN OE_Order_PUB.Line_Rec_Type
2692 ,x_return_status OUT NOCOPY VARCHAR2)
2693
2694 IS
2695 l_purchasing_enabled_flag VARCHAR2(1) := 'Y';
2696 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2697 BEGIN
2698 IF l_debug_level > 0 then
2699 OE_DEBUG_PUB.Add('Entering Validate_source_type', 3);
2700 END IF;
2701
2702 IF (NOT OE_GLOBALS.Equal(p_line_rec.source_type_code,
2703 p_old_line_rec.source_type_code) OR
2704 NOT OE_GLOBALS.Equal(p_line_rec.ship_from_org_id,
2705 p_old_line_rec.ship_from_org_id)) AND
2706 OE_GLOBALS.Equal(p_line_rec.source_type_code,
2707 OE_GLOBALS.G_SOURCE_EXTERNAL) THEN
2708
2709 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110508'
2710 THEN
2711 IF p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_SERVICE OR
2712 p_line_rec.ship_model_complete_flag = 'Y'
2713 THEN
2714 IF l_debug_level > 0 then
2715 oe_debug_pub.add('service / part of smc model', 4);
2716 END IF;
2717 FND_MESSAGE.SET_NAME('ONT', 'OE_DS_NOT_VALID_ITEM');
2718 FND_MESSAGE.SET_TOKEN('ITEM', nvl(p_line_rec.ordered_item,p_line_rec.inventory_item_id));
2719 OE_MSG_PUB.Add;
2720 x_return_status := FND_API.G_RET_STS_ERROR;
2721 RETURN;
2722 ELSE
2723 IF l_debug_level > 0 then
2724 oe_debug_pub.add('validate line: pack H new logic DS', 1);
2725 END IF;
2726 END IF;
2727 ELSE
2728 IF (p_line_rec.item_type_code <> OE_GLOBALS.G_ITEM_STANDARD) THEN
2729 IF l_debug_level > 0 then
2730 oe_debug_pub.add('Cannot dropship non-standard item',2);
2731 END IF;
2732 FND_MESSAGE.SET_NAME('ONT', 'OE_DS_NOT_ALLOWED');
2733 OE_MSG_PUB.Add;
2734 x_return_status := FND_API.G_RET_STS_ERROR;
2735 RETURN;
2736 END IF;
2737 END IF;
2738
2739 -- Validate Receiving Organization
2740
2741 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110510'
2742 -- AND INVCONV
2743 -- NOT INV_GMI_RSV_BRANCH.Process_Branch(p_line_rec.ship_from_org_id) INVCONV
2744 THEN
2745
2746 SELECT purchasing_enabled_flag
2747 INTO l_purchasing_enabled_flag
2748 FROM mtl_system_items msi,
2749 org_organization_definitions org
2750 WHERE msi.inventory_item_id = p_line_rec.inventory_item_id
2751 AND org.organization_id= msi.organization_id
2752 AND sysdate <= nvl( org.disable_date, sysdate)
2753 AND org.organization_id = nvl(p_line_rec.ship_from_org_id,
2754 OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID'));
2755 IF l_debug_level > 0 then
2756 OE_DEBUG_PUB.Add('Pack-J Across SOB',2);
2757 END IF;
2758 ELSE
2759 SELECT purchasing_enabled_flag
2760 INTO l_purchasing_enabled_flag
2761 FROM mtl_system_items msi,
2762 org_organization_definitions org
2763 WHERE msi.inventory_item_id = p_line_rec.inventory_item_id
2764 AND org.organization_id= msi.organization_id
2765 AND sysdate <= nvl( org.disable_date, sysdate)
2766 AND org.organization_id = nvl(p_line_rec.ship_from_org_id,
2767 OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID'))
2768 AND org.set_of_books_id= ( SELECT fsp.set_of_books_id
2769 FROM financials_system_parameters fsp);
2770 IF l_debug_level > 0 then
2771 OE_DEBUG_PUB.Add('Pre Pack-J Logic',2);
2772 END IF;
2773 END IF;
2774
2775 IF l_purchasing_enabled_flag = 'N' THEN
2776 FND_MESSAGE.SET_NAME('ONT', 'OE_DS_NOT_ENABLED');
2777 FND_MESSAGE.SET_TOKEN('ITEM', nvl(p_line_rec.ordered_item,p_line_rec.inventory_item_id));
2778 FND_MESSAGE.SET_TOKEN('ORG', nvl(p_line_rec.ship_from_org_id,
2779 OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID')));
2780 OE_MSG_PUB.Add;
2781 x_return_status := FND_API.G_RET_STS_ERROR;
2782 END IF;
2783
2784 END IF; -- if external
2785
2786 IF p_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
2787 NOT OE_GLOBALS.Equal(p_line_rec.source_type_code,
2788 p_old_line_rec.source_type_code) AND
2789 p_line_rec.ato_line_id <> p_line_rec.line_id AND
2790 OE_Config_Util.CASCADE_CHANGES_FLAG = 'N' AND
2791 OE_CODE_CONTROL.Get_Code_Release_Level >= '110508'
2792 THEN
2793 IF l_debug_level > 0 then
2794 oe_debug_pub.add('item under ato model', 4);
2795 END IF;
2796 FND_MESSAGE.SET_NAME('ONT', 'OE_DS_CHANGE_NOT_ALLOWED');
2797 OE_MSG_PUB.Add;
2798 x_return_status := FND_API.G_RET_STS_ERROR;
2799 END IF;
2800 IF l_debug_level > 0 then
2801 oe_debug_pub.add('leaving validate_source_type', 3);
2802 END IF;
2803
2804 EXCEPTION
2805 WHEN OTHERS THEN
2806 oe_debug_pub.add('error in Validate_Source_Type');
2807 RAISE;
2808 END Validate_Source_Type;
2809
2810
2811 FUNCTION Validate_Set_id
2812 ( p_line_rec IN OE_Order_PUB.Line_Rec_Type
2813 ,p_old_line_rec IN OE_Order_PUB.Line_Rec_Type)
2814 RETURN BOOLEAN
2815 IS
2816 l_arrival_set_id Number;
2817 l_ship_set_id Number;
2818 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2819 BEGIN
2820
2821
2822 IF (p_line_rec.top_model_line_id IS NOT NULL AND
2823 p_line_rec.top_model_line_id <> FND_API.G_MISS_NUM)
2824 AND p_line_rec.top_model_line_id <> p_line_rec.line_id THEN
2825
2826 IF (NOT OE_GLOBALS.Equal(p_line_rec.ship_set_id,
2827 p_old_line_rec.ship_set_id) OR
2828 NOT OE_GLOBALS.Equal(p_line_rec.arrival_set_id,
2829 p_old_line_rec.arrival_set_id)) THEN
2830
2831 BEGIN
2832
2833 Select arrival_set_id,
2834 ship_set_id
2835 Into l_arrival_set_id,
2836 l_ship_set_id
2837 FROM OE_ORDER_LINES_ALL
2838 Where line_id = p_line_rec.top_model_line_id;
2839
2840 EXCEPTION
2841 WHEN OTHERS THEN
2842 l_arrival_set_id := p_line_rec.arrival_set_id;
2843 l_ship_set_id := p_line_rec.ship_set_id;
2844 END;
2845
2846 IF l_debug_level > 0 then
2847 oe_debug_pub.add('ship_set_id : '|| p_line_rec.ship_set_id,2);
2848 oe_debug_pub.add('old ship_set_id : '|| p_old_line_rec.ship_set_id,2);
2849 oe_debug_pub.add('arrival_set_id : '|| p_line_rec.arrival_set_id,2);
2850 oe_debug_pub.add('old arrival_set_id : '|| p_old_line_rec.arrival_set_id,2);
2851 oe_debug_pub.add('l_arrival_set_id : '|| l_arrival_set_id,2);
2852 oe_debug_pub.add('l_ship_set_id : '|| l_ship_set_id,2);
2853 oe_debug_pub.add('3039131: OESCH_PERFORM_SCHEDULING:' ||
2854 OE_ORDER_SCH_UTIL.OESCH_PERFORM_SCHEDULING,1);
2855 END IF;
2856
2857 /* added the AND condition in the following if to fix the bug 3039131 */
2858
2859 IF (NOT OE_GLOBALS.Equal(p_line_rec.ship_set_id,
2860 l_ship_set_id) OR
2861 NOT OE_GLOBALS.Equal(p_line_rec.arrival_set_id,
2862 l_arrival_set_id)) AND
2863 OE_ORDER_SCH_UTIL.OESCH_PERFORM_SCHEDULING = 'Y' THEN
2864
2865 FND_MESSAGE.SET_NAME('ONT','OE_INVALID_SET_OPR');
2866 FND_MESSAGE.SET_TOKEN('ITEMTYPE', p_line_rec.item_type_code);
2867 OE_MSG_PUB.ADD;
2868 IF l_debug_level > 0 then
2869 oe_debug_pub.add('Set- not allowed for this itemtype');
2870 END IF;
2871 RETURN FALSE;
2872 END IF;
2873 END IF; -- id
2874 IF l_debug_level > 0 then
2875 oe_debug_pub.add('OESCH_PERFORM_SCHEDULING:' ||
2876 OE_ORDER_SCH_UTIL.OESCH_PERFORM_SCHEDULING,1);
2877 END IF;
2878 IF ((p_line_rec.ship_set IS NOT NULL AND
2879 p_line_rec.ship_set <> FND_API.G_MISS_CHAR AND
2880 p_line_rec.ship_set_id is NULL ) OR
2881 (p_line_rec.arrival_set IS NOT NULL AND
2882 p_line_rec.arrival_set <> FND_API.G_MISS_CHAR AND
2883 p_line_rec.arrival_set_id IS NULL)) AND
2884 OE_ORDER_SCH_UTIL.OESCH_PERFORM_SCHEDULING = 'Y' THEN
2885 IF l_debug_level > 0 then
2886 oe_debug_pub.add('ship_set_id : '|| p_line_rec.ship_set_id,2);
2887 oe_debug_pub.add('ship_set : '|| p_line_rec.ship_set,2);
2888 oe_debug_pub.add('arrival_set_id : '|| p_line_rec.arrival_set_id,2);
2889 oe_debug_pub.add('arrival_set : '|| p_line_rec.arrival_set,2);
2890 oe_debug_pub.add('Set name - not allowed for this itemtype');
2891 END IF;
2892 FND_MESSAGE.SET_NAME('ONT','OE_INVALID_SET_OPR');
2893 FND_MESSAGE.SET_TOKEN('ITEMTYPE', p_line_rec.item_type_code);
2894 OE_MSG_PUB.ADD;
2895 RETURN FALSE;
2896 END IF; -- set name
2897 END IF; -- main
2898
2899 RETURN TRUE;
2900 EXCEPTION
2901 WHEN OTHERS THEN
2902 IF l_debug_level > 0 then
2903 oe_debug_pub.add('error in Validate_Set_id');
2904 END IF;
2905 RETURN FALSE;
2906 END Validate_Set_id;
2907
2908 PROCEDURE Validate_User_Item_Description
2909 (p_line_rec IN OE_Order_PUB.Line_Rec_Type
2910 , x_return_status OUT NOCOPY VARCHAR2
2911
2912 )
2913 IS
2914 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2915 BEGIN
2916 IF l_debug_level > 0 then
2917 oe_debug_pub.add('Enter Validate_User_Item_Description',1);
2918 END IF;
2919 x_return_status := FND_API.G_RET_STS_SUCCESS;
2920
2921 IF LENGTHB(p_line_rec.user_item_description) > 240 THEN
2922 fnd_message.set_name('ONT','ONT_USER_ITEM_DESC_TOO_LONG');
2923 OE_MSG_PUB.Add;
2924 IF l_debug_level > 0 then
2925 Oe_debug_pub.add('The length of user_item_description should not exceed 240 characters for drop ship lines.',3);
2926 END IF;
2927 x_return_status := FND_API.G_RET_STS_ERROR;
2928 END IF;
2929 IF l_debug_level > 0 then
2930 oe_debug_pub.add('Exit Validate_User_Item_Description',1);
2931 END IF;
2932
2933 EXCEPTION
2934 WHEN OTHERS THEN
2935
2936 x_return_status := FND_API.G_RET_STS_ERROR;
2937 OE_DEBUG_PUB.Add('Validate_User_Item_Description: When others');
2938 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2939 THEN
2940 FND_MSG_PUB.Add_Exc_Msg
2941 ( G_PKG_NAME
2942 , 'Validate_User_Item_Description'
2943 );
2944 END IF;
2945 END Validate_User_Item_Description;
2946
2947
2948 ----------------------------------------------------------------------------
2949 -- Procedure Validate_Blanket_Values
2950 ----------------------------------------------------------------------------
2951
2952 Procedure Validate_Blanket_Values
2953 ( p_line_rec IN OE_Order_PUB.Line_Rec_Type,
2954 p_old_line_rec IN OE_Order_PUB.Line_Rec_Type,
2955 x_return_status OUT NOCOPY VARCHAR2
2956 )
2957 IS
2958 l_temp VARCHAR2(240);
2959 l_sold_to_org_id NUMBER;
2960 l_on_hold_flag VARCHAR2(1);
2961 l_item_id NUMBER;
2962 l_item_context VARCHAR2(240);
2963 l_item_cross_ref_type VARCHAR2(30);
2964 l_start_date_active DATE;
2965 l_end_date_active DATE;
2966 l_hdr_start_date_active DATE;
2967 l_hdr_end_date_active DATE;
2968 l_enforce_price_list_flag VARCHAR2(1);
2969 l_enforce_ship_to_flag VARCHAR2(1);
2970 l_enforce_invoice_to_flag VARCHAR2(1);
2971 l_enforce_freight_term_flag VARCHAR2(1);
2972 l_enforce_shipping_method_flag VARCHAR2(1);
2973 l_enforce_payment_term_flag VARCHAR2(1);
2974 l_enforce_accounting_rule_flag VARCHAR2(1);
2975 l_enforce_invoicing_rule_flag VARCHAR2(1);
2976 l_price_list_id NUMBER;
2977 L_SHIP_TO_ORG_ID NUMBER;
2978 L_INVOICE_TO_ORG_ID NUMBER;
2979 L_FREIGHT_TERMS_CODE VARCHAR2(30);
2980 L_SHIPPING_METHOD_CODE VARCHAR2(30);
2981 L_PAYMENT_TERM_ID NUMBER;
2982 L_ACCOUNTING_RULE_ID NUMBER;
2983 L_INVOICING_RULE_ID NUMBER;
2984 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2985 l_item_val_org NUMBER;
2986 --FOR BUG 3192386
2987 l_flow_status_code VARCHAR2(30);
2988 -- Bug 3232544
2989 lcustomer_relations varchar2(1) :=
2990 OE_Sys_Parameters.VALUE('CUSTOMER_RELATIONSHIPS_FLAG');
2991 l_exists varchar2(1);
2992 --For Bug 3257240
2993 l_customer_name VARCHAR2(240);
2994 l_customer_number NUMBER;
2995 l_address1 VARCHAR2(240);
2996 l_address2 VARCHAR2(240);
2997 l_address3 VARCHAR2(240);
2998 l_address4 VARCHAR2(240);
2999 l_location VARCHAR2(240);
3000 l_org VARCHAR2(240);
3001 l_city VARCHAR2(240);
3002 l_state VARCHAR2(240);
3003 l_postal_code VARCHAR2(240);
3004 l_country VARCHAR2(240);
3005
3006 l_ordered_item_id NUMBER;
3007 l_ordered_item OE_BLANKET_LINES_ALL.ORDERED_ITEM%TYPE; --Bug 7635963
3008 BEGIN
3009
3010 x_return_status := fnd_api.g_ret_sts_success;
3011
3012 if l_debug_level > 0 then
3013 OE_DEBUG_PUB.Add('Entering OE_VALIDATE_LINE.Validate_Blanket_Values',1);
3014 end if;
3015
3016 IF p_line_rec.blanket_line_number IS NULL OR
3017 p_line_rec.blanket_version_number IS NULL THEN
3018 if l_debug_level > 0 then
3019 oe_debug_pub.add('Blanket Line Number is not supplied: Blanket #:'||
3020 p_line_rec.blanket_number || ', Inventory Item #:'||p_line_rec.inventory_item_id, 2);
3021 end if;
3022 FND_MESSAGE.SET_NAME('ONT', 'OE_BLKT_NO_BLANKET_LINE_NUM');
3023 OE_MSG_PUB.Add;
3024 x_return_status := FND_API.G_RET_STS_ERROR;
3025 END IF;
3026
3027
3028 if oe_code_control.get_code_release_level < '110510' then /* added by Srini FOR Pack J*/
3029 -- Bug 2757773 =>
3030 -- Items that are not standard items and are not top level kit items
3031 -- are not supported for blankets.
3032 IF ((p_line_rec.item_type_code <> 'STANDARD') AND
3033 NOT (p_line_rec.item_type_code = 'KIT' AND p_line_rec.top_model_line_id = p_line_rec.line_id)) THEN
3034
3035 SELECT meaning
3036 INTO l_temp
3037 FROM OE_LOOKUPS
3038 WHERE LOOKUP_TYPE = 'ITEM_TYPE'
3039 AND LOOKUP_CODE = p_line_rec.item_type_code;
3040
3041 if l_debug_level > 0 then
3042 oe_debug_pub.add('Blankets only support standard items', 1);
3043 end if;
3044
3045 FND_MESSAGE.SET_NAME('ONT', 'OE_BLKT_NON_STANDARD_ITEM');
3046 OE_MSG_PUB.Add;
3047 x_return_status := FND_API.G_RET_STS_ERROR;
3048
3049 END IF;
3050 ELSE --for bug 3372805
3051 IF(p_line_rec.item_type_code ='INCLUDED')
3052 THEN
3053 if l_debug_level > 0 then
3054 oe_debug_pub.add('Blankets does not support Included items', 1);
3055 end if;
3056
3057 FND_MESSAGE.SET_NAME('ONT', 'OE_BLKT_INCLUDED_ITEM');
3058 OE_MSG_PUB.Add;
3059 x_return_status := FND_API.G_RET_STS_ERROR;
3060 END IF;
3061
3062 END IF; -- End of Pack -J changes.
3063 -- Blanket AND Agreement cannot co-exist on release line
3064
3065 IF p_line_rec.agreement_id IS NOT NULL THEN
3066 FND_MESSAGE.SET_NAME('ONT', 'OE_BLKT_AGREEMENT_EXISTS');
3067 OE_MSG_PUB.Add;
3068 x_return_status := FND_API.G_RET_STS_ERROR;
3069 END IF;
3070
3071 -- If any of the above checks failed, no need to proceed with
3072 -- further blanket validations
3073 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3074 RETURN;
3075 END IF;
3076
3077
3078 -- Get data we'll need from blanket tables
3079 --Altered the sql for bug 3192386. Blankets in Negotiation or with Draft submitted as 'N' should not be selected
3080 SELECT /* MOAC_SQL_CHANGE */ BL.SOLD_TO_ORG_ID,
3081 BHE.on_hold_flag,
3082 BLE.START_DATE_ACTIVE,
3083 BLE.END_DATE_ACTIVE,
3084 BL.INVENTORY_ITEM_ID,
3085 BL.ORDERED_ITEM_ID, --bug6929192
3086 BL.ORDERED_ITEM, --bug6929192
3087 BL.ITEM_IDENTIFIER_TYPE,
3088 BL.PRICE_LIST_ID,
3089 BL.SHIP_TO_ORG_ID,
3090 BL.INVOICE_TO_ORG_ID,
3091 BL.FREIGHT_TERMS_CODE,
3092 BL.SHIPPING_METHOD_CODE,
3093 BL.PAYMENT_TERM_ID,
3094 BL.ACCOUNTING_RULE_ID,
3095 BL.INVOICING_RULE_ID,
3096 BLE.ENFORCE_PRICE_LIST_FLAG,
3097 BLE.ENFORCE_SHIP_TO_FLAG,
3098 BLE.ENFORCE_INVOICE_TO_FLAG,
3099 BLE.ENFORCE_FREIGHT_TERM_FLAG,
3100 BLE.ENFORCE_SHIPPING_METHOD_FLAG,
3101 BLE.ENFORCE_PAYMENT_TERM_FLAG,
3102 BLE.ENFORCE_ACCOUNTING_RULE_FLAG,
3103 BLE.ENFORCE_INVOICING_RULE_FLAG,
3104 NVL(BH.FLOW_STATUS_CODE,'ACTIVE')
3105 INTO l_sold_to_org_id,
3106 l_on_hold_flag,
3107 l_start_date_active,
3108 l_end_date_active,
3109 l_item_id,
3110 l_ordered_item_id,
3111 l_ordered_item,
3112 l_item_context,
3113 l_price_list_id,
3114 L_SHIP_TO_ORG_ID,
3115 L_INVOICE_TO_ORG_ID,
3116 L_FREIGHT_TERMS_CODE,
3117 L_SHIPPING_METHOD_CODE,
3118 L_PAYMENT_TERM_ID,
3119 L_ACCOUNTING_RULE_ID,
3120 L_INVOICING_RULE_ID,
3121 l_enforce_price_list_flag,
3122 l_enforce_ship_to_flag,
3123 l_enforce_invoice_to_flag,
3124 l_enforce_freight_term_flag,
3125 l_enforce_shipping_method_flag,
3126 l_enforce_payment_term_flag,
3127 l_enforce_accounting_rule_flag,
3128 l_enforce_invoicing_rule_flag,
3129 l_flow_status_code
3130 FROM OE_BLANKET_LINES_ALL BL,OE_BLANKET_HEADERS BH,
3131 OE_BLANKET_HEADERS_EXT BHE,OE_BLANKET_LINES_EXT BLE
3132 WHERE BLE.ORDER_NUMBER = p_line_rec.blanket_number
3133 AND BLE.LINE_NUMBER = p_line_rec.blanket_line_number
3134 AND BHE.ORDER_NUMBER = BLE.ORDER_NUMBER
3135 AND BL.LINE_ID = BLE.LINE_ID
3136 AND BH.ORDER_NUMBER = BHE.ORDER_NUMBER
3137 AND BL.SALES_DOCUMENT_TYPE_CODE = 'B'
3138 AND BH.ORG_ID =BL.ORG_ID
3139 AND NVL(BH.TRANSACTION_PHASE_CODE,'F')='F'
3140 AND NVL(BH.DRAFT_SUBMITTED_FLAG,'Y') = 'Y';
3141
3142 -- Set Item validation org parameter value
3143 l_item_val_org := to_number(OE_Sys_Parameters.VALUE('MASTER_ORGANIZATION_ID'));
3144
3145 -- Blanket/Item Validations
3146
3147 IF p_line_rec.inventory_item_id IS NOT NULL
3148 AND (NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_number
3149 ,p_old_line_rec.blanket_number)
3150 OR NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_line_number
3151 ,p_old_line_rec.blanket_line_number)
3152 OR NOT OE_GLOBALS.EQUAL(p_line_rec.inventory_item_id
3153 ,p_old_line_rec.inventory_item_id)
3154 OR NOT OE_GLOBALS.EQUAL(p_line_rec.ordered_item_id --bug6929192
3155 ,p_old_line_rec.ordered_item_id)
3156 OR NOT OE_GLOBALS.EQUAL(p_line_rec.ordered_item
3157 ,p_old_line_rec.ordered_item)
3158
3159 )
3160 THEN
3161
3162 --for cust and xrefs, validate l_item_id against p_inventory_item_id
3163 --bug6929192
3164 IF l_item_context = 'INT' THEN -- = '1' THEN
3165
3166 IF (l_item_id <> p_line_rec.inventory_item_id) THEN
3167 if l_debug_level > 0 then
3168 oe_debug_pub.add('Release does not match blanket line inventory item', 1);
3169 end if;
3170 FND_MESSAGE.SET_NAME('ONT', 'OE_BLKT_INVALID_ATTRIBUTE');
3171 fnd_message.set_token('ATTRIBUTE', OE_Order_Util.Get_Attribute_Name('INVENTORY_ITEM_ID'));
3172 --for bug 3257240
3173 FND_MESSAGE.SET_TOKEN('BLANKET_VALUE', OE_Id_To_Value.Inventory_Item(l_item_id));
3174 OE_MSG_PUB.Add;
3175 x_return_status := FND_API.G_RET_STS_ERROR;
3176 END IF;
3177 ELSIF l_item_context = 'CUST' THEN
3178
3179 IF (l_ordered_item_id <> p_line_rec.ordered_item_id
3180 OR l_item_id <> p_line_rec.inventory_item_id ) THEN
3181 if l_debug_level > 0 then
3182 oe_debug_pub.add('Release does not match blanket line customer item', 1);
3183 end if;
3184 FND_MESSAGE.SET_NAME('ONT', 'OE_BLKT_INVALID_ATTRIBUTE');
3185 fnd_message.set_token('ATTRIBUTE', OE_Order_Util.Get_Attribute_Name('CUSTOMER_ITEM_ID'));
3186 --for bug 3257240
3187 FND_MESSAGE.SET_TOKEN('BLANKET_VALUE', OE_Id_To_Value.Inventory_Item(l_item_id));
3188 OE_MSG_PUB.Add;
3189 x_return_status := FND_API.G_RET_STS_ERROR;
3190 END IF;
3191
3192 ELSIF l_item_context = 'ALL' THEN
3193 NULL; --Item is valid
3194 ELSIF l_item_context = 'CAT' THEN
3195 oe_debug_pub.add('SHIP FROM ORG ID: '||p_line_rec.ship_from_org_id);
3196 oe_debug_pub.add('INV ORG: '||l_item_val_org);
3197 oe_debug_pub.add('Cat ID: '||l_item_id);
3198
3199 BEGIN
3200 SELECT 'VALID'
3201 INTO l_temp
3202 FROM MTL_ITEM_CATEGORIES
3203 WHERE ORGANIZATION_ID = l_item_val_org -- 5630818
3204 AND INVENTORY_ITEM_ID = p_line_rec.inventory_item_id
3205 AND CATEGORY_ID = l_item_id
3206 -- Bug 2857391 => Item can be assigned to this category
3207 -- in multiple category sets, select only 1 row to avoid
3208 -- multiple rows error.
3209 AND ROWNUM = 1;
3210
3211 EXCEPTION
3212 WHEN NO_DATA_FOUND THEN
3213 SELECT DESCRIPTION
3214 INTO l_temp
3215 FROM MTL_CATEGORIES_VL
3216 WHERE CATEGORY_ID = l_item_id;
3217 if l_debug_level > 0 then
3218 oe_debug_pub.add('Release does not match blanket line item category', 1);
3219 end if;
3220 FND_MESSAGE.SET_NAME('ONT', 'OE_BLKT_INVALID_ATTRIBUTE');
3221 fnd_message.set_token('ATTRIBUTE', OE_Order_Util.Get_Attribute_Name('INVENTORY_ITEM_ID'));
3222 --for bug 3257240
3223 FND_MESSAGE.SET_TOKEN('BLANKET_VALUE', OE_Id_To_Value.Inventory_Item(l_item_id));
3224 OE_MSG_PUB.Add;
3225 x_return_status := FND_API.G_RET_STS_ERROR;
3226 END;
3227
3228 ELSE
3229 IF (l_ordered_item <> p_line_rec.ordered_item
3230 OR l_item_id <> p_line_rec.inventory_item_id ) THEN
3231
3232 if l_debug_level > 0 then
3233 oe_debug_pub.add('Release does not match blanket line xref item item', 1);
3234 end if;
3235 FND_MESSAGE.SET_NAME('ONT', 'OE_BLKT_INVALID_ATTRIBUTE');
3236 fnd_message.set_token('ATTRIBUTE', OE_Order_Util.Get_Attribute_Name('ORDERED_ITEM'));
3237 --for bug 3257240
3238 FND_MESSAGE.SET_TOKEN('BLANKET_VALUE', OE_Id_To_Value.Inventory_Item(l_item_id));
3239 OE_MSG_PUB.Add;
3240 x_return_status := FND_API.G_RET_STS_ERROR;
3241 END IF;
3242 END IF;
3243 END IF;
3244
3245
3246
3247 -- Blanket/Customer Validation
3248
3249 IF (NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_number
3250 ,p_old_line_rec.blanket_number)
3251 OR NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_line_number
3252 ,p_old_line_rec.blanket_line_number)
3253 OR NOT OE_GLOBALS.EQUAL(p_line_rec.sold_to_org_id
3254 ,p_old_line_rec.sold_to_org_id) )
3255 AND l_sold_to_org_id <> p_line_rec.sold_to_org_id
3256 THEN
3257 if l_debug_level > 0 then
3258 oe_debug_pub.add('Customer on release does not match blanket customer', 1);
3259 oe_debug_pub.add('blkt customer :'||l_sold_to_org_id);
3260 oe_debug_pub.add('line customer :'||p_line_rec.sold_to_org_id);
3261 end if;
3262 if lcustomer_relations = 'Y' then
3263 begin
3264 SELECT 'Y'
3265 INTO l_exists
3266 FROM HZ_CUST_ACCT_RELATE
3267 WHERE RELATED_CUST_ACCOUNT_ID = p_line_rec.sold_to_org_id
3268 AND CUST_ACCOUNT_ID = l_sold_to_org_id
3269 AND STATUS = 'A'
3270 AND ROWNUM = 1;
3271 exception
3272 when no_data_found then
3273 FND_MESSAGE.SET_NAME('ONT','OE_BLKT_INVALID_ATTRIBUTE');
3274 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_Util.Get_Attribute_Name
3275 ('SOLD_TO_ORG_ID'));
3276 --for bug 3257240
3277 OE_Id_To_Value.Sold_To_Org
3278 ( p_sold_to_org_id => l_sold_to_org_id
3279 , x_org => l_customer_name
3280 , x_customer_number => l_customer_number
3281 );
3282 FND_MESSAGE.SET_TOKEN('BLANKET_VALUE',l_customer_name);
3283 OE_MSG_PUB.Add;
3284 x_return_status := FND_API.G_RET_STS_ERROR;
3285 end;
3286 else
3287 FND_MESSAGE.SET_NAME('ONT','OE_BLKT_INVALID_ATTRIBUTE');
3288 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_Util.Get_Attribute_Name
3289 ('SOLD_TO_ORG_ID'));
3290 --for bug 3257240
3291 OE_Id_To_Value.Sold_To_Org
3292 ( p_sold_to_org_id => l_sold_to_org_id
3293 , x_org => l_customer_name
3294 , x_customer_number => l_customer_number
3295 );
3296 FND_MESSAGE.SET_TOKEN('BLANKET_VALUE',l_customer_name);
3297 OE_MSG_PUB.Add;
3298 x_return_status := FND_API.G_RET_STS_ERROR;
3299 end if;
3300 END IF;
3301
3302
3303 -- Blanket ON Hold Validation
3304
3305 --only check if not a return
3306 -- Bug 2761943 => on hold check corrected.
3307 IF p_line_rec.line_category_code = 'ORDER' AND ( l_on_hold_flag <> 'N')
3308 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_number
3309 ,p_old_line_rec.blanket_number)
3310 OR NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_line_number
3311 ,p_old_line_rec.blanket_line_number))
3312 THEN
3313 if l_debug_level > 0 then
3314 oe_debug_pub.add('Blanket order is currently on hold', 1);
3315 end if;
3316 FND_MESSAGE.SET_NAME('ONT', 'OE_BLKT_ON_HOLD');
3317 OE_MSG_PUB.Add;
3318 x_return_status := FND_API.G_RET_STS_ERROR;
3319 END IF;
3320
3321 --Active Blanket Validation for release lines.For Bug 3192386
3322 IF p_line_rec.line_category_code = 'ORDER' AND ( l_flow_status_code<>'ACTIVE')
3323 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_number
3324 ,p_old_line_rec.blanket_number)
3325 OR NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_line_number
3326 ,p_old_line_rec.blanket_line_number))
3327 THEN
3328 if l_debug_level > 0 then
3329 oe_debug_pub.add('Blanket is not in Active Status', 1);
3330 end if;
3331 FND_MESSAGE.SET_NAME('ONT', 'OE_BLKT_INVALID_BLANKET');
3332 OE_MSG_PUB.Add;
3333 x_return_status := FND_API.G_RET_STS_ERROR;
3334 END IF;
3335
3336
3337 -- Blanket/Request Date Validation
3338
3339 IF p_line_rec.line_category_code = 'ORDER'
3340 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_number
3341 ,p_old_line_rec.blanket_number)
3342 OR NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_line_number
3343 ,p_old_line_rec.blanket_line_number)
3344 OR NOT OE_GLOBALS.EQUAL(p_line_rec.request_date
3345 ,p_old_line_rec.request_date))
3346 AND NOT trunc(nvl(p_line_rec.request_date,sysdate))
3347 BETWEEN trunc(l_start_date_active)
3348 -- Bug 2895023
3349 -- If end date active is null, substitute current request date
3350 -- so that validation will pass as long as request date is
3351 -- greater than start_date_active.
3352 AND trunc(nvl(l_end_date_active
3353 ,p_line_rec.request_date) )
3354 THEN
3355 if l_debug_level > 0 then
3356 oe_debug_pub.add('Request date is not within active blanket line dates', 1);
3357 end if;
3358 FND_MESSAGE.SET_NAME('ONT', 'OE_BLKT_INVALID_LINE_REQ_DATE');
3359 OE_MSG_PUB.Add;
3360 x_return_status := FND_API.G_RET_STS_ERROR;
3361 END IF;
3362
3363
3364
3365 -- Blankets: Check for fields that should be enforced to be
3366 -- same value as on blanket line.
3367 -- The check fires only if field is not null on both release line
3368 -- and blanket line (if l_value <> p_line_rec.value check will return
3369 -- TRUE only if both are not null and the values do not match)
3370
3371 IF l_enforce_price_list_flag = 'Y'
3372 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_number
3373 ,p_old_line_rec.blanket_number)
3374 OR NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_line_number
3375 ,p_old_line_rec.blanket_line_number)
3376 OR NOT OE_GLOBALS.EQUAL(p_line_rec.price_list_id
3377 ,p_old_line_rec.price_list_id) )
3378 THEN
3379 IF l_price_list_id <> p_line_rec.price_list_id THEN
3380 FND_MESSAGE.SET_NAME('ONT','OE_BLKT_INVALID_ATTRIBUTE');
3381 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_Util.Get_Attribute_Name
3382 ('PRICE_LIST_ID'));
3383 --for bug 3257240
3384 FND_MESSAGE.SET_TOKEN('BLANKET_VALUE',OE_Id_To_Value.Price_List(l_price_list_id));
3385 OE_MSG_PUB.ADD;
3386 x_return_status := FND_API.G_RET_STS_ERROR;
3387 END IF;
3388 END IF;
3389
3390 IF l_enforce_ship_to_flag = 'Y'
3391 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_number
3392 ,p_old_line_rec.blanket_number)
3393 OR NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_line_number
3394 ,p_old_line_rec.blanket_line_number)
3395 OR NOT OE_GLOBALS.EQUAL(p_line_rec.ship_to_org_id
3396 ,p_old_line_rec.ship_to_org_id) )
3397 THEN
3398 IF l_ship_to_org_id <> p_line_rec.ship_to_org_id THEN
3399 FND_MESSAGE.SET_NAME('ONT','OE_BLKT_INVALID_ATTRIBUTE');
3400 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_Util.Get_Attribute_Name
3401 ('SHIP_TO_ORG_ID'));
3402 --for bug 3257240
3403 OE_ID_TO_VALUE.ship_to_Org
3404 ( p_ship_to_org_id => p_line_rec.ship_to_org_id
3405 , x_ship_to_address1 => l_address1
3406 , x_ship_to_address2 => l_address2
3407 , x_ship_to_address3 => l_address3
3408 , x_ship_to_address4 => l_address4
3409 , x_ship_to_location => l_location
3410 , x_ship_to_org => l_org
3411 , x_ship_to_city => l_city
3412 , x_ship_to_state => l_state
3413 , x_ship_to_postal_code => l_postal_code
3414 , x_ship_to_country => l_country
3415 );
3416 FND_MESSAGE.SET_TOKEN('BLANKET_VALUE',l_org);
3417 OE_MSG_PUB.ADD;
3418 x_return_status := FND_API.G_RET_STS_ERROR;
3419 END IF;
3420 END IF;
3421
3422 IF l_enforce_invoice_to_flag = 'Y'
3423 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_number
3424 ,p_old_line_rec.blanket_number)
3425 OR NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_line_number
3426 ,p_old_line_rec.blanket_line_number)
3427 OR NOT OE_GLOBALS.EQUAL(p_line_rec.invoice_to_org_id
3428 ,p_old_line_rec.invoice_to_org_id) )
3429 THEN
3430 IF l_invoice_to_org_id <> p_line_rec.invoice_to_org_id THEN
3431 FND_MESSAGE.SET_NAME('ONT','OE_BLKT_INVALID_ATTRIBUTE');
3432 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_Util.Get_Attribute_Name
3433 ('INVOICE_TO_ORG_ID'));
3434 --for bug 3257240
3435 OE_ID_TO_VALUE.Invoice_To_Org
3436 ( p_invoice_to_org_id => p_line_rec.invoice_to_org_id
3437 , x_invoice_to_address1 => l_address1
3438 , x_invoice_to_address2 => l_address2
3439 , x_invoice_to_address3 => l_address3
3440 , x_invoice_to_address4 => l_address4
3441 , x_invoice_to_location => l_location
3442 , x_invoice_to_org => l_org
3443 , x_invoice_to_city => l_city
3444 , x_invoice_to_state => l_state
3445 , x_invoice_to_postal_code => l_postal_code
3446 , x_invoice_to_country => l_country
3447 );
3448 FND_MESSAGE.SET_TOKEN('BLANKET_VALUE',l_org);
3449 OE_MSG_PUB.ADD;
3450 x_return_status := FND_API.G_RET_STS_ERROR;
3451 END IF;
3452 END IF;
3453
3454 IF l_enforce_freight_term_flag = 'Y'
3455 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_number
3456 ,p_old_line_rec.blanket_number)
3457 OR NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_line_number
3458 ,p_old_line_rec.blanket_line_number)
3459 OR NOT OE_GLOBALS.EQUAL(p_line_rec.freight_terms_code
3460 ,p_old_line_rec.freight_terms_code) )
3461 THEN
3462 IF l_freight_terms_code <> p_line_rec.freight_terms_code THEN
3463 FND_MESSAGE.SET_NAME('ONT','OE_BLKT_INVALID_ATTRIBUTE');
3464 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_Util.Get_Attribute_Name
3465 ('FREIGHT_TERMS_CODE'));
3466 --for bug 3257240
3467 FND_MESSAGE.SET_TOKEN('BLANKET_VALUE',OE_Id_To_Value.Freight_Terms(l_freight_terms_code));
3468 OE_MSG_PUB.ADD;
3469 x_return_status := FND_API.G_RET_STS_ERROR;
3470 END IF;
3471 END IF;
3472
3473 IF l_enforce_shipping_method_flag = 'Y'
3474 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_number
3475 ,p_old_line_rec.blanket_number)
3476 OR NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_line_number
3477 ,p_old_line_rec.blanket_line_number)
3478 OR NOT OE_GLOBALS.EQUAL(p_line_rec.shipping_method_code
3479 ,p_old_line_rec.shipping_method_code) )
3480 THEN
3481 IF l_shipping_method_code <> p_line_rec.shipping_method_code THEN
3482 FND_MESSAGE.SET_NAME('ONT','OE_BLKT_INVALID_ATTRIBUTE');
3483 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_Util.Get_Attribute_Name
3484 ('SHIPPING_METHOD_CODE'));
3485 --for bug 3257240
3486 FND_MESSAGE.SET_TOKEN('BLANKET_VALUE',OE_Id_To_Value.Ship_Method(l_shipping_method_code));
3487 OE_MSG_PUB.ADD;
3488 x_return_status := FND_API.G_RET_STS_ERROR;
3489 END IF;
3490 END IF;
3491
3492 IF l_enforce_payment_term_flag = 'Y'
3493 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_number
3494 ,p_old_line_rec.blanket_number)
3495 OR NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_line_number
3496 ,p_old_line_rec.blanket_line_number)
3497 OR NOT OE_GLOBALS.EQUAL(p_line_rec.payment_term_id
3498 ,p_old_line_rec.payment_term_id) )
3499 THEN
3500 IF l_payment_term_id <> p_line_rec.payment_term_id THEN
3501 FND_MESSAGE.SET_NAME('ONT','OE_BLKT_INVALID_ATTRIBUTE');
3502 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_Util.Get_Attribute_Name
3503 ('PAYMENT_TERM_ID'));
3504 --for bug 3257240
3505 FND_MESSAGE.SET_TOKEN('BLANKET_VALUE',OE_Id_To_Value.Payment_Term(l_payment_term_id));
3506 OE_MSG_PUB.ADD;
3507 x_return_status := FND_API.G_RET_STS_ERROR;
3508 END IF;
3509 END IF;
3510
3511 IF l_enforce_accounting_rule_flag = 'Y'
3512 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_number
3513 ,p_old_line_rec.blanket_number)
3514 OR NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_line_number
3515 ,p_old_line_rec.blanket_line_number)
3516 OR NOT OE_GLOBALS.EQUAL(p_line_rec.accounting_rule_id
3517 ,p_old_line_rec.accounting_rule_id) )
3518 THEN
3519 IF l_accounting_rule_id <> p_line_rec.accounting_rule_id THEN
3520 FND_MESSAGE.SET_NAME('ONT','OE_BLKT_INVALID_ATTRIBUTE');
3521 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_Util.Get_Attribute_Name
3522 ('ACCOUNTING_RULE_ID'));
3523 --for bug 3257240
3524 FND_MESSAGE.SET_TOKEN('BLANKET_VALUE',OE_Id_To_Value.Accounting_Rule(l_accounting_rule_id));
3525 OE_MSG_PUB.ADD;
3526 x_return_status := FND_API.G_RET_STS_ERROR;
3527 END IF;
3528 END IF;
3529
3530 IF l_enforce_invoicing_rule_flag = 'Y'
3531 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_number
3532 ,p_old_line_rec.blanket_number)
3533 OR NOT OE_GLOBALS.EQUAL(p_line_rec.blanket_line_number
3534 ,p_old_line_rec.blanket_line_number)
3535 OR NOT OE_GLOBALS.EQUAL(p_line_rec.invoicing_rule_id
3536 ,p_old_line_rec.invoicing_rule_id) )
3537 THEN
3538 IF l_invoicing_rule_id <> p_line_rec.invoicing_rule_id THEN
3539 FND_MESSAGE.SET_NAME('ONT','OE_BLKT_INVALID_ATTRIBUTE');
3540 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_Util.Get_Attribute_Name
3541 ('INVOICING_RULE_ID'));
3542 --for bug 3257240
3543 FND_MESSAGE.SET_TOKEN('BLANKET_VALUE',OE_Id_To_Value.Invoicing_Rule(l_invoicing_rule_id));
3544 OE_MSG_PUB.ADD;
3545 x_return_status := FND_API.G_RET_STS_ERROR;
3546 END IF;
3547 END IF;
3548
3549 EXCEPTION
3550 WHEN NO_DATA_FOUND THEN
3551 if l_debug_level > 0 then
3552 oe_debug_pub.add('Blanket Values combination is not valid: Blanket #:'||
3553 p_line_rec.blanket_number || ', Blanket Line #:'||p_line_rec.blanket_line_number, 2);
3554 end if;
3555 FND_MESSAGE.SET_NAME('ONT', 'OE_BLKT_INVALID_BLANKET');
3556 OE_MSG_PUB.Add;
3557 x_return_status := FND_API.G_RET_STS_ERROR;
3558
3559 WHEN FND_API.G_EXC_ERROR THEN
3560 if l_debug_level > 0 then
3561 OE_DEBUG_PUB.Add('Expected Error in Validate Blanket Values',2);
3562 End if;
3563
3564 x_return_status := FND_API.G_RET_STS_ERROR;
3565
3566 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3567 if l_debug_level > 0 then
3568 OE_DEBUG_PUB.Add('Unexpected Error in Validate Blanket Values:'||SqlErrm, 1);
3569 End if;
3570 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3571
3572
3573 WHEN OTHERS THEN
3574
3575 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3576
3577 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3578 THEN
3579 OE_MSG_PUB.Add_Exc_Msg
3580 ( 'OE_VALIDATE_LINE',
3581 'Validate_Blanket_Values');
3582 END IF;
3583
3584 END Validate_Blanket_Values;
3585
3586 /*------------------------------------------------------------------------------
3587 Procedure Name: Get_Return_Line_Attributes
3588 Procedure to return the item type code of the reference line in case of
3589 returns. In case the line is part of ato model the function also returns the
3590 ato_line_id. Added for bug 3718547.
3591 ------------------------------------------------------------------------------*/
3592 PROCEDURE Get_Return_Line_Attributes
3593 ( p_line_rec IN OE_Order_PUB.Line_Rec_Type
3594 , x_line_id OUT NOCOPY NUMBER
3595 , x_item_type_code OUT NOCOPY VARCHAR2
3596 , x_ato_line_id OUT NOCOPY NUMBER
3597 , x_return_status OUT NOCOPY VARCHAR2
3598 )
3599 IS
3600 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3601 BEGIN
3602
3603 x_item_type_code := p_line_rec.item_type_code;
3604 x_return_status := FND_API.G_RET_STS_SUCCESS;
3605
3606 IF p_line_rec.line_category_code = 'RETURN'
3607 AND p_line_rec.reference_line_id IS NOT NULL
3608 AND p_line_rec.return_context IS NOT NULL
3609 THEN
3610
3611 SELECT item_type_code, ato_line_id
3612 INTO x_item_type_code, x_ato_line_id
3613 FROM oe_order_lines
3614 WHERE line_id = p_line_rec.reference_line_id;
3615
3616 x_line_id := p_line_rec.reference_line_id;
3617 END IF;
3618
3619 EXCEPTION
3620
3621 WHEN OTHERS THEN
3622
3623 x_ato_line_id := p_line_rec.ato_line_id;
3624 x_item_type_code := p_line_rec.item_type_code;
3625 x_line_id := p_line_rec.reference_line_id;
3626
3627 IF l_debug_level > 0 THEN
3628 oe_debug_pub.add('Unexpected error in OE_Validate_Line.Get_Return_Line_Attributes');
3629 END IF;
3630
3631 END Get_Return_Line_Attributes;
3632
3633 ------------------------------------------------------------
3634 -- PUBLIC PROCEDURES
3635
3636 --change record for MACD
3637 --MACD: It calls the OE_CONFIG_TSO_PVT.Validate_Container_Model
3638 --to ensure that model restrictions are followed.
3639 -- Procedure Entity
3640 -- We are modifying the procedure ENTITY signature to make p_line_rec as
3641 -- IN OUT NOCOPY. If Entity Validation fails for a combination of attributes
3642 -- then these attributes can be set to MISSING and get new values re-defaulted
3643 -- This logic is needed if
3644 -- * COPY is calling process_order.
3645 -- * User is trying to create a referenced RMA.
3646 -- * User is trying to change the RMA reference.
3647 --
3648 --
3649 PROCEDURE Entity
3650 ( x_return_status OUT NOCOPY VARCHAR2
3651 , p_line_rec IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type
3652 , p_old_line_rec IN OE_Order_PUB.Line_Rec_Type := OE_Order_PUB.G_MISS_LINE_REC
3653 , p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL
3654 )
3655 IS
3656 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
3657 l_commitment_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
3658 l_valid_line_number VARCHAR2(1) := 'Y';
3659 l_dummy VARCHAR2(10);
3660 l_uom VARCHAR2(3);
3661 l_uom_count NUMBER;
3662 /*1544265*/
3663 l_ret_status BOOLEAN:=TRUE;
3664 /*1544265*/
3665 l_agreement_name VARCHAR2(240);
3666 l_item_type_code VARCHAR2(30);
3667 l_sold_to_org NUMBER;
3668 l_price_list_id NUMBER;
3669 l_price_list_name VARCHAR2(240);
3670 l_option_count NUMBER;
3671 l_is_ota_line BOOLEAN;
3672 l_order_quantity_uom VARCHAR2(3);
3673 lcustomer_relations varchar2(1) := OE_Sys_Parameters.VALUE('CUSTOMER_RELATIONSHIPS_FLAG');
3674 l_list_type_code VARCHAR2(30);
3675 l_currency_code VARCHAR2(30);
3676 l_hdr_currency_code VARCHAR2(30);
3677 l_restrict_subinv NUMBER;
3678 --l_price_list_name VARCHAR2(240);
3679 --MC BGN
3680 l_validate_result VARCHAR2(1):='Y';
3681 --MC End
3682 /*OPM 02/JUN/00 BEGIN
3683 ====================*/
3684 l_item_rec OE_ORDER_CACHE.item_rec_type; -- OPM
3685 --l_OPM_UOM VARCHAR2(4); --OPM 06/22 --INVCONV
3686 l_status VARCHAR2(1); --OPM 06/22
3687 l_msg_count NUMBER;
3688 l_msg_data VARCHAR2(2000);
3689 l_return NUMBER;
3690 --3718547
3691 l_ato_line_id NUMBER;
3692 l_line_id NUMBER;
3693 --Begin Bug 2639667
3694 l_delta_qty1 NUMBER;
3695 l_delta_qty2 NUMBER;
3696 l_req_qty1 NUMBER;
3697 l_req_qty2 NUMBER;
3698 l_delivery_count NUMBER;
3699 l_pick_flag VARCHAR2(1);
3700 l_rounded_qty NUMBER;
3701
3702 l_top_container_model VARCHAR2(1);
3703 l_part_of_container VARCHAR2(1);
3704 l_item_description VARCHAR2(240);
3705 l_mast_org_id NUMBER := OE_Sys_Parameters.VALUE_WNPS('MASTER_ORGANIZATION_ID');
3706 CURSOR pick_status IS
3707 SELECT RELEASED_STATUS, SRC_REQUESTED_QUANTITY,
3708 SRC_REQUESTED_QUANTITY2
3709 FROM WSH_DELIVERY_DETAILS
3710 WHERE SOURCE_CODE = 'OE'
3711 AND SOURCE_LINE_ID = p_line_rec.line_id;
3712
3713 --End Bug 2639667
3714 /*OPM 02/JUN/00 END
3715 ==================*/
3716 l_header_created BOOLEAN := FALSE;
3717
3718 -- Added for Enhanced Project Validation
3719 result VARCHAR2(1) := PJM_PROJECT.G_VALIDATE_SUCCESS;
3720 errcode VARCHAR2 (80);
3721 l_order_date_type_code VARCHAR2(10);
3722 p_date DATE;
3723
3724 l_scheduling_Level_code VARCHAR2(30); -- 2691825
3725 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3726
3727 --l_po_status VARCHAR2(4100);
3728 l_req_status VARCHAR2(4100);
3729 l_ds_req VARCHAR2(240) := '';
3730 l_ds_po VARCHAR2(240) := '';
3731 l_line_num VARCHAR2(50);
3732
3733 -- Ar System Parameters
3734 l_AR_Sys_Param_Rec AR_SYSTEM_PARAMETERS_ALL%ROWTYPE;
3735 l_sob_id NUMBER;
3736
3737 -- For Bug 3323610
3738 l_tot_transaction_quantity NUMBER :=0;
3739 l_quantity_entered NUMBER :=0;
3740 l_notnull_revision_flag VARCHAR2(1) := 'N';
3741
3742 --bug 4411054
3743 l_req_header_id NUMBER;
3744 l_po_header_id NUMBER;
3745 l_po_status_rec PO_STATUS_REC_TYPE;
3746 l_cancel_flag VARCHAR2(1);
3747 l_closed_code VARCHAR2(30);
3748
3749 CURSOR c_transaction_quantity IS
3750 SELECT ABS(mmt.transaction_quantity) transaction_quantity,
3751 mmt.transaction_uom,
3752 mmt.revision
3753 FROM oe_order_lines_all ool, mtl_material_transactions mmt
3754 WHERE ool.line_id = p_line_rec.reference_line_id
3755 AND mmt.transaction_source_type_id = 2
3756 AND mmt.transaction_type_id = 33
3757 AND mmt.trx_source_line_id = ool.line_id
3758 AND mmt.inventory_item_id = ool.inventory_item_id
3759 AND mmt.organization_id = ool.ship_from_org_id;
3760 -- AND mmt.revision = p_line_rec.item_revision;
3761
3762 -- For bug3327250
3763 l_old_line_tbl OE_Order_PUB.Line_Tbl_Type;
3764 l_line_tbl OE_Order_PUB.Line_Tbl_Type;
3765 l_control_rec OE_GLOBALS.Control_Rec_Type;
3766 l_old_line_rec OE_Order_PUB.Line_Rec_Type;
3767 -- Variable to indicate Referenced RMA creation or change of reference
3768 G_REF_RMA VARCHAR2(1) := 'N';
3769 -- Variable to indicate that a oe_order_pvt.line call is needed to redefault
3770 -- Missing / Invalid attributes
3771 G_REDEFAULT_MISSING VARCHAR2(1) := 'N';
3772 --added for bug 3739650
3773 l_site_use_code VARCHAR2(30);
3774
3775 l_ordered_quantity NUMBER;
3776 l_cancelled_quantity NUMBER;
3777
3778 -- eBTax Changes
3779 l_ship_to_cust_Acct_id hz_cust_Accounts.cust_Account_id%type;
3780 l_ship_to_party_id hz_cust_accounts.party_id%type;
3781 l_ship_to_party_site_id hz_party_sites.party_site_id%type;
3782 l_bill_to_cust_Acct_id hz_cust_Accounts.cust_Account_id%type;
3783 l_bill_to_party_id hz_cust_accounts.party_id%type;
3784 l_bill_to_party_site_id hz_party_sites.party_site_id%type;
3785 l_org_id NUMBER;
3786 -- l_legal_entity_id NUMBER;
3787
3788 cursor partyinfo(p_site_org_id HZ_CUST_SITE_USES_ALL.SITE_USE_ID%type) is
3789 SELECT cust_acct.cust_account_id,
3790 cust_Acct.party_id,
3791 acct_site.party_site_id,
3792 site_use.org_id
3793 FROM
3794 HZ_CUST_SITE_USES_ALL site_use,
3795 HZ_CUST_ACCT_SITES_ALL acct_site,
3796 HZ_CUST_ACCOUNTS_ALL cust_Acct
3797 WHERE site_use.site_use_id = p_site_org_id
3798 AND site_use.cust_acct_site_id = acct_site.cust_acct_site_id
3799 and acct_site.cust_account_id = cust_acct.cust_account_id;
3800
3801 -- end eBTax changes
3802 --added for bug 4200055
3803 l_price_list_rec OE_ORDER_CACHE.Price_List_Rec_Type ;
3804 --PP Revenue Recognition
3805 --bug 4893057
3806 l_rule_type VARCHAR2(10);
3807
3808 BEGIN
3809 IF l_debug_level > 0 then
3810 oe_debug_pub.add('Enter OE_VALIDATE_LINE.ENTITY',1);
3811 END IF;
3812
3813 IF OE_GLOBALS.G_HEADER_CREATED
3814 THEN
3815 IF l_debug_level > 0 then
3816 oe_debug_pub.add('Header has got created in the same call',1);
3817 END IF;
3818 OE_Order_Cache.Load_Order_Header(p_line_rec.header_id);
3819 l_header_created := TRUE;
3820 END IF;
3821
3822 -----------------------------------------------------------
3823 -- Check required attributes.
3824 -----------------------------------------------------------
3825
3826 IF l_debug_level > 0 then
3827 oe_debug_pub.add('1 '||l_return_status, 1);
3828 END IF;
3829 IF p_line_rec.line_id IS NULL
3830 THEN
3831
3832 l_return_status := FND_API.G_RET_STS_ERROR;
3833
3834 fnd_message.set_name('ONT','OE_ATTRIBUTE_REQUIRED');
3835 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
3836 OE_Order_UTIL.Get_Attribute_Name('LINE_ID'));
3837 OE_MSG_PUB.Add;
3838
3839 END IF;
3840 IF l_debug_level > 0 then
3841 oe_debug_pub.add('2 '||l_return_status, 1);
3842 END IF;
3843 IF p_line_rec.inventory_item_id IS NULL
3844 THEN
3845
3846 l_return_status := FND_API.G_RET_STS_ERROR;
3847
3848 fnd_message.set_name('ONT','OE_ATTRIBUTE_REQUIRED');
3849 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
3850 OE_Order_UTIL.Get_Attribute_Name('INVENTORY_ITEM_ID'));
3851 OE_MSG_PUB.Add;
3852
3853 END IF;
3854 IF l_debug_level > 0 then
3855 oe_debug_pub.add('3 '||l_return_status, 1);
3856 END IF;
3857 IF p_line_rec.line_type_id IS NULL
3858 THEN
3859
3860 l_return_status := FND_API.G_RET_STS_ERROR;
3861
3862 fnd_message.set_name('ONT','OE_ATTRIBUTE_REQUIRED');
3863 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
3864 OE_Order_UTIL.Get_Attribute_Name('LINE_TYPE_ID'));
3865 OE_MSG_PUB.Add;
3866
3867 ELSIF p_line_rec.line_type_id IS NOT NULL AND -- Bug 5873408
3868 ( nvl(p_line_rec.transaction_phase_code, 'F') <> 'N' )
3869 THEN
3870 Validate_line_type(p_line_rec => p_line_rec,
3871 p_old_line_rec => p_old_line_rec);
3872
3873 END IF;
3874
3875 -- Return Error if a required attribute is missing.
3876
3877 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
3878
3879 RAISE FND_API.G_EXC_ERROR;
3880
3881 END IF;
3882
3883
3884 --------------------------------------------------------------
3885 -- Check conditionally required attributes here.
3886 --------------------------------------------------------------
3887
3888 -- QUOTING changes
3889 IF oe_code_control.code_release_level >= '110510' THEN
3890
3891 Check_Negotiation_Attributes(p_line_rec
3892 ,p_old_line_rec
3893 ,l_return_status
3894 );
3895
3896 ELSE
3897
3898 -- Feature not supported prior to 11i10, raise error
3899 IF p_line_rec.transaction_phase_code = 'N' THEN
3900 FND_MESSAGE.SET_NAME('ONT','OE_QUOTE_INVALID_RELEASE');
3901 OE_MSG_PUB.ADD;
3902 RAISE FND_API.G_EXC_ERROR;
3903 END IF;
3904
3905 END IF;
3906
3907 l_item_type_code := p_line_rec.item_type_code;
3908
3909 -- For return lines, Return_Reason_Code is required
3910 IF l_debug_level > 0 then
3911 oe_debug_pub.add('5 '||l_return_status, 1);
3912 END IF;
3913 IF p_line_rec.line_category_code = OE_GLOBALS.G_RETURN_CATEGORY_CODE
3914 THEN
3915 -- For return lines, Return_Reason_Code is required
3916 IF p_line_rec.return_reason_code is NULL
3917 THEN
3918 l_return_status := FND_API.G_RET_STS_ERROR;
3919
3920 fnd_message.set_name('ONT','OE_ATTRIBUTE_REQUIRED');
3921 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
3922 OE_Order_UTIL.Get_Attribute_Name('RETURN_REASON_CODE'));
3923 OE_MSG_PUB.Add;
3924 END IF;
3925
3926 -- Set the G_REF_RMA if the RMA is getting created or the reference is
3927 -- changing.
3928
3929 if l_debug_level > 0 then
3930 oe_debug_pub.add('The return attr 2 is '||p_line_rec.return_attribute2);
3931 oe_debug_pub.add('The old return attr 2 is '||p_old_line_rec.return_attribute2);
3932 oe_debug_pub.add('The ship_to_org_id is '||p_line_rec.ship_to_org_id);
3933 end if;
3934 IF l_return_status = FND_API.G_RET_STS_SUCCESS AND
3935 NOT OE_GLOBALS.EQUAL(p_line_rec.return_attribute2,
3936 p_old_line_rec.return_attribute2)
3937 THEN
3938 G_REF_RMA := 'Y';
3939 if l_debug_level > 0 then
3940 OE_DEBUG_PUB.Add('Setting G_REF_RMA',1);
3941 end if;
3942 END IF;
3943
3944 --3718547
3945 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
3946 Get_Return_Line_Attributes
3947 ( p_line_rec => p_line_rec
3948 , x_line_id => l_line_id
3949 , x_item_type_code => l_item_type_code
3950 , x_ato_line_id => l_ato_line_id
3951 , x_return_status => l_return_status);
3952 END IF;
3953
3954 END IF;
3955
3956 IF l_debug_level > 0 then
3957 oe_debug_pub.add('6 '||l_return_status, 1);
3958 END IF;
3959
3960 ---- Start 2691825 ---
3961 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
3962 IF l_debug_level > 0 then
3963 oe_debug_pub.add('Checking that it is a standard item...',1);
3964 END IF;
3965
3966 IF (p_line_rec.item_type_code IN( 'MODEL','CLASS','KIT','OPTION')
3967 AND p_line_rec.line_category_code = 'ORDER'
3968 AND p_line_rec.source_type_code = 'INTERNAL')
3969 OR (p_line_rec.ship_set_id is not null
3970 OR P_line_rec.arrival_set_id is not null) THEN -- 2527722
3971 IF l_debug_level > 0 then
3972 oe_debug_pub.add('Checking the level...',1);
3973 END IF;
3974 l_scheduling_level_code := Oe_Schedule_Util.Get_Scheduling_Level(p_line_rec.header_id,
3975 p_line_rec.line_type_id);
3976 -- Any item other than Standard can not have level - four or five
3977 IF (l_scheduling_level_code = OE_SCHEDULE_UTIL.SCH_LEVEL_FOUR
3978 OR l_scheduling_level_code = OE_SCHEDULE_UTIL.SCH_LEVEL_FIVE) THEN
3979
3980 FND_MESSAGE.SET_NAME('ONT', 'OE_SCH_INACTIVE_STD_ONLY');
3981 FND_MESSAGE.SET_TOKEN('LTYPE',nvl(Oe_Schedule_Util.sch_cached_line_type ,'0'));
3982 OE_MSG_PUB.Add;
3983 l_return_status := FND_API.G_RET_STS_ERROR;
3984 END IF;
3985
3986 END IF;
3987 END IF;
3988 -- End 2691825 -----
3989 -- Start 2720165 --
3990 IF p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_SERVICE
3991 AND p_line_rec.reserved_quantity is not null
3992 AND p_line_rec.reserved_quantity <> FND_API.G_MISS_NUM THEN
3993 IF l_debug_level > 0 then
3994 oe_debug_pub.add( 'A SERVICE LINE ', 1 ) ;
3995 END IF;
3996
3997 FND_MESSAGE.SET_NAME('ONT','OE_SCH_NO_ACTION_DONE_NO_EXP');
3998 OE_MSG_PUB.Add;
3999 l_return_status := FND_API.G_RET_STS_ERROR;
4000 END IF;
4001 ---- End 2720165 --
4002
4003 -- subinventory
4004 IF l_debug_level > 0 then
4005 oe_debug_pub.add('Entity: subinventory - ' || p_line_rec.subinventory);
4006 END IF;
4007 -- first validate warehouse/subinv combination is valid
4008
4009 IF p_line_rec.ship_from_org_id is not null AND
4010 p_line_rec.subinventory is not null AND
4011 p_line_rec.ship_From_org_id <> FND_API.G_MISS_NUM AND
4012 p_line_rec.subinventory <> FND_API.G_MISS_CHAR THEN
4013
4014 IF p_line_rec.ship_from_org_id <> nvl(p_old_line_rec.ship_from_org_id, 0) OR
4015 p_line_rec.subinventory <> nvl(p_old_line_rec.subinventory, '0') THEN
4016 BEGIN
4017 SELECT 'VALID'
4018 INTO l_dummy
4019 FROM MTL_SUBINVENTORIES_TRK_VAL_V
4020 WHERE organization_id = p_line_rec.ship_from_org_id
4021 AND secondary_inventory_name = p_line_rec.subinventory;
4022 EXCEPTION
4023 WHEN OTHERS THEN
4024 fnd_message.set_name('ONT','OE_SUBINV_INVALID');
4025 OE_MSG_PUB.Add;
4026 l_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4027 END;
4028 END IF;
4029 END IF;
4030
4031 --Shipment number cannot be updated. Bug 3456544
4032 IF nvl(p_line_rec.shipment_number,FND_API.G_MISS_NUM) <> nvl(p_old_line_rec.shipment_number,FND_API.G_MISS_NUM)
4033 AND p_line_rec.operation =OE_GLOBALS.G_OPR_UPDATE
4034 AND nvl(p_line_rec.split_action_code,'X')<>'SPLIT'
4035 THEN
4036 fnd_message.set_name('ONT','OE_CANT_UPDATE_SHIPMENT_NO');
4037 OE_MSG_PUB.Add;
4038 l_return_status:=FND_API.G_RET_STS_ERROR;
4039 END IF;
4040
4041 IF p_line_rec.subinventory is not null THEN
4042 IF p_line_rec.source_type_code = 'INTERNAL' OR
4043 p_line_rec.source_type_code is null THEN
4044 IF l_debug_level > 0 then
4045 oe_debug_pub.add('Entity Validateion: subinventory', 1);
4046 END IF;
4047 IF p_line_rec.ship_from_org_id is null THEN
4048 l_return_status := FND_API.G_RET_STS_ERROR;
4049 fnd_message.set_name('ONT', 'OE_ATTRIBUTE_REQUIRED');
4050 fnd_message.set_token('ATTRIBUTE',OE_Order_UTIL.Get_Attribute_Name('SHIP_FROM_ORG_ID'));
4051 OE_MSG_PUB.Add;
4052 ELSE
4053 -- validate the subinv is allowed (expense/asset)
4054 -- because defaulting can be defaulting an expense sub
4055 -- and the INV profile is set to No.
4056 IF l_debug_level > 0 then
4057 oe_debug_pub.add('Entity: p_line_rec.order_source_id:' || p_line_rec.order_source_id, 5);
4058 oe_debug_pub.add('Entity: profile expense_asset:' || fnd_profile.value('INV:EXPENSE_TO_ASSET_TRANSFER'), 5);
4059 END IF;
4060 /* fix bug 2570174, check for restricted subinv */
4061 BEGIN
4062 -- bug 4171642
4063 if (OE_ORDER_CACHE.g_item_rec.organization_id <> FND_API.G_MISS_NUM
4064 AND
4065 OE_ORDER_CACHE.g_item_rec.organization_id = p_line_rec.ship_from_org_id
4066 AND
4067 OE_ORDER_CACHE.g_item_rec.inventory_item_id = p_line_rec.inventory_item_id)
4068 THEN
4069 l_restrict_subinv := OE_ORDER_CACHE.g_item_rec.restrict_subinventories_code;
4070 else
4071 OE_ORDER_CACHE.Load_Item( p_key1 => p_line_rec.inventory_item_id ,
4072 p_key2 => p_line_rec.ship_from_org_id );
4073 if ( OE_ORDER_CACHE.g_item_rec.organization_id = p_line_rec.ship_from_org_id
4074 and OE_ORDER_CACHE.g_item_rec.inventory_item_id = p_line_rec.inventory_item_id) THEN
4075 l_restrict_subinv := OE_ORDER_CACHE.g_item_rec.restrict_subinventories_code;
4076 else
4077 l_restrict_subinv := 0;
4078 end if ;
4079 end if ;
4080 /*SELECT RESTRICT_SUBINVENTORIES_CODE
4081 INTO l_restrict_subinv
4082 FROM MTL_SYSTEM_ITEMS
4083 WHERE inventory_item_id = p_line_rec.inventory_item_id
4084 AND organization_id = p_line_rec.ship_from_org_id;*/
4085 -- bug 4171642
4086 EXCEPTION
4087 WHEN NO_DATA_FOUND THEN
4088 l_restrict_subinv := 0;
4089 END;
4090
4091 IF nvl(l_restrict_subinv, 0) = 1 THEN
4092 BEGIN
4093 select 'Y'
4094 into l_dummy
4095 from MTL_ITEM_SUB_INVENTORIES_ALL_V
4096 where organization_id = p_line_rec.ship_from_org_id
4097 and inventory_item_id = p_line_rec.inventory_item_id
4098 and secondary_inventory = p_line_rec.subinventory;
4099 EXCEPTION
4100 WHEN OTHERS THEN
4101 l_return_status := FND_API.G_RET_STS_ERROR;
4102 fnd_message.set_name('ONT', 'OE_SUBINV_INVALID');
4103 oe_msg_pub.add;
4104 END;
4105 ELSE -- not a restricted subinv case
4106 BEGIN
4107 select 'Y'
4108 into l_dummy
4109 from mtl_subinventories_trk_val_v sub
4110 where sub.organization_id = p_line_rec.ship_from_org_id
4111 and sub.secondary_inventory_name = p_line_rec.subinventory
4112 and (fnd_profile.value('INV:EXPENSE_TO_ASSET_TRANSFER') = 1
4113 OR
4114 (fnd_profile.value('INV:EXPENSE_TO_ASSET_TRANSFER') <> 1
4115 and nvl(p_line_rec.order_source_id, -1) <> 10
4116 )
4117 OR
4118 (fnd_profile.value('INV:EXPENSE_TO_ASSET_TRANSFER') <> 1
4119 and nvl(p_line_rec.order_source_id, -1) = 10
4120 and 'N' = (select inventory_asset_flag
4121 from mtl_system_items
4122 where inventory_item_id = p_line_rec.inventory_item_id
4123 and organization_id = p_line_rec.ship_from_org_id)
4124 )
4125 OR
4126 (fnd_profile.value('INV:EXPENSE_TO_ASSET_TRANSFER') <> 1
4127 and nvl(p_line_rec.order_source_id, -1) = 10
4128 and 'Y' = (select inventory_asset_flag
4129 from mtl_system_items
4130 where inventory_item_id = p_line_rec.inventory_item_id
4131 and organization_id = p_line_rec.ship_from_org_id)
4132 and sub.asset_inventory = 1
4133 )
4134 );
4135 EXCEPTION
4136 WHEN OTHERS THEN
4137 l_return_status := FND_API.G_RET_STS_ERROR;
4138 fnd_message.set_name('ONT', 'OE_SUBINV_NON_ASSET');
4139 oe_msg_pub.add;
4140 END;
4141 END IF; -- restrict subinv or not
4142 END IF;
4143 ELSE -- external
4144 l_return_status := FND_API.G_RET_STS_ERROR;
4145 fnd_message.set_name('ONT', 'OE_SUBINV_EXTERNAL');
4146 OE_MSG_PUB.Add;
4147 END IF;
4148 END IF;
4149
4150 -- end subinventory
4151 IF l_debug_level > 0 then
4152 oe_debug_pub.add('Entity: done subinv validation', 1);
4153 END IF;
4154
4155 -- If line is booked, then check for the attributes required on booked lines
4156 -- Fix bug 1277092: this check not required for fully cancelled lines
4157 IF p_line_rec.booked_flag = 'Y'
4158 AND p_line_rec.cancelled_flag <> 'Y' THEN
4159 /*IF NOT OE_Sales_Can_Util.G_Require_Reason
4160 -- added check for cancellation request
4161 AND NOT OE_delayed_requests_Pvt.Check_For_Request
4162 (p_entity_code => OE_GLOBALS.G_ENTITY_ALL,
4163 p_entity_id => p_line_rec.line_id,
4164 p_request_type => OE_GLOBALS.G_CANCEL_WF) THEN
4165 */
4166
4167 Check_Book_Reqd_Attributes( p_line_rec => p_line_rec
4168 , p_old_line_rec => p_old_line_rec
4169 , x_return_status => l_return_status);
4170 -- END IF;
4171
4172 END IF;
4173
4174 -- Return Error if a conditionally required attribute is missing.
4175
4176 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
4177
4178 RAISE FND_API.G_EXC_ERROR;
4179
4180 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4181
4182 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4183
4184 END IF;
4185
4186 -- Bug3412008 Suppressing the validation of item_revision and
4187 -- l_tot_transaction_quantity for retrobill lines
4188 IF p_line_rec.order_source_id <>27 THEN
4189 --bug 3323610
4190 IF p_line_rec.line_category_code = OE_GLOBALS.G_RETURN_CATEGORY_CODE AND
4191 (p_line_rec.item_revision is not NULL and
4192 p_line_rec.item_revision <> FND_API.G_MISS_CHAR) AND
4193 (p_line_rec.ship_from_org_id is not NULL and
4194 p_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM) AND
4195 ((NOT OE_GLOBALS.Equal(p_line_rec.Item_revision,
4196 p_old_line_rec.Item_revision)) OR
4197 (NOT OE_GLOBALS.Equal(p_line_rec.ship_from_org_id,
4198 p_old_line_rec.ship_from_org_id)) OR
4199 (NOT OE_GLOBALS.Equal(p_line_rec.ordered_quantity,
4200 p_old_line_rec.ordered_quantity)) OR
4201 (NOT OE_GLOBALS.Equal(p_line_rec.inventory_item_id,
4202 p_old_line_rec.inventory_item_id)))
4203 THEN
4204 BEGIN
4205 SELECT 1
4206 INTO l_dummy
4207 FROM mtl_item_revisions
4208 WHERE inventory_item_id=p_line_rec.inventory_item_id
4209 AND organization_id=p_line_rec.ship_from_org_id
4210 AND effectivity_date<=sysdate
4211 AND revision= p_line_rec.item_revision;
4212 EXCEPTION
4213 WHEN NO_DATA_FOUND THEN
4214 fnd_message.set_name('ONT','ONT_REV_WH_NOT_EXIST');
4215 OE_MSG_PUB.Add;
4216 l_return_status := FND_API.G_RET_STS_ERROR;
4217 END;
4218 IF p_line_rec.reference_line_id is NOT NULL AND
4219 p_line_rec.reference_line_id <> FND_API.G_MISS_NUM
4220 THEN
4221 FOR r_transaction_quantity IN c_transaction_quantity
4222 LOOP
4223 -- Set the flag to mark a valid record exists in inventory for
4224 -- the shipped line with item revision.
4225
4226 IF r_transaction_quantity.revision IS NOT NULL THEN
4227 l_notnull_revision_flag := 'Y';
4228 END IF;
4229
4230 IF r_transaction_quantity.revision = p_line_rec.item_revision THEN
4231
4232 l_tot_transaction_quantity:=l_tot_transaction_quantity +
4233 OE_Order_Misc_Util.convert_uom(
4234 p_line_rec.inventory_item_id,
4235 r_transaction_quantity.transaction_uom,
4236 p_line_rec.order_quantity_uom,
4237 r_transaction_quantity.transaction_quantity
4238 );
4239 END IF;
4240 END LOOP;
4241
4242 -- If the item revision entered on RMA line doesn't match the one
4243 -- on shipped line then give a warning message.
4244
4245 IF l_notnull_revision_flag = 'Y' AND
4246 l_tot_transaction_quantity = 0
4247 THEN
4248 fnd_message.set_name('ONT','ONT_ITEM_REV_MISMATCH');
4249 OE_MSG_PUB.Add;
4250 END IF;
4251
4252 IF l_tot_transaction_quantity > 0
4253 THEN
4254 -- Check if there are other booked RMA lines with the same item
4255 -- revision.
4256 BEGIN
4257
4258 select sum(ordered_quantity)
4259 into l_quantity_entered
4260 from oe_order_lines
4261 where reference_line_id = p_line_rec.reference_line_id
4262 and line_category_code = 'RETURN'
4263 and item_revision = p_line_rec.item_revision
4264 and sold_to_org_id = p_line_rec.sold_to_org_id
4265 and booked_flag = 'Y'
4266 and cancelled_flag <> 'Y'
4267 and line_id <> p_line_rec.line_id;
4268
4269 EXCEPTION
4270 WHEN NO_DATA_FOUND THEN
4271 NULL;
4272 END;
4273 If l_debug_level > 0 THEN
4274 oe_debug_pub.add('The quantity entered is '||l_quantity_entered);
4275 oe_debug_pub.add('l_tot_transaction_quantity '||l_tot_transaction_quantity);
4276 END IF;
4277 IF (l_tot_transaction_quantity - NVL(l_quantity_entered,0))
4278 < p_line_rec.ordered_quantity
4279 THEN
4280 fnd_message.set_name('ONT','ONT_RMA_EXCEED_SHIP_QTY');
4281 OE_MSG_PUB.Add;
4282 l_return_status := FND_API.G_RET_STS_ERROR;
4283 END IF;
4284 END IF; -- IF l_tot_transaction_quantity > 0
4285 END IF; -- IF p_line_rec.reference_line_id is NOT NULL
4286
4287 END IF;
4288 --end bug 3323610
4289 END IF; --bug3412008
4290
4291 -- OPM 02/JUN/00 START
4292 -- For a dual control process item, check qty1/2 both present and sync'd
4293 -- =====================================================================
4294 IF l_debug_level > 0 THEN
4295 oe_debug_pub.add('Entity DUAL X-VAL start', 1);
4296 END IF;
4297 IF OE_Line_Util.dual_uom_control
4298 (p_line_rec.inventory_item_id
4299 ,p_line_rec.ship_from_org_id
4300 ,l_item_rec)
4301 THEN
4302 --IF l_item_rec.dualum_ind in (1,2,3) THEN INVCONV
4303 IF l_debug_level > 0 THEN
4304 oe_debug_pub.add('DUAL X-VAL dualum is true', 2);
4305 END IF;
4306
4307 IF (p_line_rec.ordered_quantity <> FND_API.G_MISS_NUM OR
4308 p_line_rec.ordered_quantity IS NOT NULL) AND
4309 (p_line_rec.ordered_quantity2 = FND_API.G_MISS_NUM OR
4310 p_line_rec.ordered_quantity2 IS NULL) THEN
4311 IF l_debug_level > 0 THEN
4312 oe_debug_pub.add('dual X-VAL qty 1 not empty', 2);
4313 END IF;
4314 l_return_status := FND_API.G_RET_STS_ERROR;
4315 fnd_message.set_name('ONT','OE_ATTRIBUTE_REQUIRED');
4316 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Ordered_Quantity2');
4317 OE_MSG_PUB.Add;
4318
4319 ELSIF (p_line_rec.ordered_quantity2 <> FND_API.G_MISS_NUM OR
4320 p_line_rec.ordered_quantity2 IS NOT NULL) AND
4321 (p_old_line_rec.ordered_quantity = FND_API.G_MISS_NUM OR
4322 p_line_rec.ordered_quantity IS NULL) THEN
4323
4324 l_return_status := FND_API.G_RET_STS_ERROR;
4325 fnd_message.set_name('ONT','OE_ATTRIBUTE_REQUIRED');
4326 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Ordered_Quantity');
4327 OE_MSG_PUB.Add;
4328 END IF;
4329 -- END IF; INVCONV
4330
4331 /* If qty1/qty2 both populated, check tolerances
4332 ================================================*/
4333 IF l_debug_level > 0 THEN
4334 oe_debug_pub.add('dual - start tolerance check', 2);
4335 END IF;
4336
4337 IF l_item_rec.secondary_default_ind in ('D','N') THEN -- INVCONV
4338 --IF l_item_rec.dualum_ind in (2,3) THEN
4339 IF (p_line_rec.ordered_quantity <> FND_API.G_MISS_NUM AND
4340 p_line_rec.ordered_quantity IS NOT NULL) AND
4341 (p_line_rec.ordered_quantity2 <> FND_API.G_MISS_NUM AND
4342 p_line_rec.ordered_quantity2 IS NOT NULL)
4343 --and (p_line_rec.order_quantity_uom <> p_line_rec.ordered_quantity_uom2 ) -- INVCONV
4344 AND (p_line_rec.ordered_quantity <> p_line_rec.ordered_quantity2 ) -- INVCONV
4345
4346 THEN
4347
4348 IF l_debug_level > 0 THEN
4349 oe_debug_pub.add('Entity - DUAL X-Val. ordered_quantity = ' || p_line_rec.ordered_quantity ,1);
4350 oe_debug_pub.add('Entity - DUAL X-Val. ordered_quantity2 = ' || p_line_rec.ordered_quantity2 ,1);
4351 END IF;
4352 -- OPM BEGIN 06/22
4353 /* Get the OPM equivalent code for order_quantity_uom
4354 ===================================================== -- INVCONV
4355 GMI_Reservation_Util.Get_OPMUOM_from_AppsUOM
4356 (p_Apps_UOM => p_line_rec.order_quantity_uom
4357 ,x_OPM_UOM => l_OPM_UOM
4358 ,x_return_status => l_status
4359 ,x_msg_count => l_msg_count
4360 ,x_msg_data => l_msg_data);
4361
4362 l_return := GMICVAL.dev_validation(l_item_rec.opm_item_id
4363 ,0
4364 ,p_line_rec.ordered_quantity
4365 ,l_OPM_UOM
4366 ,p_line_rec.ordered_quantity2
4367 ,l_item_rec.opm_item_um2
4368 ,0);
4369 -- OPM END 06/22 */
4370 l_return := INV_CONVERT.Within_Deviation -- INVCONV
4371 ( p_organization_id => p_line_rec.ship_from_org_id
4372 , p_inventory_item_id => p_line_rec.inventory_item_id
4373 , p_precision => 5
4374 , p_quantity => abs(p_line_rec.ordered_quantity) -- Added abs for bug 6485013
4375 , p_uom_code1 => p_line_rec.order_quantity_uom
4376 , p_quantity2 => abs(p_line_rec.ordered_quantity2) -- Added abs for bug 6485013
4377 , p_uom_code2 => p_line_rec.ordered_quantity_uom2 );
4378
4379 IF l_return = 0 -- (false)
4380 then
4381 IF l_debug_level > 0 THEN
4382 oe_debug_pub.add('Entity - dual UM with tolerance error 1. return = '|| l_return ,1);
4383 END IF;
4384
4385 l_msg_data := FND_MSG_PUB.GET(p_msg_index => FND_MSG_PUB.G_LAST, -- INVCONV
4386 p_encoded => 'F');
4387 oe_msg_pub.add_text(p_message_text => l_msg_data);
4388 IF l_debug_level > 0 THEN
4389 oe_debug_pub.add(l_msg_data,1);
4390 END IF;
4391 RAISE fnd_api.g_exc_error;
4392
4393 else
4394
4395 IF l_debug_level > 0 THEN
4396 oe_debug_pub.add('Entity - dual UM with no tolerance error ',1);
4397 END IF; -- INVCONV
4398
4399 --Begin Bug 2639667
4400 -- Code added till End Bug 2639667 comment.
4401
4402
4403 l_pick_flag := 'N';
4404 l_delivery_count := 0;
4405 l_delta_qty1 := Null;
4406 l_delta_qty2 := Null;
4407
4408 FOR r_pick_status IN pick_status LOOP
4409 l_delivery_count := l_delivery_count + 1;
4410 l_req_qty1 := r_pick_status.SRC_REQUESTED_QUANTITY;
4411 l_req_qty2 := r_pick_status.SRC_REQUESTED_QUANTITY2;
4412 IF r_pick_status.RELEASED_STATUS IN ('Y', 'S', 'N', 'X') THEN
4413 l_pick_flag := 'Y';
4414 END IF;
4415 END LOOP;
4416
4417
4418 IF (l_pick_flag = 'Y' OR l_delivery_count > 1) THEN
4419
4420 l_delta_qty1 := p_line_rec.ordered_quantity - l_req_qty1;
4421 l_delta_qty2 := p_line_rec.ordered_quantity2 - nvl(l_req_qty2,0);
4422
4423 IF ( l_delta_qty1 > 0 AND l_delta_qty2 <= 0) OR (l_delta_qty2 > 0 AND l_delta_qty1 <= 0) THEN
4424 l_return_status := FND_API.G_RET_STS_ERROR;
4425 FND_MESSAGE.set_name('GMI', 'GMI_SHIPPING_SPLIT_DEV_ERR'); -- INVCONV change this message to INV
4426 OE_MSG_PUB.Add;
4427 END IF;
4428
4429 IF (l_delta_qty1 > 0) AND (l_delta_qty2 > 0) THEN
4430
4431 l_return := INV_CONVERT.Within_Deviation -- INVCONV
4432 ( p_organization_id =>
4433 p_line_rec.ship_from_org_id
4434 , p_inventory_item_id =>
4435 p_line_rec.inventory_item_id
4436 , p_precision => 5
4437 , p_quantity => l_delta_qty1
4438 , p_uom_code1 => p_line_rec.order_quantity_uom -- INVCONV
4439 , p_quantity2 => l_delta_qty2
4440 , p_uom_code2 => l_item_rec.secondary_uom_code );
4441
4442 IF l_return = 0 -- (false) -- INVCONV
4443 then
4444 IF l_debug_level > 0 THEN
4445 oe_debug_pub.add('Entity - dual UM with tolerance error 2. return = '|| l_return ,1);
4446 END IF;
4447
4448 l_msg_data := FND_MSG_PUB.GET(p_msg_index => FND_MSG_PUB.G_LAST, -- INVCONV
4449 p_encoded => 'F');
4450 oe_msg_pub.add_text(p_message_text => l_msg_data);
4451 IF l_debug_level > 0 THEN
4452 oe_debug_pub.add(l_msg_data,1);
4453 END IF;
4454 l_return_status := FND_API.G_RET_STS_ERROR;
4455 RAISE fnd_api.g_exc_error;
4456 END IF; -- IF l_return = 0 -- (false)
4457
4458
4459 END IF; -- IF (l_delta_qty1 > 0) AND (l_delta_qty2 > 0) THEN
4460 END IF;
4461 --End Bug 2639667
4462 END IF; -- IF (l_pick_flag = 'Y' OR l_delivery_count > 1) THEN
4463 END IF; -- else
4464 END IF;
4465 END IF;
4466
4467 -- Return Error if a required quantity validation fails
4468 -- ====================================================
4469 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
4470 RAISE FND_API.G_EXC_ERROR;
4471 END IF;
4472 -- OPM 02/JUN/00 END
4473 -- ===================
4474
4475
4476 ---------------------------------------------------------------------
4477 -- Validate attribute dependencies here.
4478 ---------------------------------------------------------------------
4479
4480 -- BEGINNING : line number validation
4481 -- Validate line number if item type or line number changed
4482 -- AND if the line is not being created by splits.
4483
4484 /* IF NOT l_header_created commented out nocopy for 2068070. Also replaced the following AND with IF */
4485
4486
4487 IF NOT (p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
4488 p_line_rec.split_from_line_id IS NOT NULL)
4489 AND ( NOT OE_GLOBALS.Equal
4490 (p_line_rec.item_type_code,p_old_line_rec.item_type_code)
4491 OR NOT OE_GLOBALS.Equal
4492 (p_line_rec.line_number,p_old_line_rec.line_number) )
4493 THEN
4494
4495 -- Line number should be unique on all standard and top level
4496 -- model lines on an order
4497
4498 IF ( p_line_rec.item_type_code = 'STANDARD'
4499 --Bug 6186554
4500 --For Top Models, top_model_line_id and line_id are equal.
4501 --OR (p_line_rec.top_model_line_id <> p_line_rec.line_id
4502 OR (p_line_rec.top_model_line_id = p_line_rec.line_id
4503 AND p_line_rec.item_type_code = 'MODEL'))
4504 AND OE_ORDER_IMPORT_MAIN_PVT.G_CONTEXT_ID IS NULL --- validate only if not Order import Condition added for bug no 5493479
4505 THEN
4506
4507 BEGIN
4508 SELECT 'N'
4509 INTO l_valid_line_number
4510 FROM oe_order_lines L
4511 WHERE L.line_number = p_line_rec.line_number
4512 AND L.header_id = p_line_rec.header_id
4513 AND L.line_id <> p_line_rec.line_id
4514 AND ( L.item_type_code = 'STANDARD'
4515 OR ( L.top_model_line_id = L.line_id
4516 AND L.item_type_code = 'MODEL'));
4517
4518 EXCEPTION
4519 WHEN no_data_found THEN
4520 l_valid_line_number := 'Y';
4521 -- Too many rows exception would be raised if there are split
4522 -- lines with the same line number
4523 WHEN too_many_rows THEN
4524 l_valid_line_number := 'N';
4525 END;
4526
4527 IF l_valid_line_number = 'N' THEN
4528 FND_MESSAGE.SET_NAME('ONT','OE_LINE_NUMBER_EXISTS');
4529 OE_MSG_PUB.ADD;
4530 /* x_return_status := FND_API.G_RET_STS_ERROR; This line replaced with next for 2068070 */
4531 l_return_status := FND_API.G_RET_STS_ERROR;
4532 END IF;
4533
4534 END IF;
4535
4536 END IF;
4537 oe_debug_pub.add('l_valid_line_number end ***'||l_valid_line_number);
4538 -- END : line number validation
4539
4540
4541 -- Validate if the warehouse, item combination is valid
4542 IF p_line_rec.inventory_item_id is not null AND
4543 p_line_rec.ship_from_org_id is not null AND
4544 p_line_rec.inventory_item_id <> FND_API.G_MISS_NUM AND
4545 p_line_rec.ship_from_org_id <> FND_API.G_MISS_NUM THEN
4546
4547 IF p_line_rec.inventory_item_id <>
4548 nvl(p_old_line_rec.inventory_item_id,0) OR
4549 p_line_rec.ship_from_org_id <> nvl(p_old_line_rec.ship_from_org_id,0)
4550 THEN
4551 IF p_line_rec.source_type_code = OE_GLOBALS.G_SOURCE_INTERNAL
4552 or p_line_rec.source_type_code is null
4553 THEN
4554 IF l_debug_level > 0 then
4555 oe_debug_pub.add('Source Type is Internal',1);
4556 END IF;
4557
4558 -- FOR RMAs we don't validate Item Warehouse combination
4559
4560 IF NOT Validate_Item_Warehouse
4561 (p_line_rec.inventory_item_id,
4562 p_line_rec.ship_from_org_id,
4563 l_item_type_code,
4564 p_line_rec.line_id,
4565 p_line_rec.top_model_line_id,
4566 p_line_rec.source_document_type_id, /*Bug1741158 chhung*/
4567 p_line_rec.line_category_code)/* Bug1741158 chhung */
4568 THEN
4569 l_return_status := FND_API.G_RET_STS_ERROR;
4570 -- Schords (R12 Project #6403)
4571 IF OE_SCH_CONC_REQUESTS.g_conc_program = 'Y' AND
4572 (p_line_rec.top_model_line_id = p_line_rec.ato_line_id OR
4573 (p_line_rec.ship_model_complete_flag = 'Y' AND
4574 p_line_rec.top_model_line_id IS NOT NULL))THEN
4575 IF l_debug_level > 0 THEN
4576 oe_debug_pub.add('ROLLBACK THE CHANGES ' ,2);
4577 END IF;
4578
4579 UPDATE OE_ORDER_LINES_ALL
4580 SET SCHEDULE_SHIP_DATE = p_old_line_rec.schedule_ship_date,
4581 SCHEDULE_ARRIVAL_DATE = p_old_line_rec.schedule_arrival_date,
4582 SHIP_FROM_ORG_ID = p_old_line_rec.ship_from_org_id
4583 WHERE top_model_line_id = p_line_rec.top_model_line_id;
4584 --5166476
4585 OE_SCH_CONC_REQUESTS.OE_line_status_Tbl(p_line_rec.line_id) := 'N';
4586 END IF;
4587 END IF;
4588
4589 --bug 6647169 start
4590 IF (p_line_rec.ship_from_org_id <> nvl(p_old_line_rec.ship_from_org_id,0)) THEN
4591 IF NOT Validate_Warehouse_Change
4592 ( p_line_rec => p_line_rec
4593 ,p_old_line_rec => p_old_line_rec )
4594 THEN
4595 oe_debug_pub.add('The warehouse change is invalid as the item is not shippable in new warehoues');
4596 l_return_status := FND_API.G_RET_STS_ERROR;
4597 END IF;
4598 END IF;
4599 --bug 6647169 end
4600
4601 ELSE
4602 IF l_debug_level > 0 then
4603 oe_debug_pub.add('Source Type is External',1);
4604 END IF;
4605 -- In release 12, discrete and process warehouses can also belong to any SOB.
4606 -- Bug 4190927, Validate_Item_Warehouse would be used instead of Validate_Receiving_Org
4607 -- IF NOT Validate_Receiving_Org
4608 -- (p_line_rec.inventory_item_id,
4609 -- p_line_rec.ship_from_org_id)
4610 IF NOT Validate_Item_Warehouse
4611 (p_inventory_item_id => p_line_rec.inventory_item_id,
4612 p_ship_from_org_id => p_line_rec.ship_from_org_id,
4613 p_item_type_code => l_item_type_code,
4614 p_line_id => p_line_rec.line_id,
4615 p_top_model_line_id => p_line_rec.top_model_line_id,
4616 p_source_document_type_id => p_line_rec.source_document_type_id,
4617 p_line_category_code => p_line_rec.line_category_code)
4618 THEN
4619 l_return_status := FND_API.G_RET_STS_ERROR;
4620 END IF;
4621
4622 END IF;
4623 END IF;
4624 END IF;
4625
4626 -- start decimal qty validation
4627 IF p_line_rec.inventory_item_id is not null THEN
4628 IF l_debug_level > 0 then
4629 oe_debug_pub.add('decimal1',2);
4630 END IF;
4631 IF p_line_rec.order_quantity_uom is not null THEN
4632
4633 l_line_num := RTRIM(p_line_rec.line_number || '.' ||
4634 p_line_rec.shipment_number || '.' ||
4635 p_line_rec.option_number || '.' ||
4636 p_line_rec.component_number || '.' ||
4637 p_line_rec.service_number, '.');
4638
4639 -- validate ordered quantity
4640 IF NOT OE_GLOBALS.EQUAL(p_line_rec.ordered_quantity
4641 ,p_old_line_rec.ordered_quantity)
4642 OR NOT OE_GLOBALS.EQUAL(p_line_rec.order_quantity_uom, p_old_line_rec.order_quantity_uom) --Bug 7563563
4643
4644 OR p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
4645
4646 l_ordered_quantity :=p_line_rec.ordered_quantity;
4647 /* This local var will be passed as an IN parameter below */
4648 /* l_ordered_quantity is IN and p_line_rec.ordered_quantity is OUT */
4649
4650 Validate_Decimal_Quantity
4651 (p_item_id => p_line_rec.inventory_item_id
4652 ,p_item_type_code => l_item_type_code
4653 -- ,p_input_quantity => p_line_rec.ordered_quantity no copy effect
4654 ,p_input_quantity => l_ordered_quantity
4655 ,p_uom_code => p_line_rec.order_quantity_uom
4656 -- 3718547
4657 ,p_ato_line_id => nvl(l_ato_line_id, p_line_rec.ato_line_id)
4658 ,p_line_id => nvl(l_line_id, p_line_rec.line_id)
4659 ,p_line_num => l_line_num
4660 ,x_output_quantity => p_line_rec.ordered_quantity
4661 -- 4197444
4662 ,x_return_status => l_status);
4663
4664 -- 4197444
4665 IF l_status = FND_API.G_RET_STS_ERROR THEN
4666 l_return_status := l_status;
4667 ELSIF l_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4668 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4669 END IF;
4670
4671 IF l_debug_level > 0 then
4672 oe_debug_pub.add('Ordered Qty '||p_line_rec.ordered_quantity,2);
4673 END IF;
4674
4675 END IF;
4676
4677 -- validate invoiced_quantity
4678 IF NOT OE_GLOBALS.EQUAL(p_line_rec.invoiced_quantity
4679 ,p_old_line_rec.invoiced_quantity)
4680 OR p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
4681
4682 Validate_Decimal_Quantity
4683 (p_item_id => p_line_rec.inventory_item_id
4684 ,p_item_type_code => l_item_type_code
4685 ,p_input_quantity => p_line_rec.invoiced_quantity
4686 ,p_uom_code => p_line_rec.order_quantity_uom
4687 -- 3718547
4688 ,p_ato_line_id => nvl(l_ato_line_id, p_line_rec.ato_line_id)
4689 ,p_line_id => nvl(l_line_id, p_line_rec.line_id)
4690 ,p_line_num => l_line_num
4691 ,x_output_quantity => l_rounded_qty
4692 -- 4197444
4693 ,x_return_status => l_status);
4694
4695 -- 4197444
4696 IF l_status = FND_API.G_RET_STS_ERROR THEN
4697 l_return_status := l_status;
4698 ELSIF l_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4699 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4700 END IF;
4701
4702 IF l_debug_level > 0 then
4703 oe_debug_pub.add('Invoiced Qty '||p_line_rec.invoiced_quantity,2);
4704 END IF;
4705 END IF;
4706
4707 -- cancelled quantity
4708 -- 3840386 : Condition added to validate cancel quantity
4709 -- for change in ordered quantity or create operation.
4710 -- Also x_output_quantity is assigned back to cancelled_quantity
4711 IF NOT OE_GLOBALS.EQUAL(p_line_rec.ordered_quantity
4712 ,p_old_line_rec.ordered_quantity)
4713 OR p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
4714
4715 l_cancelled_quantity :=p_line_rec.cancelled_quantity;
4716 /* This local var will be passed as an IN parameter below */
4717 /* l_ordered_quantity is IN and p_line_rec.ordered_quantity is OUT */
4718
4719 Validate_Decimal_Quantity
4720 (p_item_id => p_line_rec.inventory_item_id
4721 ,p_item_type_code => l_item_type_code
4722 -- ,p_input_quantity => p_line_rec.cancelled_quantity nocopy effect
4723 ,p_input_quantity => l_cancelled_quantity
4724 ,p_uom_code => p_line_rec.order_quantity_uom
4725 -- 3718547
4726 ,p_ato_line_id => nvl(l_ato_line_id, p_line_rec.ato_line_id)
4727 ,p_line_id => nvl(l_line_id, p_line_rec.line_id)
4728 ,p_line_num => l_line_num
4729 ,x_output_quantity => p_line_rec.cancelled_quantity --l_rounded_qty
4730 -- 4197444
4731 ,x_return_status => l_status);
4732
4733 -- 4197444
4734 IF l_status = FND_API.G_RET_STS_ERROR THEN
4735 l_return_status := l_status;
4736 ELSIF l_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4737 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4738 END IF;
4739
4740 IF l_debug_level > 0 then
4741 oe_debug_pub.add('Cancel Qty '||p_line_rec.cancelled_quantity,2);
4742 END IF;
4743 END IF;
4744 -- auto_selected quantity
4745 IF NOT OE_GLOBALS.EQUAL(p_line_rec.auto_selected_quantity
4746 ,p_old_line_rec.auto_selected_quantity)
4747 OR p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
4748
4749 Validate_Decimal_Quantity
4750 (p_item_id => p_line_rec.inventory_item_id
4751 ,p_item_type_code => l_item_type_code
4752 ,p_input_quantity => p_line_rec.auto_selected_quantity
4753 ,p_uom_code => p_line_rec.order_quantity_uom
4754 -- 3718547
4755 ,p_ato_line_id => nvl(l_ato_line_id, p_line_rec.ato_line_id)
4756 ,p_line_id => nvl(l_line_id, p_line_rec.line_id)
4757 ,p_line_num => l_line_num
4758 ,x_output_quantity => l_rounded_qty
4759 -- 4197444
4760 ,x_return_status => l_status);
4761
4762 -- 4197444
4763 IF l_status = FND_API.G_RET_STS_ERROR THEN
4764 l_return_status := l_status;
4765 ELSIF l_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4766 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4767 END IF;
4768
4769 IF l_debug_level > 0 then
4770 oe_debug_pub.add('Auto Selected Qty '||p_line_rec.auto_selected_quantity,2);
4771 END IF;
4772 END IF;
4773
4774 -- reserved quantity
4775 IF NOT OE_GLOBALS.EQUAL(p_line_rec.reserved_quantity
4776 ,p_old_line_rec.reserved_quantity)
4777 OR p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
4778
4779 Validate_Decimal_Quantity
4780 (p_item_id => p_line_rec.inventory_item_id
4781 ,p_item_type_code => l_item_type_code
4782 ,p_input_quantity => p_line_rec.reserved_quantity
4783 ,p_uom_code => p_line_rec.order_quantity_uom
4784 -- 3718547
4785 ,p_ato_line_id => nvl(l_ato_line_id, p_line_rec.ato_line_id)
4786 ,p_line_id => nvl(l_line_id, p_line_rec.line_id)
4787 ,p_line_num => l_line_num
4788 ,x_output_quantity => l_rounded_qty
4789 -- 4197444
4790 ,x_return_status => l_status);
4791
4792 -- 4197444
4793 IF l_status = FND_API.G_RET_STS_ERROR THEN
4794 l_return_status := l_status;
4795 ELSIF l_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4796 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4797 END IF;
4798
4799 IF l_debug_level > 0 then
4800 oe_debug_pub.add('Reserved Qty '||p_line_rec.reserved_quantity,2);
4801 END IF;
4802 END IF;
4803
4804
4805 -- fulfilled quantity, double check with Shashi
4806 IF NOT OE_GLOBALS.EQUAL(p_line_rec.fulfilled_quantity
4807 ,p_old_line_rec.fulfilled_quantity)
4808 OR p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
4809 Validate_Decimal_Quantity
4810 (p_item_id => p_line_rec.inventory_item_id
4811 ,p_item_type_code => l_item_type_code
4812 ,p_input_quantity => p_line_rec.fulfilled_quantity
4813 ,p_uom_code => p_line_rec.order_quantity_uom
4814 -- 3718547
4815 ,p_ato_line_id => nvl(l_ato_line_id, p_line_rec.ato_line_id)
4816 ,p_line_id => nvl(l_line_id, p_line_rec.line_id)
4817 ,p_line_num => l_line_num
4818 ,x_output_quantity => l_rounded_qty
4819 -- 4197444
4820 ,x_return_status => l_status);
4821
4822 -- 4197444
4823 IF l_status = FND_API.G_RET_STS_ERROR THEN
4824 l_return_status := l_status;
4825 ELSIF l_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4826 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4827 END IF;
4828
4829 IF l_debug_level > 0 then
4830 oe_debug_pub.add('Fulfilled Qty '||p_line_rec.fulfilled_quantity,2);
4831 END IF;
4832 END IF;
4833
4834 END IF; -- order quantity uom not null
4835
4836 -- validate pricing quantity starts here
4837 -- bug 1391668, don't need to validate pricing quantity
4838 /*
4839 IF (p_line_rec.pricing_quantity_uom is not null AND
4840 p_line_rec.pricing_quantity is not null) THEN
4841
4842 Validate_Decimal_Quantity
4843 (p_item_id => p_line_rec.inventory_item_id
4844 ,p_item_type_code => p_line_rec.item_type_code
4845 ,p_input_quantity => p_line_rec.pricing_quantity
4846 ,p_uom_code => p_line_rec.pricing_quantity_uom
4847 ,x_output_quantity => l_rounded_qty
4848 ,x_return_status => l_return_status
4849 );
4850
4851 END IF; -- quantity or uom is null
4852 */
4853 END IF; -- inventory_item_id is null
4854 -- end decimal quantity validation
4855
4856 -- Check to see if the user has changed both the Schedule Ship Date
4857 -- and Schedule Arrival Date. This is not allowed. The user can change
4858 -- either one, but not both.
4859
4860 /*
4861 IF (NOT OE_GLOBALS.Equal(p_line_rec.schedule_ship_date,
4862 p_old_line_rec.schedule_ship_date)) AND
4863 (NOT OE_GLOBALS.Equal(p_line_rec.schedule_arrival_date,
4864 p_old_line_rec.schedule_arrival_date)) AND
4865 (OE_ORDER_SCH_UTIL.OESCH_PERFORM_SCHEDULING = 'Y') THEN
4866
4867 -- Config item is created and passed by the CTO team. So this is
4868 -- is the only item type, which when gets created, already has
4869 -- Schedule_Ship_Date and schedule_Arrival_date. We should not
4870 -- error out for this item.
4871
4872 IF p_line_rec.item_type_code <> OE_GLOBALS.G_ITEM_CONFIG THEN
4873 FND_MESSAGE.SET_NAME('ONT','OE_SCH_INVALID_CHANGE');
4874 OE_MSG_PUB.Add;
4875 l_return_status := FND_API.G_RET_STS_ERROR;
4876 END IF;
4877
4878 END IF;
4879 */
4880
4881 Validate_Source_Type
4882 ( p_line_rec => p_line_rec
4883 ,p_old_line_rec => p_old_line_rec
4884 ,x_return_status => l_status);
4885
4886 IF l_status = FND_API.G_RET_STS_ERROR THEN
4887 l_return_status := FND_API.G_RET_STS_ERROR;
4888 END IF;
4889
4890 -- PJM validation.
4891
4892 IF PJM_UNIT_EFF.ENABLED = 'Y' THEN
4893 /* Added the below IF clause for bug 6243026.
4894 The Project / Task / End Item Unit Number validation should happen
4895 only when one of the below attributes change */
4896 IF (NOT OE_GLOBALS.Equal(p_line_rec.project_id, p_old_line_rec.project_id)) Or
4897 (NOT OE_GLOBALS.Equal(p_line_rec.task_id, p_old_line_rec.task_id)) Or
4898 (NOT OE_GLOBALS.Equal(p_line_rec.inventory_item_id, p_old_line_rec.inventory_item_id)) or
4899 (NOT OE_GLOBALS.Equal(p_line_rec.ship_from_org_id, p_old_line_rec.ship_from_org_id)) or
4900 (NOT OE_GLOBALS.Equal(p_line_rec.request_date, p_old_line_rec.request_date)) or
4901 (NOT OE_GLOBALS.Equal(p_line_rec.schedule_ship_date, p_old_line_rec.schedule_ship_date)) or
4902 (NOT OE_GLOBALS.Equal(p_line_rec.schedule_arrival_date, p_old_line_rec.schedule_arrival_date)) or
4903 (NOT OE_GLOBALS.Equal(p_line_rec.end_item_unit_number, p_old_line_rec.end_item_unit_number))
4904 THEN
4905
4906 IF (p_line_rec.project_id IS NOT NULL
4907 AND p_line_rec.ship_from_org_id IS NULL) THEN
4908
4909 l_return_status := FND_API.G_RET_STS_ERROR;
4910 FND_MESSAGE.SET_NAME('ONT', 'OE_SHIP_FROM_REQD');
4911 OE_MSG_PUB.add;
4912 ELSIF (p_line_rec.task_id IS NOT NULL AND
4913 p_line_rec.project_id IS NULL) THEN
4914
4915 l_return_status := FND_API.G_RET_STS_ERROR;
4916 FND_MESSAGE.SET_NAME('ONT', 'OE_VAL_PROJECT_REQD');
4917 OE_MSG_PUB.add;
4918 END IF;
4919
4920 -- Added Code for Enhanced Project Validation and Controls.
4921
4922 l_order_date_type_code := NVL(OE_SCHEDULE_UTIL.Get_Date_Type(
4923 p_line_rec.header_id), 'SHIP');
4924
4925
4926 IF l_order_date_type_code = 'SHIP' THEN
4927 p_date := NVL(p_line_rec.schedule_ship_date,
4928 p_line_rec.request_date);
4929 ELSIF l_order_date_type_code = 'ARRIVAL' THEN
4930 p_date := NVL(p_line_rec.schedule_arrival_date,
4931 p_line_rec.request_date);
4932 END IF;
4933 IF l_debug_level > 0 then
4934 OE_DEBUG_PUB.Add('Before calling Validate Proj References',1);
4935 END IF;
4936
4937 result := PJM_PROJECT.VALIDATE_PROJ_REFERENCES
4938 ( X_inventory_org_id => p_line_rec.ship_from_org_id
4939 , X_operating_unit => p_line_rec.org_id
4940 , X_project_id => p_line_rec.project_id
4941 , X_task_id => p_line_rec.task_id
4942 , X_date1 => p_date
4943 , X_date2 => NULL
4944 , X_calling_function =>'OEXOEORD'
4945 , X_error_code => errcode
4946 );
4947 IF l_debug_level > 0 then
4948 OE_DEBUG_PUB.Add('Validate Proj References Error:'||
4949 errcode,1);
4950 OE_DEBUG_PUB.Add('Validate Proj References Result:'||
4951 result,1);
4952 END IF;
4953 IF result <> PJM_PROJECT.G_VALIDATE_SUCCESS THEN
4954 OE_MSG_PUB.Transfer_Msg_Stack;
4955 l_msg_count:=OE_MSG_PUB.COUNT_MSG;
4956 FOR I in 1..l_msg_count loop
4957 l_msg_data := OE_MSG_PUB.Get(I,'F');
4958 IF l_debug_level > 0 then
4959 OE_DEBUG_PUB.add(l_msg_data,1);
4960 END IF;
4961 END LOOP;
4962 END IF;
4963
4964 IF result = PJM_PROJECT.G_VALIDATE_FAILURE THEN
4965 l_return_status := FND_API.G_RET_STS_ERROR;
4966 IF l_debug_level > 0 then
4967 OE_DEBUG_PUB.Add('PJM Validation API returned with Errors',1);
4968 END IF;
4969 ELSIF result = PJM_PROJECT.G_VALIDATE_WARNING THEN
4970 IF l_debug_level > 0 then
4971 OE_DEBUG_PUB.Add('PJM Validation API returned with Warnings',1);
4972 END IF;
4973 END IF;
4974
4975
4976
4977 /* -- Code Commented for Enhanced Project Validation and Controls.
4978
4979 ELSIF ((NOT OE_GLOBALS.Equal(p_line_rec.ship_from_org_id,
4980 p_old_line_rec.ship_from_org_id)) OR
4981 (NOT OE_GLOBALS.Equal(p_line_rec.project_id,
4982 p_old_line_rec.project_id)))
4983 AND (p_line_rec.ship_from_org_id IS NOT NULL AND
4984 p_line_rec.project_id IS NOT NULL) THEN
4985
4986 -- Validate project/warehouse combination.
4987 IF pjm_project.val_proj_idtonum
4988 (p_line_rec.project_id,
4989 p_line_rec.ship_from_org_id) IS NULL THEN
4990
4991 l_return_status := FND_API.G_RET_STS_ERROR;
4992 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_SHIP_FROM_PROJ');
4993 OE_MSG_PUB.add;
4994 END IF;
4995
4996 END IF;
4997
4998 IF (p_line_rec.task_id IS NOT NULL
4999 AND p_line_rec.project_id IS NULL) THEN
5000
5001 l_return_status := FND_API.G_RET_STS_ERROR;
5002 FND_MESSAGE.SET_NAME('ONT', 'OE_VAL_PROJECT_REQD');
5003 OE_MSG_PUB.add;
5004
5005 ELSIF (p_line_rec.task_id is NOT NULL
5006 AND p_line_rec.project_id IS NOT NULL) THEN
5007
5008 IF NOT Validate_task(
5009 p_line_rec.project_id,
5010 p_line_rec.task_id) THEN
5011
5012 l_return_status := FND_API.G_RET_STS_ERROR;
5013 OE_MSG_PUB.Update_Msg_Context(p_attribute_code => 'TASK_ID');
5014 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
5015 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
5016 OE_Order_Util.Get_Attribute_Name('task_id'));
5017 OE_MSG_PUB.Add;
5018 OE_MSG_PUB.Update_Msg_Context(p_attribute_code => null);
5019
5020 END IF;
5021
5022 ELSIF (p_line_rec.task_id is NULL
5023 AND p_line_rec.project_id IS NOT NULL) THEN
5024
5025 IF Validate_task_reqd(
5026 p_line_rec.project_id,
5027 p_line_rec.ship_from_org_id) THEN
5028
5029 l_return_status := FND_API.G_RET_STS_ERROR;
5030 FND_MESSAGE.SET_NAME('ONT', 'OE_VAL_TASK_REQD');
5031 OE_MSG_PUB.ADD;
5032
5033 END IF;
5034
5035 END IF;
5036 */
5037
5038 -- End Item Unit number logic.
5039 IF l_debug_level > 0 then
5040 oe_debug_pub.add('10 '||l_return_status, 1);
5041 END IF;
5042 IF (p_line_rec.inventory_item_id IS NOT NULL) AND
5043 (p_line_rec.ship_from_org_id IS NOT NULL) AND
5044 (p_line_rec.end_item_unit_number IS NULL) THEN
5045
5046 IF PJM_UNIT_EFF.UNIT_EFFECTIVE_ITEM
5047 (p_line_rec.inventory_item_id,p_line_rec.ship_from_org_id) = 'Y'
5048 THEN
5049
5050 l_return_status := FND_API.G_RET_STS_ERROR;
5051 fnd_message.set_name('ONT', 'OE_UEFF_NUMBER_REQD');
5052 OE_MSG_PUB.add;
5053 END IF;
5054
5055 END IF;
5056 END IF; -- Added for bug 6243026
5057 ELSE -- When project manufacturing is not enabled at the site.
5058
5059 IF (NOT OE_GLOBALS.Equal(p_line_rec.project_id,
5060 p_old_line_rec.project_id)) Or
5061 (NOT OE_GLOBALS.Equal(p_line_rec.task_id,
5062 p_old_line_rec.task_id)) Or
5063 (NOT OE_GLOBALS.Equal(p_line_rec.end_item_unit_number,
5064 p_old_line_rec.end_item_unit_number))
5065 THEN
5066
5067 l_return_status := FND_API.G_RET_STS_ERROR;
5068 fnd_message.set_name('ONT', 'OE_PJM_NOT_INSTALLED');
5069 OE_MSG_PUB.add;
5070
5071 END IF;
5072
5073
5074 END IF; --End if PJM_UNIT_EFF.ENABLED
5075
5076 -- Donot allow to update project and task when a option/class is under ATO
5077 -- Model.
5078 IF l_debug_level > 0 then
5079 oe_debug_pub.add('11 '||l_return_status, 1);
5080 END IF;
5081 IF p_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
5082
5083 IF (p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION OR
5084 p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
5085 p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CONFIG) AND
5086 OE_Config_Util.CASCADE_CHANGES_FLAG = 'N' AND
5087 p_line_rec.line_id <> p_line_rec.ato_line_id THEN
5088
5089 IF (NOT OE_GLOBALS.EQUAL(p_line_rec.project_id,
5090 p_old_line_rec.project_id)) THEN
5091 l_return_status := FND_API.G_RET_STS_ERROR;
5092 FND_MESSAGE.SET_NAME('ONT', 'OE_VAL_PROJ_UPD');
5093 OE_MSG_PUB.add;
5094 ELSIF (NOT OE_GLOBALS.EQUAL(p_line_rec.task_id,
5095 p_old_line_rec.task_id)) THEN
5096 l_return_status := FND_API.G_RET_STS_ERROR;
5097 FND_MESSAGE.SET_NAME('ONT', 'OE_VAL_TASK_UPD');
5098 OE_MSG_PUB.add;
5099 END IF;
5100
5101 END IF;
5102
5103 END IF;
5104 -- End of PJM validation.
5105
5106
5107 -- Validate if item, item_identifier_type, inventory_item combination is valid
5108 IF l_debug_level > 0 then
5109 oe_debug_pub.add('12-1 '||l_return_status, 1);
5110 END IF;
5111 IF p_line_rec.inventory_item_id IS NOT NULL AND
5112 p_line_rec.inventory_item_id <> nvl(p_old_line_rec.inventory_item_id,0) OR
5113 NVL(p_line_rec.item_identifier_type, 'INT') <> NVL(p_old_line_rec.item_identifier_type, 'INT') OR
5114 p_line_rec.ordered_item_id <> nvl(p_old_line_rec.ordered_item_id, 0) OR
5115 p_line_rec.ordered_item <> p_old_line_rec.ordered_item OR
5116 p_line_rec.sold_to_org_id <> nvl(p_old_line_rec.sold_to_org_id, 0) THEN
5117
5118 IF NOT Validate_Item_Fields
5119 ( p_line_rec.inventory_item_id
5120 , p_line_rec.ordered_item_id
5121 , p_line_rec.item_identifier_type
5122 , p_line_rec.ordered_item
5123 , p_line_rec.sold_to_org_id
5124 , p_line_rec.line_category_code /* Bug1678296 chhung modify */
5125 , p_line_rec.item_type_code /* Bug1741158- chhung adds */
5126 , p_line_rec.line_id /* Bug1741158- chhung adds */
5127 , p_line_rec.top_model_line_id /* Bug1741158- chhung adds */
5128 , p_line_rec.source_document_type_id /* Bug1741158- chhung adds */
5129 , p_line_rec.operation /*Bug 1805985 add*/
5130 )
5131 THEN
5132 l_return_status := FND_API.G_RET_STS_ERROR;
5133 fnd_message.set_name('ONT', 'OE_ITEM_VALIDATION_FAILED');
5134 OE_MSG_PUB.add;
5135 END IF;
5136
5137 END IF;
5138 IF l_debug_level > 0 then
5139 oe_debug_pub.add('12 '||l_return_status, 1);
5140 END IF;
5141
5142
5143 --Added for Item Orderability feature
5144 -- Validate Item Orderability Rules
5145 IF (p_line_rec.inventory_item_id IS NOT NULL
5146 and ( NVL(p_line_rec.item_type_code,OE_GLOBALS.G_ITEM_STANDARD) = OE_GLOBALS.G_ITEM_STANDARD
5147 OR p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL )) then
5148
5149 IF NOT OE_ITORD_UTIL.Validate_Item_Orderability(p_line_rec) then
5150 l_return_status := FND_API.G_RET_STS_ERROR;
5151 fnd_message.set_name('ONT', 'OE_ITORD_VALIDATION_FAILED');
5152 fnd_message.set_token('ITEM',OE_ITORD_UTIL.get_item_name(p_line_rec.inventory_item_id));
5153 fnd_message.set_token('CATEGORY',OE_ITORD_UTIL.get_item_category_name(p_line_rec.inventory_item_id));
5154 OE_MSG_PUB.add;
5155 END IF;
5156 END IF;
5157
5158 IF l_debug_level > 0 then
5159 oe_debug_pub.add('Item Orderability Validation Result : '||l_return_status, 1);
5160 END IF;
5161
5162
5163 -- Validate if return item and item on referenced sales order line mismatch
5164 IF (p_line_rec.line_category_code = OE_GLOBALS.G_RETURN_CATEGORY_CODE and
5165 p_line_rec.reference_line_id is not null and
5166 p_line_rec.inventory_item_id IS NOT NULL and
5167 p_line_rec.inventory_item_id <> nvl(p_old_line_rec.inventory_item_id
5168 ,-99))
5169 THEN
5170 IF NOT Validate_Return_Item_Mismatch
5171 ( p_line_rec.reference_line_id
5172 , p_line_rec.inventory_item_id
5173 )
5174 THEN
5175 l_return_status := FND_API.G_RET_STS_ERROR;
5176 fnd_message.set_name('ONT', 'OE_RETURN_ITEM_MISMATCH_REJECT');
5177 OE_MSG_PUB.add;
5178 END IF;
5179 END IF;
5180 IF l_debug_level > 0 then
5181 oe_debug_pub.add('13 '||l_return_status, 1);
5182 END IF;
5183
5184 -- Validate if returning a fulfilled sales order line
5185 IF (p_line_rec.line_category_code = OE_GLOBALS.G_RETURN_CATEGORY_CODE and
5186 p_line_rec.reference_line_id is not null and
5187 p_line_rec.reference_line_id <> nvl(p_old_line_rec.reference_line_id
5188 ,-99))
5189 THEN
5190 IF NOT Validate_Return_Fulfilled_Line
5191 ( p_line_rec.reference_line_id
5192 )
5193 THEN
5194 l_return_status := FND_API.G_RET_STS_ERROR;
5195 fnd_message.set_name('ONT', 'OE_UNFULFILLED_LINE_REJECT');
5196 OE_MSG_PUB.add;
5197 END IF;
5198
5199 END IF;
5200 IF l_debug_level > 0 then
5201 oe_debug_pub.add('14 '||l_return_status, 1);
5202 END IF;
5203
5204 -- Validate if item on the Return is Returnable
5205 IF (p_line_rec.line_category_code = OE_GLOBALS.G_RETURN_CATEGORY_CODE and
5206 p_line_rec.inventory_item_id IS NOT NULL and
5207 p_line_rec.inventory_item_id <> nvl(p_old_line_rec.inventory_item_id
5208 ,-99))
5209 THEN
5210 Validate_Return_Item(p_line_rec.inventory_item_id,
5211 p_line_rec.ship_from_org_id,
5212 l_status);
5213 IF l_status <> FND_API.G_RET_STS_SUCCESS THEN
5214 IF l_debug_level > 0 then
5215 oe_debug_pub.add('Validate_Return_Item error '||l_status, 3);
5216 END IF;
5217 l_return_status := l_status;
5218 END IF;
5219
5220 END IF;
5221
5222 IF l_debug_level > 0 then
5223 oe_debug_pub.add('14_1 '||l_return_status, 1);
5224 END IF;
5225
5226 --bug 5898152
5227 IF p_line_rec.line_category_code = OE_GLOBALS.G_RETURN_CATEGORY_CODE and
5228 p_line_rec.reference_line_id is not null and
5229 p_line_rec.reference_line_id <> fnd_api.g_miss_num AND
5230 --p_line_rec.tax_code is NOT NULL AND commented this condition for bug 5990058
5231 p_line_rec.return_context = 'ORDER'
5232 THEN
5233 IF NOT Validate_Return_Reference_Tax(p_line_rec.reference_line_id,p_line_rec.tax_code) THEN
5234 l_return_status := FND_API.G_RET_STS_ERROR;
5235 END IF;
5236 END IF;
5237
5238 -- Validate if Reference SO Line is Valid
5239 IF p_line_rec.line_category_code = OE_GLOBALS.G_RETURN_CATEGORY_CODE and
5240 p_line_rec.reference_line_id is not null and
5241 (p_line_rec.reference_line_id <> nvl(p_old_line_rec.reference_line_id,-99)
5242 OR NOT OE_GLOBALS.equal(p_line_rec.order_quantity_uom,p_old_line_rec.order_quantity_uom ))
5243 THEN
5244 IF NOT Validate_Return_Reference(p_line_rec.reference_line_id,
5245 p_line_rec.ORDER_QUANTITY_UOM)
5246 THEN
5247 -- Message is populated in the function
5248 l_return_status := FND_API.G_RET_STS_ERROR;
5249 END IF;
5250 END IF;
5251 IF l_debug_level > 0 then
5252 oe_debug_pub.add('14_2 '||l_return_status, 1);
5253 END IF;
5254
5255 -- Fix Bug # 2791253: Check if SO Line is being referenced by RMA(s)
5256 IF p_line_rec.line_category_code = 'ORDER' AND
5257 (p_line_rec.ordered_quantity <> nvl(p_old_line_rec.ordered_quantity,-99))
5258 THEN
5259 IF NOT Validate_Return_Existence(p_line_rec.line_id,
5260 p_line_rec.ordered_quantity)
5261 THEN
5262 -- Message is populated in the function
5263 l_return_status := FND_API.G_RET_STS_ERROR;
5264 END IF;
5265 END IF;
5266 IF l_debug_level > 0 then
5267 oe_debug_pub.add('14_2_1'||l_return_status, 1);
5268 END IF;
5269
5270 -- Validate the quantity = 1 on RMA for Serial Number reference
5271 IF (p_line_rec.line_category_code = OE_GLOBALS.G_RETURN_CATEGORY_CODE and
5272 p_line_rec.reference_line_id is not null and
5273 p_line_rec.return_context = 'SERIAL' and
5274 p_line_rec.cancelled_flag <> 'Y' and
5275 NVL(p_line_rec.ordered_quantity,1) <> 1)
5276 THEN
5277 l_return_status := FND_API.G_RET_STS_ERROR;
5278 fnd_message.set_name('ONT','OE_SERIAL_REFERENCED_RMA');
5279 OE_MSG_PUB.Add;
5280 END IF;
5281
5282 IF l_debug_level > 0 then
5283 oe_debug_pub.add('14_3 '||l_return_status, 1);
5284 END IF;
5285
5286 -- Validation of Ship To Org Id.
5287 IF p_line_rec.ship_to_org_id IS NOT NULL
5288 AND NOT (l_header_created AND OE_GLOBALS.EQUAL
5289 (OE_Order_Cache.g_header_rec.ship_to_org_id,p_line_rec.ship_to_org_id))
5290 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.ship_to_org_id
5291 ,p_old_line_rec.ship_to_org_id)
5292 OR NOT OE_GLOBALS.EQUAL(p_line_rec.sold_to_org_id
5293 ,p_old_line_rec.sold_to_org_id))
5294 THEN
5295
5296 IF NOT Validate_Ship_To_Org(p_line_rec.ship_to_org_id,
5297 p_line_rec.sold_to_org_id
5298 )
5299 THEN
5300 IF G_REF_RMA = 'Y' THEN
5301 p_line_rec.ship_to_org_id := NULL;
5302 l_old_line_rec.ship_to_org_id := NULL;
5303 if l_debug_level > 0 then
5304 OE_DEBUG_PUB.Add('Setting ship_to_org_id to NULL',1);
5305 end if;
5306 ELSE
5307
5308 l_return_status := FND_API.G_RET_STS_ERROR;
5309 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
5310 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
5311 OE_Order_Util.Get_Attribute_Name('ship_to_org_id'));
5312 OE_MSG_PUB.Add;
5313 END IF;
5314 END IF;
5315
5316 END IF;
5317
5318
5319 -- Ship to contact depends on Ship To Org
5320 IF p_line_rec.ship_to_contact_id IS NOT NULL
5321 AND NOT (l_header_created
5322 AND OE_GLOBALS.EQUAL(OE_Order_Cache.g_header_rec.ship_to_contact_id, p_line_rec.ship_to_contact_id)
5323 AND OE_GLOBALS.EQUAL(OE_Order_Cache.g_header_rec.ship_to_org_id,p_line_rec.ship_to_org_id))
5324 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.ship_to_contact_id,p_old_line_rec.ship_to_contact_id)
5325 OR NOT OE_GLOBALS.EQUAL(p_line_rec.ship_to_org_id,p_old_line_rec.ship_to_org_id))
5326 --Bug 5679739 AND OE_GLOBALS.EQUAL(OE_Order_Cache.g_header_rec.ship_to_org_id,p_line_rec.ship_to_org_id)
5327 THEN
5328
5329 BEGIN
5330 IF l_debug_level > 0 then
5331 oe_debug_pub.add('ship_to_contact_id :'||to_char(p_line_rec.ship_to_contact_id),2);
5332 END IF;
5333
5334 SELECT /* MOAC_SQL_CHANGE */ 'VALID'
5335 INTO l_dummy
5336 FROM
5337 HZ_CUST_ACCOUNT_ROLES ACCT_ROLE,
5338 HZ_CUST_SITE_USES_ALL SITE_USE, --changed SHIP to SITE_USE for bug 3739650
5339 HZ_CUST_ACCT_SITES ADDR
5340 WHERE
5341 ACCT_ROLE.CUST_ACCOUNT_ROLE_ID = p_line_rec.ship_to_contact_id
5342 AND ACCT_ROLE.CUST_ACCOUNT_ID = ADDR.CUST_ACCOUNT_ID
5343 AND ACCT_ROLE.ROLE_TYPE = 'CONTACT'
5344 AND ADDR.CUST_ACCT_SITE_ID = SITE_USE.CUST_ACCT_SITE_ID
5345 AND SITE_USE.SITE_USE_ID = p_line_rec.ship_to_org_id
5346 AND SITE_USE.STATUS = 'A'
5347 AND ADDR.STATUS ='A' --bug 2752321
5348 AND ACCT_ROLE.STATUS = 'A'
5349 AND ROWNUM = 1;
5350
5351 EXCEPTION
5352 WHEN NO_DATA_FOUND THEN
5353 IF G_REF_RMA = 'Y' THEN
5354 p_line_rec.ship_to_contact_id := NULL;
5355 l_old_line_rec.ship_to_contact_id := NULL;
5356 if l_debug_level > 0 then
5357 OE_DEBUG_PUB.Add('Setting ship_to_contact_id to NULL',1);
5358 end if;
5359 ELSE
5360 l_return_status := FND_API.G_RET_STS_ERROR;
5361 FND_MESSAGE.SET_NAME('ONT','OE_INVALID_ATTRIBUTE');
5362 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
5363 OE_Order_Util.Get_Attribute_Name('ship_to_contact_id'));
5364 OE_MSG_PUB.Add;
5365 END IF;
5366 WHEN OTHERS THEN
5367 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
5368 OE_MSG_PUB.Add_Exc_Msg
5369 ( G_PKG_NAME ,
5370 'Record - Ship To Contact validation '
5371 );
5372 END IF;
5373 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5374 END;
5375
5376 END IF;
5377
5378
5379 -- Validation of Deliver To Org Id.
5380 IF p_line_rec.deliver_to_org_id IS NOT NULL
5381 AND NOT (l_header_created AND OE_GLOBALS.EQUAL
5382 (OE_Order_Cache.g_header_rec.deliver_to_org_id,
5383 p_line_rec.deliver_to_org_id))
5384 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.deliver_to_org_id
5385 ,p_old_line_rec.deliver_to_org_id)
5386 OR NOT OE_GLOBALS.EQUAL(p_line_rec.sold_to_org_id
5387 ,p_old_line_rec.sold_to_org_id))
5388 THEN
5389
5390 IF NOT Validate_Deliver_To_Org(p_line_rec.deliver_to_org_id,
5391 p_line_rec.sold_to_org_id
5392 ) THEN
5393 IF G_REF_RMA = 'Y' THEN
5394 p_line_rec.deliver_to_org_id := NULL;
5395 l_old_line_rec.deliver_to_org_id := NULL;
5396 if l_debug_level > 0 then
5397 OE_DEBUG_PUB.Add('Setting deliver_to_org_id to NULL',1);
5398 end if;
5399 ELSE
5400 l_return_status := FND_API.G_RET_STS_ERROR;
5401 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
5402 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
5403 OE_Order_Util.Get_Attribute_Name('deliver_to_org_id'));
5404 OE_MSG_PUB.Add;
5405 END IF;
5406 END IF;
5407
5408 END IF;
5409
5410 -- Deliver to contact depends on Deliver To Org
5411 IF p_line_rec.deliver_to_contact_id IS NOT NULL
5412 AND NOT (l_header_created AND OE_GLOBALS.EQUAL
5413 (OE_Order_Cache.g_header_rec.deliver_to_org_id,
5414 p_line_rec.deliver_to_org_id) AND OE_GLOBALS.EQUAL
5415 (OE_Order_Cache.g_header_rec.deliver_to_contact_id,
5416 p_line_rec.deliver_to_contact_id))
5417 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.deliver_to_contact_id
5418 ,p_old_line_rec.deliver_to_contact_id)
5419 OR NOT OE_GLOBALS.EQUAL(p_line_rec.deliver_to_org_id
5420 ,p_old_line_rec.deliver_to_org_id))
5421 THEN
5422
5423 BEGIN
5424 IF l_debug_level > 0 then
5425 oe_debug_pub.add('deliver_to_contact_id :'||to_char(p_line_rec.deliver_to_contact_id),2);
5426 END IF;
5427
5428 SELECT /* MOAC_SQL_CHANGE */ 'VALID'
5429 INTO l_dummy
5430 FROM
5431 HZ_CUST_ACCOUNT_ROLES ACCT_ROLE,
5432 HZ_CUST_SITE_USES_ALL SITE_USE, --changed INV to SITE_USE for bug 3739650
5433 HZ_CUST_ACCT_SITES ADDR
5434 WHERE
5435 ACCT_ROLE.CUST_ACCOUNT_ROLE_ID = p_line_rec.deliver_to_contact_id
5436 AND ACCT_ROLE.CUST_ACCOUNT_ID = ADDR.CUST_ACCOUNT_ID
5437 AND ACCT_ROLE.ROLE_TYPE = 'CONTACT'
5438 AND ADDR.CUST_ACCT_SITE_ID = SITE_USE.CUST_ACCT_SITE_ID
5439 AND SITE_USE.SITE_USE_ID = p_line_rec.deliver_to_org_id
5440 AND SITE_USE.STATUS = 'A'
5441 AND ADDR.STATUS ='A' --bug 2752321
5442 AND ACCT_ROLE.STATUS = 'A'
5443 AND ROWNUM = 1;
5444
5445 EXCEPTION
5446 WHEN NO_DATA_FOUND THEN
5447 IF G_REF_RMA = 'Y' THEN
5448 p_line_rec.deliver_to_contact_id := NULL;
5449 l_old_line_rec.deliver_to_contact_id := NULL;
5450 if l_debug_level > 0 then
5451 OE_DEBUG_PUB.Add('Setting deliver_to_contact_id to NULL',1);
5452 end if;
5453 ELSE
5454 l_return_status := FND_API.G_RET_STS_ERROR;
5455 FND_MESSAGE.SET_NAME('ONT','OE_INVALID_ATTRIBUTE');
5456 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
5457 OE_Order_Util.Get_Attribute_Name('deliver_to_contact_id'));
5458 OE_MSG_PUB.Add;
5459 END IF;
5460 WHEN OTHERS THEN
5461 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
5462 OE_MSG_PUB.Add_Exc_Msg
5463 ( G_PKG_NAME ,
5464 'Record - Deliver To Contact validation '
5465 );
5466 END IF;
5467 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5468 END;
5469
5470 END IF;
5471
5472 -- Validation of Invoice To Org Id.
5473 IF p_line_rec.invoice_to_org_id IS NOT NULL
5474 AND NOT (l_header_created AND OE_GLOBALS.EQUAL
5475 (OE_Order_Cache.g_header_rec.invoice_to_org_id,
5476 p_line_rec.invoice_to_org_id))
5477 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.invoice_to_org_id
5478 ,p_old_line_rec.invoice_to_org_id)
5479 OR NOT OE_GLOBALS.EQUAL(p_line_rec.sold_to_org_id
5480 ,p_old_line_rec.sold_to_org_id))
5481 THEN
5482
5483 BEGIN
5484 IF l_debug_level > 0 then
5485 oe_debug_pub.add('invoice_to_org_id :'||to_char(p_line_rec.invoice_to_org_id),2);
5486 END IF;
5487 --lcustomer_relations := FND_PROFILE.VALUE('ONT_CUSTOMER_RELATIONSHIPS');
5488
5489 IF nvl(lcustomer_relations,'N') = 'N' THEN
5490
5491 Select 'VALID'
5492 Into l_dummy
5493 From oe_invoice_to_orgs_v
5494 Where customer_id = p_line_rec.sold_to_org_id
5495 And site_use_id = p_line_rec.invoice_to_org_id
5496 and status='A'
5497 and address_status ='A';--bug 2752321
5498
5499 ELSIF lcustomer_relations = 'Y' THEN
5500 IF l_debug_level > 0 then
5501 oe_debug_pub.add('Cr: Yes Line Inv',2);
5502 END IF;
5503 --variable added for bug 3739650
5504 l_site_use_code := 'BILL_TO' ;
5505 SELECT /* MOAC_SQL_CHANGE */ 'VALID'
5506 Into l_dummy
5507 FROM HZ_CUST_SITE_USES_ALL SITE,
5508 HZ_CUST_ACCT_SITES ACCT_SITE
5509 WHERE SITE.SITE_USE_ID = p_line_rec.invoice_to_org_id
5510 AND SITE.SITE_USE_CODE = l_site_use_code
5511 AND SITE.CUST_ACCT_SITE_ID = ACCT_SITE.CUST_ACCT_SITE_ID
5512 AND SITE.STATUS = 'A'
5513 AND ACCT_SITE.STATUS ='A' AND --bug 2752321
5514 ACCT_SITE.CUST_ACCOUNT_ID in (
5515 SELECT p_line_rec.sold_to_org_id FROM DUAL
5516 UNION
5517 SELECT CUST_ACCOUNT_ID FROM
5518 HZ_CUST_ACCT_RELATE_ALL h WHERE
5519 RELATED_CUST_ACCOUNT_ID = p_line_rec.sold_to_org_id
5520 and h.org_id=acct_site.org_id
5521 and bill_to_flag = 'Y' and status='A')
5522 --bug 4205113
5523 AND EXISTS(SELECT 1 FROM HZ_CUST_ACCOUNTS WHERE CUST_ACCOUNT_ID = ACCT_SITE.CUST_ACCOUNT_ID AND STATUS='A')
5524 AND ROWNUM = 1;
5525 END IF;
5526
5527 EXCEPTION
5528 WHEN NO_DATA_FOUND THEN
5529 IF G_REF_RMA = 'Y' THEN
5530 G_REDEFAULT_MISSING := 'Y';
5531 -- Check if l_old_line_rec has already got populated
5532 IF l_old_line_rec.invoice_to_org_id IS NULL THEN
5533 l_old_line_rec := p_line_rec;
5534 if l_debug_level > 0 then
5535 OE_DEBUG_PUB.Add('Setting l_old_line_rec',1);
5536 end if;
5537 END IF;
5538 -- set invoice_to_org_id to G_MISS_NUM so that it gets
5539 -- re-defaulted.
5540 p_line_rec.invoice_to_org_id := FND_API.G_MISS_NUM;
5541 p_line_rec.invoice_to_contact_id := FND_API.G_MISS_NUM;
5542 if l_debug_level > 0 then
5543 OE_DEBUG_PUB.Add('Setting invoice_to_org_id to MISSING',1);
5544 end if;
5545 ELSE
5546 l_return_status := FND_API.G_RET_STS_ERROR;
5547 FND_MESSAGE.SET_NAME('ONT','OE_INVALID_ATTRIBUTE');
5548 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
5549 OE_Order_Util.Get_Attribute_Name('invoice_to_org_id'));
5550 OE_MSG_PUB.Add;
5551 END IF;
5552 WHEN OTHERS THEN
5553 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
5554 OE_MSG_PUB.Add_Exc_Msg
5555 ( G_PKG_NAME ,
5556 'Record - Invoice To Org validation '
5557 );
5558 END IF;
5559 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5560 END;
5561
5562 END IF;
5563
5564 -- Validation of Invoice To Contact Id.
5565 IF p_line_rec.invoice_to_contact_id IS NOT NULL
5566 AND p_line_rec.invoice_to_contact_id <> FND_API.G_MISS_NUM
5567 AND NOT (l_header_created AND OE_GLOBALS.EQUAL
5568 (OE_Order_Cache.g_header_rec.invoice_to_contact_id,
5569 p_line_rec.invoice_to_contact_id))
5570 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.invoice_to_contact_id
5571 ,p_old_line_rec.invoice_to_contact_id)
5572 OR NOT OE_GLOBALS.EQUAL(p_line_rec.invoice_to_org_id
5573 ,p_old_line_rec.invoice_to_org_id))
5574 THEN
5575
5576 BEGIN
5577 IF l_debug_level > 0 then
5578 oe_debug_pub.add('invoice_to_contact_id :'||to_char(p_line_rec.invoice_to_contact_id),2);
5579 END IF;
5580
5581 SELECT 'VALID'
5582 INTO l_dummy
5583 FROM
5584 HZ_CUST_ACCOUNT_ROLES ACCT_ROLE,
5585 HZ_CUST_SITE_USES_ALL SITE_USE, --changed INV to SITE_USE for bug 3739650
5586 HZ_CUST_ACCT_SITES_ALL ADDR
5587 WHERE
5588 ACCT_ROLE.CUST_ACCOUNT_ROLE_ID = p_line_rec.invoice_to_contact_id
5589 AND ACCT_ROLE.CUST_ACCOUNT_ID = ADDR.CUST_ACCOUNT_ID
5590 AND ACCT_ROLE.ROLE_TYPE = 'CONTACT'
5591 AND ADDR.CUST_ACCT_SITE_ID = SITE_USE.CUST_ACCT_SITE_ID
5592 AND SITE_USE.SITE_USE_ID = p_line_rec.invoice_to_org_id
5593 AND SITE_USE.STATUS = 'A'
5594 AND ADDR.STATUS ='A' --bug 2752321
5595 AND ACCT_ROLE.STATUS = 'A'
5596 AND ROWNUM = 1;
5597
5598 EXCEPTION
5599 WHEN NO_DATA_FOUND THEN
5600 IF G_REF_RMA = 'Y' THEN
5601 p_line_rec.invoice_to_contact_id := NULL;
5602 l_old_line_rec.invoice_to_contact_id := NULL;
5603 if l_debug_level > 0 then
5604 OE_DEBUG_PUB.Add('Setting invoice_to_contact_id to NULL',1);
5605 end if;
5606 ELSE
5607 l_return_status := FND_API.G_RET_STS_ERROR;
5608 FND_MESSAGE.SET_NAME('ONT','OE_INVALID_ATTRIBUTE');
5609 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
5610 OE_Order_Util.Get_Attribute_Name('invoice_to_contact_id'));
5611 OE_MSG_PUB.Add;
5612 END IF;
5613 WHEN OTHERS THEN
5614 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
5615 OE_MSG_PUB.Add_Exc_Msg
5616 ( G_PKG_NAME ,
5617 'Record - Invoice To Contact validation '
5618 );
5619 END IF;
5620 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5621 END;
5622
5623 END IF;
5624
5625
5626 /* Added by Manish */
5627
5628 -- Validating Tax Information
5629 IF p_line_rec.tax_code IS NOT NULL AND
5630 p_line_rec.tax_date IS NOT NULL
5631 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.tax_code
5632 ,p_old_line_rec.tax_code)
5633 OR NOT OE_GLOBALS.EQUAL(p_line_rec.tax_date
5634 ,p_old_line_rec.tax_date))
5635 THEN
5636 BEGIN
5637 -- EBTax Changes
5638 /* IF oe_code_control.code_release_level < '110510' THEN
5639 SELECT 'VALID'
5640 INTO l_dummy
5641 FROM AR_VAT_TAX V,
5642 AR_SYSTEM_PARAMETERS P
5643 WHERE V.TAX_CODE = p_line_rec.tax_code
5644 AND V.SET_OF_BOOKS_ID = P.SET_OF_BOOKS_ID
5645 AND NVL(V.ENABLED_FLAG,'Y')='Y'
5646 AND NVL(V.TAX_CLASS,'O')='O'
5647 AND NVL(V.DISPLAYED_FLAG,'Y')='Y'
5648 AND TRUNC(p_line_rec.tax_date) BETWEEN TRUNC(V.START_DATE) AND
5649 TRUNC(NVL(V.END_DATE, p_line_rec.tax_date))
5650 AND ROWNUM = 1;
5651 Else
5652 l_AR_Sys_Param_Rec := OE_Sys_Parameters_Pvt.Get_AR_Sys_Params;
5653 l_sob_id := l_AR_Sys_Param_Rec.set_of_books_id;
5654
5655 SELECT 'VALID'
5656 INTO l_dummy
5657 FROM AR_VAT_TAX V
5658 WHERE V.TAX_CODE = p_line_rec.tax_code
5659 AND V.SET_OF_BOOKS_ID = l_sob_id
5660 AND NVL(V.ENABLED_FLAG,'Y')='Y'
5661 AND NVL(V.TAX_CLASS,'O')='O'
5662 AND NVL(V.DISPLAYED_FLAG,'Y')='Y'
5663 AND TRUNC(p_line_rec.tax_date) BETWEEN TRUNC(V.START_DATE) AND
5664 TRUNC(NVL(V.END_DATE, p_line_rec.tax_date))
5665 AND ROWNUM = 1;
5666 End if;
5667 */
5668 SELECT 'VALID'
5669 INTO l_dummy
5670 FROM ZX_OUTPUT_CLASSIFICATIONS_V
5671 WHERE LOOKUP_CODE = p_line_rec.tax_code
5672 -- AND LOOKUP_TYPE = 'ZX_OUTPUT_CLASSIFICATIONS'
5673 AND ENABLED_FLAG ='Y'
5674 AND ORG_ID in (p_line_rec.org_id, -99)
5675 AND TRUNC(p_line_rec.tax_date) BETWEEN
5676 TRUNC(START_DATE_ACTIVE) AND
5677 TRUNC(NVL(END_DATE_ACTIVE, p_line_rec.tax_date))
5678 AND ROWNUM = 1;
5679
5680 EXCEPTION
5681
5682 WHEN NO_DATA_FOUND THEN
5683 l_return_status := FND_API.G_RET_STS_ERROR;
5684 FND_MESSAGE.SET_NAME('ONT','OE_INVALID_ATTRIBUTE');
5685 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
5686 OE_Order_Util.Get_Attribute_Name('TAX_CODE'));
5687 OE_MSG_PUB.Add;
5688
5689 WHEN OTHERS THEN
5690 IF OE_MSG_PUB.Check_Msg_Level (
5691 OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5692 THEN
5693 OE_MSG_PUB.Add_Exc_Msg
5694 ( G_PKG_NAME ,
5695 'Record - Tax Code validation '
5696 );
5697 END IF;
5698 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5699
5700 END; -- BEGIN
5701 END IF;
5702
5703
5704
5705 --bug6441512
5706 IF p_line_rec.tax_exempt_flag = 'S' AND
5707 (p_line_rec.tax_exempt_number IS NOT NULL OR
5708 p_line_rec.tax_exempt_reason_code IS NOT NULL)
5709 THEN
5710 l_return_status := FND_API.G_RET_STS_ERROR;
5711 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_ERROR)
5712 THEN
5713 fnd_message.set_name('ONT','OE_NO_TAX_EXEMPTION');
5714 OE_MSG_PUB.Add;
5715 END IF;
5716
5717 END IF; -- If Tax handling is Standard
5718
5719
5720 --bug6441512
5721 IF p_line_rec.tax_exempt_flag = 'E'
5722 THEN
5723 -- Check for Tax exempt reason
5724
5725 --bug6732513
5726 /* IF p_line_rec.tax_exempt_number IS NULL
5727 THEN
5728 l_return_status := FND_API.G_RET_STS_ERROR;
5729 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_ERROR)
5730 THEN
5731 fnd_message.set_name('ONT','OE_TAX_EXEMPTION_REQUIRED');
5732 OE_MSG_PUB.Add;
5733 END IF;
5734 END IF;*/
5735
5736
5737 IF p_line_rec.tax_exempt_reason_code IS NULL
5738 THEN
5739 l_return_status := FND_API.G_RET_STS_ERROR;
5740 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_ERROR)
5741 THEN
5742 fnd_message.set_name('ONT','OE_ATTRIBUTE_REQUIRED');
5743 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
5744 OE_Order_Util.Get_Attribute_Name('TAX_EXEMPT_REASON_CODE'));
5745 OE_MSG_PUB.Add;
5746 END IF;
5747 END IF;
5748 END IF; -- If Tax handling is exempt
5749
5750
5751 --bug6441512
5752 IF p_line_rec.tax_exempt_flag = 'R' AND
5753 (p_line_rec.tax_exempt_number IS NOT NULL OR
5754 p_line_rec.tax_exempt_reason_code IS NOT NULL)
5755 THEN
5756 l_return_status := FND_API.G_RET_STS_ERROR;
5757 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_ERROR)
5758 THEN
5759 fnd_message.set_name('ONT','OE_TAX_EXEMPTION_NOT_ALLOWED');
5760 OE_MSG_PUB.Add;
5761 END IF;
5762
5763 END IF; -- If Tax handling is Required
5764
5765
5766 -- Removing the following Tax Exemption Number Validation for bug 6441512
5767
5768 -- Check for Tax Exempt number/ Tax Exempt reason code depends on
5769 -- following attributes if the Tax_exempt_flag = 'S' (Standard)
5770
5771 /* IF p_line_rec.tax_exempt_flag IS NOT NULL
5772 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.tax_exempt_number
5773 ,p_old_line_rec.tax_exempt_number)
5774 OR NOT OE_GLOBALS.EQUAL(p_line_rec.tax_exempt_reason_code
5775 ,p_old_line_rec.tax_exempt_reason_code)
5776 OR NOT OE_GLOBALS.EQUAL(p_line_rec.tax_date
5777 ,p_old_line_rec.tax_date)
5778 OR NOT OE_GLOBALS.EQUAL(p_line_rec.ship_to_org_id
5779 ,p_old_line_rec.ship_to_org_id)
5780 OR NOT OE_GLOBALS.EQUAL(p_line_rec.invoice_to_org_id
5781 ,p_old_line_rec.invoice_to_org_id)
5782 OR NOT OE_GLOBALS.EQUAL(p_line_rec.sold_to_org_id
5783 ,p_old_line_rec.sold_to_org_id)
5784 )
5785 THEN
5786
5787 BEGIN
5788
5789 oe_debug_pub.Add('Tax Exempt Flag is :'|| p_line_rec.tax_exempt_flag, 1);
5790 --bug 6118092
5791 IF ( p_line_rec.tax_exempt_flag = 'S' OR p_line_rec.tax_exempt_flag = 'E' ) and
5792 p_line_rec.tax_exempt_number IS NOT NULL and
5793 p_line_rec.tax_exempt_reason_code IS NOT NULL and
5794 p_line_rec.tax_code IS NOT NULL
5795 THEN
5796 -- EBTax Changes
5797
5798 open partyinfo(p_line_rec.invoice_to_org_id);
5799 fetch partyinfo into l_bill_to_cust_Acct_id,
5800 l_bill_to_party_id,
5801 l_bill_to_party_site_id,
5802 l_org_id;
5803 close partyinfo;
5804
5805 if p_line_rec.ship_to_org_id = p_line_rec.invoice_to_org_id then
5806 l_ship_to_cust_Acct_id := l_bill_to_cust_Acct_id;
5807 l_ship_to_party_id := l_bill_to_party_id;
5808 l_ship_to_party_site_id := l_bill_to_party_site_id ;
5809 else
5810 open partyinfo(p_line_rec.ship_to_org_id);
5811 fetch partyinfo into l_ship_to_cust_Acct_id,
5812 l_ship_to_party_id,
5813 l_ship_to_party_site_id,
5814 l_org_id;
5815 close partyinfo;
5816 end if;
5817
5818 -- Modified below code to validate Tax Exempt Number based on Tax Handling for Bug 6378168
5819 IF ( p_line_rec.tax_exempt_flag = 'S' ) THEN
5820 SELECT 'VALID'
5821 INTO l_dummy
5822 FROM ZX_EXEMPTIONS_V
5823 WHERE EXEMPT_CERTIFICATE_NUMBER = p_line_rec.tax_exempt_number
5824 AND EXEMPT_REASON_CODE = p_line_rec.tax_exempt_reason_code
5825 AND nvl(site_use_id,nvl(p_line_rec.ship_to_org_id,
5826 p_line_rec.invoice_to_org_id))
5827 = nvl(p_line_rec.ship_to_org_id,
5828 p_line_rec.invoice_to_org_id)
5829 AND nvl(cust_account_id, l_bill_to_cust_acct_id) = l_bill_to_cust_acct_id
5830 AND nvl(PARTY_SITE_ID,nvl(l_ship_to_party_site_id, l_bill_to_party_site_id))=
5831 nvl(l_ship_to_party_site_id, l_bill_to_party_site_id)
5832 --* AND TAX_CODE = p_line_rec.tax_code
5833 AND org_id = l_org_id
5834 AND party_id = l_bill_to_party_id
5835 -- AND nvl(LEGAL_ENTITY_ID,-99) IN (nvl(l_legal_entity_id, legal_entity_id), -99)
5836 AND EXEMPTION_STATUS_CODE = 'PRIMARY'
5837 AND TRUNC(NVL(p_line_rec.request_date,sysdate))
5838 BETWEEN TRUNC(EFFECTIVE_FROM)
5839 AND TRUNC(NVL(EFFECTIVE_TO,NVL(p_line_rec.request_date,sysdate)))
5840 AND ROWNUM = 1;
5841 ELSIF ( p_line_rec.tax_exempt_flag = 'E' ) THEN
5842 SELECT 'VALID'
5843 INTO l_dummy
5844 FROM ZX_EXEMPTIONS_V
5845 WHERE EXEMPT_CERTIFICATE_NUMBER = p_line_rec.tax_exempt_number
5846 AND EXEMPT_REASON_CODE = p_line_rec.tax_exempt_reason_code
5847 AND nvl(site_use_id,nvl(p_line_rec.ship_to_org_id,
5848 p_line_rec.invoice_to_org_id))
5849 = nvl(p_line_rec.ship_to_org_id,
5850 p_line_rec.invoice_to_org_id)
5851 AND nvl(cust_account_id, l_bill_to_cust_acct_id) = l_bill_to_cust_acct_id
5852 AND nvl(PARTY_SITE_ID,nvl(l_ship_to_party_site_id, l_bill_to_party_site_id))=
5853 nvl(l_ship_to_party_site_id, l_bill_to_party_site_id)
5854 --* AND TAX_CODE = p_line_rec.tax_code
5855 AND org_id = l_org_id
5856 AND party_id = l_bill_to_party_id
5857 -- AND nvl(LEGAL_ENTITY_ID,-99) IN (nvl(l_legal_entity_id, legal_entity_id), -99)
5858 AND EXEMPTION_STATUS_CODE IN ( 'PRIMARY', 'MANUAL', 'UNAPPROVED' )
5859 AND TRUNC(NVL(p_line_rec.request_date,sysdate))
5860 BETWEEN TRUNC(EFFECTIVE_FROM)
5861 AND TRUNC(NVL(EFFECTIVE_TO,NVL(p_line_rec.request_date,sysdate)))
5862 AND ROWNUM = 1;
5863 END IF;
5864 -- end eBTax changes
5865 END IF;
5866
5867 oe_debug_pub.Add(' Valid Tax Exempt Number',1);
5868
5869 EXCEPTION
5870
5871 WHEN NO_DATA_FOUND THEN
5872 -- Bug 6118092 Redefault as it may be no more valid
5873 IF p_line_rec.line_category_code = 'RETURN' THEN
5874 null;
5875 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
5876 p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
5877 p_line_rec.tax_exempt_number := FND_API.G_MISS_CHAR;
5878 p_line_rec.tax_exempt_reason_code := FND_API.G_MISS_CHAR;
5879 p_line_rec.tax_exempt_flag :=FND_API.G_MISS_CHAR;
5880 G_REDEFAULT_MISSING := 'Y';
5881
5882 oe_debug_pub.Add('Redefault the tax_exempt_number',1);
5883
5884 ELSE
5885
5886 l_return_status := FND_API.G_RET_STS_ERROR;
5887
5888 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR)
5889 THEN
5890 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
5891 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
5892 OE_Order_Util.Get_Attribute_Name('TAX_EXEMPT_NUMBER'));
5893 OE_MSG_PUB.Add;
5894 END IF;
5895 END IF;
5896
5897 WHEN OTHERS THEN
5898 IF OE_MSG_PUB.Check_Msg_Level (
5899 OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5900 THEN
5901 OE_MSG_PUB.Add_Exc_Msg
5902 ( G_PKG_NAME ,
5903 'Record - Tax Exemptions '
5904 );
5905 END IF;
5906 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5907
5908 END; -- BEGIN
5909
5910 END IF; -- Tax exempton info validation.
5911
5912 */
5913
5914 /* Added by Manish */
5915
5916 -- order_quantity_uom should be primary uom for model/class/option.
5917 IF p_line_rec.order_quantity_uom is not null
5918 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.inventory_item_id,p_old_line_rec.inventory_item_id)
5919 OR NOT OE_GLOBALS.EQUAL(p_line_rec.order_quantity_uom,p_old_line_rec.order_quantity_uom)
5920 OR NOT OE_GLOBALS.EQUAL(p_line_rec.ship_from_org_id,p_old_line_rec.ship_from_org_id))
5921 THEN
5922
5923 IF ( p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
5924 p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
5925 p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION OR
5926 p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT OR
5927 p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_INCLUDED OR
5928 p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CONFIG)
5929 THEN
5930 BEGIN
5931 -- bug 4171642
5932 IF ((OE_ORDER_CACHE.g_item_rec.organization_id <> FND_API.G_MISS_NUM)
5933 AND
5934 (nvl(p_line_rec.ship_from_org_id,g_master_org_id) = OE_ORDER_CACHE.g_item_rec.organization_id)
5935 AND
5936 OE_ORDER_CACHE.g_item_rec.inventory_item_id = p_line_rec.inventory_item_id ) THEN
5937 l_uom := OE_ORDER_CACHE.g_item_rec.primary_uom_code ;
5938 ELSE
5939 OE_ORDER_CACHE.Load_Item( p_key1 => p_line_rec.inventory_item_id , p_key2 => p_line_rec.ship_from_org_id );
5940 l_uom := OE_ORDER_CACHE.g_item_rec.primary_uom_code ;
5941 END IF ;
5942 /*SELECT primary_uom_code
5943 INTO l_uom
5944 FROM mtl_system_items_b
5945 WHERE inventory_item_id = p_line_rec.inventory_item_id
5946 AND organization_id = nvl(p_line_rec.ship_from_org_id,
5947 OE_Sys_Parameters.VALUE_WNPS('MASTER_ORGANIZATION_ID'));
5948 */
5949 -- end bug 4171642
5950 IF l_debug_level > 0 then
5951 oe_debug_pub.add('primary uom: '|| l_uom, 1);
5952 oe_debug_pub.add('uom entered: '||p_line_rec.order_quantity_uom , 1);
5953 END IF;
5954
5955 IF l_uom <> p_line_rec.order_quantity_uom
5956 THEN
5957 IF l_debug_level > 0 then
5958 oe_debug_pub.add('uom other than primary uom is entered', 1);
5959 END IF;
5960
5961 fnd_message.set_name('ONT','OE_INVALID_ORDER_QUANTITY_UOM');
5962 fnd_message.set_token('ITEM',nvl(p_line_rec.ordered_item,p_line_rec.inventory_item_id));
5963 fnd_message.set_token('UOM', l_uom);
5964 OE_MSG_PUB.Add;
5965 RAISE FND_API.G_EXC_ERROR;
5966 END IF;
5967 EXCEPTION
5968 when no_data_found then
5969 IF l_debug_level > 0 then
5970 oe_debug_pub.add('OEXLLINB, no_data_found in uom validation', 1);
5971 END IF;
5972 RAISE FND_API.G_EXC_ERROR;
5973 END;
5974
5975 ELSE -- not ato related, validate item, uom combination
5976 /*1544265*/
5977 /*SELECT count(*)
5978 INTO l_uom_count
5979 FROM mtl_item_uoms_view
5980 WHERE inventory_item_id = p_line_rec.inventory_item_id
5981 AND uom_code = p_line_rec.order_quantity_uom
5982 AND organization_id = nvl(p_line_rec.ship_from_org_id,
5983 OE_Sys_Parameters.VALUE_WNPS('MASTER_ORGANIZATION_ID'));
5984
5985
5986 IF l_uom_count = 0 THEN
5987 IF l_debug_level > 0 then
5988 oe_debug_pub.add('uom/item combination invalid',2);
5989 END IF;
5990 fnd_message.set_name('ONT', 'OE_INVALID_ITEM_UOM');
5991 OE_MSG_PUB.Add;
5992 RAISE FND_API.G_EXC_ERROR;
5993 END IF;
5994
5995 */
5996 l_ret_status := inv_convert.validate_item_uom(p_line_rec.order_quantity_uom,p_line_rec.inventory_item_id,nvl(p_line_rec.ship_from_org_id,OE_Sys_Parameters.VALUE_WNPS('MASTER_ORGANIZATION_ID')));
5997 IF NOT l_ret_status THEN
5998 IF l_debug_level > 0 then
5999 oe_debug_pub.add('uom/item combination invalid',2);
6000 END IF;
6001 fnd_message.set_name('ONT', 'OE_INVALID_ITEM_UOM');
6002 OE_MSG_PUB.Add;
6003 RAISE FND_API.G_EXC_ERROR;
6004 END IF;
6005 /*1544265*/
6006 END IF;
6007 END IF;
6008
6009 If p_line_rec.agreement_id is not null and
6010 NOT OE_GLOBALS.EQUAL(p_line_rec.agreement_id, fnd_api.g_miss_num) then
6011 If not oe_globals.equal(p_line_rec.agreement_id,p_old_line_rec.agreement_id) then
6012
6013 -- Check for Agreement +sold_org_id
6014
6015 -- Where cluase added to check start and end date for agreements
6016 -- Geresh
6017
6018 BEGIN
6019 BEGIN
6020 select list_type_code
6021 into l_list_type_code
6022 from qp_list_headers_vl
6023 where list_header_id = p_line_rec.price_list_id;
6024 EXCEPTION WHEN NO_DATA_FOUND THEN
6025 null;
6026 END;
6027
6028 BEGIN
6029 SELECT name ,sold_to_org_id , price_list_id
6030 INTO l_agreement_name,l_sold_to_org,l_price_list_id
6031 FROM oe_agreements_v
6032 WHERE agreement_id = p_line_rec.agreement_id
6033 AND trunc(nvl(p_line_rec.pricing_date,sysdate)) between
6034 trunc(nvl(START_DATE_ACTIVE,add_months(sysdate,-10000)))
6035 AND trunc(nvl(END_DATE_ACTIVE,add_months(sysdate,+10000)));
6036 EXCEPTION WHEN NO_DATA_FOUND THEN
6037 null;
6038 END;
6039
6040 --for bug 2345712 begin
6041 if p_line_rec.price_list_id is not null and
6042 p_line_rec.price_list_id <> FND_API.G_MISS_NUM
6043 then
6044 IF NOT OE_GLOBALS.EQUAL(l_list_type_code,'PRL') THEN
6045 -- any price list with 'PRL' type should be allowed to
6046 -- be associated with any agreement according to bug 1386406.
6047 IF NOT OE_GLOBALS.EQUAL(l_price_list_id, p_line_rec.price_list_id) THEN
6048 fnd_message.set_name('ONT', 'OE_INVALID_AGREEMENT_PLIST');
6049 fnd_message.set_Token('AGREEMENT_NAME', l_agreement_name);
6050 BEGIN
6051 SELECT name
6052 INTO l_price_list_name
6053 FROM qp_List_headers_vl
6054 WHERE list_header_id = p_line_rec.price_list_id
6055 AND trunc(nvl(p_line_rec.pricing_date,sysdate)) BETWEEN
6056 trunc(nvl(START_DATE_ACTIVE,add_months(sysdate,-10000)))
6057 AND trunc(nvl(END_DATE_ACTIVE,add_months(sysdate,+10000)));
6058
6059 Exception when no_data_found then
6060 l_price_list_name := p_line_rec.price_list_id;
6061 END;
6062 fnd_message.set_Token('PRICE_LIST1', l_price_list_name);
6063 BEGIN
6064
6065 SELECT name
6066 INTO l_price_list_name
6067 FROM QP_List_headers_vl
6068 WHERE list_header_id = l_price_list_id
6069 AND trunc(nvl(p_line_rec.pricing_date,sysdate)) BETWEEN
6070 trunc(nvl(START_DATE_ACTIVE,add_months(sysdate,-10000)))
6071 AND trunc(nvl(END_DATE_ACTIVE,add_months(sysdate,+10000)));
6072 EXCEPTION
6073 WHEN NO_DATA_FOUND THEN
6074 l_price_list_name := l_price_list_id;
6075 END;
6076 fnd_message.set_Token('PRICE_LIST2', l_price_list_name);
6077 OE_MSG_PUB.Add;
6078 IF l_debug_level > 0 then
6079 oe_debug_pub.add('Invalid Agreement +price_list_id combination',2);
6080 END IF;
6081 raise FND_API.G_EXC_ERROR;
6082 END IF;
6083 END IF; -- end of if l_list_type_code <> 'PRL'
6084 end if; --for bug 2345712 end
6085
6086 -- modified by lkxu, to check for customer relationships.
6087 IF l_sold_to_org IS NOT NULL AND l_sold_to_org <> -1
6088 AND NOT OE_GLOBALS.EQUAL(l_sold_to_org,p_line_rec.sold_to_org_id) THEN
6089 IF nvl(lcustomer_relations,'N') = 'N' THEN
6090 fnd_message.set_name('ONT', 'OE_INVALID_AGREEMENT');
6091 fnd_message.set_Token('AGREEMENT_ID', p_line_rec.agreement_id);
6092 fnd_message.set_Token('AGREEMENT_NAME', l_agreement_name);
6093 fnd_message.set_Token('CUSTOMER_ID', p_line_rec.sold_to_org_id);
6094 OE_MSG_PUB.Add;
6095 IF l_debug_level > 0 then
6096 oe_debug_pub.add('Invalid Agreement +sold_org_id combination',2);
6097 END IF;
6098 RAISE FND_API.G_EXC_ERROR;
6099 ELSIF lcustomer_relations = 'Y' THEN
6100
6101 BEGIN
6102 SELECT 'VALID'
6103 INTO l_dummy
6104 FROM dual
6105 WHERE exists(
6106 select 'x' from
6107 hz_cust_acct_relate where
6108 related_cust_account_id = p_line_rec.sold_to_org_id
6109 and status = 'A'
6110 AND cust_account_id = l_sold_to_org
6111 );
6112
6113 EXCEPTION
6114 WHEN NO_DATA_FOUND THEN
6115 fnd_message.set_name('ONT', 'OE_INVALID_AGREEMENT');
6116 fnd_message.set_Token('AGREEMENT_ID', p_line_rec.agreement_id);
6117 fnd_message.set_Token('AGREEMENT_NAME', l_agreement_name);
6118 fnd_message.set_Token('CUSTOMER_ID', p_line_rec.sold_to_org_id);
6119 OE_MSG_PUB.Add;
6120 IF l_debug_level > 0 then
6121 oe_debug_pub.add('Invalid Agreement +sold_org_id combination',2);
6122 END IF;
6123 RAISE FND_API.G_EXC_ERROR;
6124 END;
6125 END IF;
6126 END IF;
6127
6128
6129 EXCEPTION
6130 WHEN NO_DATA_FOUND THEN
6131 fnd_message.set_name('ONT', 'OE_INVALID_AGREEMENT');
6132 fnd_message.set_Token('AGREEMENT_ID', p_line_rec.agreement_id);
6133 fnd_message.set_Token('AGREEMENT_NAME', l_agreement_name);
6134 fnd_message.set_Token('CUSTOMER_ID', l_sold_to_org);
6135 OE_MSG_PUB.Add;
6136 IF l_debug_level > 0 then
6137 oe_debug_pub.add('Invalid Agreement +sold_org_id combination',2);
6138 END IF;
6139 RAISE FND_API.G_EXC_ERROR;
6140 END;
6141 END IF; -- Agreement has changed
6142
6143 -- fixed bug 1672380, only validate for not null price list id
6144 ELSIF p_line_rec.price_list_id IS NOT NULL and
6145 NOT OE_GLOBALS.EQUAL(p_line_rec.price_list_id,p_old_line_rec.price_list_id)
6146 THEN
6147
6148 if p_line_rec.cancelled_flag <> 'Y' and
6149 p_line_rec.calculate_price_flag not in ('P','N') Then
6150 BEGIN
6151 --
6152 l_hdr_currency_code := OE_ORDER_CACHE.g_header_rec.transactional_curr_code;
6153
6154 --fix a problem in which for some rare cases in which cachce has a null of transactional_curr_code
6155 If nvl(l_hdr_currency_code,FND_API.G_MISS_CHAR) = FND_API.G_MISS_CHAR Then
6156 Select transactional_curr_code
6157 into l_hdr_currency_code
6158 From oe_order_headers_all
6159 Where header_id = p_line_rec.header_id;
6160 End If;
6161
6162 QP_UTIL_PUB.Validate_Price_list_Curr_code(p_line_rec.price_list_id,
6163 l_hdr_currency_code,
6164 p_line_rec.pricing_date,
6165 l_validate_result);
6166
6167 --
6168 EXCEPTION
6169 --
6170 WHEN NO_DATA_FOUND THEN
6171 --
6172 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR) THEN
6173 --
6174 OE_MSG_PUB.Update_Msg_Context(p_attribute_code => 'PRICE_LIST_ID');
6175
6176 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
6177 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
6178 OE_Order_Util.Get_Attribute_Name('price_list_id'));
6179 OE_MSG_PUB.Add;
6180 OE_MSG_PUB.Update_Msg_Context(p_attribute_code => null);
6181 --
6182 END IF;
6183 --
6184 RAISE FND_API.G_EXC_ERROR;
6185 --
6186 END;
6187 --
6188 end if;
6189 IF l_debug_level > 0 then
6190 OE_DEBUG_PUB.ADD('l_hdr_currency_code:' || l_hdr_currency_code,2);
6191 OE_DEBUG_PUB.ADD('l_validate_result:'||l_VALIDATE_RESULT);
6192 OE_DEBUG_PUB.ADD('operation:'||p_line_rec.operation);
6193 OE_DEBUG_PUB.ADD('validate level'||p_validation_level);
6194 END IF;
6195 --
6196 IF l_VALIDATE_RESULT = 'N' THEN
6197 --bug 3572931 depending on the validation level set the Price List to NULL or G_MISS_NUM
6198 --if it is not valid, else raise an error.
6199 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL
6200 AND p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
6201 p_line_rec.price_list_id := NULL;
6202 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF
6203 AND p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
6204 p_line_rec.price_list_id := FND_API.G_MISS_NUM;
6205 G_REDEFAULT_MISSING := 'Y';
6206 ELSE
6207
6208 --
6209 FND_MESSAGE.SET_NAME('ONT','OE_CURRENCY_MISMATCH');
6210 FND_MESSAGE.SET_TOKEN('LINE_CURR_CODE', l_currency_code);
6211 FND_MESSAGE.SET_TOKEN('PRICE_LIST_NAME', l_price_list_name);
6212 FND_MESSAGE.SET_TOKEN('HEADER_CURR_CODE', l_hdr_currency_code);
6213 OE_MSG_PUB.ADD;
6214 --
6215 RAISE FND_API.G_EXC_ERROR;
6216 --
6217 END IF;
6218 END IF;
6219
6220 --
6221 IF NOT oe_globals.equal(p_line_rec.pricing_date,p_old_line_rec.pricing_date) OR
6222 not oe_globals.equal(p_line_rec.price_list_id,p_old_line_rec.price_list_id) THEN
6223
6224 -- Allow only the non agreement price_lists
6225 -- do not need to validate price list if calculate_price_flag is N or P.
6226 IF p_line_rec.calculate_price_flag Not IN ('N', 'P')
6227 --Bug 3572931 added the condition so that code is called only when Price List is not NULL and G_MISS_NUM
6228 AND not (oe_globals.equal(p_line_rec.price_list_id,FND_API.G_MISS_NUM) OR
6229 (p_line_rec.price_list_id IS NULL ) )
6230 THEN
6231
6232 BEGIN
6233 IF l_debug_level > 0 then
6234 oe_debug_pub.add('Pricing date is '||p_line_rec.pricing_date,2);
6235 END IF;
6236
6237 -- Modified 09-DEC-2001
6238 -- Blankets: modified select to select list_type_code instead
6239 -- of selecting only PRL price list
6240 -- modified by lkxu: to select from qp_list_headers_vl instead
6241 -- of from qp_price_lists_v to select only PRL type list headers.
6242
6243 --use cache instead of sql for bug 4200055
6244 l_price_list_rec := OE_ORDER_CACHE.Load_Price_List(p_line_rec.price_list_id) ;
6245 IF ( l_price_list_rec.price_list_id <> FND_API.G_MISS_NUM
6246 AND l_price_list_rec.price_list_id IS NOT NULL
6247 AND l_price_list_rec.price_list_id = p_line_rec.price_list_id ) THEN
6248 if (
6249 trunc(nvl(l_price_list_rec.start_date_active,add_months(sysdate,-10000))) <= trunc(nvl(p_line_rec.pricing_date,sysdate))
6250 and trunc(nvl(l_price_list_rec.end_date_active,add_months(sysdate,10000))) >= trunc(nvl(p_line_rec.pricing_date,sysdate))
6251 ) then
6252 l_price_list_name := l_price_list_rec.name ;
6253 l_list_type_code := l_price_list_rec.list_type_code ;
6254 else
6255 RAISE NO_DATA_FOUND ;
6256 end if ;
6257 ELSE
6258 RAISE NO_DATA_FOUND ;
6259 END IF ;
6260 /*SELECT name, list_type_code
6261 INTO l_price_list_name, l_list_type_code
6262 FROM qp_list_headers_vl
6263 WHERE list_header_id = p_line_rec.price_list_id
6264 AND trunc(nvl(p_line_rec.pricing_date,sysdate)) BETWEEN
6265 trunc(nvl(START_DATE_ACTIVE,add_months(sysdate,-10000)))
6266 AND trunc(nvl(END_DATE_ACTIVE,add_months(sysdate,+10000))); */
6267 -- end bug 4200055
6268
6269 IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110509'
6270 AND p_line_rec.blanket_number IS NOT NULL
6271 THEN
6272
6273 -- For release lines, any price lists other than PRL and AGR are
6274 -- invalid.
6275 IF l_list_type_code NOT IN ('PRL','AGR') THEN
6276 RAISE NO_DATA_FOUND;
6277 END IF;
6278
6279 -- If price list is of type 'AGR', validate customer on agreement
6280 -- against customer on line. If sold_to_org_id on agreement is -1,
6281 -- price list is valid for all customers.
6282 IF l_list_type_code = 'AGR' THEN
6283 IF lcustomer_relations = 'N' THEN
6284 SELECT 'Y'
6285 INTO l_dummy
6286 FROM oe_agreements oa
6287 WHERE price_list_id = p_line_rec.price_list_id
6288 AND (sold_to_org_id = -1
6289 OR sold_to_org_id = p_line_rec.sold_to_org_id);
6290 ELSIF lcustomer_relations = 'Y' THEN
6291 SELECT 'Y'
6292 INTO l_dummy
6293 FROM oe_agreements oa
6294 WHERE price_list_id = p_line_rec.price_list_id
6295 AND sold_to_org_id IN
6296 (select -1
6297 from dual
6298 union
6299 select p_line_rec.sold_to_org_id
6300 from dual
6301 union
6302 select r.cust_account_id
6303 from hz_cust_acct_relate r
6304 where r.related_cust_account_id = p_line_rec.sold_to_org_id);
6305 END IF;
6306 END IF;
6307
6308 -- For regular lines, price list other than of type PRL is invalid
6309 ELSIF l_list_type_code <> 'PRL' THEN
6310 RAISE NO_DATA_FOUND;
6311 END IF;
6312
6313 EXCEPTION
6314 WHEN NO_DATA_FOUND THEN
6315 fnd_message.set_name('ONT', 'OE_INVALID_NONAGR_PLIST');
6316 fnd_message.set_Token('PRICE_LIST1', p_line_rec.price_list_id);
6317 fnd_message.set_Token('PRICING_DATE', p_line_rec.pricing_date);
6318 OE_MSG_PUB.Add;
6319 IF l_debug_level > 0 then
6320 oe_debug_pub.add('Invalid non agreement price list ',2);
6321 END IF;
6322 RAISE FND_API.G_EXC_ERROR;
6323 END;
6324
6325 END IF; --calculate_price_flag
6326 END IF; -- Price list or pricing date has changed
6327 END IF;
6328 IF l_debug_level > 0 then
6329 oe_debug_pub.add('15 '||l_return_status ,1);
6330 END IF;
6331
6332 -- Line number validation.
6333 -- Allow line number updates only on Model, Standard, Kit,
6334 -- and stand alone service line.
6335 -- Bug 2382657 : Modified the condition for KIT and added
6336 -- condition for INCLUDED items.
6337
6338 IF p_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE THEN
6339
6340 IF (p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION) OR
6341 (p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS) OR
6342 (p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT AND
6343 p_line_rec.line_id <> p_line_rec.top_model_line_id ) OR --bug 2382657
6344 (p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_INCLUDED) OR
6345 (p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_SERVICE AND
6346 p_line_rec.service_reference_line_id IS NOT NULL AND
6347 p_line_rec.service_reference_line_id <> FND_API.G_MISS_NUM)
6348
6349 THEN
6350
6351 IF (NOT OE_GLOBALS.EQUAL(p_line_rec.line_number,
6352 p_old_line_rec.line_number)) THEN
6353
6354 l_return_status := FND_API.G_RET_STS_ERROR;
6355 fnd_message.set_name('ONT', 'OE_LINE_NUMBER_UPD');
6356 OE_MSG_PUB.add;
6357
6358 END IF;
6359 END IF;
6360
6361 END IF;
6362
6363 IF l_debug_level > 0 then
6364 oe_debug_pub.add('16 '||l_return_status ,1);
6365 END IF;
6366 IF l_debug_level > 0 then
6367 IF p_line_rec.top_model_line_id is not null AND
6368 p_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
6369 p_line_rec.ordered_quantity = 0
6370 THEN
6371 IF l_debug_level > 0 then
6372 oe_debug_pub.add('qty of a configuration related line 0'|| p_line_rec.item_type_code, 1);
6373 END IF;
6374 END IF;
6375 END IF;
6376 /*
6377 -- If a model has classes/options under it, making ordered_quantity from n
6378 -- to 0 is not allowed. It has some issues when the next time user
6379 -- changing model's quantity from 0 to n, we can not simply cascade etc. We
6380 -- will give a message which says that => user needs to delete all the
6381 -- options/classes under this model and then he can change the quantity to
6382 -- 0. I will add this message and modify code accordingly.
6383 -- Also the next time user wants to go to configurator, he should change
6384 -- the ordered quantity on the model line from 0 to something, else we will
6385 -- not open configurator. I will add a message for this. Order Import also
6386 -- will have same behavior. However we do see if this is a complete cancellation.
6387
6388
6389 IF (p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_CLASS OR
6390 p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_OPTION) AND
6391 p_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
6392 p_line_rec.ordered_quantity = 0
6393 THEN
6394 IF l_debug_level > 0 then
6395 oe_debug_pub.add('class/option qty changed to 0', 1);
6396 END IF;
6397 l_return_status := FND_API.G_RET_STS_ERROR;
6398 FND_MESSAGE.SET_NAME('ONT', 'OE_CONFIG_NO_ZERO_QTY');
6399 oe_msg_pub.add;
6400 END IF;
6401
6402 l_option_count := 0;
6403
6404 IF (p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_MODEL OR
6405 p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_KIT) AND
6406 p_line_rec.ordered_quantity = 0 AND
6407 p_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
6408 OE_Sales_Can_Util.G_Require_Reason = FALSE
6409 THEN
6410 -- this is a decrement and not a cancellation.
6411
6412 SELECT count(*)
6413 INTO l_option_count
6414 FROM oe_order_lines
6415 WHERE top_model_line_id = p_line_rec.line_id
6416 AND line_id <> p_line_rec.line_id;
6417
6418 IF l_option_count > 0 THEN
6419 IF l_debug_level > 0 then
6420 oe_debug_pub.add('models qty changed to 0, no cancellation', 1);
6421 END IF;
6422 l_return_status := FND_API.G_RET_STS_ERROR;
6423 FND_Message.Set_Name('ONT', 'OE_CONFIG_NO_ZERO_QTY');
6424 oe_msg_pub.add;
6425 END IF;
6426 END IF;
6427 */
6428 IF l_debug_level > 0 then
6429 oe_debug_pub.add('OEXLLINB, RR:T2',1);
6430 oe_debug_pub.add('17 '||l_return_status ,1);
6431 END IF;
6432
6433 -- Validate ordered quantity for OTA lines. OTA Lines are
6434 -- identified by item_type_code of training. The ordered
6435 -- quantity cannot be greater than 1 for OTA lines.
6436
6437 l_order_quantity_uom := p_line_rec.order_quantity_uom;
6438 l_is_ota_line := OE_OTA_UTIL.Is_OTA_Line(l_order_quantity_uom);
6439
6440 IF (l_is_ota_line) AND
6441 p_line_rec.ordered_quantity > 1 then
6442 IF l_debug_level > 0 then
6443 oe_debug_pub.add('Ordered Qty cannot be greater than 1 for OTA lines', 1);
6444 END IF;
6445 l_return_status := FND_API.G_RET_STS_ERROR;
6446 FND_Message.Set_Name('ONT', 'OE_OTA_INVALID_QTY');
6447 oe_msg_pub.add;
6448 END IF;
6449
6450 /* End of validation for OTA */
6451
6452 --bug3412008 Suppressing the warning message for PO number for retrobill lines
6453 IF p_line_rec.order_source_id <> 27 THEN
6454 -- Fix bug 1162304: issue a warning message if the PO number
6455 -- is being referenced by another order
6456 IF p_line_rec.cust_po_number IS NOT NULL
6457 AND ( NOT OE_GLOBALS.EQUAL(p_line_rec.sold_to_org_id
6458 ,p_old_line_rec.sold_to_org_id)
6459 OR NOT OE_GLOBALS.EQUAL(p_line_rec.cust_po_number
6460 ,p_old_line_rec.cust_po_number)
6461 )
6462 THEN
6463
6464 -- Fixed bug 1949756: validate line level cust po number
6465 -- only if it is different from header cust po number
6466 OE_Order_Cache.Load_Order_Header(p_line_rec.header_id);
6467 IF NOT OE_GLOBALS.EQUAL(OE_Order_Cache.g_header_rec.cust_po_number,
6468 p_line_rec.cust_po_number)
6469 AND OE_Validate_Header.Is_Duplicate_PO_Number
6470 (p_line_rec.cust_po_number
6471 ,p_line_rec.sold_to_org_id
6472 ,p_line_rec.header_id )
6473 THEN
6474 FND_MESSAGE.SET_NAME('ONT','OE_VAL_DUP_PO_NUMBER');
6475 OE_MSG_PUB.ADD;
6476 END IF;
6477
6478 END IF;
6479 -- End of check for duplicate PO number
6480 END IF; --bug3412008
6481
6482 -- Bug -2124989 Added Agreement validation.
6483
6484 IF p_line_rec.agreement_id IS NOT NULL AND
6485 p_line_rec.agreement_id <> FND_API.G_MISS_NUM THEN
6486
6487 IF NOT oe_globals.equal(p_line_rec.pricing_date,
6488 p_old_line_rec.pricing_date) OR
6489 not oe_globals.equal(p_line_rec.agreement_id,
6490 p_old_line_rec.agreement_id) THEN
6491 -- Allow only the Active agreement Revision
6492
6493 BEGIN
6494 IF l_debug_level > 0 then
6495 oe_debug_pub.add('Pricing date is '||p_line_rec.pricing_date,2);
6496 END IF;
6497
6498 SELECT name
6499 INTO l_agreement_name
6500 FROM oe_agreements_vl
6501 WHERE agreement_id = p_line_rec.agreement_id
6502 AND trunc(nvl(p_line_rec.pricing_date,sysdate)) BETWEEN
6503 trunc(nvl(START_DATE_ACTIVE,add_months(sysdate,-10000)))
6504 AND trunc(nvl(END_DATE_ACTIVE,add_months(sysdate,+10000)));
6505
6506 EXCEPTION
6507 WHEN NO_DATA_FOUND THEN
6508 fnd_message.set_name('ONT', 'ONT_INVALID_AGR');
6509 fnd_message.set_Token('PRICING_DATE', p_line_rec.pricing_date);
6510 OE_MSG_PUB.Add;
6511 IF l_debug_level > 0 then
6512 oe_debug_pub.add('Invalid Agreement',2);
6513 END IF;
6514 RAISE FND_API.G_EXC_ERROR;
6515 END;
6516 End If;
6517 END IF; /* End of Bug-2124989 */
6518
6519
6520 -- Fix for bug#1411346:
6521 -- SERVICE end date must be after service start date.
6522
6523 IF (p_line_rec.service_end_date <> FND_API.G_MISS_DATE OR
6524 p_line_rec.service_end_date IS NOT NULL) AND
6525 (p_line_rec.service_start_date <> FND_API.G_MISS_DATE OR
6526 p_line_rec.service_start_date IS NOT NULL) THEN
6527
6528 IF (p_line_rec.service_end_date < p_line_rec.service_start_date) -- 2992944
6529 THEN
6530 l_return_status := FND_API.G_RET_STS_ERROR;
6531 fnd_message.set_name('ONT','OE_SERV_END_DATE');
6532 OE_MSG_PUB.Add;
6533 END IF;
6534
6535 END IF;
6536
6537
6538 -- Validating Commitment on an order line.
6539 -- Also Enhancement Request #1741013:
6540 -- to validate Commitment End Date against OTA Event End Date.
6541
6542 -- fix bug 1618229.
6543 -- Fix Bug # 3015881: Validate Commitment for change in Line Level Invoice To
6544 IF p_line_rec.commitment_id is not NULL AND
6545 (NOT OE_GLOBALS.EQUAL(p_old_line_rec.commitment_id, p_line_rec.commitment_id)
6546 OR NOT OE_GLOBALS.EQUAL(p_old_line_rec.sold_to_org_id, p_line_rec.sold_to_org_id)
6547 OR NOT OE_GLOBALS.EQUAL(p_old_line_rec.invoice_to_org_id, p_line_rec.invoice_to_org_id)
6548 OR NOT OE_GLOBALS.EQUAL(p_old_line_rec.inventory_item_id, p_line_rec.inventory_item_id)
6549 OR NOT OE_GLOBALS.EQUAL(p_old_line_rec.ordered_item_id, p_line_rec.ordered_item_id)
6550 OR NOT OE_GLOBALS.EQUAL(p_old_line_rec.ordered_item, p_line_rec.ordered_item)
6551 OR (NOT OE_GLOBALS.EQUAL(p_old_line_rec.agreement_id, p_line_rec.agreement_id)
6552 AND p_line_rec.agreement_id IS NOT NULL)) THEN
6553
6554 IF l_debug_level > 0 then
6555 OE_DEBUG_PUB.ADD('l_hdr_currency_code1:' || l_hdr_currency_code,2);
6556 END IF;
6557 l_hdr_currency_code := OE_ORDER_CACHE.g_header_rec.transactional_curr_code;
6558 Validate_Commitment(
6559 p_line_rec => p_line_rec
6560 , p_hdr_currency_code => l_hdr_currency_code
6561 , p_ota_line => l_is_ota_line
6562 , x_return_status => l_commitment_status );
6563
6564 IF l_commitment_status = FND_API.G_RET_STS_ERROR THEN
6565 l_return_status := FND_API.G_RET_STS_ERROR;
6566 RAISE FND_API.G_EXC_ERROR;
6567 END IF;
6568
6569 END IF;
6570 IF l_debug_level > 0 then
6571 oe_debug_pub.add('18 '||l_return_status ,1);
6572 END IF;
6573
6574 IF (nvl(p_line_rec.top_model_line_id,-1) <> nvl(p_line_rec.ato_line_id,-1) AND
6575 p_line_rec.top_model_line_id IS NOT NULL) AND
6576 (nvl(p_line_rec.ship_tolerance_below,0) <> 0 OR
6577 nvl(p_line_rec.ship_tolerance_above,0) <> 0 )THEN
6578 IF l_debug_level > 0 then
6579 oe_debug_pub.add('Ship tolerances can not be specified on PTOs',3);
6580 END IF;
6581 l_return_status := FND_API.G_RET_STS_ERROR;
6582 fnd_message.set_name('ONT','OE_NO_TOL_FOR_PTO');
6583 OE_MSG_PUB.Add;
6584
6585 END IF;
6586 IF l_debug_level > 0 then
6587 oe_debug_pub.add('19 '||l_return_status ,1);
6588 END IF;
6589
6590
6591 IF p_line_rec.top_model_line_id is NOT NULL AND
6592 p_line_rec.top_model_line_id <> p_line_rec.line_id AND
6593 p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
6594 p_line_rec.ordered_quantity is NULL THEN
6595
6596 IF l_debug_level > 0 then
6597 oe_debug_pub.add('child line of model with null qty', 3);
6598 END IF;
6599 l_return_status := FND_API.G_RET_STS_ERROR;
6600 fnd_message.set_name('ONT','OE_CONFIG_NULL_QUANTITY');
6601 fnd_message.set_Token('ITEM', nvl(p_line_rec.ordered_item,p_line_rec.inventory_item_id));
6602 OE_MSG_PUB.Add;
6603
6604 END IF;
6605
6606 IF l_debug_level > 0 then
6607 oe_debug_pub.add('20 '||l_return_status ,1);
6608 END IF;
6609
6610 -- Added the logic to fix bug 2116353.
6611 IF NOT Validate_set_id
6612 (p_line_rec => p_line_rec,
6613 p_old_line_rec => p_old_line_rec) THEN
6614
6615 l_return_status := FND_API.G_RET_STS_ERROR;
6616
6617 END IF;
6618
6619 -- BUG 1282873
6620 IF OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
6621
6622 IF NVL(p_line_rec.override_atp_date_code, 'N') = 'Y' THEN
6623
6624 IF p_line_rec.schedule_ship_date IS NULL AND
6625 p_line_rec.schedule_arrival_date IS NULL AND
6626 p_line_rec.ship_set_id IS NULL AND
6627 p_line_rec.arrival_set_id IS NULL AND
6628 p_line_rec.schedule_action_code IS NULL THEN
6629
6630 -- Must have some scheduling action when you set the Override
6631 -- ATP Flag
6632 FND_MESSAGE.SET_NAME('ONT','OE_SCH_OVER_ATP_NO_SCH_ACT');
6633 OE_MSG_PUB.Add;
6634 IF l_debug_level > 0 then
6635 Oe_debug_pub.add('Missing Schedule Action',1);
6636 END IF;
6637 l_return_status := FND_API.G_RET_STS_ERROR;
6638 END IF;
6639
6640 IF (p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_SERVICE OR
6641 p_line_rec.line_category_code = 'RETURN' OR
6642 p_line_rec.source_type_code = OE_GLOBALS.G_SOURCE_EXTERNAL) THEN
6643
6644 -- Override ATP flag cannot be set for Service, Return,
6645 -- and Drop Ship Lines.
6646 FND_MESSAGE.SET_NAME('ONT', 'OE_SCH_OVER_ATP_INVLD_LINE');
6647 OE_MSG_PUB.Add;
6648 IF l_debug_level > 0 then
6649 Oe_debug_pub.add('Override ATP cannot be set for Service, Return and
6650 Drop Ship lines',1);
6651 END IF;
6652 l_return_status := FND_API.G_RET_STS_ERROR;
6653 END IF;
6654
6655 END IF; -- override atp set to Y
6656
6657 ELSE
6658
6659 IF p_line_rec.override_atp_date_code IS NOT NULL THEN
6660
6661 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
6662 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Override Atp');
6663 OE_MSG_PUB.Add;
6664 l_return_status := FND_API.G_RET_STS_ERROR;
6665 IF l_debug_level > 0 then
6666 Oe_debug_pub.add('Override ATP cannot be set prior to pack-I' ||
6667 p_line_rec.override_atp_date_code,2);
6668 END IF;
6669
6670 END IF;
6671 END IF; -- check for code release level
6672 -- END 1282873
6673
6674 IF Nvl(p_line_rec.firm_demand_flag,'N') <> FND_API.G_MISS_CHAR
6675 AND NOT OE_GLOBALS.EQUAL(p_line_rec.firm_demand_flag,
6676 p_old_line_rec.firm_demand_flag)
6677 THEN
6678 IF l_debug_level > 0 then
6679 oe_debug_pub.add('Old firm flag : ' || p_old_line_rec.firm_demand_flag,3);
6680 oe_debug_pub.add('New firm flag : ' || p_line_rec.firm_demand_flag,3);
6681 END IF;
6682 IF nvl(p_line_rec.cancelled_flag,'N') = 'Y'
6683 OR p_line_rec.shipped_quantity is NOT NULL
6684 OR p_line_rec.source_type_code = OE_GLOBALS.G_SOURCE_EXTERNAL
6685 OR p_line_rec.item_type_code = OE_GLOBALS.G_ITEM_SERVICE
6686 OR p_line_rec.line_category_code = 'RETURN'
6687 OR p_line_rec.open_flag = 'N' THEN
6688
6689 FND_MESSAGE.SET_NAME('ONT','OE_INVALID_FIRM_OPR');
6690 OE_MSG_PUB.Add;
6691 l_return_status := FND_API.G_RET_STS_ERROR;
6692
6693 END IF;
6694
6695 END IF;
6696
6697 IF p_line_rec.user_item_description IS NOT NULL
6698 AND p_line_rec.source_type_code = 'EXTERNAL'
6699 AND NOT OE_GLOBALS.EQUAL(p_line_rec.user_item_description,
6700 fnd_api.g_miss_char)
6701 AND (NOT oe_globals.equal(p_line_rec.user_item_description,
6702 p_old_line_rec.user_item_description)
6703 OR NOT oe_globals.equal(p_line_rec.source_type_code,
6704 p_old_line_rec.source_type_code))
6705 AND OE_CODE_CONTROL.Get_Code_Release_Level >= '110509' THEN
6706
6707 Validate_User_Item_Description
6708 ( p_line_rec => p_line_rec
6709 ,x_return_status => l_status);
6710
6711 IF l_status = FND_API.G_RET_STS_ERROR THEN
6712 l_return_status := FND_API.G_RET_STS_ERROR;
6713 END IF;
6714 END IF;
6715
6716 -------------------------------------------------------------------
6717 -- Validating Blankets
6718 -------------------------------------------------------------------
6719
6720 IF OE_CODE_CONTROL.Get_Code_Release_Level < '110509' THEN
6721
6722 IF (p_line_rec.blanket_number IS NOT NULL OR
6723 p_line_rec.blanket_line_number IS NOT NULL OR
6724 p_line_rec.blanket_version_number IS NOT NULL) THEN
6725 if l_debug_level > 0 then
6726 OE_DEBUG_PUB.Add('Blankets are only available in Pack I or greater',1);
6727 end if;
6728 l_return_status := FND_API.G_RET_STS_ERROR;
6729 FND_MESSAGE.Set_Name('ONT','OE_BLANKET_INVALID_VERSION');
6730 OE_MSG_PUB.Add;
6731 END IF;
6732
6733 ELSE
6734
6735 IF p_line_rec.blanket_number IS NOT NULL THEN
6736
6737 Validate_Blanket_Values
6738 (p_line_rec => p_line_rec,
6739 p_old_line_rec => p_old_line_rec,
6740 x_return_status => l_status);
6741 IF l_status = FND_API.G_RET_STS_ERROR THEN
6742 l_return_status := l_status;
6743 ELSIF l_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6744 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6745 END IF;
6746
6747 END IF;
6748
6749 END IF; --check if less than pack I
6750
6751 ---------------------------------------------------------
6752 -- Validate Pick Released Shipsets and SMC Models
6753 ---------------------------------------------------------
6754 IF p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE AND
6755 p_line_rec.booked_flag = 'Y' AND
6756 (p_line_rec.ship_set_id IS NOT NULL OR
6757 p_line_rec.ship_model_complete_flag = 'Y')
6758 THEN
6759 Validate_Shipset_SMC
6760 ( p_line_rec => p_line_rec
6761 ,p_old_line_rec => p_old_line_rec
6762 ,x_return_status => l_status);
6763
6764 IF l_status = FND_API.G_RET_STS_ERROR THEN
6765 l_return_status := l_status;
6766 ELSIF l_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6767 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6768 END IF;
6769 END IF;
6770
6771 IF p_line_rec.source_type_code = 'EXTERNAL' AND
6772 p_line_rec.booked_flag = 'Y' AND
6773 NOT OE_GLOBALS.EQUAL(p_line_rec.ordered_quantity,
6774 p_old_line_rec.ordered_quantity) THEN
6775
6776 IF l_debug_level > 0 THEN
6777 oe_debug_pub.add('dropship line - check if message reqd', 1);
6778 END IF;
6779
6780 BEGIN
6781 SELECT requisition_header_id, po_header_id
6782 --INTO l_uom_count, l_msg_count
6783 INTO l_req_header_id,l_po_header_id
6784 FROM oe_drop_ship_sources
6785 WHERE line_id = p_line_rec.line_id;
6786
6787 IF l_debug_level > 0 THEN
6788 oe_debug_pub.add(l_req_header_id || ' - '|| l_po_header_id, 1);
6789 END IF;
6790
6791 IF l_req_header_id is not null THEN
6792 l_req_status := po_releases_sv2.get_release_status(l_req_header_id);
6793 IF l_debug_level > 0 THEN
6794 oe_debug_pub.add('l_req_status- '|| l_req_status, 3);
6795 END IF;
6796
6797 IF l_req_status is null THEN
6798 po_reqs_sv2.get_reqs_auth_status
6799 (l_req_header_id,
6800 l_req_status,
6801 l_ds_req,
6802 l_ds_po);
6803
6804 l_req_status := UPPER(l_req_status);
6805 END IF;
6806
6807 END IF; -- req created
6808
6809
6810 IF l_po_header_id is not null THEN
6811
6812 -- comment out for bug 4411054
6813 /*l_po_status := UPPER(po_headers_sv3.get_po_status(l_po_header_id));
6814 IF l_debug_level > 0 THEN
6815 oe_debug_pub.add('l_po_status- '|| l_po_status, 2);
6816 END IF;*/
6817 PO_DOCUMENT_CHECKS_GRP.po_status_check
6818 (p_api_version => 1.0
6819 , p_header_id => l_po_header_id
6820 , p_mode => 'GET_STATUS'
6821 , x_po_status_rec => l_po_status_rec
6822 , x_return_status => l_return_status);
6823 IF(l_return_status = FND_API.G_RET_STS_SUCCESS) THEN
6824 l_cancel_flag := l_po_status_rec.cancel_flag(1);
6825 l_closed_code := l_po_status_rec.closed_code(1);
6826 IF l_debug_level > 0 THEN
6827 OE_DEBUG_PUB.Add('Sucess call from PO_DOCUMENT_CHECKS_GRP.po_status_check',2);
6828 OE_DEBUG_PUB.Add('Cancel_flag : '|| l_cancel_flag, 2);
6829 OE_DEBUG_PUB.Add('Closed_code : '|| l_closed_code,2);
6830 END IF;
6831 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6832 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6833 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
6834 RAISE FND_API.G_EXC_ERROR;
6835 END IF;
6836
6837 END IF; -- po created
6838
6839 IF ((INSTR(nvl(l_req_status, 'z'), 'CANCELLED') = 0 AND
6840 INSTR(nvl(l_req_status, 'z'), 'FINALLY CLOSED') = 0) OR
6841 --(INSTR(nvl(l_po_status, 'z'), 'CANCELLED') = 0 AND
6842 --INSTR(nvl(l_po_status, 'z'), 'FINALLY CLOSED') = 0)) AND
6843 (nvl(l_cancel_flag,'z')='Y' AND
6844 nvl(l_closed_code, 'z')= 'FINALLY CLOSED' )) AND
6845 (PO_CODE_RELEASE_GRP.Current_Release <
6846 PO_CODE_RELEASE_GRP.PRC_11i_Family_Pack_J AND
6847 OE_CODE_CONTROL.Code_Release_Level < '110510') THEN
6848
6849
6850 Fnd_Message.Set_Name('ONT','ONT_DS_PO_CHANGE_REQD');
6851
6852 l_ds_req := RTRIM(p_line_rec.line_number || '.' ||
6853 p_line_rec.shipment_number || '.' ||
6854 p_line_rec.option_number || '.' ||
6855 p_line_rec.component_number || '.' ||
6856 p_line_rec.service_number, '.');
6857
6858
6859 FND_Message.Set_Token('LINE_NUM', l_ds_req);
6860
6861 IF l_debug_level > 0 THEN
6862 oe_debug_pub.add('dropship line - message reqd', 1);
6863 END IF;
6864
6865 BEGIN
6866 SELECT segment1
6867 INTO l_sold_to_org
6868 FROM po_requisition_headers_all
6869 WHERE requisition_header_id = l_req_header_id;
6870
6871 FND_Message.Set_Token('REQ_NUM', l_sold_to_org);
6872 FND_Message.Set_Token('REQ_STS', nvl(l_req_status, '-'));
6873
6874 EXCEPTION
6875 WHEN OTHERS THEN
6876 null;
6877 END;
6878
6879 IF l_po_header_id is not NULL THEN
6880
6881 SELECT segment1
6882 INTO l_sold_to_org
6883 FROM po_headers_all
6884 WHERE po_header_id = l_po_header_id;
6885
6886 FND_Message.Set_Token('PO_NUM', l_sold_to_org);
6887 -- bug 4411054
6888 --FND_Message.Set_Token('PO_STS', nvl(l_po_status, '-'));
6889 FND_Message.Set_Token('PO_STS', nvl(l_closed_code, '-'));
6890
6891 ELSE
6892
6893 FND_Message.Set_Token('PO_NUM', '-');
6894 FND_Message.Set_Token('PO_STS', 'NOT CREATED');
6895 IF l_debug_level > 0 THEN
6896 oe_debug_pub.add('no po', 4);
6897 END IF;
6898 END IF;
6899
6900 OE_MSG_PUB.Add;
6901 END IF;
6902
6903 EXCEPTION
6904 WHEN NO_DATA_FOUND THEN
6905 IF l_debug_level > 0 THEN
6906 oe_debug_pub.add('dropship line - message not reqd', 4);
6907 END IF;
6908 WHEN OTHERS THEN
6909 IF l_debug_level > 0 THEN
6910 oe_debug_pub.add('dropship line - others '|| sqlerrm, 3);
6911 END IF;
6912 END;
6913 END IF; --qty change on dropship line
6914
6915 --------------------------------------------------
6916 -- Decimal Ratio Check.
6917 --------------------------------------------------
6918
6919 IF l_debug_level > 0 THEN
6920 OE_DEBUG_PUB.ADD('Before Decimal Ratio Check.. ');
6921 OE_DEBUG_PUB.add('No Decimal Check for Included Remnant Lines - 3132424',5);
6922 END IF;
6923
6924 IF (p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE OR
6925 (p_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
6926 p_line_rec.item_type_code <> 'CONFIG' )) AND
6927 (p_line_rec.top_model_line_id is NOT NULL and
6928 p_line_rec.top_model_line_id <> p_line_rec.line_id)
6929 AND NVL(p_line_rec.model_remnant_flag,'N')='N'
6930 THEN
6931 Decimal_Ratio_Check
6932 ( p_line_rec => p_line_rec
6933 ,x_return_status => l_status);
6934
6935 IF l_status = FND_API.G_RET_STS_ERROR THEN
6936 l_return_status := l_status;
6937 ELSIF l_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6938 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6939 END IF;
6940 END IF;
6941
6942 --Macd
6943 -- This is to make sure If Old value is INSTALL_BASE it should not change
6944 IF l_debug_level > 0 THEN
6945 OE_DEBUG_PUB.ADD('old rec ib_owner'||p_old_line_rec.ib_owner);
6946 OE_DEBUG_PUB.ADD('new rec ib_owner'||p_line_rec.ib_owner);
6947 OE_DEBUG_PUB.ADD('old rec ib_current_location'||p_old_line_rec.ib_current_location);
6948 OE_DEBUG_PUB.ADD('new rec ib_current_location'||p_line_rec.ib_current_location);
6949 OE_DEBUG_PUB.ADD('old rec ib_installed_at_location'||p_old_line_rec.ib_installed_at_location);
6950 OE_DEBUG_PUB.ADD('new rec ib_installed_at_location'||p_line_rec.ib_installed_at_location);
6951 END IF;
6952
6953 IF p_old_line_rec.ib_owner='INSTALL_BASE' AND
6954 NOT OE_GLOBALS.EQUAL(p_line_rec.ib_owner,p_old_line_rec.ib_owner)
6955 THEN
6956 IF l_debug_level > 0 THEN
6957 OE_DEBUG_PUB.ADD('VALIDATION FOR IB_OWNER FAILED IN OEXLLINB.pls');
6958 OE_DEBUG_PUB.ADD('OLD LINE HAS INSTALL_BASE CAN NOT CHANGE IT');
6959 END IF;
6960 l_return_status := FND_API.G_RET_STS_ERROR;
6961 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
6962 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_OWNER'));
6963 OE_MSG_PUB.Add;
6964 END IF;
6965
6966
6967 IF p_old_line_rec.ib_installed_at_location='INSTALL_BASE' AND
6968 NOT OE_GLOBALS.EQUAL(p_line_rec.ib_installed_at_location,p_old_line_rec.ib_installed_at_location)
6969 THEN
6970 IF l_debug_level > 0 THEN
6971 OE_DEBUG_PUB.ADD('VALIDATION FOR IB_INSTALLED_AT_LOCATION FAILED IN OEXLLINB.pls');
6972 OE_DEBUG_PUB.ADD('OLD LINE HAS INSTALL_BASE CAN NOT CHANGE IT');
6973 END IF;
6974 l_return_status := FND_API.G_RET_STS_ERROR;
6975 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
6976 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_INSTALLED_AT_LOCATION'));
6977 OE_MSG_PUB.Add;
6978 END IF;
6979
6980
6981 IF p_old_line_rec.ib_current_location='INSTALL_BASE' AND
6982 NOT OE_GLOBALS.EQUAL(p_line_rec.ib_current_location,p_old_line_rec.ib_current_location)
6983 THEN
6984 IF l_debug_level > 0 THEN
6985 OE_DEBUG_PUB.ADD('VALIDATION FOR IB_CURRENT_LOCATION FAILED IN OEXLLINB.pls');
6986 OE_DEBUG_PUB.ADD('OLD LINE HAS INSTALL_BASE CAN NOT CHANGE IT');
6987 END IF;
6988 l_return_status := FND_API.G_RET_STS_ERROR;
6989 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
6990 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_CURRENT_LOCATION'));
6991 OE_MSG_PUB.Add;
6992 END IF;
6993
6994 -- END OF check.
6995
6996 -- This will prevent updating the three Ib fields with the value INSTALL_BASE
6997 -- where the current value is not null
6998
6999 IF l_debug_level > 0 THEN
7000 OE_DEBUG_PUB.ADD('1 old rec ib_owner'||p_old_line_rec.ib_owner);
7001 END IF;
7002 IF p_line_rec.ib_owner='INSTALL_BASE' and p_old_line_rec.ib_owner in ('END_CUSTOMER','SOLD_TO') THEN
7003 IF l_debug_level > 0 THEN
7004 OE_DEBUG_PUB.ADD('VALIDATION FOR IB_OWNER FAILED IN OEXLLINB.pls');
7005 OE_DEBUG_PUB.ADD('TRYING TO UPDATE WITH INSTALL_BASE OLD LINE HAS SOME VALUE');
7006 END IF;
7007 l_return_status := FND_API.G_RET_STS_ERROR;
7008 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7009 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_OWNER'));
7010 OE_MSG_PUB.Add;
7011 END IF;
7012
7013 IF p_line_rec.ib_installed_at_location='INSTALL_BASE' and p_old_line_rec.ib_installed_at_location in ('BILL_TO','DELIVER_TO','END_CUSTOMER','SHIP_TO','SOLD_TO') THEN
7014 IF l_debug_level > 0 THEN
7015 OE_DEBUG_PUB.ADD('VALIDATION FOR IB_INSTALLED_AT_LOCATION FAILED IN OEXLLINB.pls');
7016 OE_DEBUG_PUB.ADD('TRYING TO UPDATE WITH INSTALL_BASE OLD LINE HAS SOME VALUE');
7017 END IF;
7018 l_return_status := FND_API.G_RET_STS_ERROR;
7019 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7020 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_INSTALLED_AT_LOCATION'));
7021 OE_MSG_PUB.Add;
7022 END IF;
7023
7024 IF p_line_rec.ib_current_location='INSTALL_BASE' and p_old_line_rec.ib_current_location in ('BILL_TO','DELIVER_TO','END_CUSTOMER','SHIP_TO','SOLD_TO') THEN
7025 IF l_debug_level > 0 THEN
7026 OE_DEBUG_PUB.ADD('VALIDATION FOR IB_CURRENT_LOCATION FAILED IN OEXLLINB.pls');
7027 OE_DEBUG_PUB.ADD('TRYING TO UPDATE WITH INSTALL_BASE OLD LINE HAS SOME VALUE');
7028 END IF;
7029 l_return_status := FND_API.G_RET_STS_ERROR;
7030 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7031 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_CURRENT_LOCATION'));
7032 OE_MSG_PUB.Add;
7033 END IF;
7034
7035 IF OE_CODE_CONTROL.GET_CODE_RELEASE_LEVEL >= '110510' THEN
7036
7037 IF p_line_rec.ib_owner='INSTALL_BASE' and p_old_line_rec.ib_owner Is NULL THEN
7038
7039 IF p_line_rec.top_model_line_id is NULL THEN -- This is not a model line
7040
7041 IF l_debug_level >0 THEN
7042 OE_DEBUG_PUB.ADD('Validation for IB_OWNER failed from OEXLLINB.pls');
7043 OE_DEBUG_PUB.ADD('THIS IS NOT A MODEL , CAN NOT HAVE INSTALL_BASE ');
7044 END IF;
7045 l_return_status := FND_API.G_RET_STS_ERROR;
7046 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7047 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_OWNER'));
7048 OE_MSG_PUB.Add;
7049
7050 END IF;
7051
7052 END IF;
7053
7054 IF p_line_rec.ib_installed_at_location='INSTALL_BASE' and p_old_line_rec.ib_installed_at_location Is NULL THEN
7055
7056 IF p_line_rec.top_model_line_id is NULL THEN -- This is not a model line
7057
7058 IF l_debug_level >0 THEN
7059 OE_DEBUG_PUB.ADD('Validation for IB_INSTALLED_AT_LOCATION failed from OEXLLINB.pls');
7060 OE_DEBUG_PUB.ADD('This is not a model , can not have INSTALL_BASE ');
7061 END IF;
7062 l_return_status := FND_API.G_RET_STS_ERROR;
7063 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7064 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_INSTALLED_AT_LOCATION'));
7065 OE_MSG_PUB.Add;
7066
7067 END IF;
7068
7069 END IF;
7070
7071
7072 IF p_line_rec.ib_current_location='INSTALL_BASE' and p_old_line_rec.ib_current_location Is NULL THEN
7073
7074 IF p_line_rec.top_model_line_id is NULL THEN -- This is not a model line
7075
7076 IF l_debug_level >0 THEN
7077 OE_DEBUG_PUB.ADD('Validation for IB_CURRENT_LOCATION failed from OEXLLINB.pls');
7078 OE_DEBUG_PUB.ADD('THIS IS NOT A MODEL , CAN NOT HAVE INSTALL_BASE ');
7079 END IF;
7080 l_return_status := FND_API.G_RET_STS_ERROR;
7081 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7082 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_CURRENT_LOCATION'));
7083 OE_MSG_PUB.Add;
7084
7085 END IF;
7086
7087 END IF;
7088
7089 END IF;
7090
7091 ----Macd
7092 -- distributed orders @
7093 IF l_debug_level > 0 THEN
7094 OE_DEBUG_PUB.ADD('old rec ib_owner:'||p_old_line_rec.ib_owner);
7095 END IF;
7096 IF p_line_rec.ib_owner IS NOT NULL AND
7097 (NOT OE_GLOBALS.EQUAL(p_line_rec.ib_owner,p_old_line_rec.ib_owner)
7098 OR NOT OE_GLOBALS.EQUAL(p_line_rec.sold_to_org_id, p_old_line_rec.sold_to_org_id)
7099 OR NOT OE_GLOBALS.EQUAL(p_line_rec.end_customer_id, p_old_line_rec.end_customer_id)
7100 OR p_old_line_rec.ib_owner IS NULL )
7101 THEN
7102 IF p_line_rec.ib_owner = 'END_CUSTOMER' AND
7103 p_line_rec.end_customer_id is null
7104 THEN
7105 IF l_debug_level >0 THEN
7106 OE_DEBUG_PUB.ADD('end customer id is null but value is end_customer!');
7107 END IF;
7108 l_return_status := FND_API.G_RET_STS_ERROR;
7109 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7110 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_OWNER'));
7111 OE_MSG_PUB.Add;
7112
7113 ELSIF p_line_rec.ib_owner = 'SOLD_TO' AND
7114 p_line_rec.sold_to_org_id is null
7115 THEN
7116 IF l_debug_level >0 THEN
7117 OE_DEBUG_PUB.ADD(' sold_to_org_id is null but value is sold_to!');
7118 END IF;
7119 l_return_status := FND_API.G_RET_STS_ERROR;
7120 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7121 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_OWNER'));
7122 OE_MSG_PUB.Add;
7123 END IF;
7124 END IF;
7125 IF l_debug_level > 0 then
7126 oe_debug_pub.ADD('ib_installed_at_location: '||p_line_rec.ib_installed_at_location);
7127 END IF;
7128
7129 IF p_line_rec.ib_installed_at_location IS NOT NULL AND
7130 (NOT OE_GLOBALS.EQUAL(p_line_rec.ib_installed_at_location,p_old_line_rec.ib_installed_at_location)
7131 OR NOT OE_GLOBALS.EQUAL(p_line_rec.invoice_to_org_id ,p_old_line_rec.invoice_to_org_id)
7132 OR NOT OE_GLOBALS.EQUAL(p_line_rec.ship_to_org_id ,p_old_line_rec.ship_to_org_id)
7133 OR NOT OE_GLOBALS.EQUAL(p_line_rec.deliver_to_org_id ,p_old_line_rec.deliver_to_org_id)
7134 OR NOT OE_GLOBALS.EQUAL(p_line_rec.end_customer_site_use_id ,p_old_line_rec.end_customer_site_use_id)
7135 OR p_old_line_rec.ib_installed_at_location IS NULL )
7136 THEN
7137 IF p_line_rec.ib_installed_at_location = 'BILL_TO' AND
7138 p_line_rec.invoice_to_org_id is null
7139 THEN
7140 IF l_debug_level >0 THEN
7141 OE_DEBUG_PUB.ADD(' bill_to_org_id is null but value is bill_to!');
7142 END IF;
7143 l_return_status := FND_API.G_RET_STS_ERROR;
7144 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7145 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_INSTALLED_AT_LOCATION'));
7146 OE_MSG_PUB.Add;
7147
7148 ELSIF p_line_rec.ib_installed_at_location = 'SHIP_TO' AND
7149 p_line_rec.ship_to_org_id is null
7150 THEN
7151 IF l_debug_level >0 THEN
7152 OE_DEBUG_PUB.ADD(' ship_to_org_id is null but value is ship_to!');
7153 END IF;
7154 l_return_status := FND_API.G_RET_STS_ERROR;
7155 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7156 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_INSTALLED_AT_LOCATION'));
7157 OE_MSG_PUB.Add;
7158
7159 ELSIF p_line_rec.ib_installed_at_location = 'DELIVER_TO' AND
7160 p_line_rec.deliver_to_org_id is null
7161 THEN
7162 IF l_debug_level >0 THEN
7163 OE_DEBUG_PUB.ADD(' deliver_to_org_id is null but value is deliver_to!');
7164 END IF;
7165 l_return_status := FND_API.G_RET_STS_ERROR;
7166 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7167 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_INSTALLED_AT_LOCATION'));
7168 OE_MSG_PUB.Add;
7169 ELSIF p_line_rec.ib_installed_at_location = 'END_CUSTOMER' AND
7170 p_line_rec.end_customer_site_use_id is null
7171 THEN
7172 IF l_debug_level >0 THEN
7173 OE_DEBUG_PUB.ADD('end customer id is null but value is end_customer!');
7174 END IF;
7175 l_return_status := FND_API.G_RET_STS_ERROR;
7176 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7177 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_INSTALLED_AT_LOCATION'));
7178 OE_MSG_PUB.Add;
7179
7180 -- no validation for SOLD_TO
7181 -- since no line level sold_to_site_use_id
7182 -- REMOVE after LOV is fixed
7183 ELSIF p_line_rec.ib_installed_at_location = 'SOLD_TO'
7184 AND OE_Order_Cache.g_header_rec.sold_to_site_use_id is null
7185 THEN
7186 l_return_status := FND_API.G_RET_STS_ERROR;
7187 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7188 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_INSTALLED_AT_LOCATION'));
7189 OE_MSG_PUB.Add;
7190
7191 END IF;
7192 END IF;
7193 IF l_debug_level > 0 then
7194 oe_debug_pub.ADD('ib_current_location: '||p_line_rec.ib_current_location);
7195 END IF;
7196
7197 IF p_line_rec.ib_current_location IS NOT NULL AND
7198 (NOT OE_GLOBALS.EQUAL(p_line_rec.ib_current_location, p_old_line_rec.ib_current_location)
7199 OR NOT OE_GLOBALS.EQUAL(p_line_rec.invoice_to_org_id ,p_old_line_rec.invoice_to_org_id)
7200 OR NOT OE_GLOBALS.EQUAL(p_line_rec.ship_to_org_id ,p_old_line_rec.ship_to_org_id)
7201 OR NOT OE_GLOBALS.EQUAL(p_line_rec.deliver_to_org_id ,p_old_line_rec.deliver_to_org_id)
7202 OR NOT OE_GLOBALS.EQUAL(p_line_rec.end_customer_site_use_id ,p_old_line_rec.end_customer_site_use_id)
7203 OR p_old_line_rec.ib_current_location IS NULL )
7204 THEN
7205 IF p_line_rec.ib_current_location = 'BILL_TO' AND
7206 p_line_rec.invoice_to_org_id is null
7207 THEN
7208 IF l_debug_level >0 THEN
7209 OE_DEBUG_PUB.ADD(' bill_to_org_id is null but value is bill_to!');
7210 END IF;
7211 l_return_status := FND_API.G_RET_STS_ERROR;
7212 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7213 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_CURRENT_LOCATION'));
7214 OE_MSG_PUB.Add;
7215
7216 ELSIF p_line_rec.ib_current_location = 'SHIP_TO' AND
7217 p_line_rec.ship_to_org_id is null
7218 THEN
7219 IF l_debug_level >0 THEN
7220 OE_DEBUG_PUB.ADD(' ship_to_org_id is null but value is ship_to!');
7221 END IF;
7222 l_return_status := FND_API.G_RET_STS_ERROR;
7223 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7224 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_CURRENT_LOCATION'));
7225 OE_MSG_PUB.Add;
7226
7227 ELSIF p_line_rec.ib_current_location = 'DELIVER_TO' AND
7228 p_line_rec.deliver_to_org_id is null
7229 THEN
7230 l_return_status := FND_API.G_RET_STS_ERROR;
7231 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7232 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_CURRENT_LOCATION'));
7233 OE_MSG_PUB.Add;
7234
7235 ELSIF p_line_rec.ib_current_location = 'END_CUSTOMER' AND
7236 p_line_rec.end_customer_site_use_id is null
7237 THEN
7238 l_return_status := FND_API.G_RET_STS_ERROR;
7239 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7240 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_CURRENT_LOCATION'));
7241 OE_MSG_PUB.Add;
7242
7243 -- no validation for SOLD_TO
7244 -- since no line level sold_to_site_use_id
7245 -- REMOVE after LOV is fixed
7246 ELSIF p_line_rec.ib_current_location = 'SOLD_TO'
7247 AND OE_Order_Cache.g_header_rec.sold_to_site_use_id is null
7248 THEN
7249 l_return_status := FND_API.G_RET_STS_ERROR;
7250 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7251 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',OE_Order_UTIL.Get_attribute_name('IB_CURRENT_LOCATION'));
7252 OE_MSG_PUB.Add;
7253
7254
7255 END IF;
7256 END IF;
7257
7258 -- end customer contact id depends on end customer id
7259 IF p_line_rec.end_customer_contact_id IS NOT NULL AND
7260 ( NOT OE_GLOBALS.EQUAL(p_line_rec.end_customer_contact_id
7261 ,p_old_line_rec.end_customer_contact_id) OR
7262 NOT OE_GLOBALS.EQUAL(p_line_rec.end_customer_id
7263 ,p_old_line_rec.end_customer_id))
7264 THEN
7265
7266 BEGIN
7267
7268 SELECT 'VALID'
7269 INTO l_dummy
7270 FROM
7271 HZ_CUST_ACCOUNT_ROLES ACCT_ROLE
7272 WHERE
7273 ACCT_ROLE.CUST_ACCOUNT_ROLE_ID = p_line_rec.end_customer_contact_id
7274 AND ACCT_ROLE.CUST_ACCOUNT_ID = p_line_rec.end_customer_id
7275 AND ROWNUM = 1
7276 AND ACCT_ROLE.ROLE_TYPE = 'CONTACT'
7277 AND STATUS= 'A';
7278
7279 -- Valid Sold To Contact
7280
7281 EXCEPTION
7282
7283 WHEN NO_DATA_FOUND THEN
7284 l_return_status := FND_API.G_RET_STS_ERROR;
7285 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7286 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
7287 OE_Order_Util.Get_Attribute_Name('END_CUSTOMER_CONTACT_ID'));
7288 OE_MSG_PUB.Add;
7289
7290 WHEN OTHERS THEN
7291 IF OE_MSG_PUB.Check_Msg_Level
7292 ( OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
7293 THEN
7294 OE_MSG_PUB.Add_Exc_Msg
7295 ( G_PKG_NAME ,
7296 'Record - End Customer Contact'
7297 );
7298 END IF;
7299
7300 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7301
7302 END; -- BEGIN
7303
7304 END IF; -- End Customer contact needed validation.
7305
7306 IF p_line_rec.end_customer_site_use_id IS NOT NULL AND
7307 ( NOT OE_GLOBALS.EQUAL(p_line_rec.end_customer_site_use_id
7308 ,p_old_line_rec.end_customer_id) OR
7309 NOT OE_GLOBALS.EQUAL(p_line_rec.end_customer_id
7310 ,p_old_line_rec.end_customer_id))
7311 THEN
7312
7313 BEGIN
7314
7315 SELECT /* MOAC_SQL_CHANGE */ 'VALID'
7316 INTO
7317 l_dummy
7318 FROM
7319 hz_cust_site_uses_all site_use,
7320 hz_cust_acct_sites acct_site
7321 WHERE
7322 site_use.site_use_id=p_line_rec.end_customer_site_use_id
7323 and site_use.cust_acct_site_id=acct_site.cust_acct_site_id
7324 and acct_site.cust_account_id=p_line_rec.end_customer_id;
7325
7326 -- Valid End customer site
7327
7328 EXCEPTION
7329
7330 WHEN NO_DATA_FOUND THEN
7331 l_return_status := FND_API.G_RET_STS_ERROR;
7332 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7333 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
7334 OE_Order_Util.Get_Attribute_Name('END_CUSTOMER_SITE_USE_ID'));
7335 OE_MSG_PUB.Add;
7336
7337 WHEN OTHERS THEN
7338 IF OE_MSG_PUB.Check_Msg_Level
7339 ( OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
7340 THEN
7341 OE_MSG_PUB.Add_Exc_Msg
7342 ( G_PKG_NAME ,
7343 'Record - End Customer Site'
7344 );
7345 END IF;
7346
7347 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7348
7349 END; -- BEGIN
7350
7351 END IF; -- End Customer site needed validation.
7352 IF l_debug_level > 0 then
7353 oe_debug_pub.add('Top Model line:'||p_line_rec.top_model_line_id, 4);
7354 oe_debug_pub.add('Validate cfg? :'||OE_CONFIG_PVT.OECFG_VALIDATE_CONFIG, 4);
7355 oe_debug_pub.add('Return status before MACD Logic:'||l_return_status,4);
7356 END IF;
7357
7358 IF OE_CODE_CONTROL.GET_CODE_RELEASE_LEVEL >= '110510' AND
7359 p_line_rec.top_model_line_id is NOT NULL THEN
7360
7361 IF l_debug_level > 0 THEN
7362 OE_DEBUG_PUB.Add('MACD Logic, calling Validate_Container_model',3);
7363 END IF;
7364
7365 --bug3314488
7366 --must use l_status as return variable so that value in
7367 --l_return_status is not overridden by the output of
7368 --Validate_Container_Model procedure
7369 OE_CONFIG_TSO_PVT.Validate_Container_Model
7370 ( p_line_rec => p_line_rec
7371 ,p_old_line_rec => p_old_line_rec
7372 --,x_return_status => l_return_status );
7373 ,x_return_status => l_status );
7374
7375 IF l_status = FND_API.G_RET_STS_ERROR THEN
7376 IF l_debug_level > 0 THEN
7377 OE_DEBUG_PUB.Add('Error in Validate_Container_Model',2);
7378 END IF;
7379 l_return_status := l_status;
7380 ELSIF l_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7381 IF l_debug_level > 0 THEN
7382 OE_DEBUG_PUB.Add('Unexpected error in Validate_Container_Model',1); END IF;
7383 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7384 END IF;
7385 --end of bug3314488 fix
7386 ELSE
7387 IF l_debug_level > 0 then
7388 OE_DEBUG_PUB.Add('Not part of model||Not in 110510 - no MACD logic',3);
7389 END IF;
7390 END IF;
7391
7392 IF l_debug_level > 0 THEN
7393 oe_debug_pub.add('Return status after MACD Logic:'||l_return_status,4);
7394 END IF;
7395
7396 --{ Recurring Charges operation create or update of periodicity
7397 IF p_line_rec.charge_periodicity_code <> FND_API.G_MISS_CHAR AND
7398 NOT OE_GLOBALS.Equal(p_line_rec.charge_periodicity_code,
7399 p_old_line_rec.charge_periodicity_code) THEN
7400
7401 IF l_debug_level > 0 THEN
7402 OE_DEBUG_PUB.Add ('Line has changed recurring charges:'
7403 ||p_line_rec.charge_periodicity_code,3);
7404 END IF;
7405
7406 IF OE_Validate.Charge_Periodicity (p_line_rec.charge_periodicity_code) THEN
7407
7408 IF OE_SYS_PARAMETERS.Value ('RECURRING_CHARGES') = 'Y' THEN
7409
7410 IF p_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
7411
7412 IF p_line_rec.top_model_line_id IS NOT NULL THEN
7413 OE_CONFIG_TSO_PVT.Is_Part_Of_Container_Model
7414 ( p_top_model_line_id => p_line_rec.top_model_line_id
7415 ,p_inventory_item_id => p_line_rec.inventory_item_id
7416 ,p_line_id => p_line_rec.line_id
7417 ,p_operation => p_line_rec.operation
7418 ,x_top_container_model => l_top_container_model
7419 ,x_part_of_container => l_part_of_container
7420 );
7421 ELSE
7422 l_part_of_container := 'N';
7423 END IF;
7424
7425 IF l_part_of_container = 'N' OR
7426 l_top_container_model = 'Y' THEN
7427 IF l_debug_level > 0 THEN
7428 OE_DEBUG_PUB.Add('ERR: Line not child of container model',2);
7429 OE_DEBUG_PUB.Add('Line should not have charge periodicity',1);
7430 OE_DEBUG_PUB.Add('Line ID:'||p_line_rec.line_id,1);
7431 END IF;
7432
7433 --SELECT description
7434 --INTO l_item_description
7435 --FROM MTL_SYSTEM_ITEMS mtl_msi
7436 --WHERE mtl_msi.inventory_item_id = p_line_rec.inventory_item_id
7437 --AND mtl_msi.organization_id =
7438 -- OE_SYS_PARAMETERS.VALUE('MASTER_ORGANIZATION_ID');
7439
7440 FND_MESSAGE.SET_NAME('ONT','ONT_NO_RC_ALLOWED');
7441 --FND_MESSAGE.SET_TOKEN('ITEM',l_item_description);
7442 OE_MSG_PUB.Add;
7443 RAISE FND_API.G_EXC_ERROR;
7444 END IF;
7445 END IF; --operation CREATE
7446
7447 IF p_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
7448 OE_GLOBALS.Equal (p_line_rec.inventory_item_id,
7449 p_old_line_rec.inventory_item_id) THEN
7450
7451 IF l_debug_level > 0 THEN
7452 OE_DEBUG_PUB.Add('Line ID:'||p_line_rec.line_id,2);
7453 OE_DEBUG_PUB.Add('Line Num:'||p_line_rec.line_number,2);
7454 OE_DEBUG_PUB.Add('ERR: Update of charge periodicity',3);
7455 END IF;
7456
7457 FND_MESSAGE.SET_NAME('ONT','ONT_NO_UPDATE_ON_PERIODICITY');
7458 FND_MESSAGE.SET_TOKEN('LINE_NUM',p_line_rec.line_number);
7459 OE_MSG_PUB.Add;
7460 RAISE FND_API.G_EXC_ERROR;
7461
7462 END IF;
7463 ELSE --recurring charges system paramter is N
7464 IF l_debug_level > 0 THEN
7465 OE_DEBUG_PUB.Add('ERR: Recurring Charges SYS Param is disabled');
7466 END IF;
7467 FND_MESSAGE.SET_NAME('ONT','ONT_RECUR_CHARGES_NOT_ENABLED');
7468 OE_MSG_PUB.Add;
7469 RAISE FND_API.G_EXC_ERROR;
7470
7471 END IF;
7472 ELSE -- Invalid charge_periodicity
7473 l_return_status := FND_API.G_RET_STS_ERROR;
7474 END IF;
7475 END IF;
7476 -- Recurring Charges }
7477 --Shifted the code from procedure attributes to procedure entity as this is a cross attribute validation
7478 --for bug4963691
7479 --Added for bug 4905987 start
7480
7481 IF p_line_rec.item_type_code <>'SERVICE'
7482 AND NOT (l_rule_type = 'PP_DR_PP' OR l_rule_type = 'PP_DR_ALL') -- webroot bug 6826344 modified start
7483 then
7484
7485 if p_line_rec.service_duration is not null and p_line_rec.service_duration <>FND_API.G_MISS_NUM then
7486 l_return_status := FND_API.G_RET_STS_ERROR;
7487 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7488 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
7489 OE_Order_UTIL.Get_Attribute_Name('SERVICE_DURATION'));
7490 OE_MSG_PUB.ADD;
7491 end if;
7492
7493 if p_line_rec.service_period is not null and p_line_rec.service_period <>FND_API.G_MISS_CHAR then
7494 l_return_status := FND_API.G_RET_STS_ERROR;
7495 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7496 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
7497 OE_Order_UTIL.Get_Attribute_Name('SERVICE_PERIOD'));
7498 OE_MSG_PUB.ADD;
7499 end if;
7500
7501 if p_line_rec.service_start_date is not null and p_line_rec.service_start_date <>FND_API.G_MISS_DATE then
7502 l_return_status := FND_API.G_RET_STS_ERROR;
7503 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7504 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
7505 OE_Order_UTIL.Get_Attribute_Name('SERVICE_START_DATE'));
7506 OE_MSG_PUB.ADD;
7507 end if;
7508
7509 if p_line_rec.service_end_date is not null and p_line_rec.service_end_date <>FND_API.G_MISS_DATE then
7510 l_return_status := FND_API.G_RET_STS_ERROR;
7511 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7512 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
7513 OE_Order_UTIL.Get_Attribute_Name('SERVICE_END_DATE'));
7514 OE_MSG_PUB.ADD;
7515 end if;
7516
7517 -- webroot bug 6826344 added start
7518 END IF;
7519
7520 IF p_line_rec.item_type_code <>'SERVICE' then
7521
7522 -- webroot bug 6826344 added end
7523
7524 if p_line_rec.service_txn_comments is not null and p_line_rec.service_txn_comments <>FND_API.G_MISS_CHAR then
7525 l_return_status := FND_API.G_RET_STS_ERROR;
7526 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7527 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
7528 OE_Order_UTIL.Get_Attribute_Name('SERVICE_TXN_COMMENTS'));
7529 OE_MSG_PUB.ADD;
7530 end if;
7531
7532 if p_line_rec.service_txn_reason_code is not null and p_line_rec.service_txn_reason_code <>FND_API.G_MISS_CHAR then
7533 l_return_status := FND_API.G_RET_STS_ERROR;
7534 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7535 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
7536 OE_Order_UTIL.Get_Attribute_Name('SERVICE_TXN_REASON_CODE'));
7537 OE_MSG_PUB.ADD;
7538 end if;
7539
7540 if p_line_rec.service_coterminate_flag is not null and p_line_rec.service_coterminate_flag <>FND_API.G_MISS_CHAR then
7541 l_return_status := FND_API.G_RET_STS_ERROR;
7542 fnd_message.set_name('ONT','OE_INVALID_ATTRIBUTE');
7543 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
7544 OE_Order_UTIL.Get_Attribute_Name('SERVICE_COTERMINATE_FLAG'));
7545 OE_MSG_PUB.ADD;
7546 end if;
7547 end if;
7548
7549 --PP Revenue Recognition
7550 --bug 4893057
7551 -- webroot bug 6826344 modified the condition
7552 IF p_line_rec.item_type_code NOT IN ('SERVICE', 'STANDARD') THEN
7553 IF p_line_rec.accounting_rule_id <> FND_API.G_MISS_NUM AND
7554 p_line_rec.accounting_rule_id IS NOT NULL THEN
7555 IF l_debug_level > 0 THEN
7556 oe_debug_pub.add('Getting accounting rule type');
7557 END IF;
7558 SELECT type
7559 INTO l_rule_type
7560 FROM ra_rules
7561 WHERE rule_id = p_line_rec.accounting_rule_id;
7562 IF l_debug_level > 0 THEN
7563 oe_debug_pub.add('Rule Type is :'||l_rule_type);
7564 END IF;
7565 IF l_rule_type = 'PP_DR_ALL' or l_rule_type = 'PP_DR_PP' THEN
7566 l_return_status := FND_API.G_RET_STS_ERROR;
7567 FND_MESSAGE.Set_Name('ONT','OE_INVALID_ATTRIBUTE');
7568 FND_MESSAGE.SET_TOKEN('ATTRIBUTE',
7569 OE_Order_Util.Get_Attribute_Name('ACCOUNTING_RULE_ID'));
7570 OE_MSG_PUB.ADD;
7571 END IF; --End of rule type
7572 END IF;--End of accounting type id is not null
7573 END IF; --End of item type not Service
7574 --PP Revenue Recognition
7575 --bug 4893057
7576
7577 IF p_line_rec.item_type_code='SERVICE' and p_line_rec.service_period is not null and p_line_rec.service_period <>FND_API.G_MISS_CHAR then
7578 declare
7579 l_uom varchar2(3);
7580 begin
7581 /*Modified the query for bug # 4955363*/
7582 IF p_line_rec.ship_from_org_id = FND_API.G_MISS_NUM or p_line_rec.ship_from_org_id is NULL
7583 THEN
7584 SELECT uom_code
7585 INTO l_uom
7586 FROM mtl_item_uoms_view
7587 WHERE inventory_item_id = p_line_rec.inventory_item_id
7588 and uom_code=p_line_rec.service_period
7589 AND organization_id = l_mast_org_id
7590 and rownum=1;
7591
7592 ELSE
7593 SELECT uom_code
7594 INTO l_uom
7595 FROM mtl_item_uoms_view
7596 WHERE inventory_item_id = p_line_rec.inventory_item_id
7597 and uom_code=p_line_rec.service_period
7598 AND organization_id = p_line_rec.ship_from_org_id
7599 and rownum=1;
7600
7601 END IF;
7602
7603 exception
7604 when no_data_found then
7605 begin
7606 /*Modified the query for bug # 4955363*/
7607 IF p_line_rec.ship_from_org_id = FND_API.G_MISS_NUM or p_line_rec.ship_from_org_id is NULL
7608 THEN
7609 SELECT primary_uom_code
7610 INTO l_uom
7611 FROM mtl_system_items_b
7612 WHERE inventory_item_id = p_line_rec.inventory_item_id
7613 AND organization_id = l_mast_org_id
7614 and rownum=1;
7615 ELSE
7616 SELECT primary_uom_code
7617 INTO l_uom
7618 FROM mtl_system_items_b
7619 WHERE inventory_item_id = p_line_rec.inventory_item_id
7620 AND organization_id = p_line_rec.ship_from_org_id
7621 and rownum=1;
7622 END IF;
7623
7624 fnd_message.set_name('ONT','OE_INVALID_ORDER_QUANTITY_UOM');
7625 fnd_message.set_token('ITEM',nvl(p_line_rec.ordered_item,p_line_rec.inventory_item_id));
7626 fnd_message.set_token('UOM', l_uom);
7627 l_return_status := FND_API.G_RET_STS_ERROR;
7628 OE_MSG_PUB.ADD;
7629 exception
7630 when no_data_found then
7631 IF l_debug_level > 0 then
7632 oe_debug_pub.add('OEXLLINB, no_data_found in service period validation', 1);
7633 END IF;
7634 RAISE FND_API.G_EXC_ERROR;
7635 end;
7636 end ;
7637 end if;
7638 --Added for bug 4905987 end
7639
7640
7641 -- Please do not add code below this procedure. This has to be the last
7642 -- procedure in ENTITY
7643 IF G_REDEFAULT_MISSING = 'Y' AND
7644 l_return_status = FND_API.G_RET_STS_SUCCESS
7645 THEN
7646 IF l_debug_level > 0 then
7647 oe_debug_pub.add('Inside G_REDEFAULT_MISSING',4);
7648 END IF;
7649
7650 -- Need to Call Oe_Order_Pvt.Lines to re-default missing attributes
7651
7652 l_control_rec.controlled_operation := TRUE;
7653 l_control_rec.check_security := TRUE;
7654 l_control_rec.clear_dependents := TRUE;
7655 l_control_rec.default_attributes := TRUE;
7656 l_control_rec.change_attributes := TRUE;
7657 l_control_rec.validate_entity := TRUE;
7658 l_control_rec.write_to_DB := FALSE;
7659 l_control_rec.process := FALSE;
7660
7661
7662 l_old_line_tbl(1) := l_old_line_rec;
7663 l_line_tbl(1) := p_line_rec;
7664
7665 Oe_Order_Pvt.Lines
7666 ( p_validation_level => FND_API.G_VALID_LEVEL_NONE
7667 , p_control_rec => l_control_rec
7668 , p_x_line_tbl => l_line_tbl
7669 , p_x_old_line_tbl => l_old_line_tbl
7670 , x_return_status => l_return_status
7671 );
7672
7673 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
7674 RAISE FND_API.G_EXC_ERROR;
7675 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7676 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7677 END IF;
7678
7679 p_line_rec := l_line_tbl(1);
7680
7681 END IF;
7682 x_return_status := l_return_status;
7683
7684 -- Done validating entity
7685 IF l_debug_level > 0 then
7686 oe_debug_pub.add('Exit OE_VALIDATE_LINE.ENTITY ' || x_return_status,1);
7687 END IF;
7688 EXCEPTION
7689
7690 WHEN FND_API.G_EXC_ERROR THEN
7691
7692 x_return_status := FND_API.G_RET_STS_ERROR;
7693
7694 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7695
7696 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7697
7698 WHEN OTHERS THEN
7699
7700 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7701
7702 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
7703 THEN
7704 OE_MSG_PUB.Add_Exc_Msg
7705 ( G_PKG_NAME
7706 , 'Entity'
7707 );
7708 END IF;
7709
7710 END Entity;
7711
7712 -- Procedure Attributes
7713
7714 PROCEDURE Attributes
7715 ( x_return_status OUT NOCOPY VARCHAR2
7716
7717 , p_x_line_rec IN OUT NOCOPY OE_Order_PUB.Line_Rec_Type
7718 , p_old_line_rec IN OE_Order_PUB.Line_Rec_Type :=
7719 OE_Order_PUB.G_MISS_LINE_REC
7720 , p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL
7721 )
7722 IS
7723 l_return_status VARCHAR2(1);
7724 l_header_rec OE_Order_PUB.Header_Rec_Type;
7725 l_type_code VARCHAR2(30);
7726 l_header_created BOOLEAN := FALSE;
7727 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
7728
7729 BEGIN
7730 IF l_debug_level > 0 then
7731 oe_debug_pub.add('Enter procedure OE_validate_line.Attributes',1);
7732 END IF;
7733 x_return_status := FND_API.G_RET_STS_SUCCESS;
7734 l_return_status := FND_API.G_RET_STS_SUCCESS;
7735
7736 -- Compare line attributes with header record if the header record is
7737 -- created in the same call to process_order. If they match
7738 -- then no need to re-validate line attributes.
7739
7740 IF OE_GLOBALS.G_HEADER_CREATED
7741 THEN
7742 IF l_debug_level > 0 then
7743 oe_debug_pub.add('Header has got created in the same call',1);
7744 END IF;
7745 OE_Order_Cache.Load_Order_Header(p_x_line_rec.header_id);
7746 l_header_created := TRUE;
7747 END IF;
7748
7749 -- Validate line attributes
7750
7751 IF p_x_line_rec.accounting_rule_id IS NOT NULL AND
7752 ( p_x_line_rec.accounting_rule_id <>
7753 p_old_line_rec.accounting_rule_id OR
7754 p_old_line_rec.accounting_rule_id IS NULL )
7755 THEN
7756 IF NOT(l_header_created) OR
7757 (l_header_created AND
7758 NOT OE_GLOBALS.EQUAL(p_x_line_rec.accounting_rule_id,
7759 OE_Order_Cache.g_header_rec.accounting_rule_id ))
7760 THEN
7761 IF l_debug_level > 0 then
7762 oe_debug_pub.add('Calling OE_VALIDATE for accounting_rule',1);
7763 END IF;
7764 IF NOT OE_Validate.Accounting_Rule(p_x_line_rec.accounting_rule_id) THEN
7765 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
7766 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7767 p_x_line_rec.accounting_rule_id := NULL;
7768 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
7769 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7770 p_x_line_rec.accounting_rule_id := FND_API.G_MISS_NUM;
7771 ELSE
7772 x_return_status := FND_API.G_RET_STS_ERROR;
7773 END IF;
7774 END IF;
7775
7776 END IF;
7777 END IF;
7778
7779 IF p_x_line_rec.accounting_rule_duration IS NOT NULL AND
7780 ( p_x_line_rec.accounting_rule_duration <>
7781 p_old_line_rec.accounting_rule_duration OR
7782 p_old_line_rec.accounting_rule_duration IS NULL )
7783 THEN
7784 IF NOT(l_header_created) OR
7785 (l_header_created AND
7786 NOT OE_GLOBALS.EQUAL(p_x_line_rec.accounting_rule_duration,
7787 OE_Order_Cache.g_header_rec.accounting_rule_duration ))
7788 THEN
7789 IF l_debug_level > 0 then
7790 oe_debug_pub.add('Calling OE_VALIDATE for accounting_rule_duration',1);
7791 END IF;
7792 IF NOT OE_Validate.Accounting_Rule_Duration(p_x_line_rec.accounting_rule_duration) THEN
7793 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
7794 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7795 p_x_line_rec.accounting_rule_duration := NULL;
7796 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
7797 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7798 p_x_line_rec.accounting_rule_duration := FND_API.G_MISS_NUM;
7799 ELSE
7800 x_return_status := FND_API.G_RET_STS_ERROR;
7801 END IF;
7802 END IF;
7803
7804 END IF;
7805 END IF;
7806
7807 IF p_x_line_rec.agreement_id IS NOT NULL AND
7808 ( p_x_line_rec.agreement_id <>
7809 p_old_line_rec.agreement_id OR
7810 p_old_line_rec.agreement_id IS NULL )
7811 THEN
7812 IF NOT(l_header_created) OR
7813 (l_header_created AND
7814 NOT OE_GLOBALS.EQUAL(p_x_line_rec.agreement_id,
7815 OE_Order_Cache.g_header_rec.agreement_id ))
7816 THEN
7817
7818 IF NOT OE_Validate.Agreement(p_x_line_rec.agreement_id) THEN
7819 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
7820 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7821 p_x_line_rec.agreement_id := NULL;
7822 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
7823 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7824 p_x_line_rec.agreement_id := FND_API.G_MISS_NUM;
7825 ELSE
7826 x_return_status := FND_API.G_RET_STS_ERROR;
7827 END IF;
7828 END IF;
7829
7830 END IF;
7831 END IF;
7832
7833
7834 IF p_x_line_rec.deliver_to_contact_id IS NOT NULL AND
7835 ( p_x_line_rec.deliver_to_contact_id <>
7836 p_old_line_rec.deliver_to_contact_id OR
7837 p_old_line_rec.deliver_to_contact_id IS NULL )
7838 THEN
7839 IF NOT(l_header_created) OR
7840 (l_header_created AND
7841 NOT OE_GLOBALS.EQUAL(p_x_line_rec.deliver_to_contact_id,
7842 OE_Order_Cache.g_header_rec.deliver_to_contact_id ))
7843 THEN
7844
7845 IF NOT OE_Validate.Deliver_To_Contact(p_x_line_rec.deliver_to_contact_id) THEN
7846 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
7847 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7848 p_x_line_rec.deliver_to_contact_id := NULL;
7849 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
7850 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE
7851 THEN
7852 p_x_line_rec.deliver_to_contact_id := FND_API.G_MISS_NUM;
7853 ELSE
7854 x_return_status := FND_API.G_RET_STS_ERROR;
7855 END IF;
7856 END IF;
7857
7858 END IF;
7859 END IF;
7860
7861 IF p_x_line_rec.deliver_to_org_id IS NOT NULL AND
7862 ( p_x_line_rec.deliver_to_org_id <>
7863 p_old_line_rec.deliver_to_org_id OR
7864 p_old_line_rec.deliver_to_org_id IS NULL )
7865 THEN
7866 IF NOT(l_header_created) OR
7867 (l_header_created AND
7868 NOT OE_GLOBALS.EQUAL(p_x_line_rec.deliver_to_org_id,
7869 OE_Order_Cache.g_header_rec.deliver_to_org_id ))
7870 THEN
7871
7872 IF NOT OE_Validate.Deliver_To_Org(p_x_line_rec.deliver_to_org_id) THEN
7873 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
7874 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7875 p_x_line_rec.deliver_to_org_id := NULL;
7876 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
7877 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE
7878 THEN
7879 p_x_line_rec.deliver_to_org_id := FND_API.G_MISS_NUM;
7880 ELSE
7881 x_return_status := FND_API.G_RET_STS_ERROR;
7882 END IF;
7883 END IF;
7884
7885 END IF;
7886 END IF;
7887
7888 IF p_x_line_rec.demand_class_code IS NOT NULL AND
7889 ( p_x_line_rec.demand_class_code <>
7890 p_old_line_rec.demand_class_code OR
7891 p_old_line_rec.demand_class_code IS NULL )
7892 THEN
7893 IF NOT(l_header_created) OR
7894 (l_header_created AND
7895 NOT OE_GLOBALS.EQUAL(p_x_line_rec.demand_class_code,
7896 OE_Order_Cache.g_header_rec.demand_class_code ))
7897 THEN
7898
7899 IF NOT OE_Validate.Demand_Class(p_x_line_rec.demand_class_code) THEN
7900 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
7901 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7902 p_x_line_rec.demand_class_code := NULL;
7903 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
7904 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7905 p_x_line_rec.demand_class_code := FND_API.G_MISS_CHAR;
7906 ELSE
7907 x_return_status := FND_API.G_RET_STS_ERROR;
7908 END IF;
7909 END IF;
7910
7911 END IF;
7912 END IF;
7913
7914 IF p_x_line_rec.dep_plan_required_flag IS NOT NULL AND
7915 ( p_x_line_rec.dep_plan_required_flag <>
7916 p_old_line_rec.dep_plan_required_flag OR
7917 p_old_line_rec.dep_plan_required_flag IS NULL )
7918 THEN
7919 IF NOT OE_Validate.Dep_Plan_Required(p_x_line_rec.dep_plan_required_flag) THEN
7920 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
7921 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7922 p_x_line_rec.dep_plan_required_flag := NULL;
7923 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
7924 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7925 p_x_line_rec.dep_plan_required_flag := FND_API.G_MISS_CHAR;
7926 ELSE
7927 x_return_status := FND_API.G_RET_STS_ERROR;
7928 END IF;
7929 END IF;
7930 END IF;
7931
7932 IF p_x_line_rec.end_item_unit_number IS NOT NULL AND
7933 ( p_x_line_rec.end_item_unit_number <>
7934 p_old_line_rec.end_item_unit_number OR
7935 p_old_line_rec.end_item_unit_number IS NULL )
7936 THEN
7937 IF NOT OE_Validate.End_Item_Unit_Number(p_x_line_rec.end_item_unit_number) THEN
7938 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
7939 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7940 p_x_line_rec.end_item_unit_number := NULL;
7941 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
7942 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7943 p_x_line_rec.end_item_unit_number := FND_API.G_MISS_CHAR;
7944 ELSE
7945 x_return_status := FND_API.G_RET_STS_ERROR;
7946 END IF;
7947 END IF;
7948 END IF;
7949
7950 IF p_x_line_rec.fob_point_code IS NOT NULL AND
7951 ( p_x_line_rec.fob_point_code <>
7952 p_old_line_rec.fob_point_code OR
7953 p_old_line_rec.fob_point_code IS NULL )
7954 THEN
7955 IF NOT(l_header_created) OR
7956 (l_header_created AND
7957 NOT OE_GLOBALS.EQUAL(p_x_line_rec.fob_point_code,
7958 OE_Order_Cache.g_header_rec.fob_point_code ))
7959 THEN
7960
7961 IF NOT OE_Validate.Fob_Point(p_x_line_rec.fob_point_code) THEN
7962 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
7963 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7964 p_x_line_rec.fob_point_code := NULL;
7965 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
7966 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7967 p_x_line_rec.fob_point_code := FND_API.G_MISS_CHAR;
7968 ELSE
7969 x_return_status := FND_API.G_RET_STS_ERROR;
7970 END IF;
7971 END IF;
7972
7973 END IF;
7974 END IF;
7975
7976 IF p_x_line_rec.freight_terms_code IS NOT NULL AND
7977 ( p_x_line_rec.freight_terms_code <>
7978 p_old_line_rec.freight_terms_code OR
7979 p_old_line_rec.freight_terms_code IS NULL )
7980 THEN
7981 IF NOT(l_header_created) OR
7982 (l_header_created AND
7983 NOT OE_GLOBALS.EQUAL(p_x_line_rec.freight_terms_code,
7984 OE_Order_Cache.g_header_rec.freight_terms_code ))
7985 THEN
7986
7987 IF NOT OE_Validate.Freight_Terms(p_x_line_rec.freight_terms_code) THEN
7988 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
7989 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7990 p_x_line_rec.freight_terms_code := NULL;
7991 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
7992 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
7993 p_x_line_rec.freight_terms_code := FND_API.G_MISS_CHAR;
7994 ELSE
7995 x_return_status := FND_API.G_RET_STS_ERROR;
7996 END IF;
7997 END IF;
7998
7999 END IF;
8000 END IF;
8001
8002 IF p_x_line_rec.invoice_to_contact_id IS NOT NULL AND
8003 ( p_x_line_rec.invoice_to_contact_id <>
8004 p_old_line_rec.invoice_to_contact_id OR
8005 p_old_line_rec.invoice_to_contact_id IS NULL )
8006 THEN
8007 IF NOT(l_header_created) OR
8008 (l_header_created AND
8009 NOT OE_GLOBALS.EQUAL(p_x_line_rec.invoice_to_contact_id,
8010 OE_Order_Cache.g_header_rec.invoice_to_contact_id ))
8011 THEN
8012
8013 IF NOT OE_Validate.Invoice_To_Contact(p_x_line_rec.invoice_to_contact_id) THEN
8014 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8015 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8016 p_x_line_rec.invoice_to_contact_id := NULL;
8017 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8018 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8019 p_x_line_rec.invoice_to_contact_id := FND_API.G_MISS_NUM;
8020 ELSE
8021 x_return_status := FND_API.G_RET_STS_ERROR;
8022 END IF;
8023 END IF;
8024
8025 END IF;
8026 END IF;
8027
8028 IF p_x_line_rec.invoice_to_org_id IS NOT NULL AND
8029 ( p_x_line_rec.invoice_to_org_id <>
8030 p_old_line_rec.invoice_to_org_id OR
8031 p_old_line_rec.invoice_to_org_id IS NULL )
8032 THEN
8033 IF NOT(l_header_created) OR
8034 (l_header_created AND
8035 NOT OE_GLOBALS.EQUAL(p_x_line_rec.invoice_to_org_id,
8036 OE_Order_Cache.g_header_rec.invoice_to_org_id ))
8037 THEN
8038
8039 IF NOT OE_Validate.Invoice_To_Org(p_x_line_rec.invoice_to_org_id) THEN
8040 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8041 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8042 p_x_line_rec.invoice_to_org_id := NULL;
8043 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8044 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8045 p_x_line_rec.invoice_to_org_id := FND_API.G_MISS_NUM;
8046 ELSE
8047 x_return_status := FND_API.G_RET_STS_ERROR;
8048 END IF;
8049 END IF;
8050
8051 END IF;
8052 END IF;
8053
8054 IF p_x_line_rec.invoicing_rule_id IS NOT NULL AND
8055 ( p_x_line_rec.invoicing_rule_id <>
8056 p_old_line_rec.invoicing_rule_id OR
8057 p_old_line_rec.invoicing_rule_id IS NULL )
8058 THEN
8059 IF NOT(l_header_created) OR
8060 (l_header_created AND
8061 NOT OE_GLOBALS.EQUAL(p_x_line_rec.invoicing_rule_id,
8062 OE_Order_Cache.g_header_rec.invoicing_rule_id ))
8063 THEN
8064
8065 IF NOT OE_Validate.Invoicing_Rule(p_x_line_rec.invoicing_rule_id) THEN
8066 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8067 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8068 p_x_line_rec.invoicing_rule_id := NULL;
8069 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8070 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8071 p_x_line_rec.invoicing_rule_id := FND_API.G_MISS_NUM;
8072 ELSE
8073 x_return_status := FND_API.G_RET_STS_ERROR;
8074 END IF;
8075 END IF;
8076
8077 END IF;
8078 END IF;
8079
8080 IF p_x_line_rec.item_type_code IS NOT NULL AND
8081 ( p_x_line_rec.item_type_code <>
8082 p_old_line_rec.item_type_code OR
8083 p_old_line_rec.item_type_code IS NULL )
8084 THEN
8085 IF NOT OE_Validate.Item_Type(p_x_line_rec.item_type_code) THEN
8086 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8087 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8088 p_x_line_rec.item_type_code := NULL;
8089 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8090 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8091 p_x_line_rec.item_type_code := FND_API.G_MISS_CHAR;
8092 ELSE
8093 x_return_status := FND_API.G_RET_STS_ERROR;
8094 END IF;
8095 END IF;
8096 END IF;
8097
8098 --Added for bug 3575484
8099 IF p_x_line_rec.line_type_id IS NOT NULL AND
8100 ( p_x_line_rec.line_type_id <>
8101 p_old_line_rec.line_type_id OR
8102 p_old_line_rec.line_type_id IS NULL )
8103 THEN
8104 IF NOT OE_Validate.Line_Type(p_x_line_rec.line_type_id) THEN
8105 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8106 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8107 p_x_line_rec.line_type_id := NULL;
8108 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8109 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8110 p_x_line_rec.line_type_id := FND_API.G_MISS_NUM;
8111 ELSE
8112 x_return_status := FND_API.G_RET_STS_ERROR;
8113 END IF;
8114 END IF;
8115 END IF;
8116 --End of bug 3575484
8117
8118 IF p_x_line_rec.ordered_quantity IS NOT NULL AND
8119 ( p_x_line_rec.ordered_quantity <>
8120 p_old_line_rec.ordered_quantity OR
8121 p_old_line_rec.ordered_quantity IS NULL )
8122 THEN
8123 IF NOT OE_Validate.ordered_quantity(p_x_line_rec.ordered_quantity) THEN
8124 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8125 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8126 p_x_line_rec.ordered_quantity := NULL;
8127 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8128 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8129 p_x_line_rec.ordered_quantity := FND_API.G_MISS_CHAR;
8130 ELSE
8131 x_return_status := FND_API.G_RET_STS_ERROR;
8132 END IF;
8133 END IF;
8134 END IF;
8135
8136
8137 IF p_x_line_rec.payment_term_id IS NOT NULL AND
8138 ( p_x_line_rec.payment_term_id <>
8139 p_old_line_rec.payment_term_id OR
8140 p_old_line_rec.payment_term_id IS NULL )
8141 THEN
8142 IF NOT(l_header_created) OR
8143 (l_header_created AND
8144 NOT OE_GLOBALS.EQUAL(p_x_line_rec.payment_term_id,
8145 OE_Order_Cache.g_header_rec.payment_term_id ))
8146 THEN
8147
8148 IF NOT OE_Validate.Payment_Term(p_x_line_rec.payment_term_id) THEN
8149 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8150 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8151 p_x_line_rec.payment_term_id := NULL;
8152 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8153 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8154 p_x_line_rec.payment_term_id := FND_API.G_MISS_NUM;
8155 ELSE
8156 x_return_status := FND_API.G_RET_STS_ERROR;
8157 END IF;
8158 END IF;
8159
8160 END IF;
8161 END IF;
8162
8163 -- Changes for Late Demand Penalty Factor
8164 IF l_debug_level > 0 then
8165 OE_DEBUG_PUB.Add('Checking late_demand penalty factor');
8166 END IF;
8167
8168 IF p_x_line_rec.late_demand_penalty_factor IS NOT NULL AND
8169 ( p_x_line_rec.late_demand_penalty_factor <>
8170 p_old_line_rec.late_demand_penalty_factor OR
8171 p_old_line_rec.late_demand_penalty_factor IS NULL)
8172 THEN
8173
8174 IF NOT OE_Validate.Late_Demand_Penalty_Factor
8175 (p_x_line_rec.late_demand_penalty_factor) THEN
8176
8177 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8178 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8179
8180 p_x_line_rec.late_demand_penalty_factor := NULL;
8181
8182 ELSE
8183
8184 l_return_status := FND_API.G_RET_STS_ERROR;
8185
8186 END IF;
8187
8188 END IF;
8189
8190 END IF;
8191
8192 IF p_x_line_rec.price_list_id IS NOT NULL AND
8193 ( p_x_line_rec.price_list_id <>
8194 p_old_line_rec.price_list_id OR
8195 p_old_line_rec.price_list_id IS NULL )
8196 THEN
8197 IF NOT(l_header_created) OR
8198 (l_header_created AND
8199 NOT OE_GLOBALS.EQUAL(p_x_line_rec.price_list_id,
8200 OE_Order_Cache.g_header_rec.price_list_id ))
8201 THEN
8202
8203 IF NOT OE_Validate.Price_List(p_x_line_rec.price_list_id) THEN
8204 --No partial level validation if this is a mandatory field.
8205 --IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8206 -- p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8207 -- p_x_line_rec.price_list_id := NULL;
8208 IF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8209 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8210
8211 -- bug 3572931 added the calculate price flag check
8212 -- because freeze price line shouldn't get a new price list
8213 IF nvl(p_x_line_rec.calculate_price_flag, 'Y') = 'Y' THEN
8214 p_x_line_rec.price_list_id := FND_API.G_MISS_NUM;
8215 END IF;
8216 ELSE
8217 x_return_status := FND_API.G_RET_STS_ERROR;
8218 END IF;
8219 END IF;
8220
8221 END IF;
8222 END IF;
8223
8224 IF p_x_line_rec.project_id IS NOT NULL AND
8225 ( p_x_line_rec.project_id <>
8226 p_old_line_rec.project_id OR
8227 p_old_line_rec.project_id IS NULL )
8228 THEN
8229 IF NOT OE_Validate.Project(p_x_line_rec.project_id) THEN
8230 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8231 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8232 p_x_line_rec.project_id := NULL;
8233 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8234 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8235 p_x_line_rec.project_id := FND_API.G_MISS_NUM;
8236 ELSE
8237 x_return_status := FND_API.G_RET_STS_ERROR;
8238 END IF;
8239 END IF;
8240 END IF;
8241 IF l_debug_level > 0 then
8242 oe_debug_pub.add('Checking for Ship Dates....',1);
8243 END IF;
8244 -- If the order date type is does not match the change, error out.
8245 IF Nvl(p_x_line_rec.source_type_code,OE_GLOBALS.G_SOURCE_INTERNAL) =
8246 OE_GLOBALS.G_SOURCE_INTERNAL THEN
8247 IF NOT OE_GLOBALS.Equal(p_x_line_rec.schedule_ship_date,
8248 p_old_line_rec.schedule_ship_date) AND
8249 p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
8250 THEN
8251 l_type_code := Get_Date_Type(p_x_line_rec.header_id);
8252 -- If Date type is Arrival, then the user is not allowed
8253 -- to change the schedule ship date.
8254
8255 IF l_type_code = 'ARRIVAL' THEN
8256
8257 FND_MESSAGE.SET_NAME('ONT','OE_SCH_INV_SHP_DATE');
8258 OE_MSG_PUB.Add;
8259
8260 l_return_status := FND_API.G_RET_STS_ERROR;
8261
8262 END IF;
8263 END IF;
8264 IF l_debug_level > 0 then
8265 oe_debug_pub.add('Checking for Arival Dates....',1);
8266 END IF;
8267
8268 -- If the order date type is does not match the change, error out.
8269 IF NOT OE_GLOBALS.Equal(p_x_line_rec.schedule_arrival_date,
8270 p_old_line_rec.schedule_arrival_date) AND
8271 p_x_line_rec.operation = OE_GLOBALS.G_OPR_UPDATE
8272 THEN
8273 l_type_code := Get_Date_Type(p_x_line_rec.header_id);
8274 -- If Date type is Ship, then the user is not allowed
8275 -- to change the schedule arrival date.
8276
8277 IF nvl(l_type_code,'SHIP') = 'SHIP' THEN
8278
8279 FND_MESSAGE.SET_NAME('ONT','OE_SCH_INV_ARR_DATE');
8280 OE_MSG_PUB.Add;
8281
8282 l_return_status := FND_API.G_RET_STS_ERROR;
8283
8284 END IF;
8285
8286 END IF;
8287 END IF;
8288 IF p_x_line_rec.shipment_priority_code IS NOT NULL AND
8289 ( p_x_line_rec.shipment_priority_code <>
8290 p_old_line_rec.shipment_priority_code OR
8291 p_old_line_rec.shipment_priority_code IS NULL )
8292 THEN
8293 IF NOT(l_header_created) OR
8294 (l_header_created AND
8295 NOT OE_GLOBALS.EQUAL(p_x_line_rec.shipment_priority_code,
8296 OE_Order_Cache.g_header_rec.shipment_priority_code ))
8297 THEN
8298
8299 IF NOT OE_Validate.Shipment_Priority(p_x_line_rec.shipment_priority_code) THEN
8300 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8301 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8302 p_x_line_rec.shipment_priority_code := NULL;
8303 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8304 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8305 p_x_line_rec.shipment_priority_code := FND_API.G_MISS_CHAR;
8306 ELSE
8307 x_return_status := FND_API.G_RET_STS_ERROR;
8308 END IF;
8309 END IF;
8310
8311 END IF;
8312 END IF;
8313
8314 IF p_x_line_rec.shipping_method_code IS NOT NULL AND
8315 ( p_x_line_rec.shipping_method_code <>
8316 p_old_line_rec.shipping_method_code OR
8317 p_old_line_rec.shipping_method_code IS NULL )
8318 THEN
8319 IF NOT(l_header_created) OR
8320 (l_header_created AND
8321 NOT OE_GLOBALS.EQUAL(p_x_line_rec.shipping_method_code,
8322 OE_Order_Cache.g_header_rec.shipping_method_code ))
8323 THEN
8324
8325 IF NOT OE_Validate.Shipping_Method(p_x_line_rec.shipping_method_code) THEN
8326 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8327 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8328 p_x_line_rec.shipping_method_code := NULL;
8329 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8330 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8331 p_x_line_rec.shipping_method_code := FND_API.G_MISS_CHAR;
8332 ELSE
8333 x_return_status := FND_API.G_RET_STS_ERROR;
8334 END IF;
8335 END IF;
8336
8337 END IF;
8338 END IF;
8339
8340 IF p_x_line_rec.ship_from_org_id IS NOT NULL AND
8341 ( p_x_line_rec.ship_from_org_id <>
8342 p_old_line_rec.ship_from_org_id OR
8343 p_old_line_rec.ship_from_org_id IS NULL )
8344 THEN
8345 IF NOT(l_header_created) OR
8346 (l_header_created AND
8347 NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_from_org_id,
8348 OE_Order_Cache.g_header_rec.ship_from_org_id ))
8349 THEN
8350
8351 IF NOT OE_Validate.Ship_From_Org(p_x_line_rec.ship_from_org_id) THEN
8352 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8353 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8354 p_x_line_rec.ship_from_org_id := NULL;
8355 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8356 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8357 p_x_line_rec.ship_from_org_id := FND_API.G_MISS_NUM;
8358 ELSE
8359 x_return_status := FND_API.G_RET_STS_ERROR;
8360 END IF;
8361 END IF;
8362
8363 END IF;
8364 END IF;
8365
8366 IF p_x_line_rec.shipping_interfaced_flag IS NOT NULL AND
8367 ( p_x_line_rec.shipping_interfaced_flag <>
8368 p_old_line_rec.shipping_interfaced_flag OR
8369 p_old_line_rec.shipping_interfaced_flag IS NULL )
8370 THEN
8371 IF NOT OE_Validate.Shipping_Interfaced(p_x_line_rec.shipping_interfaced_flag) THEN
8372 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8373 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8374 p_x_line_rec.shipping_interfaced_flag := NULL;
8375 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8376 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8377 p_x_line_rec.shipping_interfaced_flag := FND_API.G_MISS_CHAR;
8378 ELSE
8379 x_return_status := FND_API.G_RET_STS_ERROR;
8380 END IF;
8381 END IF;
8382 END IF;
8383
8384 IF p_x_line_rec.shippable_flag IS NOT NULL AND
8385 ( p_x_line_rec.shippable_flag <>
8386 p_old_line_rec.shippable_flag OR
8387 p_old_line_rec.shippable_flag IS NULL )
8388 THEN
8389 IF NOT OE_Validate.shippable(p_x_line_rec.shippable_flag) THEN
8390 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8391 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8392 p_x_line_rec.shippable_flag := NULL;
8393 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8394 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8395 p_x_line_rec.shippable_flag := FND_API.G_MISS_CHAR;
8396 ELSE
8397 x_return_status := FND_API.G_RET_STS_ERROR;
8398 END IF;
8399 END IF;
8400 END IF;
8401
8402 IF p_x_line_rec.ship_to_contact_id IS NOT NULL AND
8403 ( p_x_line_rec.ship_to_contact_id <>
8404 p_old_line_rec.ship_to_contact_id OR
8405 p_old_line_rec.ship_to_contact_id IS NULL )
8406 THEN
8407 IF NOT(l_header_created) OR
8408 (l_header_created AND
8409 NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_to_contact_id,
8410 OE_Order_Cache.g_header_rec.ship_to_contact_id ))
8411 THEN
8412
8413 IF NOT OE_Validate.Ship_To_Contact(p_x_line_rec.ship_to_contact_id) THEN
8414 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8415 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8416 p_x_line_rec.ship_to_contact_id := NULL;
8417 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8418 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8419 p_x_line_rec.ship_to_contact_id := FND_API.G_MISS_NUM;
8420 ELSE
8421 x_return_status := FND_API.G_RET_STS_ERROR;
8422 END IF;
8423 END IF;
8424
8425 END IF;
8426 END IF;
8427
8428 IF p_x_line_rec.ship_to_org_id IS NOT NULL AND
8429 ( p_x_line_rec.ship_to_org_id <>
8430 p_old_line_rec.ship_to_org_id OR
8431 p_old_line_rec.ship_to_org_id IS NULL )
8432 THEN
8433 IF NOT(l_header_created) OR
8434 (l_header_created AND
8435 NOT OE_GLOBALS.EQUAL(p_x_line_rec.ship_to_org_id,
8436 OE_Order_Cache.g_header_rec.ship_to_org_id ))
8437 THEN
8438
8439 IF NOT OE_Validate.Ship_To_Org(p_x_line_rec.ship_to_org_id) THEN
8440 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8441 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8442 p_x_line_rec.ship_to_org_id := NULL;
8443 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8444 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8445 p_x_line_rec.ship_to_org_id := FND_API.G_MISS_NUM;
8446 ELSE
8447 x_return_status := FND_API.G_RET_STS_ERROR;
8448 END IF;
8449 END IF;
8450
8451 END IF;
8452 END IF;
8453
8454 IF p_x_line_rec.sold_to_org_id IS NOT NULL AND
8455 ( p_x_line_rec.sold_to_org_id <>
8456 p_old_line_rec.sold_to_org_id OR
8457 p_old_line_rec.sold_to_org_id IS NULL )
8458 THEN
8459 IF NOT(l_header_created) OR
8460 (l_header_created AND
8461 NOT OE_GLOBALS.EQUAL(p_x_line_rec.sold_to_org_id,
8462 OE_Order_Cache.g_header_rec.sold_to_org_id ))
8463 THEN
8464
8465 IF NOT OE_Validate.Sold_To_Org(p_x_line_rec.sold_to_org_id) THEN
8466 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8467 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8468 p_x_line_rec.sold_to_org_id := NULL;
8469 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8470 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8471 p_x_line_rec.sold_to_org_id := FND_API.G_MISS_NUM;
8472 ELSE
8473 x_return_status := FND_API.G_RET_STS_ERROR;
8474 END IF;
8475 END IF;
8476
8477 END IF;
8478 END IF;
8479
8480 IF p_x_line_rec.source_type_code IS NOT NULL AND
8481 ( p_x_line_rec.source_type_code <>
8482 p_old_line_rec.source_type_code OR
8483 p_old_line_rec.source_type_code IS NULL )
8484 THEN
8485 IF NOT OE_Validate.Source_Type(p_x_line_rec.source_type_code) THEN
8486 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8487 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8488 p_x_line_rec.source_type_code := NULL;
8489 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8490 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8491 p_x_line_rec.source_type_code := FND_API.G_MISS_CHAR;
8492 ELSE
8493 x_return_status := FND_API.G_RET_STS_ERROR;
8494 END IF;
8495 END IF;
8496 END IF;
8497
8498 IF p_x_line_rec.tax_exempt_flag IS NOT NULL AND
8499 ( p_x_line_rec.tax_exempt_flag <>
8500 p_old_line_rec.tax_exempt_flag OR
8501 p_old_line_rec.tax_exempt_flag IS NULL )
8502 THEN
8503 IF NOT(l_header_created) OR
8504 (l_header_created AND
8505 NOT OE_GLOBALS.EQUAL(p_x_line_rec.tax_exempt_flag,
8506 OE_Order_Cache.g_header_rec.tax_exempt_flag ))
8507 THEN
8508
8509 IF NOT OE_Validate.Tax_Exempt(p_x_line_rec.tax_exempt_flag) THEN
8510 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8511 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8512 p_x_line_rec.tax_exempt_flag := NULL;
8513 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8514 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8515 p_x_line_rec.tax_exempt_flag := FND_API.G_MISS_CHAR;
8516 ELSE
8517 x_return_status := FND_API.G_RET_STS_ERROR;
8518 END IF;
8519 END IF;
8520
8521 END IF;
8522 END IF;
8523
8524 IF p_x_line_rec.tax_exempt_reason_code IS NOT NULL AND
8525 ( p_x_line_rec.tax_exempt_reason_code <>
8526 p_old_line_rec.tax_exempt_reason_code OR
8527 p_old_line_rec.tax_exempt_reason_code IS NULL )
8528 THEN
8529 IF NOT(l_header_created) OR
8530 (l_header_created AND
8531 NOT OE_GLOBALS.EQUAL(p_x_line_rec.tax_exempt_reason_code,
8532 OE_Order_Cache.g_header_rec.tax_exempt_reason_code ))
8533 THEN
8534
8535 IF NOT OE_Validate.Tax_Exempt_Reason(p_x_line_rec.tax_exempt_reason_code) THEN
8536 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8537 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8538 p_x_line_rec.tax_exempt_reason_code := NULL;
8539 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8540 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8541 p_x_line_rec.tax_exempt_reason_code := FND_API.G_MISS_CHAR;
8542 ELSE
8543 x_return_status := FND_API.G_RET_STS_ERROR;
8544 END IF;
8545 END IF;
8546
8547 END IF;
8548 END IF;
8549
8550 IF p_x_line_rec.tax_point_code IS NOT NULL AND
8551 ( p_x_line_rec.tax_point_code <>
8552 p_old_line_rec.tax_point_code OR
8553 p_old_line_rec.tax_point_code IS NULL )
8554 THEN
8555 IF NOT(l_header_created) OR
8556 (l_header_created AND
8557 NOT OE_GLOBALS.EQUAL(p_x_line_rec.tax_point_code,
8558 OE_Order_Cache.g_header_rec.tax_point_code ))
8559 THEN
8560
8561 IF NOT OE_Validate.Tax_Point(p_x_line_rec.tax_point_code) THEN
8562 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8563 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8564 p_x_line_rec.tax_point_code := NULL;
8565 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8566 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8567 p_x_line_rec.tax_point_code := FND_API.G_MISS_CHAR;
8568 ELSE
8569 x_return_status := FND_API.G_RET_STS_ERROR;
8570 END IF;
8571 END IF;
8572
8573 END IF;
8574 END IF;
8575
8576 IF p_x_line_rec.fulfilled_flag IS NOT NULL AND
8577 ( p_x_line_rec.fulfilled_flag <>
8578 p_old_line_rec.fulfilled_flag OR
8579 p_old_line_rec.fulfilled_flag IS NULL )
8580 THEN
8581 IF NOT OE_Validate.fulfilled(p_x_line_rec.fulfilled_flag) THEN
8582 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8583 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8584 p_x_line_rec.fulfilled_flag := NULL;
8585 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8586 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8587 p_x_line_rec.fulfilled_flag := FND_API.G_MISS_CHAR;
8588 ELSE
8589 x_return_status := FND_API.G_RET_STS_ERROR;
8590 END IF;
8591 END IF;
8592 END IF;
8593
8594 IF p_x_line_rec.flow_status_code IS NOT NULL AND
8595 ( p_x_line_rec.flow_status_code <>
8596 p_old_line_rec.flow_status_code OR
8597 p_old_line_rec.flow_status_code IS NULL )
8598 THEN
8599 IF NOT OE_Validate.Line_Flow_Status(p_x_line_rec.flow_status_code) THEN
8600 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8601 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8602 p_x_line_rec.flow_status_code := NULL;
8603 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8604 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8605 p_x_line_rec.flow_status_code := FND_API.G_MISS_CHAR;
8606 ELSE
8607 x_return_status := FND_API.G_RET_STS_ERROR;
8608 END IF;
8609 END IF;
8610 END IF;
8611
8612 -- Flex Validation code has been moved to Procedure Validate_Flex, bug 2511313
8613 if OE_GLOBALS.g_validate_desc_flex ='Y' then --4343612
8614 Validate_Flex( p_x_line_rec => p_x_line_rec,
8615 p_old_line_rec => p_old_line_rec,
8616 p_validation_level => p_validation_level,
8617 x_return_status => x_return_status
8618 );
8619 end if;
8620 -- Done with flex Validation
8621
8622 IF p_x_line_rec.salesrep_id IS NOT NULL AND
8623 ( p_x_line_rec.salesrep_id <>
8624 p_old_line_rec.salesrep_id OR
8625 p_old_line_rec.salesrep_id IS NULL )
8626 THEN
8627 IF NOT(l_header_created) OR
8628 (l_header_created AND
8629 NOT OE_GLOBALS.EQUAL(p_x_line_rec.salesrep_id,
8630 OE_Order_Cache.g_header_rec.salesrep_id ))
8631 THEN
8632
8633 IF NOT OE_Validate.salesrep(p_x_line_rec.salesrep_id) THEN
8634 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8635 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8636 p_x_line_rec.salesrep_id := NULL;
8637 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8638 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8639 p_x_line_rec.salesrep_id := FND_API.G_MISS_NUM;
8640 ELSE
8641 x_return_status := FND_API.G_RET_STS_ERROR;
8642 END IF;
8643 END IF;
8644
8645 END IF;
8646 END IF;
8647
8648 IF p_x_line_rec.return_reason_code IS NOT NULL AND
8649 ( p_x_line_rec.return_reason_code <>
8650 p_old_line_rec.return_reason_code OR
8651 p_old_line_rec.return_reason_code IS NULL )
8652 THEN
8653 IF NOT OE_Validate.return_reason(p_x_line_rec.return_reason_code) THEN
8654 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8655 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8656 p_x_line_rec.return_reason_code := NULL;
8657 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8658 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8659 p_x_line_rec.return_reason_code := FND_API.G_MISS_CHAR;
8660 ELSE
8661 x_return_status := FND_API.G_RET_STS_ERROR;
8662 END IF;
8663 END IF;
8664 END IF;
8665
8666 -- Validate Commitment
8667 IF (p_x_line_rec.commitment_id IS NOT NULL)
8668 AND (p_x_line_rec.commitment_id <> p_old_line_rec.commitment_id
8669 OR p_old_line_rec.commitment_id IS NULL) THEN
8670 IF NOT oe_validate.commitment(p_x_line_rec.commitment_id) THEN
8671 x_return_status := FND_API.G_RET_STS_ERROR;
8672 END IF;
8673 END IF;
8674
8675 IF p_x_line_rec.user_item_description IS NOT NULL AND
8676 ( p_x_line_rec.user_item_description <>
8677 p_old_line_rec.user_item_description OR
8678 p_old_line_rec.user_item_description IS NULL )
8679 THEN
8680 IF NOT OE_Validate.User_Item_Description(p_x_line_rec.user_item_description) THEN
8681 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8682 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8683 p_x_line_rec.user_item_description := NULL;
8684 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8685 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8686 p_x_line_rec.user_item_description := FND_API.G_MISS_CHAR;
8687 ELSE
8688 x_return_status := FND_API.G_RET_STS_ERROR;
8689 END IF;
8690 END IF;
8691 END IF;
8692 IF l_debug_level > 0 then
8693 oe_debug_pub.ADD('item_relationship_type :'||p_x_line_rec.item_relationship_type,1);
8694 END IF;
8695 IF p_x_line_rec.item_relationship_type IS NOT NULL AND
8696 ( p_x_line_rec.item_relationship_type <>
8697 p_old_line_rec.item_relationship_type OR
8698 p_old_line_rec.item_relationship_type IS NULL )
8699 THEN
8700 IF NOT OE_Validate.item_relationship_type(p_x_line_rec.item_relationship_type) THEN
8701 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8702 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8703 p_x_line_rec.item_relationship_type := NULL;
8704 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8705 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8706 p_x_line_rec.item_relationship_type := FND_API.G_MISS_NUM;
8707 ELSE
8708 x_return_status := FND_API.G_RET_STS_ERROR;
8709 END IF;
8710 END IF;
8711 END IF;
8712
8713 IF p_x_line_rec.Minisite_Id IS NOT NULL AND
8714 ( p_x_line_rec.Minisite_id <>
8715 p_old_line_rec.Minisite_id OR
8716 p_old_line_rec.Minisite_id IS NULL )
8717 THEN
8718 IF NOT(l_header_created) OR
8719 (l_header_created AND
8720 NOT OE_GLOBALS.EQUAL(p_x_line_rec.minisite_id,
8721 OE_Order_Cache.g_header_rec.minisite_id ))
8722
8723 THEN
8724
8725 IF NOT OE_Validate.Minisite(p_x_line_rec.Minisite_id) THEN
8726 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8727 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8728 p_x_line_rec.Minisite_id := NULL;
8729 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8730 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8731 p_x_line_rec.Minisite_id := FND_API.G_MISS_NUM;
8732 ELSE
8733 x_return_status := FND_API.G_RET_STS_ERROR;
8734 END IF;
8735 END IF;
8736
8737 END IF;
8738
8739 END IF;
8740
8741 -- distributed orders @
8742
8743 IF p_x_line_rec.Ib_owner IS NOT NULL AND
8744 ( p_x_line_rec.Ib_owner <>
8745 p_old_line_rec.Ib_owner OR
8746 p_old_line_rec.Ib_owner IS NULL )
8747 THEN
8748 IF NOT(l_header_created) OR
8749 (l_header_created AND
8750 NOT OE_GLOBALS.EQUAL(p_x_line_rec.Ib_owner,
8751 OE_Order_Cache.g_header_rec.Ib_owner ))
8752
8753 THEN
8754
8755 IF NOT OE_Validate.IB_OWNER(p_x_line_rec.Ib_owner) THEN
8756 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8757 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8758 p_x_line_rec.Ib_owner := NULL;
8759 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8760 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8761 p_x_line_rec.Ib_Owner := FND_API.G_MISS_CHAR;
8762 ELSE
8763 x_return_status := FND_API.G_RET_STS_ERROR;
8764 END IF;
8765 END IF;
8766
8767 END IF;
8768
8769 END IF;
8770
8771 IF p_x_line_rec.Ib_installed_at_location IS NOT NULL AND
8772 ( p_x_line_rec.Ib_installed_at_location <>
8773 p_old_line_rec.Ib_installed_at_location OR
8774 p_old_line_rec.Ib_installed_at_location IS NULL )
8775 THEN
8776 IF NOT(l_header_created) OR
8777 (l_header_created AND
8778 NOT OE_GLOBALS.EQUAL(p_x_line_rec.Ib_installed_at_location,
8779 OE_Order_Cache.g_header_rec.Ib_installed_at_location ))
8780
8781 THEN
8782
8783 IF NOT OE_Validate.IB_INSTALLED_AT_LOCATION(p_x_line_rec.Ib_installed_at_location) THEN
8784 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8785 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8786 p_x_line_rec.Ib_installed_at_location := NULL;
8787 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8788 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8789 p_x_line_rec.Ib_installed_at_location := FND_API.G_MISS_CHAR;
8790 ELSE
8791 x_return_status := FND_API.G_RET_STS_ERROR;
8792 END IF;
8793 END IF;
8794
8795 END IF;
8796
8797 END IF;
8798
8799 IF p_x_line_rec.Ib_current_location IS NOT NULL AND
8800 ( p_x_line_rec.Ib_current_location <>
8801 p_old_line_rec.Ib_current_location OR
8802 p_old_line_rec.Ib_current_location IS NULL )
8803 THEN
8804 IF NOT(l_header_created) OR
8805 (l_header_created AND
8806 NOT OE_GLOBALS.EQUAL(p_x_line_rec.Ib_current_location,
8807 OE_Order_Cache.g_header_rec.Ib_current_location ))
8808
8809 THEN
8810
8811 IF NOT OE_Validate.IB_CURRENT_LOCATION(p_x_line_rec.ib_current_location) THEN
8812 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8813 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8814 p_x_line_rec.Ib_current_location := NULL;
8815 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8816 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8817 p_x_line_rec.Ib_current_location := FND_API.G_MISS_CHAR;
8818 ELSE
8819 x_return_status := FND_API.G_RET_STS_ERROR;
8820 END IF;
8821 END IF;
8822
8823 END IF;
8824
8825 END IF;
8826
8827 IF p_x_line_rec.End_customer_id IS NOT NULL AND
8828 ( p_x_line_rec.End_customer_id <>
8829 p_old_line_rec.End_customer_id OR
8830 p_old_line_rec.End_customer_id IS NULL )
8831 THEN
8832 IF NOT(l_header_created) OR
8833 (l_header_created AND
8834 NOT OE_GLOBALS.EQUAL(p_x_line_rec.End_customer_id,
8835 OE_Order_Cache.g_header_rec.End_customer_id ))
8836
8837 THEN
8838
8839 IF NOT OE_Validate.END_CUSTOMER(p_x_line_rec.End_customer_id) THEN
8840 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8841 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8842 p_x_line_rec.End_customer_id := NULL;
8843 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8844 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8845 p_x_line_rec.End_customer_id := FND_API.G_MISS_NUM;
8846 ELSE
8847 x_return_status := FND_API.G_RET_STS_ERROR;
8848 END IF;
8849 END IF;
8850
8851 END IF;
8852
8853 END IF;
8854
8855 IF p_x_line_rec.End_customer_contact_id IS NOT NULL AND
8856 ( p_x_line_rec.End_customer_contact_id <>
8857 p_old_line_rec.End_customer_contact_id OR
8858 p_old_line_rec.End_customer_contact_id IS NULL )
8859 THEN
8860 IF NOT(l_header_created) OR
8861 (l_header_created AND
8862 NOT OE_GLOBALS.EQUAL(p_x_line_rec.End_customer_contact_id,
8863 OE_Order_Cache.g_header_rec.End_customer_contact_id ))
8864
8865 THEN
8866
8867 IF NOT OE_Validate.END_CUSTOMER_CONTACT(p_x_line_rec.End_customer_contact_id) THEN
8868 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8869 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8870 p_x_line_rec.End_customer_contact_id := NULL;
8871 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8872 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8873 p_x_line_rec.End_customer_contact_id := FND_API.G_MISS_NUM;
8874 ELSE
8875 x_return_status := FND_API.G_RET_STS_ERROR;
8876 END IF;
8877 END IF;
8878
8879 END IF;
8880
8881 END IF;
8882
8883 IF p_x_line_rec.End_customer_site_use_id IS NOT NULL AND
8884 ( p_x_line_rec.End_customer_site_use_id <>
8885 p_old_line_rec.End_customer_site_use_id OR
8886 p_old_line_rec.End_customer_site_use_id IS NULL )
8887 THEN
8888 IF NOT(l_header_created) OR
8889 (l_header_created AND
8890 NOT OE_GLOBALS.EQUAL(p_x_line_rec.End_customer_site_use_id,
8891 OE_Order_Cache.g_header_rec.End_customer_site_use_id ))
8892
8893 THEN
8894
8895 IF NOT OE_Validate.END_CUSTOMER_SITE_USE(p_x_line_rec.End_customer_site_use_id) THEN
8896 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8897 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8898 p_x_line_rec.End_customer_site_use_id := NULL;
8899 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8900 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8901 p_x_line_rec.End_customer_site_use_id := FND_API.G_MISS_NUM;
8902 ELSE
8903 x_return_status := FND_API.G_RET_STS_ERROR;
8904 END IF;
8905 END IF;
8906
8907 END IF;
8908
8909 END IF;
8910
8911
8912 -- OPM bug 3457463
8913
8914 if l_debug_level > 0 then
8915 oe_debug_pub.ADD('preferred_grade:'||p_x_line_rec.preferred_grade,1);
8916 end if;
8917
8918
8919 IF p_x_line_rec.preferred_grade IS NOT NULL AND
8920 ( p_x_line_rec.preferred_grade <>
8921 p_old_line_rec.preferred_grade OR
8922 p_old_line_rec.preferred_grade IS NULL )
8923 THEN
8924 IF NOT OE_Validate.preferred_grade(p_x_line_rec.preferred_grade) THEN
8925 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
8926 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8927 p_x_line_rec.preferred_grade := NULL;
8928 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
8929 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
8930 p_x_line_rec.preferred_grade := FND_API.G_MISS_CHAR;
8931 ELSE
8932 x_return_status := FND_API.G_RET_STS_ERROR;
8933 END IF;
8934 END IF;
8935 END IF;
8936 --Customer Acceptance
8937 IF p_old_line_rec.accepted_quantity IS NOT NULL AND
8938 p_old_line_rec.accepted_quantity <> FND_API.G_MISS_NUM AND
8939 p_old_line_rec.accepted_quantity <> p_x_line_rec.accepted_quantity
8940 THEN
8941 p_x_line_rec.accepted_quantity := p_old_line_rec.accepted_quantity;
8942 FND_MESSAGE.SET_NAME('ONT','ONT_CANNOT_UPDATE_ACCEPTANCE');
8943 OE_MSG_PUB.Add;
8944 END IF;
8945
8946 IF p_old_line_rec.REVREC_SIGNATURE_DATE IS NOT NULL AND
8947 p_old_line_rec.REVREC_SIGNATURE_DATE <> FND_API.G_MISS_DATE AND
8948 p_old_line_rec.REVREC_SIGNATURE_DATE <> p_x_line_rec.REVREC_SIGNATURE_DATE
8949 THEN
8950 p_x_line_rec.REVREC_SIGNATURE_DATE := p_old_line_rec.REVREC_SIGNATURE_DATE;
8951 FND_MESSAGE.SET_NAME('ONT','ONT_CANNOT_UPDATE_ACCEPTANCE');
8952 OE_MSG_PUB.Add;
8953 END IF;
8954
8955 IF p_old_line_rec.accepted_by IS NOT NULL AND
8956 p_old_line_rec.accepted_by <> FND_API.G_MISS_NUM AND
8957 p_old_line_rec.accepted_by <> p_x_line_rec.accepted_by
8958 THEN
8959 p_x_line_rec.accepted_by := p_old_line_rec.accepted_by;
8960 FND_MESSAGE.SET_NAME('ONT','ONT_CANNOT_UPDATE_ACCEPTANCE');
8961 OE_MSG_PUB.Add;
8962 END IF;
8963 --
8964
8965 IF l_debug_level > 0 then
8966 oe_debug_pub.add('Exiting procedure OE_validate_line.Attributes',1);
8967 END IF;
8968
8969 EXCEPTION
8970
8971 WHEN FND_API.G_EXC_ERROR THEN
8972
8973 x_return_status := FND_API.G_RET_STS_ERROR;
8974
8975 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
8976
8977 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8978
8979 WHEN OTHERS THEN
8980
8981 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8982
8983 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
8984 THEN
8985 OE_MSG_PUB.Add_Exc_Msg
8986 ( G_PKG_NAME
8987 , 'Attributes'
8988 );
8989 END IF;
8990
8991 /* IF p_x_line_rec.supplier_signature IS NOT NULL AND
8992 ( p_x_line_rec.supplier_signature <>
8993 p_old_line_rec.supplier_signature OR
8994 p_old_line_rec.supplier_signature IS NULL )
8995 THEN
8996 IF NOT(l_header_created) OR
8997 (l_header_created AND
8998 NOT OE_GLOBALS.EQUAL(p_x_line_rec.supplier_signature,
8999 OE_Order_Cache.g_header_rec.supplier_signature ))
9000
9001 THEN
9002
9003 IF NOT OE_Validate.SUPPLIER_SIGNATURE(p_x_line_rec.supplier_signature) THEN
9004 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
9005 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
9006 p_x_line_rec.supplier_signature := NULL;
9007 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
9008 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
9009 p_x_line_rec.supplier_signature := FND_API.G_MISS_CHAR;
9010 ELSE
9011 x_return_status := FND_API.G_RET_STS_ERROR;
9012 END IF;
9013 END IF;
9014
9015 END IF;
9016
9017 END IF;
9018
9019 IF p_x_line_rec.supplier_signature_date IS NOT NULL AND
9020 ( p_x_line_rec.supplier_signature_date <>
9021 p_old_line_rec.supplier_signature_date OR
9022 p_old_line_rec.supplier_signature_date IS NULL )
9023 THEN
9024 IF NOT(l_header_created) OR
9025 (l_header_created AND
9026 NOT OE_GLOBALS.EQUAL(p_x_line_rec.supplier_signature_date,
9027 OE_Order_Cache.g_header_rec.supplier_signature_date ))
9028
9029 THEN
9030
9031 IF NOT OE_Validate.SUPPLIER_SIGNATURE_DATE(p_x_line_rec.supplier_signature_date) THEN
9032 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
9033 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
9034 p_x_line_rec.supplier_signature_date := NULL;
9035 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
9036 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
9037 p_x_line_rec.supplier_signature_date := FND_API.G_MISS_DATE;
9038 ELSE
9039 x_return_status := FND_API.G_RET_STS_ERROR;
9040 END IF;
9041 END IF;
9042
9043 END IF;
9044
9045 END IF;
9046
9047 IF p_x_line_rec.customer_signature IS NOT NULL AND
9048 ( p_x_line_rec.customer_signature <>
9049 p_old_line_rec.customer_signature OR
9050 p_old_line_rec.customer_signature IS NULL )
9051 THEN
9052 IF NOT(l_header_created) OR
9053 (l_header_created AND
9054 NOT OE_GLOBALS.EQUAL(p_x_line_rec.customer_signature,
9055 OE_Order_Cache.g_header_rec.customer_signature ))
9056
9057 THEN
9058
9059 IF NOT OE_Validate.CUSTOMER_SIGNATURE(p_x_line_rec.customer_signature) THEN
9060 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
9061 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
9062 p_x_line_rec.customer_signature := NULL;
9063 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
9064 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
9065 p_x_line_rec.customer_signature := FND_API.G_MISS_CHAR;
9066 ELSE
9067 x_return_status := FND_API.G_RET_STS_ERROR;
9068 END IF;
9069 END IF;
9070
9071 END IF;
9072
9073 END IF;
9074
9075 IF p_x_line_rec.customer_signature_date IS NOT NULL AND
9076 ( p_x_line_rec.customer_signature_date <>
9077 p_old_line_rec.customer_signature_date OR
9078 p_old_line_rec.customer_signature_date IS NULL )
9079 THEN
9080 IF NOT(l_header_created) OR
9081 (l_header_created AND
9082 NOT OE_GLOBALS.EQUAL(p_x_line_rec.customer_signature_date,
9083 OE_Order_Cache.g_header_rec.customer_signature_date ))
9084
9085 THEN
9086
9087 IF NOT OE_Validate.CUSTOMER_SIGNATURE_DATE(p_x_line_rec.customer_signature_date) THEN
9088 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
9089 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
9090 p_x_line_rec.customer_signature_date := NULL;
9091 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
9092 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
9093 p_x_line_rec.customer_signature_date := FND_API.G_MISS_DATE;
9094 ELSE
9095 x_return_status := FND_API.G_RET_STS_ERROR;
9096 END IF;
9097 END IF;
9098
9099 END IF;
9100
9101 END IF;
9102
9103 */
9104
9105 END Attributes;
9106
9107
9108 ------------------------------------------------------------------
9109 -- Procedure Validate_Flex : for bug 2511313
9110 -- The flex validations have been moved from the procedure Attributes
9111 -- to this new procedure. The call to this procedure not only validates
9112 -- the flex values on the line record passed to it but also defaults
9113 -- the segments which can be defaulted.
9114 --
9115 -- This procedure is also called from OE_CONFIG_UTIL.Default_Child_Line
9116 -- procedure with the validation level set to NONE to default the flex segments.
9117 ---------------------------------------------------------------------
9118
9119
9120 PROCEDURE Validate_Flex
9121 ( p_x_line_rec IN OUT NOCOPY OE_ORDER_PUB.Line_Rec_Type,
9122 p_old_line_rec IN OE_ORDER_PUB.line_rec_type :=
9123 OE_Order_PUB.G_MISS_LINE_REC,
9124 p_validation_level IN NUMBER,
9125 x_return_status OUT NOCOPY VARCHAR2
9126 )
9127 IS
9128 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
9129 --Start of bug#7380336
9130 l_context_required_flag fnd_descriptive_flexs_vl.context_required_flag%TYPE;
9131 l_default_context_field_name fnd_descriptive_flexs_vl.default_context_field_name%TYPE;
9132 l_validate_line VARCHAR2(1) := 'Y';
9133 CURSOR c_check_context(l_flex_name fnd_descriptive_flexs_vl.descriptive_flexfield_name%TYPE) IS
9134 SELECT context_required_flag, default_context_field_name
9135 FROM FND_DESCRIPTIVE_FLEXS_VL
9136 WHERE (application_id = 660)
9137 AND (descriptive_flexfield_name = l_flex_name); --End of bug#7380336
9138
9139 BEGIN
9140 if OE_GLOBALS.g_validate_desc_flex ='Y' then --4230230
9141 IF l_debug_level > 0 then
9142 oe_debug_pub.add('Entering Oe_Validate_Line.Validate_Flex with status: '||x_return_status,2);
9143 END IF;
9144
9145 -- Bug 2333071 : Excluding Flexfield validation for CONFIG line
9146 -- Fixing 2375476 to skip the Flex field validation in case of
9147 -- Internal Orders. This condition will be removed once process Order
9148 -- starts defaulting the FF
9149 -- The AND condition added for 2611912, to exclude validation in
9150 -- case of order lines coming from CRM. It can be removed once
9151 -- Process Order starts defaulting the FF
9152
9153 -- IF (p_x_line_rec.item_type_code <> OE_GLOBALS.G_ITEM_CONFIG AND
9154 -- p_x_line_rec.order_source_id <> 10 AND -- added for 2611912
9155 -- (p_x_line_rec.source_document_type_id IS NULL OR
9156 -- p_x_line_rec.source_document_type_id = FND_API.G_MISS_NUM OR
9157 -- p_x_line_rec.source_document_type_id = 2)) THEN
9158
9159 --Start of bug#7380336
9160 OPEN c_check_context('OE_LINE_ATTRIBUTES');
9161 FETCH c_check_context INTO l_context_required_flag,l_default_context_field_name;
9162 CLOSE c_check_context;
9163
9164 -- Skip the Validation if not changes are made in the DFF from the UI.
9165 IF l_context_required_flag = 'Y' AND ( p_x_line_rec.context IS NULL OR p_x_line_rec.context = FND_API.G_MISS_CHAR ) AND (OE_GLOBALS.G_UI_FLAG) THEN
9166 l_validate_line := 'N';
9167 IF l_debug_level > 0 then
9168 oe_debug_pub.add('Skipping Validation');
9169 END IF;
9170
9171 ELSIF l_context_required_flag = 'Y' AND ( p_x_line_rec.context IS NULL OR p_x_line_rec.context = FND_API.G_MISS_CHAR ) AND NOT (OE_GLOBALS.G_UI_FLAG) THEN
9172 -- Show Error message if appropriate context value is not passed
9173 -- from the Process Order Call and if the Context field is required.
9174 IF l_debug_level > 0 THEN
9175 oe_debug_pub.add( 'before call to desc_flex Context not set for OE_LINE_ATTRIBUTES DFF ' ) ;
9176 END IF;
9177
9178 ELSE
9179 -- Validate the DFF in all other cases.
9180 l_validate_line := 'Y';
9181 IF l_debug_level > 0 then
9182 oe_debug_pub.add('Validating the Flex Field');
9183 END IF;
9184 END IF; --End of bug#7380336
9185
9186 IF(l_validate_line = 'Y') THEN --Bug#7380336
9187
9188 IF p_x_line_rec.operation = oe_globals.g_opr_create OR
9189 (p_x_line_rec.operation = oe_globals.g_opr_update AND
9190 (p_x_line_rec.attribute1 IS NOT NULL AND
9191 ( p_x_line_rec.attribute1 <>
9192 p_old_line_rec.attribute1 OR
9193 p_old_line_rec.attribute1 IS NULL ))
9194 OR (p_x_line_rec.attribute10 IS NOT NULL AND
9195 ( p_x_line_rec.attribute10 <>
9196 p_old_line_rec.attribute10 OR
9197 p_old_line_rec.attribute10 IS NULL ))
9198 OR (p_x_line_rec.attribute11 IS NOT NULL AND
9199 ( p_x_line_rec.attribute11 <>
9200 p_old_line_rec.attribute11 OR
9201 p_old_line_rec.attribute11 IS NULL ))
9202 OR (p_x_line_rec.attribute12 IS NOT NULL AND
9203 ( p_x_line_rec.attribute12 <>
9204 p_old_line_rec.attribute12 OR
9205 p_old_line_rec.attribute12 IS NULL ))
9206 OR (p_x_line_rec.attribute13 IS NOT NULL AND
9207 ( p_x_line_rec.attribute13 <>
9208 p_old_line_rec.attribute13 OR
9209 p_old_line_rec.attribute13 IS NULL ))
9210 OR (p_x_line_rec.attribute14 IS NOT NULL AND
9211 ( p_x_line_rec.attribute14 <>
9212 p_old_line_rec.attribute14 OR
9213 p_old_line_rec.attribute14 IS NULL ))
9214 OR (p_x_line_rec.attribute15 IS NOT NULL AND
9215 ( p_x_line_rec.attribute15 <>
9216 p_old_line_rec.attribute15 OR
9217 p_old_line_rec.attribute15 IS NULL ))
9218 OR (p_x_line_rec.attribute16 IS NOT NULL AND -- For bug 2184255
9219 ( p_x_line_rec.attribute16 <>
9220 p_old_line_rec.attribute16 OR
9221 p_old_line_rec.attribute16 IS NULL ))
9222 OR (p_x_line_rec.attribute17 IS NOT NULL AND
9223 ( p_x_line_rec.attribute17 <>
9224 p_old_line_rec.attribute17 OR
9225 p_old_line_rec.attribute17 IS NULL ))
9226 OR (p_x_line_rec.attribute18 IS NOT NULL AND
9227 ( p_x_line_rec.attribute18 <>
9228 p_old_line_rec.attribute18 OR
9229 p_old_line_rec.attribute18 IS NULL ))
9230 OR (p_x_line_rec.attribute19 IS NOT NULL AND
9231 ( p_x_line_rec.attribute19 <>
9232 p_old_line_rec.attribute19 OR
9233 p_old_line_rec.attribute19 IS NULL ))
9234 OR (p_x_line_rec.attribute2 IS NOT NULL AND
9235 ( p_x_line_rec.attribute2 <>
9236 p_old_line_rec.attribute2 OR
9237 p_old_line_rec.attribute2 IS NULL ))
9238 OR (p_x_line_rec.attribute20 IS NOT NULL AND
9239 ( p_x_line_rec.attribute20 <>
9240 p_old_line_rec.attribute20 OR
9241 p_old_line_rec.attribute20 IS NULL ))
9242 OR (p_x_line_rec.attribute3 IS NOT NULL AND
9243 ( p_x_line_rec.attribute3 <>
9244 p_old_line_rec.attribute3 OR
9245 p_old_line_rec.attribute3 IS NULL ))
9246 OR (p_x_line_rec.attribute4 IS NOT NULL AND
9247 ( p_x_line_rec.attribute4 <>
9248 p_old_line_rec.attribute4 OR
9249 p_old_line_rec.attribute4 IS NULL ))
9250 OR (p_x_line_rec.attribute5 IS NOT NULL AND
9251 ( p_x_line_rec.attribute5 <>
9252 p_old_line_rec.attribute5 OR
9253 p_old_line_rec.attribute5 IS NULL ))
9254 OR (p_x_line_rec.attribute6 IS NOT NULL AND
9255 ( p_x_line_rec.attribute6 <>
9256 p_old_line_rec.attribute6 OR
9257 p_old_line_rec.attribute6 IS NULL ))
9258 OR (p_x_line_rec.attribute7 IS NOT NULL AND
9259 ( p_x_line_rec.attribute7 <>
9260 p_old_line_rec.attribute7 OR
9261 p_old_line_rec.attribute7 IS NULL ))
9262 OR (p_x_line_rec.attribute8 IS NOT NULL AND
9263 ( p_x_line_rec.attribute8 <>
9264 p_old_line_rec.attribute8 OR
9265 p_old_line_rec.attribute8 IS NULL ))
9266 OR (p_x_line_rec.attribute9 IS NOT NULL AND
9267 ( p_x_line_rec.attribute9 <>
9268 p_old_line_rec.attribute9 OR
9269 p_old_line_rec.attribute9 IS NULL ))
9270 OR (p_x_line_rec.context IS NOT NULL AND
9271 ( p_x_line_rec.context <>
9272 p_old_line_rec.context OR
9273 p_old_line_rec.context IS NULL )))
9274 THEN
9275 IF l_debug_level > 0 then
9276 oe_debug_pub.add('Before calling line_desc_flex',2);
9277 END IF;
9278 IF Oe_Order_Cache.IS_FLEX_ENABLED('OE_LINE_ATTRIBUTES') = 'Y' THEN
9279
9280 IF NOT OE_VALIDATE.Line_Desc_Flex
9281 (p_context => p_x_line_rec.context
9282 ,p_attribute1 => p_x_line_rec.attribute1
9283 ,p_attribute2 => p_x_line_rec.attribute2
9284 ,p_attribute3 => p_x_line_rec.attribute3
9285 ,p_attribute4 => p_x_line_rec.attribute4
9286 ,p_attribute5 => p_x_line_rec.attribute5
9287 ,p_attribute6 => p_x_line_rec.attribute6
9288 ,p_attribute7 => p_x_line_rec.attribute7
9289 ,p_attribute8 => p_x_line_rec.attribute8
9290 ,p_attribute9 => p_x_line_rec.attribute9
9291 ,p_attribute10 => p_x_line_rec.attribute10
9292 ,p_attribute11 => p_x_line_rec.attribute11
9293 ,p_attribute12 => p_x_line_rec.attribute12
9294 ,p_attribute13 => p_x_line_rec.attribute13
9295 ,p_attribute14 => p_x_line_rec.attribute14
9296 ,p_attribute15 => p_x_line_rec.attribute15
9297 ,p_attribute16 => p_x_line_rec.attribute16 -- for bug 2184255
9298 ,p_attribute17 => p_x_line_rec.attribute17
9299 ,p_attribute18 => p_x_line_rec.attribute18
9300 ,p_attribute19 => p_x_line_rec.attribute19
9301 ,p_attribute20 => p_x_line_rec.attribute20) THEN
9302
9303 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
9304 p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
9305
9306 p_x_line_rec.context := null;
9307 p_x_line_rec.attribute1 := null;
9308 p_x_line_rec.attribute2 := null;
9309 p_x_line_rec.attribute3 := null;
9310 p_x_line_rec.attribute4 := null;
9311 p_x_line_rec.attribute5 := null;
9312 p_x_line_rec.attribute6 := null;
9313 p_x_line_rec.attribute7 := null;
9314 p_x_line_rec.attribute8 := null;
9315 p_x_line_rec.attribute9 := null;
9316 p_x_line_rec.attribute10 := null;
9317 p_x_line_rec.attribute11 := null;
9318 p_x_line_rec.attribute12 := null;
9319 p_x_line_rec.attribute13 := null;
9320 p_x_line_rec.attribute14 := null;
9321 p_x_line_rec.attribute15 := null;
9322 p_x_line_rec.attribute16 := null; -- for bug 2184255
9323 p_x_line_rec.attribute17 := null;
9324 p_x_line_rec.attribute18 := null;
9325 p_x_line_rec.attribute19 := null;
9326 p_x_line_rec.attribute20 := null;
9327
9328 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
9329 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
9330
9331 p_x_line_rec.context := FND_API.G_MISS_CHAR;
9332 p_x_line_rec.attribute1 := FND_API.G_MISS_CHAR;
9333 p_x_line_rec.attribute2 := FND_API.G_MISS_CHAR;
9334 p_x_line_rec.attribute3 := FND_API.G_MISS_CHAR;
9335 p_x_line_rec.attribute4 := FND_API.G_MISS_CHAR;
9336 p_x_line_rec.attribute5 := FND_API.G_MISS_CHAR;
9337 p_x_line_rec.attribute6 := FND_API.G_MISS_CHAR;
9338 p_x_line_rec.attribute7 := FND_API.G_MISS_CHAR;
9339 p_x_line_rec.attribute8 := FND_API.G_MISS_CHAR;
9340 p_x_line_rec.attribute9 := FND_API.G_MISS_CHAR;
9341 p_x_line_rec.attribute10 := FND_API.G_MISS_CHAR;
9342 p_x_line_rec.attribute11 := FND_API.G_MISS_CHAR;
9343 p_x_line_rec.attribute12 := FND_API.G_MISS_CHAR;
9344 p_x_line_rec.attribute13 := FND_API.G_MISS_CHAR;
9345 p_x_line_rec.attribute14 := FND_API.G_MISS_CHAR;
9346 p_x_line_rec.attribute15 := FND_API.G_MISS_CHAR;
9347 p_x_line_rec.attribute16 := FND_API.G_MISS_CHAR; -- for bug 2184255
9348 p_x_line_rec.attribute17 := FND_API.G_MISS_CHAR;
9349 p_x_line_rec.attribute18 := FND_API.G_MISS_CHAR;
9350 p_x_line_rec.attribute19 := FND_API.G_MISS_CHAR;
9351 p_x_line_rec.attribute20 := FND_API.G_MISS_CHAR;
9352
9353 ELSIF p_validation_level = FND_API.G_VALID_LEVEL_NONE THEN
9354 NULL;
9355
9356 ELSE
9357 x_return_status := FND_API.G_RET_STS_ERROR;
9358 END IF;
9359
9360 ELSE -- if the flex validation is successfull
9361 -- For bug 2511313
9362 IF p_x_line_rec.context IS NULL
9363 OR p_x_line_rec.context = FND_API.G_MISS_CHAR THEN
9364 p_x_line_rec.context := oe_validate.g_context;
9365 END IF;
9366
9367 IF p_x_line_rec.attribute1 IS NULL
9368 OR p_x_line_rec.attribute1 = FND_API.G_MISS_CHAR THEN
9369 p_x_line_rec.attribute1 := oe_validate.g_attribute1;
9370 END IF;
9371
9372 IF p_x_line_rec.attribute2 IS NULL
9373 OR p_x_line_rec.attribute2 = FND_API.G_MISS_CHAR THEN
9374 p_x_line_rec.attribute2 := oe_validate.g_attribute2;
9375 END IF;
9376
9377 IF p_x_line_rec.attribute3 IS NULL
9378 OR p_x_line_rec.attribute3 = FND_API.G_MISS_CHAR THEN
9379 p_x_line_rec.attribute3 := oe_validate.g_attribute3;
9380 END IF;
9381
9382 IF p_x_line_rec.attribute4 IS NULL
9383 OR p_x_line_rec.attribute4 = FND_API.G_MISS_CHAR THEN
9384 p_x_line_rec.attribute4 := oe_validate.g_attribute4;
9385 END IF;
9386
9387 IF p_x_line_rec.attribute5 IS NULL
9388 OR p_x_line_rec.attribute5 = FND_API.G_MISS_CHAR THEN
9389 p_x_line_rec.attribute5 := oe_validate.g_attribute5;
9390 END IF;
9391
9392 IF p_x_line_rec.attribute6 IS NULL
9393 OR p_x_line_rec.attribute6 = FND_API.G_MISS_CHAR THEN
9394 p_x_line_rec.attribute6 := oe_validate.g_attribute6;
9395 END IF;
9396
9397 IF p_x_line_rec.attribute7 IS NULL
9398 OR p_x_line_rec.attribute7 = FND_API.G_MISS_CHAR THEN
9399 p_x_line_rec.attribute7 := oe_validate.g_attribute7;
9400 END IF;
9401
9402 IF p_x_line_rec.attribute8 IS NULL
9403 OR p_x_line_rec.attribute8 = FND_API.G_MISS_CHAR THEN
9404 p_x_line_rec.attribute8 := oe_validate.g_attribute8;
9405 END IF;
9406
9407 IF p_x_line_rec.attribute9 IS NULL
9408 OR p_x_line_rec.attribute9 = FND_API.G_MISS_CHAR THEN
9409 p_x_line_rec.attribute9 := oe_validate.g_attribute9;
9410 END IF;
9411
9412 IF p_x_line_rec.attribute10 IS NULL
9413 OR p_x_line_rec.attribute10 = FND_API.G_MISS_CHAR THEN
9414 p_x_line_rec.attribute10 := Oe_validate.G_attribute10;
9415 End IF;
9416
9417 IF p_x_line_rec.attribute11 IS NULL
9418 OR p_x_line_rec.attribute11 = FND_API.G_MISS_CHAR THEN
9419 p_x_line_rec.attribute11 := oe_validate.g_attribute11;
9420 END IF;
9421
9422 IF p_x_line_rec.attribute12 IS NULL
9423 OR p_x_line_rec.attribute12 = FND_API.G_MISS_CHAR THEN
9424 p_x_line_rec.attribute12 := oe_validate.g_attribute12;
9425 END IF;
9426
9427 IF p_x_line_rec.attribute13 IS NULL
9428 OR p_x_line_rec.attribute13 = FND_API.G_MISS_CHAR THEN
9429 p_x_line_rec.attribute13 := oe_validate.g_attribute13;
9430 END IF;
9431
9432 IF p_x_line_rec.attribute14 IS NULL
9433 OR p_x_line_rec.attribute14 = FND_API.G_MISS_CHAR THEN
9434 p_x_line_rec.attribute14 := oe_validate.g_attribute14;
9435 END IF;
9436
9437 IF p_x_line_rec.attribute15 IS NULL
9438 OR p_x_line_rec.attribute15 = FND_API.G_MISS_CHAR THEN
9439 p_x_line_rec.attribute15 := oe_validate.g_attribute15;
9440 END IF;
9441 IF p_x_line_rec.attribute16 IS NULL -- for bug 2184255
9442 OR p_x_line_rec.attribute16 = FND_API.G_MISS_CHAR THEN
9443 p_x_line_rec.attribute16 := oe_validate.g_attribute16;
9444 END IF;
9445
9446 IF p_x_line_rec.attribute17 IS NULL
9447 OR p_x_line_rec.attribute17 = FND_API.G_MISS_CHAR THEN
9448 p_x_line_rec.attribute17 := oe_validate.g_attribute17;
9449 END IF;
9450
9451 IF p_x_line_rec.attribute18 IS NULL
9452 OR p_x_line_rec.attribute18 = FND_API.G_MISS_CHAR THEN
9453 p_x_line_rec.attribute18 := oe_validate.g_attribute18;
9454 END IF;
9455
9456 IF p_x_line_rec.attribute19 IS NULL
9457 OR p_x_line_rec.attribute19 = FND_API.G_MISS_CHAR THEN
9458 p_x_line_rec.attribute19 := oe_validate.g_attribute19;
9459 END IF;
9460
9461 IF p_x_line_rec.attribute20 IS NULL -- for bug 2184255
9462 OR p_x_line_rec.attribute20 = FND_API.G_MISS_CHAR THEN
9463 p_x_line_rec.attribute20 := oe_validate.g_attribute20;
9464 END IF;
9465
9466 -- end of assignments, bug 2511313
9467 END IF; -- Flex Validation successfull
9468 END IF; -- Is flex enabled
9469 IF l_debug_level > 0 then
9470 oe_debug_pub.add('After line_desc_flex ' || x_return_status,2);
9471 END IF;
9472
9473 END IF; -- For Additional Line Information
9474
9475 END IF; --bug#7380336
9476
9477 --Start of bug#7380336
9478 --Added the condition here so that, if default value are provided, they can be defaulted by the flex api.
9479
9480 IF l_context_required_flag = 'Y' AND ( p_x_line_rec.context IS NULL OR p_x_line_rec.context = FND_API.G_MISS_CHAR ) AND NOT (OE_GLOBALS.G_UI_FLAG) THEN
9481
9482 -- Show Error message if appropriate context value is not passed
9483 -- from the Process Order Call and if the Context field is required
9484 -- and context is not defaulted by the flex api.
9485
9486 IF OE_OE_PRICING_AVAILABILITY.IS_PRICING_AVAILIBILITY = 'N' THEN
9487 FND_MESSAGE.SET_NAME('FND', 'ONT_CONTEXT_NOT_FOUND');
9488 OE_MSG_PUB.ADD;
9489 IF l_debug_level > 0 THEN
9490 oe_debug_pub.add('desc_flex Context Not set for OE_LINE_ATTRIBUTES DFF ') ;
9491 END IF;
9492 RAISE FND_API.G_EXC_ERROR;
9493 END IF;
9494 END IF; --End of bug#7380336
9495
9496 -- END IF;
9497 /* Fixing 2375476 to skip the Flex field validation in case of
9498 Internal Orders. This condition will be removed once process Order
9499 starts defaulting the FF */
9500 -- IF p_x_line_rec.order_source_id <> 10 THEN
9501 IF p_x_line_rec.operation = oe_globals.g_opr_create
9502 OR
9503 ( p_x_line_rec.operation = oe_globals.g_opr_update AND
9504 (p_x_line_rec.global_attribute1 IS NOT NULL AND
9505 ( p_x_line_rec.global_attribute1 <>
9506 p_old_line_rec.global_attribute1 OR
9507 p_old_line_rec.global_attribute1 IS NULL ))
9508 OR (p_x_line_rec.global_attribute10 IS NOT NULL AND
9509 ( p_x_line_rec.global_attribute10 <>
9510 p_old_line_rec.global_attribute10 OR
9511 p_old_line_rec.global_attribute10 IS NULL ))
9512 OR (p_x_line_rec.global_attribute11 IS NOT NULL AND
9513 ( p_x_line_rec.global_attribute11 <>
9514 p_old_line_rec.global_attribute11 OR
9515 p_old_line_rec.global_attribute11 IS NULL ))
9516 OR (p_x_line_rec.global_attribute12 IS NOT NULL AND
9517 ( p_x_line_rec.global_attribute12 <>
9518 p_old_line_rec.global_attribute12 OR
9519 p_old_line_rec.global_attribute12 IS NULL ))
9520 OR (p_x_line_rec.global_attribute13 IS NOT NULL AND
9521 ( p_x_line_rec.global_attribute13 <>
9522 p_old_line_rec.global_attribute13 OR
9523 p_old_line_rec.global_attribute13 IS NULL ))
9524 OR (p_x_line_rec.global_attribute14 IS NOT NULL AND
9525 ( p_x_line_rec.global_attribute14 <>
9526 p_old_line_rec.global_attribute14 OR
9527 p_old_line_rec.global_attribute14 IS NULL ))
9528 OR (p_x_line_rec.global_attribute15 IS NOT NULL AND
9529 ( p_x_line_rec.global_attribute15 <>
9530 p_old_line_rec.global_attribute15 OR
9531 p_old_line_rec.global_attribute15 IS NULL ))
9532 OR (p_x_line_rec.global_attribute16 IS NOT NULL AND
9533 ( p_x_line_rec.global_attribute16 <>
9534 p_old_line_rec.global_attribute16 OR
9535 p_old_line_rec.global_attribute16 IS NULL ))
9536 OR (p_x_line_rec.global_attribute17 IS NOT NULL AND
9537 ( p_x_line_rec.global_attribute17 <>
9538 p_old_line_rec.global_attribute17 OR
9539 p_old_line_rec.global_attribute17 IS NULL ))
9540 OR (p_x_line_rec.global_attribute18 IS NOT NULL AND
9541 ( p_x_line_rec.global_attribute18 <>
9542 p_old_line_rec.global_attribute18 OR
9543 p_old_line_rec.global_attribute18 IS NULL ))
9544 OR (p_x_line_rec.global_attribute19 IS NOT NULL AND
9545 ( p_x_line_rec.global_attribute19 <>
9546 p_old_line_rec.global_attribute19 OR
9547 p_old_line_rec.global_attribute19 IS NULL ))
9548 OR (p_x_line_rec.global_attribute2 IS NOT NULL AND
9549 ( p_x_line_rec.global_attribute2 <>
9550 p_old_line_rec.global_attribute2 OR
9551 p_old_line_rec.global_attribute2 IS NULL ))
9552 OR (p_x_line_rec.global_attribute20 IS NOT NULL AND
9553 ( p_x_line_rec.global_attribute20 <>
9554 p_old_line_rec.global_attribute20 OR
9555 p_old_line_rec.global_attribute20 IS NULL ))
9556 OR (p_x_line_rec.global_attribute3 IS NOT NULL AND
9557 ( p_x_line_rec.global_attribute3 <>
9558 p_old_line_rec.global_attribute3 OR
9559 p_old_line_rec.global_attribute3 IS NULL ))
9560 OR (p_x_line_rec.global_attribute4 IS NOT NULL AND
9561 ( p_x_line_rec.global_attribute4 <>
9562 p_old_line_rec.global_attribute4 OR
9563 p_old_line_rec.global_attribute4 IS NULL ))
9564 OR (p_x_line_rec.global_attribute5 IS NOT NULL AND
9565 ( p_x_line_rec.global_attribute5 <>
9566 p_old_line_rec.global_attribute5 OR
9567 p_old_line_rec.global_attribute5 IS NULL ))
9568 OR (p_x_line_rec.global_attribute6 IS NOT NULL AND
9569 ( p_x_line_rec.global_attribute6 <>
9570 p_old_line_rec.global_attribute6 OR
9571 p_old_line_rec.global_attribute6 IS NULL ))
9572 OR (p_x_line_rec.global_attribute7 IS NOT NULL AND
9573 ( p_x_line_rec.global_attribute7 <>
9574 p_old_line_rec.global_attribute7 OR
9575 p_old_line_rec.global_attribute7 IS NULL ))
9576 OR (p_x_line_rec.global_attribute8 IS NOT NULL AND
9577 ( p_x_line_rec.global_attribute8 <>
9578 p_old_line_rec.global_attribute8 OR
9579 p_old_line_rec.global_attribute8 IS NULL ))
9580 OR (p_x_line_rec.global_attribute9 IS NOT NULL AND
9581 ( p_x_line_rec.global_attribute9 <>
9582 p_old_line_rec.global_attribute9 OR
9583 p_old_line_rec.global_attribute9 IS NULL ))
9584 OR (p_x_line_rec.global_attribute_category IS NOT NULL AND
9585 ( p_x_line_rec.global_attribute_category <>
9586 p_old_line_rec.global_attribute_category OR
9587 p_old_line_rec.global_attribute_category IS NULL )))
9588 THEN
9589
9590
9591 IF l_debug_level > 0 then
9592 OE_DEBUG_PUB.ADD('Before G_line_desc_flex',2);
9593 END IF;
9594 IF Oe_Order_Cache.IS_FLEX_ENABLED('OE_LINE_GLOBAL_ATTRIBUTE') = 'Y' THEN
9595 IF NOT OE_VALIDATE.G_Line_Desc_Flex
9596 (p_context => p_x_line_rec.global_attribute_category
9597 ,p_attribute1 => p_x_line_rec.global_attribute1
9598 ,p_attribute2 => p_x_line_rec.global_attribute2
9599 ,p_attribute3 => p_x_line_rec.global_attribute3
9600 ,p_attribute4 => p_x_line_rec.global_attribute4
9601 ,p_attribute5 => p_x_line_rec.global_attribute5
9602 ,p_attribute6 => p_x_line_rec.global_attribute6
9603 ,p_attribute7 => p_x_line_rec.global_attribute7
9604 ,p_attribute8 => p_x_line_rec.global_attribute8
9605 ,p_attribute9 => p_x_line_rec.global_attribute9
9606 ,p_attribute10 => p_x_line_rec.global_attribute10
9607 ,p_attribute11 => p_x_line_rec.global_attribute11
9608 ,p_attribute12 => p_x_line_rec.global_attribute12
9609 ,p_attribute13 => p_x_line_rec.global_attribute13
9610 ,p_attribute14 => p_x_line_rec.global_attribute13
9611 ,p_attribute15 => p_x_line_rec.global_attribute14
9612 ,p_attribute16 => p_x_line_rec.global_attribute16
9613 ,p_attribute17 => p_x_line_rec.global_attribute17
9614 ,p_attribute18 => p_x_line_rec.global_attribute18
9615 ,p_attribute19 => p_x_line_rec.global_attribute19
9616 ,p_attribute20 => p_x_line_rec.global_attribute20) THEN
9617
9618 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
9619 p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
9620
9621 p_x_line_rec.global_attribute_category := null;
9622 p_x_line_rec.global_attribute1 := null;
9623 p_x_line_rec.global_attribute2 := null;
9624 p_x_line_rec.global_attribute3 := null;
9625 p_x_line_rec.global_attribute4 := null;
9626 p_x_line_rec.global_attribute5 := null;
9627 p_x_line_rec.global_attribute6 := null;
9628 p_x_line_rec.global_attribute7 := null;
9629 p_x_line_rec.global_attribute8 := null;
9630 p_x_line_rec.global_attribute9 := null;
9631 p_x_line_rec.global_attribute11 := null;
9632 p_x_line_rec.global_attribute12 := null;
9633 p_x_line_rec.global_attribute13 := null;
9634 p_x_line_rec.global_attribute14 := null;
9635 p_x_line_rec.global_attribute15 := null;
9636 p_x_line_rec.global_attribute16 := null;
9637 p_x_line_rec.global_attribute17 := null;
9638 p_x_line_rec.global_attribute18 := null;
9639 p_x_line_rec.global_attribute19 := null;
9640 p_x_line_rec.global_attribute20 := null;
9641
9642 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
9643 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
9644 p_x_line_rec.global_attribute_category := FND_API.G_MISS_CHAR;
9645 p_x_line_rec.global_attribute1 := FND_API.G_MISS_CHAR;
9646 p_x_line_rec.global_attribute2 := FND_API.G_MISS_CHAR;
9647 p_x_line_rec.global_attribute3 := FND_API.G_MISS_CHAR;
9648 p_x_line_rec.global_attribute4 := FND_API.G_MISS_CHAR;
9649 p_x_line_rec.global_attribute5 := FND_API.G_MISS_CHAR;
9650 p_x_line_rec.global_attribute6 := FND_API.G_MISS_CHAR;
9651 p_x_line_rec.global_attribute7 := FND_API.G_MISS_CHAR;
9652 p_x_line_rec.global_attribute8 := FND_API.G_MISS_CHAR;
9653 p_x_line_rec.global_attribute9 := FND_API.G_MISS_CHAR;
9654 p_x_line_rec.global_attribute11 := FND_API.G_MISS_CHAR;
9655 p_x_line_rec.global_attribute12 := FND_API.G_MISS_CHAR;
9656 p_x_line_rec.global_attribute13 := FND_API.G_MISS_CHAR;
9657 p_x_line_rec.global_attribute14 := FND_API.G_MISS_CHAR;
9658 p_x_line_rec.global_attribute15 := FND_API.G_MISS_CHAR;
9659 p_x_line_rec.global_attribute16 := FND_API.G_MISS_CHAR;
9660 p_x_line_rec.global_attribute17 := FND_API.G_MISS_CHAR;
9661 p_x_line_rec.global_attribute18 := FND_API.G_MISS_CHAR;
9662 p_x_line_rec.global_attribute19 := FND_API.G_MISS_CHAR;
9663 p_x_line_rec.global_attribute20 := FND_API.G_MISS_CHAR;
9664
9665 ELSIF p_validation_level = FND_API.G_VALID_LEVEL_NONE THEN
9666 NULL;
9667
9668 ELSE
9669 x_return_status := FND_API.G_RET_STS_ERROR;
9670 END IF;
9671
9672 ELSE -- for bug 2511313
9673 IF p_x_line_rec.global_attribute_category IS NULL
9674 OR p_x_line_rec.global_attribute_category = FND_API.G_MISS_CHAR THEN
9675 p_x_line_rec.global_attribute_category := oe_validate.g_context;
9676 END IF;
9677
9678 IF p_x_line_rec.global_attribute1 IS NULL
9679 OR p_x_line_rec.global_attribute1 = FND_API.G_MISS_CHAR THEN
9680 p_x_line_rec.global_attribute1 := oe_validate.g_attribute1;
9681 END IF;
9682
9683 IF p_x_line_rec.global_attribute2 IS NULL
9684 OR p_x_line_rec.global_attribute2 = FND_API.G_MISS_CHAR THEN
9685 p_x_line_rec.global_attribute2 := oe_validate.g_attribute2;
9686 END IF;
9687
9688 IF p_x_line_rec.global_attribute3 IS NULL
9689 OR p_x_line_rec.global_attribute3 = FND_API.G_MISS_CHAR THEN
9690 p_x_line_rec.global_attribute3 := oe_validate.g_attribute3;
9691 END IF;
9692
9693 IF p_x_line_rec.global_attribute4 IS NULL
9694 OR p_x_line_rec.global_attribute4 = FND_API.G_MISS_CHAR THEN
9695 p_x_line_rec.global_attribute4 := oe_validate.g_attribute4;
9696 END IF;
9697
9698 IF p_x_line_rec.global_attribute5 IS NULL
9699 OR p_x_line_rec.global_attribute5 = FND_API.G_MISS_CHAR THEN
9700 p_x_line_rec.global_attribute5 := oe_validate.g_attribute5;
9701 END IF;
9702
9703 IF p_x_line_rec.global_attribute6 IS NULL
9704 OR p_x_line_rec.global_attribute6 = FND_API.G_MISS_CHAR THEN
9705 p_x_line_rec.global_attribute6 := oe_validate.g_attribute6;
9706 END IF;
9707
9708 IF p_x_line_rec.global_attribute7 IS NULL
9709 OR p_x_line_rec.global_attribute7 = FND_API.G_MISS_CHAR THEN
9710 p_x_line_rec.global_attribute7 := oe_validate.g_attribute7;
9711 END IF;
9712
9713 IF p_x_line_rec.global_attribute8 IS NULL
9714 OR p_x_line_rec.global_attribute8 = FND_API.G_MISS_CHAR THEN
9715 p_x_line_rec.global_attribute8 := oe_validate.g_attribute8;
9716 END IF;
9717
9718 IF p_x_line_rec.global_attribute9 IS NULL
9719 OR p_x_line_rec.global_attribute9 = FND_API.G_MISS_CHAR THEN
9720 p_x_line_rec.global_attribute9 := oe_validate.g_attribute9;
9721 END IF;
9722
9723 IF p_x_line_rec.global_attribute11 IS NULL
9724 OR p_x_line_rec.global_attribute11 = FND_API.G_MISS_CHAR THEN
9725 p_x_line_rec.global_attribute11 := oe_validate.g_attribute11;
9726 END IF;
9727
9728 IF p_x_line_rec.global_attribute12 IS NULL
9729 OR p_x_line_rec.global_attribute12 = FND_API.G_MISS_CHAR THEN
9730 p_x_line_rec.global_attribute12 := oe_validate.g_attribute12;
9731 END IF;
9732
9733 IF p_x_line_rec.global_attribute13 IS NULL
9734 OR p_x_line_rec.global_attribute13 = FND_API.G_MISS_CHAR THEN
9735 p_x_line_rec.global_attribute13 := oe_validate.g_attribute13;
9736 END IF;
9737
9738 IF p_x_line_rec.global_attribute14 IS NULL
9739 OR p_x_line_rec.global_attribute14 = FND_API.G_MISS_CHAR THEN
9740 p_x_line_rec.global_attribute14 := oe_validate.g_attribute14;
9741 END IF;
9742
9743 IF p_x_line_rec.global_attribute15 IS NULL
9744 OR p_x_line_rec.global_attribute15 = FND_API.G_MISS_CHAR THEN
9745 p_x_line_rec.global_attribute15 := oe_validate.g_attribute15;
9746 END IF;
9747
9748 IF p_x_line_rec.global_attribute16 IS NULL
9749 OR p_x_line_rec.global_attribute16 = FND_API.G_MISS_CHAR THEN
9750 p_x_line_rec.global_attribute16 := oe_validate.g_attribute16;
9751 END IF;
9752
9753 IF p_x_line_rec.global_attribute17 IS NULL
9754 OR p_x_line_rec.global_attribute17 = FND_API.G_MISS_CHAR THEN
9755 p_x_line_rec.global_attribute17 := oe_validate.g_attribute17;
9756 END IF;
9757
9758 IF p_x_line_rec.global_attribute18 IS NULL
9759 OR p_x_line_rec.global_attribute18 = FND_API.G_MISS_CHAR THEN
9760 p_x_line_rec.global_attribute18 := oe_validate.g_attribute18;
9761 END IF;
9762
9763 IF p_x_line_rec.global_attribute19 IS NULL
9764 OR p_x_line_rec.global_attribute19 = FND_API.G_MISS_CHAR THEN
9765 p_x_line_rec.global_attribute19 := oe_validate.g_attribute19;
9766 END IF;
9767
9768 IF p_x_line_rec.global_attribute20 IS NULL
9769 OR p_x_line_rec.global_attribute20 = FND_API.G_MISS_CHAR THEN
9770 p_x_line_rec.global_attribute20 := oe_validate.g_attribute20;
9771 END IF;
9772
9773 IF p_x_line_rec.global_attribute10 IS NULL
9774 OR p_x_line_rec.global_attribute10 = FND_API.G_MISS_CHAR THEN
9775 p_x_line_rec.global_attribute10 := oe_validate.g_attribute10;
9776 END IF;
9777 -- end of bug 2511313
9778 END IF;
9779
9780 END IF; -- Is flex enabled
9781 IF l_debug_level > 0 then
9782 OE_DEBUG_PUB.ADD('After G_Line_desc_flex ' || x_return_status,2);
9783 END IF;
9784
9785 END IF;
9786 -- END IF;
9787
9788 IF p_x_line_rec.operation = oe_globals.g_opr_create OR
9789 ( p_x_line_rec.operation = oe_globals.g_opr_update AND
9790 (p_x_line_rec.industry_attribute1 IS NOT NULL AND
9791 ( p_x_line_rec.industry_attribute1 <>
9792 p_old_line_rec.industry_attribute1 OR
9793 p_old_line_rec.industry_attribute1 IS NULL ))
9794 OR (p_x_line_rec.industry_attribute10 IS NOT NULL AND
9795 ( p_x_line_rec.industry_attribute10 <>
9796 p_old_line_rec.industry_attribute10 OR
9797 p_old_line_rec.industry_attribute10 IS NULL ))
9798 OR (p_x_line_rec.industry_attribute11 IS NOT NULL AND
9799 ( p_x_line_rec.industry_attribute11 <>
9800 p_old_line_rec.industry_attribute11 OR
9801 p_old_line_rec.industry_attribute11 IS NULL ))
9802 OR (p_x_line_rec.industry_attribute12 IS NOT NULL AND
9803 ( p_x_line_rec.industry_attribute12 <>
9804 p_old_line_rec.industry_attribute12 OR
9805 p_old_line_rec.industry_attribute12 IS NULL ))
9806 OR (p_x_line_rec.industry_attribute13 IS NOT NULL AND
9807 ( p_x_line_rec.industry_attribute13 <>
9808 p_old_line_rec.industry_attribute13 OR
9809 p_old_line_rec.industry_attribute13 IS NULL ))
9810 OR (p_x_line_rec.industry_attribute14 IS NOT NULL AND
9811 ( p_x_line_rec.industry_attribute14 <>
9812 p_old_line_rec.industry_attribute14 OR
9813 p_old_line_rec.industry_attribute14 IS NULL ))
9814 OR (p_x_line_rec.industry_attribute15 IS NOT NULL AND
9815 ( p_x_line_rec.industry_attribute15 <>
9816 p_old_line_rec.industry_attribute15 OR
9817 p_old_line_rec.industry_attribute15 IS NULL ))
9818 OR (p_x_line_rec.industry_attribute16 IS NOT NULL AND
9819 ( p_x_line_rec.industry_attribute16 <>
9820 p_old_line_rec.industry_attribute16 OR
9821 p_old_line_rec.industry_attribute16 IS NULL ))
9822 OR (p_x_line_rec.industry_attribute17 IS NOT NULL AND
9823 ( p_x_line_rec.industry_attribute17 <>
9824 p_old_line_rec.industry_attribute17 OR
9825 p_old_line_rec.industry_attribute17 IS NULL ))
9826 OR (p_x_line_rec.industry_attribute18 IS NOT NULL AND
9827 ( p_x_line_rec.industry_attribute18 <>
9828 p_old_line_rec.industry_attribute18 OR
9829 p_old_line_rec.industry_attribute18 IS NULL ))
9830 OR (p_x_line_rec.industry_attribute19 IS NOT NULL AND
9831 ( p_x_line_rec.industry_attribute19 <>
9832 p_old_line_rec.industry_attribute19 OR
9833 p_old_line_rec.industry_attribute19 IS NULL ))
9834 OR (p_x_line_rec.industry_attribute2 IS NOT NULL AND
9835 ( p_x_line_rec.industry_attribute2 <>
9836 p_old_line_rec.industry_attribute2 OR
9837 p_old_line_rec.industry_attribute2 IS NULL ))
9838 OR (p_x_line_rec.industry_attribute20 IS NOT NULL AND
9839 ( p_x_line_rec.industry_attribute20 <>
9840 p_old_line_rec.industry_attribute20 OR
9841 p_old_line_rec.industry_attribute20 IS NULL ))
9842 OR (p_x_line_rec.industry_attribute21 IS NOT NULL AND
9843 ( p_x_line_rec.industry_attribute21 <>
9844 p_old_line_rec.industry_attribute21 OR
9845 p_old_line_rec.industry_attribute21 IS NULL ))
9846 OR (p_x_line_rec.industry_attribute22 IS NOT NULL AND
9847 ( p_x_line_rec.industry_attribute22 <>
9848 p_old_line_rec.industry_attribute22 OR
9849 p_old_line_rec.industry_attribute22 IS NULL ))
9850 OR (p_x_line_rec.industry_attribute23 IS NOT NULL AND
9851 ( p_x_line_rec.industry_attribute23 <>
9852 p_old_line_rec.industry_attribute23 OR
9853 p_old_line_rec.industry_attribute23 IS NULL ))
9854 OR (p_x_line_rec.industry_attribute24 IS NOT NULL AND
9855 ( p_x_line_rec.industry_attribute24 <>
9856 p_old_line_rec.industry_attribute24 OR
9857 p_old_line_rec.industry_attribute24 IS NULL ))
9858 OR (p_x_line_rec.industry_attribute25 IS NOT NULL AND
9859 ( p_x_line_rec.industry_attribute25 <>
9860 p_old_line_rec.industry_attribute25 OR
9861 p_old_line_rec.industry_attribute25 IS NULL ))
9862 OR (p_x_line_rec.industry_attribute26 IS NOT NULL AND
9863 ( p_x_line_rec.industry_attribute26 <>
9864 p_old_line_rec.industry_attribute26 OR
9865 p_old_line_rec.industry_attribute26 IS NULL ))
9866 OR (p_x_line_rec.industry_attribute27 IS NOT NULL AND
9867 ( p_x_line_rec.industry_attribute27 <>
9868 p_old_line_rec.industry_attribute27 OR
9869 p_old_line_rec.industry_attribute27 IS NULL ))
9870 OR (p_x_line_rec.industry_attribute28 IS NOT NULL AND
9871 ( p_x_line_rec.industry_attribute28 <>
9872 p_old_line_rec.industry_attribute28 OR
9873 p_old_line_rec.industry_attribute28 IS NULL ))
9874 OR (p_x_line_rec.industry_attribute29 IS NOT NULL AND
9875 ( p_x_line_rec.industry_attribute29 <>
9876 p_old_line_rec.industry_attribute29 OR
9877 p_old_line_rec.industry_attribute29 IS NULL ))
9878 OR (p_x_line_rec.industry_attribute3 IS NOT NULL AND
9879 ( p_x_line_rec.industry_attribute3 <>
9880 p_old_line_rec.industry_attribute3 OR
9881 p_old_line_rec.industry_attribute3 IS NULL ))
9882 OR (p_x_line_rec.industry_attribute30 IS NOT NULL AND
9883 ( p_x_line_rec.industry_attribute30 <>
9884 p_old_line_rec.industry_attribute30 OR
9885 p_old_line_rec.industry_attribute30 IS NULL ))
9886 OR (p_x_line_rec.industry_attribute4 IS NOT NULL AND
9887 ( p_x_line_rec.industry_attribute4 <>
9888 p_old_line_rec.industry_attribute4 OR
9889 p_old_line_rec.industry_attribute4 IS NULL ))
9890 OR (p_x_line_rec.industry_attribute5 IS NOT NULL AND
9891 ( p_x_line_rec.industry_attribute5 <>
9892 p_old_line_rec.industry_attribute5 OR
9893 p_old_line_rec.industry_attribute5 IS NULL ))
9894 OR (p_x_line_rec.industry_attribute6 IS NOT NULL AND
9895 ( p_x_line_rec.industry_attribute6 <>
9896 p_old_line_rec.industry_attribute6 OR
9897 p_old_line_rec.industry_attribute6 IS NULL ))
9898 OR (p_x_line_rec.industry_attribute7 IS NOT NULL AND
9899 ( p_x_line_rec.industry_attribute7 <>
9900 p_old_line_rec.industry_attribute7 OR
9901 p_old_line_rec.industry_attribute7 IS NULL ))
9902 OR (p_x_line_rec.industry_attribute8 IS NOT NULL AND
9903 ( p_x_line_rec.industry_attribute8 <>
9904 p_old_line_rec.industry_attribute8 OR
9905 p_old_line_rec.industry_attribute8 IS NULL ))
9906 OR (p_x_line_rec.industry_attribute9 IS NOT NULL AND
9907 ( p_x_line_rec.industry_attribute9 <>
9908 p_old_line_rec.industry_attribute9 OR
9909 p_old_line_rec.industry_attribute9 IS NULL ))
9910 OR (p_x_line_rec.industry_context IS NOT NULL AND
9911 ( p_x_line_rec.industry_context <>
9912 p_old_line_rec.industry_context OR
9913 p_old_line_rec.industry_context IS NULL )))
9914 THEN
9915 IF Oe_Order_Cache.IS_FLEX_ENABLED('OE_LINE_INDUSTRY_ATTRIBUTE') = 'Y' THEN
9916 IF NOT OE_VALIDATE.I_Line_Desc_Flex
9917 (p_context => p_x_line_rec.Industry_context
9918 ,p_attribute1 => p_x_line_rec.Industry_attribute1
9919 ,p_attribute2 => p_x_line_rec.Industry_attribute2
9920 ,p_attribute3 => p_x_line_rec.Industry_attribute3
9921 ,p_attribute4 => p_x_line_rec.Industry_attribute4
9922 ,p_attribute5 => p_x_line_rec.Industry_attribute5
9923 ,p_attribute6 => p_x_line_rec.Industry_attribute6
9924 ,p_attribute7 => p_x_line_rec.Industry_attribute7
9925 ,p_attribute8 => p_x_line_rec.Industry_attribute8
9926 ,p_attribute9 => p_x_line_rec.Industry_attribute9
9927 ,p_attribute10 => p_x_line_rec.Industry_attribute10
9928 ,p_attribute11 => p_x_line_rec.Industry_attribute11
9929 ,p_attribute12 => p_x_line_rec.Industry_attribute12
9930 ,p_attribute13 => p_x_line_rec.Industry_attribute13
9931 ,p_attribute14 => p_x_line_rec.Industry_attribute14
9932 ,p_attribute15 => p_x_line_rec.Industry_attribute15
9933 ,p_attribute16 => p_x_line_rec.Industry_attribute16
9934 ,p_attribute17 => p_x_line_rec.Industry_attribute17
9935 ,p_attribute18 => p_x_line_rec.Industry_attribute18
9936 ,p_attribute19 => p_x_line_rec.Industry_attribute19
9937 ,p_attribute20 => p_x_line_rec.Industry_attribute20
9938 ,p_attribute21 => p_x_line_rec.Industry_attribute21
9939 ,p_attribute22 => p_x_line_rec.Industry_attribute22
9940 ,p_attribute23 => p_x_line_rec.Industry_attribute23
9941 ,p_attribute24 => p_x_line_rec.Industry_attribute24
9942 ,p_attribute25 => p_x_line_rec.Industry_attribute25
9943 ,p_attribute26 => p_x_line_rec.Industry_attribute26
9944 ,p_attribute27 => p_x_line_rec.Industry_attribute27
9945 ,p_attribute28 => p_x_line_rec.Industry_attribute28
9946 ,p_attribute29 => p_x_line_rec.Industry_attribute29
9947 ,p_attribute30 => p_x_line_rec.Industry_attribute30) THEN
9948
9949 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
9950 p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
9951
9952
9953 p_x_line_rec.Industry_context := null;
9954 p_x_line_rec.Industry_attribute1 := null;
9955 p_x_line_rec.Industry_attribute2 := null;
9956 p_x_line_rec.Industry_attribute3 := null;
9957 p_x_line_rec.Industry_attribute4 := null;
9958 p_x_line_rec.Industry_attribute5 := null;
9959 p_x_line_rec.Industry_attribute6 := null;
9960 p_x_line_rec.Industry_attribute7 := null;
9961 p_x_line_rec.Industry_attribute8 := null;
9962 p_x_line_rec.Industry_attribute9 := null;
9963 p_x_line_rec.Industry_attribute10 := null;
9964 p_x_line_rec.Industry_attribute11 := null;
9965 p_x_line_rec.Industry_attribute12 := null;
9966 p_x_line_rec.Industry_attribute13 := null;
9967 p_x_line_rec.Industry_attribute14 := null;
9968 p_x_line_rec.Industry_attribute15 := null;
9969 p_x_line_rec.Industry_attribute16 := null;
9970 p_x_line_rec.Industry_attribute17 := null;
9971 p_x_line_rec.Industry_attribute18 := null;
9972 p_x_line_rec.Industry_attribute19 := null;
9973 p_x_line_rec.Industry_attribute20 := null;
9974 p_x_line_rec.Industry_attribute21 := null;
9975 p_x_line_rec.Industry_attribute22 := null;
9976 p_x_line_rec.Industry_attribute23 := null;
9977 p_x_line_rec.Industry_attribute24 := null;
9978 p_x_line_rec.Industry_attribute25 := null;
9979 p_x_line_rec.Industry_attribute26 := null;
9980 p_x_line_rec.Industry_attribute27 := null;
9981 p_x_line_rec.Industry_attribute28 := null;
9982 p_x_line_rec.Industry_attribute29 := null;
9983 p_x_line_rec.Industry_attribute30 := null;
9984
9985 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
9986 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
9987
9988 p_x_line_rec.Industry_context := FND_API.G_MISS_CHAR;
9989 p_x_line_rec.Industry_attribute1 := FND_API.G_MISS_CHAR;
9990 p_x_line_rec.Industry_attribute2 := FND_API.G_MISS_CHAR;
9991 p_x_line_rec.Industry_attribute3 := FND_API.G_MISS_CHAR;
9992 p_x_line_rec.Industry_attribute4 := FND_API.G_MISS_CHAR;
9993 p_x_line_rec.Industry_attribute5 := FND_API.G_MISS_CHAR;
9994 p_x_line_rec.Industry_attribute6 := FND_API.G_MISS_CHAR;
9995 p_x_line_rec.Industry_attribute7 := FND_API.G_MISS_CHAR;
9996 p_x_line_rec.Industry_attribute8 := FND_API.G_MISS_CHAR;
9997 p_x_line_rec.Industry_attribute9 := FND_API.G_MISS_CHAR;
9998 p_x_line_rec.Industry_attribute10 := FND_API.G_MISS_CHAR;
9999 p_x_line_rec.Industry_attribute11 := FND_API.G_MISS_CHAR;
10000 p_x_line_rec.Industry_attribute12 := FND_API.G_MISS_CHAR;
10001 p_x_line_rec.Industry_attribute13 := FND_API.G_MISS_CHAR;
10002 p_x_line_rec.Industry_attribute14 := FND_API.G_MISS_CHAR;
10003 p_x_line_rec.Industry_attribute15 := FND_API.G_MISS_CHAR;
10004 p_x_line_rec.Industry_attribute16 := FND_API.G_MISS_CHAR;
10005 p_x_line_rec.Industry_attribute17 := FND_API.G_MISS_CHAR;
10006 p_x_line_rec.Industry_attribute18 := FND_API.G_MISS_CHAR;
10007 p_x_line_rec.Industry_attribute19 := FND_API.G_MISS_CHAR;
10008 p_x_line_rec.Industry_attribute20 := FND_API.G_MISS_CHAR;
10009 p_x_line_rec.Industry_attribute21 := FND_API.G_MISS_CHAR;
10010 p_x_line_rec.Industry_attribute22 := FND_API.G_MISS_CHAR;
10011 p_x_line_rec.Industry_attribute23 := FND_API.G_MISS_CHAR;
10012 p_x_line_rec.Industry_attribute24 := FND_API.G_MISS_CHAR;
10013 p_x_line_rec.Industry_attribute25 := FND_API.G_MISS_CHAR;
10014 p_x_line_rec.Industry_attribute26 := FND_API.G_MISS_CHAR;
10015 p_x_line_rec.Industry_attribute27 := FND_API.G_MISS_CHAR;
10016 p_x_line_rec.Industry_attribute28 := FND_API.G_MISS_CHAR;
10017 p_x_line_rec.Industry_attribute29 := FND_API.G_MISS_CHAR;
10018 p_x_line_rec.Industry_attribute30 := FND_API.G_MISS_CHAR;
10019
10020 ELSIF p_validation_level = FND_API.G_VALID_LEVEL_NONE THEN
10021 NULL;
10022
10023 ELSE
10024 x_return_status := FND_API.G_RET_STS_ERROR;
10025 END IF;
10026
10027 ELSE -- for bug 2511313
10028 IF p_x_line_rec.industry_context IS NULL
10029 OR p_x_line_rec.industry_context = FND_API.G_MISS_CHAR THEN
10030 p_x_line_rec.industry_context := oe_validate.g_context;
10031 END IF;
10032
10033 IF p_x_line_rec.industry_attribute1 IS NULL
10034 OR p_x_line_rec.industry_attribute1 = FND_API.G_MISS_CHAR THEN
10035 p_x_line_rec.industry_attribute1 := oe_validate.g_attribute1;
10036 END IF;
10037
10038 IF p_x_line_rec.industry_attribute2 IS NULL
10039 OR p_x_line_rec.industry_attribute2 = FND_API.G_MISS_CHAR THEN
10040 p_x_line_rec.industry_attribute2 := oe_validate.g_attribute2;
10041 END IF;
10042
10043 IF p_x_line_rec.industry_attribute3 IS NULL
10044 OR p_x_line_rec.industry_attribute3 = FND_API.G_MISS_CHAR THEN
10045 p_x_line_rec.industry_attribute3 := oe_validate.g_attribute3;
10046 END IF;
10047
10048 IF p_x_line_rec.industry_attribute4 IS NULL
10049 OR p_x_line_rec.industry_attribute4 = FND_API.G_MISS_CHAR THEN
10050 p_x_line_rec.industry_attribute4 := oe_validate.g_attribute4;
10051 END IF;
10052
10053 IF p_x_line_rec.industry_attribute5 IS NULL
10054 OR p_x_line_rec.industry_attribute5 = FND_API.G_MISS_CHAR THEN
10055 p_x_line_rec.industry_attribute5 := oe_validate.g_attribute5;
10056 END IF;
10057
10058 IF p_x_line_rec.industry_attribute6 IS NULL
10059 OR p_x_line_rec.industry_attribute6 = FND_API.G_MISS_CHAR THEN
10060 p_x_line_rec.industry_attribute6 := oe_validate.g_attribute6;
10061 END IF;
10062
10063 IF p_x_line_rec.industry_attribute7 IS NULL
10064 OR p_x_line_rec.industry_attribute7 = FND_API.G_MISS_CHAR THEN
10065 p_x_line_rec.industry_attribute7 := oe_validate.g_attribute7;
10066 END IF;
10067
10068 IF p_x_line_rec.industry_attribute8 IS NULL
10069 OR p_x_line_rec.industry_attribute8 = FND_API.G_MISS_CHAR THEN
10070 p_x_line_rec.industry_attribute8 := oe_validate.g_attribute8;
10071 END IF;
10072
10073 IF p_x_line_rec.industry_attribute9 IS NULL
10074 OR p_x_line_rec.industry_attribute9 = FND_API.G_MISS_CHAR THEN
10075 p_x_line_rec.industry_attribute9 := oe_validate.g_attribute9;
10076 END IF;
10077
10078 IF p_x_line_rec.industry_attribute10 IS NULL
10079 OR p_x_line_rec.industry_attribute10 = FND_API.G_MISS_CHAR THEN
10080 p_x_line_rec.industry_attribute10 := oe_validate.g_attribute10;
10081 END IF;
10082
10083 IF p_x_line_rec.industry_attribute11 IS NULL
10084 OR p_x_line_rec.industry_attribute11 = FND_API.G_MISS_CHAR THEN
10085 p_x_line_rec.industry_attribute11 := oe_validate.g_attribute11;
10086 END IF;
10087
10088 IF p_x_line_rec.industry_attribute12 IS NULL
10089 OR p_x_line_rec.industry_attribute12 = FND_API.G_MISS_CHAR THEN
10090 p_x_line_rec.industry_attribute12 := oe_validate.g_attribute12;
10091 END IF;
10092
10093 IF p_x_line_rec.industry_attribute13 IS NULL
10094 OR p_x_line_rec.industry_attribute13 = FND_API.G_MISS_CHAR THEN
10095 p_x_line_rec.industry_attribute13 := oe_validate.g_attribute13;
10096 END IF;
10097
10098 IF p_x_line_rec.industry_attribute14 IS NULL
10099 OR p_x_line_rec.industry_attribute14 = FND_API.G_MISS_CHAR THEN
10100 p_x_line_rec.industry_attribute14 := oe_validate.g_attribute14;
10101 END IF;
10102
10103 IF p_x_line_rec.industry_attribute15 IS NULL
10104 OR p_x_line_rec.industry_attribute15 = FND_API.G_MISS_CHAR THEN
10105 p_x_line_rec.industry_attribute15 := oe_validate.g_attribute15;
10106 END IF;
10107
10108 IF p_x_line_rec.industry_attribute16 IS NULL
10109 OR p_x_line_rec.industry_attribute16 = FND_API.G_MISS_CHAR THEN
10110 p_x_line_rec.industry_attribute16 := oe_validate.g_attribute16;
10111 END IF;
10112
10113 IF p_x_line_rec.industry_attribute17 IS NULL
10114 OR p_x_line_rec.industry_attribute17 = FND_API.G_MISS_CHAR THEN
10115 p_x_line_rec.industry_attribute17 := oe_validate.g_attribute17;
10116 END IF;
10117
10118 IF p_x_line_rec.industry_attribute18 IS NULL
10119 OR p_x_line_rec.industry_attribute18 = FND_API.G_MISS_CHAR THEN
10120 p_x_line_rec.industry_attribute18 := oe_validate.g_attribute18;
10121 END IF;
10122
10123 IF p_x_line_rec.industry_attribute19 IS NULL
10124 OR p_x_line_rec.industry_attribute19 = FND_API.G_MISS_CHAR THEN
10125 p_x_line_rec.industry_attribute19 := oe_validate.g_attribute19;
10126 END IF;
10127
10128 IF p_x_line_rec.industry_attribute20 IS NULL
10129 OR p_x_line_rec.industry_attribute20 = FND_API.G_MISS_CHAR THEN
10130 p_x_line_rec.industry_attribute20 := oe_validate.g_attribute20;
10131 END IF;
10132
10133 IF p_x_line_rec.industry_attribute21 IS NULL
10134 OR p_x_line_rec.industry_attribute21 = FND_API.G_MISS_CHAR THEN
10135 p_x_line_rec.industry_attribute21 := oe_validate.g_attribute21;
10136 END IF;
10137
10138 IF p_x_line_rec.industry_attribute22 IS NULL
10139 OR p_x_line_rec.industry_attribute22 = FND_API.G_MISS_CHAR THEN
10140 p_x_line_rec.industry_attribute22 := oe_validate.g_attribute22;
10141 END IF;
10142
10143 IF p_x_line_rec.industry_attribute23 IS NULL
10144 OR p_x_line_rec.industry_attribute23 = FND_API.G_MISS_CHAR THEN
10145 p_x_line_rec.industry_attribute23 := oe_validate.g_attribute23;
10146 END IF;
10147
10148 IF p_x_line_rec.industry_attribute24 IS NULL
10149 OR p_x_line_rec.industry_attribute24 = FND_API.G_MISS_CHAR THEN
10150 p_x_line_rec.industry_attribute24 := oe_validate.g_attribute24;
10151 END IF;
10152
10153 IF p_x_line_rec.industry_attribute25 IS NULL
10154 OR p_x_line_rec.industry_attribute25 = FND_API.G_MISS_CHAR THEN
10155 p_x_line_rec.industry_attribute25 := oe_validate.g_attribute25;
10156 END IF;
10157
10158 IF p_x_line_rec.industry_attribute26 IS NULL
10159 OR p_x_line_rec.industry_attribute26 = FND_API.G_MISS_CHAR THEN
10160 p_x_line_rec.industry_attribute26 := oe_validate.g_attribute26;
10161 END IF;
10162
10163 IF p_x_line_rec.industry_attribute27 IS NULL
10164 OR p_x_line_rec.industry_attribute27 = FND_API.G_MISS_CHAR THEN
10165 p_x_line_rec.industry_attribute27 := oe_validate.g_attribute27;
10166 END IF;
10167
10168 IF p_x_line_rec.industry_attribute28 IS NULL
10169 OR p_x_line_rec.industry_attribute28 = FND_API.G_MISS_CHAR THEN
10170 p_x_line_rec.industry_attribute28 := oe_validate.g_attribute28;
10171 END IF;
10172
10173 IF p_x_line_rec.industry_attribute29 IS NULL
10174 OR p_x_line_rec.industry_attribute29 = FND_API.G_MISS_CHAR THEN
10175 p_x_line_rec.industry_attribute29 := oe_validate.g_attribute29;
10176 END IF;
10177
10178 IF p_x_line_rec.industry_attribute30 IS NULL
10179 OR p_x_line_rec.industry_attribute30 = FND_API.G_MISS_CHAR THEN
10180 p_x_line_rec.industry_attribute30 := oe_validate.g_attribute30;
10181 END IF;
10182
10183 -- end of bug 2511313
10184 END IF;
10185 END IF; -- Is flex enabled
10186 IF l_debug_level > 0 then
10187 oe_debug_pub.add('After I_line_desc_flex ' || x_return_status,2);
10188 END IF;
10189
10190 END IF;
10191
10192 /* Trading Partner Attributes */
10193 IF p_x_line_rec.operation = oe_globals.g_opr_create OR
10194 ( p_x_line_rec.operation = oe_globals.g_opr_update AND
10195 (p_x_line_rec.tp_attribute1 IS NOT NULL AND
10196 ( p_x_line_rec.tp_attribute1 <>
10197 p_old_line_rec.tp_attribute1 OR
10198 p_old_line_rec.tp_attribute1 IS NULL ))
10199 OR (p_x_line_rec.tp_attribute2 IS NOT NULL AND
10200 ( p_x_line_rec.tp_attribute2 <>
10201 p_old_line_rec.tp_attribute2 OR
10202 p_old_line_rec.tp_attribute2 IS NULL ))
10203 OR (p_x_line_rec.tp_attribute3 IS NOT NULL AND
10204 ( p_x_line_rec.tp_attribute3 <>
10205 p_old_line_rec.tp_attribute3 OR
10206 p_old_line_rec.tp_attribute3 IS NULL ))
10207 OR (p_x_line_rec.tp_attribute4 IS NOT NULL AND
10208 ( p_x_line_rec.tp_attribute4 <>
10209 p_old_line_rec.tp_attribute4 OR
10210 p_old_line_rec.tp_attribute4 IS NULL ))
10211 OR (p_x_line_rec.tp_attribute5 IS NOT NULL AND
10212 ( p_x_line_rec.tp_attribute5 <>
10213 p_old_line_rec.tp_attribute5 OR
10214 p_old_line_rec.tp_attribute5 IS NULL ))
10215 OR (p_x_line_rec.tp_attribute6 IS NOT NULL AND
10216 ( p_x_line_rec.tp_attribute6 <>
10217 p_old_line_rec.tp_attribute6 OR
10218 p_old_line_rec.tp_attribute6 IS NULL ))
10219 OR (p_x_line_rec.tp_attribute7 IS NOT NULL AND
10220 ( p_x_line_rec.tp_attribute7 <>
10221 p_old_line_rec.tp_attribute7 OR
10222 p_old_line_rec.tp_attribute7 IS NULL ))
10223 OR (p_x_line_rec.tp_attribute8 IS NOT NULL AND
10224 ( p_x_line_rec.tp_attribute8 <>
10225 p_old_line_rec.tp_attribute8 OR
10226 p_old_line_rec.tp_attribute8 IS NULL ))
10227 OR (p_x_line_rec.tp_attribute9 IS NOT NULL AND
10228 ( p_x_line_rec.tp_attribute9 <>
10229 p_old_line_rec.tp_attribute9 OR
10230 p_old_line_rec.tp_attribute9 IS NULL ))
10231 OR (p_x_line_rec.tp_attribute10 IS NOT NULL AND
10232 ( p_x_line_rec.tp_attribute10 <>
10233 p_old_line_rec.tp_attribute10 OR
10234 p_old_line_rec.tp_attribute10 IS NULL ))
10235 OR (p_x_line_rec.tp_attribute11 IS NOT NULL AND
10236 ( p_x_line_rec.tp_attribute11 <>
10237 p_old_line_rec.tp_attribute11 OR
10238 p_old_line_rec.tp_attribute11 IS NULL ))
10239 OR (p_x_line_rec.tp_attribute12 IS NOT NULL AND
10240 ( p_x_line_rec.tp_attribute12 <>
10241 p_old_line_rec.tp_attribute12 OR
10242 p_old_line_rec.tp_attribute12 IS NULL ))
10243 OR (p_x_line_rec.tp_attribute13 IS NOT NULL AND
10244 ( p_x_line_rec.tp_attribute13 <>
10245 p_old_line_rec.tp_attribute13 OR
10246 p_old_line_rec.tp_attribute13 IS NULL ))
10247 OR (p_x_line_rec.tp_attribute14 IS NOT NULL AND
10248 ( p_x_line_rec.tp_attribute14 <>
10249 p_old_line_rec.tp_attribute14 OR
10250 p_old_line_rec.tp_attribute14 IS NULL ))
10251 OR (p_x_line_rec.tp_attribute15 IS NOT NULL AND
10252 ( p_x_line_rec.tp_attribute15 <>
10253 p_old_line_rec.tp_attribute15 OR
10254 p_old_line_rec.tp_attribute15 IS NULL )))
10255
10256 THEN
10257
10258 IF Oe_Order_Cache.IS_FLEX_ENABLED('OE_LINE_TP_ATTRIBUTES') = 'Y' THEN
10259 IF NOT OE_VALIDATE.TP_Line_Desc_Flex
10260 (p_context => p_x_line_rec.tp_context
10261 ,p_attribute1 => p_x_line_rec.tp_attribute1
10262 ,p_attribute2 => p_x_line_rec.tp_attribute2
10263 ,p_attribute3 => p_x_line_rec.tp_attribute3
10264 ,p_attribute4 => p_x_line_rec.tp_attribute4
10265 ,p_attribute5 => p_x_line_rec.tp_attribute5
10266 ,p_attribute6 => p_x_line_rec.tp_attribute6
10267 ,p_attribute7 => p_x_line_rec.tp_attribute7
10268 ,p_attribute8 => p_x_line_rec.tp_attribute8
10269 ,p_attribute9 => p_x_line_rec.tp_attribute9
10270 ,p_attribute10 => p_x_line_rec.tp_attribute10
10271 ,p_attribute11 => p_x_line_rec.tp_attribute11
10272 ,p_attribute12 => p_x_line_rec.tp_attribute12
10273 ,p_attribute13 => p_x_line_rec.tp_attribute13
10274 ,p_attribute14 => p_x_line_rec.tp_attribute14
10275 ,p_attribute15 => p_x_line_rec.tp_attribute15) THEN
10276
10277 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
10278 p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
10279
10280
10281 p_x_line_rec.tp_context := null;
10282 p_x_line_rec.tp_attribute1 := null;
10283 p_x_line_rec.tp_attribute2 := null;
10284 p_x_line_rec.tp_attribute3 := null;
10285 p_x_line_rec.tp_attribute4 := null;
10286 p_x_line_rec.tp_attribute5 := null;
10287 p_x_line_rec.tp_attribute6 := null;
10288 p_x_line_rec.tp_attribute7 := null;
10289 p_x_line_rec.tp_attribute8 := null;
10290 p_x_line_rec.tp_attribute9 := null;
10291 p_x_line_rec.tp_attribute10 := null;
10292 p_x_line_rec.tp_attribute11 := null;
10293 p_x_line_rec.tp_attribute12 := null;
10294 p_x_line_rec.tp_attribute13 := null;
10295 p_x_line_rec.tp_attribute14 := null;
10296 p_x_line_rec.tp_attribute15 := null;
10297
10298 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
10299 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
10300
10301 p_x_line_rec.tp_context := FND_API.G_MISS_CHAR;
10302 p_x_line_rec.tp_attribute1 := FND_API.G_MISS_CHAR;
10303 p_x_line_rec.tp_attribute2 := FND_API.G_MISS_CHAR;
10304 p_x_line_rec.tp_attribute3 := FND_API.G_MISS_CHAR;
10305 p_x_line_rec.tp_attribute4 := FND_API.G_MISS_CHAR;
10306 p_x_line_rec.tp_attribute5 := FND_API.G_MISS_CHAR;
10307 p_x_line_rec.tp_attribute6 := FND_API.G_MISS_CHAR;
10308 p_x_line_rec.tp_attribute7 := FND_API.G_MISS_CHAR;
10309 p_x_line_rec.tp_attribute8 := FND_API.G_MISS_CHAR;
10310 p_x_line_rec.tp_attribute9 := FND_API.G_MISS_CHAR;
10311 p_x_line_rec.tp_attribute10 := FND_API.G_MISS_CHAR;
10312 p_x_line_rec.tp_attribute11 := FND_API.G_MISS_CHAR;
10313 p_x_line_rec.tp_attribute12 := FND_API.G_MISS_CHAR;
10314 p_x_line_rec.tp_attribute13 := FND_API.G_MISS_CHAR;
10315 p_x_line_rec.tp_attribute14 := FND_API.G_MISS_CHAR;
10316 p_x_line_rec.tp_attribute15 := FND_API.G_MISS_CHAR;
10317
10318 ELSIF p_validation_level = FND_API.G_VALID_LEVEL_NONE THEN
10319 NULL;
10320
10321 ELSE
10322 x_return_status := FND_API.G_RET_STS_ERROR;
10323 END IF;
10324
10325 ELSE -- if the flex validation is successfull
10326 -- For bug 2511313
10327 IF p_x_line_rec.tp_context IS NULL
10328 OR p_x_line_rec.tp_context = FND_API.G_MISS_CHAR THEN
10329 p_x_line_rec.tp_context := oe_validate.g_context;
10330 END IF;
10331
10332 IF p_x_line_rec.tp_attribute1 IS NULL
10333 OR p_x_line_rec.tp_attribute1 = FND_API.G_MISS_CHAR THEN
10334 p_x_line_rec.tp_attribute1 := oe_validate.g_attribute1;
10335 END IF;
10336
10337 IF p_x_line_rec.tp_attribute2 IS NULL
10338 OR p_x_line_rec.tp_attribute2 = FND_API.G_MISS_CHAR THEN
10339 p_x_line_rec.tp_attribute2 := oe_validate.g_attribute2;
10340 END IF;
10341
10342 IF p_x_line_rec.tp_attribute3 IS NULL
10343 OR p_x_line_rec.tp_attribute3 = FND_API.G_MISS_CHAR THEN
10344 p_x_line_rec.tp_attribute3 := oe_validate.g_attribute3;
10345 END IF;
10346
10347 IF p_x_line_rec.tp_attribute4 IS NULL
10348 OR p_x_line_rec.tp_attribute4 = FND_API.G_MISS_CHAR THEN
10349 p_x_line_rec.tp_attribute4 := oe_validate.g_attribute4;
10350 END IF;
10351
10352 IF p_x_line_rec.tp_attribute5 IS NULL
10353 OR p_x_line_rec.tp_attribute5 = FND_API.G_MISS_CHAR THEN
10354 p_x_line_rec.tp_attribute5 := oe_validate.g_attribute5;
10355 END IF;
10356
10357 IF p_x_line_rec.tp_attribute6 IS NULL
10358 OR p_x_line_rec.tp_attribute6 = FND_API.G_MISS_CHAR THEN
10359 p_x_line_rec.tp_attribute6 := oe_validate.g_attribute6;
10360 END IF;
10361
10362 IF p_x_line_rec.tp_attribute7 IS NULL
10363 OR p_x_line_rec.tp_attribute7 = FND_API.G_MISS_CHAR THEN
10364 p_x_line_rec.tp_attribute7 := oe_validate.g_attribute7;
10365 END IF;
10366
10367 IF p_x_line_rec.tp_attribute8 IS NULL
10368 OR p_x_line_rec.tp_attribute8 = FND_API.G_MISS_CHAR THEN
10369 p_x_line_rec.tp_attribute8 := oe_validate.g_attribute8;
10370 END IF;
10371
10372 IF p_x_line_rec.tp_attribute9 IS NULL
10373 OR p_x_line_rec.tp_attribute9 = FND_API.G_MISS_CHAR THEN
10374 p_x_line_rec.tp_attribute9 := oe_validate.g_attribute9;
10375 END IF;
10376
10377 IF p_x_line_rec.tp_attribute10 IS NULL
10378 OR p_x_line_rec.tp_attribute10 = FND_API.G_MISS_CHAR THEN
10379 p_x_line_rec.tp_attribute10 := Oe_validate.G_attribute10;
10380 End IF;
10381
10382 IF p_x_line_rec.tp_attribute11 IS NULL
10383 OR p_x_line_rec.tp_attribute11 = FND_API.G_MISS_CHAR THEN
10384 p_x_line_rec.tp_attribute11 := oe_validate.g_attribute11;
10385 END IF;
10386
10387 IF p_x_line_rec.tp_attribute12 IS NULL
10388 OR p_x_line_rec.tp_attribute12 = FND_API.G_MISS_CHAR THEN
10389 p_x_line_rec.tp_attribute12 := oe_validate.g_attribute12;
10390 END IF;
10391
10392 IF p_x_line_rec.tp_attribute13 IS NULL
10393 OR p_x_line_rec.tp_attribute13 = FND_API.G_MISS_CHAR THEN
10394 p_x_line_rec.tp_attribute13 := oe_validate.g_attribute13;
10395 END IF;
10396
10397 IF p_x_line_rec.tp_attribute14 IS NULL
10398 OR p_x_line_rec.tp_attribute14 = FND_API.G_MISS_CHAR THEN
10399 p_x_line_rec.tp_attribute14 := oe_validate.g_attribute14;
10400 END IF;
10401
10402 IF p_x_line_rec.tp_attribute15 IS NULL
10403 OR p_x_line_rec.tp_attribute15 = FND_API.G_MISS_CHAR THEN
10404 p_x_line_rec.tp_attribute15 := oe_validate.g_attribute15;
10405 END IF;
10406 -- end of assignments, bug 2511313
10407
10408 END IF;
10409 END IF; -- Is flex enabled
10410
10411 --oe_debug_pub.add('After TP_line_desc_flex ' || x_return_status);
10412
10413 END IF;
10414 /* Trading Partner */
10415
10416 --For bug 2517505
10417 IF ( p_x_line_rec.operation = oe_globals.g_opr_create AND
10418 p_x_line_rec.line_category_code = 'RETURN' ) OR
10419 ( p_x_line_rec.operation = oe_globals.g_opr_update AND
10420 p_x_line_rec.line_category_code = 'RETURN' AND -- added for bug 2750455
10421 ((p_x_line_rec.return_attribute1 IS NOT NULL AND -- additional pair of braces added for 2750455
10422 ( p_x_line_rec.return_attribute1 <>
10423 p_old_line_rec.return_attribute1 OR
10424 p_old_line_rec.return_attribute1 IS NULL ))
10425 OR (p_x_line_rec.return_attribute2 IS NOT NULL AND
10426 ( p_x_line_rec.return_attribute2 <>
10427 p_old_line_rec.return_attribute2 OR
10428 p_old_line_rec.return_attribute2 IS NULL ))
10429 OR (p_x_line_rec.return_context IS NOT NULL AND
10430 ( p_x_line_rec.return_context <>
10431 p_old_line_rec.return_context OR
10432 p_old_line_rec.return_context IS NULL ))))
10433 THEN
10434
10435 IF l_debug_level > 0 then
10436 oe_debug_pub.add('Before calling Return line_desc_flex',2);
10437 END IF;
10438 IF Oe_Order_Cache.IS_FLEX_ENABLED('OE_LINE_RETURN_ATTRIBUTE') = 'Y' THEN
10439 IF NOT OE_VALIDATE.R_Line_Desc_Flex
10440 (p_context => p_x_line_rec.Return_context
10441 ,p_attribute1 => p_x_line_rec.Return_attribute1
10442 ,p_attribute2 => p_x_line_rec.Return_attribute2
10443 ,p_attribute3 => p_x_line_rec.Return_attribute3
10444 ,p_attribute4 => p_x_line_rec.Return_attribute4
10445 ,p_attribute5 => p_x_line_rec.Return_attribute5
10446 ,p_attribute6 => p_x_line_rec.Return_attribute6
10447 ,p_attribute7 => p_x_line_rec.Return_attribute7
10448 ,p_attribute8 => p_x_line_rec.Return_attribute8
10449 ,p_attribute9 => p_x_line_rec.Return_attribute9
10450 ,p_attribute10 => p_x_line_rec.Return_attribute10
10451 ,p_attribute11 => p_x_line_rec.Return_attribute11
10452 ,p_attribute12 => p_x_line_rec.Return_attribute12
10453 ,p_attribute13 => p_x_line_rec.Return_attribute13
10454 ,p_attribute14 => p_x_line_rec.Return_attribute14
10455 ,p_attribute15 => p_x_line_rec.Return_attribute15) THEN
10456
10457 IF p_validation_level = OE_GLOBALS.G_VALID_LEVEL_PARTIAL AND
10458 p_x_line_rec.operation = OE_GLOBALS.G_OPR_CREATE THEN
10459
10460
10461 p_x_line_rec.Return_context := null;
10462 p_x_line_rec.Return_attribute1 := null;
10463 p_x_line_rec.Return_attribute2 := null;
10464 p_x_line_rec.Return_attribute3 := null;
10465 p_x_line_rec.Return_attribute4 := null;
10466 p_x_line_rec.Return_attribute5 := null;
10467 p_x_line_rec.Return_attribute6 := null;
10468 p_x_line_rec.Return_attribute7 := null;
10469 p_x_line_rec.Return_attribute8 := null;
10470 p_x_line_rec.Return_attribute9 := null;
10471 p_x_line_rec.Return_attribute11 := null;
10472 p_x_line_rec.Return_attribute12 := null;
10473 p_x_line_rec.Return_attribute13 := null;
10474 p_x_line_rec.Return_attribute14 := null;
10475 p_x_line_rec.Return_attribute15 := null;
10476 p_x_line_rec.Return_attribute10 := null;
10477
10478 ELSIF p_validation_level = OE_GLOBALS.G_VALID_PARTIAL_WITH_DEF AND
10479 p_x_line_rec.operation =OE_GLOBALS.G_OPR_CREATE THEN
10480 p_x_line_rec.Return_context := FND_API.G_MISS_CHAR;
10481 p_x_line_rec.Return_attribute1 := FND_API.G_MISS_CHAR;
10482 p_x_line_rec.Return_attribute2 := FND_API.G_MISS_CHAR;
10483 p_x_line_rec.Return_attribute3 := FND_API.G_MISS_CHAR;
10484 p_x_line_rec.Return_attribute4 := FND_API.G_MISS_CHAR;
10485 p_x_line_rec.Return_attribute5 := FND_API.G_MISS_CHAR;
10486 p_x_line_rec.Return_attribute6 := FND_API.G_MISS_CHAR;
10487 p_x_line_rec.Return_attribute7 := FND_API.G_MISS_CHAR;
10488 p_x_line_rec.Return_attribute8 := FND_API.G_MISS_CHAR;
10489 p_x_line_rec.Return_attribute9 := FND_API.G_MISS_CHAR;
10490 p_x_line_rec.Return_attribute11 := FND_API.G_MISS_CHAR;
10491 p_x_line_rec.Return_attribute12 := FND_API.G_MISS_CHAR;
10492 p_x_line_rec.Return_attribute13 := FND_API.G_MISS_CHAR;
10493 p_x_line_rec.Return_attribute14 := FND_API.G_MISS_CHAR;
10494 p_x_line_rec.Return_attribute15 := FND_API.G_MISS_CHAR;
10495 p_x_line_rec.Return_attribute10 := FND_API.G_MISS_CHAR;
10496
10497 ELSIF p_validation_level = FND_API.G_VALID_LEVEL_NONE THEN
10498 NULL;
10499
10500 ELSE
10501
10502 x_return_status := FND_API.G_RET_STS_ERROR;
10503 END IF;
10504 ELSE -- for bug 2511313
10505 IF p_x_line_rec.return_context IS NULL
10506 OR p_x_line_rec.return_context = FND_API.G_MISS_CHAR THEN
10507 p_x_line_rec.return_context := oe_validate.g_context;
10508 END IF;
10509
10510 IF p_x_line_rec.return_attribute1 IS NULL
10511 OR p_x_line_rec.return_attribute1 = FND_API.G_MISS_CHAR THEN
10512 p_x_line_rec.return_attribute1 := oe_validate.g_attribute1;
10513 END IF;
10514
10515 IF p_x_line_rec.return_attribute2 IS NULL
10516 OR p_x_line_rec.return_attribute2 = FND_API.G_MISS_CHAR THEN
10517 p_x_line_rec.return_attribute2 := oe_validate.g_attribute2;
10518 END IF;
10519
10520 IF p_x_line_rec.return_attribute3 IS NULL
10521 OR p_x_line_rec.return_attribute3 = FND_API.G_MISS_CHAR THEN
10522 p_x_line_rec.return_attribute3 := oe_validate.g_attribute3;
10523 END IF;
10524
10525 IF p_x_line_rec.return_attribute4 IS NULL
10526 OR p_x_line_rec.return_attribute4 = FND_API.G_MISS_CHAR THEN
10527 p_x_line_rec.return_attribute4 := oe_validate.g_attribute4;
10528 END IF;
10529
10530 IF p_x_line_rec.return_attribute5 IS NULL
10531 OR p_x_line_rec.return_attribute5 = FND_API.G_MISS_CHAR THEN
10532 p_x_line_rec.return_attribute5 := oe_validate.g_attribute5;
10533 END IF;
10534
10535 IF p_x_line_rec.return_attribute6 IS NULL
10536 OR p_x_line_rec.return_attribute6 = FND_API.G_MISS_CHAR THEN
10537 p_x_line_rec.return_attribute6 := oe_validate.g_attribute6;
10538 END IF;
10539
10540 IF p_x_line_rec.return_attribute7 IS NULL
10541 OR p_x_line_rec.return_attribute7 = FND_API.G_MISS_CHAR THEN
10542 p_x_line_rec.return_attribute7 := oe_validate.g_attribute7;
10543 END IF;
10544
10545 IF p_x_line_rec.return_attribute8 IS NULL
10546 OR p_x_line_rec.return_attribute8 = FND_API.G_MISS_CHAR THEN
10547 p_x_line_rec.return_attribute8 := oe_validate.g_attribute8;
10548 END IF;
10549
10550 IF p_x_line_rec.return_attribute9 IS NULL
10551 OR p_x_line_rec.return_attribute9 = FND_API.G_MISS_CHAR THEN
10552 p_x_line_rec.return_attribute9 := oe_validate.g_attribute9;
10553 END IF;
10554
10555 IF p_x_line_rec.return_attribute10 IS NULL
10556 OR p_x_line_rec.return_attribute10 = FND_API.G_MISS_CHAR THEN
10557 p_x_line_rec.return_attribute10 := oe_validate.g_attribute10;
10558 END IF;
10559
10560 IF p_x_line_rec.return_attribute11 IS NULL
10561 OR p_x_line_rec.return_attribute11 = FND_API.G_MISS_CHAR THEN
10562 p_x_line_rec.return_attribute11 := oe_validate.g_attribute11;
10563 END IF;
10564
10565 IF p_x_line_rec.return_attribute12 IS NULL
10566 OR p_x_line_rec.return_attribute12 = FND_API.G_MISS_CHAR THEN
10567 p_x_line_rec.return_attribute12 := oe_validate.g_attribute12;
10568 END IF;
10569
10570 IF p_x_line_rec.return_attribute13 IS NULL
10571 OR p_x_line_rec.return_attribute13 = FND_API.G_MISS_CHAR THEN
10572 p_x_line_rec.return_attribute13 := oe_validate.g_attribute13;
10573 END IF;
10574
10575 IF p_x_line_rec.return_attribute14 IS NULL
10576 OR p_x_line_rec.return_attribute14 = FND_API.G_MISS_CHAR THEN
10577 p_x_line_rec.return_attribute14 := oe_validate.g_attribute14;
10578 END IF;
10579
10580 IF p_x_line_rec.return_attribute15 IS NULL
10581 OR p_x_line_rec.return_attribute15 = FND_API.G_MISS_CHAR THEN
10582 p_x_line_rec.return_attribute15 := oe_validate.g_attribute15;
10583 END IF;
10584 -- end of bug 2511313
10585 END IF;
10586 END IF; -- Is flex enabled
10587 IF l_debug_level > 0 then
10588 oe_debug_pub.add('After Return line_desc_flex ' || x_return_status,2);
10589 END IF;
10590 END IF;
10591 end if; --end if OE_GLOBALS.g_validate_desc_flex ='Y' then --4343612
10592 -- Done validating attributes
10593
10594 EXCEPTION
10595 WHEN OTHERS THEN
10596 oe_debug_pub.add('error in Validate_Flex '|| sqlerrm, 1);
10597 RAISE;
10598 END Validate_Flex;
10599
10600 -- Procedure Entity_Delete
10601
10602 PROCEDURE Entity_Delete
10603 ( x_return_status OUT NOCOPY VARCHAR2
10604
10605 , p_line_rec IN OE_Order_PUB.Line_Rec_Type
10606 )
10607 IS
10608 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
10609 BEGIN
10610
10611 -- Validate entity delete.
10612
10613 NULL;
10614
10615 -- Done.
10616
10617 x_return_status := l_return_status;
10618
10619 EXCEPTION
10620
10621 WHEN FND_API.G_EXC_ERROR THEN
10622
10623 x_return_status := FND_API.G_RET_STS_ERROR;
10624
10625 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
10626
10627 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
10628
10629 WHEN OTHERS THEN
10630
10631 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
10632
10633 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
10634 THEN
10635 OE_MSG_PUB.Add_Exc_Msg
10636 ( G_PKG_NAME
10637 , 'Entity_Delete'
10638 );
10639 END IF;
10640
10641 END Entity_Delete;
10642
10643 END OE_Validate_Line;