Easytrieve EQ Operator

EQ is Broadcom's keyword spelling for equality in relational expressions. When you write IF DEPT EQ 911, you ask whether the department field holds exactly nine-one-one—not whether you want to store that value. Legacy Easytrieve programs and IBM-era manuals used keyword operators before symbolic punctuation became common on 80-column listings. Modern shops still standardize on EQ NE LT GT GE LE because keywords read clearly in printed source, survive OCR and mainframe terminal fonts better than angle brackets, and never collide with assignment equals on a quick scan. EQ does not replace assignment: FLAG = Y on its own line stores into FLAG; IF FLAG EQ Y only tests. This page teaches EQ syntax, equivalence with symbolic =, numeric and alphabetic equality rules, field-to-field tests, THRU range membership, logical combinations, and production filtering patterns that keep payroll and exception batch jobs correct on first run.

Progress0 of 0 lessons

EQ in Conditional Expressions

EQ appears between two operands inside IF, ELSE-IF, DO WHILE, and nested conditions in JOB procedural logic. The operator evaluates to true or false; it never modifies either operand. IF STATUS EQ A branches when STATUS matches literal A. IF EMPNO EQ HOLD-EMP compares two fields. IF REC-TYPE EQ D routes detail records to one report while IF REC-TYPE EQ S routes summary lines elsewhere. Broadcom Getting Started filtered-report samples often show IF DEPT EQ 911 before PRINT—keyword form matches Language Reference headings exactly, which helps beginners cross-reference documentation.

text
1
2
3
4
5
6
7
8
JOB INPUT PERSNL IF DEPT EQ 911 PRINT PAY-RPT END-IF IF STATUS EQ 'A' AND GROSS EQ 0 PRINT EXCEPTION-RPT END-IF

EQ Versus Symbolic =

Functionally, IF DEPT EQ 911 and IF DEPT = 911 express the same equality test in standard Easytrieve grammar. The difference is presentation and team convention, not runtime semantics. Keyword EQ belongs to a consistent operator family documented as EQ, NE, LT, GT, GE, and LE. Symbolic forms =, <>, <, >, >=, and <= mirror algebra and SQL. Mixed programs compile but confuse maintainers—pick one style per application or per shop standard.

EQ and related equality forms
FormExampleRole
Keyword EQIF DEPT EQ 911
Symbolic =IF DEPT = 911
Assignment =DEPT = 911
EQ with THRUIF CODE EQ 1 THRU 5

Why Keyword EQ Matters on Mainframe Teams

Mainframe code reviews happen on paper, in email diffs, and in ISPF panels where punctuation can blur. EQ reads as a word; = can mean compare or assign depending on line context. New hires searching Broadcom PDFs find EQ in operator tables immediately. Audit teams mapping business rules to code match policy language is equal to with EQ literally. None of this means symbolic = is wrong—many tutorials use it—but EQ remains the canonical keyword in vendor documentation and certification study guides.

Numeric EQ Comparisons

Packed decimal P fields, zoned N fields, and binary B fields compare by numeric value. IF GROSS EQ 0 skips zero-pay lines. IF TAX EQ FED-TAX detects matching components between two fields. Implied decimals participate: a P 2 field holding ten dollars compares equal to another field or literal at the same scale. Cross-type comparisons—P 2 against N 5—may convert per product rules; verify with DISPLAY or audit output in development before production. Signed values retain sign: IF BALANCE EQ -100 requires operands representing negative one hundred in the types your DEFINE statements declare.

Floating or edited display fields rarely use exact EQ for derived amounts—penny drift from rounding can make IF NET EQ EXPECTED fail when business intent allows a cent tolerance. In those cases combine NE with range tests or compare rounded working fields defined in Library. EQ shines for discrete codes: department numbers, record types, status flags, and integer counts.

Alphabetic EQ and Trailing Spaces

Fixed-length alphabetic fields pad with spaces. EMPNAME defined A 8 holding ARNOLD occupies seven characters plus one trailing space. IF EMPNAME EQ ARNOLD may fail when the literal length or padding does not match the stored field—spaces are significant characters in collating sequence. Quote literals to match business length: IF STATUS EQ 'A' for a one-byte active flag. When rules ignore trailing blanks, use TRIM, substring, or derived edited fields documented for your release rather than assuming EQ trims automatically. Case sensitivity follows site collating rules—IF CODE EQ abc differs from IF CODE EQ ABC when uppercase and lowercase sort as distinct values.

text
1
2
3
4
5
6
7
8
FILE PERSNL FB(150 1800) EMPNAME 17 8 A STATUS 99 1 A JOB INPUT PERSNL IF STATUS EQ 'A' PRINT ACTIVE-RPT END-IF

Field-to-Field EQ

IF SHIP-DEPT EQ HOME-DEPT identifies same-department routing. IF PRIOR-GROSS EQ GROSS detects unchanged pay between cycles—useful for change-only extracts. IF KEY-A EQ KEY-B supports duplicate detection when keys should differ. Operand lengths and types should align; comparing A 10 to A 3 may compare only overlapping positions per grammar—check Language Reference for your compiler. Mixing alphabetic and numeric without explicit conversion yields errors or silent false results.

EQ With THRU Ranges

Single-value EQ tests one point. IF SERVICE EQ 6 THRU 10 is true for six, seven, eight, nine, and ten inclusive—a banded category common in benefits and seniority rules. Contrast with IF SERVICE EQ 10 alone, which matches only exactly ten years. THRU upper bounds combine with EQ for closed intervals; open-ended floors often use GE instead. Document which bands your program implements so auditors map policy tables to code without misreading a single EQ as a range.

EQ in Logical Expressions

IF A EQ B AND C EQ D requires both equalities. IF REGION EQ E OR REGION EQ W splits processing by coast. NOT STATUS EQ X processes everyone except status X when NOT precedence is clear—see logical expressions for binding rules. Mixing EQ with LT or GT in one condition is valid: IF AGE EQ 65 OR AGE GT 65 simplifies to IF AGE GE 65 when you prefer one operator for at least sixty-five semantics.

EQ in Report and Selection Contexts

Primary use is JOB filtering before PRINT or PUT. IF REC-TYPE EQ D PRINT DETAIL-RPT; IF REC-TYPE EQ S PRINT SUMMARY-RPT. Some REPORT PROC or edit contexts accept relational tests per release—confirm before coding EQ outside JOB logic. Selection efficiency does not require sorted input for simple EQ filters; duplicate detection comparing EQ to a prior key benefits from sorted files as a logic pattern, not an operator requirement.

Testing EQ Logic

  1. Build a small file with known DEPT, STATUS, and GROSS values.
  2. Run with audit PRINT or DISPLAY to confirm only matching records appear.
  3. Test boundary literals—zero, maximum field value, LOW-VALUES.
  4. Test alphabetic fields with and without trailing spaces.
  5. Verify no assignment lines accidentally use EQ instead of =.

Common EQ Mistakes

  • Using EQ on a standalone line expecting assignment—use = instead.
  • Ignoring trailing spaces on fixed alphabetic FILE fields.
  • Comparing amounts at different implied decimal scales without conversion test.
  • Mixing EQ and = randomly in one program without team convention.
  • Testing rounded amounts with exact EQ when policy allows tolerance.
  • Assuming EQ THRU and single EQ mean the same thing.

Explain It Like I'm Five

EQ means same. The teacher asks: is your lunch box color the same as the blue sticker? If yes, you go to the blue table. That question is EQ—it does not change your lunch box. Handing you a blue sticker to put on your box is assignment—that uses equals on its own line, not EQ inside a question. If your name tag says BOB with extra blank space at the end, it is not exactly the same as BOB without those spaces, so EQ might say no even though you know it is you.

Exercises

  1. Write IF DEPT EQ 911 PRINT filter using keyword form only.
  2. Rewrite two conditions from symbolic = to EQ and explain equivalence.
  3. Describe why IF NAME EQ BOB fails when NAME is A 10 holding BOB plus spaces.
  4. Write IF NEW-STATUS EQ OLD-STATUS for change detection with no update.
  5. Contrast DEPT = 911 assignment with IF DEPT EQ 911 in one paragraph.

Quiz

Test Your Knowledge

1. IF DEPT EQ 911 tests:

  • Whether DEPT equals 911
  • Assigns 911 into DEPT
  • Sorts by department
  • Opens file 911

2. EQ and symbolic = in IF STATUS EQ Y versus IF STATUS = Y:

  • Both test equality in comparison context
  • EQ assigns and = compares
  • Only EQ is valid
  • Only = is valid

3. Why do shops prefer EQ over = in code reviews?

  • EQ cannot be confused with assignment on a plain statement line
  • EQ runs faster
  • EQ works only on numbers
  • = is deprecated

4. IF GROSS EQ LIMIT compares:

  • Two values for equality
  • Two DD names
  • Report line numbers
  • Exponentiation

5. IF SERVICE EQ 6 THRU 10 is:

  • Inclusive range membership using EQ with THRU
  • Assignment of ten to SERVICE
  • Invalid syntax always
  • JCL CLASS test
Published
Read time16 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 EQ keyword equality in conditional expressionsSources: Broadcom Easytrieve Report Generator 11.6 Language Reference relational operatorsApplies to: Easytrieve EQ operator in comparisons