Easytrieve ZERO, ZEROS, and ZEROES

ZERO is one of the most common reserved words in Easytrieve logic. In IF GROSS ZERO you ask whether the packed salary field holds a numeric zero—not whether the employee name is blank, not whether a byte contains X 00, and not whether your JCL completed with return code zero. Broadcom accepts three spellings—ZERO, ZEROS, ZEROES—with identical meaning in field class conditions. The same word family appears in MOVE ZERO TO WS-COUNT to clear counters before a loop and in IF PAYFILE:FILE-STATUS NOT ZERO after I/O. Beginners confuse ZERO with SPACE for empty names, with LOW-VALUES for binary init, and with default initialization on W fields that already start at zero without VALUE. This page explains type-aware zero testing, NOT ZERO filtering, MOVE clearing, FILE-STATUS success checks, and report MASK BWZ blank-when-zero display related to zero content.

Progress0 of 0 lessons

Field Class Condition Syntax

Field class conditions omit EQ and GT. Format is IF field-name ZERO or IF field-name NOT ZERO. Combine with AND OR like other conditions. ZERO tests the entire field for zero value in the correct representation for the defined type.

text
1
2
3
4
5
6
7
JOB INPUT PAYFILE IF GROSS NOT ZERO PRINT PAY-RPT END-IF IF DEDUCT ZERO DEDUCT = 0 END-IF

How ZERO Tests Each Data Type

ZERO test behavior by field type
TypeWhat ZERO meansCommon IF use
N zonedZoned zero with valid sign in low byteIF COUNT ZERO after increment reset
P packedPacked decimal zero e.g. X 0000C patternIF GROSS NOT ZERO before division
B binaryBinary zero fullword or halfwordIF WS-FLAGS ZERO before OR mask
A alphabeticRare—character zero digit not blankUsually use SPACE for empty A
FILE-STATUSSuccessful I/O status codeIF FILE:FILE-STATUS NOT ZERO

ZERO vs SPACE on Empty Fields

Unfilled alphabetic NAME after MOVE SPACES contains spaces—not numeric zero. IF NAME ZERO is false for all blanks. Use IF NAME SPACE to detect empty name. Numeric fields after MOVE ZERO or default W initialization test true on IF field ZERO. Mixing tests causes records to slip past validation—classic beginner bug on payroll edits.

text
1
2
3
4
5
6
IF NAME SPACE DISPLAY 'MISSING NAME' END-IF IF GROSS ZERO DISPLAY 'ZERO GROSS SKIPPED' END-IF

NOT ZERO Filtering

Production reports often exclude zero amounts: IF AMT NOT ZERO before PRINT. Commission jobs skip employees with zero sales. NOT ZERO is cleaner than IF AMT GT 0 when negative amounts are impossible by business rule. When negatives are allowed, use relational IF AMT NE 0 or GT 0 explicitly instead of NOT ZERO alone.

MOVE ZERO to Clear Fields

MOVE ZERO TO target assigns zero formatted for target type. Use before accumulation loops, when initializing output records field-by-field—Easytrieve has no COBOL INITIALIZE on group level—and when resetting counters inside PROC. Assignment WS-COUNT = 0 is equivalent stylistic choice for numeric fields.

text
1
2
3
4
5
6
7
8
9
PROC CLEAR-COUNTERS. MOVE ZERO TO WS-REC-COUNT MOVE ZERO TO WS-ERR-COUNT MOVE ZERO TO GRAND-TOT END-PROC JOB INPUT MASTER PERFORM CLEAR-COUNTERS WS-REC-COUNT = WS-REC-COUNT + 1

ZERO and FILE-STATUS

FILE-STATUS on each file is numeric. Zero typically means successful operation. After GET PUT READ WRITE check IF PAYMSTR:FILE-STATUS NOT ZERO before continuing. Display status for operations. STOP on hard errors. EOF handling is separate—use EOF file-name constant not ZERO alone for end detection.

text
1
2
3
4
5
GET PAYMSTR IF PAYMSTR:FILE-STATUS NOT ZERO DISPLAY 'GET FAILED' PAYMSTR:FILE-STATUS STOP END-IF

ZERO vs Default W Initialization

DEFINE WS-COUNT W 5 N without VALUE already starts at zero at allocation. MOVE ZERO and IF WS-COUNT ZERO redundant immediately after JOB start unless RESET fired. VALUE 0 documents intent. RESET returns to VALUE or default zero at each JOB. Do not re-clear unnecessarily inside tight READ loops unless logic requires mid-record reset.

ZERO vs Literal 0 in Relational Conditions

IF NET GT 0 uses relational operator with literal—requires quantitative field. IF NET ZERO uses class test—no operator. IF NET EQ 0 may differ subtly by release for some types—field class ZERO is idiomatic for whole-field zero test. Field relational NET GT GROSS uses two field names—not ZERO constant.

ZERO in Field Series and Complex IF

CA-Easytrieve Plus examples combine conditions: IF NET GT GROSS OR NET ZEROS uses field class ZEROS synonym. Parentheses and AND OR precedence follow standard rules—see order of evaluation page. Keep complex IF readable with PROC validation routines.

Report Display and Zero — MASK BWZ

MASK BWZ blanks numeric fields at print when all zeros—display convenience not IF ZERO. DEDUCTIONS line may show blank instead of 0.00 when no deduction. Field still tests ZERO in logic. Combine BWZ with MASK editing for currency reports.

ZERO vs HIGH-VALUES and LOW-VALUES

HIGH-VALUES tests X FF each byte—sort high keys. LOW-VALUES tests X 00 each byte—binary init. ZERO tests numeric zero per type—not every byte 00 on packed fields. Choose the test matching your intent—key init vs amount zero.

Common Mistakes

  1. IF NAME ZERO on space-filled alphabetic field.
  2. DEFINE field named ZERO—reserved word conflict.
  3. Assuming NOT ZERO excludes negative amounts.
  4. Skipping FILE-STATUS check when zero expected success.
  5. Confusing EOF with FILE-STATUS ZERO.
  6. MOVE ZERO to alphabetic field expecting blanks—use SPACES.

Explain It Like I'm Five

ZERO means the number bowl has no marbles left—for that kind of bowl. A name tag with only empty spaces is not ZERO—it is SPACE. When the teacher says MOVE ZERO, you empty the marble bowl. When the file robot says status ZERO, the last file trick worked with no problem.

Exercises

  1. Filter PRINT with IF GROSS NOT ZERO.
  2. Validate NAME with SPACE not ZERO for empty.
  3. Write error branch for FILE-STATUS NOT ZERO after GET.
  4. PROC that MOVE ZERO to three counters at job start.
  5. Explain packed GROSS ZERO vs HIGH-VALUES on same field.

Quiz

Test Your Knowledge

1. IF GROSS ZERO tests:

  • Whether GROSS holds zero in its defined numeric format
  • Whether field name is ZERO
  • Whether JCL RC is zero
  • Whether record length is zero

2. Alternate spellings accepted include:

  • ZERO, ZEROS, ZEROES
  • ZERO only
  • ZER0
  • NULL

3. MOVE ZERO TO WS-COUNT is used to:

  • Clear numeric working storage to zero
  • Delete the file
  • Skip READ
  • Set HIGH-VALUES

4. IF NAME ZERO on alphabetic name filled with spaces:

  • May be false—use SPACE test for all blanks on type A
  • Always true
  • Compile error
  • Same as NOT NUMERIC

5. IF PAYFILE:FILE-STATUS NOT ZERO means:

  • File I/O returned nonzero status—error or special condition
  • Field contains packed zero
  • End of file
  • Duplicate key only
Published
Read time13 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 field class ZERO ZEROS ZEROES MOVE FILE-STATUSSources: Broadcom Easytrieve 11.6 IF field class conditions, CA-Easytrieve Plus Application GuideApplies to: Easytrieve ZERO ZEROS ZEROES constants