itsme
(Rhythem Prajapati)
August 29, 2023, 1:31pm
1
Hello Folks,
I hope everyone are doing great and are enjoying.
I am trying to achieve a move inventory request triggered by a checkbox/Button at Job-Mtl table. If a checkbox is flagged to true, it should create a STK-STK request and then it will be seen and be manageable from Material Queue Manager.
Idea is the details could be pulled off from PartBin table. ‘FromWareHouse ’ and ‘TOWarehouse ’ in my case will always be the same as well as ‘ToBin ’. ‘FromBin ’ details depends on PartNum and can be fetched from PartBin table.?
Checkbox at JobMtl for reference
I am wondering if this feasible or not. If so, does anyone have an idea to start with ? Does anyone have came across this before? Any help will be appreciated.
Thanking everyone in advance and appreciating your time for looking into this.
klincecum
(Kevin Lincecum)
August 29, 2023, 6:19pm
3
gpayne:
I need a MTL-STK queue which I have not figured out yet.
I think I’ve done that but I’m a little under the weather. Remind me and I’ll look tomorrow.
gpayne
(Greg Payne)
August 29, 2023, 6:23pm
4
No worries. I have a Db write that works, I am trying to use the BO and getting a bunch of fields are required that I have in the call that I have not had time to work thru.
itsme
(Rhythem Prajapati)
August 29, 2023, 8:12pm
5
Thank you @gpayne for your help. I am looking for just a location transfer.
But I am facing those errors:
Any idea ?
Using this references
gpayne
(Greg Payne)
August 29, 2023, 8:19pm
6
Sorry, that was not the working code. Let me look.
itsme
(Rhythem Prajapati)
August 29, 2023, 9:04pm
7
Thank you for your help. I tried this way. It showed no errors but when I try to mark the checkbox to true, it runs but nothing happens:
foreach (var ttJobMtlRow in (from m in ttJobMtl
where (m.RowMod == "A" || m.RowMod == "U") && m.Company == Session.CompanyID
select m))
{
if (!ttJobMtlRow.SendToMtlQueue_c)
{
int MtlQueueSeq1 = 0;
string Bin = "";
string FirstName = "";
string LastName = "";
string RequestedBy = "";
var _SEQT_MtlQueueSeq = (from s in Db.MtlQueue
where s.Company == Session.CompanyID
select s).FirstOrDefault();
if (_SEQT_MtlQueueSeq != null)
{
MtlQueueSeq1 =_SEQT_MtlQueueSeq.MtlQueueSeq + 1 ;
}
var PartBin = (from pb in Db.PartBin
where pb.Company == Session.CompanyID && pb.PartNum == ttJobMtlRow.PartNum
&& pb.WarehouseCode == ttJobMtlRow.WarehouseCode && pb.BinNum == pb.BinNum
select pb).FirstOrDefault();
if (PartBin != null)
{
Bin = PartBin.BinNum;
}
Erp.Contracts.MoveRequestSvcContract hMoveRequest = null;
hMoveRequest = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.MoveRequestSvcContract>(this.Db);
// add a STK-STK material queue record
Erp.Tablesets.MoveRequestTableset ts = new Erp.Tablesets.MoveRequestTableset();
hMoveRequest.GetNewMoveRequest("MI",ref ts);
hMoveRequest.OnChangePartNum(ttJobMtlRow.PartNum, ref ts);
hMoveRequest.OnChangeFromWhse(ttJobMtlRow.WarehouseCode,ref ts);
hMoveRequest.OnChangeFromBin(Bin,ref ts);
hMoveRequest.OnChangeToWhse("GVA WH",ref ts);
hMoveRequest.OnChangeToBin("PROD",ref ts);
ts.MoveRequest[0].RequestQty = ttJobMtlRow.RequiredQty;
ts.MoveRequest[0].PartNum=ttJobMtlRow.PartNum;
ts.MoveRequest[0].UOM=ttJobMtlRow.IUM;
ts.MoveRequest[0].JobNum=ttJobMtlRow.JobNum;
ts.MoveRequest[0].NeedByDate=ttJobMtlRow.ReqDate;
ts.MoveRequest[0].PartDesc=ttJobMtlRow.Description;
ts.MoveRequest[0].EmpId= DcdUserID;
hMoveRequest.ProcessRequest(ref ts);
}
}
gpayne
(Greg Payne)
August 29, 2023, 9:29pm
8
I had lost all of mine, so I am starting over, but you are making more progress than me.
OnChangepartNum needs an out of warehouseList.
string warehouseList;
moveRec.OnChangePartNum(ttJobMtlRow.PartNum,ref mrds, out warehouseList);
itsme
(Rhythem Prajapati)
August 29, 2023, 10:07pm
9
Thank you Greg, looks like I am missing out on something. Shows no error but also does not create request as well.
gpayne
(Greg Payne)
August 29, 2023, 10:24pm
10
I don’t think your condition needs the !.
This routine will create a STK-STK queue.
/* DD JobMtl to Mtl Request Queue */
string Bin = string.Empty;
string empID = string.Empty;
string verifiedID = string.Empty;
Erp.Tables.PartBin PartBin;
Action<string> WT = (msg) =>
{
Ice.Diagnostics.Log.WriteEntry(msg);
};
var mtlQ = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.MaterialQueueSvcContract>(Db);
foreach (var ttJobMtlRow in (from ttJobMtl_Row in ttJobMtl
where (ttJobMtl_Row.Added() || ttJobMtl_Row.Updated()) && ttJobMtl_Row.Company == Session.CompanyID
select ttJobMtl_Row))
{
if ((bool)ttJobMtlRow["CheckBox01"] != true)
{
continue;
}
Ice.Diagnostics.Log.WriteEntry("DEBUG - In create MtlQueue loop ");
var partBin = (from PartBin_Row in Db.PartBin
where PartBin_Row.Company == Session.CompanyID && PartBin_Row.PartNum == ttJobMtlRow.PartNum && PartBin_Row.WarehouseCode == ttJobMtlRow.WarehouseCode
select PartBin_Row.BinNum).FirstOrDefault();
if (partBin != null)
{
Bin = partBin;
Ice.Diagnostics.Log.WriteEntry($"Bin is {Bin} ");
}
var emp = Db.EmpBasic.Where(EmpBasic_Row => EmpBasic_Row.Company == Session.CompanyID && callContextClient.CurrentUserId == EmpBasic_Row.DcdUserID).FirstOrDefault();
if (emp != null)
{
empID = emp.EmpID;
}
else
{
empID = "1234";
}
WT($"Set Emp {empID}");
Erp.Contracts.MoveRequestSvcContract moveRec = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.MoveRequestSvcContract>(Db);
{
Erp.Tablesets.MoveRequestTableset mrds = new Erp.Tablesets.MoveRequestTableset();
moveRec.GetNewMoveRequest("MI", ref mrds);
WT("5:moveRec.GetNewMoveRequest(\"MI\", ref mrds);");
moveRec.VerifyEmpID(empID, out verifiedID);
string empName = "";
moveRec.CheckEmployee(empID, out empName);
mrds.MoveRequest[0].EmpId = empID;
WT($"Get name Emp {empName} id {mrds.MoveRequest[0].EmpId} verified {verifiedID}");
string warehouseList;
moveRec.OnChangePartNum(ttJobMtlRow.PartNum,ref mrds, out warehouseList);
WT("6: moveRec.OnChangePartNum");
moveRec.OnChangeToWhse(ttJobMtlRow.WarehouseCode, ref mrds);
moveRec.OnChangeToBin("NO BIN",ref mrds);
WT("7: moveRec.OnChangeToWhse");
moveRec.OnChangeFromWhse(ttJobMtlRow.WarehouseCode, ref mrds);
moveRec.OnChangeFromBin(Bin,ref mrds);
WT("8: moveRec.OnChangeToBin");
mrds.MoveRequest[0].RequestQty = ttJobMtlRow.RequiredQty;
moveRec.ProcessRequest(ref mrds);
WT("9: moveRec.ProcessRequest");
}
}
itsme
(Rhythem Prajapati)
August 30, 2023, 2:11pm
11
@gpayne , you the man !!
Thank you so much for the code. It is working the way I want.
Only thing is now I am looking to assign backflush binnum(coming from resource group level) to “ToBin” . Is that doable?
gpayne
(Greg Payne)
August 30, 2023, 3:09pm
12
The resourceGrp is on the JobOpDtl of the related operation of this material or if it is zero the the first operation. This should get the bin of the RG of the related operation.
var rgBin = (from resGrp in Db.ResourceGroup
join jod in Db.JobOpDtl
on new { resGrp.Company, resGrp.ResourceGrpID } equals new { jod.Company, jod.ResourceGrpID }
where
jod.Company == ttJobMtlRow.Company && jod.JobNum == ttJobMtlRow.JobNum &&
jod.OprSeq >= ttJobMtlRow.RelatedOperation
orderby jod.OprSeq ascending
select resGrp.BackflushBinNum ?? "").FirstOrDefault();
1 Like
itsme
(Rhythem Prajapati)
August 30, 2023, 7:09pm
13
@gpayne , Perfect.
Thank you again. this worked the way I wanted.