Monday, November 28, 2011

GL Journal, Recurring Journal, detail query

Query to fetch  Journal batch, Journal Header, Journal Line, Currency, Ledger details (The accounting combination segments can be selected based on the Chart of Accounts Structure):
SELECT gjh.currency_code,
           gjl.effective_date,
           gjh.actual_flag,
           gjh.je_category,
           gjh.je_source,
           gjh.period_name,
           gcc.concatenated_segments Concatenated_Segments,
           gjl.entered_dr,
           gjl.entered_cr,
           gjb.name batch_name,
           gjb.description batch_desc,
           gjh.name header_name,
           gjh.description header_desc,
           gjl.description line_desc,
           gcc.start_date_active
           gll.name Ledger_Name,
           gll.ledger_id
  FROM gl.gl_je_headers gjh,
          gl.gl_je_lines gjl,
          gl.gl_je_batches gjb,
          gl.gl_code_combinations_kfv gcc,
          gl.gl_ledgers gll
 WHERE gjh.je_header_id = gjl.je_header_id
   AND gjh.je_batch_id = gjb.je_batch_id
   AND gjl.code_combination_id = gcc.code_combination_id
   AND gjh.je_category = gao.je_category_name
   AND gjh.ledger_id = gll.ledger_id
   AND gjh.ledger_id = :p_ledger_id
   AND gjh.currency_code = :p_curr_code
   AND gjh.status = 'P'
   AND gjh.actual_flag = :p_act_flag -- A for Actual, B for Budget, E for Encumbrance
   AND gjh.period_name = :p_period_name;

Query to fetch Recurring Journal batch, Journal Header, Journal Line details
(The accounting combination segments can be selected based on the Chart of Accounts Structure):
SELECT grb.name batch_name,
           grh.recurring_batch_id,
           grh.recurring_header_id,
           grh.name journal_name,
           grl.recurring_line_num,
           gcc.concatenated_segments Concatenated_Segments,
           grl.description,
           grlc.rule_num,
           grlc.operator,
           grlc.amount
  FROM
gl.gl_recurring_batches grb,
         
gl.gl_recurring_line_calc_rules grlc,
         
gl.gl_recurring_lines grl,
         
gl.gl_recurring_headers_v grh,
          gl.gl_code_combinations_kfv gcc
 WHERE grb.recurring_batch_id = grh.recurring_batch_id
   AND grlc.rule_num = grl.recurring_line_num
   AND grl.recurring_header_id = grlc.recurring_header_id
   AND grl.recurring_header_id = grh.recurring_header_id
   AND grl.code_combination_id = gcc.code_combination_id;

No comments:

Post a Comment