Method 3

The physical disk file name can be specified with the use of UNIX shell environment variables. This method takes precedence over methods 1 and 2. This method allows you to easily alter the physical disk file used for different invocations of the same application. You can specify the location of a file using an environment variable whose name is derived from either of the above methods with MF_ or DD_ prefixed, or use the DCB_ddname environment variable.

Derived name environment variable

You can set one or more environment variables to point to the location of referenced files rather than hard-coding their locations. For each file, set an environment variable whose name is derived from either Method 1 or Method 2, with MF_ or DD_ prefixed.

Note: The MF_ and DD_ prefixes are equivalent and can be used interchangeably.

For example, the following code does not specify the location of either opened file:

dcl file data2 update; 
dcl file specs output; 

open file (data2); 
open file (specs) title('report');

The locations become known to the program via the following environment variables:

set MF_DATA2   /common/data
set MF_REPORT   /common/report

I/O operations for file data2 access /common/data and I/O for file specs access /common/report.

In this example, MF_REPORT is the name of the second environment variable because the title option on the second open statement is set to 'report', which overrides the specs file name.

Note: To assign a physical file to the following special file declarations you will need to use the corresponding environment variables:
SYSIN use DD_STDIN
SYSPRINT use DD_STDOUT
SYSOUT use DD_STDOUT

DCB_ddname environment variable

Use the DCB_ddname environment variable to specify characteristics of the dataset in the absence of JCL. Each characteristic is represented by a set of values, with each value separated by a space.

Windows:

set DCB_ddname type record-length format 

UNIX/Linux:

export DCB_ddname type record-length format 
type
Valid values are:
  • RECORD
  • STREAM
  • VSAM
record-length
Valid values are 1 through 32765.
format
Valid values are:
  • F (for fixed length records)
  • V (for variable length records)

For example, if you had a FIXED LENGTH file used in RECORD IO with a length of 20 and a file name of MUMBLY, the environment variable would be set as follows:

Windows:

set DCB_MUMBLY=RECORD 20 F

UNIX/Linux:

export DCB_MUMBLY=RECORD 20 F
Note: If the DCB_ddname environment variable is missing, and the format and record size are not used as part of the ENV() option on the FILE declaration, then the file is assumed to be an ASCII LSEQ file.