Easytrieve Cursor Positioning

The cursor is the small blinking marker that shows where typing will go. On a 3270 terminal it is the operator's starting point every time a screen appears, so where you place it has a real effect on speed and accuracy. Put the cursor on the first field an operator should fill and they can start typing instantly. Put it on the field that just failed validation and they can correct the mistake without searching. Leave it unmanaged and the operator may waste keystrokes tabbing to the right place. This page explains what cursor positioning is, how the SCREEN runtime decides where the cursor lands, how to set it in BEFORE-SCREEN, the important pattern of moving the cursor to the field in error, default behavior when you say nothing, and the small habits that make data entry feel smooth. Cursor handling is a detail, but it is the kind of detail operators notice every single day.

Progress0 of 0 lessons

What the Cursor Represents

On a full-screen 3270 display the cursor is where the next character the operator types will appear. It also determines where certain terminal actions begin. Because the whole screen is sent at once and the operator then works locally until they press a key, the cursor's starting position is fixed by what the program requested when it painted the map. If you request the account number field, the operator opens the screen already positioned to type an account number. That immediacy is the entire point of thoughtful cursor positioning.

How Positioning Is Requested

Easytrieve lets you indicate the target field to the screen runtime before the display. The exact mechanism depends on the release: some use a CURSOR attribute or clause on a field, some expose a cursor field you set to the name or index of the target, and some let you mark a field as the default cursor location in the SCREEN definition. Whatever the spelling, the idea is the same—you name the field that should receive focus, and the runtime paints the cursor there when it transmits the screen.

Ways cursor position is influenced (release dependent)
MethodHow it worksWhen useful
Default field in SCREENMark one field as the standard cursor home
Cursor indicator set in codeSet a value naming the target field before display
First unprotected field defaultRuntime picks the first input field automatically

Because the precise keyword and field name are release-specific, verify them in your SCREEN statement reference before coding. The patterns below use a placeholder such as CURSOR-FIELD to represent whatever your release provides; the reasoning transfers regardless of syntax.

Setting the Cursor in BEFORE-SCREEN

BEFORE-SCREEN runs immediately before the screen is painted, which is exactly when the cursor target must be known. On a fresh inquiry screen you set the cursor to the primary input field so the operator can begin. On a data entry screen with several fields you place it on the first one in tab order. The assignment is simple: name the field, and let the runtime handle the rest.

text
1
2
3
4
5
6
BEFORE-SCREEN. PROC PERFORM LOAD-DISPLAY * Position cursor on the primary input field CURSOR-FIELD = 'ACCT-NO' SCR-MSG = SPACES END-PROC

The Error-Field Pattern

The most valuable use of cursor positioning is error handling. When AFTER-SCREEN detects an invalid field it records both a message and which field failed. On the next display, BEFORE-SCREEN reads that record and positions the cursor on the failing field. The operator sees the error message and finds the cursor already sitting on the field they must fix. This single behavior makes correction feel effortless and is a hallmark of well-built screens.

text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
AFTER-SCREEN. PROC IF ACCT-NO EQ SPACES SCR-MSG = 'ACCOUNT NUMBER REQUIRED' ERROR-FIELD = 'ACCT-NO' ELSE IF NOT NUMERIC(ACCT-NO) SCR-MSG = 'ACCOUNT MUST BE NUMERIC' ERROR-FIELD = 'ACCT-NO' ELSE ERROR-FIELD = SPACES PERFORM LOOKUP-ACCOUNT END-IF END-PROC BEFORE-SCREEN. PROC PERFORM LOAD-DISPLAY IF ERROR-FIELD NE SPACES CURSOR-FIELD = ERROR-FIELD ELSE CURSOR-FIELD = 'ACCT-NO' END-IF END-PROC

The two procedures cooperate: AFTER-SCREEN diagnoses and records the problem field, BEFORE-SCREEN acts on that record when repainting. Keeping the error field name in a dedicated working field (here ERROR-FIELD) keeps the logic clear and lets you extend it to multiple fields later.

Default Cursor Behavior

If you never set the cursor, Easytrieve applies a default—commonly the first unprotected field on the screen in row-column order. For a screen with a single input area that default is often fine. The trouble appears on richer screens: the first unprotected field may not be the one the operator should fill first, and after an error the default ignores which field failed. Relying on the default is acceptable for prototypes, but production screens benefit from explicit positioning that you control on every cycle.

Do Not Position on Protected Fields

Output fields are protected so the operator cannot type into them. Placing the cursor on a protected field is confusing—the operator sees the cursor but cannot type, and the terminal may move focus unpredictably. Always target an unprotected input field. If a screen is display-only with no input fields at all, let the default apply or position on a field associated with the primary action, and rely on PF keys for navigation.

Cursor and Paging

On list screens that page with PF7 and PF8, decide where the cursor belongs after a page change. A common choice is the first data row or the command field, so the operator can immediately act on the newly displayed page. Set this in BEFORE-SCREEN based on the navigation the operator just performed. Consistency matters: if paging always lands the cursor in the same logical spot, operators build muscle memory.

Testing Cursor Positioning

  1. Open a fresh screen and confirm the cursor starts on the intended first field.
  2. Submit an invalid field and confirm the cursor lands on that field with a message.
  3. Correct the error and confirm the cursor returns to normal starting position.
  4. Verify the cursor never rests on a protected output field.
  5. Page a list and confirm the cursor lands in the agreed spot each time.

Common Cursor Mistakes

  • Never setting the cursor, so focus defaults to the wrong field on complex screens.
  • Positioning on a protected field the operator cannot type into.
  • Forgetting to move the cursor to the field in error after validation fails.
  • Setting the cursor in AFTER-SCREEN instead of BEFORE-SCREEN, so it has no effect on the next paint.
  • Leaving a stale error-field value so the cursor keeps jumping to a field already corrected.
  • Assuming a cursor field name without checking the release reference.

Explain It Like I'm Five

The cursor is like the tip of your pencil on a worksheet. When the teacher hands you the sheet, it is nicest if the pencil is already resting on the first blank you need to fill in, so you can start right away. If you write a wrong answer and the teacher hands it back, the best teachers put your pencil right on the mistake so you know exactly what to fix. We should not rest the pencil on a spot that is glued shut—those are the read-only areas you cannot write on.

Exercises

  1. Set the cursor to a primary input field in BEFORE-SCREEN for a new screen.
  2. Record an error field in AFTER-SCREEN and position the cursor on it next cycle.
  3. Explain why cursor changes belong in BEFORE-SCREEN, not AFTER-SCREEN.
  4. Describe the default cursor behavior and when it is insufficient.
  5. Decide where the cursor should land after paging a list and justify it.

Quiz

Test Your Knowledge

1. Cursor positioning on a screen controls:

  • Where the operator starts typing when the screen appears
  • The sort key of a file
  • The report page size
  • The blocksize of a dataset

2. After a validation error, good practice is to place the cursor on:

  • The field that failed validation
  • The last field on the screen
  • A protected output field
  • The message line

3. Where do you normally set cursor position for the next display?

  • BEFORE-SCREEN
  • TERMINATION
  • In the JCL
  • Inside END-PROC only

4. If you never set the cursor, the runtime usually:

  • Places it at a default position such as the first unprotected field
  • Crashes the program
  • Sorts the file
  • Disables all keys

5. The cursor should be placed on a protected field:

  • Rarely—cursors belong on input fields the operator can edit
  • Always
  • Only on menus
  • Whenever paging
Published
Read time15 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve Report Generator 11.6 SCREEN activity cursor positioningSources: Broadcom Easytrieve 11.6 Programming Guide SCREEN section, cursor handling, screen field definitionsApplies to: Easytrieve screen cursor positioning