Easytrieve Assignment Operator (=)

The equals sign in assignment context stores a value into a field. GROSS = BASE + BONUS calculates pay components and writes the result to GROSS. STATUS = ACTIVE sets a code literal. COUNT = COUNT + 1 increments a counter. The same symbol in IF STATUS = ACTIVE compares for equality—context tells assignment from comparison. Assignment accepts arithmetic expressions with + - * / ** and nested parentheses. ROUNDED and TRUNCATED follow the expression to control decimal behavior on numeric targets. Type conversion applies when source and target differ—packed to zoned, numeric to alphabetic via edit patterns. SPACE HIGH-VALUES LOW-VALUES and ZERO act as source constants. Beginners use = in IF thinking it assigns, or omit ROUNDED on currency fields and audit finds penny drift. This page teaches assignment syntax, contrast with EQ keyword in IF, expression evaluation order, modifiers, constant sources, field-to-field copy via assignment, increment patterns, and testing assignments in Easytrieve batch jobs.

Progress0 of 0 lessons

Assignment Statement Form

Assignment appears in JOB activities and PROC bodies as a standalone statement: target = expression. Target must be a writable field—W working storage, file output buffer, or report work field defined in Library. Expression may be literal, field reference, or full arithmetic. Multiple assignments execute in source order unless control flow redirects.

text
1
2
3
4
5
6
7
8
JOB INPUT PAYROLL GROSS = BASE + BONUS + OT-PAY TAX = GROSS * TAX-RATE ROUNDED NET = GROSS - TAX IF NET LT 0 NET = 0 END-IF

Assignment Versus Comparison

Same symbol, different roles
ContextExampleMeaning
Assignment statementAMT = 100Store 100 into AMT
IF conditionIF AMT = 100Test whether AMT equals 100
IF with EQ keywordIF AMT EQ 100Same comparison—keyword form
Assignment from fieldAMT = LIMITCopy LIMIT value into AMT

Arithmetic in Assignment

Expressions evaluate with standard precedence: ** before * and / before + and -. Use parentheses to override: DISCOUNT = (AMT * RATE) + FEE. Mixed-type arithmetic promotes per compiler rules—verify packed decimal scale on currency jobs. Division by zero causes runtime errors—guard with IF before assign when divisor can be zero.

ROUNDED and TRUNCATED

Append ROUNDED or TRUNCATED after the expression on numeric targets. TAX = GROSS * RATE ROUNDED for penny-aligned tax. AVG = TOTAL / COUNT TRUNCATED when policy drops fractional units. Omitting modifiers uses default truncation behavior for field type—document shop standard for financial fields. Inconsistent ROUNDED usage across related programs causes reconciliation gaps between subsystems.

text
1
2
3
COMM-PCT = SALES / QUOTA COMM-AMT = SALES * COMM-PCT ROUNDED ADJ-AMT = RAW-AMT TRUNCATED

Constants as Sources

ZERO assigns numeric zero. SPACE assigns blank fill to alphabetic targets. HIGH-VALUES and LOW-VALUES set all bits high or low for sentinel patterns—common in COBOL-aligned interfaces. Literal strings and numbers assign directly: CODE = 01 or REGION = EAST with appropriate quoting for alphabetic fields.

Type Conversion on Assignment

Assigning numeric result to alphabetic may require edit-compatible intermediate or use documented conversion functions elsewhere in program. Assigning alphabetic to numeric parses digits per rules—invalid data causes runtime issues. Short field to long field pads; long to short truncates with possible data loss—match Library lengths to file layouts.

Increment and Accumulator Patterns

COUNT = COUNT + 1 increments per processed record. TOTAL = TOTAL + AMT accumulates running sums—often paired with SUM in reports for verification. WS-IDX = WS-IDX + 1 drives manual loop counters. Functional update style reads current value, computes new, stores back in one statement.

Conditional Assignment

IF AMT GT LIMIT then AMT = LIMIT caps values. ELSE branches assign alternatives. Some shops use nested IF; others use single-line assign only when condition passes. No ternary operator—explicit IF blocks assign conditionally.

Assignment Versus MOVE

Simple field copy: DEST = SOURCE equals MOVE SOURCE TO DEST in many cases. Assignment shines when expression arithmetic is required. MOVE handles some group moves and bulk patterns documented separately. Choose assignment for calculations; consider MOVE for structured copy idioms your site standardizes.

Testing Assignment Logic

  1. Trace numeric assignments with known inputs and hand-calculated expected outputs.
  2. Verify ROUNDED versus TRUNCATED penny differences at .005 boundaries.
  3. Test alphabetic assignment length and padding behavior.
  4. Confirm increment COUNT = COUNT + 1 across loop iterations.
  5. Validate conditional assignment branches with boundary IF values.

Common Assignment Mistakes

  • Using = in IF expecting assignment—use assignment statement outside IF.
  • Missing ROUNDED on currency chains causing penny drift.
  • Division without zero guard.
  • Truncating into shorter field without awareness.
  • Assigning before Library field exists—compile errors.
  • Confusing = assignment with EQ in comparisons when reading listings.

Explain It Like I'm Five

Assignment equals put this answer in the box. If the box is labeled GROSS and you write GROSS = 500, the box now holds 500. If you write GROSS = BASE + BONUS, the computer adds two other boxes and puts the sum in GROSS. In an IF line, equals asks a question—is this box exactly this value?—instead of changing the box. Same sign, different job depending on whether you are storing or asking.

Exercises

  1. Write NET = GROSS - TAX with ROUNDED on tax calculation line.
  2. Explain difference between AMT = 100 and IF AMT = 100.
  3. Implement COUNT = COUNT + 1 in a record loop.
  4. Cap AMT with IF AMT GT LIMIT then AMT = LIMIT.
  5. Clear alphabetic NAME with NAME = SPACE.

Quiz

Test Your Knowledge

1. GROSS = BASE + BONUS in JOB logic:

  • Stores sum into GROSS
  • Tests if GROSS equals sum
  • Moves file record
  • JCL only

2. IF STATUS = ACTIVE uses = as:

  • Relational comparison in IF
  • Assignment to STATUS
  • MOVE synonym
  • Invalid syntax

3. COUNT = COUNT + 1:

  • Increments COUNT by one
  • Tests COUNT equals one
  • Clears COUNT
  • Library definition

4. ROUNDED after assignment expression:

  • Applies rounding per field definition
  • Rounds JCL allocation
  • Invalid on numeric
  • Only for reports

5. NAME = SPACE clears alphabetic field by:

  • Assigning blank fill per type rules
  • Deleting field
  • Setting HIGH-VALUES
  • Compile error
Published
Read time15 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 assignment statement and = store operatorSources: Broadcom Easytrieve Report Generator 11.6 Language Reference assignment statementsApplies to: Easytrieve = assignment in JOB and PROC logic