Position answers one question before length and type matter: where do this field's bytes start? On a FILE record, position is a byte number counting from one at the left end of each record—the same convention COBOL copybooks use when they list field offsets. On working storage, position is the letter W or S instead of a number. On overlays, position is another field's name plus an optional +offset skip. One-byte position error on a packed salary field makes department code look like part of gross pay and every following field drift. This page teaches numeric start positions, asterisk auto-layout, W versus S, overlay offsets, qualified overlays from other files, and copybook transcription discipline beginners need before touching production payroll layouts.
The most common FILE pattern names the field, gives an unsigned integer start byte, then length and type. NAME 17 16 A starts at byte seventeen and occupies sixteen bytes through byte thirty-two inclusive. Positions are one-based—first byte of record is one, not zero. COBOL programmers transcribing copybooks must include SYNC padding and FILLER bytes in the count even when FILLER is not declared as an Easytrieve field.
12345FILE PERSNL FB(150 1800) NAME 17 16 A PAY-GROSS 94 4 P 2 DEPT 98 3 N DATE-OF-HIRE 136 6 N
Walk the copybook sequentially. If EMPNO is PIC X(6) at start, position 1 length 6. Next field LAST-NAME PIC X(16) starts at 7 unless filler intervenes. COMP-3 packed fields consume bytes per COMP formula—not display digit count. Document running offset in a spreadsheet when learning; experienced maintainers verify with hex dump on sample records when copybook is old or REDEFINES obscure layout.
| Field | COBOL | Easytrieve position | Length |
|---|---|---|---|
| EMPNO | PIC X(6) | 1 | 6 A |
| LAST-NAME | PIC X(16) | 7 | 16 A |
| GROSS | PIC S9(7)V99 COMP-3 | After prior fields | 5 P 2 |
| FILLER | PIC X(3) | Counts but may omit DEFINE | 3 bytes skip |
Coding * as location places the field at the next available byte after the highest position already defined in the current FILE block—plus optional +offset literal. Useful when appending trailer fields without recalculating absolute numbers. Syntax requires blank between * and +offset. Positive offset only. Less common in maintained copybook-driven layouts than explicit integers because absolute positions aid cross-program comparison.
1234FILE TRAILER FB(80 800) REC-COUNT 1 6 N TOTAL-GROSS * 5 P 2 FILLER * +2 10 A
W replaces numeric position for fields that live in program memory, not on the input record. DEFINE WS-TAX W 5 P 2 allocates five packed bytes in working storage. W fields spool to report work files when used in sequenced reporting contexts—Broadcom warns non-static W accumulators used after sequencing may produce wrong averages if logic assumes pre-sequence values. Understand W before building report totals in working storage.
S also allocates working storage but marks static persistence semantics. CURR-DATE S 6 N in sample programs holds run date set once by %GETDATE. S fields are not spooled to report work files the way W fields are. Choose S for values that should remain stable across report formatting phases within a job run.
| Location | Storage | Spooled to work file? | Typical use |
|---|---|---|---|
| W | Working | Yes | Counters, scratch amounts |
| S | Static working | No | Run date, job constants |
| 1–n | File record | N/A | Input/output columns |
Overlay syntax: child-name parent-name [+offset] length type. HIRE-MM DATE-OF-HIRE 2 N starts at byte one of parent—no +offset needed. HIRE-DD DATE-OF-HIRE +2 2 N skips two bytes from parent start. Child must fit inside parent byte span. Parent must be defined first in source. Overlaying different types on same bytes is allowed but contents are not revalidated—use same type family when possible.
1234567DATE-OF-HIRE 136 6 N HIRE-MM DATE-OF-HIRE 2 N HIRE-DD DATE-OF-HIRE +2 2 N HIRE-YY DATE-OF-HIRE +4 2 N LAST-NAME NAME 8 A FIRST-NAME NAME +8 8 A
file-qualifier:overlay-field-name lets overlay reference parent in different file or record when current definition context differs. Rare in beginner batch programs but appears in multi-file macros. Qualifier prevents ambiguous parent when duplicate names exist across FILE statements.
Last field start plus length minus one must not exceed record length on FILE FB(lrecl ...). FB(150 1800) allows 150-byte records. Field starting at 136 length 6 ends at 141—valid. Field starting at 145 length 10 ends at 154—exceeds 150, layout error or truncated read. Always reconcile highest byte used with DCB LRECL in JCL.
Position is the seat number on a long bench. Each person field sits in numbered seats starting at one. Overlays are smaller name tags on part of someone else's seat—month and day tags on the birthday seat. W and S are extra chairs next to the bench for scratch paper, not part of the bench from the file.
1. Start-location on a FILE field is relative to:
2. Location W means:
3. Overlay HIRE-DD DATE-OF-HIRE +2 2 N places HIRE-DD at:
4. Asterisk * as location means:
5. Static storage S differs from W because: