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 

How to split a file in to two halves

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


Joined: 02 Oct 2005
Posts: 20
Topics: 9

PostPosted: Tue Jan 10, 2006 11:40 pm    Post subject: How to split a file in to two halves Reply with quote

Hi All,

I am working on a request where we need to split the file into two halves.
How do we do it dyanmically?

Thanks in advance.

Regards,
uday.
Back to top
View user's profile Send private message
prakal
Beginner


Joined: 14 Mar 2003
Posts: 22
Topics: 1

PostPosted: Wed Jan 11, 2006 12:54 am    Post subject: Reply with quote

Not sure what you mean by splitting a file dynamically. If you are looking for a job that splits the file into two, SORT will do it for you. Please search for keyword SPLIT in this form to find lots of examples for splitting a file.
Back to top
View user's profile Send private message
eureka19
Beginner


Joined: 02 Oct 2005
Posts: 20
Topics: 9

PostPosted: Wed Jan 11, 2006 1:18 am    Post subject: Reply with quote

Sorry for not being clear.
Requirement : I have a transaction file. Number of records in the file keep changing daily. Assume file has 100 records.I need to copy first 50 in one file and the next 50 in another file.
The number 100 can vary. If the number is 50 then i need to copy 25 into one file and remaining 25 in to another file.

I have gone thru SPLIT keyword but it is not helping in solving this.

Please letme know ur ideas and suggestions.

Thanks,
Uday.
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Wed Jan 11, 2006 2:05 am    Post subject: Reply with quote

Eureka19,

The following link should help you !
http://mvsforums.com/helpboards/viewtopic.php?p=6493#6493

Let us know if need more information.

Cheers,

Phantom
Back to top
View user's profile Send private message
Alain Benveniste
Beginner


Joined: 04 May 2003
Posts: 92
Topics: 4
Location: Paris, France

PostPosted: Wed Jan 11, 2006 3:41 am    Post subject: Reply with quote

Here is an other way to that
Code:

//STEP0001 EXEC PGM=ICETOOL
//DFSMSG   DD SYSOUT=*
//TOOLMSG  DD SYSOUT=*
//TOOLIN   DD *
  COPY FROM(IN) USING(ICE0)
  COPY FROM(IN) USING(ICE1)
/*
//IN       DD *
A
B
C
D
E
F
G
H
I
J
K
/*
//OUTX     DD SYSOUT=*
//OUTY     DD SYSOUT=*
//ICE0CNTL DD *
  INREC FIELDS=(1,80,SEQNUM,5,ZD)
  OUTFIL FNAMES=ICE1CNTL,
         OUTREC=(1,80),
         REMOVECC,
         NODETAIL,
         TRAILER1=(C' OUTFIL FNAMES=(OUTX,OUTY),',/,
                   C'        SPLITBY=',AVG=(81,5,ZD,EDIT=(TTTTT)))
/*
//ICE1CNTL DD DISP=(NEW,DELETE,DELETE),
//            UNIT=SYSDA,
//            SPACE=(TRK,(1,0,0),RLSE),
//            DCB=(DSORG=PS,RECFM=FB,LRECL=80),
//            DSN=&&OUT

Alain
Back to top
View user's profile Send private message
eureka19
Beginner


Joined: 02 Oct 2005
Posts: 20
Topics: 9

PostPosted: Thu Jan 12, 2006 12:17 am    Post subject: Reply with quote

Thanks a lot for timely help.
It worked fine.

Regards,
Uday.
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: Fri May 12, 2006 12:36 pm    Post subject: Reply with quote

Here's a new solution for this requirement that uses the SPLIT1R function of DFSORT available with z/OS DFSORT PTF UK90007 and DFSORT R14 PTF UK90006. Whereas SPLITBY can rotate back to the first data set, resulting in non-contiguous records, SPLIT1R only does one rotation so the records are always contiguous.

Here's a DFSORT job that uses SPLIT1R dynamically to divide any number of input records among any number of output files:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=... input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//C1 DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//CTL3CNTL DD *
  OUTFIL FNAMES=(OUT01,OUT02,...,OUTnn),  <--- change for nn
//    DD DSN=*.C1,VOL=REF=*.C1,DISP=(OLD,PASS)
//OUT01 DD DSN=... output file01
//OUT02 DD DSN=... output file02
...
//OUTnn DD DSN=... output filenn  <--- change for nn
//TOOLIN DD *
* Get the record count.
COPY FROM(IN) USING(CTL1)
* Generate:
* SPLIT1R=x where x = count/nn.
* nn is the number of output files.
COPY FROM(T1) TO(C1) USING(CTL2)
* Use SPLIT1R=x to split records contiguously among
* the nn output files.
COPY FROM(IN) USING(CTL3)
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=T1,REMOVECC,NODETAIL,
    TRAILER1=(COUNT=(M11,LENGTH=8))
/*
//CTL2CNTL DD *
  OUTREC BUILD=(2X,C'SPLIT1R=',
    1,8,ZD,DIV,+nn,               <--- set to nn
      TO=ZD,LENGTH=8,80:X)
/*


For complete information on SPLIT1R and the other new DFSORT/ICETOOL functions available with the April, 2006 PTFs, see:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/
_________________
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
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