Cost roll-up error duplicate key value

The error is duplicate key value in the costpart table. The total error is below. Any Ideas what causes this?

Program Ice.Services.Lib.RunTask raised an unexpected exception with the following message: RunTask: An error occurred while updating the entries. See the inner exception for details.
Stack Trace:
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
at Ice.IceDataContext.SaveChanges(SaveOptions options) in C:_Releases\ICE\3.1.600.15\Source\Framework\Epicor.System\Data\IceDataContext.cs:line 352
at Ice.IceDataContext.Validate[TLinqRow](TLinqRow row) in C:_Releases\ICE\3.1.600.15\Source\Framework\Epicor.System\Data\IceDataContext.cs:line 311
at Erp.Internal.BM.CostWBRollup.createCostPart(_PartCache ttPartCache, String iGroupID, String ipTypeCode) in c:_Releases\ERP\RL10.1.600.0\Source\Server\Internal\BM\CostWBRollup\CostWBRollup.cs:line 1052
at Erp.Internal.BM.CostWBRollup.getMtlPartCosts(_PartCache ttPartCache, String ipTypeCode, String ipOrigTypeCode, String ipMtlPartNum, Boolean ipMethod, Boolean ipCoPartsExist, Boolean ipPullAsAsm, Boolean ipIsCRCPart, Decimal& opAsmMaterialCost, Decimal& opAsmLaborCost, Decimal& opAsmBurdenCost, Decimal& opAsmSubcontCost, Decimal& opAsmMtlBurCost, Decimal& opAsmSetupLabCost, Decimal& opAsmSetupBurCost, Boolean& opIsTransferCostID) in c:_Releases\ERP\RL10.1.600.0\Source\Server\Internal\BM\CostWBRollup\CostWBRollup.cs:line 1974
at Erp.Internal.BM.CostWBRollup.rollCostMtl(Decimal ipParentPart_MfgLotSize, Boolean ipCoPartsExist, Decimal ipCoPartsReqQty) in c:_Releases\ERP\RL10.1.600.0\Source\Server\Internal\BM\CostWBRollup\CostWBRollup.cs:line 2595
at Erp.Internal.BM.CostWBRollup.RollCost(String IP_PartNum, String IP_RevisionNum, String IP_AltMethod, String IP_PrimPartNum, String IP_PrimRevisionNum, String IP_PrimAltMethod) in c:_Releases\ERP\RL10.1.600.0\Source\Server\Internal\BM\CostWBRollup\CostWBRollup.cs:line 2413
at Erp.Internal.BM.CostWBRollup.RunCostWBRollup(String ipGroupID, Nullable1 ipEffectivityDate, String ipPartList, String ipPartClassList, String ipProdGrupList, Boolean ipConsiderPullAsAsm, Boolean ipTransferPartAsMtl, Boolean ipConsiderOnlyApprovedRevs, String ipLogFileName, Int64 Instance_TaskNum) in c:\_Releases\ERP\RL10.1.600.0\Source\Server\Internal\BM\CostWBRollup\CostWBRollup.cs:line 602 at Erp.Internal.BM.BMM30.RunProcess(Int64 InstanceTaskNum, String OutputFileName) in c:\_Releases\ERP\RL10.1.600.0\Source\Server\Internal\BM\BMM30\BMM30.cs:line 79 at Ice.Hosting.TaskCaller.InnerExecuteTask(IceDataContext newContext) in C:\_Releases\ICE\3.1.600.15\Source\Framework\Epicor.Ice\Hosting\TaskCaller\TaskCaller.cs:line 93 at Ice.Hosting.TaskCaller.ExecuteTask() in C:\_Releases\ICE\3.1.600.15\Source\Framework\Epicor.Ice\Hosting\TaskCaller\TaskCaller.cs:line 54 at Ice.Lib.RunTask.BpmFriendlyTaskLauncher.Run(String sessionIdPrefix, IceContext db, Action taskRunner) in c:\_Releases\ICE\3.1.600.0\Source\Server\Services\Lib\RunTask\BpmFriendlyTaskLauncher.cs:line 63 at Ice.Services.Lib.RunTaskSvc.InnerRunTask(Int64 ipTaskNum, Boolean suppressTransaction) in c:\_Releases\ICE\3.1.600.0\Source\Server\Services\Lib\RunTask\RunTask.cs:line 535 Inner Exception: Violation of PRIMARY KEY constraint 'PK_CostPart'. Cannot insert duplicate key in object 'Erp.CostPart'. The duplicate key value is (TEST, 1229TUBE, M, BAR0.18X6.0A1011GR50). The statement has been terminated. Stack Trace: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary2 identifierValues, List1 generatedValues) at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) at Ice.Services.Lib.RunTaskSvc.InnerRunTask(Int64 ipTaskNum, Boolean suppressTransaction) in c:\_Releases\ICE\3.1.600.0\Source\Server\Services\Lib\RunTask\RunTask.cs:line 535 at Ice.Services.Lib.RunTaskSvcFacade.RunTask(Int64 ipTaskNum) in c:\_Releases\ICE\3.1.600.0\Source\Server\Services\Lib\RunTask\RunTaskSvcFacade.cs:line 87 at SyncInvokeRunTask(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at Epicor.Hosting.OperationBoundInvoker.InnerInvoke(Object instance, Func2 func) in C:_Releases\ICE\3.1.600.15\Source\Framework\Epicor.System\Hosting\OperationBoundInvoker.cs:line 59
at Epicor.Hosting.OperationBoundInvoker.Invoke(Object instance, Func`2 func) in C:_Releases\ICE\3.1.600.15\Source\Framework\Epicor.System\Hosting\OperationBoundInvoker.cs:line 28
at Epicor.Hosting.Wcf.EpiOperationInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) in C:_Releases\ICE\3.1.600.15\Source\Framework\Epicor.System\Hosting\Wcf\EpiOperationInvoker.cs:line 23
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
at System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext request, Boolean cleanThread, OperationContext currentOperationContext)
at System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext)
at System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result)
at System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult result)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.ServiceModel.Channels.TransportDuplexSessionChannel.TryReceiveAsyncResult.OnReceive(IAsyncResult result)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.ServiceModel.Channels.SynchronizedMessageSource.ReceiveAsyncResult.OnReceiveComplete(Object state)
at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
at System.Net.Security.NegotiateStream.ProcessFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.ReadCallback(AsyncProtocolRequest asyncRequest)
at System.Net.AsyncProtocolRequest.CompleteRequest(Int32 result)
at System.Net.FixedSizeReader.CheckCompletionBeforeNextRead(Int32 bytes)
at System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult)
at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.ServiceModel.Channels.ConnectionStream.IOAsyncResult.OnAsyncIOComplete(Object state)
at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs e)
at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)
at System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

Are there any BPMs associated with these tables?

Is this a copart? I am assuming that the part number is 1229TUBE, correct?. There isn’t any other part number that has the same numbers? You don’t use spaces in any part numbers, do you?

Had this issue a few months back and got this conversion program from Epicor. Then the cost roll worked.Costing workbench same key error.pdf (270.8 KB)

The part number starts with BAR. The 1229tube is the cost group. There is no way to have duplicate parts in epicor.

No there aren’t.

Do you happen to know where the trailing spaces were

No I didn’t. I guess you could try to export the parts to a spreadsheet and use a formula count the characters, then do a trim and see if you have any parts with difference.

So this issue was with the part number? I am scouring the tables looking for fields with trailing zeros and none have them.

Yes, the issue is parts with trialing spaces. The costing workbench program must not be able to read the part number. It is much easier to run the program listed in the PDF from Epicor than to search for the part.

I found a few parts that have trailing spaces but they aren’t the one listed but could be the problem. Unfortunately at this time we don’t have support with Epicor.

@MattSpotts There is conversion 1420 which removes trailing spaces from several tables in the user run list in the conversion workbench. Maybe one of those tables will fix the issue.

That is What @EricZ had relayed through the pdf. Unfortunately I cannot run it because I do not have it and I do not have epicor support. I will be stuck on my own for this one.