asset transfer api测试范例

经过测试ok的sample

 

--测试代码开始

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       :=
12138;--要移转的资产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 := -0.1;-- assignment当前行unit要变化的数量

  
-- Source
  
-- Option A - known dist id
   l_asset_dist_tbl(
1).distribution_id   := 2165368;-- assignment当前行id
  
  
-- or
  
-- Option B - known dist attributes
   l_asset_dist_tbl(
1).assigned_to       := 1527; -- assignment当前行assigned_to 人员id
   l_asset_dist_tbl(
1).expense_ccid      := 1009142; -- assignment当前行expense account
   l_asset_dist_tbl(
1).location_ccid     := 1037635 ; -- assignment当前行location



  
-- Destination
   l_asset_dist_tbl(
2).distribution_id   := 2165369;
  
  
-- fill in dist info for one or more destination distribution (start with 2..(3,4,..))
   l_asset_dist_tbl(
2).transaction_units := 0.1;
   l_asset_dist_tbl(
2).assigned_to       := 1527;
   l_asset_dist_tbl(
2).expense_ccid      := 1005158;
   l_asset_dist_tbl(
2).location_ccid     := 1037635;


   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;

 

--测试代码结束

 

辅助sql

根据asset_id查询asset assignment信息

Select Units_Assigned, Rowid, Asset_Id, Book_Type_Code, Distribution_Id, Assigned_To, Transaction_Units,

               Code_Combination_Id, Location_Id, Date_Effective, Date_Ineffective, Transaction_Header_Id_In,

               Transaction_Header_Id_Out, Retirement_Id, Last_Update_Login, Last_Update_Date, Last_Updated_By

From Fa_Distribution_History

Where ('' Is Null And Date_Ineffective Is Null And Book_Type_Code = 'AP ASSET BOOK' And Asset_Id = 12138 And

              'TRANSFER' != 'TRANSFER IN') Or

              ('' Is Not Null And

              (Transaction_Header_Id_Out = '' And 'TRANSFER' In ('TRANSFER', 'TRANSFER OUT', 'UNIT ADJUSTMENT')) Or

              (Transaction_Header_Id_In = '' And 'TRANSFER' In ('TRANSFER IN', 'TRANSFER', 'UNIT ADJUSTMENT') And

              (Code_Combination_Id, Location_Id, Nvl(Assigned_To, -99)) Not In

              (Select Dh.Code_Combination_Id, Dh.Location_Id, Nvl(Dh.Assigned_To, -99)

                    From Fa_Distribution_History Dh

                    Where Dh.Asset_Id = 12138 And Dh.Book_Type_Code = 'AP ASSET BOOK' And Dh.Transaction_Header_Id_Out = '' And

                                  'TRANSFER' In ('TRANSFER', 'TRANSFER OUT', 'UNIT ADJUSTMENT'))))

Order By Distribution_Id;

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值