I have a natural program which reads the DB file and after some processing write the details in ouput work file and updates DB file. However after processing some records the job fails, so when i restart i want the program to write the records to the work file in such a way that it should overwrite the selected already written records (during first run which failed) from the desired record position. You can consider the below scenario
The failure occurs after the data is written to flat file and before the update has happened…so the question is how to overwrite the data written in the file when we restart the job.
Suppose after writing 20 records in the output file the job failed but when i restart program should write the data starting from 18th record.
Using DISP=MOD will apend the records at the end of the file but not from the desired position.
Joined: 21 Nov 2009 Posts: 58 Location: California
The solution is to make the WORK records uniquely identifiable, adding a sequence number if necessary. Each time you restart, "duplicate" records will be written - in your example, records 18, 19, and 20. In the next job step, sort the records by the unique key, and use parameters
to remove the duplicates.
If you needed to add a sequence number to the end of the record (let's say after byte 80), it can be removed with
This is standard Natural restart logic, but it should not be used when human lives are at stake (in hospital applications or in nuclear power plants), because it is possible to lose WORK records during unlikely events, such as a power failure. To guarantee success, STORE the records in Adabas as part of the transaction, then extract them to a WORK file in a separate job step.