Page 1 of 1

Split Files Using sort in to multiple files

PostPosted: Tue Dec 24, 2013 11:02 pm
by rszode
Hi Team
I have a input file which is having many header which is common value as below ( Header - ONDEMAND INDEX ) , now i want this files to be divided in 2 or 3 files based on count of header in this case ( ONDEMAND INDEX ), please help me on this

Input File :

ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------


Suppose Result needs files to be divided in 3 files after 2 count of "ONDEMAND INDEX"

Out put file : 1

ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------

Out put file : 2

ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------

Out put file : 3

ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------

Re: Split Files Using sort in to multiple files

PostPosted: Wed Dec 25, 2013 1:54 am
by Akatsukami
As this requirement cannot be fulfilled using the forum rules, you should have chosen a different area to post in :roll:

Re: Split Files Using sort in to multiple files

PostPosted: Wed Dec 25, 2013 8:41 pm
by BillyBoyo
Your post has been moved. Don't know which SORT product you use, so let us know, it may have to move again.

Use WHEN=GROUP, and PUSH an ID and have an appropriate number of OUTFIL INCLUDE=( for the range of ID values you want. If that is not it, describe your problem a bit more clearly.

Re: Split Files Using sort in to multiple files

PostPosted: Wed Dec 25, 2013 9:38 pm
by rszode
Hi Thanks for reply, i want to use aany sort which gives me result as expected.let me provide example in simple way as below

Here in input file Key word AAAAAAAA occur 6 time in file, so i want to divide this file in 3 file, but along with its parts present below it. like 'abcdefssdadadad' see in exa.

Input File :
AAAAAAAA
abcdefssdadadad
sdasdsadsadadad
fdfdfdfdfdsgdsddf
AAAAAAAA
dsdasdasdsa
AAAAAAAA
rfggfdgfgffgf
bvcxvcxvcxv
AAAAAAAA
dgdsgfdgthtytb
AAAAAAAA
retewtretrtrrtr
AAAAAAAA
wddsadasdsad
fgdsgdsgdfsg

Expected output files

OUTPUT FILE 1
AAAAAAAA
abcdefssdadadad
sdasdsadsadadad
fdfdfdfdfdsgdsddf
AAAAAAAA
dsdasdasdsa

OUTPUT File 2

AAAAAAAA
rfggfdgfgffgf
bvcxvcxvcxv
AAAAAAAA
dgdsgfdgthtytb


OUTPUT File 3

AAAAAAAA
retewtretrtrrtr
AAAAAAAA
wddsadasdsad
fgdsgdsgdfsg

Re: Split Files Using sort in to multiple files

PostPosted: Thu Dec 26, 2013 3:46 pm
by BillyBoyo
You can't just use "any sort", you have to use the one installed at your site. We don't know which that is.

You need to consult your manual(s) and become familiar with IFTHEN=(WHEN=GROUP and PUSH= with an ID.

Once your groups of records have a value which can be used to keep them together (the ID) then it should be easy to distribute them to one of multiple output files using OUTFIL INCLUE=/OMIT=.

Try it, one thing at at time, and let us know if you get stuck, showing what you tried, what actually happened, what you expected to happen, and input data to create the problem. We need to know the RECFM and LRECL of your files as well.