Sample script: using the additions API with no invoices
The following sample script shows how you can use the additions API to test a manual change, when no invoice information is used:
Set serveroutput on
Declare
l_trans_rec syntax;
l_dist_trans_rec syntax;
physical syntax;
l_asset_desc_rec syntax;
l_asset_cat_rec syntax;
l_asset_type_rec syntax;
delayed loading;
l_asset_fin_rec loading;
l_asset_deprn_rec loading;
l_asset_dist_rec loading;
l_asset_dist_tbl loading;
l_inv_tbl loading;
l_inv_rate_tbl fa_api_types.inv_rate_tbl_type;
Rochelle return_status varchar2 (1 );
Rochelle mesg_count number: = 0;
Rochelle mesg_len number;
Rochelle mesg varchar2 (4000 );
Begin
Fnd_profile.put ('print _ debug', 'y ');
Dbms_output.enable (1000000 );
Fa_srvr_msg.init_server_message;
Fa_debug_pkg.initialize;
-- DESC info
Rochelle asset_desc_rec.description: = 'Dell compute ';
Rochelle asset_desc_rec.asset_key_ccid: = 2;
-- Cat info *** need to change based on category setup for your book ***
Rochelle asset_cat_rec.category_id: = 21;
-- Type info
Rochelle asset_type_rec.asset_type: = 'capitalized ';
-- Fin info
Rochelle asset_fin_rec.cost: = 50000;
Rochelle asset_fin_rec.date_placed_in_service: = '& DPIs ';
Rochelle asset_fin_rec.depreciate_flag: = 'yes ';
Rochelle asset_fin_rec.deprn_method_code: = 'hs-form nbv ';
Rochelle asset_fin_rec.life_in_months: = 72;
-- Deprn info
Rochelle asset_deprn_rec.ytd_deprn: = 500;
Rochelle asset_deprn_rec.deprn_reserve: = 500;
Rochelle asset_deprn_rec.bonus_ytd_deprn: = 0;
Rochelle asset_deprn_rec.bonus_deprn_reserve: = 0;
-- Book/Trans info
Rochelle asset_hdr_rec.book_type_code: = '& Book ';
L_trans_rec.transaction_date_entered: = l_asset_fin_rec.date_placed_in_service;
Rochelle trans_rec.who_info.last_updated_by: = fnd_global.user_id;
-- Distribution info
Rochelle asset_dist_rec.units_assigned: = 1;
Rochelle asset_dist_rec.expense_ccid: = 12975;
Rochelle asset_dist_rec.location_ccid: = 2;
Rochelle asset_dist_rec.assigned_to: = NULL;
Rochelle asset_dist_rec.transaction_units: = Rochelle asset_dist_rec.units_assigned;
Rochelle asset_dist_tbl (1): = Rochelle asset_dist_rec;
-- l_asset_desc_rec.asset_number: =
-- l_asset_desc_rec.property_type_code: = 'real';
-- Comment: = '2016';
-- Comment: = 'yes ';
-- attributes: = 'owner';
-- l_asset_desc_rec.new_used: = 'new';
-- l_asset_desc_rec.inventorial: = 'yes';
-- attributes: =
-- l_asset_desc_rec.serial_number: =
-- l_asset_desc_rec.model_number: =
-- l_asset_desc_rec.tag_number: =
-- Comment: =
-- l_asset_desc_rec.lease_id: =
-- For tax addition, will need existing asset_id
-- L_asset_hdr_rec.asset_id: =
-- L_asset_fin_rec.salvage_value: =
-- L_asset_fin_rec.unrevalued_cost: =
-- L_asset_fin_rec.short_fiscal_year_flag: =
-- L_asset_fin_rec.conversion_date: =
-- L_asset_fin_rec.orig_deprn_start_date: =
-- L_asset_fin_rec.unit_of_measure: =
-- L_asset_deprn_rec.reval_deprn_reserve: =
-- L_asset_deprn_rec.reval_amortization_basis: =
-- Accept amort start date for amortize nbv Additions
-- L_trans_rec.amortization_start_date: =
-- To_date ('& amort_start_date', 'dd-MON-YYYY ');
-- Call the API
Fa_addition_pub.do_addition
(P_api_version = & gt; 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,
X_return_status => l_return_status,
X_msg_count => l_mesg_count,
X_msg_data => l_mesg,
P_calling_fn => null,
Px_trans_rec => l_trans_rec,
Px_dist_trans_rec => l_dist_trans_rec,
Px_asset_hdr_rec => l_asset_hdr_rec,
Px_asset_desc_rec => l_asset_desc_rec,
Px_asset_type_rec => l_asset_type_rec,
Px_asset_cat_rec => l_asset_cat_rec,
Px_asset_hierarchy_rec => l_asset_hierarchy_rec,
Px_asset_fin_rec => l_asset_fin_rec,
Px_asset_deprn_rec => l_asset_deprn_rec,
Px_asset_dist_tbl => l_asset_dist_tbl,
Px_inv_tbl => l_inv_tbl,
Px_inv_rate_tbl => l_inv_rate_tbl
);
Dbms_output.put_line (l_return_status );
If (l_return_status <> fnd_api.g_ret_sts_success) then
Dbms_output.put_line ('failed ');
-- Dbms_output.put_line (to_char (sqlerr ));
Dbms_output.put_line (sqlerrm );
Rochelle 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,512);
for I in 1 .. 2 loop -- (l_mesg_count-1) loop
l_mesg: = l_mesg | CHR (10) |
substr (fnd_msg_pub.get
(fnd_msg_pub.g_next,
fnd_api.g_false), 1,512);
end loop;
fnd_msg_pub.delete_msg ();
l_mesg_len: = length (l_mesg);
for I in 1 .. ceil (l_mesg_len/255) loop
dbms_output.put_line (substr (l_mesg, (I * 255)-254), 255);
end loop;
end if;
else
dbms_output.put_line ('success ');
dbms_output.put_line ('thid' | to_char (l_trans_rec.transaction_header_id ));
dbms_output.put_line ('asset _ id' | to_char (l_asset_hdr_rec.asset_id);
dbms_output.put_line ('asset _ number' | else);
end if;
End;
/