Oracle EBS 资产分配APIFA_TRANSFER_PUB.do_transfer
Sample Script: Using the Transfer API to Transfer Units
The following example shows how to use Transfer API for transfer transaction. The example shows transfer of two units from an existing distribution of two
new distributions, each having one unit.
set serveroutput on;
declare
l_trans_rec fa_api_types.trans_rec_type;
l_asset_hdr_rec fa_api_types.asset_hdr_rec_type;
l_asset_dist_tbl fa_api_types.asset_dist_tbl_type;
l_return_status VARCHAR2(1);
l_mesg_count number;
l_mesg varchar2(512);
begin
dbms_output.enable(1000000);
fa_srvr_msg.init_server_message;
-- fill in asset information
l_asset_hdr_rec.asset_id := &asset_id
-- fill in distribution data for existing distribution lines
-- affected by this transfer txn. Note: You need to fill in
-- only affected distribution lines.
--
-- For source distribution, you must fill in either existing
-- distribution id or 2 columns(expense_ccid,location_ccid) or
-- 3-tuple columns(assigned_to,expense_ccid, and location_ccid)
-- depending on the makeup of the particular distribution
-- of the asset.
l_asset_dist_tbl(1).transaction_units := &trx_units
-- Source
-- Option A - known dist id
l_asset_dist_tbl(1).distribution_id := &existing_dist_id
-- or
-- Option B - known dist attributes
l_asset_dist_tbl(1).assigned_to := &existing_assigned_to
l_asset_dist_tbl(1).expense_ccid := &existing_expense_ccid
l_asset_dist_tbl(1).location_ccid := &existing_location_id
-- Destination
-- fill in dist info for one or more destination distribution (start with 2..(3,4,..))
l_asset_dist_tbl(2).transaction_units := &trx_units2
l_asset_dist_tbl(2).assigned_to := &new_assigned_to
l_asset_dist_tbl(2).expense_ccid := &new_expesne_ccid
l_asset_dist_tbl(2).location_ccid := &new_location_id
FA_TRANSFER_PUB.do_transfer(
-- 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_asset_hdr_rec => l_asset_hdr_rec,
px_asset_dist_tbl => l_asset_dist_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('THID' || to_char(l_trans_rec.transaction_header_id));
end if;
end;
/
-- 刘轶鹤转