金蝶核算项目常见问题及数据结构分析.docx
《金蝶核算项目常见问题及数据结构分析.docx》由会员分享,可在线阅读,更多相关《金蝶核算项目常见问题及数据结构分析.docx(15页珍藏版)》请在冰豆网上搜索。
金蝶核算项目常见问题及数据结构分析
金蝶核算项目常见问题及数据结构分析
科目挂核算项目的业务在总帐与基础资料部分涉及的范围比较广,如果对应此部分的后台数据发生错乱,则会导致软件无法正常进行,下面对常见报错进行了汇总,用户可以在学习完基础数据结构与逻辑的基础上自行进行分析与处理,从而解决问题。
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*fromt_itemdetail
wherefdetailidin(selectFdetailidfromt_itemdetailv
wherefitemid=-1)
以下Fdetailid只能出现在各余额表、凭证分录表中:
select*fromt_itemdetail
wherefdetailidin(selectFdetailidfromt_itemdetailvwherefitemid<>-1)
另外:
在t_itemdetail中有一条fdetail为0的记录,这条记录是系统预设的,不能丢失,
丢失了要手工参照标准帐套补入,否则会导致无法过帐,不能正常查看帐簿等问题。
此外还
不允许在Fx列中出现NULL值。
如果出现Null值,一般都是该表的约束或默认值值丢失,
需要更正:
updatet_itemdetailsetF3003=0whereF3003isnull
ALTERTABLEt_ItemDetailALTERcolumnF3003intNOTNULL
综上,核算项目横纵表与各数据表之间的关系可以通过下图来表示:
案例
1.修改客户的核算项目明细时报“定义的应用程序或对象错误”,或录入单据时候F7调不
出数据:
这种情况很有可能是保存客户详细记录的表t_Organization中记录丢失,可在查询分析
器中执行如下语句补入:
insertintot_Organization(Fitemid,Fnumber,Fparentid,Fshortnumber)
selectFitemid,Fnumber,Fparentid,Fshortnumber
fromt_item
wherefitemclassid=1andfdetail=1
andfitemidnotin(selectfitemidfromt_Organization)
updatet_OrganizationsetFregionid=0,ftrade=0,Fvalueaddrate=0,Fsaleid=0
wherefitemidin(selectfitemidfromt_itemwherefdetail=1)
updateaseta.fname=b.fname
fromt_Organizationajoint_itembona.fitemid=b.fitemid
同理,其他核算项目类别下的明细表记录丢失,也可模仿此语句补入。
2.凭证无法过账、账薄报表无法查询、无法结转损益结转损益之后无法过帐或仍有余额,
提示:
在结果列中多次出现F1,名称或代码已存在等
一般是fdetailcount数目不对或者相同的核算项目组合出现重
复,
对于错误的fdetailcount,首先要执行如下语句进行更新:
execsp_cleanitemdetailv--横表生成纵表的存储结构
updateaseta.fdetailcount=b.Fcount
fromt_itemdetailajoin
(selectFdetailid,count(Fitemid)Fcount
fromt_itemdetailv
wherefitemid<>0groupbyFdetailid)b
ona.fdetailid=b.fdetailid--更新fdetailcount
execsp_cleanitemdetailv--重新生成纵表
作了以上更新后发现表中还存在相同组合的重复记录,这是不允许的:
图中f2=-1的记录一共有两条,对应的fdetailid分别为8,224,其在科目表t_account
引用状况如下:
而我们只需要保留一个fdetailid即可,此时我们取最小的fdetailid,执行如下语句更新
科目表:
updatet_account
setFdetailid=(selectmin(fdetailid)fromt_itemdetail
wherefdetailidin(selectFdetailidfromt_itemdetailv
wherefitemid=-1)
andFdetailcount=1andF2=-1)
whereFdetailidin(select(fdetailid)fromt_itemdetail
wherefdetailidin(selectFdetailidfromt_itemdetailv
wherefitemid=-1)
andFdetailcount=1andF2=-1)
执行之后科目表更新为以下状况:
同时我们还要删除核算项目横表中的多余记录,执行如下语句:
deletefromt_itemdetail
whereFdetailidin(select(fdetailid)fromt_itemdetail
wherefdetailidin(selectFdetailidfromt_itemdetailv
wherefitemid=-1)
andFdetailcount=1andF2=-1)
andFdetailid<>(selectmin(fdetailid)fromt_itemdetail
wherefdetailidin(selectFdetailidfromt_itemdetailv
wherefitemid=-1)
andFdetailcount=1andF2=-1)
execsp_cleanitemdetailv--重新生成纵表
执行之后核算项目横表itemdetail中多余的fdetailid=224的记录被删除
另外还要查看各余额表中有没有非法的fdetailid,即不在核算项目横纵表中的,有的话
则需要删除:
--查找科目余额表中有没有非法的fdetailid
select*fromt_balance
wherefdetailidnotin(selectfdetailidfromt_itemdetail)
--删除科目余额表中非法的fdetailid
deletefromt_balance
wherefdetailidnotin(selectfdetailidfromt_itemdetail)
同理进行以下操作
查找数量余额表中有没有非法的fdetailid
select*fromt_quantitybalance
wherefdetailidnotin(selectfdetailidfromt_itemdetail)
删除数量余额表中非法的fdetailid
deletefromt_quantitybalance
wherefdetailidnotin(selectfdetailidfromt_itemdetail)
查找损益类科目实际发生额表中有没有非法的fdetailid
select*fromt_profitandloss
wherefdetailidnotin(selectfdetailidfromt_itemdetail)
删除损益类科目实际发生额表中有没有非法的fdetailid
deletefromt_profitandloss
wherefdetailidnotin(selectfdetailidfromt_itemdetail)
3.查询账薄时提示列名‘f3001’无效出现如上报错则需要查看t_itemdetail表中该对
应的列是否存在,如果不存在,应该补充执行如下语句:
IfNotExists(Selectc.Namefromsyscolumnsc,sysobjectso
wherec.Id=o.Idandc.name='F3001'ando.name='t_ItemDetail')
Begin
AlterTablet_ItemDetailAddF3001intnotnulldefault(0)
CreateIndexix_ItemDetail_3001Ont_ItemDetail(F3001)
END
4.科目余额表过滤本期,科目选择'应付帐款',显示核算项目,确定.
报表显示有部分供应商显示两行数据,正确数据为这两行数据之和,供应商编码相同.例:
供
应商代码2001.0001这种情况一般是由于核算项目横表中被凭证表,余额表引用的核算项目
组合有重复记录,如下图:
象这种情况,需要做如下处理:
(1)创建临时表t_itemdetail_error,把重复核算项目记录插入该表
selecta.*,a.fdetailidFdetailid_temp
intot_itemdetail_error
fromt_itemdetailajoint_itemdetailbona.f8=b.f8and
a.fdetailcount=b.fdetailcount
wherea.fdetailcount=1anda.fdetailid<>b.fdetailid
anda.f8>0
orderbya.f8
(2)在临时表t_itemdetail_error中修改错误的fdetailid值(以最小的fdetailid值为
基准):
updatebsetb.fdetailid_temp=a.fdetailid
fromt_itemdetail_errorajoint_itemdetail_errorbona.f8=b.f8and
a.fdetailcount=b.fdetailcount
wherea.fdetailcount=1anda.fdetailid
anda.f8>0
(3)创建余额表临时表t_balance_temp:
select*intot_balance_tempfromt_balance
orderbyfyear,fperiod,faccountid,fdetailid,fcurrencyid
(4)更新余额表临时表的错误detailid值:
updateaseta.fdetailid=b.fdetailid_temp
fromt_balance_tempajoint_itemdetail_errorbona.fdetailid=b.fdetailid
(5)创建临时表temp002:
selecttop0*intotemp002fromt_balance
(6)合并t_balance_temp相同核算项目项的金额,把结果插入temp002:
insertintotemp002
(fyear,fperiod,faccountid,fdetailid,fcurrencyid,FFrameWorkID,
FBeginBalanceFor,FDebitFor,FCreditFor,FYtdDebitFor,FYtdCreditFor,FEndBalanc
eFor,
FBeginBalance,FDebit,FCredit,FYtdDebit,FYtdCredit,FEndBalance)
selectfyear,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
fromt_balance_temp
groupbyfyear,fperiod,faccountid,fdetailid,fcurrencyid,FFrameWorkID
(7)清空t_balance数据:
deletefromt_balance
(8)把temp002的值写回t_balance:
insertintot_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
fromtemp002
(9)删除t_itemdetail中的重复值:
deletefromt_itemdetail
wherefdetailidin(selectfdetailidfromt_itemdetail_error)
andfdetailidnotin(selectfdetailid_tempfromt_itemdetail_error)
(10)更新纵表:
execsp_cleanitemdetailv
(11)更正凭证分录数据:
updateaseta.fdetailid=b.fdetailid_temp
fromt_voucherentryajoint_itemdetail_errorbona.fdetailid=b.fdetailid
wherea.fdetailid<>b.fdetailid_temp
总结
一般的处理Fdetailid相关信息的逻辑顺序为:
1、查询被科目使用的核算项目使用详情信息
2、查询、更正核算项目使用详情组合个数
3、根据实际情况,更正科目表(或凭证表,余额表)中的Fdetailid和删除t_itemdetail
表中的重复记录
4、补充检查出来的账套中预设的0记录(一般情况下不会有)
5、反结账到到出现问题的期间,建议同时将反结账后期间的凭证反过账;
6、删除三个余额表中的错误Fdetailid记录
7、如果结转损益的凭证数据有误,建议删除
8、更正和补充其他相关数据(如补充t_itemdetail表中丢失的列等)
9、数据修正完后,凭证重新过账,重新结转损益过账,再结账到当前期间。