The following lines contain the word 'select', 'insert', 'update' or 'delete':
maj_select_statement varchar2(50);
min_select_statement varchar2(50);
spec_select_statement varchar2(50);
select_statement varchar2(15000);
select fcr.last_update_login into h_login_id
from fnd_concurrent_requests fcr
where fcr.request_id = h_request_id;
select category_flex_structure, location_flex_structure,asset_key_flex_structure
into h_cat_struct, h_loc_struct, h_assetkey_flex_structure
from fa_system_controls;
select period_open_date --Bug#9491496
into h_period1_pod
from fa_deprn_periods
where book_type_code = h_book and period_name = begin_period;
select count(*) into h_count
from fa_deprn_periods where period_name = end_period
and book_type_code = h_book;
select period_close_date --Bug#9491496
into h_period2_pcd
from fa_deprn_periods
where book_type_code = h_book and period_name = end_period;
select accounting_flex_structure, distribution_source_book
into h_acct_struct, h_dist_source_book
from fa_book_controls
where book_type_code = h_book;
select cur.precision into h_precision
from fa_book_controls bc, gl_sets_of_books sob, fnd_currencies cur
where bc.book_type_code = h_book
and sob.set_of_books_id = bc.set_of_books_id
and sob.currency_code = cur.currency_code;
select sob.chart_of_accounts_id,
sob.set_of_books_id,
substr(sob.currency_code,1,15),
substr(sob.name,1 ,80)
into h_chart_of_accounts_id,
h_set_of_books_id,
h_currency_code,
h_organization_name
from fa_book_controls bc, gl_sets_of_books sob, fnd_currencies cur
WHERE bc.book_type_code = h_book
AND sob.set_of_books_id = bc.set_of_books_id
AND sob.currency_code = cur.currency_code; -- Added set_of_books_id and currency_code to display those on report
maj_select_statement := fa_rx_flex_pkg.flex_sql(140,'CAT#', h_assetkey_flex_structure,'CAT','SELECT', 'BASED_CATEGORY');
min_select_statement := fa_rx_flex_pkg.flex_sql(140,'CAT#', h_assetkey_flex_structure,'CAT','SELECT', 'MINOR_CATEGORY');
min_select_statement := 'null';
spec_select_statement := fa_rx_flex_pkg.flex_sql(140,'CAT#', h_assetkey_flex_structure,'CAT','SELECT', cat_seg_num);
spec_select_statement := 'null';
'SELECT', 'BASED_CATEGORY') ||' >= :from_maj_cat or :from_maj_cat is NULL)';
'SELECT', 'BASED_CATEGORY') ||' <= :to_maj_cat or :to_maj_cat is NULL)';
'SELECT', 'MINOR_CATEGORY') ||' >= :from_min_cat or :from_min_cat is NULL)';
'SELECT', 'MINOR_CATEGORY') ||' <= :to_min_cat or :to_min_cat is NULL)';
'SELECT', 'MINOR_CATEGORY') ||' >= :from_min_cat or :from_min_cat is NULL)';
'SELECT', 'MINOR_CATEGORY') ||' <= :to_min_cat or :to_min_cat is NULL)';
'SELECT', cat_seg_num) ||' >= :from_cat_seg_val or :from_cat_seg_val is NULL)';
'SELECT', cat_seg_num) ||' <= :to_cat_seg_val or :to_cat_seg_val is NULL)';
'SELECT', 'FA_COST_CTR') ||' >= :from_cc or :from_cc is NULL)';
'SELECT', 'FA_COST_CTR') ||' <= :to_cc or :to_cc is NULL)';
select_statement := '
SELECT /*+ leading(th ad) use_nl(ad) index(FA_ADDITIONS_B_U1 )*/ --Bug# 7587861
dhcc.code_combination_id,
emp.full_name,
emp.employee_number,
loc.location_id,
cb.category_id,
decode(ah.asset_type,''CIP'',cb.cip_cost_acct,cb.asset_cost_acct),
cb.deprn_reserve_acct,
ad.inventorial,
ad.asset_number,
ad.description,
ad.serial_number,
ad.tag_number,
ret.date_retired,
decode(sign(dh.transaction_units),-1,-dh.transaction_units,dh.transaction_units),
th.transaction_header_id,
ROUND(decode(ret.units, NULL,
(decode(th.transaction_type_code, ''REINSTATEMENT'',
-ret.cost_retired, ret.cost_retired)
* (dh.units_assigned /ah.units)),
(decode(th.transaction_type_code, ''REINSTATEMENT'',
-ret.cost_retired, ret.cost_retired)
* -dh.transaction_units / ret.units)) ,:h_precision),
ROUND(decode(ret.units, NULL,
(decode(th.transaction_type_code, ''REINSTATEMENT'',
-ret.nbv_retired, ret.nbv_retired)
* (dh.units_assigned /ah.units)),
(decode(th.transaction_type_code, ''REINSTATEMENT'',
-ret.nbv_retired, ret.nbv_retired)
* -dh.transaction_units / ret.units)),:h_precision),
ROUND(decode(ret.units, NULL,
(decode(th.transaction_type_code, ''REINSTATEMENT'',
-ret.proceeds_of_sale, ret.proceeds_of_sale)
* (dh.units_assigned /ah.units)),
(decode(th.transaction_type_code, ''REINSTATEMENT'',
-ret.proceeds_of_sale, ret.proceeds_of_sale)
* -dh.transaction_units / ret.units)),:h_precision),
ROUND(decode(ret.units, NULL,
(decode(th.transaction_type_code, ''REINSTATEMENT'',
-ret.gain_loss_amount, ret.gain_loss_amount)
* (dh.units_assigned /ah.units)),
(decode(th.transaction_type_code, ''REINSTATEMENT'',
-ret.gain_loss_amount, ret.gain_loss_amount)
* -dh.transaction_units / ret.units)),:h_precision),
round(decode(ret.units, NULL,
(decode(th.transaction_type_code,''REINSTATEMENT'',
-ret.cost_of_removal, ret.cost_of_removal)
* (dh.units_assigned / ah.units)),
(decode(th.transaction_type_code, ''REINSTATEMENT'',
-ret.cost_of_removal, ret.cost_of_removal)
* -dh.transaction_units / ret.units)),:h_precision),
round(decode(ret.units, NULL,
(decode(th.transaction_type_code,''REINSTATEMENT'',
-ret.itc_recaptured, ret.itc_recaptured)
* (dh.units_assigned / ah.units)),
(decode(th.transaction_type_code, ''REINSTATEMENT'',
-ret.itc_recaptured, ret.itc_recaptured)
* -dh.transaction_units / ret.units)),:h_precision),
decode(th.transaction_type_code, ''REINSTATEMENT'', ''*'', ''PARTIAL RETIREMENT'',''P'',NULL),
books.date_placed_in_service,
dd.ytd_deprn,'||
maj_select_statement ||','||
min_select_statement ||','||
spec_select_statement ||'
FROM ' || from_clause || '
WHERE ' || where_clause;
fa_rx_util_pkg.debug('ret: ' || 'select_statement:' || select_statement);
open ret_lines for select_statement ;
open ret_lines for select_statement using
h_precision, -- select
h_precision,
h_precision,
h_precision,
h_precision,
h_precision,
h_period1_pod, -- where_clause
h_period2_pcd,
h_book,
h_book,
h_book,
h_dist_source_book,
h_book,
from_maj_cat, -- l_param_where
from_maj_cat,
to_maj_cat,
to_maj_cat,
from_min_cat,
from_min_cat,
to_min_cat,
to_min_cat,
from_cat_seg_val,
from_cat_seg_val,
to_cat_seg_val,
to_cat_seg_val,
from_cc,
from_cc,
to_cc,
to_cc,
from_asset_num,
from_asset_num,
to_asset_num,
to_asset_num;
h_mesg_name := 'FA_SHARED_INSERT_FAILED';
insert into fa_retire_rep_itf (
request_id, company, cost_Center, expense_acct,
location, category, cost_acct, reserve_acct,
asset_number, description, serial_number, tag_number,
date_retired, units_retired, cost_retired, nbv_retired,
proceeds_of_sale, gain_loss_amount, removal_cost,
itc_captured, flag, date_placed_in_service, inventorial,
employee_name, employee_number, transaction_header_id,
created_by, creation_date, last_updated_by,
last_update_date, last_update_login,
set_of_books_id, functional_currency_code,organization_name,
book_type_code,period_name,period_name_to,account_description,
cost_center_description,
deprn_reserve,
major_category,
major_category_desc,minor_category,minor_category_desc,
specified_category_seg,specified_cat_seg_desc) values (
request_id, h_acct_segs(h_bal_seg),
h_acct_segs(h_cc_seg), h_acct_segs(h_acct_seg),
h_concat_loc, h_concat_cat, h_cost_acct, h_reserve_acct,
h_asset_number, h_description, h_serial_number,
h_tag_number, h_date_retired, h_units,
h_cost_retired, h_nbv_retired, h_proceeds_of_sale,
h_gain_loss_amount, h_removal_cost, h_itc_captured,
h_flag, h_dpis, h_inventorial, h_emp_name, h_emp_number, h_trx_id,
user_id, sysdate, user_id, sysdate, h_login_id,
h_set_of_books_id, h_currency_code, h_organization_name,
h_book,h_period_name,h_period_name_to,h_account_desc,
h_cost_center_desc,
h_deprn_reserve,
h_maj_cat,h_maj_cat_desc,h_min_cat,
h_min_cat_desc,h_specified_cat,h_specified_cat_desc);
if h_mesg_name = 'FA_SHARED_INSERT_FAIL' then
fnd_message.set_token('TABLE','FA_RETIRE_REP_ITF',FALSE);