resourceAssociation variable for file I/O
When your program uses a record in an I/O operation, EGL assumes that the record-specific recordName.resourceAssociation variable contains the name of the physical file that holds the record (if that variable supports the particular type of file).
EGL initializes the variable in accordance with the ResourceAssociation part that is used at generation time; for more information, see the Resource associations part. You can change the object of your I/O operations at run time by placing a different value in the recordName.resourceAssociation variable.
In most cases, you must use the syntax recordName.resourceAssociation. If EGL can determine the record that you intended, you do not need to specify the recordName portion, as in each of the following cases:
- I/O is only performed against one record in the program.
- resourceAssociation is used in a function that performs I/O against only one record.
- I/O is performed against multiple records in the program, but all records have the same file name; in this case, the first record that appears in an I/O statement is used as the implicit qualifier.
- Primitive type
- CHAR
- Data length
- 300 characters for Java™ generation and Debug, 65 characters for COBOL generation
- Saved across segment?
- Yes
Definition considerations
The value that you move into recordName.resourceAssociation must be a valid system resource name for the system and file type that you specified when the program was generated. If more than one record specifies the same file name and you modify resourceAssociation for any record with that file name, the value of resourceAssociation changes for all the records in the program that have the same file name.
- An I/O option runs against a record that has the same EGL file name as the record that qualifies resourceAssociation.
- The record variable is changed.
To close the file that is associated with the current setting of resourceAssociation, use a close statement. EGL automatically closes all open files when a run unit ends or a segmented converse occurs.
For COBOL environments, EGL folds the contents of resourceAssociation to uppercase before it uses those contents to access a file. However, the value that you place in resourceAssociation remains unchanged for comparison purposes.
Files shared across programs
If multiple programs share a system resource, each program must set resourceAssociation to refer to the same resource. If two programs in the same run unit access the same logical file, each program must set resourceAssociation to the same system resource name at generation time to ensure that both programs access the same system resource at run time.
If two programs use the same EGL file name, each of the record-specific resourceAssociation variables must contain the same value. Otherwise the previously opened system resource is closed when a new one is opened.
- At generation time
- If two programs in the same run unit access the same logical file, specify the same system resource name for the logical file at generation to ensure that both programs access the same physical file at run time.
- At run time
- If you use recordName.resourceAssociation, each program that accesses the file must set resourceAssociation for the file. If two programs in the same run unit access the same logical file, each program must set resourceAssociation to the same system resource name to ensure that both programs access the same physical file at run time.
WebSphere® MQ records
The system resource name for WebSphere® MQ records defines the queue manager name and queue name. Specify the name in the following format:
queueManagerName:queueName
- queueManagerName
- Name of the queue manager
- queueName
- Name of the queue
As shown, the names are separated with a colon. However, you can omit queueManagerName and the colon. The system resource name is the initial value for the record-specific resourceAssociation field and identifies the default queue that is associated with the record. For more information, see WebSphere MQ message queue access.
Compatibility
| Platform | Issue |
|---|---|
| CICS® for z/OS® |
|
| IMS™ BMP | IMS™ BMP supports the same file types that are supported for IMS/VS in addition to those that are supported for z/OS® batch. |
| IMS/VS |
|
| iSeries® COBOL | The fileType must
be seq (sequential) or vsam.
You can move the value to resourceAssociation in
one of the following ways:
When you modify the value in resourceAssociation,
the iSeries® OVRDBF
command functions in the following manner:
The value set in resourceAssociation is propagated from the call level and is changed to all its subordinate call levels. The value is not propagated if the file was previously opened by the program. |
| MQSeries® | The system resource name for WebSphere® MQ records defines the queue manager name and queue name. Use the following format to specify the name:
As shown, the names are separated with a colon. However, queueManagerName and the colon can be omitted. The system resource name is used as the initial value for the record-specific resourceAssociation field and identifies the default queue associated with the record. |
| z/OS® batch |
|
Example
The following example shows the assignment of a file to the resourceAssociation variable.
if (process == 1)
myrec.resourceAssociation = "myFile.txt";
else
myrec.resourceAssociation = "myFile02.txt";
end