SELECT A.SETID ,A.INV_ITEM_ID ,B.VENDOR_SETID ,B.VENDOR_ID ,A.CATEGORY_ID ,A.UNIT_MEASURE_STD ,F.DESCR ,A.DESCR60 ,B.ITM_ID_VNDR ,B.VNDR_CATALOG_ID ,T.TREE_NAME ,F.PRICE_LIST ,B.ITM_VNDR_PRIORITY ,F.CURRENCY_CD ,B.VNDR_NAME1 ,B.VNDR_LOC FROM PS_MASTER_ITEM_TBL A , PS_ITM_CAT_TBL J , PS_PV_PERF_VNDR_VW B , PS_PURCH_ITEM_ATTR F , PS_PV_CAT_TREE_TBL T WHERE A.INV_ITEM_ID = B.INV_ITEM_ID (+) AND A.SETID = B.SETID (+) AND A.ITM_STATUS_CURRENT = '1' AND A.SETID = F.SETID AND A.INV_ITEM_ID = F.INV_ITEM_ID AND ((%CurrentDateIn >= F.PO_AVAIL_DT) AND (F.PO_UNAVAIL_DT > %CurrentDateIn )) AND A.SETID = J.SETID AND J.EFF_STATUS = 'A' AND A.CATEGORY_ID = J.CATEGORY_ID AND J.EFFDT = ( SELECT MAX(EFFDT) FROM PS_ITM_CAT_TBL WHERE SETID = J.SETID AND CATEGORY_ID = J.CATEGORY_ID AND CATEGORY_CD = J.CATEGORY_CD AND EFFDT <= %CurrentDateIn) AND A.SETID = T.SETID AND A.CATEGORY_ID = T.CATEGORY_ID AND A.INV_ITEM_ID NOT IN( SELECT INV_ITEM_ID FROM PS_MASTER_ITEM_TBL WHERE A.ITM_STAT_DT_FUTURE <= %CurrentDateIn AND A.ITM_STATUS_FUTURE <> '1') AND (EXISTS ( SELECT 'X' FROM PS_INSTALLATION_PV WHERE PV_NONDYNAMICRANGE = 'Y') AND (((A.INV_ITEM_ID >= T.RANGE_FROM AND A.INV_ITEM_ID <= T.RANGE_TO) AND T.DYNAMIC_RANGE = 'N') ) OR NOT EXISTS ( SELECT 'X' FROM PS_INSTALLATION_PV WHERE PV_NONDYNAMICRANGE = 'Y'))
|