Hi. I have a calendar I wrote in cobol that is not giving me the output I desire.
Below is the code. My lines aren't showing up straight. Help!
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INDATE ASSIGN TO "C:\COBOL\FILE\DATEDOW.DAT"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT INBIRTHDAY ASSIGN TO "C:\COBOL\FILE\INBIR.TXT"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT OUTFILE ASSIGN TO "C:\COBOL\FILE\OUTPUT.TXT".
DATA DIVISION.
FILE SECTION.
FD INDATE LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "DATEDOW.DAT".
01 INDATE-REC.
05 DATE-GROUP.
10 YY PIC 9(4).
10 MM PIC 9(2).
10 DD PIC 9(2).
05 DOW PIC 9(1).
05 LINE-1 PIC X(10).
05 LINE-2 PIC X(10).
05 LINE-3 PIC X(10).
05 LINE-4 PIC X(10).
FD INBIRTHDAY LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "INBIR.TXT".
01 INBIRTHDAY-REC.
05 NAME1 PIC X(10).
05 NAME2 PIC X(10).
05 BDATE-GROUP.
10 BYY PIC 9(4).
10 BMM PIC 9(2).
10 BDD PIC 9(2).
FD OUTFILE
LABEL RECORDS ARE OMITTED.
01 OUT-REC PIC X(80).
WORKING-STORAGE SECTION.
77 EOF PIC X VALUE "N".
77 PMM PIC 99.
77 EOF2 PIC X.
77 TEMP-NAME1 PIC X(20).
77 TEMP-NAME2 PIC X(20).
77 FLAG PIC X.
01 HEADING-REC1.
05 FILLER PIC X(33) VALUE SPACES.
05 MONTH-NAME PIC X(15).
05 FILLER PIC X(33) VALUE SPACES.
01 HEADING-REC2.
05 FILLER PIC X(10) VALUE "SUNDAY".
05 FILLER PIC X(1) VALUE SPACES.
05 FILLER PIC X(10) VALUE "MONDAY".
05 FILLER PIC X(1) VALUE SPACES.
05 FILLER PIC X(10) VALUE "TUESDAY".
05 FILLER PIC X(1) VALUE SPACES.
05 FILLER PIC X(10) VALUE "WEDNESDAY".
05 FILLER PIC X(1) VALUE SPACES.
05 FILLER PIC X(10) VALUE "THURSDAY".
05 FILLER PIC X(1) VALUE SPACES.
05 FILLER PIC X(10) VALUE "FRIDAY".
05 FILLER PIC X(1) VALUE SPACES.
05 FILLER PIC X(10) VALUE "SATURDAY".
05 FILLER PIC X(1) VALUE SPACES.
01 OUT-REC1.
05 ROWS OCCURS 6 TIMES.
10 SQUARES OCCURS 7 TIMES.
15 LINE1 PIC X(10).
15 BAR-C PIC X.
10 FILLER PIC X(3).
01 DASH-LINE PIC X(77) VALUE ALL "-".
77 I PIC 9.
PROCEDURE DIVISION.
MAIN-PARA.
OPEN INPUT INDATE.
OPEN OUTPUT OUTFILE.
PERFORM READ-PARA.
PERFORM INIT-PARA.
PERFORM HEADING-PARA.
PERFORM PROCESS-PARA UNTIL EOF = "Y".
CLOSE INDATE OUTFILE.
STOP RUN.
INIT-PARA.
MOVE MM TO PMM.
READ-PARA.
READ INDATE AT END MOVE "Y" TO EOF.
HEADING-PARA.
PERFORM MONTH-PARA.
WRITE OUT-REC FROM HEADING-REC1
AFTER ADVANCING 1 LINE.
MOVE SPACES TO OUT-REC.
WRITE OUT-REC
AFTER ADVANCING 1 LINE.
WRITE OUT-REC FROM HEADING-REC2
AFTER ADVANCING 1 LINE.
WRITE OUT-REC FROM DASH-LINE
AFTER ADVANCING 1 LINE.
MOVE MM TO PMM.
PROCESS-PARA.
MOVE "Y" TO FLAG.
MOVE SPACES TO OUT-REC1.
PERFORM BAR-PARA 6 TIMES.
MOVE 1 TO I.
PERFORM DATE-PARA UNTIL FLAG = "N".
MOVE SPACES TO OUT-REC.
WRITE OUT-REC FROM ROWS(1)
AFTER ADVANCING 1 LINE.
WRITE OUT-REC FROM ROWS(2)
AFTER ADVANCING 1 LINE.
WRITE OUT-REC FROM ROWS(3)
AFTER ADVANCING 1 LINE.
WRITE OUT-REC FROM ROWS(4)
AFTER ADVANCING 1 LINE.
WRITE OUT-REC FROM ROWS(5)
AFTER ADVANCING 1 LINE.
WRITE OUT-REC FROM ROWS(6)
AFTER ADVANCING 1 LINE.
WRITE OUT-REC FROM DASH-LINE
AFTER ADVANCING 1 LINE.
IF EOF NOT = "Y" AND MM NOT = PMM
PERFORM HEADING-PARA
MOVE SPACES TO OUT-REC
WRITE OUT-REC AFTER ADVANCING PAGE.
DATE-PARA.
MOVE SPACES TO TEMP-NAME1.
MOVE SPACES TO TEMP-NAME2.
PERFORM GET-BIRTHNAME-PARA.
MOVE DD TO LINE1 (1, DOW).
IF DOW = 7
MOVE "N" TO FLAG
ELSE IF EOF = "Y"
MOVE "N" TO FLAG.
GET-BIRTHNAME-PARA.
OPEN INPUT INBIRTHDAY
MOVE "N" TO EOF2.
READ INBIRTHDAY AT END MOVE "Y" TO EOF2.
PERFORM SEARCH-PARA UNTIL EOF2 = "Y".
CLOSE INBIRTHDAY.
MOVE DD TO LINE1 (1, DOW).
PERFORM READ-PARA.
SEARCH-PARA.
IF BDD = DD AND BMM = MM
MOVE NAME1 TO TEMP-NAME1
MOVE NAME2 TO TEMP-NAME2
MOVE TEMP-NAME1 TO LINE1 (3, DOW)
MOVE TEMP-NAME2 TO LINE1 (4, DOW).
READ INBIRTHDAY AT END MOVE "Y" TO EOF2.
MONTH-PARA.
IF MM = 1
MOVE "JANUARY" TO MONTH-NAME
ELSE IF MM = 2
MOVE "FEBRUARY" TO MONTH-NAME
ELSE IF MM = 3
MOVE "MARCH" TO MONTH-NAME
ELSE IF MM = 4
MOVE "APRIL" TO MONTH-NAME
ELSE IF MM = 5
MOVE "MAY" TO MONTH-NAME
ELSE IF MM = 6
MOVE "JUNE" TO MONTH-NAME
ELSE IF MM = 7
MOVE "JULY" TO MONTH-NAME
ELSE IF MM = 8
MOVE "AUGUST" TO MONTH-NAME
ELSE IF MM = 9
MOVE "SEPTEMBER" TO MONTH-NAME
ELSE IF MM = 10
MOVE "OCTOBER" TO MONTH-NAME
ELSE IF MM = 11
MOVE "NOVEMBER" TO MONTH-NAME
ELSE IF MM = 12
MOVE "DECEMBER" TO MONTH-NAME.
BAR-PARA.
MOVE "|" TO BAR-C (I, 1).
MOVE "|" TO BAR-C (I, 2).
MOVE "|" TO BAR-C (I, 3).
MOVE "|" TO BAR-C (I, 4).
MOVE "|" TO BAR-C (I, 5).
MOVE "|" TO BAR-C (I, 6).
MOVE "|" TO BAR-C (I, 7).
ADD 1 TO I.
Below is the code. My lines aren't showing up straight. Help!
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INDATE ASSIGN TO "C:\COBOL\FILE\DATEDOW.DAT"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT INBIRTHDAY ASSIGN TO "C:\COBOL\FILE\INBIR.TXT"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT OUTFILE ASSIGN TO "C:\COBOL\FILE\OUTPUT.TXT".
DATA DIVISION.
FILE SECTION.
FD INDATE LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "DATEDOW.DAT".
01 INDATE-REC.
05 DATE-GROUP.
10 YY PIC 9(4).
10 MM PIC 9(2).
10 DD PIC 9(2).
05 DOW PIC 9(1).
05 LINE-1 PIC X(10).
05 LINE-2 PIC X(10).
05 LINE-3 PIC X(10).
05 LINE-4 PIC X(10).
FD INBIRTHDAY LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "INBIR.TXT".
01 INBIRTHDAY-REC.
05 NAME1 PIC X(10).
05 NAME2 PIC X(10).
05 BDATE-GROUP.
10 BYY PIC 9(4).
10 BMM PIC 9(2).
10 BDD PIC 9(2).
FD OUTFILE
LABEL RECORDS ARE OMITTED.
01 OUT-REC PIC X(80).
WORKING-STORAGE SECTION.
77 EOF PIC X VALUE "N".
77 PMM PIC 99.
77 EOF2 PIC X.
77 TEMP-NAME1 PIC X(20).
77 TEMP-NAME2 PIC X(20).
77 FLAG PIC X.
01 HEADING-REC1.
05 FILLER PIC X(33) VALUE SPACES.
05 MONTH-NAME PIC X(15).
05 FILLER PIC X(33) VALUE SPACES.
01 HEADING-REC2.
05 FILLER PIC X(10) VALUE "SUNDAY".
05 FILLER PIC X(1) VALUE SPACES.
05 FILLER PIC X(10) VALUE "MONDAY".
05 FILLER PIC X(1) VALUE SPACES.
05 FILLER PIC X(10) VALUE "TUESDAY".
05 FILLER PIC X(1) VALUE SPACES.
05 FILLER PIC X(10) VALUE "WEDNESDAY".
05 FILLER PIC X(1) VALUE SPACES.
05 FILLER PIC X(10) VALUE "THURSDAY".
05 FILLER PIC X(1) VALUE SPACES.
05 FILLER PIC X(10) VALUE "FRIDAY".
05 FILLER PIC X(1) VALUE SPACES.
05 FILLER PIC X(10) VALUE "SATURDAY".
05 FILLER PIC X(1) VALUE SPACES.
01 OUT-REC1.
05 ROWS OCCURS 6 TIMES.
10 SQUARES OCCURS 7 TIMES.
15 LINE1 PIC X(10).
15 BAR-C PIC X.
10 FILLER PIC X(3).
01 DASH-LINE PIC X(77) VALUE ALL "-".
77 I PIC 9.
PROCEDURE DIVISION.
MAIN-PARA.
OPEN INPUT INDATE.
OPEN OUTPUT OUTFILE.
PERFORM READ-PARA.
PERFORM INIT-PARA.
PERFORM HEADING-PARA.
PERFORM PROCESS-PARA UNTIL EOF = "Y".
CLOSE INDATE OUTFILE.
STOP RUN.
INIT-PARA.
MOVE MM TO PMM.
READ-PARA.
READ INDATE AT END MOVE "Y" TO EOF.
HEADING-PARA.
PERFORM MONTH-PARA.
WRITE OUT-REC FROM HEADING-REC1
AFTER ADVANCING 1 LINE.
MOVE SPACES TO OUT-REC.
WRITE OUT-REC
AFTER ADVANCING 1 LINE.
WRITE OUT-REC FROM HEADING-REC2
AFTER ADVANCING 1 LINE.
WRITE OUT-REC FROM DASH-LINE
AFTER ADVANCING 1 LINE.
MOVE MM TO PMM.
PROCESS-PARA.
MOVE "Y" TO FLAG.
MOVE SPACES TO OUT-REC1.
PERFORM BAR-PARA 6 TIMES.
MOVE 1 TO I.
PERFORM DATE-PARA UNTIL FLAG = "N".
MOVE SPACES TO OUT-REC.
WRITE OUT-REC FROM ROWS(1)
AFTER ADVANCING 1 LINE.
WRITE OUT-REC FROM ROWS(2)
AFTER ADVANCING 1 LINE.
WRITE OUT-REC FROM ROWS(3)
AFTER ADVANCING 1 LINE.
WRITE OUT-REC FROM ROWS(4)
AFTER ADVANCING 1 LINE.
WRITE OUT-REC FROM ROWS(5)
AFTER ADVANCING 1 LINE.
WRITE OUT-REC FROM ROWS(6)
AFTER ADVANCING 1 LINE.
WRITE OUT-REC FROM DASH-LINE
AFTER ADVANCING 1 LINE.
IF EOF NOT = "Y" AND MM NOT = PMM
PERFORM HEADING-PARA
MOVE SPACES TO OUT-REC
WRITE OUT-REC AFTER ADVANCING PAGE.
DATE-PARA.
MOVE SPACES TO TEMP-NAME1.
MOVE SPACES TO TEMP-NAME2.
PERFORM GET-BIRTHNAME-PARA.
MOVE DD TO LINE1 (1, DOW).
IF DOW = 7
MOVE "N" TO FLAG
ELSE IF EOF = "Y"
MOVE "N" TO FLAG.
GET-BIRTHNAME-PARA.
OPEN INPUT INBIRTHDAY
MOVE "N" TO EOF2.
READ INBIRTHDAY AT END MOVE "Y" TO EOF2.
PERFORM SEARCH-PARA UNTIL EOF2 = "Y".
CLOSE INBIRTHDAY.
MOVE DD TO LINE1 (1, DOW).
PERFORM READ-PARA.
SEARCH-PARA.
IF BDD = DD AND BMM = MM
MOVE NAME1 TO TEMP-NAME1
MOVE NAME2 TO TEMP-NAME2
MOVE TEMP-NAME1 TO LINE1 (3, DOW)
MOVE TEMP-NAME2 TO LINE1 (4, DOW).
READ INBIRTHDAY AT END MOVE "Y" TO EOF2.
MONTH-PARA.
IF MM = 1
MOVE "JANUARY" TO MONTH-NAME
ELSE IF MM = 2
MOVE "FEBRUARY" TO MONTH-NAME
ELSE IF MM = 3
MOVE "MARCH" TO MONTH-NAME
ELSE IF MM = 4
MOVE "APRIL" TO MONTH-NAME
ELSE IF MM = 5
MOVE "MAY" TO MONTH-NAME
ELSE IF MM = 6
MOVE "JUNE" TO MONTH-NAME
ELSE IF MM = 7
MOVE "JULY" TO MONTH-NAME
ELSE IF MM = 8
MOVE "AUGUST" TO MONTH-NAME
ELSE IF MM = 9
MOVE "SEPTEMBER" TO MONTH-NAME
ELSE IF MM = 10
MOVE "OCTOBER" TO MONTH-NAME
ELSE IF MM = 11
MOVE "NOVEMBER" TO MONTH-NAME
ELSE IF MM = 12
MOVE "DECEMBER" TO MONTH-NAME.
BAR-PARA.
MOVE "|" TO BAR-C (I, 1).
MOVE "|" TO BAR-C (I, 2).
MOVE "|" TO BAR-C (I, 3).
MOVE "|" TO BAR-C (I, 4).
MOVE "|" TO BAR-C (I, 5).
MOVE "|" TO BAR-C (I, 6).
MOVE "|" TO BAR-C (I, 7).
ADD 1 TO I.