Hi Victoria,
You have been a great help! I have come quite far with the query, just missing a few fields.
Query:
SELECT
LTRIM(RTRIM(gl.JRNENTRY)) 'JournalEntry',
CASE LTRIM(RTRIM(gl.SERIES))
WHEN 2 THEN 'Financial'
WHEN 3 THEN 'Sales'
WHEN 4 THEN 'Purchasing'
END SERIES,
gl.TRXDATE,
LTRIM(RTRIM(a.ACTNUMBR_1)) + '-' +
LTRIM(RTRIM(a.ACTNUMBR_2)) + '-' +
LTRIM(RTRIM(a.ACTNUMBR_3)) + '-' +
LTRIM(RTRIM(a.ACTNUMBR_4)) + '-' +
LTRIM(RTRIM(a.ACTNUMBR_5)) 'AccountNumber',
a.ACTDESCR 'AccountDescription',
gl.DEBITAMT,
gl.CRDTAMNT,
gl.REFRENCE,
gl.DSCRIPTN,
a.ACTNUMBR_2 'MainAccountSegment',
gl.ORMSTRID,
gl.ORMSTRNM,
gl.ORCTRNUM,
gl.DEBITAMT - gl.CRDTAMNT 'Amount',
MONTH(gl.JRNENTRY) 'Month',
CASE LTRIM(RTRIM(a.ACTNUMBR_2))
WHEN 5280 THEN 'FREIGHT-RETURNS'
WHEN 5225 THEN 'FREIGHT-INTERCOMPANY'
WHEN 5260 THEN 'FREIGHT-PURCHASES'
WHEN 5300 THEN 'FREIGHT-SALES'
END SegmentDesc,
'TO DO' 'Location',
LTRIM(RTRIM(a.ACTNUMBR_2)) 'MainSegment',
LTRIM(RTRIM(a.ACTNUMBR_3)) 'Department',
LTRIM(RTRIM(a.ACTNUMBR_4)) 'Sub',
LTRIM(RTRIM(a.ACTNUMBR_3)) + '-' +
LTRIM(RTRIM(a.ACTNUMBR_4)) + '-' +
LTRIM(RTRIM(a.ACTNUMBR_5)) 'Data1',
LTRIM(RTRIM(a.ACTNUMBR_4)) + '-' +
LTRIM(RTRIM(a.ACTNUMBR_5)) 'Data2',
LTRIM(RTRIM(a.ACTNUMBR_5)) 'Data3',
(SELECT ACCATDSC FROM GL00102 WHERE ACCATNUM = a.ACCATNUM) 'P&L_Category'
FROM GL20000 gl
INNER JOIN
GL00100 a
ON LTRIM(RTRIM(a.ACTINDX)) = LTRIM(RTRIM(gl.ACTINDX))
WHERE
LTRIM(RTRIM(a.ACTNUMBR_2)) IN ('5260','5300','5280','5225') AND
gl.SERIES IN (2, 3, 4) AND -- finan, sales, purch
LTRIM(RTRIM(gl.JRNENTRY)) = 215051
I was able to map the "P&L Category", which ended up being GL00100.ACCATNUM, i then mapped it from the legend table GL00102 (which i obtained from your site :) ). I now need to join a PM table to the GL to get "AP Invoice" and "Invoice Amount"...