[Home] [Help]
PACKAGE BODY: APPS.FA_DEPRN_ROLLBACK_PUB
Source
1 PACKAGE BODY FA_DEPRN_ROLLBACK_PUB AS
2 /* $Header: FAPDRBB.pls 120.20 2011/02/02 07:57:20 skchawla ship $ */
3
4 --*********************** Global constants *******************************--
5 G_PKG_NAME CONSTANT varchar2(30) := 'FA_DEPRN_ROLLBACK_PUB';
6 G_API_NAME CONSTANT varchar2(30) := 'Depreciation Rollback API';
7 G_API_VERSION CONSTANT number := 1.0;
8
9 g_log_level_rec fa_api_types.log_level_rec_type; -- Bug:5475024
10
11 --*********************** Private functions ******************************--
12
13 FUNCTION do_all_books
14 (px_asset_hdr_rec IN OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type,
15 p_calling_fn IN VARCHAR2,
16 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) RETURN BOOLEAN; -- Bug:5475024
17
18 --*********************** Public procedures ******************************--
19 procedure do_rollback (
20 -- Standard Parameters --
21 p_api_version IN NUMBER,
22 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
23 p_commit IN VARCHAR2 := FND_API.G_FALSE,
24 p_validation_level IN NUMBER :=FND_API.G_VALID_LEVEL_FULL,
25 x_return_status OUT NOCOPY VARCHAR2,
26 x_msg_count OUT NOCOPY NUMBER,
27 x_msg_data OUT NOCOPY VARCHAR2,
28 p_calling_fn IN VARCHAR2,
29 -- Asset Object --
30 px_asset_hdr_rec IN OUT NOCOPY fa_api_types.asset_hdr_rec_type
31 ) as
32
33 l_asset_type_rec fa_api_types.asset_type_rec_type;
34 l_asset_hdr_rec fa_api_types.asset_hdr_rec_type;
35 l_group_asset_id number;
36 l_tracking_method varchar2(30);
37
38 -- used to store original sob info upon entry into api
39 l_orig_set_of_books_id number;
40 l_orig_currency_context varchar2(64);
41
42 l_calling_fn varchar2(40) := 'fa_deprn_rollback_pub.do_rollback';
43
44 rb_err exception; -- sets return status
45
46
47 cursor c_members (p_book_type_code varchar2,
48 p_group_asset_id number) is
49 select asset_id
50 from fa_books
51 where group_asset_id = p_group_asset_id
52 and book_type_code = p_book_type_code
53 and transaction_header_id_out is null;
54
55 begin
56
57 SAVEPOINT do_rollback;
58
59 -- Bug:5475024
60 if (not g_log_level_rec.initialized) then
61 if (NOT fa_util_pub.get_log_level_rec (
62 x_log_level_rec => g_log_level_rec
63 )) then
64 raise rb_err;
65 end if;
66 end if;
67
68 -- Initialize message list if p_init_msg_list is set to TRUE.
69 if (fnd_api.to_boolean(p_init_msg_list)) then
70 -- initialize error message stack.
71 fa_srvr_msg.init_server_message;
72
73 -- initialize debug message stack.
74 fa_debug_pkg.initialize;
75 end if;
76
77 -- Check version of the API
78 -- Standard call to check for API call compatibility.
79 if (NOT fnd_api.compatible_api_call (
80 G_API_VERSION,
81 p_api_version,
82 G_API_NAME,
83 G_PKG_NAME
84 )) then
85 raise rb_err;
86 end if;
87
88 -- Call the cache for the primary transaction book
89 if (NOT fa_cache_pkg.fazcbc (X_book => px_asset_hdr_rec.book_type_code,
90 p_log_level_rec => g_log_level_rec)) then -- Bug:5475024
91 raise rb_err;
92 end if;
93
94 px_asset_hdr_rec.set_of_books_id :=
95 fa_cache_pkg.fazcbc_record.set_of_books_id;
96
97 if (p_validation_level = FND_API.G_VALID_LEVEL_FULL) then
98
99 null;
100
101 end if;
102
103 -- Bug:5475024
104 -- verify the asset exist in the book already
105 if not FA_ASSET_VAL_PVT.validate_asset_book
106 (p_transaction_type_code => 'DEPRECIATION',
107 p_book_type_code => px_asset_hdr_rec.book_type_code,
108 p_asset_id => px_asset_hdr_rec.asset_id,
109 p_calling_fn => l_calling_fn,
110 p_log_level_rec => g_log_level_rec) then
111 raise rb_err;
112 end if;
113
114 if not FA_UTIL_PVT.get_asset_type_rec
115 (p_asset_hdr_rec => px_asset_hdr_rec,
116 px_asset_type_rec => l_asset_type_rec,
117 p_date_effective => null,
118 p_log_level_rec => g_log_level_rec -- Bug:5475024
119 ) then
120 raise rb_err;
121 end if;
122
123 -- get group info for processing
124 select group_asset_id,
125 tracking_method
126 into l_group_asset_id,
127 l_tracking_method
128 from fa_books
129 where asset_id = px_asset_hdr_rec.asset_id
130 and book_type_code = px_asset_hdr_rec.book_type_code
131 and transaction_header_id_out is null;
132
133 -- call the routine to loop through primary and reporting books
134 if not do_all_books
135 (px_asset_hdr_rec => px_asset_hdr_rec,
136 p_calling_fn => p_calling_fn,
137 p_log_level_rec => g_log_level_rec) then -- Bug:5475024
138 raise rb_err;
139 end if;
140
141 l_asset_hdr_rec := px_asset_hdr_rec;
142
143 if (l_asset_type_rec.asset_type = 'GROUP' and
144 l_tracking_method is not null) then
145
146 for c_rec in c_members (p_book_type_code => px_asset_hdr_rec.book_type_code,
147 p_group_asset_id => px_asset_hdr_rec.asset_id) loop
148
149 l_asset_hdr_rec.asset_id := c_rec.asset_id;
150
151 if not do_all_books
152 (px_asset_hdr_rec => l_asset_hdr_rec,
153 p_calling_fn => p_calling_fn,
154 p_log_level_rec => g_log_level_rec) then -- Bug:5475024
155 raise rb_err;
156 end if;
157
158 end loop;
159
160
161 elsif (l_group_asset_id is not null) then
162
163 l_asset_hdr_rec.asset_id := l_group_asset_id;
164
165 if not do_all_books
166 (px_asset_hdr_rec => l_asset_hdr_rec,
167 p_calling_fn => p_calling_fn,
168 p_log_level_rec => g_log_level_rec) then -- Bug:5475024
169 raise rb_err;
170 end if;
171
172 if (l_tracking_method = 'ALLOCATE') then
173 --Bug6680499 changed px_asset_hdr_rec.asset_id to l_asset_hdr_rec.asset_id
174 for c_rec in c_members (p_book_type_code => px_asset_hdr_rec.book_type_code,
175 p_group_asset_id => l_asset_hdr_rec.asset_id) loop
176
177 l_asset_hdr_rec.asset_id := c_rec.asset_id;
178
179 if not do_all_books
180 (px_asset_hdr_rec => l_asset_hdr_rec,
181 p_calling_fn => p_calling_fn,
182 p_log_level_rec => g_log_level_rec) then -- Bug:5475024
183 raise rb_err;
184 end if;
185
186 end loop;
187
188 end if;
189 end if;
190
191 -- commit if p_commit is TRUE.
192 if (fnd_api.to_boolean (p_commit)) then
193 COMMIT WORK;
194 end if;
195
196 -- Standard call to get message count and if count is 1 get message info.
197 fnd_msg_pub.count_and_get (
198 p_count => x_msg_count,
199 p_data => x_msg_data
200 );
201
202 x_return_status := FND_API.G_RET_STS_SUCCESS;
203
204 exception
205 when rb_err then
206
207 ROLLBACK TO do_rollback;
208
209 fa_srvr_msg.add_message
210 (calling_fn => l_calling_fn,
211 p_log_level_rec => g_log_level_rec); -- Bug:5475024
212
213 FND_MSG_PUB.count_and_get (
214 p_count => x_msg_count,
215 p_data => x_msg_data
216 );
217
218 x_return_status := FND_API.G_RET_STS_ERROR;
219
220 when others then
221
222 ROLLBACK TO do_rollback;
223
224 fa_srvr_msg.add_sql_error
225 (calling_fn => l_calling_fn,
226 p_log_level_rec => g_log_level_rec); -- Bug:5475024
227
228 FND_MSG_PUB.count_and_get (
229 p_count => x_msg_count,
230 p_data => x_msg_data
231 );
232
233 x_return_status := FND_API.G_RET_STS_ERROR;
234
235 end do_rollback;
236
237 -----------------------------------------------------------------------------
238
239 -- Books (MRC) Wrapper - called from public API above
240 --
241 -- For non mrc books, this just calls the private API with provided params
242 -- For MRC, it processes the primary and then loops through each reporting
243 -- book calling the private api for each.
244
245
246 FUNCTION do_all_books
247 (px_asset_hdr_rec IN OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type,
248 p_calling_fn IN VARCHAR2,
249 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) RETURN BOOLEAN IS -- Bug:5475024
250
251 l_mrc_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
252 l_period_rec fa_api_types.period_rec_type;
253 l_rsob_tbl fa_cache_pkg.fazcrsob_sob_tbl_type;
254 l_mrc_sob_type_code varchar2(1);
255
256 l_deprn_source_info XLA_EVENTS_PUB_PKG.t_event_source_info;
257 l_security_context XLA_EVENTS_PUB_PKG.t_security;
258
259
260 l_event_id number;
261 l_rev_event_id number;
262
263 l_deprn_run_id number;
264 l_event_status varchar2(1);
265 l_deprn_count number;
266 l_sysdate date;
267 l_result integer;
268
269 l_txn_status boolean;
270
271 --Secondary Changes
272 l_secondary_event_id number;
273 l_secondary_deprn_run_id number;
274 l_secondary_deprn_source_info XLA_EVENTS_PUB_PKG.t_event_source_info;
275 l_secondary_event_status varchar2(1);
276 l_secondary_exists number;
277
278 l_calling_fn varchar2(60) := 'fa_deprn_rollback_pub.do_all_books';
279 rb_err exception;
280
281 BEGIN
282
283 l_sysdate := sysdate;
284
285 if (NOT FA_UTIL_PVT.get_period_rec (
286 p_book => px_asset_hdr_rec.book_type_code,
287 p_effective_date => NULL,
288 x_period_rec => l_period_rec,
289 p_log_level_rec => p_log_level_rec -- Bug:5475024
290 )) then
291 raise rb_err;
292 end if;
293
294 -- see if any rows actually exist in any currencies
295
296 BEGIN
297
298 select event_id, deprn_run_id
299 into l_event_id,
300 l_deprn_run_id
301 from fa_deprn_events_v de
302 where de.book_type_code = px_asset_hdr_rec.book_type_code
303 and de.asset_id = px_asset_hdr_rec.asset_id
304 and de.period_counter = l_period_rec.period_counter
305 and de.reversal_event_id is null;
306
307 if (g_log_level_rec.statement_level) then -- Bug:5475024
308 fa_debug_pkg.add(l_calling_fn, 'l_event_id', l_event_id,
309 p_log_level_rec => p_log_level_rec);
310 fa_debug_pkg.add(l_calling_fn, 'l_deprn_run_id', l_deprn_run_id,
311 p_log_level_rec => p_log_level_rec);
312 end if;
313
314 EXCEPTION
315
316 WHEN NO_DATA_FOUND THEN
317 if (g_log_level_rec.statement_level) then -- Bug:5475024
318 fa_debug_pkg.add(l_calling_fn, 'no event found', 'for this asset',
319 p_log_level_rec => p_log_level_rec);
320 end if;
321 END;
322
323
324
325 -- call transaction approval for primary books only
326 -- note that we don't need all the logic in faxcat since no transaction
327 -- would be allowed on a transaction in the open period. We need to insure
328 -- two things:
329 -- 1) no pending mass transaction on the book. (which could be mass deprn rollback)
330 -- 2) no deprn run ongoing since closing the book and rolling back deprn
331 -- on one or more of the already processed assets would not be good combination
332
333 -- BUG# 8247224
334 -- removing call to faxcat... replaceing with condition book level check
335 --
336 -- as originally written, this call will become recursive in the
337 -- event depreciatio nhas run for the period. When called from
338 -- faxcdr (via a transaction API), we're covered. in the event
339 -- it is called directly, we need to cover as book level check
340
341 if (nvl(p_calling_fn, '-X') <> 'FA_CHK_BOOKSTS_PKG.faxcdr') then
342 if not FA_CHK_BOOKSTS_PKG.faxcps
343 (X_book => px_asset_hdr_rec.book_type_code,
344 X_submit => FALSE,
345 X_start => FALSE,
346 X_asset_id => 0,
347 X_trx_type => 'RB_DEP',
348 X_txn_status => l_txn_status,
349 X_close_period => 0,
350 p_log_level_rec => p_log_level_rec
351 ) then
352 raise rb_err;
353 else
354 if (not l_txn_status ) then
355 raise rb_err;
356 end if;
357 end if;
358 end if;
359
360 if (l_event_id is not null) then
361 l_deprn_source_info.application_id := 140;
362 l_deprn_source_info.ledger_id := px_asset_hdr_rec.set_of_books_id;
363 l_deprn_source_info.source_id_int_1 := px_asset_hdr_rec.asset_id ;
364 l_deprn_source_info.source_id_char_1 := px_asset_hdr_rec.book_type_code;
365 l_deprn_source_info.source_id_int_2 := l_period_rec.period_counter;
366 l_deprn_source_info.source_id_int_3 := l_deprn_run_id;
367 l_deprn_source_info.entity_type_code := 'DEPRECIATION';
368
369 if (g_log_level_rec.statement_level) then -- Bug:5475024
370 fa_debug_pkg.add(l_calling_fn, 'calling get event status for event ', l_event_id,
371 p_log_level_rec => p_log_level_rec);
372 end if;
373
374 -- check the event status
375 l_event_status := XLA_EVENTS_PUB_PKG.get_event_status
376 (p_event_source_info => l_deprn_source_info,
377 p_event_id => l_event_id,
378 p_valuation_method => px_asset_hdr_rec.book_type_code,
379 p_security_context => l_security_context);
380
381 if (g_log_level_rec.statement_level) then -- Bug:5475024
382 fa_debug_pkg.add(l_calling_fn, 'event status ', l_event_status,
383 p_log_level_rec => p_log_level_rec);
384 end if;
385
386 if (l_event_status = XLA_EVENTS_PUB_PKG.C_EVENT_PROCESSED) then
387
388 -- create the reversal event
389 l_rev_event_id := xla_events_pub_pkg.create_event
390 (p_event_source_info => l_deprn_source_info,
391 p_event_type_code => 'ROLLBACK_DEPRECIATION',
392 p_event_date => greatest(l_period_rec.calendar_period_open_date, /*Bug#9274982 */
393 least(l_period_rec.calendar_period_close_date,
394 sysdate)),
395 p_event_status_code => XLA_EVENTS_PUB_PKG.C_EVENT_UNPROCESSED,
396 p_event_number => NULL,
397 p_reference_info => NULL,
398 p_valuation_method => px_asset_hdr_rec.book_type_code,
399 p_security_context => l_security_context);
400
401 if (g_log_level_rec.statement_level) then -- Bug:5475024
402 fa_debug_pkg.add(l_calling_fn, 'rollback event id', l_event_id,
403 p_log_level_rec => p_log_level_rec);
404 end if;
405
406 elsif (l_event_status = XLA_EVENTS_PUB_PKG.C_EVENT_UNPROCESSED) then
407
408 if (g_log_level_rec.statement_level) then -- Bug:5475024
409 fa_debug_pkg.add(l_calling_fn, 'deleting event', l_event_id,
410 p_log_level_rec => p_log_level_rec);
411 end if;
412
413 XLA_EVENTS_PUB_PKG.delete_event
414 (p_event_source_info => l_deprn_source_info,
415 p_event_id => l_event_id,
416 p_valuation_method => px_asset_hdr_rec.book_type_code,
417 p_security_context => l_security_context);
418
419 --6702657
420 BEGIN
421 l_result := XLA_EVENTS_PUB_PKG.delete_entity
422 (p_source_info => l_deprn_source_info,
423 p_valuation_method => px_asset_hdr_rec.book_type_code,
424 p_security_context => l_security_context);
425
426 EXCEPTION
427 WHEN OTHERS THEN
428 l_result := 1;
429 fa_debug_pkg.add(l_calling_fn, 'Unable to delete entity for rb event',
430 l_event_id, p_log_level_rec => p_log_level_rec);
431 fa_debug_pkg.add(l_calling_fn, 'l_result', l_result, p_log_level_rec => p_log_level_rec);
432 END; --annonymous
433 else
434 raise rb_err;
435 end if;
436
437 end if; -- event is not null
438
439 if (g_log_level_rec.statement_level) then -- Bug:5475024
440 fa_debug_pkg.add(l_calling_fn, 'entering ', 'main logic',
441 p_log_level_rec => p_log_level_rec);
442 end if;
443
444
445 if (NOT fa_cache_pkg.fazcrsob (
446 x_book_type_code => px_asset_hdr_rec.book_type_code,
447 x_sob_tbl => l_rsob_tbl,
448 p_log_level_rec => p_log_level_rec -- Bug:5475024
449 )) then
450 raise rb_err;
451 end if;
452
453 for mrc_index in 0..l_rsob_tbl.COUNT loop
454
455 l_mrc_asset_hdr_rec := px_asset_hdr_rec;
456
457 -- if the counter mrc_index is at 0, then process incoming
458 -- book else iterate through reporting books
459 if (mrc_index = 0) then
460 l_mrc_asset_hdr_rec.set_of_books_id :=
461 px_asset_hdr_rec.set_of_books_id;
462 l_mrc_sob_type_code := 'P';
463 else
464 l_mrc_asset_hdr_rec.set_of_books_id :=
465 l_rsob_tbl(mrc_index);
466 l_mrc_sob_type_code := 'R';
467 end if;
468
469 -- Need to always call fazcbcs
470 if (NOT fa_cache_pkg.fazcbcs (
471 X_book => l_mrc_asset_hdr_rec.book_type_code,
472 X_set_of_books_id => l_mrc_asset_hdr_rec.set_of_books_id,
473 p_log_level_rec => p_log_level_rec -- Bug:5475024
474 )) then
475 raise rb_err;
476 end if;
477 --Secondary changes
478 begin
479 l_secondary_exists := -1;
480 l_secondary_exists := FA_XLA_EVENTS_PVT.get_secondary_sob_id(l_mrc_asset_hdr_rec.book_type_code);
481 exception
482 when no_data_found then
483 l_secondary_exists := -1;
484 end;
485
486 if( l_mrc_asset_hdr_rec.set_of_books_id <> px_asset_hdr_rec.set_of_books_id)
487 AND (l_mrc_asset_hdr_rec.set_of_books_id = l_secondary_exists)then
488
489 BEGIN
490 if (g_log_level_rec.statement_level) then -- Bug:5475024
491 fa_debug_pkg.add(l_calling_fn, ' l_secondary_deprn_run_id', l_secondary_deprn_run_id,p_log_level_rec => p_log_level_rec);
492 fa_debug_pkg.add(l_calling_fn, 'l_secondary_sob_id ', l_secondary_exists,p_log_level_rec => p_log_level_rec);
493 fa_debug_pkg.add(l_calling_fn, 'px_asset_hdr_rec.asset_id ', px_asset_hdr_rec.asset_id,p_log_level_rec => p_log_level_rec);
494 fa_debug_pkg.add(l_calling_fn, 'l_period_rec.period_counter ', l_period_rec.period_counter,p_log_level_rec => p_log_level_rec);
495 end if;
496
497 SELECT deprn_run_id
498 into l_secondary_deprn_run_id
499 from fa_mc_deprn_summary
500 where set_of_books_id = l_secondary_exists
501 and book_type_code = px_asset_hdr_rec.book_type_code
502 and period_counter = l_period_rec.period_counter
503 and asset_id = px_asset_hdr_rec.asset_id;
504 if (g_log_level_rec.statement_level) then -- Bug:5475024
505 fa_debug_pkg.add(l_calling_fn, ' l_secondary_deprn_run_id', l_secondary_deprn_run_id,p_log_level_rec => p_log_level_rec);
506 end if;
507 select event_id
508 into l_secondary_event_id
509 from xla_events xeve,
510 xla_transaction_entities xent
511 where xeve.application_id = 140
512 and xeve.event_type_code = 'DEPRECIATION'
513 and xent.application_id = xeve.application_id
514 and source_id_char_1 = px_asset_hdr_rec.book_type_code
515 and source_id_int_1 = px_asset_hdr_rec.asset_id
516 and source_id_int_2 = l_period_rec.period_counter
517 and source_id_int_3 = l_secondary_deprn_run_id
518 and ledger_id = l_secondary_exists
519 and xeve.entity_id = xent.entity_id;
520
521 if (g_log_level_rec.statement_level) then -- Bug:5475024
522 fa_debug_pkg.add(l_calling_fn, 'l_sec_event_id', l_secondary_event_id,
523 p_log_level_rec => p_log_level_rec);
524 end if;
525
526 EXCEPTION
527
528 WHEN NO_DATA_FOUND THEN
529 if (g_log_level_rec.statement_level) then -- Bug:5475024
530 fa_debug_pkg.add(l_calling_fn, 'no sec event found', 'for this asset',
531 p_log_level_rec => p_log_level_rec);
532 end if;
533 END;
534
535 if (l_secondary_event_id is not null ) then
536 l_secondary_deprn_source_info.application_id := 140;
537 l_secondary_deprn_source_info.ledger_id := l_mrc_asset_hdr_rec.set_of_books_id;
538 l_secondary_deprn_source_info.source_id_int_1 := l_mrc_asset_hdr_rec.asset_id ;
539 l_secondary_deprn_source_info.source_id_char_1 := l_mrc_asset_hdr_rec.book_type_code;
540 l_secondary_deprn_source_info.source_id_int_2 := l_period_rec.period_counter;
541 l_secondary_deprn_source_info.source_id_int_3 := l_secondary_deprn_run_id;
542 l_secondary_deprn_source_info.entity_type_code := 'DEPRECIATION';
543
544 if (g_log_level_rec.statement_level) then -- Bug:5475024
545 fa_debug_pkg.add(l_calling_fn, 'calling get event status for event l_secondary event ', l_secONDARY_event_id,
546 p_log_level_rec => p_log_level_rec);
547 end if;
548
549 -- check the event status
550 l_secondary_event_status := XLA_EVENTS_PUB_PKG.get_event_status
551 (p_event_source_info => l_secondary_deprn_source_info,
552 p_event_id => l_secondary_event_id,
553 p_valuation_method => l_mrc_asset_hdr_rec.book_type_code,
554 p_security_context => l_security_context);
555
556 if (g_log_level_rec.statement_level) then -- Bug:5475024
557 fa_debug_pkg.add(l_calling_fn, 'event status ', l_secondary_event_status,
558 p_log_level_rec => p_log_level_rec);
559 end if;
560
561 if (l_secondary_event_status = XLA_EVENTS_PUB_PKG.C_EVENT_PROCESSED) then
562
563 -- create the reversal event
564 l_rev_event_id := xla_events_pub_pkg.create_event
565 (p_event_source_info => l_secondary_deprn_source_info,
566 p_event_type_code => 'ROLLBACK_DEPRECIATION',
567 p_event_date => greatest(l_period_rec.calendar_period_open_date, /*Bug#9274982 */
568 least(l_period_rec.calendar_period_close_date,
569 sysdate)),
570 p_event_status_code => XLA_EVENTS_PUB_PKG.C_EVENT_UNPROCESSED,
571 p_event_number => NULL,
572 p_reference_info => NULL,
573 p_valuation_method => l_mrc_asset_hdr_rec.book_type_code,
574 p_security_context => l_security_context);
575
576 if (g_log_level_rec.statement_level) then -- Bug:5475024
577 fa_debug_pkg.add(l_calling_fn, 'sec rollback event id', l_secondary_event_id,
578 p_log_level_rec => p_log_level_rec);
579 end if;
580
581 elsif (l_secondary_event_status = XLA_EVENTS_PUB_PKG.C_EVENT_UNPROCESSED) then
582
583 if (g_log_level_rec.statement_level) then -- Bug:5475024
584 fa_debug_pkg.add(l_calling_fn, 'deleting event', l_secondary_event_id,
585 p_log_level_rec => p_log_level_rec);
586 end if;
587
588 XLA_EVENTS_PUB_PKG.delete_event
589 (p_event_source_info => l_secondary_deprn_source_info,
590 p_event_id => l_secondary_event_id,
591 p_valuation_method => l_mrc_asset_hdr_rec.book_type_code,
592 p_security_context => l_security_context);
593
594 --6702657
595 BEGIN
596 l_result := XLA_EVENTS_PUB_PKG.delete_entity
597 (p_source_info => l_secondary_deprn_source_info,
598 p_valuation_method => l_mrc_asset_hdr_rec.book_type_code,
599 p_security_context => l_security_context);
600
601 EXCEPTION
602 WHEN OTHERS THEN
603 l_result := 1;
604 fa_debug_pkg.add(l_calling_fn, 'Unable to delete entity for sec rb event',
605 l_secondary_event_id, p_log_level_rec => p_log_level_rec);
606 fa_debug_pkg.add(l_calling_fn, 'l_result', l_result, p_log_level_rec => p_log_level_rec);
607 END; --annonymous
608 else
609 raise rb_err;
610 end if;
611
612 end if; -- event is not null
613
614 end if;
615
616 -- check to make sure there are deprn rows for the
617 -- currency in question
618
619 if (mrc_index = 0) then
620 select count(*)
621 into l_deprn_count
622 from fa_deprn_summary ds
623 where ds.book_type_code = px_asset_hdr_rec.book_type_code
624 and ds.asset_id = px_asset_hdr_rec.asset_id
625 and ds.period_counter = l_period_rec.period_counter;
626 else
627 select count(*)
628 into l_deprn_count
629 from fa_mc_deprn_summary ds
630 where ds.book_type_code = px_asset_hdr_rec.book_type_code
631 and ds.asset_id = px_asset_hdr_rec.asset_id
632 and ds.period_counter = l_period_rec.period_counter
633 and ds.set_of_books_id = l_mrc_asset_hdr_rec.set_of_books_id;
634 end if;
635
636 --8666930
637 if l_deprn_count <> 0 then
638 -- now rollback deprn
639 if not fa_deprn_rollback_pvt.do_rollback
640 (p_asset_hdr_rec => l_mrc_asset_hdr_rec,
641 p_period_rec => l_period_rec,
642 p_deprn_run_id => l_deprn_run_id,
643 p_reversal_event_id => l_rev_event_id,
644 p_reversal_date => l_sysdate,
645 p_deprn_exists_count => l_deprn_count,
646 p_mrc_sob_type_code => l_mrc_sob_type_code,
647 p_calling_fn => l_calling_fn,
648 p_log_level_rec => p_log_level_rec) then -- Bug:5475024
649 raise rb_err;
650 end if;
651 end if;
652 end loop;
653
654
655 -- Bug 6391045
656 -- Code hook for IAC
657
658 if (FA_IGI_EXT_PKG.IAC_Enabled) then
659 if not FA_IGI_EXT_PKG.Do_Rollback_Deprn(
660 p_asset_hdr_rec => px_asset_hdr_rec,
661 p_period_rec => l_period_rec,
662 p_deprn_run_id => l_deprn_run_id,
663 p_reversal_event_id => l_rev_event_id,
664 p_reversal_date => l_sysdate,
665 p_deprn_exists_count => l_deprn_count,
666 p_calling_function => l_calling_fn) then
667 raise rb_err;
668 end if;
669 end if; -- (FA_IGI_EXT_PKG.IAC_Enabled)
670
671
672
673 return true;
674
675 EXCEPTION
676
677 WHEN rb_ERR THEN
678 fa_srvr_msg.add_message(calling_fn => l_calling_fn,
679 p_log_level_rec => p_log_level_rec); -- Bug:5475024
680 return FALSE;
681
682 WHEN OTHERS THEN
683 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn,
684 p_log_level_rec => p_log_level_rec); -- Bug:5475024
685 return FALSE;
686
687 END do_all_books;
688
689 END FA_DEPRN_ROLLBACK_PUB;