DOUBLE CONTROL-BREAK
ALGORITHM
FD input-file. 01
input-rec. 05 rank-in pic 99. 05 college-in pic xxx. 05 filler pic x.
cbval1 = first control break input field value (rank)
cbval2 = second control break input field value (college)
temp1 = temporary variable for holding previous cbval1
temp2 = temporary variable for holding previous cbval2
record length = 6
Data: 04BUS 04BUS 04ENG 04ENG 04ESL 03ESL 03MIS 03MIS 02GYM 01ENG 01ENG
Problem: how many students of each rank then within each rank, how many students in each college; also keep track of total number of students
****************************************************************************
set total number of students to 0
set rank number of students to 0
set college number of students to 0
read one record from input file
if not end of file
save cbval1 to temp1
save cbval2 to temp2
end if
loop until end of file
add 1 to total students
if temp1 not equal to cbval1 (end of rank is automatically end of college; order matters!)
do college control break information
write number of college students
set college number of students to 0
move cbval2 to temp2
do rank control break information
write number of rank students
set rank number of students to 0
move cbval1 to temp1
end if
if temp2 not equal to cbval2
do college control break information (see above)
end-if
work with current input record information
add 1 to rank number of students
add 1 to college number of students
read one record from input file
end loop
if total students > 0
output last control break information (rank and college)
output other total information (total number of students)
end if
etc…
OPTIONS…