Group MOVE Statement


Group MOVE is used to move the data from one group item to another group item. Group MOVE can have one or more receiving items.

Syntax -

MOVE sending-group TO receiving-group

Rules -

  • The sending item can be an alphanumeric or a literal or a figurative constant.
  • The receiving item should be an alphanumeric or elementary variable but not a literal or a figurative constant.
  • The elementary variables in both groups should have same name and in the same order, but the lengths may differ.

Practical Example -


Scenario - Moving data from one group to another group.

Code -

       IDENTIFICATION DIVISION.
       PROGRAM-ID. GRPMOVE.
       AUTHOR. MTH.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 WS-GRP1.
          05 NUM        PIC 9(02) VALUE 1.
          05 NAME       PIC X(20) VALUE 'MAINFRAMESTECHHELP'.
       01 WS-GRP2.
          05 NUM        PIC 9(02).
          05 NAME       PIC X(20).

       PROCEDURE DIVISION.
           MOVE WS-GRP1     TO WS-GRP2.
           DISPLAY "WS-GRP1: " WS-GRP1.
           DISPLAY "WS-GRP2: " WS-GRP2.
           STOP RUN.

Output -

WS-GRP1: 01MAINFRAMESTECHHELP 
WS-GRP2: 01MAINFRAMESTECHHELP 

Explaining Example -

In the above example:

  • WS-GRP1 declared as of length 22 and initialized with 01MAINFRAMESTECHHELP.
  • Similarly WS-GRP-2 is declared with same length 22.
  • WS-GRP2 has equal length with WS-GRP1, after executing the below group MOVE the WS-GRP1 data will be moved to WS-GRP2.