原来曾经写过多级BOM语句的查询,但在实际应用中我们更多的时候是使用到只查询当前物料的上一级或者下一级物料,这样我们在使用原来的多级BOM语句时效率就相当低了,根据我们平时的查询,只需简单写出一级查询即可。下面是一级BOM查询的SQL语句,平时在各种查询中非常有用。
select msi.segment1 父物料编码,
msi.description 父物料说明,
msi1.segment1 子物料编码,
msi1.description 子物料说明
from mtl_system_items_b msi,
bom_bill_of_materials bom,
bom_inventory_components bic,
mtl_system_items_b msi1
where 1 = 1
and msi.organization_id = 103
and msi.inventory_item_id = bom.assembly_item_id
and msi.organization_id = bom.organization_id
and bom.organization_id = 103
and bom.alternate_bom_designator is null
and bom.bill_sequence_id = bic.bill_sequence_id
and bic.disable_date is null
and bic.component_item_id = msi1.inventory_item_id
and msi1.organization_id = 103
--and msi.segment1 in ('W.PL.RTT.0400.014') --由父及子
and msi1.segment1 in ('YB.H0062') --由子及父