Online transactions fail in production when validation is weak: operators enter bad account numbers, leave required fields blank, pick incompatible date ranges, and still UPDATE master files because the program never checked. Easytrieve screen validation spans two layers—declarative rules on ROW declarations that catch simple input mistakes before logic runs, and procedural checks in AFTER-SCREEN that enforce business rules requiring file READ, table SEARCH, or cross-field comparisons. VALUE and ERROR on ROW handle menu letters and numeric masks; AFTER-SCREEN handles account exists on master, sufficient balance, and approval authority. Failed validation redisplays the screen with message text and cursor on the problem field—GOTO SCREEN and REFRESH belong in AFTER-SCREEN, not BEFORE-SCREEN. This page teaches validation design for beginners: declarative clauses, attribute-based rules, procedural patterns, error message fields, validation PROC modularization, and safe ordering so file updates never run on rejected input.
Think of validation as a funnel. Terminal attributes and VALUE lists filter keystrokes and required presence at field level. AFTER-SCREEN applies business rules on complete panel input after Enter or IMMEDIATE key. Only when all layers pass should READ/UPDATE/WRITE modify production files. Splitting responsibilities prevents duplicating the same IF in three PROCs and prevents UPDATE before format checks complete.
| Layer | Where coded | Examples |
|---|---|---|
| Field attributes | ROW ATTR | NUMERIC, MUSTENTER, MUSTFILL |
| Declarative lists | ROW VALUE ERROR | Menu V E D X; ERROR 'Invalid option' |
| Business rules | AFTER-SCREEN PROC | READ master; IF NOT FOUND; date range |
| Shared modules | VALIDATE. PROC PERFORM | Reusable date and amount checks |
123ROW 8 COL 10 SCR-OPT VALUE ('V' 'E' 'D' 'X') + ERROR 'Valid options: V View E Edit D Delete X Exit' MUSTENTER
VALUE enumerates allowed values—typically single-character menus or short codes. Operator typing outside list triggers ERROR message on redisplay. MUSTENTER blocks empty submission. Combine with UPPERCASE on SCREEN header so lowercase v matches V in VALUE list when product translates input.
NUMERIC restricts keys to numeric characters—use on account numbers and amounts when DEFINE is numeric. MUSTFILL requires every position in field length filled—useful for fixed-length codes. MUSTENTER requires some input. INVISIBLE fields still validate when used for password entry. ALARM draws attention on error highlight per terminal support. Attributes apply on ROW; DEFAULT can set baseline MUSTENTER for all input fields in simple forms.
1234567891011121314AFTER-SCREEN. PROC IF SCR-ACCT EQ 0 SCR-MSG = 'Account number required' GOTO SCREEN END-IF READ CUSTMAST KEY SCR-ACCT IF NOT CUSTMAST SCR-MSG = 'Account not found' GOTO SCREEN END-IF MOVE CUST-NAME TO SCR-NAME MOVE CUST-BAL TO SCR-BAL SCR-MSG = SPACES END-PROC
AFTER-SCREEN runs after operator input. Zero account fails business rule VALUE cannot express. READ validates existence on master. Success MOVEs output fields; failure sets SCR-MSG and GOTO SCREEN redisplays inquiry panel. Broadcom permits GOTO SCREEN in AFTER-SCREEN—not in BEFORE-SCREEN.
12345678910AFTER-SCREEN. PROC IF SCR-END-DATE LT SCR-START-DATE SCR-MSG = 'End date must be on or after start date' GOTO SCREEN END-IF IF SCR-AMOUNT GT SCR-LIMIT SCR-MSG = 'Amount exceeds approval limit' GOTO SCREEN END-IF END-PROC
Compare multiple screen fields after complete panel entry. Amount versus limit may READ approver profile first. Document cross-field rules in screen design spec so testers know invalid combinations to exercise.
Department or status codes validate via SEARCH on TABLE files—same pattern as batch LOOKUP. AFTER-SCREEN SEARCH DEPTTAB WITH SCR-DEPT GIVING SCR-DEPTNAME; IF NOT DEPTTAB set message and GOTO SCREEN. Combines reference data integrity with online input without SQL for small code tables.
123456789101112131415AFTER-SCREEN. PROC PERFORM VALIDATE-ACCT IF ERR-FLAG EQ 'Y' GOTO SCREEN END-IF PERFORM VALIDATE-AMOUNTS IF ERR-FLAG EQ 'Y' GOTO SCREEN END-IF PERFORM UPDATE-MASTER END-PROC VALIDATE-ACCT. PROC ... END-PROC
Shared VALIDATE. PROC modules keep AFTER-SCREEN readable when rules grow. ERR-FLAG or SCR-MSG convention signals failure. PERFORM order matters—cheap format checks before expensive READ of large files.
BEFORE-SCREEN prepares display—GET next record, MOVE defaults, clear prior input areas. Do not validate operator typing there; it has not arrived yet. Do not GOTO SCREEN in BEFORE-SCREEN. INITIATION opens files once—not per-validation. TERMINATION cleanup runs at activity end—not per failed field.
KEY F1 IMMEDIATE processes help without full Enter on other fields. KEY definitions may PERFORM help PROC before redisplay. Validation for IMMEDIATE keys runs in key handler path—ensure help keys do not accidentally trigger UPDATE paths meant for Enter confirmation.
Validation is the teacher checking your homework before it goes in the grade book. VALUE is the list of answers allowed for question one. AFTER-SCREEN is the teacher reading the whole page— dates must make sense, account must exist. If something is wrong, you get the paper back with a note at the bottom (ERROR message) and fix it before turning it in again.
1. Declarative field validation on ROW uses:
2. Business rules like account exists in file belong in:
3. Failed validation typically redisplays with:
4. MUSTENTER means:
5. Validation should not run file UPDATE before: