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

Splitting records using DFSORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sunnyk

New User


Joined: 20 Oct 2004
Posts: 59

PostPosted: Thu Jun 29, 2006 12:31 pm
Reply with quote

Hi,
I have a requirement wherein i want to split one file(containing multiple Headers/Records/Trailers) into "n" number of files. The records in the input file are like :

HEADER1
record1....
record2....
recordn....
TRAILER1
HEADER2
record1....
record2....
recordn....
TRAILER2
TRAILER1
HEADERn
record1....
record2....
recordn....
TRAILERn

I want to put each Header/Records/Trailer records into separate files.

And i don't know how many records are there in the file(so don't know how many output files will be created).

But assuming there won't be more than 50 records in the input file, is there any way to do this using DFSORT?

Regds
Sunny
Back to top
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Thu Jun 29, 2006 6:46 pm
Reply with quote

Try this link, Frank has provided this link

www.ibm.com/servers/storage/support/software/sort/mvs/tricks/srtmtrck.html#a02
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: Thu Jun 29, 2006 9:30 pm
Reply with quote

You can use a DFSORT job like the one below to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, and you can have up to 50 output files. The first header/detail/trailer group will go to OUT01, the second to OUT02, etc. If you have less than 50 groups (e.g. 40), then the remaining OUTnn files will be empty (e.g. OUT41-OUT50).

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//OUT01 DD DSN...  output file 01 (FB/80)
//OUT02 DD DSN...  output file 02 (FB/80)
...
//OUT50 DD DSN...  output file 50 (FB/80)
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,2,ZD)),               
        IFTHEN=(WHEN=(1,6,CH,EQ,C'HEADER'),                       
                OVERLAY=(81:SEQNUM,2,ZD)),                         
        IFTHEN=(WHEN=NONE,                                         
                OVERLAY=(83:SEQNUM,2,ZD,                           
                         81:81,2,ZD,SUB,83,2,ZD,M11,LENGTH=2))     
  OUTFIL FNAMES=OUT01,INCLUDE=(81,2,ZD,EQ,+1),BUILD=(1,80)         
  OUTFIL FNAMES=OUT02,INCLUDE=(81,2,ZD,EQ,+2),BUILD=(1,80)
  ...       
  OUTFIL FNAMES=OUT50,INCLUDE=(81,2,ZD,EQ,+50),BUILD=(1,80)         
/*
Back to top
View user's profile Send private message
sunnyk

New User


Joined: 20 Oct 2004
Posts: 59

PostPosted: Fri Jun 30, 2006 11:12 am
Reply with quote

Hi Frank,
Thanks for your quich response. But i guess i need to check with client if there is ICEMAN tool available. Can we do it using some other tool also?

And i was not able to understand the following IFTHEN:
IFTHEN=(WHEN=NONE,
OVERLAY=(83:SEQNUM,2,ZD,
81:81,2,ZD,SUB,83,2,ZD,M11,LENGTH=2))

I understand what WHEN=NONE does but in OVERLAY what are we actually trying to do, can you please explain with some example.
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 Jun 30, 2006 8:22 pm
Reply with quote

PGM=ICEMAN invokes DFSORT. If you have z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213, then you can use IFTHEN. These PTFs have been available since Dec, 2004.

For an explanation of the IFTHEN "group" technique, see these Smart DSORT Tricks:

www.ibm.com/servers/storage/support/software/sort/mvs/tricks/srtmtrck.html#d01

www.ibm.com/servers/storage/support/software/sort/mvs/tricks/srtmtrck.html#d02

For complete details on the Dec, 2004 DFSORT PTF functions, see:

Use [URL] BBCode for External Links

For complete details on the April, 2006 DFSORT PTF functions, 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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top