Page 1 of 2

Splitting a file from middle using DFSORT in 2 parts

PostPosted: Wed Jan 07, 2015 10:44 pm
by ranjeet586
I have a file in which I don't know the number of records (policies only of length 10). I have to split the file in to two parts with equal number of policies (1 difference can happen in case of total odd number). Does any SORT options are available to use in jcl to split the file from middle. Please let me know. Appreciate you help.

Please note, We could split it after giving specific number like below, but if I don't want to hard code the number.

SORT FIELDS=COPY
OUTFIL FNAMES=OUT1,ENDREC=00100000
OUTFIL FNAMES=OUT2,SAVE
OUTREC FIELDS=(1:1,4,5:6,10)

KCT.ITO4860.SOR1
===>
********************
010EC00088
010EC00662
010EC00718
010EC00936

Re: Splitting a file from middle using DFSORT in 2 parts

PostPosted: Wed Jan 07, 2015 11:06 pm
by BillyBoyo
Have you looked at SPLIT and its cousins on OUTFIL? None will give you the implied "first half of the file". Why would that be important? If it is, amend a program which is already reading the file to output the count of records, then use that information in you SORT control cards.

Re: Splitting a file from middle using DFSORT in 2 parts

PostPosted: Thu Jan 08, 2015 12:00 am
by ranjeet586
I have one policy master file from where I am fetching all the policies. Now the list has to be divided in two parts and then IDA file has to be stripped for some other job.

I don't care if I get any utility which could be used through jcl. It would be great if you share any method. Thanks.

Re: Splitting a file from middle using DFSORT in 2 parts

PostPosted: Thu Jan 08, 2015 1:47 am
by enrico-sorichetti
whatever thing You will be using You will have to make TWO passes over the input file
the first one to determine the split point the second one to do it!

Re: Splitting a file from middle using DFSORT in 2 parts

PostPosted: Thu Jan 08, 2015 2:02 am
by ranjeet586
I have main file in that record count is available in packed format. Can I use that to calculate the middle point.

Re: Splitting a file from middle using DFSORT in 2 parts

PostPosted: Thu Jan 08, 2015 2:02 am
by ranjeet586
Footer has the record count in the policy master file, from where I am taking all the list of policies.

Re: Splitting a file from middle using DFSORT in 2 parts

PostPosted: Thu Jan 08, 2015 3:00 am
by BillyBoyo
The best thing would be if where the trailer (what we call a footer) is, write out a new file with the count in it.

Then you can use that to generate a SORT symbol or generate the SORT control cards so that your "hardcoded" value is generate each run.

Re: Splitting a file from middle using DFSORT in 2 parts

PostPosted: Thu Jan 08, 2015 3:27 am
by ranjeet586
Thanks for your reply Billy.

Could you please suggest how could we make that if I have trailer available like below in file
KCT.ITO8971.TRAILER1
===>
*************************
999 lÈ*
FFF0097544444444444444444
9990134C00000000000000000

Re: Splitting a file from middle using DFSORT in 2 parts

PostPosted: Fri Jan 09, 2015 1:59 pm
by neo4u
Ranjeet,

try SPLIT option.
SORT FIELDS=COPY               
OUTFIL FNAMES=(OUT1,OUT2),SPLIT


INPUT
111111
222222
333333
444444
555555
666666


OUTPUT
----OUT1----
111111
333333
555555

----OUT2----
222222
444444
666666

Re: Splitting a file from middle using DFSORT in 2 parts

PostPosted: Fri Jan 09, 2015 8:03 pm
by Terry Heinze
ranjeet586,
In the future, please use Code tags to preserve correct character spacing:
*************************
999 lÈ*
FFF0097544444444444444444
9990134C00000000000000000