FA 分配已有资产 API Demo

/*(注意点:1:只能在不同的行之间进行调整
2:调整之后的数量之和应和调整之前一样,否则报错)*/
DECLARE
  l_return_status  VARCHAR2(1 );
  l_msg_count      NUMBER := 0 ;
  l_msg_data       VARCHAR2(4000);
  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;
  temp_str         VARCHAR2(512);
  l_mesg_len number;
  l_mesg_count    NUMBER;
  l_mesg          VARCHAR2(4000);
BEGIN
--初始化
  fnd_profile.put('PRINT_DEBUG', 'Y');
  dbms_output.enable(1000000);
  fa_srvr_msg.init_server_message;
  fa_debug_pkg.initialize;
  -- fill in asset information
--资产id
  l_asset_hdr_rec.asset_id       := 109927;--已经存在,需要进行重新分配
--资产账簿
  l_asset_hdr_rec.book_type_code := 'ADB CORP';--资产帐簿

  -- transaction date must be filled in if performing
  -- prior period transfer
  --l_trans_rec.transaction_date_entered := to_date('01-JAN-1999 10:54:22', 'dd-mon-yyyy hh24:mi:ss');

--清空资产分配记录中的数据
  l_asset_dist_tbl.delete;
  /*
  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).distribution_id := 138141 ; -----存在的调整之前的行ID
  l_asset_dist_tbl(1).transaction_units := -0.8 ; ----调整数量
  /*
  either above 2 lines or below 4 lines must be provided
  for source distribution:
--调整的数量
  l_asset_dist_tbl(1).transaction_units := -2;
--员工id
  l_asset_dist_tbl(1).assigned_to := 11;*/
--费用账户id
  l_asset_dist_tbl(1).expense_ccid :=17506;
--地点组合id
  l_asset_dist_tbl(1).location_ccid := 3; 
  -- fill in dist info for destination distribution
  l_asset_dist_tbl(2).transaction_units := 0.8 ; ----调整之后新建的行数量
  --l_asset_dist_tbl(2).assigned_to := 61 ; ---调整给谁
  l_asset_dist_tbl(2).expense_ccid := 17635 ; --CODE_COMBINATION_ID;  ----费用账户
  l_asset_dist_tbl(2).location_ccid := 2 ; --LOCATION_ID;    -----地点

  l_trans_rec.who_info.last_updated_by   := 1013518; --FND_GLOBAL.USER_ID;
  l_trans_rec.who_info.last_update_login := 5521287; --FND_GLOBAL.LOGIN_ID;

  fa_transfer_pub.do_transfer( 1.0,
                               fnd_api.g_false,
                               fnd_api.g_false,
                               fnd_api.g_valid_level_full,
                               NULL,
                               l_return_status,
                               l_msg_count,
                               l_msg_data,
                               l_trans_rec,
                               l_asset_hdr_rec,
                               l_asset_dist_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);
    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,
                       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');
  end if;
                               
END;

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值