diff --git a/org.adempiere.base/src/org/compiere/process/SvrProcess.java b/org.adempiere.base/src/org/compiere/process/SvrProcess.java index b627dc5fce..072c84159a 100644 --- a/org.adempiere.base/src/org/compiere/process/SvrProcess.java +++ b/org.adempiere.base/src/org/compiere/process/SvrProcess.java @@ -703,8 +703,9 @@ public abstract class SvrProcess implements ProcessCall if (log.isLoggable(Level.FINE)) log.fine("AD_PInstance_ID=" + m_pi.getAD_PInstance_ID()); try { - DB.executeUpdate("UPDATE AD_PInstance SET IsProcessing='Y' WHERE AD_PInstance_ID=" - + m_pi.getAD_PInstance_ID(), null); // outside trx + if(m_pi.getAD_PInstance_ID() > 0) // Update only when AD_PInstance_ID > 0 (When we Start Process w/o saving process instance (No Process Audit)) + DB.executeUpdate("UPDATE AD_PInstance SET IsProcessing='Y' WHERE AD_PInstance_ID=" + + m_pi.getAD_PInstance_ID(), null); // outside trx } catch (Exception e) { log.severe("lock() - " + e.getLocalizedMessage()); @@ -727,20 +728,22 @@ public abstract class SvrProcess implements ProcessCall //clear interrupt signal so that we can unlock the ad_pinstance record if (Thread.currentThread().isInterrupted()) Thread.interrupted(); - - MPInstance mpi = new MPInstance (getCtx(), m_pi.getAD_PInstance_ID(), null); - if (mpi.get_ID() == 0) - { - log.log(Level.SEVERE, "Did not find PInstance " + m_pi.getAD_PInstance_ID()); - return; - } - mpi.setIsProcessing(false); - mpi.setResult(!m_pi.isError()); - mpi.setErrorMsg(m_pi.getSummary()); - mpi.saveEx(); - if (log.isLoggable(Level.FINE)) log.fine(mpi.toString()); - ProcessInfoUtil.saveLogToDB(m_pi); + if(m_pi.getAD_PInstance_ID() > 0) { + MPInstance mpi = new MPInstance (getCtx(), m_pi.getAD_PInstance_ID(), null); + if (mpi.get_ID() == 0) + { + log.log(Level.INFO, "Did not find PInstance " + m_pi.getAD_PInstance_ID()); + return; + } + mpi.setIsProcessing(false); + mpi.setResult(!m_pi.isError()); + mpi.setErrorMsg(m_pi.getSummary()); + mpi.saveEx(); + if (log.isLoggable(Level.FINE)) log.fine(mpi.toString()); + + ProcessInfoUtil.saveLogToDB(m_pi); + } } catch (Exception e) {