I'm trying to code a DFSORT procedure that would merge 2 files into one with the following model :
The first input file contains every headers and trailers while the second input file only contains the details records.
The records look like that :
Header : 01XXXXXXCCCCCXXXXXXXXX..
Detail : 02XXXXXXCCCCCXXXXXXXXXXXXXX....
Header : 09XXXXXXCCCCC0000000
The X's are random irrelevant characters
The C's represent the key on which both files are sorted
The counter of the trailer is initialy at 0000000
What I've been able to do so far is just a simple sort merging both files using :
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=dsn of input1
// DD DISP=SHR,DSN=dsn of input2
//SORTOUT DD DISP=SHR,DSN=dsn of output
//SYSIN DD *
but I then have to manually count the detail records to change the trailer for each header/details/trailer bloc.
So I need your help to add a counter to each trailer, that would reset back to 0 everytime the sorting key changes
The output file should look like this
I tried a few things using Frank Yaeger's documentation but nothing succesful so far.
I'm sorry for any english mistake and/or if my post isn't clear enough, but english is not my first langage
Thanks in advance for any help.