問(wèn)題已解決

金蝶云星空 科目余額表里核算維度一樣 但是不能合并的問(wèn)題

84784959| 提問(wèn)時(shí)間:2022 11/18 09:43
溫馨提示:如果以上題目與您遇到的情況不符,可直接提問(wèn),隨時(shí)問(wèn)隨時(shí)答
速問(wèn)速答
玲老師
金牌答疑老師
職稱(chēng):會(huì)計(jì)師
你好?? 本腳本修復(fù)以下數(shù)據(jù)問(wèn)題: 核算維度V表存在核算維度組合相同但FID不同的記錄,導(dǎo)致科目余額表等報(bào)表核算維度有相同的記錄不合并的問(wèn)題 注意事項(xiàng): 1,備份正式賬套,并恢復(fù)成測(cè)試賬套 2,在測(cè)試賬套上執(zhí)行修復(fù)操作,檢查數(shù)據(jù)修復(fù)成功,且憑證、科目余額表等數(shù)據(jù)正確后再在正式賬套上執(zhí)行 3,查看未過(guò)賬余額數(shù)據(jù)時(shí)需要在憑證查詢的菜單中執(zhí)行“刷新未過(guò)賬余額表” 按以下步驟執(zhí)行: 0,修改腳本中的日期(2017-09-01)為發(fā)現(xiàn)問(wèn)題的期間的第一天(腳本只處理此日期及以后的憑證,大大節(jié)省時(shí)間) 1,所有賬簿反結(jié)賬反過(guò)賬到發(fā)現(xiàn)問(wèn)題前一個(gè)期間。 2,執(zhí)行腳本以修復(fù)總賬憑證及業(yè)務(wù)憑證表的數(shù)據(jù)。 3,重新過(guò)賬以修復(fù)科目余額表、數(shù)據(jù)余額表以及損益余額表的數(shù)據(jù) 4,檢查數(shù)據(jù)修復(fù)情況。 */ DECLARE @glvid int,@bizvid int; SELECT @glvid = MIN(FVOUCHERID) FROM T_GL_Voucher WHERE FCREATEDATE>=2017-09-01; SELECT @bizvid = MIN(FVOUCHERID) FROM T_BAS_Voucher WHERE FCREATEDATE>=2017-09-01; --備份指定日期以后通過(guò)憑證生成新產(chǎn)生的憑證分錄數(shù)據(jù)及核算維度V表 IF NOT EXISTS (SELECT * FROM SYSOBJECTS WHERE ID = OBJECT_ID(NT_GL_VOUCHERENTRY_20180101) AND OBJECTPROPERTY(ID, NISUSERTABLE) = 1) SELECT * INTO T_GL_VOUCHERENTRY_20180101 FROM T_GL_VOUCHERENTRY WHERE FVOUCHERID>=@glvid ?AND FVOUCHERID IN( ? SELECT DISTINCT ? ? FVOUCHERID ? FROM ? ?T_GL_VOUCHER V ? JOIN T_BAS_BILLTYPE BT ON BT.FBILLFORMID = V.FSOURCEBILLKEY ? ); IF NOT EXISTS (SELECT * FROM SYSOBJECTS WHERE ID = OBJECT_ID(NT_BAS_VOUCHERENTRY_20180101) AND OBJECTPROPERTY(ID, NISUSERTABLE) = 1) SELECT * INTO T_BAS_VOUCHERENTRY_20180101 FROM T_BAS_VOUCHERENTRY WHERE FVOUCHERID>=@bizvid ?AND FVOUCHERID IN( ? SELECT DISTINCT ? ? FVOUCHERID ? FROM ? ?T_BAS_VOUCHER V ? JOIN T_BAS_BILLTYPE BT ON BT.FBILLFORMID = V.FSOURCEBILLKEY ? ); IF NOT EXISTS (SELECT * FROM SYSOBJECTS WHERE ID = OBJECT_ID(NT_BD_FLEXITEMDETAILV_20180101) AND OBJECTPROPERTY(ID, NISUSERTABLE) = 1) SELECT * INTO T_BD_FLEXITEMDETAILV_20180101 FROM T_BD_FLEXITEMDETAILV; --刪除唯一索引 IF EXISTS(SELECT * FROM SYSINDEXES WHERE ID=OBJECT_ID(T_BD_FLEXITEMDETAILV) AND NAME=IDX_FLEXITEMUNIQUE) DROP INDEX IDX_FLEXITEMUNIQUE ON T_BD_FLEXITEMDETAILV; --開(kāi)始批處理 BEGIN ? ?DECLARE @flexfield VARCHAR(50) , ? ? ? ?@FCALCOL VARCHAR(2000) , ? ? ? ?@flexid1 INT , ? ? ? ?@flexid2 INT; --更新輔助資料核算維度為空的值為默認(rèn)的空格 ? ?DECLARE flex_cursore CURSOR ? ?FOR ? ? ? ?( SELECT ? ?FFLEXNUMBER ? ? ? ? ?FROM ? ? ?T_BD_FLEXITEMPROPERTY ? ? ? ? ?WHERE ? ? FVALUETYPE = 1 ? ? ? ? ? ? ? ? ? ?AND FDOCUMENTSTATUS = C ? ? ? ?); ? ?OPEN flex_cursore; ? ?FETCH NEXT FROM flex_cursore INTO @flexfield; ? ?WHILE @@FETCH_STATUS = 0 ? ? ? ?BEGIN ? ? ? ? ? ?EXEC( UPDATE ?T_BD_FLEXITEMDETAILV SET + @flexfield+ = WHERE +@flexfield+ = AND LEN(+@flexfield+)<=1); ? ? ? ? ? ?FETCH NEXT FROM flex_cursore INTO @flexfield; ? ? ? ?END; ? ?CLOSE flex_cursore; ? ?DEALLOCATE flex_cursore; DECLARE @cnt INT; SELECT @cnt = COUNT(*) ? ? FROM ? ? ?( SELECT ? ?MIN(FID) fid1 , ? ? ? ? MAX(FID) fid2 , ? ? ? ? FCALCOL ? ? ? ?FROM ? ? ?T_BD_FLEXITEMDETAILV ? ? ? ?GROUP BY ?FCALCOL ? ? ?) TM ? ? WHERE ? ? fid1 <> fid2; WHILE @cnt>0 BEGIN ?--找出所有重復(fù)的核算維度,更新憑證等表中的維度組合ID為最小的那個(gè),且保留FID值最小的那個(gè),刪除此后生成的重復(fù)維度ID ?DECLARE flexid_cursore CURSOR ?FOR ? ( SELECT ? ?fid1 , ? ? ?fid2 , ? ? ?FCALCOL ? ? FROM ? ? ?( SELECT ? ?MIN(FID) fid1 , ? ? ? ? MAX(FID) fid2 , ? ? ? ? FCALCOL ? ? ? ?FROM ? ? ?T_BD_FLEXITEMDETAILV ? ? ? ?GROUP BY ?FCALCOL ? ? ?) TM ? ? WHERE ? ? fid1 <> fid2 ? ); ?OPEN flexid_cursore; ?FETCH NEXT FROM flexid_cursore INTO @flexid1, @flexid2, @FCALCOL; ?WHILE @@FETCH_STATUS = 0 ? BEGIN ? ?UPDATE ?T_GL_VOUCHERENTRY ? ?SET ? ? FDETAILID = @flexid1 ? ?WHERE ? FDETAILID = @flexid2 ? ? ?AND FVOUCHERID>=@glvid ? ? ?AND FVOUCHERID IN( ? ? ? SELECT DISTINCT ? ? ? ? FVOUCHERID ? ? ? FROM ? ?T_GL_VOUCHER V ? ? ? ? --JOIN T_BAS_BILLTYPE BT ON BT.FBILLFORMID = V.FSOURCEBILLKEY ? ? ? ); ? ?UPDATE ?T_BAS_VOUCHERENTRY ? ?SET ? ? FDETAILID = @flexid1 ? ?WHERE ? FDETAILID = @flexid2 ? ? ?AND FVOUCHERID>=@bizvid ? ? ?AND FVOUCHERID IN( ? ? ? SELECT DISTINCT ? ? ? ? FVOUCHERID ? ? ? FROM ? ?T_BAS_VOUCHER V ? ? ? ? --JOIN T_BAS_BILLTYPE BT ON BT.FBILLFORMID = V.FSOURCEBILLKEY ? ? ? ); ? ? ? ?DELETE ?T_BD_FLEXITEMDETAILV ? ?WHERE ? FID > @flexid1 ? ? ?AND FCALCOL = @FCALCOL ? ? ?AND FID NOT IN ( ? ? ? ?SELECT DISTINCT ? ? ? ? FDETAILID ? ? ? ?FROM ? T_GL_VOUCHERENTRY ? ? ? ?UNION ? ? ? ?SELECT DISTINCT ? ? ? ? FDETAILID ? ? ? ?FROM ? T_BAS_VOUCHERENTRY ); ? ?FETCH NEXT FROM flexid_cursore INTO @flexid1, @flexid2, @FCALCOL; ? END; ?CLOSE flexid_cursore; ?DEALLOCATE flexid_cursore; ?--檢查是否還存在重復(fù)的ID ?SELECT @cnt = COUNT(*) ? ? FROM ? ? ?( SELECT ? ?MIN(FID) fid1 , ? ? ? ? MAX(FID) fid2 , ? ? ? ? FCALCOL ? ? ? ?FROM ? ? ?T_BD_FLEXITEMDETAILV ? ? ? ?GROUP BY ?FCALCOL ? ? ?) TM ? ? WHERE ? ? fid1 <> fid2; END; END; GO --重新創(chuàng)建唯一索引 CREATE UNIQUE NONCLUSTERED INDEX IDX_FLEXITEMUNIQUE ON T_BD_FLEXITEMDETAILV (FCALCOL); GO
2022 11/18 09:47
84784959
2022 11/18 09:57
科目余額表相同的維度,為什么不能合并顯示?
玲老師
2022 11/18 10:05
您好,可以按照上面的方法操作。如果自己不能操作,就找一下軟件客服。
描述你的問(wèn)題,直接向老師提問(wèn)
0/400
      提交問(wèn)題

      您有一張限時(shí)會(huì)員卡待領(lǐng)取

      00:10:00

      免費(fèi)領(lǐng)取
      Hi,您好,我是基于人工智能技術(shù)的智能答疑助手,如果有什么問(wèn)題可以直接問(wèn)我呦~