Easytrieve BEFORE-SCREEN Statement

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.

Progress0 of 0 lessons

Statement Format

text
1
2
3
4
5
6
BEFORE-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.

SCREEN Activity Flow

When screen procedures run
StepProcedureAction
SCREEN activity startINITIATIONOne-time setup
Each display iterationBEFORE-SCREENI/O, init fields, cursor
Build and send map(product)Terminal output
After user inputAFTER-SCREENValidate, branch, GOTO SCREEN
SCREEN endTERMINATIONCleanup

Typical BEFORE-SCREEN Tasks

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.

text
1
2
3
4
5
6
7
8
9
10
11
12
13
SCREEN 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

RESET Working Storage

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.

Invalid Statements

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.

BEFORE-SCREEN Versus INITIATION

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 Versus AFTER-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.

CICS and Conversational Mode

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.

Testing BEFORE-SCREEN

  1. Verify first record displays correct field values on screen open.
  2. Step through file with F8 Forward key—BEFORE-SCREEN GET each time.
  3. Test EOF path shows message and clean EXIT.
  4. Confirm RESET fields clear between iterations as designed.
  5. Attempt compile with GOTO SCREEN in BEFORE-SCREEN—expect rejection.

Common BEFORE-SCREEN Mistakes

  • GOTO SCREEN inside BEFORE-SCREEN.
  • PERFORM instead of special-name hook.
  • One-time OPEN in BEFORE-SCREEN instead of INITIATION.
  • Ignoring EOF after GET.
  • Confusing with BEFORE-LINE report procedure.
  • Validation logic in BEFORE-SCREEN instead of AFTER-SCREEN.

Explain It Like I'm Five

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.

Exercises

  1. Write BEFORE-SCREEN GET with EOF message and EXIT.
  2. List SCREEN procedures in execution order.
  3. Explain why GOTO SCREEN is forbidden in BEFORE-SCREEN.
  4. Move one-time file OPEN from BEFORE-SCREEN to INITIATION pseudocode.
  5. Contrast RESET field behavior across two screen iterations.

Quiz

Test Your Knowledge

1. BEFORE-SCREEN. PROC runs:

  • Before screen is built and sent to terminal
  • After user presses Enter only
  • During JCL execution
  • In batch JOB INPUT

2. Invalid inside BEFORE-SCREEN:

  • GOTO SCREEN, REFRESH, RESHOW
  • GET file
  • MOVE fields
  • IF conditions

3. BEFORE-SCREEN must end with:

  • END-PROC
  • END-SCREEN
  • END-IF only
  • STOP

4. RESET fields on DEFINE are initialized:

  • Before BEFORE-SCREEN runs
  • After TERMINATION
  • Never
  • Only at compile

5. Typical BEFORE-SCREEN use:

  • GET next record and initialize screen fields
  • PRINT report
  • SORT file
  • LINK-edit
Published
Read time15 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve Report Generator 11.6 BEFORE-SCREEN screen procedureSources: Broadcom Easytrieve 11.6 Language Reference BEFORE-SCREEN, Screen ProceduresApplies to: Easytrieve BEFORE-SCREEN screen procedure