WRKACTJOB: The AS/400's Information Center

IT Infrastructure - Other
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

To me, the single most important command on the AS/400 is the Work with Active Jobs (WRKACT-JOB) command. Why? By using this command, you can observe just about anything that you need to know about what goes on inside your AS/400. One of the first things I do every morning (after I get my cup of coffee) is to take a look at what is running (or not running) on my AS/400. Did anything get hung up the night before? Are all the servers, such as email and HTTP, active? Do any jobs have messages that need a reply? All of these questions can be answered by using the WRKACTJOB command.

Eight Parameters to Choose From

Before I jump into the WRKACT-JOB display, let me tell you about the parameters for the command. To see the parameters, enter WRKACTJOB on the command line and press the F4 key. Then, press F10 to display all the parameters. There are eight parameters available that control how data is displayed.

The first option available, PRINT, determines whether output should be directed to the screen (*) or to a print file (*PRINT).

RESET determines whether or not the job statistics are reset. If you are watching performance information, it is a good idea to reset the statistics from time to time because the numbers are calculated over long time spans.

Next is the Subsystem (SBS) parameter. I like to use this parameter when I am interested only in jobs on one subsystem. For example, WRKACTJOB SBS(QSYSWRK) displays only the active jobs in the QSYSWRK subsystem. This parameter saves me the hassle of paging through hundreds of jobs that I am not interested in.

The CPU percent limit (CPU-PCTLMT) parameter filters out all active jobs with a CPU percentage less than the value specified. This parameter is useful if you are trying to find a job that is hogging CPU resources.

Response time limit (RSPLMT) is used to eliminate jobs below a certain response level. The response level is simply the average amount of time it takes to complete an interactive request. This parameter is good for finding jobs experiencing long wait times.

The Sequence (SEQ) parameter determines the order in which jobs are listed. The default is to list jobs by subsystem.

JOB is used to select active jobs by job name. Wild cards such as QPADEV* can be used on this parameter.

Finally, there is Automatic refresh interval (INTERVAL). This parameter is used in conjunction with a command key on the WRKACTJOB display and is discussed later.

Let’s See the Jobs, Already!

Now that you know how to choose what you want to see, it’s time to look at the display. As you can see in Figure 1, the WRKACTJOB display is divided into four sections. The first section, at the top of the screen, displays information about the state of the system as a whole. This information gives you a snapshot of what goes on under the hood by providing statistics such as CPU usage and the number of jobs running.

So Many Options, So Little Time

The second section displays the options available for working with jobs. (Press F23 to toggle between the options.) There are 13 options that cover almost everything you need for managing work on your AS/400.

The most widely used option is probably number 5. This option executes the Work with Job (WRKJOB) command and provides a substantial amount of information about what goes on behind the scenes. Once option 5 is selected, a screen appears that offers even more options. There are too many of these additional options to highlight them all, so I am going to talk about the ones that I think are most important:

• Option 1: Display job status attributes. This option displays a screen that shows when a particular job entered the system and how long it has been running. I use this screen to help in determining whether or not a job has been running an abnormally long period of time.

• Option 2: Display job definition attributes. The job definition describes how a particular job was submitted. Is it batch or interactive? What job queue did it come from? What priority level is the job running at? All of these questions can be answered by looking at option 2.

• Option 4: Work with spooled files. I use this option to spy on certain jobs that produce multiple spooled files. If I’m familiar enough with the job running, I can usually tell how far along the job is by looking at what spooled file is being created.

• Option 10: Display job log. Job logs are invaluable on the AS/400. Many times, if a job has a problem, the only way to uncover what went wrong is via the job log. Reading job logs takes practice, but it is well worth the effort because the detail they provide is second to none.

• Option 11: Display call stack. Displaying the call stack is a good way to figure out whether or not you can recover from a program failure. My favorite trick is to call all RPG programs from CL programs because RPG doesn’t allow the retry option but CL does. If the RPG program has an error, I simply cancel it to jump back a level in the call stack. I then fix the RPG code and do a retry from the CL. Although this technique won’t work in every situation, it has saved me on more than one occasion. Another thing the call stack is good for is indicating what program is producing the error when a user can’t explain an error situation.

• Option 13: Display library list. This option shows the library list that the job is currently using. Many times, it’s not clear why a job is not executing properly or why files are not getting updated correctly. Sometimes it’s as simple as not having the library list set up properly. By using this option, you can see exactly what library list the job is using in order to determine if that is the problem.

• Option 14: Display open files. All jobs’ open files are displayed when this option is selected. A neat trick here is using the F11 key to display all the I/O statistics for a file. What good is this? Simple. If a job is stuck in a loop, chances are that when you press F5, the relative record numbers do not change because the job is either reading the same record

over and over or reading nothing at all. If this is the case, you can generally confirm your suspicions by displaying the call stack and refreshing the screen several times. If the job is looping, you will see the same statements being executed over and over again.

Another widely used option on the WRKACTJOB display is option 7 (Display messages). When a job encounters an error, it generally sends a message to the system operator and waits for a reply. Option 7 allows you to display the message and respond to it as desired. I find this more convenient to do from the WRKACTJOB screen because I can get all the information I need on fixing, analyzing, and responding to the problem in the same place.

If the runtime attributes of a job (priority, time slice, etc.) need to be changed, option 2 is used. This option runs the Change Job (CHGJOB) command on the selected job.

Option 8 allows you to work with a job’s spooled file. As mentioned earlier, this is a good way to spy on the progress of a job.

Finally, option 4 allows you to end an active job.

Jobs on Display

In the third section of the WRKACTJOB display, there are three views that you can toggle between by using the F11 key. The default view shows job status data, such as the name, the user who submitted the job, and the job’s CPU percentage. The two most important pieces of data are the status and the CPU percentage. A status of MSGW (message wait) means that the job has a message that needs a response. (If you place your cursor on the status column and press F1, an online help screen will show all the statuses and their meanings.) The CPU percentage shows the amount of CPU resources the job is using. This can be valuable information for discovering “runaway” jobs that do nothing but drain your machine’s resources. When relying on the WRKACTJOB display for CPU percentage, it is important to use F10 throughout the day to restart the statistics. The reason I say this is that the stats are cumulative, and if you check them early in the morning and then late in the day, you will be looking at many hours of data.

The next view available shows the elapsed data. This display is useful for hunting down system killers such as power query users and programmers who, like me, compile programs interactively. Generally, these users show high response times and large amounts of auxiliary I/O operations. This view gives you the power to put them out of business!

The final view shows thread data but is really useful only if you are using multithreaded languages such as C or Java.

Just What Is Your Function, Anyway?

The last section of the screen displays the available function keys. (Use F24 to toggle among them.)

Personally, the one I use most is F5, which refreshes the screen. This key updates the display so you can tell whether or not a batch job has finished, a user has signed off, or a subsystem has ended.

The F7 (find) key adds another powerful function to your arsenal. When F7 is pressed, a window appears that allows you to enter a search string and the type of attribute to be searched. You can search by job name, user name, job number, etc. Once the search is completed, the screen is repositioned to show the job you were searching for. (The F8 key is used to repeat the search.) This is an extremely useful feature on large systems because it saves you the trouble of having to page through thousands of jobs to find what you’re looking for.

The final command key that I want to discuss is the F19 (start automatic refresh) key. Way back at the beginning of this article, I mentioned that one of the parameters for the WRKACTJOB command is an interval. If a time interval is specified and F19 is pressed, the screen automatically refreshes at the time interval selected. Using this feature

eliminates the need to keep pressing the F5 key. (Pressing F19 again will turn off the automatic refresh.)

You’ve Just Scratched the Surface

As you can see, the WRKACTJOB command is packed with features. It also uses a lot of AS/400 resources, so if you have response concerns, use the command sparingly. There are so many features that I can’t fit them in the space provided. If you haven’t done so already, take a few minutes to play with the command’s options. There is a wealth of data that can be uncovered by this command, and that is why it is truly the AS/400’s information center.


OS/400 Work Management V4R4 (SC41-5306-03, CD-ROM QB3ALG03)

Figure 1:The WRKACTJOB display is divided into four sections.

WRKACTJOB-_The_AS-_400s_Information_Center04-00.png 597x335