View previous topic :: View next topic
|
Author |
Message |
mallik4u
New User
Joined: 17 Sep 2008 Posts: 75 Location: bangalore
|
|
|
|
hi,
I got a requirement to split a file into 5 files. This input file will have set of XMLs. There is no limit in the number of XMLs. Number can vary. Each XML is separated by a blank line. Also there is no size limit for the XML. One XML might be spread-ed in 100 records and other might be only 50. Input file record length is 200 characters. I need to break this file into 5 files.
For example if i have 8 XMLs in the input file then output files will have xmls as follows:
File 1 - XML 1 and XML 6
File 2 - XML 2 and XML 7
File 3 - XML 3 and XML 8
File 4 - XML 4
File 5 - XML 5
Could any one let me know how we can split this kind of file?
Thanks,
Mallik |
|
Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Have a look at OUTFIL SPLIT and its cousins, choosing the one appropriate to you. |
|
Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
You cannot do it with JCL. Were you perhaps wanting a sort solution? If so, why did you not post in the appropriate sort forum? |
|
Back to top |
|
 |
mallik4u
New User
Joined: 17 Sep 2008 Posts: 75 Location: bangalore
|
|
|
|
Thanks for quick replies.
I can write a COBOL program to split the file into multiple files using Round Robin method. But i am looking for SORT solution.
Thanks,
Mallik |
|
Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
And have you done what I suggested? |
|
Back to top |
|
 |
PeterHolland
Global Moderator

Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Quote: |
split the file into multiple files using Round Robin |
As far as I know RR is used to merge intermediate sort files into ONE, and not to split one file.
Follow up what Bill suggested. |
|
Back to top |
|
 |
prino
Senior Member

Joined: 07 Feb 2009 Posts: 1318 Location: Vilnius, Lithuania
|
|
|
|
mallik4u wrote: |
I can write a COBOL program to split the file into multiple files using Round Robin method. |
So why haven't you done so already? I once wrote a small CICS on-line enquiry system (five programs, two BMS screens and two transactions) before my lunchtime. (Yes, really!)
mallik4u wrote: |
But i am looking for SORT solution. |
<cynical mode>
Which should be provided by someone here...
</cynical mode> |
|
Back to top |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1207 Location: Dublin, Ireland
|
|
|
|
Quote: |
But i am looking for SORT solution.
|
You should look for "Smart DFSORT Tricks".... where just what you want can be found, I believe.
Garry |
|
Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
DFSORT Getting Started shows how to do it. DFSORT Application Programming Guide shows how to do it. The Smart Tricks does indeed show five (six or 10) ways to do it.
I'm reasonably sure SyncSORT documents how to do it as well. |
|
Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10896 Location: italy
|
|
|
|
unfortunately the smart tricks show squat
and SPLIT and it' s relatives( ASIS) will not do it ...
UIABW ( unless I am blatantly wrong )
SPLIT and relatives work with fixed/predetermined number of records,
not with groups of records, where each group could contain a different number of records
here is a snippet with the logic to split in three files according to the TS rules
( I did not clean up the output to show the modulus/remainder logic )
Code: |
****** ***************************** Top of Data ******************************
- - - - - - - - - - - - - - - - - - - 3 Line(s) not Displayed
000004 //S1 EXEC PGM=SORT
000005 //SYSPRINT DD SYSOUT=*
000006 //SYSOUT DD SYSOUT=*
000007 //SORTIN DD *
000008 XML 1 1
000009 XML 1 2
000010
000011 XML 2 1
000012 XML 2 2
000013 XML 2 3
000014
000015 XML 3 1
000016 XML 3 2
000017 XML 3 3
000018 XML 3 4
000019
000020 XML 4 1
000021 XML 4 2
000022 XML 4 3
000023 XML 4 4
000024 XML 4 5
000025
000026 XML 5 1
000027 XML 5 2
000028
000029 XML 6 1
000030 XML 6 2
000031 XML 6 3
000032
000033 XML 7 1
000034 XML 7 2
000035 XML 7 3
000036 XML 7 4
000037
000038 //SORTOUT DD SYSOUT=*
000039 //OUT1 DD SYSOUT=*
000040 //OUT2 DD SYSOUT=*
000041 //OUT3 DD SYSOUT=*
000042 //SYSIN DD *
000043 OPTION COPY
000044 INREC IFTHEN=(WHEN=GROUP,END=(1,1,CH,EQ,C' '),
000045 PUSH=(11:ID=5)),
000046 IFTHEN=(WHEN=INIT,
000047 OVERLAY=(16:(11,5,ZD,DIV,+3),TO=ZD,LENGTH=5,
000048 21:(16,5,ZD,MUL,+3),TO=ZD,LENGTH=5,
000049 26:(11,5,ZD,SUB,21,5,ZD),TO=ZD,LENGTH=5))
000050 OUTFIL FNAMES=OUT1,INCLUDE=(26,5,ZD,EQ,1)
000051 OUTFIL FNAMES=OUT2,INCLUDE=(26,5,ZD,EQ,2)
000052 OUTFIL FNAMES=OUT3,INCLUDE=(26,5,ZD,EQ,0)
****** **************************** Bottom of Data **************************** |
the result ...
OUT1
Code: |
********************************* TOP OF DATA **********************************
XML 1 1 00001000000000000001
XML 1 2 00001000000000000001
00001000000000000001
XML 4 1 00004000010000300001
XML 4 2 00004000010000300001
XML 4 3 00004000010000300001
XML 4 4 00004000010000300001
XML 4 5 00004000010000300001
00004000010000300001
XML 7 1 00007000020000600001
XML 7 2 00007000020000600001
XML 7 3 00007000020000600001
XML 7 4 00007000020000600001
00007000020000600001
******************************** BOTTOM OF DATA ******************************** |
OUT2
********************************* TOP OF DATA **********************************
Code: |
XML 2 1 00002000000000000002
XML 2 2 00002000000000000002
XML 2 3 00002000000000000002
00002000000000000002
XML 5 1 00005000010000300002
XML 5 2 00005000010000300002
00005000010000300002
******************************** BOTTOM OF DATA ******************************** |
OUT3
Code: |
********************************* TOP OF DATA **********************************
XML 3 1 00003000010000300000
XML 3 2 00003000010000300000
XML 3 3 00003000010000300000
XML 3 4 00003000010000300000
00003000010000300000
XML 6 1 00006000020000600000
XML 6 2 00006000020000600000
XML 6 3 00006000020000600000
00006000020000600000
******************************** BOTTOM OF DATA ******************************** |
for five parts use 5-five instead of 3-three and add the relative output datasets |
|
Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Mmmm.... I didn't read the question. |
|
Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
There is a MOD function available. One of the OUTFIL's can specify SAVE if you like, although it is 100% the case that only results of 0, 1 and 2 would be possible from MOD,+3. |
|
Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10896 Location: italy
|
|
|
|
Quote: |
There is a MOD function available. |
that' what happens when You ( me in this case ) do not read the manuals
the changed control cards
Code: |
****** ***************************** Top of Data ******************************
- - - - - - - - - - - - - - - - - - - 41 Line(s) not Displayed
000042 //SYSIN DD *
000043 OPTION COPY
000044 INREC IFTHEN=(WHEN=GROUP,END=(1,1,CH,EQ,C' '),
000045 PUSH=(11:ID=5)),
000046 IFTHEN=(WHEN=INIT,
000047 OVERLAY=(16:(11,5,ZD,MOD,+3),TO=ZD,LENGTH=5))
000048 OUTFIL FNAMES=OUT1,INCLUDE=(16,5,ZD,EQ,1)
000049 OUTFIL FNAMES=OUT2,INCLUDE=(16,5,ZD,EQ,2)
000050 OUTFIL FNAMES=OUT3,INCLUDE=(16,5,ZD,EQ,0)
****** **************************** Bottom of Data **************************** |
the changed results
Code: |
********************************* TOP OF DATA **********************************
XML 1 1 0000100001
XML 1 2 0000100001
0000100001
XML 4 1 0000400001
XML 4 2 0000400001
XML 4 3 0000400001
XML 4 4 0000400001
XML 4 5 0000400001
0000400001
XML 7 1 0000700001
XML 7 2 0000700001
XML 7 3 0000700001
XML 7 4 0000700001
0000700001
******************************** BOTTOM OF DATA ********************************
********************************* TOP OF DATA **********************************
XML 2 1 0000200002
XML 2 2 0000200002
XML 2 3 0000200002
0000200002
XML 5 1 0000500002
XML 5 2 0000500002
0000500002
******************************** BOTTOM OF DATA ********************************
********************************* TOP OF DATA **********************************
XML 3 1 0000300000
XML 3 2 0000300000
XML 3 3 0000300000
XML 3 4 0000300000
0000300000
XML 6 1 0000600000
XML 6 2 0000600000
XML 6 3 0000600000
0000600000
***********
********************* BOTTOM OF DATA ******************************** |
|
|
Back to top |
|
 |
|
|