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!

Calendar not working

Status
Not open for further replies.

TerriAnne

Technical User
Apr 21, 2003
3
US
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.

 
Hi TerriAnne,

Why don't you show us your O/P and how it varies from what you expected? It will make it easier to zero in on your problem.

Regards, Jack.
 
TerriAnne,

From a very brief look at the code a couple of things spring to mind:

It appears that before executing your BAR-PARA section you do not initialise the I variable

The SEARCH-PARA section always seems to over write the previously built details, because the first subscripts are hard coded as 3 and 4.

This last 'error' may not be an error as I'm not sure what it is you are trying to achieve, and what errors you are getting. Jack's suggestion of a bit more info, would be helpful.

Marc
 
Hi guys.

Sorry I didn't get to this sooner...I've been working a ton of overtime to get the FDA off our backs.

Anyways, I figured out the problem. I had an infinite loop where I shouldn't have and now the program works! Thanks for the quick and knowledgable responses tho!
 
Amazing! First she says her O/P is bad, then she says the pgm was in a loop. Thanx, bye.

That's why I don't bother w/requests that are incomplete or fuzzy.

Sheesh.
 
TerriAnne,
Jack (Slade) might be considered a little bit harsh, bearing in mind the fact that you are pretty new to these forums (fora? forii?), but has a valid point.

The more information that you can give, the better, and the more likely you are of receiving 'expert' advice. If you give incomplete info, and then a seemingly contradictory resolution, expect curses and gnashing of teeth in response!

As you posted the code, I feel I've got to comment on it, and I hope my comments help........

The structure of the program, from working storage through to procedure division statements, is not easy to follow.

For instance, your field names do not give any indication of where they came from. The fields YY or NAME1 could have come from anywhere in the program. It's good to name fields with some sort of prefix, and more often than not the site that you are working at will have standards (eg. working storage date fields beginning WD-, INDATE file fields beginning IND-).

When it comes to procedure division statements, this is even more important. People often code sections/paragraph with a prefix that kind of describes where the s/p was executed from. eg. CA-PROCESS will perform CAA- CAB- CAC- etc. sections or paragraphs.

This is all very very very useful when, as a support programmer, you get called into the office at 3.30am to debug a program that you know very little about.

Right, lecture over, and I hope you don't take offence. Please come back to us with your comments........

Marc
 
Ya know....I thought these forums were for people like me (BEGINNERS) to get help from experts. How the heck am I supposed to know what is "fuzzy" (great word coming from an expert!)??? Jack, maybe you should take a chill pill. If posts like mine get you upset....maybe you're in the wrong business. You are here to help, aren't you? Or is it common to get ridiculed, as well????

At least I had the decency to come back into the forum and close this out so I didn't have people working on it for nothing.

Marc, thanks for trying to smooth things over. I think Jack should change his handle to "abrasive"!
 
TerriAnne,
You did good. It's always difficult posting to a forum like this when you are a beginner. Jack is an incredibly knowledgable and helpful member, who has helped me out on more than one occassion. I suspect that in this instance he was unaware of your er.... 'virginal' (can I get away with a non PC word like this???) status.

I expect/hope to see you back with further questions in the near future.

Marc
 
Hi TerriAnn,

Given the attitude displayed in your earlier posts, I'm not surprised by your last.

I was just amazed at that fact that you somehow failed to mention that your pgm was in a loop, and somewhat bemused at the breeziness (there goes one of those "z" words again) of your dismissal.

BTW, if "fuzzy" is good enough for Lotfi Zadeh, it's good enough for me.

Regards, Abrasive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top