多级BOM

--多级BOM
SELECT chlid_items.level_num,
fmsib.segment1 parent_item,
msib.segment1 component_item,
chlid_items.bill_sequence_id
FROM mtl_system_items_b msib,
(SELECT LEVEL level_num,
bic.component_item_id,
bic.bill_sequence_id
FROM bom_inventory_components bic
WHERE bic.bill_sequence_id IS NOT NULL
AND nvl(bic.disable_date, SYSDATE + 1) > SYSDATE
START WITH bic.bill_sequence_id = (SELECT bsb.bill_sequence_id
FROM mtl_system_items_b msib,
bom_structures_b bsb
WHERE bsb.assembly_item_id = msib.inventory_item_id
AND bsb.organization_id = msib.organization_id
AND bsb.organization_id = 108
AND bsb.assembly_item_id = 310)
CONNECT BY bic.bill_sequence_id = PRIOR
(SELECT bsb.bill_sequence_id
FROM bom_structures_b bsb
WHERE bic.component_item_id = bsb.assembly_item_id)) chlid_items,
bom_structures_b bsb,
mtl_system_items_b fmsib
WHERE msib.inventory_item_id = chlid_items.component_item_id
AND bsb.bill_sequence_id = chlid_items.bill_sequence_id
AND bsb.assembly_item_id = fmsib.inventory_item_id
AND fmsib.organization_id = bsb.organization_id
AND msib.organization_id = bsb.organization_id;

你可能感兴趣的:(bom)