Logic works in BL Tester, but not BPM Code (Mass Shipment)

Boom! That was it! That was too many hours of different testing. Too many hours… :sob:

Free working code (Standard Data Directive on OrderHed):

var tt = ttOrderHed.First();

string creditMessage;
bool opPromptForNum;

string opReleaseMessage;
string opCompleteMessage;
string opShippingMessage;
string opLotMessage;
string opInventoryMessage;
string opLockQtyMessage;
string opAllocationMessage;
string opPartListNeedsAttr;
string opLotListNeedsAttr;
string shipCreditMsg;
bool cError;
bool compError;
string msg;
string opPostUpdMessage;
bool updateComplete;
bool checkComplianceError;
bool changeStatusError;
bool checkShipDtlAgain;

string warnMsg;

using (var txScope = IceContext.CreateDefaultTransactionScope())
  {
    using (var hCustShip = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.CustShipSvcContract>(Db))
      {
        Erp.Tablesets.CustShipTableset ds = new Erp.Tablesets.CustShipTableset();
        hCustShip.GetNewShipHead(ref ds);
        hCustShip.GetHeadOrderInfo(tt.OrderNum, out creditMessage, ref ds);
        hCustShip.GetLegalNumGenOpts(0, ref ds, out opPromptForNum);
        hCustShip.UpdateMaster(ref ds, false, false, false, false, false, false, false, packNum, tt.CustNum, out opReleaseMessage, out opCompleteMessage, out opShippingMessage, out opLotMessage, out opInventoryMessage, out opLockQtyMessage, out opAllocationMessage, out opPartListNeedsAttr, out opLotListNeedsAttr, out shipCreditMsg, out cError, out compError, out msg, out opPostUpdMessage, out updateComplete, out checkComplianceError, out changeStatusError, out checkShipDtlAgain);
        
        packNum = ds.ShipHead[0].PackNum;
        
        hCustShip.PreCreateMassShipDtl(packNum, tt.OrderNum, out warnMsg, ref ds);
        hCustShip.CreateMassShipDtl(packNum, tt.OrderNum, ref ds);
        
        ds.ShipHead[0].RowMod = "U";
        hCustShip.GetManifestInfo(tt.OrderNum, packNum, ref ds);
        hCustShip.MarkShipmentLines(ref ds);
        ds.ShipHead[0].RowMod = "U"; //May not be needed
        
        //The BO is updating the PackNum on the second UpdateMaster because the unmodified row is not present on the tableset, so it considers the row a new one.
        var unmodifiedShipHead = BufferCopy.Copy<Erp.Tablesets.ShipHeadRow>(ds.ShipHead[0]);
        unmodifiedShipHead.RowMod = "";
        ds.ShipHead.Add(unmodifiedShipHead);
        
        hCustShip.UpdateMaster(ref ds, false, true, false, false, false, false, false, packNum, tt.CustNum, out opReleaseMessage, out opCompleteMessage, out opShippingMessage, out opLotMessage, out opInventoryMessage, out opLockQtyMessage, out opAllocationMessage, out opPartListNeedsAttr, out opLotListNeedsAttr, out shipCreditMsg, out cError, out compError, out msg, out opPostUpdMessage, out updateComplete, out checkComplianceError, out changeStatusError, out checkShipDtlAgain);

      }
    txScope.Complete();
  }
2 Likes