楼主: tommy_gu

求BOM清單SQL語句

[复制链接]
论坛徽章:
10
授权会员
日期:2006-12-11 19:12:24会员2007贡献徽章
日期:2007-09-26 18:42:10数据库板块每日发贴之星
日期:2007-09-09 01:03:40ERP板块每日发贴之星
日期:2007-08-30 01:04:32ERP板块每日发贴之星
日期:2007-08-28 01:04:00ERP板块每日发贴之星
日期:2007-08-26 01:04:03ERP板块每日发贴之星
日期:2007-08-19 01:03:49数据库板块每日发贴之星
日期:2007-08-06 01:03:19ERP板块每日发贴之星
日期:2007-04-02 01:03:29ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44
11#
发表于 2007-8-8 11:01 | 只看该作者
肯定有的
select DISTINCT
msi1.segment1 P_item,
to_char(b.lvl) LV,
nvl(bom.alternate_bom_designator,'P') Alternate_bom_designator,
msi2.segment1 C_item,
b.component_quantity Component_Qty
from inv.mtl_system_items msi1,
inv.mtl_system_items msi2,
bom.bom_bill_of_materials bom,
bom.bom_operation_sequences bos,
(select level
lvl,
bic.bill_sequence_id,
bic.component_item_id,
bic.component_quantity,
bic.OPERATION_SEQ_NUM,
bic.COMPONENT_YIELD_FACTOR,
bic.COMPONENT_SEQUENCE_ID,
bic.item_num,
bic.wip_supply_type,
bic.supply_subinventory,
bic.effectivity_date
FROM bom.bom_inventory_components bic
where disable_date IS NULL
start with bic.bill_sequence_id in
( select bill_sequence_id
from bom.bom_bill_of_materials bom2,
inv.mtl_system_items msi
where bom2.assembly_item_id = msi.inventory_item_id
and bom2.organization_id = msi.organization_id
and msi.segment1='10022111742'
and msi.organization_id = 2
and bom2.alternate_bom_designator is null
)
CONNECT BY bic.bill_sequence_id in
prior (SELECT distinct bill_sequence_id
FROM bom.bom_bill_of_materials BO,
inv.mtl_system_items msi
WHERE BO.assembly_item_id = bic.component_item_id
AND BO.organization_id = 2
and bo.ORGANIZATION_ID = msi.ORGANIZATION_ID
and bo.ASSEMBLY_ITEM_ID = msi.INVENTORY_ITEM_ID
and bo.alternate_bom_designator is null
and disable_date IS NULL
)
) b
where b.bill_sequence_id = bom.bill_sequence_id
and bom.ORGANIZATION_ID =2
and bom.ORGANIZATION_ID = msi1.ORGANIZATION_ID
and bom.ASSEMBLY_ITEM_ID = msi1.INVENTORY_ITEM_ID
and bom.ORGANIZATION_ID = MSI2.ORGANIZATION_ID
AND b.component_item_id = MSI2.INVENTORY_ITEM_ID
order by 2
试试这个怎么样的...呵呵...

使用道具 举报

回复
论坛徽章:
10
授权会员
日期:2006-12-11 19:12:24会员2007贡献徽章
日期:2007-09-26 18:42:10数据库板块每日发贴之星
日期:2007-09-09 01:03:40ERP板块每日发贴之星
日期:2007-08-30 01:04:32ERP板块每日发贴之星
日期:2007-08-28 01:04:00ERP板块每日发贴之星
日期:2007-08-26 01:04:03ERP板块每日发贴之星
日期:2007-08-19 01:03:49数据库板块每日发贴之星
日期:2007-08-06 01:03:19ERP板块每日发贴之星
日期:2007-04-02 01:03:29ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44
12#
发表于 2007-8-8 11:04 | 只看该作者
个人感觉还是不错的....
其实这个你都可以做个report出来的了
那样看的话比较直观点

使用道具 举报

回复
论坛徽章:
3
生肖徽章2007版:羊
日期:2008-11-27 12:28:33授权会员
日期:2011-02-16 22:18:57优秀写手
日期:2013-12-18 09:29:16
13#
发表于 2007-8-8 16:56 | 只看该作者
那个SQL只取单层BOM,其实你的半成品还有自己的清单,在下面了,那段很简单,不是多级展开的,那样的话麻烦死了,偶也不会。

使用道具 举报

回复
论坛徽章:
2
2010新春纪念徽章
日期:2010-03-01 11:20:052011新春纪念徽章
日期:2011-02-18 11:43:34
14#
发表于 2007-8-8 19:55 | 只看该作者

哈哈,多级展开。。。。

系統里有個功能可以PROCEDURE:bompexpl.explosion_report   可以研究哦!!

使用道具 举报

回复
论坛徽章:
0
15#
 楼主| 发表于 2007-8-9 09:58 | 只看该作者

Re: 哈哈,多级展开。。。。

最初由 xing_lang 发布
[B]系統里有個功能可以PROCEDURE:bompexpl.explosion_report   可以研究哦!! [/B]

14樓說說看呢,具體是怎麼處理的呢?寫的太簡單.

使用道具 举报

回复
论坛徽章:
0
16#
发表于 2007-8-16 18:05 | 只看该作者
PROCEDURE bom_exp1(
                  ,p_item_id   NUMBER
                 ) IS

CURSOR CU_2(p_item_id NUMBER) IS

SELECT
       msi.segment1                SEG2   , --
       bic.component_sequence_id          ,
       bic.component_item_id              ,
       msi.INVENTORY_ITEM_ID
       ,bic.disable_date
FROM   bom_inventory_components bic,
       mtl_system_items_b        msi,
       bom_bill_of_materials    bbom,
WHERE      bbom.assembly_item_id   = p_item_id    --
       and bbom.organization_id    = &&1
       and bbom.alternate_bom_designator is null
       and (bbom.common_bill_sequence_id= bic.bill_sequence_id
       OR  bbom.bill_sequence_id= bic.bill_sequence_id)
       and bic.component_item_id = msi.inventory_item_id
       and nvl(bic.acd_type,'1')<>'3'
       and bic.implementation_date is not null
       and msi.organization_id  = &&1            
ORDER  BY msi.segment1;

LR_2   CU_2%ROWTYPE;

BEGIN

   FOR lr_2 IN cu_2(p_item_id) LOOP
        
            insert into temp_table(......);
           
           bom_exp1(lr_2.component_item_id);

   END LOOP;
END;

使用道具 举报

回复
论坛徽章:
32
夏利
日期:2013-10-15 08:34:12
17#
发表于 2007-8-20 14:30 | 只看该作者
最初由 lveamy 发布
[B]肯定有的
select DISTINCT
msi1.segment1 P_item,
to_char(b.lvl) LV,
nvl(bom.alternate_bom_designator,'P') Alternate_bom_designator,
msi2.segment1 C_item,
b.component_quantity Component_Qty
from inv.mtl_system_items msi1,
inv.mtl_system_items msi2,
bom.bom_bill_of_materials bom,
bom.bom_operation_sequences bos,
(select level
lvl,
bic.bill_sequence_id,
bic.component_item_id,
bic.component_quantity,
bic.OPERATION_SEQ_NUM,
bic.COMPONENT_YIELD_FACTOR,
bic.COMPONENT_SEQUENCE_ID,
bic.item_num,
bic.wip_supply_type,
bic.supply_subinventory,
bic.effectivity_date
FROM bom.bom_inventory_components bic
where disable_date IS NULL
start with bic.bill_sequence_id in
( select bill_sequence_id
from bom.bom_bill_of_materials bom2,
inv.mtl_system_items msi
where bom2.assembly_item_id = msi.inventory_item_id
and bom2.organization_id = msi.organization_id
and msi.segment1='10022111742'
and msi.organization_id = 2
and bom2.alternate_bom_designator is null
)
CONNECT BY bic.bill_sequence_id in
prior (SELECT distinct bill_sequence_id
FROM bom.bom_bill_of_materials BO,
inv.mtl_system_items msi
WHERE BO.assembly_item_id = bic.component_item_id
AND BO.organization_id = 2
and bo.ORGANIZATION_ID = msi.ORGANIZATION_ID
and bo.ASSEMBLY_ITEM_ID = msi.INVENTORY_ITEM_ID
and bo.alternate_bom_designator is null
and disable_date IS NULL
)
) b
where b.bill_sequence_id = bom.bill_sequence_id
and bom.ORGANIZATION_ID =2
and bom.ORGANIZATION_ID = msi1.ORGANIZATION_ID
and bom.ASSEMBLY_ITEM_ID = msi1.INVENTORY_ITEM_ID
and bom.ORGANIZATION_ID = MSI2.ORGANIZATION_ID
AND b.component_item_id = MSI2.INVENTORY_ITEM_ID
order by 2
试试这个怎么样的...呵呵... [/B]

感觉很好,可惜不能执行成功?

使用道具 举报

回复
论坛徽章:
32
夏利
日期:2013-10-15 08:34:12
18#
发表于 2007-8-20 14:33 | 只看该作者
楼主发了问题就不见拉,问题解决了吗?

使用道具 举报

回复
论坛徽章:
20
授权会员
日期:2007-04-27 15:28:202011新春纪念徽章
日期:2011-02-18 11:42:472010广州亚运会纪念徽章:垒球
日期:2011-05-09 10:43:16ITPUB十周年纪念徽章
日期:2011-11-01 16:20:282012新春纪念徽章
日期:2012-01-04 11:50:44双黄蛋
日期:2012-04-20 23:06:40ITPUB 11周年纪念徽章
日期:2012-10-09 18:06:20蜘蛛蛋
日期:2012-11-21 09:24:372013年新春福章
日期:2013-02-25 14:51:242010广州亚运会纪念徽章:田径
日期:2011-02-17 12:45:54
19#
发表于 2007-8-20 15:39 | 只看该作者
最初由 lveamy 发布
[B]肯定有的
select DISTINCT
msi1.segment1 P_item,
to_char(b.lvl) LV,
nvl(bom.alternate_bom_designator,'P') Alternate_bom_designator,
msi2.segment1 C_item,
b.component_quantity Component_Qty
from inv.mtl_system_items msi1,
inv.mtl_system_items msi2,
bom.bom_bill_of_materials bom,
bom.bom_operation_sequences bos,
(select level
lvl,
bic.bill_sequence_id,
bic.component_item_id,
bic.component_quantity,
bic.OPERATION_SEQ_NUM,
bic.COMPONENT_YIELD_FACTOR,
bic.COMPONENT_SEQUENCE_ID,
bic.item_num,
bic.wip_supply_type,
bic.supply_subinventory,
bic.effectivity_date
FROM bom.bom_inventory_components bic
where disable_date IS NULL
start with bic.bill_sequence_id in
( select bill_sequence_id
from bom.bom_bill_of_materials bom2,
inv.mtl_system_items msi
where bom2.assembly_item_id = msi.inventory_item_id
and bom2.organization_id = msi.organization_id
and msi.segment1='10022111742'
and msi.organization_id = 2
and bom2.alternate_bom_designator is null
)
CONNECT BY bic.bill_sequence_id in
prior (SELECT distinct bill_sequence_id
FROM bom.bom_bill_of_materials BO,
inv.mtl_system_items msi
WHERE BO.assembly_item_id = bic.component_item_id
AND BO.organization_id = 2
and bo.ORGANIZATION_ID = msi.ORGANIZATION_ID
and bo.ASSEMBLY_ITEM_ID = msi.INVENTORY_ITEM_ID
and bo.alternate_bom_designator is null
and disable_date IS NULL
)
) b
where b.bill_sequence_id = bom.bill_sequence_id
and bom.ORGANIZATION_ID =2
and bom.ORGANIZATION_ID = msi1.ORGANIZATION_ID
and bom.ASSEMBLY_ITEM_ID = msi1.INVENTORY_ITEM_ID
and bom.ORGANIZATION_ID = MSI2.ORGANIZATION_ID
AND b.component_item_id = MSI2.INVENTORY_ITEM_ID
order by 2
试试这个怎么样的...呵呵... [/B]


這個以前改過,基本上是可以用的,衹是有個別BOM導出來不是很全,如果有版本的話就比較麻煩.

使用道具 举报

回复
论坛徽章:
32
夏利
日期:2013-10-15 08:34:12
20#
发表于 2007-8-20 19:44 | 只看该作者
我的意思是以上的SQL SCRIPT有问题,可否修正一下,谢谢

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表