Page 1 of 2

Splitting Records to Files

PostPosted: Mon Nov 15, 2010 8:30 pm
by meowmeow
Hello,

is there a possibility to specify a block of data to be captured for specific files using Syncsort?
Sample Input:
AA1
abcdefg
abcdefg
abcdefg
AA2
BB1
abcdefg
abcdefg
abcdefg
BB2
CC1
abcdefg
abcdefg
abcdefg
CC2

Output:
File1:
AA1
abcdefg
abcdefg
abcdefg
AA2

File2:
BB1
abcdefg
abcdefg
abcdefg
BB2

File3:
CC1
abcdefg
abcdefg
abcdefg
CC2

So the splitting really depends on the header and the trailer records... AA1 should match with AA2 and so on... All records between them must be captured...

Thanks in advance :)

Re: Splitting Records to Files

PostPosted: Mon Nov 15, 2010 9:25 pm
by Alissa Margulies
Yes, this can be accomplished using WHEN=GROUP logic. Please see the example below:
//SORT1 EXEC PGM=SORT 
//SORTIN  DD *         
AA1                   
ABCDEFG               
ABCDEFG               
ABCDEFG               
AA2                   
BB1                   
ABCDEFG               
ABCDEFG               
ABCDEFG               
BB2                   
CC1                   
ABCDEFG               
ABCDEFG               
ABCDEFG               
CC2                   
//SORTOF01 DD DSN=AA.RECORDS
//SORTOF02 DD DSN=BB.RECORDS
//SORTOF03 DD DSN=CC.RECORDS
//SYSOUT   DD SYSOUT=*                                           
//SYSIN    DD *                                                   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(3,1,ZD,EQ,1),END=(3,1,ZD,EQ,2),
  PUSH=(81:ID=1))                                               
  SORT FIELDS=COPY                                               
  OUTFIL FILES=01,INCLUDE=(81,1,ZD,EQ,1),BUILD=(1,80)           
  OUTFIL FILES=02,INCLUDE=(81,1,ZD,EQ,2),BUILD=(1,80)           
  OUTFIL FILES=03,INCLUDE=(81,1,ZD,EQ,3),BUILD=(1,80)           
/*                             

Re: Splitting Records to Files

PostPosted: Fri Feb 08, 2013 3:55 pm
by ManishT
Hi,

I am new to this forum. I have the same requirement as mentioned but the number of files may vary. e.g. this time I have to split the data in 11 files.

SORTIN:
AA1                           
ABCDEFG                       
ABCDEFG                       
ABCDEFG                       
AA2                           
BB1                           
ABCDEFG                       
ABCDEFG                       
ABCDEFG                       
BB2                           
CC1                           
ABCDEFG                       
ABCDEFG                       
ABCDEFG                       
CC2                           
DD1                           
ABCDEFG                       
ABCDEFG                       
ABCDEFG                       
DD2                           
...............
.............
................


Sort:
SYSIN :
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(3,1,ZD,EQ,1),END=(3,1,ZD,EQ,2),
  PUSH=(81:ID=1))
  SORT FIELDS=COPY
  OUTFIL FILES=01,INCLUDE=(81,1,ZD,EQ,1),BUILD=(1,80)                           
  OUTFIL FILES=02,INCLUDE=(81,1,ZD,EQ,2),BUILD=(1,80)                           
  OUTFIL FILES=03,INCLUDE=(81,1,ZD,EQ,3),BUILD=(1,80)                           
  OUTFIL FILES=04,INCLUDE=(81,1,ZD,EQ,4),BUILD=(1,80)                           
  OUTFIL FILES=05,INCLUDE=(81,1,ZD,EQ,5),BUILD=(1,80)                           
  OUTFIL FILES=06,INCLUDE=(81,1,ZD,EQ,6),BUILD=(1,80)                           
  OUTFIL FILES=07,INCLUDE=(81,1,ZD,EQ,7),BUILD=(1,80)                           
  OUTFIL FILES=08,INCLUDE=(81,1,ZD,EQ,8),BUILD=(1,80)                           
  OUTFIL FILES=09,INCLUDE=(81,1,ZD,EQ,9),BUILD=(1,80)                           
  OUTFIL FILES=10,INCLUDE=(81,2,ZD,EQ,10),BUILD=(1,80)                         
  OUTFIL FILES=11,INCLUDE=(81,2,ZD,EQ,11),BUILD=(1,80)                         
  /*                                                       
  *                                                       
WER275A  NO KEYWORDS FOUND ON CONTROL STATEMENT           
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000             

Please advice why I am getting this error.

Thanks,
ManishT

Code'd

Re: Splitting Records to Files

PostPosted: Fri Feb 08, 2013 4:52 pm
by bodatrinadh
Hi Manish,

Show us your complete SYSOUT...And also check your input file attributes..

Re: Splitting Records to Files

PostPosted: Fri Feb 08, 2013 5:14 pm
by ManishT
Hi,

This is the complete SYSOUT I have. Can you please tell me which specific information your are looking for. The I/P File is of EB, 80 Bytes.

Re: Splitting Records to Files

PostPosted: Fri Feb 08, 2013 5:26 pm
by enrico-sorichetti
This is the complete SYSOUT I have.


when posting code/jcl snippets it is NECESSARY to use the code tags,
they preserve the spacing and use a fixed pitch font so to make possible
to spot for wrong columns in the data

the following line is ( as the text tells is )
indented 10 chars
1234567890
but it does not show

and here the same with the code tags
          indented 10 chars
1234567890


usually You get that error because of starting the sort control statements in column 1 instead of column 2

Re: Splitting Records to Files

PostPosted: Fri Feb 08, 2013 5:39 pm
by ManishT
Hi Enrico,

Thanks for reply. The JCL I am using is:

//X0TNSORT JOB (1,1424618),SORT,CLASS=L,PRTY=1,                     
//         REGION=0M,MSGCLASS=M,NOTIFY=&SYSUID TYPRUN=SCAN           
/*ROUTE PRINT LOCAL                                                 
/*JOBPARM ROOM=242C                                                 
//*                                                                 
//SORT1 EXEC PGM=SORT                                               
//SORTIN  DD DSN=SYSPGRP.XMKT.CCI.CLEAR.TEST,VOL=SER=Y2VL1E,DISP=SHR,
//   UNIT=3390                                                       
//SORTOF01 DD DSN=SYSPGRP.XMKT.SORT01,                               
//    SPACE=(CYL,(10,20),RLSE),DISP=(NEW,CATLG,DELETE),             
//    DCB=(RECFM=FB,LRECL=80)                                       
//SORTOF02 DD DSN=SYSPGRP.XMKT.SORT02,                               
//    SPACE=(CYL,(10,20),RLSE),DISP=(NEW,CATLG,DELETE),             
//    DCB=(RECFM=FB,LRECL=80)                                       
//SORTOF03 DD DSN=SYSPGRP.XMKT.SORT03,                               
//    SPACE=(CYL,(10,20),RLSE),DISP=(NEW,CATLG,DELETE),             
//    DCB=(RECFM=FB,LRECL=80)                                       
//SORTOF04 DD DSN=SYSPGRP.XMKT.SORT04,                               
//    SPACE=(CYL,(10,20),RLSE),DISP=(NEW,CATLG,DELETE),             
//    DCB=(RECFM=FB,LRECL=80)                                       
//SORTOF05 DD DSN=SYSPGRP.XMKT.SORT05,                   
//    SPACE=(CYL,(10,20),RLSE),DISP=(NEW,CATLG,DELETE), 
//    DCB=(RECFM=FB,LRECL=80)                           
//SORTOF06 DD DSN=SYSPGRP.XMKT.SORT06,                   
//    SPACE=(CYL,(10,20),RLSE),DISP=(NEW,CATLG,DELETE), 
//    DCB=(RECFM=FB,LRECL=80)                           
//SORTOF07 DD DSN=SYSPGRP.XMKT.SORT07,                   
//    SPACE=(CYL,(10,20),RLSE),DISP=(NEW,CATLG,DELETE), 
//    DCB=(RECFM=FB,LRECL=80)                           
//SORTOF08 DD DSN=SYSPGRP.XMKT.SORT08,                   
//    SPACE=(CYL,(10,20),RLSE),DISP=(NEW,CATLG,DELETE), 
//    DCB=(RECFM=FB,LRECL=80)                           
//SORTOF09 DD DSN=SYSPGRP.XMKT.SORT09,                   
//    SPACE=(CYL,(10,20),RLSE),DISP=(NEW,CATLG,DELETE), 
//    DCB=(RECFM=FB,LRECL=80)                           
//SORTOF10 DD DSN=SYSPGRP.XMKT.SORT10,                   
//    SPACE=(CYL,(10,20),RLSE),DISP=(NEW,CATLG,DELETE), 
//    DCB=(RECFM=FB,LRECL=80)                           
//SORTOF11 DD DSN=SYSPGRP.XMKT.SORT11,                   
//    SPACE=(CYL,(10,20),RLSE),DISP=(NEW,CATLG,DELETE), 
//    DCB=(RECFM=FB,LRECL=80)                           
//SYSOUT   DD SYSOUT=*
//SYSIN    DD *                                                   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(3,1,ZD,EQ,1),END=(3,1,ZD,EQ,2),
  PUSH=(81:ID=1))                                                 
  SORT FIELDS=COPY                                               
  OUTFIL FILES=01,INCLUDE=(81,1,ZD,EQ,1),BUILD=(1,80)             
  OUTFIL FILES=02,INCLUDE=(81,1,ZD,EQ,2),BUILD=(1,80)             
  OUTFIL FILES=03,INCLUDE=(81,1,ZD,EQ,3),BUILD=(1,80)             
  OUTFIL FILES=04,INCLUDE=(81,1,ZD,EQ,4),BUILD=(1,80)             
  OUTFIL FILES=05,INCLUDE=(81,1,ZD,EQ,5),BUILD=(1,80)             
  OUTFIL FILES=06,INCLUDE=(81,1,ZD,EQ,6),BUILD=(1,80)             
  OUTFIL FILES=07,INCLUDE=(81,1,ZD,EQ,7),BUILD=(1,80)             
  OUTFIL FILES=08,INCLUDE=(81,1,ZD,EQ,8),BUILD=(1,80)             
  OUTFIL FILES=09,INCLUDE=(81,1,ZD,EQ,9),BUILD=(1,80)             
  OUTFIL FILES=10,INCLUDE=(81,2,ZD,EQ,10),BUILD=(1,80)           
  OUTFIL FILES=11,INCLUDE=(81,2,ZD,EQ,11),BUILD=(1,80)           
  /*                                                             

I am sorry as I don't know how to add a window to scroll code. The SYSIN is starting from column 3 in the JCL.

Thanks,
MainshT

Re: Splitting Records to Files

PostPosted: Fri Feb 08, 2013 6:07 pm
by enrico-sorichetti
wasting time...
if You do not use the code tags we cannot tell the error

what is that You are incapable of doing ...

select some text like when cutting and pasting

and after the text has been highlighted click on the code button ???
:mrgreen:

but apart that why not try to put the SORT/COPY statement as the first control record ???

Re: Splitting Records to Files

PostPosted: Fri Feb 08, 2013 6:35 pm
by NicC
If the code button is not visible then use thPOSTREPLY button instead of the Quick Reply button - or use the Quick Reply button and then the Full Editor button.

Also, new or not, there is no excuse for not reading and obeying the forum rules e.g. do not 'tail-gate' old topics.

Re: Splitting Records to Files

PostPosted: Fri Feb 08, 2013 7:52 pm
by BillyBoyo
A good way to get an error like that from Sort is to have a line, prior to your SYSIN, which the system thinks is "data" so generates a SYSIN DD * card. It tells you this, if you can manage to find it in your messages output.