Sunday 8 July 2018

Oracle Item Category Extract Query

select
msi.segment1 Item_Code,  msi.DESCRIPTION Item_Desc,
mcs.CATEGORY_SET_NAME, mck.CONCATENATED_SEGMENTS,
mck.SEGMENT1, mck.SEGMENT2, mck.SEGMENT3, mck.SEGMENT4, mck.SEGMENT5,
mck.SEGMENT6, mck.SEGMENT7, mck.SEGMENT8, mck.SEGMENT9, mck.SEGMENT10,
mck.SEGMENT11, mck.SEGMENT12, mck.SEGMENT13, mck.SEGMENT14, mck.SEGMENT15,
mck.SEGMENT16, mck.SEGMENT17, mck.SEGMENT18, mck.SEGMENT19, mck.SEGMENT20
from mtl_system_items_b msi, mtl_item_categories mic, MTL_CATEGORIES_KFV MCK, MTL_CATEGORY_SETS_TL mcs
where msi.INVENTORY_ITEM_ID = mic.INVENTORY_ITEM_ID and msi.ORGANIZATION_ID = mic.ORGANIZATION_ID
and mic.CATEGORY_ID = mck.CATEGORY_ID
and mcs.CATEGORY_SET_ID = mic.CATEGORY_SET_ID and mcs.LANGUAGE = userenv('Lang')
and msi.ORGANIZATION_ID = :P_Org_id

Oracle Supplier Master Extract Query

select
         pv.vendor_name Supplier_name,
         pv.segment1 Supplier_num,       
         pvs.vendor_site_code Supplier_site_name,
         (select party_site_number from hz_party_sites where party_site_id = pvs.party_site_id) site_num,
          (select territory_short_name from fnd_territories_vl ft where pvs.country = ft.territory_code) site_country,
         pvs.address_line1 site_address_line1,
         pvs.address_line2 site_address_line2,
         pvs.address_line3 site_address_line3,
         pvs.address_line4 site_address_line4,
         pvs.city site_city,
         pvs.county site_county,
         pvs.state site_state,
         pvs.zip site_Postal_code,
         hou.name BU_NAME ,
         ship_loc.location_code ship_to_location_name, 
         ship_loc.address_line_1   ship_address_line_1,
         ship_loc.address_line_2   ship_address_line_2,
         ship_loc.address_line_3   ship_address_line_3,
         ship_loc.town_or_city ship_to_city,
         ship_loc.postal_code ship_to_postal_code,
         (select territory_short_name from fnd_territories_vl ft where ship_loc.country = ft.territory_code) ship_to_country,
         bill_loc.location_code    bill_to_location_name, 
         bill_loc.address_line_1   bill_address_line_1,
         bill_loc.address_line_2   bill_address_line_2,
         bill_loc.address_line_3   bill_address_line_3,
         bill_loc.town_or_city bill_to_city,
         bill_loc.postal_code bill_to_postal_code,
         (select territory_short_name from fnd_territories_vl ft where bill_loc.country = ft.territory_code) bill_to_country
from apps.po_vendors pv,
          apps.ap_supplier_sites_all pvs,
          apps.hr_operating_units hou,
          hr_locations bill_loc,
          hr_locations ship_loc
where pv.vendor_id = pvs.vendor_id
   and pvs.org_id = hou.organization_id
   and pvs.bill_to_location_id = bill_loc.location_id(+)
   and pvs.ship_to_location_id = ship_loc.location_id(+)
--   and pvs.org_id = 43
   and ((pv.end_date_active is null) or (pv.end_date_active > trunc(sysdate)))
  and ((pvs.inactive_date is null) or (pvs.inactive_date > trunc(sysdate)))
order by pv.vendor_id,pvs.vendor_site_id

Oracle Customer Master Extract Query


SELECT GLL.NAME Ledger_name,
       HP.PARTY_NAME CUSTOMER_NAME,
       HP.PARTY_NUMBER CUSTOMER_NUMBER,
       HCA.ACCOUNT_NUMBER Customer_account_number,
        hps.party_site_name,
        hps.party_site_number,       
       (select TERRITORY_SHORT_NAME from FND_TERRITORIES_TL where TERRITORY_CODE =hl.COUNTRY and language = 'US') site_COUNTRY,       
        HL.ADDRESS1,
        HL.ADDRESS2,
        HL.ADDRESS3,
        HL.ADDRESS4,
        HL.CITY,
        hl.county,
        hl.state,
        hl.POSTAL_CODE,
        HROU.NAME OPERATING_UNIT,       
       hps.party_site_name,     
       hl.city site_name,
       HCSUB.SITE_USE_CODE BILL_TO_CODE,
        HCSUB.PRIMARY_FLAG BILL_TO_FLAG,
       HCSUB.LOCATION BILL_TO_LOCATION,     
       HCSUS.SITE_USE_CODE SHIP_TO_CODE,
       HCSUS.PRIMARY_FLAG SHIP_TO_FLAG,   
       HCSUS.LOCATION SHIP_TO_LOCATION
  FROM APPS.HZ_PARTIES HP,
       GL_LEDGERS GLL,
       APPS.HZ_PARTY_SITES HPS,
       APPS.HZ_LOCATIONS HL,
       APPS.HZ_CUST_ACCOUNTS_ALL HCA,
       APPS.HZ_CUST_ACCT_SITES_ALL HCSA,
       APPS.HZ_CUST_SITE_USES_ALL HCSUS,
       HZ_CUST_SITE_USES_ALL HCSUB,
       HR_OPERATING_UNITS HROU
 WHERE     HP.PARTY_ID = HPS.PARTY_ID
       AND HROU.SET_OF_BOOKS_ID = GLL.LEDGER_ID
       AND HPS.LOCATION_ID = HL.LOCATION_ID
       AND HCSA.ORG_ID = HROU.ORGANIZATION_ID
       AND HP.PARTY_ID = HCA.PARTY_ID
       AND HCSA.PARTY_SITE_ID(+) = HPS.PARTY_SITE_ID
       AND HCSUS.CUST_ACCT_SITE_ID(+) = HCSA.CUST_ACCT_SITE_ID
       AND HCSUB.CUST_ACCT_SITE_ID(+) = HCSA.CUST_ACCT_SITE_ID
       AND HCA.CUST_ACCOUNT_ID = HCSA.CUST_ACCOUNT_ID
       AND HCSUS.SITE_USE_CODE(+) = 'SHIP_TO'
       AND HCSUB.SITE_USE_CODE(+) = 'BILL_TO'
--       and hp.party_name like 'BAY%SHORE%'
 --    AND GLL.NAME LIKE '%MCC%'