You didn’t show us how this module is executed or what the work file contains, so it’s difficult to discuss your specific situation, but many developers have had difficulty creating empty files in Natural, and this program may be a result of that difficulty. (How’s that for a run-on sentence? ) My guess is that your program doesn’t write any records at all, but is used to force the creation of an empty file.
Here’s the typical situation:
. A large program writes a WORK file.
. Due to size constraints, the program is broken into subprograms, one of which writes the WORK file. This subprogram is invoked conditionally.
. During some runs, the “condition” does not exist, and the subprogram is not called. No records are written to the WORK file.
. Because Natural does not “see” the WORK file (ie does not encounter a WRITE WORK statement), it neither opens nor closes it. There is no reason to inform the operating system of such things as the file’s logical record length (LRECL).
. The operating system attempts to close the file, but finds no LRECL in the JCL. Because Natural did not pass the LRECL, the file is not closed properly.
. When attempting to open the file in a subsequent JCL step, an I/O error is thrown.
The solution is to allow Natural to provide the LRECL to the operating system.
Option 1: code the LRECL in the JCL (my recommendation)
Option 2: ensure that Natural “sees” the file. In the mainline, code something like
WRITE WORK 1 #A (1:450) /* must match LRECL in subpgm XXXXXXXX
For more information, go to the SAG-L archives, or come see my presentation, Natural Batch Topics, at the Natural Conference in Philadelphia in October.