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 a file into 2 output files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
sguhan

New User


Joined: 15 Mar 2010
Posts: 9
Location: Chennai

PostPosted: Tue Mar 16, 2010 12:30 pm    Post subject: Split a file into 2 output files
Reply with quote

I have a scenario wherein i have to split an input file into 2 output files.

input File layout

$$$ ABC (header)
1111111111111111111
2222222222222222222
3333333333333333333
$$$ XYZ (header)
1111122211113333333
2453333333331111111
5555555555555555555

I want different header and its corresponding detail records to be split into 2 files..

outfile1

$$$ ABC (header)
1111111111111111111
2222222222222222222
3333333333333333333

outfile2
$$$ XYZ (header)
1111122211113333333
2453333333331111111
5555555555555555555.

$$$ is the identifier for header record.Detail records do not have any identifier. Could this be achieved using SORT? If so,How?
Back to top
View user's profile Send private message

Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Mar 16, 2010 12:41 pm    Post subject:
Reply with quote

What is the SORT product you are using?
Back to top
View user's profile Send private message
sguhan

New User


Joined: 15 Mar 2010
Posts: 9
Location: Chennai

PostPosted: Tue Mar 16, 2010 12:42 pm    Post subject:
Reply with quote

I am using ICETOOL
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Mar 16, 2010 12:54 pm    Post subject:
Reply with quote

expat wrote:

Because the solution for sort related questions may vary from product to product, please ensure that you state clearly which sort product you are using.

If you are not sure, then by running a simple sort step shown below, you will be able to find out for yourself.

If the messages start with ICE then your product is DFSORT. Please also post the output of the complete line which has a message code ICE201I, as this will enable our DFSORT experts to determine which release of DFSORT that you have installed. This may also affect the solution offered.

If the messages start with WER or SYT then the product is SYNCSORT and the topic will be moved into the JCL forum by one of the moderators. Please also post the information telling which version of SYNCSORT is installed, as this may also affect the solution offered.

Thank you for taking your time to ensure that the valuable time of others is not wasted by offering inappropriate solutions which are not relevant due to the sort product being used and/or the release that is installed in your site.

Code:
//SORTSTEP EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
ABC
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  SORT     FIELDS=COPY


You also need to give more information that you have bothered to do.
1) RECFM and LRECL of both files

Answer to this post of expat to get correct solution.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Mar 16, 2010 3:28 pm    Post subject:
Reply with quote

sguhan wrote:
I am using ICETOOL

Assuming you have DFSORT and LRECL=80, RECFM=FB
below step will give you desired output...
Code:

//S1    EXEC  PGM=SORT                                     
//SYSOUT    DD  SYSOUT=*                                   
//SORTIN DD *                                             
$$$ ABC (header)                                           
1111111111111111111                                       
2222222222222222222                                       
3333333333333333333                                       
$$$ XYZ (header)                                           
1111122211113333333                                       
2453333333331111111                                       
5555555555555555555                                       
/*                                                         
//SYSOUT   DD SYSOUT=*                                     
//OUT1  DD SYSOUT=*                                       
//OUT2  DD SYSOUT=*                                       
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                         
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),       
               PUSH=(81:ID=1))                           
  OUTFIL FNAMES=OUT1,INCLUDE=(81,1,ZD,EQ,1),BUILD=(1,80) 
  OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,80)                   
/*                                                       
Back to top
View user's profile Send private message
sguhan

New User


Joined: 15 Mar 2010
Posts: 9
Location: Chennai

PostPosted: Thu Mar 18, 2010 10:08 am    Post subject:
Reply with quote

It worked. Thanks..

I have modified the code to remove the header being written into output file..

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
$$$ ABC (header)
1111111111111111111
2222222222222222222
3333333333333333333
$$$ XYZ (header)
1111122211113333333
2453333333331111111
5555555555555555555
/*
//SYSOUT DD SYSOUT=*
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),
PUSH=(81:ID=1))
OUTFIL FNAMES=OUT1,INCLUDE=(81,1,ZD,EQ,1,AND,
1,3,CH,NE,C'$$$'),BUILD=(1,80)
OUTFIL FNAMES=OUT2,INCLUDE=(81,1,ZD,EQ,2,AND,
1,3,CH,NE,C'$$$'),BUILD=(1,80)

/*

it worked.. i want to sort the detail records before writing it to the output file.. How could this be acheived?

Instead of putting SORT FIELDS=COPY , can i use SORT FIELDS=(1,3,CH,A)? if i input this which operation will get executed first? will it remove the header records and then sort the file ? Please advise?
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Thu Mar 18, 2010 10:12 am    Post subject:
Reply with quote

Hi,

why not just run it and see the results ?


Gerry
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