Easytrieve Formatting Functions

Formatting functions answer how should this number look on the report—not what is its mathematical value. Internal payroll files store GROSS as packed decimal with implied decimals; recipients expect 1,234.56 on paper, not hex nibbles. Easytrieve formatting builtins and EDIT-style masks translate storage form into display form: commas, dollar signs, leading zeros suppressed, negative amounts in parentheses or with minus sign, dates as MM/DD/YYYY instead of packed CCYYMMDD. Beginners often PRINT packed fields directly and wonder why columns misalign or show unreadable characters. Separate calculation fields from display fields: compute in P or N types, format into A fields, PRINT the A field. Broadcom Easytrieve Plus Application Reference indexes formatting functions separately from conversion functions because the task differs—pretty output versus type change. This index catalogs formatting families, typical picture characters, assignment keywords like ROUNDED that interact with display, report column alignment patterns, common overflow asterisks, and when procedural MOVE with manual literals beats a function call on sites with limited catalogs.

Progress0 of 0 lessons

Role of Formatting in Batch Programs

Batch Easytrieve jobs read files, compute totals, write reports. Numeric integrity lives in packed fields through arithmetic. Formatting is the last mile before human eyes or downstream systems expecting character layouts. TITLE lines show run dates formatted pleasantly. LINE statements list currency right-aligned via edited strings. DISPLAY during development shows readable diagnostics without attaching a hex dump tool. Skipping formatting produces technically correct numbers in wrong clothes—auditors reject reports even when totals reconcile.

EDIT and Picture Mask Patterns

The EDIT family—exact invocation spelling varies by release—applies a picture string to a numeric source. Picture characters mirror COBOL conventions: 9 for digit, Z for zero suppress, comma and period as punctuation, $ or currency symbol, S or CR for sign control. A mask Z,ZZZ,ZZ9.99- turns 1234567.8 into 1,234,567.80- when field width accommodates output. Masks must be wide enough; overflow often prints asterisks filling the field—a signal to widen OUT-AMT A 20 before blaming arithmetic.

text
1
2
3
4
5
* Illustrative pattern—verify EDIT syntax on your compiler GROSS-EDIT = EDIT(GROSS, 'ZZ,ZZZ,ZZ9.99') NET-EDIT = EDIT(NET, '$$$,$$$,$$9.99CR') LINE GROSS-EDIT NET-EDIT EMP-NAME

Representative Formatting Function Families

Formatting categories (names vary by release—check manual)
FamilyPurposeTypical use
Numeric EDITApply picture to packed/zoned amountReport currency columns
Date formatRender date field as text layoutTITLE run date, audit headers
Time formatRender time-of-day stringsBatch timestamp on SYSPRINT
Sign controlLeading minus, parentheses, CR/DRAccounting debit/credit display
Zero fill / suppressLeading zeros on codesCheck numbers, control IDs

Picture Character Reference for Beginners

Each picture character controls one aspect of output. Combining them builds the display template. Wrong character in one position shifts every column right on the report.

Common picture characters
CharacterMeaningEffect on output
9Digit positionAlways shows digit; leading zero may appear unless Z used
ZZero suppressSuppresses leading zeros in that position
,Thousands separatorInserts comma in fixed position of mask
.Decimal pointAligns implied decimal with display decimal
$Currency symbolPlaces dollar sign per mask template
-Sign trailingMinus sign after amount for negatives
CR / DRCredit/debitAccounting notation for signed amounts

Separate Compute Fields From Display Fields

Define GROSS P 2 for math. Define GROSS-DISP A 18 for EDIT output. After NET = GROSS - TAX, assign GROSS-DISP = EDIT(GROSS, mask). Never round-trip: editing NET into a display field then adding tax back in arithmetic without reconverting corrupts totals. Report LINE lists GROSS-DISP; internal SUM accumulators stay numeric. This pattern prevents the most common formatting bug—accidentally using edited strings in IF GROSS GT LIMIT comparisons where collating order replaces numeric order.

Formatting in REPORT Versus JOB Logic

JOB procedural logic prepares working display fields before PRINT selects records. REPORT LINE may reference those fields by name. Some releases allow edit specifications on LINE directly; others require pre-formatted Library fields. TITLE often concatenates literals with formatted date fields: TITLE 'PAYROLL AS OF ' RUN-DATE-EDIT. Keep TITLE within LINESIZE; long masks widen lines and wrap unexpectedly when LINESIZE is tight.

Implied Decimals and Mask Alignment

P 2 stores cents in the last two digit positions. Mask must include two 9 or Z positions after decimal point for cents to appear. P 0 amounts need no decimal portion in mask—or use .99 only when policy shows fractional dollars. Misaligned implied decimal produces 100x errors visible only on formatted output while packed math remains internally consistent—a dangerous split-brain state during debugging.

International and Legacy Variations

European sites may swap comma and period roles in masks. Legacy programs hard-code dollar sign when multi-currency was not required. When migrating, grep all EDIT masks and verify against business requirements document—not just compile success. EBCDIC display characters for currency differ from ASCII tools used in open-systems editors; test on z/OS spool or viewer matching production code page.

Performance Considerations

Formatting per record on million-row files adds CPU versus printing raw packed—but human reports require it. Hoist run-date formatting once before JOB loop. Avoid re-editing unchanged fields inside inner IF chains. Cache formatted department name when DEPT code maps to long text via table lookup plus format step. I/O still dominates runtime; clarity of separate DISP fields saves more maintainer time than micro-optimizing EDIT calls.

Alternatives When EDIT Builtin Unavailable

  • Manual division and MOVE of digit subfields—legacy but portable.
  • TABLE-driven picture selection for multiple report layouts.
  • CALL to COBOL or assembler edit routine when shop standard permits.
  • Post-process spool with DFSORT OUTREC overlay—outside Easytrieve but common ops pattern.

Common Formatting Mistakes

  • Mask too narrow—asterisk overflow on large amounts.
  • Using edited A field in numeric IF or ADD.
  • Implied decimal mismatch between source P field and mask.
  • Formatting inside loop when value unchanged since last format.
  • Assuming SQL CAST or COBOL INSPECT equivalents exist with same names.
  • Negative values with wrong sign picture—parentheses omitted on credits.

Explain It Like I'm Five

Formatting is dressing up numbers for a photo. The amount in the piggy bank is the real number. The label you stick on the jar—with dollar sign, commas, and two decimal places—is formatting so grown-ups can read it quickly. You do not pay for candy using the label; you use the coins inside. Easytrieve keeps coins in packed fields and makes labels in character fields before showing them on the report picture.

Exercises

  1. Define GROSS P 2 and GROSS-EDIT A 16; describe assignment order before PRINT.
  2. Explain why asterisks appear when amount exceeds mask width.
  3. Write a TITLE using a formatted date field name placeholder.
  4. Contrast formatting function with conversion function in one paragraph.
  5. List three picture characters and what each controls on output.

Quiz

Test Your Knowledge

1. Formatting functions primarily prepare values for:

  • Human-readable display and report columns
  • Packed arithmetic only
  • JCL allocation
  • Sort keys

2. EDIT-style formatting in Easytrieve resembles:

  • COBOL picture editing and mask strings
  • SQL JOIN syntax
  • CICS HANDLE CONDITION
  • Assembler DSECT

3. Formatting should occur when:

  • After calculations, before PRINT or DISPLAY
  • Before FILE definition
  • Only in JCL
  • At link-edit

4. Assigning formatted value back into packed arithmetic field without conversion:

  • May cause compile errors or wrong math
  • Always recommended
  • Required by PARM
  • Impossible

5. Formatting function availability:

  • Depends on product level—verify Application Reference
  • Identical on every mainframe
  • Replaced by HTML
  • Only in SCREEN section
Published
Read time16 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom EZT Plus Application Reference formatting and EDIT patterns; exact names per siteSources: Broadcom EZT Plus 6.3 Application Reference, Easytrieve Report Generator 11.6 ProgrammingApplies to: Easytrieve formatting and display edit functions