ITPub博客

首页 > Linux操作系统 > Linux操作系统 > improt bom正确程序

improt bom正确程序

原创 Linux操作系统 作者:ceo_lxy 时间:2008-11-28 10:09:27 0 删除 编辑

declare
cursor c1 is
--select * from mtl_system_items where organization_id=299
--and  segment1='5KB1-3100010'
-- select * from ch_castbom_0718 -- where ass_item='EN-GJS40015A'
/*
create table ch_temp008 as
select distinct msi.inventory_item_id,a.ass_item from ch_castbom_0718 a ,mtl_system_items msi
where a.ass_item=msi.segment1
and  msi.organization_id=299
and a.ass_item<>'(临)1A3-12'
*/
 select distinct INVENTORY_ITEM_ID from inquiry.CH_IMPROTBOM_388
where comp_item in
('02001',
'02002',
'03004',
'7001-0200302',
'7001-0200701',
'CP00-0000442')
;
v1 c1%rowtype;
v_seq number;
begin
   open c1;
   loop
   fetch c1 into v1;
   exit when c1%notfound;
   begin
    select  bom_inventory_components_s.nextval into v_seq from  dual;
    insert into  bom_bill_of_mtls_interface
 (ASSEMBLY_ITEM_ID          ,
 ORGANIZATION_ID             ,
 ALTERNATE_BOM_DESIGNATOR     ,
 LAST_UPDATE_DATE              ,
 LAST_UPDATED_BY                ,
 CREATION_DATE                   ,
 CREATED_BY                       ,
 LAST_UPDATE_LOGIN                 ,
 COMMON_ASSEMBLY_ITEM_ID            ,
 SPECIFIC_ASSEMBLY_COMMENT           ,
 PENDING_FROM_ECN                     ,
 ATTRIBUTE_CATEGORY                    ,
 ATTRIBUTE1                             ,
 ATTRIBUTE2                             ,
 ATTRIBUTE3                             ,
 ATTRIBUTE4                             ,
 ATTRIBUTE5                             ,
 ATTRIBUTE6                             ,
 ATTRIBUTE7                             ,
 ATTRIBUTE8                             ,
 ATTRIBUTE9                             ,
 ATTRIBUTE10                            ,
 ATTRIBUTE11                            ,
 ATTRIBUTE12                            ,
 ATTRIBUTE13                            ,
 ATTRIBUTE14                            ,
 ATTRIBUTE15                            ,
 ASSEMBLY_TYPE                          ,
 COMMON_BILL_SEQUENCE_ID                ,
 BILL_SEQUENCE_ID                       ,
 REQUEST_ID                             ,
 PROGRAM_APPLICATION_ID                 ,
 PROGRAM_ID                             ,
 PROGRAM_UPDATE_DATE                    ,
 DEMAND_SOURCE_LINE                     ,
 SET_ID                                 ,
 COMMON_ORGANIZATION_ID                 ,
 DEMAND_SOURCE_TYPE                     ,
 DEMAND_SOURCE_HEADER_ID                ,
 TRANSACTION_ID                         ,
 PROCESS_FLAG                           ,
 ORGANIZATION_CODE                      ,
 COMMON_ORG_CODE                        ,
 ITEM_NUMBER                            ,
 COMMON_ITEM_NUMBER                     ,
 NEXT_EXPLODE_DATE                      ,
 REVISION                               ,
 TRANSACTION_TYPE)
 values
 (
 v1.inventory_item_id,--ASSEMBLY_ITEM_ID
299,-- ORGANIZATION_ID
null,-- ALTERNATE_BOM_DESIGNATOR
sysdate,-- LAST_UPDATE_DATE
1231,-- LAST_UPDATED_BY
sysdate,-- CREATION_DATE
1231,-- CREATED_BY
null,-- LAST_UPDATE_LOGIN
null,-- COMMON_ASSEMBLY_ITEM_ID
null,-- SPECIFIC_ASSEMBLY_COMMENT
null,-- PENDING_FROM_ECN
null,-- ATTRIBUTE_CATEGORY
null,-- ATTRIBUTE1
null,-- ATTRIBUTE2
null,-- ATTRIBUTE3
null,-- ATTRIBUTE4
null,-- ATTRIBUTE5
null,-- ATTRIBUTE6
null,-- ATTRIBUTE7
null,-- ATTRIBUTE8
null,-- ATTRIBUTE9
null,-- ATTRIBUTE10
null,-- ATTRIBUTE11
null,-- ATTRIBUTE12
null,-- ATTRIBUTE13
null,-- ATTRIBUTE14
'upload08',-- ATTRIBUTE15
1,-- ASSEMBLY_TYPE
null,--v_seq,-- COMMON_BILL_SEQUENCE_ID
null,--v_seq,-- BILL_SEQUENCE_ID
null,-- REQUEST_ID
null,-- PROGRAM_APPLICATION_ID
null,-- PROGRAM_ID
null,-- PROGRAM_UPDATE_DATE
null,-- DEMAND_SOURCE_LINE
null,-- SET_ID
null,-- COMMON_ORGANIZATION_ID
null,-- DEMAND_SOURCE_TYPE
null,-- DEMAND_SOURCE_HEADER_ID
null,-- TRANSACTION_ID
1,-- PROCESS_FLAG
null,-- ORGANIZATION_CODE
null,-- COMMON_ORG_CODE
null,-- ITEM_NUMBER
null,-- COMMON_ITEM_NUMBER
null,-- NEXT_EXPLODE_DATE
null,-- REVISION
'CREATE'-- TRANSACTION_TYPE
 )   ;
 commit;
 declare
 cursor c2 is
 select b.COMP_ITEM_ID  inventory_item_id,round(to_number(b.COMP_QTY,'999999999.999999999'),4) qty
 from inquiry.CH_IMPROTBOM_388 b
where b.comp_item in
('02001',
'02002',
'03004',
'7001-0200302',
'7001-0200701',
'CP00-0000442') and b.inventory_item_id=v1.inventory_item_id
;
 V2 c2%rowtype;
 begin
    open c2;
    loop
    fetch c2 into v2;
    exit when c2%notfound;
    begin
       insert into bom_inventory_comps_interface
 (
  OPERATION_SEQ_NUM                      ,
 COMPONENT_ITEM_ID                      ,
 LAST_UPDATE_DATE                       ,
 LAST_UPDATED_BY                        ,
 CREATION_DATE                          ,
 CREATED_BY                             ,
 LAST_UPDATE_LOGIN                      ,
 ITEM_NUM                               ,
 COMPONENT_QUANTITY                     ,
 COMPONENT_YIELD_FACTOR                 ,
 COMPONENT_REMARKS                      ,
 EFFECTIVITY_DATE                       ,
 CHANGE_NOTICE                          ,
 IMPLEMENTATION_DATE                    ,
 DISABLE_DATE                           ,
 ATTRIBUTE_CATEGORY                     ,
 ATTRIBUTE1                             ,
 ATTRIBUTE2                             ,
 ATTRIBUTE3                             ,
 ATTRIBUTE4                             ,
 ATTRIBUTE5                             ,
 ATTRIBUTE6                             ,
 ATTRIBUTE7                             ,
 ATTRIBUTE8                             ,
 ATTRIBUTE9                             ,
 ATTRIBUTE10                            ,
 ATTRIBUTE11                            ,
 ATTRIBUTE12                            ,
 ATTRIBUTE13                            ,
 ATTRIBUTE14                            ,
 ATTRIBUTE15                            ,
 PLANNING_FACTOR                        ,
 QUANTITY_RELATED                       ,
 SO_BASIS                               ,
 OPTIONAL                               ,
 MUTUALLY_EXCLUSIVE_OPTIONS             ,
 INCLUDE_IN_COST_ROLLUP                 ,
 CHECK_ATP                              ,
 SHIPPING_ALLOWED                       ,
 REQUIRED_TO_SHIP                       ,
 REQUIRED_FOR_REVENUE                   ,
 INCLUDE_ON_SHIP_DOCS                   ,
 LOW_QUANTITY                           ,
 HIGH_QUANTITY                          ,
 ACD_TYPE                               ,
 OLD_COMPONENT_SEQUENCE_ID              ,
 COMPONENT_SEQUENCE_ID                  ,
 BILL_SEQUENCE_ID                       ,
 REQUEST_ID                             ,
 PROGRAM_APPLICATION_ID                 ,
 PROGRAM_ID                             ,
 PROGRAM_UPDATE_DATE                    ,
 WIP_SUPPLY_TYPE                        ,
 SUPPLY_SUBINVENTORY                    ,
 SUPPLY_LOCATOR_ID                      ,
 REVISED_ITEM_SEQUENCE_ID               ,
 MODEL_COMP_SEQ_ID                      ,
 ASSEMBLY_ITEM_ID                       ,
 ALTERNATE_BOM_DESIGNATOR               ,
 ORGANIZATION_ID                        ,
 ORGANIZATION_CODE                      ,
 COMPONENT_ITEM_NUMBER                  ,
 ASSEMBLY_ITEM_NUMBER                   ,
 REVISED_ITEM_NUMBER                    ,
 LOCATION_NAME                          ,
 REFERENCE_DESIGNATOR                   ,
 SUBSTITUTE_COMP_ID                     ,
 SUBSTITUTE_COMP_NUMBER                 ,
 TRANSACTION_ID                         ,
 PROCESS_FLAG                           ,
 BOM_ITEM_TYPE                          ,
 OPERATION_LEAD_TIME_PERCENT            ,
 COST_FACTOR                            ,
 INCLUDE_ON_BILL_DOCS                   ,
 PICK_COMPONENTS                        ,
 DDF_CONTEXT1                           ,
 DDF_CONTEXT2                           ,
 NEW_OPERATION_SEQ_NUM                  ,
 OLD_OPERATION_SEQ_NUM                  ,
 NEW_EFFECTIVITY_DATE                   ,
 OLD_EFFECTIVITY_DATE                   ,
 ASSEMBLY_TYPE                          ,
 INTERFACE_ENTITY_TYPE                  ,
 TRANSACTION_TYPE                       ,
 BOM_INVENTORY_COMPS_IFCE_KEY           ,
 ENG_REVISED_ITEMS_IFCE_KEY             ,
 ENG_CHANGES_IFCE_KEY                   )
values
       (
1,--        OPERATION_SEQ_NUM
v2.inventory_item_id,-- COMPONENT_ITEM_ID
sysdate,-- LAST_UPDATE_DATE
1231,-- LAST_UPDATED_BY
sysdate,-- CREATION_DATE
1231,-- CREATED_BY
null,-- LAST_UPDATE_LOGIN
1,-- ITEM_NUM
v2.qty,--COMPONENT_QUANTITY
1,-- COMPONENT_YIELD_FACTOR
null,-- COMPONENT_REMARKS
sysdate,-- EFFECTIVITY_DATE
null,-- CHANGE_NOTICE
null,-- IMPLEMENTATION_DATE
null,-- DISABLE_DATE
null,-- ATTRIBUTE_CATEGORY
null,-- ATTRIBUTE1
null,-- ATTRIBUTE2
null,-- ATTRIBUTE3
null,-- ATTRIBUTE4
null,-- ATTRIBUTE5
null,-- ATTRIBUTE6
null,-- ATTRIBUTE7
null,-- ATTRIBUTE8
null,-- ATTRIBUTE9
null,-- ATTRIBUTE10
null,-- ATTRIBUTE11
null,-- ATTRIBUTE12
null,-- ATTRIBUTE13
null,-- ATTRIBUTE14
'upload08',-- ATTRIBUTE15
null,--100,-- PLANNING_FACTOR
null,--2,-- QUANTITY_RELATED
null,--2,-- SO_BASIS
null,--2,-- OPTIONAL
null,--2,-- MUTUALLY_EXCLUSIVE_OPTIONS
null,--1,-- INCLUDE_IN_COST_ROLLUP
null,--2,-- CHECK_ATP
null,-- SHIPPING_ALLOWED
null,--2,-- REQUIRED_TO_SHIP
null,--2,-- REQUIRED_FOR_REVENUE
null,--2,-- INCLUDE_ON_SHIP_DOCS
null,-- LOW_QUANTITY
null,-- HIGH_QUANTITY
null,-- ACD_TYPE
null,-- OLD_COMPONENT_SEQUENCE_ID
null,--v_seq,-- COMPONENT_SEQUENCE_ID
null,--v_seq,-- BILL_SEQUENCE_ID
null,-- REQUEST_ID
null,-- PROGRAM_APPLICATION_ID
null,-- PROGRAM_ID
null,-- PROGRAM_UPDATE_DATE
null,-- WIP_SUPPLY_TYPE
null,-- SUPPLY_SUBINVENTORY
null,-- SUPPLY_LOCATOR_ID
null,-- REVISED_ITEM_SEQUENCE_ID
null,-- MODEL_COMP_SEQ_ID
v1.inventory_item_id,-- ASSEMBLY_ITEM_ID
null,-- ALTERNATE_BOM_DESIGNATOR
299,-- ORGANIZATION_ID
null,-- ORGANIZATION_CODE
null,-- COMPONENT_ITEM_NUMBER
null,-- ASSEMBLY_ITEM_NUMBER
null,-- REVISED_ITEM_NUMBER
null,-- LOCATION_NAME
null,-- REFERENCE_DESIGNATOR
null,-- SUBSTITUTE_COMP_ID
null,-- SUBSTITUTE_COMP_NUMBER
null,-- TRANSACTION_ID
1,-- PROCESS_FLAG
null,--4,-- BOM_ITEM_TYPE
null,-- OPERATION_LEAD_TIME_PERCENT
null,-- COST_FACTOR
null,-- INCLUDE_ON_BILL_DOCS
null,-- PICK_COMPONENTS
null,-- DDF_CONTEXT1
null,-- DDF_CONTEXT2
null,-- NEW_OPERATION_SEQ_NUM
null,-- OLD_OPERATION_SEQ_NUM
null,-- NEW_EFFECTIVITY_DATE
null,-- OLD_EFFECTIVITY_DATE
1,-- ASSEMBLY_TYPE
null,-- INTERFACE_ENTITY_TYPE
'CREATE',-- TRANSACTION_TYPE
null,-- BOM_INVENTORY_COMPS_IFCE_KEY
null,-- ENG_REVISED_ITEMS_IFCE_KEY
null) -- ENG_CHANGES_IFCE_KEY                   )
 ;
 commit;
 exception
 when others then
 null;
end;
end loop;
close c2;
end;
exception
when others then
null;
end;
end loop;
close c1;
end;
 -------------------------------------export bom

select top.organization_id,
      bom.ASSEMBLY_ITEM_ID           TOP_ITEM_ID,
      top.segment1                   top_item_num,
      top.description                top_desc,
      bom.ASSEMBLY_ITEM_ID           ASSEMBLY_ITEM_ID,
      bic.ITEM_num                   ITEM_NO,
      1                              item_level,
      bic.COMPONENT_ITEM_ID          COMPONENT_ITEM_ID,
      msi.segment1                   item_num,
      msi.description                item_desc,
      msi.unit_weight,
      msi.WEIGHT_UOM_CODE,
      msi.primary_uom_code,
      NVL(bic.WIP_SUPPLY_TYPE,MSI.WIP_SUPPLY_TYPE)            WIP_SUPPLY_TYPE,
      msi.PLANNING_MAKE_BUY_CODE,
      bic.COMPONENT_QUANTITY         COMPONENT_QUANTITY,
      bic.COMPONENT_QUANTITY         PER_UNIT_QTY,
      bic.COMPONENT_REMARKS          COMPONENT_REMARKS,
        substr(ltrim(bic.COMPONENT_REMARKS),1,2)     cc_code,
       bic.COMPONENT_QUANTITY            require_qty,
      bic.EFFECTIVITY_DATE,
      BIC.DISABLE_DATE,
       to_date(null)  dis_date1,
       to_date(null)  dis_date2,
       to_date(null)  dis_date3,
       to_date(null)  dis_date4,
       to_date(null)  dis_date5,
       to_date(null)  dis_date6,
       null,
       msi.FIXED_LEAD_TIME request_id
--       ,nvl(CST.item_cost,0) item_cost--v1.wip_entity_name
from
      mtl_system_items                top,
      bom.BOM_BILL_OF_MATERIALS       bom,
      bom.BOM_INVENTORY_COMPONENTS    bic,
      mtl_system_items                msi,
      cst_item_costs cst
where
        top.inventory_item_id=bom.ASSEMBLY_ITEM_ID
   and  top.organization_id=bom.organization_id
   AND  bic.BILL_SEQUENCE_ID=bom.common_BILL_SEQUENCE_ID
   AND  bom.ALTERNATE_BOM_DESIGNATOR  is null
   AND  bic.COMPONENT_ITEM_ID=MSI.INVENTORY_ITEM_ID
   AND  MSI.ORGANIZATION_ID=bom.organization_id
   and  msi.inventory_item_id=cst.inventory_item_id
   and  msi.organization_id=cst.organization_id
   and  cst.cost_type_id=2
   AND  NVL(bic.WIP_SUPPLY_TYPE,MSI.WIP_SUPPLY_TYPE)!=6
--   AND ( BIC.DISABLE_DATE IS NULL OR BIC.DISABLE_DATE>=v1.BOM_REVISION_DATE)
   and top.organization_id=299
--      and   top.segment1=v1.item_num
--select * from mtl_parameters
--   and top.segment1='5102-130100Z'
 and bom.ASSEMBLY_ITEM_ID='297907'

   --SELECT * FROM mtl_system_items where organization_id=299 and segment1='5102-130100Z'
 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12122734/viewspace-503810/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 药物
下一篇: pl/sql
请登录后发表评论 登录
全部评论

注册时间:2008-06-02

  • 博文量
    519
  • 访问量
    490335