Batch Easytrieve dominates tutorials—JOB INPUT, PRINT, REPORT. Enterprise shops also run SCREEN activities where operators query balances, approve adjustments, and trigger reports from terminals. BEFORE-SCREEN prepares labels and default field values before display. AFTER-SCREEN is the hook that runs after the operator fills input and presses enter—validate account number numeric, reject blank amount, READ master file, UPDATE hold record, display error message map, or EXECUTE payroll JOB when approval flag set. AFTER-SCREEN is a reserved PROC label invoked by screen runtime—not PERFORM from unrelated activity. It sits at end of SCREEN activity with other screen PROCs—INITIATION, BEFORE-SCREEN, TERMINATION—following same placement discipline as report PROCs after REPORT. Beginners port batch IF logic into BEFORE-SCREEN when validation belongs in AFTER-SCREEN after input exists. This page teaches screen event lifecycle, validation and update patterns, error messaging, EXECUTE JOB integration, variable RESET on SCREEN boundaries, contrast with report AFTER-LINE, and testing in development terminal regions.
INITIATION PROC once at SCREEN activity entry—open files, ACCESS database, set defaults. Screen cycle repeats: BEFORE-SCREEN maps outgoing fields, runtime displays screen, operator edits, AFTER-SCREEN validates and acts. TERMINATION PROC cleanup at activity end. Multiple screens in one activity chain via GOTO or CASE navigation after AFTER-SCREEN sets next screen id field.
| PROC name | When invoked |
|---|---|
| INITIATION | SCREEN activity start |
| BEFORE-SCREEN | Before each screen display |
| AFTER-SCREEN | After operator input received |
| TERMINATION | SCREEN activity end |
12345678910111213141516AFTER-SCREEN. PROC IF ACCT-NO EQ SPACES ERR-MSG = 'Account required' GOTO SAME-SCREEN END-IF IF NOT NUMERIC(ACCT-NO) ERR-MSG = 'Account must be numeric' GOTO SAME-SCREEN END-IF PERFORM READ-MASTER IF NOT-FOUND EQ Y ERR-MSG = 'Account not found' GOTO SAME-SCREEN END-IF PERFORM SHOW-DETAIL-SCREEN END-PROC
BEFORE-SCREEN loads customer name from file into display field before operator sees screen. AFTER-SCREEN reads operator-entered account number after keypress—cannot validate empty account in BEFORE-SCREEN before operator had chance to type unless clearing prior session residue. Error message field ERR-MSG set in AFTER-SCREEN displays on redisplay via BEFORE-SCREEN on next cycle.
Approved adjustment: AFTER-SCREEN validates amount range, READ hold record, ADD amount to balance, WRITE or REWRITE per file type, commit if database. Failed validation skips update and redisplays screen with ERR-MSG. Use same FILE definitions as batch Library—online and batch share data dictionary when designed well.
Operator approves report: AFTER-SCREEN sets parms and EXECUTE JOB PRINT-PAYROLL activity batch side generates spool. Operator sees confirmation message. Long-running JOB may async per site—message should set expectations. JCL for EXECUTE must exist in runtime environment documented for SCREEN.
W working storage RESET at SCREEN activity start per variable lifetime rules. Session flags persist across screen cycles within activity unless cleared in AFTER-SCREEN. S fields may carry forward through multiple EXECUTE calls—document semantics for maintainers.
Report AFTER-LINE hooks printed detail rows in batch report writer. Screen AFTER-SCREEN hooks terminal interaction cycles—completely different runtime. Names parallel BEFORE/AFTER pattern but contexts do not interchange.
The screen is a form the operator fills out. BEFORE-SCREEN puts the blank form on the desk with today's date filled in. AFTER-SCREEN is the teacher collecting the form and checking answers—if something wrong, hand form back with red marks; if right, file it and show next form.
1. AFTER-SCREEN PROC runs:
2. AFTER-SCREEN is invoked by:
3. Typical AFTER-SCREEN logic includes:
4. AFTER-SCREEN compared to BEFORE-SCREEN:
5. SCREEN activity PROC placement: