You are on page 1of 6

R12 E-Business Suite Suppliers Query - SQL to join Suppliers, Contacts, Banks

In the Oracle E-Business Suite (EBS) Release 12 the data model of Suppliers has become much more complex. The base tables have changed (Suppliers, Sites, Bank Accounts, Contacts) and some of the fields have become obsolete. Here is a query to bring many of the Supplier attributes together, with focus on banks / bank accounts, payment methods, contacts, remittance delivery (email, notification method). Please post comments if you find any issues! Adjust the WHERE clause on the first WITH query to return the suppliers that you need to report on. Hope this query helps someone out. Add additional fields to the final query (or WITH queries as required.)
with vendors as ( select vendor_id from ap_suppliers where 1=1 /* COMMENT / UNCOMMENT and UPDATE THE NEXT 5 LINES AS YOU REQUIRE */ --and vendor_type_lookup_code = 'VENDOR' --and upper( vendor_name ) like 'VIRTUATE%' and creation_date between '01-JAN-2011' and '01-JAN-2012' --and enabled_flag = 'Y' ) , vend as ( select pv.vendor_id vendor_id , pv.vendor_name_alt vendor_name_alt , pv.vendor_name vendor_name , pv.segment1 vendor_number , pv.vendor_type_lookup_code vendor_type_lookup_code from ap_suppliers pv where pv.vendor_id in (select v.vendor_id from vendors v) ) , site as ( select ss.vendor_id vendor_id , ss.vendor_site_id vendor_site_id , ss.vendor_site_code vendor_site_code , ss.vendor_site_code_alt vendor_site_code_alt , ss.vat_code tax_code , ss.vat_registration_num vat_registration_num , t.name terms_name , ss.address_line1 ss_address_line1 , ss.address_line2 ss_address_line2 , ss.address_line3 ss_address_line3 , ss.zip ss_zip , ss.city ss_city , ss.state ss_state , ss.country ss_country , ss.area_code ss_area_code , ss.phone ss_phone , ss.fax_area_code ss_fax_area_code

owner_table_name = 'HZ_PARTY_SITES' and hcp.remittance_email ss_remittance_email ss.phone_line_type = 'GEN' and hcp. ss.created_by_module = 'AP_SUPPLIERS_API' and rownum < 2 -.remit_advice_email ss_remit_advice_email pm.phone_line_type = 'FAX' and hcp. . .phone_area_code from hz_contact_points hcp where hcp.phone_number from hz_contact_points hcp where hcp. . .created_by_module = 'AP_SUPPLIERS_API' and rownum < 2 -. payee..contact_point_type = 'PHONE' --and hcp.copied from OAF View Object ) ss_hcp_fax_number ap_supplier_sites_all ss ap_suppliers sup ap_terms t ( select ss.owner_table_name = 'HZ_PARTY_SITES' and hcp. .phone_line_type = 'FAX' and hcp. .owner_table_id = ss.created_by_module = 'AP_SUPPLIERS_API' and rownum < 2 -.remit_advice_fax . pm.copied from OAF View Object ) ss_hcp_fax_area_code ( select hcp.supplier_notif_method ss_supplier_notif_method ps.phone_line_type = 'GEN' and hcp. payee.party_site_id and hcp.payment_method_code from iby_external_payees_all payee . . payee.contact_point_type = 'PHONE' --and hcp.remit_advice_delivery_method ss_remit_advice_deliv_meth pm. .party_site_id and hcp.phone_area_code from hz_contact_points hcp where hcp. .fax ss_fax ss.remit_advice_email .payment_method_code ss_payment_method_code ss.owner_table_name = 'HZ_PARTY_SITES' and hcp. .party_site_id and hcp.owner_table_id = ss.owner_table_name = 'HZ_PARTY_SITES' and hcp.remit_advice_fax ss_remit_advice_fax pm. . .remit_advice_delivery_method .party_site_id and hcp.primary_pay_site_flag ss_primary_pay_site_flag pm.telex ss_telex ss.contact_point_type = 'PHONE' --and hcp.copied from OAF View Object ) ss_hcp_phone_area_code ( select hcp. . from .owner_table_id = ss.owner_table_id = ss. .phone_number from hz_contact_points hcp where hcp. .copied from OAF View Object ) ss_hcp_phone_number ( select hcp.addressee ss_addressee ( select hcp. .vendor_site_id .contact_point_type = 'PHONE' --and hcp.created_by_module = 'AP_SUPPLIERS_API' and rownum < 2 -.pay_site_flag ss_pay_site_flag ss.

. iby_ext_party_pmt_mthds pm . .party_site_id (+) ss. ap_supplier_sites_all ss where payee..payee_party_id = ps. pm. payee.ext_pmt_party_id = payee.primary_flag = 'N' and not exists ( select 1 from iby_ext_party_pmt_mthds pm2 where pm. ap_supplier_sites_all ss where payee.term_id (+) as pv.supplier_site_id = ss.party_site_id = ps.person_last_name hp.remit_advice_delivery_method .org_id and payee. .ext_pmt_party_id = pm2.email_address hcpp.org_id = ss.ext_pmt_party_id and pm2. payee.vendor_id pm.phone_area_code hcpp. cont ( select .party_site_id = ss. . payee.remit_advice_email .party_site_id and payee. where and and and and ) .remit_advice_fax .person_title hcpe.org_id = ss.primary_flag = 'Y' ) union all select ss.org_id and payee. .vendor_site_id ss.payment_function = 'PAYABLES_DISB' and payee.vendor_id = ss.party_site_id = ss.party_site_id and pm.party_id and payee.ext_payee_id and pm.vendor_site_id hp.payment_method_code from iby_external_payees_all payee .org_type = 'OPERATING_UNIT' and ss.phone_number hcpf.ext_payee_id and pm. hz_party_sites ps .vendor_site_id and payee.primary_flag = 'Y' ) pm hz_party_sites ps sup.vendor_site_id .vendor_id pvs.payee_party_id = ps.ext_pmt_party_id = payee.vendor_id in (select vendor_id from vendors) sup. .terms_id = t.org_type = 'OPERATING_UNIT' and ss.vendor_site_id and payee. iby_ext_party_pmt_mthds pm .supplier_site_id = ss.vendor_site_id = ss.party_id and payee.party_site_id = ps.party_site_id and pm.party_site_id = ps. hz_party_sites ps .party_id hp. .person_first_name hp.payment_function = 'PAYABLES_DISB' and payee. .party_site_id and payee. .phone_area_code vendor_id vendor_site_id c_party_id c_first_name c_last_name c_person_title c_email_address c_phone_area_code c_phone_number c_fax_area_code .

.owner_table_name(+) = 'HZ_PARTIES' hcpe.order_of_preference hcpf.party_id hcpf.object_id pvs.vendor_id = pvs.bank_account_name .bank_or_branch_number .per_party_id ) pv.phone_number c_fax_number hz_parties hp hz_relationships hzr hz_contact_points hcpp hz_contact_points hcpf hz_contact_points hcpe ap_suppliers pv ap_supplier_sites_all pvs hz_party_sites hps hp.status (+)='A' hcpf.vendor_id exists ( select 1 from ap_supplier_contacts ascs where (ascs. .org_party_site_id and hzr.end_date . ss.contact_point_type(+) = 'PHONE' hcpe.status (+)='A' hps.party_id = hzr. . eba. piu.vendor_site_id . from . . piu.bank_account_num .start_date .bank_or_branch_number .relationship_id = ascs.relationship_id and hzr. piu. bank as ( select pv.inactive_date is null or ascs.object_table_name = 'HZ_PARTIES' hzr.vendor_id . .owner_table_name(+) = 'HZ_PARTIES' hcpf.party_id = hzr.subject_table_name = 'HZ_PARTIES' hzr.party_id = ascs..status = 'A' hcpp.object_type = 'ORGANIZATION' hzr. where and and and and and and and and and and and and and and and and and and and and and and and and and and ) .party_site_id = hps. hopbank.vendor_id in (select vendor_id from vendors) vendor_id vendor_site_id bank_number branch_number bank_account_num bank_account_name bank_use_start_date bank_use_end_date bank_priority .phone_line_type(+) = 'FAX' hcpf. hopbranch.phone_line_type(+) = 'GEN' hcpp.party_id hcpp.status (+)='A' hcpe.party_site_id = ascs.contact_point_type(+) = 'EMAIL' hcpp.owner_table_name(+) = 'HZ_PARTIES' hcpp.inactive_date > sysdate) and hzr. eba.rel_party_id and hps.subject_type = 'PERSON' hzr.owner_table_id(+) = hzr.owner_table_id(+) = hzr.party_id hcpe.relationship_code = 'CONTACT_OF' hzr.party_site_id pv.relationship_type = 'CONTACT' hzr.subject_id = ascs.subject_id hzr.owner_table_id(+) = hzr.contact_point_type(+) = 'PHONE' hcpf. .

c. s.terms_name . s.c_first_name .vendor_name .vendor_id .vendor_id pv.org_id = ss.c_fax_area_code . s. v. where and and and and and and and and and and and and and and and ) -.org_id payee.ss_payment_method_code . .* select distinct v.vendor_site_id payee.ss_city .branch_number .vat_registration_num .vendor_type_lookup_code .payment_flow = 'DISBURSEMENTS' piu.*.bank_number . b. s.tax_code . b. c.payment_function = 'PAYABLES_DISB' payee. c. v.ss_remit_advice_deliv_meth .ss_address_line2 . s.ss_remit_advice_email .ss_address_line1 .c_phone_area_code .ss_address_line3 .c_fax_number iby_ext_bank_accounts eba iby_external_payees_all payee iby_pmt_instr_uses_all piu ap_supplier_sites_all ss ap_suppliers pv hz_organization_profiles hopbank hz_organization_profiles hopbranch 1=1 eba. s.vendor_site_code . s.*. s. .c_last_name . v. s. c.ss_country .party_site_id payee. c.party_id payee. c. s. .vendor_id = pv.party_site_id = ss.ss_zip .end_date is null or piu.bank_id = hopbank.end_date > sysdate ) ss.instrument_type = 'BANKACCOUNT' piu.ext_payee_id = piu.from .branch_id = hopbranch. c.bank_account_num .org_type = 'OPERATING_UNIT' payee. s.c_phone_number . s. . c. s.c_person_title .ext_pmt_party_id piu.start_date < sysdate ( piu. .ext_bank_account_id piu.supplier_site_id = ss.vendor_number .vendor_id in (select vendor_id from vendors) supplier_id supplier_num supplier_name supplier_type terms_name invoice_tax_code vat_registration_num site_code address1 address2 address3 suburb state post_code country payment_method bank_account_name bank_number branch_number bank_account_num remittance_email notification_method contact_first_name contact_last_name contact_title contact_email contact_ph_area_code contact_ph_number contact_fax_area_code contact_fax_number .instrument_id = eba.party_id eba.*.bank_account_name .ss_state . s. b. b.c_email_address .select distinct v. b. s. c.

7.13.vendor_site_id = b.5.vendor_site_id (+) s.vendor_site_id = c.vendor_id and b2.9.vendor_site_id) order by 3. .bank_priority.4. .vendor_id = b.from .vendor_site_id (+) nvl(b.vendor_id = c.2. where and and and and and vend v site s cont c bank b v.11.vendor_site_id = b.12.-1) from bank b2 where b2. .vendor_id = b.vendor_id (+) s.vendor_id = s.1.8.-1) = (select nvl(min(bank_priority).vendor_id (+) s.10.6.vendor_id (+) s.