SELECT okh.*, okt.description,
(SELECT hca.account_number
FROM apps.hz_cust_accounts hca,
apps.hz_cust_acct_sites_all hcs,
apps.hz_cust_site_uses_all hcsu
WHERE hca.cust_account_id = hcs.cust_account_id
AND hcs.cust_acct_site_id = hcsu.cust_acct_site_id
AND okh.bill_to_site_use_id = hcsu.site_use_id
AND hcsu.site_use_code = 'BILL_TO') bill_to_customer,
(SELECT hca.account_number
FROM apps.hz_cust_accounts hca,
apps.hz_cust_acct_sites_all hcs,
apps.hz_cust_site_uses_all hcsu
WHERE hca.cust_account_id = hcs.cust_account_id
AND hcs.cust_acct_site_id = hcsu.cust_acct_site_id
AND okh.ship_to_site_use_id = hcsu.site_use_id
AND hcsu.site_use_code = 'SHIP_TO') ship_to_customer,
(SELECT DISTINCT jrs.NAME
FROM apps.okc_contacts oc,
okx_salesreps_v jrs
WHERE okh.ID = oc.dnz_chr_id
AND oc.object1_id1 = jrs.id1
AND oc.cro_code LIKE 'SALESPERSON'
AND jrs.org_id = okh.authoring_org_id) "Sales Person"
FROM apps.okc_k_headers_b okh, apps.okc_k_headers_tl okt
WHERE 1 = 1
AND okt.ID = okh.ID
and okh.sts_code in ('ACTIVE', 'ENTERED', 'QA_HOLD')
AND okh.authoring_org_id = 204
order by okh.contract_number;
Useful information like this one must be kept and maintained so I will put this one on my bookmark list! Thanks for this wonderful post and hoping to post more of this!
ReplyDeleteSAP Financial Training Courses & SAP Financial Accounting Training Courses