Hi Jack,
A platform I have extensively worked on (Tandem NonStop Servers) has a COBOL85 compiler. This compiler is comparable to COBOL II for IBM. I have coded both batch and online programs with COBOL85.
When dealing with "unpredictable" files, I either use COBOL's own file definitions and handling, or I make system (or API) calls from COBOL to the OS (Guardian) to deal with such situations. These methods offer more flexibility and sophistication to COBOL, that you will have to labor to find by using techniques that rely on batch oriented parameters passing strategies such as offered by JCL.
In order to deal with variable length and variable name files on Tandem, all one has to do is use the following coding strategies - no "JCL".
COBOL only solution:
SELECT OPTIONAL input-file
ASSIGN TO #DYNAMIC
This will reserve a file handle. You can assign any file to it, open it, close it, and re-assign another file. The COBOL_ASSIGN_ routine, will be called to assign file names to the handle when needed.
FD input-file
RECORD IS VARYING IN SIZE FROM 10 TO 2400 CHARACTERS DEPENDING ON num-bytes.
This will accommodate any record size you wish (from 10 to 2400 bytes, in this example). When the file is opened (yes, it will be opened without specifying num-bytes beforehand) and read, num-bytes will contain the current file record size (if you need it).
COBOL and OS solution:
The other technique for dealing with these pesky files is to use system (API) calls to open and read the files. In this strategy, you will not need the COBOL Environment Division at all, and you will only use the Working-Storage in the Data Division.
The following code snippets come from a fully functional program (I wrote years ago) that does what the utility GREP does on Unix systems. The program (written in COBOL) looks to match a search string by opening and reading any file type (and any record size) on any disk on the system.
Code:
This call returns the next file on disk, including various characteristics about the file structure and type:
ENTER TAL "filename_findnext_"
USING search-id
file-name (1:36)
file-name-len
entity-info-grp
GIVING result
This call will open any file on Tandem:
ENTER TAL "file_open_"
USING file-name (1:file-name-len)
file-name-number
GIVING result
While this call will read any given file returning the number of bytes (record size) read:
ENTER TAL "readx"
USING file-name-number
edit-buffer
edit-buffer-len
count-read
All the information is of course processed in COBOL. As you can see, there was absolutely no JCL needed to accomplish any of the above. Your OS already has any information you need about any file on your system, and COBOL can get it.
Dimandja