The blog provides the Oracle EBS R12 SQL get AP cancelled invoices with distribution lines
SELECT AIA.ORG_ID,AIA.INVOICE_ID, AIA.INVOICE_AMOUNT, AIA.GL_DATE, AIA.INVOICE_DATE, NVL(SUM(AIDA.AMOUNT),0) AMOUNT FROM AP_INVOICES_ALL AIA,AP_INVOICE_DISTRIBUTIONS_ALL AIDA WHERE 1=1 --AND AIA.org_id = <ORG_ID_VALUE> AND AIA.INVOICE_ID = AIDA.INVOICE_ID AND AIDA.LINE_TYPE_LOOKUP_CODE NOT IN ('PREPAY') AND AIA.CANCELLED_DATE IS NOT NULL AND ROWNUM <100 GROUP BY AIA.ORG_ID,AIA.INVOICE_ID, AIA.INVOICE_AMOUNT ,AIA.GL_DATE, AIA.INVOICE_DATE HAVING (AIA.INVOICE_AMOUNT <> NVL(SUM(AIDA.AMOUNT),0)) ORDER BY AIA.INVOICE_ID ASC
SELECT * FROM AP_INVOICE_DISTRIBUTIONS_ALL AIDA WHERE AIDA.INVOICE_ID = <INVOICE_ID>