Hi Frank, Thanks for the suggested solutions. In my case, the header and trailer are identifiable (HDR=X'00', TRLR=X'FF', pos 1 for let's say at least 10 bytes).
The file is VB, LRECL=8004, and the data records vary widely in length. Header and trailer are length 700 always, but both header and trailer records contain various data fields (not just date/time/record count) that are not constant and must be preserved. Another wrinkle I realized overnight is that the records cannot actually be sorted, it must be a COPY operation. The sort sequence is complex, depending on business criteria that cannot be duplicated in sort control. Here is a simple example that I believe matches my needs (??? = low values, ### = high values): ??????????DATE=YYYYMMDDHHMMSS PLUS OTHER DATA FIELDS D000000001 DATA RECORD A B C D E D000000005 DATA RECORD C D T R E W T U D000000003 DATA RECORD H J K D000000002 DATA RECORD Y Z S F D000000004 DATA RECORD M X W Q 2 4 6 ##########REC-COUNT=00000000015 PLUS OTHER DATA FIELDS Record count in the trailer in this example = pos 21 for 11 bytes (pos 25 for 11 with RDW added). The record count of 15 in the trailer must now be replaced by 5 because records have been removed by a utility process (no program logic, so no trailer update possible). I need to get the trailer count corrected without changing the order of the data records. Also, the data records may not be touched in any way, or if modified must be returned to their exact before-SORT value. Thanks again for your generous help. 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 lists...@bama.ua.edu with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html