Wednesday, September 28, 2011

Dead Reservations

SELECT L.LINE_ID,
( SELECT ORDER_NUMBER FROM OE_ORDER_HEADERS_ALL WE WHERE WE.HEADER_ID = L.HEADER_ID) ORDER_NUMBER
, ORDERED_ITEM
, RESERVATION_QUANTITY
FROM OE_ORDER_LINES_ALL L, MTL_RESERVATIONS M
WHERE M.PRIMARY_RESERVATION_QUANTITY>0
AND nvl(L.OPEN_FLAG,'Y')='N'
AND L.LINE_ID = M.DEMAND_SOURCE_LINE_ID
AND NOT EXISTS (SELECT NULL FROM MTL_TRANSACTIONS_INTERFACE MTI
WHERE MTI.TRX_SOURCE_LINE_ID = L.LINE_ID
AND MTI.SOURCE_HEADER_ID = L.HEADER_ID
AND MTI.SOURCE_CODE = nvl('&OE_SOURCE_CODE',MTI.SOURCE_CODE))
AND NOT EXISTS (SELECT 1 FROM WSH_DELIVERY_DETAILS WDD
WHERE WDD.SOURCE_LINE_ID=L.LINE_ID
AND WDD.SOURCE_CODE ='OE'
AND WDD.INV_INTERFACED_FLAG IN ('N','P')
AND WDD.RELEASED_STATUS <> 'D');

No comments:

Post a Comment