Fulfillment Workbench

order reservation is done by release level, you need to loop through each release or add all the release to SlimAlloc tableset and reserve in one go.

out of curiosity, is the standard fulfilment workbench not helpful? or whats that your end goal?

anyway , here is a rudimentary code.

Erp.Contracts.OrderAllocSvcContract od = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.OrderAllocSvcContract>(Db);
string ordHed = "OrderHed.OrderNum = "+ordNum.ToString();
using(od)
      {
          oatl = od.GetListOfOrders("", ordHed, "", "", "", "", "", "", "", "", "", "", 0, 0, out res, Session.CompanyID);

          foreach (var row in oatl.OrderAllocList)
          {
/* bug in my system*/
              row.RowMod = IceRow.ROWSTATE_UNCHANGED;
          }
           oat = od.OrderAllocationGetRows(oatl, 0); 
      
 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"] = ordLine;
                sR["OrderNum"] = ordNum;
                sR["OrderRelNum"] = relNum;
                sR["SelectedForAction"] = true;
                sR["TFOrdLine"] = 0;
                sR["TFOrdNum"] = "";
                soa.SlimOrderAlloc.Add(sR);
                try 
                  {          
                    od.AutoReserve(ref soa, "", "primaryOnly", out resreveMsg);
                  }
                  catch (Exception ex)
                  {
                    Epicor.Customization.Bpm.InfoMessage.Publish(" Reservation Error "+ ex.Message + "\n" + ex.InnerException);
                  }                
                
            }
          }
         }
3 Likes