Wednesday, 26 August 2020

Oracle Fusion Maintenance Cloud - Asset Work Order Resource Extract Query

select 

'KEY' AS "KEY",

ROWNUM SR_NO,

WWO.WORK_ORDER_ID,

WWO.ORGANIZATION_ID,

HOU.NAME ORG_NAME,

WWO.WORK_ORDER_PRIORITY,

WWO.WORK_ORDER_NUMBER,

WWOT.WORK_ORDER_DESCRIPTION,

WWST.WO_STATUS_NAME,

WWA.WO_ASSET_ID,

CAB.ASSET_ID,

CAB.ASSET_NUMBER,

CAV.DESCRIPTION,

CAB.SERIAL_NUMBER,

WWO.PLANNED_START_DATE WO_START_DATE,

WWO.PLANNED_COMPLETION_DATE WO_COMPLETION_DATE,

CASE WHEN (WWO.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WWO.LAST_UPDATE_DATE

WHEN (WWOT.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WWOT.LAST_UPDATE_DATE

WHEN (WWA.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WWA.LAST_UPDATE_DATE

WHEN (WWST.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WWST.LAST_UPDATE_DATE

WHEN (WWD.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WWD.LAST_UPDATE_DATE

WHEN (WWDNT.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WWDNT.LAST_UPDATE_DATE

WHEN (WWOV.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WWOV.LAST_UPDATE_DATE

WHEN (WWORV.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WWORV.LAST_UPDATE_DATE

WHEN (WRT.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WRT.LAST_UPDATE_DATE

WHEN (WRB.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WRB.LAST_UPDATE_DATE

END AS LAST_UPDATE_DATE,

WWO.WORK_ORDER_TYPE,

WWO.WORK_ORDER_SUB_TYPE,

WWO.WORK_DEFINITION_ID,

WWDNT.WORK_DEF_NAME,

WWOV.WD_OPERATION_ID,

WWOV.WORK_CENTER_ID,

WWOV.OPERATION_SEQ_NUMBER,

WWOV.OPERATION_DESCRIPTION OPERATION_CODE,

WWOV.OPERATION_TYPE,

WWOV.OPERATION_NAME,

WWOV.WORK_CENTER_CODE,

WWOV.PLANNED_START_DATE OPERATION_START_DATE,

WWOV.PLANNED_COMPLETION_DATE OPERATION_END_DATE,

WWOV.WO_OPERATION_ID,

/*

WWOMV.WO_OPERATION_MATERIAL_ID,

WWOMV.MATERIAL_SEQ_NUMBER,

WWOMV.INVENTORY_ITEM_ID,

(select ITEM_NUMBER from egp_system_items_b where INVENTORY_ITEM_ID=WWOMV.INVENTORY_ITEM_ID AND ROWNUM=1) ITEM,

(SELECT 

ESIT.DESCRIPTION

FROM

EGP_SYSTEM_ITEMS_B ESI,

   EGP_SYSTEM_ITEMS_TL ESIT

WHERE

ESI.INVENTORY_ITEM_ID = ESIT.INVENTORY_ITEM_ID

AND ESI.ORGANIZATION_ID = ESIT.ORGANIZATION_ID

AND ESI.INVENTORY_ITEM_ID = WWOMV.INVENTORY_ITEM_ID

AND ROWNUM=1

)     ITEM_DESC,

WWOMV.QUANTITY REQUIRED_QTY,

WWOMV.UOM_CODE ITEM_UOM,

WWOMV.REQUIRED_DATE,

WWOMV.SUPPLY_TYPE,

WWOMV.SUPPLY_SUBINVENTORY,

*/

WWORV.WO_OPERATION_RESOURCE_ID,

WWORV.RESOURCE_ID,

WWORV.RESOURCE_SEQ_NUMBER,

WRT.RESOURCE_NAME,

DECODE(WWORV.BASIS_TYPE,1,'Variable',2,'Fixed') BASIS,

WWORV.ASSIGNED_UNITS AVAILABLE_UNIT,

WWORV.USAGE_RATE,

WWORV.REQUIRED_USAGE,

WWORV.UOM_CODE RESOURCE_UOM,

WRB.RESOURCE_TYPE,

WWORV.SCHEDULED_FLAG,

WWORV.CHARGE_TYPE

FROM 

WIE_WORK_ORDERS_B WWO,

HR_ORGANIZATION_UNITS HOU,

WIE_WORK_ORDERS_TL WWOT,

WIE_WO_ASSETS WWA,

CSE_ASSETS_B CAB,

CSE_ASSETS_VL CAV,

WIE_WO_STATUSES_TL WWST,

WIS_WORK_DEFINITIONS WWD,

WIS_WORK_DEFINITION_NAMES_TL WWDNT,

WIE_WO_OPERATIONS_V  WWOV,

-- WIE_WO_OPERATION_MATERIALS_V WWOMV,

WIE_WO_OPERATION_RESOURCES WWORV,

WIS_RESOURCES_B WRB,

WIS_RESOURCES_TL WRT

WHERE 

WWO.ORGANIZATION_ID=HOU.ORGANIZATION_ID

AND WWO.WORK_ORDER_ID=WWOT.WORK_ORDER_ID

AND WWOT.SOURCE_LANG='US'

AND WWO.WORK_ORDER_ID=WWA.WORK_ORDER_ID(+)  --- Outer join to fetch all work order data even asset detail is not available

AND WWO.ORGANIZATION_ID=WWA.ORGANIZATION_ID(+) --- Outer join to fetch all work order data even asset detail is not available

AND WWA.ASSET_ID = CAB.ASSET_ID

AND CAB.ASSET_ID = CAV.ASSET_ID

AND WWO.WORK_ORDER_STATUS_ID=WWST.WO_STATUS_ID

AND WWST.LANGUAGE='US' 

AND WWO.WORK_DEFINITION_ID=WWD.WORK_DEFINITION_ID(+)    ---Outer Join Fetch WO data even Work Definition is blank

AND WWO.ORGANIZATION_ID=WWD.ORGANIZATION_ID(+) ---Outer Join Fetch WO data even Work Definition is blank

AND WWD.WORK_DEFINITION_NAME_ID=WWDNT.WORK_DEFINITION_NAME_ID

AND WWDNT.LANGUAGE='US' 

AND WWO.WORK_ORDER_ID=WWOV.WORK_ORDER_ID(+) ---Outer Join Fetch WO data even Operation data is null

AND WWO.ORGANIZATION_ID=WWOV.ORGANIZATION_ID(+) ---Outer Join Fetch WO data even Operation data is null

-- AND WWO.WORK_ORDER_ID=WWOMV.WORK_ORDER_ID(+) ---Outer Join Fetch WO data even Material data is null

-- AND WWO.ORGANIZATION_ID=WWOMV.ORGANIZATION_ID(+) ---Outer Join Fetch WO data even Material data is null

-- AND WWOV.WO_OPERATION_ID=WWOMV.WO_OPERATION_ID

AND WWOV.WO_OPERATION_ID=WWORV.WO_OPERATION_ID(+)

AND WWOV.ORGANIZATION_ID=WWORV.ORGANIZATION_ID(+)

AND WRB.RESOURCE_ID=WWORV.RESOURCE_ID

AND WRB.ORGANIZATION_ID = WWORV.ORGANIZATION_ID

AND WRT.RESOURCE_ID=WRB.RESOURCE_ID

AND WRT.SOURCE_LANG='US'

--AND WWO.WORK_ORDER_NUMBER='GDI2797'

AND (

(WWO.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) 

OR (WWOT.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss'))

OR (WWA.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) 

OR (WWST.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) 

OR (WWD.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) 

OR (WWDNT.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) 

OR (WWOV.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) 

OR (WWORV.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) 

OR (WRB.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) 

OR (WRT.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) 

)

Oracle Fusion Maintenance Cloud - Asset Work Order Material Extract Query

select 

'KEY' AS "KEY",

ROWNUM SR_NO,

WWO.WORK_ORDER_ID,

WWO.ORGANIZATION_ID,

HOU.NAME ORG_NAME,

WWO.WORK_ORDER_PRIORITY,

WWO.WORK_ORDER_NUMBER,

WWOT.WORK_ORDER_DESCRIPTION,

WWST.WO_STATUS_NAME,

WWA.WO_ASSET_ID,

CAB.ASSET_ID,

CAB.ASSET_NUMBER,

CAV.DESCRIPTION,

CAB.SERIAL_NUMBER,

WWO.PLANNED_START_DATE WO_START_DATE,

WWO.PLANNED_COMPLETION_DATE WO_COMPLETION_DATE,

CASE WHEN (WWO.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WWO.LAST_UPDATE_DATE

WHEN (WWOT.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WWOT.LAST_UPDATE_DATE

WHEN (WWA.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WWA.LAST_UPDATE_DATE

WHEN (WWST.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WWST.LAST_UPDATE_DATE

WHEN (WWD.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WWD.LAST_UPDATE_DATE

WHEN (WWDNT.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WWDNT.LAST_UPDATE_DATE

WHEN (WWOV.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WWOV.LAST_UPDATE_DATE

WHEN (WWOMV.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) THEN WWOMV.LAST_UPDATE_DATE

END AS LAST_UPDATE_DATE,

WWO.WORK_ORDER_TYPE,

WWO.WORK_ORDER_SUB_TYPE,

WWO.WORK_DEFINITION_ID,

WWDNT.WORK_DEF_NAME,

WWOV.WD_OPERATION_ID,

WWOV.WORK_CENTER_ID,

WWOV.OPERATION_SEQ_NUMBER,

WWOV.OPERATION_DESCRIPTION OPERATION_CODE,

WWOV.OPERATION_TYPE,

WWOV.OPERATION_NAME,

WWOV.WORK_CENTER_CODE,

WWOV.PLANNED_START_DATE OPERATION_START_DATE,

WWOV.PLANNED_COMPLETION_DATE OPERATION_END_DATE,

WWOV.WO_OPERATION_ID,

WWOMV.WO_OPERATION_MATERIAL_ID,

WWOMV.MATERIAL_SEQ_NUMBER,

WWOMV.INVENTORY_ITEM_ID,

(select ITEM_NUMBER from egp_system_items_b where INVENTORY_ITEM_ID=WWOMV.INVENTORY_ITEM_ID AND ROWNUM=1) ITEM,

(SELECT 

ESIT.DESCRIPTION

FROM

EGP_SYSTEM_ITEMS_B ESI,

   EGP_SYSTEM_ITEMS_TL ESIT

WHERE

ESI.INVENTORY_ITEM_ID = ESIT.INVENTORY_ITEM_ID

AND ESI.ORGANIZATION_ID = ESIT.ORGANIZATION_ID

AND ESI.INVENTORY_ITEM_ID = WWOMV.INVENTORY_ITEM_ID

AND ROWNUM=1

)     ITEM_DESC,

WWOMV.QUANTITY REQUIRED_QTY,

WWOMV.UOM_CODE ITEM_UOM,

WWOMV.REQUIRED_DATE,

(select meaning from WIE_WO_SUPPLY_TYPES_V where LOOKUP_CODE=WWOMV.SUPPLY_TYPE) SUPPLY_TYPE,

WWOMV.SUPPLY_SUBINVENTORY

FROM 

WIE_WORK_ORDERS_B WWO,

HR_ORGANIZATION_UNITS HOU,

WIE_WORK_ORDERS_TL WWOT,

WIE_WO_ASSETS WWA,

CSE_ASSETS_B CAB,

CSE_ASSETS_VL CAV,

WIE_WO_STATUSES_TL WWST,

WIS_WORK_DEFINITIONS WWD,

WIS_WORK_DEFINITION_NAMES_TL WWDNT,

WIE_WO_OPERATIONS_V  WWOV,

WIE_WO_OPERATION_MATERIALS_V WWOMV

WHERE 

WWO.ORGANIZATION_ID=HOU.ORGANIZATION_ID

AND WWO.WORK_ORDER_ID=WWOT.WORK_ORDER_ID

AND WWOT.SOURCE_LANG='US'

AND WWO.WORK_ORDER_ID=WWA.WORK_ORDER_ID(+)  --- Outer join to fetch all work order data even asset detail is not available

AND WWO.ORGANIZATION_ID=WWA.ORGANIZATION_ID(+) --- Outer join to fetch all work order data even asset detail is not available

AND WWA.ASSET_ID = CAB.ASSET_ID

AND CAB.ASSET_ID = CAV.ASSET_ID

AND WWO.WORK_ORDER_STATUS_ID=WWST.WO_STATUS_ID

AND WWST.LANGUAGE='US' 

AND WWO.WORK_DEFINITION_ID=WWD.WORK_DEFINITION_ID(+)    ---Outer Join Fetch WO data even Work Definition is blank

AND WWO.ORGANIZATION_ID=WWD.ORGANIZATION_ID(+) ---Outer Join Fetch WO data even Work Definition is blank

AND WWD.WORK_DEFINITION_NAME_ID=WWDNT.WORK_DEFINITION_NAME_ID

AND WWDNT.LANGUAGE='US' 

AND WWO.WORK_ORDER_ID=WWOV.WORK_ORDER_ID(+) ---Outer Join Fetch WO data even Operation data is null

AND WWO.ORGANIZATION_ID=WWOV.ORGANIZATION_ID(+) ---Outer Join Fetch WO data even Operation data is null

AND WWO.WORK_ORDER_ID=WWOMV.WORK_ORDER_ID(+) ---Outer Join Fetch WO data even Material data is null

AND WWO.ORGANIZATION_ID=WWOMV.ORGANIZATION_ID(+) ---Outer Join Fetch WO data even Material data is null

AND WWOV.WO_OPERATION_ID=WWOMV.WO_OPERATION_ID

--AND WWO.WORK_ORDER_NUMBER='GDI2797'

AND (

(WWO.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) 

OR (WWOT.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss'))

OR (WWA.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) 

OR (WWST.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) 

OR (WWD.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) 

OR (WWDNT.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) 

OR (WWOV.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) 

OR (WWOMV.LAST_UPDATE_DATE BETWEEN TO_DATE(:P_START_DT,'mm-dd-yyyy hh24:mi:ss')  AND TO_DATE(:P_END_DT,'mm-dd-yyyy hh24:mi:ss')) 

)

Sunday, 16 August 2020

Oracle Fusion Maintenance Cloud - Maintenance Work Definition-Material- Resource Extract


SELECT

'KEY' AS "KEY",

ROWNUM SR_NO,

X.*

FROM

(

SELECT 

*

FROM

(

SELECT 

WWMNV.MAINTENANCE_WD_NAME Work_Definition_Name,

WWV.VERSION_NUMBER,

WWV.EFFECTIVE_FROM_DATE,

WWV.EFFECTIVE_TO_DATE,

WWMNV.ORGANIZATION_ID,

CASE WHEN (TRUNC(WWMNV.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WWMNV.LAST_UPDATE_DATE

WHEN (TRUNC(WWDV.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WWDV.LAST_UPDATE_DATE

WHEN (TRUNC(WWOB.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WWOB.LAST_UPDATE_DATE

WHEN (TRUNC(WWC.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WWC.LAST_UPDATE_DATE

WHEN (TRUNC(WWOM.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WWOM.LAST_UPDATE_DATE

WHEN (TRUNC(WWOT.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WWOT.LAST_UPDATE_DATE

WHEN (TRUNC(WWORV.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WWORV.LAST_UPDATE_DATE

WHEN (TRUNC(WWV.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WWV.LAST_UPDATE_DATE

END AS LAST_UPDATE_DATE,

WWDV.WORK_DEFINITION_ID,

WWDV.WORK_DEFINITION_TYPE,

WWDV.WORK_DEFINITION_NAME_ID,

WWDV.WORK_METHOD_ID,

WWOB.WD_OPERATION_ID,

WWOB.WORK_CENTER_ID,

WWOB.OPERATION_SEQ_NUMBER,

WWOT.OPERATION_NAME,

WWC.WORK_CENTER_NAME,

WWOB.OPERATION_TYPE,

WWC.WORK_AREA_ID,

WWOM.WD_OPERATION_MATERIAL_ID,

WWOM.INVENTORY_ITEM_ID,

WWOM.MATERIAL_SEQ_NUMBER,

(select ITEM_NUMBER from egp_system_items_b where INVENTORY_ITEM_ID=WWOM.INVENTORY_ITEM_ID AND ROWNUM=1) ITEM,

WWOM.UOM_CODE,

WWOM.MATERIAL_QUANTITY,

WWOM.MATERIAL_TYPE,

WWORV.RESOURCE_ID,

WWORV.RESOURCE_NAME,

WWORV.RESOURCE_SEQ_NUMBER,

WWORV.ASSIGNED_UNITS,

WWORV.USAGE_RATE,

WWORV.UOM_CODE RESOURCE_UOM

FROM 

WIS_WD_MAINTENANCE_NAMES_VL WWMNV,

WIS_WORK_DEFINITIONS_V WWDV,

WIS_WD_OPERATIONS_B WWOB,

wis_work_centers_vl WWC,

WIS_WD_OPERATION_MATERIALS WWOM,

WIS_WD_OPERATIONS_TL WWOT,

WIS_WD_OPERATION_RESOURCES_V WWORV,

WIS_WD_VERSIONS WWV

WHERE 

WWMNV.WD_MNT_NAME_ID=WWDV.WD_MNT_NAME_ID

AND WWMNV.ORGANIZATION_ID=WWDV.ORGANIZATION_ID

AND WWOB.WORK_DEFINITION_ID=WWDV.WORK_DEFINITION_ID

AND WWOB.WORK_CENTER_ID=WWC.WORK_CENTER_ID

AND WWMNV.ORGANIZATION_ID=WWC.ORGANIZATION_ID

AND WWOB.WD_OPERATION_ID=WWOM.WD_OPERATION_ID

AND WWOT.LANGUAGE='US' 

AND WWOT.WD_OPERATION_ID=WWOB.WD_OPERATION_ID

AND WWOB.STANDARD_OPERATION_ID IS NULL

AND WWORV.WORK_CENTER_ID=WWOB.WORK_CENTER_ID

AND WWORV.WD_OPERATION_ID=WWOB.WD_OPERATION_ID

AND WWV.WORK_DEFINITION_ID=WWDV.WORK_DEFINITION_ID

-- AND WWMNV.MAINTENANCE_WD_CODE='Large Truck Service'

AND (

(TRUNC(WWMNV.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

OR (TRUNC(WWDV.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

OR (TRUNC(WWOB.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

OR (TRUNC(WWC.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

OR (TRUNC(WWOM.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

OR (TRUNC(WWOT.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

OR (TRUNC(WWORV.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

OR (TRUNC(WWV.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

)


----STD OPERATION 

UNION ALL

SELECT 

WWMNV.MAINTENANCE_WD_NAME Work_Definition_Name,

WWV.VERSION_NUMBER,

WWV.EFFECTIVE_FROM_DATE,

WWV.EFFECTIVE_TO_DATE,

WWMNV.ORGANIZATION_ID,

CASE WHEN (TRUNC(WWMNV.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WWMNV.LAST_UPDATE_DATE

WHEN (TRUNC(WWDV.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WWDV.LAST_UPDATE_DATE

WHEN (TRUNC(WWOB.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WWOB.LAST_UPDATE_DATE

WHEN (TRUNC(WWC.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WWC.LAST_UPDATE_DATE

WHEN (TRUNC(WSOB.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WSOB.LAST_UPDATE_DATE

WHEN (TRUNC(WWOM.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WWOM.LAST_UPDATE_DATE

WHEN (TRUNC(WWOT.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WWOT.LAST_UPDATE_DATE

WHEN (TRUNC(WWORV.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WWORV.LAST_UPDATE_DATE

WHEN (TRUNC(WWV.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) THEN WWV.LAST_UPDATE_DATE

END AS LAST_UPDATE_DATE,

WWDV.WORK_DEFINITION_ID,

WWDV.WORK_DEFINITION_TYPE,

WWDV.WORK_DEFINITION_NAME_ID,

WWDV.WORK_METHOD_ID,

WWOB.WD_OPERATION_ID,

WSOB.WORK_CENTER_ID,

WWOB.OPERATION_SEQ_NUMBER,

WSOB.STANDARD_OPERATION_CODE OPERATION_NAME,

WWC.WORK_CENTER_NAME,

WWOB.OPERATION_TYPE,

WWC.WORK_AREA_ID,

WWOM.WD_OPERATION_MATERIAL_ID,

WWOM.INVENTORY_ITEM_ID,

WWOM.MATERIAL_SEQ_NUMBER,

(select ITEM_NUMBER from egp_system_items_b where INVENTORY_ITEM_ID=WWOM.INVENTORY_ITEM_ID AND ROWNUM=1) ITEM,

WWOM.UOM_CODE,

WWOM.MATERIAL_QUANTITY,

WWOM.MATERIAL_TYPE,

WWORV.RESOURCE_ID,

WWORV.RESOURCE_NAME,

WWORV.RESOURCE_SEQ_NUMBER,

WWORV.ASSIGNED_UNITS,

WWORV.USAGE_RATE,

WWORV.UOM_CODE RESOURCE_UOM

FROM 

WIS_WD_MAINTENANCE_NAMES_VL WWMNV,

WIS_WORK_DEFINITIONS_V WWDV,

WIS_WD_OPERATIONS_B WWOB,

wis_work_centers_vl WWC,

WIS_STANDARD_OPERATIONS_B WSOB,

WIS_WD_OPERATION_MATERIALS WWOM,

WIS_WD_OPERATIONS_TL WWOT,

WIS_WD_OPERATION_RESOURCES_V WWORV,

WIS_WD_VERSIONS WWV

WHERE 

WWMNV.WD_MNT_NAME_ID=WWDV.WD_MNT_NAME_ID

AND WWMNV.ORGANIZATION_ID=WWDV.ORGANIZATION_ID

AND WWOB.WORK_DEFINITION_ID=WWDV.WORK_DEFINITION_ID

AND WSOB.STANDARD_OPERATION_ID=WWOB.STANDARD_OPERATION_ID

AND WSOB.WORK_CENTER_ID=WWC.WORK_CENTER_ID

AND WWMNV.ORGANIZATION_ID=WWC.ORGANIZATION_ID

AND WWOB.WD_OPERATION_ID=WWOM.WD_OPERATION_ID(+)

AND WWOT.LANGUAGE='US' 

AND WWOT.WD_OPERATION_ID=WWOB.WD_OPERATION_ID

AND WWOB.STANDARD_OPERATION_ID IS NOT NULL

AND WWORV.WORK_CENTER_ID=WSOB.WORK_CENTER_ID

AND WWORV.WD_OPERATION_ID=WWOB.WD_OPERATION_ID

AND WWV.WORK_DEFINITION_ID=WWDV.WORK_DEFINITION_ID

-- AND WWMNV.MAINTENANCE_WD_CODE='Large Truck Service'

AND (

(TRUNC(WWMNV.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

OR (TRUNC(WWDV.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

OR (TRUNC(WWOB.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

OR (TRUNC(WWC.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

OR (TRUNC(WSOB.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

OR (TRUNC(WWOM.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

OR (TRUNC(WWOT.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

OR (TRUNC(WWORV.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

OR (TRUNC(WWV.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) 

)


ORDER BY WORK_DEFINITION_ID,VERSION_NUMBER,OPERATION_SEQ_NUMBER,MATERIAL_SEQ_NUMBER,RESOURCE_SEQ_NUMBER

) X