Allocating a Lot - BPM

Hi,

Not sure if anyone can help out here - spent far too long on trying to get this to work.
I’m trying to allocate by Lot through a BPM. It runs through OK but doesn’t create a record in OrderAlloc. I’ve ran a full trace and matched up everything (I’ve obviously missed something though.
Any help appreciated - excuse code - it’s a test on getting the BPM to work before tidying up and running properly:

//Epicor.Customization.Bpm.InfoMessage.Publish("0");
//string OrderNum = "2320";
string Message = "";
 Guid OrderAllocSysRowID = new Guid();

bool res = false;

Erp.Tablesets.OrderAllocTableset oat = new Erp.Tablesets.OrderAllocTableset();
Erp.Tablesets.OrderAllocListTableset oatl = new Erp.Tablesets.OrderAllocListTableset();

//Erp.Tablesets.OrderAllocListTableset padt = new Erp.Tablesets.OrderAllocTableset.PartAllocTableset();
//OrderAllocDataSet.PartAllocLotDataTable

Erp.Contracts.OrderAllocSvcContract oa = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.OrderAllocSvcContract>(Db);
string ordHed = "OrderHed.OrderNum = "+ 2320;
string orderDtl = "OrderDtl.OrderLine = 1 ";
string ordeRel = "OrderRel.OrderRelNum = 1";



using(oa)
{
  string PartAllocWhereClause = "NoFilter,NoFilter,NoFilter,NoFilter";
  oatl = oa.GetListOfOrders("", ordHed, orderDtl, ordeRel, "", PartAllocWhereClause, "", "", "", "", "", "", 0, 0, out res, Session.CompanyID);   ////////////////////////////////////////////   One
  foreach (var row in oatl.OrderAllocList)
  {

  row.RowMod = IceRow.ROWSTATE_UNCHANGED;
  } 

oat = oa.OrderAllocationGetRows(oatl, 0);                                                                                          ///////////////////////////////////////////  Two





  
if(oat != null )
{
  
  //foreach(var ordRel in oat.OrderAlloc.Where(i=>i.Company == Session.CompanyID ))
  //{
  //*  
  Erp.Tablesets.SlimOrderAllocTableset soa = new Erp.Tablesets.SlimOrderAllocTableset();
  Ice.IceRow sR = soa.SlimOrderAlloc.NewRow();
  sR["AssemblySeq"] = 0;
  sR["Company"] = Session.CompanyID.ToString();
  sR["DemandType"] = "Order";
  sR["FulfillmentSeq"] = 1;
  sR["JobNum"] = "";
  sR["MtlSeq"] = 0;
  sR["OrderLine"] = 1;
  sR["OrderNum"] = 2320;
  sR["OrderRelNum"] = 1;
  sR["SelectedForAction"] = true; 
  sR["TFOrdLine"] = 0;
  sR["TFOrdNum"] = "";
  sR["RowMod"] = "A"; 
  
  soa.SlimOrderAlloc.Add(sR);
   
  try
    {
           
    foreach(var ORow in oat.OrderAlloc)
    {
       ORow.SelectedForAction = true; // Will Get a Demand Error if you don;t set this!!
       ORow.RowMod = "U";
       //Epicor.Customization.Bpm.InfoMessage.Publish(Convert.ToString(ORow.OrderLine));
       Epicor.Customization.Bpm.InfoMessage.Publish(Convert.ToString(ORow.ShipToNum));
    }
       
    foreach(var TRow in oat.PartAllocTran)
    {
     TRow.AddHoc = true;
     TRow.ReleaseToPicking = true;
     TRow.Replenishable = true; //new
     TRow.TransPriority = 5; //new
     TRow.AllocType = "Order"; //new
     TRow.RowMod = "U";
     //Epicor.Customization.Bpm.InfoMessage.Publish("Tran" + TRow.Company);
    }
   
    oa.CheckDates(ref soa ,out Message);
    
    //Ensure SelectedForAction is True in OrderAlloc
    foreach(var ORow in oat.OrderAlloc)
    {
      Epicor.Customization.Bpm.InfoMessage.Publish("Selected For Action" + Convert.ToString(ORow.SelectedForAction));
      Epicor.Customization.Bpm.InfoMessage.Publish("SysRow" + Convert.ToString(ORow.SysRowID));
      OrderAllocSysRowID =new Guid(ORow.SysRowID.ToString());
    }
    oa.OneDemandType(ref oat ,out Message, out Message);
    
    oa.GetSearchSortDefault("Order",out Message);
    
    //Ensure SelectedForAction is True in OrderAlloc
    //Ensure RowMod = "U" in OrderAlloc
    //Ensure AddHoc = True is True in PartAllocTran
    foreach(var ORow in oat.OrderAlloc)
    {
      Epicor.Customization.Bpm.InfoMessage.Publish("Selected For Action" + Convert.ToString(ORow.SelectedForAction));
      Epicor.Customization.Bpm.InfoMessage.Publish("RowMod" + ORow.RowMod);
    }
    foreach(var TRow in oat.PartAllocTran)
    {
     Epicor.Customization.Bpm.InfoMessage.Publish("PartAllocAddHoc:" + Convert.ToString(TRow.AddHoc));
     Epicor.Customization.Bpm.InfoMessage.Publish("PartAllocRowMod:" + Convert.ToString(TRow.RowMod));
    }
    oa.GetLotBinOnHandByWhseCodeZoneBinType(ref oat, "","","Standard");

    decimal Qty = 12;
    decimal OH = 17800;
    decimal avail = 17800;
    
    Erp.Tablesets.PartAllocLotRow PAllocLR = new Erp.Tablesets.PartAllocLotRow();
    PAllocLR["Company"] = "CABP";
    PAllocLR["PartNum"] = "1000522";
    PAllocLR["WarehouseCode"] = "WCAS";
    PAllocLR["BinNum"] = "PUTAWAY";
    PAllocLR["OrderNum"] = 2320;
    PAllocLR["Orderline"] = 1;
    PAllocLR["OrderRelNum"] = 1;
    PAllocLR["LotNum"] = "515";
    PAllocLR["Allocate"] = true;
    PAllocLR["NewAllocatedQty"] = Qty  ;
    PAllocLR["AllocatedQty"] = Qty  ;
    PAllocLR["RelatedToSchemaName"] = "Erp"  ;
    PAllocLR["RelatedToTableName"] = "OrderRel"  ;
    Guid OrderRel =new Guid("272B6BCE-5863-42DC-AE55-AD73AB0E0088");
    System.Guid.NewGuid().ToString();
    PAllocLR["RelatedToSysRowID"] = OrderRel  ;
    PAllocLR["DimCode"] = "EA"  ;
    PAllocLR["SysRowID"] = OrderAllocSysRowID  ;
    PAllocLR["OnHandQty"] = OH  ;
    PAllocLR["AvailableQty"] = avail ;
    PAllocLR["RowMod"] = "A"  ;
           
    oat.PartAllocLot.Add(PAllocLR);
    
    //And Now the other Lot thats isn;t being allocated
    Qty = 0;
    OH = 48496;
    avail = 39996;
    
    PAllocLR["Company"] = "CABP";
    PAllocLR["PartNum"] = "1000522";
    PAllocLR["WarehouseCode"] = "WCAS";
    PAllocLR["BinNum"] = "RECEIPTBIN";
    PAllocLR["OrderNum"] = 2320;
    PAllocLR["Orderline"] = 1;
    PAllocLR["OrderRelNum"] = 1;
    PAllocLR["LotNum"] = "366";
    PAllocLR["Allocate"] = false;
    PAllocLR["NewAllocatedQty"] = Qty  ;
    PAllocLR["AllocatedQty"] = Qty  ;
    PAllocLR["RelatedToSchemaName"] = "Erp"  ;
    PAllocLR["RelatedToTableName"] = "OrderRel"  ;
    PAllocLR["RelatedToSysRowID"] = OrderRel  ;
    PAllocLR["DimCode"] = "EA"  ;
    PAllocLR["OnHandQty"] = OH  ;
    PAllocLR["AvailableQty"] = avail ;
     
   
    PAllocLR["SysRowID"] = OrderAllocSysRowID  ;
    
    PAllocLR["RowMod"] = "A"  ;
    
    
    
    
    oa.AllocateByLotBin(ref oat,"","All",out Message,out res);
    
    }
    catch (Exception ex)
    {
    Epicor.Customization.Bpm.InfoMessage.Publish(" Reservation Error "+ ex.Message + "\n" + ex.InnerException);
    }
    Epicor.Customization.Bpm.InfoMessage.Publish("Done");
     
}

}

Do you see anything in the windows event log or the server system log?

Triple checking everything I realised I hadn’t set “DimCode” in PartAllocLot!

1 Like

I was going to say that…Just kidding. Nothing like staring at something a million times. Glad you found the issue.

It’s always the case - you spend ages doing something and it’s only when you ask for help that you realise waht you did wrong!. Thanks for reaching out to help though.
Cheers

Mark

No problems always too happy to help. I’ve been there many times, which reminds me. Look at the time. All good Aussie Epicor peeps should be tucked into bed by now. :slight_smile:

Have a good one.