action.skip

Data Division

The DATA DIVISION contains the descriptions of all of the data items that are used in the program. The separate SECTIONs of the Data Division separate the data descriptions, according to functionality.

General Format:

       DATA DIVISION. 
       [ FILE SECTION. ] 
              [ file-descripiton ]… 
              [ fd-data-level fd-data-description ]  
              [ sort-description ]… 
              [ sd-data-level sd-data-description ]  
       [ WORKING-STORAGE SECTION. ]
              [ ws-data-level ws-data-description ]  
       [ LOCAL-STORAGE SECTION. ] 
              [ ls-data-level ls-data-description ]  
       [ LINKAGE SECTION. ] 
              [ lk-data-level lk-data-description ]  
       [ SCREEN SECTION. ] 
              [ ss-data-level screen-item-description]…

Syntax:

  1. file-description is descriptions of data items used in sequential, relative, and indexed files.
  2. fd-data-level is a number between 01 and 49 (inclusive), 66, 78, or 88.
  3. fd-data-description is descriptions of data items used in sequential, relative, and indexed, files.
  4. sort-description is descriptions of data items used in sort files.
  5. sd-data-level is a number between 01 and 49 (inclusive), 66, 78, or 88.
  6. sd-data-description is descriptions of data items used in sort files.
  7. ws-data-level is a number between 01 and 49 (inclusive), 66, 77, 78, or 88.
  8. ws-data-description is descriptions of data items used by the program internally.
  9. ls-data-level is a number between 01 and 49 (inclusive), 66, 77, 78, or 88.
  10. ls-data-description is descriptions of data items used by nested programs
  11. lk-data-level is a number between 01 and 49 (inclusive), 66, 77, 78, or 88.
  12. lk-data-description is is descriptions of data items that have been passed to a called subprogram.
  13. ss-data-level is a number between 01 and 49 (inclusive).
  14. ss-data-description is descriptions of Screen Section console screen items.

General Rules:

The General Rules for the Data Division Clauses are documented below.

Data Level Numbers

General Rules:

Data level numbers are numbers between 01 and 49 (inclusive), 66, 77, 78, or 88.

Level 01 thru 49

  1. The 01-level is the top level of a data description.
  2. Data items with data levels between 01 and 49 (inclusive) may be divided into data elements containing data level numbers greater than the data level of the parent data item, and less than or equal to 49 . Note that level 66, 78, and 88 data levels are permitted in a group data item, but they are each special cases, as described below.
  3. Level-77 data items may not be used in a group data item.

Example:

      01 customer-address. 
       05 customer-street-number   pic 9(7). 
       05 customer-street-name     pic x(30). 
       05 customer-apt-num         pic 9(3).
  1. The top data level of a record description in an FD must be an 01-level.
  2. It is possible for a file to have multiple record descriptions. This is indicated with multiple 01-level record descriptions.

Level 66

Level 66 is used with the RENAMES clause, and permits the programmer to rename a data element, or series of contiguous data elements immediately preceding the declaration of the level 66 data item.

Example:

       01 group-item. 
              05 customer-name     pic x(30) . 
              05 customer-address  pic x(30). 
       66 customer-info renames customer-name thru customer address.

Level 77

  1. Level 77 data items may not be used in record descriptions in the File Section.
  2. Level 77 data items may not be divided into data elements, nor may level 77 data items be used in a group item.
  3. Level 77 data items may have level 88 conditions associated with them.

Example:

  77 file-status  pic xx.

Level 78

Level 78 data items equate a data name with a numeric or alphanumeric constant. This can add readability to source code.

Example:

       78 one-thousand      value 1000. 
       78 largest-planet    value Jupiter.

This permits code such as:

  ADD one-thousand TO year-end-bonus.

  DISPLAY largest-planet LINE 10 COL 10.

Level 88

Level 88 data items describe condition names. This can add readability to source code.

General Format:

       77 file-status pic xx. 
              88 end-of-file value 10.

This allows for the replacement of code such as:

If file-status = “10”

with

If end-of-file