MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Retreiving records from VSAM files using a Flat file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12357
Topics: 75
Location: San Jose

PostPosted: Tue Jul 27, 2004 10:06 am    Post subject: Reply with quote

Ravi,

The first part of question of splitting the input file when colb matches colc can be done in many ways. In sort you can use the following 2 methods

Method1: We compare the contents of colb to colc and if matched we write to temp file t1, else we write to file T2. Next we concatenate these 2 temp files and sort on the first 3 bytes to have the records in sorted order so that we can use it against matching vsam file.
Code:

//STEP0100 EXEC PGM=ICETOOL                                 
//DFSMSG   DD SYSOUT=*                                     
//TOOLMSG  DD SYSOUT=*                                     
//IN       DD *                                             
A1010                                                       
B2030                                                       
C4040                                                       
D5050                                                       
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)   
//T2       DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)   
//CON      DD DSN=&T1,DISP=OLD,VOL=REF=*.T1                 
//         DD DSN=&T2,DISP=OLD,VOL=REF=*.T2                 
//OUT      DD SYSOUT=*                                     
//TOOLIN   DD *                                             
  COPY FROM(IN)  USING(CTL1)                               
  SORT FROM(CON) USING(CTL2)                               
//CTL1CNTL DD *                                             
  OUTFIL FNAMES=T1,INCLUDE=(2,2,CH,EQ,4,2,CH),OUTREC=(1,3) 
  OUTFIL FNAMES=T2,SAVE,OUTREC=(1,3,/,1,1,4,2)             
//CTL2CNTL DD *                                             
  SORT FIELDS=(1,3,CH,A)                                   
  OUTFIL FNAMES=OUT                                         
/*     


Method2: Here we split each record into 2. The first record will the first 3 bytes and the second record will have the firs byte and byte 4 & 5.

Now if colb matches with colc the second record will become a duplicate. So sort on the first 3 bytes and eliminate the dups, which will give us the desired results.

Code:

//STEP0100 EXEC PGM=ICETOOL                               
//DFSMSG   DD SYSOUT=*                                     
//TOOLMSG  DD SYSOUT=*                                     
//IN       DD *                                           
A1010                                                     
B2030                                                     
C4040                                                     
D5050                                                     
//T1       DD DSN=&T1,DISP=(,CATLG),SPACE=(CYL,(X,Y),RLSE)
//OUT      DD SYSOUT=*                                     
//TOOLIN   DD *                                           
  COPY FROM(IN) USING(CTL1)                               
  SORT FROM(T1) USING(CTL2)                               
//CTL1CNTL DD *                                           
  OUTFIL FNAMES=T1,OUTREC=(1,3,/,                         
                           1,1,4,2)                       
//CTL2CNTL DD *                                           
  SORT FIELDS=(1,3,CH,A)                                   
  SUM FIELDS=NONE                                         
  OUTFIL FNAMES=OUT                                       
/*


Both the above codes produce the following results.
Code:

A10
B20
B30
C40
D50


Now if you want match this flat file against a vsam file with a partial key, then I easytrieve is a very good option. The code is simple and it can be used for any file layouts. since your matching key is only partial , just define the partial key for the vsam file.

ex:
Code:

//STEP0100 EXEC PGM=EZTPA00                       
//STEPLIB  DD DSN=EASYTREV.LOADLIB,     
//            DISP=SHR                           
//SYSPRINT DD SYSOUT=*                           
//SYSOUT   DD SYSOUT=*                           
//SYSSNAP  DD SYSOUT=*                           
//SYSUDUMP DD SYSOUT=*   
//INFILE   DD *                         
A10
B20
B30
C40
D50
//INVSAM   DD DSN=YOUR VSAM FILE,
//            DISP=SHR                           
//OUTPUT   DD DSN=YOUR OUTPUT MATCH FILE,
//            DISP=(NEW,CATLG,DELETE),           
//            UNIT=SYSDA,                         
//            SPACE=(CYL,(X,Y),RLSE),         
//            DCB=(LRECL=ZZZ,RECFM=FB,BLKSIZE=0) 
//*
//* ZZZ is the LRECL of vsam file                           
//*                 
//SYSIN    DD *                                 
  FILE INFILE                                   
       IN-KEY           01 003 A                 
                                                 
  FILE INVSAM VS                                 
       VSAM-KEY         01 003 A                 
                                                               
  FILE OUTPUT  FB(0 0)                                         
                                                               
*************************************************
* MAINLINE                                      *               
*************************************************
                                                               
 JOB INPUT (INFILE  KEY (IN-KEY)     +                       
            INVSAM  KEY (VSAM-KEY))                         
                                                               
   IF MATCHED                                                 
      PUT OUTPUT FROM INVSAM                                   
   END-IF                                                     
               
/*


Now you would get all the records from the vsam file which are matching with input flat file.

For the second vsam file , all you need is change the input vsam file name & LRECL=ZZZ of the output file in thejcl, and you can use the same program to get the matching records from other vsam file.


Hope this helps...

Cheers

Kolusu
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group