Fixed Assets API匯入測試

來源:互聯網
上載者:User

Backdrop:

1.花很長一段時間盤點所有Fixed Assets,我主要處理的是電子產品類,電子產品類在OA上有管理記錄,ERP上也有管理記錄,但是盤點之後發現實際資料與OA、ERP記錄的資料都核對不清。

2.解決方案:將ERP中的固定資產(僅電子產品類)全部報廢,將現有資產資訊由財務整理好,然後通過API重新匯入。

Difficulties:

1.時間:11月25號開始至30號關帳.

2.初涉FA,介面操作都不熟練,且對API不熟悉。

3.在獲得FA相關的API後,需時間測試,尤其需要考慮匯入是否會影響一些沒有注意到的東東。

 Test Script:

  procedure auto_import_info_p(errbuf out varchar2, retcode out number) is
    l_trans_rec           fa_api_types.trans_rec_type;
    l_dist_trans_rec      fa_api_types.trans_rec_type;
    l_asset_hdr_rec       fa_api_types.asset_hdr_rec_type;
    l_asset_desc_rec      fa_api_types.asset_desc_rec_type;
    l_asset_cat_rec       fa_api_types.asset_cat_rec_type;
    l_asset_type_rec      fa_api_types.asset_type_rec_type;
    l_asset_hierarchy_rec fa_api_types.asset_hierarchy_rec_type;
    l_asset_fin_rec       fa_api_types.asset_fin_rec_type;
    l_asset_deprn_rec     fa_api_types.asset_deprn_rec_type;
    l_asset_dist_rec      fa_api_types.asset_dist_rec_type;
    l_asset_dist_tbl      fa_api_types.asset_dist_tbl_type;
    l_inv_tbl             fa_api_types.inv_tbl_type;
    l_inv_rate_tbl        fa_api_types.inv_rate_tbl_type;
 
    l_return_status varchar2(1);
    l_mesg_count    number := 0;
    l_mesg_len      number;
    l_mesg          varchar2(4000);
 
  begin
 
    fnd_profile.put('PRINT_DEBUG', 'Y'); --用於指定相關的配置資訊
    errbuf  := null;
    retcode := null;
    fa_srvr_msg.init_server_message; --初始化錯誤資訊堆棧。
    fa_debug_pkg.initialize; --初始化調試資訊堆棧
 
    -- desc info
    l_asset_desc_rec.description    := null; --'Dell computer'; --說明
    l_asset_desc_rec.asset_key_ccid := 1; --與資產關鍵字對應的程式碼群組合標識
 
    -- cat info *** NEED TO CHANGE BASED ON CATEGORY SETUP FOR YOUR BOOK ***
    l_asset_cat_rec.category_id := 3; --類別id    fa_categories_b
 
    --type info
    l_asset_type_rec.asset_type := 'CAPITALIZED'; --資本化
 
    -- fin info
    l_asset_fin_rec.cost                   := 1001; --目前成本
    l_asset_fin_rec.date_placed_in_service := to_date('2009-08-31',
                                                      'yyyy-mm-dd'); --啟用日期     --'&DPIS';
    l_asset_fin_rec.depreciate_flag        := 'YES'; --折舊複選框
    l_asset_fin_rec.deprn_method_code      := 'STL'; --方法
    l_asset_fin_rec.life_in_months         := 60; --總月數 
 
    -- deprn info
    l_asset_deprn_rec.ytd_deprn           := 0; --YTD折舊
    l_asset_deprn_rec.deprn_reserve       := 0; --累計折舊
    l_asset_deprn_rec.bonus_ytd_deprn     := 0; --額外折舊???????
    l_asset_deprn_rec.bonus_deprn_reserve := 0; --預計額外折舊????
 
    -- book / trans info
    l_asset_hdr_rec.book_type_code       := '帳簿'; --'&book';  
    l_trans_rec.transaction_date_entered := l_asset_fin_rec.date_placed_in_service; --轉移日期
    l_trans_rec.who_info.last_updated_by := fnd_global.user_id; --目前使用者*****************
 
    -- distribution info                 --分配資訊                          --fa_distribution_history
 
    l_asset_dist_rec.units_assigned := 2; -- select distinct units_assigned from fa_distribution_history;
    l_asset_dist_rec.expense_ccid   := 64157; --是一個組合id
    /*
    select * from fa_distribution_history
    where trunc(last_update_date,'DD') = trunc(to_date('2009-11-20','yyyy-mm-dd'),'DD');  --expense_ccid 實際是code_combination_id
   
    select * from GL_CODE_COMBINATIONS
    where code_combination_id = 64157;
    */
 
    l_asset_dist_rec.location_ccid := 40; --
    --HEK_固定資產超級使用者 -> 設定 -> 財務系統 -> 員工    找person_ID
    l_asset_dist_rec.assigned_to := 120; --負責此資產的員工的員工標識
    apps.fnd_file.put_line(apps.fnd_file.log,
                           '員工編號:' || l_asset_dist_rec.assigned_to);
    l_asset_dist_rec.transaction_units := l_asset_dist_rec.units_assigned;
    l_asset_dist_tbl(1) := l_asset_dist_rec;
 
    --l_asset_desc_rec.asset_number :=                                             --資產編號 --自動產生
    --l_asset_desc_rec.property_type_code := 'REAL';
    --l_asset_desc_rec.property_1245_1250_code := '1245';
    --l_asset_desc_rec.in_use_flag := 'YES';
    --l_asset_desc_rec.owned_leased := 'OWNED';
    --l_asset_desc_rec.new_used := 'NEW';
    --l_asset_desc_rec.inventorial := 'YES';
    --l_asset_desc_rec.manufacturer_name :=
    --l_asset_desc_rec.serial_number :=
    --l_asset_desc_rec.model_number :=
    --l_asset_desc_rec.tag_number :=
    --l_asset_desc_rec.parent_asset_id :=
    --l_asset_desc_rec.warranty_id :=
    --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          => 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, --檢查API是否應該對資產進行驗證
                                x_return_status        => l_return_status, --確定是否API的成功完成。
                                x_msg_count            => l_mesg_count, --郵件數堆棧的訊息。
                                x_msg_data             => l_mesg, --訊息堆棧
                                p_calling_fn           => null, --調用API函數
                                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, --資產層次的資訊Hierarchy information of the asset
                                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 --對利率表為資產為醫學研究委員會的發票
                                );
    apps.fnd_file.put_line(apps.fnd_file.log,
                           'l_return_status : ' || l_return_status);
    apps.fnd_file.put_line(apps.fnd_file.log,
                           'fnd_api.g_ret_sts_success : ' ||
                           fnd_api.g_ret_sts_success);
    if (l_return_status <> fnd_api.g_ret_sts_success) then
      apps.fnd_file.put_line(apps.fnd_file.log, 'FAILED');
      apps.fnd_file.put_line(apps.fnd_file.log, 'error: ' || 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 := 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
          apps.fnd_file.put_line(apps.fnd_file.log,
                                 substr(l_mesg, ((i * 255) - 254), 255));
        end loop;
      end if;
   
    else
      apps.fnd_file.put_line(apps.fnd_file.log, 'SUCCESS');
      apps.fnd_file.put_line(apps.fnd_file.log,
                             'THID: ' ||
                             to_char(l_trans_rec.transaction_header_id));
      apps.fnd_file.put_line(apps.fnd_file.log,
                             'ASSET_ID: ' ||
                             to_char(l_asset_hdr_rec.asset_id));
      apps.fnd_file.put_line(apps.fnd_file.log,
                             'ASSET_NUMBER: ' ||
                             l_asset_desc_rec.asset_number);
   
    end if;
 
  end auto_import_info_p;

測試指令碼是OK的,測試資料可以順利匯入系統O(∩_∩)O

CCID的擷取還有待研究...

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.