123
返回列表 发新帖
楼主: tommy_gu

求BOM清單SQL語句

[复制链接]
论坛徽章:
32
夏利
日期:2013-10-15 08:34:12
21#
发表于 2007-8-20 19:44 | 只看该作者
最初由 hotwish 发布
[B]我的意思是以上的SQL SCRIPT有问题,可否修正一下,谢谢 [/B]

error.jpg (53.87 KB, 下载次数: 5)

error.jpg

使用道具 举报

回复
论坛徽章:
18
授权会员
日期:2005-10-30 17:05:33ITPUB十周年纪念徽章
日期:2011-11-01 16:20:282010新春纪念徽章
日期:2010-03-01 11:08:332009新春纪念徽章
日期:2009-01-04 14:52:28生肖徽章2007版:虎
日期:2008-10-28 09:16:49生肖徽章2007版:虎
日期:2008-10-26 17:52:47奥运会纪念徽章:曲棍球
日期:2008-08-04 08:04:06奥运会纪念徽章:排球
日期:2008-04-24 11:05:31NBA常规赛纪念章
日期:2008-04-18 19:48:16生肖徽章2007版:牛
日期:2008-01-02 17:35:53
22#
发表于 2007-8-21 08:18 | 只看该作者
好資料先收藏再研究

使用道具 举报

回复
求职 : 技术/实施/服务顾问
论坛徽章:
43
会员2007贡献徽章
日期:2007-09-26 18:42:10参与WIN7挑战赛纪念
日期:2009-11-06 16:05:25IT宝贝
日期:2009-11-17 09:33:292010新春纪念徽章
日期:2010-03-01 11:04:582010年世界杯参赛球队:韩国
日期:2010-03-30 15:01:292010年世界杯参赛球队:葡萄牙
日期:2010-04-06 08:33:102010年世界杯参赛球队:日本
日期:2010-08-06 12:52:402010年世界杯参赛球队:巴西
日期:2010-08-10 11:56:16ITPUB9周年纪念徽章
日期:2010-10-08 09:28:522011新春纪念徽章
日期:2011-02-18 11:43:33
23#
发表于 2007-8-21 08:52 | 只看该作者
單純的sql只能一個一個執行.必須寫成procedure.利用指針取得成品料號.當作參數傳給它.就可以執行.
以下程式供你參考.
--建立PROCEDURE
CREATE OR REPLACE PROCEDURE BLIST IS
P_item_id number(10);
LV  number(2);
m_iid number(10);
Component_Qty number(9,5);
edate date;
ddate date;
cursor c_mmt is
select msi.inventory_item_id
from inv.mtl_system_items_b msi,
bom.bom_bill_of_materials bom
where msi.inventory_item_id=bom.assembly_item_id
and bom.ORGANIZATION_ID IN('89','147')
and bom.ORGANIZATION_ID = MSI.ORGANIZATION_ID
and bom.ALTERNATE_BOM_DESIGNATOR is null
and msi.inventory_item_id in(select DISTINCT mmt.inventory_item_id from mtl_material_transactions mmt
where mmt.transaction_type_id=33);
begin
for h_iid in c_mmt loop
for c_rev in (select revision
from aw_bom_rev_v
where inventory_item_id=h_iid.inventory_item_id) loop
for c_bom in (
select  
msi1.inventory_item_id P_item_id,
to_char(b.lvl) LV,
msi2.inventory_item_id m_iid,
b.component_quantity Component_Qty,
b.effectivity_date edate,
b.disable_date ddate
from inv.mtl_system_items_b msi1,
inv.mtl_system_items_b msi2,
bom.bom_bill_of_materials bom,
(select level lvl,
bic.bill_sequence_id,
bic.component_item_id,
bic.component_quantity,
bic.COMPONENT_YIELD_FACTOR,
bic.item_num,
bic.wip_supply_type,
bic.supply_subinventory,
bic.effectivity_date,
bic.disable_date
FROM bom.bom_inventory_components bic
start with bic.bill_sequence_id in
( select bill_sequence_id
from bom.bom_bill_of_materials bom2,
inv.mtl_system_items_b msi
where bom2.assembly_item_id = msi.inventory_item_id
and bom2.organization_id = msi.organization_id
and  msi.inventory_item_id=h_iid.inventory_item_id
and msi.organization_id IN('89','147')
and bom2.alternate_bom_designator is null
)
CONNECT BY bic.bill_sequence_id =
prior (SELECT distinct bill_sequence_id
FROM bom.bom_bill_of_materials BO,
inv.mtl_system_items_b msi,
apps.aw_bom_rev_v rev
WHERE BO.assembly_item_id = bic.component_item_id
And msi. PLANNING_MAKE_BUY_CODE=1
and rev.inventory_item_id=h_iid.inventory_item_id
and rev.revision=c_rev.revision
AND BO.organization_id in('89','147')
and ((to_char(bic.effectivity_date,'yyyy/mm/dd')<=rev.disable_date and bic.disable_date is null)
or (to_char(bic.disable_date,'yyyy/mm/dd')>rev.disable_date
and to_char(bic.effectivity_date,'yyyy/mm/dd')<=rev.disable_date
and  bic.disable_date is not null))
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,
apps.aw_bom_rev_v rev1
where b.bill_sequence_id = bom.bill_sequence_id
and rev1.inventory_item_id=h_iid.inventory_item_id
and rev1.revision=c_rev.revision
and bom.ORGANIZATION_ID IN('89','147')
and ((to_char(b.effectivity_date,'yyyy/mm/dd')<=rev1.disable_date and b.disable_date is null)
or (to_char(b.disable_date,'yyyy/mm/dd')>rev1.disable_date
and to_char(b.effectivity_date,'yyyy/mm/dd')<=rev1.disable_date
and  b.disable_date is not null))
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
AND bom.alternate_bom_designator is null
and (MSI2.INVENTORY_ITEM_ID NOT IN (SELECT ASSEMBLY_ITEM_ID FROM  bom_bill_of_materials) or
msi2. PLANNING_MAKE_BUY_CODE=2)
) loop
INSERT INTO AW_BOM_BLIST VALUES(h_iid.inventory_item_id,c_bom.p_item_id, C_bom.LV,
c_bom.m_iid,c_bom.Component_Qty,c_bom.edate,c_bom.ddate,c_rev.revision);
commit;
END LOOP;
END LOOP;
END LOOP;
END BLIST;
/

使用道具 举报

回复
论坛徽章:
12
24#
发表于 2010-10-1 23:31 | 只看该作者
很久没做ODM,先收藏,认真研究!

使用道具 举报

回复
论坛徽章:
0
25#
发表于 2012-11-7 16:16 | 只看该作者
lveamy 发表于 2007-8-8 11:01
肯定有的
select DISTINCT
msi1.segment1 P_item,

不错 我这边用上了 谢谢lveamy

使用道具 举报

回复
论坛徽章:
52
巨蟹座
日期:2015-10-21 09:52:07红宝石
日期:2012-10-16 13:52:13ITPUB 11周年纪念徽章
日期:2012-10-09 18:05:372012新春纪念徽章
日期:2012-01-04 11:50:44ITPUB十周年纪念徽章
日期:2011-11-03 08:04:362011新春纪念徽章
日期:2011-02-18 11:43:332010广州亚运会纪念徽章:棋类
日期:2010-11-22 15:28:08ITPUB9周年纪念徽章
日期:2010-10-08 09:28:522010新春纪念徽章
日期:2010-03-01 11:06:222010新春纪念徽章
日期:2010-03-01 11:06:21
26#
发表于 2012-11-8 11:50 | 只看该作者
恭喜!您刚拣到ITPUB送出的 复活蛋 。

使用道具 举报

回复

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

本版积分规则 发表回复

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