A Helpful Tool for Dealing with Unexpected Problems
January 6, 2010 Ted Holt
In the Pink Panther movies, Chief Inspector Dreyfus dreaded to hear the name Clouseau. Just the mention of that name was enough to cause Dreyfus to lose control of himself, and even landed him several stays in psychiatric hospitals. In the same way, there are certain words I hate to hear when I’m at work.
In my day job, the words I hate to hear are “There’s a message on QSYSOPR.” A message on the QSYSOPR message queue is rarely good news. It means I’ve got to stop what I’m doing and deal with a problem. (I am proud to say, however, that I do bear bad news much better than Monsieur Dreyfus did.)
When dealing with an unexpected problem, several questions must be addressed:
One good but underused investigation tool is CL’s Start Service Job (STRSRVJOB) command. STRSRVJOB allows you to see a program’s data values, and under certain conditions, the program’s source code, before you cancel the program. Here’s an example.
Suppose the following message shows up on the system operator message queue:
Decimal-data error occurred (C G D F).
The first thing to do is to determine the identifiers of the job that is in error. There are several ways to do this, but one easy one is to place the cursor on the error message, press F1 (for help text), then F9 (to display the message details). The “From job” field tells the job name, user name, and job number.
From a CL command line, run STRSRVJOB.
Use Work with Job (WRKJOB), option 11, to find the name of the program that has halted.
Next, start the debugger, referencing the program name.
STRDBG PGM(SOMELIB/SOMEPGM) UPDPROD(*YES) OPMSRC(*YES)
Depending on how the program was compiled, you may or may not see the source code. The big advantage to seeing the code is that you immediately determine the location of the error.
Whether the source code is visible or not, you can use the debugger’s EVAL command to view the values of fields and variables. If the source code is visible, you can also use the F11 key to display data values.
When you have finished your investigation, run the End Debug Mode (ENDDBG) and End Service Job (ENDSRVJOB) commands to tidy up.