金蝶KIS旗舰版业务单据保存时提示插入重复键?

【问题描述】

业务单据(出入库单据,如销售出库、外购入库等)保存的时候提示“单据未能正确保存,原因如下:插入重复键值”?

【场景介绍】

业务单据不能正常保存。提示“插入重复键值”。

【解决方案】

该问题有两种情况:

情况一:因为单据体存在脏数据,存在有单据体,没有单据头的情况,导致单据体被异常占用,无法新增单据,请用以下语句进行检测:

–库存类单据(出库类单据+入库类单据)

select * from icstockbillentry where finterid not in (select finterid from icstokcbill)

–销售订单

select * from seorderentry where finterid not in (select finterid from seorder)

–采购订单

select * from poorderentry where finterid not in (select finterid from poorder)

–销售发票

select * from icsaleentry where finterid not in (select finterid from icsale)

–采购发票

select * from icpurchaseentry where finterid not in (select finterid from icpurchase)

如果查询出来数据,则代表有上述的情况需要进行修复,需要将这部分异常的单据体进行删除,修复语句如下:

–库存类单据(出库类单据+入库类单据)

delete from icstockbillentry where finterid not in (select finterid from icstokcbill)

–销售订单

delete from seorderentry where finterid not in (select finterid from seorder)

–采购订单

delete from poorderentry where finterid not in (select finterid from poorder)

–销售发票

delete from icsaleentry where finterid not in (select finterid from icsale)

–采购发票

delete from icpurchaseentry where finterid not in (select finterid from icpurchase)

情况二:单据中的最大内码在已有单据中已存在,导致新增内码失败,无法保存新增单据,请用以下语句进行检测,如果第一行查出的数小于第二行查出的数,则证明有问题:

–出入库单据

select max(finterid) from icstockbill 

select * from icmaxnum where ftablename=’icstockbill’

–销售订单

select max(finterid) from seorder 

select * from icmaxnum where ftablename=’seorder’

–采购订单

select max(finterid) from poorder 

select * from icmaxnum where ftablename=’poorder’

–销售发票

select max(finterid) from icsale 

select * from icmaxnum where ftablename=’icsale’

–采购发票

select max(finterid) from icpurchase 

select * from icmaxnum where ftablename=’icpurchase’

修改方案(需执行对应单据的语句):

–出入库单据

update icmaxnum set fmaxnum=(select max(finterid) from icstockbill)+1 where ftablename=’icstockbill’

–销售订单

update icmaxnum set fmaxnum=(select max(finterid) from seorder)+1 where ftablename=’seorder’

–采购订单

update icmaxnum set fmaxnum=(select max(finterid) from poorder)+1 where ftablename=’poorder’

–销售发票

update icmaxnum set fmaxnum=(select max(finterid) from icsale)+1 where ftablename=’icsale’

–采购发票

update icmaxnum set fmaxnum=(select max(finterid) from icpurchase)+1 where ftablename=’icpurchase’

【注意事项】

正式账套执行脚本前请先做好备份,建议待在测试账套中核实无误后再在正式账套中执行。

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注