Change command defaults

You can change the default value of a command keyword by using the Change Command Default (CHGCMDDFT) command.

The keyword must have an existing default in order to allow a 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 are recommendations for changing defaults:

  1. 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 Change System Library List (CHGSYSLIBL) command. Doing this removes the special library or library-qualify to the affected commands.

  2. 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:

    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 Change Command Default (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 Change Command Default (CHGCMDDFT) command. The USRQSYS/CRTCLPGM command is used in this example.

  1. 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)
  2. Enter the command name to be changed in a source file referred to by the Source Entry Utility (SEU).
  3. Press F4 to call the command prompter.
  4. Enter any new default values for the keywords you want changed. In this example, AUT(*EXCLUDE) and TEXT('Isn''t this nice text') is entered.
  5. 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.
  6. 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')
  7. 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.

  8. Insert the Change Command Default (CHGCMDDFT) at the beginning as shown in the example below:
    CHGCMDDFT USRQSYS/CRTCLPGM AUT(*EXCLUDE) +
    TEXT('Isn''t this nice text')
  9. You must quote the input for the NEWDFT keyword as shown in the example below:
    CHGCMDDFT USRQSYS/CRTCLPGM 'AUT(*EXCLUDE) +
    TEXT('Isn''t this nice text')'
  10. Since there are embedded apostrophes 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'')'
  11. 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'')'
  12. Now if you press the Enter key, the Change Command Default (CHGCMDDFT) command string is:
    CHGCMDDFT CMD(USRQSYS/CRTCLPGM) NEWDFT('AUT(*EXCLUDE) +
              TEXT(''Isn''''t  this nice text'')')
  13. Press F1 to exit SEU and create and run the CL program or procedure.
  14. The USRQSYS/CRTCLPGM will have default values of *EXCLUDE for AUT and 'Isn''t this nice text' for TEXT.
Related information
CL command finder
Application Programming Interfaces (APIs)