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

Selecting N number of records from different files


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

New User


Joined: 08 May 2007
Posts: 13
Location: Hyderabad

PostPosted: Tue Oct 30, 2007 2:41 pm
Reply with quote

Hi,
I have 5 files (same LRECL) as input and I need to pull 1000 records from each file and write out to another file.The first three bytes of each record will let me know which file does the record belong to. Can I achieve this in a single sort step?? icon_question.gif

Scenario:
INPUT: FILE1,FILE2,FILE3,FILE4 and FILE5
OUTPUT: FILE6 with 5000 records to which all the above input files contribute 1000 records each.
Back to top
View user's profile Send private message
murmohk1

Senior Member


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

PostPosted: Tue Oct 30, 2007 2:55 pm
Reply with quote

Nynali,

Code:
//STEPP  EXEC PGM=SYNCTOOL                                             
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG DD SYSOUT=*                                                   
//*                                                                   
//IN1   DD DSN=FILE1,DISP=SHR                           
//IN2   DD DSN=FILE2,DISP=SHR                           
//IN3  DD DSN=FILE3,DISP=SHR                           
//IN4  DD DSN=FILE4,DISP=SHR                           
//IN5  DD DSN=FILE5,DISP=SHR                           

//*                                                                   
//OP DD DSN=....,DISP=(MOD,CATLG,CATLG),
//       LRECL=xx,RECFM=xx                                           
//TOOLIN DD *                                                         
 COPY FROM(IN1) TO(OP) USING(CTL1)                                     
 COPY FROM(IN2) TO(OP) USING(CTL1)       
 COPY FROM(IN3) TO(OP) USING(CTL1)       
 COPY FROM(IN4) TO(OP) USING(CTL1)       
 COPY FROM(IN5) TO(OP) USING(CTL1)       
/*                                                                     
//CTL1CNTL DD *                                                       
  SORT FIELDS=COPY,STOPAFT=1000                           
/*
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Tue Oct 30, 2007 2:57 pm
Reply with quote

Hi !

If i understood it correctly:

Concatenate your 5 InputFiles as Sortin and sort them to your File6, which is Sortout by using include-cond parameter on theese 3 bytes.

Be shure that alle InputFiles are in same SortOrder before doing this.

Plse correct me if i'm wrong

regards, UmeySan
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Aug 01, 2008 6:04 am
Reply with quote

Hi,

I think Murali's option is the best option, why read more records than necessary.

If each file has millions of records, there will be many unnecessary reads.


Gerry
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Fri Aug 01, 2008 9:12 am
Reply with quote

I think Murali's solution copies first thousand records of each file. But the original requirement is, 1000 records will be selected on the basis of 1 to 3 characters value.

KSK
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Aug 01, 2008 9:29 am
Reply with quote

Hello,

Quote:
The first three bytes of each record will let me know which file does the record belong to.
If i understand correctly, every record in a file has the same value in pos 1-3. Hopefully, there would be no duplication between files icon_wink.gif

I believe Murali's process does what was requested as well as saves millions of reads. . . (if i have not misunderstood something).
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Aug 01, 2008 9:51 am
Reply with quote

Hi Dick,

I'm with you, how could you tell which file it was from if the records were not unique in each file.


Gerry
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 Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top