作者:admin????發布時間:2020-04-19 15:56 ????瀏覽次數 :
科目掛核算項目的業務在總帳與基礎資料部分涉及的范圍比較廣, 如果對應此部分的后臺數據發生錯亂,則會導致軟件無法正常進行,下面對常見報錯進行了匯總,用戶可以在學習完基礎數據結構與邏輯的基礎上自行進行分析與處理,從而解決問題。
1、科目設置了核算項目,在憑證錄入時不提示需要輸入核算
2、科目設置了核算項目,在憑證查詢時,看不到核算項目信息
3、在科目余額表中無法查看核算項目明細,但未過賬前在包括未過賬憑證時可以正常顯示
4、無法結轉損益,提示分錄缺少核算項目
5、憑證無法過賬,提示分錄缺少核算項目
6、賬薄查詢時,提示 F3001 列無效
7、憑證過賬時提示:在結果列中多次出現列名 F1
8、應收應付系統初始化轉余額到總賬失敗
9、其他憑證模板如自動轉賬、各類型的單據模板等生成憑證失敗
10、修改核算項目明細時,提示定義的應用程序或對象錯誤
11、單據錄入時 F7 無法調出客戶或者供應商
12、科目余額表有部分供應商顯示兩行數據,正確數據為這兩行數據之和,供應商編碼相同上述錯誤,都是因為與 Fdetailid 值相關的記錄不正確造成的。比照數據邏輯進行處理。另外,即使同樣的報錯,執行處理的語句也會因不同帳套或不同期間而略有不同,請一定在理解基礎數據結構與邏輯的基礎上進行處理。
基礎數據結構與邏輯
1.核算項目類別
增加一核算項目類別,一般先在 t_itemclass 中生成記錄,如果新生成的核算項目類別有具體的屬性則會繼續在 t_itempropdesc 中生成記錄,同時在對應的 t_itemclass 中的 Fsqltablename中會為對應的類別生成一個具體的數據表來記錄它的專有屬性。 例如: 新增一個核算項目類別“銀行” ,包括的屬性有銀行的代碼、名稱、地址、區域。如下圖:
則 t_itemclass 表中會發生如下變化:
注:Fitemclassid(核算項目類別內碼) 。代表不同的核算項目類別,1 為客戶,2 為部門,3為職員,4 為物料,5 為倉庫,6 為備注,7 為計量單位,8 為供應商,9 為現金流量項目…如果是自定義的核算項目,一般 Fitemclassid 字段的值都比較大,一般均在 3001 以后。t_itemclass 是保存核算項目類別的一些共有屬性的,如 Fnumber 代表核算項目類別的代碼,Fname 代表名稱,另外有一個 FsqlTableName 字段,它表示每個核算項目對應的詳細情況表名稱,由圖可見銀行類對應的核算項目詳細情況表為 T_item_3001,這個稍后作介紹。
由于我們還定義了銀行類的一些專有屬性,所以在 t_itempropdesc 中會有如下變化:
t_itempropdesc 表是通過 Fitemclassid 與 T_itemclass 聯系的,這里對應 Fitemclassid 為 3001的共有 4 條記錄,就是我們剛才定義的銀行類的專有屬性,其中字段 fsqlcolumnname 為四個屬性分別在核算項目詳情表 T_item_3001 對應的字段。
2.核算項目
具體的核算項目是保存在表 t_item 中的,若核算項目類還有專有屬性,則其專有信息保存在 t_itemclasss 中 FsqlTableName 對應的表中。在核算項目類銀行下新增一核算項目明細,如圖:
此時,在 t_item 表中會增加一條明細,如下圖第 64 條記錄:
同時在保存該核算項目詳細情況的表中會增加以下一條記錄:
以上兩表是通過 fitemid(核算項目內碼)進行關聯的。
3.核算項目橫縱表
核算項目橫表:涉及的表為 t_ItemDetail,此表是聯接各個核算項目業務表的紐帶,如科目表,憑證表,余額表等等都與此表有很大的聯系。核 算 項 目 縱 表 為 t_ItemDetailV , 此 表 是 由 核 算 項 目 橫 表 來 生 成 的 , 可 以 用SP_CleanItemDetailV 這個存儲過程來生成 。是核算項目橫表另一種形式的表現。在平時的各種報表計算時,程序是直接關聯的該表。下面我們以一實例來說明核算項目橫縱表是如何來管理核算項目的:在科目應收賬款下掛客戶的核算項目類別,則在 t_itemdetail 中會出現如下記錄:
其中 fdetailid 為核算項目組合內碼,fdetailcount 代表核算項目組合數目,后面的以 F 開頭的類分別代表該組合的具體內容, 上圖中的 fdetailid=1 的記錄就代表某一科目下掛一個核算項目類,該類為客戶,其中 F 后面的數字具體代表什么類別是根據 t_itemclass 中核算項目類別對應的 fitemclassid 來決定的。如下圖:
t_itemclass 與 t_itemdetail,t_itemdetailv 的關系:
同時我們也會看到科目表 t_account 中關于應收賬款的記錄作了如下變化:
t_account 中應收賬款對應的 fdetailid 字段由未掛核算項目前的 0 變為了 1,也就是說進行了核算項目管理的科目的具體情況, 都可以通過該表中的這個字段來表示, 該字段與核算項目橫表是一一對應的。
如果我們在錄入憑證的時候選擇了科目下的具體核算項目,如圖:
其中 f1 下面的 64 代表核算項目 t_item 表中 fitemid 為 64 的核算項目, 即我們在憑證錄入時候選擇的核算項目。
該憑證在憑證分錄表中保存信息如下:
當該憑證過帳時,科目余額表中也會保存不同幣別的兩條相應的記錄:
也就是說對于核算項目橫表中 FX 列對應的不是 0 或者-1 的 fdetailid 會在憑證表與科目表中
被引用,對于-1 的則被科目表所引用。
以下 Fdetailid 只能為科目屬性值使用,即只能出現在 t_account 表中:
select * from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
以下 Fdetailid 只能出現在各余額表、憑證分錄表中:
select *from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv where fitemid<>-1)
另外:在 t_itemdetail 中有一條 fdetail 為 0 的記錄,這條記錄是系統預設的,不能丟失,
丟失了要手工參照標準帳套補入,否則會導致無法過帳,不能正常查看帳簿等問題。此外還
不允許在 Fx 列中出現 NULL 值。如果出現 Null 值,一般都是該表的約束或默認值值丟失,
需要更正:
update t_itemdetail set F3003=0 where F3003 is null
ALTER TABLE t_ItemDetail ALTER column F3003 int NOT NULL
綜上,核算項目橫縱表與各數據表之間的關系可以通過下圖來表示:
案例
1. 修改客戶的核算項目明細時報“定義的應用程序或對象錯誤” ,或錄入單據時候 F7 調不
出數據:
這種情況很有可能是保存客戶詳細記錄的表 t_Organization 中記錄丟失,可在查詢分析
器中執行如下語句補入:
insert into t_Organization(Fitemid,Fnumber,Fparentid,Fshortnumber)
select Fitemid,Fnumber,Fparentid,Fshortnumber
from t_item
where fitemclassid=1 and fdetail=1
and fitemid not in (select fitemid from t_Organization)
update t_Organization set Fregionid=0,ftrade=0,Fvalueaddrate=0,Fsaleid=0
where fitemid in (select fitemid from t_item where fdetail=1)
update a set a.fname=b.fname
from t_Organization a join t_item b on a.fitemid=b.fitemid
同理,其他核算項目類別下的明細表記錄丟失,也可模仿此語句補入。
2. 憑證無法過賬、賬薄報表無法查詢、無法結轉損益結轉損益之后無法過帳或仍有余額,
提示:在結果列中多次出現 F1,名稱或代碼已存在等
一般是 fdetailcount 數目不對或者相同的核算項目組合出現重復,
對于錯誤的 fdetailcount,首先要執行如下語句進行更新:
exec sp_cleanitemdetailv--橫表生成縱表的存儲結構
update a set a.fdetailcount=b.Fcount
from t_itemdetail a join
(select Fdetailid,count(Fitemid) Fcount
from t_itemdetailv
where fitemid<>0 group by Fdetailid) b
on a.fdetailid=b.fdetailid--更新 fdetailcount
exec sp_cleanitemdetailv--重新生成縱表
作了以上更新后發現表中還存在相同組合的重復記錄,這是不允許的:
圖中 f2=-1 的記錄一共有兩條,對應的 fdetailid 分別為 8,224,其在科目表 t_account
引用狀況如下:
而我們只需要保留一個 fdetailid 即可,此時我們取最小的 fdetailid,執行如下語句更新
科目表:
update t_account
set Fdetailid =(select min(fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F2=-1 )
where Fdetailid in (select (fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F2=-1 )
執行之后科目表更新為以下狀況:
同時我們還要刪除核算項目橫表中的多余記錄,執行如下語句:
delete from t_itemdetail
where Fdetailid in(select (fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F2=-1 )
and Fdetailid <>(select min(fdetailid) from t_itemdetail
where fdetailid in (select Fdetailid from t_itemdetailv
where fitemid=-1)
and Fdetailcount=1 and F2=-1 )
exec sp_cleanitemdetailv--重新生成縱表
執行之后核算項目橫表 itemdetail 中多余的 fdetailid=224 的記錄被刪除
另外還要查看各余額表中有沒有非法的 fdetailid,即不在核算項目橫縱表中的,有的話
則需要刪除:
--查找科目余額表中有沒有非法的 fdetailid
select * from t_balance
where fdetailid not in (select fdetailid from t_itemdetail)
--刪除科目余額表中非法的 fdetailid
delete from t_balance
where fdetailid not in (select fdetailid from t_itemdetail)
同理進行以下操作
查找數量余額表中有沒有非法的 fdetailid
select * from t_quantitybalance
where fdetailid not in (select fdetailid from t_itemdetail)
刪除數量余額表中非法的 fdetailid
delete from t_quantitybalance
where fdetailid not in (select fdetailid from t_itemdetail)
查找損益類科目實際發生額表中有沒有非法的 fdetailid
select * from t_profitandloss
where fdetailid not in (select fdetailid from t_itemdetail)
刪除損益類科目實際發生額表中有沒有非法的 fdetailid
delete from t_profitandloss
where fdetailid not in (select fdetailid from t_itemdetail)
3. 查詢賬薄時提示列名 ‘f3001’ 無效出現如上報錯則需要查看 t_itemdetail 表中該對
應的列是否存在,如果不存在,應該補充執行如下語句:
If Not Exists(Select c.Name from syscolumns c,sysobjects o
where c.Id=o.Id and c.name='F3001' and o.name='t_ItemDetail')
Begin
Alter Table t_ItemDetail Add F3001 int not null default(0)
Create Index ix_ItemDetail_3001 On t_ItemDetail(F3001)
END
4. 科目余額表過濾本期,科目選擇'應付帳款',顯示核算項目,確定.
報表顯示有部分供應商顯示兩行數據,正確數據為這兩行數據之和,供應商編碼相同.例:供
應商代碼 2001.0001 這種情況一般是由于核算項目橫表中被憑證表, 余額表引用的核算項目
組合有重復記錄,如下圖:
象這種情況,需要做如下處理:
(1)創建臨時表 t_itemdetail_error,把重復核算項目記錄插入該表
select a.*, a.fdetailid Fdetailid_temp
into t_itemdetail_error
from t_itemdetail a join t_itemdetail b on a.f8=b.f8 and
a.fdetailcount=b.fdetailcount
where a.fdetailcount=1 and a.fdetailid<>b.fdetailid
and a.f8>0
order by a.f8
(2) 在臨時表 t_itemdetail_error 中修改錯誤的 fdetailid 值 (以最小的 fdetailid 值為
基準) :
update b set b.fdetailid_temp=a.fdetailid
from t_itemdetail_error a join t_itemdetail_error b on a.f8=b.f8 and
a.fdetailcount=b.fdetailcount
where a.fdetailcount=1 and a.fdetailid
and a.f8>0
(3)創建余額表臨時表 t_balance_temp :
select * into t_balance_temp from t_balance
order by fyear,fperiod,faccountid,fdetailid,fcurrencyid
(4)更新余額表臨時表的錯誤 detailid 值:
update a set a.fdetailid=b.fdetailid_temp
from t_balance_temp a join t_itemdetail_error b on a.fdetailid=b.fdetailid
(5)創建臨時表 temp002:
select top 0 * into temp002 from t_balance
(6)合并 t_balance_temp 相同核算項目項的金額,把結果插入 temp002:
insert into temp002
(fyear,fperiod,faccountid,fdetailid,fcurrencyid,FFrameWorkID,
FBeginBalanceFor,FDebitFor,FCreditFor,FYtdDebitFor,FYtdCreditFor,FEndBalanc
eFor,
FBeginBalance,FDebit,FCredit,FYtdDebit,FYtdCredit,FEndBalance)
select fyear,fperiod,faccountid,fdetailid,fcurrencyid,FFrameWorkID,
sum(FBeginBalanceFor)FBeginBalanceFor,sum(FDebitFor)FDebitFor,sum(FCreditFor)FC
reditFor,
sum(FYtdDebitFor)FYtdDebitFor,sum(FYtdCreditFor)FYtdCreditFor,sum(FEndBalanceFo
r)FEndBalanceFor,
sum(FBeginBalance)FBeginBalance,sum(FDebit)FDebit,sum(FCredit)FCredit,sum(FYtdD
ebit)FYtdDebit,
sum(FYtdCredit)FYtdCredit,sum(FEndBalance)FEndBalance
from t_balance_temp
group by fyear,fperiod,faccountid,fdetailid,fcurrencyid,FFrameWorkID
(7)清空 t_balance 數據 :
delete from t_balance
(8)把 temp002 的值寫回 t_balance:
insert into t_balance
(fyear,fperiod,faccountid,fdetailid,fcurrencyid,FBeginBalanceFor,FDebitFor,FCre
ditFor,FYtdDebitFor,
FYtdCreditFor,FEndBalanceFor,FBeginBalance,FDebit,FCredit,FYtdDebit,FYtdCredit,
FEndBalance,FFrameWorkID)
select
fyear,fperiod,faccountid,fdetailid,fcurrencyid,FBeginBalanceFor,FDebitFor,FCred
itFor,FYtdDebitFor,
FYtdCreditFor,FEndBalanceFor,FBeginBalance,FDebit,FCredit,FYtdDebit,FYtdCredit,
FEndBalance,FFrameWorkID
from temp002
(9)刪除 t_itemdetail 中的重復值:
delete from t_itemdetail
where fdetailid in (select fdetailid from t_itemdetail_error)
and fdetailid not in (select fdetailid_temp from t_itemdetail_error)
(10)更新縱表:
exec sp_cleanitemdetailv
(11)更正憑證分錄數據:
update a set a.fdetailid=b.fdetailid_temp
from t_voucherentry a join t_itemdetail_error b on a.fdetailid=b.fdetailid
where a.fdetailid<>b.fdetailid_temp
總結
一般的處理 Fdetailid 相關信息的邏輯順序為:
1、查詢被科目使用的核算項目使用詳情信息
2、查詢、更正核算項目使用詳情組合個數
3、根據實際情況,更正科目表(或憑證表,余額表)中的 Fdetailid 和刪除 t_itemdetail
表中的重復記錄
4、補充檢查出來的賬套中預設的 0 記錄(一般情況下不會有)
5、反結賬到到出現問題的期間,建議同時將反結賬后期間的憑證反過賬;
6、刪除三個余額表中的錯誤 Fdetailid 記錄
7、如果結轉損益的憑證數據有誤,建議刪除
8、更正和補充其他相關數據(如補充 t_itemdetail 表中丟失的列等)
9、數據修正完后,憑證重新過賬,重新結轉損益過賬,再結賬到當前期間。