COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
Running the New Process in the Background
By default, your TACL process suspends itself while your HP COBOL program executes. You can
prevent this by running your program in the background with the NOWAIT option of the RUN
command.
Beware of using the NOWAIT option if your program has ACCEPT and DISPLAY statements that
use the home terminal. With NOWAIT, your HP COBOL program cannot accept input from, or
display output to, the home terminal until you pause the terminal. Without NOWAIT, you can
access your TACL process by pressing Break when you are certain that the COBOL-created process
is done with the home terminal.
This command runs the program PROG1 in the background:
PROG1 /NOWAIT/
Run-Time Errors
Run-time errors are errors that arise during the execution of a process. Examples of their causes
are:
• The process tries to open a nonexistent file.
• The process tries to open a file that is inaccessible because another process has it open
exclusively.
• The process tries to call a non-COBOL program that is not in the process’s own loadfile, the
system library, or the TNS or user library.
Diagnostic Messages
When a run-time error occurs, the run-time routine that detects it sends a run-time diagnostic message
to the default output device. The default output device is the home terminal unless you changed it
with the PARAM EXECUTION-LOG command (see Specifying a Default Input-Output Device) or
the OUT option of the RUN command (see Specifying Default Input and Output Devices).
A run-time diagnostic message identifies the error, the process in which the error occurred, and
the loadfile from which the process was loaded. The error number and format of a run-time
diagnostic message depend on the run-time environment. For details, see Section 48, Run-Time
Diagnostic Messages.
One category of run-time diagnostic messages is not reported to the default output device:
input-output exceptions with I-O status codes less than “30” that your program handles with its
own error-handling procedures.
Error-Handling Procedures
In your HP COBOL program, you can define error-handling procedures with USE AFTER EXCEPTION
statements. When a file system error occurs, control passes to a USE AFTER EXCEPTION statement,
which can access two values to determine what action to take. The first value is the I-O status code,
which identifies the error; the second value is that of the special register GUARDIAN-ERR, which
identifies the cause of the error.
One I-O error can have several possible causes; therefore, one I-O code status value can be
associated with several GUARDIAN-ERR values. For example, a WRITE statement error (I-O code
status value “24”) can be caused by a relative key that is out of bounds (GUARDIAN-ERR value
23), a full file (GUARDIAN-ERR value 45), or an invalid key (GUARDIAN-ERR value 46). The USE
AFTER EXCEPTION statement can interpret the value of GUARDIAN-ERR and act accordingly.
After a USE AFTER EXCEPTION statement executes, it returns control to the routine that called it,
except when the I-O status code is “4x ” or “90,” in which case the process terminates abnormally.
For more information about the USE AFTER EXCEPTION statement and diagnosing input-output
errors, see USE AFTER EXCEPTION (page 484).
828 Executing and Debugging HP COBOL Programs










