Guru: QCMDEXC Makes A Good CPP
March 22, 2021 Ted Holt
I’m a fairly decent typist, and chances are you are, too. A person doesn’t sit at a keyboard for decades and not improve. At the same time, I don’t get paid to type, and I do everything I can to reduce the number of keystrokes I have to produce while carrying out the duties of the job.
If you find yourself keying the same old long commands over and over — and who doesn’t? — I’ve got a tip for you. I have an easy way to reduce long commands to just a few keystrokes. Maybe it will save you wear and tear on your fingers and reduce your chances of getting carpal tunnel syndrome.
Consider this command, which I use often in my work:
RCLACTGRP ACTGRP(*ELIGIBLE)
That’s 30 keystrokes, as I have to press the Enter key to run the command. I can reduce it by omitting the keyword.
RCLACTGRP *ELIGIBLE
That’s 21 keystrokes, still more than I want to type over and over throughout the course of a day.
Fortunately, I can reduce this to five keystrokes. Here’s how.
I create a source member, usually in QGPL/QCMDSRC, and load it with one CMD command and two PARMS. (If you’ve never created a command before, don’t panic. It’s just like keying CL.) Here’s the source code for my RAGE command.
/* RAGE - Run command RCLACTGRP ACTGRP(*ELIGIBLE) */ /* CPP is QCMDEXC */ CMD PROMPT('RCLACTGRP ACTGRP(*ELIGIBLE)') PARM KWD(CMD) TYPE(*CHAR) LEN(27) + CONSTANT('RCLACTGRP ACTGRP(*ELIGIBLE)') PARM KWD(CMDLEN) TYPE(*DEC) LEN(15 5) CONSTANT(27)
In the CMD command, you can type some text in the PROMPT parameter, but it’s not necessary, as you’ll never prompt the command.
In the first PARM command, key the long command string in the CONSTANT parameter and the length of the command string in the LEN parameter.
Define the second PARM as 15,5 packed decimal and key the length of the command string in the CONSTANT parameter.
Now create the command, using QCMDEXC for the command-processing program.
CRTCMD CMD(xxx/RAGE) PGM(QCMDEXC) SRCFILE(xxx/QCMDSRC) SRCMBR(RAGE)
Now I type RAGE and press Enter — five keystrokes! — every time I need to destroy the activation groups while I’m testing.
Here’s another example. WJ4 (“Work with Job, Option 4”) shows me the spooled files that were created in my 5250 session. This saves me from wading through pages of spooled files in the Work with Spooled Files (WRKSPLF) panel.
/* WJ4 - Work with this job's spool files */ /* CPP is QCMDEXC */ CMD PROMPT('Work with job''s spool files') PARM KWD(CMD) TYPE(*CHAR) LEN(20) + CONSTANT('WRKJOB OPTION(*SPLF)') PARM KWD(LENGTH) TYPE(*DEC) LEN(15 5) CONSTANT(20)
I use these and other such commands all day long.
Just a few more comments and I’ll be done.
- You can start the command string with a question mark if you want to be prompted to fill in parameters.
/* WSJ - Prompt and run WRKSBMJOB */ /* CPP is QCMDEXC */ CMD PARM KWD(CMD) TYPE(*CHAR) LEN(20) + CONSTANT('?WRKSBMJOB') PARM KWD(LENGTH) TYPE(*DEC) LEN(15 5) CONSTANT(10)
Don’t forget that the command can be CALL. If you often call a program with the same parameters, creating a command can be a huge keystroke saver, even if you only use the command for one day.
- This process is very similar to what you do when you create PDM options. The difference is that these commands run from a 5250 command line and the PDM options run from a WRKxxxPDM panel. You may want to create a command first, then put it behind a PDM option of the same name.
- I never use these commands in production code. There’s no need to, but if there were, I’d put the “real” IBM-supplied commands in the production code.
You do lots of nice things to help other people do their jobs more easily. Do something nice for yourself for a change.
Hi Ted, thanks for another reminder about this. I used this technique years ago to give an operator similar shortcuts that we used back in S/34-S/36 days. Like D P to show spool files, I created a shortcut DP, etc. As I’m in PDM a lot, I’ve create numerous PDM shortcuts to reduce my typing. I think you said something once about the lazy programmer – I’ve seen him, he’s in my mirror. Thanks as always for your inspiring articles.
great tip!
You can further reduce that to 2 characters- in SEU set up an Option (F16) like ‘RG’ and then you just need to type that on any source member in your SEU screen
I do this for the various subsystems I like to check. So, after I’ve submitted a job, I just enter ‘QBATCH’ instead of WRKACTJOB SBS(QBATCH). I didn’t do the cool thing you did, I just created a CL called QBATCH that does WRKACTJOB, then a command, no parms, called QBATCH.
Hi Ted, great tip, and one I’ve been using too. I also like your WJ4 abbreviation, hadn’t thought of that. (IE: WrkJob option 4)
Just one restriction with this technique that I can’t see you’ve mentioned, is that CONSTANT is limited to 32 characters.
Thanks, Robert. I forgot all about that 32-character limitation. I should have mentioned that.
CRTPRXCMD could be an alternate approach to abbreviate long commands.
Yes, Kumar, and it would have the advantage of allowing us to key in parameters, unlike the technique in this article.