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
 

 

Split rcords into 2 different files

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

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Tue Feb 28, 2006 2:24 am    Post subject: Split rcords into 2 different files
Reply with quote

I have a requirement where I need to select a particular set of records into 1 file and remaining into another file. Can I achieve this in a single step.

Input File:
A 111111111
A 222222222
B 111111111
C 111111111
A 777777777
D 666666666

I need all records starting with 'A' in one file and remaining in another file.
Outfile 1 :
A 111111111
A 222222222
A 777777777

Outfile 2:
B 111111111
C 111111111
D 666666666

Is there a direct method instead of using select statements with 2 control cards. It'll be helpful if I can do it in one single step where I give an include condition for one case for all the records to go into output file 1 and in the same step rest of the records will go to output file 2 also. Please help.
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: Tue Feb 28, 2006 4:06 am    Post subject:
Reply with quote

You can use a DFSORT job like this to do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//OUT1 DD DSN=...    output file1
//OUT2 DD DSN=...    output file2
//SYSIN    DD    *
  OPTION COPY
  OUTFIL FNAMES=OUT1,INCLUDE=(1,1,CH,EQ,C'A')
  OUTFIL FNAMES=OUT2,SAVE
/*


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
Back to top
View user's profile Send private message
pjnithin

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Wed Mar 01, 2006 12:57 am    Post subject:
Reply with quote

In the same step is it possible for me to sort the file based on the last 9 bytes.
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 Mar 01, 2006 3:23 am    Post subject:
Reply with quote

Sure, just change:

Code:

   OPTION COPY


to:

Code:

   SORT FIELDS=(3,9,CH,A)


Use ZD instead of CH if you want to treat the key as numeric (zoned decimal).
Back to top
View user's profile Send private message
pjnithin

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Wed Mar 01, 2006 8:58 am    Post subject:
Reply with quote

But I need only the OUT1 file to be sorted. I think the above mentioned method sorts both the files.
Back to top
View user's profile Send private message
fixdoubts

New User


Joined: 21 Oct 2005
Posts: 54

PostPosted: Wed Mar 01, 2006 1:51 pm    Post subject:
Reply with quote

Hi,

Im not sure this optimal one but it works.
Code:

//S1    EXEC  PGM=ICETOOL
//SYSOUT    DD  SYSOUT=*
//IN1    DD DSN=...  input file
//OUT1 DD DSN=...    output file1
//OUT2 DD DSN=...    output file2
//TOOL IN DD *
   COPY FROM(IN1) TO(OUT1) USING(CPY1)
   COPY FROM(IN1) TO(OUT2) USING(CPY2)
/*
//CPY1CNTL    DD    *
  SORT FIELDS=(LAST 9)
  INCLUDE COND=(1,1,CH,EQ,C'A')
/*
//CPY2CNTL    DD    *
  OPTION COPY
  OMIT COND=(1,1,CH,EQ,C'A')
/*


This will do i think might not be an optimal one but it will do what you wanted.

Regards,
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 Mar 01, 2006 9:26 pm    Post subject:
Reply with quote

Quote:
But I need only the OUT1 file to be sorted. I think the above mentioned method sorts both the files.


And was I supposed to know that by reading your mind? Please try to be more clear in your requirements in the future so we don't waste your time or mine.

If you want to sort the 'A' records, but not the 'B' records, you have to use two passes. Here are two ways to do that with DFSORT/ICETOOL:

Method 1

Code:

//S2    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...  input file1
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT1 DD DSN=...  output file1
//OUT2 DD DSN=...  output file2
//TOOLIN   DD    *
* IN->T1: 'A' records (unsorted)
* IN->OUT2: non-'A' records (unsorted)
COPY FROM(IN) USING(CTL1)
* T1->OUT1:  Sort 'A' records
SORT FROM(T1) TO(OUT1) USING(CTL2)
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=T1,INCLUDE=(1,1,CH,EQ,C'A')
  OUTFIL FNAMES=OUT2,SAVE
/*
//CTL2CNTL DD *
  SORT FIELDS=(3,9,CH,A)
/*


Method 2

Code:

//S3    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...  input file1
//OUT1 DD DSN=...  output file1
//OUT2 DD DSN=...  output file2
//TOOLIN   DD    *
* IN->OUT1:  'A' records (sorted)
SORT FROM(IN) TO(OUT1) USING(CTL1)
* IN->OUT2:  non-'A' records (unsorted)
COPY FROM(IN) TO(OUT2) USING(CTL2)
/*
//CTL1CNTL DD *
  INCLUDE COND=(1,1,CH,EQ,C'A')
  SORT FIELDS=(3,9,CH,A)
/*
//CTL2CNTL DD *
  INCLUDE COND=(1,1,CH,NE,C'A')
/*
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 Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 15 Thu Dec 01, 2016 8:28 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm


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