IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Splitting file into 5


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mallik4u

New User


Joined: 17 Sep 2008
Posts: 75
Location: bangalore

PostPosted: Wed Jul 15, 2015 10:13 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jul 16, 2015 12:49 am
Reply with quote

Have a look at OUTFIL SPLIT and its cousins, choosing the one appropriate to you.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Thu Jul 16, 2015 3:22 am
Reply with quote

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
View user's profile Send private message
mallik4u

New User


Joined: 17 Sep 2008
Posts: 75
Location: bangalore

PostPosted: Thu Jul 16, 2015 9:36 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jul 16, 2015 12:15 pm
Reply with quote

And have you done what I suggested?
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Jul 16, 2015 12:40 pm
Reply with quote

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
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1314
Location: Vilnius, Lithuania

PostPosted: Thu Jul 16, 2015 2:35 pm
Reply with quote

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
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1205
Location: Dublin, Ireland

PostPosted: Thu Jul 16, 2015 5:01 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jul 16, 2015 5:30 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Thu Jul 16, 2015 6:45 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jul 16, 2015 7:46 pm
Reply with quote

Mmmm.... I didn't read the question.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jul 16, 2015 7:51 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Thu Jul 16, 2015 7:57 pm
Reply with quote

Quote:
There is a MOD function available.

that' what happens when You ( me in this case ) do not read the manuals icon_biggrin.gif

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Unable to interpret a hex value to De... COBOL Programming 4
No new posts how to eliminate null indicator value... DB2 7
No new posts Format Binary file to EBCDIC JCL & VSAM 4
No new posts Binary File format getting change whi... All Other Mainframe Topics 7
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
Search our Forums:

Back to Top