MOVE copies data from a source to a target without evaluating an arithmetic expression. MOVE EMP-NAME TO OUT-NAME transfers the employee name to an output buffer. MOVE SPACE TO OUT-REC clears an output record before selective fields populate it. MOVE ZERO TO TOTAL-AMT resets an accumulator. MOVE HIGH-VALUES TO EOF-FLAG sets a sentinel bit pattern. MOVE contrasts with assignment: GROSS = BASE + BONUS calculates; MOVE BASE TO SAVE-BASE copies. Mainframe shops standardize on MOVE for initialization PROCs and = for computed fields—consistency helps reviewers. Group moves copy structured record areas when Library defines matching layouts. Beginners assign with = when MOVE reads clearer for copy-only, or MOVE when expression math is required—wrong tool slows debugging. This page teaches MOVE syntax, TO keyword direction, constant sources, buffer clearing patterns, field-to-field transfer, contrast with assignment, overlay interaction, length and type conversion on move, and testing MOVE chains in Easytrieve batch jobs.
MOVE appears in JOB activities and PROC bodies. Form: MOVE source TO target. Source may be field, literal, or language constant. Target must be writable. Direction is always source TO target—reverse order is invalid. Multiple MOVE statements execute sequentially unless control flow intervenes.
123456PROC BUILD-OUTPUT MOVE SPACE TO OUT-REC MOVE IN-NAME TO OUT-NAME MOVE IN-DEPT TO OUT-DEPT MOVE IN-GROSS TO OUT-GROSS END-PROC
| Pattern | MOVE form | Assignment form |
|---|---|---|
| Field copy | MOVE A TO B | B = A |
| Arithmetic | Not applicable | C = A + B |
| Clear alpha record | MOVE SPACE TO REC | REC = SPACE |
| Zero numeric | MOVE ZERO TO N | N = 0 |
SPACE provides blank fill for alphabetic targets—standard output record slate. ZERO provides numeric zero. HIGH-VALUES sets all bits one—EOF and sentinel patterns aligned with COBOL interfaces. LOW-VALUES sets all bits zero—alternate clear pattern for binary areas. Choose constant matching downstream consumer expectations on shared files.
123456PROC INIT-WORK MOVE ZERO TO WS-COUNT MOVE ZERO TO WS-TOTAL MOVE SPACE TO WS-NAME MOVE HIGH-VALUES TO WS-EOF-FLAG END-PROC
Before PUT writes output, PROC often MOVE SPACE TO OUT-REC so unfilled columns do not carry garbage from prior iteration. Numeric totals within record may MOVE ZERO TO each counter field. Partial clear moves only affected sections when record layout mixes static headers with changing detail—document which bytes MOVE touches to avoid wiping keys.
MOVE IN-ZIP TO OUT-ZIP copies postal code. MOVE PRIOR-BAL TO WORK-BAL preserves value before update. Length mismatch truncates or pads per conversion rules—shorter source into longer target pads alphabetic with spaces; longer into shorter truncates rightmost or leftmost per type. Verify against file DCB and partner system specs.
When Library defines record-level names, MOVE IN-REC TO SAVE-REC may copy entire input snapshot for later compare. Overlay fields within record still share parent bytes—moving parent moves all subfields together. Understand parent-child layout before group MOVE in maintenance windows.
MOVE ZIP-CODE TO PRIOR-ZIP before update detects address changes on next record. MOVE KEY TO HOLD-KEY saves break key for control totals. HOLD fields are common W storage pattern paired with IF NE compare on next iteration.
12345JOB INPUT CUSTOMER-FILE IF ZIP NE PRIOR-ZIP PRINT ADDRESS-CHANGE-RPT END-IF MOVE ZIP TO PRIOR-ZIP
IF STATUS EQ ACTIVE MOVE RATE-A TO APPL-RATE ELSE MOVE RATE-B TO APPL-RATE selects rate tables. Nested IF assigns different MOVE targets. No single-line conditional MOVE—use IF branches explicitly for audit clarity.
Moving non-numeric alphabetic into numeric target without valid digits causes runtime issues. Moving incompatible lengths on packed fields may misalign decimals. Test MOVE chains with production-like data including edge cases—empty names, zero amounts, maximum lengths.
MOVE is copy from here to there. You have a sticker on one notebook and you MOVE it TO another notebook—the same sticker picture appears on the new page. MOVE SPACE is like erasing the page to blank before writing new words. MOVE does not add or multiply—it just carries what is already there to a new box. When you need to add numbers, use equals assignment instead.
1. MOVE SPACE TO OUT-REC clears output by:
2. MOVE SOURCE-FIELD TO DEST-FIELD:
3. MOVE ZERO TO COUNT versus COUNT = 0:
4. When to prefer MOVE over = assignment:
5. MOVE HIGH-VALUES TO FLAG sets: