I have a merged file with some headers,lines and trailers.The trailers appear twice now with two different record counts.
By using JCL Sort, Can I replace 2 trailers with a single Trailer?
The record count of the Single Trailer should be the sum of the existing 2 trailers.
e.g Currently in the existing file" we have the following trailers.
T R32055 040605 000008211
----------data------
T R32055 040605 000003712
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
LOPA,
You really haven't given enough information to help us give you a solution.
MGIndaco's method is a shot in the dark. It assumes that the data records can be sorted on positions 1-16 (we don't know this), that there are no duplicates among the data records (we don't know this) and that sorting by 1-16 will put the trailer record in the correct place relative to the data records (we don't know this). Also, the OUTFIL statement isn't needed - OPTION ZDPRINT can be used to get the total as 9 printable digits.
You need to show us a more complete example of your input records (what do the data records actually look like) and what you expect the output records to look like (e.g. where do you want the trailer record - before or after the data records).
What identifies a trailer record vs a data record (does the trailer record have a T in position 1 whereas the data record has something else in position 1?).
Also, what is the RECFM and LRECL of the input file.
If you need an urgent reply, you need to suppy enough information so we don't have to guess what you're trying to do.
Thanks for your feedback.Even I was pondering with the same issues.
For a better clarity I am pasting a portion of data here for ur reference.
1st place is "L" for line data. "H" for header and "T" for batch trailer.
Joined: 10 Mar 2005 Posts: 432 Location: Milan, Italy
I'm in accord with you yaeger... I only replied to LOPA the easy way to resolve the problem that was explained in it's shortly version....
The ZDPRINT is only another way to proceed...
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
LOPA,
With z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004), you can use DFSORT's new IFTHEN and OVERLAY parameters to do what you want with this one pass DFSORT job:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
* Use F sign for summed ZD field.
OPTION ZDPRINT
* Set seqnum (1,2, ...) in 81-88 for all records except
* T records. Set 99999999 as seqnum for T records.
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(1,1,CH,EQ,C'T'),OVERLAY=(81:C'99999999'))
* Sort on seqnum. H and L records will remain in their
* original sequence. T records will be sorted last.
* Note that T records have dup seqnums (99999999), so they
* will be summed. All other records have nondup seqnums
* so they won't be summed.
SORT FIELDS=(81,8,ZD,A)
* Sum on amount in T records.
SUM FIELDS=(14,9,ZD)
* Remove seqnum.
OUTREC FIELDS=(1,80)
/*
If you have DFSORT, but you don't have the Dec, 2004 PTF, ask your System Programmer to install it (it's free). If you can't get it installed, you can use this DFSORT/ICETOOL job instead:
Code:
//S2 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//*** Use MOD for OUT
//OUT DD DISP=MOD,DSN=... output file
// DISP=(MOD,PASS)
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
* IN->OUT: Copy all records except T records.
OUTFIL FNAMES=OUT,OMIT=(1,1,CH,EQ,C'T')
* IN->T1: Copy all T records.
OUTFIL FNAMES=T1,SAVE
/*
//CTL2CNTL DD *
* Use F sign for summed ZD field.
OPTION ZDPRINT
* Sort on 'T'.
SORT FIELDS=(1,1,CH,A)
* Sum on amount in T records.
SUM FIELDS=(14,9,ZD)
/*
I tried your code..It worked fine however the OUT file only contains trailer record.If we want all records with trailer in the last then what will be the solution ?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
brain,
The S1 and S2 jobs I showed do give ALL of the records for LOPA's situation.
If you only got the trailer record, then something is different for your situation (e.g. different input record setup or RECFM or LRECL or ...).
You'd need to show me an example of YOUR input records, the job YOU used, YOUR output records, and the SYSOUT (S1) messages or TOOLMSG and DFSMSG (S2) messages YOU got in order for me to show you how to modify the job for YOUR situation. Feel free to send me the information offline (yaeger@us.ibm.com). Please put "DFSORT" somewhere in your Subject line to catch my attention.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Here's a DFSORT job that will do what you asked for. You'll need z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec,
2004) in order to use DFSORT's new IFTHEN and OVERLAY functions. Only DFSORT has these functions, so if you don't have DFSORT, you won't be able to use them. If you do have DFSORT, but you don't have the Dec, 2004 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the Dec, 2004 PTF, see:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
* Put '1' in 81 for trailer record.
* Put '0' in 81 for all other records.
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'0')),
IFTHEN=(WHEN=(1,2,CH,EQ,C'TR'),OVERLAY=(81:C'1'))
OPTION EQUALS
* Sort on BUC and then on '0' or '1' in 81.
SORT FIELDS=(3,5,CH,A,81,1,CH,A)
* Remove '0' or '1' from 81.
OUTREC FIELDS=(1,80)
/*