SELECT wos.WLDOCO AS WorkOrderNumber,
       wos.WLOPSQ/10 AS StepNumber,
       TRIM(wos.WLMCU) AS WorkCenterCode,
	   TRIM(wos.WLMMCU) AS BranchCode,
       TRIM(wos.WLDSC1) AS StepDescription,
       TRIM(mes.CFDS80) AS FunctionOperationDescription,
       wos.WLOPSC AS StepTypeCode,
       CASE wos.WLSTRT WHEN 0 THEN NULL ELSE TO_DATE(wos.WLSTRT+1900000,'YYYYDDD') END AS StartDT,
       CASE wos.WLSTRX WHEN 0 THEN NULL ELSE TO_DATE(wos.WLSTRX+1900000,'YYYYDDD') END AS EndDT,
       TRIM(wos.WLURRF) AS FunctionCode,
	   wos.WLSOCN / 100.0 AS ScrappedQuantity,
	   wos.WLUPMJ AS LastUpdateDate,
	   wos.WLTDAY AS LastUpdateTime
  FROM PRODDTA.F3112 wos LEFT OUTER JOIN 
       PRODDTA.F00192 mes ON (wos.WLURRF = mes.CFKY)
 WHERE TRIM(wos.WLMCU) IS NOT NULL AND
       TRIM(wos.WLMMCU) IS NOT NULL 