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:
That’s 30 keystrokes, as I have to press the Enter key to run the command. I can reduce it by omitting the keyword.
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.