Data division is used to define the variables used in the program including their names, lengths, storage formats. It consists of four sections −
- File section is used to define the record structure of the file i.e. the data sent to and comes from computer peripherals .
- Working-Storage section is used to declare temporary variables and file structures which are used in the program like for the purpose of calculation and internal manipulation of data. They are the variable name belongs to the structure of the file.
- Linkage section is used to describe the data names that are received from an external program.
- Report Section used in report writer based programs.
01 CUST-NAME PIC A (25).
01 WS-CUSTOMER PIC A (30).
01 WS-CUST-ID PIC 9(5).
01 LS-CUST-ID PIC 9(5).
DISPLAY “I am a Data Division”.
FD is the file description level indicator which describe the file structure.
SD is the sort file description level indicator that describe about sort files.
Working storage section:
It defines the variables that are used for data manipulation inside the programs like for calculation purpose.
It is used in subprograms where we need to send or receive the data between the main program (calling program) and subprogram (called program).subprogram uses the working storage section of the main program to access the data.
01 WS-A PIC 9(2).
01 WS-B PIC 9(2).
01 WS-C PIC 9(2).
01 CALLED-PGM PIC X(6) VALUE “SUBPGM”.
CALL CALLED-PGM USING WS-A,WS-B,WS-C.
01 WS-A1 PIC 9(2).
01 WS-B1 PIC 9(2).
01 WS-C1 PIC 9(2).
PROCEDURE DIVISION USING WS-A1, WS-B1, WS-C1.