[syteLine]检查物料的问题--类似日志的问题

/*
1、物料
1.1 无为G的单位
1.2 物料几乎都为采购料;成品/半成品为制造物料;
1.3 成品/需购买的物料不可为虚拟物料;半成品HS3*S和HB*S不为虚拟物料,其它都是
1.4 不用“MPS”标志
1.5 “接收需求”和“传递需求”都必须使用
1.6 物料需有固定提前期有需求时,还为0提示
1.7 最小订货量和订购倍量有需求时,还为0提示
1.8 半成品胶水用量和为1KG(暂不考虑)


2、BOM
2.1 KG*胶水物料单位为G,不为KG
2.2 检查ECN是否全部过帐

3、作业单
3.1 KG*胶水物料单位为G,不为KG

4、销售
4.1 至少存在一行预测
4.2 预测日期是否在今天之前

*/

CREATE procedure UF_PreMrpCheck
as

/*
if not exists(select * from sysobjects WHERE (name = '@UF_tmpTable'))
   create table @UF_tmpTable(t1 varchar(300))
else
   delete from @UF_tmpTable
*/

declare @UF_tmpTable table (t1 varchar(300))

--1、物料检查
if exists(select item from item where u_m='G')
begin
   insert @UF_tmpTable values('下面物料单位为G,请检查是否正确:')
   insert @UF_tmpTable select item from item where u_m='G'
   insert @UF_tmpTable values('')
end

if exists(select item from item where p_m_t_code='P' and (left(item,1)='F' or left(item,1)='H'))
begin
   insert @UF_tmpTable values('下面物料为成品/半成品,但来源是采购的,请检查是否正确:')
   insert @UF_tmpTable select item from item where p_m_t_code='P' and (left(item,1)='F' or left(item,1)='H')
   insert @UF_tmpTable values('')
end
if exists(select item from item where p_m_t_code='M' and left(item,1)<>'F' and left(item,1)<>'H')
begin
   insert @UF_tmpTable values('下面物料不是成品/半成品,但来源是制造的,请检查是否正确:')
   insert @UF_tmpTable select item from item where p_m_t_code='M' and left(item,1)<>'F' and left(item,1)<>'H'
   insert @UF_tmpTable values('')
end

if exists(select item from item where Phantom_Flag=1 and left(item,1)='F')
begin
   insert @UF_tmpTable values('下面物料是成品,但为虚拟标志,请检查是否正确:')
   insert @UF_tmpTable select item from item  where Phantom_Flag=1 and left(item,1)='F'
   insert @UF_tmpTable values('')
end

if exists(select item from item where Phantom_Flag=1 and left(item,1)<>'F' and left(item,1)<>'H')
begin
   insert @UF_tmpTable values('下面物料是采购物料,但为虚拟标志,请检查是否正确:')
   insert @UF_tmpTable select item from item where Phantom_Flag=1 and left(item,1)<>'F' and left(item,1)<>'H'
   insert @UF_tmpTable values('')
end

if exists(select item from item where Phantom_Flag<>1 and (left(item,3)='HS3' or left(item,2)='HB') and right(item,1)='S')
begin
   insert @UF_tmpTable values('下面物料是以HS3或HB开头,以S结尾,但不为虚拟标志,请检查是否正确:')
   insert @UF_tmpTable select item from item where Phantom_Flag<>1 and (left(item,3)='HS3' or left(item,2)='HB') and right(item,1)='S'
   insert @UF_tmpTable values('')
end

if exists(select item from item where Mps_Flag=1)
begin
   insert @UF_tmpTable values('下面物料设置为MPS标志,但现在未使用MPS标志,请检查是否正确:')
   insert @UF_tmpTable select item from item where Mps_Flag=1
   insert @UF_tmpTable values('')
end

if exists(select item from item where Accept_Req<>1 or Pass_Req<>1)
begin
   insert @UF_tmpTable values('下面物料未使用接收需求或传递需求,请检查是否正确:')
   insert @UF_tmpTable select item from item where Accept_Req<>1 or Pass_Req<>1
   insert @UF_tmpTable values('')
end

if exists(select distinct(item) from planningdetailsview where lead_time=0 and qtyreq>0)
begin
   insert @UF_tmpTable values('下面物料提前期为0,但有物料需求计划,请检查是否正确:')
   insert @UF_tmpTable select distinct(item) from planningdetailsview where lead_time=0 and qtyreq>0
   insert @UF_tmpTable values('若父料有需求,则子料需求需要MRP后才能产生,请运行MRP后再次运行此工具,检查其子料提前期是否为0')
   insert @UF_tmpTable values('')
end

if exists(select distinct(item) from planningdetailsview where (order_min=0 or order_mult=0) and qtyreq>0 and left(item,1)<>'F' and left(item,1)<>'H')
begin
   insert @UF_tmpTable values('下面物料最小订货量或订货倍量为0,但有物料需求计划,请检查是否正确:')
   insert @UF_tmpTable select distinct(item) from planningdetailsview where (order_min=0 or order_mult=0) and qtyreq>0 and left(item,1)<>'F' and left(item,1)<>'H'
   insert @UF_tmpTable values('若父料有需求,则子料需求需要MRP后才能产生,请运行MRP后再次运行此工具,检查其子料最小订货量或订货倍量是否为0')
   insert @UF_tmpTable values('')
end

--2、BOM检查
if exists(select distinct(jm.item) from jobmatl jm left join job j on jm.job=j.job and jm.suffix=j.suffix where left(jm.item,2)='KG' and jm.u_m='KG' AND j.type = 'S')
begin
   insert @UF_tmpTable values('BOM中胶水为应设置为G,但下面物料为KG,请检查是否正确:')
   insert @UF_tmpTable select distinct(jm.item) from jobmatl jm left join job j on jm.job=j.job and jm.suffix=j.suffix where left(jm.item,2)='KG' and jm.u_m='KG' AND j.type = 'S'
   insert @UF_tmpTable values('')
end

if exists(select ecn_num from ecn where stat<>'C')
begin
   insert @UF_tmpTable values('下面ECN未过帐,请检查是否正确:')
   insert @UF_tmpTable select ecn_num from ecn where stat<>'C'
   insert @UF_tmpTable values('')
end

--3、作业检查
if exists(select distinct(jm.item) from jobmatl jm left join job j on jm.job=j.job and jm.suffix=j.suffix where left(jm.item,2)='KG' and jm.u_m='KG' AND j.type = 'J' and j.stat='R')
begin
   insert @UF_tmpTable values('作业BOM中胶水单位用量为应设置为G,但下面物料为KG,请检查是否正确:')
   insert @UF_tmpTable select distinct(jm.item) from jobmatl jm left join job j on jm.job=j.job and jm.suffix=j.suffix where left(jm.item,2)='KG' and jm.u_m='KG' AND j.type = 'J' and j.stat='R'
   insert @UF_tmpTable values('')
end

--4、客户预测检查
if not exists(select item from forecast)
begin
   insert @UF_tmpTable values('系统中没有销售预测,请检查是否正确:')
   insert @UF_tmpTable values('')
end

if exists(select distinct(item) from forecast where convert(varchar(10),fcst_date,120)<convert(varchar(10),getdate(),120))
begin
   insert @UF_tmpTable values('下面物料有销售预测需求日期在今天之前,请检查是否正确:')
   insert @UF_tmpTable select distinct(item) from forecast where convert(varchar(10),fcst_date,120)<convert(varchar(10),getdate(),120)
   insert @UF_tmpTable values('')
end

insert @UF_tmpTable values('检查完毕!')


--exec   master..xp_cmdshell   'bcp   "shat_app..@UF_tmpTable"   out   "d:/tt.txt"   -c   -t   ,-U"sa"   -P"svtep"'

select * from @UF_tmpTable
GO

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

厦门德仔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值