header and trailer needed in split files
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> Utilities

#1: header and trailer needed in split files Author: da_one PostPosted: Wed Oct 15, 2003 6:24 pm
    —
DFSORT requirement:
I have a requirement which says there 3 input files, each containing header and trailer, and 100,200, 300 records respectively.

I need to repartiton these 3 files into 2 files such that each
will contain header and footer information. They should contain say 150
records each depending on some sort criteria. The header in both the
output files should be same as the header info in any 1 of the input
file (it contains date etc). And the trailer in both the files, should
contain number of records in that file.

I should also need 1 temp file which just contains 6
records. this should be:
header from Input file 1
header from Input file 2
header from Input file 3
trailer from Input file 1
trailer from Input file 2
trailer from Input file 3

I heard that the TRAILER option of the dfsort works only if the record length is 132 or less.

#2:  Author: Frank YaegerLocation: San Jose PostPosted: Wed Oct 15, 2003 7:03 pm
    —
Some questions:

What identifies a header record? Does it have something in it that identifies it (e.g. a '0' in position 1). If so, what? Or is the header record only identified by being the first record in the file?

What identifies a trailer record? Does it have something in it that identifies it (e.g. a '9' in position 1). If so, what? Or is the trailer record only identified by being the last record in the file?

What is the starting position and length of the record count you want in the trailer records? What do you want these counts to look like?

What is the RECFM and LRECL of the input files?

Quote:
I heard that the TRAILER option of the dfsort works only if the record length is 132 or less.


You heard wrong. The TRAILER option of DFSORT works with any record length.

Quote:
They should contain say 150 records each depending on some sort criteria.


What do you mean by this? How exactly do you want to select the records for the two output files? Do you mean INCLUDE criteria rather than sort criteria? If not, what exactly do you mean?

#3:  Author: da_one PostPosted: Fri Oct 17, 2003 4:57 pm
    —
The header would be identified by a word callled as 'hdrdate'
The tailer would be identified by word 'CNTR'

Yes, you are right, I actually meant Include criteria, and not the sort criteria. The include condition could be anythign that could make the too files equal. That would be decided during execution. So you can ignore the actual Include condition for the time being

As of now, we have a 9 digit trailer counter field. The trailer should look like
TRAILER=(2:"Trailer Counter",COUNT).

The length of the input record is around 1400 bytes

thanks

#4:  Author: Frank YaegerLocation: San Jose PostPosted: Fri Oct 17, 2003 5:47 pm
    —
Here's a DFSORT/ICETOOL job that will do what I think you're asking for:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//CON DD DSN=...  input file1
//    DD DSN=...  input file2
//    DD DSN=...  input file3
//OUT1 DD DSN=&&O1,UNIT=SYSDA,SPACE=(CYL,(5,5)),
//***> Use MOD for OUT1
// DISP=(MOD,PASS)
//OUT2 DD DSN=&&O2,UNIT=SYSDA,SPACE=(CYL,(5,5)),
//***> Use MOD for OUT2
// DISP=(MOD,PASS)
//OUT3 DD DSN=&&O3,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//TOOLIN DD *
* Write one header record to OUT1 and OUT2
  COPY FROM(CON) TO(OUT1,OUT2) USING(CTL1)
* MOD the detail records and trailer records
* to OUT1 and OUT2
  COPY FROM(CON) USING(CTL2)
/*
//CTL1CNTL DD *
* Write the first header record to OUT1 and OUT2.
* Stop after reading/writing the header record.
  INCLUDE COND=(1,7,CH,EQ,C'hdrdate')
  OPTION STOPAFT=1
/*
//CTL2CNTL DD *
  OUTFIL FNAMES=OUT1,REMOVECC,
* OUT1:  output file1.
* Omit the header and trailer records.  Keep the needed records.
* Write the trailer as the last record.
    INCLUDE=(1,7,CH,NE,C'hdrdate',AND,1,4,CH,NE,C'CNTR',AND,
      additional conditions),
    TRAILER1=(2:'Trailer Counter',COUNT)
  OUTFIL FNAMES=OUT2,REMOVECC,
* OUT2:  output file2.
* Omit the header and trailer records.  Keep the needed records.
* Write the trailer as the last record.
    INCLUDE=(1,7,CH,NE,C'hdrdate',AND,1,4,CH,NE,C'CNTR',AND,
      additional conditions),
    TRAILER1=(2:'Trailer Counter',COUNT)
* OUT3:  output file3.
* Create file with all header and trailer records.         
  OUTFIL FNAMES=OUT3,REMOVECC,                             
    INCLUDE=(1,7,CH,EQ,C'hdrdate',OR,1,4,CH,EQ,C'CNTR')   
/*


Last edited by Frank Yaeger on Mon Oct 20, 2003 10:42 am; edited 1 time in total

#5:  Author: da_one PostPosted: Mon Oct 20, 2003 9:47 am
    —
Hi Frank,
thanks for this. This definately takes care of the primary requirement. But there is also a secondary requirement, which is to creates 1 file which just contains the header and trailer records of all input files. I should be able to this in the same step, i.e without increasing the number of passes on the data.

This file should look like
header from Input file 1
header from Input file 2
header from Input file 3
trailer from Input file 1
trailer from Input file 2
trailer from Input file 3

Thanks all the same

#6:  Author: Frank YaegerLocation: San Jose PostPosted: Mon Oct 20, 2003 10:43 am
    —
Oops, I forgot about that part. I've updated the DFSORT/ICETOOL job above to create OUT3 with all of the headers and trailers.

#7:  Author: kolusuLocation: San Jose PostPosted: Mon Oct 20, 2003 1:26 pm
    —
Frank,

Da_one wanted all the header records as a group and the all the footer records as one group.But with a copy operation you will get a header followed by a footer record.Or am I intrepreting the question differently?

Kolusu

#8:  Author: Frank YaegerLocation: San Jose PostPosted: Mon Oct 20, 2003 2:02 pm
    —
Kolusu,

I assumed Da_one just wanted all of the header and trailer records in one file and didn't care about their order. I guess he/she will have to let us know if the order is important. If so, that would require some modifications to the job.

#9:  Author: da_one PostPosted: Mon Oct 20, 2003 6:11 pm
    —
Hi Frank, it would have been great if I could do that, but this is great by itelf. I will just need to change the program that was going to read this header trailer file. But thats ok. thanks a lot

#10:  Author: Frank YaegerLocation: San Jose PostPosted: Tue Oct 21, 2003 10:13 am
    —
Well, we could do it, but we'd have to do a sort on the header/trailer record file to get the header/trailer records into the sequence you want



MVSFORUMS.com -> Utilities


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group