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

Split a file into 2 output files


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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
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
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
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
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
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: 1702
Location: Australia

PostPosted: Thu Mar 18, 2010 10:12 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
Search our Forums:

Back to Top