Menu
CoddyTech

MOVE

Part of the First Programs section of Coddy's COBOL Programming journey. Lesson 8 of 19.

MOVE puts a value into a field. The field's old content is replaced:

MOVE "Lisbon" TO CITY.

It also copies one field into another. The sending field keeps its value:

MOVE CITY TO HOME-CITY.

Into a PIC X field, the text starts on the left and spaces fill the rest. Into a PIC 9 field, the number lines up on the right and zeros fill the left: MOVE 7 TO SCORE stores 007 in a PIC 9(3).

One MOVE can fill several fields: MOVE 0 TO A B C.

challenge icon

Challenge

Easy

Display CITY, then MOVE "Rome" into it and display it again.

Try it yourself

       IDENTIFICATION DIVISION.
       PROGRAM-ID. MOVES.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 CITY PIC X(10) VALUE "Paris".
       PROCEDURE DIVISION.
           *> Display, move, display
           STOP RUN.

All lessons in First Programs