Midrange News for the IBM i Community

Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Fun with CL Commands - WRKJOBSPLF
has no ratings.
Published: 19 May 2012
Revised: 23 Jan 2013 - 2493 days ago
Last viewed on: 20 Nov 2019 (5814 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Fun with CL Commands - WRKJOBSPLF Published by: Bob Cozzi on 19 May 2012 view comments(8)

Check out the latest COZTOOLS. A free runtime version of the Full COZTOOLS Software Product.

I just realized that my end-users are typically wanting to see their current job's SPOOL output, not everything they've ever printed. They really don't enjoy doing (for example) WRKSPLF and then press F18 and F11 to figure out which SPOOL files are from "today"

Of course there are these native IBM i CL commands:


The issue with WRKSPLF is as I just mentioned--too much data.

The issue with WRKOUTQ is that they could have multiple SPOOL files in different output queues, and again from different jobs.

The issue with WRKJOB is they can start playing with options other than option 4.

So i thought, why not go back to our roots, i.e., the S/38 CPF days when we'd write a helper CL command to do just about everything. What they really want is to use the WRKJOB command as follows:


Now its problematic to get end-users to type in a goofy parameter name (such as "OPTION") and get the syntax right every time.

So I thought, how about "WRKJOBSPLF" as a command name? But I really don't want to have a command definition and a CL program just to create a helper command. So I went back to the old issues of Q38 Technical Journal and saw the "CONSTANT" parameter I wrote about nearly 27 years go and got what I wanted quickly.

Here's the Command Definition Source for WRKJOBSPLF.

            PARM       KWD(CMD) TYPE(*CMDSTR) LEN(32) +      
                         CONSTANT('WRKJOB OPTION(*SPLF)')    
            PARM       KWD(CMDLENGTH) TYPE(*DEC) LEN(15 5) + 

To create the command, use the CRTCMD command (yes, this is the "Create Command" command) and specify QCMDEXC as the Command Processing Program for the PGM parameter as follows:


When you type in WRKJOBSPLF you'll be sent directly to option 4 of the WRKJOB menu. This means they will bypass the menu itself just as if your user had typed in the full WRKJOB OPTION(*SPLF) command.

How it works

The command processing program is called whenever a user-written command is entered into the command line, or run from within a CL program. The Command itself is just a template for building the parameter list that is sent to the program.

By specifying QCMDEXC as the program to call, we know that QCMDEXC accepts a command string and command string length as its first two parameters. I simply force those values by specifying (in this case) 'WRKJOB OPTION(*SPLF)' as the CMD parameter and then hard-coded the length as the 2nd parameter, while defining it as Packed(15,5) which is required by QCMDEXC.

You can mimic this command and write your own short-cut command for anything you want. There is a limit on the CONSTANT parameter length, but I don't recall what it is right now--again this is for short-cuts now "macros". Smile

Have a nice day!

Return to midrangenews.com home page.
Sort Ascend | Descend