Thank you Frank! That is eminently easier. And yes, you are correct, the count should be 10, not 9. At the last minute I added a duplicate key record to show that condition in the data and I forgot to update the count field to reflect that addition.
One further question about this technique -- If possible, I would like to have the DATE field in the trailer contain the same business processing date as the only selected header record. Is there any way in SORT to "save" the date value from the header record and propagate that date to the trailer? That header date is NOT necessarily the current system date (e.g., on weekends and holidays), so I cannot just use the "current" date to fill the trailer date field. Thanks as always for your generous and insightful help. Peter -----Original Message----- From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf Of Frank Yaeger Sent: Thursday, March 29, 2012 7:26 PM To: [email protected] Subject: Re: MERGE question: Does SEQNUM restart for each SORTINxx? Peter Farley at IBM Mainframe Discussion List <[email protected]> wrote on 03/29/2012 02:28:49 PM: >... >As can be seen, the trailer count is not correct. >It should be 00000000009. >... I'm confused. Since you have 10 data records (1,2,3,4,5,5,6,7,8.9), wouldn't you want the count to be 10, not 9? Assuming you do, this would be a simpler DFSORT solution: //S1 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN01 DD DSN=... input file 1 (VB) //SORTIN02 DD DSN=... input file 2 (VB) //SORTIN03 DD DSN=... input file 3 (VB) //SORTOUT DD DSN=... output file (VB) //SYSIN DD * OPTION VLSCMP,VLSHRT OMIT COND=(((5,3,CH,EQ,C'000'),AND, OMIT(HEADER RECORD AND (34,5,CH,NE,C'FILE1')),OR, NOT FILE1) OR (5,3,CH,EQ,C'999')) TRAILER RECORD) MERGE FIELDS=(5,3,CH,A),EQUALS OUTFIL REMOVECC, TRAILER1=(C'999FILE TLR CNT=', COUNT-1=(TO=ZD,LENGTH=11), C',DATE=000000') /* For your input example (SORTIN01-03), SORTOUT would have: 000FILE HDR DATE=032912,FILE=FILE1.NAME 001DATA REC 001 002DATA REC 002 003DATA REC 003 004DATA REC 004 005DATA REC 005 005DATA REC 005 SECOND TIME 006DATA REC 006 007DATA REC 007 008DATA REC 008 009DATA REC 009 999FILE TLR CNT=00000000010,DATE=000000 If that's not what you want for output, then please explain the "rules" for getting from input to output more clearly. -- This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system. ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN

