MODULE 2 · DATA AND PICTURE · 5/7

Group moves and FILLER

15 min30 XPExercise

A group item is, as far as MOVE is concerned, just a string of bytes. Moving to or from a group is always an alphanumeric move: bytes are copied left to right, padded with spaces or cut off on the right, and the fields inside are ignored. No numeric alignment, no conversion.

FILLER

FILLER names a piece of a record that you never need to refer to. It has a picture and often a VALUE, but no data name. You'll see it in two places:

  • input records, to skip bytes you don't use
  • print lines, for constant text, separators and spacing

Field by field versus group move

Here a date is copied into a display layout with / separators held in FILLER items:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. GROUPS.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  WS-DATE-IN.
           05  WS-IN-YYYY       PIC 9(4)  VALUE 2026.
           05  WS-IN-MM         PIC 9(2)  VALUE 9.
           05  WS-IN-DD         PIC 9(2)  VALUE 24.
       01  WS-DATE-OUT.
           05  WS-OUT-DD        PIC 9(2).
           05  FILLER           PIC X     VALUE "/".
           05  WS-OUT-MM        PIC 9(2).
           05  FILLER           PIC X     VALUE "/".
           05  WS-OUT-YYYY      PIC 9(4).
       PROCEDURE DIVISION.
           MOVE WS-IN-DD   TO WS-OUT-DD.
           MOVE WS-IN-MM   TO WS-OUT-MM.
           MOVE WS-IN-YYYY TO WS-OUT-YYYY.
           DISPLAY "FIELD BY FIELD: [" WS-DATE-OUT "]".
           MOVE WS-DATE-IN TO WS-DATE-OUT.
           DISPLAY "GROUP MOVE:     [" WS-DATE-OUT "]".
           STOP RUN.
FIELD BY FIELD: [24/09/2026]
GROUP MOVE:     [20260924  ]

The field-by-field moves put each part in the right place and leave the FILLER slashes alone. The group move blindly copied eight bytes over the ten-byte layout, slashes included, and padded with two spaces. Now WS-OUT-YYYY holds 24 followed by two spaces, which isn't a valid number.

Group moves are perfect when the two layouts are identical, for example copying an input record to a save area. When the layouts differ, move the fields one by one.

Building a print line

The most common use of FILLER is a report line. Declare the whole line as a group, with FILLER for the fixed text and named fields for the data, then move values into the named fields and display the group:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PRTLINE.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  WS-TOTAL-LINE.
           05  FILLER           PIC X(8)  VALUE "BRANCH: ".
           05  TL-BRANCH        PIC X(3).
           05  FILLER           PIC X(10) VALUE "  ORDERS: ".
           05  TL-ORDERS        PIC 9(4).
       PROCEDURE DIVISION.
           MOVE "D04" TO TL-BRANCH.
           MOVE 57    TO TL-ORDERS.
           DISPLAY WS-TOTAL-LINE.
           STOP RUN.
BRANCH: D04  ORDERS: 0057

Count your bytes: the PIC of each FILLER must match the length of its VALUE text exactly, or the text is truncated or padded.

Clearing a line

MOVE SPACES TO WS-TOTAL-LINE blanks every byte, including the FILLER text, and VALUE is never applied again. Clear the named fields individually instead. INITIALIZE is also safe: it resets the named fields and leaves FILLER alone.

On the job

Report programs are full of print-line groups: headings, detail lines and total lines, each built this way. When a column is misaligned in a report, count the bytes of each FILLER and field in the line.

Your task

Build one line of the employee listing report.

The program reads an employee ID, name and department into the group IN-EMP. Then:

  1. Add FILLER items with VALUE text to WS-DETAIL so that it prints like this (note the spaces around each |):

    EMP 00123 | SMITH, JOHN | DEPT D04

  2. MOVE the three input fields into DL-ID, DL-NAME and DL-DEPT.

  3. Copy the whole input record into WS-ARCHIVE with a single group move, so the second line shows the raw 23-byte record padded to 30:

    RAW: [00123SMITH, JOHN D04 ]

For the input 123, SMITH, JOHN, D04, the full output is the two lines above.

Check your understanding

1. WS-A is a group of PIC 9(4), 9(2), 9(2). WS-B is a group of PIC 9(2), X, 9(2), X, 9(4). What does MOVE WS-A TO WS-B do?
2. What is FILLER used for?
3. A print line contains FILLER items with VALUE text. What happens after MOVE SPACES to the whole line?
fixed format
Run your program to see its output here. The first visible test's input and datasets are used.
Submit to grade your program against every test.