COGS reporting

Looking for any insight.  As far as I can tell there is  not direct report that links COGs to deliveries.  I've created a quick SQL query that provides me the necessary details from GACCENTRYD based on the TYP = stock.  This works for a very base understanding of what summary values are at a GL. What I am having issue completing is joining the SDELIVERYD to GACCENTRYD or A.  The only what I can see to tie the details together is a combination of parsing the DES_0 in GACCENTRYD to pull out what appears to be the SDDLIN_0 or other LIN_0 details from SDELIVERY.  However even if parsed and where clauses applied to limit the GLs to SALES REV and INVENTORY I still get a join failure because there are still some descriptions that fall outside the SDDLIN details.

Any insight how to tie COGS back to STK entries would be much appreciated.  Using Sage X3 V12.