Easytrieve POSITION

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.

Progress0 of 0 lessons

Numeric Start-Location

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.

text
1
2
3
4
5
FILE PERSNL FB(150 1800) NAME 17 16 A PAY-GROSS 94 4 P 2 DEPT 98 3 N DATE-OF-HIRE 136 6 N

Calculating Positions From Copybooks

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.

Position calculation examples
FieldCOBOLEasytrieve positionLength
EMPNOPIC X(6)16 A
LAST-NAMEPIC X(16)716 A
GROSSPIC S9(7)V99 COMP-3After prior fields5 P 2
FILLERPIC X(3)Counts but may omit DEFINE3 bytes skip

Asterisk Auto-Position

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.

text
1
2
3
4
FILE TRAILER FB(80 800) REC-COUNT 1 6 N TOTAL-GROSS * 5 P 2 FILLER * +2 10 A

Working Storage W

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.

Static Storage S

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.

W vs S location comparison
LocationStorageSpooled to work file?Typical use
WWorkingYesCounters, scratch amounts
SStatic workingNoRun date, job constants
1–nFile recordN/AInput/output columns

Overlay Position

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.

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

Qualified Overlay From Another File

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.

Position and Record Length

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.

Common Position Mistakes

  1. Zero-based counting from PC habits—Easytrieve uses position 1.
  2. Omitting COBOL FILLER bytes from running offset.
  3. Wrong +2 on overlay—confuses skip with absolute file position.
  4. Defining child overlay before parent field.
  5. Using W position syntax on FILE record columns.

Explain It Like I'm Five

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.

Exercises

  1. Given EMPNO bytes 1–6 and NAME bytes 7–22, write two FILE lines with positions.
  2. Split six-byte date at 136 into three +offset overlays.
  3. Explain when S is preferable to W for CURR-DATE.
  4. Calculate last byte used for field at 94 length 4.
  5. List one cause of one-byte position shift in copybooks.

Quiz

Test Your Knowledge

1. Start-location on a FILE field is relative to:

  • Byte 1 of the record
  • Byte 0 of the file
  • JCL DD statement
  • REPORT line

2. Location W means:

  • Working storage
  • Write-only
  • Wide type
  • Week field

3. Overlay HIRE-DD DATE-OF-HIRE +2 2 N places HIRE-DD at:

  • Two bytes after start of DATE-OF-HIRE
  • Byte 2 of file only
  • Working storage
  • Column 2 of report

4. Asterisk * as location means:

  • Next available position after highest defined so far
  • End of file
  • Random position
  • Comment

5. Static storage S differs from W because:

  • S is not spooled to report work files per Broadcom
  • S cannot hold numbers
  • S is only in JCL
  • S replaces FILE
Published
Read time14 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 DEFINE start-location W S overlay offsetSources: Broadcom Easytrieve 11.6 DEFINE Statement location sectionApplies to: Easytrieve field position and overlay layout