CHGENVVAR (Change Environment Variable)
CHGENVVAR Command syntax diagram
Purpose
The Change Environment Variable (CHGENVVAR) command changes the value for an existing environment variable.
Restriction: You must have *JOBCTL special authority to use this command to change system-level environment variables.
Required Parameters
- ENVVAR
- Specifies the name of the environment variable to be changed. If an environment variable by this name does not exist at the specified level (LEVEL parameter), error message CPFA981 is issued.
The case is preserved when lowercase characters are specified. If an apostrophe is intended, two apostrophes must be used ('').
Optional Parameters
- VALUE
- Specifies the environment variable value.
*SAME: The value does not change.
*NULL: The value of the environment variable is the null character (X'00'). This value can be used to stop the association of the current environment variable value with the specified environment variable name.
'environment-variable-value': Specify the value of the environment variable. CHGENVVAR limits value to a maximum of 1024 bytes in length. The case is preserved when lowercase characters are specified. Valid values include all EBCDIC characters. The value must be enclosed in apostrophes if it contains any non-alphanumeric character or blanks. If an apostrophe is intended, two apostrophes must be used ('').
- CCSID
- Specifies the coded character set identifier (CCSID) of the text supplied on the ENVVAR and the VALUE parameters. This value is stored with the environment variable.
*SAME: The value does not change.
*JOB: The CCSID of the text is assumed to be the CCSID of the job running this command.
*HEX: The CCSID of 65535 is stored with this environment variable.
coded-character-set-identifier: Specify the CCSID to be stored with the environment variable. Valid values range from 1 through 65535.
- LEVEL
- Specifies the level of the environment variable.
*JOB:This is a job-level environment variable.
*SYS:This is a system-level environment variable.
Note: This field is only used to specify the level of the environment variable that is being changed, and cannot be used to change the level of the environment variable.
Examples for CHGENVVAR
Example 1: Change a Job-level Environment Variable
CHGENVVAR ENVVAR(altdir) VALUE(/mydir/test)This command changes the value of the job-level environment variable named altdir to the value /mydir/test. The CCSID that is stored with the environment variable is not changed.
Example 2: Change the CCSID of an Environment Variable
CHGENVVAR ENVVAR(altdir) CCSID(819)This command changes the CCSID of the job-level environment variable named altdir to 819. The environment variable value is not changed.
Example 3: Set an Environment Variable to Null
CHGENVVAR ENVVAR(LIBPATH) VALUE(*NULL)This command changes the value of the job-level environment variable named LIBPATH to the null (x'00') character.
Example 4: Change a System-level Environment Variable
CHGENVVAR ENVVAR(home) VALUE(/usr/home) LEVEL(*SYS)This command changes the value of the system-level environment variable named home to /usr/home.
Error messages for CHGENVVAR
*ESCAPE Messages
- CPFA981
- Environment variable does not exist.
- CPFA982
- ENVVAR character not valid.
- CPFA983
- Unexpected error occurred.
- CPFA984
- Maximum number of environment variables exist.
- CPFA98E
- *JOBCTL special authority required to update system-level environment variables.
- CPF3BCA
- CCSID &1 not supported.