CASE WHEN B.BOM != 'NULL' THEN B.BOM || '/' || B.REVISION END BOM,
CASE WHEN ZSS.HANDLE != 'NULL' THEN ZSS.REASON
ELSE ZABV.PB_DESCRIPTION
END REASON
END REASON,
ZSS.TYPE TYPE
FROM SFC S
INNER JOIN SFC_ROUTING SR ON SR.SFC_BO = S.HANDLE
INNER JOIN SFC_ROUTER ST ON ST.SFC_ROUTING_BO = SR.HANDLE
@ -1004,7 +1006,11 @@
LEFT JOIN ROUTER R ON R.HANDLE = ZSD.ROUTER_BO
LEFT JOIN Z_SFC_SCRAP ZSS ON ZSS.SFC = S.SFC AND ZSS.SITE = S.SITE
LEFT JOIN BOM B ON B.HANDLE = SO.PLANNED_BOM_BO
INNER JOIN ( SELECT * FROM Z_ABNORMAL_BILL_VIEW ZABV WHERE ZABV.HANDLE = (SELECT MAX(HANDLE) FROM Z_ABNORMAL_BILL_VIEW) ) ZABV ON ZABV.SFC = S.SFC AND ZABV.SITE= S.SITE
INNER JOIN ( SELECT * FROM Z_ABNORMAL_BILL_VIEW ZABV WHERE ZABV.HANDLE = (SELECT MAX(HANDLE) FROM Z_ABNORMAL_BILL_VIEW ZABV2