SELECT
  RTRIM(SRCE) AS srce,
  RTRIM(WRKO) AS wrko,
  BTID AS btid,
  "ENT#" AS "ent#",
  "SEQ#" AS "seq#",
  RTRIM(PART) AS part,
  RTRIM(RPLN) AS rpln,
  PQTY AS pqty,
  RTRIM(ARSC) AS arsc,
  RTRIM(ADEP) AS adep,
  RTRIM(ACTN) AS actn,
  RTRIM(ACCT) AS acct,
  AMNT AS amnt,
  RTRIM(SRSC) AS srsc,
  RHRS AS rhrs,
  RCRW AS rcrw,
  SHRS AS shrs,
  SCRW AS scrw,
  RRAT AS rrat,
  RSIZ AS rsiz
FROM FANALDEV.FFPDGLR1
INNER JOIN LGDAT.RPRH ON NWBTID = BTID
WHERE DIGITS(NWFSYY)||DIGITS(NWFSPP) >= '{ffpdglr1_wm}'
   -- Rollover hot set. The period floor above advances to the new period as soon
   -- as one batch posts into it, so a late posting into the prior period would
   -- stop being refreshed from that moment. These branches follow RPRH's own
   -- stamps instead, and carry the unposted batches too (NWPDAT stays
   -- 0001-01-01 until a batch posts, so no period/date floor can see them).
   -- FFPDGLR1 itself has no dates -- only BTID/ENT#/SEQ# -- so RPRH is the only
   -- change signal available. Measured 2026-08-19 mid-period: this adds 0 rows,
   -- a strict subset of the period branch. It earns its keep at a period
   -- boundary, which is the only time the two floors disagree.
   OR NWPDAT >= DATE('{ffpdglr1_hot}')
   OR NWUDAT >= DATE('{ffpdglr1_hot}')
   OR NWCDAT >= DATE('{ffpdglr1_hot}')
   OR RTRIM(NWPOST) <> 'Y'
