Easytrieve Padding

Padding is what happens when a ten-character name field holds only four letters and the remaining six bytes are spaces. Or when a numeric working storage field starts at zero before your JOB logic runs. Easytrieve does not call it padding in every manual, but the behavior is everywhere: assignment rules, default initialization, report MASK characters, and file records that arrive space-filled from COBOL programs. Beginners lose hours when IF STATUS EQ 'Y' fails because the file field is Y plus nine spaces and the literal was one byte. This page explains space fill, zero fill, display padding versus storage padding, and patterns to pad intentionally for output formats.

Progress0 of 0 lessons

Default Initialization Padding

DEFINE working storage fields receive default values at program start. Type A fields become all spaces—EBCDIC X'40' on the mainframe. Numeric types N, P, B, U, and I initialize to zero in their respective formats. VALUE on DEFINE overrides defaults with your literal or numeric constant. FILE fields read from input carry whatever bytes exist in the record; the compiler does not pad file fields on read.

text
1
2
3
4
5
DEFINE WS-NAME W 20 A DEFINE WS-CNT W 5 N 0 * WS-NAME starts as 20 spaces; WS-CNT starts as numeric zero DEFINE WS-FLAG W 1 A VALUE 'N'

Assignment Padding Rules

When a receive field is longer than the source, assignment pads the result. Character assignment pads with spaces on the right for standard MOVE patterns. Shorter literal 'ABC' into ten-byte field yields ABC plus seven spaces. When source is longer than receive, truncation drops rightmost bytes unless you designed overlay to capture the portion you need. Numeric assignment uses conversion rules—assigning N to longer N may pad with leading zeros in zoned format per field type.

Padding behavior by type
SituationTypical fillNotes
A WS init without VALUESpacesAll bytes X'40' EBCDIC
Numeric WS init without VALUEZerosPacked, zoned, or binary zero
Short literal to long ARight space padOn assignment
Long source to short ATruncate rightData loss possible
MASK Z on reportSuppress leading zero displayStorage unchanged

Space Padding and Comparisons

IF FIELD EQ 'ABC' compares the literal to the full field width. A ten-byte field containing ABC plus spaces fails EQ against three-byte literal unless you compare a three-byte overlay or normalize first. GT and LT use collating sequence where space often sorts before letters in EBCDIC—another surprise for beginners. Document whether file standards require trailing spaces or trimmed values; mixed files break comparisons.

text
1
2
3
4
5
6
DEFINE WS-STAT W 5 A * File has 'OK ' in 5 bytes IF WS-STAT EQ 'OK' * May FAIL—literal is 2 bytes, field is 5 IF WS-STAT EQ 'OK ' * Matches if bytes align exactly

Leading Zero Padding for Display

Part numbers and employee IDs often need leading zeros visible on reports. MASK literals with 9 characters print every digit including leading zeros: '0000000009' pattern for nine-digit IDs. MASK with Z suppresses leading zeros for counts you do not want padded: ZZZ9 shows 42 instead of 0042. Choose per business rule—social security masks use 9 throughout; quantity fields often use Z. BWZ blanks entire field on report when all zeros.

Leading Zero Padding in Character Fields

Store IDs as type A to preserve leading zeros that numeric types would drop on display. Pad character codes by building with literals: MOVE '00001234' to eight-byte field, or concatenate segments in a buffer. Loop filling with INDEX over digit positions when length varies. No built-in PAD LEFT statement—explicit logic or copy from upstream system that already padded the file.

Numeric Zero Padding

Zoned N fields store digits with zone nybbles—unassigned digit positions may appear as zero digits in display. Packed P fields compress digits—value zero occupies packed zero pattern in all bytes. Assignment INTEGER or ROUNDED affects numeric padding on conversion, not character spaces. SUM on reports treats quantitative zero fields as numeric zero, not blank—use BWZ on MASK to hide zero amounts on printed output.

FILL on ROW and Screen Statements

Screen ROW statement supports FILL with a fill character or NULL for input field display padding on panels. Report formatting may use literals interleaved with fields to pad columns visually. FILL affects presentation layer similar to MASK—not always the stored FILE field unless you WRITE that padded image back to disk.

Output Record Padding

When writing files, output records should match downstream COBOL or Easytrieve layouts. Space-fill unused name columns before WRITE so receivers expecting fixed eighty-byte records get consistent blanks. Numeric amounts in P format need correct length and decimal positions—zero pad is implicit in packed representation, not spaces. Mismatch padding on output breaks next job in the chain.

Padding vs Trimming

Padding adds fill characters; trimming removes trailing spaces before compare or output. Many programs pad on output after trimming input—normalize once in JOB logic. See the trimming tutorial for scan loops that strip spaces; combine with padding when building delimited export where separators must not include trailing spaces.

Common Padding Mistakes

  1. EQ compare short literal to long space-padded file field.
  2. Using N type for ID and losing leading zeros on reports.
  3. Expecting MASK Z to change stored value for next IF test.
  4. Writing output records without space-filling fixed layout gaps.
  5. Assuming MOVE from numeric to A removes leading spaces automatically.

Explain It Like I'm Five

Padding is filling empty boxes with filler. Character boxes get space stickers when you do not fill them with letters. Number boxes get zero stickers when you start. When you pour a short word into a long box, spaces fill the empty spots at the end. Report masks can hide extra zero stickers on the printout even though the box still has them inside.

Exercises

  1. Define 10-byte A field and explain bytes after MOVE from 'HI'.
  2. Write MASK literals for leading zeros vs suppressed zeros on a 5-digit field.
  3. Explain why employee ID should often be A not N.
  4. State default init for P 5 2 working storage without VALUE.
  5. Describe difference between storage padding and MASK display padding.

Quiz

Test Your Knowledge

1. Working storage A fields initialize to:

  • Blanks (spaces)
  • Zeros
  • LOW-VALUES
  • Quotes

2. Working storage numeric fields initialize to:

  • Zeros
  • Spaces
  • HIGH-VALUES
  • Random

3. Assigning a 3-byte literal to a 10-byte A field:

  • Pads with spaces on the right
  • Truncates the field
  • Abends
  • Pads with zeros

4. MASK character Z in edit masks:

  • Suppresses leading zeros on display
  • Adds spaces
  • Converts to packed
  • Only for A fields

5. Trailing spaces in an A field:

  • Are part of the stored value and affect EQ comparisons
  • Always stripped on MOVE
  • Ignored always
  • Only in FILE fields
Published
Read time13 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 initialization, assignment, and MASK padding rulesSources: Broadcom Easytrieve Report Generator 11.6 TechDocs, Describe Files and Fields, MASK Parameter, Assignment StatementApplies to: Easytrieve space and zero padding on character and numeric fields