Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Update Flat file by comparing Flat file with another VSAM

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Update Flat file by comparing Flat file with another VSAM
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: 1439
Location: Bangalore,India

PostPosted: Fri Mar 16, 2007 2:27 pm    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Fri Mar 16, 2007 2:52 pm    Post subject:
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    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Fri Mar 16, 2007 3:17 pm    Post subject:
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    Post subject:
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    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Fri Mar 16, 2007 3:40 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Mon Mar 26, 2007 9:29 pm    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Tue Mar 27, 2007 2:06 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 1 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 3 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us