工單用料和實際用料差別主要體現在bom不發料有點多,而bom表裡沒有做成直接材料,另外就是工單變更,那就什麼可能也會發生,協助分析工單用料分析和工單用料分析表差不多吧,但應該簡潔快
alter proc [dbo].[mocyl] (@starttime varchar(8),@endtime varchar(8))
as begin
declare @ta001 varchar(8)
declare @ta002 varchar(20)
declare @tmpph varchar(60)
declare @tmpdw varchar(8)
declare @yl numeric(18,8)
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..##tempfy'))
drop table ##tempyl
create table ##tempyl
(tta001 varchar(8),
tta002 varchar(20),
ph varchar(20),
--pm varchar(60),
--gg varchar(100),
dw varchar(8),
sjyl varchar(200),
bzyl varchar(200)
)declare gddhlb cursor for
select ta001,ta002 from mocta
where ta003>=@starttime and ta003<=@endtime and ta001 like '51%' and ta011='y' and ta013='y' and ta030='1'
open gddhlb
fetch next from gddhlb into @ta001,@ta002
while @@fetch_status=0
begin
insert into ##tempyl
select tb001,tb002,tb003,tb007,tb005,0 from moctb
where tb001=@ta001 and tb002=@ta002 and tb003 not in (select md003 from bommd where md001 in(select ta006 from mocta where ta001=@ta001 and ta002=@ta002))
declare tmpyll cursor for select md003,mb004,convert (numeric(18,8),ceiling(md006/md007*(1+md008)*ta015)) as yl from bommd
left join invmb on md003=mb001
left join mocta on ta006=md001
where ta001=@ta001 and ta002=@ta002 and md017='1'
--where ta001=@ta001 and ta002=@ta002
open tmpyll
fetch next from tmpyll into @tmpph,@tmpdw,@yl
while @@fetch_status=0
begin
fetch next from tmpyll into @tmpph,@tmpdw,@yl
insert into ##tempyl
select tb001,tb002,tb003,tb007,tb005,@yl
--select tb001,tb002,tb003,tb005,tb007
from moctb where tb001=@ta001 and tb002=@ta002 and tb003=@tmpph and tb007=@tmpdw
and tb005<>@yl
endclose tmpyll
deallocate tmpyll
fetch next from gddhlb into @ta001,@ta002
endclose gddhlb
deallocate gddhlb
select * from ##tempyl
end
易飛 四 郵件預警 生產中工單
sql select mocta.ta001 mocta.ta002 工單,ze.dbo.date10 mocta.ta040 單據日期,mocta.ta006 品號,mocta.ta034 品名,mocta.ta035 規格,ze.dbo.date10 mocta.ta009 預計開工日,ze.d...
易飛 開立工單自動帶出BOM中的外掛程式位置
用途 開立工單時候自動帶出外掛程式位置 create trigger h tr moctb on dbo moctb for insert asdeclare itemno varchar 20 begin transaction set nocount on select itemno ta006...
易飛工單產品返工成本相關影響之考慮
工單在途返工 還未入庫和進入品檢狀態時 工時增加,物料損壞則要生產超領 成本已經歸集 工單入庫時檢驗返工 入庫時品管發現 工單引數報廢和破壞數量記入完工數量,審核生產入庫單時修改其破壞與完工數量 品質不可能幫其全部返工 手工開具生產返工單 記錄工時,並且超領其料,記錄工時,成本做其產品歸集 報廢的產...