MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to split files using SYNCSORT ?
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
vijay
Beginner


Joined: 09 May 2003
Posts: 131
Topics: 64

PostPosted: Wed Sep 10, 2003 10:06 pm    Post subject: How to split files using SYNCSORT ? Reply with quote

Hi ,
I've a file like this with records of two files combined like this.

01(header)
11(details of 1st file)
..
99(trailer of 1st file)
01(header)
11(details of 2nd file)
..
99(trailer of 2nd file)

I want to split this into 2 files.
file1:
01(header)
11(details of 1st file)
..
file2:
01(header)
11(details of 2nd file)
..
99(trailer of 2nd file)

Can u suggest me a solution for this using syncsort?

Thanks,
Vijay
Back to top
View user's profile Send private message
coolman
Intermediate


Joined: 03 Jan 2003
Posts: 283
Topics: 27
Location: US

PostPosted: Thu Sep 11, 2003 12:24 am    Post subject: Reply with quote

Vijay,

The following job should give you the results...

Code:

//STEP1    EXEC PGM=SYNCTOOL                                 
//IN       DD *                                             
01(HEADER)                                                 
11(DETAILS OF 1ST FILE)                                     
..                                                         
99(TRAILER OF 1ST FILE)                                     
01(HEADER)                                                 
11(DETAILS OF 2ND FILE)                                     
..                                                         
99(TRAILER OF 2ND FILE)                                     
/*                                                         
//TOOLMSG  DD SYSOUT=*                                     
//OUT1     DD SYSOUT=*                                     
//OUT2     DD SYSOUT=*                                     
//DFSMSG   DD SYSOUT=*                                     
//TOOLIN   DD *                                             
  COPY FROM(IN) USING(CTL0)                                 
  COPY FROM(IN) USING(CTL1)                                     
/*                                                               
//CTL0CNTL DD *                                                 
  INREC FIELDS=(1,80,SEQNUM,4,ZD)                               
  OUTFIL FNAMES=CTL1CNTL,INCLUDE=(1,2,CH,EQ,C'99'),             
  OUTREC=(C' OUTFIL FNAMES=OUT1,OUTREC=(1,80),ENDREC=',81,4,80:X)
/*                                                               
//CTL1CNTL DD DISP=(,PASS),DSN=&C,UNIT=SYSDA,SPACE=(TRK,(1,1))   
//         DD *                                                 
   OUTFIL SAVE,FNAMES=OUT2                                       
/*                                                               
//


Hope this helps...

Cheers,
Coolman.
________
vaaapp vaporizer


Last edited by coolman on Sat Feb 05, 2011 1:29 am; edited 1 time in total
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Sep 11, 2003 6:07 am    Post subject: Reply with quote

coolman,

Did you test the solution? Your first copy statement will write 2 records as there are 2 records with '99'

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
coolman
Intermediate


Joined: 03 Jan 2003
Posts: 283
Topics: 27
Location: US

PostPosted: Thu Sep 11, 2003 11:14 pm    Post subject: Reply with quote

Kolusu,
You are right, it will write 2 records with '99', but it works as expected.

Coolman.
________
easyvape vaporizer


Last edited by coolman on Sat Feb 05, 2011 1:29 am; edited 1 time in total
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Sep 12, 2003 6:10 am    Post subject: Reply with quote

coolman,

NO it won't execute at all. It will fail with
Code:

OUT1     DUPLICATE OUTFIL SPECIFICATION


Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Fri Sep 12, 2003 7:26 am    Post subject: Reply with quote

This solution must work.

The first step identifies the line numbers where the trailer records are. The second step uses the first line number and dynamically generates OUTFIL statements to split the input dataset. THe conditions are, those records that are less than the line number of the first trailer and, those that are greater.


Code:
//STEP     EXEC PGM=ICETOOL         
//TOOLIN   DD *                     
 COPY FROM(IN01) TO(T1)   USING(CPY1)
 COPY FROM(T1)            USING(CPY2)
 COPY FROM(IN01)          USING(CPY3)
/*                                   
//IN01     DD *                     
----+----1----+----2----+----3----+--
01 HEADER  OF FIRST FILE             
11 DETAIL  OF FIRST FILE             
11 DETAIL  OF FIRST FILE             
11 DETAIL  OF FIRST FILE             
11 DETAIL  OF FIRST FILE             
99 TRAILER OF FIRST FILE             
01 HEADER  OF SECOND FILE           
11 DETAIL  OF SECOND FILE           
11 DETAIL  OF SECOND FILE           
11 DETAIL  OF SECOND FILE           
11 DETAIL  OF SECOND FILE           
99 TRAILER OF SECOND FILE           
/*                                   
//T1       DD DSN=&&TEMP0001,                             
//            DISP=(,PASS)                                 
//T2       DD DSN=&&TEMP0002,                             
//            DISP=(,PASS)                                 
//OT01     DD SYSOUT=*                                     
//OT02     DD SYSOUT=*                                     
//CPY1CNTL DD *                                           
 INREC   FIELDS=(1,80,SEQNUM,8,ZD)                         
 OUTFIL  FNAMES=T1,                                       
         INCLUDE=(1,2,CH,EQ,C'99')                         
/*                                                         
//CPY2CNTL DD *                                           
 OUTFIL FNAMES=T2,                                         
        ENDREC=1,                                         
        OUTREC=(C' INREC FIELDS=(1,80,SEQNUM,8,ZD)',80:X,/,
                C' OUTFIL FNAMES=OT01,',80:X,/,           
                C' INCLUDE=(81,8,ZD,LT,',81,8,C'),',80:X,/,
                C' OUTREC=(1,80)',80:X,/,                 
                C' OUTFIL FNAMES=OT02,',80:X,/,           
                C' INCLUDE=(81,8,ZD,GT,',81,8,C'),',80:X,/,
                C' OUTREC=(1,80)',80:X)
                                       
//CPY3CNTL DD DSN=&&TEMP0002,         
//            DISP=(SHR,KEEP),         
//            VOL=REF=*.T2             
//TOOLMSG  DD SYSOUT=*                 
//DFSMSG   DD SYSOUT=*                 



The output datasets are:

OT01:
Code:

---+----1----+----2----+-
01 HEADER OF FIRST FILE
11 DETAIL  OF FIRST FILE
11 DETAIL  OF FIRST FILE
11 DETAIL  OF FIRST FILE
11 DETAIL  OF FIRST FILE


OT02:
Code:
---+----1----+----2----+-
01 HEADER  OF SECOND FILE
11 DETAIL  OF SECOND FILE
11 DETAIL  OF SECOND FILE
11 DETAIL  OF SECOND FILE
11 DETAIL  OF SECOND FILE
99 TRAILER OF SECOND FILE

_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Sep 12, 2003 8:29 am    Post subject: Reply with quote

Vijay,

The following JCl will give you the desired results.
Code:

//STEP0100 EXEC PGM=SYNCTOOL                                   
//TOOLMSG   DD SYSOUT=*                                         
//DFSMSG    DD SYSOUT=*                                         
//IN        DD DSN=YOUR INPUT FILE,
//             DISP=SHR
//OUT1      DD DSN=YOUR OUTPUT FILE,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(X,Y),RLSE)                                         
//TOOLIN   DD  *                                               
  SORT FROM(IN) USING(CTL1)                                     
  COPY FROM(IN) USING(CTL2)                                     
//CTL1CNTL DD  *       
  OPTION EQUALS                                         
  INREC FIELDS=(1,2,SEQNUM,8,ZD)                                 
  SORT FIELDS=(1,2,CH,A)                                         
  SUM FIELDS=NONE                                               
  OUTFIL FNAMES=CTL2CNTL,INCLUDE=(1,2,CH,EQ,C'99'),
  OUTREC=(C' OUTFIL FNAMES=OUT1,STARTREC=1,ENDREC=',3,8,/,   
         C' OUTFIL FNAMES=OUT2,SAVE',80:X)                                 
//CTL2CNTL  DD DSN=&C1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//*   


Hope this helps...

cheers

kolusu


Last edited by kolusu on Fri Sep 12, 2003 10:32 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Fri Sep 12, 2003 8:44 am    Post subject: Reply with quote

Kolusu,
Don't you think, a OPTION EQUALS is needed so that the unique 99 that is used to decide the STARTREC and ENDREC is the first 99 record?

Also, looking at the sample output provided by Vijay, he does not need the trailer of the first file. So, maybe, your ENDREC should be less than 1.

Finally, his input is a concatenation of two datasets. Wonder what would happen if either of them is empty? Rolling Eyes This concern of mine is valid for any solution that one may post.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
vijay
Beginner


Joined: 09 May 2003
Posts: 131
Topics: 64

PostPosted: Fri Sep 12, 2003 10:03 am    Post subject: Reply with quote

Hi,
I also need the trailer of the first file.Sorry ,I missed that .

Vijay
Back to top
View user's profile Send private message
coolman
Intermediate


Joined: 03 Jan 2003
Posts: 283
Topics: 27
Location: US

PostPosted: Fri Sep 12, 2003 10:19 am    Post subject: Reply with quote

Kolusu,
It works perfectly. I have posted the job only after testing. But I did it in DFSORT. Probably Frank/Cogito can certify that it is correct.

Cheers,
Coolman.
________
1958 Dodge history


Last edited by coolman on Sat Feb 05, 2011 1:29 am; edited 2 times in total
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Fri Sep 12, 2003 10:24 am    Post subject: Reply with quote

Vijay,
In that case, my job needs to be changed as follows:

Code:
//CPY2CNTL DD *                                           
 OUTFIL FNAMES=T2,                                         
        ENDREC=1,                                         
        OUTREC=(C' INREC FIELDS=(1,80,SEQNUM,8,ZD)',80:X,/,
                C' OUTFIL FNAMES=OT01,',80:X,/,           
                C' INCLUDE=(81,8,ZD,LE,',81,8,C'),',80:X,/,
                C' OUTREC=(1,80)',80:X,/,                 
                C' OUTFIL FNAMES=OT02,',80:X,/,           
                C' SAVE,',80:X,/,                         
                C' OUTREC=(1,80)',80:X)                   
/*                                                         

_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Sep 12, 2003 10:31 am    Post subject: Reply with quote

coolman: I would be surprised if DFSORT allows DUPLICATE outfil names.

cogito: You are right about the OPTION EQUALS.I missed it. I am editing the post to reflect the change.I did not have the problem as my shop have OPTION EQUALS as default parameter.

Frank: can you clarify if DFSORT allows duplicate outfil names.

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Fri Sep 12, 2003 10:32 am    Post subject: Reply with quote

Kolusu,
I must agree with Coolman. Here is what I get.
Quote:
OUTFIL FNAMES=OUT1,OUTREC=(1,80),ENDREC=0004
OUTFIL FNAMES=OUT1,OUTREC=(1,80),ENDREC=0008
ICE219I 0 DUPLICATE DDNAME OUT1 IGNORED


Let do some more hair-splitting. Wink Will DFSORT always ignore the second OUTFIL? (It must, I guess. But, just curious... Wink )
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Sep 12, 2003 10:43 am    Post subject: Reply with quote

Thanks Cogito for clarifying about the duplicate OUTFIL names.Syncsort abends with
Code:

 WER190A  OUT1     DUPLICATE OUTFIL SPECIFICATION 


I would like the sort to abend if there is a duplicate outfil name. Let us take an example

Let us say I want to split the file into 5 different files and specify as follows:
Code:

OUTFIL FNAMES=(OUT1,OUT2,OUT3,OUT3,OUT5),SPLIT   


In this case it was my mistake to code 2 out3 file names and if DFSORT ignores the duplicate and I might not get the desired results.

I would be scratching my head as to why out4 file is empty since the job completed successfully

Frank can you explain the reason behind ignoring duplicate file name??


kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Fri Sep 12, 2003 10:58 am    Post subject: Reply with quote

Kolusu,
From the manual,

Quote:
Duplicate Ddnames
If you specify a particular ddname (such as SORTIN) more than once within the
same step, DFSORT uses the first ddname and ignores subsequent duplicates.
Processing continues normally.
In addition, SORTIN0, SORTIN1...SORTIN9 can be specified instead of SORTIN00,
SORTIN01...SORTIN09, respectively. If you specify both SORTINn and SORTIN0n
in the same job step, DFSORT treats them as duplicates, and ignores each usage
after the first. For example, SORTIN2 and SORTIN02 are treated as duplicates and
only SORTIN2 is used.


Quote:
Duplicate OUTFIL ddnames are ignored at the OUTFIL statement level


More from the manual
Quote:
Multiple OUTFIL statements can be specified in the same and different sources.
If a ddname occurs more than once in the same source, the ddname is
associated with the first OUTFIL group in which it appears. For example, if the
following is specified in SYSIN:
OUTFIL FNAMES=(OUT1,OUT2),INCLUDE=(1,1,CH,EQ,C ’A ’)
OUTFIL FNAMES=(OUT3,OUT1),SAVE
OUT1 and OUT2 are processed as part of the first OUTFIL group, that is, with
INCLUDE. OUT3 is processed as part of the second OUTFIL group, that is, with
SAVE; but OUT1 is not because it is a duplicate ddname.
If a ddname occurs in more than one source, the ddname is associated with the
highest source OUTFIL group in which it appears. For example, if the following is
specified in DFSPARM:
OUTFIL FNAMES=(OUT1,OUT2),INCLUDE=(1,1,CH,EQ,C ’A ’)and the following is specified in SYSIN:
OUTFIL FNAMES=(OUT3,OUT1),SAVE
OUT1 and OUT2 are processed as part of the DFSPARM OUTFIL group, that is,
with INCLUDE. OUT3 is processed as part of the SYSIN OUTFIL group, that is,
with SAVE; but OUT1 is not because it is an overridden ddname.


However, your question still holds. A user would not know as to why the dataset is empty until he looks up his/her control statements. Again, I guess, the chances of coding duplicate DD names (Coolman's case is unique) will be few. So, DFSORT, I think, pardons such peccadilloes. Smile
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group