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

Update Flat file by comparing Flat file with another VSAM


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
hsk

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Fri Mar 16, 2007 2:17 pm
Reply with quote

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
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Fri Mar 16, 2007 2:27 pm
Reply with 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.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Fri Mar 16, 2007 2:52 pm
Reply with quote

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
View user's profile Send private message
hsk

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Fri Mar 16, 2007 2:59 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Fri Mar 16, 2007 3:17 pm
Reply with quote

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
View user's profile Send private message
hsk

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Fri Mar 16, 2007 3:30 pm
Reply with quote

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
View user's profile Send private message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Fri Mar 16, 2007 3:30 pm
Reply with quote

i feel u should start coding ur COBOL program now... icon_lol.gif


i don't think u can achieve this by REPRO..
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Fri Mar 16, 2007 3:40 pm
Reply with quote

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
View user's profile Send private message
hsk

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Fri Mar 16, 2007 4:02 pm
Reply with quote

I will try that expat !!!
Back to top
View user's profile Send private message
zensa

New User


Joined: 21 Feb 2007
Posts: 10
Location: India

PostPosted: Thu Mar 22, 2007 2:30 pm
Reply with quote

Hi HSK,

We can achieve this using EZYTRIVE.
Back to top
View user's profile Send private message
hsk

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Mon Mar 26, 2007 9:14 am
Reply with quote

Zensa,
How ?? do you have sample code? any link or Doc?

Don't know much about EZYTRIVE!
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Mon Mar 26, 2007 9:29 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Tue Mar 27, 2007 2:06 pm
Reply with quote

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
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Unable to interpret a hex value to De... COBOL Programming 4
No new posts how to eliminate null indicator value... DB2 7
No new posts VSAM LISTCAT INFORMATION JCL & VSAM 2
No new posts Format Binary file to EBCDIC JCL & VSAM 4
No new posts Binary File format getting change whi... All Other Mainframe Topics 7
Search our Forums:

Back to Top