Guest_imported
New member
- Jan 1, 1970
- 0
I am not a professional programmer. I am here to seek answers from professionals. I am doing a lab in an advanced COBOL class. I am modifying a program that figured out ages and birthdates of a list of people. I now have to print a separate output with just the people that have birthdays in the next 31 days. The program already identifies them with an asterisk on the output. I now just have to get those names to another output, while at the same time leaving the old output alone. So I'll have to outputs.
Here is my old program, it hasn't been changed yet.
------------------------------------------------------------
*-----------------------------------------------------------------
IDENTIFICATION DIVISION.
*-----------------------------------------------------------------
PROGRAM-ID. LAB1.
AUTHOR.
*-----------------------------------------------------------------
*THIS PROGRAM USES DATE MANIPULATION TO COMPUTE THE AGE OF CLIENTS
*THAT ARE IN AN INPUT FILE TO SEE IF THEY HAVE AN UPCOMING
*BIRTHDAY
*-----------------------------------------------------------------
*-----------------------------------------------------------------
ENVIRONMENT DIVISION.
*-----------------------------------------------------------------
*------------------------
INPUT-OUTPUT SECTION.
*------------------------
FILE-CONTROL.
SELECT INPUT-FILE ASSIGN TO 'R:\COBOL2\LAB1\CLIENTS.TXT'
ORGANIZATION IS LINE SEQUENTIAL.
SELECT REPORT-FILE ASSIGN TO 'R:\COBOL2\LAB1\AGEREPORT.OUT'
ORGANIZATION IS LINE SEQUENTIAL.
*-----------------------------------------------------------------
DATA DIVISION.
*-----------------------------------------------------------------
*------------------------
FILE SECTION.
*------------------------
* |--------------------|
* | INPUT FILE |
* |--------------------|
FD INPUT-FILE
LABEL RECORDS ARE STANDARD
RECORD CONTAINS 41 CHARACTERS
BLOCK CONTAINS 41 CHARACTERS.
01 CLIENT-RECORD.
05 CLIENT-NUMBER-CR PIC X(5).
05 CLIENT-NAME-CR PIC X(20).
05 CLIENT-BIRTHDAY-CR PIC 9(8).
05 FILLER PIC X(8).
* |--------------------|
* | OUTPUT FILE |
* |--------------------|
FD REPORT-FILE
LABEL RECORDS ARE STANDARD
RECORD CONTAINS 100 CHARACTERS
BLOCK CONTAINS 100 CHARACTERS.
01 REPORT-RECORD PIC X(100).
*------------------------
WORKING-STORAGE SECTION.
*------------------------
* |--------------------|
* | FLAG |
* |--------------------|
01 FLAGS-AND-ACCUMULATORS.
05 EOF-FLAG PIC X(3) VALUE 'NO'.
* |--------------------|
* | DATE FIELDS |
* |--------------------|
01 WS-CURRENT-DATE.
05 WS-CURRENT-DATE-MONTH.
10 WS-YEAR PIC 9(04).
10 WS-MONTH PIC 9(02).
10 WS-DAY PIC 9(02).
05 WS-INTEGER-TODAY REDEFINES WS-CURRENT-DATE-MONTH PIC 9(8).
01 DAYS-LEFT.
05 WS-DAYS-LEFT PIC 999.
05 WS-INTEGER-TODAY2 PIC 9(10).
05 WS-INTEGER-CLIENT-BDAY PIC 9(10).
01 CLIENT-BIRTHDAY.
05 WS-YEAR-BDAY PIC 9999.
05 WS-MONTH-BDAY PIC 99.
05 WS-DAY-BDAY PIC 99.
01 WS-INTEGER-CLIENT-BIRTHDAY REDEFINES CLIENT-BIRTHDAY PIC 9(8).
* |--------------------|
* | REPORT STRUCTURES |
* |--------------------|
01 TITLE-LINE-ONE.
05 PIC X(12) VALUE SPACES.
05 PIC X(23) VALUE
'White Insurance Company'.
01 TITLE-LINE-TWO.
05 PIC X(12) VALUE SPACES.
05 PIC X(19) VALUE
'Bruce, South Dakota'.
01 COLUMN-HEADING.
05 PIC X(11) VALUE 'Client Name'.
05 PIC X(14) VALUE SPACES.
05 PIC X(8) VALUE 'Birthday'.
05 PIC X(12) VALUE SPACES.
05 PIC X(3) VALUE 'Age'.
05 PIC X(2) VALUE SPACES.
05 PIC X(8) VALUE 'Upcoming'.
01 DETAIL-LINE.
05 CLIENT-NAME-DL PIC X(25).
05 MONTH-DL PIC Z9.
05 PIC X(1) VALUE '/'.
05 DAY-DL PIC 99.
05 PIC X(1) VALUE '/'.
05 YEAR-DL PIC 9999.
05 PIC X(10) VALUE SPACES.
05 AGE-DL PIC ZZ9.
05 PIC X(5) VALUE SPACES.
05 UPCOMING-DL PIC X.
*-----------------------------------------------------------------
PROCEDURE DIVISION.
*-----------------------------------------------------------------
*------------------------
1000-MAIN-MODULE.
*------------------------
PERFORM 2000-INITIALIZE
* |---------------------|
* |PROCESS INPUT RECORDS|
* |---------------------|
PERFORM UNTIL EOF-FLAG = 'YES'
READ INPUT-FILE
AT END
MOVE 'YES' TO EOF-FLAG
NOT AT END
PERFORM 3000-PROCESS
END-READ
END-PERFORM
PERFORM 4000-TERMINATE
STOP RUN.
*------------------------
2000-INITIALIZE.
*------------------------
* |--------------------|
* | OPEN FILES |
* |--------------------|
OPEN INPUT INPUT-FILE
OUTPUT REPORT-FILE
MOVE FUNCTION CURRENT-DATE TO WS-CURRENT-DATE-MONTH
PERFORM 9000-WRITE-HEADINGS.
*------------------------
3000-PROCESS.
*------------------------
MOVE CLIENT-BIRTHDAY-CR TO CLIENT-BIRTHDAY
MOVE FUNCTION INTEGER-OF-DATE (CLIENT-BIRTHDAY-CR)
TO WS-INTEGER-CLIENT-BDAY
MOVE FUNCTION INTEGER-OF-DATE (WS-INTEGER-TODAY)
TO WS-INTEGER-TODAY2
SUBTRACT WS-INTEGER-CLIENT-BDAY FROM WS-INTEGER-TODAY2
GIVING WS-INTEGER-CLIENT-BDAY
DIVIDE WS-INTEGER-CLIENT-BDAY BY 365.25 GIVING AGE-DL
REMAINDER WS-DAYS-LEFT
IF WS-DAYS-LEFT >334
MOVE '*' TO UPCOMING-DL
END-IF
MOVE CLIENT-NAME-CR TO CLIENT-NAME-DL
MOVE CLIENT-BIRTHDAY-CR TO CLIENT-BIRTHDAY
MOVE WS-YEAR-BDAY TO YEAR-DL
MOVE WS-MONTH-BDAY TO MONTH-DL
MOVE WS-DAY-BDAY TO DAY-DL
WRITE REPORT-RECORD FROM DETAIL-LINE AFTER 1
MOVE SPACES TO UPCOMING-DL.
*------------------------
4000-TERMINATE.
*------------------------
CLOSE INPUT-FILE
REPORT-FILE.
*------------------------
9000-WRITE-HEADINGS.
*------------------------
WRITE REPORT-RECORD FROM TITLE-LINE-ONE AFTER PAGE
WRITE REPORT-RECORD FROM TITLE-LINE-TWO AFTER 1
WRITE REPORT-RECORD FROM COLUMN-HEADING AFTER 2
WRITE REPORT-RECORD FROM SPACES.
Here is my old program, it hasn't been changed yet.
------------------------------------------------------------
*-----------------------------------------------------------------
IDENTIFICATION DIVISION.
*-----------------------------------------------------------------
PROGRAM-ID. LAB1.
AUTHOR.
*-----------------------------------------------------------------
*THIS PROGRAM USES DATE MANIPULATION TO COMPUTE THE AGE OF CLIENTS
*THAT ARE IN AN INPUT FILE TO SEE IF THEY HAVE AN UPCOMING
*BIRTHDAY
*-----------------------------------------------------------------
*-----------------------------------------------------------------
ENVIRONMENT DIVISION.
*-----------------------------------------------------------------
*------------------------
INPUT-OUTPUT SECTION.
*------------------------
FILE-CONTROL.
SELECT INPUT-FILE ASSIGN TO 'R:\COBOL2\LAB1\CLIENTS.TXT'
ORGANIZATION IS LINE SEQUENTIAL.
SELECT REPORT-FILE ASSIGN TO 'R:\COBOL2\LAB1\AGEREPORT.OUT'
ORGANIZATION IS LINE SEQUENTIAL.
*-----------------------------------------------------------------
DATA DIVISION.
*-----------------------------------------------------------------
*------------------------
FILE SECTION.
*------------------------
* |--------------------|
* | INPUT FILE |
* |--------------------|
FD INPUT-FILE
LABEL RECORDS ARE STANDARD
RECORD CONTAINS 41 CHARACTERS
BLOCK CONTAINS 41 CHARACTERS.
01 CLIENT-RECORD.
05 CLIENT-NUMBER-CR PIC X(5).
05 CLIENT-NAME-CR PIC X(20).
05 CLIENT-BIRTHDAY-CR PIC 9(8).
05 FILLER PIC X(8).
* |--------------------|
* | OUTPUT FILE |
* |--------------------|
FD REPORT-FILE
LABEL RECORDS ARE STANDARD
RECORD CONTAINS 100 CHARACTERS
BLOCK CONTAINS 100 CHARACTERS.
01 REPORT-RECORD PIC X(100).
*------------------------
WORKING-STORAGE SECTION.
*------------------------
* |--------------------|
* | FLAG |
* |--------------------|
01 FLAGS-AND-ACCUMULATORS.
05 EOF-FLAG PIC X(3) VALUE 'NO'.
* |--------------------|
* | DATE FIELDS |
* |--------------------|
01 WS-CURRENT-DATE.
05 WS-CURRENT-DATE-MONTH.
10 WS-YEAR PIC 9(04).
10 WS-MONTH PIC 9(02).
10 WS-DAY PIC 9(02).
05 WS-INTEGER-TODAY REDEFINES WS-CURRENT-DATE-MONTH PIC 9(8).
01 DAYS-LEFT.
05 WS-DAYS-LEFT PIC 999.
05 WS-INTEGER-TODAY2 PIC 9(10).
05 WS-INTEGER-CLIENT-BDAY PIC 9(10).
01 CLIENT-BIRTHDAY.
05 WS-YEAR-BDAY PIC 9999.
05 WS-MONTH-BDAY PIC 99.
05 WS-DAY-BDAY PIC 99.
01 WS-INTEGER-CLIENT-BIRTHDAY REDEFINES CLIENT-BIRTHDAY PIC 9(8).
* |--------------------|
* | REPORT STRUCTURES |
* |--------------------|
01 TITLE-LINE-ONE.
05 PIC X(12) VALUE SPACES.
05 PIC X(23) VALUE
'White Insurance Company'.
01 TITLE-LINE-TWO.
05 PIC X(12) VALUE SPACES.
05 PIC X(19) VALUE
'Bruce, South Dakota'.
01 COLUMN-HEADING.
05 PIC X(11) VALUE 'Client Name'.
05 PIC X(14) VALUE SPACES.
05 PIC X(8) VALUE 'Birthday'.
05 PIC X(12) VALUE SPACES.
05 PIC X(3) VALUE 'Age'.
05 PIC X(2) VALUE SPACES.
05 PIC X(8) VALUE 'Upcoming'.
01 DETAIL-LINE.
05 CLIENT-NAME-DL PIC X(25).
05 MONTH-DL PIC Z9.
05 PIC X(1) VALUE '/'.
05 DAY-DL PIC 99.
05 PIC X(1) VALUE '/'.
05 YEAR-DL PIC 9999.
05 PIC X(10) VALUE SPACES.
05 AGE-DL PIC ZZ9.
05 PIC X(5) VALUE SPACES.
05 UPCOMING-DL PIC X.
*-----------------------------------------------------------------
PROCEDURE DIVISION.
*-----------------------------------------------------------------
*------------------------
1000-MAIN-MODULE.
*------------------------
PERFORM 2000-INITIALIZE
* |---------------------|
* |PROCESS INPUT RECORDS|
* |---------------------|
PERFORM UNTIL EOF-FLAG = 'YES'
READ INPUT-FILE
AT END
MOVE 'YES' TO EOF-FLAG
NOT AT END
PERFORM 3000-PROCESS
END-READ
END-PERFORM
PERFORM 4000-TERMINATE
STOP RUN.
*------------------------
2000-INITIALIZE.
*------------------------
* |--------------------|
* | OPEN FILES |
* |--------------------|
OPEN INPUT INPUT-FILE
OUTPUT REPORT-FILE
MOVE FUNCTION CURRENT-DATE TO WS-CURRENT-DATE-MONTH
PERFORM 9000-WRITE-HEADINGS.
*------------------------
3000-PROCESS.
*------------------------
MOVE CLIENT-BIRTHDAY-CR TO CLIENT-BIRTHDAY
MOVE FUNCTION INTEGER-OF-DATE (CLIENT-BIRTHDAY-CR)
TO WS-INTEGER-CLIENT-BDAY
MOVE FUNCTION INTEGER-OF-DATE (WS-INTEGER-TODAY)
TO WS-INTEGER-TODAY2
SUBTRACT WS-INTEGER-CLIENT-BDAY FROM WS-INTEGER-TODAY2
GIVING WS-INTEGER-CLIENT-BDAY
DIVIDE WS-INTEGER-CLIENT-BDAY BY 365.25 GIVING AGE-DL
REMAINDER WS-DAYS-LEFT
IF WS-DAYS-LEFT >334
MOVE '*' TO UPCOMING-DL
END-IF
MOVE CLIENT-NAME-CR TO CLIENT-NAME-DL
MOVE CLIENT-BIRTHDAY-CR TO CLIENT-BIRTHDAY
MOVE WS-YEAR-BDAY TO YEAR-DL
MOVE WS-MONTH-BDAY TO MONTH-DL
MOVE WS-DAY-BDAY TO DAY-DL
WRITE REPORT-RECORD FROM DETAIL-LINE AFTER 1
MOVE SPACES TO UPCOMING-DL.
*------------------------
4000-TERMINATE.
*------------------------
CLOSE INPUT-FILE
REPORT-FILE.
*------------------------
9000-WRITE-HEADINGS.
*------------------------
WRITE REPORT-RECORD FROM TITLE-LINE-ONE AFTER PAGE
WRITE REPORT-RECORD FROM TITLE-LINE-TWO AFTER 1
WRITE REPORT-RECORD FROM COLUMN-HEADING AFTER 2
WRITE REPORT-RECORD FROM SPACES.