Pages

Tuesday, May 4, 2010

Print Ship To Customer Address from Order Management

SELECT hl.address1, hl.address2, hl.address3,
hl.address4, hl.city, hl.postal_code,hl.STATE,hp.party_name
FROM hz_locations hl,
hz_party_sites hps,
hz_parties hp,
hz_cust_accounts hca,
hz_cust_acct_sites_all has,
hz_cust_site_uses_all hcs
WHERE hcs.site_use_code = 'SHIP_TO'
AND has.cust_acct_site_id = hcs.cust_acct_site_id
AND has.party_site_id = hps.party_site_id
AND hca.cust_account_id = has.cust_account_id
AND hp.party_id = hca.party_id
AND hps.party_id = hp.party_id
AND hl.location_id = hps.location_id
AND hca.cust_account_id = oe_order_headers_all.sold_to_org_id
AND hcs.site_use_id = wsh_delivery_details.ship_from_location_id;-->Take this coloumn from the table (wsh_delivery_details)

or use the below query

SELECT hp.party_name,hl.address1, hl.address2, hl.address3,
hl.address4,hl.PROVINCE, hl.city,hl.STATE, hl.postal_code,hl.COUNTRY,hcs.site_use_code
FROM hz_locations hl,
hz_party_sites hps,
hz_parties hp,
hz_cust_accounts hca,
hz_cust_acct_sites_all has,
hz_cust_site_uses_all hcs
WHERE 1=1--hcs.site_use_code = 'BILL_TO'
AND has.cust_acct_site_id = hcs.cust_acct_site_id
AND has.party_site_id = hps.party_site_id
AND hca.cust_account_id = has.cust_account_id
AND hp.party_id = hca.party_id
AND hps.party_id = hp.party_id
AND hl.location_id = hps.location_id
--AND hca.cust_account_id = 2231634 --oe_order_headers_all.sold_to_org_id
AND hcs.site_use_id = (SELECT (ship_to_org_id) or (invoice_to_org_id) FROM OE_ORDER_HEADERS_ALL WHERE HEADER_ID=
(select DISTINCT SOURCE_HEADER_ID from WSH_DELIVERABLES_V WHERE DELIVERY_ID=:P_DELIVERY_ID))-->use either (ship_to_org_id) or (invoice_to_org_id)

No comments: