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.
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.
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.
SYSIN | use DD_STDIN |
SYSPRINT | use DD_STDOUT |
SYSOUT | use DD_STDOUT |
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
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