Data Division Format

General Format

[ DATA DIVISION. ]

[ FILE SECTION.
   [ file-desc { record-description } ... ] ... ]
   [ sort-desc { record-description } ... ]

[ WORKING-STORAGE SECTION.
   [ record-description ] ... ]

[ LINKAGE SECTION.
   [ record-description ] ... ]

[ SCREEN SECTION.
   [ screen-description ] ... ]

Syntax Rules

  1. The division header is optional for the Data Division.
  2. The FILE SECTION header is optional.

General Rules

The Data Division entries are described in:

  1. The File Section defines the structure of data files.
  2. A file-desc entry and its associated record-descriptions specify the format, layout, and sizes of a file's logical records. A sort-desc entry specifies the layout and sizes of a sort file's logical records.
  3. For each file described by a SELECT in the Environment Division, a corresponding file-desc or sort-desc must be made in the Data Division.
  4. The Working-Storage Section describes the records and independent data items which are not part of data files but are developed and processed by the program internally.
  5. Each record-description in Working Storage describes the format, layout, and size of an internal data item.
  6. Data items in Working Storage can be given initial values (see VALUE Clause). Items that are not explicitly initialized are set to spaces, or the value specified with the -Dv compile option, when the program is in its initial state. This may or may not be a valid value for the data item.
  7. The Linkage Section is used only in a called program. It defines the data available from the calling program. Both the called and calling program can use this data.
  8. To access data described in the Linkage Section, the called program may specify a USING phrase in its Procedure Division header. An alternative way to do this is through the SET ADDRESS OF statement. In the example below, note that the USING phrase has been omitted from the Procedure Division header.
    LINKAGE SECTION.
    01  my-var       pic x(30).
    
    PROCEDURE DIVISION.
    main-logic.
        if switch-1
           set address of my-var to msg-1
        else
           set address of my-var to msg-2
        end-if.
        display my-var.

    See Procedure Division Statements for additional information on the SET Statement.

  9. The Screen Section describes the format, layout, and behavior of console screen items. These screen items are used with the ACCEPT and DISPLAY verbs to perform single- and multi-field console I/O.