IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Copying half records into one file & remaning into other


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 1208
Location: Bangalore,India

PostPosted: Mon Sep 03, 2007 12:54 pm
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 Developer


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

PostPosted: Mon Sep 03, 2007 9:21 pm
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
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: 1436
Location: Bangalore,India

PostPosted: Wed Sep 05, 2007 12:27 pm
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
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 Developer


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

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

Vikas,

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

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
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

Moderator Emeritus


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

PostPosted: Thu Sep 06, 2007 8:43 pm
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 Developer


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

PostPosted: Thu Sep 06, 2007 9:39 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top