Remapping a file name hard-coded in a SELECT statement using an external variable.
Estimated Reading Time: 1 MinutesIf your program uses a hard-coded value for the data file name, you can define an alternate name as an alias in your configuration file. To do this, add the following two properties to your configuration file:
iscobol.file.env_naming=true
iscobol.<assign_to_name>=<new-name>
<assign_to_name>: The physical file name specified in theASSIGN TOclause of theSELECTstatement.<new_name>: The physical name of the file you want to access.
Important: The name must be normalized:
- Replace any hyphens (
-) with underscores (_). - Use lowercase letters.
For example, a file calledNew-Nameshould be referenced asnew_namein the variable.
Suppose your program includes the following
SELECT statement:
select FILE1 assign to "file-1" organization indexed access dynamic record key f1-key status file-status .
To use an alternate file name, such as
new-file-1, add these properties to your configuration file:
iscobol.file.env_naming=true iscobol.file_1=new-file-1
If the "assign to" contains a full or a relative path name, the path needs to be specified in your property.
For example:
select FILE1 assign to "subdir/file-1" organization indexed access dynamic record key f1-key status file-status .
iscobol.file.env_naming=true iscobol.subdir/file_1=subdir/new-file-1