View previous topic :: View next topic
|
Author |
Message |
nynali
New User
Joined: 08 May 2007 Posts: 13 Location: Hyderabad
|
|
|
|
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??
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 |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
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 |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
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 |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
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 |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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
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 |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
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 |
|
|
|