# E9 help with BAQ calculated field

I thought I knew how to do this but am not getting the desired result. Trying to figure out if jobmaterials are short. Basically, if there isn’t enough issued or onhand, it’s short, else it’s zero. Sort of like backorder unless there is enough in stock to cover.

if JobMtl.RequiredQty - JobMtl.IssuedQty - PartWhse.OnHandQty > 0
then JobMtl.RequiredQty - JobMtl.IssuedQty

else 0

It returns 0 no matter what:
eg
10 - 0 - 5 = 5 Short - not enough in stock to over

10 - 0 - 10 = 0 Not Short - enough in stock to cover

I do a similar exercise to what you’re doing as a BPM when an operation is completed to ensure that the job issued material is equal to the required quantity. Granted, that won’t work for everyone, but in our situation it works well.

Are you aware of the PPlan tables? I haven’t played with them a whole lot but they seem to exist to help identify part shortages on jobs and help to assign priority/resolution for those shortages.

If you can send a screenshot of your BAQ I’d also be happy to take a look at what you have.

When calculated values aren’t making sense, I like to break the component values out individually, easier (for me) to see what is going on.
e.g. 3 calculated fields instead of 1

cOpenQty
if (JobMtl.RequiredQty - JobMtl.IssuedQty) > 0
then JobMtl.RequiredQty - JobMtl.IssuedQty
else 0

cOnHandQty
If PartWhse.OnHandQty > 0
then PartWhse.OnHandQty
else 0

cShortQty
If cOnHand > cOpenQty
then 0
else cOpenQty - cOnHand

And verify my table joins, criteria e.g.

each JobAsmbl