Easytrieve Equal Operator (=)

The equals sign wears two hats in Easytrieve. In a standalone assignment statement it stores a value—NET = GROSS - TAX. Inside an IF condition it asks a yes-or-no question: is this field equal to that value? That second role is the symbolic equal operator documented on this page. Broadcom Getting Started examples use IF DEPT = 911 to filter personnel records before PRINT. Beginners stumble when they use = for assignment inside IF or EQ for assignment on a plain statement line—the compiler error messages distinguish context, but understanding the dual role prevents hours of debugging. Equality comparisons drive payroll exception reports, status routing, duplicate detection, and control-break prerequisites. This page teaches symbolic = syntax, the EQ keyword synonym, numeric versus alphabetic equality rules, field-to-field tests, interaction with THRU ranges, common space-padding traps, and patterns that keep batch filters correct on production files.

Progress0 of 0 lessons

Symbolic = in Conditional Expressions

Equality testing uses = between two operands inside IF, ELSE-IF, DO WHILE, or nested conditions within procedural logic. IF STATUS = A branches when the STATUS field equals literal A. IF DEPT = 911 matches Broadcom filtered-report tutorial syntax. IF EMPNO = HOLD-EMP compares two fields for the same stored value. The operator does not modify either operand—it evaluates to true or false for the enclosing condition.

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

= Versus EQ: Two Spellings, Same Test

Broadcom Language Reference documents relational operators in both symbolic and keyword form. IF STATUS = Y and IF STATUS EQ Y express the same equality test in most installations. Keyword EQ removes ambiguity with assignment in code reviews—readers never confuse IF STATUS EQ Y with STATUS = Y on an assignment line because assignment never appears inside IF without the IF wrapper. Symbolic = feels natural to developers from SQL or algebra. Pick one spelling per project style guide; mixing both in one program works but hurts readability.

Equality operator forms
FormExampleWhen to use
Symbolic =IF DEPT = 911Matches math notation; requires IF context
Keyword EQIF DEPT EQ 911Unambiguous in manuals and code review
Assignment =FLAG = YNot comparison—stores into FLAG

Assignment = Is Not This Page's Operator

STATUS = A on its own statement line assigns literal A into STATUS. That is the assignment operator covered on the dedicated assignment page. IF STATUS = A never assigns—it only tests. A classic beginner bug codes IF STATUS = A expecting to set status, but the condition runs only when STATUS already equals A. To store, use STATUS = A as a procedural statement outside IF or in the THEN branch: IF VALID = Y; STATUS = A; END-IF patterns vary by release grammar—verify terminator rules for your compiler.

Numeric Equality

Packed P fields, zoned N fields, and binary B fields compare by numeric value, not by display editing. IF GROSS = 0 skips zero-pay records. IF TAX = FED-TAX detects matching tax components between two fields. Implied decimals participate: P 2 field storing 10.00 equals literal or field representing ten dollars and zero cents when scales align. Comparing P 2 to N 5 may convert per product rules—test with DISPLAY in development before trusting cross-type equality in production.

Signed values compare with sign nibble intact. IF BALANCE = -100 requires literal or field representing negative hundred in the type system your DEFINE uses. LOW-VALUES and HIGH-VALUES constants compare equal only to themselves and documented special cases—not to business zero unless your site initialization maps them that way.

Alphabetic Equality and Spaces

Fixed-length alphabetic fields pad with spaces to the right. EMPNAME defined A 8 holding ARNOLD occupies ARNOLD followed by one space. IF EMPNAME = ARNOLD may fail if the literal is shorter and comparison does not trim—literal ARNOLD in quotes may need length matching field padding conventions. Use documented TRIM, substring, or edited derived fields when business rules ignore trailing blanks. Case sensitivity depends on site and field definition—IF CODE = abc differs from IF CODE = ABC when collating treats case distinctly.

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 = 'A' PRINT ACTIVE-RPT END-IF

Field-to-Field Equality

IF SHIP-DEPT = HOME-DEPT routes transfers when department codes match. IF PRIOR-GROSS = GROSS detects unchanged pay amounts between cycles. IF KEY-A = KEY-B supports duplicate detection when both keys should differ. Operand types should be compatible—comparing A 10 to A 3 may compare only overlapping length or promote per grammar; verify in Language Reference for your release. Mismatched types between alphabetic and numeric without conversion yield compile errors or unexpected false results.

Equality With THRU Ranges

Equality combines with THRU for inclusive range membership: IF SERVICE EQ 6 THRU 10 is true for 6, 7, 8, 9, and 10. That is not a single = test but a related relational pattern beginners meet alongside equality. Single-value = tests one point; THRU tests interval. Use = for exact codes—department 911 only. Use THRU for banded categories— service years six through ten.

Equality in DO WHILE and Complex Conditions

DO WHILE EOF = N continues until end-of-file constant matches. IF A = B AND C = D requires both equalities true when AND binds conditions. Parentheses clarify: IF (A = B) OR (C = D). NOT wraps equality: IF NOT STATUS = X processes everyone except status X per NOT precedence rules on logical expressions page. Mixing = with GT or LT in one condition is valid: IF AGE = 65 OR AGE GT 65 simplifies to IF AGE GE 65 when you prefer one operator.

Equality in Report and Selection Contexts

Primary equality use is JOB procedural filtering before PRINT or PUT. Some report or edit contexts accept relational tests per release—confirm grammar before coding = in REPORT PROC conditions. Selection files often pre-filter in JOB: IF REC-TYPE = D PRINT DETAIL-RPT; IF REC-TYPE = S PRINT SUMMARY-RPT. Consistent single-character codes in A 1 fields make = tests fast and readable.

Performance and Sort Order

Equality test cost is negligible per record—one compare per IF. Millions of records with dozens of IF chains still spend most time in I/O. Equality does not require sorted input unlike CONTROL breaks. Duplicate detection IF KEY = PRIOR-KEY benefits from sorted input so PRIOR-KEY tracks previous record—logic pattern not operator requirement.

Testing Equality Logic

  1. Build a ten-record test file with known DEPT and STATUS values.
  2. Run with DISPLAY or audit PRINT to confirm only matching records appear.
  3. Test boundary literals—0, max field value, LOW-VALUES.
  4. Test alphabetic with and without trailing spaces.
  5. Verify assignment lines are not accidentally coded inside IF without intent.

Common Equal Operator Mistakes

  • Using = expecting assignment inside IF condition.
  • Ignoring trailing spaces on alphabetic FILE fields.
  • Comparing mixed decimal scales without conversion test.
  • Literal length mismatch on fixed character fields.
  • Mixing = and EQ randomly in one program without team convention.
  • Testing floating approximations with exact = instead of range test.

Explain It Like I'm Five

The equals sign in a question means same. Is your shirt color the same as the blue crayon? If yes, we put you in the blue team line. If no, you go somewhere else. That question is different from handing you a blue crayon—that is assignment, giving you the crayon to hold. Easytrieve uses the same squiggle for both jobs, but it knows whether you are asking a question inside IF or giving a field a new value on its own line. Spaces at the end of a name tag count—ARNOLD with an extra blank space is not exactly ARNOLD without it.

Exercises

  1. Write IF DEPT = 911 PRINT filter matching Broadcom sample.
  2. Rewrite two conditions using = instead of EQ and explain equivalence.
  3. Describe why IF NAME = BOB fails when NAME is A 10 holding BOB plus spaces.
  4. Write field-to-field equality IF NEW-STATUS = OLD-STATUS for change detection.
  5. Contrast assignment STATUS = A with IF STATUS = A in one paragraph.

Quiz

Test Your Knowledge

1. IF DEPT = 911 tests:

  • Whether DEPT equals 911
  • Assigns 911 into DEPT
  • Opens file 911
  • Concatenates strings

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

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

3. Comparing alphabetic field to literal requires attention to:

  • Trailing spaces and field length
  • JCL CLASS
  • STEPLIB order
  • Exponentiation

4. IF GROSS = LIMIT compares:

  • Two numeric values for equality
  • Two file DD names
  • Report titles
  • Sequence numbers

5. Using = in TARGET = EXPRESSION without IF is:

  • Assignment storing expression into TARGET
  • Equality test only
  • Compile error always
  • JCL directive
Published
Read time16 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 symbolic = equality in conditional expressionsSources: Broadcom Easytrieve Report Generator 11.6 Getting Started, Language Reference relational operatorsApplies to: Easytrieve equal operator (=) in comparisons