How do I set my program up to read a variable length KSDS file? I am using Enterprise COBOL for z/os.I want to read a variable length KSDS sequentially. My program reads the first 3 records successfully and then gets a file status of 04 - wrong length record. The longest record can be 1018 bytes.I have the following code :
Code:
SELECT CUSTMSTR-FILE
ASSIGN TO CUSTMSTR
ACCESS MODE IS SEQUENTIAL
ORGANIZATION IS INDEXED
RECORD KEY IS CUSTMSTR-REC-KEY
FILE STATUS IS CUSTMSTR-STATUS
CUSTMSTR-VSAM-STATUS.
FILE SECTION.
FD CUSTMSTR-FILE
RECORD IS VARYING
DEPENDING ON WS-CUSTMSTR-LENGTH.
01 CUSTMSTR-RECORD.
03 CUSTMSTR-REC-KEY PIC X(66).
03 CUSTMSTR-DATA PIC X(952).
WORKING-STORAGE SECTION.
01 WS-CUSTMSTR-LENGTH PIC 9(04) COMP.
.....
READ CUSTMSTR-FILE
AT END
SET END-OF-FILE TO TRUE
END-READ.
IF END-OF-FILE
CONTINUE
ELSE
EVALUATE CUSTMSTR-STATUS
WHEN '00'
INITIALIZE CIRMISC
MOVE CUSTMSTR-REC-KEY TO CIRMISC-REC-KEY
PERFORM C010-WRITE-CIKMISC
WHEN '10'
CONTINUE
WHEN OTHER
MOVE CUSTMSTR-VSAM-STATUS TO VSAM-STATUS
PERFORM VSAM-CODE-DISPLAY
END-EVALUATE
end-if.