SELECT alc1.displayed_field, --'类型',
ac.org_id, --'业务实体',
ac.vendor_name, --'贸易伙伴',
ass.segment1, --'供应商编号',
ac.vendor_site_code, --'供应商地点',
ac.check_date, --'付款日期',
ac.amount, --'付款额',
ac.attribute15, --'交易流水号',
aia.invoice_num, --'单据编号',
aipa.accounting_date, --'GL日期',
ac.currency_code, --'付款币种',
xl.accounting_class_code, --'会计分类',
gcc.segment1 || '.' || gcc.segment2 || '.' || gcc.segment3 || '.' ||
gcc.segment4 || '.' || gcc.segment5 || '.' || gcc.segment6 || '.' ||
gcc.segment7, --账户
xl.accounted_dr, --入账借项
xl.accounted_cr, --入账贷项
ppf.last_name || ppf.first_name
FROM ap_lookup_codes alc1,
ap_checks_all ac,
ap_invoice_payments_all aipa,
ap_invoices_all aia,
xla.xla_ae_headers xh,
xla.xla_ae_lines xl,
xla.xla_transaction_entities xte,
gl.gl_code_combinations gcc,
gl.gl_import_references gir,
gl.gl_je_headers gjh,
gl.gl_je_batches gjb,
xla.xla_events xea,
ap_suppliers ass,
fnd_user fu,
per_people_f ppf
WHERE alc1.lookup_type = 'PAYMENT TYPE'
AND alc1.lookup_code = ac.payment_type_flag
AND aipa.check_id = ac.check_id
AND aia.invoice_id = aipa.invoice_id
AND xh.ae_header_id = xl.ae_header_id
AND xte.entity_id = xh.entity_id
AND ac.check_id = xte.source_id_int_1(+)
AND gir.gl_sl_link_id(+) = xl.gl_sl_link_id
AND gir.je_header_id = gjh.je_header_id(+)
AND xl.code_combination_id = gcc.code_combination_id
AND gjh.je_batch_id = gjb.je_batch_id
AND xea.event_id = xte.entity_id
AND xte.entity_code = 'AP_PAYMENTS'
AND ass.vendor_id = ac.vendor_id
AND fu.user_id = ac.created_by
AND fu.employee_id = ppf.person_id;