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