Operating System - OpenVMS
1753427 Members
4768 Online
108793 Solutions
New Discussion юеВ

Re: OpenVMS COBOL: Dynamic Filenames

 
SOLVED
Go to solution
Paul Raulerson
Advisor

OpenVMS COBOL: Dynamic Filenames

This is probably just me having tunnel vision from another platform, but I need to use dynamic filenames in a program.

I have about 40 files, all of which are small and all of which have exactly the same internal format. I need to be able to dynamically open any of these files in a program and RWUD the records in them.

Yes, I could just combine them all into a single file, and use a type key to differentiate the data, but these are basically "domain tables" and keeping them separate makes life *much* easier.

Anyone know how I can do this easily? The files are indexed by the way, with only a primary key, which is in the exact same place in the record of each file (the first six bytes).

Thanks -Paul
5 REPLIES 5
Jon Pinkley
Honored Contributor

Re: OpenVMS COBOL: Dynamic Filenames

Maybe I don't understand your question, but normally you would just use a logical name for the file, and use that logical name as the file to open.

Then you can define the logical name either inside or outside the program, and the program will open the file specified by the logical name.

For example, choose a logical name that describes what the files are used for, for example "DOMAIN_TABLE_FILE", and in the open statement, use DOMAIN_TABLE_FILE as the file to open. Outside your program,

$ define DOMAIN_TABLE_FILE MY_DISK:[MYDIR]DOMAIN_0001.DAT
$ run table_updater

The file MY_DISK:[MYDIR]DOMAIN_0001.DAT
will be used when the cobol program opens DOMAIN_TABLE_FILE

This will work for any files, as long as they all have the same layout.

But perhaps dynamic filenames has some specific meaning I am not aware of.

Jon
it depends
Hein van den Heuvel
Honored Contributor
Solution

Re: OpenVMS COBOL: Dynamic Filenames

OpenVMS Cobol provides two places to provide a file name.

1) The ASSIGN clause in the SELECT

2) The FD clause VALUE OF ID which can be a data-name for a WS item.

They map to the RMS 'filename' and 'default-filename'.

Your option is to just set the rigth file name in the value of id, or to dynamically define a logical name for the 'select' name to follow.

fwiw... from an RMS and system resource perspective the single file solution is LIKELY to be preferable. Not garantueed, just very likely. Shared overhead basically, and the exponential power of index trees.


Hope this helps some,
Hein van den Heuvel (at gmail dot com)
HvdH Performance Consulting


Paul Raulerson
Advisor

Re: OpenVMS COBOL: Dynamic Filenames

Thank You Gentlemen:

The VALUE OF ID clause is what I was looking for. I knew I could do it from DCL, but I needed to do it within an executing program to make all that work well.

P.S. -You understood exactly what I meant by Dynamic Files, thank you. It's a bit different in a particular three letter competitor's COBOL.

Thanks -Paul
Paul Raulerson
Advisor

Re: OpenVMS COBOL: Dynamic Filenames

Thank You!
Leif R. Jansson
Occasional Advisor

Re: OpenVMS COBOL: Dynamic Filenames

Hi

If You know what file to open before the program is started You can use 'logical names'.
Logical names works like an 'alias' and can be used as filenames in programs.

From DCL create the logical name FILE_TO_OPEN:
$ DEFINE/JOB FILE_TO_OPEN ANY_FILE.DAT


From program use the logical name:
OPEN FILE_TO_OPEN

For more info about logical names do:
$ HELP DEFINE

/Regards
Leif J
All questions are good questions