The plus sign is the addition operator in Easytrieve arithmetic. It sums two numeric values—gross pay plus bonus, year-to-date plus current amount, hours plus overtime hours— and produces a result you store in a working storage field, FILE output buffer, or nested inside a larger expression before multiply or compare. Addition looks simple but mainframe payroll depends on implied decimal alignment: adding two packed P 2 amounts keeps hundredths aligned internally; adding into a field too short overflows; adding FILE fields with corrupt packed signs abends the step. Beginners confuse + with string concatenation from other languages—Easytrieve uses + only for numeric sum in assignment expressions. This page teaches operand rules, packed and zoned behavior, accumulator patterns, chaining multiple adds, interaction with precedence, SUM report contrast, and defensive validation before adding untrusted extract amounts.
Addition appears in assignment: TARGET = operand1 + operand2. Operands may be field names, numeric literals up to 18 digits, or parenthesized subexpressions. TOTAL = GROSS + BONUS adds two fields. WS-HOLD = GROSS + 100 adds literal hundred to gross—literal scale must match business intent for implied decimals. CHAIN = A + B + C adds left to right after any tighter operators inside operands: RESULT = A + B * C multiplies B * C first, then adds A.
123TOTAL-PAY = GROSS + BONUS YTD-TAX = YTD-TAX + FED-TAX HOURS = REG-HRS + OT-HRS
| Operand type | Role in addition | Beginner notes |
|---|---|---|
| P packed decimal | Primary payroll currency | Implied decimals must align across operands and target |
| N zoned numeric | Display numeric sums | Converts with P per product rules |
| B binary | Integer-style sums | Counters and bit-related totals |
| Numeric literal | Fixed addend | 0.05 literal differs from 5—mind decimal intent |
| W or S field | Accumulator target | Size target for maximum expected sum |
DEFINE GROSS W 7 P 2 and BONUS W 7 P 2 both carry two decimal places. GROSS + BONUS computes sum at two implied decimals—1234.56 plus 10.00 yields 1244.56 when stored in W 7 P 2. Mixing P 2 with N 5 without decimals promotes per conversion rules—test with DISPLAY during development. Adding P 2 result into P 0 field truncates or rounds per assignment keywords—auditors notice penny drift. Standardize decimal positions across pay components before adding in production decks.
GRAND-TOT = GRAND-TOT + GROSS inside JOB INPUT loop accumulates program total. Library S field GRAND-TOT S 11 P 2 persists across records; W field without careful design may participate in report work file copy at PRINT—choose S for cross-record program totals referenced in reports. RESET on W accumulator restarts each JOB when coded. Addition assignment is O(1) per record—millions of adds run nightly in batch windows.
123456DEFINE GRAND-GROSS S 11 P 2 JOB INPUT PAYROLL GRAND-GROSS = GRAND-GROSS + GROSS PRINT PAY-RPT END-JOB
Plus in assignment executes during JOB procedural logic—you control when add happens. SUM on REPORT line accumulates field values during report formatting with control breaks— declarative totaling tied to PRINT. Use + for intermediate business calculations feeding PUT records. Use SUM when report writer should total GROSS by department on printed output. Both may appear in one program: NET = GROSS + BONUS in JOB; SUM GROSS on REPORT for department subtotals.
NET = GROSS - FED - STATE - FICA chains subtraction which is addition of negated values internally in some implementations—subtraction page covers sign. Explicit add chain: TOTAL = A + B + C + D evaluates left to right: ((A + B) + C) + D. GROUP = (REG + OT) + (BONUS + ADJ) uses parentheses to document pay components. See order of evaluation when mixing + with * or / in same expression.
IF REG-HRS + OT-HRS GT STD-HRS compares sum before relational test—addition binds before GT. IF A + B GT LIMIT + BUFFER mixes adds on both sides—each side evaluates before compare. Parentheses clarify: IF (A + B) GT (C + D). Numeric validation before add on FILE fields prevents abend: IF GROSS NUMERIC AND BONUS NUMERIC before TOTAL = GROSS + BONUS.
Target field must accommodate maximum sum range. Adding two W 7 P 2 fields may need W 8 P 2 target when carry exceeds seven digits. Cumulative GRAND-TOT S 11 P 2 sized for fiscal year program total. Overflow corrupts packed sign or truncates high digits—test with extreme production-like values. Intermediate WS-HOLD wider than final target captures sum before ROUNDED into display field.
Pure addition of same-scale currency often needs no ROUNDED on assignment. When add follows multiply in same expression RESULT = GROSS + BONUS * PCT, product may need rounding before add—split: HOLD = BONUS * PCT ROUNDED; TOTAL = GROSS + HOLD. ROUNDED on final TOTAL = A + B ROUNDED applies rounding to stored sum when target has fewer decimals than intermediate computation.
FILE GROSS from upstream extract may contain invalid packed data. IF GROSS NUMERIC before add to accumulator. FLDCHK in PARM DEBUG surfaces bad bytes during test. LOW-VALUES in numeric FILE field may pass some tests but fail addition—combine NUMERIC with reasonable range check IF GROSS GE 0 AND GROSS LT 9999999.99 when business rules allow.
COBOL and Easytrieve beginners from JavaScript sometimes try NAME = FIRST + LAST for names—invalid for alphabetic join with +. Use MOVE, overlay, or documented string operations for text. Plus is numeric only in arithmetic expression grammar.
The plus sign puts numbers together. Three marbles plus two marbles makes five marbles. Pennies matter when the piggy bank counts dollars and cents—both piles must count the same way. The plus sign does not glue words together; it only adds numbers. When many numbers join in one line, times and divide may go first unless parentheses say add this group first.
1. TOTAL = GROSS + BONUS uses + to:
2. Adding two P 2 packed fields aligns:
3. GRAND-TOT = GRAND-TOT + GROSS in a loop:
4. Plus binds compared to multiply in A + B * C:
5. Adding invalid packed FILE data may: