Tuesday, 25 June 2013

SLA periodically to check for multiple postings GL

  SELECT   DISTINCT a.gl_sl_link_id, a.gl_sl_link_table
    FROM   gl_import_references a
   WHERE   (a.gl_sl_link_id, a.gl_sl_link_table) IN
                 (SELECT   DISTINCT gl_sl_link_id, gl_sl_link_table
                    FROM   xla_ae_headers xah, xla_ae_lines xal
                   WHERE       xah.application_id = xal.application_id
                           AND xah.ae_header_id = xal.ae_header_id
                           AND xah.ledger_id = :ledger_id
                           AND xah.application_id = :appl_id -- 200 for AP, 222 for AR etc.
                           AND xah.accounting_entry_status_code = 'F'
                           AND xah.accounting_date BETWEEN :p_start AND :p_end)
           AND EXISTS
                 (SELECT   1
                    FROM   gl_je_headers gh
                   WHERE       gh.je_batch_id = a.je_batch_id
                           AND gh.je_header_id = a.je_header_id
                           AND gh.ledger_id > 0
                           AND NVL (gh.accrual_rev_je_header_id, 0) = 0)
GROUP BY   a.gl_sl_link_id, a.gl_sl_link_table
  HAVING   COUNT ( * ) > 1

No comments:

Post a Comment