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.
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.
1234567JOB INPUT PAYFILE IF GROSS NOT ZERO PRINT PAY-RPT END-IF IF DEDUCT ZERO DEDUCT = 0 END-IF
| Type | What ZERO means | Common IF use |
|---|---|---|
| N zoned | Zoned zero with valid sign in low byte | IF COUNT ZERO after increment reset |
| P packed | Packed decimal zero e.g. X 0000C pattern | IF GROSS NOT ZERO before division |
| B binary | Binary zero fullword or halfword | IF WS-FLAGS ZERO before OR mask |
| A alphabetic | Rare—character zero digit not blank | Usually use SPACE for empty A |
| FILE-STATUS | Successful I/O status code | IF FILE:FILE-STATUS NOT ZERO |
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.
123456IF NAME SPACE DISPLAY 'MISSING NAME' END-IF IF GROSS ZERO DISPLAY 'ZERO GROSS SKIPPED' END-IF
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 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.
123456789PROC 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
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.
12345GET PAYMSTR IF PAYMSTR:FILE-STATUS NOT ZERO DISPLAY 'GET FAILED' PAYMSTR:FILE-STATUS STOP END-IF
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.
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.
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.
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.
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.
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.
1. IF GROSS ZERO tests:
2. Alternate spellings accepted include:
3. MOVE ZERO TO WS-COUNT is used to:
4. IF NAME ZERO on alphabetic name filled with spaces:
5. IF PAYFILE:FILE-STATUS NOT ZERO means: