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 Comparing two sequential files Mohan Kothakota COBOL Programming 14 Mon Apr 16, 2018 6:35 pm
No new posts SORT 3 files,extract specific fields ... Kiransr DFSORT/ICETOOL 13 Fri Mar 23, 2018 10:54 am
No new posts How to build one file from two input ... daniele DFSORT/ICETOOL 5 Tue Feb 27, 2018 6:45 pm
No new posts Compare two PS files using ICE TOOL f... SENTHIL MURUGAAN DFSORT/ICETOOL 5 Sun Dec 24, 2017 1:26 pm
No new posts Compare VSAM files using DFSORT pshongal DFSORT/ICETOOL 5 Thu Nov 23, 2017 10:24 am

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