固定资产的调整分配接口

/*(注意点: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);
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 := 418;
  --资产账簿
  l_asset_hdr_rec.book_type_code := 'FA_BOOK_01';

  -- 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 := 22001; -----存在的调整之前的行ID
  l_asset_dist_tbl(1).transaction_units := -1; ----调整数量
  /*
    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 :=15338;
  --地点组合id
    l_asset_dist_tbl(1).location_ccid := 3; */
  -- fill in dist info for destination distribution
  l_asset_dist_tbl(2).transaction_units := 2; ----调整之后新建的行数量
  l_asset_dist_tbl(2).assigned_to := 61; ---调整给谁
  l_asset_dist_tbl(2).expense_ccid := 14001; --CODE_COMBINATION_ID;  ----费用账户
  l_asset_dist_tbl(2).location_ccid := 1; --LOCATION_ID;    -----地点

  l_trans_rec.who_info.last_updated_by   := 1330; --FND_GLOBAL.USER_ID;
  l_trans_rec.who_info.last_update_login := 14001; --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);
  IF (l_return_status != fnd_api.g_ret_sts_success) THEN
  
    dbms_output.put_line('TRANSFER failed!.');
    l_msg_count := fnd_msg_pub.count_msg;
  
    IF (l_msg_count > 0) THEN
      temp_str := substr(fnd_msg_pub.get(fnd_msg_pub.g_first,
                                         fnd_api.g_false),
                         1,
                         512);
      dbms_output.put_line('Error: ' || temp_str);
      FOR i IN 1 .. (l_msg_count - 1) LOOP
        temp_str := substr(fnd_msg_pub.get(fnd_msg_pub.g_next,
                                           fnd_api.g_false),
                           1,
                           512);
        dbms_output.put_line('Error: ' || temp_str);
      END LOOP;
    END IF;
  ELSE
    dbms_output.put_line('TRANSFER completed successfully!');
    dbms_output.put_line('THID = ' ||
                         to_char(l_trans_rec.transaction_header_id));
  END IF;
  fnd_msg_pub.delete_msg();

END;

你可能感兴趣的:(接口,资产调整分配)