Sunday, 22 April 2012

WIP discrete jobs Query



SELECT WE.WIP_ENTITY_NAME,
 DECODE(wdj.job_type,1,'STANDARD',2,'NON_STANDARD',wdj.job_type)JOB_TYPE,
 MSIB.SEGMENT1 ASSEMBLY_ITEM_NAME,
 MSIB.DESCRIPTION,
 wdj.class_code,
 lu1.meaning status,
 MMT.TRANSACTION_UOM UOM,
 wdj.scheduled_start_date SCHEDULE_START_DATE,
 wdj.scheduled_completion_date SCHEDULE_END_DATE ,
 wdj.start_quantity,
 wdj.net_quantity,
 ----BILL TAB-------------------------
 lu2.meaning wip_supply_type,
 ----------ROUTING TAB----------------
    wdj.completion_subinventory,
    -------COMPONENTS
    msik.concatenated_segments,
    --DEPARTMENTS---------
    bd.department_code
    ---RESOURCES-----------
     --br.resource_code
FROM WIP_ENTITIES WE,
wip_discrete_jobs wdj,        
MTL_SYSTEM_ITEMS_B MSIB ,
mfg_lookups lu1,
mfg_lookups lu2,
MTL_MATERIAL_TRANSACTIONS MMT,
--------------------------
 mtl_system_items_vl msik,
       wip_requirement_operations wro,
       --------------------------
        wip_operations wo,
      bom_departments bd,
       --------------------
        bom_resources br,
        wip_operation_resources wor
WHERE WE.WIP_ENTITY_NAME='246412'
AND we.wip_entity_id = wdj.wip_entity_id
AND WE.PRIMARY_ITEM_ID=MSIB.INVENTORY_ITEM_ID
AND lu1.lookup_type = 'WIP_JOB_STATUS'
AND lu1.lookup_code = wdj.status_type
AND lu2.lookup_type = 'WIP_SUPPLY'
AND lu2.lookup_code = wdj.wip_supply_type
AND WE.PRIMARY_ITEM_ID=MMT.INVENTORY_ITEM_ID
---------------------------------------
AND WE.WIP_ENTITY_ID=WRO.WIP_ENTITY_ID
AND WE.ORGANIZATION_ID=WRO.ORGANIZATION_ID
AND  msik.inventory_item_id = wro.inventory_item_id
AND msik.organization_id = wro.organization_id
----------------------------------------------
AND bd.department_id = wo.department_id
AND WE.WIP_ENTITY_ID=WO.WIP_ENTITY_ID
AND WE.ORGANIZATION_ID=WO.ORGANIZATION_ID
 --------------------------------------
 AND br.resource_id = wor.resource_id
 AND WOR.WIP_ENTITY_ID=WE.WIP_ENTITY_ID
 AND WOR.ORGANIZATION_ID=WE.ORGANIZATION_ID

5 comments: