SELECT wo.WADOCO AS WorkOrderNumber,
       TRIM(wo.WAMMCU) AS BranchCode,
       TRIM(wo.WALOTN) AS LotNumber,
       TRIM(wo.WALITM) AS ItemNumber,
       wo.WAITM AS ShortItemNumber,
       TRIM(wo.WAPARS) AS ParentWorkOrderNumber,
       wo.WAUORG / 100.0 AS OrderQuantity,
       wo.WASOBK / 100.0 AS HeldQuantity,
       wo.WASOQS / 100.0 AS ShippedQuantity,
       TRIM(wo.WASRST) AS StatusCode,
	   CASE wo.WADCG WHEN 0 THEN TO_DATE('1900-01-01', 'YYYY-MM-DD') ELSE TO_DATE(wo.WADCG+1900000,'YYYYDDD') END AS StatusCodeUpdateDT,
	   CASE wo.WATRDJ WHEN 0 THEN TO_DATE('1900-01-01', 'YYYY-MM-DD') ELSE TO_DATE(wo.WATRDJ+1900000,'YYYYDDD') END AS IssueDate,
	   CASE wo.WASTRT WHEN 0 THEN TO_DATE('1900-01-01', 'YYYY-MM-DD') ELSE TO_DATE(wo.WASTRT+1900000,'YYYYDDD') END AS StartDate,
       TRIM(wo.WATRT) AS RoutingType,
	   wo.WAUPMJ AS LastUpdateDate,
	   wo.WATDAY AS LastUpdateTime
  FROM ARCDTAPD.F4801 wo
