[Info-vax] VMS Cobol filename issue

jeffrey_dsi jeffrey at digitalsynergyinc.com
Thu Dec 21 12:24:25 EST 2023



On 12/21/23 06:54, Arne Vajhøj wrote:
> Even considering that in general I do not understand
> Cobol, then this one has me puzzled.
> 
> How does one open a file with the filename being variable?
> 
> Docs says:
> 
> <quote>
> On OpenVMS, if file-spec is not a literal, the compiler:
> • Translates hyphens in the COBOL word to underline characters
> • Treats the word as if it were enclosed in quotation marks
> ...
> If you specify ASSIGN TO unquoted string, you need not specify this name 
> in the WORKING-STORAGE section. For example:
> 
> ASSIGN TO TEST1
> 
> This assignment would use "TEST1.DAT" on OpenVMS Alpha and I64.
> 
> On UNIX systems, you would specify:
> 
> ASSIGN TO "TEST1.DAT"
> 
> or:
> 
> ASSIGN TO TEST1
> ...
> WORKING-STORAGE SECTION.
> 01 TEST1 PIC X(9) VALUE IS "TEST1.DAT".
> </quote>
> 
> So easy to do in OSF/1 aka DUNIX aka Tru64, but how
> does one do it on VMS??
> 
> Arne
> 
> 
> 

The only way I've seen to make the filename in Cobol a variable is to 
use a logical.

ASSIGN TO "TEST"

and before the program is run

$ DEFINE TEST PROD_DATA:MYFILE.DAT




More information about the Info-vax mailing list