# 全阶BOM算法

32 篇文章 2 订阅
9 篇文章 0 订阅

P：父项；C：子件；SortSeq：行号，QTY：用量

if OBJECT_ID('SBom') is not null
begin
drop table SBom
end
select 1 as L, P+'-'+RTRIM(CAST(SORTSEQ AS CHAR)) AS LEV,P,SORTSEQ,C,QTY,qty as Sqty  into SBom from bom where P='a'

DECLARE @ID AS INT
SET @ID=0
WHILE @ID<1
BEGIN
INSERT INTO SBOM(L,Lev,p,sortseq,c,qty,sqty)
select t1.L+1 as L,t1.lev+'-'+rtrim(cast(t2.sortseq as char)) as Lev,
t1.p,t2.sortseq,t2.c,t2.qty,t1.Sqty*t2.qty as Sqty from
(
select L,LEV,P,SORTSEQ,C,QTY,Sqty from SBom where L in(select MAX(l) from SBom)
)t1
INNER join bom t2 on t1.c=t2.p
SELECT @ID=CASE WHEN ISNULL(COUNT(1),0)>0 THEN 0 ELSE 1 END  FROM SBOM T1
INNER JOIN BOM T2 ON T1.C=T2.P
WHERE T1.l IN(SELECT MAX(L) FROM SBOM)
END

• 2
点赞
• 15
收藏
觉得还不错? 一键收藏
• 0
评论
11-09
12-30
04-15 1659
08-11
02-25
09-21
02-23
03-18 2272
12-22 3882
02-16 570
07-26 741
07-16 1450
07-18 816
11-21 3428
03-15 353

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

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