Read VSAM



Unicenter CA-Easytrieve Plus Report Generator: CA's information retrieval and data management tool

Read VSAM

Postby Kitz » Mon Nov 02, 2015 3:42 am

Hi,

I am trying to select the matching records from the vsam file based on the key.
Its numeric of 12 length. When I run this program...it does not return any error. But for some reasons, its not able to match any records from the VSAM file (but there are matching records).

key in the vsam file:
sort code 6
account number 8
seq no 1



It displays in the log as
example:
121212121212NOT FOUND
141212121212NOT FOUND
121312121212NOT FOUND


Could you please advise what could be problem?

//SYSIN DD *
LIST ON
 FILE FILE1 FB(80 *)
   IN-REC 1 80 A
   IN-KEY 1 15 A
 FILE FILE2 VS
   F2-REC 1 124 A
   F2-KEY 1 15 A
   F2-VALUE 16 30 A
 FILE OUTFILE FB(80 *)
   OUT-REC 1 80 A
   OUT-KEY 1 15 A
   OUT-VALUE 20 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 FOUND'
   END-IF
   GET FILE1
 END-DO
 STOP


Code'd
Kitz
 
Posts: 47
Joined: Thu Mar 17, 2011 3:46 am
Has thanked: 0 time
Been thanked: 1 time

Re: Read VSAM

Postby BillyBoyo » Mon Nov 02, 2015 12:52 pm

That output is not from that program. The output shows 12 bytes of key, the key is 15 bytes.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Read VSAM

Postby Kitz » Mon Nov 02, 2015 4:48 pm

ah, sorry... I missed to enter them

121212121212121NOT FOUND
141212121212121NOT FOUND
121312121212121NOT FOUND
Kitz
 
Posts: 47
Joined: Thu Mar 17, 2011 3:46 am
Has thanked: 0 time
Been thanked: 1 time

Re: Read VSAM

Postby Kitz » Wed Nov 04, 2015 4:21 am

Hi Billy,

I just got the original copybook and found that the VSAM key are:
S code - s9(12) comp-3
Ac no - s9(16) comp-3
ser no- s9(1) comp-3

I think since the comparing key of VSAM is in packed decimal, and so its not matching with the numeric key in FILE1.

1. Is it possible to compare the complete key of the VSAM together or do I need to compare each field separately? Please suggest.
2. Could you please advise how do I compare a numeric field with a Packed decimal?
Kitz
 
Posts: 47
Joined: Thu Mar 17, 2011 3:46 am
Has thanked: 0 time
Been thanked: 1 time

Re: Read VSAM

Postby Robert Sample » Wed Nov 04, 2015 4:48 am

I think you first need to dump a few records from the VSAM data set and verify the key. S9(12) COMP-3 will require 7 bytes, not 6, to store and S9(16) COMP-3 will require 9 bytes, not 8, to store. So instead of having 3 fields of 6, 8, 1 bytes for a total key length of 15 you have 7, 9, 1 bytes for a total key length of 17. There is something wrong since you are sure the key length is 15. I suspect the key fields are actually S9(11) COMP-3 and S9(15) COMP-3 which would have lengths of 6 and 8 bytes, respectively.

In any case, you will need to compare each field separately since they are packed decimal. Assuming you do have 6, 8, 1 bytes of packed decimal you will need to define variables as W 6 P, W 8 P, and W 1 P for the packed decimal values you want to compare your key to.

Your question 2 makes no sense -- a packed decimal value IS numeric so comparing a numeric field to a packed decimal field is not really a question; it's more the way the system works. If you use the P modifier on your variables, they will be packed decimal and you won't have to think about the numeric to packed decimal comparison.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Read VSAM

Postby Kitz » Thu Nov 05, 2015 3:03 am

That worked. Thanks Robert and Billy Boyo.
Kitz
 
Posts: 47
Joined: Thu Mar 17, 2011 3:46 am
Has thanked: 0 time
Been thanked: 1 time


Return to CA-Easytrieve

 


  • Related topics
    Replies
    Views
    Last post