Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
Fun with CL Commands - WRKJOBSPLF
has no ratings.
Published: 19 May 2012
Revised: 23 Jan 2013 - 1522 days ago
Last viewed on: 25 Mar 2017 (4048 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:

  • WRKSPLF
  • WRKOUTQ
  • WRKJOB

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:

WRKJOB OPTION(*SPLF)

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.

WRKJOBSPLF: CMD        PROMPT('COZZI - Work Job SPOOL Files')
            PARM       KWD(CMD) TYPE(*CMDSTR) LEN(32) +      
                         CONSTANT('WRKJOB OPTION(*SPLF)')    
            PARM       KWD(CMDLENGTH) TYPE(*DEC) LEN(15 5) + 
                         CONSTANT(32)

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:

CRTCMD CMD(WRKJOBSPLF) PGM(QCMDEXC) ALWLMTUSR(*YES)

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

COMMENTS

(Sign in to Post a Comment)
Posted by: bdietz400
Premium member *
columbus, oh
Comment on: Fun with CL Commands - WRKJOBSPLF
Posted: 4 years 10 months 4 days 14 hours 32 minutes ago

from the help screen on the CONSTANT parm:

<help>

If a character constant is specified in this parameter, it can be no 
longer than 32 bytes.

</help>

Posted by: Paulster
Premium member *
Sweden and The Netherlands
Comment on: Fun with CL Commands - WRKJOBSPLF
Posted: 4 years 10 months 2 days 20 hours 55 minutes ago

I remember this 'trick' from the News/400 days. Very handy for simple commands. Thanks for putting it back in active memory! 

 

Regards,

Paulster

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Fun with CL Commands - WRKJOBSPLF
Posted: 4 years 10 months 2 days 14 hours 15 minutes ago

That would be "Q38" or "Midrange Magazine" days... "News" was David Duke's publication.

Posted by: sarge
Premium member *
United States
Comment on: Fun with CL Commands - WRKJOBSPLF
Posted: 4 years 10 months 2 days 8 hours 13 minutes ago

in fact, Duke has News 34/38, as the magazine started prior to the release of Project Sunglow, or as we really old timers knew it, the System/36.

Midrange Computing, if my old @$$ brain remembers correctly, was DataNetwork 34/36.

back when Mel Beckman and Gary Kraztner from ASNA were my buddy/foes on the old BBS.

-Sarge

Posted by: DaleB
Premium member *
Reading, PA
Comment on: Fun with CL Commands - WRKJOBSPLF
Posted: 4 years 10 months 2 days 8 hours ago

Reminds me of 1988. We had a developer who kept typing OFF instead of SIGNOFF. Never did get around to it, but often joked about creating an OFF command for him. Though I don't think we knew about the CONSTANT trick at the time.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Fun with CL Commands - WRKJOBSPLF
Posted: 4 years 10 months 2 days 7 hours 12 minutes ago

Ya, I started the Q38Labs BBS back in my basement... must have been in 1984-timeframe. I know Duke started something similar about 2 or 3 years later and constantly got hit with the "Why isn't it as good as Q38?" questions.

Dale, coming from a 370, I kept typing in "BYE" instead of signoff. But then got used to 24 until they switched it to 90.

Posted by: sarge
Premium member *
United States
Comment on: Fun with CL Commands - WRKJOBSPLF
Posted: 4 years 10 months 2 days 7 hours 12 minutes ago

i actually cut my teeth on the /34.  i DID create an 'OFF' command when i got on the /400.

worked out well. it was my first CrtCmd. everybody in the department thought i was a genius. intelligent, depending on who you ask, but was more a of a case of "Lazy-Bone-Syndrome" than anything else.

-sarge

Posted by: neilrh
Premium member *
Jackson, MI
Comment on: Fun with CL Commands - WRKJOBSPLF
Posted: 4 years 10 months 1 days 7 hours 1 minutes ago

Our first local OFF did have a CPP behind it, but performed a successive ENDPASTH/MONMSG/SIGNOFF