问题现象: | 年转后库存期初结存中存在许多数量为0的记录和没有货位的记录 数据已上传 艺红.rar文件 |
问题原因: | |
解决方案: | 您好,已就该问题与一线丁女士电话沟通,此问题【经查看数据--天津艺虹】现做如下分析与答复: 【问题原因】 初步判断年转后库存期初存在数量为0或没有货位的情况可能与未打最新的年结补丁有关,由于用户处已在新年度发生业务因此建议通过相应脚本在后台予以调整。 【解决方案】 执行如下脚本前请做好数据备份!(请根据实际情况调整帐套号即可) --查询上下年的货位明细的差异: select * from (SELECT cwhcode,cposcode,cinvcode,CBATCH,sum(case brdflag when 1 then iquantity else -iquantity end )iquantity from ufdata_002_2011..invposition WHERE DDATE<='2011-12-31' group by cwhcode,cposcode,cinvcode,CBATCH having sum(case brdflag when 1 then iquantity else -iquantity end )<>0) invpos11 join (SELECT cwhcode,cposcode,cinvcode,CBATCH,sum(case brdflag when 1 then iquantity else -iquantity end )iquantity from ufdata_002_2012..invposition WHERE DDATE<='2011-12-31' group by cwhcode,cposcode,cinvcode,CBATCH having sum(case brdflag when 1 then iquantity else -iquantity end )<>0)invpos12 on invpos11.cwhcode=invpos12.cwhcode and invpos11.cposcode=invpos12.cposcode and invpos11.cinvcode=invpos12.cinvcode and invpos11.cbatch=invpos12.cbatch where ABS(isnull(invpos11.iquantity,0)-isnull(invpos12.iquantity,0))>=0.01 --调整库存货位期初结存 UPDATE ufdata_002_2012..invposition SET IQUANTITY=-220 FROM ufdata_002_2012..invposition WHERE DDATE<='2011-12-31' AND CINVCODE='AD69-03597A' AND IQUANTITY=-293 --查询库存期初带货位管理的数据与货位期初不平的记录 use ufdata_002_2012 select * from ( select rdrecord.cwhcode,cinvcode,sum(iquantity)iq from rdrecord join rdrecords on rdrecord.id=rdrecords.id join warehouse on rdrecord.cwhcode=warehouse.cwhcode where bisstqc=1 and bWhPos=1 group by rdrecord.cwhcode,cinvcode having sum(iquantity)<>0)qc full outer join ( SELECT cwhcode,cinvcode,sum(case brdflag when 1 then iquantity else -iquantity end )iquantity from ufdata_002_2012..invposition WHERE DDATE<='2011-12-31' group by cwhcode,cinvcode having sum(case brdflag when 1 then iquantity else -iquantity end )<>0)po on qc.cwhcode=po.cwhcode and qc.cinvcode=po.cinvcode where abs(isnull(iq,0)-isnull(iquantity,0))>=0.01 --修改库存期初不正确的结存 update rdrecords set iquantity=592 from rdrecord join rdrecords on rdrecord.id=rdrecords.id join warehouse on rdrecord.cwhcode=warehouse.cwhcode where bisstqc=1 and bWhPos=1 and cinvcode in('AD69-03287A') update rdrecords set iquantity=1353 from rdrecord join rdrecords on rdrecord.id=rdrecords.id join warehouse on rdrecord.cwhcode=warehouse.cwhcode where bisstqc=1 and bWhPos=1 and cinvcode in('AD69-03597A') --查询货位期初对应的库存期初货位 --1.先删除库存期初结存为0的记录 select autoid,rdrecord.id into rdid from rdrecord join rdrecords on rdrecord.id=rdrecords.id where bisstqc=1 and iquantity=0 delete from rdrecords where autoid in(select autoid from rdid) delete From rdrecord where id in(select id from rdid) --查询对应的记录的货位 select rdrecords.cposition,po.cposcode,* from rdrecord join rdrecords on rdrecord.id=rdrecords.id join warehouse on rdrecord.cwhcode=warehouse.cwhcode join ( SELECT cwhcode,cposcode,cinvcode,CBATCH,sum(case brdflag when 1 then convert(decimal (38,6),IsNull(iquantity,0)) else -convert(decimal (38,6),IsNull(iquantity,0)) end )iquantity from ufdata_002_2012..invposition WHERE DDATE<='2011-12-31' group by cwhcode,cposcode,cinvcode,CBATCH having sum(case brdflag when 1 then convert(decimal (38,6),IsNull(iquantity,0)) else -convert(decimal (38,6),IsNull(iquantity,0)) end )<>0)po on rdrecord.cwhcode=po.cwhcode and rdrecords.cinvcode=po.cinvcode where bisstqc=1 and bWhPos=1 --修改 update rdrecords set rdrecords.cposition=po.cposcode from rdrecord join rdrecords on rdrecord.id=rdrecords.id join warehouse on rdrecord.cwhcode=warehouse.cwhcode join ( SELECT cwhcode,cposcode,cinvcode,CBATCH,sum(case brdflag when 1 then convert(decimal (38,6),IsNull(iquantity,0)) else -convert(decimal (38,6),IsNull(iquantity,0)) end )iquantity from ufdata_002_2012..invposition WHERE DDATE<='2011-12-31' group by cwhcode,cposcode,cinvcode,CBATCH having sum(case brdflag when 1 then convert(decimal (38,6),IsNull(iquantity,0)) else -convert(decimal (38,6),IsNull(iquantity,0)) end )<>0)po on rdrecord.cwhcode=po.cwhcode and rdrecords.cinvcode=po.cinvcode where bisstqc=1 and bWhPos=1 and abs(isnull(rdrecords.iquantity,0)-isnull(po.iquantity,0))=0 and rdrecords.cposition is null --查询2012库存期初记录中结存数量一致但与货位明细不匹配的数据,若日常发生时货位结存取自货位明细结果则无需调整。 use ufdata_002_2012 select po.*,qc.* from ( select rdrecord.cwhcode 仓库,cinvcode 存货,cposition 期初货位,cbatch 期初批次,sum(iquantity)期初结存数量 from rdrecord join rdrecords on rdrecord.id=rdrecords.id join warehouse on rdrecord.cwhcode=warehouse.cwhcode where bisstqc=1 and bWhPos=1 group by rdrecord.cwhcode,cinvcode,cposition,cbatch having sum(iquantity)<>0)qc full outer join ( SELECT cwhcode 仓库,cinvcode 存货,cposcode 上年货位,cbatch 上年批次,sum(case brdflag when 1 then iquantity else -iquantity end )上年结存数量 from ufdata_002_2011..invposition WHERE DDATE<='2011-12-31' group by cwhcode,cinvcode,cposcode,cbatch having sum(case brdflag when 1 then iquantity else -iquantity end )<>0)po on qc.仓库=po.仓库 and qc.存货=po.存货 and qc.期初货位=po.上年货位 and qc.期初批次=po.上年批次 where abs(isnull(期初结存数量,0)-isnull(上年结存数量,0))>=0.01 【注意事项】修改前请务必做好数据备份;可在测试环境下先行引入用户数据后打补丁测试验证 |
相关补丁: | |
版本: | 8.90 |
模块: | 库存管理 |
产品: | 供应链 |
问题名称: | 艺红--库存期初结存问题 |
最后更新: | 2012-01-17 15:42:08 |