EBS 固定资产报废API是实例

Sample Scripts for Retirement, Reinstatement and Undo Transaction

This section lists sample scripts for the following retirement-related transaction types:

  • Full retirement

  • Partial unit retirement

  • Reinstatement

  • Undo retirement

  • Undo reinstatement

  • Retirement Details

Retirement_ID must be provided as a parameter for the following: Reinstatement, Undo retirement, Undo reinstatement, & Retirement Details

1:EBS 固定资产报废API(Full retirement)

declare

l_trans_rec FA_API_TYPES.trans_rec_type;

l_dist_trans_rec FA_API_TYPES.trans_rec_type;

l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;

l_asset_retire_rec FA_API_TYPES.asset_retire_rec_type;

l_asset_dist_tbl FA_API_TYPES.asset_dist_tbl_type;

l_subcomp_tbl FA_API_TYPES.subcomp_tbl_type;

l_inv_tbl FA_API_TYPES.inv_tbl_type;

l_return_status VARCHAR2(1);

l_mesg_count number;

l_mesg varchar2(4000);

begin

dbms_output.enable(1000000);

FA_SRVR_MSG.Init_Server_Message;

fnd_global.apps_initialize

( user_id => 2515,

resp_id => 52219,

resp_appl_id => 140

);

-- Get standard who info

l_asset_hdr_rec.asset_id := 10023125;

l_asset_hdr_rec.book_type_code := 'KOZA_FA';

l_asset_retire_rec.cost_retired := 2500;

--l_asset_retire_rec.proceeds_of_sale := '&Proceeds';

--l_asset_retire_rec.cost_of_removal := '&CostRemoval';

--l_asset_retire_rec.retirement_type_code := '&RetirementType';

l_asset_retire_rec.calculate_gain_loss := FND_API.G_FALSE;

FA_RETIREMENT_PUB.do_retirement(

-- std parameters

p_api_version => 1.0,

p_init_msg_list => FND_API.G_FALSE,

p_commit => FND_API.G_FALSE,

p_validation_level => FND_API.G_VALID_LEVEL_FULL,

p_calling_fn => NULL,

x_return_status => l_return_status,

x_msg_count => l_mesg_count,

x_msg_data => l_mesg,

-- api parameters

px_trans_rec => l_trans_rec,

px_dist_trans_rec => l_dist_trans_rec,

px_asset_hdr_rec => l_asset_hdr_rec,

px_asset_retire_rec => l_asset_retire_rec,

p_asset_dist_tbl => l_asset_dist_tbl,

p_subcomp_tbl => l_subcomp_tbl,

p_inv_tbl => l_inv_tbl

);

--dump messages

l_mesg_count := fnd_msg_pub.count_msg;

if l_mesg_count > 0 then

l_mesg := chr(10) || substr(fnd_msg_pub.get

(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE),

1, 250);

dbms_output.put_line(l_mesg);

for i in 1..(l_mesg_count - 1) loop

l_mesg :=

substr(fnd_msg_pub.get

(fnd_msg_pub.G_NEXT,

fnd_api.G_FALSE), 1, 250);

dbms_output.put_line(l_mesg);

end loop;

fnd_msg_pub.delete_msg();

end if;

if (l_return_status <> FND_API.G_RET_STS_SUCCESS) then

dbms_output.put_line('FAILURE');

rollback;

else

dbms_output.put_line('SUCCESS');

dbms_output.put_line('RETIREMENT_ID' || to_char(l_asset_retire_rec.retirement_id));

end if;

end;

2:EBS 固定资产报废API(Partial unit retirement)

declare

l_trans_rec FA_API_TYPES.trans_rec_type;

l_dist_trans_rec FA_API_TYPES.trans_rec_type;

l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;

l_asset_retire_rec FA_API_TYPES.asset_retire_rec_type;

l_asset_dist_tbl FA_API_TYPES.asset_dist_tbl_type;

l_subcomp_tbl FA_API_TYPES.subcomp_tbl_type;

l_inv_tbl FA_API_TYPES.inv_tbl_type;

l_return_status varchar2(1);

l_mesg_count number;

l_mesg varchar2(512);

begin

fnd_global.apps_initialize

( user_id => 2515,

resp_id => 52219,

resp_appl_id => 140

);

dbms_output.enable(1000000);

fa_srvr_msg.init_server_message;

l_asset_hdr_rec.asset_id := 10023126;

l_asset_hdr_rec.book_type_code := 'KOZA_FA';

l_asset_retire_rec.units_retired := 1;

l_asset_retire_rec.calculate_gain_loss := FND_API.G_FALSE;

l_asset_dist_tbl.delete;

l_asset_dist_tbl(1).distribution_id := 688226;

l_asset_dist_tbl(1).transaction_units := null;

l_asset_dist_tbl(1).units_assigned := null;

l_asset_dist_tbl(1).assigned_to := null;

l_asset_dist_tbl(1).expense_ccid := null;

l_asset_dist_tbl(1).location_ccid := null;

-- optionally load additional rows into dist table (2,3..)

FA_RETIREMENT_PUB.do_retirement(

-- std parameters

p_api_version => 1.0,

p_init_msg_list => FND_API.G_FALSE,

p_commit => FND_API.G_FALSE,

p_validation_level => FND_API.G_VALID_LEVEL_FULL,

p_calling_fn => NULL,

x_return_status => l_return_status,

x_msg_count => l_mesg_count,

x_msg_data => l_mesg,

-- api parameters

px_trans_rec => l_trans_rec,

px_dist_trans_rec => l_dist_trans_rec,

px_asset_hdr_rec => l_asset_hdr_rec,

px_asset_retire_rec => l_asset_retire_rec,

p_asset_dist_tbl => l_asset_dist_tbl,

p_subcomp_tbl => l_subcomp_tbl,

p_inv_tbl => l_inv_tbl

);

--dump messages

l_mesg_count := fnd_msg_pub.count_msg;

if l_mesg_count > 0 then

l_mesg := chr(10) || substr(fnd_msg_pub.get

(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE),

1, 250);

dbms_output.put_line(l_mesg);

for i in 1..(l_mesg_count - 1) loop

l_mesg :=

substr(fnd_msg_pub.get

(fnd_msg_pub.G_NEXT,

fnd_api.G_FALSE), 1, 250);

dbms_output.put_line(l_mesg);

end loop;

fnd_msg_pub.delete_msg();

end if;

if (l_return_status <> FND_API.G_RET_STS_SUCCESS) then

dbms_output.put_line('FAILURE');

else

dbms_output.put_line('SUCCESS');

dbms_output.put_line('RETIREMENT_ID' || to_char(l_asset_retire_rec.retirement_id));

end if;

end;

3:

declare

api_error EXCEPTION;

-- Test asset info

l_retirement_id number := '&Retirement_id';

--l_asset_id number := '&AssetId';

--l_book_type_code varchar2(15) := '&Book';

l_user_id number := '&UserId';

-- USER_ID must properly be set to run calc gain-loss

-- define local record types

l_trans_rec FA_API_TYPES.trans_rec_type;

l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;

l_asset_retire_rec FA_API_TYPES.asset_retire_rec_type;

l_asset_dist_tbl FA_API_TYPES.asset_dist_tbl_type;

l_subcomp_tbl FA_API_TYPES.subcomp_tbl_type;

l_inv_tbl FA_API_TYPES.inv_tbl_type;

-- misc info

l_api_version number := 1;

l_init_msg_list varchar2(1) := FND_API.G_FALSE;

l_commit varchar2(1) := FND_API.G_TRUE;

l_validation_level number := FND_API.G_VALID_LEVEL_FULL;

l_calling_fn varchar2(80) := 'Retirement test wrapper';

l_return_status varchar2(1) := FND_API.G_FALSE;

l_msg_count number := 0;

l_msg_data varchar2(512);

l_count number;

l_request_id number;

i number := 0;

temp_str varchar2(512);

mesg_count number;

begin

dbms_output.disable;

dbms_output.enable(1000000);

dbms_output.put_line('begin');

fa_srvr_msg.init_server_message;

fa_debug_pkg.set_debug_flag(debug_flag => 'YES');

-- Set rollback segment if profile option is set

-- fnd_profile.get('FA_LARGE_ROLLBACK_SEGMENT', rbs_name);

--IF (rbs_name is not NULL) THEN

--sql_stmt := 'SET TRANSACTION USE ROLLBACK SEGMENT ' || rbs_name;

--execute immediate sql_stmt;

-- END IF;

-- Get standard who info

l_request_id := fnd_global.conc_request_id;

fnd_profile.get('LOGIN_ID', l_trans_rec.who_info.last_update_login);

fnd_profile.get('USER_ID', l_trans_rec.who_info.last_updated_by);

if (l_trans_rec.who_info.last_updated_by is null) then

l_trans_rec.who_info.last_updated_by := -1;

end if;

if (l_trans_rec.who_info.last_update_login is null) then

l_trans_rec.who_info.last_update_login := -1;

end if;

l_trans_rec.who_info.last_update_date := sysdate;

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

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

l_trans_rec.transaction_type_code := NULL; -- this will be determined inside API

l_trans_rec.transaction_date_entered := NULL;

--l_asset_hdr_rec.asset_id := l_asset_id;

--l_asset_hdr_rec.book_type_code := l_book_type_code;

--l_asset_hdr_rec.period_of_addition := NULL;

--l_asset_retire_rec.date_retired := NULL; -- will be current period by default

--l_asset_retire_rec.units_retired := NULL;

l_asset_retire_rec.calculate_gain_loss := FND_API.G_FALSE;

l_asset_retire_rec.retirement_id := l_retirement_id;

fnd_profile.put('USER_ID',l_user_id);

l_asset_dist_tbl.delete;

--l_asset_dist_tbl(1).distribution_id := '&DistId';

--l_asset_dist_tbl(1).transaction_units := '&#-Units';

--l_asset_dist_tbl(1).units_assigned := null;

--l_asset_dist_tbl(1).assigned_to := null;

--l_asset_dist_tbl(1).expense_ccid := null;

--l_asset_dist_tbl(1).location_ccid := null;

FA_RETIREMENT_PUB.do_reinstatement

(p_api_version => l_api_version

,p_init_msg_list => l_init_msg_list

,p_commit => l_commit

,p_validation_level => l_validation_level

,p_calling_fn => l_calling_fn

,x_return_status => l_return_status

,x_msg_count => l_msg_count

,x_msg_data => l_msg_data

,px_trans_rec => l_trans_rec

,px_asset_hdr_rec => l_asset_hdr_rec

,px_asset_retire_rec => l_asset_retire_rec

,p_asset_dist_tbl => l_asset_dist_tbl

,p_subcomp_tbl => l_subcomp_tbl

,p_inv_tbl => l_inv_tbl);

if l_return_status = FND_API.G_FALSE then

raise api_error;

end if;

commit;

-- Dump Debug messages when run in debug mode to log file

if (fa_debug_pkg.print_debug) then

fa_debug_pkg.Write_Debug_Log;

end if;

fa_srvr_msg.add_message(

calling_fn => l_calling_fn,

name => 'FA_SHARED_END_SUCCESS',

token1 => 'PROGRAM',

value1 => 'RETIREMENT_API');

mesg_count := fnd_msg_pub.count_msg;

if (mesg_count > 0) then

temp_str := fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE);

dbms_output.put_line('dump: ' || temp_str);

for I in 1..(mesg_count -1) loop

temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);

dbms_output.put_line('dump: ' || temp_str);

end loop;

else

dbms_output.put_line('dump: NO MESSAGE !');

end if;

exception

when api_error then

ROLLBACK WORK;

fa_srvr_msg.add_message(

calling_fn => l_calling_fn,

name => 'FA_SHARED_PROGRAM_FAILED',

token1 => 'PROGRAM',

value1 => l_calling_fn);

mesg_count := fnd_msg_pub.count_msg;

if (mesg_count > 0) then

temp_str := fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE);

dbms_output.put_line('dump: ' || temp_str);

for I in 1..(mesg_count -1) loop

temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);

dbms_output.put_line('dump: ' || temp_str);

end loop;

else

dbms_output.put_line('dump: NO MESSAGE !');

end if;

end;

3:EBS 固定资产报废资产重建API(Reinstatement)

declare

-- Test asset info

l_retirement_id number :=241085;-- retirement 根据资产编号从FA_RETIREMENTS 中去找

--l_asset_id number := '&AssetId';

--l_book_type_code varchar2(15) := '&Book';

l_user_id number :=2515;

-- USER_ID must properly be set to run calc gain-loss

-- define local record types

l_trans_rec FA_API_TYPES.trans_rec_type;

l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;

l_asset_retire_rec FA_API_TYPES.asset_retire_rec_type;

l_asset_dist_tbl FA_API_TYPES.asset_dist_tbl_type;

l_subcomp_tbl FA_API_TYPES.subcomp_tbl_type;

l_inv_tbl FA_API_TYPES.inv_tbl_type;

api_error exception;

-- misc info

l_api_version number := 1;

l_init_msg_list varchar2(1) := FND_API.G_FALSE;

l_commit varchar2(1) := FND_API.G_TRUE;

l_validation_level number := FND_API.G_VALID_LEVEL_FULL;

l_calling_fn varchar2(80) := 'Retirement test wrapper';

l_return_status varchar2(1) := FND_API.G_FALSE;

l_msg_count number := 0;

l_msg_data varchar2(512);

l_count number;

l_request_id number;

i number := 0;

temp_str varchar2(512);

mesg_count number;

begin

dbms_output.disable;

dbms_output.enable(1000000);

dbms_output.put_line('begin');

fa_srvr_msg.init_server_message;

fa_debug_pkg.set_debug_flag(debug_flag => 'YES');

fnd_global.apps_initialize

( user_id => 2515,

resp_id => 52219,

resp_appl_id => 140

);

-- Set rollback segment if profile option is set

-- fnd_profile.get('FA_LARGE_ROLLBACK_SEGMENT', rbs_name);

--IF (rbs_name is not NULL) THEN

--sql_stmt := 'SET TRANSACTION USE ROLLBACK SEGMENT ' || rbs_name;

--execute immediate sql_stmt;

-- END IF;

-- Get standard who info

l_request_id := fnd_global.conc_request_id;

fnd_profile.get('LOGIN_ID', l_trans_rec.who_info.last_update_login);

fnd_profile.get('USER_ID', l_trans_rec.who_info.last_updated_by);

if (l_trans_rec.who_info.last_updated_by is null) then

l_trans_rec.who_info.last_updated_by := -1;

end if;

if (l_trans_rec.who_info.last_update_login is null) then

l_trans_rec.who_info.last_update_login := -1;

end if;

l_trans_rec.who_info.last_update_date := sysdate;

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

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

l_trans_rec.transaction_type_code := NULL; -- this will be determined inside API

l_trans_rec.transaction_date_entered := NULL;

--l_asset_hdr_rec.asset_id := l_asset_id;

--l_asset_hdr_rec.book_type_code := l_book_type_code;

--l_asset_hdr_rec.period_of_addition := NULL;

--l_asset_retire_rec.date_retired := NULL; -- will be current period by default

--l_asset_retire_rec.units_retired := NULL;

l_asset_retire_rec.calculate_gain_loss := FND_API.G_FALSE;

l_asset_retire_rec.retirement_id := l_retirement_id;

fnd_profile.put('USER_ID',l_user_id);

l_asset_dist_tbl.delete;

--l_asset_dist_tbl(1).distribution_id := '&DistId';

--l_asset_dist_tbl(1).transaction_units := '&#-Units';

--l_asset_dist_tbl(1).units_assigned := null;

--l_asset_dist_tbl(1).assigned_to := null;

--l_asset_dist_tbl(1).expense_ccid := null;

--l_asset_dist_tbl(1).location_ccid := null;

FA_RETIREMENT_PUB.do_reinstatement

(p_api_version => l_api_version

,p_init_msg_list => l_init_msg_list

,p_commit => l_commit

,p_validation_level => l_validation_level

,p_calling_fn => l_calling_fn

,x_return_status => l_return_status

,x_msg_count => l_msg_count

,x_msg_data => l_msg_data

,px_trans_rec => l_trans_rec

,px_asset_hdr_rec => l_asset_hdr_rec

,px_asset_retire_rec => l_asset_retire_rec

,p_asset_dist_tbl => l_asset_dist_tbl

,p_subcomp_tbl => l_subcomp_tbl

,p_inv_tbl => l_inv_tbl);

if l_return_status = FND_API.G_FALSE then

raise api_error;

end if;

commit;

-- Dump Debug messages when run in debug mode to log file

if (fa_debug_pkg.print_debug) then

fa_debug_pkg.Write_Debug_Log;

end if;

fa_srvr_msg.add_message(

calling_fn => l_calling_fn,

name => 'FA_SHARED_END_SUCCESS',

token1 => 'PROGRAM',

value1 => 'RETIREMENT_API');

mesg_count := fnd_msg_pub.count_msg;

if (mesg_count > 0) then

temp_str := fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE);

dbms_output.put_line('dump: ' || temp_str);

for I in 1..(mesg_count -1) loop

temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);

dbms_output.put_line('dump: ' || temp_str);

end loop;

else

dbms_output.put_line('dump: NO MESSAGE !');

end if;

exception

when api_error then

ROLLBACK WORK;

fa_srvr_msg.add_message(

calling_fn => l_calling_fn,

name => 'FA_SHARED_PROGRAM_FAILED',

token1 => 'PROGRAM',

value1 => l_calling_fn);

mesg_count := fnd_msg_pub.count_msg;

if (mesg_count > 0) then

temp_str := fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE);

dbms_output.put_line('dump: ' || temp_str);

for I in 1..(mesg_count -1) loop

temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);

dbms_output.put_line('dump: ' || temp_str);

end loop;

else

dbms_output.put_line('dump: NO MESSAGE !');

end if;

end;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

EBS夕阳西下

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值