DBA Data[Home] [Help]

PACKAGE BODY: APPS.FA_CACHE_PKG

Source


1 PACKAGE BODY FA_CACHE_PKG as
2 /* $Header: FACACHEB.pls 120.34.12020000.3 2013/03/08 05:06:50 rmandali ship $ */
3 
4 -----------------------------------------------------------------------------
5 
6 Function fazcbc
7            (X_book in varchar2, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
8          return boolean is
9 
10    l_found       boolean;
11    l_count       number;
12    fazcbc_err    exception;
13 
14 begin <<FAZCBC>>
15 
16    -- due to caching problem, will do direct select
17    -- BUG# 1910467 - reinstating cache
18    -- transaction approval will insure the cache is not
19    -- not stale every time it is called
20    --   bridgway   08/01/01
21 
22    if nvl(fazcbc_record.book_type_code, X_book || 'NULL') = X_book then
23       null;
24    else
25       if fazcbc_table.count = 0 then
26          l_found := FALSE;
27 
28          -- load profiles
29          if not fazprof then
30             raise fazcbc_err;
31          end if;
32 
33       end if;
34 
35       for i in 1..fazcbc_table.count loop
36 
37          if (fazcbc_table(i).book_type_code = X_book) then
38             l_found := TRUE;
39             l_count := i;
40             exit;
41          else
42             l_found := FALSE;
43          end if;
44 
45       end loop;
46 
47       if l_found = TRUE then
48          fazcbc_record       := fazcbc_table(l_count);
49          fazcbc_index        := l_count;
50       else
51          SELECT book_type_code,
52                 book_type_name,
53                 set_of_books_id,
54                 initial_date,
55                 last_deprn_run_date,
56                 amortize_flag,
57                 fully_reserved_flag,
58                 deprn_calendar,
59                 book_class,
60                 gl_posting_allowed_flag,
61                 current_fiscal_year,
62                 allow_mass_changes,
63                 allow_deprn_adjustments,
64                 accounting_flex_structure,
65                 last_update_date,
66                 last_updated_by,
67                 prorate_calendar,
68                 date_ineffective,
69                 je_retirement_category,
70                 je_depreciation_category,
71                 je_reclass_category,
72                 gl_je_source,
73                 je_addition_category,
74                 je_adjustment_category,
75                 distribution_source_book,
76                 je_transfer_category,
77                 copy_retirements_flag,
78                 copy_adjustments_flag,
79                 deprn_request_id,
80                 allow_cost_ceiling,
81                 allow_deprn_exp_ceiling,
82                 calculate_nbv,
83                 run_year_end_program,
84                 je_deferred_deprn_category,
85                 itc_allowed_flag,
86                 created_by,
87                 creation_date,
88                 last_update_login,
89                 allow_mass_copy,
90                 allow_purge_flag,
91                 allow_reval_flag,
92                 amortize_reval_reserve_flag,
93                 ap_intercompany_acct,
94                 ar_intercompany_acct,
95                 attribute1,
96                 attribute2,
97                 attribute3,
98                 attribute4,
99                 attribute5,
100                 attribute6,
101                 attribute7,
102                 attribute8,
103                 attribute9,
104                 attribute10,
105                 attribute11,
106                 attribute12,
107                 attribute13,
108                 attribute14,
109                 attribute15,
110                 attribute_category_code,
111                 capital_gain_threshold,
112                 copy_salvage_value_flag,
113                 cost_of_removal_clearing_acct,
114                 cost_of_removal_gain_acct,
115                 cost_of_removal_loss_acct,
116                 default_life_extension_ceiling,
117                 default_life_extension_factor,
118                 default_max_fully_rsvd_revals,
119                 default_reval_fully_rsvd_flag,
120                 deferred_deprn_expense_acct,
121                 deferred_deprn_reserve_acct,
122                 deprn_allocation_code,
123                 deprn_status,
124                 fiscal_year_name,
125                 initial_period_counter,
126                 je_cip_adjustment_category,
127                 je_cip_addition_category,
128                 je_cip_reclass_category,
129                 je_cip_retirement_category,
130                 je_cip_reval_category,
131                 je_cip_transfer_category,
132                 je_reval_category,
133                 last_mass_copy_period_counter,
134                 last_period_counter,
135                 last_purge_period_counter,
136                 mass_copy_source_book,
137                 mass_request_id,
138                 nbv_amount_threshold,
139                 nbv_fraction_threshold,
140                 nbv_retired_gain_acct,
141                 nbv_retired_loss_acct,
142                 proceeds_of_sale_clearing_acct,
143                 proceeds_of_sale_gain_acct,
144                 proceeds_of_sale_loss_acct,
145                 revalue_on_retirement_flag,
146                 reval_deprn_reserve_flag,
147                 reval_rsv_retired_gain_acct,
148                 reval_rsv_retired_loss_acct,
149                 deprn_adjustment_acct,
150                 immediate_copy_flag,
151                 je_deprn_adjustment_category,
152                 depr_first_year_ret_flag,
153                 flexbuilder_defaults_ccid,
154                 retire_reval_reserve_flag,
155                 use_current_nbv_for_deprn,
156                 copy_additions_flag,
157                 use_percent_salvage_value_flag,
158                 reval_posting_flag,
159                 global_attribute1,
160                 global_attribute2,
161                 global_attribute3,
162                 global_attribute4,
163                 global_attribute5,
164                 global_attribute6,
165                 global_attribute7,
166                 global_attribute8,
167                 global_attribute9,
168                 global_attribute10,
169                 global_attribute11,
170                 global_attribute12,
171                 global_attribute13,
172                 global_attribute14,
173                 global_attribute15,
174                 global_attribute16,
175                 global_attribute17,
176                 global_attribute18,
177                 global_attribute19,
178                 global_attribute20,
179                 global_attribute_category,
180                 mc_source_flag,
181                 reval_ytd_deprn_flag,
182                 allow_cip_assets_flag,
183                 org_id,
184                 allow_group_deprn_flag,
185                 allow_cip_dep_group_flag,
186                 allow_interco_group_flag,
187                 copy_group_addition_flag,
188                 copy_group_assignment_flag,
189                 allow_cip_member_flag,
190                 allow_member_tracking_flag,
191                 INTERCOMPANY_POSTING_FLAG,
192                 allow_cost_sign_change_flag,
193                 sorp_enabled_flag,
194                 allow_impairment_flag,
195                 copy_amort_adaj_exp_flag,
196                 copy_group_change_flag,
197                 prevent_prior_period_txns_flag,
198                 allow_unallocated_lines_flag,
199                 IMPORT_ALLOC_INV_LINES_AS_NEW
200            INTO fazcbc_record.book_type_code,
201                 fazcbc_record.book_type_name,
202                 fazcbc_record.set_of_books_id,
203                 fazcbc_record.initial_date,
204                 fazcbc_record.last_deprn_run_date,
205                 fazcbc_record.amortize_flag,
206                 fazcbc_record.fully_reserved_flag,
207                 fazcbc_record.deprn_calendar,
208                 fazcbc_record.book_class,
209                 fazcbc_record.gl_posting_allowed_flag,
210                 fazcbc_record.current_fiscal_year,
211                 fazcbc_record.allow_mass_changes,
212                 fazcbc_record.allow_deprn_adjustments,
213                 fazcbc_record.accounting_flex_structure,
214                 fazcbc_record.last_update_date,
215                 fazcbc_record.last_updated_by,
216                 fazcbc_record.prorate_calendar,
217                 fazcbc_record.date_ineffective,
218                 fazcbc_record.je_retirement_category,
219                 fazcbc_record.je_depreciation_category,
220                 fazcbc_record.je_reclass_category,
221                 fazcbc_record.gl_je_source,
222                 fazcbc_record.je_addition_category,
223                 fazcbc_record.je_adjustment_category,
224                 fazcbc_record.distribution_source_book,
225                 fazcbc_record.je_transfer_category,
226                 fazcbc_record.copy_retirements_flag,
227                 fazcbc_record.copy_adjustments_flag,
228                 fazcbc_record.deprn_request_id,
229                 fazcbc_record.allow_cost_ceiling,
230                 fazcbc_record.allow_deprn_exp_ceiling,
231                 fazcbc_record.calculate_nbv,
232                 fazcbc_record.run_year_end_program,
233                 fazcbc_record.je_deferred_deprn_category,
234                 fazcbc_record.itc_allowed_flag,
235                 fazcbc_record.created_by,
236                 fazcbc_record.creation_date,
237                 fazcbc_record.last_update_login,
238                 fazcbc_record.allow_mass_copy,
239                 fazcbc_record.allow_purge_flag,
240                 fazcbc_record.allow_reval_flag,
241                 fazcbc_record.amortize_reval_reserve_flag,
242                 fazcbc_record.ap_intercompany_acct,
243                 fazcbc_record.ar_intercompany_acct,
244                 fazcbc_record.attribute1,
245                 fazcbc_record.attribute2,
246                 fazcbc_record.attribute3,
247                 fazcbc_record.attribute4,
248                 fazcbc_record.attribute5,
249                 fazcbc_record.attribute6,
250                 fazcbc_record.attribute7,
251                 fazcbc_record.attribute8,
252                 fazcbc_record.attribute9,
253                 fazcbc_record.attribute10,
254                 fazcbc_record.attribute11,
255                 fazcbc_record.attribute12,
256                 fazcbc_record.attribute13,
257                 fazcbc_record.attribute14,
258                 fazcbc_record.attribute15,
259                 fazcbc_record.attribute_category_code,
260                 fazcbc_record.capital_gain_threshold,
261                 fazcbc_record.copy_salvage_value_flag,
262                 fazcbc_record.cost_of_removal_clearing_acct,
263                 fazcbc_record.cost_of_removal_gain_acct,
264                 fazcbc_record.cost_of_removal_loss_acct,
265                 fazcbc_record.default_life_extension_ceiling,
266                 fazcbc_record.default_life_extension_factor,
267                 fazcbc_record.default_max_fully_rsvd_revals,
268                 fazcbc_record.default_reval_fully_rsvd_flag,
269                 fazcbc_record.deferred_deprn_expense_acct,
270                 fazcbc_record.deferred_deprn_reserve_acct,
271                 fazcbc_record.deprn_allocation_code,
272                 fazcbc_record.deprn_status,
273                 fazcbc_record.fiscal_year_name,
274                 fazcbc_record.initial_period_counter,
275                 fazcbc_record.je_cip_adjustment_category,
276                 fazcbc_record.je_cip_addition_category,
277                 fazcbc_record.je_cip_reclass_category,
278                 fazcbc_record.je_cip_retirement_category,
279                 fazcbc_record.je_cip_reval_category,
280                 fazcbc_record.je_cip_transfer_category,
281                 fazcbc_record.je_reval_category,
282                 fazcbc_record.last_mass_copy_period_counter,
283                 fazcbc_record.last_period_counter,
284                 fazcbc_record.last_purge_period_counter,
285                 fazcbc_record.mass_copy_source_book,
286                 fazcbc_record.mass_request_id,
287                 fazcbc_record.nbv_amount_threshold,
288                 fazcbc_record.nbv_fraction_threshold,
289                 fazcbc_record.nbv_retired_gain_acct,
290                 fazcbc_record.nbv_retired_loss_acct,
291                 fazcbc_record.proceeds_of_sale_clearing_acct,
292                 fazcbc_record.proceeds_of_sale_gain_acct,
293                 fazcbc_record.proceeds_of_sale_loss_acct,
294                 fazcbc_record.revalue_on_retirement_flag,
295                 fazcbc_record.reval_deprn_reserve_flag,
296                 fazcbc_record.reval_rsv_retired_gain_acct,
297                 fazcbc_record.reval_rsv_retired_loss_acct,
298                 fazcbc_record.deprn_adjustment_acct,
299                 fazcbc_record.immediate_copy_flag,
300                 fazcbc_record.je_deprn_adjustment_category,
301                 fazcbc_record.depr_first_year_ret_flag,
302                 fazcbc_record.flexbuilder_defaults_ccid,
303                 fazcbc_record.retire_reval_reserve_flag,
304                 fazcbc_record.use_current_nbv_for_deprn,
305                 fazcbc_record.copy_additions_flag,
306                 fazcbc_record.use_percent_salvage_value_flag,
307                 fazcbc_record.reval_posting_flag,
308                 fazcbc_record.global_attribute1,
309                 fazcbc_record.global_attribute2,
310                 fazcbc_record.global_attribute3,
311                 fazcbc_record.global_attribute4,
312                 fazcbc_record.global_attribute5,
313                 fazcbc_record.global_attribute6,
314                 fazcbc_record.global_attribute7,
315                 fazcbc_record.global_attribute8,
316                 fazcbc_record.global_attribute9,
317                 fazcbc_record.global_attribute10,
318                 fazcbc_record.global_attribute11,
319                 fazcbc_record.global_attribute12,
320                 fazcbc_record.global_attribute13,
321                 fazcbc_record.global_attribute14,
322                 fazcbc_record.global_attribute15,
323                 fazcbc_record.global_attribute16,
324                 fazcbc_record.global_attribute17,
325                 fazcbc_record.global_attribute18,
326                 fazcbc_record.global_attribute19,
327                 fazcbc_record.global_attribute20,
328                 fazcbc_record.global_attribute_category,
329                 fazcbc_record.mc_source_flag,
330                 fazcbc_record.reval_ytd_deprn_flag,
331                 fazcbc_record.allow_cip_assets_flag,
332                 fazcbc_record.org_id,
333                 fazcbc_record.allow_group_deprn_flag,
334                 fazcbc_record.allow_cip_dep_group_flag,
335                 fazcbc_record.allow_interco_group_flag,
336                 fazcbc_record.copy_group_addition_flag,
337                 fazcbc_record.copy_group_assignment_flag,
338                 fazcbc_record.allow_cip_member_flag,
339                 fazcbc_record.allow_member_tracking_flag,
340                 fazcbc_record.INTERCOMPANY_POSTING_FLAG,
341                 fazcbc_record.allow_cost_sign_change_flag,
342                 fazcbc_record.sorp_enabled_flag,
343                 fazcbc_record.allow_impairment_flag,
344                 fazcbc_record.copy_amort_adaj_exp_flag,
345                 fazcbc_record.copy_group_change_flag,
346                 fazcbc_record.prevent_prior_period_txns_flag,
347                 fazcbc_record.allow_unallocated_lines_flag,
348                 fazcbc_record.IMPORT_ALLOC_INV_LINES_AS_NEW
349            FROM fa_book_controls
350           WHERE book_type_code = X_book;
351 
352          fazcbc_table(fazcbc_table.count + 1):= fazcbc_record;
353          fazcbc_index                   := fazcbc_table.count;
354 
355       end if;
356    end if;
357 
358    -- now load the fazcbcs cache proactively
359    if NOT fa_cache_pkg.fazcbcs(X_book => x_book,
360                                X_set_of_books_id => fazcbc_record.set_of_books_id,
361                                p_log_level_rec => p_log_level_rec) then
362       raise fazcbc_err;
363    end if;
364 
365    return (TRUE);
366 
367 exception
368    when NO_DATA_FOUND then
369         fa_srvr_msg.add_message(calling_fn => NULL,
370                         name       => 'FA_CACHE_BOOK_CONTROLS',
371                         token1     => 'BOOK',
372                         value1     => X_book, p_log_level_rec => p_log_level_rec);
373         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcbc', p_log_level_rec => p_log_level_rec);
374         return (false);
375    when fazcbc_err then
376         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcbc', p_log_level_rec => p_log_level_rec);
377         return (false);
378    when others then
379         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcbc', p_log_level_rec => p_log_level_rec);
380         return (FALSE);
381 
382 end FAZCBC;
383 
384 -----------------------------------------------------------------------------
385 
386 Function fazcbcs
387           (X_book in VARCHAR2,
388            X_set_of_books_id in number,
389            p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
390          return boolean is
391 
392    l_found            boolean;
393    l_count            number;
394    h_reporting_flag   varchar2(1);
395 
396 begin <<FAZCBCS>>
397 
398    if (X_set_of_books_id is not null) then
399       if not fazcsob
400               (X_set_of_books_id   => X_set_of_books_id,
401                X_mrc_sob_type_code => h_reporting_flag) then
402                    fa_srvr_msg.add_sql_error
403                      (calling_fn => 'fa_cache_pkg.fazcbcs', p_log_level_rec => p_log_level_rec);
404                    return(FALSE);
405       end if;
406    else
407       h_reporting_flag := 'P';
408    end if;
409 
410    if ((nvl(fazcbcs_record.book_type_code, X_book || 'NULL') = X_book) and
411        (fazcbcs_record.set_of_books_id = X_set_of_books_id)) then
412       return true;
413    else
414       if fazcbcs_table.count = 0 then
415          l_found := FALSE;
416       end if;
417 
418       for i in 1..fazcbcs_table.count loop
419           if ((fazcbcs_table(i).book_type_code  = X_book) and
420               (fazcbcs_table(i).set_of_books_id = X_set_of_books_id)) then
421              l_found := TRUE;
422              l_count := i;
423              exit;
424           else
425              l_found := FALSE;
426           end if;
427       end loop;
428 
429       if l_found = TRUE then
430          fazcbcs_record       := fazcbcs_table(l_count);
431          fazcbcs_index        := l_count;
432       else
433          -- load primary cache first if needed
434          if (nvl(fazcbc_record.book_type_code, X_book || 'NULL') <> X_book)
435 then
436             if not (fazcbc (X_book, p_log_level_rec)) then
437                fa_srvr_msg.add_sql_error
438                   (calling_fn => 'fa_cache_pkg.fazcbcs', p_log_level_rec => p_log_level_rec);
439                return(FALSE);
440             end if;
441          end if;
442 
443          if h_reporting_flag = 'R' then
444 
445             -- initialize the value to primary
446             fazcbcs_record                  := fazcbc_record;
447 
448             -- overlay the matching MC columns
449 
450             SELECT  DEPRN_REQUEST_ID
451                   , LAST_UPDATE_LOGIN
452                   , DEPRN_STATUS
453                   , LAST_PERIOD_COUNTER
454                   , MASS_REQUEST_ID
455                   , NBV_AMOUNT_THRESHOLD
456                   , BOOK_TYPE_CODE
457                   , SET_OF_BOOKS_ID
458                   , LAST_DEPRN_RUN_DATE
459                   , CURRENT_FISCAL_YEAR
460                   , LAST_UPDATE_DATE
461                   , LAST_UPDATED_BY
462               INTO  fazcbcs_record.DEPRN_REQUEST_ID
463                   , fazcbcs_record.LAST_UPDATE_LOGIN
464                   , fazcbcs_record.DEPRN_STATUS
465                   , fazcbcs_record.LAST_PERIOD_COUNTER
466                   , fazcbcs_record.MASS_REQUEST_ID
467                   , fazcbcs_record.NBV_AMOUNT_THRESHOLD
468                   , fazcbcs_record.BOOK_TYPE_CODE
469                   , fazcbcs_record.SET_OF_BOOKS_ID
470                   , fazcbcs_record.LAST_DEPRN_RUN_DATE
471                   , fazcbcs_record.CURRENT_FISCAL_YEAR
472                   , fazcbcs_record.LAST_UPDATE_DATE
473                   , fazcbcs_record.LAST_UPDATED_BY
474               FROM fa_mc_book_controls
475              WHERE book_type_code = X_book
476                AND set_of_books_id = X_set_of_books_id;
477          else
478              fazcbcs_record := fazcbc_record;
479          end if;
480 
481          fazcbcs_table(fazcbcs_table.count + 1):= fazcbcs_record;
482          fazcbcs_index                   := fazcbcs_table.count;
483 
484       end if;
485    end if;
486 
487    return (TRUE);
488 
489 exception
490    when NO_DATA_FOUND then
491         fa_srvr_msg.add_message(calling_fn => NULL,
492                         name       => 'FA_CACHE_MC_BOOK_CONTROLS',
493                         token1     => 'BOOK',
494                         value1     => X_book,
495                         token2     => 'SET_OF_BOOKS_ID',
496                         value2     => X_set_of_books_id, p_log_level_rec => p_log_level_rec);
497         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcbcs', p_log_level_rec => p_log_level_rec);
498         return (FALSE);
499    when others then
500         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcbcs', p_log_level_rec => p_log_level_rec);
501         return (FALSE);
502 
503 end FAZCBCS;
504 
505 -----------------------------------------------------------------------------
506 
507 Function fazcbc_clr
508           (X_book in varchar2, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
509          return boolean is
510 
511    l_count   number;
512 
513 BEGIN <<fazcbc_clr>>
514 
515    -- clear the record
516    fazcbc_record.book_type_code := 'NULL';
517 
518    -- clear the member in the table. since the cache should always
519    -- be called before doing this (i.e. faxcps) we know the global
520    -- index variable will have the correct index from fazcbc
521 
522    -- correction on the above - this is not necessarily true
523    -- since we're proatviely clearing it in query_balances
524    -- in the client interface to prevent stale data in the
525    -- last period counter
526 
527    if nvl(fazcbc_index, 0) > 0 then
528 
529       fazcbc_table.delete(fazcbc_index);
530 
531       -- reset the values so there is no missing member for future use
532       l_count := fazcbc_table.count;
533 
534       for i in fazcbc_index..l_count loop
535           -- copy the next member into the current one
536           fazcbc_table(i) := fazcbc_table(i+1);
537       end loop;
538 
539       -- delete the last member in the array which is now a duplicate
540       fazcbc_table.delete(l_count + 1);
541    end if;
542 
543    fazcbcs_record.book_type_code := 'NULL';
544 
545    if nvl(fazcbcs_index, 0) > 0 then
546 
547       fazcbcs_table.delete(fazcbcs_index);
548 
549       -- reset the values so there is no missing member for future use
550       l_count := fazcbcs_table.count;
551 
552       for i in fazcbcs_index..l_count loop
553           -- copy the next member into the current one
554           fazcbcs_table(i) := fazcbcs_table(i+1);
555       end loop;
556 
557       -- delete the last member in the array which is now a duplicate
558       fazcbcs_table.delete(l_count + 1);
559    end if;
560 
561    return TRUE;
562 
563 exception
564    when others then
565         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcbc_clr', p_log_level_rec => p_log_level_rec);
566         return (FALSE);
567 
568 END fazcbc_clr;
569 
570 -----------------------------------------------------------------------------
571 
572 Function fazcct
573           (X_calendar in varchar2, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
574          return boolean is
575 
576    l_found       boolean;
577    l_count       number;
578 
579 begin <<FAZCCT>>
580    if nvl(fazcct_record.calendar_type, 'NULL') = X_calendar then
581       return true;
582    else
583 
584       if fazcct_table.count = 0 then
585          l_found := FALSE;
586       end if;
587 
588       for i in 1..fazcct_table.count loop
589 
590           if (fazcct_table(i).calendar_type = X_calendar) then
591              l_found := TRUE;
592              l_count := i;
593              exit;
594           else
595              l_found := FALSE;
596           end if;
597 
598       end loop;
599 
600       if l_found = TRUE then
601          fazcct_record           := fazcct_table(l_count);
602       else
603          SELECT *
604            INTO fazcct_record
605            FROM fa_calendar_types
606           WHERE calendar_type = X_calendar;
607 
608          fazcct_table(fazcct_table.count + 1):= fazcct_record;
609 
610       end if;
611    end if;
612 
613    return (TRUE);
614 
615 exception
616    when NO_DATA_FOUND then
617         fa_srvr_msg.add_message(calling_fn => NULL,
618                         name       => 'FA_CACHE_CALENDAR_TYPES',
619                         token1     => 'CALENDAR',
620                         value1     => X_calendar, p_log_level_rec => p_log_level_rec);
621         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcct', p_log_level_rec => p_log_level_rec);
622         return (FALSE);
623 
624    when others then
625         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcct', p_log_level_rec => p_log_level_rec);
626         return (FALSE);
627 
628 end FAZCCT;
629 
630 -----------------------------------------------------------------------------
631 
632 Function fazcff
633           (X_calendar         varchar2,
634            X_book             varchar2,
635            X_fy               integer,
636            X_period_fracs out NOCOPY fa_std_types.table_fa_cp_struct
637           , p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
638          return boolean is
639 
640    l_count            number;
641    l_period           number;
642    l_found            boolean;
643 
644    h_fiscal_year_name varchar2(30);
645    h_deprn_alloc_code varchar2(30);
646    h_pers_per_yr integer(5);
647 
648    CURSOR FAZCFF_CURSOR IS
649        SELECT decode (substr(h_deprn_alloc_code,1,1),
650                       'E', 1.0 / h_pers_per_yr,
651                      (cp.end_date + 1 - cp.start_date) /
652                      (fy.end_date + 1 - fy.start_date)),
653               to_number (to_char (cp.start_date, 'J')),
654               to_number (to_char (cp.end_date, 'J'))
655          FROM fa_calendar_periods cp, fa_fiscal_year fy
656         WHERE fy.fiscal_year = X_fy
657           AND fy.fiscal_year_name = h_fiscal_year_name
658           AND cp.calendar_type = X_calendar
659           AND cp.start_date BETWEEN fy.start_date AND fy.end_date
660           AND cp.end_date BETWEEN fy.start_date AND fy.end_date
661         ORDER BY period_num;
662 
663 begin <<FAZCFF>>
664 
665    -- NOTE: the internal fazcff table is indexed starting at 1
666    --       the out paramter starts at 0!!!!
667 
668    if fazcff_table.count = 0 then
669       l_found := FALSE;
670    end if;
671 
672       for i in 1..fazcff_table.count loop
673          -- find first match which is the first period of the year
674          if (fazcff_table(i).book_type_code = X_book and
675              fazcff_table(i).calendar_type  = X_calendar and
676              fazcff_table(i).fiscal_year    = X_fy) then
677             l_count := i;
678             l_found := TRUE;
679             exit;
680          else
681             l_found := FALSE;
682          end if;
683       end loop;
684 
685       -- Get number of periods per year
686       if not fazcct (X_calendar) then
687         fa_srvr_msg.add_message(calling_fn => 'fa_cache_pkg.fazcff', p_log_level_rec => p_log_level_rec);
688         return (FALSE);
689       end if;
690 
691       h_pers_per_yr := fazcct_record.number_per_fiscal_year;
692 
693       if l_found = TRUE then
694 
695          -- init l_period which is used for output struct to 0
696          l_period := 0;
697          for x in l_count..l_count + h_pers_per_yr - 1 loop
698              X_period_fracs(l_period).frac        := fazcff_table(x).frac;
699              X_period_fracs(l_period).start_jdate := fazcff_table(x).start_jdate;
700              X_period_fracs(l_period).end_jdate   := fazcff_table(x).end_jdate;
701              l_period                             := l_period + 1;
702          end loop;
703       else
704 
705 /*  will implement this later for this cache type in order
706  *  to prevent the pl/sql table from getting to big
707  *  logic should delete all rows for the book/cal/fy combo
708  *  though this may get tricky and we might need to bump max_size
709 
710          -- do not let array get to big.. once it is at the
711          -- max begin clearing values from the array
712          if fazcff_table.count >= G_max_array_size then
713 
714             -- get the first record
715 
716             -- clear the first record
717             fazcff_record.book_type_code := 'NULL';
718 
719             -- clear the first member in the table
720             fazcff_table.delete(1);
721 
722             -- reset values so there is no missing member for future use
723             l_count := fazcff_table.count;
724 
725             for i in 1..l_count loop
726                -- copy the next member into the current one
727                fazcff_table(i) := fazcff_table(i+1);
728             end loop;
729 
730             -- delete the last member in the array which is now a duplicate
731             fazcff_table.delete(l_count + 1);
732 
733          end if;
734 */
735 
736          -- Get fiscal year name (book cache should already be loaded)
737 
738          h_fiscal_year_name := fazcbc_record.fiscal_year_name;
739          h_deprn_alloc_code := fazcbc_record.deprn_allocation_code;
740 
741          OPEN FAZCFF_CURSOR;
742          for ctr in 0..h_pers_per_yr-1 loop
743              FETCH FAZCFF_CURSOR
744               INTO X_period_fracs(ctr).frac,
745                    X_period_fracs(ctr).start_jdate,
746                    X_period_fracs(ctr).end_jdate;
747 
748              fazcff_table(fazcff_table.count + 1).book_type_code := X_book;
749              fazcff_table(fazcff_table.count).calendar_type      := X_calendar;
750              fazcff_table(fazcff_table.count).fiscal_year        := X_fy;
751              fazcff_table(fazcff_table.count).frac               := X_period_fracs(ctr).frac;
752              fazcff_table(fazcff_table.count).start_jdate        := X_period_fracs(ctr).start_jdate;
753              fazcff_table(fazcff_table.count).end_jdate          := X_period_fracs(ctr).end_jdate;
754 
755          end loop;
756 
757          if FAZCFF_CURSOR%ROWCOUNT = 0 then
758             CLOSE FAZCFF_CURSOR;
759             raise NO_DATA_FOUND;
760          end if;
761 
762          CLOSE FAZCFF_CURSOR;
763       end if;
764 
765    return (TRUE);
766 
767 Exception
768    when NO_DATA_FOUND then
769         fa_srvr_msg.add_message(calling_fn => NULL,
770                         name       => 'FA_CACHE_CALENDAR_FRAC',
771                         token1     => 'CALENDAR',
772                         value1     => X_calendar,
773                         token2     => 'BOOK',
774                         value2     => X_book,
775                         token3     => 'FY',
776                         value3     => X_fy, p_log_level_rec => p_log_level_rec);
777         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcff', p_log_level_rec => p_log_level_rec);
778         return (FALSE);
779    when others then
780         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcff', p_log_level_rec => p_log_level_rec);
781         return (FALSE);
782 
783 end FAZCFF;
784 
785 -----------------------------------------------------------------------------
786 
787 Function fazccl
788          (X_target_ceiling_name varchar2,
789           X_target_jdate        integer,
790           X_target_year         integer,
791           X_ceiling         out NOCOPY number
792          , p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
793 return boolean is
794 
795    l_found       boolean;
796    l_count       number;
797 
798 begin <<FAZCCL>>
799 
800    if (nvl(fazccl_record.t_ceiling_name, 'NULL') = X_target_ceiling_name and
801        nvl(fazccl_record.t_jdate, -1)        = X_target_jdate and
802        nvl(fazccl_record.t_year, -1)         = X_target_year ) then
803       X_ceiling := fazccl_record.ceiling;
804       return (TRUE);
805    else
806       if fazccl_table.count = 0 then
807          l_found := FALSE;
808       end if;
809 
810       for i in 1..fazccl_table.count loop
811 
812          if (nvl(fazccl_table(i).t_ceiling_name, 'NULL') = X_target_ceiling_name and
813              nvl(fazccl_table(i).t_jdate, -1)        = X_target_jdate and
814              nvl(fazccl_table(i).t_year, -1)         = X_target_year ) then
815             l_found := TRUE;
816             l_count := i;
817             exit;
818          else
819             l_found := FALSE;
820          end if;
821       end loop;
822 
823       if l_found = TRUE then
824          fazccl_record           := fazccl_table(l_count);
825       else
826          SELECT cur_one.limit
827            INTO fazccl_record.ceiling
828            FROM fa_ceilings cur_one,
829                 fa_ceilings this_one,
830                 fa_ceilings next_one
831           WHERE cur_one.ceiling_name = X_target_ceiling_name
832             AND this_one.ceiling_name = X_target_ceiling_name
833             AND next_one.ceiling_name (+) = X_target_ceiling_name
834             AND to_date (X_target_jdate, 'J') BETWEEN
835                  cur_one.start_date AND
836                  nvl (cur_one.end_date, to_date (X_target_jdate, 'J'))
837             AND to_date (X_target_jdate, 'J') BETWEEN
838                  this_one.start_date AND
839                  nvl (this_one.end_date, to_date (X_target_jdate, 'J'))
840             AND to_date (X_target_jdate, 'J') BETWEEN
841                  next_one.start_date (+) AND
842                  nvl (next_one.end_date (+),
843                       to_date (X_target_jdate, 'J'))
844             AND X_target_year >= nvl (this_one.year_of_life, 0)
845             AND nvl (cur_one.year_of_life, 0) < next_one.year_of_life (+)
846           GROUP BY cur_one.limit, cur_one.year_of_life,
847                    cur_one.start_date, cur_one.end_date
848           HAVING  nvl (cur_one.year_of_life, 0) =
849                           nvl (max (this_one.year_of_life), 0);
850 
851          fazccl_record.t_ceiling_name         := X_target_ceiling_name;
852          fazccl_record.t_jdate                := X_target_jdate;
853          fazccl_record.t_year                 := X_target_year;
854          fazccl_table(fazccl_table.count + 1) := fazccl_record;
855 
856       end if;
857    end if;
858 
859    X_ceiling := fazccl_record.ceiling;
860    return (TRUE);
861 
862 Exception
863    when no_data_found then
864         X_ceiling := 1000000000000.00;
865         return (TRUE);
866    when others then
867         fa_srvr_msg.add_sql_error (calling_fn => 'fa_cache_pkg.fazccl', p_log_level_rec => p_log_level_rec);
868         return (FALSE);
869 
870 end FAZCCL;
871 
872 -----------------------------------------------------------------------------
873 
874 Function fazcbr
875           (X_target_bonus_rule                 varchar2,
876            X_target_year                       number,
877            X_bonus_rate             out NOCOPY number,
878            X_deprn_factor           out NOCOPY number,
879            X_alternate_deprn_factor out NOCOPY number, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
880          return boolean is
881 
882    l_found       boolean;
883    l_count       number;
884 
885 begin <<FAZCBR>>
886 
887    if (nvl(fazcbr_record.t_bonus_rule, 'NULL') = X_target_bonus_rule and
888       fazcbr_record.t_year = X_target_year) then
889       X_bonus_rate := fazcbr_record.bonus_rate;
890       X_deprn_factor := fazcbr_record.deprn_factor;
891       X_alternate_deprn_factor := fazcbr_record.alternate_deprn_factor;
892       return (TRUE);
893    else
894       if fazcbr_table.count = 0 then
895          l_found := FALSE;
896       end if;
897 
898       for i in 1..fazcbr_table.count loop
899 
900          if (fazcbr_table(i).t_bonus_rule = X_target_bonus_rule and
901              fazcbr_table(i).t_year       = X_target_year) then
902             l_count := i;
903             l_found := TRUE;
904             exit;
905          else
906             l_found := FALSE;
907          end if;
908       end loop;
909 
910       if l_found = TRUE then
911          fazcbr_record           := fazcbr_table(l_count);
912       else
913 
914          SELECT bonus_rate,
915                 deprn_factor,
916                 alternate_deprn_factor
917            INTO fazcbr_record.bonus_rate,
918                 fazcbr_record.deprn_factor,
919                 fazcbr_record.alternate_deprn_factor
920            FROM fa_bonus_rates
921           WHERE bonus_rule = X_target_bonus_rule
922             AND X_target_year BETWEEN
923                   start_year AND nvl (end_year, X_target_year);
924 
925          fazcbr_record.t_bonus_rule     := X_target_bonus_rule;
926          fazcbr_record.t_year           := X_target_year;
927          fazcbr_table(fazcbr_table.count + 1):= fazcbr_record;
928 
929       end if;
930    end if;
931 
932    X_bonus_rate := fazcbr_record.bonus_rate;
933    X_deprn_factor := fazcbr_record.deprn_factor;
934    X_alternate_deprn_factor := fazcbr_record.alternate_deprn_factor;
935 
936    return (TRUE);
937 
938 Exception
939    when no_data_found then
940         X_bonus_rate := 0;
941         X_deprn_factor := 0;
942         X_alternate_deprn_factor := 0;
943 
944         return (TRUE);
945    when others then
946         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcbr', p_log_level_rec => p_log_level_rec);
947         return (FALSE);
948 
949 end FAZCBR;
950 
951 -----------------------------------------------------------------------------
952 
953 Function fazccp
954           (X_target_calendar       varchar2,
955            X_target_fy_name        varchar2,
956            X_target_jdate          number,
957            X_period_num     in out NOCOPY number,
958            X_fiscal_year    in out NOCOPY number,
959            X_start_jdate    in out NOCOPY number, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
960 return boolean is
961 
962    x_target_date  date;
963    l_found        boolean;
964    l_count        number;
965 
966 begin <<FAZCCP>>
967 
968    if (fazccp_record.t_calendar = X_target_calendar and
969        fazccp_record.t_fy_name  = X_target_fy_name and
970        fazccp_record.t_jdate    = X_target_jdate) then
971       X_period_num   := fazccp_record.period_num;
972       X_fiscal_year  := fazccp_record.fiscal_year;
973       X_start_jdate  := fazccp_record.start_jdate;
974       return (TRUE);
975    else
976       if fazccp_table.count = 0 then
977          l_found := FALSE;
978       end if;
979 
980       for i in 1..fazccp_table.count loop
981           if (fazccp_table(i).t_calendar = X_target_calendar and
982               fazccp_table(i).t_fy_name  = X_target_fy_name and
983               fazccp_table(i).t_jdate    = X_target_jdate) then
984              l_found := TRUE;
985              l_count := i;
986              exit;
987           else
988              l_found := FALSE;
989           end if;
990 
991       end loop;
992 
993       if l_found = TRUE then
994          fazccp_record  := fazccp_table(l_count);
995       else
996          x_target_date := to_date (to_char (X_target_jdate), 'J');
997 
998          SELECT to_number (to_char (cp.start_date, 'J')),
999                 cp.period_num,
1000                 fy.fiscal_year
1001            INTO fazccp_record.start_jdate,
1002                 fazccp_record.period_num,
1003                 fazccp_record.fiscal_year
1004            FROM fa_calendar_periods cp,
1005                 fa_fiscal_year fy
1006           WHERE fy.fiscal_year_name = X_target_fy_name
1007             AND cp.calendar_type    = X_target_calendar
1008             AND x_target_date       between fy.start_date and fy.end_date
1009             AND cp.start_date       between fy.start_date and fy.end_date
1010             AND cp.end_date         between fy.start_date and fy.end_date
1011             AND x_target_date       between cp.start_date and cp.end_date;
1012 
1013          fazccp_record.t_calendar := X_target_calendar;
1014          fazccp_record.t_fy_name := X_target_fy_name;
1015          fazccp_record.t_jdate := X_target_jdate;
1016          fazccp_table(fazccp_table.count + 1):= fazccp_record;
1017       end if;
1018    end if;
1019 
1020    X_period_num   := fazccp_record.period_num;
1021    X_fiscal_year  := fazccp_record.fiscal_year;
1022    X_start_jdate  := fazccp_record.start_jdate;
1023    return (TRUE);
1024 
1025 exception
1026    when NO_DATA_FOUND then
1027         fa_srvr_msg.add_message(calling_fn => NULL,
1028                         name       => 'FA_CACHE_CALENDAR_PERIODS',
1029                         token1     => 'CALENDAR',
1030                         value1     => X_target_calendar,
1031                         token2     => 'FY_NAME',
1032                         value2     => X_target_fy_name,
1033                         token3     => 'DATE',
1034                         value3     => X_target_date, p_log_level_rec => p_log_level_rec);
1035         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazccp', p_log_level_rec => p_log_level_rec);
1036         return (FALSE);
1037    when others then
1038         fa_srvr_msg.add_sql_error ( calling_fn => 'fa_cache_pkg.fazccp', p_log_level_rec => p_log_level_rec);
1039         return (FALSE);
1040 
1041 end FAZCCP;
1042 
1043 function fazccb
1044           (X_book   in varchar2,
1045            X_cat_id in number, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
1046          return boolean is
1047 
1048    l_found       boolean;
1049    l_count       number;
1050 
1051 begin <<FAZCCB>>
1052 
1053    if (fazccb_record.book_type_code = X_book and
1054        fazccb_record.category_id    = X_cat_id) then
1055       return (TRUE);
1056    else
1057       if fazccb_table.count = 0 then
1058          l_found := FALSE;
1059       end if;
1060 
1061       for i in 1..fazccb_table.count loop
1062 
1063          if (fazccb_table(i).book_type_code = X_book and
1064              fazccb_table(i).category_id    = X_cat_id ) then
1065             l_count := i;
1066             l_found := TRUE;
1067             exit;
1068          else
1069             l_found := FALSE;
1070          end if;
1071 
1072       end loop;
1073 
1074       if l_found = TRUE then
1075          fazccb_record           := fazccb_table(l_count);
1076       else
1077          SELECT *
1078            INTO fazccb_record
1079            FROM fa_category_books
1080           WHERE book_type_code = X_book
1081             AND category_id = X_cat_id;
1082 
1083          fazccb_table(fazccb_table.count + 1):= fazccb_record;
1084 
1085       end if;
1086 
1087    end if;
1088 
1089    return (TRUE);
1090 
1091 exception
1092    when NO_DATA_FOUND then
1093         fa_srvr_msg.add_message(calling_fn => NULL,
1094                         name       => 'FA_CACHE_CATEGORY_BOOKS',
1095                         token1     => 'CATEGORY_ID',
1096                         value1     => X_cat_id,
1097                         token2     => 'BOOK',
1098                         value2     => X_book, p_log_level_rec => p_log_level_rec);
1099         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazccb', p_log_level_rec => p_log_level_rec);
1100         return (FALSE);
1101    when others then
1102         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazccb', p_log_level_rec => p_log_level_rec);
1103         return (FALSE);
1104 
1105 end fazccb;
1106 
1107 --------------------------------------------------------------------------
1108 
1109 Function fazccmt
1110           (X_method                    varchar2,
1111            X_life                      integer, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
1112         return boolean is
1113 
1114    l_found       boolean;
1115    l_count       number;
1116    l_table_name  varchar2(15);
1117 
1118 begin
1119 
1120    if (nvl(fazccmt_record.method_code, '-NULL') = X_method and
1121        nvl(fazccmt_record.life_in_months, -99)  = nvl(X_life, -99)) then
1122       return true;
1123    else
1124 
1125       l_table_name := 'METHODS';
1126 
1127       if fazccmt_table.count = 0 then
1128          l_found := FALSE;
1129       end if;
1130 
1131       for i in 1..fazccmt_table.count loop
1132 
1133          if (fazccmt_table(i).method_code              = X_method and
1134              nvl(fazccmt_table(i).life_in_months, -99) = nvl(X_life, -99)) then
1135             l_count := i;
1136             l_found := TRUE;
1137             exit;
1138          else
1139             l_found := FALSE;
1140          end if;
1141 
1142       end loop;
1143 
1144       if l_found = TRUE then
1145 
1146          fazccmt_record           := fazccmt_table(l_count);
1147 
1148       else
1149 
1150          -- Performance issue.
1151          -- Split into different selects to use index better
1152 
1153          if (X_life is not null and X_life <> 0) then
1154 
1155             SELECT *
1156               INTO fazccmt_record
1157               FROM fa_methods
1158              WHERE method_code = X_method
1159                AND life_in_months = X_life;
1160 
1161          else
1162 
1163             SELECT *
1164               INTO fazccmt_record
1165               FROM fa_methods
1166              WHERE method_code = X_method
1167                AND (life_in_months is null OR
1168                     life_in_months = 0);
1169 
1170          end if;
1171 
1172          if (fazccmt_record.deprn_basis_rule_id is null) then
1173             fazccmt_record.deprn_basis_rule_id := 0;
1174          end if;
1175 
1176          fazccmt_table(fazccmt_table.count + 1) := fazccmt_record;
1177 
1178       end if;
1179    end if;
1180 
1181    -- load fa_formulas if formula based asset
1182    if (fazccmt_record.rate_source_rule = 'FORMULA') then
1183       if (fazccmt_record.method_id = nvl(fazcfor_record.method_id, -99)) then
1184          -- return true;
1185          null; -- keep what is in the fazcfor cache
1186       else
1187          l_table_name := 'FORMULAS';
1188 
1189          if fazcfor_table.count = 0 then
1190             l_found := FALSE;
1191          end if;
1192 
1193          for i in 1..fazcfor_table.count loop
1194             if (fazcfor_table(i).method_id  = fazccmt_record.method_id) then
1195 
1196                l_count := i;
1197                l_found := TRUE;
1198                exit;
1199             else
1200                l_found := FALSE;
1201             end if;
1202          end loop;
1203 
1204          if l_found = TRUE then
1205 
1206             fazcfor_record           := fazcfor_table(l_count);
1207 
1208          else
1209             begin
1210                select *
1211                into   fazcfor_record
1212                from   fa_formulas
1213                where  method_id = fazccmt_record.method_id;
1214 
1215                fazcfor_table(fazcfor_table.count + 1) := fazcfor_record;
1216             exception
1217                when no_data_found then
1218 
1219                   -- For Japan Tax reform, when loading seed formula rates,
1220                   -- the record in fa_methods will exist, but the one in
1221                   -- fa_formulas will not exist.
1222                   fazcfor_record.method_id := null;
1223                   fazcfor_record.formula_actual := null;
1224                   fazcfor_record.formula_displayed := null;
1225                   fazcfor_record.formula_parsed := null;
1226                   fazcfor_record.original_rate := null;
1227                   fazcfor_record.revised_rate := null;
1228                   fazcfor_record.guarantee_rate := null;
1229             end;
1230          end if;
1231       end if;
1232    else
1233       -- Not a formula method, so make sure everything is null
1234       fazcfor_record.method_id := null;
1235       fazcfor_record.formula_actual := null;
1236       fazcfor_record.formula_displayed := null;
1237       fazcfor_record.formula_parsed := null;
1238       fazcfor_record.original_rate := null;
1239       fazcfor_record.revised_rate := null;
1240       fazcfor_record.guarantee_rate := null;
1241    end if;
1242 
1243    -- now find and load the deprn basis rules
1244    if (fazcdbr_record.deprn_basis_rule_id= nvl(fazccmt_record.deprn_basis_rule_id, 0)) then
1245       return true;
1246    else
1247       l_table_name  := 'RULES';
1248 
1249       if fazcdbr_table.count = 0 then
1250          l_found := FALSE;
1251       end if;
1252 
1253       for j in 1..fazcdbr_table.count loop
1254          if fazcdbr_table(j).deprn_basis_rule_id = nvl(fazccmt_record.deprn_basis_rule_id, 0) then
1255             l_count := j;
1256             l_found := TRUE;
1257             exit;
1258          else
1259             l_found := FALSE;
1260          end if;
1261       end loop;
1262 
1263       if l_found = TRUE then
1264          fazcdbr_record := fazcdbr_table(l_count);
1265       else
1266 
1267          if (fazccmt_record.deprn_basis_rule_id = 0) then
1268             fazcdbr_record.deprn_basis_rule_id := 0;
1269             fazcdbr_record.rule_name           := null;
1270             fazcdbr_record.user_rule_name      := null;
1271             fazcdbr_record.rate_source         := null;
1272             fazcdbr_record.deprn_basis         := null;
1273             fazcdbr_record.enabled_flag        := null;
1274             fazcdbr_record.program_name        := null;
1275             fazcdbr_record.polish_rule         :=
1276                               FA_STD_TYPES.FAD_DBR_POLISH_NONE;
1277          else
1278             select deprn_basis_rule_id,
1279                    rule_name,
1280                    user_rule_name,
1281                    last_update_date,
1282                    last_updated_by,
1283                    created_by,
1284                    creation_date,
1285                    last_update_login,
1286                    rate_source,
1287                    deprn_basis,
1288                    enabled_flag,
1289                    program_name,
1290                    description
1291               into fazcdbr_record.deprn_basis_rule_id,
1292                    fazcdbr_record.rule_name,
1293                    fazcdbr_record.user_rule_name,
1294                    fazcdbr_record.last_update_date,
1295                    fazcdbr_record.last_updated_by,
1296                    fazcdbr_record.created_by,
1297                    fazcdbr_record.creation_date,
1298                    fazcdbr_record.last_update_login,
1299                    fazcdbr_record.rate_source,
1300                    fazcdbr_record.deprn_basis,
1301                    fazcdbr_record.enabled_flag,
1302                    fazcdbr_record.program_name,
1303                    fazcdbr_record.description
1304               from fa_deprn_basis_rules
1305              where deprn_basis_rule_id = fazccmt_record.deprn_basis_rule_id;
1306          end if;
1307 
1308          -- Determine the Polish Rule
1309          if (fazcdbr_record.rule_name =
1310             'POLISH 30% WITH A SWITCH TO DECLINING CLASSICAL AND FLAT RATE'
1311          ) then
1312             -- Polish Mechanism 1
1313             fazcdbr_record.polish_rule := FA_STD_TYPES.FAD_DBR_POLISH_1;
1314          elsif (fazcdbr_record.rule_name =
1315             'POLISH 30% WITH A SWITCH TO FLAT RATE'
1316          ) then
1317             -- Polish Mechanism 2
1318             fazcdbr_record.polish_rule :=  FA_STD_TYPES.FAD_DBR_POLISH_2;
1319          elsif (fazcdbr_record.rule_name =
1320             'POLISH DECLINING MODIFIED WITH A SWITCH TO DECLINING CLASSICAL AND FLAT RATE'
1321          ) then
1322             -- Polish Mechanism 3
1323             fazcdbr_record.polish_rule := FA_STD_TYPES.FAD_DBR_POLISH_3;
1324          elsif (fazcdbr_record.rule_name =
1325             'POLISH DECLINING MODIFIED WITH A SWITCH TO FLAT RATE'
1326          ) then
1327             -- Polish Mechanism 4
1328             fazcdbr_record.polish_rule := FA_STD_TYPES.FAD_DBR_POLISH_4;
1329          elsif (fazcdbr_record.rule_name =
1330             'POLISH STANDARD DECLINING WITH A SWITCH TO FLAT RATE'
1331          ) then
1332             -- Polish Mechansism 5
1333             fazcdbr_record.polish_rule := FA_STD_TYPES.FAD_DBR_POLISH_5;
1334          else
1335             -- No Polish Mechanism
1336             fazcdbr_record.polish_rule := FA_STD_TYPES.FAD_DBR_POLISH_NONE;
1337          end if;
1338 
1339          fazcdbr_table(fazcdbr_table.count + 1) := fazcdbr_record;
1340       end if;
1341    end if;
1342 
1343    -- now find and load the deprn basis rule details
1344   if   (fazcdrd_record.deprn_basis_rule_id  = nvl(fazccmt_record.deprn_basis_rule_id, 0))
1345         and fazcdrd_record.rate_source_rule = fazccmt_record.rate_source_rule
1346         and fazcdrd_record.deprn_basis_rule = fazccmt_record.deprn_basis_rule
1347   then
1348     return true;
1349 
1350    else
1351     l_table_name := 'RULE_DETAILS';
1352 
1353     if fazcdrd_table.count =0 then
1354       l_found := FALSE;
1355     end if;
1356 
1357     for k in 1..fazcdrd_table.count loop
1358       if nvl(fazcdrd_table(k).deprn_basis_rule_id,0) = nvl(fazccmt_record.deprn_basis_rule_id, 0)
1359       and fazcdrd_table(k).rate_source_rule = fazccmt_record.rate_source_rule
1360       and fazcdrd_table(k).deprn_basis_rule = fazccmt_record.deprn_basis_rule then
1361         l_count := k;
1362         l_found := TRUE;
1363         exit;
1364       else
1365         l_found := FALSE;
1366       end if;
1367    end loop;
1368 
1369    if l_found = TRUE then
1370      fazcdrd_record := fazcdrd_table(l_count);
1371    else
1372 
1373      if (fazccmt_record.deprn_basis_rule_id = 0) then
1374             -- For FA_DEPRN_RULE_DETAILS
1375        fazcdrd_record.deprn_rule_detail_id        := 0;
1376        fazcdrd_record.deprn_basis_rule_id         := 0;
1377        fazcdrd_record.rule_name                   := null;
1378        fazcdrd_record.rate_source_rule            := null;
1379        fazcdrd_record.deprn_basis_rule            := null;
1380        fazcdrd_record.asset_type                  := null;
1381        fazcdrd_record.period_update_flag          := null;
1382        fazcdrd_record.subtract_ytd_flag           := null;
1383        fazcdrd_record.allow_reduction_rate_flag   := null;
1384        fazcdrd_record.use_eofy_reserve_flag       := null;
1385        fazcdrd_record.use_rsv_after_imp_flag      := null;
1386      else
1387 
1388        select *
1389          into fazcdrd_record
1390          from fa_deprn_rule_details
1391         where deprn_basis_rule_id = fazccmt_record.deprn_basis_rule_id
1392           and rate_source_rule = fazccmt_record.rate_source_rule
1393           and deprn_basis_rule = fazccmt_record.deprn_basis_rule;
1394      end if;
1395 
1396      fazcdrd_table(fazcdrd_table.count + 1) := fazcdrd_record;
1397 
1398    end if; -- End l_found
1399   end if;  -- End FA_DEPRN_RULE_DETAILS
1400 
1401   return (TRUE);
1402 
1403 exception
1404    when NO_DATA_FOUND then
1405         if (l_table_name = 'METHODS')then
1406            fa_srvr_msg.add_message(calling_fn => NULL,
1407                            name       => 'FA_CACHE_METHODS',
1408                            token1     => 'METHOD',
1409                            value1     => X_method,
1410                            token2     => 'LIFE',
1411                            value2     => X_life, p_log_level_rec => p_log_level_rec);
1412         else
1413            fa_srvr_msg.add_message(calling_fn => NULL,
1414                            name       => 'FA_CACHE_DEPRN_BASIS_RULES',
1415                            token1     => 'RULE_ID',
1416                            value1     => fazccmt_record.deprn_basis_rule_id, p_log_level_rec => p_log_level_rec);
1417         end if;
1418 
1419         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazccmt', p_log_level_rec => p_log_level_rec);
1420         return (FALSE);
1421 
1422    when others then
1423         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazccmt', p_log_level_rec => p_log_level_rec);
1424         return (False);
1425 
1426 end FAZCCMT;
1427 
1428 --------------------------------------------------------------
1429 
1430 -- sob_book_type_code
1431 function fazcsob
1432           (X_set_of_books_id   in  number,
1433            X_mrc_sob_type_code out NOCOPY varchar, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
1434          return boolean is
1435 
1436    l_found       boolean;
1437    l_count       number;
1438 
1439 begin
1440 
1441    if (nvl(fazcsob_record.set_of_books_id, -1) = X_set_of_books_id) then
1442       X_mrc_sob_type_code := fazcsob_record.mrc_sob_type_code;
1443       return (TRUE);
1444    else
1445       if fazcsob_table.count = 0 then
1446          l_found := FALSE;
1447       end if;
1448 
1449       for i in 1..fazcsob_table.count loop
1450 
1451          if (fazcsob_table(i).set_of_books_id = X_set_of_books_id) then
1452             l_count := i;
1453             l_found := TRUE;
1454             exit;
1455          else
1456             l_found := FALSE;
1457          end if;
1458 
1459       end loop;
1460 
1461       if l_found = TRUE then
1462          X_mrc_sob_type_code      := fazcsob_table(l_count).mrc_sob_type_code;
1463          fazcsob_record           := fazcsob_table(l_count);
1464       else
1465          SELECT set_of_books_id,
1466                 mrc_sob_type_code
1467            INTO fazcsob_record.set_of_books_id,
1468                 fazcsob_record.mrc_sob_type_code
1469            FROM gl_sets_of_books
1470           WHERE set_of_books_id = X_set_of_books_id;
1471 
1472          fazcsob_table(fazcsob_table.count + 1)    := fazcsob_record;
1473       end if;
1474    end if;
1475 
1476    X_mrc_sob_type_code := fazcsob_record.mrc_sob_type_code;
1477    return (TRUE);
1478 
1479 exception
1480    when NO_DATA_FOUND then
1481         fa_srvr_msg.add_message(calling_fn => NULL,
1482                         name       => 'FA_CACHE_SETS_OF_BOOKS',
1483                         token1     => 'SET_OF_BOOKS_ID',
1484                         value1     => X_set_of_books_id, p_log_level_rec => p_log_level_rec);
1485         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcsob', p_log_level_rec => p_log_level_rec);
1486         return (FALSE);
1487    when others then
1488         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcsob', p_log_level_rec => p_log_level_rec);
1489         return(FALSE);
1490 
1491 end fazcsob;
1492 
1493 -------------------------------------------------------------------
1494 
1495 FUNCTION fazccbd
1496           (X_book    in varchar2,
1497            X_cat_id  in number,
1498            X_jdpis   in number, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
1499          return boolean is
1500 
1501    l_found           boolean;
1502    l_count           number;
1503 
1504 begin <<FAZCCBD>>
1505 
1506    if (fazccbd_record.book_type_code = X_book and
1507        fazccbd_record.category_id    = X_cat_id and
1508        fazccbd_record.start_dpis    <= to_date(X_jdpis, 'J') and
1509        nvl(fazccbd_record.end_dpis, to_date(X_jdpis, 'J')) >=
1510            to_date(X_jdpis, 'J')) then
1511       return (TRUE);
1512    else
1513       if fazccbd_table.count = 0 then
1514          l_found := FALSE;
1515       end if;
1516 
1517       for i in 1..fazccbd_table.count loop
1518 
1519          if (fazccbd_table(i).book_type_code = X_book and
1520              fazccbd_table(i).category_id    = X_cat_id and
1521              fazccbd_table(i).start_dpis      <= to_date(X_jdpis, 'J') and
1522              nvl(fazccbd_table(i).end_dpis, to_date(X_jdpis, 'J')) >=
1523                  to_date(X_jdpis, 'J')) then
1524             l_count := i;
1525             l_found := TRUE;
1526             exit;
1527          else
1528             l_found := FALSE;
1529          end if;
1530       end loop;
1531 
1532       if l_found = TRUE then
1533          fazccbd_record           := fazccbd_table(l_count);
1534       else
1535          -- do not let array get to big.. once it is at the
1536          -- max begin clearing values from the array
1537          if fazccbd_table.count = G_max_array_size then
1538 
1539             -- clear the first record
1540             fazccbd_record.book_type_code := 'NULL';
1541 
1542             -- clear the first member in the table
1543             fazccbd_table.delete(1);
1544 
1545             -- reset values so there is no missing member for future use
1546             l_count := fazccbd_table.count;
1547 
1548             for i in 1..l_count loop
1549                -- copy the next member into the current one
1550                fazccbd_table(i) := fazccbd_table(i+1);
1551             end loop;
1552 
1553             -- delete the last member in the array which is now a duplicate
1554             fazccbd_table.delete(l_count + 1);
1555 
1556          end if;
1557 
1558          SELECT *
1559            INTO fazccbd_record
1560                 FROM fa_category_book_defaults
1561                WHERE book_type_code = X_book
1562                  AND category_id = X_cat_id
1563                  AND to_date (X_jdpis, 'J') BETWEEN
1564                         start_dpis AND
1565                         nvl (end_dpis, to_date (X_jdpis, 'J'));
1566 
1567          fazccbd_table(fazccbd_table.count + 1):= fazccbd_record;
1568 
1569       end if;
1570    end if;
1571 
1572    return (TRUE);
1573 
1574 exception
1575    when NO_DATA_FOUND then
1576         fa_srvr_msg.add_message(calling_fn => NULL,
1577                         name       => 'FA_CACHE_CATEGORY_BOOK_DEF',
1578                         token1     => 'BOOK',
1579                         value1     => X_book,
1580                         token2     => 'CATEGORY_ID',
1581                         value2     => X_cat_id,
1582                         token3     => 'DATE',
1583                         value3     => to_date(X_jdpis, 'J'));
1584         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazccbd', p_log_level_rec => p_log_level_rec);
1585         return (FALSE);
1586 
1587    when others then
1588         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazccbd', p_log_level_rec => p_log_level_rec);
1589         return (FALSE);
1590 
1591 end fazccbd;
1592 
1593 -------------------------------------------------------------------
1594 
1595 FUNCTION fazcat
1596           (X_cat_id  in number, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
1597          return boolean is
1598 
1599    l_found           boolean;
1600    l_count           number;
1601 
1602 begin <<FAZCAT>>
1603 
1604    if (fazcat_record.category_id = X_cat_id) then
1605       return (TRUE);
1606    else
1607       if fazcat_table.count = 0 then
1608          l_found := FALSE;
1609       end if;
1610 
1611       for i in 1..fazcat_table.count loop
1612 
1613          if (fazcat_table(i).category_id = X_cat_id)then
1614             l_count := i;
1615             l_found := TRUE;
1616             exit;
1617          else
1618             l_found := FALSE;
1619          end if;
1620 
1621       end loop;
1622 
1623 
1624       if l_found = TRUE then
1625          fazcat_record           := fazcat_table(l_count);
1626       else
1627          -- do not let array get to big.. once it is at the
1628          -- max begin clearing values from the array
1629          if fazcat_table.count = G_max_array_size then
1630 
1631             -- clear the first record
1632             fazcat_record.category_id := NULL;
1633 
1634             -- clear the first member in the table
1635             fazcat_table.delete(1);
1636 
1637             -- reset values so there is no missing member for future use
1638             l_count := fazcat_table.count;
1639 
1640             for i in 1..l_count loop
1641                 -- copy the next member into the current one
1642                 fazcat_table(i) := fazcat_table(i+1);
1643             end loop;
1644 
1645             -- delete the last member in the array which is now a duplicate
1646             fazcat_table.delete(l_count + 1);
1647 
1648          end if;
1649 
1650          SELECT *
1651            INTO fazcat_record
1652            FROM fa_categories
1653           WHERE category_id = X_cat_id;
1654 
1655          fazcat_table(fazcat_table.count + 1):= fazcat_record;
1656 
1657       end if;
1658    end if;
1659 
1660    return (TRUE);
1661 
1662 exception
1663    when NO_DATA_FOUND then
1664         fa_srvr_msg.add_message(calling_fn => NULL,
1665                         name       => 'FA_CACHE_CATEGORIES',
1666                         token1     => 'CATEGORY',
1667                         value1     => X_cat_id, p_log_level_rec => p_log_level_rec);
1668         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcat', p_log_level_rec => p_log_level_rec);
1669         return (FALSE);
1670 
1671    when others then
1672         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcat', p_log_level_rec => p_log_level_rec);
1673         return (FALSE);
1674 
1675 end fazcat;
1676 
1677 ------------------------------------------------------------------------
1678 
1679 Function fazsys (p_log_level_rec        IN
1680 FA_API_TYPES.log_level_rec_type default null)
1681 return boolean is
1682 
1683 begin <<FAZSYS>>
1684 
1685    if (fazsys_record.company_name is not null) then
1686       return (TRUE);
1687    else
1688       SELECT *
1689         INTO fazsys_record
1690         FROM fa_system_controls;
1691    end if;
1692 
1693    return (TRUE);
1694 
1695 exception
1696    when NO_DATA_FOUND then
1697         fa_srvr_msg.add_message(calling_fn => NULL,
1698                         name       => 'FA_SYSTEM_CONTROLS', p_log_level_rec => p_log_level_rec);
1699         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazsys', p_log_level_rec => p_log_level_rec);
1700         return (FALSE);
1701 
1702    when others then
1703         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazsys', p_log_level_rec => p_log_level_rec);
1704         return (FALSE);
1705 
1706 end FAZSYS;
1707 
1708 
1709 ---------------------------------------------------------------------
1710 
1711 Function fazctbk
1712           (x_corp_book     in     varchar2,
1713            x_asset_type    in     varchar2,
1714            x_tax_book_tbl     out NOCOPY fazctbk_tbl_type, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
1715          return boolean is
1716 
1717    l_tax_rec            fazctbk_pvt_rec_type;
1718    l_found              boolean := FALSE;
1719    l_main_array_count   number  := fazctbk_main_tbl.count;
1720    l_corp_array_count   number  := fazctbk_corp_tbl.count;
1721    l_tax_array_count    number  := fazctbk_tax_tbl.count;
1722 
1723    i number  := 0;
1724 
1725    CURSOR c_tax_books IS
1726      select distribution_source_book,
1727             book_type_code,
1728             nvl(allow_cip_assets_flag, 'NO') allow_cip_assets_flag,
1729             nvl(immediate_copy_flag, 'NO') immediate_copy_flag,
1730             nvl(copy_group_addition_flag, 'N') copy_group_addition_flag
1731        from fa_book_controls
1732       where book_class = 'TAX'
1733         and distribution_source_book = x_corp_book
1734         and date_ineffective is null;
1735 
1736 begin <<FAZCTBK>>
1737 
1738    -- check if values are the same as the last cobination requested
1739 
1740    if ((nvl(fazctbk_last_book_used, 'NULL') = x_corp_book ) and
1741        (nvl(fazctbk_last_type_used, 'NULL') = x_asset_type)) then
1742       x_tax_book_tbl := fazctbk_tax_tbl;
1743       return (TRUE);
1744    else
1745       -- delete the existing return table contents
1746       fazctbk_tax_tbl.delete;
1747       l_tax_array_count := 0;
1748 
1749       -- see if the corp book in question has previously been cached
1750       for i in 1..l_corp_array_count loop
1751 
1752          if (fazctbk_corp_tbl(i) = x_corp_book) then  -- book_type_code
1753              l_found := TRUE;
1754              exit;
1755          else
1756              l_found := FALSE;
1757          end if;
1758 
1759       end loop;
1760 
1761       if l_found then
1762 
1763          -- load the values for this particular asset type and book into return table
1764          for i in 1..fazctbk_main_tbl.count loop
1765             if (((x_asset_type = 'CIP' and
1766                   fazctbk_main_tbl(i).allow_cip_assets_flag = 'YES') or
1767                  (x_asset_type = 'CAPITALIZED' and
1768                   fazctbk_main_tbl(i).immediate_copy_flag = 'YES') or
1769                  (x_asset_type = 'GROUP' and
1770                   fazctbk_main_tbl(i).copy_group_addition_flag = 'Y' and
1771                   fazctbk_main_tbl(i).immediate_copy_flag = 'YES')) and
1772                 (fazctbk_main_tbl(i).corp_book = x_corp_book)) then
1773 
1774                 -- add record to return table
1775                 fazctbk_tax_tbl(l_tax_array_count + 1) := fazctbk_main_tbl(i).tax_book;  -- book_type_code
1776                 l_tax_array_count := l_tax_array_count + 1;
1777              end if;
1778          end loop;
1779 
1780       else
1781 
1782          -- corp book not been cached before so first get each enabled tax book regardless
1783          -- of auto-copy / cip-intax value into the main table
1784 
1785          for c_rec in c_tax_books loop
1786             -- populate the tax record
1787 
1788             l_tax_rec.corp_book                := c_rec.distribution_source_book;
1789             l_tax_rec.tax_book                 := c_rec.book_type_code;
1790             l_tax_rec.allow_cip_assets_flag    := c_rec.allow_cip_assets_flag;
1791             l_tax_rec.immediate_copy_flag      := c_rec.immediate_copy_flag;
1792             l_tax_rec.copy_group_addition_flag := c_rec.copy_group_addition_flag;
1793 
1794             -- add record to the main association table
1795             fazctbk_main_tbl(l_main_array_count + 1) := l_tax_rec;
1796             l_main_array_count := l_main_array_count + 1;
1797          end loop;
1798 
1799          -- add the corp book to the array of corp book to indicate it's been processed
1800          fazctbk_corp_tbl(l_corp_array_count + 1) := x_corp_book;
1801          l_corp_array_count := l_corp_array_count + 1;
1802 
1803 
1804          -- load the values for this particular asset type and book into return table
1805          for i in 1..fazctbk_main_tbl.count loop
1806             if (((x_asset_type = 'CIP' and
1807                   fazctbk_main_tbl(i).allow_cip_assets_flag = 'YES') or
1808                  (x_asset_type = 'CAPITALIZED' and
1809                   fazctbk_main_tbl(i).immediate_copy_flag = 'YES') or
1810                  (x_asset_type = 'GROUP' and
1811                   fazctbk_main_tbl(i).copy_group_addition_flag = 'Y' and
1812                   fazctbk_main_tbl(i).immediate_copy_flag = 'YES')) and
1813                 (fazctbk_main_tbl(i).corp_book = x_corp_book)) then
1814                  -- add record to return table
1815                 fazctbk_tax_tbl(l_tax_array_count + 1) := fazctbk_main_tbl(i).tax_book;
1816                 l_tax_array_count := l_tax_array_count + 1;
1817             end if;
1818          end loop;
1819 
1820       end if;
1821 
1822       fazctbk_last_book_used := x_corp_book;
1823       fazctbk_last_type_used := x_asset_type;
1824 
1825    end if;
1826 
1827    -- set the return table to the new loaded one
1828    x_tax_book_tbl := fazctbk_tax_tbl;
1829    return (TRUE);
1830 
1831 exception
1832    when NO_DATA_FOUND then
1833         fa_srvr_msg.add_message(calling_fn => NULL,
1834                         name       => 'FA_CACHE_BOOK_CONTROLS',
1835                         token1     => 'BOOK',
1836                         value1     => X_corp_book, p_log_level_rec => p_log_level_rec);
1837         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazctbk', p_log_level_rec => p_log_level_rec);
1838         return (FALSE);
1839 
1840    when others then
1841         fa_srvr_msg.add_sql_error (calling_fn => 'fa_cache_pkg.fazctbk', p_log_level_rec => p_log_level_rec);
1842         return (FALSE);
1843 
1844 end fazctbk;
1845 
1846 
1847 ---------------------------------------------------------------------
1848 
1849 Function fazcrsob
1850           (x_book_type_code     in     varchar2,
1851            x_sob_tbl               out NOCOPY fazcrsob_sob_tbl_type, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
1852          return boolean is
1853 
1854    l_sob_rec            fazcrsob_pvt_rec_type;
1855    l_found              boolean;
1856    l_main_array_count   number  := fazcrsob_main_tbl.count;
1857    l_book_array_count   number  := fazcrsob_book_tbl.count;
1858    l_sob_array_count    number  := fazcrsob_sob_tbl.count;
1859 
1860    i number  := 0;
1861 
1862    CURSOR r_sob_id is
1863    SELECT set_of_books_id
1864      FROM fa_mc_book_controls
1865     WHERE book_type_code          = x_book_type_code
1866       AND enabled_flag            = 'Y'
1867       AND mrc_converted_flag      = 'Y';
1868 
1869 
1870 begin <<FAZCRSOB>>
1871 
1872    -- check if values are the same as the last cobination requested
1873 
1874    if (nvl(fazcrsob_last_book_used, 'NULL') = x_book_type_code) then
1875       -- set the return table to the new loaded one
1876       x_sob_tbl := fazcrsob_sob_tbl;
1877    else
1878       -- delete the existing return table contents
1879       fazcrsob_sob_tbl.delete;
1880       l_sob_array_count := 0;
1881 
1882       -- see if the book in question has previously been cached
1883       for i in 1..l_book_array_count loop
1884 
1885           if (fazcrsob_book_tbl(i) = x_book_type_code) then
1886               l_found := TRUE;
1887               exit;
1888           else
1889               l_found := FALSE;
1890           end if;
1891 
1892       end loop;
1893 
1894       if l_found then
1895 
1896          -- load the reporting sobs into the return table
1897          for i in 1..fazcrsob_main_tbl.count loop
1898             if (fazcrsob_main_tbl(i).book_type_code = x_book_type_code) then
1899 
1900                -- add record to return table
1901                fazcrsob_sob_tbl(l_sob_array_count + 1) := fazcrsob_main_tbl(i).set_of_books_id;
1902                l_sob_array_count := l_sob_array_count + 1;
1903             end if;
1904          end loop;
1905 
1906       else
1907 
1908          -- book has not been cached before so first get each enabled
1909          -- reporting book that is enabled and converted
1910 
1911          for c_sob_id in r_sob_id loop
1912             -- populate the tax record
1913             l_sob_rec.book_type_code   := x_book_type_code;
1914             l_sob_rec.set_of_books_id  := c_sob_id.set_of_books_id;
1915 
1916             -- add record to the main association table
1917             fazcrsob_main_tbl(l_main_array_count + 1) := l_sob_rec;
1918             l_main_array_count := l_main_array_count + 1;
1919          end loop;
1920 
1921          -- add the book to the array of books to indicate it's been processed
1922          fazcrsob_book_tbl(l_book_array_count + 1) := x_book_type_code;
1923          l_book_array_count := l_book_array_count + 1;
1924 
1925 
1926          -- load the values for this particular asset type and book into return table
1927          for i in 1..fazcrsob_main_tbl.count loop
1928             if (fazcrsob_main_tbl(i).book_type_code = x_book_type_code) then
1929 
1930                -- add record to return table
1931                fazcrsob_sob_tbl(l_sob_array_count + 1) := fazcrsob_main_tbl(i).set_of_books_id;
1932                l_sob_array_count := l_sob_array_count + 1;
1933             end if;
1934          end loop;
1935 
1936       end if;
1937 
1938       fazcrsob_last_book_used := x_book_type_code;
1939 
1940    end if;
1941 
1942    -- set the return table to the new loaded one
1943    x_sob_tbl := fazcrsob_sob_tbl;
1944 
1945    return (TRUE);
1946 
1947 exception
1948    when others then
1949         fa_srvr_msg.add_sql_error (calling_fn => 'fa_cache_pkg.fazcrsob', p_log_level_rec => p_log_level_rec);
1950         return (FALSE);
1951 
1952 end fazcrsob;
1953 
1954 -----------------------------------------------------------------------------
1955 
1956 Function fazccvt
1957           (x_prorate_convention_code in  varchar2,
1958            x_fiscal_year_name        in  varchar2, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
1959          return boolean is
1960 
1961    l_found       boolean;
1962    l_count       number;
1963 
1964 begin
1965 
1966    if (nvl(fazccvt_record.prorate_convention_code, 'NULL') = X_prorate_convention_code and
1967        nvl(fazccvt_record.fiscal_year_name, 'NULL') = X_fiscal_year_name) then
1968       return (TRUE);
1969    else
1970       if fazccvt_table.count = 0 then
1971          l_found := FALSE;
1972       end if;
1973 
1974       for i in 1..fazccvt_table.count loop
1975 
1976          if (fazccvt_table(i).prorate_convention_code = X_prorate_convention_code and
1977              fazccvt_table(i).fiscal_year_name        = X_fiscal_year_name) then
1978             l_count := i;
1979             l_found := TRUE;
1980             exit;
1981          else
1982             l_found := FALSE;
1983          end if;
1984 
1985       end loop;
1986 
1987       if l_found = TRUE then
1988          fazccvt_record           := fazccvt_table(l_count);
1989       else
1990          -- do not let array get to big.. once it is at the
1991          -- max begin clearing values from the array
1992          if fazccvt_table.count = G_max_array_size then
1993 
1994             -- clear the first record
1995             fazccvt_record.fiscal_year_name := 'NULL';
1996 
1997             -- clear the first member in the table
1998             fazccvt_table.delete(1);
1999 
2000             -- reset values so there is no missing member for future use
2001             l_count := fazccvt_table.count;
2002 
2003             for i in 1..l_count loop
2004                -- copy the next member into the current one
2005                fazccvt_table(i) := fazccvt_table(i+1);
2006             end loop;
2007 
2008             -- delete the last member in the array which is now a duplicate
2009             fazccvt_table.delete(l_count + 1);
2010 
2011          end if;
2012 
2013          SELECT *
2014            INTO fazccvt_record
2015            FROM fa_convention_types
2016           WHERE prorate_convention_code = X_prorate_convention_code
2017             AND fiscal_year_name = X_fiscal_year_name;
2018 
2019          fazccvt_table(fazccvt_table.count + 1):= fazccvt_record;
2020      end if;
2021   end if;
2022 
2023   return (TRUE);
2024 
2025 exception
2026    when NO_DATA_FOUND then
2027         fa_srvr_msg.add_message(calling_fn => NULL,
2028                         name       => 'FA_CACHE_CONVENTION_TYPES',
2029                         token1     => 'CONVENTION',
2030                         value1     => X_prorate_convention_code,
2031                         token2     => 'FISCAL_YEAR_NAME',
2032                         value2     => X_fiscal_year_name, p_log_level_rec => p_log_level_rec);
2033         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazccvt', p_log_level_rec => p_log_level_rec);
2034         return (FALSE);
2035    when others then
2036         fa_srvr_msg.add_sql_error (
2037            calling_fn => 'fa_cache_pkg.fazccvt', p_log_level_rec => p_log_level_rec);
2038         return (FALSE);
2039 end fazccvt;
2040 
2041 -----------------------------------------------------------------------------
2042 
2043 Function fazcfy
2044           (x_fiscal_year_name in varchar2,
2045            x_fiscal_year      in number, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
2046          return boolean is
2047 
2048    l_found       boolean;
2049    l_count       number;
2050 
2051 begin
2052 
2053 
2054    if (nvl(fazcfy_record.fiscal_year_name, 'NULL') = X_fiscal_year_name and
2055        nvl(fazcfy_record.fiscal_year,      -99)    = X_fiscal_year) then
2056       return (TRUE);
2057    else
2058       if fazcfy_table.count = 0 then
2059          l_found := FALSE;
2060       end if;
2061 
2062       for i in 1..fazcfy_table.count loop
2063          if (fazcfy_table(i).fiscal_year_name = X_fiscal_year_name and
2064              fazcfy_table(i).fiscal_year      = X_fiscal_year) then
2065             l_count := i;
2066             l_found := TRUE;
2067             exit;
2068          else
2069             l_found := FALSE;
2070          end if;
2071 
2072       end loop;
2073 
2074       if l_found = TRUE then
2075          fazcfy_record           := fazcfy_table(l_count);
2076       else
2077          -- do not let array get to big.. once it is at the
2078          -- max begin clearing values from the array
2079          if fazcfy_table.count  = G_max_array_size then
2080 
2081             -- clear the first record
2082             fazcfy_record.fiscal_year_name := 'NULL';
2083 
2084             -- clear the first member in the table
2085             fazcfy_table.delete(1);
2086 
2087             -- reset values so there is no missing member for future use
2088             l_count := fazcfy_table.count;
2089 
2090             for i in 1..l_count loop
2091                -- copy the next member into the current one
2092                fazcfy_table(i) := fazcfy_table(i+1);
2093             end loop;
2094 
2095             -- delete the last member in the array which is now a duplicate
2096             fazcfy_table.delete(l_count + 1);
2097 
2098          end if;
2099 
2100          SELECT *
2101            INTO fazcfy_record
2102            FROM fa_fiscal_year
2103           WHERE fiscal_year_name = X_fiscal_year_name
2104             AND fiscal_year      = X_fiscal_year;
2105 
2106          fazcfy_table(fazcfy_table.count + 1):= fazcfy_record;
2107 
2108       end if;
2109    end if;
2110 
2111    return (TRUE);
2112 
2113 exception
2114    when NO_DATA_FOUND then
2115         fa_srvr_msg.add_message(calling_fn => NULL,
2116                         name       => 'FA_CACHE_FISCAL_YEARS',
2117                         token1     => 'FY_NAME',
2118                         value1     => X_fiscal_year_name,
2119                         token2     => 'FY',
2120                         value2     => X_fiscal_year, p_log_level_rec => p_log_level_rec);
2121         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcfy', p_log_level_rec => p_log_level_rec);
2122         return (FALSE);
2123 
2124    when others then
2125         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcfy', p_log_level_rec => p_log_level_rec);
2126         return (FALSE);
2127 end fazcfy;
2128 
2129 -----------------------------------------------------------------------------
2130 
2131 Function fazcdp
2132           (x_book_type_code  in  varchar2,
2133            x_period_counter  in  number   default null,
2134            x_effective_date  in  date     default null, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
2135          return boolean is
2136 
2137    l_found       boolean;
2138    l_count       number;
2139 
2140 begin
2141 
2142    if ((nvl(fazcdp_record.book_type_code, 'NULL') = X_book_type_code) and
2143        (((X_period_counter is not null) and
2144          (nvl(fazcdp_record.period_counter, -99)   = X_period_counter)) or
2145         ((x_effective_date is not null) and
2146          (fazcdp_record.period_open_date                <= x_effective_date) and
2147          (nvl(fazcdp_record.period_close_date, sysdate) >= x_effective_date)) or
2148         (X_period_counter is null and
2149          x_effective_date is null and
2150          fazcdp_record.period_close_date is null))) then
2151       null;
2152    else
2153       if fazcdp_table.count = 0 then
2154          l_found := FALSE;
2155       end if;
2156 
2157       for i in 1..fazcdp_table.count loop
2158 
2159          if ((fazcdp_table(i).book_type_code  = X_book_type_code) and
2160              ((X_period_counter is not null and
2161                fazcdp_table(i).period_counter = X_period_counter) or
2162               (x_effective_date is not null and
2163                (fazcdp_table(i).period_open_date                <= x_effective_date) and
2164                (nvl(fazcdp_table(i).period_close_date, sysdate) >= x_effective_date)) or
2165               (X_period_counter is null and
2166                x_effective_date is null and
2167                fazcdp_table(i).period_close_date is null))) then
2168             l_count := i;
2169             l_found := TRUE;
2170             exit;
2171          else
2172             l_found := FALSE;
2173          end if;
2174 
2175       end loop;
2176 
2177       if l_found = TRUE then
2178          fazcdp_record           := fazcdp_table(l_count);
2179          fazcdp_index            := l_count;
2180       else
2181          -- do not let array get to big.. once it is at the
2182          -- max begin clearing values from the array
2183          if fazcdp_table.count = G_max_array_size then
2184 
2185             -- clear the first record
2186             fazcdp_record.book_type_code := 'NULL';
2187             fazcdp_record.period_counter := NULL;
2188 
2189             -- clear the first member in the table
2190             fazcdp_table.delete(1);
2191 
2192             -- reset values so there is no missing member for future use
2193             l_count := fazcdp_table.count;
2194 
2195             for i in 1..l_count loop
2196                -- copy the next member into the current one
2197                fazcdp_table(i) := fazcdp_table(i+1);
2198             end loop;
2199 
2200             -- delete the last member in the array which is now a duplicate
2201             fazcdp_table.delete(l_count + 1);
2202 
2203          end if;
2204 
2205          if X_period_counter is not null then
2206             SELECT book_type_code,
2207                    period_name,
2208                    period_counter,
2209                    fiscal_year,
2210                    period_num,
2211                    period_open_date,
2212                    period_close_date,
2213                    calendar_period_open_date,
2214                    calendar_period_close_date,
2215                    deprn_run
2216               INTO fazcdp_record
2217               FROM fa_deprn_periods
2218              WHERE book_type_code = X_book_type_code
2219                AND period_counter = X_period_counter;
2220          elsif X_effective_date is not null then
2221             SELECT book_type_code,
2222                    period_name,
2223                    period_counter,
2224                    fiscal_year,
2225                    period_num,
2226                    period_open_date,
2227                    period_close_date,
2228                    calendar_period_open_date,
2229                    calendar_period_close_date,
2230                    deprn_run
2231               INTO fazcdp_record
2232               FROM fa_deprn_periods
2233              WHERE book_type_code = X_book_type_code
2234                AND x_effective_date between
2235                        period_open_date and nvl(period_close_date, sysdate);
2236          else
2237             SELECT book_type_code,
2238                    period_name,
2239                    period_counter,
2240                    fiscal_year,
2241                    period_num,
2242                    period_open_date,
2243                    period_close_date,
2244                    calendar_period_open_date,
2245                    calendar_period_close_date,
2246                    deprn_run
2247               INTO fazcdp_record
2248               FROM fa_deprn_periods
2249              WHERE book_type_code = X_book_type_code
2250                AND period_close_date is null;
2251          end if;
2252 
2253          fazcdp_table(fazcdp_table.count + 1):= fazcdp_record;
2254          fazcdp_index                        := fazcdp_table.count;
2255 
2256       end if;
2257    end if;
2258 
2259    return (TRUE);
2260 
2261 exception
2262    when NO_DATA_FOUND then
2263         fa_srvr_msg.add_message(calling_fn => NULL,
2264                         name       => 'FA_CACHE_DEPRN_PERIODS',
2265                         token1     => 'BOOK',
2266                         value1     => X_book_type_code,
2267                         token2     => 'PERIOD_COUNTER',
2268                         value2     => X_period_counter,
2269                         token3     => 'DATE',
2270                         value3     => X_effective_date, p_log_level_rec => p_log_level_rec);
2271         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcdp', p_log_level_rec => p_log_level_rec);
2272         return (FALSE);
2273 
2274    when others then
2275         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcdp', p_log_level_rec => p_log_level_rec);
2276         return (FALSE);
2277 end fazcdp;
2278 
2279 -----------------------------------------------------------------------------
2280 
2281 Function fazcdp_clr
2282           (X_book in varchar2, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
2283          return boolean is
2284 
2285    l_count   number;
2286 
2287 BEGIN <<fazcdp_clr>>
2288 
2289    -- clear the record
2290    fazcdp_record.book_type_code := 'NULL';
2291    fazcdp_record.period_counter := NULL;
2292 
2293    -- clear the member in the table. since the cache should always
2294    -- be called before doing this (i.e. faxcps) we know the global
2295    -- index variable will have the correct index from fazcdp
2296 
2297    fazcdp_table.delete(fazcdp_index);
2298 
2299    -- reset the values so there is no missing member for future use
2300    l_count := fazcdp_table.count;
2301 
2302    for i in fazcdp_index..l_count loop
2303        -- copy the next member into the current one
2304        fazcdp_table(i) := fazcdp_table(i+1);
2305    end loop;
2306 
2307    -- delete the last member in the array which is now a duplicate
2308    fazcdp_table.delete(l_count + 1);
2309 
2310    return TRUE;
2311 
2312 exception
2313    when others then
2314         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcdp_clr', p_log_level_rec => p_log_level_rec);
2315         return (FALSE);
2316 
2317 END fazcdp_clr;
2318 
2319 -----------------------------------------------------------------------------
2320 
2321 Function fazprof return boolean IS
2322 
2323    l_fa_crl_enabled                 varchar2(3);
2324    l_fa_print_debug                 varchar2(3);
2325    l_fa_use_threshold               varchar2(3);
2326    l_fa_gen_expense_account         varchar2(3);
2327    l_fa_pregen_asset_account        varchar2(3);
2328    l_fa_pregen_book_account         varchar2(3);
2329    l_fa_pregen_cat_account          varchar2(3);
2330    l_fa_mcp_all_cost_adj            varchar2(3);
2331    l_fa_deprn_override_enabled      varchar2(3);
2332    l_fa_deprn_basis_enabled         varchar2(3);
2333    l_fa_batch_size                  varchar2(15);
2334    l_fa_custom_gen_ccid             varchar2(3);
2335 
2336    fazprof_err                      exception;
2337 
2338 BEGIN
2339 
2340    if not fa_profile_init then
2341 
2342       -- load profiles
2343       fnd_profile.get('FA_DEBUG_FILE', fa_debug_file);
2344       fnd_profile.get('FA_LARGE_ROLLBACK_SEGMENT', fa_large_rollback);
2345       fnd_profile.get('FA_ANNUAL_ROUND', fa_annual_round );
2346 
2347       fnd_profile.get('CRL-FA ENABLED', l_fa_crl_enabled);
2348       fnd_profile.get('PRINT_DEBUG', l_fa_print_debug);
2349       fnd_profile.get('FA_USE_THRESHOLD', l_fa_use_threshold);
2350       fnd_profile.get('FA_GEN_EXPENSE_ACCOUNT', l_fa_gen_expense_account);
2351       fnd_profile.get('FA_PREGEN_ASSET_ACCOUNT', l_fa_pregen_asset_account);
2352       fnd_profile.get('FA_PREGEN_BOOK_ACCOUNT', l_fa_pregen_book_account);
2353       fnd_profile.get('FA_PREGEN_CAT_ACCOUNT', l_fa_pregen_cat_account );
2354       fnd_profile.get('FA_MCP_ALL_COST_ADJ', l_fa_mcp_all_cost_adj);
2355       fnd_profile.get('FA_DEPRN_OVERRIDE_ENABLED', l_fa_deprn_override_enabled);
2356       fnd_profile.get('FA_ENABLED_DEPRN_BASIS_FORMULA', l_fa_deprn_basis_enabled);
2357 
2358       fnd_profile.get('FA_BATCH_SIZE', l_fa_batch_size);
2359       fnd_profile.get('FA_CUSTOM_GEN_CCID', l_fa_custom_gen_ccid);
2360 
2361       if (nvl(l_fa_crl_enabled, 'N') = 'Y') then
2362          fa_crl_enabled := TRUE;
2363       else
2364          fa_crl_enabled := FALSE;
2365       end if;
2366 
2367       if (nvl(l_fa_print_debug, 'N') = 'Y') then
2368          fa_print_debug := TRUE;
2369       else
2370          fa_print_debug := FALSE;
2371       end if;
2372 
2373       if (nvl(l_fa_use_threshold, 'N') = 'Y') then
2374          fa_use_threshold := TRUE;
2375       else
2376          fa_use_threshold := FALSE;
2377       end if;
2378 
2379       if (nvl(l_fa_gen_expense_account, 'N') = 'Y') then
2380          fa_gen_expense_account := TRUE;
2381       else
2382          fa_gen_expense_account := FALSE;
2383       end if;
2384 
2385       if (nvl(l_fa_pregen_asset_account, 'Y') = 'Y') then
2386          fa_pregen_asset_account := TRUE;
2387       else
2388          fa_pregen_asset_account := FALSE;
2389       end if;
2390 
2391       if (nvl(l_fa_pregen_book_account, 'Y') = 'Y') then
2392          fa_pregen_book_account := TRUE;
2393       else
2394          fa_pregen_book_account := FALSE;
2395       end if;
2396 
2397       if (nvl(l_fa_pregen_cat_account, 'Y') = 'Y') then
2398          fa_pregen_cat_account := TRUE;
2399       else
2400          fa_pregen_cat_account := FALSE;
2401       end if;
2402 
2403       if (nvl(l_fa_mcp_all_cost_adj, 'N') = 'Y') then
2404          fa_mcp_all_cost_adj := TRUE;
2405       else
2406          fa_mcp_all_cost_adj := FALSE;
2407       end if;
2408 
2409       if (nvl(l_fa_deprn_override_enabled, 'N') = 'Y') then
2410          fa_deprn_override_enabled := TRUE;
2411       else
2412          fa_deprn_override_enabled := FALSE;
2413       end if;
2414 
2415       if (nvl(l_fa_deprn_basis_enabled, 'N') = 'Y') then
2416          fa_enabled_deprn_basis_formula := TRUE;
2417       else
2418          fa_enabled_deprn_basis_formula := FALSE;
2419       end if;
2420 
2421       if (nvl(l_fa_custom_gen_ccid, 'N') = 'Y') then
2422          fa_custom_gen_ccid := TRUE;
2423       else
2424          fa_custom_gen_ccid := FALSE;
2425       end if;
2426 
2427       begin
2428          fa_batch_size  := to_number(nvl(l_fa_batch_size, '200'));
2429       exception
2430         when others then
2431           fa_batch_size  := 200;
2432       end;
2433 
2434       -- proactively load the applications release
2435       if not fazarel then
2436          raise fazprof_err;
2437       end if;
2438 
2439       fa_profile_init := true;
2440 
2441    end if;
2442 
2443    return true;
2444 
2445 EXCEPTION
2446    WHEN fazprof_err then
2447         fa_srvr_msg.add_message(calling_fn => 'fa_cache_pkg.fazprof');
2448         return (FALSE);
2449 
2450    WHEN others then
2451         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazprof');
2452         return (FALSE);
2453 
2454 END fazprof;
2455 
2456 -----------------------------------------------------------------------------
2457 
2458 Function fazcsgr(
2459      X_super_group_id  in  number,
2460      X_book_type_code  in  varchar2,
2461      X_period_counter  in  number, p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
2462 return boolean is
2463 
2464    CURSOR c_get_super_group_rules is
2465          select super_group_id,
2466                 book_type_code,
2467                 start_period_counter,
2468                 end_period_counter,
2469                 deprn_method_code,
2470                 basic_rate,
2471                 adjusted_rate,
2472                 percent_salvage_value
2473          from   fa_super_group_rules
2474          where  super_group_id = X_super_group_id
2475          and    book_type_code = X_book_type_code
2476          and    X_period_counter between start_period_counter
2477                                      and nvl(end_period_counter, X_period_counter)
2478          and    date_ineffective is null;
2479 
2480    CURSOR c_get_init_super_group_rules is
2481          select super_group_id,
2482                 book_type_code,
2483                 0,
2484                 start_period_counter -1,
2485                 deprn_method_code,
2486                 0,
2487                 0,
2488                 1
2489          from   fa_super_group_rules
2490          where  super_group_id = X_super_group_id
2491          and    book_type_code = X_book_type_code
2492          and    date_ineffective is null
2493          order by start_period_counter;
2494 
2495    l_found       boolean;
2496    l_count       number;
2497 
2498 begin
2499    if (fazcsgr_record.book_type_code = X_book_type_code and
2500        fazcsgr_record.super_group_id    = X_super_group_id and
2501        X_period_counter >= fazcsgr_record.start_period_counter and
2502        X_period_counter <= nvl(fazcsgr_record.end_period_counter, X_period_counter)) then
2503       return (TRUE);
2504    else
2505       if fazcsgr_table.count = 0 then
2506          l_found := FALSE;
2507       end if;
2508 
2509       for i in 1..fazcsgr_table.count loop
2510 
2511          if (fazcsgr_table(i).book_type_code = X_book_type_code and
2512              fazcsgr_table(i).super_group_id = X_super_group_id and
2513              X_period_counter >= fazcsgr_table(i).start_period_counter and
2514              X_period_counter <= nvl(fazcsgr_table(i).end_period_counter, X_period_counter)) then
2515             l_count := i;
2516             l_found := TRUE;
2517             exit;
2518          else
2519             l_found := FALSE;
2520          end if;
2521 
2522       end loop;
2523 
2524       if l_found = TRUE then
2525          fazcsgr_record           := fazcsgr_table(l_count);
2526       else
2527          -- do not let array get to big.. once it is at the
2528          -- max begin clearing values from the array
2529          if fazcsgr_table.count = G_max_array_size then
2530 
2531             -- clear the first record
2532             fazcsgr_record.book_type_code := 'NULL';
2533 
2534             -- clear the first member in the table
2535             fazcsgr_table.delete(1);
2536 
2537             -- reset values so there is no missing member for future use
2538             l_count := fazcsgr_table.count;
2539 
2540             for i in 1..l_count loop
2541                -- copy the next member into the current one
2542                fazcsgr_table(i) := fazcsgr_table(i+1);
2543             end loop;
2544 
2545             -- delete the last member in the array which is now a duplicate
2546             fazcsgr_table.delete(l_count + 1);
2547 
2548          end if;
2549 
2550          OPEN c_get_super_group_rules;
2551          FETCH c_get_super_group_rules
2552              INTO fazcsgr_record.super_group_id,
2553                   fazcsgr_record.book_type_code,
2554                   fazcsgr_record.start_period_counter,
2555                   fazcsgr_record.end_period_counter,
2556                   fazcsgr_record.deprn_method_code,
2557                   fazcsgr_record.basic_rate,
2558                   fazcsgr_record.adjusted_rate,
2559                   fazcsgr_record.percent_salvage_value;
2560 
2561          -- Bug4037112
2562          -- Added to handle the case that super group rule
2563          -- is not available. Earlier periods
2564          if c_get_super_group_rules%NOTFOUND then
2565             OPEN c_get_init_super_group_rules;
2566             FETCH c_get_init_super_group_rules
2567                 INTO fazcsgr_record.super_group_id,
2568                      fazcsgr_record.book_type_code,
2569                      fazcsgr_record.start_period_counter,
2570                      fazcsgr_record.end_period_counter,
2571                      fazcsgr_record.deprn_method_code,
2572                      fazcsgr_record.basic_rate,
2573                      fazcsgr_record.adjusted_rate,
2574                      fazcsgr_record.percent_salvage_value;
2575                CLOSE c_get_init_super_group_rules;
2576          end if;
2577 
2578          CLOSE c_get_super_group_rules;
2579 
2580          fazcsgr_table(fazcsgr_table.count + 1):= fazcsgr_record;
2581 
2582       end if;
2583    end if;
2584 
2585    return (TRUE);
2586 
2587 exception
2588    when NO_DATA_FOUND then
2589         fa_srvr_msg.add_message(calling_fn => NULL,
2590                         name       => 'FA_CACHE_SUPER_GROUP_RULES',
2591                         token1     => 'BOOK',
2592                         value1     => X_book_type_code,
2593                         token2     => 'PERIOD_COUNTER',
2594                         value2     => X_period_counter, p_log_level_rec => p_log_level_rec);
2595         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcsgr', p_log_level_rec => p_log_level_rec);
2596         return (FALSE);
2597 
2598    when others then
2599         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazcsgr', p_log_level_rec => p_log_level_rec);
2600         return (FALSE);
2601 end fazcsgr;
2602 
2603 -----------------------------------------------------------------------------
2604 
2605 Function fazarel return boolean is
2606 
2607    l_release_name         varchar2(30);
2608    l_other_release_info   varchar2(2000);
2609    fazarel_err            exception;
2610 
2611 begin <<FAZAREL>>
2612 
2613    if (fazarel_release = 999999999) then
2614 
2615       if not FND_RELEASE.get_release (l_release_name, l_other_release_info) then
2616          null;
2617       end if;
2618 
2619       fazarel_release_name := l_release_name;-- Bug 10636707 - Character date international calendar support
2620 
2621       if (substrb(l_release_name, 1, 2) = '11') then
2622          fazarel_release := 11;
2623       elsif (substrb(l_release_name, 1, 2) = '12') then
2624          fazarel_release := 12;
2625       else
2626          -- unknown release
2627          raise fazarel_err;
2628       end if;
2629    end if;
2630 
2631    return (TRUE);
2632 
2633 Exception
2634    when fazarel_err then
2635         fa_srvr_msg.add_message(calling_fn => 'fa_cache_pkg.fazarel');
2636         return (FALSE);
2637 
2638    when others then
2639         fa_srvr_msg.add_sql_error(calling_fn => 'fa_cache_pkg.fazarel');
2640         return (FALSE);
2641 
2642 end FAZAREL;
2643 
2644 END FA_CACHE_PKG;