Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT iib.item,
- iib2.item AS comp_item,
- iib.item_description,
- ood.organization_name,
- ood.organization_code,
- iib.planner_code,
- iib.master_scheduler,
- iib.mlx_package,
- iib.mlx_supplier_package,
- iib.mlx_inventory_project,
- dev.element_value AS product_name,
- supply.requested_due_date,
- supply.completion_date,
- supply.request_date_year,
- supply.completion_date_year,
- supply.qty_out,
- (TO_CHAR(TO_DATE(sic.from_date,'DD-MON-YYYY HH24:MI:SS') ,'WWYYYY')) AS from_date,
- (TO_CHAR(TO_DATE(sic.TO_DATE,'DD-MON-YYYY HH24:MI:SS') ,'WWYYYY')) AS TO_DATE,
- sic.capacity_per_day
- FROM XXMLX_ITEM_INFORMATION_BASE_MV iib,
- XXMLX_ITEM_INFORMATION_BASE_MV iib2,
- MTL_DESCR_ELEMENT_VALUES dev,
- ORG_ORGANIZATION_DEFINITIONS ood,
- pos_supplier_item_capacity_v sic,
- mtl_system_items msi,
- (
- SELECT 'Inventory' AS supply_location
- , moq.subinventory_code
- , moq.lot_number
- , moq.primary_transaction_quantity AS qty_out
- , NULL AS rcv_transaction
- , moq.date_received
- , moq.last_update_date
- , moq.inventory_item_id
- , moq.organization_id
- , NULL AS gen_object_id
- , NULL AS wip_entity_id
- , NULL AS current_operation_code
- , NULL AS operation_seq_num
- , NULL AS job_operation_seq_num
- , NULL AS department
- , NULL AS step
- , NULL AS start_date
- , NULL AS requested_due_date
- , NULL AS completion_date
- , NULL AS firm_planned_flag
- , NULL AS production_remarks
- , NULL AS error_handling
- , NULL AS hold_reason
- , NULL AS completion_subinventory
- , NULL AS handlerprober
- , NULL AS taper
- , ' ' AS demand_class
- , NULL AS completion_date_year
- , NULL AS completion_date_quarter
- , NULL AS completion_date_month
- , NULL AS completion_date_week
- , NULL AS completion_date_day
- , NULL AS request_date_year
- , NULL AS request_date_quarter
- , NULL AS request_date_month
- , NULL AS request_date_week
- , NULL AS request_date_day
- , NVL( xxmlx_sfm_tools_pkg.get_lot_wafer_qty( moq.lot_number ),moq.primary_transaction_quantity ) AS wafer_qty_out
- , '' AS location_name
- , '' AS shipment_number
- , TO_DATE( '' ) AS receipt_date
- , NULL AS planning_remarks
- FROM xxmlx_onhand_qty_prod_overvw_v moq
- WHERE 1 = 1
- AND moq.is_consigned = 2
- UNION ALL
- SELECT 'WIP' AS supply_location
- , DECODE( mlu.meaning,'Released','SFM Released','SFM On Hold' ) AS subinventory_code
- , we.wip_entity_name AS lot_number
- , wo.quantity_in_queue + wo.quantity_running + wo.quantity_waiting_to_move AS qty_out
- , NULL AS rcv_transaction
- , wdj.creation_date AS date_received
- , wdj.last_update_date AS last_update_date
- , we.primary_item_id AS inventory_item_id -- TODO - Check why WIP Part
- , we.organization_id AS organization_id
- , we.gen_object_id AS gen_object_id
- , we.wip_entity_id AS wip_entity_id
- , wco.operation_description AS current_operation_code
- , wco.operation_seq_num AS operation_seq_num
- , wo.operation_seq_num AS job_operation_seq_num
- , bd.department_code AS department
- , ml.meaning AS step
- , wdj.scheduled_start_date AS start_date
- , wdj.due_date AS requested_due_date
- , wdj.scheduled_completion_date AS completion_date
- , DECODE( wdj.firm_planned_flag,1,'Yes',2,'No' ) AS firm_planned_flag
- , wdj.attribute1 AS production_remarks
- , wdj.attribute2 AS error_handling
- , wdj.attribute3 AS hold_reason
- , wdj.completion_subinventory AS completion_subinventory
- , wdj.attribute4 AS handlerprober
- , wdj.attribute5 AS taper
- , wdj.demand_class AS demand_class
- , TO_CHAR( wdj.scheduled_completion_date,'IYYY' ) AS completion_date_year
- , TO_CHAR( wdj.scheduled_completion_date,'Q' ) AS completion_date_quarter
- , TO_CHAR( wdj.scheduled_completion_date,'MM' ) AS completion_date_month
- , xxmlx_to_number( TO_CHAR( NEXT_DAY( wdj.scheduled_completion_date,'sunday' ),'iw' ) ) AS completion_date_week
- , TO_CHAR( wdj.scheduled_completion_date,'DD' ) AS completion_date_day
- , TO_CHAR( wdj.due_date,'IYYY' ) AS request_date_year
- , TO_CHAR( wdj.due_date,'Q' ) AS request_date_quarter
- , TO_CHAR( wdj.due_date,'MM' ) AS request_date_month
- , xxmlx_to_number( TO_CHAR( NEXT_DAY( wdj.due_date,'sunday' ),'iw' ) ) AS request_date_week
- , TO_CHAR( wdj.due_date,'DD' ) AS request_date_day
- , NVL(xxmlx_sfm_tools_pkg.get_lot_wafer_qty( we.wip_entity_name )
- ,wo.quantity_in_queue + wo.quantity_running + wo.quantity_waiting_to_move
- ) AS wafer_qty_out
- , '' AS location_name
- , '' AS shipment_number
- , TO_DATE( '' ) AS receipt_date
- , NULL AS planning_remarks
- FROM mfg_lookups ml
- , wip_operations wo
- , wip_entities we
- , wip_discrete_jobs wdj
- , mfg_lookups mlu
- , bom_standard_operations bso
- , wsm_copy_operations wco
- , bom_departments bd
- WHERE 1 = 1
- AND ml.lookup_type = 'WIP_INTRAOPERATION_STEP'
- AND ml.lookup_code = DECODE( wo.quantity_in_queue, 0 ,DECODE( wo.quantity_running,0,3,2 ),1 )
- AND we.wip_entity_id = wo.wip_entity_id
- AND wo.standard_operation_id = bso.standard_operation_id (+)
- AND NVL( bso.operation_type,1 ) = 1
- AND bso.line_id IS NULL
- AND ( wo.quantity_in_queue != 0 OR wo.quantity_running != 0 OR wo.quantity_waiting_to_move != 0)
- AND wo.operation_sequence_id = wco.operation_sequence_id (+)
- AND wo.wip_entity_id = wco.wip_entity_id (+)
- AND wdj.wip_entity_id = we.wip_entity_id
- AND wdj.status_type IN ( 3, 6 )
- AND wdj.organization_id = we.organization_id
- AND mlu.lookup_code = wdj.status_type
- AND mlu.lookup_type = 'WIP_JOB_STATUS'
- AND bd.department_id = bso.department_id
- UNION ALL
- SELECT CASE WHEN ms.supply_type_code = 'RECEIVING'
- THEN'RECEIVING'
- WHEN ms.supply_type_code = 'SHIPMENT'
- THEN'INTRANSIT'
- END AS supply_location
- , CASE WHEN ms.supply_type_code = 'RECEIVING'
- THEN 'RECEIVING'
- WHEN ms.supply_type_code = 'SHIPMENT'
- THEN 'INTRANSIT'
- END AS subinventory_code
- , rls.lot_num AS lot_number
- , NVL( rls.quantity,ms.quantity ) AS qty_out
- , ms.rcv_transaction_id AS rcv_transaction
- , ms.creation_date AS date_received
- , ms.last_update_date AS last_update_date
- , ms.item_id AS inventory_item_id
- , ms.to_organization_id AS organization_id
- , TO_NUMBER( '' ) AS gen_object_id
- , NULL AS wip_entity_id
- , NULL AS current_operation_code
- , NULL AS operation_seq_num
- , NULL AS job_operation_seq_num
- , NULL AS department
- , NULL AS step
- , NULL AS start_date
- , NULL AS requested_due_date
- , NULL AS completion_date
- , NULL AS firm_planned_flag
- , NULL AS production_remarks
- , NULL AS error_handling
- , NULL AS hold_reason
- , NULL AS completion_subinventory
- , NULL AS handlerprober
- , NULL AS taper
- , ' ' AS demand_class
- , NULL AS completion_date_year
- , NULL AS completion_date_quarter
- , NULL AS completion_date_month
- , NULL AS completion_date_week
- , NULL AS completion_date_day
- , NULL AS request_date_year
- , NULL AS request_date_quarter
- , NULL AS request_date_month
- , NULL AS request_date_week
- , NULL AS request_date_day
- , NULL AS wafer_qty_out
- , hla.location_code AS location_name
- , NVL( sh.shipment_num,sh.receipt_num ) AS shipment_number
- , ms.receipt_date AS receipt_date
- , mln_from.c_attribute10 AS planning_remarks
- FROM mtl_supply ms
- , rcv_lots_supply rls
- , hr_locations_all hla
- , rcv_shipment_headers sh
- , mtl_lot_numbers mln_from
- WHERE 1 = 1
- AND ms.shipment_line_id = rls.shipment_line_id (+)
- AND ms.supply_type_code IN ('RECEIVING','SHIPMENT')
- AND ms.location_id = hla.location_id (+)
- AND ms.shipment_header_id = sh.shipment_header_id (+)
- AND ms.item_id = mln_from.inventory_item_id(+)
- AND ms.from_organization_id= mln_from.organization_id(+)
- AND (rls.lot_num = mln_from.lot_number OR rls.lot_num IS NULL)
- ) supply
- WHERE iib.inventory_item_id = dev.inventory_item_id
- AND iib.organization_id = ood.organization_id
- AND dev.element_name (+) = 'PRODUCT'
- AND supply.inventory_item_id = iib.inventory_item_id
- AND supply.organization_id = iib.organization_id
- AND iib2.inventory_item_id = sic.item_id;
- AND iib2.organization_id = 83
- AND iib2.MLX_OSP_SUPPLIER = iib.MLX_OSP_SUPPLIER
- AND iib2.MLX_PACKAGE = iib.MLX_PACKAGE;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement