oracle bom递归查询,求多阶BOM查询代码

select

LPad('.', level*2-2, ' ') || level          层次,

msib1.segment1                              父项,

msib1.description                           父项说明,

bcb.item_num                                BOM序号,

msib2.segment1                              子项,

msib2.description                           子项说明,

(select long_description

from inv.mtl_system_items_tl t

where t.inventory_item_id = msib2.inventory_item_id

and t.organization_id = msib2.organization_id

and t.language= Userenv('LANG'))        图号,

msib2.item_type                             物料类型,

msib2.primary_unit_of_measure               单位,

bcb.component_quantity                      定额,

bcb.component_yield_factor                  产出率,

decode(prior (bcb.component_quantity/

bcb.component_yield_factor),

null,1,

prior (bcb.component_quantity/

bcb.component_yield_factor)

) *

(bcb.component_quantity/

bcb.component_yield_factor)              扩展数,

decode(bcb.wip_supply_type,

1,'推式',

2,'装配拉式',

3,'工序拉式',

6,'虚拟件',

null,null,

'其它')                   供应方式,

bcb.supply_subinventory                     供应子库

from bom.bom_structures_b   bsb,

bom.bom_components_b   bcb,

inv.mtl_system_items_b msib1,

inv.mtl_system_items_b msib2

where bsb.bill_sequence_id    = bcb.bill_sequence_id

and nvl(bcb.disable_date,sysdate+1) >sysdate

and bsb.alternate_bom_designator is null

and msib1.organization_id   = bsb.organization_id

and msib1.inventory_item_id = bsb.assembly_item_id

and msib2.organization_id   = bsb.organization_id

and msib2.inventory_item_id = bcb.component_item_id

start with bsb.organization_id   = 10     --在此输入ORG ID

and bsb.alternate_bom_designator is null

and msib1.organization_id = 10      --在此输入ORG ID

and msib1.segment1 = '1111'         --在此输入父项编码

connect by prior bcb.component_item_id =bsb.assembly_item_id         and

prior nvl(bcb.disable_date,sysdate+1) >= sysdate+1/86400  and

--           prior bcb.effectivity_date            <= sysdate          and

bcb.bill_sequence_id  =bsb.bill_sequence_id         and

bsb.organization_id   =10        --在此输入父项编码

and  bsb.alternate_bom_designator is null                and

not (msib1.build_in_wip_flag = 'N'  and

msib2.build_in_wip_flag = 'N'     )

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值