Alphanu
(Ben)
April 11, 2019, 3:55pm
1
As there is no BO method to invoke that can be used in a BPM to propagate the SLimOrderAlloc temporary table. I have been trying to do this through custom code. I have have tried a few things with no luck. I have also tried the answer to a similar thread here. https://epiusers.help/t/casting-orderallocdataset-to-slimorderallocdataset/52735 This also has not worked for me, maybe I am missing some references or something.
This is how my code looks now but it throws up the following error message -
BPM runtime caught an unexpected exception of ‘NullReferenceException’ type.
See more info in the Inner Exception section of Exception Details.
Erp.Tablesets.SlimOrderAllocTableset slimTT = new Erp.Tablesets.SlimOrderAllocTableset();
var newSlimRow = slimTT.SlimOrderAlloc.FirstOrDefault();
foreach (var row in OrderAlloctt.OrderAlloc){
newSlimRow.Company = row.Company;
newSlimRow.OrderNum = row.OrderNum;
newSlimRow.OrderLine = row.OrderLine;
newSlimRow.OrderRelNum = row.OrderRelNum;
newSlimRow.MtlSeq = row.MtlSeq;
newSlimRow.JobNum = row.JobNum;
newSlimRow.AssemblySeq = row.AssemblySeq;
newSlimRow.FulfillmentSeq = row.FulfillmentSeq;
newSlimRow.SelectedForAction = true;
SlimAlltt.SlimOrderAlloc.Add(newSlimRow);
}
I have invoked the BO method for OrderAlloc and have checked it contains data.
I know I am probably doing this the wrong way and would really appreciate some help. I know you guys on here are gurus props to you all.
Thanks in advance.
-Ben
I think you need to use the BO to get a new row in the tableset before referencing and/or altering that row.
Alphanu
(Ben)
April 12, 2019, 3:00pm
3
Thanks for the reply.
I choose not to use custom code in the end. Instead I used fill table with query which has worked like a charm.
-Ben
1 Like
Hey Ben, since it’s been asked a couple of times, would you mind showing how you accomplished this with the Fill Table by Query widgets? It would be good to have that so the next person to ask could follow your examples
Alphanu
(Ben)
April 12, 2019, 9:04pm
5
Yeah, not a problem.
When I get back to work on Monday, I’ll get some screen shots and post them up.
-Ben
Alphanu
(Ben)
April 13, 2019, 10:57am
6
I need to add the preconditions so this triggers at the right point for us. However, here are the steps
Setup variables. Here is my overall layout.
Invoke BO OrderAlloc.GetList to get the OrderAllocList tableset.
Invoke BO OrderAlloc.OrderAllocationGetRows to get OrderAlloc tableset from OrderAllocList Tableset.
Flag SelectedForAction of all rows in OrderAlloc tableset
Fill SlimOrderAlloc tableset from OrderAlloc tableset using fill table with query. Pass the display fields needed for the SlimOrderAlloc tableset.
Invoke BO OrderAlloc.AutoReserve.
Show message response from AutoReserve (cMesage Text)
Hope this help others trying to achieve the same thing.
-Ben
2 Likes
aclements
(Andrew Clements)
April 13, 2019, 11:18am
7
Hi,
I have written a c# application for a client to auto run the fulfilment workbench based upon a set of specified search parameters and then allocate the stock.
I did the following to overcome the casting issue by doing the following:
orderallocBO.OrderAllocationGetRows(orderAllocListDS, 0);
DataTable dtOrderAlloc = orderAllocListDS.Tables[0];
foreach (DataRow dr in dtOrderAlloc.Rows)
{
dr["SysRowID"] = DBNull.Value;
}
DataTable dtSlimOrderAlloc = dtOrderAlloc.Copy();
dtSlimOrderAlloc.PrimaryKey = null;
dtSlimOrderAlloc.Columns.Remove("ReqDate");
dtSlimOrderAlloc.Columns.Remove("PartNum");
dtSlimOrderAlloc.Columns.Remove("WarehouseCode");
dtSlimOrderAlloc.Columns.Remove("SelectForPicking");
dtSlimOrderAlloc.Columns.Remove("CustID");
dtSlimOrderAlloc.Columns.Remove("CustName");
dtSlimOrderAlloc.Columns.Remove("ShipToNum");
dtSlimOrderAlloc.Columns.Remove("JobAssemblyMtl");
dtSlimOrderAlloc.Columns.Remove("TFOrdNumTFOrdLine");
dtSlimOrderAlloc.Columns.Remove("DemandTypeDesc");
dtSlimOrderAlloc.Columns.Remove("DisplaySeq");
dtSlimOrderAlloc.Columns.Remove("FromPlant");
dtSlimOrderAlloc.Columns.Remove("JobType");
dtSlimOrderAlloc.Columns.Remove("Plant");
dtSlimOrderAlloc.Columns.Remove("PriorityCode");
dtSlimOrderAlloc.Columns.Remove("ToPlant");
dtSlimOrderAlloc.Columns.Remove("OrderNumLineRel");
dtSlimOrderAlloc.Columns.Remove("NeedByDate");
dtSlimOrderAlloc.Columns.Remove("RequestDate");
dtSlimOrderAlloc.Columns.Remove("RequiredDate");
dtSlimOrderAlloc.Columns.Remove("ReadyToFulfill");
dtSlimOrderAlloc.Columns.Remove("PartDescription");
dtSlimOrderAlloc.Columns.Add("FulfillmentSeq");
dtSlimOrderAlloc.Columns.Add("DoNotShipAfterDate");
dtSlimOrderAlloc.Columns.Add("DoNotShipBeforeDate");
dtSlimOrderAlloc.Columns.Add("ReservePriorityOverride");
dtSlimOrderAlloc.Columns.Add("SelectedForAction");
int fulseq = 1;
foreach (DataRow dr in dtSlimOrderAlloc.Rows)
{
dr["RowMod"] = "U";
dr["FulfillmentSeq"] = fulseq;
dr["SelectedForAction"] = "true";
//dr["SysRowID"] = null;
fulseq = fulseq + 1;
}
dtSlimOrderAlloc.Columns["AssemblySeq"].SetOrdinal(0);
dtSlimOrderAlloc.Columns["Company"].SetOrdinal(1);
dtSlimOrderAlloc.Columns["DemandType"].SetOrdinal(2);
dtSlimOrderAlloc.Columns["DoNotShipAfterDate"].SetOrdinal(3); ;
dtSlimOrderAlloc.Columns["DoNotShipBeforeDate"].SetOrdinal(4); ;
dtSlimOrderAlloc.Columns["FulfillmentSeq"].SetOrdinal(5);
dtSlimOrderAlloc.Columns["JobNum"].SetOrdinal(6);
dtSlimOrderAlloc.Columns["MtlSeq"].SetOrdinal(7);
dtSlimOrderAlloc.Columns["OrderLine"].SetOrdinal(8);
dtSlimOrderAlloc.Columns["OrderNum"].SetOrdinal(9);
dtSlimOrderAlloc.Columns["OrderRelNum"].SetOrdinal(10);
dtSlimOrderAlloc.Columns["ReservePriorityOverride"].SetOrdinal(11);
dtSlimOrderAlloc.Columns["SelectedForAction"].SetOrdinal(12);
dtSlimOrderAlloc.Columns["TFOrdLine"].SetOrdinal(13);
dtSlimOrderAlloc.Columns["TFOrdNum"].SetOrdinal(14);
dtSlimOrderAlloc.Columns["SysRowID"].SetOrdinal(15);
dtSlimOrderAlloc.Columns["RowMod"].SetOrdinal(16);
SlimOrderAllocDataSet slimOrderAllocDataSet = new SlimOrderAllocDataSet();
foreach (DataRow dr in dtSlimOrderAlloc.Rows)
{
slimOrderAllocDataSet.Tables[0].Rows.Add(dr.ItemArray);
}
1 Like
Alphanu
(Ben)
April 13, 2019, 1:47pm
8
Hi @aclements ,
That’s for the reply. I have it working through widgets know, but I will try this too.
I have auto reserve working. However, I cant seem to send for picking. Any chance you could guide me here?
-Ben
aclements
(Andrew Clements)
April 13, 2019, 2:59pm
9
Hi Ben,
In order to get the whole thing working , I followed the same calls as the fulfillment workbench, which I obtained by looking at the trace file.
After you have run auto reserve working you need to be looking at the ‘orderallocBO.AutoPick’, ‘orderallocBO.SubmitForPicking’ methods.
Cheers,
Andrew.
Alphanu
(Ben)
April 13, 2019, 3:09pm
10
Hey @aclements ,
This is what I have done. however, I always get “0 demand sent for picking”
I guess I am not setting one of the fields correctly. I am currently setting these field:
SetectForAction = true;
RowMod ="U"
Again though, I am now doing it with widgets in stead of custom code. Maybe I am missing something.
Are you running your code as a pre or post method?
Thanks again.
-Ben
aclements
(Andrew Clements)
April 13, 2019, 3:21pm
11
Hi Ben,
I created it as a console application in Visual Studio.
The application then runs as a scheduled task, every hour, using an agreed set of search criteria.
Cheers,
Andrew.
mehar
(meharban)
September 15, 2019, 4:36am
12
You need one more field Selected for picking=true;
fakhruddin
(fakhruddin husain)
December 22, 2022, 1:27pm
13
@mehar , do you have a code for Auto Pick?
mehar
(meharban)
February 27, 2023, 5:03am
14
string outStr = "";
string cMsg = "";
int orderNum = ttOrderHed[0].OrderNum;
Erp.Tablesets.OrderAllocTableset orderAllocTableSet = new Erp.Tablesets.OrderAllocTableset();
Erp.Tablesets.OrderAllocListTableset orderAllocListTableSet = new Erp.Tablesets.OrderAllocListTableset();
Erp.Tablesets.SlimOrderAllocTableset slimOrderAllocTableSet = new Erp.Tablesets.SlimOrderAllocTableset();
var orderAllocSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.OrderAllocSvcContract>(Db);
//// Reserve Lines
var orderRelRows = Db.OrderRel.Where(rel => rel.OrderNum == orderNum).ToList();
// Add Rows
foreach(var rel in orderRelRows)
{
SlimOrderAllocRow newSlimOrderAlloc = new SlimOrderAllocRow();
newSlimOrderAlloc.AssemblySeq = 0;
newSlimOrderAlloc.Company = "10POL";
newSlimOrderAlloc.DemandType = "Order";
newSlimOrderAlloc.FulfillmentSeq = 2;
newSlimOrderAlloc.JobNum = "";
newSlimOrderAlloc.MtlSeq = 0;
newSlimOrderAlloc.OrderLine = rel.OrderLine;
newSlimOrderAlloc.OrderNum = rel.OrderNum;
newSlimOrderAlloc.OrderRelNum = rel.OrderRelNum;
newSlimOrderAlloc.ReservePriorityOverride = 0;
newSlimOrderAlloc.SelectedForAction = true;
newSlimOrderAlloc.TFOrdLine = 0;
newSlimOrderAlloc.TFOrdNum = "";
newSlimOrderAlloc.SysRowID = new Guid("00000000-0000-0000-0000-000000000000");
newSlimOrderAlloc.RowMod = "U";
slimOrderAllocTableSet.SlimOrderAlloc.Add(newSlimOrderAlloc);
}
orderAllocSvc.AutoReserve(ref slimOrderAllocTableSet,"","all",out outStr);
//this.PublishInfoMessage( outStr, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
//// Release For Picking
var morePages = false;
orderAllocListTableSet = orderAllocSvc.GetList("OrderNum = " + ttOrderHed[0].OrderNum + " BY OrderNum", 0, 0, out morePages, "");
int numLines = orderAllocListTableSet.OrderAllocList.Count;
Erp.Tablesets.OrderAllocTableset tsOrdAlloc = new Erp.Tablesets.OrderAllocTableset();
tsOrdAlloc = orderAllocSvc.OrderAllocationGetRows(orderAllocListTableSet, numLines);
bool cSuccess = false;
DateTime needByDate = Convert.ToDateTime("1900-01-01");
int iRelPickSeq = 0;
bool iReleased = false;
foreach (var line in tsOrdAlloc.OrderAlloc)
{
cMsg = cMsg + "Line:" + line.ToString() + ",SelectForAction" + line.SelectedForAction.ToString() + Environment.NewLine;
line.RowMod = "U";
line.SelectedForAction = true;
line.EnableSelectForPicking = true;
line.SelectForPicking = true;
}
if (cMsg !="")
{
//this.PublishInfoMessage( cMsg, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "MtlQueue", "MtlQueue");
cMsg = "";
}
orderAllocSvc.AutoPick(ref tsOrdAlloc,"",out cSuccess,out cMsg);
if (cMsg != "")
{
//this.PublishInfoMessage("Error Found in AutoPick." + cMsg, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "MtlQueue", "MtlQueue");
}
orderAllocSvc.SubmitForPicking(ref tsOrdAlloc,0,needByDate,false, out cMsg, out iRelPickSeq, out iReleased);
if (cMsg != "")
{
this.PublishInfoMessage(cMsg, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}
//TODO: Update ttOrderHed SysRevID
//ttOrderHed[0].RowMod = "";