成本计算提示工单未结案,但是工单已经被删除的问题
金蝶云社区-Tony唐冰
Tony唐冰
0人赞赏了该文章 1,140次浏览 未经作者许可,禁止转载编辑于2018年01月17日 15:00:40

成本计算时,提示SQL错误,按照之前顾问给的SQL脚本执行,删除重复的投入产量归集表的数据
再重新计算,提示某个工单未期在产金额为0未结案。的提示
但是查询生产订单已找不到此单据,如何解决?
V7 补丁9-8
QQ13750599
SQL脚本
--删除重复的投入产量归集表信息
select t2.FENTRYID, t2.FPROORDERNO,t2.FPRODUCTID,t2.FPROORDERENTRYID,t2.FPROORDERSEQ into T_NeedDelete180117
from T_CB_INPUTQTY t1
inner join T_CB_INPUTQTYENTRY t2 on t1.FID=t2.FID
left join (
select mo.FBILLNO,moentry.FSEQ,moentry.FENTRYID,moentry.FMATERIALID
from T_PRD_MO mo inner join T_PRD_MOENTRY moentry
on mo.FID=moentry.FID
) A on A.FBILLNO=t2.FPROORDERNO and A.FENTRYID=t2.FPROORDERENTRYID and A.FMATERIALID=t2.FPRODUCTID and A.FSEQ=t2.FPROORDERSEQ
where t2.FPROORDERTYPE='PO' and A.FBILLNO is null and t2.FDATE>='2017-09-01'and t2.FDATE<'2018-12-31'

select * into T_CB_INPUTQTYENTRY180117 from T_CB_INPUTQTYENTRY where FENTRYID in (select FENTRYID from T_NeedDelete180117 )
select * from T_CB_INPUTQTYENTRY180117
-- delete from T_CB_INPUTQTYENTRY where FENTRYID in (select FENTRYID from T_NeedDelete180117 )
select * from T_NeedDelete180117

--生产订单反下达后删除了订单导致成本计算报SQl错误 2017-11-14
DELETE FROM T_CB_INPUTQTYENTRY WHERE FSRCBILLFORMID = 'PRD_MO'
AND NOT EXISTS(SELECT 1 FROM T_PRD_MOENTRY T0 WHERE T0.FENTRYID = T_CB_INPUTQTYENTRY.FSRCENTRYID);
DELETE FROM T_CB_INPUTQTYENTRY WHERE FSRCBILLFORMID = 'SUB_SUBREQORDER'
AND NOT EXISTS(SELECT 1 FROM T_SUB_REQORDERENTRY T0 WHERE T0.FENTRYID = T_CB_INPUTQTYENTRY.FSRCENTRYID);