1 PACKAGE BODY OE_Versioning_Util AS
2 /* $Header: OEXUVERB.pls 120.11.12020000.2 2012/07/18 13:14:05 suthumma ship $ */
3
4 G_PKG_NAME CONSTANT VARCHAR2(30) := 'OE_Versioning_Util';
5
6 G_VERSION_NUMBER NUMBER;
7
8 -- Forward declaration to delete created records from history
9 FUNCTION Delete_Created_Records
10 RETURN VARCHAR2
11 IS
12 i NUMBER;
13 TYPE num_tbl IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
14 l_temp_table num_tbl;
15 l_return_status VARCHAR2(30);
16 --
17 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
18 --
19 BEGIN
20
21 l_return_status := FND_API.G_RET_STS_SUCCESS;
22
23 IF l_debug_level > 0 THEN
24 oe_debug_pub.add('Entering Delete_Created_Records ',1);
25 END IF;
26
27 -- Get created records
28
29 i := oe_order_util.g_old_line_tbl.FIRST; -- get subscript of first element
30 WHILE i IS NOT NULL LOOP
31 if oe_order_util.g_old_line_tbl(i).operation = OE_GLOBALS.G_OPR_CREATE then
32 l_temp_table(l_temp_table.count + 1) := oe_order_util.g_old_line_tbl(i).line_id;
33 end if;
34 i := oe_order_util.g_old_line_tbl.NEXT(i); -- get subscript of next element
35 END LOOP;
36
37 if l_temp_table.count > 0 then
38 FORALL i in 1..l_temp_table.COUNT
39 DELETE FROM OE_ORDER_LINES_HISTORY
40 WHERE line_id = l_temp_table(i);
41 l_temp_table.DELETE;
42 end if;
43
44 i := oe_order_util.g_old_header_adj_tbl.FIRST;
45 WHILE i IS NOT NULL LOOP
46 if oe_order_util.g_old_header_adj_tbl(i).operation = OE_GLOBALS.G_OPR_CREATE then
47 l_temp_table(l_temp_table.count + 1) := oe_order_util.g_old_header_adj_tbl(i).price_adjustment_id;
48 end if;
49 i := oe_order_util.g_old_header_adj_tbl.NEXT(i);
50 END LOOP;
51
52 i := oe_order_util.g_old_line_adj_tbl.FIRST;
53 WHILE i IS NOT NULL LOOP
54 if oe_order_util.g_old_line_adj_tbl(i).operation = OE_GLOBALS.G_OPR_CREATE then
55 l_temp_table(l_temp_table.count + 1) := oe_order_util.g_old_line_adj_tbl(i).price_adjustment_id;
56 end if;
57 i := oe_order_util.g_old_line_adj_tbl.NEXT(i);
58 END LOOP;
59
60 if l_temp_table.count > 0 then
61 FORALL i in 1..l_temp_table.COUNT
62 DELETE FROM OE_PRICE_ADJS_HISTORY
63 WHERE price_adjustment_id = l_temp_table(i);
64 l_temp_table.DELETE;
65 end if;
66
67 i := oe_order_util.g_old_header_scredit_tbl.FIRST;
68 WHILE i IS NOT NULL LOOP
69 if oe_order_util.g_old_header_scredit_tbl(i).operation = OE_GLOBALS.G_OPR_CREATE then
70 l_temp_table(l_temp_table.count + 1) := oe_order_util.g_old_header_scredit_tbl(i).sales_credit_id;
71 end if;
72 i := oe_order_util.g_old_header_scredit_tbl.NEXT(i);
73 END LOOP;
74
75 i := oe_order_util.g_old_line_scredit_tbl.FIRST;
76 WHILE i IS NOT NULL LOOP
77 if oe_order_util.g_old_line_scredit_tbl(i).operation = OE_GLOBALS.G_OPR_CREATE then
78 l_temp_table(l_temp_table.count + 1) := oe_order_util.g_old_line_scredit_tbl(i).sales_credit_id;
79 end if;
80 i := oe_order_util.g_old_line_scredit_tbl.NEXT(i);
81 END LOOP;
82
83 if l_temp_table.count > 0 then
84 FORALL i in 1..l_temp_table.COUNT
85 DELETE FROM OE_SALES_CREDIT_HISTORY
86 WHERE sales_credit_id = l_temp_table(i);
87 l_temp_table.DELETE;
88 end if;
89
90 IF l_debug_level > 0 THEN
91 oe_debug_pub.add('Exiting Delete_Created_Records ',1);
92 END IF;
93
94 RETURN l_return_status;
95
96 EXCEPTION
97 WHEN OTHERS THEN
98 ROLLBACK TO SAVEPOINT Perform_Versioning;
99
100 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
101 OE_MSG_PUB.Add_Exc_Msg
102 ( G_PKG_NAME
103 , 'Delete_Created_Records'
104 );
105 END IF;
106
107 RETURN l_return_status;
108 END Delete_Created_Records;
109
110 Procedure Execute_Versioning_Request(
111 p_header_id IN NUMBER,
112 p_document_type IN VARCHAR2,
113 p_changed_attribute IN VARCHAR2 default null,
114 x_msg_count OUT NOCOPY NUMBER,
115 x_msg_data OUT NOCOPY VARCHAR2,
116 x_return_status OUT NOCOPY VARCHAR2
117 )
118 IS
119 l_return_status VARCHAR2(30);
120 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
121
122 BEGIN
123 IF l_debug_level > 0 THEN
124 oe_debug_pub.add('Executing Versioning/Audit delayed request');
125 END IF;
126
127 l_return_status := FND_API.G_RET_STS_SUCCESS;
128
129 IF OE_GLOBALS.G_ROLL_VERSION <> 'N' THEN
130 Perform_Versioning (p_header_id => p_header_id,
131 p_document_type => p_document_type,
132 p_changed_attribute => p_changed_attribute,
133 x_msg_count => x_msg_count,
134 x_msg_data => x_msg_data,
135 x_return_status => l_return_status);
136
137 --takintoy Version articles
138 If l_return_status = FND_API.G_RET_STS_SUCCESS
139 AND OE_Code_Control.Get_Code_Release_Level >= '110510'
140 Then
141 OE_Contracts_Util.Version_Articles(
142 p_api_version => 1,
143 p_doc_type => OE_Contracts_Util.G_SO_DOC_TYPE,
144 p_doc_id => p_header_id,
145 -- p_version_number => OE_ORDER_UTIL.G_OLD_HEADER_REC.VERSION_NUMBER ,
146 p_version_number => G_VERSION_NUMBER,
147 x_return_status => l_return_status,
148 x_msg_data => x_msg_data,
149 x_msg_count => x_msg_count);
150 End If;
151 ELSE
152 --Perform Audit Trail
153 Record_Changed_Records(
154 p_changed_attribute => p_changed_attribute,
155 x_return_status => l_return_status);
156 IF (NOT OE_Versioning_Util.Reset_Globals) THEN
157 l_return_status := FND_API.G_RET_STS_ERROR;
158 END IF;
159 END IF;
160
161 IF l_debug_level > 0 THEN
162 oe_debug_pub.add('End Versioning/Audit Request '|| l_return_status);
163 END IF;
164
165 x_return_status := l_return_status;
166
167 END Execute_Versioning_Request;
168
169
170 Procedure Perform_Versioning (
171 p_header_id IN NUMBER,
172 p_document_type IN VARCHAR2,
173 p_changed_attribute IN VARCHAR2 := NULL,
174 x_msg_count OUT NOCOPY NUMBER,
175 x_msg_data OUT NOCOPY VARCHAR2,
176 x_return_status OUT NOCOPY VARCHAR2
177 )
178 IS
179
180 l_return_status VARCHAR2(30);
181 l_lock_control NUMBER;
182 l_version_number NUMBER;
183 l_entity_id NUMBER;
184 l_reason_id NUMBER;
185 l_version_flag VARCHAR2(1);
186 l_phase_change_flag VARCHAR2(1);
187 i NUMBER;
188 l_x_header_rec OE_Order_Pub.Header_Rec_Type; --Bug# 14084432
189
190 --
191 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
192 --
193 BEGIN
194
195 SAVEPOINT Perform_Versioning;
196
197 l_return_status := FND_API.G_RET_STS_SUCCESS;
198 l_version_flag := 'N';
199 l_phase_change_flag := 'N';
200
201 IF l_debug_level > 0 THEN
202 oe_debug_pub.add('Entering Perform_Versioning ',1);
203 END IF;
204
205 IF (OE_GLOBALS.G_ROLL_VERSION = 'PV') THEN
206 l_version_flag := 'Y';
207 l_phase_change_flag := 'Y';
208 IF (p_document_type <> 'BLANKETS') THEN
209 IF OE_ORDER_UTIL.g_old_header_rec.version_number IS NULL
210 OR OE_ORDER_UTIL.g_old_header_rec.version_number = FND_API.G_MISS_NUM THEN
211 select version_number into l_version_number from oe_order_headers_all where header_id = p_header_id;
212 ELSE
213 l_version_number := OE_ORDER_UTIL.g_old_header_rec.version_number;
214 END IF;
215 END IF;
216 ELSIF (OE_GLOBALS.G_ROLL_VERSION = 'P') THEN
217 l_version_flag := 'N';
218 l_phase_change_flag := 'Y';
219 ELSE
220 l_phase_change_flag := 'N';
221 l_version_flag := 'Y';
222 IF (p_document_type <> 'BLANKETS') THEN
223 IF OE_ORDER_UTIL.g_old_header_rec.version_number IS NULL
224 OR OE_ORDER_UTIL.g_old_header_rec.version_number = FND_API.G_MISS_NUM THEN
225 select version_number into l_version_number from oe_order_headers_all where header_id = p_header_id;
226 ELSE
227 l_version_number := OE_ORDER_UTIL.g_old_header_rec.version_number;
228 END IF;
229 END IF;
230 END IF;
231
232
233 IF (p_document_type = 'BLANKETS') THEN
234
235 OE_Blanket_Util.Record_Blanket_History(p_phase_change_flag => l_phase_change_flag, p_version_flag => l_version_flag, x_return_status => l_return_status);
236
237 IF (l_version_flag = 'Y') THEN
238
239 SELECT LOCK_CONTROL, VERSION_NUMBER
240 INTO l_lock_control, l_version_number
241 FROM OE_BLANKET_HEADERS_ALL
242 WHERE HEADER_ID = p_header_id;
243
244 IF l_version_number = OE_Blanket_Util.g_old_header_hist_rec.version_number THEN
245
246 UPDATE OE_BLANKET_HEADERS_ALL
247 SET VERSION_NUMBER = l_version_number + 1,
248 LOCK_CONTROL = l_lock_control + 1
249 WHERE HEADER_ID = p_header_id;
250
251 -- added update for bug#10384912
252 UPDATE OE_BLANKET_HEADERS_EXT
253 SET REVISION_CHANGE_DATE = sysdate
254 WHERE ORDER_NUMBER IN
255 (SELECT ORDER_NUMBER
256 FROM OE_BLANKET_HEADERS_ALL
257 WHERE HEADER_ID = p_header_id
258 );
259
260 OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
261 ELSIF l_version_number < OE_Blanket_Util.g_old_header_hist_rec.version_number THEN
262 FND_MESSAGE.SET_NAME('ONT','OE_BLKT_INVALID_REVISION_NUM');
263 OE_MSG_PUB.ADD;
264
265 RAISE FND_API.G_EXC_ERROR;
266 END IF;
267 END IF;
268
269 --Apply reason changes
270 IF OE_GLOBALS.G_CAPTURED_REASON = 'Y' AND
271 OE_GLOBALS.G_REASON_CODE <> FND_API.G_MISS_CHAR THEN
272 OE_Reasons_Util.Apply_Reason(
273 p_entity_code => 'BLANKET_HEADER',
274 p_entity_id => p_header_id,
275 p_header_id => p_header_id,
276 p_version_number => OE_Blanket_Util.g_old_header_hist_rec.version_number,
277 p_reason_type => 'CANCEL_CODE',
278 p_reason_code => OE_GLOBALS.G_REASON_CODE,
279 p_reason_comments => OE_GLOBALS.G_REASON_COMMENTS,
280 x_reason_id => l_reason_id,
281 x_return_status => l_return_status);
282
283 UPDATE OE_BLANKET_HEADERS_HIST
284 SET REASON_ID = l_reason_id
285 WHERE phase_change_flag = l_phase_change_flag
286 AND version_flag = l_version_flag
287 AND version_number = OE_Blanket_Util.g_old_header_hist_rec.version_number --7312291;
288 AND HEADER_ID = p_header_id; --7312291
289
290 ELSIF OE_GLOBALS.G_CAPTURED_REASON = 'V' THEN
291 FND_MESSAGE.SET_NAME('ONT','OE_AUDIT_REASON_RQD');
292 OE_MSG_PUB.ADD;
293
294 RAISE FND_API.G_EXC_ERROR;
295 END IF;
296
297 -- Bug 5156668
298 -- This needs to be called only in the end, hence commenting
299 -- IF (NOT Reset_Globals) THEN
300 -- RAISE FND_API.G_EXC_ERROR;
301 -- END IF;
302
303 -- XDING: Commentting out this DOESNOT fix bug 5156668 but cause
304 -- regression issue 505564, so put this code back
305 IF (NOT Reset_Globals) THEN
306 RAISE FND_API.G_EXC_ERROR;
307 END IF;
308
309 RETURN;
310 END IF;
311
312
313 -- Return if header is created in same operation
314 -- add g_header_created check to fix bug 3700341
315 IF OE_Order_Util.g_header_rec.operation = OE_GLOBALS.G_OPR_CREATE OR
316 OE_GLOBALS.G_HEADER_CREATED THEN
317 IF l_debug_level > 0 THEN
318 oe_debug_pub.add('Not versioning because header was also created',1);
319 END IF;
320
321 x_return_status := l_return_status;
322
323 -- Bug 5156668
324 -- This needs to be called only in the end, hence commenting
325 -- IF (NOT Reset_Globals) THEN
326 -- RAISE FND_API.G_EXC_ERROR;
327 -- END IF;
328
329 -- XDING: Commentting out this DOESNOT fix bug 5156668 but cause
330 -- regression issue 505564, so put this code back
331 IF (NOT Reset_Globals) THEN
332 RAISE FND_API.G_EXC_ERROR;
333 END IF;
334
335 RETURN;
336 END IF;
337
338 -- Record changed records
339
340 Record_Changed_Records(p_version_flag => l_version_flag,
341 p_phase_change_flag => l_phase_change_flag,
342 p_changed_attribute => p_changed_attribute,
343 x_return_status => l_return_status);
344
345 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
346 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
347 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
348 RAISE FND_API.G_EXC_ERROR;
349 END IF;
350
351 -- Record unchanged records
352 IF l_debug_level > 0 THEN
353 oe_debug_pub.add('Calling Create_Version_History ',1);
354 END IF;
355
356 OE_Version_History_Util.Create_Version_History(p_header_id => p_header_id,
357 p_version_number => l_version_number,
358 p_phase_change_flag => l_phase_change_flag,
359 p_changed_attribute => p_changed_attribute,
360 x_return_status => l_return_status);
361
362 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
363 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
364 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
365 RAISE FND_API.G_EXC_ERROR;
366 END IF;
367
368 l_return_status := Delete_Created_Records;
369
370 IF IS_REASON_RQD <> 'N' THEN
371 IF OE_GLOBALS.G_REASON_CODE IS NULL OR
372 OE_GLOBALS.G_REASON_CODE = FND_API.G_MISS_CHAR THEN
373 -- Get stored reason in event of SYSTEM change
374 Get_Reason_Info(x_reason_code => OE_GLOBALS.G_REASON_CODE,
375 x_reason_comments => OE_GLOBALS.G_REASON_COMMENTS);
376
377 IF OE_GLOBALS.G_REASON_CODE IS NOT NULL OR
378 OE_GLOBALS.G_REASON_CODE = FND_API.G_MISS_CHAR THEN
379 OE_GLOBALS.G_CAPTURED_REASON := 'Y';
380 END IF;
381 END IF;
382 END IF;
383
384 --Apply reason changes
385 IF (IS_REASON_RQD = 'Y' AND
386 OE_GLOBALS.G_REASON_CODE <> FND_API.G_MISS_CHAR) OR
387 (IS_REASON_RQD <> 'N' AND
388 OE_GLOBALS.G_DEFAULT_REASON) THEN
389
390 IF OE_GLOBALS.G_DEFAULT_REASON THEN
391 IF l_debug_level > 0 THEN
392 oe_debug_pub.add('Defaulting Versioning Reason if necessary');
393 END IF;
394 OE_GLOBALS.G_REASON_CODE := nvl(OE_GLOBALS.G_REASON_CODE, 'SYSTEM');
395 END IF;
396
397 IF l_debug_level > 0 THEN
398 oe_debug_pub.add('Calling Apply_Reason ' || OE_GLOBALS.G_REASON_CODE,1);
399 END IF;
400
401 OE_Reasons_Util.Apply_Reason(
402 p_entity_code => 'HEADER',
403 p_entity_id => p_header_id,
404 p_header_id => p_header_id,
405 p_version_number => l_version_number,
406 p_reason_type => nvl(OE_GLOBALS.G_REASON_TYPE, 'CANCEL_CODE'),
407 p_reason_code => OE_GLOBALS.G_REASON_CODE,
408 p_reason_comments => OE_GLOBALS.G_REASON_COMMENTS,
409 x_reason_id => l_reason_id,
410 x_return_status => l_return_status);
411
412 UPDATE OE_ORDER_HEADER_HISTORY
413 SET REASON_ID = l_reason_id
414 WHERE HEADER_ID = p_header_id
415 AND phase_change_flag = l_phase_change_flag
416 AND version_flag = l_version_flag
417 AND version_number = l_version_number;
418
419 ELSIF IS_REASON_RQD <> 'N' THEN
420 FND_MESSAGE.SET_NAME('ONT','OE_AUDIT_REASON_RQD');
421 OE_MSG_PUB.ADD;
422
423 RAISE FND_API.G_EXC_ERROR;
424
425 END IF;
426
427 --Update l_version_number
428 IF (l_version_flag = 'Y') THEN
429
430 IF l_debug_level > 0 THEN
431 oe_debug_pub.add(' Updating version number, lock control ',1);
432 END IF;
433 --Adding for Bug# 14084432
434 OE_Header_Util.Lock_Row
435 (p_header_id => p_header_id
436 ,p_x_header_rec => l_x_header_rec
437 ,x_return_status => l_return_status
438 );
439 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
440 RAISE FND_API.G_EXC_ERROR;
441 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
442 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
443 END IF;
444 --End of Addition for Bug# 14084432
445 SELECT LOCK_CONTROL
446 INTO l_lock_control
447 FROM OE_ORDER_HEADERS_ALL
448 WHERE HEADER_ID = p_header_id;
449
450 IF OE_ORDER_UTIL.G_HEADER_REC.VERSION_NUMBER = OE_ORDER_UTIL.G_OLD_HEADER_REC.VERSION_NUMBER
451 OR OE_ORDER_UTIL.G_HEADER_REC.VERSION_NUMBER IS NULL
452 OR OE_ORDER_UTIL.G_HEADER_REC.VERSION_NUMBER = FND_API.G_MISS_NUM
453 OR OE_ORDER_UTIL.G_OLD_HEADER_REC.VERSION_NUMBER IS NULL
454 OR OE_ORDER_UTIL.G_OLD_HEADER_REC.VERSION_NUMBER = FND_API.G_MISS_NUM THEN
455 UPDATE OE_ORDER_HEADERS_ALL
456 SET VERSION_NUMBER = l_version_number + 1,
457 LOCK_CONTROL = l_lock_control + 1
458 WHERE HEADER_ID = p_header_id;
459
460 /* update the order cache so that the header can be updated without requery
461 after creating a new version from line, bug 4523686*/
462 IF l_debug_level > 0 THEN
463 oe_debug_pub.add(' Updating oe_order_cache.g_header_rec with version number, lock control ',1);
464 END IF;
465 OE_ORDER_CACHE.g_header_rec.version_number := l_version_number + 1;
466 OE_ORDER_CACHE.g_header_rec.lock_control := l_lock_control + 1;
467
468 OE_GLOBALS.G_CASCADING_REQUEST_LOGGED := TRUE;
469 ELSIF OE_ORDER_UTIL.G_HEADER_REC.VERSION_NUMBER < OE_ORDER_UTIL.G_OLD_HEADER_REC.VERSION_NUMBER THEN
470 FND_MESSAGE.SET_NAME('ONT','OE_BLKT_INVALID_REVISION_NUM');
471 OE_MSG_PUB.ADD;
472
473 RAISE FND_API.G_EXC_ERROR;
474 END IF;
475 END IF;
476
477 G_VERSION_NUMBER := l_version_number;
478 --added for bug5216912 start
479 if G_VERSION_NUMBER is null then
480 G_VERSION_NUMBER := OE_ORDER_UTIL.g_old_header_rec.version_number;
481 end if;
482 --added for bug5216912 end
483 -- added for 3679627
484 x_return_status := l_return_status;
485
486 -- Bug 5156668
487 -- This needs to be called only in the end, hence commenting
488 --IF (NOT Reset_Globals) THEN
489 -- RAISE FND_API.G_EXC_ERROR;
490 --END IF;
491
492 -- XDING: Commentting out this DOESNOT fix bug 5156668 but cause
493 -- regression issue 505564, so put this code back
494 IF (NOT Reset_Globals) THEN
495 RAISE FND_API.G_EXC_ERROR;
496 END IF;
497
498 EXCEPTION
499 WHEN FND_API.G_EXC_ERROR THEN
500 ROLLBACK TO SAVEPOINT Perform_Versioning;
501 x_return_status := FND_API.G_RET_STS_ERROR;
502 RAISE FND_API.G_EXC_ERROR;
503 WHEN OTHERS THEN
504 ROLLBACK TO SAVEPOINT Perform_Versioning;
505 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
506
507 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
508 OE_MSG_PUB.Add_Exc_Msg
509 ( G_PKG_NAME
510 , 'Perform_Versioning'
511 );
512 END IF;
513
514 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
515
516 END Perform_Versioning;
517
518
519 FUNCTION Get_Header_ID
520 RETURN NUMBER
521 IS
522 i NUMBER;
523 BEGIN
524
525 -- Get current header_id
526
527 if oe_order_util.g_header_id <> FND_API.G_MISS_NUM then
528 RETURN oe_order_util.g_header_id;
529 elsif
530 oe_order_util.g_old_header_rec.header_id <> FND_API.G_MISS_NUM then
531 RETURN oe_order_util.g_old_header_rec.header_id;
532 elsif
533 oe_order_util.g_header_rec.header_id <> FND_API.G_MISS_NUM then
534 RETURN oe_order_util.g_header_rec.header_id;
535 else
536 i := oe_order_util.g_old_line_tbl.FIRST; -- get subscript of first element
537 WHILE i IS NOT NULL LOOP
538 if oe_order_util.g_old_line_tbl(i).header_id <> FND_API.G_MISS_NUM then
539 RETURN oe_order_util.g_old_line_tbl(i).header_id;
540 end if;
541 i := oe_order_util.g_old_line_tbl.NEXT(i); -- get subscript of next element
542 END LOOP;
543
544 i := oe_order_util.g_line_tbl.FIRST; -- get subscript of first element
545 WHILE i IS NOT NULL LOOP
546 if oe_order_util.g_line_tbl(i).header_id <> FND_API.G_MISS_NUM then
547 RETURN oe_order_util.g_line_tbl(i).header_id;
548 end if;
549 i := oe_order_util.g_line_tbl.NEXT(i); -- get subscript of next element
550 END LOOP;
551
552 i := oe_order_util.g_old_header_adj_tbl.FIRST; -- get subscript of first element
553 WHILE i IS NOT NULL LOOP
554 if oe_order_util.g_old_header_adj_tbl(i).header_id <> FND_API.G_MISS_NUM then
555 RETURN oe_order_util.g_old_header_adj_tbl(i).header_id;
556 end if;
557 i := oe_order_util.g_old_header_adj_tbl.NEXT(i); -- get subscript of next element
558 END LOOP;
559
560 i := oe_order_util.g_header_adj_tbl.FIRST; -- get subscript of first element
561 WHILE i IS NOT NULL LOOP
562 if oe_order_util.g_header_adj_tbl(i).header_id <> FND_API.G_MISS_NUM then
563 RETURN oe_order_util.g_header_adj_tbl(i).header_id;
564 end if;
565 i := oe_order_util.g_header_adj_tbl.NEXT(i); -- get subscript of next element
566 END LOOP;
567
568 i := oe_order_util.g_old_line_adj_tbl.FIRST; -- get subscript of first element
569 WHILE i IS NOT NULL LOOP
570 if oe_order_util.g_old_line_adj_tbl(i).header_id <> FND_API.G_MISS_NUM then
571 RETURN oe_order_util.g_old_line_adj_tbl(i).header_id;
572 end if;
573 i := oe_order_util.g_old_line_adj_tbl.NEXT(i); -- get subscript of next element
574 END LOOP;
575
576 i := oe_order_util.g_line_adj_tbl.FIRST; -- get subscript of first element
577 WHILE i IS NOT NULL LOOP
578 if oe_order_util.g_line_adj_tbl(i).header_id <> FND_API.G_MISS_NUM then
579 RETURN oe_order_util.g_line_adj_tbl(i).header_id;
580 end if;
581 i := oe_order_util.g_line_adj_tbl.NEXT(i); -- get subscript of next element
582 END LOOP;
583
584 i := oe_order_util.g_old_header_scredit_tbl.FIRST; -- get subscript of first element
585 WHILE i IS NOT NULL LOOP
586 if oe_order_util.g_old_header_scredit_tbl(i).header_id <> FND_API.G_MISS_NUM then
587 RETURN oe_order_util.g_old_header_scredit_tbl(i).header_id;
588 end if;
589 i := oe_order_util.g_old_header_scredit_tbl.NEXT(i); -- get subscript of next element
590 END LOOP;
591
592 i := oe_order_util.g_header_scredit_tbl.FIRST; -- get subscript of first element
593 WHILE i IS NOT NULL LOOP
594 if oe_order_util.g_header_scredit_tbl(i).header_id <> FND_API.G_MISS_NUM then
595 RETURN oe_order_util.g_header_scredit_tbl(i).header_id;
596 end if;
597 i := oe_order_util.g_header_scredit_tbl.NEXT(i); -- get subscript of next element
598 END LOOP;
599
600 i := oe_order_util.g_old_line_scredit_tbl.FIRST; -- get subscript of first element
601 WHILE i IS NOT NULL LOOP
602 if oe_order_util.g_old_line_scredit_tbl(i).header_id <> FND_API.G_MISS_NUM then
603 RETURN oe_order_util.g_old_line_scredit_tbl(i).header_id;
604 end if;
605 i := oe_order_util.g_old_line_scredit_tbl.NEXT(i); -- get subscript of next element
606 END LOOP;
607
608 i := oe_order_util.g_line_scredit_tbl.FIRST; -- get subscript of first element
609 WHILE i IS NOT NULL LOOP
610 if oe_order_util.g_line_scredit_tbl(i).header_id <> FND_API.G_MISS_NUM then
611 RETURN oe_order_util.g_line_scredit_tbl(i).header_id;
612 end if;
613 i := oe_order_util.g_line_scredit_tbl.NEXT(i); -- get subscript of next element
614 END LOOP;
615
616 end if;
617
618 END Get_Header_Id;
619
620 --Procedure runs from delayed request. This procedure is called to handle
621 --changed records, handling both audit trail requests and changed records
622 --prior to recording unchanged records in the event of versioning/phase change
623
624 Procedure Record_Changed_Records(
625 p_version_flag IN VARCHAR2 := NULL,
626 p_phase_change_flag IN VARCHAR2 := NULL,
627 p_changed_attribute IN VARCHAR2 := NULL,
628 x_return_status OUT NOCOPY VARCHAR2)
629 IS
630 i NUMBER;
631 l_return_status VARCHAR2(1);
632 l_hist_type_code VARCHAR2(30);
633 l_audit_flag VARCHAR2(1);
634 l_header_id NUMBER;
635 l_version_number NUMBER;
636 l_reason_id NUMBER;
637 --
638 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
639 --
640 BEGIN
641
642 SAVEPOINT Record_Changed_Records;
643 l_return_status := FND_API.G_RET_STS_SUCCESS;
644
645 IF l_debug_level > 0 THEN
646 oe_debug_pub.add('Entering OE_Versioning_util.record_changed_records ',1);
647 END IF;
648
649 l_header_id := Get_Header_ID;
650
651 IF l_debug_level > 0 THEN
652 oe_debug_pub.add('OE_Versioning_Util header_id: ' || l_header_id,1);
653 END IF;
654
655 IF OE_ORDER_UTIL.g_old_header_rec.version_number IS NULL
656 OR OE_ORDER_UTIL.g_old_header_rec.version_number = FND_API.G_MISS_NUM THEN
657 select version_number into l_version_number from oe_order_headers_all where header_id = l_header_id;
658 ELSE
659 l_version_number := OE_ORDER_UTIL.g_old_header_rec.version_number;
660 END IF;
661
662 IF l_debug_level > 0 THEN
663 oe_debug_pub.add('Before updating history ',1);
664 END IF;
665
666 --Update history with audit flag information gathered in global picture
667 IF OE_Order_Util.g_old_header_rec.header_id <> FND_API.G_MISS_NUM THEN
668 IF NOT OE_GLOBALS.Equal(OE_Order_Util.g_old_header_rec.operation, OE_GLOBALS.G_OPR_CREATE) AND
669 (p_version_flag = 'Y' OR p_phase_change_flag = 'Y' or
670 g_audit_header_hist_code IS NOT NULL) THEN
671
672 IF g_audit_header_hist_code IS NOT NULL THEN
673 l_audit_flag := 'Y';
674 l_hist_type_code := g_audit_header_hist_code;
675 ELSE
676 l_audit_flag := 'N';
677 END IF;
678
679
680 if g_audit_header_reason_required and l_audit_flag = 'Y' then
681 --Apply Reason for audit
682 OE_Reasons_Util.Apply_Reason(
683 p_entity_code => 'HEADER',
684 p_entity_id => oe_order_util.g_old_header_rec.header_id,
685 p_header_id => oe_order_util.g_old_header_rec.header_id,
686 p_version_number => l_version_number,
687 p_reason_type => 'CANCEL_CODE',
688 p_reason_code => OE_ORDER_UTIL.g_header_rec.change_reason,
689 p_reason_comments => OE_ORDER_UTIL.g_header_rec.change_comments,
690 x_reason_id => l_reason_id,
691 x_return_status => l_return_status);
692
693 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
694 IF l_debug_level > 0 THEN
695 oe_debug_pub.add('Applying Audit Reason Caused Error on Header',1);
696 END IF;
697
698 if l_return_status = FND_API.G_RET_STS_ERROR then
699 raise FND_API.G_EXC_ERROR;
700 else
701 raise FND_API.G_EXC_UNEXPECTED_ERROR;
702 end if;
703 end if;
704
705 end if; --end apply reason
706
707 IF l_debug_level > 0 THEN
708 oe_debug_pub.add('Calling recordheaderhist operation: '|| oe_order_util.g_old_header_rec.operation,1);
709 END IF;
710
711 OE_CHG_ORDER_PVT.RecordHeaderHist
712 ( p_header_id => oe_order_util.g_old_header_rec.header_id,
713 p_header_rec => oe_order_util.g_old_header_rec,
714 p_hist_type_code => l_hist_type_code,
715 p_reason_code => NULL,
716 p_comments => NULL,
717 p_audit_flag => l_audit_flag,
718 p_version_flag => p_version_flag,
719 p_phase_change_flag => p_phase_change_flag,
720 p_version_number => l_version_number,
721 p_reason_id => l_reason_id,
722 p_wf_activity_code => null,
723 p_wf_result_code => null,
724 p_changed_attribute => p_changed_attribute,
725 x_return_status => l_return_status
726 );
727
728 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
729 IF l_debug_level > 0 THEN
730 oe_debug_pub.add('Inserting Header History Caused Error ',1);
731 END IF;
732
733 if l_return_status = FND_API.G_RET_STS_ERROR then
734 raise FND_API.G_EXC_ERROR;
735 else
736 raise FND_API.G_EXC_UNEXPECTED_ERROR;
737 end if;
738 end if;
739
740 END IF;
741 END IF;
742
743 IF l_debug_level > 0 THEN
744 oe_debug_pub.add(' OEXUVERB: before recording lines ',1);
745 END IF;
746
747 --Update history for lines
748 i := oe_order_util.g_old_line_tbl.FIRST; -- get subscript of first element
749 WHILE i IS NOT NULL LOOP
750 IF NOT OE_GLOBALS.Equal(oe_order_util.g_old_line_tbl(i).operation, OE_GLOBALS.G_OPR_CREATE) AND
751 (p_version_flag = 'Y' OR p_phase_change_flag = 'Y' or
752 g_audit_line_id_tbl.exists(i)) THEN
753 IF g_audit_line_id_tbl.exists(i) THEN
754 l_audit_flag := 'Y';
755 l_hist_type_code := g_audit_line_id_tbl(i).hist_type_code;
756 ELSE
757 l_audit_flag := 'N';
758 l_hist_type_code := 'VERSIONING';
759 END IF;
760
761 if l_debug_level > 0 then
762 oe_debug_pub.add('audit flag :'||l_audit_flag);
763 oe_debug_pub.add('hist type code :'||l_hist_type_code);
764 end if;
765
766 if l_audit_flag = 'Y' and g_audit_line_id_tbl.exists(i) and
767 (g_audit_line_id_tbl(i).reason_required
768 -- Cancellation (hist type of CANCELLATION)
769 -- Or qty decrease (hist type of QUANTITY UPDATE) can always send
770 -- in a reason as cancel action window has a reason field. This
771 -- value can be passed even if constraint does not require reason
772 -- but if reason is supplied for these hist types, it should be
773 -- captured.
774 OR (l_hist_type_code IN ('CANCELLATION','QUANTITY UPDATE')
775 and OE_ORDER_UTIL.g_line_tbl(i).change_reason is not null
776 and OE_ORDER_UTIL.g_line_tbl(i).change_reason <> fnd_api.g_miss_char
777 )
778 ) then
779 --Apply Reason for audit
780 OE_Reasons_Util.Apply_Reason(
781 p_entity_code => 'LINE',
782 p_entity_id => oe_order_util.g_old_line_tbl(i).line_id,
783 p_header_id => oe_order_util.g_old_line_tbl(i).header_id,
784 p_version_number => l_version_number,
785 p_reason_type => 'CANCEL_CODE',
786 p_reason_code => OE_ORDER_UTIL.g_line_tbl(i).change_reason,
787 p_reason_comments => OE_ORDER_UTIL.g_line_tbl(i).change_comments,
788 x_reason_id => l_reason_id,
789 x_return_status => l_return_status);
790
791 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
792 IF l_debug_level > 0 THEN
793 oe_debug_pub.add('Applying Audit Reason Caused Error on Line',1);
794 END IF;
795
796 if l_return_status = FND_API.G_RET_STS_ERROR then
797 raise FND_API.G_EXC_ERROR;
798 else
799 raise FND_API.G_EXC_UNEXPECTED_ERROR;
800 end if;
801 end if;
802
803 end if; --end apply reason
804
805 IF l_debug_level > 0 THEN
806 oe_debug_pub.add('Calling recordlinehist operation: '|| oe_order_util.g_old_line_tbl(i).operation,1);
807 END IF;
808
809 OE_CHG_ORDER_PVT.RecordLineHist
810 (p_line_id => oe_order_util.g_old_line_tbl(i).line_id,
811 p_line_rec => oe_order_util.g_old_line_tbl(i),
812 p_hist_type_code => l_hist_type_code,
813 p_reason_code => NULL,
814 p_comments => NULL,
815 p_audit_flag => l_audit_flag,
816 p_version_flag => p_version_flag,
817 p_phase_change_flag => p_phase_change_flag,
818 p_version_number => l_version_number,
819 p_reason_id => l_reason_id,
820 p_wf_activity_code => null,
821 p_wf_result_code => null,
822 x_return_status => l_return_status);
823 IF l_debug_level > 0 THEN
824 OE_DEBUG_PUB.add('IN OEXUVERB:After'||l_return_status,5);
825 END IF;
826
827 IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
828 IF l_debug_level > 0 THEN
829 oe_debug_pub.add('Inserting Line Audit History error',1);
830 END IF;
831 IF l_return_status = FND_API.G_RET_STS_ERROR then
832 raise FND_API.G_EXC_ERROR;
833 ELSE
834 raise FND_API.G_EXC_UNEXPECTED_ERROR;
835 END IF;
836 END IF;
837
838 END IF;
839 i := oe_order_util.g_old_line_tbl.NEXT(i); -- get subscript of next element
840 END LOOP;
841
842 IF l_debug_level > 0 THEN
843 oe_debug_pub.add(' OEXUVERB: before recording header adjs ',1);
844 END IF;
845
846 --Update history for header adj
847 i := oe_order_util.g_old_header_adj_tbl.FIRST; -- get subscript of first element
848 WHILE i IS NOT NULL LOOP
849 IF NOT OE_GLOBALS.Equal(oe_order_util.g_old_header_adj_tbl(i).operation, OE_GLOBALS.G_OPR_CREATE) AND
850 (p_version_flag = 'Y' OR p_phase_change_flag = 'Y' or
851 g_audit_header_adj_id_tbl.exists(i)) THEN
852 IF g_audit_header_adj_id_tbl.exists(i) THEN
853 l_audit_flag := 'Y';
854 l_hist_type_code := g_audit_header_adj_id_tbl(i).hist_type_code;
855 ELSE
856 l_audit_flag := 'N';
857 l_hist_type_code := NULL;
858 END IF;
859
860 if l_audit_flag = 'Y' and g_audit_header_adj_id_tbl.exists(i) and
861 g_audit_header_adj_id_tbl(i).reason_required then
862 --Apply Reason for audit
863 OE_Reasons_Util.Apply_Reason(
864 p_entity_code => 'HEADER_ADJ',
865 p_entity_id => oe_order_util.g_old_header_adj_tbl(i).price_adjustment_id,
866 p_header_id => oe_order_util.g_old_header_adj_tbl(i).header_id,
867 p_version_number => l_version_number,
868 p_reason_type => 'CHANGE_CODE',
869 p_reason_code => OE_ORDER_UTIL.g_header_adj_tbl(i).change_reason_code,
870 p_reason_comments => OE_ORDER_UTIL.g_header_adj_tbl(i).change_reason_text,
871 x_reason_id => l_reason_id,
872 x_return_status => l_return_status);
873
874 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
875 IF l_debug_level > 0 THEN
876 oe_debug_pub.add('Applying Audit Reason Caused Error on Header Adj',1);
877 END IF;
878
879 if l_return_status = FND_API.G_RET_STS_ERROR then
880 raise FND_API.G_EXC_ERROR;
881 else
882 raise FND_API.G_EXC_UNEXPECTED_ERROR;
883 end if;
884 end if;
885
886 end if; --end apply reason
887
888 IF l_debug_level > 0 THEN
889 oe_debug_pub.add('Calling recordHPAdjhist operation: '|| oe_order_util.g_old_header_adj_tbl(i).operation,1);
890 END IF;
891
892 OE_CHG_ORDER_PVT.RecordHPAdjHist
893 (p_header_adj_id => oe_order_util.g_old_header_adj_tbl(i).price_adjustment_id,
894 p_header_adj_rec => oe_order_util.g_old_header_adj_tbl(i),
895 p_hist_type_code => l_hist_type_code,
896 p_reason_code => oe_globals.g_reason_code,
897 p_comments => oe_globals.g_reason_comments,
898 p_audit_flag => l_audit_flag,
899 p_version_flag => p_version_flag,
900 p_phase_change_flag => p_phase_change_flag,
901 p_version_number => l_version_number,
902 p_reason_id => l_reason_id,
903 p_wf_activity_code => null,
904 p_wf_result_code => null,
905 x_return_status => l_return_status);
906
907 IF l_debug_level > 0 THEN
908 OE_DEBUG_PUB.add('IN OEXUVERB:After'||l_return_status,5);
909 END IF;
910 IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
911 IF l_debug_level > 0 THEN
912 oe_debug_pub.add('Inserting Line Audit History error',1);
913 END IF;
914
915 IF l_return_status = FND_API.G_RET_STS_ERROR then
916 raise FND_API.G_EXC_ERROR;
917 ELSE
918 raise FND_API.G_EXC_UNEXPECTED_ERROR;
919 END IF;
920 END IF;
921
922 END IF;
923 i := oe_order_util.g_old_header_adj_tbl.NEXT(i); -- get subscript of next element
924 END LOOP;
925
926
927 IF l_debug_level > 0 THEN
928 oe_debug_pub.add(' OEXUVERB: before recording header scredits ',1);
929 END IF;
930
931 --Update history for header scredit
932 i := oe_order_util.g_old_header_scredit_tbl.FIRST; -- get subscript of first element
933 WHILE i IS NOT NULL LOOP
934 IF NOT OE_GLOBALS.Equal(oe_order_util.g_old_header_scredit_tbl(i).operation, OE_GLOBALS.G_OPR_CREATE) AND
935 (p_version_flag = 'Y' OR p_phase_change_flag = 'Y' or
936 g_audit_header_scredit_id_tbl.exists(i)) THEN
937 IF g_audit_header_scredit_id_tbl.exists(i) THEN
938 l_audit_flag := 'Y';
939 l_hist_type_code := g_audit_header_scredit_id_tbl(i).hist_type_code;
940 ELSE
941 l_audit_flag := 'N';
942 l_hist_type_code := NULL;
943 END IF;
944
945 if l_audit_flag = 'Y' and g_audit_header_scredit_id_tbl.exists(i) and
946 g_audit_header_scredit_id_tbl(i).reason_required then
947 --Apply Reason for audit
948 OE_Reasons_Util.Apply_Reason(
949 p_entity_code => 'HEADER_SCREDIT',
950 p_entity_id => oe_order_util.g_old_header_scredit_tbl(i).sales_credit_id,
951 p_header_id => oe_order_util.g_old_header_scredit_tbl(i).header_id,
952 p_version_number => l_version_number,
953 p_reason_type => 'CANCEL_CODE',
954 p_reason_code => OE_ORDER_UTIL.g_header_scredit_tbl(i).change_reason,
955 p_reason_comments => OE_ORDER_UTIL.g_header_scredit_tbl(i).change_comments,
956 x_reason_id => l_reason_id,
957 x_return_status => l_return_status);
958
959 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
960 IF l_debug_level > 0 THEN
961 oe_debug_pub.add('Applying Audit Reason Caused Error on Header Scredit',1);
962 END IF;
963
964 if l_return_status = FND_API.G_RET_STS_ERROR then
965 raise FND_API.G_EXC_ERROR;
966 else
967 raise FND_API.G_EXC_UNEXPECTED_ERROR;
968 end if;
969 end if;
970
971 end if; --end apply reason
972
973 IF l_debug_level > 0 THEN
974 oe_debug_pub.add('Calling recordHSCredithist operation: '|| oe_order_util.g_old_header_scredit_tbl(i).operation,1);
975 END IF;
976
977 OE_CHG_ORDER_PVT.RecordHSCreditHist
978 (p_header_scredit_id => oe_order_util.g_old_header_scredit_tbl(i).sales_credit_id,
979 p_header_scredit_rec => oe_order_util.g_old_header_scredit_tbl(i),
980 p_hist_type_code => l_hist_type_code,
981 p_reason_code => oe_globals.g_reason_code,
982 p_comments => oe_globals.g_reason_comments,
983 p_audit_flag => l_audit_flag,
984 p_version_flag => p_version_flag,
985 p_phase_change_flag => p_phase_change_flag,
986 p_version_number => l_version_number,
987 p_reason_id => l_reason_id,
988 p_wf_activity_code => null,
989 p_wf_result_code => null,
990 x_return_status => l_return_status);
991
992 IF l_debug_level > 0 THEN
993 OE_DEBUG_PUB.add('IN OEXUVERB:After'||l_return_status,5);
994 END IF;
995 IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
996 IF l_debug_level > 0 THEN
997 oe_debug_pub.add('Inserting Line Audit History error',1);
998 END IF;
999 IF l_return_status = FND_API.G_RET_STS_ERROR then
1000 raise FND_API.G_EXC_ERROR;
1001 ELSE
1002 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1003 END IF;
1004 END IF;
1005
1006 END IF;
1007 i := oe_order_util.g_old_header_scredit_tbl.NEXT(i); -- get subscript of next element
1008 END LOOP;
1009
1010 IF l_debug_level > 0 THEN
1011 oe_debug_pub.add(' OEXUVERB: before recording line adjs ',1);
1012 END IF;
1013 --Update history for line adj
1014 i := oe_order_util.g_old_line_adj_tbl.FIRST; -- get subscript of first element
1015 WHILE i IS NOT NULL LOOP
1016 IF NOT OE_GLOBALS.Equal(oe_order_util.g_old_line_adj_tbl(i).operation, OE_GLOBALS.G_OPR_CREATE) AND
1017 (p_version_flag = 'Y' OR p_phase_change_flag = 'Y' or
1018 g_audit_line_adj_id_tbl.exists(i)) THEN
1019 IF g_audit_line_adj_id_tbl.exists(i) THEN
1020 l_audit_flag := 'Y';
1021 l_hist_type_code := g_audit_line_adj_id_tbl(i).hist_type_code;
1022 ELSE
1023 l_audit_flag := 'N';
1024 l_hist_type_code := NULL;
1025 END IF;
1026
1027 if l_audit_flag = 'Y' and g_audit_line_adj_id_tbl.exists(i) and
1028 g_audit_line_adj_id_tbl(i).reason_required then
1029 --Apply Reason for audit
1030 OE_Reasons_Util.Apply_Reason(
1031 p_entity_code => 'LINE_ADJ',
1032 p_entity_id => oe_order_util.g_old_line_adj_tbl(i).price_adjustment_id,
1033 p_header_id => oe_order_util.g_old_line_adj_tbl(i).header_id,
1034 p_version_number => l_version_number,
1035 p_reason_type => 'CHANGE_CODE',
1036 p_reason_code => OE_ORDER_UTIL.g_line_adj_tbl(i).change_reason_code,
1037 p_reason_comments => OE_ORDER_UTIL.g_line_adj_tbl(i).change_reason_text,
1038 x_reason_id => l_reason_id,
1039 x_return_status => l_return_status);
1040
1041 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
1042 IF l_debug_level > 0 THEN
1043 oe_debug_pub.add('Applying Audit Reason Caused Error on Line Adj',1);
1044 END IF;
1045
1046 if l_return_status = FND_API.G_RET_STS_ERROR then
1047 raise FND_API.G_EXC_ERROR;
1048 else
1049 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1050 end if;
1051 end if;
1052
1053 end if; --end apply reason
1054
1055 IF l_debug_level > 0 THEN
1056 oe_debug_pub.add('Calling recordLPAdjhist operation: '|| oe_order_util.g_old_line_adj_tbl(i).operation,1);
1057 END IF;
1058
1059 OE_CHG_ORDER_PVT.RecordLPAdjHist
1060 (p_line_adj_id => oe_order_util.g_old_line_adj_tbl(i).price_adjustment_id,
1061 p_line_adj_rec => oe_order_util.g_old_line_adj_tbl(i),
1062 p_hist_type_code => l_hist_type_code,
1063 p_reason_code => oe_globals.g_reason_code,
1064 p_comments => oe_globals.g_reason_comments,
1065 p_audit_flag => l_audit_flag,
1066 p_version_flag => p_version_flag,
1067 p_phase_change_flag => p_phase_change_flag,
1068 p_version_number => l_version_number,
1069 p_reason_id => l_reason_id,
1070 p_wf_activity_code => null,
1071 p_wf_result_code => null,
1072 x_return_status => l_return_status);
1073
1074 IF l_debug_level > 0 THEN
1075 OE_DEBUG_PUB.add('IN OEXUVERB:After'||l_return_status,5);
1076 END IF;
1077 IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
1078 IF l_debug_level > 0 THEN
1079 oe_debug_pub.add('Inserting Line Audit History error',1);
1080 END IF;
1081
1082 IF l_return_status = FND_API.G_RET_STS_ERROR then
1083 raise FND_API.G_EXC_ERROR;
1084 ELSE
1085 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1086 END IF;
1087 END IF;
1088
1089 END IF;
1090 i := oe_order_util.g_old_line_adj_tbl.NEXT(i); -- get subscript of next element
1091 END LOOP;
1092
1093 IF l_debug_level > 0 THEN
1094 oe_debug_pub.add(' OEXUVERB: before recording line scredits ',1);
1095 END IF;
1096 --Update history for line scredit
1097 i := oe_order_util.g_old_line_scredit_tbl.FIRST; -- get subscript of first element
1098 WHILE i IS NOT NULL LOOP
1099 IF NOT OE_GLOBALS.Equal(oe_order_util.g_old_line_scredit_tbl(i).operation, OE_GLOBALS.G_OPR_CREATE) AND
1100 (p_version_flag = 'Y' OR p_phase_change_flag = 'Y' or
1101 g_audit_line_scredit_id_tbl.exists(i)) THEN
1102 IF g_audit_line_scredit_id_tbl.exists(i) THEN
1103 l_audit_flag := 'Y';
1104 l_hist_type_code := g_audit_line_scredit_id_tbl(i).hist_type_code;
1105 ELSE
1106 l_audit_flag := 'N';
1107 l_hist_type_code := NULL;
1108 END IF;
1109
1110 if l_audit_flag = 'Y' and g_audit_line_scredit_id_tbl.exists(i) and
1111 g_audit_line_scredit_id_tbl(i).reason_required then
1112 --Apply Reason for audit
1113 OE_Reasons_Util.Apply_Reason(
1114 p_entity_code => 'LINE_SCREDIT',
1115 p_entity_id => oe_order_util.g_old_line_scredit_tbl(i).sales_credit_id,
1116 p_header_id => oe_order_util.g_old_line_scredit_tbl(i).header_id,
1117 p_version_number => l_version_number,
1118 p_reason_type => 'CANCEL_CODE',
1119 p_reason_code => OE_ORDER_UTIL.g_line_scredit_tbl(i).change_reason,
1120 p_reason_comments => OE_ORDER_UTIL.g_line_scredit_tbl(i).change_comments,
1121 x_reason_id => l_reason_id,
1122 x_return_status => l_return_status);
1123
1124 if l_return_status <> FND_API.G_RET_STS_SUCCESS then
1125 IF l_debug_level > 0 THEN
1126 oe_debug_pub.add('Applying Audit Reason Caused Error on Line Scredit',1);
1127 END IF;
1128
1129 if l_return_status = FND_API.G_RET_STS_ERROR then
1130 raise FND_API.G_EXC_ERROR;
1131 else
1132 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1133 end if;
1134 end if;
1135
1136 end if; --end apply reason
1137
1138 IF l_debug_level > 0 THEN
1139 oe_debug_pub.add('Calling recordLSCredithist operation: '|| oe_order_util.g_old_line_scredit_tbl(i).operation,1);
1140 END IF;
1141
1142 OE_CHG_ORDER_PVT.RecordLSCreditHist
1143 (p_line_scredit_id => oe_order_util.g_old_line_scredit_tbl(i).sales_credit_id,
1144 p_line_scredit_rec => oe_order_util.g_old_line_scredit_tbl(i),
1145 p_hist_type_code => l_hist_type_code,
1146 p_reason_code => oe_globals.g_reason_code,
1147 p_comments => oe_globals.g_reason_comments,
1148 p_audit_flag => l_audit_flag,
1149 p_version_flag => p_version_flag,
1150 p_phase_change_flag => p_phase_change_flag,
1151 p_version_number => l_version_number,
1152 p_reason_id => l_reason_id,
1153 p_wf_activity_code => null,
1154 p_wf_result_code => null,
1155 x_return_status => l_return_status);
1156
1157 IF l_debug_level > 0 THEN
1158 OE_DEBUG_PUB.add('IN OEXUVERB:After'||l_return_status,5);
1159 END IF;
1160 IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
1161 IF l_debug_level > 0 THEN
1162 oe_debug_pub.add('Inserting Line Audit History error',1);
1163 END IF;
1164 IF l_return_status = FND_API.G_RET_STS_ERROR then
1165 raise FND_API.G_EXC_ERROR;
1166 ELSE
1167 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1168 END IF;
1169 END IF;
1170
1171 END IF;
1172 i := oe_order_util.g_old_line_scredit_tbl.NEXT(i); -- get subscript of next element
1173 END LOOP;
1174
1175 -- added for bug 4321689
1176 x_return_status := l_return_status;
1177
1178 /*
1179 IF (NOT Reset_Globals) THEN
1180 RAISE FND_API.G_EXC_ERROR;
1181 END IF;
1182 */
1183 EXCEPTION
1184 WHEN OTHERS THEN
1185 ROLLBACK TO SAVEPOINT Record_Changed_Records;
1186 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1187 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
1188 OE_MSG_PUB.Add_Exc_Msg
1189 ( G_PKG_NAME
1190 , 'Record Changed Records'
1191 );
1192 END IF;
1193 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1194
1195 END Record_Changed_Records;
1196
1197 Function Reset_Globals
1198 RETURN BOOLEAN
1199 IS
1200 --
1201 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1202 --
1203 BEGIN
1204
1205 --Reset globals
1206 IF l_debug_level > 0 THEN
1207 oe_debug_pub.add(' OEXUVERB: reset_globals ',1);
1208 END IF;
1209
1210 OE_GLOBALS.G_ROLL_VERSION := 'N';
1211 OE_GLOBALS.G_CAPTURED_REASON := 'N';
1212 OE_GLOBALS.G_REASON_CODE := NULL;
1213 OE_GLOBALS.G_REASON_COMMENTS := NULL;
1214 OE_GLOBALS.G_REASON_TYPE := NULL;
1215 G_Audit_Line_ID_Tbl.DELETE;
1216 G_Audit_Header_Adj_ID_Tbl.DELETE;
1217 G_Audit_Line_Adj_ID_Tbl.DELETE;
1218 G_Audit_Header_Scredit_ID_Tbl.DELETE;
1219 G_Audit_Line_Scredit_ID_Tbl.DELETE;
1220
1221 G_AUDIT_HEADER_HIST_CODE := NULL;
1222
1223 RETURN TRUE;
1224 END Reset_Globals;
1225
1226 Procedure Check_Security(
1227 p_column_name IN VARCHAR2,
1228 p_on_operation_action IN NUMBER)
1229 IS
1230 --
1231 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1232 --
1233 BEGIN
1234 IF l_debug_level > 0 THEN
1235 oe_debug_pub.add(' OEXUVERB: check security ',1);
1236 oe_debug_pub.add(' OEXUVERB: gen_version action: '|| p_on_operation_action,1);
1237 END IF;
1238
1239 -- added for bug 3518059
1240 -- add g_header_created check to fix bug 3700341
1241 if OE_Order_Util.g_header_rec.operation = OE_GLOBALS.G_OPR_CREATE OR
1242 OE_GLOBALS.G_HEADER_CREATED OR
1243 OE_Blanket_Util.g_header_rec.operation = OE_GLOBALS.G_OPR_CREATE then
1244 IF l_debug_level > 0 THEN
1245 oe_debug_pub.add(' OEXUVERB: header is created, do nothing',1);
1246 END IF;
1247 else
1248 IF p_column_name = 'TRANSACTION_PHASE_CODE' AND
1249 OE_QUOTE_UTIL.G_COMPLETE_NEG = 'Y' THEN
1250 --if transaction_phase is changing
1251 IF OE_GLOBALS.G_ROLL_VERSION = 'Y' THEN
1252 OE_GLOBALS.G_ROLL_VERSION := 'PV';
1253 ELSIF OE_GLOBALS.G_ROLL_VERSION = 'N' THEN
1254 OE_GLOBALS.G_ROLL_VERSION := 'P';
1255 END IF;
1256 END IF;
1257
1258 IF p_on_operation_action IN (.1,.2) THEN
1259 IF OE_GLOBALS.G_ROLL_VERSION = 'P' THEN
1260 OE_GLOBALS.G_ROLL_VERSION := 'PV';
1261 ELSIF OE_GLOBALS.G_ROLL_VERSION = 'N' THEN
1262 OE_GLOBALS.G_ROLL_VERSION := 'Y';
1263 END IF;
1264
1265 IF p_on_operation_action = .1 AND OE_GLOBALS.G_CAPTURED_REASON = 'N' THEN
1266 --Capture reason required for versioning
1267 OE_GLOBALS.G_CAPTURED_REASON := 'V';
1268 END IF;
1269 END IF;
1270 end if;
1271 IF l_debug_level > 0 THEN
1272 oe_debug_pub.add(' OEXUVERB: gen_version roll: '|| oe_globals.g_roll_version,1);
1273 END IF;
1274
1275 END Check_Security;
1276
1277
1278 FUNCTION IS_REASON_RQD RETURN Varchar2 IS
1279 BEGIN
1280 IF OE_GLOBALS.G_CAPTURED_REASON IN ('V') THEN
1281 RETURN OE_GLOBALS.G_CAPTURED_REASON;
1282 ELSIF OE_GLOBALS.G_AUDIT_REASON_RQD_FLAG = 'Y' THEN
1283 RETURN 'A';
1284 ELSE
1285 -- else condition added for bug 4144357
1286 IF OE_GLOBALS.OE_AUDIT_HISTORY_TBL.count > 0 THEN
1287 FOR l_ind in 1..OE_GLOBALS.oe_audit_history_tbl.last LOOP
1288 IF OE_GLOBALS.OE_AUDIT_HISTORY_TBL.exists(l_ind) AND
1289 OE_GLOBALS.oe_audit_history_tbl(l_ind).HISTORY_TYPE = 'R' THEN
1290 OE_GLOBALS.G_AUDIT_REASON_RQD_FLAG := 'Y';
1291 RETURN 'A';
1292 END IF;
1293 END LOOP;
1294 END IF;
1295 END IF;
1296
1297 IF OE_GLOBALS.G_CAPTURED_REASON IN ('N','Y') THEN
1298 RETURN OE_GLOBALS.G_CAPTURED_REASON;
1299 END IF;
1300 END;
1301
1302 FUNCTION IS_AUDIT_REASON_CAPTURED
1303 (p_entity_code IN VARCHAR2,
1304 p_entity_id IN NUMBER)
1305 RETURN BOOLEAN
1306 IS
1307 l_ind NUMBER;
1308 l_result VARCHAR2(1);
1309 l_return_stat VARCHAR2(1);
1310
1311 BEGIN
1312
1313 G_UI_CALLED := TRUE;
1314
1315 IF p_entity_code = OE_GLOBALS.G_ENTITY_HEADER THEN
1316 IF OE_Order_Util.g_header_rec.change_reason <> FND_API.G_MISS_CHAR THEN
1317 g_temp_reason_code := OE_Order_Util.g_header_rec.change_reason;
1318 g_temp_reason_comments := OE_Order_Util.g_header_rec.change_comments;
1319 RETURN TRUE;
1320 END IF;
1321 ELSE
1322
1323 OE_Order_Util.Return_Glb_Ent_Index(
1324 p_entity_code,
1325 p_entity_id,
1326 l_ind,
1327 l_result,
1328 l_return_stat);
1329
1330 IF l_result = FND_API.G_TRUE THEN
1331 IF p_entity_code = OE_GLOBALS.G_ENTITY_LINE THEN
1332 IF OE_Order_Util.g_line_tbl(l_ind).change_reason <> FND_API.G_MISS_CHAR THEN
1333 g_temp_reason_code := OE_Order_Util.g_line_tbl(l_ind).change_reason;
1334 g_temp_reason_comments := OE_Order_Util.g_line_tbl(l_ind).change_comments;
1335 RETURN TRUE;
1336 END IF;
1337 ELSIF p_entity_code = OE_GLOBALS.G_ENTITY_HEADER_ADJ THEN
1338 IF OE_Order_Util.g_header_adj_tbl(l_ind).change_reason_code <> FND_API.G_MISS_CHAR THEN
1339 g_temp_reason_code := OE_Order_Util.g_header_adj_tbl(l_ind).change_reason_code;
1340 g_temp_reason_comments := OE_Order_Util.g_header_adj_tbl(l_ind).change_reason_text;
1341 RETURN TRUE;
1342 END IF;
1343 ELSIF p_entity_code = OE_GLOBALS.G_ENTITY_HEADER_SCREDIT THEN
1344 IF OE_Order_Util.g_header_scredit_tbl(l_ind).change_reason <> FND_API.G_MISS_CHAR THEN
1345 g_temp_reason_code := OE_Order_Util.g_header_scredit_tbl(l_ind).change_reason;
1346 g_temp_reason_comments := OE_Order_Util.g_header_scredit_tbl(l_ind).change_comments;
1347 RETURN TRUE;
1348 END IF;
1349 ELSIF p_entity_code = OE_GLOBALS.G_ENTITY_LINE_ADJ THEN
1350 IF OE_Order_Util.g_line_adj_tbl(l_ind).change_reason_code <> FND_API.G_MISS_CHAR THEN
1351 g_temp_reason_code := OE_Order_Util.g_line_adj_tbl(l_ind).change_reason_code;
1352 g_temp_reason_comments := OE_Order_Util.g_line_adj_tbl(l_ind).change_reason_text;
1353 RETURN TRUE;
1354 END IF;
1355 ELSIF p_entity_code = OE_GLOBALS.G_ENTITY_LINE_SCREDIT THEN
1356 IF OE_Order_Util.g_line_scredit_tbl(l_ind).change_reason <> FND_API.G_MISS_CHAR THEN
1357 g_temp_reason_code := OE_Order_Util.g_line_scredit_tbl(l_ind).change_reason;
1358 g_temp_reason_comments := OE_Order_Util.g_line_scredit_tbl(l_ind).change_comments;
1359 RETURN TRUE;
1360 END IF;
1361 END IF;
1362 END IF;
1363 END IF;
1364
1365 RETURN FALSE;
1366
1367 END;
1368
1369 FUNCTION CAPTURED_REASON RETURN Varchar2 IS
1370 BEGIN
1371 RETURN OE_GLOBALS.G_REASON_CODE;
1372 END CAPTURED_REASON;
1373
1374
1375 Procedure Capture_Audit_Info(
1376 p_entity_code IN VARCHAR2,
1377 p_entity_id IN NUMBER,
1378 p_hist_type_code IN VARCHAR2
1379 )
1380 IS
1381 l_ind NUMBER;
1382 l_result VARCHAR2(1);
1383 l_return_stat VARCHAR2(1);
1384 --
1385 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1386 --
1387 BEGIN
1388
1389 if l_debug_level > 0 then
1390 oe_debug_pub.add('capture audit info');
1391 oe_debug_pub.add('entity code :'||p_entity_code);
1392 oe_debug_pub.add('entity id :'||p_entity_id);
1393 oe_debug_pub.add('hist type :'||p_hist_type_code);
1394 end if;
1395
1396 IF p_entity_code <> OE_GLOBALS.G_ENTITY_HEADER THEN
1397 OE_Order_Util.Return_Glb_Ent_Index(
1398 p_entity_code,
1399 p_entity_id,
1400 l_ind,
1401 l_result,
1402 l_return_stat);
1403 END IF;
1404
1405 IF p_entity_code = OE_GLOBALS.G_ENTITY_HEADER THEN
1406 G_Audit_Header_Hist_Code := 'UPDATE';
1407 IF OE_GLOBALS.G_AUDIT_REASON_RQD_FLAG = 'Y' THEN
1408 G_Audit_Header_Reason_Required := TRUE;
1409 END IF;
1410 ELSIF p_entity_code = OE_GLOBALS.G_ENTITY_LINE THEN
1411 IF NOT G_Audit_Line_ID_Tbl.exists(l_ind)
1412 OR G_Audit_Line_ID_Tbl(l_ind).hist_type_code NOT IN ('SPLIT', 'CANCELLATION') THEN
1413 G_Audit_Line_ID_Tbl(l_ind).entity_id := p_entity_id;
1414 G_Audit_Line_ID_Tbl(l_ind).hist_type_code := p_hist_type_code;
1415 IF OE_GLOBALS.G_AUDIT_REASON_RQD_FLAG = 'Y' THEN
1416 G_Audit_Line_ID_Tbl(l_ind).Reason_Required := TRUE;
1417 END IF;
1418 END IF;
1419 ELSIF p_entity_code = OE_GLOBALS.G_ENTITY_HEADER_ADJ THEN
1420 IF NOT G_Audit_Header_Adj_ID_Tbl.exists(l_ind)
1421 OR G_Audit_Header_Adj_ID_Tbl(l_ind).hist_type_code NOT IN ('SPLIT', 'CANCELLATION') THEN
1422 G_Audit_Header_Adj_ID_Tbl(l_ind).entity_id := p_entity_id;
1423 G_Audit_Header_Adj_ID_Tbl(l_ind).hist_type_code := p_hist_type_code;
1424 IF OE_GLOBALS.G_AUDIT_REASON_RQD_FLAG = 'Y' THEN
1425 G_Audit_Header_Adj_ID_Tbl(l_ind).Reason_Required := TRUE;
1426 END IF;
1427 END IF;
1428 ELSIF p_entity_code = OE_GLOBALS.G_ENTITY_HEADER_SCREDIT THEN
1429 IF NOT G_Audit_Header_scredit_ID_Tbl.exists(l_ind)
1430 OR G_Audit_Header_scredit_ID_Tbl(l_ind).hist_type_code NOT IN ('SPLIT', 'CANCELLATION') THEN
1431 G_Audit_Header_scredit_ID_Tbl(l_ind).entity_id := p_entity_id;
1432 G_Audit_Header_scredit_ID_Tbl(l_ind).hist_type_code := p_hist_type_code;
1433 IF OE_GLOBALS.G_AUDIT_REASON_RQD_FLAG = 'Y' THEN
1434 G_Audit_Header_Scredit_ID_Tbl(l_ind).Reason_Required := TRUE;
1435 END IF;
1436 END IF;
1437 ELSIF p_entity_code = OE_GLOBALS.G_ENTITY_LINE_ADJ THEN
1438 IF NOT G_Audit_Line_Adj_ID_Tbl.exists(l_ind)
1439 OR G_Audit_Line_Adj_ID_Tbl(l_ind).hist_type_code NOT IN ('SPLIT', 'CANCELLATION') THEN
1440 G_Audit_Line_Adj_ID_Tbl(l_ind).entity_id := p_entity_id;
1441 G_Audit_Line_Adj_ID_Tbl(l_ind).hist_type_code := p_hist_type_code;
1442 IF OE_GLOBALS.G_AUDIT_REASON_RQD_FLAG = 'Y' THEN
1443 G_Audit_Line_Adj_ID_Tbl(l_ind).Reason_Required := TRUE;
1444 END IF;
1445 END IF;
1446 ELSIF p_entity_code = OE_GLOBALS.G_ENTITY_LINE_SCREDIT THEN
1447 IF NOT G_Audit_Line_scredit_ID_Tbl.exists(l_ind)
1448 OR G_Audit_Line_scredit_ID_Tbl(l_ind).hist_type_code NOT IN ('SPLIT', 'CANCELLATION') THEN
1449 G_Audit_Line_scredit_ID_Tbl(l_ind).entity_id := p_entity_id;
1450 G_Audit_Line_scredit_ID_Tbl(l_ind).hist_type_code := p_hist_type_code;
1451 IF OE_GLOBALS.G_AUDIT_REASON_RQD_FLAG = 'Y' THEN
1452 G_Audit_Line_Scredit_ID_Tbl(l_ind).Reason_Required := TRUE;
1453 END IF;
1454 END IF;
1455 END IF;
1456
1457 OE_GLOBALS.G_AUDIT_REASON_RQD_FLAG := 'N';
1458 END Capture_Audit_Info;
1459
1460 Procedure Get_Reason_Info(
1461 x_reason_code OUT NOCOPY VARCHAR2,
1462 x_reason_comments OUT NOCOPY VARCHAR2
1463 )
1464 IS
1465 i NUMBER;
1466 BEGIN
1467
1468 -- Get reason from temp values
1469 if G_UI_CALLED THEN
1470 x_reason_code := G_TEMP_REASON_CODE;
1471 x_reason_comments := G_TEMP_REASON_COMMENTS;
1472
1473 G_TEMP_REASON_CODE := NULL;
1474 G_TEMP_REASON_COMMENTS := NULL;
1475
1476 G_UI_CALLED := FALSE;
1477
1478 RETURN;
1479 end if;
1480
1481 -- Get current change reason
1482
1483 if OE_GLOBALS.G_REASON_CODE IS NOT NULL THEN
1484 x_reason_code := OE_GLOBALS.G_REASON_CODE;
1485 x_reason_comments := OE_GLOBALS.G_REASON_COMMENTS;
1486 end if;
1487
1488 if oe_order_util.g_header_rec.change_reason <> FND_API.G_MISS_CHAR then
1489 x_reason_code := oe_order_util.g_header_rec.change_reason;
1490 x_reason_comments := oe_order_util.g_header_rec.change_comments;
1491 RETURN;
1492 else
1493
1494 i := oe_order_util.g_header_adj_tbl.FIRST; -- get subscript of first element
1495 WHILE i IS NOT NULL LOOP
1496 if oe_order_util.g_header_adj_tbl(i).change_reason_code <> FND_API.G_MISS_CHAR then
1497 x_reason_code := oe_order_util.g_header_adj_tbl(i).change_reason_code;
1498 x_reason_comments := oe_order_util.g_header_adj_tbl(i).change_reason_text;
1499 RETURN;
1500 end if;
1501 i := oe_order_util.g_header_adj_tbl.NEXT(i); -- get subscript of next element
1502 END LOOP;
1503
1504 i := oe_order_util.g_header_scredit_tbl.FIRST;
1505 WHILE i IS NOT NULL LOOP
1506 if oe_order_util.g_header_scredit_tbl(i).change_reason <> FND_API.G_MISS_CHAR then
1507 x_reason_code := oe_order_util.g_header_scredit_tbl(i).change_reason;
1508 x_reason_comments := oe_order_util.g_header_scredit_tbl(i).change_comments;
1509 RETURN;
1510 end if;
1511 i := oe_order_util.g_header_scredit_tbl.NEXT(i);
1512 END LOOP;
1513
1514 i := oe_order_util.g_line_tbl.FIRST;
1515 WHILE i IS NOT NULL LOOP
1516 if oe_order_util.g_line_tbl(i).change_reason <> FND_API.G_MISS_CHAR then
1517 x_reason_code := oe_order_util.g_line_tbl(i).change_reason;
1518 x_reason_comments := oe_order_util.g_line_tbl(i).change_comments;
1519 RETURN;
1520 end if;
1521 i := oe_order_util.g_line_tbl.NEXT(i);
1522 END LOOP;
1523
1524 i := oe_order_util.g_line_adj_tbl.FIRST;
1525 WHILE i IS NOT NULL LOOP
1526 if oe_order_util.g_line_adj_tbl(i).change_reason_code <> FND_API.G_MISS_CHAR then
1527 x_reason_code := oe_order_util.g_line_adj_tbl(i).change_reason_code;
1528 x_reason_comments := oe_order_util.g_line_adj_tbl(i).change_reason_text;
1529 RETURN;
1530 end if;
1531 i := oe_order_util.g_line_adj_tbl.NEXT(i);
1532 END LOOP;
1533
1534 i := oe_order_util.g_line_scredit_tbl.FIRST;
1535 WHILE i IS NOT NULL LOOP
1536 if oe_order_util.g_line_scredit_tbl(i).change_reason <> FND_API.G_MISS_CHAR then
1537 x_reason_code := oe_order_util.g_line_scredit_tbl(i).change_reason;
1538 x_reason_comments := oe_order_util.g_line_scredit_tbl(i).change_comments;
1539 RETURN;
1540 end if;
1541 i := oe_order_util.g_line_scredit_tbl.NEXT(i);
1542 END LOOP;
1543
1544 end if;
1545
1546 END Get_Reason_Info;
1547
1548 -------------------------------
1549 -- QUERY_ROW(S) Procedures have been moved to
1550 -- OE_Version_History_Util (OEXHVERS/B.pls)
1551 -------------------------------
1552
1553 END OE_Versioning_Util;