Thanks once again Sri, both of those work for me. Peter
From: IBM Mainframe Discussion List <[email protected]> On Behalf Of Sri Hari Kolusu Sent: Saturday, January 31, 2026 3:08 PM To: [email protected] Subject: Re: Sort question on populating a binary record count in the last output record Peter, OVERLAY=(72:1,2,BI,SUB,+1,EDIT=(TT),LENGTH=2)) You used EDIT=(TT) which makes it zoned decimal data If your intention is to subtract 1 for the last record, then it is quite easy. If you start the seqnum from 0 then there is no need for subtracting 1. Use the untested control cards OPTION COPY * ADD SEQNUM IN POSITION 81 with 0 INREC IFOUTLEN=80, IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,2,BI,START=0)), * LAST RECORD (IDENTIFIED BY 10 9'S IN POSITION 1) IFTHEN=(WHEN=(01,10,CH,EQ,C'9999999999'), OVERLAY=(72:81,2)) Alternatively, if you want to use your control cards then you can use this OVERLAY=(72:1,2,BI,SUB,+1,BI,LENGTH=2)) Thanks, Kolusu -----Original Message----- From: IBM Mainframe Discussion List <mailto:[email protected]> On Behalf Of Farley, Peter Sent: Saturday, January 31, 2026 11:42 AM To: mailto:[email protected] Subject: [EXTERNAL] Sort question on populating a binary record count in the last output record Hi All, I have not been able to figure this out by myself. Using the technique Sri Kolusu taught me years ago to place a record count minus a constant in the final record of an OPTION COPY run, I now need to place a BINARY count in the output instead of a zoned decimal count. I have tried the following, but it generates a ZD count instead of a binary count. The input and output files are RECFM=FB,LRECL=80 just for this example. I tried to keep it simple to help me get the idea of how to place a binary count. OPTION COPY * ADD SEQNUM IN POSITION 1 INREC IFTHEN=(WHEN=INIT,BUILD=(1:SEQNUM,2,BI,03:1,80)), * USE SEQNUM-1 TO PUT COUNT OF DATA RECORDS IN * LAST RECORD (IDENTIFIED BY 10 9'S IN POSITION 1) IFTHEN=(WHEN=(03,10,CH,EQ,C'9999999999'), OVERLAY=(72:1,2,BI,SUB,+1,EDIT=(TT),LENGTH=2)) * REMOVE SEQNUM. OUTREC BUILD=(1:03,80) Yes, I know 2-byte binary will only count 32K records (or maybe 64K?) but my input volume for this application will always be much less than that number, certainly under 3000. Any help you can provide would be appreciated. Peter -- 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
