SQL Query to get First Level Items from Microsoft Dynamics GP Manufacturing BOM

Microsoft Dynamics GPWe’re currently doing some work for a client using the Manufacturing module of Microsoft Dynamics GP and I’ve been involved in the periphery of the manufacturing element while focusing on the financial and distribution parts, but have been assisting with some reporting items. One of them was to help create a report on the Mfg BOM showing only the first level items.

The below script, against the client data, gave the result which was required:

/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */
SELECT ['Mfg Order Master'].MANUFACTUREORDER_I ,['Mfg Order Master'].ITEMNMBR ,['Item Master'].ITEMDESC ,['Mfg Order Master'].ENDQTY_I ,['Inventory U of M Schedule Setup'].BASEUOFM ,['Bill Of Material Line File'].CPN_I FROM WO010032 AS ['Mfg Order Master'] --WO010032 INNER JOIN IV00101 AS ['Item Master'] --Item Master (IV00101) ON ['Item Master'].ITEMNMBR = ['Mfg Order Master'].ITEMNMBR INNER JOIN IV40201 AS ['Inventory U of M Schedule Setup'] --Inventory U of M Schedule Setup (IV40201) ON ['Inventory U of M Schedule Setup'].UOMSCHDL = ['Item Master'].UOMSCHDL INNER JOIN BM010115 AS ['Bill Of Material Line File'] --BM010115 ON ['Bill Of Material Line File'].PPN_I = ['Mfg Order Master'].ITEMNMBR