2023-03-31

[Oracle]How to Query Customer Item

SELECT MCI.CONTAINER_ITEM_ORG_ID ORG_ID,
       MCI.CUSTOMER_ID,
       HZC.ACCOUNT_NUMBER        CUSTOMER_NUMBER,
       MFL.MEANING               ITEM_LEVEL,
       HZP.PARTY_NAME            CUSTOMER_NAME,
       MCIXRF.CUSTOMER_ITEM_ID,
       MCI.CUSTOMER_ITEM_NUMBER,
       MCI.CUSTOMER_ITEM_DESC,
       MCIXRF.INVENTORY_ITEM_ID,
       MSI.CONCATENATED_SEGMENTS,
       MSIT.DESCRIPTION          ITEM_DESCRIPTION,
       MCIXRF.PREFERENCE_NUMBER  RANK
  FROM MTL_CUSTOMER_ITEMS      MCI,
       MTL_CUSTOMER_ITEM_XREFS MCIXRF,
       MTL_SYSTEM_ITEMS_TL     MSIT,
       MTL_SYSTEM_ITEMS_B_KFV  MSI,
       HZ_PARTIES              HZP,
       HZ_CUST_ACCOUNTS        HZC,
       AR_LOOKUPS              ARL,
       MFG_LOOKUPS             MFL
 WHERE MCIXRF.CUSTOMER_ITEM_ID = MCI.CUSTOMER_ITEM_ID
   AND MCIXRF.INVENTORY_ITEM_ID = MSI.INVENTORY_ITEM_ID
   AND MCIXRF.MASTER_ORGANIZATION_ID = MSI.ORGANIZATION_ID
   AND MCIXRF.INVENTORY_ITEM_ID = MSIT.INVENTORY_ITEM_ID
   AND MCIXRF.MASTER_ORGANIZATION_ID = MSIT.ORGANIZATION_ID
   AND MSIT.LANGUAGE = USERENV('LANG')
   AND MCI.CUSTOMER_ID = HZC.CUST_ACCOUNT_ID
   AND MCI.CUSTOMER_CATEGORY_CODE = ARL.LOOKUP_CODE(+)
   AND ARL.ENABLED_FLAG(+) = 'Y'
   AND ARL.LOOKUP_TYPE(+) = 'ADDRESS_CATEGORY'
   AND TRUNC(SYSDATE) BETWEEN
       NVL(TRUNC((ARL.START_DATE_ACTIVE(+))), SYSDATE) AND
       NVL(TRUNC((ARL.END_DATE_ACTIVE(+))), SYSDATE)
   AND HZC.STATUS = 'A'
   AND MCI.ITEM_DEFINITION_LEVEL = MFL.LOOKUP_CODE
   AND MFL.LOOKUP_TYPE = 'INV_ITEM_DEFINITION_LEVEL'
   AND MCI.INACTIVE_FLAG = 'N'
   AND HZC.PARTY_ID = HZP.PARTY_ID
      --AND MCI.CUSTOMER_ID NOT IN 501669
      --AND MSI.INVENTORY_ITEM_ID = 365795
   AND MCIXRF.INACTIVE_FLAG = 'N'

沒有留言:

張貼留言