SQL Scripts to print BOM Hierarchy

本文详细介绍了如何使用VisionDemo库中的AssemblyItem:75100021作为实例,进行BOM层级打印及组件情况查询,包括BOM层级结构与组件数量信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

以Vision Demo库的Assembly Item:75100021为例(这个Item为摩托车组装成品物料)


Query1:Sql query to print BOM hierarchy for a given assembly item

select level,bill_item_name,assembly_item_id,component_item_name, component_item_id
from apps.bomfg_bom_components
start with bill_item_name = '75100021'   --Replace your assembly_item_id to here
connect by prior component_item_name = bill_item_name;

Output:

LEVELBILL_ITEM_NAMEASSEMBLY_ITEM_IDCOMPONENT_ITEM_NAME COMPONENT_ITEM_ID
1751000216088751000226090
2751000226090751000236092
3751000236092751000346126
1751000216088751000256094
2751000256094751000266128
1751000216088751000276130

Query2:另外一个类似的脚本,通过Assembly查询BOM的组件情况(包含组件数量)

SELECT 'Material' Material ,
       (SELECT msi.segment1
       FROM    mtl_system_items msi
       WHERE   msi.inventory_item_id=bom.assembly_item_id
       AND     msi.organization_id  =207  --Replace your organization_id to here
       )
       parent_item         ,
       bom.assembly_item_id,
       lpad('',2*(level-1))
              ||
       (SELECT msi.segment1
       FROM    mtl_system_items msi
       WHERE   msi.inventory_item_id=bic.component_item_id
       AND     msi.organization_id  =207  --Replace your organization_id to here
       )
                             child_item   ,
       bic.component_item_id child_item_id,
       bic.bill_sequence_id               ,
       bic.operation_seq_num              ,
       level                              ,
       bic.component_quantity
FROM   bom_inventory_components bic,
       (SELECT *
       FROM    bom_bill_of_materials
       WHERE   organization_id=207 --Replace your organization_id to here
       )
       bom
WHERE  bom.bill_sequence_id=bic.bill_sequence_id 
START WITH bom.assembly_item_id= 6088 ----Replace your assembly_item_id to here 
CONNECT BY prior bic.component_item_id=bom.assembly_item_id;

Sample Output:

MATERIALPARENT_ITEMASSEMBLY_ITEM_IDCHILD_ITEMCHILD_ITEM_IDBILL_SEQUENCE_IDOPERATION_SEQ_NUMLEVELCOMPONENT_QUANTITY
Material751000216088751000226090236321011
Material751000226090751000236092236601021
Material751000236092751000346126236631030.3
Material751000216088751000256094236321011
Material751000256094751000266128236661021
Material751000216088751000276130236321011





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值