Tom:
Your solution gives me the following error:
SQL State: 42836
Vendor Code: -346
Message: [SQL0346] Recursion not allowed for common table expressions. Cause
. . . . . : The common table expression specified is not valid. The
subselect for table TEMP_PSTRUC refers to itself. Recursive common table
expressions are not allowed. Recovery . . . : Change the common table
expressions to refer to a table that exists or a common table expression
that has already been defined. Try the request again.
Processing ended because the highlighted statement did not complete
successfully
-----Original Message-----
From: mapics-l-bounces@xxxxxxxxxxxx [mailto:mapics-l-bounces@xxxxxxxxxxxx]
On Behalf Of Tom E Stieger
Sent: Thursday, May 14, 2009 6:09 PM
To: mapics-l@xxxxxxxxxxxx
Subject: Re: [MAPICS-L] BOM Explosion
Here is an SQL that works to start with.
WITH temp_pstruc (RELVL, ITEM, QTY) AS
(
SELECT 0, PINBR, 0
FROM AMFLIBP/PSTRUC where pinbr like '%5022322%'
UNION ALL SELECT a.relvl + 1, b.cinbr, b.qtypr
FROM temp_pstruc AS a join amflibp/pstruc AS b
on ITEM = b.pinbr
)
SELECT DISTINCT *
FROM temp_pstruc
Here is the resulting data, which is valid based on my source
RELVL ITEM QTY
0 5022322 .000
1 7022322 1.000
1 7022322.1 1.000
1 10566.16 2.000
2 7022322.2 1.000
2 9022322 1.000
2 7022322.3 1.000
2 9022322.1 1.000
It is not quite in the order that I want though. Does anyone know how to get
it to order like this:
RELVL ITEM QTY
0 5022322 .000
1 7022322 1.000
2 7022322.2 1.000
2 9022322 1.000
1 7022322.1 1.000
2 7022322.3 1.000
2 9022322.1 1.000
1 10566.16 2.000
Thanks.
-Tom Stieger
California Fine Wire
Engineer
***DISCLAIMER - Use this SQL at your own risk. I am not responsible if your
recursion loops indefinitely.***
-----Original Message-----
From: mapics-l-bounces@xxxxxxxxxxxx [mailto:mapics-l-bounces@xxxxxxxxxxxx]
On Behalf Of CRPence
Sent: Thursday, May 14, 2009 1:38 PM
To: 'mapics-l@xxxxxxxxxxxx'
Subject: Re: [MAPICS-L] BOM Explosion
My browser is unavailable, but what about searching the web for examples
of recursive SQL queries to do that? I seem to recall running across one or
two when trying to learn about recursive queries. SQL is available on all
IBM i & i5/OS; later releases support recursive queries [with restriction to
the SQL Query Engine; SQE, which means query of the physical file(s) only].
HTH.
Regards, Chuck
Bob Voltz wrote:
<<SNIP>>
I am looking for a program that will do a BOM Explosion and produce
results that match MAPICS Inquiry AMEC72.
It needs to output to a file.
Someone did send me a program that will blow through the BOM, but the
quantities don't match the MAPICS Inquiry AMEC72.
_______________________________________________
This is the MAPICS ERP System Discussion (MAPICS-L) mailing list To post a
message email: MAPICS-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change
list options,
visit:
http://lists.midrange.com/mailman/listinfo/mapics-l
or email: MAPICS-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/mapics-l.
_______________________________________________
This is the MAPICS ERP System Discussion (MAPICS-L) mailing list
To post a message email: MAPICS-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/mapics-l
or email: MAPICS-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
http://archive.midrange.com/mapics-l.
As an Amazon Associate we earn from qualifying purchases.