Change Command Default (CHGCMDDFT)

The Change Command Default (CHGCMDDFT) command changes the default value of a command parameter.

The parameter must have an existing default to change to a new default value. The changed command can be either an IBM-supplied command or a user-defined command.

To find out which parameters of a command have default values, enter the command name and press the F4 key (Prompt) to prompt for the command. Default values for parameters are shown on the first command prompt screen. However, not all defaults are shown. A parameter that is a list of elements or a qualified name may have a single value (SNGVAL) as the default of the entire list or qualified name. For example, Display Job (DSPJOB) is a command in which JOB is a list of elements but has a SNGVAL as the default for the entire list. See 'Additional Considerations' for more information on SNGVAL as a default value.

The new parameter default must be valid for the parameter being changed. To find out which values are valid, move the cursor to the default value shown and press the F4 key. The Parameter Prompt with Permissible Values display shows a list of valid values and/or the value of the parameter type. When only a list of valid values is shown, only those values can be used as new default values. Otherwise, any valid value that conforms to the requirements of the parameter can be used as the new default.

Processing a command that had earlier default value changes is the same as specifying the new default value for the parameter on an unchanged copy of the same command. The new default value may conflict with other parameter combinations even when the parameter is not explicitly specified.

When you run system commands with default value changes from system displays, the new default values cannot be used. This occurs because the system cannot use the command device to process a function. Instead, the system can use an IBM internal device to a system program to run the requested function. Therefore, use the F4 key (Prompt) key to prompt for the system command when processing the command from a system display. In most cases, the specified default value is then used.

To change an IBM-supplied command, you should create a copy of the command in a user library and change the defaults of the copied command, instead of the IBM-supplied command itself. The user library should be listed before the library QSYS on the library list. Save the source of the CHGCMDDFT command so that the same changes can be made again later, if needed. This procedure allows you to use the original IBM-supplied command defaults when necessary and ensures that changes made to the copied commands are not overlaid when a new release is installed, or a PTF is applied that contains the IBM-supplied command.

A compatibility problem can occur when a new release is installed or a PTF that contains IBM-supplied commands is applied. If IBM-supplied commands have been copied into a user library and the newly installed IBM-supplied version of the command has had new parameters added to it, the copied version of the command will not run correctly. This is a result of parameter mismatches between the copied command and the newly installed IBM-supplied command processing program. Also, if a copied command is used in the starting program of a user profile, this program does not run correctly, again because of parameter mismatches between the old command and the new command processing program. As a result, the user cannot sign onto the system. To prevent this, you should ensure that at least one user profile exists on the system which has authority to make the required changes to the starting programs and has QCMD as the starting program. An alternative is to code the starting programs to detect all errors and to recover by showing the Command Entry display (program QCMD).

The CL topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/, contains a list of recommendations and examples for using the Change Command Default (CHGCMDDFT) command.

Additional Considerations

A keyword that is defined as a list of elements or as a qualified name, and has a SNGVAL as the default, can have a required element or qualifier as the first element in the list of elements or qualified name. The default SNGVAL may be changed to another valid SNGVAL if one exists, but the required element or qualifier cannot have a default value. A SNGVAL cannot be used as a new default value if the existing default value is not a SNGVAL. To find out if list elements or qualifiers of a qualified name have default values, change the SNGVAL to a valid value for the keyword, blank out remaining list elements or qualifiers, and press the Enter key. If any remaining list elements or qualifiers have default values, the default values now appear in the input field for the list element or qualifier.

Restriction: The user must have object management and *USE authority for the command being changed.

Parameters

Keyword Description Choices Notes
CMD Command Qualified object name Required, Positional 1
Qualifier 1: Command Name
Qualifier 2: Library Name, *LIBL, *CURLIB
NEWDFT New default parameter string Character value Required, Positional 2

Command (CMD)

Specifies the command to be changed. The command can be a user-defined or an IBM-supplied command.

Qualifier 1: Command

name
Specify the name of the command whose parameter defaults are to be changed.

Qualifier 2: Library

*LIBL
All libraries in the library list for the current thread are searched until the first match is found.
*CURLIB
The current library for the job is used to locate the command. If no library is specified as the current library for the job, QGPL is used.
name
Specify the library where the command is located.

New default parameter string (NEWDFT)

Specifies the parameter string, enclosed in apostrophes, that contains the new default values being assigned to a parameter, element, or qualifier if a value is not specified by the user when the command is processed. New default values can be specified only for those parameters, elements, or qualifiers that already have a default value.

*N must be used as a place holder in a qualified name or in a list of values to take the place of elements or qualifiers that do not have existing default values. If the elements or qualifiers have default values but are not to be changed to a new default value, then *N or the existing default value can be used as the place holder in the list of values or the qualified name.

Note: Checking between parameters and validity checking program processing is done when the command is run. Neither are performed during the changing of the default value.

character-value
Specify the new default parameter value string, enclosed in apostrophes.

Examples

The following examples show changes in the defaults of command parameters when the CHGCMDDFT command is processed.

Example 1: Changing Default Value of AUT Parameter

CHGCMDDFT   CMD(CRTPF)  NEWDFT('AUT(*EXCLUDE)')

This command changes the AUT parameter default to *EXCLUDE for the Create Physical File (CRTPF) command.

Example 2: Changing CRTCLPGM Command Defaults

CHGCMDDFT   CMD(USRQSYS/CRTCLPGM)
            NEWDFT('PGM(LIB1/*N) SRCFILE(LIB1/FILE1) LOG(*YES)')

This command changes the defaults of the Create CL Program (CRTCLPGM) command when the NEWDFT parameter is specified in the form above. In the example, the default value of the LOG parameter is *YES. No default can be specified for the second qualifier (program-name) of the PGM parameter because no default value exists. Therefore, *N is used as the place holder for the second qualifier. The first qualifier (library-name) of the PGM parameter has a default value of LIB1. For the SRCFILE parameter, the first qualifier (library-name) has a default value of LIB1. The second qualifier (source-file-name) has a default value of FILE1.

Example 3: Changing CRTPF Default Value of MAXMBRS Parameter

CHGCMDDFT   CMD(CRTPF)  NEWDFT('MAXMBRS(*NOMAX)')

This command changes the default value of the MAXMBRS parameter on the CRTPF command to *NOMAX.

Error messages

*ESCAPE Messages

CPF6216
Command &1 not valid for &2 command
CPF6260
Errors detected while changing defaults.
CPF6261
Cannot change command &1 in library &2.