更新PAC期初成本

来源:互联网 发布:mac dns设置成什么值 编辑:程序博客网 时间:2024/06/01 10:43

1、创建临时表,存放期初数据

create table cux_bh_cost_ny7 (item_id number,      item_num varchar2(260),      item_des varchar2(260),      cost_group_id number,      pac_period_id number,      quantity number,      item_cost_amount number);

2、将整理的数据添加到临时表

select * from cux_bh_cost_ny7 for update;

3、更新PAC物料成本表

declare  cursor c_c is    select cpic.cost_layer_id, t.*      from cst_pac_item_costs cpic, cux_bh_cost_ny7 t     where t.item_id = cpic.inventory_item_id       and t.pac_period_id = cpic.pac_period_id       and t.cost_group_id = cpic.cost_group_id;begin  for c in c_c loop    update cst_pac_item_costs t       set t.total_layer_quantity = c.quantity     where t.cost_layer_id = c.cost_layer_id;    update cst_pac_item_cost_details t       set t.item_balance = c.item_cost_amount,           t.item_cost    = c.item_cost_amount / c.quantity     where t.cost_layer_id = c.cost_layer_id;  end loop;  commit;end;

4、提交PAC成本计算程序,系统将会按照新的数量和金额产生PAC期初成本。

原创粉丝点击