MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
nagasadhu Beginner Joined: 08 Jul 2006 Posts: 17 Topics: 6
Posted: Wed Oct 25, 2006 5:55 am Post subject: Splitting a file into multiple files.
Hello all,
I have a requirement of splitting a single file into multiple files:
My input file has the layout:
Header1
Record1
Record2
Record3
Record4
Trailer1
Header2
Record5
Record6
Record7
Trailer2
Header3
Record8
Record9
Record10
Trailer3
-
-
-
Header-n
Record-n
Trailer-n
I want my o/p files as:
File 1:
Header1
Record1
Record2
Record3
Record4
Trailer1
File 2:
Header2
Record5
Record6
Record7
Trailer2
File 3:
Header3
Record8
Record9
Record10
Trailer3
-
-
-
File n:
Header-n
Record-n
Trailer-n
Please let me know if it can be done using a JCL utility or should I go for an application program itself.
Thanks,
Binoy.
Back to top
THRIVIKRAM Beginner Joined: 03 Oct 2005 Posts: 70 Topics: 34
Posted: Wed Oct 25, 2006 7:29 am Post subject:
nagasadhu,
1)Is n finite in this case?
2) Does the records between Header-1 and Trailer-1 have some commen characters in any field?
Thanks,
Thrivikram.
Back to top
shekar123 Advanced Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
Posted: Wed Oct 25, 2006 7:38 am Post subject:
Some more to add is there any identification for your Headers and Trailers and the records how u identify them through any key . _________________ Shekar
Grow Technically
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12370 Topics: 75 Location: San Jose
Posted: Wed Oct 25, 2006 8:18 am Post subject:
Try this DFSORT JCL. The first step0100 will create dynamic control cards for allocation and also for splitting. The Second step0200 will create the entire JCL to be execueted. Check the output from step0200, if you see everything is correct then change this statement in step0200
Code:
//SORTOUT DD SYSOUT=*
to
Code:
//SORTOUT DD SYSOUT=(*,INTRDR)
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
HEADER1
RECORD1
RECORD2
RECORD3
RECORD4
TRAILER1
HEADER2
RECORD5
RECORD6
RECORD7
TRAILER2
HEADER3
RECORD8
RECORD9
RECORD10
TRAILER3
//ALLOCDSN DD DSN=&A,DISP=(,PASS),SPACE=(CYL,(5,5),RLSE)
//CARDS DD DSN=&C,DISP=(,PASS),SPACE=(CYL,(5,5),RLSE)
//FULLDSN DD DSN=your seqnum numbered dsn,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(1,6,CH,EQ,C'HEADER'),
OVERLAY=(81:SEQNUM,8,ZD,START=1,INCR=2)),
IFTHEN=(WHEN=(1,7,CH,EQ,C'TRAILER'),
OVERLAY=(81:SEQNUM,8,ZD,START=1,INCR=2)),
IFTHEN=(WHEN=NONE,
OVERLAY=(89:SEQNUM,8,ZD,
81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
OUTFIL FNAMES=FULLDSN,
OUTREC=(01,88)
OUTFIL FNAMES=ALLOCDSN,
INCLUDE=(01,06,CH,EQ,C'HEADER'),
OUTREC=(C'//OUT',SEQNUM,5,ZD,X,
C'DD DSN=OUT',SEQNUM,5,ZD,
C'.FILE',/,
C'//',12X,
C'DISP=(NEW,CATLG,DELETE),',/,
C'//',12X,
C'UNIT=SYSDA,',/,
C'//',12X,
C'SPACE=(CYL,(1,1,),RLSE)',/,
C'/*',80:X)
OUTFIL FNAMES=CARDS,REMOVECC,NODETAIL,
OUTREC=(1,80),
HEADER1=(C'//SYSIN DD *',/,
C' SORT FIELDS=COPY',80:X),
SECTIONS=(81,8,
TRAILER3=(C' OUTFIL FNAMES=OUT',84,5,
C',INCLUDE=(81,8,ZD,EQ,',81,8,
C'),OUTREC=(1,80)',80:X)),
TRAILER1=(C'/*',80:X)
/*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
//SORTOUT DD SYSOUT=*
//SORTIN DD DATA,DLM=$$
//USERIDA JOB 'SPLIT COPY',
// CLASS=A,
// MSGCLASS=Y,
// MSGLEVEL=(1,1),
// NOTIFY=&SYSUID
//*
//COPYSTEP EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=your seqnum numbered dsn,
// DISP=SHR
//*
$$
// DD DSN=&A,DISP=(OLD,PASS)
// DD DSN=&C,DISP=(OLD,PASS)
/*
Hope this helps...
Cheers
Kolusu _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
www.linkedin.com/in/kolusu
Back to top
shekar123 Advanced Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
Posted: Wed Oct 25, 2006 8:35 am Post subject:
Kolusu,
Once again great answer and the logic used is excellent. _________________ Shekar
Grow Technically
Back to top
nagasadhu Beginner Joined: 08 Jul 2006 Posts: 17 Topics: 6
Posted: Mon Oct 30, 2006 12:46 pm Post subject:
A million thanks
Regards
Back to top
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum