MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Splitting a file into multiple files.

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
nagasadhu
Beginner


Joined: 08 Jul 2006
Posts: 17
Topics: 6

PostPosted: Wed Oct 25, 2006 5:55 am    Post subject: Splitting a file into multiple files. Reply with quote

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


Joined: 03 Oct 2005
Posts: 70
Topics: 34

PostPosted: Wed Oct 25, 2006 7:29 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed Oct 25, 2006 7:38 am    Post subject: Reply with quote

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


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed Oct 25, 2006 8:18 am    Post subject: Reply with quote

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
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed Oct 25, 2006 8:35 am    Post subject: Reply with quote

Kolusu,

Once again great answer and the logic used is excellent.
_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
nagasadhu
Beginner


Joined: 08 Jul 2006
Posts: 17
Topics: 6

PostPosted: Mon Oct 30, 2006 12:46 pm    Post subject: Reply with quote

A million thanks
Regards Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group