可能是期初使用excel导入或者中途强制修改过单位造成,只能通过修改数据库处理。
处理办法: 把入库单、库存余额表、即时库存的单位,改成与物料一致
query not right inventory unit material
SELECT distinct n.fmaterialid, n.fnumber,m.FBASEUNITID 物料基本单位,a.FBASEUNITID 即时库存基本单位,s.FSTOREUNITID 物料库存单位,a.FSTOCKUNITID 即时库存单位,a.FSTOCKORGID , l.fname, s.FAUXUNITID 物料辅单位,a.FSECUNITID ,a.fid,a.fbaseqty
from T_STK_INVENTORY a join T_BD_MATERIALbase m on m.FMATERIALID=a.FMATERIALID join T_BD_MATERIAL n on n.FMATERIALID=m.FMATERIALID join T_BD_MATERIALSTOCK s on s.FMATERIALID=n.FMATERIALID
join T_ORG_ORGANIZATIONS_L l on l.forgid=a.FSTOCKORGID AND L.FLOCALEID =2052 where (m.FBASEUNITID <>a.FBASEUNITID or s.FSTOREUNITID<>a.FSTOCKUNITID or s.FAUXUNITID<>a.FSECUNITID )
select * from T_STK_INVENTORYLOG where FINVENTORYID ='0894ef07-3ec3-80fd-11e9-ebff63a97977'
select a.fbillno,a.fdate,e.fseq,e.FBASEUNITID ,e.FBASEUNITQTY ,e.FUNITID , *
from t_STK_InStock a join t_STK_InStockentry e on a.fid=e.fid where e.fentryid=126562
这里可以看到FBASEUNITID和FUNITID都是错误的10101单位,如果有一个是正确的,那么可以不用修改。
select e.* into t_STK_InStockentrybak2
from t_STK_InStock a join t_STK_InStockentry e on a.fid=e.fid where e.fentryid=126562
update e set FBASEUNITID=10095, FUNITID=10095
from t_STK_InStock a join t_STK_InStockentry e on a.fid=e.fid where e.fentryid=126562
select FBASEUNITID, * from t_stk_invbal t where fmaterialid=611336
select * into t_stk_invbalbak2 from t_stk_invbal t where fmaterialid=611336
update t set FBASEUNITID=10095 from t_stk_invbal t where fmaterialid=611336
select FBASEUNITID, * from T_STK_INVENTORY t where fmaterialid=611336
select * into T_STK_INVENTORYbak2 from T_STK_INVENTORY t where fmaterialid=611336
update t set FBASEUNITID=10095 from T_STK_INVENTORY t where fmaterialid=611336
这样使用盘点方案进行清空物料库存就不会提示这个错误了。