Admin Alert: How to Change OS/400 Command Default Parameters
October 19, 2005 Joe Hertvik
A number of readers have recently written in and asked me how to change default parameters for OS/400 commands. While IBM does provide the Change Command Default command (CHGCMDDFT) for this purpose, there are a few wrinkles in the process that you need to understand to use CHGCMDDFT effectively.
Before you begin changing command parameters, it’s always best to make a copy of each command that you want to change and only modify the copied command. This is a wise move for a number of reasons. First, you can retain IBM’s original unaltered commands in case you make a mistake and want to reset the command back to its prior state. Second, if you put the changed command in a separate library, you can place that library higher in your user’s library lists than IBM’s QSYS command library (where most commands are kept) and your users will automatically use the changed command without having to think about it. Finally, if you place the altered command in a different non-IBM library, the changed command will remain intact after an i5/OS upgrade, giving you time to coordinate your changes with any command changes IBM may make in the new release.
Use the Create Duplicate Object command (CRTDUPOBJ) to make an alterable copy of the command in a different library. If you wanted to copy the Display Job command (DSPJOB) to the NEWCOMMAND library, for example, your CRTDUPOBJ command would look like this:
CRTDUPOBJ OBJ(DSPJOB) FROMLIB(*LIBL) OBJTYPE(*CMD) TOLIB(NEWCOMMAND)
Once the command is copied over, you can start modifying it to suit your needs. By default, the parameter to specify which information the command will display (OPTION) is set to *SELECT, which tells DSPJOB to show users a menu from which they can choose a job option to display. If you want to change the default for this parameter so that it automatically shows all job information when DSPJOB runs, you can change the parameter default to *ALL by running the following CHGCMDDFT statement.
CHGCMDDFT CMD(NEWCOMMAND/DSPJOB) NEWDFT(‘OPTION(*ALL)’)
The New default parameter string parameter (NEWDFT) tells OS/400 to change the default parameter to *ALL. Once that happens, the next time that you run the DSPJOB command in library NEWCOMMAND, it will automatically display all information about your target job.
CHGCMDDFT is fairly straight-forward when you are changing single-value default parameters. It gets slightly more confusing when you want to change default values for parameters containing one or more list elements.
As an example, if you want to change the default parameters on the Create RPG Module command (CRTRPGMOD) so that it always uses QGPL/QRPGLESRC1 as its source file parameter (SRCFILE) and it always compiles the module into the RPGLEMOD library (the MODULE parameter), you could change CRTRPGMOD to use the following default parameters:
CHGCMDDFT CMD(NEWCOMMAND/CRTRPGMOD) NEWDFT(‘MODULE(RPGLEMOD/*N) SRCFILE(QGPL/QRPGLESRC1)’)
When you enter and run the CRTRPGMOD command, it will give you the new defaults. Also notice that I used *N as one of the default name values in CRTRPGMOD’s MODULE list parameter. When you specify *N as a default, it functions as a placeholder to tell i5/OS not to change the default for that particular element or value. *N can be used to retain default values in list parameters or it can be used to designate command parameters that do not have existing default values (such as a module name, which may change every time the command is run).
But the trickiest part about changing default command parameters occurs when you try to change a list parameter that has a single value, such as *ALL, in the first element of the list to a multi-valued list parameter such as a qualified object name. In IBM parlance, a single-value parameter is known as a SNGVAL, and there are a few bumps in the road on this one. Here’s a recap of what IBM says about changing a SNGVAL in the first element of a list parameter.
First, for these parameters, the SNGVAL element can only be changed to another valid SNGVAL entry, if one exists. For example, the Message Queue list parameter (MSGQ) on the Create Device Description (Printer) command (CRTDEVPRT) has a SNGVAL default of *CTLD, which indicates that devices messages are sent to the message queue defined in the attached controller. If you attempt to change this parameter to indicate a specific message queue, complete with message queue name and qualifying library, by running a command like this:
CHGCMDDFT CMD(NEWCOMMAND/CRTDEVPRT) NEWDFT(‘MSGQ(QGPL/DEVICEQ)’)
You will receive the following message:
CPD6266 — Qualifier changed, but SNGVAL at higher level
What this appears to mean is that, since you can only replace a SNGVAL list parameter with another SNGVAL, IBM will store the qualifier part of the parameter change with the command, but the command will not automatically use the qualifier unless the message queue name (the first item in the list) is manually changed when the command is entered. So you would still need to manually put in your message queue name but, once you do, i5/OS will specify that the device should look in the QGPL library to find that message queue. In my testing, I have not found a way around this limitation.
As another example, IBM also provides a software technical document (click here to read it) that explains what happens when you try to change the Restart Options parameter (RESTART) on the Power Down System command (PWRDWNSYS) from its SNGVAL default of *NO to *YES with a Restart type of *FULL. This change will also not work as expected because of the SNGVAL problem, and IBM recommends working around the issue because there is no good solution to changing both PWRDWNSYS list parameter elements.
The second thing you need to be aware of is that a SNGVAL cannot be used as a new default value if the current default value is not a SNGVAL. The same limitation that prevents you from replacing a SNGVAL with a qualified list item works in reverse, as well.
The end result is that, yes, you can change the default parameters in many different i5/OS commands, but you have to be aware of the limitations.
iSeries Information Center, CHGCMDDFT (Change Command Default) Command Description, IBM
IBM Software Technical Document, CHGCMDDFT of RESTART Parameter on PWRDWNSYS Does Not Work in V4R1/V4R2/V4R3, IBM