Tuesday, November 6, 2012

Order with Customer(Billto & Shipto) Script

SELECT ooh.header_id,'BILL' SiteUse,
  ooh.sold_to_org_id,--ooh.sold_from_org_id,
  ooh.INVOICE_TO_ORG_ID,
  bill_party.party_name bill_customer,
  bill_cus.account_number customer_number,
  hcs_bill.location,
  hl_bill.address1,
  hl_bill.address2,
  hl_bill.city
  ||', '
  ||hl_bill.state
  ||' '
  ||hl_bill.postal_code
  ||' '
  ||hl_bill.country
FROM oe_order_headers_all ooh,
  hz_cust_accounts bill_cus,
  hz_parties bill_party,
  HZ_CUST_SITE_USES_ALL hcs_bill,
  HZ_CUST_ACCT_SITES_ALL hca_bill,
  hz_party_sites hps_bill,
  hz_locations hl_bill
WHERE ooh.header_id         =252047
AND ooh.SOLD_TO_ORG_ID   =bill_cus.cust_account_id
AND bill_party.party_id       =bill_cus.party_id
AND ooh.INVOICE_TO_ORG_ID   =hcs_bill.site_use_id
AND hcs_bill.site_use_code    ='BILL_TO'
AND hca_bill.cust_acct_site_id=hcs_bill.cust_acct_site_id
AND hps_bill.party_site_id    =hca_bill.party_site_id
AND hl_bill.location_id       =hps_bill.location_id
union
SELECT ooh.header_id,'SHIP' SiteUse,
  --rct.bill_to_customer_id,
  ooh.SHIP_TO_ORG_ID,
  ooh.SOLD_TO_ORG_ID,
  Sold_party.party_name Sold_customer,
  sold_cus.account_number customer_number,
  hcs_ship.location,
  hl_ship.address1,
  hl_ship.address2,
  hl_ship.city
  ||', '
  ||hl_ship.state
  ||' '
  ||hl_ship.postal_code
  ||' '
  ||hl_ship.country
FROM oe_order_headers_all ooh,
  hz_cust_accounts sold_cus,
  hz_parties sold_party,
  HZ_CUST_SITE_USES_ALL hcs_ship,
  HZ_CUST_ACCT_SITES_ALL hca_ship,
  hz_party_sites hps_ship,
  hz_locations hl_ship
WHERE ooh.header_id         =252047
AND ooh.SOLD_TO_ORG_ID   =sold_cus.cust_account_id
AND sold_party.party_id       =sold_cus.party_id
AND ooh.SHIP_TO_ORG_ID   =hcs_ship.site_use_id
AND hcs_ship.site_use_code    ='SHIP_TO'
AND hca_ship.cust_acct_site_id=hcs_ship.cust_acct_site_id
AND hps_ship.party_site_id    =hca_ship.party_site_id
AND hl_ship.location_id       =hps_ship.location_id;

2 comments:

  1. I want to share a testimony on how Le_Meridian funding service helped me with loan of 2,000,000.00 USD to finance my marijuana farm project , I'm very grateful and i promised to share this legit funding company to anyone looking for way to expand his or her business project.the company is UK/USA funding company. Anyone seeking for finance support should contact them on lfdsloans@outlook.com Or lfdsloans@lemeridianfds.com Mr Benjamin is also on whatsapp 1-989-394-3740 to make things easy for any applicant. 

    ReplyDelete