壹佰网|ERP100 - 企业信息化知识门户

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2376|回复: 17

[二次开发] [分享知识 原创连载]ORACLE EBS R12 财务模块接口记录

[复制链接]
发表于 2013/8/12 09:29:55 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622  。

您需要 登录 才可以下载或查看,没有帐号?注册

x
本帖最后由 jojoz 于 2013/8/15 15:50 编辑

开篇先写几句废话吧。
最近两年做了有关金融互联网的项目,发现这些行业有共同的特点,外围系统多,而且业务人员都不喜欢用ORACLE EBS这玩意。
引发的事情就是,基本上所有业务都在外围的一些业务系统做好,然后通过接口导到ORACLE EBS上,财务的同学只需要检查一下,过过帐就over了
从这些项目中,也积累了大量的财务方面的接口知识,现在弄出来丢人现眼一番吧


第一篇,总帐

一、总帐凭证导入说明
1.1 简单导入例子
declare
  l_interface_run_id number;
  l_group_id         number;
  l_dr_rec           gl_interface%rowtype;
  l_cr_rec           gl_interface%rowtype;
  l_request_id       number;
begin
  --初始化
  Fnd_Global.apps_initialize(3632, --user_id
                             50240, --resp_id
                             101); --appl id

  --取INTERFACE_RUN_ID及GROUP_ID
  SELECT gl_journal_import_s.NEXTVAL INTO l_interface_run_id FROM dual;
  SELECT gl_interface_control_s.NEXTVAL INTO l_group_id FROM dual;

  --插入数据至gl_interface表
  --借项
  l_dr_rec.status                := 'NEW'; --状态
  l_dr_rec.ledger_id             := 1001; --分类帐ID
  l_dr_rec.accounting_date       := trunc(sysdate); --GL日期
  l_dr_rec.currency_code         := 'CNY'; --币别
  l_dr_rec.date_created          := sysdate; --创建日期
  l_dr_rec.created_by            := fnd_profile.value('USER_ID'); --创建人
  l_dr_rec.actual_flag           := 'A'; --日记帐种类
  l_dr_rec.user_je_category_name := '手工日记帐'; --类别
  l_dr_rec.user_je_source_name   := '人工'; --来源
  l_dr_rec.period_name           := to_char(sysdate, 'yyyy-mm'); --期间
  l_dr_rec.reference1            := '测试批名';
  l_dr_rec.reference4            := '测试分录名';
  l_dr_rec.reference5            := '测试分录说明';
  l_dr_rec.reference10           := '日记帐分录行说明';
  l_dr_rec.code_combination_id   := 11002; --CCID
  l_dr_rec.entered_dr            := 100;
  l_dr_rec.group_id              := l_group_id;
  insert into gl_interface values l_dr_rec;
  --贷项
  l_cr_rec.status                := 'NEW'; --状态
  l_cr_rec.ledger_id             := 1001; --分类帐ID
  l_cr_rec.accounting_date       := trunc(sysdate); --GL日期
  l_cr_rec.currency_code         := 'CNY'; --币别
  l_cr_rec.date_created          := sysdate; --创建日期
  l_cr_rec.created_by            := fnd_profile.value('USER_ID'); --创建人
  l_cr_rec.actual_flag           := 'A'; --日记帐种类
  l_cr_rec.user_je_category_name := '手工日记帐'; --类别
  l_cr_rec.user_je_source_name   := '人工'; --来源
  l_cr_rec.period_name           := to_char(sysdate, 'yyyy-mm'); --期间
  l_cr_rec.reference1            := '测试批名';
  l_cr_rec.reference4            := '测试分录名';
  l_cr_rec.reference5            := '测试分录说明';
  l_cr_rec.reference10           := '日记帐分录行说明';
  l_cr_rec.code_combination_id   := 11002; --CCID
  l_cr_rec.entered_cr            := 100;
  l_cr_rec.group_id              := l_group_id;
  insert into gl_interface values l_cr_rec;

  --插入数据至gl_interface_control
  INSERT INTO gl_interface_control
    (set_of_books_id,
     interface_run_id,
     je_source_name,
     group_id,
     status,
     packet_id)
  VALUES
    (1001, l_interface_run_id, 'Manual', l_group_id, 'S', NULL);
  commit;

  --提交导入请求
  l_request_id := FND_REQUEST.SUBMIT_REQUEST('SQLGL',
                                             'GLLEZL',
                                             '',
                                             '',
                                             FALSE,
                                             l_interface_run_id,
                                             fnd_profile.value('GL_ACCESS_SET_ID'),
                                             'N', --error to suspense flag
                                             '', --from accounting date
                                             '', --to accounting date
                                             'N', -- create summary flag
                                             'O', --import desc flex flag
                                             'Y' --Data security mode flag
                                             );
  commit;
end;


1.2 手工导入凭证信息的一些小技巧
1.2.1 如何导入凭证头弹性域
(1) 把头弹性域的信息输入至gl_interface字段reference21 ~ reference 30
(2) 在导入完成后,gl_interface字段reference21 ~ reference30的信息将保存于gl_je_lines的reference_1 ~ reference_10字段
(3) 此时可直接把这些信息更新至gl_je_headers中即可
1.2.2 外币汇率的处理方法
(1) 在gl_interface为CURRENCY_CODE,CURRENCY_CONVERSION_DATE 和 USER_CURRENCY_CONVERSION_TYPE列中输入相应值即可
(2) 如果USER_CURRENCY_CONVERSION_TYPE为User即用户汇率,CURRENCY_CONVERSION_RATE列必须输入
(3) 如果不想受计算影响,可以直接为ACCOUNTED_DR 和 ACCOUNTED_CR输入值


1.3 使用WEBADI时的一个小技巧
1.3.1 当WEBADI中存在错误信息或有多人同时使用时,必须设置“GLDI:创建组标识”

1.4 如何控制其他模块导入的总帐凭证的信息
在gl_interface_control加一个trigger即可,简单例子如下
CREATE OR REPLACE TRIGGER CUX_GL_INTERFACE_CONTROL_TRG
  BEFORE INSERT on GL.Gl_Interface_Control
  for each ROW
DECLARE
  l_sql VARCHAR2(6000);
BEGIN
  --为从资产模块导入的数据添加信息
  IF :new.interface_table_name IS NOT NULL and
     :new.je_source_name = 'Assets' THEN
    l_sql := 'UPDATE ' || :new.interface_table_name || ' g
                   SET reference21 = ''测试''
                 WHERE g.group_id =' || :new.group_id;
    EXECUTE IMMEDIATE l_sql;
  END IF;
END;


1.5 字段的详细说明可参考帮助文件或UG
http://www.erp100.com/document/ebs/gl_HTML/gloiji03.htm

二、过帐总帐凭证简单例子
declare
  l_posting_run_id number;
  l_access_set_id  number;
  l_ledger_id      number;
  l_coa_id         number;
  l_request_id     number;
begin
  --初始化
  Fnd_Global.apps_initialize(3632, --user_id
                             50240, --resp_id
                             101); --appl id

  --取初始化值
  l_posting_run_id := gl_je_batches_post_pkg.get_unique_id;
  l_access_set_id  := fnd_profile.value('gl_access_set_id');
  l_ledger_id      := fnd_profile.value 'gl_set_of_books_id');
  select chart_of_accounts_id
    into l_coa_id
    from gl_ledgers l
   where l.ledger_id = l_ledger_id;

  --选取需要过帐的日记帐批
  update gl_je_batches b
     set b.posting_run_id = l_posting_run_id, b.status = 'S'
   where exists (select 1
            from gl_je_headers h
           where h.je_batch_id = b.je_batch_id
             and h.je_header_id = 2009879);
  commit;

  --提交过帐请求
  l_request_id := fnd_request.submit_request('SQLGL',
                                             'GLPPOSS',
                                             '',
                                             '',
                                             FALSE,
                                             To_Char(p_ledger_id),
                                             To_Char(l_access_set_id),
                                             To_Char(l_coa_id),
                                             To_Char(l_posting_run_id),
                                             chr(0));

  commit;
end;


三、删除未过帐日记帐批例子
declare
  l_je_batch_row_id varchar2(18);
  l_je_batch_id     number;
begin
  --初始化
  Fnd_Global.apps_initialize(3632, --user_id
                             50240, --resp_id
                             101); --appl id

  --取批ID及批ROWID
  select b.rowid, b.je_batch_id
    into l_je_batch_row_id, l_je_batch_id
    from gl_je_batches b
   where exists (select 1
            from gl_je_headers h
           where h.je_batch_id = b.je_batch_id
             and h.je_header_id = 2142342);

  --执行批删除
  GL_JE_BATCHES_PKG.Delete_Row(l_je_batch_row_id, l_je_batch_id);
  commit;
end;

四、冲销已过帐日记帐例子
declare
  l_request_id   NUMBER;
  l_je_header_id NUMBER := 78251;
BEGIN
  --初始化
  Fnd_Global.apps_initialize(1130, 50738, 101);

  --设置冲销标记及期间
  update gl_je_headers h
     set h.accrual_rev_flag             = 'Y',
         h.accrual_rev_period_name      = h.period_name,
         h.accrual_rev_change_sign_flag = 'Y'
   where h.je_header_id = l_je_header_id;
  commit;

  --提交冲销请求
  l_request_id := fnd_request.submit_request('SQLGL',
                                       'GLPREV',
                                       '',
                                       '',
                                       FALSE,
                                       fnd_profile.value('gl_access_set_id'),
                                       to_char(l_je_header_id),
                                       chr(0));
  commit;

END;

五、子分类帐分录API使用简单例子
待续




点评

持续关注中  发表于 2013/8/17 10:22
这个连载可是干货;  发表于 2013/8/15 06:55
你终于出手了  发表于 2013/8/12 12:05

本帖被以下淘专辑推荐:

 楼主| 发表于 2013/8/12 09:30:10 | 显示全部楼层
本帖最后由 jojoz 于 2013/9/2 09:59 编辑

第二篇 固定资产

一、资产新增API
declare
  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_inv_rec             FA_API_TYPES.inv_rec_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');
  dbms_output.enable(10000000);
  FA_SRVR_MSG.Init_Server_Message;
  FA_DEBUG_PKG.Initialize;

  --资产描述信息
  l_asset_desc_rec.description    := '电脑';
  l_asset_desc_rec.tag_number := 'BZ20120223003';
  l_asset_desc_rec.asset_key_ccid := 1001;--2;
  l_asset_cat_rec.category_id := 1001;
  l_asset_type_rec.asset_type := 'CAPITALIZED';
  --l_asset_desc_rec.asset_number :=
  --l_asset_desc_rec.property_type_code :=
  --l_asset_desc_rec.property_1245_1250_code :=
  --l_asset_desc_rec.in_use_flag :=
  --l_asset_desc_rec.owned_leased :=
  --l_asset_desc_rec.new_used :=

  --l_asset_desc_rec.inventorial :=
  --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 :=

  --资产发票信息
/*
  -- invoice info
-- l_inv_rec.fixed_assets_cost            := 2500;
-- l_inv_rec.deleted_flag                 := 'NO';
  l_inv_rec.description                  := l_asset_desc_rec.description;
-- l_inv_rec.unrevalued_cost              := 5555;
-- l_inv_rec.create_batch_id              := 1000;
  --l_inv_rec.payables_code_combination_id := 13528;
  l_inv_rec.feeder_system_name           := 'BZ';
-- l_inv_rec.payables_cost                := 5555;
l_inv_rec.payables_units               := 1;
l_inv_rec.po_vendor_id                 := 1;
  --l_inv_rec.inv_indicator                := 1;*/

  l_inv_tbl(1) := l_inv_rec;

  --发票汇率信息
  /*  l_inv_rate_tbl(1).set_of_books_id := 658; -- first reporting book
  l_inv_rate_tbl(1).exchange_rate := .532;

  l_inv_rate_tbl(2).inv_indicator := 1;
  l_inv_rate_tbl(2).set_of_books_id := 659; -- second reporting book
  l_inv_rate_tbl(2).exchange_rate := .233;*/

  --资产财务信息
  l_asset_fin_rec.date_placed_in_service := to_date('2012-01-31','yyyy-mm-dd');--'DPIS';
  l_asset_fin_rec.depreciate_flag        := 'YES';
  l_asset_fin_rec.cost := 6000;

  --资产折旧信息
  l_asset_deprn_rec.ytd_deprn           := 0;
  l_asset_deprn_rec.deprn_reserve       := 0;
  l_asset_deprn_rec.bonus_ytd_deprn     := 0;
  l_asset_deprn_rec.bonus_deprn_reserve := 0;

  --资产转移信息
  l_asset_hdr_rec.book_type_code       :=  'ZZ_FA_BOOK';--'book';
  l_trans_rec.transaction_date_entered := l_asset_fin_rec.date_placed_in_service;
  l_trans_rec.who_info.last_updated_by := 1130;--FND_GLOBAL.USER_ID;

  /* distribution info */
  -- l_asset_dist_tbl := fa_API_TYPES.asset_dist_tbl_type (null);

  l_asset_dist_rec.units_assigned := 1;
  l_asset_dist_rec.expense_ccid := 20005;--12975;
  l_asset_dist_rec.location_ccid := 6001;--2;
  l_asset_dist_rec.assigned_to := null;--81
  l_asset_dist_rec.transaction_units := l_asset_dist_rec.units_assigned;
  l_asset_dist_tbl(1) := l_asset_dist_rec;

  --调用API
  fa_addition_pub .do_addition(1.0,
                               FND_API.G_FALSE,
                               FND_API.G_FALSE,
                               FND_API.G_VALID_LEVEL_FULL,
                               l_return_status,
                               l_mesg_count,
                               l_mesg,
                               null,
                               --
                               l_trans_rec,
                               l_dist_trans_rec,
                               --
                               l_asset_hdr_rec,
                               l_asset_desc_rec,
                               l_asset_type_rec,
                               l_asset_cat_rec,
                               l_asset_hierarchy_rec,
                               l_asset_fin_rec,
                               l_asset_deprn_rec,
                               l_asset_dist_tbl,
                               l_inv_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');
    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' || l_asset_desc_rec.asset_number);
  end if;
end;
/

二、资产描述信息调整
declare
  l_count         NUMBER;
  l_return_status varchar2(100);
  l_msg_count     number := 0;
  l_msg_data      varchar2(4000);
  l_request_id    number;
  reclass_err EXCEPTION;
  i number := 0;
  l_api_version CONSTANT number := 1.0;
  l_msg_list                 VARCHAR2(5) := FND_API.G_FALSE;
  l_commit_flag              VARCHAR2(5) := FND_API.G_FALSE;
  l_validation_level         VARCHAR2(5) := FND_API.G_VALID_LEVEL_FULL;
  l_debug_flag               VARCHAR2(5) := FND_API.G_FALSE;
  l_calling_fn               VARCHAR2(50) := 'Update Asset Desc Script';
  l_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_type_rec           FA_API_TYPES.asset_type_rec_type;
  l_asset_cat_rec            FA_API_TYPES.asset_cat_rec_type;
  l_asset_id                 number(15) := 64;
  l_description              varchar2(30) := substr('Description', 1, 30);
  l_serial_number            varchar2(10) := substr('Serial_number', 1, 10);
  l_category_id              number(15);
  l_transaction_type_code    varchar2(20) := null;
  l_transaction_date_entered date := null;
  l_temp_str                 varchar2(640);
begin
  --初始化
  fnd_profile.put('PRINT_DEBUG', 'Y');
  dbms_output.enable(10000000);
  FA_SRVR_MSG.Init_Server_Message;
  FA_DEBUG_PKG.Initialize;

  l_trans_rec.who_info.last_updated_by := 1001;
  l_trans_rec.who_info.last_update_login := 1001;
  l_trans_rec.who_info.last_update_date := sysdate;
  l_trans_rec.who_info.creation_date    := l_trans_rec.who_info.last_update_date;
  l_trans_rec.who_info.created_by       := l_trans_rec.who_info.last_updated_by;

  l_asset_hdr_rec.asset_id := 64;

  l_asset_desc_rec.description   := l_description;
  l_asset_desc_rec.serial_number := l_serial_number;

  l_asset_cat_rec.desc_flex.attribute1 := 'Test Thru API';
  l_asset_cat_rec.desc_flex.attribute2 := 'Test2 Thru API';

  l_return_status := null;
  dbms_output.put_line('calling FA_ASSET_DESC_PUB.update_desc');
  FA_ASSET_DESC_PUB.update_desc(
                                -- std parameters
                                p_api_version         => l_api_version,
                                p_init_msg_list       => l_msg_list,
                                p_commit              => l_commit_flag,
                                p_validation_level    => l_validation_level,
                                x_return_status       => l_return_status,
                                x_msg_count           => l_msg_count,
                                x_msg_data            => l_msg_data,
                                p_calling_fn          => l_calling_fn,
                                px_trans_rec          => l_trans_rec,
                                px_asset_hdr_rec      => l_asset_hdr_rec,
                                px_asset_desc_rec_new => l_asset_desc_rec,
                                px_asset_cat_rec_new  => l_asset_cat_rec);

  -- rollback;
  dbms_output.put_line('l_return_status ' || l_return_status);
  if l_return_status = 'E' then
    l_msg_count := fnd_msg_pub.count_msg;

    if (l_msg_count > 0) then
      dbms_output.put_line('l_msg_count ' || to_char(l_msg_count));
      l_temp_str := substr(fnd_msg_pub.get(fnd_msg_pub.G_FIRST,
                                         fnd_api.G_FALSE),
                         1,
                         230);
      dbms_output.put_line(l_temp_str);

      l_temp_str := null;
      for I in 1 .. (l_msg_count - 1) loop
        l_temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);
        dbms_output.put_line(l_temp_str);
      end loop;
    else
      dbms_output.put_line('dump: NO MESSAGE !');
    end if;
    return;
  end if;

  fa_srvr_msg.add_message(calling_fn => 'reclass.sql',
                          name       => 'FA_SHARED_END_SUCCESS',
                          token1     => 'PROGRAM',
                          value1     => 'FA_ASSET_DESC_PUB.update_desc');

exception
  when reclass_err then
    ROLLBACK WORK;
    fa_srvr_msg.add_message(calling_fn => 'reclass.sql',
                            name       => 'FA_SHARED_PROGRAM_FAILED',
                            token1     => 'PROGRAM',
                            value1     => 'FA_ASSET_DESC_PUB.update_desc');

    l_msg_count := fnd_msg_pub.count_msg;
    if (l_msg_count > 0) then
      l_temp_str := fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE);
      dbms_output.put_line('dump: ' || l_temp_str);

      for I in 1 .. (l_msg_count - 1) loop
        temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);
        dbms_output.put_line('dump: ' || l_temp_str);
      end loop;
    else
      dbms_output.put_line('dump: NO MESSAGE !');
    end if;
  when others then
    rollback work;
    fa_srvr_msg.add_sql_error(calling_fn => 'fa_asset_desc_pub..update_desc');
    raise FND_API.G_EXC_UNEXPECTED_ERROR;
end;
/

三、资产交易信息及财务信息调整
declare
  l_trans_rec                 FA_API_TYPES.trans_rec_type;
  l_asset_hdr_rec             FA_API_TYPES.asset_hdr_rec_type;
  l_asset_fin_rec_adj         FA_API_TYPES.asset_fin_rec_type;
  l_asset_fin_rec_new         FA_API_TYPES.asset_fin_rec_type;
  l_asset_fin_mrc_tbl_new     FA_API_TYPES.asset_fin_tbl_type;
  l_inv_trans_rec             FA_API_TYPES.inv_trans_rec_type;
  l_inv_tbl                   FA_API_TYPES.inv_tbl_type;
  l_inv_rate_tbl              FA_API_TYPES.inv_rate_tbl_type;
  l_asset_deprn_rec_adj       FA_API_TYPES.asset_deprn_rec_type;
  l_asset_deprn_rec_new       FA_API_TYPES.asset_deprn_rec_type;
  l_asset_deprn_mrc_tbl_new   FA_API_TYPES.asset_deprn_tbl_type;
  l_inv_rec                   FA_API_TYPES.inv_rec_type;
  l_group_reclass_options_rec FA_API_TYPES.group_reclass_options_rec_type;
  l_return_status             VARCHAR2(1);
  l_mesg_count                number := 0;
  l_mesg_len                  number;
  l_mesg                      varchar2(512);
begin
  --初始化
  fnd_profile.put('PRINT_DEBUG', 'Y');
  dbms_output.enable(10000000);
  FA_SRVR_MSG.Init_Server_Message;
  FA_DEBUG_PKG.Initialize;

  l_asset_hdr_rec.asset_id       := 64;--asset_id;
  l_asset_hdr_rec.book_type_code := 'ZZ_FA_BOOK';
  -- invoice trans
  l_inv_trans_rec.transaction_type := 'INVOICE ADDITION';
  -- invoice info
  l_inv_rec.fixed_assets_cost            := 3000;
  l_inv_rec.DELETED_FLAG                 := 'NO';
  l_inv_rec.description                  := 'TEST NIV';
  l_inv_rec.unrevalued_cost              := 0;
  l_inv_rec.create_batch_id              := 1000;
  --l_inv_rec.payables_code_combination_id := 13528;
  l_inv_rec.payables_cost                := 2500;
  l_inv_rec.payables_units               := 1;
  l_inv_rec.inv_indicator                := 1;
  -- rate info for mrc
/*  l_inv_rate_tbl(1).inv_indicator := 1;
  l_inv_rate_tbl(1).set_of_books_id := 425;
  l_inv_rate_tbl(1).exchange_rate := 50;*/
  -- set up the invoice table
  l_inv_tbl(1) := l_inv_rec;

  FA_ADJUSTMENT_PUB.do_adjustment(1.0,
                                   FND_API.G_FALSE,
                                   FND_API.G_FALSE,
                                   FND_API.G_VALID_LEVEL_FULL,
                                   null,
                                   l_return_status,
                                   l_mesg_count,
                                   l_mesg,
                                   l_trans_rec,
                                   l_asset_hdr_rec,
                                   l_asset_fin_rec_adj,
                                   l_asset_fin_rec_new,
                                   l_asset_fin_mrc_tbl_new,
                                   l_inv_trans_rec,
                                   l_inv_tbl,
                                   l_asset_deprn_rec_adj,
                                   l_asset_deprn_rec_new,
                                   l_asset_deprn_mrc_tbl_new,
                                   l_group_reclass_options_rec);
  dbms_output.put_line(l_return_status);
  if (l_return_status <> FND_API.G_RET_STS_SUCCESS) then
    fa_debug_pkg.dump_debug_messages(max_mesgs => 0);
    l_mesg_count := fnd_msg_pub.count_msg;
    if l_mesg_count > 0 then
      l_mesg := substr(fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE),
                       1,
                       512);
      dbms_output.put_line(substr(l_mesg, 1, 255));
      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,
                         512);
        dbms_output.put_line(substr(l_mesg, 1, 255));
      end loop;
      fnd_msg_pub.delete_msg();
    end if;
  else
    dbms_output.put_line('SUCCESS');
    dbms_output.put_line('THID' ||
                         to_char(l_trans_rec.transaction_header_id));
  end if;
end;
/


三、资产删除(限刚创建,无折旧,无报废等资产)
declare

    l_asset_hdr_rec            FA_API_TYPES.asset_hdr_rec_type;

    l_return_status            VARCHAR2(1);
    l_mesg_count               number := 0;
    l_mesg_len                 number;
    l_mesg                     varchar2(4000);

begin

   dbms_output.enable(1000000);

   FA_SRVR_MSG.Init_Server_Message;

   -- asset header info
   l_asset_hdr_rec.asset_id       := 64
   l_asset_hdr_rec.book_type_code := 'ZZ_FA_BOOK';


   FA_DELETION_PUB.do_delete
      (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,
       x_return_status           => l_return_status,
       x_msg_count               => l_mesg_count,
       x_msg_data                => l_mesg,
       p_calling_fn              => null,
       px_asset_hdr_rec          => l_asset_hdr_rec
      );


   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('ASSET_ID' || to_char(l_asset_hdr_rec.asset_id));
     dbms_output.put_line('BOOK: ' || l_asset_hdr_rec.book_type_code);
   end if;

end;
/


四、资产分配
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
  l_asset_hdr_rec.asset_id       := 49;
  l_asset_hdr_rec.book_type_code := 'ZZ_FA_BOOK';

  -- 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 := 2007;
  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;
  l_asset_dist_tbl(1).assigned_to := 11;
  l_asset_dist_tbl(1).expense_ccid :=15338;
  l_asset_dist_tbl(1).location_ccid := 3; */
  -- fill in dist info for destination distribution
  l_asset_dist_tbl(2).transaction_units := 1;
  l_asset_dist_tbl(2).assigned_to := 81;
  l_asset_dist_tbl(2).expense_ccid := 1013;--15338;
  l_asset_dist_tbl(2).location_ccid := 1;--3;



  l_trans_rec.who_info.last_updated_by   := 1130;--FND_GLOBAL.USER_ID;
  l_trans_rec.who_info.last_update_login := 10001;--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;
/

五、资产报废
declare
  api_error EXCEPTION;
  /* Test asset info */
  l_asset_id       number;
  l_book_type_code varchar2(15) := 'ZZ_FA_BOOK';
  l_user_id        number := 1130; -- USER_ID must properly be set to run calc gain/loss

  --/ define local record types /
  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_retire_rec FA_API_TYPES.asset_retire_rec_type;
  l_asset_dist_tbl   FA_API_TYPES.asset_dist_tbl_type;
  l_subcomp_tbl      FA_API_TYPES.subcomp_tbl_type;
  l_inv_tbl          FA_API_TYPES.inv_tbl_type;

  --/ misc info /
  l_api_version      number := 1;
  l_init_msg_list    varchar2(1) := FND_API.G_FALSE;
  l_commit           varchar2(1) := FND_API.G_FALSE;
  l_validation_level number := FND_API.G_VALID_LEVEL_FULL;
  l_calling_fn       varchar2(80) := 'Retirement test wrapper';
  l_return_status    varchar2(1) := FND_API.G_FALSE;
  l_msg_count        number := 0;
  l_msg_data         varchar2(512);

  l_count      number;
  l_request_id number;

  i number := 0;

  temp_str   varchar2(512);
  mesg_count number;

begin

  dbms_output.disable;
  dbms_output.enable(1000000);
  dbms_output.put_line('begin');
  fa_srvr_msg.init_server_message;
  fa_debug_pkg.set_debug_flag(debug_flag => 'YES');

  -- Get standard who info
  l_request_id := fnd_global.conc_request_id;
  l_asset_id   := 100014573;
  --A530000000104

  l_trans_rec.who_info.last_updated_by := 1130;
  l_trans_rec.who_info.last_update_login := -1;

  l_trans_rec.who_info.last_update_date := sysdate;
  l_trans_rec.who_info.creation_date    := l_trans_rec.who_info.last_update_date;
  l_trans_rec.who_info.created_by       := l_trans_rec.who_info.last_updated_by;

  l_trans_rec.transaction_type_code    := NULL; -- this will be determined inside API
  l_trans_rec.transaction_date_entered := NULL;

  l_asset_hdr_rec.asset_id           := l_asset_id;
  l_asset_hdr_rec.book_type_code     := l_book_type_code;
  l_asset_hdr_rec.period_of_addition := NULL;

  l_asset_retire_rec.retirement_prorate_convention := null;--'STL';
  l_asset_retire_rec.date_retired                  := null; -- will be current period by default
  l_asset_retire_rec.units_retired                 := 1;
  l_asset_retire_rec.cost_retired                  := 6266806.97;
  --  l_asset_retire_rec.proceeds_of_sale              := 0;
  -- l_asset_retire_rec.cost_of_removal               := 0;
  -- l_asset_retire_rec.retirement_type_code          := 'SALE';
  l_asset_retire_rec.trade_in_asset_id   := NULL;
  l_asset_retire_rec.calculate_gain_loss := FND_API.G_true;--特别注意,如果此处为TRUE,则资产只能进行重建,如果FALSE,则报废可以进行UNDO操作

  fnd_profile.put('USER_ID', l_user_id);

  l_asset_dist_tbl.delete;
  --l_asset_dist_tbl(1).distribution_id := 4003;

  FA_RETIREMENT_PUB.do_retirement(p_api_version       => l_api_version,
                                  p_init_msg_list     => l_init_msg_list,
                                  p_commit            => l_commit,
                                  p_validation_level  => l_validation_level,
                                  p_calling_fn        => l_calling_fn,
                                  x_return_status     => l_return_status,
                                  x_msg_count         => l_msg_count,
                                  x_msg_data          => l_msg_data,
                                  px_trans_rec        => l_trans_rec,
                                  px_dist_trans_rec   => l_dist_trans_rec,
                                  px_asset_hdr_rec    => l_asset_hdr_rec,
                                  px_asset_retire_rec => l_asset_retire_rec,
                                  p_asset_dist_tbl    => l_asset_dist_tbl,
                                  p_subcomp_tbl       => l_subcomp_tbl,
                                  p_inv_tbl           => l_inv_tbl);

  if l_return_status = FND_API.G_FALSE then
    raise api_error;
  end if;

  dbms_output.put_line('test wrapper: retirement_id: ' ||
                       l_asset_retire_rec.retirement_id);
  --commit;

  -- Dump Debug messages when run in debug mode to log file
  if (fa_debug_pkg.print_debug) then
    fa_debug_pkg.Write_Debug_Log;
  end if;

  fa_srvr_msg.add_message(calling_fn => l_calling_fn,
                          name       => 'FA_SHARED_END_SUCCESS',
                          token1     => 'PROGRAM',
                          value1     => 'RETIREMENT_API');

  mesg_count := fnd_msg_pub.count_msg;

  if (mesg_count > 0) then
    temp_str := fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE);
    dbms_output.put_line('dump: ' || temp_str);

    for I in 1 .. (mesg_count - 1) loop
      temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);
      dbms_output.put_line('dump: ' || temp_str);
    end loop;
  else
    dbms_output.put_line('dump: NO MESSAGE !');
  end if;

exception
  when api_error then
    ROLLBACK WORK;

    fa_srvr_msg.add_message(calling_fn => l_calling_fn,
                            name       => 'FA_SHARED_PROGRAM_FAILED',
                            token1     => 'PROGRAM',
                            value1     => l_calling_fn);

    mesg_count := fnd_msg_pub.count_msg;
    if (mesg_count > 0) then
      temp_str := fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE);
      dbms_output.put_line('dump: ' || temp_str);

      for I in 1 .. (mesg_count - 1) loop
        temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);
        dbms_output.put_line('dump: ' || temp_str);
      end loop;
    else
      dbms_output.put_line('dump: NO MESSAGE !');
    end if;

end;
/

六、撤消资产报废(只能撤消未进行“计算损益”的报废)
declare
  api_error EXCEPTION;
  l_retirement_id number := 2013;
  --l_asset_id number := 101027;
  --l_book_type_code varchar2(15) := 'ZBOOK';
  l_user_id number := 1130; -- USER_ID must properly be set to run calc gain/loss

  --/ define local record types /
  l_trans_rec        FA_API_TYPES.trans_rec_type;
  l_asset_hdr_rec    FA_API_TYPES.asset_hdr_rec_type;
  l_asset_retire_rec FA_API_TYPES.asset_retire_rec_type;
  l_asset_dist_tbl   FA_API_TYPES.asset_dist_tbl_type;
  l_subcomp_tbl      FA_API_TYPES.subcomp_tbl_type;
  l_inv_tbl          FA_API_TYPES.inv_tbl_type;

  -- / misc info /
  l_api_version      number := 1;
  l_init_msg_list    varchar2(1) := FND_API.G_FALSE;
  l_commit           varchar2(1) := FND_API.G_TRUE;
  l_validation_level number := FND_API.G_VALID_LEVEL_FULL;
  l_calling_fn       varchar2(80) := 'Retirement test wrapper';
  l_return_status    varchar2(1) := FND_API.G_FALSE;
  l_msg_count        number := 0;
  l_msg_data         varchar2(512);

  l_count      number;
  l_request_id number;

  i number := 0;

  temp_str   varchar2(512);
  mesg_count number;

begin

  dbms_output.disable;
  dbms_output.enable(1000000);
  dbms_output.put_line('begin');
  fa_srvr_msg.init_server_message;
  fa_debug_pkg.set_debug_flag(debug_flag => 'YES');

  -- Get standard who info
  l_request_id := fnd_global.conc_request_id;
  l_trans_rec.who_info.last_updated_by := -1;
  l_trans_rec.who_info.last_update_login := -1;
  l_trans_rec.who_info.last_update_date := sysdate;
  l_trans_rec.who_info.creation_date    := l_trans_rec.who_info.last_update_date;
  l_trans_rec.who_info.created_by       := l_trans_rec.who_info.last_updated_by;

  l_trans_rec.transaction_type_code    := NULL; -- this will be determined inside API
  l_trans_rec.transaction_date_entered := NULL;

  -- l_asset_hdr_rec.asset_id := l_asset_id;
  -- l_asset_hdr_rec.book_type_code := l_book_type_code;
  -- l_asset_hdr_rec.period_of_addition := NULL;

  l_asset_retire_rec.retirement_id := l_retirement_id;

  fnd_profile.put('USER_ID', l_user_id);

  FA_RETIREMENT_PUB.undo_retirement(p_api_version      => l_api_version,
                                    p_init_msg_list    => l_init_msg_list,
                                    p_commit           => l_commit,
                                    p_validation_level => l_validation_level,
                                    p_calling_fn       => l_calling_fn,
                                    x_return_status    => l_return_status,
                                    x_msg_count        => l_msg_count,
                                    x_msg_data         => l_msg_data

                                   ,
                                    px_trans_rec        => l_trans_rec,
                                    px_asset_hdr_rec    => l_asset_hdr_rec,
                                    px_asset_retire_rec => l_asset_retire_rec);

  if l_return_status = FND_API.G_FALSE then
    raise api_error;
  end if;

  commit;

  -- Dump Debug messages when run in debug mode to log file
  if (fa_debug_pkg.print_debug) then
    fa_debug_pkg.Write_Debug_Log;
  end if;

  fa_srvr_msg.add_message(calling_fn => l_calling_fn,
                          name       => 'FA_SHARED_END_SUCCESS',
                          token1     => 'PROGRAM',
                          value1     => 'RETIREMENT_API');

  mesg_count := fnd_msg_pub.count_msg;

  if (mesg_count > 0) then
    temp_str := fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE);
    dbms_output.put_line('dump: ' || temp_str);

    for I in 1 .. (mesg_count - 1) loop
      temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);
      dbms_output.put_line('dump: ' || temp_str);
    end loop;
  else
    dbms_output.put_line('dump: NO MESSAGE !');
  end if;

exception
  when api_error then
    ROLLBACK WORK;

    fa_srvr_msg.add_message(calling_fn => l_calling_fn,
                            name       => 'FA_SHARED_PROGRAM_FAILED',
                            token1     => 'PROGRAM',
                            value1     => l_calling_fn);

    mesg_count := fnd_msg_pub.count_msg;
    if (mesg_count > 0) then
      temp_str := fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE);
      dbms_output.put_line('dump: ' || temp_str);

      for I in 1 .. (mesg_count - 1) loop
        temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);
        dbms_output.put_line('dump: ' || temp_str);
      end loop;
    else
      dbms_output.put_line('dump: NO MESSAGE !');
    end if;
end;
/

七、报废资产重建
declare
  api_error EXCEPTION;
  --/ Test asset info /
  l_retirement_id number := 2012;
  --l_asset_id number := 100837;
  --l_book_type_code varchar2(15) := 'ZBOOK1';
  l_user_id number := 1130; -- USER_ID must properly be set to run calc gain/loss
  --/ define local record types /
  l_trans_rec        FA_API_TYPES.trans_rec_type;
  l_asset_hdr_rec    FA_API_TYPES.asset_hdr_rec_type;
  l_asset_retire_rec FA_API_TYPES.asset_retire_rec_type;
  l_asset_dist_tbl   FA_API_TYPES.asset_dist_tbl_type;
  l_subcomp_tbl      FA_API_TYPES.subcomp_tbl_type;
  l_inv_tbl          FA_API_TYPES.inv_tbl_type;

  --/ misc info /
  l_api_version      number := 1;
  l_init_msg_list    varchar2(1) := FND_API.G_FALSE;
  l_commit           varchar2(1) := FND_API.G_false;
  l_validation_level number := FND_API.G_VALID_LEVEL_FULL;
  l_calling_fn       varchar2(80) := 'Retirement test wrapper';
  l_return_status    varchar2(1) := FND_API.G_FALSE;
  l_msg_count        number := 0;
  l_msg_data         varchar2(512);

  l_count      number;
  l_request_id number;

  i number := 0;

  temp_str   varchar2(512);
  mesg_count number;

begin
  dbms_output.disable;
  dbms_output.enable(1000000);
  dbms_output.put_line('begin');
  fa_srvr_msg.init_server_message;
  fa_debug_pkg.set_debug_flag(debug_flag => 'YES');

  -- Get standard who info
  l_request_id := fnd_global.conc_request_id;
  l_trans_rec.who_info.last_updated_by := -1;
  l_trans_rec.who_info.last_update_login := -1;

  l_trans_rec.who_info.last_update_date := sysdate;
  l_trans_rec.who_info.creation_date    := l_trans_rec.who_info.last_update_date;
  l_trans_rec.who_info.created_by       := l_trans_rec.who_info.last_updated_by;

  l_trans_rec.transaction_type_code    := NULL; -- this will be determined inside API
  l_trans_rec.transaction_date_entered := NULL;

  --l_asset_hdr_rec.asset_id := l_asset_id;
  --l_asset_hdr_rec.book_type_code := l_book_type_code;
  --l_asset_hdr_rec.period_of_addition := NULL;

  --l_asset_retire_rec.date_retired := NULL; -- will be current period by default
  --l_asset_retire_rec.units_retired := NULL;
  l_asset_retire_rec.calculate_gain_loss := FND_API.G_TRUE;--特别注意,如果此处为TRUE,则资产只能进行重新报废,如果FALSE,则重建可以进行UNDO操作
  l_asset_retire_rec.retirement_id       := l_retirement_id;

  fnd_profile.put('USER_ID', l_user_id);

  l_asset_dist_tbl.delete;

  --l_asset_dist_tbl(1).distribution_id := 975;
  --l_asset_dist_tbl(1).transaction_units := -1;
  --l_asset_dist_tbl(1).units_assigned := null;
  --l_asset_dist_tbl(1).assigned_to := null;
  --l_asset_dist_tbl(1).expense_ccid := null;
  --l_asset_dist_tbl(1).location_ccid := null;

  FA_RETIREMENT_PUB.do_reinstatement(p_api_version      => l_api_version,
                                     p_init_msg_list    => l_init_msg_list,
                                     p_commit           => l_commit,
                                     p_validation_level => l_validation_level,
                                     p_calling_fn       => l_calling_fn,
                                     x_return_status    => l_return_status,
                                     x_msg_count        => l_msg_count,
                                     x_msg_data         => l_msg_data

                                    ,
                                     px_trans_rec        => l_trans_rec,
                                     px_asset_hdr_rec    => l_asset_hdr_rec,
                                     px_asset_retire_rec => l_asset_retire_rec,
                                     p_asset_dist_tbl    => l_asset_dist_tbl,
                                     p_subcomp_tbl       => l_subcomp_tbl,
                                     p_inv_tbl           => l_inv_tbl);

  if l_return_status = FND_API.G_FALSE then
    raise api_error;
  end if;

  commit;

  -- Dump Debug messages when run in debug mode to log file
  if (fa_debug_pkg.print_debug) then
    fa_debug_pkg.Write_Debug_Log;
  end if;

  fa_srvr_msg.add_message(calling_fn => l_calling_fn,
                          name       => 'FA_SHARED_END_SUCCESS',
                          token1     => 'PROGRAM',
                          value1     => 'RETIREMENT_API');

  mesg_count := fnd_msg_pub.count_msg;

  if (mesg_count > 0) then
    temp_str := fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE);
    dbms_output.put_line('dump: ' || temp_str);

    for I in 1 .. (mesg_count - 1) loop
      temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);
      dbms_output.put_line('dump: ' || temp_str);
    end loop;
  else
    dbms_output.put_line('dump: NO MESSAGE !');
  end if;

exception
  when api_error then
    ROLLBACK WORK;

    fa_srvr_msg.add_message(calling_fn => l_calling_fn,
                            name       => 'FA_SHARED_PROGRAM_FAILED',
                            token1     => 'PROGRAM',
                            value1     => l_calling_fn);

    mesg_count := fnd_msg_pub.count_msg;
    if (mesg_count > 0) then
      temp_str := fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE);
      dbms_output.put_line('dump: ' || temp_str);

      for I in 1 .. (mesg_count - 1) loop
        temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);
        dbms_output.put_line('dump: ' || temp_str);
      end loop;
    else
      dbms_output.put_line('dump: NO MESSAGE !');
    end if;

end;
/


八、撤消资产重建(限于未进行“计算损益”的重建资产)

declare
  api_error EXCEPTION;
  /* Test asset info */
  l_retirement_id number := 2011;
  --l_asset_id number := 100837;
  --l_book_type_code varchar2(15) := 'ZBOOK1';
  l_user_id number := 1001; -- USER_ID must properly be set to run calc gain/loss
  /* define local record types */
  l_trans_rec        FA_API_TYPES.trans_rec_type;
  l_asset_hdr_rec    FA_API_TYPES.asset_hdr_rec_type;
  l_asset_retire_rec FA_API_TYPES.asset_retire_rec_type;
  l_asset_dist_tbl   FA_API_TYPES.asset_dist_tbl_type;
  l_subcomp_tbl      FA_API_TYPES.subcomp_tbl_type;
  l_inv_tbl          FA_API_TYPES.inv_tbl_type;
  /* misc info */
  l_api_version      number := 1;
  l_init_msg_list    varchar2(1) := FND_API.G_FALSE;
  l_commit           varchar2(1) := FND_API.G_TRUE;
  l_validation_level number := FND_API.G_VALID_LEVEL_FULL;
  l_calling_fn       varchar2(80) := 'Retirement test wrapper';
  l_return_status    varchar2(1) := FND_API.G_FALSE;
  l_msg_count        number := 0;
  l_msg_data         varchar2(512);
  l_count            number;
  l_request_id       number;
  i                  number := 0;
  temp_str           varchar2(512);
  mesg_count         number;
begin
  dbms_output.disable;
  dbms_output.enable(1000000);
  dbms_output.put_line('begin');
  fa_srvr_msg.init_server_message;
  fa_debug_pkg.set_debug_flag(debug_flag => 'YES');
  -- Set rollback segment if profile option is set
  /*
  fnd_profile.get('FA_LARGE_ROLLBACK_SEGMENT', rbs_name);
  IF (rbs_name is not NULL) THEN
  sql_stmt := 'SET TRANSACTION USE ROLLBACK SEGMENT ' || rbs_name;
  execute immediate sql_stmt;
  END IF;
  */
  -- Get standard who info
  l_request_id := fnd_global.conc_request_id;
  l_trans_rec.who_info.last_updated_by := -1;
  l_trans_rec.who_info.last_update_login := -1;
  l_trans_rec.who_info.last_update_date := sysdate;
  l_trans_rec.who_info.creation_date    := l_trans_rec.who_info.last_update_date;
  l_trans_rec.who_info.created_by       := l_trans_rec.who_info.last_updated_by;
  l_trans_rec.transaction_type_code     := NULL; -- this will be determined inside API
  l_trans_rec.transaction_date_entered  := NULL;
  -- l_asset_hdr_rec.asset_id := l_asset_id;
  -- l_asset_hdr_rec.book_type_code := l_book_type_code;
  -- l_asset_hdr_rec.period_of_addition := NULL;
  l_asset_retire_rec.retirement_id := l_retirement_id;
  fnd_profile.put('USER_ID', l_user_id);

  FA_RETIREMENT_PUB.undo_reinstatement(p_api_version       => l_api_version,
                                       p_init_msg_list     => l_init_msg_list,
                                       p_commit            => l_commit,
                                       p_validation_level  => l_validation_level,
                                       p_calling_fn        => l_calling_fn,
                                       x_return_status     => l_return_status,
                                       x_msg_count         => l_msg_count,
                                       x_msg_data          => l_msg_data,
                                       px_trans_rec        => l_trans_rec,
                                       px_asset_hdr_rec    => l_asset_hdr_rec,
                                       px_asset_retire_rec => l_asset_retire_rec);
  if l_return_status = FND_API.G_FALSE then
    raise api_error;
  end if;
  commit;
  -- Dump Debug messages when run in debug mode to log file
  if (fa_debug_pkg.print_debug) then
    fa_debug_pkg.Write_Debug_Log;
  end if;
  fa_srvr_msg.add_message(calling_fn => l_calling_fn,
                          name       => 'FA_SHARED_END_SUCCESS',
                          token1     => 'PROGRAM',
                          value1     => 'RETIREMENT_API');
  mesg_count := fnd_msg_pub.count_msg;
  if (mesg_count > 0) then
    temp_str := fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE);
    dbms_output.put_line('dump: ' || temp_str);
    for I in 1 .. (mesg_count - 1) loop
      temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);
      dbms_output.put_line('dump: ' || temp_str);
    end loop;
  else
    dbms_output.put_line('dump: NO MESSAGE !');
  end if;
exception
  when api_error then
    ROLLBACK WORK;
    fa_srvr_msg.add_message(calling_fn => l_calling_fn,
                            name       => 'FA_SHARED_PROGRAM_FAILED',
                            token1     => 'PROGRAM',
                            value1     => l_calling_fn);
    mesg_count := fnd_msg_pub.count_msg;
    if (mesg_count > 0) then
      temp_str := fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE);
      dbms_output.put_line('dump: ' || temp_str);
      for I in 1 .. (mesg_count - 1) loop
        temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);
        dbms_output.put_line('dump: ' || temp_str);
      end loop;
    else
      dbms_output.put_line('dump: NO MESSAGE !');
    end if;
end;
/












 楼主| 发表于 2013/8/12 09:31:19 | 显示全部楼层
第三篇 客户,供应商,员工,银行
待续

点评

该更新了  发表于 2013/9/16 14:38
 楼主| 发表于 2013/8/12 09:32:36 | 显示全部楼层
第三篇 客户,供应商,员工,银行
待续

 楼主| 发表于 2013/8/12 09:33:13 | 显示全部楼层
第四篇 应收帐款
待续
 楼主| 发表于 2013/8/12 09:33:33 | 显示全部楼层
第五篇 应付帐款
待续

点评

哈哈,框架出来了  发表于 2013/8/12 22:55
发表于 2013/8/13 14:47:02 | 显示全部楼层
楼主啊,详细点嘛{:soso_e144:}

点评

会比较详细的,相信组织;  发表于 2013/8/13 15:43
发表于 2013/8/14 23:52:47 | 显示全部楼层
行家终于出手顶起{:soso_e179:}
发表于 2013/9/10 11:58:43 | 显示全部楼层
这帖太好了,学习!收藏!
发表于 2013/9/11 10:23:15 | 显示全部楼层
这个必须严重关注一下!!!{:soso_e179:}
发表于 2013/9/13 17:19:32 | 显示全部楼层
占个位置,等内外部供应商+银行!支持支持
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|手机版|壹佰网 ERP100 ( 京ICP备19053597号-2 )

Copyright © 2005-2012 北京海之大网络技术有限责任公司 服务器托管由互联互通
手机:13911575376
网站技术点击发送消息给对方83569622   广告&合作 点击发送消息给对方27675401   点击发送消息给对方634043306   咨询及人才点击发送消息给对方138011526

GMT+8, 2025/11/29 02:04 , Processed in 0.027001 second(s), 17 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表