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