def var t-first-year as int. def var t-last-year as int. def buffer x-periods for symix.periods. def var t-year as int format "9999". def var t-prob-found as logical. def var t-last-bucket-end as date. def var i as int. find last symix.periods no-lock. t-last-year = periods.fiscal-year. find first symix.periods no-lock. t-first-year = periods.fiscal-year. output to bad-periods.out. do t-year = t-first-year to t-last-year: find symix.periods where periods.fiscal-year = t-year no-lock no-error. if not available periods and t-year <> t-last-year then do: t-prob-found = yes. put "Missing fiscal year " t-year skip(1). end. else do: do i = 1 to 13: if periods.per-end[i] <> ? then t-last-bucket-end = periods.per-end[i]. end. find x-periods where x-periods.fiscal-year = t-year + 1 no-lock no-error. if available x-periods and x-periods.per-start[1] <> t-last-bucket-end + 1 then do: put "Gap found between end of year " t-year " and start of year " x-periods.fiscal-year skip(1). t-prob-found = yes. end. end. end. output close. if t-prob-found then message "Problems found. See bad-periods.out file for list". else message "No problems found with accounting periods".