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
 

 

Splitting the flat file by using SORT Utility

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Splitting the flat file by using SORT Utility
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: 171
Location: Bangalore

PostPosted: Wed Apr 09, 2008 5:47 pm    Post subject: Reply to: Splitting the flat file by using SORT Utility
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    Post subject:
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    Post subject: Reply to: Splitting the flat file by using SORT Utility
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: 8593
Location: Back in jolly old England

PostPosted: Thu Apr 10, 2008 1:39 pm    Post subject:
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    Post subject:
Reply with quote

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

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Apr 10, 2008 1:44 pm    Post subject:
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: 182
Location: hyderabad

PostPosted: Thu Apr 10, 2008 1:46 pm    Post subject:
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    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Thu Apr 10, 2008 2:33 pm    Post subject: Reply to: Splitting the flat file by using SORT Utility
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    Post subject:
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

Site Director


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

PostPosted: Fri Apr 11, 2008 1:08 am    Post subject:
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 Moderator


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

PostPosted: Fri Aug 08, 2008 3:04 am    Post subject:
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:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 1 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 3 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


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