View previous topic :: View next topic
|
Author |
Message |
Anand78
New User
Joined: 06 Mar 2006 Posts: 50 Location: PUNE
|
|
|
|
Hi,
Please see below querry.
I have a file having 6 records : 1
2
3
4
5
6
I need to split this file into three files , first file should have 1 2 3 value,
second file should have 4 5 6 and third file should contain the first
records of two files i.e. 1 and 4.
Pls tell me how to acieve this.
Thnaks
Anand |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Anand,
DFSORT OUTFIL statement is helpful to you. Search the forum for examples. |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Adding to murali's post, use SPLIT1R\SPLIT for your requirement.
The commands are well explained in the DFSORT sort tricks. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Note: The original Subject was "Splitting files using DFSORT" - it was changed to "Splitting files using Syncsort" when it was discovered later that Syncsort was actually being used.
Anand,
Assuming you want the first three records in output file1, the second three records in output file2 and the first record from each group of three in output file3, you can use a DFSORT job like this:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1
2
3
4
5
6
/*
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//OUT3 DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL FNAMES=(OUT1,OUT2),SPLIT1R=3
OUTFIL FNAMES=OUT3,SAMPLE=3
/*
|
If that's not what you want, then please explain clearly the rules you want to use to go from input to output. |
|
Back to top |
|
|
Anand78
New User
Joined: 06 Mar 2006 Posts: 50 Location: PUNE
|
|
|
|
Thanks Frank.
Sort card u have specified , is working fine with me,
it is satisfying all the rules that I have posted.
Anand. |
|
Back to top |
|
|
Anand78
New User
Joined: 06 Mar 2006 Posts: 50 Location: PUNE
|
|
|
|
Frank,
The sort card to split files is not working for out1 and out2 files. As all records are copied into out1 & out2 files(means not splitted).
I apologize for miscommunication.
Anand.... |
|
Back to top |
|
|
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
Anand78
Quote: |
The sort card to split files is not working for out1 and out2 files. As all records are copied into out1 & out2 files(means not splitted).
|
Elaborate as to, What exactly you are getting, and what do you want? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
The sort card to split files is not working for out1 and out2 files. As all records are copied into out1 & out2 files(means not splitted). |
I don't understand. When I run the job I gave you, I get the following output:
OUT1
1
2
3
OUT2
4
5
6
OUT3
1
4
If that's not what you're getting, then you're doing something different.
Please show the input you're using, the output you're getting and the //SYSOUT messages for your job. |
|
Back to top |
|
|
snehalpatel
New User
Joined: 13 Sep 2007 Posts: 37 Location: India
|
|
|
|
Hi Frank
I tried above Jcl. But it gave me syntax error as below
Code: |
SYSIN :
OPTION COPY
OUTFIL FNAMES=(OUT1,OUT2),SPLIT1R=3
*
OUTFIL FNAMES=OUT3,SAMPLE=3
WER268A OUTFIL STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE |
Since we Synsort, Is this the reason that i got this message ? (I Apologize if this post was not supposed to be posted in DFSORT)
When I removed ',SPLIT1R=3' and Ran the job i got below result
OUT1
1
2
3
4
5
6
OUT2
1
2
3
4
5
6
OUT3
1
4
But I wanted below result
OUT1
1
2
3
OUT2
4
5
6
OUT3
1
4 |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
Since we use Syncsort, Is this the reason that i got this message ? |
Yes. The job works fine with DFSORT which has supported SPLIT1R since April, 2006. Syncsort does not support SPLIT1R so you can't use it with Syncsort. |
|
Back to top |
|
|
snehalpatel
New User
Joined: 13 Sep 2007 Posts: 37 Location: India
|
|
|
|
Frank Yaeger wrote: |
Quote: |
Since we use Syncsort, Is this the reason that i got this message ? |
Yes. The job works fine with DFSORT which has supported SPLIT1R since April, 2006. Syncsort does not support SPLIT1R so you can't use it with Syncsort. |
Thanks Frank for quick reply. |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
Hi !
While using Syncsort, you could do this with the OUTFILE option.
Example: Splitting by using Outfile with Include statement.
//SORTOF1 DD DSN=FRANK.MARTINS.OUTPUT01
//SORTOF2 DD DSN=FRANK.MARTINS.OUTPUT02
//SYSIN DD *
SORT FIELDS=COPY
RECORD TYPE=F
OUTFIL FILES=1,
INCLUDE=(66,03,BI,NE,X'00000C'),
INCLUDE=(66,03,ZD,GT,+0),
OUTREC=(050,010,066,003)
OUTFIL FILES=2,
INCLUDE=(66,03,BI,EQ,X'00000C'),
OUTREC=(050,010,066,003)
/*
Regards, UmeySan |
|
Back to top |
|
|
Anand78
New User
Joined: 06 Mar 2006 Posts: 50 Location: PUNE
|
|
|
|
Hi UmeySan,
Please explain me, as I am able to see only two split files, where is the third file which is expected to contain first record of each group.
Thnaks
Anand |
|
Back to top |
|
|
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 196 Location: Bangalore
|
|
|
|
Anand78,
Instead of using SPLIT1R use SPLITBY. SPLITBY is available in SYNCSORT
Code: |
SPLIT1R:
OPTION COPY
OUTFIL FNAMES=(OUT1,OUT2),SPLIT1R=3
OUTFIL FNAMES=OUT3,SAMPLE=3
The above code will work as follows.
It will put the first three records from input file to OUT1 and then remaining records to OUT2. |
Code: |
SPLITBY:
OPTION COPY
OUTFIL FNAMES=(OUT1,OUT2),SPLITBY=3
OUTFIL FNAMES=OUT3,SAMPLE=3
The above code will work as follows.
It will put the first three records from input file to out1 and then
next three records to OUT2 and then
next three records to OUT1 and then
next three records to OUT2 and then
...... |
|
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
For the record, there's an important difference between SPLIT1R=n and SPLITBY=n. SPLIT1R=n does NOT rotate back to the first output file so you get contiguous records in each output file, whereas SPLITBY=n rotates back so you can get non-contiguous records in a file.
To illustrate the difference, if you had 8 input records, SPLIT1R=3,FNAMES=(OUT1,OUT2) would put records 1-3 in OUT1 and 4-8 in OUT2. whereas SPLITBY=3,FNAMES=(OUT1,OUT2) would put records 1-3 and 7-8 in OUT1 and 4-6 in OUT2.
With 6 records as specified by the OP that wouldn't make a difference. But it can make a difference in other situations. |
|
Back to top |
|
|
sachin_star3 Warnings : 1 New User
Joined: 30 Sep 2006 Posts: 78 Location: pune
|
|
|
|
USE THE FOLOWING JCL
Code: |
//JOB STATEMNT
//STEP01 EXEC PGM=SORT
//SORTIN DD DSN=INPUT.FILE.NAME,DISP=SHR
//SORTOF1 DD DSN=OUPUT.FILE1
//SORTOF2 DD DSN=OUPUT.FILE2
//SORTOF03 DD DSN=OUPUT.FILE3
//SYSIN DD *
SORT FIELDS=COPY
OUFILE FILEDS = SORTOF1, INCLUDE COND=(1.1,CH,LT,C'4')
OUFILE FILEDS = SORTOF2, INCLUDE COND=(1.1,CH,GT,C'3')
OUFILE FILEDS = SORTOF3, INCLUDE COND=(1.1,CH,EQ,C'1') AND
INCLUDE COND=(1,1,CH,EQ,C'4')
/*
//
|
|
|
Back to top |
|
|
|