问题:应付单审核报错。通过com.kingdee.eas.scm.common.AR2SIWriteBackHandler.batchWriteBackOrder(AR2SIWriteBackHandler.java:329)
可以确定是应付单审核时,反写销售订单出错。
可能原因:
1,多计量单位中有重复记录,包括主计量单位重复、计量单位重复。
可以通过数据卫士检查修复,也可以通过下面的语句查询:
---主计量单位重复
select fmaterialid,count(*) from t_bd_multimeasureunit where fisbasicunit=1 group by fmaterialid having count(*)>1
---计量单位重复
select fmaterialid,FMeasureUnitID, count(*) from t_bd_multimeasureunit group by fmaterialid, FMeasureUnitID having count(*)>1
如果没有查到记录,还有一种情况:
一张应收单的分录中有满足以下情况的数据:
有多行应收单分录的核心单据分录ID相同,且应付单分录的计量单位不完全相同,这样情况会报错。
解决办法:
导致以上问题的销售出库单的每一条分录分别生成一笔应收单,可以正常审核。
后台ksql日志:
--------------------------------------------------------------------------------------------------------
select * from t_pm_user
select f.FNUMBER, e.FSEQ, e.FSALEORDERID,e.fid, e.FSALEORDERENTRYID, e.FSALEORDERENTRYSEQ, e.FSALEORDERNUMBER
from T_IM_SALEISSUEENTRY e
inner join T_IM_SALEISSUEBILL f on f.FID = e.FPARENTID
where 1 = 1 and f.fnumber = 'XSCK-07-201506001666'
select a.fid, a.FSEQ,a.FMEASUREUNITID, a.FBASEUNITID, a.FCOREBILLENTRYID, a.FCOREBILLID, a.FCOREBILLNUMBER, a.FCOREBILLTYPEID
, f.FNUMBER, e.FSEQ, e.FSALEORDERID, e.FSALEORDERENTRYID, e.FSALEORDERENTRYSEQ, e.FSALEORDERNUMBER
, a.*
from T_AR_OTHERBILLENTRY a
inner join (SELECT FParentID, FCoreBillEntryId, FMeasureUnitID, FBaseUnitID
, SUM(FBaseQty) FBASEQTY, SUM(FQuantity) FQUANTITY, SUM(FRecievePayAmount) FRECIEVEPAYAMOUNT
from T_AR_OtherBillEntry
where (FParentID IN ('HFSeAPJhREuy4oYbnwH5yPyRDvM='))
group BY FParentID, FCoreBillEntryId, FMeasureUnitID, FBaseUnitID --having count(*) > 1
) b on a.FPARENTID = b.fparentid and a.FCOREBILLENTRYID = b. FCOREBILLENTRYID
and a.FMEASUREUNITID = b.FMEASUREUNITID and a.FBASEUNITID = b.FBASEUNITID
inner join T_IM_SALEISSUEENTRY e on e.fid = a.FSOURCEBILLENTRYID
inner join T_IM_SALEISSUEBILL f on f.FID = e.FPARENTID
where a.FCOREBILLENTRYID in ('qE9xd46WTJyuw96Qd6rhYoiIKlg=', 'jirNPjvmTa6npvx/wmOeFIiIKlg=')
order by a.FCOREBILLENTRYID asc, a.FSEQ asc
, e.FSALEORDERNUMBER, e.FSALEORDERENTRYID asc, e.FSALEORDERENTRYSEQ asc
------------------------------------------------------------------------
select FCoreBillEntryId
from (SELECT FParentID, FCoreBillEntryId, FMeasureUnitID, FBaseUnitID
, SUM(FBaseQty) FBASEQTY, SUM(FQuantity) FQUANTITY, SUM(FRecievePayAmount) FRECIEVEPAYAMOUNT
from T_AR_OtherBillEntry
where (FParentID IN ('HFSeAPJhREuy4oYbnwH5yPyRDvM='))
group BY FParentID, FCoreBillEntryId, FMeasureUnitID, FBaseUnitID --having count(*) > 1
)
where 1 = 1
group by FCoreBillEntryId having count(*) >1
---------------------------------------------------------------------------------------
--更新语句
--如果满足以上情况,
ARE on are.FCoreBillEntryId = soe.FID (更新的子查询就会返回多条记录,程序报错。)
UPD2ATE T_SD_SaleOrderEntry T1 set (FTolInvoidBaseQty, FTotalInvoicedQty, FAssociateQty, FTotalArAmount) = (
SELECT (soe.FTolInvoidBaseQty + are.FBaseQty) IBQ, CASE
when soe.FUnitID = are.FMeasureUnitID THEN (soe.FTotalInvoicedQty + are.FQuantity)
ELSE ROUND(CAST(((soe.FTolInvoidBaseQty + CAST(are.FBaseQty AS NUMBER(21, 8))) / mmu.FBaseConvsRate) AS NUMBER(21, 8)), mmu.FQtyPrecision) END QTY
, (soe.FAssociateQty - are.FBaseQty) UIQ, (soe.FTotalArAmount + are.FRecievePayAmount) INM
from T_SD_SaleOrderEntry SOE
inner JOIN (
SELECT FParentId, FMeasureUnitId, FCoreBillEntryId, sum(FBaseQty) FBASEQTY, sum(FQuantity) FQUANTITY, sum(FRecievePayAmount) FRECIEVEPAYAMOUNT from (
SELECT FParentID, FCoreBillEntryId, FMeasureUnitID, FBaseUnitID, SUM(FBaseQty) FBASEQTY, SUM(FQuantity) FQUANTITY, SUM(FRecievePayAmount) FRECIEVEPAYAMOUNT
from T_AR_OtherBillEntry
where (FParentID IN ('HFSeAPJhREuy4oYbnwH5yPyRDvM='))
group BY FParentID, FCoreBillEntryId, FMeasureUnitID, FBaseUnitID
)group BY FParentId, FMeasureUnitId, FCoreBillEntryId) ARE on are.FCoreBillEntryId = soe.FID
left OUTER JOIN T_BD_MultiMeasureUnit MMU on (mmu.FMaterialID = soe.FMaterialID and mmu.FMeasureUnitID = soe.FUnitID)
inner JOIN T_SD_SaleOrder SO on so.FID = soe.FParentID
inner JOIN T_AR_OtherBill AR on are.FParentID = ar.FID
where (((so.FIsCentralBalance = 1 and ar.FCompanyId = so.FCompanyOrgUnitID)
or (so.FIsCentralBalance = 0 and ar.FCompanyId = soe.FCompanyOrgUnitID))
and T1.FID = soe.FID)
)
where EXISTS (
SELECT (soe.FTolInvoidBaseQty + are.FBaseQty) IBQ, CASE
when soe.FUnitID = are.FMeasureUnitID THEN (soe.FTotalInvoicedQty + are.FQuantity) ELSE ROUND(CAST(((soe.FTolInvoidBaseQty + CAST(are.FBaseQty AS NUMBER(21, 8))) / mmu.FBaseConvsRate) AS NUMBER(21, 8)), mmu.FQtyPrecision) END QTY, (soe.FAssociateQty - are.FBaseQty) UIQ, (soe.FTotalArAmount + are.FRecievePayAmount) INM
from T_SD_SaleOrderEntry SOE
inner JOIN (SELECT FParentId, FMeasureUnitId, FCoreBillEntryId, sum(FBaseQty) FBASEQTY, sum(FQuantity) FQUANTITY, sum(FRecievePayAmount) FRECIEVEPAYAMOUNT from (SELECT FParentID, FCoreBillEntryId, FMeasureUnitID, FBaseUnitID, SUM(FBaseQty) FBASEQTY, SUM(FQuantity) FQUANTITY, SUM(FRecievePayAmount) FRECIEVEPAYAMOUNT from T_AR_OtherBillEntry
where (FParentID IN ('HFSeAPJhREuy4oYbnwH5yPyRDvM='))
group BY FParentID, FCoreBillEntryId, FMeasureUnitID, FBaseUnitID
) group BY FParentId, FMeasureUnitId, FCoreBillEntryId) ARE on are.FCoreBillEntryId = soe.FID
left OUTER JOIN T_BD_MultiMeasureUnit MMU on (mmu.FMaterialID = soe.FMaterialID and mmu.FMeasureUnitID = soe.FUnitID)
inner JOIN T_SD_SaleOrder SO on so.FID = soe.FParentID
inner JOIN T_AR_OtherBill AR on are.FParentID = ar.FID
where (((so.FIsCentralBalance = 1 and ar.FCompanyId = so.FCompanyOrgUnitID)
or (so.FIsCentralBalance = 0 and ar.FCompanyId = soe.FCompanyOrgUnitID))
and T1.FID = soe.FID)
)
------------------------------------------------------------------------------------------------------------
错误日志:Caused exception message is: ORA-01427: single-row subquery returns more than one row
错误详细堆栈信息:com.kingdee.bos.BOSException: nullCaused exception message is: ORA-01427: single-row subquery returns more than one row at com.kingdee.eas.scm.common.AbstractWriteBackHandler.handle(AbstractWriteBackHandler.java:180) at com.kingdee.eas.fi.ar.app.OtherBillControllerBean._audit(OtherBillControllerBean.java:2721) at com.kingdee.eas.fi.ar.app.AbstractOtherBillControllerBean.audit(AbstractOtherBillControllerBean.java:247) at sun.reflect.GeneratedMethodAccessor2005.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:618) at com.kingdee.bos.transaction.EJBTxFacade.TxInvokerBean.invoke(TxInvokerBean.java:125) at com.kingdee.bos.transaction.EJBTxFacade.TxInvokerBean.INVOKE_REQUIRED(TxInvokerBean.java:60) at com.kingdee.bos.transaction.EJBTxFacade.TxInvokerBean_LocalObjectImpl_2.INVOKE_REQUIRED(Unknown Source) at com.kingdee.bos.transaction.EJBTransactionProxy.invoke(EJBTransactionProxy.java:171) at com.kingdee.bos.transaction.EJBTransactionProxy.invoke(EJBTransactionProxy.java:324) at $Proxy313.audit(Unknown Source) at com.kingdee.eas.fi.ar.OtherBill.audit(OtherBill.java:163) at rpc_generate._PROXY_com_1_kingdee_1_eas_1_fi_1_ar_1_IOtherBill.pi95(Unknown Source) at rpc_generate._PROXY_com_1_kingdee_1_eas_1_fi_1_ar_1_IOtherBill.processInvoke(Unknown Source) at com.kingdee.bos.rpc.impl.ObjectProxy.processInvoke(ObjectProxy.java:177) at com.kingdee.bos.rpc.impl.RPCService.serviceInvoke(RPCService.java:780) at com.kingdee.bos.rpc.impl.RPCService.service(RPCService.java:139) at com.kingdee.bos.rpc.impl.ServiceDispatcher.run(ServiceDispatcher.java:153) at com.kingdee.bos.rpc.impl.ThreadJob.run(ThreadJob.java:27) at com.kingdee.bos.rpc.impl.ThreadPool2$Worker.run(ThreadPool2.java:140)Caused by: java.sql.SQLException: ORA-01427: single-row subquery returns more than one row at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:330) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:287) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:744) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213) at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:965) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1169) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3338) at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3444) at com.kingdee.bos.sql.shell.KDPreparedStatement.execute(KDPreparedStatement.java:264) at com.apusic.jdbc.adapter.PreparedStatementHandle.execute(Unknown Source) at com.kingdee.eas.scm.common.AbstractWriteBackHandler.executeUpdate(AbstractWriteBackHandler.java:161) at com.kingdee.eas.scm.common.AR2SIWriteBackHandler.batchWriteBackOrder(AR2SIWriteBackHandler.java:329) at com.kingdee.eas.scm.common.AR2SIWriteBackHandler.doHandle(AR2SIWriteBackHandler.java:447) at com.kingdee.eas.scm.common.AbstractWriteBackHandler.handle(AbstractWriteBackHandler.java:177) ... 20 moreCaused by: java.sql.SQLExceptionjava.sql.SQLException: ORA-01427: single-row subquery returns more than one row at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:330) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:287) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:744) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213) at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:965) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1169) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3338) at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3444) at com.kingdee.bos.sql.shell.KDPreparedStatement.execute(KDPreparedStatement.java:264) at com.apusic.jdbc.adapter.PreparedStatementHandle.execute(Unknown Source) at com.kingdee.eas.scm.common.AbstractWriteBackHandler.executeUpdate(AbstractWriteBackHandler.java:161) at com.kingdee.eas.scm.common.AR2SIWriteBackHandler.batchWriteBackOrder(AR2SIWriteBackHandler.java:329) at com.kingdee.eas.scm.common.AR2SIWriteBackHandler.doHandle(AR2SIWriteBackHandler.java:447) at com.kingdee.eas.scm.common.AbstractWriteBackHandler.handle(AbstractWriteBackHandler.java:177) at com.kingdee.eas.fi.ar.app.OtherBillControllerBean._audit(OtherBillControllerBean.java:2721) at com.kingdee.eas.fi.ar.app.AbstractOtherBillControllerBean.audit(AbstractOtherBillControllerBean.java:247) at sun.reflect.GeneratedMethodAccessor2005.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:618) at com.kingdee.bos.transaction.EJBTxFacade.TxInvokerBean.invoke(TxInvokerBean.java:125) at com.kingdee.bos.transaction.EJBTxFacade.TxInvokerBean.INVOKE_REQUIRED(TxInvokerBean.java: