Tuesday, December 13, 2011
R12 AR Customer Site Query
SELECT distinct hcsua.site_use_code
,hcasa.status
,hcsua.LOCATION
,hcsua.primary_flag
,hcsua.orig_system_reference
,hcsua.tax_reference
,hcsua.status site_use_status
,hcasa.attribute4 primary_per_type
,hcasa.attribute4 cust_acct_status
,hp.party_number
,hca.account_number
,hcsua.created_by_module
,hcasa.attribute4 rec_status
,hcpc.NAME profile_class
,hcasa.attribute4 profile_class_id
,hcp.dunning_letters
,hcp.override_terms
,hcp.credit_balance_statements -- Added on 24-07-09
,hcpc.statements -- Added on 24-07-09
,rt.NAME term_name
,hou.NAME operating_unit
,hp.jgzz_fiscal_code taxpayer_id
,hcasa.attribute4 party_site_number
,hcasa.orig_system_reference site_orig_system_reference
,hcsua.tax_code -- Added on 25-06-09
,arsc.NAME statement_cycle -- Added on 24-07-09
,arc.NAME collector_name -- Added on 24-07-09
,hcasa.attribute4 org_id
,hcasa.attribute4 collector_id
,hcasa.attribute4 statement_cycle_id
,hcasa.attribute4 error_code
,hcasa.attribute4 error_message
,hcasa.attribute4 company
,hcasa.attribute4 payment_term_id
,hcp.account_status profile_acct_status
,gcck1.concatenated_segments Revenue
,gcck2.concatenated_segments Receivable
,gcck3.concatenated_segments Tax
,hp.tax_reference tax_reg_number
,att.name Terms_name
,rtt.name Domestic
,RES.RESOURCE_NAME
,hcsua.territory_id domestic_id
,hcsua.payment_term_id
,hcsua.PRIMARY_SALESREP_ID
FROM
ar.hz_parties hp
,ar.hz_party_sites hps
,ar.hz_cust_accounts hca
,ar.hz_cust_acct_sites_all hcasa
,ar.hz_cust_site_uses_all hcsua
,ar.hz_customer_profiles hcp
,ar.ra_terms_tl rt
,ar.hz_cust_profile_classes hcpc
,hr.hr_all_organization_units hou
,ar.ar_statement_cycles arsc
,ar.ar_collectors arc
,apps.gl_code_combinations_kfv gcck1
,apps.gl_code_combinations_kfv gcck2
,apps.gl_code_combinations_kfv gcck3
,apps.ra_terms_tl att
,apps.ra_territories rtt
,apps.JTF_RS_SALESREPS SR
,apps.JTF_RS_RESOURCE_EXTNS_VL RES
WHERE 1=1
AND hp.party_id = hca.party_id
AND hca.cust_account_id = hcasa.cust_account_id
AND hcsua.cust_acct_site_id = hcasa.cust_acct_site_id
AND hp.party_type = 'ORGANIZATION'
AND hp.status = 'A'
AND hca.status = 'A'
AND hcasa.status ='A'
AND hcsua.status ='A'
AND hcasa.org_id = hcsua.org_id
AND hcsua.payment_term_id = rt.term_id(+)
AND hcsua.site_use_id = hcp.site_use_id(+)
AND hcpc.profile_class_id(+) = hcp.profile_class_id
AND arsc.statement_cycle_id(+) = hcpc.statement_cycle_id
AND arc.collector_id(+) = hcpc.collector_id
AND hcp.status(+) = 'A'
AND hcpc.status (+) = 'A'
AND hou.organization_id = hcsua.org_id
AND hcsua.site_use_code IN ('BILL_TO', 'SELF_SERVICE_USER')
and hp.party_id=hps.party_id
and hps.party_site_id=hcasa.party_site_id
and hcasa.cust_acct_site_id=hcsua.cust_acct_site_id
and gcck1.code_combination_id(+)=hcsua.gl_id_rev
and gcck2.code_combination_id(+)=hcsua.gl_id_rec
and gcck3.code_combination_id(+)=hcsua.gl_id_tax
and hcsua.payment_term_id=att.term_id(+)
and hcsua.territory_id=rtt.territory_id
AND hcsua.PRIMARY_SALESREP_ID = SR.SALESREP_ID (+)
AND SR.RESOURCE_ID = RES.RESOURCE_ID (+)
--and hp.party_number in (1249,1244,1211,1214,1218,1222,1226)
--AND hca.customer_class_code <> 'INTERCOMPANY';
--and hp.party_name='ALDAR PROPERTIES PJSC'
order by 10
Labels:
AR
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment