DBA Data[Home] [Help]

APPS.FA_RETIREMENT_PVT SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 66

    select adjustment_type,
           debit_credit_flag,
           adjustment_amount,
           period_counter_adjusted,
           period_counter_created
    from   fa_adjustments
    where  asset_id = l_asset_hdr_rec.asset_id
    and    book_type_code = l_asset_hdr_rec.book_type_code
    and    transaction_header_id = l_trans_rec.transaction_header_id
    and    source_type_code = 'DEPRECIATION';
Line: 78

    select 'Y'
    from   fa_books
    where  book_type_code = p_asset_hdr_rec.book_type_code
    and    group_asset_id = p_asset_fin_rec.group_asset_id
    and    period_counter_fully_retired is null
    and    transaction_header_id_out is null
    /*bug#16426081*/
    and    not(
               tracking_method = 'CALCULATE'
               and member_rollup_flag='Y'
               and cost=0
               and adjusted_cost <> 0
              );
Line: 93

    select fa_transaction_headers_s.nextval
    from   dual;
Line: 97

    select transaction_header_id
    from   fa_transaction_headers
    where  asset_id = p_asset_fin_rec.group_asset_id
    and    book_type_code = p_asset_hdr_rec.book_type_code
    and    member_transaction_header_id = p_trans_rec.transaction_header_id;
Line: 192

   l_trans_rec.who_info.last_update_date := p_trans_rec.who_info.last_update_date;
Line: 193

   l_trans_rec.who_info.last_updated_by := p_trans_rec.who_info.last_updated_by;
Line: 194

   l_trans_rec.who_info.last_update_login := p_trans_rec.who_info.last_update_login;
Line: 397

         l_adj.selection_retid         := 0;
Line: 398

         l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 401

         l_adj.last_update_date        := p_trans_rec.who_info.last_update_date;
Line: 419

                             p_trans_rec.who_info.last_update_date,
                             p_trans_rec.who_info.last_updated_by,
                             p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
            raise ret_err;
Line: 435

                             p_trans_rec.who_info.last_update_date,
                             p_trans_rec.who_info.last_updated_by,
                             p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
            raise ret_err;
Line: 566

      fa_debug_pkg.add(l_calling_fn, 'Call FA_RETIREMENTS_PKG.Update_Row', 'Begin', p_log_level_rec => p_log_level_rec);
Line: 569

   FA_RETIREMENTS_PKG.Update_Row(
                              X_Rowid             => l_rowid,
                              X_Retirement_Id     => p_asset_retire_rec.retirement_id,
                              X_Status            => 'PROCESSED',
                              X_Recapture_Amount  => l_recapture_amount,
                              X_mrc_sob_type_code => p_mrc_sob_type_code,
                              X_set_of_books_id   => p_asset_hdr_rec.set_of_books_id,
                              X_Calling_Fn        => l_calling_fn, p_log_level_rec => p_log_level_rec);
Line: 579

      fa_debug_pkg.add(l_calling_fn, 'Call FA_RETIREMENTS_PKG.Update_Row', 'End', p_log_level_rec => p_log_level_rec);
Line: 590

             element => 'calling fa_xla_events_pvt.update_transaction_event with thid: ',
             value   => p_trans_rec.transaction_header_id);
Line: 594

      if not fa_xla_events_pvt.update_transaction_event
               (p_ledger_id              => p_asset_hdr_rec.set_of_books_id,
                p_transaction_header_id  => p_trans_rec.transaction_header_id,
                p_book_type_code         => p_asset_hdr_rec.book_type_code,
                p_event_type_code        => 'RETIREMENTS',
                p_event_date             => p_asset_retire_rec.date_retired, --?
                p_event_status_code      => FA_XLA_EVENTS_PVT.C_EVENT_UNPROCESSED,
                p_calling_fn             => l_calling_fn,
                p_log_level_rec          => p_log_level_rec) then
         raise ret_err;
Line: 630

         FA_BOOKS_PKG.Update_Row(
                   X_Book_Type_Code               => l_asset_hdr_rec.book_type_code,
                   X_Asset_Id                     => l_asset_hdr_rec.asset_id,
                   X_terminal_gain_loss_flag      => 'Y',
                   X_mrc_sob_type_code            => p_mrc_sob_type_code,
                   X_set_of_books_id              => p_asset_hdr_rec.set_of_books_id,
                   X_Calling_Fn                   => l_calling_fn, p_log_level_rec => p_log_level_rec);
Line: 644

               UPDATE FA_MC_BOOKS
               SET    TERMINAL_GAIN_LOSS_FLAG = 'Y'
               WHERE  GROUP_ASSET_ID = l_asset_hdr_rec.asset_id
               AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
               AND    TRANSACTION_HEADER_ID_OUT is null
               AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 651

               UPDATE FA_BOOKS
               SET    TERMINAL_GAIN_LOSS_FLAG = 'Y'
               WHERE  GROUP_ASSET_ID = l_asset_hdr_rec.asset_id
               AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
               AND    TRANSACTION_HEADER_ID_OUT is null;
Line: 699

    select transaction_header_id
    from   fa_transaction_headers
    where  asset_id = p_group_asset_id
    and    book_type_code = p_asset_hdr_rec.book_type_code
    and    member_transaction_header_id = p_transaction_header_id;
Line: 708

    select rowid
    from   fa_adjustments
    where  asset_id = p_group_asset_id
    and    book_type_code = p_asset_hdr_rec.book_type_code
    and    transaction_header_id = l_transaction_header_id;
Line: 715

    select rowid
    from   fa_mc_adjustments
    where  transaction_header_id = l_transaction_header_id
    and    set_of_books_id = p_set_of_books_id;
Line: 731

    FA_BOOKS_PKG.Delete_Row(
                       X_Transaction_Header_Id_in => l_transaction_header_id,
                       X_mrc_sob_type_code        => p_mrc_sob_type_code,
                       X_set_of_books_id          => p_set_of_books_id,
                       X_Calling_Fn               => l_calling_fn, p_log_level_rec => p_log_level_rec);
Line: 745

      FA_ADJUSTMENTS_PKG.DELETE_ROW(
                       X_Rowid             => l_adj.rowid,
                       X_mrc_sob_type_code => p_mrc_sob_type_code,
                       X_set_of_books_id          => p_set_of_books_id,
                       X_Calling_Fn        => l_calling_fn, p_log_level_rec => p_log_level_rec);
Line: 754

    FA_BOOKS_PKG.Delete_Row(
                       X_Transaction_Header_Id_in => l_transaction_header_id,
                       X_mrc_sob_type_code        => p_mrc_sob_type_code,
                       X_set_of_books_id          => p_set_of_books_id,
                       X_Calling_Fn               => l_calling_fn, p_log_level_rec => p_log_level_rec);
Line: 768

      FA_ADJUSTMENTS_PKG.DELETE_ROW(
                         X_Rowid             => l_adj.rowid,
                         X_mrc_sob_type_code => p_mrc_sob_type_code,
                         X_set_of_books_id          => p_set_of_books_id,
                         X_Calling_Fn        => l_calling_fn, p_log_level_rec => p_log_level_rec);
Line: 813

    select FA_DISTRIBUTION_HISTORY_S.NEXTVAL
         , -1 * transaction_units
         , assigned_to
         , code_combination_id
         , location_id
                        , units_assigned
    from   fa_distribution_history
    where  retirement_id = p_asset_retire_rec.retirement_id;
Line: 825

    select distribution_id
         , units_assigned + nvl(transaction_units, 0)
    from   fa_distribution_history
    where  asset_id = p_asset_hdr_rec.asset_id
    and    book_type_code = p_asset_hdr_rec.book_type_code
    and    transaction_header_id_out is null
    and    (assigned_to = c_assigned_to
       or  (assigned_to is null and
            c_assigned_to is null))
    and    code_combination_id = c_expense_ccid
    and    location_id = c_location_ccid;
Line: 838

    select transaction_type_code
      from fa_transaction_headers
     where asset_id =  p_asset_hdr_rec.asset_id
       and book_type_code = p_asset_hdr_rec.book_type_code
       and transaction_header_id = p_asset_retire_rec.detail_info.transaction_header_id_in;
Line: 849

    select fa_transaction_headers_s.nextval
    from   dual;
Line: 853

    select transaction_header_id
    from   fa_transaction_headers
    where  asset_id = p_asset_fin_rec.group_asset_id
    and    book_type_code = p_asset_hdr_rec.book_type_code
    and    member_transaction_header_id = p_trans_rec.transaction_header_id;
Line: 913

    select distribution_id
         , transaction_header_id_in
         , transaction_header_id_out
         , units_assigned
         , transaction_units
    from   fa_distribution_history
    where  asset_id = p_asset_hdr_rec.asset_id
    order by distribution_id;
Line: 1000

            update FA_DISTRIBUTION_HISTORY
            set    transaction_units = nvl(transaction_units, t_units_assigned(i)),
                   transaction_header_id_out = p_trans_rec.transaction_header_id,
                   date_ineffective = p_trans_rec.who_info.last_update_date,
                   last_update_date = p_trans_rec.who_info.last_update_date,
                   last_updated_by = p_trans_rec.who_info.last_updated_by,
                   last_update_login = p_trans_rec.who_info.last_update_login
            where  distribution_id = l_distribution_id;
Line: 1017

      insert into FA_DISTRIBUTION_HISTORY(
                            DISTRIBUTION_ID,
                            BOOK_TYPE_CODE,
                            ASSET_ID,
                            UNITS_ASSIGNED,
                            DATE_EFFECTIVE,
                            CODE_COMBINATION_ID,
                            LOCATION_ID,
                            TRANSACTION_HEADER_ID_IN,
                            LAST_UPDATE_DATE,
                            LAST_UPDATED_BY,
                            ASSIGNED_TO)
                     VALUES(t_distribution_id(i),
                            p_asset_hdr_rec.book_type_code,
                            p_asset_hdr_rec.asset_id,
                            t_units_assigned(i),
                            p_trans_rec.who_info.creation_date,
                            t_expense_ccid(i),
                            t_location_ccid(i),
                            p_trans_rec.transaction_header_id,
                            p_trans_rec.who_info.last_update_date,
                            p_trans_rec.who_info.last_updated_by,
                            t_assigned_to(i));
Line: 1061

         FA_ASSET_HISTORY_PKG.Update_Row
                   (X_Asset_Id                  => p_asset_hdr_rec.asset_id,
                    X_Date_Ineffective          => p_trans_rec.who_info.last_update_date,
                    X_Transaction_Header_Id_Out => p_trans_rec.transaction_header_id,
                    X_Last_Update_Date          => p_trans_rec.who_info.last_update_date,
                    X_Last_Updated_By           => p_trans_rec.who_info.last_updated_by,
                    X_Last_Update_Login         => p_trans_rec.who_info.last_update_login,
                    X_Return_Status             => l_status,
                    X_Calling_Fn                => l_calling_fn, p_log_level_rec => p_log_level_rec);
Line: 1075

         FA_ASSET_HISTORY_PKG.Insert_Row
                   (X_Rowid                     => l_rowid,
                    X_Asset_Id                  => p_asset_hdr_rec.asset_id,
                    X_Category_Id               => p_asset_cat_rec.category_id,
                    X_Asset_Type                => p_asset_type_rec.asset_type,
                    X_Units                     => l_asset_desc_rec_m.current_units + p_asset_retire_rec.units_retired,
                    X_Date_Effective            => p_trans_rec.who_info.last_update_date,
                    X_Transaction_Header_Id_In  => p_trans_rec.transaction_header_id,
                    X_Last_Update_Date          => p_trans_rec.who_info.last_update_date,
                    X_Last_Updated_By           => p_trans_rec.who_info.last_updated_by,
                    X_Return_Status             => l_status,
                    X_Calling_Fn                => 'FA_DISTRIBUTION_PVT.update_asset_history',  p_log_level_rec => p_log_level_rec);
Line: 1091

         update fa_additions_b
         set    current_units = current_units + p_asset_retire_rec.units_retired
         where  asset_id = p_asset_hdr_rec.asset_id;
Line: 1117

   l_trans_rec.who_info.last_update_date := p_trans_rec.who_info.last_update_date;
Line: 1118

   l_trans_rec.who_info.last_updated_by := p_trans_rec.who_info.last_updated_by;
Line: 1119

   l_trans_rec.who_info.last_update_login := p_trans_rec.who_info.last_update_login;
Line: 1231

          X_Date_Ineffective             => p_trans_rec.who_info.last_update_date,
          X_mrc_sob_type_code            => p_mrc_sob_type_code,
          X_set_of_books_id              => p_asset_hdr_rec.set_of_books_id,
          X_Calling_Fn                   => l_calling_fn, p_log_level_rec => p_log_level_rec);
Line: 1238

   FA_BOOKS_PKG.INSERT_ROW(
          X_Rowid                        => l_rowid,
          X_Book_Type_Code               => p_asset_hdr_rec.book_type_code,
          X_Asset_Id                     => p_asset_hdr_rec.asset_id,
          X_Date_Placed_In_Service       => p_asset_fin_rec.date_placed_in_service,
          X_Date_Effective               => p_trans_rec.who_info.creation_date,
          X_Deprn_Start_Date             => p_asset_fin_rec.deprn_start_date,
          X_Deprn_Method_Code            => p_asset_fin_rec.deprn_method_code,
          X_Life_In_Months               => p_asset_fin_rec.life_in_months,
          X_Rate_Adjustment_Factor       => l_asset_fin_rec_mn.rate_adjustment_factor,
          X_Adjusted_Cost                => l_asset_fin_rec_mn.adjusted_cost,
          X_Cost                         => l_asset_fin_rec_mn.cost,
          X_Original_Cost                => p_asset_fin_rec.original_cost,
          X_Salvage_Value                => l_asset_fin_rec_mn.salvage_value,
          X_Prorate_Convention_Code      => p_asset_fin_rec.prorate_convention_code,
          X_Prorate_Date                 => p_asset_fin_rec.prorate_date,
          X_Cost_Change_Flag             => p_asset_fin_rec.cost_change_flag,
          X_Adjustment_Required_Status   => p_asset_fin_rec.adjustment_required_status,
          X_Capitalize_Flag              => p_asset_fin_rec.capitalize_flag,
          X_Retirement_Pending_Flag      => 'NO',
          X_Depreciate_Flag              => p_asset_fin_rec.depreciate_flag,
          X_Disabled_Flag                => p_asset_fin_rec.disabled_flag, --HH
          X_Last_Update_Date             => p_trans_rec.who_info.last_update_date,
          X_Last_Updated_By              => p_trans_rec.who_info.last_updated_by,
          X_Transaction_Header_Id_In     => p_trans_rec.transaction_header_id,
          X_Itc_Amount_Id                => p_asset_fin_rec.itc_amount_id,
          X_Itc_Amount                   => p_asset_fin_rec.itc_amount,
  --        X_Retirement_Id                => ,
  --        X_Tax_Request_Id               => ,
          X_Itc_Basis                    => p_asset_fin_rec.itc_basis,
          X_Basic_Rate                   => p_asset_fin_rec.basic_rate,
          X_Adjusted_Rate                => p_asset_fin_rec.adjusted_rate,
          X_Bonus_Rule                   => p_asset_fin_rec.bonus_rule,
          X_Ceiling_Name                 => p_asset_fin_rec.ceiling_name,
          X_Recoverable_Cost             => l_asset_fin_rec_mn.recoverable_cost,
          X_Adjusted_Capacity            => l_asset_fin_rec_mn.adjusted_capacity,
          X_Fully_Rsvd_Revals_Counter    => p_asset_fin_rec.fully_rsvd_revals_counter,
          X_Idled_Flag                   => p_asset_fin_rec.idled_flag,
          X_Period_Counter_Capitalized   => p_asset_fin_rec.period_counter_capitalized,
          X_PC_Fully_Reserved            => null,
          X_Production_Capacity          => p_asset_fin_rec.production_capacity,
          X_Reval_Amortization_Basis     => l_asset_fin_rec_mn.reval_amortization_basis,
          X_Reval_Ceiling                => l_asset_fin_rec_mn.reval_ceiling,
          X_Unit_Of_Measure              => p_asset_fin_rec.unit_of_measure,
          X_Unrevalued_Cost              => l_asset_fin_rec_mn.unrevalued_cost,
          X_Annual_Deprn_Rounding_Flag   => l_asset_fin_rec_mn.annual_deprn_rounding_flag,
          X_Percent_Salvage_Value        => p_asset_fin_rec.percent_salvage_value,
          X_Allowed_Deprn_Limit          => p_asset_fin_rec.allowed_deprn_limit,
          X_Allowed_Deprn_Limit_Amount   => l_asset_fin_rec_mn.allowed_deprn_limit_amount,
          X_Period_Counter_Life_Complete => p_asset_fin_rec.period_counter_life_complete,
          X_Adjusted_Recoverable_Cost    => l_asset_fin_rec_mn.adjusted_recoverable_cost,
          X_Short_Fiscal_Year_Flag       => p_asset_fin_rec.short_fiscal_year_flag,
          X_Conversion_Date              => p_asset_fin_rec.conversion_date,
          X_Orig_Deprn_Start_Date        => p_asset_fin_rec.orig_deprn_start_date,
          X_Remaining_Life1              => p_asset_fin_rec.remaining_life1,
          X_Remaining_Life2              => p_asset_fin_rec.remaining_life2,
          X_Old_Adj_Cost                 => p_asset_fin_rec.adjusted_cost,   ---???
          X_Formula_Factor               => l_asset_fin_rec_mn.formula_factor,
          X_gf_Attribute1                => p_asset_fin_rec.global_attribute1,
          X_gf_Attribute2                => p_asset_fin_rec.global_attribute2,
          X_gf_Attribute3                => p_asset_fin_rec.global_attribute3,
          X_gf_Attribute4                => p_asset_fin_rec.global_attribute4,
          X_gf_Attribute5                => p_asset_fin_rec.global_attribute5,
          X_gf_Attribute6                => p_asset_fin_rec.global_attribute6,
          X_gf_Attribute7                => p_asset_fin_rec.global_attribute7,
          X_gf_Attribute8                => p_asset_fin_rec.global_attribute8,
          X_gf_Attribute9                => p_asset_fin_rec.global_attribute9,
          X_gf_Attribute10               => p_asset_fin_rec.global_attribute10,
          X_gf_Attribute11               => p_asset_fin_rec.global_attribute11,
          X_gf_Attribute12               => p_asset_fin_rec.global_attribute12,
          X_gf_Attribute13               => p_asset_fin_rec.global_attribute13,
          X_gf_Attribute14               => p_asset_fin_rec.global_attribute14,
          X_gf_Attribute15               => p_asset_fin_rec.global_attribute15,
          X_gf_Attribute16               => p_asset_fin_rec.global_attribute16,
          X_gf_Attribute17               => p_asset_fin_rec.global_attribute17,
          X_gf_Attribute18               => p_asset_fin_rec.global_attribute18,
          X_gf_Attribute19               => p_asset_fin_rec.global_attribute19,
          X_gf_Attribute20               => p_asset_fin_rec.global_attribute20,
          X_global_attribute_category    => p_asset_fin_rec.global_attribute_category,
          X_group_asset_id               => p_asset_fin_rec.group_asset_id,
          X_salvage_type                 => p_asset_fin_rec.salvage_type,
          X_deprn_limit_type             => p_asset_fin_rec.deprn_limit_type,
          X_over_depreciate_option       => p_asset_fin_rec.over_depreciate_option,
          X_super_group_id               => p_asset_fin_rec.super_group_id,
          X_reduction_rate               => l_asset_fin_rec_mn.reduction_rate,
          X_reduce_addition_flag         => p_asset_fin_rec.reduce_addition_flag,
          X_reduce_adjustment_flag       => p_asset_fin_rec.reduce_adjustment_flag,
          X_reduce_retirement_flag       => p_asset_fin_rec.reduce_retirement_flag,
          X_recognize_gain_loss          => p_asset_fin_rec.recognize_gain_loss,
          X_recapture_reserve_flag       => p_asset_fin_rec.recapture_reserve_flag,
          X_limit_proceeds_flag          => p_asset_fin_rec.limit_proceeds_flag,
          X_terminal_gain_loss           => p_asset_fin_rec.terminal_gain_loss,
          X_tracking_method              => p_asset_fin_rec.tracking_method,
          X_allocate_to_fully_rsv_flag   => p_asset_fin_rec.allocate_to_fully_rsv_flag,
          X_allocate_to_fully_ret_flag   => p_asset_fin_rec.allocate_to_fully_ret_flag,
          X_exclude_fully_rsv_flag       => p_asset_fin_rec.exclude_fully_rsv_flag,
          X_excess_allocation_option     => p_asset_fin_rec.excess_allocation_option,
          X_depreciation_option          => p_asset_fin_rec.depreciation_option,
          X_member_rollup_flag           => p_asset_fin_rec.member_rollup_flag,
          X_ytd_proceeds                 => l_asset_fin_rec_mn.ytd_proceeds,
          X_ltd_proceeds                 => l_asset_fin_rec_mn.ltd_proceeds,
          X_eofy_reserve                 => l_asset_fin_rec_mn.eofy_reserve,
          X_cip_cost                     => l_asset_fin_rec_mn.cip_cost,
          X_terminal_gain_loss_amount    => l_asset_fin_rec_mn.terminal_gain_loss_amount,
          X_ltd_cost_of_removal          => l_asset_fin_rec_mn.ltd_cost_of_removal,
          X_cash_generating_unit_id      =>
                                      p_asset_fin_rec.cash_generating_unit_id,
          X_Return_Status                => l_status,
          X_mrc_sob_type_code            => p_mrc_sob_type_code,
          X_set_of_books_id              => p_asset_hdr_rec.set_of_books_id,
          X_Calling_Fn                   => l_calling_fn,
          p_log_level_rec                => p_log_level_rec);
Line: 1411

      DELETE FROM FA_ADJUSTMENTS
      WHERE  ASSET_ID = l_asset_hdr_rec.asset_id
      AND    BOOK_TYPE_CODE = l_asset_hdr_rec.book_type_code
      AND    TRANSACTION_HEADER_ID = l_trans_rec.member_transaction_header_id
      AND    SOURCE_TYPE_CODE = 'DEPRECIATION'
      AND    ADJUSTMENT_TYPE in ('EXPENSE', 'BONUS EXPENSE',
                                 'IMPAIR EXPENSE');
Line: 1422

   FA_BOOKS_PKG.Update_Row(
                   X_Book_Type_Code            => l_asset_hdr_rec.book_type_code,
                   X_Asset_Id                  => l_asset_hdr_rec.asset_id,
                   X_terminal_gain_loss_amount => FND_API.G_MISS_NUM,
                   X_mrc_sob_type_code         => p_mrc_sob_type_code,
                   X_set_of_books_id           => p_asset_hdr_rec.set_of_books_id,
                   X_Calling_Fn                => l_calling_fn, p_log_level_rec => p_log_level_rec);
Line: 1534

    select distinct nvl(transaction_header_id_out,0)
    from   fa_distribution_history
    where  asset_id = p_asset_hdr_rec.asset_id
    and    book_type_code = p_asset_hdr_rec.book_type_code
    and    retirement_id = p_asset_retire_rec.retirement_id; */
Line: 1541

      select db.rule_name                             -- ENERGY
      from   fa_deprn_basis_rules db                  -- ENERGY
           , fa_methods mt                            -- ENERGY
           , fa_books bk                              -- ENERGY
      where  bk.asset_id = p_asset_fin_rec.group_asset_id           -- ENERGY
      and    bk.book_type_code = p_asset_hdr_rec.book_type_code   -- ENERGY
      and    bk.transaction_header_id_out is null                      -- ENERGY
      and    bk.deprn_method_code = mt.method_code                     -- ENERGY
      and    nvl(bk.life_in_months, -99) = nvl(mt.life_in_months, -99) -- ENERGY
      and    mt.deprn_basis_rule_id = db.deprn_basis_rule_id;          -- ENERGY
Line: 1592

  l_adj.selection_retid         := 0;
Line: 1596

  l_adj.last_update_date        := p_trans_rec.who_info.last_update_date;
Line: 1625

     FETCH c_get_thid INTO l_adj.selection_thid;
Line: 1628

     if (nvl(l_adj.selection_thid, 0) = 0) then

        if (p_log_level_rec.statement_level) then
           fa_debug_pkg.add(l_calling_fn, 'Error', 'Getting selection_thid', p_log_level_rec => p_log_level_rec);
Line: 1637

     l_adj.selection_thid          := p_trans_rec.transaction_header_id;
Line: 1638

     l_adj.selection_mode          := FA_STD_TYPES.FA_AJ_CLEAR;
Line: 1642

                          p_trans_rec.who_info.last_update_date,
                          p_trans_rec.who_info.last_updated_by,
                          p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
        raise calc_err;
Line: 1654

     l_adj.selection_thid          := 0;
Line: 1655

     l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 1659

                          p_trans_rec.who_info.last_update_date,
                          p_trans_rec.who_info.last_updated_by,
                          p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
        raise calc_err;
Line: 1690

       l_adj.selection_thid          := 0;
Line: 1691

       l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 1701

                               p_trans_rec.who_info.last_update_date,
                               p_trans_rec.who_info.last_updated_by,
                               p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
            raise calc_err;
Line: 1712

                          p_trans_rec.who_info.last_update_date,
                          p_trans_rec.who_info.last_updated_by,
                          p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
          raise calc_err;
Line: 1726

      l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 1786

                             p_trans_rec.who_info.last_update_date,
                             p_trans_rec.who_info.last_updated_by,
                             p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
        raise calc_err;
Line: 1809

                                   p_trans_rec.who_info.last_update_date,
                                   p_trans_rec.who_info.last_updated_by,
                                   p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
               raise calc_err;
Line: 1831

                                   p_trans_rec.who_info.last_update_date,
                                   p_trans_rec.who_info.last_updated_by,
                                   p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
              raise calc_err;
Line: 1855

                                   p_trans_rec.who_info.last_update_date,
                                   p_trans_rec.who_info.last_updated_by,
                                   p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
               raise calc_err;
Line: 1880

                                   p_trans_rec.who_info.last_update_date,
                                   p_trans_rec.who_info.last_updated_by,
                                   p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
               raise calc_err;
Line: 1929

  l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 1947

                          p_trans_rec.who_info.last_update_date,
                          p_trans_rec.who_info.last_updated_by,
                          p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
    raise calc_err;
Line: 1970

                                p_trans_rec.who_info.last_update_date,
                                p_trans_rec.who_info.last_updated_by,
                                p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
          raise calc_err;
Line: 1986

                                l_trans_rec.who_info.last_update_date,
                                l_trans_rec.who_info.last_updated_by,
                                l_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
           raise calc_err;
Line: 2008

                            p_trans_rec.who_info.last_update_date,
        --p_mode <> 'CR'                     p_trans_rec.who_info.last_updated_by,
                            p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
      raise calc_err;
Line: 2031

                            p_trans_rec.who_info.last_update_date,
                            p_trans_rec.who_info.last_updated_by,
                            p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
      raise calc_err;
Line: 2058

                            p_trans_rec.who_info.last_update_date,
                            p_trans_rec.who_info.last_updated_by,
                            p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
      raise calc_err;
Line: 2081

                            p_trans_rec.who_info.last_update_date,
                            p_trans_rec.who_info.last_updated_by,
                            p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
      raise calc_err;
Line: 2139

        l_adj.selection_retid         := 0;
Line: 2141

        l_adj.last_update_date        := p_trans_rec.who_info.last_update_date;
Line: 2160

           l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 2186

                                 p_trans_rec.who_info.last_update_date,
                                 p_trans_rec.who_info.last_updated_by,
                                 p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
              raise calc_err;
Line: 2212

           l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 2231

                                 p_trans_rec.who_info.last_update_date,
                                 p_trans_rec.who_info.last_updated_by,
                                 p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
              raise calc_err;
Line: 2257

           l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 2276

                                 p_trans_rec.who_info.last_update_date,
                                 p_trans_rec.who_info.last_updated_by,
                                 p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
              raise calc_err;
Line: 2336

/*    select transaction_header_id_out
    from   fa_distribution_history
    where  asset_id = p_asset_hdr_rec.asset_id
    and    book_type_code = p_asset_hdr_rec.book_type_code
    and    retirement_id = p_asset_retire_rec.retirement_id;
Line: 2342

    select  transaction_header_id_out
    from    fa_retirements
    where   asset_id = p_asset_hdr_rec.asset_id
    and     retirement_id = p_asset_retire_rec.retirement_id
    and     book_type_code = p_asset_hdr_rec.book_type_code;
Line: 2350

   select outbk.salvage_value - inbk.salvage_value
   from   fa_books inbk , fa_books outbk
   where  inbk.transaction_header_id_in = p_asset_retire_rec.detail_info.transaction_header_id_in
   and    outbk.asset_id = p_asset_hdr_rec.asset_id
   and    outbk.book_type_code = p_asset_hdr_rec.book_type_code
   and    outbk.transaction_header_id_out = p_asset_retire_rec.detail_info.transaction_header_id_in;
Line: 2358

   select outbk.salvage_value - inbk.salvage_value
   from   fa_mc_books inbk , fa_mc_books outbk
   where  inbk.transaction_header_id_in = p_asset_retire_rec.detail_info.transaction_header_id_in
   and    outbk.asset_id = p_asset_hdr_rec.asset_id
   and    outbk.book_type_code = p_asset_hdr_rec.book_type_code
   and    outbk.transaction_header_id_out = p_asset_retire_rec.detail_info.transaction_header_id_in
   and    inbk.set_of_books_id = p_asset_hdr_rec.set_of_books_id
   and    outbk.set_of_books_id = p_asset_hdr_rec.set_of_books_id ;
Line: 2370

    SELECT transaction_header_id,
           asset_id,
           date_effective
    FROM   fa_transaction_headers
    WHERE  member_transaction_header_id =
               p_asset_retire_rec.detail_info.transaction_header_id_in
    AND    asset_id = p_asset_fin_rec.group_asset_id
    AND    book_type_code = p_asset_hdr_rec.book_type_code;
Line: 2388

  SELECT TRANSACTION_HEADER_ID,
         SOURCE_TYPE_CODE,
         ADJUSTMENT_TYPE,
         DEBIT_CREDIT_FLAG,
         CODE_COMBINATION_ID,
         BOOK_TYPE_CODE,
         ASSET_ID,
         ADJUSTMENT_AMOUNT,
         DISTRIBUTION_ID,
         ANNUALIZED_ADJUSTMENT,
         PERIOD_COUNTER_ADJUSTED,
         PERIOD_COUNTER_CREATED,
         ASSET_INVOICE_ID
  FROM   FA_MC_ADJUSTMENTS
  WHERE  TRANSACTION_HEADER_ID  = l_group_thid
  AND    ASSET_ID               = l_group_asset_id
  AND    BOOK_TYPE_CODE         = p_asset_hdr_rec.book_type_code
  AND    PERIOD_COUNTER_CREATED = l_period_rec.period_counter
  AND    ADJUSTMENT_TYPE in ('PROCEEDS CLR', 'REMOVALCOST CLR', 'NBV RETIRED')
  AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 2410

  SELECT TRANSACTION_HEADER_ID,
         SOURCE_TYPE_CODE,
         ADJUSTMENT_TYPE,
         DEBIT_CREDIT_FLAG,
         CODE_COMBINATION_ID,
         BOOK_TYPE_CODE,
         ASSET_ID,
         ADJUSTMENT_AMOUNT,
         DISTRIBUTION_ID,
         ANNUALIZED_ADJUSTMENT,
         PERIOD_COUNTER_ADJUSTED,
         PERIOD_COUNTER_CREATED,
         ASSET_INVOICE_ID
  FROM   FA_ADJUSTMENTS
  WHERE  TRANSACTION_HEADER_ID  = l_group_thid
  AND    ASSET_ID               = l_group_asset_id
  AND    BOOK_TYPE_CODE         = p_asset_hdr_rec.book_type_code
  AND    PERIOD_COUNTER_CREATED = l_period_rec.period_counter
  AND    ADJUSTMENT_TYPE in ('PROCEEDS CLR', 'REMOVALCOST CLR', 'NBV RETIRED');
Line: 2489

   l_adj.selection_thid          := 0;
Line: 2490

   l_adj.selection_retid         := 0;
Line: 2492

   l_adj.last_update_date        := p_trans_rec.who_info.last_update_date;
Line: 2521

      FETCH c_get_thid_for_dist INTO l_adj.selection_thid;
Line: 2524

      if (nvl(l_adj.selection_thid, 0) = 0) then
         raise calc_err;
Line: 2528

      l_adj.selection_mode    := FA_STD_TYPES.FA_AJ_CLEAR;
Line: 2532

      l_adj.selection_thid    := 0;
Line: 2533

      l_adj.selection_mode    := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 2539

                          p_trans_rec.who_info.last_update_date,
                          p_trans_rec.who_info.last_updated_by,
                          p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
      raise calc_err;
Line: 2560

      l_adj.selection_thid    := 0;
Line: 2561

      l_adj.selection_mode    := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 2565

      l_adj.adjustment_amount := l_adj.amount_inserted +
                                p_asset_retire_rec.cost_retired;
Line: 2570

                              p_trans_rec.who_info.last_update_date,
                              p_trans_rec.who_info.last_updated_by,
                              p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
         raise calc_err;
Line: 2610

  l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 2623

                          p_trans_rec.who_info.last_update_date,
                          p_trans_rec.who_info.last_updated_by,
                          p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
    raise calc_err;
Line: 2672

  l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 2685

                          p_trans_rec.who_info.last_update_date,
                          p_trans_rec.who_info.last_updated_by,
                          p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
    raise calc_err;
Line: 2730

                                  p_trans_rec.who_info.last_update_date,
                                  p_trans_rec.who_info.last_updated_by,
                                  p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
           raise calc_err;
Line: 2764

        l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 2780

                                       p_trans_rec.who_info.last_update_date,
                                       p_trans_rec.who_info.last_updated_by,
                                       p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
           raise calc_err;
Line: 2803

                                  p_trans_rec.who_info.last_update_date,
                                  p_trans_rec.who_info.last_updated_by,
                                  p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
           raise calc_err;
Line: 2837

        l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 2853

                                       p_trans_rec.who_info.last_update_date,
                                       p_trans_rec.who_info.last_updated_by,
                                       p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
           raise calc_err;
Line: 2874

                              p_trans_rec.who_info.last_update_date,
                              p_trans_rec.who_info.last_updated_by,
                              p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
     raise calc_err;
Line: 2961

        l_adj.selection_retid         := 0;
Line: 2963

        l_adj.last_update_date        := p_trans_rec.who_info.last_update_date;
Line: 2983

           l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 3009

                                    p_trans_rec.who_info.last_update_date,
                                    p_trans_rec.who_info.last_updated_by,
                                    p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
              raise calc_err;
Line: 3034

           l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 3053

                                    p_trans_rec.who_info.last_update_date,
                                    p_trans_rec.who_info.last_updated_by,
                                    p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
              raise calc_err;
Line: 3078

           l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 3097

                                    p_trans_rec.who_info.last_update_date,
                                    p_trans_rec.who_info.last_updated_by,
                                    p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
              raise calc_err;
Line: 3137

    select fa_transaction_headers_s.nextval
    from   dual;
Line: 3141

    select trx.transaction_date_entered
         , trx.last_update_date
         , trx.last_updated_by
         , trx.last_update_login
         , trx.mass_transaction_id
         , trx.calling_interface
         , trx.mass_reference_id
         , nvl(trx.amortization_start_date, trx.transaction_date_entered)
         , trx.event_id
    from   fa_transaction_headers trx
    where  trx.transaction_header_id = p_ret.th_id_in;
Line: 3154

    select 'Y'
    from   fa_books
    where  book_type_code = p_ret.book
    and    group_asset_id = p_bk.group_asset_id
    and    ((period_counter_fully_retired is null)
        or  (period_counter_fully_retired is not null
         and retirement_pending_flag = 'YES'))
    and    transaction_header_id_out is null;
Line: 3164

    select -1 * eofy_reserve
    from   fa_retirements
    where retirement_id = p_ret.retirement_id;
Line: 3169

    select -1 * eofy_reserve
    from   fa_mc_retirements
    where retirement_id = p_ret.retirement_id
    and set_of_books_id = p_ret.set_of_books_id;
Line: 3249

                      , l_trans_rec.who_info.last_update_date
                      , l_trans_rec.who_info.last_updated_by
                      , l_trans_rec.who_info.last_update_login
                      , l_trans_rec.mass_transaction_id
                      , l_trans_rec.calling_interface
                      , l_trans_rec.mass_reference_id
                      , l_trans_rec.amortization_start_date
                      , l_trans_rec.event_id;
Line: 3269

   l_trans_rec.who_info.creation_date := l_trans_rec.who_info.last_update_date;
Line: 3270

   l_trans_rec.who_info.created_by := l_trans_rec.who_info.last_updated_by;
Line: 3430

            FA_BOOKS_PKG.Update_Row(
                   X_Book_Type_Code               => l_asset_hdr_rec.book_type_code,
                   X_Asset_Id                     => l_asset_hdr_rec.asset_id,
                   X_terminal_gain_loss_flag      => 'Y',
                   X_mrc_sob_type_code            => p_mrc_sob_type_code,
                   X_set_of_books_id              => p_ret.set_of_books_id,
                   X_Calling_Fn                   => l_calling_fn, p_log_level_rec => p_log_level_rec);
Line: 3501

               l_adj.selection_retid         := 0;
Line: 3504

               l_adj.last_update_date        := l_trans_rec.who_info.last_update_date;
Line: 3528

                                l_trans_rec.who_info.last_update_date,
                                l_trans_rec.who_info.last_updated_by,
                                l_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
                  raise calc_err;
Line: 3551

                                l_trans_rec.who_info.last_update_date,
                                l_trans_rec.who_info.last_updated_by,
                                l_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
                  raise calc_err;
Line: 3562

               FA_BOOKS_PKG.Update_Row(
                      X_Book_Type_Code            => l_asset_hdr_rec.book_type_code,
                      X_Asset_Id                  => l_asset_hdr_rec.asset_id,
                      X_terminal_gain_loss_amount => l_deprn_reserve,
                      X_mrc_sob_type_code         => p_mrc_sob_type_code,
                      X_set_of_books_id           => p_ret.set_of_books_id,
                      X_Calling_Fn                => l_calling_fn, p_log_level_rec => p_log_level_rec);
Line: 3607

    select fa_transaction_headers_s.nextval
    from   dual;
Line: 3611

    select trx.transaction_header_id
         , trx.transaction_date_entered
         , trx.last_update_date
         , trx.last_updated_by
         , trx.last_update_login
         , trx.mass_transaction_id
         , trx.calling_interface
         , trx.mass_reference_id
         , nvl(trx.amortization_start_date, trx.transaction_date_entered)
         , event_id
    from   fa_retirements ret
       ,   fa_transaction_headers trx
    where  ret.retirement_id = p_ret.retirement_id
    and    ret.transaction_header_id_out = trx.transaction_header_id;
Line: 3632

    select sum(decode(debit_credit_flag, 'CR', -1 * adjustment_amount,
                                                  adjustment_amount))
    from   fa_adjustments
    where  source_type_code = 'RETIREMENT'
    and    adjustment_type = 'RESERVE'
    and    asset_id = p_ret.asset_id
    and    book_type_code = p_ret.book
    and    transaction_header_id = c_transaction_header_id;
Line: 3646

    select sum(decode(debit_credit_flag, 'CR', -1 * adjustment_amount,
                                                  adjustment_amount))
    from   fa_mc_adjustments
    where  source_type_code = 'RETIREMENT'
    and    adjustment_type = 'RESERVE'
    and    asset_id = p_ret.asset_id
    and    book_type_code = p_ret.book
    and    transaction_header_id = c_transaction_header_id
    and    set_of_books_id = p_ret.set_of_books_id;
Line: 3661

    select sum(decode(debit_credit_flag, 'DR', -1, 1) * adjustment_amount)
    from   fa_adjustments aj, fa_transaction_headers th
    where  aj.source_type_code = 'RETIREMENT'
    and    aj.adjustment_type = 'EXPENSE'
    and    aj.asset_id = p_bk.group_asset_id
    and    aj.book_type_code = p_ret.book
    and    aj.transaction_header_id = th.transaction_header_id
    and    th.asset_id = p_bk.group_asset_id
    and    th.book_type_code = p_ret.book
    and    th.member_transaction_header_id = p_ret.th_id_in;
Line: 3676

    select sum(decode(debit_credit_flag, 'DR', -1, 1) * adjustment_amount)
    from   fa_mc_adjustments aj, fa_transaction_headers th
    where  aj.source_type_code = 'RETIREMENT'
    and    aj.adjustment_type = 'EXPENSE'
    and    aj.asset_id = p_bk.group_asset_id
    and    aj.book_type_code = p_ret.book
    and    aj.transaction_header_id = th.transaction_header_id
    and    th.asset_id = p_bk.group_asset_id
    and    th.book_type_code = p_ret.book
    and    th.member_transaction_header_id = p_ret.th_id_in
    and    aj.set_of_books_id = p_ret.set_of_books_id;
Line: 3740

                      , l_trans_rec.who_info.last_update_date
                      , l_trans_rec.who_info.last_updated_by
                      , l_trans_rec.who_info.last_update_login
                      , l_trans_rec.mass_transaction_id
                      , l_trans_rec.calling_interface
                      , l_trans_rec.mass_reference_id
                      , l_trans_rec.amortization_start_date
                      , l_trans_rec.event_id;
Line: 3759

   l_trans_rec.who_info.creation_date := l_trans_rec.who_info.last_update_date;
Line: 3760

   l_trans_rec.who_info.created_by := l_trans_rec.who_info.last_updated_by;
Line: 3854

      l_adj.selection_retid         := 0;
Line: 3855

      l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 3858

      l_adj.last_update_date        := l_trans_rec.who_info.last_update_date;
Line: 3878

                                l_trans_rec.who_info.last_update_date,
                                l_trans_rec.who_info.last_updated_by,
                                l_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
         raise calc_err;
Line: 3910

   UPDATE FA_ADJUSTMENTS
   SET TRANSACTION_HEADER_ID = l_trans_rec.transaction_header_id
   WHERE TRANSACTION_HEADER_ID = l_trans_rec.member_transaction_header_id
   AND   ASSET_ID = l_asset_hdr_rec.asset_id
   AND   BOOK_TYPE_CODE = l_asset_hdr_rec.book_type_code;
Line: 3964

      DELETE FROM FA_ADJUSTMENTS
      WHERE  ASSET_ID = l_asset_hdr_rec.asset_id
      AND    BOOK_TYPE_CODE = l_asset_hdr_rec.book_type_code
      AND    TRANSACTION_HEADER_ID = l_trans_rec.member_transaction_header_id
      AND    SOURCE_TYPE_CODE = 'DEPRECIATION'
      AND    ADJUSTMENT_TYPE in ('EXPENSE', 'BONUS EXPENSE', 'IMPAIR EXPENSE');
Line: 3974

   FA_BOOKS_PKG.Update_Row(
                   X_Book_Type_Code            => l_asset_hdr_rec.book_type_code,
                   X_Asset_Id                  => l_asset_hdr_rec.asset_id,
                   X_terminal_gain_loss_amount => FND_API.G_MISS_NUM,
                   X_mrc_sob_type_code         => p_mrc_sob_type_code,
                   X_set_of_books_id           => p_ret.set_of_books_id,
                   X_Calling_Fn                => l_calling_fn, p_log_level_rec => p_log_level_rec);
Line: 4026

     select 'Y'
     from   fa_books
     where  book_type_code = p_book_type_code
     and    group_asset_id = p_asset_id
     and    period_counter_fully_retired is null
     and    transaction_header_id_out is null;
Line: 4034

     select max(gth.transaction_header_id)
     from   fa_transaction_headers gth,
            fa_transaction_headers mth,
            fa_retirements ret,
            fa_books bk
     where  bk.group_asset_id = p_asset_id
     and    bk.book_type_code = p_book_type_code
     and    ret.asset_id = bk.asset_id
     and    ret.book_type_code = p_book_type_code
     and    mth.asset_id = bk.asset_id
     and    mth.book_type_code = p_book_type_code
     and    gth.asset_id = p_asset_id
     and    gth.book_type_code = p_book_type_code
     and    mth.transaction_type_code = 'FULL RETIREMENT'
     and    mth.transaction_header_id = gth.member_transaction_header_id;
Line: 4051

     select 'Y'
     from   fa_mc_books
     where  book_type_code = p_book_type_code
     and    group_asset_id = p_asset_id
     and    period_counter_fully_retired is null
     and    transaction_header_id_out is null
     and    set_of_books_id = p_set_of_books_id;
Line: 4060

     select max(gth.transaction_header_id)
     from   fa_transaction_headers gth,
            fa_transaction_headers mth,
            fa_mc_retirements ret,
            fa_mc_books bk
     where  bk.group_asset_id = p_asset_id
     and    bk.book_type_code = p_book_type_code
     and    bk.set_of_books_id = p_set_of_books_id
     and    ret.asset_id = bk.asset_id
     and    ret.book_type_code = p_book_type_code
     and    ret.set_of_books_id = p_set_of_books_id
     and    mth.asset_id = bk.asset_id
     and    mth.book_type_code = p_book_type_code
     and    gth.asset_id = p_asset_id
     and    gth.book_type_code = p_book_type_code
     and    mth.transaction_type_code = 'FULL RETIREMENT'
     and    mth.transaction_header_id = gth.member_transaction_header_id;
Line: 4080

     select units,
            category_id
     from   fa_asset_history
     where  asset_id = p_asset_id
     and    transaction_header_id_out is null;
Line: 4091

   l_last_update_date  DATE := sysdate;
Line: 4092

   l_last_updated_by   NUMBER(15) := fnd_global.user_id;
Line: 4093

   l_last_update_login NUMBER(15) := fnd_global.user_id;
Line: 4185

      l_adj.selection_retid         := 0;
Line: 4186

      l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 4189

      l_adj.last_update_date        := sysdate;
Line: 4213

                                l_last_update_date,
                                l_last_updated_by,
                                l_last_update_login, p_log_level_rec => p_log_level_rec) then
         raise gl_err;
Line: 4235

                                l_last_update_date,
                                l_last_updated_by,
                                l_last_update_login, p_log_level_rec => p_log_level_rec) then

         raise gl_err;
Line: 4242

      FA_BOOKS_PKG.Update_Row(
                      X_Book_Type_Code               => p_book_type_code,
                      X_Asset_Id                     => p_asset_id,
                      X_terminal_gain_loss_amount    => l_deprn_reserve,
                      X_terminal_gain_loss_flag      => 'N',
                      X_mrc_sob_type_code            => p_mrc_sob_type_code,
                      X_set_of_books_id              => fa_cache_pkg.fazcbc_record.set_of_books_id,
                      X_Calling_Fn                   => l_calling_fn, p_log_level_rec => p_log_level_rec);
Line: 4260

      FA_BOOKS_PKG.Update_Row(
                   X_Book_Type_Code               => p_book_type_code,
                   X_Asset_Id                     => p_asset_id,
                   X_terminal_gain_loss_flag      => FND_API.G_MISS_CHAR,
                   X_mrc_sob_type_code            => p_mrc_sob_type_code,
                   X_set_of_books_id              => fa_cache_pkg.fazcbc_record.set_of_books_id,
                   X_Calling_Fn                   => l_calling_fn, p_log_level_rec => p_log_level_rec);
Line: 4297

     select bk.asset_id asset_id
     from   fa_books bk,
            fa_additions ad
     where  bk.book_type_code = p_book_type_code
     and    bk.transaction_header_id_out is null
     and    bk.asset_id = ad.asset_id
     and    ad.asset_type = 'GROUP'
     and    bk.terminal_gain_loss = 'YES'
     and    bk.terminal_gain_loss_flag = 'Y'
     and    MOD(bk.asset_id, p_total_requests) = (p_request_number - 1);
Line: 4309

     select bk.asset_id asset_id
     from   fa_books bk,
            fa_additions ad
     where  bk.book_type_code = p_book_type_code
     and    bk.transaction_header_id_out is null
     and    bk.asset_id = ad.asset_id
     and    ad.asset_type = 'GROUP'
     and    bk.terminal_gain_loss_flag = 'Y'
     and    MOD(bk.asset_id, p_total_requests) = (p_request_number - 1);
Line: 4467

      select asset_id
      from   fa_books
      where  group_asset_id = p_asset_hdr_rec.asset_id
      and    book_type_code = p_asset_hdr_rec.book_type_code
      and    period_counter_fully_retired is null
      and    transaction_header_id_out is null;
Line: 4475

      select asset_id
      from   fa_mc_books
      where  group_asset_id = p_asset_hdr_rec.asset_id
      and    book_type_code = p_asset_hdr_rec.book_type_code
      and    period_counter_fully_retired is null
      and    transaction_header_id_out is null
      and    set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 4601

         UPDATE FA_MC_BOOKS
         SET    TERMINAL_GAIN_LOSS_FLAG = 'Y'
         WHERE  ASSET_ID = p_asset_hdr_rec.asset_id
         AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
         AND    TRANSACTION_HEADER_ID_OUT is null
         AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 4608

         UPDATE FA_MC_BOOKS_SUMMARY
         SET    TERMINAL_GAIN_LOSS_FLAG = 'Y'
         WHERE  ASSET_ID = p_asset_hdr_rec.asset_id
         AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
         AND    PERIOD_COUNTER = p_period_rec.period_counter
         AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 4616

         UPDATE FA_MC_BOOKS
         SET    TERMINAL_GAIN_LOSS_FLAG = 'Y'
         WHERE  GROUP_ASSET_ID = p_asset_hdr_rec.asset_id
         AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
         AND    TRANSACTION_HEADER_ID_OUT is null
         AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id
         AND    tracking_method = 'CALCULATE'
         AND    recognize_gain_loss = 'NO'
         and    member_rollup_flag = 'Y';
Line: 4629

         UPDATE FA_BOOKS
         SET    TERMINAL_GAIN_LOSS_FLAG = 'Y'
         WHERE  ASSET_ID = p_asset_hdr_rec.asset_id
         AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
         AND    TRANSACTION_HEADER_ID_OUT is null;
Line: 4635

         UPDATE FA_BOOKS_SUMMARY
         SET    TERMINAL_GAIN_LOSS_FLAG = 'Y'
         WHERE  ASSET_ID = p_asset_hdr_rec.asset_id
         AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
         AND    PERIOD_COUNTER = p_period_rec.period_counter;
Line: 4642

         UPDATE FA_BOOKS
         SET    TERMINAL_GAIN_LOSS_FLAG = 'Y'
         WHERE  GROUP_ASSET_ID = p_asset_hdr_rec.asset_id
         AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
         AND    TRANSACTION_HEADER_ID_OUT is null
         AND    tracking_method = 'CALCULATE'
         AND    recognize_gain_loss = 'NO'
         and    member_rollup_flag = 'Y';
Line: 4708

      SELECT BK.ASSET_ID                  ASSET_ID
           , BK.TRANSACTION_HEADER_ID_IN  TRANSACTION_HEADER_ID_IN
           , BK.RATE_ADJUSTMENT_FACTOR    RATE_ADJUSTMENT_FACTOR
           , BK.ADJUSTED_COST             ADJUSTED_COST
           , BK.RECOVERABLE_COST          RECOVERABLE_COST
      FROM   FA_BOOKS BK
           , FA_ADDITIONS_B AD
           , fa_transaction_headers th
      WHERE  BK.BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
      AND    BK.TRANSACTION_HEADER_ID_OUT is null
      AND    BK.GROUP_ASSET_ID = p_asset_hdr_rec.asset_id
      AND    nvl(BK.CIP_COST, 0) = 0
      AND    BK.ASSET_ID = th.asset_id
      AND    th.transaction_header_id = p_mem_ret_thid
      AND    AD.ASSET_TYPE = 'CAPITALIZED';
Line: 4725

      SELECT BK.ASSET_ID                  ASSET_ID
           , BK.TRANSACTION_HEADER_ID_IN  TRANSACTION_HEADER_ID_IN
           , BK.RATE_ADJUSTMENT_FACTOR    RATE_ADJUSTMENT_FACTOR
           , BK.ADJUSTED_COST             ADJUSTED_COST
           , BK.RECOVERABLE_COST          RECOVERABLE_COST
      FROM   FA_MC_BOOKS BK
           , FA_ADDITIONS_B AD
           , fa_transaction_headers th
      WHERE  BK.BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
      AND    BK.TRANSACTION_HEADER_ID_OUT is null
      AND    BK.GROUP_ASSET_ID = p_asset_hdr_rec.asset_id
      AND    nvl(BK.CIP_COST, 0) = 0
      AND    BK.ASSET_ID = th.asset_id
      AND    th.transaction_header_id = p_mem_ret_thid
      AND    AD.ASSET_TYPE = 'CAPITALIZED'
      AND    BK.SET_OF_BOOKS_ID = p_asset_hdr_rec.set_of_books_id;
Line: 4747

      SELECT SUM(RECOVERABLE_COST)
      FROM   FA_BOOKS
      WHERE  BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
      AND    TRANSACTION_HEADER_ID_OUT is null
      AND    PERIOD_COUNTER_FULLY_RESERVED is null
      AND    PERIOD_COUNTER_FULLY_RETIRED is null
      AND    nvl(CIP_COST, 0) = 0
      AND    GROUP_ASSET_ID = p_asset_hdr_rec.asset_id;
Line: 4758

      SELECT SUM(RECOVERABLE_COST)
      FROM   FA_MC_BOOKS
      WHERE  BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
      AND    TRANSACTION_HEADER_ID_OUT is null
      AND    PERIOD_COUNTER_FULLY_RESERVED is null
      AND    PERIOD_COUNTER_FULLY_RETIRED is null
      AND    nvl(CIP_COST, 0) = 0
      AND    GROUP_ASSET_ID = p_asset_hdr_rec.asset_id
      AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 4769

      SELECT SUM(ADJUSTED_COST)
      FROM   FA_BOOKS_SUMMARY
      WHERE  BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
      AND    TRANSACTION_HEADER_ID_OUT is null
      AND    nvl(FULLY_RESERVED_FLAG, 'N') = 'N'
      AND    nvl(FULLY_RETIRED_FLAG, 'N') = 'N'
      AND    GROUP_ASSET_ID = p_asset_hdr_rec.asset_id
      AND    nvl(CIP_COST, 0) = 0
      AND    PERIOD_COUNTER = p_period_rec.period_counter;
Line: 4780

      SELECT SUM(ADJUSTED_COST)
      FROM   FA_MC_BOOKS_SUMMARY
      WHERE  BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
      AND    TRANSACTION_HEADER_ID_OUT is null
      AND    nvl(FULLY_RESERVED_FLAG, 'N') = 'N'
      AND    nvl(FULLY_RETIRED_FLAG, 'N') = 'N'
      AND    GROUP_ASSET_ID = p_asset_hdr_rec.asset_id
      AND    nvl(CIP_COST, 0) = 0
      AND    PERIOD_COUNTER = p_period_rec.period_counter
      AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 4792

      SELECT sum(decode(AJ.DEBIT_CREDIT_FLAG, 'CR', -1, 1)*AJ.ADJUSTMENT_AMOUNT)
      FROM   FA_ADJUSTMENTS AJ
      WHERE  AJ.ASSET_ID = p_asset_hdr_rec.asset_id
      AND    AJ.BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
      AND    AJ.TRANSACTION_HEADER_ID = p_trans_rec.transaction_header_id;
Line: 4799

      SELECT sum(decode(AJ.DEBIT_CREDIT_FLAG, 'CR', -1, 1)*AJ.ADJUSTMENT_AMOUNT)
      FROM   FA_ADJUSTMENTS AJ
      WHERE  AJ.ASSET_ID = p_asset_hdr_rec.asset_id
      AND    AJ.BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
      AND    AJ.TRANSACTION_HEADER_ID = p_trans_rec.transaction_header_id;
Line: 4807

      SELECT BK.ASSET_ID                  ASSET_ID
           , BK.TRANSACTION_HEADER_ID_IN  TRANSACTION_HEADER_ID_IN
           , BK.RATE_ADJUSTMENT_FACTOR    RATE_ADJUSTMENT_FACTOR
           , BK.ADJUSTED_COST             ADJUSTED_COST
           , BK.CAPITALIZE_FLAG           CAPITALIZE_FLAG
           , BK.RECOVERABLE_COST          RECOVERABLE_COST
           , BK.ADJUSTED_RECOVERABLE_COST ADJUSTED_RECOVERABLE_COST
           , AD.ASSET_CATEGORY_ID         ASSET_CATEGORY_ID
           , AD.CURRENT_UNITS             CURRENT_UNITS
           , 'NO' REINS_ASSET_FLAG
      FROM   FA_BOOKS BK
           , FA_ADDITIONS_B AD
      WHERE  BK.BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
      AND    BK.TRANSACTION_HEADER_ID_OUT is null
      AND    BK.GROUP_ASSET_ID = p_asset_hdr_rec.asset_id
      AND    nvl(BK.CIP_COST, 0) = 0
      AND    BK.PERIOD_COUNTER_FULLY_RESERVED is null
      AND    BK.PERIOD_COUNTER_FULLY_RETIRED is null
      AND    BK.ASSET_ID = AD.ASSET_ID
      AND    BK.ASSET_ID <> decode(p_mode,'RECURR',nvl(h_rein_mem_asset_id,-1),-1)
      AND    AD.ASSET_TYPE = 'CAPITALIZED'
      UNION ALL
      SELECT BK.ASSET_ID                  ASSET_ID
           , BK.TRANSACTION_HEADER_ID_IN  TRANSACTION_HEADER_ID_IN
           , BK.RATE_ADJUSTMENT_FACTOR    RATE_ADJUSTMENT_FACTOR
           , BK.ADJUSTED_COST             ADJUSTED_COST
           , BK.CAPITALIZE_FLAG           CAPITALIZE_FLAG
           , BK.RECOVERABLE_COST          RECOVERABLE_COST
           , BK.ADJUSTED_RECOVERABLE_COST ADJUSTED_RECOVERABLE_COST
           , AD.ASSET_CATEGORY_ID         ASSET_CATEGORY_ID
           , AD.CURRENT_UNITS             CURRENT_UNITS
           , 'YES' REINS_ASSET_FLAG
      FROM   FA_BOOKS BK
           , FA_ADDITIONS_B AD
      WHERE  BK.BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
      AND    BK.TRANSACTION_HEADER_ID_OUT is null
      AND    BK.GROUP_ASSET_ID = p_asset_hdr_rec.asset_id
      AND    nvl(BK.CIP_COST, 0) = 0
      AND    BK.ASSET_ID = AD.ASSET_ID
      AND    BK.ASSET_ID = decode(p_mode,'RECURR',nvl(h_rein_mem_asset_id,-1),-1)
      AND    AD.ASSET_TYPE = 'CAPITALIZED'
      order by 10,1; --Please never change this Order By clause. If changed will cause huge corruption.
Line: 4852

      SELECT BK.ASSET_ID                  ASSET_ID
           , BK.TRANSACTION_HEADER_ID_IN  TRANSACTION_HEADER_ID_IN
           , BK.RATE_ADJUSTMENT_FACTOR    RATE_ADJUSTMENT_FACTOR
           , BK.ADJUSTED_COST             ADJUSTED_COST
           , BK.CAPITALIZE_FLAG           CAPITALIZE_FLAG
           , BK.RECOVERABLE_COST          RECOVERABLE_COST
           , BK.ADJUSTED_RECOVERABLE_COST ADJUSTED_RECOVERABLE_COST
           , AD.ASSET_CATEGORY_ID         ASSET_CATEGORY_ID
           , AD.CURRENT_UNITS             CURRENT_UNITS
           , 'NO' REINS_ASSET_FLAG
      FROM   FA_MC_BOOKS BK
           , FA_ADDITIONS_B AD
      WHERE  BK.BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
      AND    BK.TRANSACTION_HEADER_ID_OUT is null
      AND    BK.GROUP_ASSET_ID = p_asset_hdr_rec.asset_id
      AND    nvl(BK.CIP_COST, 0) = 0
      AND    BK.PERIOD_COUNTER_FULLY_RESERVED is null
      AND    BK.PERIOD_COUNTER_FULLY_RETIRED is null
      AND    BK.ASSET_ID = AD.ASSET_ID
      AND    BK.ASSET_ID <> decode(p_mode,'RECURR',nvl(h_rein_mem_asset_id,-1),-1)
      AND    AD.ASSET_TYPE = 'CAPITALIZED'
      AND    BK.SET_OF_BOOKS_ID = p_asset_hdr_rec.set_of_books_id
      UNION ALL
      SELECT BK.ASSET_ID                  ASSET_ID
           , BK.TRANSACTION_HEADER_ID_IN  TRANSACTION_HEADER_ID_IN
           , BK.RATE_ADJUSTMENT_FACTOR    RATE_ADJUSTMENT_FACTOR
           , BK.ADJUSTED_COST             ADJUSTED_COST
           , BK.CAPITALIZE_FLAG           CAPITALIZE_FLAG
           , BK.RECOVERABLE_COST          RECOVERABLE_COST
           , BK.ADJUSTED_RECOVERABLE_COST ADJUSTED_RECOVERABLE_COST
           , AD.ASSET_CATEGORY_ID         ASSET_CATEGORY_ID
           , AD.CURRENT_UNITS             CURRENT_UNITS
           , 'YES' REINS_ASSET_FLAG
      FROM   FA_MC_BOOKS BK
           , FA_ADDITIONS_B AD
      WHERE  BK.BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
      AND    BK.TRANSACTION_HEADER_ID_OUT is null
      AND    BK.GROUP_ASSET_ID = p_asset_hdr_rec.asset_id
      AND    nvl(BK.CIP_COST, 0) = 0
      AND    BK.ASSET_ID = AD.ASSET_ID
      AND    BK.ASSET_ID = decode(p_mode,'RECURR',nvl(h_rein_mem_asset_id,-1),-1)
      AND    AD.ASSET_TYPE = 'CAPITALIZED'
      AND    BK.SET_OF_BOOKS_ID = p_asset_hdr_rec.set_of_books_id
      order by 10,1; --Please never change this Order By clause. If changed will cause huge corruption.
Line: 4899

      SELECT min(transaction_header_id)
        FROM fa_transaction_headers fath
       WHERE fath.asset_id = p_asset_id
         and fath.source_transaction_header_id = p_source_trans_id;
Line: 4905

      SELECT max(transaction_header_id)
        FROM fa_transaction_headers fath
       WHERE fath.asset_id = p_asset_id
         and fath.source_transaction_header_id = p_source_trans_id;
Line: 4911

      SELECT ASSET_ID
           , TRANSACTION_HEADER_ID_IN
           , BK.RECOVERABLE_COST -
             (FA_UTIL_PVT.get_asset_deprn_resv(p_asset_hdr_rec.book_type_code,BK.ASSET_ID, p_asset_hdr_rec.set_of_books_id
                                              , null, 'P' ) )
             ADJUSTED_COST
      FROM   FA_BOOKS BK
      WHERE  BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
      AND    TRANSACTION_HEADER_ID_OUT is null
      AND    GROUP_ASSET_ID = p_asset_hdr_rec.asset_id
      AND    PERIOD_COUNTER_FULLY_RESERVED is null
      AND    PERIOD_COUNTER_FULLY_RETIRED is null
      AND    nvl(CIP_COST, 0) = 0
      AND    (BK.RECOVERABLE_COST -
              (FA_UTIL_PVT.get_asset_deprn_resv(p_asset_hdr_rec.book_type_code,BK.ASSET_ID, p_asset_hdr_rec.set_of_books_id
                                              , null, 'P' ) )
             ) <> 0;
Line: 4930

      SELECT ASSET_ID
           , TRANSACTION_HEADER_ID_IN
           , BK.RECOVERABLE_COST -
           (FA_UTIL_PVT.get_asset_deprn_resv(p_asset_hdr_rec.book_type_code,BK.ASSET_ID, p_asset_hdr_rec.set_of_books_id
                                              , null, 'R' ) )
             ADJUSTED_COST
      FROM   FA_MC_BOOKS BK
      WHERE  BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
      AND    TRANSACTION_HEADER_ID_OUT is null
      AND    GROUP_ASSET_ID = p_asset_hdr_rec.asset_id
      AND    PERIOD_COUNTER_FULLY_RESERVED is null
      AND    PERIOD_COUNTER_FULLY_RETIRED is null
      AND    nvl(CIP_COST, 0) = 0
      AND    (BK.RECOVERABLE_COST -
              (FA_UTIL_PVT.get_asset_deprn_resv(p_asset_hdr_rec.book_type_code,BK.ASSET_ID, p_asset_hdr_rec.set_of_books_id
                                              , null, 'R' ) )
             ) <> 0
      AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 4952

      select th.asset_id
           , th.transaction_header_id
           , aj.debit_credit_flag
           , ad.current_units
           , ad.asset_category_id
           , bk.adjusted_recoverable_cost
           , sum(aj.adjustment_amount)
      from   fa_transaction_headers th    -- member
           , fa_transaction_headers gth -- group
           , fa_adjustments aj
           , fa_deprn_periods dp
           , fa_additions_b ad
           , fa_books bk
      where  th.book_type_code = p_asset_hdr_rec.book_type_code
--      and    th.date_effective = gth.date_effective
      and    th.source_transaction_header_id = gth.transaction_header_id
      and    gth.book_type_code = p_asset_hdr_rec.book_type_code
      and    gth.member_transaction_header_id = p_mem_ret_thid
      and    aj.asset_id = th.asset_id
      and    aj.book_type_code = p_asset_hdr_rec.book_type_code
      and    aj.transaction_header_id  = th.transaction_header_id
      and    dp.book_type_code = p_asset_hdr_rec.book_type_code
      and    gth.date_effective between dp.period_open_date and nvl(dp.period_close_date, sysdate)
      and    dp.period_counter = aj.period_counter_created
      and    th.asset_id = ad.asset_id
      and    bk.asset_id = th.asset_id
      and    bk.book_type_code = p_asset_hdr_rec.book_type_code
      and    bk.group_asset_id = gth.asset_id
      and    bk.transaction_header_id_out is null
      group by th.asset_id
             , th.transaction_header_id
             , aj.debit_credit_flag
             , ad.current_units
             , ad.asset_category_id
             , bk.adjusted_recoverable_cost;
Line: 4990

      select th.asset_id
           , th.transaction_header_id
           , aj.debit_credit_flag
           , ad.current_units
           , ad.asset_category_id
           , bk.adjusted_recoverable_cost
           , sum(aj.adjustment_amount)
      from   fa_transaction_headers th    -- member
           , fa_transaction_headers gth -- group
           , fa_mc_adjustments aj
           , fa_mc_deprn_periods dp
           , fa_additions_b ad
           , fa_mc_books bk
      where  th.book_type_code = p_asset_hdr_rec.book_type_code
--      and    th.date_effective = gth.date_effective
      and    th.source_transaction_header_id = gth.transaction_header_id
      and    gth.book_type_code = p_asset_hdr_rec.book_type_code
      and    gth.member_transaction_header_id = p_mem_ret_thid
      and    aj.asset_id = th.asset_id
      and    aj.book_type_code = p_asset_hdr_rec.book_type_code
      and    aj.transaction_header_id  = th.transaction_header_id
      and    dp.book_type_code = p_asset_hdr_rec.book_type_code
      and    gth.date_effective between dp.period_open_date and nvl(dp.period_close_date, sysdate)
      and    dp.period_counter = aj.period_counter_created
      and    th.asset_id = ad.asset_id
      and    bk.asset_id = th.asset_id
      and    bk.book_type_code = p_asset_hdr_rec.book_type_code
      and    bk.group_asset_id = gth.asset_id
      and    bk.transaction_header_id_out is null
      and    bk.set_of_books_id = p_asset_hdr_rec.set_of_books_id
      and    aj.set_of_books_id = bk.set_of_books_id
      and    dp.set_of_books_id = aj.set_of_books_id
      group by th.asset_id
             , th.transaction_header_id
             , aj.debit_credit_flag
             , ad.current_units
             , ad.asset_category_id
             , bk.adjusted_recoverable_cost;
Line: 5030

      select  transaction_header_id_in
      from    fa_books
      where book_type_code = p_asset_hdr_rec.book_type_code
      and   asset_id = c_asset_id
      and   transaction_header_id_out is null;
Line: 5037

      select  transaction_header_id_in
      from    fa_mc_books
      where book_type_code = p_asset_hdr_rec.book_type_code
      and   asset_id = c_asset_id
      and   transaction_header_id_out is null
      and   set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 5051

     select count(1)
     from   fa_transaction_headers th    -- member
          , fa_transaction_headers gth -- group
          , fa_adjustments aj
     where  th.book_type_code = p_asset_hdr_rec.book_type_code
     and    th.source_transaction_header_id = gth.transaction_header_id
     and    gth.book_type_code = p_asset_hdr_rec.book_type_code
     and    gth.member_transaction_header_id = p_mem_ret_thid
     and    aj.asset_id = th.asset_id
     and    aj.book_type_code = p_asset_hdr_rec.book_type_code
     and    aj.transaction_header_id  = th.transaction_header_id;
Line: 5131

   l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 5132

   l_adj.selection_retid         := 0;
Line: 5135

   l_adj.last_update_date        := p_trans_rec.who_info.last_update_date;
Line: 5263

      t_thid.delete;
Line: 5264

      t_asset_id.delete;
Line: 5265

      t_transaction_header_id_in.delete;
Line: 5266

      t_rate_adjustment_factor.delete;
Line: 5267

      t_adjusted_cost.delete;
Line: 5268

      t_capitalize_flag.delete;
Line: 5269

      t_recoverable_cost.delete;
Line: 5270

      t_adjusted_recoverable_cost.delete;
Line: 5271

      t_asset_category_id.delete;
Line: 5272

      t_current_units.delete;
Line: 5273

      t_new_adj_cost.delete;
Line: 5274

      t_adjustment_amount.delete;
Line: 5275

      t_reins_asset_flag.delete;
Line: 5355

      l_loc := 'Before Insert TH';
Line: 5358

      /* Do not insert last record in RECURR mode and reinstated asset flag is YES */

      if(p_mode = 'RECURR' AND t_reins_asset_flag(l_th_count) = 'YES') THEN
         l_th_count := l_th_count-1;
Line: 5364

      IF (p_mrc_sob_type_code <> 'R') THEN  --Bug 9076882 No need insert transaction headers for MRC
      FORALL i in t_asset_id.first..l_th_count
         INSERT INTO FA_TRANSACTION_HEADERS(
                         TRANSACTION_HEADER_ID
                       , BOOK_TYPE_CODE
                       , ASSET_ID
                       , TRANSACTION_TYPE_CODE
                       , TRANSACTION_DATE_ENTERED
                       , DATE_EFFECTIVE
                       , LAST_UPDATE_DATE
                       , LAST_UPDATED_BY
                       , SOURCE_TRANSACTION_HEADER_ID
                       , MASS_REFERENCE_ID
                       , LAST_UPDATE_LOGIN
                       , TRANSACTION_SUBTYPE
                       , TRANSACTION_KEY
                       , AMORTIZATION_START_DATE
                       , CALLING_INTERFACE
                       , MASS_TRANSACTION_ID
         ) VALUES (
                         FA_TRANSACTION_HEADERS_S.NEXTVAL
                       , p_asset_hdr_rec.book_type_code
                       , t_asset_id(i)
                       , 'ADJUSTMENT'
                       , p_trans_rec.transaction_date_entered
                       , p_trans_rec.who_info.last_update_date
                       , p_trans_rec.who_info.last_update_date
                       , p_trans_rec.who_info.last_updated_by
                       , p_trans_rec.transaction_header_id
                       , p_trans_rec.mass_reference_id
                       , p_trans_rec.who_info.last_update_login
                       , 'AMORTIZED'
                       , 'RA'
                       , p_trans_rec.amortization_start_date
                       , p_trans_rec.calling_interface
                       , p_trans_rec.mass_transaction_id
         ) RETURNING transaction_header_id BULK COLLECT INTO t_thid;
Line: 5591

                     select FA_TRANSACTION_HEADERS_S.NEXTVAL
                     into   t_thid(i)
                     from   dual;
Line: 5595

                     /* Insert record into fa_transaction_headers */
                     INSERT INTO FA_TRANSACTION_HEADERS(
                                     TRANSACTION_HEADER_ID
                                   , BOOK_TYPE_CODE
                                   , ASSET_ID
                                   , TRANSACTION_TYPE_CODE
                                   , TRANSACTION_DATE_ENTERED
                                   , DATE_EFFECTIVE
                                   , LAST_UPDATE_DATE
                                   , LAST_UPDATED_BY
                                   , SOURCE_TRANSACTION_HEADER_ID
                                   , MASS_REFERENCE_ID
                                   , LAST_UPDATE_LOGIN
                                   , TRANSACTION_SUBTYPE
                                   , TRANSACTION_KEY
                                   , AMORTIZATION_START_DATE
                                   , CALLING_INTERFACE
                                   , MASS_TRANSACTION_ID
                     ) VALUES (
                                     t_thid(i)
                                   , p_asset_hdr_rec.book_type_code
                                   , t_asset_id(i)
                                   , 'ADJUSTMENT'
                                   , p_trans_rec.transaction_date_entered
                                   , p_trans_rec.who_info.last_update_date
                                   , p_trans_rec.who_info.last_update_date
                                   , p_trans_rec.who_info.last_updated_by
                                   , p_trans_rec.transaction_header_id
                                   , p_trans_rec.mass_reference_id
                                   , p_trans_rec.who_info.last_update_login
                                   , 'AMORTIZED'
                                   , 'RA'
                                   , p_trans_rec.amortization_start_date
                                   , p_trans_rec.calling_interface
                                   , p_trans_rec.mass_transaction_id
                     );
Line: 5769

                             p_trans_rec.who_info.last_update_date,
                             p_trans_rec.who_info.last_updated_by,
                             p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
            raise allocate_err;
Line: 5780

      /* Bug 8633654 starts (delete last record when it is not required)*/

      IF (p_mode = 'RECURR' and (NOT bln_rein_mem_reqd)) THEN
         if (p_log_level_rec.statement_level) then
            fa_debug_pkg.add(l_calling_fn, 'Delete Reinstated member from PL-SQL','CHECK',p_log_level_rec);
Line: 5786

         l_loc := 'Before PL-SQL Delete';
Line: 5794

            t_asset_id.delete(t_asset_id.last);
Line: 5795

            t_transaction_header_id_in.delete(t_transaction_header_id_in.last);
Line: 5796

            t_rate_adjustment_factor.delete(t_rate_adjustment_factor.last);
Line: 5797

            t_adjusted_cost.delete(t_adjusted_cost.last);
Line: 5798

            t_capitalize_flag.delete(t_capitalize_flag.last);
Line: 5799

            t_recoverable_cost.delete(t_recoverable_cost.last);
Line: 5800

            t_adjusted_recoverable_cost.delete(t_adjusted_recoverable_cost.last);
Line: 5801

            t_asset_category_id.delete(t_asset_category_id.last);
Line: 5802

            t_current_units.delete(t_current_units.last);
Line: 5803

            t_reins_asset_flag.delete(t_reins_asset_flag.last);
Line: 5806

            fa_debug_pkg.add(l_calling_fn, 'Delete Reinstated member from PL-SQL','Done',p_log_level_rec);
Line: 5817

            UPDATE FA_MC_BOOKS_SUMMARY
            SET    RESERVE_ADJUSTMENT_AMOUNT = RESERVE_ADJUSTMENT_AMOUNT + t_adjustment_amount(i)
                 , DEPRN_RESERVE = DEPRN_RESERVE + t_adjustment_amount(i)
                 , ADJUSTED_COST = RECOVERABLE_COST - DEPRN_RESERVE - t_adjustment_amount(i)
            WHERE  ASSET_ID = t_asset_id(i)
            AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
            AND    PERIOD_COUNTER = p_period_rec.period_counter
            AND    TRANSACTION_HEADER_ID_OUT IS NULL
            AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 5830

            UPDATE FA_MC_BOOKS
            SET    DATE_INEFFECTIVE = p_trans_rec.who_info.last_update_date
                 , TRANSACTION_HEADER_ID_OUT = t_thid(i)
            WHERE  TRANSACTION_HEADER_ID_IN = t_transaction_header_id_in(i)
              AND  set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 5836

         l_loc := 'Before MRC Insert Books';
Line: 5839

            INSERT INTO FA_MC_BOOKS( BOOK_TYPE_CODE
                                      , ASSET_ID
                                      , DATE_PLACED_IN_SERVICE
                                      , DATE_EFFECTIVE
                                      , DEPRN_START_DATE
                                      , DEPRN_METHOD_CODE
                                      , LIFE_IN_MONTHS
                                      , RATE_ADJUSTMENT_FACTOR
                                      , ADJUSTED_COST
                                      , COST
                                      , ORIGINAL_COST
                                      , SALVAGE_VALUE
                                      , PRORATE_CONVENTION_CODE
                                      , PRORATE_DATE
                                      , COST_CHANGE_FLAG
                                      , ADJUSTMENT_REQUIRED_STATUS
                                      , CAPITALIZE_FLAG
                                      , RETIREMENT_PENDING_FLAG
                                      , DEPRECIATE_FLAG
                                      , LAST_UPDATE_DATE
                                      , LAST_UPDATED_BY
                                      , TRANSACTION_HEADER_ID_IN
                                      , ITC_AMOUNT_ID
                                      , ITC_AMOUNT
                                      , RETIREMENT_ID
                                      , TAX_REQUEST_ID
                                      , ITC_BASIS
                                      , BASIC_RATE
                                      , ADJUSTED_RATE
                                      , BONUS_RULE
                                      , CEILING_NAME
                                      , RECOVERABLE_COST
                                      , LAST_UPDATE_LOGIN
                                      , ADJUSTED_CAPACITY
                                      , FULLY_RSVD_REVALS_COUNTER
                                      , IDLED_FLAG
                                      , PERIOD_COUNTER_CAPITALIZED
                                      , PERIOD_COUNTER_FULLY_RESERVED
                                      , PERIOD_COUNTER_FULLY_RETIRED
                                      , PRODUCTION_CAPACITY
                                      , REVAL_AMORTIZATION_BASIS
                                      , REVAL_CEILING
                                      , UNIT_OF_MEASURE
                                      , UNREVALUED_COST
                                      , ANNUAL_DEPRN_ROUNDING_FLAG
                                      , PERCENT_SALVAGE_VALUE
                                      , ALLOWED_DEPRN_LIMIT
                                      , ALLOWED_DEPRN_LIMIT_AMOUNT
                                      , PERIOD_COUNTER_LIFE_COMPLETE
                                      , ADJUSTED_RECOVERABLE_COST
                                      , ANNUAL_ROUNDING_FLAG
                                      , GLOBAL_ATTRIBUTE1
                                      , GLOBAL_ATTRIBUTE2
                                      , GLOBAL_ATTRIBUTE3
                                      , GLOBAL_ATTRIBUTE4
                                      , GLOBAL_ATTRIBUTE5
                                      , GLOBAL_ATTRIBUTE6
                                      , GLOBAL_ATTRIBUTE7
                                      , GLOBAL_ATTRIBUTE8
                                      , GLOBAL_ATTRIBUTE9
                                      , GLOBAL_ATTRIBUTE10
                                      , GLOBAL_ATTRIBUTE11
                                      , GLOBAL_ATTRIBUTE12
                                      , GLOBAL_ATTRIBUTE13
                                      , GLOBAL_ATTRIBUTE14
                                      , GLOBAL_ATTRIBUTE15
                                      , GLOBAL_ATTRIBUTE16
                                      , GLOBAL_ATTRIBUTE17
                                      , GLOBAL_ATTRIBUTE18
                                      , GLOBAL_ATTRIBUTE19
                                      , GLOBAL_ATTRIBUTE20
                                      , GLOBAL_ATTRIBUTE_CATEGORY
                                      , EOFY_ADJ_COST
                                      , EOFY_FORMULA_FACTOR
                                      , SHORT_FISCAL_YEAR_FLAG
                                      , CONVERSION_DATE
                                      , ORIGINAL_DEPRN_START_DATE
                                      , REMAINING_LIFE1
                                      , REMAINING_LIFE2
                                      , OLD_ADJUSTED_COST
                                      , FORMULA_FACTOR
                                      , GROUP_ASSET_ID
                                      , SALVAGE_TYPE
                                      , DEPRN_LIMIT_TYPE
                                      , REDUCTION_RATE
                                      , REDUCE_ADDITION_FLAG
                                      , REDUCE_ADJUSTMENT_FLAG
                                      , REDUCE_RETIREMENT_FLAG
                                      , RECOGNIZE_GAIN_LOSS
                                      , RECAPTURE_RESERVE_FLAG
                                      , LIMIT_PROCEEDS_FLAG
                                      , TERMINAL_GAIN_LOSS
                                      , TRACKING_METHOD
                                      , EXCLUDE_FULLY_RSV_FLAG
                                      , EXCESS_ALLOCATION_OPTION
                                      , DEPRECIATION_OPTION
                                      , MEMBER_ROLLUP_FLAG
                                      , ALLOCATE_TO_FULLY_RSV_FLAG
                                      , ALLOCATE_TO_FULLY_RET_FLAG
                                      , TERMINAL_GAIN_LOSS_AMOUNT
                                      , CIP_COST
                                      , YTD_PROCEEDS
                                      , LTD_PROCEEDS
                                      , LTD_COST_OF_REMOVAL
                                      , EOFY_RESERVE
                                      , PRIOR_EOFY_RESERVE
                                      , EOP_ADJ_COST
                                      , EOP_FORMULA_FACTOR
                                      , EXCLUDE_PROCEEDS_FROM_BASIS
                                      , RETIREMENT_DEPRN_OPTION
                                      , TERMINAL_GAIN_LOSS_FLAG
                                      , SUPER_GROUP_ID
                                      , OVER_DEPRECIATE_OPTION
                                      , DISABLED_FLAG
                                      , SET_OF_BOOKS_ID
            ) SELECT BOOK_TYPE_CODE
                   , ASSET_ID
                   , DATE_PLACED_IN_SERVICE
                   , p_trans_rec.who_info.last_update_date -- DATE_EFFECTIVE
                   , DEPRN_START_DATE
                   , DEPRN_METHOD_CODE
                   , LIFE_IN_MONTHS
                   , RATE_ADJUSTMENT_FACTOR
                   , t_adjusted_cost(i) - t_adjustment_amount(i)
                   , COST
                   , ORIGINAL_COST
                   , SALVAGE_VALUE
                   , PRORATE_CONVENTION_CODE
                   , PRORATE_DATE
                   , COST_CHANGE_FLAG
                   , ADJUSTMENT_REQUIRED_STATUS
                   , CAPITALIZE_FLAG
                   , RETIREMENT_PENDING_FLAG
                   , DEPRECIATE_FLAG
                   , p_trans_rec.who_info.last_update_date -- LAST_UPDATE_DATE
                   , p_trans_rec.who_info.last_updated_by -- LAST_UPDATED_BY
                   , t_thid(i) -- TRANSACTION_HEADER_ID_IN
                   , ITC_AMOUNT_ID
                   , ITC_AMOUNT
                   , RETIREMENT_ID
                   , TAX_REQUEST_ID
                   , ITC_BASIS
                   , BASIC_RATE
                   , ADJUSTED_RATE
                   , BONUS_RULE
                   , CEILING_NAME
                   , RECOVERABLE_COST
                   , p_trans_rec.who_info.last_update_login -- LAST_UPDATE_LOGIN
                   , ADJUSTED_CAPACITY
                   , FULLY_RSVD_REVALS_COUNTER
                   , IDLED_FLAG
                   , PERIOD_COUNTER_CAPITALIZED
                   , PERIOD_COUNTER_FULLY_RESERVED
                   , PERIOD_COUNTER_FULLY_RETIRED
                   , PRODUCTION_CAPACITY
                   , REVAL_AMORTIZATION_BASIS
                   , REVAL_CEILING
                   , UNIT_OF_MEASURE
                   , UNREVALUED_COST
                   , ANNUAL_DEPRN_ROUNDING_FLAG
                   , PERCENT_SALVAGE_VALUE
                   , ALLOWED_DEPRN_LIMIT
                   , ALLOWED_DEPRN_LIMIT_AMOUNT
                   , PERIOD_COUNTER_LIFE_COMPLETE
                   , ADJUSTED_RECOVERABLE_COST
                   , ANNUAL_ROUNDING_FLAG
                   , GLOBAL_ATTRIBUTE1
                   , GLOBAL_ATTRIBUTE2
                   , GLOBAL_ATTRIBUTE3
                   , GLOBAL_ATTRIBUTE4
                   , GLOBAL_ATTRIBUTE5
                   , GLOBAL_ATTRIBUTE6
                   , GLOBAL_ATTRIBUTE7
                   , GLOBAL_ATTRIBUTE8
                   , GLOBAL_ATTRIBUTE9
                   , GLOBAL_ATTRIBUTE10
                   , GLOBAL_ATTRIBUTE11
                   , GLOBAL_ATTRIBUTE12
                   , GLOBAL_ATTRIBUTE13
                   , GLOBAL_ATTRIBUTE14
                   , GLOBAL_ATTRIBUTE15
                   , GLOBAL_ATTRIBUTE16
                   , GLOBAL_ATTRIBUTE17
                   , GLOBAL_ATTRIBUTE18
                   , GLOBAL_ATTRIBUTE19
                   , GLOBAL_ATTRIBUTE20
                   , GLOBAL_ATTRIBUTE_CATEGORY
                   , EOFY_ADJ_COST
                   , EOFY_FORMULA_FACTOR
                   , SHORT_FISCAL_YEAR_FLAG
                   , CONVERSION_DATE
                   , ORIGINAL_DEPRN_START_DATE
                   , REMAINING_LIFE1
                   , REMAINING_LIFE2
                   , OLD_ADJUSTED_COST
                   , FORMULA_FACTOR
                   , GROUP_ASSET_ID
                   , SALVAGE_TYPE
                   , DEPRN_LIMIT_TYPE
                   , REDUCTION_RATE
                   , REDUCE_ADDITION_FLAG
                   , REDUCE_ADJUSTMENT_FLAG
                   , REDUCE_RETIREMENT_FLAG
                   , RECOGNIZE_GAIN_LOSS
                   , RECAPTURE_RESERVE_FLAG
                   , LIMIT_PROCEEDS_FLAG
                   , TERMINAL_GAIN_LOSS
                   , TRACKING_METHOD
                   , EXCLUDE_FULLY_RSV_FLAG
                   , EXCESS_ALLOCATION_OPTION
                   , DEPRECIATION_OPTION
                   , MEMBER_ROLLUP_FLAG
                   , ALLOCATE_TO_FULLY_RSV_FLAG
                   , ALLOCATE_TO_FULLY_RET_FLAG
                   , TERMINAL_GAIN_LOSS_AMOUNT
                   , CIP_COST
                   , YTD_PROCEEDS
                   , LTD_PROCEEDS
                   , LTD_COST_OF_REMOVAL
                   , EOFY_RESERVE
                   , PRIOR_EOFY_RESERVE
                   , EOP_ADJ_COST
                   , EOP_FORMULA_FACTOR
                   , EXCLUDE_PROCEEDS_FROM_BASIS
                   , RETIREMENT_DEPRN_OPTION
                   , TERMINAL_GAIN_LOSS_FLAG
                   , SUPER_GROUP_ID
                   , OVER_DEPRECIATE_OPTION
                   , DISABLED_FLAG
                   , SET_OF_BOOKS_ID
              FROM  FA_MC_BOOKS
              WHERE TRANSACTION_HEADER_ID_IN = t_transaction_header_id_in(i)
                AND set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 6078

            UPDATE FA_BOOKS_SUMMARY
            SET    RESERVE_ADJUSTMENT_AMOUNT = RESERVE_ADJUSTMENT_AMOUNT + t_adjustment_amount(i)
                 , DEPRN_RESERVE = DEPRN_RESERVE + t_adjustment_amount(i)
                 , ADJUSTED_COST = RECOVERABLE_COST - DEPRN_RESERVE - t_adjustment_amount(i)
            WHERE  ASSET_ID = t_asset_id(i)
            AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
            AND    PERIOD_COUNTER = p_period_rec.period_counter;
Line: 6098

            UPDATE FA_BOOKS
            SET    DATE_INEFFECTIVE = p_trans_rec.who_info.last_update_date
                 , TRANSACTION_HEADER_ID_OUT = t_thid(i)
            WHERE  TRANSACTION_HEADER_ID_IN = t_transaction_header_id_in(i);
Line: 6103

         l_loc := 'Before primary Insert Books';
Line: 6106

            INSERT INTO FA_BOOKS( BOOK_TYPE_CODE
                                , ASSET_ID
                                , DATE_PLACED_IN_SERVICE
                                , DATE_EFFECTIVE
                                , DEPRN_START_DATE
                                , DEPRN_METHOD_CODE
                                , LIFE_IN_MONTHS
                                , RATE_ADJUSTMENT_FACTOR
                                , ADJUSTED_COST
                                , COST
                                , ORIGINAL_COST
                                , SALVAGE_VALUE
                                , PRORATE_CONVENTION_CODE
                                , PRORATE_DATE
                                , COST_CHANGE_FLAG
                                , ADJUSTMENT_REQUIRED_STATUS
                                , CAPITALIZE_FLAG
                                , RETIREMENT_PENDING_FLAG
                                , DEPRECIATE_FLAG
                                , LAST_UPDATE_DATE
                                , LAST_UPDATED_BY
                                , TRANSACTION_HEADER_ID_IN
                                , ITC_AMOUNT_ID
                                , ITC_AMOUNT
                                , RETIREMENT_ID
                                , TAX_REQUEST_ID
                                , ITC_BASIS
                                , BASIC_RATE
                                , ADJUSTED_RATE
                                , BONUS_RULE
                                , CEILING_NAME
                                , RECOVERABLE_COST
                                , LAST_UPDATE_LOGIN
                                , ADJUSTED_CAPACITY
                                , FULLY_RSVD_REVALS_COUNTER
                                , IDLED_FLAG
                                , PERIOD_COUNTER_CAPITALIZED
                                , PERIOD_COUNTER_FULLY_RESERVED
                                , PERIOD_COUNTER_FULLY_RETIRED
                                , PRODUCTION_CAPACITY
                                , REVAL_AMORTIZATION_BASIS
                                , REVAL_CEILING
                                , UNIT_OF_MEASURE
                                , UNREVALUED_COST
                                , ANNUAL_DEPRN_ROUNDING_FLAG
                                , PERCENT_SALVAGE_VALUE
                                , ALLOWED_DEPRN_LIMIT
                                , ALLOWED_DEPRN_LIMIT_AMOUNT
                                , PERIOD_COUNTER_LIFE_COMPLETE
                                , ADJUSTED_RECOVERABLE_COST
                                , ANNUAL_ROUNDING_FLAG
                                , GLOBAL_ATTRIBUTE1
                                , GLOBAL_ATTRIBUTE2
                                , GLOBAL_ATTRIBUTE3
                                , GLOBAL_ATTRIBUTE4
                                , GLOBAL_ATTRIBUTE5
                                , GLOBAL_ATTRIBUTE6
                                , GLOBAL_ATTRIBUTE7
                                , GLOBAL_ATTRIBUTE8
                                , GLOBAL_ATTRIBUTE9
                                , GLOBAL_ATTRIBUTE10
                                , GLOBAL_ATTRIBUTE11
                                , GLOBAL_ATTRIBUTE12
                                , GLOBAL_ATTRIBUTE13
                                , GLOBAL_ATTRIBUTE14
                                , GLOBAL_ATTRIBUTE15
                                , GLOBAL_ATTRIBUTE16
                                , GLOBAL_ATTRIBUTE17
                                , GLOBAL_ATTRIBUTE18
                                , GLOBAL_ATTRIBUTE19
                                , GLOBAL_ATTRIBUTE20
                                , GLOBAL_ATTRIBUTE_CATEGORY
                                , EOFY_ADJ_COST
                                , EOFY_FORMULA_FACTOR
                                , SHORT_FISCAL_YEAR_FLAG
                                , CONVERSION_DATE
                                , ORIGINAL_DEPRN_START_DATE
                                , REMAINING_LIFE1
                                , REMAINING_LIFE2
                                , OLD_ADJUSTED_COST
                                , FORMULA_FACTOR
                                , GROUP_ASSET_ID
                                , SALVAGE_TYPE
                                , DEPRN_LIMIT_TYPE
                                , REDUCTION_RATE
                                , REDUCE_ADDITION_FLAG
                                , REDUCE_ADJUSTMENT_FLAG
                                , REDUCE_RETIREMENT_FLAG
                                , RECOGNIZE_GAIN_LOSS
                                , RECAPTURE_RESERVE_FLAG
                                , LIMIT_PROCEEDS_FLAG
                                , TERMINAL_GAIN_LOSS
                                , TRACKING_METHOD
                                , EXCLUDE_FULLY_RSV_FLAG
                                , EXCESS_ALLOCATION_OPTION
                                , DEPRECIATION_OPTION
                                , MEMBER_ROLLUP_FLAG
                                , ALLOCATE_TO_FULLY_RSV_FLAG
                                , ALLOCATE_TO_FULLY_RET_FLAG
                                , TERMINAL_GAIN_LOSS_AMOUNT
                                , CIP_COST
                                , YTD_PROCEEDS
                                , LTD_PROCEEDS
                                , LTD_COST_OF_REMOVAL
                                , EOFY_RESERVE
                                , PRIOR_EOFY_RESERVE
                                , EOP_ADJ_COST
                                , EOP_FORMULA_FACTOR
                                , EXCLUDE_PROCEEDS_FROM_BASIS
                                , RETIREMENT_DEPRN_OPTION
                                , TERMINAL_GAIN_LOSS_FLAG
                                , SUPER_GROUP_ID
                                , OVER_DEPRECIATE_OPTION
                                , DISABLED_FLAG
            ) SELECT BOOK_TYPE_CODE
                   , ASSET_ID
                   , DATE_PLACED_IN_SERVICE
                   , p_trans_rec.who_info.last_update_date -- DATE_EFFECTIVE
                   , DEPRN_START_DATE
                   , DEPRN_METHOD_CODE
                   , LIFE_IN_MONTHS
                   , RATE_ADJUSTMENT_FACTOR
                   , t_adjusted_cost(i) - t_adjustment_amount(i) -- ADJUSTED_COST
                   , COST
                   , ORIGINAL_COST
                   , SALVAGE_VALUE
                   , PRORATE_CONVENTION_CODE
                   , PRORATE_DATE
                   , COST_CHANGE_FLAG
                   , ADJUSTMENT_REQUIRED_STATUS
                   , CAPITALIZE_FLAG
                   , RETIREMENT_PENDING_FLAG
                   , DEPRECIATE_FLAG
                   , p_trans_rec.who_info.last_update_date -- LAST_UPDATE_DATE
                   , p_trans_rec.who_info.last_updated_by -- LAST_UPDATED_BY
                   , t_thid(i) -- TRANSACTION_HEADER_ID_IN
                   , ITC_AMOUNT_ID
                   , ITC_AMOUNT
                   , RETIREMENT_ID
                   , TAX_REQUEST_ID
                   , ITC_BASIS
                   , BASIC_RATE
                   , ADJUSTED_RATE
                   , BONUS_RULE
                   , CEILING_NAME
                   , RECOVERABLE_COST
                   , p_trans_rec.who_info.last_update_login -- LAST_UPDATE_LOGIN
                   , ADJUSTED_CAPACITY
                   , FULLY_RSVD_REVALS_COUNTER
                   , IDLED_FLAG
                   , PERIOD_COUNTER_CAPITALIZED
                   , PERIOD_COUNTER_FULLY_RESERVED
                   , PERIOD_COUNTER_FULLY_RETIRED
                   , PRODUCTION_CAPACITY
                   , REVAL_AMORTIZATION_BASIS
                   , REVAL_CEILING
                   , UNIT_OF_MEASURE
                   , UNREVALUED_COST
                   , ANNUAL_DEPRN_ROUNDING_FLAG
                   , PERCENT_SALVAGE_VALUE
                   , ALLOWED_DEPRN_LIMIT
                   , ALLOWED_DEPRN_LIMIT_AMOUNT
                   , PERIOD_COUNTER_LIFE_COMPLETE
                   , ADJUSTED_RECOVERABLE_COST
                   , ANNUAL_ROUNDING_FLAG
                   , GLOBAL_ATTRIBUTE1
                   , GLOBAL_ATTRIBUTE2
                   , GLOBAL_ATTRIBUTE3
                   , GLOBAL_ATTRIBUTE4
                   , GLOBAL_ATTRIBUTE5
                   , GLOBAL_ATTRIBUTE6
                   , GLOBAL_ATTRIBUTE7
                   , GLOBAL_ATTRIBUTE8
                   , GLOBAL_ATTRIBUTE9
                   , GLOBAL_ATTRIBUTE10
                   , GLOBAL_ATTRIBUTE11
                   , GLOBAL_ATTRIBUTE12
                   , GLOBAL_ATTRIBUTE13
                   , GLOBAL_ATTRIBUTE14
                   , GLOBAL_ATTRIBUTE15
                   , GLOBAL_ATTRIBUTE16
                   , GLOBAL_ATTRIBUTE17
                   , GLOBAL_ATTRIBUTE18
                   , GLOBAL_ATTRIBUTE19
                   , GLOBAL_ATTRIBUTE20
                   , GLOBAL_ATTRIBUTE_CATEGORY
                   , EOFY_ADJ_COST
                   , EOFY_FORMULA_FACTOR
                   , SHORT_FISCAL_YEAR_FLAG
                   , CONVERSION_DATE
                   , ORIGINAL_DEPRN_START_DATE
                   , REMAINING_LIFE1
                   , REMAINING_LIFE2
                   , OLD_ADJUSTED_COST
                   , FORMULA_FACTOR
                   , GROUP_ASSET_ID
                   , SALVAGE_TYPE
                   , DEPRN_LIMIT_TYPE
                   , REDUCTION_RATE
                   , REDUCE_ADDITION_FLAG
                   , REDUCE_ADJUSTMENT_FLAG
                   , REDUCE_RETIREMENT_FLAG
                   , RECOGNIZE_GAIN_LOSS
                   , RECAPTURE_RESERVE_FLAG
                   , LIMIT_PROCEEDS_FLAG
                   , TERMINAL_GAIN_LOSS
                   , TRACKING_METHOD
                   , EXCLUDE_FULLY_RSV_FLAG
                   , EXCESS_ALLOCATION_OPTION
                   , DEPRECIATION_OPTION
                   , MEMBER_ROLLUP_FLAG
                   , ALLOCATE_TO_FULLY_RSV_FLAG
                   , ALLOCATE_TO_FULLY_RET_FLAG
                   , TERMINAL_GAIN_LOSS_AMOUNT
                   , CIP_COST
                   , YTD_PROCEEDS
                   , LTD_PROCEEDS
                   , LTD_COST_OF_REMOVAL
                   , EOFY_RESERVE
                   , PRIOR_EOFY_RESERVE
                   , EOP_ADJ_COST
                   , EOP_FORMULA_FACTOR
                   , EXCLUDE_PROCEEDS_FROM_BASIS
                   , RETIREMENT_DEPRN_OPTION
                   , TERMINAL_GAIN_LOSS_FLAG
                   , SUPER_GROUP_ID
                   , OVER_DEPRECIATE_OPTION
                   , DISABLED_FLAG
              FROM  FA_BOOKS
              WHERE TRANSACTION_HEADER_ID_IN = t_transaction_header_id_in(i);
Line: 6348

              p_trans_rec.who_info.last_update_date,
              p_trans_rec.who_info.last_updated_by,
              p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
         raise allocate_err;
Line: 6450

            UPDATE FA_MC_ADJUSTMENTS
            SET    ADJUSTMENT_AMOUNT = ADJUSTMENT_AMOUNT + l_reallocate_amount
            WHERE  ASSET_ID = l_last_asset_id
            AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
            AND    TRANSACTION_HEADER_ID = l_last_thid
            AND    DISTRIBUTION_ID = (SELECT MIN(DISTRIBUTION_ID)
                                      FROM   FA_MC_ADJUSTMENTS
                                      WHERE  ASSET_ID = l_last_asset_id
                                      AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
                                      AND    TRANSACTION_HEADER_ID = l_last_thid
                                      AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id)
            AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 6463

            UPDATE FA_MC_BOOKS_SUMMARY
            SET    RESERVE_ADJUSTMENT_AMOUNT = RESERVE_ADJUSTMENT_AMOUNT + ( l_reallocate_amount * sign(p_reserve_amount) * -1 )
                 , DEPRN_RESERVE = DEPRN_RESERVE + ( l_reallocate_amount * sign(p_reserve_amount) * -1 )
                 , ADJUSTED_COST = ADJUSTED_COST - ( l_reallocate_amount * sign(p_reserve_amount) * -1 )
            WHERE  ASSET_ID = l_last_asset_id
            AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
            AND    PERIOD_COUNTER = p_period_rec.period_counter
            AND    TRANSACTION_HEADER_ID_OUT IS NULL
            AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 6474

            UPDATE FA_MC_BOOKS
            SET    ADJUSTED_COST = ADJUSTED_COST - ( l_reallocate_amount * sign(p_reserve_amount) * -1 )
            WHERE  TRANSACTION_HEADER_ID_IN = l_last_thid
              AND  set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 6479

            UPDATE FA_ADJUSTMENTS
            SET    ADJUSTMENT_AMOUNT = ADJUSTMENT_AMOUNT + l_reallocate_amount
            WHERE  ASSET_ID = l_last_asset_id
            AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
            AND    TRANSACTION_HEADER_ID = l_last_thid
            AND    DISTRIBUTION_ID = (SELECT MIN(DISTRIBUTION_ID)
                                      FROM   FA_ADJUSTMENTS
                                      WHERE  ASSET_ID = l_last_asset_id
                                      AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
                                      AND    TRANSACTION_HEADER_ID = l_last_thid);
Line: 6490

            UPDATE FA_BOOKS_SUMMARY
            SET    RESERVE_ADJUSTMENT_AMOUNT = RESERVE_ADJUSTMENT_AMOUNT + ( l_reallocate_amount * sign(p_reserve_amount) * -1 )
                 , DEPRN_RESERVE = DEPRN_RESERVE + ( l_reallocate_amount * sign(p_reserve_amount) * -1 )
                 , ADJUSTED_COST = ADJUSTED_COST - ( l_reallocate_amount * sign(p_reserve_amount) * -1 )
            WHERE  ASSET_ID = l_last_asset_id
            AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
            AND    PERIOD_COUNTER = p_period_rec.period_counter
            AND    TRANSACTION_HEADER_ID_OUT IS NULL;
Line: 6500

            UPDATE FA_BOOKS
            SET    ADJUSTED_COST = ADJUSTED_COST - ( l_reallocate_amount * sign(p_reserve_amount) * -1 )
            WHERE  TRANSACTION_HEADER_ID_IN = l_last_thid;
Line: 6520

            t_thid.delete;
Line: 6521

            t_asset_id.delete;
Line: 6522

            t_adjusted_cost.delete;
Line: 6575

                        UPDATE FA_MC_ADJUSTMENTS
                        SET    ADJUSTMENT_AMOUNT = ADJUSTMENT_AMOUNT + l_reallocate_amount
                        WHERE  ASSET_ID = t_asset_id(i)
                        AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
                        AND    TRANSACTION_HEADER_ID = t_thid(i)
                        AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id
                        AND    DISTRIBUTION_ID = (SELECT MIN(DISTRIBUTION_ID)
                                                  FROM   FA_MC_ADJUSTMENTS
                                                  WHERE  ASSET_ID = t_asset_id(i)
                                                  AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
                                                  AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id
                                                  AND    TRANSACTION_HEADER_ID = t_thid(i));
Line: 6588

                        UPDATE FA_MC_BOOKS_SUMMARY
                        SET    RESERVE_ADJUSTMENT_AMOUNT = RESERVE_ADJUSTMENT_AMOUNT + (l_reallocate_amount * sign(p_reserve_amount) * -1)
                             , DEPRN_RESERVE = DEPRN_RESERVE + (l_reallocate_amount * sign(p_reserve_amount) * -1)
                             , ADJUSTED_COST = ADJUSTED_COST + l_reallocate_amount
                        WHERE  ASSET_ID = t_asset_id(i)
                        AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
                        AND    PERIOD_COUNTER = p_period_rec.period_counter
                        AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id
                        AND    TRANSACTION_HEADER_ID_OUT is null;
Line: 6599

                        UPDATE FA_MC_BOOKS
                        SET    ADJUSTED_COST = ADJUSTED_COST + l_reallocate_amount
                        WHERE  TRANSACTION_HEADER_ID_IN = t_thid(i)
                          AND  set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 6608

                        UPDATE FA_ADJUSTMENTS
                        SET    ADJUSTMENT_AMOUNT = ADJUSTMENT_AMOUNT + l_reallocate_amount
                        WHERE  ASSET_ID = t_asset_id(i)
                        AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
                        AND    TRANSACTION_HEADER_ID = t_thid(i)
                        AND    DISTRIBUTION_ID = (SELECT MIN(DISTRIBUTION_ID)
                                                  FROM   FA_ADJUSTMENTS
                                                  WHERE  ASSET_ID = t_asset_id(i)
                                                  AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
                                                  AND    TRANSACTION_HEADER_ID = t_thid(i));
Line: 6619

                        UPDATE FA_BOOKS_SUMMARY
                        SET    RESERVE_ADJUSTMENT_AMOUNT = RESERVE_ADJUSTMENT_AMOUNT + (l_reallocate_amount * sign(p_reserve_amount) * -1)
                             , DEPRN_RESERVE = DEPRN_RESERVE + (l_reallocate_amount * sign(p_reserve_amount) * -1)
                             , ADJUSTED_COST = ADJUSTED_COST + l_reallocate_amount
                        WHERE  ASSET_ID = t_asset_id(i)
                        AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
                        AND    PERIOD_COUNTER = p_period_rec.period_counter
                        AND    TRANSACTION_HEADER_ID_OUT is null;
Line: 6629

                        UPDATE FA_BOOKS
                        SET    ADJUSTED_COST = ADJUSTED_COST + l_reallocate_amount
                        WHERE  TRANSACTION_HEADER_ID_IN = t_thid(i);
Line: 6639

                        UPDATE FA_MC_ADJUSTMENTS
                        SET    ADJUSTMENT_AMOUNT = ADJUSTMENT_AMOUNT + t_adjusted_cost(i)
                        WHERE  ASSET_ID = t_asset_id(i)
                        AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
                        AND    TRANSACTION_HEADER_ID = t_thid(i)
                        AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id
                        AND    DISTRIBUTION_ID = (SELECT MIN(DISTRIBUTION_ID)
                                                  FROM   FA_MC_ADJUSTMENTS
                                                  WHERE  ASSET_ID = t_asset_id(i)
                                                  AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
                                                  AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id
                                                  AND    TRANSACTION_HEADER_ID = t_thid(i));
Line: 6652

                        UPDATE FA_MC_BOOKS_SUMMARY
                        SET    RESERVE_ADJUSTMENT_AMOUNT = RESERVE_ADJUSTMENT_AMOUNT + t_adjusted_cost(i)
                             , DEPRN_RESERVE = ADJUSTED_RECOVERABLE_COST
                             , ADJUSTED_COST = RECOVERABLE_COST - ADJUSTED_RECOVERABLE_COST
                        WHERE  ASSET_ID = t_asset_id(i)
                        AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
                        AND    set_of_books_id = p_asset_hdr_rec.set_of_books_id
                        AND    PERIOD_COUNTER = p_period_rec.period_counter;
Line: 6662

                        UPDATE FA_MC_BOOKS
                        SET    ADJUSTED_COST = RECOVERABLE_COST - ADJUSTED_RECOVERABLE_COST
                        WHERE  TRANSACTION_HEADER_ID_IN = t_thid(i)
                          AND  set_of_books_id = p_asset_hdr_rec.set_of_books_id;
Line: 6667

                        UPDATE FA_ADJUSTMENTS
                        SET    ADJUSTMENT_AMOUNT = ADJUSTMENT_AMOUNT + t_adjusted_cost(i)
                        WHERE  ASSET_ID = t_asset_id(i)
                        AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
                        AND    TRANSACTION_HEADER_ID = t_thid(i)
                        AND    DISTRIBUTION_ID = (SELECT MIN(DISTRIBUTION_ID)
                                                  FROM   FA_ADJUSTMENTS
                                                  WHERE  ASSET_ID = t_asset_id(i)
                                                  AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
                                                  AND    TRANSACTION_HEADER_ID = t_thid(i));
Line: 6678

                        UPDATE FA_BOOKS_SUMMARY
                        SET    RESERVE_ADJUSTMENT_AMOUNT = RESERVE_ADJUSTMENT_AMOUNT + t_adjusted_cost(i)
                             , DEPRN_RESERVE = ADJUSTED_RECOVERABLE_COST
                             , ADJUSTED_COST = RECOVERABLE_COST - ADJUSTED_RECOVERABLE_COST
                        WHERE  ASSET_ID = t_asset_id(i)
                        AND    BOOK_TYPE_CODE = p_asset_hdr_rec.book_type_code
                        AND    PERIOD_COUNTER = p_period_rec.period_counter;
Line: 6687

                        UPDATE FA_BOOKS
                        SET    ADJUSTED_COST = RECOVERABLE_COST - ADJUSTED_RECOVERABLE_COST
                        WHERE  TRANSACTION_HEADER_ID_IN = t_thid(i);
Line: 6751

   select distribution_id
   from   FA_DISTRIBUTION_HISTORY
   where  book_type_code = p_asset_hdr_rec.book_type_code
   and    asset_id = p_asset_hdr_rec.asset_id
   and    transaction_header_id_out = p_trans_rec.transaction_header_id;
Line: 6763

   l_adj.selection_thid          := 0;
Line: 6764

   l_adj.selection_retid         := 0;
Line: 6766

   l_adj.last_update_date        := p_trans_rec.who_info.last_update_date;
Line: 6767

   l_adj.selection_mode          := FA_ADJUST_TYPE_PKG.FA_AJ_SINGLE;
Line: 6826

                             p_trans_rec.who_info.last_update_date,
                             p_trans_rec.who_info.last_updated_by,
                             p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
            raise calc_err;
Line: 6835

   l_adj.selection_thid    := 0;
Line: 6837

   l_adj.selection_mode    := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
Line: 6841

                          p_trans_rec.who_info.last_update_date,
                          p_trans_rec.who_info.last_updated_by,
                          p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
         raise calc_err;