金蝶K3 SQL报表系列-委外核销检查表
Posted 小米online
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了金蝶K3 SQL报表系列-委外核销检查表相关的知识,希望对你有一定的参考价值。
转自:https://blog.csdn.net/mamengna/article/details/111798954
1、创建存储过程:sp_ICStockBill_Check
create procedure [dbo].[sp_ICStockBill_Check] as set nocount on declare @currYear int declare @currPeriod int declare @begindate datetime declare @enddate datetime SELECT @currPeriod=FValue FROM t_Systemprofile WHERE FKey=\'CurrentPeriod\' And FCategory=\'IC\' SELECT @currYear=FValue FROM t_Systemprofile WHERE FKey=\'CurrentYear\' And FCategory=\'IC\' EXECUTE GetPeriodStartEnd 0, @currPeriod, @begindate OUTPUT, @enddate OUTPUT create table #StockBill ( FInterid int, FEntryid int, FOrderInterid int, ForderEntryid int, FQty decimal(21,10) ) create table #icstockbillEntry ( FStockInterid int, FStockEntryid int, FOrderInterid int, FOrderEntryid int, FItemid int, FStarandQty decimal(21,10), FScrap decimal(21,10), FQtyMust decimal(21,10), FQty decimal(21,10) ) insert into #StockBill (FInterid,FEntryid,FQty,FOrderInterid,ForderEntryid) select u1.Finterid,u1.Fentryid,u1.Fqty,u1.FOrderInterID,u1.FOrderEntryID from ICStockBillEntry u1 inner join ICStockBill t1 on u1.FInterID=t1.FInterID where t1.FTranType=5 and ISNULL(FCheckerid,0)<>0 and t1.Fdate>=@begindate and t1.Fdate<=@enddate insert into #icstockbillEntry (FStockInterid,FStockEntryid,FOrderInterid,FOrderEntryid,FItemid,FStarandQty,FScrap,FQtyMust) select u1.FInterid,u1.FEntryid,u1.FOrderInterid,u1.ForderEntryid,t2.FItemID,t2.FQtyScrap,t2.FScrap,u1.FQty*t2.FQtyScrap*(1+t2.FScrap/100) from #StockBill u1 inner join PPBOM t1 on u1.FOrderInterid=t1.FICMOInterID and u1.ForderEntryid=t1.FOrderEntryID inner join PPBOMEntry t2 on t2.FInterID=t1.FInterID insert into #icstockbillEntry (FStockInterid,FStockEntryid,FOrderInterid,FOrderEntryid,FItemid,FStarandQty,FScrap,FQtyMust) select u1.FDInterID,u1.FDEntryID,t2.FOrderInterID,t2.FOrderEntryID,t2.FItemID,0,0,0 from ICClientVer u1 left join #icstockbillEntry t1 on u1.FDInterID=t1.FStockInterid and u1.FDEntryID=t1.FStockEntryid inner join ICStockBillEntry t2 on t2.FInterID=u1.FSInterID and t2.FEntryID=u1.FSEntryID and t2.FItemID=t1.FItemid where t1.FStockInterid is null group by u1.FDInterID,u1.FDEntryID,t2.FOrderInterID,t2.FOrderEntryID,t2.FItemID update u1 set u1.FQty=t1.Fqty from #icstockbillEntry u1 inner join ( select k1.FDInterID,k1.FDEntryID,k3.Fitemid,SUM(k1.Fqty) as FQty from ICClientVer k1 inner join ICStockBillEntry k3 on k3.FInterID=k1.FSInterID and k3.FEntryID=k1.FSEntryID group by k1.FDInterID,k1.FDEntryID,k3.Fitemid )t1 on t1.FDInterID=u1.FStockInterid and t1.FDEntryID=u1.FStockEntryid and u1.FItemid=t1.FItemID select t4.FBillNo 委外入库单号, v1.FEntryid 入库单行号, t4.FDate 入库日期, t3.FBillNo 委外订单号, t2.FEntryID 订单行号, t5.FNumber 产品代码, t5.FName 产品名称, t5.FModel 产品规格, t2.FQty 订单数量, t2.FStockQty 订单入库数量, t1.FQty 入库数量, t6.FNumber 材料代码, t6.FName 材料名称, t6.FModel 材料规格, u1.FStarandQty 标准用量, u1.FScrap [损耗(%)], u1.FQtyMust 应核销数量, isnull(u1.FQty,0) 实际核销数量, u1.FQtyMust-isnull(u1.FQty,0) 差异数量 from #StockBill v1 left join #icstockbillEntry u1 on u1.FStockInterid=v1.FInterid and u1.FStockEntryid=v1.FEntryid left join ICStockBillEntry t1 on v1.FInterid=t1.FInterID and v1.FEntryid=t1.FEntryID left join ICStockBill t4 on t4.FInterID=t1.FInterID left join ICSubContractEntry t2 on t2.FInterID=u1.FOrderInterid and t2.FEntryID=u1.FOrderEntryid left join ICSubContract t3 on t3.FInterID=t2.FInterID left join t_ICItem t5 on t5.FItemID=t1.FItemID left join t_ICItem t6 on t6.FItemID=u1.FItemid order by u1.FStockInterid,u1.FStockEntryid drop table #icstockbillEntry drop table #StockBill
2、K3查询分析工具调用:
exec sp_icstockbill_check
金蝶kis自定义报表逻辑判断IF怎么实现,比如说:当某个科目数值等于零时,公式等于0
我现在的公式,有一方数值为零,就会出现“被零除”的提示。
参考技术A =IF(除数单元格=0,,被除数单元格/除数单元格)追问不太对,麻烦帮忙看一下
哦,“金蝶kis”,这和EXCEL表格不同,没有用过,可能是公式的写法不同,帮不上你了
这是百度来的链接你试一下能不能解决你的问题
http://www.0513kingdee.com/news/html/501.html
以上是关于金蝶K3 SQL报表系列-委外核销检查表的主要内容,如果未能解决你的问题,请参考以下文章