a) The layout of the first 8 characters for all types of records is the same:
(01,02,ch) --> Record type: 00 is Header, 01 is detail, 99 is Trailer
(03,01,ch) --> Filler (space)
(04,04,ch) --> Record sequence: 0000 is Header, 9999 is Trailer and 0001 til 9998 is reserved to record detail.
(08,01,ch) --> Filler (space)
b) Header
(09,09,ch) --> Fileid Text (Its is the same for all fileid number)
(18,04,ch) --> Fileid number (This field is different for each Header and is very important to my process)
c) trailer
(09,09,ch) --> Fileid Text (Its is the same for all fileid number, it's not important to my process)
(18,04,ch) --> Total detail records
Well, let's go to the grand finale: In my sortin there are two files into one, because the file has two headers and two trailers. I have to include the fileid field in all records from the header to the trailer, then I have to sort the file using this new field.
This is the result expected