Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Selecting N number of records from different files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Selecting N number of records from different files
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: 1439
Location: Bangalore,India

PostPosted: Tue Oct 30, 2007 2:55 pm    Post subject:
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: 757
Location: Germany

PostPosted: Tue Oct 30, 2007 2:57 pm    Post subject:
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: 1703
Location: Australia

PostPosted: Fri Aug 01, 2008 6:04 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Fri Aug 01, 2008 9:29 am    Post subject:
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: 1703
Location: Australia

PostPosted: Fri Aug 01, 2008 9:51 am    Post subject:
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    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 Inefficient BUILD - VB records paddin... Daniel Prosser SYNCSORT 6 Thu Dec 14, 2017 3:52 pm
No new posts ISSUE IN copying Sequential file reco... thesumitk JCL & VSAM 2 Wed Dec 13, 2017 3:07 pm
No new posts Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 2 Wed Dec 06, 2017 1:50 am
No new posts Compare VSAM files using DFSORT pshongal DFSORT/ICETOOL 5 Thu Nov 23, 2017 10:24 am
No new posts Split files upto certain limit based ... bubbu75 DFSORT/ICETOOL 5 Tue Nov 14, 2017 11:11 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us