Archives

Wednesday, April 11, 2018

How to find AP Invoices based on a GL Batch

  SELECT source_id_int_1 invoice_id,
         '''' || transaction_number invoice_number,
         SUM (e.accounted_cr) amount,
         h.segment1 vendor#,
         i.vendor_site_code,
         l.bank_account_name bank_acct_on_check
    FROM apps.gl_import_references a,
         apps.gl_je_headers b,
         apps.gl_je_batches c,
         apps.xla_ae_headers d,
         apps.xla_ae_lines e,
         xla.xla_transaction_entities f,
         apps.ap_invoices_all g,
         apps.po_vendors h,
         apps.po_vendor_sites_all i,
         apps.ap_invoice_payments_all j,
         apps.ap_checks_all l
   WHERE     a.je_header_id = b.je_header_id
         AND b.je_batch_id = c.je_batch_id
         AND a.gl_sl_link_id = e.gl_sl_link_id
         AND e.ae_header_id = d.ae_header_id
         AND d.entity_id = f.entity_id
         AND g.invoice_id = f.source_id_int_1
         AND g.vendor_id = h.vendor_id
         AND g.vendor_site_id = i.vendor_site_id
         AND h.vendor_id = i.vendor_id
         AND f.source_id_int_1 = j.invoice_id(+)
         AND l.check_id(+) = j.check_id
         AND e.accounting_class_code = 'LIABILITY'
         AND c.name = '&batchname'
         -------------------AND g.accts_pay_code_combination_id = 878589
GROUP BY c.name,
         transaction_number,
         g.accts_pay_code_combination_id,
         i.vendor_site_code,
         h.segment1,
         source_id_int_1,
         l.bank_account_name
ORDER BY 6;
         

No comments:

Post a Comment