BPM making sure material is issued before receipt to inventory

,

Another coding question. I had a BPM working in E9 that would stop receipt to inventory if all material was not issued to the job. I put it through the C converter from Epicor and it is now giving me the error that PCjobnum does not exist.

ReceiptsFromMfg.GetNewReceiptsFromMfgJobAsm

Pre-Processing

Synchronously execute code

After C# Conversion:

string MSG = string.Empty;
string ClassList = "WTOO, WTES, WQUA,WPLY,WLAY,WCOR,WASY,COMP,ADH,CON,CONE, CORE,FRZ,HDW,PAIN,TOOL";
Erp.Tables.JobMtl JobMtl;
Erp.Tables.Part Part;
foreach (var JobMtl_iterator in (from JobMtl_Row in Db.JobMtl
                                 where string.Compare(JobMtl_Row.Company ,"CHS" ,true)==0&& JobMtl_Row.JobNum == PCjobnum && JobMtl_Row.AssemblySeq == JobMtl_Row.AssemblySeq && JobMtl_Row.MtlSeq == JobMtl_Row.MtlSeq
                                 select JobMtl_Row))
{
    JobMtl = JobMtl_iterator;
    foreach (var Part_iterator in (from Part_Row in Db.Part
                                   where Part_Row.Company == JobMtl.Company && Part_Row.PartNum == JobMtl.PartNum
                                   select Part_Row))
    {
        Part = Part_iterator;
        if (ClassList.Lookup(Part.ClassID) != -1 && JobMtl.IssuedQty == 0)
        {
            MSG = MSG + "\n" + JobMtl.PartNum;
        }
    }
}
if (!String.IsNullOrEmpty(MSG))
{
    MSG = "The following parts have not been issued and so you cannot continue" + MSG;
CallContext.Current.ExceptionManager.AddBLException(MSG);
}

I think your BPM could be done just using widgets. The condition widget would do a query of the Job, for JobMtl’s that aren’t marked Issued Complete.

Try changing PCjobnum to pcJobNum

Right click in the Code window to see the available parameters.
image

Also…

What is the purpose of the following in the foreach(JobMtl ...) query?

&& JobMtl_Row.AssemblySeq == JobMtl_Row.AssemblySeq 
&& JobMtl_Row.MtlSeq == JobMtl_Row.MtlSeq

Those will always be true.

1 Like

Thanks. I will try. It had to be code in 9 so I didn’t even think to try 🤦

See my second reply for how to make your code work. The first suggestion doesn’t provide the feedback of which parts are not yet issued complete.

1 Like

Hi,
That worked. I didn’t know I could right click, that’s going to be very helpful :slight_smile: I don’t know why those lines are there, a co-worker wrote the original code.

You need to update your epiusers.help profile…

image
:wink:

1 Like

Hello, can you share your BPM? Thank you and may you be happy every day

string MSG = string.Empty;
string ClassList = "WTOO,WTES,WQUA,WPLY,WLAY,WCOR,WASY,COMP,CORE,FRZ,HDW";
Erp.Tables.JobMtl JobMtl;
Erp.Tables.Part Part;
foreach (var JobMtl_iterator in (from JobMtl_Row in Db.JobMtl
                                 where string.Compare(JobMtl_Row.Company ,"CHS" ,true)==0&& JobMtl_Row.JobNum == pcJobNum && JobMtl_Row.AssemblySeq == JobMtl_Row.AssemblySeq && JobMtl_Row.MtlSeq == JobMtl_Row.MtlSeq
                                 select JobMtl_Row))
{
    JobMtl = JobMtl_iterator;
    foreach (var Part_iterator in (from Part_Row in Db.Part
                                   where Part_Row.Company == JobMtl.Company && Part_Row.PartNum == JobMtl.PartNum
                                   select Part_Row))
    {
        Part = Part_iterator;
        if (ClassList.Lookup(Part.ClassID) != -1 && JobMtl.IssuedQty == 0 && JobMtl.QtyPer != 0)
        {
            MSG = MSG + "\n" + JobMtl.PartNum;
        }
    }
}
if (!String.IsNullOrEmpty(MSG))
{
    MSG = "The following parts have not been issued and so you cannot continue" + MSG;
CallContext.Current.ExceptionManager.AddBLException(MSG);
}

I had no luck, it wasn’t working,Thanks. I will try.