Put Environment Variable (QtmhPutEnv) API

The QtmhPutEnv() API allows you to set or create a job-level environment variable.

Required Parameter Group:
1 Environment string Input Char(*)
2 Length of environment string Input Binary(4)
3 Error Code I/O Char(*)

Required parameter group

Environment string
INPUT:CHAR(*)

The input string of the form: ″envVar=value″. Where ″envVar″ is the name of the new or existing environment variable, and ″value″ is the value you want to set the environment variable. Note that they are both case sensitive. The server expects this value to be in the CCSID of the job.

Length of environment string
INPUT:BINARY(4)

The input variable that contains the length of the environment string parameter (without trailing blanks). For example, the length of the environment string ″envVar=value″ is twelve.

Error Code
I/O:CHAR(*)

The structure in which to return error information. For the format of the structure and for details on how to process API errors, see the API error reporting topic in the IBM® i Information Center.

Error messages

CPF24B4 E
Severe Error while addressing parameter list.
CPF3021 E
The value specified for the argument is not correct.
CPF3C17 E
Error occurred with input data parameter.
CPF3CF1 E
Error code parameter not valid.
CPF3408 E
The address used for an argument is not correct.
CPF3460 E
Storage allocation request failed.
CPF3474 E
Unknown system state.
CPF3484 E
A damaged object was encountered.
Note: The Environment Variable APIs provide the putenv() (Put Value in Environment Variable) function necessary to set (or create and set) an environment variable. Therefore, programs written in ILE C do not need to use the QtmhPutEnv() API. This API, for ILE C, is more difficult to use (and is slower) than the putenv() API on which it is based.

Programs that need CCSID conversion support for environment variables should use the Put environment variable with CCSID (QzsrPutEnvCCSID) API.