Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

data division

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hello, can someone please help me with the data division. I have to give an explination on exactly what the data division does in this program: Thanks for all the help!


IDENTIFICATION DIVISION.
************************

PROGRAM-ID. CH3EX-2.
AUTHOR.
INSTALLATION.
DATE-WRITTEN. NOV. 28, 2001.
DATE-COMPILED.
******************************************************************
* PROGRAM NARRATIVE *
* *
* *
* THIS PROGRAM READS ALL RECORDS IN THE CUSTOMER FILE FOR THE *
* ABC DEPARTMENT STORE AND DISPLAYS A DETAIL LINE CONTAINING *
* AN ACCOUNT NUMBER, CUSTOMER NAME, BALANCE, PURCHASES, AND *
* CREDIT LIMIT. A RECORD COUNT IS PROVIDED AT THE END OF THE *
* REPORT. *
* *
* INPUT: CUSTOMER.DAT - CUSTOMER INPUT FILE *
* *
* OUTPUT: SCREEN - CUSTOMER PURCHASES REPORT *
* *
******************************************************************

ENVIRONMENT DIVISION.
**********************

INPUT-OUTPUT SECTION.
**********************

FILE-CONTROL.

SELECT CUSTOMER-FILE
ASSIGN TO "A:\CUSTOMER.DAT".

/
DATA DIVISION.
***************

FILE SECTION.
**************

******************************************************************
* *
* INPUT-FILE - CUSTOMER FILE *
* *
******************************************************************

FD CUSTOMER-FILE.

01 CUSTOMER-RECORD.
02 PIC X(8).
02 CR-ACCOUNT-NUMBER PIC X(6).
02 CR-CUSTOMER-NAME PIC X(20).
02 PIC X(21).
02 CR-BALANCE PIC S9(4)V99.
02 CR-PURCHASES PIC 9(4)V99.
02 CR-CREDIT-LIMIT PIC 9(5).
02 PIC XX.
/
WORKING-STORAGE SECTION.
************************

******************************************************************
* *
* Switches *
* *
******************************************************************

01 SWITCHES.

02 SW-END-OF-FILE PIC X.
88 END-OF-FILE VALUE "Y".

******************************************************************
* *
* Accumulators *
* *
******************************************************************

01 ACCUMULATORS.

02 AC-LINE-COUNT PIC 999.
02 AC-PAGE-COUNT PIC 999.
02 AC-RECORD-COUNT PIC 9(5).
/
******************************************************************
* *
* Work Area Fields *
* *
******************************************************************

01 WORK-AREA.

02 WA-TODAYS-DATE-TIME.
03 WA-TODAYS-DATE.
04 WA-TODAYS-YEAR PIC 9(4).
04 WA-TODAYS-MONTH PIC 99.
04 WA-TODAYS-DAY PIC 99.
03 WA-TODAYS-TIME.
04 WA-TODAYS-HOUR PIC 99.
04 WA-TODAYS-MINUTES PIC 99.
03 PIC X(9).

02 WA-DATE.
03 WA-MONTH PIC 99.
03 WA-DAY PIC 99.
03 WA-YEAR PIC 9(4).

02 WA-RUN-DATE REDEFINES
WA-DATE PIC 9(8).

02 WA-SCREEN-HOLD PIC X.
02 WA-HYPHENS PIC X(20) VALUE ALL "-". /
/
SCREEN SECTION.
***************

******************************************************************
* *
* Report Headings for the Customer Purchases Report *
* *
******************************************************************

01 HEADING-LINES.
02 BLANK SCREEN.
02 LINE 1 COLUMN 1 VALUE "DATE".
02 COLUMN 6 PIC Z9/99/9999 FROM WA-RUN-DATE.
02 COLUMN 22 VALUE "ABC DEPARTMENT STORE".
02 COLUMN 57 VALUE "PAGE ".
02 COLUMN 62 PIC ZZ9 FROM AC-PAGE-COUNT.
02 LINE 2 COLUMN 20 VALUE "CUSTOMER PURCHASES REPORT".
02 LINE 4 COLUMN 1 VALUE "ACCOUNT".
02 COLUMN 57 VALUE "CREDIT".
02 LINE 5 COLUMN 1 VALUE "NUMBER".
02 COLUMN 9 VALUE "CUSTOMER NAME".
02 COLUMN 31 VALUE "BALANCE".
02 COLUMN 44 VALUE "PURCHASES".
02 COLUMN 57 VALUE "LIMIT".
02 LINE 6 COLUMN 1 PIC X(7) FROM WA-HYPHENS.
02 COLUMN 9 PIC X(20) FROM WA-HYPHENS.
02 COLUMN 31 PIC X(11) FROM WA-HYPHENS.
02 COLUMN 44 PIC X(9) FROM WA-HYPHENS.
02 COLUMN 57 PIC X(8) FROM WA-HYPHENS.
/
******************************************************************
* *
* Detail Line for the Customer Purchases Report *
* *
******************************************************************

01 DETAIL-LINE.

02 LINE AC-LINE-COUNT.
02 COLUMN 1 PIC X(6) FROM CR-ACCOUNT-NUMBER.
02 COLUMN 9 PIC X(20) FROM CR-CUSTOMER-NAME.
02 COLUMN 31 PIC $$,$$$.99CR FROM CR-BALANCE.
02 COLUMN 44 PIC $$,$$$.99 FROM CR-PURCHASES.
02 COLUMN 56 PIC ZZ,ZZ9.99 FROM CR-CREDIT-LIMIT.
/
******************************************************************
* *
* Summary Lines for the Customer Purchases Report *
* *
******************************************************************

01 SUMMARY-LINES.

02 SL-LINE-1.
03 LINE AC-LINE-COUNT.
03 COLUMN 11 VALUE
"TOTAL NUMBER OF RECORDS DISPLAYED = ".
03 COLUMN 47 PIC ZZZZ9 FROM AC-RECORD-COUNT.

02 SL-LINE-2.
03 LINE AC-LINE-COUNT.
03 COLUMN 24 VALUE "END OF REPORT".
/
PROCEDURE DIVISION.
*******************
******************************************************************
* *
* MAIN-PROGRAM - THIS IS THE MAIN PARAGRAPH OF THIS PROGRAM *
* *
******************************************************************

MAIN-PROGRAM.

PERFORM A-100-INITIALIZATION.
PERFORM B-100-PROCESS-FILE.
PERFORM C-100-WRAP-UP.
STOP RUN.

******************************************************************
* *
* THE INITIALIZATION PARAGRAPH FOLLOWS *
* *
******************************************************************

A-100-INITIALIZATION.

MOVE ZERO TO AC-PAGE-COUNT
AC-LINE-COUNT
AC-RECORD-COUNT.

MOVE FUNCTION CURRENT-DATE TO WA-TODAYS-DATE-TIME.
MOVE WA-TODAYS-MONTH TO WA-MONTH.
MOVE WA-TODAYS-DAY TO WA-DAY.
MOVE WA-TODAYS-YEAR TO WA-YEAR.

OPEN INPUT CUSTOMER-FILE.
/
******************************************************************
* *
* FILE PROCESSING CONTROL PARAGRAPH *
* *
******************************************************************

B-100-PROCESS-FILE.

MOVE "N" TO SW-END-OF-FILE.
READ CUSTOMER-FILE
AT END MOVE "Y" TO SW-END-OF-FILE.

PERFORM B-200-PROCESS-RECORD
UNTIL END-OF-FILE.
ADD 1 TO AC-LINE-COUNT.
DISPLAY SL-LINE-1.
ADD 1 TO AC-LINE-COUNT.
DISPLAY SL-LINE-2.
/
******************************************************************
* *
* DISPLAY HEADINGS AND DETAIL LINES *
* *
******************************************************************

B-200-PROCESS-RECORD.

IF AC-LINE-COUNT = 0
ADD 1 TO AC-PAGE-COUNT
DISPLAY HEADING-LINES
MOVE 7 TO AC-LINE-COUNT.

DISPLAY DETAIL-LINE.
ADD 1 TO AC-LINE-COUNT.
ADD 1 TO AC-RECORD-COUNT.

IF AC-LINE-COUNT > 20
DISPLAY " "
DISPLAY "PLEASE PRESS THE ENTER KEY TO CONTINUE"
ACCEPT WA-SCREEN-HOLD
MOVE ZERO TO AC-LINE-COUNT.

READ CUSTOMER-FILE
AT END MOVE "Y" TO SW-END-OF-FILE.
/
******************************************************************
* *
* END OF JOB PARAGRAPH *
* *
******************************************************************

C-100-WRAP-UP.

DISPLAY " ".
DISPLAY " ".
DISPLAY "PLEASE PRESS THE ENTER KEY TO CONTINUE".
ACCEPT WA-SCREEN-HOLD.
CLOSE CUSTOMER-FILE.
DISPLAY " ".
DISPLAY "CUSTOMER PURCHASES REPORT PROGRAM HAS TERMINATED".
DISPLAY " ".
/
 
From the Final Committee Draft of COBOL 2002:

"The data division describes the data that the runtime module is to accept as input, to manipulate, to create, or to produce as output. The data division is optional."

Stephen J Spiro
Member, ANSI COBOL Standards Committee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top