any files open after you have altered it. Files opened prior to your changing the setting will have been opened using (cont.)
the old setting.
The *READ command can be issued at any time to change the default open type to OPENR (open for read-only). If your (cont.)
program is a report program which never needs to update any records on any files, you should issue the *READ command (cont.)
near the top of your processing logic so that all files will be opened read-only.
The *LOAD command can be used to reset the default open type to OPENU. Your program can issue the *LOAD and *READ commands any number of times throughout its processing.
Please not that these commands affect only implicit opens. Also note that explicit opens neither affect the default setting not are affected by it.
##
Explicit Opens
Several commands are provided for your programs to explicitly open a file. In the CICS environment all of these are ignored and treated as a NOOPS (no operation).
The OPENR command will open a file for read-only.
The OPENU command will open a file for input-output, allowing updates.
The OPENO command will open a file for output, intiializing the file.
The OPENE command will open a file "extended". This is valid only for a sequential file and allows you to add records to the "end" of the file.
The OPENX command will open a file for exclusive input-output. That means that no other user on the network will be (cont.)
able to access that file until you have closed it or reached end-of-job. This command has meaning only on a LAN/WAN and (cont.)
is equivalent to OPENU if issued on a mainframe. Opening exclusively will greatly speed your processing sicne not (cont.)
sharing logic will be executed.
##
Explicit Closes
When an online program completes a transaction, sneding the screen to the operator, an implicit close is done (except (cont.)
in CICS) on all files that were left open. They will automatically be reopened with any positioning restored for the (cont.)
next transaction if needed. Explicit closes can be done prior to the end of your transaction, if you wish, to minimize (cont.)
resource consumption.
Batch programs also have their files closed implicitly at end-of-job. You can issue explicit closes to enable reopening (cont.)
the file differently. For example, if you have created a new file by opening for output, you may want to close it and (cont.)
reopen it using OPENU to be able to access and update records on that file.
The *CLSE command will close all files that are open and will issue a COMMIT to ensure that all data is flushed from file buffers and saved to disk.
The CLSFL, or CLOSE (they are synonyms) commands will close an individual file.
#
Appendix H -- Sequential Files
To define a sequential file to MAGEC, use the access method SEQDS, SEQCMPR, OR SEQCRLF on the DCL definition. SEQDS (cont.)
specifies a fixed-length, non-compressed file. SEQCMPR specifies a compressed sequential file using the intrinsic (cont.)
compression facilities of the environments file systems (usually, MicroFocus Cobol). SEQCRLF specifies a sequential (cont.)
text file using Carriage Return-Line Feed ASCII characters to denote end-of-record.
Sequential files can be accessed using MAGECIO, however only certain commands can be issued against them. Obviously, (cont.)
without an index many of the facilities available to VSAM or other indexed access methods cannot be (cont.)
provided.
All of the explicit open commands are supported for sequential files, including OPENE, but excluding OPENI.
All of the close commands are supported.
The only read command supported is REDNX, which, for a sequential file requires no prerequisite except for an open.
The ADDIT command is used to write to a sequential file.The file must have been opened using OPENE.
The UPDAT command is used to rewrite a record to a sequential file.
If you issue a database command that is not supported for sequential files, though it is a valid command for other file types, you will be issued a return code of '1S' in TWA-DB-RETURN-CODE.
##
Generic File Names
MAGEC in the PC environment allows you to define and access files using generic names. A generic name is one which (cont.)
includes one or more (maximum 7) question marks as the trailing characters of the file name. For example: (cont.)
FILE???.TXT.
At the time that your program first accesses the file using either an explicit or implicit open (REDNX, OPENR, or (cont.)
OPENX) MAGEC's IO module will access the directory of the PC file system (may be either a LAN or local file) to (cont.)
determine whether there are any files whose names match the generic name given, and which file name to use. In the case (cont.)
of an input file that means that there may be several files with matching names, i.e.: FILE001.TXT, FILE002.TXT, (cont.)
FILE003.TXT, etc.
The IO module will access the directory and will open the first (lowest in collating sequence) file. In this example (cont.)
FILE001.TXT. When you program reads to the physical end of FILE001.TXT, the IO module will again access the directory (cont.)
to obtain the next lowest file name and will open it as if it were concatenated to the first file, and so (cont.)
forth.
In order to avoid conflicts, the IO module renames the input file using an extension of "_IN" before opening it, and (cont.)
renames it using another extension immediately after it is closed. The extension used for this final rename operation (cont.)
is taken from the KYF description in the "Extension after file is processed" specification. The extension given here (cont.)
should not be the same as the original extension and should not be "_IN". For example, a good choice for Extension (cont.)
after file is processed would be "DUN" (for "done").
As you can see, using this scheme would mean that the IO module would first find FILE001.TXT, rename it to FILE001._IN, (cont.)
and open it for your program. When you have read through that file, it would rename it as FILE001.DUN and re-access the (cont.)
directory to find the new lowest file name matching the FILE???.TXT generic name. That would probably be ("probably" (cont.)
because of the possibility for multiple workstations to be performing the same process as discussed below) FILE002.TXT. (cont.)
Your program will read through several concatenated files as if they were one.
##
Multiple Concurrent Processing
Using this scheme it is possible for several (unlimited number) of workstations attached to a server to concurrently (cont.)
process a "pool" of transaction files. The same program could be executing on each workstation processing the (cont.)
transactions against the same database or master files. Since the files are renamed before and after processing, other (cont.)
workstations will not recognize them as input files. Therefore, one workstation might process FILE001.TXT, then another (cont.)
might begin processing FILE002.TXT. When the first reaches the physical end of FILE001 it will automatically begin (cont.)
processing FILE003.TXT.
##
Generic Output Files
In the case of generic file names for output files, the IO module will access the directory to determine the highest (cont.)
file name which currently exists matching the generic name. It will add one to the numeric (generic) portion of the (cont.)
file name and will open it for output using a temporary extension of "_OT". When your program closes the file the IO (cont.)
module renames it using the extension specified in the File specification,
not the "Extension after file is processed"!
Multiple workstations could be creating files using the generic name and each will automatically use a unique name. (cont.)
They would likely be creating a pool of transaction files which will later be accessed as described (cont.)
above.
If you wish to write files using generic names your program must issue an explicit OPENO and an explicit CLOSE command.
##
Generic Name Formats
Only sequential files may be specified using generic file names. Indexed files may not. Sequential files are defined using the access methods: SEQDS, SEQCMPR, or SEQCRLF on the DCL definition.
A generic name is any name including question mark characters (?) as the last characters of the name (not the (cont.)
extension). The question marks must be contiguous and may not be followed by any other character, except for the dot (cont.)
(.) which separates the name from the extension. There may be from one to seven question marks. The actual file names (cont.)
represented by the generic name must have numeric characters (1 - 9) in the positions held by the question marks. For (cont.)
example:
A???????.TXT (files: A0000001 thru A9999999)
TRANS??.INP (files: TRANS01 thru TRANS99).