物料启用保质期,后台修改取消保质期。
整体思路:1、将物料上保质期取消;
2、将单据上的保质期进行取消;
3、取消库房存货余额表上对应物料的保质期;
4、取消存货表上对应物料的保质期;
5、处理完以后,在即时库存中进行对应物料库存校对;
附:相应代码
注:在插入数据前一定要看清对应表中的字段是否与语句中一样,如果不相同需要进行相应修改。
--取消物料上的保质期
update t_ICItem set FISKFPeriod=0,FKFPeriod=0 where FNumber in(物料代码)
--查询库存明细
SELECT * FROM ICInvBal where fitemid=物料ID
--将库房存货余额表中对应物料库存明细先放入临时表
SELECT * INTO #ICInvBalFKFDate FROM ICInvBal where fitemid=物料ID
GO
--删除库房存货余额表中对应物料记录
delete from ICInvBal where fitemid=物料ID
GO
--将临时表中数据取出来插入到库房存货余额表中(有进行合计)
INSERT INTO ICInvBal(FBrNo,FYear,FPeriod,FStockID,FItemID,FBatchNo,FBegQty,FReceive,FSend,FYtdReceive,FYtdSend
,FEndQty,FBegBal,FDebit,FCredit,FYtdDebit,FYtdCredit,FEndBal,FBegDiff,FReceiveDiff
,FSendDiff,FEndDiff,FBillInterID,FStockPlaceID,FKFPeriod,FKFDate,FYtdReceiveDiff,FYtdSendDiff
,FSecBegQty,FSecReceive,FSecSend,FSecYtdReceive,FSecYtdSend,FSecEndQty,FAuxPropID,FStockInDate,FMTONo,FSupplyID)
select FBrNo,FYear,FPeriod,FStockID,FItemID,FBatchNo,
SUM(FBegQty),SUM(FReceive),SUM(FSend),SUM(FYtdReceive),sum(FYtdSend),
SUM(FEndQty),SUM(fbegbal),SUM(fdebit),SUM(FCredit),SUM(FYtdDebit),
SUM(FYtdCredit),SUM(FEndBal),SUM(FBegDiff),SUM(FReceiveDiff),
SUM(FSendDiff),SUM(FEndDiff),FBillInterID,FStockPlaceID,0,'',
SUM(FYtdReceiveDiff),SUM(FYtdSendDiff),
SUM(FSecBegQty),SUM(FSecReceive),SUM(FSecSend),SUM(FSecYtdReceive),
sum(FSecYtdSend),SUM(FSecEndQty),
FAuxPropID,FStockInDate,FMTONo,FSupplyID
from #ICInvBalFKFDate
group by FBrNo,FYear,FPeriod,FStockID,FItemID,FBatchNo,FBillInterID,FStockPlaceID,FAuxPropID,FStockInDate,FMTONo,FSupplyID
GO
--查询临时表数据
SELECT * FROM #ICInvBalFKFDate
GO
--删除临时表
drop table #ICInvBalFKFDate
--更新出入库单表
SELECT FKFDate,FKFPeriod,FPeriodDate,* FROM ICStockBillEntry WHERE FItemID=物料ID
update ICStockBillEntry set FKFDate=null ,FKFPeriod=0,FPeriodDate=null where FItemID in(物料ID)
--收料通知/请检单/退料通知单
update POInStockEntry set FKFDate=null ,FKFPeriod=0,FPeriodDate=null where FItemID in(物料ID)
--将存货表中数据取出来放入临时表中
SELECT * into #TEMP01 FROM ICInventory where fitemid=物料ID
GO
--删除存货表中对应物料数据
delete from ICInventory where fitemid=物料ID
--查询一下临时表中数据
SELECT * FROM #TEMP01
GO
--将临时表中数据插入到存货表中
INSERT INTO ICInventory(FBrNo,FItemID,FBatchNo,FStockID,FQty,FBAL,FStockPlaceID,FKFPeriod,FKFDate,FQtyLock,FAuxPropID,
FSecQty,FMTONo,FSupplyID)
select FBrNo,FItemID,FBatchNo,FStockID, SUM(FQTY),FBal,FStockPlaceID,0,0,FQtyLock,FAuxPropID,FSecQty,FMTONo,FSupplyID
from #TEMP01
group by FBrNo,FItemID,FBatchNo,FStockID,FBAL,FStockPlaceID,FQtyLock,FAuxPropID,FSecQty,FMTONo,FSupplyID
GO
--删除临时表
DROP TABLE #TEMP01
【emoji】
【emoji】
物料启用保质期,后台修改取消保质期。
本文2024-09-16 15:51:17发表“k3wise知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3wise-5494.html