# 前段时间写的一个关于成本计算的存储过程!

--                             ///|///
--                            // -- //
--                            ( @@ )
--┏━━━━━━━━━oOOo-(_)-oOOo━┓
--┃  定义于2004-07-16                                ┃
--┃ 成本试算存储过程定义，计算成本 ┃
--┃                                                 Oooo  ┃
--┗━━━━━━━━━oooO━-(  )━┛
--                                          (  )  )/
--                                           /(  (_/
--                                            /_)
CREATEPROCEDUREsp_costing_compute
(@out_matnrvarchar(18),
@out_werksvarchar(4),
@out_datetimedatetime)
AS
--插入赠品
declare@matnrvarchar(18),@werksvarchar(4),@kriqidatetime,@meinsvarchar(10)
declare@bomatnrvarchar(18),@bomsehlvarchar(10),@mengefloat
declare@pricefloat,@danwvarchar(20)
declare@umrezfloat,@aapricefloat,@jjpricefloat,@aratefloat,@jratefloat,@asyfloat,@jsyfloat
declare@cpjgfloat,@umrenfloat
set@cpjg=0
--计算产成品成本价格
Declaremycursorcursorforselectmeins,aprice,jpricefromtb_matnrwhereconvert(varchar(10),kriqi,120)=convert(varchar(10),@out_datetime,120) andmatnr=@out_matnrandplant=@out_werks
openmycursor
fetchmycursorinto@meins,@aaprice,@jjprice
closemycursor
deallocatemycursor
declare bccursorcursorforselectbomatnr,bomsehl,mengefromtb_bomwherecpmatnr=@out_matnrandwerks=@out_werksandconvert(varchar(10),kriqi,120)=convert(varchar(10),@out_datetime,120)共3页  1