The TRACE-PROCEDURE command can be used to trace the step-by-step execution of a procedure. However, this command can only be used for procedures which are specified in their procedure heads as being interruptible, more specifically in the SET-PROCEDURE-OPTIONS command (by the operand value INTERRUPT-ALLOWED = *YES).
If it is necessary to trace a procedure step-by-step, the user must first specify TRACE-PROCEDURE, before the procedure is called, i.e. before the CALL-PROCEDURE or INCLUDE-PROCEDURE. The procedure is then interrupted at intervals defined by the STEPS operand in TRACE-PROCEDURE. Procedure execution is resumed when the next TRACE-PROCEDURE command is issued.
The STEPS operand should be used to specify how many commands are to be executed before the procedure is next interrupted. The first time that TRACE-PROCEDURE is called, the default setting STEPS = 1 applies, i.e. the procedure will be interrupted after every command. If a different value is specified for STEPS, this new value will apply for the entire execution of the procedure.
When the procedure has been interrupted the programmer can, for example, query the procedure status, or use the MODIFY-PROCEDURE-TEST-OPTIONS command to change the setting for logging or to amend the maximum number of back branches (see below). After this is done, the procedure is again interrupted.
Step-by-step procedure execution can then be resumed with the TRACE-PROCEDURE command or procedure execution can be resumed with the RESUME-PROCEDURE command, causing it to be executed to the end.
If an error occurred in the procedure, the programmer can also use the interruption to modify variable contents, declare variables, etc.
Logging
After the TRACE-PROCEDURE command is entered, the execution of commands that takes place in the procedure is always logged to SYSOUT (provided that logging is allowed for the procedure), regardless of the settings of the LOGGING operand in the CALL-PROCEDURE (or INCLUDE-PROCEDURE) or MODIFY-PROCEDURE-TEST-OPTIONS command; these settings are ignored.