View previous topic :: View next topic
|
Author |
Message |
Amit tandon Warnings : 1 New User
Joined: 29 Jul 2010 Posts: 6 Location: mumbai
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
|