FROM dbo.GLTRANS GLT with (nolock) LEFT OUTER JOIN dbo.APDISTRIB APD with (nolock) ON GLT.OBJ_ID = APD.GLT_OBJ_ID AND SYSTEM=''AP''
LEFT OUTER JOIN dbo.APPAYMENT APP with (nolock) ON APD.COMPANY = APP.COMPANY AND APD.VENDOR = APP.VENDOR AND APD.INVOICE = APP.INVOICE AND APD.SUFFIX = APP.SUFFIX AND APD.CANCEL_SEQ = APP.CANCEL_SEQ AND APP.VOID_SEQ=0 LEFT OUTER JOIN dbo.APINVOICE API with (nolock) ON APD.COMPANY = API.COMPANY AND APD.VENDOR = API.VENDOR AND APD.INVOICE = API.INVOICE AND APD.SUFFIX = API.SUFFIX AND APD.CANCEL_SEQ = API.CANCEL_SEQ
LEFT OUTER JOIN dbo.GLNAMES GLN with (nolock) ON APD.COMPANY=GLN.COMPANY AND APD.DIS_ACCT_UNIT=GLN.ACCT_UNIT
LEFT OUTER JOIN dbo.GLCHARTDTL GDT with (nolock) ON APD.DIS_ACCOUNT=GDT.ACCOUNT