Easytrieve OR Operator

OR widens selection: the IF branch runs when any connected condition is true. IF DEPT EQ 10 OR DEPT EQ 20 includes both departments. IF STATUS EQ HOLD OR STATUS EQ CLOSED catches two exception states with one PRINT. IF BALANCE LT 0 OR BALANCE GT LIMIT flags outliers at both ends of the range. OR contrasts with AND which requires every test to pass. Policy language any of these departments maps to OR; all of these criteria maps to AND. Precedence places AND tighter than OR—parentheses prevent misread intent. NOT with OR demands careful grouping for exclusion lists. Beginners duplicate PRINT blocks for each department instead of one OR chain—maintenance drift follows. This page teaches OR syntax, truth tables, exception and allow-list patterns, chained OR for status codes, precedence with AND, alternatives with EQ THRU, nested IF comparison, and testing multi-branch OR logic in Easytrieve batch jobs.

Progress0 of 0 lessons

OR in Conditional Expressions

OR appears between boolean subexpressions in IF, ELSE-IF, DO WHILE, and WHILE constructs. IF ERROR-CODE EQ 100 OR ERROR-CODE EQ 200 OR ERROR-CODE EQ 300 routes three distinct errors to one handler. IF REGION EQ N OR REGION EQ S OR REGION EQ E selects three of four regions without four separate IF blocks.

text
1
2
3
4
5
6
7
8
JOB INPUT ACCOUNTS IF DEPT EQ 10 OR DEPT EQ 20 PRINT SPECIAL-DEPT-RPT END-IF IF BALANCE LT 0 OR BALANCE GT CREDIT-LIMIT PRINT EXCEPTION-RPT END-IF

OR Truth Table

Two-condition OR outcomes
Condition ACondition BA OR B
TrueTrueTrue—IF branch runs
TrueFalseTrue—IF branch runs
FalseTrueTrue—IF branch runs
FalseFalseFalse—IF branch skipped

OR Versus AND

AND narrows—every condition must pass. OR broadens—one success suffices. IF STATUS EQ ACTIVE AND REGION EQ EAST requires both. IF STATUS EQ ACTIVE OR STATUS EQ PENDING accepts either status. Choosing wrong operator doubles or halves record counts in production extracts. Re-read policy: and means AND; or means OR. Comma-separated lists in English specs often imply OR for inclusion sets.

Exception Lists With OR

Outlier detection uses OR across tails: IF AMT LT FLOOR OR AMT GT CEILING. Multi-code errors: IF RC EQ 4 OR RC EQ 8 OR RC EQ 12. Multi-department routing: IF DEPT EQ 100 OR DEPT EQ 200 OR DEPT EQ 300. When codes are contiguous, EQ THRU may shorten—IF CODE EQ 1 THRU 5 versus five OR clauses for 1, 3, 5, 7, 9 only.

text
1
2
3
4
5
6
7
8
JOB INPUT TRANSACTIONS IF TRAN-TYPE EQ 'CR' OR TRAN-TYPE EQ 'DB' OR TRAN-TYPE EQ 'AD' PRINT MONITORED-TYPE-RPT END-IF IF AMT LT 0 OR AMT GT 999999.99 PRINT AMT-OUTLIER-RPT END-IF

Precedence With AND

IF REGION EQ EAST OR REGION EQ WEST AND SALES GT 1000 may group as EAST alone or (WEST AND high sales) depending on precedence—parentheses required for IF (REGION EQ EAST OR REGION EQ WEST) AND SALES GT 1000. Code reviews flag mixed AND OR without parentheses. Write intent explicitly rather than debating language rules at midnight during cutover.

Chaining Multiple OR Conditions

Long OR chains list allow-list values. Beyond five or six alternatives, consider a table lookup, array scan, or PROC that sets WS-MATCH from validated reference file. OR chains remain readable for two to four discrete values common in department and status routing.

OR With NOT

Exclusion sometimes reads clearer with NOT and AND: IF NOT (STATUS EQ CLOSED OR STATUS EQ DELETED) for open records. De Morgan: NOT (A OR B) equals (NOT A) AND (NOT B). Rewriting complex exclusions avoids double-negative confusion in listings. IF NOT DEPT EQ 99 OR DEPT EQ 100 parses differently from IF NOT (DEPT EQ 99 OR DEPT EQ 100)—parentheses matter.

OR Versus Multiple IF Blocks

Three IF blocks with identical bodies duplicate maintenance. One IF with OR centralizes action. Separate IF blocks help when each branch performs different work—OR is wrong when outcomes differ. ELSE-IF chains handle prioritized mutually exclusive cases; OR handles shared outcome for independent triggers.

Testing OR Logic

  1. Test each OR branch true alone—IF must pass.
  2. Test all OR branches false—IF must fail.
  3. Test two branches true simultaneously—IF still passes once.
  4. Verify parentheses with mixed AND OR against expected counts.
  5. Compare totals to SQL IN list or OR WHERE clause.

Common OR Mistakes

  • Using OR when policy requires all criteria—should be AND.
  • Missing parentheses with mixed AND OR.
  • Duplicating PRINT bodies instead of one OR condition.
  • Using OR for contiguous ranges where EQ THRU is clearer.
  • Mis-scoping NOT with OR.
  • Overlong OR chains without lookup table alternative.

Explain It Like I'm Five

OR means any one rule can say yes. To pick a snack you can have fruit OR crackers OR cheese—one choice is enough. You do not need all three. AND would mean eating fruit and crackers and cheese together. OR is the easygoing operator—it runs the IF block when any connected test passes.

Exercises

  1. Write IF DEPT EQ 10 OR DEPT EQ 20 OR DEPT EQ 30 for three-department report.
  2. Rewrite tail outlier check with OR for low and high bounds.
  3. Add parentheses to clarify IF A AND B OR C for two business meanings.
  4. Compare OR list versus EQ THRU for codes 1 through 5 contiguous.
  5. Convert three duplicate IF PRINT blocks into one OR condition.

Quiz

Test Your Knowledge

1. IF DEPT EQ 10 OR DEPT EQ 20 selects:

  • Records in department 10 or 20
  • Records in both departments
  • Department 10 only
  • Compile error

2. IF BALANCE LT 0 OR BALANCE GT 10000 flags:

  • Outliers at both tails
  • Normal mid-range balances
  • Zero balances only
  • Inactive accounts

3. OR has _____ precedence than AND:

  • Lower (binds looser)
  • Higher
  • Same always
  • OR forbidden with AND

4. IF STATUS EQ HOLD OR STATUS EQ CLOSED OR STATUS EQ PEND:

  • Any of the three statuses
  • All three simultaneously
  • None—use AND
  • Invalid syntax

5. IF A AND B OR C without parentheses is risky because:

  • Precedence may not match business intent
  • OR never works with AND
  • Compile always fails
  • Only two conditions allowed
Published
Read time14 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 OR logical disjunction in conditional expressionsSources: Broadcom Easytrieve Report Generator 11.6 Language Reference logical operatorsApplies to: Easytrieve OR operator in IF and WHILE conditions