Matching Identical Records in UD Table with Single Release


Good morning,
I am struggling with a complex BAQ. I have a UD table that contains a list of parts, dates, and quantities that the customer wants. We use this table to compare to the existing orders in Epicor. We will add/remove/update releases to match this data file.

Sometimes there is a case where the customer wants three releases on the same day for the same amount. For example, they might want 1 piece on 8/6/24, three times. In the UD02 table it looks like three rows with the same data. I want to match this to the existing data in Epicor. Order/Line/Release are not stored as part of the customer’s UD02 table, so I have to match on just part number, quantity, and date (technically a few others but not relevant here).

The ‘OurOrders’ Subquery is simply a join of the Order tables and displaying the open releases, dates, quantities. You can see how I joined this to the UD02 table in the screenshot. The tricky part is that we are looking at the quantity the customer wants (from UD02), and comparing it to the actual quantity in the release, or the remaining quantity in the release.

If I have three identical records in UD02, and they match a single release from our order tables, then I want to see just the two records that didn’t match the release. The tricky part is that technically all three records match the existing release. So I need a way to have the first match take off the first record from UD02, and then I would only see the two records that didn’t match.

Does this make sense? I am having a hard time putting it into words. If three records in UD02 match a single release in OrderRel, how can I get the BAQ to show me the two remaining records that, while they still match, do not have a corresponding record in OrderRel.

Thank you for your time.

This sounds hard, maybe something with sysrowid.

e1: sysrowid and Windowed functions or some other way to establish a row number for both your UD entries and order releases and match on the row number too?

e2: maybe you dont need sysrowid. Just group by part/date/qty on both sides and tack on a row number with windowed functions.

1 Like

You need another piece of data to match on on both sides, that also identifies the row as unique. This is why my mind went to sysrowid right away, but this doesn’t work. the unique row identfier has to be the same on the UD side and the release side.

You need your releases that have the same part/qty/date to have their own set of row numbers, same thing for your UD entries. And then include your row numbers in the join.

1 Like

I know there are some BAQ / SQL wizards on here who can help you.
But this type of query breaks my brain :face_with_spiral_eyes:

My first thought is to create some subqueries that add a row number to each group of releases and each matching group of UD02 … the resulting row numbers that don’t match would then be reported

2 Likes

This is a great idea

1 Like