DBA Data[Home] [Help]

APPS.FA_QUERY_BALANCES_PKG SQL Statements

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

Line: 73

        select group_asset_id, member_rollup_flag
        from fa_books
        where asset_id = X_ASSET_ID
        and book_type_code = X_BOOK
        and transaction_header_id_out is null;
Line: 249

        SELECT NVL(SUM(DECODE(ADJ.DEBIT_CREDIT_FLAG,
                             'DR', ADJ.ADJUSTMENT_AMOUNT,
                             'CR', -1*ADJ.ADJUSTMENT_AMOUNT)), 0), 1
          INTO h_deprn_expense_adjs, h_dummy
          FROM FA_MC_ADJUSTMENTS ADJ
         WHERE ADJ.ASSET_ID               = x_adj_drs.asset_id
           AND ADJ.BOOK_TYPE_CODE         = x_adj_drs.book
           AND ADJ.PERIOD_COUNTER_CREATED = h_curr_period_counter
           AND ADJ.SOURCE_TYPE_CODE       = 'REVALUATION'
           AND ADJ.ADJUSTMENT_TYPE        = 'EXPENSE'
           AND ADJ.SET_OF_BOOKS_ID        = x_adj_drs.set_of_books_id;
Line: 261

        SELECT NVL(SUM(DECODE(ADJ.DEBIT_CREDIT_FLAG,
                             'DR', ADJ.ADJUSTMENT_AMOUNT,
                             'CR', -1*ADJ.ADJUSTMENT_AMOUNT)), 0), 1
          INTO h_deprn_expense_adjs, h_dummy
          FROM FA_MC_ADJUSTMENTS ADJ
         WHERE ADJ.ASSET_ID               = x_adj_drs.asset_id
           AND ADJ.BOOK_TYPE_CODE         = x_adj_drs.book
           AND ADJ.PERIOD_COUNTER_CREATED = h_curr_period_counter
           AND ADJ.SOURCE_TYPE_CODE       = 'REVALUATION'
           AND ADJ.ADJUSTMENT_TYPE        = 'EXPENSE'
           AND ADJ.DISTRIBUTION_ID        = x_adj_drs.dist_id
           AND ADJ.SET_OF_BOOKS_ID        = x_adj_drs.set_of_books_id;
Line: 276

        SELECT NVL(SUM(DECODE(ADJ.DEBIT_CREDIT_FLAG,
                             'DR', ADJ.ADJUSTMENT_AMOUNT,
                             'CR', -1*ADJ.ADJUSTMENT_AMOUNT)), 0), 1
          INTO h_deprn_expense_adjs, h_dummy
          FROM FA_ADJUSTMENTS ADJ
         WHERE ADJ.ASSET_ID               = x_adj_drs.asset_id
           AND ADJ.BOOK_TYPE_CODE         = x_adj_drs.book
           AND ADJ.PERIOD_COUNTER_CREATED = h_curr_period_counter
           AND ADJ.SOURCE_TYPE_CODE       = 'REVALUATION'
           AND ADJ.ADJUSTMENT_TYPE        = 'EXPENSE';
Line: 287

        SELECT NVL(SUM(DECODE(ADJ.DEBIT_CREDIT_FLAG,
                             'DR', ADJ.ADJUSTMENT_AMOUNT,
                             'CR', -1*ADJ.ADJUSTMENT_AMOUNT)), 0), 1
          INTO h_deprn_expense_adjs, h_dummy
          FROM FA_ADJUSTMENTS ADJ
         WHERE ADJ.ASSET_ID               = x_adj_drs.asset_id
           AND ADJ.BOOK_TYPE_CODE         = x_adj_drs.book
           AND ADJ.PERIOD_COUNTER_CREATED = h_curr_period_counter
           AND ADJ.SOURCE_TYPE_CODE       = 'REVALUATION'
           AND ADJ.ADJUSTMENT_TYPE        = 'EXPENSE'
           AND ADJ.DISTRIBUTION_ID        = x_adj_drs.dist_id;
Line: 449

    select dp.period_counter-1,
           count(*)
      into X_dpr_row.period_ctr,
           h_count
      from fa_deprn_periods dp,
           fa_transaction_headers th
     where dp.book_type_code = X_dpr_row.book
       and th.date_effective between
             dp.period_open_date and
             nvl(dp.period_close_date,to_date('31-12-4712','DD-MM-YYYY'))
       and th.transaction_header_id = X_transaction_header_id
     group by dp.period_counter-1;
Line: 741

         SELECT 0,
                DEPRN_RESERVE,
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, DEPRN_AMOUNT,
                               0)),
                NVL(REVAL_RESERVE, 0),
                DECODE (FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                        h_fy, YTD_DEPRN,
                        0),
                DECODE (FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                        h_fy, NVL(YTD_REVAL_DEPRN_EXPENSE, 0),
                        0),
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, NVL(REVAL_DEPRN_EXPENSE, 0),
                               0)),
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, NVL(REVAL_AMORTIZATION, 0),
                               0)),
                NVL(BONUS_DEPRN_RESERVE,0),
                DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, BONUS_YTD_DEPRN,
                       0),
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, BONUS_DEPRN_AMOUNT,
                               0)),
                NVL(impairment_reserve,0),
                DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, YTD_IMPAIRMENT,
                       0),
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, IMPAIRMENT_AMOUNT,
                               0)),
                PERIOD_COUNTER,
                NVL(PRODUCTION, 0),
                DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, NVL(YTD_PRODUCTION, 0),
                       0),
                NVL(LTD_PRODUCTION, 0),
                ADJUSTED_COST,
                NVL(REVAL_AMORTIZATION_BASIS, 0),
                NVL(BONUS_RATE, 0),
                DEPRN_SOURCE_CODE,
                0,
                NVL(PRIOR_FY_EXPENSE, 0),
                NVL(PRIOR_FY_BONUS_EXPENSE, 0),
                NVL(CAPITAL_ADJUSTMENT,0), --Bug 6666666
                NVL(GENERAL_FUND,0),        --Bug 6666666
		NVL(REVAL_LOSS_BALANCE,0)
           FROM FA_MC_DEPRN_SUMMARY DS
          WHERE DS.ASSET_ID             =  X_dpr_row.asset_id
            AND DS.BOOK_TYPE_CODE       =  X_dpr_row.book
            AND DS.PERIOD_COUNTER      <= h_period_counter
            AND DS.SET_OF_BOOKS_ID      =  X_dpr_row.set_of_books_id
         ORDER BY PERIOD_COUNTER DESC;
Line: 808

         SELECT 0,
                DEPRN_RESERVE,
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, DEPRN_AMOUNT,
                               0)),
                NVL(REVAL_RESERVE, 0),
/* Bug# 6353715     DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, YTD_DEPRN,
                       0),*/
                DECODE(FLOOR(
                       DECODE(deprn_source_code
                             ,'BOOKS',PERIOD_COUNTER
                                     , (PERIOD_COUNTER - 1))/ h_num_pers_fy),
                       h_fy, YTD_DEPRN,
                       0),
                DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, NVL(YTD_REVAL_DEPRN_EXPENSE, 0),
                       0),
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, NVL(REVAL_DEPRN_EXPENSE, 0),
                               0)),
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, NVL(REVAL_AMORTIZATION, 0),
                               0)),
                NVL(BONUS_DEPRN_RESERVE,0),
                DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, BONUS_YTD_DEPRN,
                       0),
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, BONUS_DEPRN_AMOUNT,
                               0)),
                NVL(impairment_reserve,0),
                DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, YTD_IMPAIRMENT,
                       0),
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, IMPAIRMENT_AMOUNT,
                               0)),
                PERIOD_COUNTER,
                NVL(PRODUCTION, 0),
                DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, NVL(YTD_PRODUCTION, 0),
                       0),
                NVL(LTD_PRODUCTION, 0),
                ADJUSTED_COST,
                NVL(REVAL_AMORTIZATION_BASIS, 0),
                NVL(BONUS_RATE, 0),
                DEPRN_SOURCE_CODE,
                0,
                NVL(PRIOR_FY_EXPENSE, 0),
                NVL(PRIOR_FY_BONUS_EXPENSE, 0),
                NVL(CAPITAL_ADJUSTMENT,0), --Bug 6666666
                NVL(GENERAL_FUND,0),        --Bug 6666666
		NVL(REVAL_LOSS_BALANCE,0)
           FROM FA_DEPRN_SUMMARY DS
          WHERE DS.ASSET_ID             =  X_dpr_row.asset_id
            AND DS.BOOK_TYPE_CODE       =  X_dpr_row.book
            AND DS.PERIOD_COUNTER       <= h_period_counter
         ORDER BY PERIOD_COUNTER DESC;
Line: 881

         SELECT 0,
                sum(DEPRN_RESERVE),
                sum(decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, DEPRN_AMOUNT,
                               0))),
                sum(NVL(REVAL_RESERVE, 0)),
                sum(DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, YTD_DEPRN,
                       0)),
                sum(DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, NVL(YTD_REVAL_DEPRN_EXPENSE, 0),
                       0)),
                sum(decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, NVL(REVAL_DEPRN_EXPENSE, 0),
                               0))),
                sum(decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, NVL(REVAL_AMORTIZATION, 0),
                               0))),
                sum(NVL(BONUS_DEPRN_RESERVE,0)),
                sum(DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, BONUS_YTD_DEPRN,
                       0)),
                sum(decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, BONUS_DEPRN_AMOUNT,
                               0))),
                sum(NVL(impairment_reserve,0)),       -- bug 5951733 (added sum function)
                sum(DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy), -- bug 5951733 (added sum function)
                       h_fy, YTD_IMPAIRMENT,
                       0)),
                sum(decode (X_RUN_MODE,               -- bug 5951733 (added sum function)
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, IMPAIRMENT_AMOUNT,
                               0))),
                max(PERIOD_COUNTER), -- Bug#6350172
                sum(NVL(PRODUCTION, 0)),
                sum(DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, NVL(YTD_PRODUCTION, 0),
                       0)),
                sum(NVL(LTD_PRODUCTION, 0)),
                sum(ADJUSTED_COST),
                sum(NVL(REVAL_AMORTIZATION_BASIS, 0)),
                sum(NVL(BONUS_RATE, 0)),
                'DEPRN' DEPRN_SOURCE_CODE,
                0,
                sum(NVL(PRIOR_FY_EXPENSE, 0)),
                sum(NVL(PRIOR_FY_BONUS_EXPENSE, 0)),
                sum(NVL(CAPITAL_ADJUSTMENT,0)), --Bug 6666666
                sum(NVL(GENERAL_FUND,0))        --Bug 6666666
           FROM FA_MC_DEPRN_SUMMARY DS
          WHERE DS.ASSET_ID             in (select bk.asset_id
                                            from   fa_books bk
                                            where bk.book_type_code = x_dpr_row.book
                                            and   bk.transaction_header_id_out is null
                                            and    bk.group_asset_id = x_dpr_row.asset_id)
            AND DS.BOOK_TYPE_CODE       =  X_dpr_row.book
            AND DS.SET_OF_BOOKS_ID      =  X_dpr_row.set_of_books_id
            -- Bug#6350172: Modified query to fetch correct reserve values
            AND DS.PERIOD_COUNTER = ( select max(period_counter) from fa_mc_deprn_summary
                                      where asset_id = ds.asset_id
                                      and book_type_code = X_dpr_row.book
                                      and set_of_books_id = X_dpr_row.set_of_books_id);
Line: 954

         SELECT 0,
                sum(DEPRN_RESERVE),
                sum(decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, DEPRN_AMOUNT,
                               0))),
                sum(NVL(REVAL_RESERVE, 0)),
                sum(DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, YTD_DEPRN,
                       0)),
                sum(DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, NVL(YTD_REVAL_DEPRN_EXPENSE, 0),
                       0)),
                sum(decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, NVL(REVAL_DEPRN_EXPENSE, 0),
                               0))),
                sum(decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, NVL(REVAL_AMORTIZATION, 0),
                               0))),
                sum(NVL(BONUS_DEPRN_RESERVE,0)),
                sum(DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, BONUS_YTD_DEPRN,
                       0)),
                sum(decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, BONUS_DEPRN_AMOUNT,
                               0))),
                sum(NVL(impairment_reserve,0)),         -- bug 5951733 (added sum function)
                sum(DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),    -- bug 5951733 (added sum function)
                       h_fy, YTD_IMPAIRMENT,
                       0)),
                sum(decode (X_RUN_MODE,            -- bug 5951733 (added sum function)
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, IMPAIRMENT_AMOUNT,
                               0))),
                max(PERIOD_COUNTER), -- Bug#6350172
                sum(NVL(PRODUCTION, 0)),
                sum(DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, NVL(YTD_PRODUCTION, 0),
                       0)),
                sum(NVL(LTD_PRODUCTION, 0)),
                sum(ADJUSTED_COST),
                sum(NVL(REVAL_AMORTIZATION_BASIS, 0)),
                sum(NVL(BONUS_RATE, 0)),
                'DEPRN' DEPRN_SOURCE_CODE,
                0,
                sum(NVL(PRIOR_FY_EXPENSE, 0)),
                sum(NVL(PRIOR_FY_BONUS_EXPENSE, 0)),
                sum(NVL(CAPITAL_ADJUSTMENT,0)), --Bug 6666666
                sum(NVL(GENERAL_FUND,0))        --Bug 6666666
           FROM FA_DEPRN_SUMMARY DS
          WHERE DS.ASSET_ID             in (select bk.asset_id
                                            from   fa_books bk
                                            where bk.book_type_code = x_dpr_row.book
                                            and   bk.transaction_header_id_out is null
                                            and    bk.group_asset_id = x_dpr_row.asset_id)
            AND DS.BOOK_TYPE_CODE       =  X_dpr_row.book
            -- Bug#6350172: Modified query to fetch correct reserve values
            AND DS.PERIOD_COUNTER = ( select max(period_counter) from fa_deprn_summary
                                      where asset_id = ds.asset_id and book_type_code = X_dpr_row.book );
Line: 1065

         select fiscal_year
         into h_fy
         from fa_deprn_periods
         where book_type_code = X_dpr_row.book
               and period_counter = h_period_counter;
Line: 1455

         SELECT NVL(COST, 0),
                DEPRN_RESERVE,
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, DEPRN_AMOUNT,
                               0)),
                NVL(REVAL_RESERVE, 0),
                DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, YTD_DEPRN,
                       0),
                DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, NVL(YTD_REVAL_DEPRN_EXPENSE, 0),
                       0),
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, NVL(REVAL_DEPRN_EXPENSE, 0),
                               0)),
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, NVL(REVAL_AMORTIZATION, 0),
                               0)),
                NVL(BONUS_DEPRN_RESERVE,0),
                DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, BONUS_YTD_DEPRN,
                       0),
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, BONUS_DEPRN_AMOUNT,
                               0)),
                NVL(impairment_reserve,0),
                DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, YTD_IMPAIRMENT,
                       0),
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, IMPAIRMENT_AMOUNT,
                               0)),
                PERIOD_COUNTER,
                NVL(ADDITION_COST_TO_CLEAR, 0),
                DECODE(ADDITION_COST_TO_CLEAR,
                       NULL, 1,
                       0),
                NVL(CAPITAL_ADJUSTMENT,0),  -- Bug 6666666
                NVL(GENERAL_FUND,0)         -- Bug 6666666
           FROM FA_MC_DEPRN_DETAIL DD
          WHERE DD.ASSET_ID         = X_dpr_row.asset_id
            AND DD.BOOK_TYPE_CODE   = X_dpr_row.book
            AND DD.PERIOD_COUNTER  <= h_period_counter
            AND DD.DISTRIBUTION_ID  = X_dpr_row.dist_id
            AND DD.SET_OF_BOOKS_ID  = x_dpr_row.set_of_books_id
          ORDER BY PERIOD_COUNTER DESC;
Line: 1513

         SELECT NVL(COST, 0),
                DEPRN_RESERVE,
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, DEPRN_AMOUNT,
                               0)),
                NVL(REVAL_RESERVE, 0),
                DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, YTD_DEPRN,
                       0),
                DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, NVL(YTD_REVAL_DEPRN_EXPENSE, 0),
                       0),
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, NVL(REVAL_DEPRN_EXPENSE, 0),
                               0)),
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, NVL(REVAL_AMORTIZATION, 0),
                               0)),
                NVL(BONUS_DEPRN_RESERVE,0),
                DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, BONUS_YTD_DEPRN,
                       0),
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, BONUS_DEPRN_AMOUNT,
                               0)),
                NVL(impairment_reserve,0),
                DECODE(FLOOR((PERIOD_COUNTER - 1) / h_num_pers_fy),
                       h_fy, YTD_IMPAIRMENT,
                       0),
                decode (X_RUN_MODE,
                        'DEPRN', 0,
                        DECODE(PERIOD_COUNTER,
                               h_period_counter, IMPAIRMENT_AMOUNT,
                               0)),
                PERIOD_COUNTER,
                NVL(ADDITION_COST_TO_CLEAR, 0),
                DECODE(ADDITION_COST_TO_CLEAR,
                       NULL, 1,
                       0),
                NVL(CAPITAL_ADJUSTMENT,0),  -- Bug 6666666
                NVL(GENERAL_FUND,0)         -- Bug 6666666
           FROM FA_DEPRN_DETAIL DD
          WHERE DD.ASSET_ID         = X_dpr_row.asset_id
            AND DD.BOOK_TYPE_CODE   = X_dpr_row.book
            AND DD.PERIOD_COUNTER  <= h_period_counter
            AND DD.DISTRIBUTION_ID  = X_dpr_row.dist_id
          ORDER BY PERIOD_COUNTER DESC;
Line: 1612

         select fiscal_year
         into h_fy
         from fa_deprn_periods
         where book_type_code = X_dpr_row.book
               and period_counter = h_period_counter;
Line: 1853

        SELECT NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'COST',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR',-1*ADJ.ADJUSTMENT_AMOUNT),
                              'CIP COST',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR',-1*ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'RESERVE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                 'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'EXPENSE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'BONUS RESERVE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                 'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'BONUS EXPENSE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'IMPAIR RESERVE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                 'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'IMPAIR EXPENSE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT),
                           'LINK IMPAIR EXP',
                            DECODE(ADJ.DEBIT_CREDIT_FLAG,  /*For Bug 7460979, we need to Consider LINK IMP EXP while calculating YTD_IMPAIRMENT*/
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'DEPRN ADJUST',
                              DECODE(h_book_class,'TAX',
                                     DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT)))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'REVAL EXPENSE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                 'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'REVAL AMORT',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                          'REVAL RESERVE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                          'ASSET CLEARING',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                          'CIP CLEARING',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,             -- Bug 6666666
                          'CAPITAL ADJ',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,             -- Bug 6666666
                          'GENERAL FUND',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'CR', ADJ.ADJUSTMENT_AMOUNT,
                                     'DR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               COUNT(*)
          INTO X_ADJ_ROW.cost,
               X_ADJ_ROW.deprn_rsv,
               X_ADJ_ROW.deprn_exp,
               X_ADJ_ROW.bonus_deprn_rsv,
               X_ADJ_ROW.bonus_deprn_amount,
               X_ADJ_ROW.impairment_rsv,
               X_ADJ_ROW.impairment_amount,
               X_ADJ_ROW.deprn_adjust_exp,
               X_ADJ_ROW.reval_deprn_exp,
               X_ADJ_ROW.reval_amo,
               X_ADJ_ROW.reval_rsv,
               h_asset_clearing_adjs,
               h_cip_clearing_adjs,
               X_ADJ_ROW.capital_adjustment, --Bug 6666666
               X_ADJ_ROW.general_fund,       --Bug 6666666
               h_num_adjs
          FROM FA_MC_ADJUSTMENTS ADJ
         WHERE ADJ.ASSET_ID in (select bk.asset_id
                                from   fa_mc_books bk
                                where  bk.book_type_code = x_adj_row.book
                                and    bk.transaction_header_id_out is null
                                and    bk.group_asset_id = x_adj_row.asset_id
                                and    bk.set_of_books_id = x_adj_row.set_of_books_id) AND
               ADJ.BOOK_TYPE_CODE =  X_ADJ_ROW.book AND
               ADJ.PERIOD_COUNTER_CREATED > X_found_per_ctr AND
               DECODE(h_book_class,
                      'TAX', ADJ.PERIOD_COUNTER_ADJUSTED,
                      ADJ.PERIOD_COUNTER_CREATED)
                   <= X_ADJ_ROW.period_ctr AND
               DECODE(X_transaction_header_id,-1,transaction_header_id,
                      X_transaction_header_id) >= transaction_header_id AND
               ADJ.DISTRIBUTION_ID =
                   DECODE(X_ADJ_ROW.dist_id,
                          0, ADJ.DISTRIBUTION_ID,
                          X_ADJ_ROW.dist_id) AND
               ADJ.SET_OF_BOOKS_ID = X_ADJ_ROW.set_of_books_id;
Line: 1992

        SELECT NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'COST',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR',-1*ADJ.ADJUSTMENT_AMOUNT),
                              'CIP COST',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR',-1*ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'RESERVE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                 'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'EXPENSE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'BONUS RESERVE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                 'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'BONUS EXPENSE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'IMPAIR RESERVE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                 'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'IMPAIR EXPENSE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT),
                           'LINK IMPAIR EXP',
                            DECODE(ADJ.DEBIT_CREDIT_FLAG,  /*For Bug 7460979, we need to Consider LINK IMP EXP while calculating YTD_IMPAIRMENT*/
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'DEPRN ADJUST',
                              DECODE(h_book_class,'TAX',
                                     DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT)))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'REVAL EXPENSE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                 'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'REVAL AMORT',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                          'REVAL RESERVE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                          'ASSET CLEARING',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                          'CIP CLEARING',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,             -- Bug 6666666
                          'CAPITAL ADJ',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,             -- Bug 6666666
                          'GENERAL FUND',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'CR', ADJ.ADJUSTMENT_AMOUNT,
                                     'DR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               COUNT(*)
          INTO X_ADJ_ROW.cost,
               X_ADJ_ROW.deprn_rsv,
               X_ADJ_ROW.deprn_exp,
               X_ADJ_ROW.bonus_deprn_rsv,
               X_ADJ_ROW.bonus_deprn_amount,
               X_ADJ_ROW.impairment_rsv,
               X_ADJ_ROW.impairment_amount,
               X_ADJ_ROW.deprn_adjust_exp,
               X_ADJ_ROW.reval_deprn_exp,
               X_ADJ_ROW.reval_amo,
               X_ADJ_ROW.reval_rsv,
               h_asset_clearing_adjs,
               h_cip_clearing_adjs,
               X_ADJ_ROW.capital_adjustment, --Bug 6666666
               X_ADJ_ROW.general_fund,       --Bug 6666666
               h_num_adjs
          FROM FA_ADJUSTMENTS ADJ
         WHERE ADJ.ASSET_ID in (select bk.asset_id
                                from   fa_books bk
                                where bk.book_type_code = x_adj_row.book
                                and   bk.transaction_header_id_out is null
                                and    bk.group_asset_id = x_adj_row.asset_id) AND
               ADJ.BOOK_TYPE_CODE =  X_ADJ_ROW.book AND
               ADJ.PERIOD_COUNTER_CREATED > X_found_per_ctr AND
               DECODE(h_book_class,
                      'TAX', ADJ.PERIOD_COUNTER_ADJUSTED,
                      ADJ.PERIOD_COUNTER_CREATED)
                   <= X_ADJ_ROW.period_ctr AND
               DECODE(X_transaction_header_id,-1,transaction_header_id,
                      X_transaction_header_id) >= transaction_header_id AND
               ADJ.DISTRIBUTION_ID =
                   DECODE(X_ADJ_ROW.dist_id,
                          0, ADJ.DISTRIBUTION_ID,
                          X_ADJ_ROW.dist_id);
Line: 2132

        SELECT NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'COST',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR',-1*ADJ.ADJUSTMENT_AMOUNT),
                              'CIP COST',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR',-1*ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'RESERVE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                 'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'EXPENSE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'BONUS RESERVE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                 'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'BONUS EXPENSE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               /*8520733 to return correct impairment reserve*/
               NVL(SUM(DECODE(ADJ.source_type_code,
                              'DEPRECIATION',
                              DECODE(ADJ.ADJUSTMENT_TYPE,
                                     'IMPAIR EXPENSE',
                                     DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                            'CR', ADJ.ADJUSTMENT_AMOUNT,
                                            'DR', -1 * ADJ.ADJUSTMENT_AMOUNT),0),
                              DECODE(ADJ.ADJUSTMENT_TYPE,
                              'IMPAIR RESERVE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT)))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'IMPAIR EXPENSE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT),
                           'LINK IMPAIR EXP',
                            DECODE(ADJ.DEBIT_CREDIT_FLAG,  /*For Bug 7460979, we need to Consider LINK IMP EXP while calculating YTD_IMPAIRMENT*/
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'DEPRN ADJUST',
                              DECODE(h_book_class,'TAX',
                                     DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT)))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'REVAL EXPENSE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                 'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'REVAL AMORT',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                          'REVAL RESERVE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                          'ASSET CLEARING',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                          'CIP CLEARING',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,             -- Bug 6666666
                          'CAPITAL ADJ',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,             -- Bug 6666666
                          'GENERAL FUND',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'CR', ADJ.ADJUSTMENT_AMOUNT,
                                     'DR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                          'REVAL LOSS',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               COUNT(*)
          INTO X_ADJ_ROW.cost,
               X_ADJ_ROW.deprn_rsv,
               X_ADJ_ROW.deprn_exp,
               X_ADJ_ROW.bonus_deprn_rsv,
               X_ADJ_ROW.bonus_deprn_amount,
               X_ADJ_ROW.impairment_rsv,
               X_ADJ_ROW.impairment_amount,
               X_ADJ_ROW.deprn_adjust_exp,
               X_ADJ_ROW.reval_deprn_exp,
               X_ADJ_ROW.reval_amo,
               X_ADJ_ROW.reval_rsv,
               h_asset_clearing_adjs,
               h_cip_clearing_adjs,
               X_ADJ_ROW.capital_adjustment, --Bug 6666666
               X_ADJ_ROW.general_fund,       --Bug 6666666
	       X_ADJ_ROW.reval_loss_balance,
               h_num_adjs
          FROM FA_MC_ADJUSTMENTS ADJ
         WHERE ADJ.ASSET_ID = X_ADJ_ROW.asset_id AND
               ADJ.BOOK_TYPE_CODE =  X_ADJ_ROW.book AND
               ADJ.PERIOD_COUNTER_CREATED > X_found_per_ctr AND
               DECODE(h_book_class,
                      'TAX', ADJ.PERIOD_COUNTER_ADJUSTED,
                      ADJ.PERIOD_COUNTER_CREATED)
                   <= X_ADJ_ROW.period_ctr AND
               DECODE(X_transaction_header_id,-1,transaction_header_id,
                      X_transaction_header_id) >= transaction_header_id AND
               ADJ.DISTRIBUTION_ID =
                   DECODE(X_ADJ_ROW.dist_id,
                          0, ADJ.DISTRIBUTION_ID,
                          X_ADJ_ROW.dist_id) AND
               ADJ.SET_OF_BOOKS_ID = X_ADJ_ROW.set_of_books_id;
Line: 2281

        SELECT NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'COST',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR',-1*ADJ.ADJUSTMENT_AMOUNT),
                              'CIP COST',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR',-1*ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'RESERVE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                 'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'EXPENSE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'BONUS RESERVE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                 'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'BONUS EXPENSE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               /*8520733 to return correct impairment reserve*/
               NVL(SUM(DECODE(ADJ.source_type_code,
                              'DEPRECIATION',
                              DECODE(ADJ.ADJUSTMENT_TYPE,
                                     'IMPAIR EXPENSE',
                                     DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                            'CR', ADJ.ADJUSTMENT_AMOUNT,
                                            'DR', -1 * ADJ.ADJUSTMENT_AMOUNT),0),
                              DECODE(ADJ.ADJUSTMENT_TYPE,
                              'IMPAIR RESERVE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT)))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'IMPAIR EXPENSE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT),
                           'LINK IMPAIR EXP',
                            DECODE(ADJ.DEBIT_CREDIT_FLAG,  /*For Bug 7460979, we need to Consider LINK IMP EXP while calculating YTD_IMPAIRMENT*/
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'DEPRN ADJUST',
                              DECODE(h_book_class,'TAX',
                                     DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT)))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'REVAL EXPENSE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                 'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                              'REVAL AMORT',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                          'REVAL RESERVE',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                          'ASSET CLEARING',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                          'CIP CLEARING',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,             -- Bug 6666666
                          'CAPITAL ADJ',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,             -- Bug 6666666
                          'GENERAL FUND',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'CR', ADJ.ADJUSTMENT_AMOUNT,
                                     'DR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               NVL(SUM(DECODE(ADJ.ADJUSTMENT_TYPE,
                          'REVAL LOSS',
                              DECODE(ADJ.DEBIT_CREDIT_FLAG,
                                     'DR', ADJ.ADJUSTMENT_AMOUNT,
                                     'CR', -1 * ADJ.ADJUSTMENT_AMOUNT))),
                   0),
               COUNT(*)
          INTO X_ADJ_ROW.cost,
               X_ADJ_ROW.deprn_rsv,
               X_ADJ_ROW.deprn_exp,
               X_ADJ_ROW.bonus_deprn_rsv,
               X_ADJ_ROW.bonus_deprn_amount,
               X_ADJ_ROW.impairment_rsv,
               X_ADJ_ROW.impairment_amount,
               X_ADJ_ROW.deprn_adjust_exp,
               X_ADJ_ROW.reval_deprn_exp,
               X_ADJ_ROW.reval_amo,
               X_ADJ_ROW.reval_rsv,
               h_asset_clearing_adjs,
               h_cip_clearing_adjs,
               X_ADJ_ROW.capital_adjustment, --Bug 6666666
               X_ADJ_ROW.general_fund,       --Bug 6666666
	       X_ADJ_ROW.reval_loss_balance,
               h_num_adjs
          FROM FA_ADJUSTMENTS ADJ
         WHERE ADJ.ASSET_ID =  X_ADJ_ROW.asset_id AND
               ADJ.BOOK_TYPE_CODE =  X_ADJ_ROW.book AND
               ADJ.PERIOD_COUNTER_CREATED > X_found_per_ctr AND
               DECODE(h_book_class,
                      'TAX', ADJ.PERIOD_COUNTER_ADJUSTED,
                      ADJ.PERIOD_COUNTER_CREATED)
                   <= X_ADJ_ROW.period_ctr AND
               DECODE(X_transaction_header_id,-1,transaction_header_id,
                      X_transaction_header_id) >= transaction_header_id AND
               ADJ.DISTRIBUTION_ID =
                   DECODE(X_ADJ_ROW.dist_id,
                          0, ADJ.DISTRIBUTION_ID,
                          X_ADJ_ROW.dist_id);