Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Copying half records into one file & remaning into other

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
VIKAS GAIKWAD

New User


Joined: 30 Nov 2006
Posts: 33
Location: MUMBAI

PostPosted: Mon Sep 03, 2007 12:44 pm    Post subject: Copying half records into one file & remaning into other
Reply with quote

Hi,

I have one file having 100 records in it. I want to create two files from this file.
1. Which will contain first 50 records
2. It will contain remaining 50 records.
Is there is any way to do it by using SORT?

Thanks,

Vikas.
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Mon Sep 03, 2007 12:54 pm    Post subject:
Reply with quote

Hi There,

You can use following JCL
Code:
//SORTIN   DD DISP=SHR,DSN=input data set
//FIRST   DD DSN=output data set,     
//         DISP=(NEW,CATLG,CATLG),                     
//         DCB=(RECFM=FB,LRECL=80,BLKSIZE=800),         
//         SPACE=(CYL,(5,1),RLSE)                       
//REMAIN   DD DSN=A40661.£K.STARTREC.OUTPUT2.FILE,     
//         DISP=(NEW,CATLG,CATLG),                     
//         DCB=(RECFM=FB,LRECL=80,BLKSIZE=800),         
//         SPACE=(CYL,(5,1),RLSE)               
//SORTWK1  DD UNIT=SYSDA,SPACE=(CYL,(10,10))           
//SORTWK2  DD UNIT=SYSDA,SPACE=(CYL,(10,10))           
//SYSOUT   DD SYSOUT=*                                 
//SYSIN    DD *                                         
  OPTION COPY
  OUTFIL FNAMES=FIRST,ENDREC=50               
  OUTFIL FNAMES=REMAIN,STARTREC=51   
/*
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Sep 03, 2007 9:21 pm    Post subject:
Reply with quote

Here's a simpler way to do it with DFSORT:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//OUT1 DD DSN=...    output file1 (first 50 records)
//OUT2 DD DSN=...    output file2 (remaining records)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL SPLIT1R=50,FNAMES=(OUT1,OUT2)
/*
Back to top
View user's profile Send private message
VIKAS GAIKWAD

New User


Joined: 30 Nov 2006
Posts: 33
Location: MUMBAI

PostPosted: Wed Sep 05, 2007 11:30 am    Post subject:
Reply with quote

Hi,

Thanks Ekta, Thanks Frank Above JCL's are working. I apologize the way in which I written the question.
The question is The input file may have 100 or 200 or any no. of records, I want to split input file into two files, half records in one file & remaining into another half. If Input file contains odd number of records the Int(n/2+1) into first file & remaining into second file.

Thanks,

Vikas.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Wed Sep 05, 2007 12:27 pm    Post subject:
Reply with quote

Vikas,

Frank's JCL holds good for your requirement.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Wed Sep 05, 2007 1:20 pm    Post subject:
Reply with quote

Code:
// EXEC PGM=ICETOOL                                           
//DFSMSG DD SYSOUT=*                                           
//TOOLMSG DD SYSOUT=*                                           
//IN DD DSN=...,DISP=SHR                         
//T DD DSN=&T1,DISP=(,PASS)                                     
//CTL3CNTL DD DSN=&T2,DISP=(,PASS)                               
//FILE1 DD SYSOUT=*                                             
//FILE2 DD SYSOUT=*                                             
//TOOLIN DD  *                                                 
 COPY FROM(IN) TO(T) USING(CTL1)                               
 COPY FROM(T) TO(CTL3CNTL) USING(CTL2)                         
 COPY FROM(IN) TO(FILE1,FILE2) USING(CTL3)                     
/*                                                             
//CTL1CNTL DD *                                                 
 OPTION COPY                                                   
 OUTFIL REMOVECC,NODETAIL,TRAILER1=(COUNT=(M11,LENGTH=8),80:X) 
/*                                                             
//CTL2CNTL DD *                                                     
 OUTFIL OUTREC=(C' OPTION COPY',/,                                 
                C' OUTFIL FNAMES=(FILE1,FILE2),SPLITBY=',           
                1,8,ZD,DIV,+2,ADD,1,8,ZD,MOD,+2,M11,LENGTH=15,80:X)
/*                                                                 
//                                                                 
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Sep 05, 2007 9:16 pm    Post subject:
Reply with quote

Vikas,

See the "Split a file to n output files dynamically" Smart DFSORT Trick at:

http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/

shankar,

When I ran your job with DFSORT, it got a RC=16. Please try your jobs to see if they work before posting them!
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Thu Sep 06, 2007 11:05 am    Post subject:
Reply with quote

Frank,
Quote:
Please try your jobs to see if they work before posting them!

As per your kindly advice, hereafter i follow your words.
But that job ran successfully with syncsort.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Sep 06, 2007 8:43 pm    Post subject:
Reply with quote

Hello,

If you post a Syncsort solution in this DFSORT forum, it would at least be a good idea to mention that the suggestion was a Syncsort solution.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Sep 06, 2007 9:39 pm    Post subject:
Reply with quote

Shankar,

This is the DFSORT Forum. People come here looking for a DFSORT solution. If you can't test with DFSORT, then I'd respectively suggest you not post in this Forum.

Note that while full documentation is available for DFSORT's ICETOOL, there's no documentation for Syncsort's SYNCTOOL. So you can't really look up what syntax is valid for SYNCTOOL or what the use of particular syntax will accomplish with SYNCTOOL. You can only experiment. And the DFSORT Forum is not the appropriate place for SYNCTOOL experiments.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
No new posts copying data without knowing location arunsoods DFSORT/ICETOOL 6 Thu Jul 20, 2017 1:03 pm
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us