[Home] [Help]
408:
409: error varchar2(100);
410: BEGIN
411:
412: insert into fa_mass_ext_retirements
413: (batch_name,
414: mass_external_retire_id,
415: book_type_code,
416: review_status,
434: )
435: VALUES
436: (
437: g_batch_name,
438: fa_mass_ext_retirements_s.nextval,
439: g_book_type_code,
440: 'POST',
441: p_asset_id,
442: 'YES', -- calc_gain_loss_flag
1111: mer.mass_external_retire_id,
1112: mer.code_combination_id,
1113: mer.location_id,
1114: mer.assigned_to
1115: From fa_mass_ext_retirements mer,
1116: fa_books bk,
1117: fa_additions ad
1118: Where mer.batch_name = G_batch_name -- current batch
1119: And mer.asset_id = bk.asset_id
1298:
1299:
1300: cursor c_mer is
1301: select units
1302: from fa_mass_ext_retirements
1303: where book_type_code = G_book_type_code
1304: and asset_id = l_asset_id
1305: and review_status = 'POST'
1306: and units is not null
1375: fa_debug_pkg.add(l_calling_fn, 'In aurec-loop: mer_units',aurec.mer_units
1376: ,p_log_level_rec => p_log_level_rec);
1377: end if;
1378:
1379: -- this solution assumes that units are entered in fa_mass_ext_retirements records.(verified ok).
1380:
1381: if l_asset_id <> aurec.asset_id then
1382:
1383: l_asset_id := aurec.asset_id;
1404: end if;
1405:
1406: l_remaining_units := l_remaining_units - aurec.mer_units;
1407:
1408: Update fa_mass_ext_retirements
1409: Set review_status = 'POST',
1410: calc_gain_loss_flag = 'YES'
1411: Where mass_external_retire_id = aurec.mass_external_retire_id;
1412:
1424:
1425:
1426: select nvl(sum(units),0)
1427: into l_asset_post_units
1428: from fa_mass_ext_retirements
1429: where book_type_code = g_book_type_code
1430: and asset_id = l_asset_id
1431: and review_status = 'POST'
1432: and batch_name <> g_batch_name;
1459: -- 1. check if any asset exists with distribution info
1460:
1461: select nvl(sum(units),0)
1462: into l_dist_post_units
1463: from fa_mass_ext_retirements
1464: where book_type_code = g_book_type_code
1465: and asset_id = l_asset_id
1466: and review_status = 'POST'
1467: and batch_name <> g_batch_name
1596: if aurec.current_units > l_asset_post_units then
1597:
1598: select nvl(sum(units),0)
1599: into l_dist_post_units
1600: from fa_mass_ext_retirements
1601: where book_type_code = g_book_type_code
1602: and asset_id = l_asset_id
1603: and review_status = 'POST'
1604: and batch_name <> g_batch_name
1800: end if;
1801:
1802: select nvl(sum(units),0)
1803: into l_asset_post_units
1804: from fa_mass_ext_retirements
1805: where book_type_code = g_book_type_code
1806: and asset_id = l_asset_id
1807: and review_status = 'POST'
1808: and batch_name <> g_batch_name;
1833:
1834:
1835: select nvl(sum(units),0)
1836: into l_dist_post_units
1837: from fa_mass_ext_retirements
1838: where book_type_code = g_book_type_code
1839: and asset_id = l_asset_id
1840: and review_status = 'POST'
1841: and batch_name <> g_batch_name
2042:
2043:
2044: select nvl(sum(units),0)
2045: into l_dist_post_units
2046: from fa_mass_ext_retirements
2047: where book_type_code = g_book_type_code
2048: and asset_id = l_asset_id
2049: and review_status = 'POST'
2050: and batch_name <> g_batch_name
2304:
2305: -- need to prorate the units over distributions.....
2306: select nvl(sum(units),0)
2307: into l_asset_post_units
2308: from fa_mass_ext_retirements
2309: where book_type_code = g_book_type_code
2310: and asset_id = l_asset_id
2311: and review_status = 'POST'
2312: and batch_name <> g_batch_name;
2347: end if;
2348:
2349: select nvl(sum(units),0)
2350: into l_dist_post_units
2351: from fa_mass_ext_retirements
2352: where book_type_code = g_book_type_code
2353: and asset_id = l_asset_id
2354: and review_status = 'POST'
2355: and batch_name <> g_batch_name
2458:
2459: if l_2nd_current_units > l_asset_post_units then
2460: select nvl(sum(units),0)
2461: into l_dist_post_units
2462: from fa_mass_ext_retirements
2463: where book_type_code = g_book_type_code
2464: and asset_id = l_asset_id
2465: and review_status = 'POST'
2466: and batch_name <> g_batch_name
2639:
2640:
2641: select nvl(sum(units),0)
2642: into l_asset_post_units
2643: from fa_mass_ext_retirements
2644: where book_type_code = g_book_type_code
2645: and asset_id = l_asset_id
2646: and review_status = 'POST'
2647: and batch_name <> g_batch_name;
2658:
2659:
2660: select nvl(sum(units),0)
2661: into l_dist_post_units
2662: from fa_mass_ext_retirements
2663: where book_type_code = g_book_type_code
2664: and asset_id = l_asset_id
2665: and review_status = 'POST'
2666: and batch_name <> g_batch_name
2819: if l_2nd_current_units > l_asset_post_units then
2820:
2821: select nvl(sum(units),0)
2822: into l_dist_post_units
2823: from fa_mass_ext_retirements
2824: where book_type_code = g_book_type_code
2825: and asset_id = l_asset_id
2826: and review_status = 'POST'
2827: and batch_name <> g_batch_name
2926: fa_debug_pkg.add(l_calling_fn, 'Update status',l_remaining_units
2927: ,p_log_level_rec => p_log_level_rec);
2928: end if;
2929:
2930: Delete from fa_mass_ext_retirements
2931: Where batch_name = g_batch_name;
2932:
2933: Update fa_mass_retirements
2934: Set status = 'ON_HOLD'
2949:
2950:
2951: Elsif l_remaining_units <= 0 then
2952: -- Not enough units provided, assets have been
2953: -- inserted into fa_mass_ext_retirements
2954: -- but will not get any units assigned for certain of these rows.
2955: if (g_log_level_rec.statement_level) then
2956: fa_debug_pkg.add(l_calling_fn, 'Update status <= 0 ',l_remaining_units
2957: ,p_log_level_rec => p_log_level_rec);
2959:
2960:
2961: -- rn Delete review_status have been set in initial insert.
2962:
2963: Delete from fa_mass_ext_retirements
2964: Where batch_name = g_batch_name
2965: And review_status = 'DELETE';
2966:
2967: -- rn print messages to outfile now.
3477:
3478: CURSOR mass_ret_assets (p_batch_name varchar2) IS
3479: SELECT asset_id,
3480: cost_retired
3481: FROM fa_mass_ext_retirements
3482: WHERE batch_name = p_batch_name;
3483:
3484:
3485: l_candidate_units num_tbl;
3674: calling_fn => l_calling_fn
3675: ,p_log_level_rec => g_log_level_rec);
3676: raise error_found;
3677: else -- purge any prior / incomplete data from mass ext ret
3678: delete from fa_mass_ext_retirements
3679: where batch_name = g_batch_name;
3680: commit;
3681: end if;
3682:
3837:
3838: l_candidate_units(l_candidate_units.count + 1) := l_sc_units(l_loop_count_sub);
3839:
3840: -- rn Print message during allocate_units when there are units to prorate,
3841: -- because some of these assets may be deleted from fa_mass_ext_retirements
3842: -- due to unit buckets are emptied.
3843: If nvl(G_UNITS,0) = 0 then
3844: Write_Message(l_sc_Asset_Number(l_loop_count_sub),'FA_SHARED_INSERT_DEBUG','','');
3845: End if;
3999: 'Before insert into fa_mass_ext_ret ccid',
4000: l_asset_dist_tbl(l_dist_count).expense_ccid, p_log_level_rec => g_log_level_rec );
4001: end if;
4002:
4003: insert into fa_mass_ext_retirements
4004: (batch_name,
4005: mass_external_retire_id,
4006: book_type_code,
4007: review_status,
4056: th_attribute15
4057: )
4058: values
4059: (g_batch_name,
4060: fa_mass_ext_retirements_s.nextval,
4061: G_book_type_code,
4062: decode(nvl(g_units,0),'0','POST','DELETE'),
4063: l_candidate_asset_id(l_count),
4064: 'NO',
4112:
4113:
4114: if (g_log_level_rec.statement_level) then
4115: fa_debug_pkg.add(l_calling_fn,
4116: 'After insert into FA_MASS_EXT_RETIREMENTS table',
4117: l_asset_dist_tbl(l_dist_count).units_assigned,p_log_level_rec => g_log_level_rec );
4118: fa_debug_pkg.add(l_calling_fn,
4119: 'After insert into FA_MASS_EXT_RETIREMENTS table',
4120: l_candidate_units(l_count), p_log_level_rec => g_log_level_rec );
4115: fa_debug_pkg.add(l_calling_fn,
4116: 'After insert into FA_MASS_EXT_RETIREMENTS table',
4117: l_asset_dist_tbl(l_dist_count).units_assigned,p_log_level_rec => g_log_level_rec );
4118: fa_debug_pkg.add(l_calling_fn,
4119: 'After insert into FA_MASS_EXT_RETIREMENTS table',
4120: l_candidate_units(l_count), p_log_level_rec => g_log_level_rec );
4121:
4122: end if;
4123:
4178: select count(*),
4179: sum( abs(cost_retired) )
4180: into l_total_count_retired,
4181: l_total_cost_retired
4182: from fa_mass_ext_retirements
4183: where batch_name = g_batch_name;
4184:
4185: if (g_log_level_rec.statement_level) then
4186: fa_debug_pkg.add(l_calling_fn,
4213: LIMIT l_batch_size;
4214:
4215: select count(*)
4216: into l_msg_count
4217: from fa_mass_ext_retirements
4218: where batch_name = g_batch_name;
4219:
4220: if (g_log_level_rec.statement_level) then
4221: fa_debug_pkg.add(l_calling_fn,
4279: end if;
4280: END LOOP;
4281:
4282: FORALL l_count in 1..l_asset_id.count
4283: UPDATE fa_mass_ext_retirements
4284: SET cost_of_removal = l_prorated_cost_of_removal(l_count),
4285: proceeds_of_sale = l_prorated_proceeds_of_sale(l_count)
4286: where asset_id = l_asset_id(l_count)
4287: and batch_name = g_batch_name;