Peter,

I suspect you've gone home for the day and I'll be in a few hours after you
in the morning
(I'm on the West Coast).

So I'll show you some examples of how to do what you want to do with
DFSORT/ICETOOL.
I'm assuming that your input file has RECFM=FB and LRECL=80.  If it has
RECFM=VB and/or
a different LRECL, I can show you how to adjust the jobs if you need me to.

Case 1 - Trailer record has an identifier ('T' in position 1)

The input file looks like this:

H HEADER
D RECORD 01
D RECORD 05
D RECORD 02
D RECORD 04
D RECORD 03
T 00000000009 AAAAAAAAAAAAAAAAAAAA

Here's a DFSORT/ICETOOL job to update the trailer count in positions 3-13:.

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...  input file (FB/80)
//OUT DD DSN=...  output file (FB/80)
//TOOLIN DD *...
* Sort data records
DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)
/*
//CTL1CNTL DD *
* Sort statement for data records
  SORT FIELDS=(1,20,CH,A)
  OUTFIL FNAMES=OUT,
    IFOUTLEN=80,
* Put sequence number at end of all records
    IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,11,ZD)),
* Overlay count of data records in trailer
    IFTHEN=(WHEN=(1,1,CH,EQ,C'T'),
       OVERLAY=(3:81,11,ZD,SUB,+2,TO=ZD,LENGTH=11)))
/*

The output file would be:

H HEADER
D RECORD 01
D RECORD 02
D RECORD 03
D RECORD 04
D RECORD 05
T 00000000005 AAAAAAAAAAAAAAAAAAAA

Case 2 - Trailer record does not have an identifier (it's just the last
record):

The input file looks like this:

2008/03/02
RECORD 01
RECORD 05
RECORD 02
RECORD 04
RECORD 03
00000000009 AAAAAAAAAAAAAAAAAAAA

Here's a DFSORT/ICETOOL job to update the trailer count in positions 1-11:

//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN DD DSN=...  input file (FB/80)
//SYM DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS))
//SYSIN DD *
  OPTION COPY
* Copy input file with sequence numbers at end
  OUTFIL FNAMES=T1,OVERLAY=(81:SEQNUM,11,ZD)
* Create DFSORT symbols as follows:
* NEWCT,'nnnnnnnnnnn'  <- count of data records
* TRLID,+nnnnnnnnnnn   <- count of all records
  OUTFIL FNAMES=SYM,REMOVECC,NODETAIL,
    TRAILER1=('NEWCT,''',COUNT-2=(M11,LENGTH=11),C'''',80:X,/,
      'TRLID,+',COUNT=(M11,LENGTH=11))
/*
//S2 EXEC PGM=ICETOOL
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=&&T1,DISP=(OLD,PASS),
//OUT DD DSN=...  output file (FB/80))
//TOOLIN DD *...
* Sort data records
DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)
/*
//CTL1CNTL DD *
* Sort statement for data records
  SORT FIELDS=(1,20,CH,A)
  OUTFIL FNAMES=OUT,
    IFOUTLEN=80,
* Overlay count of data records in trailer
* Use TRILD to identify trailer record.
* Use NEWCT to overlay count.
    IFTHEN=(WHEN=(81,11,ZD,EQ,TRLID),
       OVERLAY=(1:NEWCT))
/*

The output file would be:

2008/03/02
RECORD 01
RECORD 02
RECORD 03
RECORD 04
RECORD 05
00000000005 AAAAAAAAAAAAAAAAAAAA

If you need help adapting one of these jobs to your requirements, let me
know
the relevant details.

Frank Yaeger - DFSORT Development Team (IBM) - [email protected]
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration

 => DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort/

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to