Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 FTP Skip or ignore error and process ... AJAYREDDY All Other Mainframe Topics 3 Wed Sep 27, 2017 8:12 pm
No new posts Comparing 2 Files using Current time arunsoods SYNCSORT 9 Fri Sep 22, 2017 6:00 pm
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am
No new posts Mainframe dataset split purushottam DFSORT/ICETOOL 13 Tue Aug 29, 2017 12:28 pm
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 22 Sun Aug 27, 2017 10:35 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us