SELECT
  RTRIM(AECODE) AS aecode,
  RTRIM(AEDES1) AS aedes1,
  RTRIM(AEDES2) AS aedes2,
  RTRIM(AEDES3) AS aedes3,
  RTRIM(AEDES4) AS aedes4,
  CASE WHEN AEDATE IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE AEDATE END AS aedate,
  AELABR AS aelabr,
  RTRIM(AEBK01) AS aebk01,
  RTRIM(AEPLNT) AS aeplnt
FROM LGDAT.OPCODE
