0% found this document useful (0 votes)
296 views12 pages

Work Order

The document defines a SQL view that selects and aggregates data from various tables to display work order information. The view selects over 150 columns from tables related to work orders, work order details, assets, projects, and other maintenance-related data. It includes descriptive fields to display additional information for some columns.

Uploaded by

Sp Vinoth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
296 views12 pages

Work Order

The document defines a SQL view that selects and aggregates data from various tables to display work order information. The view selects over 150 columns from tables related to work orders, work order details, assets, projects, and other maintenance-related data. It includes descriptive fields to display additional information for some columns.

Uploaded by

Sp Vinoth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 12

DROP VIEW APPS.

EAM_WORK_ORDERS_V;
/* Formatted on 2016/08/01 14:45 (Formatter Plus v4.8.8) */
CREATE OR REPLACE FORCE VIEW apps.eam_work_orders_v (row_id,
sched_parent_wip_entity_nam
e,
actual_start_date,
wip_entity_id,
wip_entity_name,
we_row_id,
entity_type,
organization_id,
last_update_date,
last_updated_by,
creation_date,
created_by,
last_update_login,
description,
primary_item_id,
asset_activity,
asset_group_id,
asset_number,
asset_description,
class_code,
status_type,
pm_schedule_id,
manual_rebuild_flag,
work_order_type,
work_order_type_disp,
material_account,
material_overhead_account,
resource_account,
outside_processing_account,
material_variance_account,
resource_variance_account,
outside_proc_variance_accou
nt,
std_cost_adjustment_account
,
overhead_account,
overhead_variance_account,
scheduled_start_date,
scheduled_completion_date,
date_released,
date_completed,
date_closed,
owning_department,
owning_department_code,
activity_type,
activity_type_disp,
activity_cause,
activity_cause_disp,
priority,
priority_disp,
requested_start_date,
requested_due_date,
estimation_status,
notification_required,
shutdown_type,
shutdown_type_disp,

tagout_required,
plan_maintenance,
firm_planned_flag,
schedule_group_id,
schedule_group_name,
project_number,
project_name,
project_id,
task_number,
task_name,
task_id,
parent_wip_entity_id,
parent_wip_entity_name,
rebuild_item_id,
rebuild_serial_number,
bom_reference_id,
routing_reference_id,
common_bom_sequence_id,
common_routing_sequence_id,
alternate_bom_designator,
bom_revision,
bom_revision_date,
alternate_routing_designato
r,
routing_revision,
routing_revision_date,
completion_subinventory,
completion_locator_id,
lot_number,
demand_class,
attribute_category,
attribute1,
attribute2,
attribute3,
attribute4,
attribute5,
attribute6,
attribute7,
attribute8,
attribute9,
attribute10,
attribute11,
attribute12,
attribute13,
attribute14,
attribute15,
instance_id,
instance_number,
maintenance_object_source,
maintenance_object_type,
SOURCE,
maintenance_object_id,
service_request_id,
service_request,
material_issue_by_mo,
activity_source,
activity_source_meaning,
eam_linear_location_id,
pending_flag,
user_defined_status_id,

work_order_status,
work_order_status_pending,
material_shortage_check_dat
e,
material_shortage_flag,
material_shortage_disp,
workflow_type,
warranty_claim_status,
cycle_id,
seq_id,
ds_scheduled_flag,
asset_serial_number,
maint_organization_id,
asset_rebuild_group,
pm_suggested_start_date,
pm_suggested_end_date,
failure_id,
failure_entry_id,
failure_code,
cause_code,
resolution_code,
failure_code_required,
failure_date,
comments,
parent_instance_number
)
AS
SELECT "ROW_ID", "SCHED_PARENT_WIP_ENTITY_NAME", "ACTUAL_START_DATE",
"WIP_ENTITY_ID", "WIP_ENTITY_NAME", "WE_ROW_ID", "ENTITY_TYPE",
"ORGANIZATION_ID", "LAST_UPDATE_DATE", "LAST_UPDATED_BY",
"CREATION_DATE", "CREATED_BY", "LAST_UPDATE_LOGIN", "DESCRIPTION",
"PRIMARY_ITEM_ID", "ASSET_ACTIVITY", "ASSET_GROUP_ID",
"ASSET_NUMBER", "ASSET_DESCRIPTION", "CLASS_CODE", "STATUS_TYPE",
"PM_SCHEDULE_ID", "MANUAL_REBUILD_FLAG", "WORK_ORDER_TYPE",
"WORK_ORDER_TYPE_DISP", "MATERIAL_ACCOUNT",
"MATERIAL_OVERHEAD_ACCOUNT", "RESOURCE_ACCOUNT",
"OUTSIDE_PROCESSING_ACCOUNT", "MATERIAL_VARIANCE_ACCOUNT",
"RESOURCE_VARIANCE_ACCOUNT", "OUTSIDE_PROC_VARIANCE_ACCOUNT",
"STD_COST_ADJUSTMENT_ACCOUNT", "OVERHEAD_ACCOUNT",
"OVERHEAD_VARIANCE_ACCOUNT", "SCHEDULED_START_DATE",
"SCHEDULED_COMPLETION_DATE", "DATE_RELEASED", "DATE_COMPLETED",
"DATE_CLOSED", "OWNING_DEPARTMENT", "OWNING_DEPARTMENT_CODE",
"ACTIVITY_TYPE", "ACTIVITY_TYPE_DISP", "ACTIVITY_CAUSE",
"ACTIVITY_CAUSE_DISP", "PRIORITY", "PRIORITY_DISP",
"REQUESTED_START_DATE", "REQUESTED_DUE_DATE", "ESTIMATION_STATUS",
"NOTIFICATION_REQUIRED", "SHUTDOWN_TYPE", "SHUTDOWN_TYPE_DISP",
"TAGOUT_REQUIRED", "PLAN_MAINTENANCE", "FIRM_PLANNED_FLAG",
"SCHEDULE_GROUP_ID", "SCHEDULE_GROUP_NAME", "PROJECT_NUMBER",
"PROJECT_NAME", "PROJECT_ID", "TASK_NUMBER", "TASK_NAME", "TASK_ID",
"PARENT_WIP_ENTITY_ID", "PARENT_WIP_ENTITY_NAME", "REBUILD_ITEM_ID",
"REBUILD_SERIAL_NUMBER", "BOM_REFERENCE_ID", "ROUTING_REFERENCE_ID",
"COMMON_BOM_SEQUENCE_ID", "COMMON_ROUTING_SEQUENCE_ID",
"ALTERNATE_BOM_DESIGNATOR", "BOM_REVISION", "BOM_REVISION_DATE",
"ALTERNATE_ROUTING_DESIGNATOR", "ROUTING_REVISION",
"ROUTING_REVISION_DATE", "COMPLETION_SUBINVENTORY",
"COMPLETION_LOCATOR_ID", "LOT_NUMBER", "DEMAND_CLASS",
"ATTRIBUTE_CATEGORY", "ATTRIBUTE1", "ATTRIBUTE2", "ATTRIBUTE3",
"ATTRIBUTE4", "ATTRIBUTE5", "ATTRIBUTE6", "ATTRIBUTE7",
"ATTRIBUTE8", "ATTRIBUTE9", "ATTRIBUTE10", "ATTRIBUTE11",
"ATTRIBUTE12", "ATTRIBUTE13", "ATTRIBUTE14", "ATTRIBUTE15",

"INSTANCE_ID", "INSTANCE_NUMBER", "MAINTENANCE_OBJECT_SOURCE",


"MAINTENANCE_OBJECT_TYPE", "SOURCE", "MAINTENANCE_OBJECT_ID",
"SERVICE_REQUEST_ID", "SERVICE_REQUEST", "MATERIAL_ISSUE_BY_MO",
"ACTIVITY_SOURCE", "ACTIVITY_SOURCE_MEANING",
"EAM_LINEAR_LOCATION_ID", "PENDING_FLAG", "USER_DEFINED_STATUS_ID",
"WORK_ORDER_STATUS", "WORK_ORDER_STATUS_PENDING",
"MATERIAL_SHORTAGE_CHECK_DATE", "MATERIAL_SHORTAGE_FLAG",
"MATERIAL_SHORTAGE_DISP", "WORKFLOW_TYPE", "WARRANTY_CLAIM_STATUS",
"CYCLE_ID", "SEQ_ID", "DS_SCHEDULED_FLAG", "ASSET_SERIAL_NUMBER",
"MAINT_ORGANIZATION_ID", "ASSET_REBUILD_GROUP",
"PM_SUGGESTED_START_DATE", "PM_SUGGESTED_END_DATE", "FAILURE_ID",
"FAILURE_ENTRY_ID", "FAILURE_CODE", "CAUSE_CODE", "RESOLUTION_CODE",
"FAILURE_CODE_REQUIRED", "FAILURE_DATE", "COMMENTS",
"PARENT_INSTANCE_NUMBER"
FROM (SELECT wdj.ROWID row_id,
(SELECT we.wip_entity_name
FROM eam_wo_relationships ewr,
wip_entities we
WHERE ewr.child_object_id = wdj.wip_entity_id
AND ewr.parent_relationship_type = 1
AND ewr.parent_object_id = we.wip_entity_id)
AS sched_parent_wip_entity_name,
(SELECT actual_start_date
FROM eam_job_completion_txns
WHERE transaction_type = 1
AND transaction_id =
(SELECT MAX (transaction_id)
FROM eam_job_completion_txns ejt
WHERE ejt.wip_entity_id = wdj.wip_entity_id
AND ejt.organization_id = wdj.organization_id))
AS actual_start_date,
wdj.wip_entity_id AS wip_entity_id,
we.wip_entity_name wip_entity_name, we.ROWID AS we_row_id,
we.entity_type entity_type,
wdj.organization_id organization_id,
wdj.last_update_date last_update_date,
wdj.last_updated_by last_updated_by,
wdj.creation_date creation_date, wdj.created_by created_by,
wdj.last_update_login last_update_login,
wdj.description description,
wdj.primary_item_id primary_item_id,
(SELECT concatenated_segments
FROM mtl_system_items_vl
WHERE inventory_item_id =
wdj.primary_item_id
AND organization_id = wdj.organization_id)
AS asset_activity,
wdj.asset_group_id AS asset_group_id,
wdj.asset_number AS asset_number,
DECODE (wdj.maintenance_object_type,
3, cii.instance_description,
2, (SELECT description
FROM mtl_system_items
WHERE inventory_item_id = wdj.rebuild_item_id
AND ROWNUM = 1)
) asset_description,
wdj.class_code class_code, wdj.status_type status_type,
wdj.pm_schedule_id pm_schedule_id,
wdj.manual_rebuild_flag manual_rebuild_flag,
wdj.work_order_type work_order_type,

(SELECT meaning
FROM mfg_lookups
WHERE lookup_code =
wdj.work_order_type
AND lookup_type = 'WIP_EAM_WORK_ORDER_TYPE')
work_order_type_disp,
wdj.material_account, wdj.material_overhead_account,
wdj.resource_account, wdj.outside_processing_account,
wdj.material_variance_account,
wdj.resource_variance_account,
wdj.outside_proc_variance_account,
wdj.std_cost_adjustment_account, wdj.overhead_account,
wdj.overhead_variance_account, wdj.scheduled_start_date,
wdj.scheduled_completion_date, wdj.date_released,
wdj.date_completed, wdj.date_closed, wdj.owning_department,
(SELECT department_code
FROM bom_departments
WHERE organization_id =
wdj.organization_id
AND department_id = wdj.owning_department)
owning_department_code,
wdj.activity_type,
(SELECT meaning
FROM mfg_lookups
WHERE lookup_code = wdj.activity_type
AND lookup_type = 'MTL_EAM_ACTIVITY_TYPE')
activity_type_disp,
wdj.activity_cause,
(SELECT meaning
FROM mfg_lookups
WHERE lookup_code =
wdj.activity_cause
AND lookup_type = 'MTL_EAM_ACTIVITY_CAUSE')
activity_cause_disp,
wdj.priority,
(SELECT meaning
FROM mfg_lookups
WHERE lookup_code = wdj.priority
AND lookup_type = 'WIP_EAM_ACTIVITY_PRIORITY')
priority_disp,
wdj.requested_start_date, wdj.due_date requested_due_date,
wdj.estimation_status, wdj.notification_required,
wdj.shutdown_type,
(SELECT meaning
FROM mfg_lookups
WHERE lookup_code = wdj.shutdown_type
AND lookup_type = 'BOM_EAM_SHUTDOWN_TYPE')
shutdown_type_disp,
wdj.tagout_required, wdj.plan_maintenance,
wdj.firm_planned_flag, wdj.schedule_group_id,
(SELECT schedule_group_name
FROM wip_schedule_groups
WHERE schedule_group_id =
wdj.schedule_group_id
AND organization_id = wdj.organization_id)
schedule_group_name,
pjm_project.all_proj_idtonum (wdj.project_id)
project_number,
pjm_project.all_proj_idtoname (wdj.project_id) project_name,
wdj.project_id,

pjm_project.all_task_idtonum (wdj.task_id) task_number,


pjm_project.all_task_idtoname (wdj.task_id) task_name,
wdj.task_id, wdj.parent_wip_entity_id,
(SELECT wip_entity_name
FROM wip_entities
WHERE wip_entity_id =
wdj.parent_wip_entity_id
AND organization_id = wdj.organization_id)
parent_wip_entity_name,
wdj.rebuild_item_id,
DECODE (wdj.rebuild_item_id,
NULL, NULL,
cii.serial_number
) rebuild_serial_number,
wdj.bom_reference_id, wdj.routing_reference_id,
wdj.common_bom_sequence_id, wdj.common_routing_sequence_id,
wdj.alternate_bom_designator, wdj.bom_revision,
wdj.bom_revision_date, wdj.alternate_routing_designator,
wdj.routing_revision, wdj.routing_revision_date,
wdj.completion_subinventory, wdj.completion_locator_id,
wdj.lot_number, wdj.demand_class, wdj.attribute_category,
wdj.attribute1, wdj.attribute2, wdj.attribute3,
wdj.attribute4, wdj.attribute5, wdj.attribute6,
wdj.attribute7, wdj.attribute8, wdj.attribute9,
wdj.attribute10, wdj.attribute11, wdj.attribute12,
wdj.attribute13, wdj.attribute14, wdj.attribute15,
NVL (cii.instance_id, -1) AS instance_id,
NVL (cii.instance_number, '') AS instance_number,
wdj.maintenance_object_source, wdj.maintenance_object_type,
(SELECT meaning
FROM mfg_lookups
WHERE lookup_code =
wdj.maintenance_object_source
AND lookup_type = 'WIP_MAINTENANCE_OBJECT_SOURCE')
AS SOURCE,
wdj.maintenance_object_id,
(SELECT service_request_id
FROM eam_wo_service_association ewsa
WHERE ewsa.wip_entity_id =
wdj.wip_entity_id
AND (ewsa.enable_flag IS NULL OR ewsa.enable_flag = 'Y'
)) service_request_id,
(SELECT ciab.incident_number
FROM eam_wo_service_association ewsa,
cs_incidents_b_sec ciab
WHERE ewsa.wip_entity_id = wdj.wip_entity_id
AND ciab.incident_id = ewsa.service_request_id
AND (ewsa.enable_flag IS NULL OR ewsa.enable_flag = 'Y'
)) AS service_request,
wdj.material_issue_by_mo, wdj.activity_source,
(SELECT meaning
FROM mfg_lookups
WHERE lookup_code =
wdj.activity_source
AND lookup_type = 'MTL_EAM_ACTIVITY_SOURCE')
AS activity_source_meaning,
wdj.eam_linear_location_id, ewodv.pending_flag,
ewodv.user_defined_status_id, ewodv.work_order_status,
ewodv.work_order_status_pending,
ewodv.material_shortage_check_date,

FROM

WHERE
AND
AND
AND
AND
AND

ewodv.material_shortage_flag, ewodv.material_shortage_disp,
ewodv.workflow_type, ewodv.warranty_claim_status,
ewodv.cycle_id, ewodv.seq_id, ewodv.ds_scheduled_flag,
cii.serial_number AS asset_serial_number,
mp.maint_organization_id AS maint_organization_id,
(SELECT msik.concatenated_segments
FROM mtl_system_items_kfv msik
WHERE msik.inventory_item_id =
NVL (wdj.rebuild_item_id,
wdj.asset_group_id
)
AND ROWNUM = 1) AS asset_rebuild_group,
ewodv.pm_suggested_start_date, ewodv.pm_suggested_end_date,
(SELECT eaf.failure_id
FROM eam_asset_failures eaf
WHERE eaf.source_id = wdj.wip_entity_id) AS failure_id,
(SELECT eafc.failure_entry_id
FROM eam_asset_failures eaf,
eam_asset_failure_codes eafc
WHERE eaf.source_id = wdj.wip_entity_id
AND eafc.failure_id = eaf.failure_id)
AS failure_entry_id,
(SELECT eafc.failure_code
FROM eam_asset_failures eaf,
eam_asset_failure_codes eafc
WHERE eaf.source_id = wdj.wip_entity_id
AND eafc.failure_id = eaf.failure_id) AS failure_code,
(SELECT eafc.cause_code
FROM eam_asset_failures eaf,
eam_asset_failure_codes eafc
WHERE eaf.source_id = wdj.wip_entity_id
AND eafc.failure_id = eaf.failure_id) AS cause_code,
(SELECT eafc.resolution_code
FROM eam_asset_failures eaf,
eam_asset_failure_codes eafc
WHERE eaf.source_id = wdj.wip_entity_id
AND eafc.failure_id = eaf.failure_id)
AS resolution_code,
NVL (ewodv.failure_code_required,
'N') failure_code_required,
(SELECT eaf.failure_date
FROM eam_asset_failures eaf
WHERE eaf.source_id = wdj.wip_entity_id) AS failure_date,
(SELECT eafc.comments
FROM eam_asset_failures eaf,
eam_asset_failure_codes eafc
WHERE eaf.source_id = wdj.wip_entity_id
AND eafc.failure_id = eaf.failure_id) AS comments,
NULL AS parent_instance_number
wip_entities we,
wip_discrete_jobs wdj,
eam_work_order_details_v ewodv,
csi_item_instances cii,
mtl_parameters mp
wdj.wip_entity_id = we.wip_entity_id
wdj.organization_id = we.organization_id
we.entity_type IN (6, 7)
ewodv.wip_entity_id = wdj.wip_entity_id
ewodv.organization_id = wdj.organization_id
DECODE (wdj.maintenance_object_type,

3, wdj.maintenance_object_id,
NULL
) = cii.instance_id(+)
AND mp.organization_id(+) = cii.last_vld_organization_id
UNION
SELECT wdj.ROWID row_id,
(SELECT we.wip_entity_name
FROM eam_wo_relationships ewr,
wip_entities we
WHERE ewr.child_object_id = wdj.wip_entity_id
AND ewr.parent_relationship_type = 1
AND ewr.parent_object_id = we.wip_entity_id)
AS sched_parent_wip_entity_name,
(SELECT actual_start_date
FROM eam_job_completion_txns
WHERE transaction_type = 1
AND transaction_id =
(SELECT MAX (transaction_id)
FROM eam_job_completion_txns ejt
WHERE ejt.wip_entity_id = wdj.wip_entity_id
AND ejt.organization_id = wdj.organization_id))
AS actual_start_date,
wdj.wip_entity_id AS wip_entity_id,
we.wip_entity_name wip_entity_name, we.ROWID AS we_row_id,
we.entity_type entity_type,
wdj.organization_id organization_id,
wdj.last_update_date last_update_date,
wdj.last_updated_by last_updated_by,
wdj.creation_date creation_date, wdj.created_by created_by,
wdj.last_update_login last_update_login,
wdj.description description,
wdj.primary_item_id primary_item_id,
(SELECT concatenated_segments
FROM mtl_system_items_vl
WHERE inventory_item_id =
wdj.primary_item_id
AND organization_id = wdj.organization_id)
AS asset_activity,
NVL (wdj1.rebuild_item_id,
wdj1.asset_group_id
) AS asset_group_id,
NVL (wdj1.asset_number,
wdj1.rebuild_serial_number
) AS asset_number,
DECODE (wdj.maintenance_object_type,
3, cii.instance_description,
2, (SELECT description
FROM mtl_system_items
WHERE inventory_item_id = wdj.rebuild_item_id
AND ROWNUM = 1)
) asset_description,
wdj.class_code class_code, wdj.status_type status_type,
wdj.pm_schedule_id pm_schedule_id,
wdj.manual_rebuild_flag manual_rebuild_flag,
wdj.work_order_type work_order_type,
(SELECT meaning
FROM mfg_lookups
WHERE lookup_code =
wdj.work_order_type
AND lookup_type = 'WIP_EAM_WORK_ORDER_TYPE')

work_order_type_disp,
wdj.material_account, wdj.material_overhead_account,
wdj.resource_account, wdj.outside_processing_account,
wdj.material_variance_account,
wdj.resource_variance_account,
wdj.outside_proc_variance_account,
wdj.std_cost_adjustment_account, wdj.overhead_account,
wdj.overhead_variance_account, wdj.scheduled_start_date,
wdj.scheduled_completion_date, wdj.date_released,
wdj.date_completed, wdj.date_closed, wdj.owning_department,
(SELECT department_code
FROM bom_departments
WHERE organization_id =
wdj.organization_id
AND department_id = wdj.owning_department)
owning_department_code,
wdj.activity_type,
(SELECT meaning
FROM mfg_lookups
WHERE lookup_code = wdj.activity_type
AND lookup_type = 'MTL_EAM_ACTIVITY_TYPE')
activity_type_disp,
wdj.activity_cause,
(SELECT meaning
FROM mfg_lookups
WHERE lookup_code =
wdj.activity_cause
AND lookup_type = 'MTL_EAM_ACTIVITY_CAUSE')
activity_cause_disp,
wdj.priority,
(SELECT meaning
FROM mfg_lookups
WHERE lookup_code = wdj.priority
AND lookup_type = 'WIP_EAM_ACTIVITY_PRIORITY')
priority_disp,
wdj.requested_start_date, wdj.due_date requested_due_date,
wdj.estimation_status, wdj.notification_required,
wdj.shutdown_type,
(SELECT meaning
FROM mfg_lookups
WHERE lookup_code = wdj.shutdown_type
AND lookup_type = 'BOM_EAM_SHUTDOWN_TYPE')
shutdown_type_disp,
wdj.tagout_required, wdj.plan_maintenance,
wdj.firm_planned_flag, wdj.schedule_group_id,
(SELECT schedule_group_name
FROM wip_schedule_groups
WHERE schedule_group_id =
wdj.schedule_group_id
AND organization_id = wdj.organization_id)
schedule_group_name,
pjm_project.all_proj_idtonum (wdj.project_id)
project_number,
pjm_project.all_proj_idtoname (wdj.project_id) project_name,
wdj.project_id,
pjm_project.all_task_idtonum (wdj.task_id) task_number,
pjm_project.all_task_idtoname (wdj.task_id) task_name,
wdj.task_id, wdj.parent_wip_entity_id,
(SELECT wip_entity_name
FROM wip_entities

WHERE wip_entity_id =
wdj.parent_wip_entity_id
AND organization_id = wdj.organization_id)
parent_wip_entity_name,
wdj.rebuild_item_id,
DECODE (wdj.rebuild_item_id,
NULL, NULL,
cii.serial_number
) rebuild_serial_number,
wdj.bom_reference_id, wdj.routing_reference_id,
wdj.common_bom_sequence_id, wdj.common_routing_sequence_id,
wdj.alternate_bom_designator, wdj.bom_revision,
wdj.bom_revision_date, wdj.alternate_routing_designator,
wdj.routing_revision, wdj.routing_revision_date,
wdj.completion_subinventory, wdj.completion_locator_id,
wdj.lot_number, wdj.demand_class, wdj.attribute_category,
wdj.attribute1, wdj.attribute2, wdj.attribute3,
wdj.attribute4, wdj.attribute5, wdj.attribute6,
wdj.attribute7, wdj.attribute8, wdj.attribute9,
wdj.attribute10, wdj.attribute11, wdj.attribute12,
wdj.attribute13, wdj.attribute14, wdj.attribute15,
NVL (cii.instance_id, -1) AS instance_id,
NVL (cii.instance_number, '') AS instance_number,
wdj.maintenance_object_source, wdj.maintenance_object_type,
(SELECT meaning
FROM mfg_lookups
WHERE lookup_code =
wdj.maintenance_object_source
AND lookup_type = 'WIP_MAINTENANCE_OBJECT_SOURCE')
AS SOURCE,
wdj.maintenance_object_id,
(SELECT service_request_id
FROM eam_wo_service_association ewsa
WHERE ewsa.wip_entity_id =
wdj.wip_entity_id
AND (ewsa.enable_flag IS NULL OR ewsa.enable_flag = 'Y'
)) service_request_id,
(SELECT ciab.incident_number
FROM eam_wo_service_association ewsa,
cs_incidents_b_sec ciab
WHERE ewsa.wip_entity_id = wdj.wip_entity_id
AND ciab.incident_id = ewsa.service_request_id
AND (ewsa.enable_flag IS NULL OR ewsa.enable_flag = 'Y'
)) AS service_request,
wdj.material_issue_by_mo, wdj.activity_source,
(SELECT meaning
FROM mfg_lookups
WHERE lookup_code =
wdj.activity_source
AND lookup_type = 'MTL_EAM_ACTIVITY_SOURCE')
AS activity_source_meaning,
wdj.eam_linear_location_id, ewodv.pending_flag,
ewodv.user_defined_status_id, ewodv.work_order_status,
ewodv.work_order_status_pending,
ewodv.material_shortage_check_date,
ewodv.material_shortage_flag, ewodv.material_shortage_disp,
ewodv.workflow_type, ewodv.warranty_claim_status,
ewodv.cycle_id, ewodv.seq_id, ewodv.ds_scheduled_flag,
cii.serial_number AS asset_serial_number,
mp.maint_organization_id AS maint_organization_id,

FROM

WHERE
AND
AND
AND
AND

(SELECT msik.concatenated_segments
FROM mtl_system_items_kfv msik
WHERE msik.inventory_item_id =
NVL (wdj.rebuild_item_id,
wdj.asset_group_id
)
AND ROWNUM = 1) AS asset_rebuild_group,
ewodv.pm_suggested_start_date, ewodv.pm_suggested_end_date,
(SELECT eaf.failure_id
FROM eam_asset_failures eaf
WHERE eaf.source_id = wdj.wip_entity_id) AS failure_id,
(SELECT eafc.failure_entry_id
FROM eam_asset_failures eaf,
eam_asset_failure_codes eafc
WHERE eaf.source_id = wdj.wip_entity_id
AND eafc.failure_id = eaf.failure_id)
AS failure_entry_id,
(SELECT eafc.failure_code
FROM eam_asset_failures eaf,
eam_asset_failure_codes eafc
WHERE eaf.source_id = wdj.wip_entity_id
AND eafc.failure_id = eaf.failure_id) AS failure_code,
(SELECT eafc.cause_code
FROM eam_asset_failures eaf,
eam_asset_failure_codes eafc
WHERE eaf.source_id = wdj.wip_entity_id
AND eafc.failure_id = eaf.failure_id) AS cause_code,
(SELECT eafc.resolution_code
FROM eam_asset_failures eaf,
eam_asset_failure_codes eafc
WHERE eaf.source_id = wdj.wip_entity_id
AND eafc.failure_id = eaf.failure_id)
AS resolution_code,
NVL (ewodv.failure_code_required,
'N') failure_code_required,
(SELECT eaf.failure_date
FROM eam_asset_failures eaf
WHERE eaf.source_id = wdj.wip_entity_id) AS failure_date,
(SELECT eafc.comments
FROM eam_asset_failures eaf,
eam_asset_failure_codes eafc
WHERE eaf.source_id = wdj.wip_entity_id
AND eafc.failure_id = eaf.failure_id) AS comments,
(SELECT instance_number
FROM csi_item_instances
WHERE instance_id =
wdj1.maintenance_object_id
AND wdj1.maintenance_object_type = 3)
AS parent_instance_number
wip_entities we,
wip_discrete_jobs wdj1,
wip_discrete_jobs wdj,
eam_work_order_details_v ewodv,
csi_item_instances cii,
mtl_parameters mp
wdj.wip_entity_id = we.wip_entity_id
wdj.organization_id = we.organization_id
we.entity_type IN (6, 7)
wdj.parent_wip_entity_id = wdj1.wip_entity_id
wdj.organization_id = wdj1.organization_id

AND ewodv.wip_entity_id = wdj.wip_entity_id


AND ewodv.organization_id = wdj.organization_id
AND DECODE (wdj.maintenance_object_type,
3, wdj.maintenance_object_id,
NULL
) = cii.instance_id(+)
AND mp.organization_id(+) = cii.last_vld_organization_id)
WHERE asset_group_id IS NOT NULL AND asset_number IS NOT NULL;

You might also like