When debugging, it is useful to periodically check:
To accomplish these tasks, you can use built-in functions, PUT DATA and PUT LIST statements, and display statements. These approaches are described in more detail in the following sections.
display (procname() || sourceline());
Debug: Proc(x);
dcl x fixed bin(31);
on fixedoverflow
begin;
put skip list('Fixedoverflow raised because z = '||z);
end;
end;
get list(z);
x = 8 * z;
If z is too large, multiplying it by 8 produces a value that is too large for any FIXED BIN(31) variable and would therefore raise the FIXEDOVERFLOW condition. PUT SKIP LIST transmits the data (in this case, the string "Fixedoverflow raised because z = ...") to the default file SYSPRINT. You can define SYSPRINT using export DD= statements. For more information on using SYSPRINT, see Using SYSIN and SYSPRINT files.
put data (string1, string2);
Display ('End of job!');
Display ('Reached the MATH procedure');
Display ('Hurrah! Got past the string manipulation stuff...');
Using DISPLAY with PUT statements results in output appearing in
unpredictable order. For more information on using the DISPLAY statement,
see DISPLAY statement input and output.