Oracle ERP 常用查询:R12客户表

来源:互联网 发布:mac千牛可以上多个账号 编辑:程序博客网 时间:2024/04/24 08:28
针对Oracle ERP实施过程中遇到的常用客户信息取值,整理如下:

A.客户基本表:HZ_PARTIES和HZ_CUST_ACCOUNTS

HZ_PARTIES:基本表,可以是组织类型信息,也可以是人员类型信息。

HZ_CUST_ACCOUNTS:存储客户的账户层信息,和表HZ_PARTIES通过PARTY_ID字段进行关联。一个PARTY_ID可以在此表有多条记录,对应表示客户有多个账户。

常用字段查询示例:

SELECT hp.party_id      ,hp.party_name --客户名称      ,hp.party_number --注册标识      ,hp.tax_reference --纳税登记编号      ,hca.cust_account_id --账户ID      ,hca.account_number --帐号/客户编号      ,hca.account_name --账户说明      ,hca.customer_class_code --账户分类代码      ,cux_pj_common_pkg.get_lookup_value('CUSTOMER CLASS'                                         ,hca.customer_class_code) customer_class_desc --账户分类说明      ,hca.primary_salesrep_id --账户层销售员      ,hca.sales_channel_code --销售渠道编码      ,hz_utility_v2pub.get_lookupmeaning('SO_LOOKUPS'                                         ,'SALES_CHANNEL'                                         ,hca.sales_channel_code) sales_channel_desc --销售渠道说明      ,hca.customer_type --账户类型编码      ,cux_pj_common_pkg.get_lookup_value('CUSTOMER_TYPE'                                         ,hca.customer_type) customer_type_desc --账户类型说明      ,hca.orig_system_reference --来源系统参考      ,hca.status --账户状态编码      ,cux_pj_common_pkg.get_lookup_value('HZ_CPUI_REGISTRY_STATUS'                                         ,hca.status) status_desc --账户状态说明      ,hca.payment_term_id --账户层付款条件ID  FROM hz_parties       hp      ,hz_cust_accounts hca WHERE 1 = 1   AND hp.party_id = hca.party_id   AND hca.cust_account_id = &p_cust_account_id;

B.账户地点表:HZ_CUST_ACCT_SITES_ALL

HZ_CUST_ACCT_SITES_ALL:账户地点表,存储了地点的可使用用途等信息,并不包含具体的地点信息。
常用字段查询示例:
SELECT cas.cust_acct_site_id --账户地点ID      ,cas.cust_account_id --账户ID      ,cas.party_site_id --地点ID      ,cas.orig_system_reference --来源系统参考      ,cas.status --状态      ,cas.bill_to_flag --是否可用于收单      ,cas.ship_to_flag --是否可用于收货      ,cas.org_id --业务实体  FROM HZ_CUST_ACCT_SITES_ALL cas WHERE 1 = 1   AND cas.cust_account_id = &p_cust_account_id;

C.地点用途表:HZ_CUST_SITE_USES_ALL

HZ_CUST_SITE_USES_ALL:账户地点用途表,存储了地点的具体用途信息,常用的有收单方、收货方等。
常用字段查询示例:
SELECT site_use.site_use_id --地点用途ID      ,cas.cust_acct_site_id --账户地点ID      ,site_use.status --地点用途状态      ,hz_utility_v2pub.get_lookupmeaning('FND_LOOKUP_VALUES'                                         ,'SITE_USE_CODE'                                         ,site_use.site_use_code) --业务目的      ,site_use.primary_flag --主要标志      ,site_use.location --地点      ,site_use.payment_term_id --付款条件ID AP_TERMS_TL      ,site_use.primary_salesrep_id --销售员 JTF_RS_SALESREPS      ,site_use.order_type_id --订单类型 OE_TRANSACTION_TYPES_ALL      ,site_use.price_list_id --价目表 qp.QP_LIST_HEADERS_B      ,cas.org_id --业务实体  FROM hz_cust_acct_sites_all cas      ,hz_cust_site_uses_all  site_use WHERE 1 = 1   AND cas.cust_acct_site_id = site_use.cust_acct_site_id(+)   AND cas.cust_account_id = &p_cust_account_id;

D.地点信息表:HZ_PARTY_SITES和HZ_LOCATIONS

HZ_PARTY_SITES:账户地点表,存储了地点的基本信息,常用字段为地点编号和名称。
HZ_LOCATIONS:账户地点地址表,存储了地点具体地址信息,通过LOCATION_ID字段和表HZ_PARTY_SITES关联
常用字段查询示例:
SELECT hps.party_site_id --地点ID      ,hps.party_site_number --地点编号      ,hps.party_site_name --地点名称      ,hps.status --地点状态      ,hps.addressee --地点地址      ,loc.location_id --地址ID      ,hz_format_pub.format_address(loc.location_id, NULL, NULL, ', ') --地址      ,loc.address1 --地址行1      ,loc.address2 --地址行2      ,loc.city --城市      ,loc.country --县      ,loc.state --省(州)      ,loc.province --省      ,loc.country --国家 FND_TERRITORIES_VL      ,loc.postal_code --邮政编码  FROM hz_party_sites hps      ,hz_locations   loc WHERE hps.location_id = loc.location_id   AND hps.party_site_id = &p_party_site_id;


未完待续。。。

0 0