Thursday, 13 June 2013

Gl Trial Balance Query

/* Formatted on 11/16/2016 12:15:12 PM (QP5 v5.114.809.3010) */
  SELECT   GCC.SEGMENT3 account,
           gjh.CURRENCY_CODE gl_header,
           gl.CURRENCY_CODE Ladger,
           gl_flexfields_pkg.get_description_sql (gcc.chart_of_accounts_id,
                                                  3,
                                                  gcc.segment3)
              description,
           SUM (NVL (GJL.ACCOUNTED_DR, 0)) ACCOUNTED_DR,
           SUM (NVL (GJL.ACCOUNTED_CR, 0)) ACCOUNTED_CR,
           SUM (NVL (GJL.ACCOUNTED_DR, 0) - NVL (GJL.ACCOUNTED_CR, 0)) BALANCE
    FROM   gl_je_headers gjh,
           gl_je_lines gjl,
           gl_ledgers gl,
           gl_code_combinations_kfv gcc,
           GL_JE_BATCHES GJB
   WHERE       gjl.je_header_id = gjh.je_header_id
           AND gjh.je_batch_id = gjb.je_batch_id
           AND gjl.code_combination_id = gcc.code_combination_id
           AND gjh.ledger_id = gl.ledger_id
           AND gjh.status = 'P'
           AND gjh.actual_flag = 'A'
           AND gjh.period_name = 'Apr-16'
           AND GL.name = '<>_Ledger'
GROUP BY   GCC.SEGMENT3,
           gcc.chart_of_accounts_id,
           gjh.CURRENCY_CODE,
           gl.CURRENCY_CODE
ORDER BY   1;

          *******************     ===============      *******************

/* Formatted on 11/16/2016 12:18:42 PM (QP5 v5.114.809.3010) */
  SELECT   gjh.name Journal_name,
           gjh.je_category category_name,
           gjh.je_source source_name,
           gjb.name batch_name,
           GCC.SEGMENT1,                                            -- comapny
           GCC.SEGMENT2,                                         --cost center
           GCC.SEGMENT3,                                            -- account
           GCC.SEGMENT4,                                            ---Project
           GCC.SEGMENT5,                                             --Product
           GCC.SEGMENT6,                                              --Others
           SUM (NVL (GJL.ACCOUNTED_DR, 0)) ACCOUNTED_DR,
           SUM (NVL (GJL.ACCOUNTED_CR, 0)) ACCOUNTED_CR,
           SUM (NVL (GJL.ACCOUNTED_DR, 0) - NVL (GJL.ACCOUNTED_CR, 0)) BALANCE
    FROM   gl_je_headers gjh,
           gl_je_lines gjl,
           gl_ledgers gl,
           gl_code_combinations gcc,
           GL_JE_BATCHES GJB
   WHERE       gjl.je_header_id = gjh.je_header_id
           AND gjh.je_batch_id = gjb.je_batch_id
           AND gjl.code_combination_id = gcc.code_combination_id
           AND gjh.ledger_id = gl.ledger_id
           AND gjh.status = 'P'      --This will pick all posted journal entry
           AND gjh.actual_flag = 'A' -- This is for Actual entry A-Actual, B-Budget
           AND gjh.period_name = 'Apr-16'
           AND GL.name = 'NAPSA_Ledger'  --Ledger Name for organization
GROUP BY   GCC.SEGMENT1,
           GCC.SEGMENT2,
           GCC.SEGMENT3,
           GCC.SEGMENT4,
           GCC.SEGMENT5,
           GCC.SEGMENT6,
           GCC.SEGMENT7,
           gjh.je_category,
           gjh.je_source,
           gjb.name,
           gjh.name;

No comments:

Post a Comment