Subledgers(SLA) to AP Invoice Drill Down Script
Select ap.* FROM ap.ap_invoices_all ap
WHERE AP_INVOICES_PKG.GET_POSTING_STATUS(ap.INVOICE_ID)='Y'
AND ap_invoices_pkg.get_approval_status(ap.invoice_id, ap.invoice_amount,ap.payment_status_flag,ap.invoice_type_lookup_code )<>'CANCELLED'
AND ap.gl_date >= :p_start_date
AND ap.gl_date <= :p_to_date
AND NOT EXISTS (Select 1--upg.source_id_int_1,upg.security_id_int_1,sum(NVL(xal.accounted_dr,0) - NVL (xal.accounted_cr,0) ) net_balance
FROM
xla_ae_lines xal,
xla_ae_headers xah,
xla_transaction_entities_upg upg
WHERE 1=1
AND xal.ae_header_id = xah.ae_header_id
AND xah.entity_id = upg.entity_id
AND upg.entity_code = 'AP_INVOICES'
AND upg.source_id_int_1 = ap.invoice_id
AND upg.security_id_int_1 = ap.org_id);