tuxama
New User
Joined: 25 Jan 2007 Posts: 42 Location: france
|
|
|
|
Hi all,
What is the best way to add a header and a footer records to a file.
infile is like this
record 001
record 002
record 003
record 004
What I whish in the output file
header record
record 001
record 002
record 003
record 004
footer record
Also , I need to add an other record (after the footer) that contain the records number of the file (except the header and footer).
For a moment I wrote this
Code: |
//HEADER DD *
---- HEADER ----------
/*
//FOOTER DD *
---- FOOTER ----------
/*
//INF DD *
RECORD 001
RECORD 002
RECORD 003
RECORD 004
/*
//******
//OUTF DD SYSOUT=*
//TMPA DD DSN=&SYSUID..TMPA,DISP=(,DELETE),
// DATACLAS=DC100F,LRECL=80
//TOOLIN DD *
DEFAULTS LIST(SHOWDEF)
COPY FROM(INF) TO(TMPA) USING(CTL2)
COPY FROM(HEADER) TO(OUTF)
COPY FROM(INF) TO(OUTF)
COPY FROM(FOOTER) TO(OUTF)
COPY FROM(TMPA) TO(OUTF)
/*
//* -----------------------------------------
//CTL2CNTL DD *
OUTFIL FNAMES=TMPA,REMOVECC,NODETAIL,
TRAILER1=(/,' RECORD NUMBER: ',COUNT)
/* |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Wow. That's one of the most convoluted "solutions" to a simple problem I've seen.
Here's a simple DFSORT job that will do what you asked for:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
record 001
record 002
record 003
record 004
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,
HEADER1=('---- HEADER ----------'),
TRAILER1=('---- FOOTER ----------',/,
' RECORD NUMBER: ',COUNT)
/*
|
SORTOUT will have:
Code: |
---- HEADER ----------
record 001
record 002
record 003
record 004
---- FOOTER ----------
RECORD NUMBER: 4
|
|
|