IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Fetch records from flat file which match with those of KSDS


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vinay kashyap

New User


Joined: 13 Aug 2008
Posts: 5
Location: US, california

PostPosted: Mon Sep 15, 2008 2:44 pm
Reply with quote

hi,
i got two files. one flat and the other is a KSDS. i have to fetch those records from flat file which match with those of KSDS. so every time i read a record from flat file do i need to open/close the KSDS in order to point to the first record? or isnt it necessary?
am new to KSDS concept.
Back to top
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Mon Sep 15, 2008 4:01 pm
Reply with quote

Hi Vinay,

Welcome to forum

Quote:
every time i read a record from flat file do i need to open/close the KSDS in order to point to the first record? or isnt it necessary?


It is not necessary to open/close KSDS File every time

Implement logic this way.

1. Read record from flat file sequentially(put it in loop till end of file).
2. Read randomly record from KSDS File for each record of Flat file
3. Check out status code ie record were present in KSDS File
4. If yes; Process how ever u want If not; By pass that record and next record from flat file

Hope this helps
Back to top
View user's profile Send private message
vinay kashyap

New User


Joined: 13 Aug 2008
Posts: 5
Location: US, california

PostPosted: Mon Sep 15, 2008 8:23 pm
Reply with quote

thanks revel,
i tried opening the KSDS , but am not able to.
The open , itself is failing with a VSAM return code of "39".
i guess , the above return code is for file attribute mismatch,but am not able to figure out where exactly the mismatch is occuring.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Sep 15, 2008 8:34 pm
Reply with quote

You need to compare a LISTCAT of the VSAM file with the COBOL definition you have provided of the file. There's a mismatch somewhere, and the manual suggests some good starting points:

Quote:
These attributes include
the organization of the file
(sequential, relative, or indexed), the
prime record key, the alternate record
keys, the code set, the maximum record
size, the record type (fixed or
variable), and the blocking factor.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Sep 15, 2008 8:54 pm
Reply with quote

if it is an existing vsam file that is used in production,
any good shop will already have copybooks to define the records.
Most probably, there exists at least 1 batch program that accesses the vsam file.
copy the fd statements from a batch program that works.............................
Back to top
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Tue Sep 16, 2008 9:15 am
Reply with quote

Hi Vinay,

Check as Robert said; The VSAM File attributes may mismatch with the Attributes which you mentioned in Application program(its attribute mismatch).


Check it out fallowing info

Code:
The OPEN statement was unsuccessful because a conflict was detected between the fixed file attributes and the attributes specified for that file in the program. These attributes include the organization of the file (sequential, relative, or indexed), the prime record key, the alternate record keys, the code set, the maximum record size, the record type (fixed or variable), and the blocking factor.
Back to top
View user's profile Send private message
vinay kashyap

New User


Joined: 13 Aug 2008
Posts: 5
Location: US, california

PostPosted: Tue Sep 16, 2008 10:12 am
Reply with quote

yeah.. it an existing VSAM , but it is in my PDS

My fd section is as follows
FILE-CONTROL.
SELECT IN-FILE1 ASSIGN TO INFILE1R.
SELECT IN-FILE2 ASSIGN TO INFILE2R
ORGANIZATION IS INDEXED
ACCESS IS SEQUENTIAL
FILE STATUS IS VSAM-FILE-1-STATUS
RECORD KEY IS IN-FILE2-REC-KEY
SELECT OUT-FILE ASSIGN TO OUTFILEW.

and am trying to open in the following way
OPEN INPUT IN-FILE2.

IF NOT VSAM-OPEN-SUCCESS
MOVE VSAM-FILE-STATUS TO FILE-STATUS
DISPLAY FILE-STATUS-ABEND-MESSAGE
GO TO 1000-END-JOB
END-IF.
"VSAM-OPEN-SUCCESS" has been included in the copybook.


Am getting an RC of 39
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Tue Sep 16, 2008 10:36 am
Reply with quote

Check the size of the VSAM file record and your FD entry ...
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Sep 16, 2008 11:05 am
Reply with quote

vinay kashyap wrote:
yeah.. it an existing VSAM , but it is in my PDS
I'm stumped, please clarify.
Back to top
View user's profile Send private message
vinay kashyap

New User


Joined: 13 Aug 2008
Posts: 5
Location: US, california

PostPosted: Tue Sep 16, 2008 1:00 pm
Reply with quote

hi anuj,
I meant to say thaat the VSAM is in my personal location and its not in production . sorry for the mis communication..

in my FD section , i have given only FD IN-FILE2 and defined its record layout.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Sep 16, 2008 1:08 pm
Reply with quote

Quote:
in my FD section , i have given only FD IN-FILE2 and defined its record layout
Vinay,

Do you find any difference in file-attributes mentioned in FD and your actual dataset attributes. As suggested earlier, Compare the COBOL FD, JCL DD card and the LISTCAT output to find out the mismatch.

Thanks,
Arun
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top