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

making OUTFIL's Trailer1 a Header1


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

New User


Joined: 31 Dec 2012
Posts: 31
Location: England

PostPosted: Fri May 31, 2013 5:22 pm
Reply with quote

OUTFIL's Trailer1 has counts and aggregates that can find use as a Header1 (which doesn't have the same counts for obvious reasons), but how to do it?
What I'd like to do is to take an input dataset, get counts, etc., then put a record of those counts as the first record.
My best thought at the moment is to read the input file and write just the Trailer1 record to a temporary dataset, then to Merge this sole record dataset with the original file. This would take two steps - one with a COPY and OUTFIL, and another with a MERGE: can it be done better, especially in just one step?
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri May 31, 2013 5:43 pm
Reply with quote

Do you mind pasting the code which you tried?

I couldnt follow your description pretty clear
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 May 31, 2013 7:11 pm
Reply with quote

Jim Alton wrote:
OUTFIL's Trailer1 has counts and aggregates that can find use as a Header1 (which doesn't have the same counts for obvious reasons), but how to do it?
What I'd like to do is to take an input dataset, get counts, etc., then put a record of those counts as the first record.
My best thought at the moment is to read the input file and write just the Trailer1 record to a temporary dataset, then to Merge this sole record dataset with the original file. This would take two steps - one with a COPY and OUTFIL, and another with a MERGE: can it be done better, especially in just one step?


If you just want original file, with a header at the front, one possibility which avoids another pass of the data is just to use "concatenation" to deal with the "file" (treat it as a "virtual file" consisting of two physical datasets). If your data is "huge", this may be effective. For smaller amounts of data, you might not want (or be able to have due to standards, audit requirements, whatever) this approach due to the extra "complexity".

JOINKEYS with the same file as the two inputs will be able to do what you want, using SUM in one of the CNTL files, but requires a SORT of the data.

To use MERGE your data needs to be in sequence on a key, and that key has to be "lowest" for your header. You can use INREC and OUTREC if you need to "fake-up" a key.

If your data is not in sequence, you can use JOINKEYS to insert the header.

So, what is your data like?
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri May 31, 2013 10:52 pm
Reply with quote

Jim Alton wrote:
This would take two steps - one with a COPY and OUTFIL, and another with a MERGE: can it be done better, especially in just one step?


As Bill pointed out there is a trick to get the count of records as the first record using a single step of JOINKEYS with just a COPY operation. You don't have to perform SORT.
Back to top
View user's profile Send private message
Jim Alton

New User


Joined: 31 Dec 2012
Posts: 31
Location: England

PostPosted: Mon Jun 03, 2013 12:38 am
Reply with quote

Dear Bill,

Thanks for your reply and the suggestion that JOINKEYS will satisfy my need (I'm not familiar with JOINKEYS so will have to learn about its functionality that will achieve this) but I don't understand your first suggestion:
Quote:
If you just want original file, with a header at the front, one possibility which avoids another pass of the data is just to use "concatenation" to deal with the "file" (treat it as a "virtual file" consisting of two physical datasets). If your data is "huge", this may be effective. For smaller amounts of data, you might not want (or be able to have due to standards, audit requirements, whatever) this approach due to the extra "complexity".

What are you concatenating and treating as a virtual file? And what is a virtual file - how is it created and manipulated?
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: Mon Jun 03, 2013 2:59 am
Reply with quote

Code:
//MYFILE DD DSN=MYFILE.WITH.THE.HEADER,DISP=OLD

//MYFILE DD DSN=MYFILE.THE.HEADER,DISP=OLD
//       DD DSN=MYFILE.THE.DATA,DISP=OLD


In the first example, the header was written, then all the data copied to it.

With the second, the header was written, but then a simple concatenation in the JCL gets you the entire input, although it consists of two DSNs.

It is my invention to call it a "virtual" file, not a specific terminological meaning.

If you have 732,000,000 records, this can save a bit of processing, at the expense of making the JCL (not very much) more complicated. Some site standards and audit requirements may not allow this.

For "small" (a relative term) volumes of data someone may argue that the additional "complexity" outweighs the saving.

My experience with Auditors is that they like all the data that is part of the same file to be in the same file.

It is an option, and something to be seriously considered for large volumes. Avoids extra DASD usage and lengthening of the Critical Path as well as the 250-365 times a year processing cost just to get that header at the front.
Back to top
View user's profile Send private message
Jim Alton

New User


Joined: 31 Dec 2012
Posts: 31
Location: England

PostPosted: Mon Jun 03, 2013 6:57 pm
Reply with quote

Dear Bill,

I see what you're getting at - either you do further processing on the merged (not necessarily DFSORT MERGEd) file or you don't merge and try to continue processing with the files as a concatenation.
Regarding the worth or need of performing this process, in my installation, special (small) programs have been created to provide in a header record the counts that are found in the Trailer1 record.
Talk of virtual files threw me a bit. If you had instead de-virt-ed from the virtual you would have come up with dual.
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 Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts OUTFIL with SAVE option DFSORT/ICETOOL 7
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts convert file from VB to FB and use tr... DFSORT/ICETOOL 8
No new posts How to append data from PARM in OUTFIL DFSORT/ICETOOL 17
Search our Forums:

Back to Top