Test 12a2asdasd
Test 12a2asdasd
SELECT
ORGANIZATION_ID,WIP_ENTITY_ID, WIP_ENTITY_NAME WO,DESCRIPTION
,ASSET_GROUP,ASSET_NUMBER,ASSET_NUMBER_DESCRIPTION ASSET_DESCRIPTION
,WORK_ORDER_TYPE_DISP TIPO
,owning_department_id
,OWNING_DEPARTMENT_CODE DEPARTAMENTO
,PRIORITY_DISP PRIORIDAD
,scheduled_start_date, scheduled_completion_date
,AREA
,user_defined_status_id
,USER_DEFINED_STATUS_DISP ESTADO
,(select sum(REQUIRED_QUANTITY) from WIP_REQUIREMENT_OPERATIONS_V where
wip_entity_id = a.wip_entity_id) requerido
,(select sum(QUANTITY_ISSUED) from WIP_REQUIREMENT_OPERATIONS_V where
wip_entity_id = a.wip_entity_id) consumido
,(select sum(QUANTITY_ALLOCATED) from WIP_REQUIREMENT_OPERATIONS_V where
wip_entity_id = a.wip_entity_id) asignado
,qty_req
,qty_pendiente_oc
,qty_pendiente_rec
,case when qty_pendiente_rec > 0 then max_promised_date else null end
promised_date
FROM eam_cfr_work_order_v a
,(select prl.destination_organization_id,prh.attribute9,sum(prl.quantity)
qty_req,sum(prl.quantity - nvl(PO.QUANTITY_ordered,0) +
nvl(PO.QUANTITY_cancelled,0)) qty_pendiente_oc
,sum(po.quantity_ordered - po.quantity_cancelled -
po.quantity_delivered) qty_pendiente_rec,sum(po.quantity_ordered) qty_po
,sum(prl.quantity_delivered) qty_rec
,max(nvl(promised_date,po.creation_date + 30)) max_promised_date
from po_requisition_headers_all prh, po_requisition_lines_all prl,
po_req_distributions_all prd
,(select pd.req_distribution_id, pd.quantity_ordered
,pd.quantity_delivered,pd.quantity_cancelled,pll.promised_date,pd.creation_Date
from po_line_locations_all pll, po_distributions_all pd
where pll.line_location_id = pd.line_location_id and
pll.quantity_cancelled = 0) po
where 1=1
and prh.authorization_status IN ('APPROVED','IN PROCESS')
and prh.requisition_header_id = prl.requisition_header_id
and prl.item_id is not null
and prl.requisition_line_id = prd.requisition_line_id
and prd.distribution_id = po.req_distribution_id (+)
group by prl.destination_organization_id,prh.attribute9) b
where system_status_type NOT IN (4,5,7,12,14,15)
and a.wip_entity_name = b.attribute9
and a.organization_id = b.destination_organization_id