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!

Coding for table problem re. slade 1

Status
Not open for further replies.

coboldummy

Programmer
Mar 22, 2001
3
GB
slade and other members

This is the code I have produced so far for my problem with cobol tables.

FD Student-File.
01 Student-Rec.
03 SF-CandNo Pic 99.
03 SF-Paper1-Mark Pic 999.
03 SF-Paper2-Mark Pic 999.
03 SF-Paper3-Mark Pic 999.

Working-Storage Section.
01 W-Student-EOF Pic X Value "N".
88 End-Of-Student-File Value "Y".

01 W-ExamTable.
03 W-Paper Occurs 3.
05 W-Mark Pic 999 Occurs 4.

Procedure Division.

Open Input Student-File
Move Zeros to W-ExamTable
Read Student-File
At End Move "Y" to W-Student-EOF
Not At End
Perform Paper1
Perform Paper2
Perform Paper3
End-Read.

Paper1.
Evaluate SF-Paper1-Mark
When SF-Paper1-Mark < 40
Add 1 to W-ExamTable(1,1)
When SF-Paper1-Mark > 39 AND < 50
Add 1 to W-ExamTable(1,2)
When SF-Paper1-Mark > 49 AND < 70
Add 1 to W-Examtable(1,3)
When SF-Paper1-Mark > 69
Add 1 to W-ExamTable(1,4)
End-Evaluate.

Ive got this far but I am sure I am not tackling the problem the right way. I think the Perform Varying should prehaps be used but dont know how to go about it.
Any help would be gratefully appreciated.
 
Hi CD,

Don't think you're on the right track. Let's take a look at your i/p file:

file
students
papers

What this says is: to process the file you have to process all the students in the file. To process a student you must process all the papers for the student.

This gives you insight into what control breaks you will need. Note, this approach can be used for a vast majority of batch (and some on-line) problems you'll be faced with in your career.

So from this you can construct a first-cut mainline that looks like this (written in pseudo code):

Code:
       1000-mainline.
           perf 8000-init
           perf 7000-1st-read
           if eof perf 9999-bad-term stop.
           perf 2000-proc-all-students until eof
           perf 6000-print-grade-summary
           perf 9000-good-term stop 
           .
       2000-proc-all-students.
           perf 3000-proc-all-grades-for-student
                until student-is-finished
           .

       3000-proc-all-grades-for-student.
           perf 3100-determ-grade-title
           perf 7100-get-nxt-ip-rec
           .
       3100-determ-grade-title.
      *===> here's where your table processing is done.
      *===> give it a try and let me know what you come up
      *===> with. Hint: its a 2 dimen table.

Other ques you can ask yourself: Why do I do that 1st read outside the loop? How do I determine when student-is-finished? What happens if P# 2000- is left as written? Why do I need P# 2000-; it doesn't do anything?  This approach may confuse you at first, but stay with it; it's worth the  effort.

Regards, Jack.
 
Cheers Jack thats helped me a bit. I'll give it a go.

CobolDummy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top