Easytrieve Not Equal Operator (<>)

Not equal asks the opposite of equality: are these two values different? The symbolic operator <>—angle brackets with a slash conceptually between them—appears in IF conditions when you want records that fail to match a code, amounts that changed since last cycle, or departments excluded from a corporate rollup. Keyword NE performs the same test and appears frequently in legacy manuals where symbolic punctuation was discouraged on 80-column cards. Exception processing lives on not equal: IF ERROR-FLAG <> 0 PRINT ERRORS-RPT surfaces only problem rows. Beginners underuse <> because positive filters—IF DEPT = 911—read more naturally, but exclusion logic—IF DEPT <> 999— often matches business questions better. This page covers syntax, NE equivalence, numeric and alphabetic inequality, combination with AND OR NOT, contrast with equal and THRU, duplicate-change detection, and testing strategies for production-grade filters.

Progress0 of 0 lessons

Basic Syntax

Not equal appears between operands in conditional expressions: IF STATUS <> T, IF GROSS <> 0, IF NEW-KEY <> OLD-KEY. True when values differ; false when they compare equal under type rules. Use in IF ELSE-IF DO WHILE and nested conditions. Does not modify operands.

text
1
2
3
4
5
6
7
8
JOB INPUT PAYROLL IF ERROR-CODE <> 0 PRINT EXCEPTION-RPT END-IF IF NEW-GROSS <> PRIOR-GROSS PRINT CHANGE-RPT END-IF

<> Versus NE

Not equal operator forms
FormExampleNotes
Symbolic <>IF FLAG <> YCompact; familiar from SQL-like syntax
Keyword NEIF FLAG NE YMatches EQ GE LE keyword family
NOT ... =IF NOT FLAG = YLogical negation of equality—mind precedence

IF STATUS NE X and IF STATUS <> X are equivalent in standard grammar. Choose one style per program section for maintainability. Code reviewers scanning for NE find all relational tests quickly when you avoid mixing six symbolic and six keyword forms randomly.

Numeric Not Equal

IF BALANCE <> 0 includes positive and negative non-zero balances—only exact zero fails the inequality. IF TAX <> FED-TAX flags rows where two tax fields diverge. Packed decimal compares by value: 10.00 <> 10.01 is true at P 2 scale. Watch implied decimal alignment when comparing P 2 to N 5—values that display the same may still compare unequal internally if conversion differs. Zero versus LOW-VALUES: uninitialized packed fields may not equal business zero—validate FILE data before trusting <> 0 as valid record test.

Alphabetic Not Equal

IF REGION <> 99 excludes region ninety-nine when REGION is N 2 or A 2 depending on definition. IF NAME <> PRIOR-NAME detects name changes between history and current file merge. Trailing spaces cause false inequality: ARNOLD-space versus ARNOLD-space on equal-length fields compares equal; ARNOLD-space versus ARNOLD literal may compare unequal if literal padding differs. Trim or normalize before <> when business rules ignore blanks.

Exclusion Filters Versus Inclusion

Inclusion: IF DEPT = 911 keeps one department. Exclusion: IF DEPT <> 999 keeps every department except 999. When valid codes are few, equality lists are shorter. When one bad code must drop, not equal is clearer than long OR chains of allowed equals. Multiple exclusions: IF CODE <> X AND CODE <> Y AND CODE <> Z—or refactor to positive allow-list with equality and OR when codes are enumerable.

Change Detection Pattern

Prior-cycle compare files drive reconciliation jobs. IF CURR-AMT <> PRIOR-AMT PRINT CHANGE-RPT highlights adjustments. Sort both files by key, read in parallel or merge pattern, compare field by field with <>. Pair with = for no-change skip: IF CURR-AMT = PRIOR-AMT skip detail PRINT when only exceptions matter—reduces spool volume.

text
1
2
3
4
5
6
7
8
9
JOB INPUT MASTER IF RECORD-STATUS <> 'A' PRINT INACTIVE-RPT END-IF IF ZIP-CODE <> PRIOR-ZIP MOVE ZIP-CODE TO PRIOR-ZIP PRINT ADDRESS-CHANGE-RPT END-IF

Combining With Logical Operators

IF STATUS <> X AND STATUS <> Y requires both inequalities—status differs from X and from Y. IF TYPE <> A OR TYPE <> B is almost always true for any TYPE value—a common logic bug; beginner meant AND or a single not-equal against a set. IF NOT DEPT = 911 equals IF DEPT <> 911 when NOT applies to the equality subexpression. Parentheses prevent surprises: IF (A <> B) AND (C <> D).

Not Equal Versus Greater or Less

Inequality <> only tests difference—not ordering. IF AGE <> 18 includes ages below and above eighteen. IF AGE GT 18 excludes minors only. Pick operator matching business rule wording. Auditors asking for everyone not exactly sixty-five need <> 65 or NOT = 65, not GT 65 alone.

Performance Considerations

Single <> compare per record is inexpensive. Long chains of AND <> on many literals cost more in maintenance than lookup table or range design. Consider E-Z Table or site validation patterns when excluding dozens of codes—architecture choice beyond operator mechanics but affects nightly batch CPU when IF trees grow deep.

Common Not Equal Mistakes

  • IF A <> B OR A <> C when AND was intended.
  • Expecting <> to test ordering magnitude.
  • Ignoring space padding on alphabetic compares.
  • Comparing uninitialized FILE numeric to zero without validation.
  • Mixing <> and NE without team convention.
  • Using <> for assignment—invalid context.

Explain It Like I'm Five

Not equal means not the same. If everyone wearing a red hat goes to circle A, not equal red sends everyone else—blue hats, green hats, no hats—to circle B. The <> sign is a way of saying these two things do not match. It is the opposite of asking are they the same? Spelling NE means the same thing as <>—like saying isn't instead of is not. Be careful when you say not red and not blue—you might accidentally include almost everyone unless you really mean both rules at once.

Exercises

  1. Write exception filter IF ERR <> 0 with PRINT.
  2. Rewrite IF NOT STATUS = X as IF STATUS <> X.
  3. Explain why IF A <> 1 OR A <> 2 is usually always true.
  4. Build change-detection IF NEW <> OLD for one amount field.
  5. Compare when to use DEPT = 911 versus DEPT <> 999 for business filtering.

Quiz

Test Your Knowledge

1. IF STATUS <> X means:

  • STATUS is not equal to X
  • STATUS assigns X
  • STATUS less than X
  • Concatenate STATUS and X

2. NE is:

  • Keyword synonym for not equal
  • Numeric exponent
  • New entry statement
  • Negative literal

3. IF DEPT <> 999 filters:

  • Records where department is not 999
  • Only department 999
  • All records unconditionally
  • Invalid syntax always

4. NOT STATUS = X compared to STATUS <> X:

  • Often equivalent inequality logic
  • Always compile error
  • NOT only works on numbers
  • X must be numeric

5. Alphabetic <> compares:

  • Character values including spaces
  • Only first byte
  • JCL parameters
  • Packed signs only
Published
Read time15 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 symbolic <> not equal in conditional expressionsSources: Broadcom Easytrieve 11.6 Language Reference relational operatorsApplies to: Easytrieve not equal operator (<>)