Friday, February 7, 2025

Query to get Customer details of Sales Order

 

SELECT  ooha.order_number
     ,  ooha.ordered_date
     ,  ooha.flow_status_code
     ,  hp.party_name "Customer Name"
     ,  hca.account_name
     ,  hca.org_id
     ,  hpb.status bill_to_status
     ,     'Address1: '
        || bill_loc.address1
        || ','
        || CHR (10)
        || 'Address2: '
        || bill_loc.address2
        || ','
        || CHR (10)
        || 'Address3: '
        || bill_loc.address3
        || ','
        || CHR (10)
        || 'City     - '
        || bill_loc.city
        || ','
        || CHR (10)
        || 'Postal Code: '
        || bill_loc.postal_code
        || ','
        || CHR (10)
        || 'Country: '
        || bill_loc.country
           bill_to_address
     ,  hcasas.orig_system_reference ship_to_orig_ref
     ,  hps.status ship_to_status
     ,     'Address1: '
        || ship_loc.address1
        || ','
        || CHR (10)
        || 'Address1: '
        || ship_loc.address2
        || ','
        || CHR (10)
        || 'Address1: '
        || ship_loc.address3
        || ','
        || CHR (10)
        || 'City: '
        || ship_loc.city
        || ','
        || CHR (10)
        || 'Postal Code: '
        || ship_loc.postal_code
        || ','
        || CHR (10)
        || 'Country: '
        || ship_loc.country
           ship_to_address

  FROM  apps.oe_order_headers_all ooha

     ,  apps.hz_parties hp
     ,  apps.hz_cust_accounts hca
     ,  apps.hz_cust_acct_sites_all hcasab
     ,  apps.hz_cust_acct_sites_all hcasas
     ,  apps.hz_cust_site_uses_all hzsuab
     ,  apps.hz_cust_site_uses_all hzsuas
     ,  apps.hz_party_sites hps
     ,  apps.hz_party_sites hpb
     ,  apps.hz_locations bill_loc
     ,  apps.hz_locations ship_loc

 WHERE 

   AND hp.party_id                        = hca.party_id
   AND hca.cust_account_id          = ooha.sold_to_org_id
   AND hcasab.cust_account_id    = hca.cust_account_id
   AND hcasas.cust_account_id     = hca.cust_account_id
   AND hpb.location_id                 = bill_loc.location_id
   AND hps.location_id                 = ship_loc.location_id
   AND hcasab.party_site_id         = hpb.party_site_id
   AND hcasas.party_site_id         = hps.party_site_id
   AND hcasab.cust_acct_site_id  = hzsuab.cust_acct_site_id
   AND hcasas.cust_acct_site_id  = hzsuas.cust_acct_site_id
   AND ooha.ship_to_org_id        = hzsuas.site_use_id
   AND ooha.invoice_to_org_id   = hzsuab.site_use_id
   AND ooha.order_number          = '&Order_Number';

No comments:

Post a Comment

Query to get Concurrent Program Data Template details

 SELECT  fcpt.user_concurrent_program_name       , fcp.concurrent_program_name       , fet.user_executable_name executable_name       , fe....