用友软件出库跟踪入库型存货处理通用脚本

技术咨询,有偿服务!
复制微信号
原因分析:2102080存货的不能参照入库单的原因是:存货对应入库单的累计出库数量错误以及出入库跟踪表记录错误
问题解答:以下是通用的脚本,可直接修改出库跟踪入库型存货的入库单子表累计出库数量与对应出入库跟踪表出空标识,脚本如下:--查询出库跟踪入库型存货的入库单“累计出库数量”不等于对应出库单“实际出库数量”(不包含辅助计量单位、存货自由项)select rds.autoid,rd.cwhcode,rds.cinvcode,(case when bRdFlag=1 then rds.iQuantity else -rds.iQuantity end) as iinQuantity,rds.isoutquantity,a.ifoutquantityfrom rdrecord rd inner join RdRecords rds on rd.ID=rds.id right join (select cvouchcode,cwhcode,cinvcode,sum(iquantity) as ifoutquantity from rdrecord rd left join RdRecords rds on rd.ID=rds.id where cwhcode='01' and cinvcode='2102080' and brdflag=0 and cvouchcode is not null group by cvouchcode,cwhcode,cinvcode) a on a.cvouchcode=rds.autoid and a.cwhcode=rd.cwhcode and a.cInvCode=rds.cInvCode where (brdflag=1 or(brdflag=0 and rds.cVouchCode is null)) and rds.isoutquantity<>a.ifoutquantity and (case when bRdFlag=1 then rds.iQuantity else -rds.iQuantity end)>a.ifoutquantity --最后rds.isoutquantity>a.ifoutquantity考虑到有可能实际出库数量大于入库单据累计入库数量--查询出入库跟踪表“是否出空”记录(不包含辅助计量单位、存货自由项)select MainBatch.rdid,MainBatch.cwhcode,MainBatch.cinvcode,MainBatch.bisnull,a.iinQuantity,a.isoutquantityfrom MainBatch right join (select rds.autoid,rd.cwhcode,rds.cinvcode,(case when bRdFlag=1 then rds.iQuantity else -rds.iQuantity end) as iinQuantity,rds.isoutquantity from rdrecord rd left join RdRecords rds on rd.ID=rds.id where (brdflag=1 or(brdflag=0 and cVouchCode is null))) a on a.AutoID=MainBatch.RdID and a.cWhCode=MainBatch.cWhCode and a.cInvCode=MainBatch.cInvCodewhere MainBatch.cwhcode='01' and MainBatch.cInvCode ='2102080' and a.iinQuantity<>a.iSOutQuantity and MainBatch.bisnull<>0如确定上述问题,修改脚本如下:--修改出库跟踪入库型存货的入库单“累计出库数量”不等于对应出库单“实际出库数量”(不包含辅助计量单位、存货自由项)update RdRecords set iSOutQuantity=a.ifoutquantityfrom rdrecord rd inner join RdRecords rds on rd.ID=rds.id right join (select cvouchcode,cwhcode,cinvcode,sum(iquantity) as ifoutquantity from rdrecord rd left join RdRecords rds on rd.ID=rds.id where cwhcode='01' and cinvcode='2102080' and brdflag=0 and cvouchcode is not null group by cvouchcode,cwhcode,cinvcode) a on a.cvouchcode=rds.autoid and a.cwhcode=rd.cwhcode and a.cInvCode=rds.cInvCode where (brdflag=1 or(brdflag=0 and rds.cVouchCode is null)) and rds.isoutquantity<>a.ifoutquantity and (case when bRdFlag=1 then rds.iQuantity else -rds.iQuantity end)>a.ifoutquantity --最后rds.isoutquantity>a.ifoutquantity考虑到有可能实际出库数量大于入库单据累计入库数量--修改出入库跟踪表“是否出空”记录(不包含辅助计量单位、存货自由项)update MainBatch set bIsNull=0 from MainBatch right join (select rds.autoid,rd.cwhcode,rds.cinvcode,(case when bRdFlag=1 then rds.iQuantity else -rds.iQuantity end) as iinQuantity,rds.isoutquantity from rdrecord rd left join RdRecords rds on rd.ID=rds.id where (brdflag=1 or(brdflag=0 and cVouchCode is null))) a on a.AutoID=MainBatch.RdID and a.cWhCode=MainBatch.cWhCode and a.cInvCode=MainBatch.cInvCodewhere MainBatch.cwhcode='01' and MainBatch.cInvCode ='2102080' and a.iinQuantity<>a.iSOutQuantity and MainBatch.bisnull<>0