BEFORE-SCREEN is a special-name screen procedure the SCREEN activity invokes before sending data to the terminal. Online Easytrieve programs present maps, accept function keys, and read input—BEFORE-SCREEN prepares each display cycle. Typical tasks: GET the next personnel record to populate name fields, MOVE SPACE to clear prior input, set default values from master files, or position the cursor on the first editable field. It runs after working storage fields with RESET on DEFINE are reinitialized and before the screen image is built and transmitted. Format is BEFORE-SCREEN. PROC terminated by END-PROC within the SCREEN activity block. Broadcom forbids GOTO SCREEN, REFRESH, and RESHOW inside BEFORE-SCREEN—those belong in AFTER-SCREEN or other flow points. Beginners migrating from batch JOB logic must learn SCREEN procedure names parallel to report BEFORE-LINE hooks. This page teaches syntax, SCREEN activity sequence, valid statements, restrictions, comparison with AFTER-SCREEN and INITIATION, and pseudo-conversational considerations on CICS-backed deployments.
123456BEFORE-SCREEN. PROC GET PERSNL IF EOF PERSNL EXIT END-IF END-PROC
Broadcom example shows GET from file PERSNL at start of each screen cycle—when end of file, EXIT ends procedure flow. Your maps reference fields populated here before the operator sees the screen.
| Step | Procedure | Action |
|---|---|---|
| SCREEN activity start | INITIATION | One-time setup |
| Each display iteration | BEFORE-SCREEN | I/O, init fields, cursor |
| Build and send map | (product) | Terminal output |
| After user input | AFTER-SCREEN | Validate, branch, GOTO SCREEN |
| SCREEN end | TERMINATION | Cleanup |
File GET reads next master record driving inquiry screens. MOVE initializes output-only fields or clears input areas from prior transaction. Assignment sets calculated defaults. IF EOF handles empty file gracefully with message field and EXIT. Cursor positioning statements per release grammar place focus on first error field after validation failure in prior cycle—often coordinated with AFTER-SCREEN setting hold flags BEFORE-SCREEN reads.
12345678910111213SCREEN NAME INQUIRY KEY F3 NAME 'Exit' EXIT KEY F8 NAME 'Forward' BEFORE-SCREEN. PROC GET MASTER-FILE IF EOF MASTER-FILE MSG = 'NO MORE RECORDS' EXIT END-IF MOVE CUST-NAME TO SCR-NAME MOVE CUST-BAL TO SCR-BALANCE END-PROC
Fields defined with RESET in Library reinitialize before BEFORE-SCREEN each iteration. Do not rely on values persisting across screen cycles unless stored in non-RESET fields or file buffers. Conflicts occur when AFTER-SCREEN expects a flag BEFORE-SCREEN clears via RESET—document field RESET attributes in screen design specs.
GOTO SCREEN, REFRESH, and RESHOW are invalid in BEFORE-SCREEN and procedures invoked from it. These control redisplay and flow after input processing—code them in AFTER-SCREEN when validation fails or user requests refresh. Violating restriction yields compile or runtime errors depending on release checks.
INITIATION runs once when SCREEN activity begins—open files, load tables, display welcome once. BEFORE-SCREEN runs every iteration including each return from AFTER-SCREEN loop. Heavy one-time setup belongs in INITIATION; per-record GET belongs in BEFORE-SCREEN.
BEFORE-SCREEN prepares outgoing map data before terminal send. AFTER-SCREEN processes incoming data after Enter or PF keys—validation, UPDATE files, GOTO SCREEN to redisplay. Split read logic: populate before show; validate after receive.
Called programs in CICS must stay conversational when Easytrieve CALL is used—task must not end in called program. Screen activities on CICS often use pseudo-conversational patterns; BEFORE-SCREEN may run on each resumed task. Coordinate with operations on terminal definition and transaction routing separate from batch JOB tutorials.
BEFORE-SCREEN is getting the page ready before the teacher shows it on the big screen. You fetch the right name and numbers and erase old scribbles. Then the computer shows the page to the person typing. You cannot press the redo-display button during setup—that button works later after the person answers. The computer calls BEFORE-SCREEN every time a new page is about to show.
1. BEFORE-SCREEN. PROC runs:
2. Invalid inside BEFORE-SCREEN:
3. BEFORE-SCREEN must end with:
4. RESET fields on DEFINE are initialized:
5. Typical BEFORE-SCREEN use: