FILE SECTION.
FD FILE1
LABEL RECORDS ARE STANDARD
BLOCK CONTAINS 0 RECORDS
RECORDING MODE F
DATA RECORD IS INPUT-REC.
01 INPUT-REC.
05 POLICY-NUMBER PIC X(20).
WORKING-STORAGE SECTION.
01 WS-STATUS-IN PIC 9(02) VALUE ZERO.
PROCEDURE DIVISION.
OPEN I-O FILE1.
IF WS-STATUS-IN = 0
DISPLAY 'OPEN SUCCES'
DISPLAY WS-STATUS-IN
ELSE
DISPLAY 'OPEN FAIL'
DISPLAY WS-STATUS-IN
END-IF.
READ FILE1.
IF WS-STATUS-IN = 0
DISPLAY 'READ SUCCESS'
DISPLAY INPUT-REC
ELSE
DISPLAY 'READ FAIL'
DISPLAY WS-STATUS-IN
END-IF.
MOVE '999999' TO INPUT-REC.
WRITE INPUT-REC.
IF WS-STATUS-IN = 0
DISPLAY 'WRITE SUCCESS'
ELSE
DISPLAY 'WRITE FAIL'
DISPLAY WS-STATUS-IN
END-IF.
CLOSE FILE1.
STOP RUN.
FD FILE1
LABEL RECORDS ARE STANDARD
BLOCK CONTAINS 0 RECORDS
RECORDING MODE F
DATA RECORD IS INPUT-REC.
01 INPUT-REC.
05 POLICY-NUMBER PIC X(20).
WORKING-STORAGE SECTION.
01 WS-STATUS-IN PIC 9(02) VALUE ZERO.
PROCEDURE DIVISION.
OPEN I-O FILE1.
IF WS-STATUS-IN = 0
DISPLAY 'OPEN SUCCES'
DISPLAY WS-STATUS-IN
ELSE
DISPLAY 'OPEN FAIL'
DISPLAY WS-STATUS-IN
END-IF.
READ FILE1.
IF WS-STATUS-IN = 0
DISPLAY 'READ SUCCESS'
DISPLAY INPUT-REC
ELSE
DISPLAY 'READ FAIL'
DISPLAY WS-STATUS-IN
END-IF.
MOVE '999999' TO INPUT-REC.
WRITE INPUT-REC.
IF WS-STATUS-IN = 0
DISPLAY 'WRITE SUCCESS'
ELSE
DISPLAY 'WRITE FAIL'
DISPLAY WS-STATUS-IN
END-IF.
CLOSE FILE1.
STOP RUN.
when I opened the file1 in I-O Mode and executing the program im getting the below result.
******
OPEN SUCCES
00
READ SUCCESS
999999
WRITE FAIL
48
*******
But when I opened FILE1 in EXTEND MODE / OUTPUT MODE. Im able to write the records in to FILE1 but not able to read the record.
How can I achieve both READ & WRITE in a single program.
Help would be appreciated.
Regards,
Sriraj K