Reconcile GL Balances with Journal Totals in Oracle R12

In Oracle General Ledger the period activity in GL_BALANCES should equal the sum of the posted journal lines for the same ledger, account, period and currency. When a trial balance looks wrong, comparing the two shows exactly which accounts are out. The query below calculates PTD from GL_BALANCES and from GL_JE_LINES, joins them by account and period, and returns only the accounts where the two PTD values differ, with the difference.

SQL: GL balances vs journal totals

--balances vs journals
select 
  bl.*, 
  gl.*, 
  gl.ptd - bl.ptd diff 
from 
  (
    select 
      * 
    from 
      (
        SELECT 
          gb.currency_code, 
          gcc.concatenated_segments, 
          SUM(
            nvl(gb.begin_balance_dr, 0) - nvl(gb.begin_balance_cr, 0)
          ) opening_balance, 
          sum(gb.period_net_dr) dr, 
          sum(gb.period_net_cr) cr, 
          sum(
            nvl(gb.period_net_dr, 0) - nvl(gb.period_net_cr, 0)
          ) ptd, 
          SUM(
            nvl(gb.begin_balance_dr, 0) - nvl(gb.begin_balance_cr, 0) +(
              nvl(gb.period_net_dr, 0) - nvl(gb.period_net_cr, 0)
            )
          ) closing_bal, 
          gb.period_name 
        FROM 
          gl_balances gb, 
          gl_code_combinations_kfv gcc 
        WHERE 
          gb.code_combination_id = gcc.code_combination_id -- AND gcc.concatenated_segments = '001.0000.120120.000.000000.0000.000.0000'
          and segment1 = '001' -- and segment3='120120'
          AND gb.ledger_id = 1000
          AND gb.actual_flag = 'A' 
          AND gb.period_name in ('SEP-22') -- AND gb.currency_code = (
          -- SELECT currency_code FROM gl_ledgers
          -- WHERE ledger_id = gb.ledger_id )
        GROUP BY 
          gb.currency_code, 
          gcc.concatenated_segments, 
          gb.period_name
      ) 
    where 
      OPENING_BALANCE<>0 
      or dr<>0
      or cr<>0 
      or ptd<>0 
      or CLOSING_BAL<>0
  ) bl, 
  (
    --balances by journals
    SELECT 
      --gjh.currency_code entered_currency,
      gjh.period_name, 
      gcc.concatenated_segments, 
      sum(
        nvl(gjl.accounted_dr, 0)
      ) dr_ptd, 
      sum(
        nvl(gjl.accounted_cr, 0)
      ) cr_ptd, 
      sum(
        nvl(gjl.accounted_dr, 0) - nvl(gjl.accounted_cr, 0)
      ) ptd, 
      (
        SELECT 
          gl.currency_code 
        FROM 
          apps.gl_ledgers gl 
        WHERE 
          gl.ledger_id = gjh.ledger_id
      ) accounted_cuurency 
    FROM 
      apps.gl_je_headers gjh, 
      apps.gl_je_lines gjl, 
      apps.gl_code_combinations_kfv gcc, 
      apps.gl_je_sources_tl gjst 
    WHERE 
      1 = 1 -- AND gjh.default_effective_date BETWEEN '01-OCT-2022' AND '06-MAR-2023'
      AND gjh.je_source = gjst.je_source_name --AND gjst.user_je_source_name IN ( 'manual', 'spreadsheet' )
      AND gjst.language = 'US' 
      AND gjh.je_header_id = gjl.je_header_id 
      AND gjl.code_combination_id = gcc.code_combination_id 
      AND gcc.segment1 = '001' -- AND gcc.segment3 = '120120'
      AND gjh.ledger_id = 1000
      and gjh.period_name in ('SEP-22') 
    group by 
      --gjh.currency_code,
      gjh.period_name, 
      gjh.ledger_id, 
      gcc.concatenated_segments
  ) gl 
where 
  gl.accounted_cuurency = bl.currency_code 
  and gl.period_name = bl.period_name 
  and gl.concatenated_segments = bl.concatenated_segments 
  and gl.ptd != bl.ptd;

Parameters and notes

  • Set ledger_id, the segment filters and period_name in both inline views.
  • The journal side sums all journals regardless of status. Add AND gjh.status = 'P' and AND gjh.actual_flag = 'A' so it compares like with like; unposted journals are the most common cause of a difference.
  • Summary accounts and translated balances exist only in GL_BALANCES; restrict the balance side to detail accounts and the ledger currency.
  • A remaining difference after that usually points to data corruption or a posting issue and is worth raising with Oracle Support.

Why don’t my GL balances match the journal totals?

Most often because unposted journals are included on the journal side, or because GL_BALANCES rows for other currencies, translated balances or summary accounts are included on the balance side.

Which column holds period activity in GL_BALANCES?

PERIOD_NET_DR and PERIOD_NET_CR. Their difference is the period-to-date (PTD) movement.

Related queries

Related posts: Upload your own post and refer it anywhere anytime:

Leave a Comment