I seem to have yet another problem dealing with COBOL. My teacher has assigned us with having to take a file of names and make it into two columns going 54 rows down. I thought this was going to be simple as I looked in the book as it was more or less using a new function to do what I had all ready been doing, but once I got home and put down my code it all went to heck. Th program I made, for some reason unknown to me, only writes one name in the first column of row one and the does the same ever 54 rows. I am obviously on the wrong track but in my mind it looks right. Here is what I got:
WORKING-STORAGE SECTION.
01 ARE-THERE-MORE-RECORDS PIC X(3) VALUE 'YES'.
01 REPORT-START PIC X VALUE 'Y'.
01 LINE-COUNT PIC 99 VALUE ZEROS.
01 PAGE-NUMBER PIC 99 VALUE ZEROS.
01 NAME-COUNT PIC 9(3) VALUE ZEROS.
01 WORK-AREA-1.
05 N-COLUMN-1 PIC 99 VALUE ZEROS.
01 WORK-AREA-2.
05 N-COLUMN-2 PIC 9(3) VALUE 54.
01 NAME-STORAGE.
05 NAME-STO OCCURS 108 TIMES PIC X(30).
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(32) VALUE SPACES.
05 PIC X(16)
VALUE 'NAME LIST REPORT'.
05 PIC X(6) 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(4) VALUE SPACES.
05 PAGE-1 PIC X(4) VALUE 'PAGE'.
05 PIC X(1) VALUE SPACES.
05 NUMBER-PAGE PIC Z9.
01 DETAIL-LINE.
05 BLANK-A-OUT PIC X(4) VALUE SPACES.
05 DL-COLUMN-1 PIC X(30).
05 BLANK-E-OUT PIC X(20) VALUE SPACES.
05 DL-COLUMN-2 PIC X(30).
PROCEDURE DIVISION.
100-MAIN.
OPEN INPUT NAMELIST-FILE-IN
OPEN OUTPUT NAMELIST-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
PERFORM 200-NEXT-PAGE
PERFORM UNTIL ARE-THERE-MORE-RECORDS = 'NO '
READ NAMELIST-FILE-IN
AT END
MOVE 'NO ' TO ARE-THERE-MORE-RECORDS
NOT AT END
PERFORM 300-STORE-NAME
END-READ
END-PERFORM
CLOSE NAMELIST-FILE-IN
CLOSE NAMELIST-FILE-OUT
STOP RUN.
200-NEXT-PAGE.
开发者_C百科 ADD 1 TO PAGE-NUMBER
MOVE PAGE-NUMBER TO NUMBER-PAGE
MOVE HEADING-LINE-1 TO NAMELIST-RECORD-OUT
IF REPORT-START = 'N'
WRITE NAMELIST-RECORD-OUT
AFTER ADVANCING PAGE
ELSE
MOVE 'N' TO REPORT-START
WRITE NAMELIST-RECORD-OUT
AFTER ADVANCING 1 LINE
END-IF.
MOVE ZEROS TO LINE-COUNT.
300-STORE-NAME.
ADD 1 TO NAME-COUNT
MOVE NAME-IN TO NAME-STORAGE
IF NAME-COUNT > 54
PERFORM 400-PROCESS-FILE
END-IF.
400-PROCESS-FILE.
IF LINE-COUNT >= 52
PERFORM 200-NEXT-PAGE
END-IF
ADD 1 TO LINE-COUNT
ADD 1 TO N-COLUMN-1
ADD 1 TO N-COLUMN-2
MOVE NAME-STO (N-COLUMN-1) TO DL-COLUMN-1
MOVE NAME-STO (N-COLUMN-2) TO DL-COLUMN-2
MOVE DETAIL-LINE TO NAMELIST-RECORD-OUT
WRITE NAMELIST-RECORD-OUT
AFTER ADVANCING 1 LINE
IF N-COLUMN-2 = 108
MOVE 0 TO NAME-COUNT
MOVE 0 TO N-COLUMN-1
MOVE 54 TO N-COLUMN-2
END-IF.
This is not all I have to do, but until I figure this out I cannot continue.
I'm not familiar with this dialect of COBOL, but i thnk the problem is with:
MOVE NAME-IN TO NAME-STORAGE
I t should look like this:
MOVE NAME-IN TO NAME-STO OF NAME-STORAGE(NAME-COUNT)
Am i right am i wrong or am i just dreaming?
精彩评论