Peter Farley wrote on 03/03/2010 07:16:55 AM:
> 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.

Peter,

That's no problem.  Here's a DFSORT job that will do what you asked for:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (VB/8004)
//SORTOUT DD DSN=...  output file (VB/8004)
//SYSIN    DD    *..
  OPTION COPY
* Add SEQNUM between RDW and data.
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,5:SEQNUM,11,ZD,16:5)),
* Use SEQNUM-2 to put count of data records in
* last record (identified by X'FF').
      IFTHEN=(WHEN=(16,1,BI,EQ,X'FF'),
         OVERLAY=(36:5,11,ZD,SUB,+2,TO=ZD,LENGTH=11))
* Remove SEQNUM.
  OUTREC BUILD=(1,4,5:16),
/*

Frank Yaeger - DFSORT Development Team (IBM) - yae...@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration

 => DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort/

----------------------------------------------------------------------
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

Reply via email to