Group Move Example


Scenario - Moving data from one group to another group.

Code -

----+----1----+----2----+----3----+----4----+----5----+
       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.