• 采购入库


    --exec cgrk_all 6
    --采购入库全功能
    alter proc cgrk_all(@hid int)
    as
    set nocount on
    begin
    --入库量
    declare @rksl table(ph varchar(100),pm varchar(100),cgdh varchar(100),rksl float,itemid int,hid int,ck varchar(100),location varchar(100),fid int)
    --未存在库存的物料
    declare @ph table(ph varchar(100))

    insert into @rksl(ph,pm,cgdh,rksl,itemid,hid,ck,location,fid)
    select ph,pm,cgdddh,rksl,itemid,hid,ck,location,fid from dwc_279 where hid=@hid
    --采购入库回填
    update dwc_232 set ckdigit=isnull(ckdigit,0)+isnull(rksl,0)
    from dwd_232 a inner join dwc_232 b on a.hid=b.hid inner join @rksl c on a.dh=c.cgdh and b.hpbm=c.ph

    --更新到库存
    update ditw set onHand=isnull(onHand,0)+isnull(rksl,0)
    from @rksl a inner join ditw b on a.ph=b.fathercode

    --库存未存在,插入
    insert into @ph(ph)
    select ph from @rksl where ph not in (select fathercode from ditw)
    insert into ditw(whscode,fathercode,onhand)
    select ck,a.ph,rksl from @rksl a inner join @ph b on a.ph=b.ph
    --插入明细
    insert into dwsd(insertTime,whouseID,location,doccode,doctype,docdate,itemcode,periodid,innum,fid,hid)
    select getdate(),ck,location,cgdh,'采购入库',getdate(),ph,convert(varchar(7),getdate(),120),rksl,fid,hid from @rksl
    end

    每天一进步、一积累,创造自我价值,体现人生逼格,你是自己的赢家!
  • 相关阅读:
    hdu 1392 凸包周长
    hdu 1847
    时间管理101招
    祝大家端午节快乐
    激励员工的二十种非经济手段
    Web2.0个人桌面
    回顾Windows系列的OEM版本历史
    什么是电子商务
    解析3G软件人才成功之道
    成功者应具备的八个心态
  • 原文地址:https://www.cnblogs.com/chlf/p/4152056.html
Copyright © 2020-2023  润新知