FILE-CONTROL.
SELECT FILE1 ASSIGN TO IN1.
SELECT FILE2 ASSIGN TO IN2.
SELECT FILE3 ASSIGN TO OUT1.
SELECT FILE4 ASSIGN TO OUT2.
DATA DIVISION.
FILE SECTION.
FD FILE1
BLOCK CONTAINS 0 RECORDS
RECORDING MODE IS F.
01 IN-FILE1-REC.
05 WS-NUM1 PIC X(02) VALUE ZERO.
05 FILLER PIC X(78) VALUE SPACES.
FD FILE2
BLOCK CONTAINS 0 RECORDS
RECORDING MODE IS F.
01 IN-FILE2-REC.
05 WS-NUM2 PIC X(02) VALUE ZERO.
05 FILLER PIC X(78) VALUE SPACES.
FD FILE3
BLOCK CONTAINS 0 RECORDS
RECORDING MODE IS F.
01 OUT-FILE3-REC PIC X(80).
FD FILE4
BLOCK CONTAINS 0 RECORDS
RECORDING MODE IS F.
01 OUT-FILE4-REC PIC X(80).
WORKING-STORAGE SECTION.
01 WS-EOF-SW PIC X.
88 EOF1 VALUE 'Y'.
01 WS-EOF2-SW PIC X.
88 EOF2 VALUE 'Y'.
/
PROCEDURE DIVISION.
0000-MAINLINE.
DISPLAY '0000-MAINLINE'.
PERFORM 0001-OPENING.
PERFORM 0002-READF1
PERFORM 0006-CLOSING.
0001-OPENING.
DISPLAY '0001-OPENING'.
OPEN INPUT FILE1
FILE2
OUTPUT FILE3
FILE4.
0002-READF1.
DISPLAY '0002-READF1'.
READ FILE1
AT END
SET EOF1 TO TRUE
NOT AT END
DISPLAY 'WS-NUM1' WS-NUM1.
PERFORM 0003-COMPARE
0003-COMPARE.
DISPLAY '0003-COMPARE'.
READ FILE2
AT END
SET EOF2 TO TRUE
PERFORM 0005-WRITEF4
NOT AT END
DISPLAY 'WS-NUM1' WS-NUM1
DISPLAY 'WS-NUM2' WS-NUM2
IF WS-NUM1 = WS-NUM2
PERFORM 0004-WRITEF3
DISPLAY 'WS-NUM2' WS-NUM2
END-IF.
0004-WRITEF3.
DISPLAY '0004-WRITEF3'.
MOVE WS-NUM1 TO OUT-FILE3-REC
DISPLAY 'FILE3' OUT-FILE3-REC
WRITE OUT-FILE3-REC
IF NOT EOF1
PERFORM 0002-READF1
ELSE
PERFORM 0006-CLOSING
GOBACK.
0005-WRITEF4.
DISPLAY '0005-WRITEF4'.
MOVE WS-NUM1 TO OUT-FILE4-REC.
DISPLAY 'FILE4' OUT-FILE4-REC
WRITE OUT-FILE4-REC
IF NOT EOF1
PERFORM 0002-READF1
ELSE
PERFORM 0006-CLOSING
GOBACK.
0006-CLOSING.
DISPLAY '0006-CLOSING'.
CLOSE FILE1
FILE2
FILE3
FILE4.
DISPLAY 'CLOSE'
GOBACK.
答案 0 :(得分:1)
正如Bill所说使用PERFORM 循环!!!
为了方便你,你的程序就像:
perform read-input-file
perform until eof
...
perform read-input-file
end-perform.
我建议Google使用像perform until eof
这样的东西This是我在快速搜索中找到的最好的例子。