Easytrieve Decimal Positions

In Easytrieve, decimal is not a separate data type like character or packed decimal. Instead, decimal precision is controlled by the decimal-positions parameter you code after the type letter on DEFINE and FILE lines. A salary stored as P 5 2 holds five bytes of packed data where the last two digit positions represent cents—12345 in storage might mean 123.45 dollars depending on editing and assignment rules. Getting decimal positions wrong is one of the most expensive beginner mistakes: amounts look plausible on reports but SUM totals are off by a factor of one hundred, or every field after a misaligned packed definition reads garbage. This page explains implied decimals, quantitative fields, valid ranges per type, assignment rounding, and how decimal positions connect to COBOL copybooks and report SUM behavior.

Progress0 of 0 lessons

Decimal Positions vs Data Type

Easytrieve numeric storage uses type letters N, P, B, U, and I. Decimal precision attaches to the first four of those—not to I, which must have zero or blank decimal positions. When documentation refers to a quantitative field, it means you specified decimal positions after the type code. Quantitative fields participate in signed arithmetic and automatic totaling on reports when referenced in SUM statements. Omitting decimal positions on a P field that holds currency tells the compiler to treat the value as unsigned non-quantitative, which changes sign handling and default editing.

Decimal position limits by numeric type
TypeNameMax decimal positionsExample declaration
NZoned decimal0–18AMT 10 9 N 2
PPacked decimal0–18GROSS 27 5 P 2
BBinary0–10RATE 40 4 B 4
UUnsigned packed0–18QTY 50 3 U 0
IInteger0 onlyCOUNT W 4 I
AAlphabeticNot validNAME 1 16 A

Syntax on DEFINE and FILE Lines

Pattern: field-name, location, length, type letter, optional decimal positions. The decimal count is an unsigned integer—it is not written with a decimal point in source. P 5 2 means five-byte packed with two places after the implied decimal point, not five point two as a literal. FILE and DEFINE share the same attribute pattern. Overlay fields inherit parent location; decimal positions on overlays must align with how you interpret the underlying bytes.

text
1
2
3
4
5
6
7
8
FILE PAYROLL FB(200 2000) EMPNO 1 6 N 0 GROSS 10 5 P 2 TAX-PCT 15 3 P 4 HOURS 18 3 P 1 DEFINE WS-NET W 5 P 2 DEFINE WS-FLAG W 2 B

GROSS uses two decimal places typical for dollars and cents. TAX-PCT with P 4 stores 0.0825 as a fractional rate—four decimal positions preserve precision for percentage calculations. HOURS with one decimal supports half-hour increments. WS-FLAG omits decimal positions entirely, making B non-quantitative for bit-style data rather than signed fractional binary.

Implied Decimal Arithmetic

Internal arithmetic respects implied decimal alignment. Adding GROSS and BONUS both P 2 produces a P result scaled consistently. Multiplying GROSS P 2 by a literal 0.15 applies decimal rules from assignment documentation—intermediate precision may exceed storage width before ROUNDED or TRUNCATED trims the receive field. Division especially exposes scale issues: dividing two P 2 fields and storing into P 2 without rounding may truncate fractional cents.

text
1
2
3
WS-TAX = GROSS * 0.15 WS-NET = GROSS - WS-TAX ROUNDED WS-RATE = (PART / TOTAL) * 100 TRUNCATED

ROUNDED adjusts the stored value to the receive field decimal count using product rounding rules. TRUNCATED discards excess fractional digits. INTEGER truncates toward zero for integer-style receive fields. These options apply only when the receive field is numeric—never on type A assignments.

Quantitative vs Non-Quantitative

Broadcom text conventions distinguish signed quantitative fields—those with decimal positions specified—from unsigned non-quantitative fields where decimal positions are omitted. Quantitative zoned and packed fields use sign nybbles or zone digits for negative values during assignment. Non-quantitative numeric fields treat storage as unsigned; assignment to the left side of an equation may force a positive sign. For currency you almost always want quantitative definitions with appropriate decimal count.

  • Quantitative P 5 2: signed salary, SUM on reports, negative amounts allowed.
  • Non-quantitative P 5: five bytes treated as unsigned packed magnitude—rare for money.
  • Quantitative B 4 0: four-byte signed binary integer with sign bit.
  • Non-quantitative B 2: sixteen bits of data without signed decimal semantics.

Decimal Positions and COBOL Copybooks

Mapping COBOL to Easytrieve decimal positions requires reading PIC clauses, not guessing from display width. PIC S9(5)V99 COMP-3 is five digits plus two fractional digits in packed form—five bytes P 2. PIC 9(7)V9(2) display is nine digits total with two after the implied decimal—often N 9 2 if stored zoned. COMP binary counts differ: PIC S9(9) COMP may be four-byte B 0 quantitative. Mis-counting V99 decimals shifts every subsequent FILE position when you transcribe copybooks manually.

COBOL PIC to Easytrieve decimal mapping examples
COBOLEasytrieveNotes
PIC S9(5)V99 COMP-35 P 2Five packed bytes, two implied decimals
PIC 9(9)V9911 N 2Eleven zoned digits if display storage
PIC S9(4)V9999 COMP2 B 4Binary rate field—verify COMP size
PIC 9(5)5 N 0Whole number—zero decimal positions

Reports, MASK, and Default Editing

Quantitative fields receive default system edit masks that insert commas and decimal points on LINE and TITLE output. A P 7 2 field with value representing 1000.00 may print with comma grouping per default mask tables. Override with MASK on DEFINE when you need credit indicators, floating dollar signs, or blank-when-zero BWZ. MASK affects display only—the stored packed value unchanged. Decimal count on the field drives how many nines appear in the mask literal relative to field width.

Literals and Decimal Precision

Numeric literals accept up to eighteen digits with optional sign and one decimal point in the literal itself—distinct from field decimal positions. Literal 1234.56 assigns into P 5 2 with conversion. Assigning a literal with more fractional digits than the target field supports triggers rounding or truncation per assignment options. Match literal scale to field scale when testing IF thresholds—IF AMT GT 999.99 on a P 5 2 field compares against the implied two-decimal amount.

Common Decimal Mistakes

  1. Coding P 5 without 2 when copybook has V99—amounts off by 100x on reports.
  2. Using decimal positions on type A date strings—compile error or wrong attribute.
  3. Mixing N display length with P packed length when transcribing positions.
  4. Expecting I fields to hold fractional cents—type I allows zero decimals only.
  5. MASK with too few nines for field length and decimal count—truncated print columns.

Explain It Like I'm Five

Imagine counting coins in a jar labeled dollars and cents. Decimal positions tell Easytrieve where the cents part starts without drawing a dot on every coin. If you say this jar holds numbers with two secret cents digits at the end, 12345 means 123 dollars and 45 cents. If you forget to say there are cents digits, the computer thinks you have twelve thousand three hundred forty-five dollars instead—and that is a very different allowance.

Exercises

  1. Declare GROSS as five-byte packed with two decimal positions at byte 10.
  2. Explain why P 5 and P 5 2 behave differently in SUM statements.
  3. Map COBOL PIC S9(7)V99 COMP-3 to Easytrieve length, type, and decimals.
  4. Write an assignment computing 7.5% tax with ROUNDED into a P 5 2 receive field.
  5. List which types allow decimal positions and the maximum for each.

Quiz

Test Your Knowledge

1. Decimal positions on a DEFINE line apply to which field types?

  • N, P, B, and U only
  • A and K only
  • All types including A
  • JCL DD names

2. A field defined as P 5 2 is quantitative because:

  • Two decimal positions are specified after the type letter
  • P always implies two decimals
  • Length five requires decimals
  • Quantitative applies only to type N

3. Maximum decimal positions on a packed P field is:

  • 18
  • 10
  • 4
  • 254

4. ROUNDED on assignment affects:

  • How fractional results are stored in the receive field
  • JCL COND parameters
  • Comment lines only
  • Alphabetic padding

5. COBOL PIC S9(5)V99 COMP-3 maps to Easytrieve as approximately:

  • 5 bytes P with 2 decimal positions
  • 7 bytes N with 0 decimals
  • 2 bytes I
  • 16 bytes A
Published
Read time14 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 DEFINE decimal-positions on N P B U fieldsSources: Broadcom Easytrieve Report Generator 11.6 DEFINE Statement, Describe Files and Fields, Text Conventions and Field RulesApplies to: Easytrieve implied decimal and quantitative field definitions