Page 1 of 1

add header trailer to file with counts on trailer

PostPosted: Tue Apr 12, 2011 11:34 pm
by jawaharsmg
Hi,

I need to add header and trailer to the input file content and create an output.

Input file
A
B
C
D
E

Output
<Header>
A
B
C
D
E
<trailer>

Header should be in the format
H<LABEL1><todays date>

Trailer should be in the format
T<LABEL1><Rec count><todays date>

Rec count on trailer should include header and trailer records too. So in this case it will be 7.

Is there any way, I can still get a FB file out of this as output rather than a FBA.

Thanks

Re: add header trailer to file with counts on trailer

PostPosted: Wed Apr 13, 2011 1:03 am
by Frank Yaeger
You can use a DFSORT job like the following. You didn't show what you want the date or count to look like, so all I could do was guess.

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN DD *
  OPTION COPY
  OUTFIL REMOVECC,
    HEADER1=('H<LABEL1>',DATE=(4MD/)),
    TRAILER1=('T<LABEL1>',COUNT+2=(M11,LENGTH=8),X,DATE=(4MD/))
/*


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss? ... g3T7000080

Re: add header trailer to file with counts on trailer

PostPosted: Thu Apr 14, 2011 3:35 am
by jawaharsmg
Thanks Frank.

I forgot to mention that the date is not to be from the system but to read from an other file. Can you help.

Meanwhile, I will go thru the doc link attached.

thanks again

Re: add header trailer to file with counts on trailer

PostPosted: Thu Apr 14, 2011 8:17 pm
by Frank Yaeger
I forgot to mention that the date is not to be from the system but to read from an other file


You need to show an example of the record or records in that other file so I can see where the date is and what it looks like. Also, give the RECFM and LRECL of that other file and the starting position and length of the date.