AP_HZ Party和Supplier、Bank表关系详解

2014-06-26 Created By BaoXinjian

一、摘要


基本在做supplier, customer, employee查询,都会涉及hz_parties表的使用,通过主外键party_id进行关联

 

二、 案例


1. 查询Supplier相关信息

 

2. 供应商主表数据

 1 SELECT ass.vendor_id                  vendor_id,
 2        ass.party_id                   party_id,
 3        ass.segment1                   vendor_code,
 4        ass.vendor_name                vendor_name,
 5        ass.vendor_name                vendor_short_name,
 6        ass.vendor_type_lookup_code    vendor_type,
 7        flv.meaning                    vendor_type_meaning,
 8        hp.tax_reference               tax_registered_name,
 9        ass.payment_method_lookup_code payment_method,
10        att.name                       term_name,
11        att.enabled_flag               enabled_flag,
12        att.end_date_active            end_date_active,
13        ass.creation_date              creation_date,
14        ass.created_by                 created_by,
15        ass.last_update_date           last_update_date,
16        ass.last_updated_by            last_updated_by,
17        ass.last_update_login          last_update_login
18   FROM ap_suppliers      ass,
19        fnd_lookup_values flv,
20        hz_parties        hp,
21        ap_terms_tl       att
22   WHERE ass.vendor_type_lookup_code = flv.lookup_code(+)
23    AND flv.lookup_type(+) = 'VENDOR TYPE'
24    AND flv.language(+) = userenv ( 'LANG' )
25    AND ass.party_id = hp.party_id
26    AND att.language = userenv ( 'LANG' )
27    AND ass.terms_id = att.term_id(+);

 

3. 供应商银行信息

 1 SELECT ass.vendor_id         vendor_id,
 2        ass.party_id          party_id,
 3        bank.party_id         bank_id,
 4        bank.party_name       bank_name,
 5        branch.party_id       branch_id,
 6        branch.party_name     bank_branch_name,
 7        ieba.bank_account_num bank_account_num
 8   FROM ap_suppliers          ass,
 9        hz_parties            hp,
10        iby_account_owners    iao,
11        iby_ext_bank_accounts ieba,
12        hz_parties            bank,
13        hz_parties            branch
14   WHERE ass.party_id = hp.party_id
15    AND hp.party_id = iao.account_owner_party_id(+)
16    AND iao.ext_bank_account_id = ieba.ext_bank_account_id(+)
17    AND ieba.bank_id = bank.party_id(+)
18    AND ieba.branch_id = branch.party_id(+)
19   ORDER BY ieba.creation_date;

 

4. 供应商开户行地址信息

 1 SELECT hps.party_id      party_id,
 2        hps.party_site_id party_site_id,
 3         hl.location_id    location_id,
 4        hl.country        country,
 5        hl.province       province,
 6        hl.city           city,
 7        hl.address1       address1,
 8        hl.address2       address2,
 9        hl.address3       address3,
10        hl.address4       address4
11   FROM hz_party_sites hps, hz_locations hl
12   WHERE hps.location_id = hl.location_id
13   ORDER BY hps.creation_date

 

5. 供应商联系人信息

 1 SELECT hr.subject_id subject_id,
 2        hr.object_id object_id,
 3        hr.party_id party_id,
 4        hp.person_last_name || ' ' || hp.person_middle_name || ' ' ||
 5        hp.person_first_name contact_person,
 6        hcpp.phone_area_code phone_area_code,
 7        hcpp.phone_number phone_number,
 8        hcpp.phone_extension phone_extension,
 9        hcpf.phone_area_code fax_phone_area_code,
10        hcpf.phone_number fax_phone_number,
11        hcpe.email_address email_address
12   FROM hz_relationships  hr,
13        hz_contact_points hcpp,
14        hz_contact_points hcpf,
15        hz_contact_points hcpe,
16        hz_parties        hp
17   WHERE hr.object_id = hp.party_id
18    AND hcpp.owner_table_id(+) = hr.party_id
19    AND hcpf.owner_table_id(+) = hr.party_id
20    AND hcpe.owner_table_id(+) = hr.party_id
21    AND hr.object_type = 'PERSON'
22    AND hr.relationship_code(+) = 'CONTACT'
23    AND hcpp.owner_table_name(+) = 'HZ_PARTIES'
24    AND hcpf.owner_table_name(+) = 'HZ_PARTIES'
25    AND hcpe.owner_table_name(+) = 'HZ_PARTIES'
26    AND hcpp.contact_point_type(+) = 'PHONE'
27    AND hcpp.phone_line_type(+) = 'GEN'
28    AND hcpf.contact_point_type(+) = 'PHONE'
29    AND hcpf.phone_line_type(+) = 'FAX'
30    AND hcpe.contact_point_type(+) = 'EMAIL'
31    AND hcpe.phone_line_type IS NULL
32   ORDER BY hr.creation_date;

 

6. 供应商地址主信息

 1 SELECT assa.vendor_site_id       vendor_site_id,
 2        assa.vendor_id            vendor_id,
 3        assa.vendor_site_code     vendor_code,
 4        assa.vendor_site_code     address_short_name,
 5        assa.address_line1        address_line1,
 6        assa.address_line2        address_line2,
 7        assa.address_line3        address_line3,
 8        assa.address_line4        address_line4,
 9        assa.org_id               org_id,
10        assa.country              country,
11        assa.province             province,
12        assa.city                 city,
13        assa.county               county,
14        assa.zip                  zip,
15        assa.pay_site_flag        pay_site_flag,
16        assa.purchasing_site_flag purchasing_site_flag,
17        assa.inactive_date        inactive_date,
18        assa.creation_date        creation_date,
19        assa.created_by           created_by,
20        assa.last_update_date     last_update_date,
21        assa.last_updated_by      last_updated_by,
22        assa.last_update_login    last_update_login
23   FROM ap_suppliers ass, ap_supplier_sites_all assa
24   WHERE assa.vendor_id = ass.vendor_id;

 

7. 供应商地址联系人信息: phone 、 fax 和 Email

 1 SELECT hcpp.phone_area_code phone_area_code,
 2        hcpp.phone_number    phone_number,
 3        hcpp.phone_extension phone_extension,
 4        hcpf.phone_area_code fax_phone_area_code,
 5        hcpf.phone_number    fax_phone_number,
 6        hcpe.email_address   email_address
 7   FROM ap_supplier_sites_all assa,
 8        hz_contact_points     hcpp,
 9        hz_contact_points     hcpf,
10        hz_contact_points     hcpe,
11        hz_party_sites        hps
12   WHERE assa.party_site_id = hps.party_site_id
13    AND hcpp.owner_table_id(+) = assa.party_site_id
14    AND hcpf.owner_table_id(+) = assa.party_site_id
15    AND hcpe.owner_table_id(+) = assa.party_site_id
16    AND hcpp.owner_table_name(+) = 'HZ_PARTY_SITES'
17    AND hcpf.owner_table_name(+) = 'HZ_PARTY_SITES'
18    AND hcpe.owner_table_name(+) = 'HZ_PARTY_SITES'
19    AND hcpp.contact_point_type(+) = 'PHONE'
20    AND hcpp.phone_line_type(+) = 'GEN'
21    AND hcpf.contact_point_type(+) = 'PHONE'
22    AND hcpf.phone_line_type(+) = 'FAX'
23    AND hcpe.contact_point_type(+) = 'EMAIL'
24    AND hcpe.phone_line_type IS NULL ;

 

8. 供应商地址收件人信息

SELECT assa.party_site_id

FROM ap_supplier_sites_all assa

 

9. 根据 party_site_id 得到供应商地址的收件人名称  

SELECT hps.addressee FROM hz_party_sites hps;

 

10. 供应商银行帐户分配层次关系

SELECT * FROM iby_pmt_instr_uses_all;

 

11. 供应商银行帐户分配层次关系明细 ( 不包括供应商层的分配信息 ):

SELECT * FROM iby_external_payees_all;

 

Thanks and Regards

 

posted on 2014-06-26 20:21  东方瀚海  阅读(1027)  评论(0编辑  收藏  举报