I thought that you are using too many useless parenthese.
Here is an example of rewriting which removed useless parentheses, added correlation names and chnged sequence of joins.
Code:
SELECT F48.WAMCU AS "Company #"
, Cmp.ABALPH AS "Company"
, F48.WADOCO AS "Workorder #"
, F48.WAPARS AS "Parent WO #"
, F48.WAVR01 AS "Ref"
, F48.WADL01 AS "Description"
, DATE(
DIGITS(
DECIMAL(
F09.GLDGJ + 1900000
, 7 , 0
)
)
) AS "Date"
, F48.WASRST AS "Status"
, F48.WAAMTO /100 AS "Budgeted"
, F09.GLPO AS "PO Number"
, F09.GLEXA AS "Explanation - Name Alpha"
, F09.GLAA /100 AS "Amount"
, Org.ABALPH AS "Originator"
, Mgr.ABALPH AS "Manager"
FROM &lib.F0911 F09
INNER JOIN
&lib.F4801 F48
ON F48.WADOCO = F09.GLSBL
INNER JOIN
&lib.F0101 Cmp
ON TRIM(Cmp.ABAN8) = TRIM(F48.WAMCU)
/* ON Cmp.ABAN8 = F48.WAMCU */
LEFT JOIN
&lib.F0101 Org
ON Org.ABAN8 = F48.WAAN8
LEFT JOIN
&lib.F0101 Mgr
ON Mgr.ABAN8 = F48.WAANSA
WHERE F09.GLOBJ = '2003'
AND F09.GLFY &SPARM02
AND F09.GLSBLT = 'W'
AND F09.GLDCT <> '33'
AND F09.GLLT = 'AA'
AND F48.WADOCO < 11111111
AND F48.WAPARS <> '11111111'
AND F48.WASRST &SPARM01
AND F48.WATYPS &SPARM03
ORDER BY
"Parent WO #"
, "Workorder #"
;
If Cmp.ABAN8 and F48.WAMCU were left justified(i.e. no left blanks),
ON TRIM(Cmp.ABAN8) = TRIM(F48.WAMCU)
can be replaced by
ON Cmp.ABAN8 = F48.WAMCU