Raghavendra,Here you go. This code is really a simplest one to insert a record in a VSAM.
1. Run the below job and create a VSAM with some contents.
//STEP01 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DELETE (F3618TV.ARUN.TEST.VSAM) CL
IF MAXCC=8 THEN SET MAXCC=0
DEF CL (NAME (F3618TV.ARUN.TEST.VSAM)) -
DATA (NAME (F3618TV.ARUN.TEST.VSAM.D) -
RECSZ(80 80) CISZ(18432) KEYS(6 0) -
BUFSPC(80) CYL(1 1) FSPC(0 0)) -
INDEX (NAME (F3618TV.ARUN.TEST.VSAM.I) -
CISZ(512))
/*
//STEP02 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//VSAMIN DD *
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
129078 ARUN
129257 JANANI
/*
//VSAMOUT DD DSN=F3618TV.ARUN.TEST.VSAM,DISP=OLD
//SYSIN DD *
REPRO IFILE (VSAMIN) OFILE (VSAMOUT)
/*
2. Then compile, link-edit and run this program with a DD name
//VSAMIN DD DSN=F3618TV.ARUN.TEST.VSAM,DISP=MOD
Code: IDENTIFICATION DIVISION.
PROGRAM-ID. TESTPGM.
AUTHOR. ARUN.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INP-VSAM ASSIGN TO VSAMIN
ORGANIZATION IS INDEXED
ACCESS IS DYNAMIC
RECORD KEY IS EMP-ID
FILE STATUS IS FS-STATUS.
DATA DIVISION.
FILE SECTION.
FD INP-VSAM.
01 FILE-LAYOUT.
05 EMP-ID PIC X(06).
05 FILLER PIC X(01).
05 EMP-NAME PIC X(10).
WORKING-STORAGE SECTION.
01 FS-STATUS PIC X(02).
88 SUCCESSFUL-COMPLETION VALUE '00'.
SKIP3
PROCEDURE DIVISION.
MAINLINE.
OPEN I-O INP-VSAM.
IF SUCCESSFUL-COMPLETION
MOVE '123456' TO EMP-ID
MOVE 'PRASAD' TO EMP-NAME
WRITE FILE-LAYOUT
END-IF.
CLOSE INP-VSAM.
GOBACK.