MES Report Quantity BPM

I am trying to use a BPM on the Report Quantity Method to stop over reporting qty. My though tis to say if the production qty is less than or equal to current + completed, all good; if false, then error out. However, I can’t seem to get the production qty in the BPM. That seems to require some method with JobHead info or JobMtl. For JobMtl I need the mtlseq which i don’t have in Report Qty method. Any other ideas or ways of getting this done?

We have this at LaborDtl data directive:

Erp.Tables.LaborDtl LaborDtl;
Erp.Tables.LaborDtl LaborDtl1;
Erp.Tables.JobAsmbl JobOpDtl;
string Company = “”;
decimal LaborQty = 0.0m;
decimal LaborQty1 = 0.0m;
decimal LaborQty2 = 0.0m;
int OperationSeq = 0;
int LaborSeqDtl = 0;
decimal ProductionQty = 0.0m;
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))
{
var ttLaborDtlRow = ttLaborDtl_iterator;
if (ttLaborDtlRow.LaborType == “P” )
{
Company = ttLaborDtlRow.Company;
LaborSeqDtl = ttLaborDtlRow.LaborDtlSeq;
LaborQty = ttLaborDtlRow.LaborQty;
JobOpDtl = (from JobOpDtl_Row in Db.JobAsmbl
where string.Compare(JobOpDtl_Row.Company,ttLaborDtlRow.Company, true) == 0 &&
JobOpDtl_Row.JobNum == ttLaborDtlRow.JobNum && JobOpDtl_Row.AssemblySeq == ttLaborDtlRow.AssemblySeq
select JobOpDtl_Row).FirstOrDefault();
if (JobOpDtl != null)
{
ProductionQty = JobOpDtl.RequiredQty;
}
foreach (var LaborDtl1_iterator in (from LaborDtl1_Row in Db.LaborDtl
where LaborDtl1_Row.Company == Company && LaborDtl1_Row.JobNum == ttLaborDtlRow.JobNum && LaborDtl1_Row.AssemblySeq == ttLaborDtlRow.AssemblySeq && LaborDtl1_Row.OprSeq == ttLaborDtlRow.OprSeq && LaborSeqDtl != LaborDtl1_Row.LaborDtlSeq
select LaborDtl1_Row))
{
LaborDtl1 = LaborDtl1_iterator;

					       LaborQty2 =  LaborQty2 + LaborDtl1.LaborQty;     
					   
					   }
LaborQty2 = LaborQty2 + LaborQty;

if (LaborQty2 > ProductionQty)
{
     object THROW_PRIVATE = null;
           CallContext.Current.ExceptionManager.AddBLException("Labor qty would not be more than production qty.");
           THROW_PRIVATE = null;
} 

}
}

I made some changes where needed and am still getting one error I can’t figure out…

Operator ‘==’ cannot be applied to operands of type ‘string’ and ‘char’

Make sure you have regular quotes here. Without encoding the code in the post with the CS block, it converted it into the “formatted” open/closed quotes.

```CS
string Company = "";
...
if (ttLaborDtlRow.LaborType == "P" )
```
1 Like

So have those fixed, but still getting these errors. Here are picks of what I have and the errors.


image

This is what you have:

string Company = '???';
...
if (ttLaborDtlRow.LaborType == 'P' )

It should be

string Company = "???";
...
if (ttLaborDtlRow.LaborType == "P" )

The single quote (') is used for the character data type in C#, the double quote (") is used for strings.

Ok…got it! Made those changes, and have this final little bugger.

image

You only have one = in the test for “P” … it needs to be ==

It should be

if (ttLaborDtlRow.LaborType == "P" )

@Doug.C @itsme

Thanks! Lastly, did you use any rules with the
custom code? I’m thinking just use the standard Once passing all matching rows.

Actually, I’ve been relooking over and had another question. First, I am not super sharp on coding. With that being said, do I need to take LaborDtl1or anything else a variable on the variables tab of the Custom code?

I’m asking because it doesn’t seem to work. I am using an in transaction Data Directive on LaborDtl.

Going to try to pass this to a variable and see how that works. Hoping this will work. Still learning coding…

UPDATE: This only returns false for everything. There is something wrong on the LaborDtl1 = LaborDtl1_iterator;

             LaborQty2 =  LaborQty2 + LaborDtl1.LaborQty;     
         
         }

LaborQty2 = LaborQty2 + LaborQty;

but not sure where. Any help is appreciated.

Erp.Tables.LaborDtl LaborDtl;
Erp.Tables.LaborDtl LaborDtl1;
Erp.Tables.JobAsmbl JobOpDtl;
string Company = "";
decimal LaborQty = 0.0m;
decimal LaborQty1 = 0.0m;
decimal LaborQty2 = 0.0m;
int OperationSeq = 0;
int LaborSeqDtl = 0;
decimal ProductionQty = 0.0m;
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))
{
var ttLaborDtlRow = ttLaborDtl_iterator;
if (ttLaborDtlRow.LaborType == "P")
{
Company = ttLaborDtlRow.Company;
LaborSeqDtl = ttLaborDtlRow.LaborDtlSeq;
LaborQty = ttLaborDtlRow.LaborQty;
JobOpDtl = (from JobOpDtl_Row in Db.JobAsmbl
where string.Compare(JobOpDtl_Row.Company,ttLaborDtlRow.Company, true) == 0 &&
JobOpDtl_Row.JobNum == ttLaborDtlRow.JobNum && JobOpDtl_Row.AssemblySeq == ttLaborDtlRow.AssemblySeq
select JobOpDtl_Row).FirstOrDefault();
if (JobOpDtl != null)
{
ProductionQty = JobOpDtl.RequiredQty;
}
foreach (var LaborDtl1_iterator in (from LaborDtl1_Row in Db.LaborDtl
where LaborDtl1_Row.Company == Company && LaborDtl1_Row.JobNum == ttLaborDtlRow.JobNum && LaborDtl1_Row.AssemblySeq == ttLaborDtlRow.AssemblySeq && LaborDtl1_Row.OprSeq == ttLaborDtlRow.OprSeq && LaborSeqDtl != LaborDtl1_Row.LaborDtlSeq
select LaborDtl1_Row))
{
LaborDtl1 = LaborDtl1_iterator;

                 LaborQty2 =  LaborQty2 + LaborDtl1.LaborQty;     
             
             }
LaborQty2 = LaborQty2 + LaborQty;
bool Overs;

if (LaborQty2 > ProductionQty)
{
     Overs = true;
} 
else
{
  Overs = false;
}
}
}

It looks like LaborDtl1 is a table, and ttLaborDtl1_iterator is a row, that might be where your problem is, I’m not sure.