You are on page 1of 2

AR to GL query detailed:

1. Set the Org Context first:

begin
mo_global.set_policy_context('S',&Org_id);
end;

2. SQL Query: Provide AR transaction

SELECT gjb.name GL_batch_name,


gjh.name Journal_Name,
gjl.period_name,
gjh.JE_CATEGORY,
gjh.JE_SOURCE,
gjh.currency_code,
DECODE (gjh.ACTUAL_FLAG, 'A', 'Actual','B', 'Budget','E', 'Encumbrance')
Balance_Type,
DECODE (gjl.status, 'P', 'Posted', 'U', 'Unposted', gjl.status)
Batch_Status,
gjh.posted_date,
xal.accounting_class_code,
xal.entered_dr,
xal.entered_cr,
xal.accounted_dr accted_dr_in_func_cur,
xal.accounted_cr accted_cr_in_func_cur,
gjl.code_combination_id,
rcta.trx_number,
rcta.trx_date
FROM gl_je_lines gjl,
gl_je_headers gjh,
gl_je_batches gjb,
gl_import_references gir,
xla_ae_lines xal,
xla_ae_headers xah,
xla_events xe,
xla_transaction_entities xte,
ra_customer_trx_all rcta
WHERE gjb.je_batch_id = gjh.je_batch_id
and gjl.je_header_id = gjh.je_header_id
/* gl_je_lines (je_header_id, je_line_num) -> gl_import_references
(je_header_id, je_line_num) */
and gjl.je_header_id = gir.je_header_id
and gjl.je_line_num = gir.je_line_num
/*gl_import_references (gl_sl_link_table, gl_sl_link_id) -> xla_ae_lines
(gl_sl_link_table, gl_sl_link_id)*/
and gir.gl_sl_link_table = xal.gl_sl_link_table
and gir.gl_sl_link_id = xal.gl_sl_link_id
/*xla_ae_lines (applicaiton_id, ae_header_id) -> xla_ae_headers
(application_id, ae_header_id)*/
and xal.application_id = xah.application_id
and xal.ae_header_id = xah.ae_header_id
/*xla_ae_headers (application_id, event_id) -> xla_events (application_id,
event_id)*/
and xah.application_id = xe.application_id
and xah.event_id = xe.event_id
/*xla_events (application_id, entity_id) -> xla.xla_transaction_entities
(application_id, entity_id) */
and xe.application_id = xte.application_id
and xe.entity_id = xte.entity_id
/*xla.xla_transaction_entities (source_id_int_1) filtered by application_id
222, entity_code TRANSACTIONS and ledger_id -> ra_customer_trx_all
(customer_trx_id) for that ledger_id.*/
and xte.application_id = 222
and xte.entity_code = 'TRANSACTIONS'
and xte.source_id_int_1 = rcta.customer_trx_id
and trim(rcta.trx_number) = trim('&AR_trx_number')
;

You might also like