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 a file into four with no discernible key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Splitting a file into four with no discernible key
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Thu Jun 12, 2014 1:58 pm    Post subject: Reply to: Splitting a file into four with no discernible key
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Thu Jun 12, 2014 2:10 pm    Post subject: Reply to: Splitting a file into four with no discernible key
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Thu Jun 12, 2014 2:53 pm    Post subject: Reply to: Splitting a file into four with no discernible key
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    Post subject:
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Fri Jun 13, 2014 1:03 pm    Post subject: Reply to: Splitting a file into four with no discernible key
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Fri Jun 13, 2014 1:38 pm    Post subject: Reply to: Splitting a file into four with no discernible key
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


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