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

Spliting files using SYNCSORT


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

New User


Joined: 06 Mar 2006
Posts: 50
Location: PUNE

PostPosted: Wed Oct 17, 2007 1:56 pm
Reply with quote

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
View user's profile Send private message
murmohk1

Senior Member


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

PostPosted: Wed Oct 17, 2007 2:14 pm
Reply with quote

Anand,

DFSORT OUTFIL statement is helpful to you. Search the forum for examples.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Wed Oct 17, 2007 3:30 pm
Reply with quote

Adding to murali's post, use SPLIT1R\SPLIT for your requirement.

The commands are well explained in the DFSORT sort tricks.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Oct 17, 2007 9:50 pm
Reply with quote

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
View user's profile Send private message
Anand78

New User


Joined: 06 Mar 2006
Posts: 50
Location: PUNE

PostPosted: Mon Oct 22, 2007 12:09 pm
Reply with quote

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
View user's profile Send private message
Anand78

New User


Joined: 06 Mar 2006
Posts: 50
Location: PUNE

PostPosted: Mon Oct 22, 2007 4:25 pm
Reply with quote

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
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Oct 22, 2007 4:58 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Oct 22, 2007 9:28 pm
Reply with quote

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
View user's profile Send private message
snehalpatel

New User


Joined: 13 Sep 2007
Posts: 37
Location: India

PostPosted: Thu Oct 25, 2007 3:09 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Oct 25, 2007 8:42 pm
Reply with quote

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
View user's profile Send private message
snehalpatel

New User


Joined: 13 Sep 2007
Posts: 37
Location: India

PostPosted: Fri Oct 26, 2007 3:34 pm
Reply with quote

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
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Fri Oct 26, 2007 3:47 pm
Reply with quote

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
View user's profile Send private message
Anand78

New User


Joined: 06 Mar 2006
Posts: 50
Location: PUNE

PostPosted: Fri Oct 26, 2007 5:07 pm
Reply with quote

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
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Fri Oct 26, 2007 5:52 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Oct 26, 2007 11:45 pm
Reply with quote

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
View user's profile Send private message
sachin_star3
Warnings : 1

New User


Joined: 30 Sep 2006
Posts: 78
Location: pune

PostPosted: Sat Oct 27, 2007 1:49 pm
Reply with quote

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
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 3 files concatenated to 1 DFSORT/ICETOOL 2
No new posts Syncsort help SYNCSORT 3
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts SYNCSORT-DB2 interface SYNCSORT 0
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
Search our Forums:

Back to Top