Changing CL command defaults
To change the default value of a command parameter, use the Change Command Default (CHGCMDDFT) command.
The command parameter must have an existing default to change to a new default value. You can change either an IBM-supplied command or a user-written command. You must use caution when changing defaults for IBM-supplied commands. The following recommendations pertain to changing defaults:
- Use the Create Duplicate Object (CRTDUPOBJ) command
to create a duplicate of the IBM-supplied command that you want to
change in a user library. This allows other users on the system to
use the IBM-supplied defaults if necessary.
Use the Change System Library List (CHGSYSLIBL) command to move the user library ahead of QSYS or any other system-supplied libraries in the library list. This will allow the user to use the changed command without using the library qualifier.
Changes to commands that are needed on a system-wide basis should be made in a user library. Additionally, you should add the user library name to the QSYSLIBL system value ahead of QSYS. The changed command is used system-wide. If you need to run an application that uses the IBM-supplied default, do so by using the CHGSYSLIBL command. Doing this removes the special library or library-qualify to the affected commands.
- Installing a new release of a licensed program replaces all IBM-supplied
commands for the licensed program on the machine. You should use a
CL program to make changes to commands when installing a new release.
This way you can run the CL program to duplicate the new commands
to pick up any new keywords and make the command default changes.
If an IBM-supplied command has new keywords, a copy of the command from a previous release may not run properly.
The following is an example of a CL program that is used to delete the old version and create the new changed command.
Note: By using the code example, you agree to the terms of the Code license and disclaimer information.PGM DLTCMD USRQSYS/SIGNOFF CRTDUPOBJ OBJ(SIGNOFF) FROMLIB(QSYS) OBJTYPE(*CMD) + TOLIB(USRQSYS) NEWOBJ(*SAME) CHGCMDDFT CMD(USRQSYS/SIGNOFF) NEWDFT('LOG(*LIST)') . . Repeat the DLTCMD, CRTDUPOBJ and CHGCMDDFT for each command you want changed . . ENDPGM
You can track changes you make to CL command defaults for use when you install a new release. To track changes, register an exit program for exit point QIBM_QCA_RTV_COMMAND. The exit program is called when you run the CHGCMDDFT command. One of the parameters passed to the exit program is the command string that is being run. You can save the command string to a source file and then compile the source file into a CL program. Finally, you use this program to reproduce the changes you have made to command defaults during the previous release.
The following steps can be used to build the NEWDFT command string for the CHGCMDDFT command. The USRQSYS/CRTCLPGM command is used in this example.
- Create a duplicate copy of the command to be changed in a user
library with the following command:
CRTDUPOBJ OBJ(CRTCLPGM) FROMLIB(QSYS) OBJTYPE(*CMD) + TOLIB(USRQSYS) NEWOBJ(*SAME)
- Enter the command name to be changed in a source file referred to by the Source Entry Utility (SEU).
- Press F4 to call the command prompter.
- Enter any new default values for the keywords you want changed.
In this example,
AUT(*EXCLUDE)
andTEXT('Isn''t this nice text')
is entered. - Required keywords cannot have a default value; however, in order to get the command string in the source file, a valid value must be specified for each required keyword. Specify PGM1 for the PGM parameter.
- Press the Enter key to put the command string into the source
file. The command string returned would look like this:
USRQSYS/CRTCLPGM PGM(PGM1) AUT(*EXCLUDE) + TEXT('Isn''t this nice text')
- Remove the required keywords from the command string:
USRQSYS/CRTCLPGM AUT(*EXCLUDE) + TEXT('Isn''t this nice text')
Remember that you may change only parameters, elements, or qualifiers that have existing default values. Specifying a value for a parameter, element, or qualifier that does not have an existing default value makes no default changes.
- Insert the CHGCMDDFT at the beginning as shown
in the following example:
CHGCMDDFT USRQSYS/CRTCLPGM AUT(*EXCLUDE) + TEXT('Isn''t this nice text')
- You must quote the input for the NEWDFT keyword as shown in the
following example:
CHGCMDDFT USRQSYS/CRTCLPGM 'AUT(*EXCLUDE) + TEXT('Isn''t this nice text')'
- Because there are embedded single quotation marks in the NEWDFT
value, you must double them for the process to run properly:
CHGCMDDFT USRQSYS/CRTCLPGM 'AUT(*EXCLUDE) + TEXT(''Isn''''t this nice text'')'
- Now if you press F4 to call the command prompter, then F11 to
request keyword prompting, you will see the following display:
Command . . . . . . . . . . : CMD R CRTCLPGM Library . . . . . . . . . : USRQSYS New default parameter string: NEWDFT R 'AUT(*EXCLUDE) TEXT(''Isn''''t this nice text'')'
- Now if you press the Enter key, the CHGCMDDFT command
string is:
CHGCMDDFT CMD(USRQSYS/CRTCLPGM) NEWDFT('AUT(*EXCLUDE) + TEXT(''Isn''''t this nice text'')')
- Press F1 to exit SEU, and create and run the CL program or procedure.
- The USRQSYS/CRTCLPGM will have default values of
*EXCLUDE for AUT
and'Isn''t this nice text'
for TEXT.