-- WorkOrderStep Full Query
-- Source: JDESTAGE.F3112_VIEW, JDESTAGE.F00192_VIEW
-- Destination: WorkOrderStep_Curr
-- Schedule: Mass/Daily/Hourly

SELECT wos.DOCUMENTORDERINVOICEE_WLDOCO AS WorkOrderNumber,
       TRIM(wos.COSTCENTERALT_WLMMCU) AS BranchCode,
       TRIM(wos.COSTCENTER_WLMCU) AS WorkCenterCode,
       wos.SEQUENCENOOPERATIONS_WLOPSQ AS StepNumber,
       TRIM(wos.DESCRIPTIONLINE1_WLDSC1) AS StepDescription,
       TRIM(mes.DESCRIPT80CHARACTERS_CFDS80) AS FunctionOperationDescription,
       wos.TYPEOPERATIONCODE_WLOPSC AS StepTypeCode,
       CASE wos.DATESTART_WLSTRT WHEN TO_DATE('1900-01-01', 'yyyy-MM-dd') THEN NULL ELSE wos.DATESTART_WLSTRT END AS StartDT,
       CASE wos.DATECOMPLETION_WLSTRX WHEN TO_DATE('1900-01-01', 'yyyy-MM-dd') THEN NULL ELSE wos.DATECOMPLETION_WLSTRX END AS EndDT,
       TRIM(wos.USERRESERVEDREFERENCE_WLURRF) AS FunctionCode,
       wos.DATEUPDATED_WLUPMJ AS DateUpdated,
       wos.TIMEOFDAY_WLTDAY AS TimeUpdated
  FROM JDESTAGE.F3112_VIEW wos LEFT OUTER JOIN
       JDESTAGE.F00192_VIEW mes ON (wos.USERRESERVEDREFERENCE_WLURRF = mes.USERDEFINEDCODE_CFKY)
