关于KIS专业版13.0 生产领料汇总表取数错误问题!!
金蝶云社区-wxjmxx
wxjmxx
0人赞赏了该文章 952次浏览 未经作者许可,禁止转载编辑于2015年10月21日 22:43:44

过滤条件为如图所示:

KIS专业版13.0 问题

举例: A部门 本日领用 001材料 数量为 5个 单价为 3元
本日又领用一张红字单 001材料 数量为 5个 单价为 3元

B部门 本日领料 001材料 数量为 10个 单价为 3元

按上面的过滤条件 查来所有部门为空数据

经过 数据库跟踪发现语句有问题

Set NoCount On
Select v2.FInterID,v2.FEntryID,v2.FItemID,v2.FSCStockID,v2.FDCStockID,v2.FBatchNo,
round(v2.FQty,t1.FQtyDecimal) as FQty,v2.FPrice,Round(v2.FAmount,2) as FAmount,
round(v2.FQty/t8.FCoefficient,t1.FQtyDecimal) As FCUUnitQty,
v2.FPrice*t8.FCoefficient
As FCUUintPrice Into #ICStockBillEntry
From ICStockBillEntry v2 Inner Join ICStockBill v1 On v1.FInterID=v2.FInterID And v1.FTranType=24
Inner Join t_ICItem t1 On v2.FItemID=t1.FItemID
Inner Join t_MeasureUnit t8 On t1.FStoreUnitID=t8.FMeasureUnitID
inner join t_Stock t2 on v2.FSCStockID=t2.FItemID
inner join t_Department t3 on v1.FDeptID=t3.FItemID
AND t1.FNumber>='001' AND t1.FNumber<='001'
And v1.FDate >='2015-10-21'
And v1.FDate <='2015-10-21'
And v1.FCancelLation=0
Select v1.*,v2.FEntryID Into #ICStockBill
From ICStockBillEntry v2 Inner Join ICStockBill v1 On v1.FInterID=v2.FInterID And v1.FTranType=24
Inner Join t_ICItem t1 On v2.FItemID=t1.FItemID
inner join t_Stock t2 on v2.FSCStockID=t2.FItemID
inner join t_Department t3 on v1.FDeptID=t3.FItemID
AND t1.FNumber>='001' AND t1.FNumber<='001'
And v1.FDate >='2015-10-21'
And v1.FDate <='2015-10-21'
And v1.FCancelLation=0
SET NOCOUNT ON

--------------------------------------------------------此段有问题--------------------------------------------------------------------
delete from #ICStockBillEntry where fitemid in (select t1.fitemid from #ICStockBillEntry v2 Inner Join #ICStockBill v1 On v1.FInterID=v2.FInterID And v1.FTranType=24
Inner Join t_ICItem t1 On v2.FItemID=t1.FItemID
Inner Join t_MeasureUnit t8 On t1.FStoreUnitID=t8.FMeasureUnitID
inner join t_Stock t2 on v2.FSCStockID=t2.FItemID
inner join t_Department t3 on v1.FDeptID=t3.FItemID
--------------------------------------------------------此段有问题----------------------------------------------------------------------
GROUP BY t3.FName,t1.FNumber ,t1.FitemID having sum(v2.Fqty)=0 and sum(v2.FAmount) = 0) CREATE TABLE #DATA(
FProp02 Varchar(355) null,
FNumber Varchar(355) null,
FShortNumber Varchar(355) null,
FName Varchar(355) null,
FModel Varchar(355) null,
FUnitName Varchar(355) null,
FCUUnitName Varchar(355) null,
FQtyDecimal smallint null,
FPriceDecimal smallint null,
FQty decimal(23,10) null,
FPrice decimal(23,10) null,
FCUUnitQty decimal(23,10) null,
FCUUnitPrice decimal(23,10) null,
FAmount Decimal(18,2) null,
FSumSort smallint not null Default(0),
FID int not null identity)
INSERT INTO #DATA SELECT CASE WHEN GROUPING(t3.FName)=1 THEN '合计'
WHEN GROUPING(t1.FNumber)=1 THEN CONVERT(Varchar(355),t3.FName)+'(小计)'
ELSE CONVERT(Varchar(355),t3.FName) END,
t1.FNumber,'','合计','','','',4,4, Sum (v2.FQty),
Max(v2.FPrice),
Sum (v2.FCUUnitQty),Max(v2.FCUUintPrice),
Sum(v2.FAmount),
CASE WHEN GROUPING(t3.FName)=1 THEN 101
WHEN GROUPING(t1.FNumber)=1 THEN 102 ELSE 0 END FROM #ICStockBill v1 inner join #ICStockBillEntry v2 on v1.FInterID=v2.FInterID and v1.FEntryID=v2.FEntryID
inner join t_ICItem t1 on v2.FItemID=t1.FItemID
inner join t_Stock t2 on v2.FSCStockID=t2.FItemID
inner join t_Department t3 on v1.FDeptID=t3.FItemID
WHERE 1=1

AND t1.FNumber>='001' AND t1.FNumber<='001'
GROUP BY t3.FName,t1.FNumber WITH ROLLUP

Update t1 Set t1.FPrice=FAmount/FQty From #DATA t1 Where t1.FQty<>0
Update t1 Set t1.FCUUnitPrice=FAmount/FCUUnitQty From #DATA t1 Where t1.FCUUnitQty<>0
Update t1 Set
t1.FName=t2.FName,t1.FShortNumber=t2.FShortNumber,t1.FModel=t2.FModel,
t1.FUnitName=t3.FName,t1.FCUUnitName=t4.FName,t1.FQtyDecimal=t2.FQtyDecimal,t1.FPriceDecimal=t2.FPriceDecimal
From #DATA t1,t_ICItem t2,t_MeasureUnit t3,t_MeasureUnit t4
Where t1.FNumber=t2.FNumber
And t3.FStandard=1
And t2.FUnitID=t3.FMeasureUnitID
And t2.FStoreUnitID=t4.FMeasureUnitID
update #Data set FQtyDecimal=4,FPriceDecimal=4 where FSumSort<>0 Update #data Set FName = '' where FName ='合计'
SELECT * FROM #DATA
Order by FID
DROP TABLE #DATA

Drop Table #ICStockBill
Drop Table #ICStockBillEntry

以上错误语句是只要001物料有部门数为汇总数为0 就把这个物料的查询记录全删除(不管是哪一个部门的)