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?
Joined: 07 Feb 2009 Posts: 1314 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>
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.
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
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.
********************************* 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 ********************************