SELECT api.invoice_num
, jel.accounted_cr
, jel.creation_date
, jeh.*
FROM gl_import_references gli
, xla_ae_lines xll
, xla_ae_headers xlh
, xla_distribution_links xld
, ap_invoices_all api
, ap_invoice_lines_all apl
, ap_invoice_distributions_all adp
, gl_je_lines jel
, gl_je_headers jeh
WHERE 1 = 1
AND api.invoice_id = apl.invoice_id
AND apl.invoice_id = adp.invoice_id
AND apl.line_number = adp.invoice_line_number
AND gli.gl_sl_link_table = xll.gl_sl_link_table
AND gli.gl_sl_link_id = xll.gl_sl_link_id
AND xll.ae_header_id = xlh.ae_header_id
AND xld.ae_header_id = xlh.ae_header_id
AND jel.je_header_id = jeh.je_header_id
AND jel.je_header_id = gli.je_header_id
AND jel.je_line_num = gli.je_line_num
AND xld.source_distribution_id_num_1 = adp.invoice_distribution_id
AND xld.source_distribution_type = 'AP_PMT_DIST'
AND xll.gl_sl_link_table = 'XLAJEL'
Subscribe to:
Post Comments (Atom)
I thought in R12 xld.source_distribution_id_num_1 points to the payment_hist_dist_id and not the invoice_distribution_id for source_distribution_type 'AP_PMT_DIST?.
ReplyDeleteI also think the join should be " xdl.source_distribution_id_num_1 = AP_PAYMENT_HIST_DISTS.payment_hist_dist_id"
ReplyDelete