Vsam file creation -
//VSAMKSDS JOB CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),PRTY=15,
// NOTIFY=&SYSUID
//STEP10 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE CLUSTER( -
NAME(RAHUL.KSDS.FILE) -
INDEXED -
KEYS(05 1) -
RECSZ(35 35) -
FREESPACE(10 20) -
TRACKS(50 30) -
CISZ(8192) -
VOLUME(ZASYS1))
/*
Records in file -
RBA Len 1<==5>..10....5...20....5...30....5..
0 35 12543rajjd jdhdjd 9876553
35 35 53221dfdffd jhsfhd 9778785
Getting error -
KSDSFL OPEN STATUS 39
KSDSFL CLOSE STATUS 42
My Cobol Program:-
IDENTIFICATION DIVISION.
PROGRAM-ID. KSDSPROG.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT KSDSFL ASSIGN TO INFLDD
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS EMP-ID
FILE STATUS IS RTCODE.
DATA DIVISION.
FILE SECTION.
FD KSDSFL.
01 KSDSFL-REC.
05 EMP-ID PIC X(05).
05 EMP-DESC PIC X(30).
WORKING-STORAGE SECTION.
01 RTCODE PIC X(02).
01 REC-OUT PIC X(35).
PROCEDURE DIVISION.
OPEN INPUT KSDSFL.
DISPLAY 'KSDSFL OPEN STATUS ' RTCODE.
MOVE '12345' TO EMP-ID
READ KSDSFL RECORD INTO REC-OUT
KEY IS EMP-ID
INVALID KEY
DISPLAY 'KEY IS INVALID'
NOT INVALID KEY
DISPLAY 'KEY IS VALID'
END-READ.
CLOSE KSDSFL.
DISPLAY 'KSDSFL CLOSE STATUS ' RTCODE.
STOP RUN.
No idea why I am getting the data mismatch issue. Program is compiling successfully but on running getting file-status 39. all field records are matched but still Issue not resolved. please help me to resolve it.
The data you provided shows a record length of 37. It should be 35.
I modified the question section for the record to make it code so there was a fixed width font as it was confusing me where the record lines up. If I made an error please correct.
Your key in the FD
section (EMP-ID
)starts in offset 0; it should be offset 1.
FILE SECTION.
FD KSDSFL.
01 KSDSFL-REC.
05 EMP-ID PIC X(05).
05 EMP-DESC PIC X(30).
change to
FILE SECTION.
FD KSDSFL.
01 KSDSFL-REC.
05 FILLER PIC X.
05 EMP-ID PIC X(05).
05 EMP-DESC PIC X(29).