Debugging is an important concept to be learned in any programming language as it makes the life of developer easier. When an error is encountered in an exec, there are several ways to locate the error such as:
Using TRACE instructions.
By accessing the Special variables which contains vital information such as status of execution, line of execution and so on.
When an exec results in an exception, the exec ends with an error message which may not be sufficient enough to determine the root cause of the error. It may be needed to know the way the command is executed.
TRACE instructions are normally used to know details of the way the REXX commands are executed. There are various levels at which TRACE commands can be used to display the information on command execution.
When 'TRACE C' command is specified in an exec, any command that follows is traced before it is executed, then it is executed, and the return code from the command is displayed.
For example, let us consider an example where LISTDS command is used with incorrect dataset name as follows:
When TRACE is not used, this example results in the following error message.
MISSING DATA SET NAME INVALID KEYWORD, ?
However, when 'TRACE C' is included, the error message will be displayed with the details of return code, line number and actual error message as follows:
3 *-* "LISTDS ?" >>> "LISTDS ?" MISSING DATA SET NAME INVALID KEYWORD, ? +++ RC(12) +++ ***
When "TRACE E" is used in any exec, any host command that results in a nonzero return code is traced after it executes and the return code from the command is displayed as follows:
MISSING DATA SET NAME INVALID KEYWORD, ? 3 *-* "LISTDS ?" +++ RC(12) +++ ***
When "TRACE I" is used in any exec, all the intermediate operations are traced and the return code from all the commands are displayed.
|TRACE C||Any command that follows is traced before it is executed. After execution, the return code from the command is displayed.|
|TRACE E||Any host command that results in a non-zero return code is traced after it executes. The return code from the code is displayed.|
|TRACE I||Traces all intermediate operations performed when a command is executed.|
|TRACE R||Traces the results of each and every command that is executed.|
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!