GL Journal Lines Extract for a Particular Account in Oracle R12

To see every journal line that hit a particular account in Oracle General Ledger R12, join GL_JE_HEADERS and GL_JE_LINES to GL_CODE_COMBINATIONS_KFV and filter on the account segments. The query below also returns the journal source and category names, the journal and line descriptions, whether the account was debited or credited, and the entered and accounted amounts with both currencies. It is the backend equivalent of drilling from Account Inquiry to journal details.

SQL: journal lines for an account

--journal details
SELECT 
  gjst.user_je_source_name source, 
  (
    SELECT 
      gjct.user_je_category_name 
    FROM 
      apps.gl_je_categories_tl gjct 
    WHERE 
      gjh.je_category = gjct.je_category_name 
      AND language = 'US'
  ) category, 
  gjh.name batch_name, 
  gjh.description header_description, 
  gjl.je_line_num, 
  gjl.description line_description, 
  CASE WHEN gjl.entered_dr IS NOT NULL THEN gcc.concatenated_segments END debit_account_string, 
  CASE WHEN gjl.entered_cr IS NOT NULL THEN gcc.concatenated_segments END credit_account_string, 
  gjh.currency_code entered_currency, 
  gjl.entered_dr, 
  gjl.entered_cr, 
  gjl.accounted_dr, 
  gjl.accounted_cr, 
  (
    SELECT 
      gl.currency_code 
    FROM 
      apps.gl_ledgers gl 
    WHERE 
      gl.ledger_id = gjh.ledger_id
  ) accounted_cuurency, 
  gjh.period_name 
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 
ORDER BY 
  1, 
  3, 
  5;

Parameters to change

  • gcc.segment1 = '001' and gcc.segment3 = '120120': your company and natural account values (or filter on concatenated_segments).
  • gjh.ledger_id = 1000: your ledger ID.
  • default_effective_date BETWEEN ...: your date range. Use TO_DATE('01-OCT-2022','DD-MON-YYYY') to avoid depending on the session date format, or filter on gjh.period_name instead.
  • Uncomment the user_je_source_name IN ('manual','spreadsheet') filter to see only manual or ADI journals.

Notes

  • The query returns journals in every status. Add AND gjh.status = 'P' for posted journals only, so totals match balances.
  • GJH.NAME is the journal name; join GL_JE_BATCHES on JE_BATCH_ID for the batch name.
  • For journals that came from subledgers, follow GL_IMPORT_REFERENCES back to SLA to find the source transaction.

Which tables store GL journals in Oracle R12?

GL_JE_BATCHES (batches), GL_JE_HEADERS (journals) and GL_JE_LINES (lines). Sources and categories are in GL_JE_SOURCES_TL and GL_JE_CATEGORIES_TL.

How do I get only posted journal lines?

Filter GL_JE_HEADERS.STATUS = ‘P’. Unposted journals have status U.

Related queries

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

Leave a Comment