ORACLE ERP导数据(BOM清单)
13、如果在mtl_system_items中,有不存在的物品ITEM时,要把其删除(或是把这些物品Item导入到系统中)
删除:delete cux_bill_temp b
where not exists (select null from mtl_system_items where segment1=b.component_item and organization_id=2);
delete cux_bill_temp a
where not exists (select null from mtl_system_items where segment1=a.assembly_item and organization_id=2);
14、对没有物品Item的进行处理,把其放入另一临时表cux_item_temp中(以备查询及导入mtl_system_items表中)
delete cux_item_temp;
insert into cux_item_temp(
segment1,description)
select distinct item,item
from (
select distinct assembly_item item
from cux_bill_temp b
where not exists (select null from mtl_system_items where segment1=b.assembly_item and organization_id=2)
union
select distinct component_item item
from cux_bill_temp b
where not exists (select null from mtl_system_items where segment1=b.component_item and organization_id=2)
)
;
将找到没有ITEM的BOM数据放到另一个表中,以备下次ITEM导入后在导BOM
create table cux_bom_temp1
select distinct item
from (
select distinct assembly_item item
from cux_bill_temp b
where not exists (select null from mtl_system_items where segment1=b.assembly_item and organization_id=2)
union
select distinct component_item item
from cux_bill_temp b
where not exists (select null from mtl_system_items where segment1=b.component_item and organization_id=2)
)
-----------------------------------------------------------------------------------------------------------
15、从表mtl_system_items中把物品的编码ID加入中转表cux_bill_temp表(从项目主组织)中
update cux_bill_temp b
set assembly_item_id=(select inventory_item_id from mtl_system_items
where segment1=b.assembly_item and organization_id=2),
component_item_id=(select inventory_item_id from mtl_system_items
where segment1=b.component_item and organization_id=2);
16、查看是否有没有物品ID的编码存在(既没有物品的ID被导入临时表cux_bill_temp中)
select row_num
from cux_bill_temp
where assembly_item_id is null or component_item_id is null;
17、对其中导入的数据进行处理
update cux_bill_temp
set OPTIONAL=1
where upper(OPTIONAL_disp) like 'Y%';
update cux_bill_temp
set OPTIONAL=2
where OPTIONAL is null;
update cux_bill_temp
set MUTUALLY_EXCLUSIVE_OPTIONS=1
where upper(MUTUALLY_EXCLUSIVE_O_DISP) like 'Y%';
update cux_bill_temp
set MUTUALLY_EXCLUSIVE_OPTIONS=2
where MUTUALLY_EXCLUSIVE_O_DISP is null;
18、查看cux_bill_temp中的数据处理是否有漏
select count(*)
from cux_bill_temp
where OPTIONAL is null
or MUTUALLY_EXCLUSIVE_OPTIONS is null
or assembly_item_id is null
or component_item_id is null;
19、更新其内的WIP_SUPPLY_TYPE;
update cux_bill_temp
set WIP_SUPPLY_TYPE=6
where component_item like 'B%';
20、删除表中的包(cux_bill_temp中),其相对应于表bom_bill_of_materials(既在表中已经存在了些选项包,不必导入包头,只需导入包内容既可)
delete cux_bill_temp t
where exists (select null from bom_bill_of_materials where assembly_item_id=t.assembly_item_id and organization_id=2);
21、利用已经写好的包写入数据(既写入接口表bom_bill_of_mtls_interface)
exec cux_bom_temp.insert_bill_15(1);
select count(*) from cux_bill_temp temp
where exits (select null from bom_inventory_components b
where temp.bill_sequence_id=b.bill_sequence_id
and temp.component_item_id=b.component_item_id);
delete cux_bill_temp temp
where exists (select null from bom_inventory_components b
where b.bill_sequence_id=temp.bill_sequence_id
and b.component_item_id=temp.component_item_id);
exec cux_bom_temp.insert_bill_10(1);
22、对写入的数据在接口表中的情况进行查看
select count(*) from bom_bill_of_mtls_interface;
23、接着更新
exec cux_bom_temp.insert_bill_15(1);
select count(*) from cux_bill_temp where bill_sequence_id is null;
exec cux_bom_temp.insert_bill_20(1);
去提交请求
select count(*) from bom_inventory_comps_interface;
(导入成功后)对组件进行排序
exec cux_bom_temp.update_bill_item_num4;
select count(*) from bom_inventory_comps_interface;
24、对于接口表中的数据进行导入
delete bom_bill_of_mtls_interface;
insert into bom_bill_of_mtls_interface(
assembly_type,assembly_item_id,
organization_id,
process_flag,transaction_type)
select distinct 1,assembly_item_id,
1,
1,'CREATE'
from cux_bill_temp;