Inventory Transfer UBAQ-Custom Code problem "PCID required"

I am having trouble transferring a Part with a specified quantity into a target bin. I can do it manually, but with my code it’s wanting a PCID which was never enabled on our Epicor. Manually transferring doesn’t care for this PCID, but with widgets or custom code it does. How can I get this to go through without involving the PCID?

using (var txScope = IceDataContext.CreateDefaultTransactionScope())
{
    Erp.Contracts.InvTransferSvcContract svcInvTransfer = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.InvTransferSvcContract>(Db);
    var dsInvTransfer = new Erp.Tablesets.InvTransferTableset();

    bool bRowAdded;
    string partNum = PART; //variable from my BAQ row
    string uomCode = EA;   //variable set in my BPM widget
    Guid guid2 = Guid.NewGuid();
    Guid getTransferRecordSysRowId = Guid.NewGuid();

    try
    {
        string serialWarning, questionString;
        bool multipleMatch;
        svcInvTransfer.GetPartXRefInfo(ref partNum, ref uomCode, guid2, string.Empty, out serialWarning, out questionString, out multipleMatch);
        Ice.Diagnostics.Log.WriteEntry("GetPartXRefInfo executed successfully.");
        Ice.Diagnostics.Log.WriteEntry($"Serial Warning: {serialWarning}, Question String: {questionString}, Multiple Match: {multipleMatch}");
    }
    catch (Exception ex)
    {
        Ice.Diagnostics.Log.WriteEntry($"Error in GetPartXRefInfo: {ex.Message}");
        // Handle exception
    }

    try
    {
        // Retrieve existing transfer record
        bool requiresUserInput;
        string legalNumberMessage, partTranPKs;
        svcInvTransfer.GetTransferRecord(partNum, getTransferRecordSysRowId, string.Empty, uomCode, out bRowAdded, ref dsInvTransfer);

        // Check if the transfer record is retrieved successfully
        if (bRowAdded)
        {
            // Modify the transfer record
            var transferRow = dsInvTransfer.InvTrans[0]; 
           // transferRow.PCID = ""; 
            transferRow.FromWarehouseCode = "01"; 
            transferRow.ToWarehouseCode = "01"; 
            transferRow.FromBinNum = "B3A3"; 
            transferRow.ToBinNum = "(GTOWN)"; 
            transferRow.TransferQty = 2; 
            transferRow.RowMod = "A";

            Ice.Diagnostics.Log.WriteEntry("Transfer record modified successfully.");
            Ice.Diagnostics.Log.WriteEntry($"PCID: {transferRow.PCID}"); // Log PCID here

            // Perform the transfer
            svcInvTransfer.PreCommitTransfer(ref dsInvTransfer, out requiresUserInput);
            Ice.Diagnostics.Log.WriteEntry("Pre-commit transfer executed successfully.");

            svcInvTransfer.CommitTransfer(ref dsInvTransfer, out legalNumberMessage, out partTranPKs);

            Ice.Diagnostics.Log.WriteEntry("Transfer completed successfully.");
            Ice.Diagnostics.Log.WriteEntry($"Legal Number Message: {legalNumberMessage}");
            Ice.Diagnostics.Log.WriteEntry($"Part Tran PKs: {partTranPKs}");
        }
        else
        {
            Ice.Diagnostics.Log.WriteEntry("Transfer record not found.");
            // Handle the case where the transfer record is not found
        }
    }
    catch (Exception ex)
    {
        Ice.Diagnostics.Log.WriteEntry($"Error in transfer process: {ex.Message}");
        // Handle exception
    }
}

OR SHOULD I USE THIS:

string msg = "";
string ptmsg = "";
bool reqUserInput = false;
string uomCode = "EA"; // Variable set in my BPM widget
bool bRowAdded;

Guid guid2 = Guid.NewGuid();

foreach (var ttResultsRow in (from row in ttResults where row.RowMod == "U" select row))
{
    using (var txScope = IceContext.CreateDefaultTransactionScope())
    {
        msg = "";
        ptmsg = "";
        Erp.Contracts.InvTransferSvcContract invTrans = null;
        invTrans = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.InvTransferSvcContract>(Db);
        var InvTransferDS = new Erp.Tablesets.InvTransferTableset();

        try
        {
            string serialWarning, questionString;
            bool multipleMatch;

            // Pass necessary parameters for GetTransferRecord
            invTrans.GetTransferRecord(ttResultsRow.OrderDtl_PartNum, guid2, string.Empty, uomCode, out bRowAdded, ref InvTransferDS);
            var ttInvTrans_Row = (from InvRow in InvTransferDS.InvTrans select InvRow).FirstOrDefault();

            this.PublishInfoMessage(ttInvTrans_Row?.PartNum ?? "null", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");

            if (ttInvTrans_Row != null)
            {
                 Ice.Diagnostics.Log.WriteEntry("Transfer record found successfully.");

                ttInvTrans_Row.TransferQty = ttResultsRow.OrderDtl_SellingQuantity;
                ttInvTrans_Row.TrackingQty = ttResultsRow.OrderDtl_SellingQuantity;
                ttInvTrans_Row.FromWarehouseCode = "01";
                ttInvTrans_Row.FromBinNum = "";
                ttInvTrans_Row.ToWarehouseCode = "01";
                ttInvTrans_Row.FromBinNum = ttResultsRow.PartBin_BinNum;
                ttInvTrans_Row.TranReference = "";
                ttInvTrans_Row.RowMod = "U";

                Ice.Diagnostics.Log.WriteEntry("Transfer record modified successfully.");

                // Change UOM
                invTrans.ChangeUOM(ref InvTransferDS);
                Ice.Diagnostics.Log.WriteEntry("ChangeUOM executed successfully.");

                // Change From Warehouse
                invTrans.ChangeFromWhse(ttInvTrans_Row.FromWarehouseCode, ref InvTransferDS);
                Ice.Diagnostics.Log.WriteEntry("ChangeFromWhse executed successfully.");
                
                
                // Change From Bin
                string fromBinNum = "B3A3";
                invTrans.ChangeFromBin(fromBinNum, ref InvTransferDS);
                Ice.Diagnostics.Log.WriteEntry("ChangeFromBin executed successfully.");
                
                
                       // Change To Warehouse
                invTrans.ChangeToWhse(ttInvTrans_Row.ToWarehouseCode, ref InvTransferDS);
                Ice.Diagnostics.Log.WriteEntry("ChangeToWhse executed successfully.");


                // Change To Bin
                string toBinNum = "(GTOWN)";
                invTrans.ChangeToBin(toBinNum, ref InvTransferDS);
                Ice.Diagnostics.Log.WriteEntry("ChangeToBin executed successfully.");

                         // Pre-commit transfer
                invTrans.PreCommitTransfer(ref InvTransferDS, out reqUserInput);
                Ice.Diagnostics.Log.WriteEntry("Pre-commit transfer executed successfully.");

                ttInvTrans_Row.RowMod = "U";
                
        // Commit transfer
                invTrans.CommitTransfer(ref InvTransferDS, out msg, out ptmsg);
                Ice.Diagnostics.Log.WriteEntry("Commit transfer executed successfully.");
                Ice.Diagnostics.Log.WriteEntry($"Legal Number Message: {msg}");
                Ice.Diagnostics.Log.WriteEntry($"Part Tran PKs: {ptmsg}");

                Erp.Internal.Lib.DeferredUpdate libDeferredUpdate = new Erp.Internal.Lib.DeferredUpdate(Db);
                libDeferredUpdate.UpdPQDemand();
                Ice.Diagnostics.Log.WriteEntry("Deferred update executed successfully.");
            }
            else
            {
                Ice.Diagnostics.Log.WriteEntry("Transfer record not found.");
                // Handle the case where the transfer record is not found
            }
        }
        catch (Exception ex)
        {
            Ice.Diagnostics.Log.WriteEntry($"Error in transfer process: {ex.Message}");
            Ice.Diagnostics.Log.WriteEntry($"Exception Stack Trace: {ex.StackTrace}");
            // Handle exception
        }
        finally
        {
            invTrans?.Dispose();
            InvTransferDS = null;
        }

        txScope.Complete();
    }

    Erp.Internal.Lib.DeferredUpdate libDeferredUpdateOuter = new Erp.Internal.Lib.DeferredUpdate(Db);
    libDeferredUpdateOuter.UpdPQDemand();
    Ice.Diagnostics.Log.WriteEntry("Deferred update (outer) executed successfully.");
}


I’m sorry i can’t be More help, but I have recently just finished redesigning my companies way of managing Inventory, and I was able to do inventory transfers without assigning any value to the PCID input.


In my picture above you’ll see that i do not Populate that Value at all, My process was to Populate the InvTranTable.InvTrans Table (as shown) and then send it to the Erp.InvTransfer.CommitTransfer business object. No other steps or code involved i filled the Table then Sent it to the commit transfer BO.
image

If i had the actual error you are seeing, making you suspect that the PCID is the error i might be able to provide more help.

Okay I did it that method and I got it working. Thank you Benny!

No problem, glad to help.