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

Splitting the flat file by using SORT Utility


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Hari1282

New User


Joined: 31 Mar 2008
Posts: 7
Location: Pune, INDIA

PostPosted: Wed Apr 09, 2008 5:45 pm
Reply with quote

Hi All,

I have one flat file it consists of Header, records and Trailer.
Here my requirement is I want to copy Header in one file Records in one file and Trailer in one file.

Is it possible by using sort utility in JCL.
Back to top
View user's profile Send private message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 174
Location: Bangalore

PostPosted: Wed Apr 09, 2008 5:47 pm
Reply with quote

Can you please provide your sample input file...?
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Wed Apr 09, 2008 6:02 pm
Reply with quote

yes it's posible, search for OUTFIL.

Code:
OUTFIL FILES=01,INCLUDE=(CONDITIONFORHEADER)
OUTFIL FILES=02,INCLUDE=(CONDITIONFORDETAILS)
OUTFIL FILES=03,INCLUDE=(CONDITIONFORTRAILER)
Back to top
View user's profile Send private message
Hari1282

New User


Joined: 31 Mar 2008
Posts: 7
Location: Pune, INDIA

PostPosted: Thu Apr 10, 2008 1:09 pm
Reply with quote

Hi All,

Below is the example for my input file.

AC325644120080410130356 ----- Header
4521356 0 200804090001 ----- Record 1
4512345 1 200803310000 ----- Record 2
AC325644120080410130628 ----- Trailer

Now I want to split above file into three output files such as
Header in File 1
Record 1 and Record 2 in File 2
Trailer in File 3
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Thu Apr 10, 2008 1:39 pm
Reply with quote

Is this because you want to sort the records between the header and trailer but keep the header / trailer seperate to rebuild the file after sorting ?
Back to top
View user's profile Send private message
Hari1282

New User


Joined: 31 Mar 2008
Posts: 7
Location: Pune, INDIA

PostPosted: Thu Apr 10, 2008 1:42 pm
Reply with quote

Yes excatly.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Thu Apr 10, 2008 1:44 pm
Reply with quote

There is a search button at the top of the page, please use it as this topic has been discussed and answered with the correct code supplied.
Back to top
View user's profile Send private message
sril.krishy

Active User


Joined: 30 Jul 2005
Posts: 183
Location: hyderabad

PostPosted: Thu Apr 10, 2008 1:46 pm
Reply with quote

Hari1282,
Please see the below code.


Code:

//PS020    EXEC PGM=ICETOOL                                             
//SYSOUT   DD  SYSOUT=*                                                 
//TOOLMSG  DD  SYSOUT=*                                                 
//DFSMSG   DD  SYSOUT=*                                                 
//IN       DD  *                                                       
AC325644120080410130356 ----- HEADER                                   
4521356 0 200804090001 ----- RECORD 1                                   
4512345 1 200803310000 ----- RECORD 2                                   
AC325644120080410130628 ----- TRAILER                                   
AC325644120080410130356 ----- HEADER                                   
4521356 0 200804090001 ----- RECORD 1                                   
4512345 1 200803310000 ----- RECORD 2                                   
AC325644120080410130628 ----- TRAILER                                   
//OUT1     DD  SYSOUT=*                                                 
//OUT2     DD  SYSOUT=*                                                 
//OUT3     DD  SYSOUT=*                                                 
//TMP1     DD  DSN=&&TA,UNIT=SYSDK,SPACE=(CYL,(5,5)),DISP=(,PASS)       
//TOOLIN   DD  *                                                       
   SORT FROM(IN) USING(CTL1)                                           
   SORT FROM(TMP1) USING(CTL2)                                         
//CTL1CNTL DD  *                                                       
   SORT FIELDS=COPY                                                     
   OUTFIL FNAMES=TMP1,INCLUDE=(1,2,CH,EQ,C'AC'),                       
   OUTREC=(1,40)                                                       
   OUTFIL FNAMES=OUT2,INCLUDE=(1,2,CH,NE,C'AC'),                       
   OUTREC=(1,40)                                                       
//CTL2CNTL DD  *                                                       
   SORT FIELDS=COPY                                                     
   OUTFIL FNAMES=(OUT1,OUT3),SPLIT                                     
/*                                                                     


The OUT1 output :

Code:


AC325644120080410130356 ----- HEADER
AC325644120080410130356 ----- HEADER



Code:


The OUT2 output :

4521356 0 200804090001 ----- RECORD 1
4512345 1 200803310000 ----- RECORD 2
4521356 0 200804090001 ----- RECORD 1
4512345 1 200803310000 ----- RECORD 2



The OUT3 output :

Code:


AC325644120080410130628 ----- TRAILER
AC325644120080410130628 ----- TRAILER




Thanks
Krishy
Back to top
View user's profile Send private message
Hari1282

New User


Joined: 31 Mar 2008
Posts: 7
Location: Pune, INDIA

PostPosted: Thu Apr 10, 2008 2:20 pm
Reply with quote

Hi Krishy,

Thanks a lot yaar.
Can I give PS file name instead of giving all the records in input file?
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Apr 10, 2008 2:33 pm
Reply with quote

hari,

Quote:

Can I give PS file name instead of giving all the records in input file?


Yes, You can .
Back to top
View user's profile Send private message
pavankumarhassaji

New User


Joined: 20 Aug 2007
Posts: 11
Location: Canada

PostPosted: Thu Apr 10, 2008 7:04 pm
Reply with quote

Hi,

if your requirement is to sort records of a file between header and trailer.
Then u need not split the file, u can directly do that using IFTHEN OVERLAY of ICETOOL

copy the file into a tempory file,
while copying that
overlay '0' for the header record at end of record say at 81st position
overlay '1' for the detail record same position as above
overlay '2' for the trailer record same position as above


now in the sort card give the 81st postion as primary key and secondary key as the sort field of detail record.

if u want any other info regarding IFTHEN OVERLAY, refer ICETOOL manual or SORT TRICS book, which u can find in this forum stickys

Thanks,
Pavan Hassaji.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Apr 11, 2008 1:08 am
Reply with quote

Hello,

To repeat what Expat posted. . . .
Quote:
Is this because you want to sort the records between the header and trailer but keep the header / trailer seperate to rebuild the file after sorting ?


To repeat what Hari1282 posted. . . .
Quote:
Yes excatly.


To repeat what Expat posted. . . .
Quote:
There is a search button at the top of the page, please use it as this topic has been discussed and answered with the correct code supplied.


There is no need to split the input to accomplish the requirement.

Hari, i'd suggest you become familiar and comfortable with the "SEARCH" feature (near the top of the page).

Here is one of the topics you could have found:http://ibmmainframes.com/viewtopic.php?t=23773&highlight=detail+header+trailer
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: Fri Aug 08, 2008 3:04 am
Reply with quote

With z/OS DFSORT V1R5 PTF UK90013 (July, 2008), you can now use DATASORT to sort the records between a header and a trailer quite easily.

For complete details on the new DATASORT function and the other new functions available with PTF UK90013, see:

Use [URL] BBCode for External Links
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Unable to interpret a hex value to De... COBOL Programming 4
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Is this possible via sort (in one pass)? SYNCSORT 4
No new posts GDG generation name to GDG Base name ... DFSORT/ICETOOL 3
No new posts SORT on detail record, then repeat he... DFSORT/ICETOOL 3
Search our Forums:

Back to Top