The below pasted cobol code is executing and ending with file status 46.
****** ***************************** Top of Data ******************************
000001 IDENTIFICATION DIVISION.
000002 PROGRAM-ID. EXTBAC01.
000003
000004 ENVIRONMENT DIVISION.
000005 INPUT-OUTPUT SECTION.
000006 FILE-CONTROL.
000007 SELECT I1-FILE ASSIGN TO I1FILE.
000008 SELECT I2-FILE ASSIGN TO I2FILE.
000009 SELECT O1-FILE ASSIGN TO O1FILE.
000010
000011 DATA DIVISION.
000012 FILE SECTION.
000013 FD I1-FILE
000014 LABEL RECORDS ARE STANDARD
000015 RECORDING MODE IS F.
000016 01 I1-FILE-REC PIC X(80).
000017
000018 FD I2-FILE
000019 LABEL RECORDS ARE STANDARD
000020 RECORDING MODE IS F.
000021 01 I2-FILE-REC PIC X(1048).
000022
000023 FD O1-FILE
000024 LABEL RECORDS ARE STANDARD
000025 RECORDING MODE IS F.
000026 01 O1-FILE-REC PIC X(1048).
000027
000028 WORKING-STORAGE SECTION.
000029 01 WS-EOF-1 PIC X(01) VALUE SPACE.
000030 01 WS-EOF-2 PIC X(01) VALUE SPACE.
000031
000032 01 WS-IN1-REC.
000033 05 WS-UNQ-NBR-1 PIC X(07) VALUE SPACE.
000034 05 FILLER PIC X(73) VALUE SPACE.
000035
000036 01 WS-IN2-REC.
000037 05 WS-REC-TYPE PIC X(02) VALUE SPACE.
000038 05 FILLER PIC X(03) VALUE SPACE.
000039 05 WS-UNQ-NBR-2 PIC X(07) VALUE SPACE.
000040 05 FILLER PIC X(42) VALUE SPACE.
000041 05 WS-BAC PIC X(06) VALUE SPACE.
000042 05 FILLER PIC X(988) VALUE SPACE.
000043
000044 PROCEDURE DIVISION.
000045 01-MAIN-PARA.
000046 DISPLAY '01-MAIN-PARA'.
000047 PERFORM 02-OPEN-PARA.
000048 PERFORM 03-READ-PARA.
000049 PERFORM 04-READ-PARA.
000050 PERFORM 05-PERF-PARA UNTIL WS-EOF-1 = 'Y'
000051 AND WS-EOF-2 = 'Y'.
000052 PERFORM 07-CLOS-PARA.
000053 STOP RUN.
000054
000055 02-OPEN-PARA.
000056 DISPLAY '02-OPEN-PARA'.
000057 OPEN INPUT I1-FILE
000058 INPUT I2-FILE
000059 OUTPUT O1-FILE.
000060
000061 03-READ-PARA.
000062 DISPLAY '03-READ-PARA'.
000063 READ I1-FILE INTO WS-IN1-REC
000064 AT END MOVE 'Y' TO WS-EOF-1
000065 MOVE SPACE TO WS-UNQ-NBR-1
000066 END-READ.
000067
000068 04-READ-PARA.
000069 DISPLAY '04-READ-PARA'.
000070 READ I2-FILE INTO WS-IN2-REC
000071 AT END MOVE 'Y' TO WS-EOF-2
000072 MOVE SPACE TO WS-UNQ-NBR-2
000073 END-READ.
000074
000075 05-PERF-PARA.
000076 DISPLAY '05-PERF-PARA'.
000077 EVALUATE TRUE
000078 WHEN WS-UNQ-NBR-1 = WS-UNQ-NBR-2
000079 PERFORM 06-WRIT-PARA
000080 PERFORM 03-READ-PARA
000081 PERFORM 04-READ-PARA
000082 WHEN WS-UNQ-NBR-1 < WS-UNQ-NBR-2
000083 DISPLAY 'LESS THAN KEY'
000084 PERFORM 03-READ-PARA
000085 WHEN WS-UNQ-NBR-1 > WS-UNQ-NBR-2
000086 DISPLAY 'GREATER THAN KEY'
000087 PERFORM 04-READ-PARA
000088 END-EVALUATE.
000089
000090 06-WRIT-PARA.
000091 DISPLAY '06-WRIT-PARA'.
000092 MOVE SPACE TO O1-FILE-REC
000093 MOVE I2-FILE-REC TO O1-FILE-REC
000094 WRITE O1-FILE-REC.
000095
000096 07-CLOS-PARA.
000097 DISPLAY '06-CLOS-PARA'.
000098 CLOSE I1-FILE
000099 I2-FILE
000100 O1-FILE.
****** **************************** Bottom of Data ****************************
000001 IDENTIFICATION DIVISION.
000002 PROGRAM-ID. EXTBAC01.
000003
000004 ENVIRONMENT DIVISION.
000005 INPUT-OUTPUT SECTION.
000006 FILE-CONTROL.
000007 SELECT I1-FILE ASSIGN TO I1FILE.
000008 SELECT I2-FILE ASSIGN TO I2FILE.
000009 SELECT O1-FILE ASSIGN TO O1FILE.
000010
000011 DATA DIVISION.
000012 FILE SECTION.
000013 FD I1-FILE
000014 LABEL RECORDS ARE STANDARD
000015 RECORDING MODE IS F.
000016 01 I1-FILE-REC PIC X(80).
000017
000018 FD I2-FILE
000019 LABEL RECORDS ARE STANDARD
000020 RECORDING MODE IS F.
000021 01 I2-FILE-REC PIC X(1048).
000022
000023 FD O1-FILE
000024 LABEL RECORDS ARE STANDARD
000025 RECORDING MODE IS F.
000026 01 O1-FILE-REC PIC X(1048).
000027
000028 WORKING-STORAGE SECTION.
000029 01 WS-EOF-1 PIC X(01) VALUE SPACE.
000030 01 WS-EOF-2 PIC X(01) VALUE SPACE.
000031
000032 01 WS-IN1-REC.
000033 05 WS-UNQ-NBR-1 PIC X(07) VALUE SPACE.
000034 05 FILLER PIC X(73) VALUE SPACE.
000035
000036 01 WS-IN2-REC.
000037 05 WS-REC-TYPE PIC X(02) VALUE SPACE.
000038 05 FILLER PIC X(03) VALUE SPACE.
000039 05 WS-UNQ-NBR-2 PIC X(07) VALUE SPACE.
000040 05 FILLER PIC X(42) VALUE SPACE.
000041 05 WS-BAC PIC X(06) VALUE SPACE.
000042 05 FILLER PIC X(988) VALUE SPACE.
000043
000044 PROCEDURE DIVISION.
000045 01-MAIN-PARA.
000046 DISPLAY '01-MAIN-PARA'.
000047 PERFORM 02-OPEN-PARA.
000048 PERFORM 03-READ-PARA.
000049 PERFORM 04-READ-PARA.
000050 PERFORM 05-PERF-PARA UNTIL WS-EOF-1 = 'Y'
000051 AND WS-EOF-2 = 'Y'.
000052 PERFORM 07-CLOS-PARA.
000053 STOP RUN.
000054
000055 02-OPEN-PARA.
000056 DISPLAY '02-OPEN-PARA'.
000057 OPEN INPUT I1-FILE
000058 INPUT I2-FILE
000059 OUTPUT O1-FILE.
000060
000061 03-READ-PARA.
000062 DISPLAY '03-READ-PARA'.
000063 READ I1-FILE INTO WS-IN1-REC
000064 AT END MOVE 'Y' TO WS-EOF-1
000065 MOVE SPACE TO WS-UNQ-NBR-1
000066 END-READ.
000067
000068 04-READ-PARA.
000069 DISPLAY '04-READ-PARA'.
000070 READ I2-FILE INTO WS-IN2-REC
000071 AT END MOVE 'Y' TO WS-EOF-2
000072 MOVE SPACE TO WS-UNQ-NBR-2
000073 END-READ.
000074
000075 05-PERF-PARA.
000076 DISPLAY '05-PERF-PARA'.
000077 EVALUATE TRUE
000078 WHEN WS-UNQ-NBR-1 = WS-UNQ-NBR-2
000079 PERFORM 06-WRIT-PARA
000080 PERFORM 03-READ-PARA
000081 PERFORM 04-READ-PARA
000082 WHEN WS-UNQ-NBR-1 < WS-UNQ-NBR-2
000083 DISPLAY 'LESS THAN KEY'
000084 PERFORM 03-READ-PARA
000085 WHEN WS-UNQ-NBR-1 > WS-UNQ-NBR-2
000086 DISPLAY 'GREATER THAN KEY'
000087 PERFORM 04-READ-PARA
000088 END-EVALUATE.
000089
000090 06-WRIT-PARA.
000091 DISPLAY '06-WRIT-PARA'.
000092 MOVE SPACE TO O1-FILE-REC
000093 MOVE I2-FILE-REC TO O1-FILE-REC
000094 WRITE O1-FILE-REC.
000095
000096 07-CLOS-PARA.
000097 DISPLAY '06-CLOS-PARA'.
000098 CLOSE I1-FILE
000099 I2-FILE
000100 O1-FILE.
****** **************************** Bottom of Data ****************************
Would you please suggest where I am wrong here.
Thanks.