I’m assuming you have sql backend, if not the table links are the same. Change YOURDATABASE to your actual database and YourCompany to your actual company and enter the gl account details and period as required. I hope this helps. Essentially you need to join the GLJrnDtl to the TranGLC.
FROM YOURDATABASE.Erp.TranGLC RIGHT OUTER JOIN YOURDATABASE.Erp.GLJrnDtl ON TranGLC.Company = GLJrnDtl.Company AND TranGLC.BookID = GLJrnDtl.BookID AND TranGLC.FiscalYear = GLJrnDtl.FiscalYear AND TranGLC.FiscalYearSuffix = GLJrnDtl.FiscalYearSuffix AND TranGLC.JournalCode = GLJrnDtl.JournalCode AND TranGLC.JournalNum = GLJrnDtl.JournalNum AND TranGLC.JournalLine = GLJrnDtl.JournalLine RIGHT OUTER JOIN YOURDATABASE.Erp.GLPeriodBal ON GLJrnDtl.Company = GLPeriodBal.Company AND GLJrnDtl.BookID = GLPeriodBal.BookID AND GLJrnDtl.SegValue1 = GLPeriodBal.SegValue1 AND GLJrnDtl.SegValue2 = GLPeriodBal.SegValue2 AND GLJrnDtl.SegValue3 = GLPeriodBal.SegValue3 AND GLJrnDtl.FiscalYear = GLPeriodBal.FiscalYear AND GLJrnDtl.FiscalYearSuffix = GLPeriodBal.FiscalYearSuffix AND GLJrnDtl.FiscalPeriod = GLPeriodBal.FiscalPeriod
where GLPeriodBal.company = ‘YourCompany’ and GLPeriodBal.SegValue1 = ‘xxxx’ and GLPeriodBal.SegValue2 = ‘xx’ and GLPeriodBal.SegValue3 = ‘xxx’ and GLPeriodBal.FiscalYear = ‘2018’ and GLPeriodBal.FiscalPeriod >= ‘8’ and GLPeriodBal.FiscalPeriod <= ‘8’ and TranGLC.RelatedToFile = ‘APInvExp’
I think you want to use the TranGLC table to support your needs here. The RelatedToFile entry you are looking for is APInvExp. You will use the other fields labeled Key1-4 to support your links back to the AP invc table.