Error creating PartTran on CommitTransfer

HI all,

i am getting an error when doing an inventory transfer via BPM that is triggered by change in UD40…
I have tried InTran Data directive and Update Method PostProcessing in MethodDirective but get the same error in both cases.
The issue is only happening when duplicate parts need to be transfered…

 using (var txScope = IceDataContext.CreateDefaultTransactionScope())
                               {
                                  try
                                  {

                                                    sbDebugMsg.AppendLine(string.Format("{0:yyyy-MM-dd__HH:mm:ss}  -  > > > > > > > > > >   Transferring Stock   > > > > > > > > > >", System.DateTime.Now));
                                    
                                                    toWarehouseCode = tt.WarehouseCode;
                                                    toBinNum = tt.BinNum;
                                                   
                                                    Erp.Contracts.InvTransferSvcContract svcInvTransfer = null;
                                                    svcInvTransfer = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.InvTransferSvcContract>(Db);
                                                    var dsInvTransfer = new Erp.Tablesets.InvTransferTableset();
    
    
                                                    sbDebugMsg.AppendLine(string.Format("{0:yyyy-MM-dd__HH:mm:ss}  -  GetTransferRecord", System.DateTime.Now));
                                                    dsInvTransfer = svcInvTransfer.GetTransferRecord(tt.PartNum, "CT");
                                                    
                                                    var ttInvTrans = (from r in dsInvTransfer.InvTrans select r).FirstOrDefault();
                                                    if(ttInvTrans != null)
                                                     {
                                                   
                                                    ttInvTrans.TranReference = "Pack:" + tt.PackNum;

                                                    ttInvTrans.TransferQty = tt.OurInventoryShipQty;
                                                    ttInvTrans.TrackingQty = tt.OurInventoryShipQty;
                                                    ttInvTrans.RowMod = "U"; 
                                                    sbDebugMsg.AppendLine(string.Format("{0:yyyy-MM-dd__HH:mm:ss}  -  ChangeUOM ({1:#})", System.DateTime.Now, tt.OurInventoryShipQty));
                                                    svcInvTransfer.ChangeUOM(ref dsInvTransfer);
                                                    sbDebugMsg.AppendLine(string.Format("{0:yyyy-MM-dd__HH:mm:ss}  -  ttInvTrans.FromWhse/BinNum ({1}/{2}) -> ttInvTrans.ToWhse/BinNum ({3}/{4})"
                                                                     , System.DateTime.Now, ttInvTrans.FromWarehouseCode, ttInvTrans.FromBinNum, ttInvTrans.ToWarehouseCode, ttInvTrans.ToBinNum));
                                                    if (!string.Equals(ttInvTrans.FromWarehouseCode, fromWarehouseCode, StringComparison.OrdinalIgnoreCase))
                                                    {
                                                            ttInvTrans.FromWarehouseCode = fromWarehouseCode;
                                                            sbDebugMsg.AppendLine(string.Format("{0:yyyy-MM-dd__HH:mm:ss}  -  \tChangeFromWhse ({1})", System.DateTime.Now, fromWarehouseCode));
                                                            svcInvTransfer.ChangeFromWhse(ref dsInvTransfer);
                                                    }
    
                                                    if (!string.Equals(ttInvTrans.FromBinNum, fromBinNum, StringComparison.OrdinalIgnoreCase))
                                                    {
                                                            ttInvTrans.FromBinNum = fromBinNum;
                                                            sbDebugMsg.AppendLine(string.Format("{0:yyyy-MM-dd__HH:mm:ss}  -  \tChangeFromBin ({1})", System.DateTime.Now, fromBinNum));
                                                            svcInvTransfer.ChangeFromBin(ref dsInvTransfer);
                                                    }
                                                 
                                                    if (!string.Equals(ttInvTrans.ToWarehouseCode, toWarehouseCode, StringComparison.OrdinalIgnoreCase))
                                                    {
                                                            ttInvTrans.ToWarehouseCode = toWarehouseCode;
                                                            sbDebugMsg.AppendLine(string.Format("{0:yyyy-MM-dd__HH:mm:ss}  -  \tChangeToWhse ({1})", System.DateTime.Now, toWarehouseCode));
                                                            svcInvTransfer.ChangeToWhse(ref dsInvTransfer);
                                                    }
    
                                                    if (!string.Equals(ttInvTrans.ToBinNum, toBinNum, StringComparison.OrdinalIgnoreCase))
                                                    {
                                                            ttInvTrans.ToBinNum = toBinNum;
                                                            sbDebugMsg.AppendLine(string.Format("{0:yyyy-MM-dd__HH:mm:ss}  -  \tChangeToBin ({1})", System.DateTime.Now, toBinNum));
                                                            svcInvTransfer.ChangeToBin(ref dsInvTransfer);
                                                    }
                       
                                                    bool RequiresUserInput = false;
                                                    sbDebugMsg.AppendLine(string.Format("{0:yyyy-MM-dd__HH:mm:ss}  -  PreCommitTransfer ({1}/{2} -> {3}/{4},{5})",
                                                                                    System.DateTime.Now, ttInvTrans.FromWarehouseCode, ttInvTrans.FromBinNum, ttInvTrans.ToWarehouseCode, ttInvTrans.ToBinNum, tt.PartNum));
                                                    svcInvTransfer.PreCommitTransfer(ref dsInvTransfer, out RequiresUserInput);
                                                    ttInvTrans.RowMod = "U";
                                                    string LegalNumberMessage, partTranPKs;
                                                    sbDebugMsg.AppendLine(string.Format("{0:yyyy-MM-dd__HH:mm:ss}  -  CommitTransfer...", System.DateTime.Now));
                                                    svcInvTransfer.CommitTransfer(ref dsInvTransfer, out LegalNumberMessage, out partTranPKs);
                                                    sbDebugMsg.AppendLine(string.Format("{0:yyyy-MM-dd__HH:mm:ss}  -  ...Completed", System.DateTime.Now));
                                                    
                                                    }
                                                   
                                                  svcInvTransfer.Dispose();
                                                  dsInvTransfer  = null;                 
                                                  txScope.Complete(); 
                                     }

catch (Exception ex)
{
sbDebugMsg.AppendFormat(" … Failed!! [{0}]\r\n{1}\r\n{2}\r\n", ex.Message, ex.StackTrace, ex.InnerException);

                                    txScope.Dispose();
                                }
       
                            } // using (var txScope = IceContext.CreateDefaultTransactionScope()) 
                          
                          // tt.ToTransfer_c = false;
                            Erp.Internal.Lib.DeferredUpdate libDeferredUpdate = new Erp.Internal.Lib.DeferredUpdate(Db);
                        libDeferredUpdate.UpdPQDemand();    
                      }

What’s your error?

[Error creating PartTran. Please retry.]
at Erp.Services.BO.InvTransferSvc.doPartTran(String ipPartIUM, Boolean ipPartTrackDimension, String ipPCID, String& partTranPK) in c:_Releases\ERP\RL10.2.200.0\Source\Server\Services\BO\InvTransfer\InvTransfer.cs:line 1477
at Erp.Services.BO.InvTransferSvc.CommitTransfer(InvTransferTableset& ds, String& LegalNumberMessage, String& partTranPKs) in c:_Releases\ERP\RL10.2.200.0\Source\Server\Services\BO\InvTransfer\InvTransfer.cs:line 1188
at Epicor.Customization.Bpm.MethodCustomizationBase23.RunDirectives(TParam parameters) in C:\_Releases\ICE\ICE3.2.200.10\Source\Server\Internal\Lib\Epicor.Customization.BPM\MethodCustomizationBase2.cs:line 197 at Epicor.Customization.Bpm.CustomizationBase23.Execute(TParam parameters) in C:_Releases\ICE\ICE3.2.200.10\Source\Server\Internal\Lib\Epicor.Customization.BPM\CustomizationBase2.cs:line 73
at Epicor.Customization.Bpm.BO28F7D29F8E6D4E8B91A3042D152634BF.InvTransferSvcCustomization.CommitTransfer(InvTransferTableset& ds, String& LegalNumberMessage, String& partTranPKs)
at Erp.Services.BO.InvTransferSvcFacade.CommitTransfer(InvTransferTableset& ds, String& LegalNumberMessage, String& partTranPKs) in c:_Releases\ERP\RL10.2.200.0\Source\Server\Services\BO\InvTransfer\InvTransferSvcFacade.cs:line 295
at Epicor.Customization.Bpm.BO0DC13D68BD9341C3B5A0D8E431CB2833.UpdatePostProcessingDirective_test_FA5AA429962044C89BF36DDB8B98EBA7.A001_CustomCodeAction()

Looks like you have a BPM called TEST in that method that is erroring.