zoukankan      html  css  js  c++  java
  • 按BOM清单展开物料及需求(SQL) 沧海

    适用环境:
    人工的去展开BOM
    CREATE function f_pcode1(@code varchar(20))
    returns @re1 table(code varchar(20),father varchar(20),uom varchar(5),quantity float,level1 int)
    as
    begin
    declare @l int
    declare @father varchar(20)
    declare @uom varchar(5)
    declare @quantity float
    set @l=0
    insert @re1 select @code,@father,@uom,@quantity,@l
    while @@rowcount>0
    begin
      set @l=@l+1
      insert @re1(code,father,uom,quantity,level1) select a.code,a.father,a.uom,a.quantity,@l
      from itt1 a,@re1 b
      where a.father=b.code collate database_default
       and b.level1=@l-1
    end
    return
    end


    用这个SQL我实现了这样一种功能:按销售订单查询成品的标准BOM清单,并计算需求。
    输入成品的料号
    输出父料号、子料号、单位、用量、BOM级别


    关于B1的两个功能(二)按销售订单展开生产订单的用料清单

    简单的说:就是输出一个销售订单销售物料的生产订单用料清单
    CREATE function f_wo(@code_a varchar(20),@code_b varchar(20))
    returns @re1 table(DocEntry int,code varchar(20),father varchar(20),uom varchar(5), PlannedQty float,IssuedQty float,level1 int)
    as
    begin
    declare @l int
    DECLARE @DocEntry INT
    declare @father varchar(20)
    declare @code varchar(20)
    declare @IssuedQty float
    declare @PlannedQty float
    declare @re2 TABLE (DocEntry int,code varchar(20),father varchar(20), PlannedQty float,IssuedQty float,OriginNum int)

    insert @re2(DocEntry,code,father,PlannedQty,IssuedQty,OriginNum) SELECT DiSTinct T1.DocEntry,T1.ItemCode, T0.ItemCode,T1.PlannedQty, T1.IssuedQty ,T0.OriginNum from OWOR T0 INNER JOIN WOR1 T1 ON T0.DocEntry = T1.DocEntry where   t0.OriginNum = @code_a

    set @l=0
    insert @re1(code,father,PlannedQty,IssuedQty,level1) select @code_b,@father,@PlannedQty,@IssuedQty,@l
    while @@rowcount>0
    begin
    set @l=@l+1
    insert @re1(DocEntry,code,father,IssuedQty,PlannedQty,level1) select DiSTinct a.DocEntry,a.code,a.father,a.IssuedQty,a.PlannedQty,@l
    from @re2 a,@re1 b
    where a.father=b.code collate database_default
    and b.level1=@l-1
    end
    return
    end
    --------------
    这个就是按单生产的SQL。
    输入项目:销售订单号、销售订单销售的成品料号。
    输出:
    生产订单号
    料号
    父料号
    发出数量
    计划数量
    BOM级别


    由以上的两个功能可以开发出:按销售订单生产、计划的功能。
    专注于企业信息化,最近对股票数据分析较为感兴趣,可免费分享股票个股主力资金实时变化趋势分析工具,股票交流QQ群:457394862
  • 相关阅读:
    Proof of Stake-股权证明 系列3
    共识算法的比较:Casper vs Tendermint
    我的友情链接
    我的友情链接
    我的友情链接
    我的友情链接
    我的友情链接
    我的友情链接
    我的友情链接
    我的友情链接
  • 原文地址:https://www.cnblogs.com/omygod/p/995611.html
Copyright © 2011-2022 走看看