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

update VSAM KSDS file


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Amit tandon
Warnings : 1

New User


Joined: 29 Jul 2010
Posts: 6
Location: mumbai

PostPosted: Tue Mar 29, 2011 11:02 pm
Reply with quote

Hi all,

I have to update vsam ksds file with records based on flat file.

ex:-
flat file I have company code(input file)
01
02
03

and based on company code I need to update account no
like
01 32444
02 26666
03 99999

key is account no (not 01,02,03)

I'm reading like below

read input-file
at end
move 'y' to eof
not at end
move fs-recodrs to ws-records

fs records from input file

in output I need which company code and acount no get updated

output would be like

01 32444
02 26666
03 99999

The problem is reading sequentally read and sequentally update.
My output file is gettng only one record not all 3 .

could you please help me out of this problem

Thanks,
Amit
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Tue Mar 29, 2011 11:24 pm
Reply with quote

Well, I'm not a programmer, but it looks to me as if you'd read one record from the update dataset, start reading the VSAM dataset until you get a hit on the Company Code, update that record, and continue on (presuming there are other records with a matching Company Code). Then, you'll have to return the pointer back to the beginning on the VSAM dataset, read the next update record, and repeat the process.
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: Tue Mar 29, 2011 11:28 pm
Reply with quote

You're not exactly giving us much to work with, are you? The logic for this is well known:
- Read a sequential record
- Use the key to directly read the VSAM record
- Update the data on the VSAM record
- Rewrite the VSAM record
- Output sequential record (if needed) identifying the change
- Repeat from read until EOF on sequential file

So you have 3 DD statements (sequential input, sequential output report, and VSAM KSDS) with 3 SELECT statements, 3 OPEN, etc.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed Mar 30, 2011 2:32 am
Reply with quote

Robert, maybe I misunderstood, but I thought that the poster's indication that the information in the update dataset is not based on the key would mean a brute-force type of approach to this problem, since the key values are unknown ahead of time.
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: Wed Mar 30, 2011 2:59 am
Reply with quote

Actually, after re-reading the original post, I'm no longer sure it is even possible as stated:
Quote:
and based on company code I need to update account no
like
01 32444
02 26666
03 99999

key is account no (not 01,02,03)
Another post where someone posted without thinking through the problem and did not tell us exactly what is needed.

Amit tandon: post exactly what your input looks like, what the layout of the VSAM file is, a few sample input records and what each of them should do to the VSAM file and what you want for output (if any) other than the VSAM file changes. If you expect to update the VSAM file by changing the primary key values, the only way to do so is to delete the record with the old key and write the record with the new key.
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
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
Search our Forums:

Back to Top