Wednesday, October 19, 2016

How To Check Journal from SLA that has Transfer Flag Y but not exist in GL

You can check by using query below:

--1 Cek Combination ID
SELECT gck.concatenated_segments receiving_insp_account,
       gck.code_combination_id recv_insp_account_id
  FROM gl_code_combinations_kfv gck
 WHERE concatenated_segments = '301.2019900000.000.0000000000.0000.0000.00000.0000'--512342

--2 Cek Ledger ID
select *
  from gl_ledgers --2103 JMK --2022 BPS

select gl_flexfields_pkg.get_concat_description
                                           (chart_of_accounts_id,
                                            code_combination_id)
                                          from gl_code_combinations

--3 Transfer Flag Y but not exist in GL
SELECT h.ledger_id,
       l.ae_header_id,
       h.accounting_date,
       h.period_name,
       h.entity_id,
       l.gl_sl_link_id,
       l.gl_sl_link_table,
       l.ACCOUNTED_DR,
       l.ACCOUNTED_CR,
       l.CODE_COMBINATION_ID,       gcc.segment1||'.'||gcc.segment2||'.'||gcc.segment3||'.'||gcc.segment4||'.'||gcc.segment5||'.'||gcc.segment6||'.'||gcc.segment7||'.'||gcc.segment8 account,
       gcc.segment2,
       gl_flexfields_pkg.get_concat_description
                                           (gcc.chart_of_accounts_id,
                                            gcc.code_combination_id
                                           ) description,
       gl_flexfields_pkg.get_description_sql  
                                      (gcc.chart_of_accounts_id,--- chart of account id  
                                       2,----- Position of segment  
                                       gcc.segment2 ---- Segment value  
                                      )account_description                                         
  FROM xla_ae_lines l,
       xla_ae_headers h,
       gl_code_combinations gcc
 WHERE 1=1
   and gcc.CODE_COMBINATION_ID = l.CODE_COMBINATION_ID
   and l.application_id = h.application_id
   AND l.ae_header_id = h.ae_header_id
   AND h.application_id = &p_application_id
--   and l.code_combination_id=&p_account_id
   AND h.ledger_id IN (SELECT   gled.ledger_id
                           FROM gl_ledger_relationships glr,
                                gl_ledgers gled
                          WHERE glr.primary_ledger_id = &p_ledger_id
                            AND glr.application_id = 101
                            AND (   (    glr.target_ledger_category_code IN ('SECONDARY', 'ALC')
                                     AND glr.relationship_type_code = 'SUBLEDGER')
                                 OR (    glr.target_ledger_category_code IN ('PRIMARY')
                                     AND glr.relationship_type_code = 'NONE')
                                )
                            AND glr.target_ledger_id = gled.ledger_id
                            AND NVL (gled.complete_flag, 'Y') = 'Y'
                       GROUP BY gled.ledger_id)
   AND (   h.upg_batch_id IS NULL
        OR h.upg_batch_id = -9999)
   AND l.gl_sl_link_id IS NOT NULL
   AND h.gl_transfer_status_code = 'Y'
   AND h.accounting_entry_status_code = 'F'
   and nvl(l.ACCOUNTED_DR,0) - nvl(l.ACCOUNTED_CR,0) <>0
   --and l.AE_HEADER_ID in ('4059629')
   AND h.accounting_date BETWEEN TO_DATE ('&p_start_date', 'DD-MON-YYYY') AND TO_DATE ('&p_end_date', 'DD-MON-YYYY')
   AND NOT EXISTS (SELECT 1
                     FROM gl_import_references ir,
                          gl_je_headers gh
                    WHERE ir.gl_sl_link_id = l.gl_sl_link_id
                      AND ir.gl_sl_link_table = l.gl_sl_link_table
                      AND ir.je_header_id = gh.je_header_id
                      AND ir.je_batch_id = gh.je_batch_id
                      AND gh.ledger_id = h.ledger_id)
    order by l.AE_HEADER_ID                  ;

No comments:

Post a Comment