Change Environment Variable (CHGENVVAR)

Where allowed to run: All environments (*ALL)
Threadsafe: Yes
Parameters
Examples
Error messages

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.

Top

Parameters

Keyword Description Choices Notes
ENVVAR Environment variable Character value Required, Positional 1
VALUE New value Character value, *SAME, *NULL Optional, Positional 2
CCSID Coded character set ID 1-65535, *JOB, *HEX, *SAME Optional, Positional 3
LEVEL Level *JOB, *SYS Optional
Top

Environment variable (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.

Note: The case is preserved when lowercase characters are specified.

If an apostrophe is intended, two apostrophes must be used ('').

This is a required parameter.

Top

Initial value (VALUE)

Specifies the environment variable value.

The possible values are:

*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. 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 ('').

Note: The case is preserved when lowercase characters are specified.

Top

Coded character set ID (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.

The possible values are:

*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.
Top

Level (LEVEL)

Specifies the level of the environment variable.

The possible values are:

*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.

Top

Examples

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(273)

This command changes the CCSID of the job-level environment variable named altdir to 273. 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.

Top

Error messages

*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.
Top