TSO-ISPF JCL COBOL VSAM DB2 CICS Tools Articles Job Portal Forum Quiz Interview Q&A

COBOL - Data Division

The Data Division of a COBOL source program describes, in a structured manner, all the data to be processed by the object program; also the relationship between physical and logical records.

The Data Division is optional in a COBOL source program.

The DATA DIVISION is where all of the data used by a program is defined. It is divided into five sections: the FILE, WORKING-STORAGE, LINKAGE, REPORT, and COMMUNICATION SECTIONs, although most programs only include the FILE and WORKING-STORAGE SECTIONs.

The Data Division must begin with the words DATA DIVISION, followed by a period and a space.

The Data Division is divided into four sections:
  1. File Section
    Describes externally stored data (including sort-merge files).

  2. Working-Storage Section
    Describes internal data.

  3. Local-Storage Section
    Describes internal data that is allocated on a per-invocation basis.

  4. Linkage Section
    Describes data made available by another program. It appears in the called program and describes data items that are provided by the calling program and are referred to by the called program. The called program can be a nested program
The purpose of each of the sections follows:

FILE SECTION: The FILE SECTION is used to define the files that will be used in the program.

There will be on file description (FD) for each file followed by a record description for each different record format associated with the file. For example:

   05 FIELD-NAME-01		PIC X(20).
   05 FIELD-NAME-02		PIC X(3).
   05 FIELD-NAME-03		PIC 99V99.

In the example, the file is named FILE-NAME. It is the same file name that was specified in the SELECT statement for the file. The 01 following the FD is called a record description entry.

Multiple 01 entries can be included if there is more than one applicable record format for the file.

See Data Items chapter for further information on the record description and its subordinate items.

WORKING-STORAGE SECTION: The WORKING-STORAGE SECTION is used to define any data that will be used in the program that is not part of a file. These may include, but are not limited to accumulators, lookup tables, print line formats, save fields, etc.

The structure of the items is as described in the Data Items section of this tutorial.

LINKAGE SECTION: The LINKAGE SECTION is used in a subprogram to define data that will be passed as arguments to the routine.

The structure of the items is as described in the Data Items section of this tutorial.

Each 01 level item in the LINKAGE SECTION should be included in the PROCEDURE DIVISION USING heading. For example:


Note : Comma(,) is optional

In this example, the subprogram would have 3 passed parameters called PARAMETER-1, PARAMETER-2, and PARAMETER-3. Each of them would be defined as an 01 level item in the LINKAGE SECTION. The order that the items are defined in the LINKAGE SECTION is unimportant.

REPORT SECTION: The REPORT SECTION can be used to produce standard control break driven reports. It is not commonly used.

COMMUNICATION SECTION: The COMMUNICATION SECTION is used for communicating between two programs running simultaneously on a computer which supports such operations. It is not commonly used.

If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!

Are you looking for Job Change? Job Portal