Hello Experts,
Currently, we use Backflush for all job materials.
We want to prevent users from starting a job if the resource group for the operation has a backflush warehouse and bin assigned. The system should check the on-hand quantity for all materials related to that operation in the job. If the required quantity is greater than or equal to the on-hand quantity, an error should be triggered.
Is this feasible? We have successfully prevented users from starting a job when the on-hand balance goes negative using the code below. Now, we want to extend this to include consideration of the backflush warehouse and bin assigned at the resource level.
Erp.Tables.JobMtl JobMtl; //Table to fetch matetial detail
// Erp.Tables.LaborDtl LaborDtl; //table to fetch operation complete qty detila
Erp.Tables.PlantWhse PlantWhse; // table to fetch operation qty
int Count = 0;
int Count1 = 0;
string JobNum;
string Company;
string PartNumStkInfo;
int OprSeq;
int AssemblySeq;
decimal LaborQty = 0.0m;
decimal LaborQty1 = 0.0m;
decimal LaborQty2 = 0.0m;
decimal vQtyper= 0.0m;
decimal ProductionQty= 0.0m;
{
/Fetch Data from Current Transactions************/
foreach (var ttLaborDtl_iterator in (from ttLaborDtl_Row in ttLaborDtl
where (string.Equals(ttLaborDtl_Row.RowMod, IceRow.ROWSTATE_ADDED, StringComparison.OrdinalIgnoreCase) ||
string.Equals(ttLaborDtl_Row.RowMod, IceRow.ROWSTATE_UPDATED, StringComparison.OrdinalIgnoreCase))
select ttLaborDtl_Row))
if ((ttLaborDtl_iterator.LaborQty+ttLaborDtl_iterator.ScrapQty+ ttLaborDtl_iterator.DiscrepQty) > 0)
{ {
JobNum = ttLaborDtl_iterator.JobNum;
Company = ttLaborDtl_iterator.Company;
foreach( var JobMtl_db_iterator in (from JobMtl_Row in Db.JobMtl
where string.Compare(JobMtl_Row.Company,ttLaborDtl_iterator.Company, true) == 0 &&
JobMtl_Row.JobNum == ttLaborDtl_iterator.JobNum
&& JobMtl_Row.BackFlush==true && JobMtl_Row.IssuedComplete == false && JobMtl_Row.RelatedOperation == ttLaborDtl_iterator.OprSeq
select JobMtl_Row))
{
Count1 = Count1+1; //Using this variable to count no of cursor records
PartNumStkInfo=JobMtl_db_iterator.PartNum; //Using this variable to Store all Part Number from cursor
//Handle Job fixed Qty
if (JobMtl_db_iterator.FixedQty==true)
{
vQtyper=JobMtl_db_iterator.QtyPer;
}
else
{
vQtyper=((ttLaborDtl_iterator.LaborQty+ttLaborDtl_iterator.ScrapQty+ ttLaborDtl_iterator.DiscrepQty)JobMtl_db_iterator.QtyPer);
}
/end*****************/
/Verify Part Stock In Primary BIN****************/
foreach (var PartStk_iterator in (from PlantWhs_Row in Db.PlantWhse
join PartBin_Row in Db.PartBin on (PlantWhs_Row.PartNum+PlantWhs_Row.PrimBin+PlantWhs_Row.WarehouseCode) equals (PartBin_Row.PartNum+PartBin_Row.BinNum+PartBin_Row.WarehouseCode)
join PartPlant_Row in Db.PartPlant on (PartBin_Row.WarehouseCode+PartBin_Row.PartNum) equals (PartPlant_Row.PrimWhse+PartPlant_Row.PartNum)
where string.Compare(PlantWhs_Row.Company, Company, true) == 0
&& PlantWhs_Row.PartNum==JobMtl_db_iterator.PartNum
&& PlantWhs_Row.PrimBin==PartBin_Row.BinNum
&& PlantWhs_Row.PrimBin !=“”
&& PartBin_Row.OnhandQty >=vQtyper
select PlantWhs_Row))
{
PartNumStkInfo=“”; //Clear Part Number from variable if stock exists
Count = Count+1;
}
/End Loop*******************/
if (PartNumStkInfo!=“”) //
{
PartInfo=PartInfo+" ,"+PartNumStkInfo; //Store Part into BPM Variable if stock not exists
}
}
}
if (Count !=Count1 ) //Check If All Part have Stock Or Not
{
BackFlushMtlBool1=true; //Assign Value to BPM Variable
}
else
{
BackFlushMtlBool1=false;
}
}
Thank you for your time and taken this post into consideration.