Friday, 24 January 2014

Return Material Authorization Report

SELECT ooha.order_number,
       sysdate + 120 expiration_date,
       msib.segment1 item,
       msib.description,
       oola.order_quantity_uom uom,
       oola.fulfilled_quantity return_qty,
       oola.return_reason_code,
       hp.party_name,
       hcaa.account_number,
       hl.address1,
       hl.address2,
       hl.address3,
       hl.address4,
       hl.city,
       hl.state,
       hl.country
  FROM OE_ORDER_HEADERS_ALL OOHA,
       OE_ORDER_LINES_ALL OOLA,
       MTL_SYSTEM_ITEMS_B MSIB,
       HZ_PARTIES HP,
       HZ_PARTY_SITES HPS,
       HZ_LOCATIONS HL,
       HZ_CUST_ACCOUNTS_ALL HCAA,
       HZ_CUST_ACCT_SITES_ALL HCASA,
       HZ_CUST_SITE_USES_ALL HCSUA
 WHERE ooha.order_number = :P_ORDER_NUMBER
   AND ooha.header_id = oola.header_id
   AND oola.line_category_code = 'RETURN'
   AND shipped_quantity IS NOT NULL
   AND oola.inventory_item_id = msib.inventory_item_id
   AND oola.ship_from_org_id = msib.organization_id
   AND ooha.sold_to_org_id = hcaa.cust_account_id
   AND hp.party_id = hps.party_id
   AND hps.location_id = hl.location_id
   AND hp.party_id = hcaa.party_id
   AND hcaa.cust_account_id = hcasa.cust_account_id
   AND hcasa.cust_acct_site_id = hcsua.cust_acct_site_id
   AND hcsua.site_use_code = 'BILL_TO'
   AND hcasa.party_site_id = hps.party_site_id

No comments:

Post a Comment