We have this code written by a consultant for us a while ago which @hmwillett helped fix for our kinetic uplift.
Is it possible to auto complete the move when the actionID = ProcessIn?
string requestType = "MI";
string warehousesList = string.Empty;
string defaultBinNum = "PUTAWAY";
List<string> binIssues = new List<string>();
foreach (var toProcess in queryResultDataset.Results.Where(r => r.Calculated_Select && r.RowMod == "U"))
{
var tsMoveRequest = new MoveRequestTableset();
using (var hMoveRequest = ServiceRenderer.GetService<MoveRequestSvcContract>(Db))
{
decimal pdRequestQty = actionID == "ProcessIn" ? String.IsNullOrEmpty(toProcess.PartBin_LotNum) ? callContextBpmData.Number01 : toProcess.PartBin_OnhandQty : toProcess.PartBin_OnhandQty;
string toWhse = actionID == "ProcessIn" ? callContextBpmData.ShortChar01 : toProcess.PartPlant_PrimWhse;
string toBin = actionID == "ProcessIn" ? callContextBpmData.ShortChar02 : toProcess.PlantWhse_PrimBin;
if (String.IsNullOrEmpty(toBin))
{
bool defaultBinExists = Db.WhseBin.Where(r => r.Company == toProcess.PartBin_Company && r.WarehouseCode == toWhse && r.BinNum == defaultBinNum).Any();
if (!defaultBinExists)
{
binIssues.Add($"PartNum = {toProcess.PartBin_PartNum}, LotNum = {toProcess.PartBin_LotNum}");
continue;
}
toBin = defaultBinNum;
}
if (toProcess.PartBin_WarehouseCode == toWhse && toProcess.PartBin_BinNum == toBin) continue;
hMoveRequest.GetNewMoveRequest(requestType, ref tsMoveRequest);
hMoveRequest.OnChangePartNum(toProcess.PartBin_PartNum, ref tsMoveRequest, out warehousesList);
hMoveRequest.OnChangeRequestQty(pdRequestQty, ref tsMoveRequest);
hMoveRequest.OnChangeFromWhse(toProcess.PartBin_WarehouseCode, ref tsMoveRequest);
hMoveRequest.OnChangeFromBin(toProcess.PartBin_BinNum, ref tsMoveRequest);
hMoveRequest.OnChangeToWhse(toWhse, ref tsMoveRequest);
//if (String.IsNullOrEmpty(toBin)) ;
hMoveRequest.OnChangeToBin(toBin, ref tsMoveRequest);
if (!String.IsNullOrEmpty(toProcess.PartBin_LotNum)) hMoveRequest.OnChangeLot(toProcess.PartBin_LotNum, ref tsMoveRequest);
tsMoveRequest.MoveRequest.FirstOrDefault().EmpId = toProcess.Calculated_Employee;
hMoveRequest.ProcessRequest(ref tsMoveRequest);
}
}
if (binIssues.Any())
{
PublishInfoMessage($"The following records have failed processing because there is no default bin against the part and the Bin {defaultBinNum} does not exist in the part's default warehouse.{Environment.NewLine}{Environment.NewLine}{String.Join(Environment.NewLine, binIssues)}",Ice.Common.BusinessObjectMessageType.Warning, Ice.Bpm.InfoMessageDisplayMode.Individual, "LineSequencing", "Process" );
}
PublishInfoMessage($"Processing completed",Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "LineSequencing", "Process" );