应收单的收款计划为空如何数据库批量补入 sql语句
很多期初导入的单据,由于没有维护好,收款计划为空,导致后边去核销的时候会出现报错。下边脚本可以参考如何批量补入收款计划为空的单据(前提条件是:收付款条件为空或者按到期日收付款的付款方式)。
应收单: 1、查询异常的单据有多少张 select count(1) from T_AR_RECEIVABLE a left join T_AR_RECEIVABLEPLAN b on a.fid=b.fid WHERE A.fallamountfor<>0 AND A.fdocumentstatus='C' AND B.fpayamountfor IS NULL 2、查询应收单收款计划的当前种子 SELECT IDENT_CURRENT('z_AR_RECEIVABLEPLAN') ---100000 3、强制标识值从某值开始,如 100000 -- 当前种子值+异常的单据数量(例如5) DBCC CHECKIDENT (z_AR_RECEIVABLEPLAN, RESEED, 100000+5) 4、插入数据到收款计划(100000替换未第一步查询的数量) INSERT INTO T_AR_RECEIVABLEPLAN (FID,FENTRYID,FSEQ,FENDDATE,FPAYRATE,FPAYAMOUNTFOR,FPAYAMOUNT,FWRITTENOFFSTATUS,FWRITTENOFFAMOUNTFOR,FWRITTENOFFAMOUNT,FNOTWRITTENOFFAMOUNTFOR,FRELATEHADPAYAMOUNT,fnotverificateamount ) select A.FID,100000+ROW_NUMBER() OVER(ORDER BY A.FID) FENTRYID,1 FSEQ,A.FENDDATE FENDDATE,100 FPAYRATE,A.FALLAMOUNTFOR FPAYAMOUNTFOR,C.FALLAMOUNT FPAYAMOUNT,'A' FWRITTENOFFSTATUS,0 FWRITTENOFFAMOUNTFOR, 0 FWRITTENOFFAMOUNT,A.FALLAMOUNTFOR FNOTWRITTENOFFAMOUNTFOR ,0 FRELATEHADPAYAMOUNT ,A.FALLAMOUNTFOR fnotverificateamount from T_AR_RECEIVABLE a left join T_AR_RECEIVABLEPLAN b on a.fid=b.fid LEFT JOIN T_AR_RECEIVABLEFIN C ON A.FID=C.FID WHERE A.fallamountfor<>0 AND A.fdocumentstatus='C' AND B.fpayamountfor IS NULL 应付单同理: select count(1) from t_ap_payable a left join t_ap_payableplan b on a.fid=b.fid WHERE A.fallamountfor<>0 AND A.fdocumentstatus='C' AND B.fpayamountfor IS NULL SELECT IDENT_CURRENT('z_ap_payableplan') ---107648 DBCC CHECKIDENT (z_ap_payableplan, RESEED, 107683) INSERT INTO t_ap_payableplan (FID,FENTRYID,FSEQ,FENDDATE,FPAYRATE,FPAYAMOUNTFOR,FPAYAMOUNT,FWRITTENOFFSTATUS,FWRITTENOFFAMOUNTFOR,FWRITTENOFFAMOUNT,FNOTWRITTENOFFAMOUNTFOR,FRELATEHADPAYAMOUNT,fnotverificateamount ) select A.FID,107648+ROW_NUMBER() OVER(ORDER BY A.FID) FENTRYID,1 FSEQ,A.FENDDATE FENDDATE,100 FPAYRATE,A.FALLAMOUNTFOR FPAYAMOUNTFOR,C.FALLAMOUNT FPAYAMOUNT,'A' FWRITTENOFFSTATUS,0 FWRITTENOFFAMOUNTFOR, 0 FWRITTENOFFAMOUNT,A.FALLAMOUNTFOR FNOTWRITTENOFFAMOUNTFOR ,0 FRELATEHADPAYAMOUNT ,A.FALLAMOUNTFOR fnotverificateamount from t_ap_payable a left join t_ap_payableplan b on a.fid=b.fid LEFT JOIN t_ap_payablefin C ON A.FID=C.FID WHERE A.fallamountfor<>0 AND A.fdocumentstatus='C' AND B.fpayamountfor IS NULL
点赞ing~
厉害
应收单的收款计划为空如何数据库批量补入 sql语句
很多期初导入的单据,由于没有维护好,收款计划为空,导致后边去核销的时候会出现报错。下边脚本可以参考如何批量补入收款计划为空的单据(...
点击下载文档
上一篇:并发编程之定时任务&定时线程池下一篇:论坛学习,存货核算,开启成本之路
本文2024-09-16 17:37:09发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-16864.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章