tags:

views:

57

answers:

4

I am having a bit of a problem with my COBOL homework again. I think everything is how it is suppose to be, but for some reason I cannot get any output data when I run my program. All it does is show blank lines like someone just hit the enter key over and over. It really sucks cause I can't see if I am right or wrong. Here is my code:

   IDENTIFICATION DIVISION.
   PROGRAM-ID. BASEBALL-2.
  * Charles Hicks
  ******************************************************************
  *
  *    This program reads a file of Major League baseball player
  *    batting statistics and writes a report.
  *
  *
  ******************************************************************
   ENVIRONMENT DIVISION.
   INPUT-OUTPUT SECTION.
   FILE-CONTROL.

       SELECT BASEBALL-FILE-IN
           ASSIGN TO 'BASEBALL-2.SEQ'
           ORGANIZATION IS LINE SEQUENTIAL.

       SELECT BASEBALL-FILE-OUT
           ASSIGN TO 'BASEBALL-2.RPT'
           ORGANIZATION IS LINE SEQUENTIAL.

   DATA DIVISION.
   FILE SECTION.

   FD  BASEBALL-FILE-IN.
   01  BASEBALL-RECORD-IN.
       05  NAME-IN                 PIC X(18).
       05                          PIC XX.
       05  LEAGUE-IN               PIC XX.
       05                          PIC X.
       05  TEAM-IN                 PIC X(3).
       05                          PIC X(3).
       05  AT-BATS-IN              PIC 9(3).
       05                          PIC X.
       05  HITS-IN                 PIC 9(3).

   FD  BASEBALL-FILE-OUT.
   01  BASEBALL-RECORD-OUT         PIC X(80).

   WORKING-STORAGE SECTION.
   01  ARE-THERE-MORE-RECORDS      PIC X(3)  VALUE 'YES'.

   01 LINE-COUNT                   PIC 99    VALUE ZEROS.

   01  WS-DATE.
       05  RUN-YEAR                PIC XX.
       05  RUN-MONTH               PIC XX.
       05  RUN-DAY                 PIC XX.
   01  HEADING-LINE-1.
       05                          PIC X(24) VALUE SPACES.
       05                          PIC X(26)
           VALUE 'BASEBALL PLAYER STATISTICS'.
       05                          PIC X(12) VALUE SPACES.
       05  HL-1-DATE.
           10  MONTH-2             PIC XX.
           10                      PIC X      VALUE '/'.
           10  DAY-2               PIC XX.
           10                      PIC X      VALUE '/'.
           10  YEAR-2              PIC XX.
       05                          PIC X(6)   VALUE SPACES.
       05  PAGE-1                  PIC X(4)   VALUE 'PAGE'.

   01  HEADING-LINE-2.
       05                          PIC X(6)   VALUE 'LEAGUE'.
       05                          PIC X(3)   VALUE SPACES.
       05                          PIC X(4)   VALUE 'TEAM'.
       05                          PIC X(5)   VALUE SPACES.
       05                          PIC X(4)   VALUE 'NAME'.
       05                          PIC X(10)  VALUE SPACES.
       05                          PIC X(4)   VALUE 'HITS'.
       05                          PIC X(6)   VALUE SPACES.
       05                          PIC X(7)   VALUE 'AT BATS'.
   01  DETAIL-LINE.
       05 BLANK-A-OUT              PIC X      VALUE SPACES.
       05 DL-LEAGUE                PIC XX.
       05 BLANK-B-OUT              PIC X(3)   VALUE SPACES.
       05 DL-TEAM                  PIC X(3).
       05 BLANK-C-OUT              PIC X(3)   VALUE SPACES.
       05 DL-NAME                  PIC X(10).
       05 BLANK-D-OUT              PIC X(3)   VALUE SPACES.
       05 DL-HITS                  PIC ZZ9.
       05 BLANK-E-OUT              PIC X(3)   VALUE SPACES.
       05 DL-AT-BATS               PIC ZZ9.

   PROCEDURE DIVISION.
   100-MAIN.
       OPEN INPUT BASEBALL-FILE-IN
       OPEN OUTPUT BASEBALL-FILE-OUT

       ACCEPT WS-DATE FROM DATE
       MOVE RUN-MONTH TO MONTH-2
       MOVE RUN-DAY TO DAY-2
       MOVE RUN-YEAR TO YEAR-2
       WRITE BASEBALL-RECORD-OUT

       PERFORM UNTIL ARE-THERE-MORE-RECORDS = 'NO '
           READ BASEBALL-FILE-IN
               AT END
                   MOVE 'NO ' TO ARE-THERE-MORE-RECORDS
               NOT AT END
                   PERFORM 200-PROCESS-ONE-RECORD
           END-READ
       END-PERFORM

       CLOSE BASEBALL-FILE-IN
       CLOSE BASEBALL-FILE-OUT
       STOP RUN.


   200-PROCESS-ONE-RECORD.
       MOVE LEAGUE-IN TO DL-LEAGUE
       MOVE SPACES TO BLANK-A-OUT
       MOVE TEAM-IN TO DL-TEAM
       MOVE SPACES TO BLANK-B-OUT
       MOVE NAME-IN TO DL-NAME
       MOVE SPACES TO BLANK-C-OUT
       MOVE HITS-IN TO DL-HITS
       MOVE SPACES TO BLANK-D-OUT
       MOVE AT-BATS-IN TO DL-AT-BATS
       MOVE SPACES TO BLANK-E-OUT
       WRITE BASEBALL-RECORD-OUT
           AFTER ADVANCING 2 LINES.

   300-LINE.
       IF  LINE-COUNT >= 50
           PERFORM 400-NEXT-PAGE
       END-IF
       WRITE BASEBALL-RECORD-OUT
           AFTER ADVANCING 1 LINE
       ADD 1 TO LINE-COUNT.

   400-NEXT-PAGE.
       WRITE BASEBALL-RECORD-OUT
           AFTER ADVANCING PAGE
       MOVE ZEROS TO LINE-COUNT.
A: 

It's been a while since I touched Cobol but you are probably missing updating BASEBALL-RECORD-OUT.

Klinger
A: 

You have to move HEADING-LINE-1, HEADING-LINE-2, and DETAIL-LINE to BASEBALL-RECORD-OUT before you WRITE BASEBALL-RECORD-OUT.

Gilbert Le Blanc
A: 

You are never moving the data you read from BASEBALL-2.SEQ into the record used to write BASEBALL-2.RPT.

You can do something like

* WRITE THE HEADER INFO
MOVE HEADING-LINE-1 TO BASEBALL-RECORD-OUT 
WRITE BASEBALL-RECORD-OUT 

Or

WRITE BASEBALL-RECORD-OUT FROM HEADING-LINE-1

Similarly you can write the details line

* WRITE THE DETAIL
MOVE DETAIL-LINE TO BASEBALL-RECORD-OUT 
WRITE BASEBALL-RECORD-OUT 
bruno