问题现象: | 存货设置为PE件,销售订单做预留,做发货单,后来把发货单删除,但原销售订单中的预留数量不清空; 整单关闭销售订单,也无法释放,也没有办法做整单释放。 |
问题原因: | |
解决方案: | 您好,研发回复:执行下列脚本先试一下. 联系方式:01062435340田先林 if exists (select * from sysobjects where xtype ='tr' and name = 'tr_scm_fhd_pe_preqty' and object_name(parent_obj)=N'dispatchlists') drop trigger tr_scm_fhd_pe_preqty go create trigger tr_scm_fhd_pe_preqty on dispatchlists for insert ,update as update a set iprekeepquantity = case when isnull(iprekeepquantity,0)- isnull(b.iqty,0) >= 0 then isnull(iprekeepquantity,0)- isnull(b.iqty,0) else 0 end, iprekeepnum = case when i.igrouptype = 0 then null when i.igrouptype = 2 then case when isnull(iprekeepnum,0)- isnull(b.inum,0) >= 0 then isnull(iprekeepnum,0)- isnull(b.inum,0) else 0 end else case when isnull(iprekeepquantity,0)- isnull(b.iqty,0) >= 0 then isnull(iprekeepquantity,0)- isnull(b.iqty,0) else 0 end / a.iinvexchrate end, iprekeeptotquantity = case when isnull(iprekeeptotquantity,0)- isnull(b.iqty,0) >= 0 then isnull(iprekeeptotquantity,0)- isnull(b.iqty,0) else 0 end, iprekeeptotnum = case when i.igrouptype = 0 then null when i.igrouptype = 2 then case when isnull(iprekeeptotnum,0)- isnull(b.inum,0) >= 0 then isnull(iprekeeptotnum,0)- isnull(b.inum,0) else 0 end else case when isnull(iprekeeptotquantity,0)- isnull(b.iqty,0) >= 0 then isnull(iprekeeptotquantity,0)- isnull(b.iqty,0) else 0 end / a.iinvexchrate end from so_sodetails a inner join ( select sum ((isnull(inserted.iquantity,0) - isnull(deleted.iquantity,0))) as iqty, sum((isnull(inserted.inum,0) - isnull(deleted.inum,0))) as inum, inserted.isosid from inserted left join deleted on inserted.isosid = deleted.isosid left join inventory i on inserted.cinvcode = i.cinvcode where isnull(i.cSRPolicy,'')=N'PE' and isnull(inserted.iquantity,0) > 0 and (isnull(inserted.iquantity,0) - isnull(deleted.iquantity,0)) > 0 and isnull(deleted.iquantity,0)>= 0 group by inserted.isosid ) b on a.isosid = b.isosid inner join inventory i with (nolock) on a.cinvcode = i.cinvcode where isnull(i.cSRPolicy,'')=N'PE' go update a set iprekeepquantity = isnull(b.iqty,0) , iprekeepnum = case when i.igrouptype = 0 then null when i.igrouptype = 2 then isnull(b.inum,0) else isnull(b.iqty,0) / a.iinvexchrate end, iprekeeptotquantity =isnull(b.iqty,0) , iprekeeptotnum =case when i.igrouptype = 0 then null when i.igrouptype = 2 then isnull(b.inum,0) else isnull(b.iqty,0)/ a.iinvexchrate end from so_sodetails a left join (select isodid,sum(isnull(iquantity,0)) as iqty,sum(isnull(inum,0)) as inum from ST_PELockedSum with (nolock) where isotype =1 group by isodid ) b on convert(nvarchar(40),a.isosid) = b.isodid left join inventory i on a.cinvcode = i.cinvcode where isnull(i.cSRPolicy,'')=N'PE' go |
相关补丁: | |
版本: | 8.90 |
模块: | 销售管理 |
产品: | 供应链 |
问题名称: | PE预留,销售发货单删除或订单关闭时,预留数量不回写 |
最后更新: | 2011-06-21 23:04:44 |