Monday, June 5, 2017

Query - Link AR XLA and GL

SELECT 
       rcta.trx_number transaction_num, 
       rcta.trx_date transaction_date,       
       gjh.posted_date posted_date, 
       gjh.je_source, 
       gjh.je_category,
       gjb.NAME je_batch_name, 

       gjh.NAME journal_name, 
       gjl.je_line_num je_line, 
       gjl.description je_line_descr,
       xal.entered_cr global_cr, 

       xal.entered_dr global_dr,
       xal.currency_code global_cur, 

       ac.customer_name vendor_customer,
       xal.accounting_class_code transaction_type, 

       xal.accounted_cr local_cr,
       xal.accounted_dr local_dr, 

       gl.currency_code local_cur,
       (NVL (xal.accounted_dr, 0) - NVL (xal.accounted_cr, 0)
       ) transaction_amount,
       gl.currency_code transaction_curr_code, 

       gjh.period_name fiscal_period,
       gl.NAME ledger_name
  FROM apps.gl_je_headers gjh,
       apps.gl_je_lines gjl,
       apps.gl_import_references gir,
       xla.xla_ae_lines xal,
       xla.xla_ae_headers xah,
       apps.gl_code_combinations glcc,
       xla.xla_transaction_entities xte,
       apps.ra_customer_trx_all rcta,
       apps.gl_ledgers gl,
       apps.gl_balances gb,
       apps.ar_customers ac,
       apps.gl_je_batches gjb
 WHERE 1 = 1
   AND gjh.je_header_id = gjl.je_header_id
   AND gjl.je_header_id = gir.je_header_id

   AND gjh.je_source = 'Receivables'
   AND gjl.je_line_num = gir.je_line_num

   AND gir.gl_sl_link_id = xal.gl_sl_link_id
   AND gir.gl_sl_link_table = xal.gl_sl_link_table
   AND xal.ae_header_id = xah.ae_header_id
   AND xal.application_id = xah.application_id
   AND xal.code_combination_id = glcc.code_combination_id
   AND xte.entity_id = xah.entity_id
   AND xte.entity_code = 'TRANSACTIONS'
   AND xte.ledger_id = gl.ledger_id
   AND xte.application_id = xal.application_id
   AND NVL (xte.source_id_int_1, -99) = rcta.customer_trx_id
   AND gjh.ledger_id = gl.ledger_id
   AND gb.code_combination_id = glcc.code_combination_id
   AND gb.period_name = gjh.period_name
   AND gb.currency_code = gl.currency_code
   AND gjh.je_batch_id = gjb.je_batch_id
   AND rcta.bill_to_customer_id = ac.customer_id(+)
   AND rcta.trx_number = :trx_number

  

0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Justin Bieber, Gold Price in India