View previous topic :: View next topic
|
Author |
Message |
hsk
New User
Joined: 28 Nov 2006 Posts: 69 Location: India
|
|
|
|
I have 3 files,
File1 - VSAM
File2 - VSAM
File3 - Flat
What i have to do is,
Read flat file
Search that record in VSAM files
If found then update Flat file with one field in VSAM file.
Is there any easy way, other than Cobol, to do this? |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Use REPLACE option in REPRO. It updates the existing member in vsam file as in flat file. But REMEMBER, it also adds the record to vsam file if that particular record is present in flat file and not in vsam file. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
I would guess that a programming solution will be the best bet.
I have assumed that your VSAM files are both KSDS.
This can be achieved in COBOL, SAS, even maybe with REXX using REPRO to check if exists and fetch the VSAM records.
Quote: |
Use REPLACE option in REPRO. It updates the existing member in vsam file as in flat file. But REMEMBER, it also adds the record to vsam file if that particular record is present in flat file and not in vsam file. |
This is NOT what the OP wants to do. The requirement is to update the flat file with one field from the VSAM file. |
|
Back to top |
|
|
hsk
New User
Joined: 28 Nov 2006 Posts: 69 Location: India
|
|
|
|
No the situation is little complex..
I have to update Flat file (Pos 30 to 33) with the value present in VSAM.
If i write COBOL what i will do is,
Read Flat file Seq.
Read VSAM File1 with Key(Value 1-7 in flat File)
If found
move vsam value to flat file and Rewrite Flat File
Else
Read VSAM File2 with Key
if found
move vsam value to flat file and Rewrite Flat File
Else
Read next record in Flat file.
No change in VSAm Files, only Flat file is updated!
I am not sure how Repro will help? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
In a REXX only situation, you would use REPRO to see if the key value is present in the VSAM files, first file1 then file2 if needed.
If the key value is present in the VSAM file being tested, then the record would have been REPRO'd to a work file, so read that work file and to extract the data you want, and update the flat file from that data.
The logic you have shown above will work for SAS, REXX and COBOL. |
|
Back to top |
|
|
hsk
New User
Joined: 28 Nov 2006 Posts: 69 Location: India
|
|
|
|
Thanks Murali , expat !!
I guess COBOL is the most efficient solution !!
I was searching for some solution with probably FileAid/SORT/ICETOOL |
|
Back to top |
|
|
raak
Active User
Joined: 23 May 2006 Posts: 166 Location: chennai
|
|
|
|
i feel u should start coding ur COBOL program now...
i don't think u can achieve this by REPRO.. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Quote: |
i don't think u can achieve this by REPRO.. |
Oh yes you can using REXX, as I said above ..... If you follow the logic
1 read flatfile and get key from flatfile
2 REPRO by key to workfile from VSAM1 - check RC if 0 - record exists
3 if RC (2) NE 0 then repeat for VSAM2
If either REPRO RC=0 then extract data from workfile, update flatfile, rewrite flatfile record and read next flatfile record
if both REPRO RC <> 0 then read next flatfile |
|
Back to top |
|
|
hsk
New User
Joined: 28 Nov 2006 Posts: 69 Location: India
|
|
|
|
I will try that expat !!! |
|
Back to top |
|
|
zensa
New User
Joined: 21 Feb 2007 Posts: 10 Location: India
|
|
|
|
Hi HSK,
We can achieve this using EZYTRIVE. |
|
Back to top |
|
|
hsk
New User
Joined: 28 Nov 2006 Posts: 69 Location: India
|
|
|
|
Zensa,
How ?? do you have sample code? any link or Doc?
Don't know much about EZYTRIVE! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
If this is something you want running any time soon, i'd make the same suggestion raak made earlier:
Quote: |
i feel u should start coding ur COBOL program now... |
. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
I knocked this up in about 5 minutes - totally untested but based on something that I have done in the past. Even included a restart capability as an extra function.
Code: |
CARD1 = " REPRO IFILE(IDD) OFILE(ODD) - "
CARD2 = " FROMKEY( ) - "
CARD3 = " TOKEY( ) "
"EXECIO 1 DISKR CNTRFILE ( FINIS" /* ALLOCATED IN JCL */
PARSE VAR CNTRFILE 1 RECNO . /* GET LAST RECORD PROCESSED */
IF RECNO > 0 THEN DO
*** READ AHEAD TO LAST RECORD PROCESSED IF RESTART
END
READ:
"EXECIO 1 DISKRU FLATFILE"
PARSE VAR FLATFILE 1 KEY 10 DATA 99 .
"EXECIO 0 DISKW SYSIN ( FINIS" /* ALLOCATED BY JCL - AS IS ODD DD */
QUEUE CARD1
QUEUE OVERLAY(KEY,CARD2,12)
QUEUE OVERLAY(KEY,CARD3,12)
"EXECIO" QUEUED() "DISKW SYSIN ( FINIS"
"FREE FI(IDD)"
"ALLOC FI(IDD) DA('"VSAM FILE 1 NAME"') SHR"
"IDCAMS"
IF RC = 0 THEN DO /* KEY MATCH VSAM FILE 1 */
********************
READ DATA FROM ODD
GET FIELD FROM ODD
OVERLAY ORIGINAL RECORD WITH DATA FROM VSAM FILE
REWRITE FLATFILE RECORD
********************
END
ELSE DO
"FREE FI(IDD)"
"ALLOC FI(IDD) DA('"VSAM FILE 2 NAME"') SHR"
"IDCAMS"
IF RC = 0 THEN DO /* KEY MATCH VSAM FILE 2 */
********************
READ DATA FROM ODD
GET FIELD FROM ODD
OVERLAY ORIGINAL RECORD WITH DATA FROM VSAM FILE
REWRITE FLATFILE RECORD
********************
END
END
/*** KEEP COUNT OF LAST RECORD PROCESSED FOR RESTART ***/
RECNO = RECNO + 1
PUSH RECNO
"EXECIO 1 DISKW CNTRFILE ( FINIS"
SIGNAL READ |
|
|
Back to top |
|
|
|