用友U8 U821以前年度未结算的发货单在本年度能够弃审用友U8 U821以前年度未结算的发货单在本年度能够弃审
问题原因:发货单弃审时未检查是否为以前年度的单据 解决方法:在未出补丁时可用以下办法暂时解决,即修改存储过程SA_CancelSureFHD后当审核期初发货单时软件会报期初发货单不能弃审!/* 江苏省药材公司 期初发货单能弃审 2003-07-07 南京用友维护部 丁德安*/IF EXISTS(SELECT * FROM sysobjects WHERE name='SA_CancelSureFHD' and type='P')DROP PROC SA_CancelSureFHDGOCREATE PROC SA_CancelSureFHD(@VouchType as varchar(3),@VouchID As Int)AS--删除出库单、删除货位、修改现存量Declare @AutoID As IntDeclare @cWhCode As Varchar(10)Declare @cInvCode As Varchar(20)Declare @cFree1 As Varchar(20)Declare @cFree2 As Varchar(20)Declare @iQuantity As FloatDeclare @iNum As FloatDeclare @iDispQuantity As FloatDeclare @iDispNum As Float/* 增加判断条件 判断是否为期初发货单,即RdRecord.cVouchtype='34' 如为期初发货单则不能弃审 2003-07-07*/Declare @cVouchType as varchar(10)SELECT DISTINCT @cVouchType=r.cVouchType FROM RdRecord r inner join rdrecords rs on r.id=rs.id inner joinDispatchLists ds on rs.iDLsID=ds.iDLsID inner join DispatchList d on d.DLID=ds.DLIDWHERE d.DLID=@VouchIDIF @cVouchType='34'BeginSELECT 0 AS iRet,'期初发货单不能弃审!' AS InfoReturnEnd--弃审时如果生成的是红字销售出库单则如果指定了货位,就不能弃审--在删除货位结存时要判断不等于'货位调整'--SET @AutoID=(SELECT Count(AutoID) FROM RdRecord INNER JOIN RdRecords ON RdRecord.ID=RdRecords.ID --WHERE cVouchType='32' AND bRdFlag=0 AND iQuantity<0 AND RdRecord.cDLCode = @VouchID --AND AutoID IN (SELECT RdsID FROM InvPosition WHERE IsNull(cSource,'')=''))--If IsNull(@AutoID,0)=0--Begin--删除货位if @VouchType='FHD' OR @VouchType='WT'if @VouchType='FHD'DELETE FROM InvPosition WHERE IsNull(cSource,'')='' AND RdsID IN (SELECT RdRecords.AutoID FROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID=RdRecords.ID) inner join dispatchlists on rdrecords.idlsid=dispatchlists.idlsid WHERE DLID = @VouchID AND cVouchType='32')ElseDELETE FROM InvPosition WHERE IsNull(cSource,'')='' AND RdsID IN (SELECT RdRecords.AutoID FROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID=RdRecords.ID) inner join EnDispatchs on rdrecords.iEnsid=EnDispatchs.AutoID WHERE EDID = @VouchID AND cVouchType='32')elseDELETE FROM InvPosition WHERE IsNull(cSource,'')='' AND RdsID IN (SELECT RdRecords.AutoID FROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID=RdRecords.ID) inner join salebillvouchs on rdrecords.isbsid=salebillvouchs.autoid WHERE sbvid = @VouchID AND cVouchType='32')--修改现存量表if @VouchType='FHD' OR @VouchType='WT'if @VouchType='FHD'DECLARE cur_CurrentStock CURSOR FORSELECT DispatchLists.cWhCode,DispatchLists.cInvCode,DispatchLists.cFree1,DispatchLists.cFree2,Rdrecords.iQuantity,RdRecords.iNum,DispatchLists.iQuantity,DispatchLists.iNumFROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID = RdRecords.ID) inner join DispatchLists on dispatchlists.idlsid=rdrecords.idlsidWHERE DLID = @VouchID AND cVouchType='32' AND cBusType<>'委托代销'FOR READ ONLYElseDECLARE cur_CurrentStock CURSOR FORSELECT EnDispatchs.cWhCode,EnDispatchs.cInvCode,EnDispatchs.cFree1,EnDispatchs.cFree2,Rdrecords.iQuantity,RdRecords.iNum,EnDispatchs.iQuantity,EnDispatchs.iNumFROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID = RdRecords.ID) inner join EnDispatchs on EnDispatchs.AutoID=rdrecords.iEnsidWHERE EDID = @VouchID AND cVouchType='32'FOR READ ONLYelseDECLARE cur_CurrentStock CURSOR FORSELECT Salebillvouchs.cWhCode,Salebillvouchs.cInvCode,Salebillvouchs.cFree1,Salebillvouchs.cFree2,Rdrecords.iQuantity,RdRecords.iNum,Salebillvouchs.iQuantity,Salebillvouchs.iNumFROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID = RdRecords.ID) inner join Salebillvouchs on Salebillvouchs.autoid=rdrecords.isbsidWHERE sbvid = @VouchID AND cVouchType='32'FOR READ ONLYOPEN cur_CurrentStockFETCH NEXT FROM cur_CurrentStock INTO @cWhCode,@cInvCode,@cFree1,@cFree2,@iQuantity,@iNum,@iDispQuantity,@iDispNumWHILE @@FETCH_STATUS>=0Begin--If @VouchType='WT'--UPDATE CurrentStock SET fOutQuantity=cast(isnull(fOutQuantity,0)+@iDispQuantity as decimal(20,6)),fOutNum=cast(isnull(fOutNum,0)+@iDispNum as decimal(20,6)),--iQuantity=cast(isnull(iQuantity,0)+@iQuantity as decimal(20,6)),iNum=cast(isnull(iNum,0)+@iNum as decimal(20,6))--WHERE cWhCode = @cWhCode AND cInvCode = @cInvCode AND IsNull(cFree1,'') = IsNull(@cFree1,'') AND IsNull(cFree2,'') = IsNull(@cFree2,'')--ElseIf @iDispQuantity>0UPDATE CurrentStock SET fOutQuantity=cast(isnull(fOutQuantity,0)+@iDispQuantity as decimal(20,6)),fOutNum=cast(isnull(fOutNum,0)+@iDispNum as decimal(20,6)),iQuantity=cast(isnull(iQuantity,0)+@iQuantity as decimal(20,6)),iNum=cast(isnull(iNum,0)+@iNum as decimal(20,6))WHERE cWhCode = @cWhCode AND cInvCode = @cInvCode AND IsNull(cFree1,'') = IsNull(@cFree1,'') AND IsNull(cFree2,'') = IsNull(@cFree2,'')Else UPDATE CurrentStock SET fInQuantity=cast(isnull(fInQuantity,0)+Abs(@iDispQuantity) as decimal(20,6)),fInNum=cast(isnull(fInNum,0)+Abs(@iDispNum) as decimal(20,6)),iQuantity=cast(isnull(iQuantity,0)-Abs(@iQuantity) as decimal(20,6)),iNum=cast(isnull(iNum,0)-Abs(@iNum) as decimal(20,6))WHERE cWhCode = @cWhCode AND cInvCode = @cInvCode AND IsNull(cFree1,'') = IsNull(@cFree1,'') AND IsNull(cFree2,'') = IsNull(@cFree2,'')If @@Error<>0BeginSELECT 0 AS iRet,'修改现存量错!' AS InfoReturnEndFETCH NEXT FROM cur_CurrentStock INTO @cWhCode,@cInvCode,@cFree1,@cFree2,@iQuantity,@iNum,@iDispQuantity,@iDispNumEndCLOSE cur_CurrentStockDEALLOCATE cur_CurrentStockif @VouchType='FHD' OR @VouchType='WT'if @VouchType='FHD'DELETE FROM RdRecords WHERE IsNull(iEnsID,0)=0 And iDLsID IN (SELECT iDLsID FROM DispatchLists WHERE DLID=@VouchID)ElseDELETE FROM RdRecords WHERE IsNull(iEnsID,0)<>0 And iEnsID IN (SELECT AutoID FROM EnDispatchs WHERE EDID=@VouchID)elseDELETE FROM RdRecords WHERE iSBsid IN (SELECT autoid FROM salebillvouchs WHERE sbvid=@VouchID)If @@Error<>0BeginSELECT 0 AS iRet,'删除出库单表体记录错!' AS InfoReturnEnd--if @VouchType='FHD'delete from rdrecord where id in (select rdrecord.id from rdrecord left join rdrecords on rdrecord.id=rdrecords.id where rdrecords.id is null)--else--DELETE FROM RdRecord WHERE cBillCode = @VouchID AND cVouchType='32'If @@Error<>0BeginSELECT 0 AS iRet,'删除出库单表头记录错!' AS InfoReturnEnd--End --Else--Begin--SELECT 0 AS iRet,'号发货单对应的红字出库单已经指定货位,不能弃审!' AS Info--Return--Endif @VouchType='FHD' OR @VouchType='WT'if @VouchType='FHD'UPDATE DispatchList SET cSaleOut='' WHERE DLID=@VouchIDElseUPDATE EnDispatch SET cSaleOut='' WHERE EDID=@VouchIDelseUPDATE Salebillvouch SET cSaleOut='' WHERE SBVID=@VouchIDIf @@Error<>0BeginSELECT 0 AS iRet,'修改发货单错!' AS InfoReturnEndSELECT 1 AS iRet,'' As InfoReturn
解决方案:
问题原因:发货单弃审时未检查是否为以前年度的单据 解决方法:在未出补丁时可用以下办法暂时解决,即修改存储过程SA_CancelSureFHD后当审核期初发货单时软件会报期初发货单不能弃审!/* 江苏省药材公司 期初发货单能弃审 2003-07-07 南京用友维护部 丁德安*/IF EXISTS(SELECT * FROM sysobjects WHERE name='SA_CancelSureFHD' and type='P')DROP PROC SA_CancelSureFHDGOCREATE PROC SA_CancelSureFHD(@VouchType as varchar(3),@VouchID As Int)AS--删除出库单、删除货位、修改现存量Declare @AutoID As IntDeclare @cWhCode As Varchar(10)Declare @cInvCode As Varchar(20)Declare @cFree1 As Varchar(20)Declare @cFree2 As Varchar(20)Declare @iQuantity As FloatDeclare @iNum As FloatDeclare @iDispQuantity As FloatDeclare @iDispNum As Float/* 增加判断条件 判断是否为期初发货单,即RdRecord.cVouchtype='34' 如为期初发货单则不能弃审 2003-07-07*/Declare @cVouchType as varchar(10)SELECT DISTINCT @cVouchType=r.cVouchType FROM RdRecord r inner join rdrecords rs on r.id=rs.id inner joinDispatchLists ds on rs.iDLsID=ds.iDLsID inner join DispatchList d on d.DLID=ds.DLIDWHERE d.DLID=@VouchIDIF @cVouchType='34'BeginSELECT 0 AS iRet,'期初发货单不能弃审!' AS InfoReturnEnd--弃审时如果生成的是红字销售出库单则如果指定了货位,就不能弃审--在删除货位结存时要判断不等于'货位调整'--SET @AutoID=(SELECT Count(AutoID) FROM RdRecord INNER JOIN RdRecords ON RdRecord.ID=RdRecords.ID --WHERE cVouchType='32' AND bRdFlag=0 AND iQuantity<0 AND RdRecord.cDLCode = @VouchID --AND AutoID IN (SELECT RdsID FROM InvPosition WHERE IsNull(cSource,'')=''))--If IsNull(@AutoID,0)=0--Begin--删除货位if @VouchType='FHD' OR @VouchType='WT'if @VouchType='FHD'DELETE FROM InvPosition WHERE IsNull(cSource,'')='' AND RdsID IN (SELECT RdRecords.AutoID FROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID=RdRecords.ID) inner join dispatchlists on rdrecords.idlsid=dispatchlists.idlsid WHERE DLID = @VouchID AND cVouchType='32')ElseDELETE FROM InvPosition WHERE IsNull(cSource,'')='' AND RdsID IN (SELECT RdRecords.AutoID FROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID=RdRecords.ID) inner join EnDispatchs on rdrecords.iEnsid=EnDispatchs.AutoID WHERE EDID = @VouchID AND cVouchType='32')elseDELETE FROM InvPosition WHERE IsNull(cSource,'')='' AND RdsID IN (SELECT RdRecords.AutoID FROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID=RdRecords.ID) inner join salebillvouchs on rdrecords.isbsid=salebillvouchs.autoid WHERE sbvid = @VouchID AND cVouchType='32')--修改现存量表if @VouchType='FHD' OR @VouchType='WT'if @VouchType='FHD'DECLARE cur_CurrentStock CURSOR FORSELECT DispatchLists.cWhCode,DispatchLists.cInvCode,DispatchLists.cFree1,DispatchLists.cFree2,Rdrecords.iQuantity,RdRecords.iNum,DispatchLists.iQuantity,DispatchLists.iNumFROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID = RdRecords.ID) inner join DispatchLists on dispatchlists.idlsid=rdrecords.idlsidWHERE DLID = @VouchID AND cVouchType='32' AND cBusType<>'委托代销'FOR READ ONLYElseDECLARE cur_CurrentStock CURSOR FORSELECT EnDispatchs.cWhCode,EnDispatchs.cInvCode,EnDispatchs.cFree1,EnDispatchs.cFree2,Rdrecords.iQuantity,RdRecords.iNum,EnDispatchs.iQuantity,EnDispatchs.iNumFROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID = RdRecords.ID) inner join EnDispatchs on EnDispatchs.AutoID=rdrecords.iEnsidWHERE EDID = @VouchID AND cVouchType='32'FOR READ ONLYelseDECLARE cur_CurrentStock CURSOR FORSELECT Salebillvouchs.cWhCode,Salebillvouchs.cInvCode,Salebillvouchs.cFree1,Salebillvouchs.cFree2,Rdrecords.iQuantity,RdRecords.iNum,Salebillvouchs.iQuantity,Salebillvouchs.iNumFROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID = RdRecords.ID) inner join Salebillvouchs on Salebillvouchs.autoid=rdrecords.isbsidWHERE sbvid = @VouchID AND cVouchType='32'FOR READ ONLYOPEN cur_CurrentStockFETCH NEXT FROM cur_CurrentStock INTO @cWhCode,@cInvCode,@cFree1,@cFree2,@iQuantity,@iNum,@iDispQuantity,@iDispNumWHILE @@FETCH_STATUS>=0Begin--If @VouchType='WT'--UPDATE CurrentStock SET fOutQuantity=cast(isnull(fOutQuantity,0)+@iDispQuantity as decimal(20,6)),fOutNum=cast(isnull(fOutNum,0)+@iDispNum as decimal(20,6)),--iQuantity=cast(isnull(iQuantity,0)+@iQuantity as decimal(20,6)),iNum=cast(isnull(iNum,0)+@iNum as decimal(20,6))--WHERE cWhCode = @cWhCode AND cInvCode = @cInvCode AND IsNull(cFree1,'') = IsNull(@cFree1,'') AND IsNull(cFree2,'') = IsNull(@cFree2,'')--ElseIf @iDispQuantity>0UPDATE CurrentStock SET fOutQuantity=cast(isnull(fOutQuantity,0)+@iDispQuantity as decimal(20,6)),fOutNum=cast(isnull(fOutNum,0)+@iDispNum as decimal(20,6)),iQuantity=cast(isnull(iQuantity,0)+@iQuantity as decimal(20,6)),iNum=cast(isnull(iNum,0)+@iNum as decimal(20,6))WHERE cWhCode = @cWhCode AND cInvCode = @cInvCode AND IsNull(cFree1,'') = IsNull(@cFree1,'') AND IsNull(cFree2,'') = IsNull(@cFree2,'')Else UPDATE CurrentStock SET fInQuantity=cast(isnull(fInQuantity,0)+Abs(@iDispQuantity) as decimal(20,6)),fInNum=cast(isnull(fInNum,0)+Abs(@iDispNum) as decimal(20,6)),iQuantity=cast(isnull(iQuantity,0)-Abs(@iQuantity) as decimal(20,6)),iNum=cast(isnull(iNum,0)-Abs(@iNum) as decimal(20,6))WHERE cWhCode = @cWhCode AND cInvCode = @cInvCode AND IsNull(cFree1,'') = IsNull(@cFree1,'') AND IsNull(cFree2,'') = IsNull(@cFree2,'')If @@Error<>0BeginSELECT 0 AS iRet,'修改现存量错!' AS InfoReturnEndFETCH NEXT FROM cur_CurrentStock INTO @cWhCode,@cInvCode,@cFree1,@cFree2,@iQuantity,@iNum,@iDispQuantity,@iDispNumEndCLOSE cur_CurrentStockDEALLOCATE cur_CurrentStockif @VouchType='FHD' OR @VouchType='WT'if @VouchType='FHD'DELETE FROM RdRecords WHERE IsNull(iEnsID,0)=0 And iDLsID IN (SELECT iDLsID FROM DispatchLists WHERE DLID=@VouchID)ElseDELETE FROM RdRecords WHERE IsNull(iEnsID,0)<>0 And iEnsID IN (SELECT AutoID FROM EnDispatchs WHERE EDID=@VouchID)elseDELETE FROM RdRecords WHERE iSBsid IN (SELECT autoid FROM salebillvouchs WHERE sbvid=@VouchID)If @@Error<>0BeginSELECT 0 AS iRet,'删除出库单表体记录错!' AS InfoReturnEnd--if @VouchType='FHD'delete from rdrecord where id in (select rdrecord.id from rdrecord left join rdrecords on rdrecord.id=rdrecords.id where rdrecords.id is null)--else--DELETE FROM RdRecord WHERE cBillCode = @VouchID AND cVouchType='32'If @@Error<>0BeginSELECT 0 AS iRet,'删除出库单表头记录错!' AS InfoReturnEnd--End --Else--Begin--SELECT 0 AS iRet,'号发货单对应的红字出库单已经指定货位,不能弃审!' AS Info--Return--Endif @VouchType='FHD' OR @VouchType='WT'if @VouchType='FHD'UPDATE DispatchList SET cSaleOut='' WHERE DLID=@VouchIDElseUPDATE EnDispatch SET cSaleOut='' WHERE EDID=@VouchIDelseUPDATE Salebillvouch SET cSaleOut='' WHERE SBVID=@VouchIDIf @@Error<>0BeginSELECT 0 AS iRet,'修改发货单错!' AS InfoReturnEndSELECT 1 AS iRet,'' As InfoReturn
www.kuaiji66.com 天龙瑞德