BPM to prevent over-receiving a PO

Yes, I see that this has been discussedbefore.

But I found some flaws in the logic as I tried to break the system.

A big problem is if you change the supplier UOM on the PO midway through the process. In the pic below, I had started with 720 EA (suppler qty), arrived/received more than half of that, and then switched the PO to 360 PR (supplier qty).

And then the system gets really confused! It thinks 426 [somethings] have been “arrived.” but that’s not helpful, as it was 420 EA and 6 PR - which is 432 EA or 216 PR.

This even thwarts the built-in warning message. It said on line 5 in the pic that I was receiving more than the qty ordered, but that’s not true. Yes, 426 > 360, but it should be comparing 432 EA < 720 EA or some equivalent.

So, all of that to say, has anyone by chance licked this problem in its entirety? The solutions I saw here didn’t seem to address this level of calculation.

And since the PO release numbers are flawed, I can’t use those in a BPM/function as I had hoped. I would have to find a way to convert all receipts to a single UOM and then total them and THEN see if the current receipt exceeds that. Oy.

1 Like

I am trying to do this now. Is there a simple way to sum all rows of a field?

Thus far I have succeeded in

  1. RcvDtlSearch.GetRows for the given PO/Line/Rel
  2. Resulting dataset is variable that I named dsReceipts
  3. Made an integer variable that is set to dsReceipts.RcvDtl.Count

So that’s cool - you can do an aggregate (kind of; not really) in a simple variable without a loop or anything. Took me a while to work out the syntax, but I got there.

But I don’t really want the count, I want the sum of a field (well, a calculation, but one step at a time!).

Is there a way to do that in a line of code in a widget like I did with count? You know, something like dsReceipts.RcvDtl.sum(OurQty)

Failing that, is there a way to reference the row number of the dataset? Since I have the count, I was thinking a loop like this. Naturally, this syntax does not actually work, but I was hoping there was a way to call out the row number.

image

@Evan_Purdy You’re the widget guru, right?

I’ve held out from learning meaningful C# this long!

have you tried dsReceipt.RcvDtl.OurQty.sum() ? Or dsReceipt.RcvDtl.Sum(x => x.OurQty) ?

3 Likes

YES! You rock @A.Baeisa

The second one did it:

image

Now I need to convert the quantities to base or something, etc. But woohoo!

(No to the first one, FYI):

pic

1 Like

good to know mate,

could you elaborate on this ?

Sure. What I accomplished with summing “OurQty” was the orange column from my first post. That’s actually not useful itself to add the raw numbers in 3 different UOMs. What I need is the sum of the blue column. But - that does not exist. “This Transaction Qty” is not a real field in RcvDtl. So… looks like I will need to get creative.

Any thoughts?

if ThisTransactionQty is not a database value then it is for sure ttThisTransactionQty within this data set, so use it straight a way to do your comparison, i have done something similar with Quote Break Qty Cost values.

1 Like

Ooh, interesting. That raises some questions, though.

So, this compiles (or whatever) but returns zero (in sum, anyway).

image

Just to clarify here, this is not itself a BPM. It’s an Epicor Function, and I am testing it in hopes of using it in a Data Directive (BPM).

So perhaps that is why I get zero, because I am not transacting?

But I don’t think I buy that, because I am indeed invoking the BO. And Receipt Tracker, for example, shows This Transaction Qty and it is certainly not mid-transaction.

@A.Baeisa Let me do some tracing and see if I can figure why I get zero, before I bother you much more. Also, it’s about quitting time in the UK, no?

Alright, I think we got it!

image

So, I had been using the BO of RcvDtlSearch (seemed like it would be less bloated), but in fact I needed Receipt instead, in order to get that “transaction” quantity.

Still more work to do, but huzzah! Go @A.Baeisa !

To reiterate, this code did work just fine if you use the right BO:

image

By the way,

RcvDtlSearch parameters

vs.

Receipt paraneters

Well, it gets it done, at least.

one note… when creating a BPM to monitor this, remember that there are two ways to create a receipt line…

  1. you can create one receipt detail at a time
  2. you can do a Mass Receipt.

These two methods call two different business objects, and therefore, your BPM needs to run two different ways. This might be a time to consider creating a FUNCTION, and then call the function from both BPMs to reduce the amount of code.

1 Like

And here begins the wild task of trying to build a BPM to stop something. I forget what it was, maybe something on order entry, where they asked to stop the action of adding a line or something related to adding an order line… It became a huge task to try and record all the different ways to create an order line and then have to trace them all and build the bpm to stop each bo method.

Yup… from order entry, you can retrieve a quote line, you can duplicate an order, you can manually enter a line… from Quotes, you can push the entire quote. ECC can also create quotes. I am sure that there are others. in the end, you must trap each one separately because they each use a differing business object. Before Epicor functions, you had to duplicate the code over and over again… but now, you could create one function that you pass data to for any validation, and then have the separate BPMs handle the calling of the function.

2 Likes

Still, you have to call the function from all the separate bo methods. Great that you can re-use the same code though! I love functions!

@timshuwy I agree. :point_up_2:

sorry @JasonMcD, yes i finish 4:00pm UK time, i am back now so good morning :grin:, i am going through your messages / posts now

ok, now the tt table will hold the value of any -on the fly- field which in transaction i.e. row status A or U, but the problem you will face that you need this value for the other recept lines to do your comparison i.e. from the lines that not in transaction i.e. Database thereby this value does not exist for those lines, am i correct ?

No, actually it does, thankfully. It’s there is receipt tracker, so I did the trace on it and saw it used the Receipt BO, and so I used that, too.

so problem solved ?

@A.Baeisa Well, this leg of it is resolved, definitely, thanks to you.

Now I’m on to the check against ordered quantity (is tran qty > ordered qty), and is this a delete or are they modifying an existing receipt or is it a new receipt, etc. Normal problems. I’ll keep updating as I progress.

1 Like