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 

Split a sequential file to n number of files having 1 record

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


Joined: 02 Dec 2002
Posts: 48
Topics: 9
Location: Columbus, GA

PostPosted: Tue Dec 03, 2002 4:52 pm    Post subject: Split a sequential file to n number of files having 1 record Reply with quote

Hai all,

I have a sequential file which may have records from 1 to n. I want to split the file to n number of files each having single record. 'n' varies from 1 to 100. LRECL of the file is 32760. ( n will be always 1 - 100).

Suppose I have a file AAA.BBB.CCC with 3 records. I need AAA.BBB.CCC001 and
AAA.BBB.CCC002 and AAA.BBB.CCC003 with First and second and third records on it respectively.

Can any one help me to do this.
_________________
Thanks,
Jeba
(Known is a drop Unknown is an ocean)
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Dec 03, 2002 5:20 pm    Post subject: Reply with quote

Jeba,

If you can hardcode the output DD statements, then you can use a DFSORT job like this:

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=AAA.BBB.CCC,DISP=SHR
//OUT001 DD DSN=AAA.BBB.CCC001,...
//OUT002 DD DSN=AAA.BBB.CCC002,...
...
//OUT100 DD DSN=AAA.BBB.CCC100,...
//SYSIN DD *
  OPTION COPY
  OUTFIL SPLIT,
    FNAMES=(OUT001,OUT002,OUT003,OUT004,OUT005,
     OUT006,OUT007,OUT008,OUT009,
     ...,
     OUT096, OUT097,OUT098,OUT099,OUT100)
/*


The first record will go to OUT001, the second record will go to OUT002, and so on until you run out of records or get to record 100 which will go to OUT100. OUTnnn data sets without a corrresponding record will be empty. For example, if you have 98 records, then AAA.BBB.CCC099 and AAA.BBB.CCC100 will be empty.

If this isn't what you want to do, then please describe what you want to do in more detail.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort


Last edited by Frank Yaeger on Tue Dec 03, 2002 6:45 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Jeba
Beginner


Joined: 02 Dec 2002
Posts: 48
Topics: 9
Location: Columbus, GA

PostPosted: Tue Dec 03, 2002 5:59 pm    Post subject: Reply with quote

Frank,

Thanks for your input.
_________________
Thanks,
Jeba
(Known is a drop Unknown is an ocean)
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Dec 03, 2002 6:47 pm    Post subject: Reply with quote

Jeba,

Is that what you wanted to do?
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Jeba
Beginner


Joined: 02 Dec 2002
Posts: 48
Topics: 9
Location: Columbus, GA

PostPosted: Tue Dec 03, 2002 10:52 pm    Post subject: Reply with quote

Frank,

This is what I expected. But the only thing I don't like is (100 - n ) Empty files will be created. Is there any way to get n number of files alone ?
_________________
Thanks,
Jeba
(Known is a drop Unknown is an ocean)
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Dec 04, 2002 5:20 am    Post subject: Reply with quote

Jeba,

The following DFSORT/ICETOOL JCL will give you the results.If you have syncsort at your shop, then change the pgm name to synctool.A brief explanation of the job.Since you wanted only output files corresponding to the no: of records in the file, we create dynamic control cards.

Step010 is create the control cards.we use inrec to have just the seqnum and we sort descending on the seqnum, so that the last record will be first.we create 4 temp files.

File T1 will be as follows:
Code:

OUTFIL SPLIT,FNAMES=(OUT001,


File T2 will be as follows:
Code:

OUT002,
OUT003,
OUT004,


File T3 will be as follows:
Code:

 OUT005)


File T4 will have the jcl allocation for these 5 files.
Code:

//OUT001 DD DSN=XXXXXXX.OUT001,       
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,             
//            SPACE=(CYL,(1,1),RLSE)
...
//OUT005  DD DSN=XXXXXXX.OUT005,       
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,             
//            SPACE=(CYL,(1,1),RLSE)



change xxxxxx to your tid or highlevel qualifier at your shop in the control card where we create file T4

Now step020 will take all these temp file as sysin and submit a job to the intrdr which will actually split the each record into one file.


Code:

//STEP010  EXEC  PGM=ICETOOL                             
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG   DD SYSOUT=*                                   
//IN       DD *                                           
AAA                                                       
BBB                                                       
CCC                                                       
DDD                                                       
EEE                                                       
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T2       DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T3       DD DSN=&T3,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T4       DD DSN=&T4,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//TOOLIN   DD    *                                       
  SORT FROM(IN) USING(CTL1)                               
//CTL1CNTL DD    *                                       
  INREC FIELDS=(SEQNUM,3,ZD)                             
  SORT FIELDS=(1,3,ZD,D)                                 
  OUTFIL FNAMES=T1,ENDREC=1,                             
  OUTREC=(C' OUTFIL SPLIT,FNAMES=(OUT',SEQNUM,3,ZD,C',',80:X)         
  OUTFIL FNAMES=T2,STARTREC=2,OMIT=(1,3,ZD,EQ,1),         
  OUTREC=(23X,C'OUT',SEQNUM,3,ZD,START=2,C',',80:X)                 
  OUTFIL FNAMES=T3,ENDREC=1,                             
  OUTREC=(23X,C'OUT',1,3,C')',80:X)                       
  OUTFIL FNAMES=T4,                                       
  OUTREC=(C'//OUT',SEQNUM,3,ZD,C' DD DSN=XXXXXXX.OUT',   
         SEQNUM,3,ZD,C',',/,                             
         C'//',12X,C'DISP=(NEW,CATLG,DELETE),',/,       
         C'//',12X,C'UNIT=SYSDA,',/,                     
         C'//',12X,C'SPACE=(CYL,(1,1),RLSE)',80:X)       
/*                                                       
//STEP020  EXEC  PGM=SORT                       
//SYSOUT   DD SYSOUT=*                         
//SYSIN    DD *                                 
   OPTION COPY                                   
/*                                             
//SORTOUT  DD SYSOUT=(*,INTRDR)                 
//SORTIN   DD DATA,DLM=$$                       
//TIDXXXX  JOB 'COPY',                         
//             CLASS=A,                         
//             MSGCLASS=Y,                     
//             MSGLEVEL=(1,1),                 
//             NOTIFY=&SYSUID                   
//*                                             
//STEP0100 EXEC  PGM=SORT                       
//*                                             
//SYSOUT   DD SYSOUT=*                         
//SORTIN   DD DSN=YOUR INPUT FILE NAME,
//            DISP=SHR                                 
//SYSIN    DD *                       
  OPTION COPY                         
$$                                   
//         DD DSN=&T1,DISP=(OLD,PASS)
//         DD DSN=&T2,DISP=(OLD,PASS)
//         DD DSN=&T3,DISP=(OLD,PASS)
//         DD DSN=&T4,DISP=(OLD,PASS)
/*                                   


Hope this helps...


kolusu


Last edited by kolusu on Sun Jan 05, 2003 11:18 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Jeba
Beginner


Joined: 02 Dec 2002
Posts: 48
Topics: 9
Location: Columbus, GA

PostPosted: Wed Dec 04, 2002 10:53 am    Post subject: Reply with quote

Kolusu,

Thanks. It worked. This is what exactly I expected.
_________________
Thanks,
Jeba
(Known is a drop Unknown is an ocean)
Back to top
View user's profile Send private message Send e-mail
moyeenkhan
Beginner


Joined: 04 Dec 2002
Posts: 64
Topics: 21

PostPosted: Wed Dec 04, 2002 1:47 pm    Post subject: Reply with quote

The easiest way to do this by a rexx / clist program. Let me know the outfile naming standards. I will post the rexx program

Thanks
Back to top
View user's profile Send private message Send e-mail
jay
Beginner


Joined: 03 Dec 2002
Posts: 3
Topics: 1

PostPosted: Thu Dec 05, 2002 8:39 am    Post subject: Reply with quote

Hi moyeenkhan,

It would be great if you post your REXX code that will achieve this.
It would be really helpful to all.

Thanx
Laughing
Back to top
View user's profile Send private message
moyeenkhan
Beginner


Joined: 04 Dec 2002
Posts: 64
Topics: 21

PostPosted: Mon Dec 09, 2002 10:08 am    Post subject: Reply with quote

Here is the code

Code:

/*                              */         
/*              Rexx            */         
/*       moyeenkhan@yahoo.com   */         
/*                              */         
xInfile='Full.Input.Name'                 
xOutPrfx='Full.Out.Name.Prefix'           
Call ReadInp                               
If xInp.0 > 0 Then Call SplitInp           
Exit                                       
                                           
ReadInp:                                   
Address TSO                               
xMsgSt = msg(off)                         
'FREE DD(MYINP)'                           
"ALLOC DD(MYINP) DA('"xInFile"') SHR"     
'EXECIO * DISKR MYINP (STEM xInp. FINIS'   
'FREE DD(MYINP)'                           
xReset=Msg(xMsgSt)                         
Return                                     
                                                                       
SplitInp:                                                               
Address TSO                                                             
Do I=1 By 1 Until I=xInp.0                                             
 xData=xInp.I                                                           
 xOutName="'"xOutPrfx||Right(I,3,0)"'"                                 
 xSamFir=MSG('OFF')                                                     
 'DELETE' xOutName                                                     
 'FREE DD(xOutDsn)'                                                     
 "ALLOC DD(xOutName) DSN("xOutName") NEW CATALOG",                     
       'LRECL(27364) BLKSIZE(0) RECFM(V, B) DSORG(PS) UNIT(DISK)',     
       'SPACE (1 1) TRACKS'                                             
 xAskNb=MSG(xSamFir)                                                   
 If Rc<>0 Then Exit                                                     
 xOutData.0=1                                                           
 xOutData.1=xData                                                       
 'EXECIO * DISKW xOutName (Stem xOutData. Finis'                       
 'FREE DD(xOutDsn)'                                                     
 End                                                                   
Return
Back to top
View user's profile Send private message Send e-mail
rajvasan
Beginner


Joined: 10 Dec 2002
Posts: 14
Topics: 4

PostPosted: Sun Jan 05, 2003 9:24 am    Post subject: Reply with quote

Kolusu,
I have a question. Why do we have to sort it in Descending order.

Thanks,
Rajvasan
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Sun Jan 05, 2003 10:40 am    Post subject: Reply with quote

Rajvasan,

In STEP010, Kolusu is creating an OUTFIL statement like this:

Code:

 OUTFIL SPLIT,FNAMES=(OUT001,    From T1   
           OUT002,    From T2
            ...
           OUTnnn)    From T3 


The descending sort on the sequence numbers makes them look like this:

Code:

nnn
...
002
001


The nnn sequence number is equal to the count of records = data sets needed. So now Kolusu can use:

Code:

  OUTFIL FNAMES=T3,ENDREC=1,             
   OUTREC=(23X,C'OUT',1,3,C')',80:X)     


to create the OUTnnn statement since ENDREC=1 gets the first record which has nnn. This is a clever way to easily access the count of records.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


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

PostPosted: Sun Jan 05, 2003 10:45 am    Post subject: Reply with quote

Rajvasan,

We need to sort in the descending order so that we will know the max : of files to be created.Let us you have 25 records in your file.

The sysin cards are as follows

Code:

 
  INREC FIELDS=(SEQNUM,3,ZD)
  SORT FIELDS=(1,3,ZD,D)


Now the last record will be the first record and this tells us as to how many files to be created.

If you don't sort in descending order , there is no way to know the no: of files to be created.

the job builds the dynamic control cards. So we need to know the last record to end the control cards.Look at the closing parenthesis.So sorting on descending seqnum will give the last record and we can use that record to end the dynamic control cards.

Code:

OUT025)


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Sun Jan 05, 2003 10:58 am    Post subject: Reply with quote

Kolusu,

I noticed that the job as you have coded it won't work for two records. You could fix that by changing the FNAMES=T3 statement to:

Code:

  OUTFIL FNAMES=T2,STARTREC=2,OMIT=(1,3,ZD,EQ,1),     
   OUTREC=(23X,C'OUT',SEQNUM,3,ZD,START=2,C',',80:X) 


Note EQ,1 instead of EQ,2. EQ,2 would omit the next to last record, but you really want to omit the last record which has sequence number 1. With 2, both T2 and T3 will have OUT002. With 1, T2 won't have any records and T3 will have OUT002.

For completeness (even though it's not likely to be a problem), note that either way, this won't work for just one record because both T1 and T3 will have OUT001.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


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

PostPosted: Sun Jan 05, 2003 11:20 am    Post subject: Reply with quote

Thanks Frank. I have changed the control cards for T2. As always there is a catch for every solution like in this case having just 1 record in the input file.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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