Loading

Reading VSAM file in Easytrieve

Declaring VSAM:

 FILE FILE2 VS

Reading VSAM file by Key

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
 LIST ON
 FILE FILE1 FB(80 200)
   IN-REC 1 80 A
   IN-KEY 1 8 A
 FILE FILE2 VS
   F2-REC 1 80 A
   F2-KEY 1 8 A
   F2-VALUE 15 30 A
 FILE OUTFILE FB(80 200)
   OUT-REC 1 80 A
   OUT-KEY 1 8 A
   OUT-VALUE 10 30 A
 JOB INPUT NULL
 GET FILE1
 DO WHILE NOT EOF FILE1
   READ FILE2 KEY IN-KEY STATUS
   IF FILE2 : FILE-STATUS EQ 0
      MOVE IN-KEY TO OUT-KEY
      MOVE F2-VALUE TO OUT-VALUE
      PUT OUTFILE
   ELSE
      DISPLAY IN-KEY ' NOT PRESENT IN VSAM FILE'
   END-IF
   GET INFILE
 END-DO
 STOP

Related Posts




blog comments powered by Disqus

There's 2 Comments So Far

  •   Praveen
    July 25th, 2013 at 11:28 am

    How to read VSAM KSDS file using alternate key? What all the things we need to define and use in easytrieve program.

  •   Lakshmy
    November 29th, 2013 at 6:59 am

    Hi Karthik,

    Can you please answer the above query…evn I am also facing the same challenge…I need to read a VSAM file with its alternate key…..

Share your thoughts, leave a comment!