I am building a baq that looks at the part mtl table and pulls out the parent part and mtl part. I then build 5 sub-queries linking mtl part to part num of the next query down. This gives me a blow out of a bom for each parent part.
What I want to do next is link all the subqueries together using a Union or Union all statement like the one below:
The idea is to have all mtl parts listed next to their primary parent part. However, as I click to analyze the Epicor Crashes. Has anyone else done something similar or have an idea on how to get this working?
@Banderson,
How does a CTE work exactly? Ive not used them and would like a quick rundown on what makes them different from an InnerSubQuery. Additionally in this instant would I change all my InnersubQueries to CTE’s?
@Doug.C,
Do you have an example of how this would work? Currently, I have it as a primary InnerSubQuery and I just reuse it and a new PartMtl table to go to the next layer down. Is this close to what you mean?
Look in the tools guide, there is a step example of exactly what you are trying to do. Basically a CTE lets you reference the same query and recursively loop through your data, then it adds all of the rows into a union.
You can make a recursive BOM indenter as mentioned, however, with your current set up the only thing you need to do to make it union is to add several UnionAlls which have the subqueries inside of them. As shown below. I use this method because RecursiveCTE indenters don’t like group by functions in the anchor, and I don’t want duplicates of a part within a level.
The union all basically rolls up whatever fields from what is inside it’s subquery into the subquery. In my instance I roll up all the levels, into Level5 subquery, and then put that subquery into my mainquery. Looks ugly, but it works nice for my application
My appologies! The original post had exactly what I was after. I had accidentally changed a join field from what you originally had. Credit for the solution to you. Thanks to all who participated! Thumbs up all around!