Mass Operation Replace - Error - Duplicate Key Row?!

We are trying to update numerous operations using Mass Operation Replace. Some operations update without a problem, others keep giving us the following error. Any suggestions?

Error Detail

Description: An error occurred while updating the entries. See the inner exception for details.
Inner Exception: Cannot insert duplicate key row in object ‘Erp.PartAudit’ with unique index ‘IX_PartAudit’. The duplicate key value is (GLCT, 940-50629-0000, 0.0, , 2018-09-13, 49059).
The statement has been terminated.
Program: EntityFramework.dll
Method: Update
Original Exception Type: UpdateException
Framework Method: SaveChanges
Framework Line Number: 361
Framework Column Number: 17
Framework Source: SaveChanges at offset 404 in file:line:column C:_Releases\ICE\ICE3.2.100.15\Source\Framework\Epicor.System\Data\IceDataContext.cs:361:17

From the Data Dictionary…
Part Audit History. Records the Date, User and description of changes made to Part Methods of Manufacture.

The index is

Company,PartNum,RevisionNum,ChangeDate,ChangeTime,AltMethod

If you had the same operation multiple times in the MOM, that might try too update both within a second of each other, thus not producing a unique key for the index.

1 Like

Hmm. I don’t think that is it because the error only occurs on a handful of part numbers each time (the same part numbers).

Does the error occur on operations with inspection plans? We experienced this error when getting details from a template job that had an inspection plan tied to one of the operations. Maybe there is something buggy with inspection plans. Something to check.

And do those those part numbers have the same Operation specified multiple times?

For example:

Op 10 - CUT
OP 20 - STRIP
Op 30 - CUT
etc ...

if Operation CUT was being replaced with SLICE, it would try to make two changes to the PartAudit table, and if they happened 0.5 seconds apart, they wouldn’t generate unique keys.

FWIW - I don’t think this is it, as I’ve never seen this happen for Mass Part Replace, and most of our BOM’s have the same Part on several Material Sequence lines.

Yes, the part often has the same operation on multiple times… Each time I run it errors with the part number that is the problem. If I open that part in Eng Workbench, I can manually change the operation, then re-run Mass Part Replace. Then, I get the next part number and do the same manual fix. Some operation changes only require 6-10 part numbers with problems. However, last week the last operation I did required 30+ manual changes… I’m concerned that the next few updates will require waaay more than 30.

Stuck… hmm.

This post might help you:

2 Likes

Thanks for lead! Would have taken a while to track this down. For others, here is SQL to find the offending parts:

select PartNum, count(*) from erp.PartOpr
where OpCode = 'OPR1'
group by PartNum
having count(*)>1

I only had 29 parts with the duplicate operations, so I fixed them manually in EWB. Then mass replace ran fine.