Easytrieve NE Operator

NE is the keyword spelling for not equal—the inverse of EQ in Broadcom relational operator tables. IF STATUS NE X keeps processing when status differs from X. IF ERROR-CODE NE 0 drives exception reports. IF NEW-AMT NE OLD-AMT extracts changed pay records between cycles. Legacy mainframe shops standardized NE alongside EQ LT GT GE LE because keywords survive noisy line printers and code walkthroughs without punctuation ambiguity. Symbolic <> expresses the same test; NE matches manual headings exactly. NE never assigns values—it only evaluates true or false inside conditions. Beginners overuse NE for long exclusion lists that become unreadable; sometimes EQ with THRU or positive inclusion filters maintain better. This page teaches NE syntax, equivalence with <>, numeric and alphabetic inequality, field-to-field change detection, logical combinations, contrast with NOT EQ, and audit-friendly exclusion patterns for batch Easytrieve jobs.

Progress0 of 0 lessons

NE in Conditional Expressions

NE appears between operands in IF, ELSE-IF, DO WHILE, and nested JOB conditions. IF DEPT NE 999 includes every department except nine-nine-nine. IF REC-STATUS NE D skips detail lines when building a summary-only extract. IF TAX NE 0 flags rows with tax withheld. The operator does not modify operands—it gates PRINT, PUT, assignment blocks, or procedure calls in the THEN path.

text
1
2
3
4
5
6
7
8
JOB INPUT PAYROLL IF ERROR-CODE NE 0 PRINT EXCEPTION-RPT END-IF IF REGION NE 99 PRINT REGION-DETAIL END-IF

NE Versus Symbolic <>

Not equal operator forms
FormExampleNotes
Keyword NEIF STATUS NE XBroadcom manual spelling
Symbolic <>IF STATUS <> XSame test—see Not equal page
NOT EQIF NOT STATUS EQ XLogically related—prefer NE for clarity
NE zeroIF AMT NE 0Common non-zero filter pattern

When NE Fits Business Rules

Exclusion rules often phrase as anything except: all regions except corporate rollup ninety-nine, all statuses except terminated T, all accounts except closed zero balance when zero means closed. NE maps directly. Change detection compares current to prior: IF CURR-KEY NE PRIOR-KEY after reading previous record in sorted duplicate logic. Error surfacing uses IF CODE NE 0 because zero conventionally means success. Positive inclusion with EQ sometimes reads clearer—IF STATUS EQ A OR STATUS EQ P for active and pending— when the allowed set is small. NE chains for many exclusions become hard to audit; ref actor to lookup flags in Library when exclusion lists grow.

Numeric NE

IF BALANCE NE 0 includes overdraft and credit—anything not exactly zero. IF RATE NE STANDARD-RATE flags pricing exceptions. Implied decimal scales apply as with EQ: P 2 compares monetary values, not display pictures. IF COUNT NE PRIOR-COUNT detects volume shifts between runs. Signed negatives compare with sign intact: IF ADJ NE -100 passes when adjustment differs from negative one hundred. NE with zero is among the most common production patterns because zero often encodes no error, no tax, or no activity.

Alphabetic NE

IF STATUS NE T keeps non-terminated employees. Trailing spaces matter: IF NAME NE SMITH compares full fixed field including pads—ARNOLD with trailing space NE SMITH literal may be true even when business names match visually. Quote literals to declared lengths for single-character codes. Case follows collating rules—IF CODE NE abc differs from IF CODE NE ABC when case is significant. Blank-padded fields compared to empty-looking literals trip beginners who expect trim semantics NE does not provide.

text
1
2
3
4
5
6
7
8
9
10
FILE EMPLOYEE FB(80 800) STATUS 72 1 A DEPT 73 3 N JOB INPUT EMPLOYEE IF STATUS NE 'T' IF DEPT NE 999 PRINT ACTIVE-EXCL-CORP END-IF END-IF

Field-to-Field NE

IF NEW-ADDR NE OLD-ADDR extracts address changes. IF CURR-GROSS NE PRIOR-GROSS drives pay-change notices. IF BATCH-ID NE PREV-BATCH detects file boundary in concatenated inputs. Types and lengths must align; comparing partial fields may require substring definitions in Library. NE between numeric and alphabetic without conversion is invalid or misleading—define working fields with explicit moves first.

NE With Logical Operators

IF STATUS NE X AND STATUS NE Y excludes two statuses—equivalent to neither X nor Y when both must fail for exclusion. IF REGION NE E OR REGION NE W is always true for any single region value—a common logic bug; use AND for excluding both coasts simultaneously or restructure with EQ inclusion lists. Parentheses clarify intent: IF (CODE NE A) AND (CODE NE B). Combine NE with LT GT for band gaps: IF SCORE NE 0 AND SCORE LT 60 for failing non-zero scores only—unusual but valid when zero means not tested.

NE Versus Positive EQ Filters

IF DEPT NE 911 includes all departments except nine-one-one. IF DEPT EQ 100 OR DEPT EQ 200 includes only two departments. Choose NE when exclusion set is small; choose EQ inclusion when allowed set is small. Auditors reading NE must infer everything else passes—document intent in comments when exclusion semantics affect compliance reports.

Performance and Input Order

NE cost per record is one compare—negligible versus I/O. No sort requirement for simple threshold NE tests. Duplicate detection IF KEY NE PRIOR-KEY often pairs with sorted input so PRIOR-KEY holds the previous row—pattern choice, not operator requirement.

Testing NE Logic

  1. Include records matching and not matching excluded value.
  2. Verify zero and non-zero ERROR-CODE rows route correctly.
  3. Test alphabetic NE with padded fields and quoted literals.
  4. Confirm field-to-field NE fires on single-byte differences.
  5. Review AND OR combinations for always-true bugs with OR NE chains.

Common NE Mistakes

  • Long OR chains of NE when EQ inclusion list is clearer.
  • IF REGION NE E OR REGION NE W always true—logic error.
  • Ignoring trailing spaces on alphabetic compares.
  • Using NOT STATUS EQ X without understanding precedence versus NE.
  • Expecting NE to trim or ignore case automatically.
  • Mixing NE and <> randomly without team convention.

Explain It Like I'm Five

NE means not the same. The teacher says everyone who is not wearing red shoes goes to the playground. Red-shoe kids stay inside. That is NE—you are checking who does not match one thing. It is the opposite of EQ, which asks who matches. If your name tag has extra spaces, NE might think you are different from a name without spaces even when it is still you.

Exercises

  1. Write IF ERROR-CODE NE 0 PRINT for an exception report.
  2. Rewrite two <> conditions using NE keyword form.
  3. Explain why IF REGION NE E OR REGION NE W is always true for one REGION value.
  4. Write IF NEW-GROSS NE OLD-GROSS change-detection IF.
  5. Decide when NE exclusion beats EQ inclusion for three allowed status codes.

Quiz

Test Your Knowledge

1. IF STATUS NE X means:

  • STATUS is not equal to X
  • STATUS assigns X
  • STATUS less than X
  • Numeric exponent

2. NE and <> in IF DEPT NE 999 versus IF DEPT <> 999:

  • Both express not equal in standard grammar
  • NE assigns and <> compares
  • Only NE valid
  • Only <> valid

3. IF ERROR-CODE NE 0 is typical for:

  • Exception reports listing non-zero errors
  • Zero-error-only output
  • File open
  • Sort control

4. NOT STATUS EQ X compared to STATUS NE X:

  • Often equivalent inequality when precedence is clear
  • Always compile error
  • NOT only on numbers
  • NE only in JCL

5. IF NEW-AMT NE OLD-AMT detects:

  • Changed amounts between cycles
  • Identical amounts only
  • Assignment
  • Division remainder
Published
Read time15 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 NE keyword not equal in conditional expressionsSources: Broadcom Easytrieve Report Generator 11.6 Language Reference relational operatorsApplies to: Easytrieve NE operator in comparisons