codegurukool.com · Free coding tutorials & online compiler

Home › COBOL Tutorial › COBOL group items and records

COBOL group items and records

Build a record from smaller fields.

A group item has no PIC; it contains subordinate items with higher level numbers (05, 10...). Displaying or moving the group treats it as one piece of text made from its fields, joined in order. This is how COBOL describes records such as an employee or a customer.

Example code

       IDENTIFICATION DIVISION.
       PROGRAM-ID. GROUPS.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 EMPLOYEE.
          05 EMP-NAME   PIC X(10) VALUE "Ada".
          05 EMP-SALARY PIC 9(5)  VALUE 45000.
       PROCEDURE DIVISION.
           DISPLAY FUNCTION TRIM(EMP-NAME).
           DISPLAY EMP-SALARY.
           DISPLAY EMPLOYEE.
           STOP RUN.

Run this code in the online editor

← COBOL tables (arrays)COBOL intrinsic functions →