Easytrieve MOVE Statement

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.

Progress0 of 0 lessons

MOVE Statement Syntax

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.

text
1
2
3
4
5
6
PROC 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

MOVE Versus Assignment

When to use MOVE versus =
PatternMOVE formAssignment form
Field copyMOVE A TO BB = A
ArithmeticNot applicableC = A + B
Clear alpha recordMOVE SPACE TO RECREC = SPACE
Zero numericMOVE ZERO TO NN = 0

Language Constants With MOVE

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.

text
1
2
3
4
5
6
PROC 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

Record Buffer Clearing

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.

Field-to-Field MOVE

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.

Group and Structured MOVE

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 in Input Processing

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.

text
1
2
3
4
5
JOB INPUT CUSTOMER-FILE IF ZIP NE PRIOR-ZIP PRINT ADDRESS-CHANGE-RPT END-IF MOVE ZIP TO PRIOR-ZIP

MOVE With Conditional Logic

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.

Conversion and Runtime Errors

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.

Testing MOVE Logic

  1. Verify SPACE clear leaves expected blank columns on PUT output.
  2. Confirm field-to-field copy preserves value and padding.
  3. Test PRIOR-field hold pattern across record sequence.
  4. Compare MOVE versus = copy for identical numeric and alphabetic results.
  5. Validate group MOVE does not disturb unintended overlays.

Common MOVE Mistakes

  • Reversed TO direction—target must follow TO keyword.
  • Skipping SPACE clear causing garbage on output records.
  • Truncation from length mismatch without documentation.
  • Using MOVE when arithmetic assignment is required.
  • Group MOVE wiping overlay subfields unintentionally.
  • Mixing MOVE and = randomly within same program without style guide.

Explain It Like I'm Five

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.

Exercises

  1. Write PROC that MOVE SPACE TO OUT-REC then copies three input fields.
  2. Implement PRIOR-ZIP hold with MOVE after IF address change test.
  3. Initialize WS counters with MOVE ZERO TO each field.
  4. Explain when MOVE IN-REC TO SAVE-REC is safer than field-by-field copy.
  5. Contrast MOVE A TO B with B = A for alphabetic ten-byte fields.

Quiz

Test Your Knowledge

1. MOVE SPACE TO OUT-REC clears output by:

  • Filling alphabetic areas with blanks per rules
  • Deleting the file
  • Setting numeric HIGH-VALUES
  • JCL only

2. MOVE SOURCE-FIELD TO DEST-FIELD:

  • Copies source value into destination
  • Compares two fields
  • Sorts the file
  • Defines Library entry

3. MOVE ZERO TO COUNT versus COUNT = 0:

  • Both set numeric COUNT to zero in typical usage
  • MOVE invalid for numeric
  • Only = works
  • MOVE compares only

4. When to prefer MOVE over = assignment:

  • Simple field copy without expression
  • Always—MOVE required
  • Never—= only
  • JCL allocation

5. MOVE HIGH-VALUES TO FLAG sets:

  • All bits on in target field
  • Numeric zero
  • Blank alphabetic
  • Compile error always
Published
Read time15 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 MOVE statement and TO copy syntaxSources: Broadcom Easytrieve Report Generator 11.6 Language Reference MOVE statementApplies to: Easytrieve MOVE in JOB and PROC logic