SELECT GCC.CODE_COMBINATION_ID,
GJH.JE_HEADER_ID,
XDL.AE_HEADER_ID,
XDL.AE_LINE_NUM,
XTE.SOURCE_ID_INT_1,
XTE.APPLICATION_ID,
XTE.ENTITY_ID,
GJH.JE_SOURCE,
GJH.JE_CATEGORY,
AIA.GL_DATE,
AP.VENDOR_NAME,
AP.SEGMENT1 SUPPLIER_NO,
XDL.EVENT_CLASS_CODE EVENT_CLASS,
AIA.INVOICE_ID,
AIDA.INVOICE_DISTRIBUTION_ID,
AIA.INVOICE_NUM TRANSACTION_NUMBER,
AIA.INVOICE_DATE,
INITCAP (GJL.DESCRIPTION) DESCRIPTION,
GJL.ACCOUNTED_DR DEBIT,
GJL.ACCOUNTED_CR CREDIT
--NVL (Jl.Accounted_Dr, 0) – NVL(Jl.Accounted_Cr, 0) Net_Amount
FROM GL_JE_HEADERS GJH,
GL_JE_LINES GJL,
GL_CODE_COMBINATIONS GCC,
GL_IMPORT_REFERENCES GIR,
XLA.XLA_AE_LINES XAL,
XLA.XLA_AE_HEADERS XAH,
XLA.XLA_DISTRIBUTION_LINKS XDL,
AP_INVOICES_ALL AIA,
AP_INVOICE_DISTRIBUTIONS_ALL AIDA,
AP_SUPPLIERS AP,
XLA_EVENTS XE,
XLA_TRANSACTION_ENTITIES XTE
WHERE 1=1
AND GJL.JE_HEADER_ID = GJH.JE_HEADER_ID
AND GJL.CODE_COMBINATION_ID = GCC.CODE_COMBINATION_ID
AND GIR.JE_HEADER_ID = GJL.JE_HEADER_ID
AND GIR.JE_LINE_NUM = GJL.JE_LINE_NUM
AND XAL.GL_SL_LINK_ID = GIR.GL_SL_LINK_ID
AND XAL.AE_HEADER_ID = XAH.AE_HEADER_ID
AND XAL.APPLICATION_ID = XAH.APPLICATION_ID
AND XAH.APPLICATION_ID = XE.APPLICATION_ID
AND XAH.EVENT_ID = XE.EVENT_ID
AND XE.APPLICATION_ID = XTE.APPLICATION_ID(+)
AND XE.ENTITY_ID = XTE.ENTITY_ID(+)
AND XDL.AE_HEADER_ID = XAL.AE_HEADER_ID
AND XDL.AE_LINE_NUM = XAL.AE_LINE_NUM
AND XDL.APPLIED_TO_SOURCE_ID_NUM_1 = AIA.INVOICE_ID
AND XDL.SOURCE_DISTRIBUTION_ID_NUM_1 = AIDA.INVOICE_DISTRIBUTION_ID
AND AIDA.INVOICE_ID = AIA.INVOICE_ID
AND AIA.VENDOR_ID = AP.VENDOR_ID
AND AIDA.LINE_TYPE_LOOKUP_CODE = 'ITEM'
AND AIDA.ACCOUNTING_DATE BETWEEN :STARTDATE AND :ENDDATE
--AND GCC.CODE_COMBINATION_ID = 6429
ORDER BY AIA.GL_DATE DESC
GJH.JE_HEADER_ID,
XDL.AE_HEADER_ID,
XDL.AE_LINE_NUM,
XTE.SOURCE_ID_INT_1,
XTE.APPLICATION_ID,
XTE.ENTITY_ID,
GJH.JE_SOURCE,
GJH.JE_CATEGORY,
AIA.GL_DATE,
AP.VENDOR_NAME,
AP.SEGMENT1 SUPPLIER_NO,
XDL.EVENT_CLASS_CODE EVENT_CLASS,
AIA.INVOICE_ID,
AIDA.INVOICE_DISTRIBUTION_ID,
AIA.INVOICE_NUM TRANSACTION_NUMBER,
AIA.INVOICE_DATE,
INITCAP (GJL.DESCRIPTION) DESCRIPTION,
GJL.ACCOUNTED_DR DEBIT,
GJL.ACCOUNTED_CR CREDIT
--NVL (Jl.Accounted_Dr, 0) – NVL(Jl.Accounted_Cr, 0) Net_Amount
FROM GL_JE_HEADERS GJH,
GL_JE_LINES GJL,
GL_CODE_COMBINATIONS GCC,
GL_IMPORT_REFERENCES GIR,
XLA.XLA_AE_LINES XAL,
XLA.XLA_AE_HEADERS XAH,
XLA.XLA_DISTRIBUTION_LINKS XDL,
AP_INVOICES_ALL AIA,
AP_INVOICE_DISTRIBUTIONS_ALL AIDA,
AP_SUPPLIERS AP,
XLA_EVENTS XE,
XLA_TRANSACTION_ENTITIES XTE
WHERE 1=1
AND GJL.JE_HEADER_ID = GJH.JE_HEADER_ID
AND GJL.CODE_COMBINATION_ID = GCC.CODE_COMBINATION_ID
AND GIR.JE_HEADER_ID = GJL.JE_HEADER_ID
AND GIR.JE_LINE_NUM = GJL.JE_LINE_NUM
AND XAL.GL_SL_LINK_ID = GIR.GL_SL_LINK_ID
AND XAL.AE_HEADER_ID = XAH.AE_HEADER_ID
AND XAL.APPLICATION_ID = XAH.APPLICATION_ID
AND XAH.APPLICATION_ID = XE.APPLICATION_ID
AND XAH.EVENT_ID = XE.EVENT_ID
AND XE.APPLICATION_ID = XTE.APPLICATION_ID(+)
AND XE.ENTITY_ID = XTE.ENTITY_ID(+)
AND XDL.AE_HEADER_ID = XAL.AE_HEADER_ID
AND XDL.AE_LINE_NUM = XAL.AE_LINE_NUM
AND XDL.APPLIED_TO_SOURCE_ID_NUM_1 = AIA.INVOICE_ID
AND XDL.SOURCE_DISTRIBUTION_ID_NUM_1 = AIDA.INVOICE_DISTRIBUTION_ID
AND AIDA.INVOICE_ID = AIA.INVOICE_ID
AND AIA.VENDOR_ID = AP.VENDOR_ID
AND AIDA.LINE_TYPE_LOOKUP_CODE = 'ITEM'
AND AIDA.ACCOUNTING_DATE BETWEEN :STARTDATE AND :ENDDATE
--AND GCC.CODE_COMBINATION_ID = 6429
ORDER BY AIA.GL_DATE DESC