I agree with Wolfgang. From what you have told us, this program probably should be written as a traditional COBOL tape processing program would have been written, copying an input file to an output file while doing some processing of the records. (The file's design seems like it could be a holdover from long ago and may even have originated in a tape-oriented environment.) The program probably should have two input files (old file and the file containing the records to be added) and an output file. It probably should have a processing loop that reads an input record, writes it to the output if it is a D record, possibly accumulates totals or other data from the D records, and skips the record if it is a T record (possibly after verifying the totals in the record are correct). At EOF on the input file, it should read the new D records from the second input file and write them to the output file (probably also doing the totals accumulation and such), and at EOF on the sec
ond input file, write the new T record to the output file, close files, and stop.
Setting the buffered option on the output file (via FUP or equivalent) can easily speed up writing a file without making any changes to the program, but my experience is that it does not do much to speed up reading a file. The discprocess usually prefetches and keeps blocks in cache to satisfy reads, but unless the buffered attribute is set on the file, the discprocess must write the changed block to disc for every record written. Adding the buffered option eliminates the write to disc for every record written, which will speed up processing at the cost that if a processor failure occurs, not all of the data is guaranteed to be on disk, so recovery requires rerunning from the beginning, not trying to restart in the middle. That seems not to be a barrier in this case.
Simply using buffered mode still requires a message per record between the application and the discprocess, both for reading and writing.
The RESERVE 2 AREAS, when it can be used, greatly reduces the number of messages needed for reading by moving the records between the application and discprocess in large blocks. As far as I know, RESERVE 2 AREAS does not do any better for writing than creating the file with buffered mode does (but I believe it will turn on buffered mode for you, so you do not have to remember to do that when you create the file). It still requires one message per record to the discprocess when writing.
RESERVE 3 AREAS provides even better writing performance because it blocks the records in the application process and only sends the large blocks to the discprocess. I thought that RESERVE 3 AREAS performs the same as RESERVE 2 AREAS when reading a file, but the wording in the manual implies that RESERVE 3 AREAS improves read performance over that of RESERVE 2 AREAS, so perhaps it does something more than sequential block buffering when reading. In any case, RESERVE 3 AREAS cannot hurt read performance, and may improve it further.
To summarize, I agree with Wolfgang: Your program probably should be written to read the input file and write a new output file, using RESERVE 3 AREAS for both of those files. Since it seems that the third file containing the new D records to be added is small, it probably does not matter whether you use RESERVE 3 AREAS for it, but it certainly would not hurt to do so, except perhaps make the program use a little more main memory.
The main drawback to this approach would be that twice as much disk storage is required, since it produces a new copy of the data file.
My earlier suggestion to make the input file be a relative file could enable you to avoid making a copy of the data file by just deleting the old T record and appending the few new D records and a new T record to the existing file. It also could run much quicker if it were acceptable not to read all of the old D records, but rely on the data in the old T record to be correct and calculate the new T record by adding just the information from the new D records to the values from the old T record. This assumes that the file's home is on the NonStop system. However, you now tell us that the file is received from another system. Unless you can arrange to load that file onto the NonStop system as a relative file rather than as an entry-sequenced file, the extra pass over the data required to copy from an entry-sequenced file to a relative file negates a lot of the advantages of using the relative file organization. There certainly are ways to load an externally-sourced file a
s a relative file, so don't rule out using a relative file without thinking about it, but if you cannot arrange to load directly to a relative file in your case, the traditional input, process, output approach using entry-sequenced files probably would be best.
Depending on how you are introducing the externally-sourced file into the NonStop system, there might be an opportunity to improve the speed of that operation, too. If you want to investigate that, tell us some details about the steps taken to get the file onto the NonStop system, and we might be able to suggest improvements to that.