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.
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.
12345FILE COUNTS FB(80 800) REC-CNT 1 6 N 0 AMOUNT 7 9 N 2 DEFINE WS-YEAR W 4 N 0 VALUE 2026
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.
| Aspect | N (zoned) | P (packed) |
|---|---|---|
| Digits per byte | ||
| Max length | ||
| Human DISPLAY | ||
| COBOL match | ||
| Space efficiency |
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.
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.
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.
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.
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.
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.
1. Zoned decimal in Easytrieve uses type:
2. Digit 0 in EBCDIC zoned form is:
3. Maximum zoned field length is:
4. N versus P main difference:
5. Decimal positions on N fields: