|
View previous topic :: View next topic
|
| Author |
Message |
pjnithin
Active User
Joined: 22 Dec 2005 Posts: 116
|
|
|
|
I have a requirement where I need to select a particular set of records into 1 file and remaining into another file. Can I achieve this in a single step.
Input File:
A 111111111
A 222222222
B 111111111
C 111111111
A 777777777
D 666666666
I need all records starting with 'A' in one file and remaining in another file.
Outfile 1 :
A 111111111
A 222222222
A 777777777
Outfile 2:
B 111111111
C 111111111
D 666666666
Is there a direct method instead of using select statements with 2 control cards. It'll be helpful if I can do it in one single step where I give an include condition for one case for all the records to go into output file 1 and in the same step rest of the records will go to output file 2 also. Please help. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You can use a DFSORT job like this to do what you asked for:
| Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//OUT1 DD DSN=... output file1
//OUT2 DD DSN=... output file2
//SYSIN DD *
OPTION COPY
OUTFIL FNAMES=OUT1,INCLUDE=(1,1,CH,EQ,C'A')
OUTFIL FNAMES=OUT2,SAVE
/*
|
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:
Use [URL] BBCode for External Links |
|
| Back to top |
|
 |
pjnithin
Active User
Joined: 22 Dec 2005 Posts: 116
|
|
|
|
| In the same step is it possible for me to sort the file based on the last 9 bytes. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Sure, just change:
to:
| Code: |
SORT FIELDS=(3,9,CH,A)
|
Use ZD instead of CH if you want to treat the key as numeric (zoned decimal). |
|
| Back to top |
|
 |
pjnithin
Active User
Joined: 22 Dec 2005 Posts: 116
|
|
|
|
| But I need only the OUT1 file to be sorted. I think the above mentioned method sorts both the files. |
|
| Back to top |
|
 |
fixdoubts
New User
Joined: 21 Oct 2005 Posts: 54
|
|
|
|
Hi,
Im not sure this optimal one but it works.
| Code: |
//S1 EXEC PGM=ICETOOL
//SYSOUT DD SYSOUT=*
//IN1 DD DSN=... input file
//OUT1 DD DSN=... output file1
//OUT2 DD DSN=... output file2
//TOOL IN DD *
COPY FROM(IN1) TO(OUT1) USING(CPY1)
COPY FROM(IN1) TO(OUT2) USING(CPY2)
/*
//CPY1CNTL DD *
SORT FIELDS=(LAST 9)
INCLUDE COND=(1,1,CH,EQ,C'A')
/*
//CPY2CNTL DD *
OPTION COPY
OMIT COND=(1,1,CH,EQ,C'A')
/* |
This will do i think might not be an optimal one but it will do what you wanted.
Regards, |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| Quote: |
| But I need only the OUT1 file to be sorted. I think the above mentioned method sorts both the files. |
And was I supposed to know that by reading your mind? Please try to be more clear in your requirements in the future so we don't waste your time or mine.
If you want to sort the 'A' records, but not the 'B' records, you have to use two passes. Here are two ways to do that with DFSORT/ICETOOL:
Method 1
| Code: |
//S2 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file1
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT1 DD DSN=... output file1
//OUT2 DD DSN=... output file2
//TOOLIN DD *
* IN->T1: 'A' records (unsorted)
* IN->OUT2: non-'A' records (unsorted)
COPY FROM(IN) USING(CTL1)
* T1->OUT1: Sort 'A' records
SORT FROM(T1) TO(OUT1) USING(CTL2)
/*
//CTL1CNTL DD *
OUTFIL FNAMES=T1,INCLUDE=(1,1,CH,EQ,C'A')
OUTFIL FNAMES=OUT2,SAVE
/*
//CTL2CNTL DD *
SORT FIELDS=(3,9,CH,A)
/*
|
Method 2
| Code: |
//S3 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file1
//OUT1 DD DSN=... output file1
//OUT2 DD DSN=... output file2
//TOOLIN DD *
* IN->OUT1: 'A' records (sorted)
SORT FROM(IN) TO(OUT1) USING(CTL1)
* IN->OUT2: non-'A' records (unsorted)
COPY FROM(IN) TO(OUT2) USING(CTL2)
/*
//CTL1CNTL DD *
INCLUDE COND=(1,1,CH,EQ,C'A')
SORT FIELDS=(3,9,CH,A)
/*
//CTL2CNTL DD *
INCLUDE COND=(1,1,CH,NE,C'A')
/*
|
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|