GL Journal Extraction SQL Query in Oracle EBS and Oracle Fusion

Introduction

                           Extracting General Ledger (GL) journal data is one of the most common and essential tasks in both Oracle E-Business Suite (EBS) and Oracle Fusion environments. Whether you're supporting reconciliation, audit reporting, or building a custom data integration, this detailed SQL helps you fetch journal entries, ledger information, accounting amounts, project attributes, and line-level details in one go.

Use Case

This GL journal extraction query is helpful when:

  • Users want detailed journal information including batch, header, line, and segment details.

  • Auditors or finance teams request transactional history within a specific ledger or period.

  • Custom reporting or reconciliation processes are being built in BI Publisher, OTBI, or any third-party reporting tools.


SQL Query:

SELECT
    gl.ledger_id,
    TO_CHAR(gjh.default_effective_date,'YYYY/MM/DD') default_effective_date,
    gjh.je_source,
    gjh.je_category,
    gjh.currency_code                                                 Currency_Code,
    TO_CHAR(gjh.date_created,'YYYY/MM/DD')  Creation_Date,
    gjh.actual_flag                                                       Actual_Flag,
    gcc.segment1,
    gcc.segment2,
    gcc.segment3,
    gcc.segment4,
    gcc.segment5,
    gcc.segment6,
    gcc.segment7,
    gcc.segment8,
    gcc.segment9,
    ROUND(gjl.ENTERED_DR,2)         Entered_Debit_Amount,
    ROUND(gjl.ENTERED_CR,2)         Entered_Credit_Amount,
    ROUND(gjl.accounted_dr,2)             Converted_Debit_Amount,
    ROUND(gjl.accounted_cr,2)             Converted_Credit_Amount,
    gjb.name                                             REFERENCE1_Batch_Name,
    gjb.description                                    REFERENCE2_Batch_Description,
    gjl.description                 REFERENCE10_Line_Description,
    gjh.currency_conversion_type,
    gjh.currency_conversion_date,
    gjh.currency_conversion_rate,
    gjl.attribute11          DOC_SEQUENCE_VALUE,
    gjl.attribute12          attribute_currency_type,
    gjl.attribute13          project_segment,
    gjl.attribute14          project_desc,
    gl.name                  Ledger_Name,
    gjh.ENCUMBRANCE_TYPE_ID Encumbrance_Type_ID,
    gjl.period_name             Period_Name,
    gjb.je_batch_id,
    gjh.je_header_id,
    gjl.je_line_num

--add columns needed 

FROM
gl_je_batches gjb,
gl_je_headers gjh,
gl_je_lines gjl,
gl_code_combinations gcc,
gl_ledgers gl,
gl_periods gp

--add tables needed 

WHERE
1 = 1
AND gjb.je_batch_id = gjh.je_batch_id
AND gjh.status = 'P'
AND gjh.je_header_id = gjl.je_header_id
AND gjh.actual_flag = 'A'
AND gjl.code_combination_id = gcc.code_combination_id
AND gjl.ledger_id = gl.ledger_id
AND gjl.period_name = gp.period_name
AND gp.period_set_name = 'give set name here'
AND gp.adjustment_period_flag = 'N'
AND gl.name = :p_ledger_name
        AND gjh.je_source = NVL(:p_source, gjh.je_source)
AND gcc.segment1 = :p_company
AND gp.period_year = NVL(:p_year, gp.period_year)
        AND (gjl.period_name IN (:p_period) OR 'All' IN ('All' || :p_period))
AND TRUNC(gjl.effective_date) BETWEEN NVL(:p_from_date, gjl.effective_date)         AND NVL(:p_to_date, gjl.effective_date)
ORDER BY
gjh.je_header_id,
        gjl.je_line_num

Comments

Popular posts from this blog

Query to find Responsibility and Request Group from Concurrent Program

How to Extract User Role Details with SQL in Oracle Fusion

3 Way PO Matching SQL Query in Oracle Fusion: Purchase Order, Receipt, and Invoice Reconciliation