RPTRUN - Retriever Runner Activity

-- RPTRUN — Retriever scheduled runner activity.
-- One row per PASS of the runner, which is a different question from the
-- one RPTLOG answers. RPTLOG records report EXECUTIONS — including
-- interactive runs from the screen and export staging — so it cannot tell
-- you whether the runner is alive: a dead job and a quiet night both
-- produce no rows there. This table records that the runner woke up,
-- looked, and what it found.
--
-- IDLE = 'N' rows are activity and are always inserted, one per pass that
-- ran something, carrying that pass's counts (DUE/SENT/SKIPPED/FAILED),
-- the number of individual emails accepted (EMAILS), the report names
-- (REPORTS) and a human summary line per report (DETAIL).
--
-- IDLE = 'Y' rows are quiet, and are COALESCED. A pass that finds nothing
-- due looks at the newest row: if it is already idle it updates ENDED and
-- increments PASSES; otherwise it inserts a new idle row. So a runner
-- polling every five minutes all weekend leaves ONE row saying "quiet from
-- Friday 18:05 to Monday 06:00, 690 passes" rather than 690 rows. The
-- table therefore reads as a timeline of activity with quiet stretches
-- between, and stays small enough to keep indefinitely.
--
-- Per-report detail lives in RPTLOG and per-recipient detail in RPTMAIL;
-- this is the index over them. No FKs — like RPTMAIL, log rows outlive the
-- schedules and reports they describe, and REPORTS is a name snapshot
-- rather than a reference.
--
-- Written best effort by Tools\Retriever\ScheduledRunner: an install
-- without this table, or a profile without INSERT on it, still sends its
-- reports. Dry runs write nothing.
--
-- Runs in each install's XXX_5WEB library.

SET SCHEMA XXX_5WEB;

CREATE TABLE RPTRUN (
	RUN_ID INTEGER GENERATED ALWAYS AS IDENTITY
		( START WITH 1 INCREMENT BY 1 ) NOT NULL ,
	STARTED TIMESTAMP NOT NULL ,
	ENDED TIMESTAMP DEFAULT NULL ,
	IDLE CHAR(1) CCSID 37 NOT NULL DEFAULT 'N' ,
	PASSES INTEGER NOT NULL DEFAULT 1 ,
	DUE INTEGER NOT NULL DEFAULT 0 ,
	SENT INTEGER NOT NULL DEFAULT 0 ,
	SKIPPED INTEGER NOT NULL DEFAULT 0 ,
	FAILED INTEGER NOT NULL DEFAULT 0 ,
	EMAILS INTEGER NOT NULL DEFAULT 0 ,
	REPORTS VARCHAR(500) CCSID 37 NOT NULL DEFAULT '' ,
	DETAIL VARCHAR(2000) CCSID 37 NOT NULL DEFAULT '' ,
	PRIMARY KEY ( RUN_ID ) )

	RCDFMT RPTRUN ;

LABEL ON TABLE RPTRUN
	IS 'Web - Retriever Runner Activity' ;

CREATE INDEX RPTRUN_STARTED_IX ON RPTRUN ( STARTED ) ;

Columns

Column Meaning
RUN_ID Identity. Newest row = most recent pass, which is how the coalescing rule finds the current quiet stretch.
STARTED When this row began. For an idle row, when the quiet stretch started.
ENDED When this row last changed. For an idle row this moves forward on every quiet pass, so ENDED is effectively “runner last seen alive”.
IDLE 'N' = the pass ran something. 'Y' = nothing was due; this row is coalescing.
PASSES How many passes this row represents. Always 1 on activity rows; counts up on idle rows.
DUE Schedules found due in this pass.
SENT Schedules that rendered and delivered.
SKIPPED Schedules that ran but deliberately sent nothing — SENDMODE said not to, or the schedule had no enabled recipients. Not a failure.
FAILED Schedules that errored. Detail is in RPTSCHED.LASTERROR and RPTLOG.ERRORTEXT; the owner is emailed.
EMAILS Individual messages SendGrid accepted across the whole pass — not the same as SENT, since one report goes to many recipients.
REPORTS Comma-separated report names this pass touched, truncated at 500. A snapshot, not a reference.
DETAIL One human line per report, e.g. Overstock By Supplier — sent to 3, 8412 row(s), truncated at 2000.

Reading it

Is the runner alive? The newest row’s ENDED is the last time it woke up, whether or not it did anything. If that is hours old, the job is dead or the subsystem is down — check WRKACTJOB SBS(XXX_NOMAX).

What went out last night? Filter IDLE = 'N' and read DETAIL.

Why did nothing go out? An idle row spanning the time a report was due means the runner was awake and did not consider it due — its RUNTIME, RUNDAYS or LASTRUN in RPTSCHED will say which. A gap with no row at all means the runner was not running.

Note on the K3S_NITE gate. When the data area is not '0' the runner exits before touching the database at all, so those passes leave no row here — deliberately, since writing to XXX_5WEB during the night job is exactly what the gate exists to prevent. A gap during the night-job window is expected, not a fault.