[Home] [Help]
PACKAGE BODY: APPS.FA_MC_BOOK_CONTROLS_PKG
Source
1 PACKAGE BODY FA_MC_BOOK_CONTROLS_PKG as
2 /* $Header: faxmcbcb.pls 120.10 2011/02/03 06:01:24 skchawla ship $ */
3
4 --*********************** Global constants ******************************--
5
6 g_log_level_rec fa_api_types.log_level_rec_type;
7
8 G_PKG_NAME CONSTANT varchar2(30) := 'FA_MC_BOOK_CONTROLS_PUB';
9 G_API_NAME CONSTANT varchar2(30) := 'MC Book Controls API';
10 G_API_VERSION CONSTANT number := 1.0;
11
12
13 TYPE num_tbl IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
14 TYPE v30_tbl IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;
15
16 --*********************** Private functions ******************************--
17
18 FUNCTION insert_record
19 (p_src_ledger_id IN NUMBER,
20 p_alc_ledger_id IN NUMBER,
21 p_src_currency IN VARCHAR2,
22 p_alc_currency IN VARCHAR2,
23 p_book_type_code IN VARCHAR2,
24 p_gl_posting_allowed in varchar2 default 'YES',
25 p_enabled_flag in varchar2 default 'Y') RETURN BOOLEAN;
26
27 --*********************** Public procedures ******************************--
28
29 -----------------------------------------------------------------------------
30 --
31 -- Currency Based Insert
32 -- Called from ledger when adding an ALC
33 --
34 -----------------------------------------------------------------------------
35
36
37 PROCEDURE add_new_currency
38 (p_api_version IN NUMBER,
39 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
40 p_commit IN VARCHAR2 := FND_API.G_FALSE,
41 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
42 p_calling_fn IN VARCHAR2,
43
44 p_src_ledger_id IN NUMBER,
45 p_alc_ledger_id IN NUMBER,
46 p_src_currency IN VARCHAR2,
47 p_alc_currency IN VARCHAR2,
48 x_return_status OUT NOCOPY VARCHAR2,
49 x_msg_count OUT NOCOPY NUMBER,
50 x_msg_data OUT NOCOPY VARCHAR2
51 ) IS
52
53 l_book_type_code v30_tbl;
54
55 l_calling_fn VARCHAR2(35) := 'fa_mc_bc_pkg.add_new_currency';
56 error_found EXCEPTION;
57
58 cursor c_book_controls is
59 select book_type_code
60 from fa_book_controls
61 where set_of_books_id = p_src_ledger_id;
62
63 BEGIN
64
65 SAVEPOINT create_mc_bc;
66
67 -- Initialize message list if p_init_msg_list is set to TRUE.
68 if (fnd_api.to_boolean(p_init_msg_list)) then
69 -- initialize error message stack.
70 fa_srvr_msg.init_server_message;
71
72 -- initialize debug message stack.
73 fa_debug_pkg.initialize;
74 end if;
75
76 if not fa_util_pub.get_log_level_rec
77 (x_log_level_rec => g_log_level_rec) then
78 raise error_found;
79 end if;
80
81
82 if g_log_level_rec.statement_level then
83 fa_debug_pkg.add(
84 l_calling_fn,
85 'after initializing message stacks',
86 '',
87 p_log_level_rec => g_log_level_rec);
88 fa_debug_pkg.add(
89 l_calling_fn,
90 'p_src_ledger_id',
91 p_src_ledger_id,
92 p_log_level_rec => g_log_level_rec);
93 fa_debug_pkg.add(
94 l_calling_fn,
95 'p_alc_ledger_id',
96 p_alc_ledger_id,
97 p_log_level_rec => g_log_level_rec);
98 end if;
99
100 -- Check version of the API
101 -- Standard call to check for API call compatibility.
102 if NOT fnd_api.compatible_api_call (
103 G_API_VERSION,
104 p_api_version,
105 G_API_NAME,
106 G_PKG_NAME
107 ) then
108 x_return_status := FND_API.G_RET_STS_ERROR;
109 raise error_found;
110 end if;
111
112 open c_book_controls;
113 fetch c_book_controls bulk collect
114 into l_book_type_code;
115 close c_book_controls;
116
117
118 for i in 1..l_book_type_code.count loop
119
120 if g_log_level_rec.statement_level then
121 fa_debug_pkg.add(
122 l_calling_fn,
123 'processing book_type_code',
124 l_book_type_code(i),
125 p_log_level_rec => g_log_level_rec);
126 end if;
127
128 if not insert_record
129 (p_src_ledger_id => p_src_ledger_id,
130 p_alc_ledger_id => p_alc_ledger_id,
131 p_src_currency => p_src_currency,
132 p_alc_currency => p_alc_currency,
133 p_book_type_code => l_book_type_code(i)) then
134 raise error_found;
135 end if;
136
137 end loop;
138
139 x_return_status := FND_API.G_RET_STS_SUCCESS;
140
141 EXCEPTION
142
143 when error_found then
144 ROLLBACK TO create_mc_bc;
145
146 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
147
148 FND_MSG_PUB.count_and_get (
149 p_count => x_msg_count,
150 p_data => x_msg_data
151 );
152
153 x_return_status := FND_API.G_RET_STS_ERROR;
154
155 when others then
156 ROLLBACK TO create_mc_bc;
157
158 fa_srvr_msg.add_sql_error(
159 calling_fn => l_calling_fn);
160
161 FND_MSG_PUB.count_and_get (
162 p_count => x_msg_count,
163 p_data => x_msg_data
164 );
165
166 x_return_status := FND_API.G_RET_STS_ERROR;
167
168 END add_new_currency;
169
170 -----------------------------------------------------------------------------
171 --
172 -- Book Based Insert
173 -- Called from book controls related apis to process alternate currencies
174 --
175 -----------------------------------------------------------------------------
176
177 PROCEDURE add_new_book
178 (p_api_version IN NUMBER,
179 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
180 p_commit IN VARCHAR2 := FND_API.G_FALSE,
181 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
182 p_calling_fn IN VARCHAR2,
183 p_book_type_code IN VARCHAR2,
184 p_secondary_sob_id in number default null,
185 p_gl_posting_allowed in varchar2 default 'YES',
186 p_enabled_flag in varchar2 default 'Y',
187 x_return_status OUT NOCOPY VARCHAR2,
188 x_msg_count OUT NOCOPY NUMBER,
189 x_msg_data OUT NOCOPY VARCHAR2
190 ) IS
191
192 -- LPOON: Change to use ALC ledger record list instead ID list in order to
193 -- get their currencies at the same time
194 l_alc_ledger_list GL_MC_INFO.r_sob_list := GL_MC_INFO.r_sob_list();
195 l_src_ledger_id NUMBER;
196 l_src_currency VARCHAR2(15);
197
198 l_calling_fn VARCHAR2(35) := 'fa_mc_bc_pkg.add_new_book';
199 error_found EXCEPTION;
200 --Secondary Changes
201 l_ledger_category_code VARCHAR2(30);
202 l_book_class VARCHAR2(15);
203 l_corp_book VARCHAR2(15);
204 l_corp_currency VARCHAR2(15);
205 l_secondary_currency VARCHAR2(15);
206 l_corp_ledger_id NUMBER;
207 l_secondary_set_of_books_id number;
208
209 BEGIN
210
211 SAVEPOINT create_mc_bc;
212
213 -- Initialize message list if p_init_msg_list is set to TRUE.
214 if (fnd_api.to_boolean(p_init_msg_list)) then
215 -- initialize error message stack.
216 fa_srvr_msg.init_server_message;
217
218 -- initialize debug message stack.
219 fa_debug_pkg.initialize;
220 end if;
221
222 if g_log_level_rec.statement_level then
223 fa_debug_pkg.add(
224 l_calling_fn,
225 'processing book_type_code',
226 p_book_type_code);
227 end if;
228
229 -- Check version of the API
230 -- Standard call to check for API call compatibility.
231 if NOT fnd_api.compatible_api_call (
232 G_API_VERSION,
233 p_api_version,
234 G_API_NAME,
235 G_PKG_NAME
236 ) then
237 x_return_status := FND_API.G_RET_STS_ERROR;
238 raise error_found;
239 end if;
240
241 -- get the src ledger id from book controls
242 select lg.ledger_id,
243 lg.currency_code,
244 bc.book_class,
245 ledger_category_code,
246 distribution_source_book
247 into l_src_ledger_id,
248 l_src_currency,
249 l_book_class,
250 l_ledger_category_code,
251 l_corp_book
252 from fa_book_controls bc,
253 gl_ledgers lg
254 where bc.book_type_code = p_book_type_code
255 and lg.ledger_id = bc.set_of_books_id;
256 --Secondary Changes start
257
258 if(p_secondary_sob_id is not null) and ( l_book_class = 'TAX') then
259
260 select ledger_id,currency_code
261 into l_secondary_set_of_books_id,
262 l_secondary_currency
263 from gl_ledgers
264 where ledger_id = p_secondary_sob_id;
265 if ( (l_src_currency <> l_secondary_currency) and l_src_ledger_id <> p_secondary_sob_id) then
266 if not insert_record
267 (p_src_ledger_id => l_src_ledger_id,
268 p_alc_ledger_id => p_secondary_sob_id,
269 p_src_currency => l_src_currency,
270 p_alc_currency => l_secondary_currency,
271 p_book_type_code => p_book_type_code,
272 p_gl_posting_allowed => p_gl_posting_allowed,
273 p_enabled_flag => p_enabled_flag) then
274 raise error_found;
275 end if;
276 end if;
277 end if;
278
279 -- loop through each alternate ledger currency
280 -- and create the needed mc info
281 if(p_secondary_sob_id is null) then
282 if g_log_level_rec.statement_level then
283 fa_debug_pkg.add(
284 l_calling_fn,
285 'calling GL_MC_INFO.GET_ALC_LEDGER_ID for src ledger',
286 l_src_ledger_id,
287 p_log_level_rec => g_log_level_rec);
288 end if;
289
290 -- LPOON: Changed to call another API to get ALC ledger list instead of ID list
291 -- and then loop through that list
292 GL_MC_INFO.GET_ALC_ASSOCIATED_LEDGERS
293 (n_ledger_id => l_src_ledger_id,
294 n_appl_id => 140,
295 n_include_source_ledger => 'N',
296 n_ledger_list => l_alc_ledger_list);
297
298 for i in 1..l_alc_ledger_list.count loop
299
300 if g_log_level_rec.statement_level then
301 fa_debug_pkg.add
302 (l_calling_fn,
303 'processing alc currency',
304 l_alc_ledger_list(i).r_sob_id,
305 p_log_level_rec => g_log_level_rec);
306 end if;
307
308 -- BUG# 4673321 / 4673659
309 -- skip if it's the original null record for initialization
310 if (l_alc_ledger_list(i).r_sob_id is not null) and (nvl(p_secondary_sob_id,-1) <> l_alc_ledger_list(i).r_sob_id)then
311 if not insert_record
312 (p_src_ledger_id => l_src_ledger_id,
313 p_alc_ledger_id => l_alc_ledger_list(i).r_sob_id,
314 p_src_currency => l_src_currency,
315 p_alc_currency => l_alc_ledger_list(i).r_sob_curr,
316 p_book_type_code => p_book_type_code) then
317 raise error_found;
318 end if;
319
320 end if;
321
322 end loop;
323 end if;
324 x_return_status := FND_API.G_RET_STS_SUCCESS;
325
326 EXCEPTION
327
328 when error_found then
329 ROLLBACK TO create_mc_bc;
330
331 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
332
333 FND_MSG_PUB.count_and_get (
334 p_count => x_msg_count,
335 p_data => x_msg_data
336 );
337
338 x_return_status := FND_API.G_RET_STS_ERROR;
339
340 when others then
341 ROLLBACK TO create_mc_bc;
342
343 fa_srvr_msg.add_sql_error(
344 calling_fn => l_calling_fn);
345
346 FND_MSG_PUB.count_and_get (
347 p_count => x_msg_count,
348 p_data => x_msg_data
349 );
350
351 x_return_status := FND_API.G_RET_STS_ERROR;
352
353 END add_new_book;
354
355 -----------------------------------------------------------------------------
356 --
357 -- Main Insert - called from either the rate based or book based calls
358 --
359 -----------------------------------------------------------------------------
360
361
362 FUNCTION insert_record
363 (p_src_ledger_id IN NUMBER,
364 p_alc_ledger_id IN NUMBER,
365 p_src_currency IN VARCHAR2,
366 p_alc_currency IN VARCHAR2,
367 p_book_type_code IN VARCHAR2,
368 p_gl_posting_allowed in varchar2 default 'YES',
369 p_enabled_flag in varchar2 default 'Y') RETURN BOOLEAN IS
370
371 -- LPOON: Remove the local variables for source and ALC ledger currencies
372 -- as they're passed as parameters instead of getting them by APIs
373
374 l_retired_status varchar2(1) := 'C';
375 l_source_retired_status varchar2(1) := 'C';
376 l_mrc_converted_flag varchar2(1);
377 l_nbv_amount_threshold number;
378 l_mass_id number;
379 l_last_deprn_run_date date;
380 l_last_period_counter number;
381 l_current_fiscal_year number;
382
383 -- LPOON: A new variable to check if the record exists
384 l_exist_flag VARCHAR2(1) := 'N';
385
386 l_calling_fn VARCHAR2(35) := 'fa_mc_bc_pkg.insert_record';
387 error_found EXCEPTION;
388
389 BEGIN
390
391 -- we need to do this in order to insure no
392 -- mass process could be adding assets to
393 -- what would be seen as an empty book
394
395 -- lock the book while this process is occurring
396 -- need to verify there is no pending deprn run first
397 -- and then that there are active mass request id's
398
399 if (g_log_level_rec.statement_level) then
400 fa_debug_pkg.add
401 (l_calling_fn,
402 'locking',
403 'book controls record',
404 p_log_level_rec => g_log_level_rec);
405 end if;
406
407 BEGIN
408 select mass_request_id
409 into l_mass_id
410 from fa_book_controls
411 where book_type_code = p_book_type_code
412 and deprn_status = 'C';
413 EXCEPTION
414 WHEN OTHERS THEN
415 fa_srvr_msg.add_message
416 (calling_fn => l_calling_fn,
417 name => 'FA_TRXAPP_DEPRN_IS_RUNNING',
418 token1 => 'BOOK',
419 value1 => p_book_type_code);
420 raise error_found;
421 END;
422
423 BEGIN
424 select mass_request_id
425 into l_mass_id
426 from fa_book_controls
427 where book_type_code = p_book_type_code
428 and mass_request_id is null
429 for update of mass_request_id
430 NOWAIT;
431 EXCEPTION
432 WHEN OTHERS THEN
433 fa_srvr_msg.add_message
434 (calling_fn => l_calling_fn,
435 name => 'FA_TRXAPP_LOCK_FAILED',
436 token1 => 'BOOK',
437 value1 => p_book_type_code);
438 raise error_found;
439 END;
440
441 -- check if assets exists
442 if (g_log_level_rec.statement_level) then
443 fa_debug_pkg.add
444 (l_calling_fn,
445 'checking',
446 'if assets exist',
447 p_log_level_rec => g_log_level_rec);
448 end if;
449
450 BEGIN
451 select 'N'
452 into l_mrc_converted_flag
453 from dual
454 where exists
455 (select book_type_code
456 from fa_books
457 where book_type_code = p_book_type_code);
458 EXCEPTION
459 WHEN OTHERS THEN
460 l_mrc_converted_flag := 'Y';
461
462 END;
463
464 -- calculate nbv_threshold
465 if (g_log_level_rec.statement_level) then
466 fa_debug_pkg.add
467 (l_calling_fn,
468 'calculating',
469 'nbv amount threshold',
470 p_log_level_rec => g_log_level_rec);
471 end if;
472
473 select power(10,(1-precision))
474 into l_nbv_amount_threshold
475 from fnd_currencies a
476 where currency_code = p_alc_currency;
477
478 -- remaining values
479 if (g_log_level_rec.statement_level) then
480 fa_debug_pkg.add
481 (l_calling_fn,
482 'fetching',
483 'remaining values from fa_book_controls',
484 p_log_level_rec => g_log_level_rec);
485 end if;
486
487 select last_deprn_run_date,
488 last_period_counter,
489 current_fiscal_year
490 into l_last_deprn_run_date,
491 l_last_period_counter,
492 l_current_fiscal_year
493 from fa_book_controls
494 where book_type_code = p_book_type_code;
495
496 -- insert mc book controls record
497 if (g_log_level_rec.statement_level) then
498 fa_debug_pkg.add
499 (l_calling_fn,
500 'checking',
501 'existing mc book controls record',
502 p_log_level_rec => g_log_level_rec);
503 end if;
504
505 -- LPOON: Check if MC book control record exists
506
507 BEGIN
508 SELECT 'Y'
509 INTO l_exist_flag
510 FROM FA_MC_BOOK_CONTROLS
511 WHERE set_of_books_id = p_alc_ledger_id
512 AND book_type_code = p_book_type_code;
513 EXCEPTION
514 WHEN NO_DATA_FOUND THEN
515 l_exist_flag := 'N';
516 END;
517
518 -- LPOON: If it doesn't exist, insert one; Otherwise, update the columns that
519 -- can be changed i.e. CURRENCY_CODE and NBV_AMOUNT_THRESHOLD
520 if (l_exist_flag = 'N') then
521
522 if (g_log_level_rec.statement_level) then
523 fa_debug_pkg.add
524 (l_calling_fn,
525 'inserting',
526 'mc book controls record',
527 p_log_level_rec => g_log_level_rec);
528 end if;
529
530 -- Insert new records
531 INSERT INTO FA_MC_BOOK_CONTROLS
532 (SET_OF_BOOKS_ID ,
533 BOOK_TYPE_CODE ,
534 CURRENCY_CODE ,
535 DEPRN_STATUS ,
536 DEPRN_REQUEST_ID ,
537 LAST_PERIOD_COUNTER ,
538 LAST_DEPRN_RUN_DATE ,
539 CURRENT_FISCAL_YEAR ,
540 RETIRED_STATUS ,
541 RETIRED_REQUEST_ID ,
542 PRIMARY_SET_OF_BOOKS_ID ,
543 PRIMARY_CURRENCY_CODE ,
544 SOURCE_RETIRED_STATUS ,
545 SOURCE_RETIRED_REQUEST_ID ,
546 MRC_CONVERTED_FLAG ,
547 ENABLED_FLAG ,
548 NBV_AMOUNT_THRESHOLD ,
549 LAST_UPDATED_BY ,
550 LAST_UPDATE_DATE ,
551 LAST_UPDATE_LOGIN ,
552 CONVERSION_STATUS ,
553 MASS_REQUEST_ID ,
554 gl_posting_allowed_flag
555 ) values (
556 p_alc_ledger_id ,
557 p_book_type_code ,
558 p_alc_currency ,
559 'C' ,
560 NULL ,
561 l_last_period_counter ,
562 l_last_deprn_run_date ,
563 l_current_fiscal_year ,
564 l_retired_status ,
565 0 ,
566 p_src_ledger_id ,
567 p_src_currency ,
568 l_source_retired_status ,
569 0 ,
570 l_mrc_converted_flag ,
571 p_enabled_flag ,
572 l_nbv_amount_threshold ,
573 fnd_global.user_id ,
574 sysdate ,
575 fnd_global.login_id ,
576 NULL ,
577 NULL ,
578 p_gl_posting_allowed
579 );
580
581 -- insert the mc deprn periods rows
582 if (g_log_level_rec.statement_level) then
583 fa_debug_pkg.add
584 (l_calling_fn,
585 'inserting',
586 'mc deprn periods records',
587 p_log_level_rec => g_log_level_rec);
588 end if;
589
590 INSERT INTO FA_MC_DEPRN_PERIODS(
591 SET_OF_BOOKS_ID,
592 BOOK_TYPE_CODE,
593 PERIOD_NAME,
594 PERIOD_COUNTER,
595 FISCAL_YEAR,
596 PERIOD_NUM,
597 PERIOD_OPEN_DATE,
598 PERIOD_CLOSE_DATE,
599 DEPRECIATION_BATCH_ID,
600 RETIREMENT_BATCH_ID,
601 RECLASS_BATCH_ID,
602 TRANSFER_BATCH_ID,
603 ADDITION_BATCH_ID,
604 ADJUSTMENT_BATCH_ID,
605 DEFERRED_DEPRN_BATCH_ID,
606 CALENDAR_PERIOD_OPEN_DATE,
607 CALENDAR_PERIOD_CLOSE_DATE,
608 CIP_ADDITION_BATCH_ID,
609 CIP_ADJUSTMENT_BATCH_ID,
610 CIP_RECLASS_BATCH_ID,
611 CIP_RETIREMENT_BATCH_ID,
612 CIP_REVAL_BATCH_ID,
613 CIP_TRANSFER_BATCH_ID,
614 REVAL_BATCH_ID,
615 DEPRN_ADJUSTMENT_BATCH_ID)
616 SELECT p_alc_ledger_id,
617 p_book_type_code,
618 PERIOD_NAME,
619 PERIOD_COUNTER,
620 FISCAL_YEAR,
621 PERIOD_NUM,
622 PERIOD_OPEN_DATE,
623 PERIOD_CLOSE_DATE,
624 DEPRECIATION_BATCH_ID,
625 RETIREMENT_BATCH_ID,
626 RECLASS_BATCH_ID,
627 TRANSFER_BATCH_ID,
628 ADDITION_BATCH_ID,
629 ADJUSTMENT_BATCH_ID,
630 DEFERRED_DEPRN_BATCH_ID,
631 CALENDAR_PERIOD_OPEN_DATE,
632 CALENDAR_PERIOD_CLOSE_DATE,
633 CIP_ADDITION_BATCH_ID,
634 CIP_ADJUSTMENT_BATCH_ID,
635 CIP_RECLASS_BATCH_ID,
636 CIP_RETIREMENT_BATCH_ID,
637 CIP_REVAL_BATCH_ID,
638 CIP_TRANSFER_BATCH_ID,
639 REVAL_BATCH_ID,
640 DEPRN_ADJUSTMENT_BATCH_ID
641 FROM FA_DEPRN_PERIODS
642 WHERE BOOK_TYPE_CODE = p_book_type_code;
643
644 ELSE
645
646 if (g_log_level_rec.statement_level) then
647 fa_debug_pkg.add
648 (l_calling_fn,
649 'updating',
650 'mc book controls record',
651 p_log_level_rec => g_log_level_rec);
652 end if;
653
654 -- Update existing records for columns which can be changed only
655 UPDATE FA_MC_BOOK_CONTROLS
656 SET CURRENCY_CODE = p_alc_currency,
657 NBV_AMOUNT_THRESHOLD = l_nbv_amount_threshold
658 WHERE set_of_books_id = p_alc_ledger_id
659 AND book_type_code = p_book_type_code;
660
661 END IF; -- IF (l_exist_flag = 'N')
662
663 -- update the mrc anabled flag on primary table
664 if (g_log_level_rec.statement_level) then
665 fa_debug_pkg.add
666 (l_calling_fn,
667 'updating',
668 'fa_book_controls.mc_source_flag',
669 p_log_level_rec => g_log_level_rec);
670 end if;
671
672 update fa_book_controls
673 set mc_source_flag = 'Y'
674 where book_type_code = p_book_type_code;
675
676 if (g_log_level_rec.statement_level) then
677 fa_debug_pkg.add
678 (l_calling_fn,
679 'returning',
680 'true',
681 p_log_level_rec => g_log_level_rec);
682 end if;
683
684
685 return true;
686
687 EXCEPTION
688 WHEN ERROR_FOUND THEN
689 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
690 return FALSE;
691
692 WHEN OTHERS THEN
693 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn);
694 return FALSE;
695
696 END insert_record;
697
698 -----------------------------------------------------------------------------
699
700 -----------------------------------------------------------------------------
701 --
702 -- Currency Based Update
703 -- Called from ledger when disabling an ALC
704 --
705 -----------------------------------------------------------------------------
706
707 PROCEDURE disable_currency
708 (p_api_version IN NUMBER,
709 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
710 p_commit IN VARCHAR2 := FND_API.G_FALSE,
711 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
712 p_calling_fn IN VARCHAR2,
713
714 p_src_ledger_id IN NUMBER,
715 p_alc_ledger_id IN NUMBER,
716 p_src_currency IN VARCHAR2,
717 p_alc_currency IN VARCHAR2,
718 x_return_status OUT NOCOPY VARCHAR2,
719 x_msg_count OUT NOCOPY NUMBER,
720 x_msg_data OUT NOCOPY VARCHAR2
721 ) IS
722
723 l_calling_fn VARCHAR2(35) := 'fa_mc_bc_pkg.disable_currency';
724 error_found EXCEPTION;
725
726 BEGIN
727
728 SAVEPOINT update_mc_bc;
729
730 -- Initialize message list if p_init_msg_list is set to TRUE.
731 if (fnd_api.to_boolean(p_init_msg_list)) then
732 -- initialize error message stack.
733 fa_srvr_msg.init_server_message;
734
735 -- initialize debug message stack.
736 fa_debug_pkg.initialize;
737 end if;
738
739 if not fa_util_pub.get_log_level_rec
740 (x_log_level_rec => g_log_level_rec) then
741 raise error_found;
742 end if;
743
744
745 if g_log_level_rec.statement_level then
746 fa_debug_pkg.add(
747 l_calling_fn,
748 'after initializing message stacks',
749 '',
750 p_log_level_rec => g_log_level_rec);
751 fa_debug_pkg.add(
752 l_calling_fn,
753 'p_src_ledger_id',
754 p_src_ledger_id,
755 p_log_level_rec => g_log_level_rec);
756 fa_debug_pkg.add(
757 l_calling_fn,
758 'p_alc_ledger_id',
759 p_alc_ledger_id,
760 p_log_level_rec => g_log_level_rec);
761 end if;
762
763 -- Check version of the API
764 -- Standard call to check for API call compatibility.
765 if NOT fnd_api.compatible_api_call (
766 G_API_VERSION,
767 p_api_version,
768 G_API_NAME,
769 G_PKG_NAME
770 ) then
771 x_return_status := FND_API.G_RET_STS_ERROR;
772 raise error_found;
773 end if;
774
775 if g_log_level_rec.statement_level then
776 fa_debug_pkg.add(
777 l_calling_fn,
778 'updating the books',
779 '',
780 p_log_level_rec => g_log_level_rec);
781 end if;
782
783
784 Update fa_mc_book_controls
785 set enabled_flag = 'N',
786 last_update_date = sysdate,
787 last_updated_by = fnd_global.user_id,
788 last_update_login = fnd_global.login_id
789 where set_of_books_id = p_alc_ledger_id
790 and primary_set_of_books_id = p_src_ledger_id
791 and enabled_flag = 'Y';
792
793 x_return_status := FND_API.G_RET_STS_SUCCESS;
794
795 EXCEPTION
796
797 when error_found then
798 ROLLBACK TO update_mc_bc;
799
800 fa_srvr_msg.add_message(calling_fn => l_calling_fn);
801
802 FND_MSG_PUB.count_and_get (
803 p_count => x_msg_count,
804 p_data => x_msg_data
805 );
806
807 x_return_status := FND_API.G_RET_STS_ERROR;
808
809 when others then
810 ROLLBACK TO update_mc_bc;
811
812 fa_srvr_msg.add_sql_error(
813 calling_fn => l_calling_fn);
814
815 FND_MSG_PUB.count_and_get (
816 p_count => x_msg_count,
817 p_data => x_msg_data
818 );
819
820 x_return_status := FND_API.G_RET_STS_ERROR;
821
822 END disable_currency;
823
824 ----------------------------------------------------------------------------
825
826
827 END FA_MC_BOOK_CONTROLS_PKG;