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.
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.
12345678JOB 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
| Condition A | Condition B | A OR B |
|---|---|---|
| True | True | True—IF branch runs |
| True | False | True—IF branch runs |
| False | True | True—IF branch runs |
| False | False | False—IF branch skipped |
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.
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.
12345678JOB 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
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.
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.
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.
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.
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.
1. IF DEPT EQ 10 OR DEPT EQ 20 selects:
2. IF BALANCE LT 0 OR BALANCE GT 10000 flags:
3. OR has _____ precedence than AND:
4. IF STATUS EQ HOLD OR STATUS EQ CLOSED OR STATUS EQ PEND:
5. IF A AND B OR C without parentheses is risky because: