Hi All,
My requirement is to rewrite the count in the last/trailer record.
In my input file, there is a header, trailer and detail records.
first 3 characters specify if it is a header/trailer/detail.
001 - header record
002 - detail records
003 - trailer record
In my trailer record which would be the last record in the file, i have a count (8 digits from 7th position). I'm removing the duplicates in the jcl and sum certain fields. So, i need to rewrite the count now with correct count.
My sort card now looks like this..
INREC OVERLAY=(66:66,11,SFF,TO=ZD,LENGTH=11,
77:77,11,SFF,TO=ZD,LENGTH=11,
106:106,13,SFF,TO=ZD,LENGTH=13)
SORT FIELDS=(1,3,CH,A,7,35,CH,A,42,9,ZD,A,56,4,CH,A,97,9,ZD,A,
119,10,CH,A,139,2,CH,A,4,3,CH,A)
SUM FIELDS=(66,11,77,11,106,13),FORMAT=ZD
OUTREC OVERLAY=(66:66,11,ZD,EDIT=(STTTTTT.TTT),SIGNS=(+,-),
77:77,11,ZD,EDIT=(STTTTTT.TTT),SIGNS=(+,-),
106:106,13,ZD,EDIT=(STTTTTTTTT.TT),SIGNS=(+,-))
Can we have the COUNT function with OVERLAY? Please comment...
Thanks Frank!!
Instead of using COUNT parameter, Can we do it in a single step by giving sequence number to each detail row and use the maximum of sequence number to overwrite in the last record? Is it possible?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Yes, it's possible but it does require adding a sequence number and then removing it. I'll leave it to you to code it up and test it. But here are some thoughts on how I think it could be done: You would have to add the sequence number with the OUTREC statement since you want the count of records after summing. The seqnum for the '003' (last) record will be equal to the count of the summed records. So you can use OUTFIL with IFTHEN for the '003' record to do the OVERLAY of the last seqnum, and finally remove the seqnum (you could do that with IFOUTLEN).
Hi Frank,
I need the count of detail records only. If i had used the seqnum, i would have got the count including header and trailer record. I should have started the SEQNUM with -1 so that i get the correct detail count in the last record. But the seqnum, seems can start only from 0.
I have used COUNT-2=(M11,LENGTH=8) to the existing step and used OVERLAY with IFTHEN as you have mentioned in the second step to rewrite the second step. Thanks.
Can we have the sequence number/count for a given condition?
For example, can we give sequence number/count only for records with first 3 characters as '002'?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
You could use IFTHEN for '002' to get the sequence number for only the '002' records but then you wouldn't have the sequence number in the trailer record ('003') to pick up for the count.
But here's a trick you can use:
SEQNUM,8,ZD,START=99999999
The sequence number will wrap around and you will end up with the sequence number for the count you need in the last record. For example:
Code:
H ... 99999999
D1 ... 00000000
D2 ... 00000001
D3 ... 00000002
T ... 00000003
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
With z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF UK90026 (Oct,2010), you can now use DFSORT's new IFTRAIL function to update the trailer count quite easily.
For complete details on the new functions for DFSORT and DFSORT's ICETOOL available with the Oct, 2010 PTF, see: