Terminal interaction is the conversation between your program and a person sitting at a 3270 display. Unlike a batch JOB that quietly reads a file from top to bottom, an online SCREEN activity is a dialogue: it shows a screen, waits for the operator to type and press a key, receives what they entered, decides what to do, and shows the next screen. Understanding this send-and-receive rhythm is the foundation of every online Easytrieve program. This page walks through the full display cycle, the four screen procedures that fire at each stage, the difference between conversational and pseudo-conversational execution, how one screen leads to another, and why online flow feels so different from the implied loop you already know from batch reporting. Everything else in screen programming—input, output, PF keys, cursor, messages—hangs off this cycle.
A 3270 terminal does not stream characters the way a modern keyboard event does. Instead it works in full-screen bursts. The program builds a complete screen image—the map—and transmits it in one go. The terminal then belongs to the operator: they tab between fields, type values, and finally press an action key such as Enter or a PF key. Only that key press sends data back. The program receives the changed fields in one burst, processes them, and builds the next screen. This send, wait, receive, process loop is the heartbeat of terminal interaction.
1234567* Conceptual cycle for one screen 1. BEFORE-SCREEN -> load output fields, position cursor 2. (runtime) -> transmit map to terminal 3. (operator) -> types input, presses Enter or a PF key 4. (runtime) -> receive changed fields and the key pressed 5. AFTER-SCREEN -> validate input, act, decide next screen 6. repeat, or leave the activity
The important beginner insight is that your code does not run while the operator is typing. It runs in short bursts before the send (BEFORE-SCREEN) and after the receive (AFTER-SCREEN). Between those bursts the program is waiting. Designing around this rhythm—rather than expecting keystroke-by-keystroke control—keeps online logic simple and correct.
An Easytrieve SCREEN activity exposes four special-name procedures that the runtime calls at fixed points. You do not PERFORM them; the runtime dispatches each one when its event occurs. Placing logic in the right procedure is most of the skill in online programming.
| Procedure | When it runs | Typical work |
|---|---|---|
| INITIATION | Once, at activity start | Open files, load tables, set one-time defaults |
| BEFORE-SCREEN | Before every display | Load output fields, set cursor, clear messages |
| AFTER-SCREEN | After each operator submit | Validate input, update files, choose next screen |
| TERMINATION | Once, at activity end | Close files, release resources, final cleanup |
INITIATION and TERMINATION bracket the whole activity and run a single time each. BEFORE-SCREEN and AFTER-SCREEN bracket every individual display cycle and run once per interaction. A frequent beginner error is putting one-time setup such as opening a file in BEFORE-SCREEN, which then re-runs on every cycle; that work belongs in INITIATION.
How the program behaves while waiting for the operator defines two execution styles. In conversational mode the task stays in memory the entire time, holding files, storage, and any locks while the operator thinks. It is simple to reason about because your variables keep their values across the wait. The cost is scalability: dozens of idle operators each pin resources. In pseudo-conversational mode the task ends after sending the screen and is restarted when the operator presses a key, so resources are freed during think time. This scales far better under CICS but requires saving state between interactions.
| Aspect | Conversational | Pseudo-conversational |
|---|---|---|
| Resources during wait | Held by the idle task | Released until next key press |
| State handling | Variables persist naturally | Must be saved and restored between turns |
| Scalability | Limited—each user pins resources | High—supports many concurrent users |
| Complexity | Simpler to write | More design effort to preserve context |
Which mode your Easytrieve screen uses depends on the runtime environment and site configuration, especially whether screens run native or under CICS. Confirm with your operations team; the programming pattern for BEFORE-SCREEN and AFTER-SCREEN stays similar, but state persistence assumptions change.
Real applications are not a single screen; they are a flow—menu, inquiry, detail, confirm. The decision about which screen comes next is made in AFTER-SCREEN, after you know what the operator typed and which key they pressed. You branch based on that information, often setting a next screen identifier or using GOTO or CASE logic to route control. A menu screen reads a selection number and routes to the matching screen; a detail screen returns to the list when the operator presses the exit key.
123456789101112AFTER-SCREEN. PROC CASE MENU-CHOICE WHEN '1' PERFORM SHOW-CUSTOMER-INQUIRY WHEN '2' PERFORM SHOW-ORDER-ENTRY WHEN '9' PERFORM EXIT-APPLICATION OTHERWISE SCR-MSG = 'INVALID SELECTION' END-CASE END-PROC
If you have written batch reports, the mental shift is real. A JOB INPUT activity loops automatically: read a record, run your logic, read the next, until end of file, with no human in the loop. A SCREEN activity has no file to exhaust—it loops until the operator chooses to leave. The driver is human action and key presses, not EOF. Counters accumulate across interactions the way they accumulate across records, but the pacing is set by a person, and the program spends most of its life waiting rather than computing.
1234567891011121314151617181920212223SCREEN NAME CUST-INQUIRY * field layout and KEY definitions here INITIATION. PROC OPEN CUSTOMER-FILE END-PROC BEFORE-SCREEN. PROC PERFORM LOAD-DISPLAY SCR-MSG = SPACES END-PROC AFTER-SCREEN. PROC IF ACCT-NO EQ SPACES SCR-MSG = 'ENTER AN ACCOUNT NUMBER' ELSE PERFORM LOOKUP-ACCOUNT END-IF END-PROC TERMINATION. PROC CLOSE CUSTOMER-FILE END-PROC
Talking to a terminal is like passing notes with a friend. You write a whole note and slide it over—that is sending the screen. Then you wait; you cannot see your friend writing. When they slide the note back with their answer—that is pressing Enter—you read it and write a new note. The teacher hands out the first blank note (INITIATION) and collects everything at the end of class (TERMINATION). You only get to write just before sliding a note over and just after getting one back—never in between.
1. The basic 3270 terminal interaction cycle is:
2. Which procedure runs once at the start of a SCREEN activity?
3. A conversational program differs from pseudo-conversational because it:
4. Online SCREEN activities differ from batch JOB activities because they:
5. Moving from one screen to the next is usually driven by: