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

Splitting a file into four with no discernible key


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

New User


Joined: 11 Jun 2014
Posts: 9
Location: England

PostPosted: Thu Jun 12, 2014 1:40 pm
Reply with quote

I've got an input file that looks like this:
HEADER1
DETAIL1
FOOTER1
HEADER2
DETAIL2
FOOTER2
HEADER3
DETAIL3
FOOTER3
HEADER4
DETAIL4
FOOTER4

I want to strip the detail records out into four different files. But there is no key field to distinguish them. Using COBOL it would be easy, but I need (want?) to use DFSORT.

So, how do I use the header record as some sort of trigger to tell DFSORT to use the next output file?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jun 12, 2014 1:58 pm
Reply with quote

You specify multiple output files using one OUTFIL for each. There you state selection criteria (INCLUDE= or OMIT=, or SPLIT*, or several others for numbers of records).

So, what selection criteria do you want?
Back to top
View user's profile Send private message
marc_holmes

New User


Joined: 11 Jun 2014
Posts: 9
Location: England

PostPosted: Thu Jun 12, 2014 2:07 pm
Reply with quote

Bill, that's the problem, there are no discernible selection criteria. There's nothing in the records that you could use to split them, They are all different layouts. Essentially it is four different files in one dataset.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jun 12, 2014 2:10 pm
Reply with quote

OK, with DFSORT there is a PTF available which supports MAGIC=ON on the OPTION statement. However, it is for internal use only.

If it is "easy" in COBOL, perhaps you could reveal an outline of that coding?
Back to top
View user's profile Send private message
marc_holmes

New User


Joined: 11 Jun 2014
Posts: 9
Location: England

PostPosted: Thu Jun 12, 2014 2:31 pm
Reply with quote

There are four headers, four footers and lots of detail.
Start a count at 0. Whenever I get a header record add 1. The counter can be used to determine which file to write to. If 1 then File1, if 2 then File2 etc.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jun 12, 2014 2:53 pm
Reply with quote

So, on INREC use IFTHEN=(WHEN=GROUP to identify your headers, and PUSH an ID onto an extension of the record.

The ID will be a sequence number per group of records, one for the first, two for the second, three for the third.

This then gives you your INCLUDE= for OUTFIL. position,length,one for the first OUTFIL, two for the second, where one and two are C'1' and C'2' assuming you really have four groups (this means you use a one-digit ID, which is ID=1).
Back to top
View user's profile Send private message
marc_holmes

New User


Joined: 11 Jun 2014
Posts: 9
Location: England

PostPosted: Thu Jun 12, 2014 2:58 pm
Reply with quote

OK, thanks, I'll give it a try.
Back to top
View user's profile Send private message
marc_holmes

New User


Joined: 11 Jun 2014
Posts: 9
Location: England

PostPosted: Fri Jun 13, 2014 12:32 pm
Reply with quote

Bill, thanks for the help. I've now got four jobs, each with the below statement but with different values for the INCLUDE= (the output goes direct into a set of Teradata Fastloads so I strip the header and footer). Maybe not the most efficient way of doing it (one job splitting the file and then four loads may be better) but it fits with our standard design pattern.

OPTION COPY
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(13,6,CH,EQ,C'HEADER'),
END=(13,6,CH,EQ,C'FOOTER'),PUSH=(761:ID=1))
OUTFIL INCLUDE=(761,1,CH,EQ,C'1',
AND,13,6,CH,NE,C'HEADER',
AND,13,6,CH,NE,C'FOOTER'),
BUILD=(1,760)
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Jun 13, 2014 1:03 pm
Reply with quote

seems from Your last post that the header is just "HEADER" for every group

if that is the case You can do it in one sort step
( changed the strings for less typing , the POC still stands )

Code:

//S1      EXEC PGM=SORT
//SYSPRINT  DD SYSOUT=*
//SYSOUT    DD SYSOUT=*
//SORTIN    DD *
H
SOMETHING FOR FILE1
T
H
SOMETHING FOR FILE2
SOMETHING FOR FILE2
T
H
SOMETHING FOR FILE3
SOMETHING FOR FILE3
SOMETHING FOR FILE3
T
H
SOMETHING FOR FILE4
SOMETHING FOR FILE4
SOMETHING FOR FILE4
SOMETHING FOR FILE4
T
//OUT1      DD SYSOUT=*
//OUT2      DD SYSOUT=*
//OUT3      DD SYSOUT=*
//OUT4      DD SYSOUT=*
//SYSIN     DD *
  OPTION COPY
  INREC  IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'H'),
                 PUSH=(51:ID=1))
  OUTFIL FNAMES=OUT1,INCLUDE=(51,1,CH,EQ,C'1',AND,
                               1,1,CH,NE,C'H',AND,
                               1,1,CH,NE,C'T')
  OUTFIL FNAMES=OUT2,INCLUDE=(51,1,CH,EQ,C'2',AND,
                               1,1,CH,NE,C'H',AND,
                               1,1,CH,NE,C'T')
  OUTFIL FNAMES=OUT3,INCLUDE=(51,1,CH,EQ,C'3',AND,
                               1,1,CH,NE,C'H',AND,
                               1,1,CH,NE,C'T')
  OUTFIL FNAMES=OUT4,INCLUDE=(51,1,CH,EQ,C'4',AND,
                               1,1,CH,NE,C'H',AND,
                               1,1,CH,NE,C'T')
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jun 13, 2014 1:38 pm
Reply with quote

With the four OUTFILs, as enrico has shown in his code, the input data is only read once.

If you have only a small amount of data, this won't be so important. The larger your data, the greater the resource savings.
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 How to split large record length file... DFSORT/ICETOOL 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top