Easytrieve Zoned Decimal (Type N)

Zoned decimal—type N—stores numbers the way humans read them on green-bar reports: one digit per byte with zone bits in the high nybble. Digit zero is X'F0' in EBCDIC. COBOL PIC 9 fields without COMP usage map here. Zoned fields appear in older files, download extracts from systems that favor readable dumps, and working storage when developers want easy DISPLAY without hex decoding. Packed P is denser, but N remains essential when the file layout demands it. This page covers zoned byte layout, signed zones, decimal positions, comparison to P, and migration pitfalls across EBCDIC and ASCII.

Progress0 of 0 lessons

Zoned Storage Layout

Each byte contains one decimal digit 0-9 in the low nybble with zone bits in the high nybble. In EBCDIC, unsigned digit bytes often appear F0 through F9 for digits 0-9. Signed zoned uses zone patterns in the sign byte—often last byte of field—for negative values per IBM conventions. Implied decimal comes from decimal-positions on DEFINE, not a physical point in the byte string.

text
1
2
3
4
5
FILE COUNTS FB(80 800) REC-CNT 1 6 N 0 AMOUNT 7 9 N 2 DEFINE WS-YEAR W 4 N 0 VALUE 2026

Declaring Type N

Pattern: name, position, length, N, optional decimals. REC-CNT 1 6 N 0 is six-digit integer count at start of record. AMOUNT 7 9 N 2 is nine-byte zoned with two decimal places starting byte seven. N 0 means quantitative integer with zero decimal positions—still participates in SUM when specified.

N vs P comparison
AspectN (zoned)P (packed)
Digits per byte
Max length
Human DISPLAY
COBOL match
Space efficiency

EBCDIC vs ASCII Zoned

Mainframe production uses EBCDIC zone nybbles. Open-system ASCII files use different byte patterns—digit 0 is X'30'. Multiple Platform Considerations warn migration must translate alphanumeric without corrupting numeric zones. Testing ASCII zoned on PC then deploying EBCDIC file on z/OS produces wrong amounts in IF and SUM. CODE parameter on FILE documents encoding expectation.

Signed Zoned Numbers

Negative zoned values encode sign in zone of last digit byte—COBOL familiar patterns. DISPLAY may show minus editing via MASK on reports while storage remains zoned. Compare negative amounts in IF with numeric literals— -123.45 literal assigns to N field with matching decimals. Mixed sign handling between COBOL and Easytrieve rare when copybook aligned.

Arithmetic and SUM

Expressions add, subtract, multiply, divide N fields with conversion to internal arithmetic form. Receive field type determines result storage—assign N to P converts format. SUM on REPORT totals quantitative N fields at break levels. ROUNDED and TRUNCATED on assignment apply when receiving into N fields. Overflow when result exceeds digit capacity truncates or wraps—size fields for maximum business values.

When Files Use N

  • Legacy sequential extracts from DISPLAY numeric COBOL.
  • Downloaded flat files documented as zoned decimal.
  • Working storage counters where readability beats space.
  • Interface files from systems exporting ASCII zoned.
  • Report-only calculated fields before WRITE to zoned output.

Converting N and P

Assignment WS-P-AMT = WS-N-AMT converts zoned to packed in receive field type. Frequent conversion in million-row loops adds CPU—prefer single type through pipeline when possible. Format relationship tables in Literal and Data Formatting Rules document valid conversions at compile time. Invalid pairs error rather than silent corruption on mainframe.

MASK and Display

N fields receive default edit masks by length and decimals. Telephone masks '(999) 999-9999' apply to N fields storing ten digits. Z suppresses leading zeros on counts; 9 preserves them for IDs stored as N—prefer A for IDs with leading zeros. BWZ blanks zero amounts on printed detail lines.

Common Zoned Mistakes

  1. Declaring zoned file data as P—wrong digit pairing in hex.
  2. Using N for COMP-3 copybook field—amounts nonsense.
  3. Ignoring ASCII vs EBCDIC on migrated files.
  4. Wrong decimal positions—amounts off by factor of 100.
  5. Storing employee ID as N losing leading zeros conceptually on edit.

Explain It Like I'm Five

Zoned numbers put one digit sticker in each box so you can read them left to right like on paper. Packed numbers squish two digits in each box to save space. If the file comes with one-digit-per-box stickers, tell Easytrieve N. If stickers are squished pairs, use P. Wrong label and you read the wrong number from the boxes.

Exercises

  1. Define six-byte N 0 count and nine-byte N 2 amount fields.
  2. State EBCDIC hex for digit 0 in zoned form.
  3. Compare when you choose N vs P for a new payroll file.
  4. Write IF testing REC-CNT GT 1000 on N field.
  5. Explain ASCII migration risk for zoned fields.

Quiz

Test Your Knowledge

1. Zoned decimal in Easytrieve uses type:

  • N
  • P
  • Z
  • D

2. Digit 0 in EBCDIC zoned form is:

  • X'F0'
  • X'00'
  • X'30'
  • X'0F'

3. Maximum zoned field length is:

  • 18 bytes
  • 10 bytes
  • 254 bytes
  • 4 bytes

4. N versus P main difference:

  • N one digit per byte; P two digits per byte packed
  • N is ASCII only
  • P is text
  • No difference

5. Decimal positions on N fields:

  • 0 through 18
  • Not allowed
  • A only
  • Fixed at 2
Published
Read time13 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 type N zoned decimal rulesSources: Broadcom Easytrieve Report Generator 11.6 TechDocs, DEFINE Statement, Multiple Platform ConsiderationsApplies to: Easytrieve zoned decimal display numeric fields